Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
e8f99fc
feat: add @trigger.dev/ai package with TriggerChatTransport
cursoragent Feb 15, 2026
ea8cf28
test: add comprehensive unit tests for TriggerChatTransport
cursoragent Feb 15, 2026
7800981
refactor: polish TriggerChatTransport implementation
cursoragent Feb 15, 2026
e940262
test: add abort signal, multiple sessions, and body merging tests
cursoragent Feb 15, 2026
97b385a
chore: add changeset for @trigger.dev/ai package
cursoragent Feb 15, 2026
891375a
refactor: remove internal ChatSessionState from public exports
cursoragent Feb 15, 2026
997c322
feat: support dynamic accessToken function for token refresh
cursoragent Feb 15, 2026
99ff39e
refactor: avoid double-resolving accessToken in sendMessages
cursoragent Feb 15, 2026
c56a364
feat: add chat transport and AI chat helpers to @trigger.dev/sdk
cursoragent Feb 15, 2026
ccc85e4
test: move chat transport tests to @trigger.dev/sdk
cursoragent Feb 15, 2026
f0dd5e0
refactor: delete packages/ai/ — moved to @trigger.dev/sdk subpaths
cursoragent Feb 15, 2026
f682235
chore: update changeset to target @trigger.dev/sdk
cursoragent Feb 15, 2026
037d1da
fix: address CodeRabbit review feedback
cursoragent Feb 15, 2026
499fc94
docs(ai): add AI Chat with useChat guide
cursoragent Feb 15, 2026
3805d91
feat(reference): add ai-chat Next.js reference project
cursoragent Feb 15, 2026
a7f4d27
fix(reference): use compatible @ai-sdk v3 packages, await convertToMo…
cursoragent Feb 15, 2026
fefc7df
Use a single run with iterative waitpoint token completions
ericallam Feb 21, 2026
f92bf6c
Added tool example
ericallam Feb 21, 2026
e963271
expose a useTriggerChatTransport hook
ericallam Feb 21, 2026
ba81c37
use input streams and rename chatTask and chatState to chat.task and …
ericallam Mar 3, 2026
3f66c56
add stopping support and fix issue with the OpenAI responses API and …
ericallam Mar 4, 2026
522e85c
Add warmTimeoutInSeconds option
ericallam Mar 4, 2026
3b5e8f5
Add clientData support
ericallam Mar 4, 2026
d5af5a3
provide already converted UIMessages to the run function for better dx
ericallam Mar 4, 2026
869b41d
Added better telemetry support to view turns
ericallam Mar 4, 2026
6258122
Fix double looping when resuming from an input stream waitpoint
ericallam Mar 4, 2026
9bae6c0
Add some pending message support in the example
ericallam Mar 4, 2026
c5ec4a0
Accumulate messages in the task, allowing us to only have to send use…
ericallam Mar 5, 2026
4e6a5c8
build full example with persisting messages, adding necessary hooks, …
ericallam Mar 5, 2026
c7276e1
Add ai chat to the sidebar for now
ericallam Mar 5, 2026
4b1e461
remove postinstall hook
ericallam Mar 5, 2026
5c75341
feat: add onTurnStart hook, lastEventId support, and stream resume de…
ericallam Mar 5, 2026
d082678
Minor fixes around reconnecting streams
ericallam Mar 6, 2026
94b4e9a
update pnpm link file
ericallam Mar 6, 2026
ee3e9b2
fixed chat tests
ericallam Mar 6, 2026
c409e7d
use locals for the chat pipe counter instead of a module global
ericallam Mar 6, 2026
c85d541
Add triggerOptions to the transport, auto-tag with the chat ID
ericallam Mar 6, 2026
78923cf
Make clientData typesafe and pass to all chat.task hooks
ericallam Mar 6, 2026
704ab74
feat: add chat.local for per-run typed data with Proxy access and dir…
ericallam Mar 6, 2026
235a4d4
feat(chat): add stop handling, abort cleanup, continuation support, a…
ericallam Mar 7, 2026
90a9556
Some improvements to the example ai-chat
ericallam Mar 7, 2026
fdd3f9b
feat(chat): expose typed chat.stream, add deepResearch subtask exampl…
ericallam Mar 8, 2026
c98f6f3
feat(ai): pass chat context and toolCallId to subtasks, add typed ai.…
ericallam Mar 8, 2026
77a1351
feat(chat): add preload support, dynamic tools, and preload-specific …
ericallam Mar 9, 2026
6cf3a01
docs: add mermaid architecture diagrams for ai-chat system
ericallam Mar 9, 2026
b54b500
docs: add sequence diagrams to ai-chat guide
ericallam Mar 9, 2026
7ef73da
feat(chat): auto-hydrate chat.local values in ai.tool subtasks
ericallam Mar 9, 2026
9f705ab
feat(chat): add chat.defer(), preload toggle, TTFB measurement, and f…
ericallam Mar 9, 2026
4a17be4
fix(reference): replace hand-rolled HTML stripping with turndown
ericallam Mar 9, 2026
9d1bb5e
feat(streams): add inputStream.waitWithWarmup(), warm timeout config …
ericallam Mar 9, 2026
981a5a0
feat(chat): add composable primitives, raw task example, and task mod…
ericallam Mar 10, 2026
6c1b4f8
Introduce the chat session API and better docs organization
ericallam Mar 10, 2026
b7afc17
Add support for toUIMessageStream() options
ericallam Mar 10, 2026
99f58bb
Add metadata to the streamText call
ericallam Mar 12, 2026
fd1fbe6
feat(chat): add chat.prompt API with provider registry support
ericallam Mar 23, 2026
74c7039
refactor: rename warmTimeout to idleTimeout across chat APIs
ericallam Mar 23, 2026
e06fbdb
feat: support message compaction
ericallam Mar 24, 2026
e94ce5e
better compaction support in our other chat variants
ericallam Mar 24, 2026
843b85e
feat(chat): add compaction option, pendingMessages steering, and useP…
ericallam Mar 25, 2026
a503e99
Add a writer to easily write chunks in callbacks
ericallam Mar 26, 2026
973bd2c
feat(ai): add triggerAndSubscribe method and use it in ai.tool
ericallam Mar 26, 2026
fe90614
feat(chat): add chat.inject() for background context injection and ch…
ericallam Mar 26, 2026
dbe5ae4
feat(sdk): ToolSet typing for toolFromTask, ai.toolExecute, deprecate…
ericallam Mar 27, 2026
b3106f8
Add run-scoped PAT renewal for chat transport
ericallam Mar 27, 2026
828c34a
feat(sdk): ctx on chat.task hooks; ai-chat E2B sandbox; docs patterns
ericallam Mar 27, 2026
9e7b2d1
feat(sdk): add onChatSuspend/onChatResume hooks, exitAfterPreloadIdle…
ericallam Mar 28, 2026
84d430e
Add support for triggering from the backend
ericallam Mar 28, 2026
ed40628
chat.task -> chat.agent
ericallam Mar 30, 2026
8245586
feat: upgrade streamdown to v2.5.0 with custom Trigger.dev Shiki theme
ericallam Apr 1, 2026
5569201
playground ui tweaks
ericallam Apr 1, 2026
581c1ec
Some design tweaks, improvements to playground options, rename unname…
ericallam Apr 1, 2026
badc7de
Add the chat client and strip agent crumbs
ericallam Apr 1, 2026
8c5f012
Add server-to-server chat support and subagent support to the playgro…
ericallam Apr 2, 2026
d973dd1
add agent mcp tools
ericallam Apr 2, 2026
ee0fb66
Add support for optionally validating UI messages
ericallam Apr 2, 2026
611904b
Support for upgrading an agent to a new version
ericallam Apr 3, 2026
4b9bb59
Add run agent view
ericallam Apr 10, 2026
925add2
feat(chat): add stopGeneration, fix onTurnComplete/onFinishPromise, a…
ericallam Apr 11, 2026
569cd7c
fix(sdk): inject prepareStep in toStreamTextOptions even without chat…
ericallam Apr 13, 2026
cc2ad1f
feat(chat): allow generateMessageId in uiMessageStreamOptions, auto-p…
ericallam Apr 14, 2026
3241e1c
feat(chat): tool approvals support — ID-matched message replacement, …
ericallam Apr 14, 2026
216ba98
fix: restore applyPrepareMessages call after agentcrumbs strip
ericallam Apr 14, 2026
d614147
prevent preloads from firing twice when in React strictMode
ericallam Apr 14, 2026
375409c
feat(chat): add chat.response API for persistent data parts, transien…
ericallam Apr 14, 2026
bbb5cfb
feat(chat): add hydrateMessages, chat.history, and custom actions
ericallam Apr 15, 2026
1fb15e1
fix(chat): prevent useChat resume from hanging on completed turns
ericallam Apr 15, 2026
c7af17f
fix pnpm lock file
ericallam Apr 16, 2026
c46543b
feat(ai-chat): add askUser tool for HITL testing, verify TRI-8556 fix
ericallam Apr 17, 2026
964794a
chore(ai-chat): remove test-big-error trigger from onValidateMessages
ericallam Apr 17, 2026
29097d7
feat(chat): multi-tab coordination via BroadcastChannel
ericallam Apr 17, 2026
0469366
fix(ai-chat): defer multi-tab broadcasts, disable streamdown word ani…
ericallam Apr 17, 2026
056805c
feat(core): add runInMockTaskContext test infrastructure
ericallam Apr 18, 2026
c4e0a04
feat(sdk): add mockChatAgent test harness with locals DI
ericallam Apr 18, 2026
f0909df
feat(chat): expose finishReason on turn-complete events
ericallam Apr 18, 2026
47ac1b6
feat(chat): add chat.endRun()
ericallam Apr 18, 2026
c146ef1
fix(chat): include "action" in ChatTaskPayload.trigger type
ericallam Apr 18, 2026
bf8e936
feat(core): add skill resource catalog + SkillManifest schemas
ericallam Apr 18, 2026
eea6676
feat(sdk): add skills.define + chat.skills runtime wiring
ericallam Apr 18, 2026
9ef910b
feat(cli): built-in skill bundler for trigger dev + deploy
ericallam Apr 18, 2026
9d5f3c2
feat(sdk,cli,core,build): phase 1 of agent skills
ericallam Apr 18, 2026
665b81b
fix(cli): skills bundler resolves caller-relative paths + correct dev…
ericallam Apr 18, 2026
0c4b4b0
WIP chat.store primitive
ericallam Apr 19, 2026
0eb750f
feat(sdk,core): Session client SDK + hello-world smoke test
ericallam Apr 20, 2026
5c66161
feat(sdk,core): Session channel SDK toolkits + waitpoints — client side
ericallam Apr 23, 2026
08da57d
feat(sdk): chat.agent → Sessions migration (phases B + C + min E)
ericallam Apr 23, 2026
c0986f8
feat(sdk): server-side ChatStream / AgentChat -> Sessions (phase D)
ericallam Apr 23, 2026
3f08d19
fix(sdk,chat): route pipeChat through session.out + chat-agent smoke …
ericallam Apr 23, 2026
d468923
test(sdk,core): session-aware mockChatAgent harness + chat.test.ts mocks
ericallam Apr 23, 2026
0657eac
docs(architecture): chat.agent over Sessions reference
ericallam Apr 23, 2026
6c66b74
feat(cli): MCP agentChat tool → Sessions migration
ericallam Apr 23, 2026
c66f1d2
feat(webapp,sdk): dashboard AgentView → session streams
ericallam Apr 23, 2026
a332e1d
feat(sdk,ai-chat): skills runtime subpath + ai-chat browser test bridge
ericallam Apr 23, 2026
23bf81e
feat(sdk,webapp,ai-chat): end-to-end browser UI smoke on sessions
ericallam Apr 23, 2026
0ff3999
feat(sdk,core): drop legacy chat stream-ID constants
ericallam Apr 23, 2026
af21fe9
fix(sdk,chat): make isStreaming optional in reconnectToStream short-c…
ericallam Apr 24, 2026
186f04f
fix(webapp): use getRequestAbortSignal() for dashboard stream routes
ericallam Apr 24, 2026
1be14ec
refactor(sdk): extract browser-safe chat types into ai-shared
ericallam Apr 25, 2026
1fb7fbf
feat(sdk,webapp): X-Peek-Settled opt-in fast-close on session.out
ericallam Apr 25, 2026
0ed1744
feat(sdk,webapp): X-Peek-Settled fast-close (webapp + docs)
ericallam Apr 25, 2026
37503a4
feat(sdk,playground,ai-chat): chat.agent on Sessions-as-run-manager
ericallam Apr 27, 2026
b04baf9
ignore claude subdirs
ericallam Apr 28, 2026
37da37a
fix sdk build for new context field
ericallam Apr 28, 2026
6ed5e07
fix(core): buffer session-stream chunks even when handlers exist
ericallam Apr 28, 2026
28c4df4
ignroe claude scheduled tasks lock file
ericallam Apr 28, 2026
76b476d
fix(sdk,ai-chat): auto chat:{chatId} tag on server-mediated start; at…
ericallam Apr 28, 2026
27e3c93
fix(ai-chat reference): await Chat.messages persist in onTurnStart
ericallam Apr 29, 2026
0add0e7
feat(ai-chat reference): db:reset:chats helper for clean smoke-test s…
ericallam Apr 29, 2026
f3ee842
feat(ai-chat reference): explicit Preload button + Runs link in debug…
ericallam Apr 29, 2026
79a3f96
fix(cli): MCP agentChat — task-bound session creation
ericallam Apr 29, 2026
dce8013
test(clickhouse): add missing task_kind to taskRuns test fixtures
ericallam Apr 29, 2026
a3a568a
fix(sdk,cli): server-to-agent chat preload — `trigger: "preload"` + `…
ericallam Apr 29, 2026
73371c1
feat(sdk,core): ChatChunkTooLargeError for oversized chat-stream chunks
ericallam Apr 30, 2026
0a9c326
fix(sdk,core): unblock CI on PR #3173
ericallam Apr 30, 2026
b143e77
fix(core): typesVersions entry for v3/chat-client + inline CodeQL guards
ericallam Apr 30, 2026
9ca81dd
fix(core,webapp): plumb maxDuration / lockToVersion / region through …
ericallam May 1, 2026
88096fc
chore: consolidate chat.agent / Sessions / Skills changesets (26 → 8)
ericallam May 1, 2026
2d8d909
chore: rewrite consolidated changesets in user-facing changelog voice
ericallam May 1, 2026
65aa6d3
fix: address PR 3173 review feedback
ericallam May 1, 2026
f4aac25
feat(sdk): resilient SSE reconnection in chat transport
ericallam May 1, 2026
2fc6b6a
feat(sdk): chat.headStart for fast first-turn TTFC
ericallam May 3, 2026
74e7077
chore(references): demo chat.headStart in ai-chat reference
ericallam May 3, 2026
3b2cb96
fix(webapp): wrap playground 'save' JSON.parse to return 400 on malfo…
ericallam May 3, 2026
eb1dc3a
feat(webapp): plumb per-org basin through playground + dashboard rout…
ericallam May 4, 2026
02dca08
fix: AGENT/SCHEDULED runs misclassified + green up the chat.handover …
ericallam May 5, 2026
d221490
fix(webapp): normalize taskKind in API + drop unsafe casts in playgro…
ericallam May 5, 2026
5629d2b
fix(sdk): drop session-stream auto-reconnect after explicit disconnect
ericallam May 5, 2026
d1b27a9
fix(sdk): drop duplicate onError on SSE auth-error path
ericallam May 5, 2026
f66fbb0
feat(sdk): stamp gen_ai.conversation.id on chat spans and metrics
ericallam May 5, 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
16 changes: 16 additions & 0 deletions .changeset/agent-skills.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 for `chat.agent`. Drop a folder with a `SKILL.md` and any helper scripts/references next to your task code, register it with `skills.define({ id, path })`, and the CLI bundles it into the deploy image automatically — no `trigger.config.ts` changes. The agent gets a one-line summary in its system prompt and discovers full instructions on demand via `loadSkill`, with `bash` and `readFile` tools scoped per-skill (path-traversal guards, output caps, abort-signal propagation).

```ts
const pdfSkill = skills.define({ id: "pdf-extract", path: "./skills/pdf-extract" });

