@sixb/core 0.1.2 → 0.1.4

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 (383) hide show
  1. package/dist/actions/index.js +19 -17
  2. package/dist/actions/index.js.map +1 -1
  3. package/dist/actions/worker.js +4 -4
  4. package/dist/actions/worker.js.map +1 -1
  5. package/dist/agents/adapters.d.ts +11 -1
  6. package/dist/agents/adapters.d.ts.map +1 -1
  7. package/dist/agents/context-compaction.d.ts +40 -0
  8. package/dist/agents/context-compaction.d.ts.map +1 -0
  9. package/dist/agents/context.js +1 -1
  10. package/dist/agents/errors.d.ts +1 -1
  11. package/dist/agents/errors.d.ts.map +1 -1
  12. package/dist/agents/execution.d.ts +3 -0
  13. package/dist/agents/execution.d.ts.map +1 -1
  14. package/dist/agents/ids.d.ts +2 -0
  15. package/dist/agents/ids.d.ts.map +1 -1
  16. package/dist/agents/index.d.ts +10 -6
  17. package/dist/agents/index.d.ts.map +1 -1
  18. package/dist/agents/index.js +51 -35
  19. package/dist/agents/index.js.map +1 -1
  20. package/dist/agents/request.d.ts.map +1 -1
  21. package/dist/agents/streams.d.ts +17 -1
  22. package/dist/agents/streams.d.ts.map +1 -1
  23. package/dist/agents/streams.js +5 -3
  24. package/dist/agents/streams.js.map +1 -1
  25. package/dist/agents/thread-context-projection.d.ts +19 -0
  26. package/dist/agents/thread-context-projection.d.ts.map +1 -0
  27. package/dist/agents/tool-definition.d.ts.map +1 -1
  28. package/dist/agents/tool-result.d.ts +6 -0
  29. package/dist/agents/tool-result.d.ts.map +1 -0
  30. package/dist/agents/types.d.ts +46 -1
  31. package/dist/agents/types.d.ts.map +1 -1
  32. package/dist/agents/validation.d.ts +2 -2
  33. package/dist/agents/validation.d.ts.map +1 -1
  34. package/dist/auth/index.js +11 -5
  35. package/dist/auth/index.js.map +1 -1
  36. package/dist/authorization/index.js +6 -2
  37. package/dist/authorization/index.js.map +1 -1
  38. package/dist/bootstrap/index.js +33 -31
  39. package/dist/bootstrap/index.js.map +1 -1
  40. package/dist/{chunk-ys1nse2v.js → chunk-1wk20wn3.js} +438 -246
  41. package/dist/{chunk-ys1nse2v.js.map → chunk-1wk20wn3.js.map} +11 -11
  42. package/dist/{chunk-sa4340y1.js → chunk-1yz3x65y.js} +7 -7
  43. package/dist/{chunk-gqdd7508.js → chunk-4rh2m6zg.js} +1 -1
  44. package/dist/{chunk-fmx1sz2h.js → chunk-72q2y8hn.js} +3 -3
  45. package/dist/{chunk-fmx1sz2h.js.map → chunk-72q2y8hn.js.map} +4 -4
  46. package/dist/{chunk-nnyp53zt.js → chunk-7gw7mepb.js} +259 -9
  47. package/dist/chunk-7gw7mepb.js.map +14 -0
  48. package/dist/{chunk-nten49ta.js → chunk-819wnjz8.js} +11 -5
  49. package/dist/chunk-819wnjz8.js.map +12 -0
  50. package/dist/chunk-96swp2wd.js +47 -0
  51. package/dist/chunk-96swp2wd.js.map +10 -0
  52. package/dist/{chunk-4x43bkbp.js → chunk-a09jx26t.js} +1 -1
  53. package/dist/{chunk-st4xgxey.js → chunk-afjpa2hs.js} +205 -48
  54. package/dist/chunk-afjpa2hs.js.map +45 -0
  55. package/dist/{chunk-0mbx247x.js → chunk-c43qr6s0.js} +427 -99
  56. package/dist/chunk-c43qr6s0.js.map +46 -0
  57. package/dist/{chunk-zg9yryhz.js → chunk-cbkm2vam.js} +3 -3
  58. package/dist/{chunk-57zpb99z.js → chunk-dm72y8wt.js} +26 -3
  59. package/dist/chunk-dm72y8wt.js.map +10 -0
  60. package/dist/chunk-drjqm1aa.js +913 -0
  61. package/dist/chunk-drjqm1aa.js.map +15 -0
  62. package/dist/chunk-dysw7nsm.js.map +1 -1
  63. package/dist/{chunk-8ryen3p3.js → chunk-f6erf2vv.js} +1 -1
  64. package/dist/{chunk-34bqh420.js → chunk-f83ka50g.js} +188 -44
  65. package/dist/chunk-f83ka50g.js.map +23 -0
  66. package/dist/{chunk-bct7hmfc.js → chunk-g13869yf.js} +3 -3
  67. package/dist/{chunk-0k4avqr2.js → chunk-hbeh8j9w.js} +2 -2
  68. package/dist/{chunk-qvybnnpe.js → chunk-nzw7sm3b.js} +2 -2
  69. package/dist/{chunk-k9pts48t.js → chunk-pn8n8sba.js} +16 -15
  70. package/dist/{chunk-k9pts48t.js.map → chunk-pn8n8sba.js.map} +3 -3
  71. package/dist/{chunk-63te770v.js → chunk-qewtks41.js} +8 -8
  72. package/dist/{chunk-63te770v.js.map → chunk-qewtks41.js.map} +2 -2
  73. package/dist/{chunk-85j5ybfj.js → chunk-rdeagz6b.js} +2 -2
  74. package/dist/{chunk-85j5ybfj.js.map → chunk-rdeagz6b.js.map} +3 -3
  75. package/dist/chunk-rhrbz7d4.js +36 -0
  76. package/dist/chunk-rhrbz7d4.js.map +10 -0
  77. package/dist/{chunk-bh6k3nc6.js → chunk-rs1wbvy6.js} +1 -1
  78. package/dist/{chunk-88ppkr54.js → chunk-rte5sm3z.js} +26 -2
  79. package/dist/chunk-rte5sm3z.js.map +12 -0
  80. package/dist/{chunk-n8herkry.js → chunk-s31d0qmq.js} +57 -20
  81. package/dist/{chunk-n8herkry.js.map → chunk-s31d0qmq.js.map} +8 -7
  82. package/dist/{chunk-7pc8b818.js → chunk-sxwk41qa.js} +1 -1
  83. package/dist/{chunk-663csy96.js → chunk-t0jjkep3.js} +2 -1
  84. package/dist/chunk-t0jjkep3.js.map +10 -0
  85. package/dist/{chunk-c6qd89g5.js → chunk-tek1qwgm.js} +6 -6
  86. package/dist/{chunk-c6qd89g5.js.map → chunk-tek1qwgm.js.map} +1 -1
  87. package/dist/{chunk-jaj13078.js → chunk-tkdscva6.js} +3 -33
  88. package/dist/{chunk-jaj13078.js.map → chunk-tkdscva6.js.map} +3 -4
  89. package/dist/{chunk-5egfka8j.js → chunk-tycbzedm.js} +2 -2
  90. package/dist/{chunk-g9t3kdtx.js → chunk-x2yw73hy.js} +1 -1
  91. package/dist/{chunk-57r1cpxx.js → chunk-xc7hq65b.js} +3 -2
  92. package/dist/{chunk-57r1cpxx.js.map → chunk-xc7hq65b.js.map} +3 -3
  93. package/dist/chunk-xdf9yswn.js +133 -0
  94. package/dist/chunk-xdf9yswn.js.map +11 -0
  95. package/dist/execution/agent.js +29 -27
  96. package/dist/execution/agent.js.map +1 -1
  97. package/dist/execution/primitive.js +29 -27
  98. package/dist/execution/primitive.js.map +2 -2
  99. package/dist/execution/request.js +30 -28
  100. package/dist/execution/request.js.map +2 -2
  101. package/dist/http/index.js +1 -1
  102. package/dist/index.d.ts +6 -5
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +60 -58
  105. package/dist/index.js.map +1 -1
  106. package/dist/lake-storage/types.d.ts +2 -1
  107. package/dist/lake-storage/types.d.ts.map +1 -1
  108. package/dist/materialization/model.d.ts +4 -0
  109. package/dist/materialization/model.d.ts.map +1 -1
  110. package/dist/materializer/edits/apply.d.ts +6 -1
  111. package/dist/materializer/edits/apply.d.ts.map +1 -1
  112. package/dist/materializer/edits/working-state.d.ts +2 -0
  113. package/dist/materializer/edits/working-state.d.ts.map +1 -1
  114. package/dist/materializer/effective/resolve.d.ts +3 -1
  115. package/dist/materializer/effective/resolve.d.ts.map +1 -1
  116. package/dist/materializer/execution/work-records.d.ts.map +1 -1
  117. package/dist/materializer/index.js +19 -17
  118. package/dist/materializer/index.js.map +1 -1
  119. package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
  120. package/dist/materializer/shared/normalize.d.ts.map +1 -1
  121. package/dist/models/index.d.ts +40 -0
  122. package/dist/models/index.d.ts.map +1 -0
  123. package/dist/objects/execution.d.ts +6 -1
  124. package/dist/objects/execution.d.ts.map +1 -1
  125. package/dist/objects/index.js +21 -19
  126. package/dist/objects/index.js.map +1 -1
  127. package/dist/objects/link/endpoints.d.ts.map +1 -1
  128. package/dist/objects/query/executor.d.ts +1 -0
  129. package/dist/objects/query/executor.d.ts.map +1 -1
  130. package/dist/objects/query/explain.d.ts +1 -0
  131. package/dist/objects/query/explain.d.ts.map +1 -1
  132. package/dist/objects/query/index.d.ts +3 -1
  133. package/dist/objects/query/index.d.ts.map +1 -1
  134. package/dist/objects/query/index.js +30 -5
  135. package/dist/objects/query/index.js.map +1 -1
  136. package/dist/objects/query/ir.d.ts +14 -1
  137. package/dist/objects/query/ir.d.ts.map +1 -1
  138. package/dist/objects/query/links.d.ts +25 -0
  139. package/dist/objects/query/links.d.ts.map +1 -0
  140. package/dist/objects/query/normalize.d.ts.map +1 -1
  141. package/dist/objects/query/planner.d.ts.map +1 -1
  142. package/dist/objects/query/validate.d.ts +1 -0
  143. package/dist/objects/query/validate.d.ts.map +1 -1
  144. package/dist/pipelines/index.js +16 -15
  145. package/dist/pipelines/index.js.map +1 -1
  146. package/dist/projections/builders.d.ts +52 -10
  147. package/dist/projections/builders.d.ts.map +1 -1
  148. package/dist/projections/index.d.ts +2 -1
  149. package/dist/projections/index.d.ts.map +1 -1
  150. package/dist/projections/internal.d.ts +4 -1
  151. package/dist/projections/internal.d.ts.map +1 -1
  152. package/dist/projections/internal.js +22 -17
  153. package/dist/projections/internal.js.map +1 -1
  154. package/dist/projections/run-dispatch.d.ts +1 -0
  155. package/dist/projections/run-dispatch.d.ts.map +1 -1
  156. package/dist/projections/timestamp.d.ts +3 -0
  157. package/dist/projections/timestamp.d.ts.map +1 -0
  158. package/dist/projections/types.d.ts +21 -9
  159. package/dist/projections/types.d.ts.map +1 -1
  160. package/dist/projections/validation.d.ts +6 -5
  161. package/dist/projections/validation.d.ts.map +1 -1
  162. package/dist/query.d.ts +2 -1
  163. package/dist/query.d.ts.map +1 -1
  164. package/dist/query.js +2 -2
  165. package/dist/queues/index.d.ts +1 -1
  166. package/dist/queues/index.d.ts.map +1 -1
  167. package/dist/queues/types.d.ts +7 -0
  168. package/dist/queues/types.d.ts.map +1 -1
  169. package/dist/runtime/ai-cost.d.ts +8 -0
  170. package/dist/runtime/ai-cost.d.ts.map +1 -0
  171. package/dist/runtime/create.d.ts +3 -0
  172. package/dist/runtime/create.d.ts.map +1 -1
  173. package/dist/runtime/definitions.d.ts +3 -0
  174. package/dist/runtime/definitions.d.ts.map +1 -1
  175. package/dist/runtime/host.d.ts +2 -0
  176. package/dist/runtime/host.d.ts.map +1 -1
  177. package/dist/runtime/resolve-definitions.d.ts +2 -0
  178. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  179. package/dist/storage/agents/in-memory.d.ts +22 -4
  180. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  181. package/dist/storage/agents/index.d.ts +1 -1
  182. package/dist/storage/agents/index.d.ts.map +1 -1
  183. package/dist/storage/agents/provider.d.ts +31 -0
  184. package/dist/storage/agents/provider.d.ts.map +1 -1
  185. package/dist/storage/agents/provider.js +22 -7
  186. package/dist/storage/agents/provider.js.map +1 -1
  187. package/dist/storage/agents/types.d.ts +75 -4
  188. package/dist/storage/agents/types.d.ts.map +1 -1
  189. package/dist/storage/ai-cost/analytics.d.ts +61 -0
  190. package/dist/storage/ai-cost/analytics.d.ts.map +1 -0
  191. package/dist/storage/ai-cost/codec.d.ts +14 -0
  192. package/dist/storage/ai-cost/codec.d.ts.map +1 -0
  193. package/dist/storage/ai-cost/errors.d.ts +7 -0
  194. package/dist/storage/ai-cost/errors.d.ts.map +1 -0
  195. package/dist/storage/ai-cost/in-memory.d.ts +32 -0
  196. package/dist/storage/ai-cost/in-memory.d.ts.map +1 -0
  197. package/dist/storage/ai-cost/index.d.ts +6 -0
  198. package/dist/storage/ai-cost/index.d.ts.map +1 -0
  199. package/dist/storage/ai-cost/provider.d.ts +7 -0
  200. package/dist/storage/ai-cost/provider.d.ts.map +1 -0
  201. package/dist/storage/ai-cost/provider.js +132 -0
  202. package/dist/storage/ai-cost/provider.js.map +10 -0
  203. package/dist/storage/ai-cost/types.d.ts +154 -0
  204. package/dist/storage/ai-cost/types.d.ts.map +1 -0
  205. package/dist/storage/ai-cost/validation.d.ts +7 -0
  206. package/dist/storage/ai-cost/validation.d.ts.map +1 -0
  207. package/dist/storage/ai-usage/in-memory.d.ts +2 -1
  208. package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
  209. package/dist/storage/ai-usage/index.d.ts +1 -1
  210. package/dist/storage/ai-usage/index.d.ts.map +1 -1
  211. package/dist/storage/ai-usage/types.d.ts +6 -0
  212. package/dist/storage/ai-usage/types.d.ts.map +1 -1
  213. package/dist/storage/in-memory/index.d.ts +5 -0
  214. package/dist/storage/in-memory/index.d.ts.map +1 -1
  215. package/dist/storage/index.d.ts +6 -3
  216. package/dist/storage/index.d.ts.map +1 -1
  217. package/dist/storage/index.js +33 -21
  218. package/dist/storage/index.js.map +1 -1
  219. package/dist/storage/objects/in-memory.d.ts +6 -3
  220. package/dist/storage/objects/in-memory.d.ts.map +1 -1
  221. package/dist/storage/objects/index.d.ts +3 -1
  222. package/dist/storage/objects/index.d.ts.map +1 -1
  223. package/dist/storage/objects/keys.d.ts +16 -0
  224. package/dist/storage/objects/keys.d.ts.map +1 -0
  225. package/dist/storage/objects/types.d.ts +33 -6
  226. package/dist/storage/objects/types.d.ts.map +1 -1
  227. package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
  228. package/dist/storage/ontology/materializations.d.ts +3 -0
  229. package/dist/storage/ontology/materializations.d.ts.map +1 -1
  230. package/dist/storage/ontology/provider.js +1 -1
  231. package/dist/storage/operation-scope.d.ts.map +1 -1
  232. package/dist/storage/operation-scope.js +1 -1
  233. package/dist/storage/types.d.ts +2 -0
  234. package/dist/storage/types.d.ts.map +1 -1
  235. package/dist/storage/workflow-runs/provider.js +10 -5
  236. package/dist/storage/workflow-runs/provider.js.map +1 -1
  237. package/dist/syncs/index.js +16 -15
  238. package/dist/syncs/index.js.map +1 -1
  239. package/dist/testing/agent-storage-contract.d.ts +3 -2
  240. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  241. package/dist/testing/ai-cost-storage-contract.d.ts +12 -0
  242. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -0
  243. package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
  244. package/dist/testing/effective-storage-contract.d.ts +1 -1
  245. package/dist/testing/effective-storage-contract.d.ts.map +1 -1
  246. package/dist/testing/index.d.ts +1 -0
  247. package/dist/testing/index.d.ts.map +1 -1
  248. package/dist/testing/index.js +2525 -1480
  249. package/dist/testing/index.js.map +10 -9
  250. package/dist/testing/lake-storage-contract.d.ts.map +1 -1
  251. package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
  252. package/dist/testing/object-query-contract.d.ts +1 -1
  253. package/dist/testing/object-query-contract.d.ts.map +1 -1
  254. package/dist/webhooks/internal.js +14 -13
  255. package/dist/webhooks/internal.js.map +2 -2
  256. package/dist/workers/index.js +12 -2
  257. package/dist/workers/index.js.map +3 -3
  258. package/dist/workers/queue-worker.d.ts +2 -0
  259. package/dist/workers/queue-worker.d.ts.map +1 -1
  260. package/dist/workflows/execution.d.ts +3 -0
  261. package/dist/workflows/execution.d.ts.map +1 -1
  262. package/dist/workflows/index.js +30 -28
  263. package/dist/workflows/index.js.map +1 -1
  264. package/package.json +7 -1
  265. package/src/agents/adapters.ts +64 -23
  266. package/src/agents/builders.ts +3 -3
  267. package/src/agents/context-compaction.ts +261 -0
  268. package/src/agents/errors.ts +2 -2
  269. package/src/agents/execution.ts +14 -2
  270. package/src/agents/ids.ts +5 -0
  271. package/src/agents/index.ts +32 -6
  272. package/src/agents/request.ts +5 -0
  273. package/src/agents/streams.ts +56 -0
  274. package/src/agents/thread-context-projection.ts +93 -0
  275. package/src/agents/tool-definition.ts +17 -2
  276. package/src/agents/tool-result.ts +61 -0
  277. package/src/agents/types.ts +57 -1
  278. package/src/agents/validation.ts +36 -6
  279. package/src/http/api-routes.ts +7 -7
  280. package/src/index.ts +27 -0
  281. package/src/lake-storage/types.ts +2 -1
  282. package/src/materialization/model.ts +4 -0
  283. package/src/materializer/edits/apply.ts +55 -2
  284. package/src/materializer/edits/operations.ts +8 -1
  285. package/src/materializer/edits/working-state.ts +7 -0
  286. package/src/materializer/effective/resolve.ts +78 -9
  287. package/src/materializer/execution/work-records.ts +3 -1
  288. package/src/materializer/projections/entry-validator.ts +23 -1
  289. package/src/materializer/projections/replacement-plan.ts +2 -0
  290. package/src/materializer/shared/normalize.ts +16 -0
  291. package/src/materializer/telemetry/append.ts +33 -16
  292. package/src/models/index.ts +71 -0
  293. package/src/objects/execution.ts +20 -0
  294. package/src/objects/link/endpoints.ts +2 -1
  295. package/src/objects/query/executor.ts +42 -11
  296. package/src/objects/query/explain.ts +11 -0
  297. package/src/objects/query/index.ts +6 -0
  298. package/src/objects/query/ir.ts +16 -0
  299. package/src/objects/query/links.ts +308 -0
  300. package/src/objects/query/normalize.ts +40 -1
  301. package/src/objects/query/planner.ts +5 -0
  302. package/src/objects/query/validate.ts +58 -2
  303. package/src/projections/builders.ts +320 -50
  304. package/src/projections/index.ts +7 -0
  305. package/src/projections/internal.ts +4 -1
  306. package/src/projections/ownership.ts +5 -5
  307. package/src/projections/registry.ts +16 -3
  308. package/src/projections/revision.ts +35 -5
  309. package/src/projections/run-dispatch.ts +10 -1
  310. package/src/projections/timestamp.ts +66 -0
  311. package/src/projections/types.ts +20 -9
  312. package/src/projections/validation.ts +85 -19
  313. package/src/query.ts +2 -0
  314. package/src/queues/index.ts +1 -0
  315. package/src/queues/types.ts +8 -0
  316. package/src/runtime/ai-cost.ts +15 -0
  317. package/src/runtime/create.ts +4 -0
  318. package/src/runtime/definitions.ts +3 -0
  319. package/src/runtime/host.ts +2 -0
  320. package/src/runtime/resolve-definitions.ts +28 -0
  321. package/src/storage/agents/in-memory.ts +186 -4
  322. package/src/storage/agents/index.ts +5 -0
  323. package/src/storage/agents/provider.ts +225 -0
  324. package/src/storage/agents/types.ts +82 -3
  325. package/src/storage/ai-cost/analytics.ts +602 -0
  326. package/src/storage/ai-cost/codec.ts +136 -0
  327. package/src/storage/ai-cost/errors.ts +12 -0
  328. package/src/storage/ai-cost/in-memory.ts +164 -0
  329. package/src/storage/ai-cost/index.ts +35 -0
  330. package/src/storage/ai-cost/provider.ts +20 -0
  331. package/src/storage/ai-cost/types.ts +193 -0
  332. package/src/storage/ai-cost/validation.ts +337 -0
  333. package/src/storage/ai-usage/in-memory.ts +23 -0
  334. package/src/storage/ai-usage/index.ts +1 -0
  335. package/src/storage/ai-usage/types.ts +10 -0
  336. package/src/storage/in-memory/index.ts +50 -0
  337. package/src/storage/index.ts +48 -0
  338. package/src/storage/objects/in-memory.ts +103 -16
  339. package/src/storage/objects/index.ts +9 -0
  340. package/src/storage/objects/keys.ts +36 -0
  341. package/src/storage/objects/types.ts +34 -6
  342. package/src/storage/ontology/in-memory/materializations.ts +1 -0
  343. package/src/storage/ontology/materializations.ts +3 -0
  344. package/src/storage/ontology/provider-header-validation.ts +2 -2
  345. package/src/storage/operation-scope.ts +1 -0
  346. package/src/storage/types.ts +2 -0
  347. package/src/testing/agent-storage-contract.ts +353 -2
  348. package/src/testing/ai-cost-storage-contract.ts +320 -0
  349. package/src/testing/ai-usage-storage-contract.ts +35 -0
  350. package/src/testing/effective-storage-contract.ts +194 -4
  351. package/src/testing/index.ts +5 -0
  352. package/src/testing/lake-storage-contract.ts +56 -0
  353. package/src/testing/materializer-storage-contract.ts +120 -2
  354. package/src/testing/object-query-contract.ts +208 -1
  355. package/src/workers/queue-worker.ts +14 -1
  356. package/src/workflows/execution.ts +31 -10
  357. package/dist/agents/prompt.d.ts +0 -15
  358. package/dist/agents/prompt.d.ts.map +0 -1
  359. package/dist/chunk-0mbx247x.js.map +0 -43
  360. package/dist/chunk-34bqh420.js.map +0 -23
  361. package/dist/chunk-57zpb99z.js.map +0 -10
  362. package/dist/chunk-663csy96.js.map +0 -10
  363. package/dist/chunk-6wetht33.js +0 -89
  364. package/dist/chunk-6wetht33.js.map +0 -10
  365. package/dist/chunk-88ppkr54.js.map +0 -12
  366. package/dist/chunk-nnyp53zt.js.map +0 -13
  367. package/dist/chunk-nten49ta.js.map +0 -12
  368. package/dist/chunk-st4xgxey.js.map +0 -45
  369. package/dist/chunk-vp1vc6ee.js +0 -35
  370. package/dist/chunk-vp1vc6ee.js.map +0 -11
  371. package/src/agents/prompt.ts +0 -57
  372. /package/dist/{chunk-sa4340y1.js.map → chunk-1yz3x65y.js.map} +0 -0
  373. /package/dist/{chunk-gqdd7508.js.map → chunk-4rh2m6zg.js.map} +0 -0
  374. /package/dist/{chunk-4x43bkbp.js.map → chunk-a09jx26t.js.map} +0 -0
  375. /package/dist/{chunk-zg9yryhz.js.map → chunk-cbkm2vam.js.map} +0 -0
  376. /package/dist/{chunk-8ryen3p3.js.map → chunk-f6erf2vv.js.map} +0 -0
  377. /package/dist/{chunk-bct7hmfc.js.map → chunk-g13869yf.js.map} +0 -0
  378. /package/dist/{chunk-0k4avqr2.js.map → chunk-hbeh8j9w.js.map} +0 -0
  379. /package/dist/{chunk-qvybnnpe.js.map → chunk-nzw7sm3b.js.map} +0 -0
  380. /package/dist/{chunk-bh6k3nc6.js.map → chunk-rs1wbvy6.js.map} +0 -0
  381. /package/dist/{chunk-7pc8b818.js.map → chunk-sxwk41qa.js.map} +0 -0
  382. /package/dist/{chunk-5egfka8j.js.map → chunk-tycbzedm.js.map} +0 -0
  383. /package/dist/{chunk-g9t3kdtx.js.map → chunk-x2yw73hy.js.map} +0 -0
