refactor(chat-runtime): AdapterEvent uses `type`, like DurableEvent

Approval required
SU
24d ago
+308-321

Summary

  • AdapterEvent now uses type: like DurableEvent, instead of a parallel union keyed on kind:. Every adapter, LiveSession and the event-queue tests speak one vocabulary: item | turn | session, with delta as the only extra case.
  • LiveSession journals item and turn events as the adapter sent them, instead of rebuilding each one. FakeHarness.stripDelay drops its per-case copy.

Why

The two unions had the same item and turn shapes under different discriminator names, so every hop rebuilt the object and a reader had to remember which key applied where. They still differ in two ways, and those stay: session is a partial patch from the adapter (LiveSession merges it into full state), and delta is live-only and never journaled.

Compatibility

AdapterEvent never leaves the host. The wire format (Envelope) and the journal (DurableEvent) are unchanged, so released clients and stored chat.db rows are not affected.

How the change was made

  • The field was renamed only at the positions tsc reported as .kind on AdapterEvent or ScriptedEvent, so item.kind, source.kind and timeline entry.kind were not touched.
  • Afterwards I searched for .kind === "item"|"turn"|"session"|"delta" reads through untyped values. That found host-service/scripts/acp-smoke.ts, which is outside the typecheck, and it's updated too.

Testing

  • bun run typecheck: chat-runtime, chat, host-service
  • bun test: chat-runtime (375 pass, 2 skipped), chat (94 pass), host-service trpc/router/sessions and chat-v3 (56 pass)
  • biome check on changed files