@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,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: SWR hooks
|
|
3
|
+
sidebarTitle: SWR
|
|
4
|
+
description: Fetch and cache data using SWR-based hooks
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
SWR hooks use the [swr](https://swr.vercel.app/) library to fetch data once and cache it. These hooks are useful when you need to fetch data without real-time updates.
|
|
8
|
+
|
|
9
|
+
<Note>
|
|
10
|
+
While SWR can be configured to poll for updates, we recommend using our other [Realtime
|
|
11
|
+
hooks](/realtime/react-hooks/) for most use-cases due to rate-limits and the way the Trigger.dev
|
|
12
|
+
API works.
|
|
13
|
+
</Note>
|
|
14
|
+
|
|
15
|
+
## useRun
|
|
16
|
+
|
|
17
|
+
The `useRun` hook allows you to fetch a run by its ID.
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
"use client"; // This is needed for Next.js App Router or other RSC frameworks
|
|
21
|
+
|
|
22
|
+
import { useRun } from "@trigger.dev/react-hooks";
|
|
23
|
+
|
|
24
|
+
export function MyComponent({ runId }: { runId: string }) {
|
|
25
|
+
const { run, error, isLoading } = useRun(runId);
|
|
26
|
+
|
|
27
|
+
if (isLoading) return <div>Loading...</div>;
|
|
28
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
29
|
+
|
|
30
|
+
return <div>Run: {run.id}</div>;
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The `run` object returned is the same as the [run object](/management/runs/retrieve) returned by the Trigger.dev API. To correctly type the run's payload and output, you can provide the type of your task to the `useRun` hook:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { useRun } from "@trigger.dev/react-hooks";
|
|
38
|
+
import type { myTask } from "@/trigger/myTask";
|
|
39
|
+
|
|
40
|
+
export function MyComponent({ runId }: { runId: string }) {
|
|
41
|
+
const { run, error, isLoading } = useRun<typeof myTask>(runId, {
|
|
42
|
+
refreshInterval: 0, // Disable polling
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (isLoading) return <div>Loading...</div>;
|
|
46
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
47
|
+
|
|
48
|
+
// Now run.payload and run.output are correctly typed
|
|
49
|
+
|
|
50
|
+
return <div>Run: {run.id}</div>;
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Common SWR options
|
|
55
|
+
|
|
56
|
+
You can pass the following options to the all SWR hooks:
|
|
57
|
+
|
|
58
|
+
<ParamField path="revalidateOnFocus" type="boolean">
|
|
59
|
+
Revalidate the data when the window regains focus.
|
|
60
|
+
</ParamField>
|
|
61
|
+
|
|
62
|
+
<ParamField path="revalidateOnReconnect" type="boolean">
|
|
63
|
+
Revalidate the data when the browser regains a network connection.
|
|
64
|
+
</ParamField>
|
|
65
|
+
|
|
66
|
+
<ParamField path="refreshInterval" type="number">
|
|
67
|
+
Poll for updates at the specified interval (in milliseconds). Polling is not recommended for most
|
|
68
|
+
use-cases. Use the Realtime hooks instead.
|
|
69
|
+
</ParamField>
|
|
70
|
+
|
|
71
|
+
## Common SWR return values
|
|
72
|
+
|
|
73
|
+
<ResponseField name="error" type="Error">
|
|
74
|
+
An error object if an error occurred while fetching the data.
|
|
75
|
+
</ResponseField>
|
|
76
|
+
|
|
77
|
+
<ResponseField name="isLoading" type="boolean">
|
|
78
|
+
A boolean indicating if the data is currently being fetched.
|
|
79
|
+
</ResponseField>
|
|
80
|
+
|
|
81
|
+
<ResponseField name="isValidating" type="boolean">
|
|
82
|
+
A boolean indicating if the data is currently being revalidated.
|
|
83
|
+
</ResponseField>
|
|
84
|
+
|
|
85
|
+
<ResponseField name="isError" type="boolean">
|
|
86
|
+
A boolean indicating if an error occurred while fetching the data.
|
|
87
|
+
</ResponseField>{" "}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Trigger tasks from React"
|
|
3
|
+
sidebarTitle: Triggering
|
|
4
|
+
description: "Trigger background tasks from React components and optionally subscribe to their progress or stream their output."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Trigger tasks directly from your React components. You can fire-and-forget, or trigger and immediately subscribe to the run's progress or streamed output.
|
|
8
|
+
|
|
9
|
+
<Note>
|
|
10
|
+
For triggering tasks from your frontend, you need to use “trigger” tokens. These can only be used
|
|
11
|
+
once to trigger a task and are more secure than regular Public Access Tokens. To learn more about
|
|
12
|
+
how to create and use these tokens, see our [Trigger
|
|
13
|
+
Tokens](/realtime/auth#trigger-tokens-for-frontend-triggering-only) documentation.
|
|
14
|
+
</Note>
|
|
15
|
+
|
|
16
|
+
## Hooks
|
|
17
|
+
|
|
18
|
+
We provide three hooks for triggering tasks from your frontend application:
|
|
19
|
+
|
|
20
|
+
- `useTaskTrigger` - Trigger a task from your frontend application.
|
|
21
|
+
- `useRealtimeTaskTrigger` - Trigger a task from your frontend application and subscribe to the run.
|
|
22
|
+
- `useRealtimeTaskTriggerWithStreams` - Trigger a task from your frontend application and subscribe to the run, and also receive any streams that are emitted by the task.
|
|
23
|
+
|
|
24
|
+
### useTaskTrigger
|
|
25
|
+
|
|
26
|
+
The `useTaskTrigger` hook allows you to trigger a task from your frontend application.
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
"use client"; // This is needed for Next.js App Router or other RSC frameworks
|
|
30
|
+
|
|
31
|
+
import { useTaskTrigger } from "@trigger.dev/react-hooks";
|
|
32
|
+
import type { myTask } from "@/trigger/myTask";
|
|
33
|
+
// 👆 This is the type of your task, include this to get type-safety
|
|
34
|
+
|
|
35
|
+
export function MyComponent({ publicAccessToken }: { publicAccessToken: string }) {
|
|
36
|
+
// pass the type of your task here 👇
|
|
37
|
+
const { submit, handle, error, isLoading } = useTaskTrigger<typeof myTask>("my-task", {
|
|
38
|
+
accessToken: publicAccessToken, // 👈 this is the "trigger" token
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (error) {
|
|
42
|
+
return <div>Error: {error.message}</div>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (handle) {
|
|
46
|
+
return <div>Run ID: {handle.id}</div>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<button onClick={() => submit({ foo: "bar" })} disabled={isLoading}>
|
|
51
|
+
{isLoading ? "Loading..." : "Trigger Task"}
|
|
52
|
+
</button>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`useTaskTrigger` returns an object with the following properties:
|
|
58
|
+
|
|
59
|
+
- `submit`: A function that triggers the task. It takes the payload of the task as an argument.
|
|
60
|
+
- `handle`: The run handle object. This object contains the ID of the run that was triggered, along with a Public Access Token that can be used to access the run.
|
|
61
|
+
- `isLoading`: A boolean that indicates whether the task is currently being triggered.
|
|
62
|
+
- `error`: An error object that contains any errors that occurred while triggering the task.
|
|
63
|
+
|
|
64
|
+
The `submit` function triggers the task with the specified payload. You can additionally pass an optional [options](/triggering#options) argument to the `submit` function:
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
submit({ foo: "bar" }, { tags: ["tag1", "tag2"] });
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### Using the handle object
|
|
71
|
+
|
|
72
|
+
You can use the `handle` object to initiate a subsequent [Realtime hook](/realtime/react-hooks/subscribe#userealtimerun) to subscribe to the run.
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
"use client"; // This is needed for Next.js App Router or other RSC frameworks
|
|
76
|
+
|
|
77
|
+
import { useTaskTrigger, useRealtimeRun } from "@trigger.dev/react-hooks";
|
|
78
|
+
import type { myTask } from "@/trigger/myTask";
|
|
79
|
+
// 👆 This is the type of your task
|
|
80
|
+
|
|
81
|
+
export function MyComponent({ publicAccessToken }: { publicAccessToken: string }) {
|
|
82
|
+
// pass the type of your task here 👇
|
|
83
|
+
const { submit, handle, error, isLoading } = useTaskTrigger<typeof myTask>("my-task", {
|
|
84
|
+
accessToken: publicAccessToken, // 👈 this is the "trigger" token
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// pass the run ID and the task type to preserve type-safety 👇
|
|
88
|
+
const { run, error: realtimeError } = useRealtimeRun<typeof myTask>(handle?.id, {
|
|
89
|
+
accessToken: handle?.publicAccessToken,
|
|
90
|
+
enabled: !!handle, // Only subscribe to the run if the handle is available
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (error) {
|
|
94
|
+
return <div>Error: {error.message}</div>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (handle) {
|
|
98
|
+
return <div>Run ID: {handle.id}</div>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (realtimeError) {
|
|
102
|
+
return <div>Error: {realtimeError.message}</div>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (run) {
|
|
106
|
+
return <div>Run ID: {run.id}</div>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<button onClick={() => submit({ foo: "bar" })} disabled={isLoading}>
|
|
111
|
+
{isLoading ? "Loading..." : "Trigger Task"}
|
|
112
|
+
</button>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
We've also created some additional hooks that allow you to trigger tasks and subscribe to the run in one step:
|
|
118
|
+
|
|
119
|
+
### useRealtimeTaskTrigger
|
|
120
|
+
|
|
121
|
+
The `useRealtimeTaskTrigger` hook allows you to trigger a task from your frontend application and then subscribe to the run in using Realtime:
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
"use client"; // This is needed for Next.js App Router or other RSC frameworks
|
|
125
|
+
|
|
126
|
+
import { useRealtimeTaskTrigger } from "@trigger.dev/react-hooks";
|
|
127
|
+
import type { myTask } from "@/trigger/myTask";
|
|
128
|
+
|
|
129
|
+
export function MyComponent({ publicAccessToken }: { publicAccessToken: string }) {
|
|
130
|
+
const { submit, run, error, isLoading } = useRealtimeTaskTrigger<typeof myTask>("my-task", {
|
|
131
|
+
accessToken: publicAccessToken,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
if (error) {
|
|
135
|
+
return <div>Error: {error.message}</div>;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// This is the Realtime run object, which will automatically update when the run changes
|
|
139
|
+
if (run) {
|
|
140
|
+
return <div>Run ID: {run.id}</div>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<button onClick={() => submit({ foo: "bar" })} disabled={isLoading}>
|
|
145
|
+
{isLoading ? "Loading..." : "Trigger Task"}
|
|
146
|
+
</button>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### useRealtimeTaskTriggerWithStreams
|
|
152
|
+
|
|
153
|
+
The `useRealtimeTaskTriggerWithStreams` hook allows you to trigger a task from your frontend application and then subscribe to the run in using Realtime, and also receive any streams that are emitted by the task.
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
"use client"; // This is needed for Next.js App Router or other RSC frameworks
|
|
157
|
+
|
|
158
|
+
import { useRealtimeTaskTriggerWithStreams } from "@trigger.dev/react-hooks";
|
|
159
|
+
import type { myTask } from "@/trigger/myTask";
|
|
160
|
+
|
|
161
|
+
type STREAMS = {
|
|
162
|
+
openai: string; // this is the type of each "part" of the stream
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export function MyComponent({ publicAccessToken }: { publicAccessToken: string }) {
|
|
166
|
+
const { submit, run, streams, error, isLoading } = useRealtimeTaskTriggerWithStreams<
|
|
167
|
+
typeof myTask,
|
|
168
|
+
STREAMS
|
|
169
|
+
>("my-task", {
|
|
170
|
+
accessToken: publicAccessToken,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
if (error) {
|
|
174
|
+
return <div>Error: {error.message}</div>;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (streams && run) {
|
|
178
|
+
const text = streams.openai?.map((part) => part).join("");
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<div>
|
|
182
|
+
<div>Run ID: {run.id}</div>
|
|
183
|
+
<div>{text}</div>
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<button onClick={() => submit({ foo: "bar" })} disabled={isLoading}>
|
|
190
|
+
{isLoading ? "Loading..." : "Trigger Task"}
|
|
191
|
+
</button>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: useWaitToken
|
|
3
|
+
description: Use the useWaitToken hook to complete a wait token from a React component
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
We've added a new `useWaitToken` react hook that allows you to complete a wait token from a React component, using a Public Access Token.
|
|
7
|
+
|
|
8
|
+
```ts backend.ts
|
|
9
|
+
import { wait } from "@trigger.dev/sdk";
|
|
10
|
+
|
|
11
|
+
// Somewhere in your code, you'll need to create the token and then pass the token ID and the public token to the frontend
|
|
12
|
+
const token = await wait.createToken({
|
|
13
|
+
timeout: "10m",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
tokenId: token.id,
|
|
18
|
+
publicToken: token.publicAccessToken, // An automatically generated public access token that expires in 24 hours
|
|
19
|
+
};
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Now you can use the `useWaitToken` hook in your frontend code:
|
|
23
|
+
|
|
24
|
+
```tsx frontend.tsx
|
|
25
|
+
import { useWaitToken } from "@trigger.dev/react-hooks";
|
|
26
|
+
|
|
27
|
+
export function MyComponent({ publicToken, tokenId }: { publicToken: string; tokenId: string }) {
|
|
28
|
+
const { complete } = useWaitToken(tokenId, {
|
|
29
|
+
accessToken: publicToken,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return <button onClick={() => complete({ foo: "bar" })}>Complete</button>;
|
|
33
|
+
}
|
|
34
|
+
```
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "The run object"
|
|
3
|
+
sidebarTitle: "The run object"
|
|
4
|
+
description: "The run object schema for Realtime subscriptions"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
The [run object](/realtime/run-object#the-run-object) is the main object returned by Realtime subscriptions (e.g., `runs.subscribeToRun()`). It contains all the information about the run, including the run ID, task identifier, payload, output, and more.
|
|
8
|
+
|
|
9
|
+
Type-safety is supported for the run object, so you can infer the types of the run's payload and output. See [type-safety](#type-safety) for more information.
|
|
10
|
+
|
|
11
|
+
## The run object
|
|
12
|
+
|
|
13
|
+
### Properties
|
|
14
|
+
|
|
15
|
+
<ParamField path="id" type="string" required>
|
|
16
|
+
The run ID.
|
|
17
|
+
</ParamField>
|
|
18
|
+
|
|
19
|
+
<ParamField path="taskIdentifier" type="string" required>
|
|
20
|
+
The task identifier.
|
|
21
|
+
</ParamField>
|
|
22
|
+
|
|
23
|
+
<ParamField path="payload" type="object" required>
|
|
24
|
+
The input payload for the run.
|
|
25
|
+
</ParamField>
|
|
26
|
+
|
|
27
|
+
<ParamField path="output" type="object">
|
|
28
|
+
The output result of the run.
|
|
29
|
+
</ParamField>
|
|
30
|
+
|
|
31
|
+
<ParamField path="createdAt" type="Date" required>
|
|
32
|
+
Timestamp when the run was created.
|
|
33
|
+
</ParamField>
|
|
34
|
+
|
|
35
|
+
<ParamField path="updatedAt" type="Date" required>
|
|
36
|
+
Timestamp when the run was last updated.
|
|
37
|
+
</ParamField>
|
|
38
|
+
|
|
39
|
+
<ParamField path="status" type="RunStatus" required>
|
|
40
|
+
Current status of the run.
|
|
41
|
+
|
|
42
|
+
<Accordion title="RunStatus enum">
|
|
43
|
+
|
|
44
|
+
| Status | Description |
|
|
45
|
+
| ----------------- | --------------------------------------------------------------------------------------------------------- |
|
|
46
|
+
| `PENDING_VERSION` | Run is waiting for a version update because it cannot execute without additional information |
|
|
47
|
+
| `QUEUED` | Run is waiting to be executed by a worker |
|
|
48
|
+
| `DEQUEUED` | Run has been dequeued and is being sent to a worker to start executing |
|
|
49
|
+
| `EXECUTING` | Run is currently being executed by a worker |
|
|
50
|
+
| `WAITING` | Run has been paused by the system, and will be resumed by the system |
|
|
51
|
+
| `COMPLETED` | Run has been completed successfully |
|
|
52
|
+
| `CANCELED` | Run has been canceled by the user |
|
|
53
|
+
| `FAILED` | Run has been completed with errors |
|
|
54
|
+
| `CRASHED` | Run has crashed and won't be retried, most likely the worker ran out of resources, e.g. memory or storage |
|
|
55
|
+
| `SYSTEM_FAILURE` | Run has failed to complete, due to an error in the system |
|
|
56
|
+
| `DELAYED` | Run has been scheduled to run at a specific time |
|
|
57
|
+
| `EXPIRED` | Run has expired and won't be executed |
|
|
58
|
+
| `TIMED_OUT` | Run has reached it's maxDuration and has been stopped |
|
|
59
|
+
|
|
60
|
+
</Accordion>
|
|
61
|
+
</ParamField>
|
|
62
|
+
|
|
63
|
+
<ParamField path="durationMs" type="number" required>
|
|
64
|
+
Duration of the run in milliseconds.
|
|
65
|
+
</ParamField>
|
|
66
|
+
|
|
67
|
+
<ParamField path="costInCents" type="number" required>
|
|
68
|
+
Total cost of the run in cents.
|
|
69
|
+
</ParamField>
|
|
70
|
+
|
|
71
|
+
<ParamField path="baseCostInCents" type="number" required>
|
|
72
|
+
Base cost of the run in cents before any additional charges.
|
|
73
|
+
</ParamField>
|
|
74
|
+
|
|
75
|
+
<ParamField path="tags" type="string[]" required>
|
|
76
|
+
Array of tags associated with the run.
|
|
77
|
+
</ParamField>
|
|
78
|
+
|
|
79
|
+
<ParamField path="idempotencyKey" type="string">
|
|
80
|
+
Key used to ensure idempotent execution.
|
|
81
|
+
</ParamField>
|
|
82
|
+
|
|
83
|
+
<ParamField path="expiredAt" type="Date">
|
|
84
|
+
Timestamp when the run expired.
|
|
85
|
+
</ParamField>
|
|
86
|
+
|
|
87
|
+
<ParamField path="finishedAt" type="Date">
|
|
88
|
+
Timestamp when the run finished.
|
|
89
|
+
</ParamField>
|
|
90
|
+
|
|
91
|
+
<ParamField path="startedAt" type="Date">
|
|
92
|
+
Timestamp when the run started.
|
|
93
|
+
</ParamField>
|
|
94
|
+
|
|
95
|
+
<ParamField path="delayedUntil" type="Date">
|
|
96
|
+
Timestamp until which the run is delayed.
|
|
97
|
+
</ParamField>
|
|
98
|
+
|
|
99
|
+
<ParamField path="queuedAt" type="Date">
|
|
100
|
+
Timestamp when the run was queued.
|
|
101
|
+
</ParamField>
|
|
102
|
+
|
|
103
|
+
<ParamField path="metadata" type="Record<string, DeserializedJson>">
|
|
104
|
+
Additional metadata associated with the run.
|
|
105
|
+
</ParamField>
|
|
106
|
+
|
|
107
|
+
<ParamField path="error" type="SerializedError">
|
|
108
|
+
Error information if the run failed.
|
|
109
|
+
</ParamField>
|
|
110
|
+
|
|
111
|
+
<ParamField path="isTest" type="boolean" required>
|
|
112
|
+
Indicates whether this is a test run.
|
|
113
|
+
</ParamField>
|
|
114
|
+
|
|
115
|
+
<ParamField path="realtimeStreams" type="string[]" required>
|
|
116
|
+
Names of the Realtime streams on the run.
|
|
117
|
+
</ParamField>
|
|
118
|
+
|
|
119
|
+
<ParamField path="isQueued" type="boolean" required>
|
|
120
|
+
`true` if the run is queued, delayed or waiting for a version update.
|
|
121
|
+
</ParamField>
|
|
122
|
+
|
|
123
|
+
<ParamField path="isExecuting" type="boolean" required>
|
|
124
|
+
`true` if the run is dequeued or executing.
|
|
125
|
+
</ParamField>
|
|
126
|
+
|
|
127
|
+
<ParamField path="isWaiting" type="boolean" required>
|
|
128
|
+
`true` if the run is waiting.
|
|
129
|
+
</ParamField>
|
|
130
|
+
|
|
131
|
+
<ParamField path="isCompleted" type="boolean" required>
|
|
132
|
+
`true` if the run has finished, either successfully or with any failure status.
|
|
133
|
+
</ParamField>
|
|
134
|
+
|
|
135
|
+
<ParamField path="isFailed" type="boolean" required>
|
|
136
|
+
`true` if the run failed, crashed, hit a system failure, expired or timed out.
|
|
137
|
+
</ParamField>
|
|
138
|
+
|
|
139
|
+
<ParamField path="isSuccess" type="boolean" required>
|
|
140
|
+
`true` if the run completed successfully.
|
|
141
|
+
</ParamField>
|
|
142
|
+
|
|
143
|
+
<ParamField path="isCancelled" type="boolean" required>
|
|
144
|
+
`true` if the run was canceled.
|
|
145
|
+
</ParamField>
|
|
146
|
+
|
|
147
|
+
## Type-safety
|
|
148
|
+
|
|
149
|
+
You can infer the types of the run's payload and output by passing the type of the task to the `subscribeToRun` function. This will give you type-safe access to the run's payload and output.
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import { runs, tasks } from "@trigger.dev/sdk";
|
|
153
|
+
import type { myTask } from "./trigger/my-task";
|
|
154
|
+
|
|
155
|
+
// Somewhere in your backend code
|
|
156
|
+
async function myBackend() {
|
|
157
|
+
const handle = await tasks.trigger("my-task", { some: "data" });
|
|
158
|
+
|
|
159
|
+
for await (const run of runs.subscribeToRun<typeof myTask>(handle.id)) {
|
|
160
|
+
// This will log the run every time it changes
|
|
161
|
+
console.log(run.payload.some);
|
|
162
|
+
|
|
163
|
+
if (run.output) {
|
|
164
|
+
// This will log the output if it exists
|
|
165
|
+
console.log(run.output.some);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
When using `subscribeToRunsWithTag`, you can pass a union of task types for all the possible tasks that can have the tag.
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
import { runs } from "@trigger.dev/sdk";
|
|
175
|
+
import type { myTask, myOtherTask } from "./trigger/my-task";
|
|
176
|
+
|
|
177
|
+
// Somewhere in your backend code
|
|
178
|
+
for await (const run of runs.subscribeToRunsWithTag<typeof myTask | typeof myOtherTask>("my-tag")) {
|
|
179
|
+
// You can narrow down the type based on the taskIdentifier
|
|
180
|
+
switch (run.taskIdentifier) {
|
|
181
|
+
case "my-task": {
|
|
182
|
+
console.log("Run output:", run.output.foo); // This will be type-safe
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
case "my-other-task": {
|
|
186
|
+
console.log("Run output:", run.output.bar); // This will be type-safe
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
This works with all realtime subscription functions:
|
|
194
|
+
|
|
195
|
+
- `runs.subscribeToRun<TaskType>()`
|
|
196
|
+
- `runs.subscribeToRunsWithTag<TaskType>()`
|
|
197
|
+
- `runs.subscribeToBatch<TaskType>()`
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Replaying"
|
|
3
|
+
description: "A replay is a copy of a run with the same payload but against the latest version in that environment. This is useful if something went wrong and you want to try again with the latest version of your code."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
### Replaying from the UI
|
|
7
|
+
|
|
8
|
+
<Tabs>
|
|
9
|
+
<Tab title="From a run">
|
|
10
|
+
<Steps>
|
|
11
|
+
<Step title="Click the Replay button in the top right">
|
|
12
|
+

|
|
14
|
+
</Step>
|
|
15
|
+
<Step title="Confirm replay settings">
|
|
16
|
+
You can edit the payload <Icon icon="circle-1" iconType="solid" size={20} color="F43F47" /> (if available) and choose the environment <Icon icon="circle-2" iconType="solid" size={20} color="F43F47" /> to replay the run in.
|
|
17
|
+
|
|
18
|
+

|
|
20
|
+
</Step>
|
|
21
|
+
</Steps>
|
|
22
|
+
</Tab>
|
|
23
|
+
<Tab title="Runs list">
|
|
24
|
+
<Steps>
|
|
25
|
+
<Step title="Click the action button on a run">
|
|
26
|
+

|
|
27
|
+
</Step>
|
|
28
|
+
<Step title="Click replay"></Step>
|
|
29
|
+
</Steps>
|
|
30
|
+
</Tab>
|
|
31
|
+
</Tabs>
|
|
32
|
+
|
|
33
|
+
### Detecting replays in your task
|
|
34
|
+
|
|
35
|
+
You can check if a run is a replay using the [context](/context) object:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
export const myTask = task({
|
|
39
|
+
id: "my-task",
|
|
40
|
+
run: async (payload, { ctx }) => {
|
|
41
|
+
if (ctx.run.isReplay) {
|
|
42
|
+
// This run is a replay of a previous run
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Replaying using the SDK
|
|
49
|
+
|
|
50
|
+
You can replay a run using the SDK:
|
|
51
|
+
|
|
52
|
+
```ts Your backend code
|
|
53
|
+
import { runs } from "@trigger.dev/sdk";
|
|
54
|
+
|
|
55
|
+
const replayedRun = await runs.replay(run.id);
|
|
56
|
+
// { id: "run_cmv6ixfn30008ct9kegazjolu" }
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The new run reuses the original run's payload, metadata, tags, queue, concurrency key, and machine. Pass options to override any of them for the new run:
|
|
60
|
+
|
|
61
|
+
```ts Your backend code
|
|
62
|
+
import { runs } from "@trigger.dev/sdk";
|
|
63
|
+
|
|
64
|
+
const replayedRun = await runs.replay(run.id, {
|
|
65
|
+
payload: { userId: "user_456" },
|
|
66
|
+
metadata: { source: "replay" },
|
|
67
|
+
tags: ["replayed"],
|
|
68
|
+
machine: "large-1x",
|
|
69
|
+
delay: "10m",
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The options use the same names as [`trigger()` options](/triggering): `payload`, `metadata`, `tags`, `queue`, `concurrencyKey`, `machine`, `version`, `region`, `delay`, `ttl`, `idempotencyKey`, `idempotencyKeyTTL`, `maxAttempts`, `maxDuration`, and `priority`. If you leave out `payload`, `metadata`, `tags`, `queue`, `concurrencyKey`, or `machine`, the new run uses the original run's value. The other options fall back to the task's current defaults, and without `version` the replay runs on the current version. The replay always runs in the same environment as the original run.
|
|
74
|
+
|
|
75
|
+
A `queue` must already exist in the environment, and a `version` must be a version deployed to it. Otherwise the replay fails with an error and no run is created.
|
|
76
|
+
|
|
77
|
+
A replay starts a new run, so the API key or token you replay with needs permission to trigger the task as well as write access to the run.
|
|
78
|
+
|
|
79
|
+
The SDK serializes a `payload` override the same way `trigger()` does, so values like `Date`, `BigInt`, `Map` and `Set` reach the task with their types.
|
|
80
|
+
|
|
81
|
+
When you call `trigger()` or `batchTrigger()` on a task you receive back a run handle which has an `id` property. You can use that `id` to replay the run.
|
|
82
|
+
|
|
83
|
+
You can also access the run id from inside a run. You could write this to your database and then replay it later.
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
export const simpleChildTask = task({
|
|
87
|
+
id: "simple-child-task",
|
|
88
|
+
run: async (payload, { ctx }) => {
|
|
89
|
+
// the run ID (and other useful info) is in ctx
|
|
90
|
+
const runId = ctx.run.id;
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Bulk replaying
|
|
96
|
+
|
|
97
|
+
See [Bulk actions](/bulk-actions) for more information.
|