@trigger.dev/sdk 4.8.4 → 4.8.6

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 (187) hide show
  1. package/dist/commonjs/v3/ai.d.ts +29 -5
  2. package/dist/commonjs/v3/ai.js +160 -114
  3. package/dist/commonjs/v3/ai.js.map +1 -1
  4. package/dist/commonjs/v3/auth.d.ts +4 -4
  5. package/dist/commonjs/v3/auth.js +21 -75
  6. package/dist/commonjs/v3/auth.js.map +1 -1
  7. package/dist/commonjs/v3/chat-client.d.ts +1 -1
  8. package/dist/commonjs/v3/chat.d.ts +1 -1
  9. package/dist/commonjs/v3/prompt.js +6 -8
  10. package/dist/commonjs/v3/prompt.js.map +1 -1
  11. package/dist/commonjs/v3/runs.d.ts +5 -1
  12. package/dist/commonjs/v3/runs.js.map +1 -1
  13. package/dist/commonjs/v3/sessions.js +10 -7
  14. package/dist/commonjs/v3/sessions.js.map +1 -1
  15. package/dist/commonjs/v3/shared.d.ts +2 -2
  16. package/dist/commonjs/v3/shared.js +16 -15
  17. package/dist/commonjs/v3/shared.js.map +1 -1
  18. package/dist/commonjs/v3/steeringContext.d.ts +35 -10
  19. package/dist/commonjs/v3/steeringContext.js +35 -12
  20. package/dist/commonjs/v3/steeringContext.js.map +1 -1
  21. package/dist/commonjs/v3/streams.js +10 -8
  22. package/dist/commonjs/v3/streams.js.map +1 -1
  23. package/dist/commonjs/v3/tasks.d.ts +2 -2
  24. package/dist/commonjs/v3/tasks.js.map +1 -1
  25. package/dist/commonjs/v3/test/mock-chat-agent.js +24 -13
  26. package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
  27. package/dist/commonjs/v3/webhooks.d.ts +8 -2
  28. package/dist/commonjs/v3/webhooks.js +20 -11
  29. package/dist/commonjs/v3/webhooks.js.map +1 -1
  30. package/dist/commonjs/version.js +1 -1
  31. package/dist/esm/v3/ai.d.ts +29 -5
  32. package/dist/esm/v3/ai.js +162 -117
  33. package/dist/esm/v3/ai.js.map +1 -1
  34. package/dist/esm/v3/auth.d.ts +4 -4
  35. package/dist/esm/v3/auth.js +22 -76
  36. package/dist/esm/v3/auth.js.map +1 -1
  37. package/dist/esm/v3/chat-client.d.ts +1 -1
  38. package/dist/esm/v3/chat.d.ts +1 -1
  39. package/dist/esm/v3/prompt.js +6 -8
  40. package/dist/esm/v3/prompt.js.map +1 -1
  41. package/dist/esm/v3/runs.d.ts +5 -1
  42. package/dist/esm/v3/runs.js.map +1 -1
  43. package/dist/esm/v3/sessions.js +10 -7
  44. package/dist/esm/v3/sessions.js.map +1 -1
  45. package/dist/esm/v3/shared.d.ts +2 -2
  46. package/dist/esm/v3/shared.js +16 -15
  47. package/dist/esm/v3/shared.js.map +1 -1
  48. package/dist/esm/v3/steeringContext.d.ts +35 -10
  49. package/dist/esm/v3/steeringContext.js +34 -12
  50. package/dist/esm/v3/steeringContext.js.map +1 -1
  51. package/dist/esm/v3/streams.js +10 -8
  52. package/dist/esm/v3/streams.js.map +1 -1
  53. package/dist/esm/v3/tasks.d.ts +2 -2
  54. package/dist/esm/v3/tasks.js.map +1 -1
  55. package/dist/esm/v3/test/mock-chat-agent.js +25 -14
  56. package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
  57. package/dist/esm/v3/webhooks.d.ts +8 -2
  58. package/dist/esm/v3/webhooks.js +20 -11
  59. package/dist/esm/v3/webhooks.js.map +1 -1
  60. package/dist/esm/version.js +1 -1
  61. package/docs/ai/observability.mdx +25 -19
  62. package/docs/ai/prompts.mdx +25 -19
  63. package/docs/ai-chat/actions.mdx +1 -1
  64. package/docs/ai-chat/anatomy.mdx +1 -1
  65. package/docs/ai-chat/backend.mdx +24 -24
  66. package/docs/ai-chat/background-injection.mdx +5 -5
  67. package/docs/ai-chat/chat-local.mdx +2 -2
  68. package/docs/ai-chat/compaction.mdx +38 -15
  69. package/docs/ai-chat/custom-agents.mdx +4 -4
  70. package/docs/ai-chat/error-handling.mdx +4 -4
  71. package/docs/ai-chat/fast-starts.mdx +8 -7
  72. package/docs/ai-chat/frontend.mdx +6 -2
  73. package/docs/ai-chat/lifecycle-hooks.mdx +11 -11
  74. package/docs/ai-chat/migrating-from-a-route-handler.mdx +4 -4
  75. package/docs/ai-chat/migrating-from-hydrate-messages.mdx +1 -1
  76. package/docs/ai-chat/overview.mdx +1 -1
  77. package/docs/ai-chat/patterns/branching-conversations.mdx +1 -1
  78. package/docs/ai-chat/patterns/database-persistence.mdx +2 -2
  79. package/docs/ai-chat/patterns/human-in-the-loop.mdx +1 -1
  80. package/docs/ai-chat/patterns/native-compaction.mdx +29 -9
  81. package/docs/ai-chat/patterns/persistence-and-replay.mdx +1 -1
  82. package/docs/ai-chat/patterns/redacting-telemetry.mdx +2 -2
  83. package/docs/ai-chat/patterns/skills.mdx +2 -2
  84. package/docs/ai-chat/patterns/sub-agents.mdx +1 -1
  85. package/docs/ai-chat/patterns/tool-result-auditing.mdx +1 -1
  86. package/docs/ai-chat/patterns/trusted-edge-signals.mdx +2 -2
  87. package/docs/ai-chat/patterns/version-upgrades.mdx +2 -2
  88. package/docs/ai-chat/pending-messages.mdx +5 -5
  89. package/docs/ai-chat/prompt-caching.mdx +7 -7
  90. package/docs/ai-chat/quick-start.mdx +2 -2
  91. package/docs/ai-chat/testing.mdx +9 -9
  92. package/docs/ai-chat/tools.mdx +9 -5
  93. package/docs/ai-chat/transcript-storage.mdx +2 -2
  94. package/docs/ai-chat/types.mdx +10 -3
  95. package/docs/apikeys.mdx +2 -1
  96. package/docs/cli-login-commands.mdx +12 -0
  97. package/docs/concurrency.mdx +40 -0
  98. package/docs/database-connections.mdx +1 -1
  99. package/docs/deploy-environment-variables.mdx +84 -2
  100. package/docs/deployment/trusted-publishing.mdx +4 -0
  101. package/docs/errors-retrying.mdx +25 -18
  102. package/docs/github-actions.mdx +1 -1
  103. package/docs/github-integration.mdx +21 -0
  104. package/docs/how-it-works.mdx +4 -2
  105. package/docs/introduction.mdx +1 -1
  106. package/docs/mcp-introduction.mdx +7 -1
  107. package/docs/mcp-remote.mdx +90 -0
  108. package/docs/oidc/azure.mdx +81 -0
  109. package/docs/oidc/databricks.mdx +99 -0
  110. package/docs/oidc/doppler.mdx +60 -0
  111. package/docs/oidc/gcp.mdx +109 -0
  112. package/docs/oidc/hugging-face.mdx +90 -0
  113. package/docs/oidc/openrouter.mdx +91 -0
  114. package/docs/oidc/snowflake.mdx +91 -0
  115. package/docs/oidc/vault.mdx +71 -0
  116. package/docs/oidc.mdx +2 -0
  117. package/docs/runs/metadata.mdx +1 -1
  118. package/docs/self-hosting/docker.mdx +2 -0
  119. package/docs/self-hosting/env/webapp.mdx +4 -1
  120. package/docs/self-hosting/kubernetes.mdx +2 -0
  121. package/docs/tasks/schemaTask.mdx +26 -13
  122. package/docs/tasks/streams.mdx +2 -2
  123. package/docs/troubleshooting.mdx +7 -0
  124. package/docs/webhooks/channels.mdx +6 -6
  125. package/docs/webhooks/connect.mdx +9 -75
  126. package/docs/webhooks/custom-providers.mdx +87 -0
  127. package/docs/webhooks/deliveries.mdx +7 -7
  128. package/docs/webhooks/filters.mdx +2 -2
  129. package/docs/webhooks/how-it-works.mdx +58 -0
  130. package/docs/webhooks/human-in-the-loop.mdx +3 -3
  131. package/docs/webhooks/linear.mdx +5 -3
  132. package/docs/webhooks/overview.mdx +20 -71
  133. package/docs/webhooks/own-handler.mdx +62 -0
  134. package/docs/webhooks/pricing-and-limits.mdx +13 -0
  135. package/docs/webhooks/providers/attio.mdx +38 -0
  136. package/docs/webhooks/providers/autumn.mdx +40 -0
  137. package/docs/webhooks/providers/cal-com.mdx +41 -0
  138. package/docs/webhooks/providers/calendly.mdx +41 -0
  139. package/docs/webhooks/providers/clerk.mdx +40 -0
  140. package/docs/webhooks/providers/discord.mdx +45 -0
  141. package/docs/webhooks/providers/docusign.mdx +41 -0
  142. package/docs/webhooks/providers/elevenlabs.mdx +41 -0
  143. package/docs/webhooks/providers/firecrawl.mdx +54 -0
  144. package/docs/webhooks/providers/github.mdx +46 -0
  145. package/docs/webhooks/providers/gitlab.mdx +41 -0
  146. package/docs/webhooks/providers/granola.mdx +44 -0
  147. package/docs/webhooks/providers/hookdeck.mdx +98 -0
  148. package/docs/webhooks/providers/infisical.mdx +41 -0
  149. package/docs/webhooks/providers/jira.mdx +41 -0
  150. package/docs/webhooks/providers/langfuse.mdx +40 -0
  151. package/docs/webhooks/providers/linear.mdx +45 -0
  152. package/docs/webhooks/providers/loops.mdx +40 -0
  153. package/docs/webhooks/providers/metronome.mdx +42 -0
  154. package/docs/webhooks/providers/mux.mdx +40 -0
  155. package/docs/webhooks/providers/openai.mdx +40 -0
  156. package/docs/webhooks/providers/pagerduty.mdx +40 -0
  157. package/docs/webhooks/providers/plain.mdx +41 -0
  158. package/docs/webhooks/providers/planetscale.mdx +40 -0
  159. package/docs/webhooks/providers/recall-ai.mdx +54 -0
  160. package/docs/webhooks/providers/replicate.mdx +41 -0
  161. package/docs/webhooks/providers/resend.mdx +44 -0
  162. package/docs/webhooks/providers/retell.mdx +41 -0
  163. package/docs/webhooks/providers/sentry.mdx +41 -0
  164. package/docs/webhooks/providers/shopify.mdx +49 -0
  165. package/docs/webhooks/providers/slack.mdx +48 -0
  166. package/docs/webhooks/providers/square.mdx +40 -0
  167. package/docs/webhooks/providers/stripe.mdx +86 -0
  168. package/docs/webhooks/providers/supabase.mdx +41 -0
  169. package/docs/webhooks/providers/tailscale.mdx +43 -0
  170. package/docs/webhooks/providers/typeform.mdx +42 -0
  171. package/docs/webhooks/providers/vapi.mdx +47 -0
  172. package/docs/webhooks/providers/vercel.mdx +40 -0
  173. package/docs/webhooks/providers/whatsapp.mdx +45 -0
  174. package/docs/webhooks/providers/workos.mdx +41 -0
  175. package/docs/webhooks/providers/zendesk.mdx +41 -0
  176. package/docs/webhooks/providers.mdx +53 -0
  177. package/docs/webhooks/quick-start.mdx +131 -0
  178. package/docs/webhooks/session-routing.mdx +6 -6
  179. package/docs/webhooks/signing-secrets.mdx +80 -0
  180. package/docs/webhooks/slack.mdx +11 -2
  181. package/docs/webhooks/verification.mdx +139 -0
  182. package/docs/webhooks/waiters.mdx +2 -2
  183. package/docs/webhooks/webhook-tasks.mdx +46 -0
  184. package/package.json +4 -5
  185. package/docs/migrating-from-v3.mdx +0 -332
  186. package/docs/webhooks/public-beta.mdx +0 -70
  187. package/docs/webhooks/sources.mdx +0 -252
