"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const registry_1 = require("./registry"); (0, registry_1.registerTool)({ name: 'spawn_agent', description: 'Dispatch a sub-agent job to run in the background. Returns a job ID. Use this to delegate specialized work to Coder, PM, or Marketing agents.', parameters: { type: 'object', properties: { agent: { type: 'string', description: '"Coder", "PM", or "Marketing"' }, task: { type: 'string', description: 'Detailed task description for the agent' }, repo: { type: 'string', description: 'Gitea repo in "owner/name" format the agent should work on' } }, required: ['agent', 'task', 'repo'] }, async handler(args, _ctx) { const runnerUrl = process.env.AGENT_RUNNER_URL || 'http://localhost:3333'; try { const res = await fetch(`${runnerUrl}/api/agent/run`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Internal': 'true' }, body: JSON.stringify({ agent: args.agent, task: args.task, repo: args.repo }) }); const data = await res.json(); return { jobId: data.jobId, agent: args.agent, status: 'dispatched' }; } catch (err) { return { error: `Failed to spawn agent: ${err instanceof Error ? err.message : String(err)}` }; } } }); (0, registry_1.registerTool)({ name: 'get_job_status', description: 'Check the status of a previously spawned agent job by job ID.', parameters: { type: 'object', properties: { job_id: { type: 'string', description: 'Job ID returned by spawn_agent' } }, required: ['job_id'] }, async handler(args, _ctx) { const runnerUrl = process.env.AGENT_RUNNER_URL || 'http://localhost:3333'; try { const res = await fetch(`${runnerUrl}/api/jobs/${String(args.job_id)}`); const job = await res.json(); return { id: job.id, agent: job.agent, status: job.status, progress: job.progress, toolCalls: job.toolCalls?.length, result: job.result, error: job.error }; } catch (err) { return { error: `Failed to get job: ${err instanceof Error ? err.message : String(err)}` }; } } });