Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
b7d9e2a
feat: add @trigger.dev/ai package with TriggerChatTransport
cursoragent Feb 15, 2026
ef27bf2
test: add comprehensive unit tests for TriggerChatTransport
cursoragent Feb 15, 2026
dba5098
refactor: polish TriggerChatTransport implementation
cursoragent Feb 15, 2026
a20bf29
test: add abort signal, multiple sessions, and body merging tests
cursoragent Feb 15, 2026
af6188d
chore: add changeset for @trigger.dev/ai package
cursoragent Feb 15, 2026
c9cb78d
refactor: remove internal ChatSessionState from public exports
cursoragent Feb 15, 2026
5990faf
feat: support dynamic accessToken function for token refresh
cursoragent Feb 15, 2026
b8aed06
refactor: avoid double-resolving accessToken in sendMessages
cursoragent Feb 15, 2026
52b25e5
feat: add chat transport and AI chat helpers to @trigger.dev/sdk
cursoragent Feb 15, 2026
532741d
test: move chat transport tests to @trigger.dev/sdk
cursoragent Feb 15, 2026
3e5296a
refactor: delete packages/ai/ — moved to @trigger.dev/sdk subpaths
cursoragent Feb 15, 2026
d4a5676
chore: update changeset to target @trigger.dev/sdk
cursoragent Feb 15, 2026
a894edf
fix: address CodeRabbit review feedback
cursoragent Feb 15, 2026
e5f5f2a
docs(ai): add AI Chat with useChat guide
cursoragent Feb 15, 2026
2586e22
feat(reference): add ai-chat Next.js reference project
cursoragent Feb 15, 2026
9652df4
fix(reference): use compatible @ai-sdk v3 packages, await convertToMo…
cursoragent Feb 15, 2026
5f79563
Use a single run with iterative waitpoint token completions
ericallam Feb 21, 2026
5aeb543
Added tool example
ericallam Feb 21, 2026
4f46d9a
expose a useTriggerChatTransport hook
ericallam Feb 21, 2026
db462f5
use input streams and rename chatTask and chatState to chat.task and …
ericallam Mar 3, 2026
94ee347
add stopping support and fix issue with the OpenAI responses API and …
ericallam Mar 4, 2026
a9d5f30
Add warmTimeoutInSeconds option
ericallam Mar 4, 2026
7239448
Add clientData support
ericallam Mar 4, 2026
9c01d2c
provide already converted UIMessages to the run function for better dx
ericallam Mar 4, 2026
6649ec7
Added better telemetry support to view turns
ericallam Mar 4, 2026
f80b0c3
Fix double looping when resuming from an input stream waitpoint
ericallam Mar 4, 2026
d57e09b
Add some pending message support in the example
ericallam Mar 4, 2026
10ca6d5
Accumulate messages in the task, allowing us to only have to send use…
ericallam Mar 5, 2026
153f8ae
build full example with persisting messages, adding necessary hooks, …
ericallam Mar 5, 2026
585427d
Add ai chat to the sidebar for now
ericallam Mar 5, 2026
96a65ba
remove postinstall hook
ericallam Mar 5, 2026
c23b18e
feat: add onTurnStart hook, lastEventId support, and stream resume de…
ericallam Mar 5, 2026
c3d3ca0
Minor fixes around reconnecting streams
ericallam Mar 6, 2026
59cfd43
update pnpm link file
ericallam Mar 6, 2026
3522386
fixed chat tests
ericallam Mar 6, 2026
70f55c8
use locals for the chat pipe counter instead of a module global
ericallam Mar 6, 2026
3a38eba
Add triggerOptions to the transport, auto-tag with the chat ID
ericallam Mar 6, 2026
a2a9f4c
Make clientData typesafe and pass to all chat.task hooks
ericallam Mar 6, 2026
c40880f
feat: add chat.local for per-run typed data with Proxy access and dir…
ericallam Mar 6, 2026
a8a0b9c
feat(chat): add stop handling, abort cleanup, continuation support, a…
ericallam Mar 7, 2026
bf93b64
Some improvements to the example ai-chat
ericallam Mar 7, 2026
6b117a2
feat(chat): expose typed chat.stream, add deepResearch subtask exampl…
ericallam Mar 8, 2026
cbf2770
feat(ai): pass chat context and toolCallId to subtasks, add typed ai.…
ericallam Mar 8, 2026
baadafa
feat(chat): add preload support, dynamic tools, and preload-specific …
ericallam Mar 9, 2026
991ba12
docs: add mermaid architecture diagrams for ai-chat system
ericallam Mar 9, 2026
b905094
docs: add sequence diagrams to ai-chat guide
ericallam Mar 9, 2026
d015bbc
feat(chat): auto-hydrate chat.local values in ai.tool subtasks
ericallam Mar 9, 2026
e0bc2e3
feat(chat): add chat.defer(), preload toggle, TTFB measurement, and f…
ericallam Mar 9, 2026
1bb09fb
fix(reference): replace hand-rolled HTML stripping with turndown
ericallam Mar 9, 2026
65e06a5
feat(streams): add inputStream.waitWithWarmup(), warm timeout config …
ericallam Mar 9, 2026
1e9fe12
feat(chat): add composable primitives, raw task example, and task mod…
ericallam Mar 10, 2026
fcdd031
Introduce the chat session API and better docs organization
ericallam Mar 10, 2026
5073b2e
Add support for toUIMessageStream() options
ericallam Mar 10, 2026
ad1431b
Add metadata to the streamText call
ericallam Mar 12, 2026
b7cde3a
feat(chat): add chat.prompt API with provider registry support
ericallam Mar 23, 2026
a50df13
refactor: rename warmTimeout to idleTimeout across chat APIs
ericallam Mar 23, 2026
eee58da
feat: support message compaction
ericallam Mar 24, 2026
1c1aacc
better compaction support in our other chat variants
ericallam Mar 24, 2026
12dab3a
feat(chat): add compaction option, pendingMessages steering, and useP…
ericallam Mar 25, 2026
af3784b
Add a writer to easily write chunks in callbacks
ericallam Mar 26, 2026
e556496
feat(ai): add triggerAndSubscribe method and use it in ai.tool
ericallam Mar 26, 2026
5ce21cc
feat(chat): add chat.inject() for background context injection and ch…
ericallam Mar 26, 2026
745f314
feat(sdk): ToolSet typing for toolFromTask, ai.toolExecute, deprecate…
ericallam Mar 27, 2026
6aeda46
Add run-scoped PAT renewal for chat transport
ericallam Mar 27, 2026
a20dacb
feat(sdk): ctx on chat.task hooks; ai-chat E2B sandbox; docs patterns
ericallam Mar 27, 2026
6ccd5b9
feat(sdk): add onChatSuspend/onChatResume hooks, exitAfterPreloadIdle…
ericallam Mar 28, 2026
715ad8f
Add support for triggering from the backend
ericallam Mar 28, 2026
bcf1c33
chat.task -> chat.agent
ericallam Mar 30, 2026
a66d95b
feat: upgrade streamdown to v2.5.0 with custom Trigger.dev Shiki theme
ericallam Apr 1, 2026
7a5e1f1
playground ui tweaks
ericallam Apr 1, 2026
6b9984a
Some design tweaks, improvements to playground options, rename unname…
ericallam Apr 1, 2026
e48f36d
Add the chat client and strip agent crumbs
ericallam Apr 1, 2026
acc181c
Add server-to-server chat support and subagent support to the playgro…
ericallam Apr 2, 2026
7fb1479
add agent mcp tools
ericallam Apr 2, 2026
3e4f10b
Add support for optionally validating UI messages
ericallam Apr 2, 2026
3533d2a
Support for upgrading an agent to a new version
ericallam Apr 3, 2026
3a01d0f
Add run agent view
ericallam Apr 10, 2026
11d4c84
feat(chat): add stopGeneration, fix onTurnComplete/onFinishPromise, a…
ericallam Apr 11, 2026
5b41bf6
fix(sdk): inject prepareStep in toStreamTextOptions even without chat…
ericallam Apr 13, 2026
0c06419
feat(chat): allow generateMessageId in uiMessageStreamOptions, auto-p…
ericallam Apr 14, 2026
209c074
feat(chat): tool approvals support — ID-matched message replacement, …
ericallam Apr 14, 2026
93fd67f
fix: restore applyPrepareMessages call after agentcrumbs strip
ericallam Apr 14, 2026
f99f87a
prevent preloads from firing twice when in React strictMode
ericallam Apr 14, 2026
17e18f4
feat(chat): add chat.response API for persistent data parts, transien…
ericallam Apr 14, 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).

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.
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`.
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.
22 changes: 22 additions & 0 deletions .claude/rules/package-installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
paths:
- "**/package.json"
---

# Installing Packages

When adding a new dependency to any package.json in the monorepo:

1. **Look up the latest version** on npm before adding:
```bash
pnpm view <package-name> version
```
If unsure which version to use (e.g. major version compatibility), confirm with the user.

2. **Edit the package.json directly** — do NOT use `pnpm add` as it can cause issues in the monorepo. Add the dependency with the correct version range (typically `^x.y.z`).

3. **Run `pnpm i` from the repo root** after editing to install and update the lockfile:
```bash
pnpm i
```
Always run from the repo root, not from the package directory.
6 changes: 6 additions & 0 deletions .server-changes/run-agent-view.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
area: webapp
type: feature
---

Add an Agent view to the run details page for runs whose `taskKind` annotation is `AGENT`. The view renders the agent's `UIMessage` conversation by subscribing to the run's `chat` realtime stream — the same data source as the Agent Playground content view. Switching is via a `Trace view` / `Agent view` segmented control above the run body, and the selected view is reflected in the URL via `?view=agent` so it's shareable.
6 changes: 6 additions & 0 deletions .server-changes/streamdown-v2-upgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
area: webapp
type: improvement
---

Upgrade streamdown from v1.4.0 to v2.5.0. Custom Shiki syntax highlighting theme matching our CodeMirror dark theme colors. Consolidate duplicated lazy StreamdownRenderer into a shared component.
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This file provides guidance to Claude Code when working with this repository. Su

This is a pnpm 10.23.0 monorepo using Turborepo. Run commands from root with `pnpm run`.

**Adding dependencies:** Edit `package.json` directly instead of using `pnpm add`, then run `pnpm i` from the repo root. See `.claude/rules/package-installation.md` for the full process.

```bash
pnpm run docker # Start Docker services (PostgreSQL, Redis, Electric)
pnpm run db:migrate # Run database migrations
Expand Down
13 changes: 13 additions & 0 deletions apps/webapp/app/components/BulkActionFilterSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,19 @@ export function BulkActionFilterSummary({
/>
);
}
case "sources": {
const values = Array.isArray(value) ? value : [`${value}`];
return (
<AppliedFilter
variant="minimal/medium"
key={key}
label={filterTitle(key)}
icon={filterIcon(key)}
value={appliedSummary(values)}
removable={false}
/>
);
}
default: {
assertNever(typedKey);
}
Expand Down
14 changes: 2 additions & 12 deletions apps/webapp/app/components/code/AIQueryInput.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
import { CheckIcon, PencilSquareIcon, PlusIcon, XMarkIcon } from "@heroicons/react/20/solid";
import { AnimatePresence, motion } from "framer-motion";
import { Suspense, lazy, useCallback, useEffect, useRef, useState } from "react";
import { Suspense, useCallback, useEffect, useRef, useState } from "react";
import { Button } from "~/components/primitives/Buttons";
import { Spinner } from "~/components/primitives/Spinner";
import { StreamdownRenderer } from "~/components/code/StreamdownRenderer";
import { useEnvironment } from "~/hooks/useEnvironment";
import { useOrganization } from "~/hooks/useOrganizations";
import { useProject } from "~/hooks/useProject";
import type { AITimeFilter } from "~/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/types";
import { cn } from "~/utils/cn";

