@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.
Files changed (732) hide show
  1. package/README.md +29 -9
  2. package/dist/commonjs/imports/ai-runtime-cjs.cjs.map +1 -0
  3. package/dist/commonjs/imports/ai-runtime.d.ts +1 -0
  4. package/dist/commonjs/imports/ai-runtime.js +31 -0
  5. package/dist/commonjs/imports/uncrypto.js +4 -4
  6. package/dist/commonjs/package.json +2 -1
  7. package/dist/commonjs/v3/agentSkillsRuntime.d.ts +28 -0
  8. package/dist/commonjs/v3/agentSkillsRuntime.js +173 -0
  9. package/dist/commonjs/v3/agentSkillsRuntime.js.map +1 -0
  10. package/dist/commonjs/v3/ai-shared.d.ts +156 -0
  11. package/dist/commonjs/v3/ai-shared.js +215 -0
  12. package/dist/commonjs/v3/ai-shared.js.map +1 -0
  13. package/dist/commonjs/v3/ai.d.ts +4225 -0
  14. package/dist/commonjs/v3/ai.js +11569 -0
  15. package/dist/commonjs/v3/ai.js.map +1 -0
  16. package/dist/commonjs/v3/aiAutoTelemetry.d.ts +2 -0
  17. package/dist/commonjs/v3/aiAutoTelemetry.js +81 -0
  18. package/dist/commonjs/v3/aiAutoTelemetry.js.map +1 -0
  19. package/dist/commonjs/v3/auth.d.ts +71 -10
  20. package/dist/commonjs/v3/auth.js +85 -19
  21. package/dist/commonjs/v3/auth.js.map +1 -1
  22. package/dist/commonjs/v3/batch.d.ts +3 -3
  23. package/dist/commonjs/v3/batch.js.map +1 -1
  24. package/dist/commonjs/v3/cache.js.map +1 -1
  25. package/dist/commonjs/v3/chat-client.d.ts +324 -0
  26. package/dist/commonjs/v3/chat-client.js +774 -0
  27. package/dist/commonjs/v3/chat-client.js.map +1 -0
  28. package/dist/commonjs/v3/chat-react.d.ts +244 -0
  29. package/dist/commonjs/v3/chat-react.js +463 -0
  30. package/dist/commonjs/v3/chat-react.js.map +1 -0
  31. package/dist/commonjs/v3/chat-server.d.ts +350 -0
  32. package/dist/commonjs/v3/chat-server.js +965 -0
  33. package/dist/commonjs/v3/chat-server.js.map +1 -0
  34. package/dist/commonjs/v3/chat-tab-coordinator.d.ts +65 -0
  35. package/dist/commonjs/v3/chat-tab-coordinator.js +235 -0
  36. package/dist/commonjs/v3/chat-tab-coordinator.js.map +1 -0
  37. package/dist/commonjs/v3/chat.d.ts +792 -0
  38. package/dist/commonjs/v3/chat.js +1662 -0
  39. package/dist/commonjs/v3/chat.js.map +1 -0
  40. package/dist/commonjs/v3/chatRouteWait.d.ts +21 -0
  41. package/dist/commonjs/v3/chatRouteWait.js +43 -0
  42. package/dist/commonjs/v3/chatRouteWait.js.map +1 -0
  43. package/dist/commonjs/v3/chatSnapshotIo.d.ts +2 -0
  44. package/dist/commonjs/v3/chatSnapshotIo.js +173 -0
  45. package/dist/commonjs/v3/chatSnapshotIo.js.map +1 -0
  46. package/dist/commonjs/v3/chatVersionSkew.d.ts +12 -0
  47. package/dist/commonjs/v3/chatVersionSkew.js +30 -0
  48. package/dist/commonjs/v3/chatVersionSkew.js.map +1 -0
  49. package/dist/commonjs/v3/compactionResponse.d.ts +9 -0
  50. package/dist/commonjs/v3/compactionResponse.js +37 -0
  51. package/dist/commonjs/v3/compactionResponse.js.map +1 -0
  52. package/dist/commonjs/v3/concurrency-shared.d.ts +13 -0
  53. package/dist/commonjs/v3/concurrency-shared.js +35 -0
  54. package/dist/commonjs/v3/concurrency-shared.js.map +1 -0
  55. package/dist/commonjs/v3/concurrencyLimits.d.ts +103 -0
  56. package/dist/commonjs/v3/concurrencyLimits.js +134 -0
  57. package/dist/commonjs/v3/concurrencyLimits.js.map +1 -0
  58. package/dist/commonjs/v3/config.js.map +1 -1
  59. package/dist/commonjs/v3/deployments.d.ts +25 -0
  60. package/dist/commonjs/v3/deployments.js +37 -0
  61. package/dist/commonjs/v3/deployments.js.map +1 -0
  62. package/dist/commonjs/v3/envvars.d.ts +5 -5
  63. package/dist/commonjs/v3/envvars.js.map +1 -1
  64. package/dist/commonjs/v3/externalDeploymentId.d.ts +23 -0
  65. package/dist/commonjs/v3/externalDeploymentId.js +43 -0
  66. package/dist/commonjs/v3/externalDeploymentId.js.map +1 -0
  67. package/dist/commonjs/v3/heartbeats.d.ts +37 -0
  68. package/dist/commonjs/v3/heartbeats.js +45 -0
  69. package/dist/commonjs/v3/heartbeats.js.map +1 -0
  70. package/dist/commonjs/v3/hooks.d.ts +26 -0
  71. package/dist/commonjs/v3/hooks.js +79 -0
  72. package/dist/commonjs/v3/hooks.js.map +1 -0
  73. package/dist/commonjs/v3/idempotencyKeys.d.ts +2 -1
  74. package/dist/commonjs/v3/idempotencyKeys.js +1 -0
  75. package/dist/commonjs/v3/idempotencyKeys.js.map +1 -1
  76. package/dist/commonjs/v3/index.d.ts +20 -5
  77. package/dist/commonjs/v3/index.js +56 -20
  78. package/dist/commonjs/v3/index.js.map +1 -1
  79. package/dist/commonjs/v3/locals.d.ts +3 -0
  80. package/dist/commonjs/v3/locals.js +6 -0
  81. package/dist/commonjs/v3/locals.js.map +1 -0
  82. package/dist/commonjs/v3/managedChatResponse.d.ts +44 -0
  83. package/dist/commonjs/v3/managedChatResponse.js +221 -0
  84. package/dist/commonjs/v3/managedChatResponse.js.map +1 -0
  85. package/dist/commonjs/v3/metadata.d.ts +5 -2
  86. package/dist/commonjs/v3/metadata.js +8 -1
  87. package/dist/commonjs/v3/metadata.js.map +1 -1
  88. package/dist/commonjs/v3/modelFileDownload.d.ts +10 -0
  89. package/dist/commonjs/v3/modelFileDownload.js +164 -0
  90. package/dist/commonjs/v3/modelFileDownload.js.map +1 -0
  91. package/dist/commonjs/v3/otel.d.ts +4 -0
  92. package/dist/commonjs/v3/otel.js +12 -0
  93. package/dist/commonjs/v3/otel.js.map +1 -0
  94. package/dist/commonjs/v3/prompt.d.ts +38 -0
  95. package/dist/commonjs/v3/prompt.js +146 -0
  96. package/dist/commonjs/v3/prompt.js.map +1 -0
  97. package/dist/commonjs/v3/promptManagement.d.ts +26 -0
  98. package/dist/commonjs/v3/promptManagement.js +180 -0
  99. package/dist/commonjs/v3/promptManagement.js.map +1 -0
  100. package/dist/commonjs/v3/prompts.d.ts +3 -0
  101. package/dist/commonjs/v3/prompts.js +15 -0
  102. package/dist/commonjs/v3/prompts.js.map +1 -0
  103. package/dist/commonjs/v3/query.d.ts +545 -0
  104. package/dist/commonjs/v3/query.js +163 -0
  105. package/dist/commonjs/v3/query.js.map +1 -0
  106. package/dist/commonjs/v3/queues.d.ts +107 -0
  107. package/dist/commonjs/v3/queues.js +225 -0
  108. package/dist/commonjs/v3/queues.js.map +1 -0
  109. package/dist/commonjs/v3/retry.d.ts +6 -2
  110. package/dist/commonjs/v3/retry.js +34 -23
  111. package/dist/commonjs/v3/retry.js.map +1 -1
  112. package/dist/commonjs/v3/runs.d.ts +182 -101
  113. package/dist/commonjs/v3/runs.js +99 -5
  114. package/dist/commonjs/v3/runs.js.map +1 -1
  115. package/dist/commonjs/v3/schedules/api.d.ts +8 -1
  116. package/dist/commonjs/v3/schedules/index.d.ts +29 -9
  117. package/dist/commonjs/v3/schedules/index.js +5 -1
  118. package/dist/commonjs/v3/schedules/index.js.map +1 -1
  119. package/dist/commonjs/v3/schemas.d.ts +1 -0
  120. package/dist/commonjs/{integrations.js → v3/schemas.js} +1 -1
  121. package/dist/commonjs/v3/schemas.js.map +1 -0
  122. package/dist/commonjs/v3/sessionTracing.d.ts +7 -0
  123. package/dist/commonjs/v3/sessionTracing.js +44 -0
  124. package/dist/commonjs/v3/sessionTracing.js.map +1 -0
  125. package/dist/commonjs/v3/sessions.d.ts +268 -0
  126. package/dist/commonjs/v3/sessions.js +776 -0
  127. package/dist/commonjs/v3/sessions.js.map +1 -0
  128. package/dist/commonjs/v3/shared.d.ts +129 -24
  129. package/dist/commonjs/v3/shared.js +1527 -689
  130. package/dist/commonjs/v3/shared.js.map +1 -1
  131. package/dist/commonjs/v3/skill.d.ts +99 -0
  132. package/dist/commonjs/v3/skill.js +165 -0
  133. package/dist/commonjs/v3/skill.js.map +1 -0
  134. package/dist/commonjs/v3/skills.d.ts +2 -0
  135. package/dist/commonjs/v3/skills.js +6 -0
  136. package/dist/commonjs/v3/skills.js.map +1 -0
  137. package/dist/commonjs/v3/steeringContext.d.ts +41 -0
  138. package/dist/commonjs/v3/steeringContext.js +118 -0
  139. package/dist/commonjs/v3/steeringContext.js.map +1 -0
  140. package/dist/commonjs/v3/streams.d.ts +298 -0
  141. package/dist/commonjs/v3/streams.js +584 -0
  142. package/dist/commonjs/v3/streams.js.map +1 -0
  143. package/dist/commonjs/v3/tasks.d.ts +19 -4
  144. package/dist/commonjs/v3/tasks.js +15 -1
  145. package/dist/commonjs/v3/tasks.js.map +1 -1
  146. package/dist/commonjs/v3/test/index.d.ts +5 -0
  147. package/dist/commonjs/v3/test/index.js +23 -0
  148. package/dist/commonjs/v3/test/index.js.map +1 -0
  149. package/dist/commonjs/v3/test/mock-channel-connector.d.ts +172 -0
  150. package/dist/commonjs/v3/test/mock-channel-connector.js +173 -0
  151. package/dist/commonjs/v3/test/mock-channel-connector.js.map +1 -0
  152. package/dist/commonjs/v3/test/mock-chat-agent.d.ts +388 -0
  153. package/dist/commonjs/v3/test/mock-chat-agent.js +689 -0
  154. package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -0
  155. package/dist/commonjs/v3/test/setup-catalog.d.ts +1 -0
  156. package/dist/commonjs/v3/test/setup-catalog.js +18 -0
  157. package/dist/commonjs/v3/test/setup-catalog.js.map +1 -0
  158. package/dist/commonjs/v3/test/test-session-handle.d.ts +24 -0
  159. package/dist/commonjs/v3/test/test-session-handle.js +271 -0
  160. package/dist/commonjs/v3/test/test-session-handle.js.map +1 -0
  161. package/dist/commonjs/v3/test/transcript-storage-tests.d.ts +40 -0
  162. package/dist/commonjs/v3/test/transcript-storage-tests.js +258 -0
  163. package/dist/commonjs/v3/test/transcript-storage-tests.js.map +1 -0
  164. package/dist/commonjs/v3/toolResultOrder.d.ts +15 -0
  165. package/dist/commonjs/v3/toolResultOrder.js +58 -0
  166. package/dist/commonjs/v3/toolResultOrder.js.map +1 -0
  167. package/dist/commonjs/v3/transcriptStorage.d.ts +307 -0
  168. package/dist/commonjs/v3/transcriptStorage.js +445 -0
  169. package/dist/commonjs/v3/transcriptStorage.js.map +1 -0
  170. package/dist/commonjs/v3/triggerClient.d.ts +45 -0
  171. package/dist/commonjs/v3/triggerClient.js +114 -0
  172. package/dist/commonjs/v3/triggerClient.js.map +1 -0
  173. package/dist/commonjs/v3/uiMessageChunks.d.ts +1 -0
  174. package/dist/commonjs/v3/uiMessageChunks.js +119 -0
  175. package/dist/commonjs/v3/uiMessageChunks.js.map +1 -0
  176. package/dist/commonjs/v3/usage.js +7 -6
  177. package/dist/commonjs/v3/usage.js.map +1 -1
  178. package/dist/commonjs/v3/wait.d.ts +218 -3
  179. package/dist/commonjs/v3/wait.js +433 -7
  180. package/dist/commonjs/v3/wait.js.map +1 -1
  181. package/dist/commonjs/v3/waitUntil.js.map +1 -1
  182. package/dist/commonjs/v3/webhookWaiters.d.ts +80 -0
  183. package/dist/commonjs/v3/webhookWaiters.js +156 -0
  184. package/dist/commonjs/v3/webhookWaiters.js.map +1 -0
  185. package/dist/commonjs/v3/webhooks.d.ts +192 -2
  186. package/dist/commonjs/v3/webhooks.js +340 -2
  187. package/dist/commonjs/v3/webhooks.js.map +1 -1
  188. package/dist/commonjs/version.js +1 -1
  189. package/dist/esm/imports/ai-runtime.d.ts +2 -0
  190. package/dist/esm/imports/ai-runtime.js +16 -0
  191. package/dist/esm/imports/ai-runtime.js.map +1 -0
  192. package/dist/esm/package.json +2 -1
  193. package/dist/esm/v3/agentSkillsRuntime.d.ts +28 -0
  194. package/dist/esm/v3/agentSkillsRuntime.js +136 -0
  195. package/dist/esm/v3/agentSkillsRuntime.js.map +1 -0
  196. package/dist/esm/v3/ai-shared.d.ts +156 -0
  197. package/dist/esm/v3/ai-shared.js +208 -0
  198. package/dist/esm/v3/ai-shared.js.map +1 -0
  199. package/dist/esm/v3/ai.d.ts +4225 -0
  200. package/dist/esm/v3/ai.js +11550 -0
  201. package/dist/esm/v3/ai.js.map +1 -0
  202. package/dist/esm/v3/aiAutoTelemetry.d.ts +2 -0
  203. package/dist/esm/v3/aiAutoTelemetry.js +78 -0
  204. package/dist/esm/v3/aiAutoTelemetry.js.map +1 -0
  205. package/dist/esm/v3/auth.d.ts +71 -10
  206. package/dist/esm/v3/auth.js +83 -17
  207. package/dist/esm/v3/auth.js.map +1 -1
  208. package/dist/esm/v3/batch.d.ts +3 -3
  209. package/dist/esm/v3/batch.js +2 -2
  210. package/dist/esm/v3/batch.js.map +1 -1
  211. package/dist/esm/v3/chat-client.d.ts +324 -0
  212. package/dist/esm/v3/chat-client.js +769 -0
  213. package/dist/esm/v3/chat-client.js.map +1 -0
  214. package/dist/esm/v3/chat-react.d.ts +244 -0
  215. package/dist/esm/v3/chat-react.js +455 -0
  216. package/dist/esm/v3/chat-react.js.map +1 -0
  217. package/dist/esm/v3/chat-server.d.ts +350 -0
  218. package/dist/esm/v3/chat-server.js +962 -0
  219. package/dist/esm/v3/chat-server.js.map +1 -0
  220. package/dist/esm/v3/chat-tab-coordinator.d.ts +65 -0
  221. package/dist/esm/v3/chat-tab-coordinator.js +231 -0
  222. package/dist/esm/v3/chat-tab-coordinator.js.map +1 -0
  223. package/dist/esm/v3/chat.d.ts +792 -0
  224. package/dist/esm/v3/chat.js +1655 -0
  225. package/dist/esm/v3/chat.js.map +1 -0
  226. package/dist/esm/v3/chatRouteWait.d.ts +21 -0
  227. package/dist/esm/v3/chatRouteWait.js +40 -0
  228. package/dist/esm/v3/chatRouteWait.js.map +1 -0
  229. package/dist/esm/v3/chatSnapshotIo.d.ts +2 -0
  230. package/dist/esm/v3/chatSnapshotIo.js +165 -0
  231. package/dist/esm/v3/chatSnapshotIo.js.map +1 -0
  232. package/dist/esm/v3/chatVersionSkew.d.ts +12 -0
  233. package/dist/esm/v3/chatVersionSkew.js +27 -0
  234. package/dist/esm/v3/chatVersionSkew.js.map +1 -0
  235. package/dist/esm/v3/compactionResponse.d.ts +9 -0
  236. package/dist/esm/v3/compactionResponse.js +34 -0
  237. package/dist/esm/v3/compactionResponse.js.map +1 -0
  238. package/dist/esm/v3/concurrency-shared.d.ts +13 -0
  239. package/dist/esm/v3/concurrency-shared.js +31 -0
  240. package/dist/esm/v3/concurrency-shared.js.map +1 -0
  241. package/dist/esm/v3/concurrencyLimits.d.ts +103 -0
  242. package/dist/esm/v3/concurrencyLimits.js +126 -0
  243. package/dist/esm/v3/concurrencyLimits.js.map +1 -0
  244. package/dist/esm/v3/deployments.d.ts +25 -0
  245. package/dist/esm/v3/deployments.js +34 -0
  246. package/dist/esm/v3/deployments.js.map +1 -0
  247. package/dist/esm/v3/envvars.d.ts +5 -5
  248. package/dist/esm/v3/envvars.js.map +1 -1
  249. package/dist/esm/v3/externalDeploymentId.d.ts +23 -0
  250. package/dist/esm/v3/externalDeploymentId.js +38 -0
  251. package/dist/esm/v3/externalDeploymentId.js.map +1 -0
  252. package/dist/esm/v3/heartbeats.d.ts +37 -0
  253. package/dist/esm/v3/heartbeats.js +42 -0
  254. package/dist/esm/v3/heartbeats.js.map +1 -0
  255. package/dist/esm/v3/hooks.d.ts +26 -0
  256. package/dist/esm/v3/hooks.js +66 -0
  257. package/dist/esm/v3/hooks.js.map +1 -0
  258. package/dist/esm/v3/idempotencyKeys.d.ts +2 -1
  259. package/dist/esm/v3/idempotencyKeys.js +2 -1
  260. package/dist/esm/v3/idempotencyKeys.js.map +1 -1
  261. package/dist/esm/v3/index.d.ts +20 -5
  262. package/dist/esm/v3/index.js +16 -2
  263. package/dist/esm/v3/index.js.map +1 -1
  264. package/dist/esm/v3/locals.d.ts +3 -0
  265. package/dist/esm/v3/locals.js +3 -0
  266. package/dist/esm/v3/locals.js.map +1 -0
  267. package/dist/esm/v3/managedChatResponse.d.ts +44 -0
  268. package/dist/esm/v3/managedChatResponse.js +216 -0
  269. package/dist/esm/v3/managedChatResponse.js.map +1 -0
  270. package/dist/esm/v3/metadata.d.ts +5 -2
  271. package/dist/esm/v3/metadata.js +8 -1
  272. package/dist/esm/v3/metadata.js.map +1 -1
  273. package/dist/esm/v3/modelFileDownload.d.ts +10 -0
  274. package/dist/esm/v3/modelFileDownload.js +161 -0
  275. package/dist/esm/v3/modelFileDownload.js.map +1 -0
  276. package/dist/esm/v3/otel.d.ts +4 -0
  277. package/dist/esm/v3/otel.js +9 -0
  278. package/dist/esm/v3/otel.js.map +1 -0
  279. package/dist/esm/v3/prompt.d.ts +38 -0
  280. package/dist/esm/v3/prompt.js +143 -0
  281. package/dist/esm/v3/prompt.js.map +1 -0
  282. package/dist/esm/v3/promptManagement.d.ts +26 -0
  283. package/dist/esm/v3/promptManagement.js +170 -0
  284. package/dist/esm/v3/promptManagement.js.map +1 -0
  285. package/dist/esm/v3/prompts.d.ts +3 -0
  286. package/dist/esm/v3/prompts.js +3 -0
  287. package/dist/esm/v3/prompts.js.map +1 -0
  288. package/dist/esm/v3/query.d.ts +545 -0
  289. package/dist/esm/v3/query.js +160 -0
  290. package/dist/esm/v3/query.js.map +1 -0
  291. package/dist/esm/v3/queues.d.ts +107 -0
  292. package/dist/esm/v3/queues.js +217 -0
  293. package/dist/esm/v3/queues.js.map +1 -0
  294. package/dist/esm/v3/retry.d.ts +6 -2
  295. package/dist/esm/v3/retry.js +27 -19
  296. package/dist/esm/v3/retry.js.map +1 -1
  297. package/dist/esm/v3/runs.d.ts +179 -98
  298. package/dist/esm/v3/runs.js +99 -5
  299. package/dist/esm/v3/runs.js.map +1 -1
  300. package/dist/esm/v3/schedules/api.d.ts +8 -1
  301. package/dist/esm/v3/schedules/index.d.ts +29 -9
  302. package/dist/esm/v3/schedules/index.js +6 -2
  303. package/dist/esm/v3/schedules/index.js.map +1 -1
  304. package/dist/esm/v3/schemas.d.ts +1 -0
  305. package/dist/esm/v3/schemas.js +2 -0
  306. package/dist/esm/v3/schemas.js.map +1 -0
  307. package/dist/esm/v3/sessionTracing.d.ts +7 -0
  308. package/dist/esm/v3/sessionTracing.js +40 -0
  309. package/dist/esm/v3/sessionTracing.js.map +1 -0
  310. package/dist/esm/v3/sessions.d.ts +268 -0
  311. package/dist/esm/v3/sessions.js +767 -0
  312. package/dist/esm/v3/sessions.js.map +1 -0
  313. package/dist/esm/v3/shared.d.ts +129 -24
  314. package/dist/esm/v3/shared.js +1521 -688
  315. package/dist/esm/v3/shared.js.map +1 -1
  316. package/dist/esm/v3/skill.d.ts +99 -0
  317. package/dist/esm/v3/skill.js +128 -0
  318. package/dist/esm/v3/skill.js.map +1 -0
  319. package/dist/esm/v3/skills.d.ts +2 -0
  320. package/dist/esm/v3/skills.js +2 -0
  321. package/dist/esm/v3/skills.js.map +1 -0
  322. package/dist/esm/v3/steeringContext.d.ts +41 -0
  323. package/dist/esm/v3/steeringContext.js +113 -0
  324. package/dist/esm/v3/steeringContext.js.map +1 -0
  325. package/dist/esm/v3/streams.d.ts +298 -0
  326. package/dist/esm/v3/streams.js +580 -0
  327. package/dist/esm/v3/streams.js.map +1 -0
  328. package/dist/esm/v3/tasks.d.ts +19 -4
  329. package/dist/esm/v3/tasks.js +16 -2
  330. package/dist/esm/v3/tasks.js.map +1 -1
  331. package/dist/esm/v3/test/index.d.ts +5 -0
  332. package/dist/esm/v3/test/index.js +15 -0
  333. package/dist/esm/v3/test/index.js.map +1 -0
  334. package/dist/esm/v3/test/mock-channel-connector.d.ts +172 -0
  335. package/dist/esm/v3/test/mock-channel-connector.js +170 -0
  336. package/dist/esm/v3/test/mock-channel-connector.js.map +1 -0
  337. package/dist/esm/v3/test/mock-chat-agent.d.ts +388 -0
  338. package/dist/esm/v3/test/mock-chat-agent.js +685 -0
  339. package/dist/esm/v3/test/mock-chat-agent.js.map +1 -0
  340. package/dist/esm/v3/test/setup-catalog.d.ts +1 -0
  341. package/dist/esm/v3/test/setup-catalog.js +16 -0
  342. package/dist/esm/v3/test/setup-catalog.js.map +1 -0
  343. package/dist/esm/v3/test/test-session-handle.d.ts +24 -0
  344. package/dist/esm/v3/test/test-session-handle.js +268 -0
  345. package/dist/esm/v3/test/test-session-handle.js.map +1 -0
  346. package/dist/esm/v3/test/transcript-storage-tests.d.ts +40 -0
  347. package/dist/esm/v3/test/transcript-storage-tests.js +255 -0
  348. package/dist/esm/v3/test/transcript-storage-tests.js.map +1 -0
  349. package/dist/esm/v3/toolResultOrder.d.ts +15 -0
  350. package/dist/esm/v3/toolResultOrder.js +55 -0
  351. package/dist/esm/v3/toolResultOrder.js.map +1 -0
  352. package/dist/esm/v3/transcriptStorage.d.ts +307 -0
  353. package/dist/esm/v3/transcriptStorage.js +431 -0
  354. package/dist/esm/v3/transcriptStorage.js.map +1 -0
  355. package/dist/esm/v3/triggerClient.d.ts +45 -0
  356. package/dist/esm/v3/triggerClient.js +77 -0
  357. package/dist/esm/v3/triggerClient.js.map +1 -0
  358. package/dist/esm/v3/uiMessageChunks.d.ts +1 -0
  359. package/dist/esm/v3/uiMessageChunks.js +116 -0
  360. package/dist/esm/v3/uiMessageChunks.js.map +1 -0
  361. package/dist/esm/v3/usage.js +7 -6
  362. package/dist/esm/v3/usage.js.map +1 -1
  363. package/dist/esm/v3/wait.d.ts +218 -3
  364. package/dist/esm/v3/wait.js +431 -7
  365. package/dist/esm/v3/wait.js.map +1 -1
  366. package/dist/esm/v3/webhookWaiters.d.ts +80 -0
  367. package/dist/esm/v3/webhookWaiters.js +149 -0
  368. package/dist/esm/v3/webhookWaiters.js.map +1 -0
  369. package/dist/esm/v3/webhooks.d.ts +192 -2
  370. package/dist/esm/v3/webhooks.js +336 -2
  371. package/dist/esm/v3/webhooks.js.map +1 -1
  372. package/dist/esm/version.js +1 -1
  373. package/docs/ai/observability.mdx +174 -0
  374. package/docs/ai/prompts.mdx +426 -0
  375. package/docs/ai-chat/actions.mdx +148 -0
  376. package/docs/ai-chat/anatomy.mdx +87 -0
  377. package/docs/ai-chat/backend.mdx +933 -0
  378. package/docs/ai-chat/background-injection.mdx +320 -0
  379. package/docs/ai-chat/changelog.mdx +958 -0
  380. package/docs/ai-chat/chat-local.mdx +170 -0
  381. package/docs/ai-chat/client-protocol.mdx +1091 -0
  382. package/docs/ai-chat/compaction.mdx +413 -0
  383. package/docs/ai-chat/custom-agents.mdx +545 -0
  384. package/docs/ai-chat/error-handling.mdx +379 -0
  385. package/docs/ai-chat/fast-starts.mdx +764 -0
  386. package/docs/ai-chat/frontend.mdx +634 -0
  387. package/docs/ai-chat/how-it-works.mdx +226 -0
  388. package/docs/ai-chat/lifecycle-hooks.mdx +532 -0
  389. package/docs/ai-chat/mcp.mdx +97 -0
  390. package/docs/ai-chat/migrating-from-a-route-handler.mdx +594 -0
  391. package/docs/ai-chat/migrating-from-hydrate-messages.mdx +299 -0
  392. package/docs/ai-chat/overview.mdx +86 -0
  393. package/docs/ai-chat/patterns/branching-conversations.mdx +145 -0
  394. package/docs/ai-chat/patterns/code-sandbox.mdx +122 -0
  395. package/docs/ai-chat/patterns/database-persistence.mdx +425 -0
  396. package/docs/ai-chat/patterns/human-in-the-loop.mdx +281 -0
  397. package/docs/ai-chat/patterns/large-payloads.mdx +165 -0
  398. package/docs/ai-chat/patterns/native-compaction.mdx +310 -0
  399. package/docs/ai-chat/patterns/oom-resilience.mdx +116 -0
  400. package/docs/ai-chat/patterns/persistence-and-replay.mdx +218 -0
  401. package/docs/ai-chat/patterns/recovery-boot.mdx +233 -0
  402. package/docs/ai-chat/patterns/redacting-telemetry.mdx +117 -0
  403. package/docs/ai-chat/patterns/skills.mdx +214 -0
  404. package/docs/ai-chat/patterns/sub-agents.mdx +412 -0
  405. package/docs/ai-chat/patterns/tool-result-auditing.mdx +145 -0
  406. package/docs/ai-chat/patterns/trusted-edge-signals.mdx +333 -0
  407. package/docs/ai-chat/patterns/version-upgrades.mdx +261 -0
  408. package/docs/ai-chat/pending-messages.mdx +363 -0
  409. package/docs/ai-chat/prompt-caching.mdx +204 -0
  410. package/docs/ai-chat/quick-start.mdx +163 -0
  411. package/docs/ai-chat/reference.mdx +1071 -0
  412. package/docs/ai-chat/server-chat.mdx +259 -0
  413. package/docs/ai-chat/sessions.mdx +334 -0
  414. package/docs/ai-chat/side-channels.mdx +172 -0
  415. package/docs/ai-chat/testing.mdx +691 -0
  416. package/docs/ai-chat/tools.mdx +192 -0
  417. package/docs/ai-chat/transcript-storage.mdx +247 -0
  418. package/docs/ai-chat/types.mdx +242 -0
  419. package/docs/ai-chat/upgrade-guide.mdx +511 -0
  420. package/docs/apikeys.mdx +170 -0
  421. package/docs/billing-limits.mdx +73 -0
  422. package/docs/building-with-ai.mdx +261 -0
  423. package/docs/bulk-actions.mdx +77 -0
  424. package/docs/changelog.mdx +6 -0
  425. package/docs/cli-deploy-commands.mdx +9 -0
  426. package/docs/cli-dev-commands.mdx +9 -0
  427. package/docs/cli-env-commands.mdx +115 -0
  428. package/docs/cli-init-commands.mdx +84 -0
  429. package/docs/cli-introduction.mdx +25 -0
  430. package/docs/cli-list-profiles-commands.mdx +42 -0
  431. package/docs/cli-login-commands.mdx +53 -0
  432. package/docs/cli-logout-commands.mdx +33 -0
  433. package/docs/cli-preview-archive.mdx +59 -0
  434. package/docs/cli-projects-commands.mdx +74 -0
  435. package/docs/cli-promote-commands.mdx +9 -0
  436. package/docs/cli-runs-commands.mdx +95 -0
  437. package/docs/cli-switch.mdx +43 -0
  438. package/docs/cli-tasks-commands.mdx +95 -0
  439. package/docs/cli-update-commands.mdx +48 -0
  440. package/docs/cli-whoami-commands.mdx +45 -0
  441. package/docs/community.mdx +6 -0
  442. package/docs/concurrency.mdx +416 -0
  443. package/docs/config/config-file.mdx +662 -0
  444. package/docs/config/extensions/additionalFiles.mdx +38 -0
  445. package/docs/config/extensions/additionalPackages.mdx +40 -0
  446. package/docs/config/extensions/aptGet.mdx +34 -0
  447. package/docs/config/extensions/audioWaveform.mdx +23 -0
  448. package/docs/config/extensions/custom.mdx +393 -0
  449. package/docs/config/extensions/emitDecoratorMetadata.mdx +52 -0
  450. package/docs/config/extensions/esbuildPlugin.mdx +31 -0
  451. package/docs/config/extensions/ffmpeg.mdx +45 -0
  452. package/docs/config/extensions/lightpanda.mdx +56 -0
  453. package/docs/config/extensions/overview.mdx +69 -0
  454. package/docs/config/extensions/playwright.mdx +195 -0
  455. package/docs/config/extensions/prismaExtension.mdx +1013 -0
  456. package/docs/config/extensions/puppeteer.mdx +28 -0
  457. package/docs/config/extensions/pythonExtension.mdx +190 -0
  458. package/docs/config/extensions/syncEnvVars.mdx +330 -0
  459. package/docs/context.mdx +235 -0
  460. package/docs/database-connections.mdx +213 -0
  461. package/docs/deploy-environment-variables.mdx +466 -0
  462. package/docs/deployment/atomic-deployment.mdx +470 -0
  463. package/docs/deployment/dev-branches.mdx +92 -0
  464. package/docs/deployment/overview.mdx +260 -0
  465. package/docs/deployment/preview-branches.mdx +227 -0
  466. package/docs/errors-retrying.mdx +383 -0
  467. package/docs/github-actions.mdx +260 -0
  468. package/docs/github-integration.mdx +148 -0
  469. package/docs/github-repo.mdx +8 -0
  470. package/docs/help-email.mdx +6 -0
  471. package/docs/help-slack.mdx +12 -0
  472. package/docs/hidden-tasks.mdx +56 -0
  473. package/docs/how-it-works.mdx +454 -0
  474. package/docs/how-to-reduce-your-spend.mdx +211 -0
  475. package/docs/idempotency.mdx +542 -0
  476. package/docs/introduction.mdx +135 -0
  477. package/docs/limits.mdx +284 -0
  478. package/docs/logging.mdx +195 -0
  479. package/docs/machines.mdx +952 -0
  480. package/docs/manual-setup.mdx +632 -0
  481. package/docs/mcp-agent-rules.mdx +41 -0
  482. package/docs/mcp-introduction.mdx +386 -0
  483. package/docs/mcp-tools.mdx +425 -0
  484. package/docs/migrating-from-v3.mdx +332 -0
  485. package/docs/observability/dashboards.mdx +166 -0
  486. package/docs/observability/query.mdx +614 -0
  487. package/docs/open-source-contributing.mdx +16 -0
  488. package/docs/private-networking/aws-console-setup.mdx +304 -0
  489. package/docs/private-networking/overview.mdx +144 -0
  490. package/docs/private-networking/troubleshooting.mdx +78 -0
  491. package/docs/queues.mdx +271 -0
  492. package/docs/quick-start.mdx +60 -0
  493. package/docs/realtime/auth.mdx +228 -0
  494. package/docs/realtime/backend/input-streams.mdx +159 -0
  495. package/docs/realtime/backend/overview.mdx +45 -0
  496. package/docs/realtime/backend/streams.mdx +433 -0
  497. package/docs/realtime/backend/subscribe.mdx +225 -0
  498. package/docs/realtime/how-it-works.mdx +94 -0
  499. package/docs/realtime/overview.mdx +63 -0
  500. package/docs/realtime/react-hooks/overview.mdx +73 -0
  501. package/docs/realtime/react-hooks/session-stream.mdx +126 -0
  502. package/docs/realtime/react-hooks/streams.mdx +517 -0
  503. package/docs/realtime/react-hooks/subscribe.mdx +690 -0
  504. package/docs/realtime/react-hooks/swr.mdx +87 -0
  505. package/docs/realtime/react-hooks/triggering.mdx +194 -0
  506. package/docs/realtime/react-hooks/use-wait-token.mdx +34 -0
  507. package/docs/realtime/run-object.mdx +197 -0
  508. package/docs/replaying.mdx +97 -0
  509. package/docs/reports.mdx +159 -0
  510. package/docs/request-feature.mdx +6 -0
  511. package/docs/roadmap.mdx +6 -0
  512. package/docs/run-tests.mdx +21 -0
  513. package/docs/run-usage.mdx +113 -0
  514. package/docs/runs/bulk-actions.mdx +183 -0
  515. package/docs/runs/heartbeats.mdx +38 -0
  516. package/docs/runs/list-best-practices.mdx +234 -0
  517. package/docs/runs/max-duration.mdx +143 -0
  518. package/docs/runs/metadata.mdx +731 -0
  519. package/docs/runs/priority.mdx +8 -0
  520. package/docs/runs.mdx +406 -0
  521. package/docs/self-hosting/docker.mdx +512 -0
  522. package/docs/self-hosting/env/supervisor.mdx +78 -0
  523. package/docs/self-hosting/env/webapp.mdx +305 -0
  524. package/docs/self-hosting/kubernetes.mdx +725 -0
  525. package/docs/self-hosting/overview.mdx +145 -0
  526. package/docs/self-hosting/security.mdx +67 -0
  527. package/docs/skills.mdx +85 -0
  528. package/docs/tags.mdx +126 -0
  529. package/docs/tasks/overview.mdx +695 -0
  530. package/docs/tasks/scheduled.mdx +479 -0
  531. package/docs/tasks/schemaTask.mdx +413 -0
  532. package/docs/tasks/streams.mdx +887 -0
  533. package/docs/triggering.mdx +1340 -0
  534. package/docs/troubleshooting-alerts.mdx +607 -0
  535. package/docs/troubleshooting-debugging-in-vscode.mdx +9 -0
  536. package/docs/troubleshooting-github-issues.mdx +6 -0
  537. package/docs/troubleshooting-uptime-status.mdx +7 -0
  538. package/docs/troubleshooting-zod.mdx +158 -0
  539. package/docs/troubleshooting.mdx +414 -0
  540. package/docs/upgrading-packages.mdx +80 -0
  541. package/docs/vercel-integration.mdx +250 -0
  542. package/docs/versioning.mdx +58 -0
  543. package/docs/video-walkthrough.mdx +23 -0
  544. package/docs/wait-for-token.mdx +540 -0
  545. package/docs/wait-for.mdx +42 -0
  546. package/docs/wait-until.mdx +53 -0
  547. package/docs/wait.mdx +18 -0
  548. package/docs/webhooks/channels.mdx +154 -0
  549. package/docs/webhooks/connect.mdx +91 -0
  550. package/docs/webhooks/deliveries.mdx +99 -0
  551. package/docs/webhooks/filters.mdx +146 -0
  552. package/docs/webhooks/human-in-the-loop.mdx +158 -0
  553. package/docs/webhooks/linear.mdx +186 -0
  554. package/docs/webhooks/overview.mdx +115 -0
  555. package/docs/webhooks/session-routing.mdx +141 -0
  556. package/docs/webhooks/slack.mdx +393 -0
  557. package/docs/webhooks/sources.mdx +250 -0
  558. package/docs/webhooks/waiters.mdx +190 -0
  559. package/docs/writing-tasks-introduction.mdx +34 -0
  560. package/package.json +143 -42
  561. package/skills/trigger-authoring-chat-agent/SKILL.md +308 -0
  562. package/skills/trigger-authoring-tasks/SKILL.md +254 -0
  563. package/skills/trigger-chat-agent-advanced/SKILL.md +403 -0
  564. package/skills/trigger-cost-savings/SKILL.md +116 -0
  565. package/skills/trigger-realtime-and-frontend/SKILL.md +276 -0
  566. package/dist/commonjs/apiClient.d.ts +0 -727
  567. package/dist/commonjs/apiClient.js +0 -692
  568. package/dist/commonjs/apiClient.js.map +0 -1
  569. package/dist/commonjs/concurrencyLimit.d.ts +0 -10
  570. package/dist/commonjs/concurrencyLimit.js +0 -17
  571. package/dist/commonjs/concurrencyLimit.js.map +0 -1
  572. package/dist/commonjs/errors.d.ts +0 -66
  573. package/dist/commonjs/errors.js +0 -109
  574. package/dist/commonjs/errors.js.map +0 -1
  575. package/dist/commonjs/httpEndpoint.d.ts +0 -87
  576. package/dist/commonjs/httpEndpoint.js +0 -130
  577. package/dist/commonjs/httpEndpoint.js.map +0 -1
  578. package/dist/commonjs/index.d.ts +0 -23
  579. package/dist/commonjs/index.js +0 -55
  580. package/dist/commonjs/index.js.map +0 -1
  581. package/dist/commonjs/integrations.d.ts +0 -11
  582. package/dist/commonjs/integrations.js.map +0 -1
  583. package/dist/commonjs/io.d.ts +0 -441
  584. package/dist/commonjs/io.js +0 -1165
  585. package/dist/commonjs/io.js.map +0 -1
  586. package/dist/commonjs/ioWithIntegrations.d.ts +0 -4
  587. package/dist/commonjs/ioWithIntegrations.js +0 -32
  588. package/dist/commonjs/ioWithIntegrations.js.map +0 -1
  589. package/dist/commonjs/job.d.ts +0 -96
  590. package/dist/commonjs/job.js +0 -210
  591. package/dist/commonjs/job.js.map +0 -1
  592. package/dist/commonjs/retry.d.ts +0 -20
  593. package/dist/commonjs/retry.js +0 -22
  594. package/dist/commonjs/retry.js.map +0 -1
  595. package/dist/commonjs/runLocalStorage.d.ts +0 -8
  596. package/dist/commonjs/runLocalStorage.js +0 -6
  597. package/dist/commonjs/runLocalStorage.js.map +0 -1
  598. package/dist/commonjs/security.d.ts +0 -18
  599. package/dist/commonjs/security.js +0 -41
  600. package/dist/commonjs/security.js.map +0 -1
  601. package/dist/commonjs/status.d.ts +0 -19
  602. package/dist/commonjs/status.js +0 -38
  603. package/dist/commonjs/status.js.map +0 -1
  604. package/dist/commonjs/store/keyValueStore.d.ts +0 -17
  605. package/dist/commonjs/store/keyValueStore.js +0 -138
  606. package/dist/commonjs/store/keyValueStore.js.map +0 -1
  607. package/dist/commonjs/store/keyValueStoreClient.d.ts +0 -19
  608. package/dist/commonjs/store/keyValueStoreClient.js +0 -65
  609. package/dist/commonjs/store/keyValueStoreClient.js.map +0 -1
  610. package/dist/commonjs/triggerClient.d.ts +0 -290
  611. package/dist/commonjs/triggerClient.js +0 -1366
  612. package/dist/commonjs/triggerClient.js.map +0 -1
  613. package/dist/commonjs/triggers/dynamic.d.ts +0 -56
  614. package/dist/commonjs/triggers/dynamic.js +0 -97
  615. package/dist/commonjs/triggers/dynamic.js.map +0 -1
  616. package/dist/commonjs/triggers/eventTrigger.d.ts +0 -58
  617. package/dist/commonjs/triggers/eventTrigger.js +0 -69
  618. package/dist/commonjs/triggers/eventTrigger.js.map +0 -1
  619. package/dist/commonjs/triggers/externalSource.d.ts +0 -148
  620. package/dist/commonjs/triggers/externalSource.js +0 -106
  621. package/dist/commonjs/triggers/externalSource.js.map +0 -1
  622. package/dist/commonjs/triggers/invokeTrigger.d.ts +0 -39
  623. package/dist/commonjs/triggers/invokeTrigger.js +0 -58
  624. package/dist/commonjs/triggers/invokeTrigger.js.map +0 -1
  625. package/dist/commonjs/triggers/notifications.d.ts +0 -111
  626. package/dist/commonjs/triggers/notifications.js +0 -101
  627. package/dist/commonjs/triggers/notifications.js.map +0 -1
  628. package/dist/commonjs/triggers/scheduled.d.ts +0 -145
  629. package/dist/commonjs/triggers/scheduled.js +0 -208
  630. package/dist/commonjs/triggers/scheduled.js.map +0 -1
  631. package/dist/commonjs/triggers/webhook.d.ts +0 -143
  632. package/dist/commonjs/triggers/webhook.js +0 -133
  633. package/dist/commonjs/triggers/webhook.js.map +0 -1
  634. package/dist/commonjs/typed-emitter.d.ts +0 -37
  635. package/dist/commonjs/typed-emitter.js +0 -3
  636. package/dist/commonjs/typed-emitter.js.map +0 -1
  637. package/dist/commonjs/types.d.ts +0 -204
  638. package/dist/commonjs/types.js +0 -23
  639. package/dist/commonjs/types.js.map +0 -1
  640. package/dist/commonjs/utils/formatSchemaErrors.d.ts +0 -3
  641. package/dist/commonjs/utils/formatSchemaErrors.js +0 -10
  642. package/dist/commonjs/utils/formatSchemaErrors.js.map +0 -1
  643. package/dist/commonjs/utils/typedAsyncLocalStorage.d.ts +0 -6
  644. package/dist/commonjs/utils/typedAsyncLocalStorage.js +0 -18
  645. package/dist/commonjs/utils/typedAsyncLocalStorage.js.map +0 -1
  646. package/dist/commonjs/utils.d.ts +0 -1
  647. package/dist/commonjs/utils.js +0 -11
  648. package/dist/commonjs/utils.js.map +0 -1
  649. package/dist/esm/apiClient.d.ts +0 -727
  650. package/dist/esm/apiClient.js +0 -687
  651. package/dist/esm/apiClient.js.map +0 -1
  652. package/dist/esm/concurrencyLimit.d.ts +0 -10
  653. package/dist/esm/concurrencyLimit.js +0 -13
  654. package/dist/esm/concurrencyLimit.js.map +0 -1
  655. package/dist/esm/errors.d.ts +0 -66
  656. package/dist/esm/errors.js +0 -95
  657. package/dist/esm/errors.js.map +0 -1
  658. package/dist/esm/httpEndpoint.d.ts +0 -87
  659. package/dist/esm/httpEndpoint.js +0 -125
  660. package/dist/esm/httpEndpoint.js.map +0 -1
  661. package/dist/esm/index.d.ts +0 -23
  662. package/dist/esm/index.js +0 -35
  663. package/dist/esm/index.js.map +0 -1
  664. package/dist/esm/integrations.d.ts +0 -11
  665. package/dist/esm/integrations.js +0 -2
  666. package/dist/esm/integrations.js.map +0 -1
  667. package/dist/esm/io.d.ts +0 -441
  668. package/dist/esm/io.js +0 -1159
  669. package/dist/esm/io.js.map +0 -1
  670. package/dist/esm/ioWithIntegrations.d.ts +0 -4
  671. package/dist/esm/ioWithIntegrations.js +0 -29
  672. package/dist/esm/ioWithIntegrations.js.map +0 -1
  673. package/dist/esm/job.d.ts +0 -96
  674. package/dist/esm/job.js +0 -206
  675. package/dist/esm/job.js.map +0 -1
  676. package/dist/esm/retry.d.ts +0 -20
  677. package/dist/esm/retry.js +0 -19
  678. package/dist/esm/retry.js.map +0 -1
  679. package/dist/esm/runLocalStorage.d.ts +0 -8
  680. package/dist/esm/runLocalStorage.js +0 -3
  681. package/dist/esm/runLocalStorage.js.map +0 -1
  682. package/dist/esm/security.d.ts +0 -18
  683. package/dist/esm/security.js +0 -34
  684. package/dist/esm/security.js.map +0 -1
  685. package/dist/esm/status.d.ts +0 -19
  686. package/dist/esm/status.js +0 -34
  687. package/dist/esm/status.js.map +0 -1
  688. package/dist/esm/store/keyValueStore.d.ts +0 -17
  689. package/dist/esm/store/keyValueStore.js +0 -134
  690. package/dist/esm/store/keyValueStore.js.map +0 -1
  691. package/dist/esm/store/keyValueStoreClient.d.ts +0 -19
  692. package/dist/esm/store/keyValueStoreClient.js +0 -61
  693. package/dist/esm/store/keyValueStoreClient.js.map +0 -1
  694. package/dist/esm/triggerClient.d.ts +0 -288
  695. package/dist/esm/triggerClient.js +0 -1359
  696. package/dist/esm/triggerClient.js.map +0 -1
  697. package/dist/esm/triggers/dynamic.d.ts +0 -56
  698. package/dist/esm/triggers/dynamic.js +0 -93
  699. package/dist/esm/triggers/dynamic.js.map +0 -1
  700. package/dist/esm/triggers/eventTrigger.d.ts +0 -58
  701. package/dist/esm/triggers/eventTrigger.js +0 -64
  702. package/dist/esm/triggers/eventTrigger.js.map +0 -1
  703. package/dist/esm/triggers/externalSource.d.ts +0 -148
  704. package/dist/esm/triggers/externalSource.js +0 -100
  705. package/dist/esm/triggers/externalSource.js.map +0 -1
  706. package/dist/esm/triggers/invokeTrigger.d.ts +0 -39
  707. package/dist/esm/triggers/invokeTrigger.js +0 -53
  708. package/dist/esm/triggers/invokeTrigger.js.map +0 -1
  709. package/dist/esm/triggers/notifications.d.ts +0 -111
  710. package/dist/esm/triggers/notifications.js +0 -94
  711. package/dist/esm/triggers/notifications.js.map +0 -1
  712. package/dist/esm/triggers/scheduled.d.ts +0 -145
  713. package/dist/esm/triggers/scheduled.js +0 -197
  714. package/dist/esm/triggers/scheduled.js.map +0 -1
  715. package/dist/esm/triggers/webhook.d.ts +0 -143
  716. package/dist/esm/triggers/webhook.js +0 -128
  717. package/dist/esm/triggers/webhook.js.map +0 -1
  718. package/dist/esm/typed-emitter.d.ts +0 -37
  719. package/dist/esm/typed-emitter.js +0 -2
  720. package/dist/esm/typed-emitter.js.map +0 -1
  721. package/dist/esm/types.d.ts +0 -204
  722. package/dist/esm/types.js +0 -19
  723. package/dist/esm/types.js.map +0 -1
  724. package/dist/esm/utils/formatSchemaErrors.d.ts +0 -3
  725. package/dist/esm/utils/formatSchemaErrors.js +0 -7
  726. package/dist/esm/utils/formatSchemaErrors.js.map +0 -1
  727. package/dist/esm/utils/typedAsyncLocalStorage.d.ts +0 -6
  728. package/dist/esm/utils/typedAsyncLocalStorage.js +0 -14
  729. package/dist/esm/utils/typedAsyncLocalStorage.js.map +0 -1
  730. package/dist/esm/utils.d.ts +0 -1
  731. package/dist/esm/utils.js +0 -8
  732. package/dist/esm/utils.js.map +0 -1
