@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
@@ -553,7 +553,7 @@ function assertWebhookRunStorage(
553
553
  }
554
554
  }
555
555
 
556
- /** Reject source access the factory cannot provide: a run checks what `resolve` returns. */
556
+ /** Reject a factory an agent cannot run in: a run checks what `resolve` returns. */
557
557
  function assertSandboxCredentials<TParams extends ParamsConfig>(
558
558
  sandboxes: SandboxFactory<TParams> | undefined
559
559
  ): void {
@@ -6,10 +6,10 @@ Factories define environments; threads retain immutable parameters; runs provide
6
6
  Dynamic recipes require an execution-resolved environment; providers never invoke resolvers.
7
7
  - Selection and validation happen before provisioning. Initial source access must be allowed by
8
8
  the session network policy. Creation runs setup once; resume never replays it.
9
- - One rule decides whether source access can work (`sandboxCredentialIssue` in
10
- [configuration](./configuration.ts)): write access needs `auth`, and `auth` a provider with
11
- `supportsRequestCredentials`, even for a recipe without a source. `SixbHost` applies it to the
12
- factory's static recipe at construction. The worker applies it again to each recipe a run
9
+ - One rule decides whether an agent can run in a factory's sandboxes (`sandboxCredentialIssue` in
10
+ [configuration](./configuration.ts)): the provider must have `supportsRequestCredentials`, since
11
+ the run's token is one of the credentials, and write access needs `auth`. `SixbHost` applies it
12
+ to the factory and its static recipe at construction. The worker applies it again to each recipe a run
13
13
  resolves: `resolve` results are unknown at startup, and a worker host is structural.
14
14
  - Runs without a thread binding explicitly select `{}`; shared env/network defaults remain session
15
15
  settings, not an implicit project binding. Unsupported provider capabilities fail explicitly.
@@ -49,14 +49,25 @@ Vercel requests can outlive their worker: storage fencing cannot cancel provider
49
49
  Uncertain sandboxes stay blocked; explicit recreation uses a new name without deleting old state.
50
50
  Saved files remain subject to provider retention.
51
51
 
52
- Source `auth` stays host-side. Providers advertising `supportsRequestCredentials` must apply
53
- execution-prepared credentials; direct create/resume never invoke `auth` implicitly. They apply
52
+ Source `auth` stays host-side. Providers advertising `supportsRequestCredentials`, as every
53
+ agent's provider must, apply execution-prepared credentials; direct create/resume never invoke `auth` implicitly. They apply
54
54
  initial credentials before setup and expose session-scoped renewal, for ephemeral and named
55
55
  sandboxes alike. Unsupported providers reject credentials before provisioning. During initial
56
56
  provisioning/setup, the worker aborts before token expiry if no session handle is available yet;
57
57
  renewal begins after acquisition. Normal teardown removes injection and revokes grants. A crash
58
58
  cannot guarantee immediate revocation.
59
59
 
60
+ Such a provider's sandboxes also give `credentialedUrl(url)`: the address guest commands use to
61
+ reach `url` with the session's credentials added out of its reach. A provider whose firewall adds
62
+ them returns `url` itself; one that forwards on the host returns its own address, such as
63
+ `unix:/tmp/…/0.sock`, which reaches only `url`. The worker adds every run's own token for the Sixb
64
+ API this way, beside a source's credentials, so the run's commands never hold it.
65
+ A VM guest does the same from inside: its commands run as an unprivileged user and a root forwarder
66
+ holds the credentials (`guestCredentialsCommands`, `unprivilegedGuestArgv`), as smolvm and Apple
67
+ Container do. `runSandboxCredentialsContractSuite` in `@sixb/core/testing` is the contract: a command reaches the
68
+ origin with the credential added, only matching requests get it, replacing it takes effect, and
69
+ nothing a command can read (its env, process lists, `/proc`, its files) holds it.
70
+
60
71
  A grant may also carry a guest-readable `env` (identities, placeholders), validated like recipe
61
72
  `env` before provisioning; an invalid one fails authentication. It applies on creation and resume
62
73
  under the recipe's own `env`. Only the first grant of a run is read: the session environment
@@ -139,7 +139,7 @@ export function createSandboxDefinition<TParams extends ParamsConfig>(
139
139
  })
140
140
  }
141
141
 
