@trigger.dev/sdk 0.0.0-prerelease-20260909071038 → 0.0.0-prerelease-streamfix-20260909094302

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 (142) hide show
  1. package/dist/commonjs/imports/ai-runtime-cjs.cjs.map +1 -1
  2. package/dist/commonjs/imports/ai-runtime.js +0 -2
  3. package/dist/commonjs/v3/ai-shared.d.ts +0 -15
  4. package/dist/commonjs/v3/ai-shared.js +1 -35
  5. package/dist/commonjs/v3/ai-shared.js.map +1 -1
  6. package/dist/commonjs/v3/ai.d.ts +25 -275
  7. package/dist/commonjs/v3/ai.js +308 -1283
  8. package/dist/commonjs/v3/ai.js.map +1 -1
  9. package/dist/commonjs/v3/chat-client.d.ts +2 -11
  10. package/dist/commonjs/v3/chat-client.js +111 -227
  11. package/dist/commonjs/v3/chat-client.js.map +1 -1
  12. package/dist/commonjs/v3/chat-react.d.ts +0 -88
  13. package/dist/commonjs/v3/chat-react.js +1 -130
  14. package/dist/commonjs/v3/chat-react.js.map +1 -1
  15. package/dist/commonjs/v3/chat-server.d.ts +6 -42
  16. package/dist/commonjs/v3/chat-server.js +7 -52
  17. package/dist/commonjs/v3/chat-server.js.map +1 -1
  18. package/dist/commonjs/v3/chat.d.ts +10 -92
  19. package/dist/commonjs/v3/chat.js +73 -328
  20. package/dist/commonjs/v3/chat.js.map +1 -1
  21. package/dist/commonjs/v3/sessions.d.ts +2 -15
  22. package/dist/commonjs/v3/sessions.js +1 -12
  23. package/dist/commonjs/v3/sessions.js.map +1 -1
  24. package/dist/commonjs/v3/shared.js +36 -30
  25. package/dist/commonjs/v3/shared.js.map +1 -1
  26. package/dist/commonjs/v3/test/index.d.ts +0 -1
  27. package/dist/commonjs/v3/test/index.js +1 -3
  28. package/dist/commonjs/v3/test/index.js.map +1 -1
  29. package/dist/commonjs/v3/test/mock-chat-agent.d.ts +4 -47
  30. package/dist/commonjs/v3/test/mock-chat-agent.js +4 -115
  31. package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
  32. package/dist/commonjs/v3/test/test-session-handle.js +0 -6
  33. package/dist/commonjs/v3/test/test-session-handle.js.map +1 -1
  34. package/dist/commonjs/version.js +1 -1
  35. package/dist/esm/imports/ai-runtime.d.ts +2 -2
  36. package/dist/esm/imports/ai-runtime.js +2 -2
  37. package/dist/esm/imports/ai-runtime.js.map +1 -1
  38. package/dist/esm/v3/ai-shared.d.ts +0 -15
  39. package/dist/esm/v3/ai-shared.js +0 -33
  40. package/dist/esm/v3/ai-shared.js.map +1 -1
  41. package/dist/esm/v3/ai.d.ts +25 -275
  42. package/dist/esm/v3/ai.js +305 -1275
  43. package/dist/esm/v3/ai.js.map +1 -1
  44. package/dist/esm/v3/chat-client.d.ts +2 -11
  45. package/dist/esm/v3/chat-client.js +112 -228
  46. package/dist/esm/v3/chat-client.js.map +1 -1
  47. package/dist/esm/v3/chat-react.d.ts +0 -88
  48. package/dist/esm/v3/chat-react.js +1 -127
  49. package/dist/esm/v3/chat-react.js.map +1 -1
  50. package/dist/esm/v3/chat-server.d.ts +6 -42
  51. package/dist/esm/v3/chat-server.js +8 -53
  52. package/dist/esm/v3/chat-server.js.map +1 -1
  53. package/dist/esm/v3/chat.d.ts +10 -92
  54. package/dist/esm/v3/chat.js +74 -329
  55. package/dist/esm/v3/chat.js.map +1 -1
  56. package/dist/esm/v3/sessions.d.ts +2 -15
  57. package/dist/esm/v3/sessions.js +1 -11
  58. package/dist/esm/v3/sessions.js.map +1 -1
  59. package/dist/esm/v3/shared.js +23 -17
  60. package/dist/esm/v3/shared.js.map +1 -1
  61. package/dist/esm/v3/test/index.d.ts +0 -1
  62. package/dist/esm/v3/test/index.js +0 -1
  63. package/dist/esm/v3/test/index.js.map +1 -1
  64. package/dist/esm/v3/test/mock-chat-agent.d.ts +4 -47
  65. package/dist/esm/v3/test/mock-chat-agent.js +6 -117
  66. package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
  67. package/dist/esm/v3/test/test-session-handle.js +0 -6
  68. package/dist/esm/v3/test/test-session-handle.js.map +1 -1
  69. package/dist/esm/version.js +1 -1
  70. package/docs/ai-chat/actions.mdx +23 -55
  71. package/docs/ai-chat/anatomy.mdx +3 -3
  72. package/docs/ai-chat/backend.mdx +48 -125
  73. package/docs/ai-chat/background-injection.mdx +19 -69
  74. package/docs/ai-chat/client-protocol.mdx +4 -5
  75. package/docs/ai-chat/compaction.mdx +7 -13
  76. package/docs/ai-chat/custom-agents.mdx +0 -23
  77. package/docs/ai-chat/fast-starts.mdx +20 -27
  78. package/docs/ai-chat/frontend.mdx +14 -19
  79. package/docs/ai-chat/lifecycle-hooks.mdx +2 -6
  80. package/docs/ai-chat/migrating-from-a-route-handler.mdx +14 -16
  81. package/docs/ai-chat/patterns/database-persistence.mdx +2 -6
  82. package/docs/ai-chat/patterns/persistence-and-replay.mdx +23 -34
  83. package/docs/ai-chat/patterns/skills.mdx +10 -7
  84. package/docs/ai-chat/patterns/version-upgrades.mdx +6 -79
  85. package/docs/ai-chat/pending-messages.mdx +3 -3
  86. package/docs/ai-chat/prompt-caching.mdx +25 -23
  87. package/docs/ai-chat/quick-start.mdx +11 -11
  88. package/docs/ai-chat/reference.mdx +9 -67
  89. package/docs/ai-chat/sessions.mdx +1 -6
  90. package/docs/ai-chat/testing.mdx +1 -2
  91. package/docs/ai-chat/tools.mdx +13 -18
  92. package/docs/ai-chat/upgrade-guide.mdx +2 -2
  93. package/docs/apikeys.mdx +45 -27
  94. package/docs/config/extensions/syncEnvVars.mdx +0 -6
  95. package/docs/deploy-environment-variables.mdx +2 -23
  96. package/docs/deployment/overview.mdx +8 -4
  97. package/docs/deployment/preview-branches.mdx +4 -4
  98. package/docs/deployment/version-skew-protection.mdx +0 -62
  99. package/docs/manual-setup.mdx +7 -7
  100. package/docs/mcp-tools.mdx +0 -9
  101. package/docs/quick-start.mdx +3 -3
  102. package/docs/realtime/auth.mdx +1 -1
  103. package/docs/self-hosting/security.mdx +0 -5
  104. package/docs/tasks/scheduled.mdx +0 -24
  105. package/docs/triggering.mdx +1 -1
  106. package/package.json +4 -4
  107. package/skills/trigger-authoring-chat-agent/SKILL.md +29 -41
  108. package/skills/trigger-chat-agent-advanced/SKILL.md +12 -31
  109. package/dist/commonjs/v3/chatSnapshotIo.d.ts +0 -2
  110. package/dist/commonjs/v3/chatSnapshotIo.js +0 -174
  111. package/dist/commonjs/v3/chatSnapshotIo.js.map +0 -1
  112. package/dist/commonjs/v3/chatVersionSkew.d.ts +0 -12
  113. package/dist/commonjs/v3/chatVersionSkew.js +0 -30
  114. package/dist/commonjs/v3/chatVersionSkew.js.map +0 -1
  115. package/dist/commonjs/v3/externalDeploymentId.d.ts +0 -23
  116. package/dist/commonjs/v3/externalDeploymentId.js +0 -43
  117. package/dist/commonjs/v3/externalDeploymentId.js.map +0 -1
  118. package/dist/commonjs/v3/test/transcript-storage-tests.d.ts +0 -40
  119. package/dist/commonjs/v3/test/transcript-storage-tests.js +0 -258
  120. package/dist/commonjs/v3/test/transcript-storage-tests.js.map +0 -1
  121. package/dist/commonjs/v3/transcriptStorage.d.ts +0 -229
  122. package/dist/commonjs/v3/transcriptStorage.js +0 -321
  123. package/dist/commonjs/v3/transcriptStorage.js.map +0 -1
  124. package/dist/esm/v3/chatSnapshotIo.d.ts +0 -2
  125. package/dist/esm/v3/chatSnapshotIo.js +0 -166
  126. package/dist/esm/v3/chatSnapshotIo.js.map +0 -1
  127. package/dist/esm/v3/chatVersionSkew.d.ts +0 -12
  128. package/dist/esm/v3/chatVersionSkew.js +0 -27
  129. package/dist/esm/v3/chatVersionSkew.js.map +0 -1
  130. package/dist/esm/v3/externalDeploymentId.d.ts +0 -23
  131. package/dist/esm/v3/externalDeploymentId.js +0 -38
  132. package/dist/esm/v3/externalDeploymentId.js.map +0 -1
  133. package/dist/esm/v3/test/transcript-storage-tests.d.ts +0 -40
  134. package/dist/esm/v3/test/transcript-storage-tests.js +0 -255
  135. package/dist/esm/v3/test/transcript-storage-tests.js.map +0 -1
  136. package/dist/esm/v3/transcriptStorage.d.ts +0 -229
  137. package/dist/esm/v3/transcriptStorage.js +0 -309
  138. package/dist/esm/v3/transcriptStorage.js.map +0 -1
  139. package/docs/ai-chat/patterns/native-compaction.mdx +0 -310
  140. package/docs/ai-chat/transcript-storage.mdx +0 -233
  141. package/docs/reports.mdx +0 -157
  142. package/docs/troubleshooting-zod.mdx +0 -158
