@sixb/core 0.2.0 → 0.2.2

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 (337) hide show
  1. package/dist/actions/index.js +30 -30
  2. package/dist/agents/cancel.d.ts.map +1 -1
  3. package/dist/agents/index.d.ts +5 -3
  4. package/dist/agents/index.d.ts.map +1 -1
  5. package/dist/agents/index.js +39 -33
  6. package/dist/agents/index.js.map +1 -1
  7. package/dist/agents/run-plan.d.ts +15 -1
  8. package/dist/agents/run-plan.d.ts.map +1 -1
  9. package/dist/agents/run-session-http.d.ts.map +1 -1
  10. package/dist/agents/run-session-serve.d.ts.map +1 -1
  11. package/dist/agents/run-session.d.ts +14 -2
  12. package/dist/agents/run-session.d.ts.map +1 -1
  13. package/dist/agents/skills.d.ts +3 -0
  14. package/dist/agents/skills.d.ts.map +1 -1
  15. package/dist/agents/step-limits.d.ts +6 -0
  16. package/dist/agents/step-limits.d.ts.map +1 -1
  17. package/dist/agents/streams/index.js +1 -1
  18. package/dist/agents/streams/internal.js +1 -1
  19. package/dist/agents/streams/protocol.d.ts +8 -2
  20. package/dist/agents/streams/protocol.d.ts.map +1 -1
  21. package/dist/agents/tool-files.d.ts +3 -1
  22. package/dist/agents/tool-files.d.ts.map +1 -1
  23. package/dist/agents/validation.d.ts +1 -1
  24. package/dist/agents/validation.d.ts.map +1 -1
  25. package/dist/agents/web.d.ts +47 -0
  26. package/dist/agents/web.d.ts.map +1 -0
  27. package/dist/artifacts/publish/index.js +17 -17
  28. package/dist/auth/index.js +3 -3
  29. package/dist/authorization/index.js +2 -2
  30. package/dist/authorization/resolve.d.ts +4 -3
  31. package/dist/authorization/resolve.d.ts.map +1 -1
  32. package/dist/authorization/types.d.ts +5 -5
  33. package/dist/authorization/types.d.ts.map +1 -1
  34. package/dist/bootstrap/index.js +38 -38
  35. package/dist/{chunk-neftrg0n.js → chunk-0j3crh1w.js} +2 -2
  36. package/dist/{chunk-8dcfj58k.js → chunk-2ajw5rz0.js} +14 -10
  37. package/dist/chunk-2ajw5rz0.js.map +18 -0
  38. package/dist/{chunk-23s66j86.js → chunk-31kcqmhf.js} +1 -1
  39. package/dist/{chunk-nghc7eq0.js → chunk-3723kgba.js} +1 -1
  40. package/dist/{chunk-fdkpkkpw.js → chunk-3sqqhpr7.js} +5 -5
  41. package/dist/{chunk-m3qe54bb.js → chunk-4bm0caep.js} +1 -1
  42. package/dist/{chunk-ztf5vtmp.js → chunk-4s753g3k.js} +41 -10
  43. package/dist/chunk-4s753g3k.js.map +12 -0
  44. package/dist/{chunk-fntqb7qy.js → chunk-57g0215c.js} +1 -1
  45. package/dist/{chunk-8wsjr52f.js → chunk-5wtnmpze.js} +1 -1
  46. package/dist/{chunk-edx8xcsm.js → chunk-7z5rkf0m.js} +29 -6
  47. package/dist/chunk-7z5rkf0m.js.map +13 -0
  48. package/dist/{chunk-2pk5hjj9.js → chunk-80gym75n.js} +1 -1
  49. package/dist/{chunk-qbrmpgvv.js → chunk-9whfmsfk.js} +1 -1
  50. package/dist/{chunk-qya541bk.js → chunk-a5v4gjdx.js} +31 -28
  51. package/dist/{chunk-qya541bk.js.map → chunk-a5v4gjdx.js.map} +4 -4
  52. package/dist/{chunk-he7g39e5.js → chunk-a7aa0nzj.js} +7 -7
  53. package/dist/{chunk-tvefbgvw.js → chunk-az95tsh3.js} +4 -2
  54. package/dist/chunk-az95tsh3.js.map +11 -0
  55. package/dist/{chunk-7hd2ez3q.js → chunk-c4nrycdy.js} +1 -1
  56. package/dist/{chunk-ekkpzcka.js → chunk-c706qvyc.js} +36 -9
  57. package/dist/chunk-c706qvyc.js.map +11 -0
  58. package/dist/{chunk-n54k068r.js → chunk-c7cfe31p.js} +7 -7
  59. package/dist/{chunk-qsg8rw04.js → chunk-d04g36fw.js} +1 -1
  60. package/dist/{chunk-hjy3dsws.js → chunk-dsv783c3.js} +305 -32
  61. package/dist/{chunk-hjy3dsws.js.map → chunk-dsv783c3.js.map} +12 -10
  62. package/dist/{chunk-peggaard.js → chunk-e6xgz4h4.js} +20 -2
  63. package/dist/{chunk-peggaard.js.map → chunk-e6xgz4h4.js.map} +5 -3
  64. package/dist/{chunk-e99kp9jh.js → chunk-eqgr6nsa.js} +86 -30
  65. package/dist/{chunk-e99kp9jh.js.map → chunk-eqgr6nsa.js.map} +10 -9
  66. package/dist/{chunk-f2w6328x.js → chunk-f1h34y3r.js} +6 -6
  67. package/dist/{chunk-9rh8ncs5.js → chunk-fwsvshr5.js} +1 -1
  68. package/dist/{chunk-c78jjzhy.js → chunk-ga63a3dz.js} +6 -6
  69. package/dist/{chunk-c78jjzhy.js.map → chunk-ga63a3dz.js.map} +2 -2
  70. package/dist/{chunk-cgznz22f.js → chunk-gkv8r794.js} +2 -2
  71. package/dist/{chunk-d3t26vah.js → chunk-j1ny5fwh.js} +35 -11
  72. package/dist/chunk-j1ny5fwh.js.map +15 -0
  73. package/dist/{chunk-8hvfs0fr.js → chunk-j8thxj7w.js} +4 -4
  74. package/dist/{chunk-855n80en.js → chunk-jjmggm9a.js} +1 -1
  75. package/dist/{chunk-31khg3g0.js → chunk-kkjfve0t.js} +73 -2
  76. package/dist/{chunk-31khg3g0.js.map → chunk-kkjfve0t.js.map} +3 -3
  77. package/dist/{chunk-fb3m4sa1.js → chunk-m2vh8gh0.js} +8 -14
  78. package/dist/{chunk-fb3m4sa1.js.map → chunk-m2vh8gh0.js.map} +3 -3
  79. package/dist/{chunk-vkweppkw.js → chunk-mbc5hvnj.js} +3 -3
  80. package/dist/{chunk-jk97v21j.js → chunk-n4zzaf6q.js} +3 -2
  81. package/dist/chunk-n4zzaf6q.js.map +10 -0
  82. package/dist/{chunk-y2x2935j.js → chunk-nh26e7c5.js} +2 -2
  83. package/dist/{chunk-jhbk10wf.js → chunk-q9nkpr8k.js} +1 -1
  84. package/dist/{chunk-47e09r7z.js → chunk-qttqe1ah.js} +86 -6
  85. package/dist/{chunk-47e09r7z.js.map → chunk-qttqe1ah.js.map} +5 -4
  86. package/dist/{chunk-9mab3dvg.js → chunk-s038wa5v.js} +9 -1
  87. package/dist/{chunk-9mab3dvg.js.map → chunk-s038wa5v.js.map} +3 -3
  88. package/dist/{chunk-3x3bebz7.js → chunk-s7j8ewqv.js} +161 -62
  89. package/dist/{chunk-3x3bebz7.js.map → chunk-s7j8ewqv.js.map} +7 -6
  90. package/dist/{chunk-dz7a4t3a.js → chunk-twfreyxr.js} +5 -10
  91. package/dist/{chunk-dz7a4t3a.js.map → chunk-twfreyxr.js.map} +4 -4
  92. package/dist/{chunk-semf1yqn.js → chunk-w1btn96n.js} +51 -26
  93. package/dist/{chunk-semf1yqn.js.map → chunk-w1btn96n.js.map} +6 -6
  94. package/dist/{chunk-fg1db9xx.js → chunk-wkq3kvzd.js} +5 -5
  95. package/dist/chunk-wkq3kvzd.js.map +10 -0
  96. package/dist/{chunk-xj97s5js.js → chunk-wrjx1fqz.js} +6 -6
  97. package/dist/{chunk-agn8d8ys.js → chunk-xtztwpkh.js} +1 -1
  98. package/dist/{chunk-0g5nyx0k.js → chunk-zeykm8my.js} +2 -2
  99. package/dist/connectors/connections/runs.d.ts +7 -0
  100. package/dist/connectors/connections/runs.d.ts.map +1 -1
  101. package/dist/datasets/execution.d.ts.map +1 -1
  102. package/dist/events/index.js +1 -1
  103. package/dist/events/selectors/index.js +1 -1
  104. package/dist/events/selectors/predicate.d.ts.map +1 -1
  105. package/dist/events/types/datasets.d.ts +6 -0
  106. package/dist/events/types/datasets.d.ts.map +1 -1
  107. package/dist/execution/agent.js +30 -30
  108. package/dist/execution/object-reader-security.d.ts.map +1 -1
  109. package/dist/execution/primitive.js +30 -30
  110. package/dist/execution/request.js +31 -31
  111. package/dist/index.d.ts +2 -2
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +42 -42
  114. package/dist/lake-storage/in-memory.d.ts.map +1 -1
  115. package/dist/lake-storage/index.d.ts +2 -2
  116. package/dist/lake-storage/index.d.ts.map +1 -1
  117. package/dist/lake-storage/index.js +6 -2
  118. package/dist/lake-storage/index.js.map +1 -1
  119. package/dist/lake-storage/source-ordering.d.ts +7 -0
  120. package/dist/lake-storage/source-ordering.d.ts.map +1 -1
  121. package/dist/lake-storage/types.d.ts +18 -0
  122. package/dist/lake-storage/types.d.ts.map +1 -1
  123. package/dist/lake-storage/version-inputs.d.ts +11 -3
  124. package/dist/lake-storage/version-inputs.d.ts.map +1 -1
  125. package/dist/materializer/index.js +16 -16
  126. package/dist/models/catalog.d.ts +16 -0
  127. package/dist/models/catalog.d.ts.map +1 -1
  128. package/dist/models/definitions.d.ts +1 -1
  129. package/dist/models/definitions.d.ts.map +1 -1
  130. package/dist/models/execution/index.js +18 -18
  131. package/dist/models/execution/model-call-recorder.d.ts +1 -1
  132. package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
  133. package/dist/models/execution/web-search.d.ts +7 -0
  134. package/dist/models/execution/web-search.d.ts.map +1 -0
  135. package/dist/models/index.d.ts +3 -1
  136. package/dist/models/index.d.ts.map +1 -1
  137. package/dist/models/index.js +5 -3
  138. package/dist/models/index.js.map +1 -1
  139. package/dist/models/language-model.d.ts +12 -0
  140. package/dist/models/language-model.d.ts.map +1 -1
  141. package/dist/models/web-search-model.d.ts +66 -0
  142. package/dist/models/web-search-model.d.ts.map +1 -0
  143. package/dist/objects/index.js +30 -30
  144. package/dist/objects/query/executor.d.ts.map +1 -1
  145. package/dist/objects/query/index.d.ts +1 -0
  146. package/dist/objects/query/index.d.ts.map +1 -1
  147. package/dist/objects/query/index.js +19 -16
  148. package/dist/objects/query/index.js.map +1 -1
  149. package/dist/objects/query/sort-ties.d.ts +11 -0
  150. package/dist/objects/query/sort-ties.d.ts.map +1 -0
  151. package/dist/pipelines/index.js +19 -19
  152. package/dist/pipelines/run-dispatch.d.ts +2 -0
  153. package/dist/pipelines/run-dispatch.d.ts.map +1 -1
  154. package/dist/projections/internal.js +16 -16
  155. package/dist/runtime/create.d.ts +1 -1
  156. package/dist/runtime/create.d.ts.map +1 -1
  157. package/dist/runtime/internal.js +22 -22
  158. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  159. package/dist/schedules/index.js +2 -2
  160. package/dist/security/index.d.ts +1 -0
  161. package/dist/security/index.d.ts.map +1 -1
  162. package/dist/security/registry.d.ts +2 -0
  163. package/dist/security/registry.d.ts.map +1 -1
  164. package/dist/security/view-conditions.d.ts.map +1 -1
  165. package/dist/security/visibility-keys.d.ts +19 -0
  166. package/dist/security/visibility-keys.d.ts.map +1 -0
  167. package/dist/shares/internal.js +16 -16
  168. package/dist/storage/agents/in-memory.d.ts +8 -2
  169. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  170. package/dist/storage/agents/index.d.ts +1 -1
  171. package/dist/storage/agents/index.d.ts.map +1 -1
  172. package/dist/storage/agents/provider.d.ts +8 -2
  173. package/dist/storage/agents/provider.d.ts.map +1 -1
  174. package/dist/storage/agents/provider.js +12 -6
  175. package/dist/storage/agents/provider.js.map +1 -1
  176. package/dist/storage/agents/types.d.ts +42 -2
  177. package/dist/storage/agents/types.d.ts.map +1 -1
  178. package/dist/storage/ai-cost/provider.js +4 -4
  179. package/dist/storage/ai-limits/enforcement.js +3 -3
  180. package/dist/storage/ai-limits/provider.js +2 -2
  181. package/dist/storage/connector-connections/provider.js +3 -3
  182. package/dist/storage/connector-connections/provider.js.map +3 -3
  183. package/dist/storage/file-upload-sessions/provider.js +4 -4
  184. package/dist/storage/index.d.ts +2 -2
  185. package/dist/storage/index.d.ts.map +1 -1
  186. package/dist/storage/index.js +15 -15
  187. package/dist/storage/internal.d.ts +2 -0
  188. package/dist/storage/internal.d.ts.map +1 -1
  189. package/dist/storage/internal.js +8 -4
  190. package/dist/storage/internal.js.map +1 -1
  191. package/dist/storage/migrations/types.d.ts +6 -0
  192. package/dist/storage/migrations/types.d.ts.map +1 -1
  193. package/dist/storage/objects/in-memory/query.d.ts.map +1 -1
  194. package/dist/storage/objects/index.d.ts +1 -1
  195. package/dist/storage/objects/index.d.ts.map +1 -1
  196. package/dist/storage/objects/query-preparation.d.ts +13 -0
  197. package/dist/storage/objects/query-preparation.d.ts.map +1 -1
  198. package/dist/storage/objects/read-scope.d.ts.map +1 -1
  199. package/dist/storage/objects/types.d.ts +52 -0
  200. package/dist/storage/objects/types.d.ts.map +1 -1
  201. package/dist/storage/pipeline-runs/in-memory.d.ts.map +1 -1
  202. package/dist/storage/pipeline-runs/transitions.d.ts +7 -0
  203. package/dist/storage/pipeline-runs/transitions.d.ts.map +1 -0
  204. package/dist/storage/share-grants/provider.js +2 -2
  205. package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
  206. package/dist/storage/sync-runs/transitions.d.ts +7 -0
  207. package/dist/storage/sync-runs/transitions.d.ts.map +1 -0
  208. package/dist/storage/workflow-runs/provider.js +4 -4
  209. package/dist/syncs/index.js +20 -20
  210. package/dist/syncs/run-dispatch.d.ts +2 -0
  211. package/dist/syncs/run-dispatch.d.ts.map +1 -1
  212. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  213. package/dist/testing/ai-limit-storage-contract.d.ts.map +1 -1
  214. package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
  215. package/dist/testing/connector-connection-storage-contract.d.ts.map +1 -1
  216. package/dist/testing/dataset-sequence-contract.d.ts.map +1 -1
  217. package/dist/testing/index.js +552 -61
  218. package/dist/testing/index.js.map +11 -11
  219. package/dist/testing/lake-changes-contract.d.ts.map +1 -1
  220. package/dist/testing/lake-storage-contract.d.ts.map +1 -1
  221. package/dist/testing/object-conditional-read-scope-contract.d.ts.map +1 -1
  222. package/dist/testing/object-query-contract.d.ts.map +1 -1
  223. package/dist/webhooks/internal.js +16 -16
  224. package/dist/workers/index.d.ts +1 -0
  225. package/dist/workers/index.d.ts.map +1 -1
  226. package/dist/workers/index.js +12 -2
  227. package/dist/workers/index.js.map +5 -4
  228. package/dist/workers/unstarted-run.d.ts +10 -0
  229. package/dist/workers/unstarted-run.d.ts.map +1 -0
  230. package/dist/workflows/index.js +34 -34
  231. package/package.json +1 -1
  232. package/src/agents/README.md +2 -1
  233. package/src/agents/cancel.ts +7 -1
  234. package/src/agents/index.ts +9 -1
  235. package/src/agents/run-plan.ts +31 -0
  236. package/src/agents/run-session-http.ts +15 -12
  237. package/src/agents/run-session-serve.ts +8 -2
  238. package/src/agents/run-session.ts +31 -11
  239. package/src/agents/skills.ts +3 -0
  240. package/src/agents/step-limits.ts +6 -0
  241. package/src/agents/streams/protocol.ts +9 -4
  242. package/src/agents/tool-files.ts +11 -3
  243. package/src/agents/validation.ts +9 -0
  244. package/src/agents/web.ts +218 -0
  245. package/src/authorization/resolve.ts +9 -11
  246. package/src/authorization/types.ts +5 -5
  247. package/src/connectors/connections/runs.ts +42 -5
  248. package/src/datasets/execution.ts +2 -0
  249. package/src/events/selectors/predicate.ts +15 -0
  250. package/src/events/types/datasets.ts +6 -0
  251. package/src/execution/object-reader-security.ts +4 -9
  252. package/src/index.ts +2 -0
  253. package/src/lake-storage/in-memory.ts +30 -20
  254. package/src/lake-storage/index.ts +2 -1
  255. package/src/lake-storage/source-ordering.ts +31 -4
  256. package/src/lake-storage/types.ts +18 -0
  257. package/src/lake-storage/version-inputs.ts +21 -5
  258. package/src/models/catalog.ts +52 -3
  259. package/src/models/definitions.ts +2 -0
  260. package/src/models/execution/README.md +22 -2
  261. package/src/models/execution/model-call-recorder.ts +1 -1
  262. package/src/models/execution/web-search.ts +186 -0
  263. package/src/models/index.ts +12 -0
  264. package/src/models/language-model.ts +12 -0
  265. package/src/models/web-search-model.ts +152 -0
  266. package/src/objects/query/executor.ts +7 -3
  267. package/src/objects/query/index.ts +1 -0
  268. package/src/objects/query/sort-ties.ts +16 -0
  269. package/src/pipelines/run-dispatch.ts +53 -6
  270. package/src/runtime/create.ts +3 -2
  271. package/src/runtime/resolve-definitions.ts +4 -0
  272. package/src/security/index.ts +1 -0
  273. package/src/security/registry.ts +2 -0
  274. package/src/security/view-conditions.ts +4 -3
  275. package/src/security/visibility-keys.ts +144 -0
  276. package/src/storage/agents/in-memory.ts +29 -2
  277. package/src/storage/agents/index.ts +2 -0
  278. package/src/storage/agents/provider.ts +57 -1
  279. package/src/storage/agents/types.ts +45 -2
  280. package/src/storage/connector-connections/in-memory.ts +2 -2
  281. package/src/storage/connector-connections/provider/connections.ts +2 -2
  282. package/src/storage/index.ts +4 -0
  283. package/src/storage/internal.ts +2 -0
  284. package/src/storage/migrations/types.ts +6 -0
  285. package/src/storage/objects/in-memory/query.ts +5 -2
  286. package/src/storage/objects/index.ts +2 -0
  287. package/src/storage/objects/query-preparation.ts +59 -1
  288. package/src/storage/objects/read-scope.ts +108 -2
  289. package/src/storage/objects/types.ts +43 -0
  290. package/src/storage/pipeline-runs/in-memory.ts +2 -5
  291. package/src/storage/pipeline-runs/transitions.ts +14 -0
  292. package/src/storage/sync-runs/in-memory.ts +2 -5
  293. package/src/storage/sync-runs/transitions.ts +11 -0
  294. package/src/syncs/run-dispatch.ts +68 -13
  295. package/src/testing/agent-storage-contract.ts +70 -0
  296. package/src/testing/ai-limit-storage-contract.ts +11 -1
  297. package/src/testing/ai-usage-storage-contract.ts +15 -2
  298. package/src/testing/connector-connection-storage-contract.ts +23 -0
  299. package/src/testing/dataset-sequence-contract.ts +81 -0
  300. package/src/testing/lake-changes-contract.ts +2 -1
  301. package/src/testing/lake-storage-contract.ts +112 -0
  302. package/src/testing/object-conditional-read-scope-contract.ts +267 -5
  303. package/src/testing/object-query-contract.ts +75 -0
  304. package/src/workers/index.ts +1 -0
  305. package/src/workers/unstarted-run.ts +18 -0
  306. package/dist/chunk-8dcfj58k.js.map +0 -18
  307. package/dist/chunk-d3t26vah.js.map +0 -15
  308. package/dist/chunk-edx8xcsm.js.map +0 -13
  309. package/dist/chunk-ekkpzcka.js.map +0 -11
  310. package/dist/chunk-fg1db9xx.js.map +0 -10
  311. package/dist/chunk-jk97v21j.js.map +0 -10
  312. package/dist/chunk-tvefbgvw.js.map +0 -11
  313. package/dist/chunk-ztf5vtmp.js.map +0 -12
  314. /package/dist/{chunk-neftrg0n.js.map → chunk-0j3crh1w.js.map} +0 -0
  315. /package/dist/{chunk-23s66j86.js.map → chunk-31kcqmhf.js.map} +0 -0
  316. /package/dist/{chunk-nghc7eq0.js.map → chunk-3723kgba.js.map} +0 -0
  317. /package/dist/{chunk-fdkpkkpw.js.map → chunk-3sqqhpr7.js.map} +0 -0
  318. /package/dist/{chunk-m3qe54bb.js.map → chunk-4bm0caep.js.map} +0 -0
  319. /package/dist/{chunk-fntqb7qy.js.map → chunk-57g0215c.js.map} +0 -0
  320. /package/dist/{chunk-8wsjr52f.js.map → chunk-5wtnmpze.js.map} +0 -0
  321. /package/dist/{chunk-2pk5hjj9.js.map → chunk-80gym75n.js.map} +0 -0
  322. /package/dist/{chunk-qbrmpgvv.js.map → chunk-9whfmsfk.js.map} +0 -0
  323. /package/dist/{chunk-he7g39e5.js.map → chunk-a7aa0nzj.js.map} +0 -0
  324. /package/dist/{chunk-7hd2ez3q.js.map → chunk-c4nrycdy.js.map} +0 -0
  325. /package/dist/{chunk-n54k068r.js.map → chunk-c7cfe31p.js.map} +0 -0
  326. /package/dist/{chunk-qsg8rw04.js.map → chunk-d04g36fw.js.map} +0 -0
  327. /package/dist/{chunk-f2w6328x.js.map → chunk-f1h34y3r.js.map} +0 -0
  328. /package/dist/{chunk-9rh8ncs5.js.map → chunk-fwsvshr5.js.map} +0 -0
  329. /package/dist/{chunk-cgznz22f.js.map → chunk-gkv8r794.js.map} +0 -0
  330. /package/dist/{chunk-8hvfs0fr.js.map → chunk-j8thxj7w.js.map} +0 -0
  331. /package/dist/{chunk-855n80en.js.map → chunk-jjmggm9a.js.map} +0 -0
  332. /package/dist/{chunk-vkweppkw.js.map → chunk-mbc5hvnj.js.map} +0 -0
  333. /package/dist/{chunk-y2x2935j.js.map → chunk-nh26e7c5.js.map} +0 -0
  334. /package/dist/{chunk-jhbk10wf.js.map → chunk-q9nkpr8k.js.map} +0 -0
  335. /package/dist/{chunk-xj97s5js.js.map → chunk-wrjx1fqz.js.map} +0 -0
  336. /package/dist/{chunk-agn8d8ys.js.map → chunk-xtztwpkh.js.map} +0 -0
  337. /package/dist/{chunk-0g5nyx0k.js.map → chunk-zeykm8my.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { compareStrings, getInvalidJsonValueReason } from "../../json"
2
2
  import type { ObjectQueryPredicate, QueryScalarKind } from "../../objects/query"
3
- import { isCurrentUser } from "../../ontology/user-ref"
3
+ import { isCurrentUser, type UserRef } from "../../ontology/user-ref"
4
4
  import type {
5
5
  CompiledConditionalObjectReadScope,
6
6
  CompiledObjectReadObjectSelection,
@@ -14,6 +14,8 @@ import type {
14
14
  ObjectReadNode,
15
15
  ObjectReadObjectSelection,
16
16
  ObjectReadRoot,
17
+ ObjectReadVisibility,
18
+ ObjectVisibilityKeys,
17
19
  SelectedObjectReadScope,
18
20
  } from "./types"
19
21
 
@@ -560,7 +562,13 @@ export function compileConditionalObjectReadScope(
560
562
  objectTypeIds.add(objectTypeId)
561
563
 
562
564
  const predicate = capturePredicate(condition.predicate, `${path}.predicate`, 0, budget)
563
- conditions.push(Object.freeze({ objectTypeId, predicate }))
565
+ const visibility =
566
+ condition.visibility === undefined
567
+ ? undefined
568
+ : captureVisibility(condition.visibility, `${path}.visibility`, budget)
569
+ conditions.push(
570
+ Object.freeze({ objectTypeId, predicate, ...(visibility ? { visibility } : {}) })
571
+ )
564
572
  }
565
573
 
566
574
  conditions.sort((left, right) => compareStrings(left.objectTypeId, right.objectTypeId))
@@ -571,6 +579,104 @@ export function compileConditionalObjectReadScope(
571
579
  }) as CompiledConditionalObjectReadScope
572
580
  }
