@sixb/core 0.2.5 → 0.2.6

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 (385) 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 +2 -2
  9. package/dist/agents/index.d.ts.map +1 -1
  10. package/dist/agents/index.js +50 -44
  11. package/dist/agents/index.js.map +1 -1
  12. package/dist/agents/model-routing.d.ts +5 -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-turn.d.ts +9 -1
  20. package/dist/agents/run-turn.d.ts.map +1 -1
  21. package/dist/agents/streams/index.d.ts +1 -1
  22. package/dist/agents/streams/index.d.ts.map +1 -1
  23. package/dist/agents/streams/index.js +1 -1
  24. package/dist/agents/streams/internal.d.ts +2 -1
  25. package/dist/agents/streams/internal.d.ts.map +1 -1
  26. package/dist/agents/streams/internal.js +22 -2
  27. package/dist/agents/streams/internal.js.map +1 -1
  28. package/dist/agents/streams/protocol.d.ts +37 -0
  29. package/dist/agents/streams/protocol.d.ts.map +1 -1
  30. package/dist/agents/streams/steps.d.ts +24 -0
  31. package/dist/agents/streams/steps.d.ts.map +1 -0
  32. package/dist/agents/thread-access.d.ts +44 -2
  33. package/dist/agents/thread-access.d.ts.map +1 -1
  34. package/dist/artifacts/live/server.js +19 -18
  35. package/dist/artifacts/live/server.js.map +1 -1
  36. package/dist/artifacts/publish/index.js +18 -17
  37. package/dist/artifacts/publish/index.js.map +1 -1
  38. package/dist/artifacts/publish/merge.d.ts +2 -1
  39. package/dist/artifacts/publish/merge.d.ts.map +1 -1
  40. package/dist/artifacts/run-query.d.ts.map +1 -1
  41. package/dist/auth/index.js +6 -6
  42. package/dist/authorization/index.js +2 -2
  43. package/dist/bootstrap/index.js +40 -38
  44. package/dist/bootstrap/index.js.map +2 -2
  45. package/dist/calendar.d.ts +55 -0
  46. package/dist/calendar.d.ts.map +1 -0
  47. package/dist/calendar.js +19 -0
  48. package/dist/calendar.js.map +9 -0
  49. package/dist/{chunk-5a4a52tq.js → chunk-0pmpwn3g.js} +18 -2
  50. package/dist/chunk-0pmpwn3g.js.map +10 -0
  51. package/dist/{chunk-xcrnrpfh.js → chunk-394zjzjs.js} +20 -10
  52. package/dist/{chunk-xcrnrpfh.js.map → chunk-394zjzjs.js.map} +5 -5
  53. package/dist/{chunk-stmxh0hv.js → chunk-3neam1y5.js} +2 -2
  54. package/dist/{chunk-zeykm8my.js → chunk-3qtk0070.js} +16 -42
  55. package/dist/chunk-3qtk0070.js.map +14 -0
  56. package/dist/{chunk-0mvjpgvm.js → chunk-425ydk65.js} +4 -4
  57. package/dist/{chunk-s5pj68fa.js → chunk-5sswe5ej.js} +2 -2
  58. package/dist/chunk-6hfbz4d0.js +98 -0
  59. package/dist/chunk-6hfbz4d0.js.map +10 -0
  60. package/dist/{chunk-3zagkr6w.js → chunk-7mhbs9yy.js} +4 -4
  61. package/dist/{chunk-3zagkr6w.js.map → chunk-7mhbs9yy.js.map} +1 -1
  62. package/dist/{chunk-fpf57gca.js → chunk-7r9mqpva.js} +273 -66
  63. package/dist/{chunk-fpf57gca.js.map → chunk-7r9mqpva.js.map} +5 -5
  64. package/dist/{chunk-ewqn51gr.js → chunk-88xeh6zx.js} +6 -4
  65. package/dist/{chunk-ewqn51gr.js.map → chunk-88xeh6zx.js.map} +4 -4
  66. package/dist/chunk-90nqenq8.js +386 -0
  67. package/dist/chunk-90nqenq8.js.map +14 -0
  68. package/dist/{chunk-gjhrz66x.js → chunk-9c9yknwt.js} +247 -20
  69. package/dist/{chunk-gjhrz66x.js.map → chunk-9c9yknwt.js.map} +6 -6
  70. package/dist/{chunk-q9nkpr8k.js → chunk-9tpmfh3n.js} +1 -1
  71. package/dist/chunk-9wr3yajk.js.map +2 -2
  72. package/dist/{chunk-z1njfqqs.js → chunk-ats8y3d9.js} +721 -156
  73. package/dist/{chunk-z1njfqqs.js.map → chunk-ats8y3d9.js.map} +13 -13
  74. package/dist/{chunk-68hm50qh.js → chunk-bcz9dxtf.js} +16 -46
  75. package/dist/chunk-bcz9dxtf.js.map +12 -0
  76. package/dist/{chunk-naxjka9v.js → chunk-brhp9d97.js} +2 -2
  77. package/dist/{chunk-8a8k38tz.js → chunk-brybqw5k.js} +1 -1
  78. package/dist/{chunk-s1mqyqmm.js → chunk-bs1sd0e0.js} +12 -8
  79. package/dist/chunk-bs1sd0e0.js.map +18 -0
  80. package/dist/{chunk-vehcr9eb.js → chunk-cg7cygfj.js} +1 -1
  81. package/dist/chunk-dq3t5sr3.js +114 -0
  82. package/dist/chunk-dq3t5sr3.js.map +11 -0
  83. package/dist/{chunk-r2psmn42.js → chunk-eg6xqef7.js} +1 -1
  84. package/dist/{chunk-zxhym8tr.js → chunk-f05994as.js} +1 -1
  85. package/dist/{chunk-5t9gm5tt.js → chunk-fmgf9h5e.js} +38 -14
  86. package/dist/chunk-fmgf9h5e.js.map +22 -0
  87. package/dist/{chunk-ey1p8w68.js → chunk-gaj8djsw.js} +80 -4
  88. package/dist/chunk-gaj8djsw.js.map +13 -0
  89. package/dist/{chunk-1yh6jgtz.js → chunk-grt2j5vp.js} +2 -2
  90. package/dist/{chunk-zft9bzbc.js → chunk-hkbks1xm.js} +2 -1
  91. package/dist/{chunk-zft9bzbc.js.map → chunk-hkbks1xm.js.map} +3 -3
  92. package/dist/{chunk-rtdrm592.js → chunk-htdzx40w.js} +2 -2
  93. package/dist/{chunk-bc3y6gff.js → chunk-jka26v8c.js} +1 -1
  94. package/dist/{chunk-m3qx2pns.js → chunk-jt012fxq.js} +28 -12
  95. package/dist/{chunk-m3qx2pns.js.map → chunk-jt012fxq.js.map} +5 -5
  96. package/dist/{chunk-k3jh8gsg.js → chunk-kft7mp7z.js} +20 -3
  97. package/dist/chunk-kft7mp7z.js.map +10 -0
  98. package/dist/{chunk-qavwr628.js → chunk-n1hbwc6y.js} +5 -6
  99. package/dist/chunk-n1hbwc6y.js.map +12 -0
  100. package/dist/chunk-nxysqbt0.js.map +2 -2
  101. package/dist/{chunk-pqvvqc65.js → chunk-pqj8vff9.js} +3 -3
  102. package/dist/{chunk-wqe9shx2.js → chunk-qbd282aa.js} +2 -2
  103. package/dist/{chunk-e91fmg6t.js → chunk-qsa7nw6f.js} +2 -1
  104. package/dist/{chunk-e91fmg6t.js.map → chunk-qsa7nw6f.js.map} +3 -3
  105. package/dist/{chunk-rg725hry.js → chunk-s8xxef60.js} +83 -33
  106. package/dist/{chunk-rg725hry.js.map → chunk-s8xxef60.js.map} +5 -5
  107. package/dist/{chunk-fzae1jpq.js → chunk-t19wjmnc.js} +5 -5
  108. package/dist/{chunk-paxabbqd.js → chunk-tapdssb5.js} +1 -1
  109. package/dist/{chunk-dhkc9b23.js → chunk-v8a1qjzp.js} +1 -1
  110. package/dist/{chunk-q8d9p0tb.js → chunk-wzcjhv54.js} +8 -1
  111. package/dist/{chunk-q8d9p0tb.js.map → chunk-wzcjhv54.js.map} +3 -3
  112. package/dist/{chunk-pc7kra3k.js → chunk-xavet0qs.js} +1 -1
  113. package/dist/{chunk-0hkdtwqk.js → chunk-xf76csps.js} +5 -5
  114. package/dist/{chunk-m9ketb51.js → chunk-ygvay56w.js} +1 -1
  115. package/dist/{chunk-b4escq4c.js → chunk-ykchk644.js} +6 -6
  116. package/dist/{chunk-k29n4176.js → chunk-ym1bqd98.js} +6 -6
  117. package/dist/connectors/connections/capability.d.ts +11 -0
  118. package/dist/connectors/connections/capability.d.ts.map +1 -1
  119. package/dist/connectors/connections/internal.d.ts +2 -1
  120. package/dist/connectors/connections/internal.d.ts.map +1 -1
  121. package/dist/connectors/connections/internal.js +8 -4
  122. package/dist/connectors/connections/internal.js.map +1 -1
  123. package/dist/connectors/connections/service.d.ts +9 -1
  124. package/dist/connectors/connections/service.d.ts.map +1 -1
  125. package/dist/connectors/execution.d.ts +7 -1
  126. package/dist/connectors/execution.d.ts.map +1 -1
  127. package/dist/connectors/service.d.ts +5 -1
  128. package/dist/connectors/service.d.ts.map +1 -1
  129. package/dist/deploy/types.d.ts +4 -1
  130. package/dist/deploy/types.d.ts.map +1 -1
  131. package/dist/events/execution.d.ts +8 -1
  132. package/dist/events/execution.d.ts.map +1 -1
  133. package/dist/events/types/syncs.d.ts +4 -0
  134. package/dist/events/types/syncs.d.ts.map +1 -1
  135. package/dist/execution/agent.js +37 -36
  136. package/dist/execution/agent.js.map +1 -1
  137. package/dist/execution/authorized-object-reader.d.ts +4 -0
  138. package/dist/execution/authorized-object-reader.d.ts.map +1 -1
  139. package/dist/execution/object-reader-ontology.d.ts +3 -0
  140. package/dist/execution/object-reader-ontology.d.ts.map +1 -1
  141. package/dist/execution/primitive.js +36 -35
  142. package/dist/execution/primitive.js.map +1 -1
  143. package/dist/execution/request.d.ts +1 -1
  144. package/dist/execution/request.d.ts.map +1 -1
  145. package/dist/execution/request.js +33 -32
  146. package/dist/execution/request.js.map +3 -3
  147. package/dist/http/api-routes.d.ts.map +1 -1
  148. package/dist/http/index.js +1 -1
  149. package/dist/index.d.ts +5 -5
  150. package/dist/index.d.ts.map +1 -1
  151. package/dist/index.js +61 -59
  152. package/dist/index.js.map +1 -1
  153. package/dist/maintenance/index.js +1 -1
  154. package/dist/materializer/index.js +22 -21
  155. package/dist/materializer/index.js.map +1 -1
  156. package/dist/models/audio/runtime.d.ts.map +1 -1
  157. package/dist/models/audio/types.d.ts +19 -0
  158. package/dist/models/audio/types.d.ts.map +1 -1
  159. package/dist/models/execution/index.js +20 -19
  160. package/dist/models/execution/index.js.map +1 -1
  161. package/dist/models/index.d.ts +1 -1
  162. package/dist/models/index.d.ts.map +1 -1
  163. package/dist/objects/index.js +36 -35
  164. package/dist/objects/index.js.map +1 -1
  165. package/dist/objects/query/executor.d.ts +3 -1
  166. package/dist/objects/query/executor.d.ts.map +1 -1
  167. package/dist/objects/query/explain.d.ts +3 -1
  168. package/dist/objects/query/explain.d.ts.map +1 -1
  169. package/dist/objects/query/index.d.ts +1 -1
  170. package/dist/objects/query/index.d.ts.map +1 -1
  171. package/dist/objects/query/index.js +19 -18
  172. package/dist/objects/query/index.js.map +1 -1
  173. package/dist/objects/query/link-query-clearance.d.ts +3 -0
  174. package/dist/objects/query/link-query-clearance.d.ts.map +1 -1
  175. package/dist/objects/query/links.d.ts +1 -1
  176. package/dist/objects/query/links.d.ts.map +1 -1
  177. package/dist/objects/query/validate.d.ts +17 -0
  178. package/dist/objects/query/validate.d.ts.map +1 -1
  179. package/dist/objects/sdk/runtime-query-executor.d.ts +1 -1
  180. package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
  181. package/dist/ontology/index.js +3 -3
  182. package/dist/ontology/internal.js +3 -3
  183. package/dist/pipelines/index.js +21 -20
  184. package/dist/pipelines/index.js.map +1 -1
  185. package/dist/projections/internal.js +20 -19
  186. package/dist/projections/internal.js.map +1 -1
  187. package/dist/queues/in-memory.d.ts +1 -1
  188. package/dist/queues/in-memory.d.ts.map +1 -1
  189. package/dist/runtime/host.d.ts.map +1 -1
  190. package/dist/runtime/internal.js +24 -23
  191. package/dist/runtime/internal.js.map +2 -2
  192. package/dist/runtime/locale.d.ts +0 -2
  193. package/dist/runtime/locale.d.ts.map +1 -1
  194. package/dist/runtime/sixb.d.ts.map +1 -1
  195. package/dist/sandboxes/auth.d.ts +26 -4
  196. package/dist/sandboxes/auth.d.ts.map +1 -1
  197. package/dist/sandboxes/index.d.ts +3 -1
  198. package/dist/sandboxes/index.d.ts.map +1 -1
  199. package/dist/sandboxes/index.js +5 -5
  200. package/dist/security/view-conditions.d.ts.map +1 -1
  201. package/dist/shares/internal.js +16 -15
  202. package/dist/shares/internal.js.map +2 -2
  203. package/dist/storage/agents/in-memory.d.ts +18 -1
  204. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  205. package/dist/storage/agents/index.d.ts +1 -1
  206. package/dist/storage/agents/index.d.ts.map +1 -1
  207. package/dist/storage/agents/provider.d.ts +43 -9
  208. package/dist/storage/agents/provider.d.ts.map +1 -1
  209. package/dist/storage/agents/provider.js +18 -2
  210. package/dist/storage/agents/provider.js.map +1 -1
  211. package/dist/storage/agents/types.d.ts +136 -3
  212. package/dist/storage/agents/types.d.ts.map +1 -1
  213. package/dist/storage/ai-cost/analytics.d.ts +3 -2
  214. package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
  215. package/dist/storage/ai-cost/provider.js +4 -3
  216. package/dist/storage/ai-cost/provider.js.map +1 -1
  217. package/dist/storage/ai-cost/types.d.ts +5 -1
  218. package/dist/storage/ai-cost/types.d.ts.map +1 -1
  219. package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
  220. package/dist/storage/artifacts/record.d.ts +3 -1
  221. package/dist/storage/artifacts/record.d.ts.map +1 -1
  222. package/dist/storage/artifacts/types.d.ts +7 -0
  223. package/dist/storage/artifacts/types.d.ts.map +1 -1
  224. package/dist/storage/file-upload-sessions/provider.js +7 -7
  225. package/dist/storage/index.d.ts +2 -2
  226. package/dist/storage/index.d.ts.map +1 -1
  227. package/dist/storage/index.js +22 -21
  228. package/dist/storage/index.js.map +1 -1
  229. package/dist/storage/internal.js +8 -8
  230. package/dist/storage/operation-scope.d.ts.map +1 -1
  231. package/dist/storage/operation-scope.js +1 -1
  232. package/dist/storage/sync-runs/idempotency.d.ts.map +1 -1
  233. package/dist/storage/sync-runs/in-memory.d.ts +2 -1
  234. package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
  235. package/dist/storage/sync-runs/index.d.ts +1 -1
  236. package/dist/storage/sync-runs/index.d.ts.map +1 -1
  237. package/dist/storage/sync-runs/types.d.ts +27 -2
  238. package/dist/storage/sync-runs/types.d.ts.map +1 -1
  239. package/dist/storage/workflow-runs/provider.js +7 -7
  240. package/dist/syncs/accounts.d.ts +36 -0
  241. package/dist/syncs/accounts.d.ts.map +1 -0
  242. package/dist/syncs/builders.d.ts.map +1 -1
  243. package/dist/syncs/connections.d.ts +36 -0
  244. package/dist/syncs/connections.d.ts.map +1 -0
  245. package/dist/syncs/execution.d.ts +14 -4
  246. package/dist/syncs/execution.d.ts.map +1 -1
  247. package/dist/syncs/index.d.ts +2 -1
  248. package/dist/syncs/index.d.ts.map +1 -1
  249. package/dist/syncs/index.js +22 -21
  250. package/dist/syncs/index.js.map +1 -1
  251. package/dist/syncs/request.d.ts +16 -2
  252. package/dist/syncs/request.d.ts.map +1 -1
  253. package/dist/syncs/run-dispatch.d.ts +14 -2
  254. package/dist/syncs/run-dispatch.d.ts.map +1 -1
  255. package/dist/testing/agent-approval-storage-contract.d.ts.map +1 -1
  256. package/dist/testing/agent-inbox-storage-contract.d.ts.map +1 -1
  257. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  258. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
  259. package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
  260. package/dist/testing/index.js +1051 -58
  261. package/dist/testing/index.js.map +8 -8
  262. package/dist/testing/run-claim-storage-contract.d.ts.map +1 -1
  263. package/dist/webhooks/internal.js +17 -16
  264. package/dist/webhooks/internal.js.map +2 -2
  265. package/dist/workers/index.js +66 -13
  266. package/dist/workers/index.js.map +4 -4
  267. package/dist/workers/queue-worker.d.ts +5 -0
  268. package/dist/workers/queue-worker.d.ts.map +1 -1
  269. package/dist/workers/worker.d.ts +8 -0
  270. package/dist/workers/worker.d.ts.map +1 -1
  271. package/dist/workflows/index.js +42 -40
  272. package/dist/workflows/index.js.map +1 -1
  273. package/package.json +7 -1
  274. package/src/actions/validation.ts +3 -1
  275. package/src/agents/children.ts +6 -0
  276. package/src/agents/errors.ts +3 -0
  277. package/src/agents/execution.ts +170 -20
  278. package/src/agents/index.ts +4 -0
  279. package/src/agents/model-routing.ts +25 -9
  280. package/src/agents/request.ts +759 -40
  281. package/src/agents/run-events.ts +235 -38
  282. package/src/agents/run-session-children.ts +13 -2
  283. package/src/agents/run-turn.ts +140 -23
  284. package/src/agents/streams/index.ts +2 -0
  285. package/src/agents/streams/internal.ts +12 -0
  286. package/src/agents/streams/protocol.ts +69 -1
  287. package/src/agents/streams/steps.ts +131 -0
  288. package/src/agents/thread-access.ts +57 -2
  289. package/src/artifacts/publish/merge.ts +14 -3
  290. package/src/artifacts/run-query.ts +5 -2
  291. package/src/calendar.ts +195 -0
  292. package/src/connectors/connections/capability.ts +40 -0
  293. package/src/connectors/connections/internal.ts +3 -0
  294. package/src/connectors/connections/service.ts +74 -5
  295. package/src/connectors/execution.ts +5 -6
  296. package/src/connectors/service.ts +23 -0
  297. package/src/deploy/types.ts +4 -1
  298. package/src/events/execution.ts +42 -2
  299. package/src/events/types/syncs.ts +4 -0
  300. package/src/execution/authorized-object-reader.ts +33 -5
  301. package/src/execution/object-reader-ontology.ts +6 -0
  302. package/src/execution/request.ts +1 -0
  303. package/src/http/api-routes.ts +8 -0
  304. package/src/index.ts +18 -2
  305. package/src/models/audio/runtime.ts +57 -14
  306. package/src/models/audio/types.ts +20 -0
  307. package/src/models/index.ts +1 -0
  308. package/src/objects/query/executor.ts +4 -0
  309. package/src/objects/query/explain.ts +5 -0
  310. package/src/objects/query/index.ts +1 -0
  311. package/src/objects/query/link-query-clearance.ts +4 -1
  312. package/src/objects/query/links.ts +5 -1
  313. package/src/objects/query/validate.ts +33 -1
  314. package/src/objects/sdk/runtime-query-executor.ts +7 -3
  315. package/src/runtime/host.ts +13 -7
  316. package/src/runtime/locale.ts +0 -10
  317. package/src/runtime/sixb.ts +12 -2
  318. package/src/sandboxes/README.md +3 -1
  319. package/src/sandboxes/auth.ts +32 -4
  320. package/src/sandboxes/index.ts +15 -1
  321. package/src/security/view-conditions.ts +2 -1
  322. package/src/storage/agents/in-memory.ts +271 -6
  323. package/src/storage/agents/index.ts +10 -0
  324. package/src/storage/agents/provider.ts +170 -13
  325. package/src/storage/agents/types.ts +148 -3
  326. package/src/storage/ai-cost/analytics.ts +22 -43
  327. package/src/storage/ai-cost/types.ts +5 -1
  328. package/src/storage/artifacts/in-memory.ts +20 -5
  329. package/src/storage/artifacts/record.ts +8 -2
  330. package/src/storage/artifacts/types.ts +7 -0
  331. package/src/storage/index.ts +11 -0
  332. package/src/storage/operation-scope.ts +1 -0
  333. package/src/storage/sync-runs/idempotency.ts +1 -0
  334. package/src/storage/sync-runs/in-memory.ts +43 -1
  335. package/src/storage/sync-runs/index.ts +1 -0
  336. package/src/storage/sync-runs/types.ts +30 -1
  337. package/src/syncs/accounts.ts +85 -0
  338. package/src/syncs/builders.ts +18 -1
  339. package/src/syncs/connections.ts +123 -0
  340. package/src/syncs/execution.ts +64 -22
  341. package/src/syncs/index.ts +3 -0
  342. package/src/syncs/request.ts +81 -23
  343. package/src/syncs/run-dispatch.ts +69 -7
  344. package/src/testing/agent-approval-storage-contract.ts +123 -0
  345. package/src/testing/agent-inbox-storage-contract.ts +59 -0
  346. package/src/testing/agent-storage-contract.ts +767 -8
  347. package/src/testing/ai-cost-storage-contract.ts +80 -0
  348. package/src/testing/artifact-storage-contract.ts +129 -0
  349. package/src/testing/run-claim-storage-contract.ts +116 -0
  350. package/src/workers/README.md +4 -1
  351. package/src/workers/lost-runs.ts +1 -0
  352. package/src/workers/queue-worker.ts +16 -5
  353. package/src/workers/worker.ts +67 -7
  354. package/dist/chunk-5a4a52tq.js.map +0 -10
  355. package/dist/chunk-5t9gm5tt.js.map +0 -22
  356. package/dist/chunk-68hm50qh.js.map +0 -13
  357. package/dist/chunk-aw1z0gre.js +0 -234
  358. package/dist/chunk-aw1z0gre.js.map +0 -12
  359. package/dist/chunk-ey1p8w68.js.map +0 -13
  360. package/dist/chunk-k3jh8gsg.js.map +0 -10
  361. package/dist/chunk-qavwr628.js.map +0 -12
  362. package/dist/chunk-s1mqyqmm.js.map +0 -18
  363. package/dist/chunk-zeykm8my.js.map +0 -14
  364. /package/dist/{chunk-stmxh0hv.js.map → chunk-3neam1y5.js.map} +0 -0
  365. /package/dist/{chunk-0mvjpgvm.js.map → chunk-425ydk65.js.map} +0 -0
  366. /package/dist/{chunk-s5pj68fa.js.map → chunk-5sswe5ej.js.map} +0 -0
  367. /package/dist/{chunk-q9nkpr8k.js.map → chunk-9tpmfh3n.js.map} +0 -0
  368. /package/dist/{chunk-naxjka9v.js.map → chunk-brhp9d97.js.map} +0 -0
  369. /package/dist/{chunk-8a8k38tz.js.map → chunk-brybqw5k.js.map} +0 -0
  370. /package/dist/{chunk-vehcr9eb.js.map → chunk-cg7cygfj.js.map} +0 -0
  371. /package/dist/{chunk-r2psmn42.js.map → chunk-eg6xqef7.js.map} +0 -0
  372. /package/dist/{chunk-zxhym8tr.js.map → chunk-f05994as.js.map} +0 -0
  373. /package/dist/{chunk-1yh6jgtz.js.map → chunk-grt2j5vp.js.map} +0 -0
  374. /package/dist/{chunk-rtdrm592.js.map → chunk-htdzx40w.js.map} +0 -0
  375. /package/dist/{chunk-bc3y6gff.js.map → chunk-jka26v8c.js.map} +0 -0
  376. /package/dist/{chunk-pqvvqc65.js.map → chunk-pqj8vff9.js.map} +0 -0
  377. /package/dist/{chunk-wqe9shx2.js.map → chunk-qbd282aa.js.map} +0 -0
  378. /package/dist/{chunk-fzae1jpq.js.map → chunk-t19wjmnc.js.map} +0 -0
  379. /package/dist/{chunk-paxabbqd.js.map → chunk-tapdssb5.js.map} +0 -0
  380. /package/dist/{chunk-dhkc9b23.js.map → chunk-v8a1qjzp.js.map} +0 -0
  381. /package/dist/{chunk-pc7kra3k.js.map → chunk-xavet0qs.js.map} +0 -0
  382. /package/dist/{chunk-0hkdtwqk.js.map → chunk-xf76csps.js.map} +0 -0
  383. /package/dist/{chunk-m9ketb51.js.map → chunk-ygvay56w.js.map} +0 -0
  384. /package/dist/{chunk-b4escq4c.js.map → chunk-ykchk644.js.map} +0 -0
  385. /package/dist/{chunk-k29n4176.js.map → chunk-ym1bqd98.js.map} +0 -0
