MCPcopy Create free account
hub / github.com/apache/maka / buildSubagentSpawnTool

Function buildSubagentSpawnTool

packages/runtime/src/subagent-tools.ts:72–296  ·  view source on GitHub ↗
(
  deps: { taskLedger?: TaskLedgerStore; definitions?: readonly AgentDefinition[] } = {},
)

Source from the content-addressed store, hash-verified

70}
71
72export 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.'),

Callers 2

buildParentAgentToolsFunction · 0.85

Calls 12

observeMethod · 0.95
cleanSubagentSpawnInputFunction · 0.85
resolvePresetDefinitionFunction · 0.85
boundedChildErrorFunction · 0.85
joinMethod · 0.80
spawnChildSessionMethod · 0.80
getMethod · 0.65
claimMethod · 0.65
settleAgentOutcomeMethod · 0.65

Tested by

no test coverage detected