@sixb/core 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (427) hide show
  1. package/dist/actions/index.js +36 -35
  2. package/dist/actions/index.js.map +1 -1
  3. package/dist/actions/validation.d.ts.map +1 -1
  4. package/dist/agents/errors.d.ts +1 -1
  5. package/dist/agents/errors.d.ts.map +1 -1
  6. package/dist/agents/execution.d.ts +17 -2
  7. package/dist/agents/execution.d.ts.map +1 -1
  8. package/dist/agents/index.d.ts +3 -3
  9. package/dist/agents/index.d.ts.map +1 -1
  10. package/dist/agents/index.js +53 -45
  11. package/dist/agents/index.js.map +1 -1
  12. package/dist/agents/model-routing.d.ts +16 -2
  13. package/dist/agents/model-routing.d.ts.map +1 -1
  14. package/dist/agents/request.d.ts +45 -4
  15. package/dist/agents/request.d.ts.map +1 -1
  16. package/dist/agents/run-events.d.ts +4 -0
  17. package/dist/agents/run-events.d.ts.map +1 -1
  18. package/dist/agents/run-session-children.d.ts.map +1 -1
  19. package/dist/agents/run-token.d.ts +6 -0
  20. package/dist/agents/run-token.d.ts.map +1 -1
  21. package/dist/agents/run-turn.d.ts +9 -1
  22. package/dist/agents/run-turn.d.ts.map +1 -1
  23. package/dist/agents/streams/index.d.ts +1 -1
  24. package/dist/agents/streams/index.d.ts.map +1 -1
  25. package/dist/agents/streams/index.js +1 -1
  26. package/dist/agents/streams/internal.d.ts +2 -1
  27. package/dist/agents/streams/internal.d.ts.map +1 -1
  28. package/dist/agents/streams/internal.js +22 -2
  29. package/dist/agents/streams/internal.js.map +1 -1
  30. package/dist/agents/streams/protocol.d.ts +37 -0
  31. package/dist/agents/streams/protocol.d.ts.map +1 -1
  32. package/dist/agents/streams/steps.d.ts +24 -0
  33. package/dist/agents/streams/steps.d.ts.map +1 -0
  34. package/dist/agents/thread-access.d.ts +44 -2
  35. package/dist/agents/thread-access.d.ts.map +1 -1
  36. package/dist/artifacts/live/server.js +19 -18
  37. package/dist/artifacts/live/server.js.map +1 -1
  38. package/dist/artifacts/publish/index.js +18 -17
  39. package/dist/artifacts/publish/index.js.map +1 -1
  40. package/dist/artifacts/publish/merge.d.ts +2 -1
  41. package/dist/artifacts/publish/merge.d.ts.map +1 -1
  42. package/dist/artifacts/run-query.d.ts.map +1 -1
  43. package/dist/auth/index.js +6 -6
  44. package/dist/authorization/index.js +2 -2
  45. package/dist/bootstrap/discovery.d.ts +6 -0
  46. package/dist/bootstrap/discovery.d.ts.map +1 -1
  47. package/dist/bootstrap/index.js +40 -38
  48. package/dist/bootstrap/index.js.map +2 -2
  49. package/dist/calendar.d.ts +55 -0
  50. package/dist/calendar.d.ts.map +1 -0
  51. package/dist/calendar.js +19 -0
  52. package/dist/calendar.js.map +9 -0
  53. package/dist/chunk-04r2fdsd.js +386 -0
  54. package/dist/chunk-04r2fdsd.js.map +14 -0
  55. package/dist/{chunk-gjhrz66x.js → chunk-06kpaqg4.js} +248 -21
  56. package/dist/{chunk-gjhrz66x.js.map → chunk-06kpaqg4.js.map} +6 -6
  57. package/dist/{chunk-5a4a52tq.js → chunk-0pmpwn3g.js} +18 -2
  58. package/dist/chunk-0pmpwn3g.js.map +10 -0
  59. package/dist/{chunk-nxysqbt0.js → chunk-389ybvw9.js} +6 -2
  60. package/dist/chunk-389ybvw9.js.map +10 -0
  61. package/dist/{chunk-xcrnrpfh.js → chunk-394zjzjs.js} +20 -10
  62. package/dist/{chunk-xcrnrpfh.js.map → chunk-394zjzjs.js.map} +5 -5
  63. package/dist/{chunk-stmxh0hv.js → chunk-3neam1y5.js} +2 -2
  64. package/dist/{chunk-zeykm8my.js → chunk-3qtk0070.js} +16 -42
  65. package/dist/chunk-3qtk0070.js.map +14 -0
  66. package/dist/{chunk-0hkdtwqk.js → chunk-44hrfmbk.js} +5 -5
  67. package/dist/{chunk-ey1p8w68.js → chunk-5pz3htbe.js} +86 -5
  68. package/dist/chunk-5pz3htbe.js.map +13 -0
  69. package/dist/{chunk-s5pj68fa.js → chunk-5sswe5ej.js} +2 -2
  70. package/dist/{chunk-k3jh8gsg.js → chunk-5xkqasvn.js} +21 -4
  71. package/dist/chunk-5xkqasvn.js.map +10 -0
  72. package/dist/{chunk-5t9gm5tt.js → chunk-6md802cc.js} +38 -14
  73. package/dist/chunk-6md802cc.js.map +22 -0
  74. package/dist/{chunk-3zagkr6w.js → chunk-7mhbs9yy.js} +4 -4
  75. package/dist/{chunk-3zagkr6w.js.map → chunk-7mhbs9yy.js.map} +1 -1
  76. package/dist/{chunk-ewqn51gr.js → chunk-88xeh6zx.js} +6 -4
  77. package/dist/{chunk-ewqn51gr.js.map → chunk-88xeh6zx.js.map} +4 -4
  78. package/dist/{chunk-z1njfqqs.js → chunk-8qmp9fpa.js} +783 -171
  79. package/dist/{chunk-z1njfqqs.js.map → chunk-8qmp9fpa.js.map} +13 -13
  80. package/dist/{chunk-r2psmn42.js → chunk-95ps0k5q.js} +3 -3
  81. package/dist/{chunk-r2psmn42.js.map → chunk-95ps0k5q.js.map} +3 -3
  82. package/dist/{chunk-fpf57gca.js → chunk-9cyq87qa.js} +276 -68
  83. package/dist/{chunk-fpf57gca.js.map → chunk-9cyq87qa.js.map} +6 -6
  84. package/dist/{chunk-q9nkpr8k.js → chunk-9tpmfh3n.js} +1 -1
  85. package/dist/chunk-9wr3yajk.js.map +2 -2
  86. package/dist/{chunk-naxjka9v.js → chunk-brhp9d97.js} +2 -2
  87. package/dist/{chunk-8a8k38tz.js → chunk-brybqw5k.js} +1 -1
  88. package/dist/{chunk-vehcr9eb.js → chunk-cg7cygfj.js} +1 -1
  89. package/dist/{chunk-b4escq4c.js → chunk-cpy282b8.js} +6 -6
  90. package/dist/chunk-dq3t5sr3.js +114 -0
  91. package/dist/chunk-dq3t5sr3.js.map +11 -0
  92. package/dist/{chunk-68hm50qh.js → chunk-fdk0ks9p.js} +16 -46
  93. package/dist/chunk-fdk0ks9p.js.map +12 -0
  94. package/dist/{chunk-fzae1jpq.js → chunk-fycac8e9.js} +50 -16
  95. package/dist/{chunk-fzae1jpq.js.map → chunk-fycac8e9.js.map} +3 -3
  96. package/dist/{chunk-zft9bzbc.js → chunk-hkbks1xm.js} +2 -1
  97. package/dist/{chunk-zft9bzbc.js.map → chunk-hkbks1xm.js.map} +3 -3
  98. package/dist/{chunk-m3qx2pns.js → chunk-hvq8xs66.js} +28 -12
  99. package/dist/{chunk-m3qx2pns.js.map → chunk-hvq8xs66.js.map} +5 -5
  100. package/dist/{chunk-bc3y6gff.js → chunk-jka26v8c.js} +1 -1
  101. package/dist/{chunk-s1mqyqmm.js → chunk-js9e6487.js} +12 -8
  102. package/dist/chunk-js9e6487.js.map +18 -0
  103. package/dist/{chunk-zxhym8tr.js → chunk-k29rdc3h.js} +1 -1
  104. package/dist/{chunk-rg725hry.js → chunk-m1cwncee.js} +86 -34
  105. package/dist/{chunk-rg725hry.js.map → chunk-m1cwncee.js.map} +8 -8
  106. package/dist/{chunk-1yh6jgtz.js → chunk-mrs7jy17.js} +2 -2
  107. package/dist/{chunk-qavwr628.js → chunk-n1hbwc6y.js} +5 -6
  108. package/dist/chunk-n1hbwc6y.js.map +12 -0
  109. package/dist/{chunk-pqvvqc65.js → chunk-pfdq1ga6.js} +3 -3
  110. package/dist/{chunk-k29n4176.js → chunk-phs5fbff.js} +6 -6
  111. package/dist/{chunk-wqe9shx2.js → chunk-qbd282aa.js} +2 -2
  112. package/dist/{chunk-e91fmg6t.js → chunk-qsa7nw6f.js} +2 -1
  113. package/dist/{chunk-e91fmg6t.js.map → chunk-qsa7nw6f.js.map} +3 -3
  114. package/dist/chunk-r588h4ev.js +98 -0
  115. package/dist/chunk-r588h4ev.js.map +10 -0
  116. package/dist/{chunk-rtdrm592.js → chunk-t58sktr5.js} +12 -4
  117. package/dist/{chunk-rtdrm592.js.map → chunk-t58sktr5.js.map} +3 -3
  118. package/dist/{chunk-paxabbqd.js → chunk-tapdssb5.js} +1 -1
  119. package/dist/{chunk-dhkc9b23.js → chunk-v8a1qjzp.js} +1 -1
  120. package/dist/{chunk-q8d9p0tb.js → chunk-wzcjhv54.js} +8 -1
  121. package/dist/{chunk-q8d9p0tb.js.map → chunk-wzcjhv54.js.map} +3 -3
  122. package/dist/{chunk-pc7kra3k.js → chunk-xavet0qs.js} +1 -1
  123. package/dist/{chunk-m9ketb51.js → chunk-ygvay56w.js} +1 -1
  124. package/dist/{chunk-0mvjpgvm.js → chunk-yyj009tv.js} +4 -4
  125. package/dist/connectors/connections/capability.d.ts +11 -0
  126. package/dist/connectors/connections/capability.d.ts.map +1 -1
  127. package/dist/connectors/connections/internal.d.ts +2 -1
  128. package/dist/connectors/connections/internal.d.ts.map +1 -1
  129. package/dist/connectors/connections/internal.js +8 -4
  130. package/dist/connectors/connections/internal.js.map +1 -1
  131. package/dist/connectors/connections/service.d.ts +9 -1
  132. package/dist/connectors/connections/service.d.ts.map +1 -1
  133. package/dist/connectors/execution.d.ts +7 -1
  134. package/dist/connectors/execution.d.ts.map +1 -1
  135. package/dist/connectors/service.d.ts +5 -1
  136. package/dist/connectors/service.d.ts.map +1 -1
  137. package/dist/deploy/index.d.ts +1 -1
  138. package/dist/deploy/index.d.ts.map +1 -1
  139. package/dist/deploy/internal.js +2 -2
  140. package/dist/deploy/internal.js.map +2 -2
  141. package/dist/deploy/types.d.ts +12 -59
  142. package/dist/deploy/types.d.ts.map +1 -1
  143. package/dist/env/index.d.ts +10 -3
  144. package/dist/env/index.d.ts.map +1 -1
  145. package/dist/env/index.js.map +2 -2
  146. package/dist/events/execution.d.ts +8 -1
  147. package/dist/events/execution.d.ts.map +1 -1
  148. package/dist/events/types/syncs.d.ts +4 -0
  149. package/dist/events/types/syncs.d.ts.map +1 -1
  150. package/dist/execution/agent.js +37 -36
  151. package/dist/execution/agent.js.map +1 -1
  152. package/dist/execution/authorized-object-reader.d.ts +4 -0
  153. package/dist/execution/authorized-object-reader.d.ts.map +1 -1
  154. package/dist/execution/object-reader-ontology.d.ts +3 -0
  155. package/dist/execution/object-reader-ontology.d.ts.map +1 -1
  156. package/dist/execution/primitive.js +36 -35
  157. package/dist/execution/primitive.js.map +1 -1
  158. package/dist/execution/request.d.ts +1 -1
  159. package/dist/execution/request.d.ts.map +1 -1
  160. package/dist/execution/request.js +33 -32
  161. package/dist/execution/request.js.map +3 -3
  162. package/dist/http/api-routes.d.ts.map +1 -1
  163. package/dist/http/index.js +1 -1
  164. package/dist/index.d.ts +7 -7
  165. package/dist/index.d.ts.map +1 -1
  166. package/dist/index.js +63 -59
  167. package/dist/index.js.map +1 -1
  168. package/dist/maintenance/index.js +1 -1
  169. package/dist/materializer/index.js +22 -21
  170. package/dist/materializer/index.js.map +1 -1
  171. package/dist/models/audio/runtime.d.ts.map +1 -1
  172. package/dist/models/audio/types.d.ts +19 -0
  173. package/dist/models/audio/types.d.ts.map +1 -1
  174. package/dist/models/execution/index.js +20 -19
  175. package/dist/models/execution/index.js.map +1 -1
  176. package/dist/models/index.d.ts +1 -1
  177. package/dist/models/index.d.ts.map +1 -1
  178. package/dist/objects/index.js +36 -35
  179. package/dist/objects/index.js.map +1 -1
  180. package/dist/objects/query/executor.d.ts +3 -1
  181. package/dist/objects/query/executor.d.ts.map +1 -1
  182. package/dist/objects/query/explain.d.ts +3 -1
  183. package/dist/objects/query/explain.d.ts.map +1 -1
  184. package/dist/objects/query/index.d.ts +1 -1
  185. package/dist/objects/query/index.d.ts.map +1 -1
  186. package/dist/objects/query/index.js +19 -18
  187. package/dist/objects/query/index.js.map +1 -1
  188. package/dist/objects/query/link-query-clearance.d.ts +3 -0
  189. package/dist/objects/query/link-query-clearance.d.ts.map +1 -1
  190. package/dist/objects/query/links.d.ts +1 -1
  191. package/dist/objects/query/links.d.ts.map +1 -1
  192. package/dist/objects/query/validate.d.ts +17 -0
  193. package/dist/objects/query/validate.d.ts.map +1 -1
  194. package/dist/objects/sdk/runtime-query-executor.d.ts +1 -1
  195. package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
  196. package/dist/ontology/index.js +3 -3
  197. package/dist/ontology/internal.js +3 -3
  198. package/dist/pipelines/index.js +21 -20
  199. package/dist/pipelines/index.js.map +1 -1
  200. package/dist/projections/internal.js +20 -19
  201. package/dist/projections/internal.js.map +1 -1
  202. package/dist/queues/in-memory.d.ts +1 -1
  203. package/dist/queues/in-memory.d.ts.map +1 -1
  204. package/dist/runtime/create.d.ts.map +1 -1
  205. package/dist/runtime/definitions.d.ts +14 -0
  206. package/dist/runtime/definitions.d.ts.map +1 -1
  207. package/dist/runtime/host.d.ts +3 -1
  208. package/dist/runtime/host.d.ts.map +1 -1
  209. package/dist/runtime/index.d.ts +1 -1
  210. package/dist/runtime/index.d.ts.map +1 -1
  211. package/dist/runtime/internal.js +24 -23
  212. package/dist/runtime/internal.js.map +2 -2
  213. package/dist/runtime/locale.d.ts +0 -2
  214. package/dist/runtime/locale.d.ts.map +1 -1
  215. package/dist/runtime/resolve-definitions.d.ts +2 -1
  216. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  217. package/dist/runtime/sixb.d.ts.map +1 -1
  218. package/dist/sandboxes/auth.d.ts +26 -4
  219. package/dist/sandboxes/auth.d.ts.map +1 -1
  220. package/dist/sandboxes/errors.d.ts +19 -0
  221. package/dist/sandboxes/errors.d.ts.map +1 -1
  222. package/dist/sandboxes/exec.d.ts +2 -0
  223. package/dist/sandboxes/exec.d.ts.map +1 -1
  224. package/dist/sandboxes/index.d.ts +4 -2
  225. package/dist/sandboxes/index.d.ts.map +1 -1
  226. package/dist/sandboxes/index.js +13 -7
  227. package/dist/sandboxes/index.js.map +1 -1
  228. package/dist/sandboxes/sandbox.d.ts +15 -1
  229. package/dist/sandboxes/sandbox.d.ts.map +1 -1
  230. package/dist/security/view-conditions.d.ts.map +1 -1
  231. package/dist/shares/internal.js +16 -15
  232. package/dist/shares/internal.js.map +2 -2
  233. package/dist/storage/agents/in-memory.d.ts +18 -1
  234. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  235. package/dist/storage/agents/index.d.ts +1 -1
  236. package/dist/storage/agents/index.d.ts.map +1 -1
  237. package/dist/storage/agents/provider.d.ts +43 -9
  238. package/dist/storage/agents/provider.d.ts.map +1 -1
  239. package/dist/storage/agents/provider.js +19 -3
  240. package/dist/storage/agents/provider.js.map +1 -1
  241. package/dist/storage/agents/types.d.ts +150 -4
  242. package/dist/storage/agents/types.d.ts.map +1 -1
  243. package/dist/storage/ai-cost/analytics.d.ts +3 -2
  244. package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
  245. package/dist/storage/ai-cost/provider.js +4 -3
  246. package/dist/storage/ai-cost/provider.js.map +1 -1
  247. package/dist/storage/ai-cost/types.d.ts +5 -1
  248. package/dist/storage/ai-cost/types.d.ts.map +1 -1
  249. package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
  250. package/dist/storage/artifacts/record.d.ts +3 -1
  251. package/dist/storage/artifacts/record.d.ts.map +1 -1
  252. package/dist/storage/artifacts/types.d.ts +7 -0
  253. package/dist/storage/artifacts/types.d.ts.map +1 -1
  254. package/dist/storage/file-upload-sessions/provider.js +7 -7
  255. package/dist/storage/index.d.ts +2 -2
  256. package/dist/storage/index.d.ts.map +1 -1
  257. package/dist/storage/index.js +23 -22
  258. package/dist/storage/index.js.map +1 -1
  259. package/dist/storage/internal.js +8 -8
  260. package/dist/storage/operation-scope.d.ts.map +1 -1
  261. package/dist/storage/operation-scope.js +1 -1
  262. package/dist/storage/sync-runs/idempotency.d.ts.map +1 -1
  263. package/dist/storage/sync-runs/in-memory.d.ts +2 -1
  264. package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
  265. package/dist/storage/sync-runs/index.d.ts +1 -1
  266. package/dist/storage/sync-runs/index.d.ts.map +1 -1
  267. package/dist/storage/sync-runs/types.d.ts +27 -2
  268. package/dist/storage/sync-runs/types.d.ts.map +1 -1
  269. package/dist/storage/workflow-runs/provider.js +7 -7
  270. package/dist/syncs/accounts.d.ts +36 -0
  271. package/dist/syncs/accounts.d.ts.map +1 -0
  272. package/dist/syncs/builders.d.ts.map +1 -1
  273. package/dist/syncs/connections.d.ts +36 -0
  274. package/dist/syncs/connections.d.ts.map +1 -0
  275. package/dist/syncs/execution.d.ts +14 -4
  276. package/dist/syncs/execution.d.ts.map +1 -1
  277. package/dist/syncs/index.d.ts +2 -1
  278. package/dist/syncs/index.d.ts.map +1 -1
  279. package/dist/syncs/index.js +22 -21
  280. package/dist/syncs/index.js.map +1 -1
  281. package/dist/syncs/request.d.ts +16 -2
  282. package/dist/syncs/request.d.ts.map +1 -1
  283. package/dist/syncs/run-dispatch.d.ts +14 -2
  284. package/dist/syncs/run-dispatch.d.ts.map +1 -1
  285. package/dist/testing/agent-approval-storage-contract.d.ts.map +1 -1
  286. package/dist/testing/agent-inbox-storage-contract.d.ts.map +1 -1
  287. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  288. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
  289. package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
  290. package/dist/testing/index.js +1157 -100
  291. package/dist/testing/index.js.map +9 -9
  292. package/dist/testing/run-claim-storage-contract.d.ts.map +1 -1
  293. package/dist/testing/sandboxes-contract.d.ts.map +1 -1
  294. package/dist/webhooks/internal.js +17 -16
  295. package/dist/webhooks/internal.js.map +2 -2
  296. package/dist/workers/index.js +66 -13
  297. package/dist/workers/index.js.map +4 -4
  298. package/dist/workers/queue-worker.d.ts +5 -0
  299. package/dist/workers/queue-worker.d.ts.map +1 -1
  300. package/dist/workers/worker.d.ts +8 -0
  301. package/dist/workers/worker.d.ts.map +1 -1
  302. package/dist/workflows/index.js +42 -40
  303. package/dist/workflows/index.js.map +1 -1
  304. package/package.json +7 -1
  305. package/src/actions/validation.ts +3 -1
  306. package/src/agents/children.ts +6 -0
  307. package/src/agents/errors.ts +3 -0
  308. package/src/agents/execution.ts +170 -20
  309. package/src/agents/index.ts +5 -0
  310. package/src/agents/model-routing.ts +116 -34
  311. package/src/agents/request.ts +783 -38
  312. package/src/agents/run-events.ts +235 -38
  313. package/src/agents/run-session-children.ts +13 -2
  314. package/src/agents/run-token.ts +7 -0
  315. package/src/agents/run-turn.ts +140 -23
  316. package/src/agents/streams/index.ts +2 -0
  317. package/src/agents/streams/internal.ts +12 -0
  318. package/src/agents/streams/protocol.ts +69 -1
  319. package/src/agents/streams/steps.ts +131 -0
  320. package/src/agents/thread-access.ts +57 -2
  321. package/src/artifacts/publish/merge.ts +14 -3
  322. package/src/artifacts/run-query.ts +5 -2
  323. package/src/bootstrap/discovery.ts +61 -11
  324. package/src/calendar.ts +195 -0
  325. package/src/connectors/connections/capability.ts +40 -0
  326. package/src/connectors/connections/internal.ts +3 -0
  327. package/src/connectors/connections/service.ts +74 -5
  328. package/src/connectors/execution.ts +5 -6
  329. package/src/connectors/service.ts +23 -0
  330. package/src/deploy/index.ts +0 -5
  331. package/src/deploy/types.ts +12 -64
  332. package/src/deploy/validation.ts +1 -1
  333. package/src/env/index.ts +10 -4
  334. package/src/events/execution.ts +42 -2
  335. package/src/events/types/syncs.ts +4 -0
  336. package/src/execution/authorized-object-reader.ts +33 -5
  337. package/src/execution/object-reader-ontology.ts +6 -0
  338. package/src/execution/request.ts +1 -0
  339. package/src/http/api-routes.ts +8 -0
  340. package/src/index.ts +21 -2
  341. package/src/models/audio/runtime.ts +57 -14
  342. package/src/models/audio/types.ts +20 -0
  343. package/src/models/index.ts +1 -0
  344. package/src/objects/query/executor.ts +4 -0
  345. package/src/objects/query/explain.ts +5 -0
  346. package/src/objects/query/index.ts +1 -0
  347. package/src/objects/query/link-query-clearance.ts +4 -1
  348. package/src/objects/query/links.ts +5 -1
  349. package/src/objects/query/validate.ts +33 -1
  350. package/src/objects/sdk/runtime-query-executor.ts +7 -3
  351. package/src/runtime/create.ts +1 -0
  352. package/src/runtime/definitions.ts +25 -0
  353. package/src/runtime/host.ts +16 -8
  354. package/src/runtime/index.ts +6 -1
  355. package/src/runtime/locale.ts +0 -10
  356. package/src/runtime/resolve-definitions.ts +7 -1
  357. package/src/runtime/sixb.ts +12 -2
  358. package/src/sandboxes/README.md +12 -1
  359. package/src/sandboxes/auth.ts +32 -4
  360. package/src/sandboxes/errors.ts +27 -0
  361. package/src/sandboxes/exec.ts +3 -1
  362. package/src/sandboxes/index.ts +18 -1
  363. package/src/sandboxes/sandbox.ts +15 -1
  364. package/src/security/view-conditions.ts +2 -1
  365. package/src/storage/agents/in-memory.ts +271 -6
  366. package/src/storage/agents/index.ts +10 -0
  367. package/src/storage/agents/provider.ts +178 -13
  368. package/src/storage/agents/types.ts +166 -4
  369. package/src/storage/ai-cost/analytics.ts +22 -43
  370. package/src/storage/ai-cost/types.ts +5 -1
  371. package/src/storage/artifacts/in-memory.ts +20 -5
  372. package/src/storage/artifacts/record.ts +8 -2
  373. package/src/storage/artifacts/types.ts +7 -0
  374. package/src/storage/index.ts +11 -0
  375. package/src/storage/operation-scope.ts +1 -0
  376. package/src/storage/sync-runs/idempotency.ts +1 -0
  377. package/src/storage/sync-runs/in-memory.ts +43 -1
  378. package/src/storage/sync-runs/index.ts +1 -0
  379. package/src/storage/sync-runs/types.ts +30 -1
  380. package/src/syncs/accounts.ts +85 -0
  381. package/src/syncs/builders.ts +18 -1
  382. package/src/syncs/connections.ts +123 -0
  383. package/src/syncs/execution.ts +64 -22
  384. package/src/syncs/index.ts +3 -0
  385. package/src/syncs/request.ts +81 -23
  386. package/src/syncs/run-dispatch.ts +69 -7
  387. package/src/testing/agent-approval-storage-contract.ts +123 -0
  388. package/src/testing/agent-inbox-storage-contract.ts +59 -0
  389. package/src/testing/agent-storage-contract.ts +794 -8
  390. package/src/testing/ai-cost-storage-contract.ts +80 -0
  391. package/src/testing/artifact-storage-contract.ts +139 -0
  392. package/src/testing/run-claim-storage-contract.ts +116 -0
  393. package/src/testing/sandboxes-contract.ts +50 -0
  394. package/src/workers/README.md +4 -1
  395. package/src/workers/lost-runs.ts +1 -0
  396. package/src/workers/queue-worker.ts +16 -5
  397. package/src/workers/worker.ts +67 -7
  398. package/dist/chunk-5a4a52tq.js.map +0 -10
  399. package/dist/chunk-5t9gm5tt.js.map +0 -22
  400. package/dist/chunk-68hm50qh.js.map +0 -13
  401. package/dist/chunk-aw1z0gre.js +0 -234
  402. package/dist/chunk-aw1z0gre.js.map +0 -12
  403. package/dist/chunk-ey1p8w68.js.map +0 -13
  404. package/dist/chunk-k3jh8gsg.js.map +0 -10
  405. package/dist/chunk-nxysqbt0.js.map +0 -10
  406. package/dist/chunk-qavwr628.js.map +0 -12
  407. package/dist/chunk-s1mqyqmm.js.map +0 -18
  408. package/dist/chunk-zeykm8my.js.map +0 -14
  409. /package/dist/{chunk-stmxh0hv.js.map → chunk-3neam1y5.js.map} +0 -0
  410. /package/dist/{chunk-0hkdtwqk.js.map → chunk-44hrfmbk.js.map} +0 -0
  411. /package/dist/{chunk-s5pj68fa.js.map → chunk-5sswe5ej.js.map} +0 -0
  412. /package/dist/{chunk-q9nkpr8k.js.map → chunk-9tpmfh3n.js.map} +0 -0
  413. /package/dist/{chunk-naxjka9v.js.map → chunk-brhp9d97.js.map} +0 -0
  414. /package/dist/{chunk-8a8k38tz.js.map → chunk-brybqw5k.js.map} +0 -0
  415. /package/dist/{chunk-vehcr9eb.js.map → chunk-cg7cygfj.js.map} +0 -0
  416. /package/dist/{chunk-b4escq4c.js.map → chunk-cpy282b8.js.map} +0 -0
  417. /package/dist/{chunk-bc3y6gff.js.map → chunk-jka26v8c.js.map} +0 -0
  418. /package/dist/{chunk-zxhym8tr.js.map → chunk-k29rdc3h.js.map} +0 -0
  419. /package/dist/{chunk-1yh6jgtz.js.map → chunk-mrs7jy17.js.map} +0 -0
  420. /package/dist/{chunk-pqvvqc65.js.map → chunk-pfdq1ga6.js.map} +0 -0
  421. /package/dist/{chunk-k29n4176.js.map → chunk-phs5fbff.js.map} +0 -0
  422. /package/dist/{chunk-wqe9shx2.js.map → chunk-qbd282aa.js.map} +0 -0
  423. /package/dist/{chunk-paxabbqd.js.map → chunk-tapdssb5.js.map} +0 -0
  424. /package/dist/{chunk-dhkc9b23.js.map → chunk-v8a1qjzp.js.map} +0 -0
  425. /package/dist/{chunk-pc7kra3k.js.map → chunk-xavet0qs.js.map} +0 -0
  426. /package/dist/{chunk-m9ketb51.js.map → chunk-ygvay56w.js.map} +0 -0
  427. /package/dist/{chunk-0mvjpgvm.js.map → chunk-yyj009tv.js.map} +0 -0