@@ -7,10 +7,10 @@ import {
7
7
  effectsWithoutEditsMessage,
8
8
  isObjectActionDefinition,
9
9
  missingActionMutationMessage
10
- } from "./chunk-c6qd89g5.js";
10
+ } from "./chunk-tek1qwgm.js";
11
11
  import {
12
12
  createLinkScopeFingerprint
13
- } from "./chunk-st4xgxey.js";
13
+ } from "./chunk-afjpa2hs.js";
14
14
  import {
15
15
  linkRefKey,
16
16
  linkScopeKey,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  createDisabledRuntimeAuthorization,
4
4
  createPrincipalRuntimeAuthorization
5
- } from "./chunk-34bqh420.js";
5
+ } from "./chunk-f83ka50g.js";
6
6
 
7
7
  // src/execution/scopes.ts
8
8
  import { randomUUID } from "crypto";
@@ -142,7 +142,8 @@ function createAgentOperationScope(target, scope) {
142
142
  return createOperationScopedFacade(target, scope, {
143
143
  threads: createOperationScopedFacade(target.threads, scope),
144
144
  runs: createOperationScopedFacade(target.runs, scope),
145
- messages: createOperationScopedFacade(target.messages, scope)
145
+ messages: createOperationScopedFacade(target.messages, scope),
146
+ checkpoints: createOperationScopedFacade(target.checkpoints, scope)
146
147
  });
147
148
  }
