@sixb/core 0.1.9 → 0.1.11

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 (328) hide show
  1. package/dist/actions/index.js +9 -9
  2. package/dist/agents/index.js +17 -16
  3. package/dist/agents/index.js.map +1 -1
  4. package/dist/blob-storage/types.d.ts +4 -1
  5. package/dist/blob-storage/types.d.ts.map +1 -1
  6. package/dist/bootstrap/index.js +21 -20
  7. package/dist/bootstrap/index.js.map +1 -1
  8. package/dist/broker/in-memory.d.ts +8 -2
  9. package/dist/broker/in-memory.d.ts.map +1 -1
  10. package/dist/broker/index.d.ts +4 -2
  11. package/dist/broker/index.d.ts.map +1 -1
  12. package/dist/broker/index.js +7 -3
  13. package/dist/broker/index.js.map +1 -1
  14. package/dist/broker/retention.d.ts +4 -0
  15. package/dist/broker/retention.d.ts.map +1 -0
  16. package/dist/broker/subscriber.d.ts +10 -0
  17. package/dist/broker/subscriber.d.ts.map +1 -0
  18. package/dist/broker/types.d.ts +14 -1
  19. package/dist/broker/types.d.ts.map +1 -1
  20. package/dist/{chunk-ypbtykv6.js → chunk-01kj2pbh.js} +1 -1
  21. package/dist/{chunk-k3cqkkn2.js → chunk-1824gssz.js} +30 -65
  22. package/dist/chunk-1824gssz.js.map +12 -0
  23. package/dist/{chunk-xyr8kppc.js → chunk-1yefycb1.js} +1 -1
  24. package/dist/chunk-2c4j899j.js.map +1 -1
  25. package/dist/{chunk-ppytyr6w.js → chunk-358caqf5.js} +4 -4
  26. package/dist/chunk-358caqf5.js.map +12 -0
  27. package/dist/{chunk-m3z3x9v0.js → chunk-3ckk0xfj.js} +2 -2
  28. package/dist/{chunk-kxwa347f.js → chunk-3qms4nax.js} +2 -2
  29. package/dist/{chunk-kxwa347f.js.map → chunk-3qms4nax.js.map} +3 -3
  30. package/dist/{chunk-52hbv0ak.js → chunk-4zhmdsx6.js} +141 -55
  31. package/dist/chunk-4zhmdsx6.js.map +36 -0
  32. package/dist/{chunk-zcnq6105.js → chunk-85cd7e8c.js} +2 -1
  33. package/dist/chunk-85cd7e8c.js.map +10 -0
  34. package/dist/{chunk-3f7veca0.js → chunk-9x8dybsb.js} +3 -3
  35. package/dist/chunk-9x8dybsb.js.map +10 -0
  36. package/dist/{chunk-0w35wavj.js → chunk-a0e6x5hd.js} +1 -1
  37. package/dist/{chunk-r29fxdhn.js → chunk-aa6z4a19.js} +160 -44
  38. package/dist/chunk-aa6z4a19.js.map +12 -0
  39. package/dist/{chunk-emyyk7dx.js → chunk-cfvakeax.js} +22 -145
  40. package/dist/chunk-cfvakeax.js.map +12 -0
  41. package/dist/chunk-d62kjtbg.js.map +1 -1
  42. package/dist/{chunk-h1gfhhbh.js → chunk-d63nnr5b.js} +2 -2
  43. package/dist/{chunk-r4tfx1sf.js → chunk-fh8kgex1.js} +5 -5
  44. package/dist/{chunk-an5tt9y0.js → chunk-ftv470j8.js} +42 -4
  45. package/dist/{chunk-an5tt9y0.js.map → chunk-ftv470j8.js.map} +7 -7
  46. package/dist/{chunk-jjy0fhrn.js → chunk-g91qxjj0.js} +20 -3
  47. package/dist/chunk-g91qxjj0.js.map +12 -0
  48. package/dist/{chunk-hpr1r6av.js → chunk-gq8vhakp.js} +51 -40
  49. package/dist/{chunk-hpr1r6av.js.map → chunk-gq8vhakp.js.map} +6 -6
  50. package/dist/{chunk-x57ycxq0.js → chunk-gqh45d2n.js} +42 -3
  51. package/dist/{chunk-x57ycxq0.js.map → chunk-gqh45d2n.js.map} +3 -3
  52. package/dist/{chunk-mjbk2djy.js → chunk-gqm76kse.js} +231 -125
  53. package/dist/{chunk-mjbk2djy.js.map → chunk-gqm76kse.js.map} +9 -8
  54. package/dist/{chunk-e0d1rzef.js → chunk-jsy70480.js} +16 -3
  55. package/dist/chunk-jsy70480.js.map +15 -0
  56. package/dist/{chunk-0rdrecsb.js → chunk-kfee1h52.js} +116 -32
  57. package/dist/chunk-kfee1h52.js.map +13 -0
  58. package/dist/{chunk-3frsnm7x.js → chunk-qma80ych.js} +4 -6
  59. package/dist/chunk-qma80ych.js.map +11 -0
  60. package/dist/{chunk-vf691g1r.js → chunk-sepyxgpc.js} +3 -3
  61. package/dist/chunk-v2vcg0w6.js +151 -0
  62. package/dist/chunk-v2vcg0w6.js.map +11 -0
  63. package/dist/{chunk-3tgwrcyh.js → chunk-wf88w4kp.js} +17 -23
  64. package/dist/chunk-wf88w4kp.js.map +14 -0
  65. package/dist/{chunk-xfbydgzy.js → chunk-x9m9x2eq.js} +7 -8
  66. package/dist/{chunk-xfbydgzy.js.map → chunk-x9m9x2eq.js.map} +3 -3
  67. package/dist/{chunk-qhcpj9wc.js → chunk-z0271qkp.js} +98 -2
  68. package/dist/chunk-z0271qkp.js.map +15 -0
  69. package/dist/{chunk-1enhpacz.js → chunk-z0s4axeh.js} +6 -6
  70. package/dist/connectors/connections/authorizations.d.ts.map +1 -1
  71. package/dist/connectors/connections/command-context.d.ts +2 -0
  72. package/dist/connectors/connections/command-context.d.ts.map +1 -1
  73. package/dist/connectors/connections/contracts.d.ts +4 -1
  74. package/dist/connectors/connections/contracts.d.ts.map +1 -1
  75. package/dist/connectors/connections/execution.d.ts +1 -0
  76. package/dist/connectors/connections/execution.d.ts.map +1 -1
  77. package/dist/connectors/connections/internal.js +1 -1
  78. package/dist/connectors/connections/request.d.ts +3 -1
  79. package/dist/connectors/connections/request.d.ts.map +1 -1
  80. package/dist/connectors/connections/runs.d.ts +1 -0
  81. package/dist/connectors/connections/runs.d.ts.map +1 -1
  82. package/dist/connectors/connections/service.d.ts +2 -0
  83. package/dist/connectors/connections/service.d.ts.map +1 -1
  84. package/dist/connectors/connections/tokens.d.ts.map +1 -1
  85. package/dist/connectors/connections/validation.d.ts +5 -1
  86. package/dist/connectors/connections/validation.d.ts.map +1 -1
  87. package/dist/connectors/types.d.ts +19 -4
  88. package/dist/connectors/types.d.ts.map +1 -1
  89. package/dist/events/execution.d.ts +1 -1
  90. package/dist/events/execution.d.ts.map +1 -1
  91. package/dist/events/index.js +1 -1
  92. package/dist/events/outbox-dispatcher.d.ts +2 -2
  93. package/dist/events/outbox-dispatcher.d.ts.map +1 -1
  94. package/dist/events/service.d.ts +2 -2
  95. package/dist/events/service.d.ts.map +1 -1
  96. package/dist/execution/agent.js +17 -16
  97. package/dist/execution/agent.js.map +1 -1
  98. package/dist/execution/primitive.js +17 -16
  99. package/dist/execution/primitive.js.map +2 -2
  100. package/dist/execution/request.js +17 -16
  101. package/dist/execution/request.js.map +2 -2
  102. package/dist/index.d.ts +3 -3
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +31 -29
  105. package/dist/index.js.map +1 -1
  106. package/dist/lake-storage/changes.d.ts +5 -0
  107. package/dist/lake-storage/changes.d.ts.map +1 -0
  108. package/dist/lake-storage/in-memory.d.ts +2 -1
  109. package/dist/lake-storage/in-memory.d.ts.map +1 -1
  110. package/dist/lake-storage/index.d.ts +2 -1
  111. package/dist/lake-storage/index.d.ts.map +1 -1
  112. package/dist/lake-storage/index.js +4 -2
  113. package/dist/lake-storage/index.js.map +1 -1
  114. package/dist/lake-storage/types.d.ts +38 -0
  115. package/dist/lake-storage/types.d.ts.map +1 -1
  116. package/dist/logging/internal.js +1 -1
  117. package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
  118. package/dist/maintenance/types.d.ts +1 -1
  119. package/dist/maintenance/types.d.ts.map +1 -1
  120. package/dist/materialization/index.d.ts +1 -1
  121. package/dist/materialization/index.d.ts.map +1 -1
  122. package/dist/materialization/model.d.ts +12 -1
  123. package/dist/materialization/model.d.ts.map +1 -1
  124. package/dist/materializer/index.d.ts +1 -1
  125. package/dist/materializer/index.d.ts.map +1 -1
  126. package/dist/materializer/index.js +6 -6
  127. package/dist/materializer/materializer.d.ts +5 -1
  128. package/dist/materializer/materializer.d.ts.map +1 -1
  129. package/dist/materializer/projections/entry-validator.d.ts +2 -1
  130. package/dist/materializer/projections/entry-validator.d.ts.map +1 -1
  131. package/dist/materializer/projections/replace.d.ts.map +1 -1
  132. package/dist/materializer/projections/source-materialization.d.ts +4 -3
  133. package/dist/materializer/projections/source-materialization.d.ts.map +1 -1
  134. package/dist/materializer/shared/normalize.d.ts +2 -1
  135. package/dist/materializer/shared/normalize.d.ts.map +1 -1
  136. package/dist/models/definitions.d.ts +7 -0
  137. package/dist/models/definitions.d.ts.map +1 -1
  138. package/dist/models/execution/index.js +6 -6
  139. package/dist/models/index.js +1 -1
  140. package/dist/objects/index.js +10 -10
  141. package/dist/objects/query/index.js +6 -6
  142. package/dist/pipelines/index.js +7 -7
  143. package/dist/pipelines/run-dispatch.d.ts.map +1 -1
  144. package/dist/projections/internal.js +7 -9
  145. package/dist/projections/internal.js.map +1 -1
  146. package/dist/projections/run-dispatch.d.ts.map +1 -1
  147. package/dist/queues/in-memory.d.ts +7 -3
  148. package/dist/queues/in-memory.d.ts.map +1 -1
  149. package/dist/queues/index.js +1 -1
  150. package/dist/queues/indexed-heap.d.ts +15 -0
  151. package/dist/queues/indexed-heap.d.ts.map +1 -0
  152. package/dist/runtime/host.d.ts.map +1 -1
  153. package/dist/runtime/internal.js +1 -1
  154. package/dist/runtime/ontology-mutations.d.ts +3 -1
  155. package/dist/runtime/ontology-mutations.d.ts.map +1 -1
  156. package/dist/shares/internal.js +5 -5
  157. package/dist/storage/agents/provider.js +1 -1
  158. package/dist/storage/connector-connections/in-memory.d.ts +1 -0
  159. package/dist/storage/connector-connections/in-memory.d.ts.map +1 -1
  160. package/dist/storage/connector-connections/provider/connections.d.ts.map +1 -1
  161. package/dist/storage/connector-connections/provider/runs.d.ts +1 -0
  162. package/dist/storage/connector-connections/provider/runs.d.ts.map +1 -1
  163. package/dist/storage/connector-connections/provider/shared.d.ts +1 -0
  164. package/dist/storage/connector-connections/provider/shared.d.ts.map +1 -1
  165. package/dist/storage/connector-connections/provider.d.ts +1 -0
  166. package/dist/storage/connector-connections/provider.d.ts.map +1 -1
  167. package/dist/storage/connector-connections/provider.js +11 -17
  168. package/dist/storage/connector-connections/provider.js.map +6 -6
  169. package/dist/storage/connector-connections/types.d.ts +6 -3
  170. package/dist/storage/connector-connections/types.d.ts.map +1 -1
  171. package/dist/storage/index.d.ts +1 -1
  172. package/dist/storage/index.d.ts.map +1 -1
  173. package/dist/storage/index.js +5 -5
  174. package/dist/storage/internal.js +1 -1
  175. package/dist/storage/ontology/in-memory/materializations-state.d.ts.map +1 -1
  176. package/dist/storage/ontology/in-memory/materializations.d.ts +1 -1
  177. package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
  178. package/dist/storage/ontology/in-memory/shared-state.d.ts +15 -2
  179. package/dist/storage/ontology/in-memory/shared-state.d.ts.map +1 -1
  180. package/dist/storage/ontology/in-memory/source-roots.d.ts +6 -0
  181. package/dist/storage/ontology/in-memory/source-roots.d.ts.map +1 -0
  182. package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -1
  183. package/dist/storage/ontology/index.d.ts +1 -1
  184. package/dist/storage/ontology/index.d.ts.map +1 -1
  185. package/dist/storage/ontology/outbox.d.ts +1 -0
  186. package/dist/storage/ontology/outbox.d.ts.map +1 -1
  187. package/dist/storage/ontology/provider.d.ts +16 -0
  188. package/dist/storage/ontology/provider.d.ts.map +1 -1
  189. package/dist/storage/ontology/provider.js +4 -2
  190. package/dist/storage/ontology/provider.js.map +1 -1
  191. package/dist/storage/ontology/sources.d.ts +13 -4
  192. package/dist/storage/ontology/sources.d.ts.map +1 -1
  193. package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -1
  194. package/dist/storage/projection-runs/provider.js +2 -2
  195. package/dist/storage/projection-runs/types.d.ts +2 -0
  196. package/dist/storage/projection-runs/types.d.ts.map +1 -1
  197. package/dist/syncs/index.js +9 -8
  198. package/dist/syncs/index.js.map +1 -1
  199. package/dist/syncs/run-dispatch.d.ts.map +1 -1
  200. package/dist/testing/broker-contract.d.ts.map +1 -1
  201. package/dist/testing/connector-connection-storage-contract.d.ts.map +1 -1
  202. package/dist/testing/index.d.ts +1 -0
  203. package/dist/testing/index.d.ts.map +1 -1
  204. package/dist/testing/index.js +1499 -963
  205. package/dist/testing/index.js.map +10 -9
  206. package/dist/testing/lake-changes-contract.d.ts +6 -0
  207. package/dist/testing/lake-changes-contract.d.ts.map +1 -0
  208. package/dist/testing/lake-storage-contract.d.ts.map +1 -1
  209. package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
  210. package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
  211. package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
  212. package/dist/webhooks/connections.d.ts +6 -0
  213. package/dist/webhooks/connections.d.ts.map +1 -0
  214. package/dist/webhooks/index.d.ts +1 -1
  215. package/dist/webhooks/index.d.ts.map +1 -1
  216. package/dist/webhooks/internal.d.ts +2 -0
  217. package/dist/webhooks/internal.d.ts.map +1 -1
  218. package/dist/webhooks/internal.js +55 -10
  219. package/dist/webhooks/internal.js.map +4 -3
  220. package/dist/webhooks/registry.d.ts +1 -1
  221. package/dist/webhooks/registry.d.ts.map +1 -1
  222. package/dist/webhooks/types.d.ts +15 -4
  223. package/dist/webhooks/types.d.ts.map +1 -1
  224. package/dist/workflows/index.js +18 -17
  225. package/dist/workflows/index.js.map +1 -1
  226. package/dist/workflows/run-dispatch.d.ts +3 -1
  227. package/dist/workflows/run-dispatch.d.ts.map +1 -1
  228. package/package.json +1 -1
  229. package/src/agents/model-loop.ts +7 -0
  230. package/src/blob-storage/types.ts +4 -1
  231. package/src/broker/in-memory.ts +104 -39
  232. package/src/broker/index.ts +4 -1
  233. package/src/broker/retention.ts +28 -0
  234. package/src/broker/subscriber.ts +21 -0
  235. package/src/broker/types.ts +15 -1
  236. package/src/connectors/builders.ts +0 -6
  237. package/src/connectors/connections/authorizations.ts +11 -5
  238. package/src/connectors/connections/command-context.ts +21 -4
  239. package/src/connectors/connections/contracts.ts +7 -1
  240. package/src/connectors/connections/execution.ts +3 -0
  241. package/src/connectors/connections/request.ts +56 -22
  242. package/src/connectors/connections/runs.ts +39 -1
  243. package/src/connectors/connections/service.ts +6 -0
  244. package/src/connectors/connections/tokens.ts +4 -0
  245. package/src/connectors/connections/validation.ts +91 -5
  246. package/src/connectors/types.ts +19 -4
  247. package/src/events/execution.ts +2 -2
  248. package/src/events/outbox-dispatcher.ts +20 -26
  249. package/src/events/service.ts +3 -3
  250. package/src/index.ts +10 -2
  251. package/src/lake-storage/changes.ts +43 -0
  252. package/src/lake-storage/in-memory.ts +75 -0
  253. package/src/lake-storage/index.ts +4 -0
  254. package/src/lake-storage/types.ts +42 -0
  255. package/src/logging/service.ts +1 -1
  256. package/src/maintenance/ontology-maintenance.ts +6 -2
  257. package/src/maintenance/types.ts +1 -1
  258. package/src/materialization/index.ts +2 -0
  259. package/src/materialization/model.ts +14 -1
  260. package/src/materializer/README.md +1 -1
  261. package/src/materializer/index.ts +2 -0
  262. package/src/materializer/materializer.ts +10 -0
  263. package/src/materializer/projections/entry-validator.ts +19 -1
  264. package/src/materializer/projections/replace.ts +36 -1
  265. package/src/materializer/projections/source-materialization.ts +26 -6
  266. package/src/materializer/shared/normalize.ts +1 -1
  267. package/src/models/definitions.ts +19 -0
  268. package/src/models/pricing.ts +6 -2
  269. package/src/pipelines/run-dispatch.ts +21 -1
  270. package/src/projections/run-dispatch.ts +30 -68
  271. package/src/queues/in-memory.ts +105 -62
  272. package/src/queues/indexed-heap.ts +74 -0
  273. package/src/runtime/host.ts +0 -14
  274. package/src/runtime/ontology-mutations.ts +4 -0
  275. package/src/storage/connector-connections/in-memory.ts +19 -19
  276. package/src/storage/connector-connections/provider/connections.ts +1 -15
  277. package/src/storage/connector-connections/provider/runs.ts +9 -1
  278. package/src/storage/connector-connections/provider/shared.ts +2 -3
  279. package/src/storage/connector-connections/provider.ts +6 -0
  280. package/src/storage/connector-connections/types.ts +8 -3
  281. package/src/storage/index.ts +1 -0
  282. package/src/storage/ontology/in-memory/materializations-state.ts +5 -18
  283. package/src/storage/ontology/in-memory/materializations.ts +73 -92
  284. package/src/storage/ontology/in-memory/shared-state.ts +36 -4
  285. package/src/storage/ontology/in-memory/source-roots.ts +123 -0
  286. package/src/storage/ontology/in-memory/sources.ts +78 -23
  287. package/src/storage/ontology/index.ts +1 -0
  288. package/src/storage/ontology/outbox.ts +1 -0
  289. package/src/storage/ontology/provider.ts +70 -0
  290. package/src/storage/ontology/sources.ts +14 -3
  291. package/src/storage/projection-runs/lifecycle.ts +5 -2
  292. package/src/storage/projection-runs/types.ts +4 -3
  293. package/src/syncs/run-dispatch.ts +19 -1
  294. package/src/testing/broker-contract.ts +95 -0
  295. package/src/testing/connector-connection-storage-contract.ts +29 -12
  296. package/src/testing/index.ts +1 -0
  297. package/src/testing/lake-changes-contract.ts +240 -0
  298. package/src/testing/lake-storage-contract.ts +29 -0
  299. package/src/testing/materializer-storage-contract.ts +172 -1
  300. package/src/testing/ontology-storage-contract.ts +15 -3
  301. package/src/testing/projection-run-storage-contract.ts +34 -0
  302. package/src/webhooks/connections.ts +56 -0
  303. package/src/webhooks/index.ts +2 -0
  304. package/src/webhooks/internal.ts +2 -0
  305. package/src/webhooks/registry.ts +3 -4
  306. package/src/webhooks/types.ts +17 -4
  307. package/src/workflows/run-dispatch.ts +42 -29
  308. package/dist/chunk-0rdrecsb.js.map +0 -11
  309. package/dist/chunk-3f7veca0.js.map +0 -10
  310. package/dist/chunk-3frsnm7x.js.map +0 -11
  311. package/dist/chunk-3tgwrcyh.js.map +0 -14
  312. package/dist/chunk-52hbv0ak.js.map +0 -36
  313. package/dist/chunk-e0d1rzef.js.map +0 -15
  314. package/dist/chunk-emyyk7dx.js.map +0 -14
  315. package/dist/chunk-jjy0fhrn.js.map +0 -12
  316. package/dist/chunk-k3cqkkn2.js.map +0 -12
  317. package/dist/chunk-ppytyr6w.js.map +0 -12
  318. package/dist/chunk-qhcpj9wc.js.map +0 -14
  319. package/dist/chunk-r29fxdhn.js.map +0 -11
  320. package/dist/chunk-zcnq6105.js.map +0 -10
  321. /package/dist/{chunk-ypbtykv6.js.map → chunk-01kj2pbh.js.map} +0 -0
  322. /package/dist/{chunk-xyr8kppc.js.map → chunk-1yefycb1.js.map} +0 -0
  323. /package/dist/{chunk-m3z3x9v0.js.map → chunk-3ckk0xfj.js.map} +0 -0
  324. /package/dist/{chunk-0w35wavj.js.map → chunk-a0e6x5hd.js.map} +0 -0
  325. /package/dist/{chunk-h1gfhhbh.js.map → chunk-d63nnr5b.js.map} +0 -0
  326. /package/dist/{chunk-r4tfx1sf.js.map → chunk-fh8kgex1.js.map} +0 -0
  327. /package/dist/{chunk-vf691g1r.js.map → chunk-sepyxgpc.js.map} +0 -0
  328. /package/dist/{chunk-1enhpacz.js.map → chunk-z0s4axeh.js.map} +0 -0
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-dz5h08xv.js";
13
13
  import {
14
14
  PIPELINE_RUN_FAILURE_CODES2
15
- } from "./chunk-mjbk2djy.js";
15
+ } from "./chunk-gqm76kse.js";
16
16
  import {
17
17
  PipelineRunError2
18
18
  } from "./chunk-mmagke4x.js";
