@trigger.dev/core 3.3.17 → 4.0.0-v4-beta.0

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 (794) hide show
  1. package/dist/commonjs/debounce.d.ts +2 -0
  2. package/dist/commonjs/debounce.js +19 -0
  3. package/dist/commonjs/debounce.js.map +1 -0
  4. package/dist/commonjs/index.d.ts +2 -7
  5. package/dist/commonjs/index.js +2 -7
  6. package/dist/commonjs/index.js.map +1 -1
  7. package/dist/commonjs/retry.d.ts +0 -2
  8. package/dist/commonjs/retry.js +0 -24
  9. package/dist/commonjs/retry.js.map +1 -1
  10. package/dist/commonjs/schemas/index.d.ts +0 -16
  11. package/dist/commonjs/schemas/index.js +0 -16
  12. package/dist/commonjs/schemas/index.js.map +1 -1
  13. package/dist/commonjs/types.d.ts +0 -6
  14. package/dist/commonjs/utils.d.ts +1 -2
  15. package/dist/commonjs/utils.js +10 -27
  16. package/dist/commonjs/utils.js.map +1 -1
  17. package/dist/commonjs/v3/apiClient/core.d.ts +11 -3
  18. package/dist/commonjs/v3/apiClient/core.js +42 -2
  19. package/dist/commonjs/v3/apiClient/core.js.map +1 -1
  20. package/dist/commonjs/v3/apiClient/index.d.ts +191 -113
  21. package/dist/commonjs/v3/apiClient/index.js +153 -7
  22. package/dist/commonjs/v3/apiClient/index.js.map +1 -1
  23. package/dist/commonjs/v3/apiClient/runStream.js +7 -1
  24. package/dist/commonjs/v3/apiClient/runStream.js.map +1 -1
  25. package/dist/commonjs/v3/apiClient/stream.js +51 -30
  26. package/dist/commonjs/v3/apiClient/stream.js.map +1 -1
  27. package/dist/commonjs/v3/apiClient/types.d.ts +9 -1
  28. package/dist/commonjs/v3/apps/exec.d.ts +30 -0
  29. package/dist/commonjs/v3/apps/exec.js +82 -0
  30. package/dist/commonjs/v3/apps/exec.js.map +1 -0
  31. package/dist/commonjs/v3/apps/http.d.ts +8 -6
  32. package/dist/commonjs/v3/apps/http.js +38 -2
  33. package/dist/commonjs/v3/apps/http.js.map +1 -1
  34. package/dist/commonjs/v3/apps/index.d.ts +1 -3
  35. package/dist/commonjs/v3/apps/index.js +1 -3
  36. package/dist/commonjs/v3/apps/index.js.map +1 -1
  37. package/dist/commonjs/v3/build/flags.d.ts +20 -0
  38. package/dist/commonjs/v3/build/flags.js +49 -0
  39. package/dist/commonjs/v3/build/flags.js.map +1 -0
  40. package/dist/commonjs/v3/build/flags.test.d.ts +1 -0
  41. package/dist/commonjs/v3/build/flags.test.js +50 -0
  42. package/dist/commonjs/v3/build/flags.test.js.map +1 -0
  43. package/dist/commonjs/v3/build/index.d.ts +1 -0
  44. package/dist/commonjs/v3/build/index.js +1 -0
  45. package/dist/commonjs/v3/build/index.js.map +1 -1
  46. package/dist/commonjs/v3/build/resolvedConfig.d.ts +3 -1
  47. package/dist/commonjs/v3/build/runtime.d.ts +2 -2
  48. package/dist/commonjs/v3/build/runtime.js +11 -4
  49. package/dist/commonjs/v3/build/runtime.js.map +1 -1
  50. package/dist/commonjs/v3/config.d.ts +19 -7
  51. package/dist/commonjs/v3/errors.d.ts +9 -0
  52. package/dist/commonjs/v3/errors.js +90 -2
  53. package/dist/commonjs/v3/errors.js.map +1 -1
  54. package/dist/commonjs/v3/idempotencyKeys.d.ts +1 -0
  55. package/dist/commonjs/v3/idempotencyKeys.js +19 -0
  56. package/dist/commonjs/v3/idempotencyKeys.js.map +1 -1
  57. package/dist/commonjs/v3/index.d.ts +7 -2
  58. package/dist/commonjs/v3/index.js +10 -2
  59. package/dist/commonjs/v3/index.js.map +1 -1
  60. package/dist/commonjs/v3/isomorphic/consts.d.ts +2 -0
  61. package/dist/commonjs/v3/isomorphic/consts.js +6 -0
  62. package/dist/commonjs/v3/isomorphic/consts.js.map +1 -0
  63. package/dist/commonjs/v3/{apps → isomorphic}/duration.d.ts +1 -0
  64. package/dist/commonjs/v3/{apps → isomorphic}/duration.js +19 -0
  65. package/dist/commonjs/v3/isomorphic/duration.js.map +1 -0
  66. package/dist/commonjs/v3/isomorphic/friendlyId.d.ts +36 -0
  67. package/dist/commonjs/v3/isomorphic/friendlyId.js +102 -0
  68. package/dist/commonjs/v3/isomorphic/friendlyId.js.map +1 -0
  69. package/dist/commonjs/v3/isomorphic/index.d.ts +5 -0
  70. package/dist/commonjs/v3/isomorphic/index.js +22 -0
  71. package/dist/commonjs/v3/isomorphic/index.js.map +1 -0
  72. package/dist/commonjs/v3/isomorphic/maxDuration.d.ts +2 -0
  73. package/dist/commonjs/v3/isomorphic/maxDuration.js +20 -0
  74. package/dist/commonjs/v3/isomorphic/maxDuration.js.map +1 -0
  75. package/dist/commonjs/v3/isomorphic/queueName.d.ts +1 -0
  76. package/dist/commonjs/v3/isomorphic/queueName.js +8 -0
  77. package/dist/commonjs/v3/isomorphic/queueName.js.map +1 -0
  78. package/dist/commonjs/v3/lifecycle-hooks-api.d.ts +4 -0
  79. package/dist/commonjs/v3/{task-catalog-api.js → lifecycle-hooks-api.js} +4 -4
  80. package/dist/commonjs/v3/lifecycle-hooks-api.js.map +1 -0
  81. package/dist/commonjs/v3/lifecycleHooks/index.d.ts +53 -0
  82. package/dist/commonjs/v3/lifecycleHooks/index.js +160 -0
  83. package/dist/commonjs/v3/lifecycleHooks/index.js.map +1 -0
  84. package/dist/commonjs/v3/lifecycleHooks/manager.d.ts +115 -0
  85. package/dist/commonjs/v3/lifecycleHooks/manager.js +401 -0
  86. package/dist/commonjs/v3/lifecycleHooks/manager.js.map +1 -0
  87. package/dist/commonjs/v3/lifecycleHooks/types.d.ts +179 -0
  88. package/dist/commonjs/v3/lifecycleHooks/types.js +3 -0
  89. package/dist/commonjs/v3/lifecycleHooks/types.js.map +1 -0
  90. package/dist/commonjs/v3/locals/index.d.ts +12 -0
  91. package/dist/commonjs/v3/locals/index.js +37 -0
  92. package/dist/commonjs/v3/locals/index.js.map +1 -0
  93. package/dist/commonjs/v3/locals/manager.d.ts +12 -0
  94. package/dist/commonjs/v3/locals/manager.js +35 -0
  95. package/dist/commonjs/v3/locals/manager.js.map +1 -0
  96. package/dist/commonjs/v3/locals/types.d.ts +14 -0
  97. package/dist/commonjs/v3/locals/types.js +3 -0
  98. package/dist/commonjs/v3/locals/types.js.map +1 -0
  99. package/dist/commonjs/v3/locals-api.d.ts +12 -0
  100. package/dist/commonjs/v3/locals-api.js +28 -0
  101. package/dist/commonjs/v3/locals-api.js.map +1 -0
  102. package/dist/commonjs/v3/logger/index.d.ts +4 -4
  103. package/dist/commonjs/v3/logger/index.js.map +1 -1
  104. package/dist/commonjs/v3/logger/taskLogger.d.ts +8 -4
  105. package/dist/commonjs/v3/logger/taskLogger.js +16 -2
  106. package/dist/commonjs/v3/logger/taskLogger.js.map +1 -1
  107. package/dist/commonjs/v3/machines/index.d.ts +27 -0
  108. package/dist/commonjs/v3/machines/index.js +51 -0
  109. package/dist/commonjs/v3/machines/index.js.map +1 -0
  110. package/dist/commonjs/v3/machines/max-old-space.test.d.ts +1 -0
  111. package/dist/commonjs/v3/machines/max-old-space.test.js +44 -0
  112. package/dist/commonjs/v3/machines/max-old-space.test.js.map +1 -0
  113. package/dist/commonjs/v3/otel/tracingSDK.js +1 -1
  114. package/dist/commonjs/v3/otel/tracingSDK.js.map +1 -1
  115. package/dist/commonjs/v3/otel/utils.d.ts +1 -0
  116. package/dist/commonjs/v3/otel/utils.js +6 -0
  117. package/dist/commonjs/v3/otel/utils.js.map +1 -1
  118. package/dist/{esm/v3/task-catalog → commonjs/v3/resource-catalog}/catalog.d.ts +7 -3
  119. package/dist/commonjs/v3/resource-catalog/catalog.js.map +1 -0
  120. package/dist/commonjs/v3/resource-catalog/index.d.ts +22 -0
  121. package/dist/commonjs/v3/resource-catalog/index.js +61 -0
  122. package/dist/commonjs/v3/resource-catalog/index.js.map +1 -0
  123. package/dist/commonjs/v3/resource-catalog/noopResourceCatalog.d.ts +17 -0
  124. package/dist/commonjs/v3/{task-catalog/noopTaskCatalog.js → resource-catalog/noopResourceCatalog.js} +17 -5
  125. package/dist/commonjs/v3/resource-catalog/noopResourceCatalog.js.map +1 -0
  126. package/dist/commonjs/v3/resource-catalog/standardResourceCatalog.d.ts +22 -0
  127. package/dist/commonjs/v3/resource-catalog/standardResourceCatalog.js +129 -0
  128. package/dist/commonjs/v3/resource-catalog/standardResourceCatalog.js.map +1 -0
  129. package/dist/commonjs/v3/resource-catalog-api.d.ts +3 -0
  130. package/dist/commonjs/v3/resource-catalog-api.js +9 -0
  131. package/dist/commonjs/v3/resource-catalog-api.js.map +1 -0
  132. package/dist/commonjs/v3/runEngineWorker/consts.d.ts +12 -0
  133. package/dist/commonjs/v3/runEngineWorker/consts.js +16 -0
  134. package/dist/commonjs/v3/runEngineWorker/consts.js.map +1 -0
  135. package/dist/commonjs/v3/runEngineWorker/index.d.ts +7 -0
  136. package/dist/commonjs/v3/runEngineWorker/index.js +24 -0
  137. package/dist/commonjs/v3/runEngineWorker/index.js.map +1 -0
  138. package/dist/commonjs/v3/runEngineWorker/supervisor/events.d.ts +49 -0
  139. package/dist/commonjs/v3/runEngineWorker/supervisor/events.js +3 -0
  140. package/dist/commonjs/v3/runEngineWorker/supervisor/events.js.map +1 -0
  141. package/dist/commonjs/v3/runEngineWorker/supervisor/http.d.ts +351 -0
  142. package/dist/commonjs/v3/runEngineWorker/supervisor/http.js +154 -0
  143. package/dist/commonjs/v3/runEngineWorker/supervisor/http.js.map +1 -0
  144. package/dist/commonjs/v3/runEngineWorker/supervisor/queueConsumer.d.ts +26 -0
  145. package/dist/commonjs/v3/runEngineWorker/supervisor/queueConsumer.js +92 -0
  146. package/dist/commonjs/v3/runEngineWorker/supervisor/queueConsumer.js.map +1 -0
  147. package/dist/commonjs/v3/runEngineWorker/supervisor/schemas.d.ts +3537 -0
  148. package/dist/commonjs/v3/runEngineWorker/supervisor/schemas.js +91 -0
  149. package/dist/commonjs/v3/runEngineWorker/supervisor/schemas.js.map +1 -0
  150. package/dist/commonjs/v3/runEngineWorker/supervisor/session.d.ts +32 -0
  151. package/dist/commonjs/v3/runEngineWorker/supervisor/session.js +174 -0
  152. package/dist/commonjs/v3/runEngineWorker/supervisor/session.js.map +1 -0
  153. package/dist/commonjs/v3/runEngineWorker/supervisor/types.d.ts +13 -0
  154. package/dist/commonjs/v3/runEngineWorker/supervisor/types.js +3 -0
  155. package/dist/commonjs/v3/runEngineWorker/supervisor/types.js.map +1 -0
  156. package/dist/commonjs/v3/runEngineWorker/supervisor/util.d.ts +3 -0
  157. package/dist/commonjs/v3/runEngineWorker/supervisor/util.js +39 -0
  158. package/dist/commonjs/v3/runEngineWorker/supervisor/util.js.map +1 -0
  159. package/dist/commonjs/v3/runEngineWorker/types.d.ts +52 -0
  160. package/dist/commonjs/v3/runEngineWorker/types.js +3 -0
  161. package/dist/commonjs/v3/runEngineWorker/types.js.map +1 -0
  162. package/dist/commonjs/v3/runEngineWorker/util.d.ts +4 -0
  163. package/dist/commonjs/v3/runEngineWorker/util.js +15 -0
  164. package/dist/commonjs/v3/runEngineWorker/util.js.map +1 -0
  165. package/dist/commonjs/v3/runEngineWorker/workload/http.d.ts +266 -0
  166. package/dist/commonjs/v3/runEngineWorker/workload/http.js +117 -0
  167. package/dist/commonjs/v3/runEngineWorker/workload/http.js.map +1 -0
  168. package/dist/commonjs/v3/runEngineWorker/workload/schemas.d.ts +2996 -0
  169. package/dist/commonjs/v3/runEngineWorker/workload/schemas.js +25 -0
  170. package/dist/commonjs/v3/runEngineWorker/workload/schemas.js.map +1 -0
  171. package/dist/commonjs/v3/runEngineWorker/workload/types.d.ts +7 -0
  172. package/dist/commonjs/v3/runEngineWorker/workload/types.js +3 -0
  173. package/dist/commonjs/v3/runEngineWorker/workload/types.js.map +1 -0
  174. package/dist/commonjs/v3/runEngineWorker/workload/util.d.ts +2 -0
  175. package/dist/commonjs/v3/runEngineWorker/workload/util.js +14 -0
  176. package/dist/commonjs/v3/runEngineWorker/workload/util.js.map +1 -0
  177. package/dist/commonjs/v3/runTimelineMetrics/runTimelineMetricsManager.d.ts +1 -1
  178. package/dist/commonjs/v3/runTimelineMetrics/runTimelineMetricsManager.js +5 -2
  179. package/dist/commonjs/v3/runTimelineMetrics/runTimelineMetricsManager.js.map +1 -1
  180. package/dist/commonjs/v3/runtime/index.d.ts +4 -4
  181. package/dist/commonjs/v3/runtime/index.js +5 -5
  182. package/dist/commonjs/v3/runtime/index.js.map +1 -1
  183. package/dist/commonjs/v3/runtime/managedRuntimeManager.d.ts +30 -0
  184. package/dist/commonjs/v3/runtime/managedRuntimeManager.js +185 -0
  185. package/dist/commonjs/v3/runtime/managedRuntimeManager.js.map +1 -0
  186. package/dist/commonjs/v3/runtime/manager.d.ts +6 -4
  187. package/dist/commonjs/v3/runtime/noopRuntimeManager.d.ts +6 -4
  188. package/dist/commonjs/v3/runtime/noopRuntimeManager.js +4 -5
  189. package/dist/commonjs/v3/runtime/noopRuntimeManager.js.map +1 -1
  190. package/dist/commonjs/v3/schemas/api.d.ts +1966 -586
  191. package/dist/commonjs/v3/schemas/api.js +252 -11
  192. package/dist/commonjs/v3/schemas/api.js.map +1 -1
  193. package/dist/commonjs/v3/schemas/build.d.ts +464 -356
  194. package/dist/commonjs/v3/schemas/build.js +5 -2
  195. package/dist/commonjs/v3/schemas/build.js.map +1 -1
  196. package/dist/commonjs/v3/schemas/checkpoints.d.ts +419 -0
  197. package/dist/commonjs/v3/schemas/checkpoints.js +26 -0
  198. package/dist/commonjs/v3/schemas/checkpoints.js.map +1 -0
  199. package/dist/commonjs/v3/schemas/common.d.ts +302 -189
  200. package/dist/commonjs/v3/schemas/common.js +50 -9
  201. package/dist/commonjs/v3/schemas/common.js.map +1 -1
  202. package/dist/commonjs/v3/schemas/fetch.d.ts +42 -42
  203. package/dist/commonjs/v3/schemas/index.d.ts +4 -0
  204. package/dist/commonjs/v3/schemas/index.js +4 -0
  205. package/dist/commonjs/v3/schemas/index.js.map +1 -1
  206. package/dist/commonjs/v3/schemas/messages.d.ts +4701 -3934
  207. package/dist/commonjs/v3/schemas/messages.js +27 -0
  208. package/dist/commonjs/v3/schemas/messages.js.map +1 -1
  209. package/dist/commonjs/v3/schemas/openTelemetry.d.ts +18 -18
  210. package/dist/commonjs/v3/schemas/queues.d.ts +97 -0
  211. package/dist/commonjs/v3/schemas/queues.js +70 -0
  212. package/dist/commonjs/v3/schemas/queues.js.map +1 -0
  213. package/dist/commonjs/v3/schemas/resources.d.ts +153 -114
  214. package/dist/commonjs/v3/schemas/resources.js +3 -2
  215. package/dist/commonjs/v3/schemas/resources.js.map +1 -1
  216. package/dist/commonjs/v3/schemas/runEngine.d.ts +1630 -0
  217. package/dist/commonjs/v3/schemas/runEngine.js +202 -0
  218. package/dist/commonjs/v3/schemas/runEngine.js.map +1 -0
  219. package/dist/commonjs/v3/schemas/schemas.d.ts +523 -401
  220. package/dist/commonjs/v3/schemas/schemas.js +23 -5
  221. package/dist/commonjs/v3/schemas/schemas.js.map +1 -1
  222. package/dist/commonjs/v3/schemas/style.d.ts +6 -4
  223. package/dist/commonjs/v3/schemas/style.js +4 -2
  224. package/dist/commonjs/v3/schemas/style.js.map +1 -1
  225. package/dist/commonjs/v3/schemas/warmStart.d.ts +12 -0
  226. package/dist/commonjs/v3/schemas/warmStart.js +9 -0
  227. package/dist/commonjs/v3/schemas/warmStart.js.map +1 -0
  228. package/dist/commonjs/v3/schemas/webhooks.d.ts +204 -204
  229. package/dist/commonjs/v3/schemas/webhooks.js +6 -7
  230. package/dist/commonjs/v3/schemas/webhooks.js.map +1 -1
  231. package/dist/commonjs/v3/semanticInternalAttributes.d.ts +7 -0
  232. package/dist/commonjs/v3/semanticInternalAttributes.js +7 -0
  233. package/dist/commonjs/v3/semanticInternalAttributes.js.map +1 -1
  234. package/dist/commonjs/v3/serverOnly/checkpointClient.d.ts +23 -0
  235. package/dist/commonjs/v3/serverOnly/checkpointClient.js +80 -0
  236. package/dist/commonjs/v3/serverOnly/checkpointClient.js.map +1 -0
  237. package/dist/commonjs/v3/{apps/checkpoints.js → serverOnly/checkpointTest.js} +2 -2
  238. package/dist/commonjs/v3/serverOnly/checkpointTest.js.map +1 -0
  239. package/dist/commonjs/v3/serverOnly/httpServer.d.ts +49 -0
  240. package/dist/commonjs/v3/serverOnly/httpServer.js +244 -0
  241. package/dist/commonjs/v3/serverOnly/httpServer.js.map +1 -0
  242. package/dist/commonjs/v3/serverOnly/index.d.ts +6 -0
  243. package/dist/commonjs/v3/serverOnly/index.js +23 -0
  244. package/dist/commonjs/v3/serverOnly/index.js.map +1 -0
  245. package/dist/commonjs/v3/serverOnly/k8s.d.ts +1 -0
  246. package/dist/commonjs/v3/serverOnly/k8s.js +18 -0
  247. package/dist/commonjs/v3/serverOnly/k8s.js.map +1 -0
  248. package/dist/commonjs/v3/serverOnly/shutdownManager.d.ts +20 -0
  249. package/dist/commonjs/v3/serverOnly/shutdownManager.js +92 -0
  250. package/dist/commonjs/v3/serverOnly/shutdownManager.js.map +1 -0
  251. package/dist/commonjs/v3/serverOnly/shutdownManager.test.d.ts +1 -0
  252. package/dist/commonjs/v3/serverOnly/shutdownManager.test.js +139 -0
  253. package/dist/commonjs/v3/serverOnly/shutdownManager.test.js.map +1 -0
  254. package/dist/commonjs/v3/serverOnly/singleton.d.ts +1 -0
  255. package/dist/commonjs/v3/serverOnly/singleton.js +10 -0
  256. package/dist/commonjs/v3/serverOnly/singleton.js.map +1 -0
  257. package/dist/commonjs/v3/taskContext/index.d.ts +1 -0
  258. package/dist/commonjs/v3/taskContext/index.js +4 -0
  259. package/dist/commonjs/v3/taskContext/index.js.map +1 -1
  260. package/dist/commonjs/v3/taskContext/otelProcessors.d.ts +3 -1
  261. package/dist/commonjs/v3/taskContext/otelProcessors.js +34 -1
  262. package/dist/commonjs/v3/taskContext/otelProcessors.js.map +1 -1
  263. package/dist/commonjs/v3/taskContext/types.d.ts +1 -0
  264. package/dist/commonjs/v3/tracer.js +21 -16
  265. package/dist/commonjs/v3/tracer.js.map +1 -1
  266. package/dist/commonjs/v3/tryCatch.d.ts +5 -0
  267. package/dist/commonjs/v3/tryCatch.js +14 -0
  268. package/dist/commonjs/v3/tryCatch.js.map +1 -0
  269. package/dist/commonjs/v3/types/index.d.ts +1 -0
  270. package/dist/commonjs/v3/types/index.js +1 -0
  271. package/dist/commonjs/v3/types/index.js.map +1 -1
  272. package/dist/commonjs/v3/types/queues.d.ts +43 -0
  273. package/dist/commonjs/v3/types/queues.js +3 -0
  274. package/dist/commonjs/v3/types/queues.js.map +1 -0
  275. package/dist/commonjs/v3/types/schemas.d.ts +3 -0
  276. package/dist/commonjs/v3/types/schemas.js +16 -0
  277. package/dist/commonjs/v3/types/schemas.js.map +1 -1
  278. package/dist/commonjs/v3/types/tasks.d.ts +77 -34
  279. package/dist/commonjs/v3/types/tasks.js.map +1 -1
  280. package/dist/commonjs/v3/utils/durations.d.ts +1 -0
  281. package/dist/commonjs/v3/utils/durations.js +1 -1
  282. package/dist/commonjs/v3/utils/durations.js.map +1 -1
  283. package/dist/commonjs/v3/utils/globals.d.ts +6 -2
  284. package/dist/commonjs/v3/utils/globals.js.map +1 -1
  285. package/dist/commonjs/v3/utils/heartbeat.d.ts +21 -0
  286. package/dist/commonjs/v3/utils/heartbeat.js +79 -0
  287. package/dist/commonjs/v3/utils/heartbeat.js.map +1 -0
  288. package/dist/commonjs/v3/utils/imageRef.d.ts +8 -0
  289. package/dist/commonjs/v3/utils/imageRef.js +55 -0
  290. package/dist/commonjs/v3/utils/imageRef.js.map +1 -0
  291. package/dist/commonjs/v3/workers/index.d.ts +8 -2
  292. package/dist/commonjs/v3/workers/index.js +15 -3
  293. package/dist/commonjs/v3/workers/index.js.map +1 -1
  294. package/dist/commonjs/v3/workers/populateEnv.d.ts +23 -0
  295. package/dist/commonjs/v3/workers/populateEnv.js +33 -0
  296. package/dist/commonjs/v3/workers/populateEnv.js.map +1 -0
  297. package/dist/commonjs/v3/workers/taskExecutor.d.ts +10 -9
  298. package/dist/commonjs/v3/workers/taskExecutor.js +648 -247
  299. package/dist/commonjs/v3/workers/taskExecutor.js.map +1 -1
  300. package/dist/commonjs/v3/workers/warmStartClient.d.ts +27 -0
  301. package/dist/commonjs/v3/workers/warmStartClient.js +112 -0
  302. package/dist/commonjs/v3/workers/warmStartClient.js.map +1 -0
  303. package/dist/commonjs/version.js +1 -1
  304. package/dist/esm/debounce.d.ts +2 -0
  305. package/dist/esm/debounce.js +16 -0
  306. package/dist/esm/debounce.js.map +1 -0
  307. package/dist/esm/index.d.ts +2 -7
  308. package/dist/esm/index.js +2 -7
  309. package/dist/esm/index.js.map +1 -1
  310. package/dist/esm/retry.d.ts +0 -2
  311. package/dist/esm/retry.js +0 -23
  312. package/dist/esm/retry.js.map +1 -1
  313. package/dist/esm/schemas/index.d.ts +0 -16
  314. package/dist/esm/schemas/index.js +0 -16
  315. package/dist/esm/schemas/index.js.map +1 -1
  316. package/dist/esm/types.d.ts +0 -6
  317. package/dist/esm/utils.d.ts +1 -2
  318. package/dist/esm/utils.js +9 -26
  319. package/dist/esm/utils.js.map +1 -1
  320. package/dist/esm/v3/apiClient/core.d.ts +11 -3
  321. package/dist/esm/v3/apiClient/core.js +41 -2
  322. package/dist/esm/v3/apiClient/core.js.map +1 -1
  323. package/dist/esm/v3/apiClient/index.d.ts +191 -113
  324. package/dist/esm/v3/apiClient/index.js +154 -8
  325. package/dist/esm/v3/apiClient/index.js.map +1 -1
  326. package/dist/esm/v3/apiClient/runStream.js +7 -1
  327. package/dist/esm/v3/apiClient/runStream.js.map +1 -1
  328. package/dist/esm/v3/apiClient/stream.js +51 -30
  329. package/dist/esm/v3/apiClient/stream.js.map +1 -1
  330. package/dist/esm/v3/apiClient/types.d.ts +9 -1
  331. package/dist/esm/v3/apps/exec.d.ts +30 -0
  332. package/dist/esm/v3/apps/exec.js +77 -0
  333. package/dist/esm/v3/apps/exec.js.map +1 -0
  334. package/dist/esm/v3/apps/http.d.ts +8 -6
  335. package/dist/esm/v3/apps/http.js +37 -2
  336. package/dist/esm/v3/apps/http.js.map +1 -1
  337. package/dist/esm/v3/apps/index.d.ts +1 -3
  338. package/dist/esm/v3/apps/index.js +1 -3
  339. package/dist/esm/v3/apps/index.js.map +1 -1
  340. package/dist/esm/v3/build/flags.d.ts +20 -0
  341. package/dist/esm/v3/build/flags.js +46 -0
  342. package/dist/esm/v3/build/flags.js.map +1 -0
  343. package/dist/esm/v3/build/flags.test.d.ts +1 -0
  344. package/dist/esm/v3/build/flags.test.js +48 -0
  345. package/dist/esm/v3/build/flags.test.js.map +1 -0
  346. package/dist/esm/v3/build/index.d.ts +1 -0
  347. package/dist/esm/v3/build/index.js +1 -0
  348. package/dist/esm/v3/build/index.js.map +1 -1
  349. package/dist/esm/v3/build/resolvedConfig.d.ts +3 -1
  350. package/dist/esm/v3/build/runtime.d.ts +2 -2
  351. package/dist/esm/v3/build/runtime.js +11 -4
  352. package/dist/esm/v3/build/runtime.js.map +1 -1
  353. package/dist/esm/v3/config.d.ts +19 -7
  354. package/dist/esm/v3/errors.d.ts +9 -0
  355. package/dist/esm/v3/errors.js +85 -1
  356. package/dist/esm/v3/errors.js.map +1 -1
  357. package/dist/esm/v3/idempotencyKeys.d.ts +1 -0
  358. package/dist/esm/v3/idempotencyKeys.js +18 -0
  359. package/dist/esm/v3/idempotencyKeys.js.map +1 -1
  360. package/dist/esm/v3/index.d.ts +7 -2
  361. package/dist/esm/v3/index.js +7 -2
  362. package/dist/esm/v3/index.js.map +1 -1
  363. package/dist/esm/v3/isomorphic/consts.d.ts +2 -0
  364. package/dist/esm/v3/isomorphic/consts.js +3 -0
  365. package/dist/esm/v3/isomorphic/consts.js.map +1 -0
  366. package/dist/esm/v3/{apps → isomorphic}/duration.d.ts +1 -0
  367. package/dist/esm/v3/{apps → isomorphic}/duration.js +18 -0
  368. package/dist/esm/v3/isomorphic/duration.js.map +1 -0
  369. package/dist/esm/v3/isomorphic/friendlyId.d.ts +36 -0
  370. package/dist/esm/v3/isomorphic/friendlyId.js +90 -0
  371. package/dist/esm/v3/isomorphic/friendlyId.js.map +1 -0
  372. package/dist/esm/v3/isomorphic/index.d.ts +5 -0
  373. package/dist/esm/v3/isomorphic/index.js +6 -0
  374. package/dist/esm/v3/isomorphic/index.js.map +1 -0
  375. package/dist/esm/v3/isomorphic/maxDuration.d.ts +2 -0
  376. package/dist/esm/v3/isomorphic/maxDuration.js +16 -0
  377. package/dist/esm/v3/isomorphic/maxDuration.js.map +1 -0
  378. package/dist/esm/v3/isomorphic/queueName.d.ts +1 -0
  379. package/dist/esm/v3/isomorphic/queueName.js +5 -0
  380. package/dist/esm/v3/isomorphic/queueName.js.map +1 -0
  381. package/dist/esm/v3/lifecycle-hooks-api.d.ts +4 -0
  382. package/dist/esm/v3/lifecycle-hooks-api.js +6 -0
  383. package/dist/esm/v3/lifecycle-hooks-api.js.map +1 -0
  384. package/dist/esm/v3/lifecycleHooks/index.d.ts +53 -0
  385. package/dist/esm/v3/lifecycleHooks/index.js +156 -0
  386. package/dist/esm/v3/lifecycleHooks/index.js.map +1 -0
  387. package/dist/esm/v3/lifecycleHooks/manager.d.ts +115 -0
  388. package/dist/esm/v3/lifecycleHooks/manager.js +396 -0
  389. package/dist/esm/v3/lifecycleHooks/manager.js.map +1 -0
  390. package/dist/esm/v3/lifecycleHooks/types.d.ts +179 -0
  391. package/dist/esm/v3/lifecycleHooks/types.js +2 -0
  392. package/dist/esm/v3/lifecycleHooks/types.js.map +1 -0
  393. package/dist/esm/v3/locals/index.d.ts +12 -0
  394. package/dist/esm/v3/locals/index.js +33 -0
  395. package/dist/esm/v3/locals/index.js.map +1 -0
  396. package/dist/esm/v3/locals/manager.d.ts +12 -0
  397. package/dist/esm/v3/locals/manager.js +30 -0
  398. package/dist/esm/v3/locals/manager.js.map +1 -0
  399. package/dist/esm/v3/locals/types.d.ts +14 -0
  400. package/dist/esm/v3/locals/types.js +2 -0
  401. package/dist/esm/v3/locals/types.js.map +1 -0
  402. package/dist/esm/v3/locals-api.d.ts +12 -0
  403. package/dist/esm/v3/locals-api.js +25 -0
  404. package/dist/esm/v3/locals-api.js.map +1 -0
  405. package/dist/esm/v3/logger/index.d.ts +4 -4
  406. package/dist/esm/v3/logger/index.js.map +1 -1
  407. package/dist/esm/v3/logger/taskLogger.d.ts +8 -4
  408. package/dist/esm/v3/logger/taskLogger.js +16 -2
  409. package/dist/esm/v3/logger/taskLogger.js.map +1 -1
  410. package/dist/esm/v3/machines/index.d.ts +27 -0
  411. package/dist/esm/v3/machines/index.js +46 -0
  412. package/dist/esm/v3/machines/index.js.map +1 -0
  413. package/dist/esm/v3/machines/max-old-space.test.d.ts +1 -0
  414. package/dist/esm/v3/machines/max-old-space.test.js +42 -0
  415. package/dist/esm/v3/machines/max-old-space.test.js.map +1 -0
  416. package/dist/esm/v3/otel/tracingSDK.js +1 -1
  417. package/dist/esm/v3/otel/tracingSDK.js.map +1 -1
  418. package/dist/esm/v3/otel/utils.d.ts +1 -0
  419. package/dist/esm/v3/otel/utils.js +6 -1
  420. package/dist/esm/v3/otel/utils.js.map +1 -1
  421. package/dist/{commonjs/v3/task-catalog → esm/v3/resource-catalog}/catalog.d.ts +7 -3
  422. package/dist/esm/v3/resource-catalog/catalog.js.map +1 -0
  423. package/dist/esm/v3/resource-catalog/index.d.ts +22 -0
  424. package/dist/esm/v3/resource-catalog/index.js +57 -0
  425. package/dist/esm/v3/resource-catalog/index.js.map +1 -0
  426. package/dist/esm/v3/resource-catalog/noopResourceCatalog.d.ts +17 -0
  427. package/dist/esm/v3/{task-catalog/noopTaskCatalog.js → resource-catalog/noopResourceCatalog.js} +15 -3
  428. package/dist/esm/v3/resource-catalog/noopResourceCatalog.js.map +1 -0
  429. package/dist/esm/v3/resource-catalog/standardResourceCatalog.d.ts +22 -0
  430. package/dist/esm/v3/resource-catalog/standardResourceCatalog.js +125 -0
  431. package/dist/esm/v3/resource-catalog/standardResourceCatalog.js.map +1 -0
  432. package/dist/esm/v3/resource-catalog-api.d.ts +3 -0
  433. package/dist/esm/v3/resource-catalog-api.js +6 -0
  434. package/dist/esm/v3/resource-catalog-api.js.map +1 -0
  435. package/dist/esm/v3/runEngineWorker/consts.d.ts +12 -0
  436. package/dist/esm/v3/runEngineWorker/consts.js +13 -0
  437. package/dist/esm/v3/runEngineWorker/consts.js.map +1 -0
  438. package/dist/esm/v3/runEngineWorker/index.d.ts +7 -0
  439. package/dist/esm/v3/runEngineWorker/index.js +8 -0
  440. package/dist/esm/v3/runEngineWorker/index.js.map +1 -0
  441. package/dist/esm/v3/runEngineWorker/supervisor/events.d.ts +49 -0
  442. package/dist/esm/v3/runEngineWorker/supervisor/events.js +2 -0
  443. package/dist/esm/v3/runEngineWorker/supervisor/events.js.map +1 -0
  444. package/dist/esm/v3/runEngineWorker/supervisor/http.d.ts +351 -0
  445. package/dist/esm/v3/runEngineWorker/supervisor/http.js +150 -0
  446. package/dist/esm/v3/runEngineWorker/supervisor/http.js.map +1 -0
  447. package/dist/esm/v3/runEngineWorker/supervisor/queueConsumer.d.ts +26 -0
  448. package/dist/esm/v3/runEngineWorker/supervisor/queueConsumer.js +88 -0
  449. package/dist/esm/v3/runEngineWorker/supervisor/queueConsumer.js.map +1 -0
  450. package/dist/esm/v3/runEngineWorker/supervisor/schemas.d.ts +3537 -0
  451. package/dist/esm/v3/runEngineWorker/supervisor/schemas.js +88 -0
  452. package/dist/esm/v3/runEngineWorker/supervisor/schemas.js.map +1 -0
  453. package/dist/esm/v3/runEngineWorker/supervisor/session.d.ts +32 -0
  454. package/dist/esm/v3/runEngineWorker/supervisor/session.js +167 -0
  455. package/dist/esm/v3/runEngineWorker/supervisor/session.js.map +1 -0
  456. package/dist/esm/v3/runEngineWorker/supervisor/types.d.ts +13 -0
  457. package/dist/esm/v3/runEngineWorker/supervisor/types.js +2 -0
  458. package/dist/esm/v3/runEngineWorker/supervisor/types.js.map +1 -0
  459. package/dist/esm/v3/runEngineWorker/supervisor/util.d.ts +3 -0
  460. package/dist/esm/v3/runEngineWorker/supervisor/util.js +35 -0
  461. package/dist/esm/v3/runEngineWorker/supervisor/util.js.map +1 -0
  462. package/dist/esm/v3/runEngineWorker/types.d.ts +52 -0
  463. package/dist/esm/v3/runEngineWorker/types.js +2 -0
  464. package/dist/esm/v3/runEngineWorker/types.js.map +1 -0
  465. package/dist/esm/v3/runEngineWorker/util.d.ts +4 -0
  466. package/dist/esm/v3/runEngineWorker/util.js +12 -0
  467. package/dist/esm/v3/runEngineWorker/util.js.map +1 -0
  468. package/dist/esm/v3/runEngineWorker/workload/http.d.ts +266 -0
  469. package/dist/esm/v3/runEngineWorker/workload/http.js +113 -0
  470. package/dist/esm/v3/runEngineWorker/workload/http.js.map +1 -0
  471. package/dist/esm/v3/runEngineWorker/workload/schemas.d.ts +2996 -0
  472. package/dist/esm/v3/runEngineWorker/workload/schemas.js +22 -0
  473. package/dist/esm/v3/runEngineWorker/workload/schemas.js.map +1 -0
  474. package/dist/esm/v3/runEngineWorker/workload/types.d.ts +7 -0
  475. package/dist/esm/v3/runEngineWorker/workload/types.js +2 -0
  476. package/dist/esm/v3/runEngineWorker/workload/types.js.map +1 -0
  477. package/dist/esm/v3/runEngineWorker/workload/util.d.ts +2 -0
  478. package/dist/esm/v3/runEngineWorker/workload/util.js +11 -0
  479. package/dist/esm/v3/runEngineWorker/workload/util.js.map +1 -0
  480. package/dist/esm/v3/runTimelineMetrics/runTimelineMetricsManager.d.ts +1 -1
  481. package/dist/esm/v3/runTimelineMetrics/runTimelineMetricsManager.js +5 -2
  482. package/dist/esm/v3/runTimelineMetrics/runTimelineMetricsManager.js.map +1 -1
  483. package/dist/esm/v3/runtime/index.d.ts +4 -4
  484. package/dist/esm/v3/runtime/index.js +5 -5
  485. package/dist/esm/v3/runtime/index.js.map +1 -1
  486. package/dist/esm/v3/runtime/managedRuntimeManager.d.ts +30 -0
  487. package/dist/esm/v3/runtime/managedRuntimeManager.js +181 -0
  488. package/dist/esm/v3/runtime/managedRuntimeManager.js.map +1 -0
  489. package/dist/esm/v3/runtime/manager.d.ts +6 -4
  490. package/dist/esm/v3/runtime/noopRuntimeManager.d.ts +6 -4
  491. package/dist/esm/v3/runtime/noopRuntimeManager.js +4 -5
  492. package/dist/esm/v3/runtime/noopRuntimeManager.js.map +1 -1
  493. package/dist/esm/v3/schemas/api.d.ts +1966 -586
  494. package/dist/esm/v3/schemas/api.js +249 -10
  495. package/dist/esm/v3/schemas/api.js.map +1 -1
  496. package/dist/esm/v3/schemas/build.d.ts +464 -356
  497. package/dist/esm/v3/schemas/build.js +6 -3
  498. package/dist/esm/v3/schemas/build.js.map +1 -1
  499. package/dist/esm/v3/schemas/checkpoints.d.ts +419 -0
  500. package/dist/esm/v3/schemas/checkpoints.js +20 -0
  501. package/dist/esm/v3/schemas/checkpoints.js.map +1 -0
  502. package/dist/esm/v3/schemas/common.d.ts +302 -189
  503. package/dist/esm/v3/schemas/common.js +49 -8
  504. package/dist/esm/v3/schemas/common.js.map +1 -1
  505. package/dist/esm/v3/schemas/fetch.d.ts +42 -42
  506. package/dist/esm/v3/schemas/index.d.ts +4 -0
  507. package/dist/esm/v3/schemas/index.js +4 -0
  508. package/dist/esm/v3/schemas/index.js.map +1 -1
  509. package/dist/esm/v3/schemas/messages.d.ts +4701 -3934
  510. package/dist/esm/v3/schemas/messages.js +28 -1
  511. package/dist/esm/v3/schemas/messages.js.map +1 -1
  512. package/dist/esm/v3/schemas/openTelemetry.d.ts +18 -18
  513. package/dist/esm/v3/schemas/queues.d.ts +97 -0
  514. package/dist/esm/v3/schemas/queues.js +67 -0
  515. package/dist/esm/v3/schemas/queues.js.map +1 -0
  516. package/dist/esm/v3/schemas/resources.d.ts +153 -114
  517. package/dist/esm/v3/schemas/resources.js +4 -3
  518. package/dist/esm/v3/schemas/resources.js.map +1 -1
  519. package/dist/esm/v3/schemas/runEngine.d.ts +1630 -0
  520. package/dist/esm/v3/schemas/runEngine.js +199 -0
  521. package/dist/esm/v3/schemas/runEngine.js.map +1 -0
  522. package/dist/esm/v3/schemas/schemas.d.ts +523 -401
  523. package/dist/esm/v3/schemas/schemas.js +22 -4
  524. package/dist/esm/v3/schemas/schemas.js.map +1 -1
  525. package/dist/esm/v3/schemas/style.d.ts +6 -4
  526. package/dist/esm/v3/schemas/style.js +3 -1
  527. package/dist/esm/v3/schemas/style.js.map +1 -1
  528. package/dist/esm/v3/schemas/warmStart.d.ts +12 -0
  529. package/dist/esm/v3/schemas/warmStart.js +6 -0
  530. package/dist/esm/v3/schemas/warmStart.js.map +1 -0
  531. package/dist/esm/v3/schemas/webhooks.d.ts +204 -204
  532. package/dist/esm/v3/schemas/webhooks.js +3 -4
  533. package/dist/esm/v3/schemas/webhooks.js.map +1 -1
  534. package/dist/esm/v3/semanticInternalAttributes.d.ts +7 -0
  535. package/dist/esm/v3/semanticInternalAttributes.js +7 -0
  536. package/dist/esm/v3/semanticInternalAttributes.js.map +1 -1
  537. package/dist/esm/v3/serverOnly/checkpointClient.d.ts +23 -0
  538. package/dist/esm/v3/serverOnly/checkpointClient.js +76 -0
  539. package/dist/esm/v3/serverOnly/checkpointClient.js.map +1 -0
  540. package/dist/esm/v3/{apps/checkpoints.js → serverOnly/checkpointTest.js} +2 -2
  541. package/dist/esm/v3/serverOnly/checkpointTest.js.map +1 -0
  542. package/dist/esm/v3/serverOnly/httpServer.d.ts +49 -0
  543. package/dist/esm/v3/serverOnly/httpServer.js +240 -0
  544. package/dist/esm/v3/serverOnly/httpServer.js.map +1 -0
  545. package/dist/esm/v3/serverOnly/index.d.ts +6 -0
  546. package/dist/esm/v3/serverOnly/index.js +7 -0
  547. package/dist/esm/v3/serverOnly/index.js.map +1 -0
  548. package/dist/esm/v3/serverOnly/k8s.d.ts +1 -0
  549. package/dist/esm/v3/serverOnly/k8s.js +15 -0
  550. package/dist/esm/v3/serverOnly/k8s.js.map +1 -0
  551. package/dist/esm/v3/serverOnly/shutdownManager.d.ts +20 -0
  552. package/dist/esm/v3/serverOnly/shutdownManager.js +88 -0
  553. package/dist/esm/v3/serverOnly/shutdownManager.js.map +1 -0
  554. package/dist/esm/v3/serverOnly/shutdownManager.test.d.ts +1 -0
  555. package/dist/esm/v3/serverOnly/shutdownManager.test.js +137 -0
  556. package/dist/esm/v3/serverOnly/shutdownManager.test.js.map +1 -0
  557. package/dist/esm/v3/serverOnly/singleton.d.ts +1 -0
  558. package/dist/esm/v3/serverOnly/singleton.js +7 -0
  559. package/dist/esm/v3/serverOnly/singleton.js.map +1 -0
  560. package/dist/esm/v3/taskContext/index.d.ts +1 -0
  561. package/dist/esm/v3/taskContext/index.js +4 -0
  562. package/dist/esm/v3/taskContext/index.js.map +1 -1
  563. package/dist/esm/v3/taskContext/otelProcessors.d.ts +3 -1
  564. package/dist/esm/v3/taskContext/otelProcessors.js +34 -1
  565. package/dist/esm/v3/taskContext/otelProcessors.js.map +1 -1
  566. package/dist/esm/v3/taskContext/types.d.ts +1 -0
  567. package/dist/esm/v3/tracer.js +21 -16
  568. package/dist/esm/v3/tracer.js.map +1 -1
  569. package/dist/esm/v3/tryCatch.d.ts +5 -0
  570. package/dist/esm/v3/tryCatch.js +11 -0
  571. package/dist/esm/v3/tryCatch.js.map +1 -0
  572. package/dist/esm/v3/types/index.d.ts +1 -0
  573. package/dist/esm/v3/types/index.js +1 -0
  574. package/dist/esm/v3/types/index.js.map +1 -1
  575. package/dist/esm/v3/types/queues.d.ts +43 -0
  576. package/dist/esm/v3/types/queues.js +2 -0
  577. package/dist/esm/v3/types/queues.js.map +1 -0
  578. package/dist/esm/v3/types/schemas.d.ts +3 -0
  579. package/dist/esm/v3/types/schemas.js +13 -0
  580. package/dist/esm/v3/types/schemas.js.map +1 -1
  581. package/dist/esm/v3/types/tasks.d.ts +77 -34
  582. package/dist/esm/v3/types/tasks.js.map +1 -1
  583. package/dist/esm/v3/utils/durations.d.ts +1 -0
  584. package/dist/esm/v3/utils/durations.js +1 -1
  585. package/dist/esm/v3/utils/durations.js.map +1 -1
  586. package/dist/esm/v3/utils/globals.d.ts +6 -2
  587. package/dist/esm/v3/utils/globals.js.map +1 -1
  588. package/dist/esm/v3/utils/heartbeat.d.ts +21 -0
  589. package/dist/esm/v3/utils/heartbeat.js +75 -0
  590. package/dist/esm/v3/utils/heartbeat.js.map +1 -0
  591. package/dist/esm/v3/utils/imageRef.d.ts +8 -0
  592. package/dist/esm/v3/utils/imageRef.js +51 -0
  593. package/dist/esm/v3/utils/imageRef.js.map +1 -0
  594. package/dist/esm/v3/workers/index.d.ts +8 -2
  595. package/dist/esm/v3/workers/index.js +8 -2
  596. package/dist/esm/v3/workers/index.js.map +1 -1
  597. package/dist/esm/v3/workers/populateEnv.d.ts +23 -0
  598. package/dist/esm/v3/workers/populateEnv.js +30 -0
  599. package/dist/esm/v3/workers/populateEnv.js.map +1 -0
  600. package/dist/esm/v3/workers/taskExecutor.d.ts +10 -9
  601. package/dist/esm/v3/workers/taskExecutor.js +651 -250
  602. package/dist/esm/v3/workers/taskExecutor.js.map +1 -1
  603. package/dist/esm/v3/workers/warmStartClient.d.ts +27 -0
  604. package/dist/esm/v3/workers/warmStartClient.js +108 -0
  605. package/dist/esm/v3/workers/warmStartClient.js.map +1 -0
  606. package/dist/esm/version.js +1 -1
  607. package/package.json +72 -128
  608. package/dist/commonjs/bloom.d.ts +0 -10
  609. package/dist/commonjs/bloom.js +0 -58
  610. package/dist/commonjs/bloom.js.map +0 -1
  611. package/dist/commonjs/replacements.d.ts +0 -19
  612. package/dist/commonjs/replacements.js +0 -27
  613. package/dist/commonjs/replacements.js.map +0 -1
  614. package/dist/commonjs/requestFilterMatches.d.ts +0 -7
  615. package/dist/commonjs/requestFilterMatches.js +0 -62
  616. package/dist/commonjs/requestFilterMatches.js.map +0 -1
  617. package/dist/commonjs/schemas/addMissingVersionField.d.ts +0 -1
  618. package/dist/commonjs/schemas/addMissingVersionField.js +0 -13
  619. package/dist/commonjs/schemas/addMissingVersionField.js.map +0 -1
  620. package/dist/commonjs/schemas/api.d.ts +0 -13789
  621. package/dist/commonjs/schemas/api.js +0 -852
  622. package/dist/commonjs/schemas/api.js.map +0 -1
  623. package/dist/commonjs/schemas/errors.d.ts +0 -26
  624. package/dist/commonjs/schemas/errors.js +0 -14
  625. package/dist/commonjs/schemas/errors.js.map +0 -1
  626. package/dist/commonjs/schemas/events.d.ts +0 -66
  627. package/dist/commonjs/schemas/events.js +0 -31
  628. package/dist/commonjs/schemas/events.js.map +0 -1
  629. package/dist/commonjs/schemas/fetch.d.ts +0 -682
  630. package/dist/commonjs/schemas/fetch.js +0 -68
  631. package/dist/commonjs/schemas/fetch.js.map +0 -1
  632. package/dist/commonjs/schemas/integrations.d.ts +0 -66
  633. package/dist/commonjs/schemas/integrations.js +0 -21
  634. package/dist/commonjs/schemas/integrations.js.map +0 -1
  635. package/dist/commonjs/schemas/jobs.d.ts +0 -12
  636. package/dist/commonjs/schemas/jobs.js +0 -9
  637. package/dist/commonjs/schemas/jobs.js.map +0 -1
  638. package/dist/commonjs/schemas/notifications.d.ts +0 -587
  639. package/dist/commonjs/schemas/notifications.js +0 -59
  640. package/dist/commonjs/schemas/notifications.js.map +0 -1
  641. package/dist/commonjs/schemas/properties.d.ts +0 -57
  642. package/dist/commonjs/schemas/properties.js +0 -23
  643. package/dist/commonjs/schemas/properties.js.map +0 -1
  644. package/dist/commonjs/schemas/request.d.ts +0 -17
  645. package/dist/commonjs/schemas/request.js +0 -11
  646. package/dist/commonjs/schemas/request.js.map +0 -1
  647. package/dist/commonjs/schemas/requestFilter.d.ts +0 -225
  648. package/dist/commonjs/schemas/requestFilter.js +0 -60
  649. package/dist/commonjs/schemas/requestFilter.js.map +0 -1
  650. package/dist/commonjs/schemas/runs.d.ts +0 -344
  651. package/dist/commonjs/schemas/runs.js +0 -91
  652. package/dist/commonjs/schemas/runs.js.map +0 -1
  653. package/dist/commonjs/schemas/schedules.d.ts +0 -185
  654. package/dist/commonjs/schemas/schedules.js +0 -48
  655. package/dist/commonjs/schemas/schedules.js.map +0 -1
  656. package/dist/commonjs/schemas/statuses.d.ts +0 -89
  657. package/dist/commonjs/schemas/statuses.js +0 -23
  658. package/dist/commonjs/schemas/statuses.js.map +0 -1
  659. package/dist/commonjs/schemas/tasks.d.ts +0 -294
  660. package/dist/commonjs/schemas/tasks.js +0 -50
  661. package/dist/commonjs/schemas/tasks.js.map +0 -1
  662. package/dist/commonjs/schemas/triggers.d.ts +0 -532
  663. package/dist/commonjs/schemas/triggers.js +0 -57
  664. package/dist/commonjs/schemas/triggers.js.map +0 -1
  665. package/dist/commonjs/searchParams.d.ts +0 -1
  666. package/dist/commonjs/searchParams.js +0 -16
  667. package/dist/commonjs/searchParams.js.map +0 -1
  668. package/dist/commonjs/v3/apps/checkpoints.js.map +0 -1
  669. package/dist/commonjs/v3/apps/duration.js.map +0 -1
  670. package/dist/commonjs/v3/apps/friendlyId.d.ts +0 -1
  671. package/dist/commonjs/v3/apps/friendlyId.js +0 -9
  672. package/dist/commonjs/v3/apps/friendlyId.js.map +0 -1
  673. package/dist/commonjs/v3/dev/index.d.ts +0 -1
  674. package/dist/commonjs/v3/dev/index.js +0 -6
  675. package/dist/commonjs/v3/dev/index.js.map +0 -1
  676. package/dist/commonjs/v3/prod/index.d.ts +0 -1
  677. package/dist/commonjs/v3/prod/index.js +0 -6
  678. package/dist/commonjs/v3/prod/index.js.map +0 -1
  679. package/dist/commonjs/v3/runtime/devRuntimeManager.d.ts +0 -27
  680. package/dist/commonjs/v3/runtime/devRuntimeManager.js +0 -77
  681. package/dist/commonjs/v3/runtime/devRuntimeManager.js.map +0 -1
  682. package/dist/commonjs/v3/runtime/prodRuntimeManager.d.ts +0 -38
  683. package/dist/commonjs/v3/runtime/prodRuntimeManager.js +0 -94
  684. package/dist/commonjs/v3/runtime/prodRuntimeManager.js.map +0 -1
  685. package/dist/commonjs/v3/task-catalog/catalog.js.map +0 -1
  686. package/dist/commonjs/v3/task-catalog/index.d.ts +0 -18
  687. package/dist/commonjs/v3/task-catalog/index.js +0 -49
  688. package/dist/commonjs/v3/task-catalog/index.js.map +0 -1
  689. package/dist/commonjs/v3/task-catalog/noopTaskCatalog.d.ts +0 -13
  690. package/dist/commonjs/v3/task-catalog/noopTaskCatalog.js.map +0 -1
  691. package/dist/commonjs/v3/task-catalog/standardTaskCatalog.d.ts +0 -16
  692. package/dist/commonjs/v3/task-catalog/standardTaskCatalog.js +0 -84
  693. package/dist/commonjs/v3/task-catalog/standardTaskCatalog.js.map +0 -1
  694. package/dist/commonjs/v3/task-catalog-api.d.ts +0 -3
  695. package/dist/commonjs/v3/task-catalog-api.js.map +0 -1
  696. package/dist/commonjs/versions.d.ts +0 -9
  697. package/dist/commonjs/versions.js +0 -23
  698. package/dist/commonjs/versions.js.map +0 -1
  699. package/dist/esm/bloom.d.ts +0 -10
  700. package/dist/esm/bloom.js +0 -54
  701. package/dist/esm/bloom.js.map +0 -1
  702. package/dist/esm/replacements.d.ts +0 -19
  703. package/dist/esm/replacements.js +0 -24
  704. package/dist/esm/replacements.js.map +0 -1
  705. package/dist/esm/requestFilterMatches.d.ts +0 -7
  706. package/dist/esm/requestFilterMatches.js +0 -58
  707. package/dist/esm/requestFilterMatches.js.map +0 -1
  708. package/dist/esm/schemas/addMissingVersionField.d.ts +0 -1
  709. package/dist/esm/schemas/addMissingVersionField.js +0 -10
  710. package/dist/esm/schemas/addMissingVersionField.js.map +0 -1
  711. package/dist/esm/schemas/api.d.ts +0 -13789
  712. package/dist/esm/schemas/api.js +0 -847
  713. package/dist/esm/schemas/api.js.map +0 -1
  714. package/dist/esm/schemas/errors.d.ts +0 -26
  715. package/dist/esm/schemas/errors.js +0 -11
  716. package/dist/esm/schemas/errors.js.map +0 -1
  717. package/dist/esm/schemas/events.d.ts +0 -66
  718. package/dist/esm/schemas/events.js +0 -28
  719. package/dist/esm/schemas/events.js.map +0 -1
  720. package/dist/esm/schemas/fetch.d.ts +0 -682
  721. package/dist/esm/schemas/fetch.js +0 -65
  722. package/dist/esm/schemas/fetch.js.map +0 -1
  723. package/dist/esm/schemas/integrations.d.ts +0 -66
  724. package/dist/esm/schemas/integrations.js +0 -18
  725. package/dist/esm/schemas/integrations.js.map +0 -1
  726. package/dist/esm/schemas/jobs.d.ts +0 -12
  727. package/dist/esm/schemas/jobs.js +0 -6
  728. package/dist/esm/schemas/jobs.js.map +0 -1
  729. package/dist/esm/schemas/notifications.d.ts +0 -587
  730. package/dist/esm/schemas/notifications.js +0 -56
  731. package/dist/esm/schemas/notifications.js.map +0 -1
  732. package/dist/esm/schemas/properties.d.ts +0 -57
  733. package/dist/esm/schemas/properties.js +0 -20
  734. package/dist/esm/schemas/properties.js.map +0 -1
  735. package/dist/esm/schemas/request.d.ts +0 -17
  736. package/dist/esm/schemas/request.js +0 -8
  737. package/dist/esm/schemas/request.js.map +0 -1
  738. package/dist/esm/schemas/requestFilter.d.ts +0 -225
  739. package/dist/esm/schemas/requestFilter.js +0 -57
  740. package/dist/esm/schemas/requestFilter.js.map +0 -1
  741. package/dist/esm/schemas/runs.d.ts +0 -344
  742. package/dist/esm/schemas/runs.js +0 -88
  743. package/dist/esm/schemas/runs.js.map +0 -1
  744. package/dist/esm/schemas/schedules.d.ts +0 -185
  745. package/dist/esm/schemas/schedules.js +0 -45
  746. package/dist/esm/schemas/schedules.js.map +0 -1
  747. package/dist/esm/schemas/statuses.d.ts +0 -89
  748. package/dist/esm/schemas/statuses.js +0 -20
  749. package/dist/esm/schemas/statuses.js.map +0 -1
  750. package/dist/esm/schemas/tasks.d.ts +0 -294
  751. package/dist/esm/schemas/tasks.js +0 -47
  752. package/dist/esm/schemas/tasks.js.map +0 -1
  753. package/dist/esm/schemas/triggers.d.ts +0 -532
  754. package/dist/esm/schemas/triggers.js +0 -54
  755. package/dist/esm/schemas/triggers.js.map +0 -1
  756. package/dist/esm/searchParams.d.ts +0 -1
  757. package/dist/esm/searchParams.js +0 -13
  758. package/dist/esm/searchParams.js.map +0 -1
  759. package/dist/esm/v3/apps/checkpoints.js.map +0 -1
  760. package/dist/esm/v3/apps/duration.js.map +0 -1
  761. package/dist/esm/v3/apps/friendlyId.d.ts +0 -1
  762. package/dist/esm/v3/apps/friendlyId.js +0 -6
  763. package/dist/esm/v3/apps/friendlyId.js.map +0 -1
  764. package/dist/esm/v3/dev/index.d.ts +0 -1
  765. package/dist/esm/v3/dev/index.js +0 -2
  766. package/dist/esm/v3/dev/index.js.map +0 -1
  767. package/dist/esm/v3/prod/index.d.ts +0 -1
  768. package/dist/esm/v3/prod/index.js +0 -2
  769. package/dist/esm/v3/prod/index.js.map +0 -1
  770. package/dist/esm/v3/runtime/devRuntimeManager.d.ts +0 -27
  771. package/dist/esm/v3/runtime/devRuntimeManager.js +0 -73
  772. package/dist/esm/v3/runtime/devRuntimeManager.js.map +0 -1
  773. package/dist/esm/v3/runtime/prodRuntimeManager.d.ts +0 -38
  774. package/dist/esm/v3/runtime/prodRuntimeManager.js +0 -90
  775. package/dist/esm/v3/runtime/prodRuntimeManager.js.map +0 -1
  776. package/dist/esm/v3/task-catalog/catalog.js.map +0 -1
  777. package/dist/esm/v3/task-catalog/index.d.ts +0 -18
  778. package/dist/esm/v3/task-catalog/index.js +0 -45
  779. package/dist/esm/v3/task-catalog/index.js.map +0 -1
  780. package/dist/esm/v3/task-catalog/noopTaskCatalog.d.ts +0 -13
  781. package/dist/esm/v3/task-catalog/noopTaskCatalog.js.map +0 -1
  782. package/dist/esm/v3/task-catalog/standardTaskCatalog.d.ts +0 -16
  783. package/dist/esm/v3/task-catalog/standardTaskCatalog.js +0 -80
  784. package/dist/esm/v3/task-catalog/standardTaskCatalog.js.map +0 -1
  785. package/dist/esm/v3/task-catalog-api.d.ts +0 -3
  786. package/dist/esm/v3/task-catalog-api.js +0 -6
  787. package/dist/esm/v3/task-catalog-api.js.map +0 -1
  788. package/dist/esm/versions.d.ts +0 -9
  789. package/dist/esm/versions.js +0 -19
  790. package/dist/esm/versions.js.map +0 -1
  791. /package/dist/commonjs/v3/{task-catalog → resource-catalog}/catalog.js +0 -0
  792. /package/dist/commonjs/v3/{apps/checkpoints.d.ts → serverOnly/checkpointTest.d.ts} +0 -0
  793. /package/dist/esm/v3/{task-catalog → resource-catalog}/catalog.js +0 -0
  794. /package/dist/esm/v3/{apps/checkpoints.d.ts → serverOnly/checkpointTest.d.ts} +0 -0
