Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
918ddd2
feat: add @trigger.dev/ai package with TriggerChatTransport
cursoragent Feb 15, 2026
a0dcb4e
test: add comprehensive unit tests for TriggerChatTransport
cursoragent Feb 15, 2026
a5a7122
refactor: polish TriggerChatTransport implementation
cursoragent Feb 15, 2026
f15cb35
test: add abort signal, multiple sessions, and body merging tests
cursoragent Feb 15, 2026
334c8bb
chore: add changeset for @trigger.dev/ai package
cursoragent Feb 15, 2026
65e1601
refactor: remove internal ChatSessionState from public exports
cursoragent Feb 15, 2026
98feae0
feat: support dynamic accessToken function for token refresh
cursoragent Feb 15, 2026
14a740f
refactor: avoid double-resolving accessToken in sendMessages
cursoragent Feb 15, 2026
60ebad4
feat: add chat transport and AI chat helpers to @trigger.dev/sdk
cursoragent Feb 15, 2026
99aeced
test: move chat transport tests to @trigger.dev/sdk
cursoragent Feb 15, 2026
3f04726
refactor: delete packages/ai/ — moved to @trigger.dev/sdk subpaths
cursoragent Feb 15, 2026
1fcdf33
chore: update changeset to target @trigger.dev/sdk
cursoragent Feb 15, 2026
dfb738b
fix: address CodeRabbit review feedback
cursoragent Feb 15, 2026
d828d65
docs(ai): add AI Chat with useChat guide
cursoragent Feb 15, 2026
6edf643
feat(reference): add ai-chat Next.js reference project
cursoragent Feb 15, 2026
1c14424
fix(reference): use compatible @ai-sdk v3 packages, await convertToMo…
cursoragent Feb 15, 2026
1d5e862
Use a single run with iterative waitpoint token completions
ericallam Feb 21, 2026
800315d
Added tool example
ericallam Feb 21, 2026
318f26b
expose a useTriggerChatTransport hook
ericallam Feb 21, 2026
360fceb
use input streams and rename chatTask and chatState to chat.task and …
ericallam Mar 3, 2026
1842781
add stopping support and fix issue with the OpenAI responses API and …
ericallam Mar 4, 2026
0be4f02
Add warmTimeoutInSeconds option
ericallam Mar 4, 2026
48f234e
Add clientData support
ericallam Mar 4, 2026
d34e927
provide already converted UIMessages to the run function for better dx
ericallam Mar 4, 2026
860551f
Added better telemetry support to view turns
ericallam Mar 4, 2026
1fb5891
Fix double looping when resuming from an input stream waitpoint
ericallam Mar 4, 2026
d1d22c4
Add some pending message support in the example
ericallam Mar 4, 2026
16bafcf
Accumulate messages in the task, allowing us to only have to send use…
ericallam Mar 5, 2026
896f061
build full example with persisting messages, adding necessary hooks, …
ericallam Mar 5, 2026
a0d0216
Add ai chat to the sidebar for now
ericallam Mar 5, 2026
cee3a21
remove postinstall hook
ericallam Mar 5, 2026
52610fb
feat: add onTurnStart hook, lastEventId support, and stream resume de…
ericallam Mar 5, 2026
5338b01
Minor fixes around reconnecting streams
ericallam Mar 6, 2026
1e3b15e
update pnpm link file
ericallam Mar 6, 2026
1ce8082
fixed chat tests
ericallam Mar 6, 2026
b74e7dd
use locals for the chat pipe counter instead of a module global
ericallam Mar 6, 2026
8008e09
Add triggerOptions to the transport, auto-tag with the chat ID
ericallam Mar 6, 2026
ee7d58e
Make clientData typesafe and pass to all chat.task hooks
ericallam Mar 6, 2026
a65a564
feat: add chat.local for per-run typed data with Proxy access and dir…
ericallam Mar 6, 2026
fa9920f
feat(chat): add stop handling, abort cleanup, continuation support, a…
ericallam Mar 7, 2026
a424e39
Some improvements to the example ai-chat
ericallam Mar 7, 2026
fe308cd
feat(chat): expose typed chat.stream, add deepResearch subtask exampl…
ericallam Mar 8, 2026
6de6a3d
feat(ai): pass chat context and toolCallId to subtasks, add typed ai.…
ericallam Mar 8, 2026
faaa6ed
feat(chat): add preload support, dynamic tools, and preload-specific …
ericallam Mar 9, 2026
f8a94b7
docs: add mermaid architecture diagrams for ai-chat system
ericallam Mar 9, 2026
2e9c997
docs: add sequence diagrams to ai-chat guide
ericallam Mar 9, 2026
eec966d
feat(chat): auto-hydrate chat.local values in ai.tool subtasks
ericallam Mar 9, 2026
7724279
feat(chat): add chat.defer(), preload toggle, TTFB measurement, and f…
ericallam Mar 9, 2026
7345541
fix(reference): replace hand-rolled HTML stripping with turndown
ericallam Mar 9, 2026
97e0e9e
feat(streams): add inputStream.waitWithWarmup(), warm timeout config …
ericallam Mar 9, 2026
350e4e4
feat(chat): add composable primitives, raw task example, and task mod…
ericallam Mar 10, 2026
92c3ebc
Introduce the chat session API and better docs organization
ericallam Mar 10, 2026
87cb7d7
Add support for toUIMessageStream() options
ericallam Mar 10, 2026
6f0df94
Add metadata to the streamText call
ericallam Mar 12, 2026
590bcb5
feat(chat): add chat.prompt API with provider registry support
ericallam Mar 23, 2026
9d51d5d
refactor: rename warmTimeout to idleTimeout across chat APIs
ericallam Mar 23, 2026
248acea
feat: support message compaction
ericallam Mar 24, 2026
c7f244e
better compaction support in our other chat variants
ericallam Mar 24, 2026
5711f8b
feat(chat): add compaction option, pendingMessages steering, and useP…
ericallam Mar 25, 2026
6c00a08
Add a writer to easily write chunks in callbacks
ericallam Mar 26, 2026
876ce39
feat(ai): add triggerAndSubscribe method and use it in ai.tool
ericallam Mar 26, 2026
2932789
feat(chat): add chat.inject() for background context injection and ch…
ericallam Mar 26, 2026
2466081
feat(sdk): ToolSet typing for toolFromTask, ai.toolExecute, deprecate…
ericallam Mar 27, 2026
d3712a6
Add run-scoped PAT renewal for chat transport
ericallam Mar 27, 2026
a430ee3
feat(sdk): ctx on chat.task hooks; ai-chat E2B sandbox; docs patterns
ericallam Mar 27, 2026
8a6b9c1
feat(sdk): add onChatSuspend/onChatResume hooks, exitAfterPreloadIdle…
ericallam Mar 28, 2026
af8728f
Add support for triggering from the backend
ericallam Mar 28, 2026
f0b5791
chat.task -> chat.agent
ericallam Mar 30, 2026
c111047
feat: upgrade streamdown to v2.5.0 with custom Trigger.dev Shiki theme
ericallam Apr 1, 2026
7157ab9
playground ui tweaks
ericallam Apr 1, 2026
ad41d46
Some design tweaks, improvements to playground options, rename unname…
ericallam Apr 1, 2026
1a97f3a
Add the chat client and strip agent crumbs
ericallam Apr 1, 2026
7fc60db
Add server-to-server chat support and subagent support to the playgro…
ericallam Apr 2, 2026
c4212a0
add agent mcp tools
ericallam Apr 2, 2026
a0083dd
Add support for optionally validating UI messages
ericallam Apr 2, 2026
d8d305b
Support for upgrading an agent to a new version
ericallam Apr 3, 2026
9f476b8
Add run agent view
ericallam Apr 10, 2026
9d1c5ed
feat(chat): add stopGeneration, fix onTurnComplete/onFinishPromise, a…
ericallam Apr 11, 2026
5118645
fix(sdk): inject prepareStep in toStreamTextOptions even without chat…
ericallam Apr 13, 2026
87439ab
feat(chat): allow generateMessageId in uiMessageStreamOptions, auto-p…
ericallam Apr 14, 2026
7c19154
feat(chat): tool approvals support — ID-matched message replacement, …
ericallam Apr 14, 2026
601a796
fix: restore applyPrepareMessages call after agentcrumbs strip
ericallam Apr 14, 2026
03899af
prevent preloads from firing twice when in React strictMode
ericallam Apr 14, 2026
0a748e5
feat(chat): add chat.response API for persistent data parts, transien…
ericallam Apr 14, 2026
4dbc385
feat(chat): add hydrateMessages, chat.history, and custom actions
ericallam Apr 15, 2026
2df3283
fix(chat): prevent useChat resume from hanging on completed turns
ericallam Apr 15, 2026
3884bc5
fix pnpm lock file
ericallam Apr 16, 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