@trigger.dev/sdk 0.0.0-prerelease-20260909071038 → 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.
Files changed (142) hide show
  1. package/dist/commonjs/imports/ai-runtime-cjs.cjs.map +1 -1
  2. package/dist/commonjs/imports/ai-runtime.js +0 -2
  3. package/dist/commonjs/v3/ai-shared.d.ts +0 -15
  4. package/dist/commonjs/v3/ai-shared.js +1 -35
  5. package/dist/commonjs/v3/ai-shared.js.map +1 -1
  6. package/dist/commonjs/v3/ai.d.ts +25 -275
  7. package/dist/commonjs/v3/ai.js +308 -1283
  8. package/dist/commonjs/v3/ai.js.map +1 -1
  9. package/dist/commonjs/v3/chat-client.d.ts +2 -11
  10. package/dist/commonjs/v3/chat-client.js +111 -227
  11. package/dist/commonjs/v3/chat-client.js.map +1 -1
  12. package/dist/commonjs/v3/chat-react.d.ts +0 -88
  13. package/dist/commonjs/v3/chat-react.js +1 -130
  14. package/dist/commonjs/v3/chat-react.js.map +1 -1
  15. package/dist/commonjs/v3/chat-server.d.ts +6 -42
  16. package/dist/commonjs/v3/chat-server.js +7 -52
  17. package/dist/commonjs/v3/chat-server.js.map +1 -1
  18. package/dist/commonjs/v3/chat.d.ts +10 -92
  19. package/dist/commonjs/v3/chat.js +73 -328
  20. package/dist/commonjs/v3/chat.js.map +1 -1
  21. package/dist/commonjs/v3/sessions.d.ts +2 -15
  22. package/dist/commonjs/v3/sessions.js +1 -12
  23. package/dist/commonjs/v3/sessions.js.map +1 -1
  24. package/dist/commonjs/v3/shared.js +36 -30
  25. package/dist/commonjs/v3/shared.js.map +1 -1
  26. package/dist/commonjs/v3/test/index.d.ts +0 -1
  27. package/dist/commonjs/v3/test/index.js +1 -3
  28. package/dist/commonjs/v3/test/index.js.map +1 -1
  29. package/dist/commonjs/v3/test/mock-chat-agent.d.ts +4 -47
  30. package/dist/commonjs/v3/test/mock-chat-agent.js +4 -115
  31. package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
  32. package/dist/commonjs/v3/test/test-session-handle.js +0 -6
  33. package/dist/commonjs/v3/test/test-session-handle.js.map +1 -1
  34. package/dist/commonjs/version.js +1 -1
  35. package/dist/esm/imports/ai-runtime.d.ts +2 -2
  36. package/dist/esm/imports/ai-runtime.js +2 -2
  37. package/dist/esm/imports/ai-runtime.js.map +1 -1
  38. package/dist/esm/v3/ai-shared.d.ts +0 -15
  39. package/dist/esm/v3/ai-shared.js +0 -33
  40. package/dist/esm/v3/ai-shared.js.map +1 -1
  41. package/dist/esm/v3/ai.d.ts +25 -275
  42. package/dist/esm/v3/ai.js +305 -1275
  43. package/dist/esm/v3/ai.js.map +1 -1
  44. package/dist/esm/v3/chat-client.d.ts +2 -11
  45. package/dist/esm/v3/chat-client.js +112 -228
  46. package/dist/esm/v3/chat-client.js.map +1 -1
  47. package/dist/esm/v3/chat-react.d.ts +0 -88
  48. package/dist/esm/v3/chat-react.js +1 -127
  49. package/dist/esm/v3/chat-react.js.map +1 -1
  50. package/dist/esm/v3/chat-server.d.ts +6 -42
  51. package/dist/esm/v3/chat-server.js +8 -53
  52. package/dist/esm/v3/chat-server.js.map +1 -1
  53. package/dist/esm/v3/chat.d.ts +10 -92
  54. package/dist/esm/v3/chat.js +74 -329
  55. package/dist/esm/v3/chat.js.map +1 -1
  56. package/dist/esm/v3/sessions.d.ts +2 -15
  57. package/dist/esm/v3/sessions.js +1 -11
  58. package/dist/esm/v3/sessions.js.map +1 -1
  59. package/dist/esm/v3/shared.js +23 -17
  60. package/dist/esm/v3/shared.js.map +1 -1
  61. package/dist/esm/v3/test/index.d.ts +0 -1
  62. package/dist/esm/v3/test/index.js +0 -1
  63. package/dist/esm/v3/test/index.js.map +1 -1
  64. package/dist/esm/v3/test/mock-chat-agent.d.ts +4 -47
  65. package/dist/esm/v3/test/mock-chat-agent.js +6 -117
  66. package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
  67. package/dist/esm/v3/test/test-session-handle.js +0 -6
  68. package/dist/esm/v3/test/test-session-handle.js.map +1 -1
  69. package/dist/esm/version.js +1 -1
  70. package/docs/ai-chat/actions.mdx +23 -55
  71. package/docs/ai-chat/anatomy.mdx +3 -3
  72. package/docs/ai-chat/backend.mdx +48 -125
  73. package/docs/ai-chat/background-injection.mdx +19 -69
  74. package/docs/ai-chat/client-protocol.mdx +4 -5
  75. package/docs/ai-chat/compaction.mdx +7 -13
  76. package/docs/ai-chat/custom-agents.mdx +0 -23
  77. package/docs/ai-chat/fast-starts.mdx +20 -27
  78. package/docs/ai-chat/frontend.mdx +14 -19
  79. package/docs/ai-chat/lifecycle-hooks.mdx +2 -6
  80. package/docs/ai-chat/migrating-from-a-route-handler.mdx +14 -16
  81. package/docs/ai-chat/patterns/database-persistence.mdx +2 -6
  82. package/docs/ai-chat/patterns/persistence-and-replay.mdx +23 -34
  83. package/docs/ai-chat/patterns/skills.mdx +10 -7
  84. package/docs/ai-chat/patterns/version-upgrades.mdx +6 -79
  85. package/docs/ai-chat/pending-messages.mdx +3 -3
  86. package/docs/ai-chat/prompt-caching.mdx +25 -23
  87. package/docs/ai-chat/quick-start.mdx +11 -11
  88. package/docs/ai-chat/reference.mdx +9 -67
  89. package/docs/ai-chat/sessions.mdx +1 -6
  90. package/docs/ai-chat/testing.mdx +1 -2
  91. package/docs/ai-chat/tools.mdx +13 -18
  92. package/docs/ai-chat/upgrade-guide.mdx +2 -2
  93. package/docs/apikeys.mdx +45 -27
  94. package/docs/config/extensions/syncEnvVars.mdx +0 -6
  95. package/docs/deploy-environment-variables.mdx +2 -23
  96. package/docs/deployment/overview.mdx +8 -4
  97. package/docs/deployment/preview-branches.mdx +4 -4
  98. package/docs/deployment/version-skew-protection.mdx +0 -62
  99. package/docs/manual-setup.mdx +7 -7
  100. package/docs/mcp-tools.mdx +0 -9
  101. package/docs/quick-start.mdx +3 -3
  102. package/docs/realtime/auth.mdx +1 -1
  103. package/docs/self-hosting/security.mdx +0 -5
  104. package/docs/tasks/scheduled.mdx +0 -24
  105. package/docs/triggering.mdx +1 -1
  106. package/package.json +4 -4
  107. package/skills/trigger-authoring-chat-agent/SKILL.md +29 -41
  108. package/skills/trigger-chat-agent-advanced/SKILL.md +12 -31
  109. package/dist/commonjs/v3/chatSnapshotIo.d.ts +0 -2
  110. package/dist/commonjs/v3/chatSnapshotIo.js +0 -174
  111. package/dist/commonjs/v3/chatSnapshotIo.js.map +0 -1
  112. package/dist/commonjs/v3/chatVersionSkew.d.ts +0 -12
  113. package/dist/commonjs/v3/chatVersionSkew.js +0 -30
  114. package/dist/commonjs/v3/chatVersionSkew.js.map +0 -1
  115. package/dist/commonjs/v3/externalDeploymentId.d.ts +0 -23
  116. package/dist/commonjs/v3/externalDeploymentId.js +0 -43
  117. package/dist/commonjs/v3/externalDeploymentId.js.map +0 -1
  118. package/dist/commonjs/v3/test/transcript-storage-tests.d.ts +0 -40
  119. package/dist/commonjs/v3/test/transcript-storage-tests.js +0 -258
  120. package/dist/commonjs/v3/test/transcript-storage-tests.js.map +0 -1
  121. package/dist/commonjs/v3/transcriptStorage.d.ts +0 -229
  122. package/dist/commonjs/v3/transcriptStorage.js +0 -321
  123. package/dist/commonjs/v3/transcriptStorage.js.map +0 -1
  124. package/dist/esm/v3/chatSnapshotIo.d.ts +0 -2
  125. package/dist/esm/v3/chatSnapshotIo.js +0 -166
  126. package/dist/esm/v3/chatSnapshotIo.js.map +0 -1
  127. package/dist/esm/v3/chatVersionSkew.d.ts +0 -12
  128. package/dist/esm/v3/chatVersionSkew.js +0 -27
  129. package/dist/esm/v3/chatVersionSkew.js.map +0 -1
  130. package/dist/esm/v3/externalDeploymentId.d.ts +0 -23
  131. package/dist/esm/v3/externalDeploymentId.js +0 -38
  132. package/dist/esm/v3/externalDeploymentId.js.map +0 -1
  133. package/dist/esm/v3/test/transcript-storage-tests.d.ts +0 -40
  134. package/dist/esm/v3/test/transcript-storage-tests.js +0 -255
  135. package/dist/esm/v3/test/transcript-storage-tests.js.map +0 -1
  136. package/dist/esm/v3/transcriptStorage.d.ts +0 -229
  137. package/dist/esm/v3/transcriptStorage.js +0 -309
  138. package/dist/esm/v3/transcriptStorage.js.map +0 -1
  139. package/docs/ai-chat/patterns/native-compaction.mdx +0 -310
  140. package/docs/ai-chat/transcript-storage.mdx +0 -233
  141. package/docs/reports.mdx +0 -157
  142. package/docs/troubleshooting-zod.mdx +0 -158