@@ -63,7 +63,10 @@ class PipelineRunDispatcher2 {
63
63
  }
64
64
  async function dispatchPipelineRun(input) {
65
65
  const runId = createPipelineRunId(input.runId);
66
- const persisted = await persistPipelineRun(input, runId);
66
+ let persisted = await persistPipelineRun(input, runId);
67
+ if (!persisted.publish && input.validateExistingRun && persisted.run.status === "queued") {
68
+ persisted = await reusePipelineRun(input, persisted.run);
69
+ }
67
70
  if (!persisted.publish)
68
71
  return existingPipelineRunResult(persisted.run);
69
72
  return publishPipelineRun(input, persisted);
@@ -108,6 +111,15 @@ async function persistPipelineRun(input, runId) {
108
111
  async function reusePipelineRun(input, existing) {
109
112
  assertExistingRunMatchesRequest(existing, input);
110
113
  await input.validateExistingRun?.(existing, input.storage);
114
+ if (input.validateExistingRun && existing.status === "queued") {
115
+ const execution = await input.storage.executions.getById({
116
+ projectId: input.projectId,
117
+ id: existing.executionId
118
+ });
119
+ if (!execution)
120
+ throw new PipelineRunError2(`[Sixb] Execution '${existing.executionId}' was not found.`);
121
+ return { publish: true, run: existing, execution, queuedAt: existing.queuedAt, created: false };
122
+ }
111
123
  if (existing.status !== "failed" || existing.error?.code !== "queue.enqueue_failed" || !existing.error.retryable) {
112
124
  return { publish: false, run: existing };
113
125
  }
@@ -141,6 +153,9 @@ async function publishPipelineRun(input, persisted) {
141
153
  }
142
154
  ]
143
155
  });