@@ -8,15 +8,15 @@ import {
8
8
  defineWorkflow2,
9
9
  createWorkflowNodeFailure2,
10
10
  unwrapWorkflowNodeFailure2
11
- } from "../chunk-0mvjpgvm.js";
11
+ } from "../chunk-425ydk65.js";
12
12
  import"../chunk-dvgc56n2.js";
13
13
  import"../chunk-fzbhybya.js";
14
14
  import"../chunk-z4jqb44a.js";
15
- import"../chunk-fpf57gca.js";
15
+ import"../chunk-7r9mqpva.js";
16
16
  import"../chunk-de5sfbc3.js";
17
- import"../chunk-bc3y6gff.js";
18
- import"../chunk-q8d9p0tb.js";
19
- import"../chunk-zxhym8tr.js";
17
+ import"../chunk-jka26v8c.js";
18
+ import"../chunk-wzcjhv54.js";
19
+ import"../chunk-f05994as.js";
20
20
  import {
21
21
  WorkflowDefinitionError2,
22
22
  WorkflowValidationError2,
@@ -46,75 +46,77 @@ import {
46
46
  snapshotWorkflowActionInput2,
47
47
  WorkflowRunDispatcher2,
48
48
  requestWorkflowRun2
49
- } from "../chunk-z1njfqqs.js";
50
- import"../chunk-aw1z0gre.js";
51
- import"../chunk-qavwr628.js";
52
- import"../chunk-wqe9shx2.js";
53
- import"../chunk-k29n4176.js";
54
- import"../chunk-rtdrm592.js";
55
- import"../chunk-b4escq4c.js";
49
+ } from "../chunk-ats8y3d9.js";
50
+ import"../chunk-90nqenq8.js";
51
+ import"../chunk-n1hbwc6y.js";
52
+ import"../chunk-qbd282aa.js";
53
+ import"../chunk-pqj8vff9.js";
54
+ import"../chunk-y8fwm3z2.js";
55
+ import"../chunk-ym1bqd98.js";
56
+ import"../chunk-htdzx40w.js";
57
+ import"../chunk-ykchk644.js";
58
+ import"../chunk-xavet0qs.js";
56
59
  import"../chunk-3723kgba.js";
