@sixb/core 0.1.12 → 0.1.14

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 (538) hide show
  1. package/dist/actions/index.d.ts +2 -2
  2. package/dist/actions/index.d.ts.map +1 -1
  3. package/dist/actions/index.js +28 -26
  4. package/dist/actions/index.js.map +1 -1
  5. package/dist/actions/read-facade.d.ts +14 -16
  6. package/dist/actions/read-facade.d.ts.map +1 -1
  7. package/dist/actions/request.d.ts.map +1 -1
  8. package/dist/actions/run-dispatch.d.ts +2 -0
  9. package/dist/actions/run-dispatch.d.ts.map +1 -1
  10. package/dist/actions/types/context.d.ts +18 -31
  11. package/dist/actions/types/context.d.ts.map +1 -1
  12. package/dist/actions/types/params.d.ts +2 -1
  13. package/dist/actions/types/params.d.ts.map +1 -1
  14. package/dist/actions/worker.js +1 -1
  15. package/dist/agents/index.js +41 -39
  16. package/dist/agents/index.js.map +1 -1
  17. package/dist/agents/streams/index.js +2 -2
  18. package/dist/agents/streams/internal.js +2 -2
  19. package/dist/assert-never.d.ts +6 -0
  20. package/dist/assert-never.d.ts.map +1 -0
  21. package/dist/auth/client-address.d.ts +3 -0
  22. package/dist/auth/client-address.d.ts.map +1 -0
  23. package/dist/auth/csrf.d.ts +5 -1
  24. package/dist/auth/csrf.d.ts.map +1 -1
  25. package/dist/auth/errors.d.ts +12 -0
  26. package/dist/auth/errors.d.ts.map +1 -1
  27. package/dist/auth/index.d.ts +4 -3
  28. package/dist/auth/index.d.ts.map +1 -1
  29. package/dist/auth/index.js +16 -8
  30. package/dist/auth/index.js.map +1 -1
  31. package/dist/auth/runtime.d.ts +58 -41
  32. package/dist/auth/runtime.d.ts.map +1 -1
  33. package/dist/auth/session-cache.d.ts +10 -3
  34. package/dist/auth/session-cache.d.ts.map +1 -1
  35. package/dist/auth/sessions.d.ts +12 -0
  36. package/dist/auth/sessions.d.ts.map +1 -1
  37. package/dist/auth/strategy.d.ts +2 -0
  38. package/dist/auth/strategy.d.ts.map +1 -1
  39. package/dist/auth/strategy.js +4 -2
  40. package/dist/auth/strategy.js.map +1 -1
  41. package/dist/auth/types.d.ts +16 -15
  42. package/dist/auth/types.d.ts.map +1 -1
  43. package/dist/authorization/index.js +3 -3
  44. package/dist/bootstrap/index.d.ts +1 -1
  45. package/dist/bootstrap/index.d.ts.map +1 -1
  46. package/dist/bootstrap/index.js +45 -43
  47. package/dist/bootstrap/index.js.map +1 -1
  48. package/dist/bootstrap/ontology-type-manifest.d.ts +8 -0
  49. package/dist/bootstrap/ontology-type-manifest.d.ts.map +1 -1
  50. package/dist/{chunk-m7cx05vp.js → chunk-00pfcqh4.js} +126 -59
  51. package/dist/{chunk-m7cx05vp.js.map → chunk-00pfcqh4.js.map} +13 -12
  52. package/dist/{chunk-nzsy3xrp.js → chunk-16jenmzw.js} +69 -44
  53. package/dist/{chunk-nzsy3xrp.js.map → chunk-16jenmzw.js.map} +7 -7
  54. package/dist/{chunk-y3ev53cq.js → chunk-2fv8sajb.js} +2 -2
  55. package/dist/{chunk-q5gz3g2j.js → chunk-2jntasmh.js} +13 -16
  56. package/dist/{chunk-q5gz3g2j.js.map → chunk-2jntasmh.js.map} +3 -3
  57. package/dist/chunk-3a338wrp.js +191 -0
  58. package/dist/chunk-3a338wrp.js.map +11 -0
  59. package/dist/{chunk-ybhz3j9g.js → chunk-3fpgxpsq.js} +104 -148
  60. package/dist/{chunk-ybhz3j9g.js.map → chunk-3fpgxpsq.js.map} +7 -8
  61. package/dist/{chunk-eyjzgav0.js → chunk-3nx8vj5a.js} +6 -4
  62. package/dist/chunk-3nx8vj5a.js.map +12 -0
  63. package/dist/{chunk-5tetw4hn.js → chunk-4tnrzqqh.js} +1 -1
  64. package/dist/{chunk-3ghw2t5q.js → chunk-4ypbe95r.js} +10 -16
  65. package/dist/chunk-4ypbe95r.js.map +10 -0
  66. package/dist/{chunk-2cxv584m.js → chunk-6rzb1g6h.js} +358 -248
  67. package/dist/chunk-6rzb1g6h.js.map +44 -0
  68. package/dist/{chunk-7zgecwy1.js → chunk-6x0pqh32.js} +12 -1
  69. package/dist/{chunk-7zgecwy1.js.map → chunk-6x0pqh32.js.map} +3 -3
  70. package/dist/{chunk-6ma8dvzc.js → chunk-728fp090.js} +49 -42
  71. package/dist/chunk-728fp090.js.map +15 -0
  72. package/dist/chunk-96yw3pwd.js.map +2 -2
  73. package/dist/{chunk-4k53sm9e.js → chunk-a0073121.js} +59 -59
  74. package/dist/{chunk-4k53sm9e.js.map → chunk-a0073121.js.map} +5 -5
  75. package/dist/{chunk-y1ahv8b7.js → chunk-bdhfn0ww.js} +1 -1
  76. package/dist/{chunk-kept9cdd.js → chunk-bxx3ms5t.js} +1 -1
  77. package/dist/{chunk-xtfryrfb.js → chunk-cbn96bve.js} +2 -2
  78. package/dist/{chunk-vsg0g7h9.js → chunk-d8yes9yx.js} +304 -45
  79. package/dist/chunk-d8yes9yx.js.map +20 -0
  80. package/dist/{chunk-vpxss818.js → chunk-drz59ve0.js} +9 -8
  81. package/dist/chunk-drz59ve0.js.map +10 -0
  82. package/dist/{chunk-7c2g3sz9.js → chunk-dsfw1bdr.js} +5 -5
  83. package/dist/{chunk-7c2g3sz9.js.map → chunk-dsfw1bdr.js.map} +1 -1
  84. package/dist/{chunk-qm535afa.js → chunk-dv4ct8mp.js} +66 -24
  85. package/dist/chunk-dv4ct8mp.js.map +15 -0
  86. package/dist/{chunk-t7dzd1tm.js → chunk-e2c5yxfe.js} +2 -2
  87. package/dist/{chunk-p6r1ex7t.js → chunk-ffwvdgk1.js} +5 -13
  88. package/dist/chunk-ffwvdgk1.js.map +10 -0
  89. package/dist/{chunk-tg4g4zh0.js → chunk-gct3m1da.js} +9 -9
  90. package/dist/{chunk-tg4g4zh0.js.map → chunk-gct3m1da.js.map} +3 -3
  91. package/dist/chunk-h89wz928.js +42 -0
  92. package/dist/chunk-h89wz928.js.map +10 -0
  93. package/dist/{chunk-b768c93y.js → chunk-hj0n3c2p.js} +83 -28
  94. package/dist/{chunk-b768c93y.js.map → chunk-hj0n3c2p.js.map} +5 -5
  95. package/dist/{chunk-hkw8rykk.js → chunk-ht4a7mjg.js} +74 -4
  96. package/dist/chunk-ht4a7mjg.js.map +15 -0
  97. package/dist/{chunk-7qnvhtcd.js → chunk-hxgj4kzd.js} +17 -17
  98. package/dist/{chunk-7qnvhtcd.js.map → chunk-hxgj4kzd.js.map} +5 -5
  99. package/dist/{chunk-bg2bs62d.js → chunk-jfdggg1p.js} +5 -5
  100. package/dist/{chunk-f06sf7rr.js → chunk-k4kkp58d.js} +18 -5
  101. package/dist/chunk-k4kkp58d.js.map +11 -0
  102. package/dist/{chunk-e1f1sqba.js → chunk-kxea54yg.js} +3 -3
  103. package/dist/{chunk-2h63nrde.js → chunk-ky7zpbtt.js} +5 -7
  104. package/dist/{chunk-2h63nrde.js.map → chunk-ky7zpbtt.js.map} +3 -4
  105. package/dist/chunk-m4ehq95f.js +9 -0
  106. package/dist/chunk-m4ehq95f.js.map +10 -0
  107. package/dist/{chunk-0mza4xb2.js → chunk-m8zkvep1.js} +2 -2
  108. package/dist/{chunk-xn686q2e.js → chunk-ma1mhh7w.js} +75 -57
  109. package/dist/{chunk-xn686q2e.js.map → chunk-ma1mhh7w.js.map} +3 -3
  110. package/dist/{chunk-yxb4c62x.js → chunk-mr60an99.js} +3 -2
  111. package/dist/{chunk-yxb4c62x.js.map → chunk-mr60an99.js.map} +3 -3
  112. package/dist/{chunk-g50nxqs5.js → chunk-pvgpckm1.js} +63 -20
  113. package/dist/chunk-pvgpckm1.js.map +20 -0
  114. package/dist/{chunk-jjwhy3rs.js → chunk-q2xghyft.js} +5 -5
  115. package/dist/chunk-rdghfsss.js.map +2 -2
  116. package/dist/{chunk-bbaa1fet.js → chunk-rzcjp5m2.js} +7 -3
  117. package/dist/chunk-rzcjp5m2.js.map +25 -0
  118. package/dist/{chunk-hzw7yv5g.js → chunk-rzkr70gr.js} +5 -1
  119. package/dist/{chunk-hzw7yv5g.js.map → chunk-rzkr70gr.js.map} +3 -3
  120. package/dist/{chunk-axndsymr.js → chunk-tw03bsmb.js} +2 -2
  121. package/dist/{chunk-axndsymr.js.map → chunk-tw03bsmb.js.map} +3 -3
  122. package/dist/{chunk-y0v18c2j.js → chunk-vef6qa14.js} +2 -2
  123. package/dist/{chunk-gzt6v1ja.js → chunk-vn3yh259.js} +1 -1
  124. package/dist/{chunk-sfypc7mk.js → chunk-wn7mznxc.js} +4 -4
  125. package/dist/{chunk-r5zythxp.js → chunk-wnxabtn4.js} +7 -7
  126. package/dist/{chunk-4ph94nhd.js → chunk-ww185kt6.js} +2 -2
  127. package/dist/{chunk-3h7ctayx.js → chunk-xgptywp0.js} +4 -3
  128. package/dist/chunk-xgptywp0.js.map +11 -0
  129. package/dist/{chunk-gswwr35f.js → chunk-y487ywrv.js} +4 -4
  130. package/dist/{chunk-bet1rb9h.js → chunk-y6vnvayj.js} +1 -1
  131. package/dist/{chunk-x9tmx3fc.js → chunk-ypj2wqtj.js} +3 -6
  132. package/dist/{chunk-x9tmx3fc.js.map → chunk-ypj2wqtj.js.map} +4 -4
  133. package/dist/{chunk-3bnt2wna.js → chunk-yvf2jqj8.js} +1 -1
  134. package/dist/{chunk-g2gezsg5.js → chunk-z9h698s8.js} +1 -1
  135. package/dist/{chunk-wjffn5m4.js → chunk-zdkcdshk.js} +3 -36
  136. package/dist/{chunk-wjffn5m4.js.map → chunk-zdkcdshk.js.map} +3 -4
  137. package/dist/{chunk-bfjv1adk.js → chunk-znw0zvy4.js} +1 -1
  138. package/dist/edits/types.d.ts +19 -19
  139. package/dist/edits/types.d.ts.map +1 -1
  140. package/dist/error-reporting/internal.js +3 -3
  141. package/dist/errors/catalog.d.ts +4 -0
  142. package/dist/errors/catalog.d.ts.map +1 -1
  143. package/dist/errors/internal.js +1 -1
  144. package/dist/events/envelope.d.ts +0 -12
  145. package/dist/events/envelope.d.ts.map +1 -1
  146. package/dist/events/index.d.ts +1 -1
  147. package/dist/events/index.d.ts.map +1 -1
  148. package/dist/events/index.js +3 -3
  149. package/dist/events/service.d.ts +1 -2
  150. package/dist/events/service.d.ts.map +1 -1
  151. package/dist/events/toStoredEvent.d.ts +1 -2
  152. package/dist/events/toStoredEvent.d.ts.map +1 -1
  153. package/dist/events/types/index.d.ts +2 -1
  154. package/dist/events/types/index.d.ts.map +1 -1
  155. package/dist/execution/agent.d.ts +1 -2
  156. package/dist/execution/agent.d.ts.map +1 -1
  157. package/dist/execution/agent.js +39 -37
  158. package/dist/execution/agent.js.map +1 -1
  159. package/dist/execution/authorized-object-reader.d.ts.map +1 -1
  160. package/dist/execution/primitive.d.ts +1 -2
  161. package/dist/execution/primitive.d.ts.map +1 -1
  162. package/dist/execution/primitive.js +38 -36
  163. package/dist/execution/primitive.js.map +3 -3
  164. package/dist/execution/request.d.ts +1 -2
  165. package/dist/execution/request.d.ts.map +1 -1
  166. package/dist/execution/request.js +39 -37
  167. package/dist/execution/request.js.map +3 -3
  168. package/dist/index.d.ts +6 -6
  169. package/dist/index.d.ts.map +1 -1
  170. package/dist/index.js +56 -50
  171. package/dist/index.js.map +1 -1
  172. package/dist/maintenance/ontology-maintenance.d.ts +11 -1
  173. package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
  174. package/dist/materialization/errors.d.ts +3 -1
  175. package/dist/materialization/errors.d.ts.map +1 -1
  176. package/dist/materialization/events.d.ts +27 -2
  177. package/dist/materialization/events.d.ts.map +1 -1
  178. package/dist/materializer/edits/commit.d.ts.map +1 -1
  179. package/dist/materializer/edits/operations.d.ts +2 -1
  180. package/dist/materializer/edits/operations.d.ts.map +1 -1
  181. package/dist/materializer/edits/plan.d.ts +2 -2
  182. package/dist/materializer/edits/plan.d.ts.map +1 -1
  183. package/dist/materializer/edits/user-refs.d.ts +30 -0
  184. package/dist/materializer/edits/user-refs.d.ts.map +1 -0
  185. package/dist/materializer/effective/build-events.d.ts +2 -2
  186. package/dist/materializer/effective/build-events.d.ts.map +1 -1
  187. package/dist/materializer/execution/scope.d.ts +11 -3
  188. package/dist/materializer/execution/scope.d.ts.map +1 -1
  189. package/dist/materializer/index.js +23 -21
  190. package/dist/materializer/index.js.map +1 -1
  191. package/dist/materializer/projections/replacement-plan.d.ts +2 -0
  192. package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
  193. package/dist/materializer/telemetry/plan.d.ts +2 -2
  194. package/dist/materializer/telemetry/plan.d.ts.map +1 -1
  195. package/dist/models/execution/index.js +23 -21
  196. package/dist/models/execution/index.js.map +1 -1
  197. package/dist/models/index.js +1 -1
  198. package/dist/objects/execution.d.ts +21 -27
  199. package/dist/objects/execution.d.ts.map +1 -1
  200. package/dist/objects/index.js +28 -26
  201. package/dist/objects/index.js.map +1 -1
  202. package/dist/objects/query/executor.d.ts.map +1 -1
  203. package/dist/objects/query/index.js +27 -25
  204. package/dist/objects/query/index.js.map +1 -1
  205. package/dist/objects/query/ir.d.ts +8 -1
  206. package/dist/objects/query/ir.d.ts.map +1 -1
  207. package/dist/objects/query/scalar-values.d.ts.map +1 -1
  208. package/dist/objects/query/validate.d.ts.map +1 -1
  209. package/dist/objects/sdk/object-handle.d.ts +1 -2
  210. package/dist/objects/sdk/object-handle.d.ts.map +1 -1
  211. package/dist/objects/sdk/object-set.d.ts +2 -3
  212. package/dist/objects/sdk/object-set.d.ts.map +1 -1
  213. package/dist/objects/sdk/query-builder.d.ts +8 -10
  214. package/dist/objects/sdk/query-builder.d.ts.map +1 -1
  215. package/dist/objects/sdk/telemetry-channel.d.ts +1 -2
  216. package/dist/objects/sdk/telemetry-channel.d.ts.map +1 -1
  217. package/dist/objects/sdk/where.d.ts +2 -3
  218. package/dist/objects/sdk/where.d.ts.map +1 -1
  219. package/dist/ontology/builders.d.ts +11 -10
  220. package/dist/ontology/builders.d.ts.map +1 -1
  221. package/dist/ontology/index.d.ts +4 -2
  222. package/dist/ontology/index.d.ts.map +1 -1
  223. package/dist/ontology/index.js +6 -4
  224. package/dist/ontology/index.js.map +1 -1
  225. package/dist/ontology/inference/index.d.ts +34 -22
  226. package/dist/ontology/inference/index.d.ts.map +1 -1
  227. package/dist/ontology/internal.d.ts +1 -0
  228. package/dist/ontology/internal.d.ts.map +1 -1
  229. package/dist/ontology/internal.js +9 -7
  230. package/dist/ontology/internal.js.map +1 -1
  231. package/dist/ontology/primitives.d.ts +38 -0
  232. package/dist/ontology/primitives.d.ts.map +1 -0
  233. package/dist/ontology/query-capabilities.d.ts +38 -0
  234. package/dist/ontology/query-capabilities.d.ts.map +1 -0
  235. package/dist/ontology/refs.d.ts +23 -2
  236. package/dist/ontology/refs.d.ts.map +1 -1
  237. package/dist/ontology/registered.d.ts +16 -0
  238. package/dist/ontology/registered.d.ts.map +1 -0
  239. package/dist/ontology/registry.d.ts.map +1 -1
  240. package/dist/ontology/tokens.d.ts +35 -1
  241. package/dist/ontology/tokens.d.ts.map +1 -1
  242. package/dist/ontology/types.d.ts +18 -4
  243. package/dist/ontology/types.d.ts.map +1 -1
  244. package/dist/ontology/user-ref.d.ts +35 -0
  245. package/dist/ontology/user-ref.d.ts.map +1 -0
  246. package/dist/ontology/validation/definition.d.ts.map +1 -1
  247. package/dist/ontology/validation/index.d.ts +1 -1
  248. package/dist/ontology/validation/index.d.ts.map +1 -1
  249. package/dist/ontology/validation/normalize.d.ts.map +1 -1
  250. package/dist/ontology/validation/properties.d.ts +6 -1
  251. package/dist/ontology/validation/properties.d.ts.map +1 -1
  252. package/dist/ontology/validation/query.d.ts.map +1 -1
  253. package/dist/ontology/validation/schema.d.ts.map +1 -1
  254. package/dist/pipelines/index.js +26 -24
  255. package/dist/pipelines/index.js.map +1 -1
  256. package/dist/predicates/types.d.ts +53 -3
  257. package/dist/predicates/types.d.ts.map +1 -1
  258. package/dist/projections/builders.d.ts +19 -1
  259. package/dist/projections/builders.d.ts.map +1 -1
  260. package/dist/projections/internal.js +23 -21
  261. package/dist/projections/internal.js.map +1 -1
  262. package/dist/projections/validation.d.ts.map +1 -1
  263. package/dist/query.js +2 -2
  264. package/dist/queues/in-memory.d.ts +1 -1
  265. package/dist/queues/in-memory.d.ts.map +1 -1
  266. package/dist/runtime/create.d.ts +1 -1
  267. package/dist/runtime/create.d.ts.map +1 -1
  268. package/dist/runtime/host.d.ts +5 -5
  269. package/dist/runtime/host.d.ts.map +1 -1
  270. package/dist/runtime/index.d.ts +1 -1
  271. package/dist/runtime/index.d.ts.map +1 -1
  272. package/dist/runtime/internal.js +27 -25
  273. package/dist/runtime/internal.js.map +1 -1
  274. package/dist/runtime/sixb.d.ts +5 -5
  275. package/dist/runtime/sixb.d.ts.map +1 -1
  276. package/dist/runtime/types.d.ts +171 -188
  277. package/dist/runtime/types.d.ts.map +1 -1
  278. package/dist/sandboxes/index.js +5 -5
  279. package/dist/sandboxes/sandbox.d.ts +4 -1
  280. package/dist/sandboxes/sandbox.d.ts.map +1 -1
  281. package/dist/shared/params/types.d.ts +4 -3
  282. package/dist/shared/params/types.d.ts.map +1 -1
  283. package/dist/shared/params/user-refs.d.ts +19 -0
  284. package/dist/shared/params/user-refs.d.ts.map +1 -0
  285. package/dist/shares/compiler.d.ts.map +1 -1
  286. package/dist/shares/internal.js +24 -22
  287. package/dist/shares/internal.js.map +2 -2
  288. package/dist/storage/action-runs/failure.js +2 -2
  289. package/dist/storage/action-runs/types.d.ts +1 -1
  290. package/dist/storage/action-runs/types.d.ts.map +1 -1
  291. package/dist/storage/agents/provider.js +1 -1
  292. package/dist/storage/ai-limits/enforcement.js +2 -2
  293. package/dist/storage/auth/errors.d.ts +1 -1
  294. package/dist/storage/auth/errors.d.ts.map +1 -1
  295. package/dist/storage/auth/in-memory/access-tokens.d.ts.map +1 -1
  296. package/dist/storage/auth/in-memory/auth-storage.d.ts +2 -1
  297. package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
  298. package/dist/storage/auth/in-memory/device-authorizations.d.ts.map +1 -1
  299. package/dist/storage/auth/in-memory/sessions.d.ts +8 -1
  300. package/dist/storage/auth/in-memory/sessions.d.ts.map +1 -1
  301. package/dist/storage/auth/in-memory/shared.d.ts.map +1 -1
  302. package/dist/storage/auth/index.d.ts +1 -1
  303. package/dist/storage/auth/index.d.ts.map +1 -1
  304. package/dist/storage/auth/types.d.ts +77 -20
  305. package/dist/storage/auth/types.d.ts.map +1 -1
  306. package/dist/storage/connector-connections/provider.js +1 -1
  307. package/dist/storage/executions/provider.js +1 -1
  308. package/dist/storage/file-upload-sessions/in-memory.d.ts +9 -18
  309. package/dist/storage/file-upload-sessions/in-memory.d.ts.map +1 -1
  310. package/dist/storage/file-upload-sessions/index.d.ts +1 -1
  311. package/dist/storage/file-upload-sessions/index.d.ts.map +1 -1
  312. package/dist/storage/file-upload-sessions/provider.d.ts +52 -0
  313. package/dist/storage/file-upload-sessions/provider.d.ts.map +1 -0
  314. package/dist/storage/file-upload-sessions/provider.js +24 -0
  315. package/dist/storage/file-upload-sessions/provider.js.map +9 -0
  316. package/dist/storage/file-upload-sessions/types.d.ts +19 -1
  317. package/dist/storage/file-upload-sessions/types.d.ts.map +1 -1
  318. package/dist/storage/file-upload-sessions/utils.d.ts +8 -2
  319. package/dist/storage/file-upload-sessions/utils.d.ts.map +1 -1
  320. package/dist/storage/index.d.ts +3 -3
  321. package/dist/storage/index.d.ts.map +1 -1
  322. package/dist/storage/index.js +29 -25
  323. package/dist/storage/index.js.map +1 -1
  324. package/dist/storage/internal.js +11 -9
  325. package/dist/storage/internal.js.map +1 -1
  326. package/dist/storage/objects/in-memory/query.d.ts.map +1 -1
  327. package/dist/storage/ontology/commits.d.ts +6 -2
  328. package/dist/storage/ontology/commits.d.ts.map +1 -1
  329. package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
  330. package/dist/storage/ontology/provider-work.d.ts.map +1 -1
  331. package/dist/storage/ontology/provider.d.ts +14 -1
  332. package/dist/storage/ontology/provider.d.ts.map +1 -1
  333. package/dist/storage/ontology/provider.js +8 -2
  334. package/dist/storage/ontology/provider.js.map +1 -1
  335. package/dist/storage/operation-scope.d.ts.map +1 -1
  336. package/dist/storage/operation-scope.js +1 -1
  337. package/dist/storage/projection-runs/provider.js +2 -2
  338. package/dist/storage/types.d.ts +1 -1
  339. package/dist/storage/types.d.ts.map +1 -1
  340. package/dist/storage/workflow-interventions/index.d.ts +1 -1
  341. package/dist/storage/workflow-interventions/index.d.ts.map +1 -1
  342. package/dist/storage/workflow-interventions/types.d.ts +5 -8
  343. package/dist/storage/workflow-interventions/types.d.ts.map +1 -1
  344. package/dist/storage/workflow-runs/provider.js +8 -8
  345. package/dist/syncs/index.js +27 -25
  346. package/dist/syncs/index.js.map +1 -1
  347. package/dist/testing/action-execution.d.ts +4 -0
  348. package/dist/testing/action-execution.d.ts.map +1 -1
  349. package/dist/testing/auth-storage-contract.d.ts.map +1 -1
  350. package/dist/testing/execution.d.ts +1 -2
  351. package/dist/testing/execution.d.ts.map +1 -1
  352. package/dist/testing/file-upload-session-storage-contract.d.ts +12 -0
  353. package/dist/testing/file-upload-session-storage-contract.d.ts.map +1 -0
  354. package/dist/testing/index.d.ts +2 -0
  355. package/dist/testing/index.d.ts.map +1 -1
  356. package/dist/testing/index.js +2035 -1358
  357. package/dist/testing/index.js.map +15 -13
  358. package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
  359. package/dist/testing/object-query-contract.d.ts.map +1 -1
  360. package/dist/testing/ontology-contract-fixture.d.ts +8 -0
  361. package/dist/testing/ontology-contract-fixture.d.ts.map +1 -1
  362. package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
  363. package/dist/testing/sandboxes-contract.d.ts.map +1 -1
  364. package/dist/testing/workflow-intervention-storage-contract.d.ts +8 -0
  365. package/dist/testing/workflow-intervention-storage-contract.d.ts.map +1 -0
  366. package/dist/webhooks/internal.js +24 -22
  367. package/dist/webhooks/internal.js.map +2 -2
  368. package/dist/webhooks/types.d.ts +2 -2
  369. package/dist/webhooks/types.d.ts.map +1 -1
  370. package/dist/workers/index.js +1 -1
  371. package/dist/workflows/index.js +42 -40
  372. package/dist/workflows/index.js.map +1 -1
  373. package/dist/workflows/run-dispatch.d.ts.map +1 -1
  374. package/dist/workflows/types.d.ts +2 -2
  375. package/dist/workflows/types.d.ts.map +1 -1
  376. package/package.json +7 -1
  377. package/src/actions/index.ts +0 -3
  378. package/src/actions/read-facade.ts +102 -62
  379. package/src/actions/request.ts +13 -0
  380. package/src/actions/run-dispatch.ts +3 -0
  381. package/src/actions/types/context.ts +17 -65
  382. package/src/actions/types/params.ts +2 -1
  383. package/src/agents/authority.ts +1 -1
  384. package/src/assert-never.ts +7 -0
  385. package/src/auth/client-address.ts +12 -0
  386. package/src/auth/csrf.ts +14 -5
  387. package/src/auth/errors.ts +23 -0
  388. package/src/auth/index.ts +4 -3
  389. package/src/auth/runtime.ts +353 -297
  390. package/src/auth/session-cache.ts +18 -6
  391. package/src/auth/sessions.ts +30 -0
  392. package/src/auth/strategy.ts +2 -0
  393. package/src/auth/types.ts +15 -17
  394. package/src/bootstrap/index.ts +1 -0
  395. package/src/bootstrap/ontology-type-manifest.ts +112 -60
  396. package/src/edits/types.ts +47 -63
  397. package/src/errors/catalog.ts +4 -0
  398. package/src/events/envelope.ts +0 -13
  399. package/src/events/index.ts +1 -1
  400. package/src/events/service.ts +1 -11
  401. package/src/events/toStoredEvent.ts +1 -3
  402. package/src/events/types/index.ts +1 -1
  403. package/src/execution/agent.ts +1 -2
  404. package/src/execution/authorized-object-reader.ts +5 -7
  405. package/src/execution/primitive.ts +1 -2
  406. package/src/execution/request.ts +1 -2
  407. package/src/index.ts +8 -7
  408. package/src/maintenance/ontology-maintenance.ts +77 -1
  409. package/src/materialization/errors.ts +2 -0
  410. package/src/materialization/events.ts +27 -2
  411. package/src/materializer/README.md +2 -0
  412. package/src/materializer/edits/commit.ts +21 -12
  413. package/src/materializer/edits/operations.ts +32 -4
  414. package/src/materializer/edits/plan.ts +4 -5
  415. package/src/materializer/edits/user-refs.ts +115 -0
  416. package/src/materializer/effective/build-events.ts +4 -5
  417. package/src/materializer/execution/scope.ts +40 -7
  418. package/src/materializer/projections/replace.ts +2 -0
  419. package/src/materializer/projections/replacement-plan.ts +4 -0
  420. package/src/materializer/telemetry/append.ts +4 -12
  421. package/src/materializer/telemetry/plan.ts +4 -5
  422. package/src/objects/execution.ts +33 -62
  423. package/src/objects/query/executor.ts +12 -3
  424. package/src/objects/query/ir.ts +7 -0
  425. package/src/objects/query/planner.ts +1 -0
  426. package/src/objects/query/scalar-values.ts +19 -0
  427. package/src/objects/query/validate.ts +55 -44
  428. package/src/objects/sdk/object-handle.ts +8 -8
  429. package/src/objects/sdk/object-set.ts +8 -15
  430. package/src/objects/sdk/query-builder.ts +59 -71
  431. package/src/objects/sdk/telemetry-channel.ts +6 -7
  432. package/src/objects/sdk/where.ts +6 -13
  433. package/src/ontology/builders.ts +15 -11
  434. package/src/ontology/index.ts +4 -0
  435. package/src/ontology/inference/index.ts +56 -36
  436. package/src/ontology/internal.ts +1 -0
  437. package/src/ontology/json-schema.ts +12 -0
  438. package/src/ontology/primitives.ts +91 -0
  439. package/src/ontology/query-capabilities.ts +136 -0
  440. package/src/ontology/refs.ts +33 -6
  441. package/src/ontology/registered.ts +22 -0
  442. package/src/ontology/registry.ts +6 -3
  443. package/src/ontology/tokens.ts +41 -2
  444. package/src/ontology/types.ts +19 -3
  445. package/src/ontology/user-ref.ts +120 -0
  446. package/src/ontology/validation/definition.ts +2 -13
  447. package/src/ontology/validation/index.ts +1 -0
  448. package/src/ontology/validation/normalize.ts +39 -3
  449. package/src/ontology/validation/properties.ts +95 -19
  450. package/src/ontology/validation/query.ts +11 -42
  451. package/src/ontology/validation/schema.ts +16 -0
  452. package/src/predicates/types.ts +43 -33
  453. package/src/projections/builders.ts +24 -3
  454. package/src/projections/validation.ts +15 -1
  455. package/src/runtime/create.ts +2 -2
  456. package/src/runtime/host.ts +10 -12
  457. package/src/runtime/index.ts +3 -2
  458. package/src/runtime/sixb.ts +13 -23
  459. package/src/runtime/types.ts +277 -479
  460. package/src/sandboxes/sandbox.ts +4 -1
  461. package/src/shared/params/types.ts +4 -3
  462. package/src/shared/params/user-refs.ts +48 -0
  463. package/src/shares/compiler.ts +6 -16
  464. package/src/storage/action-runs/types.ts +1 -0
  465. package/src/storage/auth/errors.ts +0 -1
  466. package/src/storage/auth/in-memory/access-tokens.ts +5 -2
  467. package/src/storage/auth/in-memory/auth-storage.ts +49 -73
  468. package/src/storage/auth/in-memory/device-authorizations.ts +0 -2
  469. package/src/storage/auth/in-memory/sessions.ts +69 -1
  470. package/src/storage/auth/in-memory/shared.ts +13 -7
  471. package/src/storage/auth/index.ts +2 -1
  472. package/src/storage/auth/types.ts +72 -20
  473. package/src/storage/executions/validation.ts +1 -1
  474. package/src/storage/file-upload-sessions/in-memory.ts +64 -113
  475. package/src/storage/file-upload-sessions/index.ts +1 -0
  476. package/src/storage/file-upload-sessions/provider.ts +258 -0
  477. package/src/storage/file-upload-sessions/types.ts +20 -1
  478. package/src/storage/file-upload-sessions/utils.ts +25 -9
  479. package/src/storage/index.ts +3 -2
  480. package/src/storage/objects/in-memory/query.ts +13 -3
  481. package/src/storage/ontology/commits.ts +6 -2
  482. package/src/storage/ontology/in-memory/materializations.ts +6 -34
  483. package/src/storage/ontology/provider-header-validation.ts +57 -0
  484. package/src/storage/ontology/provider-work.ts +15 -3
  485. package/src/storage/ontology/provider.ts +59 -1
  486. package/src/storage/operation-scope.ts +1 -0
  487. package/src/storage/types.ts +0 -1
  488. package/src/storage/workflow-interventions/index.ts +0 -1
  489. package/src/storage/workflow-interventions/types.ts +5 -9
  490. package/src/testing/action-execution.ts +13 -3
  491. package/src/testing/auth-storage-contract.ts +253 -192
  492. package/src/testing/execution-storage-contract.ts +1 -2
  493. package/src/testing/execution.ts +4 -7
  494. package/src/testing/file-upload-session-storage-contract.ts +335 -0
  495. package/src/testing/index.ts +8 -0
  496. package/src/testing/materializer-storage-contract.ts +86 -4
  497. package/src/testing/object-query-contract.ts +121 -2
  498. package/src/testing/ontology-contract-fixture.ts +23 -3
  499. package/src/testing/ontology-storage-contract.ts +58 -0
  500. package/src/testing/sandboxes-contract.ts +27 -0
  501. package/src/testing/workflow-intervention-storage-contract.ts +203 -0
  502. package/src/webhooks/types.ts +2 -2
  503. package/src/workflows/run-dispatch.ts +12 -1
  504. package/src/workflows/snapshot.ts +16 -7
  505. package/src/workflows/types.ts +2 -2
  506. package/dist/chunk-2cxv584m.js.map +0 -43
  507. package/dist/chunk-3ghw2t5q.js.map +0 -10
  508. package/dist/chunk-3h7ctayx.js.map +0 -11
  509. package/dist/chunk-6ma8dvzc.js.map +0 -15
  510. package/dist/chunk-bbaa1fet.js.map +0 -25
  511. package/dist/chunk-eyjzgav0.js.map +0 -12
  512. package/dist/chunk-f06sf7rr.js.map +0 -11
  513. package/dist/chunk-g50nxqs5.js.map +0 -18
  514. package/dist/chunk-hkw8rykk.js.map +0 -15
  515. package/dist/chunk-p6r1ex7t.js.map +0 -10
  516. package/dist/chunk-qm535afa.js.map +0 -15
  517. package/dist/chunk-vpxss818.js.map +0 -10
  518. package/dist/chunk-vsg0g7h9.js.map +0 -17
  519. /package/dist/{chunk-y3ev53cq.js.map → chunk-2fv8sajb.js.map} +0 -0
  520. /package/dist/{chunk-5tetw4hn.js.map → chunk-4tnrzqqh.js.map} +0 -0
  521. /package/dist/{chunk-y1ahv8b7.js.map → chunk-bdhfn0ww.js.map} +0 -0
  522. /package/dist/{chunk-kept9cdd.js.map → chunk-bxx3ms5t.js.map} +0 -0
  523. /package/dist/{chunk-xtfryrfb.js.map → chunk-cbn96bve.js.map} +0 -0
  524. /package/dist/{chunk-t7dzd1tm.js.map → chunk-e2c5yxfe.js.map} +0 -0
  525. /package/dist/{chunk-bg2bs62d.js.map → chunk-jfdggg1p.js.map} +0 -0
  526. /package/dist/{chunk-e1f1sqba.js.map → chunk-kxea54yg.js.map} +0 -0
  527. /package/dist/{chunk-0mza4xb2.js.map → chunk-m8zkvep1.js.map} +0 -0
  528. /package/dist/{chunk-jjwhy3rs.js.map → chunk-q2xghyft.js.map} +0 -0
  529. /package/dist/{chunk-y0v18c2j.js.map → chunk-vef6qa14.js.map} +0 -0
  530. /package/dist/{chunk-gzt6v1ja.js.map → chunk-vn3yh259.js.map} +0 -0
  531. /package/dist/{chunk-sfypc7mk.js.map → chunk-wn7mznxc.js.map} +0 -0
  532. /package/dist/{chunk-r5zythxp.js.map → chunk-wnxabtn4.js.map} +0 -0
  533. /package/dist/{chunk-4ph94nhd.js.map → chunk-ww185kt6.js.map} +0 -0
  534. /package/dist/{chunk-gswwr35f.js.map → chunk-y487ywrv.js.map} +0 -0
  535. /package/dist/{chunk-bet1rb9h.js.map → chunk-y6vnvayj.js.map} +0 -0
  536. /package/dist/{chunk-3bnt2wna.js.map → chunk-yvf2jqj8.js.map} +0 -0
  537. /package/dist/{chunk-g2gezsg5.js.map → chunk-z9h698s8.js.map} +0 -0
  538. /package/dist/{chunk-bfjv1adk.js.map → chunk-znw0zvy4.js.map} +0 -0
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  assertPropertyTokenBelongsToObjectType2,
4
4
  assertTelemetryProperty2