156
+ if (!job || job.id !== persisted.run.id) {
157
+ throw new PipelineRunError2(`[Sixb] Queue did not acknowledge Pipeline run '${persisted.run.id}'.`);
158
+ }
144
159
  return {
145
160
  pipelineId: persisted.run.pipelineId,
146
161
  runId: persisted.run.id,
@@ -149,6 +164,8 @@ async function publishPipelineRun(input, persisted) {
149
164
  created: persisted.created
150
165
  };
151
166
  } catch (error) {
167
+ if (input.validateExistingRun)
168
+ throw error;
152
169
  const failedAt = new Date;
153
170
  const failure = toEnqueueFailure(error, persisted.run, failedAt);
154
171
  const failed = await requirePipelineRunStorage(input.storage).finish({
@@ -254,4 +271,4 @@ async function requestPipelineRun2(runtime, execution, pipeline, options = {}) {
254
271
 
255
272
  export { PipelineError2, PipelineRunDispatcher2, requestPipelineRun2 };
256
273
 
257
- //# debugId=C687324B500486F164756E2164756E21
274
+ //# debugId=5A812F362A35F07864756E2164756E21
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/pipelines/errors.ts", "../src/pipelines/run-dispatch.ts", "../src/pipelines/request.ts"],
4
+ "sourcesContent": [
5
+ "export class PipelineError extends Error {\n readonly name = \"PipelineError\"\n}\n",
6
+ "import { randomUUID } from \"node:crypto\"\nimport { reportRunFailure } from \"../error-reporting/capability\"\nimport { createSixbError, toSixbFailure } from \"../errors/internal\"\nimport type { SixbFailure } from \"../errors/types\"\nimport type { RunDispatcher } from \"../execution/dispatch\"\nimport { createPrimitiveExecutionRecord } from \"../execution/durable\"\nimport type { Queues } from \"../queues\"\nimport type { SixbDefinitions } from \"../runtime/definitions\"\nimport type {\n CreateExecutionInput,\n PipelineRunFailureCode,\n PipelineRunRecord,\n Storage,\n} from \"../storage\"\nimport { PIPELINE_RUN_FAILURE_CODES, PipelineRunError } from \"../storage\"\nimport { PipelineError } from \"./errors\"\nimport type { PipelineRunRequestOptions, PipelineRunRequestResult } from \"./request\"\nimport type { PipelineDefinition } from \"./types\"\n\nexport type AutomaticPipelineExecutionSource =\n | { readonly type: \"schedule\"; readonly eventId: string }\n | { readonly type: \"event\"; readonly eventId: string }\n\nexport interface AutomaticPipelineRunDispatchInput extends PipelineRunRequestOptions {\n readonly pipelineId: string\n readonly runId: string\n readonly source: AutomaticPipelineExecutionSource\n readonly correlationId: string\n readonly metadata?: Readonly<Record<string, string>>\n}\n\nexport type PipelineRunDispatchPort = RunDispatcher<\n AutomaticPipelineRunDispatchInput,\n PipelineRunRequestResult\n>\n\nexport interface PipelineRunDispatcherDependencies {\n readonly id: string\n readonly definitions: Pick<SixbDefinitions, \"pipelines\">\n readonly storage: Storage\n readonly queues: Pick<Queues, \"pipelines\">\n}\n\ninterface DispatchPipelineRunInput extends PipelineRunRequestOptions {\n readonly errorReporterHost: object\n readonly projectId: string\n readonly pipeline: PipelineDefinition\n readonly storage: Storage\n readonly queue: Queues[\"pipelines\"]\n readonly metadata?: Readonly<Record<string, string>>\n readonly createExecution: (executionId: string, runId: string) => Promise<CreateExecutionInput>\n readonly validateExistingRun?: (run: PipelineRunRecord, storage: Storage) => Promise<void>\n}\n\ntype PersistedPipelineRun =\n | { readonly publish: false; readonly run: PipelineRunRecord }\n | {\n readonly publish: true\n readonly run: PipelineRunRecord\n readonly execution: CreateExecutionInput\n readonly queuedAt: Date\n readonly created: boolean\n }\n\n/** Core-owned durable dispatch boundary used by automatic Pipeline triggers. */\nexport class PipelineRunDispatcher implements PipelineRunDispatchPort {\n constructor(private readonly dependencies: PipelineRunDispatcherDependencies) {}\n\n async dispatch(input: AutomaticPipelineRunDispatchInput): Promise<PipelineRunRequestResult> {\n assertAutomaticDispatchInput(input)\n const pipeline = this.dependencies.definitions.pipelines.getById(input.pipelineId)\n if (!pipeline) throw new PipelineError(`[Sixb] Unknown pipeline '${input.pipelineId}'`)\n\n return dispatchPipelineRun({\n errorReporterHost: this.dependencies,\n projectId: this.dependencies.id,\n pipeline,\n storage: this.dependencies.storage,\n queue: this.dependencies.queues.pipelines,\n runId: input.runId,\n metadata: input.metadata,\n validateExistingRun: (run, storage) =>\n assertAutomaticExecutionIdentity(storage, this.dependencies.id, input, run),\n createExecution: async (executionId, runId) =>\n createPrimitiveExecutionRecord({\n id: executionId,\n primitive: { kind: \"pipeline\", id: pipeline.id, runId },\n origin: {\n type: \"automatic\",\n projectId: this.dependencies.id,\n source: input.source,\n correlationId: input.correlationId,\n },\n }),\n })\n }\n}\n\n/** Persist a Pipeline execution and queued run before publishing its queue job. */\nexport async function dispatchPipelineRun(\n input: DispatchPipelineRunInput\n): Promise<PipelineRunRequestResult> {\n const runId = createPipelineRunId(input.runId)\n let persisted = await persistPipelineRun(input, runId)\n if (!persisted.publish && input.validateExistingRun && persisted.run.status === \"queued\") {\n persisted = await reusePipelineRun(input, persisted.run)\n }\n if (!persisted.publish) return existingPipelineRunResult(persisted.run)\n return publishPipelineRun(input, persisted)\n}\n\nasync function persistPipelineRun(\n input: DispatchPipelineRunInput,\n runId: string\n): Promise<PersistedPipelineRun> {\n const pipelineRuns = requirePipelineRunStorage(input.storage)\n const existing = await pipelineRuns.getById({ projectId: input.projectId, id: runId })\n if (existing) return reusePipelineRun(input, existing)\n\n const execution = await input.createExecution(`exec_${randomUUID()}`, runId)\n const queuedAt = new Date()\n try {\n return await input.storage.transaction(\n async (tx): Promise<PersistedPipelineRun> => {\n const transactionalRuns = requirePipelineRunStorage(tx)\n const raced = await transactionalRuns.getById({ projectId: input.projectId, id: runId })\n if (raced) {\n assertExistingRunMatchesRequest(raced, input)\n await input.validateExistingRun?.(raced, tx)\n return { publish: false, run: raced }\n }\n\n await tx.executions.create(execution)\n const run = await transactionalRuns.queue({\n projectId: input.projectId,\n id: runId,\n executionId: execution.id,\n pipelineId: input.pipeline.id,\n queuedAt,\n })\n return { publish: true, run, execution, queuedAt, created: true }\n },\n { isolation: \"serializable\" }\n )\n } catch (error) {\n if (!(error instanceof PipelineRunError)) throw error\n const raced = await pipelineRuns.getById({ projectId: input.projectId, id: runId })\n if (!raced) throw error\n assertExistingRunMatchesRequest(raced, input)\n await input.validateExistingRun?.(raced, input.storage)\n return { publish: false, run: raced }\n }\n}\n\nasync function reusePipelineRun(\n input: DispatchPipelineRunInput,\n existing: PipelineRunRecord\n): Promise<PersistedPipelineRun> {\n assertExistingRunMatchesRequest(existing, input)\n await input.validateExistingRun?.(existing, input.storage)\n if (input.validateExistingRun && existing.status === \"queued\") {\n const execution = await input.storage.executions.getById({\n projectId: input.projectId,\n id: existing.executionId,\n })\n if (!execution)\n throw new PipelineRunError(`[Sixb] Execution '${existing.executionId}' was not found.`)\n return { publish: true, run: existing, execution, queuedAt: existing.queuedAt, created: false }\n }\n if (\n existing.status !== \"failed\" ||\n existing.error?.code !== \"queue.enqueue_failed\" ||\n !existing.error.retryable\n ) {\n return { publish: false, run: existing }\n }\n\n const execution = await input.storage.executions.getById({\n projectId: input.projectId,\n id: existing.executionId,\n })\n if (!execution) {\n throw new PipelineRunError(\n `[Sixb] Execution '${existing.executionId}' for Pipeline run '${existing.id}' was not found.`\n )\n }\n\n const queuedAt = new Date()\n const run = await requirePipelineRunStorage(input.storage).queue({\n projectId: input.projectId,\n id: existing.id,\n executionId: existing.executionId,\n pipelineId: existing.pipelineId,\n queuedAt,\n })\n return { publish: true, run, execution, queuedAt, created: false }\n}\n\nasync function publishPipelineRun(\n input: DispatchPipelineRunInput,\n persisted: Extract<PersistedPipelineRun, { readonly publish: true }>\n): Promise<PipelineRunRequestResult> {\n try {\n const [job] = await input.queue.enqueue({\n projectId: input.projectId,\n jobs: [\n {\n id: persisted.run.id,\n type: \"pipeline.run.requested\",\n payload: { runId: persisted.run.id },\n ...(input.metadata === undefined ? {} : { metadata: input.metadata }),\n },\n ],\n })\n if (!job || job.id !== persisted.run.id) {\n throw new PipelineRunError(\n `[Sixb] Queue did not acknowledge Pipeline run '${persisted.run.id}'.`\n )\n }\n return {\n pipelineId: persisted.run.pipelineId,\n runId: persisted.run.id,\n queuedAt: persisted.queuedAt.toISOString(),\n ...(job?.id ? { jobId: job.id } : {}),\n created: persisted.created,\n }\n } catch (error) {\n // Automatic consumers retain the batch and retry. Keep uncertain delivery queued:\n // a lost reply does not prove that the queue rejected the job.\n if (input.validateExistingRun) throw error\n const failedAt = new Date()\n const failure = toEnqueueFailure(error, persisted.run, failedAt)\n const failed = await requirePipelineRunStorage(input.storage).finish({\n projectId: input.projectId,\n id: persisted.run.id,\n status: \"failed\",\n finishedAt: failedAt,\n error: failure,\n })\n reportRunFailure(input.errorReporterHost, error, {\n projectId: input.projectId,\n runKind: \"pipeline\",\n run: { runId: failed.id, pipelineId: failed.pipelineId },\n failure,\n })\n throw error\n }\n}\n\nfunction assertExistingRunMatchesRequest(\n existing: PipelineRunRecord,\n input: Pick<DispatchPipelineRunInput, \"pipeline\">\n): void {\n if (existing.pipelineId !== input.pipeline.id) {\n throw new PipelineRunError(\n `[Sixb] Pipeline run '${existing.id}' already exists with a different request payload.`\n )\n }\n}\n\nfunction existingPipelineRunResult(existing: PipelineRunRecord): PipelineRunRequestResult {\n return {\n pipelineId: existing.pipelineId,\n runId: existing.id,\n queuedAt: existing.queuedAt.toISOString(),\n created: false,\n }\n}\n\nfunction requirePipelineRunStorage(storage: Storage): NonNullable<Storage[\"pipelineRuns\"]> {\n if (!storage.pipelineRuns) {\n throw new PipelineError(\"[Sixb] Pipeline run storage is not configured.\")\n }\n return storage.pipelineRuns\n}\n\nfunction createPipelineRunId(runId: string | undefined): string {\n if (runId === undefined) return `run_${randomUUID()}`\n if (!runId.trim()) throw new PipelineError(\"[Sixb] Pipeline run id must not be empty\")\n return runId\n}\n\nfunction assertAutomaticDispatchInput(input: AutomaticPipelineRunDispatchInput): void {\n assertNonBlank(input.pipelineId, \"Pipeline id\")\n assertNonBlank(input.runId, \"Pipeline run id\")\n assertNonBlank(input.source.eventId, \"Pipeline source event id\")\n assertNonBlank(input.correlationId, \"Pipeline correlation id\")\n}\n\nasync function assertAutomaticExecutionIdentity(\n storage: Storage,\n projectId: string,\n input: AutomaticPipelineRunDispatchInput,\n run: PipelineRunRecord\n): Promise<void> {\n const execution = await storage.executions.getById({ projectId, id: run.executionId })\n if (\n !execution ||\n execution.source.type !== input.source.type ||\n execution.source.eventId !== input.source.eventId ||\n execution.correlationId !== input.correlationId ||\n execution.requestedBy !== undefined\n ) {\n throw new PipelineError(\n `[Sixb] Pipeline run '${run.id}' already exists with different automatic provenance.`\n )\n }\n}\n\nfunction toEnqueueFailure(\n error: unknown,\n run: PipelineRunRecord,\n at: Date\n): SixbFailure<PipelineRunFailureCode> {\n const enqueueError = createSixbError(\n \"queue.enqueue_failed\",\n `[Sixb] Could not enqueue Pipeline run '${run.id}'.`,\n {\n cause: error,\n details: { pipelineId: run.pipelineId, runId: run.id, phase: \"enqueue\" },\n }\n )\n return toSixbFailure(enqueueError, { allowedCodes: PIPELINE_RUN_FAILURE_CODES, at })\n}\n\nfunction assertNonBlank(value: string, label: string): void {\n if (!value.trim()) throw new PipelineError(`[Sixb] ${label} must not be empty.`)\n}\n",
7
+ "import { assertAuthorized } from \"../authorization\"\nimport { resolveExecutionScopeAuthorization } from \"../execution/authorization\"\nimport {\n createPrimitiveExecutionRecord,\n ensureExecutionRecord,\n executionRecordInputFromRuntime,\n} from \"../execution/durable\"\nimport type { ExecutionContext } from \"../execution/types\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport { PipelineError } from \"./errors\"\nimport { dispatchPipelineRun } from \"./run-dispatch\"\nimport type { PipelineDefinition } from \"./types\"\n\nexport interface PipelineRunRequestOptions {\n /** Stable identity used to make dispatch idempotent. */\n readonly runId?: string\n}\n\nexport interface RequestPipelineRunInput extends PipelineRunRequestOptions {\n readonly pipelineId: string\n}\n\nexport interface PipelineRunRequestResult {\n readonly pipelineId: string\n readonly runId: string\n /** Durable time at which the run entered the queue. */\n readonly queuedAt: string\n readonly jobId?: string\n readonly created: boolean\n}\n\n/**\n * Authorize and queue a pipeline run request.\n *\n * Operates on an already-resolved definition and the shared runtime context, so the HTTP route and\n * the runtime verb cannot drift apart.\n *\n * The immutable child execution and queued run are persisted before queue publication.\n */\nexport async function requestPipelineRun(\n runtime: SixbRuntimeContext,\n execution: ExecutionContext,\n pipeline: PipelineDefinition,\n options: PipelineRunRequestOptions = {}\n): Promise<PipelineRunRequestResult> {\n resolveExecutionScopeAuthorization(runtime.projectId, {\n execution,\n authorization: runtime.runtimeAuthorization,\n })\n assertAuthorized(runtime, { kind: \"pipeline.run\", pipelineId: pipeline.id })\n if (!runtime.storage.pipelineRuns) {\n throw new PipelineError(\"[Sixb] Pipeline run storage is not configured.\")\n }\n\n const queue = runtime.queues.pipelines\n if (!queue) {\n throw new PipelineError(\"[Sixb] Pipeline run queue is not configured.\")\n }\n\n return dispatchPipelineRun({\n errorReporterHost: runtime,\n projectId: runtime.projectId,\n pipeline,\n storage: runtime.storage,\n queue,\n ...options,\n createExecution: async (executionId, runId) => {\n const caller = await ensureExecutionRecord(\n runtime.storage.executions,\n executionRecordInputFromRuntime({\n execution,\n runtimeAuthorization: runtime.runtimeAuthorization,\n })\n )\n return createPrimitiveExecutionRecord({\n id: executionId,\n primitive: { kind: \"pipeline\", id: pipeline.id, runId },\n origin: { type: \"execution\", parent: caller },\n })\n },\n })\n}\n"
8
+ ],
9
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,uBAAsB,MAAM;AAAA,EAC9B,OAAO;AAClB;;;ACFA;AAiEO,MAAM,uBAAyD;AAAA,EACvC;AAAA,EAA7B,WAAW,CAAkB,cAAiD;AAAA,IAAjD;AAAA;AAAA,OAEvB,SAAQ,CAAC,OAA6E;AAAA,IAC1F,6BAA6B,KAAK;AAAA,IAClC,MAAM,WAAW,KAAK,aAAa,YAAY,UAAU,QAAQ,MAAM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
+ }
@@ -47,7 +47,7 @@ import {
47
47
  StructuredOutputError2,
48
48
  estimateModelCall,
49
49
  rateModelCall2
50
- } from "./chunk-e0d1rzef.js";
50
+ } from "./chunk-jsy70480.js";
51
51
  import {
52
52
  AgentStorageError2,
53
53
  AGENT_REASONING_LEVELS2
@@ -60,7 +60,7 @@ import {
60
60
  } from "./chunk-93csa55g.js";
61
61
  import {
62
62
  WORKFLOW_RUN_FAILURE_CODES2
63
- } from "./chunk-mjbk2djy.js";
63
+ } from "./chunk-gqm76kse.js";
64
64
  import {
65
65
  WorkflowRunError2
66
66
  } from "./chunk-pr2h4bv4.js";
@@ -70,7 +70,7 @@ import {
70
70
  canDelegationAccessActionRun,
71
71
  requestAction3,
72
72
  requestActionAndWait2
73
- } from "./chunk-ypbtykv6.js";
73
+ } from "./chunk-01kj2pbh.js";
74
74
  import {
75
75
  shareSixbErrorReporter2,
76
76
  reportRunFailure2
@@ -92,19 +92,21 @@ import {
92
92
  registerConnectorConnectionsRuntime
93
93
  } from "./chunk-5a4a52tq.js";
94
94
  import {
95
- createConnectorRuntime,
96
- SyncValidationError2,
97
- requestSyncRun2
98
- } from "./chunk-emyyk7dx.js";
95
+ createConnectorRuntime
96
+ } from "./chunk-v2vcg0w6.js";
99
97
  import {
100
98
  writeDataset2
101
99
  } from "./chunk-mrp7k0pw.js";
102
100
  import {
103
101
  shareOntologyMutationRuntime2
104
- } from "./chunk-zcnq6105.js";
102
+ } from "./chunk-85cd7e8c.js";
105
103
  import {
106
104
  compileShareAccessPlan
107
105
  } from "./chunk-awbhdqyc.js";
