@sixb/core 0.1.25 → 0.1.26

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 (446) hide show
  1. package/dist/actions/index.js +35 -35
  2. package/dist/agents/attachment-keys.d.ts +25 -0
  3. package/dist/agents/attachment-keys.d.ts.map +1 -0
  4. package/dist/agents/cancel.d.ts +12 -0
  5. package/dist/agents/cancel.d.ts.map +1 -1
  6. package/dist/agents/children.d.ts.map +1 -1
  7. package/dist/agents/dispatch.d.ts +1 -9
  8. package/dist/agents/dispatch.d.ts.map +1 -1
  9. package/dist/agents/execution.d.ts +5 -0
  10. package/dist/agents/execution.d.ts.map +1 -1
  11. package/dist/agents/index.d.ts +31 -6
  12. package/dist/agents/index.d.ts.map +1 -1
  13. package/dist/agents/index.js +154 -66
  14. package/dist/agents/index.js.map +1 -1
  15. package/dist/agents/model-loop.d.ts +3 -5
  16. package/dist/agents/model-loop.d.ts.map +1 -1
  17. package/dist/agents/model-routing.d.ts +4 -1
  18. package/dist/agents/model-routing.d.ts.map +1 -1
  19. package/dist/agents/request.d.ts +9 -1
  20. package/dist/agents/request.d.ts.map +1 -1
  21. package/dist/agents/run-after-finish.d.ts +11 -0
  22. package/dist/agents/run-after-finish.d.ts.map +1 -0
  23. package/dist/agents/run-artifacts.d.ts +56 -0
  24. package/dist/agents/run-artifacts.d.ts.map +1 -0
  25. package/dist/agents/run-events.d.ts +49 -0
  26. package/dist/agents/run-events.d.ts.map +1 -0
  27. package/dist/agents/run-fence.d.ts +38 -0
  28. package/dist/agents/run-fence.d.ts.map +1 -0
  29. package/dist/agents/run-liveness.d.ts +36 -0
  30. package/dist/agents/run-liveness.d.ts.map +1 -0
  31. package/dist/agents/run-plan.d.ts +110 -0
  32. package/dist/agents/run-plan.d.ts.map +1 -0
  33. package/dist/agents/run-session-children.d.ts +89 -0
  34. package/dist/agents/run-session-children.d.ts.map +1 -0
  35. package/dist/agents/run-session-http.d.ts +37 -0
  36. package/dist/agents/run-session-http.d.ts.map +1 -0
  37. package/dist/agents/run-session-serve.d.ts +24 -0
  38. package/dist/agents/run-session-serve.d.ts.map +1 -0
  39. package/dist/agents/run-session-wire.d.ts +31 -0
  40. package/dist/agents/run-session-wire.d.ts.map +1 -0
  41. package/dist/agents/run-session.d.ts +239 -0
  42. package/dist/agents/run-session.d.ts.map +1 -0
  43. package/dist/agents/run-token.d.ts +40 -0
  44. package/dist/agents/run-token.d.ts.map +1 -0
  45. package/dist/agents/run-tools.d.ts +68 -0
  46. package/dist/agents/run-tools.d.ts.map +1 -0
  47. package/dist/agents/run-turn.d.ts +59 -0
  48. package/dist/agents/run-turn.d.ts.map +1 -0
  49. package/dist/agents/streams/index.js +1 -1
  50. package/dist/agents/streams/internal.d.ts +1 -1
  51. package/dist/agents/streams/internal.d.ts.map +1 -1
  52. package/dist/agents/streams/internal.js +2 -4
  53. package/dist/agents/streams/internal.js.map +1 -1
  54. package/dist/agents/streams/protocol.d.ts +1 -96
  55. package/dist/agents/streams/protocol.d.ts.map +1 -1
  56. package/dist/agents/subagent-runs.d.ts +7 -1
  57. package/dist/agents/subagent-runs.d.ts.map +1 -1
  58. package/dist/agents/tool-files.d.ts +34 -0
  59. package/dist/agents/tool-files.d.ts.map +1 -0
  60. package/dist/agents/workflow-node-session.d.ts +99 -0
  61. package/dist/agents/workflow-node-session.d.ts.map +1 -0
  62. package/dist/artifacts/frames/index.js +1 -1
  63. package/dist/artifacts/frames/index.js.map +1 -1
  64. package/dist/artifacts/index.js.map +1 -1
  65. package/dist/artifacts/publish/index.d.ts +1 -1
  66. package/dist/artifacts/publish/index.d.ts.map +1 -1
  67. package/dist/artifacts/publish/index.js +19 -19
  68. package/dist/auth/index.js +8 -8
  69. package/dist/authorization/index.js +4 -4
  70. package/dist/bootstrap/index.js +45 -43
  71. package/dist/bootstrap/index.js.map +2 -2
  72. package/dist/{chunk-2fn60nvs.js → chunk-06sg8s4z.js} +2 -2
  73. package/dist/{chunk-2fn60nvs.js.map → chunk-06sg8s4z.js.map} +1 -1
  74. package/dist/chunk-07kkp2e1.js.map +1 -1
  75. package/dist/{chunk-9ntbsnke.js → chunk-0bc3w0zq.js} +7 -7
  76. package/dist/{chunk-9ntbsnke.js.map → chunk-0bc3w0zq.js.map} +2 -2
  77. package/dist/{chunk-d2m879s4.js → chunk-0kk2wt0h.js} +27 -27
  78. package/dist/chunk-0kk2wt0h.js.map +12 -0
  79. package/dist/chunk-16a9dmfy.js.map +1 -1
  80. package/dist/chunk-18sk89cg.js.map +2 -2
  81. package/dist/{chunk-3qms4nax.js → chunk-1vg43g9q.js} +20 -20
  82. package/dist/{chunk-3qms4nax.js.map → chunk-1vg43g9q.js.map} +4 -4
  83. package/dist/{chunk-hqsp2sx4.js → chunk-1xvqgg88.js} +31 -33
  84. package/dist/{chunk-hqsp2sx4.js.map → chunk-1xvqgg88.js.map} +6 -6
  85. package/dist/chunk-2adz0h75.js.map +1 -1
  86. package/dist/{chunk-fm62y49k.js → chunk-2pk5hjj9.js} +5 -3
  87. package/dist/{chunk-fm62y49k.js.map → chunk-2pk5hjj9.js.map} +5 -5
  88. package/dist/{chunk-vrf90dkv.js → chunk-2vjnyz1s.js} +1 -1
  89. package/dist/{chunk-vrf90dkv.js.map → chunk-2vjnyz1s.js.map} +1 -1
  90. package/dist/{chunk-4f3ydv7t.js → chunk-315qye3g.js} +1 -1
  91. package/dist/{chunk-4f3ydv7t.js.map → chunk-315qye3g.js.map} +1 -1
  92. package/dist/{chunk-rap5w0x0.js → chunk-31khg3g0.js} +1 -1
  93. package/dist/{chunk-rap5w0x0.js.map → chunk-31khg3g0.js.map} +1 -1
  94. package/dist/chunk-45ngkxkp.js.map +1 -1
  95. package/dist/chunk-48jezz3j.js.map +1 -1
  96. package/dist/{chunk-vr3j63jq.js → chunk-4jq2bg8t.js} +78 -78
  97. package/dist/{chunk-vr3j63jq.js.map → chunk-4jq2bg8t.js.map} +4 -4
  98. package/dist/chunk-4ymrcdbm.js.map +1 -1
  99. package/dist/chunk-58geavnf.js.map +1 -1
  100. package/dist/{chunk-6y0mkhex.js → chunk-59kf345w.js} +2 -2
  101. package/dist/{chunk-6y0mkhex.js.map → chunk-59kf345w.js.map} +1 -1
  102. package/dist/{chunk-3p93tb91.js → chunk-6qn7nmd3.js} +102 -102
  103. package/dist/{chunk-3p93tb91.js.map → chunk-6qn7nmd3.js.map} +4 -4
  104. package/dist/chunk-73j0v4qv.js +355 -0
  105. package/dist/chunk-73j0v4qv.js.map +13 -0
  106. package/dist/{chunk-2gjj5dx3.js → chunk-78ymxrn0.js} +1 -1
  107. package/dist/{chunk-6bkbyer5.js → chunk-7ex2p3zp.js} +3 -3
  108. package/dist/{chunk-6bkbyer5.js.map → chunk-7ex2p3zp.js.map} +1 -1
  109. package/dist/{chunk-5tfev0fv.js → chunk-7hf6tkgs.js} +167 -167
  110. package/dist/{chunk-5tfev0fv.js.map → chunk-7hf6tkgs.js.map} +4 -4
  111. package/dist/{chunk-8z4726jz.js → chunk-7wn5z7mq.js} +10 -10
  112. package/dist/{chunk-8z4726jz.js.map → chunk-7wn5z7mq.js.map} +2 -2
  113. package/dist/{chunk-6n69k945.js → chunk-8mb7mt8n.js} +2 -2
  114. package/dist/chunk-8ncg20rd.js.map +1 -1
  115. package/dist/{chunk-68wghpdf.js → chunk-8v5a54qz.js} +50 -11
  116. package/dist/{chunk-68wghpdf.js.map → chunk-8v5a54qz.js.map} +3 -3
  117. package/dist/{chunk-gqm0b7vd.js → chunk-8v6xzwgr.js} +92 -76
  118. package/dist/{chunk-gqm0b7vd.js.map → chunk-8v6xzwgr.js.map} +6 -6
  119. package/dist/{chunk-m36fw8ft.js → chunk-8wsjr52f.js} +1 -1
  120. package/dist/{chunk-vd1rk42q.js → chunk-8xnz9vvp.js} +4 -4
  121. package/dist/{chunk-vd1rk42q.js.map → chunk-8xnz9vvp.js.map} +1 -1
  122. package/dist/chunk-9mab3dvg.js.map +1 -1
  123. package/dist/chunk-9tc8dxmn.js.map +1 -1
  124. package/dist/chunk-9x8dybsb.js.map +2 -2
  125. package/dist/chunk-a3faa34j.js.map +1 -1
  126. package/dist/{chunk-62a63pr6.js → chunk-axb4ss9a.js} +7 -7
  127. package/dist/{chunk-62a63pr6.js.map → chunk-axb4ss9a.js.map} +2 -2
  128. package/dist/{chunk-z3ryd53f.js → chunk-b6ghvap7.js} +35 -11
  129. package/dist/{chunk-z3ryd53f.js.map → chunk-b6ghvap7.js.map} +3 -3
  130. package/dist/{chunk-sqfvnvqj.js → chunk-c14ap3s9.js} +2 -2
  131. package/dist/{chunk-sqfvnvqj.js.map → chunk-c14ap3s9.js.map} +1 -1
  132. package/dist/{chunk-661ezhks.js → chunk-cbcgs9f7.js} +87 -8
  133. package/dist/chunk-cbcgs9f7.js.map +11 -0
  134. package/dist/chunk-cwdzcv37.js.map +1 -1
  135. package/dist/{chunk-bab05bhg.js → chunk-dgtd0836.js} +1 -1
  136. package/dist/{chunk-1j6j0rht.js → chunk-e24fvw8g.js} +1 -1
  137. package/dist/{chunk-1j6j0rht.js.map → chunk-e24fvw8g.js.map} +1 -1
  138. package/dist/chunk-e5wf5vz0.js.map +1 -1
  139. package/dist/chunk-eptrvnby.js.map +1 -1
  140. package/dist/chunk-ey1nk510.js.map +1 -1
  141. package/dist/{chunk-j936th07.js → chunk-fakrpfy3.js} +58 -58
  142. package/dist/{chunk-j936th07.js.map → chunk-fakrpfy3.js.map} +5 -5
  143. package/dist/chunk-fb3feg1e.js.map +1 -1
  144. package/dist/chunk-ff5xkv0p.js.map +1 -1
  145. package/dist/chunk-fntqb7qy.js.map +1 -1
  146. package/dist/{chunk-7ny9mjgm.js → chunk-ft3w5ahs.js} +1 -1
  147. package/dist/chunk-g663fahq.js.map +1 -1
  148. package/dist/{chunk-cdk3egjj.js → chunk-h1na2cxc.js} +1 -1
  149. package/dist/{chunk-cdk3egjj.js.map → chunk-h1na2cxc.js.map} +1 -1
  150. package/dist/chunk-hn2r7z41.js.map +1 -1
  151. package/dist/{chunk-24bqx0dx.js → chunk-hn76sanm.js} +1 -1
  152. package/dist/{chunk-24bqx0dx.js.map → chunk-hn76sanm.js.map} +1 -1
  153. package/dist/chunk-jmfet9r4.js.map +1 -1
  154. package/dist/{chunk-bnr4a734.js → chunk-jn3ysaf2.js} +24 -22
  155. package/dist/{chunk-bnr4a734.js.map → chunk-jn3ysaf2.js.map} +5 -5
  156. package/dist/{chunk-4y26vs3v.js → chunk-jspskey0.js} +16 -3
  157. package/dist/chunk-jspskey0.js.map +10 -0
  158. package/dist/{chunk-r6szek0x.js → chunk-jt3r6thp.js} +2 -135
  159. package/dist/chunk-jt3r6thp.js.map +10 -0
  160. package/dist/chunk-kfee1h52.js.map +1 -1
  161. package/dist/{chunk-qx00vjrj.js → chunk-kwfhd1g0.js} +23 -23
  162. package/dist/{chunk-qx00vjrj.js.map → chunk-kwfhd1g0.js.map} +4 -4
  163. package/dist/chunk-m427qgq0.js.map +1 -1
  164. package/dist/chunk-mbsbxarb.js.map +1 -1
  165. package/dist/{chunk-et017krg.js → chunk-mdxmt0n3.js} +8657 -8704
  166. package/dist/{chunk-et017krg.js.map → chunk-mdxmt0n3.js.map} +37 -37
  167. package/dist/chunk-mmagke4x.js.map +1 -1
  168. package/dist/{chunk-2x19q6k6.js → chunk-mqx25wwh.js} +319 -154
  169. package/dist/chunk-mqx25wwh.js.map +18 -0
  170. package/dist/chunk-mzx71snp.js.map +1 -1
  171. package/dist/chunk-n8q5j6y5.js.map +1 -1
  172. package/dist/chunk-npcr0228.js.map +1 -1
  173. package/dist/{chunk-m2nevja0.js → chunk-phm3c7b9.js} +1 -1
  174. package/dist/{chunk-m2nevja0.js.map → chunk-phm3c7b9.js.map} +1 -1
  175. package/dist/chunk-qf954wje.js.map +1 -1
  176. package/dist/{chunk-65pyhyas.js → chunk-qgvbxfqv.js} +6 -8
  177. package/dist/{chunk-65pyhyas.js.map → chunk-qgvbxfqv.js.map} +2 -2
  178. package/dist/{chunk-hk38wahh.js → chunk-qst145py.js} +4 -4
  179. package/dist/{chunk-hk38wahh.js.map → chunk-qst145py.js.map} +1 -1
  180. package/dist/{chunk-c844dkwd.js → chunk-qtzftvxa.js} +4 -5
  181. package/dist/{chunk-c844dkwd.js.map → chunk-qtzftvxa.js.map} +2 -2
  182. package/dist/chunk-ratkv4zc.js +3 -0
  183. package/dist/chunk-ratkv4zc.js.map +9 -0
  184. package/dist/{chunk-nzapm6p0.js → chunk-s3we74h8.js} +1 -2
  185. package/dist/chunk-s3we74h8.js.map +12 -0
  186. package/dist/{chunk-0xmt5p5y.js → chunk-t3brw0wd.js} +1 -2
  187. package/dist/{chunk-0xmt5p5y.js.map → chunk-t3brw0wd.js.map} +2 -2
  188. package/dist/chunk-t5608tkq.js.map +1 -1
  189. package/dist/chunk-tdxfsg1c.js.map +1 -1
  190. package/dist/{chunk-1t6k1avb.js → chunk-tnhqtfea.js} +1 -1
  191. package/dist/chunk-vhbw5sqm.js.map +1 -1
  192. package/dist/{chunk-rp9wwk7b.js → chunk-vx4e4zv4.js} +30 -30
  193. package/dist/{chunk-rp9wwk7b.js.map → chunk-vx4e4zv4.js.map} +4 -4
  194. package/dist/chunk-waqk73p1.js.map +1 -1
  195. package/dist/chunk-x0v3jd47.js.map +1 -1
  196. package/dist/{chunk-yecwnwpq.js → chunk-xm8qgbqm.js} +58 -29
  197. package/dist/{chunk-yecwnwpq.js.map → chunk-xm8qgbqm.js.map} +7 -7
  198. package/dist/{chunk-97wr6p2g.js → chunk-y7j6x4h0.js} +8 -8
  199. package/dist/{chunk-97wr6p2g.js.map → chunk-y7j6x4h0.js.map} +4 -4
  200. package/dist/{chunk-xe0732g0.js → chunk-yavhtnac.js} +12 -8
  201. package/dist/{chunk-xe0732g0.js.map → chunk-yavhtnac.js.map} +4 -4
  202. package/dist/chunk-yd00vzqr.js +3394 -0
  203. package/dist/chunk-yd00vzqr.js.map +37 -0
  204. package/dist/{chunk-n9w3n38q.js → chunk-ye5c8016.js} +54 -8
  205. package/dist/chunk-ye5c8016.js.map +23 -0
  206. package/dist/chunk-yw9pyg66.js.map +1 -1
  207. package/dist/{chunk-nydf3dbe.js → chunk-z9mg7wya.js} +37 -20
  208. package/dist/chunk-z9mg7wya.js.map +13 -0
  209. package/dist/chunk-zbc929zg.js.map +1 -1
  210. package/dist/chunk-zhh1jd89.js +290 -0
  211. package/dist/chunk-zhh1jd89.js.map +10 -0
  212. package/dist/connectors/connections/authorizations.d.ts +2 -2
  213. package/dist/connectors/connections/authorizations.d.ts.map +1 -1
  214. package/dist/connectors/connections/service.d.ts.map +1 -1
  215. package/dist/connectors/connections/tokens.d.ts +2 -2
  216. package/dist/connectors/connections/tokens.d.ts.map +1 -1
  217. package/dist/connectors/connections/validation.d.ts +5 -0
  218. package/dist/connectors/connections/validation.d.ts.map +1 -1
  219. package/dist/connectors/types.d.ts +9 -2
  220. package/dist/connectors/types.d.ts.map +1 -1
  221. package/dist/datasets/write.js +3 -3
  222. package/dist/deploy/internal.js +2 -5
  223. package/dist/deploy/internal.js.map +3 -3
  224. package/dist/deploy/types.d.ts +0 -2
  225. package/dist/deploy/types.d.ts.map +1 -1
  226. package/dist/execution/agent.d.ts +2 -2
  227. package/dist/execution/agent.d.ts.map +1 -1
  228. package/dist/execution/agent.js +38 -38
  229. package/dist/execution/agent.js.map +1 -1
  230. package/dist/execution/primitive.js +35 -35
  231. package/dist/execution/request.js +37 -37
  232. package/dist/execution/request.js.map +2 -2
  233. package/dist/http/api-routes.d.ts +12 -11
  234. package/dist/http/api-routes.d.ts.map +1 -1
  235. package/dist/http/index.js +1 -1
  236. package/dist/index.d.ts +3 -3
  237. package/dist/index.d.ts.map +1 -1
  238. package/dist/index.js +53 -51
  239. package/dist/index.js.map +1 -1
  240. package/dist/lake-storage/index.js +3 -3
  241. package/dist/logging/internal.js +1 -1
  242. package/dist/materializer/index.js +17 -17
  243. package/dist/models/execution/errors.d.ts +5 -0
  244. package/dist/models/execution/errors.d.ts.map +1 -1
  245. package/dist/models/execution/index.d.ts +2 -1
  246. package/dist/models/execution/index.d.ts.map +1 -1
  247. package/dist/models/execution/index.js +55 -50
  248. package/dist/models/execution/index.js.map +1 -1
  249. package/dist/models/execution/model-call-recorder.d.ts +7 -2
  250. package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
  251. package/dist/models/execution.d.ts.map +1 -1
  252. package/dist/models/language-call.d.ts +51 -0
  253. package/dist/models/language-call.d.ts.map +1 -0
  254. package/dist/objects/index.js +35 -35
  255. package/dist/objects/query/index.js +17 -17
  256. package/dist/ontology/docs-markdown.d.ts.map +1 -1
  257. package/dist/ontology/index.d.ts +1 -1
  258. package/dist/ontology/index.d.ts.map +1 -1
  259. package/dist/ontology/index.js +4 -4
  260. package/dist/ontology/internal.js +8 -275
  261. package/dist/ontology/internal.js.map +3 -4
  262. package/dist/ontology/user-ref.d.ts +21 -3
  263. package/dist/ontology/user-ref.d.ts.map +1 -1
  264. package/dist/pipelines/index.js +19 -19
  265. package/dist/projections/builders.d.ts +13 -2
  266. package/dist/projections/builders.d.ts.map +1 -1
  267. package/dist/projections/index.d.ts +1 -1
  268. package/dist/projections/index.d.ts.map +1 -1
  269. package/dist/projections/internal.js +17 -17
  270. package/dist/projections/types.d.ts +7 -0
  271. package/dist/projections/types.d.ts.map +1 -1
  272. package/dist/projections/validation.d.ts +2 -0
  273. package/dist/projections/validation.d.ts.map +1 -1
  274. package/dist/query.js +2 -2
  275. package/dist/queues/in-memory.d.ts +0 -1
  276. package/dist/queues/in-memory.d.ts.map +1 -1
  277. package/dist/queues/index.d.ts +1 -1
  278. package/dist/queues/index.d.ts.map +1 -1
  279. package/dist/queues/index.js +1 -1
  280. package/dist/queues/types.d.ts +0 -8
  281. package/dist/queues/types.d.ts.map +1 -1
  282. package/dist/runtime/internal.js +23 -23
  283. package/dist/runtime/internal.js.map +1 -1
  284. package/dist/sandboxes/configuration.d.ts +4 -6
  285. package/dist/sandboxes/configuration.d.ts.map +1 -1
  286. package/dist/sandboxes/environment.d.ts.map +1 -1
  287. package/dist/sandboxes/exec.d.ts +5 -3
  288. package/dist/sandboxes/exec.d.ts.map +1 -1
  289. package/dist/sandboxes/guest-credentials.d.ts +61 -0
  290. package/dist/sandboxes/guest-credentials.d.ts.map +1 -0
  291. package/dist/sandboxes/index.d.ts +2 -0
  292. package/dist/sandboxes/index.d.ts.map +1 -1
  293. package/dist/sandboxes/index.js +23 -9
  294. package/dist/sandboxes/index.js.map +1 -1
  295. package/dist/sandboxes/sandbox.d.ts +18 -4
  296. package/dist/sandboxes/sandbox.d.ts.map +1 -1
  297. package/dist/security/internal.js +1 -1
  298. package/dist/security/internal.js.map +1 -1
  299. package/dist/shares/internal.js +17 -17
  300. package/dist/shares/internal.js.map +1 -1
  301. package/dist/storage/agents/in-memory.d.ts +3 -1
  302. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  303. package/dist/storage/agents/index.d.ts +1 -1
  304. package/dist/storage/agents/index.d.ts.map +1 -1
  305. package/dist/storage/agents/provider.d.ts +6 -0
  306. package/dist/storage/agents/provider.d.ts.map +1 -1
  307. package/dist/storage/agents/provider.js +8 -2
  308. package/dist/storage/agents/provider.js.map +1 -1
  309. package/dist/storage/agents/types.d.ts +63 -7
  310. package/dist/storage/agents/types.d.ts.map +1 -1
  311. package/dist/storage/ai-cost/provider.js +2 -2
  312. package/dist/storage/connector-connections/provider.js.map +1 -1
  313. package/dist/storage/file-upload-sessions/provider.js +9 -9
  314. package/dist/storage/index.d.ts +1 -1
  315. package/dist/storage/index.d.ts.map +1 -1
  316. package/dist/storage/index.js +15 -15
  317. package/dist/storage/ontology/provider.js +1 -1
  318. package/dist/storage/share-grants/provider.js +3 -3
  319. package/dist/storage/types.d.ts +1 -1
  320. package/dist/storage/types.d.ts.map +1 -1
  321. package/dist/storage/workflow-runs/provider.js +9 -9
  322. package/dist/syncs/index.js +20 -20
  323. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  324. package/dist/testing/index.d.ts +2 -0
  325. package/dist/testing/index.d.ts.map +1 -1
  326. package/dist/testing/index.js +677 -352
  327. package/dist/testing/index.js.map +9 -7
  328. package/dist/testing/queues-contract.d.ts.map +1 -1
  329. package/dist/testing/sandbox-credentials-contract.d.ts +27 -0
  330. package/dist/testing/sandbox-credentials-contract.d.ts.map +1 -0
  331. package/dist/testing/sandboxes-contract.d.ts.map +1 -1
  332. package/dist/testing/users.d.ts +20 -0
  333. package/dist/testing/users.d.ts.map +1 -0
  334. package/dist/users/execution.d.ts +6 -2
  335. package/dist/users/execution.d.ts.map +1 -1
  336. package/dist/users/index.d.ts +1 -1
  337. package/dist/users/index.d.ts.map +1 -1
  338. package/dist/webhooks/internal.js +17 -17
  339. package/dist/webhooks/internal.js.map +1 -1
  340. package/dist/workers/index.js.map +1 -1
  341. package/dist/workflows/index.js +41 -39
  342. package/dist/workflows/index.js.map +1 -1
  343. package/package.json +1 -1
  344. package/src/agents/README.md +136 -0
  345. package/src/agents/attachment-keys.ts +83 -0
  346. package/src/agents/cancel.ts +16 -1
  347. package/src/agents/children.ts +5 -3
  348. package/src/agents/dispatch.ts +6 -58
  349. package/src/agents/execution.ts +18 -0
  350. package/src/agents/index.ts +127 -21
  351. package/src/agents/model-loop.ts +23 -73
  352. package/src/agents/model-routing.ts +7 -2
  353. package/src/agents/request.ts +69 -20
  354. package/src/agents/run-after-finish.ts +133 -0
  355. package/src/agents/run-artifacts.ts +257 -0
  356. package/src/agents/run-events.ts +302 -0
  357. package/src/agents/run-fence.ts +71 -0
  358. package/src/agents/run-liveness.ts +122 -0
  359. package/src/agents/run-plan.ts +316 -0
  360. package/src/agents/run-session-children.ts +303 -0
  361. package/src/agents/run-session-http.ts +397 -0
  362. package/src/agents/run-session-serve.ts +479 -0
  363. package/src/agents/run-session-wire.ts +189 -0
  364. package/src/agents/run-session.ts +802 -0
  365. package/src/agents/run-token.ts +124 -0
  366. package/src/agents/run-tools.ts +180 -0
  367. package/src/agents/run-turn.ts +265 -0
  368. package/src/agents/streams/internal.ts +0 -1
  369. package/src/agents/streams/protocol.ts +0 -292
  370. package/src/agents/subagent-runs.ts +19 -1
  371. package/src/agents/tool-files.ts +225 -0
  372. package/src/agents/workflow-node-session.ts +387 -0
  373. package/src/artifacts/publish/index.ts +1 -0
  374. package/src/connectors/connections/authorizations.ts +3 -2
  375. package/src/connectors/connections/service.ts +5 -1
  376. package/src/connectors/connections/tokens.ts +41 -5
  377. package/src/connectors/connections/validation.ts +21 -0
  378. package/src/connectors/types.ts +12 -2
  379. package/src/deploy/types.ts +0 -2
  380. package/src/deploy/validation.ts +1 -4
  381. package/src/execution/agent.ts +2 -2
  382. package/src/execution/authorized-object-reader.ts +28 -1
  383. package/src/http/api-routes.ts +114 -27
  384. package/src/index.ts +3 -1
  385. package/src/models/execution/README.md +15 -1
  386. package/src/models/execution/errors.ts +14 -0
  387. package/src/models/execution/index.ts +2 -1
  388. package/src/models/execution/model-call-recorder.ts +12 -10
  389. package/src/models/execution.ts +9 -11
  390. package/src/models/language-call.ts +247 -0
  391. package/src/ontology/docs-markdown.ts +14 -0
  392. package/src/ontology/index.ts +1 -1
  393. package/src/ontology/user-ref.ts +40 -6
  394. package/src/projections/builders.ts +48 -4
  395. package/src/projections/index.ts +1 -0
  396. package/src/projections/registry.ts +1 -0
  397. package/src/projections/revision.ts +10 -0
  398. package/src/projections/types.ts +8 -0
  399. package/src/projections/validation.ts +52 -6
  400. package/src/queues/in-memory.ts +0 -5
  401. package/src/queues/index.ts +0 -2
  402. package/src/queues/types.ts +0 -13
  403. package/src/runtime/host.ts +1 -1
  404. package/src/sandboxes/README.md +17 -6
  405. package/src/sandboxes/configuration.ts +7 -9
  406. package/src/sandboxes/environment.ts +1 -0
  407. package/src/sandboxes/exec.ts +17 -9
  408. package/src/sandboxes/guest-credentials.ts +262 -0
  409. package/src/sandboxes/index.ts +14 -0
  410. package/src/sandboxes/sandbox.ts +19 -4
  411. package/src/storage/agents/in-memory.ts +53 -0
  412. package/src/storage/agents/index.ts +2 -0
  413. package/src/storage/agents/provider.ts +56 -11
  414. package/src/storage/agents/types.ts +59 -7
  415. package/src/storage/index.ts +2 -0
  416. package/src/storage/types.ts +1 -0
  417. package/src/testing/agent-storage-contract.ts +175 -2
  418. package/src/testing/ai-model-call-groups-contract.ts +0 -1
  419. package/src/testing/index.ts +5 -0
  420. package/src/testing/queues-contract.ts +0 -16
  421. package/src/testing/sandbox-credentials-contract.ts +284 -0
  422. package/src/testing/sandboxes-contract.ts +21 -0
  423. package/src/testing/users.ts +39 -0
  424. package/src/users/execution.ts +33 -7
  425. package/src/users/index.ts +7 -1
  426. package/dist/agents/api-gateway.d.ts +0 -26
  427. package/dist/agents/api-gateway.d.ts.map +0 -1
  428. package/dist/chunk-2x19q6k6.js.map +0 -17
  429. package/dist/chunk-4y26vs3v.js.map +0 -10
  430. package/dist/chunk-661ezhks.js.map +0 -11
  431. package/dist/chunk-d2m879s4.js.map +0 -12
  432. package/dist/chunk-n9w3n38q.js.map +0 -23
  433. package/dist/chunk-nydf3dbe.js.map +0 -13
  434. package/dist/chunk-nzapm6p0.js.map +0 -12
  435. package/dist/chunk-r6szek0x.js.map +0 -10
  436. package/dist/chunk-vabga7fk.js +0 -176
  437. package/dist/chunk-vabga7fk.js.map +0 -12
  438. package/dist/chunk-vpgwq5nf.js +0 -810
  439. package/dist/chunk-vpgwq5nf.js.map +0 -21
  440. package/src/agents/api-gateway.ts +0 -68
  441. /package/dist/{chunk-2gjj5dx3.js.map → chunk-78ymxrn0.js.map} +0 -0
  442. /package/dist/{chunk-6n69k945.js.map → chunk-8mb7mt8n.js.map} +0 -0
  443. /package/dist/{chunk-m36fw8ft.js.map → chunk-8wsjr52f.js.map} +0 -0
  444. /package/dist/{chunk-bab05bhg.js.map → chunk-dgtd0836.js.map} +0 -0
  445. /package/dist/{chunk-7ny9mjgm.js.map → chunk-ft3w5ahs.js.map} +0 -0
  446. /package/dist/{chunk-1t6k1avb.js.map → chunk-tnhqtfea.js.map} +0 -0
