@trigger.dev/sdk 0.0.0-prerelease-20260908122921 → 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.
- package/dist/commonjs/imports/ai-runtime-cjs.cjs.map +1 -1
- package/dist/commonjs/imports/ai-runtime.js +0 -2
- package/dist/commonjs/v3/ai.d.ts +16 -199
- package/dist/commonjs/v3/ai.js +102 -983
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/chat-client.d.ts +2 -3
- package/dist/commonjs/v3/chat-client.js +5 -31
- package/dist/commonjs/v3/chat-client.js.map +1 -1
- package/dist/commonjs/v3/chat-react.d.ts +0 -34
- package/dist/commonjs/v3/chat-react.js +1 -47
- package/dist/commonjs/v3/chat-react.js.map +1 -1
- package/dist/commonjs/v3/chat-server.d.ts +6 -42
- package/dist/commonjs/v3/chat-server.js +7 -52
- package/dist/commonjs/v3/chat-server.js.map +1 -1
- package/dist/commonjs/v3/chat.d.ts +10 -81
- package/dist/commonjs/v3/chat.js +46 -292
- package/dist/commonjs/v3/chat.js.map +1 -1
- package/dist/commonjs/v3/sessions.d.ts +2 -15
- package/dist/commonjs/v3/sessions.js +1 -12
- package/dist/commonjs/v3/sessions.js.map +1 -1
- package/dist/commonjs/v3/shared.js +36 -30
- package/dist/commonjs/v3/shared.js.map +1 -1
- package/dist/commonjs/v3/test/mock-chat-agent.d.ts +0 -43
- package/dist/commonjs/v3/test/mock-chat-agent.js +0 -90
- package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/commonjs/v3/test/test-session-handle.js +0 -6
- package/dist/commonjs/v3/test/test-session-handle.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/imports/ai-runtime.d.ts +2 -2
- package/dist/esm/imports/ai-runtime.js +2 -2
- package/dist/esm/imports/ai-runtime.js.map +1 -1
- package/dist/esm/v3/ai.d.ts +16 -199
- package/dist/esm/v3/ai.js +103 -984
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/chat-client.d.ts +2 -3
- package/dist/esm/v3/chat-client.js +5 -31
- package/dist/esm/v3/chat-client.js.map +1 -1
- package/dist/esm/v3/chat-react.d.ts +0 -34
- package/dist/esm/v3/chat-react.js +1 -46
- package/dist/esm/v3/chat-react.js.map +1 -1
- package/dist/esm/v3/chat-server.d.ts +6 -42
- package/dist/esm/v3/chat-server.js +8 -53
- package/dist/esm/v3/chat-server.js.map +1 -1
- package/dist/esm/v3/chat.d.ts +10 -81
- package/dist/esm/v3/chat.js +47 -293
- package/dist/esm/v3/chat.js.map +1 -1
- package/dist/esm/v3/sessions.d.ts +2 -15
- package/dist/esm/v3/sessions.js +1 -11
- package/dist/esm/v3/sessions.js.map +1 -1
- package/dist/esm/v3/shared.js +23 -17
- package/dist/esm/v3/shared.js.map +1 -1
- package/dist/esm/v3/test/mock-chat-agent.d.ts +0 -43
- package/dist/esm/v3/test/mock-chat-agent.js +2 -92
- package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/esm/v3/test/test-session-handle.js +0 -6
- package/dist/esm/v3/test/test-session-handle.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai-chat/actions.mdx +23 -55
- package/docs/ai-chat/anatomy.mdx +3 -3
- package/docs/ai-chat/backend.mdx +48 -125
- package/docs/ai-chat/background-injection.mdx +19 -67
- package/docs/ai-chat/client-protocol.mdx +4 -5
- package/docs/ai-chat/compaction.mdx +7 -11
- package/docs/ai-chat/custom-agents.mdx +0 -23
- package/docs/ai-chat/fast-starts.mdx +20 -27
- package/docs/ai-chat/frontend.mdx +14 -17
- package/docs/ai-chat/migrating-from-a-route-handler.mdx +14 -16
- package/docs/ai-chat/patterns/skills.mdx +10 -7
- package/docs/ai-chat/patterns/version-upgrades.mdx +6 -79
- package/docs/ai-chat/pending-messages.mdx +3 -3
- package/docs/ai-chat/prompt-caching.mdx +25 -23
- package/docs/ai-chat/quick-start.mdx +11 -11
- package/docs/ai-chat/reference.mdx +5 -12
- package/docs/ai-chat/sessions.mdx +1 -6
- package/docs/ai-chat/testing.mdx +1 -2
- package/docs/ai-chat/tools.mdx +13 -18
- package/docs/ai-chat/upgrade-guide.mdx +2 -2
- package/docs/apikeys.mdx +45 -27
- package/docs/deployment/overview.mdx +8 -4
- package/docs/deployment/preview-branches.mdx +4 -4
- package/docs/deployment/version-skew-protection.mdx +0 -62
- package/docs/manual-setup.mdx +7 -7
- package/docs/mcp-tools.mdx +0 -9
- package/docs/quick-start.mdx +3 -3
- package/docs/realtime/auth.mdx +1 -1
- package/docs/self-hosting/security.mdx +0 -5
- package/docs/tasks/scheduled.mdx +0 -24
- package/docs/triggering.mdx +1 -1
- package/package.json +4 -4
- package/skills/trigger-authoring-chat-agent/SKILL.md +27 -38
- package/skills/trigger-chat-agent-advanced/SKILL.md +12 -31
- package/dist/commonjs/v3/chatVersionSkew.d.ts +0 -12
- package/dist/commonjs/v3/chatVersionSkew.js +0 -30
- package/dist/commonjs/v3/chatVersionSkew.js.map +0 -1
- package/dist/commonjs/v3/externalDeploymentId.d.ts +0 -23
- package/dist/commonjs/v3/externalDeploymentId.js +0 -43
- package/dist/commonjs/v3/externalDeploymentId.js.map +0 -1
- package/dist/esm/v3/chatVersionSkew.d.ts +0 -12
- package/dist/esm/v3/chatVersionSkew.js +0 -27
- package/dist/esm/v3/chatVersionSkew.js.map +0 -1
- package/dist/esm/v3/externalDeploymentId.d.ts +0 -23
- package/dist/esm/v3/externalDeploymentId.js +0 -38
- package/dist/esm/v3/externalDeploymentId.js.map +0 -1
- package/docs/ai-chat/patterns/native-compaction.mdx +0 -310
- package/docs/reports.mdx +0 -157
- 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,
|
|
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;
|
package/dist/commonjs/v3/ai.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type AnyTask, type Task, type ApiClientConfiguration, type inferSchemaIn, type inferSchemaOut, type MachinePresetName, type RealtimeDefinedInputStream, type RealtimeDefinedStream, type TaskIdentifier, type TaskOptions, type TaskRunContext, type TaskSchema, type TaskWithSchema, type AnySessionChannel, type SessionChannelName } from "@trigger.dev/core/v3";
|
|
2
|
-
import type {
|
|
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";
|
|
3
3
|
import { type ChatInputChunk, type ChatTaskWirePayload, type InferChatClientData, type InferChatUIMessage, type InferChatUIMessageFromTools, PENDING_MESSAGE_INJECTED_TYPE, upsertIncomingMessage } from "./ai-shared.js";
|
|
4
4
|
import { locals } from "./locals.js";
|
|
5
5
|
import type { ResolvedPrompt } from "./prompt.js";
|
|
@@ -11,8 +11,7 @@ type ToolCallOptions = {
|
|
|
11
11
|
experimental_context?: unknown;
|
|
12
12
|
context?: unknown;
|
|
13
13
|
};
|
|
14
|
-
import { type
|
|
15
|
-
import { type SessionChannelHandleFor, type SessionTriggerConfigInput } from "./sessions.js";
|
|
14
|
+
import { type SessionChannelHandleFor } from "./sessions.js";
|
|
16
15
|
/** Re-export for typing `ctx` in `chat.agent` hooks without importing `@trigger.dev/core`. */
|
|
17
16
|
export type { TaskRunContext } from "@trigger.dev/core/v3";
|
|
18
17
|
export type ToolCallExecutionOptions = {
|
|
@@ -202,7 +201,7 @@ export type ChatTaskPayload<TClientData = unknown> = {
|
|
|
202
201
|
* to short-circuit the LLM call when an action doesn't need a response.
|
|
203
202
|
* - `"close"`: The chat session is being closed (internal; `run()` is not called).
|
|
204
203
|
*/
|
|
205
|
-
trigger: "submit-message" | "regenerate-message" | "preload" | "action" | "
|
|
204
|
+
trigger: "submit-message" | "regenerate-message" | "preload" | "action" | "close";
|
|
206
205
|
/** The ID of the message to regenerate (only for `"regenerate-message"`) */
|
|
207
206
|
messageId?: string;
|
|
208
207
|
/** Custom data from the frontend (passed via `metadata` on `sendMessage()` or the transport). */
|
|
@@ -243,16 +242,6 @@ export type ChatTaskRunPayload<TClientData = unknown, TTools extends ToolSet = T
|
|
|
243
242
|
* Use for tags, metadata, parent run links, or any API that needs the full run record.
|
|
244
243
|
*/
|
|
245
244
|
ctx: TaskRunContext;
|
|
246
|
-
/**
|
|
247
|
-
* `streamText` with this agent's managed options already applied: the
|
|
248
|
-
* prompt from `chat.prompt.set()`, the skill tools, telemetry, and the
|
|
249
|
-
* `prepareStep` that delivers steering, compaction and injected context.
|
|
250
|
-
*
|
|
251
|
-
* Prefer it over importing `streamText` from `ai`. The imported one takes
|
|
252
|
-
* none of that unless you spread `chat.toStreamTextOptions()` yourself, and
|
|
253
|
-
* forgetting the spread fails silently.
|
|
254
|
-
*/
|
|
255
|
-
streamText: AiStreamTextFn;
|
|
256
245
|
/** Token usage from the previous turn. Undefined on turn 0. */
|
|
257
246
|
previousTurnUsage?: LanguageModelUsage;
|
|
258
247
|
/** Cumulative token usage across all completed turns so far. */
|
|
@@ -849,12 +838,6 @@ export declare function buildSkillTools(skills: ResolvedSkill[]): Record<string,
|
|
|
849
838
|
* Options for {@link toStreamTextOptions}.
|
|
850
839
|
*/
|
|
851
840
|
export type ToStreamTextOptionsOptions = {
|
|
852
|
-
/**
|
|
853
|
-
* A base system prompt, used when `chat.prompt.set()` has not supplied one.
|
|
854
|
-
* `chat.agent({ system })` and a `system` passed to the managed `streamText`
|
|
855
|
-
* both arrive here.
|
|
856
|
-
*/
|
|
857
|
-
system?: string | SystemModelMessage;
|
|
858
841
|
/** Additional telemetry metadata merged into `experimental_telemetry.metadata`. */
|
|
859
842
|
telemetry?: Record<string, string>;
|
|
860
843
|
/**
|
|
@@ -925,23 +908,6 @@ export type SystemCacheControl = {
|
|
|
925
908
|
*
|
|
926
909
|
* If no prompt has been set, returns `{}` (no-op spread).
|
|
927
910
|
*/
|
|
928
|
-
/**
|
|
929
|
-
* The AI SDK's own `streamText` signature, borrowed rather than restated.
|
|
930
|
-
*
|
|
931
|
-
* The peer range spans `ai` v5, v6 and v7, whose `streamText` options differ.
|
|
932
|
-
* Describing the shape here would drift against all three; `typeof` resolves to
|
|
933
|
-
* whichever version the user installed, so generics, overloads and tool
|
|
934
|
-
* inference are exactly theirs.
|
|
935
|
-
*/
|
|
936
|
-
type AiStreamTextFn = typeof aiStreamTextSignature;
|
|
937
|
-
/**
|
|
938
|
-
* The `streamText` handed to a `chat.agent` `run()`, carrying the agent's
|
|
939
|
-
* managed options.
|
|
940
|
-
*
|
|
941
|
-
* Exported so a loop factored out of `run` can take it as a parameter and keep
|
|
942
|
-
* them: `function loop(messages: ModelMessage[], streamText: ChatStreamText)`.
|
|
943
|
-
*/
|
|
944
|
-
export type ChatStreamText = AiStreamTextFn;
|
|
945
911
|
declare function toStreamTextOptions(options?: ToStreamTextOptionsOptions): Record<string, unknown>;
|
|
946
912
|
/**
|
|
947
913
|
* Options for `pipeChat`.
|
|
@@ -987,37 +953,6 @@ export type ChatUIMessageStreamOptions<TUIM extends UIMessage = UIMessage> = Omi
|
|
|
987
953
|
type UIMessageStreamable = {
|
|
988
954
|
toUIMessageStream: (...args: any[]) => AsyncIterable<unknown> | ReadableStream<unknown>;
|
|
989
955
|
};
|
|
990
|
-
declare const actionTurnBrand: unique symbol;
|
|
991
|
-
/**
|
|
992
|
-
* The marker `onAction` returns to have a turn run on the history it just
|
|
993
|
-
* edited. Produce it with {@link chat.turn}.
|
|
994
|
-
*/
|
|
995
|
-
export type ActionTurn = {
|
|
996
|
-
readonly [actionTurnBrand]: true;
|
|
997
|
-
};
|
|
998
|
-
/**
|
|
999
|
-
* Turn the current action into a turn.
|
|
1000
|
-
*
|
|
1001
|
-
* Return it from `onAction` after editing history. The action's own work is
|
|
1002
|
-
* finished first (the edit is applied and snapshotted), then a turn runs on the
|
|
1003
|
-
* result exactly as a message turn does: `onTurnStart`, `run()` with the edited
|
|
1004
|
-
* history, `onBeforeTurnComplete`, `onTurnComplete`, and the turn counter
|
|
1005
|
-
* advances. That gives the answer everything a turn has, the system prompt,
|
|
1006
|
-
* tools, steering, compaction, injected instructions and persistence, with no
|
|
1007
|
-
* action-specific handling.
|
|
1008
|
-
*
|
|
1009
|
-
* @example
|
|
1010
|
-
* ```ts
|
|
1011
|
-
* onAction: async ({ action }) => {
|
|
1012
|
-
* if (action.type === "regenerate") {
|
|
1013
|
-
* chat.history.slice(0, -1);
|
|
1014
|
-
* return chat.turn();
|
|
1015
|
-
* }
|
|
1016
|
-
* if (action.type === "undo") chat.history.slice(0, -2); // no turn
|
|
1017
|
-
* },
|
|
1018
|
-
* ```
|
|
1019
|
-
*/
|
|
1020
|
-
declare function chatTurn(): ActionTurn;
|
|
1021
956
|
/**
|
|
1022
957
|
* Pipes a chat stream to the realtime stream, making it available to the
|
|
1023
958
|
* `TriggerChatTransport` on the frontend.
|
|
@@ -1610,17 +1545,6 @@ export type ChatAgentOptions<TIdentifier extends string, TClientDataSchema exten
|
|
|
1610
1545
|
* ```
|
|
1611
1546
|
*/
|
|
1612
1547
|
oomMachine?: MachinePresetName;
|
|
1613
|
-
/**
|
|
1614
|
-
* What to do when the session's `externalDeploymentId` no longer names the deployment
|
|
1615
|
-
* this run is on — after a redeploy re-pins the session, say.
|
|
1616
|
-
*
|
|
1617
|
-
* - `"follow"` (default) hands the conversation to the pinned deployment at the next
|
|
1618
|
-
* turn boundary, so no `chat.requestUpgrade()` of your own is needed.
|
|
1619
|
-
* - `"hold"` stays put until you ask to move. Manual `chat.requestUpgrade()` works either way.
|
|
1620
|
-
*
|
|
1621
|
-
* Ignored for sessions with no pin, and for sessions using `lockToVersion`.
|
|
1622
|
-
*/
|
|
1623
|
-
versionSkew?: ChatVersionSkewPolicy;
|
|
1624
1548
|
/**
|
|
1625
1549
|
* Schema for validating `clientData` from the frontend.
|
|
1626
1550
|
* Accepts Zod, ArkType, Valibot, or any supported schema library.
|
|
@@ -1675,14 +1599,13 @@ export type ChatAgentOptions<TIdentifier extends string, TClientDataSchema exten
|
|
|
1675
1599
|
* `onBeforeTurnComplete` / `onTurnComplete`, no `run()`. Use
|
|
1676
1600
|
* `chat.history.*` inside `onAction` to mutate state.
|
|
1677
1601
|
*
|
|
1678
|
-
* To
|
|
1679
|
-
*
|
|
1680
|
-
*
|
|
1681
|
-
* 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.
|
|
1682
1605
|
*/
|
|
1683
1606
|
onAction?: (event: ActionEvent<[
|
|
1684
1607
|
TActionSchema
|
|
1685
|
-
] extends [TaskSchema] ? inferSchemaOut<TActionSchema> : unknown, inferSchemaOut<TClientDataSchema>, TUIMessage>) => Promise<
|
|
1608
|
+
] extends [TaskSchema] ? inferSchemaOut<TActionSchema> : unknown, inferSchemaOut<TClientDataSchema>, TUIMessage>) => Promise<unknown> | unknown;
|
|
1686
1609
|
/**
|
|
1687
1610
|
* The tools available to this agent.
|
|
1688
1611
|
*
|
|
@@ -1974,31 +1897,6 @@ export type ChatAgentOptions<TIdentifier extends string, TClientDataSchema exten
|
|
|
1974
1897
|
* });
|
|
1975
1898
|
* ```
|
|
1976
1899
|
*/
|
|
1977
|
-
/**
|
|
1978
|
-
* A provider registry, so the runtime can resolve the managed prompt's model
|
|
1979
|
-
* for the `streamText` it hands to `run()`. Only needed when you set a model
|
|
1980
|
-
* through `chat.prompt.set()` and want the bound `streamText` to honour it.
|
|
1981
|
-
*/
|
|
1982
|
-
registry?: ToStreamTextOptionsOptions["registry"];
|
|
1983
|
-
/**
|
|
1984
|
-
* The agent's system prompt. Injected instructions append to it, and the
|
|
1985
|
-
* `streamText` handed to `run()` carries it without a spread.
|
|
1986
|
-
*
|
|
1987
|
-
* Set it here, at the call site, or through `chat.prompt.set()` for versioned
|
|
1988
|
-
* config, but only in one of them.
|
|
1989
|
-
*/
|
|
1990
|
-
system?: ToStreamTextOptionsOptions["system"];
|
|
1991
|
-
/**
|
|
1992
|
-
* Mark the system prompt for provider-side caching, the same sugar
|
|
1993
|
-
* `chat.toStreamTextOptions({ cacheControl })` takes. See
|
|
1994
|
-
* [prompt caching](/ai-chat/prompt-caching).
|
|
1995
|
-
*/
|
|
1996
|
-
cacheControl?: ToStreamTextOptionsOptions["cacheControl"];
|
|
1997
|
-
/**
|
|
1998
|
-
* Provider options for the system block, when `cacheControl` is not enough.
|
|
1999
|
-
* Takes precedence over `cacheControl`.
|
|
2000
|
-
*/
|
|
2001
|
-
systemProviderOptions?: ToStreamTextOptionsOptions["systemProviderOptions"];
|
|
2002
1900
|
compaction?: ChatAgentCompactionOptions<TUIMessage>;
|
|
2003
1901
|
/**
|
|
2004
1902
|
* Configure how messages that arrive during streaming are handled.
|
|
@@ -2492,22 +2390,15 @@ declare function setUIMessageStreamOptions(options: ChatUIMessageStreamOptions<U
|
|
|
2492
2390
|
*/
|
|
2493
2391
|
declare function isStopped(): boolean;
|
|
2494
2392
|
/**
|
|
2495
|
-
*
|
|
2496
|
-
*
|
|
2497
|
-
* The handover happens immediately and server-side: a successor run is created
|
|
2498
|
-
* and picks the conversation up from `session.in`. The transport keeps reading
|
|
2499
|
-
* the same session output, so no client action is needed and nothing waits for
|
|
2500
|
-
* the next message.
|
|
2501
|
-
*
|
|
2502
|
-
* Without a target the session's pin is cleared, so the successor lands on the
|
|
2503
|
-
* latest deployed version; with `externalDeploymentId` the session is re-pinned
|
|
2504
|
-
* 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).
|
|
2505
2395
|
*
|
|
2506
2396
|
* When called from `onTurnStart` or `onValidateMessages`, `run()` is skipped
|
|
2507
|
-
* entirely
|
|
2397
|
+
* entirely — the run exits immediately and the transport re-triggers the
|
|
2398
|
+
* same message on the new version.
|
|
2508
2399
|
*
|
|
2509
2400
|
* When called from `run()` or `chat.defer()`, the current turn completes
|
|
2510
|
-
* normally and the
|
|
2401
|
+
* normally and the run exits afterward instead of waiting for the next message.
|
|
2511
2402
|
*
|
|
2512
2403
|
* Call from `onTurnStart`, `onValidateMessages`, `onChatResume`, `run()`,
|
|
2513
2404
|
* or inside `chat.defer()`.
|
|
@@ -2527,9 +2418,7 @@ declare function isStopped(): boolean;
|
|
|
2527
2418
|
* });
|
|
2528
2419
|
* ```
|
|
2529
2420
|
*/
|
|
2530
|
-
declare function requestUpgrade(
|
|
2531
|
-
externalDeploymentId?: string;
|
|
2532
|
-
}): void;
|
|
2421
|
+
declare function requestUpgrade(): void;
|
|
2533
2422
|
/**
|
|
2534
2423
|
* Hand off the current custom agent Session to a fresh run.
|
|
2535
2424
|
*
|
|
@@ -2588,50 +2477,6 @@ declare function endAndContinue(): Promise<void>;
|
|
|
2588
2477
|
* ```
|
|
2589
2478
|
*/
|
|
2590
2479
|
declare function endRun(): void;
|
|
2591
|
-
/**
|
|
2592
|
-
* End the whole conversation, permanently. The session row is closed, further
|
|
2593
|
-
* appends are refused, and the run exits without scheduling a continuation.
|
|
2594
|
-
*
|
|
2595
|
-
* This is the session-level stop. {@link endRun} ends the current run and lets
|
|
2596
|
-
* the next message start a fresh one; `chat.close()` ends the session itself,
|
|
2597
|
-
* so there is no next message. Use it for a budget cap, a completed goal,
|
|
2598
|
-
* abuse detection, or a user signing out.
|
|
2599
|
-
*
|
|
2600
|
-
* In a `chat.agent`, call it from `run()`, `prepareStep`, or
|
|
2601
|
-
* `onBeforeTurnComplete`. Called mid-step, it aborts the in-flight
|
|
2602
|
-
* `streamText` the same way the stop signal does, so the partial response is
|
|
2603
|
-
* still captured and streamed. The turn then completes normally, a terminal
|
|
2604
|
-
* `session-closed` record carrying `reason` is written to the response stream,
|
|
2605
|
-
* and the loop exits.
|
|
2606
|
-
*
|
|
2607
|
-
* Prefer `onBeforeTurnComplete` over `onTurnComplete`. It carries the same
|
|
2608
|
-
* fields but still runs while the stream is open, so the closed state rides
|
|
2609
|
-
* out on the turn's final record. `onTurnComplete` runs after that record, so
|
|
2610
|
-
* a close decided there does not reach a reader that has already finished the
|
|
2611
|
-
* turn, and the user only finds out when their next message is refused.
|
|
2612
|
-
*
|
|
2613
|
-
* In a `chat.customAgent`, call it anywhere in your own loop. The close is
|
|
2614
|
-
* performed when `run()` returns, so it lands whether you break out of a
|
|
2615
|
-
* `chat.createSession` loop, return early, or hand-roll the loop entirely.
|
|
2616
|
-
*
|
|
2617
|
-
* Closing is one-way: a closed session cannot be reopened. Its transcript
|
|
2618
|
-
* stays readable.
|
|
2619
|
-
*
|
|
2620
|
-
* @example
|
|
2621
|
-
* ```ts
|
|
2622
|
-
* chat.agent({
|
|
2623
|
-
* id: "budgeted-agent",
|
|
2624
|
-
* onBeforeTurnComplete: async ({ usage }) => {
|
|
2625
|
-
* if (await overBudget(usage)) {
|
|
2626
|
-
* chat.close({ reason: "Monthly budget reached" });
|
|
2627
|
-
* }
|
|
2628
|
-
* },
|
|
2629
|
-
* });
|
|
2630
|
-
* ```
|
|
2631
|
-
*/
|
|
2632
|
-
declare function close(options?: {
|
|
2633
|
-
reason?: string;
|
|
2634
|
-
}): void;
|
|
2635
2480
|
/**
|
|
2636
2481
|
* Register a promise that runs in the background during the current turn.
|
|
2637
2482
|
*
|
|
@@ -2901,20 +2746,6 @@ declare class ChatMessageAccumulator {
|
|
|
2901
2746
|
* Queue a message for injection, converting to model messages automatically.
|
|
2902
2747
|
*/
|
|
2903
2748
|
steerAsync(message: UIMessage): Promise<void>;
|
|
2904
|
-
/**
|
|
2905
|
-
* Record the messages a steering drain consumed.
|
|
2906
|
-
*
|
|
2907
|
-
* The drain only puts them in this step's prompt, so without this they
|
|
2908
|
-
* shape one answer and then exist in neither lane: not in `uiMessages`,
|
|
2909
|
-
* which is what an app persists from, and not in `modelMessages`, which is
|
|
2910
|
-
* what every later turn sends.
|
|
2911
|
-
*
|
|
2912
|
-
* Both lanes are appended to. The model lane is never reconverted from the
|
|
2913
|
-
* UI lane, because `compactIfNeeded` replaces it with a summary and leaves
|
|
2914
|
-
* the UI lane whole: a reconversion would restore everything the summary
|
|
2915
|
-
* replaced.
|
|
2916
|
-
*/
|
|
2917
|
-
absorbSteering(claimed: UIMessage[], injected?: ModelMessage[]): Promise<void>;
|
|
2918
2749
|
/**
|
|
2919
2750
|
* Get and clear unconsumed steering messages.
|
|
2920
2751
|
*/
|
|
@@ -2952,11 +2783,6 @@ export type ChatSessionOptions = {
|
|
|
2952
2783
|
timeout?: string;
|
|
2953
2784
|
/** Max turns before ending. @default 100 */
|
|
2954
2785
|
maxTurns?: number;
|
|
2955
|
-
/**
|
|
2956
|
-
* What to do when the session's `externalDeploymentId` no longer names this deployment.
|
|
2957
|
-
* `"follow"` (default) hands over at the next turn boundary; `"hold"` stays put.
|
|
2958
|
-
*/
|
|
2959
|
-
versionSkew?: ChatVersionSkewPolicy;
|
|
2960
2786
|
/** Automatic context compaction — same options as `chat.agent({ compaction })`. */
|
|
2961
2787
|
compaction?: ChatAgentCompactionOptions;
|
|
2962
2788
|
/** Configure mid-execution message injection — same options as `chat.agent({ pendingMessages })`. */
|
|
@@ -3168,7 +2994,7 @@ export type CreateChatStartSessionActionOptions = {
|
|
|
3168
2994
|
* Default trigger config used when starting a new session for a chat.
|
|
3169
2995
|
* Per-call `params.triggerConfig` shallow-merges on top.
|
|
3170
2996
|
*/
|
|
3171
|
-
triggerConfig?: Partial<
|
|
2997
|
+
triggerConfig?: Partial<SessionTriggerConfig>;
|
|
3172
2998
|
/**
|
|
3173
2999
|
* Override the Trigger.dev API base URL. String applies to both
|
|
3174
3000
|
* `/api/v1/sessions` and `/api/v1/auth/jwt/claims`; function picks per
|
|
@@ -3211,7 +3037,7 @@ export type ChatStartSessionParams<TChat extends AnyTask = AnyTask> = {
|
|
|
3211
3037
|
* `chat.agent`: anything beyond `chatId`/`messages`/`trigger`/`metadata`,
|
|
3212
3038
|
* which the runtime injects automatically).
|
|
3213
3039
|
*/
|
|
3214
|
-
triggerConfig?: Partial<
|
|
3040
|
+
triggerConfig?: Partial<SessionTriggerConfig>;
|
|
3215
3041
|
/**
|
|
3216
3042
|
* Opaque session-level metadata stored on the Session row. Separate from
|
|
3217
3043
|
* the per-turn `clientData` above. Use this when you want to attach
|
|
@@ -3233,11 +3059,6 @@ export type ChatStartSessionResult = {
|
|
|
3233
3059
|
runId: string;
|
|
3234
3060
|
/** Session friendlyId — informational. */
|
|
3235
3061
|
sessionId: string;
|
|
3236
|
-
/**
|
|
3237
|
-
* The session's run is parked waiting for its deployment. Messages sent meanwhile are durable
|
|
3238
|
-
* and delivered once it lands; surface this so the wait reads as a deploy in progress.
|
|
3239
|
-
*/
|
|
3240
|
-
pendingVersion?: boolean;
|
|
3241
3062
|
};
|
|
3242
3063
|
/**
|
|
3243
3064
|
* Creates a server-side helper that starts (or resumes) a Session for a
|
|
@@ -3287,8 +3108,6 @@ export declare const chat: {
|
|
|
3287
3108
|
createStartSessionAction: typeof createChatStartSessionAction;
|
|
3288
3109
|
/** Pipe a stream to the chat transport. See {@link pipeChat}. */
|
|
3289
3110
|
pipe: typeof pipeChat;
|
|
3290
|
-
/** Return from `onAction` to run a turn on the edited history. See {@link chatTurn}. */
|
|
3291
|
-
turn: typeof chatTurn;
|
|
3292
3111
|
/** Create a per-run typed local. See {@link chatLocal}. */
|
|
3293
3112
|
local: typeof chatLocal;
|
|
3294
3113
|
/** Create a public access token for a chat task. See {@link createChatAccessToken}. */
|
|
@@ -3309,8 +3128,6 @@ export declare const chat: {
|
|
|
3309
3128
|
endAndContinue: typeof endAndContinue;
|
|
3310
3129
|
/** Exit the run after the current turn completes, without any upgrade signal. See {@link endRun}. */
|
|
3311
3130
|
endRun: typeof endRun;
|
|
3312
|
-
/** End the conversation permanently: close the session and exit the run. See {@link close}. */
|
|
3313
|
-
close: typeof close;
|
|
3314
3131
|
/** Clean up aborted parts from a UIMessage. See {@link cleanupAbortedParts}. */
|
|
3315
3132
|
cleanupAbortedParts: typeof cleanupAbortedParts;
|
|
3316
3133
|
/** Register background work that runs in parallel with streaming. See {@link chatDefer}. */
|