106
+ import {
107
+ SyncValidationError2,
108
+ requestSyncRun2
109
+ } from "./chunk-cfvakeax.js";
108
110
  import {
109
111
  getTelemetryHistoryBatch2,
110
112
  getLatestTelemetryPoint,
@@ -116,14 +118,14 @@ import {
116
118
  upsertObject3,
117
119
  upsertObjectBatch3,
118
120
  appendTelemetry
119
- } from "./chunk-1enhpacz.js";
121
+ } from "./chunk-z0s4axeh.js";
120
122
  import {
121
123
  schemaRecordToJsonSchema2
122
124
  } from "./chunk-7zgecwy1.js";
123
125
  import {
124
126
  PipelineError2,
125
127
  requestPipelineRun2
126
- } from "./chunk-jjy0fhrn.js";
128
+ } from "./chunk-g91qxjj0.js";
127
129
  import {
128
130
  requireAccountingCapabilities,
129
131
  aiModelCallOutputTokenAllowance,
@@ -131,7 +133,7 @@ import {
131
133
  AiModelCallRecorder2,
132
134
  enqueueAiModelCallRecovery2,
133
135
  resolveLanguageModel2
134
- } from "./chunk-h1gfhhbh.js";
136
+ } from "./chunk-d63nnr5b.js";
135
137
  import {
136
138
  getDatasetPrimaryKeyColumns2
137
139
  } from "./chunk-9qsh3p5y.js";