chat.skills.set([await pdfSkill.local()]);
```

Built on the [AI SDK cookbook pattern](https://ai-sdk.dev/cookbook/guides/agent-skills) — portable across providers. SDK + CLI only for now; dashboard-editable `SKILL.md` text is on the roadmap.
15 changes: 15 additions & 0 deletions .changeset/ai-tool-helpers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@trigger.dev/sdk": patch
---

Add `ai.toolExecute(task)` so you can wire a Trigger subtask in as the `execute` handler of an AI SDK `tool()` while defining `description` and `inputSchema` yourself — useful when you want full control over the tool surface and just need Trigger's subtask machinery for the body.

```ts
const myTool = tool({
description: "...",
inputSchema: z.object({ ... }),
execute: ai.toolExecute(mySubtask),
});
```

`ai.tool(task)` (`toolFromTask`) keeps doing the all-in-one wrap and now aligns its return type with AI SDK's `ToolSet`. Minimum `ai` peer raised to `^6.0.116` to avoid cross-version `ToolSet` mismatches in monorepos.
30 changes: 30 additions & 0 deletions .changeset/chat-agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
"@trigger.dev/sdk": minor
"@trigger.dev/core": patch
---

Run AI chats as durable Trigger.dev tasks. Define the agent in one function, wire `useChat` to it from React, and the conversation survives page refreshes, network blips, and process restarts — with built-in support for tools, HITL approvals, multi-turn state, and stop-mid-stream cancellation.

```ts
import { chat } from "@trigger.dev/sdk/ai";
import { streamText } from "ai";
import { openai } from "@ai-sdk/openai";