@@ -10,6 +10,7 @@ const run_timeline_metrics_api_js_1 = require("../run-timeline-metrics-api.js");
10
10
  const index_js_3 = require("../schemas/index.js");
11
11
  const semanticInternalAttributes_js_1 = require("../semanticInternalAttributes.js");
12
12
  const task_context_api_js_1 = require("../task-context-api.js");
13
+ const tryCatch_js_1 = require("../tryCatch.js");
13
14
  const ioSerialization_js_1 = require("../utils/ioSerialization.js");
14
15
  const retries_js_1 = require("../utils/retries.js");
15
16
  class TaskExecutor {
@@ -17,17 +18,17 @@ class TaskExecutor {
17
18
  _tracingSDK;
18
19
  _tracer;
19
20
  _consoleInterceptor;
20
- _importedConfig;
21
- _handleErrorFn;
21
+ _retries;
22
+ _isWarmStart;
22
23
  constructor(task, options) {
23
24
  this.task = task;
24
25
  this._tracingSDK = options.tracingSDK;
25
26
  this._tracer = options.tracer;
26
27
  this._consoleInterceptor = options.consoleInterceptor;
27
- this._importedConfig = options.config;
28
- this._handleErrorFn = options.handleErrorFn;
28
+ this._retries = options.retries;
29
+ this._isWarmStart = options.isWarmStart;
29
30
  }
30
- async execute(execution, worker, traceContext, usage, signal) {
31
+ async execute(execution, worker, traceContext, signal, isWarmStart) {
31
32
  const ctx = index_js_3.TaskRunContext.parse(execution);
32
33
  const attemptMessage = `Attempt ${execution.attempt.number}`;
33
34
  const originalPacket = {
@@ -37,6 +38,7 @@ class TaskExecutor {
37
38
  task_context_api_js_1.taskContext.setGlobalTaskContext({
38
39
  ctx,
39
40
  worker,
41
+ isWarmStart: isWarmStart ?? this._isWarmStart,
40
42
  });
41
43
  if (execution.run.metadata) {
42
44
  index_js_1.runMetadata.enterWithMetadata(execution.run.metadata);
@@ -50,75 +52,49 @@ class TaskExecutor {
50
52
  return await this._consoleInterceptor.intercept(console, async () => {
51
53
  let parsedPayload;
52
54
  let initOutput;
53
- try {
54
- await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "payload", async () => {
55
- const payloadPacket = await (0, ioSerialization_js_1.conditionallyImportPacket)(originalPacket, this._tracer);
56
- parsedPayload = await (0, ioSerialization_js_1.parsePacket)(payloadPacket);
57
- });
58
- }
59
- catch (inputError) {
55
+ const [inputError, payloadResult] = await (0, tryCatch_js_1.tryCatch)(run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "payload", async () => {
56
+ const payloadPacket = await (0, ioSerialization_js_1.conditionallyImportPacket)(originalPacket, this._tracer);
57
+ return await (0, ioSerialization_js_1.parsePacket)(payloadPacket);
58
+ }));
59
+ if (inputError) {
60
60
  (0, index_js_2.recordSpanException)(span, inputError);
61
- return {
62
- ok: false,
63
- id: execution.run.id,
64
- error: {
65
- type: "INTERNAL_ERROR",
66
- code: index_js_3.TaskRunErrorCodes.TASK_INPUT_ERROR,
67
- message: inputError instanceof Error
68
- ? `${inputError.name}: ${inputError.message}`
69
- : typeof inputError === "string"
70
- ? inputError
71
- : undefined,
72
- stackTrace: inputError instanceof Error ? inputError.stack : undefined,
73
- },
74
- };
61
+ return this.#internalErrorResult(execution, index_js_3.TaskRunErrorCodes.TASK_INPUT_ERROR, inputError);
75
62
  }
76
- try {
77
- parsedPayload = await this.#parsePayload(parsedPayload);
78
- if (execution.attempt.number === 1) {
79
- await this.#callOnStartFunctions(parsedPayload, ctx, signal);
80
- }
81
- initOutput = await this.#callInitFunctions(parsedPayload, ctx, signal);
82
- const output = await this.#callRun(parsedPayload, ctx, initOutput, signal);
83
- await this.#callOnSuccessFunctions(parsedPayload, output, ctx, initOutput, signal);
84
- try {
85
- const stringifiedOutput = await (0, ioSerialization_js_1.stringifyIO)(output);
86
- const finalOutput = await (0, ioSerialization_js_1.conditionallyExportPacket)(stringifiedOutput, `${execution.attempt.id}/output`, this._tracer);
87
- const attributes = await (0, ioSerialization_js_1.createPacketAttributes)(finalOutput, semanticInternalAttributes_js_1.SemanticInternalAttributes.OUTPUT, semanticInternalAttributes_js_1.SemanticInternalAttributes.OUTPUT_TYPE);
88
- if (attributes) {
89
- span.setAttributes(attributes);
63
+ parsedPayload = await this.#parsePayload(payloadResult);
64
+ index_js_1.lifecycleHooks.registerOnWaitHookListener(async (wait) => {
65
+ await this.#callOnWaitFunctions(wait, parsedPayload, ctx, initOutput, signal);
66
+ });
67
+ index_js_1.lifecycleHooks.registerOnResumeHookListener(async (wait) => {
68
+ await this.#callOnResumeFunctions(wait, parsedPayload, ctx, initOutput, signal);
69
+ });
70
+ const executeTask = async (payload) => {
71
+ const [runError, output] = await (0, tryCatch_js_1.tryCatch)((async () => {
72
+ initOutput = await this.#callInitFunctions(payload, ctx, signal);
73
+ if (execution.attempt.number === 1) {
74
+ await this.#callOnStartFunctions(payload, ctx, initOutput, signal);
75
+ }
76
+ try {
77
+ return await this.#callRun(payload, ctx, initOutput, signal);
78
+ }
79
+ catch (error) {
80
+ if ((0, errors_js_1.isCompleteTaskWithOutput)(error)) {
81
+ return error.output;
82
+ }
83
+ throw error;
84
+ }
85
+ })());
86
+ if (runError) {
87
+ const [handleErrorError, handleErrorResult] = await (0, tryCatch_js_1.tryCatch)(this.#handleError(execution, runError, payload, ctx, initOutput, signal));
88
+ if (handleErrorError) {
89
+ (0, index_js_2.recordSpanException)(span, handleErrorError);
90
+ return this.#internalErrorResult(execution, index_js_3.TaskRunErrorCodes.HANDLE_ERROR_ERROR, handleErrorError);
90
91
  }
91
- return {
92
- ok: true,
93
- id: execution.run.id,
94
- output: finalOutput.data,
95
- outputType: finalOutput.dataType,
96
- };
97
- }
98
- catch (outputError) {
99
- (0, index_js_2.recordSpanException)(span, outputError);
100
- return {
101
- ok: false,
102
- id: execution.run.id,
103
- error: {
104
- type: "INTERNAL_ERROR",
105
- code: index_js_3.TaskRunErrorCodes.TASK_OUTPUT_ERROR,
106
- message: outputError instanceof Error
107
- ? outputError.message
108
- : typeof outputError === "string"
109
- ? outputError
110
- : undefined,
111
- },
112
- };
113
- }
114
- }
115
- catch (runError) {
116
- try {
117
- const handleErrorResult = await this.#handleError(execution, runError, parsedPayload, ctx, initOutput, signal);
118
92
  (0, index_js_2.recordSpanException)(span, handleErrorResult.error ?? runError);
119
93
  if (handleErrorResult.status !== "retry") {
120
- await this.#callOnFailureFunctions(parsedPayload, handleErrorResult.error ?? runError, ctx, initOutput, signal);
94
+ await this.#callOnFailureFunctions(payload, handleErrorResult.error ?? runError, ctx, initOutput, signal);
95
+ await this.#callOnCompleteFunctions(payload, { ok: false, error: handleErrorResult.error ?? runError }, ctx, initOutput, signal);
121
96
  }
97
+ await this.#cleanupAndWaitUntil(payload, ctx, initOutput, signal);
122
98
  return {
123
99
  id: execution.run.id,
124
100
  ok: false,
@@ -129,37 +105,56 @@ class TaskExecutor {
129
105
  skippedRetrying: handleErrorResult.status === "skipped",
130
106
  };
131
107
  }
132
- catch (handleErrorError) {
133
- (0, index_js_2.recordSpanException)(span, handleErrorError);
134
- return {
135
- ok: false,
136
- id: execution.run.id,
137
- error: {
138
- type: "INTERNAL_ERROR",
139
- code: index_js_3.TaskRunErrorCodes.HANDLE_ERROR_ERROR,
140
- message: handleErrorError instanceof Error
141
- ? handleErrorError.message
142
- : typeof handleErrorError === "string"
143
- ? handleErrorError
144
- : undefined,
145
- },
146
- };
108
+ const [outputError, stringifiedOutput] = await (0, tryCatch_js_1.tryCatch)((0, ioSerialization_js_1.stringifyIO)(output));
109
+ if (outputError) {
110
+ (0, index_js_2.recordSpanException)(span, outputError);
111
+ await this.#cleanupAndWaitUntil(payload, ctx, initOutput, signal);
112
+ return this.#internalErrorResult(execution, index_js_3.TaskRunErrorCodes.TASK_OUTPUT_ERROR, outputError);
147
113
  }
148
- }
149
- finally {
150
- await this.#callTaskCleanup(parsedPayload, ctx, initOutput, signal);
151
- await this.#blockForWaitUntil();
152
- span.setAttributes(run_timeline_metrics_api_js_1.runTimelineMetrics.convertMetricsToSpanAttributes());
153
- }
114
+ const [exportError, finalOutput] = await (0, tryCatch_js_1.tryCatch)((0, ioSerialization_js_1.conditionallyExportPacket)(stringifiedOutput, `${execution.attempt.id}/output`, this._tracer));
115
+ if (exportError) {
116
+ (0, index_js_2.recordSpanException)(span, exportError);
117
+ await this.#cleanupAndWaitUntil(payload, ctx, initOutput, signal);
118
+ return this.#internalErrorResult(execution, index_js_3.TaskRunErrorCodes.TASK_OUTPUT_ERROR, exportError);
119
+ }
120
+ const [attrError, attributes] = await (0, tryCatch_js_1.tryCatch)((0, ioSerialization_js_1.createPacketAttributes)(finalOutput, semanticInternalAttributes_js_1.SemanticInternalAttributes.OUTPUT, semanticInternalAttributes_js_1.SemanticInternalAttributes.OUTPUT_TYPE));
121
+ if (!attrError && attributes) {
122
+ span.setAttributes(attributes);
123
+ }
124
+ await this.#callOnSuccessFunctions(payload, output, ctx, initOutput, signal);
125
+ await this.#callOnCompleteFunctions(payload, { ok: true, data: output }, ctx, initOutput, signal);
126
+ await this.#cleanupAndWaitUntil(payload, ctx, initOutput, signal);
127
+ return {
128
+ ok: true,
129
+ id: execution.run.id,
130
+ output: finalOutput.data,
131
+ outputType: finalOutput.dataType,
132
+ };
133
+ };
134
+ const globalMiddlewareHooks = index_js_1.lifecycleHooks.getGlobalMiddlewareHooks();
135
+ const taskMiddlewareHook = index_js_1.lifecycleHooks.getTaskMiddlewareHook(this.task.id);
136
+ const middlewareHooks = [
137
+ ...globalMiddlewareHooks,
138
+ taskMiddlewareHook ? { id: this.task.id, fn: taskMiddlewareHook } : undefined,
139
+ ].filter(Boolean);
140
+ return await this.#executeTaskWithMiddlewareHooks(parsedPayload, ctx, execution, middlewareHooks, executeTask, signal);
154
141
  });
155
142
  }, {
156
143
  kind: api_1.SpanKind.CONSUMER,
157
144
  attributes: {
158
145
  [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "attempt",
146
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.ENTITY_TYPE]: "attempt",
159
147
  [semanticInternalAttributes_js_1.SemanticInternalAttributes.SPAN_ATTEMPT]: true,
160
148
  ...(execution.attempt.number === 1
161
149
  ? run_timeline_metrics_api_js_1.runTimelineMetrics.convertMetricsToSpanAttributes()
162
150
  : {}),
151
+ ...(execution.environment.type !== "DEVELOPMENT"
152
+ ? {
153
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_VARIANT]: this._isWarmStart
154
+ ? index_js_3.WARM_VARIANT
155
+ : index_js_3.COLD_VARIANT,
156
+ }
157
+ : {}),
163
158
  },
164
159
  events: execution.attempt.number === 1
165
160
  ? run_timeline_metrics_api_js_1.runTimelineMetrics.convertMetricsToSpanEvents()
@@ -167,129 +162,426 @@ class TaskExecutor {
167
162
  }, this._tracer.extractContext(traceContext), signal);
168
163
  return { result };
169
164
  }
165
+ async #executeTaskWithMiddlewareHooks(payload, ctx, execution, hooks, executeTask, signal) {
166
+ let output;
167
+ let executeError;
168
+ const runner = hooks.reduceRight((next, hook) => {
169
+ return async () => {
170
+ await this._tracer.startActiveSpan("middleware()", async (span) => {
171
+ await hook.fn({ payload, ctx, signal, task: this.task.id, next });
172
+ }, {
173
+ attributes: {
174
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-middleware",
175
+ ...this.#lifecycleHookAccessoryAttributes(hook.name),
176
+ },
177
+ });
178
+ };
179
+ }, async () => {
180
+ const [error, result] = await (0, tryCatch_js_1.tryCatch)(executeTask(payload));
181
+ if (error) {
182
+ executeError = error;
183
+ }
184
+ else {
185
+ output = result;
186
+ }
187
+ });
188
+ const [runnerError] = await (0, tryCatch_js_1.tryCatch)(runner());
189
+ if (runnerError) {
190
+ return this.#internalErrorResult(execution, index_js_3.TaskRunErrorCodes.TASK_MIDDLEWARE_ERROR, runnerError);
191
+ }
192
+ if (executeError) {
193
+ throw executeError;
194
+ }
195
+ return output;
196
+ }
170
197
  async #callRun(payload, ctx, init, signal) {
171
198
  const runFn = this.task.fns.run;
172
- const middlewareFn = this.task.fns.middleware;
173
199
  if (!runFn) {
174
200
  throw new Error("Task does not have a run function");
175
201
  }
176
- if (!middlewareFn) {
177
- return run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "run", () => runFn(payload, { ctx, init, signal }));
202
+ // Create a promise that rejects when the signal aborts
203
+ const abortPromise = signal
204
+ ? new Promise((_, reject) => {
205
+ signal.addEventListener("abort", () => {
206
+ const maxDuration = ctx.run.maxDuration;
207
+ reject(new errors_js_1.InternalError({
208
+ code: index_js_3.TaskRunErrorCodes.MAX_DURATION_EXCEEDED,
209
+ message: `Run exceeded maximum compute time (maxDuration) of ${maxDuration} seconds`,
210
+ }));
211
+ });
212
+ })
213
+ : undefined;
214
+ return run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "run", async () => {
215
+ return await this._tracer.startActiveSpan("run()", async (span) => {
216
+ if (abortPromise) {
217
+ // Race between the run function and the abort promise
218
+ return await Promise.race([runFn(payload, { ctx, init, signal }), abortPromise]);
219
+ }
220
+ return await runFn(payload, { ctx, init, signal });
221
+ }, {
222
+ attributes: { [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-fn-run" },
223
+ });
224
+ });
225
+ }
226
+ async #callOnWaitFunctions(wait, payload, ctx, initOutput, signal) {
227
+ const globalWaitHooks = index_js_1.lifecycleHooks.getGlobalWaitHooks();
228
+ const taskWaitHook = index_js_1.lifecycleHooks.getTaskWaitHook(this.task.id);
229
+ if (globalWaitHooks.length === 0 && !taskWaitHook) {
230
+ return;
178
231
  }
179
- return middlewareFn(payload, {
180
- ctx,
181
- signal,
182
- next: async () => run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "run", () => runFn(payload, { ctx, init, signal })),
232
+ const result = await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "onWait", async () => {
233
+ for (const hook of globalWaitHooks) {
234
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("onWait()", async (span) => {
235
+ await hook.fn({ payload, ctx, signal, task: this.task.id, wait, init: initOutput });
236
+ }, {
237
+ attributes: {
238
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-onWait",
239
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
240
+ ...this.#lifecycleHookAccessoryAttributes(hook.name),
241
+ },
242
+ }));
243
+ if (hookError) {
244
+ throw hookError;
245
+ }
246
+ }
247
+ if (taskWaitHook) {
248
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("onWait()", async (span) => {
249
+ await taskWaitHook({
250
+ payload,
251
+ ctx,
252
+ signal,
253
+ task: this.task.id,
254
+ wait,
255
+ init: initOutput,
256
+ });
257
+ }, {
258
+ attributes: {
259
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-onWait",
260
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
261
+ ...this.#lifecycleHookAccessoryAttributes("task"),
262
+ },
263
+ }));
264
+ if (hookError) {
265
+ throw hookError;
266
+ }
267
+ }
183
268
  });
184
269
  }
185
- async #callInitFunctions(payload, ctx, signal) {
186
- await this.#callConfigInit(payload, ctx, signal);
187
- const initFn = this.task.fns.init;
188
- if (!initFn) {
189
- return {};
270
+ async #callOnResumeFunctions(wait, payload, ctx, initOutput, signal) {
271
+ const globalResumeHooks = index_js_1.lifecycleHooks.getGlobalResumeHooks();
272
+ const taskResumeHook = index_js_1.lifecycleHooks.getTaskResumeHook(this.task.id);
273
+ if (globalResumeHooks.length === 0 && !taskResumeHook) {
274
+ return;
190
275
  }
191
- return this._tracer.startActiveSpan("init", async (span) => {
192
- return await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "init", () => initFn(payload, { ctx, signal }));
193
- }, {
194
- attributes: {
195
- [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "function",
196
- },
276
+ const result = await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "onResume", async () => {
277
+ for (const hook of globalResumeHooks) {
278
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("onResume()", async (span) => {
279
+ await hook.fn({ payload, ctx, signal, task: this.task.id, wait, init: initOutput });
280
+ }, {
281
+ attributes: {
282
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-onResume",
283
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
284
+ ...this.#lifecycleHookAccessoryAttributes(hook.name),
285
+ },
286
+ }));
287
+ if (hookError) {
288
+ throw hookError;
289
+ }
290
+ }
291
+ if (taskResumeHook) {
292
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("onResume()", async (span) => {
293
+ await taskResumeHook({
294
+ payload,
295
+ ctx,
296
+ signal,
297
+ task: this.task.id,
298
+ wait,
299
+ init: initOutput,
300
+ });
301
+ }, {
302
+ attributes: {
303
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-onResume",
304
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
305
+ ...this.#lifecycleHookAccessoryAttributes("task"),
306
+ },
307
+ }));
308
+ if (hookError) {
309
+ throw hookError;
310
+ }
311
+ }
197
312
  });
198
313
  }
199
- async #callConfigInit(payload, ctx, signal) {
200
- const initFn = this._importedConfig?.init;
201
- if (!initFn) {
314
+ async #callInitFunctions(payload, ctx, signal) {
315
+ const globalInitHooks = index_js_1.lifecycleHooks.getGlobalInitHooks();
316
+ const taskInitHook = index_js_1.lifecycleHooks.getTaskInitHook(this.task.id);
317
+ if (globalInitHooks.length === 0 && !taskInitHook) {
202
318
  return {};
203
319
  }
204
- return this._tracer.startActiveSpan("config.init", async (span) => {
205
- return await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "config.init", async () => initFn(payload, { ctx, signal }));
206
- }, {
207
- attributes: {
208
- [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "function",
209
- },
320
+ const result = await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "init", async () => {
321
+ // Store global hook results in an array
322
+ const globalResults = [];
323
+ for (const hook of globalInitHooks) {
324
+ const [hookError, result] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("init()", async (span) => {
325
+ const result = await hook.fn({ payload, ctx, signal, task: this.task.id });
326
+ if (result && typeof result === "object" && !Array.isArray(result)) {
327
+ span.setAttributes((0, index_js_1.flattenAttributes)(result));
328
+ return result;
329
+ }
330
+ return {};
331
+ }, {
332
+ attributes: {
333
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-init",
334
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
335
+ ...this.#lifecycleHookAccessoryAttributes(hook.name),
336
+ },
337
+ }));
338
+ if (hookError) {
339
+ throw hookError;
340
+ }
341
+ if (result && typeof result === "object" && !Array.isArray(result)) {
342
+ globalResults.push(result);
343
+ }
344
+ }
345
+ // Merge all global results into a single object
346
+ const mergedGlobalResults = Object.assign({}, ...globalResults);
347
+ if (taskInitHook) {
348
+ const [hookError, taskResult] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("init()", async (span) => {
349
+ const result = await taskInitHook({ payload, ctx, signal, task: this.task.id });
350
+ if (result && typeof result === "object" && !Array.isArray(result)) {
351
+ span.setAttributes((0, index_js_1.flattenAttributes)(result));
352
+ return result;
353
+ }
354
+ return {};
355
+ }, {
356
+ attributes: {
357
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-init",
358
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
359
+ ...this.#lifecycleHookAccessoryAttributes("task"),
360
+ },
361
+ }));
362
+ if (hookError) {
363
+ throw hookError;
364
+ }
365
+ // Only merge if taskResult is an object
366
+ if (taskResult && typeof taskResult === "object" && !Array.isArray(taskResult)) {
367
+ return { ...mergedGlobalResults, ...taskResult };
368
+ }
369
+ // If taskResult isn't an object, return global results
370
+ return mergedGlobalResults;
371
+ }
372
+ return mergedGlobalResults;
210
373
  });
374
+ if (result && typeof result === "object" && !Array.isArray(result)) {
375
+ return result;
376
+ }
377
+ return;
211
378
  }
212
379
  async #callOnSuccessFunctions(payload, output, ctx, initOutput, signal) {
213
- await this.#callOnSuccessFunction(this.task.fns.onSuccess, "task.onSuccess", payload, output, ctx, initOutput, signal);
214
- await this.#callOnSuccessFunction(this._importedConfig?.onSuccess, "config.onSuccess", payload, output, ctx, initOutput, signal);
215
- }
216
- async #callOnSuccessFunction(onSuccessFn, name, payload, output, ctx, initOutput, signal) {
217
- if (!onSuccessFn) {
380
+ const globalSuccessHooks = index_js_1.lifecycleHooks.getGlobalSuccessHooks();
381
+ const taskSuccessHook = index_js_1.lifecycleHooks.getTaskSuccessHook(this.task.id);
382
+ if (globalSuccessHooks.length === 0 && !taskSuccessHook) {
218
383
  return;
219
384
  }
220
- try {
221
- await this._tracer.startActiveSpan(name, async (span) => {
222
- return await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", name, () => onSuccessFn(payload, output, { ctx, init: initOutput, signal }));
223
- }, {
224
- attributes: {
225
- [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "function",
226
- },
227
- });
228
- }
229
- catch {
230
- // Ignore errors from onSuccess functions
231
- }
385
+ return await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "success", async () => {
386
+ for (const hook of globalSuccessHooks) {
387
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("onSuccess()", async (span) => {
388
+ await hook.fn({
389
+ payload,
390
+ output,
391
+ ctx,
392
+ signal,
393
+ task: this.task.id,
394
+ init: initOutput,
395
+ });
396
+ }, {
397
+ attributes: {
398
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-onSuccess",
399
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
400
+ ...this.#lifecycleHookAccessoryAttributes(hook.name),
401
+ },
402
+ }));
403
+ if (hookError) {
404
+ throw hookError;
405
+ }
406
+ }
407
+ if (taskSuccessHook) {
408
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("onSuccess()", async (span) => {
409
+ await taskSuccessHook({
410
+ payload,
411
+ output,
412
+ ctx,
413
+ signal,
414
+ task: this.task.id,
415
+ init: initOutput,
416
+ });
417
+ }, {
418
+ attributes: {
419
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-onSuccess",
420
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
421
+ ...this.#lifecycleHookAccessoryAttributes("task"),
422
+ },
423
+ }));
424
+ if (hookError) {
425
+ throw hookError;
426
+ }
427
+ }
428
+ });
232
429
  }