5
- } from "./chunk-vsg0g7h9.js";
5
+ } from "./chunk-d8yes9yx.js";
6
6
  import {
7
7
  lowerEditBatch2
8
8
  } from "./chunk-wr8qp979.js";
@@ -13,10 +13,10 @@ import {
13
13
  } from "./chunk-7ytf06d3.js";
14
14
  import {
15
15
  createLinkScopeFingerprint2
16
- } from "./chunk-m7cx05vp.js";
16
+ } from "./chunk-00pfcqh4.js";
17
17
  import {
18
18
  ActionValidationError2
19
- } from "./chunk-hzw7yv5g.js";
19
+ } from "./chunk-rzkr70gr.js";
20
20
  import {
21
21
  ActionDefinitionError2,
22
22
  ActionEditCommitError2,
@@ -24,10 +24,13 @@ import {
24
24
  effectsWithoutEditsMessage,
25
25
  assertNonEmpty2,
26
26
  isObjectActionDefinition2
27
- } from "./chunk-2cxv584m.js";
27
+ } from "./chunk-6rzb1g6h.js";
28
+ import {
29
+ decorateObjectQueryExecutor
30
+ } from "./chunk-k4kkp58d.js";
28
31
  import {
29
32
  RuntimeError2
30
- } from "./chunk-2h63nrde.js";
33
+ } from "./chunk-m4ehq95f.js";
31
34
  import {
32
35
  OntologyValidationError2
33
36
  } from "./chunk-cqr3acm1.js";
