@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,887 @@
1
+ ---
2
+ title: "Streaming data from tasks"
3
+ sidebarTitle: "Streams"
4
+ description: "Pipe continuous data from your Trigger.dev tasks to frontend or backend clients in real time. Stream AI completions, file chunks, progress updates, and more."
5
+ ---
6
+
7
+ **Streams let you pipe data from a running task to your frontend or backend as it's produced.** Think AI completions token by token, progress updates, or file chunks. You can also **send data into** running tasks with [Input Streams](#input-streams) for bidirectional flows (cancel buttons, approvals).
8
+
9
+ For subscribing to **run state changes** (status, metadata, tags) instead, see [Realtime](/realtime/overview).
10
+
11
+ <Note>
12
+ Streams require SDK version **4.1.0 or later** (`@trigger.dev/sdk` and `@trigger.dev/react-hooks`).
13
+ This doc describes the current streams behavior (v2 is the default). For pre-4.1.0 streams, see
14
+ [Pre-4.1.0 streams (legacy)](#pre-410-streams-legacy) below.
15
+ </Note>
16
+
17
+ ## Overview
18
+
19
+ Streams provide:
20
+
21
+ - **Unlimited stream length** (previously capped at 2000 chunks)
22
+ - **Unlimited active streams per run** (previously 5)
23
+ - **Improved reliability** with automatic resumption on connection loss
24
+ - **28-day stream retention** (previously 1 day)
25
+ - **Multiple client streams** can pipe to a single stream
26
+ - **Enhanced dashboard visibility** for viewing stream data in real-time
27
+
28
+ Streams v2 is the **default** when using SDK 4.1.0 or later. If you trigger tasks outside the SDK, set the `x-trigger-realtime-streams-version=v2` header. To opt out, use `auth.configure({ future: { v2RealtimeStreams: false } })` or `TRIGGER_V2_REALTIME_STREAMS=0`.
29
+
30
+ ## Limits Comparison
31
+
32
+ | Limit | Legacy (pre-4.1.0) | Current |
33
+ | -------------------------------- | ------------------ | --------- |
34
+ | Maximum stream length | 2000 | Unlimited |
35
+ | Number of active streams per run | 5 | Unlimited |
36
+ | Maximum streams per run | 10 | Unlimited |
37
+ | Maximum stream TTL | 1 day | 28 days |
38
+ | Maximum stream size | 10MB | 300 MiB |
39
+
40
+ ## Quick Start
41
+
42
+ The recommended workflow for **output** streams (data from task to client):
43
+
44
+ 1. **Define your streams** in a shared location using `streams.define()`
45
+ 2. **Use the defined stream** in your tasks with `.pipe()`, `.append()`, or `.writer()`
46
+ 3. **Read from the stream** using `.read()` or the `useRealtimeStream` hook in React
47
+
48
+ This approach gives you full type safety, better code organization, and easier maintenance as your application grows. For **input** streams (sending data into a running task), see [Input Streams](#input-streams) below.
49
+
50
+ ## Defining Typed Streams (Recommended)
51
+
52
+ The recommended way to work with streams is to define them once with `streams.define()`. This allows you to specify the chunk type and stream ID in one place, and then reuse that definition throughout your codebase with full type safety.
53
+
54
+ ### Creating a Defined Stream
55
+
56
+ Define your streams in a shared location (like `app/streams.ts` or `trigger/streams.ts`):
57
+
58
+ ```ts
59
+ import { streams, InferStreamType } from "@trigger.dev/sdk";
60
+
61
+ // Define a stream with a specific type
62
+ export const aiStream = streams.define<string>({
63
+ id: "ai-output",
64
+ });
65
+
66
+ // Export the type for use in frontend components
67
+ export type AIStreamPart = InferStreamType<typeof aiStream>;
68
+ ```
69
+
70
+ You can define streams for any JSON-serializable type:
71
+
72
+ ```ts
73
+ import { streams, InferStreamType } from "@trigger.dev/sdk";
74
+ import { UIMessageChunk } from "ai";
75
+
76
+ // Stream for AI UI message chunks
77
+ export const aiStream = streams.define<UIMessageChunk>({
78
+ id: "ai",
79
+ });
80
+
81
+ // Stream for progress updates
82
+ export const progressStream = streams.define<{ step: string; percent: number }>({
83
+ id: "progress",
84
+ });
85
+
86
+ // Stream for simple text
87
+ export const logStream = streams.define<string>({
88
+ id: "logs",
89
+ });
90
+
91
+ // Export types
92
+ export type AIStreamPart = InferStreamType<typeof aiStream>;
93
+ export type ProgressStreamPart = InferStreamType<typeof progressStream>;
94
+ export type LogStreamPart = InferStreamType<typeof logStream>;
95
+ ```
96
+
97
+ ### Using Defined Streams in Tasks
98
+
99
+ Once defined, you can use all stream methods on your defined stream:
100
+
101
+ ```ts
102
+ import { task } from "@trigger.dev/sdk";
103
+ import { aiStream } from "./streams";
104
+
105
+ export const streamTask = task({
106
+ id: "stream-task",
107
+ run: async (payload: { prompt: string }) => {
108
+ // Get a stream from an AI service, database, etc.
109
+ const stream = await getAIStream(payload.prompt);
110
+
111
+ // Pipe the stream using your defined stream
112
+ const { stream: readableStream, waitUntilComplete } = aiStream.pipe(stream);
113
+
114
+ // Option A: Iterate over the stream locally
115
+ for await (const chunk of readableStream) {
116
+ console.log("Received chunk:", chunk);
117
+ }
118
+
119
+ // Option B: Wait for the stream to complete
120
+ await waitUntilComplete();
121
+
122
+ return { message: "Stream completed" };
123
+ },
124
+ });
125
+ ```
126
+
127
+ #### Reading from a Stream
128
+
129
+ Use the defined stream's `read()` method to consume data from anywhere (frontend, backend, or another task):
130
+
131
+ ```ts
132
+ import { aiStream } from "./streams";
133
+
134
+ const stream = await aiStream.read(runId);
135
+
136
+ for await (const chunk of stream) {
137
+ console.log(chunk); // chunk is typed as the stream's chunk type
138
+ }
139
+ ```
140
+
141
+ With options:
142
+
143
+ ```ts
144
+ const stream = await aiStream.read(runId, {
145
+ timeoutInSeconds: 60, // Stop if no data for 60 seconds
146
+ startIndex: 10, // Start from the 10th chunk
147
+ from: "latest", // Or skip history and read only new records from now
148
+ });
149
+ ```
150
+
151
+ Pass `from: "latest"` to start at the current tail and receive only records appended after the read connects, instead of replaying from the beginning.
152
+
153
+ #### Appending to a Stream
154
+
155
+ Use the defined stream's `append()` method to add a single chunk:
156
+
157
+ ```ts
158
+ import { task } from "@trigger.dev/sdk";
159
+ import { aiStream, progressStream, logStream } from "./streams";
160
+
161
+ export const appendTask = task({
162
+ id: "append-task",
163
+ run: async (payload) => {
164
+ // Append to different streams with full type safety
165
+ await logStream.append("Processing started");
166
+ await progressStream.append({ step: "Initialization", percent: 0 });
167
+
168
+ // Do some work...
169
+
170
+ await progressStream.append({ step: "Processing", percent: 50 });
171
+ await logStream.append("Step 1 complete");
172
+
173
+ // Do more work...
174
+
175
+ await progressStream.append({ step: "Complete", percent: 100 });
176
+ await logStream.append("All steps complete");
177
+ },
178
+ });
179
+ ```
180
+
181
+ #### Writing Multiple Chunks
182
+
183
+ Use the defined stream's `writer()` method for more complex stream writing:
184
+
185
+ ```ts
186
+ import { task } from "@trigger.dev/sdk";
187
+ import { logStream } from "./streams";
188
+
189
+ export const writerTask = task({
190
+ id: "writer-task",
191
+ run: async (payload) => {
192
+ const { waitUntilComplete } = logStream.writer({
193
+ execute: ({ write, merge }) => {
194
+ // Write individual chunks
195
+ write("Chunk 1");
196
+ write("Chunk 2");
197
+
198
+ // Merge another stream
199
+ const additionalStream = ReadableStream.from(["Chunk 3", "Chunk 4", "Chunk 5"]);
200
+ merge(additionalStream);
201
+ },
202
+ });
203
+
204
+ await waitUntilComplete();
205
+ },
206
+ });
207
+ ```
208
+
209
+ ### Using Defined Streams in React
210
+
211
+ Defined streams work seamlessly with the `useRealtimeStream` hook:
212
+
213
+ ```tsx
214
+ "use client";
215
+
216
+ import { useRealtimeStream } from "@trigger.dev/react-hooks";
217
+ import { aiStream } from "@/app/streams";
218
+
219
+ export function StreamViewer({ accessToken, runId }: { accessToken: string; runId: string }) {
220
+ // Pass the defined stream directly - full type safety!
221
+ const { parts, error } = useRealtimeStream(aiStream, runId, {
222
+ accessToken,
223
+ timeoutInSeconds: 600,
224
+ });
225
+
226
+ if (error) return <div>Error: {error.message}</div>;
227
+ if (!parts) return <div>Loading...</div>;
228
+
229
+ return (
230
+ <div>
231
+ {parts.map((part, i) => (
232
+ <span key={i}>{part}</span>
233
+ ))}
234
+ </div>
235
+ );
236
+ }
237
+ ```
238
+
239
+ ## Direct Stream Methods (Without Defining)
240
+
241
+ <Warning>
242
+ We strongly recommend using `streams.define()` instead of direct methods. Defined streams provide
243
+ better organization, full type safety, and make it easier to maintain your codebase as it grows.
244
+ </Warning>
245
+
246
+ If you have a specific reason to avoid defined streams, you can use stream methods directly by specifying the stream key each time.
247
+
248
+ ### Direct Piping
249
+
250
+ ```ts
251
+ import { streams, task } from "@trigger.dev/sdk";
252
+
253
+ export const directStreamTask = task({
254
+ id: "direct-stream",
255
+ run: async (payload: { prompt: string }) => {
256
+ const stream = await getAIStream(payload.prompt);
257
+
258
+ // Specify the stream key directly
259
+ const { stream: readableStream, waitUntilComplete } = streams.pipe("ai-output", stream);
260
+
261
+ await waitUntilComplete();
262
+ },
263
+ });
264
+ ```
265
+
266
+ ### Direct Reading
267
+
268
+ ```ts
269
+ import { streams } from "@trigger.dev/sdk";
270
+
271
+ // Specify the stream key when reading
272
+ const stream = await streams.read(runId, "ai-output");
273
+
274
+ for await (const chunk of stream) {
275
+ console.log(chunk);
276
+ }
277
+ ```
278
+
279
+ ### Direct Appending
280
+
281
+ ```ts
282
+ import { streams, task } from "@trigger.dev/sdk";
283
+
284
+ export const directAppendTask = task({
285
+ id: "direct-append",
286
+ run: async (payload) => {
287
+ // Specify the stream key each time
288
+ await streams.append("logs", "Processing started");
289
+ await streams.append("progress", "50%");
290
+ await streams.append("logs", "Complete");
291
+ },
292
+ });
293
+ ```
294
+
295
+ ### Direct Writing
296
+
297
+ ```ts
298
+ import { streams, task } from "@trigger.dev/sdk";
299
+
300
+ export const directWriterTask = task({
301
+ id: "direct-writer",
302
+ run: async (payload) => {
303
+ const { waitUntilComplete } = streams.writer("output", {
304
+ execute: ({ write, merge }) => {
305
+ write("Chunk 1");
306
+ write("Chunk 2");
307
+ },
308
+ });
309
+
310
+ await waitUntilComplete();
311
+ },
312
+ });
313
+ ```
314
+
315
+ ## Default Stream
316
+
317
+ Every run has a "default" stream, allowing you to skip the stream key entirely. This is useful for simple cases where you only need one stream per run.
318
+
319
+ Using direct methods:
320
+
321
+ ```ts
322
+ import { streams, task } from "@trigger.dev/sdk";
323
+
324
+ export const defaultStreamTask = task({
325
+ id: "default-stream",
326
+ run: async (payload) => {
327
+ const stream = getDataStream();
328
+
329
+ // No stream key needed - uses "default"
330
+ const { waitUntilComplete } = streams.pipe(stream);
331
+
332
+ await waitUntilComplete();
333
+ },
334
+ });
335
+
336
+ // Reading from the default stream
337
+ const readStream = await streams.read(runId);
338
+ ```
339
+
340
+ ## Targeting Different Runs
341
+
342
+ You can pipe streams to parent, root, or any other run using the `target` option. This works with both defined streams and direct methods.
343
+
344
+ ### With Defined Streams
345
+
346
+ ```ts
347
+ import { task } from "@trigger.dev/sdk";
348
+ import { logStream } from "./streams";
349
+
350
+ export const childTask = task({
351
+ id: "child-task",
352
+ run: async (payload, { ctx }) => {
353
+ const stream = getDataStream();
354
+
355
+ // Pipe to parent run
356
+ logStream.pipe(stream, { target: "parent" });
357
+
358
+ // Pipe to root run
359
+ logStream.pipe(stream, { target: "root" });
360
+
361
+ // Pipe to self (default behavior)
362
+ logStream.pipe(stream, { target: "self" });
363
+
364
+ // Pipe to a specific run ID
365
+ logStream.pipe(stream, { target: payload.otherRunId });
366
+ },
367
+ });
368
+ ```
369
+
370
+ ### With Direct Methods
371
+
372
+ ```ts
373
+ import { streams, task } from "@trigger.dev/sdk";
374
+
375
+ export const childTask = task({
376
+ id: "child-task",
377
+ run: async (payload, { ctx }) => {
378
+ const stream = getDataStream();
379
+
380
+ // Pipe to parent run
381
+ streams.pipe("output", stream, { target: "parent" });
382
+
383
+ // Pipe to root run
384
+ streams.pipe("output", stream, { target: "root" });
385
+
386
+ // Pipe to a specific run ID
387
+ streams.pipe("output", stream, { target: payload.otherRunId });
388
+ },
389
+ });
390
+ ```
391
+
392
+ ## Streaming from Outside a Task
393
+
394
+ If you specify a `target` run ID, you can pipe streams from anywhere (like a Next.js API route):
395
+
396
+ ```ts
397
+ import { streams } from "@trigger.dev/sdk";
398
+ import { openai } from "@ai-sdk/openai";
399
+ import { streamText } from "ai";
400
+
401
+ export async function POST(req: Request) {
402
+ const { messages, runId } = await req.json();
403
+
404
+ const result = streamText({
405
+ model: openai("gpt-4o"),
406
+ messages,
407
+ });
408
+
409
+ // Pipe AI stream to a Trigger.dev run
410
+ const { stream } = streams.pipe("ai-stream", result.toUIMessageStream(), {
411
+ target: runId,
412
+ });
413
+
414
+ return new Response(stream as any, {
415
+ headers: { "Content-Type": "text/event-stream" },
416
+ });
417
+ }
418
+ ```
419
+
420
+ ## React Hook
421
+
422
+ Use the `useRealtimeStream` hook to subscribe to streams in your React components.
423
+
424
+ ### With Defined Streams (Recommended)
425
+
426
+ ```tsx
427
+ "use client";
428
+
429
+ import { useRealtimeStream } from "@trigger.dev/react-hooks";
430
+ import { aiStream } from "@/app/streams";
431
+
432
+ export function StreamViewer({ accessToken, runId }: { accessToken: string; runId: string }) {
433
+ // Pass the defined stream directly for full type safety
434
+ const { parts, error } = useRealtimeStream(aiStream, runId, {
435
+ accessToken,
436
+ timeoutInSeconds: 600,
437
+ onData: (chunk) => {
438
+ console.log("New chunk:", chunk); // chunk is typed!
439
+ },
440
+ });
441
+
442
+ if (error) return <div>Error: {error.message}</div>;
443
+ if (!parts) return <div>Loading...</div>;
444
+
445
+ return (
446
+ <div>
447
+ {parts.map((part, i) => (
448
+ <span key={i}>{part}</span>
449
+ ))}
450
+ </div>
451
+ );
452
+ }
453
+ ```
454
+
455
+ ### With Direct Stream Keys
456
+
457
+ If you prefer not to use defined streams, you can specify the stream key directly:
458
+
459
+ ```tsx
460
+ "use client";
461
+
462
+ import { useRealtimeStream } from "@trigger.dev/react-hooks";
463
+
464
+ export function StreamViewer({ accessToken, runId }: { accessToken: string; runId: string }) {
465
+ const { parts, error } = useRealtimeStream<string>(runId, "ai-output", {
466
+ accessToken,
467
+ timeoutInSeconds: 600,
468
+ });
469
+
470
+ if (error) return <div>Error: {error.message}</div>;
471
+ if (!parts) return <div>Loading...</div>;
472
+
473
+ return (
474
+ <div>
475
+ {parts.map((part, i) => (
476
+ <span key={i}>{part}</span>
477
+ ))}
478
+ </div>
479
+ );
480
+ }
481
+ ```
482
+
483
+ ### Using Default Stream
484
+
485
+ ```tsx
486
+ // Omit stream key to use the default stream
487
+ const { parts, error } = useRealtimeStream<string>(runId, {
488
+ accessToken,
489
+ });
490
+ ```
491
+
492
+ ### Hook Options
493
+
494
+ ```tsx
495
+ const { parts, error } = useRealtimeStream(streamDef, runId, {
496
+ accessToken: "pk_...", // Required: Public access token
497
+ baseURL: "https://api.trigger.dev", // Optional: Custom API URL
498
+ timeoutInSeconds: 60, // Optional: Timeout (default: 60)
499
+ startIndex: 0, // Optional: Start from specific chunk
500
+ throttleInMs: 16, // Optional: Throttle updates (default: 16ms)
501
+ onData: (chunk) => {}, // Optional: Callback for each chunk
502
+ });
503
+ ```
504
+
505
+ ## Input Streams
506
+
507
+ Input Streams let you send data **into** a running task from your backend or frontend. While output streams (above) send data out of tasks, input streams complete the loop — enabling bidirectional communication.
508
+
509
+ <Note>
510
+ Input Streams require SDK version **4.4.2 or later** and use the same streams infrastructure (v2 is the default). If you're on an older SDK, calling `.on()` or `.once()` will throw with instructions to enable v2 streams. See [Pre-4.1.0 streams (legacy)](#pre-410-streams-legacy) for the older metadata-based API.
511
+ </Note>
512
+
513
+ ### Input Streams overview
514
+
515
+ Input Streams solve three common problems:
516
+
517
+ - **Cancelling AI streams mid-generation.** When you use AI SDK's `streamText` inside a task, the LLM keeps generating until it's done — even if the user clicked "Stop." With input streams, your frontend sends a cancel signal and the task aborts the LLM call immediately.
518
+ - **Human-in-the-loop workflows.** A task generates a draft, then pauses and waits for the user to approve or edit it before continuing.
519
+ - **Interactive agents.** An AI agent running as a task needs follow-up information from the user mid-execution — clarifying a question, choosing between options, or providing additional context.
520
+
521
+ ### Quick Start (Input Streams)
522
+
523
+ 1. **Define** input streams in a shared file with `streams.input<T>({ id: "..." })`.
524
+ 2. **Receive** in your task with `.wait()`, `.once()`, `.on()`, or `.peek()`.
525
+ 3. **Send** from your backend with `.send(runId, data)` or from the frontend with the `useInputStreamSend` hook (see [Realtime React hooks](/realtime/react-hooks/streams#useinputstreamsend)).
526
+
527
+ ### Defining Input Streams
528
+
529
+ Use `streams.input()` to define a typed input stream. The generic parameter controls the shape of data that can be sent:
530
+
531
+ ```ts
532
+ import { streams } from "@trigger.dev/sdk";
533
+
534
+ export const cancelSignal = streams.input<{ reason?: string }>({
535
+ id: "cancel",
536
+ });
537
+
538
+ export const approval = streams.input<{ approved: boolean; reviewer: string }>({
539
+ id: "approval",
540
+ });
541
+
542
+ export const userResponse = streams.input<{
543
+ action: "approve" | "reject" | "edit";
544
+ message?: string;
545
+ edits?: Record<string, string>;
546
+ }>({
547
+ id: "user-response",
548
+ });
549
+ ```
550
+
551
+ Type safety is enforced through the generic — both `.send()` and the receiving methods (`.wait()`, `.once()`, `.on()`, `.peek()`) share the same type.
552
+
553
+ ### Receiving data inside a task
554
+
555
+ | Method | Task suspended? | Compute cost while waiting | Best for |
556
+ |--------|-----------------|----------------------------|-----------|
557
+ | `.wait()` | **Yes** | **None** — process freed | Approval gates, human-in-the-loop, long waits |
558
+ | `.once()` | No | Full — process stays alive | Short waits, concurrent work; returns result object with `.unwrap()` |
559
+ | `.on(handler)` | No | Full — process stays alive | Continuous listening (cancel signals, live updates) |
560
+ | `.peek()` | No | None | Non-blocking check for latest buffered value |
561
+
562
+ #### `wait()` — Suspend until data arrives
563
+
564
+ Suspends the task entirely, freeing compute resources. The task resumes when data arrives via `.send()`. Returns a [`ManualWaitpointPromise`](/wait-for-token) — the same type as `wait.forToken()`.
565
+
566
+ ```ts
567
+ import { task } from "@trigger.dev/sdk";
568
+ import { approval } from "./streams";
569
+
570
+ export const publishPost = task({
571
+ id: "publish-post",
572
+ run: async (payload: { postId: string }) => {
573
+ const draft = await prepareDraft(payload.postId);
574
+ await notifyReviewer(draft);
575
+
576
+ const result = await approval.wait({ timeout: "7d" });
577
+
578
+ if (result.ok) {
579
+ if (result.output.approved) {
580
+ await publish(draft);
581
+ return { published: true, reviewer: result.output.reviewer };
582
+ }
583
+ return { published: false, reviewer: result.output.reviewer };
584
+ }
585
+ return { published: false, timedOut: true };
586
+ },
587
+ });
588
+ ```
589
+
590
+ Use `.unwrap()` to throw on timeout: `const data = await approval.wait({ timeout: "24h" }).unwrap();`
591
+
592
+ **Options:** `timeout` (e.g. `"30s"`, `"5m"`, `"24h"`, `"7d"`), `idempotencyKey`, `idempotencyKeyTTL`, `tags`. Use `idempotencyKey` when your task has retries so the same waitpoint is resumed across retries.
593
+
594
+ #### `once()` — Wait for the next value (non-suspending)
595
+
596
+ Blocks until data arrives but keeps the task process alive. Returns a result object; use `.unwrap()` to get the data or throw on timeout.
597
+
598
+ ```ts
599
+ const result = await approval.once({ timeoutMs: 300_000 });
600
+ if (result.ok) {
601
+ console.log(result.output.approved);
602
+ }
603
+ // Or: const data = await approval.once({ timeoutMs: 300_000 }).unwrap();
604
+ ```
605
+
606
+ `once()` also accepts a `signal` (e.g. `AbortController.signal`) for cancellation.
607
+
608
+ #### `on()` — Listen for every value
609
+
610
+ Registers a persistent handler that fires on every piece of data. Handlers are automatically cleaned up when the task run completes. Call `.off()` on the returned subscription to stop listening early.
611
+
612
+ ```ts
613
+ const controller = new AbortController();
614
+ cancelSignal.on((data) => {
615
+ console.log("Cancelled:", data.reason);
616
+ controller.abort();
617
+ });
618
+ const result = streamText({ ..., abortSignal: controller.signal });
619
+ ```
620
+
621
+ #### `peek()` — Non-blocking check
622
+
623
+ Returns the most recent buffered value without waiting, or `undefined` if nothing has been received yet.
624
+
625
+ ```ts
626
+ const latest = cancelSignal.peek();
627
+ if (latest) {
628
+ // A cancel was already sent before we checked
629
+ }
630
+ ```
631
+
632
+ ### Sending data to a running task
633
+
634
+ Use `.send(runId, data)` from your backend to push data into a running task. See the [backend input streams guide](/realtime/backend/input-streams) for API route patterns.
635
+
636
+ ```ts
637
+ import { cancelSignal, approval } from "./trigger/streams";
638
+
639
+ await cancelSignal.send(runId, { reason: "User clicked stop" });
640
+ await approval.send(runId, { approved: true, reviewer: "alice@example.com" });
641
+ ```
642
+
643
+ ### Complete example: Cancellable AI streaming
644
+
645
+ Stream an AI response while allowing the user to cancel mid-generation.
646
+
647
+ **Define the streams:**
648
+
649
+ ```ts
650
+ import { streams } from "@trigger.dev/sdk";
651
+
652
+ export const aiOutput = streams.define<string>({ id: "ai" });
653
+ export const cancelStream = streams.input<{ reason?: string }>({ id: "cancel" });
654
+ ```
655
+
656
+ **Task:** Register `cancelStream.on()` to abort an `AbortController`, then pipe `streamText(...).textStream` to `aiOutput`. **Backend:** POST to an API route that calls `cancelStream.send(runId, { reason: "User clicked stop" })`. **Frontend:** Use `useRealtimeStream(aiOutput, runId, { accessToken })` and a button that calls your cancel API (or use the `useInputStreamSend` hook; see [Realtime React hooks](/realtime/react-hooks/streams#useinputstreamsend)).
657
+
658
+ **Important notes (input streams):** You cannot send to a completed, failed, or canceled run. Max payload per `.send()` is 1MB. Data sent before a listener is registered is buffered and delivered when a listener attaches; `.wait()` handles the buffering race automatically. Use `.wait()` for long waits to free compute; use `.once()` for short waits or concurrent work. Define input streams in a shared location and combine with output streams for full bidirectional communication.
659
+
660
+ ## Complete Example: AI Streaming
661
+
662
+ ### Define the stream
663
+
664
+ ```ts
665
+ // app/streams.ts
666
+ import { streams, InferStreamType } from "@trigger.dev/sdk";
667
+ import { UIMessageChunk } from "ai";
668
+
669
+ export const aiStream = streams.define<UIMessageChunk>({
670
+ id: "ai",
671
+ });
672
+
673
+ export type AIStreamPart = InferStreamType<typeof aiStream>;
674
+ ```
675
+
676
+ ### Create the task
677
+
678
+ ```ts
679
+ // trigger/ai-task.ts
680
+ import { task } from "@trigger.dev/sdk";
681
+ import { openai } from "@ai-sdk/openai";
682
+ import { streamText } from "ai";
683
+ import { aiStream } from "@/app/streams";
684
+
685
+ export const generateAI = task({
686
+ id: "generate-ai",
687
+ run: async (payload: { prompt: string }) => {
688
+ const result = streamText({
689
+ model: openai("gpt-4o"),
690
+ prompt: payload.prompt,
691
+ });
692
+
693
+ const { waitUntilComplete } = aiStream.pipe(result.toUIMessageStream());
694
+
695
+ await waitUntilComplete();
696
+
697
+ return { success: true };
698
+ },
699
+ });
700
+ ```
701
+
702
+ ### Frontend component
703
+
704
+ ```tsx
705
+ // components/ai-stream.tsx
706
+ "use client";
707
+
708
+ import { useRealtimeStream } from "@trigger.dev/react-hooks";
709
+ import { aiStream } from "@/app/streams";
710
+
711
+ export function AIStream({ accessToken, runId }: { accessToken: string; runId: string }) {
712
+ const { parts, error } = useRealtimeStream(aiStream, runId, {
713
+ accessToken,
714
+ timeoutInSeconds: 300,
715
+ });
716
+
717
+ if (error) return <div>Error: {error.message}</div>;
718
+ if (!parts) return <div>Loading...</div>;
719
+
720
+ return (
721
+ <div className="prose">
722
+ {parts.map((part, i) => (
723
+ <span key={i}>{part}</span>
724
+ ))}
725
+ </div>
726
+ );
727
+ }
728
+ ```
729
+
730
+ ## Migration from v1
731
+
732
+ If you're using the old `metadata.stream()` API, here's how to migrate to the recommended v2 approach:
733
+
734
+ ### Step 1: Define Your Streams
735
+
736
+ Create a shared streams definition file:
737
+
738
+ ```ts
739
+ // app/streams.ts or trigger/streams.ts
740
+ import { streams, InferStreamType } from "@trigger.dev/sdk";
741
+
742
+ export const myStream = streams.define<string>({
743
+ id: "my-stream",
744
+ });
745
+
746
+ export type MyStreamPart = InferStreamType<typeof myStream>;
747
+ ```
748
+
749
+ ### Step 2: Update Your Tasks
750
+
751
+ Replace `metadata.stream()` with the defined stream's `pipe()` method:
752
+
753
+ ```ts
754
+ // Before (v1)
755
+ import { metadata, task } from "@trigger.dev/sdk";
756
+
757
+ export const myTask = task({
758
+ id: "my-task",
759
+ run: async (payload) => {
760
+ const stream = getDataStream();
761
+ await metadata.stream("my-stream", stream);
762
+ },
763
+ });
764
+ ```
765
+
766
+ ```ts
767
+ // After (v2 - Recommended)
768
+ import { task } from "@trigger.dev/sdk";
769
+ import { myStream } from "./streams";
770
+
771
+ export const myTask = task({
772
+ id: "my-task",
773
+ run: async (payload) => {
774
+ const stream = getDataStream();
775
+
776
+ // Don't await - returns immediately
777
+ const { waitUntilComplete } = myStream.pipe(stream);
778
+
779
+ // Optionally wait for completion
780
+ await waitUntilComplete();
781
+ },
782
+ });
783
+ ```
784
+
785
+ ### Step 3: Update Your Frontend
786
+
787
+ Use the defined stream with `useRealtimeStream`:
788
+
789
+ ```tsx
790
+ // Before
791
+ const { parts, error } = useRealtimeStream<string>(runId, "my-stream", {
792
+ accessToken,
793
+ });
794
+ ```
795
+
796
+ ```tsx
797
+ // After
798
+ import { myStream } from "@/app/streams";
799
+
800
+ const { parts, error } = useRealtimeStream(myStream, runId, {
801
+ accessToken,
802
+ });
803
+ ```
804
+
805
+ ### Alternative: Direct Methods (Not Recommended)
806
+
807
+ If you prefer not to use defined streams, you can use direct methods:
808
+
809
+ ```ts
810
+ import { streams, task } from "@trigger.dev/sdk";
811
+
812
+ export const myTask = task({
813
+ id: "my-task",
814
+ run: async (payload) => {
815
+ const stream = getDataStream();
816
+ const { waitUntilComplete } = streams.pipe("my-stream", stream);
817
+ await waitUntilComplete();
818
+ },
819
+ });
820
+ ```
821
+
822
+ ## Reliability Features
823
+
824
+ Streams v2 includes automatic reliability improvements:
825
+
826
+ - **Automatic resumption**: If a connection is lost, both appending and reading will automatically resume from the last successful chunk
827
+ - **No data loss**: Network issues won't cause stream data to be lost
828
+ - **Idempotent operations**: Duplicate chunks are automatically handled
829
+
830
+ These improvements happen automatically - no code changes needed.
831
+
832
+ ## Dashboard Integration
833
+
834
+ Streams are now visible in the Trigger.dev dashboard, allowing you to:
835
+
836
+ - View stream data in real-time as it's generated
837
+ - Inspect historical stream data for completed runs
838
+ - Debug streaming issues with full visibility into chunk delivery
839
+
840
+ <video src="https://content.trigger.dev/streams-v2-dashboard.mp4" controls muted autoPlay loop />
841
+
842
+ ## Best Practices
843
+
844
+ 1. **Always use `streams.define()`**: Define your streams in a shared location for better organization, type safety, and code reusability. This is the recommended approach for all streams.
845
+ 2. **Export stream types**: Use `InferStreamType` to export types for your frontend components
846
+ 3. **Handle errors gracefully**: Always check for errors when reading streams in your UI
847
+ 4. **Set appropriate timeouts**: Adjust `timeoutInSeconds` based on your use case (AI completions may need longer timeouts)
848
+ 5. **Target parent runs**: When orchestrating with child tasks, pipe to parent runs for easier consumption
849
+ 6. **Throttle frontend updates**: Use `throttleInMs` in `useRealtimeStream` to prevent excessive re-renders
850
+ 7. **Use descriptive stream IDs**: Choose clear, descriptive IDs like `"ai-output"` or `"progress"` instead of generic names
851
+
852
+ ## Pre-4.1.0 streams (legacy)
853
+
854
+ Prior to SDK 4.1.0, streams used the older metadata-based API. If you're on an earlier version, see [metadata.stream()](/runs/metadata#stream) for legacy usage. With 4.4.2+, [Input Streams](#input-streams) are available and documented in this page.
855
+
856
+ ## Troubleshooting
857
+
858
+ ### Stream not appearing in dashboard
859
+
860
+ - Verify your task is actually writing to the stream
861
+ - Check that the stream key matches between writing and reading
862
+
863
+ ### Stream timeout errors
864
+
865
+ - Increase `timeoutInSeconds` in your `read()` or `useRealtimeStream()` calls
866
+ - Ensure your stream source is actively producing data
867
+ - Check network connectivity between your application and Trigger.dev
868
+
869
+ ### Missing chunks
870
+
871
+ - With the current streams implementation, chunks should not be lost due to automatic resumption
872
+ - Verify you're reading from the correct stream key
873
+ - Check the `startIndex` option if you're not seeing expected chunks
874
+
875
+ ### Input streams not working
876
+
877
+ - Input streams require SDK **4.4.2 or later** and the default streams (v2) infrastructure. Ensure you're on a recent SDK and not using the legacy metadata.stream() API.
878
+ - If `.on()` or `.once()` throw, follow the error message to enable v2 streams (they are default in 4.1.0+).
879
+
880
+ ### "Stream is being deleted" during long waits
881
+
882
+ If a stream is created but stays empty for ~1 hour (for example, during a long `wait.forToken()` or `wait.for()`), the streams backend may garbage-collect it. When the run resumes and tries to use the stream, you'll see `S2Error: Stream is being deleted` and the task retries from the beginning.
883
+
884
+ Two ways to avoid this:
885
+
886
+ - Close the stream before the wait and open a new one when the run resumes.
887
+ - Write a heartbeat record to the stream every 20–30 minutes during the wait so it's never empty long enough to be deleted.