233
430
  async #callOnFailureFunctions(payload, error, ctx, initOutput, signal) {
234
- await this.#callOnFailureFunction(this.task.fns.onFailure, "task.onFailure", payload, error, ctx, initOutput, signal);
235
- await this.#callOnFailureFunction(this._importedConfig?.onFailure, "config.onFailure", payload, error, ctx, initOutput, signal);
236
- }
237
- async #callOnFailureFunction(onFailureFn, name, payload, error, ctx, initOutput, signal) {
238
- if (!onFailureFn) {
431
+ const globalFailureHooks = index_js_1.lifecycleHooks.getGlobalFailureHooks();
432
+ const taskFailureHook = index_js_1.lifecycleHooks.getTaskFailureHook(this.task.id);
433
+ if (globalFailureHooks.length === 0 && !taskFailureHook) {
239
434
  return;
240
435
  }
241
- try {
242
- return await this._tracer.startActiveSpan(name, async (span) => {
243
- return await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", name, () => onFailureFn(payload, error, { ctx, init: initOutput, signal }));
244
- }, {
245
- attributes: {
246
- [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "function",
247
- },
248
- });
249
- }
250
- catch (e) {
251
- // Ignore errors from onFailure functions
252
- }
436
+ return await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "failure", async () => {
437
+ for (const hook of globalFailureHooks) {
438
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("onFailure()", async (span) => {
439
+ await hook.fn({
440
+ payload,
441
+ error,
442
+ ctx,
443
+ signal,
444
+ task: this.task.id,
445
+ init: initOutput,
446
+ });
447
+ }, {
448
+ attributes: {
449
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-onFailure",
450
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
451
+ ...this.#lifecycleHookAccessoryAttributes(hook.name),
452
+ },
453
+ }));
454
+ if (hookError) {
455
+ throw hookError;
456
+ }
457
+ }
458
+ if (taskFailureHook) {
459
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("onFailure()", async (span) => {
460
+ await taskFailureHook({
461
+ payload,
462
+ error,
463
+ ctx,
464
+ signal,
465
+ task: this.task.id,
466
+ init: initOutput,
467
+ });
468
+ }, {
469
+ attributes: {
470
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-onFailure",
471
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
472
+ ...this.#lifecycleHookAccessoryAttributes("task"),
473
+ },
474
+ }));
475
+ if (hookError) {
476
+ throw hookError;
477
+ }
478
+ }
479
+ });
253
480
  }