@@ -256,6 +259,14 @@ class ActionReadRecorder2 {
256
259
  lastCommitId: row.lastCommitId
257
260
  });
258
261
  }
262
+ observeObjectRows(rows) {
263
+ for (const row of rows) {
264
+ this.observeObject({ objectTypeId: row.objectTypeId, primaryId: row.primaryId }, row);
265
+ for (const value of Object.values(row.links ?? {})) {
266
+ this.observeObjectRows(expandedRows(value));
267
+ }
268
+ }
269
+ }
259
270
  observeLinkScopes(source, linkIds, rows) {
260
271
  const snapshotsByLinkId = new Map;
261
272
  for (const linkId of linkIds)
@@ -302,14 +313,14 @@ class ActionReadRecorder2 {
302
313
  };
303
314
  }
304
315
  }
305
- function createActionReadFacade2(createObjectSet, options) {
306
- const facade = {
316
+ function createActionReadFacade2(reader, options) {
317
+ return {
307
318
  telemetry: createActionTelemetryReadFacade(options?.telemetry),
308
319
  objects(objectType) {
309
- return createActionReadObjectSetAdapter(objectType, createObjectSet(objectType), options);
320
+ const objectSet = reader.objects(objectType);
321
+ return options ? recordObjectReads(objectType, objectSet, options) : objectSet;
310
322
  }
311
323
  };
312
- return facade;
313
324
  }
314
325
  function createActionTelemetryReadFacade(source) {
315
326
  const facade = {
@@ -367,37 +378,68 @@ function assertTelemetryBatchResultMatchesRequest(requested, results) {
367
378
  }
368
379
  }
369
380
  }
370
- function createActionReadObjectSetAdapter(objectType, objectSet, options) {
371
- async function readObject(id, read) {
372
- const row = await read();
373
- options?.recorder.observeObject({ objectTypeId: objectType.id, primaryId: id }, row ?? null);
374
- return row;
375
- }
381
+ function recordObjectReads(objectType, objectSet, options) {
382
+ const { recorder } = options;
383
+ const ref = (primaryId) => ({
384
+ objectTypeId: objectType.id,
385
+ primaryId
386
+ });
376
387
  return {
377
- get(id) {
378
- return readObject(id, () => objectSet.get(id));
388
+ async get(id) {
389
+ const row = await objectSet.get(id);
390
+ recorder.observeObject(ref(id), row && storageRow(row));
391
+ return row;
379
392
  },
380
393
  query() {
381
- return objectSet.query();
394
+ return decorateObjectQueryExecutor(objectSet.query(), (executor) => recordingExecutor(executor, recorder));
382
395
  },
383
- list(input) {
384
- return objectSet.list(input);
396
+ async list(input) {
397
+ const result = await objectSet.list(input);
398
+ recorder.observeObjectRows(result.objects.map(storageRow));
399
+ return result;
385
400
  },
386
401
  byId(id) {
387
402
  const handle = objectSet.byId(id);
388
403
  return {
389
- get() {
390
- return readObject(id, () => handle.get());
404
+ async get() {
405
+ const row = await handle.get();
406
+ recorder.observeObject(ref(id), row && storageRow(row));
407
+ return row;
391
408
  },
392
409
  async listLinks(link) {
393
410
  const rows = await handle.listLinks(link);
394
- options?.recorder.observeLinkScopes({ objectTypeId: objectType.id, primaryId: id }, link ? [link.id] : options.resolveLinkIds(objectType.id), rows);
411
+ recorder.observeLinkScopes(ref(id), link ? [link.id] : options.resolveLinkIds(objectType.id), rows);
395
412
  return rows;
396
413
  }
397
414
  };
398
415
  }
399
416
  };
400
417
  }
418
+ function recordingExecutor(executor, recorder) {
419
+ return {
420
+ async list(query, listOptions) {
421
+ const result = await executor.list(query, listOptions);
422
+ recorder.observeObjectRows(result.objects.map(storageRow));
423
+ return result;
424
+ },
425
+ count: (query) => executor.count(query),
426
+ exists: (query) => executor.exists(query),
427
+ facets: (query, facets) => executor.facets(query, facets),
428
+ validate: executor.validate?.bind(executor),
429
+ explain: executor.explain?.bind(executor)
430
+ };
431
+ }
432
+ function storageRow(row) {
433
+ return row;
434
+ }
435
+ function expandedRows(value) {
436
+ if (value === null)
437
+ return [];
438
+ return isExpandedRowList(value) ? value : [value];
439
+ }
440
+ function isExpandedRowList(value) {
441
+ return Array.isArray(value);
442
+ }
401
443
  function toLinkSnapshot(row) {
402
444
  if (row.lastCommitId === undefined)
403
445
  return null;
@@ -547,4 +589,4 @@ function isValidatorErrorResult(value) {
547
589
  }
548
590
  export { defineAction2, param2, optional2, commitActionEdits2, findActionEditCommit2, ActionReadRecorder2, createActionReadFacade2, ActionRegistry2, runActionValidators2 };
549
591
 
550
- //# debugId=4C98929E6278211764756E2164756E21
592
+ //# debugId=1D163836FC4D0FDC64756E2164756E21
@@ -0,0 +1,15 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/actions/builders/define-action.ts", "../src/shared/params/builders.ts", "../src/actions/commit-edits.ts", "../src/actions/read-facade.ts", "../src/actions/registry.ts", "../src/actions/validators.ts"],
4
+ "sourcesContent": [
5
+ "import type { ObjectTypeWithPropertyTokens } from \"../../ontology/tokens\"\nimport { ActionDefinitionError, effectsWithoutEditsMessage } from \"../errors\"\nimport type {\n ActionBuilder,\n ActionEditsHandler,\n ActionEffectsHandler,\n ActionParamsConfig,\n ActionValidator,\n ActionWritebackHandler,\n GlobalActionDefinition,\n GlobalActionEditsHandler,\n GlobalActionEffectsHandler,\n GlobalActionPhaseBuilder,\n GlobalActionValidator,\n GlobalActionWritebackHandler,\n ObjectActionDefinition,\n ObjectActionPhaseBuilder,\n} from \"../types\"\nimport { assertNonEmpty } from \"../validation\"\n\ntype ActionOptions = {\n description?: string\n}\n\nexport function defineAction<const TId extends string>(\n id: TId,\n options?: ActionOptions\n): ActionBuilder<TId> {\n assertNonEmpty(id, \"id\")\n\n return asPublicActionType<ActionBuilder<TId>>(createActionBuilder(id, options))\n}\n\nfunction createActionBuilder(id: string, options?: ActionOptions) {\n const builder = {\n params(params: ActionParamsConfig) {\n return createGlobalActionPhaseBuilder(id, params, options)\n },\n on(objectType: ObjectTypeWithPropertyTokens) {\n assertNonEmpty(objectType.id, \"target id\")\n return createObjectActionParamsBuilder(id, objectType, options)\n },\n }\n\n return builder\n}\n\nfunction createGlobalActionPhaseBuilder(\n id: string,\n params: ActionParamsConfig,\n options?: ActionOptions\n): GlobalActionPhaseBuilder<string, ActionParamsConfig> {\n const validators: GlobalActionValidator<Record<string, unknown>>[] = []\n\n const builder = {\n validate(validator: GlobalActionValidator<Record<string, unknown>>) {\n validators.push(validator)\n return builder\n },\n writeback(handler: GlobalActionWritebackHandler<Record<string, unknown>, unknown>) {\n return createGlobalDefinition({\n id,\n params,\n description: options?.description,\n validators,\n writeback: handler,\n })\n },\n edits(handler: GlobalActionEditsHandler<Record<string, unknown>, undefined>) {\n return createGlobalDefinition({\n id,\n params,\n description: options?.description,\n validators,\n edits: handler,\n })\n },\n }\n\n return asPublicActionType<GlobalActionPhaseBuilder<string, ActionParamsConfig>>(builder)\n}\n\nfunction createObjectActionParamsBuilder(\n id: string,\n objectType: ObjectTypeWithPropertyTokens,\n options?: ActionOptions\n) {\n return {\n params(params: ActionParamsConfig) {\n return createObjectActionPhaseBuilder(id, objectType, params, options)\n },\n }\n}\n\nfunction createObjectActionPhaseBuilder(\n id: string,\n objectType: ObjectTypeWithPropertyTokens,\n params: ActionParamsConfig,\n options?: ActionOptions\n): ObjectActionPhaseBuilder<string, ObjectTypeWithPropertyTokens, ActionParamsConfig> {\n const validators: ActionValidator<ObjectTypeWithPropertyTokens, Record<string, unknown>>[] = []\n\n const builder = {\n validate(validator: ActionValidator<ObjectTypeWithPropertyTokens, Record<string, unknown>>) {\n validators.push(validator)\n return builder\n },\n writeback(\n handler: ActionWritebackHandler<\n ObjectTypeWithPropertyTokens,\n Record<string, unknown>,\n unknown\n >\n ) {\n return createObjectDefinition({\n id,\n objectType,\n params,\n description: options?.description,\n validators,\n writeback: handler,\n })\n },\n edits(\n handler: ActionEditsHandler<ObjectTypeWithPropertyTokens, Record<string, unknown>, undefined>\n ) {\n return createObjectDefinition({\n id,\n objectType,\n params,\n description: options?.description,\n validators,\n edits: handler,\n })\n },\n }\n\n return asPublicActionType<\n ObjectActionPhaseBuilder<string, ObjectTypeWithPropertyTokens, ActionParamsConfig>\n >(builder)\n}\n\nfunction createGlobalDefinition(input: {\n readonly id: string\n readonly params: ActionParamsConfig\n readonly description?: string\n readonly validators: readonly unknown[]\n readonly writeback?: unknown\n readonly edits?: unknown\n readonly effects?: unknown\n}): GlobalActionDefinition {\n const definition = {\n kind: \"action\",\n id: input.id,\n binding: { kind: \"global\" },\n params: input.params,\n phases: {\n validate: [...input.validators],\n ...(input.writeback ? { writeback: input.writeback } : {}),\n ...(input.edits ? { edits: input.edits } : {}),\n ...(input.effects ? { effects: input.effects } : {}),\n },\n ...(input.description !== undefined ? { description: input.description } : {}),\n }\n\n return asPublicActionType<GlobalActionDefinition>(\n Object.assign(definition, {\n edits(handler: GlobalActionEditsHandler<Record<string, unknown>, unknown>) {\n return createGlobalDefinition({\n ...input,\n edits: handler,\n })\n },\n effects(handler: GlobalActionEffectsHandler<Record<string, unknown>, unknown>) {\n if (!input.edits) {\n throw new ActionDefinitionError(effectsWithoutEditsMessage(input.id))\n }\n return createGlobalDefinition({\n ...input,\n effects: handler,\n })\n },\n })\n )\n}\n\nfunction createObjectDefinition(input: {\n readonly id: string\n readonly objectType: ObjectTypeWithPropertyTokens\n readonly params: ActionParamsConfig\n readonly description?: string\n readonly validators: readonly unknown[]\n readonly writeback?: unknown\n readonly edits?: unknown\n readonly effects?: unknown\n}): ObjectActionDefinition {\n const definition = {\n kind: \"action\",\n id: input.id,\n binding: { kind: \"object\", objectType: input.objectType },\n params: input.params,\n phases: {\n validate: [...input.validators],\n ...(input.writeback ? { writeback: input.writeback } : {}),\n ...(input.edits ? { edits: input.edits } : {}),\n ...(input.effects ? { effects: input.effects } : {}),\n },\n ...(input.description !== undefined ? { description: input.description } : {}),\n }\n\n return asPublicActionType<ObjectActionDefinition>(\n Object.assign(definition, {\n edits(\n handler: ActionEditsHandler<ObjectTypeWithPropertyTokens, Record<string, unknown>, unknown>\n ) {\n return createObjectDefinition({\n ...input,\n edits: handler,\n })\n },\n effects(\n handler: ActionEffectsHandler<\n ObjectTypeWithPropertyTokens,\n Record<string, unknown>,\n unknown\n >\n ) {\n if (!input.edits) {\n throw new ActionDefinitionError(effectsWithoutEditsMessage(input.id))\n }\n return createObjectDefinition({\n ...input,\n effects: handler,\n })\n },\n })\n )\n}\n\n// Runtime builders are plain objects; public builder types carry phase-order inference.\nfunction asPublicActionType<TPublic>(value: unknown): TPublic {\n return value as TPublic\n}\n",
6
+ "import type { SchemaOrRef } from \"../../ontology\"\nimport type { QuantitativeTypeId } from \"../../ontology/units\"\nimport type { ParamConfig } from \"./types\"\n\nexport interface ParamOptions {\n readonly description?: string\n readonly semanticType?: QuantitativeTypeId\n readonly nullable?: boolean\n}\n\ntype FieldFromOptions<TOptions, TKey extends string, TFallback> =\n TOptions extends Record<TKey, infer TValue>\n ? { [K in TKey]: TValue }\n : { [K in TKey]?: TFallback }\n\ntype ParamResult<\n TSchema extends SchemaOrRef,\n TRequired extends boolean,\n TOptions extends ParamOptions | undefined,\n> = {\n schema: TSchema\n required: TRequired\n} & FieldFromOptions<TOptions, \"description\", string> &\n FieldFromOptions<TOptions, \"semanticType\", QuantitativeTypeId> &\n FieldFromOptions<TOptions, \"nullable\", boolean>\n\n/** Declare one required parameter. */\nexport function param<\n const TSchema extends SchemaOrRef,\n const TOptions extends ParamOptions | undefined = undefined,\n>(schema: TSchema, options?: TOptions): ParamResult<TSchema, true, TOptions> {\n const result: ParamConfig & { required: true } = {\n schema,\n required: true,\n ...(options?.description !== undefined ? { description: options.description } : {}),\n ...(options?.semanticType !== undefined ? { semanticType: options.semanticType } : {}),\n ...(options?.nullable !== undefined ? { nullable: options.nullable } : {}),\n }\n return result as ParamResult<TSchema, true, TOptions>\n}\n\n/** Derive an optional parameter without changing its schema or metadata. */\nexport function optional<const TParam extends ParamConfig>(\n paramConfig: TParam\n): Omit<TParam, \"required\"> & { readonly required: false } {\n return {\n ...paramConfig,\n required: false,\n }\n}\n",
7
+ "import type { EditBatch } from \"../edits\"\nimport { lowerEditBatch } from \"../edits\"\nimport type {\n EditCommitResult,\n EffectiveLinkChange,\n EffectiveObjectChange,\n ExpectedLinkRevision,\n ExpectedLinkScopeRevision,\n ExpectedObjectRevision,\n OntologyOperationOutcome,\n} from \"../materializer\"\nimport type { OntologyMutationRuntime } from \"../runtime/ontology-mutations\"\nimport type { Storage } from \"../storage/types\"\nimport { ActionEditCommitError } from \"./errors\"\n\n/** Exact reads an Action handler depended on, protected by row-level CAS at commit time. */\nexport interface ActionReadDependencies {\n readonly objects: readonly ExpectedObjectRevision[]\n readonly links: readonly ExpectedLinkRevision[]\n readonly linkScopes: readonly ExpectedLinkScopeRevision[]\n}\n\nconst NO_READ_DEPENDENCIES: ActionReadDependencies = { objects: [], links: [], linkScopes: [] }\n\nexport interface CommitActionEditsInput {\n readonly mutations: Pick<OntologyMutationRuntime, \"commitEdits\">\n readonly projectId: string\n readonly runId: string\n readonly actionId: string\n readonly batch: EditBatch\n readonly dependencies?: ActionReadDependencies\n}\n\n/** The authoritative ontology commit an Action run produced. */\nexport interface ActionEditCommitResult {\n readonly commitId: string\n readonly created: boolean\n readonly eventCount: number\n readonly outcomes: readonly OntologyOperationOutcome[]\n readonly changes: {\n readonly objects: readonly EffectiveObjectChange[]\n readonly links: readonly EffectiveLinkChange[]\n }\n readonly committedAt: Date\n}\n\nexport interface FindActionEditCommitInput {\n readonly storage: Pick<Storage, \"ontology\">\n readonly projectId: string\n readonly runId: string\n}\n\n/**\n * Commits one Action run's recorded edits as a single atomic ontology commit.\n *\n * The batch lowers to canonical Materializer operations and the Materializer validates the Action run\n * identity, applies managed authority, resolves effective state, writes the authoritative commit, and\n * inserts outbox facts in one transaction. Repeating the call for the same run replays that commit;\n * a divergent request for the same run is a typed idempotency conflict.\n */\nexport async function commitActionEdits(\n input: CommitActionEditsInput\n): Promise<ActionEditCommitResult> {\n const dependencies = input.dependencies ?? NO_READ_DEPENDENCIES\n const commit = await input.mutations.commitEdits({\n mode: \"atomic\",\n source: { kind: \"action\", actionId: input.actionId, runId: input.runId },\n operations: lowerEditBatch(input.batch),\n expectedObjects: dependencies.objects,\n expectedLinks: dependencies.links,\n expectedLinkScopes: dependencies.linkScopes,\n })\n return toActionEditCommitResult(commit)\n}\n\n/**\n * Resolves the authoritative commit an Action run already produced, if any.\n *\n * Resume uses the exact `{ actionRunId }` origin instead of rerunning handlers, so a redelivered run\n * returns the persisted result without recomputing an idempotency hash.\n */\nexport async function findActionEditCommit(\n input: FindActionEditCommitInput\n): Promise<ActionEditCommitResult | null> {\n const record = await input.storage.ontology.commits.getByOrigin({\n projectId: input.projectId,\n origin: { kind: \"action\", actionRunId: input.runId },\n })\n if (!record) return null\n if (record.result.kind !== \"edit\") {\n throw new ActionEditCommitError(\n `[Sixb] Action run '${input.runId}' resolved a '${record.result.kind}' commit instead of an edit commit.`\n )\n }\n return toActionEditCommitResult({ ...record.result, created: false })\n}\n\nfunction toActionEditCommitResult(commit: EditCommitResult): ActionEditCommitResult {\n return {\n commitId: commit.commitId,\n created: commit.created,\n eventCount: commit.eventCount,\n outcomes: commit.outcomes,\n changes: commit.changes,\n committedAt: new Date(commit.committedAt),\n }\n}\n",
8
+ "import { linkRefKey, linkScopeKey, objectRefKey } from \"../materialization/refs\"\nimport type {\n EffectiveLinkSnapshot,\n ExpectedLinkRevision,\n ExpectedLinkScopeRevision,\n ExpectedObjectRevision,\n OntologyLinkRef,\n OntologyObjectRef,\n} from \"../materializer\"\nimport { createLinkScopeFingerprint } from \"../materializer\"\nimport { decorateObjectQueryExecutor } from \"../objects/sdk/query-builder\"\nimport type { ObjectQueryExecutor } from \"../objects/sdk/query-executor\"\nimport { OntologyValidationError } from \"../ontology/errors\"\nimport type { ObjectTypeWithPropertyTokens } from \"../ontology/tokens\"\nimport {\n assertPropertyTokenBelongsToObjectType,\n assertTelemetryProperty,\n} from \"../ontology/validation\"\nimport { RuntimeError } from \"../runtime/errors\"\nimport type { ObjectReader, ObjectReadSet } from \"../runtime/types\"\nimport type {\n ExpandedLinkValue,\n ExpandedObjectRow,\n ObjectLinkRow,\n ObjectRow,\n TimeseriesHistoryBatchInput,\n TimeseriesHistoryBatchResult,\n} from \"../storage\"\nimport type { ActionReadDependencies } from \"./commit-edits\"\nimport type {\n ActionReadFacade,\n ActionTelemetryHistorySeriesInput,\n ActionTelemetryReadFacade,\n} from \"./types\"\n\n/** Runtime leaves used by the Action telemetry read adapter. */\nexport interface ActionTelemetryReadSource {\n readonly resolveObjectType: (objectTypeId: string) => ObjectTypeWithPropertyTokens\n readonly getHistoryBatch: (\n input: Omit<TimeseriesHistoryBatchInput, \"projectId\">\n ) => Promise<readonly TimeseriesHistoryBatchResult[]>\n}\n\n/**\n * Records the exact state an Action handler observed while reading.\n *\n * A handler that reads one dependency twice keeps the first observation: the commit must fail when\n * current state no longer matches what the decision was made against, and the later read may already\n * reflect the handler's own intent. Objects returned by `list()` and `query()` are fenced like\n * concrete reads, but query membership is not yet: an object that starts matching a query after the\n * read, and aggregate results (`count()`, `exists()`, `facets()`), stay unfenced. Telemetry history\n * is also a call-level snapshot, not an edit dependency.\n */\nexport class ActionReadRecorder {\n private readonly objects = new Map<string, ExpectedObjectRevision>()\n private readonly links = new Map<string, ExpectedLinkRevision>()\n private readonly linkScopes = new Map<string, ExpectedLinkScopeRevision>()\n\n /** Records a concrete object read, including exact absence. */\n observeObject(ref: OntologyObjectRef, row: ObjectRow | null): void {\n const key = objectRefKey(ref)\n if (this.objects.has(key)) return\n if (!row) {\n this.objects.set(key, { ref, exists: false })\n return\n }\n // Rows without materializer provenance predate the commit ledger and cannot be fenced.\n if (row.lastCommitId === undefined) return\n this.objects.set(key, {\n ref,\n exists: true,\n version: row.version,\n lastCommitId: row.lastCommitId,\n })\n }\n\n /**\n * Records every object a listing or query returned, including the objects its expansions attached.\n *\n * Rows are keyed by their own type: a traversal or subtype query returns objects of a type other\n * than the one the query started from, and the commit checks each row under its exact identity.\n */\n observeObjectRows(rows: readonly ObjectRow[]): void {\n for (const row of rows) {\n this.observeObject({ objectTypeId: row.objectTypeId, primaryId: row.primaryId }, row)\n for (const value of Object.values(row.links ?? {})) {\n this.observeObjectRows(expandedRows(value))\n }\n }\n }\n\n /**\n * Records the complete `(source, linkId)` scopes a link listing observed.\n *\n * `linkIds` names every scope the read covered so an empty scope is recorded as an empty\n * fingerprint rather than being silently omitted.\n */\n observeLinkScopes(\n source: OntologyObjectRef,\n linkIds: readonly string[],\n rows: readonly ObjectLinkRow[]\n ): void {\n const snapshotsByLinkId = new Map<string, EffectiveLinkSnapshot[]>()\n for (const linkId of linkIds) snapshotsByLinkId.set(linkId, [])\n /** Scopes holding a row that cannot be fenced, so no expectation may be recorded for them. */\n const unfenceable = new Set<string>()\n\n for (const row of rows) {\n if (row.sourceTypeId !== source.objectTypeId || row.sourceId !== source.primaryId) continue\n const snapshots = snapshotsByLinkId.get(row.linkId)\n if (!snapshots) continue\n const snapshot = toLinkSnapshot(row)\n if (!snapshot) {\n // Same rule `observeObject` applies to rows without materializer provenance: record no\n // expectation at all. A fingerprint computed over the remaining rows would describe a scope\n // the store can never reproduce, turning every such read into a guaranteed conflict.\n unfenceable.add(row.linkId)\n continue\n }\n snapshots.push(snapshot)\n this.observeLink(snapshot.ref, snapshot)\n }\n\n for (const [linkId, snapshots] of snapshotsByLinkId) {\n if (unfenceable.has(linkId)) continue\n const key = linkScopeKey(source, linkId)\n if (this.linkScopes.has(key)) continue\n this.linkScopes.set(key, {\n source,\n linkId,\n fingerprint: createLinkScopeFingerprint(snapshots),\n })\n }\n }\n\n /** Records a concrete link read, including exact absence. */\n observeLink(ref: OntologyLinkRef, snapshot: EffectiveLinkSnapshot | null): void {\n const key = linkRefKey(ref)\n if (this.links.has(key)) return\n this.links.set(\n key,\n snapshot ? { ref, exists: true, lastCommitId: snapshot.lastCommitId } : { ref, exists: false }\n )\n }\n\n dependencies(): ActionReadDependencies {\n return {\n objects: [...this.objects.values()],\n links: [...this.links.values()],\n linkScopes: [...this.linkScopes.values()],\n }\n }\n}\n\nexport interface ActionReadFacadeOptions {\n /** Records what the handler observed, so the commit can be fenced against it. */\n readonly recorder: ActionReadRecorder\n /**\n * Every link the object type carries, inherited links included.\n *\n * Inheritance is resolved by the Ontology registry, not by the imported definition, so an\n * `extends` type would otherwise report only its own links and drop inherited ones from the\n * recorded scopes.\n */\n readonly resolveLinkIds: (objectTypeId: string) => readonly string[]\n /** Canonical authorized telemetry history leaf. Omitted only by isolated facade consumers. */\n readonly telemetry?: ActionTelemetryReadSource\n}\n\n/** Exposes `reader`'s object reads to an Action handler; with `options`, each read is recorded. */\nexport function createActionReadFacade(\n reader: ObjectReader,\n options?: ActionReadFacadeOptions\n): ActionReadFacade {\n return {\n telemetry: createActionTelemetryReadFacade(options?.telemetry),\n objects<const TObjectType extends ObjectTypeWithPropertyTokens>(objectType: TObjectType) {\n const objectSet = reader.objects(objectType)\n return options ? recordObjectReads(objectType, objectSet, options) : objectSet\n },\n }\n}\n\nfunction createActionTelemetryReadFacade(\n source: ActionTelemetryReadSource | undefined\n): ActionTelemetryReadFacade {\n const facade = {\n async historyBatch(input: {\n readonly series: readonly ActionTelemetryHistorySeriesInput[]\n readonly from?: Date\n readonly to?: Date\n readonly limitPerSeries?: number\n readonly order?: \"asc\" | \"desc\"\n }) {\n if (!source) {\n throw new RuntimeError(\n \"[Sixb] Action telemetry history requires a configured telemetry read source.\"\n )\n }\n if (input.series.length === 0) {\n return []\n }\n\n const requestedSeries = input.series.map((entry) => {\n const objectType = source.resolveObjectType(entry.property.objectTypeId)\n assertPropertyTokenBelongsToObjectType(objectType, entry.property)\n const registeredProperty = objectType.properties.find(\n (property) => property.id === entry.property.id\n )\n if (!registeredProperty) {\n throw new OntologyValidationError(\n `[Sixb] Unknown property '${entry.property.id}' for object type '${objectType.id}'`\n )\n }\n assertTelemetryProperty(registeredProperty)\n return {\n objectTypeId: objectType.id,\n objectId: entry.objectId,\n propertyId: registeredProperty.id,\n }\n })\n\n const results = await source.getHistoryBatch({\n series: requestedSeries,\n ...(input.from !== undefined ? { from: input.from } : {}),\n ...(input.to !== undefined ? { to: input.to } : {}),\n ...(input.limitPerSeries !== undefined ? { limitPerSeries: input.limitPerSeries } : {}),\n ...(input.order !== undefined ? { order: input.order } : {}),\n })\n assertTelemetryBatchResultMatchesRequest(requestedSeries, results)\n\n return input.series.map((entry, index) => ({\n objectId: entry.objectId,\n property: entry.property,\n points: results[index].points.map((point) => ({\n value: point.value,\n at: point.at,\n ...(point.unit !== undefined ? { unit: point.unit } : {}),\n })),\n }))\n },\n }\n\n // Cast needed at the generic token boundary: the implementation deliberately manipulates raw\n // provider values while the public facade maps every tuple position back to its property token.\n return facade as unknown as ActionTelemetryReadFacade\n}\n\nfunction assertTelemetryBatchResultMatchesRequest(\n requested: readonly {\n readonly objectTypeId: string\n readonly objectId: string\n readonly propertyId: string\n }[],\n results: readonly TimeseriesHistoryBatchResult[]\n): void {\n if (results.length !== requested.length) {\n throw new RuntimeError(\n `[Sixb] Telemetry history provider returned ${results.length} batch results for ${requested.length} requested series.`\n )\n }\n\n for (let index = 0; index < requested.length; index += 1) {\n const expected = requested[index]\n const actual = results[index]\n if (\n actual.objectTypeId !== expected.objectTypeId ||\n actual.objectId !== expected.objectId ||\n actual.propertyId !== expected.propertyId\n ) {\n throw new RuntimeError(\n `[Sixb] Telemetry history provider returned an unexpected series at batch index ${index}.`\n )\n }\n }\n}\n\nfunction recordObjectReads<TObjectType extends ObjectTypeWithPropertyTokens>(\n objectType: TObjectType,\n objectSet: ObjectReadSet<TObjectType>,\n options: ActionReadFacadeOptions\n): ObjectReadSet<TObjectType> {\n const { recorder } = options\n const ref = (primaryId: string): OntologyObjectRef => ({\n objectTypeId: objectType.id,\n primaryId,\n })\n\n return {\n async get(id) {\n const row = await objectSet.get(id)\n recorder.observeObject(ref(id), row && storageRow(row))\n return row\n },\n query() {\n // Recording at the executor covers every terminal of every refinement, present and future.\n return decorateObjectQueryExecutor(objectSet.query(), (executor) =>\n recordingExecutor(executor, recorder)\n )\n },\n async list(input) {\n const result = await objectSet.list(input)\n recorder.observeObjectRows(result.objects.map(storageRow))\n return result\n },\n byId(id) {\n const handle = objectSet.byId(id)\n return {\n async get() {\n const row = await handle.get()\n recorder.observeObject(ref(id), row && storageRow(row))\n return row\n },\n async listLinks(link) {\n const rows = await handle.listLinks(link)\n recorder.observeLinkScopes(\n ref(id),\n link ? [link.id] : options.resolveLinkIds(objectType.id),\n rows\n )\n return rows\n },\n }\n },\n }\n}\n\n/**\n * Delegates to `executor` and records the objects its row queries return.\n *\n * Aggregates (`count()`, `exists()`, `facets()`) return no rows to fence; protecting their result\n * needs query-level dependencies.\n */\nfunction recordingExecutor(\n executor: ObjectQueryExecutor,\n recorder: ActionReadRecorder\n): ObjectQueryExecutor {\n return {\n async list(query, listOptions) {\n const result = await executor.list(query, listOptions)\n recorder.observeObjectRows(result.objects.map(storageRow))\n return result\n },\n count: (query) => executor.count(query),\n exists: (query) => executor.exists(query),\n facets: (query, facets) => executor.facets(query, facets),\n validate: executor.validate?.bind(executor),\n explain: executor.explain?.bind(executor),\n }\n}\n\n/**\n * Runtime reads return storage rows; the SDK row types only leave out the commit fields a fence\n * needs.\n */\nfunction storageRow(row: object): ObjectRow {\n return row as ObjectRow\n}\n\nfunction expandedRows(value: ExpandedLinkValue): readonly ObjectRow[] {\n if (value === null) return []\n return isExpandedRowList(value) ? value : [value]\n}\n\n// `Array.isArray` does not narrow a readonly array out of a union.\nfunction isExpandedRowList(value: ExpandedLinkValue): value is readonly ExpandedObjectRow[] {\n return Array.isArray(value)\n}\n\nfunction toLinkSnapshot(row: ObjectLinkRow): EffectiveLinkSnapshot | null {\n // Rows without materializer provenance predate the commit ledger and cannot be fenced.\n if (row.lastCommitId === undefined) return null\n return {\n ref: {\n source: { objectTypeId: row.sourceTypeId, primaryId: row.sourceId },\n linkId: row.linkId,\n target: { objectTypeId: row.targetTypeId, primaryId: row.targetId },\n },\n ...(row.properties !== undefined\n ? { properties: row.properties as EffectiveLinkSnapshot[\"properties\"] }\n : {}),\n createdAt: row.createdAt.toISOString(),\n updatedAt: row.updatedAt.toISOString(),\n lastCommitId: row.lastCommitId,\n }\n}\n",
9
+ "import type { ObjectType, OntologyDefinitionCatalog } from \"../ontology\"\nimport {\n ActionDefinitionError,\n effectsWithoutEditsMessage,\n missingActionMutationMessage,\n} from \"./errors\"\nimport type { ActionDefinition, ObjectActionDefinition } from \"./types\"\nimport { isObjectActionDefinition } from \"./validation\"\n\nexport interface ActionDefinitionCatalog {\n list(): readonly ActionDefinition[]\n getById(id: string): ActionDefinition | null\n listGlobal(): readonly ActionDefinition[]\n listForType(type: ObjectType): readonly ObjectActionDefinition[]\n}\n\nexport interface ActionRegistryOptions {\n readonly actions: readonly ActionDefinition[]\n readonly ontology: OntologyDefinitionCatalog\n}\n\nexport class ActionRegistry implements ActionDefinitionCatalog {\n private readonly byId = new Map<string, ActionDefinition>()\n private readonly globalActions: ActionDefinition[] = []\n private readonly byTargetId = new Map<string, ObjectActionDefinition[]>()\n\n private readonly ontology: OntologyDefinitionCatalog\n\n constructor(options: ActionRegistryOptions) {\n this.ontology = options.ontology\n\n for (const action of options.actions) {\n const previous = this.byId.get(action.id)\n if (previous) {\n const chainDuplicate = this.getInheritanceDuplicate(action, previous)\n if (chainDuplicate) {\n throw new ActionDefinitionError(\n `Duplicate action id \"${action.id}\" in inheritance chain of \"${chainDuplicate.objectTypeId}\": defined on both \"${chainDuplicate.firstTargetId}\" and \"${chainDuplicate.secondTargetId}\".`\n )\n }\n\n throw new ActionDefinitionError(\n `Duplicate action id \"${action.id}\" declared in multiple files.`\n )\n }\n\n this.validatePhases(action)\n this.byId.set(action.id, action)\n\n if (!isObjectActionDefinition(action)) {\n this.globalActions.push(action)\n continue\n }\n\n const objectType = action.binding.objectType\n const target = this.ontology.getObjectTypeById(objectType.id)\n if (!target) {\n throw new ActionDefinitionError(\n `Action \"${action.id}\" targets unknown object type \"${objectType.id}\". Add the object type to ontology before registering the action.`\n )\n }\n\n const bucket = this.byTargetId.get(objectType.id) ?? []\n bucket.push(action)\n this.byTargetId.set(objectType.id, bucket)\n }\n }\n\n private validatePhases(action: ActionDefinition): void {\n const hasWriteback = action.phases.writeback !== undefined\n const hasEdits = action.phases.edits !== undefined\n const hasEffects = action.phases.effects !== undefined\n\n if (!hasWriteback && !hasEdits) {\n throw new ActionDefinitionError(missingActionMutationMessage(action.id))\n }\n\n if (hasEffects && !hasEdits) {\n throw new ActionDefinitionError(effectsWithoutEditsMessage(action.id))\n }\n }\n\n list(): readonly ActionDefinition[] {\n return [...this.byId.values()]\n }\n\n getById(id: string): ActionDefinition | null {\n return this.byId.get(id) ?? null\n }\n\n listGlobal(): readonly ActionDefinition[] {\n return [...this.globalActions]\n }\n\n listForType(type: ObjectType): readonly ObjectActionDefinition[] {\n this.ontology.resolveObjectType(type.id)\n\n const seen = new Set<string>()\n const result: ObjectActionDefinition[] = []\n\n for (const ancestor of this.ontology.listAncestorChain(type)) {\n for (const action of this.byTargetId.get(ancestor.id) ?? []) {\n if (seen.has(action.id)) continue\n seen.add(action.id)\n result.push(action)\n }\n }\n\n return result\n }\n\n private getInheritanceDuplicate(\n action: ActionDefinition,\n previous: ActionDefinition\n ): { objectTypeId: string; firstTargetId: string; secondTargetId: string } | null {\n if (!isObjectActionDefinition(action) || !isObjectActionDefinition(previous)) {\n return null\n }\n\n const actionObjectType = action.binding.objectType\n const previousObjectType = previous.binding.objectType\n\n if (actionObjectType.id === previousObjectType.id) {\n return null\n }\n\n const actionChain = this.ontology.listAncestorChain(actionObjectType)\n if (actionChain.some((ancestor) => ancestor.id === previousObjectType.id)) {\n return {\n objectTypeId: actionObjectType.id,\n firstTargetId: previousObjectType.id,\n secondTargetId: actionObjectType.id,\n }\n }\n\n const previousChain = this.ontology.listAncestorChain(previousObjectType)\n if (previousChain.some((ancestor) => ancestor.id === actionObjectType.id)) {\n return {\n objectTypeId: previousObjectType.id,\n firstTargetId: actionObjectType.id,\n secondTargetId: previousObjectType.id,\n }\n }\n\n return null\n }\n}\n",
10
+ "import { ActionValidationError } from \"../objects/action/errors\"\nimport type { ActionDefinition, ActionSubject, ActionTargetObject } from \"./types\"\nimport { isObjectActionDefinition } from \"./validation\"\n\ntype RuntimePhaseHandler = (ctx: unknown) => unknown | Promise<unknown>\n\nexport async function runActionValidators<TBaseContext extends object>(input: {\n readonly action: ActionDefinition\n readonly subject: ActionSubject\n readonly baseContext: TBaseContext\n readonly target?: ActionTargetObject | null\n}): Promise<void> {\n const validators = input.action.phases.validate as readonly RuntimePhaseHandler[]\n if (validators.length === 0) {\n return\n }\n\n if (!isObjectActionDefinition(input.action)) {\n for (const validator of validators) {\n const result = await validator(input.baseContext)\n if (isValidatorErrorResult(result)) {\n throw new ActionValidationError(result.error, {\n actionId: input.action.id,\n subject: input.subject,\n })\n }\n }\n return\n }\n\n if (!input.target) {\n throw new Error(`[Sixb] Action '${input.action.id}' requires an object target.`)\n }\n\n for (const validator of validators) {\n const result = await validator({\n ...input.baseContext,\n target: input.target,\n })\n if (isValidatorErrorResult(result)) {\n throw new ActionValidationError(result.error, {\n actionId: input.action.id,\n subject: input.subject,\n })\n }\n }\n}\n\nfunction isValidatorErrorResult(value: unknown): value is { readonly error: string } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"error\" in value &&\n typeof value.error === \"string\"\n )\n}\n"
11
+ ],
12
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBO,SAAS,aAAsC,CACpD,IACA,SACoB;AAAA,EACpB,gBAAe,IAAI,IAAI;AAAA,EAEvB,OAAO,mBAAuC,oBAAoB,IAAI,OAAO,CAAC;AAAA;AAGhF,SAAS,mBAAmB,CAAC,IAAY,SAAyB;AAAA,EAChE,MAAM,UAAU;AAAA,IACd,MAAM,CAAC,QAA4B;AAAA,MACjC,OAAO,+BAA+B,IAAI,QAAQ,OAAO;AAAA;AAAA,IAE3D,EAAE,CAAC,YAA0C;AAAA,MAC3C,gBAAe,WAAW,IAAI,WAAW;AAAA,MACzC,OAAO,gCAAgC,IAAI,YAAY,OAAO;AAAA;AAAA,EAElE;AAAA,EAEA,OAAO;AAAA;AAGT,SAAS,8BAA8B,CACrC,IACA,QACA,SACsD;AAAA,EACtD,MAAM,aAA+D,CAAC;AAAA,EAEtE,MAAM,UAAU;AAAA,IACd,QAAQ,CAAC,WAA2D;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IACjB,MAAM,IAAI,MAAM,kBAAkB,MAAM,OAAO,gCAAgC;AAAA,EACjF;AAAA,EAEA,WAAW,aAAa,YAAY;AAAA,IAClC,MAAM,SAAS,MAAM,UAAU;AAAA,SAC1B,MAAM;AAAA,MACT,QAAQ,MAAM;AAAA,IAChB,CAAC;AAAA,IACD,IAAI,uBAAuB,MAAM,GAAG;AAAA,MAClC,MAAM,IAAI,uBAAsB,OAAO,OAAO;AAAA,QAC5C,UAAU,MAAM,OAAO;AAAA,QACvB,SAAS,MAAM;AAAA,MACjB,CAAC;AAAA,IACH;AAAA,EACF;AAAA;AAGF,SAAS,sBAAsB,CAAC,OAAqD;AAAA,EACnF,OACE,OAAO,UAAU,YACjB,UAAU,QACV,WAAW,SACX,OAAO,MAAM,UAAU;AAAA;",
13
+ "debugId": "1D163836FC4D0FDC64756E2164756E21",
14
+ "names": []
15
+ }
@@ -7,13 +7,13 @@ import {
7
7
  ConnectorError2,
8
8
  createConnectorCodedError,
9
9
  getConnectorExecutionSourceResolver
10
- } from "./chunk-xtfryrfb.js";
10
+ } from "./chunk-cbn96bve.js";
11
11
  import {
12
12
  isDatasetDefinition2
13
13
  } from "./chunk-cd234ba4.js";
14
14
  import {
15
15
  SyncValidationError2
16
- } from "./chunk-jjwhy3rs.js";
16
+ } from "./chunk-q2xghyft.js";
17
17
  import {
18
18
  isOAuthConnectorAdapter,
19
19
  isConnectorDefinition
@@ -1,23 +1,15 @@
1
1
  // @bun
2
+ import {
3
+ isPrimitiveSchema
4
+ } from "./chunk-d8yes9yx.js";
2
5
  import {
3
6
  isPlainRecord
4
7
  } from "./chunk-wy0qdqfm.js";
5
8
 
6
9
  // src/ontology/validation/definition.ts
7
- var PRIMITIVE_SCHEMAS = new Set([
8
- "string",
9
- "integer",
10
- "double",
11
- "decimal",
12
- "boolean",
13
- "date",
14
- "timestamp",
15
- "uuid",
16
- "fileRef"
17
- ]);
18
10
  function assertValidSchema(schema, path, invalid, visiting = new Set) {
19
11
  if (typeof schema === "string") {
20
- if (PRIMITIVE_SCHEMAS.has(schema)) {
12
+ if (isPrimitiveSchema(schema)) {
21
13
  return;
22
14
  }
23
15
  throw invalid(path);
@@ -90,4 +82,4 @@ function isValidEnumValues(values, valueType) {
90
82
 
91
83
  export { assertValidSchema };
92
84
 
93
- //# debugId=3AF3C78456A4B4F964756E2164756E21
85
+ //# debugId=6F187C1748947F4164756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/ontology/validation/definition.ts"],
4
+ "sourcesContent": [
5
+ "import { isPlainRecord } from \"../../json\"\nimport { isPrimitiveSchema } from \"../primitives\"\n\n/** Validate a declarative schema's shape independently of the primitive that consumes it. */\nexport function assertValidSchema(\n schema: unknown,\n path: string,\n invalid: (path: string) => Error,\n visiting: Set<object> = new Set()\n): void {\n if (typeof schema === \"string\") {\n if (isPrimitiveSchema(schema)) {\n return\n }\n throw invalid(path)\n }\n if (!isPlainRecord(schema) || typeof schema.type !== \"string\" || visiting.has(schema)) {\n throw invalid(path)\n }\n\n visiting.add(schema)\n switch (schema.type) {\n case \"enum\": {\n const values = schema.values\n const validValues = isValidEnumValues(values, schema.valueType)\n if (!validValues || new Set(values).size !== values.length) {\n throw invalid(path)\n }\n break\n }\n case \"array\":\n assertValidSchema(schema.items, `${path}.items`, invalid, visiting)\n break\n case \"map\":\n if (schema.keySchema !== \"string\") {\n throw invalid(path)\n }\n assertValidSchema(schema.valueSchema, `${path}.valueSchema`, invalid, visiting)\n break\n case \"object\": {\n if (!isPlainRecord(schema.properties)) {\n throw invalid(path)\n }\n for (const [fieldId, field] of Object.entries(schema.properties)) {\n if (!fieldId.trim() || !isPlainRecord(field) || !(\"schema\" in field)) {\n throw invalid(`${path}.properties.${fieldId}`)\n }\n if (\n (field.required !== undefined && typeof field.required !== \"boolean\") ||\n (field.nullable !== undefined && typeof field.nullable !== \"boolean\") ||\n (field.description !== undefined &&\n (typeof field.description !== \"string\" || !field.description.trim()))\n ) {\n throw invalid(`${path}.properties.${fieldId}`)\n }\n assertValidSchema(field.schema, `${path}.properties.${fieldId}.schema`, invalid, visiting)\n }\n break\n }\n case \"valueTypeRef\":\n if (typeof schema.valueTypeId !== \"string\" || !schema.valueTypeId.trim()) {\n throw invalid(path)\n }\n if (schema._resolved !== undefined) {\n assertValidSchema(schema._resolved, `${path}._resolved`, invalid, visiting)\n }\n break\n default:\n throw invalid(path)\n }\n visiting.delete(schema)\n}\n\nfunction isValidEnumValues(values: unknown, valueType: unknown): values is unknown[] {\n if (!Array.isArray(values) || values.length === 0) {\n return false\n }\n\n for (let index = 0; index < values.length; index += 1) {\n if (!Object.hasOwn(values, index)) {\n return false\n }\n const value = values[index]\n if (\n valueType === \"string\"\n ? typeof value !== \"string\"\n : valueType !== \"integer\" || typeof value !== \"number\" || !Number.isInteger(value)\n ) {\n return false\n }\n }\n return true\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;AAIO,SAAS,iBAAiB,CAC/B,QACA,MACA,SACA,WAAwB,IAAI,KACtB;AAAA,EACN,IAAI,OAAO,WAAW,UAAU;AAAA,IAC9B,IAAI,kBAAkB,MAAM,GAAG;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,MAAM,QAAQ,IAAI;AAAA,EACpB;AAAA,EACA,IAAI,CAAC,cAAc,MAAM,KAAK,OAAO,OAAO,SAAS,YAAY,SAAS,IAAI,MAAM,GAAG;AAAA,IACrF,MAAM,QAAQ,IAAI;AAAA,EACpB;AAAA,EAEA,SAAS,IAAI,MAAM;AAAA,EACnB,QAAQ,OAAO;AAAA,SACR,QAAQ;AAAA,MACX,MAAM,SAAS,OAAO;AAAA,MACtB,MAAM,cAAc,kBAAkB,QAAQ,OAAO,SAAS;AAAA,MAC9D,IAAI,CAAC,eAAe,IAAI,IAAI,MAAM,EAAE,SAAS,OAAO,QAAQ;AAAA,QAC1D,MAAM,QAAQ,IAAI;AAAA,MACpB;AAAA,MACA;AAAA,IACF;AAAA,SACK;AAAA,MACH,kBAA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AyC;AAAA,EACnF,IAAI,CAAC,MAAM,QAAQ,MAAM,KAAK,OAAO,WAAW,GAAG;AAAA,IACjD,OAAO;AAAA,EACT;AAAA,EAEA,SAAS,QAAQ,EAAG,QAAQ,OAAO,QAAQ,SAAS,GAAG;AAAA,IACrD,IAAI,CAAC,OAAO,OAAO,QAAQ,KAAK,GAAG;AAAA,MACjC,OAAO;AAAA,IACT;AAAA,IACA,MAAM,QAAQ,OAAO;AAAA,IACrB,IACE,cAAc,WACV,OAAO,UAAU,WACjB,cAAc,aAAa,OAAO,UAAU,YAAY,CAAC,OAAO,UAAU,KAAK,GACnF;AAAA,MACA,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,OAAO;AAAA;",
8
+ "debugId": "6F187C1748947F4164756E2164756E21",
9
+ "names": []
10
+ }
@@ -1,16 +1,16 @@
1
1
  // @bun
2
+ import {
3
+ AuthStorageError2,
4
+ SYSTEM_PRINCIPAL2,
5
+ principalsEqual2
6
+ } from "./chunk-6rzb1g6h.js";
2
7
  import {
3
8
  agentServiceAccountId2,
4
9
  resolveAuthorizationContext2
5
- } from "./chunk-bbaa1fet.js";
10
+ } from "./chunk-rzcjp5m2.js";
6
11
  import {
7
12
  createSixbError2
8
- } from "./chunk-hzw7yv5g.js";
9
- import {
10
- AuthStorageError2,
11
- SYSTEM_PRINCIPAL2,
12
- principalsEqual2
13
- } from "./chunk-2cxv584m.js";
13
+ } from "./chunk-rzkr70gr.js";
14
14
  import {
15
15
  findPrimitiveRunExecution,
16
16
  findAgentRunExecution
@@ -210,7 +210,7 @@ function isUsableUserSession(session, userId, now) {
210
210
  return session.absoluteExpiresAt === undefined || session.absoluteExpiresAt.getTime() > now.getTime();
211
211
  }
212
212
  function isUsableUserAccessToken(token, userId, now) {
213
- if (!token || token.subjectType !== "user" || token.subjectId !== userId)
213
+ if (!token || !principalsEqual2(token.subject, { type: "user", id: userId }))
214
214
  return false;
215
215
  return token.revokedAt === undefined && token.expiresAt.getTime() > now.getTime();
216
216
  }
@@ -281,4 +281,4 @@ function invalidExecution(executionId, runId) {
281
281
 
282
282
  export { WorkflowRunError2, ensureManagedAgentExecutionIdentity2, resolveAgentExecutionAuthorization2, resolveInheritedAgentExecutionAuthorization2, assertWorkflowRunExecution2, assertWorkflowAgentNodeRunExecution2 };
283
283
 
284
- //# debugId=E7BAFA86A352672B64756E2164756E21
284
+ //# debugId=F5DA9E9C95A4C18E64756E2164756E21
@@ -2,11 +2,11 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/agents/authority.ts", "../src/storage/workflow-runs/errors.ts", "../src/storage/workflow-runs/provider.ts"],
4
4
  "sourcesContent": [
5
- "import { principalsEqual, SYSTEM_PRINCIPAL } from \"../auth\"\nimport type { AuthorizationContext } from \"../authorization\"\nimport { resolveAuthorizationContext } from \"../authorization\"\nimport { createSixbError } from \"../errors/internal\"\nimport type { AuthorizablePrincipal, AuthorizationRef } from \"../execution\"\nimport type { SecurityDefinitionCatalog } from \"../security\"\nimport type {\n AccessTokenRecord,\n AuthStorage,\n ServiceAccountGroupMembershipRecord,\n ServiceAccountRecord,\n SessionRecord,\n UserRecord,\n} from \"../storage/auth\"\nimport { AuthStorageError } from \"../storage/auth\"\nimport { agentServiceAccountId } from \"./identity\"\n\nexport type AgentExecutionAuthorization =\n | { readonly type: \"principal\"; readonly context: AuthorizationContext }\n | { readonly type: \"disabled\" }\n\ntype UserCredentialRef = NonNullable<\n Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]\n>\n\ninterface CredentialedUserAuthorizationRef {\n readonly type: \"principal\"\n readonly principal: Extract<AuthorizablePrincipal, { readonly type: \"user\" }>\n readonly credential: UserCredentialRef\n}\n\nexport { agentServiceAccountId } from \"./identity\"\n\nexport interface AgentExecutionIdentity {\n readonly serviceAccount: ServiceAccountRecord\n readonly principal: Extract<AuthorizablePrincipal, { readonly type: \"serviceAccount\" }>\n readonly groupMemberships: readonly ServiceAccountGroupMembershipRecord[]\n}\n\n/** Ensure a framework-managed Agent actor exists with exactly its declared group memberships. */\nexport async function ensureManagedAgentExecutionIdentity(input: {\n readonly auth: AuthStorage | undefined\n readonly projectId: string\n readonly actorId: string\n readonly name: string\n readonly description: string\n readonly groupIds: readonly string[]\n}): Promise<AgentExecutionIdentity> {\n const auth = requireAuthStorage(input.auth)\n const id = agentServiceAccountId(input.actorId)\n const now = new Date()\n const loaded = await loadOrCreateAgentServiceAccount(auth, {\n id,\n projectId: input.projectId,\n name: input.name,\n description: input.description,\n updatedAt: now,\n })\n assertFrameworkManagedAgentServiceAccount(input.actorId, loaded)\n assertActiveAgentServiceAccount(input.actorId, loaded)\n const serviceAccount = await updateAgentServiceAccountMetadata(auth, {\n existing: loaded,\n name: input.name,\n description: input.description,\n updatedAt: now,\n })\n assertActiveAgentServiceAccount(input.actorId, serviceAccount)\n\n const groupMemberships = requireDefinitionOwnedGroupMemberships(\n input.actorId,\n await auth.serviceAccountGroupMemberships.reconcileForServiceAccount({\n projectId: input.projectId,\n serviceAccountId: id,\n groupIds: input.groupIds,\n source: \"agent\",\n updatedAt: now,\n })\n )\n\n return {\n serviceAccount,\n principal: { type: \"serviceAccount\", id },\n groupMemberships,\n }\n}\n\n/** Load the managed identity, recovering only the expected concurrent-create race. */\nasync function loadOrCreateAgentServiceAccount(\n auth: AuthStorage,\n input: {\n readonly id: string\n readonly projectId: string\n readonly name: string\n readonly description: string\n readonly updatedAt: Date\n }\n): Promise<ServiceAccountRecord> {\n const existing = await auth.serviceAccounts.getById({\n projectId: input.projectId,\n id: input.id,\n })\n if (existing) return existing\n\n try {\n return await auth.serviceAccounts.create({\n id: input.id,\n projectId: input.projectId,\n name: input.name,\n description: input.description,\n status: \"active\",\n createdByPrincipal: SYSTEM_PRINCIPAL,\n createdAt: input.updatedAt,\n updatedAt: input.updatedAt,\n })\n } catch (error) {\n if (!(error instanceof AuthStorageError) || error.code !== \"duplicate_service_account\") {\n throw error\n }\n const concurrent = await auth.serviceAccounts.getById({\n projectId: input.projectId,\n id: input.id,\n })\n if (!concurrent) throw error\n return concurrent\n }\n}\n\nfunction assertActiveAgentServiceAccount(\n actorId: string,\n serviceAccount: ServiceAccountRecord\n): void {\n if (serviceAccount.status === \"suspended\") {\n throw new Error(\n `[Sixb] Agent '${actorId}' service account '${serviceAccount.id}' is suspended.`\n )\n }\n}\n\nfunction assertFrameworkManagedAgentServiceAccount(\n actorId: string,\n serviceAccount: ServiceAccountRecord\n): void {\n if (\n serviceAccount.createdByPrincipal === undefined ||\n !principalsEqual(serviceAccount.createdByPrincipal, SYSTEM_PRINCIPAL)\n ) {\n throw createSixbError(\n \"agent.execution_failed\",\n `[Sixb] Agent '${actorId}' cannot use service account '${serviceAccount.id}' because it is not managed by Sixb.`,\n { details: { actorId, serviceAccountId: serviceAccount.id } }\n )\n }\n}\n\nfunction requireDefinitionOwnedGroupMemberships(\n actorId: string,\n memberships: readonly ServiceAccountGroupMembershipRecord[]\n): readonly ServiceAccountGroupMembershipRecord[] {\n const externalGroupIds = memberships\n .filter((membership) => membership.source !== \"agent\")\n .map((membership) => membership.groupId)\n if (externalGroupIds.length > 0) {\n throw createSixbError(\n \"agent.execution_failed\",\n `[Sixb] Agent '${actorId}' service account has group memberships not managed by its definition: ${externalGroupIds.join(\", \")}.`,\n { details: { actorId, externalGroupIds } }\n )\n }\n return memberships\n}\n\n/** Resolve current grants for the service account referenced by a durable Agent execution. */\nexport async function resolveAgentExecutionAuthorization(input: {\n readonly auth: AuthStorage | undefined\n readonly projectId: string\n readonly actorId: string\n readonly authorizationRef: AuthorizationRef\n readonly security: SecurityDefinitionCatalog\n}): Promise<{ readonly identity: AgentExecutionIdentity; readonly context: AuthorizationContext }> {\n const auth = requireAuthStorage(input.auth)\n const expectedId = agentServiceAccountId(input.actorId)\n const principal =\n input.authorizationRef.type === \"principal\" ? input.authorizationRef.principal : null\n if (principal?.type !== \"serviceAccount\" || principal.id !== expectedId) {\n throw new Error(\n `[Sixb] Agent '${input.actorId}' execution authority must reference service account '${expectedId}'.`\n )\n }\n\n const serviceAccount = await auth.serviceAccounts.getById({\n projectId: input.projectId,\n id: principal.id,\n })\n if (!serviceAccount || serviceAccount.status !== \"active\") {\n throw new Error(`[Sixb] Agent service account '${principal.id}' is not active.`)\n }\n assertFrameworkManagedAgentServiceAccount(input.actorId, serviceAccount)\n\n const groupMemberships = requireDefinitionOwnedGroupMemberships(\n input.actorId,\n await auth.serviceAccountGroupMemberships.listForServiceAccount({\n projectId: input.projectId,\n serviceAccountId: principal.id,\n })\n )\n const identity: AgentExecutionIdentity = {\n serviceAccount,\n principal: { type: \"serviceAccount\", id: principal.id },\n groupMemberships,\n }\n return {\n identity,\n context: resolveAuthorizationContext({\n principal: identity.principal,\n groupIds: groupMemberships.map((membership) => membership.groupId),\n roles: input.security.listResolvedRoles(),\n }),\n }\n}\n\n/** Revalidate the durable user authority inherited by a conversational or child Agent. */\nexport async function resolveInheritedAgentExecutionAuthorization(input: {\n readonly auth: AuthStorage | undefined\n readonly projectId: string\n readonly authorizationRef: AuthorizationRef\n readonly security: SecurityDefinitionCatalog\n readonly now?: Date\n}): Promise<AgentExecutionAuthorization> {\n if (input.authorizationRef.type === \"disabled\") return { type: \"disabled\" }\n\n const ref = requireCredentialedUserAuthority(input.authorizationRef)\n const auth = requireAuthStorage(input.auth)\n const now = input.now ?? new Date()\n const user = await requireActiveUser(auth, input.projectId, ref.principal.id)\n const memberships = await auth.groupMemberships.listForUser({\n projectId: input.projectId,\n userId: user.id,\n })\n const credential = await revalidateUserCredential({\n auth,\n projectId: input.projectId,\n userId: user.id,\n credential: ref.credential,\n currentGroupIds: memberships.map((membership) => membership.groupId),\n now,\n })\n\n return {\n type: \"principal\",\n context: resolveAuthorizationContext({\n principal: ref.principal,\n groupIds: credential.groupIds,\n roles: input.security.listResolvedRoles(),\n ...(credential.sessionId === undefined ? {} : { sessionId: credential.sessionId }),\n }),\n }\n}\n\nfunction requireCredentialedUserAuthority(ref: AuthorizationRef): CredentialedUserAuthorizationRef {\n if (ref.type !== \"principal\" || ref.principal.type !== \"user\" || ref.credential === undefined) {\n throw invalidInheritedAuthority(\"the durable reference is not a credentialed user\")\n }\n return {\n type: \"principal\",\n principal: { type: \"user\", id: ref.principal.id },\n credential: { type: ref.credential.type, id: ref.credential.id },\n }\n}\n\nasync function requireActiveUser(\n auth: AuthStorage,\n projectId: string,\n userId: string\n): Promise<UserRecord> {\n const user = await auth.users.getById({ projectId, id: userId })\n if (!user || user.status !== \"active\") {\n throw invalidInheritedAuthority(`user '${userId}' is not active`)\n }\n return user\n}\n\nasync function revalidateUserCredential(input: {\n readonly auth: AuthStorage\n readonly projectId: string\n readonly userId: string\n readonly credential: UserCredentialRef\n readonly currentGroupIds: readonly string[]\n readonly now: Date\n}): Promise<{ readonly groupIds: readonly string[]; readonly sessionId?: string }> {\n if (input.credential.type === \"session\") {\n const session = await input.auth.sessions.getById({\n projectId: input.projectId,\n id: input.credential.id,\n })\n if (!isUsableUserSession(session, input.userId, input.now)) {\n throw invalidInheritedAuthority(\"the inherited session is no longer valid\")\n }\n return { groupIds: input.currentGroupIds, sessionId: session.id }\n }\n\n const accessToken = await input.auth.accessTokens.getById({\n projectId: input.projectId,\n id: input.credential.id,\n })\n if (!isUsableUserAccessToken(accessToken, input.userId, input.now)) {\n throw invalidInheritedAuthority(\"the inherited access token is no longer valid\")\n }\n if (accessToken.groupIds === undefined) return { groupIds: input.currentGroupIds }\n\n const allowedGroupIds = new Set(accessToken.groupIds)\n return {\n groupIds: input.currentGroupIds.filter((groupId) => allowedGroupIds.has(groupId)),\n }\n}\n\nfunction isUsableUserSession(\n session: SessionRecord | null,\n userId: string,\n now: Date\n): session is SessionRecord {\n if (!session || session.userId !== userId || session.revokedAt !== undefined) return false\n if (session.expiresAt.getTime() <= now.getTime()) return false\n return (\n session.absoluteExpiresAt === undefined || session.absoluteExpiresAt.getTime() > now.getTime()\n )\n}\n\nfunction isUsableUserAccessToken(\n token: AccessTokenRecord | null,\n userId: string,\n now: Date\n): token is AccessTokenRecord {\n if (!token || token.subjectType !== \"user\" || token.subjectId !== userId) return false\n return token.revokedAt === undefined && token.expiresAt.getTime() > now.getTime()\n}\n\nfunction invalidInheritedAuthority(reason: string): Error {\n return createSixbError(\n \"agent.execution_failed\",\n `[Sixb] The Agent execution cannot restore its inherited authority: ${reason}.`\n )\n}\n\nfunction requireAuthStorage(auth: AuthStorage | undefined): AuthStorage {\n if (!auth) {\n throw new Error(\"[Sixb] Agent executions require auth storage.\")\n }\n return auth\n}\n\nasync function updateAgentServiceAccountMetadata(\n auth: AuthStorage,\n input: {\n readonly existing: ServiceAccountRecord\n readonly name: string\n readonly description: string\n readonly updatedAt: Date\n }\n): Promise<ServiceAccountRecord> {\n if (input.existing.name === input.name && input.existing.description === input.description) {\n return input.existing\n }\n return auth.serviceAccounts.update({\n projectId: input.existing.projectId,\n id: input.existing.id,\n name: input.name,\n description: input.description,\n updatedAt: input.updatedAt,\n })\n}\n",
5
+ "import { principalsEqual, SYSTEM_PRINCIPAL } from \"../auth\"\nimport type { AuthorizationContext } from \"../authorization\"\nimport { resolveAuthorizationContext } from \"../authorization\"\nimport { createSixbError } from \"../errors/internal\"\nimport type { AuthorizablePrincipal, AuthorizationRef } from \"../execution\"\nimport type { SecurityDefinitionCatalog } from \"../security\"\nimport type {\n AccessTokenRecord,\n AuthStorage,\n ServiceAccountGroupMembershipRecord,\n ServiceAccountRecord,\n SessionRecord,\n UserRecord,\n} from \"../storage/auth\"\nimport { AuthStorageError } from \"../storage/auth\"\nimport { agentServiceAccountId } from \"./identity\"\n\nexport type AgentExecutionAuthorization =\n | { readonly type: \"principal\"; readonly context: AuthorizationContext }\n | { readonly type: \"disabled\" }\n\ntype UserCredentialRef = NonNullable<\n Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]\n>\n\ninterface CredentialedUserAuthorizationRef {\n readonly type: \"principal\"\n readonly principal: Extract<AuthorizablePrincipal, { readonly type: \"user\" }>\n readonly credential: UserCredentialRef\n}\n\nexport { agentServiceAccountId } from \"./identity\"\n\nexport interface AgentExecutionIdentity {\n readonly serviceAccount: ServiceAccountRecord\n readonly principal: Extract<AuthorizablePrincipal, { readonly type: \"serviceAccount\" }>\n readonly groupMemberships: readonly ServiceAccountGroupMembershipRecord[]\n}\n\n/** Ensure a framework-managed Agent actor exists with exactly its declared group memberships. */\nexport async function ensureManagedAgentExecutionIdentity(input: {\n readonly auth: AuthStorage | undefined\n readonly projectId: string\n readonly actorId: string\n readonly name: string\n readonly description: string\n readonly groupIds: readonly string[]\n}): Promise<AgentExecutionIdentity> {\n const auth = requireAuthStorage(input.auth)\n const id = agentServiceAccountId(input.actorId)\n const now = new Date()\n const loaded = await loadOrCreateAgentServiceAccount(auth, {\n id,\n projectId: input.projectId,\n name: input.name,\n description: input.description,\n updatedAt: now,\n })\n assertFrameworkManagedAgentServiceAccount(input.actorId, loaded)\n assertActiveAgentServiceAccount(input.actorId, loaded)\n const serviceAccount = await updateAgentServiceAccountMetadata(auth, {\n existing: loaded,\n name: input.name,\n description: input.description,\n updatedAt: now,\n })\n assertActiveAgentServiceAccount(input.actorId, serviceAccount)\n\n const groupMemberships = requireDefinitionOwnedGroupMemberships(\n input.actorId,\n await auth.serviceAccountGroupMemberships.reconcileForServiceAccount({\n projectId: input.projectId,\n serviceAccountId: id,\n groupIds: input.groupIds,\n source: \"agent\",\n updatedAt: now,\n })\n )\n\n return {\n serviceAccount,\n principal: { type: \"serviceAccount\", id },\n groupMemberships,\n }\n}\n\n/** Load the managed identity, recovering only the expected concurrent-create race. */\nasync function loadOrCreateAgentServiceAccount(\n auth: AuthStorage,\n input: {\n readonly id: string\n readonly projectId: string\n readonly name: string\n readonly description: string\n readonly updatedAt: Date\n }\n): Promise<ServiceAccountRecord> {\n const existing = await auth.serviceAccounts.getById({\n projectId: input.projectId,\n id: input.id,\n })\n if (existing) return existing\n\n try {\n return await auth.serviceAccounts.create({\n id: input.id,\n projectId: input.projectId,\n name: input.name,\n description: input.description,\n status: \"active\",\n createdByPrincipal: SYSTEM_PRINCIPAL,\n createdAt: input.updatedAt,\n updatedAt: input.updatedAt,\n })\n } catch (error) {\n if (!(error instanceof AuthStorageError) || error.code !== \"duplicate_service_account\") {\n throw error\n }\n const concurrent = await auth.serviceAccounts.getById({\n projectId: input.projectId,\n id: input.id,\n })\n if (!concurrent) throw error\n return concurrent\n }\n}\n\nfunction assertActiveAgentServiceAccount(\n actorId: string,\n serviceAccount: ServiceAccountRecord\n): void {\n if (serviceAccount.status === \"suspended\") {\n throw new Error(\n `[Sixb] Agent '${actorId}' service account '${serviceAccount.id}' is suspended.`\n )\n }\n}\n\nfunction assertFrameworkManagedAgentServiceAccount(\n actorId: string,\n serviceAccount: ServiceAccountRecord\n): void {\n if (\n serviceAccount.createdByPrincipal === undefined ||\n !principalsEqual(serviceAccount.createdByPrincipal, SYSTEM_PRINCIPAL)\n ) {\n throw createSixbError(\n \"agent.execution_failed\",\n `[Sixb] Agent '${actorId}' cannot use service account '${serviceAccount.id}' because it is not managed by Sixb.`,\n { details: { actorId, serviceAccountId: serviceAccount.id } }\n )\n }\n}\n\nfunction requireDefinitionOwnedGroupMemberships(\n actorId: string,\n memberships: readonly ServiceAccountGroupMembershipRecord[]\n): readonly ServiceAccountGroupMembershipRecord[] {\n const externalGroupIds = memberships\n .filter((membership) => membership.source !== \"agent\")\n .map((membership) => membership.groupId)\n if (externalGroupIds.length > 0) {\n throw createSixbError(\n \"agent.execution_failed\",\n `[Sixb] Agent '${actorId}' service account has group memberships not managed by its definition: ${externalGroupIds.join(\", \")}.`,\n { details: { actorId, externalGroupIds } }\n )\n }\n return memberships\n}\n\n/** Resolve current grants for the service account referenced by a durable Agent execution. */\nexport async function resolveAgentExecutionAuthorization(input: {\n readonly auth: AuthStorage | undefined\n readonly projectId: string\n readonly actorId: string\n readonly authorizationRef: AuthorizationRef\n readonly security: SecurityDefinitionCatalog\n}): Promise<{ readonly identity: AgentExecutionIdentity; readonly context: AuthorizationContext }> {\n const auth = requireAuthStorage(input.auth)\n const expectedId = agentServiceAccountId(input.actorId)\n const principal =\n input.authorizationRef.type === \"principal\" ? input.authorizationRef.principal : null\n if (principal?.type !== \"serviceAccount\" || principal.id !== expectedId) {\n throw new Error(\n `[Sixb] Agent '${input.actorId}' execution authority must reference service account '${expectedId}'.`\n )\n }\n\n const serviceAccount = await auth.serviceAccounts.getById({\n projectId: input.projectId,\n id: principal.id,\n })\n if (!serviceAccount || serviceAccount.status !== \"active\") {\n throw new Error(`[Sixb] Agent service account '${principal.id}' is not active.`)\n }\n assertFrameworkManagedAgentServiceAccount(input.actorId, serviceAccount)\n\n const groupMemberships = requireDefinitionOwnedGroupMemberships(\n input.actorId,\n await auth.serviceAccountGroupMemberships.listForServiceAccount({\n projectId: input.projectId,\n serviceAccountId: principal.id,\n })\n )\n const identity: AgentExecutionIdentity = {\n serviceAccount,\n principal: { type: \"serviceAccount\", id: principal.id },\n groupMemberships,\n }\n return {\n identity,\n context: resolveAuthorizationContext({\n principal: identity.principal,\n groupIds: groupMemberships.map((membership) => membership.groupId),\n roles: input.security.listResolvedRoles(),\n }),\n }\n}\n\n/** Revalidate the durable user authority inherited by a conversational or child Agent. */\nexport async function resolveInheritedAgentExecutionAuthorization(input: {\n readonly auth: AuthStorage | undefined\n readonly projectId: string\n readonly authorizationRef: AuthorizationRef\n readonly security: SecurityDefinitionCatalog\n readonly now?: Date\n}): Promise<AgentExecutionAuthorization> {\n if (input.authorizationRef.type === \"disabled\") return { type: \"disabled\" }\n\n const ref = requireCredentialedUserAuthority(input.authorizationRef)\n const auth = requireAuthStorage(input.auth)\n const now = input.now ?? new Date()\n const user = await requireActiveUser(auth, input.projectId, ref.principal.id)\n const memberships = await auth.groupMemberships.listForUser({\n projectId: input.projectId,\n userId: user.id,\n })\n const credential = await revalidateUserCredential({\n auth,\n projectId: input.projectId,\n userId: user.id,\n credential: ref.credential,\n currentGroupIds: memberships.map((membership) => membership.groupId),\n now,\n })\n\n return {\n type: \"principal\",\n context: resolveAuthorizationContext({\n principal: ref.principal,\n groupIds: credential.groupIds,\n roles: input.security.listResolvedRoles(),\n ...(credential.sessionId === undefined ? {} : { sessionId: credential.sessionId }),\n }),\n }\n}\n\nfunction requireCredentialedUserAuthority(ref: AuthorizationRef): CredentialedUserAuthorizationRef {\n if (ref.type !== \"principal\" || ref.principal.type !== \"user\" || ref.credential === undefined) {\n throw invalidInheritedAuthority(\"the durable reference is not a credentialed user\")\n }\n return {\n type: \"principal\",\n principal: { type: \"user\", id: ref.principal.id },\n credential: { type: ref.credential.type, id: ref.credential.id },\n }\n}\n\nasync function requireActiveUser(\n auth: AuthStorage,\n projectId: string,\n userId: string\n): Promise<UserRecord> {\n const user = await auth.users.getById({ projectId, id: userId })\n if (!user || user.status !== \"active\") {\n throw invalidInheritedAuthority(`user '${userId}' is not active`)\n }\n return user\n}\n\nasync function revalidateUserCredential(input: {\n readonly auth: AuthStorage\n readonly projectId: string\n readonly userId: string\n readonly credential: UserCredentialRef\n readonly currentGroupIds: readonly string[]\n readonly now: Date\n}): Promise<{ readonly groupIds: readonly string[]; readonly sessionId?: string }> {\n if (input.credential.type === \"session\") {\n const session = await input.auth.sessions.getById({\n projectId: input.projectId,\n id: input.credential.id,\n })\n if (!isUsableUserSession(session, input.userId, input.now)) {\n throw invalidInheritedAuthority(\"the inherited session is no longer valid\")\n }\n return { groupIds: input.currentGroupIds, sessionId: session.id }\n }\n\n const accessToken = await input.auth.accessTokens.getById({\n projectId: input.projectId,\n id: input.credential.id,\n })\n if (!isUsableUserAccessToken(accessToken, input.userId, input.now)) {\n throw invalidInheritedAuthority(\"the inherited access token is no longer valid\")\n }\n if (accessToken.groupIds === undefined) return { groupIds: input.currentGroupIds }\n\n const allowedGroupIds = new Set(accessToken.groupIds)\n return {\n groupIds: input.currentGroupIds.filter((groupId) => allowedGroupIds.has(groupId)),\n }\n}\n\nfunction isUsableUserSession(\n session: SessionRecord | null,\n userId: string,\n now: Date\n): session is SessionRecord {\n if (!session || session.userId !== userId || session.revokedAt !== undefined) return false\n if (session.expiresAt.getTime() <= now.getTime()) return false\n return (\n session.absoluteExpiresAt === undefined || session.absoluteExpiresAt.getTime() > now.getTime()\n )\n}\n\nfunction isUsableUserAccessToken(\n token: AccessTokenRecord | null,\n userId: string,\n now: Date\n): token is AccessTokenRecord {\n if (!token || !principalsEqual(token.subject, { type: \"user\", id: userId })) return false\n return token.revokedAt === undefined && token.expiresAt.getTime() > now.getTime()\n}\n\nfunction invalidInheritedAuthority(reason: string): Error {\n return createSixbError(\n \"agent.execution_failed\",\n `[Sixb] The Agent execution cannot restore its inherited authority: ${reason}.`\n )\n}\n\nfunction requireAuthStorage(auth: AuthStorage | undefined): AuthStorage {\n if (!auth) {\n throw new Error(\"[Sixb] Agent executions require auth storage.\")\n }\n return auth\n}\n\nasync function updateAgentServiceAccountMetadata(\n auth: AuthStorage,\n input: {\n readonly existing: ServiceAccountRecord\n readonly name: string\n readonly description: string\n readonly updatedAt: Date\n }\n): Promise<ServiceAccountRecord> {\n if (input.existing.name === input.name && input.existing.description === input.description) {\n return input.existing\n }\n return auth.serviceAccounts.update({\n projectId: input.existing.projectId,\n id: input.existing.id,\n name: input.name,\n description: input.description,\n updatedAt: input.updatedAt,\n })\n}\n",
6
6
  "/**\n * Base error for workflow-run storage operations.\n */\nexport class WorkflowRunError extends Error {\n readonly name = \"WorkflowRunError\"\n}\n",
7
7
  "import { agentServiceAccountId } from \"../../agents/authority\"\nimport type { ExecutionStorage } from \"../executions\"\nimport { findAgentRunExecution, findPrimitiveRunExecution } from \"../executions/run-link\"\nimport { WorkflowRunError } from \"./errors\"\n\n/** Validate the semantic link between a durable workflow run and its immutable execution. */\nexport async function assertWorkflowRunExecution(input: {\n readonly executions: ExecutionStorage\n readonly projectId: string\n readonly executionId: string\n readonly runId: string\n readonly workflowId: string\n}): Promise<void> {\n const execution = await findPrimitiveRunExecution({\n executions: input.executions,\n projectId: input.projectId,\n executionId: input.executionId,\n primitive: { kind: \"workflow\", id: input.workflowId, runId: input.runId },\n sourceTypes: [\"execution\", \"schedule\", \"event\"],\n })\n if (!execution) {\n invalidExecution(input.executionId, input.runId)\n }\n\n if (execution.source.type === \"schedule\" || execution.source.type === \"event\") {\n if (execution.requestedBy !== undefined) {\n invalidExecution(input.executionId, input.runId)\n }\n return\n }\n\n // ExecutionStorage already validates the immutable parent reference, correlation id, and\n // requested-by propagation. This boundary only owns the workflow-specific source restriction.\n if (execution.source.type !== \"execution\") {\n invalidExecution(input.executionId, input.runId)\n }\n}\n\n/** Validate the semantic link between a Workflow Agent-node run and its child execution. */\nexport async function assertWorkflowAgentNodeRunExecution(input: {\n readonly executions: ExecutionStorage\n readonly projectId: string\n readonly executionId: string\n readonly nodeRunId: string\n readonly actorId: string\n readonly workflowExecutionId: string\n}): Promise<void> {\n const execution = await findAgentRunExecution({\n executions: input.executions,\n projectId: input.projectId,\n executionId: input.executionId,\n runId: input.nodeRunId,\n authority: { type: \"managed\", serviceAccountId: agentServiceAccountId(input.actorId) },\n })\n if (\n !execution ||\n execution.source.type !== \"execution\" ||\n execution.source.executionId !== input.workflowExecutionId\n ) {\n throw new WorkflowRunError(\n `[Sixb] Execution '${input.executionId}' does not authorize Workflow Agent-node run '${input.nodeRunId}'.`\n )\n }\n}\n\nfunction invalidExecution(executionId: string, runId: string): never {\n throw new WorkflowRunError(\n `[Sixb] Execution '${executionId}' does not authorize workflow run '${runId}'.`\n )\n}\n"
8
8
  ],
9
- "mappings": ";;;;;;;;;;;;;;;;;;;AAwCA,eAAsB,oCAAmC,CAAC,OAOtB;AAAA,EAClC,MAAM,OAAO,mBAAmB,MAAM,IAAI;AAAA,EAC1C,MAAM,KAAK,uBAAsB,MAAM,OAAO;AAAA,EAC9C,MAAM,MAAM,IAAI;AAAA,EAChB,MAAM,SAAS,MAAM,gCAAgC,MAAM;AAAA,IACzD;AAAA,IACA,WAAW,MAAM;AAAA,IACjB,MAAM,MAAM;AAAA,IACZ,aAAa,MAAM;AAAA,IACnB,WAAW;AAAA,EACb,CAAC;AAAA,EACD,0CAA0C,MAAM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164756E21",
11
11
  "names": []
12
12
  }
@@ -0,0 +1,42 @@
1
+ // @bun
2
+ // src/storage/file-upload-sessions/utils.ts
3
+ import { randomUUID } from "crypto";
4
+ var DEFAULT_FILE_UPLOAD_SESSION_TTL_MS2 = 60 * 60 * 1000;
5
+ var DEFAULT_FILE_UPLOAD_TERMINAL_SESSION_TTL_MS2 = 15 * 60 * 1000;
6
+ function createUploadExpiresAt2(now = Date.now()) {
7
+ return new Date(now + DEFAULT_FILE_UPLOAD_SESSION_TTL_MS2);
8
+ }
9
+ function createFileUploadId2() {
10
+ return `upload_${randomUUID().replaceAll("-", "")}`;
11
+ }
12
+ function isFileUploadSessionExpired(session, nowMs = Date.now()) {
13
+ return session.status === "pending" && session.expiresAt.getTime() <= nowMs;
14
+ }
15
+ function isAbandonedFileUploadSession(session, nowMs = Date.now()) {
16
+ return session.providerUpload !== undefined && isFileUploadSessionExpired(session, nowMs);
17
+ }
18
+ function fileUploadSessionReapAt2(session) {
19
+ if (session.status === "pending") {
20
+ return session.providerUpload === undefined ? session.expiresAt : null;
21
+ }
22
+ const terminalAt = session.completedAt ?? session.abortedAt;
23
+ return terminalAt ? new Date(terminalAt.getTime() + DEFAULT_FILE_UPLOAD_TERMINAL_SESSION_TTL_MS2) : null;
24
+ }
25
+ function shouldDeleteFileUploadSession(session, nowMs) {
26
+ const reapAt = fileUploadSessionReapAt2(session);
27
+ return reapAt !== null && reapAt.getTime() <= nowMs;
28
+ }
29
+ function isTerminalFileUploadSessionExpired(session, nowMs) {
30
+ if (session.status === "pending") {
31
+ return false;
32
+ }
33
+ const terminalAt = session.completedAt ?? session.abortedAt;
34
+ if (!terminalAt) {
35
+ return false;
36
+ }
37
+ return terminalAt.getTime() + DEFAULT_FILE_UPLOAD_TERMINAL_SESSION_TTL_MS2 <= nowMs;
38
+ }
39
+
40
+ export { DEFAULT_FILE_UPLOAD_SESSION_TTL_MS2, DEFAULT_FILE_UPLOAD_TERMINAL_SESSION_TTL_MS2, createUploadExpiresAt2, createFileUploadId2, isFileUploadSessionExpired, isAbandonedFileUploadSession, fileUploadSessionReapAt2, shouldDeleteFileUploadSession, isTerminalFileUploadSessionExpired };
41
+
42
+ //# debugId=EAECD974E6F80CCB64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/storage/file-upload-sessions/utils.ts"],
4
+ "sourcesContent": [
5
+ "import { randomUUID } from \"node:crypto\"\nimport type { FileUploadSession } from \"./types\"\n\nexport const DEFAULT_FILE_UPLOAD_SESSION_TTL_MS = 60 * 60 * 1000\nexport const DEFAULT_FILE_UPLOAD_TERMINAL_SESSION_TTL_MS = 15 * 60 * 1000\n\nexport function createUploadExpiresAt(now = Date.now()): Date {\n return new Date(now + DEFAULT_FILE_UPLOAD_SESSION_TTL_MS)\n}\n\nexport function createFileUploadId(): string {\n return `upload_${randomUUID().replaceAll(\"-\", \"\")}`\n}\n\nexport function isFileUploadSessionExpired(\n session: FileUploadSession,\n nowMs = Date.now()\n): boolean {\n return session.status === \"pending\" && session.expiresAt.getTime() <= nowMs\n}\n\n/** Expired, still `pending`, and holding a provider upload only `abortUpload` can release. */\nexport function isAbandonedFileUploadSession(\n session: FileUploadSession,\n nowMs = Date.now()\n): boolean {\n return session.providerUpload !== undefined && isFileUploadSessionExpired(session, nowMs)\n}\n\n/**\n * When a session may be deleted, or null when only a state change can make it deletable.\n * This is the single retention rule: durable providers persist it as `reap_at` and delete\n * `reap_at <= now`, so SQL never restates it.\n */\nexport function fileUploadSessionReapAt(session: FileUploadSession): Date | null {\n if (session.status === \"pending\") {\n return session.providerUpload === undefined ? session.expiresAt : null\n }\n\n const terminalAt = session.completedAt ?? session.abortedAt\n return terminalAt\n ? new Date(terminalAt.getTime() + DEFAULT_FILE_UPLOAD_TERMINAL_SESSION_TTL_MS)\n : null\n}\n\nexport function shouldDeleteFileUploadSession(session: FileUploadSession, nowMs: number): boolean {\n const reapAt = fileUploadSessionReapAt(session)\n return reapAt !== null && reapAt.getTime() <= nowMs\n}\n\nexport function isTerminalFileUploadSessionExpired(\n session: FileUploadSession,\n nowMs: number\n): boolean {\n if (session.status === \"pending\") {\n return false\n }\n\n const terminalAt = session.completedAt ?? session.abortedAt\n if (!terminalAt) {\n return false\n }\n\n return terminalAt.getTime() + DEFAULT_FILE_UPLOAD_TERMINAL_SESSION_TTL_MS <= nowMs\n}\n"
6
+ ],
7
+ "mappings": ";;AAAA;AAGO,IAAM,sCAAqC,KAAK,KAAK;AACrD,IAAM,+CAA8C,KAAK,KAAK;AAE9D,SAAS,sBAAqB,CAAC,MAAM,KAAK,IAAI,GAAS;AAAA,EAC5D,OAAO,IAAI,KAAK,MAAM,mCAAkC;AAAA;AAGnD,SAAS,mBAAkB,GAAW;AAAA,EAC3C,OAAO,UAAU,WAAW,EAAE,WAAW,KAAK,EAAE;AAAA;AAG3C,SAAS,0BAA0B,CACxC,SACA,QAAQ,KAAK,IAAI,GACR;AAAA,EACT,OAAO,QAAQ,WAAW,aAAa,QAAQ,UAAU,QAAQ,KAAK;AAAA;AAIjE,SAAS,4BAA4B,CAC1C,SACA,QAAQ,KAAK,IAAI,GACR;AAAA,EACT,OAAO,QAAQ,mBAAmB,aAAa,2BAA2B,SAAS,KAAK;AAAA;AAQnF,SAAS,wBAAuB,CAAC,SAAyC;AAAA,EAC/E,IAAI,QAAQ,WAAW,WAAW;AAAA,IAChC,OAAO,QAAQ,mBAAmB,YAAY,QAAQ,YAAY;AAAA,EACpE;AAAA,EAEA,MAAM,aAAa,QAAQ,eAAe,QAAQ;AAAA,EAClD,OAAO,aACH,IAAI,KAAK,WAAW,QAAQ,IAAI,4CAA2C,IAC3E;AAAA;AAGC,SAAS,6BAA6B,CAAC,SAA4B,OAAwB;AAAA,EAChG,MAAM,SAAS,yBAAwB,OAAO;AAAA,EAC9C,OAAO,WAAW,QAAQ,OAAO,QAAQ,KAAK;AAAA;AAGzC,SAAS,kCAAkC,CAChD,SACA,OACS;AAAA,EACT,IAAI,QAAQ,WAAW,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