148
149
  function createOntologyOperationScope(target, scope) {
@@ -168,4 +169,4 @@ function isAsyncGeneratorFunction(value) {
168
169
 
169
170
  export { createStorageOperationScope, createOperationScopedFacade, decorateOperationScopedMethodForTesting, createAuthOperationScope, createAgentOperationScope, createOntologyOperationScope, createWorkflowRunOperationScope };
170
171
 
171
- //# debugId=57DEB820B7182A4E64756E2164756E21
172
+ //# debugId=199E470686426F9664756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/storage/operation-scope.ts"],
4
4
  "sourcesContent": [
5
- "import { AsyncLocalStorage } from \"node:async_hooks\"\nimport type { AgentStorage } from \"./agents\"\nimport type { AuthStorage } from \"./auth\"\nimport type { OntologyStorage } from \"./ontology\"\nimport type { WorkflowRunStorage } from \"./workflow-runs\"\n\nexport type StorageOperationRunner = <TResult>(\n run: () => Promise<TResult> | TResult\n) => Promise<TResult>\n\n/** Provider-owned execution boundary for root storage operations. */\nexport interface StorageOperationScope {\n assertAvailable(): void\n run<TResult>(operation: () => Promise<TResult> | TResult): Promise<TResult>\n}\n\nexport function createStorageOperationScope(\n run: StorageOperationRunner,\n assertAvailable: () => void = () => undefined\n): StorageOperationScope {\n const executions = new AsyncLocalStorage<{ active: boolean }>()\n return {\n assertAvailable,\n async run(operation) {\n const inherited = executions.getStore()\n if (inherited?.active) {\n assertAvailable()\n return operation()\n }\n\n const execution = { active: true }\n try {\n return await executions.run(execution, () => run(operation))\n } finally {\n execution.active = false\n }\n },\n }\n}\n\nconst operationScopeTargets = new WeakMap<object, object>()\n\n/**\n * Give every async operation exposed by a store one provider-owned execution scope.\n *\n * Storage contracts use `async` methods for I/O and reserve synchronous methods for local\n * capabilities such as `queryCapabilities()`. Discovering the former from their implementation\n * removes the second, manually synchronized method registry that previously coupled every storage\n * primitive to the SQLite/InMemory lock.\n */\nexport function createOperationScopedFacade<T extends object>(\n target: T,\n scope: StorageOperationScope,\n propertyOverrides: Partial<T> = {}\n): T {\n const methodKinds = discoverMethodKinds(target)\n const overrideKeys = new Set(Reflect.ownKeys(propertyOverrides))\n const methodCache = new Map<\n PropertyKey,\n { implementation: (...args: unknown[]) => unknown; exposed: (...args: unknown[]) => unknown }\n >()\n\n const facade = new Proxy(target, {\n get(current, property) {\n if (overrideKeys.has(property)) {\n return Reflect.get(propertyOverrides, property, propertyOverrides)\n }\n\n const value = Reflect.get(current, property, current)\n const kind = methodKinds.get(property)\n if (!kind || typeof value !== \"function\") return value\n const implementation = value as (...args: unknown[]) => unknown\n\n const cached = methodCache.get(property)\n if (cached?.implementation === implementation) return cached.exposed\n\n const exposed = scopeMethod(implementation, kind, current, scope)\n methodCache.set(property, { implementation, exposed })\n return exposed\n },\n set(current, property, value) {\n if (overrideKeys.has(property)) return false\n return Reflect.set(current, property, value, current)\n },\n defineProperty(current, property, attributes) {\n if (overrideKeys.has(property)) return false\n return Reflect.defineProperty(current, property, attributes)\n },\n deleteProperty(current, property) {\n if (overrideKeys.has(property)) return false\n return Reflect.deleteProperty(current, property)\n },\n })\n operationScopeTargets.set(facade, target)\n return facade\n}\n\ntype StorageMethod = (...args: never[]) => unknown\ntype StorageMethodKey<T> = {\n [TKey in keyof T]-?: T[TKey] extends StorageMethod ? TKey : never\n}[keyof T]\n\n/** Replace a provider method behind its scoped facade without exposing the raw provider. */\nexport function decorateOperationScopedMethodForTesting<\n T extends object,\n TKey extends StorageMethodKey<T>,\n>(\n facade: T,\n property: TKey,\n decorate: (implementation: Extract<T[TKey], StorageMethod>) => Extract<T[TKey], StorageMethod>\n): () => void {\n const target = operationScopeTargets.get(facade)\n if (!target) throw new Error(\"[Sixb] Expected an operation-scoped storage facade.\")\n\n const previousDescriptor = Reflect.getOwnPropertyDescriptor(target, property)\n const implementation = Reflect.get(target, property, target)\n if (typeof implementation !== \"function\") {\n throw new Error(`[Sixb] Storage property '${String(property)}' is not a method.`)\n }\n\n const boundImplementation = ((...args: never[]) =>\n Reflect.apply(implementation, target, args)) as Extract<T[TKey], StorageMethod>\n const decorated = decorate(boundImplementation)\n Reflect.defineProperty(target, property, {\n configurable: true,\n enumerable: previousDescriptor?.enumerable ?? false,\n writable: true,\n value: decorated,\n })\n\n return () => {\n if (previousDescriptor) {\n Reflect.defineProperty(target, property, previousDescriptor)\n } else {\n Reflect.deleteProperty(target, property)\n }\n }\n}\n\ntype StorageMethodKind = \"async\" | \"async-generator\" | \"sync\"\n\nfunction discoverMethodKinds(target: object): ReadonlyMap<PropertyKey, StorageMethodKind> {\n const methodKeys = new Set<PropertyKey>()\n for (\n let current: object | null = target;\n current && current !== Object.prototype;\n current = Object.getPrototypeOf(current)\n ) {\n for (const property of Reflect.ownKeys(current)) {\n if (property !== \"constructor\") methodKeys.add(property)\n }\n }\n\n const methodKinds = new Map<PropertyKey, StorageMethodKind>()\n for (const property of methodKeys) {\n const implementation = Reflect.get(target, property, target)\n if (typeof implementation !== \"function\") continue\n methodKinds.set(property, methodKind(implementation))\n }\n return methodKinds\n}\n\nfunction methodKind(implementation: (...args: unknown[]) => unknown): StorageMethodKind {\n if (isAsyncFunction(implementation)) return \"async\"\n if (isAsyncGeneratorFunction(implementation)) return \"async-generator\"\n return \"sync\"\n}\n\nfunction scopeMethod(\n implementation: (...args: unknown[]) => unknown,\n kind: StorageMethodKind,\n target: object,\n scope: StorageOperationScope\n): (...args: unknown[]) => unknown {\n if (kind === \"async\") {\n return (...args: unknown[]) => scope.run(() => Reflect.apply(implementation, target, args))\n }\n\n if (kind === \"async-generator\") {\n return (...args: unknown[]) => {\n scope.assertAvailable()\n return Reflect.apply(implementation, target, args)\n }\n }\n\n return implementation.bind(target)\n}\n\nexport function createAuthOperationScope<T extends AuthStorage>(\n target: T,\n scope: StorageOperationScope\n): T {\n return createOperationScopedFacade<AuthStorage>(target, scope, {\n users: createOperationScopedFacade(target.users, scope),\n identities: createOperationScopedFacade(target.identities, scope),\n serviceAccounts: createOperationScopedFacade(target.serviceAccounts, scope),\n serviceAccountGroupMemberships: createOperationScopedFacade(\n target.serviceAccountGroupMemberships,\n scope\n ),\n sessions: createOperationScopedFacade(target.sessions, scope),\n accessTokens: createOperationScopedFacade(target.accessTokens, scope),\n invitations: createOperationScopedFacade(target.invitations, scope),\n groupMemberships: createOperationScopedFacade(target.groupMemberships, scope),\n magicLinks: createOperationScopedFacade(target.magicLinks, scope),\n oidcAuthorizationAttempts: createOperationScopedFacade(target.oidcAuthorizationAttempts, scope),\n }) as T\n}\n\nexport function createAgentOperationScope<T extends AgentStorage>(\n target: T,\n scope: StorageOperationScope\n): T {\n return createOperationScopedFacade<AgentStorage>(target, scope, {\n threads: createOperationScopedFacade(target.threads, scope),\n runs: createOperationScopedFacade(target.runs, scope),\n messages: createOperationScopedFacade(target.messages, scope),\n }) as T\n}\n\nexport function createOntologyOperationScope<T extends OntologyStorage>(\n target: T,\n scope: StorageOperationScope\n): T {\n return createOperationScopedFacade<OntologyStorage>(target, scope, {\n commits: createOperationScopedFacade(target.commits, scope),\n sources: createOperationScopedFacade(target.sources, scope),\n materializations: createOperationScopedFacade(target.materializations, scope),\n outbox: createOperationScopedFacade(target.outbox, scope),\n }) as T\n}\n\nexport function createWorkflowRunOperationScope<T extends WorkflowRunStorage>(\n target: T,\n scope: StorageOperationScope\n): T {\n return createOperationScopedFacade<WorkflowRunStorage>(target, scope, {\n nodes: createOperationScopedFacade(target.nodes, scope),\n agentNodes: createOperationScopedFacade(target.agentNodes, scope),\n }) as T\n}\n\nfunction isAsyncFunction(value: unknown): value is (...args: unknown[]) => Promise<unknown> {\n return typeof value === \"function\" && value.constructor.name === \"AsyncFunction\"\n}\n\nfunction isAsyncGeneratorFunction(value: unknown): boolean {\n return typeof value === \"function\" && value.constructor.name === \"AsyncGeneratorFunction\"\n}\n"
5
+ "import { AsyncLocalStorage } from \"node:async_hooks\"\nimport type { AgentStorage } from \"./agents\"\nimport type { AuthStorage } from \"./auth\"\nimport type { OntologyStorage } from \"./ontology\"\nimport type { WorkflowRunStorage } from \"./workflow-runs\"\n\nexport type StorageOperationRunner = <TResult>(\n run: () => Promise<TResult> | TResult\n) => Promise<TResult>\n\n/** Provider-owned execution boundary for root storage operations. */\nexport interface StorageOperationScope {\n assertAvailable(): void\n run<TResult>(operation: () => Promise<TResult> | TResult): Promise<TResult>\n}\n\nexport function createStorageOperationScope(\n run: StorageOperationRunner,\n assertAvailable: () => void = () => undefined\n): StorageOperationScope {\n const executions = new AsyncLocalStorage<{ active: boolean }>()\n return {\n assertAvailable,\n async run(operation) {\n const inherited = executions.getStore()\n if (inherited?.active) {\n assertAvailable()\n return operation()\n }\n\n const execution = { active: true }\n try {\n return await executions.run(execution, () => run(operation))\n } finally {\n execution.active = false\n }\n },\n }\n}\n\nconst operationScopeTargets = new WeakMap<object, object>()\n\n/**\n * Give every async operation exposed by a store one provider-owned execution scope.\n *\n * Storage contracts use `async` methods for I/O and reserve synchronous methods for local\n * capabilities such as `queryCapabilities()`. Discovering the former from their implementation\n * removes the second, manually synchronized method registry that previously coupled every storage\n * primitive to the SQLite/InMemory lock.\n */\nexport function createOperationScopedFacade<T extends object>(\n target: T,\n scope: StorageOperationScope,\n propertyOverrides: Partial<T> = {}\n): T {\n const methodKinds = discoverMethodKinds(target)\n const overrideKeys = new Set(Reflect.ownKeys(propertyOverrides))\n const methodCache = new Map<\n PropertyKey,\n { implementation: (...args: unknown[]) => unknown; exposed: (...args: unknown[]) => unknown }\n >()\n\n const facade = new Proxy(target, {\n get(current, property) {\n if (overrideKeys.has(property)) {\n return Reflect.get(propertyOverrides, property, propertyOverrides)\n }\n\n const value = Reflect.get(current, property, current)\n const kind = methodKinds.get(property)\n if (!kind || typeof value !== \"function\") return value\n const implementation = value as (...args: unknown[]) => unknown\n\n const cached = methodCache.get(property)\n if (cached?.implementation === implementation) return cached.exposed\n\n const exposed = scopeMethod(implementation, kind, current, scope)\n methodCache.set(property, { implementation, exposed })\n return exposed\n },\n set(current, property, value) {\n if (overrideKeys.has(property)) return false\n return Reflect.set(current, property, value, current)\n },\n defineProperty(current, property, attributes) {\n if (overrideKeys.has(property)) return false\n return Reflect.defineProperty(current, property, attributes)\n },\n deleteProperty(current, property) {\n if (overrideKeys.has(property)) return false\n return Reflect.deleteProperty(current, property)\n },\n })\n operationScopeTargets.set(facade, target)\n return facade\n}\n\ntype StorageMethod = (...args: never[]) => unknown\ntype StorageMethodKey<T> = {\n [TKey in keyof T]-?: T[TKey] extends StorageMethod ? TKey : never\n}[keyof T]\n\n/** Replace a provider method behind its scoped facade without exposing the raw provider. */\nexport function decorateOperationScopedMethodForTesting<\n T extends object,\n TKey extends StorageMethodKey<T>,\n>(\n facade: T,\n property: TKey,\n decorate: (implementation: Extract<T[TKey], StorageMethod>) => Extract<T[TKey], StorageMethod>\n): () => void {\n const target = operationScopeTargets.get(facade)\n if (!target) throw new Error(\"[Sixb] Expected an operation-scoped storage facade.\")\n\n const previousDescriptor = Reflect.getOwnPropertyDescriptor(target, property)\n const implementation = Reflect.get(target, property, target)\n if (typeof implementation !== \"function\") {\n throw new Error(`[Sixb] Storage property '${String(property)}' is not a method.`)\n }\n\n const boundImplementation = ((...args: never[]) =>\n Reflect.apply(implementation, target, args)) as Extract<T[TKey], StorageMethod>\n const decorated = decorate(boundImplementation)\n Reflect.defineProperty(target, property, {\n configurable: true,\n enumerable: previousDescriptor?.enumerable ?? false,\n writable: true,\n value: decorated,\n })\n\n return () => {\n if (previousDescriptor) {\n Reflect.defineProperty(target, property, previousDescriptor)\n } else {\n Reflect.deleteProperty(target, property)\n }\n }\n}\n\ntype StorageMethodKind = \"async\" | \"async-generator\" | \"sync\"\n\nfunction discoverMethodKinds(target: object): ReadonlyMap<PropertyKey, StorageMethodKind> {\n const methodKeys = new Set<PropertyKey>()\n for (\n let current: object | null = target;\n current && current !== Object.prototype;\n current = Object.getPrototypeOf(current)\n ) {\n for (const property of Reflect.ownKeys(current)) {\n if (property !== \"constructor\") methodKeys.add(property)\n }\n }\n\n const methodKinds = new Map<PropertyKey, StorageMethodKind>()\n for (const property of methodKeys) {\n const implementation = Reflect.get(target, property, target)\n if (typeof implementation !== \"function\") continue\n methodKinds.set(property, methodKind(implementation))\n }\n return methodKinds\n}\n\nfunction methodKind(implementation: (...args: unknown[]) => unknown): StorageMethodKind {\n if (isAsyncFunction(implementation)) return \"async\"\n if (isAsyncGeneratorFunction(implementation)) return \"async-generator\"\n return \"sync\"\n}\n\nfunction scopeMethod(\n implementation: (...args: unknown[]) => unknown,\n kind: StorageMethodKind,\n target: object,\n scope: StorageOperationScope\n): (...args: unknown[]) => unknown {\n if (kind === \"async\") {\n return (...args: unknown[]) => scope.run(() => Reflect.apply(implementation, target, args))\n }\n\n if (kind === \"async-generator\") {\n return (...args: unknown[]) => {\n scope.assertAvailable()\n return Reflect.apply(implementation, target, args)\n }\n }\n\n return implementation.bind(target)\n}\n\nexport function createAuthOperationScope<T extends AuthStorage>(\n target: T,\n scope: StorageOperationScope\n): T {\n return createOperationScopedFacade<AuthStorage>(target, scope, {\n users: createOperationScopedFacade(target.users, scope),\n identities: createOperationScopedFacade(target.identities, scope),\n serviceAccounts: createOperationScopedFacade(target.serviceAccounts, scope),\n serviceAccountGroupMemberships: createOperationScopedFacade(\n target.serviceAccountGroupMemberships,\n scope\n ),\n sessions: createOperationScopedFacade(target.sessions, scope),\n accessTokens: createOperationScopedFacade(target.accessTokens, scope),\n invitations: createOperationScopedFacade(target.invitations, scope),\n groupMemberships: createOperationScopedFacade(target.groupMemberships, scope),\n magicLinks: createOperationScopedFacade(target.magicLinks, scope),\n oidcAuthorizationAttempts: createOperationScopedFacade(target.oidcAuthorizationAttempts, scope),\n }) as T\n}\n\nexport function createAgentOperationScope<T extends AgentStorage>(\n target: T,\n scope: StorageOperationScope\n): T {\n return createOperationScopedFacade<AgentStorage>(target, scope, {\n threads: createOperationScopedFacade(target.threads, scope),\n runs: createOperationScopedFacade(target.runs, scope),\n messages: createOperationScopedFacade(target.messages, scope),\n checkpoints: createOperationScopedFacade(target.checkpoints, scope),\n }) as T\n}\n\nexport function createOntologyOperationScope<T extends OntologyStorage>(\n target: T,\n scope: StorageOperationScope\n): T {\n return createOperationScopedFacade<OntologyStorage>(target, scope, {\n commits: createOperationScopedFacade(target.commits, scope),\n sources: createOperationScopedFacade(target.sources, scope),\n materializations: createOperationScopedFacade(target.materializations, scope),\n outbox: createOperationScopedFacade(target.outbox, scope),\n }) as T\n}\n\nexport function createWorkflowRunOperationScope<T extends WorkflowRunStorage>(\n target: T,\n scope: StorageOperationScope\n): T {\n return createOperationScopedFacade<WorkflowRunStorage>(target, scope, {\n nodes: createOperationScopedFacade(target.nodes, scope),\n agentNodes: createOperationScopedFacade(target.agentNodes, scope),\n }) as T\n}\n\nfunction isAsyncFunction(value: unknown): value is (...args: unknown[]) => Promise<unknown> {\n return typeof value === \"function\" && value.constructor.name === \"AsyncFunction\"\n}\n\nfunction isAsyncGeneratorFunction(value: unknown): boolean {\n return typeof value === \"function\" && value.constructor.name === \"AsyncGeneratorFunction\"\n}\n"
6
6
  ],
7
- "mappings": ";;AAAA;AAgBO,SAAS,2BAA2B,CACzC,KACA,kBAA8B,MAAG;AAAA,EAAG;AAAA,GACb;AAAA,EACvB,MAAM,aAAa,IAAI;AAAA,EACvB,OAAO;AAAA,IACL;AAAA,SACM,IAAG,CAAC,WAAW;AAAA,MACnB,MAAM,YAAY,WAAW,SAAS;AAAA,MACtC,IAAI,WAAW,QAAQ;AAAA,QACrB,gBAAgB;AAAA,QAChB,OAAO,UAAU;AAAA,MACnB;AAAA,MAEA,MAAM,YAAY,EAAE,QAAQ,KAAK;AAAA,MACjC,IAAI;AAAA,QACF,OAAO,MAAM,WAAW,IAAI,WAAW,MAAM,IAAI,SAAS,CAAC;AAAA,gB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4BAA4B,OAAO,YAAY,KAAK;AAAA,EAClE,CAAC;AAAA;AAGH,SAAS,eAAe,CAAC,OAAmE;AAAA,EAC1F,OAAO,OAAO,UAAU,cAAc,MAAM,YAAY,SAAS;AAAA;AAGnE,SAAS,wBAAwB,CAAC,OAAyB;AAAA,EACzD,OAAO,OAAO,UAAU,cAAc,MAAM,YAAY,SAAS;AAAA;",
8
+ "debugId": "199E470686426F9664756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -0,0 +1,133 @@
1
+ // @bun
2
+ import {
3
+ agentServiceAccountId
4
+ } from "./chunk-nzw7sm3b.js";
5
+ import {
6
+ findAgentRunExecution
7
+ } from "./chunk-t9xghkva.js";
8
+
9
+ // src/storage/agents/errors.ts
10
+ class AgentStorageError extends Error {
11
+ code;
12
+ name = "AgentStorageError";
13
+ constructor(code, message) {
14
+ super(message);
15
+ this.code = code;
16
+ }
17
+ }
18
+
19
+ // src/storage/agents/provider.ts
20
+ async function assertAgentRunExecution(input) {
21
+ const execution = await findAgentRunExecution({
22
+ executions: input.executions,
23
+ projectId: input.projectId,
24
+ executionId: input.executionId,
25
+ runId: input.runId,
26
+ serviceAccountId: agentServiceAccountId(input.agentId)
27
+ });
28
+ if (!execution) {
29
+ throw new AgentStorageError("invalid_input", `[Sixb] Execution '${input.executionId}' does not authorize Agent run '${input.runId}'.`);
30
+ }
31
+ }
32
+ function assertCreateAgentContextCheckpointInput(input, prefix = "Sixb") {
33
+ for (const [name, value] of [
34
+ ["id", input.id],
35
+ ["projectId", input.projectId],
36
+ ["threadId", input.threadId],
37
+ ["createdByRunId", input.createdByRunId],
38
+ ["executionToken", input.executionToken],
39
+ ["summary", input.summary],
40
+ ["summaryModelId", input.summaryModelId]
41
+ ]) {
42
+ if (value.trim().length === 0) {
43
+ throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint '${name}' must not be empty.`);
44
+ }
45
+ }
46
+ if (input.summaryFormatVersion !== 1) {
47
+ throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint summary format version must be 1.`);
48
+ }
49
+ if (input.reason !== "threshold" && input.reason !== "overflow") {
50
+ throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint reason must be 'threshold' or 'overflow'.`);
51
+ }
52
+ if (input.expectedPreviousCheckpointId !== null && input.expectedPreviousCheckpointId.trim().length === 0) {
53
+ throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint expected previous id must not be empty.`);
54
+ }
55
+ if (input.createdAt && !Number.isFinite(input.createdAt.getTime())) {
56
+ throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint createdAt must be a valid date.`);
57
+ }
58
+ for (const [name, value, minimum] of [
59
+ ["expectedHeadSeq", input.expectedHeadSeq, 1],
60
+ ["summarizedThroughSeq", input.summarizedThroughSeq, 1],
61
+ ["observedHeadSeq", input.observedHeadSeq, 1],
62
+ ["estimatedInputTokensBefore", input.estimatedInputTokensBefore, 0],
63
+ ["estimatedInputTokensAfter", input.estimatedInputTokensAfter, 0]
64
+ ]) {
65
+ if (!Number.isSafeInteger(value) || value < minimum) {
66
+ throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint '${name}' must be a safe integer greater than or equal to ${minimum}.`);
67
+ }
68
+ }
69
+ if (input.observedHeadSeq !== input.expectedHeadSeq) {
70
+ throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint observed head must equal its expected message head.`);
71
+ }
72
+ if (input.summarizedThroughSeq >= input.observedHeadSeq) {
73
+ throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint must retain the triggering head message.`);
74
+ }
75
+ }
76
+ function assertAgentContextCheckpointAuthority(input) {
77
+ const { create, run, thread } = input;
78
+ const prefix = input.prefix ?? "Sixb";
79
+ if (!run) {
80
+ throw new AgentStorageError("run_not_found", `[${prefix}] Agent run '${create.createdByRunId}' not found for project '${create.projectId}'.`);
81
+ }
82
+ if (!thread) {
83
+ throw new AgentStorageError("thread_not_found", `[${prefix}] Agent thread '${create.threadId}' not found for project '${create.projectId}'.`);
84
+ }
85
+ if (run.threadId !== create.threadId) {
86
+ throw new AgentStorageError("invalid_input", `[${prefix}] Agent run '${run.id}' does not belong to thread '${create.threadId}'.`);
87
+ }
88
+ if (run.status !== "running") {
89
+ throw new AgentStorageError("invalid_state", `[${prefix}] Agent run '${run.id}' is not running (status '${run.status}').`);
90
+ }
91
+ if (!run.execution || run.execution.token !== create.executionToken) {
92
+ throw new AgentStorageError("execution_lost", `[${prefix}] Execution token is no longer current on agent run '${run.id}'.`);
93
+ }
94
+ if (thread.activeRunId !== run.id) {
95
+ throw new AgentStorageError("invalid_state", `[${prefix}] Agent run '${run.id}' no longer owns thread '${thread.id}'.`);
96
+ }
97
+ }
98
+ function assertAgentContextCheckpointAnchors(input) {
99
+ const { create, latest, headSeq, firstRetained } = input;
100
+ const prefix = input.prefix ?? "Sixb";
101
+ if (headSeq !== create.expectedHeadSeq) {
102
+ throw new AgentStorageError("invalid_state", `[${prefix}] Agent thread '${create.threadId}' message head changed from ${create.expectedHeadSeq} to ${headSeq}.`);
103
+ }
104
+ const latestId = latest?.id ?? null;
105
+ if (latestId !== create.expectedPreviousCheckpointId) {
106
+ throw new AgentStorageError("invalid_state", `[${prefix}] Agent thread '${create.threadId}' checkpoint head changed.`);
107
+ }
108
+ if (latest && create.summarizedThroughSeq <= latest.summarizedThroughSeq) {
109
+ throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint boundary must advance beyond sequence ${latest.summarizedThroughSeq}.`);
110
+ }
111
+ if (!firstRetained || firstRetained.seq !== create.summarizedThroughSeq + 1) {
112
+ throw new AgentStorageError("invalid_state", `[${prefix}] Agent context checkpoint boundary does not align with stored thread messages.`);
113
+ }
114
+ if (firstRetained.role !== "user") {
115
+ throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint must retain a complete turn beginning with a user message.`);
116
+ }
117
+ }
118
+ function assertAgentContextCheckpointReplayState(input) {
119
+ const prefix = input.prefix ?? "Sixb";
120
+ if (input.headSeq !== input.create.expectedHeadSeq) {
121
+ throw new AgentStorageError("invalid_state", `[${prefix}] Agent thread '${input.create.threadId}' message head changed from ${input.create.expectedHeadSeq} to ${input.headSeq}.`);
122
+ }
123
+ if (input.latest?.id !== input.existing.id) {
124
+ throw new AgentStorageError("invalid_state", `[${prefix}] Agent thread '${input.create.threadId}' checkpoint head changed after '${input.existing.id}'.`);
125
+ }
126
+ }
127
+ function agentContextCheckpointMatchesCreateInput(record, input) {
128
+ return record.id === input.id && record.projectId === input.projectId && record.threadId === input.threadId && record.createdByRunId === input.createdByRunId && (record.previousCheckpointId ?? null) === input.expectedPreviousCheckpointId && record.reason === input.reason && record.summary === input.summary && record.summaryFormatVersion === input.summaryFormatVersion && record.summarizedThroughSeq === input.summarizedThroughSeq && record.observedHeadSeq === input.observedHeadSeq && record.estimatedInputTokensBefore === input.estimatedInputTokensBefore && record.estimatedInputTokensAfter === input.estimatedInputTokensAfter && record.summaryModelId === input.summaryModelId;
129
+ }
130
+
131
+ export { AgentStorageError, assertAgentRunExecution, assertCreateAgentContextCheckpointInput, assertAgentContextCheckpointAuthority, assertAgentContextCheckpointAnchors, assertAgentContextCheckpointReplayState, agentContextCheckpointMatchesCreateInput };
132
+
133
+ //# debugId=C4E16AF3EE9252A464756E2164756E21
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/storage/agents/errors.ts", "../src/storage/agents/provider.ts"],
4
+ "sourcesContent": [
5
+ "export type AgentStorageErrorCode =\n | \"thread_not_found\"\n | \"active_run_exists\"\n | \"run_not_found\"\n | \"invalid_input\"\n | \"invalid_state\"\n | \"execution_lost\"\n | \"duplicate_id\"\n\n/**\n * Error for agent-storage invariants and invalid state transitions (single-flight, execution\n * ownership, run lifecycle, message append). Callers branch on `code` rather than message text.\n */\nexport class AgentStorageError extends Error {\n readonly name = \"AgentStorageError\"\n\n constructor(\n readonly code: AgentStorageErrorCode,\n message: string\n ) {\n super(message)\n }\n}\n",
6
+ "import { agentServiceAccountId } from \"../../agents/authority\"\nimport type { ExecutionStorage } from \"../executions\"\nimport { findAgentRunExecution } from \"../executions/run-link\"\nimport { AgentStorageError } from \"./errors\"\nimport type {\n AgentContextCheckpointRecord,\n AgentMessageRecord,\n AgentRunRecord,\n AgentThreadRecord,\n CreateAgentContextCheckpointInput,\n} from \"./types\"\n\n/** Validate the semantic link between a conversational Agent run and its immutable execution. */\nexport async function assertAgentRunExecution(input: {\n readonly executions: ExecutionStorage\n readonly projectId: string\n readonly executionId: string\n readonly runId: string\n readonly agentId: string\n}): Promise<void> {\n const execution = await findAgentRunExecution({\n executions: input.executions,\n projectId: input.projectId,\n executionId: input.executionId,\n runId: input.runId,\n serviceAccountId: agentServiceAccountId(input.agentId),\n })\n if (!execution) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[Sixb] Execution '${input.executionId}' does not authorize Agent run '${input.runId}'.`\n )\n }\n}\n\n/** Validate provider-independent checkpoint fields before entering a storage critical section. */\nexport function assertCreateAgentContextCheckpointInput(\n input: CreateAgentContextCheckpointInput,\n prefix = \"Sixb\"\n): void {\n for (const [name, value] of [\n [\"id\", input.id],\n [\"projectId\", input.projectId],\n [\"threadId\", input.threadId],\n [\"createdByRunId\", input.createdByRunId],\n [\"executionToken\", input.executionToken],\n [\"summary\", input.summary],\n [\"summaryModelId\", input.summaryModelId],\n ] as const) {\n if (value.trim().length === 0) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint '${name}' must not be empty.`\n )\n }\n }\n\n if (input.summaryFormatVersion !== 1) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint summary format version must be 1.`\n )\n }\n if (input.reason !== \"threshold\" && input.reason !== \"overflow\") {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint reason must be 'threshold' or 'overflow'.`\n )\n }\n if (\n input.expectedPreviousCheckpointId !== null &&\n input.expectedPreviousCheckpointId.trim().length === 0\n ) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint expected previous id must not be empty.`\n )\n }\n if (input.createdAt && !Number.isFinite(input.createdAt.getTime())) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint createdAt must be a valid date.`\n )\n }\n\n for (const [name, value, minimum] of [\n [\"expectedHeadSeq\", input.expectedHeadSeq, 1],\n [\"summarizedThroughSeq\", input.summarizedThroughSeq, 1],\n [\"observedHeadSeq\", input.observedHeadSeq, 1],\n [\"estimatedInputTokensBefore\", input.estimatedInputTokensBefore, 0],\n [\"estimatedInputTokensAfter\", input.estimatedInputTokensAfter, 0],\n ] as const) {\n if (!Number.isSafeInteger(value) || value < minimum) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint '${name}' must be a safe integer greater than or equal to ${minimum}.`\n )\n }\n }\n\n if (input.observedHeadSeq !== input.expectedHeadSeq) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint observed head must equal its expected message head.`\n )\n }\n if (input.summarizedThroughSeq >= input.observedHeadSeq) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint must retain the triggering head message.`\n )\n }\n}\n\n/** Assert that the current delivery still owns the active conversational run. */\nexport function assertAgentContextCheckpointAuthority(input: {\n readonly create: CreateAgentContextCheckpointInput\n readonly run: AgentRunRecord | null\n readonly thread: AgentThreadRecord | null\n readonly prefix?: string\n}): asserts input is typeof input & {\n readonly run: AgentRunRecord\n readonly thread: AgentThreadRecord\n} {\n const { create, run, thread } = input\n const prefix = input.prefix ?? \"Sixb\"\n if (!run) {\n throw new AgentStorageError(\n \"run_not_found\",\n `[${prefix}] Agent run '${create.createdByRunId}' not found for project '${create.projectId}'.`\n )\n }\n if (!thread) {\n throw new AgentStorageError(\n \"thread_not_found\",\n `[${prefix}] Agent thread '${create.threadId}' not found for project '${create.projectId}'.`\n )\n }\n if (run.threadId !== create.threadId) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent run '${run.id}' does not belong to thread '${create.threadId}'.`\n )\n }\n if (run.status !== \"running\") {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent run '${run.id}' is not running (status '${run.status}').`\n )\n }\n if (!run.execution || run.execution.token !== create.executionToken) {\n throw new AgentStorageError(\n \"execution_lost\",\n `[${prefix}] Execution token is no longer current on agent run '${run.id}'.`\n )\n }\n if (thread.activeRunId !== run.id) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent run '${run.id}' no longer owns thread '${thread.id}'.`\n )\n }\n}\n\n/** Assert both compare-and-swap anchors and the retained-turn boundary. */\nexport function assertAgentContextCheckpointAnchors(input: {\n readonly create: CreateAgentContextCheckpointInput\n readonly latest: AgentContextCheckpointRecord | null\n readonly headSeq: number\n readonly firstRetained: AgentMessageRecord | null\n readonly prefix?: string\n}): void {\n const { create, latest, headSeq, firstRetained } = input\n const prefix = input.prefix ?? \"Sixb\"\n if (headSeq !== create.expectedHeadSeq) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent thread '${create.threadId}' message head changed from ${create.expectedHeadSeq} to ${headSeq}.`\n )\n }\n\n const latestId = latest?.id ?? null\n if (latestId !== create.expectedPreviousCheckpointId) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent thread '${create.threadId}' checkpoint head changed.`\n )\n }\n if (latest && create.summarizedThroughSeq <= latest.summarizedThroughSeq) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint boundary must advance beyond sequence ${latest.summarizedThroughSeq}.`\n )\n }\n if (!firstRetained || firstRetained.seq !== create.summarizedThroughSeq + 1) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent context checkpoint boundary does not align with stored thread messages.`\n )\n }\n if (firstRetained.role !== \"user\") {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint must retain a complete turn beginning with a user message.`\n )\n }\n}\n\n/** Validate the mutable anchors again before returning an idempotently created checkpoint. */\nexport function assertAgentContextCheckpointReplayState(input: {\n readonly create: CreateAgentContextCheckpointInput\n readonly existing: AgentContextCheckpointRecord\n readonly latest: AgentContextCheckpointRecord | null\n readonly headSeq: number\n readonly prefix?: string\n}): void {\n const prefix = input.prefix ?? \"Sixb\"\n if (input.headSeq !== input.create.expectedHeadSeq) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent thread '${input.create.threadId}' message head changed from ${input.create.expectedHeadSeq} to ${input.headSeq}.`\n )\n }\n if (input.latest?.id !== input.existing.id) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent thread '${input.create.threadId}' checkpoint head changed after '${input.existing.id}'.`\n )\n }\n}\n\n/** Compare the durable semantic payload; delivery token and generated timestamp are not content. */\nexport function agentContextCheckpointMatchesCreateInput(\n record: AgentContextCheckpointRecord,\n input: CreateAgentContextCheckpointInput\n): boolean {\n return (\n record.id === input.id &&\n record.projectId === input.projectId &&\n record.threadId === input.threadId &&\n record.createdByRunId === input.createdByRunId &&\n (record.previousCheckpointId ?? null) === input.expectedPreviousCheckpointId &&\n record.reason === input.reason &&\n record.summary === input.summary &&\n record.summaryFormatVersion === input.summaryFormatVersion &&\n record.summarizedThroughSeq === input.summarizedThroughSeq &&\n record.observedHeadSeq === input.observedHeadSeq &&\n record.estimatedInputTokensBefore === input.estimatedInputTokensBefore &&\n record.estimatedInputTokensAfter === input.estimatedInputTokensAfter &&\n record.summaryModelId === input.summaryModelId\n )\n}\n"
7
+ ],
8
+ "mappings": ";;;;;;;;;AAaO,MAAM,0BAA0B,MAAM;AAAA,EAIhC;AAAA,EAHF,OAAO;AAAA,EAEhB,WAAW,CACA,MACT,SACA;AAAA,IACA,MAAM,OAAO;AAAA,IAHJ;AAAA;AAKb;;;ACTA,eAAsB,uBAAuB,CAAC,OAM5B;AAAA,EAChB,MAAM,YAAY,MAAM,sBAAsB;AAAA,IA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uC,MAAM,OAAO,sBAAsB,MAAM,UAC5H;AAAA,EACF;AAAA,EACA,IAAI,MAAM,QAAQ,OAAO,MAAM,SAAS,IAAI;AAAA,IAC1C,MAAM,IAAI,kBACR,iBACA,IAAI,yBAAyB,MAAM,OAAO,4CAA4C,MAAM,SAAS,MACvG;AAAA,EACF;AAAA;AAIK,SAAS,wCAAwC,CACtD,QACA,OACS;AAAA,EACT,OACE,OAAO,OAAO,MAAM,MACpB,OAAO,cAAc,MAAM,aAC3B,OAAO,aAAa,MAAM,YAC1B,OAAO,mBAAmB,MAAM,mBAC/B,OAAO,wBAAwB,UAAU,MAAM,gCAChD,OAAO,WAAW,MAAM,UACxB,OAAO,YAAY,MAAM,WACzB,OAAO,yBAAyB,MAAM,wBACtC,OAAO,yBAAyB,MAAM,wBACtC,OAAO,oBAAoB,MAAM,mBACjC,OAAO,+BAA+B,MAAM,8BAC5C,OAAO,8BAA8B,MAAM,6BAC3C,OAAO,mBAAmB,MAAM;AAAA;",
9
+ "debugId": "C4E16AF3EE9252A464756E2164756E21",
10
+ "names": []
11
+ }
@@ -4,59 +4,61 @@ import {
4
4
  bindDurableAgentExecution,
5
5
  createAgentExecutionRecord,
6
6
  restoreAgentExecutionScope
7
- } from "../chunk-0mbx247x.js";
8
- import"../chunk-bct7hmfc.js";
9
- import"../chunk-zg9yryhz.js";
10
- import"../chunk-k9pts48t.js";
11
- import"../chunk-gqdd7508.js";
7
+ } from "../chunk-c43qr6s0.js";
8
+ import"../chunk-g13869yf.js";
9
+ import"../chunk-cbkm2vam.js";
10
+ import"../chunk-pn8n8sba.js";
11
+ import"../chunk-4rh2m6zg.js";
12
12
  import"../chunk-xhy826cz.js";
