@sixb/core 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (427) hide show
  1. package/dist/actions/index.js +36 -35
  2. package/dist/actions/index.js.map +1 -1
  3. package/dist/actions/validation.d.ts.map +1 -1
  4. package/dist/agents/errors.d.ts +1 -1
  5. package/dist/agents/errors.d.ts.map +1 -1
  6. package/dist/agents/execution.d.ts +17 -2
  7. package/dist/agents/execution.d.ts.map +1 -1
  8. package/dist/agents/index.d.ts +3 -3
  9. package/dist/agents/index.d.ts.map +1 -1
  10. package/dist/agents/index.js +53 -45
  11. package/dist/agents/index.js.map +1 -1
  12. package/dist/agents/model-routing.d.ts +16 -2
  13. package/dist/agents/model-routing.d.ts.map +1 -1
  14. package/dist/agents/request.d.ts +45 -4
  15. package/dist/agents/request.d.ts.map +1 -1
  16. package/dist/agents/run-events.d.ts +4 -0
  17. package/dist/agents/run-events.d.ts.map +1 -1
  18. package/dist/agents/run-session-children.d.ts.map +1 -1
  19. package/dist/agents/run-token.d.ts +6 -0
  20. package/dist/agents/run-token.d.ts.map +1 -1
  21. package/dist/agents/run-turn.d.ts +9 -1
  22. package/dist/agents/run-turn.d.ts.map +1 -1
  23. package/dist/agents/streams/index.d.ts +1 -1
  24. package/dist/agents/streams/index.d.ts.map +1 -1
  25. package/dist/agents/streams/index.js +1 -1
  26. package/dist/agents/streams/internal.d.ts +2 -1
  27. package/dist/agents/streams/internal.d.ts.map +1 -1
  28. package/dist/agents/streams/internal.js +22 -2
  29. package/dist/agents/streams/internal.js.map +1 -1
  30. package/dist/agents/streams/protocol.d.ts +37 -0
  31. package/dist/agents/streams/protocol.d.ts.map +1 -1
  32. package/dist/agents/streams/steps.d.ts +24 -0
  33. package/dist/agents/streams/steps.d.ts.map +1 -0
  34. package/dist/agents/thread-access.d.ts +44 -2
  35. package/dist/agents/thread-access.d.ts.map +1 -1
  36. package/dist/artifacts/live/server.js +19 -18
  37. package/dist/artifacts/live/server.js.map +1 -1
  38. package/dist/artifacts/publish/index.js +18 -17
  39. package/dist/artifacts/publish/index.js.map +1 -1
  40. package/dist/artifacts/publish/merge.d.ts +2 -1
  41. package/dist/artifacts/publish/merge.d.ts.map +1 -1
  42. package/dist/artifacts/run-query.d.ts.map +1 -1
  43. package/dist/auth/index.js +6 -6
  44. package/dist/authorization/index.js +2 -2
  45. package/dist/bootstrap/discovery.d.ts +6 -0
  46. package/dist/bootstrap/discovery.d.ts.map +1 -1
  47. package/dist/bootstrap/index.js +40 -38
  48. package/dist/bootstrap/index.js.map +2 -2
  49. package/dist/calendar.d.ts +55 -0
  50. package/dist/calendar.d.ts.map +1 -0
  51. package/dist/calendar.js +19 -0
  52. package/dist/calendar.js.map +9 -0
  53. package/dist/chunk-04r2fdsd.js +386 -0
  54. package/dist/chunk-04r2fdsd.js.map +14 -0
  55. package/dist/{chunk-gjhrz66x.js → chunk-06kpaqg4.js} +248 -21
  56. package/dist/{chunk-gjhrz66x.js.map → chunk-06kpaqg4.js.map} +6 -6
  57. package/dist/{chunk-5a4a52tq.js → chunk-0pmpwn3g.js} +18 -2
  58. package/dist/chunk-0pmpwn3g.js.map +10 -0
  59. package/dist/{chunk-nxysqbt0.js → chunk-389ybvw9.js} +6 -2
  60. package/dist/chunk-389ybvw9.js.map +10 -0
  61. package/dist/{chunk-xcrnrpfh.js → chunk-394zjzjs.js} +20 -10
  62. package/dist/{chunk-xcrnrpfh.js.map → chunk-394zjzjs.js.map} +5 -5
  63. package/dist/{chunk-stmxh0hv.js → chunk-3neam1y5.js} +2 -2
  64. package/dist/{chunk-zeykm8my.js → chunk-3qtk0070.js} +16 -42
  65. package/dist/chunk-3qtk0070.js.map +14 -0
  66. package/dist/{chunk-0hkdtwqk.js → chunk-44hrfmbk.js} +5 -5
  67. package/dist/{chunk-ey1p8w68.js → chunk-5pz3htbe.js} +86 -5
  68. package/dist/chunk-5pz3htbe.js.map +13 -0
  69. package/dist/{chunk-s5pj68fa.js → chunk-5sswe5ej.js} +2 -2
  70. package/dist/{chunk-k3jh8gsg.js → chunk-5xkqasvn.js} +21 -4
  71. package/dist/chunk-5xkqasvn.js.map +10 -0
  72. package/dist/{chunk-5t9gm5tt.js → chunk-6md802cc.js} +38 -14
  73. package/dist/chunk-6md802cc.js.map +22 -0
  74. package/dist/{chunk-3zagkr6w.js → chunk-7mhbs9yy.js} +4 -4
  75. package/dist/{chunk-3zagkr6w.js.map → chunk-7mhbs9yy.js.map} +1 -1
  76. package/dist/{chunk-ewqn51gr.js → chunk-88xeh6zx.js} +6 -4
  77. package/dist/{chunk-ewqn51gr.js.map → chunk-88xeh6zx.js.map} +4 -4
  78. package/dist/{chunk-z1njfqqs.js → chunk-8qmp9fpa.js} +783 -171
  79. package/dist/{chunk-z1njfqqs.js.map → chunk-8qmp9fpa.js.map} +13 -13
  80. package/dist/{chunk-r2psmn42.js → chunk-95ps0k5q.js} +3 -3
  81. package/dist/{chunk-r2psmn42.js.map → chunk-95ps0k5q.js.map} +3 -3
  82. package/dist/{chunk-fpf57gca.js → chunk-9cyq87qa.js} +276 -68
  83. package/dist/{chunk-fpf57gca.js.map → chunk-9cyq87qa.js.map} +6 -6
  84. package/dist/{chunk-q9nkpr8k.js → chunk-9tpmfh3n.js} +1 -1
  85. package/dist/chunk-9wr3yajk.js.map +2 -2
  86. package/dist/{chunk-naxjka9v.js → chunk-brhp9d97.js} +2 -2
  87. package/dist/{chunk-8a8k38tz.js → chunk-brybqw5k.js} +1 -1
  88. package/dist/{chunk-vehcr9eb.js → chunk-cg7cygfj.js} +1 -1
  89. package/dist/{chunk-b4escq4c.js → chunk-cpy282b8.js} +6 -6
  90. package/dist/chunk-dq3t5sr3.js +114 -0
  91. package/dist/chunk-dq3t5sr3.js.map +11 -0
  92. package/dist/{chunk-68hm50qh.js → chunk-fdk0ks9p.js} +16 -46
  93. package/dist/chunk-fdk0ks9p.js.map +12 -0
  94. package/dist/{chunk-fzae1jpq.js → chunk-fycac8e9.js} +50 -16
  95. package/dist/{chunk-fzae1jpq.js.map → chunk-fycac8e9.js.map} +3 -3
  96. package/dist/{chunk-zft9bzbc.js → chunk-hkbks1xm.js} +2 -1
  97. package/dist/{chunk-zft9bzbc.js.map → chunk-hkbks1xm.js.map} +3 -3
  98. package/dist/{chunk-m3qx2pns.js → chunk-hvq8xs66.js} +28 -12
  99. package/dist/{chunk-m3qx2pns.js.map → chunk-hvq8xs66.js.map} +5 -5
  100. package/dist/{chunk-bc3y6gff.js → chunk-jka26v8c.js} +1 -1
  101. package/dist/{chunk-s1mqyqmm.js → chunk-js9e6487.js} +12 -8
  102. package/dist/chunk-js9e6487.js.map +18 -0
  103. package/dist/{chunk-zxhym8tr.js → chunk-k29rdc3h.js} +1 -1
  104. package/dist/{chunk-rg725hry.js → chunk-m1cwncee.js} +86 -34
  105. package/dist/{chunk-rg725hry.js.map → chunk-m1cwncee.js.map} +8 -8
  106. package/dist/{chunk-1yh6jgtz.js → chunk-mrs7jy17.js} +2 -2
  107. package/dist/{chunk-qavwr628.js → chunk-n1hbwc6y.js} +5 -6
  108. package/dist/chunk-n1hbwc6y.js.map +12 -0
  109. package/dist/{chunk-pqvvqc65.js → chunk-pfdq1ga6.js} +3 -3
  110. package/dist/{chunk-k29n4176.js → chunk-phs5fbff.js} +6 -6
  111. package/dist/{chunk-wqe9shx2.js → chunk-qbd282aa.js} +2 -2
  112. package/dist/{chunk-e91fmg6t.js → chunk-qsa7nw6f.js} +2 -1
  113. package/dist/{chunk-e91fmg6t.js.map → chunk-qsa7nw6f.js.map} +3 -3
  114. package/dist/chunk-r588h4ev.js +98 -0
  115. package/dist/chunk-r588h4ev.js.map +10 -0
  116. package/dist/{chunk-rtdrm592.js → chunk-t58sktr5.js} +12 -4
  117. package/dist/{chunk-rtdrm592.js.map → chunk-t58sktr5.js.map} +3 -3
  118. package/dist/{chunk-paxabbqd.js → chunk-tapdssb5.js} +1 -1
  119. package/dist/{chunk-dhkc9b23.js → chunk-v8a1qjzp.js} +1 -1
  120. package/dist/{chunk-q8d9p0tb.js → chunk-wzcjhv54.js} +8 -1
  121. package/dist/{chunk-q8d9p0tb.js.map → chunk-wzcjhv54.js.map} +3 -3
  122. package/dist/{chunk-pc7kra3k.js → chunk-xavet0qs.js} +1 -1
  123. package/dist/{chunk-m9ketb51.js → chunk-ygvay56w.js} +1 -1
  124. package/dist/{chunk-0mvjpgvm.js → chunk-yyj009tv.js} +4 -4
  125. package/dist/connectors/connections/capability.d.ts +11 -0
  126. package/dist/connectors/connections/capability.d.ts.map +1 -1
  127. package/dist/connectors/connections/internal.d.ts +2 -1
  128. package/dist/connectors/connections/internal.d.ts.map +1 -1
  129. package/dist/connectors/connections/internal.js +8 -4
  130. package/dist/connectors/connections/internal.js.map +1 -1
  131. package/dist/connectors/connections/service.d.ts +9 -1
  132. package/dist/connectors/connections/service.d.ts.map +1 -1
  133. package/dist/connectors/execution.d.ts +7 -1
  134. package/dist/connectors/execution.d.ts.map +1 -1
  135. package/dist/connectors/service.d.ts +5 -1
  136. package/dist/connectors/service.d.ts.map +1 -1
  137. package/dist/deploy/index.d.ts +1 -1
  138. package/dist/deploy/index.d.ts.map +1 -1
  139. package/dist/deploy/internal.js +2 -2
  140. package/dist/deploy/internal.js.map +2 -2
  141. package/dist/deploy/types.d.ts +12 -59
  142. package/dist/deploy/types.d.ts.map +1 -1
  143. package/dist/env/index.d.ts +10 -3
  144. package/dist/env/index.d.ts.map +1 -1
  145. package/dist/env/index.js.map +2 -2
  146. package/dist/events/execution.d.ts +8 -1
  147. package/dist/events/execution.d.ts.map +1 -1
  148. package/dist/events/types/syncs.d.ts +4 -0
  149. package/dist/events/types/syncs.d.ts.map +1 -1
  150. package/dist/execution/agent.js +37 -36
  151. package/dist/execution/agent.js.map +1 -1
  152. package/dist/execution/authorized-object-reader.d.ts +4 -0
  153. package/dist/execution/authorized-object-reader.d.ts.map +1 -1
  154. package/dist/execution/object-reader-ontology.d.ts +3 -0
  155. package/dist/execution/object-reader-ontology.d.ts.map +1 -1
  156. package/dist/execution/primitive.js +36 -35
  157. package/dist/execution/primitive.js.map +1 -1
  158. package/dist/execution/request.d.ts +1 -1
  159. package/dist/execution/request.d.ts.map +1 -1
  160. package/dist/execution/request.js +33 -32
  161. package/dist/execution/request.js.map +3 -3
  162. package/dist/http/api-routes.d.ts.map +1 -1
  163. package/dist/http/index.js +1 -1
  164. package/dist/index.d.ts +7 -7
  165. package/dist/index.d.ts.map +1 -1
  166. package/dist/index.js +63 -59
  167. package/dist/index.js.map +1 -1
  168. package/dist/maintenance/index.js +1 -1
  169. package/dist/materializer/index.js +22 -21
  170. package/dist/materializer/index.js.map +1 -1
  171. package/dist/models/audio/runtime.d.ts.map +1 -1
  172. package/dist/models/audio/types.d.ts +19 -0
  173. package/dist/models/audio/types.d.ts.map +1 -1
  174. package/dist/models/execution/index.js +20 -19
  175. package/dist/models/execution/index.js.map +1 -1
  176. package/dist/models/index.d.ts +1 -1
  177. package/dist/models/index.d.ts.map +1 -1
  178. package/dist/objects/index.js +36 -35
  179. package/dist/objects/index.js.map +1 -1
  180. package/dist/objects/query/executor.d.ts +3 -1
  181. package/dist/objects/query/executor.d.ts.map +1 -1
  182. package/dist/objects/query/explain.d.ts +3 -1
  183. package/dist/objects/query/explain.d.ts.map +1 -1
  184. package/dist/objects/query/index.d.ts +1 -1
  185. package/dist/objects/query/index.d.ts.map +1 -1
  186. package/dist/objects/query/index.js +19 -18
  187. package/dist/objects/query/index.js.map +1 -1
  188. package/dist/objects/query/link-query-clearance.d.ts +3 -0
  189. package/dist/objects/query/link-query-clearance.d.ts.map +1 -1
  190. package/dist/objects/query/links.d.ts +1 -1
  191. package/dist/objects/query/links.d.ts.map +1 -1
  192. package/dist/objects/query/validate.d.ts +17 -0
  193. package/dist/objects/query/validate.d.ts.map +1 -1
  194. package/dist/objects/sdk/runtime-query-executor.d.ts +1 -1
  195. package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
  196. package/dist/ontology/index.js +3 -3
  197. package/dist/ontology/internal.js +3 -3
  198. package/dist/pipelines/index.js +21 -20
  199. package/dist/pipelines/index.js.map +1 -1
  200. package/dist/projections/internal.js +20 -19
  201. package/dist/projections/internal.js.map +1 -1
  202. package/dist/queues/in-memory.d.ts +1 -1
  203. package/dist/queues/in-memory.d.ts.map +1 -1
  204. package/dist/runtime/create.d.ts.map +1 -1
  205. package/dist/runtime/definitions.d.ts +14 -0
  206. package/dist/runtime/definitions.d.ts.map +1 -1
  207. package/dist/runtime/host.d.ts +3 -1
  208. package/dist/runtime/host.d.ts.map +1 -1
  209. package/dist/runtime/index.d.ts +1 -1
  210. package/dist/runtime/index.d.ts.map +1 -1
  211. package/dist/runtime/internal.js +24 -23
  212. package/dist/runtime/internal.js.map +2 -2
  213. package/dist/runtime/locale.d.ts +0 -2
  214. package/dist/runtime/locale.d.ts.map +1 -1
  215. package/dist/runtime/resolve-definitions.d.ts +2 -1
  216. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  217. package/dist/runtime/sixb.d.ts.map +1 -1
  218. package/dist/sandboxes/auth.d.ts +26 -4
  219. package/dist/sandboxes/auth.d.ts.map +1 -1
  220. package/dist/sandboxes/errors.d.ts +19 -0
  221. package/dist/sandboxes/errors.d.ts.map +1 -1
  222. package/dist/sandboxes/exec.d.ts +2 -0
  223. package/dist/sandboxes/exec.d.ts.map +1 -1
  224. package/dist/sandboxes/index.d.ts +4 -2
  225. package/dist/sandboxes/index.d.ts.map +1 -1
  226. package/dist/sandboxes/index.js +13 -7
  227. package/dist/sandboxes/index.js.map +1 -1
  228. package/dist/sandboxes/sandbox.d.ts +15 -1
  229. package/dist/sandboxes/sandbox.d.ts.map +1 -1
  230. package/dist/security/view-conditions.d.ts.map +1 -1
  231. package/dist/shares/internal.js +16 -15
  232. package/dist/shares/internal.js.map +2 -2
  233. package/dist/storage/agents/in-memory.d.ts +18 -1
  234. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  235. package/dist/storage/agents/index.d.ts +1 -1
  236. package/dist/storage/agents/index.d.ts.map +1 -1
  237. package/dist/storage/agents/provider.d.ts +43 -9
  238. package/dist/storage/agents/provider.d.ts.map +1 -1
  239. package/dist/storage/agents/provider.js +19 -3
  240. package/dist/storage/agents/provider.js.map +1 -1
  241. package/dist/storage/agents/types.d.ts +150 -4
  242. package/dist/storage/agents/types.d.ts.map +1 -1
  243. package/dist/storage/ai-cost/analytics.d.ts +3 -2
  244. package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
  245. package/dist/storage/ai-cost/provider.js +4 -3
  246. package/dist/storage/ai-cost/provider.js.map +1 -1
  247. package/dist/storage/ai-cost/types.d.ts +5 -1
  248. package/dist/storage/ai-cost/types.d.ts.map +1 -1
  249. package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
  250. package/dist/storage/artifacts/record.d.ts +3 -1
  251. package/dist/storage/artifacts/record.d.ts.map +1 -1
  252. package/dist/storage/artifacts/types.d.ts +7 -0
  253. package/dist/storage/artifacts/types.d.ts.map +1 -1
  254. package/dist/storage/file-upload-sessions/provider.js +7 -7
  255. package/dist/storage/index.d.ts +2 -2
  256. package/dist/storage/index.d.ts.map +1 -1
  257. package/dist/storage/index.js +23 -22
  258. package/dist/storage/index.js.map +1 -1
  259. package/dist/storage/internal.js +8 -8
  260. package/dist/storage/operation-scope.d.ts.map +1 -1
  261. package/dist/storage/operation-scope.js +1 -1
  262. package/dist/storage/sync-runs/idempotency.d.ts.map +1 -1
  263. package/dist/storage/sync-runs/in-memory.d.ts +2 -1
  264. package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
  265. package/dist/storage/sync-runs/index.d.ts +1 -1
  266. package/dist/storage/sync-runs/index.d.ts.map +1 -1
  267. package/dist/storage/sync-runs/types.d.ts +27 -2
  268. package/dist/storage/sync-runs/types.d.ts.map +1 -1
  269. package/dist/storage/workflow-runs/provider.js +7 -7
  270. package/dist/syncs/accounts.d.ts +36 -0
  271. package/dist/syncs/accounts.d.ts.map +1 -0
  272. package/dist/syncs/builders.d.ts.map +1 -1
  273. package/dist/syncs/connections.d.ts +36 -0
  274. package/dist/syncs/connections.d.ts.map +1 -0
  275. package/dist/syncs/execution.d.ts +14 -4
  276. package/dist/syncs/execution.d.ts.map +1 -1
  277. package/dist/syncs/index.d.ts +2 -1
  278. package/dist/syncs/index.d.ts.map +1 -1
  279. package/dist/syncs/index.js +22 -21
  280. package/dist/syncs/index.js.map +1 -1
  281. package/dist/syncs/request.d.ts +16 -2
  282. package/dist/syncs/request.d.ts.map +1 -1
  283. package/dist/syncs/run-dispatch.d.ts +14 -2
  284. package/dist/syncs/run-dispatch.d.ts.map +1 -1
  285. package/dist/testing/agent-approval-storage-contract.d.ts.map +1 -1
  286. package/dist/testing/agent-inbox-storage-contract.d.ts.map +1 -1
  287. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  288. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
  289. package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
  290. package/dist/testing/index.js +1157 -100
  291. package/dist/testing/index.js.map +9 -9
  292. package/dist/testing/run-claim-storage-contract.d.ts.map +1 -1
  293. package/dist/testing/sandboxes-contract.d.ts.map +1 -1
  294. package/dist/webhooks/internal.js +17 -16
  295. package/dist/webhooks/internal.js.map +2 -2
  296. package/dist/workers/index.js +66 -13
  297. package/dist/workers/index.js.map +4 -4
  298. package/dist/workers/queue-worker.d.ts +5 -0
  299. package/dist/workers/queue-worker.d.ts.map +1 -1
  300. package/dist/workers/worker.d.ts +8 -0
  301. package/dist/workers/worker.d.ts.map +1 -1
  302. package/dist/workflows/index.js +42 -40
  303. package/dist/workflows/index.js.map +1 -1
  304. package/package.json +7 -1
  305. package/src/actions/validation.ts +3 -1
  306. package/src/agents/children.ts +6 -0
  307. package/src/agents/errors.ts +3 -0
  308. package/src/agents/execution.ts +170 -20
  309. package/src/agents/index.ts +5 -0
  310. package/src/agents/model-routing.ts +116 -34
  311. package/src/agents/request.ts +783 -38
  312. package/src/agents/run-events.ts +235 -38
  313. package/src/agents/run-session-children.ts +13 -2
  314. package/src/agents/run-token.ts +7 -0
  315. package/src/agents/run-turn.ts +140 -23
  316. package/src/agents/streams/index.ts +2 -0
  317. package/src/agents/streams/internal.ts +12 -0
  318. package/src/agents/streams/protocol.ts +69 -1
  319. package/src/agents/streams/steps.ts +131 -0
  320. package/src/agents/thread-access.ts +57 -2
  321. package/src/artifacts/publish/merge.ts +14 -3
  322. package/src/artifacts/run-query.ts +5 -2
  323. package/src/bootstrap/discovery.ts +61 -11
  324. package/src/calendar.ts +195 -0
  325. package/src/connectors/connections/capability.ts +40 -0
  326. package/src/connectors/connections/internal.ts +3 -0
  327. package/src/connectors/connections/service.ts +74 -5
  328. package/src/connectors/execution.ts +5 -6
  329. package/src/connectors/service.ts +23 -0
  330. package/src/deploy/index.ts +0 -5
  331. package/src/deploy/types.ts +12 -64
  332. package/src/deploy/validation.ts +1 -1
  333. package/src/env/index.ts +10 -4
  334. package/src/events/execution.ts +42 -2
  335. package/src/events/types/syncs.ts +4 -0
  336. package/src/execution/authorized-object-reader.ts +33 -5
  337. package/src/execution/object-reader-ontology.ts +6 -0
  338. package/src/execution/request.ts +1 -0
  339. package/src/http/api-routes.ts +8 -0
  340. package/src/index.ts +21 -2
  341. package/src/models/audio/runtime.ts +57 -14
  342. package/src/models/audio/types.ts +20 -0
  343. package/src/models/index.ts +1 -0
  344. package/src/objects/query/executor.ts +4 -0
  345. package/src/objects/query/explain.ts +5 -0
  346. package/src/objects/query/index.ts +1 -0
  347. package/src/objects/query/link-query-clearance.ts +4 -1
  348. package/src/objects/query/links.ts +5 -1
  349. package/src/objects/query/validate.ts +33 -1
  350. package/src/objects/sdk/runtime-query-executor.ts +7 -3
  351. package/src/runtime/create.ts +1 -0
  352. package/src/runtime/definitions.ts +25 -0
  353. package/src/runtime/host.ts +16 -8
  354. package/src/runtime/index.ts +6 -1
  355. package/src/runtime/locale.ts +0 -10
  356. package/src/runtime/resolve-definitions.ts +7 -1
  357. package/src/runtime/sixb.ts +12 -2
  358. package/src/sandboxes/README.md +12 -1
  359. package/src/sandboxes/auth.ts +32 -4
  360. package/src/sandboxes/errors.ts +27 -0
  361. package/src/sandboxes/exec.ts +3 -1
  362. package/src/sandboxes/index.ts +18 -1
  363. package/src/sandboxes/sandbox.ts +15 -1
  364. package/src/security/view-conditions.ts +2 -1
  365. package/src/storage/agents/in-memory.ts +271 -6
  366. package/src/storage/agents/index.ts +10 -0
  367. package/src/storage/agents/provider.ts +178 -13
  368. package/src/storage/agents/types.ts +166 -4
  369. package/src/storage/ai-cost/analytics.ts +22 -43
  370. package/src/storage/ai-cost/types.ts +5 -1
  371. package/src/storage/artifacts/in-memory.ts +20 -5
  372. package/src/storage/artifacts/record.ts +8 -2
  373. package/src/storage/artifacts/types.ts +7 -0
  374. package/src/storage/index.ts +11 -0
  375. package/src/storage/operation-scope.ts +1 -0
  376. package/src/storage/sync-runs/idempotency.ts +1 -0
  377. package/src/storage/sync-runs/in-memory.ts +43 -1
  378. package/src/storage/sync-runs/index.ts +1 -0
  379. package/src/storage/sync-runs/types.ts +30 -1
  380. package/src/syncs/accounts.ts +85 -0
  381. package/src/syncs/builders.ts +18 -1
  382. package/src/syncs/connections.ts +123 -0
  383. package/src/syncs/execution.ts +64 -22
  384. package/src/syncs/index.ts +3 -0
  385. package/src/syncs/request.ts +81 -23
  386. package/src/syncs/run-dispatch.ts +69 -7
  387. package/src/testing/agent-approval-storage-contract.ts +123 -0
  388. package/src/testing/agent-inbox-storage-contract.ts +59 -0
  389. package/src/testing/agent-storage-contract.ts +794 -8
  390. package/src/testing/ai-cost-storage-contract.ts +80 -0
  391. package/src/testing/artifact-storage-contract.ts +139 -0
  392. package/src/testing/run-claim-storage-contract.ts +116 -0
  393. package/src/testing/sandboxes-contract.ts +50 -0
  394. package/src/workers/README.md +4 -1
  395. package/src/workers/lost-runs.ts +1 -0
  396. package/src/workers/queue-worker.ts +16 -5
  397. package/src/workers/worker.ts +67 -7
  398. package/dist/chunk-5a4a52tq.js.map +0 -10
  399. package/dist/chunk-5t9gm5tt.js.map +0 -22
  400. package/dist/chunk-68hm50qh.js.map +0 -13
  401. package/dist/chunk-aw1z0gre.js +0 -234
  402. package/dist/chunk-aw1z0gre.js.map +0 -12
  403. package/dist/chunk-ey1p8w68.js.map +0 -13
  404. package/dist/chunk-k3jh8gsg.js.map +0 -10
  405. package/dist/chunk-nxysqbt0.js.map +0 -10
  406. package/dist/chunk-qavwr628.js.map +0 -12
  407. package/dist/chunk-s1mqyqmm.js.map +0 -18
  408. package/dist/chunk-zeykm8my.js.map +0 -14
  409. /package/dist/{chunk-stmxh0hv.js.map → chunk-3neam1y5.js.map} +0 -0
  410. /package/dist/{chunk-0hkdtwqk.js.map → chunk-44hrfmbk.js.map} +0 -0
  411. /package/dist/{chunk-s5pj68fa.js.map → chunk-5sswe5ej.js.map} +0 -0
  412. /package/dist/{chunk-q9nkpr8k.js.map → chunk-9tpmfh3n.js.map} +0 -0
  413. /package/dist/{chunk-naxjka9v.js.map → chunk-brhp9d97.js.map} +0 -0
  414. /package/dist/{chunk-8a8k38tz.js.map → chunk-brybqw5k.js.map} +0 -0
  415. /package/dist/{chunk-vehcr9eb.js.map → chunk-cg7cygfj.js.map} +0 -0
  416. /package/dist/{chunk-b4escq4c.js.map → chunk-cpy282b8.js.map} +0 -0
  417. /package/dist/{chunk-bc3y6gff.js.map → chunk-jka26v8c.js.map} +0 -0
  418. /package/dist/{chunk-zxhym8tr.js.map → chunk-k29rdc3h.js.map} +0 -0
  419. /package/dist/{chunk-1yh6jgtz.js.map → chunk-mrs7jy17.js.map} +0 -0
  420. /package/dist/{chunk-pqvvqc65.js.map → chunk-pfdq1ga6.js.map} +0 -0
  421. /package/dist/{chunk-k29n4176.js.map → chunk-phs5fbff.js.map} +0 -0
  422. /package/dist/{chunk-wqe9shx2.js.map → chunk-qbd282aa.js.map} +0 -0
  423. /package/dist/{chunk-paxabbqd.js.map → chunk-tapdssb5.js.map} +0 -0
  424. /package/dist/{chunk-dhkc9b23.js.map → chunk-v8a1qjzp.js.map} +0 -0
  425. /package/dist/{chunk-pc7kra3k.js.map → chunk-xavet0qs.js.map} +0 -0
  426. /package/dist/{chunk-m9ketb51.js.map → chunk-ygvay56w.js.map} +0 -0
  427. /package/dist/{chunk-0mvjpgvm.js.map → chunk-yyj009tv.js.map} +0 -0
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  normalizeAiPricingContext2,
4
4
  normalizeAiCostEstimate