254
481
  async #parsePayload(payload) {
255
482
  if (!this.task.fns.parsePayload) {
256
483
  return payload;
257
484
  }
258
- try {
259
- return await this.task.fns.parsePayload(payload);
260
- }
261
- catch (e) {
262
- throw new errors_js_1.TaskPayloadParsedError(e);
485
+ const [parseError, result] = await (0, tryCatch_js_1.tryCatch)(this.task.fns.parsePayload(payload));
486
+ if (parseError) {
487
+ throw new errors_js_1.TaskPayloadParsedError(parseError);
263
488
  }
489
+ return result;
264
490
  }
265
- async #callOnStartFunctions(payload, ctx, signal) {
266
- await this.#callOnStartFunction(this._importedConfig?.onStart, "config.onStart", payload, ctx, {}, signal);
267
- await this.#callOnStartFunction(this.task.fns.onStart, "task.onStart", payload, ctx, {}, signal);
268
- }
269
- async #callOnStartFunction(onStartFn, name, payload, ctx, initOutput, signal) {
270
- if (!onStartFn) {
491
+ async #callOnStartFunctions(payload, ctx, initOutput, signal) {
492
+ const globalStartHooks = index_js_1.lifecycleHooks.getGlobalStartHooks();
493
+ const taskStartHook = index_js_1.lifecycleHooks.getTaskStartHook(this.task.id);
494
+ if (globalStartHooks.length === 0 && !taskStartHook) {
271
495
  return;
272
496
  }
273
- try {
274
- await this._tracer.startActiveSpan(name, async (span) => {
275
- return await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", name, () => onStartFn(payload, { ctx, signal }));
276
- }, {
277
- attributes: {
278
- [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "function",
279
- },
280
- });
281
- }
282
- catch {
283
- // Ignore errors from onStart functions
284
- }
497
+ return await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "start", async () => {
498
+ for (const hook of globalStartHooks) {
499
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("onStart()", async (span) => {
500
+ await hook.fn({ payload, ctx, signal, task: this.task.id, init: initOutput });
501
+ }, {
502
+ attributes: {
503
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-onStart",
504
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
505
+ ...this.#lifecycleHookAccessoryAttributes(hook.name),
506
+ },
507
+ }));
508
+ if (hookError) {
509
+ throw hookError;
510
+ }
511
+ }
512
+ if (taskStartHook) {
513
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("onStart()", async (span) => {
514
+ await taskStartHook({
515
+ payload,
516
+ ctx,
517
+ signal,
518
+ task: this.task.id,
519
+ init: initOutput,
520
+ });
521
+ }, {
522
+ attributes: {
523
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-onStart",
524
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
525
+ ...this.#lifecycleHookAccessoryAttributes("task"),
526
+ },
527
+ }));
528
+ if (hookError) {
529
+ throw hookError;
530
+ }
531
+ }
532
+ });
285
533
  }