export const myChat = chat.agent({
id: "my-chat",
run: async ({ messages, signal }) =>
streamText({ model: openai("gpt-4o"), messages, abortSignal: signal }),
});
```

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

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

Lifecycle hooks (`onPreload`, `onTurnStart`, `onTurnComplete`, etc.) cover the common needs around persistence, validation, and post-turn work. `chat.store` gives you a typed shared-data slot the agent and client both read and write. `chat.endRun()` exits cleanly when the agent decides it's done. The transport's `watch` mode lets a dashboard tab observe a run without driving it.

Drops the pre-Sessions chat stream constants (`CHAT_STREAM_KEY`, `CHAT_MESSAGES_STREAM_ID`, `CHAT_STOP_STREAM_ID`) — migrate to `sessions.open(id).out` / `.in`.
34 changes: 34 additions & 0 deletions .changeset/chat-head-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
"@trigger.dev/sdk": minor
---

Add `chat.headStart` — an opt-in fast-path that runs the first turn's `streamText` step in your warm Next.js / Hono / Workers / Express handler while the trigger agent run boots in parallel. Cold-start TTFC drops by ~50% on the first message; the agent owns step 2+ (tool execution, persistence, hooks) so heavy deps stay where they belong.

```ts
// app/api/chat/route.ts (Next.js / any Web Fetch framework)
import { chat } from "@trigger.dev/sdk/chat-server";
import { streamText } from "ai";
import { openai } from "@ai-sdk/openai";
import { headStartTools } from "@/lib/chat-tools-schemas"; // schema-only