5
- } from "./chunk-zeykm8my.js";
5
+ } from "./chunk-3qtk0070.js";
6
6
  // src/storage/ai-cost/codec.ts
7
7
  function aiModelCallCostDetails2(record) {
8
8
  return {
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/agents/errors.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * Base error for the agents module. Specific subclasses extend this so callers\n * can catch any agent-scoped failure with a single `instanceof AgentDefinitionError` check.\n */\nexport class AgentDefinitionError extends Error {\n readonly name: string = \"AgentDefinitionError\"\n}\n\n/**\n * An agent-tool failure whose message is intentionally safe to expose to the model and persist in\n * the durable trace. Tool authors must keep the message free of credentials and internal details;\n * unknown errors remain masked by the worker.\n */\nexport class AgentToolPublicError extends Error {\n readonly name: string = \"AgentToolPublicError\"\n}\n\n/** Raised when an agent tool result cannot cross the durable message boundary. */\nexport class AgentToolResultValidationError extends Error {\n readonly name = \"AgentToolResultValidationError\"\n\n constructor(\n readonly toolName: string,\n readonly reason: string,\n options?: ErrorOptions\n ) {\n super(`[Sixb] Agent tool '${toolName}' returned an invalid result; ${reason}.`, options)\n }\n}\n\nexport type AgentRequestErrorCode =\n | \"agent_selector_removed\"\n | \"agent_not_found\"\n | \"model_not_found\"\n | \"invalid_model_selection\"\n | \"invalid_locale\"\n | \"invalid_message\"\n | \"run_not_found\"\n | \"run_not_retryable\"\n | \"thread_not_found\"\n /** A conversation's write on a sub-agent's thread: a message, a fork, a participant, a mode. */\n | \"thread_not_conversation\"\n | \"active_run_exists\"\n | \"authority_not_inheritable\"\n | \"invalid_context\"\n | \"invalid_attachment\"\n | \"storage_unavailable\"\n | \"sandbox_not_configured\"\n | \"invalid_sandbox_params\"\n | \"sandbox_execution_unavailable\"\n | \"invalid_participant\"\n | \"not_thread_owner\"\n | \"not_run_requester\"\n | \"run_not_active\"\n | \"invalid_approval_mode\"\n | \"approval_not_found\"\n | \"approval_not_pending\"\n | \"approval_expired\"\n\n/**\n * Raised by {@link requestAgentRun} (the trigger). Callers branch on `code` rather than message text\n * — e.g. the HTTP layer maps `active_run_exists` to 409 and `agent_not_found` to 404.\n */\nexport class AgentRequestError extends Error {\n readonly name = \"AgentRequestError\"\n\n constructor(\n readonly code: AgentRequestErrorCode,\n message: string\n ) {\n super(message)\n }\n}\n\nexport type AgentMemoryErrorCode =\n | \"invalid_repo\"\n | \"invalid_save\"\n | \"not_allowed\"\n | \"storage_unavailable\"\n\n/**\n * Raised by `sixb.agent.memory`. Callers branch on `code`; the message says what to change, so the\n * HTTP layer can hand it to the Agent as it is.\n */\nexport class AgentMemoryError extends Error {\n readonly name = \"AgentMemoryError\"\n\n constructor(\n readonly code: AgentMemoryErrorCode,\n message: string\n ) {\n super(message)\n }\n}\n"
5
+ "/**\n * Base error for the agents module. Specific subclasses extend this so callers\n * can catch any agent-scoped failure with a single `instanceof AgentDefinitionError` check.\n */\nexport class AgentDefinitionError extends Error {\n readonly name: string = \"AgentDefinitionError\"\n}\n\n/**\n * An agent-tool failure whose message is intentionally safe to expose to the model and persist in\n * the durable trace. Tool authors must keep the message free of credentials and internal details;\n * unknown errors remain masked by the worker.\n */\nexport class AgentToolPublicError extends Error {\n readonly name: string = \"AgentToolPublicError\"\n}\n\n/** Raised when an agent tool result cannot cross the durable message boundary. */\nexport class AgentToolResultValidationError extends Error {\n readonly name = \"AgentToolResultValidationError\"\n\n constructor(\n readonly toolName: string,\n readonly reason: string,\n options?: ErrorOptions\n ) {\n super(`[Sixb] Agent tool '${toolName}' returned an invalid result; ${reason}.`, options)\n }\n}\n\nexport type AgentRequestErrorCode =\n | \"agent_selector_removed\"\n | \"agent_not_found\"\n | \"model_not_found\"\n | \"invalid_model_selection\"\n | \"invalid_locale\"\n | \"invalid_message\"\n | \"message_not_found\"\n | \"message_not_editable\"\n | \"not_message_author\"\n | \"run_not_found\"\n | \"run_not_retryable\"\n | \"thread_not_found\"\n /** A conversation's write on a sub-agent's thread: a message, a fork, a participant, a mode. */\n | \"thread_not_conversation\"\n | \"active_run_exists\"\n | \"authority_not_inheritable\"\n | \"invalid_context\"\n | \"invalid_attachment\"\n | \"storage_unavailable\"\n | \"sandbox_not_configured\"\n | \"invalid_sandbox_params\"\n | \"sandbox_execution_unavailable\"\n | \"invalid_participant\"\n | \"not_thread_owner\"\n | \"not_run_requester\"\n | \"run_not_active\"\n | \"invalid_approval_mode\"\n | \"approval_not_found\"\n | \"approval_not_pending\"\n | \"approval_expired\"\n\n/**\n * Raised by {@link requestAgentRun} (the trigger). Callers branch on `code` rather than message text\n * — e.g. the HTTP layer maps `active_run_exists` to 409 and `agent_not_found` to 404.\n */\nexport class AgentRequestError extends Error {\n readonly name = \"AgentRequestError\"\n\n constructor(\n readonly code: AgentRequestErrorCode,\n message: string\n ) {\n super(message)\n }\n}\n\nexport type AgentMemoryErrorCode =\n | \"invalid_repo\"\n | \"invalid_save\"\n | \"not_allowed\"\n | \"storage_unavailable\"\n\n/**\n * Raised by `sixb.agent.memory`. Callers branch on `code`; the message says what to change, so the\n * HTTP layer can hand it to the Agent as it is.\n */\nexport class AgentMemoryError extends Error {\n readonly name = \"AgentMemoryError\"\n\n constructor(\n readonly code: AgentMemoryErrorCode,\n message: string\n ) {\n super(message)\n }\n}\n"
6
6
  ],
7
- "mappings": ";;AAIO,MAAM,8BAA6B,MAAM;AAAA,EACrC,OAAe;AAC1B;AAAA;AAOO,MAAM,8BAA6B,MAAM;AAAA,EACrC,OAAe;AAC1B;AAAA;AAGO,MAAM,wCAAuC,MAAM;AAAA,EAI7C;AAAA,EACA;AAAA,EAJF,OAAO;AAAA,EAEhB,WAAW,CACA,UACA,QACT,SACA;AAAA,IACA,MAAM,sBAAsB,yCAAyC,WAAW,OAAO;AAAA,IAJ9E;AAAA,IACA;AAAA;AAKb;AAAA;AAmCO,MAAM,2BAA0B,MAAM;AAAA,EAIhC;AAAA,EAHF,OAAO;AAAA,EAEhB,WAAW,CACA,MACT,SACA;AAAA,IACA,MAAM,OAAO;AAAA,IAHJ;AAAA;AAKb;AAAA;AAYO,MAAM,0BAAyB,MAAM;AAAA,EAI/B;AAAA,EAHF,OAAO;AAAA,EAEhB,WAAW,CACA,MACT,SACA;AAAA,IACA,MAAM,OAAO;AAAA,IAHJ;AAAA;AAKb;",
7
+ "mappings": ";;AAIO,MAAM,8BAA6B,MAAM;AAAA,EACrC,OAAe;AAC1B;AAAA;AAOO,MAAM,8BAA6B,MAAM;AAAA,EACrC,OAAe;AAC1B;AAAA;AAGO,MAAM,wCAAuC,MAAM;AAAA,EAI7C;AAAA,EACA;AAAA,EAJF,OAAO;AAAA,EAEhB,WAAW,CACA,UACA,QACT,SACA;AAAA,IACA,MAAM,sBAAsB,yCAAyC,WAAW,OAAO;AAAA,IAJ9E;AAAA,IACA;AAAA;AAKb;AAAA;AAsCO,MAAM,2BAA0B,MAAM;AAAA,EAIhC;AAAA,EAHF,OAAO;AAAA,EAEhB,WAAW,CACA,MACT,SACA;AAAA,IACA,MAAM,OAAO;AAAA,IAHJ;AAAA;AAKb;AAAA;AAYO,MAAM,0BAAyB,MAAM;AAAA,EAI/B;AAAA,EAHF,OAAO;AAAA,EAEhB,WAAW,CACA,MACT,SACA;AAAA,IACA,MAAM,OAAO;AAAA,IAHJ;AAAA;AAKb;",
8
8
  "debugId": "A1F19C8AE043C31E64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  ProjectionValidationError2
4
- } from "./chunk-paxabbqd.js";
4
+ } from "./chunk-tapdssb5.js";
5
5
  import {
6
6
  sha256Canonical2
7
7
  } from "./chunk-zrvhsq7f.js";
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-5rqqp8cr.js";
13
13
  import {
14
14
  createPrimitiveExecutionRecord
15
- } from "./chunk-pc7kra3k.js";
15
+ } from "./chunk-xavet0qs.js";
16
16
  import {
17
17
  findPrimitiveRunExecution
18
18
  } from "./chunk-ey1nk510.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  validateSchemaValue2,
