(
data: MothershipStreamV1ToolCallDescriptor,
context: StreamingContext,
execContext: ExecutionContext,
options: OrchestratorOptions,
parentToolCallId: string | undefined,
scope: ToolScope,
spanIdentity: { spanId?: string; parentSpanId?: string }
)
| 240 | } |
| 241 | |
| 242 | async function handleCallPhase( |
| 243 | data: MothershipStreamV1ToolCallDescriptor, |
| 244 | context: StreamingContext, |
| 245 | execContext: ExecutionContext, |
| 246 | options: OrchestratorOptions, |
| 247 | parentToolCallId: string | undefined, |
| 248 | scope: ToolScope, |
| 249 | spanIdentity: { spanId?: string; parentSpanId?: string } |
| 250 | ): Promise<void> { |
| 251 | const { toolCallId, toolName } = data |
| 252 | const args = data.arguments |
| 253 | const isGenerating = data.status === TOOL_CALL_STATUS.generating |
| 254 | const isPartial = data.partial === true || isGenerating |
| 255 | const existing = context.toolCalls.get(toolCallId) |
| 256 | const isSubagent = scope === 'subagent' |
| 257 | const ui = getToolCallUI(data) |
| 258 | |
| 259 | if (isPartial && shouldDelayVfsPlaceholder(toolName, args)) return |
| 260 | |
| 261 | if (isSubagent) { |
| 262 | if (wasToolResultSeen(toolCallId) || existing?.endTime) { |
| 263 | if (existing && !existing.name && toolName) existing.name = toolName |
| 264 | if (existing && !existing.params && args) existing.params = args |
| 265 | applyToolDisplay(existing) |
| 266 | return |
| 267 | } |
| 268 | } else { |
| 269 | if ( |
| 270 | existing?.endTime || |
| 271 | (existing && existing.status !== 'pending' && existing.status !== 'executing') |
| 272 | ) { |
| 273 | if (!existing.name && toolName) existing.name = toolName |
| 274 | if (!existing.params && args) existing.params = args |
| 275 | applyToolDisplay(existing) |
| 276 | return |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | if (isSubagent) { |
| 281 | registerSubagentToolCall( |
| 282 | context, |
| 283 | toolCallId, |
| 284 | toolName, |
| 285 | args, |
| 286 | parentToolCallId!, |
| 287 | ui, |
| 288 | spanIdentity |
| 289 | ) |
| 290 | } else { |
| 291 | registerMainToolCall(context, toolCallId, toolName, args, existing, ui) |
| 292 | } |
| 293 | |
| 294 | if (isPartial) return |
| 295 | if (!isSubagent && wasToolResultSeen(toolCallId)) return |
| 296 | if (context.pendingToolPromises.has(toolCallId) || existing?.status === 'executing') { |
| 297 | return |
| 298 | } |
| 299 |
no test coverage detected