export const POST = chat.headStart({
agentId: "ai-chat",
run: async ({ chat: chatHelper }) =>
streamText({
...chatHelper.toStreamTextOptions({ tools: headStartTools }),
model: openai("gpt-4o-mini"),
system: "You are a helpful AI assistant.",
}),
});
```

```tsx
// browser — opt in by pointing the transport at your handler
const transport = useTriggerChatTransport({
task: "ai-chat",
accessToken,
headStart: "/api/chat", // first-turn-only; turn 2+ bypasses the endpoint
});
```

For Node-only frameworks (Express, Fastify, Koa, raw `node:http`) use `chat.toNodeListener(handler)` to bridge the Web Fetch handler to `(req, res)`. Adds a new `@trigger.dev/sdk/chat-server` subpath; bundle stays Web Fetch–only with no `node:*` imports.
6 changes: 6 additions & 0 deletions .changeset/chat-session-attributes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@trigger.dev/sdk": patch
"@trigger.dev/core": patch
---

Stamp `gen_ai.conversation.id` (the chat id) on every span and metric emitted from inside a `chat.task` or `chat.agent` run. Lets you filter dashboard spans, runs, and metrics by the chat conversation that produced them — independent of the run boundary, so multi-run chats correlate cleanly. No code changes required on the user side.
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
---

The CLI MCP server's agent-chat tools (`start_agent_chat`, `send_agent_message`, `close_agent_chat`) now run on the new Sessions primitive, so AI assistants driving a `chat.agent` get the same idempotent-by-`chatId`, durable-across-runs behavior the browser transport gets. Required PAT scopes go from `write:inputStreams` to `read:sessions` + `write:sessions`.
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
---

Unit-test `chat.agent` definitions offline with `mockChatAgent` from `@trigger.dev/sdk/ai/test`. Drives a real agent's turn loop in-process — no network, no task runtime — so you can 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. `setupLocals` lets you pre-seed `locals` (DB clients, service stubs) before `run()` starts.

The broader `runInMockTaskContext` harness it's built on lives at `@trigger.dev/core/v3/test` — useful for unit-testing any task code, not just chat.
14 changes: 14 additions & 0 deletions .changeset/sessions-primitive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"@trigger.dev/core": patch
"@trigger.dev/sdk": patch
---

Add Sessions — a durable, task-bound, bidirectional channel pair that outlives any single run. One identifier (your `externalId`), many runs over time, with a stable `.in` channel clients can write to and a stable `.out` channel they can subscribe to. Powers `chat.agent` (separate changeset), and unblocks anything that needs "resume tomorrow" or "approval loop" workflows.

```ts
const session = await sessions.create({ externalId: chatId, taskIdentifier: "my-task" });
await session.in.send({ kind: "message", payload: "..." });
for await (const chunk of session.out.read()) { /* ... */ }
```

Inside the task, `.in.wait()` / `.waitWithIdleTimeout()` suspends the run on a session-stream waitpoint until the next record arrives. `.out.append` / `.pipe` / `.writer` produce records via direct-to-S2 writes.
Loading
Loading