@trigger.dev/sdk 4.5.11 → 4.5.13

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 (102) hide show
  1. package/dist/commonjs/v3/ai.d.ts +154 -20
  2. package/dist/commonjs/v3/ai.js +1247 -406
  3. package/dist/commonjs/v3/ai.js.map +1 -1
  4. package/dist/commonjs/v3/auth.d.ts +3 -3
  5. package/dist/commonjs/v3/chat-client.d.ts +5 -4
  6. package/dist/commonjs/v3/chat-client.js +2 -6
  7. package/dist/commonjs/v3/chat-client.js.map +1 -1
  8. package/dist/commonjs/v3/chat.d.ts +7 -2
  9. package/dist/commonjs/v3/chat.js +22 -7
  10. package/dist/commonjs/v3/chat.js.map +1 -1
  11. package/dist/commonjs/v3/chat.test.js +13 -4
  12. package/dist/commonjs/v3/chat.test.js.map +1 -1
  13. package/dist/commonjs/v3/envvars.js.map +1 -1
  14. package/dist/commonjs/v3/retry.d.ts +1 -1
  15. package/dist/commonjs/v3/retry.js +1 -2
  16. package/dist/commonjs/v3/retry.js.map +1 -1
  17. package/dist/commonjs/v3/runs.d.ts +2 -6
  18. package/dist/commonjs/v3/runs.js.map +1 -1
  19. package/dist/commonjs/v3/schedules/api.d.ts +8 -1
  20. package/dist/commonjs/v3/schedules/index.d.ts +11 -6
  21. package/dist/commonjs/v3/schedules/index.js +2 -0
  22. package/dist/commonjs/v3/schedules/index.js.map +1 -1
  23. package/dist/commonjs/v3/schedules/index.test.d.ts +1 -0
  24. package/dist/commonjs/v3/schedules/index.test.js +49 -0
  25. package/dist/commonjs/v3/schedules/index.test.js.map +1 -0
  26. package/dist/commonjs/v3/schedules/index.types.test.d.ts +1 -0
  27. package/dist/commonjs/v3/schedules/index.types.test.js +93 -0
  28. package/dist/commonjs/v3/schedules/index.types.test.js.map +1 -0
  29. package/dist/commonjs/v3/sessions.d.ts +4 -10
  30. package/dist/commonjs/v3/sessions.js +73 -47
  31. package/dist/commonjs/v3/sessions.js.map +1 -1
  32. package/dist/commonjs/v3/shared.d.ts +2 -3
  33. package/dist/commonjs/v3/shared.js +14 -0
  34. package/dist/commonjs/v3/shared.js.map +1 -1
  35. package/dist/commonjs/v3/test/mock-chat-agent.d.ts +1 -1
  36. package/dist/commonjs/v3/test/mock-chat-agent.js +1 -0
  37. package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
  38. package/dist/commonjs/v3/test/test-session-handle.d.ts +1 -31
  39. package/dist/commonjs/v3/test/test-session-handle.js +22 -25
  40. package/dist/commonjs/v3/test/test-session-handle.js.map +1 -1
  41. package/dist/commonjs/version.js +1 -1
  42. package/dist/esm/v3/ai.d.ts +154 -20
  43. package/dist/esm/v3/ai.js +1245 -406
  44. package/dist/esm/v3/ai.js.map +1 -1
  45. package/dist/esm/v3/auth.d.ts +3 -3
  46. package/dist/esm/v3/chat-client.d.ts +5 -4
  47. package/dist/esm/v3/chat-client.js +2 -6
  48. package/dist/esm/v3/chat-client.js.map +1 -1
  49. package/dist/esm/v3/chat.d.ts +7 -2
  50. package/dist/esm/v3/chat.js +22 -7
  51. package/dist/esm/v3/chat.js.map +1 -1
  52. package/dist/esm/v3/chat.test.js +13 -4
  53. package/dist/esm/v3/chat.test.js.map +1 -1
  54. package/dist/esm/v3/envvars.js.map +1 -1
  55. package/dist/esm/v3/retry.d.ts +1 -1
  56. package/dist/esm/v3/retry.js +1 -2
  57. package/dist/esm/v3/retry.js.map +1 -1
  58. package/dist/esm/v3/runs.d.ts +2 -6
  59. package/dist/esm/v3/runs.js.map +1 -1
  60. package/dist/esm/v3/schedules/api.d.ts +8 -1
  61. package/dist/esm/v3/schedules/index.d.ts +11 -6
  62. package/dist/esm/v3/schedules/index.js +2 -0
  63. package/dist/esm/v3/schedules/index.js.map +1 -1
  64. package/dist/esm/v3/schedules/index.test.d.ts +1 -0
  65. package/dist/esm/v3/schedules/index.test.js +47 -0
  66. package/dist/esm/v3/schedules/index.test.js.map +1 -0
  67. package/dist/esm/v3/schedules/index.types.test.d.ts +1 -0
  68. package/dist/esm/v3/schedules/index.types.test.js +91 -0
  69. package/dist/esm/v3/schedules/index.types.test.js.map +1 -0
  70. package/dist/esm/v3/sessions.d.ts +4 -10
  71. package/dist/esm/v3/sessions.js +73 -47
  72. package/dist/esm/v3/sessions.js.map +1 -1
  73. package/dist/esm/v3/shared.d.ts +2 -3
  74. package/dist/esm/v3/shared.js +15 -1
  75. package/dist/esm/v3/shared.js.map +1 -1
  76. package/dist/esm/v3/test/mock-chat-agent.d.ts +1 -1
  77. package/dist/esm/v3/test/mock-chat-agent.js +2 -1
  78. package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
  79. package/dist/esm/v3/test/test-session-handle.d.ts +1 -31
  80. package/dist/esm/v3/test/test-session-handle.js +24 -25
  81. package/dist/esm/v3/test/test-session-handle.js.map +1 -1
  82. package/dist/esm/version.js +1 -1
  83. package/docs/ai-chat/client-protocol.mdx +8 -3
  84. package/docs/ai-chat/custom-agents.mdx +181 -46
  85. package/docs/ai-chat/patterns/recovery-boot.mdx +9 -2
  86. package/docs/ai-chat/patterns/version-upgrades.mdx +26 -6
  87. package/docs/ai-chat/pending-messages.mdx +5 -3
  88. package/docs/ai-chat/reference.mdx +26 -10
  89. package/docs/ai-chat/types.mdx +5 -1
  90. package/docs/apikeys.mdx +159 -27
  91. package/docs/deployment/atomic-deployment.mdx +12 -0
  92. package/docs/deployment/overview.mdx +7 -1
  93. package/docs/deployment/version-skew-protection.mdx +430 -0
  94. package/docs/github-actions.mdx +33 -5
  95. package/docs/github-integration.mdx +12 -0
  96. package/docs/realtime/auth.mdx +3 -1
  97. package/docs/self-hosting/env/supervisor.mdx +1 -0
  98. package/docs/self-hosting/env/webapp.mdx +1 -0
  99. package/docs/tasks/scheduled.mdx +45 -0
  100. package/docs/vercel-integration.mdx +43 -9
  101. package/docs/versioning.mdx +2 -0
  102. package/package.json +3 -15
