@sixb/core 0.1.6 → 0.1.7

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 (535) hide show
  1. package/dist/actions/index.js +37 -33
  2. package/dist/actions/index.js.map +1 -1
  3. package/dist/actions/worker.js +3 -3
  4. package/dist/agents/adapters.d.ts +33 -76
  5. package/dist/agents/adapters.d.ts.map +1 -1
  6. package/dist/agents/authority.d.ts +22 -6
  7. package/dist/agents/authority.d.ts.map +1 -1
  8. package/dist/agents/builders.d.ts +3 -11
  9. package/dist/agents/builders.d.ts.map +1 -1
  10. package/dist/agents/context.js +2 -2
  11. package/dist/agents/dispatch.d.ts +9 -1
  12. package/dist/agents/dispatch.d.ts.map +1 -1
  13. package/dist/agents/errors.d.ts +2 -2
  14. package/dist/agents/errors.d.ts.map +1 -1
  15. package/dist/agents/execution.d.ts +9 -10
  16. package/dist/agents/execution.d.ts.map +1 -1
  17. package/dist/agents/ids.d.ts +4 -0
  18. package/dist/agents/ids.d.ts.map +1 -1
  19. package/dist/agents/index.d.ts +13 -9
  20. package/dist/agents/index.d.ts.map +1 -1
  21. package/dist/agents/index.js +80 -68
  22. package/dist/agents/index.js.map +1 -1
  23. package/dist/agents/message.d.ts +17 -10
  24. package/dist/agents/message.d.ts.map +1 -1
  25. package/dist/agents/model-loop.d.ts +56 -0
  26. package/dist/agents/model-loop.d.ts.map +1 -0
  27. package/dist/agents/reference.d.ts +4 -0
  28. package/dist/agents/reference.d.ts.map +1 -0
  29. package/dist/agents/request.d.ts +10 -8
  30. package/dist/agents/request.d.ts.map +1 -1
  31. package/dist/agents/retired-config.d.ts +4 -0
  32. package/dist/agents/retired-config.d.ts.map +1 -0
  33. package/dist/agents/streams.d.ts +13 -8
  34. package/dist/agents/streams.d.ts.map +1 -1
  35. package/dist/agents/streams.js +7 -5
  36. package/dist/agents/streams.js.map +1 -1
  37. package/dist/agents/tool-catalog.d.ts +9 -0
  38. package/dist/agents/tool-catalog.d.ts.map +1 -0
  39. package/dist/agents/tool-definition.d.ts +1 -0
  40. package/dist/agents/tool-definition.d.ts.map +1 -1
  41. package/dist/agents/types.d.ts +31 -68
  42. package/dist/agents/types.d.ts.map +1 -1
  43. package/dist/agents/validation.d.ts +4 -10
  44. package/dist/agents/validation.d.ts.map +1 -1
  45. package/dist/ai-usage/execution.d.ts +53 -0
  46. package/dist/ai-usage/execution.d.ts.map +1 -0
  47. package/dist/ai-usage/index.d.ts +3 -0
  48. package/dist/ai-usage/index.d.ts.map +1 -0
  49. package/dist/auth/index.js +7 -7
  50. package/dist/authorization/decision.d.ts +5 -2
  51. package/dist/authorization/decision.d.ts.map +1 -1
  52. package/dist/authorization/grant-kinds.d.ts +24 -8
  53. package/dist/authorization/grant-kinds.d.ts.map +1 -1
  54. package/dist/authorization/index.d.ts +1 -1
  55. package/dist/authorization/index.d.ts.map +1 -1
  56. package/dist/authorization/index.js +8 -6
  57. package/dist/authorization/index.js.map +1 -1
  58. package/dist/authorization/resolve.d.ts +3 -3
  59. package/dist/authorization/resolve.d.ts.map +1 -1
  60. package/dist/authorization/types.d.ts +7 -5
  61. package/dist/authorization/types.d.ts.map +1 -1
  62. package/dist/blob-storage/browser.js +2 -2
  63. package/dist/blob-storage/index.js +3 -3
  64. package/dist/bootstrap/discovery.d.ts +1 -7
  65. package/dist/bootstrap/discovery.d.ts.map +1 -1
  66. package/dist/bootstrap/index.js +52 -48
  67. package/dist/bootstrap/index.js.map +1 -1
  68. package/dist/broker/index.js +2 -2
  69. package/dist/{chunk-zqysyfjt.js → chunk-08m3b6w8.js} +1 -1
  70. package/dist/{chunk-1g8negke.js → chunk-08twe8m6.js} +93 -8
  71. package/dist/chunk-08twe8m6.js.map +12 -0
  72. package/dist/{chunk-xkthy56g.js → chunk-1kamz6j0.js} +1 -1
  73. package/dist/{chunk-dy311asx.js → chunk-2b5qtban.js} +12 -12
  74. package/dist/{chunk-dy311asx.js.map → chunk-2b5qtban.js.map} +3 -3
  75. package/dist/{chunk-0172wgm9.js → chunk-2xns679x.js} +10 -2
  76. package/dist/{chunk-0172wgm9.js.map → chunk-2xns679x.js.map} +3 -3
  77. package/dist/{chunk-f83ka50g.js → chunk-37wk412q.js} +86 -28
  78. package/dist/{chunk-f83ka50g.js.map → chunk-37wk412q.js.map} +8 -8
  79. package/dist/{chunk-md8k0r54.js → chunk-3fqt22c4.js} +4 -4
  80. package/dist/{chunk-t9xghkva.js → chunk-3kv70xwp.js} +3 -2
  81. package/dist/{chunk-t9xghkva.js.map → chunk-3kv70xwp.js.map} +3 -3
  82. package/dist/{chunk-z3zp0bj1.js → chunk-407j3msh.js} +1 -1
  83. package/dist/{chunk-rhrbz7d4.js → chunk-4a849fr1.js} +1 -1
  84. package/dist/{chunk-62c7t4jc.js → chunk-4nxeacx7.js} +1 -1
  85. package/dist/{chunk-cy0n5dms.js → chunk-5jcdmjam.js} +1 -1
  86. package/dist/{chunk-819wnjz8.js → chunk-64sr682n.js} +7 -7
  87. package/dist/{chunk-t624af60.js → chunk-6ed5bwnd.js} +646 -67
  88. package/dist/{chunk-t624af60.js.map → chunk-6ed5bwnd.js.map} +10 -9
  89. package/dist/{chunk-x2yw73hy.js → chunk-7ds9620f.js} +1 -1
  90. package/dist/{chunk-dm72y8wt.js → chunk-7y0f6rf1.js} +29 -16
  91. package/dist/chunk-7y0f6rf1.js.map +10 -0
  92. package/dist/{chunk-72q2y8hn.js → chunk-8tsf6dmc.js} +2 -2
  93. package/dist/{chunk-nkbfrt0c.js → chunk-9aehf39w.js} +7 -7
  94. package/dist/{chunk-ezake7g1.js → chunk-agsvg9ar.js} +1 -1
  95. package/dist/{chunk-rdeagz6b.js → chunk-atmkaf60.js} +1 -1
  96. package/dist/{chunk-rdeagz6b.js.map → chunk-atmkaf60.js.map} +2 -2
  97. package/dist/chunk-c15dr03f.js +43 -0
  98. package/dist/chunk-c15dr03f.js.map +10 -0
  99. package/dist/{chunk-0hc5j867.js → chunk-d2ndstdf.js} +8 -6
  100. package/dist/{chunk-0hc5j867.js.map → chunk-d2ndstdf.js.map} +2 -2
  101. package/dist/{chunk-rnshztfq.js → chunk-d63tybny.js} +2 -2
  102. package/dist/{chunk-t0jjkep3.js → chunk-d8qkxt2v.js} +4 -2
  103. package/dist/chunk-d8qkxt2v.js.map +10 -0
  104. package/dist/{chunk-vybf6pkp.js → chunk-dbc80ad7.js} +1 -1
  105. package/dist/{chunk-4gz41why.js → chunk-dqn23610.js} +1 -1
  106. package/dist/{chunk-5sxb1168.js → chunk-e4rvtvpw.js} +13 -11
  107. package/dist/{chunk-5sxb1168.js.map → chunk-e4rvtvpw.js.map} +2 -2
  108. package/dist/{chunk-h9kxd41f.js → chunk-gbrpsx4m.js} +19 -6
  109. package/dist/chunk-gbrpsx4m.js.map +11 -0
  110. package/dist/{chunk-nva1xkjz.js → chunk-h0knpbz5.js} +468 -1236
  111. package/dist/chunk-h0knpbz5.js.map +38 -0
  112. package/dist/{chunk-tg5mee00.js → chunk-ha58tjtt.js} +6 -6
  113. package/dist/{chunk-f6erf2vv.js → chunk-hdz94br2.js} +2 -2
  114. package/dist/chunk-jecn6t54.js +307 -0
  115. package/dist/chunk-jecn6t54.js.map +12 -0
  116. package/dist/{chunk-dsrkgtnh.js → chunk-jq43kdvk.js} +1 -1
  117. package/dist/{chunk-wtmzkcht.js → chunk-k34z5rvh.js} +1 -1
  118. package/dist/{chunk-htq0qh7z.js → chunk-ka3a2ft3.js} +2 -2
  119. package/dist/{chunk-znagycq7.js → chunk-kt81c11h.js} +2 -2
  120. package/dist/chunk-n2arzn6e.js +1745 -0
  121. package/dist/chunk-n2arzn6e.js.map +20 -0
  122. package/dist/{chunk-f2rt4vkh.js → chunk-n2w475r0.js} +3 -3
  123. package/dist/{chunk-t8t39h7v.js → chunk-n6jxh8sw.js} +10 -2
  124. package/dist/chunk-n6jxh8sw.js.map +10 -0
  125. package/dist/{chunk-drjqm1aa.js → chunk-p03r0h5s.js} +310 -28
  126. package/dist/chunk-p03r0h5s.js.map +16 -0
  127. package/dist/chunk-p2vqaxkc.js +528 -0
  128. package/dist/chunk-p2vqaxkc.js.map +15 -0
  129. package/dist/{chunk-n4spznws.js → chunk-qjycjdj6.js} +84 -11
  130. package/dist/chunk-qjycjdj6.js.map +12 -0
  131. package/dist/chunk-qjzp9xyb.js +286 -0
  132. package/dist/chunk-qjzp9xyb.js.map +12 -0
  133. package/dist/{chunk-5gynx4xn.js → chunk-qv38twt8.js} +50 -69
  134. package/dist/{chunk-5gynx4xn.js.map → chunk-qv38twt8.js.map} +8 -8
  135. package/dist/{chunk-bhxaq2nn.js → chunk-qw9gvjv5.js} +1 -1
  136. package/dist/{chunk-8gv5z0zm.js → chunk-rp1mvzb4.js} +6 -6
  137. package/dist/{chunk-1e8m6yn3.js → chunk-rre42skh.js} +182 -18
  138. package/dist/chunk-rre42skh.js.map +39 -0
  139. package/dist/{chunk-ghteq96b.js → chunk-s5y30bc9.js} +2 -2
  140. package/dist/{chunk-a31h57d5.js → chunk-tn7xcs2n.js} +2 -2
  141. package/dist/{chunk-6gjqgd3d.js → chunk-tpnd31c1.js} +2 -1
  142. package/dist/chunk-tpnd31c1.js.map +11 -0
  143. package/dist/chunk-trxxmgnf.js +68 -0
  144. package/dist/chunk-trxxmgnf.js.map +11 -0
  145. package/dist/{chunk-e42bc6m3.js → chunk-vjjv9mrb.js} +2 -2
  146. package/dist/{chunk-8b55ygje.js → chunk-w3e09qqk.js} +1 -1
  147. package/dist/{chunk-ckxfnx7f.js → chunk-wjgm6jjt.js} +2 -2
  148. package/dist/{chunk-3j7573mj.js → chunk-x0qhkqje.js} +2 -2
  149. package/dist/{chunk-dysw7nsm.js → chunk-xdpwpkha.js} +2 -2
  150. package/dist/{chunk-a44d5zgd.js → chunk-y35ma3mj.js} +11 -16
  151. package/dist/{chunk-a44d5zgd.js.map → chunk-y35ma3mj.js.map} +3 -4
  152. package/dist/{chunk-qewtks41.js → chunk-z2sery1b.js} +64 -1
  153. package/dist/{chunk-qewtks41.js.map → chunk-z2sery1b.js.map} +3 -3
  154. package/dist/error-reporting/internal.js +4 -4
  155. package/dist/error-reporting/types.d.ts +7 -2
  156. package/dist/error-reporting/types.d.ts.map +1 -1
  157. package/dist/errors/catalog.d.ts +8 -0
  158. package/dist/errors/catalog.d.ts.map +1 -1
  159. package/dist/errors/internal.js +2 -2
  160. package/dist/events/index.js +4 -4
  161. package/dist/execution/agent.d.ts +18 -9
  162. package/dist/execution/agent.d.ts.map +1 -1
  163. package/dist/execution/agent.js +52 -43
  164. package/dist/execution/agent.js.map +1 -1
  165. package/dist/execution/authorization.d.ts +14 -4
  166. package/dist/execution/authorization.d.ts.map +1 -1
  167. package/dist/execution/primitive.js +45 -43
  168. package/dist/execution/primitive.js.map +2 -2
  169. package/dist/execution/request.d.ts +3 -1
  170. package/dist/execution/request.d.ts.map +1 -1
  171. package/dist/execution/request.js +46 -44
  172. package/dist/execution/request.js.map +3 -3
  173. package/dist/execution/types.d.ts +1 -1
  174. package/dist/execution/types.d.ts.map +1 -1
  175. package/dist/http/api-routes.d.ts.map +1 -1
  176. package/dist/http/index.js +1 -1
  177. package/dist/index.d.ts +9 -6
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +82 -77
  180. package/dist/index.js.map +1 -1
  181. package/dist/json.d.ts +2 -0
  182. package/dist/json.d.ts.map +1 -1
  183. package/dist/lake-storage/index.js +5 -5
  184. package/dist/logging/index.js +3 -3
  185. package/dist/logging/types.js +2 -2
  186. package/dist/materialization/index.js +2 -2
  187. package/dist/materializer/index.js +33 -29
  188. package/dist/materializer/index.js.map +1 -1
  189. package/dist/models/catalog.d.ts +40 -0
  190. package/dist/models/catalog.d.ts.map +1 -0
  191. package/dist/models/definitions.d.ts +25 -0
  192. package/dist/models/definitions.d.ts.map +1 -0
  193. package/dist/models/errors.d.ts +52 -0
  194. package/dist/models/errors.d.ts.map +1 -0
  195. package/dist/models/events.d.ts +192 -0
  196. package/dist/models/events.d.ts.map +1 -0
  197. package/dist/models/index.d.ts +17 -39
  198. package/dist/models/index.d.ts.map +1 -1
  199. package/dist/models/index.js +50 -0
  200. package/dist/models/index.js.map +9 -0
  201. package/dist/models/language-model.d.ts +90 -0
  202. package/dist/models/language-model.d.ts.map +1 -0
  203. package/dist/models/messages.d.ts +74 -0
  204. package/dist/models/messages.d.ts.map +1 -0
  205. package/dist/models/pricing.d.ts +69 -0
  206. package/dist/models/pricing.d.ts.map +1 -0
  207. package/dist/models/rate-card.d.ts +24 -0
  208. package/dist/models/rate-card.d.ts.map +1 -0
  209. package/dist/models/tools.d.ts +24 -0
  210. package/dist/models/tools.d.ts.map +1 -0
  211. package/dist/objects/index.js +38 -34
  212. package/dist/objects/index.js.map +1 -1
  213. package/dist/objects/query/index.js +32 -28
  214. package/dist/objects/query/index.js.map +1 -1
  215. package/dist/ontology/index.js +5 -5
  216. package/dist/ontology/internal.js +4 -4
  217. package/dist/pipelines/index.js +37 -35
  218. package/dist/pipelines/index.js.map +1 -1
  219. package/dist/projections/internal.js +35 -31
  220. package/dist/projections/internal.js.map +1 -1
  221. package/dist/queues/in-memory.d.ts +3 -2
  222. package/dist/queues/in-memory.d.ts.map +1 -1
  223. package/dist/queues/index.d.ts +3 -1
  224. package/dist/queues/index.d.ts.map +1 -1
  225. package/dist/queues/index.js +1 -1
  226. package/dist/queues/types.d.ts +15 -3
  227. package/dist/queues/types.d.ts.map +1 -1
  228. package/dist/runtime/create.d.ts +4 -4
  229. package/dist/runtime/create.d.ts.map +1 -1
  230. package/dist/runtime/definitions.d.ts +2 -2
  231. package/dist/runtime/definitions.d.ts.map +1 -1
  232. package/dist/runtime/host.d.ts +3 -2
  233. package/dist/runtime/host.d.ts.map +1 -1
  234. package/dist/runtime/resolve-definitions.d.ts +2 -2
  235. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  236. package/dist/runtime/sixb.d.ts +4 -2
  237. package/dist/runtime/sixb.d.ts.map +1 -1
  238. package/dist/security/every.d.ts +1 -4
  239. package/dist/security/every.d.ts.map +1 -1
  240. package/dist/security/grants.d.ts +6 -5
  241. package/dist/security/grants.d.ts.map +1 -1
  242. package/dist/security/index.d.ts +1 -1
  243. package/dist/security/index.d.ts.map +1 -1
  244. package/dist/security/registry.d.ts +1 -1
  245. package/dist/security/registry.d.ts.map +1 -1
  246. package/dist/security/types.d.ts +13 -5
  247. package/dist/security/types.d.ts.map +1 -1
  248. package/dist/security/validation.d.ts +4 -2
  249. package/dist/security/validation.d.ts.map +1 -1
  250. package/dist/storage/action-runs/failure.js +3 -3
  251. package/dist/storage/action-runs/provider.js +2 -2
  252. package/dist/storage/agents/errors.d.ts +1 -1
  253. package/dist/storage/agents/errors.d.ts.map +1 -1
  254. package/dist/storage/agents/in-memory.d.ts +3 -2
  255. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  256. package/dist/storage/agents/index.d.ts +1 -1
  257. package/dist/storage/agents/index.d.ts.map +1 -1
  258. package/dist/storage/agents/provider.d.ts +11 -4
  259. package/dist/storage/agents/provider.d.ts.map +1 -1
  260. package/dist/storage/agents/provider.js +18 -15
  261. package/dist/storage/agents/provider.js.map +1 -1
  262. package/dist/storage/agents/types.d.ts +65 -17
  263. package/dist/storage/agents/types.d.ts.map +1 -1
  264. package/dist/storage/ai-cost/analytics.d.ts +2 -1
  265. package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
  266. package/dist/storage/ai-cost/codec.d.ts +3 -2
  267. package/dist/storage/ai-cost/codec.d.ts.map +1 -1
  268. package/dist/storage/ai-cost/groups.d.ts +51 -0
  269. package/dist/storage/ai-cost/groups.d.ts.map +1 -0
  270. package/dist/storage/ai-cost/in-memory.d.ts +11 -1
  271. package/dist/storage/ai-cost/in-memory.d.ts.map +1 -1
  272. package/dist/storage/ai-cost/index.d.ts +1 -1
  273. package/dist/storage/ai-cost/index.d.ts.map +1 -1
  274. package/dist/storage/ai-cost/provider.d.ts +2 -0
  275. package/dist/storage/ai-cost/provider.d.ts.map +1 -1
  276. package/dist/storage/ai-cost/provider.js +29 -13
  277. package/dist/storage/ai-cost/provider.js.map +3 -3
  278. package/dist/storage/ai-cost/types.d.ts +64 -15
  279. package/dist/storage/ai-cost/types.d.ts.map +1 -1
  280. package/dist/storage/ai-cost/validation.d.ts +2 -1
  281. package/dist/storage/ai-cost/validation.d.ts.map +1 -1
  282. package/dist/storage/ai-limits/enforcement.d.ts +14 -0
  283. package/dist/storage/ai-limits/enforcement.d.ts.map +1 -0
  284. package/dist/storage/ai-limits/enforcement.js +21 -0
  285. package/dist/storage/ai-limits/enforcement.js.map +9 -0
  286. package/dist/storage/ai-limits/errors.d.ts +8 -0
  287. package/dist/storage/ai-limits/errors.d.ts.map +1 -0
  288. package/dist/storage/ai-limits/in-memory.d.ts +78 -0
  289. package/dist/storage/ai-limits/in-memory.d.ts.map +1 -0
  290. package/dist/storage/ai-limits/index.d.ts +7 -0
  291. package/dist/storage/ai-limits/index.d.ts.map +1 -0
  292. package/dist/storage/ai-limits/period.d.ts +4 -0
  293. package/dist/storage/ai-limits/period.d.ts.map +1 -0
  294. package/dist/storage/ai-limits/provider.d.ts +85 -0
  295. package/dist/storage/ai-limits/provider.d.ts.map +1 -0
  296. package/dist/storage/ai-limits/provider.js +62 -0
  297. package/dist/storage/ai-limits/provider.js.map +9 -0
  298. package/dist/storage/ai-limits/types.d.ts +175 -0
  299. package/dist/storage/ai-limits/types.d.ts.map +1 -0
  300. package/dist/storage/ai-usage/in-memory.d.ts +4 -0
  301. package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
  302. package/dist/storage/ai-usage/record.d.ts.map +1 -1
  303. package/dist/storage/ai-usage/types.d.ts +6 -2
  304. package/dist/storage/ai-usage/types.d.ts.map +1 -1
  305. package/dist/storage/auth/errors.d.ts +1 -1
  306. package/dist/storage/auth/errors.d.ts.map +1 -1
  307. package/dist/storage/auth/in-memory/auth-storage.d.ts +4 -1
  308. package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
  309. package/dist/storage/auth/in-memory/device-authorizations.d.ts +29 -0
  310. package/dist/storage/auth/in-memory/device-authorizations.d.ts.map +1 -0
  311. package/dist/storage/auth/in-memory/shared.d.ts +3 -1
  312. package/dist/storage/auth/in-memory/shared.d.ts.map +1 -1
  313. package/dist/storage/auth/index.d.ts +2 -1
  314. package/dist/storage/auth/index.d.ts.map +1 -1
  315. package/dist/storage/auth/types.d.ts +66 -0
  316. package/dist/storage/auth/types.d.ts.map +1 -1
  317. package/dist/storage/connector-connections/provider.js +2 -2
  318. package/dist/storage/executions/provider.js +1 -1
  319. package/dist/storage/executions/run-link.d.ts +7 -2
  320. package/dist/storage/executions/run-link.d.ts.map +1 -1
  321. package/dist/storage/executions/validation.d.ts.map +1 -1
  322. package/dist/storage/in-memory/index.d.ts +4 -0
  323. package/dist/storage/in-memory/index.d.ts.map +1 -1
  324. package/dist/storage/index.d.ts +7 -4
  325. package/dist/storage/index.d.ts.map +1 -1
  326. package/dist/storage/index.js +51 -38
  327. package/dist/storage/index.js.map +1 -1
  328. package/dist/storage/ontology/provider.js +3 -3
  329. package/dist/storage/pipeline-runs/provider.js +2 -2
  330. package/dist/storage/projection-runs/provider.js +4 -4
  331. package/dist/storage/sync-runs/provider.js +2 -2
  332. package/dist/storage/types.d.ts +5 -1
  333. package/dist/storage/types.d.ts.map +1 -1
  334. package/dist/storage/webhook-runs/provider.js +2 -2
  335. package/dist/storage/workflow-runs/provider.d.ts +1 -1
  336. package/dist/storage/workflow-runs/provider.js +10 -11
  337. package/dist/storage/workflow-runs/provider.js.map +1 -1
  338. package/dist/storage/workflow-runs/types.d.ts +5 -4
  339. package/dist/storage/workflow-runs/types.d.ts.map +1 -1
  340. package/dist/syncs/index.js +37 -35
  341. package/dist/syncs/index.js.map +1 -1
  342. package/dist/testing/agent-execution.d.ts +3 -1
  343. package/dist/testing/agent-execution.d.ts.map +1 -1
  344. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  345. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
  346. package/dist/testing/ai-limit-storage-contract.d.ts +18 -0
  347. package/dist/testing/ai-limit-storage-contract.d.ts.map +1 -0
  348. package/dist/testing/ai-model-call-groups-contract.d.ts +6 -0
  349. package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -0
  350. package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
  351. package/dist/testing/auth-storage-contract.d.ts.map +1 -1
  352. package/dist/testing/index.d.ts +2 -0
  353. package/dist/testing/index.d.ts.map +1 -1
  354. package/dist/testing/index.js +3637 -1962
  355. package/dist/testing/index.js.map +14 -12
  356. package/dist/testing/queues-contract.d.ts.map +1 -1
  357. package/dist/webhooks/internal.js +32 -28
  358. package/dist/webhooks/internal.js.map +2 -2
  359. package/dist/workers/index.js +2 -2
  360. package/dist/workflows/agent-step-identity.d.ts +3 -0
  361. package/dist/workflows/agent-step-identity.d.ts.map +1 -0
  362. package/dist/workflows/builders.d.ts +2 -3
  363. package/dist/workflows/builders.d.ts.map +1 -1
  364. package/dist/workflows/execution.d.ts +1 -1
  365. package/dist/workflows/execution.d.ts.map +1 -1
  366. package/dist/workflows/failure.d.ts +1 -1
  367. package/dist/workflows/failure.d.ts.map +1 -1
  368. package/dist/workflows/index.d.ts +3 -2
  369. package/dist/workflows/index.d.ts.map +1 -1
  370. package/dist/workflows/index.js +53 -45
  371. package/dist/workflows/index.js.map +1 -1
  372. package/dist/workflows/types.d.ts +26 -11
  373. package/dist/workflows/types.d.ts.map +1 -1
  374. package/dist/workflows/validation.d.ts +7 -1
  375. package/dist/workflows/validation.d.ts.map +1 -1
  376. package/package.json +19 -4
  377. package/src/agents/adapters.ts +109 -115
  378. package/src/agents/authority.ts +214 -32
  379. package/src/agents/builders.ts +3 -50
  380. package/src/agents/context-compaction.ts +4 -0
  381. package/src/agents/dispatch.ts +59 -2
  382. package/src/agents/errors.ts +5 -2
  383. package/src/agents/execution.ts +53 -52
  384. package/src/agents/ids.ts +16 -1
  385. package/src/agents/index.ts +23 -11
  386. package/src/agents/message.ts +18 -9
  387. package/src/agents/model-loop.ts +1023 -0
  388. package/src/agents/reference.ts +7 -0
  389. package/src/agents/request.ts +141 -74
  390. package/src/agents/retired-config.ts +20 -0
  391. package/src/agents/streams.ts +45 -19
  392. package/src/agents/tool-catalog.ts +21 -0
  393. package/src/agents/tool-definition.ts +23 -0
  394. package/src/agents/types.ts +39 -81
  395. package/src/agents/validation.ts +34 -180
  396. package/src/ai-usage/execution.ts +196 -0
  397. package/src/ai-usage/index.ts +15 -0
  398. package/src/authorization/decision.ts +27 -10
  399. package/src/authorization/grant-kinds.ts +62 -15
  400. package/src/authorization/index.ts +1 -0
  401. package/src/authorization/resolve.ts +12 -5
  402. package/src/authorization/types.ts +7 -5
  403. package/src/bootstrap/discovery.ts +0 -3
  404. package/src/error-reporting/types.ts +4 -2
  405. package/src/errors/catalog.ts +8 -0
  406. package/src/execution/agent.ts +129 -22
  407. package/src/execution/authorization.ts +48 -18
  408. package/src/execution/request.ts +4 -1
  409. package/src/execution/types.ts +1 -1
  410. package/src/http/api-routes.ts +63 -0
  411. package/src/index.ts +36 -7
  412. package/src/json.ts +9 -0
  413. package/src/models/catalog.ts +137 -0
  414. package/src/models/definitions.ts +202 -0
  415. package/src/models/errors.ts +83 -0
  416. package/src/models/events.ts +198 -0
  417. package/src/models/index.ts +89 -71
  418. package/src/models/language-model.ts +143 -0
  419. package/src/models/messages.ts +78 -0
  420. package/src/models/pricing.ts +390 -0
  421. package/src/models/rate-card.ts +101 -0
  422. package/src/models/tools.ts +29 -0
  423. package/src/queues/in-memory.ts +5 -0
  424. package/src/queues/index.ts +11 -0
  425. package/src/queues/types.ts +20 -3
  426. package/src/runtime/create.ts +7 -5
  427. package/src/runtime/definitions.ts +2 -2
  428. package/src/runtime/host.ts +3 -2
  429. package/src/runtime/resolve-definitions.ts +13 -36
  430. package/src/runtime/sixb.ts +6 -8
  431. package/src/security/every.ts +0 -4
  432. package/src/security/grants.ts +55 -11
  433. package/src/security/index.ts +2 -0
  434. package/src/security/registry.ts +6 -5
  435. package/src/security/types.ts +15 -4
  436. package/src/security/validation.ts +30 -9
  437. package/src/storage/agents/errors.ts +1 -0
  438. package/src/storage/agents/in-memory.ts +121 -11
  439. package/src/storage/agents/index.ts +7 -0
  440. package/src/storage/agents/provider.ts +150 -6
  441. package/src/storage/agents/types.ts +73 -16
  442. package/src/storage/ai-cost/analytics.ts +63 -6
  443. package/src/storage/ai-cost/codec.ts +37 -12
  444. package/src/storage/ai-cost/groups.ts +248 -0
  445. package/src/storage/ai-cost/in-memory.ts +42 -0
  446. package/src/storage/ai-cost/index.ts +6 -0
  447. package/src/storage/ai-cost/provider.ts +7 -0
  448. package/src/storage/ai-cost/types.ts +76 -14
  449. package/src/storage/ai-cost/validation.ts +147 -17
  450. package/src/storage/ai-limits/enforcement.ts +68 -0
  451. package/src/storage/ai-limits/errors.ts +23 -0
  452. package/src/storage/ai-limits/in-memory.ts +671 -0
  453. package/src/storage/ai-limits/index.ts +31 -0
  454. package/src/storage/ai-limits/period.ts +11 -0
  455. package/src/storage/ai-limits/provider.ts +430 -0
  456. package/src/storage/ai-limits/types.ts +195 -0
  457. package/src/storage/ai-usage/in-memory.ts +13 -0
  458. package/src/storage/ai-usage/record.ts +17 -0
  459. package/src/storage/ai-usage/types.ts +6 -2
  460. package/src/storage/auth/errors.ts +6 -0
  461. package/src/storage/auth/in-memory/auth-storage.ts +69 -0
  462. package/src/storage/auth/in-memory/device-authorizations.ts +145 -0
  463. package/src/storage/auth/in-memory/shared.ts +7 -0
  464. package/src/storage/auth/index.ts +7 -0
  465. package/src/storage/auth/types.ts +73 -0
  466. package/src/storage/executions/run-link.ts +16 -6
  467. package/src/storage/executions/validation.ts +36 -6
  468. package/src/storage/in-memory/index.ts +48 -4
  469. package/src/storage/index.ts +51 -1
  470. package/src/storage/types.ts +37 -0
  471. package/src/storage/workflow-runs/in-memory.ts +3 -3
  472. package/src/storage/workflow-runs/provider.ts +2 -2
  473. package/src/storage/workflow-runs/types.ts +6 -3
  474. package/src/testing/agent-execution.ts +40 -28
  475. package/src/testing/agent-storage-contract.ts +249 -28
  476. package/src/testing/ai-cost-storage-contract.ts +96 -8
  477. package/src/testing/ai-limit-storage-contract.ts +1134 -0
  478. package/src/testing/ai-model-call-groups-contract.ts +353 -0
  479. package/src/testing/ai-usage-storage-contract.ts +31 -0
  480. package/src/testing/auth-storage-contract.ts +85 -0
  481. package/src/testing/execution-storage-contract.ts +2 -2
  482. package/src/testing/index.ts +10 -0
  483. package/src/testing/queues-contract.ts +36 -1
  484. package/src/workflows/agent-step-identity.ts +4 -0
  485. package/src/workflows/builders.ts +95 -9
  486. package/src/workflows/execution.ts +2 -2
  487. package/src/workflows/failure.ts +2 -2
  488. package/src/workflows/index.ts +3 -0
  489. package/src/workflows/types.ts +23 -11
  490. package/src/workflows/validation.ts +100 -7
  491. package/dist/chunk-1e8m6yn3.js.map +0 -37
  492. package/dist/chunk-1g8negke.js.map +0 -11
  493. package/dist/chunk-6gjqgd3d.js.map +0 -11
  494. package/dist/chunk-dm72y8wt.js.map +0 -10
  495. package/dist/chunk-drjqm1aa.js.map +0 -15
  496. package/dist/chunk-fe5ev6mr.js +0 -55
  497. package/dist/chunk-fe5ev6mr.js.map +0 -11
  498. package/dist/chunk-h9kxd41f.js.map +0 -11
  499. package/dist/chunk-hceck7dq.js +0 -137
  500. package/dist/chunk-hceck7dq.js.map +0 -10
  501. package/dist/chunk-n4spznws.js.map +0 -11
  502. package/dist/chunk-nva1xkjz.js.map +0 -46
  503. package/dist/chunk-t0jjkep3.js.map +0 -10
  504. package/dist/chunk-t8t39h7v.js.map +0 -10
  505. /package/dist/{chunk-zqysyfjt.js.map → chunk-08m3b6w8.js.map} +0 -0
  506. /package/dist/{chunk-xkthy56g.js.map → chunk-1kamz6j0.js.map} +0 -0
  507. /package/dist/{chunk-md8k0r54.js.map → chunk-3fqt22c4.js.map} +0 -0
  508. /package/dist/{chunk-z3zp0bj1.js.map → chunk-407j3msh.js.map} +0 -0
  509. /package/dist/{chunk-rhrbz7d4.js.map → chunk-4a849fr1.js.map} +0 -0
  510. /package/dist/{chunk-62c7t4jc.js.map → chunk-4nxeacx7.js.map} +0 -0
  511. /package/dist/{chunk-cy0n5dms.js.map → chunk-5jcdmjam.js.map} +0 -0
  512. /package/dist/{chunk-819wnjz8.js.map → chunk-64sr682n.js.map} +0 -0
  513. /package/dist/{chunk-x2yw73hy.js.map → chunk-7ds9620f.js.map} +0 -0
  514. /package/dist/{chunk-72q2y8hn.js.map → chunk-8tsf6dmc.js.map} +0 -0
  515. /package/dist/{chunk-nkbfrt0c.js.map → chunk-9aehf39w.js.map} +0 -0
  516. /package/dist/{chunk-ezake7g1.js.map → chunk-agsvg9ar.js.map} +0 -0
  517. /package/dist/{chunk-rnshztfq.js.map → chunk-d63tybny.js.map} +0 -0
  518. /package/dist/{chunk-vybf6pkp.js.map → chunk-dbc80ad7.js.map} +0 -0
  519. /package/dist/{chunk-4gz41why.js.map → chunk-dqn23610.js.map} +0 -0
  520. /package/dist/{chunk-tg5mee00.js.map → chunk-ha58tjtt.js.map} +0 -0
  521. /package/dist/{chunk-f6erf2vv.js.map → chunk-hdz94br2.js.map} +0 -0
  522. /package/dist/{chunk-dsrkgtnh.js.map → chunk-jq43kdvk.js.map} +0 -0
  523. /package/dist/{chunk-wtmzkcht.js.map → chunk-k34z5rvh.js.map} +0 -0
  524. /package/dist/{chunk-htq0qh7z.js.map → chunk-ka3a2ft3.js.map} +0 -0
  525. /package/dist/{chunk-znagycq7.js.map → chunk-kt81c11h.js.map} +0 -0
  526. /package/dist/{chunk-f2rt4vkh.js.map → chunk-n2w475r0.js.map} +0 -0
  527. /package/dist/{chunk-bhxaq2nn.js.map → chunk-qw9gvjv5.js.map} +0 -0
  528. /package/dist/{chunk-8gv5z0zm.js.map → chunk-rp1mvzb4.js.map} +0 -0
  529. /package/dist/{chunk-ghteq96b.js.map → chunk-s5y30bc9.js.map} +0 -0
  530. /package/dist/{chunk-a31h57d5.js.map → chunk-tn7xcs2n.js.map} +0 -0
  531. /package/dist/{chunk-e42bc6m3.js.map → chunk-vjjv9mrb.js.map} +0 -0
  532. /package/dist/{chunk-8b55ygje.js.map → chunk-w3e09qqk.js.map} +0 -0
  533. /package/dist/{chunk-ckxfnx7f.js.map → chunk-wjgm6jjt.js.map} +0 -0
  534. /package/dist/{chunk-3j7573mj.js.map → chunk-x0qhkqje.js.map} +0 -0
  535. /package/dist/{chunk-dysw7nsm.js.map → chunk-xdpwpkha.js.map} +0 -0