@@ -1 +1 @@
1
- {"version":3,"file":"ai-runtime-cjs.cjs","sourceRoot":"","sources":["../../../src/imports/ai-runtime-cjs.cts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,iFAAiF;;AAEjF,aAAa;AACb,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzB,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,sBAAsB,GAAG,EAAE,CAAC,sBAAsB,CAAC;AAClE,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;AAC5C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;AAC1C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;AAC5C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC;AAC9C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;AAC1C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,mBAAmB,GAAG,EAAE,CAAC,mBAAmB,CAAC;AAC5D,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;AAC5C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;AAC1C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;AAC9B,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,CAAC"}
1
+ {"version":3,"file":"ai-runtime-cjs.cjs","sourceRoot":"","sources":["../../../src/imports/ai-runtime-cjs.cts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,iFAAiF;;AAEjF,aAAa;AACb,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzB,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,sBAAsB,GAAG,EAAE,CAAC,sBAAsB,CAAC;AAClE,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;AAC5C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;AAC1C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;AAC5C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC;AAC9C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;AAC1C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,mBAAmB,GAAG,EAAE,CAAC,mBAAmB,CAAC;AAC5D,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;AAC5C,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;AAC9B,aAAa;AACb,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,CAAC"}
@@ -21,8 +21,6 @@ module.exports.readUIMessageStream = ai.readUIMessageStream;
21
21
  // @ts-ignore
22
22
  module.exports.stepCountIs = ai.stepCountIs;
23
23
  // @ts-ignore
24
- module.exports.streamText = ai.streamText;
25
- // @ts-ignore
26
24
  module.exports.tool = ai.tool;
27
25
  // @ts-ignore
28
26
  module.exports.zodSchema = ai.zodSchema;
@@ -139,18 +139,3 @@ export declare function slimSubmitMessageForWire<TMsg extends UIMessage | undefi
139
139
  * long ID degrades to "not filterable by chat" rather than failing to start.
140
140
  */
141
141
  export declare function chatRunTags(chatId: string, userTags?: string[]): string[];
142
- /**
143
- * A session body that ends without a turn-complete is only terminal when the
144
- * server says the session settled — otherwise the turn is still running and
145
- * the connection was lost (long-poll window closed, proxy restarted). Both
146
- * transports resubscribe from the last event id, bounded so a permanently
147
- * empty stream can't spin.
148
- */
149
- export declare const MAX_EOF_RESUBSCRIBES = 5;
150
- /**
151
- * Backoff before the nth (1-based) EOF resubscribe, jittered so many clients
152
- * dropped by the same window don't reconnect in lockstep. Resolves early on
153
- * abort — otherwise a stop landing mid-backoff leaves the stream open for the
154
- * rest of it.
155
- */
156
- export declare function waitBeforeEofResubscribe(attempt: number, signal: AbortSignal): Promise<void>;
@@ -16,11 +16,10 @@
16
16
  * import from `ai.ts`.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.MAX_EOF_RESUBSCRIBES = exports.PENDING_MESSAGE_INJECTED_TYPE = void 0;
19
+ exports.PENDING_MESSAGE_INJECTED_TYPE = void 0;
20
20
  exports.upsertIncomingMessage = upsertIncomingMessage;
21
21
  exports.slimSubmitMessageForWire = slimSubmitMessageForWire;
22
22
  exports.chatRunTags = chatRunTags;
23
- exports.waitBeforeEofResubscribe = waitBeforeEofResubscribe;
24
23
  /**
25
24
  * Message-part `type` value for the pending-message data part the agent
26
25
  * injects when a follow-up message arrives mid-turn.
@@ -179,37 +178,4 @@ function chatRunTags(chatId, userTags = []) {
179
178
  const tags = chatTag.length <= MAX_RUN_TAG_LENGTH ? [chatTag, ...userTags] : [...userTags];
180
179
  return tags.slice(0, MAX_RUN_TAGS);
181
180
  }
182
- /**
183
- * A session body that ends without a turn-complete is only terminal when the
184
- * server says the session settled — otherwise the turn is still running and
185
- * the connection was lost (long-poll window closed, proxy restarted). Both
186
- * transports resubscribe from the last event id, bounded so a permanently
187
- * empty stream can't spin.
188
- */
189
- exports.MAX_EOF_RESUBSCRIBES = 5;
190
- /**
191
- * Backoff before the nth (1-based) EOF resubscribe, jittered so many clients
192
- * dropped by the same window don't reconnect in lockstep. Resolves early on
193
- * abort — otherwise a stop landing mid-backoff leaves the stream open for the
194
- * rest of it.
195
- */
196
- function waitBeforeEofResubscribe(attempt, signal) {
197
- // An already-aborted signal never fires `abort` again, so a listener added
198
- // here would wait out the whole backoff.
199
- if (signal.aborted)
200
- return Promise.resolve();
201
- return new Promise((resolve) => {
202
- let timer;
203
- const done = () => {
204
- clearTimeout(timer);
205
- signal.removeEventListener("abort", done);
206
- resolve();
207
- };
208
- const backoff = Math.min(100 * 2 ** (attempt - 1), 5_000);
209
- timer = setTimeout(done, backoff * (0.5 + Math.random() * 0.5));
210
- signal.addEventListener("abort", done);
211
- if (signal.aborted)
212
- done();
213
- });
214
- }
215
181
  //# sourceMappingURL=ai-shared.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-shared.js","sourceRoot":"","sources":["../../../src/v3/ai-shared.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;AAKH;;;GAGG;AACU,QAAA,6BAA6B,GAAG,+BAAwC,CAAC;AA0DtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,+BACE,MAAc,EACd,KAGC;IAED,IAAI,KAAK,CAAC,OAAO,KAAK,gBAAgB;QAAE,OAAO,KAAK,CAAC;IACrD,IAAI,KAAK,CAAC,gBAAgB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,MAAM,GAAG,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzE,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC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ream, type RealtimeDefinedStream, type TaskIdentifier, type TaskOptions, type TaskRunContext, type TaskSchema, type TaskWithSchema, type AnySessionChannel, type SessionChannelName } from "@trigger.dev/core/v3";
2
- import type { streamText as aiStreamTextSignature, FinishReason, LanguageModelUsage, ModelMessage, SystemModelMessage, ProviderMetadata, Tool, ToolSet, UIMessage, UIMessageChunk, UIMessageStreamOptions } from "ai";
3
- import { type TranscriptLoadResult, type TranscriptStorage } from "./transcriptStorage.js";
1
+ import { type AnyTask, type Task, type ChatSnapshotV1, type ApiClientConfiguration, type inferSchemaIn, type inferSchemaOut, type MachinePresetName, type RealtimeDefinedInputStream, type RealtimeDefinedStream, type SessionTriggerConfig, type TaskIdentifier, type TaskOptions, type TaskRunContext, type TaskSchema, type TaskWithSchema, type AnySessionChannel, type SessionChannelName } from "@trigger.dev/core/v3";
2
+ import type { FinishReason, LanguageModelUsage, ModelMessage, ProviderMetadata, Tool, ToolSet, UIMessage, UIMessageChunk, UIMessageStreamOptions } from "ai";
4
3
  import { type ChatInputChunk, type ChatTaskWirePayload, type InferChatClientData, type InferChatUIMessage, type InferChatUIMessageFromTools, PENDING_MESSAGE_INJECTED_TYPE, upsertIncomingMessage } from "./ai-shared.js";
5
4
  import { locals } from "./locals.js";
6
5
  import type { ResolvedPrompt } from "./prompt.js";
@@ -12,8 +11,7 @@ type ToolCallOptions = {
12
11
  experimental_context?: unknown;
13
12
  context?: unknown;
14
13
  };
15
- import { type ChatVersionSkewPolicy } from "./chatVersionSkew.js";
16
- import { type SessionChannelHandleFor, type SessionTriggerConfigInput } from "./sessions.js";
14
+ import { type SessionChannelHandleFor } from "./sessions.js";
17
15
  /** Re-export for typing `ctx` in `chat.agent` hooks without importing `@trigger.dev/core`. */
18
16
  export type { TaskRunContext } from "@trigger.dev/core/v3";
19
17
  export type ToolCallExecutionOptions = {
@@ -34,8 +32,8 @@ type ChatTurnContext<TClientData = unknown> = {
34
32
  continuation: boolean;
35
33
  clientData?: TClientData;
36
34
  };
37
- export { __readChatSnapshotProductionPathForTests, __setReadChatSnapshotImplForTests, __setWriteChatSnapshotImplForTests, __writeChatSnapshotProductionPathForTests, } from "./chatSnapshotIo.js";
38
- export { defaultStorage, memoryTranscriptStorage, reduceTranscriptChanges, snapshotTranscriptStorage, type LoadContextEvent, type MemoryTranscriptStorage, type TranscriptChange, type TranscriptChangeReason, type TranscriptChangeset, type TranscriptCursors, type TranscriptLoadOptions, type TranscriptLoadResult, type TranscriptScope, type TranscriptState, type TranscriptStorage, type TranscriptStorageContext, } from "./transcriptStorage.js";
35
+ export declare function __setReadChatSnapshotImplForTests(impl: ReadChatSnapshotImpl | undefined): void;
36
+ export declare function __setWriteChatSnapshotImplForTests(impl: WriteChatSnapshotImpl | undefined): void;
39
37
  type ReplaySessionOutTailImpl = <TUIMessage extends UIMessage>(sessionId: string, options?: {
40
38
  lastEventId?: string;
41
39
  }) => Promise<ReplaySessionOutTailResult<TUIMessage>>;
@@ -203,7 +201,7 @@ export type ChatTaskPayload<TClientData = unknown> = {
203
201
  * to short-circuit the LLM call when an action doesn't need a response.
204
202
  * - `"close"`: The chat session is being closed (internal; `run()` is not called).
205
203
  */
206
- trigger: "submit-message" | "regenerate-message" | "preload" | "action" | "action-turn" | "close";
204
+ trigger: "submit-message" | "regenerate-message" | "preload" | "action" | "close";
207
205
  /** The ID of the message to regenerate (only for `"regenerate-message"`) */
208
206
  messageId?: string;
209
207
  /** Custom data from the frontend (passed via `metadata` on `sendMessage()` or the transport). */
@@ -244,16 +242,6 @@ export type ChatTaskRunPayload<TClientData = unknown, TTools extends ToolSet = T
244
242
  * Use for tags, metadata, parent run links, or any API that needs the full run record.
245
243
  */
246
244
  ctx: TaskRunContext;
247
- /**
248
- * `streamText` with this agent's managed options already applied: the
249
- * prompt from `chat.prompt.set()`, the skill tools, telemetry, and the
250
- * `prepareStep` that delivers steering, compaction and injected context.
251
- *
252
- * Prefer it over importing `streamText` from `ai`. The imported one takes
253
- * none of that unless you spread `chat.toStreamTextOptions()` yourself, and
254
- * forgetting the spread fails silently.
255
- */
256
- streamText: AiStreamTextFn;
257
245
  /** Token usage from the previous turn. Undefined on turn 0. */
258
246
  previousTurnUsage?: LanguageModelUsage;
259
247
  /** Cumulative token usage across all completed turns so far. */
@@ -850,12 +838,6 @@ export declare function buildSkillTools(skills: ResolvedSkill[]): Record<string,
850
838
  * Options for {@link toStreamTextOptions}.
851
839
  */
852
840
  export type ToStreamTextOptionsOptions = {
853
- /**
854
- * A base system prompt, used when `chat.prompt.set()` has not supplied one.
855
- * `chat.agent({ system })` and a `system` passed to the managed `streamText`
856
- * both arrive here.
857
- */
858
- system?: string | SystemModelMessage;
859
841
  /** Additional telemetry metadata merged into `experimental_telemetry.metadata`. */
860
842
  telemetry?: Record<string, string>;
861
843
  /**
@@ -926,23 +908,6 @@ export type SystemCacheControl = {
926
908
  *
927
909
  * If no prompt has been set, returns `{}` (no-op spread).
928
910
  */
929
- /**
930
- * The AI SDK's own `streamText` signature, borrowed rather than restated.
931
- *
932
- * The peer range spans `ai` v5, v6 and v7, whose `streamText` options differ.
933
- * Describing the shape here would drift against all three; `typeof` resolves to
934
- * whichever version the user installed, so generics, overloads and tool
935
- * inference are exactly theirs.
936
- */
937
- type AiStreamTextFn = typeof aiStreamTextSignature;
938
- /**
939
- * The `streamText` handed to a `chat.agent` `run()`, carrying the agent's
940
- * managed options.
941
- *
942
- * Exported so a loop factored out of `run` can take it as a parameter and keep
943
- * them: `function loop(messages: ModelMessage[], streamText: ChatStreamText)`.
944
- */
945
- export type ChatStreamText = AiStreamTextFn;
946
911
  declare function toStreamTextOptions(options?: ToStreamTextOptionsOptions): Record<string, unknown>;
947
912
  /**
948
913
  * Options for `pipeChat`.
@@ -988,37 +953,6 @@ export type ChatUIMessageStreamOptions<TUIM extends UIMessage = UIMessage> = Omi
988
953
  type UIMessageStreamable = {
989
954
  toUIMessageStream: (...args: any[]) => AsyncIterable<unknown> | ReadableStream<unknown>;
990
955
  };
991
- declare const actionTurnBrand: unique symbol;
992
- /**
993
- * The marker `onAction` returns to have a turn run on the history it just
994
- * edited. Produce it with {@link chat.turn}.
995
- */
996
- export type ActionTurn = {
997
- readonly [actionTurnBrand]: true;
998
- };
999
- /**
1000
- * Turn the current action into a turn.
1001
- *
1002
- * Return it from `onAction` after editing history. The action's own work is
1003
- * finished first (the edit is applied and snapshotted), then a turn runs on the
1004
- * result exactly as a message turn does: `onTurnStart`, `run()` with the edited
1005
- * history, `onBeforeTurnComplete`, `onTurnComplete`, and the turn counter
1006
- * advances. That gives the answer everything a turn has, the system prompt,
1007
- * tools, steering, compaction, injected instructions and persistence, with no
1008
- * action-specific handling.
1009
- *
1010
- * @example
1011
- * ```ts
1012
- * onAction: async ({ action }) => {
1013
- * if (action.type === "regenerate") {
1014
- * chat.history.slice(0, -1);
1015
- * return chat.turn();
1016
- * }
1017
- * if (action.type === "undo") chat.history.slice(0, -2); // no turn
1018
- * },
1019
- * ```
1020
- */
1021
- declare function chatTurn(): ActionTurn;
1022
956
  /**
1023
957
  * Pipes a chat stream to the realtime stream, making it available to the
1024
958
  * `TriggerChatTransport` on the frontend.
@@ -1163,9 +1097,8 @@ export type RecoveryPendingToolCall = {
1163
1097
  * `chat.endRun()` with no buffered user messages, fresh chat, OOM retry
1164
1098
  * after a successful turn-complete with no in-flight tail).
1165
1099
  *
1166
- * Fires regardless of who owns the model's context. With `hydrateMessages`
1167
- * or a storage `loadContext`, the recovered tail reaches that hook in
1168
- * `previousMessages` on the next turn.
1100
+ * Does NOT fire when `hydrateMessages` is registered (the customer owns
1101
+ * persistence; recovery decisions live in their own DB query).
1169
1102
  */
1170
1103
  export type RecoveryBootEvent<TUIM extends UIMessage = UIMessage> = {
1171
1104
  /** Task run context — same as `task({ run })` second-argument `ctx`. */
@@ -1234,9 +1167,8 @@ export type RecoveryBootResult<TUIM extends UIMessage = UIMessage> = {
1234
1167
  * context, mutate its tool parts to inject synthesized results,
1235
1168
  * collapse history, etc.
1236
1169
  *
1237
- * With `hydrateMessages` or a storage `loadContext`, this chain is what
1238
- * the hook receives as `previousMessages` on the next turn; the hook's
1239
- * return value is the chain the model sees.
1170
+ * Ignored when `hydrateMessages` is registered (the hydrate hook
1171
+ * runs per-turn and overwrites the chain).
1240
1172
  */
1241
1173
  chain?: TUIM[];
1242
1174
  /**
@@ -1613,17 +1545,6 @@ export type ChatAgentOptions<TIdentifier extends string, TClientDataSchema exten
1613
1545
  * ```
1614
1546
  */
1615
1547
  oomMachine?: MachinePresetName;
1616
- /**
1617
- * What to do when the session's `externalDeploymentId` no longer names the deployment
1618
- * this run is on — after a redeploy re-pins the session, say.
1619
- *
1620
- * - `"follow"` (default) hands the conversation to the pinned deployment at the next
1621
- * turn boundary, so no `chat.requestUpgrade()` of your own is needed.
1622
- * - `"hold"` stays put until you ask to move. Manual `chat.requestUpgrade()` works either way.
1623
- *
1624
- * Ignored for sessions with no pin, and for sessions using `lockToVersion`.
1625
- */
1626
- versionSkew?: ChatVersionSkewPolicy;
1627
1548
  /**
1628
1549
  * Schema for validating `clientData` from the frontend.
1629
1550
  * Accepts Zod, ArkType, Valibot, or any supported schema library.
@@ -1678,14 +1599,13 @@ export type ChatAgentOptions<TIdentifier extends string, TClientDataSchema exten
1678
1599
  * `onBeforeTurnComplete` / `onTurnComplete`, no `run()`. Use
1679
1600
  * `chat.history.*` inside `onAction` to mutate state.
1680
1601
  *
1681
- * To answer after the edit, return `chat.turn()`: the edit is applied and
1682
- * snapshotted, then a turn runs on the result with every turn guarantee. An
1683
- * action that returns nothing is a state edit only. Returning anything else
1684
- * is an error; a response can no longer be returned directly.
1602
+ * To produce a model response from an action, return a
1603
+ * `StreamTextResult` (auto-piped), `string`, or `UIMessage`. Returning
1604
+ * `void` or nothing is the side-effect-only default.
1685
1605
  */
1686
1606
  onAction?: (event: ActionEvent<[
1687
1607
  TActionSchema
1688
- ] extends [TaskSchema] ? inferSchemaOut<TActionSchema> : unknown, inferSchemaOut<TClientDataSchema>, TUIMessage>) => Promise<void | ActionTurn> | void | ActionTurn;
1608
+ ] extends [TaskSchema] ? inferSchemaOut<TActionSchema> : unknown, inferSchemaOut<TClientDataSchema>, TUIMessage>) => Promise<unknown> | unknown;
1689
1609
  /**
1690
1610
  * The tools available to this agent.
1691
1611
  *
@@ -1771,9 +1691,9 @@ export type ChatAgentOptions<TIdentifier extends string, TClientDataSchema exten
1771
1691
  * continuation after `chat.endRun()` with no buffered user, a fresh
1772
1692
  * chat, or an OOM retry on top of a complete snapshot.
1773
1693
  *
1774
- * Fires regardless of who owns the model's context; a `hydrateMessages`
1775
- * hook or a storage `loadContext` receives the recovered tail in
1776
- * `previousMessages` on the next turn.
1694
+ * Does NOT fire when `hydrateMessages` is registered — that hook owns
1695
+ * the per-turn chain and overlapping recovery decisions belong in the
1696
+ * customer's DB.
1777
1697
  *
1778
1698
  * Defaults (returned when the hook is omitted or returns no field):
1779
1699
  * - With two or more in-flight users, the partial and the user it
@@ -1903,32 +1823,6 @@ export type ChatAgentOptions<TIdentifier extends string, TClientDataSchema exten
1903
1823
  * ```
1904
1824
  */
1905
1825
  hydrateMessages?: (event: HydrateMessagesEvent<inferSchemaOut<TClientDataSchema>, TUIMessage>) => TUIMessage[] | Promise<TUIMessage[]>;
1906
- /**
1907
- * Where the conversation is persisted. The runtime calls `save` after
1908
- * every turn, failed turn and history-changing action with the changes
1909
- * since the last save, and `load` once when a new run boots to continue
1910
- * the conversation.
1911
- *
1912
- * Defaults to `defaultStorage`, the platform's snapshot in object storage
1913
- * that the Sessions dashboard renders. Bring your own to write each change
1914
- * to your database; `memoryTranscriptStorage()` is the reference
1915
- * implementation and `runTranscriptStorageTests` from
1916
- * `@trigger.dev/sdk/ai/test` checks yours against the contract.
1917
- *
1918
- * A storage with `loadContext` also owns the model's context on every
1919
- * turn, which is what `hydrateMessages` did. The two cannot be combined.
1920
- *
1921
- * @example
1922
- * ```ts
1923
- * chat.agent({
1924
- * id: "my-chat",
1925
- * storage: myPostgresTranscriptStorage,
1926
- * run: async ({ messages, signal, streamText }) =>
1927
- * streamText({ model, messages, abortSignal: signal }),
1928
- * });
1929
- * ```
1930
- */
1931
- storage?: TranscriptStorage<inferSchemaOut<TClientDataSchema>>;
1932
1826
  /**
1933
1827
  * Called at the start of every turn, after message accumulation and `onChatStart` (turn 0),
1934
1828
  * but before the `run` function executes.
@@ -2003,31 +1897,6 @@ export type ChatAgentOptions<TIdentifier extends string, TClientDataSchema exten
2003
1897
  * });
2004
1898
  * ```
2005
1899
  */
2006
- /**
2007
- * A provider registry, so the runtime can resolve the managed prompt's model
2008
- * for the `streamText` it hands to `run()`. Only needed when you set a model
2009
- * through `chat.prompt.set()` and want the bound `streamText` to honour it.
2010
- */
2011
- registry?: ToStreamTextOptionsOptions["registry"];
2012
- /**
2013
- * The agent's system prompt. Injected instructions append to it, and the
2014
- * `streamText` handed to `run()` carries it without a spread.
2015
- *
2016
- * Set it here, at the call site, or through `chat.prompt.set()` for versioned
2017
- * config, but only in one of them.
2018
- */
2019
- system?: ToStreamTextOptionsOptions["system"];
2020
- /**
2021
- * Mark the system prompt for provider-side caching, the same sugar
2022
- * `chat.toStreamTextOptions({ cacheControl })` takes. See
2023
- * [prompt caching](/ai-chat/prompt-caching).
2024
- */
2025
- cacheControl?: ToStreamTextOptionsOptions["cacheControl"];
2026
- /**
2027
- * Provider options for the system block, when `cacheControl` is not enough.
2028
- * Takes precedence over `cacheControl`.
2029
- */
2030
- systemProviderOptions?: ToStreamTextOptionsOptions["systemProviderOptions"];
2031
1900
  compaction?: ChatAgentCompactionOptions<TUIMessage>;
2032
1901
  /**
2033
1902
  * Configure how messages that arrive during streaming are handled.
@@ -2521,22 +2390,15 @@ declare function setUIMessageStreamOptions(options: ChatUIMessageStreamOptions<U
2521
2390
  */
2522
2391
  declare function isStopped(): boolean;
2523
2392
  /**
2524
- * Hand the conversation over to another deployment.
2525
- *
2526
- * The handover happens immediately and server-side: a successor run is created
2527
- * and picks the conversation up from `session.in`. The transport keeps reading
2528
- * the same session output, so no client action is needed and nothing waits for
2529
- * the next message.
2530
- *
2531
- * Without a target the session's pin is cleared, so the successor lands on the
2532
- * latest deployed version; with `externalDeploymentId` the session is re-pinned
2533
- * to that deployment.
2393
+ * Request that the current run exits so the next message starts on the latest
2394
+ * deployed version (via the standard continuation mechanism).
2534
2395
  *
2535
2396
  * When called from `onTurnStart` or `onValidateMessages`, `run()` is skipped
2536
- * entirely and the successor answers the message that opened the turn.
2397
+ * entirely — the run exits immediately and the transport re-triggers the
2398
+ * same message on the new version.
2537
2399
  *
2538
2400
  * When called from `run()` or `chat.defer()`, the current turn completes
2539
- * normally and the handover happens afterward.
2401
+ * normally and the run exits afterward instead of waiting for the next message.
2540
2402
  *
2541
2403
  * Call from `onTurnStart`, `onValidateMessages`, `onChatResume`, `run()`,
2542
2404
  * or inside `chat.defer()`.
@@ -2556,9 +2418,7 @@ declare function isStopped(): boolean;
2556
2418
  * });
2557
2419
  * ```
2558
2420
  */
2559
- declare function requestUpgrade(options?: {
2560
- externalDeploymentId?: string;
2561
- }): void;
2421
+ declare function requestUpgrade(): void;
2562
2422
  /**
2563
2423
  * Hand off the current custom agent Session to a fresh run.
2564
2424
  *
@@ -2617,50 +2477,6 @@ declare function endAndContinue(): Promise<void>;
2617
2477
  * ```
2618
2478
  */
2619
2479
  declare function endRun(): void;
2620
- /**
2621
- * End the whole conversation, permanently. The session row is closed, further
2622
- * appends are refused, and the run exits without scheduling a continuation.
2623
- *
2624
- * This is the session-level stop. {@link endRun} ends the current run and lets
2625
- * the next message start a fresh one; `chat.close()` ends the session itself,
2626
- * so there is no next message. Use it for a budget cap, a completed goal,
2627
- * abuse detection, or a user signing out.
2628
- *
2629
- * In a `chat.agent`, call it from `run()`, `prepareStep`, or
2630
- * `onBeforeTurnComplete`. Called mid-step, it aborts the in-flight
2631
- * `streamText` the same way the stop signal does, so the partial response is
2632
- * still captured and streamed. The turn then completes normally, a terminal
2633
- * `session-closed` record carrying `reason` is written to the response stream,
2634
- * and the loop exits.
2635
- *
2636
- * Prefer `onBeforeTurnComplete` over `onTurnComplete`. It carries the same
2637
- * fields but still runs while the stream is open, so the closed state rides
2638
- * out on the turn's final record. `onTurnComplete` runs after that record, so
2639
- * a close decided there does not reach a reader that has already finished the
2640
- * turn, and the user only finds out when their next message is refused.
2641
- *
2642
- * In a `chat.customAgent`, call it anywhere in your own loop. The close is
2643
- * performed when `run()` returns, so it lands whether you break out of a
2644
- * `chat.createSession` loop, return early, or hand-roll the loop entirely.
2645
- *
2646
- * Closing is one-way: a closed session cannot be reopened. Its transcript
2647
- * stays readable.
2648
- *
2649
- * @example
2650
- * ```ts
2651
- * chat.agent({
2652
- * id: "budgeted-agent",
2653
- * onBeforeTurnComplete: async ({ usage }) => {
2654
- * if (await overBudget(usage)) {
2655
- * chat.close({ reason: "Monthly budget reached" });
2656
- * }
2657
- * },
2658
- * });
2659
- * ```
2660
- */
2661
- declare function close(options?: {
2662
- reason?: string;
2663
- }): void;
2664
2480
  /**
2665
2481
  * Register a promise that runs in the background during the current turn.
2666
2482
  *
@@ -2930,20 +2746,6 @@ declare class ChatMessageAccumulator {
2930
2746
  * Queue a message for injection, converting to model messages automatically.
2931
2747
  */
2932
2748
  steerAsync(message: UIMessage): Promise<void>;
2933
- /**
2934
- * Record the messages a steering drain consumed.
2935
- *
2936
- * The drain only puts them in this step's prompt, so without this they
2937
- * shape one answer and then exist in neither lane: not in `uiMessages`,
2938
- * which is what an app persists from, and not in `modelMessages`, which is
2939
- * what every later turn sends.
2940
- *
2941
- * Both lanes are appended to. The model lane is never reconverted from the
2942
- * UI lane, because `compactIfNeeded` replaces it with a summary and leaves
2943
- * the UI lane whole: a reconversion would restore everything the summary
2944
- * replaced.
2945
- */
2946
- absorbSteering(claimed: UIMessage[], injected?: ModelMessage[]): Promise<void>;
2947
2749
  /**
2948
2750
  * Get and clear unconsumed steering messages.
2949
2751
  */
@@ -2981,11 +2783,6 @@ export type ChatSessionOptions = {
2981
2783
  timeout?: string;
2982
2784
  /** Max turns before ending. @default 100 */
2983
2785
  maxTurns?: number;
2984
- /**
2985
- * What to do when the session's `externalDeploymentId` no longer names this deployment.
2986
- * `"follow"` (default) hands over at the next turn boundary; `"hold"` stays put.
2987
- */
2988
- versionSkew?: ChatVersionSkewPolicy;
2989
2786
  /** Automatic context compaction — same options as `chat.agent({ compaction })`. */
2990
2787
  compaction?: ChatAgentCompactionOptions;
2991
2788
  /** Configure mid-execution message injection — same options as `chat.agent({ pendingMessages })`. */
@@ -3197,7 +2994,7 @@ export type CreateChatStartSessionActionOptions = {
3197
2994
  * Default trigger config used when starting a new session for a chat.
3198
2995
  * Per-call `params.triggerConfig` shallow-merges on top.
3199
2996
  */
3200
- triggerConfig?: Partial<SessionTriggerConfigInput>;
2997
+ triggerConfig?: Partial<SessionTriggerConfig>;
3201
2998
  /**
3202
2999
  * Override the Trigger.dev API base URL. String applies to both
3203
3000
  * `/api/v1/sessions` and `/api/v1/auth/jwt/claims`; function picks per
@@ -3240,7 +3037,7 @@ export type ChatStartSessionParams<TChat extends AnyTask = AnyTask> = {
3240
3037
  * `chat.agent`: anything beyond `chatId`/`messages`/`trigger`/`metadata`,
3241
3038
  * which the runtime injects automatically).
3242
3039
  */
3243
- triggerConfig?: Partial<SessionTriggerConfigInput>;
3040
+ triggerConfig?: Partial<SessionTriggerConfig>;
3244
3041
  /**
3245
3042
  * Opaque session-level metadata stored on the Session row. Separate from
3246
3043
  * the per-turn `clientData` above. Use this when you want to attach
@@ -3262,11 +3059,6 @@ export type ChatStartSessionResult = {
3262
3059
  runId: string;
3263
3060
  /** Session friendlyId — informational. */
3264
3061
  sessionId: string;
3265
- /**
3266
- * The session's run is parked waiting for its deployment. Messages sent meanwhile are durable
3267
- * and delivered once it lands; surface this so the wait reads as a deploy in progress.
3268
- */
3269
- pendingVersion?: boolean;
3270
3062
  };
3271
3063
  /**
3272
3064
  * Creates a server-side helper that starts (or resumes) a Session for a
@@ -3303,42 +3095,6 @@ export type ChatStartSessionResult = {
3303
3095
  * ```
3304
3096
  */
3305
3097
  declare function createChatStartSessionAction<TChat extends AnyTask = AnyTask>(taskId: string, options?: CreateChatStartSessionActionOptions): (params: ChatStartSessionParams<TChat>) => Promise<ChatStartSessionResult>;
3306
- export type CreateChatLoadTranscriptActionOptions = {
3307
- /**
3308
- * Scope the action to a specific API client configuration (secret key,
3309
- * base URL) instead of the process-wide one. The default storage reads
3310
- * through this client.
3311
- */
3312
- apiClient?: ApiClientConfiguration;
3313
- /** Page size when the caller passes none. */
3314
- limit?: number;
3315
- };
3316
- export type ChatLoadTranscriptParams<TClientData = unknown> = {
3317
- chatId: string;
3318
- clientData?: TClientData;
3319
- limit?: number;
3320
- before?: string;
3321
- };
3322
- /**
3323
- * Creates a server-side helper that reads a conversation from a transcript
3324
- * storage, for rendering history before the chat connects. Works the same
3325
- * for every storage, the platform default included, so the browser never
3326
- * reads a store directly and the secret key stays on the server.
3327
- *
3328
- * Wrap it in a Next.js server action (or any server-side handler), scope it
3329
- * to the authenticated user through `clientData`, and pass the result to
3330
- * `useLoadTranscript` in the browser.
3331
- *
3332
- * @example
3333
- * ```ts
3334
- * // actions.ts
3335
- * "use server";
3336
- * import { chat, defaultStorage } from "@trigger.dev/sdk/ai";
3337
- *
3338
- * export const loadTranscript = chat.createLoadTranscriptAction(defaultStorage, { limit: 50 });
3339
- * ```
3340
- */
3341
- declare function createChatLoadTranscriptAction<TClientData = unknown>(storage: TranscriptStorage<TClientData>, options?: CreateChatLoadTranscriptActionOptions): (params: ChatLoadTranscriptParams<TClientData>) => Promise<TranscriptLoadResult>;
3342
3098
  export declare const chat: {
3343
3099
  /** Create a chat agent. See {@link chatAgent}. */
3344
3100
  agent: typeof chatAgent;
@@ -3350,12 +3106,8 @@ export declare const chat: {
3350
3106
  withClientData: typeof withClientData;
3351
3107
  /** Create a server-side helper for starting (or resuming) a Session for a chatId. See {@link createChatStartSessionAction}. */
3352
3108
  createStartSessionAction: typeof createChatStartSessionAction;
3353
- /** Returns a server-side helper that reads a conversation from a transcript storage. */
3354
- createLoadTranscriptAction: typeof createChatLoadTranscriptAction;
3355
3109
  /** Pipe a stream to the chat transport. See {@link pipeChat}. */
3356
3110
  pipe: typeof pipeChat;
3357
- /** Return from `onAction` to run a turn on the edited history. See {@link chatTurn}. */
3358
- turn: typeof chatTurn;
3359
3111
  /** Create a per-run typed local. See {@link chatLocal}. */
3360
3112
  local: typeof chatLocal;
3361
3113
  /** Create a public access token for a chat task. See {@link createChatAccessToken}. */
@@ -3376,8 +3128,6 @@ export declare const chat: {
3376
3128
  endAndContinue: typeof endAndContinue;
3377
3129
  /** Exit the run after the current turn completes, without any upgrade signal. See {@link endRun}. */
3378
3130
  endRun: typeof endRun;
3379
- /** End the conversation permanently: close the session and exit the run. See {@link close}. */
3380
- close: typeof close;
3381
3131
  /** Clean up aborted parts from a UIMessage. See {@link cleanupAbortedParts}. */
3382
3132
  cleanupAbortedParts: typeof cleanupAbortedParts;
3383
3133
  /** Register background work that runs in parallel with streaming. See {@link chatDefer}. */