13
- import"../chunk-nnyp53zt.js";
14
- import"../chunk-88ppkr54.js";
15
- import"../chunk-63te770v.js";
13
+ import"../chunk-7gw7mepb.js";
14
+ import"../chunk-rte5sm3z.js";
15
+ import"../chunk-qewtks41.js";
16
16
  import"../chunk-8b55ygje.js";
17
17
  import"../chunk-51fjndv0.js";
18
18
  import"../chunk-8m5ejdpn.js";
19
19
  import"../chunk-nf4r78r4.js";
20
- import"../chunk-5egfka8j.js";
21
- import"../chunk-c6qd89g5.js";
22
- import"../chunk-st4xgxey.js";
23
- import"../chunk-8ryen3p3.js";
24
- import"../chunk-ys1nse2v.js";
25
- import"../chunk-fmx1sz2h.js";
26
- import"../chunk-57r1cpxx.js";
20
+ import"../chunk-tycbzedm.js";
21
+ import"../chunk-tek1qwgm.js";
22
+ import"../chunk-afjpa2hs.js";
23
+ import"../chunk-96swp2wd.js";
24
+ import"../chunk-f6erf2vv.js";
25
+ import"../chunk-1wk20wn3.js";
26
+ import"../chunk-72q2y8hn.js";
27
+ import"../chunk-xc7hq65b.js";
27
28
  import"../chunk-cy0n5dms.js";