57
- import"../chunk-1yh6jgtz.js";
58
- import"../chunk-q9nkpr8k.js";
60
+ import"../chunk-grt2j5vp.js";
59
61
  import"../chunk-5qqmndhm.js";
60
- import"../chunk-pqvvqc65.js";
61
- import"../chunk-y8fwm3z2.js";
62
- import"../chunk-pc7kra3k.js";
62
+ import"../chunk-9tpmfh3n.js";
63
63
  import"../chunk-1vg43g9q.js";
64
64
  import"../chunk-191jz8a6.js";
65
+ import"../chunk-m427qgq0.js";
65
66
  import"../chunk-czct88ht.js";
66
67
  import"../chunk-d9xbwh3h.js";
67
68
  import"../chunk-8ncg20rd.js";
68
- import"../chunk-5a4a52tq.js";
69
+ import"../chunk-0pmpwn3g.js";
69
70
  import"../chunk-ppxf7gw2.js";
70
71
  import"../chunk-w3t94hm6.js";
71
72
  import"../chunk-wx7smkn2.js";
72
- import"../chunk-m427qgq0.js";
73
- import"../chunk-m3qx2pns.js";
74
- import"../chunk-5t9gm5tt.js";
75
- import"../chunk-s1mqyqmm.js";
76
- import"../chunk-gjhrz66x.js";
73
+ import"../chunk-jt012fxq.js";
74
+ import"../chunk-fmgf9h5e.js";
75
+ import"../chunk-bs1sd0e0.js";
76
+ import"../chunk-9c9yknwt.js";
77
+ import"../chunk-5sswe5ej.js";
78
+ import"../chunk-61zptves.js";
77
79
  import"../chunk-22d3qg4x.js";