@@ -490,6 +490,11 @@ export type ChatNewToolResult = {
490
490
  /** State stored in locals during prepareStep compaction. */
491
491
  interface CompactionState {
492
492
  summary: string;
493
+ /**
494
+ * How many of the generation's response messages the summary covers. Later
495
+ * steps rebuild from the summary plus the response messages after these.
496
+ * Returned by `chat.getCompactionState()` for custom `prepareStep` code.
497
+ */
493
498
  baseResponseMessageCount: number;
494
499
  /** Completed steps summarized this turn; unlike message counts, matches UI step markers. */
495
500
  baseResponseStepCount: number;
@@ -619,6 +624,8 @@ export type PendingMessageReceivedEvent<TUIM extends UIMessage = UIMessage> = {
619
624
  chatId: string;
620
625
  /** Current turn number (0-indexed). */
621
626
  turn: number;
627
+ /** Custom data from the frontend. */
628
+ clientData?: unknown;
622
629
  };
623
630
  /**
624
631
  * Event passed to `onInjected` callback (batch, after injection).
@@ -632,6 +639,8 @@ export type PendingMessagesInjectedEvent<TUIM extends UIMessage = UIMessage> = {
632
639
  chatId: string;
633
640
  /** Current turn number (0-indexed). */
634
641
  turn: number;
642
+ /** Custom data from the frontend. */
643
+ clientData?: unknown;
635
644
  /** Step number where injection occurred. */
636
645
  stepNumber: number;
637
646
  };
@@ -736,6 +745,8 @@ export type CompactedEvent = {
736
745
  chatId?: string;
737
746
  /** The current turn number (if running inside a chat.agent). */
738
747
  turn?: number;
748
+ /** Custom data from the frontend (if inside a chat.agent). */
749
+ clientData?: unknown;
739
750
  /** Stream writer — write custom `UIMessageChunk` parts to the chat stream. Lazy: no overhead if unused. */
740
751
  writer: ChatWriter;
741
752
  };
@@ -833,6 +844,12 @@ export type CompactOptions = {
833
844
  threshold?: number;
834
845
  /** Custom compaction trigger. When provided, used instead of `threshold`. */
835
846
  shouldCompact?: (event: ShouldCompactEvent) => boolean | Promise<boolean>;
847
+ /**
848
+ * The `responseMessages` your `prepareStep` receives. AI SDK 7 passes them,
849
+ * and without them later steps cannot be rebuilt after a compaction on AI
850
+ * SDK 7. Earlier AI SDK versions do not need them.
851
+ */
852
+ responseMessages?: ModelMessage[];
836
853
  };
837
854
  /**
838
855
  * Read the current compaction state. Returns the summary and base message count
@@ -859,9 +876,10 @@ declare function getCompactionState(): CompactionState | undefined;
859
876
  *
860
877
  * @example
861
878
  * ```ts
862
- * prepareStep: async ({ messages, steps }) => {
879
+ * prepareStep: async ({ messages, steps, responseMessages }) => {
863
880
  * // your custom logic here...
864
881
  * const result = await chat.compact(messages, steps, {
882
+ * responseMessages, // needed on AI SDK 7 to rebuild the steps after a compaction
865
883
  * threshold: 80_000,
866
884
  * summarize: async (msgs) => generateText({ model, messages: msgs }).then(r => r.text),
867
885
  * });
@@ -899,6 +917,7 @@ declare function chatCompact(messages: ModelMessage[], steps: CompactionStep[],
899
917
  declare function chatCompactionStep(options: CompactionOptions): (args: {
900
918
  messages: ModelMessage[];
901
919
  steps: CompactionStep[];
920
+ responseMessages?: ModelMessage[];
902
921
  }) => Promise<{
903
922
  messages: ModelMessage[];
904
923
  } | undefined>;
@@ -1471,6 +1490,8 @@ export type ValidateMessagesEvent<TUIM extends UIMessage = UIMessage> = {
1471
1490
  chatId: string;
1472
1491
  /** The turn number (0-indexed). */
1473
1492
  turn: number;
1493
+ /** Custom data from the frontend. */
1494
+ clientData?: unknown;
1474
1495
  /** The trigger type for this turn. */
1475
1496
  trigger: "submit-message" | "regenerate-message" | "preload" | "close";
1476
1497
  };