28
29
  import"../chunk-dysw7nsm.js";
29
30
  import"../chunk-62c7t4jc.js";
30
31
  import"../chunk-ezake7g1.js";
31
- import"../chunk-4x43bkbp.js";
32
+ import"../chunk-a09jx26t.js";
32
33
  import"../chunk-htq0qh7z.js";
33
34
  import"../chunk-xkthy56g.js";
34
- import"../chunk-vp1vc6ee.js";
35
- import"../chunk-qvybnnpe.js";
35
+ import"../chunk-xdf9yswn.js";
36
+ import"../chunk-nzw7sm3b.js";
36
37
  import"../chunk-t9xghkva.js";
38
+ import"../chunk-drjqm1aa.js";
37
39
  import"../chunk-5gd7tpv6.js";
38
40
  import"../chunk-h9kxd41f.js";
39
41
  import"../chunk-9dzba0f2.js";
40
42
  import"../chunk-vybf6pkp.js";
41
43
  import"../chunk-ry24jbr1.js";
42
- import"../chunk-6wetht33.js";
43
44
  import"../chunk-3j7573mj.js";
44
45
  import"../chunk-4gz41why.js";
45
46
  import"../chunk-zcnhxkvd.js";
46
47
  import"../chunk-1evzqhks.js";
47
48
  import"../chunk-dsrkgtnh.js";