@@ -171,6 +171,10 @@ export type ChatWriter = {
171
171
  /** Merge another stream's chunks into the chat stream. */
172
172
  merge(stream: ReadableStream<UIMessageChunk>): void;
173
173
  };
174
+ type ChatCustomAgentClientDataErrorHandler = (event: {
175
+ error: unknown;
176
+ payload: ChatTaskWirePayload;
177
+ }) => Promise<void> | void;
174
178
  /**
175
179
  * The payload shape passed to the `chatAgent` run function.
176
180
  *
@@ -257,6 +261,26 @@ export type ChatTaskRunPayload<TClientData = unknown, TTools extends ToolSet = T
257
261
  */
258
262
  tools: TTools;
259
263
  };
264
+ /**
265
+ * One message record delivered through {@link chat.messages}.
266
+ *
267
+ * `id` is the append's stable idempotency key and `seqNum` is its monotonic
268
+ * sequence on the Session `.in` channel. Both remain stable if the record is
269
+ * delivered again after a reconnect.
270
+ */
271
+ export type ChatMessageRecord = Readonly<{
272
+ id: string;
273
+ seqNum: number;
274
+ payload: ChatTaskWirePayload;
275
+ }>;
276
+ export type ChatMessages = RealtimeDefinedInputStream<ChatTaskWirePayload> & {
277
+ /** Whether the local buffer head is a message that can be consumed immediately. */
278
+ hasPending(): Promise<boolean>;
279
+ /** Consume one message record, or return `undefined` when the optional timeout elapses. */
280
+ next(options?: {
281
+ timeoutInSeconds?: number;
282
+ }): Promise<ChatMessageRecord | undefined>;
283
+ };
260
284
  /**
261
285
  * Signal received by a `handover-prepare` agent run waiting on
262
286
  * `session.in`. Either the customer's first-turn `streamText` finished
@@ -294,9 +318,8 @@ export type HandoverSignal = {
294
318
  * For the common case prefer `accumulator.consumeHandover()`, which also seeds
295
319
  * `payload.headStartMessages` and applies the partial for you.
296
320
  *
297
- * Must be called at turn 0 before any `chat.messages.waitWithIdleTimeout`
298
- * that facade consumes and discards non-message chunks, which would swallow the
299
- * handover signal.
321
+ * Safe to call at any point in turn 0: the handover signal has its own route,
322
+ * so a message facade waiting at the same time cannot take it.
300
323
  */
