@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,792 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @trigger.dev/sdk/chat
|
|
3
|
+
*
|
|
4
|
+
* Browser-safe module for AI SDK chat transport integration.
|
|
5
|
+
* Use this on the frontend with the AI SDK's `useChat` hook.
|
|
6
|
+
*
|
|
7
|
+
* For backend helpers (`chatAgent`, `pipeChat`), use `@trigger.dev/sdk/ai` instead.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { useChat } from "@ai-sdk/react";
|
|
12
|
+
* import { TriggerChatTransport } from "@trigger.dev/sdk/chat";
|
|
13
|
+
*
|
|
14
|
+
* function Chat() {
|
|
15
|
+
* const { messages, sendMessage, status } = useChat({
|
|
16
|
+
* transport: new TriggerChatTransport({
|
|
17
|
+
* task: "my-chat-task",
|
|
18
|
+
* accessToken: async ({ chatId }) => fetchSessionToken(chatId),
|
|
19
|
+
* startSession: async ({ chatId, taskId }) => createChatSession({ chatId, taskId }),
|
|
20
|
+
* }),
|
|
21
|
+
* });
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import type { ChatTransport, ModelMessage, UIMessage, UIMessageChunk, ChatRequestOptions } from "ai";
|
|
26
|
+
/**
|
|
27
|
+
* The wire payload shape sent by `TriggerChatTransport`.
|
|
28
|
+
* Uses `metadata` to match the AI SDK's `ChatRequestOptions` field name.
|
|
29
|
+
*
|
|
30
|
+
* Slim wire: at most ONE message per record. The agent runtime
|
|
31
|
+
* reconstructs prior history at run boot from a durable S3 snapshot +
|
|
32
|
+
* `session.out` replay (or `hydrateMessages` if registered).
|
|
33
|
+
*
|
|
34
|
+
* Declared here (rather than the internal shared module) so `declaration:
|
|
35
|
+
* true` consumers can name inferred agent types via this public subpath.
|
|
36
|
+
*/
|
|
37
|
+
export type ChatTaskWirePayload<TMessage extends UIMessage = UIMessage, TMetadata = unknown> = {
|
|
38
|
+
/**
|
|
39
|
+
* The single message being delivered on this trigger. Set for:
|
|
40
|
+
* - `submit-message`: the new user message OR a tool-approval-responded
|
|
41
|
+
* assistant message (with `state: "approval-responded"` tool parts).
|
|
42
|
+
* - `regenerate-message`: omitted (the agent slices its own history).
|
|
43
|
+
* - `preload` / `close` / `action`: omitted.
|
|
44
|
+
* - `handover-prepare`: omitted (use `headStartMessages` instead).
|
|
45
|
+
*/
|
|
46
|
+
message?: TMessage;
|
|
47
|
+
/**
|
|
48
|
+
* Bespoke escape hatch for `chat.headStart`. The customer's HTTP route
|
|
49
|
+
* handler ships full `UIMessage[]` history at the very first turn — before
|
|
50
|
+
* any snapshot exists. The route handler isn't subject to the
|
|
51
|
+
* `MAX_APPEND_BODY_BYTES` cap on `/in/append` because it goes through the
|
|
52
|
+
* customer's own HTTP endpoint. Used ONLY by `trigger: "handover-prepare"`.
|
|
53
|
+
* Ignored on every other trigger.
|
|
54
|
+
*/
|
|
55
|
+
headStartMessages?: TMessage[];
|
|
56
|
+
chatId: string;
|
|
57
|
+
trigger: "submit-message" | "regenerate-message" | "preload" | "close" | "action"
|
|
58
|
+
/**
|
|
59
|
+
* The customer's `chat.handover` route handler kicked us off in
|
|
60
|
+
* parallel with the first-turn `streamText` running in the warm
|
|
61
|
+
* Next.js process. The run sits idle on `session.in` waiting for
|
|
62
|
+
* a `kind: "handover"` (continue from tool execution) or
|
|
63
|
+
* `kind: "handover-skip"` (handler finished pure-text, exit
|
|
64
|
+
* cleanly). See `chat.handover` in `@trigger.dev/sdk/chat-server`.
|
|
65
|
+
*/
|
|
66
|
+
| "handover-prepare";
|
|
67
|
+
messageId?: string;
|
|
68
|
+
metadata?: TMetadata;
|
|
69
|
+
/**
|
|
70
|
+
* Custom action payload when `trigger` is `"action"`. Managed agents validate
|
|
71
|
+
* this against `actionSchema`; raw custom agents must validate it themselves.
|
|
72
|
+
*/
|
|
73
|
+
action?: unknown;
|
|
74
|
+
/**
|
|
75
|
+
* Origin of an `"action"` trigger. `"webhook"` actions (delivered by the hosted webhook ingress)
|
|
76
|
+
* carry a fixed envelope typed via `ChatEventActions`, so they bypass `actionSchema` validation;
|
|
77
|
+
* omitted / `"client"` actions (frontend or server) are validated against `actionSchema`, and so
|
|
78
|
+
* are `"channel"` actions (a click on a button the agent posted to a channel, mapped by the
|
|
79
|
+
* connector's `toAction()`).
|
|
80
|
+
*/
|
|
81
|
+
actionSource?: "client" | "webhook" | "channel";
|
|
82
|
+
/**
|
|
83
|
+
* A channel-delivered turn (hosted webhook ingress -> a chat frontend like Slack). Carries the raw
|
|
84
|
+
* verified provider event; the run resolves the connector by `connectorId` from `chat.agent({ channels })`
|
|
85
|
+
* and applies its `inbound()` mapper to produce the turn's message. Present instead of `message`.
|
|
86
|
+
*/
|
|
87
|
+
channelEvent?: {
|
|
88
|
+
connectorId: string;
|
|
89
|
+
event: unknown;
|
|
90
|
+
source: string;
|
|
91
|
+
headers: Record<string, string>;
|
|
92
|
+
/** The delivery's id (`whd_...`): new on a replay, the same across retries of one delivery. */
|
|
93
|
+
deliveryId: string;
|
|
94
|
+
/** The provider's id for the delivery, the same across replays. */
|
|
95
|
+
externalDeliveryId?: string;
|
|
96
|
+
};
|
|
97
|
+
/** Whether this run is continuing an existing chat whose previous run ended. */
|
|
98
|
+
continuation?: boolean;
|
|
99
|
+
/** The run ID of the previous run (only set when `continuation` is true). */
|
|
100
|
+
previousRunId?: string;
|
|
101
|
+
/** Override idle timeout for this run (seconds). Set by transport.preload(). */
|
|
102
|
+
idleTimeoutInSeconds?: number;
|
|
103
|
+
/**
|
|
104
|
+
* The friendlyId of the Session primitive backing this chat. The
|
|
105
|
+
* transport opens (or lazy-creates) the session with
|
|
106
|
+
* `externalId = chatId` on first message, then sends this friendlyId
|
|
107
|
+
* through to the run so the agent can attach to `.in` / `.out`
|
|
108
|
+
* without needing to round-trip through the control plane again.
|
|
109
|
+
* Optional for backward-compat while the migration is in flight;
|
|
110
|
+
* required once the legacy run-scoped stream path is removed.
|
|
111
|
+
*/
|
|
112
|
+
sessionId?: string;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* One chunk on the chat input stream. `kind` discriminates the variants —
|
|
116
|
+
* a single ordered stream carries all the signals (`message`, `stop`,
|
|
117
|
+
* `handover`, `handover-skip`).
|
|
118
|
+
*/
|
|
119
|
+
export type ChatInputChunk<TMessage extends UIMessage = UIMessage, TMetadata = unknown> = {
|
|
120
|
+
kind: "message";
|
|
121
|
+
/** Full wire payload for a new user message or regeneration. */
|
|
122
|
+
payload: ChatTaskWirePayload<TMessage, TMetadata>;
|
|
123
|
+
} | {
|
|
124
|
+
kind: "stop";
|
|
125
|
+
/** Optional human-readable reason. */
|
|
126
|
+
message?: string;
|
|
127
|
+
} | {
|
|
128
|
+
/**
|
|
129
|
+
* Sent by `chat.headStart` when the customer's first-turn
|
|
130
|
+
* `streamText` finishes. The agent run (parked in
|
|
131
|
+
* `handover-prepare`) wakes, seeds its accumulators with
|
|
132
|
+
* `partialAssistantMessage`, and runs the normal turn loop.
|
|
133
|
+
* `isFinal: false` means step 1 ended in tool-calls (the agent
|
|
134
|
+
* executes them and continues); `isFinal: true` means step 1 was
|
|
135
|
+
* the complete response (the agent skips the LLM call).
|
|
136
|
+
*/
|
|
137
|
+
kind: "handover";
|
|
138
|
+
/** Customer's step-1 response messages (ModelMessage form). */
|
|
139
|
+
partialAssistantMessage: ModelMessage[];
|
|
140
|
+
/**
|
|
141
|
+
* The UI messageId the customer's handler used for its step-1
|
|
142
|
+
* assistant message, reused so post-handover chunks merge into
|
|
143
|
+
* the SAME assistant message on the browser side.
|
|
144
|
+
*/
|
|
145
|
+
messageId?: string;
|
|
146
|
+
isFinal: boolean;
|
|
147
|
+
} | {
|
|
148
|
+
/**
|
|
149
|
+
* Sent by `chat.headStart` only when the customer's handler
|
|
150
|
+
* ABORTS before producing a finishReason. The agent run exits
|
|
151
|
+
* cleanly without firing turn hooks.
|
|
152
|
+
*/
|
|
153
|
+
kind: "handover-skip";
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Discriminator passed to per-endpoint `baseURL` and `fetch` callbacks.
|
|
157
|
+
*
|
|
158
|
+
* - `"in"` — `POST /realtime/v1/sessions/{chatId}/in/append` (user messages,
|
|
159
|
+
* stops, actions).
|
|
160
|
+
* - `"out"` — `GET /realtime/v1/sessions/{chatId}/out` (SSE response stream).
|
|
161
|
+
*
|
|
162
|
+
* Other endpoints (`/api/v1/sessions`, `/api/v1/auth/jwt/claims`) are reached
|
|
163
|
+
* from the server-side `chat.createStartSessionAction` and `accessToken`
|
|
164
|
+
* callback, not the transport — they accept the same callback shape on their
|
|
165
|
+
* own option objects.
|
|
166
|
+
*/
|
|
167
|
+
export type ChatTransportEndpoint = "in" | "out";
|
|
168
|
+
/** Context passed to `baseURL` and `fetch` callbacks. */
|
|
169
|
+
export type ChatTransportEndpointContext = {
|
|
170
|
+
endpoint: ChatTransportEndpoint;
|
|
171
|
+
chatId: string;
|
|
172
|
+
};
|
|
173
|
+
/** Resolver form of `baseURL` — return the base for the given endpoint. */
|
|
174
|
+
export type ChatBaseURLResolver = (ctx: ChatTransportEndpointContext) => string;
|
|
175
|
+
/**
|
|
176
|
+
* Per-request fetch override. Receives the fully-resolved URL and the
|
|
177
|
+
* RequestInit the transport would have used, plus endpoint context for
|
|
178
|
+
* routing decisions. Customers can rewrite the URL, inject headers, or
|
|
179
|
+
* delegate to a custom transport (e.g. a Cloudflare worker fronting
|
|
180
|
+
* `api.trigger.dev`). Must return a `Response` semantically equivalent to
|
|
181
|
+
* what `globalThis.fetch(url, init)` would have returned.
|
|
182
|
+
*/
|
|
183
|
+
export type ChatFetchOverride = (url: string, init: RequestInit, ctx: ChatTransportEndpointContext) => Promise<Response>;
|
|
184
|
+
/**
|
|
185
|
+
* Which transport path produced a send-lifecycle event: `useChat` sends,
|
|
186
|
+
* steering (`sendPendingMessage`), actions, stops, or the first-turn
|
|
187
|
+
* `headStart` POST.
|
|
188
|
+
*/
|
|
189
|
+
export type ChatTransportSendSource = "submit-message" | "regenerate-message" | "steer" | "action" | "stop" | "head-start";
|
|
190
|
+
/** The input boundary that settled a particular `sendAction` call. */
|
|
191
|
+
export type ChatActionSettlement = {
|
|
192
|
+
/** Sequence returned by this action's input append. */
|
|
193
|
+
inputSeq: number;
|
|
194
|
+
/** Committed input cursor from the turn-complete record, at or after `inputSeq`. */
|
|
195
|
+
sessionInEventId: string;
|
|
196
|
+
/** Output cursor of the turn-complete record. */
|
|
197
|
+
lastEventId?: string;
|
|
198
|
+
};
|
|
199
|
+
export type ChatActionOptions = {
|
|
200
|
+
abortSignal?: AbortSignal;
|
|
201
|
+
/** Per-action metadata merged over the transport's clientData. */
|
|
202
|
+
metadata?: Record<string, unknown>;
|
|
203
|
+
/**
|
|
204
|
+
* Called at most once when the subscription accepts a turn-complete record
|
|
205
|
+
* confirming this action's input was processed, before the returned stream
|
|
206
|
+
* closes (or continues in watch mode). Not called after cancellation, stream
|
|
207
|
+
* closure without a matching record, missing/invalid cursors, or a stream
|
|
208
|
+
* error because the stop/supersede gate discarded this action's output.
|
|
209
|
+
* The action may have been processed even if this callback never runs:
|
|
210
|
+
* reconcile persisted state or use idempotent actions before retrying.
|
|
211
|
+
* Settlement does not imply application-level success: inspect the response
|
|
212
|
+
* chunks for the action's result. Synchronous callback exceptions are ignored
|
|
213
|
+
* so they do not interrupt the stream.
|
|
214
|
+
*/
|
|
215
|
+
onSettled?: (settlement: ChatActionSettlement) => void;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Lifecycle events emitted through the transport's `onEvent` callback.
|
|
219
|
+
*
|
|
220
|
+
* Send events are terminal: `message-sent` fires when the append is
|
|
221
|
+
* durably acknowledged (2xx from the session input stream, after any
|
|
222
|
+
* internal token-refresh retries), `message-send-failed` when the send
|
|
223
|
+
* definitively failed. Response events follow the output stream:
|
|
224
|
+
* `stream-connected` when the SSE subscription opens, `first-chunk` on
|
|
225
|
+
* the first response chunk of a turn, `turn-completed` when the agent's
|
|
226
|
+
* turn-complete control record arrives, and `stream-error` when the
|
|
227
|
+
* stream fails unrecoverably.
|
|
228
|
+
*/
|
|
229
|
+
export type ChatTransportEvent = {
|
|
230
|
+
/**
|
|
231
|
+
* The chat's run is parked waiting for its deployment (version skew protection). Messages
|
|
232
|
+
* sent meanwhile are durable and drain when it lands, but nothing answers until then.
|
|
233
|
+
* Re-emitted on every send while parked; clear the notice on `first-chunk`.
|
|
234
|
+
*/
|
|
235
|
+
type: "run-pending-version";
|
|
236
|
+
chatId: string;
|
|
237
|
+
timestamp: number;
|
|
238
|
+
/**
|
|
239
|
+
* Where we learned it: creating the session, a send, the `headStart` POST, or an
|
|
240
|
+
* upgrade handing over to a deployment that has not landed yet.
|
|
241
|
+
*/
|
|
242
|
+
source: "start" | "send" | "head-start" | "upgrade";
|
|
243
|
+
} | {
|
|
244
|
+
type: "message-sent";
|
|
245
|
+
chatId: string;
|
|
246
|
+
timestamp: number;
|
|
247
|
+
messageId?: string;
|
|
248
|
+
source: ChatTransportSendSource;
|
|
249
|
+
durationMs: number;
|
|
250
|
+
/** The append's idempotency key — also stored on the server-side record. */
|
|
251
|
+
partId?: string;
|
|
252
|
+
/** Serialized request body size in bytes. */
|
|
253
|
+
bodyBytes?: number;
|
|
254
|
+
} | {
|
|
255
|
+
type: "message-send-failed";
|
|
256
|
+
chatId: string;
|
|
257
|
+
timestamp: number;
|
|
258
|
+
messageId?: string;
|
|
259
|
+
source: ChatTransportSendSource;
|
|
260
|
+
error: Error;
|
|
261
|
+
status?: number;
|
|
262
|
+
durationMs: number;
|
|
263
|
+
partId?: string;
|
|
264
|
+
bodyBytes?: number;
|
|
265
|
+
} | {
|
|
266
|
+
type: "stream-connected";
|
|
267
|
+
chatId: string;
|
|
268
|
+
timestamp: number;
|
|
269
|
+
resumed: boolean;
|
|
270
|
+
/** The resume cursor the subscription connected from, if any. */
|
|
271
|
+
lastEventId?: string;
|
|
272
|
+
/** The last turn-producing send on this chat (client-side attribution). */
|
|
273
|
+
messageId?: string;
|
|
274
|
+
} | {
|
|
275
|
+
type: "stream-error";
|
|
276
|
+
chatId: string;
|
|
277
|
+
timestamp: number;
|
|
278
|
+
error: Error;
|
|
279
|
+
status?: number;
|
|
280
|
+
} | {
|
|
281
|
+
type: "session-closed";
|
|
282
|
+
chatId: string;
|
|
283
|
+
timestamp: number;
|
|
284
|
+
/** The reason supplied to `chat.close()` / `sessions.close()`, if any. */
|
|
285
|
+
reason?: string;
|
|
286
|
+
/** How the transport learned: the terminal record, or a refused send. */
|
|
287
|
+
source: "stream" | "append";
|
|
288
|
+
} | {
|
|
289
|
+
type: "first-chunk";
|
|
290
|
+
chatId: string;
|
|
291
|
+
timestamp: number;
|
|
292
|
+
chunkType?: string;
|
|
293
|
+
lastEventId?: string;
|
|
294
|
+
messageId?: string;
|
|
295
|
+
/** Milliseconds since the last turn-producing send on this chat (time to first token). */
|
|
296
|
+
sinceSendMs?: number;
|
|
297
|
+
} | {
|
|
298
|
+
type: "turn-completed";
|
|
299
|
+
chatId: string;
|
|
300
|
+
timestamp: number;
|
|
301
|
+
lastEventId?: string;
|
|
302
|
+
/** The agent's committed input-stream cursor from the turn-complete record. */
|
|
303
|
+
sessionInEventId?: string;
|
|
304
|
+
messageId?: string;
|
|
305
|
+
/** Milliseconds since the last turn-producing send on this chat (full turn latency). */
|
|
306
|
+
sinceSendMs?: number;
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Arguments for the `accessToken` callback. The transport invokes this
|
|
310
|
+
* whenever it needs a fresh session-scoped PAT — initial use, and
|
|
311
|
+
* after a 401 from any session-PAT-authed request.
|
|
312
|
+
*
|
|
313
|
+
* The callback's job is to return a token, not to start a run.
|
|
314
|
+
* Customers whose implementation also creates the session (typical for
|
|
315
|
+
* `chat.createStartSessionAction` server actions) own the trigger
|
|
316
|
+
* payload server-side — they know their own user/context and don't
|
|
317
|
+
* need anything from the browser to populate `basePayload.metadata`.
|
|
318
|
+
*/
|
|
319
|
+
export type AccessTokenParams = {
|
|
320
|
+
/** Conversation id — same value passed to `sendMessage` / `useChat`. */
|
|
321
|
+
chatId: string;
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Arguments for the `startSession` callback. The transport invokes this
|
|
325
|
+
* when it needs a session for a chatId — on `transport.preload(chatId)`,
|
|
326
|
+
* on `transport.start(chatId)`, and lazily on the first `sendMessage`
|
|
327
|
+
* for any chatId without a cached session.
|
|
328
|
+
*
|
|
329
|
+
* The callback typically wraps a server action that calls
|
|
330
|
+
* `chat.createStartSessionAction(taskId)({ chatId, clientData })`. That
|
|
331
|
+
* action is idempotent on `(env, externalId)`, so concurrent / repeat
|
|
332
|
+
* calls converge on the same session.
|
|
333
|
+
*
|
|
334
|
+
* The `clientData` field carries the transport's current `clientData`
|
|
335
|
+
* option — same value the transport merges into per-turn `metadata` on
|
|
336
|
+
* each `.in` chunk. Passing it through `startSession` makes the first
|
|
337
|
+
* run's `payload.metadata` (visible in `onPreload` / `onChatStart`)
|
|
338
|
+
* match what subsequent turns see.
|
|
339
|
+
*
|
|
340
|
+
* @typeParam TClientData – Type of the agent's `clientDataSchema` (when
|
|
341
|
+
* the transport is parameterised with `useTriggerChatTransport<typeof agent>`).
|
|
342
|
+
*/
|
|
343
|
+
export type StartSessionParams<TClientData = unknown> = {
|
|
344
|
+
/** The Trigger.dev task ID associated with this transport. */
|
|
345
|
+
taskId: string;
|
|
346
|
+
/** Conversation id — same value passed to `sendMessage` / `useChat`. */
|
|
347
|
+
chatId: string;
|
|
348
|
+
/**
|
|
349
|
+
* The transport's current `clientData`. Pass through to the server
|
|
350
|
+
* action's `basePayload.metadata` so the first run's `payload.metadata`
|
|
351
|
+
* matches per-turn `metadata`.
|
|
352
|
+
*/
|
|
353
|
+
clientData: TClientData;
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* Result returned from the `startSession` callback. Carries the
|
|
357
|
+
* session-scoped PAT the transport caches and uses for every
|
|
358
|
+
* `.in/append`, `.out` SSE, and `end-and-continue` call afterward.
|
|
359
|
+
*/
|
|
360
|
+
export type StartSessionResult = {
|
|
361
|
+
/** Session-scoped PAT — `read:sessions:{chatId} + write:sessions:{chatId}`. */
|
|
362
|
+
publicAccessToken: string;
|
|
363
|
+
/**
|
|
364
|
+
* Pass through `pendingVersion` from `chat.createStartSessionAction` (or `POST
|
|
365
|
+
* /api/v1/sessions`) and the transport emits `run-pending-version`.
|
|
366
|
+
*/
|
|
367
|
+
pendingVersion?: boolean;
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* Public surface of {@link TriggerChatTransport}'s session state. Everything
|
|
371
|
+
* the customer should persist for resumption across page reloads. The
|
|
372
|
+
* transport addresses by `chatId` everywhere, so this is light: just a PAT,
|
|
373
|
+
* resume cursors, and a couple of UX-state flags.
|
|
374
|
+
*/
|
|
375
|
+
export type ChatSessionPersistedState = {
|
|
376
|
+
publicAccessToken: string;
|
|
377
|
+
lastEventId?: string;
|
|
378
|
+
/** The `.in` append sequence of the last send this client owned; reused as `sinceInSeq` on reconnect. */
|
|
379
|
+
activeInputSeq?: number;
|
|
380
|
+
isStreaming?: boolean;
|
|
381
|
+
/** Set once the session is closed. Persisted so a reload doesn't retry a dead session. */
|
|
382
|
+
closed?: boolean;
|
|
383
|
+
/** The reason the session was closed, when one was given. */
|
|
384
|
+
closedReason?: string;
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* Common options for the {@link TriggerChatTransport}.
|
|
388
|
+
*
|
|
389
|
+
* @typeParam TClientData – Type of the per-call client data merged into
|
|
390
|
+
* the wire payload via `metadata`. When the task uses `clientDataSchema`,
|
|
391
|
+
* pin this to the schema's input type for end-to-end type safety.
|
|
392
|
+
*/
|
|
393
|
+
export type TriggerChatTransportOptions<TClientData = unknown> = {
|
|
394
|
+
/**
|
|
395
|
+
* The Trigger.dev task ID this transport drives. Sessions created by
|
|
396
|
+
* `transport.start(chatId)` are bound to this task — every run the
|
|
397
|
+
* Session schedules invokes it. Threaded into `startSession` so the
|
|
398
|
+
* customer's server action knows which task to bind.
|
|
399
|
+
*/
|
|
400
|
+
task: string;
|
|
401
|
+
/**
|
|
402
|
+
* Returns a fresh session-scoped PAT for an existing chat session.
|
|
403
|
+
* The transport invokes this on a 401/403 from any session-PAT-authed
|
|
404
|
+
* request — pure refresh, never creates a session.
|
|
405
|
+
*
|
|
406
|
+
* Customer implementation typically does
|
|
407
|
+
* `auth.createPublicToken({ scopes: { read: { sessions: chatId },
|
|
408
|
+
* write: { sessions: chatId } } })` server-side and returns the token.
|
|
409
|
+
*
|
|
410
|
+
* Required so the transport can recover from PAT expiry — never
|
|
411
|
+
* leaves the consumer in an unrecoverable state.
|
|
412
|
+
*/
|
|
413
|
+
accessToken: (params: AccessTokenParams) => string | Promise<string>;
|
|
414
|
+
/**
|
|
415
|
+
* Creates (or no-ops on existing) a session for the given chatId, and
|
|
416
|
+
* returns the session-scoped PAT the transport will use afterward.
|
|
417
|
+
*
|
|
418
|
+
* Wraps a server action that calls
|
|
419
|
+
* `chat.createStartSessionAction(taskId)({ chatId, clientData })`.
|
|
420
|
+
* Customer's server controls authorization, the rest of the
|
|
421
|
+
* triggerConfig, and any atomic DB writes paired with session creation.
|
|
422
|
+
*
|
|
423
|
+
* The transport invokes this:
|
|
424
|
+
* - when `transport.start(chatId)` / `transport.preload(chatId)` is called
|
|
425
|
+
* - lazily on the first `sendMessage` for a chatId with no cached PAT
|
|
426
|
+
*
|
|
427
|
+
* Concurrent and repeat calls dedupe via an in-flight promise + the
|
|
428
|
+
* customer-side idempotency on `(env, externalId)`.
|
|
429
|
+
*
|
|
430
|
+
* Optional only when the customer fully manages session lifecycle
|
|
431
|
+
* externally (hydrating `sessions: { ... }` and never calling
|
|
432
|
+
* `start` / `preload`). Most customers should provide it.
|
|
433
|
+
*/
|
|
434
|
+
startSession?: (params: StartSessionParams<TClientData extends Record<string, unknown> ? TClientData : Record<string, unknown>>) => Promise<StartSessionResult>;
|
|
435
|
+
/**
|
|
436
|
+
* Base URL for the Trigger.dev API. Either a single string applied to every
|
|
437
|
+
* endpoint, or a function called per request that picks a base URL from the
|
|
438
|
+
* endpoint discriminator and chat ID. @default "https://api.trigger.dev"
|
|
439
|
+
*
|
|
440
|
+
* @example Route appends through a proxy, SSE direct:
|
|
441
|
+
* ```ts
|
|
442
|
+
* baseURL: ({ endpoint }) =>
|
|
443
|
+
* endpoint === "out" ? "https://api.trigger.dev" : "https://proxy.example.com",
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
446
|
+
baseURL?: string | ChatBaseURLResolver;
|
|
447
|
+
/**
|
|
448
|
+
* Base URL for the SSE stream subscription only (`GET .../sessions/{chatId}/out`).
|
|
449
|
+
* @deprecated Pass a function for `baseURL` instead and branch on
|
|
450
|
+
* `endpoint === "out"`. `streamBaseURL` continues to work for backwards
|
|
451
|
+
* compatibility and wins over `baseURL` for the SSE endpoint when both
|
|
452
|
+
* are set.
|
|
453
|
+
*/
|
|
454
|
+
streamBaseURL?: string;
|
|
455
|
+
/**
|
|
456
|
+
* Optional per-request fetch override. Called with the resolved URL and the
|
|
457
|
+
* RequestInit the transport built, plus endpoint context. Use this to
|
|
458
|
+
* inject custom headers (e.g. distributed tracing), redirect via a proxy,
|
|
459
|
+
* or wrap fetch with retries/logging.
|
|
460
|
+
*
|
|
461
|
+
* @example Add a tracing header to every chat request:
|
|
462
|
+
* ```ts
|
|
463
|
+
* fetch: (url, init, ctx) => {
|
|
464
|
+
* init.headers = new Headers(init.headers);
|
|
465
|
+
* init.headers.set("traceparent", currentTraceparent());
|
|
466
|
+
* return globalThis.fetch(url, init);
|
|
467
|
+
* },
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
fetch?: ChatFetchOverride;
|
|
471
|
+
/**
|
|
472
|
+
* Observability callback for transport lifecycle events (sends,
|
|
473
|
+
* stream connects, first chunk, turn completion). See
|
|
474
|
+
* {@link ChatTransportEvent} for the event catalog and semantics.
|
|
475
|
+
* Exceptions thrown by the callback are swallowed.
|
|
476
|
+
*
|
|
477
|
+
* @example Record send metrics:
|
|
478
|
+
* ```ts
|
|
479
|
+
* onEvent: (event) => {
|
|
480
|
+
* if (event.type === "message-sent") {
|
|
481
|
+
* metrics.timing("chat.send", event.durationMs);
|
|
482
|
+
* }
|
|
483
|
+
* },
|
|
484
|
+
* ```
|
|
485
|
+
*/
|
|
486
|
+
onEvent?: (event: ChatTransportEvent) => void;
|
|
487
|
+
/** Additional headers included in every API request. */
|
|
488
|
+
headers?: Record<string, string>;
|
|
489
|
+
/**
|
|
490
|
+
* Seconds to wait for the realtime stream to produce data before timing
|
|
491
|
+
* out. @default 120
|
|
492
|
+
*/
|
|
493
|
+
streamTimeoutSeconds?: number;
|
|
494
|
+
/**
|
|
495
|
+
* Default client data merged into every wire `metadata`. Per-call
|
|
496
|
+
* `metadata` overrides transport-level defaults.
|
|
497
|
+
*/
|
|
498
|
+
clientData?: TClientData extends Record<string, unknown> ? TClientData : Record<string, unknown>;
|
|
499
|
+
/**
|
|
500
|
+
* Restore active session state from external storage (e.g. localStorage)
|
|
501
|
+
* after a page refresh. Hydrated entries skip the start round-trip and
|
|
502
|
+
* use their `publicAccessToken` directly. On 401, the transport
|
|
503
|
+
* invokes `accessToken` to refresh.
|
|
504
|
+
*/
|
|
505
|
+
sessions?: Record<string, ChatSessionPersistedState>;
|
|
506
|
+
/**
|
|
507
|
+
* Called whenever a chat session's state changes. Use this to persist
|
|
508
|
+
* state for reconnection after a page refresh — `null` is passed when
|
|
509
|
+
* the session is removed.
|
|
510
|
+
*/
|
|
511
|
+
onSessionChange?: (chatId: string, session: ChatSessionPersistedState | null) => void;
|
|
512
|
+
/**
|
|
513
|
+
* Enable multi-tab coordination. When `true`, only one tab at a time
|
|
514
|
+
* can send messages to a given chatId; other tabs go read-only.
|
|
515
|
+
*
|
|
516
|
+
* No-op when `BroadcastChannel` is unavailable. @default false
|
|
517
|
+
*/
|
|
518
|
+
multiTab?: boolean;
|
|
519
|
+
/**
|
|
520
|
+
* Read-only "watch" mode for observing an existing chat run from the
|
|
521
|
+
* outside (e.g. a dashboard viewer). When `true`, the SSE subscription
|
|
522
|
+
* stays open across `trigger:turn-complete` so consumers see turn 2,
|
|
523
|
+
* 3, … through one long-lived stream. Pair with `sessions` hydration
|
|
524
|
+
* and `reconnectToStream` for the typical viewer flow. @default false
|
|
525
|
+
*/
|
|
526
|
+
watch?: boolean;
|
|
527
|
+
/**
|
|
528
|
+
* Opt-in URL that gives a brand-new chat a head start: instead of
|
|
529
|
+
* waiting for the trigger.dev agent run to dequeue + boot before
|
|
530
|
+
* the first LLM call, the transport POSTs the first user message
|
|
531
|
+
* to a route handler in your warm process (Next.js, etc.) that
|
|
532
|
+
* exports `chat.handover({ agentId, run })` from
|
|
533
|
+
* `@trigger.dev/sdk/chat-server`. That handler runs `streamText`
|
|
534
|
+
* step 1 right away while the agent boots in parallel, then hands
|
|
535
|
+
* off mid-turn for tool execution (or exits clean for pure-text
|
|
536
|
+
* turns).
|
|
537
|
+
*
|
|
538
|
+
* First turn only. Subsequent turns on the same chat bypass this
|
|
539
|
+
* URL and write directly to `session.in` — the same direct-trigger
|
|
540
|
+
* path used when `headStart` is unset. Customers using `headStart`
|
|
541
|
+
* still need `accessToken` and (optionally) `startSession` for
|
|
542
|
+
* those subsequent turns.
|
|
543
|
+
*
|
|
544
|
+
* NOT a stock `useChat` "endpoint" — this is not the canonical
|
|
545
|
+
* request URL for every turn, just the warm first-turn shortcut.
|
|
546
|
+
*
|
|
547
|
+
* In benchmarks, head-starting drops first-turn TTFC roughly in
|
|
548
|
+
* half versus the direct-trigger flow (cold-start agent boot +
|
|
549
|
+
* onTurnStart hook overlap with the LLM TTFB instead of stacking
|
|
550
|
+
* before it).
|
|
551
|
+
*
|
|
552
|
+
* @default undefined (direct-trigger flow on every turn)
|
|
553
|
+
*/
|
|
554
|
+
headStart?: string;
|
|
555
|
+
};
|
|
556
|
+
/**
|
|
557
|
+
* A custom AI SDK `ChatTransport` that runs chat completions as durable
|
|
558
|
+
* Trigger.dev tasks via the Sessions primitive.
|
|
559
|
+
*
|
|
560
|
+
* Lifecycle:
|
|
561
|
+
* 1. Customer pre-creates the session server-side OR calls
|
|
562
|
+
* `transport.start(chatId)` to mint a one-shot start token and
|
|
563
|
+
* `POST /api/v1/sessions` from the browser.
|
|
564
|
+
* 2. The server triggers the first run as part of session create and
|
|
565
|
+
* returns a session-scoped PAT.
|
|
566
|
+
* 3. `sendMessages` appends to `.in` and subscribes to `.out`. When a
|
|
567
|
+
* run dies (idle, cancel, end-and-continue), the server's
|
|
568
|
+
* append-time probe triggers a fresh run for the same session —
|
|
569
|
+
* transport keeps streaming.
|
|
570
|
+
* 4. `stop()` posts a `{kind:"stop"}` chunk; the agent's turn aborts
|
|
571
|
+
* but the run keeps reading `.in` for the next message.
|
|
572
|
+
* 5. PAT expiry: transport invokes `accessToken` to refresh and
|
|
573
|
+
* retries the failing request once.
|
|
574
|
+
*/
|
|
575
|
+
export declare class TriggerChatTransport implements ChatTransport<UIMessage> {
|
|
576
|
+
private readonly taskId;
|
|
577
|
+
private resolveAccessToken;
|
|
578
|
+
private resolveStartSession;
|
|
579
|
+
private readonly resolveBaseURLFn;
|
|
580
|
+
private fetchOverride;
|
|
581
|
+
private readonly extraHeaders;
|
|
582
|
+
private readonly streamTimeoutSeconds;
|
|
583
|
+
private defaultMetadata;
|
|
584
|
+
private readonly watchMode;
|
|
585
|
+
private readonly headStart;
|
|
586
|
+
private coordinator;
|
|
587
|
+
private _onSessionChange;
|
|
588
|
+
private _onEvent;
|
|
589
|
+
private sessions;
|
|
590
|
+
private pendingResumeCursors;
|
|
591
|
+
private activeStreams;
|
|
592
|
+
private pendingStarts;
|
|
593
|
+
private lastTurnSends;
|
|
594
|
+
constructor(options: TriggerChatTransportOptions);
|
|
595
|
+
/**
|
|
596
|
+
* Eagerly create a Session and trigger its first run. Useful as a
|
|
597
|
+
* "the user might be about to send a message — boot the agent now"
|
|
598
|
+
* preload, or to take ownership of the session before any sendMessage.
|
|
599
|
+
*
|
|
600
|
+
* Idempotent: calling `start(chatId)` twice converges to the same
|
|
601
|
+
* session via the `(env, externalId)` upsert. Concurrent calls
|
|
602
|
+
* deduplicate via an in-flight promise.
|
|
603
|
+
*
|
|
604
|
+
* Requires `getStartToken` to be configured. Customers who pre-create
|
|
605
|
+
* sessions server-side don't need to call this.
|
|
606
|
+
*/
|
|
607
|
+
start(chatId: string): Promise<ChatSessionPersistedState>;
|
|
608
|
+
/**
|
|
609
|
+
* Eagerly create the session before the user types. Same semantics as
|
|
610
|
+
* {@link start} — kept as a separate name for the AI SDK Chat hook,
|
|
611
|
+
* which calls `preload` rather than `start`.
|
|
612
|
+
*/
|
|
613
|
+
preload(chatId: string): Promise<void>;
|
|
614
|
+
/**
|
|
615
|
+
* Send a user message via the session's `.in` channel. The server
|
|
616
|
+
* probes `currentRunId`; if terminal/null it triggers a fresh run on
|
|
617
|
+
* the same session before the append lands. The returned
|
|
618
|
+
* `ReadableStream` carries the agent's response chunks via `.out` SSE.
|
|
619
|
+
*/
|
|
620
|
+
sendMessages: (options: {
|
|
621
|
+
trigger: "submit-message" | "regenerate-message";
|
|
622
|
+
chatId: string;
|
|
623
|
+
messageId: string | undefined;
|
|
624
|
+
messages: UIMessage[];
|
|
625
|
+
abortSignal: AbortSignal | undefined;
|
|
626
|
+
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk>>;
|
|
627
|
+
/**
|
|
628
|
+
* First-turn-only path used when `headStart` is configured. POSTs the
|
|
629
|
+
* wire payload to the customer's `chat.handover` route handler and
|
|
630
|
+
* pipes its SSE response back as a UIMessageChunk stream. Hydrates
|
|
631
|
+
* session state from response headers so subsequent turns bypass
|
|
632
|
+
* the endpoint and use the direct `session.in` path.
|
|
633
|
+
*/
|
|
634
|
+
private sendMessagesViaHandover;
|
|
635
|
+
/**
|
|
636
|
+
* Send a steering message during an active stream without disrupting
|
|
637
|
+
* it. The agent's `pendingMessages` config decides whether to inject
|
|
638
|
+
* between tool-call steps or buffer for the next turn.
|
|
639
|
+
*/
|
|
640
|
+
sendPendingMessage: (chatId: string, message: UIMessage, metadata?: Record<string, unknown>) => Promise<boolean>;
|
|
641
|
+
/**
|
|
642
|
+
* Re-establish an SSE subscription to a known session. Used after a
|
|
643
|
+
* page refresh: the customer hydrates `sessions` in the constructor,
|
|
644
|
+
* the AI SDK calls `reconnectToStream` to resume the stream.
|
|
645
|
+
*/
|
|
646
|
+
reconnectToStream: (options: {
|
|
647
|
+
chatId: string;
|
|
648
|
+
abortSignal?: AbortSignal | undefined;
|
|
649
|
+
/**
|
|
650
|
+
* Whether aborting this subscription sends `{kind:"stop"}` on `.in`.
|
|
651
|
+
* A subscription ending is not session ownership — a passive/watch
|
|
652
|
+
* reader unmounting must never stop a turn it doesn't drive. Only
|
|
653
|
+
* pass `true` from a caller that owns the live turn. @default false
|
|
654
|
+
*/
|
|
655
|
+
stopOnAbort?: boolean;
|
|
656
|
+
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk> | null>;
|
|
657
|
+
/**
|
|
658
|
+
* Stop the current generation. Sends `{kind:"stop"}` on `.in`; the
|
|
659
|
+
* agent aborts its `streamText` call but stays alive for the next
|
|
660
|
+
* message.
|
|
661
|
+
*/
|
|
662
|
+
stopGeneration: (chatId: string) => Promise<boolean>;
|
|
663
|
+
/**
|
|
664
|
+
* Clear the supersede gate armed by a stop. Call this when the stopped
|
|
665
|
+
* turn died without ever writing its `trigger:turn-complete` boundary,
|
|
666
|
+
* otherwise the next turn stays gated forever.
|
|
667
|
+
*/
|
|
668
|
+
clearSupersedeGate: (chatId: string) => void;
|
|
669
|
+
/**
|
|
670
|
+
* Send a custom action chunk (for `chat.agent`'s `actionSchema` /
|
|
671
|
+
* `onAction` hook). An action is an edit: only `hydrateMessages` and
|
|
672
|
+
* `onAction` fire on the agent side, and the returned stream completes
|
|
673
|
+
* with `trigger:turn-complete` once the edit is persisted. When `onAction`
|
|
674
|
+
* returns `chat.turn()` the turn's response follows on the same stream.
|
|
675
|
+
* Per-action `metadata` is merged over the transport's `clientData`.
|
|
676
|
+
*/
|
|
677
|
+
sendAction: (chatId: string, action: unknown, options?: ChatActionOptions) => Promise<ReadableStream<UIMessageChunk>>;
|
|
678
|
+
getSession: (chatId: string) => ChatSessionPersistedState | undefined;
|
|
679
|
+
setSession(chatId: string, session: ChatSessionPersistedState): void;
|
|
680
|
+
/**
|
|
681
|
+
* Seed the `.out` resume cursor from a loaded transcript. Applied to the
|
|
682
|
+
* session now if it exists, otherwise held until the session is created so
|
|
683
|
+
* the first live subscription opens past the persisted history instead of
|
|
684
|
+
* replaying it. Never moves an existing cursor backward: the transcript load
|
|
685
|
+
* is async, so a live `.out` record can already have advanced the session
|
|
686
|
+
* past the snapshot, and overwriting it would replay those records.
|
|
687
|
+
*/
|
|
688
|
+
seedResumeCursor: (chatId: string, lastEventId: string) => void;
|
|
689
|
+
private applyPendingResumeCursor;
|
|
690
|
+
setOnSessionChange(callback: ((chatId: string, session: ChatSessionPersistedState | null) => void) | undefined): void;
|
|
691
|
+
/** Update the `onEvent` callback without recreating the transport. */
|
|
692
|
+
setOnEvent(callback: ((event: ChatTransportEvent) => void) | undefined): void;
|
|
693
|
+
private emitEvent;
|
|
694
|
+
/** Run a send op, emitting the terminal message-sent / message-send-failed event. */
|
|
695
|
+
private sendWithEvents;
|
|
696
|
+
/** Attribution fields for response-side events. */
|
|
697
|
+
private turnAttribution;
|
|
698
|
+
/**
|
|
699
|
+
* Update the transport's `clientData`. Used by `useTriggerChatTransport`
|
|
700
|
+
* to keep the latest value reachable from inside `startSession` and
|
|
701
|
+
* the per-turn `metadata` merge without recreating the transport.
|
|
702
|
+
*
|
|
703
|
+
* Reads always go through the live field — closures around the
|
|
704
|
+
* transport see the latest value the next time they fire.
|
|
705
|
+
*/
|
|
706
|
+
setClientData(clientData: Record<string, unknown> | undefined): void;
|
|
707
|
+
/**
|
|
708
|
+
* Update the request-time callbacks. Same reason as `setClientData`:
|
|
709
|
+
* a host that rebuilds these per render (a dashboard navigating between
|
|
710
|
+
* projects) would otherwise keep hitting the endpoint captured at
|
|
711
|
+
* construction. Every read goes through the live field, so the next
|
|
712
|
+
* request uses the latest callback.
|
|
713
|
+
*/
|
|
714
|
+
setAccessToken(accessToken: (params: AccessTokenParams) => string | Promise<string>): void;
|
|
715
|
+
setStartSession(startSession: ((params: StartSessionParams<Record<string, unknown>>) => Promise<StartSessionResult>) | undefined): void;
|
|
716
|
+
setFetch(fetchOverride: ChatFetchOverride | undefined): void;
|
|
717
|
+
isReadOnly(chatId: string): boolean;
|
|
718
|
+
hasClaim(chatId: string): boolean;
|
|
719
|
+
addReadOnlyListener(fn: (chatId: string, isReadOnly: boolean) => void): void;
|
|
720
|
+
removeReadOnlyListener(fn: (chatId: string, isReadOnly: boolean) => void): void;
|
|
721
|
+
broadcastMessages(chatId: string, messages: unknown[]): void;
|
|
722
|
+
addMessagesListener(fn: (chatId: string, messages: unknown[]) => void): void;
|
|
723
|
+
removeMessagesListener(fn: (chatId: string, messages: unknown[]) => void): void;
|
|
724
|
+
dispose(): void;
|
|
725
|
+
private serializeInputChunk;
|
|
726
|
+
private toPersisted;
|
|
727
|
+
/**
|
|
728
|
+
* Flip a session to closed and tell listeners once. Terminal: sends and
|
|
729
|
+
* reconnects stop from here on, and there is no reopening.
|
|
730
|
+
*/
|
|
731
|
+
private markSessionClosed;
|
|
732
|
+
/**
|
|
733
|
+
* Whether the conversation has been closed — by the agent via
|
|
734
|
+
* `chat.close()`, or from outside via `sessions.close()`. Closed is
|
|
735
|
+
* one-way: the transport refuses further sends and reconnects, and the
|
|
736
|
+
* transcript stays readable.
|
|
737
|
+
*/
|
|
738
|
+
sessionStatus: (chatId: string) => "open" | "closed";
|
|
739
|
+
/** The reason the session was closed, when one was given. */
|
|
740
|
+
sessionClosedReason: (chatId: string) => string | undefined;
|
|
741
|
+
private notifySessionChange;
|
|
742
|
+
/**
|
|
743
|
+
* Resolves the session state for a chatId, starting the session if
|
|
744
|
+
* needed (and `getStartToken` is configured). Customers who provide
|
|
745
|
+
* `accessToken` but no `getStartToken` are expected to have created
|
|
746
|
+
* the session server-side; in that case the first `accessToken` call
|
|
747
|
+
* returns a fresh session PAT.
|
|
748
|
+
*/
|
|
749
|
+
private ensureSessionState;
|
|
750
|
+
private doStart;
|
|
751
|
+
/**
|
|
752
|
+
* Run `op` with the session's stored PAT. On 401/403, refresh the PAT
|
|
753
|
+
* via `accessToken` and retry once. Surfaces non-auth errors as-is.
|
|
754
|
+
*/
|
|
755
|
+
private resolveBaseURL;
|
|
756
|
+
/**
|
|
757
|
+
* `fetchClient` for an `out` subscription. Reads `this.fetchOverride` on
|
|
758
|
+
* every call, not once per subscription: a watch-mode subscription
|
|
759
|
+
* reconnects for the lifetime of the page, and `setFetch` may have swapped
|
|
760
|
+
* the override in between.
|
|
761
|
+
*/
|
|
762
|
+
private sseFetchClient;
|
|
763
|
+
private doFetch;
|
|
764
|
+
private appendInputChunk;
|
|
765
|
+
private callWithAuthRetry;
|
|
766
|
+
/**
|
|
767
|
+
* Repair a stale/phantom hydrated session. The cached state pointed at a
|
|
768
|
+
* session that doesn't exist in the current environment (404) — typically
|
|
769
|
+
* because it was persisted against a different trigger environment, or
|
|
770
|
+
* predates the upgrade to the sessions model. Recreate the session via
|
|
771
|
+
* `startSession` and overwrite the cached state **in place** so callers
|
|
772
|
+
* holding a reference (e.g. `sendMessages` before it opens the SSE) pick
|
|
773
|
+
* up the new PAT. The stale `lastEventId` resume cursor is dropped — it
|
|
774
|
+
* pointed at a different environment's stream.
|
|
775
|
+
*/
|
|
776
|
+
private recreateSession;
|
|
777
|
+
/**
|
|
778
|
+
* Open an SSE subscription to the session's `.out` stream and pipe
|
|
779
|
+
* UIMessageChunks through to the AI SDK. Trigger control records
|
|
780
|
+
* (`turn-complete`, `upgrade-required` — see `trigger-control` header
|
|
781
|
+
* on `client-protocol.mdx#records-on-session-out`) are routed by
|
|
782
|
+
* header and never reach the consumer. `upgrade-required` is purely
|
|
783
|
+
* telemetry now since the server handles the run swap inline (see
|
|
784
|
+
* `end-and-continue`).
|
|
785
|
+
*/
|
|
786
|
+
private subscribeToSessionStream;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Convenience constructor matching {@link TriggerChatTransport}.
|
|
790
|
+
*/
|
|
791
|
+
export declare function createChatTransport(options: TriggerChatTransportOptions): TriggerChatTransport;
|
|
792
|
+
export { AgentChat, ChatStream, type AgentChatOptions, type ChatSession, type ChatStreamResult, type ChatToolCall, type ChatToolResult, type InferChatClientData, type InferChatUIMessage, } from "./chat-client.js";
|