4
4
  isRecord2
5
- } from "./chunk-3zagkr6w.js";
5
+ } from "./chunk-7mhbs9yy.js";
6
6
  import {
7
7
  OntologyValidationError2
8
8
  } from "./chunk-cqr3acm1.js";
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  principalsEqual2
4
- } from "./chunk-xcrnrpfh.js";
4
+ } from "./chunk-394zjzjs.js";
5
5
  import {
6
6
  createFileUploadId2,
7
7
  isFileUploadSessionExpired,
@@ -39,7 +39,7 @@ import {
39
39
  normalizeLinkProperties2,
40
40
  validateLinkProperties2,
41
41
  validateTelemetryUnit2
42
- } from "./chunk-3zagkr6w.js";
42
+ } from "./chunk-7mhbs9yy.js";
43
43
  import {
44
44
  materializationEventKindOrdinal2,
45
45
  sha256Canonical2,
@@ -50,19 +50,19 @@ import {
50
50
  vectorConfiguration,
51
51
  vectorSources,
52
52
  normalizeVector2
53
- } from "./chunk-xcrnrpfh.js";
53
+ } from "./chunk-394zjzjs.js";
54
54
  import {
55
55
  resolveExecutionScopeAuthorization,
56
56
  ProjectionValidationError2,
57
57
  validateProjectionsAtStartup,
58
58
  isProjectionDefinition2
59
- } from "./chunk-paxabbqd.js";
59
+ } from "./chunk-tapdssb5.js";
60
60
  import {
61
61
  isStorageSerializationFailure2
62
- } from "./chunk-ewqn51gr.js";
62
+ } from "./chunk-88xeh6zx.js";
63
63
  import {
64
64
  objectBatchKey2
65
- } from "./chunk-gjhrz66x.js";
65
+ } from "./chunk-06kpaqg4.js";
66
66
  import {
67
67
  materializationApplyPhase2
68
68
  } from "./chunk-61zptves.js";
