@trigger.dev/sdk 4.8.0 → 4.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/v3/ai-shared.d.ts +6 -0
- package/dist/commonjs/v3/ai-shared.js +7 -1
- package/dist/commonjs/v3/ai-shared.js.map +1 -1
- package/dist/commonjs/v3/ai.d.ts +45 -0
- package/dist/commonjs/v3/ai.js +110 -69
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/auth.d.ts +2 -1
- package/dist/commonjs/v3/auth.js +18 -12
- package/dist/commonjs/v3/auth.js.map +1 -1
- package/dist/commonjs/v3/chat-client.d.ts +11 -2
- package/dist/commonjs/v3/chat-client.js +28 -10
- package/dist/commonjs/v3/chat-client.js.map +1 -1
- package/dist/commonjs/v3/chat-react.d.ts +21 -0
- package/dist/commonjs/v3/chat-react.js +86 -30
- package/dist/commonjs/v3/chat-react.js.map +1 -1
- package/dist/commonjs/v3/chat.d.ts +1 -0
- package/dist/commonjs/v3/chat.js +4 -1
- package/dist/commonjs/v3/chat.js.map +1 -1
- package/dist/commonjs/v3/managedChatResponse.d.ts +13 -5
- package/dist/commonjs/v3/managedChatResponse.js +36 -18
- package/dist/commonjs/v3/managedChatResponse.js.map +1 -1
- package/dist/commonjs/v3/steeringContext.d.ts +11 -0
- package/dist/commonjs/v3/steeringContext.js +44 -3
- package/dist/commonjs/v3/steeringContext.js.map +1 -1
- package/dist/commonjs/v3/subAgentStream.d.ts +50 -0
- package/dist/commonjs/v3/subAgentStream.js +154 -0
- package/dist/commonjs/v3/subAgentStream.js.map +1 -0
- package/dist/commonjs/v3/transcriptStorage.js +3 -0
- package/dist/commonjs/v3/transcriptStorage.js.map +1 -1
- package/dist/commonjs/v3/uiMessageChunks.js +5 -1
- package/dist/commonjs/v3/uiMessageChunks.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/ai-shared.d.ts +6 -0
- package/dist/esm/v3/ai-shared.js +6 -0
- package/dist/esm/v3/ai-shared.js.map +1 -1
- package/dist/esm/v3/ai.d.ts +45 -0
- package/dist/esm/v3/ai.js +113 -72
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/auth.d.ts +2 -1
- package/dist/esm/v3/auth.js +19 -13
- package/dist/esm/v3/auth.js.map +1 -1
- package/dist/esm/v3/chat-client.d.ts +11 -2
- package/dist/esm/v3/chat-client.js +29 -11
- package/dist/esm/v3/chat-client.js.map +1 -1
- package/dist/esm/v3/chat-react.d.ts +21 -0
- package/dist/esm/v3/chat-react.js +81 -30
- package/dist/esm/v3/chat-react.js.map +1 -1
- package/dist/esm/v3/chat.d.ts +1 -0
- package/dist/esm/v3/chat.js +1 -0
- package/dist/esm/v3/chat.js.map +1 -1
- package/dist/esm/v3/managedChatResponse.d.ts +13 -5
- package/dist/esm/v3/managedChatResponse.js +36 -18
- package/dist/esm/v3/managedChatResponse.js.map +1 -1
- package/dist/esm/v3/steeringContext.d.ts +11 -0
- package/dist/esm/v3/steeringContext.js +44 -4
- package/dist/esm/v3/steeringContext.js.map +1 -1
- package/dist/esm/v3/subAgentStream.d.ts +50 -0
- package/dist/esm/v3/subAgentStream.js +149 -0
- package/dist/esm/v3/subAgentStream.js.map +1 -0
- package/dist/esm/v3/transcriptStorage.js +3 -0
- package/dist/esm/v3/transcriptStorage.js.map +1 -1
- package/dist/esm/v3/uiMessageChunks.js +5 -1
- package/dist/esm/v3/uiMessageChunks.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai/prompts.mdx +9 -6
- package/docs/ai-chat/background-injection.mdx +2 -0
- package/docs/ai-chat/chat-local.mdx +4 -4
- package/docs/ai-chat/client-protocol.mdx +1 -0
- package/docs/ai-chat/fast-starts.mdx +1 -1
- package/docs/ai-chat/frontend.mdx +15 -0
- package/docs/ai-chat/overview.mdx +5 -4
- package/docs/ai-chat/patterns/database-persistence.mdx +3 -3
- package/docs/ai-chat/patterns/native-compaction.mdx +6 -6
- package/docs/ai-chat/patterns/sub-agents.mdx +82 -56
- package/docs/ai-chat/patterns/version-upgrades.mdx +3 -3
- package/docs/ai-chat/pending-messages.mdx +2 -0
- package/docs/ai-chat/quick-start.mdx +1 -1
- package/docs/ai-chat/reference.mdx +22 -0
- package/docs/ai-chat/server-chat.mdx +11 -7
- package/docs/ai-chat/side-channels.mdx +2 -2
- package/docs/ai-chat/types.mdx +5 -5
- package/docs/config/config-file.mdx +2 -2
- package/docs/database-connections.mdx +2 -2
- package/docs/how-to-reduce-your-spend.mdx +4 -0
- package/docs/introduction.mdx +104 -24
- package/docs/limits.mdx +41 -0
- package/docs/mcp-tools.mdx +5 -0
- package/docs/observability/query.mdx +29 -0
- package/docs/self-hosting/docker.mdx +62 -0
- package/docs/self-hosting/env/supervisor.mdx +4 -0
- package/docs/self-hosting/env/webapp.mdx +38 -0
- package/docs/self-hosting/kubernetes.mdx +2 -0
- package/docs/self-hosting/overview.mdx +2 -0
- package/docs/troubleshooting-alerts.mdx +39 -0
- package/docs/webhooks/deliveries.mdx +4 -0
- package/docs/webhooks/overview.mdx +8 -0
- package/docs/webhooks/sources.mdx +3 -1
- package/docs/webhooks/waiters.mdx +3 -3
- package/package.json +2 -2
- package/skills/trigger-chat-agent-advanced/SKILL.md +17 -7
- package/skills/trigger-cost-savings/SKILL.md +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trigger.dev/sdk",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.2",
|
|
4
4
|
"description": "trigger.dev Node.JS SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@opentelemetry/api": "1.9.1",
|
|
71
71
|
"@opentelemetry/semantic-conventions": "1.41.1",
|
|
72
|
-
"@trigger.dev/core": "4.8.
|
|
72
|
+
"@trigger.dev/core": "4.8.2",
|
|
73
73
|
"uncrypto": "^0.1.3"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
@@ -95,22 +95,27 @@ mutate with `sessions.update`, end with `sessions.close` (terminal, idempotent).
|
|
|
95
95
|
|
|
96
96
|
### 2. Durable sub-agent as a streaming tool
|
|
97
97
|
|
|
98
|
-
`AgentChat` inside an AI SDK `tool()` delegates to a durable sub-agent;
|
|
99
|
-
|
|
98
|
+
`AgentChat` inside an AI SDK `tool()` delegates to a durable sub-agent; `chat.forwardSubAgent`
|
|
99
|
+
streams its reply to the frontend and returns the final message as the tool output. Give the tool a
|
|
100
|
+
`toModelOutput` so the model sees a compact summary.
|
|
100
101
|
|
|
101
102
|
```ts
|
|
102
103
|
import { tool } from "ai";
|
|
104
|
+
import { chat } from "@trigger.dev/sdk/ai";
|
|
103
105
|
import { AgentChat } from "@trigger.dev/sdk/chat";
|
|
104
106
|
import { z } from "zod";
|
|
105
107
|
|
|
106
108
|
const researchTool = tool({
|
|
107
109
|
description: "Delegate research to a specialist agent.",
|
|
108
110
|
inputSchema: z.object({ topic: z.string() }),
|
|
109
|
-
execute: async
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
execute: async ({ topic }, { toolCallId, abortSignal }) => {
|
|
112
|
+
const researcher = new AgentChat({ agent: "research-agent" });
|
|
113
|
+
try {
|
|
114
|
+
const stream = await researcher.sendMessage(topic, { abortSignal });
|
|
115
|
+
return await chat.forwardSubAgent(stream, { toolCallId }); // chunks out once, final UIMessage back
|
|
116
|
+
} finally {
|
|
117
|
+
await researcher.close();
|
|
118
|
+
}
|
|
114
119
|
},
|
|
115
120
|
toModelOutput: ({ output: message }) => {
|
|
116
121
|
const lastText = message?.parts?.findLast((p: { type: string }) => p.type === "text") as
|
|
@@ -121,6 +126,11 @@ const researchTool = tool({
|
|
|
121
126
|
});
|
|
122
127
|
```
|
|
123
128
|
|
|
129
|
+
On the frontend, `useSubAgentMessages()` from `@trigger.dev/sdk/chat/react` rebuilds each sub-agent
|
|
130
|
+
while it runs: pass its `onData` to `useChat` and render `subAgents.get(part.toolCallId) ?? part.output`.
|
|
131
|
+
Do not `yield* stream.messages()` from a tool: every snapshot repeats the whole message, so the bytes
|
|
132
|
+
written grow with the square of the reply length.
|
|
133
|
+
|
|
124
134
|
For a subtask exposed via `execute: ai.toolExecute(task)`, stream progress to the agent's run with
|
|
125
135
|
`chat.stream.writer({ target: "root" })`. `target` accepts `"self" | "parent" | "root" | <runId>`.
|
|
126
136
|
Inside the subtask, read context with `ai.toolCallId()` and `ai.chatContextOrThrow<typeof myChat>()`
|
|
@@ -105,6 +105,7 @@ Larger machines cost proportionally more per second of compute:
|
|
|
105
105
|
## Key principles
|
|
106
106
|
|
|
107
107
|
- **Waits > 5 seconds are free** — checkpointed, no compute charge.
|
|
108
|
+
- **Webhook filters skip runs** — a webhook delivery starts no run when no subscriber's filter matches, so it costs no compute (a run already waiting for that webhook still resumes). Receiving webhooks has no separate charge.
|
|
108
109
|
- **Start small, scale up** — the default `small-1x` is right for most tasks.
|
|
109
110
|
- **I/O-bound tasks don't need big machines** — API calls and DB queries wait on the network.
|
|
110
111
|
- **Debounce saves the most on high-frequency tasks** — it consolidates bursts into single runs.
|