@@ -177,20 +177,6 @@ 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
- } | {
194
180
  type: "message-sent";
195
181
  chatId: string;
196
182
  timestamp: number;
@@ -227,14 +213,6 @@ export type ChatTransportEvent = {
227
213
  timestamp: number;
228
214
  error: Error;
229
215
  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";
238
216
  } | {
239
217
  type: "first-chunk";
240
218
  chatId: string;
@@ -310,11 +288,6 @@ export type StartSessionParams<TClientData = unknown> = {
310
288
  export type StartSessionResult = {
311
289
  /** Session-scoped PAT — `read:sessions:{chatId} + write:sessions:{chatId}`. */
312
290
  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;
318
291
  };
319
292
  /**
320
293
  * Public surface of {@link TriggerChatTransport}'s session state. Everything
@@ -328,10 +301,6 @@ export type ChatSessionPersistedState = {
328
301
  /** The `.in` append sequence of the last send this client owned; reused as `sinceInSeq` on reconnect. */
329
302
  activeInputSeq?: number;
330
303
  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;
335
304
  };
336
305
  /**
337
306
  * Common options for the {@link TriggerChatTransport}.
@@ -524,10 +493,10 @@ export type TriggerChatTransportOptions<TClientData = unknown> = {
524
493
  */
525
494
  export declare class TriggerChatTransport implements ChatTransport<UIMessage> {
526
495
  private readonly taskId;
527
- private resolveAccessToken;
528
- private resolveStartSession;
496
+ private readonly resolveAccessToken;
497
+ private readonly resolveStartSession;
529
498
  private readonly resolveBaseURLFn;
530
- private fetchOverride;
499
+ private readonly fetchOverride;
531
500
  private readonly extraHeaders;
532
501
  private readonly streamTimeoutSeconds;
533
502
  private defaultMetadata;
@@ -537,7 +506,6 @@ export declare class TriggerChatTransport implements ChatTransport<UIMessage> {
537
506
  private _onSessionChange;
538
507
  private _onEvent;
539
508
  private sessions;
540
- private pendingResumeCursors;
541
509
  private activeStreams;
542
510
  private pendingStarts;
543
511
  private lastTurnSends;
@@ -610,36 +578,17 @@ export declare class TriggerChatTransport implements ChatTransport<UIMessage> {
610
578
  * message.
611
579
  */
612
580
  stopGeneration: (chatId: string) => Promise<boolean>;
613
- /**
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.
617
- */
618
- clearSupersedeGate: (chatId: string) => void;
619
581
  /**
620
582
  * 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>>;
583
+ * `onAction` hook). Actions are not turns — only `hydrateMessages`
584
+ * and `onAction` fire on the agent side. The returned stream
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`.
588
+ */
589
+ sendAction: (chatId: string, action: unknown) => Promise<ReadableStream<UIMessageChunk>>;
631
590
  getSession: (chatId: string) => ChatSessionPersistedState | undefined;
632
591
  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;
643
592
  setOnSessionChange(callback: ((chatId: string, session: ChatSessionPersistedState | null) => void) | undefined): void;
644
593
  /** Update the `onEvent` callback without recreating the transport. */
645
594
  setOnEvent(callback: ((event: ChatTransportEvent) => void) | undefined): void;
@@ -657,16 +606,6 @@ export declare class TriggerChatTransport implements ChatTransport<UIMessage> {
657
606
  * transport see the latest value the next time they fire.
658
607
  */
659
608
  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;
670
609
  isReadOnly(chatId: string): boolean;
671
610
  hasClaim(chatId: string): boolean;
672
611
  addReadOnlyListener(fn: (chatId: string, isReadOnly: boolean) => void): void;
@@ -677,20 +616,6 @@ export declare class TriggerChatTransport implements ChatTransport<UIMessage> {
677
616
  dispose(): void;
678
617
  private serializeInputChunk;
679
618
  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;
694
619
  private notifySessionChange;
695
620
  /**
696
621
  * Resolves the session state for a chatId, starting the session if
@@ -706,13 +631,6 @@ export declare class TriggerChatTransport implements ChatTransport<UIMessage> {
706
631
  * via `accessToken` and retry once. Surfaces non-auth errors as-is.
707
632
  */
708
633
  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;
716
634
  private doFetch;
717
635
  private appendInputChunk;
718
636
  private callWithAuthRetry;