@trigger.dev/sdk 4.7.4 → 4.7.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 (48) hide show
  1. package/dist/commonjs/v3/ai.d.ts +26 -0
  2. package/dist/commonjs/v3/ai.js +7 -5
  3. package/dist/commonjs/v3/ai.js.map +1 -1
  4. package/dist/commonjs/v3/query.d.ts +434 -1
  5. package/dist/commonjs/v3/query.js +115 -0
  6. package/dist/commonjs/v3/query.js.map +1 -1
  7. package/dist/commonjs/version.js +1 -1
  8. package/dist/esm/v3/ai.d.ts +26 -0
  9. package/dist/esm/v3/ai.js +7 -5
  10. package/dist/esm/v3/ai.js.map +1 -1
  11. package/dist/esm/v3/query.d.ts +434 -1
  12. package/dist/esm/v3/query.js +115 -0
  13. package/dist/esm/v3/query.js.map +1 -1
  14. package/dist/esm/version.js +1 -1
  15. package/docs/ai-chat/actions.mdx +6 -1
  16. package/docs/ai-chat/backend.mdx +47 -0
  17. package/docs/ai-chat/patterns/redacting-telemetry.mdx +117 -0
  18. package/docs/ai-chat/pending-messages.mdx +2 -0
  19. package/docs/ai-chat/reference.mdx +53 -2
  20. package/docs/ai-chat/transcript-storage.mdx +1 -1
  21. package/docs/apikeys.mdx +6 -4
  22. package/docs/cli-runs-commands.mdx +2 -2
  23. package/docs/cli-tasks-commands.mdx +95 -0
  24. package/docs/config/config-file.mdx +58 -0
  25. package/docs/config/extensions/prismaExtension.mdx +4 -4
  26. package/docs/deploy-environment-variables.mdx +4 -0
  27. package/docs/deployment/atomic-deployment.mdx +3 -3
  28. package/docs/deployment/overview.mdx +1 -1
  29. package/docs/deployment/preview-branches.mdx +1 -1
  30. package/docs/github-actions.mdx +3 -3
  31. package/docs/limits.mdx +6 -0
  32. package/docs/manual-setup.mdx +1 -1
  33. package/docs/mcp-tools.mdx +99 -3
  34. package/docs/observability/dashboards.mdx +62 -0
  35. package/docs/runs/max-duration.mdx +4 -0
  36. package/docs/self-hosting/env/supervisor.mdx +1 -0
  37. package/docs/webhooks/channels.mdx +158 -0
  38. package/docs/webhooks/connect.mdx +84 -0
  39. package/docs/webhooks/deliveries.mdx +103 -0
  40. package/docs/webhooks/filters.mdx +150 -0
  41. package/docs/webhooks/human-in-the-loop.mdx +162 -0
  42. package/docs/webhooks/linear.mdx +190 -0
  43. package/docs/webhooks/overview.mdx +119 -0
  44. package/docs/webhooks/session-routing.mdx +145 -0
  45. package/docs/webhooks/slack.mdx +397 -0
  46. package/docs/webhooks/sources.mdx +224 -0
  47. package/docs/webhooks/waiters.mdx +194 -0
  48. package/package.json +3 -2
@@ -33,6 +33,7 @@ type ChatTurnContext<TClientData = unknown> = {
33
33
  turn: number;
34
34
  continuation: boolean;
35
35
  clientData?: TClientData;
36
+ recordUserMessage?: boolean;
36
37
  };
37
38
  export { __readChatSnapshotProductionPathForTests, __setReadChatSnapshotImplForTests, __setWriteChatSnapshotImplForTests, __writeChatSnapshotProductionPathForTests, } from "./chatSnapshotIo.js";
38
39
  export { defaultStorage, memoryTranscriptStorage, reduceTranscriptChanges, snapshotTranscriptStorage, type LoadContextEvent, type MemoryTranscriptStorage, type TranscriptChange, type TranscriptChangeReason, type TranscriptChangeset, type TranscriptCursors, type TranscriptLoadOptions, type TranscriptLoadResult, type TranscriptScope, type TranscriptState, type TranscriptStorage, type TranscriptStorageContext, } from "./transcriptStorage.js";
@@ -1677,6 +1678,31 @@ export type ChatAgentOptions<TIdentifier extends string, TClientDataSchema exten
1677
1678
  * Ignored for sessions with no pin, and for sessions using `lockToVersion`.
1678
1679
  */
1679
1680
  versionSkew?: ChatVersionSkewPolicy;