@@ -1003,6 +1005,7 @@ function createConnectorConnectionsRuntime(runtime, execution, process) {
1003
1005
  listConnections: (connectorId) => process.listConnections(contextFor(connectorId), connectorId),
1004
1006
  startConnectionRun: (connectorId, input) => process.startConnectionRun(contextFor(connectorId), connectorId, input),
1005
1007
  addConnection: (connectorId, input) => process.addConnection(contextFor(connectorId), connectorId, input),
1008
+ listPendingConnectionRuns: (connectorId) => process.listPendingConnectionRuns(contextFor(connectorId), connectorId),
1006
1009
  getConnectionRun: (connectorId, runId) => process.getConnectionRun(contextFor(connectorId), connectorId, runId),
1007
1010
  selectConnectionRunAccount: (connectorId, input) => process.selectConnectionRunAccount(contextFor(connectorId), connectorId, input),
1008
1011
  startReauthorization: (connectorId, connectionId, input) => process.startReauthorization(contextFor(connectorId), connectorId, connectionId, input),
@@ -1160,7 +1163,7 @@ function createEventsRuntime(runtime) {
1160
1163
  return runtime.events.subscribe(input, (events) => {
1161
1164
  const visible = visibleEvents(events);
1162
1165
  if (visible.length > 0)
1163
- handler(visible);
1166
+ return handler(visible);
1164
1167
  });
1165
1168
  }
1166
1169
  };
