(
runtime: PiRuntime,
runtimeKey: string | null,
event: Extract<RuntimeSessionEvent, { type: 'message_end' }>,
)
| 127 | } |
| 128 | |
| 129 | function handleRuntimeMessageEnd( |
| 130 | runtime: PiRuntime, |
| 131 | runtimeKey: string | null, |
| 132 | event: Extract<RuntimeSessionEvent, { type: 'message_end' }>, |
| 133 | ) { |
| 134 | if (event.message.role === 'user') { |
| 135 | cancelLiveThreadUpdate(runtime) |
| 136 | void publishThreadUpdate(runtime, 'start') |
| 137 | } else { |
| 138 | if (event.message.role === 'toolResult') { |
| 139 | const toolCallId = 'toolCallId' in event.message ? event.message.toolCallId : undefined |
| 140 | clearRuntimeToolProgress(runtime, { |
| 141 | toolCallId: typeof toolCallId === 'string' ? toolCallId : undefined, |
| 142 | toolName: event.message.toolName, |
| 143 | }) |
| 144 | } |
| 145 | deferLiveThreadUpdate(runtime, publishLiveThreadUpdate, { |
| 146 | requireStreaming: event.message.role === 'toolResult', |
| 147 | }) |
| 148 | } |
| 149 | if (runtimeKey) scheduleRuntimeDisposal(runtimeKey, isHowcodeRuntimeBusy) |
| 150 | } |
| 151 | |
| 152 | function handleRuntimeAgentEnd(runtime: PiRuntime, runtimeKey: string | null) { |
| 153 | cancelLiveThreadUpdate(runtime) |
no test coverage detected