48
49
  import"../chunk-bhxaq2nn.js";
50
+ import"../chunk-yt8wphsx.js";
51
+ import"../chunk-rdeagz6b.js";
52
+ import"../chunk-dm72y8wt.js";
53
+ import"../chunk-t0jjkep3.js";
54
+ import"../chunk-tkdscva6.js";
55
+ import"../chunk-rhrbz7d4.js";
56
+ import"../chunk-xwnf87e1.js";
57
+ import"../chunk-f83ka50g.js";
49
58
  import"../chunk-rnshztfq.js";
50
59
  import"../chunk-04b07a9q.js";
51
60
  import"../chunk-dktq02ne.js";
52
61
  import"../chunk-zqysyfjt.js";
53
- import"../chunk-yt8wphsx.js";
54
- import"../chunk-85j5ybfj.js";
55
- import"../chunk-57zpb99z.js";
56
- import"../chunk-663csy96.js";
57
- import"../chunk-jaj13078.js";
58
- import"../chunk-xwnf87e1.js";
59
- import"../chunk-34bqh420.js";
60
62
  import"../chunk-0172wgm9.js";
61
63
  import"../chunk-t8t39h7v.js";
62
64
  import"../chunk-y64skrwp.js";
@@ -67,4 +69,4 @@ export {
67
69
  assertAgentExecutionRecord
68
70
  };