78
80
  import"../chunk-5rqqp8cr.js";
79
81
  import"../chunk-186k5yz3.js";
80
82
  import"../chunk-jmfet9r4.js";
81
83
  import"../chunk-qf954wje.js";
82
- import"../chunk-s5pj68fa.js";
84
+ import"../chunk-c4nrycdy.js";
83
85
  import"../chunk-pk539cwv.js";
84
86
  import"../chunk-c29729me.js";
85
- import"../chunk-vehcr9eb.js";
86
- import"../chunk-ewqn51gr.js";
87
- import"../chunk-zft9bzbc.js";
87
+ import"../chunk-cg7cygfj.js";
88
+ import"../chunk-88xeh6zx.js";
89
+ import"../chunk-hkbks1xm.js";
88
90
  import"../chunk-hn2r7z41.js";
89
91
  import"../chunk-h89wz928.js";
90
- import"../chunk-61zptves.js";
91
92
  import"../chunk-x0v3jd47.js";
92
93
  import"../chunk-g2ph4873.js";
93
94
  import"../chunk-mbsbxarb.js";
94
- import"../chunk-ey1p8w68.js";
95
- import"../chunk-zeykm8my.js";
95
+ import"../chunk-gaj8djsw.js";
96
+ import"../chunk-3qtk0070.js";
96
97
  import"../chunk-xtztwpkh.js";