@@ -72,7 +72,7 @@ import {
72
72
  import {
73
73
  executionRecordInputFromRuntime,
74
74
  ensureExecutionRecord2
75
- } from "./chunk-pc7kra3k.js";
75
+ } from "./chunk-xavet0qs.js";
76
76
  import {
77
77
  assertPinnedDatasetWatermark2
78
78
  } from "./chunk-n8q5j6y5.js";
@@ -0,0 +1,114 @@
1
+ // @bun
2
+ // src/runtime/locale.ts
3
+ var DEFAULT_PROJECT_LOCALE = "en";
4
+ var DEFAULT_PROJECT_TIME_ZONE = "UTC";
5
+ function canonicalLocale(value) {
6
+ if (typeof value !== "string")
7
+ return;
8
+ try {
9
+ const [locale] = Intl.getCanonicalLocales(value);
10
+ return locale;
11
+ } catch {
12
+ return;
13
+ }
14
+ }
15
+
16
+ // src/calendar.ts
17
+ var MAX_PERIODS = 1e4;
18
+ var hourMs = 60 * 60 * 1000;
19
+ var dayMs = 24 * hourMs;
20
+ function canonicalTimeZone2(value) {
21
+ if (typeof value !== "string" || value.trim() !== value || value === "")
22
+ return;
23
+ let timeZone;
24
+ try {
25
+ timeZone = new Intl.DateTimeFormat("en-US", { timeZone: value }).resolvedOptions().timeZone;
26
+ } catch {
27
+ return;
28
+ }
29
+ return /^[+-]/.test(timeZone) ? undefined : timeZone;
30
+ }
31
+ var formatters = new Map;
32
+ function formatterFor(timeZone) {
33
+ let formatter = formatters.get(timeZone);
34
+ if (!formatter) {
35
+ formatter = new Intl.DateTimeFormat("en-US", {
36
+ timeZone,
37
+ year: "numeric",
38
+ month: "numeric",
39
+ day: "numeric",
40
+ hour: "numeric",
41
+ minute: "numeric",
42
+ second: "numeric",
43
+ hourCycle: "h23"
44
+ });
45
+ formatters.set(timeZone, formatter);
46
+ }
47
+ return formatter;
48
+ }
49
+ function wallClockOf(at, timeZone) {
50
+ const parts = formatterFor(timeZone).formatToParts(at);
51
+ const field = (type) => {
52
+ const part = parts.find((candidate) => candidate.type === type);
53
+ if (!part)
54
+ throw new TypeError(`[Sixb] ${timeZone} did not read back a ${type}.`);
55
+ return Number(part.value);
56
+ };
57
+ return Date.UTC(field("year"), field("month") - 1, field("day"), field("hour"), field("minute"), field("second"));
58
+ }
59
+ function offsetOf(at, timeZone) {
60
+ return wallClockOf(at, timeZone) - Math.floor(at.getTime() / 1000) * 1000;
61
+ }
62
+ function instantOf(wallClock, timeZone) {
63
+ const before = offsetOf(new Date(wallClock - dayMs), timeZone);
64
+ const after = offsetOf(new Date(wallClock + dayMs), timeZone);
65
+ if (before === after)
66
+ return new Date(wallClock - before);
67
+ const candidates = [wallClock - before, wallClock - after].sort((left, right) => left - right);
68
+ const found = candidates.find((instant) => wallClockOf(new Date(instant), timeZone) >= wallClock);
69
+ return new Date(found ?? candidates[candidates.length - 1]);
70
+ }
71
+ function wallClockAt2(at, timeZone = DEFAULT_PROJECT_TIME_ZONE) {
72
+ return new Date(wallClockOf(at, timeZone)).toISOString();
73
+ }
74
+ function wallClockInstant2(wallClock, timeZone = DEFAULT_PROJECT_TIME_ZONE) {
75
+ const wall = Date.parse(wallClock);
76
+ if (Number.isNaN(wall)) {
77
+ throw new TypeError(`[Sixb] ${JSON.stringify(wallClock)} is not a wall clock time.`);
78
+ }
79
+ return instantOf(wall, timeZone);
80
+ }
81
+ function periodWallClock(wallClock, period) {
82
+ if (period === "hour")
83
+ return wallClock - wallClock % hourMs;
84
+ const midnight = wallClock - wallClock % dayMs;
85
+ if (period === "day")
86
+ return midnight;
87
+ const mondayOffset = (new Date(midnight).getUTCDay() + 6) % 7;
88
+ return midnight - mondayOffset * dayMs;
89
+ }
90
+ function calendarPeriodStart2(at, period, timeZone = DEFAULT_PROJECT_TIME_ZONE) {
91
+ return instantOf(periodWallClock(wallClockOf(at, timeZone), period), timeZone);
92
+ }
93
+ function addCalendarPeriods2(at, period, count, timeZone = DEFAULT_PROJECT_TIME_ZONE) {
94
+ const step = period === "hour" ? hourMs : period === "week" ? 7 * dayMs : dayMs;
95
+ const start = periodWallClock(wallClockOf(at, timeZone), period);
96
+ return instantOf(start + count * step, timeZone);
97
+ }
98
+ function calendarPeriods2(from, to, period, timeZone = DEFAULT_PROJECT_TIME_ZONE) {
99
+ const periods = [];
100
+ let start = calendarPeriodStart2(from, period, timeZone);
101
+ while (start.getTime() < to.getTime()) {
102
+ if (periods.length >= MAX_PERIODS) {
103
+ throw new RangeError(`[Sixb] The range holds more than ${MAX_PERIODS} ${period} periods.`);
104
+ }
105
+ const end = addCalendarPeriods2(start, period, 1, timeZone);
106
+ periods.push({ start, end });
107
+ start = end;
108
+ }
109
+ return periods;
110
+ }
111
+
112
+ export { DEFAULT_PROJECT_LOCALE, DEFAULT_PROJECT_TIME_ZONE, canonicalLocale, canonicalTimeZone2, wallClockAt2, wallClockInstant2, calendarPeriodStart2, addCalendarPeriods2, calendarPeriods2 };
113
+
114
+ //# debugId=B253CA3F513E540B64756E2164756E21
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/runtime/locale.ts", "../src/calendar.ts"],
4
+ "sourcesContent": [
5
+ "/** Language assumed when a project sets none. */\nexport const DEFAULT_PROJECT_LOCALE = \"en\"\n\n/** Time zone assumed when a project sets none; cron schedules have always used it. */\nexport const DEFAULT_PROJECT_TIME_ZONE = \"UTC\"\n\n/** The canonical form of a BCP 47 language tag (`fr-fr` → `fr-FR`), or `undefined` if invalid. */\nexport function canonicalLocale(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined\n try {\n const [locale] = Intl.getCanonicalLocales(value)\n return locale\n } catch {\n return undefined\n }\n}\n",
6
+ "/**\n * Calendar arithmetic in an IANA time zone.\n *\n * A period of a zone's calendar is not a fixed number of milliseconds: where a zone changes its\n * clocks a day lasts 23 or 25 hours, and a zone such as Asia/Kolkata starts its hours half past a\n * UTC hour. Usage buckets are whole periods of the reader's calendar, so the queried range, the\n * bars and the calls in them all go through these functions.\n *\n * It is `@sixb/core/calendar` rather than `internal/*` because `@sixb/app` draws the bars with it,\n * and the app installs core by a compatible range, which `internal/*` refuses. It is not part of\n * the documented API: export only what the app calls.\n */\n\nimport { DEFAULT_PROJECT_TIME_ZONE } from \"./runtime/locale\"\n\n/** An hour, a day, or a week starting Monday: the periods a usage chart is drawn in. */\nexport type CalendarPeriod = \"hour\" | \"day\" | \"week\"\n\n/** A period of the calendar: a start and the start of the one after it. */\nexport interface CalendarPeriodRange {\n readonly start: Date\n readonly end: Date\n}\n\n/** A period wider than this many is a caller's mistake, not a chart. */\nconst MAX_PERIODS = 10_000\n\nconst hourMs = 60 * 60 * 1000\nconst dayMs = 24 * hourMs\n\n/**\n * The canonical IANA name of a time zone (`europe/paris` → `Europe/Paris`), or `undefined`.\n *\n * A UTC offset such as `+05:30` is refused even where `Intl` takes it: it names no zone, and\n * PostgreSQL reads it the POSIX way, five and a half hours west of UTC.\n */\nexport function canonicalTimeZone(value: unknown): string | undefined {\n if (typeof value !== \"string\" || value.trim() !== value || value === \"\") return undefined\n let timeZone: string\n try {\n timeZone = new Intl.DateTimeFormat(\"en-US\", { timeZone: value }).resolvedOptions().timeZone\n } catch {\n return undefined\n }\n return /^[+-]/.test(timeZone) ? undefined : timeZone\n}\n\n// Buckets are formatted for every call and every period of a range, so one formatter per zone is\n// built once: constructing one costs more than reading several of them.\nconst formatters = new Map<string, Intl.DateTimeFormat>()\n\nfunction formatterFor(timeZone: string): Intl.DateTimeFormat {\n let formatter = formatters.get(timeZone)\n if (!formatter) {\n formatter = new Intl.DateTimeFormat(\"en-US\", {\n timeZone,\n year: \"numeric\",\n month: \"numeric\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"numeric\",\n second: \"numeric\",\n hourCycle: \"h23\",\n })\n formatters.set(timeZone, formatter)\n }\n return formatter\n}\n\n/** The zone's wall clock at an instant, as the milliseconds `Date.UTC` gives for its fields. */\nfunction wallClockOf(at: Date, timeZone: string): number {\n const parts = formatterFor(timeZone).formatToParts(at)\n const field = (type: Intl.DateTimeFormatPartTypes) => {\n const part = parts.find((candidate) => candidate.type === type)\n if (!part) throw new TypeError(`[Sixb] ${timeZone} did not read back a ${type}.`)\n return Number(part.value)\n }\n return Date.UTC(\n field(\"year\"),\n field(\"month\") - 1,\n field(\"day\"),\n field(\"hour\"),\n field(\"minute\"),\n field(\"second\")\n )\n}\n\n/** How far the zone's wall clock runs ahead of UTC at an instant. */\nfunction offsetOf(at: Date, timeZone: string): number {\n return wallClockOf(at, timeZone) - Math.floor(at.getTime() / 1000) * 1000\n}\n\n/**\n * The instant a zone's wall clock reads `wallClock`.\n *\n * A wall clock the zone skips is met at the jump that skipped it, and one it reads twice starts the\n * period at its first reading, so periods stay in order and whole.\n */\nfunction instantOf(wallClock: number, timeZone: string): Date {\n const before = offsetOf(new Date(wallClock - dayMs), timeZone)\n const after = offsetOf(new Date(wallClock + dayMs), timeZone)\n if (before === after) return new Date(wallClock - before)\n const candidates = [wallClock - before, wallClock - after].sort((left, right) => left - right)\n const found = candidates.find((instant) => wallClockOf(new Date(instant), timeZone) >= wallClock)\n return new Date(found ?? candidates[candidates.length - 1]!)\n}\n\n/**\n * The zone's wall clock at an instant, spelled as `wallClockInstant` reads it back:\n * `2026-11-14T05:00:00.000Z` in America/New_York is `2026-11-14T00:00:00.000Z`.\n */\nexport function wallClockAt(at: Date, timeZone = DEFAULT_PROJECT_TIME_ZONE): string {\n return new Date(wallClockOf(at, timeZone)).toISOString()\n}\n\n/**\n * The instant a zone's wall clock names.\n *\n * `wallClock` is an ISO 8601 string whose `Z` marks the wall clock rather than UTC, as a provider\n * reads it out of a query without a time zone: `2026-11-14T00:00:00Z` is midnight in the zone.\n */\nexport function wallClockInstant(wallClock: string, timeZone = DEFAULT_PROJECT_TIME_ZONE): Date {\n const wall = Date.parse(wallClock)\n if (Number.isNaN(wall)) {\n throw new TypeError(`[Sixb] ${JSON.stringify(wallClock)} is not a wall clock time.`)\n }\n return instantOf(wall, timeZone)\n}\n\n/**\n * The wall clock a period of the calendar is named by: its hour, its midnight, or its Monday's.\n *\n * It is the name even where the zone skips it, so a period that began at the jump still steps to\n * the next midnight rather than to the next 1 am.\n */\nfunction periodWallClock(wallClock: number, period: CalendarPeriod): number {\n if (period === \"hour\") return wallClock - (wallClock % hourMs)\n const midnight = wallClock - (wallClock % dayMs)\n if (period === \"day\") return midnight\n\n // Weeks begin on Monday, which is what a date truncated to its week gives everywhere else.\n const mondayOffset = (new Date(midnight).getUTCDay() + 6) % 7\n return midnight - mondayOffset * dayMs\n}\n\n/** The start of the period an instant falls in, on the zone's calendar. */\nexport function calendarPeriodStart(\n at: Date,\n period: CalendarPeriod,\n timeZone = DEFAULT_PROJECT_TIME_ZONE\n): Date {\n return instantOf(periodWallClock(wallClockOf(at, timeZone), period), timeZone)\n}\n\n/**\n * The start of the period `count` periods away from the one `at` falls in.\n *\n * Stepping the zone's wall clock keeps every period whole across a change of clocks, where adding\n * milliseconds would land an hour off a boundary.\n */\nexport function addCalendarPeriods(\n at: Date,\n period: CalendarPeriod,\n count: number,\n timeZone = DEFAULT_PROJECT_TIME_ZONE\n): Date {\n const step = period === \"hour\" ? hourMs : period === \"week\" ? 7 * dayMs : dayMs\n const start = periodWallClock(wallClockOf(at, timeZone), period)\n return instantOf(start + count * step, timeZone)\n}\n\n/**\n * Every period of [from, to), starting with the one `from` falls in.\n *\n * A wall clock the zone skips begins its period where the clocks jump, which keeps the periods\n * contiguous through the hour the zone never had.\n */\nexport function calendarPeriods(\n from: Date,\n to: Date,\n period: CalendarPeriod,\n timeZone = DEFAULT_PROJECT_TIME_ZONE\n): readonly CalendarPeriodRange[] {\n const periods: CalendarPeriodRange[] = []\n let start = calendarPeriodStart(from, period, timeZone)\n while (start.getTime() < to.getTime()) {\n if (periods.length >= MAX_PERIODS) {\n throw new RangeError(`[Sixb] The range holds more than ${MAX_PERIODS} ${period} periods.`)\n }\n const end = addCalendarPeriods(start, period, 1, timeZone)\n periods.push({ start, end })\n start = end\n }\n return periods\n}\n"
7
+ ],
8
+ "mappings": ";;AACO,IAAM,yBAAyB;AAG/B,IAAM,4BAA4B;AAGlC,SAAS,eAAe,CAAC,OAA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
7
- ConnectorError2,
8
- createConnectorCodedError,
7
+ SyncValidationError2
8
+ } from "./chunk-04r2fdsd.js";
9
+ import {
9
10
  getConnectorExecutionSourceResolver
10
- } from "./chunk-qavwr628.js";
11
+ } from "./chunk-n1hbwc6y.js";
11
12
  import {
12
13
  isDatasetDefinition2
13
14
  } from "./chunk-wx7smkn2.js";