@@ -2220,8 +2241,11 @@ declare function makeChannelStreamTap(editor: ChannelStreamEditor, options?: {
2220
2241
  stopOnEnd?: boolean;
2221
2242
  }): TransformStream<unknown, unknown>;
2222
2243
  export { makeChannelStreamEditor as __makeChannelStreamEditorForTests, makeChannelStreamTap as __makeChannelStreamTapForTests, makeChannelProgressObserver as __makeChannelProgressObserverForTests, makeChannelLifecycleReporter as __makeChannelLifecycleReporterForTests, };
2244
+ type ChatLatchReason = "settled" | "run-ended";
2223
2245
  /** Resolves once the post-turn channel egress for `chatId` has finished (immediately when none is running). */
2224
- export declare function __waitForChannelEgressForTests(chatId: string): Promise<void>;
2246
+ export declare function __waitForChannelEgressForTests(chatId: string): Promise<ChatLatchReason | undefined>;
2247
+ /** Resolves once the post-turn hooks for `chatId` have finished (immediately when none are running). */
2248
+ export declare function __waitForPostTurnHooksForTests(chatId: string): Promise<ChatLatchReason | undefined>;
2225
2249
  type ChatActionType<TActionSchema extends TaskSchema | undefined, TW extends readonly AnyChatEvent[]> = [TActionSchema] extends [TaskSchema] ? inferSchemaOut<TActionSchema> | ChatEventActions<TW> : [TW] extends [readonly []] ? unknown : ChatEventActions<TW>;