@@ -41,6 +41,8 @@ import type {
41
41
  ConversationAgentRunSpec,
42
42
  CreateAgentContextCheckpointInput,
43
43
  CreateSubagentRunInput,
44
+ DeleteAgentContextCheckpointsAfterSeqInput,
45
+ DeleteAgentMessagesFromSeqInput,
44
46
  EnqueueAgentInboxItemInput,
45
47
  FinishAgentRunInput,
46
48
  ForkAgentThreadInput,
@@ -294,17 +296,37 @@ export interface AgentThreadForkPlan {
294
296
  readonly thread: AgentThreadRecord
295
297
  /** The source messages to copy, in `seq` order, with the id of each copy. */
296
298
  readonly messages: readonly { readonly sourceId: string; readonly id: string }[]
299
+ /** The seq of the last message copied, 0 when none: the copy's newest, as copies keep theirs. */
300
+ readonly headSeq: number
297
301
  readonly checkpoint?: AgentContextCheckpointRecord
298
302
  }
299
303
 
300
- /**
301
- * Decide what a fork copies. While a turn is running, the fork copies what came before its trigger
302
- * message, so the copy never has a gap; otherwise it copies everything. Copies keep their `seq`,
303
- * so the latest checkpoint whose observed head was copied projects unchanged.
304
- *
305
- * The plan mints the ids of the copies: which messages are copied is only known here, under the
306
- * provider's lock, so the caller cannot supply them.
307
- */
304
+ /** `fromSeq` names a message of the thread: sequences start at 1. */
305
+ export function assertDeleteAgentMessagesFromSeqInput(
306
+ input: DeleteAgentMessagesFromSeqInput,
307
+ prefix = "Sixb"
308
+ ): void {
309
+ if (!Number.isSafeInteger(input.fromSeq) || input.fromSeq < 1) {
310
+ throw new AgentStorageError(
311
+ "invalid_input",
312
+ `[${prefix}] Agent message 'fromSeq' must be a positive safe integer.`
313
+ )
314
+ }
315
+ }
316
+
317
+ /** `afterSeq` is the last sequence whose summaries stay: 0 keeps none. */
318
+ export function assertDeleteAgentContextCheckpointsAfterSeqInput(
319
+ input: DeleteAgentContextCheckpointsAfterSeqInput,
320
+ prefix = "Sixb"
321
+ ): void {
322
+ if (!Number.isSafeInteger(input.afterSeq) || input.afterSeq < 0) {
323
+ throw new AgentStorageError(
324
+ "invalid_input",
325
+ `[${prefix}] Agent context checkpoint 'afterSeq' must be a non-negative safe integer.`
326
+ )
327
+ }
328
+ }
329
+
308
330
  /**
309
331
  * Whether a message counts in its thread's `messageCount`, which reads as what the conversation
310
332
  * shows. The message Sixb writes to resume a paused turn carries only how its calls ended, which the
@@ -316,6 +338,32 @@ export function countsAsThreadMessage(message: Pick<AgentMessageRecord, "parts">
316
338
  )
317
339
  }
318
340
 
341
+ /**
342
+ * Whether a message past a reader's place is new to them: every Agent answer and every other
343
+ * person's message. What they wrote themselves is not, and neither is a message the thread does
344
+ * not count. An Agent answer carries its requester as author, so only a user message is theirs.
345
+ * The SQL providers say the same in their `unread` count.
346
+ */
347
+ export function isUnreadFor(
348
+ message: Pick<AgentMessageRecord, "role" | "authorPrincipal" | "parts">,
349
+ reader: UserPrincipal
350
+ ): boolean {
351
+ if (!countsAsThreadMessage(message)) return false
352
+
353
+ const author = message.authorPrincipal
354
+ const ownMessage = message.role === "user" && author?.type === "user" && author.id === reader.id
355
+
356
+ return !ownMessage
357
+ }
358
+
359
+ /**
360
+ * Decide what a fork copies. While a turn is running, the fork copies what came before its trigger
361
+ * message, so the copy never has a gap; otherwise it copies everything. Copies keep their `seq`,
362
+ * so the latest checkpoint whose observed head was copied projects unchanged.
363
+ *
364
+ * The plan mints the ids of the copies: which messages are copied is only known here, under the
365
+ * provider's lock, so the caller cannot supply them.
366
+ */
319
367
  export function planAgentThreadFork(
320
368
  input: ForkAgentThreadInput,
321
369
  source: AgentThreadForkSource,
@@ -360,6 +408,7 @@ export function planAgentThreadFork(
360
408
  return {
361
409
  thread,
362
410
  messages: copied.map((message) => ({ sourceId: message.id, id: createAgentMessageId() })),
411
+ headSeq: lastCopiedSeq,
363
412
  ...(checkpoint === undefined
364
413
  ? {}
365
414
  : {
@@ -466,6 +515,12 @@ export function assertConversationAgentRunSpec(
466
515
  }
467
516
  assertApprovalModeField(spec.approvalMode, "Conversational Agent run", prefix)
468
517
  assertRunsOn(spec.runsOn, "Conversational Agent run", prefix)
518
+ if (spec.computer !== undefined) {
519
+ if (spec.runsOn !== "computer") {
520
+ throw new AgentStorageError("invalid_input", `[${prefix}] Only a computer's turn names one.`)
521
+ }
522
+ assertAgentThreadPlace(spec.computer, prefix)
523
+ }
469
524
  }
470
525
 
471
526
  /** Validate where a thread or turn runs: `computer`, or absent for the cloud. */
@@ -478,6 +533,33 @@ export function assertRunsOn(value: unknown, subject: string, prefix = "Sixb"):
478
533
  }
479
534
  }
480
535
 
536
+ /**
537
+ * Validate which computer and folder a turn ran in. Both are shown back to its owner, so neither
538
+ * holds a control character.
539
+ */
540
+ export function assertAgentThreadPlace(
541
+ value: unknown,
542
+ prefix = "Sixb"
543
+ ): asserts value is AgentThreadPlace {
544
+ const place = value as Partial<AgentThreadPlace> | null
545
+ for (const [field, text, max] of [
546
+ ["id", place?.id, 200],
547
+ ["folder", place?.folder, 4096],
548
+ ] as const) {
549
+ if (
550
+ typeof text !== "string" ||
551
+ text.trim() === "" ||
552
+ text.length > max ||
553
+ CONTROL_CHARACTER.test(text)
554
+ ) {
555
+ throw new AgentStorageError(
556
+ "invalid_input",
557
+ `[${prefix}] A turn's computer '${field}' must be a non-blank string of at most ${max} characters, without control characters.`
558
+ )
559
+ }
560
+ }
561
+ }
562
+
481
563
  /**
482
564
  * Validate where on a computer a thread runs: the CLI's id for the computer, its name, and the
483
565
  * folder there. All are shown back to its owner, so none holds a control character.
@@ -595,8 +677,8 @@ export const CONTROL_CHARACTER =
595
677
  /[\u0000-\u001f\u007f-\u009f\u200e\u200f\u202a-\u202e\u2066-\u2069]/
596
678
 
597
679
  /**
598
- * Refuse to assign a computer to a thread that runs in the cloud, or does not exist, or to move one
599
- * while a turn runs in its folder.
680
+ * Refuse to assign a computer to a sub-agent's thread or one that does not exist, to move a cloud
681
+ * thread while a turn holds it, or to move a computer's thread while a turn runs in its folder.
600
682
  */
601
683
  export function assertAssignableComputer(
602
684
  thread: AgentThreadRecord | null,
@@ -608,12 +690,23 @@ export function assertAssignableComputer(
608
690
  if (!thread) {
609
691
  throw new AgentStorageError("thread_not_found", `[${prefix}] Agent thread '${id}' not found.`)
610
692
  }
611
- if (thread.runsOn !== "computer") {
693
+ if (thread.kind !== "conversation") {
612
694
  throw new AgentStorageError(
613
695
  "invalid_input",
614
- `[${prefix}] Agent thread '${id}' runs in the cloud: no computer runs its turns.`
696
+ `[${prefix}] Sub-agent thread '${id}' never runs on a computer.`
615
697
  )
616
698
  }
699
+ if (thread.runsOn !== "computer") {
700
+ // A turn in flight, or one waiting for its computer, would be left where nothing runs it. A
701
+ // turn paused on held calls passes here: the caller refuses that, with its approvals in view.
702
+ if (activeRun?.status === "queued" || activeRun?.status === "running") {
703
+ throw new AgentStorageError(
704
+ "active_run_exists",
705
+ `[${prefix}] A turn of Agent thread '${id}' is in progress in the cloud: stop it, or let it end, first.`
706
+ )
707
+ }
708
+ return
709
+ }
617
710
  if (movesComputerPlace(thread, computer)) assertNoTurnRunning(activeRun, id, prefix)
618
711
  }
619
712
 
@@ -703,15 +796,62 @@ export function queuedTurnInCloud(
703
796
  ): ConversationAgentRunRecord | undefined {
704
797
  if (active?.kind !== "conversation" || active.status !== "queued") return undefined
705
798
  if (active.spec?.runsOn !== "computer") return undefined
706
- const { runsOn: _runsOn, ...cloud } = active.spec
799
+ const { runsOn: _runsOn, computer: _computer, ...cloud } = active.spec
707
800
  return { ...active, spec: cloud }
708
801
  }
709
802
 
803
+ /** The queued turn of a computer's thread that moves to another folder, with its new place. */
804
+ export function queuedTurnOnComputer(
805
+ active: AgentRunRecord | null,
806
+ computer: AgentThreadPlace
807
+ ): ConversationAgentRunRecord | undefined {
808
+ if (active?.kind !== "conversation" || active.status !== "queued") return undefined
809
+ if (active.spec?.runsOn !== "computer" || active.spec.computer === undefined) return undefined
810
+ const place = { id: computer.id, folder: computer.folder }
811
+ if (sameComputerPlace(active.spec.computer, place)) return undefined
812
+ return { ...active, spec: { ...active.spec, computer: place } }
813
+ }
814
+
815
+ /**
816
+ * Mark a paused sub-agent's saved cloud workspace unavailable when its conversation leaves the
817
+ * cloud: a continuation on the computer updates out/, so a later return to the cloud starts fresh.
818
+ */
819
+ export function unavailableChildSandboxState(
820
+ state: AgentThreadSandboxState | undefined
821
+ ): AgentThreadSandboxState | undefined {
822
+ if (!state || (state.status !== "ready" && state.status !== "new")) return undefined
823
+ return { ...state, status: "unavailable" }
824
+ }
825
+
710
826
  /** Whether two places are the same folder of the same computer, whatever they call it. */
711
827
  export function sameComputerPlace(a: AgentThreadPlace, b: AgentThreadPlace): boolean {
712
828
  return a.id === b.id && a.folder === b.folder
713
829
  }
714
830
 
831
+ /** Where a turn runs, as its spec records it: the cloud, or a folder of its owner's computer. */
832
+ export type AgentTurnPlace = Pick<ConversationAgentRunSpec, "runsOn" | "computer">
833
+
834
+ /** The place a turn's spec records, from its thread's: the cloud, or a computer and its folder. */
835
+ export function turnPlace(
836
+ runsOn: "computer" | undefined,
837
+ computer: AgentThreadPlace | undefined
838
+ ): AgentTurnPlace {
839
+ if (runsOn === undefined) return {}
840
+
841
+ return computer
842
+ ? { runsOn, computer: Object.freeze({ id: computer.id, folder: computer.folder }) }
843
+ : { runsOn }
844
+ }
845
+
846
+ /**
847
+ * The same key for two turns that ran in the same workspace: the cloud, or one folder of one
848
+ * computer. A computer's turn from before folders were kept ran in a folder nobody knows.
849
+ */
850
+ export function runPlaceKey(spec: AgentTurnPlace | undefined): string {
851
+ if (spec?.runsOn !== "computer") return "cloud"
852
+ return spec.computer ? `computer:${spec.computer.id}:${spec.computer.folder}` : "computer"
853
+ }
854
+
715
855
  export function isAgentApprovalMode(value: unknown): value is AgentApprovalMode {
716
856
  return (AGENT_APPROVAL_MODES as readonly unknown[]).includes(value)
717
857
  }
@@ -829,6 +969,14 @@ export function assertCreateSubagentRunInput(input: CreateSubagentRunInput, pref
829
969
  `[${prefix}] Subagent run 'maxSteps' must be a positive safe integer.`
830
970
  )
831
971
  }
972
+ for (const flag of ["readOnly", "inParentWorkspace"] as const) {
973
+ if (input.spec[flag] !== undefined && input.spec[flag] !== true) {
974
+ throw new AgentStorageError(
975
+ "invalid_input",
976
+ `[${prefix}] Subagent run '${flag}' must be true or absent.`
977
+ )
978
+ }
979
+ }
832
980
  assertApprovalModeField(input.spec.approvalMode, "Subagent run", prefix)
833
981
 
834
982
  assertSubagentRunFiles(input.spec.files, "spec.files", prefix)
@@ -1648,6 +1796,15 @@ export function assertEnqueueAgentInboxItemInput(
1648
1796
  assertAgentInboxParts(input.parts, input.mode, prefix)
1649
1797
  assertAgentInboxSpec(input.spec, prefix)
1650
1798
  if (input.executionId !== undefined) assertNonEmptyText(input.executionId, "executionId", prefix)
1799
+ if (input.replacesMessageId !== undefined) {
1800
+ assertNonEmptyText(input.replacesMessageId, "replacesMessageId", prefix)
1801
+ if (input.mode !== "queue" || input.immediate !== true) {
1802
+ throw new AgentStorageError(
1803
+ "invalid_input",
1804
+ `[${prefix}] An agent inbox item that replaces a message is a queued message sent now.`
1805
+ )
1806
+ }
1807
+ }
1651
1808
  }
1652
1809
 
1653
1810
  /**
@@ -1769,6 +1926,7 @@ export function newAgentInboxItemRecord(
1769
1926
  ...(input.timeZone ? { timeZone: input.timeZone } : {}),
1770
1927
  ...(input.locale ? { locale: input.locale } : {}),
1771
1928
  ...(input.immediate ? { immediate: true } : {}),
1929
+ ...(input.replacesMessageId ? { replacesMessageId: input.replacesMessageId } : {}),
1772
1930
  ...(input.executionId ? { executionId: input.executionId } : {}),
1773
1931
  createdAt,
1774
1932
  updatedAt: new Date(createdAt),
@@ -1794,6 +1952,13 @@ export function updatedAgentInboxItemRecord(
1794
1952
  const nextImmediate = input.immediate === undefined ? current.immediate : input.immediate
1795
1953
  const { spec: _oldSpec, immediate: _oldImmediate, ...base } = current
1796
1954
  const mode = input.mode ?? current.mode
1955
+ // An edit rewinds the thread when it starts: it goes now, after the turn it stopped.
1956
+ if (current.replacesMessageId !== undefined && (mode !== "queue" || nextImmediate !== true)) {
1957
+ throw new AgentStorageError(
1958
+ "invalid_state",
1959
+ `[Sixb] Agent inbox item '${current.id}' edits message '${current.replacesMessageId}': it stays a message sent now.`
1960
+ )
1961
+ }
1797
1962
  const parts =
1798
1963
  input.parts !== undefined ? structuredClone(input.parts) : structuredClone(current.parts)
1799
1964
  // Promoting a message that carries a file to a steer would read bytes a replay cannot send.
@@ -306,6 +306,76 @@ export interface ListAgentThreadParticipantsInput {
306
306
  readonly threadIds: readonly string[]
307
307
  }
308
308
 
309
+ // ── agent_thread_reads — how far each person has read a conversation ──────────────────────────
310
+
311
+ /**
312
+ * How far one person's reading of a conversation has reached, as the `seq` of its last message.
313
+ *
314
+ * A watermark, not a flag: nothing writes here when a message arrives, so new ones sit past it
315
+ * until the reader moves it. A mark never moves it backwards, so two devices converge on the later
316
+ * position and a stale one cannot rewind the other. Only a deletion does: when a retry or an edit
317
+ * takes the newest messages away, every place past what remains comes back to it, because the next
318
+ * messages take those numbers again.
319
+ */
320
+ export interface AgentThreadReadRecord {
321
+ readonly projectId: string
322
+ readonly threadId: string
323
+ readonly principal: UserPrincipal
324
+ /** The highest message `seq` this person's reading has reached. 0 when none has. */
325
+ readonly throughSeq: number
326
+ /** When this person last looked: every mark sets it, even one that leaves `throughSeq` alone. */
327
+ readonly readAt: Date
328
+ }
329
+
330
+ /**
331
+ * One person's place in a conversation, and what arrived past it.
332
+ *
333
+ * `unread` counts the messages past `throughSeq` that are new to them: every Agent answer and
334
+ * every other person's message. What they wrote is not, nor a message that only reports how
335
+ * approved calls ended (`countsAsThreadMessage`).
336
+ */
337
+ export interface AgentThreadReadState {
338
+ readonly threadId: string
339
+ /** Where their reading reached, never past `headSeq`. 0 when they have no row. */
340
+ readonly throughSeq: number
341
+ /** The `seq` of the thread's newest message, 0 when it has none. */
342
+ readonly headSeq: number
343
+ /** Messages past `throughSeq` that someone else wrote. */
344
+ readonly unread: number
345
+ /** When they last looked; absent until they have a row. */
346
+ readonly readAt?: Date
347
+ }
348
+
349
+ export interface MarkAgentThreadReadInput {
350
+ readonly projectId: string
351
+ readonly threadId: string
352
+ readonly principal: UserPrincipal
353
+ /**
354
+ * The last message they read, or the thread's newest when absent. A message the thread no longer
355
+ * holds marks nothing: a retry or an edit took it away, and its number may already name another.
356
+ */
357
+ readonly throughMessageId?: string
358
+ readonly readAt?: Date
359
+ }
360
+
361
+ export interface ListAgentThreadReadsInput {
362
+ readonly projectId: string
363
+ readonly threadIds: readonly string[]
364
+ readonly principal: UserPrincipal
365
+ }
366
+
367
+ export interface AgentThreadReadStore {
368
+ /**
369
+ * Record that this person's reading reached a message, never moving it back, and that they
370
+ * looked now. A participant has a row from the moment they join, and the migration gave one to
371
+ * everyone in the threads that existed before; an owner without one reads as 0 until their
372
+ * first mark. Answers their place afterwards.
373
+ */
374
+ mark(input: MarkAgentThreadReadInput): Promise<AgentThreadReadState>
375
+ /** One person's place in each of these threads; a thread that does not exist is absent. */
376
+ list(input: ListAgentThreadReadsInput): Promise<readonly AgentThreadReadState[]>
377
+ }
378
+
309
379
  // ── agent_runs — one loop execution (the worker job; attribution + fencing) ───────────────────
310
380
 
311
381
  /** Lifecycle shared by every durable agent execution, conversational or workflow-owned. */
@@ -367,7 +437,11 @@ export function coerceAgentRunFinishReason(
367
437
  }
368
438
 
369
439
  /** Stable, user-facing diagnostics emitted by the platform while executing a run. */
370
- export const AGENT_RUN_DIAGNOSTIC_CODES = ["step_limit_reached", "output_limit_reached"] as const
440
+ export const AGENT_RUN_DIAGNOSTIC_CODES = [
441
+ "step_limit_reached",
442
+ "output_limit_reached",
443
+ "workspace_not_saved",
444
+ ] as const
371
445
 
372
446
  /**
373
447
  * Closed on purpose, and the wire is closed with it.
@@ -452,6 +526,11 @@ export interface ConversationAgentRunSpec {
452
526
  readonly approvalMode?: AgentApprovalMode
453
527
  /** Its thread's `runsOn` when it was asked for: a computer's turn never reaches the agent queue. */
454
528
  readonly runsOn?: "computer"
529
+ /**
530
+ * Which computer and folder the turn ran in: captured with `runsOn: "computer"` and updated if a
531
+ * queued turn moves to another folder before starting.
532
+ */
533
+ readonly computer?: AgentThreadPlace
455
534
  }
456
535
 
457
536
  /** Immutable, serialisable child configuration captured before dispatch. */
@@ -473,6 +552,19 @@ export interface SubagentRunSpec {
473
552
  readonly locale?: string
474
553
  /** Files the parent handed over, copied into the child's sandbox at these paths. */
475
554
  readonly files?: readonly SubagentRunFile[]
555
+ /**
556
+ * The child leaves the files as it found them, for a review or an investigation: it has no
557
+ * `edit` and no `write` tool. Absent: it has both.
558
+ */
559
+ readonly readOnly?: true
560
+ /**
561
+ * The child's thread works in its parent's workspace, as the turn that spawned it lent it: its
562
+ * runs keep their files under its thread's own directory there, and a continuation goes on in
563
+ * the workspace while its turn lends it and the conversation did not move, else in a blank
564
+ * sandbox of its own, with the same run files directory. Absent: a sandbox of its own, which its
565
+ * continuations keep.
566
+ */
567
+ readonly inParentWorkspace?: true
476
568
  }
477
569
 
478
570
  /** A file a parent and its child hand each other, stored once and copied into a sandbox. */
@@ -638,6 +730,8 @@ export interface ListThreadSubagentsInput {
638
730
  readonly threadId: string
639
731
  readonly spawnKey?: string
640
732
  readonly finishReason?: AgentRunFinishReason
733
+ /** Only children spawned by turns whose trigger message is still in the thread. */
734
+ readonly retainedTurnsOnly?: boolean
641
735
  /** At most this many, 100 by default. */
642
736
  readonly limit?: number
643
737
  }
@@ -648,6 +742,11 @@ export interface ListAgentRunsResult {
648
742
  readonly total: number
649
743
  }
650
744
 
745
+ export interface ListLatestAgentRunsInput {
746
+ readonly projectId: string
747
+ readonly threadIds: readonly string[]
748
+ }
749
+
651
750
  // ── agent_messages — one message (assistant messages inserted only once finalized) ─────────────
652
751
 
653
752
  export type { AgentMessageRole }
@@ -688,6 +787,13 @@ export interface AppendAgentMessageInput extends AgentMessage {
688
787
  readonly completedAt?: Date
689
788
  }
690
789
 
790
+ export interface DeleteAgentMessagesFromSeqInput {
791
+ readonly projectId: string
792
+ readonly threadId: string
793
+ /** Delete every message whose per-thread sequence is greater than or equal to this boundary. */
794
+ readonly fromSeq: number
795
+ }
796
+
691
797
  export interface DeleteAgentMessagesByRunInput {
692
798
  readonly projectId: string
693
799
  readonly threadId: string
@@ -796,8 +902,9 @@ export interface AgentThreadStore {
796
902
  /** Whether the user took part until now. */
797
903
  removeParticipant(input: RemoveAgentThreadParticipantInput): Promise<boolean>
798
904
  /**
799
- * Move a computer's thread to another computer or folder, and return the thread after. A cloud
800
- * thread runs on none, and is refused.
905
+ * Move a conversation thread to a computer and folder, from the cloud or from another computer or
906
+ * folder, and return the thread after. Refused while a turn holds a cloud thread or runs on its
907
+ * computer.
801
908
  */
802
909
  assignComputer(input: AssignAgentThreadComputerInput): Promise<AgentThreadRecord>
803
910
  /**
@@ -857,18 +964,35 @@ export interface AgentRunStore {
857
964
  * within a turn the latest admitted first. Read by key (one per turn) or by finish reason.
858
965
  */
859
966
  listThreadSubagents(input: ListThreadSubagentsInput): Promise<readonly SubagentRunRecord[]>
967
+ /** The newest run of each thread, by creation and id; a thread without one is absent. */
968
+ latestByThread(input: ListLatestAgentRunsInput): Promise<readonly AgentRunRecord[]>
860
969
  list(input: ListAgentRunsInput): Promise<ListAgentRunsResult>
861
970
  }
862
971
 
863
972
  export interface AgentMessageStore {
864
973
  /** Insert a message (its `parts` are the canonical content) and bump thread stats. */
865
974
  append(input: AppendAgentMessageInput): Promise<AgentMessageRecord>
866
- /** Delete every message produced by one run and repair the thread's message stats. */
975
+ /**
976
+ * Delete every message produced by one run and repair the thread's message stats. A reader's
977
+ * place past the newest message left comes back to it: the next message reuses those numbers.
978
+ */
867
979
  deleteByRunId(input: DeleteAgentMessagesByRunInput): Promise<number>
980
+ /**
981
+ * Delete every message at or after `fromSeq` and repair the thread's message stats. A reader's
982
+ * place past the newest message left comes back to it: the edit that follows reuses the numbers.
983
+ */
984
+ deleteFromSeq(input: DeleteAgentMessagesFromSeqInput): Promise<number>
868
985
  getById(params: { projectId: string; id: string }): Promise<AgentMessageRecord | null>
869
986
  list(input: ListAgentMessagesInput): Promise<ListAgentMessagesResult>
870
987
  }
871
988
 
989
+ export interface DeleteAgentContextCheckpointsAfterSeqInput {
990
+ readonly projectId: string
991
+ readonly threadId: string
992
+ /** Delete checkpoints whose observed head exceeds this retained sequence boundary. */
993
+ readonly afterSeq: number
994
+ }
995
+
872
996
  export interface AgentContextCheckpointStore {
873
997
  /**
874
998
  * Append one checkpoint after atomically validating run ownership and both transcript anchors.
@@ -885,6 +1009,8 @@ export interface AgentContextCheckpointStore {
885
1009
  readonly projectId: string
886
1010
  readonly threadId: string
887
1011
  }): Promise<AgentContextCheckpointRecord | null>
1012
+ /** Delete checkpoints that observed messages past `afterSeq`, newest first. */
1013
+ deleteAfterSeq(input: DeleteAgentContextCheckpointsAfterSeqInput): Promise<number>
888
1014
  }
889
1015
 
890
1016
  // ── agent_approvals — calls of the Agent that wait for whoever asked ───────────────────────────
@@ -1052,6 +1178,26 @@ export interface StopAgentApprovalsResult {
1052
1178
  readonly stopped: number
1053
1179
  }
1054
1180
 
1181
+ export interface RewindAgentApprovalsInput {
1182
+ readonly projectId: string
1183
+ readonly threadId: string
1184
+ /** Conversation runs removed from the thread: their approvals leave with them. */
1185
+ readonly runIds: readonly string[]
1186
+ /**
1187
+ * Message ids removed by the rewind: an earlier turn's approval reported in one becomes
1188
+ * unreported again so the replacement message carries its outcome.
1189
+ */
1190
+ readonly clearedMessageIds?: readonly string[]
1191
+ readonly cancelledAt?: Date
1192
+ }
1193
+
1194
+ export interface RewindAgentApprovalsResult {
1195
+ /** Pending approvals of the rewound runs, as `cancelled` records to announce. */
1196
+ readonly cancelled: readonly AgentApprovalRecord[]
1197
+ /** Total approvals deleted for the rewound runs. */
1198
+ readonly deleted: number
1199
+ }
1200
+
1055
1201
  /** Where a keyset listing resumes: after this approval, in the order approvals are listed. */
1056
1202
  export interface AgentApprovalCursor {
1057
1203
  readonly createdAt: Date
@@ -1118,6 +1264,11 @@ export interface AgentApprovalStore {
1118
1264
  * stopped: their turn never resumes on them.
1119
1265
  */
1120
1266
  stop(input: StopAgentApprovalsInput): Promise<StopAgentApprovalsResult>
1267
+ /**
1268
+ * Remove approvals belonging to rewound turns and unmark earlier turns' approvals whose
1269
+ * reporting message was removed.
1270
+ */
1271
+ rewind(input: RewindAgentApprovalsInput): Promise<RewindAgentApprovalsResult>
1121
1272
  /** Mark the ones no message reported yet, and return their ids. */
1122
1273
  markReported(input: MarkAgentApprovalsReportedInput): Promise<readonly string[]>
1123
1274
  /**
@@ -1405,6 +1556,11 @@ export interface AgentInboxItemRecord {
1405
1556
  readonly locale?: string
1406
1557
  /** Marked by Send now so `afterAgentRunFinished` dispatches it across a user cancel. */
1407
1558
  readonly immediate?: boolean
1559
+ /**
1560
+ * An edit waiting for the turn it stopped to end: the earlier message it replaces. When it
1561
+ * starts, the thread first rewinds to that message. Always sent now, as a queued message.
1562
+ */
1563
+ readonly replacesMessageId?: string
1408
1564
  /**
1409
1565
  * The execution of the request that sent it. A turn that starts it without a request of its
1410
1566
  * sender's runs as a child of this one, with the sender's grants as they are then.
@@ -1427,6 +1583,11 @@ export interface EnqueueAgentInboxItemInput {
1427
1583
  readonly timeZone?: string
1428
1584
  readonly locale?: string
1429
1585
  readonly immediate?: boolean
1586
+ /**
1587
+ * An edit waiting for the turn it stopped to end: the earlier message it replaces. When it
1588
+ * starts, the thread first rewinds to that message. Always sent now, as a queued message.
1589
+ */
1590
+ readonly replacesMessageId?: string
1430
1591
  readonly executionId?: string
1431
1592
  readonly createdAt?: Date
1432
1593
  }
@@ -1530,6 +1691,7 @@ export interface AgentInboxStore {
1530
1691
 
1531
1692
  export interface AgentStorage {
1532
1693
  readonly threads: AgentThreadStore
1694
+ readonly reads: AgentThreadReadStore
1533
1695
  readonly runs: AgentRunStore
1534
1696
  readonly messages: AgentMessageStore
1535
1697
  readonly checkpoints: AgentContextCheckpointStore