( context: StreamingContext, toolCallId: string, endTime: number )
| 226 | } |
| 227 | |
| 228 | function stampToolCallBlockEnd( |
| 229 | context: StreamingContext, |
| 230 | toolCallId: string, |
| 231 | endTime: number |
| 232 | ): void { |
| 233 | for (let i = context.contentBlocks.length - 1; i >= 0; i--) { |
| 234 | const block = context.contentBlocks[i] |
| 235 | if (block.type === 'tool_call' && block.toolCall?.id === toolCallId) { |
| 236 | if (block.endedAt === undefined) block.endedAt = endTime |
| 237 | return |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | async function handleCallPhase( |
| 243 | data: MothershipStreamV1ToolCallDescriptor, |