Skip to content
Open
Show file tree
Hide file tree
Changes from 135 commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
ddfe8b0
feat: add @trigger.dev/ai package with TriggerChatTransport
cursoragent Feb 15, 2026
4703275
test: add comprehensive unit tests for TriggerChatTransport
cursoragent Feb 15, 2026
8c2eeac
refactor: polish TriggerChatTransport implementation
cursoragent Feb 15, 2026
7efbc8a
test: add abort signal, multiple sessions, and body merging tests
cursoragent Feb 15, 2026
2ec57d9
chore: add changeset for @trigger.dev/ai package
cursoragent Feb 15, 2026
fab2775
refactor: remove internal ChatSessionState from public exports
cursoragent Feb 15, 2026
75aa8ca
feat: support dynamic accessToken function for token refresh
cursoragent Feb 15, 2026
8a8db47
refactor: avoid double-resolving accessToken in sendMessages
cursoragent Feb 15, 2026
c967cec
feat: add chat transport and AI chat helpers to @trigger.dev/sdk
cursoragent Feb 15, 2026
9875da6
test: move chat transport tests to @trigger.dev/sdk
cursoragent Feb 15, 2026
7a86a8b
refactor: delete packages/ai/ — moved to @trigger.dev/sdk subpaths
cursoragent Feb 15, 2026
9c0a654
chore: update changeset to target @trigger.dev/sdk
cursoragent Feb 15, 2026
ca5bc1d
fix: address CodeRabbit review feedback
cursoragent Feb 15, 2026
875db7d
docs(ai): add AI Chat with useChat guide
cursoragent Feb 15, 2026
a018b4e
feat(reference): add ai-chat Next.js reference project
cursoragent Feb 15, 2026
22bafda
fix(reference): use compatible @ai-sdk v3 packages, await convertToMo…
cursoragent Feb 15, 2026
22df2f2
Use a single run with iterative waitpoint token completions
ericallam Feb 21, 2026
c940299
Added tool example
ericallam Feb 21, 2026
155df4e
expose a useTriggerChatTransport hook
ericallam Feb 21, 2026
a0b5411
use input streams and rename chatTask and chatState to chat.task and …
ericallam Mar 3, 2026
533751f
add stopping support and fix issue with the OpenAI responses API and …
ericallam Mar 4, 2026
d03159d
Add warmTimeoutInSeconds option
ericallam Mar 4, 2026
23b510a
Add clientData support
ericallam Mar 4, 2026
b5be97a
provide already converted UIMessages to the run function for better dx
ericallam Mar 4, 2026
34f045a
Added better telemetry support to view turns
ericallam Mar 4, 2026
7a46e2e
Fix double looping when resuming from an input stream waitpoint
ericallam Mar 4, 2026
aeb0987
Add some pending message support in the example
ericallam Mar 4, 2026
29a2240
Accumulate messages in the task, allowing us to only have to send use…
ericallam Mar 5, 2026
d5d9334
build full example with persisting messages, adding necessary hooks, …
ericallam Mar 5, 2026
2b4d74f
Add ai chat to the sidebar for now
ericallam Mar 5, 2026
bf4b7d1
remove postinstall hook
ericallam Mar 5, 2026
77fae75
feat: add onTurnStart hook, lastEventId support, and stream resume de…
ericallam Mar 5, 2026
e11a188
Minor fixes around reconnecting streams
ericallam Mar 6, 2026
bcbecf2
update pnpm link file
ericallam Mar 6, 2026
2eccccc
fixed chat tests
ericallam Mar 6, 2026
7681349
use locals for the chat pipe counter instead of a module global
ericallam Mar 6, 2026
90f787c
Add triggerOptions to the transport, auto-tag with the chat ID
ericallam Mar 6, 2026
053006d
Make clientData typesafe and pass to all chat.task hooks
ericallam Mar 6, 2026
34ce5ad
feat: add chat.local for per-run typed data with Proxy access and dir…
ericallam Mar 6, 2026
be1da50
feat(chat): add stop handling, abort cleanup, continuation support, a…
ericallam Mar 7, 2026
1d6f66d
Some improvements to the example ai-chat
ericallam Mar 7, 2026
d495f9b
feat(chat): expose typed chat.stream, add deepResearch subtask exampl…
ericallam Mar 8, 2026
c12217e
feat(ai): pass chat context and toolCallId to subtasks, add typed ai.…
ericallam Mar 8, 2026
d1141a7
feat(chat): add preload support, dynamic tools, and preload-specific …
ericallam Mar 9, 2026
d34c193
docs: add mermaid architecture diagrams for ai-chat system
ericallam Mar 9, 2026
1820ab8
docs: add sequence diagrams to ai-chat guide
ericallam Mar 9, 2026
047a7fc
feat(chat): auto-hydrate chat.local values in ai.tool subtasks
ericallam Mar 9, 2026
0c13efb
feat(chat): add chat.defer(), preload toggle, TTFB measurement, and f…
ericallam Mar 9, 2026
29d90fd
fix(reference): replace hand-rolled HTML stripping with turndown
ericallam Mar 9, 2026
501154c
feat(streams): add inputStream.waitWithWarmup(), warm timeout config …
ericallam Mar 9, 2026
96dd818
feat(chat): add composable primitives, raw task example, and task mod…
ericallam Mar 10, 2026
81000b2
Introduce the chat session API and better docs organization
ericallam Mar 10, 2026
59158ad
Add support for toUIMessageStream() options
ericallam Mar 10, 2026
bb88d68
Add metadata to the streamText call
ericallam Mar 12, 2026
bf12ffa
feat(chat): add chat.prompt API with provider registry support
ericallam Mar 23, 2026
cebd32a
refactor: rename warmTimeout to idleTimeout across chat APIs
ericallam Mar 23, 2026
df72282
feat: support message compaction
ericallam Mar 24, 2026
47b06f6
better compaction support in our other chat variants
ericallam Mar 24, 2026
81d52e9
feat(chat): add compaction option, pendingMessages steering, and useP…
ericallam Mar 25, 2026
168466f
Add a writer to easily write chunks in callbacks
ericallam Mar 26, 2026
882d042
feat(ai): add triggerAndSubscribe method and use it in ai.tool
ericallam Mar 26, 2026
9c883f5
feat(chat): add chat.inject() for background context injection and ch…
ericallam Mar 26, 2026
b0815a1
feat(sdk): ToolSet typing for toolFromTask, ai.toolExecute, deprecate…
ericallam Mar 27, 2026
c088ec2
Add run-scoped PAT renewal for chat transport
ericallam Mar 27, 2026
0680744
feat(sdk): ctx on chat.task hooks; ai-chat E2B sandbox; docs patterns
ericallam Mar 27, 2026
a94465b
feat(sdk): add onChatSuspend/onChatResume hooks, exitAfterPreloadIdle…
ericallam Mar 28, 2026
ca4680f
Add support for triggering from the backend
ericallam Mar 28, 2026
2d6a6ac
chat.task -> chat.agent
ericallam Mar 30, 2026
3c4e020
feat: upgrade streamdown to v2.5.0 with custom Trigger.dev Shiki theme
ericallam Apr 1, 2026
8d4ab08
playground ui tweaks
ericallam Apr 1, 2026
dc62707
Some design tweaks, improvements to playground options, rename unname…
ericallam Apr 1, 2026
eb387c5
Add the chat client and strip agent crumbs
ericallam Apr 1, 2026
6c1379e
Add server-to-server chat support and subagent support to the playgro…
ericallam Apr 2, 2026
76842a7
add agent mcp tools
ericallam Apr 2, 2026
edf9d2d
Add support for optionally validating UI messages
ericallam Apr 2, 2026
0425209
Support for upgrading an agent to a new version
ericallam Apr 3, 2026
6c67702
Add run agent view
ericallam Apr 10, 2026
06799b7
feat(chat): add stopGeneration, fix onTurnComplete/onFinishPromise, a…
ericallam Apr 11, 2026
4a40cab
fix(sdk): inject prepareStep in toStreamTextOptions even without chat…
ericallam Apr 13, 2026
f1e20cf
feat(chat): allow generateMessageId in uiMessageStreamOptions, auto-p…
ericallam Apr 14, 2026
246dc07
feat(chat): tool approvals support — ID-matched message replacement, …
ericallam Apr 14, 2026
771b754
fix: restore applyPrepareMessages call after agentcrumbs strip
ericallam Apr 14, 2026
6cc08f2
prevent preloads from firing twice when in React strictMode
ericallam Apr 14, 2026
d5935e6
feat(chat): add chat.response API for persistent data parts, transien…
ericallam Apr 14, 2026
8780da7
feat(chat): add hydrateMessages, chat.history, and custom actions
ericallam Apr 15, 2026
8f3c331
fix(chat): prevent useChat resume from hanging on completed turns
ericallam Apr 15, 2026
1e95317
fix pnpm lock file
ericallam Apr 16, 2026
6e59e91
feat(ai-chat): add askUser tool for HITL testing, verify TRI-8556 fix
ericallam Apr 17, 2026
1d632e2
chore(ai-chat): remove test-big-error trigger from onValidateMessages
ericallam Apr 17, 2026
4e9abbc
feat(chat): multi-tab coordination via BroadcastChannel
ericallam Apr 17, 2026
77ed732
fix(ai-chat): defer multi-tab broadcasts, disable streamdown word ani…
ericallam Apr 17, 2026
140f632
feat(core): add runInMockTaskContext test infrastructure
ericallam Apr 18, 2026
9e2d05e
feat(sdk): add mockChatAgent test harness with locals DI
ericallam Apr 18, 2026
b4916d8
feat(chat): expose finishReason on turn-complete events
ericallam Apr 18, 2026
98c4d0a
feat(chat): add chat.endRun()
ericallam Apr 18, 2026
ab80b61
fix(chat): include "action" in ChatTaskPayload.trigger type
ericallam Apr 18, 2026
d65efe3
feat(core): add skill resource catalog + SkillManifest schemas
ericallam Apr 18, 2026
864d390
feat(sdk): add skills.define + chat.skills runtime wiring
ericallam Apr 18, 2026
d596777
feat(cli): built-in skill bundler for trigger dev + deploy
ericallam Apr 18, 2026
ed9171b
feat(sdk,cli,core,build): phase 1 of agent skills
ericallam Apr 18, 2026
4ed87ca
fix(cli): skills bundler resolves caller-relative paths + correct dev…
ericallam Apr 18, 2026
65b2174
WIP chat.store primitive
ericallam Apr 19, 2026
4801bdc
feat(sdk,core): Session client SDK + hello-world smoke test
ericallam Apr 20, 2026
63bf18a
feat(sdk,core): Session channel SDK toolkits + waitpoints — client side
ericallam Apr 23, 2026
f0cc566
feat(sdk): chat.agent → Sessions migration (phases B + C + min E)
ericallam Apr 23, 2026
8757928
feat(sdk): server-side ChatStream / AgentChat -> Sessions (phase D)
ericallam Apr 23, 2026
f89823e
fix(sdk,chat): route pipeChat through session.out + chat-agent smoke …
ericallam Apr 23, 2026
93789b6
test(sdk,core): session-aware mockChatAgent harness + chat.test.ts mocks
ericallam Apr 23, 2026
1faabf4
docs(architecture): chat.agent over Sessions reference
ericallam Apr 23, 2026
72ae58b
feat(cli): MCP agentChat tool → Sessions migration
ericallam Apr 23, 2026
616ca63
feat(webapp,sdk): dashboard AgentView → session streams
ericallam Apr 23, 2026
55b5756
feat(sdk,ai-chat): skills runtime subpath + ai-chat browser test bridge
ericallam Apr 23, 2026
d254198
feat(sdk,webapp,ai-chat): end-to-end browser UI smoke on sessions
ericallam Apr 23, 2026
c41e7b3
feat(sdk,core): drop legacy chat stream-ID constants
ericallam Apr 23, 2026
7757b22
fix(sdk,chat): make isStreaming optional in reconnectToStream short-c…
ericallam Apr 24, 2026
1d01ee8
fix(webapp): use getRequestAbortSignal() for dashboard stream routes
ericallam Apr 24, 2026
bf2768c
refactor(sdk): extract browser-safe chat types into ai-shared
ericallam Apr 25, 2026
4fba79f
feat(sdk,webapp): X-Peek-Settled opt-in fast-close on session.out
ericallam Apr 25, 2026
31cec28
feat(sdk,webapp): X-Peek-Settled fast-close (webapp + docs)
ericallam Apr 25, 2026
7e91abb
feat(sdk,playground,ai-chat): chat.agent on Sessions-as-run-manager
ericallam Apr 27, 2026
261f9f4
ignore claude subdirs
ericallam Apr 28, 2026
a47b0ec
fix sdk build for new context field
ericallam Apr 28, 2026
2fc68fd
fix(core): buffer session-stream chunks even when handlers exist
ericallam Apr 28, 2026
9582a71
ignroe claude scheduled tasks lock file
ericallam Apr 28, 2026
07cd5c5
fix(sdk,ai-chat): auto chat:{chatId} tag on server-mediated start; at…
ericallam Apr 28, 2026
88b0b28
fix(ai-chat reference): await Chat.messages persist in onTurnStart
ericallam Apr 29, 2026
bf24ad9
feat(ai-chat reference): db:reset:chats helper for clean smoke-test s…
ericallam Apr 29, 2026
1cb0d13
feat(ai-chat reference): explicit Preload button + Runs link in debug…
ericallam Apr 29, 2026
e99cba3
fix(cli): MCP agentChat — task-bound session creation
ericallam Apr 29, 2026
ca33bb0
test(clickhouse): add missing task_kind to taskRuns test fixtures
ericallam Apr 29, 2026
415d95b
fix(sdk,cli): server-to-agent chat preload — `trigger: "preload"` + `…
ericallam Apr 29, 2026
bc751bd
feat(sdk,core): ChatChunkTooLargeError for oversized chat-stream chunks
ericallam Apr 30, 2026
64699af
fix(sdk,core): unblock CI on PR #3173
ericallam Apr 30, 2026
b8b1b8a
fix(core): typesVersions entry for v3/chat-client + inline CodeQL guards
ericallam Apr 30, 2026
d3b8619
fix(core,webapp): plumb maxDuration / lockToVersion / region through …
ericallam May 1, 2026
56d63cf
chore: consolidate chat.agent / Sessions / Skills changesets (26 → 8)
ericallam May 1, 2026
1d06d1d
chore: rewrite consolidated changesets in user-facing changelog voice
ericallam May 1, 2026
fdade69
fix: address PR 3173 review feedback
ericallam May 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/ai-chat-sandbox-and-ctx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@trigger.dev/sdk": patch
---

Add `TaskRunContext` (`ctx`) to all `chat.task` lifecycle events, `CompactedEvent`, and `ChatTaskRunPayload`. Export `TaskRunContext` from `@trigger.dev/sdk`.

42 changes: 42 additions & 0 deletions .changeset/ai-sdk-chat-transport.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
"@trigger.dev/sdk": minor
---

Add AI SDK chat transport integration via two new subpath exports:

**`@trigger.dev/sdk/chat`** (frontend, browser-safe):
- `TriggerChatTransport` — custom `ChatTransport` for the AI SDK's `useChat` hook that runs chat completions as durable Trigger.dev tasks
- `createChatTransport()` — factory function

```tsx
import { useChat } from "@ai-sdk/react";
import { TriggerChatTransport } from "@trigger.dev/sdk/chat";

