@trigger.dev/sdk 4.5.6 → 4.5.8

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.
Files changed (50) hide show
  1. package/dist/commonjs/v3/agentSkillsRuntime.js +17 -7
  2. package/dist/commonjs/v3/agentSkillsRuntime.js.map +1 -1
  3. package/dist/commonjs/v3/ai.d.ts +49 -8
  4. package/dist/commonjs/v3/ai.js +258 -42
  5. package/dist/commonjs/v3/ai.js.map +1 -1
  6. package/dist/commonjs/v3/aiAutoTelemetry.js +3 -3
  7. package/dist/commonjs/v3/aiAutoTelemetry.js.map +1 -1
  8. package/dist/commonjs/v3/auth.d.ts +7 -3
  9. package/dist/commonjs/v3/auth.js +68 -13
  10. package/dist/commonjs/v3/auth.js.map +1 -1
  11. package/dist/commonjs/v3/auth.test.d.ts +1 -0
  12. package/dist/commonjs/v3/auth.test.js +149 -0
  13. package/dist/commonjs/v3/auth.test.js.map +1 -0
  14. package/dist/commonjs/v3/createStartSessionAction.test.js +33 -0
  15. package/dist/commonjs/v3/createStartSessionAction.test.js.map +1 -1
  16. package/dist/commonjs/v3/index.js +17 -7
  17. package/dist/commonjs/v3/index.js.map +1 -1
  18. package/dist/commonjs/v3/runs.d.ts +15 -15
  19. package/dist/commonjs/v3/skill.js +17 -7
  20. package/dist/commonjs/v3/skill.js.map +1 -1
  21. package/dist/commonjs/v3/test/test-session-handle.js +20 -8
  22. package/dist/commonjs/v3/test/test-session-handle.js.map +1 -1
  23. package/dist/commonjs/v3/triggerClient.js +17 -7
  24. package/dist/commonjs/v3/triggerClient.js.map +1 -1
  25. package/dist/commonjs/v3/triggerClient.types.test.js +17 -7
  26. package/dist/commonjs/v3/triggerClient.types.test.js.map +1 -1
  27. package/dist/commonjs/version.js +1 -1
  28. package/dist/esm/v3/ai.d.ts +49 -8
  29. package/dist/esm/v3/ai.js +259 -43
  30. package/dist/esm/v3/ai.js.map +1 -1
  31. package/dist/esm/v3/aiAutoTelemetry.js +3 -3
  32. package/dist/esm/v3/aiAutoTelemetry.js.map +1 -1
  33. package/dist/esm/v3/auth.d.ts +7 -3
  34. package/dist/esm/v3/auth.js +69 -14
  35. package/dist/esm/v3/auth.js.map +1 -1
  36. package/dist/esm/v3/auth.test.d.ts +1 -0
  37. package/dist/esm/v3/auth.test.js +147 -0
  38. package/dist/esm/v3/auth.test.js.map +1 -0
  39. package/dist/esm/v3/createStartSessionAction.test.js +33 -0
  40. package/dist/esm/v3/createStartSessionAction.test.js.map +1 -1
  41. package/dist/esm/v3/test/test-session-handle.js +20 -8
  42. package/dist/esm/v3/test/test-session-handle.js.map +1 -1
  43. package/dist/esm/version.js +1 -1
  44. package/docs/ai-chat/changelog.mdx +2 -2
  45. package/docs/ai-chat/compaction.mdx +2 -2
  46. package/docs/ai-chat/custom-agents.mdx +15 -20
  47. package/docs/ai-chat/fast-starts.mdx +2 -2
  48. package/docs/ai-chat/pending-messages.mdx +6 -2
  49. package/docs/ai-chat/reference.mdx +2 -2
  50. package/package.json +3 -3
@@ -160,11 +160,11 @@ for await (const turn of session) {
160
160
  });
161
161
 
162
162
  // Manual: pipe and capture separately
163
- const response = await chat.pipeAndCapture(result, { signal: turn.signal });
163
+ const { message } = await chat.pipeAndCapture(result, { signal: turn.signal });
164
164
 