97
- import"../chunk-c4nrycdy.js";
98
+ import"../chunk-cswhawa2.js";
98
99
  import"../chunk-qttqe1ah.js";
99
100
  import"../chunk-az95tsh3.js";
100
101
  import"../chunk-3sgvd10b.js";
101
- import"../chunk-cswhawa2.js";
102
- import"../chunk-xcrnrpfh.js";
103
- import"../chunk-stmxh0hv.js";
104
- import"../chunk-dhkc9b23.js";
105
- import"../chunk-8a8k38tz.js";
102
+ import"../chunk-dq3t5sr3.js";
103
+ import"../chunk-394zjzjs.js";
104
+ import"../chunk-3neam1y5.js";
106
105
  import"../chunk-zrvhsq7f.js";
106
+ import"../chunk-v8a1qjzp.js";
107
+ import"../chunk-brybqw5k.js";
107
108
  import"../chunk-frsz8wxd.js";
108
109
  import"../chunk-5grk14e5.js";
109
- import"../chunk-paxabbqd.js";
110
+ import"../chunk-tapdssb5.js";
110
111
  import"../chunk-rt9deb92.js";
111
- import"../chunk-3zagkr6w.js";
112
+ import"../chunk-7mhbs9yy.js";
112
113
  import"../chunk-7j4yydm2.js";
113
114
  import"../chunk-d7v97qxq.js";
114
115
  import"../chunk-xrmbhap8.js";
115
116
  import"../chunk-gfdh9kqa.js";
116
117
  import"../chunk-sgx82nnt.js";
117
- import"../chunk-k3jh8gsg.js";
118
+ import"../chunk-6hfbz4d0.js";
119
+ import"../chunk-kft7mp7z.js";
118
120
  import"../chunk-mvz89age.js";
119
121
  import"../chunk-6eqsgvxk.js";
120
122
  import"../chunk-vs2s3p8n.js";
@@ -164,4 +166,4 @@ export {
164
166
  workflowAgentStepActorId2 as workflowAgentStepActorId
165
167
  };
166
168
 
167
- //# debugId=F2704DC605A8F18964756E2164756E21
169
+ //# debugId=138D1453C3526E4264756E2164756E21
@@ -4,6 +4,6 @@
4
4
  "sourcesContent": [
5
5
  ],
6
6
  "mappings": "",
7
- "debugId": "F2704DC605A8F18964756E2164756E21",
7
+ "debugId": "138D1453C3526E4264756E2164756E21",
8
8
  "names": []
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/core",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "The ontology-first runtime for Sixb — objects, links, telemetry, actions, and provider contracts",
5
5
  "keywords": [
6
6
  "sixb",
@@ -83,6 +83,12 @@
83
83
  "import": "./dist/broker/index.js",
84
84
  "default": "./dist/broker/index.js"
85
85
  },