69
71
 
70
- //# debugId=8C2844BF10870D2364756E2164756E21
72
+ //# debugId=E543B5F16BE8040764756E2164756E21
@@ -4,6 +4,6 @@
4
4
  "sourcesContent": [
5
5
  ],
6
6
  "mappings": "",
7
- "debugId": "8C2844BF10870D2364756E2164756E21",
7
+ "debugId": "E543B5F16BE8040764756E2164756E21",
8
8
  "names": []
9
9
  }
@@ -1,63 +1,65 @@
1
1
  // @bun
2
2
  import {
3
3
  isBoundSixb
4
- } from "../chunk-0mbx247x.js";
5
- import"../chunk-bct7hmfc.js";
6
- import"../chunk-zg9yryhz.js";
7
- import"../chunk-k9pts48t.js";
8
- import"../chunk-gqdd7508.js";
4
+ } from "../chunk-c43qr6s0.js";
5
+ import"../chunk-g13869yf.js";
6
+ import"../chunk-cbkm2vam.js";
7
+ import"../chunk-pn8n8sba.js";
8
+ import"../chunk-4rh2m6zg.js";
9
9
  import {
10
10
  getOntologyMutationRuntime
11
11
  } from "../chunk-xhy826cz.js";
12
- import"../chunk-nnyp53zt.js";
13
- import"../chunk-88ppkr54.js";
14
- import"../chunk-63te770v.js";
12
+ import"../chunk-7gw7mepb.js";
13
+ import"../chunk-rte5sm3z.js";
14
+ import"../chunk-qewtks41.js";
15
15
  import"../chunk-8b55ygje.js";
16
16
  import"../chunk-51fjndv0.js";
17
17
  import"../chunk-8m5ejdpn.js";
18
18
  import"../chunk-nf4r78r4.js";
19
- import"../chunk-5egfka8j.js";
20
- import"../chunk-c6qd89g5.js";
21
- import"../chunk-st4xgxey.js";
19
+ import"../chunk-tycbzedm.js";
20
+ import"../chunk-tek1qwgm.js";
21
+ import"../chunk-afjpa2hs.js";
22
+ import"../chunk-96swp2wd.js";
22
23
  import {
23
24
  restoreTrustedPrimitiveExecutionScope
24
- } from "../chunk-8ryen3p3.js";
25
- import"../chunk-ys1nse2v.js";
26
- import"../chunk-fmx1sz2h.js";
27
- import"../chunk-57r1cpxx.js";
25
+ } from "../chunk-f6erf2vv.js";
26
+ import"../chunk-1wk20wn3.js";
27
+ import"../chunk-72q2y8hn.js";
28
+ import"../chunk-xc7hq65b.js";
28
29
  import"../chunk-cy0n5dms.js";
29
30
  import"../chunk-dysw7nsm.js";
30
31
  import"../chunk-62c7t4jc.js";
31
32
  import"../chunk-ezake7g1.js";
32
- import"../chunk-4x43bkbp.js";
33
+ import"../chunk-a09jx26t.js";
33
34
  import"../chunk-htq0qh7z.js";
34
35
  import"../chunk-xkthy56g.js";
35
- import"../chunk-vp1vc6ee.js";
36
- import"../chunk-qvybnnpe.js";
36
+ import"../chunk-xdf9yswn.js";
37
+ import"../chunk-nzw7sm3b.js";
37
38
  import"../chunk-t9xghkva.js";
39
+ import"../chunk-drjqm1aa.js";
38
40
  import"../chunk-5gd7tpv6.js";
39
41
  import"../chunk-h9kxd41f.js";
40
42
  import"../chunk-9dzba0f2.js";
41
43
  import"../chunk-vybf6pkp.js";
42
44
  import"../chunk-ry24jbr1.js";
43
- import"../chunk-6wetht33.js";
44
45
  import"../chunk-3j7573mj.js";
45
46
  import"../chunk-4gz41why.js";
46
47
  import"../chunk-zcnhxkvd.js";
47
48
  import"../chunk-1evzqhks.js";
48
49
  import"../chunk-dsrkgtnh.js";
49
50
  import"../chunk-bhxaq2nn.js";
51
+ import"../chunk-yt8wphsx.js";
52
+ import"../chunk-rdeagz6b.js";
53
+ import"../chunk-dm72y8wt.js";
54
+ import"../chunk-t0jjkep3.js";
55
+ import"../chunk-tkdscva6.js";
56
+ import"../chunk-rhrbz7d4.js";
57
+ import"../chunk-xwnf87e1.js";
58
+ import"../chunk-f83ka50g.js";
50
59
  import"../chunk-rnshztfq.js";
51
60
  import"../chunk-04b07a9q.js";
52
61
  import"../chunk-dktq02ne.js";
53
62
  import"../chunk-zqysyfjt.js";
54
- import"../chunk-yt8wphsx.js";
55
- import"../chunk-85j5ybfj.js";
56
- import"../chunk-57zpb99z.js";
57
- import"../chunk-663csy96.js";
58
- import"../chunk-jaj13078.js";
59
- import"../chunk-xwnf87e1.js";
60
- import"../chunk-34bqh420.js";
61
63
  import"../chunk-0172wgm9.js";
62
64
  import"../chunk-t8t39h7v.js";
63
65
  import"../chunk-y64skrwp.js";
@@ -85,4 +87,4 @@ export {
85
87
  bindDurablePrimitiveExecution
86
88
  };
87
89
 
88
- //# debugId=4F7596760A4099A664756E2164756E21
90
+ //# debugId=E4BA1F2A0FAF53ED64756E2164756E21
@@ -4,7 +4,7 @@
4
4
  "sourcesContent": [
5
5
  "import type { OntologySource } from \"../ontology\"\nimport type { OntologyMutationRuntime } from \"../runtime/ontology-mutations\"\nimport { getOntologyMutationRuntime } from \"../runtime/ontology-mutations\"\nimport { isBoundSixb, type Sixb } from \"../runtime/sixb\"\nimport type { ExecutionRecord } from \"../storage/executions\"\nimport { restoreTrustedPrimitiveExecutionScope } from \"./durable\"\nimport type { ExecutionScope, TrustedPrimitiveRef } from \"./types\"\n\n/** Minimal host boundary required by trusted primitive workers. */\nexport interface PrimitiveExecutionHost {\n readonly id: string\n withScope(scope: ExecutionScope): object\n}\n\nexport interface BoundPrimitiveExecution {\n readonly sixb: Sixb<readonly OntologySource[]>\n /** Internal mutation port guarded by the same runtime authority as `sixb`. */\n readonly ontologyMutations: OntologyMutationRuntime\n}\n\n/** Bind a worker to the immutable execution already owned by its durable primitive run. */\nexport function bindDurablePrimitiveExecution(\n host: PrimitiveExecutionHost,\n input: {\n readonly execution: ExecutionRecord\n readonly primitive: TrustedPrimitiveRef\n }\n): BoundPrimitiveExecution {\n return bindPrimitiveScope(host, restoreTrustedPrimitiveExecutionScope(input))\n}\n\nfunction bindPrimitiveScope(\n host: PrimitiveExecutionHost,\n scope: ExecutionScope\n): BoundPrimitiveExecution {\n let ontologyMutations: OntologyMutationRuntime | undefined\n\n const sixb = host.withScope(scope)\n if (!isBoundSixb(sixb)) {\n throw new Error(\"[Sixb] Primitive execution host returned an invalid bound SDK.\")\n }\n const bound: BoundPrimitiveExecution = {\n sixb,\n get ontologyMutations() {\n ontologyMutations ??= getOntologyMutationRuntime(sixb)\n return ontologyMutations\n },\n }\n return Object.freeze(bound)\n}\n"
6
6
  ],
7
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBO,SAAS,6BAA6B,CAC3C,MACA,OAIyB;AAAA,EACzB,OAAO,mBAAmB,MAAM,sCAAsC,KAAK,CAAC;AAAA;AAG9E,SAAS,kBAAkB,CACzB,MACA,OACyB;AAAA,EACzB,IAAI;AAAA,EAEJ,MAAM,OAAO,KAAK,UAAU,KAAK;AAAA,EACjC,IAAI,CAAC,YAAY,IAAI,GAAG;AAAA,IACtB,MAAM,IAAI,MAAM,gEAAgE;AAAA,EAClF;AAAA,EACA,MAAM,QAAiC;AAAA,IACrC;AAAA,QACI,iBAAiB,GAAG;AAAA,MACtB,sBAAsB,2BAA2B,IAAI;AAAA,MACrD,OAAO;AAAA;AAAA,EAEX;AAAA,EACA,OAAO,OAAO,OAAO,KAAK;AAAA;",
8
- "debugId": "4F7596760A4099A664756E2164756E21",
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBO,SAAS,6BAA6B,CAC3C,MACA,OAIyB;AAAA,EACzB,OAAO,mBAAmB,MAAM,sCAAsC,KAAK,CAAC;AAAA;AAG9E,SAAS,kBAAkB,CACzB,MACA,OACyB;AAAA,EACzB,IAAI;AAAA,EAEJ,MAAM,OAAO,KAAK,UAAU,KAAK;AAAA,EACjC,IAAI,CAAC,YAAY,IAAI,GAAG;AAAA,IACtB,MAAM,IAAI,MAAM,gEAAgE;AAAA,EAClF;AAAA,EACA,MAAM,QAAiC;AAAA,IACrC;AAAA,QACI,iBAAiB,GAAG;AAAA,MACtB,sBAAsB,2BAA2B,IAAI;AAAA,MACrD,OAAO;AAAA;AAAA,EAEX;AAAA,EACA,OAAO,OAAO,OAAO,KAAK;AAAA;",
8
+ "debugId": "E4BA1F2A0FAF53ED64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -2,62 +2,64 @@
2
2
  import {
3
3
  createDisabledRequestScope,
4
4
  createPrincipalRequestScope
5
- } from "../chunk-g9t3kdtx.js";
5
+ } from "../chunk-x2yw73hy.js";
6
6
  import {
7
7
  isBoundSixb
8
- } from "../chunk-0mbx247x.js";
9
- import"../chunk-bct7hmfc.js";
10
- import"../chunk-zg9yryhz.js";
11
- import"../chunk-k9pts48t.js";
12
- import"../chunk-gqdd7508.js";
8
+ } from "../chunk-c43qr6s0.js";
9
+ import"../chunk-g13869yf.js";
10
+ import"../chunk-cbkm2vam.js";
11
+ import"../chunk-pn8n8sba.js";
12
+ import"../chunk-4rh2m6zg.js";
13
13
  import"../chunk-xhy826cz.js";