@@ -0,0 +1,387 @@
1
+ import type { Broker } from "../broker"
2
+ import type { SixbFailure } from "../errors/types"
3
+ import type { DomainEventLog } from "../events/service"
4
+ import type { AuthorizationRef } from "../execution"
5
+ import type { JsonValue } from "../json"
6
+ import {
7
+ AiModelCallRecorder,
8
+ createAiModelCallLimitController,
9
+ type ModelCallAccountingStorage,
10
+ type RecoverAiModelCall,
11
+ } from "../models/execution/index"
12
+ import type { Queue, WorkflowQueueJob, WorkflowQueueJobFailureCode } from "../queues"
13
+ import type { SecurityDefinitionCatalog } from "../security"
14
+ import type { Storage } from "../storage"
15
+ import type { AgentRunFailureCode, AgentRunFinishReason } from "../storage/agents"
16
+ import type { AuthStorage } from "../storage/auth"
17
+ import type { ExecutionRecord } from "../storage/executions/types"
18
+ import type {
19
+ WorkflowAgentNodeRunRecord,
20
+ WorkflowNodeRunRecord,
21
+ WorkflowRunFailureCode,
22
+ WorkflowRunRecord,
23
+ WorkflowRunStorage,
24
+ } from "../storage/workflow-runs"
25
+ import { resolveAgentExecutionAuthorization } from "./authority"
26
+ import { createAgentRunExecutionToken } from "./ids"
27
+ import type { AgentMessagePart } from "./message"
28
+ import { AgentExecutionLostError } from "./run-fence"
29
+ import { type AgentRunPeople, agentRunPeople, watchAgentRunCancel } from "./run-session"
30
+
31
+ /**
32
+ * A workflow agent step's session: the step's agent node, claimed with a fresh execution token,
33
+ * and what the step does to shared state. Its finish ends the node and, when it failed, the
34
+ * workflow run, in one transaction fenced by the token, then publishes the outcome and, once the
35
+ * node succeeded, queues the workflow to resume.
36
+ */
37
+ export interface WorkflowAgentNodeSession {
38
+ /** The agent node as the claim left it: `running`, with this session's execution. */
39
+ readonly node: WorkflowAgentNodeRunRecord
40
+ readonly executionToken: string
41
+ /** Aborts once the step's node is cancelled. */
42
+ readonly cancelled: AbortSignal
43
+ renewLease(leaseExpiresAt: string): Promise<void>
44
+ /** Throws {@link AgentExecutionLostError} unless the node still runs under this session. */
45
+ assertOwned(): Promise<void>
46
+ /** Whether someone already cancelled the node, which then ended without this session. */
47
+ wasCancelled(): Promise<boolean>
48
+ /** The step's model calls, as a run session's: read on first use, again after a failed read. */
49
+ modelCalls(): Promise<AiModelCallRecorder>
50
+ /** The step's execution: whom its workflow runs for, and the authority it refers to. */
51
+ execution(): Promise<ExecutionRecord | null>
52
+ /** Members, as a run session reads them. */
53
+ readonly people: AgentRunPeople
54
+ /** The authority the step's actor carries now, under its workflow's execution. */
55
+ authorizeActor(
56
+ actorId: string,
57
+ ref: AuthorizationRef
58
+ ): ReturnType<typeof resolveAgentExecutionAuthorization>
59
+ /** The node answered. Throws {@link WorkflowResumeDispatchError} when its resume is not queued. */
60
+ finishSucceeded(input: {
61
+ readonly modelId: string
62
+ readonly finishReason: AgentRunFinishReason
63
+ readonly trace: readonly AgentMessagePart[]
64
+ readonly output: Readonly<Record<string, JsonValue>>
65
+ /** The workflow's node count, which the node's event names. */
66
+ readonly totalNodes: number
67
+ }): Promise<WorkflowNodeRunRecord>
68
+ /** The node failed or was cancelled, and its workflow run with it. */
69
+ finishFailed(input: {
70
+ readonly status: "failed" | "cancelled"
71
+ readonly at: Date
72
+ readonly modelId?: string
73
+ readonly finishReason?: AgentRunFinishReason
74
+ readonly trace?: readonly AgentMessagePart[]
75
+ readonly agentError: SixbFailure<AgentRunFailureCode>
76
+ readonly workflowError: SixbFailure<WorkflowRunFailureCode>
77
+ /** Absent when the workflow's definition is gone: its node event is then left out. */
78
+ readonly totalNodes?: number
79
+ }): Promise<{ readonly node: WorkflowNodeRunRecord; readonly run: WorkflowRunRecord }>
80
+ close(): void
81
+ }
82
+
83
+ export interface WorkflowAgentNodeSessionHost {
84
+ readonly projectId: string
85
+ readonly storage: Storage & { readonly auth: AuthStorage } & ModelCallAccountingStorage
86
+ readonly broker: Broker
87
+ readonly recoverAiModelCall: RecoverAiModelCall
88
+ readonly events: DomainEventLog
89
+ readonly workflowQueue: Queue<WorkflowQueueJob, WorkflowQueueJobFailureCode>
90
+ readonly security: SecurityDefinitionCatalog
91
+ }
92
+
93
+ /**
94
+ * A workflow agent node succeeded but its workflow resume could not be queued. The runner leaves
95
+ * the node's job unacknowledged: a redelivery finds the node succeeded and only re-sends the resume.
96
+ */
97
+ export class WorkflowResumeDispatchError extends Error {
98
+ readonly name = "WorkflowResumeDispatchError"
99
+ constructor(
100
+ readonly nodeRunId: string,
101
+ options?: ErrorOptions
102
+ ) {
103
+ super(`[Sixb] Could not queue the workflow resume after agent node '${nodeRunId}'.`, options)
104
+ }
105
+ }
106
+
107
+ /** Short in-place retries that absorb a transient storage blip, as a run's finish has. */
108
+ const FINISH_BACKOFF_MS = [50, 200, 600] as const
109
+
110
+ async function retryFinish<T>(
111
+ finish: () => Promise<T>,
112
+ committed: () => Promise<T | null>
113
+ ): Promise<T> {
114
+ for (let attempt = 0; ; attempt += 1) {
115
+ try {
116
+ return await finish()
117
+ } catch (error) {
118
+ const delay = FINISH_BACKOFF_MS[attempt]
119
+ if (delay === undefined) throw error
120
+ await new Promise((resolve) => setTimeout(resolve, delay))
121
+ const done = await committed().catch((reason: unknown) => {
122
+ if (reason instanceof AgentExecutionLostError) throw reason
123
+ return null
124
+ })
125
+ if (done) return done
126
+ }
127
+ }
128
+ }
129
+
130
+ /** Start a queued agent node, or reclaim a running one, and open its session. */
131
+ export async function claimWorkflowAgentNode(
132
+ host: WorkflowAgentNodeSessionHost,
133
+ input: {
134
+ readonly node: WorkflowAgentNodeRunRecord
135
+ readonly nodeRun: WorkflowNodeRunRecord
136
+ readonly leaseExpiresAt: string
137
+ }
138
+ ): Promise<WorkflowAgentNodeSession> {
139
+ const { projectId } = host
140
+ if (!host.storage.workflowRuns) {
141
+ throw new Error("[Sixb] Workflow agent nodes require workflow storage.")
142
+ }
143
+ const agentNodes = host.storage.workflowRuns.agentNodes
144
+ const execution = {
145
+ token: createAgentRunExecutionToken(),
146
+ queueLeaseExpiresAt: new Date(input.leaseExpiresAt),
147
+ }
148
+ const claim = { projectId, nodeRunId: input.nodeRun.id, execution }
149
+ const node =
150
+ input.node.status === "queued" ? await agentNodes.start(claim) : await agentNodes.reclaim(claim)
151
+ const executionToken = node.execution?.token
152
+ if (!executionToken) {
153
+ throw new Error(`[Sixb] Agent workflow node '${input.nodeRun.id}' has no execution token.`)
154
+ }
155
+
156
+ const nodeRun = input.nodeRun
157
+ const fence = { projectId, nodeRunId: nodeRun.id, executionToken }
158
+ const cancel = await watchAgentRunCancel(host, [nodeRun.id])
159
+ let modelCalls: Promise<AiModelCallRecorder> | undefined
160
+
161
+ const transaction = <T>(write: (runs: WorkflowRunStorage) => Promise<T>) =>
162
+ host.storage.transaction(async (tx) => {
163
+ if (!tx.workflowRuns) {
164
+ throw new Error("[Sixb] Workflow storage disappeared during finalization.")
165
+ }
166
+ return write(tx.workflowRuns)
167
+ })
168
+
169
+ return {
170
+ node,
171
+ executionToken,
172
+ cancelled: cancel.signal,
173
+ async renewLease(leaseExpiresAt) {
174
+ await agentNodes.confirmExecutionOwnership({
175
+ ...fence,
176
+ queueLeaseExpiresAt: new Date(leaseExpiresAt),
177
+ })
178
+ },
179
+ async assertOwned() {
180
+ const current = await agentNodes.getByNodeRunId({ projectId, nodeRunId: nodeRun.id })
181
+ if (
182
+ current?.status !== "running" ||
183
+ current.execution?.token !== executionToken ||
184
+ current.execution.queueLeaseExpiresAt.getTime() <= Date.now()
185
+ ) {
186
+ throw new AgentExecutionLostError(nodeRun.id)
187
+ }
188
+ },
189
+ async wasCancelled() {
190
+ const current = await agentNodes.getByNodeRunId({ projectId, nodeRunId: nodeRun.id })
191
+ return current?.status === "cancelled"
192
+ },
193
+ modelCalls() {
194
+ modelCalls ??= openNodeModelCalls(host, node).catch((error: unknown) => {
195
+ modelCalls = undefined
196
+ throw error
197
+ })
198
+ return modelCalls
199
+ },
200
+ execution: () => host.storage.executions.getById({ projectId, id: node.executionId }),
201
+ people: agentRunPeople(host),
202
+ authorizeActor: (actorId, ref) =>
203
+ resolveAgentExecutionAuthorization({
204
+ auth: host.storage.auth,
205
+ projectId,
206
+ actorId,
207
+ authorizationRef: ref,
208
+ security: host.security,
209
+ }),
210
+ async finishSucceeded(result) {
211
+ // The agent already answered: a storage blip here must not fail its workflow.
212
+ const finished = await retryFinish(
213
+ () =>
214
+ transaction(async (runs) => {
215
+ await runs.agentNodes.finish({
216
+ ...fence,
217
+ status: "succeeded",
218
+ modelId: result.modelId,
219
+ finishReason: result.finishReason,
220
+ trace: result.trace,
221
+ })
222
+ return runs.nodes.finish({
223
+ projectId,
224
+ id: nodeRun.id,
225
+ status: "succeeded",
226
+ output: result.output,
227
+ })
228
+ }),
229
+ // A commit whose answer was lost: the node is already succeeded. Another runner that
230
+ // reclaimed the node bumped its attempt, and what it finished is not this session's.
231
+ async () => {
232
+ const agentNode = await agentNodes.getByNodeRunId({ projectId, nodeRunId: nodeRun.id })
233
+ if (agentNode && agentNode.attempt !== node.attempt) {
234
+ throw new AgentExecutionLostError(nodeRun.id)
235
+ }
236
+
237
+ const current = await host.storage.workflowRuns?.nodes.getById({
238
+ projectId,
239
+ id: nodeRun.id,
240
+ })
241
+ return current?.status === "succeeded" ? current : null
242
+ }
243
+ )
244
+ await host.events.emit(
245
+ { events: [nodeFinishedEvent(finished, result.totalNodes, "succeeded")] },
246
+ { source: "SixbAgentWorker" }
247
+ )
248
+ await enqueueWorkflowAgentNodeResume(host, nodeRun)
249
+ return finished
250
+ },
251
+ async finishFailed(input) {
252
+ const failed = await transaction(async (runs) => {
253
+ await runs.agentNodes.finish({
254
+ ...fence,
255
+ status: input.status,
256
+ modelId: input.modelId,
257
+ finishReason: input.finishReason,
258
+ trace: input.trace,
259
+ error: input.agentError,
260
+ completedAt: input.at,
261
+ })
262
+ const finishedNode = await runs.nodes.finish({
263
+ projectId,
264
+ id: nodeRun.id,
265
+ status: input.status,
266
+ finishedAt: input.at,
267
+ error: input.workflowError,
268
+ })
269
+ const run = await runs.finish({
270
+ projectId,
271
+ id: nodeRun.workflowRunId,
272
+ status: input.status,
273
+ finishedAt: input.at,
274
+ error: input.workflowError,
275
+ })
276
+ return { node: finishedNode, run }
277
+ })
278
+ await host.events.emit(
279
+ {
280
+ events: [
281
+ // A removed definition has no trustworthy node count; the durable failure and run
282
+ // event still describe the outcome without inventing workflow metadata.
283
+ ...(input.totalNodes === undefined
284
+ ? []
285
+ : [nodeFinishedEvent(failed.node, input.totalNodes, input.status)]),
286
+ {
287
+ type: "workflow.run.finished",
288
+ payload: {
289
+ workflowId: failed.run.workflowId,
290
+ runId: failed.run.id,
291
+ status: input.status,
292
+ finishedAt: requireFinishedAt(failed.run).toISOString(),
293
+ ...(failed.run.error ? { error: failed.run.error } : {}),
294
+ },
295
+ },
296
+ ],
297
+ },
298
+ { source: "SixbAgentWorker" }
299
+ )
300
+ return failed
301
+ },
302
+ close: cancel.stop,
303
+ }
304
+ }
305
+
306
+ /**
307
+ * Queue the workflow to resume after its agent node succeeded: once by the node's finish, again
308
+ * by a redelivery that finds the node already succeeded. The job id makes the second a no-op.
309
+ */
310
+ export async function enqueueWorkflowAgentNodeResume(
311
+ host: Pick<WorkflowAgentNodeSessionHost, "projectId" | "workflowQueue">,
312
+ node: Pick<WorkflowNodeRunRecord, "id" | "workflowRunId">
313
+ ): Promise<void> {
314
+ try {
315
+ await host.workflowQueue.enqueue({
316
+ projectId: host.projectId,
317
+ jobs: [
318
+ {
319
+ id: `wfa_resume_${node.id}`,
320
+ type: "workflow.run.resume.requested",
321
+ payload: { runId: node.workflowRunId, nodeRunId: node.id },
322
+ },
323
+ ],
324
+ })
325
+ } catch (error) {
326
+ throw new WorkflowResumeDispatchError(node.id, { cause: error })
327
+ }
328
+ }
329
+
330
+ async function openNodeModelCalls(
331
+ host: WorkflowAgentNodeSessionHost,
332
+ node: WorkflowAgentNodeRunRecord
333
+ ): Promise<AiModelCallRecorder> {
334
+ const execution = await host.storage.executions.getById({
335
+ projectId: host.projectId,
336
+ id: node.executionId,
337
+ })
338
+ if (!execution) {
339
+ throw new Error(
340
+ `[Sixb] Agent workflow node '${node.nodeRunId}' references missing execution '${node.executionId}'.`
341
+ )
342
+ }
343
+ return new AiModelCallRecorder({
344
+ storage: host.storage,
345
+ projectId: host.projectId,
346
+ executionId: node.executionId,
347
+ attempt: node.attempt,
348
+ requesterGroupIds: execution.requesterGroupIds,
349
+ limits: createAiModelCallLimitController({
350
+ storage: host.storage,
351
+ projectId: host.projectId,
352
+ requestedBy: execution.requestedBy,
353
+ requesterGroupIds: execution.requesterGroupIds,
354
+ }),
355
+ recoverAiModelCall: host.recoverAiModelCall,
356
+ })
357
+ }
358
+
359
+ function nodeFinishedEvent(
360
+ node: WorkflowNodeRunRecord,
361
+ totalNodes: number,
362
+ status: "succeeded" | "failed" | "cancelled"
363
+ ) {
364
+ return {
365
+ type: "workflow.run.node.finished" as const,
366
+ payload: {
367
+ workflowId: node.workflowId,
368
+ runId: node.workflowRunId,
369
+ nodeRunId: node.id,
370
+ nodeIndex: node.nodeIndex,
371
+ totalNodes,
372
+ nodeType: "agent" as const,
373
+ nodeId: node.nodeId,
374
+ nodeKey: node.nodeKey,
375
+ status,
376
+ finishedAt: requireFinishedAt(node).toISOString(),
377
+ ...(status !== "succeeded" && node.error ? { error: node.error } : {}),
378
+ },
379
+ }
380
+ }
381
+
382
+ function requireFinishedAt(record: WorkflowNodeRunRecord | WorkflowRunRecord): Date {
383
+ if (!record.finishedAt) {
384
+ throw new Error(`[Sixb] Workflow record '${record.id}' finished without a finish time.`)
385
+ }
386
+ return record.finishedAt
387
+ }
@@ -8,6 +8,7 @@ export {
8
8
  artifactVersionWarnings,
9
9
  type PreparedArtifactVersion,
10
10
  type PublishArtifactInput,
11
+ type PublishedArtifact,
11
12
  prepareArtifactVersion,
12
13
  publishArtifact,
13
14
  storeArtifactVersion,
@@ -290,10 +290,11 @@ export class DefaultConnectorAuthorizationLifecycle implements ConnectorAuthoriz
290
290
 
291
291
  createTokenSource(
292
292
  definition: OAuthConnectorDefinition,
293
- authorizationId: string
293
+ authorizationId: string,
294
+ account: ConnectorAccountCandidate
294
295
  ): ConnectorTokenSource {
295
296
  this.assertRegistered(definition)
296
- return this.tokens.createTokenSource(definition, authorizationId)
297
+ return this.tokens.createTokenSource(definition, authorizationId, account)
297
298
  }
298
299
 
299
300
  async requireAuthorization(
@@ -226,7 +226,11 @@ export class ConnectorConnectionService implements ConnectorConnectionProcess {
226
226
  connectorId: definition.id,
227
227
  connectionId: connection.id,
228
228
  account: connection.account,
229
- tokenSource: this.authorizations.createTokenSource(definition, authorization.id),
229
+ tokenSource: this.authorizations.createTokenSource(
230
+ definition,
231
+ authorization.id,
232
+ connection.account
233
+ ),
230
234
  signal: clientSignal,
231
235
  })
232
236
  },