1681
+ /**
1682
+ * Controls which chat content the chat runtime records on its spans in the run trace.
1683
+ *
1684
+ * - `recordUserMessage` (default `true`) records the last user message as `chat.user_message`
1685
+ * and as the turn span's preview text, and messages sent mid-turn as `pending.messages`.
1686
+ * - `recordClientData` (default `true`) records the raw `clientData` sent by the frontend as
1687
+ * `chat.client_data`.
1688
+ *
1689
+ * Set either to `false` to keep that content out of telemetry. Content recorded by the AI SDK's
1690
+ * own spans is controlled separately, through `experimental_telemetry` on the model call.
1691
+ *
1692
+ * @example
1693
+ * ```ts
1694
+ * chat.agent({
1695
+ * id: "my-chat",
1696
+ * telemetry: { recordUserMessage: false, recordClientData: false },
1697
+ * run: async ({ messages, signal, streamText }) =>
1698
+ * streamText({ model, messages, abortSignal: signal }),
1699
+ * });
1700
+ * ```
1701
+ */
1702
+ telemetry?: {
1703
+ recordUserMessage?: boolean;
1704
+ recordClientData?: boolean;
1705
+ };
1680
1706
  /**
1681
1707
  * Schema for validating `clientData` from the frontend.
1682
1708
  * Accepts Zod, ArkType, Valibot, or any supported schema library.
@@ -2880,7 +2880,6 @@ async function drainSteeringQueue(config, messages, steps, queueOverride) {
2880
2880
  // Span attributes describe the offered batch; the chunk and callback below
2881
2881
  // describe what was actually claimed and injected.
2882
2882
  const messageTexts = uiMessages.map(textOfUIMessage);
2883
- const _previewText = messageTexts.length === 1 ? messageTexts[0].slice(0, 80) : `${queue.length} messages`;
2884
2883
  return tracer_js_1.tracer.startActiveSpan("pending message injected", async () => {
2885
2884
  /**
2886
2885
  * Claim before transforming, and inject only what was claimed.
@@ -3019,7 +3018,7 @@ async function drainSteeringQueue(config, messages, steps, queueOverride) {
3019
3018
  [v3_1.SemanticInternalAttributes.STYLE_ICON]: "tabler-message-forward",
3020
3019
  "pending.message_count": uiMessages.length,
3021
3020
  "pending.step_number": stepNumber,
3022
- "pending.messages": messageTexts,
3021
+ ...(ctx?.recordUserMessage === false ? {} : { "pending.messages": messageTexts }),
3023
3022
  ...(ctx?.chatId ? { "pending.chat_id": ctx.chatId } : {}),
3024
3023
  ...(ctx?.turn != null ? { "pending.turn": ctx.turn } : {}),
3025
3024
  ...(0, v3_1.accessoryAttributes)({
@@ -3858,7 +3857,9 @@ function chatCustomAgent(options) {
3858
3857
  return task;
3859
3858
  }
3860
3859
  function chatAgent(options) {
3861
- const { run: userRun, clientDataSchema, onBoot, onRecoveryBoot, onPreload, onChatStart, onValidateMessages, hydrateMessages, storage, actionSchema, onAction, onTurnStart, onBeforeTurnComplete, onCompacted, compaction, pendingMessages: pendingMessagesConfig, prepareMessages, tools: toolsOption, onTurnComplete, maxTurns = 100, turnTimeout = "1h", idleTimeoutInSeconds = 30, chatAccessTokenTTL = "1h", preloadIdleTimeoutInSeconds, preloadTimeout, uiMessageStreamOptions, onChatSuspend, onChatResume, exitAfterPreloadIdle = false, oomMachine, registry: promptRegistry, system: agentSystem, cacheControl: agentCacheControl, systemProviderOptions: agentSystemProviderOptions, versionSkew, ...restOptions } = options;
3860
+ const { run: userRun, clientDataSchema, onBoot, onRecoveryBoot, onPreload, onChatStart, onValidateMessages, hydrateMessages, storage, actionSchema, onAction, onTurnStart, onBeforeTurnComplete, onCompacted, compaction, pendingMessages: pendingMessagesConfig, prepareMessages, tools: toolsOption, onTurnComplete, maxTurns = 100, turnTimeout = "1h", idleTimeoutInSeconds = 30, chatAccessTokenTTL = "1h", preloadIdleTimeoutInSeconds, preloadTimeout, uiMessageStreamOptions, onChatSuspend, onChatResume, exitAfterPreloadIdle = false, oomMachine, registry: promptRegistry, system: agentSystem, cacheControl: agentCacheControl, systemProviderOptions: agentSystemProviderOptions, versionSkew, telemetry: telemetryOptions, ...restOptions } = options;
3861
+ const recordUserMessage = telemetryOptions?.recordUserMessage ?? true;
3862
+ const recordClientData = telemetryOptions?.recordClientData ?? true;
3862
3863
  if (hydrateMessages) {
3863
3864
  if (storage) {
3864
3865
  throw new Error(`chat.agent: "${options.id}" sets both \`hydrateMessages\` and \`storage\`. ` +
@@ -4995,7 +4996,7 @@ function chatAgent(options) {
4995
4996
  : "tabler-message-chatbot",
4996
4997
  [v3_1.SemanticInternalAttributes.ENTITY_TYPE]: isAction ? "chat-action" : "chat-turn",
4997
4998
  };
4998
- if (lastUserMessage) {
4999
+ if (lastUserMessage && recordUserMessage) {
4999
5000
  turnAttributes["chat.user_message"] = lastUserMessage;
5000
5001
  // Show a truncated preview of the user message as an accessory
5001
5002
  const preview = lastUserMessage.length > 80
@@ -5006,7 +5007,7 @@ function chatAgent(options) {
5006
5007
  style: "codepath",
5007
5008
  }));
5008
5009
  }
5009
- if (wireMetadata !== undefined) {
5010
+ if (wireMetadata !== undefined && recordClientData) {
5010
5011
  turnAttributes["chat.client_data"] =
5011
5012
  typeof wireMetadata === "string" ? wireMetadata : JSON.stringify(wireMetadata);
5012
5013
  }
@@ -5031,6 +5032,7 @@ function chatAgent(options) {
5031
5032
  turn,
5032
5033
  continuation,
5033
5034
  clientData,
5035
+ recordUserMessage,
5034
5036
  });
5035
5037
  // Resolve the per-turn `tools` set now that turn context
5036
5038
  // (incl. parsed clientData) exists, so every toModelMessages