@@ -2,23 +2,38 @@
2
2
  import {
3
3
  isScheduleDefinition
4
4
  } from "./chunk-5sz8ta9r.js";
5
+ import {
6
+ isAgentToolDefinition
7
+ } from "./chunk-n2arzn6e.js";
5
8
  import {
6
9
  WorkflowDefinitionError,
7
10
  assertNonEmpty,
8
- isAgentDefinition,
9
11
  isAgentStepDefinition,
10
12
  isInterventionDefinition,
11
13
  isStepDefinition
12
- } from "./chunk-nva1xkjz.js";
14
+ } from "./chunk-h0knpbz5.js";
13
15
  import {
14
16
  isActionDefinition
15
- } from "./chunk-a44d5zgd.js";
17
+ } from "./chunk-y35ma3mj.js";
18
+ import {
19
+ AGENT_REASONING_LEVELS
20
+ } from "./chunk-08twe8m6.js";
21
+ import {
22
+ isModelReasoning
23
+ } from "./chunk-trxxmgnf.js";
24
+ import {
25
+ isGroupDefinition
26
+ } from "./chunk-rre42skh.js";
16
27
  import {
17
28
  createSixbError,
18
29
  isSixbError,
19
30
  summarizeErrorMessage
20
- } from "./chunk-0172wgm9.js";
31
+ } from "./chunk-2xns679x.js";
21
32
 