@@ -2,6 +2,7 @@ import type { ConnectorAuthorizationRecord, ConnectorConnectionStorage } from ".
2
2
  import { createConnectorCodedError, oauthErrorKind, recoverConnectorFailure } from "../errors"
3
3
  import type {
4
4
  ConnectorAccessToken,
5
+ ConnectorAccountCandidate,
5
6
  ConnectorDefinition,
6
7
  ConnectorOAuthCredentials,
7
8
  ConnectorTokenSource,
@@ -14,7 +15,13 @@ import {
14
15
  connectorAuthorizationStatusError,
15
16
  } from "./credential-mutations"
16
17
  import { withConnectorStorageBoundary } from "./storage-boundary"
17
- import { nonNegativeDuration, shouldRefresh, tokenView, validateCredentials } from "./validation"
18
+ import {
19
+ nonNegativeDuration,
20
+ shouldRefresh,
21
+ tokenView,
22
+ validateAccountToken,
23
+ validateCredentials,
24
+ } from "./validation"
18
25
 
19
26
  type OAuthConnectorDefinition = ConnectorDefinition<string, OAuthConnectorAdapter>
20
27
 
@@ -54,10 +61,11 @@ export class ConnectorTokenAccess {
54
61
 
55
62
  createTokenSource(
56
63
  definition: OAuthConnectorDefinition,
57
- authorizationId: string
64
+ authorizationId: string,
65
+ account: ConnectorAccountCandidate
58
66
  ): ConnectorTokenSource {
59
67
  return new RevisionAwareConnectorTokenSource((rejectedRevision) =>
60
- this.getAccessToken(definition, authorizationId, rejectedRevision)
68
+ this.getAccessToken(definition, authorizationId, account, rejectedRevision)
61
69
  )
62
70
  }
63
71
 
@@ -77,6 +85,7 @@ export class ConnectorTokenAccess {
77
85
  private async getAccessToken(
78
86
  definition: OAuthConnectorDefinition,
79
87
  authorizationId: string,
88
+ account: ConnectorAccountCandidate,
80
89
  rejectedRevision?: number
81
90
  ): Promise<{
82
91
  readonly token: { readonly accessToken: string; readonly tokenType?: string }
@@ -92,9 +101,15 @@ export class ConnectorTokenAccess {
92
101
  if (refreshRejectedToken || shouldRefresh(authorization, this.now(), this.refreshSkewMs)) {
93
102
  authorization = await this.refreshAuthorization(definition, authorization)
94
103
  const refreshed = await this.open(definition.id, authorization)
95
- return { token: tokenView(refreshed), revision: authorization.revision }
104
+ return {
105
+ token: deliveredToken(definition, refreshed, account),
106
+ revision: authorization.revision,
107
+ }
108
+ }
109
+ return {
110
+ token: deliveredToken(definition, credentials, account),
111
+ revision: authorization.revision,
96
112
  }
97
- return { token: tokenView(credentials), revision: authorization.revision }
98
113
  }
99
114
 
100
115
  private async refreshAuthorization(
@@ -268,6 +283,27 @@ export class ConnectorTokenAccess {
268
283
  }
269
284
  }
270
285
 
286
+ function deliveredToken(
287
+ definition: OAuthConnectorDefinition,
288
+ credentials: ConnectorOAuthCredentials,
289
+ account: ConnectorAccountCandidate
290
+ ): { readonly accessToken: string; readonly tokenType?: string } {
291
+ const derive = definition.adapter.authentication.accountAccessToken
292
+ if (!derive) return tokenView(credentials)
293
+
294
+ let token: unknown
295
+ try {
296
+ token = derive(credentials, account)
297
+ } catch (error) {
298
+ throw createConnectorCodedError(
299
+ "connector.adapter_invalid",
300
+ "OAuth connector adapter could not derive the account access token.",
301
+ { cause: error }
302
+ )
303
+ }
304
+ return validateAccountToken(token)
305
+ }
306
+
271
307
  class RevisionAwareConnectorTokenSource implements ConnectorTokenSource {
272
308
  private rejectedRevision: number | undefined
273
309
 
@@ -215,6 +215,27 @@ export function shouldRefresh(
215
215
  )
216
216
  }
217
217
 
218
+ /** Validate the token an adapter derives for one connected account. */
219
+ export function validateAccountToken(token: unknown): {
220
+ readonly accessToken: string
221
+ readonly tokenType?: string
222
+ } {
223
+ if (!isRecord(token)) {
224
+ throw createConnectorCodedError(
225
+ "connector.adapter_invalid",
226
+ "OAuth connector adapter returned an invalid account access token."
227
+ )
228
+ }
229
+ return {
230
+ accessToken: nonblank(token.accessToken, "account access token", "connector.adapter_invalid"),
231
+ ...(token.tokenType === undefined
232
+ ? {}
233
+ : {
234
+ tokenType: nonblank(token.tokenType, "account token type", "connector.adapter_invalid"),
235
+ }),
236
+ }
237
+ }
238
+
218
239
  export function tokenView(credentials: ConnectorOAuthCredentials) {
219
240
  return {
220
241
  accessToken: credentials.accessToken,
@@ -36,8 +36,9 @@ export interface ConnectorOAuthCredentials {
36
36
  readonly expiresAt?: Date
37
37
  /**
38
38
  * Provider-owned grant context, encrypted with the tokens and never exposed in connection views.
39
- * Available to account discovery, refresh, and revoke. Refresh preserves it when omitted;
40
- * returning an object replaces it (use {} to clear it). Code exchange starts fresh on reauthorization.
39
+ * Available to account discovery, account tokens, refresh, and revoke. Refresh preserves it when
40
+ * omitted; returning an object replaces it (use {} to clear it). Code exchange starts fresh on
41
+ * reauthorization.
41
42
  */
42
43
  readonly authorizationContext?: ReadonlyJsonObject
43
44
  }
@@ -136,6 +137,15 @@ export interface ConnectorOAuth2Authentication {
136
137
  context: ConnectorContext,
137
138
  credentials: ConnectorOAuthCredentials
138
139
  ): Promise<ConnectorOAuthCredentials> | ConnectorOAuthCredentials
140
+ /**
141
+ * Derives the token delivered to one connection, for providers that issue a token per account
142
+ * from one grant (Meta Page tokens, for example). Defaults to the grant's own access token.
143
+ * Runs on every token delivery, so keep it local: read the credentials, do not call the provider.
144
+ */
145
+ accountAccessToken?(
146
+ credentials: ConnectorOAuthCredentials,
147
+ account: ConnectorAccountCandidate
148
+ ): Pick<ConnectorAccessToken, "accessToken" | "tokenType">
139
149
  /**
140
150
  * Revokes the grant idempotently. An already revoked or invalid grant must resolve successfully
141
151
  * so Sixb can converge after losing an earlier provider response.
@@ -67,8 +67,6 @@ export interface DeployWorkersConfig {
67
67
  * for.
68
68
  */
69
69
  readonly types?: readonly DeployWorkerType[] | "all"
70
- /** Wall-clock budget for one agent turn, such as `"30s"`, `"10m"`, or `"1h"`. */
71
- readonly agentTurnTimeout?: string
72
70
  /** Jobs each worker type runs at once inside one process. */
73
71
  readonly concurrency?: Readonly<Partial<Record<DeployWorkerType, number>>>
74
72
  /** Added to the deployment's `env` for the workers only. */
@@ -83,11 +83,8 @@ function services(value: unknown): void {
83
83
  })
84
84
  }
85
85
  } else {
86
- knownKeys(options, ["types", "agentTurnTimeout", "concurrency", "env", "process"], path)
86
+ knownKeys(options, ["types", "concurrency", "env", "process"], path)
87
87
  if (options.types !== undefined) workerTypes(options.types, `${path}.types`)
88
- if (options.agentTurnTimeout !== undefined) {
89
- string(options.agentTurnTimeout, `${path}.agentTurnTimeout`)
90
- }
91
88
  if (options.concurrency !== undefined) {
92
89
  workerConcurrency(options.concurrency, `${path}.concurrency`)
93
90
  }
@@ -110,12 +110,12 @@ export function bindDurableAgentExecution(
110
110
  }
111
111
 
112
112
  /**
113
- * Bind one agent API gateway request to the run's own execution, the way the run's in-process
113
+ * Bind one run-token request to the run's own execution, the way the run's in-process
114
114
  * tools are bound: what the request starts is a child of the run, with the run's requester and
115
115
  * correlation. Model calls behind it count toward the attempt the request was admitted under, with
116
116
  * a recorder of their own: the worker's in-memory failure state and cancellation do not reach them.
117
117
  */
118
- export function bindAgentGatewayRequestExecution(
118
+ export function bindAgentRunRequestExecution(
119
119
  host: AgentExecutionHost,
120
120
  input: {
121
121
  /** Aborting it cancels the request's model calls. */
@@ -939,7 +939,34 @@ function objectStorageForAuthority(
939
939
  * application-facing authorization boundary must not retain them.
940
940
  */
941
941
  function detachReadResult<T>(value: T): T {
942
- return structuredClone(value)
942
+ return detachReadValue(value) as T
943
+ }
944
+
945
+ /**
946
+ * Results are plain objects, arrays, dates and primitives, which a direct copy handles several
947
+ * times faster than structuredClone; anything else falls back to it. On a page of rows this copy
948
+ * is the largest cost of a query after the read itself.
949
+ */
950
+ function detachReadValue(value: unknown): unknown {
951
+ if (typeof value !== "object" || value === null) return value
952
+ if (Array.isArray(value)) return value.map(detachReadValue)
953
+ if (value instanceof Date) return new Date(value.getTime())
954
+ if (Object.getPrototypeOf(value) !== Object.prototype) return structuredClone(value)
955
+
956
+ const copy: Record<string, unknown> = {}
957
+ for (const key of Object.keys(value)) {
958
+ const item = detachReadValue((value as Record<string, unknown>)[key])
959
+ // Parsed JSON can hold an own "__proto__" key, which assignment would turn into a prototype.
960
+ if (key === "__proto__") {
961
+ Object.defineProperty(copy, key, {
962
+ value: item,
963
+ enumerable: true,
964
+ writable: true,
965
+ configurable: true,
966
+ })
967
+ } else copy[key] = item
968
+ }
969
+ return copy
943
970
  }
944
971
 
945
972
  /** Capture caller-owned values before authorization and execution. */