142
- /** What the source access rule reads: the provider's capability and one recipe's source. */
142
+ /** What the credential rule reads: the provider's capability and one recipe's source. */
143
143
  interface SandboxCredentialRuleInput {
144
144
  readonly supportsRequestCredentials?: boolean
145
145
  /** The factory's source auth; it applies to every recipe the factory resolves. */
@@ -148,22 +148,20 @@ interface SandboxCredentialRuleInput {
148
148
  }
149
149
 
150
150
  /**
151
- * Why a recipe cannot get the source access it declares, as a whole message, or undefined.
151
+ * Why an agent's sandbox cannot run, as a whole message, or undefined.
152
152
  *
153
- * Write access needs source auth. Source auth needs a provider that injects request credentials
154
- * outside the sandbox, even for a recipe without a source: auth is the factory's, so startup and
155
- * every run give the same answer. Source auth without a source is otherwise fine; that recipe
156
- * does not use it.
153
+ * The provider must add request credentials outside the sandbox: the run's token for the Sixb
154
+ * API is one, so the agent's commands never hold it. Write access to a source needs source auth.
157
155
  */
158
156
  export function sandboxCredentialIssue(input: SandboxCredentialRuleInput): string | undefined {
159
157
  const { supportsRequestCredentials, auth, source } = input
160
158
 
159
+ if (!supportsRequestCredentials) {
160
+ return "Agent sandboxes need a provider that adds request credentials outside the sandbox, so the agent's commands never hold its token: use a provider whose factory sets supportsRequestCredentials, such as @sixb/sandboxes-local or @sixb/sandboxes-vercel."
161
+ }
161
162
  if (source?.access === "write" && auth === undefined) {
162
163
  return 'Sandbox write access needs source auth: add auth to the sandbox factory or use access "read".'
163
164
  }
164
- if (auth !== undefined && !supportsRequestCredentials) {
165
- return "Sandbox source auth needs a provider that injects request credentials outside the sandbox: use @sixb/sandboxes-vercel, or remove auth."
166
- }
167
165
 
168
166
  return undefined
169
167
  }
@@ -64,6 +64,7 @@ export function sandboxProjectDirectory(session: Sandbox, hasSource: boolean): S
64
64
  ...(session.setRequestCredentials
65
65
  ? { setRequestCredentials: session.setRequestCredentials.bind(session) }
66
66
  : {}),
67
+ ...(session.credentialedUrl ? { credentialedUrl: session.credentialedUrl.bind(session) } : {}),
67
68
  runCommand: (command, args, options) =>
68
69
  session.runCommand(command, args, { ...options, cwd: options?.cwd ?? workingDirectory }),
69
70
  writeFiles: (files) =>
@@ -13,9 +13,11 @@ const DEFAULT_KILL_EXIT_CODE = 137
13
13
  /**
14
14
  * Spawn a child process and gather its {@link CommandResult}. Wraps Bun.spawn with timeout and
15
15
  * AbortSignal handling, and never throws. Command-agnostic: the wrapper makes no assumptions about
16
- * what it spawns, so sandbox providers share it. On timeout/abort it SIGKILLs the spawned process;
17
- * any provider whose spawned process merely fronts a longer-lived resource (e.g. a VM) is
18
- * responsible for reaping that resource in its own stop()/destroy().
16
+ * what it spawns, so sandbox providers share it. On timeout/abort it SIGKILLs the spawned process
17
+ * and everything it started: the command runs in a process group of its own, so a shell's child
18
+ * that still holds its output can't keep the call open. Any provider whose spawned process merely
19
+ * fronts a longer-lived resource (e.g. a VM) is responsible for reaping that resource in its own
20
+ * stop()/destroy().
19
21
  */
20
22
  export async function exec(options: ExecOptions): Promise<CommandResult> {
21
23
  const start = Date.now()
@@ -38,6 +40,7 @@ export async function exec(options: ExecOptions): Promise<CommandResult> {
38
40
  stdin: "ignore",
39
41
  stdout: "pipe",
40
42
  stderr: "pipe",
43
+ detached: true,
41
44
  })
42
45
  } catch (error) {
43
46
  return {
@@ -50,21 +53,26 @@ export async function exec(options: ExecOptions): Promise<CommandResult> {
50
53
 
51
54
  let timedOut = false
52
55
  let killed = false
56
+ const kill = (): void => {
57
+ killed = true
58
+ try {
59
+ process.kill(-proc.pid, "SIGKILL")
60
+ } catch {
61
+ // The group is gone: the command and everything it started already exited.
62
+ proc.kill("SIGKILL")
63
+ }
64
+ }
53
65
 
54
66
  const timer =
55
67
  options.timeoutMs !== undefined && options.timeoutMs > 0
56
68
  ? setTimeout(() => {
57
69
  timedOut = true
58
- killed = true
59
- proc.kill("SIGKILL")
70
+ kill()
60
71
  }, options.timeoutMs)
61
72
  : undefined
62
73
 
63
74
  const onAbort = (): void => {
64
- if (!killed) {
65
- killed = true
66
- proc.kill("SIGKILL")
67
- }
75
+ if (!killed) kill()
68
76
  }
69
77
  options.signal?.addEventListener("abort", onAbort)
70
78
  if (options.signal?.aborted) {
@@ -0,0 +1,262 @@
1
+ import { createHash } from "node:crypto"
2
+ import type { SandboxRequestCredential } from "./sandbox"
3
+
4
+ // A VM guest adds request credentials the way the host-side providers do, from inside the guest:
5
+ // its commands run as an unprivileged user, and a forwarder running as root holds the
6
+ // credentials. They reach the guest in the environment of a root process, which only root may
7
+ // read, never in arguments, which any process may. What the commands can read holds none of
8
+ // them: their own env and files, other processes' arguments, and the root-only state below.
9
+
10
+ /** The user a guest's commands run as: they cannot read what root holds. */
11
+ export const GUEST_COMMAND_UID = 65534
12
+
13
+ /** Where a guest's forwarder state lives. */
14
+ export interface GuestCredentialPaths {
15
+ /** Root-only: the credentials, the forwarder program and its pid. */
16
+ readonly state: string
17
+ /** World-traversable: one socket per credential origin, which commands connect to. */
18
+ readonly sockets: string
19
+ }
20
+
21
+ /** Under /var/lib: a guest may give each exec its own /run and /tmp. */
22
+ export const GUEST_CREDENTIAL_PATHS: GuestCredentialPaths = {
23
+ state: "/var/lib/sixb-credentials",
24
+ sockets: "/var/lib/sixb-forward",
25
+ }
26
+
27
+ /** The env entry that carries the credentials: pass it out of the provider's own arguments. */
28
+ export const GUEST_CREDENTIALS_ENV = "SIXB_GUEST_CREDENTIALS"
29
+
30
+ /** The install step's exit status when no forwarder runs yet: run the start step. */
31
+ export const GUEST_FORWARDER_NOT_RUNNING = 10
32
+
33
+ /** A command a provider runs in the guest as root. */
34
+ export interface GuestCommand {
35
+ readonly argv: readonly string[]
36
+ readonly env: Readonly<Record<string, string>>
37
+ }
38
+
39
+ /**
40
+ * How a provider installs credentials in a guest, all as root:
41
+ * 1. `install` writes the credentials and the forwarder from its env, and has a running forwarder
42
+ * reload. It exits {@link GUEST_FORWARDER_NOT_RUNNING} when none runs, 3 without Bun or Node.
43
+ * 2. `start`, only then, runs the forwarder detached, so it outlives the exec that started it.
44
+ * 3. `ready` waits until every credential origin's socket exists (exit 4 after five seconds).
45
+ *
46
+ * A provider that writes root-only files without passing their contents in arguments may write
47
+ * `files` instead, in the root-only `state` directory, and run `install` without the env entries
48
+ * that carry them: it writes only what its env holds.
49
+ */
50
+ export interface GuestCredentialsCommands {
51
+ readonly install: GuestCommand
52
+ readonly start: GuestCommand
53
+ readonly ready: GuestCommand
54
+ readonly files: readonly {
55
+ readonly path: string
56
+ readonly contents: string
57
+ readonly mode: number
58
+ }[]
59
+ /** The env entries of `install` that carry the files' contents. */
60
+ readonly fileEnv: readonly string[]
61
+ }
62
+
63
+ /**
64
+ * Run a guest command as {@link GUEST_COMMAND_UID}, with no way back to root: no groups, no
65
+ * capabilities, and no new privileges from a setuid program.
66
+ */
67
+ export function unprivilegedGuestArgv(command: string, args: readonly string[]): string[] {
68
+ return [
69
+ "setpriv",
70
+ `--reuid=${GUEST_COMMAND_UID}`,
71
+ `--regid=${GUEST_COMMAND_UID}`,
72
+ "--clear-groups",
73
+ "--no-new-privs",
74
+ "--bounding-set=-all",
75
+ "--inh-caps=-all",
76
+ "--ambient-caps=-all",
77
+ "--",
78
+ command,
79
+ ...args,
80
+ ]
81
+ }
82
+
83
+ /** The guest socket that reaches `url`'s origin with the credential that matches a request. */
84
+ export function guestCredentialedUrl(
85
+ url: string,
86
+ paths: GuestCredentialPaths = GUEST_CREDENTIAL_PATHS
87
+ ): string {
88
+ return `unix:${guestSocketPath(new URL(url).origin, paths)}`
89
+ }
90
+
91
+ /** The commands that install `credentials` in a guest; see {@link GuestCredentialsCommands}. */
92
+ export function guestCredentialsCommands(
93
+ credentials: readonly SandboxRequestCredential[],
94
+ paths: GuestCredentialPaths = GUEST_CREDENTIAL_PATHS
95
+ ): GuestCredentialsCommands {
96
+ const program = `(${guestForwarder.toString()})(${JSON.stringify(paths)})\n`
97
+ const sockets = [...new Set(credentials.map((credential) => credential.origin))].map((origin) =>
98
+ guestSocketPath(origin, paths)
99
+ )
100
+ const where = { SIXB_GUEST_STATE: paths.state, SIXB_GUEST_SOCKETS: paths.sockets }
101
+ return {
102
+ install: {
103
+ argv: ["sh", "-c", INSTALL_SCRIPT],
104
+ env: {
105
+ ...where,
106
+ [GUEST_CREDENTIALS_ENV]: JSON.stringify(credentials),
107
+ SIXB_GUEST_FORWARDER: Buffer.from(program).toString("base64"),
108
+ },
109
+ },
110
+ start: {
111
+ argv: ["sh", "-c", START_SCRIPT, "sh", `${paths.state}/forwarder.mjs`],
112
+ env: {},
113
+ },
114
+ ready: {
115
+ argv: ["sh", "-c", READY_SCRIPT],
116
+ env: { SIXB_GUEST_EXPECTED_SOCKETS: sockets.join(" ") },
117
+ },
118
+ files: [
119
+ {
120
+ path: `${paths.state}/credentials.json`,
121
+ contents: JSON.stringify(credentials),
122
+ mode: 0o600,
123
+ },
124
+ { path: `${paths.state}/forwarder.mjs`, contents: program, mode: 0o600 },
125
+ ],
126
+ fileEnv: [GUEST_CREDENTIALS_ENV, "SIXB_GUEST_FORWARDER"],
127
+ }
128
+ }
129
+
130
+ function guestSocketPath(origin: string, paths: GuestCredentialPaths): string {
131
+ return `${paths.sockets}/${createHash("sha256").update(origin).digest("hex").slice(0, 16)}.sock`
132
+ }
133
+
134
+ const INSTALL_SCRIPT = `set -eu
135
+ umask 077
136
+ state="$SIXB_GUEST_STATE"
137
+ mkdir -p "$state" "$SIXB_GUEST_SOCKETS"
138
+ chmod 700 "$state"
139
+ chmod 755 "$SIXB_GUEST_SOCKETS"
140
+ if [ "\${${GUEST_CREDENTIALS_ENV}+set}" = set ]; then
141
+ printf '%s' "$${GUEST_CREDENTIALS_ENV}" > "$state/credentials.json.next"
142
+ mv "$state/credentials.json.next" "$state/credentials.json"
143
+ fi
144
+ if [ -n "\${SIXB_GUEST_FORWARDER:-}" ]; then
145
+ printf '%s' "$SIXB_GUEST_FORWARDER" | base64 -d > "$state/forwarder.mjs"
146
+ fi
147
+ pid=$(cat "$state/forwarder.pid" 2>/dev/null || true)
148
+ if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
149
+ kill -HUP "$pid"
150
+ exit 0
151
+ fi
152
+ command -v bun >/dev/null 2>&1 || command -v node >/dev/null 2>&1 || exit 3
153
+ exit ${GUEST_FORWARDER_NOT_RUNNING}`
154
+
155
+ // The system bundle as Node's extra CAs: a guest whose egress is inspected signs with its own CA.
156
+ const START_SCRIPT = `[ ! -f /etc/ssl/certs/ca-certificates.crt ] ||
157
+ export NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt
158
+ exec "$(command -v bun || command -v node)" "$1"`
159
+
160
+ const READY_SCRIPT = `set -eu
161
+ for socket in $SIXB_GUEST_EXPECTED_SOCKETS; do
162
+ tries=0
163
+ while [ ! -S "$socket" ]; do
164
+ tries=$((tries + 1))
165
+ [ "$tries" -le 100 ] || exit 4
166
+ sleep 0.05
167
+ done
168
+ done`
169
+
170
+ /**
171
+ * The guest's forwarder, run as root by Bun or Node from its own source: everything it uses is
172
+ * inside it. It opens a socket for each credential's origin, and forwards what a command sends
173
+ * there to that origin alone, with the credential the request matches. It reads the credentials
174
+ * on every request, so a new list applies at once; SIGHUP opens sockets for new origins.
175
+ */
176
+ export async function guestForwarder(paths: GuestCredentialPaths): Promise<void> {
177
+ const { createServer } = await import("node:http")
178
+ const { chmodSync, readFileSync, rmSync, writeFileSync } = await import("node:fs")
179
+ const { createHash } = await import("node:crypto")
180
+ const { Readable } = await import("node:stream")
181
+
182
+ type Credential = {
183
+ readonly origin: string
184
+ readonly path: string | { readonly prefix: string }
185
+ readonly method: string | readonly string[]
186
+ readonly headers: { readonly Authorization: string }
187
+ }
188
+ const load = (): readonly Credential[] =>
189
+ JSON.parse(readFileSync(`${paths.state}/credentials.json`, "utf8"))
190
+ const socketFor = (origin: string) =>
191
+ `${paths.sockets}/${createHash("sha256").update(origin).digest("hex").slice(0, 16)}.sock`
192
+ const matches = (credential: Credential, method: string, target: URL) => {
193
+ const methods = typeof credential.method === "string" ? [credential.method] : credential.method
194
+ if (target.origin !== credential.origin || !methods.includes(method)) return false
195
+ return typeof credential.path === "string"
196
+ ? target.pathname === credential.path
197
+ : target.pathname.startsWith(credential.path.prefix)
198
+ }
199
+ // Not forwarded either way: the connection's own, what fetch has already decoded, and whom the
200
+ // request is from, which the API trusts from a proxy on its network and a command must not say.
201
+ const skipped = new Set([
202
+ "connection",
203
+ "keep-alive",
204
+ "transfer-encoding",
205
+ "content-length",
206
+ "content-encoding",
207
+ "host",
208
+ "forwarded",
209
+ "x-forwarded-for",
210
+ "x-forwarded-host",
211
+ "x-forwarded-proto",
212
+ "x-real-ip",
213
+ ])
214
+
215
+ const servers = new Map<string, ReturnType<typeof createServer>>()
216
+ const open = () => {
217
+ for (const { origin } of load()) {
218
+ if (servers.has(origin)) continue
219
+ const socket = socketFor(origin)
220
+ rmSync(socket, { force: true })
221
+ const server = createServer(async (request, response) => {
222
+ try {
223
+ // Its path alone: a request in absolute form, or for `//host`, names another host.
224
+ const requested = new URL(request.url ?? "/", "http://guest.invalid")
225
+ const target = new URL(`${origin}${requested.pathname}${requested.search}`)
226
+ const method = (request.method ?? "GET").toUpperCase()
227
+ const headers = new Headers()
228
+ for (const [name, value] of Object.entries(request.headers)) {
229
+ if (value === undefined || skipped.has(name)) continue
230
+ headers.set(name, Array.isArray(value) ? value.join(", ") : value)
231
+ }
232
+ const credential = load().find((candidate) => matches(candidate, method, target))
233
+ if (credential) headers.set("authorization", credential.headers.Authorization)
234
+ const upstream = await fetch(target, {
235
+ method,
236
+ headers,
237
+ redirect: "manual",
238
+ ...(method === "GET" || method === "HEAD"
239
+ ? {}
240
+ : { body: Readable.toWeb(request) as unknown as BodyInit, duplex: "half" }),
241
+ } as RequestInit)
242
+ const out: Record<string, string> = {}
243
+ upstream.headers.forEach((value, name) => {
244
+ if (!skipped.has(name)) out[name] = value
245
+ })
246
+ response.writeHead(upstream.status, out)
247
+ if (upstream.body) for await (const chunk of upstream.body) response.write(chunk)
248
+ response.end()
249
+ } catch {
250
+ if (!response.headersSent) response.writeHead(502)
251
+ response.end()
252
+ }
253
+ })
254
+ server.listen(socket, () => chmodSync(socket, 0o666))
255
+ servers.set(origin, server)
256
+ }
257
+ }
258
+ process.on("SIGHUP", open)
259
+ open()
260
+ // Root-only, like the rest of the state: the install step signals this process to reload.
261
+ writeFileSync(`${paths.state}/forwarder.pid`, String(process.pid), { mode: 0o600 })
262
+ }
@@ -21,6 +21,20 @@ export {
21
21
  } from "./errors"
22
22
  export type { ExecOptions } from "./exec"
23
23
  export { exec } from "./exec"
24
+ export type {
25
+ GuestCommand,
26
+ GuestCredentialPaths,
27
+ GuestCredentialsCommands,
28
+ } from "./guest-credentials"
29
+ export {
30
+ GUEST_COMMAND_UID,
31
+ GUEST_CREDENTIAL_PATHS,
32
+ GUEST_CREDENTIALS_ENV,
33
+ GUEST_FORWARDER_NOT_RUNNING,
34
+ guestCredentialedUrl,
35
+ guestCredentialsCommands,
36
+ unprivilegedGuestArgv,
37
+ } from "./guest-credentials"
24
38
  export type {
25
39
  CommandResult,
26
40
  CreateSandboxOptions,
@@ -82,7 +82,10 @@ export interface SandboxNetworkTarget {
82
82
  export type SandboxRequestMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE"
83
83
 
84
84
  /**
85
- * Host-only credentials injected outside the guest into matching HTTPS requests.
85
+ * Credentials injected into matching requests where guest commands can't reach them. Guest
86
+ * commands never hold them: not in env, files, process arguments or anything else they can read.
87
+ * A firewall or a host forwarder keeps them outside the guest; a VM guest may keep them in files
88
+ * only its root forwarder reads, while its commands run as an unprivileged user.
86
89
  *
87
90
  * A credential selects which requests receive its Authorization header. It does not decide what
88
91
  * the guest can reach, which is the network policy, nor which resources the token can act on:
@@ -90,7 +93,8 @@ export type SandboxRequestMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE"
90
93
  *
91
94
  * Providers apply the same rules so that a credential means the same thing everywhere:
92
95
  * - `origin` is one `https://` domain: no port, path, user info, IP address, loopback host or
93
- * `*` wildcard.
96
+ * `*` wildcard. A provider whose credentials are added on the host it runs on, rather than at a
97
+ * remote egress, may also accept an `http://` origin, such as a local development API.
94
98
  * - A path is matched case-sensitively against the raw request path. It starts with a single
95
99
  * "/" and is printable ASCII without spaces, control characters, "?", "#", "%", "\\", or "."
96
100
  * and ".." segments. A prefix also ends with "/", so it stops at a segment boundary.
@@ -141,7 +145,7 @@ export interface Sandbox {
141
145
  readonly workingDirectory: string
142
146
 
143
147
  /** Optional secure injection capability. Replaces all credentials on this session only.
144
- * An empty list removes injection. Secrets must never enter guest files, env or snapshots.
148
+ * An empty list removes injection. Guest commands must never be able to read a secret.
145
149
  * Must not resume a stopped session or change defaults inherited by future sessions.
146
150
  * Renewal, ephemeral or persistent, targets the handle's session; after stop() it rejects.
147
151
  * A thrown error is reported to onError: it and its causes must never contain a credential.
@@ -150,6 +154,14 @@ export interface Sandbox {
150
154
  credentials: readonly SandboxRequestCredential[]
151
155
  ) => Promise<void>
152
156
 
157
+ /**
158
+ * The address guest commands use to reach `url` with this session's request credentials added
159
+ * out of their reach. It is `url` itself where a firewall adds them, or another address, such as
160
+ * `unix:/path/to.sock`, that forwards only to `url`. Present on every sandbox of a factory that
161
+ * advertises `supportsRequestCredentials`.
162
+ */
163
+ readonly credentialedUrl?: (url: string) => string
164
+
153
165
  runCommand(
154
166
  command: string,
155
167
  args?: readonly string[],
@@ -188,7 +200,10 @@ export interface Sandbox {
188
200
  * Credentials and current authority must be supplied again, never inferred from saved files.
189
201
  */
190
202
  export interface SandboxFactory<in out TParams extends ParamsConfig = ParamsConfig> {
191
- /** Supports initial and renewable host-only credentials on ephemeral and named sessions. */
203
+ /**
204
+ * Supports initial and renewable request credentials on ephemeral and named sessions. An
205
+ * agent's sandboxes need it: the run's token for the Sixb API is one of the credentials.
206
+ */
192
207
  readonly supportsRequestCredentials?: boolean
193
208
  /** Common host-side environment recipe. Never a discovered Agent definition. */
194
209
  readonly configuration?: SandboxConfig<TParams>
@@ -22,12 +22,15 @@ import {
22
22
  assertAgentContextCheckpointReplayState,
23
23
  assertAgentRunExecution,
24
24
  assertAgentRunFinishPayload,
25
+ assertAssignableComputer,
25
26
  assertAwaitingApprovalFinish,
27
+ assertComputerId,
26
28
  assertConversationAgentRunSpec,
27
29
  assertConversationThreadRow,
28
30
  assertCreateAgentContextCheckpointInput,
29
31
  assertCreateSubagentRunInput,
30
32
  assertRequestAgentApprovalInput,
33
+ assertRunsOn,
31
34
  assertSaveAgentMemoryInput,
32
35
  assertSubagentThreadTakesRun,
33
36
  compareAgentMemoryPaths,
@@ -68,6 +71,7 @@ import type {
68
71
  AgentThreadSandboxState,
69
72
  AgentThreadStore,
70
73
  AppendAgentMessageInput,
74
+ AssignAgentThreadComputerInput,
71
75
  ConfirmAgentRunExecutionOwnershipInput,
72
76
  ConversationAgentRunRecord,
73
77
  CreateAgentContextCheckpointInput,
@@ -98,6 +102,7 @@ import type {
98
102
  RemoveAgentThreadParticipantInput,
99
103
  RequestAgentApprovalInput,
100
104
  RequestAgentApprovalResult,
105
+ RequestAgentRunCancelInput,
101
106
  SaveAgentMemoryInput,
102
107
  SaveAgentMemoryResult,
103
108
  SettleAgentApprovalsInput,
@@ -212,6 +217,7 @@ class InMemoryAgentThreadStore implements AgentThreadStore {
212
217
  }
213
218
 
214
219
  async create(input: CreateAgentThreadInput): Promise<AgentThreadRecord> {
220
+ assertRunsOn(input.runsOn, "Agent thread")
215
221
  const sandboxParams =
216
222
  input.sandboxParams === undefined
217
223
  ? undefined
@@ -232,6 +238,7 @@ class InMemoryAgentThreadStore implements AgentThreadStore {
232
238
  ownerPrincipal: clone(input.ownerPrincipal),
233
239
  ...(sandboxParams === undefined ? {} : { sandboxParams }),
234
240
  ...(input.title === undefined ? {} : { title: input.title }),
241
+ ...(input.runsOn === undefined ? {} : { runsOn: input.runsOn }),
235
242
  status: input.status ?? "active",
236
243
  activeRunId: null,
237
244
  messageCount: 0,
@@ -410,6 +417,18 @@ class InMemoryAgentThreadStore implements AgentThreadStore {
410
417
  return true
411
418
  }
412
419
 
420
+ async assignComputer(input: AssignAgentThreadComputerInput): Promise<AgentThreadRecord> {
421
+ assertComputerId(input.computerId)
422
+ const threadKey = key(input.projectId, input.id)
423
+ const thread = this.state.threads.get(threadKey) ?? null
424
+ assertAssignableComputer(thread, input.id)
425
+ if (input.ifUnassigned && thread.computerId !== undefined) return clone(thread)
426
+
427
+ const assigned = { ...thread, computerId: input.computerId }
428
+ this.state.threads.set(threadKey, assigned)
429
+ return clone(assigned)
430
+ }
431
+
413
432
  async listParticipants(
414
433
  input: ListAgentThreadParticipantsInput
415
434
  ): Promise<readonly AgentThreadParticipantRecord[]> {
@@ -672,6 +691,13 @@ class InMemoryAgentRunStore implements AgentRunStore {
672
691
 
673
692
  async reclaim(input: ReclaimAgentRunInput): Promise<AgentRunRecord> {
674
693
  const run = this.requireRunning(input.projectId, input.id)
694
+ if (
695
+ input.ifLapsedBy &&
696
+ run.execution &&
697
+ run.execution.queueLeaseExpiresAt.getTime() > input.ifLapsedBy.getTime()
698
+ ) {
699
+ throw leaseStillHeld(input.id)
700
+ }
675
701
  const next: AgentRunRecord = {
676
702
  ...run,
677
703
  attempt: run.attempt + 1,
@@ -705,6 +731,17 @@ class InMemoryAgentRunStore implements AgentRunStore {
705
731
  return clone(next)
706
732
  }
707
733
 
734
+ async requestCancel(input: RequestAgentRunCancelInput): Promise<AgentRunRecord> {
735
+ const run = this.state.runs.get(key(input.projectId, input.id))
736
+ if (!run) {
737
+ throw new AgentStorageError("run_not_found", `[Sixb] Agent run '${input.id}' was not found.`)
738
+ }
739
+ if (run.status !== "running" || run.cancelRequestedAt) return clone(run)
740
+ const next: AgentRunRecord = { ...run, cancelRequestedAt: input.at ?? new Date() }
741
+ this.state.runs.set(key(input.projectId, input.id), clone(next))
742
+ return clone(next)
743
+ }
744
+
708
745
  async finish(input: FinishAgentRunInput): Promise<AgentRunRecord> {
709
746
  const run = this.requireRunning(input.projectId, input.id)
710
747
  if (!run.execution || run.execution.token !== input.executionToken) {
@@ -950,6 +987,15 @@ class InMemoryAgentMessageStore implements AgentMessageStore {
950
987
  }
951
988
 
952
989
  async deleteByRunId(input: DeleteAgentMessagesByRunInput): Promise<number> {
990
+ if (input.fence) {
991
+ const owner = this.state.runs.get(key(input.projectId, input.fence.runId))
992
+ if (owner?.status !== "running" || owner.execution?.token !== input.fence.executionToken) {
993
+ throw new AgentStorageError(
994
+ "execution_lost",
995
+ `[Sixb] Execution token is no longer current on agent run '${input.fence.runId}'.`
996
+ )
997
+ }
998
+ }
953
999
  const threadKey = key(input.projectId, input.threadId)
954
1000
  const thread = this.state.threads.get(threadKey)
955
1001
  if (!thread) {
@@ -1604,3 +1650,10 @@ function replace<T>(target: Map<string, T>, source: Map<string, T>): void {
1604
1650
  target.set(k, value)
1605
1651
  }
1606
1652
  }
1653
+
1654
+ function leaseStillHeld(id: string): AgentStorageError {
1655
+ return new AgentStorageError(
1656
+ "invalid_state",
1657
+ `[Sixb] Agent run '${id}' is still held by its runner, whose lease has not lapsed.`
1658
+ )
1659
+ }
@@ -46,6 +46,7 @@ export type {
46
46
  AgentThreadStatus,
47
47
  AgentThreadStore,
48
48
  AppendAgentMessageInput,
49
+ AssignAgentThreadComputerInput,
49
50
  ConfirmAgentRunExecutionOwnershipInput,
50
51
  ConversationAgentRunRecord,
51
52
  ConversationAgentRunSpec,
@@ -77,6 +78,7 @@ export type {
77
78
  RemoveAgentThreadParticipantInput,
78
79
  RequestAgentApprovalInput,
79
80
  RequestAgentApprovalResult,
81
+ RequestAgentRunCancelInput,
80
82
  SaveAgentMemoryInput,
81
83
  SaveAgentMemoryResult,
82
84
  SettleAgentApprovalsInput,