feat: Sessions primitive — durable run-aware streams + dashboard

Adds Sessions, a durable, run-aware stream primitive that scopes
session.in / session.out records to a session (not a single run).
Records survive run boundaries; reconnect-from-last-event-id is built in.

Server foundation:
- New /realtime/v1/sessions/:session/:io/append + /records routes
- sessionRunManager + sessionsRepository + clickhouseSessionsRepository
- mintRunToken for short-lived per-session tokens
- s2Append retry-with-backoff + undici cause diagnostics
- /api/v[12]/packets/* exempt from customer rate limits
- BackgroundWorker schema gains taskKind enum (TASK, AGENT, SCHEDULED)
- TaskRun.taskKind column + clickhouse 029_add_task_kind_to_task_runs_v2

Core types:
- new sessionStreams, inputStreams, realtimeStreams packages in @trigger.dev/core
- session-streams-api / realtime-streams-api surface

Sessions dashboard UI (the primitive's own viewer):
- /sessions index + detail routes
- SessionsTable, SessionFilters, SessionStatus, CloseSessionDialog
- AGENT/SCHEDULED filter in RunFilters + TaskTriggerSource

Includes the sessions-primitive changeset.
This commit is contained in:
Eric Allam
2026-05-10 22:26:11 +01:00
parent 8ba067d8b0
commit be1a6cf8de
96 changed files with 6290 additions and 204 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---
Add `ChatChunkTooLargeError` and ApiClient methods for subscribing to session streams. Lays the groundwork for the upcoming `chat.agent`.
+9
View File
@@ -0,0 +1,9 @@
---
"@trigger.dev/sdk": minor
"@trigger.dev/core": patch
---
Adds the Sessions primitive — a durable, run-aware stream channel keyed
on a stable `externalId`. Public SDK additions: `tasks.triggerAndSubscribe()`
and the `chat.agent` runtime built on top of Sessions. See
https://trigger.dev/docs/ai-chat/overview for the full feature surface.