(
deps: { taskLedger?: TaskLedgerStore; definitions?: readonly AgentDefinition[] } = {},
)
| 70 | } |
| 71 | |
| 72 | export function buildSubagentSpawnTool( |
| 73 | deps: { taskLedger?: TaskLedgerStore; definitions?: readonly AgentDefinition[] } = {}, |
| 74 | ): MakaTool< |
| 75 | { |
| 76 | profile?: string; |
| 77 | subagent_id?: string; |
| 78 | task: string; |
| 79 | write_back?: string; |
| 80 | isolation?: string; |
| 81 | task_id?: string; |
| 82 | }, |
| 83 | unknown |
| 84 | > { |
| 85 | const definitions = deps.definitions ?? BUILTIN_AGENT_DEFINITIONS; |
| 86 | const profiles = agentProfilesForDefinitions(definitions); |
| 87 | return { |
| 88 | name: AGENT_SPAWN_TOOL_NAME, |
| 89 | displayName: 'Agent', |
| 90 | description: |
| 91 | 'Run one bounded foreground child task. Prefer agent_list, then select the user-approved subagent_id whose description fits the task; profile is retained for legacy callers. If both selectors are present, subagent_id wins and profile is ignored.', |
| 92 | parameters: z.preprocess( |
| 93 | (input) => cleanSubagentSpawnInput(input, deps.taskLedger !== undefined), |
| 94 | z |
| 95 | .object({ |
| 96 | profile: z.enum(profiles).optional().describe('Legacy child capability profile.'), |
| 97 | subagent_id: z |
| 98 | .string() |
| 99 | .min(1) |
| 100 | .max(128) |
| 101 | .refine(isSafeSubagentPresetId) |
| 102 | .optional() |
| 103 | .describe('User-approved subagent preset id from agent_list.'), |
| 104 | task: z |
| 105 | .string() |
| 106 | .min(1) |
| 107 | .max(60_000) |
| 108 | .describe('Bounded task for the selected child agent.'), |
| 109 | write_back: z |
| 110 | .enum(AGENT_SPAWN_WRITE_BACK_MODES) |
| 111 | .optional() |
| 112 | .describe( |
| 113 | 'Requested child write-back mode. Each built-in profile declares its supported modes.', |
| 114 | ), |
| 115 | isolation: z |
| 116 | .enum(AGENT_SPAWN_ISOLATION_MODES) |
| 117 | .optional() |
| 118 | .describe( |
| 119 | 'Requested child workspace isolation. Worktree profiles fail closed until a worktree child executor is available.', |
| 120 | ), |
| 121 | ...(deps.taskLedger |
| 122 | ? { |
| 123 | task_id: z |
| 124 | .string() |
| 125 | .min(1) |
| 126 | .max(TASK_ID_MAX_CHARS) |
| 127 | .refine(isSafeTaskId) |
| 128 | .optional() |
| 129 | .describe('Existing task UUID or short key to bind to this child run.'), |
no test coverage detected