@trigger.dev/sdk 4.5.12 → 4.5.14
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.d.ts +154 -20
- package/dist/commonjs/v3/ai.js +1241 -387
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/chat.d.ts +7 -2
- package/dist/commonjs/v3/chat.js +22 -7
- package/dist/commonjs/v3/chat.js.map +1 -1
- package/dist/commonjs/v3/chat.test.js +13 -4
- package/dist/commonjs/v3/chat.test.js.map +1 -1
- package/dist/commonjs/v3/envvars.js.map +1 -1
- package/dist/commonjs/v3/sessions.d.ts +4 -10
- package/dist/commonjs/v3/sessions.js +73 -47
- package/dist/commonjs/v3/sessions.js.map +1 -1
- package/dist/commonjs/v3/streams.js +1 -0
- package/dist/commonjs/v3/streams.js.map +1 -1
- package/dist/commonjs/v3/test/mock-chat-agent.js +1 -0
- package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/commonjs/v3/test/test-session-handle.js +22 -23
- package/dist/commonjs/v3/test/test-session-handle.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/ai.d.ts +154 -20
- package/dist/esm/v3/ai.js +1239 -387
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/chat.d.ts +7 -2
- package/dist/esm/v3/chat.js +22 -7
- package/dist/esm/v3/chat.js.map +1 -1
- package/dist/esm/v3/chat.test.js +13 -4
- package/dist/esm/v3/chat.test.js.map +1 -1
- package/dist/esm/v3/envvars.js.map +1 -1
- package/dist/esm/v3/sessions.d.ts +4 -10
- package/dist/esm/v3/sessions.js +73 -47
- package/dist/esm/v3/sessions.js.map +1 -1
- package/dist/esm/v3/streams.js +1 -0
- package/dist/esm/v3/streams.js.map +1 -1
- package/dist/esm/v3/test/mock-chat-agent.js +2 -1
- package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/esm/v3/test/test-session-handle.js +23 -24
- package/dist/esm/v3/test/test-session-handle.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai-chat/client-protocol.mdx +8 -3
- package/docs/ai-chat/custom-agents.mdx +181 -46
- package/docs/ai-chat/patterns/recovery-boot.mdx +9 -2
- package/docs/ai-chat/patterns/version-upgrades.mdx +26 -6
- package/docs/ai-chat/pending-messages.mdx +5 -3
- package/docs/ai-chat/reference.mdx +26 -10
- package/docs/ai-chat/types.mdx +5 -1
- package/docs/deployment/atomic-deployment.mdx +12 -0
- package/docs/deployment/overview.mdx +7 -1
- package/docs/deployment/version-skew-protection.mdx +430 -0
- package/docs/github-actions.mdx +33 -5
- package/docs/github-integration.mdx +12 -0
- package/docs/realtime/auth.mdx +18 -0
- package/docs/realtime/react-hooks/session-stream.mdx +109 -0
- package/docs/realtime/react-hooks/streams.mdx +71 -3
- package/docs/self-hosting/env/webapp.mdx +1 -0
- package/docs/self-hosting/security.mdx +1 -1
- package/docs/tasks/streams.mdx +3 -0
- package/docs/vercel-integration.mdx +43 -9
- package/docs/versioning.mdx +2 -0
- package/package.json +2 -2
package/dist/commonjs/v3/ai.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
298
|
-
*
|
|
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
|
|
1105
|
-
*
|
|
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`
|
|
1150
|
-
*
|
|
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
|
-
* -
|
|
1669
|
-
*
|
|
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
|
-
/**
|
|
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
|
|
2464
|
-
* this turn-complete
|
|
2465
|
-
*
|
|
2466
|
-
*
|
|
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:
|
|
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:
|
|
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}. */
|