@@ -1305,6 +1308,9 @@ async function runModelLoop2(input) {
1305
1308
  return { status: "aborted", steps, partialContent: response.content };
1306
1309
  }
1307
1310
  const localCalls = response.toolCalls.filter((call) => call.part.providerExecuted !== true);
1311
+ if (localCalls.length > 0 && !["stop", "tool-calls", "pause"].includes(response.finishReason)) {
1312
+ throw new ModelStreamError2(`[SixbModels] Cannot execute local tools after '${response.finishReason}'.`);
1313
+ }
1308
1314
  if (input.rejectLocalToolCalls && (localCalls.length > 0 || response.finishReason === "tool-calls")) {
1309
1315
  throw new ModelStreamError2("[SixbModels] Direct generation cannot continue local tool calls.");
1310
1316
  }
@@ -3397,7 +3403,7 @@ class WorkflowRunDispatcher2 {
3397
3403
  if (!workflow) {
3398
3404
  throw new WorkflowValidationError2(`[Sixb] Unknown workflow '${input.workflowId}'`);
3399
3405
  }
3400
- const result = await dispatchWorkflowRun({
3406
+ return dispatchWorkflowRun({
3401
3407
  errorReporterHost: this.dependencies,
3402
3408
  projectId: this.dependencies.id,
3403
3409
  workflow,
@@ -3415,6 +3421,7 @@ class WorkflowRunDispatcher2 {
3415
3421
  },
3416
3422
  metadata: input.metadata,
3417
3423
  queueJobId: input.runId,
3424
+ validateExistingRun: (run) => assertAutomaticExecutionIdentity(this.dependencies, input, run),
3418
3425
  createExecution: async (executionId, runId) => createPrimitiveExecutionRecord({
3419
3426
  id: executionId,
3420
3427
  primitive: { kind: "workflow", id: workflow.id, runId },
@@ -3426,17 +3433,18 @@ class WorkflowRunDispatcher2 {
3426
3433
  }
3427
3434
  })
3428
3435
  });
3429
- if (!result.created) {
3430
- await assertAutomaticExecutionIdentity(this.dependencies, input, result.runId);
3431
- }
3432
- return result;
3433
3436
  }
3434
3437
  }
3435
3438
  async function dispatchWorkflowRun(input) {
3436
3439
  const request = prepareWorkflowRun(input);
3437
3440
  const persisted = await persistWorkflowRun(input, request);
3438
- if (!persisted.created)
3441
+ if (!persisted.created) {
3442
+ await input.validateExistingRun?.(persisted.run);
3443
+ if (input.validateExistingRun && persisted.run.status === "queued") {
3444
+ await enqueueWorkflowRun(input, persisted.run);
3445
+ }
3439
3446
  return existingWorkflowRunResult(persisted.run);
3447
+ }
3440
3448
  return publishWorkflowRun(input, persisted);
3441
3449
  }
3442
3450
  function prepareWorkflowRun(input) {
@@ -3505,20 +3513,10 @@ async function persistWorkflowRun(input, request) {
3505
3513
  async function publishWorkflowRun(input, persisted) {
3506
3514
  let job;
3507
3515
  try {
3508
- const jobs = await input.queue.enqueue({
3509
- projectId: input.projectId,
3510
- jobs: [
3511
- {
3512
- ...input.queueJobId === undefined ? {} : { id: input.queueJobId },
3513
- type: "workflow.run.requested",
3514
- payload: { runId: persisted.run.id },
3515
- ...input.metadata === undefined ? {} : { metadata: input.metadata }
3516
- }
3517
- ]
3518
- });
3519
- job = jobs[0];
3516
+ job = await enqueueWorkflowRun(input, persisted.run);
3520
3517
  } catch (error) {
3521
- await failWorkflowRunPublication(input, persisted.run, error);
3518
+ if (!input.validateExistingRun)
3519
+ await failWorkflowRunPublication(input, persisted.run, error);
3522
3520
  throw error;
3523
3521
  }
3524
3522
  await input.events.emit({
@@ -3544,6 +3542,23 @@ async function publishWorkflowRun(input, persisted) {
3544
3542
  created: true
3545
3543
  };
3546
3544
  }
3545
+ async function enqueueWorkflowRun(input, run) {
3546
+ const [job] = await input.queue.enqueue({
3547
+ projectId: input.projectId,
3548
+ jobs: [
3549
+ {
3550
+ ...input.queueJobId === undefined ? {} : { id: input.queueJobId },
3551
+ type: "workflow.run.requested",
3552
+ payload: { runId: run.id },
3553
+ ...input.metadata === undefined ? {} : { metadata: input.metadata }
3554
+ }
3555
+ ]
3556
+ });
3557
+ if (!job || input.queueJobId !== undefined && job.id !== input.queueJobId) {
3558
+ throw new WorkflowRunError2(`[Sixb] Queue did not acknowledge workflow run '${run.id}'.`);
3559
+ }
3560
+ return job;
3561
+ }
3547
3562
  async function failWorkflowRunPublication(input, run, error) {
3548
3563
  const workflowRuns = input.storage.workflowRuns;
3549
3564
  if (!workflowRuns) {
@@ -3595,17 +3610,13 @@ function assertAutomaticDispatchInput(input) {
3595
3610
  assertNonBlank(input.source.eventId, "Workflow source event id");
3596
3611
  assertNonBlank(input.correlationId, "Workflow correlation id");
3597
3612
  }
3598
- async function assertAutomaticExecutionIdentity(dependencies, input, runId) {
3599
- const run = await dependencies.storage.workflowRuns?.getById({
3600
- projectId: dependencies.id,
3601
- id: runId
3602
- });
3603
- const execution = run ? await dependencies.storage.executions.getById({
3613
+ async function assertAutomaticExecutionIdentity(dependencies, input, run) {
3614
+ const execution = await dependencies.storage.executions.getById({
3604
3615
  projectId: dependencies.id,
3605
3616
  id: run.executionId
3606
- }) : null;
3617
+ });
3607
3618
  if (!execution || execution.source.type !== input.source.type || execution.source.eventId !== input.source.eventId || execution.correlationId !== input.correlationId || execution.requestedBy !== undefined) {
3608
- throw new WorkflowValidationError2(`[Sixb] Workflow run '${runId}' already exists with different automatic provenance.`);
3619
+ throw new WorkflowValidationError2(`[Sixb] Workflow run '${run.id}' already exists with different automatic provenance.`);
3609
3620
  }
3610
3621
  }
3611
3622
  function assertNonBlank(value, label) {
@@ -4003,4 +4014,4 @@ function invalidAgentExecution(executionId, runId) {
4003
4014
 
4004
4015
  export { resolveAgentContextParts2, agentRunQueueJobId2, subagentRunQueueJobId2, workflowAgentNodeQueueJobId2, dispatchQueuedAgentRuns2, dispatchQueuedSubagentRuns2, createAgentThreadId2, createAgentRunId2, createSubagentRunId2, createSubagentExecutionId2, createAgentMessageId2, agentContextCheckpointId2, createAgentRunExecutionToken2, runModelLoop2, assertNoAgentDefinitions, bindModelExecutionAttempt, ShareError2, WorkflowDefinitionError2, WorkflowValidationError2, assertNonEmpty, isStepDefinition2, isAgentStepDefinition2, isInterventionDefinition2, isWorkflowDefinition2, validateWorkflowDefinition2, validateWorkflowsAtStartup2, validateWorkflowAgentStepGroupReferences2, validateWorkflowInput2, validateWorkflowStepInput2, validateWorkflowStepOutput2, validateWorkflowInterventionInput2, validateWorkflowInterventionResponse2, validateWorkflowInterventionDefaultResponse2, validateWorkflowAgentStepInput2, validateWorkflowAgentStepOutput2, snapshotWorkflowAgentStepInput2, snapshotWorkflowAgentStepOutput2, snapshotWorkflowInput2, snapshotWorkflowStepInput2, snapshotWorkflowStepOutput2, snapshotWorkflowInterventionInput2, snapshotWorkflowInterventionResponse2, snapshotWorkflowInterventionDefaultResponse2, snapshotWorkflowActionInput2, WorkflowRunDispatcher2, requestWorkflowRun2, createBoundSixb, isBoundSixb, canInheritAgentRequestAuthorization2, createAgentExecutionRecord2, createInheritedAgentExecutionRecord2, bindDurableAgentExecution2, restoreAgentExecutionScope2, assertAgentExecutionRecord2, requestAgentRun2, retryAgentRun2 };
4005
4016
 
4006
- //# debugId=8A992C0F00F3BAC264756E2164756E21
4017
+ //# debugId=F73579E689A4184364756E2164756E21