86
+ "./calendar": {
87
+ "types": "./dist/calendar.d.ts",
88
+ "bun": "./src/calendar.ts",
89
+ "import": "./dist/calendar.js",
90
+ "default": "./dist/calendar.js"
91
+ },
86
92
  "./deploy": {
87
93
  "types": "./dist/deploy/index.d.ts",
88
94
  "bun": "./src/deploy/index.ts",
@@ -89,7 +89,9 @@ export function resolveObjectActionSubject(params: {
89
89
  const { runtime, action, subject } = params
90
90
 
91
91
  if (subject.kind !== "object") {
92
- throw new OntologyValidationError(`Action '${action.id}' requires an object subject.`)
92
+ throw new OntologyValidationError(
93
+ `Action '${action.id}' requires an object subject: name the ${action.binding.objectType.id} it acts on, by its object type and primary id.`
94
+ )
93
95
  }
94
96
 
95
97
  const objectType = runtime.ontology.resolveObjectType(subject.objectTypeId)
@@ -345,10 +345,16 @@ async function questionState(
345
345
  .find((run) => run.status !== "failed" && run.status !== "cancelled")
346
346
  if (!waiting || !isAwaitingAnswerRun(waiting)) return {}
347
347
 
348
+ const { total } = await agents.messages.list({
349
+ projectId: waiting.projectId,
350
+ threadId: conversationId,
351
+ limit: 1,
352
+ })
348
353
  const [latest] = await agents.runs.listThreadSubagents({
349
354
  projectId: waiting.projectId,
350
355
  threadId: conversationId,
351
356
  spawnKey: waiting.spawnKey,
357
+ ...(total > 0 ? { retainedTurnsOnly: true } : {}),
352
358
  limit: 1,
353
359
  })
354
360
  if (latest && latest.threadId !== thread.id) return { ended: { reason: "replaced" } }
@@ -35,6 +35,9 @@ export type AgentRequestErrorCode =
35
35
  | "invalid_model_selection"
36
36
  | "invalid_locale"
37
37
  | "invalid_message"
38
+ | "message_not_found"
39
+ | "message_not_editable"
40
+ | "not_message_author"
38
41
  | "run_not_found"
39
42
  | "run_not_retryable"
40
43
  | "thread_not_found"
@@ -71,6 +71,8 @@ import {
71
71
  type AgentQueuedTurnStart,
72
72
  assertComputerPlaceRequest,
73
73
  dispatchAgentRun,
74
+ type EditAgentMessageInput,
75
+ editAgentMessage,
74
76
  type PromoteAgentInboxItemInput,
75
77
  promoteAgentInboxItem,
76
78
  type RequestAgentRunInput,
@@ -88,7 +90,10 @@ import { normalizeSandboxBinding } from "./sandbox"
88
90
  import { publishAgentThreadMoved } from "./streams/protocol"
89
91
  import { listSubagentThreadRuns } from "./subagent-runs"
90
92
  import {
93
+ type AgentThreadLastRunView,
94
+ type AgentThreadReadView,
91
95
  type AgentThreadView,
96
+ agentRunEndedShort,
92
97
  agentThreadViews,
93
98
  assertConversationThread,
94
99
  createAgentThreadAccessRule,
@@ -97,6 +102,8 @@ import type { AgentDescriptor } from "./types"
97
102
 
98
103
  export type ExecutionAgentRequestInput = Omit<RequestAgentRunInput, "principal">
99
104
 
105
+ export type ExecutionAgentEditMessageInput = Omit<EditAgentMessageInput, "principal">
106
+
100
107
  export type ListExecutionAgentThreadsInput = Omit<
101
108
  ListAgentThreadsInput,
102
109
  "projectId" | "ownerPrincipal" | "participantPrincipal"
@@ -160,6 +167,16 @@ export type AgentThreadsRuntime<TParams extends Record<string, unknown> = Record
160
167
  getById(threadId: string): Promise<AgentThreadView | null>
161
168
  /** The caller's own threads, or with `sharedWithMe` the ones other users added it to. */
162
169
  list(input?: ListExecutionAgentThreadsInput): Promise<ListAgentThreadViewsResult>
170
+ /**
171
+ * Record that the caller's reading of a thread reached a message, or its newest when omitted,
172
+ * which is what a Done button sends. It never moves backwards, so another device that read
173
+ * further keeps its place; a message a retry or an edit took away marks nothing. Answers the
174
+ * caller's place afterwards.
175
+ */
176
+ markRead(
177
+ threadId: string,
178
+ input?: { readonly throughMessageId?: string }
179
+ ): Promise<AgentThreadReadView>
163
180
  /**
164
181
  * The sub-agents a conversation's turns spawned, oldest first, each the thread it works in with
165
182
  * every run it took; `null` when the caller cannot read the conversation. `runId` keeps those
@@ -321,6 +338,11 @@ export interface AgentRunsRuntime {
321
338
  * or stops the running one and starts now.
322
339
  */
323
340
  send(input: SendAgentMessageInput): Promise<ExecutionAgentSendResult>
341
+ /**
342
+ * Edit an earlier user message in place, rewinding the thread to that point and starting a new
343
+ * turn from the edited prompt.
344
+ */
345
+ editMessage(input: ExecutionAgentEditMessageInput): Promise<ExecutionAgentSendResult>
324
346
  /**
325
347
  * Retry a failed or interrupted turn; only whoever asked for it can, as it runs with their rights.
326
348
  * A sub-agent's run is never retried: its turn decides whether to spawn it again.
@@ -766,7 +788,7 @@ export function createAgentRuntime<
766
788
  try {
767
789
  // Someone who left the thread no longer starts turns in it.
768
790
  if (!(await rule.read(run.threadId))) return { status: "closed" }
769
- return await startQueuedAgentTurnFromInbox(runtime, execution, run, options)
791
+ return await startQueuedAgentTurnFromInbox(runtime, execution, run, options, blobStorage)
770
792
  } catch (error) {
771
793
  console.error(`[Sixb] Could not start a queued message of Agent run '${run.id}'.`, error)
772
794
  return { status: "closed" }
@@ -796,6 +818,66 @@ export function createAgentRuntime<
796
818
  },
797
819
  }
798
820
 
821
+ /** The caller, when there is a person: system code and shared links have no reading. */
822
+ const readViewer = (): UserPrincipal | undefined =>
823
+ principal.type === "user" ? principal : undefined
824
+
825
+ /**
826
+ * A thread's newest run as a client needs it to offer Continue or Retry. A run that ended short
827
+ * also names who asked for it, from its execution: only those runs pay for that read.
828
+ */
829
+ const lastRunView = async (run: AgentRunRecord): Promise<AgentThreadLastRunView> => {
830
+ const view: AgentThreadLastRunView = {
831
+ id: run.id,
832
+ status: run.status,
833
+ ...(run.finishReason === undefined ? {} : { finishReason: run.finishReason }),
834
+ ...(run.error === undefined ? {} : { errorCode: run.error.code }),
835
+ ...(run.completedAt === undefined ? {} : { completedAt: run.completedAt }),
836
+ }
837
+ if (!agentRunEndedShort(run)) return view
838
+
839
+ const execution = await runtime.storage.executions.getById({
840
+ projectId: runtime.projectId,
841
+ id: run.executionId,
842
+ })
843
+ if (!execution?.requestedBy) return view
844
+
845
+ return { ...view, requestedBy: structuredClone(execution.requestedBy) }
846
+ }
847
+
848
+ /**
849
+ * The caller's place in each thread and its newest run, in one batched read each, plus one
850
+ * execution read per thread whose newest turn ended short. Only the paths that hand a thread to
851
+ * a person call this: an access check does not pay for it.
852
+ */
853
+ const withThreadState = async (
854
+ threads: readonly AgentThreadView[],
855
+ viewer: UserPrincipal | undefined
856
+ ): Promise<readonly AgentThreadView[]> => {
857
+ const agents = runtime.storage.agents
858
+ if (!viewer || !agents || threads.length === 0) return threads
859
+
860
+ const threadIds = threads.map((thread) => thread.id)
861
+ const [reads, runs] = await Promise.all([
862
+ agents.reads.list({ projectId: runtime.projectId, threadIds, principal: viewer }),
863
+ agents.runs.latestByThread({ projectId: runtime.projectId, threadIds }),
864
+ ])
865
+ const lastRuns = await Promise.all(runs.map(lastRunView))
866
+
867
+ const readOf = new Map(reads.map((read) => [read.threadId, read]))
868
+ const runOf = new Map(runs.map((run, index) => [run.threadId, lastRuns[index]]))
869
+
870
+ return threads.map((thread) => {
871
+ const read = readOf.get(thread.id)
872
+ const lastRun = runOf.get(thread.id)
873
+ return {
874
+ ...thread,
875
+ ...(read === undefined ? {} : { read }),
876
+ ...(lastRun === undefined ? {} : { lastRun }),
877
+ }
878
+ })
879
+ }
880
+
799
881
  /** Move a conversation's sandbox out of recovery, as its owner chose: fresh, or as it was. */
800
882
  const recoverSandbox = async (
801
883
  threadId: string,
@@ -818,25 +900,23 @@ export function createAgentRuntime<
818
900
  }
819
901
  const thread = readable.thread
820
902
  const sandboxState = await transition(storage)
821
- const [view] = await agentThreadViews(runtime, [{ ...thread, sandboxState }])
903
+ const [view] = await withThreadState(
904
+ await agentThreadViews(runtime, [{ ...thread, sandboxState }]),
905
+ readViewer()
906
+ )
822
907
  return view ?? thread
823
908
  }
824
909
 
825
- const ownedComputerThread = async (threadId: string): Promise<AgentThreadRecord> => {
910
+ const ownedMovableThread = async (threadId: string): Promise<AgentThreadRecord> => {
826
911
  const readable = await rule.read(threadId)
827
912
  if (!readable) throw new AgentRequestError("thread_not_found", "[Sixb] Agent thread not found.")
913
+ assertConversationThread(readable.thread)
828
914
  if (readable.access !== "owner") {
829
915
  throw new AgentRequestError(
830
916
  "not_thread_owner",
831
917
  `[Sixb] Only the owner of Agent thread '${threadId}' moves it.`
832
918
  )
833
919
  }
834
- if (readable.thread.runsOn !== "computer") {
835
- throw new AgentRequestError(
836
- "invalid_message",
837
- `[Sixb] Agent thread '${threadId}' runs in the cloud, on no computer.`
838
- )
839
- }
840
920
  return readable.thread
841
921
  }
842
922
 
@@ -862,7 +942,9 @@ export function createAgentRuntime<
862
942
  throw error instanceof AgentStorageError && error.code === "active_run_exists"
863
943
  ? new AgentRequestError(
864
944
  "active_run_exists",
865
- "[Sixb] A turn is running on the computer: stop it, or let it end, first."
945
+ thread.runsOn === "computer"
946
+ ? "[Sixb] A turn is running on the computer: stop it, or let it end, first."
947
+ : "[Sixb] A turn is running in the cloud: stop it, or let it end, first."
866
948
  )
867
949
  : error
868
950
  })
@@ -912,23 +994,29 @@ export function createAgentRuntime<
912
994
  })
913
995
  ),
914
996
  moveToComputer: async (threadId, computer) => {
915
- const thread = await ownedComputerThread(threadId)
997
+ const thread = await ownedMovableThread(threadId)
916
998
  const moves = movesComputerPlace(thread, computer)
917
999
  const moved = await moveThread(thread, moves, (agents) =>
918
1000
  agents.threads.assignComputer({ projectId: runtime.projectId, id: threadId, computer })
919
1001
  )
920
1002
  if (moves) await announceThreadMoved(thread)
921
- const [view] = await agentThreadViews(runtime, [moved])
1003
+ const [view] = await withThreadState(await agentThreadViews(runtime, [moved]), readViewer())
922
1004
  return view ?? moved
923
1005
  },
924
1006
  moveToCloud: async (threadId) => {
925
- const thread = await ownedComputerThread(threadId)
1007
+ const thread = await ownedMovableThread(threadId)
1008
+ if (thread.runsOn !== "computer") {
1009
+ throw new AgentRequestError(
1010
+ "invalid_message",
1011
+ `[Sixb] Agent thread '${threadId}' runs in the cloud, on no computer.`
1012
+ )
1013
+ }
926
1014
  const { thread: moved, queued } = await moveThread(thread, true, (agents) =>
927
1015
  agents.threads.moveToCloud({ projectId: runtime.projectId, id: threadId })
928
1016
  )
929
1017
  if (queued) await dispatchAgentRun(runtime, requireAgents(), queued.id)
930
1018
  await announceThreadMoved(thread)
931
- const [view] = await agentThreadViews(runtime, [moved])
1019
+ const [view] = await withThreadState(await agentThreadViews(runtime, [moved]), readViewer())
932
1020
  return view ?? moved
933
1021
  },
934
1022
  create: async (input) => {
@@ -976,7 +1064,8 @@ export function createAgentRuntime<
976
1064
  ...(input.runsOn === undefined ? {} : { runsOn: input.runsOn }),
977
1065
  ...(input.computer === undefined ? {} : { computer: input.computer }),
978
1066
  })