286
- async #callTaskCleanup(payload, ctx, init, signal) {
287
- const cleanupFn = this.task.fns.cleanup;
288
- if (!cleanupFn) {
534
+ async #cleanupAndWaitUntil(payload, ctx, initOutput, signal) {
535
+ await this.#callCleanupFunctions(payload, ctx, initOutput, signal);
536
+ await this.#blockForWaitUntil();
537
+ }
538
+ async #callCleanupFunctions(payload, ctx, initOutput, signal) {
539
+ const globalCleanupHooks = index_js_1.lifecycleHooks.getGlobalCleanupHooks();
540
+ const taskCleanupHook = index_js_1.lifecycleHooks.getTaskCleanupHook(this.task.id);
541
+ if (globalCleanupHooks.length === 0 && !taskCleanupHook) {
289
542
  return;
290
543
  }
291
- return this._tracer.startActiveSpan("cleanup", async (span) => {
292
- return await cleanupFn(payload, { ctx, init, signal });
544
+ return await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "cleanup", async () => {
545
+ for (const hook of globalCleanupHooks) {
546
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("cleanup()", async (span) => {
547
+ await hook.fn({
548
+ payload,
549
+ ctx,
550
+ signal,
551
+ task: this.task.id,
552
+ init: initOutput,
553
+ });
554
+ }, {
555
+ attributes: {
556
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-cleanup",
557
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
558
+ ...this.#lifecycleHookAccessoryAttributes(hook.name),
559
+ },
560
+ }));
561
+ if (hookError) {
562
+ throw hookError;
563
+ }
564
+ }
565
+ if (taskCleanupHook) {
566
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("cleanup()", async (span) => {
567
+ await taskCleanupHook({
568
+ payload,
569
+ ctx,
570
+ signal,
571
+ task: this.task.id,
572
+ init: initOutput,
573
+ });
574
+ }, {
575
+ attributes: {
576
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-cleanup",
577
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
578
+ ...this.#lifecycleHookAccessoryAttributes("task"),
579
+ },
580
+ }));
581
+ if (hookError) {
582
+ throw hookError;
583
+ }
584
+ }
293
585
  });
