@trigger.dev/sdk 4.5.15 → 4.6.0
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 +2 -0
- package/dist/commonjs/v3/ai-shared.d.ts +15 -0
- package/dist/commonjs/v3/ai-shared.js +35 -1
- package/dist/commonjs/v3/ai-shared.js.map +1 -1
- package/dist/commonjs/v3/ai.d.ts +311 -25
- package/dist/commonjs/v3/ai.js +1633 -380
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/auth.d.ts +10 -4
- package/dist/commonjs/v3/auth.js.map +1 -1
- package/dist/commonjs/v3/chat-client.d.ts +11 -2
- package/dist/commonjs/v3/chat-client.js +227 -111
- package/dist/commonjs/v3/chat-client.js.map +1 -1
- package/dist/commonjs/v3/chat-react.d.ts +88 -0
- package/dist/commonjs/v3/chat-react.js +130 -1
- package/dist/commonjs/v3/chat-react.js.map +1 -1
- package/dist/commonjs/v3/chat-server.d.ts +42 -6
- package/dist/commonjs/v3/chat-server.js +52 -7
- package/dist/commonjs/v3/chat-server.js.map +1 -1
- package/dist/commonjs/v3/chat.d.ts +92 -10
- package/dist/commonjs/v3/chat.js +328 -73
- package/dist/commonjs/v3/chat.js.map +1 -1
- package/dist/commonjs/v3/chatSnapshotIo.d.ts +2 -0
- package/dist/commonjs/v3/chatSnapshotIo.js +173 -0
- package/dist/commonjs/v3/chatSnapshotIo.js.map +1 -0
- package/dist/commonjs/v3/chatVersionSkew.d.ts +12 -0
- package/dist/commonjs/v3/chatVersionSkew.js +30 -0
- package/dist/commonjs/v3/chatVersionSkew.js.map +1 -0
- package/dist/commonjs/v3/externalDeploymentId.d.ts +23 -0
- package/dist/commonjs/v3/externalDeploymentId.js +43 -0
- package/dist/commonjs/v3/externalDeploymentId.js.map +1 -0
- package/dist/commonjs/v3/retry.d.ts +4 -0
- package/dist/commonjs/v3/retry.js +22 -13
- package/dist/commonjs/v3/retry.js.map +1 -1
- package/dist/commonjs/v3/sessions.d.ts +15 -2
- package/dist/commonjs/v3/sessions.js +12 -1
- package/dist/commonjs/v3/sessions.js.map +1 -1
- package/dist/commonjs/v3/shared.js +30 -36
- package/dist/commonjs/v3/shared.js.map +1 -1
- package/dist/commonjs/v3/test/index.d.ts +1 -0
- package/dist/commonjs/v3/test/index.js +3 -1
- package/dist/commonjs/v3/test/index.js.map +1 -1
- package/dist/commonjs/v3/test/mock-chat-agent.d.ts +47 -4
- package/dist/commonjs/v3/test/mock-chat-agent.js +116 -10
- package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/commonjs/v3/test/test-session-handle.js +6 -0
- package/dist/commonjs/v3/test/test-session-handle.js.map +1 -1
- package/dist/commonjs/v3/test/transcript-storage-tests.d.ts +40 -0
- package/dist/commonjs/v3/test/transcript-storage-tests.js +258 -0
- package/dist/commonjs/v3/test/transcript-storage-tests.js.map +1 -0
- package/dist/commonjs/v3/transcriptStorage.d.ts +261 -0
- package/dist/commonjs/v3/transcriptStorage.js +374 -0
- package/dist/commonjs/v3/transcriptStorage.js.map +1 -0
- 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-shared.d.ts +15 -0
- package/dist/esm/v3/ai-shared.js +33 -0
- package/dist/esm/v3/ai-shared.js.map +1 -1
- package/dist/esm/v3/ai.d.ts +311 -25
- package/dist/esm/v3/ai.js +1625 -377
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/auth.d.ts +10 -4
- package/dist/esm/v3/auth.js.map +1 -1
- package/dist/esm/v3/chat-client.d.ts +11 -2
- package/dist/esm/v3/chat-client.js +228 -112
- package/dist/esm/v3/chat-client.js.map +1 -1
- package/dist/esm/v3/chat-react.d.ts +88 -0
- package/dist/esm/v3/chat-react.js +127 -1
- package/dist/esm/v3/chat-react.js.map +1 -1
- package/dist/esm/v3/chat-server.d.ts +42 -6
- package/dist/esm/v3/chat-server.js +53 -8
- package/dist/esm/v3/chat-server.js.map +1 -1
- package/dist/esm/v3/chat.d.ts +92 -10
- package/dist/esm/v3/chat.js +329 -74
- package/dist/esm/v3/chat.js.map +1 -1
- package/dist/esm/v3/chatSnapshotIo.d.ts +2 -0
- package/dist/esm/v3/chatSnapshotIo.js +165 -0
- package/dist/esm/v3/chatSnapshotIo.js.map +1 -0
- package/dist/esm/v3/chatVersionSkew.d.ts +12 -0
- package/dist/esm/v3/chatVersionSkew.js +27 -0
- package/dist/esm/v3/chatVersionSkew.js.map +1 -0
- package/dist/esm/v3/externalDeploymentId.d.ts +23 -0
- package/dist/esm/v3/externalDeploymentId.js +38 -0
- package/dist/esm/v3/externalDeploymentId.js.map +1 -0
- package/dist/esm/v3/retry.d.ts +4 -0
- package/dist/esm/v3/retry.js +14 -8
- package/dist/esm/v3/retry.js.map +1 -1
- package/dist/esm/v3/sessions.d.ts +15 -2
- package/dist/esm/v3/sessions.js +11 -1
- package/dist/esm/v3/sessions.js.map +1 -1
- package/dist/esm/v3/shared.js +17 -23
- package/dist/esm/v3/shared.js.map +1 -1
- package/dist/esm/v3/test/index.d.ts +1 -0
- package/dist/esm/v3/test/index.js +1 -0
- package/dist/esm/v3/test/index.js.map +1 -1
- package/dist/esm/v3/test/mock-chat-agent.d.ts +47 -4
- package/dist/esm/v3/test/mock-chat-agent.js +118 -12
- package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/esm/v3/test/test-session-handle.js +6 -0
- package/dist/esm/v3/test/test-session-handle.js.map +1 -1
- package/dist/esm/v3/test/transcript-storage-tests.d.ts +40 -0
- package/dist/esm/v3/test/transcript-storage-tests.js +255 -0
- package/dist/esm/v3/test/transcript-storage-tests.js.map +1 -0
- package/dist/esm/v3/transcriptStorage.d.ts +261 -0
- package/dist/esm/v3/transcriptStorage.js +360 -0
- package/dist/esm/v3/transcriptStorage.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/docs/ai-chat/actions.mdx +55 -23
- package/docs/ai-chat/anatomy.mdx +47 -27
- package/docs/ai-chat/backend.mdx +125 -48
- package/docs/ai-chat/background-injection.mdx +122 -19
- package/docs/ai-chat/client-protocol.mdx +5 -4
- package/docs/ai-chat/compaction.mdx +13 -7
- package/docs/ai-chat/custom-agents.mdx +23 -0
- package/docs/ai-chat/fast-starts.mdx +27 -20
- package/docs/ai-chat/frontend.mdx +19 -14
- package/docs/ai-chat/how-it-works.mdx +1 -1
- package/docs/ai-chat/lifecycle-hooks.mdx +6 -2
- package/docs/ai-chat/migrating-from-a-route-handler.mdx +16 -14
- package/docs/ai-chat/migrating-from-hydrate-messages.mdx +299 -0
- package/docs/ai-chat/patterns/database-persistence.mdx +24 -9
- package/docs/ai-chat/patterns/native-compaction.mdx +310 -0
- package/docs/ai-chat/patterns/persistence-and-replay.mdx +34 -23
- package/docs/ai-chat/patterns/skills.mdx +7 -10
- package/docs/ai-chat/patterns/version-upgrades.mdx +79 -6
- package/docs/ai-chat/pending-messages.mdx +3 -3
- package/docs/ai-chat/prompt-caching.mdx +23 -25
- package/docs/ai-chat/quick-start.mdx +11 -11
- package/docs/ai-chat/reference.mdx +69 -10
- package/docs/ai-chat/sessions.mdx +6 -1
- package/docs/ai-chat/side-channels.mdx +1 -1
- package/docs/ai-chat/testing.mdx +2 -1
- package/docs/ai-chat/tools.mdx +18 -13
- package/docs/ai-chat/transcript-storage.mdx +247 -0
- package/docs/ai-chat/upgrade-guide.mdx +2 -2
- package/docs/apikeys.mdx +27 -45
- package/docs/config/extensions/custom.mdx +14 -1
- package/docs/config/extensions/syncEnvVars.mdx +6 -0
- package/docs/deploy-environment-variables.mdx +23 -2
- package/docs/deployment/overview.mdx +4 -8
- package/docs/deployment/preview-branches.mdx +4 -4
- package/docs/deployment/version-skew-protection.mdx +62 -0
- package/docs/github-integration.mdx +1 -1
- package/docs/introduction.mdx +58 -152
- package/docs/manual-setup.mdx +7 -7
- package/docs/mcp-tools.mdx +9 -0
- package/docs/quick-start.mdx +3 -3
- package/docs/realtime/auth.mdx +1 -1
- package/docs/reports.mdx +157 -0
- package/docs/self-hosting/security.mdx +17 -0
- package/docs/tasks/scheduled.mdx +24 -0
- package/docs/triggering.mdx +1 -1
- package/docs/troubleshooting-zod.mdx +158 -0
- package/docs/troubleshooting.mdx +1 -1
- package/package.json +4 -4
- package/skills/trigger-authoring-chat-agent/SKILL.md +41 -29
- package/skills/trigger-chat-agent-advanced/SKILL.md +54 -19
|
@@ -177,6 +177,20 @@ export type ChatTransportSendSource = "submit-message" | "regenerate-message" |
|
|
|
177
177
|
* stream fails unrecoverably.
|
|
178
178
|
*/
|
|
179
179
|
export type ChatTransportEvent = {
|
|
180
|
+
/**
|
|
181
|
+
* The chat's run is parked waiting for its deployment (version skew protection). Messages
|
|
182
|
+
* sent meanwhile are durable and drain when it lands, but nothing answers until then.
|
|
183
|
+
* Re-emitted on every send while parked; clear the notice on `first-chunk`.
|
|
184
|
+
*/
|
|
185
|
+
type: "run-pending-version";
|
|
186
|
+
chatId: string;
|
|
187
|
+
timestamp: number;
|
|
188
|
+
/**
|
|
189
|
+
* Where we learned it: creating the session, a send, the `headStart` POST, or an
|
|
190
|
+
* upgrade handing over to a deployment that has not landed yet.
|
|
191
|
+
*/
|
|
192
|
+
source: "start" | "send" | "head-start" | "upgrade";
|
|
193
|
+
} | {
|
|
180
194
|
type: "message-sent";
|
|
181
195
|
chatId: string;
|
|
182
196
|
timestamp: number;
|
|
@@ -213,6 +227,14 @@ export type ChatTransportEvent = {
|
|
|
213
227
|
timestamp: number;
|
|
214
228
|
error: Error;
|
|
215
229
|
status?: number;
|
|
230
|
+
} | {
|
|
231
|
+
type: "session-closed";
|
|
232
|
+
chatId: string;
|
|
233
|
+
timestamp: number;
|
|
234
|
+
/** The reason supplied to `chat.close()` / `sessions.close()`, if any. */
|
|
235
|
+
reason?: string;
|
|
236
|
+
/** How the transport learned: the terminal record, or a refused send. */
|
|
237
|
+
source: "stream" | "append";
|
|
216
238
|
} | {
|
|
217
239
|
type: "first-chunk";
|
|
218
240
|
chatId: string;
|
|
@@ -288,6 +310,11 @@ export type StartSessionParams<TClientData = unknown> = {
|
|
|
288
310
|
export type StartSessionResult = {
|
|
289
311
|
/** Session-scoped PAT — `read:sessions:{chatId} + write:sessions:{chatId}`. */
|
|
290
312
|
publicAccessToken: string;
|
|
313
|
+
/**
|
|
314
|
+
* Pass through `pendingVersion` from `chat.createStartSessionAction` (or `POST
|
|
315
|
+
* /api/v1/sessions`) and the transport emits `run-pending-version`.
|
|
316
|
+
*/
|
|
317
|
+
pendingVersion?: boolean;
|
|
291
318
|
};
|
|
292
319
|
/**
|
|
293
320
|
* Public surface of {@link TriggerChatTransport}'s session state. Everything
|
|
@@ -301,6 +328,10 @@ export type ChatSessionPersistedState = {
|
|
|
301
328
|
/** The `.in` append sequence of the last send this client owned; reused as `sinceInSeq` on reconnect. */
|
|
302
329
|
activeInputSeq?: number;
|
|
303
330
|
isStreaming?: boolean;
|
|
331
|
+
/** Set once the session is closed. Persisted so a reload doesn't retry a dead session. */
|
|
332
|
+
closed?: boolean;
|
|
333
|
+
/** The reason the session was closed, when one was given. */
|
|
334
|
+
closedReason?: string;
|
|
304
335
|
};
|
|
305
336
|
/**
|
|
306
337
|
* Common options for the {@link TriggerChatTransport}.
|
|
@@ -493,10 +524,10 @@ export type TriggerChatTransportOptions<TClientData = unknown> = {
|
|
|
493
524
|
*/
|
|
494
525
|
export declare class TriggerChatTransport implements ChatTransport<UIMessage> {
|
|
495
526
|
private readonly taskId;
|
|
496
|
-
private
|
|
497
|
-
private
|
|
527
|
+
private resolveAccessToken;
|
|
528
|
+
private resolveStartSession;
|
|
498
529
|
private readonly resolveBaseURLFn;
|
|
499
|
-
private
|
|
530
|
+
private fetchOverride;
|
|
500
531
|
private readonly extraHeaders;
|
|
501
532
|
private readonly streamTimeoutSeconds;
|
|
502
533
|
private defaultMetadata;
|
|
@@ -506,6 +537,7 @@ export declare class TriggerChatTransport implements ChatTransport<UIMessage> {
|
|
|
506
537
|
private _onSessionChange;
|
|
507
538
|
private _onEvent;
|
|
508
539
|
private sessions;
|
|
540
|
+
private pendingResumeCursors;
|
|
509
541
|
private activeStreams;
|
|
510
542
|
private pendingStarts;
|
|
511
543
|
private lastTurnSends;
|
|
@@ -579,16 +611,35 @@ export declare class TriggerChatTransport implements ChatTransport<UIMessage> {
|
|
|
579
611
|
*/
|
|
580
612
|
stopGeneration: (chatId: string) => Promise<boolean>;
|
|
581
613
|
/**
|
|
582
|
-
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
* carries any model response `onAction` produced (when it returns a
|
|
586
|
-
* `StreamTextResult`); for `void`-returning side-effect-only actions
|
|
587
|
-
* the stream completes immediately with `trigger:turn-complete`.
|
|
614
|
+
* Clear the supersede gate armed by a stop. Call this when the stopped
|
|
615
|
+
* turn died without ever writing its `trigger:turn-complete` boundary,
|
|
616
|
+
* otherwise the next turn stays gated forever.
|
|
588
617
|
*/
|
|
589
|
-
|
|
618
|
+
clearSupersedeGate: (chatId: string) => void;
|
|
619
|
+
/**
|
|
620
|
+
* Send a custom action chunk (for `chat.agent`'s `actionSchema` /
|
|
621
|
+
* `onAction` hook). An action is an edit: only `hydrateMessages` and
|
|
622
|
+
* `onAction` fire on the agent side, and the returned stream completes
|
|
623
|
+
* with `trigger:turn-complete` once the edit is persisted. When `onAction`
|
|
624
|
+
* returns `chat.turn()` the turn's response follows on the same stream.
|
|
625
|
+
* Per-action `metadata` is merged over the transport's `clientData`.
|
|
626
|
+
*/
|
|
627
|
+
sendAction: (chatId: string, action: unknown, options?: {
|
|
628
|
+
abortSignal?: AbortSignal;
|
|
629
|
+
metadata?: Record<string, unknown>;
|
|
630
|
+
}) => Promise<ReadableStream<UIMessageChunk>>;
|
|
590
631
|
getSession: (chatId: string) => ChatSessionPersistedState | undefined;
|
|
591
632
|
setSession(chatId: string, session: ChatSessionPersistedState): void;
|
|
633
|
+
/**
|
|
634
|
+
* Seed the `.out` resume cursor from a loaded transcript. Applied to the
|
|
635
|
+
* session now if it exists, otherwise held until the session is created so
|
|
636
|
+
* the first live subscription opens past the persisted history instead of
|
|
637
|
+
* replaying it. Never moves an existing cursor backward: the transcript load
|
|
638
|
+
* is async, so a live `.out` record can already have advanced the session
|
|
639
|
+
* past the snapshot, and overwriting it would replay those records.
|
|
640
|
+
*/
|
|
641
|
+
seedResumeCursor: (chatId: string, lastEventId: string) => void;
|
|
642
|
+
private applyPendingResumeCursor;
|
|
592
643
|
setOnSessionChange(callback: ((chatId: string, session: ChatSessionPersistedState | null) => void) | undefined): void;
|
|
593
644
|
/** Update the `onEvent` callback without recreating the transport. */
|
|
594
645
|
setOnEvent(callback: ((event: ChatTransportEvent) => void) | undefined): void;
|
|
@@ -606,6 +657,16 @@ export declare class TriggerChatTransport implements ChatTransport<UIMessage> {
|
|
|
606
657
|
* transport see the latest value the next time they fire.
|
|
607
658
|
*/
|
|
608
659
|
setClientData(clientData: Record<string, unknown> | undefined): void;
|
|
660
|
+
/**
|
|
661
|
+
* Update the request-time callbacks. Same reason as `setClientData`:
|
|
662
|
+
* a host that rebuilds these per render (a dashboard navigating between
|
|
663
|
+
* projects) would otherwise keep hitting the endpoint captured at
|
|
664
|
+
* construction. Every read goes through the live field, so the next
|
|
665
|
+
* request uses the latest callback.
|
|
666
|
+
*/
|
|
667
|
+
setAccessToken(accessToken: (params: AccessTokenParams) => string | Promise<string>): void;
|
|
668
|
+
setStartSession(startSession: ((params: StartSessionParams<Record<string, unknown>>) => Promise<StartSessionResult>) | undefined): void;
|
|
669
|
+
setFetch(fetchOverride: ChatFetchOverride | undefined): void;
|
|
609
670
|
isReadOnly(chatId: string): boolean;
|
|
610
671
|
hasClaim(chatId: string): boolean;
|
|
611
672
|
addReadOnlyListener(fn: (chatId: string, isReadOnly: boolean) => void): void;
|
|
@@ -616,6 +677,20 @@ export declare class TriggerChatTransport implements ChatTransport<UIMessage> {
|
|
|
616
677
|
dispose(): void;
|
|
617
678
|
private serializeInputChunk;
|
|
618
679
|
private toPersisted;
|
|
680
|
+
/**
|
|
681
|
+
* Flip a session to closed and tell listeners once. Terminal: sends and
|
|
682
|
+
* reconnects stop from here on, and there is no reopening.
|
|
683
|
+
*/
|
|
684
|
+
private markSessionClosed;
|
|
685
|
+
/**
|
|
686
|
+
* Whether the conversation has been closed — by the agent via
|
|
687
|
+
* `chat.close()`, or from outside via `sessions.close()`. Closed is
|
|
688
|
+
* one-way: the transport refuses further sends and reconnects, and the
|
|
689
|
+
* transcript stays readable.
|
|
690
|
+
*/
|
|
691
|
+
sessionStatus: (chatId: string) => "open" | "closed";
|
|
692
|
+
/** The reason the session was closed, when one was given. */
|
|
693
|
+
sessionClosedReason: (chatId: string) => string | undefined;
|
|
619
694
|
private notifySessionChange;
|
|
620
695
|
/**
|
|
621
696
|
* Resolves the session state for a chatId, starting the session if
|
|
@@ -631,6 +706,13 @@ export declare class TriggerChatTransport implements ChatTransport<UIMessage> {
|
|
|
631
706
|
* via `accessToken` and retry once. Surfaces non-auth errors as-is.
|
|
632
707
|
*/
|
|
633
708
|
private resolveBaseURL;
|
|
709
|
+
/**
|
|
710
|
+
* `fetchClient` for an `out` subscription. Reads `this.fetchOverride` on
|
|
711
|
+
* every call, not once per subscription: a watch-mode subscription
|
|
712
|
+
* reconnects for the lifetime of the page, and `setFetch` may have swapped
|
|
713
|
+
* the override in between.
|
|
714
|
+
*/
|
|
715
|
+
private sseFetchClient;
|
|
634
716
|
private doFetch;
|
|
635
717
|
private appendInputChunk;
|
|
636
718
|
private callWithAuthRetry;
|