const { messages, sendMessage } = useChat({
transport: new TriggerChatTransport({
task: "my-chat-task",
accessToken,
}),
});
```

**`@trigger.dev/sdk/ai`** (backend, extends existing `ai.tool`/`ai.currentToolOptions`):
- `chatTask()` — pre-typed task wrapper with auto-pipe support
- `pipeChat()` — pipe a `StreamTextResult` or stream to the frontend
- `CHAT_STREAM_KEY` — the default stream key constant
- `ChatTaskPayload` type

```ts
import { chatTask } from "@trigger.dev/sdk/ai";
import { streamText, convertToModelMessages } from "ai";

export const myChatTask = chatTask({
id: "my-chat-task",
run: async ({ messages }) => {
return streamText({
model: openai("gpt-4o"),
messages: convertToModelMessages(messages),
});
},
});
```
5 changes: 5 additions & 0 deletions .changeset/ai-tool-execute-helper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/sdk": patch
---

Add `ai.toolExecute(task)` so you can pass Trigger's subtask/metadata wiring as the `execute` handler to AI SDK `tool()` while defining `description` and `inputSchema` yourself. Refactors `ai.tool()` to share the same internal handler.
6 changes: 6 additions & 0 deletions .changeset/ai-tool-toolset-typing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@trigger.dev/sdk": patch
---

Align `ai.tool()` (`toolFromTask`) with the AI SDK `ToolSet` shape: Zod-backed tasks use static `tool()`; returns are asserted as `Tool & ToolSet[string]`. Raise the SDK's minimum `ai` devDependency to `^6.0.116` so emitted types resolve the same `ToolSet` as apps on AI SDK 6.0.x (avoids cross-version `ToolSet` mismatches in monorepos).

5 changes: 5 additions & 0 deletions .changeset/chat-agent-action-trigger-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/sdk": patch
---

Include `"action"` in the `ChatTaskPayload.trigger` union. `run()` is invoked with `trigger: "action"` after `onAction` processes a typed action, but the type previously omitted it. Users can now cleanly short-circuit the LLM call for actions that don't need a response (e.g. user-initiated compaction): `if (trigger === "action") return;`.
5 changes: 5 additions & 0 deletions .changeset/chat-agent-end-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/sdk": patch
---

Add `chat.endRun()` — exits the run after the current turn completes, without the upgrade-required signal that `chat.requestUpgrade()` sends. Use when an agent finishes its work on its own terms (one-shot responses, goal achieved, budget exhausted) instead of waiting idle for the next user message. Call from `run()`, `chat.defer()`, `onBeforeTurnComplete`, or `onTurnComplete`.
5 changes: 5 additions & 0 deletions .changeset/chat-agent-finish-reason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/sdk": patch
---

Expose `finishReason` on `TurnCompleteEvent` and `BeforeTurnCompleteEvent`. Surfaces the AI SDK's `FinishReason` (`"stop" | "tool-calls" | "length" | ...`) so hooks can distinguish a normal turn end from one paused on a pending tool call (HITL flows like `ask_user`). Undefined for manual `pipeChat()` or aborted streams.
16 changes: 16 additions & 0 deletions .changeset/chat-agent-skills-phase-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@trigger.dev/sdk": patch
"@trigger.dev/core": patch
"@trigger.dev/build": patch
"trigger.dev": patch
---

Add agent skills — developer-authored folders (`SKILL.md` + scripts/references/assets) bundled into the deploy image automatically, discovered by the chat agent via progressive disclosure. Built on the [AI SDK cookbook pattern](https://ai-sdk.dev/cookbook/guides/agent-skills) — portable across providers.

**New:**
- `skills.define({ id, path })` registers a skill with the resource catalog; the Trigger.dev CLI bundles the folder into `/app/.trigger/skills/{id}/` automatically — no `trigger.config.ts` changes, no build extension.
- `SkillHandle.local()` reads the bundled `SKILL.md` at runtime, parses frontmatter, returns a `ResolvedSkill`.
- `chat.skills.set([...])` stores resolved skills for the current run.
- `chat.toStreamTextOptions()` auto-injects the skills preamble into the system prompt and merges three tools — `loadSkill`, `readFile`, `bash` — scoped per-skill with path-traversal guards and output caps (64 KB stdout/stderr, 1 MB `readFile`). `bash` runs with `cwd` = skill directory; the turn's abort signal propagates.

Phase 1 is SDK + CLI only — no backend, no dashboard overrides. Dashboard-editable `SKILL.md` text lands in Phase 2 (`skill.resolve()` currently throws).
9 changes: 9 additions & 0 deletions .changeset/chat-customagent-session-binding-and-stop-fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@trigger.dev/sdk": patch
---

Three chat.agent fixes surfaced by smoke-testing the Sessions migration:

- **`chat.customAgent` now binds the session handle.** Previously only `chat.agent` set up the per-run `SessionHandle` in run-locals, so any custom agent that called `chat.messages.*`, `chat.stream.*`, `chat.createSession`, or `chat.createStopSignal` threw `chat.agent session handle is not initialized`. `chat.customAgent` now wraps the user's `run` function and opens the session via `payload.sessionId ?? payload.chatId` before invoking it, matching `chat.agent`'s behavior.
- **Stop mid-stream no longer hangs the turn loop.** When the user aborts a turn, the AI SDK's `runResult.totalUsage` promise can stay unresolved indefinitely on Anthropic streams, blocking `onTurnComplete` / `writeTurnComplete` / the next-message wait. The await is now raced against a 2s timeout (mirroring the existing `onFinishPromise` race), so a stuck `totalUsage` falls through to a non-fatal "usage unknown" path and the turn finalizes correctly.
- **New `chat.sessionId` getter.** Returns the friendlyId (`session_*`) of the run's backing Session. Useful in `onPreload` / `onChatStart` / `onTurnComplete` for persisting the session id alongside `runId` so reloads can resume the same conversation. Throws if called outside a chat.agent / chat.customAgent run.
5 changes: 5 additions & 0 deletions .changeset/chat-reconnect-isstreaming-optional.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/sdk": patch
---

`TriggerChatTransport.reconnectToStream` no longer requires callers to persist an `isStreaming` flag in `ChatSession` state. Previously, any falsy `isStreaming` (including `undefined` when the flag was dropped from persistence) short-circuited reconnect to `null` and left the UI hanging on incomplete streams. Now the short-circuit only triggers on an explicit `isStreaming === false`, so callers can drop the flag entirely and let the server decide via the session's own `.out` tail. Existing callers that still persist `isStreaming` are unaffected.
6 changes: 6 additions & 0 deletions .changeset/chat-run-pat-renewal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@trigger.dev/core": patch
"@trigger.dev/sdk": patch
---

Add run-scoped PAT renewal for chat transport (`renewRunAccessToken`), fail fast on 401/403 for SSE without retry backoff, and export `isTriggerRealtimeAuthError` for auth-error detection.
21 changes: 21 additions & 0 deletions .changeset/chat-store-primitive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
"@trigger.dev/sdk": patch
"@trigger.dev/core": patch
---

Add `chat.store` — a typed, bidirectional shared data slot on `chat.agent`. Agent-side foundation for TRI-8602. Independent of AG-UI — the same primitive will back the AG-UI `STATE_SNAPSHOT` / `STATE_DELTA` translator later.

**New on the agent:**
- `chat.store.set(value)` — replace, emits a `store-snapshot` chunk on the existing chat output stream.
- `chat.store.patch([...])` — RFC 6902 JSON Patch, emits a `store-delta` chunk.
- `chat.store.get()` — read the current value (scoped to the run).
- `chat.store.onChange((value, ops) => ...)` — subscribe to changes.
- `hydrateStore?: (event) => value` config on `chat.agent` — mirrors `hydrateMessages`; restore the store after a continuation from your own persistence layer.
- `ChatTaskWirePayload.incomingStore` — optional wire field applied at turn start before `run()` fires (last-write-wins over `hydrateStore`).

**New in core:**
- `store-snapshot` / `store-delta` chunk types and `applyChatStorePatch` helper exported from `@trigger.dev/core/v3/chat-client`.

The store lives in memory for the lifetime of the run and is persisted by the existing chat output stream plus the `hydrateStore` hook across continuations — no new infrastructure.

Client-side pieces (transport `getStore` / `setStore` / `applyStorePatch` / listeners, `AgentChat` accessors, `useChatStore` React hook, reference demo, docs) land in a follow-up.
8 changes: 8 additions & 0 deletions .changeset/chat-transport-session-renew-plus-preload.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@trigger.dev/sdk": patch
---

`TriggerChatTransport` fixes for session-scoped auth and end-to-end UI smoke parity:

- `RenewRunAccessTokenParams` now includes the durable `sessionId` alongside `chatId` + `runId`. Server-side renew handlers should mint the renewed PAT with `read:sessions:{sessionId}` + `write:sessions:{sessionId}` scopes (in addition to the existing run scopes) so it keeps authenticating against the session `.in` append + `.out` subscribe endpoints. Renewing without session scopes sends the transport into a 401 loop on the first append after expiry.
- `transport.preload(chatId)` on the `triggerTask` callback path no longer calls `apiClient.createSession` from the browser. The server action (e.g. `chat.createTriggerAction`) creates the session with its secret key and returns the `sessionId` in its result, matching how `sendMessages` already worked. Browser deployments that use the `triggerTask` callback path therefore no longer need `write:sessions` on any browser-side token.
11 changes: 11 additions & 0 deletions .changeset/drop-legacy-chat-stream-constants.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@trigger.dev/sdk": patch
"@trigger.dev/core": patch
---

Drop the pre-Sessions chat stream-ID constants from the public surface:

- `CHAT_STREAM_KEY`, `CHAT_MESSAGES_STREAM_ID`, `CHAT_STOP_STREAM_ID` are no longer exported from `@trigger.dev/sdk/ai` or `@trigger.dev/core/v3/chat-client`. Deletes `packages/trigger-sdk/src/v3/chat-constants.ts`.
- The `chat.stream.id` / `chat.messages.id` / `chat.stopSignal.id` labels still contain the same string values (`"chat"` / `"chat-messages"` / `"chat-stop"`) — now inlined as opaque breadcrumbs rather than user-consumable constants. Behavior and telemetry attrs are unchanged.

These constants only mattered before the chat.agent I/O moved onto the Session primitive — the SDK no longer writes to run-scoped `streams.writer(CHAT_STREAM_KEY, …)` / `streams.input(CHAT_*_STREAM_ID)` at all. Customers who still referenced them externally should migrate to `sessions.open(sessionId).out.writer(...)` / `sessions.open(sessionId).in.on(...)` — same primitives, now session-keyed.
5 changes: 5 additions & 0 deletions .changeset/dry-sloths-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/sdk": patch
---

Add `chat.withUIMessage<TUIMessage>()` for typed AI SDK `UIMessage` in chat task hooks, optional factory `streamOptions` merged with `uiMessageStreamOptions`, and `InferChatUIMessage` helper. Generic `ChatUIMessageStreamOptions`, compaction, and pending-message event types. `usePendingMessages` accepts a UI message type parameter; re-export `InferChatUIMessage` from `@trigger.dev/sdk/chat/react`.
5 changes: 5 additions & 0 deletions .changeset/mcp-agent-chat-sessions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---

Migrate the MCP `start_agent_chat` / `send_agent_message` / `close_agent_chat` tools onto the Session primitive. The CLI MCP server now upserts a backing Session via `POST /api/v1/sessions` on chat start, threads `sessionId` through the run payload, sends messages to `session.in` as `ChatInputChunk { kind, payload }` JSON, and subscribes to `session.out` at `/realtime/v1/sessions/{sessionId}/out`. Scopes expanded from `write:inputStreams` to `read:sessions` + `write:sessions`. Upgrade-required re-trigger keeps the same session and swaps only `runId`.
6 changes: 6 additions & 0 deletions .changeset/mock-chat-agent-setup-locals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@trigger.dev/sdk": patch
"@trigger.dev/core": patch
---

Add `setupLocals` option to `mockChatAgent` for dependency injection in tests. Pre-seed `locals` (database clients, service stubs) before the agent's `run()` starts, so hooks read the test instance via `locals.get()` without leaking through untrusted `clientData`. Also exposes `drivers.locals.set()` on `runInMockTaskContext`.
8 changes: 8 additions & 0 deletions .changeset/mock-chat-agent-test-harness.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@trigger.dev/sdk": patch
"@trigger.dev/core": patch
---

Add `mockChatAgent` test harness at `@trigger.dev/sdk/ai/test` for unit-testing `chat.agent` definitions offline. Drives a real agent's turn loop without network or task runtime: send messages, actions, and stop signals via driver methods, inspect captured output chunks, and verify hooks fire. Pairs with `MockLanguageModelV3` from `ai/test` for model mocking.

Also adds `TestRunMetadataManager` to `@trigger.dev/core/v3/test` (in-memory metadata manager used by the harness), and exposes an `onWrite` hook on `TestRealtimeStreamsManager` so harnesses can react to stream writes without polling.
5 changes: 5 additions & 0 deletions .changeset/mock-task-context-test-infra.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---

Add `runInMockTaskContext` test harness at `@trigger.dev/core/v3/test` for unit-testing task code offline. Installs in-memory managers for `locals`, `lifecycleHooks`, `runtime`, `inputStreams`, and `realtimeStreams`, plus a mock `TaskContext`, so tasks can be driven end-to-end without hitting the Trigger.dev runtime. Provides drivers to send data into input streams and inspect chunks written to output streams.
11 changes: 11 additions & 0 deletions .changeset/session-sdk-toolkit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@trigger.dev/core": patch
"@trigger.dev/sdk": patch
---

Extend `SessionHandle` with two asymmetric channels mirroring the run-scoped streams primitives:

- `.in` (`SessionInputChannel`) mirrors `streams.input` — `on` / `once` / `peek` / `wait` / `waitWithIdleTimeout` for the task to consume, `send` for external clients to produce. `.wait` / `.waitWithIdleTimeout` suspend the run on a session-stream waitpoint; the run resumes when a record lands on `.in`.
- `.out` (`SessionOutputChannel`) mirrors `streams.define` — `append` / `pipe` / `writer` for the task to produce records (all route through direct-to-S2 for uniform parsed-object serialization), plus `read` for external SSE subscribers.

Adds the `sessionStreams` global + `StandardSessionStreamManager` (SSE-backed tail + buffer keyed on `{sessionId, io}`, registered in dev/managed run workers), `SessionStreamInstance` for direct-to-S2 piping, and `ApiClient.createSessionStreamWaitpoint` wiring.
5 changes: 5 additions & 0 deletions .changeset/session-trigger-config-extra-fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---

Extend `SessionTriggerConfig` with three optional fields previously missing from the schema: `maxDuration` (per-run wall-clock cap, seconds), `lockToVersion` (pin every run to a specific worker version), and `region` (geographic scheduling). Each forwards to the matching field on `TaskRunOptions` when the run is triggered. Existing sessions without these fields are unaffected.
5 changes: 5 additions & 0 deletions .changeset/skills-runtime-subpath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/sdk": patch
---

Split the skill-runtime primitives (`bash` + `readFile` tool implementations, backed by `node:child_process` + `node:fs/promises`) out of `@trigger.dev/sdk/ai` into a new `@trigger.dev/sdk/ai/skills-runtime` subpath. Fixes client-bundle build errors (`UnhandledSchemeError: Reading from "node:child_process"…`) that hit Next.js + Webpack when a browser page imports types from `@trigger.dev/sdk/ai` (for example `ChatUiMessage` via a shared tools file). The chat-agent factory now loads the runtime lazily via a computed-string dynamic import, so server workers still get full skill support without any caller changes.
23 changes: 23 additions & 0 deletions .changeset/trigger-chat-transport-watch-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
"@trigger.dev/sdk": patch
---

Add `watch` option to `TriggerChatTransport` for read-only observation of an existing chat run.

When set to `true`, the transport keeps its internal `ReadableStream` open across `trigger:turn-complete` control chunks instead of closing it after each turn. This lets a single `useChat` / `resumeStream` subscription observe every turn of a long-lived agent run — useful for dashboard viewers or debug UIs that only want to watch an existing conversation as it unfolds, rather than drive it.

```tsx
const transport = new TriggerChatTransport({
task: "my-chat-task",
accessToken: runScopedPat,
watch: true,
sessions: {
[chatId]: { runId, publicAccessToken: runScopedPat },
},
});

const { messages, resumeStream } = useChat({ id: chatId, transport });
useEffect(() => { resumeStream(); }, [resumeStream]);
```

Non-watch transports are unaffected — the default remains `false` and existing behavior (close on turn-complete so `useChat` can flip to `"ready"` between turns) is preserved for interactive playground-style flows.
Loading
Loading