@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,308 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: trigger-authoring-chat-agent
|
|
3
|
+
description: >
|
|
4
|
+
Author and run a durable AI chat agent with chat.agent from @trigger.dev/sdk/ai: the per-turn
|
|
5
|
+
run loop, why you MUST take streamText from the run argument rather than importing it from ai,
|
|
6
|
+
returning a StreamTextResult vs calling chat.pipe(), the two server actions (chat.createStartSessionAction +
|
|
7
|
+
auth.createPublicToken), and wiring useChat to useTriggerChatTransport. Load this when building,
|
|
8
|
+
modifying, or debugging a chat backend (the agent task or its lifecycle hooks) or its React
|
|
9
|
+
transport, when declaring typed tools or custom data parts, or when migrating a plain AI SDK
|
|
10
|
+
streamText route to chat.agent.
|
|
11
|
+
type: core
|
|
12
|
+
library: trigger.dev
|
|
13
|
+
sources:
|
|
14
|
+
- docs/ai-chat/overview.mdx
|
|
15
|
+
- docs/ai-chat/quick-start.mdx
|
|
16
|
+
- docs/ai-chat/how-it-works.mdx
|
|
17
|
+
- docs/ai-chat/backend.mdx
|
|
18
|
+
- docs/ai-chat/frontend.mdx
|
|
19
|
+
- docs/ai-chat/reference.mdx
|
|
20
|
+
- docs/ai-chat/types.mdx
|
|
21
|
+
- docs/ai-chat/tools.mdx
|
|
22
|
+
- docs/ai-chat/lifecycle-hooks.mdx
|
|
23
|
+
- docs/ai-chat/error-handling.mdx
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
# Authoring a chat agent
|
|
27
|
+
|
|
28
|
+
A `chat.agent` runs an entire conversation as one long-lived Trigger.dev task. It wakes when a
|
|
29
|
+
message arrives, freezes when none do, and in-memory state survives page refreshes, deploys, idle
|
|
30
|
+
gaps, and crashes. Your code is the loop you would write anyway: messages in, `streamText` out.
|
|
31
|
+
There are no API routes. The frontend talks to the agent through a `TriggerChatTransport`, so
|
|
32
|
+
history accumulates server-side and the client ships only the new message each turn.
|
|
33
|
+
|
|
34
|
+
Works with Vercel AI SDK v5, v6, or v7. On v7 also install `@ai-sdk/otel` so model calls are traced
|
|
35
|
+
(the SDK registers it for you).
|
|
36
|
+
|
|
37
|
+
## Setup
|
|
38
|
+
|
|
39
|
+
Three pieces: the agent task, two server actions, and the frontend transport.
|
|
40
|
+
|
|
41
|
+
### 1. Define the agent
|
|
42
|
+
|
|
43
|
+
```ts trigger/chat.ts
|
|
44
|
+
import { chat } from "@trigger.dev/sdk/ai";
|
|
45
|
+
import { streamText, stepCountIs } from "ai";
|
|
46
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
47
|
+
|
|
48
|
+
export const myChat = chat.agent({
|
|
49
|
+
id: "my-chat",
|
|
50
|
+
// `streamText` below is the SDK's, from the run argument. See "Common mistakes".
|
|
51
|
+
run: async ({ messages, signal, streamText }) =>
|
|
52
|
+
streamText({
|
|
53
|
+
model: anthropic("claude-sonnet-4-5"),
|
|
54
|
+
messages,
|
|
55
|
+
abortSignal: signal,
|
|
56
|
+
stopWhen: stepCountIs(15),
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`run` receives `messages` already converted to `ModelMessage[]` (the SDK converts the frontend's
|
|
62
|
+
`UIMessage[]` for you) plus a `signal` that aborts on stop or cancel. Returning the
|
|
63
|
+
`StreamTextResult` auto-pipes it to the frontend.
|
|
64
|
+
|
|
65
|
+
### 2. Add two server actions
|
|
66
|
+
|
|
67
|
+
Both run on your server, so the browser never holds your environment secret key. This is also
|
|
68
|
+
where per-user / per-plan authorization and any paired DB writes live.
|
|
69
|
+
|
|
70
|
+
```ts app/actions.ts
|
|
71
|
+
"use server";
|
|
72
|
+
import { auth } from "@trigger.dev/sdk";
|
|
73
|
+
import { chat } from "@trigger.dev/sdk/ai";
|
|
74
|
+
|
|
75
|
+
// Creates the Session + first run, returns a session PAT. Idempotent on (env, chatId).
|
|
76
|
+
export const startChatSession = chat.createStartSessionAction("my-chat");
|
|
77
|
+
|
|
78
|
+
// Pure mint. The transport calls this on 401/403 to refresh an expired token.
|
|
79
|
+
export async function mintChatAccessToken(chatId: string) {
|
|
80
|
+
return auth.createPublicToken({
|
|
81
|
+
scopes: { read: { sessions: chatId }, write: { sessions: chatId } },
|
|
82
|
+
expirationTime: "1h",
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 3. Wire the frontend
|
|
88
|
+
|
|
89
|
+
```tsx app/components/chat.tsx
|
|
90
|
+
"use client";
|
|
91
|
+
import { useState } from "react";
|
|
92
|
+
import { useChat } from "@ai-sdk/react";
|
|
93
|
+
import { useTriggerChatTransport } from "@trigger.dev/sdk/chat/react";
|
|
94
|
+
import type { myChat } from "@/trigger/chat";
|
|
95
|
+
import { mintChatAccessToken, startChatSession } from "@/app/actions";
|
|
96
|
+
|
|
97
|
+
export function Chat() {
|
|
98
|
+
const transport = useTriggerChatTransport<typeof myChat>({
|
|
99
|
+
task: "my-chat", // typeof myChat gives compile-time task-id validation
|
|
100
|
+
accessToken: ({ chatId }) => mintChatAccessToken(chatId),
|
|
101
|
+
startSession: ({ chatId, clientData }) => startChatSession({ chatId, clientData }),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const { messages, sendMessage, stop, status } = useChat({ transport });
|
|
105
|
+
const [input, setInput] = useState("");
|
|
106
|
+
// render messages, a form that calls sendMessage({ text: input }),
|
|
107
|
+
// and a Stop button (onClick={stop}) while status === "streaming".
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The transport is memoized (created once, reused across renders). Passing `typeof myChat` flows the
|
|
112
|
+
agent's message type through `useChat`.
|
|
113
|
+
|
|
114
|
+
## Core patterns
|
|
115
|
+
|
|
116
|
+
### 1. Return vs pipe
|
|
117
|
+
|
|
118
|
+
Return the `streamText` result from `run` for the simple case. When `streamText` is called deep
|
|
119
|
+
inside nested helpers, call `await chat.pipe(result)` from anywhere in the task instead, and let
|
|
120
|
+
`run` resolve `void`.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { chat, type ChatStreamText } from "@trigger.dev/sdk/ai";
|
|
124
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
125
|
+
import type { ModelMessage } from "ai";
|
|
126
|
+
|
|
127
|
+
export const agentChat = chat.agent({
|
|
128
|
+
id: "agent-chat",
|
|
129
|
+
run: async ({ messages, streamText }) => {
|
|
130
|
+
await runAgentLoop(messages, streamText); // don't return; pipe inside
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// A loop factored out of `run` takes `streamText` as an argument, so it keeps the
|
|
135
|
+
// managed options. `ChatStreamText` (from `@trigger.dev/sdk/ai`) types the parameter.
|
|
136
|
+
// `chat.toStreamTextOptions()` is the alternative when threading it down is impractical.
|
|
137
|
+
async function runAgentLoop(messages: ModelMessage[], streamText: ChatStreamText) {
|
|
138
|
+
const result = streamText({
|
|
139
|
+
model: anthropic("claude-sonnet-4-5"),
|
|
140
|
+
messages,
|
|
141
|
+
});
|
|
142
|
+
await chat.pipe(result); // works from anywhere in the task
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 2. Typed tools (declare on config AND pass back)
|
|
147
|
+
|
|
148
|
+
Declare tools on `chat.agent({ tools })`, read them back typed from the `run()` payload, and pass
|
|
149
|
+
that set as `tools`. One declaration flows everywhere.
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import { tool, stepCountIs } from "ai";
|
|
153
|
+
import { z } from "zod";
|
|
154
|
+
|
|
155
|
+
const tools = {
|
|
156
|
+
searchDocs: tool({
|
|
157
|
+
description: "Search the docs.",
|
|
158
|
+
inputSchema: z.object({ query: z.string() }),
|
|
159
|
+
execute: async ({ query }) => searchIndex(query),
|
|
160
|
+
}),
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export const myChat = chat.agent({
|
|
164
|
+
id: "my-chat",
|
|
165
|
+
tools, // so toModelOutput survives across turns
|
|
166
|
+
run: async ({ messages, tools, signal, streamText }) =>
|
|
167
|
+
streamText({
|
|
168
|
+
model: anthropic("claude-sonnet-4-5"),
|
|
169
|
+
messages,
|
|
170
|
+
tools, // same set, handed back typed
|
|
171
|
+
abortSignal: signal,
|
|
172
|
+
stopWhen: stepCountIs(15),
|
|
173
|
+
}),
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`tools` also accepts a function `(event) => ToolSet` resolved per turn, where `event` carries
|
|
178
|
+
`chatId`, `turn`, `continuation`, and `clientData`.
|
|
179
|
+
|
|
180
|
+
### 3. Custom data parts (persisted vs transient)
|
|
181
|
+
|
|
182
|
+
`data-*` parts written via `chat.response.write()` in `run()` (or `writer.write()` in hooks)
|
|
183
|
+
persist into `responseMessage.parts` and surface in `onTurnComplete`. Add `transient: true` to
|
|
184
|
+
stream them without persisting. Writes via `chat.stream` are always ephemeral.
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
// In run() - persists, surfaces in onTurnComplete's responseMessage
|
|
188
|
+
chat.response.write({ type: "data-context", data: { searchResults } });
|
|
189
|
+
|
|
190
|
+
// In a hook via writer - streams but does NOT persist
|
|
191
|
+
writer.write({ type: "data-progress", id: "search", data: { percent: 50 }, transient: true });
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### 4. Custom UIMessage type, client data, and builder hooks
|
|
195
|
+
|
|
196
|
+
For typed `data-*` parts or a tool map, build the agent through `chat.withUIMessage<T>()` and
|
|
197
|
+
`chat.withClientData({ schema })`. Builder methods chain in any order; builder hooks run before the
|
|
198
|
+
matching task hook. `streamOptions` becomes the default `uiMessageStreamOptions` (shallow-merged,
|
|
199
|
+
agent wins).
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
export const myChat = chat
|
|
203
|
+
.withUIMessage<MyChatUIMessage>({ streamOptions: { sendReasoning: true } })
|
|
204
|
+
.withClientData({ schema: z.object({ userId: z.string() }) })
|
|
205
|
+
.agent({
|
|
206
|
+
id: "my-chat",
|
|
207
|
+
tools: myTools,
|
|
208
|
+
onTurnStart: async ({ uiMessages, writer }) => {
|
|
209
|
+
writer.write({ type: "data-turn-status", data: { status: "preparing" } });
|
|
210
|
+
},
|
|
211
|
+
run: async ({ messages, tools, signal, streamText }) =>
|
|
212
|
+
streamText({ model, messages, tools, abortSignal: signal }),
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Build `MyChatUIMessage` as `UIMessage<unknown, MyDataTypes, InferUITools<typeof tools>>` (or, for
|
|
217
|
+
tools only, `InferChatUIMessageFromTools<typeof tools>` from `@trigger.dev/sdk/ai`). On the
|
|
218
|
+
frontend, narrow `useChat` with `InferChatUIMessage<typeof myChat>` from `@trigger.dev/sdk/chat/react`.
|
|
219
|
+
|
|
220
|
+
### 5. Lifecycle hooks and stop
|
|
221
|
+
|
|
222
|
+
`chat.agent` accepts hooks that fire in a fixed per-turn order:
|
|
223
|
+
|
|
224
|
+
```text
|
|
225
|
+
onValidateMessages -> storage.loadContext (or the deprecated hydrateMessages)
|
|
226
|
+
-> onChatStart (chat's first message only)
|
|
227
|
+
-> onTurnStart -> run() -> onBeforeTurnComplete -> onTurnComplete -> storage.save
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
`onBoot` fires once per worker process (every fresh boot, including continuation runs) and is where
|
|
231
|
+
`chat.local`, DB connections, and per-process state belong. `onChatStart` fires only on the chat's
|
|
232
|
+
first message. Suspend/resume use `onChatSuspend` / `onChatResume`. Config options include
|
|
233
|
+
`tools`, `clientDataSchema`, `maxTurns` (100), `turnTimeout` ("1h"), `idleTimeoutInSeconds` (30),
|
|
234
|
+
`uiMessageStreamOptions`, and `exitAfterPreloadIdle`. There is no generic `retry`; `chat.agent`
|
|
235
|
+
runs with `maxAttempts: 1` internally.
|
|
236
|
+
|
|
237
|
+
Stop depends on it: the `signal` passed to `run` aborts on stop or cancel. Forward it as
|
|
238
|
+
`abortSignal` to `streamText`, or the Stop button updates the UI while the model keeps generating
|
|
239
|
+
server-side.
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
run: async ({ messages, signal, streamText }) =>
|
|
243
|
+
streamText({ model, messages, abortSignal: signal, stopWhen: stepCountIs(15) });
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### 6. Migrating from a plain AI SDK `streamText` route
|
|
247
|
+
|
|
248
|
+
There is no API route in this model. The transport replaces the route round-trip, so:
|
|
249
|
+
|
|
250
|
+
- Delete the route handler. Move per-request auth into the two server actions from Setup step 2.
|
|
251
|
+
- Move the `streamText` call into `run`. It already receives pre-converted `ModelMessage[]`.
|
|
252
|
+
- Return the `StreamTextResult` (it auto-pipes) and take `streamText` from `run`'s argument, not from `ai`.
|
|
253
|
+
- On the client, swap the `api` URL for `useTriggerChatTransport`; `useChat` stays the same shape.
|
|
254
|
+
|
|
255
|
+
## Common mistakes
|
|
256
|
+
|
|
257
|
+
- **CRITICAL: calling the `streamText` imported from `ai`.**
|
|
258
|
+
```ts
|
|
259
|
+
// Wrong - compaction / steering / background injection silently no-op
|
|
260
|
+
import { streamText } from "ai";
|
|
261
|
+
run: async ({ messages, signal }) => streamText({ model, messages, abortSignal: signal });
|
|
262
|
+
// Correct - the run argument's streamText carries the managed options
|
|
263
|
+
run: async ({ messages, signal, streamText }) => streamText({ model, messages, abortSignal: signal });
|
|
264
|
+
```
|
|
265
|
+
The SDK's one carries the `prepareStep` behind compaction, mid-turn steering and background
|
|
266
|
+
injection, the system prompt from `chat.prompt()` or `chat.agent({ system })`, the registry-resolved
|
|
267
|
+
model, and telemetry. The imported one carries none of it, with no error.
|
|
268
|
+
`...chat.toStreamTextOptions()` does the same job by hand, and is what a custom agent has to use,
|
|
269
|
+
since it has no `run` argument. A `chat.headStart` route gets a bound `streamText` too, and there it
|
|
270
|
+
also owns `messages`, `prompt`, `stopWhen` and `abortSignal`. Spreading it and then re-setting
|
|
271
|
+
`tools` or `prepareStep` replaces the managed ones; the run argument's `streamText` merges `tools`
|
|
272
|
+
and composes `prepareStep` instead.
|
|
273
|
+
|
|
274
|
+
- **Declaring tools only on `streamText`.** Also declare them on `chat.agent({ tools })`, read them
|
|
275
|
+
back from `run`, and pass that set as `tools`. Otherwise each tool's
|
|
276
|
+
`toModelOutput` runs on turn 1 but is dropped when history is re-converted on later turns.
|
|
277
|
+
|
|
278
|
+
- **Not forwarding `signal` for stop.** Without `abortSignal: signal`, Stop updates the UI but the
|
|
279
|
+
model keeps generating server-side.
|
|
280
|
+
|
|
281
|
+
- **Initializing `chat.local` in `onChatStart`.** Initialize it in `onBoot`. `onChatStart` fires
|
|
282
|
+
once per chat, so continuation runs skip it and crash with
|
|
283
|
+
`chat.local can only be modified after initialization`. `onBoot` fires on every fresh worker.
|
|
284
|
+
|
|
285
|
+
- **Minting tokens in the browser.** Never expose the environment secret key client-side. Mint via
|
|
286
|
+
the two server actions; the transport calls them.
|
|
287
|
+
|
|
288
|
+
- **Clearing `lastEventId` on `chat.endRun()`.** Keep the cursor for the Session lifetime; clear it
|
|
289
|
+
only when the Session itself closes. It is sessionId-keyed, so clearing forces a resubscribe from
|
|
290
|
+
`seq_num=0` that can hit the prior turn's stale `turn-complete` and close the stream empty.
|
|
291
|
+
|
|
292
|
+
- **Returning the raw error from `uiMessageStreamOptions.onError`.** It leaks internals (keys,
|
|
293
|
+
stack traces). Return a sanitized string instead.
|
|
294
|
+
|
|
295
|
+
## References
|
|
296
|
+
|
|
297
|
+
- `trigger-chat-agent-advanced` skill - lifecycle hooks in depth, sessions, raw-task primitives
|
|
298
|
+
(`chat.createSession`, `chat.customAgent`, `chat.stream`), compaction, HITL approvals, recovery.
|
|
299
|
+
- `trigger-realtime-and-frontend` skill - Realtime hooks and frontend streaming beyond the chat transport.
|
|
300
|
+
- `trigger-authoring-tasks` skill - base `task()` semantics, `ctx`, and standard lifecycle hooks.
|
|
301
|
+
|
|
302
|
+
Reference docs ship beside this skill in the same package, read them locally (no network), pinned to your installed version. The `sources:` frontmatter above lists every doc this skill draws from, all under `@trigger.dev/sdk/docs/ai-chat/`. Start with `quick-start.mdx`, `backend.mdx`, `tools.mdx`, `types.mdx`, `frontend.mdx`.
|
|
303
|
+
|
|
304
|
+
A `chat.agent` is a Trigger.dev task, so it builds and deploys like any other. For `trigger.config.ts` and build extensions (Prisma, Playwright, Python, FFmpeg, etc. — e.g. when a tool needs them), read the bundled config docs under `@trigger.dev/sdk/docs/config/` (extensions are in `config/extensions/`, starting with `overview.mdx`).
|
|
305
|
+
|
|
306
|
+
## Version
|
|
307
|
+
|
|
308
|
+
This skill is bundled inside `@trigger.dev/sdk` and read directly from `node_modules`, so it always matches your installed SDK version (see the adjacent `package.json`). The full documentation for these APIs ships alongside it under `@trigger.dev/sdk/docs/`.
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: trigger-authoring-tasks
|
|
3
|
+
description: >
|
|
4
|
+
Covers writing backend Trigger.dev tasks with @trigger.dev/sdk: defining task() and
|
|
5
|
+
schemaTask(), the run function and its ctx, retries, waits, queues and concurrency,
|
|
6
|
+
idempotency keys, run metadata, logging, triggering other tasks (and the Result shape),
|
|
7
|
+
scheduled/cron tasks, and the essentials of trigger.config.ts. Load this whenever you are
|
|
8
|
+
authoring or editing code inside a /trigger directory, defining a task, or writing backend
|
|
9
|
+
code that triggers tasks. Realtime/React hooks and AI chat are covered by separate skills.
|
|
10
|
+
type: core
|
|
11
|
+
library: trigger.dev
|
|
12
|
+
sources:
|
|
13
|
+
- docs/tasks/overview.mdx
|
|
14
|
+
- docs/tasks/schemaTask.mdx
|
|
15
|
+
- docs/tasks/scheduled.mdx
|
|
16
|
+
- docs/triggering.mdx
|
|
17
|
+
- docs/queue-concurrency.mdx
|
|
18
|
+
- docs/idempotency.mdx
|
|
19
|
+
- docs/runs/metadata.mdx
|
|
20
|
+
- docs/logging.mdx
|
|
21
|
+
- docs/errors-retrying.mdx
|
|
22
|
+
- docs/wait.mdx
|
|
23
|
+
- docs/wait-for.mdx
|
|
24
|
+
- docs/wait-until.mdx
|
|
25
|
+
- docs/wait-for-token.mdx
|
|
26
|
+
- docs/context.mdx
|
|
27
|
+
- docs/config/config-file.mdx
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
# Authoring Trigger.dev Tasks
|
|
31
|
+
|
|
32
|
+
Tasks are functions that can run for a long time with strong resilience to failure. Define them in files under your `/trigger` directory. Always import from `@trigger.dev/sdk`. Never import from `@trigger.dev/sdk/v3` (deprecated alias) or `@trigger.dev/core`.
|
|
33
|
+
|
|
34
|
+
## Setup
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
// /trigger/hello-world.ts
|
|
38
|
+
import { task } from "@trigger.dev/sdk";
|
|
39
|
+
|
|
40
|
+
export const helloWorld = task({
|
|
41
|
+
id: "hello-world", // unique within the project
|
|
42
|
+
run: async (payload: { message: string }, { ctx }) => {
|
|
43
|
+
console.log(payload.message, "attempt", ctx.attempt.number);
|
|
44
|
+
return { ok: true }; // must be JSON serializable
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The `run` function receives the payload and a second argument with `ctx` (run context), an abort `signal`, and a deprecated `init` output. The return value is the task output and must be JSON serializable.
|
|
50
|
+
|
|
51
|
+
## Core patterns
|
|
52
|
+
|
|
53
|
+
### 1. Validate the payload with `schemaTask`
|
|
54
|
+
|
|
55
|
+
`schema` accepts a Zod / Yup / Superstruct / ArkType / valibot / typebox parser or a custom `(data: unknown) => T` function. A validation failure throws `TaskPayloadParsedError` and skips retrying.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { schemaTask } from "@trigger.dev/sdk";
|
|
59
|
+
import { z } from "zod";
|
|
60
|
+
|
|
61
|
+
export const createUser = schemaTask({
|
|
62
|
+
id: "create-user",
|
|
63
|
+
schema: z.object({ name: z.string(), age: z.number() }),
|
|
64
|
+
run: async (payload) => ({ greeting: `Hi ${payload.name}` }),
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 2. Configure retries and abort early
|
|
69
|
+
|
|
70
|
+
The default `maxAttempts` is 3. Throw `AbortTaskRunError` to stop retrying immediately. Task-level `retry` overrides the config-file defaults.
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { task, AbortTaskRunError } from "@trigger.dev/sdk";
|
|
74
|
+
|
|
75
|
+
export const charge = task({
|
|
76
|
+
id: "charge",
|
|
77
|
+
retry: { maxAttempts: 5, factor: 1.8, minTimeoutInMs: 500, maxTimeoutInMs: 30_000, randomize: true },
|
|
78
|
+
run: async (payload: { amount: number }) => {
|
|
79
|
+
if (payload.amount <= 0) throw new AbortTaskRunError("Invalid amount"); // no retry
|
|
80
|
+
// work that may throw and retry
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
For finer control, `catchError: async ({ payload, error, ctx, retryAt }) => {...}` can return `{ skipRetrying: true }`, `{ retryAt: Date }`, or `undefined` (use normal logic). `retry.onThrow`, `retry.fetch`, also exist for in-task retrying.
|
|
86
|
+
|
|
87
|
+
### 3. Trigger another task and handle the Result
|
|
88
|
+
|
|
89
|
+
From inside a task use `yourTask.triggerAndWait(payload)`. The result is a Result object that you must check (`ok`), or `.unwrap()` to throw on failure.
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
export const parentTask = task({
|
|
93
|
+
id: "parent-task",
|
|
94
|
+
run: async () => {
|
|
95
|
+
const result = await childTask.triggerAndWait({ data: "x" });
|
|
96
|
+
if (result.ok) return result.output; // typed child output
|
|
97
|
+
console.error("child failed", result.error);
|
|
98
|
+
// or: const output = await childTask.triggerAndWait({ data: "x" }).unwrap();
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`SubtaskUnwrapError` carries `runId`, `taskId`, and `cause`. For fan-out use `childTask.batchTriggerAndWait([{ payload: a }, { payload: b }])`; the result has a `.runs` array, each entry `{ ok, id, output?, error?, taskIdentifier }`.
|
|
104
|
+
|
|
105
|
+
### 4. Trigger from backend code with a type-only import
|
|
106
|
+
|
|
107
|
+
Outside a task, import the task type only and trigger by id. Do not import the task instance into backend bundles.
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { tasks } from "@trigger.dev/sdk";
|
|
111
|
+
import type { emailSequence } from "~/trigger/emails";
|
|
112
|
+
|
|
113
|
+
const handle = await tasks.trigger<typeof emailSequence>(
|
|
114
|
+
"email-sequence",
|
|
115
|
+
{ to: "a@b.com", name: "Ada" },
|
|
116
|
+
{ delay: "1h" }
|
|
117
|
+
);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`tasks.batchTrigger` and `batch.trigger([{ id, payload }])` cover batches. Trigger options include `delay`, `ttl`, `idempotencyKey`, `idempotencyKeyTTL`, `debounce`, `queue`, `concurrencyKey`, `maxAttempts`, `tags`, `metadata`, `priority`, `region`, and `machine`. Inspect runs with `runs.retrieve`, `runs.cancel`, and `runs.reschedule`.
|
|
121
|
+
|
|
122
|
+
### 5. Idempotency keys
|
|
123
|
+
|
|
124
|
+
`idempotencyKeys.create(key, { scope })` returns a 64-char hashed key. A raw string key defaults to `"run"` scope (v4.3.1+); for once-ever behavior use `scope: "global"`.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import { idempotencyKeys, task } from "@trigger.dev/sdk";
|
|
128
|
+
|
|
129
|
+
export const processOrder = task({
|
|
130
|
+
id: "process-order",
|
|
131
|
+
run: async (payload: { orderId: string; email: string }) => {
|
|
132
|
+
const key = await idempotencyKeys.create(`confirm-${payload.orderId}`);
|
|
133
|
+
await sendEmail.trigger({ to: payload.email }, { idempotencyKey: key });
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 6. Waits and run metadata
|
|
139
|
+
|
|
140
|
+
`wait.for({ seconds })` and `wait.until({ date })` durably pause the run. `metadata.*` is readable and writable only inside `run()`; updates are synchronous and chainable (`set`, `del`, `replace`, `append`, `remove`, `increment`, `decrement`).
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { task, metadata, wait } from "@trigger.dev/sdk";
|
|
144
|
+
|
|
145
|
+
export const importer = task({
|
|
146
|
+
id: "importer",
|
|
147
|
+
run: async (payload: { rows: unknown[] }) => {
|
|
148
|
+
metadata.set("status", "processing").set("total", payload.rows.length);
|
|
149
|
+
await wait.for({ seconds: 5 });
|
|
150
|
+
metadata.set("status", "complete");
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
For human-in-the-loop, `wait.createToken({ timeout, tags })` returns `{ id, url, publicAccessToken, ... }`; resume with `wait.forToken<T>(token: string | { id: string })` which returns `{ ok, output?, error? }` (or `.unwrap()`), and complete it elsewhere with `wait.completeToken(tokenId, output)`. Metadata max is 256KB and is not propagated to child tasks; push values to a parent with `metadata.parent.*` / `metadata.root.*`. (`metadata.stream` is deprecated since 4.1.0 in favor of `streams.pipe()`.)
|
|
156
|
+
|
|
157
|
+
### 7. Scheduled (cron) tasks
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
import { schedules } from "@trigger.dev/sdk";
|
|
161
|
+
|
|
162
|
+
export const dailyReport = schedules.task({
|
|
163
|
+
id: "daily-report",
|
|
164
|
+
cron: { pattern: "0 5 * * *", timezone: "Asia/Tokyo" },
|
|
165
|
+
run: async (payload) => {
|
|
166
|
+
console.log("scheduled at", payload.timestamp, "next", payload.upcoming);
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
The payload includes `timestamp`, `lastTimestamp`, `timezone`, `scheduleId`, `externalId`, and `upcoming`. Attach schedules dynamically with `schedules.create({ task, cron, timezone?, externalId?, deduplicationKey })` (the dedup key is required and per-project), plus `retrieve / list / update / activate / deactivate / del / timezones`.
|
|
172
|
+
|
|
173
|
+
### 8. Queues and concurrency
|
|
174
|
+
|
|
175
|
+
Set `queue: { concurrencyLimit }` on a task, or share a queue across tasks:
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
import { queue, task } from "@trigger.dev/sdk";
|
|
179
|
+
|
|
180
|
+
export const emails = queue({ name: "emails", concurrencyLimit: 5 });
|
|
181
|
+
|
|
182
|
+
export const sendEmail = task({ id: "send-email", queue: emails, run: async () => {} });
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
At trigger time override with `{ queue: "queue-name" }` and add `concurrencyKey` for per-tenant queues. Manage queues with `queues.list / retrieve / pause / resume / overrideConcurrencyLimit / resetConcurrencyLimit`.
|
|
186
|
+
|
|
187
|
+
### 9. `trigger.config.ts` essentials
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
import { defineConfig } from "@trigger.dev/sdk";
|
|
191
|
+
|
|
192
|
+
export default defineConfig({
|
|
193
|
+
project: "<project ref>",
|
|
194
|
+
dirs: ["./trigger"],
|
|
195
|
+
machine: "small-1x",
|
|
196
|
+
retries: {
|
|
197
|
+
enabledInDev: false,
|
|
198
|
+
default: { maxAttempts: 3, factor: 2, minTimeoutInMs: 1000, maxTimeoutInMs: 10000, randomize: true },
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
`build.external` controls which packages stay out of the bundle. Build extensions (`additionalFiles`, `prismaExtension`, `puppeteer`, `playwright`, `ffmpeg`, `pythonExtension`, `aptGet`, `syncEnvVars`, etc.) come from `@trigger.dev/build`. `telemetry` configures instrumentations and exporters. Each extension has its own setup doc, all bundled under `@trigger.dev/sdk/docs/config/extensions/` (start with `overview.mdx`); read the one you need before wiring it up rather than guessing the API.
|
|
204
|
+
|
|
205
|
+
### Logging
|
|
206
|
+
|
|
207
|
+
`logger.debug / log / info / warn / error(message, dataRecord?)` write structured logs; `logger.trace(name, async (span) => {...})` adds a span. Module-level metrics use `otel.metrics.getMeter(name)`.
|
|
208
|
+
|
|
209
|
+
## Common mistakes
|
|
210
|
+
|
|
211
|
+
1. **CRITICAL: Treating the wait result as the output.** `triggerAndWait` and `wait.forToken` return a Result object, not the raw output.
|
|
212
|
+
- Wrong: `const out = await childTask.triggerAndWait(p); use(out.foo);`
|
|
213
|
+
- Correct: `const r = await childTask.triggerAndWait(p); if (r.ok) use(r.output.foo);` (or `.unwrap()`).
|
|
214
|
+
|
|
215
|
+
2. **Wrapping `triggerAndWait` / `batchTriggerAndWait` / `wait` in `Promise.all`.**
|
|
216
|
+
- Wrong: `await Promise.all([childTask.triggerAndWait(a), childTask.triggerAndWait(b)]);`
|
|
217
|
+
- Correct: `await childTask.batchTriggerAndWait([{ payload: a }, { payload: b }]);` (or a sequential for-loop).
|
|
218
|
+
|
|
219
|
+
3. **Importing the task instance into backend code.**
|
|
220
|
+
- Wrong: `import { emailSequence } from "~/trigger/emails";` in a route handler.
|
|
221
|
+
- Correct: `import type { emailSequence }` plus `tasks.trigger<typeof emailSequence>("email-sequence", payload)`.
|
|
222
|
+
|
|
223
|
+
4. **Calling `metadata.set/get` outside `run()`.**
|
|
224
|
+
- Wrong: setting metadata at module scope or in unrelated backend code (a no-op; `get` returns `undefined`).
|
|
225
|
+
- Correct: call inside `run()` or a task lifecycle hook.
|
|
226
|
+
|
|
227
|
+
5. **Assuming child tasks inherit the parent's queue or metadata.**
|
|
228
|
+
- Wrong: expecting a subtask to share the parent's `concurrencyLimit` or see its metadata.
|
|
229
|
+
- Correct: subtasks run on their own queue; pass metadata explicitly via `{ metadata: metadata.current() }`, or push up with `metadata.parent.*`.
|
|
230
|
+
|
|
231
|
+
6. **Bundling native/WASM packages.**
|
|
232
|
+
- Wrong: leaving `sharp`, `re2`, `sqlite3`, or WASM packages in the default bundle.
|
|
233
|
+
- Correct: add them to `build.external` in `trigger.config.ts`.
|
|
234
|
+
|
|
235
|
+
7. **Relying on a raw string idempotency key being global.**
|
|
236
|
+
- Wrong: `trigger(p, { idempotencyKey: "welcome-email" })` expecting once-ever (true only in v4.3.0 and earlier).
|
|
237
|
+
- Correct: `await idempotencyKeys.create("welcome-email", { scope: "global" })`.
|
|
238
|
+
|
|
239
|
+
## References
|
|
240
|
+
|
|
241
|
+
Sibling skills:
|
|
242
|
+
|
|
243
|
+
- **trigger-realtime-and-frontend** for subscribing to runs and triggering from the frontend with React hooks.
|
|
244
|
+
- **trigger-authoring-chat-agent** and **trigger-chat-agent-advanced** for building AI chat agents.
|
|
245
|
+
|
|
246
|
+
Reference docs ship beside this skill in the same package, read them locally (no network), pinned to your installed version. The `sources:` frontmatter above lists every doc this skill draws from, all under `@trigger.dev/sdk/docs/`. Start with:
|
|
247
|
+
|
|
248
|
+
- `@trigger.dev/sdk/docs/tasks/overview.mdx`
|
|
249
|
+
- `@trigger.dev/sdk/docs/triggering.mdx`
|
|
250
|
+
- `@trigger.dev/sdk/docs/config/config-file.mdx`
|
|
251
|
+
|
|
252
|
+
## Version
|
|
253
|
+
|
|
254
|
+
This skill is bundled inside `@trigger.dev/sdk` and read directly from `node_modules`, so it always matches your installed SDK version (see the adjacent `package.json`). The full documentation for these APIs ships alongside it under `@trigger.dev/sdk/docs/`.
|