153
*/
154
export function buildTopLevelSubagentReadyAction(
155
>
block: Extract<import('@anthropic-ai/claude-agent-sdk').SDKAssistantMessage['message']['content'][number], { type: 'tool_use' }>,
claudeSubagentSignals.ts
156
>
chat: URI,
157
>
turnId: string,
158
>
registry: SubagentRegistry,
159
>
): AgentSignal {
160
>
const input = block.input as Record<string, unknown> | undefined;
161
>
const description = typeof input?.description === 'string' ? input.description : undefined;
162
>
const agentName = typeof input?.subagent_type === 'string' ? input.subagent_type : undefined;
163
>
const prompt = typeof input?.prompt === 'string' ? input.prompt : undefined;
164
>
const inputJson = block.input !== undefined ? safeStringify(block.input) : undefined;
165
>
registry.recordSpawn(block.id, { subagentType: agentName, description, prompt });
166
>
const meta: Mutable<IToolCallMeta> = { ...buildClaudeToolCallMeta(block.name) };
167
>
if (!meta.toolKind) {
168
meta.toolKind = 'subagent';
169
}
171
meta.subagentDescription = description;
172
}
174
meta.subagentAgentName = agentName;
175
}
177
>
kind: 'action',
178
>
resource: chat,
179
>
action: {
180
>
type: ActionType.ChatToolCallReady,
181
>
turnId,
182
>
toolCallId: block.id,
183
>
invocationMessage: getClaudeInvocationMessage(block.name, getClaudeToolDisplayName(block.name), block.input),
184
>
...(inputJson !== undefined ? { toolInput: inputJson } : {}),
185
>
confirmed: ToolCallConfirmationReason.NotNeeded,
186
>
_meta: toToolCallMeta(meta),
187
>
},
188
>
};
189
>
}
190
191
/**