(runtime: PiRuntime, event: RuntimeSessionEvent)
| 186 | } |
| 187 | |
| 188 | function handleRuntimeSessionEvent(runtime: PiRuntime, event: RuntimeSessionEvent) { |
| 189 | const runtimeKey = getPersistedSessionPath(runtime.session.sessionFile) |
| 190 | if (runtimeKey) suspendRuntimeDisposal(runtimeKey) |
| 191 | if (event.type === 'message_start' || event.type === 'message_update') |
| 192 | return scheduleLiveThreadUpdate(runtime, publishLiveThreadUpdate) |
| 193 | if (event.type === 'message_end') return handleRuntimeMessageEnd(runtime, runtimeKey, event) |
| 194 | if (event.type === 'agent_end') return handleRuntimeAgentEnd(runtime, runtimeKey) |
| 195 | if (event.type === 'compaction_start') { |
| 196 | cancelLiveThreadUpdate(runtime) |
| 197 | void publishThreadUpdate(runtime, 'compaction-start') |
| 198 | void publishRuntimeComposerState(runtime) |
| 199 | return |
| 200 | } |
| 201 | if (event.type === 'compaction_end') return handleRuntimeCompactionEnd(runtime, runtimeKey) |
| 202 | if ( |
| 203 | event.type === 'tool_execution_start' || |
| 204 | event.type === 'tool_execution_update' || |
| 205 | event.type === 'tool_execution_end' |
| 206 | ) |
| 207 | return handleRuntimeToolEvent(runtime, event) |
| 208 | if (event.type === 'queue_update') |
| 209 | void publishRuntimeComposerState(runtime).finally(() => { |
| 210 | if (runtimeKey && !runtime.session.isStreaming) |
| 211 | scheduleRuntimeDisposal(runtimeKey, isHowcodeRuntimeBusy) |
| 212 | }) |
| 213 | } |
| 214 | |
| 215 | async function createRuntime(options: { |
| 216 | cwd: string |
no test coverage detected