979
- return { ...created, participants: [] }
1067
+ const [view] = await withThreadState([{ ...created, participants: [] }], readViewer())
1068
+ return view ?? { ...created, participants: [] }
980
1069
  },
981
1070
  listChildren: async (threadId, { runId } = {}) => {
982
1071
  const thread = await getVisibleThreadRecord(threadId)
@@ -1015,10 +1104,41 @@ export function createAgentRuntime<
1015
1104
  ownerPrincipal: principal,
1016
1105
  sandbox,
1017
1106
  })
1018
- const [view] = await agentThreadViews(runtime, [fork])
1107
+ const [view] = await withThreadState(await agentThreadViews(runtime, [fork]), readViewer())
1019
1108
  return view ?? { ...fork, participants: [] }
1020
1109
  },
1021
- getById: getVisibleThreadRecord,
1110
+ getById: async (threadId) => {
1111
+ const thread = await getVisibleThreadRecord(threadId)
1112
+ if (!thread) return null
1113
+ const [view] = await withThreadState([thread], readViewer())
1114
+ return view ?? null
1115
+ },
1116
+ markRead: async (threadId, input = {}) => {
1117
+ const readable = await rule.read(threadId)
1118
+ if (!readable) {
1119
+ throw new AgentRequestError("thread_not_found", "[Sixb] Agent thread not found.")
1120
+ }
1121
+ assertConversationThread(readable.thread)
1122
+ const reader = settingsPrincipal()
1123
+ if (reader.type !== "user") {
1124
+ throw new AgentRequestError("agent_not_found", "[Sixb] The project Agent is unavailable.")
1125
+ }
1126
+ if (input.throughMessageId !== undefined && input.throughMessageId.trim().length === 0) {
1127
+ throw new AgentRequestError(
1128
+ "invalid_message",
1129
+ "[Sixb] 'throughMessageId' must name a message of the thread."
1130
+ )
1131
+ }
1132
+
1133
+ return requireAgents().reads.mark({
1134
+ projectId: runtime.projectId,
1135
+ threadId,
1136
+ principal: reader,
1137
+ ...(input.throughMessageId === undefined
1138
+ ? {}
1139
+ : { throughMessageId: input.throughMessageId }),
1140
+ })
1141
+ },
1022
1142
  list: async ({ sharedWithMe, ...input } = {}) => {
1023
1143
  assertNoAgentSelector(input)
1024
1144
  const none = { threads: [], hasMore: false, total: 0 }
@@ -1038,7 +1158,8 @@ export function createAgentRuntime<
1038
1158
  ? { participantPrincipal: caller }
1039
1159
  : { ownerPrincipal: caller }),
1040
1160
  })
1041
- return { ...result, threads: await agentThreadViews(runtime, result.threads) }
1161
+ const views = await agentThreadViews(runtime, result.threads)
1162
+ return { ...result, threads: await withThreadState(views, readViewer()) }
1042
1163
  },
1043
1164
  participants: {
1044
1165
  add: (threadId, users) =>
@@ -1070,7 +1191,12 @@ export function createAgentRuntime<
1070
1191
  `[Sixb] Agent thread '${threadId}' not found.`
1071
1192
  )
1072
1193
  }