165
- if (response) {
165
+ if (message) {
166
166
  // Custom processing before accumulating
167
- await turn.addResponse(response);
167
+ await turn.addResponse(message);
168
168
  }
169
169
 
170
170
  // Custom persistence, analytics, etc.
@@ -215,8 +215,8 @@ For full control, skip `createSession` and compose the primitives directly:
215
215
  | ------------------------------- | -------------------------------------------------------------------------------------------- |
216
216
  | `chat.messages` | Input stream for incoming messages — use `.waitWithIdleTimeout()` to wait for the next turn |
217
217
  | `chat.createStopSignal()` | Create a managed stop signal wired to the stop input stream |
218
- | `chat.pipeAndCapture(result)` | Pipe a `StreamTextResult` to the chat stream and capture the response |
219
- | `chat.writeTurnComplete()` | Signal the frontend that the current turn is complete |
218
+ | `chat.pipeAndCapture(result)` | Pipe a stream and capture the response; returns `{ message, status, error }` |
219
+ | `chat.writeTurnComplete()` | Signal turn complete; returns `{ lastEventId, sessionInEventId }` resume cursors |
220
220
  | `chat.MessageAccumulator` | Accumulates conversation messages across turns |
221
221
  | `chat.pipe(stream)` | Pipe a stream to the frontend (no response capture) |
222
222
  | `chat.cleanupAbortedParts(msg)` | Clean up incomplete parts from a stopped response |
@@ -285,21 +285,16 @@ export const myChat = chat.customAgent({
285
285
  stopWhen: stepCountIs(15),
286
286
  });
287
287
 
288
- let response;
289
- try {
290
- response = await chat.pipeAndCapture(result, { signal: combinedSignal });
291
- } catch (error) {
292
- if (error instanceof Error && error.name === "AbortError") {
293
- if (runSignal.aborted) break;
294
- // Stop — fall through to accumulate partial
295
- } else {
296
- throw error;
297
- }
298
- }
288
+ const { message, status, error } = await chat.pipeAndCapture(result, {
289
+ signal: combinedSignal,
290
+ });
291
+ // pipeAndCapture never throws: a user stop returns status "aborted" with
292
+ // the partial message, and a failure returns status "error" with `error`.
293
+ if (status === "error") throw error;
299
294
 
300
- if (response) {
295
+ if (message) {
301
296
  const cleaned =
302
- stop.signal.aborted && !runSignal.aborted ? chat.cleanupAbortedParts(response) : response;
297
+ stop.signal.aborted && !runSignal.aborted ? chat.cleanupAbortedParts(message) : message;
303
298
  await conversation.addResponse(cleaned);
304
299
  }
305
300
 
@@ -346,8 +341,8 @@ const messages = await conversation.addIncoming(
346
341
  );
347
342
 
348
343
  // After piping, add the response
349
- const response = await chat.pipeAndCapture(result);
350
- if (response) await conversation.addResponse(response);
344
+ const { message } = await chat.pipeAndCapture(result);
345
+ if (message) await conversation.addResponse(message);
351
346
 
352
347
  // Access accumulated messages for persistence
353
348
  conversation.uiMessages; // UIMessage[]
@@ -589,10 +589,10 @@ if (turn === 0 && payload.trigger === "handover-prepare") {
589
589
  messages: conversation.modelMessages,
590
590
  stopWhen: stepCountIs(10),
591
591
  });
592
- const response = await chat.pipeAndCapture(result, {
592
+ const { message } = await chat.pipeAndCapture(result, {
593
593
  originalMessages: conversation.uiMessages,
594
594
  });
595
- if (response) await conversation.addResponse(response);
595
+ if (message) await conversation.addResponse(message);
596
596
  }
597
597
  await chat.writeTurnComplete(); // on isFinal the warm partial is already the response
598
598
  return;
@@ -179,10 +179,14 @@ for (let turn = 0; turn < 100; turn++) {
179
179
  stopWhen: stepCountIs(15),
180
180
  });
181
181
 
182
- const response = await chat.pipeAndCapture(result);
182
+ const { message, status, error } = await chat.pipeAndCapture(result);
183
183
  sub.off();
184
184
 
185
- if (response) await conversation.addResponse(response);
185
+ // Keep any partial output, then branch on the outcome: pipeAndCapture no
186
+ // longer throws, so rethrow a real failure and don't complete a failed turn.
187
+ if (message) await conversation.addResponse(message);
188
+ if (status === "error") throw error;
189
+
186
190
  await chat.writeTurnComplete();
187
191
  }
188
192
  ```
@@ -503,8 +503,8 @@ All methods available on the `chat` object from `@trigger.dev/sdk/ai`.
503
503
  | `chat.agent(options)` | Create a chat agent |
504
504
  | `chat.createSession(payload, options)` | Create an async iterator for chat turns |
505
505
  | `chat.pipe(source, options?)` | Pipe a stream to the frontend (from anywhere inside a task) |
506
- | `chat.pipeAndCapture(source, options?)` | Pipe and capture the response `UIMessage` |
507
- | `chat.writeTurnComplete(options?)` | Signal the frontend that the current turn is complete |
506
+ | `chat.pipeAndCapture(source, options?)` | Pipe and capture the response; returns `{ message, status, error }` |
507
+ | `chat.writeTurnComplete(options?)` | Signal turn complete; returns `{ lastEventId, sessionInEventId }` resume cursors |
508
508
  | `chat.createStopSignal()` | Create a managed stop signal wired to the stop input stream |
509
509
  | `chat.messages` | Input stream for incoming messages — use `.waitWithIdleTimeout()` |
510
510
  | `chat.local<T>({ id })` | Create a per-run typed local (see [`chat.local`](/ai-chat/chat-local)) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trigger.dev/sdk",
3
- "version": "4.5.6",
3
+ "version": "4.5.8",
4
4
  "description": "trigger.dev Node.JS SDK",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -66,7 +66,7 @@
66
66
  "dependencies": {
67
67
  "@opentelemetry/api": "1.9.1",
68
68
  "@opentelemetry/semantic-conventions": "1.41.1",
69
- "@trigger.dev/core": "4.5.6",
69
+ "@trigger.dev/core": "4.5.8",
70
70
  "chalk": "^5.2.0",
71
71
  "cronstrue": "^2.21.0",
72
72
  "debug": "^4.3.4",
@@ -78,7 +78,7 @@
78
78
  },
79
79
  "devDependencies": {
80
80
  "@ai-sdk/provider": "3.0.8",
81
- "@arethetypeswrong/cli": "^0.15.4",
81
+ "@arethetypeswrong/cli": "^0.18.5",
82
82
  "@types/debug": "^4.1.7",
83
83
  "@types/react": "^19.2.14",
84
84
  "@types/slug": "^5.0.3",