301
324
  declare function waitForHandover(options: {
302
325
  /** The run's wire payload (only `trigger` / `idleTimeoutInSeconds` are read). */
@@ -1101,8 +1124,11 @@ export type RecoveryBootEvent<TUIM extends UIMessage = UIMessage> = {
1101
1124
  /**
1102
1125
  * User messages that arrived on `session.in` past the cursor — i.e.
1103
1126
  * the message(s) the predecessor was processing or had queued when
1104
- * it died. The runtime's default is to re-dispatch each as a fresh
1105
- * turn after the chain is restored. Return a different list via
1127
+ * it died. The runtime's default re-dispatches each as a fresh turn
1128
+ * after the chain is restored, except when a `partialAssistant` is
1129
+ * present AND there are two or more of them: the first is then
1130
+ * spliced into the chain (as the question the partial was answering)
1131
+ * rather than dispatched. Return a different list via
1106
1132
  * `recoveredTurns` to skip / reorder / collapse them.
1107
1133
  */
1108
1134
  inFlightUsers: TUIM[];
@@ -1146,8 +1172,12 @@ export type RecoveryBootResult<TUIM extends UIMessage = UIMessage> = {
1146
1172
  chain?: TUIM[];
1147
1173
  /**
1148
1174
  * The user messages to re-dispatch as fresh turns after the chain is
1149
- * restored. Default: `inFlightUsers` (re-process every in-flight
1150
- * user). Return `[]` to suppress all of them; return a filtered /
1175
+ * restored. Default: `inFlightUsers.slice(1)` when a
1176
+ * `partialAssistant` is present and there are two or more in-flight
1177
+ * users (the first one is spliced into the chain instead), otherwise
1178
+ * `inFlightUsers` — including the single-user case, where the
1179
+ * interrupted user is re-dispatched and the orphan partial is
1180
+ * dropped. Return `[]` to suppress all of them; return a filtered /
1151
1181
  * reordered subset to skip specific ones.
1152
1182
  */
1153
1183
  recoveredTurns?: TUIM[];
@@ -1665,8 +1695,13 @@ export type ChatAgentOptions<TIdentifier extends string, TClientDataSchema exten
1665
1695
  * customer's DB.
1666
1696
  *
1667
1697
  * Defaults (returned when the hook is omitted or returns no field):
1668
- * - `chain` = `settledMessages` (drop the orphan partial)
1669
- * - `recoveredTurns` = `inFlightUsers` (re-dispatch every user)
1698
+ * - With two or more in-flight users, the partial and the user it
1699
+ * was answering are spliced into the chain:
1700
+ * `chain` = `[...settledMessages, inFlightUsers[0], partialAssistant]`
1701
+ * and `recoveredTurns` = `inFlightUsers.slice(1)`.
1702
+ * - Otherwise `chain` = `settledMessages` (drop the orphan partial)
1703
+ * and `recoveredTurns` = `inFlightUsers` (re-dispatch every user)
1704
+ * — so a single interrupted user is answered on the new run.
1670
1705
  *
1671
1706
  * @example
1672
1707
  * ```ts
@@ -2077,8 +2112,48 @@ export type ChatAgentOptions<TIdentifier extends string, TClientDataSchema exten
2077
2112
  * });
2078
2113
  * ```
2079
2114
  */
2080
- type ChatCustomAgentOptions<TIdentifier extends string, TClientDataSchema extends TaskSchema | undefined = undefined, TUIMessage extends UIMessage = UIMessage> = Omit<TaskOptions<TIdentifier, ChatTaskWirePayload<TUIMessage, inferSchemaIn<TClientDataSchema>>, unknown>, "triggerSource" | "agentConfig"> & {
2115
+ type ChatCustomAgentOptions<TIdentifier extends string, TClientDataSchema extends TaskSchema | undefined = undefined, TUIMessage extends UIMessage = UIMessage> = Omit<TaskOptions<TIdentifier, ChatTaskWirePayload<TUIMessage, inferSchemaIn<TClientDataSchema>>, unknown>, "triggerSource" | "agentConfig" | "run"> & {
2116
+ /**
2117
+ * Schema for validating `metadata` from the frontend.
2118
+ *
2119
+ * The initial payload and later `chat.messages` frames are parsed before
2120
+ * user code receives them. Invalid submitted turns and async reads write an
2121
+ * error chunk followed by `turn-complete`. Messageless boots and active
2122
+ * subscriptions use `onClientDataValidationError` and the task log because
2123
+ * there is no submitted turn to complete or a response may still be streaming.
2124
+ * This validates `metadata` only; raw `action` payloads remain `unknown`.
2125
+ */
2081
2126
  clientDataSchema?: TClientDataSchema;
2127
+ /**
2128
+ * Called when a custom-agent input fails `clientDataSchema` validation.
2129
+ *
2130
+ * Submitted turns and async reads also write an error chunk followed by
2131
+ * `turn-complete`. Messageless boots and active `chat.messages.on()`
2132
+ * subscriptions are reported through this callback and the task log only.
2133
+ *
2134
+ * `payload.metadata` is typed `unknown`: this callback only fires when
2135
+ * the metadata failed to parse, so it can be any shape the client sent.
2136
+ */
2137
+ onClientDataValidationError?: (event: {
2138
+ error: unknown;
2139
+ payload: ChatTaskWirePayload<TUIMessage, unknown>;
2140
+ }) => Promise<void> | void;
2141
+ /**
2142
+ * When a frame that arrived mid-turn fails `clientDataSchema` validation,
2143
+ * decides when the terminal error reaches the client.
2144
+ *
2145
+ * - `"turn-end"` (default) waits until the turn has closed. A terminal error
2146
+ * written into a live response can close it, so this keeps a bad client
2147
+ * send from truncating an answer the user is already reading.
2148
+ * - `"arrival"` writes it as soon as validation fails, which surfaces the
2149
+ * problem sooner at the cost of ending the response in progress.
2150
+ *
2151
+ * `onClientDataValidationError` and the task log fire on arrival either way;
2152
+ * this only governs the stream-visible error. The frame is never delivered as
2153
+ * a turn in either mode.
2154
+ */
2155
+ clientDataReportErrorAt?: "turn-end" | "arrival";
2156
+ run: TaskOptions<TIdentifier, ChatTaskWirePayload<TUIMessage, inferSchemaOut<TClientDataSchema>>, unknown>["run"];
2082
2157
  };
2083
2158
  declare function chatCustomAgent<TIdentifier extends string, TClientDataSchema extends TaskSchema | undefined = undefined, TUIMessage extends UIMessage = UIMessage>(options: ChatCustomAgentOptions<TIdentifier, TClientDataSchema, TUIMessage>): Task<TIdentifier, ChatTaskWirePayload<TUIMessage, inferSchemaIn<TClientDataSchema>>, unknown>;
2084
2159
  declare function chatAgent<TIdentifier extends string, TClientDataSchema extends TaskSchema | undefined = undefined, TUIMessage extends UIMessage = UIMessage, TActionSchema extends TaskSchema | undefined = undefined, TTools extends ToolSet = ToolSet>(options: ChatAgentOptions<TIdentifier, TClientDataSchema, TUIMessage, TActionSchema, TTools>): Task<TIdentifier, ChatTaskWirePayload<TUIMessage, inferSchemaIn<TClientDataSchema>>, unknown>;
@@ -2111,9 +2186,29 @@ export type ChatWithUIMessageConfig<TUIM extends UIMessage = UIMessage> = {
2111
2186
  export interface ChatBuilder<TUIMessage extends UIMessage = UIMessage, TClientDataSchema extends TaskSchema | undefined = undefined> {
2112
2187
  /** Fix the UI message type. Returns a new builder preserving all accumulated state. */
2113
2188
  withUIMessage<TUIM extends UIMessage = UIMessage>(config?: ChatWithUIMessageConfig<TUIM>): ChatBuilder<TUIM, TClientDataSchema>;
2114
- /** Fix the client data schema. Returns a new builder preserving all accumulated state. */
2189
+ /**
2190
+ * Fix the client data schema, and how validation failures are handled.
2191
+ * Returns a new builder preserving all accumulated state.
2192
+ */
2115
2193
  withClientData<TSchema extends TaskSchema>(config: {
2116
2194
  schema: TSchema;
2195
+ /**
2196
+ * When a frame that arrived mid-turn fails validation, decides when the
2197
+ * client-visible error is written.
2198
+ *
2199
+ * `"turn-end"` (default) waits for the turn to close, so a bad send cannot
2200
+ * truncate an answer already being read. `"arrival"` writes it as soon as
2201
+ * validation fails, ending the response in progress.
2202
+ *
2203
+ * `onValidationError` and the task log fire on arrival either way, and the
2204
+ * frame is never delivered as a turn.
2205
+ */
2206
+ reportErrorAt?: "turn-end" | "arrival";
2207
+ /** Called when an input fails validation. Composes with the task-level hook. */
2208
+ onValidationError?: (event: {
2209
+ error: unknown;
2210
+ payload: ChatTaskWirePayload<TUIMessage, unknown>;
2211
+ }) => Promise<void> | void;
2117
2212
  }): ChatBuilder<TUIMessage, TSchema>;
2118
2213
  /** Register a builder-level `onBoot` hook. Runs before the task-level hook if both are set. */
2119
2214
  onBoot(fn: (event: BootEvent<inferSchemaOut<TClientDataSchema>>) => Promise<void> | void): ChatBuilder<TUIMessage, TClientDataSchema>;
@@ -2151,7 +2246,7 @@ export interface ChatBuilder<TUIMessage extends UIMessage = UIMessage, TClientDa
2151
2246
  * Builder hooks (`onPreload`, `onChatStart`, etc.) are not applied —
2152
2247
  * those are managed-lifecycle concepts handled by `.agent()`.
2153
2248
  */
2154
- customAgent: [TClientDataSchema] extends [undefined] ? <TId extends string>(options: ChatCustomAgentOptions<TId, undefined, TUIMessage>) => Task<TId, ChatTaskWirePayload<TUIMessage, undefined>, unknown> : <TId extends string>(options: ChatCustomAgentOptions<TId, TClientDataSchema, TUIMessage>) => Task<TId, ChatTaskWirePayload<TUIMessage, inferSchemaIn<TClientDataSchema>>, unknown>;
2249
+ customAgent: [TClientDataSchema] extends [undefined] ? <TId extends string>(options: ChatCustomAgentOptions<TId, undefined, TUIMessage>) => Task<TId, ChatTaskWirePayload<TUIMessage, undefined>, unknown> : <TId extends string>(options: Omit<ChatCustomAgentOptions<TId, TClientDataSchema, TUIMessage>, "clientDataSchema">) => Task<TId, ChatTaskWirePayload<TUIMessage, inferSchemaIn<TClientDataSchema>>, unknown>;
2155
2250
  }
2156
2251
  /**
2157
2252
  * Fix the UI message type for a chat task (AI SDK `UIMessage` generics) while
@@ -2195,6 +2290,8 @@ declare function withUIMessage<TUIM extends UIMessage = UIMessage>(config?: Chat
2195
2290
  */
2196
2291
  declare function withClientData<TSchema extends TaskSchema>(config: {
2197
2292
  schema: TSchema;
2293
+ reportErrorAt?: "turn-end" | "arrival";
2294
+ onValidationError?: ChatCustomAgentClientDataErrorHandler;
2198
2295
  }): ChatBuilder<UIMessage, TSchema>;
2199
2296
  /**
2200
2297
  * Override the turn timeout for subsequent turns in the current run.
@@ -2321,6 +2418,37 @@ declare function isStopped(): boolean;
2321
2418
  * ```
2322
2419
  */
2323
2420
  declare function requestUpgrade(): void;
2421
+ /**
2422
+ * Hand off the current custom agent Session to a fresh run.
2423
+ *
2424
+ * This is the low-level handoff for a fully hand-rolled
2425
+ * `chat.customAgent()` loop. This method rejects while a
2426
+ * `chat.createSession()` iterator is active. Close the iterator before calling
2427
+ * it. If `return()` races an active `next()`, it waits for that read to settle
2428
+ * before releasing the handoff guard. Call only between turns and after
2429
+ * detaching input listeners for the old run. If the old run completed its
2430
+ * current turn, persist its state and call {@link chatWriteTurnComplete} before
2431
+ * handing off.
2432
+ * Do not write a new turn boundary after input that the continuation run should
2433
+ * process has been dispatched: the boundary acknowledges that input.
2434
+ *
2435
+ * The server starts the continuation run but does not stop this run, so return
2436
+ * from the task immediately after awaiting this function. The promise rejects
2437
+ * if the server cannot complete the handoff.
2438
+ *
2439
+ * Pending Session input that the old run has not consumed remains on the
2440
+ * durable `.in` stream and is delivered to the continuation run.
2441
+ *
2442
+ * @example
2443
+ * ```ts
2444
+ * // Detach any chat.messages.on() subscriptions you created.
2445
+ * await persistMessages();
2446
+ * await chat.writeTurnComplete();
2447
+ * await chat.endAndContinue();
2448
+ * return;
2449
+ * ```
2450
+ */
2451
+ declare function endAndContinue(): Promise<void>;
2324
2452
  /**
2325
2453
  * Exit the run after the current turn completes, without waiting for the
2326
2454
  * next message. Unlike {@link requestUpgrade}, no upgrade-required signal
@@ -2460,10 +2588,14 @@ declare function createStopSignal(): {
2460
2588
  * task instead of round-tripping them back from the client:
2461
2589
  * - `lastEventId` — the turn-complete control record's seq_num on
2462
2590
  * `session.out`; where the next turn's output stream resumes.
2463
- * - `sessionInEventId` — the committed-consume cursor on `session.in` as of
2464
- * this turn-complete, letting a raw loop correlate the boundary with the
2465
- * exact input record it acknowledged. Trigger owns input-cursor recovery,
2466
- * so this is for correlation / out-of-sync detection, not required.
2591
+ * - `sessionInEventId` — the safe-to-resume-from cursor on `session.in` as of
2592
+ * this turn-complete. It is the highest sequence that can be resumed past
2593
+ * without skipping an unhandled message, so it is held back behind any
2594
+ * message still buffered unconsumed and is NOT necessarily the sequence of
2595
+ * the record this turn answered. Trigger owns input-cursor recovery, so this
2596
+ * is for correlation / out-of-sync detection, not required. Treat it as a
2597
+ * lower bound: a value below the record you just handled is expected, not a
2598
+ * sign of a lost turn.
2467
2599
  *
2468
2600
  * Either is `undefined` when the corresponding cursor isn't available.
2469
2601
  *
@@ -2655,7 +2787,7 @@ export type ChatSessionOptions = {
2655
2787
  /** Configure mid-execution message injection — same options as `chat.agent({ pendingMessages })`. */
2656
2788
  pendingMessages?: PendingMessagesOptions;
2657
2789
  };
2658
- export type ChatTurn = {
2790
+ export type ChatTurn<TClientData = unknown> = {
2659
2791
  /** Turn number (0-indexed). */
2660
2792
  number: number;
2661
2793
  /** Chat session ID. */
@@ -2663,7 +2795,7 @@ export type ChatTurn = {
2663
2795
  /** What triggered this turn. */
2664
2796
  trigger: string;
2665
2797
  /** Client data from the transport (`metadata` field on the wire payload). */
2666
- clientData: unknown;
2798
+ clientData: TClientData;
2667
2799
  /** Full accumulated model messages — pass directly to `streamText`. */
2668
2800
  readonly messages: ModelMessage[];
2669
2801
  /** Full accumulated UI messages — use for persistence. */
@@ -2758,7 +2890,7 @@ export type ChatTurn = {
2758
2890
  * });
2759
2891
  * ```
2760
2892
  */
2761
- declare function createChatSession(payload: ChatTaskWirePayload, options: ChatSessionOptions): AsyncIterable<ChatTurn>;
2893
+ declare function createChatSession<TClientData = unknown>(payload: ChatTaskWirePayload<UIMessage, TClientData>, options: ChatSessionOptions): AsyncIterable<ChatTurn<TClientData>>;
2762
2894
  /**
2763
2895
  * A Proxy-backed, run-scoped data object that appears as `T` to users.
2764
2896
  * Includes helper methods for initialization, dirty tracking, and serialization.
@@ -2991,6 +3123,8 @@ export declare const chat: {
2991
3123
  isStopped: typeof isStopped;
2992
3124
  /** Request that the run exits after the current turn so the next message starts on the latest version. See {@link requestUpgrade}. */
2993
3125
  requestUpgrade: typeof requestUpgrade;
3126
+ /** Hand off a custom agent Session to a fresh run. See {@link endAndContinue}. */
3127
+ endAndContinue: typeof endAndContinue;
2994
3128
  /** Exit the run after the current turn completes, without any upgrade signal. See {@link endRun}. */
2995
3129
  endRun: typeof endRun;
2996
3130
  /** Clean up aborted parts from a UIMessage. See {@link cleanupAbortedParts}. */
@@ -3010,7 +3144,7 @@ export declare const chat: {
3010
3144
  write(part: UIMessageChunk): void;
3011
3145
  };
3012
3146
  /** Pre-built input stream for receiving messages from the transport. */
3013
- messages: RealtimeDefinedInputStream<ChatTaskWirePayload>;
3147
+ messages: ChatMessages;
3014
3148
  /** Create a managed stop signal wired to the stop input stream. See {@link createStopSignal}. */
3015
3149
  createStopSignal: typeof createStopSignal;
3016
3150
  /** Signal the frontend that the current turn is complete. See {@link chatWriteTurnComplete}. */