summaryrefslogtreecommitdiffhomepage
path: root/packages/kernel/src/runtime/events.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-06 21:29:52 +0900
committerAdam Malczewski <[email protected]>2026-06-06 21:29:52 +0900
commit2c5bc242a8a99e3b863c247f70b26f5883333677 (patch)
treece938fbef47d8dab44bfe5cce68ebfac7a91ca8a /packages/kernel/src/runtime/events.ts
parentfedf9c2695476e9ee6f95776b0244acfc37f022f (diff)
downloaddispatch-2c5bc242a8a99e3b863c247f70b26f5883333677.tar.gz
dispatch-2c5bc242a8a99e3b863c247f70b26f5883333677.zip
feat(kernel-runtime,session-orchestrator): emit turn lifecycle events
Close a gap found live: neither transport emitted turn-start/done/turn-sealed (the wire defined them; nothing fired them). turn-sealed is the FE's cache-commit signal (frontend-design §6.3); done ends the stream. - kernel-runtime: runTurn emits turn-start first and done (with finishReason) last, on every exit path (stop/tool-calls/max-steps/error/aborted). - session-orchestrator: emits turn-sealed after conversationStore.append succeeds (the kernel touches no DB, so the post-persist seal is the orchestrator's). Not emitted if append throws. No contract change (all three wire types already existed). Verified live: HTTP /chat and WS chat both stream turn-start … done turn-sealed. typecheck clean, 494 vitest + 80 bun, biome clean.
Diffstat (limited to 'packages/kernel/src/runtime/events.ts')
-rw-r--r--packages/kernel/src/runtime/events.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/packages/kernel/src/runtime/events.ts b/packages/kernel/src/runtime/events.ts
index 2a92008..a209b00 100644
--- a/packages/kernel/src/runtime/events.ts
+++ b/packages/kernel/src/runtime/events.ts
@@ -48,6 +48,14 @@ export function usageEvent(conversationId: string, turnId: string, usage: Usage)
return { type: "usage", conversationId, turnId, usage };
}
+export function turnStartEvent(conversationId: string, turnId: string): AgentEvent {
+ return { type: "turn-start", conversationId, turnId };
+}
+
+export function doneEvent(conversationId: string, turnId: string, reason: string): AgentEvent {
+ return { type: "done", conversationId, turnId, reason };
+}
+
export function errorEvent(
conversationId: string,
turnId: string,