14
15
  import {
15
- SyncValidationError2
16
- } from "./chunk-aw1z0gre.js";
17
- import {
18
- isOAuthConnectorAdapter,
16
+ isOAuthConnectorDefinition2,
19
17
  isConnectorDefinition
20
18
  } from "./chunk-pvpq483h.js";
21
19
 
22
- // src/connectors/builders.ts
23
- function assertNonEmpty(value, field) {
24
- if (!value.trim()) {
25
- throw new ConnectorError2(`Connector ${field} must not be empty.`);
26
- }
27
- }
28
- function defineConnector2(id, adapter, options = {}) {
29
- assertNonEmpty(id, "id");
30
- assertNonEmpty(adapter.type, "type");
31
- if (typeof adapter.connect !== "function") {
32
- throw new ConnectorError2("Connector adapter connect must be a function.");
33
- }
34
- if (adapter.authentication !== undefined) {
35
- if (!isOAuthConnectorAdapter(adapter) || typeof adapter.authentication.authorizationUrl !== "function" || typeof adapter.authentication.exchangeCode !== "function" || typeof adapter.authentication.refresh !== "function" || typeof adapter.discoverAccounts !== "function") {
36
- throw createConnectorCodedError("connector.configuration_invalid", "OAuth connector adapters must define oauth2 authentication and implement authorizationUrl, exchangeCode, refresh, and discoverAccounts.");
37
- }
38
- }
39
- return {
40
- kind: "connector",
41
- id,
42
- adapter,
43
- ...options.owners === undefined ? {} : { owners: connectorOwners(id, adapter, options.owners) }
44
- };
45
- }
46
- function connectorOwners(id, adapter, owners) {
47
- if (!isOAuthConnectorAdapter(adapter)) {
48
- throw new ConnectorError2(`Connector '${id}' has no OAuth connections to own; remove its owners option.`);
49
- }
50
- const valid = owners.filter((owner) => owner === "project" || owner === "user");
51
- if (owners.length === 0 || valid.length !== owners.length || new Set(valid).size !== valid.length) {
52
- throw new ConnectorError2(`Connector '${id}' owners must list "project", "user" or both, each once.`);
53
- }
54
- return Object.freeze([...valid]);
55
- }
56
20
  // src/syncs/builders.ts