@@ -0,0 +1,333 @@
1
+ ---
2
+ title: "Trusted edge signals"
3
+ sidebarTitle: "Trusted edge signals"
4
+ description: "How to safely deliver server-trusted signals (bot scores, JA4, ASN, ReCAPTCHA verdicts) to a chat.agent run via an edge proxy."
5
+ ---
6
+
7
+ A common need for chat-style endpoints is to drive agent behavior from **server-trusted signals** that the browser cannot be allowed to declare itself — bot management scores, JA4 fingerprints, ASN, ReCAPTCHA verdicts, or any other anti-abuse data only the edge can see. The agent's [`clientData`](/ai-chat/reference#withclientdata) channel is the right delivery mechanism, but `clientData` set in the browser is by definition spoofable. The fix is to move the value population out of the browser and into a trusted edge proxy.
8
+
9
+ This page documents the pattern using Cloudflare Workers as the proxy. The same shape applies to any edge layer (custom reverse proxy, Vercel Edge Middleware, AWS Lambda@Edge) — the trust comes from the deployment topology, not from Trigger.dev validating the source.
10
+
11
+ ## Why headers don't work
12
+
13
+ It's tempting to ask whether `POST /realtime/v1/sessions/{id}/in/append` could carry the signal as an HTTP header. It cannot. The realtime route reads only `Authorization` and `X-Part-Id`; the remaining headers are dropped at the route boundary and the body is persisted to the durable stream as opaque bytes. There is no `headers → run payload` channel.
14
+
15
+ The trigger.dev wire payload, on the other hand, has a typed per-turn metadata channel ([`ChatTaskWirePayload.metadata`](/ai-chat/client-protocol#chattaskwirepayload)). It already flows from the wire into [`clientData`](/ai-chat/reference#withclientdata) on every hook (`onBoot`, `onChatStart`, `onTurnStart`, `run`, `onTurnComplete`). That field is where signals must land.
16
+
17
+ ## The trust boundary
18
+
19
+ The pattern has one architectural requirement and one wire-shape convention.
20
+
21
+ **Topology**: the browser must not be able to reach `trigger.dev` directly. All four chat-related requests (`POST /api/v1/sessions`, `GET /realtime/v1/sessions/{id}/out`, `POST /realtime/v1/sessions/{id}/in/append`, `POST /api/v1/auth/jwt/claims`) flow through your edge proxy. The proxy holds the trust; trigger.dev simply persists whatever the proxy writes.
22
+
23
+ **Namespace**: pick a key your edge proxy owns exclusively — e.g. `__cf`, `__edge`, `__trust`. The proxy **strips** anything in that key on the way in and **injects** its own value on every request. Nothing else in your system should write that key. This is the convention that converts deployment topology into a guarantee the agent can rely on.
24
+
25
+ ```mermaid
26
+ sequenceDiagram
27
+ participant Browser
28
+ participant Edge as Edge Proxy (CF Worker)
29
+ participant Trigger as trigger.dev API
30
+ participant Agent as chat.agent run
31
+
32
+ Browser->>Edge: POST /api/v1/sessions { triggerConfig.basePayload.metadata: {...} }
33
+ Edge->>Edge: strip body.triggerConfig.basePayload.metadata.__cf<br/>inject body.triggerConfig.basePayload.metadata.__cf = { botScore, ja4, asn }
34
+ Edge->>Trigger: POST /api/v1/sessions (rewritten body)
35
+ Trigger-->>Agent: run boots with payload.metadata.__cf
36
+ Browser->>Edge: POST /realtime/v1/sessions/{id}/in/append { kind: "message", payload: {...} }
37
+ Edge->>Edge: strip payload.metadata.__cf<br/>inject payload.metadata.__cf
38
+ Edge->>Trigger: POST /in/append (rewritten body)
39
+ Trigger-->>Agent: chat.messages.wait() resolves with payload.metadata.__cf
40
+ ```
41
+
42
+ ## Wire payload — the two endpoints to rewrite
43
+
44
+ The signal needs to land in **two** places. Both bodies are JSON; the edge proxy parses, mutates the namespaced key, and re-serializes.
45
+
46
+ ### `POST /api/v1/sessions` — session create
47
+
48
+ The browser's session-create call carries the first-turn metadata under `triggerConfig.basePayload.metadata`. The proxy mutates that:
49
+
50
+ ```ts
51
+ // Before
52
+ {
53
+ "type": "chat.agent",
54
+ "externalId": "conv-123",
55
+ "taskIdentifier": "my-agent",
56
+ "triggerConfig": {
57
+ "basePayload": {
58
+ "chatId": "conv-123",
59
+ "trigger": "preload",
60
+ "metadata": { "userId": "user-456" }
61
+ }
62
+ }
63
+ }
64
+
65
+ // After
66
+ {
67
+ "type": "chat.agent",
68
+ "externalId": "conv-123",
69
+ "taskIdentifier": "my-agent",
70
+ "triggerConfig": {
71
+ "basePayload": {
72
+ "chatId": "conv-123",
73
+ "trigger": "preload",
74
+ "metadata": {
75
+ "userId": "user-456",
76
+ "__cf": { "botScore": 95, "ja4": "...", "asn": 13335, "country": "US" }
77
+ }
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ ### `POST /realtime/v1/sessions/{id}/in/append` — every follow-up turn
84
+
85
+ The body is a JSON-serialized `ChatInputChunk`. The proxy parses it, checks `kind === "message"`, and mutates `payload.metadata`:
86
+
87
+ ```ts
88
+ // Before
89
+ {
90
+ "kind": "message",
91
+ "payload": {
92
+ "message": { "id": "u-2", "role": "user", "parts": [{ "type": "text", "text": "..." }] },
93
+ "chatId": "conv-123",
94
+ "trigger": "submit-message",
95
+ "metadata": { "userId": "user-456" }
96
+ }
97
+ }
98
+
99
+ // After
100
+ {
101
+ "kind": "message",
102
+ "payload": {
103
+ "message": { ... },
104
+ "chatId": "conv-123",
105
+ "trigger": "submit-message",
106
+ "metadata": {
107
+ "userId": "user-456",
108
+ "__cf": { "botScore": 95, "ja4": "...", "asn": 13335, "country": "US" }
109
+ }
110
+ }
111
+ }
112
+ ```
113
+
114
+ Both bodies stay well under the [per-record cap on `/in/append`](/ai-chat/client-protocol#step-3-send-messages-stops-and-actions) — a typical trust object is ~200 bytes.
115
+
116
+ Other paths — `.out` SSE, `/api/v1/auth/jwt/claims`, anything else — pass through the proxy untouched. The SSE stream in particular must not be buffered; preserve the response body as-is.
117
+
118
+ ## Cloudflare Worker reference implementation
119
+
120
+ A complete worker that proxies all paths to `TRIGGER_API_UPSTREAM` and injects `__cf` on the two body-write endpoints:
121
+
122
+ ```ts
123
+ export interface Env {
124
+ TRIGGER_API_UPSTREAM: string; // e.g. "https://api.trigger.dev"
125
+ }
126
+
127
+ type CfTrustData = {
128
+ botScore: number;
129
+ ja4: string;
130
+ asn: number;
131
+ country: string;
132
+ };
133
+
134
+ function readCfTrustData(request: Request): CfTrustData {
135
+ const cf = (request as Request & { cf?: Record<string, unknown> }).cf;
136
+ const bm = cf?.botManagement as Record<string, unknown> | undefined;
137
+ return {
138
+ botScore: (bm?.score as number) ?? 0,
139
+ ja4: (bm?.ja4 as string) ?? "",
140
+ asn: (cf?.asn as number) ?? 0,
141
+ country: (cf?.country as string) ?? "",
142
+ };
143
+ }
144
+
145
+ function injectCf(metadata: Record<string, unknown> | undefined, cf: CfTrustData) {
146
+ // Strip anything the client tried to send under our namespace,
147
+ // then inject the edge-trusted value. Topology + convention =
148
+ // trust.
149
+ const stripped = { ...(metadata ?? {}) };
150
+ delete stripped.__cf;
151
+ return { ...stripped, __cf: cf };
152
+ }
153
+
154
+ function rewriteSessionsCreate(body: string, cf: CfTrustData) {
155
+ const parsed = JSON.parse(body) as Record<string, unknown>;
156
+ const tc = (parsed.triggerConfig as Record<string, unknown>) ?? {};
157
+ const bp = (tc.basePayload as Record<string, unknown>) ?? {};
158
+ parsed.triggerConfig = {
159
+ ...tc,
160
+ basePayload: { ...bp, metadata: injectCf(bp.metadata as Record<string, unknown>, cf) },
161
+ };
162
+ return JSON.stringify(parsed);
163
+ }
164
+
165
+ function rewriteAppend(body: string, cf: CfTrustData) {
166
+ let parsed: Record<string, unknown>;
167
+ try {
168
+ parsed = JSON.parse(body);
169
+ } catch {
170
+ return body;
171
+ }
172
+ if (parsed.kind !== "message") return body;
173
+ const payload = (parsed.payload as Record<string, unknown>) ?? {};
174
+ parsed.payload = { ...payload, metadata: injectCf(payload.metadata as Record<string, unknown>, cf) };
175
+ return JSON.stringify(parsed);
176
+ }
177
+
178
+ export default {
179
+ async fetch(request: Request, env: Env): Promise<Response> {
180
+ const incoming = new URL(request.url);
181
+ const target = new URL(incoming.pathname + incoming.search, env.TRIGGER_API_UPSTREAM);
182
+ const cf = readCfTrustData(request);
183
+
184
+ const isSessionsCreate =
185
+ request.method === "POST" && incoming.pathname === "/api/v1/sessions";
186
+ const isAppend =
187
+ request.method === "POST" &&
188
+ /^\/realtime\/v1\/sessions\/[^/]+\/in\/append$/.test(incoming.pathname);
189
+
190
+ let body: BodyInit | null = null;
191
+ if (request.method !== "GET" && request.method !== "HEAD") {
192
+ const raw = await request.text();
193
+ if (isSessionsCreate && raw) body = rewriteSessionsCreate(raw, cf);
194
+ else if (isAppend && raw) body = rewriteAppend(raw, cf);
195
+ else body = raw;
196
+ }
197
+
198
+ const headers = new Headers(request.headers);
199
+ headers.delete("host");
200
+ headers.delete("content-length");
201
+
202
+ return fetch(target.toString(), {
203
+ method: request.method,
204
+ headers,
205
+ body,
206
+ redirect: "manual",
207
+ });
208
+ },
209
+ };
210
+ ```
211
+
212
+ Browser-only deployments also need CORS on the worker — echo `Access-Control-Request-Headers` on preflight and set `Access-Control-Allow-Origin` to your frontend origin. The trigger.dev route itself allows all origins, but the worker becomes the visible cross-origin endpoint to the browser.
213
+
214
+ ### Streaming and latency
215
+
216
+ The SDK's `baseURL` accepts a function (see [Browser transport configuration](#browser-transport-configuration)), so the recommended setup routes `.in/append` and session-create through the worker but lets `.out` SSE go direct to `api.trigger.dev`. Body-mutation only happens on the POST paths; the SSE stream is read-only, doesn't need rewriting, and routing it direct saves an edge hop on every reconnect.
217
+
218
+ If you do route `.out` through the proxy (e.g. you want a single origin in front of `api.trigger.dev` and don't care about the extra hop), the template above handles it correctly because the worker returns `response.body` as a `ReadableStream`. **Do not replace that with `await response.text()`** anywhere in your fork; doing so converts the streaming SSE response into a buffered read and breaks per-chunk delivery.
219
+
220
+ [Cloudflare Workers HTTP requests](https://developers.cloudflare.com/workers/platform/limits/) have no wall-clock duration limit while the client stays connected — the 60-second long-poll runs to completion on every plan, including Free. CPU-time limits (10 ms on Free, 30 s default on Paid) only apply to active computation; relaying bytes through `fetch` doesn't burn CPU. The two body-rewrite paths use sub-millisecond CPU for typical message sizes, well under either ceiling.
221
+
222
+ Network-wise the proxy adds one edge hop: roughly 10–50 ms per request round trip versus talking to `api.trigger.dev` directly. Routing SSE direct via the function-form `baseURL` eliminates that hop on the long-lived path.
223
+
224
+ ## Agent side — declare the namespace in `clientDataSchema`
225
+
226
+ Mirror the namespace in the agent so every turn lands typed:
227
+
228
+ ```ts
229
+ import { chat } from "@trigger.dev/sdk/ai";
230
+ import { z } from "zod";
231
+
232
+ export const myAgent = chat
233
+ .withClientData({
234
+ schema: z.object({
235
+ userId: z.string(),
236
+ __cf: z.object({
237
+ botScore: z.number(),
238
+ ja4: z.string(),
239
+ asn: z.number(),
240
+ country: z.string(),
241
+ }),
242
+ }),
243
+ })
244
+ .agent({
245
+ id: "my-agent",
246
+ run: async ({ messages, clientData, signal }) => {
247
+ // Score-based routing. The values arrive from the edge proxy.
248
+ if (clientData.__cf.botScore < 30) {
249
+ return streamText({
250
+ model: anthropic("claude-haiku-4-5"),
251
+ messages: [{ role: "system", content: "Reject politely; do not engage." }],
252
+ abortSignal: signal,
253
+ stopWhen: stepCountIs(15),
254
+ });
255
+ }
256
+
257
+ return streamText({
258
+ model: anthropic("claude-sonnet-4-5"),
259
+ messages,
260
+ abortSignal: signal,
261
+ // ...
262
+ stopWhen: stepCountIs(15),
263
+ });
264
+ },
265
+ });
266
+ ```
267
+
268
+ Because the schema requires `__cf` on every turn, any request that *doesn't* go through the proxy fails at the agent boundary — the turn produces a `[ERROR]` span on the trace and an empty `turn-complete` on the wire (see [the client protocol error-detection note](/ai-chat/client-protocol#step-3-send-messages-stops-and-actions)). That gives you a server-side enforcement check for "did this request actually come through the trusted path?"
269
+
270
+ ## Browser transport configuration
271
+
272
+ Point the `TriggerChatTransport` at the worker, not at `api.trigger.dev`:
273
+
274
+ `baseURL` accepts a function so you can route `.in/append` through the worker while keeping `.out` SSE direct to `api.trigger.dev`. The append path is where the body-mutation matters; the SSE stream is a read-only one-way channel that doesn't need to be proxied. Routing it direct saves an edge hop on every long-poll.
275
+
276
+ ```tsx
277
+ import { useTriggerChatTransport } from "@trigger.dev/sdk/chat/react";
278
+
279
+ const WORKER = "https://worker.your-domain.com";
280
+ const DIRECT = "https://api.trigger.dev";
281
+
282
+ const transport = useTriggerChatTransport({
283
+ task: "my-agent",
284
+ baseURL: ({ endpoint }) => (endpoint === "out" ? DIRECT : WORKER),
285
+ // ... accessToken, startSession, etc.
286
+ // NOTE: do not set __cf in clientData here. The browser cannot be
287
+ // trusted to populate it — the worker is the source of truth.
288
+ clientData: { userId: currentUserId },
289
+ });
290
+ ```
291
+
292
+ If you'd rather route everything through the worker, pass a single string:
293
+
294
+ ```tsx
295
+ baseURL: "https://worker.your-domain.com",
296
+ ```
297
+
298
+ `baseURL` accepts the same string-or-function shape on `chat.createStartSessionAction`, so the Next.js server action that creates the session also flows through the worker — that's how the very first run's `basePayload.metadata.__cf` gets injected before reaching `api.trigger.dev`:
299
+
300
+ ```ts
301
+ // actions.ts — server-only
302
+ import { chat } from "@trigger.dev/sdk/ai";
303
+
304
+ export const startSession = chat.createStartSessionAction("my-agent", {
305
+ tokenTTL: "1h",
306
+ baseURL: ({ endpoint }) =>
307
+ endpoint === "sessions" ? WORKER : DIRECT,
308
+ });
309
+ ```
310
+
311
+ The session-create endpoint discriminator is `"sessions"` (POST `/api/v1/sessions`) or `"auth"` (POST `/api/v1/auth/jwt/claims`) — distinct from the chat transport's `"in"` / `"out"`. If you want everything proxied, pass a string.
312
+
313
+ ## Threat model
314
+
315
+ Two important invariants follow from this design:
316
+
317
+ 1. **Direct browser-to-trigger.dev requests cannot succeed**. As long as your agent's `clientDataSchema` requires the namespaced field, any request that doesn't go through the proxy fails schema validation and produces an empty turn. This is your gate.
318
+ 2. **Anything inside the namespaced key is trusted only as far as the proxy is the sole writer**. If a client could obtain the public access token and bypass the proxy, they could send arbitrary values under `__cf`. The schema would still validate (it only checks shape, not provenance). The mitigation is operational: the public access token must only be served to clients that reach trigger.dev through the proxy. In practice this means your Next.js server actions and your browser are both behind the same edge layer, and the worker is the only fetch destination for `trigger.dev` baked into either of them.
319
+
320
+ You can harden further with a shared-secret header the worker injects (e.g. `X-Edge-Signature`) and an agent-side check, but in most CDN deployments the deployment topology is already sufficient.
321
+
322
+ ## Recipe summary
323
+
324
+ 1. Pick a namespaced key the edge proxy owns (`__cf`, `__edge`, `__trust`).
325
+ 2. Deploy a proxy in front of `trigger.dev` that rewrites POST `/api/v1/sessions` and POST `/realtime/v1/sessions/{id}/in/append` to inject your trusted values under that key.
326
+ 3. Declare the namespace in the agent's `clientDataSchema` so missing or malformed signals fail at the agent boundary.
327
+ 4. Point your transport's `baseURL` at the proxy. Never expose `api.trigger.dev` directly to the browser.
328
+
329
+ ## See also
330
+
331
+ - [Client Protocol](/ai-chat/client-protocol) — the full wire shape the proxy is rewriting.
332
+ - [`withClientData`](/ai-chat/reference#withclientdata) — agent-side typed metadata channel.
333
+ - [Large payloads](/ai-chat/patterns/large-payloads) — for when injected signals or hooks need to ship more than the 1 MiB stream cap allows.
@@ -0,0 +1,261 @@
1
+ ---
2
+ title: "Version upgrades"
3
+ sidebarTitle: "Version upgrades"
4
+ description: "Gracefully migrate chat agents to a new deployment using chat.requestUpgrade(), chat.endAndContinue(), and the continuation mechanism."
5
+ ---
6
+
7
+ Chat agent runs are pinned to the worker version they started on. When you deploy a new version, suspended runs resume on the **old** code. If your deploy includes breaking changes (new tools, changed schemas, updated API contracts), this can cause issues.
8
+
9
+ `chat.requestUpgrade()` is the managed upgrade signal for `chat.agent()` and the `chat.createSession()` iterator. Fully hand-rolled custom agents use `chat.endAndContinue()` between turns to immediately hand the Session to a new run.
10
+
11
+ <Note>
12
+ If your sessions are pinned by [version skew
13
+ protection](/deployment/atomic-deployment#chat-sessions), you do not need this page to move a
14
+ conversation onto a new deployment. A pinned session follows its pin on its own: when the stored
15
+ `externalDeploymentId` stops naming the deployment a run is on, the agent hands over at the next
16
+ turn boundary. Set [`versionSkew: "hold"`](#staying-put) to turn that off for one agent.
17
+
18
+ Read on for the cases that are still yours to decide — leaving a pin for a version nobody named,
19
+ a session that was never pinned, and hand-rolled custom agents.
20
+ </Note>
21
+
22
+ ## How it works
23
+
24
+ When `chat.requestUpgrade()` is called in `onTurnStart` or `onValidateMessages`:
25
+
26
+ 1. `run()` is **skipped** — no response is generated on old code
27
+ 2. The agent calls the server-side `endAndContinueSession` endpoint, which atomically swaps the Session's `currentRunId` to a freshly-triggered run on the latest deployment (optimistic-claim against `currentRunVersion`)
28
+ 3. The new run picks up the conversation and produces the response
29
+ 4. The transport's existing SSE subscription to `session.out` keeps receiving chunks across the swap — no client-side reconnect
30
+
31
+ The new run lives on the **same Session** as the old one. `chatId` is the durable identity; only the underlying `currentRunId` rotates. The audit log records the new run with `reason: "upgrade"`.
32
+
33
+ ### What "the latest deployment" means
34
+
35
+ The handoff clears the session's [external deployment id](/deployment/atomic-deployment#chat-sessions) so the new run can land on the current version — re-applying the pin the agent just rejected would make the upgrade impossible. The cleared pin is persisted on the session, so the next continuation doesn't fall back to it either.
36
+
37
+ To move to a specific deployment rather than to whatever is current, name it:
38
+
39
+ ```ts
40
+ chat.requestUpgrade({ externalDeploymentId: clientData.commitSha });
41
+ ```
42
+
43
+ That is usually what you want when the client told you which build it is on: it upgrades to the version the client expects instead of merely to the newest one.
44
+
45
+ <Warning>
46
+ `lockToVersion` is a different thing and is **never** cleared. A session started with an explicit
47
+ `lockToVersion` re-applies it on every run including upgrade handoffs, so `chat.requestUpgrade()`
48
+ cannot escape it — the new run lands on the same version the old one did. Use the external
49
+ deployment id if you want a pin an agent can opt out of.
50
+ </Warning>
51
+
52
+ When called from inside `run()` or `chat.defer()`, the current turn completes normally first and the run exits afterward. The next message triggers the continuation on the same session.
53
+
54
+ ```mermaid
55
+ sequenceDiagram
56
+ participant User
57
+ participant Transport
58
+ participant Session as session.in
59
+ participant RunV1 as Run (v1)
60
+ participant RunV2 as Run (v2)
61
+
62
+ User->>Transport: send message
63
+ Transport->>Session: append message
64
+ Session->>RunV1: input stream
65
+ RunV1->>RunV1: onTurnStart → requestUpgrade()
66
+ RunV1->>RunV2: end-and-continue triggers the successor
67
+ RunV1-->>Transport: trigger:upgrade-required (filtered, no re-send)
68
+ RunV1->>RunV1: exit (run() never called, message left unacknowledged)
69
+ Session->>RunV2: same message, replayed on boot
70
+ RunV2-->>Transport: response stream (same session.out)
71
+ Transport-->>User: response (seamless)
72
+ ```
73
+
74
+ ## Contract versioning
75
+
76
+ Define an explicit version for the contract between your frontend and agent. The frontend sends a `protocolVersion` via `clientData`, and the agent declares which versions it supports. When a breaking change ships (new tools, changed data parts, updated response format), bump the version.
77
+
78
+ This gives you full control — the frontend can be backwards-compatible across multiple agent versions, and the agent only upgrades when it sees a version it doesn't support.
79
+
80
+ ```tsx title="app/components/Chat.tsx"
81
+ import { useTriggerChatTransport } from "@trigger.dev/sdk/chat/react";
82
+ import { useChat } from "@ai-sdk/react";
83
+
84
+ export function Chat() {
85
+ const transport = useTriggerChatTransport({
86
+ task: "my-chat",
87
+ accessToken: ({ chatId }) => mintChatAccessToken(chatId),
88
+ startSession: ({ chatId, clientData }) =>
89
+ startChatSession({ chatId, clientData }),
90
+ // Bump this when you ship a breaking change to the chat UI or tools
91
+ clientData: { userId: user.id, protocolVersion: "v2" },
92
+ });
93
+
94
+ const { messages, sendMessage } = useChat({ transport });
95
+ // ...
96
+ }
97
+ ```
98
+
99
+ On the agent side, declare which versions the current code supports:
100
+
101
+ ```ts
102
+ import { chat } from "@trigger.dev/sdk/ai";
103
+ import { streamText } from "ai";
104
+ import { anthropic } from "@ai-sdk/anthropic";
105
+
106
+ // The set of frontend protocol versions this agent code supports.
107
+ // When you deploy a breaking change, remove old versions from this set.
108
+ const SUPPORTED_VERSIONS = new Set(["v2", "v3"]);
109
+
110
+ export const myChat = chat
111
+ .withClientData({
112
+ schema: z.object({
113
+ userId: z.string(),
114
+ protocolVersion: z.string(),
115
+ }),
116
+ })
117
+ .agent({
118
+ id: "my-chat",
119
+ onTurnStart: async ({ clientData }) => {
120
+ if (clientData?.protocolVersion && !SUPPORTED_VERSIONS.has(clientData.protocolVersion)) {
121
+ chat.requestUpgrade();
122
+ }
123
+ },
124
+ run: async ({ messages, signal }) => {
125
+ return streamText({ model: anthropic("claude-sonnet-4-5"), messages, abortSignal: signal });
126
+ },
127
+ });
128
+ ```
129
+
130
+ The transport includes `clientData` in every payload — both the initial trigger and subsequent records on the session's `.in` channel — so the agent always has the current value.
131
+
132
+ This pattern is useful when:
133
+ - Your frontend is backwards-compatible across several agent versions, but occasionally ships breaking changes
134
+ - You want explicit control over when upgrades happen rather than upgrading on every deploy
135
+ - Multiple frontend versions may be active at the same time (e.g., users with cached tabs)
136
+
137
+ ## Auto-detect from build ID (Next.js / Vercel)
138
+
139
+ <Warning>
140
+ You probably don't need this any more. If your sessions are pinned, following the pin is the
141
+ built-in behaviour and it needs no `clientData` and no `chat.local`. Reach for the recipe below
142
+ only when you want to upgrade on a signal the pin doesn't carry — a frontend build id that moves
143
+ independently of the deployment your app names.
144
+ </Warning>
145
+
146
+ For automatic upgrade on every deploy, pass your platform's build ID via `clientData` instead of a manual version. The agent stores the ID from the first message and upgrades when it changes:
147
+
148
+ ```tsx title="app/components/Chat.tsx"
149
+ // Vercel sets this at build time, or use your own build ID
150
+ const APP_VERSION = process.env.NEXT_PUBLIC_VERCEL_DEPLOYMENT_ID
151
+ ?? process.env.NEXT_PUBLIC_BUILD_ID
152
+ ?? "dev";
153
+
154
+ export function Chat() {
155
+ const transport = useTriggerChatTransport({
156
+ task: "my-chat",
157
+ accessToken: ({ chatId }) => mintChatAccessToken(chatId),
158
+ startSession: ({ chatId, clientData }) =>
159
+ startChatSession({ chatId, clientData }),
160
+ clientData: { userId: user.id, appVersion: APP_VERSION },
161
+ });
162
+ // ...
163
+ }
164
+ ```
165
+
166
+ ```ts title="trigger/chat.ts"
167
+ const initialAppVersion = chat.local<{ version: string }>({ id: "appVersion" });
168
+
169
+ export const myChat = chat
170
+ .withClientData({
171
+ schema: z.object({
172
+ userId: z.string(),
173
+ appVersion: z.string(),
174
+ }),
175
+ })
176
+ .agent({
177
+ id: "my-chat",
178
+ onBoot: async ({ clientData }) => {
179
+ initialAppVersion.init({ version: clientData.appVersion });
180
+ },
181
+ onTurnStart: async ({ clientData }) => {
182
+ if (clientData?.appVersion && clientData.appVersion !== initialAppVersion.version) {
183
+ chat.requestUpgrade();
184
+ }
185
+ },
186
+ run: async ({ messages, signal }) => {
187
+ return streamText({ model: anthropic("claude-sonnet-4-5"), messages, abortSignal: signal });
188
+ },
189
+ });
190
+ ```
191
+
192
+ This upgrades on **every** deploy, not just breaking changes. Good for fast-moving projects where you always want the latest code.
193
+
194
+ ## Staying put
195
+
196
+ A pinned session follows its pin by default. To keep one agent where it is — a long tool chain you
197
+ don't want interrupted, or a conversation you'd rather move on your own terms — set `versionSkew`:
198
+
199
+ ```ts
200
+ export const myChat = chat.agent({
201
+ id: "my-chat",
202
+ versionSkew: "hold",
203
+ run: async ({ messages, signal }) => { ... },
204
+ });
205
+ ```
206
+
207
+ `"hold"` only stops the automatic handoff. `chat.requestUpgrade()` still works, so you can keep the
208
+ decision and still get the seamless swap.
209
+
210
+ Two cases never hand over automatically, whatever `versionSkew` says:
211
+
212
+ - **A session with no pin.** There is nothing to compare against, and an unpinned session already
213
+ lands on the current version every time it starts a run.
214
+ - **A session using `lockToVersion`.** That pin outranks the external deployment id and
215
+ `chat.requestUpgrade()` cannot escape it, so handing over would land on the same version and
216
+ repeat.
217
+
218
+ <Note>
219
+ Following the pin costs one session read per turn on pinned chats, and the handoff happens at a
220
+ turn boundary — never mid-turn. If the pin names a deployment that hasn't landed yet, the successor
221
+ parks: your messages stay durable, and the transport emits `run-pending-version` with
222
+ `source: "upgrade"` so you can say so in the UI. See [parked
223
+ chats](/deployment/atomic-deployment#chat-sessions).
224
+ </Note>
225
+
226
+ ## Custom agents
227
+
228
+ Use `chat.requestUpgrade()` with `chat.agent()`. With `chat.createSession()`, call `chat.requestUpgrade()`, then advance the iterator once more so it can exit normally. For an immediate handoff, close the iterator before calling `chat.endAndContinue()`. In a fully hand-rolled `chat.customAgent()` task, detach input listeners, persist the completed turn, write its boundary, then call `chat.endAndContinue()` and return immediately:
229
+
230
+ Close a `chat.createSession()` iterator between reads. If `return()` races a `next()` that is already waiting for input, it waits for that read to settle before the handoff can continue. Input dispatched while the iterator is closing is not yielded as a turn and remains available to the continuation unless you write another turn-complete boundary.
231
+
232
+ ```ts
233
+ // Detach any chat.messages.on() subscriptions you created.
234
+ stop.cleanup();
235
+ await persistMessages(conversation.uiMessages);
236
+ await chat.writeTurnComplete();
237
+ await chat.endAndContinue();
238
+ return;
239
+ ```
240
+
241
+ The continuation uses the same durable Session and receives `.in` records that the old run has not consumed. It starts on the latest deployed task version only if the Session is unpinned — a Session carrying `lockToVersion` or an `externalDeploymentId` re-applies that pin, so the continuation lands where the Session says rather than on the newest build.
242
+
243
+ If input has been dispatched to the old run but should be processed by the continuation, detach the old listeners and skip the final `chat.writeTurnComplete()`. A turn-complete boundary acknowledges the latest input dispatched to the old run, so writing one after that dispatch would cause the continuation to resume past the input.
244
+
245
+ <Warning>
246
+ `chat.endAndContinue()` starts the successor but does not stop the calling run. Perform no more Session reads or writes after calling it, and return from the task. If the handoff fails, the promise rejects.
247
+ </Warning>
248
+
249
+ ## Interaction with recovery boot
250
+
251
+ When `chat.requestUpgrade()` is handled before a turn starts, the SDK immediately hands the Session to a new run, which processes the same input on the latest version. When it is requested during a turn, including through `chat.createSession()`, the current turn finishes and the old run exits; the next input starts the continuation run.
252
+
253
+ Both are graceful exits. [`onRecoveryBoot`](/ai-chat/patterns/recovery-boot) does not fire — the hook is reserved for mid-stream interruptions (cancel, crash, or OOM) where a partial assistant exists on the tail.
254
+
255
+ ## See also
256
+
257
+ - [Version skew protection](/deployment/atomic-deployment#chat-sessions) — pin a session to the deployment matching the app build that started it
258
+ - [Lifecycle hooks](/ai-chat/lifecycle-hooks) — where `onTurnStart` and `onChatResume` fit in the turn cycle
259
+ - [Recovery boot](/ai-chat/patterns/recovery-boot) — the sibling hook for mid-stream interruptions (does NOT fire on `requestUpgrade`)
260
+ - [Database persistence](/ai-chat/patterns/database-persistence) — how continuations interact with session state
261
+ - [Client Protocol](/ai-chat/client-protocol#step-4-handle-continuations) — how clients handle continuations at the wire level