294
586
  }
295
587
  async #blockForWaitUntil() {
@@ -300,103 +592,212 @@ class TaskExecutor {
300
592
  return await index_js_1.waitUntil.blockUntilSettled(60_000);
301
593
  }, {
302
594
  attributes: {
303
- [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "clock",
595
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "tabler-clock",
596
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
304
597
  },
305
598
  });
306
599
  }
307
600
  async #handleError(execution, error, payload, ctx, init, signal) {
308
- const retriesConfig = this._importedConfig?.retries;
601
+ const retriesConfig = this._retries;
309
602
  const retry = this.task.retry ?? retriesConfig?.default;
310
- if (!retry) {
311
- return { status: "noop" };
603
+ // Early exit conditions that prevent retrying
604
+ if ((0, errors_js_1.isInternalError)(error) && error.skipRetrying) {
605
+ return { status: "skipped", error };
312
606
  }
313
607
  if (error instanceof Error &&
314
608
  (error.name === "AbortTaskRunError" || error.name === "TaskPayloadParsedError")) {
315
609
  return { status: "skipped" };
316
610
  }
317
- if ((0, errors_js_1.isInternalError)(error) && error.skipRetrying) {
318
- return { status: "skipped", error };
319
- }
320
- if (execution.run.maxAttempts) {
321
- retry.maxAttempts = Math.max(execution.run.maxAttempts, 1);
322
- }
323
- let delay = (0, retries_js_1.calculateNextRetryDelay)(retry, execution.attempt.number);
324
- if (delay &&
325
- error instanceof Error &&
326
- error.name === "TriggerApiError" &&
327
- error.status === 429) {
328
- const rateLimitError = error;
329
- delay = rateLimitError.millisecondsUntilReset;
611
+ // Calculate default retry delay if retry config exists
612
+ let defaultDelay;
613
+ if (retry) {
614
+ if (execution.run.maxAttempts) {
615
+ retry.maxAttempts = Math.max(execution.run.maxAttempts, 1);
616
+ }
617
+ defaultDelay = (0, retries_js_1.calculateNextRetryDelay)(retry, execution.attempt.number);
618
+ // Handle rate limit errors
619
+ if (defaultDelay &&
620
+ error instanceof Error &&
621
+ error.name === "TriggerApiError" &&
622
+ error.status === 429) {
623
+ const rateLimitError = error;
624
+ defaultDelay = rateLimitError.millisecondsUntilReset;
625
+ }
330
626
  }
627
+ const defaultRetryResult = typeof defaultDelay === "undefined"
628
+ ? { status: "noop" }
629
+ : {
630
+ status: "retry",
631
+ retry: { timestamp: Date.now() + defaultDelay, delay: defaultDelay },
632
+ };
633
+ // Check if retries are enabled in dev environment
331
634
  if (execution.environment.type === "DEVELOPMENT" &&
332
635
  typeof retriesConfig?.enabledInDev === "boolean" &&
333
636
  !retriesConfig.enabledInDev) {
334
637
  return { status: "skipped" };
335
638
  }
336
- return this._tracer.startActiveSpan("handleError()", async (span) => {
337
- const handleErrorResult = this.task.fns.handleError
338
- ? await this.task.fns.handleError(payload, error, {
639
+ const taskCatchErrorHook = index_js_1.lifecycleHooks.getTaskCatchErrorHook(this.task.id);
640
+ const globalCatchErrorHooks = index_js_1.lifecycleHooks.getGlobalCatchErrorHooks();
641
+ if (globalCatchErrorHooks.length === 0 && !taskCatchErrorHook) {
642
+ return defaultRetryResult;
643
+ }
644
+ return this._tracer.startActiveSpan("catchError", async (span) => {
645
+ // Try task-specific catch error hook first
646
+ if (taskCatchErrorHook) {
647
+ const result = await taskCatchErrorHook({
648
+ payload,
649
+ error,
339
650
  ctx,
340
651
  init,
341
652
  retry,
342
- retryDelayInMs: delay,
343
- retryAt: delay ? new Date(Date.now() + delay) : undefined,
653
+ retryDelayInMs: defaultDelay,
654
+ retryAt: defaultDelay ? new Date(Date.now() + defaultDelay) : undefined,
344
655
  signal,
345
- })
346
- : this._importedConfig
347
- ? await this._handleErrorFn?.(payload, error, {
348
- ctx,
349
- init,
350
- retry,
351
- retryDelayInMs: delay,
352
- retryAt: delay ? new Date(Date.now() + delay) : undefined,
353
- signal,
354
- })
355
- : undefined;
356
- // If handleErrorResult
357
- if (!handleErrorResult) {
358
- return typeof delay === "undefined"
359
- ? { status: "noop" }
360
- : { status: "retry", retry: { timestamp: Date.now() + delay, delay } };
656
+ task: this.task.id,
657
+ });
658
+ if (result) {
659
+ return this.#processHandleErrorResult(result, execution.attempt.number, defaultDelay);
660
+ }
361
661
  }
362
- if (handleErrorResult.skipRetrying) {
363
- return { status: "skipped", error: handleErrorResult.error };
662
+ // Try global catch error hooks in order
663
+ for (const hook of globalCatchErrorHooks) {
664
+ const result = await hook.fn({
665
+ payload,
666
+ error,
667
+ ctx,
668
+ init,
669
+ retry,
670
+ retryDelayInMs: defaultDelay,
671
+ retryAt: defaultDelay ? new Date(Date.now() + defaultDelay) : undefined,
672
+ signal,
673
+ task: this.task.id,
674
+ });
675
+ if (result) {
676
+ return this.#processHandleErrorResult(result, execution.attempt.number, defaultDelay);
677
+ }
364
678
  }
365
- if (typeof handleErrorResult.retryAt !== "undefined") {
366
- return {
679
+ // If no hooks handled the error, use default retry behavior
680
+ return defaultRetryResult;
681
+ }, {
682
+ attributes: {
683
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-catchError",
684
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
685
+ },
686
+ });
687
+ }
688
+ // Helper method to process handle error results
689
+ #processHandleErrorResult(result, attemptNumber, defaultDelay) {
690
+ if (result.skipRetrying) {
691
+ return { status: "skipped", error: result.error };
692
+ }
693
+ if (typeof result.retryAt !== "undefined") {
694
+ return {
695
+ status: "retry",
696
+ retry: {
697
+ timestamp: result.retryAt.getTime(),
698
+ delay: result.retryAt.getTime() - Date.now(),
699
+ },
700
+ error: result.error,
701
+ };
702
+ }
703
+ if (typeof result.retryDelayInMs === "number") {
704
+ return {
705
+ status: "retry",
706
+ retry: {
707
+ timestamp: Date.now() + result.retryDelayInMs,
708
+ delay: result.retryDelayInMs,
709
+ },
710
+ error: result.error,
711
+ };
712
+ }
713
+ if (result.retry && typeof result.retry === "object") {
714
+ const delay = (0, retries_js_1.calculateNextRetryDelay)(result.retry, attemptNumber);
715
+ return typeof delay === "undefined"
716
+ ? { status: "noop", error: result.error }
717
+ : {
367
718
  status: "retry",
368
- retry: {
369
- timestamp: handleErrorResult.retryAt.getTime(),
370
- delay: handleErrorResult.retryAt.getTime() - Date.now(),
371
- },
372
- error: handleErrorResult.error,
719
+ retry: { timestamp: Date.now() + delay, delay },
720
+ error: result.error,
373
721
  };
374
- }
375
- if (typeof handleErrorResult.retryDelayInMs === "number") {
376
- return {
377
- status: "retry",
378
- retry: {
379
- timestamp: Date.now() + handleErrorResult.retryDelayInMs,
380
- delay: handleErrorResult.retryDelayInMs,
722
+ }
723
+ return { status: "noop", error: result.error };
724
+ }
725
+ async #callOnCompleteFunctions(payload, result, ctx, initOutput, signal) {
726
+ const globalCompleteHooks = index_js_1.lifecycleHooks.getGlobalCompleteHooks();
727
+ const taskCompleteHook = index_js_1.lifecycleHooks.getTaskCompleteHook(this.task.id);
728
+ if (globalCompleteHooks.length === 0 && !taskCompleteHook) {
729
+ return;
730
+ }
731
+ return await run_timeline_metrics_api_js_1.runTimelineMetrics.measureMetric("trigger.dev/execution", "complete", async () => {
732
+ for (const hook of globalCompleteHooks) {
733
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("onComplete()", async (span) => {
734
+ await hook.fn({
735
+ payload,
736
+ result,
737
+ ctx,
738
+ signal,
739
+ task: this.task.id,
740
+ init: initOutput,
741
+ });
742
+ }, {
743
+ attributes: {
744
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-onComplete",
745
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
746
+ ...this.#lifecycleHookAccessoryAttributes(hook.name),
381
747
  },
382
- error: handleErrorResult.error,
383
- };
748
+ }));
749
+ if (hookError) {
750
+ throw hookError;
751
+ }
384
752
  }
385
- if (handleErrorResult.retry && typeof handleErrorResult.retry === "object") {
386
- const delay = (0, retries_js_1.calculateNextRetryDelay)(handleErrorResult.retry, execution.attempt.number);
387
- return typeof delay === "undefined"
388
- ? { status: "noop", error: handleErrorResult.error }
389
- : {
390
- status: "retry",
391
- retry: { timestamp: Date.now() + delay, delay },
392
- error: handleErrorResult.error,
393
- };
753
+ if (taskCompleteHook) {
754
+ const [hookError] = await (0, tryCatch_js_1.tryCatch)(this._tracer.startActiveSpan("onComplete()", async (span) => {
755
+ await taskCompleteHook({
756
+ payload,
757
+ result,
758
+ ctx,
759
+ signal,
760
+ task: this.task.id,
761
+ init: initOutput,
762
+ });
763
+ }, {
764
+ attributes: {
765
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "task-hook-onComplete",
766
+ [semanticInternalAttributes_js_1.SemanticInternalAttributes.COLLAPSED]: true,
767
+ ...this.#lifecycleHookAccessoryAttributes("task"),
768
+ },
769
+ }));
770
+ if (hookError) {
771
+ throw hookError;
772
+ }
394
773
  }
395
- return { status: "noop", error: handleErrorResult.error };
396
- }, {
397
- attributes: {
398
- [semanticInternalAttributes_js_1.SemanticInternalAttributes.STYLE_ICON]: "exclamation-circle",
774
+ });
775
+ }
776
+ #internalErrorResult(execution, code, error) {
777
+ return {
778
+ ok: false,
779
+ id: execution.run.id,
780
+ error: {
781
+ type: "INTERNAL_ERROR",
782
+ code,
783
+ message: error instanceof Error
784
+ ? `${error.name}: ${error.message}`
785
+ : typeof error === "string"
786
+ ? error
787
+ : undefined,
788
+ stackTrace: error instanceof Error ? error.stack : undefined,
399
789
  },
790
+ };
791
+ }
792
+ #lifecycleHookAccessoryAttributes(name) {
793
+ return (0, index_js_1.accessoryAttributes)({
794
+ items: [
795
+ {
796
+ text: name ?? "global",
797
+ variant: "normal",
798
+ },
799
+ ],
800
+ style: "codepath",
400
801
  });
401
802
  }
402
803
  }