573
581
 
582
+ /** The reader's keys, user and remainder: shaped as providers read them, every predicate bound. */
583
+ function captureVisibility(
584
+ value: unknown,
585
+ path: string,
586
+ budget: { nodes: number }
587
+ ): ObjectReadVisibility {
588
+ if (!isRecord(value)) throw invalidScope(`${path} must hold keys`)
589
+
590
+ const source = captureArray(value.keys, `${path}.keys`)
591
+ if (source.length === 0) throw invalidScope(`${path}.keys must not be empty`)
592
+
593
+ const keys: ObjectVisibilityKeys[] = []
594
+ for (let index = 0; index < source.length; index += 1) {
595
+ keys.push(captureKeys(source.value[index], `${path}.keys[${index}]`, 0, budget))
596
+ }
597
+
598
+ let user: UserRef | undefined
599
+ if (value.user !== undefined) {
600
+ const ref = value.user
601
+ if (!isRecord(ref) || ref.type !== "user" || Object.keys(ref).length !== 2) {
602
+ throw invalidScope(`${path}.user must be a user reference`)
603
+ }
604
+ if (typeof ref.id !== "string" || ref.id.length === 0) {
605
+ throw invalidScope(`${path}.user.id must be a non-empty string`)
606
+ }
607
+ user = Object.freeze({ type: "user", id: ref.id })
608
+ }
609
+
610
+ const remainder =
611
+ value.remainder === undefined
612
+ ? undefined
613
+ : capturePredicate(value.remainder, `${path}.remainder`, 0, budget)
614
+
615
+ return Object.freeze({
616
+ keys: Object.freeze(keys),
617
+ ...(user ? { user } : {}),
618
+ ...(remainder ? { remainder } : {}),
619
+ })
620
+ }
621
+
622
+ function captureKeys(
623
+ value: unknown,
624
+ path: string,
625
+ depth: number,
626
+ budget: { nodes: number }
627
+ ): ObjectVisibilityKeys {
628
+ if (depth > CONDITIONAL_READ_SCOPE_LIMITS.maxPredicateDepth) {
629
+ throw invalidScope(
630
+ `${path} exceeds the maximum predicate depth of ${CONDITIONAL_READ_SCOPE_LIMITS.maxPredicateDepth}`
631
+ )
632
+ }
633
+
634
+ budget.nodes += 1
635
+ if (budget.nodes > CONDITIONAL_READ_SCOPE_LIMITS.maxPredicateNodes) {
636
+ throw invalidScope(
637
+ `scope exceeds the maximum of ${CONDITIONAL_READ_SCOPE_LIMITS.maxPredicateNodes} predicate nodes`
638
+ )
639
+ }
640
+
641
+ if (!isRecord(value)) throw invalidScope(`${path} must be visibility keys`)
642
+
643
+ switch (value.kind) {
644
+ case "everyone":
645
+ return Object.freeze({
646
+ kind: "everyone",
647
+ when: capturePredicate(value.when, `${path}.when`, depth + 1, budget),
648
+ })
649
+
650
+ case "user":
651
+ case "users":
652
+ return Object.freeze({
653
+ kind: value.kind,
654
+ propertyId: nonEmptyString(value.propertyId, `${path}.propertyId`),
655
+ })
656
+
657
+ case "union": {
658
+ const items = captureArray(value.items, `${path}.items`)
659
+ if (items.length === 0) throw invalidScope(`${path}.items must not be empty`)
660
+
661
+ const captured: ObjectVisibilityKeys[] = []
662
+ for (let index = 0; index < items.length; index += 1) {
663
+ captured.push(captureKeys(items.value[index], `${path}.items[${index}]`, depth + 1, budget))
664
+ }
665
+ return Object.freeze({ kind: "union", items: Object.freeze(captured) })
666
+ }
667
+
668
+ case "when":
669
+ return Object.freeze({
670
+ kind: "when",
671
+ when: capturePredicate(value.when, `${path}.when`, depth + 1, budget),
672
+ keys: captureKeys(value.keys, `${path}.keys`, depth + 1, budget),
673
+ })
674
+
675
+ default:
676
+ throw invalidScope(`${path}.kind must be a kind of visibility keys`)
677
+ }
678
+ }
679
+
574
680
  function capturePredicate(
575
681
  value: unknown,
576
682
  path: string,
@@ -6,6 +6,7 @@ import type {
6
6
  ObjectQuerySortField,
7
7
  QueryScalarKind,
8
8
  } from "../../objects/query"
9
+ import type { UserRef } from "../../ontology/user-ref"
9
10
  import type { Redactions } from "../../security/types"
10
11
  import type { UserProfile } from "../../users"
11
12
  import type { UniqueValueRef } from "../ontology/materializations"
@@ -203,8 +204,50 @@ export interface ObjectReadCondition {
203
204
  * bound to the reader. Providers compile it with their own predicate compiler.
204
205
  */
205
206
  readonly predicate: ObjectQueryPredicate
207
+ /**
208
+ * The same condition read from visibility keys, for a provider that indexes them. Absent when
209
+ * none of the reader's conditions on the type has keys.
210
+ */
211
+ readonly visibility?: ObjectReadVisibility
212
+ }
213
+
214
+ /**
215
+ * `predicate` read from keys: it matches an object exactly when one of `keys` shows it to everyone
216
+ * or to `user`, or when `remainder` matches it.
217
+ */
218
+ export interface ObjectReadVisibility {
219
+ /** One per condition of the reader's roles that has keys, the same for every reader. */
220
+ readonly keys: readonly ObjectVisibilityKeys[]
221
+ /** The user reading; without one, an object is only shown by keys for everyone. */
222
+ readonly user?: UserRef
223
+ /** The reader's other conditions, bound to its user: an object either matches is shown. */
224
+ readonly remainder?: ObjectQueryPredicate
206
225
  }
207
226
 
227
+ /**
228
+ * Who a view condition shows an object to, read from the object alone: everyone holding the
229
+ * condition, or the users some of its properties name.
230
+ *
231
+ * `currentUser()` only appears where a condition compares user references, so a condition has
232
+ * keys unless it negates such a comparison, or needs two of them to hold at once. Unlike the
233
+ * condition bound to a reader, keys are the same for every reader, so a provider can index them
234
+ * once per condition. A reader sees an object when its keys show it to everyone or to the reader.
235
+ */
236
+ export type ObjectVisibilityKeys =
237
+ /** Everyone, when `when` matches. `when` never reads `currentUser()`. */
238
+ | { readonly kind: "everyone"; readonly when: ObjectQueryPredicate }
239
+ /** The user a `ref.user()` property holds, as `eq(property, currentUser())` compares it. */
240
+ | { readonly kind: "user"; readonly propertyId: string }
241
+ /** Each user a list holds, as `contains(property, currentUser())` compares them. */
242
+ | { readonly kind: "users"; readonly propertyId: string }
243
+ | { readonly kind: "union"; readonly items: readonly ObjectVisibilityKeys[] }
244
+ /** `keys`, when `when` matches. `when` never reads `currentUser()`. */
245
+ | {
246
+ readonly kind: "when"
247
+ readonly when: ObjectQueryPredicate
248
+ readonly keys: ObjectVisibilityKeys
249
+ }
250
+
208
251
  /**
209
252
  * Detached and deeply immutable conditions, one per concrete type, ordered by type id.
210
253
  *
@@ -14,6 +14,7 @@ import {
14
14
  import { PipelineRunError } from "./errors"
15
15
  import { canRequeuePipelineRunAfterEnqueueFailure } from "./idempotency"
16
16
  import { assertPipelineRunExecution } from "./provider"
17
+ import { canFinishPipelineRun } from "./transitions"
17
18
  import type {
18
19
  FinishPipelineRunInput,
19
20
  FinishPipelineStepRunInput,
@@ -152,11 +153,7 @@ export class InMemoryPipelineRunStorage implements PipelineRunStorage {
152
153
 
153
154
  async finish(input: FinishPipelineRunInput): Promise<PipelineRunRecord> {
154
155
  const existing = this.requireExistingPipelineRun(input.projectId, input.id)
155
- const enqueueFailure = input.status === "failed" && input.error.code === "queue.enqueue_failed"
156
- if (
157
- (enqueueFailure && existing.status !== "queued") ||
158
- (!enqueueFailure && existing.status !== "running")
159
- ) {
156
+ if (!canFinishPipelineRun(existing.status, input)) {
160
157
  throw new PipelineRunError(
161
158
  `[Sixb] Pipeline run '${input.id}' cannot finish from status '${existing.status}'.`
162
159
  )
@@ -0,0 +1,14 @@
1
+ import type { FinishPipelineRunInput, PipelineRunStatus } from "./types"
2
+
3
+ /**
4
+ * A run finishes from `running`. One that never started can only fail: its job could not be
5
+ * published (`queue.enqueue_failed`), or the job ended before starting it.
6
+ */
7
+ export function canFinishPipelineRun(
8
+ status: PipelineRunStatus,
9
+ input: FinishPipelineRunInput
10
+ ): boolean {
11
+ if (input.status !== "failed") return status === "running"
12
+ if (input.error.code === "queue.enqueue_failed") return status === "queued"
13
+ return status === "queued" || status === "running"
14
+ }
@@ -13,6 +13,7 @@ import {
13
13
  import { SyncRunError } from "./errors"
14
14
  import { canRequeueSyncRunAfterEnqueueFailure } from "./idempotency"
15
15
  import { assertSyncRunExecution } from "./provider"
16
+ import { canFinishSyncRun } from "./transitions"
16
17
  import type {
17
18
  FinishSyncRunInput,
18
19
  ListLatestSyncRunsInput,
@@ -157,11 +158,7 @@ export class InMemorySyncRunStorage implements SyncRunStorage {
157
158
  )
158
159
  }
159
160
 
160
- const enqueueFailure = input.status === "failed" && input.error.code === "queue.enqueue_failed"
161
- if (
162
- (enqueueFailure && existing.status !== "queued") ||
163
- (!enqueueFailure && existing.status !== "running")
164
- ) {
161
+ if (!canFinishSyncRun(existing.status, input)) {
165
162
  throw new SyncRunError(
166
163
  `[Sixb] Sync run '${input.id}' cannot finish from status '${existing.status}'.`
167
164
  )
@@ -0,0 +1,11 @@
1
+ import type { FinishSyncRunInput, SyncRunStatus } from "./types"
2
+
3
+ /**
4
+ * A run finishes from `running`. One that never started can only fail: its job could not be
5
+ * published (`queue.enqueue_failed`), or the job ended before starting it.
6
+ */
7
+ export function canFinishSyncRun(status: SyncRunStatus, input: FinishSyncRunInput): boolean {
8
+ if (input.status !== "failed") return status === "running"
9
+ if (input.error.code === "queue.enqueue_failed") return status === "queued"
10
+ return status === "queued" || status === "running"
11
+ }
@@ -42,6 +42,8 @@ interface DispatchSyncRunInput extends SyncRunRequestOptions {
42
42
  readonly metadata?: Readonly<Record<string, string>>
43
43
  readonly createExecution: (executionId: string, runId: string) => Promise<CreateExecutionInput>
44
44
  readonly validateExistingRun?: (run: SyncRunRecord, storage: Storage) => Promise<void>
45
+ /** Return a matching run of this Sync that has not started yet instead of queueing another one. */
46
+ readonly joinQueuedRun?: boolean
45
47
  }
46
48
 
47
49
  type PersistedSyncRun =
@@ -49,9 +51,10 @@ type PersistedSyncRun =
49
51
  | {
50
52
  readonly publish: true
51
53
  readonly run: SyncRunRecord
52
- readonly execution: CreateExecutionInput
53
54
  readonly queuedAt: Date
54
55
  readonly created: boolean
56
+ /** Defaults to the run id. A trigger that joins a run publishes its own job for it. */
57
+ readonly jobId?: string
55
58
  }
56
59
 
57
60
  /** Core-owned durable dispatch boundary used by automatic Sync triggers. */
@@ -75,6 +78,7 @@ export class SyncRunDispatcher implements SyncRunDispatchPort {
75
78
  metadata: input.metadata,
76
79
  validateExistingRun: (run, storage) =>
77
80
  assertAutomaticExecutionIdentity(storage, this.dependencies.id, input, run),
81
+ joinQueuedRun: true,
78
82
  createExecution: async (executionId, runId) =>
79
83
  createPrimitiveExecutionRecord({
80
84
  id: executionId,
@@ -122,6 +126,19 @@ async function persistSyncRun(
122
126
  return { publish: false, run: raced }
123
127
  }
124
128
 
129
+ if (input.joinQueuedRun) {
130
+ const waiting = await findQueuedSyncRun(transactionalRuns, input)
131
+ if (waiting) {
132
+ return {
133
+ publish: true,
134
+ run: waiting,
135
+ queuedAt: waiting.queuedAt,
136
+ created: false,
137
+ jobId: joinJobId(waiting, runId),
138
+ }
139
+ }
140
+ }
141
+
125
142
  await tx.executions.create(execution)
126
143
  const run = await transactionalRuns.queue({
127
144
  projectId: input.projectId,
@@ -134,7 +151,7 @@ async function persistSyncRun(
134
151
  expectedLatestVersionId: input.expectedLatestVersionId,
135
152
  commitMessage: input.commitMessage,
136
153
  })
137
- return { publish: true, run, execution, queuedAt, created: true }
154
+ return { publish: true, run, queuedAt, created: true }
138
155
  },
139
156
  { isolation: "serializable" }
140
157
  )
@@ -148,6 +165,35 @@ async function persistSyncRun(
148
165
  }
149
166
  }
150
167
 
168
+ /**
169
+ * A run that has not started reads its source when it starts, so it already covers a trigger that
170
+ * arrives now. The oldest one starts first; one queued with another request payload is not joined.
171
+ */
172
+ async function findQueuedSyncRun(
173
+ syncRuns: NonNullable<Storage["syncRuns"]>,
174
+ input: DispatchSyncRunInput
175
+ ): Promise<SyncRunRecord | undefined> {
176
+ const { runs } = await syncRuns.list({
177
+ projectId: input.projectId,
178
+ syncId: input.sync.id,
179
+ statuses: ["queued"],
180
+ order: "asc",
181
+ limit: 1,
182
+ })
183
+ const [waiting] = runs
184
+ return waiting && runMatchesRequest(waiting, input) ? waiting : undefined
185
+ }
186
+
187
+ /**
188
+ * The job a trigger publishes for the run it joins. The run's own job may be gone (a provider
189
+ * keeps a settled job id, and ignores a new job under it), so each joining trigger brings a job
190
+ * that can start the run; once it has started, the others complete without doing anything. The id
191
+ * derives from the trigger's run id, so a redelivered trigger publishes the same job.
192
+ */
193
+ function joinJobId(waiting: SyncRunRecord, triggerRunId: string): string {
194
+ return `${waiting.id}:join:${triggerRunId}`
195
+ }
196
+
151
197
  async function reuseSyncRun(
152
198
  input: DispatchSyncRunInput,
153
199
  existing: SyncRunRecord
@@ -161,7 +207,7 @@ async function reuseSyncRun(
161
207
  })
162
208
  if (!execution)
163
209
  throw new SyncRunError(`[Sixb] Execution '${existing.executionId}' was not found.`)
164
- return { publish: true, run: existing, execution, queuedAt: existing.queuedAt, created: false }
210
+ return { publish: true, run: existing, queuedAt: existing.queuedAt, created: false }
165
211
  }
166
212
  if (
167
213
  existing.status !== "failed" ||
@@ -193,26 +239,28 @@ async function reuseSyncRun(
193
239
  expectedLatestVersionId: existing.expectedLatestVersionId,
194
240
  commitMessage: existing.commitMessage,
195
241
  })
196
- return { publish: true, run, execution, queuedAt, created: false }
242
+ return { publish: true, run, queuedAt, created: false }
197
243
  }
198
244
 
199
245
  async function publishSyncRun(
200
246
  input: DispatchSyncRunInput,
201
247
  persisted: Extract<PersistedSyncRun, { readonly publish: true }>
202
248
  ): Promise<SyncRunRequestResult> {
249
+ const jobId = persisted.jobId ?? persisted.run.id
250
+
203
251
  try {
204
252
  const [job] = await input.queue.enqueue({
205
253
  projectId: input.projectId,
206
254
  jobs: [
207
255
  {
208
- id: persisted.run.id,
256
+ id: jobId,
209
257
  type: "sync.run.requested",
210
258
  payload: { runId: persisted.run.id },
211
259
  ...(input.metadata === undefined ? {} : { metadata: input.metadata }),
212
260
  },
213
261
  ],
214
262
  })
215
- if (!job || job.id !== persisted.run.id) {
263
+ if (!job || job.id !== jobId) {
216
264
  throw new SyncRunError(`[Sixb] Queue did not acknowledge Sync run '${persisted.run.id}'.`)
217
265
  }
218
266
  return {
@@ -249,19 +297,26 @@ function assertExistingRunMatchesRequest(
249
297
  existing: SyncRunRecord,
250
298
  input: Pick<DispatchSyncRunInput, "sync" | "expectedLatestVersionId" | "commitMessage">
251
299
  ): void {
252
- if (
253
- existing.syncId !== input.sync.id ||
254
- existing.datasetId !== input.sync.target.dataset.id ||
255
- existing.mode !== input.sync.config.mode ||
256
- existing.expectedLatestVersionId !== input.expectedLatestVersionId ||
257
- existing.commitMessage !== input.commitMessage
258
- ) {
300
+ if (!runMatchesRequest(existing, input)) {
259
301
  throw new SyncRunError(
260
302
  `[Sixb] Sync run '${existing.id}' already exists with a different request payload.`
261
303
  )
262
304
  }
263
305
  }
264
306
 
307
+ function runMatchesRequest(
308
+ existing: SyncRunRecord,
309
+ input: Pick<DispatchSyncRunInput, "sync" | "expectedLatestVersionId" | "commitMessage">
310
+ ): boolean {
311
+ return (
312
+ existing.syncId === input.sync.id &&
313
+ existing.datasetId === input.sync.target.dataset.id &&
314
+ existing.mode === input.sync.config.mode &&
315
+ existing.expectedLatestVersionId === input.expectedLatestVersionId &&
316
+ existing.commitMessage === input.commitMessage
317
+ )
318
+ }
319
+
265
320
  function existingSyncRunResult(existing: SyncRunRecord): SyncRunRequestResult {
266
321
  return {
267
322
  syncId: existing.syncId,
@@ -1159,6 +1159,76 @@ export function runAgentStorageContractSuite<TStorage extends AgentStorageContra
1159
1159
  })
1160
1160
  })
1161
1161
 
1162
+ // Removal proofs: have a renewal write no stop requests (those asked are lost); drop the check
1163
+ // that a request is not kept yet (a second click lists it twice).
1164
+ test("keeps what an open sixb reports of its background commands, and the stops asked", async () => {
1165
+ await withStorage(async (storage) => {
1166
+ const live = at("2026-06-23T12:01:00.000Z")
1167
+ const session = (overrides: Partial<AgentComputerSessionRecord> = {}) => ({
1168
+ projectId,
1169
+ id: "s_1",
1170
+ ownerPrincipal: owner,
1171
+ computer: laptop,
1172
+ expiresAt: live,
1173
+ ...overrides,
1174
+ })
1175
+ const running = {
1176
+ threadId: "thr_1",
1177
+ id: "bg_1",
1178
+ command: "bun dev",
1179
+ status: "running" as const,
1180
+ startedAt: "2026-06-23T11:59:00.000Z",
1181
+ }
1182
+ const ref = { threadId: "thr_1", id: "bg_1", startedAt: running.startedAt }
1183
+ const stop = (command = ref, ownerPrincipal: Principal = owner) =>
1184
+ storage.computers.requestStop({ projectId, id: "s_1", ownerPrincipal, command })
1185
+
1186
+ await storage.computers.hold(session({ backgroundCommands: [running] }))
1187
+ await expect(stop()).resolves.toEqual(
1188
+ session({ backgroundCommands: [running], stopRequests: [ref] })
1189
+ )
1190
+ await expect(stop()).resolves.toEqual(
1191
+ session({ backgroundCommands: [running], stopRequests: [ref] })
1192
+ )
1193
+ await expect(stop(ref, otherUser)).resolves.toBeNull()
1194
+
1195
+ // A renewal reports the commands anew, and keeps what was asked of them.
1196
+ const stopped = {
1197
+ ...running,
1198
+ status: "stopped" as const,
1199
+ exitCode: 143,
1200
+ endedAt: "2026-06-23T12:00:30.000Z",
1201
+ }
1202
+ await storage.computers.hold(session({ backgroundCommands: [stopped] }))
1203
+ await expect(
1204
+ storage.computers.listLive({
1205
+ projectId,
1206
+ ownerPrincipal: owner,
1207
+ now: at(running.startedAt),
1208
+ })
1209
+ ).resolves.toEqual([session({ backgroundCommands: [stopped], stopRequests: [ref] })])
1210
+
1211
+ // The newest requests are kept.
1212
+ for (let index = 2; index <= 65; index += 1) await stop({ ...ref, id: `bg_${index}` })
1213
+ const [kept] = await storage.computers.listLive({
1214
+ projectId,
1215
+ ownerPrincipal: owner,
1216
+ now: at(running.startedAt),
1217
+ })
1218
+ expect(kept?.stopRequests?.length).toBe(64)
1219
+ expect(kept?.stopRequests?.[0]?.id).toBe("bg_2")
1220
+ expect(kept?.stopRequests?.at(-1)?.id).toBe("bg_65")
1221
+
1222
+ await expectAgentError(stop({ ...ref, id: "" }), "invalid_input")
1223
+ await expectAgentError(
1224
+ storage.computers.hold(
1225
+ session({ backgroundCommands: [{ ...running, status: "lost" as "running" }] })
1226
+ ),
1227
+ "invalid_input"
1228
+ )
1229
+ })
1230
+ })
1231
+
1162
1232
  test("reads several threads at once, in the order asked", async () => {
1163
1233
  await withStorage(async (storage) => {
1164
1234
  const first = await storage.threads.create(threadInput())
@@ -570,7 +570,7 @@ export function runAiLimitStorageContractSuite<TStorage extends AiLimitStorageCo
570
570
  meter: "cost.catalogEstimated",
571
571
  amount: { currency: "USD", amountNanos: "100" },
572
572
  }
573
- for (const modelKind of ["reranking", "image", "speech"] as const) {
573
+ for (const modelKind of ["reranking", "web-search", "image", "speech"] as const) {
574
574
  await expect(
575
575
  storage.aiLimits.reserveModelCall(
576
576
  reservation(modelKind, 0, { estimates: [cost], modelKind })
@@ -591,6 +591,16 @@ export function runAiLimitStorageContractSuite<TStorage extends AiLimitStorageCo
591
591
  projectId,
592
592
  usageRecordId: "usage-reranking",
593
593
  })
594
+ await recordUsageInput(storage.aiUsage, {
595
+ id: "usage-web-search",
596
+ callId: "web-search",
597
+ modelKind: "web-search",
598
+ usage: {},
599
+ })
600
+ await storage.aiLimits.recordModelCallActuals({
601
+ projectId,
602
+ usageRecordId: "usage-web-search",
603
+ })
594
604
  expect(await status()).toMatchObject({
595
605
  accountingStatus: "complete",
596
606
  consumption: { actual: { amount: 4 } },
@@ -71,8 +71,9 @@ export function runAiUsageStorageContractSuite<TStorage extends AiUsageStorage>(
71
71
 
72
72
  describe(label, () => {
73
73
  // Removal proof: omit audioDurationMs from a row codec; this round trip fails.
74
- // Removal proof: omit 'reranking' from a storage migration's model_kind check; the write fails.
75
- test("persists transcription and reranking usage kinds without invented token totals", async () => {
74
+ // Removal proof: omit 'reranking' or 'web-search' from a storage migration's model_kind check;
75
+ // the write fails.
76
+ test("persists transcription, reranking and web search usage kinds without invented token totals", async () => {
76
77
  await withStorage(async (storage) => {
77
78
  const latest = () =>
78
79
  storage.getLatestForExecution({ projectId, executionId: agentExecutionId })
@@ -102,6 +103,18 @@ export function runAiUsageStorageContractSuite<TStorage extends AiUsageStorage>(
102
103
  })
103
104
  )
104
105
  expect((await latest())?.modelKind).toBe("reranking")
106
+
107
+ await storage.recordModelCall(
108
+ modelCallInput({
109
+ id: "usage_web_search",
110
+ callId: "call_web_search",
111
+ responseId: "response_web_search",
112
+ modelKind: "web-search",
113
+ usage: {},
114
+ occurredAt: at("2026-06-23T10:02:00.000Z"),
115
+ })
116
+ )
117
+ expect((await latest())?.modelKind).toBe("web-search")
105
118
  })
106
119
  })
107
120
  // Removal proof: omit a media count from a row codec, or 'speech' from a storage migration's
@@ -454,6 +454,29 @@ export function runConnectorConnectionStorageContractSuite<
454
454
  })
455
455
  })
456
456
 
457
+ test("connects another account to a disconnected slot without replacement", async () => {
458
+ await withStorage(async (storage) => {
459
+ const first = await createAuthorization(storage, "authorization-a", "account-a")
460
+ const connected = await connect(storage, first, "connection-a", "account-a")
461
+ await storage.disconnectConnection({
462
+ projectId,
463
+ connectorId,
464
+ connectionId: connected.connection.id,
465
+ })
466
+
467
+ const second = await createAuthorization(storage, "authorization-b", "account-b")
468
+ const reconnected = await connect(storage, second, "ignored-new-id", "account-b")
469
+
470
+ expect(reconnected.connection).toMatchObject({
471
+ id: connected.connection.id,
472
+ authorizationId: second.id,
473
+ account: { id: "account-b" },
474
+ status: "connected",
475
+ })
476
+ expect(reconnected.replaced).toBe(false)
477
+ })
478
+ })
479
+
457
480
  test("keeps pending selection untouched when connection validation fails", async () => {
458
481
  await withStorage(async (storage) => {
459
482
  const active = await createAuthorization(storage, "authorization-a", "account-a")