@trigger.dev/sdk 0.0.0-python-preview-20250226140121 → 0.0.0-rc-4-8-0-20261021151928
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/README.md +29 -9
- package/dist/commonjs/imports/ai-runtime-cjs.cjs.map +1 -0
- package/dist/commonjs/imports/ai-runtime.d.ts +1 -0
- package/dist/commonjs/imports/ai-runtime.js +31 -0
- package/dist/commonjs/imports/uncrypto.js +4 -4
- package/dist/commonjs/package.json +2 -1
- package/dist/commonjs/v3/agentSkillsRuntime.d.ts +28 -0
- package/dist/commonjs/v3/agentSkillsRuntime.js +173 -0
- package/dist/commonjs/v3/agentSkillsRuntime.js.map +1 -0
- package/dist/commonjs/v3/ai-shared.d.ts +156 -0
- package/dist/commonjs/v3/ai-shared.js +215 -0
- package/dist/commonjs/v3/ai-shared.js.map +1 -0
- package/dist/commonjs/v3/ai.d.ts +4225 -0
- package/dist/commonjs/v3/ai.js +11569 -0
- package/dist/commonjs/v3/ai.js.map +1 -0
- package/dist/commonjs/v3/aiAutoTelemetry.d.ts +2 -0
- package/dist/commonjs/v3/aiAutoTelemetry.js +81 -0
- package/dist/commonjs/v3/aiAutoTelemetry.js.map +1 -0
- package/dist/commonjs/v3/auth.d.ts +71 -10
- package/dist/commonjs/v3/auth.js +85 -19
- package/dist/commonjs/v3/auth.js.map +1 -1
- package/dist/commonjs/v3/batch.d.ts +3 -3
- package/dist/commonjs/v3/batch.js.map +1 -1
- package/dist/commonjs/v3/cache.js.map +1 -1
- package/dist/commonjs/v3/chat-client.d.ts +324 -0
- package/dist/commonjs/v3/chat-client.js +774 -0
- package/dist/commonjs/v3/chat-client.js.map +1 -0
- package/dist/commonjs/v3/chat-react.d.ts +244 -0
- package/dist/commonjs/v3/chat-react.js +463 -0
- package/dist/commonjs/v3/chat-react.js.map +1 -0
- package/dist/commonjs/v3/chat-server.d.ts +350 -0
- package/dist/commonjs/v3/chat-server.js +965 -0
- package/dist/commonjs/v3/chat-server.js.map +1 -0
- package/dist/commonjs/v3/chat-tab-coordinator.d.ts +65 -0
- package/dist/commonjs/v3/chat-tab-coordinator.js +235 -0
- package/dist/commonjs/v3/chat-tab-coordinator.js.map +1 -0
- package/dist/commonjs/v3/chat.d.ts +792 -0
- package/dist/commonjs/v3/chat.js +1662 -0
- package/dist/commonjs/v3/chat.js.map +1 -0
- package/dist/commonjs/v3/chatRouteWait.d.ts +21 -0
- package/dist/commonjs/v3/chatRouteWait.js +43 -0
- package/dist/commonjs/v3/chatRouteWait.js.map +1 -0
- 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/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 +103 -0
- package/dist/commonjs/v3/concurrencyLimits.js +134 -0
- package/dist/commonjs/v3/concurrencyLimits.js.map +1 -0
- package/dist/commonjs/v3/config.js.map +1 -1
- package/dist/commonjs/v3/deployments.d.ts +25 -0
- package/dist/commonjs/v3/deployments.js +37 -0
- package/dist/commonjs/v3/deployments.js.map +1 -0
- package/dist/commonjs/v3/envvars.d.ts +5 -5
- package/dist/commonjs/v3/envvars.js.map +1 -1
- 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/heartbeats.d.ts +37 -0
- package/dist/commonjs/v3/heartbeats.js +45 -0
- package/dist/commonjs/v3/heartbeats.js.map +1 -0
- package/dist/commonjs/v3/hooks.d.ts +26 -0
- package/dist/commonjs/v3/hooks.js +79 -0
- package/dist/commonjs/v3/hooks.js.map +1 -0
- package/dist/commonjs/v3/idempotencyKeys.d.ts +2 -1
- package/dist/commonjs/v3/idempotencyKeys.js +1 -0
- package/dist/commonjs/v3/idempotencyKeys.js.map +1 -1
- package/dist/commonjs/v3/index.d.ts +20 -5
- package/dist/commonjs/v3/index.js +56 -20
- package/dist/commonjs/v3/index.js.map +1 -1
- package/dist/commonjs/v3/locals.d.ts +3 -0
- package/dist/commonjs/v3/locals.js +6 -0
- package/dist/commonjs/v3/locals.js.map +1 -0
- package/dist/commonjs/v3/managedChatResponse.d.ts +44 -0
- package/dist/commonjs/v3/managedChatResponse.js +221 -0
- package/dist/commonjs/v3/managedChatResponse.js.map +1 -0
- package/dist/commonjs/v3/metadata.d.ts +5 -2
- package/dist/commonjs/v3/metadata.js +8 -1
- package/dist/commonjs/v3/metadata.js.map +1 -1
- package/dist/commonjs/v3/modelFileDownload.d.ts +10 -0
- package/dist/commonjs/v3/modelFileDownload.js +164 -0
- package/dist/commonjs/v3/modelFileDownload.js.map +1 -0
- package/dist/commonjs/v3/otel.d.ts +4 -0
- package/dist/commonjs/v3/otel.js +12 -0
- package/dist/commonjs/v3/otel.js.map +1 -0
- package/dist/commonjs/v3/prompt.d.ts +38 -0
- package/dist/commonjs/v3/prompt.js +146 -0
- package/dist/commonjs/v3/prompt.js.map +1 -0
- package/dist/commonjs/v3/promptManagement.d.ts +26 -0
- package/dist/commonjs/v3/promptManagement.js +180 -0
- package/dist/commonjs/v3/promptManagement.js.map +1 -0
- package/dist/commonjs/v3/prompts.d.ts +3 -0
- package/dist/commonjs/v3/prompts.js +15 -0
- package/dist/commonjs/v3/prompts.js.map +1 -0
- package/dist/commonjs/v3/query.d.ts +545 -0
- package/dist/commonjs/v3/query.js +163 -0
- package/dist/commonjs/v3/query.js.map +1 -0
- package/dist/commonjs/v3/queues.d.ts +107 -0
- package/dist/commonjs/v3/queues.js +225 -0
- package/dist/commonjs/v3/queues.js.map +1 -0
- package/dist/commonjs/v3/retry.d.ts +6 -2
- package/dist/commonjs/v3/retry.js +34 -23
- package/dist/commonjs/v3/retry.js.map +1 -1
- package/dist/commonjs/v3/runs.d.ts +182 -101
- package/dist/commonjs/v3/runs.js +99 -5
- package/dist/commonjs/v3/runs.js.map +1 -1
- package/dist/commonjs/v3/schedules/api.d.ts +8 -1
- package/dist/commonjs/v3/schedules/index.d.ts +29 -9
- package/dist/commonjs/v3/schedules/index.js +5 -1
- package/dist/commonjs/v3/schedules/index.js.map +1 -1
- package/dist/commonjs/v3/schemas.d.ts +1 -0
- package/dist/commonjs/{integrations.js → v3/schemas.js} +1 -1
- package/dist/commonjs/v3/schemas.js.map +1 -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.d.ts +268 -0
- package/dist/commonjs/v3/sessions.js +776 -0
- package/dist/commonjs/v3/sessions.js.map +1 -0
- package/dist/commonjs/v3/shared.d.ts +129 -24
- package/dist/commonjs/v3/shared.js +1527 -689
- package/dist/commonjs/v3/shared.js.map +1 -1
- package/dist/commonjs/v3/skill.d.ts +99 -0
- package/dist/commonjs/v3/skill.js +165 -0
- package/dist/commonjs/v3/skill.js.map +1 -0
- package/dist/commonjs/v3/skills.d.ts +2 -0
- package/dist/commonjs/v3/skills.js +6 -0
- package/dist/commonjs/v3/skills.js.map +1 -0
- 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/streams.d.ts +298 -0
- package/dist/commonjs/v3/streams.js +584 -0
- package/dist/commonjs/v3/streams.js.map +1 -0
- package/dist/commonjs/v3/tasks.d.ts +19 -4
- package/dist/commonjs/v3/tasks.js +15 -1
- package/dist/commonjs/v3/tasks.js.map +1 -1
- package/dist/commonjs/v3/test/index.d.ts +5 -0
- package/dist/commonjs/v3/test/index.js +23 -0
- package/dist/commonjs/v3/test/index.js.map +1 -0
- package/dist/commonjs/v3/test/mock-channel-connector.d.ts +172 -0
- package/dist/commonjs/v3/test/mock-channel-connector.js +173 -0
- package/dist/commonjs/v3/test/mock-channel-connector.js.map +1 -0
- package/dist/commonjs/v3/test/mock-chat-agent.d.ts +388 -0
- package/dist/commonjs/v3/test/mock-chat-agent.js +689 -0
- package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -0
- package/dist/commonjs/v3/test/setup-catalog.d.ts +1 -0
- package/dist/commonjs/v3/test/setup-catalog.js +18 -0
- package/dist/commonjs/v3/test/setup-catalog.js.map +1 -0
- package/dist/commonjs/v3/test/test-session-handle.d.ts +24 -0
- package/dist/commonjs/v3/test/test-session-handle.js +271 -0
- package/dist/commonjs/v3/test/test-session-handle.js.map +1 -0
- 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/toolResultOrder.d.ts +15 -0
- package/dist/commonjs/v3/toolResultOrder.js +58 -0
- package/dist/commonjs/v3/toolResultOrder.js.map +1 -0
- package/dist/commonjs/v3/transcriptStorage.d.ts +307 -0
- package/dist/commonjs/v3/transcriptStorage.js +445 -0
- package/dist/commonjs/v3/transcriptStorage.js.map +1 -0
- package/dist/commonjs/v3/triggerClient.d.ts +45 -0
- package/dist/commonjs/v3/triggerClient.js +114 -0
- package/dist/commonjs/v3/triggerClient.js.map +1 -0
- package/dist/commonjs/v3/uiMessageChunks.d.ts +1 -0
- package/dist/commonjs/v3/uiMessageChunks.js +119 -0
- package/dist/commonjs/v3/uiMessageChunks.js.map +1 -0
- package/dist/commonjs/v3/usage.js +7 -6
- package/dist/commonjs/v3/usage.js.map +1 -1
- package/dist/commonjs/v3/wait.d.ts +218 -3
- package/dist/commonjs/v3/wait.js +433 -7
- package/dist/commonjs/v3/wait.js.map +1 -1
- package/dist/commonjs/v3/waitUntil.js.map +1 -1
- package/dist/commonjs/v3/webhookWaiters.d.ts +80 -0
- package/dist/commonjs/v3/webhookWaiters.js +156 -0
- package/dist/commonjs/v3/webhookWaiters.js.map +1 -0
- package/dist/commonjs/v3/webhooks.d.ts +192 -2
- package/dist/commonjs/v3/webhooks.js +340 -2
- package/dist/commonjs/v3/webhooks.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/imports/ai-runtime.d.ts +2 -0
- package/dist/esm/imports/ai-runtime.js +16 -0
- package/dist/esm/imports/ai-runtime.js.map +1 -0
- package/dist/esm/package.json +2 -1
- package/dist/esm/v3/agentSkillsRuntime.d.ts +28 -0
- package/dist/esm/v3/agentSkillsRuntime.js +136 -0
- package/dist/esm/v3/agentSkillsRuntime.js.map +1 -0
- package/dist/esm/v3/ai-shared.d.ts +156 -0
- package/dist/esm/v3/ai-shared.js +208 -0
- package/dist/esm/v3/ai-shared.js.map +1 -0
- package/dist/esm/v3/ai.d.ts +4225 -0
- package/dist/esm/v3/ai.js +11550 -0
- package/dist/esm/v3/ai.js.map +1 -0
- package/dist/esm/v3/aiAutoTelemetry.d.ts +2 -0
- package/dist/esm/v3/aiAutoTelemetry.js +78 -0
- package/dist/esm/v3/aiAutoTelemetry.js.map +1 -0
- package/dist/esm/v3/auth.d.ts +71 -10
- package/dist/esm/v3/auth.js +83 -17
- package/dist/esm/v3/auth.js.map +1 -1
- package/dist/esm/v3/batch.d.ts +3 -3
- package/dist/esm/v3/batch.js +2 -2
- package/dist/esm/v3/batch.js.map +1 -1
- package/dist/esm/v3/chat-client.d.ts +324 -0
- package/dist/esm/v3/chat-client.js +769 -0
- package/dist/esm/v3/chat-client.js.map +1 -0
- package/dist/esm/v3/chat-react.d.ts +244 -0
- package/dist/esm/v3/chat-react.js +455 -0
- package/dist/esm/v3/chat-react.js.map +1 -0
- package/dist/esm/v3/chat-server.d.ts +350 -0
- package/dist/esm/v3/chat-server.js +962 -0
- package/dist/esm/v3/chat-server.js.map +1 -0
- package/dist/esm/v3/chat-tab-coordinator.d.ts +65 -0
- package/dist/esm/v3/chat-tab-coordinator.js +231 -0
- package/dist/esm/v3/chat-tab-coordinator.js.map +1 -0
- package/dist/esm/v3/chat.d.ts +792 -0
- package/dist/esm/v3/chat.js +1655 -0
- package/dist/esm/v3/chat.js.map +1 -0
- package/dist/esm/v3/chatRouteWait.d.ts +21 -0
- package/dist/esm/v3/chatRouteWait.js +40 -0
- package/dist/esm/v3/chatRouteWait.js.map +1 -0
- 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/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 +103 -0
- package/dist/esm/v3/concurrencyLimits.js +126 -0
- package/dist/esm/v3/concurrencyLimits.js.map +1 -0
- package/dist/esm/v3/deployments.d.ts +25 -0
- package/dist/esm/v3/deployments.js +34 -0
- package/dist/esm/v3/deployments.js.map +1 -0
- package/dist/esm/v3/envvars.d.ts +5 -5
- package/dist/esm/v3/envvars.js.map +1 -1
- 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/heartbeats.d.ts +37 -0
- package/dist/esm/v3/heartbeats.js +42 -0
- package/dist/esm/v3/heartbeats.js.map +1 -0
- package/dist/esm/v3/hooks.d.ts +26 -0
- package/dist/esm/v3/hooks.js +66 -0
- package/dist/esm/v3/hooks.js.map +1 -0
- package/dist/esm/v3/idempotencyKeys.d.ts +2 -1
- package/dist/esm/v3/idempotencyKeys.js +2 -1
- package/dist/esm/v3/idempotencyKeys.js.map +1 -1
- package/dist/esm/v3/index.d.ts +20 -5
- package/dist/esm/v3/index.js +16 -2
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/esm/v3/locals.d.ts +3 -0
- package/dist/esm/v3/locals.js +3 -0
- package/dist/esm/v3/locals.js.map +1 -0
- package/dist/esm/v3/managedChatResponse.d.ts +44 -0
- package/dist/esm/v3/managedChatResponse.js +216 -0
- package/dist/esm/v3/managedChatResponse.js.map +1 -0
- package/dist/esm/v3/metadata.d.ts +5 -2
- package/dist/esm/v3/metadata.js +8 -1
- package/dist/esm/v3/metadata.js.map +1 -1
- package/dist/esm/v3/modelFileDownload.d.ts +10 -0
- package/dist/esm/v3/modelFileDownload.js +161 -0
- package/dist/esm/v3/modelFileDownload.js.map +1 -0
- package/dist/esm/v3/otel.d.ts +4 -0
- package/dist/esm/v3/otel.js +9 -0
- package/dist/esm/v3/otel.js.map +1 -0
- package/dist/esm/v3/prompt.d.ts +38 -0
- package/dist/esm/v3/prompt.js +143 -0
- package/dist/esm/v3/prompt.js.map +1 -0
- package/dist/esm/v3/promptManagement.d.ts +26 -0
- package/dist/esm/v3/promptManagement.js +170 -0
- package/dist/esm/v3/promptManagement.js.map +1 -0
- package/dist/esm/v3/prompts.d.ts +3 -0
- package/dist/esm/v3/prompts.js +3 -0
- package/dist/esm/v3/prompts.js.map +1 -0
- package/dist/esm/v3/query.d.ts +545 -0
- package/dist/esm/v3/query.js +160 -0
- package/dist/esm/v3/query.js.map +1 -0
- package/dist/esm/v3/queues.d.ts +107 -0
- package/dist/esm/v3/queues.js +217 -0
- package/dist/esm/v3/queues.js.map +1 -0
- package/dist/esm/v3/retry.d.ts +6 -2
- package/dist/esm/v3/retry.js +27 -19
- package/dist/esm/v3/retry.js.map +1 -1
- package/dist/esm/v3/runs.d.ts +179 -98
- package/dist/esm/v3/runs.js +99 -5
- package/dist/esm/v3/runs.js.map +1 -1
- package/dist/esm/v3/schedules/api.d.ts +8 -1
- package/dist/esm/v3/schedules/index.d.ts +29 -9
- package/dist/esm/v3/schedules/index.js +6 -2
- package/dist/esm/v3/schedules/index.js.map +1 -1
- package/dist/esm/v3/schemas.d.ts +1 -0
- package/dist/esm/v3/schemas.js +2 -0
- package/dist/esm/v3/schemas.js.map +1 -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.d.ts +268 -0
- package/dist/esm/v3/sessions.js +767 -0
- package/dist/esm/v3/sessions.js.map +1 -0
- package/dist/esm/v3/shared.d.ts +129 -24
- package/dist/esm/v3/shared.js +1521 -688
- package/dist/esm/v3/shared.js.map +1 -1
- package/dist/esm/v3/skill.d.ts +99 -0
- package/dist/esm/v3/skill.js +128 -0
- package/dist/esm/v3/skill.js.map +1 -0
- package/dist/esm/v3/skills.d.ts +2 -0
- package/dist/esm/v3/skills.js +2 -0
- package/dist/esm/v3/skills.js.map +1 -0
- 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/streams.d.ts +298 -0
- package/dist/esm/v3/streams.js +580 -0
- package/dist/esm/v3/streams.js.map +1 -0
- package/dist/esm/v3/tasks.d.ts +19 -4
- package/dist/esm/v3/tasks.js +16 -2
- package/dist/esm/v3/tasks.js.map +1 -1
- package/dist/esm/v3/test/index.d.ts +5 -0
- package/dist/esm/v3/test/index.js +15 -0
- package/dist/esm/v3/test/index.js.map +1 -0
- package/dist/esm/v3/test/mock-channel-connector.d.ts +172 -0
- package/dist/esm/v3/test/mock-channel-connector.js +170 -0
- package/dist/esm/v3/test/mock-channel-connector.js.map +1 -0
- package/dist/esm/v3/test/mock-chat-agent.d.ts +388 -0
- package/dist/esm/v3/test/mock-chat-agent.js +685 -0
- package/dist/esm/v3/test/mock-chat-agent.js.map +1 -0
- package/dist/esm/v3/test/setup-catalog.d.ts +1 -0
- package/dist/esm/v3/test/setup-catalog.js +16 -0
- package/dist/esm/v3/test/setup-catalog.js.map +1 -0
- package/dist/esm/v3/test/test-session-handle.d.ts +24 -0
- package/dist/esm/v3/test/test-session-handle.js +268 -0
- package/dist/esm/v3/test/test-session-handle.js.map +1 -0
- 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/toolResultOrder.d.ts +15 -0
- package/dist/esm/v3/toolResultOrder.js +55 -0
- package/dist/esm/v3/toolResultOrder.js.map +1 -0
- package/dist/esm/v3/transcriptStorage.d.ts +307 -0
- package/dist/esm/v3/transcriptStorage.js +431 -0
- package/dist/esm/v3/transcriptStorage.js.map +1 -0
- package/dist/esm/v3/triggerClient.d.ts +45 -0
- package/dist/esm/v3/triggerClient.js +77 -0
- package/dist/esm/v3/triggerClient.js.map +1 -0
- package/dist/esm/v3/uiMessageChunks.d.ts +1 -0
- package/dist/esm/v3/uiMessageChunks.js +116 -0
- package/dist/esm/v3/uiMessageChunks.js.map +1 -0
- package/dist/esm/v3/usage.js +7 -6
- package/dist/esm/v3/usage.js.map +1 -1
- package/dist/esm/v3/wait.d.ts +218 -3
- package/dist/esm/v3/wait.js +431 -7
- package/dist/esm/v3/wait.js.map +1 -1
- package/dist/esm/v3/webhookWaiters.d.ts +80 -0
- package/dist/esm/v3/webhookWaiters.js +149 -0
- package/dist/esm/v3/webhookWaiters.js.map +1 -0
- package/dist/esm/v3/webhooks.d.ts +192 -2
- package/dist/esm/v3/webhooks.js +336 -2
- package/dist/esm/v3/webhooks.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai/observability.mdx +174 -0
- package/docs/ai/prompts.mdx +426 -0
- package/docs/ai-chat/actions.mdx +148 -0
- package/docs/ai-chat/anatomy.mdx +87 -0
- package/docs/ai-chat/backend.mdx +933 -0
- package/docs/ai-chat/background-injection.mdx +320 -0
- package/docs/ai-chat/changelog.mdx +958 -0
- package/docs/ai-chat/chat-local.mdx +170 -0
- package/docs/ai-chat/client-protocol.mdx +1091 -0
- package/docs/ai-chat/compaction.mdx +413 -0
- package/docs/ai-chat/custom-agents.mdx +545 -0
- package/docs/ai-chat/error-handling.mdx +379 -0
- package/docs/ai-chat/fast-starts.mdx +764 -0
- package/docs/ai-chat/frontend.mdx +634 -0
- package/docs/ai-chat/how-it-works.mdx +226 -0
- package/docs/ai-chat/lifecycle-hooks.mdx +532 -0
- package/docs/ai-chat/mcp.mdx +97 -0
- package/docs/ai-chat/migrating-from-a-route-handler.mdx +594 -0
- package/docs/ai-chat/migrating-from-hydrate-messages.mdx +299 -0
- package/docs/ai-chat/overview.mdx +86 -0
- package/docs/ai-chat/patterns/branching-conversations.mdx +145 -0
- package/docs/ai-chat/patterns/code-sandbox.mdx +122 -0
- package/docs/ai-chat/patterns/database-persistence.mdx +425 -0
- package/docs/ai-chat/patterns/human-in-the-loop.mdx +281 -0
- package/docs/ai-chat/patterns/large-payloads.mdx +165 -0
- package/docs/ai-chat/patterns/native-compaction.mdx +310 -0
- package/docs/ai-chat/patterns/oom-resilience.mdx +116 -0
- package/docs/ai-chat/patterns/persistence-and-replay.mdx +218 -0
- package/docs/ai-chat/patterns/recovery-boot.mdx +233 -0
- package/docs/ai-chat/patterns/redacting-telemetry.mdx +117 -0
- package/docs/ai-chat/patterns/skills.mdx +214 -0
- package/docs/ai-chat/patterns/sub-agents.mdx +412 -0
- package/docs/ai-chat/patterns/tool-result-auditing.mdx +145 -0
- package/docs/ai-chat/patterns/trusted-edge-signals.mdx +333 -0
- package/docs/ai-chat/patterns/version-upgrades.mdx +261 -0
- package/docs/ai-chat/pending-messages.mdx +363 -0
- package/docs/ai-chat/prompt-caching.mdx +204 -0
- package/docs/ai-chat/quick-start.mdx +163 -0
- package/docs/ai-chat/reference.mdx +1071 -0
- package/docs/ai-chat/server-chat.mdx +259 -0
- package/docs/ai-chat/sessions.mdx +334 -0
- package/docs/ai-chat/side-channels.mdx +172 -0
- package/docs/ai-chat/testing.mdx +691 -0
- package/docs/ai-chat/tools.mdx +192 -0
- package/docs/ai-chat/transcript-storage.mdx +247 -0
- package/docs/ai-chat/types.mdx +242 -0
- package/docs/ai-chat/upgrade-guide.mdx +511 -0
- package/docs/apikeys.mdx +170 -0
- package/docs/billing-limits.mdx +73 -0
- package/docs/building-with-ai.mdx +261 -0
- package/docs/bulk-actions.mdx +77 -0
- package/docs/changelog.mdx +6 -0
- package/docs/cli-deploy-commands.mdx +9 -0
- package/docs/cli-dev-commands.mdx +9 -0
- package/docs/cli-env-commands.mdx +115 -0
- package/docs/cli-init-commands.mdx +84 -0
- package/docs/cli-introduction.mdx +25 -0
- package/docs/cli-list-profiles-commands.mdx +42 -0
- package/docs/cli-login-commands.mdx +53 -0
- package/docs/cli-logout-commands.mdx +33 -0
- package/docs/cli-preview-archive.mdx +59 -0
- package/docs/cli-projects-commands.mdx +74 -0
- package/docs/cli-promote-commands.mdx +9 -0
- package/docs/cli-runs-commands.mdx +95 -0
- package/docs/cli-switch.mdx +43 -0
- package/docs/cli-tasks-commands.mdx +95 -0
- package/docs/cli-update-commands.mdx +48 -0
- package/docs/cli-whoami-commands.mdx +45 -0
- package/docs/community.mdx +6 -0
- package/docs/concurrency.mdx +416 -0
- package/docs/config/config-file.mdx +662 -0
- package/docs/config/extensions/additionalFiles.mdx +38 -0
- package/docs/config/extensions/additionalPackages.mdx +40 -0
- package/docs/config/extensions/aptGet.mdx +34 -0
- package/docs/config/extensions/audioWaveform.mdx +23 -0
- package/docs/config/extensions/custom.mdx +393 -0
- package/docs/config/extensions/emitDecoratorMetadata.mdx +52 -0
- package/docs/config/extensions/esbuildPlugin.mdx +31 -0
- package/docs/config/extensions/ffmpeg.mdx +45 -0
- package/docs/config/extensions/lightpanda.mdx +56 -0
- package/docs/config/extensions/overview.mdx +69 -0
- package/docs/config/extensions/playwright.mdx +195 -0
- package/docs/config/extensions/prismaExtension.mdx +1013 -0
- package/docs/config/extensions/puppeteer.mdx +28 -0
- package/docs/config/extensions/pythonExtension.mdx +190 -0
- package/docs/config/extensions/syncEnvVars.mdx +330 -0
- package/docs/context.mdx +235 -0
- package/docs/database-connections.mdx +213 -0
- package/docs/deploy-environment-variables.mdx +466 -0
- package/docs/deployment/atomic-deployment.mdx +470 -0
- package/docs/deployment/dev-branches.mdx +92 -0
- package/docs/deployment/overview.mdx +260 -0
- package/docs/deployment/preview-branches.mdx +227 -0
- package/docs/errors-retrying.mdx +383 -0
- package/docs/github-actions.mdx +260 -0
- package/docs/github-integration.mdx +148 -0
- package/docs/github-repo.mdx +8 -0
- package/docs/help-email.mdx +6 -0
- package/docs/help-slack.mdx +12 -0
- package/docs/hidden-tasks.mdx +56 -0
- package/docs/how-it-works.mdx +454 -0
- package/docs/how-to-reduce-your-spend.mdx +211 -0
- package/docs/idempotency.mdx +542 -0
- package/docs/introduction.mdx +135 -0
- package/docs/limits.mdx +284 -0
- package/docs/logging.mdx +195 -0
- package/docs/machines.mdx +952 -0
- package/docs/manual-setup.mdx +632 -0
- package/docs/mcp-agent-rules.mdx +41 -0
- package/docs/mcp-introduction.mdx +386 -0
- package/docs/mcp-tools.mdx +425 -0
- package/docs/migrating-from-v3.mdx +332 -0
- package/docs/observability/dashboards.mdx +166 -0
- package/docs/observability/query.mdx +614 -0
- package/docs/open-source-contributing.mdx +16 -0
- package/docs/private-networking/aws-console-setup.mdx +304 -0
- package/docs/private-networking/overview.mdx +144 -0
- package/docs/private-networking/troubleshooting.mdx +78 -0
- package/docs/queues.mdx +271 -0
- package/docs/quick-start.mdx +60 -0
- package/docs/realtime/auth.mdx +228 -0
- package/docs/realtime/backend/input-streams.mdx +159 -0
- package/docs/realtime/backend/overview.mdx +45 -0
- package/docs/realtime/backend/streams.mdx +433 -0
- package/docs/realtime/backend/subscribe.mdx +225 -0
- package/docs/realtime/how-it-works.mdx +94 -0
- package/docs/realtime/overview.mdx +63 -0
- package/docs/realtime/react-hooks/overview.mdx +73 -0
- package/docs/realtime/react-hooks/session-stream.mdx +126 -0
- package/docs/realtime/react-hooks/streams.mdx +517 -0
- package/docs/realtime/react-hooks/subscribe.mdx +690 -0
- package/docs/realtime/react-hooks/swr.mdx +87 -0
- package/docs/realtime/react-hooks/triggering.mdx +194 -0
- package/docs/realtime/react-hooks/use-wait-token.mdx +34 -0
- package/docs/realtime/run-object.mdx +197 -0
- package/docs/replaying.mdx +97 -0
- package/docs/reports.mdx +159 -0
- package/docs/request-feature.mdx +6 -0
- package/docs/roadmap.mdx +6 -0
- package/docs/run-tests.mdx +21 -0
- package/docs/run-usage.mdx +113 -0
- package/docs/runs/bulk-actions.mdx +183 -0
- package/docs/runs/heartbeats.mdx +38 -0
- package/docs/runs/list-best-practices.mdx +234 -0
- package/docs/runs/max-duration.mdx +143 -0
- package/docs/runs/metadata.mdx +731 -0
- package/docs/runs/priority.mdx +8 -0
- package/docs/runs.mdx +406 -0
- package/docs/self-hosting/docker.mdx +512 -0
- package/docs/self-hosting/env/supervisor.mdx +78 -0
- package/docs/self-hosting/env/webapp.mdx +305 -0
- package/docs/self-hosting/kubernetes.mdx +725 -0
- package/docs/self-hosting/overview.mdx +145 -0
- package/docs/self-hosting/security.mdx +67 -0
- package/docs/skills.mdx +85 -0
- package/docs/tags.mdx +126 -0
- package/docs/tasks/overview.mdx +695 -0
- package/docs/tasks/scheduled.mdx +479 -0
- package/docs/tasks/schemaTask.mdx +413 -0
- package/docs/tasks/streams.mdx +887 -0
- package/docs/triggering.mdx +1340 -0
- package/docs/troubleshooting-alerts.mdx +607 -0
- package/docs/troubleshooting-debugging-in-vscode.mdx +9 -0
- package/docs/troubleshooting-github-issues.mdx +6 -0
- package/docs/troubleshooting-uptime-status.mdx +7 -0
- package/docs/troubleshooting-zod.mdx +158 -0
- package/docs/troubleshooting.mdx +414 -0
- package/docs/upgrading-packages.mdx +80 -0
- package/docs/vercel-integration.mdx +250 -0
- package/docs/versioning.mdx +58 -0
- package/docs/video-walkthrough.mdx +23 -0
- package/docs/wait-for-token.mdx +540 -0
- package/docs/wait-for.mdx +42 -0
- package/docs/wait-until.mdx +53 -0
- package/docs/wait.mdx +18 -0
- package/docs/webhooks/channels.mdx +154 -0
- package/docs/webhooks/connect.mdx +91 -0
- package/docs/webhooks/deliveries.mdx +99 -0
- package/docs/webhooks/filters.mdx +146 -0
- package/docs/webhooks/human-in-the-loop.mdx +158 -0
- package/docs/webhooks/linear.mdx +186 -0
- package/docs/webhooks/overview.mdx +115 -0
- package/docs/webhooks/session-routing.mdx +141 -0
- package/docs/webhooks/slack.mdx +393 -0
- package/docs/webhooks/sources.mdx +250 -0
- package/docs/webhooks/waiters.mdx +190 -0
- package/docs/writing-tasks-introduction.mdx +34 -0
- package/package.json +143 -42
- package/skills/trigger-authoring-chat-agent/SKILL.md +308 -0
- package/skills/trigger-authoring-tasks/SKILL.md +254 -0
- package/skills/trigger-chat-agent-advanced/SKILL.md +403 -0
- package/skills/trigger-cost-savings/SKILL.md +116 -0
- package/skills/trigger-realtime-and-frontend/SKILL.md +276 -0
- package/dist/commonjs/apiClient.d.ts +0 -727
- package/dist/commonjs/apiClient.js +0 -692
- package/dist/commonjs/apiClient.js.map +0 -1
- package/dist/commonjs/concurrencyLimit.d.ts +0 -10
- package/dist/commonjs/concurrencyLimit.js +0 -17
- package/dist/commonjs/concurrencyLimit.js.map +0 -1
- package/dist/commonjs/errors.d.ts +0 -66
- package/dist/commonjs/errors.js +0 -109
- package/dist/commonjs/errors.js.map +0 -1
- package/dist/commonjs/httpEndpoint.d.ts +0 -87
- package/dist/commonjs/httpEndpoint.js +0 -130
- package/dist/commonjs/httpEndpoint.js.map +0 -1
- package/dist/commonjs/index.d.ts +0 -23
- package/dist/commonjs/index.js +0 -55
- package/dist/commonjs/index.js.map +0 -1
- package/dist/commonjs/integrations.d.ts +0 -11
- package/dist/commonjs/integrations.js.map +0 -1
- package/dist/commonjs/io.d.ts +0 -441
- package/dist/commonjs/io.js +0 -1165
- package/dist/commonjs/io.js.map +0 -1
- package/dist/commonjs/ioWithIntegrations.d.ts +0 -4
- package/dist/commonjs/ioWithIntegrations.js +0 -32
- package/dist/commonjs/ioWithIntegrations.js.map +0 -1
- package/dist/commonjs/job.d.ts +0 -96
- package/dist/commonjs/job.js +0 -210
- package/dist/commonjs/job.js.map +0 -1
- package/dist/commonjs/retry.d.ts +0 -20
- package/dist/commonjs/retry.js +0 -22
- package/dist/commonjs/retry.js.map +0 -1
- package/dist/commonjs/runLocalStorage.d.ts +0 -8
- package/dist/commonjs/runLocalStorage.js +0 -6
- package/dist/commonjs/runLocalStorage.js.map +0 -1
- package/dist/commonjs/security.d.ts +0 -18
- package/dist/commonjs/security.js +0 -41
- package/dist/commonjs/security.js.map +0 -1
- package/dist/commonjs/status.d.ts +0 -19
- package/dist/commonjs/status.js +0 -38
- package/dist/commonjs/status.js.map +0 -1
- package/dist/commonjs/store/keyValueStore.d.ts +0 -17
- package/dist/commonjs/store/keyValueStore.js +0 -138
- package/dist/commonjs/store/keyValueStore.js.map +0 -1
- package/dist/commonjs/store/keyValueStoreClient.d.ts +0 -19
- package/dist/commonjs/store/keyValueStoreClient.js +0 -65
- package/dist/commonjs/store/keyValueStoreClient.js.map +0 -1
- package/dist/commonjs/triggerClient.d.ts +0 -290
- package/dist/commonjs/triggerClient.js +0 -1366
- package/dist/commonjs/triggerClient.js.map +0 -1
- package/dist/commonjs/triggers/dynamic.d.ts +0 -56
- package/dist/commonjs/triggers/dynamic.js +0 -97
- package/dist/commonjs/triggers/dynamic.js.map +0 -1
- package/dist/commonjs/triggers/eventTrigger.d.ts +0 -58
- package/dist/commonjs/triggers/eventTrigger.js +0 -69
- package/dist/commonjs/triggers/eventTrigger.js.map +0 -1
- package/dist/commonjs/triggers/externalSource.d.ts +0 -148
- package/dist/commonjs/triggers/externalSource.js +0 -106
- package/dist/commonjs/triggers/externalSource.js.map +0 -1
- package/dist/commonjs/triggers/invokeTrigger.d.ts +0 -39
- package/dist/commonjs/triggers/invokeTrigger.js +0 -58
- package/dist/commonjs/triggers/invokeTrigger.js.map +0 -1
- package/dist/commonjs/triggers/notifications.d.ts +0 -111
- package/dist/commonjs/triggers/notifications.js +0 -101
- package/dist/commonjs/triggers/notifications.js.map +0 -1
- package/dist/commonjs/triggers/scheduled.d.ts +0 -145
- package/dist/commonjs/triggers/scheduled.js +0 -208
- package/dist/commonjs/triggers/scheduled.js.map +0 -1
- package/dist/commonjs/triggers/webhook.d.ts +0 -143
- package/dist/commonjs/triggers/webhook.js +0 -133
- package/dist/commonjs/triggers/webhook.js.map +0 -1
- package/dist/commonjs/typed-emitter.d.ts +0 -37
- package/dist/commonjs/typed-emitter.js +0 -3
- package/dist/commonjs/typed-emitter.js.map +0 -1
- package/dist/commonjs/types.d.ts +0 -204
- package/dist/commonjs/types.js +0 -23
- package/dist/commonjs/types.js.map +0 -1
- package/dist/commonjs/utils/formatSchemaErrors.d.ts +0 -3
- package/dist/commonjs/utils/formatSchemaErrors.js +0 -10
- package/dist/commonjs/utils/formatSchemaErrors.js.map +0 -1
- package/dist/commonjs/utils/typedAsyncLocalStorage.d.ts +0 -6
- package/dist/commonjs/utils/typedAsyncLocalStorage.js +0 -18
- package/dist/commonjs/utils/typedAsyncLocalStorage.js.map +0 -1
- package/dist/commonjs/utils.d.ts +0 -1
- package/dist/commonjs/utils.js +0 -11
- package/dist/commonjs/utils.js.map +0 -1
- package/dist/esm/apiClient.d.ts +0 -727
- package/dist/esm/apiClient.js +0 -687
- package/dist/esm/apiClient.js.map +0 -1
- package/dist/esm/concurrencyLimit.d.ts +0 -10
- package/dist/esm/concurrencyLimit.js +0 -13
- package/dist/esm/concurrencyLimit.js.map +0 -1
- package/dist/esm/errors.d.ts +0 -66
- package/dist/esm/errors.js +0 -95
- package/dist/esm/errors.js.map +0 -1
- package/dist/esm/httpEndpoint.d.ts +0 -87
- package/dist/esm/httpEndpoint.js +0 -125
- package/dist/esm/httpEndpoint.js.map +0 -1
- package/dist/esm/index.d.ts +0 -23
- package/dist/esm/index.js +0 -35
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/integrations.d.ts +0 -11
- package/dist/esm/integrations.js +0 -2
- package/dist/esm/integrations.js.map +0 -1
- package/dist/esm/io.d.ts +0 -441
- package/dist/esm/io.js +0 -1159
- package/dist/esm/io.js.map +0 -1
- package/dist/esm/ioWithIntegrations.d.ts +0 -4
- package/dist/esm/ioWithIntegrations.js +0 -29
- package/dist/esm/ioWithIntegrations.js.map +0 -1
- package/dist/esm/job.d.ts +0 -96
- package/dist/esm/job.js +0 -206
- package/dist/esm/job.js.map +0 -1
- package/dist/esm/retry.d.ts +0 -20
- package/dist/esm/retry.js +0 -19
- package/dist/esm/retry.js.map +0 -1
- package/dist/esm/runLocalStorage.d.ts +0 -8
- package/dist/esm/runLocalStorage.js +0 -3
- package/dist/esm/runLocalStorage.js.map +0 -1
- package/dist/esm/security.d.ts +0 -18
- package/dist/esm/security.js +0 -34
- package/dist/esm/security.js.map +0 -1
- package/dist/esm/status.d.ts +0 -19
- package/dist/esm/status.js +0 -34
- package/dist/esm/status.js.map +0 -1
- package/dist/esm/store/keyValueStore.d.ts +0 -17
- package/dist/esm/store/keyValueStore.js +0 -134
- package/dist/esm/store/keyValueStore.js.map +0 -1
- package/dist/esm/store/keyValueStoreClient.d.ts +0 -19
- package/dist/esm/store/keyValueStoreClient.js +0 -61
- package/dist/esm/store/keyValueStoreClient.js.map +0 -1
- package/dist/esm/triggerClient.d.ts +0 -288
- package/dist/esm/triggerClient.js +0 -1359
- package/dist/esm/triggerClient.js.map +0 -1
- package/dist/esm/triggers/dynamic.d.ts +0 -56
- package/dist/esm/triggers/dynamic.js +0 -93
- package/dist/esm/triggers/dynamic.js.map +0 -1
- package/dist/esm/triggers/eventTrigger.d.ts +0 -58
- package/dist/esm/triggers/eventTrigger.js +0 -64
- package/dist/esm/triggers/eventTrigger.js.map +0 -1
- package/dist/esm/triggers/externalSource.d.ts +0 -148
- package/dist/esm/triggers/externalSource.js +0 -100
- package/dist/esm/triggers/externalSource.js.map +0 -1
- package/dist/esm/triggers/invokeTrigger.d.ts +0 -39
- package/dist/esm/triggers/invokeTrigger.js +0 -53
- package/dist/esm/triggers/invokeTrigger.js.map +0 -1
- package/dist/esm/triggers/notifications.d.ts +0 -111
- package/dist/esm/triggers/notifications.js +0 -94
- package/dist/esm/triggers/notifications.js.map +0 -1
- package/dist/esm/triggers/scheduled.d.ts +0 -145
- package/dist/esm/triggers/scheduled.js +0 -197
- package/dist/esm/triggers/scheduled.js.map +0 -1
- package/dist/esm/triggers/webhook.d.ts +0 -143
- package/dist/esm/triggers/webhook.js +0 -128
- package/dist/esm/triggers/webhook.js.map +0 -1
- package/dist/esm/typed-emitter.d.ts +0 -37
- package/dist/esm/typed-emitter.js +0 -2
- package/dist/esm/typed-emitter.js.map +0 -1
- package/dist/esm/types.d.ts +0 -204
- package/dist/esm/types.js +0 -19
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/utils/formatSchemaErrors.d.ts +0 -3
- package/dist/esm/utils/formatSchemaErrors.js +0 -7
- package/dist/esm/utils/formatSchemaErrors.js.map +0 -1
- package/dist/esm/utils/typedAsyncLocalStorage.d.ts +0 -6
- package/dist/esm/utils/typedAsyncLocalStorage.js +0 -14
- package/dist/esm/utils/typedAsyncLocalStorage.js.map +0 -1
- package/dist/esm/utils.d.ts +0 -1
- package/dist/esm/utils.js +0 -8
- package/dist/esm/utils.js.map +0 -1
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Idempotency"
|
|
3
|
+
description: "An API call or operation is idempotent if it has the same result when called more than once."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
**Idempotency keys deduplicate task triggers.** If you trigger a task with the same `idempotencyKey` twice, the second request does not create a new run. It returns the original run's handle, so you can track the existing run's progress.
|
|
7
|
+
|
|
8
|
+
The key applies to the trigger call and nothing else. It deduplicates `trigger()`, `triggerAndWait()`, and `batchTrigger()`; it does not make the code inside a task's `run()` function idempotent. See [Side effects inside `run()`](#side-effects-inside-run) for what that means when a task calls an external API.
|
|
9
|
+
|
|
10
|
+
## Why use idempotency keys?
|
|
11
|
+
|
|
12
|
+
The most common use case is **preventing duplicate child tasks when a parent task retries**. Without idempotency keys, each retry of the parent would trigger a new child task run:
|
|
13
|
+
|
|
14
|
+
```mermaid
|
|
15
|
+
sequenceDiagram
|
|
16
|
+
participant Parent as Parent Task
|
|
17
|
+
participant SDK as Trigger.dev
|
|
18
|
+
participant Child as Child Task
|
|
19
|
+
|
|
20
|
+
Note over Parent: Attempt 1
|
|
21
|
+
Parent->>SDK: trigger(childTask, {idempotencyKey})
|
|
22
|
+
SDK->>Child: Creates child run
|
|
23
|
+
Child-->>SDK: Running...
|
|
24
|
+
Parent->>Parent: Fails, will retry
|
|
25
|
+
|
|
26
|
+
Note over Parent: Attempt 2 (retry)
|
|
27
|
+
Parent->>SDK: trigger(childTask, {idempotencyKey})
|
|
28
|
+
Note over SDK: Same key, returns existing run
|
|
29
|
+
SDK-->>Parent: Returns original child run
|
|
30
|
+
|
|
31
|
+
Note over Child: Child task only runs once
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Other common use cases include:
|
|
35
|
+
|
|
36
|
+
- **Preventing duplicate emails** - Trigger the email task once, even if the parent task retries
|
|
37
|
+
- **Avoiding double-charging customers** - Trigger the payment task once, even if the parent task retries. The payment API call itself still needs the provider's own idempotency key, see [Side effects inside `run()`](#side-effects-inside-run)
|
|
38
|
+
- **One-time setup tasks** - Trigger initialization or migration tasks once
|
|
39
|
+
- **Deduplicating webhook processing** - Trigger the handler task once per webhook event, even if the event is delivered multiple times
|
|
40
|
+
|
|
41
|
+
## Side effects inside `run()`
|
|
42
|
+
|
|
43
|
+
An idempotency key stops a task from being *triggered* twice. It does not stop the code inside that task from *running* twice. When a run retries, `run()` executes again from the top, and every API call, database write, or email inside it happens again unless that operation is itself idempotent.
|
|
44
|
+
|
|
45
|
+
This matters most for payments. A refund issued directly inside a retryable task is issued again on every retry, even when the retry is caused by an unrelated failure later in the same function. Moving the refund into a child task and triggering it with an idempotency key does not close the gap either: the child is triggered once, but its own `run()` can retry after the provider has accepted the request. Only the provider can deduplicate its own API call.
|
|
46
|
+
|
|
47
|
+
Pass the provider's idempotency key on every call that must happen at most once. Derive it from a value that stays the same across every attempt of the run. The run ID, `ctx.run.id`, always qualifies: retries are attempts of the same run, so the ID does not change between them. This is the same value the default `run` scope mixes into a Trigger.dev idempotency key.
|
|
48
|
+
|
|
49
|
+
```ts /trigger/refund-order.ts
|
|
50
|
+
import { idempotencyKeys, task } from "@trigger.dev/sdk";
|
|
51
|
+
import Stripe from "stripe";
|
|
52
|
+
import { sendRefundEmail } from "./send-refund-email";
|
|
53
|
+
|
|
54
|
+
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
|
|
55
|
+
|
|
56
|
+
export const refundOrder = task({
|
|
57
|
+
id: "refund-order",
|
|
58
|
+
retry: { maxAttempts: 3 },
|
|
59
|
+
run: async (payload: { orderId: string; paymentIntentId: string; amount: number }, { ctx }) => {
|
|
60
|
+
// The run ID is stable across retries, so Stripe returns the original refund instead of creating a second one
|
|
61
|
+
await stripe.refunds.create(
|
|
62
|
+
{ payment_intent: payload.paymentIntentId, amount: payload.amount },
|
|
63
|
+
{ idempotencyKey: `refund-${ctx.run.id}` }
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// The Trigger.dev key is run-scoped by default, so a retry does not create a second email run
|
|
67
|
+
const idempotencyKey = await idempotencyKeys.create("refund-email");
|
|
68
|
+
await sendRefundEmail.trigger({ orderId: payload.orderId }, { idempotencyKey });
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The run ID protects against retries of one run. If the same task can be triggered more than once for the same order, either trigger it with a Trigger.dev idempotency key so repeated triggers resolve to the same run and the same run ID, or key the provider call on a business ID from your payload instead, such as `refund-${payload.orderId}`, which deduplicates across separate runs too.
|
|
74
|
+
|
|
75
|
+
Use a Trigger.dev idempotency key to stop a retry triggering a task twice, and the provider's idempotency key to stop a retry calling the provider twice. For a side effect with no idempotency support, record that you performed it in your own database and check that record before performing it again.
|
|
76
|
+
|
|
77
|
+
## `idempotencyKey` option
|
|
78
|
+
|
|
79
|
+
You can provide an `idempotencyKey` when triggering a task:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { idempotencyKeys, task } from "@trigger.dev/sdk";
|
|
83
|
+
|
|
84
|
+
export const myTask = task({
|
|
85
|
+
id: "my-task",
|
|
86
|
+
retry: {
|
|
87
|
+
maxAttempts: 4,
|
|
88
|
+
},
|
|
89
|
+
run: async (payload: any) => {
|
|
90
|
+
// This idempotency key will be unique to this task run, meaning the childTask will only be triggered once across all retries
|
|
91
|
+
const idempotencyKey = await idempotencyKeys.create("my-task-key");
|
|
92
|
+
|
|
93
|
+
// childTask will only be triggered once with the same idempotency key
|
|
94
|
+
await childTask.trigger({ foo: "bar" }, { idempotencyKey });
|
|
95
|
+
|
|
96
|
+
// Do something else, that may throw an error and cause the task to be retried
|
|
97
|
+
throw new Error("Something went wrong");
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
You can use the `idempotencyKeys.create` SDK function to create an idempotency key before passing it to the `options` object.
|
|
103
|
+
|
|
104
|
+
We automatically inject the run ID when generating the idempotency key when running inside a task by default. You can turn it off by passing the `scope` option to `idempotencyKeys.create`:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { idempotencyKeys, task } from "@trigger.dev/sdk";
|
|
108
|
+
|
|
109
|
+
export const myTask = task({
|
|
110
|
+
id: "my-task",
|
|
111
|
+
retry: {
|
|
112
|
+
maxAttempts: 4,
|
|
113
|
+
},
|
|
114
|
+
run: async (payload: any) => {
|
|
115
|
+
// This idempotency key will be globally unique, meaning only a single task run will be triggered with this key
|
|
116
|
+
const idempotencyKey = await idempotencyKeys.create("my-task-key", { scope: "global" });
|
|
117
|
+
|
|
118
|
+
// childTask will only be triggered once with the same idempotency key
|
|
119
|
+
await childTask.trigger({ foo: "bar" }, { idempotencyKey });
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
If you are triggering a task from your backend code, you can use the `idempotencyKeys.create` SDK function to create an idempotency key.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import { idempotencyKeys, tasks } from "@trigger.dev/sdk";
|
|
128
|
+
|
|
129
|
+
// You can also pass an array of strings to create a idempotency key
|
|
130
|
+
const idempotencyKey = await idempotencyKeys.create([myUser.id, "my-task"]);
|
|
131
|
+
await tasks.trigger("my-task", { some: "data" }, { idempotencyKey });
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
You can also pass a string to the `idempotencyKey` option, without first creating it with `idempotencyKeys.create`.
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
import { myTask } from "./trigger/myTasks";
|
|
138
|
+
|
|
139
|
+
// You can also pass an array of strings to create a idempotency key
|
|
140
|
+
await myTask.trigger({ some: "data" }, { idempotencyKey: myUser.id });
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
<Note>
|
|
144
|
+
When you pass a raw string, it defaults to `"run"` scope (scoped to the parent run). See [Default behavior](#default-behavior) for details on how scopes work and how to use global scope instead.
|
|
145
|
+
</Note>
|
|
146
|
+
|
|
147
|
+
<Note>Make sure you provide sufficiently unique keys to avoid collisions.</Note>
|
|
148
|
+
|
|
149
|
+
<Note>
|
|
150
|
+
Idempotency keys are limited to 2048 characters. Keys produced by `idempotencyKeys.create()` are 64-character hashes and always fit; this limit only matters if you pass a long raw string. Requests above the limit return `400`.
|
|
151
|
+
</Note>
|
|
152
|
+
|
|
153
|
+
You can pass the `idempotencyKey` when calling `batchTrigger` as well:
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import { tasks } from "@trigger.dev/sdk";
|
|
157
|
+
|
|
158
|
+
await tasks.batchTrigger("my-task", [
|
|
159
|
+
{
|
|
160
|
+
payload: { some: "data" },
|
|
161
|
+
options: { idempotencyKey: await idempotencyKeys.create(myUser.id) },
|
|
162
|
+
},
|
|
163
|
+
]);
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Understanding scopes
|
|
167
|
+
|
|
168
|
+
The `scope` option determines how your idempotency key is processed. When you provide a key, it gets hashed together with additional context based on the scope. This means the same key string can produce different idempotency behaviors depending on the scope you choose.
|
|
169
|
+
|
|
170
|
+
### Available scopes
|
|
171
|
+
|
|
172
|
+
| Scope | What gets hashed | Description | Use case |
|
|
173
|
+
| --- | --- | --- | --- |
|
|
174
|
+
| `"run"` | `key + parentRunId` | Key is combined with the parent run ID | Prevent duplicates within a single parent run (default) |
|
|
175
|
+
| `"attempt"` | `key + parentRunId + attemptNumber` | Key is combined with the parent run ID and attempt number | Allow child tasks to re-run on each retry of the parent |
|
|
176
|
+
| `"global"` | `key` | Key is used as-is, no context added | Ensure a task only runs once ever, regardless of parent |
|
|
177
|
+
|
|
178
|
+
### `run` scope (default)
|
|
179
|
+
|
|
180
|
+
The `run` scope makes the idempotency key unique to the current parent task run. This is the default behavior for both raw strings and `idempotencyKeys.create()`.
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
import { idempotencyKeys, task } from "@trigger.dev/sdk";
|
|
184
|
+
|
|
185
|
+
export const processOrder = task({
|
|
186
|
+
id: "process-order",
|
|
187
|
+
retry: { maxAttempts: 3 },
|
|
188
|
+
run: async (payload: { orderId: string; email: string }) => {
|
|
189
|
+
// This key is scoped to this specific run of processOrder
|
|
190
|
+
// If processOrder retries, the same key still refers to the same child run
|
|
191
|
+
const idempotencyKey = await idempotencyKeys.create(`send-confirmation-${payload.orderId}`);
|
|
192
|
+
|
|
193
|
+
// sendEmail will only be triggered once, even if processOrder retries multiple times
|
|
194
|
+
await sendEmail.trigger(
|
|
195
|
+
{ to: payload.email, subject: "Order confirmed" },
|
|
196
|
+
{ idempotencyKey }
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
// ... more processing that might fail and cause a retry
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
With `run` scope, if you trigger `processOrder` twice with different run IDs, both will send emails because the idempotency keys are different (they include different parent run IDs).
|
|
205
|
+
|
|
206
|
+
### `attempt` scope
|
|
207
|
+
|
|
208
|
+
The `attempt` scope makes the idempotency key unique to each attempt of the parent task. Use this when you want child tasks to re-execute on each retry.
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
import { idempotencyKeys, task } from "@trigger.dev/sdk";
|
|
212
|
+
|
|
213
|
+
export const syncData = task({
|
|
214
|
+
id: "sync-data",
|
|
215
|
+
retry: { maxAttempts: 3 },
|
|
216
|
+
run: async (payload: { userId: string }) => {
|
|
217
|
+
// This key changes on each retry attempt
|
|
218
|
+
const idempotencyKey = await idempotencyKeys.create(`fetch-${payload.userId}`, {
|
|
219
|
+
scope: "attempt",
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// fetchLatestData will run again on each retry, getting fresh data
|
|
223
|
+
const result = await fetchLatestData.triggerAndWait(
|
|
224
|
+
{ userId: payload.userId },
|
|
225
|
+
{ idempotencyKey }
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
// Process the fresh data...
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### `global` scope
|
|
234
|
+
|
|
235
|
+
The `global` scope makes the idempotency key truly global across all runs. Use this when you want to ensure a task only runs once ever (until the TTL expires), regardless of which parent task triggered it.
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
import { idempotencyKeys, task } from "@trigger.dev/sdk";
|
|
239
|
+
|
|
240
|
+
export const onboardUser = task({
|
|
241
|
+
id: "onboard-user",
|
|
242
|
+
run: async (payload: { userId: string; email: string }) => {
|
|
243
|
+
// This key is global - the welcome email will only be sent once per user,
|
|
244
|
+
// even if onboardUser is triggered multiple times from different places
|
|
245
|
+
const idempotencyKey = await idempotencyKeys.create(`welcome-email-${payload.userId}`, {
|
|
246
|
+
scope: "global",
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
await sendWelcomeEmail.trigger(
|
|
250
|
+
{ to: payload.email },
|
|
251
|
+
{ idempotencyKey, idempotencyKeyTTL: "7d" }
|
|
252
|
+
);
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
<Note>
|
|
258
|
+
Even with `global` scope, idempotency keys are still isolated to the specific task and environment. Using the same key to trigger *different* tasks will not deduplicate - both tasks will run. See [Environment and task scoping](#environment-and-task-scoping) for more details.
|
|
259
|
+
</Note>
|
|
260
|
+
|
|
261
|
+
## Default behavior
|
|
262
|
+
|
|
263
|
+
Understanding the default behavior is important to avoid unexpected results:
|
|
264
|
+
|
|
265
|
+
### Passing a raw string
|
|
266
|
+
|
|
267
|
+
When you pass a raw string directly to the `idempotencyKey` option, it is automatically processed with `run` scope:
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
// These two are equivalent when called inside a task:
|
|
271
|
+
await childTask.trigger(payload, { idempotencyKey: "my-key" });
|
|
272
|
+
await childTask.trigger(payload, { idempotencyKey: await idempotencyKeys.create("my-key") });
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
<Warning>
|
|
276
|
+
**Breaking change in v4.3.1:** In v4.3.0 and earlier, raw strings defaulted to `global` scope. Starting in v4.3.1, raw strings now default to `run` scope. If you're upgrading and relied on the previous global behavior, you must now explicitly use `idempotencyKeys.create("key", { scope: "global" })`.
|
|
277
|
+
</Warning>
|
|
278
|
+
|
|
279
|
+
This means raw strings are scoped to the parent run by default. If you want global behavior, you must explicitly create the key with `scope: "global"`:
|
|
280
|
+
|
|
281
|
+
```ts
|
|
282
|
+
// For global idempotency, you must use idempotencyKeys.create with scope: "global"
|
|
283
|
+
const idempotencyKey = await idempotencyKeys.create("my-key", { scope: "global" });
|
|
284
|
+
await childTask.trigger(payload, { idempotencyKey });
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Triggering from backend code
|
|
288
|
+
|
|
289
|
+
When triggering tasks from your backend code (outside of a task), there is no parent run context. In this case, `run` and `attempt` scopes behave the same as `global` since there's no run ID or attempt number to inject:
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
// In your backend code (e.g., an API route)
|
|
293
|
+
import { idempotencyKeys, tasks } from "@trigger.dev/sdk";
|
|
294
|
+
|
|
295
|
+
// All three of these behave the same when called outside a task:
|
|
296
|
+
await tasks.trigger("my-task", payload, { idempotencyKey: "my-key" });
|
|
297
|
+
await tasks.trigger("my-task", payload, {
|
|
298
|
+
idempotencyKey: await idempotencyKeys.create("my-key", { scope: "run" }),
|
|
299
|
+
});
|
|
300
|
+
await tasks.trigger("my-task", payload, {
|
|
301
|
+
idempotencyKey: await idempotencyKeys.create("my-key", { scope: "global" }),
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
<Note>
|
|
306
|
+
When triggering from backend code, the scope doesn't matter since there's no task context. All scopes effectively behave as global.
|
|
307
|
+
</Note>
|
|
308
|
+
|
|
309
|
+
## `idempotencyKeyTTL` option
|
|
310
|
+
|
|
311
|
+
The `idempotencyKeyTTL` option defines a time window during which a task with the same idempotency key will only run once. Here's how it works:
|
|
312
|
+
|
|
313
|
+
1. When you trigger a task with an idempotency key and set `idempotencyKeyTTL: "5m"`, it creates a 5-minute window.
|
|
314
|
+
2. During this window, any subsequent triggers with the same idempotency key will return the original task run instead of creating a new one.
|
|
315
|
+
3. Once the TTL window expires, the next trigger with that idempotency key will create a new task run and start a new time window.
|
|
316
|
+
|
|
317
|
+

|
|
318
|
+
|
|
319
|
+
By default idempotency keys are stored for 30 days. You can change this by passing the `idempotencyKeyTTL` option when triggering a task:
|
|
320
|
+
|
|
321
|
+
```ts
|
|
322
|
+
import { idempotencyKeys, task, wait } from "@trigger.dev/sdk";
|
|
323
|
+
|
|
324
|
+
export const myTask = task({
|
|
325
|
+
id: "my-task",
|
|
326
|
+
retry: {
|
|
327
|
+
maxAttempts: 4,
|
|
328
|
+
},
|
|
329
|
+
run: async (payload: any) => {
|
|
330
|
+
const idempotencyKey = await idempotencyKeys.create("my-task-key");
|
|
331
|
+
|
|
332
|
+
// The idempotency key will expire after 60 seconds
|
|
333
|
+
await childTask.trigger({ foo: "bar" }, { idempotencyKey, idempotencyKeyTTL: "60s" });
|
|
334
|
+
|
|
335
|
+
await wait.for({ seconds: 61 });
|
|
336
|
+
|
|
337
|
+
// The idempotency key will have expired, so the childTask will be triggered again
|
|
338
|
+
await childTask.trigger({ foo: "bar" }, { idempotencyKey });
|
|
339
|
+
|
|
340
|
+
// Do something else, that may throw an error and cause the task to be retried
|
|
341
|
+
throw new Error("Something went wrong");
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
You can use the following units for the `idempotencyKeyTTL` option:
|
|
347
|
+
|
|
348
|
+
- `s` for seconds (e.g. `60s`)
|
|
349
|
+
- `m` for minutes (e.g. `5m`)
|
|
350
|
+
- `h` for hours (e.g. `2h`)
|
|
351
|
+
- `d` for days (e.g. `3d`)
|
|
352
|
+
|
|
353
|
+
## Failed runs and idempotency
|
|
354
|
+
|
|
355
|
+
When a run with an idempotency key **fails**, the key is automatically cleared. This means triggering the same task with the same idempotency key will create a new run. However, **successful** and **canceled** runs keep their idempotency key. If you need to re-trigger after a successful or canceled run, you can:
|
|
356
|
+
|
|
357
|
+
1. **Reset the idempotency key** using `idempotencyKeys.reset()`:
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
import { idempotencyKeys } from "@trigger.dev/sdk";
|
|
361
|
+
|
|
362
|
+
// Clear the idempotency key to allow re-triggering
|
|
363
|
+
await idempotencyKeys.reset("my-task", "my-idempotency-key");
|
|
364
|
+
|
|
365
|
+
// Now you can trigger the task again
|
|
366
|
+
await myTask.trigger(payload, { idempotencyKey: "my-idempotency-key" });
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
2. **Use a shorter TTL** so the key expires automatically:
|
|
370
|
+
|
|
371
|
+
```ts
|
|
372
|
+
// Key expires after 5 minutes
|
|
373
|
+
await myTask.trigger(payload, {
|
|
374
|
+
idempotencyKey: "my-key",
|
|
375
|
+
idempotencyKeyTTL: "5m"
|
|
376
|
+
});
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## Payload-based idempotency
|
|
380
|
+
|
|
381
|
+
We don't currently support payload-based idempotency, but you can implement it yourself by hashing the payload and using the hash as the idempotency key.
|
|
382
|
+
|
|
383
|
+
```ts
|
|
384
|
+
import { idempotencyKeys, task } from "@trigger.dev/sdk";
|
|
385
|
+
import { createHash } from "node:crypto";
|
|
386
|
+
|
|
387
|
+
// Somewhere in your code
|
|
388
|
+
const idempotencyKey = await idempotencyKeys.create(hash(childPayload));
|
|
389
|
+
// childTask will only be triggered once with the same idempotency key
|
|
390
|
+
await tasks.trigger("child-task", { some: "payload" }, { idempotencyKey });
|
|
391
|
+
|
|
392
|
+
// Create a hash of the payload using Node.js crypto
|
|
393
|
+
// Ideally, you'd do a stable serialization of the payload before hashing, to ensure the same payload always results in the same hash
|
|
394
|
+
function hash(payload: any): string {
|
|
395
|
+
const hash = createHash("sha256");
|
|
396
|
+
hash.update(JSON.stringify(payload));
|
|
397
|
+
return hash.digest("hex");
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## Resetting idempotency keys
|
|
402
|
+
|
|
403
|
+
You can reset an idempotency key to clear it from all associated runs. This is useful if you need to allow a task to be triggered again with the same idempotency key.
|
|
404
|
+
|
|
405
|
+
When you reset an idempotency key, it will be cleared for all runs that match both the task identifier and the idempotency key in the current environment. This allows you to trigger the task again with the same key.
|
|
406
|
+
|
|
407
|
+
### API signature
|
|
408
|
+
|
|
409
|
+
```ts
|
|
410
|
+
idempotencyKeys.reset(
|
|
411
|
+
taskIdentifier: string,
|
|
412
|
+
idempotencyKey: string,
|
|
413
|
+
requestOptions?: ZodFetchOptions
|
|
414
|
+
): Promise<{ id: string }>
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
| Parameter | Description |
|
|
418
|
+
| --- | --- |
|
|
419
|
+
| `taskIdentifier` | The identifier of the task (e.g., `"my-task"`) |
|
|
420
|
+
| `idempotencyKey` | The idempotency key hash to reset (the 64-character hash string) |
|
|
421
|
+
| `requestOptions` | Optional fetch options for the API request |
|
|
422
|
+
|
|
423
|
+
### Resetting keys created with `idempotencyKeys.create()`
|
|
424
|
+
|
|
425
|
+
When you pass an `IdempotencyKey` created with `idempotencyKeys.create()`, the scope and original key are automatically extracted, making it easy to reset:
|
|
426
|
+
|
|
427
|
+
```ts
|
|
428
|
+
import { idempotencyKeys, task } from "@trigger.dev/sdk";
|
|
429
|
+
|
|
430
|
+
export const parentTask = task({
|
|
431
|
+
id: "parent-task",
|
|
432
|
+
run: async (payload) => {
|
|
433
|
+
const key = await idempotencyKeys.create("my-key", { scope: "global" });
|
|
434
|
+
await childTask.trigger(payload, { idempotencyKey: key });
|
|
435
|
+
|
|
436
|
+
// Later in the same task, reset it - options extracted automatically
|
|
437
|
+
await idempotencyKeys.reset("child-task", key);
|
|
438
|
+
},
|
|
439
|
+
});
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### Resetting global keys
|
|
443
|
+
|
|
444
|
+
Global keys are the simplest to reset since they don't require any run context:
|
|
445
|
+
|
|
446
|
+
```ts
|
|
447
|
+
import { idempotencyKeys } from "@trigger.dev/sdk";
|
|
448
|
+
|
|
449
|
+
// From anywhere - inside a task or from your backend code
|
|
450
|
+
await idempotencyKeys.reset("my-task", "my-key", { scope: "global" });
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
### Resetting run-scoped keys
|
|
454
|
+
|
|
455
|
+
Keys created with `"run"` scope (the default) include the parent run ID in the hash. When resetting from inside the same task, the run ID is automatically available:
|
|
456
|
+
|
|
457
|
+
```ts
|
|
458
|
+
import { idempotencyKeys, task } from "@trigger.dev/sdk";
|
|
459
|
+
|
|
460
|
+
export const parentTask = task({
|
|
461
|
+
id: "parent-task",
|
|
462
|
+
run: async (payload) => {
|
|
463
|
+
// Create a run-scoped key (default)
|
|
464
|
+
const key = await idempotencyKeys.create("my-key");
|
|
465
|
+
await childTask.trigger(payload, { idempotencyKey: key });
|
|
466
|
+
|
|
467
|
+
// Reset works automatically inside the task - run ID is available from context
|
|
468
|
+
await idempotencyKeys.reset("child-task", key);
|
|
469
|
+
},
|
|
470
|
+
});
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
When resetting from outside a task, you must provide the `parentRunId` if the key was created within a task context:
|
|
474
|
+
|
|
475
|
+
```ts
|
|
476
|
+
import { idempotencyKeys } from "@trigger.dev/sdk";
|
|
477
|
+
|
|
478
|
+
// If the key was created within a task, you need the parent run ID
|
|
479
|
+
await idempotencyKeys.reset("my-task", "my-key", {
|
|
480
|
+
scope: "run",
|
|
481
|
+
parentRunId: "run_abc123"
|
|
482
|
+
});
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
<Note>
|
|
486
|
+
If you triggered the task from backend code, all scopes behave as global (see [Triggering from backend code](#triggering-from-backend-code)). Use `scope: "global"` when resetting.
|
|
487
|
+
</Note>
|
|
488
|
+
|
|
489
|
+
### Resetting attempt-scoped keys
|
|
490
|
+
|
|
491
|
+
Keys created with `"attempt"` scope include both the parent run ID and attempt number. When resetting from outside a task, you must provide both:
|
|
492
|
+
|
|
493
|
+
```ts
|
|
494
|
+
import { idempotencyKeys } from "@trigger.dev/sdk";
|
|
495
|
+
|
|
496
|
+
// From your backend code
|
|
497
|
+
await idempotencyKeys.reset("my-task", "my-key", {
|
|
498
|
+
scope: "attempt",
|
|
499
|
+
parentRunId: "run_abc123",
|
|
500
|
+
attemptNumber: 1
|
|
501
|
+
});
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
<Warning>
|
|
505
|
+
If you try to reset a `"run"` or `"attempt"` scoped key from outside a task without providing the required `parentRunId` (and `attemptNumber` for attempt scope), it will throw an error.
|
|
506
|
+
</Warning>
|
|
507
|
+
|
|
508
|
+
### Resetting from the dashboard
|
|
509
|
+
|
|
510
|
+
You can also reset idempotency keys directly from the Trigger.dev dashboard:
|
|
511
|
+
|
|
512
|
+
1. Navigate to the run that has the idempotency key you want to reset
|
|
513
|
+
2. In the run details panel, find the "Idempotency key" section
|
|
514
|
+
3. Click the "Reset" button
|
|
515
|
+
|
|
516
|
+
This is useful when you need to manually allow a task to be re-triggered without writing code.
|
|
517
|
+
|
|
518
|
+

|
|
519
|
+
|
|
520
|
+
<Note>
|
|
521
|
+
Resetting an idempotency key only affects runs in the current environment. The reset is scoped to the specific task identifier and idempotency key combination.
|
|
522
|
+
</Note>
|
|
523
|
+
|
|
524
|
+
## Important notes
|
|
525
|
+
|
|
526
|
+
### Environment and task scoping
|
|
527
|
+
|
|
528
|
+
Idempotency keys, even the ones scoped globally, are actually scoped to the task and the environment. This means that you cannot collide with keys from other environments (e.g. dev will never collide with prod), or to other projects and orgs.
|
|
529
|
+
|
|
530
|
+
If you use the same idempotency key for triggering different tasks, the tasks will not be idempotent, and both tasks will be triggered. There's currently no way to make multiple tasks idempotent with the same key.
|
|
531
|
+
|
|
532
|
+
### How scopes affect the key
|
|
533
|
+
|
|
534
|
+
The scope determines what gets hashed alongside your key:
|
|
535
|
+
|
|
536
|
+
- Same key + `"run"` scope in different parent runs = different hashes = both tasks run
|
|
537
|
+
- Same key + `"global"` scope in different parent runs = same hash = only first task runs
|
|
538
|
+
- Same key + different scopes = different hashes = both tasks run
|
|
539
|
+
|
|
540
|
+
This is why understanding scopes is crucial: the same string key can produce different idempotency behavior depending on the scope and context.
|
|
541
|
+
|
|
542
|
+
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Trigger.dev docs"
|
|
3
|
+
sidebarTitle: "Introduction"
|
|
4
|
+
description: "Build and run durable AI agents and workflows in TypeScript. Long-running tasks with retries, queues, observability, and elastic scaling. Open source and self-hostable."
|
|
5
|
+
mode: "center"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
import AgentSetupPrompt from "/snippets/agent-setup-prompt.mdx";
|
|
9
|
+
|
|
10
|
+
<CardGroup cols={2}>
|
|
11
|
+
<Card title="Quick start" icon="rocket" href="/quick-start" color="#A8FF53">
|
|
12
|
+
Go from zero to your first task in 3 minutes.
|
|
13
|
+
</Card>
|
|
14
|
+
<Card title="Build AI agents" icon="robot" href="/guides/ai-agents/overview" color="#a855f7">
|
|
15
|
+
Agent patterns, worked examples, and the tools to run them in production.
|
|
16
|
+
</Card>
|
|
17
|
+
<Card title="AI coding assistants" icon="wand-magic-sparkles" href="/building-with-ai" color="#3B82F6">
|
|
18
|
+
Let Claude Code, Cursor and Windsurf write correct Trigger.dev code with the MCP server, Skills and rules.
|
|
19
|
+
</Card>
|
|
20
|
+
<Card title="Guides & examples" icon="book-open" href="/guides/introduction" color="#f6cd46">
|
|
21
|
+
Frameworks like Next.js, worked example projects, and step-by-step how-to guides.
|
|
22
|
+
</Card>
|
|
23
|
+
</CardGroup>
|
|
24
|
+
|
|
25
|
+
## Set up with AI
|
|
26
|
+
|
|
27
|
+
<AgentSetupPrompt />
|
|
28
|
+
|
|
29
|
+
## What is Trigger.dev?
|
|
30
|
+
|
|
31
|
+
Trigger.dev is the open source platform for building and running durable AI agents and workflows in TypeScript. Run them for hours, configure automatic retries, control concurrency, and manage queues. There's no execution timeout, and no queue or worker infrastructure for you to build.
|
|
32
|
+
|
|
33
|
+
You write agents and tasks in your existing codebase using our CLI and SDK, and get durable execution, queues, waits, full tracing, and elastic scaling without building any of it yourself.
|
|
34
|
+
|
|
35
|
+
Trigger.dev's core is Apache-2.0 licensed, a genuine OSI license. [Self-host it](/self-hosting/overview) on your own infrastructure, or let [Trigger.dev Cloud](https://cloud.trigger.dev) run it for you.
|
|
36
|
+
|
|
37
|
+
## Core concepts
|
|
38
|
+
|
|
39
|
+
<CardGroup cols={2}>
|
|
40
|
+
<Card title="Writing tasks" icon="pen-to-square" href="/tasks/overview" color="#A8FF53">
|
|
41
|
+
The durable functions at the core of Trigger.dev. Write them in your existing codebase, with retries and no timeouts.
|
|
42
|
+
</Card>
|
|
43
|
+
<Card title="Triggering tasks" icon="bullseye-pointer" href="/triggering" color="#3b82f6">
|
|
44
|
+
Trigger a task from your backend, your frontend, a schedule, or another task.
|
|
45
|
+
</Card>
|
|
46
|
+
<Card title="Runs" icon="play" href="/runs" color="#28bf5c">
|
|
47
|
+
Every execution of a task is a run, with its status, retries, and logs recorded.
|
|
48
|
+
</Card>
|
|
49
|
+
<Card title="Idempotency" icon="fingerprint" href="/idempotency" color="#F43F5E">
|
|
50
|
+
Use an idempotency key so a retried or duplicated trigger runs once, not twice.
|
|
51
|
+
</Card>
|
|
52
|
+
</CardGroup>
|
|
53
|
+
|
|
54
|
+
## Build with agents
|
|
55
|
+
|
|
56
|
+
Build durable, multi-turn agents with the [chat agent](/ai-chat/overview): one long-running task per conversation, with the tools it can call, streaming, and resumability handled for you. Add human-in-the-loop approval by pausing a run on a [waitpoint](/wait-for-token) until a person signs off, and a waiting run doesn't consume compute. Stream run status and LLM output straight to your frontend with the [Realtime API](/realtime/overview) and React hooks, and record your Vercel AI SDK calls as spans with the model, token counts, cost and latency using [AI observability](/ai/observability). Version your [prompts](/ai/prompts) in code, then edit the text or swap the model from the dashboard without redeploying.
|
|
57
|
+
|
|
58
|
+
## Scale and scheduling
|
|
59
|
+
|
|
60
|
+
Set how many runs of a task execute at once, globally or per tenant, with [concurrency](/concurrency) and [queues](/queues). Run a task on a [cron schedule](/tasks/scheduled) with timezone support, choose the CPU and memory each task runs on with [machines](/machines), and control what happens when a task throws with [errors and retries](/errors-retrying).
|
|
61
|
+
|
|
62
|
+
## Self-hosting
|
|
63
|
+
|
|
64
|
+
Trigger.dev is open source and you can self-host. Read the [overview guide](/self-hosting/overview), or how to do it with [Docker](/self-hosting/docker) or [Kubernetes](/self-hosting/kubernetes).
|
|
65
|
+
|
|
66
|
+
## Frequently asked questions
|
|
67
|
+
|
|
68
|
+
**How do I add human-in-the-loop approval to an agent?** Pause the run on a [waitpoint](/wait-for-token) until a person approves the action. A waiting run doesn't consume compute, so it can wait minutes or days.
|
|
69
|
+
|
|
70
|
+
**Does Trigger.dev support tool calling and MCP?** Yes. Agents call the tools you define, and the [MCP server](/building-with-ai) lets AI coding assistants trigger tasks, deploy, and read run traces.
|
|
71
|
+
|
|
72
|
+
**Can I use Trigger.dev for background jobs, not just AI?** Yes. The same durable tasks, queues, retries, and [cron schedules](/tasks/scheduled) run any background job or workflow, with or without AI.
|
|
73
|
+
|
|
74
|
+
## Getting help
|
|
75
|
+
|
|
76
|
+
We'd love to hear from you or give you a hand getting started. Here are some ways to get in touch with us.
|
|
77
|
+
|
|
78
|
+
<CardGroup>
|
|
79
|
+
<Card
|
|
80
|
+
title="Join our Discord server"
|
|
81
|
+
icon="discord"
|
|
82
|
+
href="https://discord.gg/kA47vcd8P6"
|
|
83
|
+
color="#5865F2"
|
|
84
|
+
>
|
|
85
|
+
Our Discord is the best place to get help with any questions about Trigger.dev.
|
|
86
|
+
</Card>
|
|
87
|
+
<Card
|
|
88
|
+
title="Follow us on X (Twitter)"
|
|
89
|
+
icon={
|
|
90
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="20" viewBox="0 0 512 512">
|
|
91
|
+
<path d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z" />
|
|
92
|
+
</svg>
|
|
93
|
+
}
|
|
94
|
+
href="https://twitter.com/triggerdotdev"
|
|
95
|
+
color="#1DA1F2"
|
|
96
|
+
>
|
|
97
|
+
Follow us to get the latest updates and news.
|
|
98
|
+
</Card>
|
|
99
|
+
<Card
|
|
100
|
+
title="Schedule a call"
|
|
101
|
+
icon="phone"
|
|
102
|
+
iconType="solid"
|
|
103
|
+
color="#22C55E"
|
|
104
|
+
href="https://cal.com/team/triggerdotdev/founders-call"
|
|
105
|
+
>
|
|
106
|
+
Arrange a call with one of the founders to get help with any questions.
|
|
107
|
+
</Card>
|
|
108
|
+
<Card
|
|
109
|
+
title="Give us a star on GitHub"
|
|
110
|
+
icon="star"
|
|
111
|
+
iconType="solid"
|
|
112
|
+
href="https://github.com/triggerdotdev/trigger.dev"
|
|
113
|
+
color="#fbbf24"
|
|
114
|
+
>
|
|
115
|
+
Check us out our GitHub repo and give us a star if you like what we're doing.
|
|
116
|
+
</Card>
|
|
117
|
+
</CardGroup>
|
|
118
|
+
|
|
119
|
+
<Visibility for="agents">
|
|
120
|
+
|
|
121
|
+
## Facts for AI assistants
|
|
122
|
+
|
|
123
|
+
**Current major version:** v4 (`@trigger.dev/sdk` 4.x). Documentation under `/docs/v2` and `/docs/v3` describes superseded versions and should not be used.
|
|
124
|
+
|
|
125
|
+
**Execution model:** tasks run on Trigger.dev infrastructure, not inside your serverless functions, so a platform function timeout is not in the execution path. A task runs until it finishes; you can cap runtime with `maxDuration` (minimum 5 seconds).
|
|
126
|
+
|
|
127
|
+
**Deploys:** each deploy is an atomic version. A run already in progress is not affected by code shipped after it started.
|
|
128
|
+
|
|
129
|
+
**Durability and retries:** retries are automatic and configurable. A failed attempt is retried according to the task's retry settings; once retries are exhausted the run ends terminally as `FAILED`, and some crashes (for example out of memory) end the run as `CRASHED` without a retry. Idempotency keys deduplicate the task triggers and waits you key, so the same key runs once instead of again.
|
|
130
|
+
|
|
131
|
+
**License:** the platform core is Apache-2.0 and the `@trigger.dev/sdk` package is MIT, permissive open source, not fair-code or source-available. Some features are gated, but the open source core is not relicensed or held back.
|
|
132
|
+
|
|
133
|
+
**LLM observability coverage:** only Vercel AI SDK calls (`generateText`, `streamText`, `generateObject`) are recorded as spans. Raw `fetch` calls and provider SDKs used directly are not captured.
|
|
134
|
+
|
|
135
|
+
</Visibility>
|