57
- function assertNonEmpty2(value, field) {
21
+ function assertNonEmpty(value, field) {
58
22
  if (!value.trim()) {
59
23
  throw new SyncValidationError2(`Sync ${field} must not be empty.`);
60
24
  }
61
25
  }
62
26
  function assertDataset(dataset, mode) {
63
- assertNonEmpty2(dataset.id, "dataset id");
27
+ assertNonEmpty(dataset.id, "dataset id");
64
28
  if (mode === "merge" && dataset.primaryKey === undefined) {
65
29
  throw new SyncValidationError2(`Merge sync dataset '${dataset.id}' must define a primaryKey.`);
66
30
  }
67
31
  }
32
+ function assertConnectorMode(syncId, connector, mode) {
33
+ if (mode !== "snapshot" || !isOAuthConnectorDefinition2(connector))
34
+ return;
35
+ throw new SyncValidationError2(`[Sixb] Sync '${syncId}' reads OAuth connector '${connector.id}', which runs once per connection, so a snapshot of one connection would replace every other connection's rows. Use mode "merge" and return change.delete() for records the provider deleted, or mode "append".`);
36
+ }
68
37
  function normalizeBatchSyncConfig(options) {
69
38
  const mode = options?.mode ?? "snapshot";
70
39
  if (mode !== "snapshot" && mode !== "append" && mode !== "merge") {
@@ -76,7 +45,7 @@ function normalizeBatchSyncConfig(options) {
76
45
  };
77
46
  }
78
47
  function defineSync2(id, options) {
79
- assertNonEmpty2(id, "id");
48
+ assertNonEmpty(id, "id");
80
49
  const config = normalizeBatchSyncConfig(options);
81
50
  const triggers = [];
82
51
  function createBuilder() {
@@ -92,6 +61,7 @@ function defineSync2(id, options) {
92
61
  return createBuilder();
93
62
  },
94
63
  from(connector) {
64
+ assertConnectorMode(id, connector, config.mode);
95
65
  return {
96
66
  read(handler) {
97
67
  return {
@@ -133,6 +103,6 @@ function isSyncDefinition2(value) {
133
103
  function isRecord(value) {
134
104
  return typeof value === "object" && value !== null && !Array.isArray(value);
135
105
  }
136
- export { defineConnector2, defineSync2, resolveSyncConnectorSources2, isSyncDefinition2 };
106
+ export { defineSync2, resolveSyncConnectorSources2, isSyncDefinition2 };
137
107
 
138
- //# debugId=5F788279C4C37FFD64756E2164756E21
108
+ //# debugId=EFF88ACC417108FB64756E2164756E21
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/syncs/builders.ts", "../src/syncs/sources.ts", "../src/syncs/types.ts"],
4
+ "sourcesContent": [
5
+ "import {\n type AnyConnectorAdapter,\n type ConnectorDefinition,\n isOAuthConnectorDefinition,\n} from \"../connectors\"\nimport type { DatasetDefinition } from \"../datasets\"\nimport type { ScheduleDefinition, ScheduleReference } from \"../schedules\"\nimport { isScheduleDefinition } from \"../schedules\"\nimport { SyncValidationError } from \"./errors\"\nimport type {\n BatchSyncConfig,\n BatchSyncDefinitionConfig,\n SyncBuilder,\n SyncDefinition,\n SyncMode,\n SyncReadBuilder,\n SyncTargetBuilder,\n} from \"./types\"\n\nfunction assertNonEmpty(value: string, field: string): void {\n if (!value.trim()) {\n throw new SyncValidationError(`Sync ${field} must not be empty.`)\n }\n}\n\nfunction assertDataset(dataset: DatasetDefinition, mode: SyncMode): void {\n assertNonEmpty(dataset.id, \"dataset id\")\n if (mode === \"merge\" && dataset.primaryKey === undefined) {\n throw new SyncValidationError(`Merge sync dataset '${dataset.id}' must define a primaryKey.`)\n }\n}\n\n/**\n * A sync on an OAuth connector runs once per connection, and a snapshot of one connection would\n * replace every other connection's rows.\n */\nfunction assertConnectorMode(syncId: string, connector: ConnectorDefinition, mode: SyncMode): void {\n if (mode !== \"snapshot\" || !isOAuthConnectorDefinition(connector)) return\n throw new SyncValidationError(\n `[Sixb] Sync '${syncId}' reads OAuth connector '${connector.id}', which runs once per connection, so a snapshot of one connection would replace every other connection's rows. Use mode \"merge\" and return change.delete() for records the provider deleted, or mode \"append\".`\n )\n}\n\nfunction normalizeBatchSyncConfig(options: BatchSyncConfig | undefined): BatchSyncDefinitionConfig {\n const mode = options?.mode ?? \"snapshot\"\n\n if (mode !== \"snapshot\" && mode !== \"append\" && mode !== \"merge\") {\n throw new SyncValidationError(\n `Invalid sync mode '${String(mode)}'. Expected 'snapshot', 'append', or 'merge'.`\n )\n }\n\n return {\n kind: \"batch\",\n mode,\n }\n}\n\ntype DefaultBatchSyncConfig = Omit<BatchSyncConfig, \"mode\"> & { readonly mode?: undefined }\n\n/**\n * Define a batch sync that reads from one connector and writes into one dataset.\n *\n * The returned definition is inert and safe to export from `syncs/` modules.\n * Supports `snapshot`, `append`, and keyed `merge` modes with optional triggers and checkpoints.\n */\nexport function defineSync<TId extends string>(\n id: TId,\n options?: DefaultBatchSyncConfig\n): SyncBuilder<TId, never, \"snapshot\">\nexport function defineSync<TId extends string, const TMode extends SyncMode>(\n id: TId,\n options: BatchSyncConfig<TMode> & { readonly mode: TMode }\n): SyncBuilder<TId, never, TMode>\nexport function defineSync<TId extends string>(\n id: TId,\n options: BatchSyncConfig\n): SyncBuilder<TId, never, SyncMode>\nexport function defineSync<TId extends string>(\n id: TId,\n options?: BatchSyncConfig\n): SyncBuilder<TId, never, SyncMode> {\n assertNonEmpty(id, \"id\")\n\n const config = normalizeBatchSyncConfig(options)\n const triggers: ScheduleReference[] = []\n\n function createBuilder<TCheckpoint>(): SyncBuilder<TId, TCheckpoint, SyncMode> {\n const builder: SyncBuilder<TId, TCheckpoint, SyncMode> = {\n when(schedule: ScheduleDefinition): SyncBuilder<TId, TCheckpoint, SyncMode> {\n if (!isScheduleDefinition(schedule)) {\n throw new SyncValidationError(\"Sync .when(...) only accepts schedules.\")\n }\n triggers.push({ type: \"schedule\", scheduleId: schedule.id })\n return builder\n },\n checkpoint<TNextCheckpoint>(): SyncBuilder<TId, TNextCheckpoint, SyncMode> {\n return createBuilder<TNextCheckpoint>()\n },\n from<TConnector extends ConnectorDefinition<string, AnyConnectorAdapter>>(\n connector: TConnector\n ): SyncReadBuilder<TId, TConnector, TCheckpoint, SyncMode> {\n assertConnectorMode(id, connector, config.mode)\n\n return {\n read(handler): SyncTargetBuilder<TId, TConnector, TCheckpoint, SyncMode> {\n return {\n intoDataset(\n dataset: DatasetDefinition\n ): SyncDefinition<TId, TConnector, TCheckpoint, SyncMode> {\n assertDataset(dataset, config.mode)\n\n return {\n kind: \"sync\",\n id,\n config,\n triggers,\n connector,\n read: handler,\n target: {\n kind: \"dataset\",\n dataset,\n },\n }\n },\n }\n },\n }\n },\n }\n\n return builder\n }\n\n return createBuilder<never>()\n}\n",
6
+ "import type { AnyConnectorAdapter, ConnectorDefinition, ConnectorRuntime } from \"../connectors\"\nimport {\n type ConnectorExecutionSource,\n type ConnectorExecutionSourceResolver,\n getConnectorExecutionSourceResolver,\n} from \"../connectors/execution\"\n\n/** One connector client invocation contributing values to a Sync run. */\nexport type SyncConnectorSource<TAdapter extends AnyConnectorAdapter = AnyConnectorAdapter> =\n ConnectorExecutionSource<TAdapter>\n\nexport type SyncConnectorSourceResolver = ConnectorExecutionSourceResolver\n\n/** Resolve the source invocations owned by one connector definition for a Sync execution. */\nexport function resolveSyncConnectorSources<TAdapter extends AnyConnectorAdapter>(\n connector: ConnectorRuntime,\n definition: ConnectorDefinition<string, TAdapter>\n): Promise<readonly SyncConnectorSource<TAdapter>[]> {\n return getConnectorExecutionSourceResolver(connector).list(definition)\n}\n",
7
+ "import type { BlobStorage } from \"../blob-storage\"\nimport {\n type AnyConnectorAdapter,\n type ConnectorAdapter,\n type ConnectorClient,\n type ConnectorConnectionMetadata,\n type ConnectorDefinition,\n isConnectorDefinition,\n type OAuthConnectorAdapter,\n} from \"../connectors\"\nimport type { DatasetDefinition, DatasetPrimaryKey, MergeChange } from \"../datasets\"\nimport { isDatasetDefinition } from \"../datasets\"\nimport type { Logger } from \"../logging\"\nimport type { ScheduleDefinition, ScheduleReference } from \"../schedules\"\nimport { isScheduleReference } from \"../schedules\"\n\n/** Blob operations available to sync read handlers. */\nexport type SyncBlobContext = Pick<BlobStorage, \"put\" | \"open\" | \"stat\">\n\n/** Non-secret connector connection metadata available to OAuth-backed Sync handlers. */\nexport type SyncConnectorConnection = ConnectorConnectionMetadata\n\ntype SyncConnectionContext<TAdapter extends AnyConnectorAdapter> =\n TAdapter extends OAuthConnectorAdapter\n ? { readonly connection: SyncConnectorConnection }\n : { readonly connection?: undefined }\n\n/** Context passed to a sync read handler. */\nexport type SyncReadContext<\n TCheckpoint = never,\n TAdapter extends AnyConnectorAdapter = ConnectorAdapter,\n> = {\n readonly projectId: string\n readonly syncId: string\n readonly signal: AbortSignal\n readonly blobs: SyncBlobContext\n readonly logger: Logger\n} & ([TCheckpoint] extends [never]\n ? { readonly checkpoint?: undefined }\n : {\n readonly checkpoint?: TCheckpoint\n setCheckpoint(next: TCheckpoint): void\n }) &\n SyncConnectionContext<TAdapter>\n\nexport type SyncMode = \"snapshot\" | \"append\" | \"merge\"\n\ntype MergeSyncChange = MergeChange<\n Readonly<Record<string, unknown>>,\n Readonly<Record<string, unknown>>\n>\n\n/** A sync read handler may return one item, a sync iterable, or an async iterable. */\nexport type SyncReadResult<TMode extends SyncMode = SyncMode> = TMode extends \"merge\"\n ? MergeSyncChange | Iterable<MergeSyncChange> | AsyncIterable<MergeSyncChange>\n : unknown | Iterable<unknown> | AsyncIterable<unknown>\n\n/** User-facing batch sync options accepted by `defineSync(...)`. */\nexport interface BatchSyncConfig<TMode extends SyncMode = SyncMode> {\n readonly mode?: TMode\n}\n\n/** Normalized batch sync config stored on the final sync definition. */\nexport interface BatchSyncDefinitionConfig<TMode extends SyncMode = SyncMode> {\n readonly kind: \"batch\"\n readonly mode: TMode\n}\n\n/** V1 syncs always target a named raw dataset. */\nexport interface DatasetSyncTarget {\n readonly kind: \"dataset\"\n readonly dataset: DatasetDefinition\n}\n\n/**\n * Connector-scoped read handler used by batch sync definitions.\n *\n * This intentionally uses TypeScript's method-parameter bivariance behavior so syncs with\n * different checkpoint types can still be stored as general `SyncDefinition[]` values. The\n * builder still gives users precise `context.checkpoint` and `setCheckpoint(...)` types when\n * they author a sync.\n */\nexport type SyncReadHandler<\n TAdapter extends AnyConnectorAdapter,\n TCheckpoint = never,\n TMode extends SyncMode = SyncMode,\n> = {\n bivarianceHack(\n client: ConnectorClient<TAdapter>,\n context: SyncReadContext<TCheckpoint, TAdapter>\n ): SyncReadResult<TMode> | Promise<SyncReadResult<TMode>>\n}[\"bivarianceHack\"]\n\n/**\n * Inert sync definition registered with Sixb.\n *\n * V1 supports batch syncs only. Definitions are declarative metadata and do not\n * start any background work on their own.\n */\nexport interface SyncDefinition<\n TId extends string = string,\n TConnector extends ConnectorDefinition<string, AnyConnectorAdapter> = ConnectorDefinition<\n string,\n AnyConnectorAdapter\n >,\n TCheckpoint = unknown,\n TMode extends SyncMode = SyncMode,\n> {\n readonly kind: \"sync\"\n readonly id: TId\n readonly config: BatchSyncDefinitionConfig<TMode>\n readonly triggers: readonly ScheduleReference[]\n readonly connector: TConnector\n readonly read: SyncReadHandler<TConnector[\"adapter\"], TCheckpoint, TMode>\n readonly target: DatasetSyncTarget\n}\n\nexport interface SyncTargetBuilder<\n TId extends string = string,\n TConnector extends ConnectorDefinition<string, AnyConnectorAdapter> = ConnectorDefinition<\n string,\n AnyConnectorAdapter\n >,\n TCheckpoint = never,\n TMode extends SyncMode = SyncMode,\n> {\n intoDataset<TDataset extends DatasetDefinition>(\n dataset: TMode extends \"merge\"\n ? TDataset & { readonly primaryKey: DatasetPrimaryKey }\n : TDataset\n ): SyncDefinition<TId, TConnector, TCheckpoint, TMode>\n}\n\nexport interface SyncReadBuilder<\n TId extends string = string,\n TConnector extends ConnectorDefinition<string, AnyConnectorAdapter> = ConnectorDefinition<\n string,\n AnyConnectorAdapter\n >,\n TCheckpoint = never,\n TMode extends SyncMode = SyncMode,\n> {\n read(\n handler: SyncReadHandler<TConnector[\"adapter\"], TCheckpoint, TMode>\n ): SyncTargetBuilder<TId, TConnector, TCheckpoint, TMode>\n}\n\nexport interface SyncBuilder<\n TId extends string = string,\n TCheckpoint = never,\n TMode extends SyncMode = SyncMode,\n> {\n when(schedule: ScheduleDefinition): SyncBuilder<TId, TCheckpoint, TMode>\n checkpoint<TNextCheckpoint>(): SyncBuilder<TId, TNextCheckpoint, TMode>\n from<TConnector extends ConnectorDefinition<string, AnyConnectorAdapter>>(\n connector: TConnector\n ): SyncReadBuilder<TId, TConnector, TCheckpoint, TMode>\n}\n\n/** Runtime type guard for values discovered from `syncs/` modules. */\nexport function isSyncDefinition(value: unknown): value is SyncDefinition {\n if (!isRecord(value)) {\n return false\n }\n\n return (\n value.kind === \"sync\" &&\n typeof value.id === \"string\" &&\n isRecord(value.config) &&\n value.config.kind === \"batch\" &&\n (value.config.mode === \"snapshot\" ||\n value.config.mode === \"append\" ||\n value.config.mode === \"merge\") &&\n Array.isArray(value.triggers) &&\n (value.triggers as unknown[]).every((reference) => isScheduleReference(reference)) &&\n isConnectorDefinition(value.connector) &&\n typeof value.read === \"function\" &&\n isRecord(value.target) &&\n value.target.kind === \"dataset\" &&\n isDatasetDefinition(value.target.dataset)\n )\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n"
8
+ ],
9
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAmBA,SAAS,cAAc,CAAC,OAAe,OAAqB;AAAA,EAC1D,IAAI,CAAC,MAAM,KAAK,GAAG;AAAA,IACjB,MAAM,IAAI,qBAAoB,QAAQ,0BAA0B;AAAA,EAClE;AAAA;AAGF,SAAS,aAAa,CAAC,SAA4B,MAAsB;AAAA,EACvE,eAAe,QAAQ,IAAI,YAAY;AAAA,EACvC,IAAI,SAAS,WAAW,QAAQ,eAAe,WAAW;AAAA,IACxD,MAAM,IAAI,qBAAoB,uBAAuB,QAAQ,+BAA+B;AAAA,EAC9F;AAAA;AAOF,SAAS,mBAAmB,CAAC,QAAgB,WAAgC,MAAsB;AAAA,EACjG,IAAI,SAAS,cAAc,CAAC,4BAA2B,SAAS;AAAA,IAAG;AAAA,EACnE,MAAM,IAAI,qBACR,gBAAgB,kCAAkC,UAAU,mNAC9D;AAAA;AAGF,SAAS,wBAAwB,CAAC,SAAiE;A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ACA,YACmD;AAAA,EACnD,OAAO,oCAAoC,SAAS,EAAE,KAAK,UAAU;AAAA;;AC8IhE,SAAS,iBAAgB,CAAC,OAAyC;AAAA,EACxE,IAAI,CAAC,SAAS,KAAK,GAAG;AAAA,IACpB,OAAO;AAAA,EACT;AAAA,EAEA,OACE,MAAM,SAAS,UACf,OAAO,MAAM,OAAO,YACpB,SAAS,MAAM,MAAM,KACrB,MAAM,OAAO,SAAS,YACrB,MAAM,OAAO,SAAS,cACrB,MAAM,OAAO,SAAS,YACtB,MAAM,OAAO,SAAS,YACxB,MAAM,QAAQ,MAAM,QAAQ,KAC3B,MAAM,SAAuB,MAAM,CAAC,cAAc,qBAAoB,SAAS,CAAC,KACjF,sBAAsB,MAAM,SAAS,KACrC,OAAO,MAAM,SAAS,cACtB,SAAS,MAAM,MAAM,KACrB,MAAM,OAAO,SAAS,aACtB,qBAAoB,MAAM,OAAO,OAAO;AAAA;AAI5C,SAAS,QAAQ,CAAC,OAAkD;AAAA,EAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAAA;",
10
+ "debugId": "EFF88ACC417108FB64756E2164756E21",
11
+ "names": []
12
+ }
@@ -4,10 +4,10 @@ import {
4
4
  ShareDefinitionError2,
5
5
  isShareDefinition,
6
6
  snapshotShareDefinition
7
- } from "./chunk-xcrnrpfh.js";
7
+ } from "./chunk-394zjzjs.js";
8
8
  import {
9
9
  isProjectionDefinition2
10
- } from "./chunk-paxabbqd.js";
10
+ } from "./chunk-tapdssb5.js";
11
11
  import {
12
12
  isMarkingDefinition,
13
13
  isGroupDefinition,
@@ -16,7 +16,7 @@ import {
16
16
  } from "./chunk-frsz8wxd.js";
17
17
  import {
18
18
  isWorkflowDefinition2
19
- } from "./chunk-z1njfqqs.js";
19
+ } from "./chunk-8qmp9fpa.js";
20
20
  import {
21
21
  isDatasetDefinition2
22
22
  } from "./chunk-wx7smkn2.js";
@@ -34,10 +34,10 @@ import {
34
34
  } from "./chunk-dvgc56n2.js";
35
35
  import {
36
36
  isSyncDefinition2
37
- } from "./chunk-68hm50qh.js";
37
+ } from "./chunk-fdk0ks9p.js";
38
38
  import {
39
39
  compileShareAccessPlan
40
- } from "./chunk-wqe9shx2.js";
40
+ } from "./chunk-qbd282aa.js";
41
41
  import {
42
42
  RuntimeError2
43
43
  } from "./chunk-m4ehq95f.js";
@@ -305,7 +305,7 @@ function instructionsError(message) {
305
305
  // src/bootstrap/discovery.ts
306
306
  import { AsyncLocalStorage } from "async_hooks";
307
307
  import { readdir as readdir2 } from "fs/promises";
308
- import { join as join2, relative as relative2, resolve, sep as sep2 } from "path";
308
+ import { join as join2, posix, relative as relative2, resolve, sep as sep2 } from "path";
309
309
  import { pathToFileURL } from "url";
310
310
 
311
311
  // src/rules/errors.ts
@@ -486,6 +486,7 @@ async function discoverOntologySources(projectRoot) {
486
486
  const objectTypes = [];
487
487
  const valueTypes = [];
488
488
  const modules = [];
489
+ const folders = new DefinitionFolderCollector;
489
490
  const seen = new Set;
490
491
  for (const loaded of loadedModules) {
491
492
  const objectTypeIds = [];
@@ -508,10 +509,10 @@ async function discoverOntologySources(projectRoot) {
508
509
  valueTypes.push(candidate);
509
510
  }
510
511
  }
511
- modules.push({
512
- path: toPosix(relative2("ontology", loaded.path)),
513
- objectTypeIds: [...new Set(objectTypeIds)]
514
- });
512
+ const path = toPosix(relative2("ontology", loaded.path));
513
+ for (const id of objectTypeIds)
514
+ folders.add(id, path);
515
+ modules.push({ path, objectTypeIds: [...new Set(objectTypeIds)] });
515
516
  }
516
517
  const discoveredSources = [...ontologyDocuments, ...objectTypes];
517
518
  if (valueTypes.length > 0) {
@@ -522,7 +523,7 @@ async function discoverOntologySources(projectRoot) {
522
523
  valueTypes
523
524
  });
524
525
  }
525
- return { sources: discoveredSources, modules };
526
+ return { sources: discoveredSources, modules, folders: folders.index };
526
527
  }
527
528
  var bundledProject = new AsyncLocalStorage;
528
529
  function withProjectModules2(projectRoot, modules, run) {
@@ -587,17 +588,50 @@ async function listProjectModules2(projectRoot) {
587
588
  ];
588
589
  return (await Promise.all(families.map(({ kind, directory }) => listFamilyModules(projectRoot, kind, directory)))).flat();
589
590
  }
591
+ var folderFamilies = new Set(["actions", "connectors", "datasets", "pipelines", "projections", "rules", "syncs", "workflows"]);
590
592
  async function discoverProjectDefinitions2(projectRoot) {
591
593
  const entries = await Promise.all(Object.entries(definitionDiscoveryRegistry).map(async ([key, family]) => {
592
- const definitions = await discoverDefinitionFamily(projectRoot, family);
593
- return [key, definitions];
594
+ const discovered = await discoverDefinitionFamily(projectRoot, family);
595
+ return [key, discovered];
594
596
  }));
595
- return Object.fromEntries(entries);
597
+ const folders = Object.fromEntries(entries.filter(([key]) => folderFamilies.has(key)).map(([key, { folders }]) => [key, folders]));
598
+ return {
599
+ ...Object.fromEntries(entries.map(([key, { definitions }]) => [key, definitions])),
600
+ folders
601
+ };
596
602
  }
597
603
  async function discoverDefinitionFamily(projectRoot, family) {
598
604
  const loadedModules = await loadFamilyModules(projectRoot, family.kind, family.directory);
599
605
  const exportedCandidates = new Set(loadedModules.flatMap((loaded) => loaded.exports));
600
- return [...exportedCandidates].filter(family.isDefinition);
606
+ const definitions = [...exportedCandidates].filter(family.isDefinition);
607
+ const isDefinition = new Set(definitions);
608
+ const directory = family.directory.join("/");
609
+ const folders = new DefinitionFolderCollector;
610
+ for (const loaded of loadedModules) {
611
+ const path = posix.relative(directory, toPosix(loaded.path));
612
+ for (const candidate of loaded.exports) {
613
+ if (isDefinition.has(candidate) && hasStringId(candidate))
614
+ folders.add(candidate.id, path);
615
+ }
616
+ }
617
+ return { definitions, folders: folders.index };
618
+ }
619
+
620
+ class DefinitionFolderCollector {
621
+ index = new Map;
622
+ depths = new Map;
623
+ add(id, path) {
624
+ const folder = posix.dirname(path);
625
+ const depth = folder === "." ? 0 : folder.split("/").length;
626
+ if ((this.depths.get(id) ?? -1) >= depth)
627
+ return;
628
+ this.depths.set(id, depth);
629
+ if (depth > 0)
630
+ this.index.set(id, folder);
631
+ }
632
+ }
633
+ function hasStringId(value) {
634
+ return isRecord3(value) && typeof value.id === "string";
601
635
  }
602
636
  function listOntologyModuleFiles(projectRoot) {
603
637
  return listModuleFiles(join2(projectRoot, "ontology"), isOntologyScriptsDirectory);
@@ -730,4 +764,4 @@ function isValueType(value) {
730
764
 
731
765
  export { isAgentContextPath2, discoverOntologyFiles, discoverAgentSkills, discoverProjectInstructions, RuleValidationError2, isRuleDefinition2, validateRulesAtStartup, defineRule2, validateSharesAtStartup, discoverOntologySources, withProjectModules2, listProjectModules2, discoverProjectDefinitions2, listOntologyModuleFiles };
732
766
 
733
- //# debugId=3FE74E9A374E410864756E2164756E21
767
+ //# debugId=3EFE897FF82D14AF64756E2164756E21