33
+ // src/workflows/agent-step-identity.ts
34
+ function workflowAgentStepActorId(workflowId, stepId) {
35
+ return `workflow:${encodeURIComponent(workflowId)}:step:${encodeURIComponent(stepId)}`;
36
+ }
22
37
  // src/workflows/builders.ts
23
38
  function interventionField(schema, options) {
24
39
  return {
@@ -49,11 +64,20 @@ function defineWorkflowStep(id) {
49
64
  }
50
65
  };
51
66
  }
52
- function defineAgentStep(id, agent) {
67
+ function defineAgentStep(id, config) {
53
68
  assertNonEmpty(id, "Agent step", "id");
54
- if (!isAgentDefinition(agent)) {
55
- throw new WorkflowDefinitionError(`Agent step "${id}" references an invalid agent.`);
69
+ if (!isRecord(config)) {
70
+ throw new WorkflowDefinitionError(`Agent step "${id}" config must be an object.`);
71
+ }
72
+ if (typeof config.instructions !== "string" || !config.instructions.trim()) {
73
+ throw new WorkflowDefinitionError(`Agent step "${id}" instructions must not be empty.`);
56
74
  }
75
+ if (config.reasoning !== undefined && !isModelReasoning(config.reasoning)) {
76
+ throw new WorkflowDefinitionError(`Agent step "${id}" reasoning must be one of: ${AGENT_REASONING_LEVELS.join(", ")}, or a nonnegative budgetTokens object.`);
77
+ }
78
+ const { model, reasoning, instructions } = config;
79
+ const groupIds = groupIdsFromAgentStepConfig(id, config);
80
+ const toolNames = toolNamesFromAgentStepConfig(id, config);
57
81
  return {
58
82
  input(input) {
59
83
  return {
@@ -63,7 +87,18 @@ function defineAgentStep(id, agent) {
63
87
  if (typeof prompt !== "function") {
64
88
  throw new WorkflowDefinitionError(`Agent step "${id}" prompt must be a function.`);
65
89
  }
66
- return { kind: "agentStep", id, agent, input, output, prompt };
90
+ return {
91
+ kind: "agentStep",
92
+ id,
93
+ ...model === undefined ? {} : { model },
94
+ ...reasoning === undefined ? {} : { reasoning },
95
+ instructions,
96
+ groupIds,
97
+ toolNames,
98
+ input,
99
+ output,
100
+ prompt
101
+ };
67
102
  }
68
103
  };
69
104
  }
@@ -71,6 +106,41 @@ function defineAgentStep(id, agent) {
71
106
  }
72
107
  };
73
108
  }
109
+ function groupIdsFromAgentStepConfig(stepId, config) {
110
+ if (config.groups !== undefined && !Array.isArray(config.groups)) {
111
+ throw new WorkflowDefinitionError(`Agent step "${stepId}" groups must be an array of group definitions.`);
112
+ }
113
+ const groupIds = Array.from(config.groups ?? [], (group) => {
114
+ if (!isGroupDefinition(group)) {
115
+ throw new WorkflowDefinitionError(`Agent step "${stepId}" groups must contain only group definitions.`);
116
+ }
117
+ return group.id;
118
+ });
119
+ assertUniqueAgentStepValues(stepId, "group", groupIds);
120
+ return Object.freeze(groupIds);
121
+ }
122
+ function toolNamesFromAgentStepConfig(stepId, config) {
123
+ if (config.tools !== undefined && !Array.isArray(config.tools)) {
124
+ throw new WorkflowDefinitionError(`Agent step "${stepId}" tools must be an array of agent tool definitions.`);
125
+ }
126
+ const toolNames = Array.from(config.tools ?? [], (tool) => {
127
+ if (!isAgentToolDefinition(tool)) {
128
+ throw new WorkflowDefinitionError(`Agent step "${stepId}" tools must contain only agent tool definitions.`);
129
+ }
130
+ return tool.name;
131
+ });
132
+ assertUniqueAgentStepValues(stepId, "tool", toolNames);
133
+ return Object.freeze(toolNames);
134
+ }
135
+ function assertUniqueAgentStepValues(stepId, kind, values) {
136
+ const seen = new Set;
137
+ for (const value of values) {
138
+ if (seen.has(value)) {
139
+ throw new WorkflowDefinitionError(`Agent step "${stepId}" ${kind}s contains duplicate ${kind} '${value}'.`);
140
+ }
141
+ seen.add(value);
142
+ }
143
+ }
74
144
  function defineIntervention(id, options) {
75
145
  assertNonEmpty(id, "Intervention", "id");
76
146
  return {
@@ -280,6 +350,9 @@ function isRuntimeWorkflowMapper(value) {
280
350
  function isRuntimeWorkflowScheduleMapper(value) {
281
351
  return typeof value === "function";
282
352
  }
353
+ function isRecord(value) {
354
+ return typeof value === "object" && value !== null && !Array.isArray(value);
355
+ }
283
356
  // src/workflows/failure.ts
284
357
  function createWorkflowNodeFailure(error, identity) {
285
358
  return createSixbError("workflow.node_failed", summarizeErrorMessage(error, "Workflow node execution failed."), {
@@ -307,11 +380,11 @@ function workflowNodeFailureDetails(identity) {
307
380
  ...identity.child.actionRunId ? { actionRunId: identity.child.actionRunId } : {}
308
381
  };
309
382
  case "agent":
310
- return { ...base, agentId: identity.child.agentId };
383
+ return { ...base, agentStepId: identity.child.agentStepId };
311
384
  case "intervention":
312
385
  return { ...base, interventionId: identity.child.interventionId };
313
386
  }
314
387
  }
315
- export { interventionField, defineWorkflowStep, defineAgentStep, defineIntervention, defineWorkflow, createWorkflowNodeFailure, unwrapWorkflowNodeFailure };
388
+ export { workflowAgentStepActorId, interventionField, defineWorkflowStep, defineAgentStep, defineIntervention, defineWorkflow, createWorkflowNodeFailure, unwrapWorkflowNodeFailure };
316
389
 
317
- //# debugId=5C2B621CC3B063C864756E2164756E21
390
+ //# debugId=F5A50788BC271A9364756E2164756E21
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/workflows/agent-step-identity.ts", "../src/workflows/builders.ts", "../src/workflows/failure.ts"],
4
+ "sourcesContent": [
5
+ "/** Stable internal actor id for one workflow Agent step. */\nexport function workflowAgentStepActorId(workflowId: string, stepId: string): string {\n return `workflow:${encodeURIComponent(workflowId)}:step:${encodeURIComponent(stepId)}`\n}\n",
6
+ "import type { ActionDefinition } from \"../actions\"\nimport { isActionDefinition } from \"../actions\"\nimport { AGENT_REASONING_LEVELS, isAgentToolDefinition } from \"../agents\"\nimport { isModelReasoning } from \"../models/language-model\"\nimport type { SchemaOrRef } from \"../ontology\"\nimport type { ScheduleDefinition, ScheduleDefinitionForEvent } from \"../schedules\"\nimport { isScheduleDefinition } from \"../schedules\"\nimport { isGroupDefinition } from \"../security\"\nimport { WorkflowDefinitionError } from \"./errors\"\nimport type {\n AgentStepBuilder,\n AgentStepDefinition,\n DefineAgentStepConfig,\n InterventionBuilder,\n InterventionDefaultsRuntimeHandler,\n InterventionDefinition,\n InterventionFieldConfig,\n StepBuilder,\n StepDefinition,\n StepHandler,\n WorkflowBuilder,\n WorkflowChainDefinition,\n WorkflowNodeDefinition,\n WorkflowScheduleMapper,\n WorkflowTriggerDefinition,\n} from \"./types\"\nimport {\n assertNonEmpty,\n isAgentStepDefinition,\n isInterventionDefinition,\n isStepDefinition,\n} from \"./validation\"\n\ntype InterventionOptions = {\n description?: string\n}\n\ntype RuntimeWorkflowInput = Record<string, SchemaOrRef>\ntype RuntimeWorkflowValueInput = Record<string, unknown>\ntype RuntimeWorkflowMapper = (...args: never[]) => unknown\ntype RuntimeWorkflowScheduleMapper = WorkflowScheduleMapper<unknown, RuntimeWorkflowValueInput>\ntype RuntimeWorkflowThenDefinition =\n | StepDefinition\n | InterventionDefinition\n | ActionDefinition\n | AgentStepDefinition\ntype RuntimeWorkflowThen = (\n nodeDefinition: RuntimeWorkflowThenDefinition,\n mapper?: RuntimeWorkflowMapper\n) => WorkflowChainDefinition\ntype RuntimeWorkflowDraftBuilder = {\n when(schedule: ScheduleDefinition): RuntimeWorkflowDraftBuilder\n when(\n schedule: ScheduleDefinitionForEvent,\n mapper: RuntimeWorkflowScheduleMapper\n ): RuntimeWorkflowDraftBuilder\n readonly then: RuntimeWorkflowThen\n}\n\n/**\n * See the action-param helper for why widened booleans are rejected. Optional\n * response fields must be an explicit literal decision so inference stays honest.\n */\ntype StrictBoolean<T extends boolean> = boolean extends T ? never : T\n\ntype InterventionFieldResult<TSchema extends SchemaOrRef, TRequired extends boolean> = {\n readonly schema: TSchema\n readonly required: TRequired\n readonly description?: string\n}\n\nexport function interventionField<const TSchema extends SchemaOrRef>(\n schema: TSchema\n): InterventionFieldResult<TSchema, true>\nexport function interventionField<\n const TSchema extends SchemaOrRef,\n const TRequired extends boolean = true,\n>(\n schema: TSchema,\n options: {\n required?: StrictBoolean<TRequired>\n description?: string\n }\n): InterventionFieldResult<TSchema, TRequired>\nexport function interventionField(\n schema: SchemaOrRef,\n options?: { required?: boolean; description?: string }\n): InterventionFieldConfig {\n return {\n schema,\n required: options?.required ?? true,\n ...(options?.description !== undefined ? { description: options.description } : {}),\n }\n}\n\nexport function defineWorkflowStep<const TId extends string>(id: TId): StepBuilder<TId> {\n assertNonEmpty(id, \"Step\", \"id\")\n\n return {\n input(input: RuntimeWorkflowInput): unknown {\n return {\n output(output: RuntimeWorkflowInput): unknown {\n return {\n run(handler: StepHandler<Record<string, unknown>, Record<string, unknown>>): unknown {\n return {\n kind: \"step\",\n id,\n input,\n output,\n handler,\n }\n },\n }\n },\n }\n },\n } as unknown as StepBuilder<TId>\n}\n\nexport function defineAgentStep<const TId extends string>(\n id: TId,\n config: DefineAgentStepConfig\n): AgentStepBuilder<TId> {\n assertNonEmpty(id, \"Agent step\", \"id\")\n if (!isRecord(config)) {\n throw new WorkflowDefinitionError(`Agent step \"${id}\" config must be an object.`)\n }\n if (typeof config.instructions !== \"string\" || !config.instructions.trim()) {\n throw new WorkflowDefinitionError(`Agent step \"${id}\" instructions must not be empty.`)\n }\n if (config.reasoning !== undefined && !isModelReasoning(config.reasoning)) {\n throw new WorkflowDefinitionError(\n `Agent step \"${id}\" reasoning must be one of: ${AGENT_REASONING_LEVELS.join(\", \")}, or a nonnegative budgetTokens object.`\n )\n }\n const { model, reasoning, instructions } = config\n const groupIds = groupIdsFromAgentStepConfig(id, config)\n const toolNames = toolNamesFromAgentStepConfig(id, config)\n\n return {\n input(input: RuntimeWorkflowInput): unknown {\n return {\n output(output: RuntimeWorkflowInput): unknown {\n return {\n prompt(prompt: unknown): unknown {\n if (typeof prompt !== \"function\") {\n throw new WorkflowDefinitionError(`Agent step \"${id}\" prompt must be a function.`)\n }\n return {\n kind: \"agentStep\",\n id,\n ...(model === undefined ? {} : { model }),\n ...(reasoning === undefined ? {} : { reasoning }),\n instructions,\n groupIds,\n toolNames,\n input,\n output,\n prompt,\n }\n },\n }\n },\n }\n },\n } as unknown as AgentStepBuilder<TId>\n}\n\nfunction groupIdsFromAgentStepConfig(\n stepId: string,\n config: DefineAgentStepConfig\n): readonly string[] {\n if (config.groups !== undefined && !Array.isArray(config.groups)) {\n throw new WorkflowDefinitionError(\n `Agent step \"${stepId}\" groups must be an array of group definitions.`\n )\n }\n const groupIds = Array.from(config.groups ?? [], (group) => {\n if (!isGroupDefinition(group)) {\n throw new WorkflowDefinitionError(\n `Agent step \"${stepId}\" groups must contain only group definitions.`\n )\n }\n return group.id\n })\n assertUniqueAgentStepValues(stepId, \"group\", groupIds)\n return Object.freeze(groupIds)\n}\n\nfunction toolNamesFromAgentStepConfig(\n stepId: string,\n config: DefineAgentStepConfig\n): readonly string[] {\n if (config.tools !== undefined && !Array.isArray(config.tools)) {\n throw new WorkflowDefinitionError(\n `Agent step \"${stepId}\" tools must be an array of agent tool definitions.`\n )\n }\n const toolNames = Array.from(config.tools ?? [], (tool) => {\n if (!isAgentToolDefinition(tool)) {\n throw new WorkflowDefinitionError(\n `Agent step \"${stepId}\" tools must contain only agent tool definitions.`\n )\n }\n return tool.name\n })\n assertUniqueAgentStepValues(stepId, \"tool\", toolNames)\n return Object.freeze(toolNames)\n}\n\nfunction assertUniqueAgentStepValues(\n stepId: string,\n kind: \"group\" | \"tool\",\n values: readonly string[]\n): void {\n const seen = new Set<string>()\n for (const value of values) {\n if (seen.has(value)) {\n throw new WorkflowDefinitionError(\n `Agent step \"${stepId}\" ${kind}s contains duplicate ${kind} '${value}'.`\n )\n }\n seen.add(value)\n }\n}\n\nexport function defineIntervention<const TId extends string>(\n id: TId,\n options?: InterventionOptions\n): InterventionBuilder<TId> {\n assertNonEmpty(id, \"Intervention\", \"id\")\n\n return {\n input(input: RuntimeWorkflowInput): unknown {\n return {\n response(response: Record<string, unknown>): unknown {\n return createInterventionDefinition({\n id,\n input,\n response,\n description: options?.description,\n })\n },\n }\n },\n } as unknown as InterventionBuilder<TId>\n}\n\nexport function defineWorkflow<const TId extends string>(id: TId): WorkflowBuilder<TId> {\n assertNonEmpty(id, \"Workflow\", \"id\")\n\n return {\n input(input: RuntimeWorkflowInput): unknown {\n return createWorkflowDraftBuilder(id, input)\n },\n } as unknown as WorkflowBuilder<TId>\n}\n\nfunction createWorkflowDraftBuilder(\n id: string,\n input: RuntimeWorkflowInput\n): RuntimeWorkflowDraftBuilder {\n const triggers: WorkflowTriggerDefinition[] = []\n const nodes: WorkflowNodeDefinition[] = []\n let definition: WorkflowChainDefinition | null = null\n\n const appendNode = (\n nodeDefinition: unknown,\n mapper?: unknown,\n ...extraArgs: unknown[]\n ): WorkflowChainDefinition => {\n if (extraArgs.length > 0) {\n throw new WorkflowDefinitionError(`Invalid workflow \"${id}\" .then(...) call.`)\n }\n\n if (isStepDefinition(nodeDefinition)) {\n if (mapper !== undefined && !isRuntimeWorkflowMapper(mapper)) {\n throw new WorkflowDefinitionError(`Invalid workflow \"${id}\" .then(...) call.`)\n }\n\n nodes.push(createStepNode(id, nodes, nodeDefinition, mapper))\n definition ??= createWorkflowDefinition(id, input, triggers, nodes, appendNode)\n return definition\n }\n\n if (isAgentStepDefinition(nodeDefinition)) {\n if (mapper !== undefined && !isRuntimeWorkflowMapper(mapper)) {\n throw new WorkflowDefinitionError(`Invalid workflow \"${id}\" .then(...) call.`)\n }\n\n nodes.push(createAgentNode(id, nodes, nodeDefinition, mapper))\n definition ??= createWorkflowDefinition(id, input, triggers, nodes, appendNode)\n return definition\n }\n\n if (isInterventionDefinition(nodeDefinition)) {\n if (mapper !== undefined && !isRuntimeWorkflowMapper(mapper)) {\n throw new WorkflowDefinitionError(`Invalid workflow \"${id}\" .then(...) call.`)\n }\n\n nodes.push(createInterventionNode(id, nodes, nodeDefinition, mapper))\n definition ??= createWorkflowDefinition(id, input, triggers, nodes, appendNode)\n return definition\n }\n\n if (isActionDefinition(nodeDefinition)) {\n if (mapper !== undefined && !isRuntimeWorkflowMapper(mapper)) {\n throw new WorkflowDefinitionError(`Invalid workflow \"${id}\" .then(...) call.`)\n }\n\n nodes.push(createActionNode(id, nodes, nodeDefinition, mapper))\n definition ??= createWorkflowDefinition(id, input, triggers, nodes, appendNode)\n return definition\n }\n\n throw new WorkflowDefinitionError(`Invalid workflow \"${id}\" .then(...) call.`)\n }\n\n let draft: RuntimeWorkflowDraftBuilder\n\n function when(schedule: ScheduleDefinition): RuntimeWorkflowDraftBuilder\n function when(\n schedule: ScheduleDefinitionForEvent,\n mapper: RuntimeWorkflowScheduleMapper\n ): RuntimeWorkflowDraftBuilder\n function when(\n schedule: unknown,\n mapper?: unknown,\n ...extraArgs: unknown[]\n ): RuntimeWorkflowDraftBuilder {\n if (extraArgs.length > 0) {\n throw new WorkflowDefinitionError(`Invalid workflow \"${id}\" .when(...) call.`)\n }\n\n if (isScheduleDefinition(schedule)) {\n if (mapper !== undefined && schedule.trigger.type !== \"event\") {\n throw new WorkflowDefinitionError(`Workflow \"${id}\" cron schedules do not accept a mapper.`)\n }\n if (mapper !== undefined && !isRuntimeWorkflowScheduleMapper(mapper)) {\n throw new WorkflowDefinitionError(`Invalid workflow \"${id}\" .when(...) schedule mapper.`)\n }\n\n triggers.push({\n type: \"schedule\",\n scheduleId: schedule.id,\n ...(mapper !== undefined ? { mapper } : {}),\n })\n return draft\n }\n\n throw new WorkflowDefinitionError(`Workflow \"${id}\" .when(...) only accepts schedules.`)\n }\n\n draft = {\n when,\n // biome-ignore lint/suspicious/noThenProperty: Workflows intentionally expose a chainable .then(...) DSL.\n then: appendNode,\n }\n\n return draft\n}\n\nfunction createWorkflowDefinition(\n id: string,\n input: RuntimeWorkflowInput,\n triggers: readonly WorkflowTriggerDefinition[],\n nodes: readonly WorkflowNodeDefinition[],\n then: (\n nodeDefinition: unknown,\n mapper?: unknown,\n ...extraArgs: unknown[]\n ) => WorkflowChainDefinition\n): WorkflowChainDefinition {\n return {\n kind: \"workflow\",\n id,\n input,\n triggers,\n nodes,\n then,\n } as unknown as WorkflowChainDefinition\n}\n\nfunction createStepNode(\n workflowId: string,\n nodes: readonly WorkflowNodeDefinition[],\n step: StepDefinition,\n mapper: RuntimeWorkflowMapper | undefined\n): WorkflowNodeDefinition {\n const key = deriveWorkflowNodeKey(step.id)\n assertNodeKey(workflowId, step.id, key)\n assertUniqueNode(workflowId, nodes, step.id, key)\n\n return {\n type: \"step\",\n id: step.id,\n key,\n step,\n ...(mapper !== undefined ? { mapper } : {}),\n }\n}\n\nfunction createAgentNode(\n workflowId: string,\n nodes: readonly WorkflowNodeDefinition[],\n agentStep: AgentStepDefinition,\n mapper: RuntimeWorkflowMapper | undefined\n): WorkflowNodeDefinition {\n const key = deriveWorkflowNodeKey(agentStep.id)\n assertNodeKey(workflowId, agentStep.id, key)\n assertUniqueNode(workflowId, nodes, agentStep.id, key)\n\n return {\n type: \"agent\",\n id: agentStep.id,\n key,\n agentStep,\n ...(mapper !== undefined ? { mapper } : {}),\n }\n}\n\nfunction createInterventionDefinition(input: {\n readonly id: string\n readonly input: RuntimeWorkflowInput\n readonly response: Record<string, unknown>\n readonly description?: string\n}): unknown {\n const base = {\n kind: \"intervention\" as const,\n id: input.id,\n input: input.input,\n response: input.response,\n ...(input.description !== undefined ? { description: input.description } : {}),\n }\n\n const defaults = (handlerOrContext: unknown) => {\n if (typeof handlerOrContext === \"function\") {\n return {\n ...base,\n defaults: handlerOrContext as InterventionDefaultsRuntimeHandler,\n }\n }\n\n // A no-defaults intervention is still usable as a definition immediately after\n // `.response(...)`. Treating the builder method as an empty default handler keeps\n // future executor code simple if it calls `definition.defaults?.(ctx) ?? {}`.\n return {}\n }\n\n Object.defineProperty(base, \"defaults\", {\n value: defaults,\n enumerable: false,\n })\n\n return base\n}\n\nfunction createActionNode(\n workflowId: string,\n nodes: readonly WorkflowNodeDefinition[],\n action: ActionDefinition,\n mapper: RuntimeWorkflowMapper | undefined\n): WorkflowNodeDefinition {\n const key = deriveWorkflowNodeKey(action.id)\n assertNodeKey(workflowId, action.id, key)\n assertUniqueNode(workflowId, nodes, action.id, key)\n\n return {\n type: \"action\",\n id: action.id,\n key,\n action,\n ...(mapper !== undefined ? { mapper } : {}),\n }\n}\n\nfunction createInterventionNode(\n workflowId: string,\n nodes: readonly WorkflowNodeDefinition[],\n intervention: InterventionDefinition,\n mapper: RuntimeWorkflowMapper | undefined\n): WorkflowNodeDefinition {\n const key = deriveWorkflowNodeKey(intervention.id)\n assertNodeKey(workflowId, intervention.id, key)\n assertUniqueNode(workflowId, nodes, intervention.id, key)\n\n return {\n type: \"intervention\",\n id: intervention.id,\n key,\n intervention,\n ...(mapper !== undefined ? { mapper } : {}),\n } as WorkflowNodeDefinition\n}\n\nfunction assertNodeKey(workflowId: string, nodeId: string, key: string): void {\n if (key.length === 0) {\n throw new WorkflowDefinitionError(\n `Workflow \"${workflowId}\" node id \"${nodeId}\" must contain at least one letter or number.`\n )\n }\n}\n\nfunction assertUniqueNode(\n workflowId: string,\n nodes: readonly WorkflowNodeDefinition[],\n nodeId: string,\n key: string\n): void {\n const duplicateId = nodes.find((node) => node.id === nodeId)\n if (duplicateId) {\n throw new WorkflowDefinitionError(\n `Duplicate workflow node id \"${nodeId}\" in workflow \"${workflowId}\".`\n )\n }\n\n const duplicateKey = nodes.find((node) => node.key === key)\n if (duplicateKey) {\n throw new WorkflowDefinitionError(\n `Duplicate workflow node key \"${key}\" in workflow \"${workflowId}\". Node ids \"${duplicateKey.id}\" and \"${nodeId}\" derive the same key.`\n )\n }\n}\n\nfunction deriveWorkflowNodeKey(id: string): string {\n const segments = id\n .trim()\n .split(/[^A-Za-z0-9]+/)\n .filter((segment) => segment.length > 0)\n\n return segments\n .map((segment, index) => {\n const normalized = uncapitalize(segment)\n return index === 0 ? normalized : capitalize(normalized)\n })\n .join(\"\")\n}\n\nfunction uncapitalize(value: string): string {\n return value.length === 0 ? value : `${value[0].toLowerCase()}${value.slice(1)}`\n}\n\nfunction capitalize(value: string): string {\n return value.length === 0 ? value : `${value[0].toUpperCase()}${value.slice(1)}`\n}\n\nfunction isRuntimeWorkflowMapper(value: unknown): value is RuntimeWorkflowMapper {\n return typeof value === \"function\"\n}\n\nfunction isRuntimeWorkflowScheduleMapper(value: unknown): value is RuntimeWorkflowScheduleMapper {\n return typeof value === \"function\"\n}\n\nfunction isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n",
7
+ "import { createSixbError, isSixbError, summarizeErrorMessage } from \"../errors/internal\"\n\ninterface WorkflowNodeFailureIdentityBase {\n readonly workflowId: string\n readonly workflowRunId: string\n readonly nodeId: string\n readonly nodeRunId?: string\n}\n\nexport interface WorkflowNodeFailureIdentity extends WorkflowNodeFailureIdentityBase {\n readonly child:\n | { readonly type: \"step\"; readonly stepId: string }\n | {\n readonly type: \"action\"\n readonly actionId: string\n readonly actionRunId?: string\n }\n | { readonly type: \"agent\"; readonly agentStepId: string }\n | { readonly type: \"intervention\"; readonly interventionId: string }\n}\n\n/** Translate a node-local failure into the workflow primitive's durable vocabulary. */\nexport function createWorkflowNodeFailure(error: unknown, identity: WorkflowNodeFailureIdentity) {\n return createSixbError(\n \"workflow.node_failed\",\n summarizeErrorMessage(error, \"Workflow node execution failed.\"),\n {\n cause: error,\n details: workflowNodeFailureDetails(identity),\n }\n )\n}\n\n/** Recover the native child error for direct callers and error-monitoring integrations. */\nexport function unwrapWorkflowNodeFailure(error: unknown): unknown {\n return isSixbError(error) && error.code === \"workflow.node_failed\" && error.cause !== undefined\n ? error.cause\n : error\n}\n\nfunction workflowNodeFailureDetails(identity: WorkflowNodeFailureIdentity) {\n const base = {\n workflowId: identity.workflowId,\n workflowRunId: identity.workflowRunId,\n nodeId: identity.nodeId,\n ...(identity.nodeRunId ? { nodeRunId: identity.nodeRunId } : {}),\n }\n\n switch (identity.child.type) {\n case \"step\":\n return { ...base, stepId: identity.child.stepId }\n case \"action\":\n return {\n ...base,\n actionId: identity.child.actionId,\n ...(identity.child.actionRunId ? { actionRunId: identity.child.actionRunId } : {}),\n }\n case \"agent\":\n return { ...base, agentStepId: identity.child.agentStepId }\n case \"intervention\":\n return { ...base, interventionId: identity.child.interventionId }\n }\n}\n"
8
+ ],
9
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACO,SAAS,wBAAwB,CAAC,YAAoB,QAAwB;AAAA,EACnF,OAAO,YAAY,mBAAmB,UAAU,UAAU,mBAAmB,MAAM;AAAA;;ACkF9E,SAAS,iBAAiB,CAC/B,QACA,SACyB;AAAA,EACzB,OAAO;AAAA,IACL;AAAA,IACA,UAAU,SAAS,YAAY;AAAA,OAC3B,SAAS,gBAAgB,YAAY,EAAE,aAAa,QAAQ,YAAY,IAAI,CAAC;AAAA,EACnF;AAAA;AAGK,SAAS,kBAA4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ecution
5
+ } from "./chunk-3kv70xwp.js";
6
+ import {
7
+ AuthStorageError,
8
+ SYSTEM_PRINCIPAL,
9
+ principalsEqual
10
+ } from "./chunk-rre42skh.js";
11
+ import {
12
+ resolveAuthorizationContext
13
+ } from "./chunk-37wk412q.js";
14
+ import {
15
+ createSixbError
16
+ } from "./chunk-2xns679x.js";
17
+
18
+ // src/agents/authority.ts
19
+ function agentServiceAccountId(actorId) {
20
+ return `svc_agent_${actorId}`;
21
+ }
22
+ async function ensureManagedAgentExecutionIdentity(input) {
23
+ const auth = requireAuthStorage(input.auth);
24
+ const id = agentServiceAccountId(input.actorId);
25
+ const now = new Date;
26
+ const loaded = await loadOrCreateAgentServiceAccount(auth, {
27
+ id,
28
+ projectId: input.projectId,
29
+ name: input.name,
30
+ description: input.description,
31
+ updatedAt: now
32
+ });
33
+ assertFrameworkManagedAgentServiceAccount(input.actorId, loaded);
34
+ assertActiveAgentServiceAccount(input.actorId, loaded);
35
+ const serviceAccount = await updateAgentServiceAccountMetadata(auth, {
36
+ existing: loaded,
37
+ name: input.name,
38
+ description: input.description,
39
+ updatedAt: now
40
+ });
41
+ assertActiveAgentServiceAccount(input.actorId, serviceAccount);
42
+ const groupMemberships = requireDefinitionOwnedGroupMemberships(input.actorId, await auth.serviceAccountGroupMemberships.reconcileForServiceAccount({
43
+ projectId: input.projectId,
44
+ serviceAccountId: id,
45
+ groupIds: input.groupIds,
46
+ source: "agent",
47
+ updatedAt: now
48
+ }));
49
+ return {
50
+ serviceAccount,
51
+ principal: { type: "serviceAccount", id },
52
+ groupMemberships
53
+ };
54
+ }
55
+ async function loadOrCreateAgentServiceAccount(auth, input) {
56
+ const existing = await auth.serviceAccounts.getById({
57
+ projectId: input.projectId,
58
+ id: input.id
59
+ });
60
+ if (existing)
61
+ return existing;
62
+ try {
63
+ return await auth.serviceAccounts.create({
64
+ id: input.id,
65
+ projectId: input.projectId,
66
+ name: input.name,
67
+ description: input.description,
68
+ status: "active",
69
+ createdByPrincipal: SYSTEM_PRINCIPAL,
70
+ createdAt: input.updatedAt,
71
+ updatedAt: input.updatedAt
72
+ });
73
+ } catch (error) {
74
+ if (!(error instanceof AuthStorageError) || error.code !== "duplicate_service_account") {
75
+ throw error;
76
+ }
77
+ const concurrent = await auth.serviceAccounts.getById({
78
+ projectId: input.projectId,
79
+ id: input.id
80
+ });
81
+ if (!concurrent)
82
+ throw error;
83
+ return concurrent;
84
+ }
85
+ }
86
+ function assertActiveAgentServiceAccount(actorId, serviceAccount) {
87
+ if (serviceAccount.status === "suspended") {
88
+ throw new Error(`[Sixb] Agent '${actorId}' service account '${serviceAccount.id}' is suspended.`);
89
+ }
90
+ }
91
+ function assertFrameworkManagedAgentServiceAccount(actorId, serviceAccount) {
92
+ if (serviceAccount.createdByPrincipal === undefined || !principalsEqual(serviceAccount.createdByPrincipal, SYSTEM_PRINCIPAL)) {
93
+ throw createSixbError("agent.execution_failed", `[Sixb] Agent '${actorId}' cannot use service account '${serviceAccount.id}' because it is not managed by Sixb.`, { details: { actorId, serviceAccountId: serviceAccount.id } });
94
+ }
95
+ }
96
+ function requireDefinitionOwnedGroupMemberships(actorId, memberships) {
97
+ const externalGroupIds = memberships.filter((membership) => membership.source !== "agent").map((membership) => membership.groupId);
98
+ if (externalGroupIds.length > 0) {
99
+ throw createSixbError("agent.execution_failed", `[Sixb] Agent '${actorId}' service account has group memberships not managed by its definition: ${externalGroupIds.join(", ")}.`, { details: { actorId, externalGroupIds } });
100
+ }
101
+ return memberships;
102
+ }
103
+ async function resolveAgentExecutionAuthorization(input) {
104
+ const auth = requireAuthStorage(input.auth);
105
+ const expectedId = agentServiceAccountId(input.actorId);
106
+ const principal = input.authorizationRef.type === "principal" ? input.authorizationRef.principal : null;
107
+ if (principal?.type !== "serviceAccount" || principal.id !== expectedId) {
108
+ throw new Error(`[Sixb] Agent '${input.actorId}' execution authority must reference service account '${expectedId}'.`);
109
+ }
110
+ const serviceAccount = await auth.serviceAccounts.getById({
111
+ projectId: input.projectId,
112
+ id: principal.id
113
+ });
114
+ if (!serviceAccount || serviceAccount.status !== "active") {
115
+ throw new Error(`[Sixb] Agent service account '${principal.id}' is not active.`);
116
+ }
117
+ assertFrameworkManagedAgentServiceAccount(input.actorId, serviceAccount);
118
+ const groupMemberships = requireDefinitionOwnedGroupMemberships(input.actorId, await auth.serviceAccountGroupMemberships.listForServiceAccount({
119
+ projectId: input.projectId,
120
+ serviceAccountId: principal.id
121
+ }));
122
+ const identity = {
123
+ serviceAccount,
124
+ principal: { type: "serviceAccount", id: principal.id },
125
+ groupMemberships
126
+ };
127
+ return {
128
+ identity,
129
+ context: resolveAuthorizationContext({
130
+ principal: identity.principal,
131
+ groupIds: groupMemberships.map((membership) => membership.groupId),
132
+ roles: input.security.listResolvedRoles()
133
+ })
134
+ };
135
+ }
136
+ async function resolveInheritedAgentExecutionAuthorization(input) {
137
+ if (input.authorizationRef.type === "disabled")
138
+ return { type: "disabled" };
139
+ const ref = requireCredentialedUserAuthority(input.authorizationRef);
140
+ const auth = requireAuthStorage(input.auth);
141
+ const now = input.now ?? new Date;
142
+ const user = await requireActiveUser(auth, input.projectId, ref.principal.id);
143
+ const memberships = await auth.groupMemberships.listForUser({
144
+ projectId: input.projectId,
145
+ userId: user.id
146
+ });
147
+ const credential = await revalidateUserCredential({
148
+ auth,
149
+ projectId: input.projectId,
150
+ userId: user.id,
151
+ credential: ref.credential,
152
+ currentGroupIds: memberships.map((membership) => membership.groupId),
153
+ now
154
+ });
155
+ return {
156
+ type: "principal",
157
+ context: resolveAuthorizationContext({
158
+ principal: ref.principal,
159
+ groupIds: credential.groupIds,
160
+ roles: input.security.listResolvedRoles(),
161
+ ...credential.sessionId === undefined ? {} : { sessionId: credential.sessionId }
162
+ })
163
+ };
164
+ }
165
+ function requireCredentialedUserAuthority(ref) {
166
+ if (ref.type !== "principal" || ref.principal.type !== "user" || ref.credential === undefined) {
167
+ throw invalidInheritedAuthority("the durable reference is not a credentialed user");
168
+ }
169
+ return {
170
+ type: "principal",
171
+ principal: { type: "user", id: ref.principal.id },
172
+ credential: { type: ref.credential.type, id: ref.credential.id }
173
+ };
174
+ }
175
+ async function requireActiveUser(auth, projectId, userId) {
176
+ const user = await auth.users.getById({ projectId, id: userId });
177
+ if (!user || user.status !== "active") {
178
+ throw invalidInheritedAuthority(`user '${userId}' is not active`);
179
+ }
180
+ return user;
181
+ }
182
+ async function revalidateUserCredential(input) {
183
+ if (input.credential.type === "session") {
184
+ const session = await input.auth.sessions.getById({
185
+ projectId: input.projectId,
186
+ id: input.credential.id
187
+ });
188
+ if (!isUsableUserSession(session, input.userId, input.now)) {
189
+ throw invalidInheritedAuthority("the inherited session is no longer valid");
190
+ }
191
+ return { groupIds: input.currentGroupIds, sessionId: session.id };
192
+ }
193
+ const accessToken = await input.auth.accessTokens.getById({
194
+ projectId: input.projectId,
195
+ id: input.credential.id
196
+ });
197
+ if (!isUsableUserAccessToken(accessToken, input.userId, input.now)) {
198
+ throw invalidInheritedAuthority("the inherited access token is no longer valid");
199
+ }
200
+ if (accessToken.groupIds === undefined)
201
+ return { groupIds: input.currentGroupIds };
202
+ const allowedGroupIds = new Set(accessToken.groupIds);
203
+ return {
204
+ groupIds: input.currentGroupIds.filter((groupId) => allowedGroupIds.has(groupId))
205
+ };
206
+ }
207
+ function isUsableUserSession(session, userId, now) {
208
+ if (!session || session.userId !== userId || session.revokedAt !== undefined)
209
+ return false;
210
+ if (session.expiresAt.getTime() <= now.getTime())
211
+ return false;
212
+ return session.absoluteExpiresAt === undefined || session.absoluteExpiresAt.getTime() > now.getTime();
213
+ }
214
+ function isUsableUserAccessToken(token, userId, now) {
215
+ if (!token || token.subjectType !== "user" || token.subjectId !== userId)
216
+ return false;
217
+ return token.revokedAt === undefined && token.expiresAt.getTime() > now.getTime();
218
+ }
219
+ function invalidInheritedAuthority(reason) {
220
+ return createSixbError("agent.execution_failed", `[Sixb] The Agent execution cannot restore its inherited authority: ${reason}.`);
221
+ }
222
+ function requireAuthStorage(auth) {
223
+ if (!auth) {
224
+ throw new Error("[Sixb] Agent executions require auth storage.");
225
+ }
226
+ return auth;
227
+ }
228
+ async function updateAgentServiceAccountMetadata(auth, input) {
229
+ if (input.existing.name === input.name && input.existing.description === input.description) {
230
+ return input.existing;
231
+ }
232
+ return auth.serviceAccounts.update({
233
+ projectId: input.existing.projectId,
234
+ id: input.existing.id,
235
+ name: input.name,
236
+ description: input.description,
237
+ updatedAt: input.updatedAt
238
+ });
239
+ }
240
+
241
+ // src/storage/workflow-runs/errors.ts
242
+ class WorkflowRunError extends Error {
243
+ name = "WorkflowRunError";
244
+ }
245
+
246
+ // src/storage/workflow-runs/provider.ts
247
+ async function assertWorkflowRunExecution(input) {
248
+ const execution = await findPrimitiveRunExecution({
249
+ executions: input.executions,
250
+ projectId: input.projectId,
251
+ executionId: input.executionId,
252
+ primitive: { kind: "workflow", id: input.workflowId, runId: input.runId },
253
+ sourceTypes: ["execution", "schedule", "event"]
254
+ });
255
+ if (!execution) {
256
+ invalidExecution(input.executionId, input.runId);
257
+ }
258
+ if (execution.source.type === "schedule" || execution.source.type === "event") {
259
+ if (execution.requestedBy !== undefined) {
260
+ invalidExecution(input.executionId, input.runId);
261
+ }
262
+ return;
263
+ }
264
+ if (execution.source.type !== "execution") {
265
+ invalidExecution(input.executionId, input.runId);
266
+ }
267
+ }
268
+ async function assertWorkflowAgentNodeRunExecution(input) {
269
+ const execution = await findAgentRunExecution({
270
+ executions: input.executions,
271
+ projectId: input.projectId,
272
+ executionId: input.executionId,
273
+ runId: input.nodeRunId,
274
+ authority: { type: "managed", serviceAccountId: agentServiceAccountId(input.actorId) }
275
+ });
276
+ if (!execution || execution.source.type !== "execution" || execution.source.executionId !== input.workflowExecutionId) {
277
+ throw new WorkflowRunError(`[Sixb] Execution '${input.executionId}' does not authorize Workflow Agent-node run '${input.nodeRunId}'.`);
278
+ }
279
+ }
280
+ function invalidExecution(executionId, runId) {
281
+ throw new WorkflowRunError(`[Sixb] Execution '${executionId}' does not authorize workflow run '${runId}'.`);
282
+ }
283
+
284
+ export { WorkflowRunError, agentServiceAccountId, ensureManagedAgentExecutionIdentity, resolveAgentExecutionAuthorization, resolveInheritedAgentExecutionAuthorization, assertWorkflowRunExecution, assertWorkflowAgentNodeRunExecution };
285
+
286
+ //# debugId=77624CF2336F235864756E2164756E21
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/agents/authority.ts", "../src/storage/workflow-runs/errors.ts", "../src/storage/workflow-runs/provider.ts"],
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\"\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 interface AgentExecutionIdentity {\n readonly serviceAccount: ServiceAccountRecord\n readonly principal: Extract<AuthorizablePrincipal, { readonly type: \"serviceAccount\" }>\n readonly groupMemberships: readonly ServiceAccountGroupMembershipRecord[]\n}\n\nexport function agentServiceAccountId(actorId: string): string {\n return `svc_agent_${actorId}`\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",
6
+ "/**\n * Base error for workflow-run storage operations.\n */\nexport class WorkflowRunError extends Error {\n readonly name = \"WorkflowRunError\"\n}\n",
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
+ ],
9
+ "mappings": ";;;;;;;;;;;;;;;;;;AAoCO,SAAS,qBAAqB,CAAC,SAAyB;AAAA,EAC7D,OAAO,aAAa;AAAA;AAItB,eAAsB,mCAAmC,CAAC,OAOtB;AAAA,EAClC,MAAM,OAAO,mBAAmB,MAAM,IAAI;AAAA,EAC1C,MAAM,KAAK,sBAAsB,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,SAAS,MAAM;AAAA,EAC/D,gCAAgC,MAAM,SAAS,MAAM;AAAA,EACrD,MAAM,iBAAiB,MAAM,kCAAkC,MAAM;AAAA,IACnE,UAAU;AAAA,IACV,MAAM,MAAM;AAAA,IACZ,aAAa,MAAM;AAAA,IACnB,WAAW;AAA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