@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,426 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Prompts"
|
|
3
|
+
sidebarTitle: "Prompts"
|
|
4
|
+
description: "Define prompt templates as code, version them on deploy, and override from the dashboard without redeploying."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
AI Prompts let you define prompt templates in your codebase alongside your tasks. When you deploy, Trigger.dev automatically versions your prompts. You can then:
|
|
10
|
+
|
|
11
|
+
- View all prompt versions in the dashboard
|
|
12
|
+
- Create **overrides** to change the prompt text or model without redeploying
|
|
13
|
+
- Track every generation that used each prompt version
|
|
14
|
+
- See token usage, cost, and latency metrics per prompt
|
|
15
|
+
- Manage prompts programmatically via SDK methods
|
|
16
|
+
|
|
17
|
+
## Defining a prompt
|
|
18
|
+
|
|
19
|
+
Use `prompts.define()` to create a prompt with typed variables:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { prompts } from "@trigger.dev/sdk";
|
|
23
|
+
import { z } from "zod";
|
|
24
|
+
|
|
25
|
+
export const supportPrompt = prompts.define({
|
|
26
|
+
id: "customer-support",
|
|
27
|
+
description: "System prompt for customer support interactions",
|
|
28
|
+
model: "gpt-4o",
|
|
29
|
+
config: { temperature: 0.7 },
|
|
30
|
+
variables: z.object({
|
|
31
|
+
customerName: z.string(),
|
|
32
|
+
plan: z.string(),
|
|
33
|
+
issue: z.string(),
|
|
34
|
+
}),
|
|
35
|
+
content: `You are a support agent for Acme SaaS.
|
|
36
|
+
|
|
37
|
+
## Customer context
|
|
38
|
+
|
|
39
|
+
- **Name:** {{customerName}}
|
|
40
|
+
- **Plan:** {{plan}}
|
|
41
|
+
- **Issue:** {{issue}}
|
|
42
|
+
|
|
43
|
+
Respond to the customer's issue. Be concise and helpful.`,
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Options
|
|
48
|
+
|
|
49
|
+
| Option | Type | Required | Description |
|
|
50
|
+
|--------|------|----------|-------------|
|
|
51
|
+
| `id` | `string` | Yes | Unique identifier (becomes the prompt slug) |
|
|
52
|
+
| `description` | `string` | No | Shown in the dashboard |
|
|
53
|
+
| `model` | `string` | No | Default model (e.g. `"gpt-4o"`, `"claude-sonnet-4-6"`) |
|
|
54
|
+
| `config` | `object` | No | Default config (temperature, maxTokens, etc.) |
|
|
55
|
+
| `variables` | Zod/ArkType schema | No | Schema for template variables (enables validation and dashboard UI) |
|
|
56
|
+
| `content` | `string` | Yes | The prompt template with `{{variable}}` placeholders |
|
|
57
|
+
|
|
58
|
+
### Template syntax
|
|
59
|
+
|
|
60
|
+
Templates use Mustache-style placeholders:
|
|
61
|
+
|
|
62
|
+
- `{{variableName}}` — replaced with the variable value
|
|
63
|
+
- `{{#conditionalVar}}...{{/conditionalVar}}` — content only included if the variable is truthy
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
export const prompt = prompts.define({
|
|
67
|
+
id: "summarizer",
|
|
68
|
+
model: "gpt-4o-mini",
|
|
69
|
+
variables: z.object({
|
|
70
|
+
text: z.string(),
|
|
71
|
+
maxSentences: z.string().optional(),
|
|
72
|
+
}),
|
|
73
|
+
content: `Summarize the following text{{#maxSentences}} in {{maxSentences}} sentences or fewer{{/maxSentences}}:
|
|
74
|
+
|
|
75
|
+
{{text}}`,
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Resolving a prompt
|
|
80
|
+
|
|
81
|
+
### Via prompt handle
|
|
82
|
+
|
|
83
|
+
Call `.resolve()` on the handle returned by `define()`:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
const resolved = await supportPrompt.resolve({
|
|
87
|
+
customerName: "Alice",
|
|
88
|
+
plan: "Pro",
|
|
89
|
+
issue: "Cannot access billing dashboard",
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
console.log(resolved.text); // The compiled prompt with variables filled in
|
|
93
|
+
console.log(resolved.version); // e.g. 3
|
|
94
|
+
console.log(resolved.model); // "gpt-4o"
|
|
95
|
+
console.log(resolved.labels); // ["current"] or ["override"]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Via standalone prompts.resolve()
|
|
99
|
+
|
|
100
|
+
Resolve any prompt by slug without needing a handle. Pass the prompt handle as a type parameter for full type safety:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { prompts } from "@trigger.dev/sdk";
|
|
104
|
+
import type { supportPrompt } from "./prompts";
|
|
105
|
+
|
|
106
|
+
// Fully typesafe — ID and variables are checked at compile time
|
|
107
|
+
const resolved = await prompts.resolve<typeof supportPrompt>("customer-support", {
|
|
108
|
+
customerName: "Alice",
|
|
109
|
+
plan: "Pro",
|
|
110
|
+
issue: "Cannot access billing dashboard",
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Without the generic, the function still works but accepts any string slug and `Record<string, unknown>` variables.
|
|
115
|
+
|
|
116
|
+
### Resolve options
|
|
117
|
+
|
|
118
|
+
You can resolve a specific version or label:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
// Resolve a specific version
|
|
122
|
+
const v2 = await supportPrompt.resolve(variables, { version: 2 });
|
|
123
|
+
|
|
124
|
+
// Resolve by label
|
|
125
|
+
const current = await supportPrompt.resolve(variables, { label: "current" });
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
By default, `resolve()` returns the **override** version if one is active, otherwise the **current** (latest deployed) version.
|
|
129
|
+
|
|
130
|
+
<Note>
|
|
131
|
+
Both `promptHandle.resolve()` and `prompts.resolve()` call the Trigger.dev API when a client is configured. During local dev with `trigger dev`, this means you'll always get the server version (including overrides).
|
|
132
|
+
</Note>
|
|
133
|
+
|
|
134
|
+
## Using with the AI SDK
|
|
135
|
+
|
|
136
|
+
The resolved prompt integrates with the [Vercel AI SDK](https://ai-sdk.dev) via `toAISDKTelemetry()`. This links AI generation spans to the prompt in the dashboard.
|
|
137
|
+
|
|
138
|
+
### generateText
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import { task } from "@trigger.dev/sdk";
|
|
142
|
+
import { generateText, stepCountIs } from "ai";
|
|
143
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
144
|
+
|
|
145
|
+
export const supportTask = task({
|
|
146
|
+
id: "handle-support",
|
|
147
|
+
run: async (payload) => {
|
|
148
|
+
const resolved = await supportPrompt.resolve({
|
|
149
|
+
customerName: payload.name,
|
|
150
|
+
plan: payload.plan,
|
|
151
|
+
issue: payload.issue,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const result = await generateText({
|
|
155
|
+
model: openai(resolved.model ?? "gpt-4o"),
|
|
156
|
+
system: resolved.text,
|
|
157
|
+
prompt: payload.issue,
|
|
158
|
+
...resolved.toAISDKTelemetry(),
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return { response: result.text };
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### streamText
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
import { streamText } from "ai";
|
|
170
|
+
|
|
171
|
+
export const streamTask = task({
|
|
172
|
+
id: "stream-support",
|
|
173
|
+
run: async (payload) => {
|
|
174
|
+
const resolved = await supportPrompt.resolve({
|
|
175
|
+
customerName: payload.name,
|
|
176
|
+
plan: payload.plan,
|
|
177
|
+
issue: payload.issue,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const result = streamText({
|
|
181
|
+
model: openai(resolved.model ?? "gpt-4o"),
|
|
182
|
+
system: resolved.text,
|
|
183
|
+
prompt: payload.issue,
|
|
184
|
+
...resolved.toAISDKTelemetry(),
|
|
185
|
+
stopWhen: stepCountIs(15),
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
let fullText = "";
|
|
189
|
+
for await (const chunk of result.textStream) {
|
|
190
|
+
fullText += chunk;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return { response: fullText };
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Custom telemetry metadata
|
|
199
|
+
|
|
200
|
+
Pass additional metadata to `toAISDKTelemetry()` that will appear on the generation span:
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
const result = await generateText({
|
|
204
|
+
model: anthropic("claude-sonnet-4-5"),
|
|
205
|
+
prompt: resolved.text,
|
|
206
|
+
...resolved.toAISDKTelemetry({
|
|
207
|
+
"task.type": "summarization",
|
|
208
|
+
"customer.tier": "enterprise",
|
|
209
|
+
}),
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Using with chat.agent()
|
|
214
|
+
|
|
215
|
+
Prompts integrate with `chat.agent()` via `chat.prompt` — a run-scoped store for the resolved prompt. Store a prompt once in a lifecycle hook, then access it anywhere during the run.
|
|
216
|
+
|
|
217
|
+
### chat.prompt.set() and chat.prompt()
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
import { chat } from "@trigger.dev/sdk/ai";
|
|
221
|
+
import { prompts } from "@trigger.dev/sdk";
|
|
222
|
+
import { streamText, createProviderRegistry } from "ai";
|
|
223
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
224
|
+
|
|
225
|
+
const registry = createProviderRegistry({ anthropic });
|
|
226
|
+
|
|
227
|
+
const systemPrompt = prompts.define({
|
|
228
|
+
id: "my-chat-system",
|
|
229
|
+
model: "anthropic:claude-sonnet-4-5",
|
|
230
|
+
config: { temperature: 0.7 },
|
|
231
|
+
variables: z.object({ name: z.string() }),
|
|
232
|
+
content: `You are a helpful assistant for {{name}}.`,
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
export const myChat = chat.agent({
|
|
236
|
+
id: "my-chat",
|
|
237
|
+
onChatStart: async ({ clientData }) => {
|
|
238
|
+
const resolved = await systemPrompt.resolve({ name: clientData.name });
|
|
239
|
+
chat.prompt.set(resolved);
|
|
240
|
+
},
|
|
241
|
+
run: async ({ messages, signal }) => {
|
|
242
|
+
return streamText({
|
|
243
|
+
...chat.toStreamTextOptions({ registry }),
|
|
244
|
+
messages,
|
|
245
|
+
abortSignal: signal,
|
|
246
|
+
stopWhen: stepCountIs(15),
|
|
247
|
+
});
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### chat.toStreamTextOptions()
|
|
253
|
+
|
|
254
|
+
Returns an options object ready to spread into `streamText()`. When a prompt is stored via `chat.prompt.set()`, it includes:
|
|
255
|
+
|
|
256
|
+
- `system` — the compiled prompt text
|
|
257
|
+
- `model` — resolved via the `registry` when provided
|
|
258
|
+
- `temperature`, `maxTokens`, etc. — from the prompt's `config`
|
|
259
|
+
- `experimental_telemetry` — links generations to the prompt in the dashboard
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
// With registry — model is resolved automatically
|
|
263
|
+
const options = chat.toStreamTextOptions({ registry });
|
|
264
|
+
// { system: "...", model: LanguageModel, temperature: 0.7, experimental_telemetry: { ... } }
|
|
265
|
+
|
|
266
|
+
// Without registry — model is not included
|
|
267
|
+
const options = chat.toStreamTextOptions();
|
|
268
|
+
// { system: "...", temperature: 0.7, experimental_telemetry: { ... } }
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
<Tip>
|
|
272
|
+
When the user provides a `registry` and the prompt has a `model` string (e.g. `"anthropic:claude-sonnet-4-5"`), the model is resolved via `registry.languageModel()` and included in the returned options. This means `streamText` uses the prompt's model by default — no manual model selection needed.
|
|
273
|
+
</Tip>
|
|
274
|
+
|
|
275
|
+
### Reading the prompt
|
|
276
|
+
|
|
277
|
+
Access the stored prompt from anywhere in the run:
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
run: async ({ messages, signal }) => {
|
|
281
|
+
const prompt = chat.prompt(); // Throws if not set
|
|
282
|
+
console.log(prompt.text); // The compiled prompt
|
|
283
|
+
console.log(prompt.model); // "anthropic:claude-sonnet-4-5"
|
|
284
|
+
console.log(prompt.version); // 3
|
|
285
|
+
|
|
286
|
+
return streamText({
|
|
287
|
+
...chat.toStreamTextOptions({ registry }),
|
|
288
|
+
messages,
|
|
289
|
+
abortSignal: signal,
|
|
290
|
+
stopWhen: stepCountIs(15),
|
|
291
|
+
});
|
|
292
|
+
},
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
You can also set a plain string if you don't need the full prompt system:
|
|
296
|
+
|
|
297
|
+
```ts
|
|
298
|
+
chat.prompt.set("You are a helpful assistant.");
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## Prompt management SDK
|
|
302
|
+
|
|
303
|
+
The `prompts` namespace includes methods for managing prompts programmatically. These work both inside tasks and outside (e.g. scripts, API handlers) as long as an API client is configured.
|
|
304
|
+
|
|
305
|
+
### List prompts
|
|
306
|
+
|
|
307
|
+
```ts
|
|
308
|
+
const allPrompts = await prompts.list();
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### List versions
|
|
312
|
+
|
|
313
|
+
```ts
|
|
314
|
+
const versions = await prompts.versions("customer-support");
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Create an override
|
|
318
|
+
|
|
319
|
+
Create a new override that takes priority over the deployed version:
|
|
320
|
+
|
|
321
|
+
```ts
|
|
322
|
+
const result = await prompts.createOverride("customer-support", {
|
|
323
|
+
textContent: "New prompt template: Hello {{customerName}}!",
|
|
324
|
+
model: "gpt-4o-mini",
|
|
325
|
+
commitMessage: "Shorter prompt",
|
|
326
|
+
});
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Update an override
|
|
330
|
+
|
|
331
|
+
```ts
|
|
332
|
+
await prompts.updateOverride("customer-support", {
|
|
333
|
+
textContent: "Updated template: Hi {{customerName}}!",
|
|
334
|
+
model: "gpt-4o",
|
|
335
|
+
});
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Remove an override
|
|
339
|
+
|
|
340
|
+
Remove the active override, reverting to the deployed version:
|
|
341
|
+
|
|
342
|
+
```ts
|
|
343
|
+
await prompts.removeOverride("customer-support");
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Promote a version
|
|
347
|
+
|
|
348
|
+
```ts
|
|
349
|
+
await prompts.promote("customer-support", 2);
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### All management methods
|
|
353
|
+
|
|
354
|
+
| Method | Description |
|
|
355
|
+
|--------|-------------|
|
|
356
|
+
| `prompts.list()` | List all prompts in the current environment |
|
|
357
|
+
| `prompts.versions(slug)` | List all versions for a prompt |
|
|
358
|
+
| `prompts.resolve(slug, variables?, options?)` | Resolve a prompt by slug |
|
|
359
|
+
| `prompts.promote(slug, version)` | Promote a version to current |
|
|
360
|
+
| `prompts.createOverride(slug, body)` | Create an override |
|
|
361
|
+
| `prompts.updateOverride(slug, body)` | Update the active override |
|
|
362
|
+
| `prompts.removeOverride(slug)` | Remove the active override |
|
|
363
|
+
| `prompts.reactivateOverride(slug, version)` | Reactivate a removed override |
|
|
364
|
+
|
|
365
|
+
## Overrides
|
|
366
|
+
|
|
367
|
+
Overrides let you change a prompt's template or model from the dashboard or SDK without redeploying your code. When an override is active, `resolve()` returns the override version instead of the deployed version.
|
|
368
|
+
|
|
369
|
+
### How overrides work
|
|
370
|
+
|
|
371
|
+
- Overrides take priority over the deployed ("current") version
|
|
372
|
+
- Only one override can be active at a time
|
|
373
|
+
- Creating a new override replaces the previous one
|
|
374
|
+
- Removing an override reverts to the deployed version
|
|
375
|
+
- Overrides are environment-scoped (dev, staging, production are independent)
|
|
376
|
+
|
|
377
|
+
### Creating an override (dashboard)
|
|
378
|
+
|
|
379
|
+
1. Go to the prompt detail page
|
|
380
|
+
2. Click **Create Override**
|
|
381
|
+
3. Edit the template text and/or model
|
|
382
|
+
4. Add an optional commit message
|
|
383
|
+
5. Click **Create override**
|
|
384
|
+
|
|
385
|
+
### Version resolution order
|
|
386
|
+
|
|
387
|
+
When `resolve()` is called, versions are resolved in this order:
|
|
388
|
+
|
|
389
|
+
1. **Specific version** — if `{ version: N }` is passed
|
|
390
|
+
2. **Override** — if an override is active in this environment
|
|
391
|
+
3. **Label** — if `{ label: "..." }` is passed (defaults to `"current"`)
|
|
392
|
+
4. **Current** — the latest deployed version with the "current" label
|
|
393
|
+
|
|
394
|
+
## Dashboard
|
|
395
|
+
|
|
396
|
+
### Prompts list
|
|
397
|
+
|
|
398
|
+
The prompts list page shows all prompts in the current environment with the current or override version, default model, and a usage sparkline.
|
|
399
|
+
|
|
400
|
+
### Prompt detail
|
|
401
|
+
|
|
402
|
+
Click a prompt to see:
|
|
403
|
+
|
|
404
|
+
- **Template panel** — the prompt template for the selected version
|
|
405
|
+
- **Details tab** — slug, description, model, config, source file, and variable schema
|
|
406
|
+
- **Versions tab** — all versions with labels, source, and commit messages
|
|
407
|
+
- **Generations tab** — every AI generation that used this prompt, with live polling
|
|
408
|
+
- **Metrics tab** — token usage, cost, and latency charts
|
|
409
|
+
|
|
410
|
+
### AI span inspectors
|
|
411
|
+
|
|
412
|
+
When you use `toAISDKTelemetry()`, AI generation spans in the run trace get a custom inspector showing:
|
|
413
|
+
|
|
414
|
+
- **Overview** — model, provider, token usage, cost, input/output preview
|
|
415
|
+
- **Messages** — the full message thread
|
|
416
|
+
- **Tools** — tool definitions and tool call details
|
|
417
|
+
- **Prompt** — the linked prompt's metadata, input variables, and template content
|
|
418
|
+
|
|
419
|
+
## Type utilities
|
|
420
|
+
|
|
421
|
+
```ts
|
|
422
|
+
import type { PromptHandle, PromptIdentifier, PromptVariables } from "@trigger.dev/sdk";
|
|
423
|
+
|
|
424
|
+
type Id = PromptIdentifier<typeof supportPrompt>; // "customer-support"
|
|
425
|
+
type Vars = PromptVariables<typeof supportPrompt>; // { customerName: string; plan: string; issue: string }
|
|
426
|
+
```
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Actions"
|
|
3
|
+
sidebarTitle: "Actions"
|
|
4
|
+
description: "Custom commands sent from the frontend that mutate chat state without consuming a turn: undo, rollback, edit, regenerate."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Custom actions let the frontend send structured commands (undo, rollback, edit, regenerate) that modify the conversation state. **Actions are not turns**: they fire `hydrateMessages` (if set) and `onAction` only. No turn lifecycle hooks (`onTurnStart` / `prepareMessages` / `onBeforeTurnComplete` / `onTurnComplete`), no `run()`, no turn-counter increment. The trace span is named `chat action`.
|
|
10
|
+
|
|
11
|
+
Actions wake the agent from suspension the same way a new message does, run their handler against the latest accumulator state, and emit a `trigger:turn-complete` chunk so the frontend's `useChat` knows the action has been applied.
|
|
12
|
+
|
|
13
|
+
## Defining an action handler
|
|
14
|
+
|
|
15
|
+
Define an `actionSchema` for validation and an `onAction` handler that uses [`chat.history`](/ai-chat/backend#chat-history) to modify state:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
|
|
20
|
+
export const myChat = chat.agent({
|
|
21
|
+
id: "my-chat",
|
|
22
|
+
actionSchema: z.discriminatedUnion("type", [
|
|
23
|
+
z.object({ type: z.literal("undo") }),
|
|
24
|
+
z.object({ type: z.literal("rollback"), targetMessageId: z.string() }),
|
|
25
|
+
z.object({ type: z.literal("edit"), messageId: z.string(), text: z.string() }),
|
|
26
|
+
]),
|
|
27
|
+
|
|
28
|
+
onAction: async ({ action }) => {
|
|
29
|
+
switch (action.type) {
|
|
30
|
+
case "undo":
|
|
31
|
+
chat.history.slice(0, -2); // Remove last user + assistant exchange
|
|
32
|
+
break;
|
|
33
|
+
case "rollback":
|
|
34
|
+
chat.history.rollbackTo(action.targetMessageId);
|
|
35
|
+
break;
|
|
36
|
+
case "edit":
|
|
37
|
+
chat.history.replace(action.messageId, {
|
|
38
|
+
id: action.messageId,
|
|
39
|
+
role: "user",
|
|
40
|
+
parts: [{ type: "text", text: action.text }],
|
|
41
|
+
});
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
// returning void → side-effect-only, no model call
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
run: async ({ messages, signal, streamText }) => {
|
|
48
|
+
return streamText({ model: anthropic("claude-sonnet-4-5"), messages, abortSignal: signal });
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Lifecycle flow:** Wake → parse action against `actionSchema` → `hydrateMessages` (if set) → **`onAction`** → apply `chat.history` mutations → emit `trigger:turn-complete` → wait for next message.
|
|
54
|
+
|
|
55
|
+
When `onAction` returns `chat.turn()`, the flow continues instead of emitting `trigger:turn-complete`: the edit is snapshotted, then a turn runs on the edited history with `trigger: "action-turn"`, so `onTurnStart`, `run()`, `onBeforeTurnComplete` and `onTurnComplete` all fire and the answer is persisted like any turn's. See [Answering after an action](#answering-after-an-action).
|
|
56
|
+
|
|
57
|
+
## Answering after an action
|
|
58
|
+
|
|
59
|
+
An action is a state edit. To answer after the edit, return `chat.turn()`: the edit is applied and snapshotted, then a turn runs on the edited history exactly as a message turn does. `onTurnStart`, `run()`, `onBeforeTurnComplete` and `onTurnComplete` fire, the turn counter advances, and the answer gets everything a turn has: the agent's system prompt and tools, steering, compaction, injected instructions and persistence.
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
onAction: async ({ action }) => {
|
|
63
|
+
switch (action.type) {
|
|
64
|
+
case "undo":
|
|
65
|
+
chat.history.slice(0, -2);
|
|
66
|
+
return; // edit only, no turn
|
|
67
|
+
|
|
68
|
+
case "regenerate":
|
|
69
|
+
chat.history.slice(0, -1);
|
|
70
|
+
return chat.turn(); // answer the edited history
|
|
71
|
+
|
|
72
|
+
case "retry-formal":
|
|
73
|
+
chat.history.slice(0, -1);
|
|
74
|
+
chat.inject([{ role: "system", content: "Answer formally this time." }]);
|
|
75
|
+
return chat.turn(); // with a one-shot instruction
|
|
76
|
+
|
|
77
|
+
case "ask":
|
|
78
|
+
return chat.turn(action.question); // answer a new user message
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`chat.turn(message)` appends `message` (a string, or a `UIMessage`) to the history as a user message after the edit, and the turn answers it. That is how a button click becomes a question, such as a follow-up suggestion in [Slack](/webhooks/slack#buttons-that-send-the-agent-an-action).
|
|
84
|
+
|
|
85
|
+
Without a message, `run()` receives the edited history with no incoming user message, the same shape as a `regenerate-message` turn, and its `trigger` is `"action-turn"`, so a `run()` that returns early on `"action"` (the pre-May behaviour, when actions invoked `run()` directly) still answers. Returning anything other than `chat.turn()` or nothing is an error; a response can no longer be returned from `onAction` directly.
|
|
86
|
+
|
|
87
|
+
### Actions and persistence
|
|
88
|
+
|
|
89
|
+
An action that returns nothing does not fire `onTurnComplete`, and that is where an app that owns its own transcript normally writes. What that means depends on which persistence model you use.
|
|
90
|
+
|
|
91
|
+
**Transcript storage** (the default, or your own `storage`): nothing to do. After an action that changed the conversation, the runtime hands the storage a changeset with `reason: "action"`. An undo is one `truncateAfter`; a regenerate is a `truncateAfter` followed by the new answer's `put` when the turn completes; an edit is a `put` for the edited id. The changeset carries the same resume cursors as the last turn. See [Transcript storage](/ai-chat/transcript-storage#what-the-runtime-saves). An action that returns `chat.turn()` is followed by a turn, which persists its answer the way every turn does.
|
|
92
|
+
|
|
93
|
+
**Your own store through the deprecated `hydrateMessages`**: the runtime deliberately does not write, because your store is the source of truth. A history edit lives only in the running worker until you persist it, and a continuation rehydrates from your store, not from what the worker had in memory. Mirror each edit in your store, not only additions: a regenerate is a delete *and* an insert. The answer that follows `chat.turn()` reaches your store through `onTurnComplete`, like any turn's answer.
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
onAction: async ({ action, chatId }) => {
|
|
97
|
+
if (action.type === "undo") {
|
|
98
|
+
chat.history.slice(0, -2);
|
|
99
|
+
await db.deleteLastExchange(chatId); // the rollback is yours to persist
|
|
100
|
+
}
|
|
101
|
+
if (action.type === "regenerate") {
|
|
102
|
+
chat.history.slice(0, -1);
|
|
103
|
+
await db.deleteLastAssistant(chatId); // the delete half
|
|
104
|
+
return chat.turn(); // the insert half arrives in onTurnComplete
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
onTurnComplete: async ({ chatId, newUIMessages }) => {
|
|
108
|
+
await db.saveMessages(chatId, newUIMessages);
|
|
109
|
+
},
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Gating actions on HITL state
|
|
113
|
+
|
|
114
|
+
If you have a [human-in-the-loop](/ai-chat/patterns/human-in-the-loop) tool waiting on `addToolOutput`, you usually want to refuse competing actions like `regenerate` until the answer arrives. [`chat.history.getPendingToolCalls()`](/ai-chat/backend#chat-history) gives you exactly that signal:
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
onAction: async ({ action }) => {
|
|
118
|
+
if (action.type === "regenerate") {
|
|
119
|
+
if (chat.history.getPendingToolCalls().length > 0) return; // gated
|
|
120
|
+
chat.history.slice(0, -1);
|
|
121
|
+
return chat.turn();
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Sending actions from the frontend
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
// Browser: TriggerChatTransport
|
|
130
|
+
const stream = await transport.sendAction(chatId, { type: "undo" });
|
|
131
|
+
|
|
132
|
+
// Server: AgentChat
|
|
133
|
+
const stream = await agentChat.sendAction({ type: "rollback", targetMessageId: "msg-3" });
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The action payload is validated against `actionSchema` on the backend; invalid actions throw and surface as a stream error. The `action` parameter in `onAction` is fully typed from the schema.
|
|
137
|
+
|
|
138
|
+
<Note>
|
|
139
|
+
For silent state changes that should never appear as a turn (e.g. injecting background context), use [`chat.inject()`](/ai-chat/background-injection) instead. Actions are explicit user-driven mutations; injections are agent-side context updates.
|
|
140
|
+
</Note>
|
|
141
|
+
|
|
142
|
+
## See also
|
|
143
|
+
|
|
144
|
+
- [`chat.history`](/ai-chat/backend#chat-history): the imperative API actions use to mutate state
|
|
145
|
+
- [Sending actions from the frontend](/ai-chat/frontend#sending-actions): sending actions through `useChat` so a turn that follows one renders like any turn
|
|
146
|
+
- [`hydrateMessages`](/ai-chat/lifecycle-hooks#hydratemessages): fires before `onAction` when set
|
|
147
|
+
- [Branching conversations](/ai-chat/patterns/branching-conversations): pairs action handlers with backend-controlled history
|
|
148
|
+
- [Human-in-the-loop](/ai-chat/patterns/human-in-the-loop): gating fresh actions while a tool is waiting
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Anatomy of an agent"
|
|
3
|
+
sidebarTitle: "Anatomy"
|
|
4
|
+
description: "The three parts of a chat agent — the agent task that runs the turn loop, the durable session that carries messages, and the frontend transport — what each does and where it's documented."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**A chat agent is three parts: an agent task that runs the turn loop, a durable session that carries messages in and streams the response out, and a frontend transport that connects the session to `useChat`.** This page is your map of the Building agents section — what each part does, how a single message flows through them, and which page to open next.
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
flowchart LR
|
|
11
|
+
FE["Frontend<br/>useChat + transport"] -- "user messages" --> IN([Session .in])
|
|
12
|
+
IN --> AGENT["Agent task<br/>turn loop + hooks"]
|
|
13
|
+
AGENT --> OUT([Session .out])
|
|
14
|
+
OUT -- "streamed response" --> FE
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Follow one message
|
|
18
|
+
|
|
19
|
+
A single turn moves through all three parts in order:
|
|
20
|
+
|
|
21
|
+
1. The **frontend transport** sends the user's message to the session's inbound stream (`.in`).
|
|
22
|
+
2. The **agent task** wakes on the new message, runs your turn loop, and streams the model's response into the session's outbound stream (`.out`).
|
|
23
|
+
3. The **frontend transport** reads `.out` and renders tokens into `useChat` as they arrive.
|
|
24
|
+
|
|
25
|
+
The session sits in the middle so both sides never have to be online at the same moment — the task keeps writing to `.out` even if the browser reloads mid-stream.
|
|
26
|
+
|
|
27
|
+
## The three parts
|
|
28
|
+
|
|
29
|
+
### The agent task
|
|
30
|
+
|
|
31
|
+
`chat.agent()` is the code you write: a long-lived agent whose `run` function is the turn loop. Messages arrive accumulated, you call `streamText`, and the returned stream is piped back to the frontend for you. [Tools](/ai-chat/tools) the model can call and [lifecycle hooks](/ai-chat/lifecycle-hooks) that fire around each turn both hang off the same config. See [Backend](/ai-chat/backend) for the full `chat.agent()` surface.
|
|
32
|
+
|
|
33
|
+
### The session
|
|
34
|
+
|
|
35
|
+
The conversation lives in a [session](/ai-chat/sessions), not in the task's memory: a pair of durable streams — `.in` and `.out` — keyed on your `chatId`. Because the session is durable, a conversation survives page refreshes, deploys, and the run boundaries between turns. The task can restart and pick up the same session. [How it works](/ai-chat/how-it-works) covers the mechanics of what survives and why.
|
|
36
|
+
|
|
37
|
+
### The frontend transport
|
|
38
|
+
|
|
39
|
+
One hook — `useTriggerChatTransport` — connects the Vercel AI SDK's `useChat` to the agent's session. There are no API routes to write: the transport talks to the session directly using a scoped token. See [Frontend](/ai-chat/frontend) for wiring, tokens, and starting sessions.
|
|
40
|
+
|
|
41
|
+
## An annotated agent
|
|
42
|
+
|
|
43
|
+
Everything above maps onto one task:
|
|
44
|
+
|
|
45
|
+
```ts trigger/my-agent.ts
|
|
46
|
+
import { chat } from "@trigger.dev/sdk/ai";
|
|
47
|
+
import { stepCountIs } from "ai";
|
|
48
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
49
|
+
|
|
50
|
+
export const myAgent = chat.agent({
|
|
51
|
+
id: "my-agent",
|
|
52
|
+
|
|
53
|
+
// Tools the model can call, declared on the config so they
|
|
54
|
+
// survive history re-conversion across turns — see Tools.
|
|
55
|
+
tools: { searchDocs },
|
|
56
|
+
|
|
57
|
+
// A lifecycle hook: fires after each turn, here to persist
|
|
58
|
+
// the response — see Lifecycle hooks.
|
|
59
|
+
onTurnComplete: async ({ responseMessage }) => {
|
|
60
|
+
await db.messages.save(responseMessage);
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
// The turn loop. Messages arrive accumulated; the returned
|
|
64
|
+
// stream is piped back to the frontend — see Backend.
|
|
65
|
+
run: async ({ messages, tools, signal, streamText }) =>
|
|
66
|
+
streamText({
|
|
67
|
+
tools,
|
|
68
|
+
model: anthropic("claude-sonnet-4-5"),
|
|
69
|
+
messages,
|
|
70
|
+
abortSignal: signal,
|
|
71
|
+
stopWhen: stepCountIs(15),
|
|
72
|
+
}),
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Related pages
|
|
77
|
+
|
|
78
|
+
Beyond the three core parts:
|
|
79
|
+
|
|
80
|
+
| Page | What it covers |
|
|
81
|
+
| ------------------------------------------- | ------------------------------------------------------- |
|
|
82
|
+
| [Server-side chat](/ai-chat/server-chat) | Driving a chat from your backend instead of a browser |
|
|
83
|
+
| [chat.local](/ai-chat/chat-local) | Per-run typed state inside the turn loop |
|
|
84
|
+
| [Types](/ai-chat/types) | Type-safe payloads, client data, and messages |
|
|
85
|
+
| [Custom agents](/ai-chat/custom-agents) | Building without the managed lifecycle |
|
|
86
|
+
|
|
87
|
+
[Features](/ai-chat/fast-starts) covers opt-in capabilities (Head Start, compaction, steering, actions), and [Patterns](/ai-chat/patterns/sub-agents) covers production recipes (sub-agents, HITL approvals, persistence, recovery).
|