From 2c5bc242a8a99e3b863c247f70b26f5883333677 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Sat, 6 Jun 2026 21:29:52 +0900 Subject: feat(kernel-runtime,session-orchestrator): emit turn lifecycle events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- packages/kernel/src/runtime/events.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'packages/kernel/src/runtime/events.ts') 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, -- cgit v1.2.3