@trigger.dev/sdk 0.0.0-prerelease-20260911094758 → 0.0.0-prerelease-windows-bundle-fix-20260928100448
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 +73 -12
- package/dist/commonjs/v3/ai.js +542 -289
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/auth.d.ts +10 -4
- package/dist/commonjs/v3/auth.js +8 -2
- package/dist/commonjs/v3/auth.js.map +1 -1
- package/dist/commonjs/v3/chat-client.js +7 -0
- package/dist/commonjs/v3/chat-client.js.map +1 -1
- package/dist/commonjs/v3/chat-server.d.ts +1 -0
- package/dist/commonjs/v3/chat-server.js +8 -0
- package/dist/commonjs/v3/chat-server.js.map +1 -1
- package/dist/commonjs/v3/chat.js +13 -9
- package/dist/commonjs/v3/chat.js.map +1 -1
- package/dist/commonjs/v3/compactionResponse.d.ts +9 -0
- package/dist/commonjs/v3/compactionResponse.js +37 -0
- package/dist/commonjs/v3/compactionResponse.js.map +1 -0
- package/dist/commonjs/v3/concurrency-shared.d.ts +13 -0
- package/dist/commonjs/v3/concurrency-shared.js +35 -0
- package/dist/commonjs/v3/concurrency-shared.js.map +1 -0
- package/dist/commonjs/v3/concurrencyLimits.d.ts +73 -0
- package/dist/commonjs/v3/concurrencyLimits.js +166 -0
- package/dist/commonjs/v3/concurrencyLimits.js.map +1 -0
- package/dist/commonjs/v3/index.d.ts +2 -1
- package/dist/commonjs/v3/index.js +3 -1
- package/dist/commonjs/v3/index.js.map +1 -1
- package/dist/commonjs/v3/managedChatResponse.d.ts +44 -0
- package/dist/commonjs/v3/managedChatResponse.js +233 -0
- package/dist/commonjs/v3/managedChatResponse.js.map +1 -0
- package/dist/commonjs/v3/queues.d.ts +31 -0
- package/dist/commonjs/v3/queues.js +31 -0
- package/dist/commonjs/v3/queues.js.map +1 -1
- package/dist/commonjs/v3/runs.d.ts +5 -0
- package/dist/commonjs/v3/sessionTracing.d.ts +7 -0
- package/dist/commonjs/v3/sessionTracing.js +44 -0
- package/dist/commonjs/v3/sessionTracing.js.map +1 -0
- package/dist/commonjs/v3/sessions.js +31 -34
- package/dist/commonjs/v3/sessions.js.map +1 -1
- package/dist/commonjs/v3/shared.d.ts +18 -1
- package/dist/commonjs/v3/shared.js +145 -52
- package/dist/commonjs/v3/shared.js.map +1 -1
- package/dist/commonjs/v3/steeringContext.d.ts +41 -0
- package/dist/commonjs/v3/steeringContext.js +118 -0
- package/dist/commonjs/v3/steeringContext.js.map +1 -0
- package/dist/commonjs/v3/test/transcript-storage-tests.js.map +1 -1
- package/dist/commonjs/v3/transcriptStorage.d.ts +5 -2
- package/dist/commonjs/v3/transcriptStorage.js +55 -4
- package/dist/commonjs/v3/transcriptStorage.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/ai.d.ts +73 -12
- package/dist/esm/v3/ai.js +543 -290
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/auth.d.ts +10 -4
- package/dist/esm/v3/auth.js +8 -2
- package/dist/esm/v3/auth.js.map +1 -1
- package/dist/esm/v3/chat-client.js +7 -0
- package/dist/esm/v3/chat-client.js.map +1 -1
- package/dist/esm/v3/chat-server.d.ts +1 -0
- package/dist/esm/v3/chat-server.js +8 -0
- package/dist/esm/v3/chat-server.js.map +1 -1
- package/dist/esm/v3/chat.js +13 -9
- package/dist/esm/v3/chat.js.map +1 -1
- package/dist/esm/v3/compactionResponse.d.ts +9 -0
- package/dist/esm/v3/compactionResponse.js +34 -0
- package/dist/esm/v3/compactionResponse.js.map +1 -0
- package/dist/esm/v3/concurrency-shared.d.ts +13 -0
- package/dist/esm/v3/concurrency-shared.js +31 -0
- package/dist/esm/v3/concurrency-shared.js.map +1 -0
- package/dist/esm/v3/concurrencyLimits.d.ts +73 -0
- package/dist/esm/v3/concurrencyLimits.js +158 -0
- package/dist/esm/v3/concurrencyLimits.js.map +1 -0
- package/dist/esm/v3/index.d.ts +2 -1
- package/dist/esm/v3/index.js +2 -1
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/esm/v3/managedChatResponse.d.ts +44 -0
- package/dist/esm/v3/managedChatResponse.js +228 -0
- package/dist/esm/v3/managedChatResponse.js.map +1 -0
- package/dist/esm/v3/queues.d.ts +31 -0
- package/dist/esm/v3/queues.js +31 -0
- package/dist/esm/v3/queues.js.map +1 -1
- package/dist/esm/v3/runs.d.ts +5 -0
- package/dist/esm/v3/sessionTracing.d.ts +7 -0
- package/dist/esm/v3/sessionTracing.js +40 -0
- package/dist/esm/v3/sessionTracing.js.map +1 -0
- package/dist/esm/v3/sessions.js +31 -34
- package/dist/esm/v3/sessions.js.map +1 -1
- package/dist/esm/v3/shared.d.ts +18 -1
- package/dist/esm/v3/shared.js +145 -53
- package/dist/esm/v3/shared.js.map +1 -1
- package/dist/esm/v3/steeringContext.d.ts +41 -0
- package/dist/esm/v3/steeringContext.js +113 -0
- package/dist/esm/v3/steeringContext.js.map +1 -0
- package/dist/esm/v3/test/transcript-storage-tests.js.map +1 -1
- package/dist/esm/v3/transcriptStorage.d.ts +5 -2
- package/dist/esm/v3/transcriptStorage.js +55 -5
- package/dist/esm/v3/transcriptStorage.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai-chat/anatomy.mdx +44 -24
- package/docs/ai-chat/background-injection.mdx +54 -1
- package/docs/ai-chat/client-protocol.mdx +2 -0
- package/docs/ai-chat/error-handling.mdx +44 -76
- package/docs/ai-chat/frontend.mdx +27 -21
- package/docs/ai-chat/lifecycle-hooks.mdx +4 -2
- package/docs/ai-chat/migrating-from-hydrate-messages.mdx +299 -0
- package/docs/ai-chat/patterns/branching-conversations.mdx +95 -230
- package/docs/ai-chat/patterns/database-persistence.mdx +18 -7
- package/docs/ai-chat/patterns/human-in-the-loop.mdx +166 -164
- package/docs/ai-chat/patterns/tool-result-auditing.mdx +28 -27
- package/docs/ai-chat/pending-messages.mdx +19 -5
- package/docs/ai-chat/quick-start.mdx +26 -20
- package/docs/ai-chat/reference.mdx +6 -3
- package/docs/ai-chat/side-channels.mdx +1 -1
- package/docs/ai-chat/testing.mdx +16 -4
- package/docs/ai-chat/transcript-storage.mdx +14 -6
- package/docs/cli-env-commands.mdx +114 -0
- package/docs/cli-projects-commands.mdx +62 -0
- package/docs/cli-runs-commands.mdx +94 -0
- package/docs/concurrency.mdx +384 -0
- package/docs/database-connections.mdx +3 -3
- package/docs/deploy-environment-variables.mdx +6 -0
- package/docs/idempotency.mdx +43 -5
- package/docs/introduction.mdx +58 -152
- package/docs/limits.mdx +16 -6
- package/docs/observability/query.mdx +25 -0
- package/docs/queues.mdx +248 -0
- package/docs/reports.mdx +1 -1
- package/docs/runs/priority.mdx +2 -25
- package/docs/self-hosting/env/webapp.mdx +7 -0
- package/docs/tasks/overview.mdx +3 -5
- package/docs/troubleshooting-alerts.mdx +124 -1
- package/docs/troubleshooting.mdx +12 -0
- package/docs/writing-tasks-introduction.mdx +2 -1
- package/package.json +2 -2
- package/docs/queue-concurrency.mdx +0 -358
package/dist/commonjs/v3/ai.d.ts
CHANGED
|
@@ -149,6 +149,41 @@ export declare const ai: {
|
|
|
149
149
|
* ```
|
|
150
150
|
*/
|
|
151
151
|
declare function createChatAccessToken<TTask extends AnyTask>(taskId: TaskIdentifier<TTask>): Promise<string>;
|
|
152
|
+
/**
|
|
153
|
+
* Register work that must land before anything from this turn reaches the
|
|
154
|
+
* frontend.
|
|
155
|
+
*
|
|
156
|
+
* Like {@link chatDefer} the work starts immediately and is never awaited by
|
|
157
|
+
* the hook that registered it, so it runs alongside the model and costs no
|
|
158
|
+
* time to first token. Unlike `chat.defer`, the output stream waits for it:
|
|
159
|
+
* no chunk of the answer is written to the session until it settles. That
|
|
160
|
+
* makes it the right home for a write the next page load has to see (a
|
|
161
|
+
* conversation row, a message insert), because a reader that can see the
|
|
162
|
+
* answer can also see what the write persisted.
|
|
163
|
+
*
|
|
164
|
+
* Reach for `chat.defer` instead when the timing does not matter for a
|
|
165
|
+
* reload: analytics, audit logs, search-index updates.
|
|
166
|
+
*
|
|
167
|
+
* This is not a consistency barrier for the turn. The work is still in flight
|
|
168
|
+
* while the model runs, so a tool, a `prepareStep`, or anything else executing
|
|
169
|
+
* during the turn can still read the state as it was before the write. It
|
|
170
|
+
* orders the write against what the frontend can see, nothing more. When the
|
|
171
|
+
* turn's own code has to read the write back, `await` it instead and accept
|
|
172
|
+
* the cost.
|
|
173
|
+
*
|
|
174
|
+
* A write registered here that fails, or outlasts the internal timeout, lets
|
|
175
|
+
* the stream through rather than stalling the conversation.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* onTurnStart: async ({ chatId, uiMessages }) => {
|
|
180
|
+
* chat.deferBeforeOutput(
|
|
181
|
+
* db.chat.update({ where: { id: chatId }, data: { messages: uiMessages } })
|
|
182
|
+
* );
|
|
183
|
+
* },
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
declare function chatDeferBeforeOutput(promiseOrFn: Promise<unknown> | (() => Promise<unknown>)): void;
|
|
152
187
|
/**
|
|
153
188
|
* A stream writer passed to chat lifecycle callbacks (`onPreload`, `onChatStart`,
|
|
154
189
|
* `onTurnStart`, `onTurnComplete`, `onCompacted`).
|
|
@@ -380,6 +415,8 @@ export type ChatNewToolResult = {
|
|
|
380
415
|
interface CompactionState {
|
|
381
416
|
summary: string;
|
|
382
417
|
baseResponseMessageCount: number;
|
|
418
|
+
/** Completed steps summarized this turn; unlike message counts, matches UI step markers. */
|
|
419
|
+
baseResponseStepCount: number;
|
|
383
420
|
}
|
|
384
421
|
/**
|
|
385
422
|
* Event passed to `summarize` callbacks.
|
|
@@ -632,14 +669,24 @@ export type CompactedEvent = {
|
|
|
632
669
|
export type ShouldCompactEvent = {
|
|
633
670
|
/** The current model messages (full conversation). */
|
|
634
671
|
messages: ModelMessage[];
|
|
635
|
-
/**
|
|
672
|
+
/**
|
|
673
|
+
* Total token count of the triggering model call: the step that just finished
|
|
674
|
+
* (`"inner"`), or the turn's LAST step (`"outer"`). This is the size of the
|
|
675
|
+
* context the model held on that call, which is what a compaction decision is
|
|
676
|
+
* about. It is never the sum over a multi-step turn; see `turnUsage` for that.
|
|
677
|
+
*/
|
|
636
678
|
totalTokens: number | undefined;
|
|
637
|
-
/** Input token count
|
|
679
|
+
/** Input token count of the triggering model call (see `totalTokens`). */
|
|
638
680
|
inputTokens: number | undefined;
|
|
639
|
-
/** Output token count
|
|
681
|
+
/** Output token count of the triggering model call (see `totalTokens`). */
|
|
640
682
|
outputTokens: number | undefined;
|
|
641
|
-
/** Full usage object
|
|
683
|
+
/** Full usage object of the triggering model call (see `totalTokens`). */
|
|
642
684
|
usage?: LanguageModelUsage;
|
|
685
|
+
/**
|
|
686
|
+
* The whole turn's usage summed over every step, as the provider billed it.
|
|
687
|
+
* Only present when `source` is `"outer"`.
|
|
688
|
+
*/
|
|
689
|
+
turnUsage?: LanguageModelUsage;
|
|
643
690
|
/** Cumulative token usage across all completed turns. Present in chat.agent contexts. */
|
|
644
691
|
totalUsage?: LanguageModelUsage;
|
|
645
692
|
/** The chat session ID (if running inside a chat.agent). */
|
|
@@ -943,7 +990,7 @@ type AiStreamTextFn = typeof aiStreamTextSignature;
|
|
|
943
990
|
* them: `function loop(messages: ModelMessage[], streamText: ChatStreamText)`.
|
|
944
991
|
*/
|
|
945
992
|
export type ChatStreamText = AiStreamTextFn;
|
|
946
|
-
declare function toStreamTextOptions(options?: ToStreamTextOptionsOptions): Record<string, unknown>;
|
|
993
|
+
declare function toStreamTextOptions(options?: ToStreamTextOptionsOptions, retain?: boolean): Record<string, unknown>;
|
|
947
994
|
/**
|
|
948
995
|
* Options for `pipeChat`.
|
|
949
996
|
*/
|
|
@@ -1058,7 +1105,9 @@ declare function chatTurn(): ActionTurn;
|
|
|
1058
1105
|
* }
|
|
1059
1106
|
* ```
|
|
1060
1107
|
*/
|
|
1061
|
-
declare function pipeChat(source: UIMessageStreamable | AsyncIterable<unknown> | ReadableStream<unknown>, options?: PipeChatOptions
|
|
1108
|
+
declare function pipeChat(source: UIMessageStreamable | AsyncIterable<unknown> | ReadableStream<unknown>, options?: PipeChatOptions, capture?: {
|
|
1109
|
+
originalMessages?: UIMessage[];
|
|
1110
|
+
}): Promise<void>;
|
|
1062
1111
|
/**
|
|
1063
1112
|
* Options for defining a chat task.
|
|
1064
1113
|
*
|
|
@@ -1409,13 +1458,17 @@ export type TurnCompleteEvent<TClientData = unknown, TUIM extends UIMessage = UI
|
|
|
1409
1458
|
*/
|
|
1410
1459
|
uiMessages: TUIM[];
|
|
1411
1460
|
/**
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1461
|
+
* Model messages for this turn's user message(s) and complete assistant response,
|
|
1462
|
+
* including steps summarized during the turn. Same-ID approval and handover
|
|
1463
|
+
* continuations include the full replacement response, so these are not always
|
|
1464
|
+
* an append-only delta. Persist `messages` for future model context, or upsert
|
|
1465
|
+
* `newUIMessages` by ID for the visible conversation.
|
|
1414
1466
|
*/
|
|
1415
1467
|
newMessages: ModelMessage[];
|
|
1416
1468
|
/**
|
|
1417
|
-
*
|
|
1418
|
-
*
|
|
1469
|
+
* New or updated UI messages from this turn (user message(s) + assistant response).
|
|
1470
|
+
* Upsert by message ID: approval and handover continuations can replace an
|
|
1471
|
+
* existing assistant message.
|
|
1419
1472
|
*/
|
|
1420
1473
|
newUIMessages: TUIM[];
|
|
1421
1474
|
/** The assistant's response for this turn, with aborted parts cleaned up when `stopped` is true. Undefined if `pipeChat` was used manually. */
|
|
@@ -2864,8 +2917,11 @@ declare class ChatMessageAccumulator {
|
|
|
2864
2917
|
modelMessages: ModelMessage[];
|
|
2865
2918
|
uiMessages: UIMessage[];
|
|
2866
2919
|
private _compaction?;
|
|
2920
|
+
/** The run a spliced head-start partial contributed, until its response replaces it. */
|
|
2921
|
+
private _handoverRun?;
|
|
2867
2922
|
private _pendingMessages?;
|
|
2868
2923
|
private _steeringQueue;
|
|
2924
|
+
private _pendingSteer;
|
|
2869
2925
|
constructor(options?: {
|
|
2870
2926
|
compaction?: ChatAgentCompactionOptions;
|
|
2871
2927
|
pendingMessages?: PendingMessagesOptions;
|
|
@@ -2960,8 +3016,10 @@ declare class ChatMessageAccumulator {
|
|
|
2960
3016
|
} | undefined>) | undefined;
|
|
2961
3017
|
/**
|
|
2962
3018
|
* Run outer-loop compaction if needed. Call after adding the response
|
|
2963
|
-
* and capturing usage.
|
|
2964
|
-
*
|
|
3019
|
+
* and capturing usage. Pass the LAST step's usage (`result.usage`), which is
|
|
3020
|
+
* the context the model held on its final call; `result.totalUsage` sums every
|
|
3021
|
+
* step of a tool-using turn and belongs in `context.turnUsage`. Applies
|
|
3022
|
+
* `compactModelMessages` and `compactUIMessages` callbacks if configured.
|
|
2965
3023
|
*
|
|
2966
3024
|
* @returns `true` if compaction was performed, `false` otherwise.
|
|
2967
3025
|
*/
|
|
@@ -2969,6 +3027,8 @@ declare class ChatMessageAccumulator {
|
|
|
2969
3027
|
chatId?: string;
|
|
2970
3028
|
turn?: number;
|
|
2971
3029
|
clientData?: unknown;
|
|
3030
|
+
/** The whole turn summed over its steps (`result.totalUsage`). */
|
|
3031
|
+
turnUsage?: LanguageModelUsage;
|
|
2972
3032
|
totalUsage?: LanguageModelUsage;
|
|
2973
3033
|
}): Promise<boolean>;
|
|
2974
3034
|
}
|
|
@@ -3382,6 +3442,7 @@ export declare const chat: {
|
|
|
3382
3442
|
cleanupAbortedParts: typeof cleanupAbortedParts;
|
|
3383
3443
|
/** Register background work that runs in parallel with streaming. See {@link chatDefer}. */
|
|
3384
3444
|
defer: typeof chatDefer;
|
|
3445
|
+
deferBeforeOutput: typeof chatDeferBeforeOutput;
|
|
3385
3446
|
/** Queue model messages for injection at the next `prepareStep` boundary. See {@link injectBackgroundContext}. */
|
|
3386
3447
|
inject: typeof injectBackgroundContext;
|
|
3387
3448
|
/** Typed chat output stream for writing custom chunks or piping from subtasks. */
|