// Lazy load streamdown components to avoid SSR issues
const StreamdownRenderer = lazy(() =>
import("streamdown").then((mod) => ({
default: ({ children, isAnimating }: { children: string; isAnimating: boolean }) => (
<mod.ShikiThemeContext.Provider value={["one-dark-pro", "one-dark-pro"]}>
<mod.Streamdown isAnimating={isAnimating}>{children}</mod.Streamdown>
</mod.ShikiThemeContext.Provider>
),
}))
);

type StreamEventType =
| { type: "thinking"; content: string }
| { type: "tool_call"; tool: string; args: unknown }
Expand Down
29 changes: 29 additions & 0 deletions apps/webapp/app/components/code/StreamdownRenderer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { lazy } from "react";
import type { CodeHighlighterPlugin } from "streamdown";

export const StreamdownRenderer = lazy(() =>
Promise.all([import("streamdown"), import("@streamdown/code"), import("./shikiTheme")]).then(
([{ Streamdown }, { createCodePlugin }, { triggerDarkTheme }]) => {
// Type assertion needed: @streamdown/code and streamdown resolve different shiki
// versions under pnpm, causing structurally-identical CodeHighlighterPlugin types
// to be considered incompatible (different BundledLanguage string unions).
const codePlugin = createCodePlugin({
themes: [triggerDarkTheme, triggerDarkTheme],
}) as unknown as CodeHighlighterPlugin;

return {
default: ({
children,
isAnimating = false,
}: {
children: string;
isAnimating?: boolean;
}) => (
<Streamdown isAnimating={isAnimating} plugins={{ code: codePlugin }}>
{children}
</Streamdown>
),
};
}
)
);
Loading
Loading