2226
2250
  export type ChatAgentOptions<TIdentifier extends string, TClientDataSchema extends TaskSchema | undefined = undefined, TUIMessage extends UIMessage = UIMessage, TActionSchema extends TaskSchema | undefined = undefined, TTools extends ToolSet = ToolSet, TW extends readonly AnyChatEvent[] = [], TChannels extends readonly AnyChannelConnector[] = []> = Omit<TaskOptions<TIdentifier, ChatTaskWirePayload<TUIMessage, inferSchemaIn<TClientDataSchema>>, unknown>, "run" | "retry"> & {
2227
2251
  /**
@@ -3893,7 +3917,7 @@ declare function chatLocal<T extends Record<string, unknown>>(options: {
3893
3917
  * `createChatStartSessionAction`.
3894
3918
  *
3895
3919
  * - `"sessions"` — `POST /api/v1/sessions` (session create + first run trigger).
3896
- * - `"auth"` — `POST /api/v1/auth/jwt/claims` (only fired when
3920
+ * - `"auth"` — `POST /api/v1/auth/public-tokens` (only fired when
3897
3921
  * `tokenTTL` is set; otherwise the publicAccessToken from session create
3898
3922
  * is reused as-is).
3899
3923
  */
@@ -3914,7 +3938,7 @@ export type CreateChatStartSessionActionOptions = {
3914
3938
  triggerConfig?: Partial<SessionTriggerConfigInput>;
3915
3939
  /**
3916
3940
  * Override the Trigger.dev API base URL. String applies to both
3917
- * `/api/v1/sessions` and `/api/v1/auth/jwt/claims`; function picks per
3941
+ * `/api/v1/sessions` and `/api/v1/auth/public-tokens`; function picks per
3918
3942
  * endpoint. When unset, falls back to `apiClientManager.baseURL`
3919
3943
  * (typically the `TRIGGER_API_URL` env var). Set this to route session
3920
3944
  * create through a trusted edge proxy that injects server-side signal
@@ -3929,7 +3953,7 @@ export type CreateChatStartSessionActionOptions = {
3929
3953
  fetch?: ChatStartSessionFetchOverride;
3930
3954
  /**
3931
3955
  * API client config (baseURL / accessToken) to scope this action to a specific
3932
- * environment, for callers that can't set a global `TRIGGER_SECRET_KEY`. The
3956
+ * environment without changing global `configure({ accessToken })` settings. The
3933
3957
  * returned action runs under this config.
3934
3958
  */
3935
3959
  apiClient?: ApiClientConfiguration;