14
- import"../chunk-nnyp53zt.js";
15
- import"../chunk-88ppkr54.js";
16
- import"../chunk-63te770v.js";
14
+ import"../chunk-7gw7mepb.js";
15
+ import"../chunk-rte5sm3z.js";
16
+ import"../chunk-qewtks41.js";
17
17
  import"../chunk-8b55ygje.js";
18
18
  import"../chunk-51fjndv0.js";
19
19
  import"../chunk-8m5ejdpn.js";
20
20
  import"../chunk-nf4r78r4.js";
21
- import"../chunk-5egfka8j.js";
22
- import"../chunk-c6qd89g5.js";
23
- import"../chunk-st4xgxey.js";
24
- import"../chunk-8ryen3p3.js";
25
- import"../chunk-ys1nse2v.js";
26
- import"../chunk-fmx1sz2h.js";
27
- import"../chunk-57r1cpxx.js";
21
+ import"../chunk-tycbzedm.js";
22
+ import"../chunk-tek1qwgm.js";
23
+ import"../chunk-afjpa2hs.js";
24
+ import"../chunk-96swp2wd.js";
25
+ import"../chunk-f6erf2vv.js";
26
+ import"../chunk-1wk20wn3.js";
27
+ import"../chunk-72q2y8hn.js";
28
+ import"../chunk-xc7hq65b.js";
28
29
  import"../chunk-cy0n5dms.js";
29
30
  import"../chunk-dysw7nsm.js";
30
31
  import"../chunk-62c7t4jc.js";
31
32
  import"../chunk-ezake7g1.js";
32
- import"../chunk-4x43bkbp.js";
33
+ import"../chunk-a09jx26t.js";
33
34
  import"../chunk-htq0qh7z.js";
34
35
  import"../chunk-xkthy56g.js";
35
- import"../chunk-vp1vc6ee.js";
36
- import"../chunk-qvybnnpe.js";
36
+ import"../chunk-xdf9yswn.js";
37
+ import"../chunk-nzw7sm3b.js";
37
38
  import"../chunk-t9xghkva.js";
39
+ import"../chunk-drjqm1aa.js";
38
40
  import"../chunk-5gd7tpv6.js";
39
41
  import"../chunk-h9kxd41f.js";
40
42
  import"../chunk-9dzba0f2.js";
41
43
  import"../chunk-vybf6pkp.js";
42
44
  import"../chunk-ry24jbr1.js";
43
- import"../chunk-6wetht33.js";
44
45
  import"../chunk-3j7573mj.js";
45
46
  import"../chunk-4gz41why.js";
46
47
  import"../chunk-zcnhxkvd.js";
47
48
  import"../chunk-1evzqhks.js";
48
49
  import"../chunk-dsrkgtnh.js";
49
50
  import"../chunk-bhxaq2nn.js";
51
+ import"../chunk-yt8wphsx.js";
52
+ import"../chunk-rdeagz6b.js";
53
+ import"../chunk-dm72y8wt.js";
54
+ import"../chunk-t0jjkep3.js";
55
+ import"../chunk-tkdscva6.js";
56
+ import"../chunk-rhrbz7d4.js";
57
+ import"../chunk-xwnf87e1.js";
58
+ import"../chunk-f83ka50g.js";
50
59
  import"../chunk-rnshztfq.js";
51
60
  import"../chunk-04b07a9q.js";
52
61
  import"../chunk-dktq02ne.js";
53
62
  import"../chunk-zqysyfjt.js";
54
- import"../chunk-yt8wphsx.js";
55
- import"../chunk-85j5ybfj.js";
56
- import"../chunk-57zpb99z.js";
57
- import"../chunk-663csy96.js";
58
- import"../chunk-jaj13078.js";
59
- import"../chunk-xwnf87e1.js";
60
- import"../chunk-34bqh420.js";
61
63
  import"../chunk-0172wgm9.js";
62
64
  import"../chunk-t8t39h7v.js";
63
65
  import"../chunk-y64skrwp.js";
@@ -94,4 +96,4 @@ export {
94
96
  bindRequestExecution
95
97
  };
96
98
 
97
- //# debugId=F830B50C978608F064756E2164756E21
99
+ //# debugId=3784441E6A6BD84464756E2164756E21
@@ -4,7 +4,7 @@
4
4
  "sourcesContent": [
5
5
  "import { randomUUID } from \"node:crypto\"\nimport type { AuthorizationContext } from \"../authorization\"\nimport type { OntologySource } from \"../ontology\"\nimport { isBoundSixb, type Sixb } from \"../runtime/sixb\"\nimport { createDisabledRequestScope, createPrincipalRequestScope } from \"./scopes\"\nimport type { AuthorizationRef, ExecutionScope } from \"./types\"\n\nexport type { ActionRunsRuntime, ActionsRuntime } from \"../actions/execution\"\nexport type {\n AgentRunListResult,\n AgentRunsRuntime,\n AgentRunView,\n AgentsRuntime,\n AgentThreadsRuntime,\n CreateExecutionAgentThreadInput,\n ExecutionAgentRequestInput,\n ListExecutionAgentThreadsInput,\n} from \"../agents/execution\"\nexport type { AuthorizationContext } from \"../authorization\"\nexport type { DatasetsRuntime } from \"../datasets/execution\"\nexport type { EventsRuntime } from \"../events/execution\"\nexport type { LogsRuntime } from \"../logging/execution\"\nexport type {\n ExecutionObjectByIdHandle,\n ExecutionObjectSet,\n ObjectsRuntime,\n} from \"../objects/execution\"\nexport type {\n PipelineRunsRuntime,\n PipelinesRuntime,\n} from \"../pipelines/execution\"\nexport type {\n ProjectionRunsRuntime,\n ProjectionsRuntime,\n} from \"../projections/execution\"\nexport type { RuleStatesRuntime, RulesRuntime } from \"../rules/execution\"\nexport type { Sixb } from \"../runtime/sixb\"\nexport type { SyncRunsRuntime, SyncsRuntime } from \"../syncs/execution\"\nexport type {\n LatestWorkflowRunListResult,\n ListWorkflowRunNodesInput,\n WorkflowAgentNodeRunView,\n WorkflowInterventionsRuntime,\n WorkflowNodeRunListResult,\n WorkflowNodeRunView,\n WorkflowRunListResult,\n WorkflowRunsRuntime,\n WorkflowRunView,\n WorkflowsRuntime,\n} from \"../workflows/execution\"\nexport type { AuthorizationRef, ExecutionContext } from \"./types\"\n\nexport type RequestExecutionAuthorization =\n | {\n readonly type: \"principal\"\n readonly context: AuthorizationContext\n readonly credential?: Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]\n }\n | { readonly type: \"disabled\" }\n\nexport interface BindRequestExecutionInput {\n readonly request: Request\n readonly authorization: RequestExecutionAuthorization\n}\n\nexport interface RequestExecutionHost {\n readonly id: string\n withScope(scope: ExecutionScope): object\n}\n\n/** Bind one HTTP or WebSocket request without exposing trusted or kernel capability factories. */\nexport function bindRequestExecution(\n host: RequestExecutionHost,\n input: BindRequestExecutionInput\n): Sixb<readonly OntologySource[]> {\n const requestId = requestIdentifier(input.request)\n const correlationId = correlationIdentifier(input.request, requestId)\n const scope =\n input.authorization.type === \"principal\"\n ? createPrincipalRequestScope({\n projectId: host.id,\n requestId,\n correlationId,\n context: input.authorization.context,\n ...(input.authorization.credential === undefined\n ? {}\n : { credential: input.authorization.credential }),\n })\n : createDisabledRequestScope({ projectId: host.id, requestId, correlationId })\n\n const sixb = host.withScope(scope)\n if (!isBoundSixb(sixb)) {\n throw new Error(\"[Sixb] Request host did not return an execution-bound Sixb SDK.\")\n }\n return sixb\n}\n\nfunction requestIdentifier(request: Request): string {\n return headerIdentifier(request, \"x-request-id\") ?? `req_${randomUUID()}`\n}\n\nfunction correlationIdentifier(request: Request, requestId: string): string {\n return headerIdentifier(request, \"x-correlation-id\") ?? requestId\n}\n\nfunction headerIdentifier(request: Request, name: string): string | undefined {\n const value = request.headers.get(name)?.trim()\n return value ? value : undefined\n}\n"
6
6
  ],
7
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAuEO,SAAS,oBAAoB,CAClC,MACA,OACiC;AAAA,EACjC,MAAM,YAAY,kBAAkB,MAAM,OAAO;AAAA,EACjD,MAAM,gBAAgB,sBAAsB,MAAM,SAAS,SAAS;AAAA,EACpE,MAAM,QACJ,MAAM,cAAc,SAAS,cACzB,4BAA4B;AAAA,IAC1B,WAAW,KAAK;AAAA,IAChB;AAAA,IACA;AAAA,IACA,SAAS,MAAM,cAAc;AAAA,OACzB,MAAM,cAAc,eAAe,YACnC,CAAC,IACD,EAAE,YAAY,MAAM,cAAc,WAAW;AAAA,EACnD,CAAC,IACD,2BAA2B,EAAE,WAAW,KAAK,IAAI,WAAW,cAAc,CAAC;AAAA,EAEjF,MAAM,OAAO,KAAK,UAAU,KAAK;AAAA,EACjC,IAAI,CAAC,YAAY,IAAI,GAAG;AAAA,IACtB,MAAM,IAAI,MAAM,iEAAiE;AAAA,EACnF;AAAA,EACA,OAAO;AAAA;AAGT,SAAS,iBAAiB,CAAC,SAA0B;AAAA,EACnD,OAAO,iBAAiB,SAAS,cAAc,KAAK,OAAO,WAAW;AAAA;AAGxE,SAAS,qBAAqB,CAAC,SAAkB,WAA2B;AAAA,EAC1E,OAAO,iBAAiB,SAAS,kBAAkB,KAAK;AAAA;AAG1D,SAAS,gBAAgB,CAAC,SAAkB,MAAkC;AAAA,EAC5E,MAAM,QAAQ,QAAQ,QAAQ,IAAI,IAAI,GAAG,KAAK;AAAA,EAC9C,OAAO,QAAQ,QAAQ;AAAA;",
8
- "debugId": "F830B50C978608F064756E2164756E21",
7
+ "mappings": ";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