1073
- return promoteAgentInboxItem(runtime, execution, { ...input, threadId, itemId })
1194
+ return promoteAgentInboxItem(
1195
+ runtime,
1196
+ execution,
1197
+ { ...input, threadId, itemId },
1198
+ blobStorage
1199
+ )
1074
1200
  },
1075
1201
  remove: async (threadId, itemId) => {
1076
1202
  if (!(await getVisibleThreadRecord(threadId))) {
@@ -1095,7 +1221,7 @@ export function createAgentRuntime<
1095
1221
  `[Sixb] Agent thread '${input.threadId}' not found.`
1096
1222
  )
1097
1223
  }
1098
- const result = await sendAgentMessage(runtime, execution, turnModels, input)
1224
+ const result = await sendAgentMessage(runtime, execution, turnModels, input, blobStorage)
1099
1225
  return result.kind === "turn"
1100
1226
  ? { ...result, run: await attachRunView(runtime, result.run) }
1101
1227
  : result
@@ -1119,6 +1245,30 @@ export function createAgentRuntime<
1119
1245
  })
1120
1246
  return { ...result, run: await attachRunView(runtime, result.run) }
1121
1247
  },
1248
+ editMessage: async (input) => {
1249
+ assertNoAgentSelector(input)
1250
+ const agent = getAgent()
1251
+ if (!agent) {
1252
+ throw new AgentRequestError("agent_not_found", "[Sixb] The project Agent is unavailable.")
1253
+ }
1254
+ assertAuthorized(runtime, { kind: "agent.run" })
1255
+ if (!(await getVisibleThreadRecord(input.threadId))) {
1256
+ throw new AgentRequestError(
1257
+ "thread_not_found",
1258
+ `[Sixb] Agent thread '${input.threadId}' not found.`
1259
+ )
1260
+ }
1261
+ const result = await editAgentMessage(
1262
+ runtime,
1263
+ execution,
1264
+ turnModels,
1265
+ { ...input, principal },
1266
+ blobStorage
1267
+ )
1268
+ return result.kind === "turn"
1269
+ ? { ...result, run: await attachRunView(runtime, result.run) }
1270
+ : result
1271
+ },
1122
1272
  retry: async (runId) => {
1123
1273
  const failedRun = await getControllableRun(runId, "retry")
1124
1274
  const agent = getAgent()
@@ -194,6 +194,9 @@ export {
194
194
  AGENT_MESSAGE_DELIVERIES,
195
195
  type AgentMessageDelivery,
196
196
  type AgentQueuedTurnStart,
197
+ type EditAgentMessageInput,
198
+ editAgentMessage,
199
+ isEditableAgentMessage,
197
200
  isRetryableAgentRun,
198
201
  type PromoteAgentInboxItemInput,
199
202
  promoteAgentInboxItem,
@@ -341,6 +344,7 @@ export type {
341
344
  AgentRunControlStreamId,
342
345
  AgentRunFailure,
343
346
  AgentRunFinishedEvent,
347
+ AgentRunStepsEvent,
344
348
  AgentRunStreamEvent,
345
349
  AgentRunStreamId,
346
350
  } from "./streams/protocol"
@@ -11,6 +11,7 @@ import { question } from "../models/decision/questions"
11
11
  import { supportsQuestion } from "../models/decision/validation"
12
12
  import { RuntimeError } from "../runtime/errors"
13
13
  import type { ConversationAgentRunRecord } from "../storage/agents"
14
+ import { type AgentTurnPlace, runPlaceKey } from "../storage/agents/provider"
14
15
 
15
16
  /** Moving up needs no confidence: a turn goes to `heavy` from this probability. */
16
17
  const HEAVY_FROM = 0.4
@@ -58,8 +59,14 @@ export interface TurnModelChoice {
58
59
  }
59
60
 
60
61
  export interface TurnModelRouter {
61
- /** The model of a turn that names none, given the thread's previous turn. */
62
- choose(text: string, previous: ConversationAgentRunRecord | undefined): Promise<TurnModelChoice>
62
+ /**
63
+ * The model of a turn that names none, given the thread's previous turn and where this one runs.
64
+ */
65
+ choose(
66
+ text: string,
67
+ previous: ConversationAgentRunRecord | undefined,
68
+ place: AgentTurnPlace
69
+ ): Promise<TurnModelChoice>
63
70
  }
64
71
 
65
72
  /**
@@ -86,14 +93,14 @@ export function createTurnModelRouter(
86
93
  if (!language || language.tiers.length === 0 || !models?.decision) return undefined
87
94
 
88
95
  return {
89
- async choose(text, previous) {
96
+ async choose(text, previous, place) {
90
97
  // Files sent alone leave nothing to judge: the turn aims for standard, and the cache rule
91
98
  // keeps a warm thread on its model.
92
99
  const tierProbabilities = text.trim() ? await askTier(decision, text) : undefined
93
100
  const tier = tierProbabilities ? tierFor(tierProbabilities) : "standard"
94
101
 
95
102
  return {
96
- model: turnModel(language, tier, previous),
103
+ model: turnModel(language, tier, previous, place),
97
104
  ...(tierProbabilities ? { tierProbabilities } : {}),
98
105
  }
99
106
  },
@@ -148,10 +155,11 @@ function tierFor(probabilities: LanguageModelTierProbabilities): LanguageModelTi
148
155
  function turnModel(
149
156
  language: LanguageModelCatalog,
150
157
  tier: LanguageModelTier,
151
- previous: ConversationAgentRunRecord | undefined
158
+ previous: ConversationAgentRunRecord | undefined,
159
+ place: AgentTurnPlace
152
160
  ): LanguageModelEntry {
153
161
  const target = language.getByTier(tier)
154
- const last = previous && previousTurn(language, previous)
162
+ const last = previous && previousTurn(language, previous, place)
155
163
  if (!last) return target
156
164
 
157
165
  const change = tierRank(target.tier ?? tier) - tierRank(last.tier)
@@ -170,7 +178,8 @@ interface PreviousTurn {
170
178
  /** An older run without a tier takes its model's; one without either counts as no turn at all. */
171
179
  function previousTurn(
172
180
  language: LanguageModelCatalog,
173
- run: ConversationAgentRunRecord
181
+ run: ConversationAgentRunRecord,
182
+ place: AgentTurnPlace
174
183
  ): PreviousTurn | undefined {
175
184
  if (!run.spec) return undefined
176
185
 
@@ -178,9 +187,16 @@ function previousTurn(
178
187
  const tier = run.spec.tier ?? model?.tier
179
188
  if (tier === undefined) return undefined
180
189
 
181
- // A run that never recorded its end counts from its start, or from its admission.
190
+ // A run that never recorded its end counts from its start, or from its admission. A turn in
191
+ // another workspace sent another system prompt, so its cache does not hold this turn's; one
192
+ // where this turn runs does, however the thread moved in between.
182
193
  const lastCallAt = run.completedAt ?? run.startedAt ?? run.createdAt
183
- return { model, tier, cacheWarm: Date.now() - lastCallAt.getTime() < PROMPT_CACHE_TTL_MS }
194
+ const samePlace = runPlaceKey(run.spec) === runPlaceKey(place)
195
+ return {
196
+ model,
197
+ tier,
198
+ cacheWarm: samePlace && Date.now() - lastCallAt.getTime() < PROMPT_CACHE_TTL_MS,
199
+ }
184
200
  }
185
201
 
186
202
  function tierRank(tier: LanguageModelTier): number {