@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
@@ -120,6 +120,11 @@ const OPERATIONS: Readonly<Record<string, Operation>> = {
120
120
  const { providerId, modelId, definition, rateCard, defaultReasoning, maxOutputTokens } = model
121
121
  return { providerId, modelId, definition, rateCard, defaultReasoning, maxOutputTokens }
122
122
  },
123
+ "models.webSearch": (session, [request], signal) =>
124
+ session.models.webSearch(
125
+ request as Parameters<AgentRunSession["models"]["webSearch"]>[0],
126
+ signal
127
+ ),
123
128
  "files.stat": (session, [blobId]) => session.files.stat(blobId as string),
124
129
  }
125
130
 
@@ -428,11 +433,12 @@ function withSavedOutputChecked(part: AgentMessagePart): AgentMessagePart {
428
433
 
429
434
  /** One model call, its events streamed back as lines of JSON as the provider sends them. */
430
435
  async function streamModelCall(session: AgentRunSession, request: Request): Promise<Response> {
431
- const { ref, call } = decodeWireValue(await readBodyText(request)) as {
436
+ const { ref, call, measures } = decodeWireValue(await readBodyText(request)) as {
432
437
  ref: Parameters<AgentRunSession["models"]["language"]>[0]
433
438
  call: Omit<LanguageModelRequest, "signal">
439
+ measures?: unknown
434
440
  }
435
- const model = await session.models.language(ref)
441
+ const model = await session.models.language(ref, { measures: measures !== false })
436
442
  const opened = await model.stream({ ...call, signal: request.signal })
437
443
  const encoder = new TextEncoder()
438
444
  const iterator = opened.events[Symbol.asyncIterator]()
@@ -19,6 +19,7 @@ import {
19
19
  } from "../models/execution/index"
20
20
  import type { LanguageModel } from "../models/language-model"
21
21
  import { resolveLanguageModel } from "../models/resolve"
22
+ import type { WebSearchModelRequest, WebSearchModelResult } from "../models/web-search-model"
22
23
  import type { Sixb } from "../runtime/sixb"
23
24
  import type { SecurityDefinitionCatalog } from "../security"
24
25
  import type { Storage } from "../storage"
@@ -90,6 +91,7 @@ import { subscribeAgentRunCancel } from "./streams/protocol"
90
91
  import { subagentSandboxFiles } from "./subagent-runs"
91
92
  import { conversationThreadId } from "./thread-access"
92
93
  import type { AgentToolRunInfo } from "./types"
94
+ import { bindAgentWebSearch } from "./web"
93
95
 
94
96
  /**
95
97
  * A run's session: the one way its runner reads and writes shared state for it. Claiming the run
@@ -198,8 +200,20 @@ export interface AgentRunSession<TRun extends AgentRunRecord = AgentRunRecord> {
198
200
 
199
201
  /** The models a run calls, by the ref its plan names. */
200
202
  export interface AgentRunModels {
201
- /** A language model of the project, resolved once for the session. */
202
- language(ref: LanguageModelRef): Promise<LanguageModel>
203
+ /**
204
+ * A language model of the project, resolved once for the session. Each call is recorded, and
205
+ * measures the model's tokenizer for the run, unless `measures` is false: a tool's own call
206
+ * (`web_fetch`'s question) reads other text than the run's context, and must not stand for it.
207
+ */
208
+ language(ref: LanguageModelRef, options?: { readonly measures?: boolean }): Promise<LanguageModel>
209
+ /**
210
+ * Search the web with the project's web search model, the one its plan's `web.search` names.
211
+ * It always runs where the project is: the provider's key never reaches the runner.
212
+ */
213
+ webSearch(
214
+ request: Omit<WebSearchModelRequest, "signal">,
215
+ signal: AbortSignal
216
+ ): Promise<WebSearchModelResult>
203
217
  }
204
218
 
205
219
  /** Where a run's files are stored: put one, open or stat one by its blob id. */
@@ -380,6 +394,11 @@ export async function openAgentRunSession<TRun extends AgentRunRecord>(
380
394
  })
381
395
  return toolsBound
382
396
  }
397
+ // Its searches bill to the run too, and stop with it.
398
+ const webSearch = bindAgentWebSearch(host.definitions, {
399
+ signal: AbortSignal.any([cancelled, ended.signal, ...(stop ? [stop] : [])]),
400
+ accounting: openedModelCalls,
401
+ })
383
402
  let logs: RunLogSession | undefined
384
403
  // Labeled with the conversation its run works in: a child's is its parent's.
385
404
  let toolLabels: Promise<LogFields> | undefined
@@ -437,7 +456,7 @@ export async function openAgentRunSession<TRun extends AgentRunRecord>(
437
456
  pausesAfterStep: () => turnPausesOnHeldCalls(host.storage.agents, run),
438
457
  },
439
458
  models: {
440
- async language(ref) {
459
+ async language(ref, options) {
441
460
  const key = `${ref.provider}/${ref.modelId}`
442
461
  let resolved = languageModels.get(key)
443
462
  if (!resolved) {
@@ -453,15 +472,16 @@ export async function openAgentRunSession<TRun extends AgentRunRecord>(
453
472
  resolved.catch(() => languageModels.delete(key))
454
473
  }
455
474
  // Each call records itself, and what it measured of the model's tokenizer.
456
- return measuringAgentContextTokenRates(
457
- (await openedModelCalls()).wrapModel(await resolved),
458
- {
459
- tokenRates: agents.tokenRates,
460
- projectId: host.projectId,
461
- runId: run.id,
462
- }
463
- )
475
+ const recorded = (await openedModelCalls()).wrapModel(await resolved)
476
+ if (options?.measures === false) return recorded
477
+
478
+ return measuringAgentContextTokenRates(recorded, {
479
+ tokenRates: agents.tokenRates,
480
+ projectId: host.projectId,
481
+ runId: run.id,
482
+ })
464
483
  },
484
+ webSearch,
465
485
  },
466
486
  async renewLease(leaseExpiresAt) {
467
487
  try {
@@ -1,6 +1,7 @@
1
1
  import type { OntologyDocsCatalog, OntologyDocsInput } from "../ontology/docs"
2
2
  import { RuntimeError } from "../runtime/errors"
3
3
  import type { AgentOptions } from "./step-limits"
4
+ import type { AgentWebOptions } from "./web"
4
5
 
5
6
  /** A project file the Agent receives byte-for-byte in its sandbox. */
6
7
  export interface AgentProjectFile {
@@ -48,6 +49,8 @@ export interface AgentDefinitions {
48
49
  /** As the project set them, checked. Absent: a turn has no limit, a sub-agent the default. */
49
50
  readonly maxSteps?: number
50
51
  readonly subagentMaxSteps?: number
52
+ /** As the project set it, checked, its domains in canonical form. Absent: web tools are on. */
53
+ readonly web?: false | AgentWebOptions
51
54
  }
52
55
 
53
56
  /** Index skills by name. Discovery validates each skill; names must also be unique. */
@@ -1,4 +1,5 @@
1
1
  import { RuntimeError } from "../runtime/errors"
2
+ import type { AgentWebOptions } from "./web"
2
3
 
3
4
  /**
4
5
  * The most model calls a run nobody watches takes when nothing sets its own limit: a sub-agent's or
@@ -15,6 +16,11 @@ export interface AgentOptions {
15
16
  readonly maxSteps?: number
16
17
  /** At most this many steps in one run of a sub-agent. Defaults to 500. */
17
18
  readonly subagentMaxSteps?: number
19
+ /**
20
+ * The web tools: `web_search` when the project has a web search model, and `web_fetch`. On by
21
+ * default; `false` turns both off, and domain lists narrow both.
22
+ */
23
+ readonly web?: false | AgentWebOptions
18
24
  }
19
25
 
20
26
  /** Reject a step limit that is not a positive integer, naming where it was set. */
@@ -37,6 +37,8 @@ export interface AgentRunActivityEvent {
37
37
  readonly attempt: number
38
38
  /** Set on a computer's turn: a `sixb` hearing of any other has nothing to read about it. */
39
39
  readonly runsOn?: "computer"
40
+ /** A stop was asked for: whatever runs it hears at its next lease renewal, or now, on this. */
41
+ readonly cancelRequested?: true
40
42
  readonly occurredAt: string
41
43
  }
42
44
 
@@ -100,7 +102,9 @@ export interface AgentApprovalActivityEvent {
100
102
 
101
103
  /**
102
104
  * An open `sixb` on its owner's computer came or went: the threads that run on that computer in
103
- * that folder are reachable now, or not. Only its owner hears it.
105
+ * that folder are reachable now, or not. Also said, `online`, as the background commands it runs
106
+ * start or end, and as its owner asks it to stop one, which it hears and renews its session for.
107
+ * Only its owner hears it.
104
108
  */
105
109
  export interface AgentComputerActivityEvent {
106
110
  readonly schemaVersion: typeof AGENT_ACTIVITY_STREAM_SCHEMA_VERSION
@@ -286,9 +290,10 @@ export async function publishAgentApprovalActivity(
286
290
 
287
291
  export async function publishAgentRunActivity(
288
292
  broker: Broker,
289
- run: ConversationAgentRunRecord
293
+ run: ConversationAgentRunRecord,
294
+ options: { readonly cancelRequested?: true } = {}
290
295
  ): Promise<void> {
291
- const event = agentRunActivityEvent(run)
296
+ const event = { ...agentRunActivityEvent(run), ...options }
292
297
  await broker.ensureStream({
293
298
  projectId: run.projectId,
294
299
  stream: agentActivityStreamDefinition(),
@@ -302,7 +307,7 @@ export async function publishAgentRunActivity(
302
307
  key: event.threadId,
303
308
  // The event is composed only of validated JSON primitives.
304
309
  payload: event as unknown as JsonValue,
305
- idempotencyKey: `${event.runId}:${event.attempt}:${event.status}`,
310
+ idempotencyKey: `${event.runId}:${event.attempt}:${event.status}${options.cancelRequested ? ":cancel" : ""}`,
306
311
  },
307
312
  ],
308
313
  })
@@ -224,23 +224,31 @@ export function agentToolFilePath(toolCallId: string, fileRef: FileRef, fileName
224
224
  return posix.join("tool-files", callKey, `${digestKey}-${fileName}`)
225
225
  }
226
226
 
227
+ /** What a saved output may be: text, a page as markdown, or a document or image as it came. */
228
+ export type AgentToolOutputExtension = "txt" | "md" | "pdf" | "png" | "jpg" | "gif" | "webp"
229
+
227
230
  /**
228
231
  * Where a call's output too large for the model's context is saved, relative to the context
229
232
  * directory: the call, and the content's digest, so a call id a provider uses again names another
230
233
  * file. `sha256` is the content's hex digest.
231
234
  */
232
- export function agentToolOutputPath(toolCallId: string, sha256: string): string {
235
+ export function agentToolOutputPath(
236
+ toolCallId: string,
237
+ sha256: string,
238
+ extension: AgentToolOutputExtension = "txt"
239
+ ): string {
233
240
  const call = SAFE_CALL_ID.test(toolCallId)
234
241
  ? toolCallId
235
242
  : createHash("sha256").update(toolCallId).digest("hex").slice(0, 16)
236
- return `${AGENT_TOOL_OUTPUTS_DIRECTORY}/${call}-${sha256.slice(0, 12)}.txt`
243
+ return `${AGENT_TOOL_OUTPUTS_DIRECTORY}/${call}-${sha256.slice(0, 12)}.${extension}`
237
244
  }
238
245
 
239
246
  /** Where saved outputs go, in the context directory. */
240
247
  export const AGENT_TOOL_OUTPUTS_DIRECTORY = "tool-outputs"
241
248
 
242
249
  const SAFE_CALL_ID = /^[A-Za-z0-9_-]{1,128}$/
243
- const TOOL_OUTPUT_PATH = /^tool-outputs\/[A-Za-z0-9_-]{1,128}-([0-9a-f]{12})\.txt$/
250
+ const TOOL_OUTPUT_PATH =
251
+ /^tool-outputs\/[A-Za-z0-9_-]{1,128}-([0-9a-f]{12})\.(?:txt|md|pdf|png|jpg|gif|webp)$/
244
252
 
245
253
  /**
246
254
  * Whether a tool-call part's `outputFile` is one {@link agentToolOutputPath} names: a stored file,
@@ -5,10 +5,13 @@ import { normalizeSchemaValue } from "../ontology/validation/normalize"
5
5
  import { validateSchemaValue } from "../ontology/validation/schema"
6
6
  import { AgentDefinitionError } from "./errors"
7
7
  import type { AgentToolDefinition, AgentToolInputSchema } from "./types"
8
+ import { AGENT_WEB_TOOL_NAMES } from "./web"
8
9
 
9
10
  const AGENT_TOOL_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/
10
11
  export const AGENT_RESERVED_TOOL_NAMES = [
11
12
  "bash",
13
+ "bash_output",
14
+ "bash_stop",
12
15
  "read",
13
16
  "view_file",
14
17
  "spawn_agent",
@@ -17,6 +20,7 @@ export const AGENT_RESERVED_TOOL_NAMES = [
17
20
  "ask_parent",
18
21
  "publish_artifact",
19
22
  "publish_artifact_version",
23
+ ...AGENT_WEB_TOOL_NAMES,
20
24
  ] as const
21
25
 
22
26
  export function isAgentToolDefinition(value: unknown): value is AgentToolDefinition {
@@ -36,6 +40,11 @@ export function assertValidAgentToolName(name: unknown): asserts name is string
36
40
  "[Sixb] Agent tool name must be 1-64 characters, start with a letter or underscore, and contain only letters, numbers, underscores, or hyphens."
37
41
  )
38
42
  }
43
+ if ((AGENT_WEB_TOOL_NAMES as readonly string[]).includes(name)) {
44
+ throw new AgentDefinitionError(
45
+ `[Sixb] Agent tool name '${name}' is reserved: Sixb gives the Agent its own ${name} tool. To search with Exa, set models.webSearch: [exaSearch(...)].`
46
+ )
47
+ }
39
48
  if ((AGENT_RESERVED_TOOL_NAMES as readonly string[]).includes(name)) {
40
49
  throw new AgentDefinitionError(`[Sixb] Agent tool name '${name}' is reserved by the framework.`)
41
50
  }
@@ -0,0 +1,218 @@
1
+ import { createSixbError } from "../errors/internal"
2
+ import type { ModelCatalog } from "../models/catalog"
3
+ import type { AiModelCallRecorder } from "../models/execution/model-call-recorder"
4
+ import { bindWebSearchModels } from "../models/execution/web-search"
5
+ import { RuntimeError } from "../runtime/errors"
6
+ import type { AgentRunModels } from "./run-session"
7
+ import type { AgentDefinitions } from "./skills"
8
+
9
+ // The Agent's web tools: the option that narrows or turns them off, the domain lists both tools
10
+ // apply, and the search a run's tool calls through its own accounting.
11
+
12
+ /** Narrows what the Agent's web tools reach. */
13
+ export interface AgentWebOptions {
14
+ /**
15
+ * Only these: `docs.example.com`, `*.example.com` (its subdomains, not itself) or a path prefix
16
+ * such as `example.com/guides`.
17
+ */
18
+ readonly allowedDomains?: readonly string[]
19
+ /** Never these, in the same syntax; they win over `allowedDomains`. */
20
+ readonly blockedDomains?: readonly string[]
21
+ }
22
+
23
+ /** The tool names Sixb gives the Agent for the web, offered unless `agent.web` is `false`. */
24
+ export const AGENT_WEB_TOOL_NAMES = ["web_search", "web_fetch"] as const
25
+
26
+ const MAX_DOMAINS = 1_200
27
+ const MAX_RULE_CHARACTERS = 4_096
28
+
29
+ /**
30
+ * Check `agent.web` and return it with each domain rule in its canonical form: lowercase, without
31
+ * a trailing dot or slash, duplicates dropped.
32
+ */
33
+ export function resolveAgentWebOptions(value: unknown): false | AgentWebOptions | undefined {
34
+ if (value === undefined || value === false) return value
35
+
36
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
37
+ throw new RuntimeError(
38
+ "[Sixb] agent.web must be false, or { allowedDomains?, blockedDomains? }."
39
+ )
40
+ }
41
+
42
+ for (const key of Object.keys(value)) {
43
+ if (key !== "allowedDomains" && key !== "blockedDomains") {
44
+ throw new RuntimeError(
45
+ `[Sixb] agent.web has an unknown option '${key}': use allowedDomains or blockedDomains.`
46
+ )
47
+ }
48
+ }
49
+
50
+ const options = value as Record<string, unknown>
51
+ const allowedDomains = canonicalRules(options.allowedDomains, "allowedDomains")
52
+ const blockedDomains = canonicalRules(options.blockedDomains, "blockedDomains")
53
+
54
+ return Object.freeze({
55
+ ...(allowedDomains ? { allowedDomains } : {}),
56
+ ...(blockedDomains ? { blockedDomains } : {}),
57
+ })
58
+ }
59
+
60
+ /**
61
+ * Refuse a language model whose provider runs a tool under a name the Agent's web tools take: a
62
+ * request would declare the name twice. Checked unless `agent.web` is `false`; `web_search` only
63
+ * when the project has a search backend, since the Agent offers none without one.
64
+ */
65
+ export function assertNoProviderWebTools(models: ModelCatalog | undefined): void {
66
+ const offered: readonly string[] = models?.webSearch ? AGENT_WEB_TOOL_NAMES : ["web_fetch"]
67
+
68
+ for (const { provider, modelId, model } of models?.language?.list() ?? []) {
69
+ const name = model.providerToolNames?.find((tool) => offered.includes(tool))
70
+ if (name === undefined) continue
71
+
72
+ throw new RuntimeError(
73
+ `[Sixb] Language model '${provider}/${modelId}' declares the provider tool '${name}', a name Sixb gives the Agent's own web tool. Remove it from providerTools, or set agent.web: false to keep the provider's.`
74
+ )
75
+ }
76
+ }
77
+
78
+ /** What the domain lists say of a URL. */
79
+ export interface WebDomainPolicy {
80
+ /** Why the lists refuse the URL, or undefined when they allow it. */
81
+ refuses(url: URL): "blocked" | "not-allowed" | undefined
82
+ }
83
+
84
+ /** Compile domain lists `resolveAgentWebOptions` already checked. */
85
+ export function webDomainPolicy(options: AgentWebOptions): WebDomainPolicy {
86
+ const allowed = options.allowedDomains?.map((rule) => parseRule(rule, "allowedDomains"))
87
+ const blocked = options.blockedDomains?.map((rule) => parseRule(rule, "blockedDomains"))
88
+
89
+ return {
90
+ refuses(url) {
91
+ if (blocked?.some((rule) => matchesRule(url, rule))) return "blocked"
92
+ if (allowed && !allowed.some((rule) => matchesRule(url, rule))) return "not-allowed"
93
+ return undefined
94
+ },
95
+ }
96
+ }
97
+
98
+ /**
99
+ * A run's web search, through the project's web search model: admitted, bounded and recorded with
100
+ * the run's other model calls.
101
+ */
102
+ export function bindAgentWebSearch(
103
+ definitions: {
104
+ readonly agent: Pick<AgentDefinitions, "web">
105
+ readonly models?: Pick<ModelCatalog, "webSearch">
106
+ },
107
+ execution: {
108
+ /** Aborts once the run ends or is cancelled. */
109
+ readonly signal: AbortSignal
110
+ readonly accounting: () => Promise<AiModelCallRecorder>
111
+ }
112
+ ): AgentRunModels["webSearch"] {
113
+ const bound = bindWebSearchModels(definitions.models?.webSearch, {
114
+ signal: (signal) => (signal ? AbortSignal.any([execution.signal, signal]) : execution.signal),
115
+ accounting: execution.accounting,
116
+ })
117
+
118
+ return async (request, signal) => {
119
+ // A runner asks for a search through its session: the project's options decide, not its plan.
120
+ if (definitions.agent.web === false) {
121
+ throw createSixbError(
122
+ "agent.execution_failed",
123
+ "[Sixb] The Agent's web tools are off: agent.web is false."
124
+ )
125
+ }
126
+
127
+ if (!bound) {
128
+ throw createSixbError(
129
+ "agent.execution_failed",
130
+ "[Sixb] The project has no web search model: set models.webSearch, or use a language model that offers one."
131
+ )
132
+ }
133
+
134
+ return bound.default.model.search({ ...request, signal })
135
+ }
136
+ }
137
+
138
+ interface DomainRule {
139
+ readonly hostname: string
140
+ readonly wildcard: boolean
141
+ readonly pathPrefix?: string
142
+ }
143
+
144
+ function canonicalRules(value: unknown, field: string): readonly string[] | undefined {
145
+ if (value === undefined) return undefined
146
+
147
+ if (!Array.isArray(value) || value.length < 1 || value.length > MAX_DOMAINS) {
148
+ throw new RuntimeError(`[Sixb] agent.web.${field} must list from 1 to ${MAX_DOMAINS} domains.`)
149
+ }
150
+
151
+ const rules = new Set<string>()
152
+ for (const entry of value) rules.add(canonicalRule(parseRule(entry, field)))
153
+
154
+ return Object.freeze([...rules])
155
+ }
156
+
157
+ function parseRule(value: unknown, field: string): DomainRule {
158
+ if (typeof value !== "string") throw invalidRule(field, value)
159
+
160
+ const trimmed = value.trim()
161
+ if (!trimmed || trimmed.length > MAX_RULE_CHARACTERS || /[\\?#]/.test(trimmed)) {
162
+ throw invalidRule(field, value)
163
+ }
164
+
165
+ const wildcard = trimmed.startsWith("*.")
166
+ const filter = wildcard ? trimmed.slice(2) : trimmed
167
+ const authority = filter.split("/", 1)[0] ?? ""
168
+ if (!authority || /[*:@]/.test(authority)) throw invalidRule(field, value)
169
+
170
+ let parsed: URL
171
+ try {
172
+ parsed = new URL(`https://${filter}`)
173
+ } catch {
174
+ throw invalidRule(field, value)
175
+ }
176
+
177
+ const hostname = canonicalHostname(parsed.hostname)
178
+ if (!isValidHostname(hostname)) throw invalidRule(field, value)
179
+
180
+ const pathPrefix = parsed.pathname.replace(/\/+$/, "")
181
+ return { hostname, wildcard, ...(pathPrefix ? { pathPrefix } : {}) }
182
+ }
183
+
184
+ function canonicalRule(rule: DomainRule): string {
185
+ return `${rule.wildcard ? "*." : ""}${rule.hostname}${rule.pathPrefix ?? ""}`
186
+ }
187
+
188
+ function matchesRule(url: URL, rule: DomainRule): boolean {
189
+ const hostname = canonicalHostname(url.hostname)
190
+ const hostnameMatches = rule.wildcard
191
+ ? hostname !== rule.hostname && hostname.endsWith(`.${rule.hostname}`)
192
+ : hostname === rule.hostname
193
+ if (!hostnameMatches) return false
194
+
195
+ if (!rule.pathPrefix) return true
196
+ return url.pathname === rule.pathPrefix || url.pathname.startsWith(`${rule.pathPrefix}/`)
197
+ }
198
+
199
+ function canonicalHostname(value: string): string {
200
+ return value.toLowerCase().replace(/\.$/, "")
201
+ }
202
+
203
+ function isValidHostname(hostname: string): boolean {
204
+ if (!hostname || hostname.length > 253) return false
205
+
206
+ return hostname
207
+ .split(".")
208
+ .every(
209
+ (label) =>
210
+ label.length >= 1 && label.length <= 63 && /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(label)
211
+ )
212
+ }
213
+
214
+ function invalidRule(field: string, value: unknown): RuntimeError {
215
+ return new RuntimeError(
216
+ `[Sixb] agent.web.${field} has an invalid entry ${JSON.stringify(value)}: write a domain such as 'example.com', '*.example.com' or 'example.com/docs', without a scheme, port, query or credentials.`
217
+ )
218
+ }
@@ -53,8 +53,9 @@ export function resolveRoleGrants(role: RoleDefinition, universe: GrantUniverse)
53
53
  * Resolve a role's conditional view grants once at startup, from their validated conditions.
54
54
  *
55
55
  * A condition applies to the type its grant names and to each subtype, as a view grant does.
56
- * Several conditions on one type combine with `or`, and a type the role also views without a
57
- * condition drops them: the role shows every object of it.
56
+ * Several conditions on one type stay apart: the role shows what any of them matches, and each
57
+ * keeps the index storage prepared for it. A type the role also views without a condition drops
58
+ * them: the role shows every object of it.
58
59
  */
59
60
  export function resolveRoleViewConditions(
60
61
  conditions: readonly {
@@ -63,7 +64,7 @@ export function resolveRoleViewConditions(
63
64
  }[],
64
65
  grants: GrantIndex,
65
66
  universe: GrantUniverse
66
- ): ReadonlyMap<string, ObjectQueryPredicate> {
67
+ ): ReadonlyMap<string, readonly ObjectQueryPredicate[]> {
67
68
  const byType = new Map<string, ObjectQueryPredicate[]>()
68
69
 
69
70
  for (const condition of conditions) {
@@ -79,15 +80,12 @@ export function resolveRoleViewConditions(
79
80
  }
80
81
 
81
82
  return new Map(
82
- [...byType].map(([objectTypeId, predicates]) => [objectTypeId, anyOf(predicates)] as const)
83
+ [...byType].map(
84
+ ([objectTypeId, predicates]) => [objectTypeId, Object.freeze(predicates)] as const
85
+ )
83
86
  )
84
87
  }
85
88
 
86
- function anyOf(predicates: readonly ObjectQueryPredicate[]): ObjectQueryPredicate {
87
- if (predicates.length === 1) return predicates[0]!
88
- return Object.freeze({ op: "or", items: Object.freeze([...predicates]) })
89
- }
90
-
91
89
  function expandSelection(
92
90
  selection: Selection,
93
91
  universe: ReadonlySet<string>,
@@ -153,8 +151,8 @@ export function resolveAuthorizationContext(input: {
153
151
  for (const markingId of role.clearances ?? []) {
154
152
  clearances.add(markingId)
155
153
  }
156
- for (const [objectTypeId, predicate] of role.viewConditions ?? []) {
157
- viewConditions.set(objectTypeId, [...(viewConditions.get(objectTypeId) ?? []), predicate])
154
+ for (const [objectTypeId, predicates] of role.viewConditions ?? []) {
155
+ viewConditions.set(objectTypeId, [...(viewConditions.get(objectTypeId) ?? []), ...predicates])
158
156
  }
159
157
  }
160
158
 
@@ -45,10 +45,10 @@ export interface ResolvedRole {
45
45
  readonly grants: GrantIndex
46
46
  /**
47
47
  * What the role's `can.view(Type).where(...)` grants show, per concrete type: the type's
48
- * conditions, combined with `or`. A type the role also views without a condition is in
49
- * `grants["view:object"]` and not here. Absent means none.
48
+ * conditions, any of which shows an object. A type the role also views without a condition is
49
+ * in `grants["view:object"]` and not here. Absent means none.
50
50
  */
51
- readonly viewConditions?: ReadonlyMap<string, ObjectQueryPredicate>
51
+ readonly viewConditions?: ReadonlyMap<string, readonly ObjectQueryPredicate[]>
52
52
  /** Marking ids this role clears. Absent means none. */
53
53
  readonly clearances?: ReadonlySet<string>
54
54
  }
@@ -61,8 +61,8 @@ export interface AuthorizationContext {
61
61
  readonly roleIds: readonly string[]
62
62
  readonly grants: GrantIndex
63
63
  /**
64
- * The object types the principal views only where a condition matches, with one condition per
65
- * role that grants it. A type in `grants["view:object"]` is never here, so a check on that grant
64
+ * The object types the principal views only where a condition matches, with every condition
65
+ * its roles put on each. A type in `grants["view:object"]` is never here, so a check on that grant
66
66
  * denies these types; only the authorized object reader reads them, through these conditions.
67
67
  * Absent means none.
68
68
  */
@@ -10,6 +10,7 @@ import {
10
10
  type Storage,
11
11
  } from "../../storage"
12
12
  import { createConnectorCodedError, isConnectorStorageError, storageBoundaryError } from "../errors"
13
+ import type { ConnectorAccountCandidate } from "../types"
13
14
  import {
14
15
  assertConnectorAuthorizationActor,
15
16
  type DefaultConnectorAuthorizationLifecycle,
@@ -326,19 +327,28 @@ export class ConnectorConnectionRunService {
326
327
  )
327
328
  }
328
329
 
330
+ return this.view(await this.connectRunAccount(run, account, input.replace === true))
331
+ }
332
+
333
+ /** Fills the run's slot with one of its authorization's accounts and finishes the run. */
334
+ private async connectRunAccount(
335
+ run: ConnectorConnectionRunRecord,
336
+ account: ConnectorAccountCandidate,
337
+ replace: boolean
338
+ ): Promise<ConnectorConnectionRunRecord> {
329
339
  let selected: Awaited<ReturnType<ConnectorConnectionStorage["putConnectionFromRun"]>>
330
340
  try {
331
341
  selected = await this.connectionStorage.putConnectionFromRun({
332
342
  id: `ccn_${randomUUID()}`,
333
343
  projectId: this.projectId,
334
- connectorId: definition.id,
344
+ connectorId: run.connectorId,
335
345
  runId: run.id,
336
346
  account,
337
- replace: input.replace === true,
347
+ replace,
338
348
  })
339
349
  } catch (error) {
340
350
  if (isConnectorStorageError(error, "run_invalid")) {
341
- const latest = await this.readRun(definition.id, run.id)
351
+ const latest = await this.readRun(run.connectorId, run.id)
342
352
  if (latest) await this.continueRunCleanup(latest)
343
353
  throw createConnectorCodedError(
344
354
  "connector.operation_conflict",
@@ -364,7 +374,7 @@ export class ConnectorConnectionRunService {
364
374
  }
365
375
  const cleanupCompleted = selected.revocationPendingAuthorizationId
366
376
  ? await this.continuePendingRevocation(
367
- definition.id,
377
+ run.connectorId,
368
378
  selected.revocationPendingAuthorizationId
369
379
  )
370
380
  : true
@@ -373,7 +383,26 @@ export class ConnectorConnectionRunService {
373
383
  } else {
374
384
  this.scheduleRunMaintenance(selected.run, CLEANUP_RETRY_DELAY_MS)
375
385
  }
376
- return this.view(selected.run)
386
+ return selected.run
387
+ }
388
+
389
+ /**
390
+ * A grant with one account leaves the user nothing to choose. The run is already waiting, so any
391
+ * failure here falls back to the picker with the grant intact.
392
+ */
393
+ private async connectOnlyAccount(
394
+ run: ConnectorConnectionRunRecord,
395
+ account: ConnectorAccountCandidate
396
+ ): Promise<void> {
397
+ try {
398
+ await this.connectRunAccount(run, account, false)
399
+ } catch (error) {
400
+ if (isSixbError(error) && error.code === "connector.replacement_required") return
401
+ console.warn(
402
+ "[Sixb] Connecting the only connector account failed; the user can still select it.",
403
+ error
404
+ )
405
+ }
377
406
  }
378
407
 
379
408
  private async claimCallback(state: string, callbackBinding: string, redirectUri: string) {
@@ -440,6 +469,12 @@ export class ConnectorConnectionRunService {
440
469
  authorization: ConnectorAuthorizationRecord
441
470
  ): Promise<ConnectorConnectionRunRecord> {
442
471
  if (run.kind === "connect") {
472
+ if (authorization.accounts.length === 0) {
473
+ throw createConnectorCodedError(
474
+ "connector.not_found",
475
+ "This authorization does not give access to any account. Sign in with one that has access."
476
+ )
477
+ }
443
478
  if (!authorization.selectionExpiresAt) {
444
479
  throw createConnectorCodedError(
445
480
  "internal.unexpected",
@@ -461,6 +496,8 @@ export class ConnectorConnectionRunService {
461
496
  )
462
497
  if (waiting) {
463
498
  this.scheduleRunMaintenance(waiting, this.selectionTtlMs + 1)
499
+ const [account, ...others] = authorization.accounts
500
+ if (account && others.length === 0) await this.connectOnlyAccount(waiting, account)
464
501
  return waiting
465
502
  }
466
503
  } else {
@@ -222,6 +222,8 @@ export function createDatasetsRuntime(
222
222
  versionId: result.version.versionId,
223
223
  createdAt: result.version.createdAt.toISOString(),
224
224
  producer,
225
+ rowsChanged: result.version.rowsChanged,
226
+ lineageChanged: result.version.lineageChanged,
225
227
  },
226
228
  },
227
229
  ],