feat: @mosaic/coord — migrate from v0, gateway integration (P2-005) (#77)
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #77.
This commit is contained in:
@@ -3,9 +3,11 @@ import { AgentService } from './agent.service.js';
|
||||
import { ProviderService } from './provider.service.js';
|
||||
import { RoutingService } from './routing.service.js';
|
||||
import { ProvidersController } from './providers.controller.js';
|
||||
import { CoordModule } from '../coord/coord.module.js';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [CoordModule],
|
||||
providers: [ProviderService, RoutingService, AgentService],
|
||||
controllers: [ProvidersController],
|
||||
exports: [AgentService, ProviderService, RoutingService],
|
||||
|
||||
@@ -8,8 +8,10 @@ import {
|
||||
} from '@mariozechner/pi-coding-agent';
|
||||
import type { Brain } from '@mosaic/brain';
|
||||
import { BRAIN } from '../brain/brain.tokens.js';
|
||||
import { CoordService } from '../coord/coord.service.js';
|
||||
import { ProviderService } from './provider.service.js';
|
||||
import { createBrainTools } from './tools/brain-tools.js';
|
||||
import { createCoordTools } from './tools/coord-tools.js';
|
||||
|
||||
export interface AgentSessionOptions {
|
||||
provider?: string;
|
||||
@@ -36,8 +38,9 @@ export class AgentService implements OnModuleDestroy {
|
||||
constructor(
|
||||
private readonly providerService: ProviderService,
|
||||
@Inject(BRAIN) private readonly brain: Brain,
|
||||
private readonly coordService: CoordService,
|
||||
) {
|
||||
this.customTools = createBrainTools(brain);
|
||||
this.customTools = [...createBrainTools(brain), ...createCoordTools(coordService)];
|
||||
this.logger.log(`Registered ${this.customTools.length} custom tools`);
|
||||
}
|
||||
|
||||
|
||||
81
apps/gateway/src/agent/tools/coord-tools.ts
Normal file
81
apps/gateway/src/agent/tools/coord-tools.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { Type } from '@sinclair/typebox';
|
||||
import type { ToolDefinition } from '@mariozechner/pi-coding-agent';
|
||||
import type { CoordService } from '../../coord/coord.service.js';
|
||||
|
||||
export function createCoordTools(coordService: CoordService): ToolDefinition[] {
|
||||
const getMissionStatus: ToolDefinition = {
|
||||
name: 'coord_mission_status',
|
||||
label: 'Mission Status',
|
||||
description:
|
||||
'Get the current orchestration mission status including milestones, tasks, and active session.',
|
||||
parameters: Type.Object({
|
||||
projectPath: Type.Optional(
|
||||
Type.String({ description: 'Project path. Defaults to gateway working directory.' }),
|
||||
),
|
||||
}),
|
||||
async execute(_toolCallId, params) {
|
||||
const { projectPath } = params as { projectPath?: string };
|
||||
const resolvedPath = projectPath ?? process.cwd();
|
||||
const status = await coordService.getMissionStatus(resolvedPath);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: 'text' as const,
|
||||
text: status ? JSON.stringify(status, null, 2) : 'No active coord mission found.',
|
||||
},
|
||||
],
|
||||
details: undefined,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
const listCoordTasks: ToolDefinition = {
|
||||
name: 'coord_list_tasks',
|
||||
label: 'List Coord Tasks',
|
||||
description: 'List all tasks from the orchestration TASKS.md file.',
|
||||
parameters: Type.Object({
|
||||
projectPath: Type.Optional(
|
||||
Type.String({ description: 'Project path. Defaults to gateway working directory.' }),
|
||||
),
|
||||
}),
|
||||
async execute(_toolCallId, params) {
|
||||
const { projectPath } = params as { projectPath?: string };
|
||||
const resolvedPath = projectPath ?? process.cwd();
|
||||
const tasks = await coordService.listTasks(resolvedPath);
|
||||
return {
|
||||
content: [{ type: 'text' as const, text: JSON.stringify(tasks, null, 2) }],
|
||||
details: undefined,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
const getCoordTaskDetail: ToolDefinition = {
|
||||
name: 'coord_task_detail',
|
||||
label: 'Coord Task Detail',
|
||||
description: 'Get detailed status for a specific orchestration task.',
|
||||
parameters: Type.Object({
|
||||
taskId: Type.String({ description: 'Task ID (e.g. P2-005)' }),
|
||||
projectPath: Type.Optional(
|
||||
Type.String({ description: 'Project path. Defaults to gateway working directory.' }),
|
||||
),
|
||||
}),
|
||||
async execute(_toolCallId, params) {
|
||||
const { taskId, projectPath } = params as { taskId: string; projectPath?: string };
|
||||
const resolvedPath = projectPath ?? process.cwd();
|
||||
const detail = await coordService.getTaskStatus(resolvedPath, taskId);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: 'text' as const,
|
||||
text: detail
|
||||
? JSON.stringify(detail, null, 2)
|
||||
: `Task ${taskId} not found in coord mission.`,
|
||||
},
|
||||
],
|
||||
details: undefined,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
return [getMissionStatus, listCoordTasks, getCoordTaskDetail];
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export { createBrainTools } from './brain-tools.js';
|
||||
export { createCoordTools } from './coord-tools.js';
|
||||
|
||||
Reference in New Issue
Block a user