@desplega.ai/agent-swarm 2.11.0 → 2.12.0

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 (382) hide show
  1. package/dist/acp-adapter-11m13kx4.js +16 -0
  2. package/dist/{acp-targets-5wyy2b9m.js → acp-targets-311gcyvw.js} +9 -9
  3. package/dist/{actions-4nxq386s.js → actions-c4chgxp6.js} +24 -22
  4. package/dist/{agent-fs-provision-v6enh76w.js → agent-fs-provision-0b9awm5n.js} +10 -5
  5. package/dist/{amp-adapter-ze3x22qn.js → amp-adapter-r0veq6x5.js} +3 -3
  6. package/dist/{app-kyqt8ehw.js → app-hn5fftf5.js} +5 -5
  7. package/dist/{approval-notifications-a0db0esw.js → approval-notifications-3g6yc8nv.js} +7 -7
  8. package/dist/{assistant-9g5jzq25.js → assistant-cpjgpjvp.js} +24 -22
  9. package/dist/{boot-args-schema-d7fme4q1.js → boot-args-schema-hce1av1h.js} +1 -1
  10. package/dist/{boot-reembed-jrwxeye2.js → boot-reembed-bztbxc4z.js} +1 -1
  11. package/dist/{boot-reembed-6wpazmpw.js → boot-reembed-d7xcym0j.js} +1 -1
  12. package/dist/{boot-scrub-sweep-52h7yntp.js → boot-scrub-sweep-mkmm16gk.js} +2 -2
  13. package/dist/{boot-seeds-kb3dxjex.js → boot-seeds-arrkbe8t.js} +4 -4
  14. package/dist/{boxd-jrrmkv3w.js → boxd-68n75y1s.js} +1 -1
  15. package/dist/{claude-adapter-0c0y8fqp.js → claude-adapter-ykpyr5p8.js} +8 -8
  16. package/dist/{claude-managed-adapter-w2es07qq.js → claude-managed-adapter-ssg6z4bt.js} +4 -4
  17. package/dist/{claude-managed-setup-9ssb7ct4.js → claude-managed-setup-trd59v7b.js} +4 -4
  18. package/dist/{claude-sdk-session-p6t0gyse.js → claude-sdk-session-yjcze0j1.js} +10 -10
  19. package/dist/{cli-2gvdvsxj.js → cli-01tvvtad.js} +63 -60
  20. package/dist/{cli-rhsc2zyx.js → cli-04zc3f7b.js} +1 -1
  21. package/dist/{cli-p1a4khta.js → cli-0k1a0sde.js} +6 -6
  22. package/dist/{cli-atm0hkes.js → cli-0pp1yjg2.js} +4 -4
  23. package/dist/{cli-0b4zam62.js → cli-0vcqcwfn.js} +18 -0
  24. package/dist/{cli-zhn4r1rz.js → cli-12vek61e.js} +72 -49
  25. package/dist/{cli-j2r1apqm.js → cli-1htmtqc2.js} +45 -44
  26. package/dist/{cli-a6q6x15h.js → cli-2amwhyv2.js} +8 -5
  27. package/dist/{cli-w5dar1bk.js → cli-2m6yaq6b.js} +1 -1
  28. package/dist/{cli-a02habn6.js → cli-2tw284hj.js} +2 -2
  29. package/dist/{cli-nc39ym5q.js → cli-39qm0rtm.js} +6 -6
  30. package/dist/{cli-6c9ve77f.js → cli-3p288654.js} +2 -2
  31. package/dist/cli-52nfye5j.js +673 -0
  32. package/dist/cli-55tc8cj4.js +252 -0
  33. package/dist/cli-5r95eqbh.js +186 -0
  34. package/dist/{cli-892y3vfp.js → cli-5tg94mdw.js} +7 -7
  35. package/dist/{cli-ynph3b70.js → cli-5x03v6en.js} +8 -8
  36. package/dist/{cli-1h4njv9y.js → cli-5z0g0e8v.js} +11 -2
  37. package/dist/{cli-6a3j25xd.js → cli-72yms3ey.js} +16 -16
  38. package/dist/{cli-h2qtafm4.js → cli-73q4g5nx.js} +17 -17
  39. package/dist/{cli-k3c13za2.js → cli-7wy8gbwb.js} +1 -1
  40. package/dist/{cli-9g12h1aq.js → cli-7yn42w6m.js} +1 -1
  41. package/dist/{cli-g56fxddf.js → cli-8hp56wat.js} +3 -2
  42. package/dist/{cli-4aswccje.js → cli-9qe5y107.js} +2 -2
  43. package/dist/{cli-7cp6aa1q.js → cli-9y4tgrkf.js} +23 -177
  44. package/dist/{cli-mhrr4d5b.js → cli-agjbj5x0.js} +1 -1
  45. package/dist/{cli-hnh8erra.js → cli-b93d81yg.js} +2 -2
  46. package/dist/{cli-9yjhshah.js → cli-bhgrhedp.js} +1 -1
  47. package/dist/{cli-b82a13ga.js → cli-bp6k9acz.js} +17 -21
  48. package/dist/{cli-7e8sxqv5.js → cli-bpje8n65.js} +30 -3
  49. package/dist/{cli-t2s7j5cy.js → cli-bz97ff9n.js} +2 -2
  50. package/dist/{cli-0bgj4rh5.js → cli-c7j31hq9.js} +3 -3
  51. package/dist/{cli-p8zqbbt1.js → cli-cah298e5.js} +1 -1
  52. package/dist/{cli-9knhkkgr.js → cli-cjqyse9q.js} +3 -3
  53. package/dist/{cli-tb4j757d.js → cli-dkvtfgn4.js} +6 -6
  54. package/dist/{cli-14xdms9a.js → cli-e3ahxq5y.js} +6 -6
  55. package/dist/{cli-6n7y5ypy.js → cli-e8n0hdzd.js} +1 -1
  56. package/dist/{cli-q71g5q39.js → cli-en6dmkxd.js} +3 -3
  57. package/dist/{cli-xqbqwpxr.js → cli-eq4kew31.js} +9 -9
  58. package/dist/{cli-4kzp7r0q.js → cli-eqq0hwvx.js} +3 -3
  59. package/dist/{cli-bf0t77nf.js → cli-ercwc8xn.js} +1 -1
  60. package/dist/{cli-qncx2r0s.js → cli-ex1y88j3.js} +1 -1
  61. package/dist/{cli-bq97k63w.js → cli-fxd1mwtr.js} +2 -2
  62. package/dist/{cli-kbm659dk.js → cli-fy4gb74g.js} +2 -2
  63. package/dist/{cli-djt6wmrc.js → cli-fyaq4zdv.js} +6 -6
  64. package/dist/{cli-raqw9fw9.js → cli-gfy6hbd9.js} +6 -6
  65. package/dist/{cli-s9twe4x0.js → cli-h70a2mxy.js} +13 -8
  66. package/dist/cli-hbvgzjq4.js +69 -0
  67. package/dist/{cli-vy3fn0mz.js → cli-hhc47ack.js} +4 -4
  68. package/dist/{cli-m00c47q6.js → cli-j5gtytvg.js} +54 -24
  69. package/dist/{cli-ha4ek2nb.js → cli-js10kdk7.js} +1 -1
  70. package/dist/{cli-yzxqwcvq.js → cli-k5jx8jya.js} +10 -3
  71. package/dist/{cli-rytq7dm2.js → cli-krbcr00p.js} +3 -3
  72. package/dist/{cli-453497a0.js → cli-kwr5qv5g.js} +2 -2
  73. package/dist/{cli-czvvnfr9.js → cli-m5qtmrbc.js} +2 -2
  74. package/dist/{cli-cstggwq7.js → cli-ma9ys8rt.js} +2 -2
  75. package/dist/{cli-htymm48w.js → cli-mbwmqb5w.js} +1 -1
  76. package/dist/{cli-wz4e5am2.js → cli-mcymtvwn.js} +320 -70
  77. package/dist/{cli-2aacfdcn.js → cli-mq2fbgva.js} +64 -3
  78. package/dist/{cli-ramn8jae.js → cli-n85m2wkq.js} +1 -1
  79. package/dist/{cli-k4r5sfaj.js → cli-n8f0fs3c.js} +4 -4
  80. package/dist/{cli-f8yhybxr.js → cli-nja15knq.js} +3 -3
  81. package/dist/{cli-6tvh1fwq.js → cli-pe3yxedk.js} +3 -3
  82. package/dist/{cli-3bpr3wks.js → cli-pqfecppn.js} +1 -1
  83. package/dist/{cli-n6ygvrrm.js → cli-q2dywc8h.js} +4 -4
  84. package/dist/{cli-8zmpwe79.js → cli-q8tc22bj.js} +5 -5
  85. package/dist/{cli-yvzxbztc.js → cli-r0mz92by.js} +2 -2
  86. package/dist/{cli-v3zcnr8g.js → cli-r14ac1y0.js} +1 -1
  87. package/dist/{cli-fwjwkw66.js → cli-rtmqzat7.js} +2 -2
  88. package/dist/{cli-zqq57pgx.js → cli-s6zk31gr.js} +4 -4
  89. package/dist/{cli-27fat7st.js → cli-sv2r3bw8.js} +7 -7
  90. package/dist/{cli-zb1hff00.js → cli-t75xngj1.js} +9 -9
  91. package/dist/{cli-r813c7rb.js → cli-tdk7jtka.js} +1 -1
  92. package/dist/{cli-5ptj757f.js → cli-tm60vtax.js} +1 -1
  93. package/dist/{cli-rpmw4fsv.js → cli-v9ya390t.js} +12 -12
  94. package/dist/{cli-075ccjh6.js → cli-wvjqaqcp.js} +2607 -65
  95. package/dist/{cli-2jtfm8kh.js → cli-xf4z5bdn.js} +4 -4
  96. package/dist/{cli-4g323fjh.js → cli-xm34qj8m.js} +2 -2
  97. package/dist/{cli-f7dhm7hh.js → cli-ya3kf4gs.js} +1 -1
  98. package/dist/{cli-rwgwen5v.js → cli-yegz2g06.js} +4 -4
  99. package/dist/{cli-nbakg5xh.js → cli-yfpc6qy9.js} +3 -3
  100. package/dist/{cli-thd3005a.js → cli-z4f346g5.js} +1 -1
  101. package/dist/cli.js +24 -21
  102. package/dist/{codex-adapter-ssahg4h4.js → codex-adapter-wc6e4wct.js} +8 -8
  103. package/dist/{codex-login-9c7aggxe.js → codex-login-1ven7yje.js} +1 -1
  104. package/dist/{codex-session-runner-xn63q3h7.js → codex-session-runner-ppfgjd97.js} +9 -9
  105. package/dist/{commands-ctey7tr5.js → commands-tsv2vx5b.js} +3 -3
  106. package/dist/{controller-rqhbppg9.js → controller-ye4sdwsy.js} +4 -4
  107. package/dist/{controllers-connect-w3qbpbt1.js → controllers-connect-zn4dg69h.js} +25 -23
  108. package/dist/core-dxcy02sc.js +41 -0
  109. package/dist/{cursor-adapter-r819hf1a.js → cursor-adapter-q2g9vwts.js} +2 -2
  110. package/dist/{db-2ah39cyx.js → db-3r1fyr2n.js} +6 -2
  111. package/dist/{db-p5drc1d1.js → db-g111qn9j.js} +3 -3
  112. package/dist/{devin-adapter-bc6g0x29.js → devin-adapter-t8d86q9x.js} +1 -1
  113. package/dist/{dispatcher-x6w14pde.js → dispatcher-4q8s0mx8.js} +22 -20
  114. package/dist/{docker-6c4reetq.js → docker-1b41eysj.js} +2 -2
  115. package/dist/{dsh-adapter-h8qn14n4.js → dsh-adapter-mmcw1z5s.js} +2 -2
  116. package/dist/{e2b-z4ec0qve.js → e2b-ew8c5j5v.js} +2 -2
  117. package/dist/{e2b-jg7kyyef.js → e2b-xm60c8ad.js} +2 -2
  118. package/dist/{easter-egg-3d-1y6r9gxy.js → easter-egg-3d-04ke6hcp.js} +1 -1
  119. package/dist/{embedding-space-z6ptw3jk.js → embedding-space-kcdn52vz.js} +6 -6
  120. package/dist/{embeddings-0sxb1d2h.js → embeddings-jnzcd91a.js} +1 -1
  121. package/dist/{event-bus-swr88jg5.js → event-bus-v4ywhc2p.js} +1 -1
  122. package/dist/{execute-6m1ex8ce.js → execute-74amghty.js} +1 -1
  123. package/dist/{external-channel-ezer7pk0.js → external-channel-v9zgxnxz.js} +2 -2
  124. package/dist/fx-adapter-0ar6pqm3.js +19 -0
  125. package/dist/grok-adapter-t6m74fb1.js +19 -0
  126. package/dist/handlers-9kwcrc4k.js +38 -0
  127. package/dist/{heartbeat-6c4fr49t.js → heartbeat-p8pk1msj.js} +25 -23
  128. package/dist/{hook-t1c5avbv.js → hook-k1h73zd7.js} +5 -5
  129. package/dist/{hook-02rt5tvq.js → hook-p5reemds.js} +7 -7
  130. package/dist/{http-qa3h32a1.js → http-ms1z5xxy.js} +565 -141
  131. package/dist/index-23cdfzr6.js +39 -0
  132. package/dist/{index-kqv9ebfj.js → index-76zzxtzf.js} +1 -1
  133. package/dist/{index-e42j998x.js → index-fbkqhvvj.js} +38 -19
  134. package/dist/index-g7kkjs5b.js +38 -0
  135. package/dist/{index-qpjk2hxk.js → index-gjn6qfgn.js} +1 -1
  136. package/dist/{index-akbgsdhh.js → index-kn63q1gr.js} +26 -24
  137. package/dist/index-stk36pa5.js +43 -0
  138. package/dist/{k8s-7jrh5va2.js → k8s-fy8hbhkg.js} +2 -2
  139. package/dist/{keepalive-jmf6pn8c.js → keepalive-031js8jz.js} +4 -4
  140. package/dist/lead-mfggjtfk.js +77 -0
  141. package/dist/{maintenance-g7v15tj1.js → maintenance-sq9v3qx9.js} +1 -1
  142. package/dist/{oauth-refresh-sweep-ywgf8tbr.js → oauth-refresh-sweep-zqmnyvs8.js} +3 -3
  143. package/dist/object-webhooks-r24wwb5y.js +21 -0
  144. package/dist/{onboard-m3fedypq.js → onboard-p25yhh7t.js} +5 -5
  145. package/dist/{opencode-adapter-19ktcbb9.js → opencode-adapter-wcjc4zdk.js} +7 -7
  146. package/dist/{otel-impl-3ehm1hgc.js → otel-impl-ff1gf20m.js} +2 -2
  147. package/dist/{pending-fwj2fatd.js → pending-hxj5yatb.js} +23 -21
  148. package/dist/{pi-mono-adapter-xdeesvc4.js → pi-mono-adapter-vkp4zz7p.js} +12 -12
  149. package/dist/{pricing-refresh-4j8dzvxg.js → pricing-refresh-9w7gx41w.js} +2 -2
  150. package/dist/{rbac-roles-8msjr07m.js → rbac-roles-84aw10nz.js} +3 -3
  151. package/dist/{rbac-roles-n7t2acv8.js → rbac-roles-hz74vckp.js} +2 -2
  152. package/dist/{registry-32b1mft6.js → registry-eeyx1201.js} +1 -1
  153. package/dist/{render-v2-j7qggj8h.js → render-v2-nrdkg9gf.js} +5 -5
  154. package/dist/{resume-hj1mn65y.js → resume-s6ey36rh.js} +9 -9
  155. package/dist/{runtime-z31mdsgv.js → runtime-x0b4pyam.js} +1 -1
  156. package/dist/{session-access-w38fh09a.js → session-access-xv49tk14.js} +4 -4
  157. package/dist/{session-source-backfill-ax6qxv20.js → session-source-backfill-r5j988ah.js} +3 -3
  158. package/dist/{setup-dsqmpfcr.js → setup-mj0krk1p.js} +1 -1
  159. package/dist/thread-buffer-temgaqsy.js +41 -0
  160. package/dist/{tree-visibility-6vqmnr71.js → tree-visibility-cbrsfaar.js} +2 -2
  161. package/dist/{user-merge-jobs-mvheb3ed.js → user-merge-jobs-f9d8nwnw.js} +3 -3
  162. package/dist/{virtual-modules-w2qk2wew.js → virtual-modules-ns0ryw05.js} +3 -3
  163. package/dist/{work-objects-4ahy5es5.js → work-objects-pydhzast.js} +25 -23
  164. package/dist/worker-efcemc22.js +77 -0
  165. package/dist/{worker-follow-up-1gs4aw7y.js → worker-follow-up-9z2xec5e.js} +22 -20
  166. package/dist/{x-3wr8c5sh.js → x-3dtaf2r9.js} +2 -2
  167. package/openapi.json +788 -253
  168. package/package.json +8 -5
  169. package/src/azure-devops/auth.ts +2 -3
  170. package/src/be/agent-fs-identity.ts +46 -0
  171. package/src/be/agent-history.ts +215 -0
  172. package/src/be/db/agents.ts +34 -12
  173. package/src/be/db/tasks/write.ts +2 -2
  174. package/src/be/db.ts +2 -0
  175. package/src/be/migrations/332_primitive_objects.sql +31 -0
  176. package/src/be/migrations/334_agent_history.sql +23 -0
  177. package/src/be/migrations/335_primitive_object_webhooks.sql +36 -0
  178. package/src/be/primitives/boards/elements.ts +717 -0
  179. package/src/be/primitives/boards/excalifont-metrics.json +516 -0
  180. package/src/be/primitives/boards/service.ts +121 -0
  181. package/src/be/primitives/object-webhooks.ts +348 -0
  182. package/src/be/primitives/objects.ts +686 -0
  183. package/src/be/primitives/sheets/a1.ts +136 -0
  184. package/src/be/primitives/sheets/engine-worker.ts +194 -0
  185. package/src/be/primitives/sheets/engine.ts +199 -0
  186. package/src/be/primitives/sheets/format.ts +106 -0
  187. package/src/be/primitives/sheets/service.ts +415 -0
  188. package/src/be/primitives/write-object.ts +83 -0
  189. package/src/be/script-credential-broker.ts +8 -27
  190. package/src/be/scripts/typecheck.ts +216 -0
  191. package/src/be/seed/agent-fs-provision.ts +18 -0
  192. package/src/be/users.ts +19 -0
  193. package/src/commands/onboard/agent-fs-version.ts +1 -1
  194. package/src/commands/onboard/steps/harness.tsx +1 -1
  195. package/src/commands/provider-credentials.ts +1 -0
  196. package/src/e2b/env.ts +3 -1
  197. package/src/fs/agent-fs-provider.ts +33 -2
  198. package/src/gitlab/auth.ts +3 -4
  199. package/src/heartbeat/heartbeat.ts +11 -11
  200. package/src/http/agent-lifecycle.ts +152 -0
  201. package/src/http/agents.ts +12 -0
  202. package/src/http/all-routes.ts +2 -0
  203. package/src/http/auth.ts +2 -1
  204. package/src/http/index.ts +15 -0
  205. package/src/http/object-webhooks.ts +101 -0
  206. package/src/http/operator-actor.ts +2 -1
  207. package/src/http/sessions.ts +7 -0
  208. package/src/http/workflows.ts +32 -0
  209. package/src/integrations/chat-sdk/outbound-files.ts +3 -2
  210. package/src/providers/acp-targets.ts +2 -2
  211. package/src/providers/amp-adapter.ts +1 -1
  212. package/src/providers/opencode-adapter.ts +4 -1
  213. package/src/rbac/legacy-policy.ts +2 -0
  214. package/src/rbac/permissions.ts +5 -0
  215. package/src/script-workflows/guest-ctx.ts +32 -0
  216. package/src/script-workflows/workflow-ctx.ts +2 -0
  217. package/src/scripts-runtime/ctx.ts +9 -1
  218. package/src/scripts-runtime/executors/native.ts +106 -21
  219. package/src/scripts-runtime/executors/quickjs-prelude.ts +9 -2
  220. package/src/scripts-runtime/executors/quickjs-runner.ts +12 -1
  221. package/src/scripts-runtime/sdk-allowlist.ts +88 -0
  222. package/src/scripts-runtime/swarm-sdk.ts +51 -3
  223. package/src/scripts-runtime/types/stdlib.d.ts +267 -0
  224. package/src/scripts-runtime/types/swarm-sdk.d.ts +267 -0
  225. package/src/server.ts +48 -0
  226. package/src/tests/agent-history.test.ts +313 -0
  227. package/src/tests/azure-devops-auth.test.ts +6 -0
  228. package/src/tests/chat-sdk-outbound-files.test.ts +3 -1
  229. package/src/tests/check-unit-test-allowlist.test.ts +193 -0
  230. package/src/tests/credential-check.test.ts +12 -0
  231. package/src/tests/db-task-read-contract.test.ts +2 -0
  232. package/src/tests/db-task-write-contract.test.ts +2 -0
  233. package/src/tests/e2e-coverage-contract.test.ts +6 -2
  234. package/src/tests/e2e-diff-coverage.test.ts +154 -0
  235. package/src/tests/e2e-rerun-quarantine.test.ts +180 -0
  236. package/src/tests/e2e-shards.test.ts +137 -0
  237. package/src/tests/e2e-tracker-ingest.test.ts +266 -0
  238. package/src/tests/extensions-heartbeat.test.ts +34 -0
  239. package/src/tests/gitlab-auth.test.ts +10 -0
  240. package/src/tests/heartbeat.test.ts +38 -0
  241. package/src/tests/http-api-integration.test.ts +0 -6
  242. package/src/tests/opencode-adapter.test.ts +11 -0
  243. package/src/tests/primitives-boards.test.ts +686 -0
  244. package/src/tests/primitives-object-webhooks.test.ts +642 -0
  245. package/src/tests/primitives-objects.test.ts +248 -0
  246. package/src/tests/reasoning-kind-ui-parity.test.ts +112 -0
  247. package/src/tests/script-native-sandbox-identity.test.ts +264 -0
  248. package/src/tests/scripts-namespaces.test.ts +211 -0
  249. package/src/tests/secret-scrub-gate.test.ts +1 -0
  250. package/src/tests/secret-scrubber-convex.test.ts +168 -0
  251. package/src/tests/secret-scrubber.test.ts +1 -1
  252. package/src/tests/session-tokens.test.ts +27 -0
  253. package/src/tests/sheet-engine.test.ts +58 -0
  254. package/src/tests/slack-file-tools-attachments.test.ts +74 -6
  255. package/src/tests/slack-read-boundaries.test.ts +4 -2
  256. package/src/tests/task-start-after-commit.test.ts +82 -0
  257. package/src/tests/ui-logs-parser.test.ts +67 -0
  258. package/src/tests/workflow-retry-v2.test.ts +101 -0
  259. package/src/tests/workflow-tla-races.test.ts +29 -0
  260. package/src/tools/boards.ts +260 -0
  261. package/src/tools/objects.ts +191 -0
  262. package/src/tools/sheets.ts +312 -0
  263. package/src/tools/slack-read.ts +10 -3
  264. package/src/tools/tool-config.ts +23 -0
  265. package/src/tools/workflows/create-workflow.ts +11 -1
  266. package/src/tools/workflows/patch-workflow-node.ts +4 -0
  267. package/src/tools/workflows/patch-workflow.ts +4 -0
  268. package/src/tools/workflows/update-workflow.ts +17 -0
  269. package/src/types.ts +16 -0
  270. package/src/utils/sandboxed-process.ts +47 -2
  271. package/src/utils/secret-scrubber.ts +61 -6
  272. package/src/workflows/engine.ts +35 -21
  273. package/src/workflows/input.ts +29 -1
  274. package/src/workflows/patch-definition.ts +15 -1
  275. package/src/workflows/retry-poller.ts +15 -2
  276. package/src/workflows/validation.ts +10 -0
  277. package/templates/ai-toolbox.manifest.json +1 -1
  278. package/templates/skills/agent-browser/SKILL.md +1 -0
  279. package/templates/skills/agent-browser/content.md +1 -0
  280. package/templates/skills/pages/content.md +5 -0
  281. package/templates/skills/swarm-docs/content.md +6 -1
  282. package/templates/skills/swarm-scripts/SKILL.md +1 -0
  283. package/templates/skills/swarm-scripts/content.md +1 -0
  284. package/templates/skills/tdd-planning/content.md +5 -2
  285. package/dist/acp-adapter-weaaxey3.js +0 -16
  286. package/dist/core-df1n049h.js +0 -39
  287. package/dist/fx-adapter-zwmps9re.js +0 -19
  288. package/dist/grok-adapter-q0avf919.js +0 -19
  289. package/dist/handlers-g5jq0e4q.js +0 -36
  290. package/dist/index-1f6m47mq.js +0 -37
  291. package/dist/index-1p1mpqda.js +0 -36
  292. package/dist/index-tnkd410q.js +0 -41
  293. package/dist/lead-m5e7xt93.js +0 -75
  294. package/dist/thread-buffer-nf55vwx3.js +0 -39
  295. package/dist/worker-ews1nyhw.js +0 -75
  296. package/src/slack/socket-mode-guard.test.ts +0 -25
  297. package/src/tests/agent-activity.test.ts +0 -247
  298. package/src/tests/agent-fs-live-url.test.ts +0 -55
  299. package/src/tests/agentmail-inbox-mapping.test.ts +0 -73
  300. package/src/tests/approval-sweeps-config.test.ts +0 -47
  301. package/src/tests/cards.test.ts +0 -169
  302. package/src/tests/chat-sdk-facts.test.ts +0 -23
  303. package/src/tests/config-env-export-chat-sdk.test.ts +0 -11
  304. package/src/tests/core-auth.test.ts +0 -156
  305. package/src/tests/date-utils.test.ts +0 -48
  306. package/src/tests/db-context-versions.test.ts +0 -37
  307. package/src/tests/db-runtime.test.ts +0 -132
  308. package/src/tests/enabled-capabilities.test.ts +0 -20
  309. package/src/tests/extensions-example-mcp-install.test.ts +0 -67
  310. package/src/tests/extensions-lead-equivalence.test.ts +0 -70
  311. package/src/tests/get-workflow-run-tool.test.ts +0 -98
  312. package/src/tests/github-event-labels.test.ts +0 -24
  313. package/src/tests/haiku-5-5-pricing.test.ts +0 -38
  314. package/src/tests/http-log-scrubbing.test.ts +0 -123
  315. package/src/tests/http-semconv-attributes.test.ts +0 -92
  316. package/src/tests/identity.test.ts +0 -117
  317. package/src/tests/inbox-state.test.ts +0 -167
  318. package/src/tests/internal-ai/models.test.ts +0 -54
  319. package/src/tests/launch-password-rejection.test.ts +0 -140
  320. package/src/tests/list-total-cache.test.ts +0 -88
  321. package/src/tests/match-route.test.ts +0 -187
  322. package/src/tests/memory-feature-flags.test.ts +0 -45
  323. package/src/tests/memory-get-tool.test.ts +0 -269
  324. package/src/tests/memory-health-endpoint.test.ts +0 -78
  325. package/src/tests/memory-http-access.test.ts +0 -221
  326. package/src/tests/memory-retrieval-purge.test.ts +0 -99
  327. package/src/tests/multi-runtime-enabled-stats.test.ts +0 -229
  328. package/src/tests/openai-embedding-provider.test.ts +0 -159
  329. package/src/tests/org-identity.test.ts +0 -44
  330. package/src/tests/pages-actions-endpoint.test.ts +0 -103
  331. package/src/tests/pages-browser-sdk.test.ts +0 -76
  332. package/src/tests/pages-feedback-keys.test.ts +0 -121
  333. package/src/tests/pages-frame-ancestors.test.ts +0 -189
  334. package/src/tests/pages-list-endpoint.test.ts +0 -148
  335. package/src/tests/pages-password-mode.test.ts +0 -266
  336. package/src/tests/pages-public-authed-401.test.ts +0 -103
  337. package/src/tests/pages-public-html.test.ts +0 -297
  338. package/src/tests/pages-public-json-redirect.test.ts +0 -122
  339. package/src/tests/pages-view-count.test.ts +0 -245
  340. package/src/tests/prompt-templates-db.test.ts +0 -616
  341. package/src/tests/rbac-engine.test.ts +0 -742
  342. package/src/tests/repo-allow-merge-gate.test.ts +0 -389
  343. package/src/tests/route-def-find-route.test.ts +0 -192
  344. package/src/tests/runtime-stale-threshold.test.ts +0 -40
  345. package/src/tests/schedule-validation-helper.test.ts +0 -51
  346. package/src/tests/scheduled-tasks-api.test.ts +0 -355
  347. package/src/tests/scheduler-backoff.test.ts +0 -166
  348. package/src/tests/script-run-token.test.ts +0 -75
  349. package/src/tests/scripts-extract-signature.test.ts +0 -47
  350. package/src/tests/scripts-sdk-bridge-tool-failure.test.ts +0 -141
  351. package/src/tests/seed-workflow-dreaming.test.ts +0 -117
  352. package/src/tests/short-id.test.ts +0 -23
  353. package/src/tests/skill-files-http.test.ts +0 -222
  354. package/src/tests/skill-get-file-tool.test.ts +0 -110
  355. package/src/tests/skill-script-refs.test.ts +0 -63
  356. package/src/tests/skill-update-scope.test.ts +0 -252
  357. package/src/tests/skills-bundle.test.ts +0 -99
  358. package/src/tests/slack-app-icon.test.ts +0 -94
  359. package/src/tests/slack-assistant-comention.test.ts +0 -139
  360. package/src/tests/slack-delete.test.ts +0 -157
  361. package/src/tests/slack-inbound-diagnostics-auth.test.ts +0 -93
  362. package/src/tests/slack-manifest.test.ts +0 -23
  363. package/src/tests/slack-task-output.test.ts +0 -90
  364. package/src/tests/store-progress-output-guidance.test.ts +0 -34
  365. package/src/tests/swarm-diff.test.ts +0 -728
  366. package/src/tests/task-lifecycle-events.test.ts +0 -53
  367. package/src/tests/template-asset-config.test.ts +0 -18
  368. package/src/tests/template-fetch.test.ts +0 -490
  369. package/src/tests/themes-page-theme.test.ts +0 -155
  370. package/src/tests/tool-annotations.test.ts +0 -442
  371. package/src/tests/tool-output-agent-id.test.ts +0 -202
  372. package/src/tests/update-profile-agentid.test.ts +0 -248
  373. package/src/tests/whoami-route.test.ts +0 -162
  374. package/src/tests/workflow-definition-telemetry.test.ts +0 -144
  375. package/src/tests/workflow-patch.test.ts +0 -169
  376. package/src/tests/workflow-run-steps-index.test.ts +0 -65
  377. package/src/tests/workflow-schedule-trigger.test.ts +0 -104
  378. package/src/tests/workflow-step-claims.test.ts +0 -152
  379. package/src/tests/workflow-step-order.test.ts +0 -92
  380. package/src/tests/workflow-trigger-schema.test.ts +0 -359
  381. package/src/tests/workflow-versions.test.ts +0 -240
  382. package/src/tests/workflow-wait.test.ts +0 -26
@@ -403,27 +403,27 @@ import {
403
403
  recordInlineScriptRun2,
404
404
  exports_db,
405
405
  init_db4
406
- } from "./cli-zhn4r1rz.js";
406
+ } from "./cli-12vek61e.js";
407
407
  import {
408
408
  assertMayActOnOperatorGrantedTarget2,
409
409
  getUserGrant2,
410
410
  init_rbac_roles
411
- } from "./cli-cstggwq7.js";
411
+ } from "./cli-ma9ys8rt.js";
412
412
  import {
413
413
  ensurePricingSeeded2,
414
414
  ensureRbacSeeded2,
415
415
  ensureModelProfilesSeeded2,
416
416
  init_boot_seeds
417
- } from "./cli-f8yhybxr.js";
417
+ } from "./cli-nja15knq.js";
418
418
  import {
419
419
  requestModelCatalogRefresh2,
420
420
  startPricingRefreshLoop2,
421
421
  init_pricing_refresh
422
- } from "./cli-hnh8erra.js";
422
+ } from "./cli-b93d81yg.js";
423
423
  import {
424
424
  workflowEventBus2,
425
425
  init_event_bus
426
- } from "./cli-thd3005a.js";
426
+ } from "./cli-z4f346g5.js";
427
427
  import {
428
428
  slackCode,
429
429
  slackMissingScopeMessage,
@@ -432,7 +432,7 @@ import {
432
432
  externalChannelToolError2,
433
433
  getChannelBlockReason2,
434
434
  init_external_channel
435
- } from "./cli-bq97k63w.js";
435
+ } from "./cli-fxd1mwtr.js";
436
436
  import {
437
437
  tableToAscii2,
438
438
  init_dist8
@@ -495,7 +495,7 @@ import {
495
495
  startSlackApp2,
496
496
  stopSlackAppUnderLifecycleLock2,
497
497
  init_app4
498
- } from "./cli-6a3j25xd.js";
498
+ } from "./cli-72yms3ey.js";
499
499
  import {
500
500
  AGENT_MAX_TASKS_CONFIG_KEY,
501
501
  resetAgentMaxTasksMirror,
@@ -516,7 +516,7 @@ import {
516
516
  postApprovalCancellationUpdates2,
517
517
  createApprovalFollowUpTask2,
518
518
  init_approval_notifications
519
- } from "./cli-raqw9fw9.js";
519
+ } from "./cli-gfy6hbd9.js";
520
520
  import {
521
521
  shapeApprovalResolution,
522
522
  init_approval_resolution,
@@ -540,21 +540,15 @@ import {
540
540
  resumeFromChildRun2,
541
541
  initWaitBusSubscriptions2,
542
542
  init_resume
543
- } from "./cli-14xdms9a.js";
543
+ } from "./cli-e3ahxq5y.js";
544
544
  import {
545
- FilesError,
546
- providerPath,
547
- normalizeStoredKey,
548
- init_provider,
549
- AgentFsProvider,
550
- init_agent_fs_provider,
551
545
  getFileStorageProvider2,
552
546
  init_registry2
553
- } from "./cli-7cp6aa1q.js";
547
+ } from "./cli-5r95eqbh.js";
554
548
  import {
555
549
  getRuntimePool2,
556
550
  init_db2
557
- } from "./cli-8zmpwe79.js";
551
+ } from "./cli-q8tc22bj.js";
558
552
  import {
559
553
  duplicateGuardedQueryKey,
560
554
  parseQueryParams,
@@ -590,17 +584,21 @@ import {
590
584
  findRoute,
591
585
  route,
592
586
  init_route_def
593
- } from "./cli-nc39ym5q.js";
587
+ } from "./cli-39qm0rtm.js";
594
588
  import {
595
589
  COMPOSIO_HTTP_METHODS,
596
590
  executeComposioRequest,
597
591
  composioArgsFromParts,
598
592
  init_composio
599
- } from "./cli-bf0t77nf.js";
593
+ } from "./cli-ercwc8xn.js";
600
594
  import {
601
595
  object,
602
596
  init_v4_mini
603
597
  } from "./cli-vbppqvte.js";
598
+ import {
599
+ addMinutes,
600
+ init_date_fns
601
+ } from "./cli-wqb4sdt1.js";
604
602
  import {
605
603
  getMemoryRaterNames,
606
604
  init_memory_raters,
@@ -610,10 +608,6 @@ import {
610
608
  LlmRater,
611
609
  init_llm
612
610
  } from "./cli-bmqp0ser.js";
613
- import {
614
- addMinutes,
615
- init_date_fns
616
- } from "./cli-wqb4sdt1.js";
617
611
  import {
618
612
  require_dist,
619
613
  ConnectionAuthInputSchema,
@@ -692,7 +686,7 @@ import {
692
686
  init_typecheck,
693
687
  parseSkillContent,
694
688
  init_skill_parser
695
- } from "./cli-wz4e5am2.js";
689
+ } from "./cli-mcymtvwn.js";
696
690
  import {
697
691
  detachedProcessGroup,
698
692
  registerProcessGroup,
@@ -707,13 +701,57 @@ import {
707
701
  ensureToken,
708
702
  ensureTokenOrThrow,
709
703
  init_ensure_token
710
- } from "./cli-4aswccje.js";
704
+ } from "./cli-9qe5y107.js";
705
+ import {
706
+ A1Error,
707
+ refOf,
708
+ parseCell,
709
+ parseRange,
710
+ capToUsed,
711
+ formatRange,
712
+ areaOf,
713
+ assertInBounds,
714
+ init_a1,
715
+ MAX_TABS,
716
+ MAX_CELLS,
717
+ MAX_FILE_BYTES,
718
+ MAX_RANGE_CELLS,
719
+ SheetDocSchema,
720
+ checkTabName,
721
+ newTab,
722
+ usedExtent,
723
+ constantInput,
724
+ init_format,
725
+ PRIMITIVE_KINDS,
726
+ PRIMITIVE_KIND_NAMES,
727
+ ObjectsError,
728
+ NO_AGENT_FS_IDENTITY,
729
+ clientFor,
730
+ createObject,
731
+ getObject,
732
+ recordObjectVersion,
733
+ listObjects,
734
+ reindexObjects,
735
+ init_objects
736
+ } from "./cli-52nfye5j.js";
737
+ import {
738
+ agentFsClientFor,
739
+ init_agent_fs_identity
740
+ } from "./cli-hbvgzjq4.js";
741
+ import {
742
+ FilesError,
743
+ providerPath,
744
+ normalizeStoredKey,
745
+ init_provider,
746
+ AgentFsProvider,
747
+ init_agent_fs_provider
748
+ } from "./cli-9y4tgrkf.js";
711
749
  import {
712
750
  SLACK_LEAVE_THREAD_DISABLE,
713
751
  isSlackLeaveThreadDisabled,
714
752
  leaveSlackThread,
715
753
  init_left_threads
716
- } from "./cli-v3zcnr8g.js";
754
+ } from "./cli-r14ac1y0.js";
717
755
  import {
718
756
  require_fast_deep_equal
719
757
  } from "./cli-bhp11egn.js";
@@ -752,6 +790,9 @@ import {
752
790
  loadCompletedStepRouting,
753
791
  init_completed_step_routing,
754
792
  resolveInputValue,
793
+ serverRefInputKeys,
794
+ serverRefInputDeniedMessage,
795
+ agentMaySetServerRefInput,
755
796
  getSecretInputKeys,
756
797
  init_input,
757
798
  validateJsonSchema,
@@ -763,6 +804,7 @@ import {
763
804
  hasOwedSuccessors,
764
805
  init_successor_routing,
765
806
  init_template,
807
+ validateOutputSchema,
766
808
  runStepValidation,
767
809
  init_validation,
768
810
  TriggerSchemaError,
@@ -794,7 +836,7 @@ import {
794
836
  validateDefinition,
795
837
  applyDefinitionPatch,
796
838
  init_definition2
797
- } from "./cli-m00c47q6.js";
839
+ } from "./cli-j5gtytvg.js";
798
840
  import {
799
841
  isMultiRuntimeEnabled,
800
842
  init_multi_runtime2
@@ -817,11 +859,11 @@ import {
817
859
  import {
818
860
  canProvisionKind,
819
861
  init_runtime_providers
820
- } from "./cli-zqq57pgx.js";
862
+ } from "./cli-s6zk31gr.js";
821
863
  import {
822
864
  publicEndpointSsrfOptions,
823
865
  init_mcp_wrapper
824
- } from "./cli-t2s7j5cy.js";
866
+ } from "./cli-bz97ff9n.js";
825
867
  import {
826
868
  findUserById,
827
869
  findUserByExternalId,
@@ -836,7 +878,7 @@ import {
836
878
  resolveSessionToken,
837
879
  fingerprintApiKey,
838
880
  init_users
839
- } from "./cli-yzxqwcvq.js";
881
+ } from "./cli-k5jx8jya.js";
840
882
  import {
841
883
  resolveGitHubHost,
842
884
  getGitHubLinkConfig,
@@ -849,7 +891,7 @@ import {
849
891
  ampBillsCacheWrites,
850
892
  resolveAmpModel,
851
893
  init_amp_models
852
- } from "./cli-5ptj757f.js";
894
+ } from "./cli-tm60vtax.js";
853
895
  import {
854
896
  normalizeAssetKey,
855
897
  defaultAssetKey,
@@ -923,7 +965,7 @@ import {
923
965
  KvNamespaceSchema,
924
966
  KvKeySchema,
925
967
  init_types5
926
- } from "./cli-1h4njv9y.js";
968
+ } from "./cli-5z0g0e8v.js";
927
969
  import {
928
970
  generateDefaultClaudeMd2,
929
971
  generateDefaultSoulMd2,
@@ -934,7 +976,7 @@ import {
934
976
  init_task_attachment_links,
935
977
  contentSha256,
936
978
  init_profile_sync
937
- } from "./cli-mhrr4d5b.js";
979
+ } from "./cli-agjbj5x0.js";
938
980
  import {
939
981
  isSteeringEnabled2,
940
982
  init_steering_enabled
@@ -952,7 +994,7 @@ import {
952
994
  splitCredentialPool,
953
995
  selectCredential,
954
996
  init_credentials2
955
- } from "./cli-ha4ek2nb.js";
997
+ } from "./cli-js10kdk7.js";
956
998
  import {
957
999
  findInterpolationTokens,
958
1000
  interpolate,
@@ -1015,7 +1057,7 @@ import {
1015
1057
  import {
1016
1058
  init_package,
1017
1059
  package_default
1018
- } from "./cli-a6q6x15h.js";
1060
+ } from "./cli-2amwhyv2.js";
1019
1061
  import {
1020
1062
  getNodeEnv,
1021
1063
  isDevOrTestNodeEnv,
@@ -1035,7 +1077,7 @@ import {
1035
1077
  registerVolatileSecret,
1036
1078
  registerSensitiveKeyName,
1037
1079
  init_secret_scrubber
1038
- } from "./cli-7e8sxqv5.js";
1080
+ } from "./cli-bpje8n65.js";
1039
1081
  import {
1040
1082
  __toESM,
1041
1083
  __commonJS,
@@ -20417,10 +20459,15 @@ function startRetryPoller(registry, intervalMs = 5000) {
20417
20459
  if (!waiting)
20418
20460
  continue;
20419
20461
  if (result.waitFor === "workflow.child.finished") {
20420
- const { resumeFromChildRun } = await import("./resume-hj1mn65y.js");
20462
+ const { resumeFromChildRun } = await import("./resume-s6ey36rh.js");
20421
20463
  await resumeFromChildRun(step.id, registry);
20422
20464
  }
20423
20465
  } else {
20466
+ const outputSchemaError = validateOutputSchema(node, result);
20467
+ if (outputSchemaError) {
20468
+ await checkpointStepFailure(run.id, step.id, outputSchemaError, step.retryCount, undefined, { fence });
20469
+ continue;
20470
+ }
20424
20471
  let validationPassed;
20425
20472
  if (node.validation) {
20426
20473
  const validationResult = await runStepValidation(registry, node, result.output, ctx, meta);
@@ -21283,7 +21330,7 @@ var init_notify = __esm(() => {
21283
21330
  }
21284
21331
  }
21285
21332
  case "slack": {
21286
- const { getSlackApp } = await import("./app-kyqt8ehw.js");
21333
+ const { getSlackApp } = await import("./app-hn5fftf5.js");
21287
21334
  let app = getSlackApp();
21288
21335
  if (!app) {
21289
21336
  if (!isSlackConfigured()) {
@@ -23907,7 +23954,7 @@ function isMcpToolAllowedForScripts(mcpToolName) {
23907
23954
  function mcpToolNameForSdkMethod(name) {
23908
23955
  return SDK_TOOL_NAME_MAP[name] ?? name;
23909
23956
  }
23910
- var SDK_TOOL_NAME_MAP, SDK_ALLOWLIST, MCP_TOOL_NAMES, REST_ONLY_SDK_METHODS;
23957
+ var SDK_TOOL_NAME_MAP, SDK_ALLOWLIST, MCP_TOOL_NAMES, REST_ONLY_SDK_METHODS, SDK_NAMESPACES;
23911
23958
  var init_sdk_allowlist = __esm(() => {
23912
23959
  SDK_TOOL_NAME_MAP = {
23913
23960
  memory_search: "memory-search",
@@ -23937,6 +23984,24 @@ var init_sdk_allowlist = __esm(() => {
23937
23984
  room_change: "room-change",
23938
23985
  room_reset: "room-reset",
23939
23986
  room_decode: "room-decode",
23987
+ objects_create: "object-create",
23988
+ objects_get: "object-get",
23989
+ objects_list: "object-list",
23990
+ objects_reindex: "object-reindex",
23991
+ sheets_create: "sheet-create",
23992
+ sheets_get: "sheet-get",
23993
+ sheets_list: "sheet-list",
23994
+ sheets_getRange: "sheet-get-range",
23995
+ sheets_setRange: "sheet-set-range",
23996
+ sheets_appendRows: "sheet-append-rows",
23997
+ sheets_clearRange: "sheet-clear-range",
23998
+ sheets_addTab: "sheet-add-tab",
23999
+ boards_create: "board-create",
24000
+ boards_get: "board-get",
24001
+ boards_list: "board-list",
24002
+ boards_addElements: "board-add-elements",
24003
+ boards_updateElements: "board-update-elements",
24004
+ boards_removeElements: "board-remove-elements",
23940
24005
  repo_list: "get-repos",
23941
24006
  repo_update: "update-repo",
23942
24007
  schedule_list: "list-schedules",
@@ -24070,6 +24135,11 @@ var init_sdk_allowlist = __esm(() => {
24070
24135
  SDK_ALLOWLIST = Object.keys(SDK_TOOL_NAME_MAP);
24071
24136
  MCP_TOOL_NAMES = new Set(Object.values(SDK_TOOL_NAME_MAP));
24072
24137
  REST_ONLY_SDK_METHODS = ["savings_calibrationGet", "savings_calibrationRun"];
24138
+ SDK_NAMESPACES = Object.freeze({
24139
+ objects: ["create", "get", "list", "reindex"],
24140
+ sheets: ["create", "get", "list", "getRange", "setRange", "appendRows", "clearRange", "addTab"],
24141
+ boards: ["create", "get", "list", "addElements", "updateElements", "removeElements"]
24142
+ });
24073
24143
  });
24074
24144
 
24075
24145
  // src/kv-overflow.ts
@@ -24712,7 +24782,7 @@ function setPreloadedTools(server, names) {
24712
24782
  async function applyPreToolCall(name, args, requestInfo, inputSchema) {
24713
24783
  if (requestInfo.callOrigin !== "mcp")
24714
24784
  return { args };
24715
- const dispatcher = await import("./dispatcher-x6w14pde.js");
24785
+ const dispatcher = await import("./dispatcher-4q8s0mx8.js");
24716
24786
  const result = await dispatcher.dispatchPre("pre.tool.call", { tool: name, args, requestInfo }, inputSchema ? {
24717
24787
  validateModify: async (data) => {
24718
24788
  const schema = normalizeObjectSchema(inputSchema) ?? inputSchema;
@@ -26041,6 +26111,7 @@ var init_swarm_sdk = __esm(() => {
26041
26111
  "app-query",
26042
26112
  "resolve-user",
26043
26113
  "room-decode",
26114
+ "sheet-get-range",
26044
26115
  "read-messages",
26045
26116
  "check-model-profile",
26046
26117
  "preview-prompt-template"
@@ -28090,9 +28161,7 @@ function verifyAzureDevOpsWebhook(authorizationHeader) {
28090
28161
  if (separator === -1)
28091
28162
  return false;
28092
28163
  const password = decoded.slice(separator + 1);
28093
- if (password.length !== webhookSecret3.length)
28094
- return false;
28095
- return crypto.timingSafeEqual(Buffer.from(password), Buffer.from(webhookSecret3));
28164
+ return verifyTokenEquality(webhookSecret3, password);
28096
28165
  }
28097
28166
  function getAzureDevOpsToken() {
28098
28167
  return apiToken;
@@ -28139,6 +28208,7 @@ function resetAzureDevOps() {
28139
28208
  var initialized3 = false, webhookSecret3 = null, apiToken = null, orgUrl = null, AZURE_DEVOPS_BOT_NAME;
28140
28209
  var init_auth3 = __esm(() => {
28141
28210
  init_env_flag();
28211
+ init_triggers();
28142
28212
  AZURE_DEVOPS_BOT_NAME = process.env.AZURE_DEVOPS_BOT_NAME ?? "agent-swarm-bot";
28143
28213
  });
28144
28214
 
@@ -31600,9 +31670,7 @@ function verifyGitLabWebhook(tokenHeader) {
31600
31670
  return false;
31601
31671
  if (!tokenHeader)
31602
31672
  return false;
31603
- if (tokenHeader.length !== webhookSecret5.length)
31604
- return false;
31605
- return crypto.timingSafeEqual(Buffer.from(tokenHeader), Buffer.from(webhookSecret5));
31673
+ return verifyTokenEquality(webhookSecret5, tokenHeader);
31606
31674
  }
31607
31675
  function getGitLabToken() {
31608
31676
  return apiToken3;
@@ -31622,6 +31690,7 @@ function resetGitLab() {
31622
31690
  var initialized5 = false, webhookSecret5 = null, apiToken3 = null, gitlabUrl = "https://gitlab.com";
31623
31691
  var init_auth5 = __esm(() => {
31624
31692
  init_env_flag();
31693
+ init_triggers();
31625
31694
  });
31626
31695
 
31627
31696
  // src/gitlab/reactions.ts
@@ -35032,7 +35101,7 @@ async function callerAgentFs(agentId) {
35032
35101
  function chatFileOfPath(path, access) {
35033
35102
  const segments = pathSegments(path);
35034
35103
  const name = segments.at(-1);
35035
- const key = segments.map(encodeURIComponent).join("/");
35104
+ const key = segments.join("/");
35036
35105
  const keyScrubber = createValueScrubber([{ value: access.apiKey, name: "AGENT_FS_API_KEY" }]);
35037
35106
  return {
35038
35107
  name,
@@ -36339,7 +36408,7 @@ async function notifySlack(text) {
36339
36408
  return;
36340
36409
  }
36341
36410
  try {
36342
- const { getSlackApp } = await import("./app-kyqt8ehw.js");
36411
+ const { getSlackApp } = await import("./app-hn5fftf5.js");
36343
36412
  const app = getSlackApp();
36344
36413
  if (!app) {
36345
36414
  console.warn("[Jira webhook keepalive] Slack not available, cannot send notification");
@@ -36410,7 +36479,7 @@ async function deleteJiraWebhook(webhookId) {
36410
36479
  console.log(`[Jira webhook keepalive] Deleted webhook id=${webhookId}`);
36411
36480
  }
36412
36481
  async function overwriteWebhookIds(next) {
36413
- const { getDbClient } = await import("./db-2ah39cyx.js");
36482
+ const { getDbClient } = await import("./db-3r1fyr2n.js");
36414
36483
  await getDbClient().transaction(async (tx) => {
36415
36484
  const row = await tx.get("SELECT metadata FROM oauth_apps WHERE provider = 'jira'");
36416
36485
  if (!row) {
@@ -109691,7 +109760,7 @@ async function resolveHttpRequestAuth(req, apiKey, options = {}) {
109691
109760
  const bearer = extractBearer(req);
109692
109761
  if (!bearer)
109693
109762
  return null;
109694
- if (apiKey && bearer === apiKey) {
109763
+ if (apiKey && verifyTokenEquality(apiKey, bearer)) {
109695
109764
  const pageSession = singleHeader(req, "x-page-session");
109696
109765
  if (pageSession !== null) {
109697
109766
  const pageId = singleHeader(req, "x-page-id");
@@ -109736,6 +109805,7 @@ var init_auth = __esm(() => {
109736
109805
  init_db4();
109737
109806
  init_users();
109738
109807
  init_page_session();
109808
+ init_triggers();
109739
109809
  });
109740
109810
 
109741
109811
  // src/http/openapi.ts
@@ -109900,7 +109970,7 @@ async function loadGlobalConfigsIntoEnv2(override = false) {
109900
109970
  if (updated.length > 0) {
109901
109971
  refreshSecretScrubberCache();
109902
109972
  }
109903
- const { syncSlackTreeVisibility } = await import("./tree-visibility-6vqmnr71.js");
109973
+ const { syncSlackTreeVisibility } = await import("./tree-visibility-cbrsfaar.js");
109904
109974
  await syncSlackTreeVisibility();
109905
109975
  return updated;
109906
109976
  }
@@ -109908,14 +109978,14 @@ async function reloadGlobalConfigsAndIntegrations2() {
109908
109978
  return runWithoutRequestAuth(() => runSlackLifecycleExclusive(() => reloadGlobalConfigsAndIntegrationsInner()));
109909
109979
  }
109910
109980
  async function reloadGlobalConfigsAndIntegrationsInner() {
109911
- const { getEmbeddingProvider, resetEmbeddingProvider } = await import("./index-kqv9ebfj.js");
109981
+ const { getEmbeddingProvider, resetEmbeddingProvider } = await import("./index-76zzxtzf.js");
109912
109982
  const wasEmbeddingsConfigured = getEmbeddingProvider().isConfigured();
109913
109983
  const updated = await loadGlobalConfigsIntoEnv2(true);
109914
109984
  await syncTelemetryEnabled("settings").catch((err) => {
109915
109985
  console.error("[config-reload] telemetry re-init failed (non-fatal):", err);
109916
109986
  });
109917
109987
  await stopSlackAppUnderLifecycleLock2();
109918
- const { resetFileStorageProvider } = await import("./registry-32b1mft6.js");
109988
+ const { resetFileStorageProvider } = await import("./registry-eeyx1201.js");
109919
109989
  resetFileStorageProvider();
109920
109990
  resetEmbeddingProvider();
109921
109991
  const isEmbeddingsConfigured = getEmbeddingProvider().isConfigured();
@@ -109924,7 +109994,7 @@ async function reloadGlobalConfigsAndIntegrationsInner() {
109924
109994
  integrations.push("embeddings");
109925
109995
  }
109926
109996
  if (isEmbeddingsConfigured) {
109927
- import("./embedding-space-z6ptw3jk.js").then(({ runEmbeddingMaintenance }) => runEmbeddingMaintenance({ backfill: !wasEmbeddingsConfigured })).catch((err) => {
109997
+ import("./embedding-space-kcdn52vz.js").then(({ runEmbeddingMaintenance }) => runEmbeddingMaintenance({ backfill: !wasEmbeddingsConfigured })).catch((err) => {
109928
109998
  console.error("[config-reload] embedding maintenance failed (non-fatal):", err);
109929
109999
  });
109930
110000
  }
@@ -115138,6 +115208,1773 @@ var init_app_upsert = __esm(() => {
115138
115208
  init_utils();
115139
115209
  });
115140
115210
 
115211
+ // node_modules/fractional-indexing/src/index.js
115212
+ function getDigitIndex(digits) {
115213
+ let m = digitIndexCache.get(digits);
115214
+ if (m === undefined) {
115215
+ m = new Uint8Array(256);
115216
+ for (let i = 0;i < digits.length; i++) {
115217
+ m[digits.charCodeAt(i)] = i;
115218
+ }
115219
+ digitIndexCache.set(digits, m);
115220
+ }
115221
+ return m;
115222
+ }
115223
+ function midpoint(a, b, digits, lookup) {
115224
+ const zero = digits[0];
115225
+ if (b != null && a >= b) {
115226
+ throw new Error(a + " >= " + b);
115227
+ }
115228
+ if (a.slice(-1) === zero || b && b.slice(-1) === zero) {
115229
+ throw new Error("trailing zero");
115230
+ }
115231
+ if (b) {
115232
+ let n = 0;
115233
+ while ((a[n] || zero) === b[n]) {
115234
+ n++;
115235
+ }
115236
+ if (n > 0) {
115237
+ return b.slice(0, n) + midpoint(a.slice(n), b.slice(n), digits, lookup);
115238
+ }
115239
+ }
115240
+ const digitA = a ? lookup[a.charCodeAt(0)] : 0;
115241
+ const digitB = b != null ? lookup[b.charCodeAt(0)] : digits.length;
115242
+ if (digitB - digitA > 1) {
115243
+ const midDigit = Math.round(0.5 * (digitA + digitB));
115244
+ return digits[midDigit];
115245
+ } else {
115246
+ if (b && b.length > 1) {
115247
+ return b.slice(0, 1);
115248
+ } else {
115249
+ return digits[digitA] + midpoint(a.slice(1), null, digits, lookup);
115250
+ }
115251
+ }
115252
+ }
115253
+ function validateInteger(int, intDigits, intLookup) {
115254
+ if (int.length !== getIntegerLength(int[0], intDigits, intLookup)) {
115255
+ throw new Error("invalid integer part of order key: " + int);
115256
+ }
115257
+ }
115258
+ function getIntegerLength(head, intDigits, intLookup) {
115259
+ const i = intLookup[head.charCodeAt(0)];
115260
+ if (intDigits[i] === head) {
115261
+ const half = intDigits.length / 2;
115262
+ return i < half ? half - i + 1 : i - half + 2;
115263
+ }
115264
+ throw new Error("invalid order key head: " + head);
115265
+ }
115266
+ function getIntegerPart(key, intDigits, intLookup) {
115267
+ const integerPartLength = getIntegerLength(key[0], intDigits, intLookup);
115268
+ if (integerPartLength > key.length) {
115269
+ throw new Error("invalid order key: " + key);
115270
+ }
115271
+ return key.slice(0, integerPartLength);
115272
+ }
115273
+ function validateOrderKey(key, digits, intDigits, intLookup) {
115274
+ if (isSmallestInteger(key, digits, intDigits)) {
115275
+ throw new Error("invalid order key: " + key);
115276
+ }
115277
+ const i = getIntegerPart(key, intDigits, intLookup);
115278
+ const f = key.slice(i.length);
115279
+ if (f.slice(-1) === digits[0]) {
115280
+ throw new Error("invalid order key: " + key);
115281
+ }
115282
+ }
115283
+ function incrementInteger(x, digits, lookup, intDigits, intLookup) {
115284
+ validateInteger(x, intDigits, intLookup);
115285
+ const head = x[0];
115286
+ const zero = digits[0];
115287
+ let trailing = "";
115288
+ for (let i = x.length - 1;i >= 1; i--) {
115289
+ const d = lookup[x.charCodeAt(i)] + 1;
115290
+ if (d === digits.length) {
115291
+ trailing = zero + trailing;
115292
+ } else {
115293
+ return head + x.slice(1, i) + digits[d] + trailing;
115294
+ }
115295
+ }
115296
+ const headIndex = intLookup[head.charCodeAt(0)];
115297
+ if (headIndex === intDigits.length - 1) {
115298
+ return null;
115299
+ }
115300
+ const h = intDigits[headIndex + 1];
115301
+ const lengthDelta = getIntegerLength(h, intDigits, intLookup) - getIntegerLength(head, intDigits, intLookup);
115302
+ return h + (lengthDelta > 0 ? trailing + zero : lengthDelta < 0 ? trailing.slice(1) : trailing);
115303
+ }
115304
+ function decrementInteger(x, digits, lookup, intDigits, intLookup) {
115305
+ validateInteger(x, intDigits, intLookup);
115306
+ const head = x[0];
115307
+ const last = digits[digits.length - 1];
115308
+ let trailing = "";
115309
+ for (let i = x.length - 1;i >= 1; i--) {
115310
+ const d = lookup[x.charCodeAt(i)] - 1;
115311
+ if (d === -1) {
115312
+ trailing = last + trailing;
115313
+ } else {
115314
+ return head + x.slice(1, i) + digits[d] + trailing;
115315
+ }
115316
+ }
115317
+ const headIndex = intLookup[head.charCodeAt(0)];
115318
+ if (headIndex === 0) {
115319
+ return null;
115320
+ }
115321
+ const h = intDigits[headIndex - 1];
115322
+ const lengthDelta = getIntegerLength(h, intDigits, intLookup) - getIntegerLength(head, intDigits, intLookup);
115323
+ return h + (lengthDelta > 0 ? trailing + last : lengthDelta < 0 ? trailing.slice(1) : trailing);
115324
+ }
115325
+ function isSmallestInteger(key, digits, intDigits) {
115326
+ let byDigit = repeatedKeysCache.get(intDigits);
115327
+ if (byDigit === undefined) {
115328
+ byDigit = new Map;
115329
+ repeatedKeysCache.set(intDigits, byDigit);
115330
+ }
115331
+ const zeroCode = digits.charCodeAt(0);
115332
+ let cached = byDigit.get(zeroCode);
115333
+ if (cached === undefined) {
115334
+ cached = intDigits[0] + digits[0].repeat(intDigits.length / 2);
115335
+ byDigit.set(zeroCode, cached);
115336
+ }
115337
+ return key === cached;
115338
+ }
115339
+ function isStrictlyAscending(s) {
115340
+ for (let i = 1;i < s.length; i++) {
115341
+ if (s.charCodeAt(i - 1) >= s.charCodeAt(i)) {
115342
+ return false;
115343
+ }
115344
+ }
115345
+ return true;
115346
+ }
115347
+ function isSingleByte(s) {
115348
+ for (let i = 0;i < s.length; i++) {
115349
+ if (s.charCodeAt(i) > 255) {
115350
+ return false;
115351
+ }
115352
+ }
115353
+ return true;
115354
+ }
115355
+ function validateDigits(digits) {
115356
+ if (validatedDigits.has(digits)) {
115357
+ return;
115358
+ }
115359
+ if (digits.length < 2 || !isStrictlyAscending(digits)) {
115360
+ throw new Error("digits must be at least 2 characters in strictly ascending character " + "code order: " + digits);
115361
+ }
115362
+ if (!isSingleByte(digits)) {
115363
+ throw new Error("digits must be single-byte (char code 0-255): " + digits);
115364
+ }
115365
+ validatedDigits.add(digits);
115366
+ }
115367
+ function validateIntDigits(intDigits) {
115368
+ if (validatedIntDigits.has(intDigits)) {
115369
+ return;
115370
+ }
115371
+ if (intDigits.length < 2 || intDigits.length % 2 !== 0 || !isStrictlyAscending(intDigits)) {
115372
+ throw new Error("intDigits must be an even number of at least 2 characters in strictly " + "ascending character code order: " + intDigits);
115373
+ }
115374
+ if (!isSingleByte(intDigits)) {
115375
+ throw new Error("intDigits must be single-byte (char code 0-255): " + intDigits);
115376
+ }
115377
+ validatedIntDigits.add(intDigits);
115378
+ }
115379
+ function generateKeyBetween(a, b, digits = undefined, intDigits = undefined) {
115380
+ if (intDigits !== undefined) {
115381
+ validateIntDigits(intDigits);
115382
+ } else {
115383
+ intDigits = digits ?? BASE_52_DIGITS;
115384
+ }
115385
+ if (digits !== undefined) {
115386
+ validateDigits(digits);
115387
+ } else {
115388
+ digits = BASE_62_DIGITS;
115389
+ }
115390
+ const lookup = getDigitIndex(digits);
115391
+ const intLookup = getDigitIndex(intDigits);
115392
+ if (a != null) {
115393
+ validateOrderKey(a, digits, intDigits, intLookup);
115394
+ }
115395
+ if (b != null) {
115396
+ validateOrderKey(b, digits, intDigits, intLookup);
115397
+ }
115398
+ if (a != null && b != null) {
115399
+ if (a > b) {
115400
+ const temp = a;
115401
+ a = b;
115402
+ b = temp;
115403
+ }
115404
+ }
115405
+ if (a == null) {
115406
+ if (b == null) {
115407
+ const head = intDigits[intDigits.length / 2];
115408
+ return head + digits[0];
115409
+ }
115410
+ const ib = getIntegerPart(b, intDigits, intLookup);
115411
+ const fb = b.slice(ib.length);
115412
+ if (isSmallestInteger(ib, digits, intDigits)) {
115413
+ return ib + midpoint("", fb, digits, lookup);
115414
+ }
115415
+ if (ib < b) {
115416
+ return ib;
115417
+ }
115418
+ const res = decrementInteger(ib, digits, lookup, intDigits, intLookup);
115419
+ if (res == null) {
115420
+ throw new Error("cannot decrement any more");
115421
+ }
115422
+ return res;
115423
+ }
115424
+ if (b == null) {
115425
+ const ia = getIntegerPart(a, intDigits, intLookup);
115426
+ const fa = a.slice(ia.length);
115427
+ const i = incrementInteger(ia, digits, lookup, intDigits, intLookup);
115428
+ return i == null ? ia + midpoint(fa, null, digits, lookup) : i;
115429
+ }
115430
+ const ia = getIntegerPart(a, intDigits, intLookup);
115431
+ const fa = a.slice(ia.length);
115432
+ const ib = getIntegerPart(b, intDigits, intLookup);
115433
+ const fb = b.slice(ib.length);
115434
+ if (ia === ib) {
115435
+ return ia + midpoint(fa, fb, digits, lookup);
115436
+ }
115437
+ const i = incrementInteger(ia, digits, lookup, intDigits, intLookup);
115438
+ if (i == null) {
115439
+ throw new Error("cannot increment any more");
115440
+ }
115441
+ if (i < b) {
115442
+ return i;
115443
+ }
115444
+ return ia + midpoint(fa, null, digits, lookup);
115445
+ }
115446
+ function generateNKeysBetween(a, b, n, digits = undefined, intDigits = undefined) {
115447
+ if (intDigits !== undefined) {
115448
+ validateIntDigits(intDigits);
115449
+ } else {
115450
+ intDigits = digits ?? BASE_52_DIGITS;
115451
+ }
115452
+ if (digits !== undefined) {
115453
+ validateDigits(digits);
115454
+ } else {
115455
+ digits = BASE_62_DIGITS;
115456
+ }
115457
+ if (n === 0) {
115458
+ return [];
115459
+ }
115460
+ if (n === 1) {
115461
+ return [generateKeyBetween(a, b, digits, intDigits)];
115462
+ }
115463
+ if (b == null) {
115464
+ let c = generateKeyBetween(a, b, digits, intDigits);
115465
+ const result = [c];
115466
+ for (let i = 0;i < n - 1; i++) {
115467
+ c = generateKeyBetween(c, b, digits, intDigits);
115468
+ result.push(c);
115469
+ }
115470
+ return result;
115471
+ }
115472
+ if (a == null) {
115473
+ let c = generateKeyBetween(a, b, digits, intDigits);
115474
+ const result = [c];
115475
+ for (let i = 0;i < n - 1; i++) {
115476
+ c = generateKeyBetween(a, c, digits, intDigits);
115477
+ result.push(c);
115478
+ }
115479
+ result.reverse();
115480
+ return result;
115481
+ }
115482
+ const mid = Math.floor(n / 2);
115483
+ const c = generateKeyBetween(a, b, digits, intDigits);
115484
+ return [
115485
+ ...generateNKeysBetween(a, c, mid, digits, intDigits),
115486
+ c,
115487
+ ...generateNKeysBetween(c, b, n - mid - 1, digits, intDigits)
115488
+ ];
115489
+ }
115490
+ var BASE_62_DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", BASE_52_DIGITS, digitIndexCache, repeatedKeysCache, validatedDigits, validatedIntDigits;
115491
+ var init_src = __esm(() => {
115492
+ BASE_52_DIGITS = BASE_62_DIGITS.slice(10);
115493
+ digitIndexCache = new Map;
115494
+ repeatedKeysCache = new Map;
115495
+ validatedDigits = new Set;
115496
+ validatedIntDigits = new Set;
115497
+ });
115498
+
115499
+ // src/be/primitives/boards/excalifont-metrics.json
115500
+ var excalifont_metrics_default;
115501
+ var init_excalifont_metrics = __esm(() => {
115502
+ excalifont_metrics_default = {
115503
+ $comment: "Generated by scripts/gen-excalifont-metrics.ts. Advance width per character, in ems.",
115504
+ font: "Excalifont (Excalidraw 0.18.1, SIL OFL 1.1)",
115505
+ lineHeight: 1.25,
115506
+ fallback: 0.5702,
115507
+ wide: 1,
115508
+ widths: {
115509
+ "0": 0.664,
115510
+ "1": 0.427,
115511
+ "2": 0.7,
115512
+ "3": 0.608,
115513
+ "4": 0.585,
115514
+ "5": 0.618,
115515
+ "6": 0.64,
115516
+ "7": 0.558,
115517
+ "8": 0.636,
115518
+ "9": 0.629,
115519
+ " ": 0.4,
115520
+ "!": 0.314,
115521
+ '"': 0.371,
115522
+ "#": 0.783,
115523
+ $: 0.721,
115524
+ "%": 0.928,
115525
+ "&": 0.718,
115526
+ "'": 0.218,
115527
+ "(": 0.441,
115528
+ ")": 0.402,
115529
+ "*": 0.525,
115530
+ "+": 0.55,
115531
+ ",": 0.257,
115532
+ "-": 0.411,
115533
+ ".": 0.274,
115534
+ "/": 0.561,
115535
+ ":": 0.264,
115536
+ ";": 0.298,
115537
+ "<": 0.55,
115538
+ "=": 0.55,
115539
+ ">": 0.55,
115540
+ "?": 0.466,
115541
+ "@": 0.829,
115542
+ A: 0.676,
115543
+ B: 0.761,
115544
+ C: 0.629,
115545
+ D: 0.78,
115546
+ E: 0.707,
115547
+ F: 0.661,
115548
+ G: 0.78,
115549
+ H: 0.573,
115550
+ I: 0.545,
115551
+ J: 0.569,
115552
+ K: 0.613,
115553
+ L: 0.543,
115554
+ M: 0.766,
115555
+ N: 0.632,
115556
+ O: 0.767,
115557
+ P: 0.698,
115558
+ Q: 0.768,
115559
+ R: 0.736,
115560
+ S: 0.622,
115561
+ T: 0.857,
115562
+ U: 0.73,
115563
+ V: 0.592,
115564
+ W: 0.786,
115565
+ X: 0.628,
115566
+ Y: 0.564,
115567
+ Z: 0.832,
115568
+ "[": 0.472,
115569
+ "\\": 0.589,
115570
+ "]": 0.497,
115571
+ "^": 0.51,
115572
+ _: 0.67,
115573
+ "`": 0.6,
115574
+ a: 0.576,
115575
+ b: 0.555,
115576
+ c: 0.504,
115577
+ d: 0.605,
115578
+ e: 0.537,
115579
+ f: 0.497,
115580
+ g: 0.555,
115581
+ h: 0.567,
115582
+ i: 0.244,
115583
+ j: 0.328,
115584
+ k: 0.533,
115585
+ l: 0.225,
115586
+ m: 0.663,
115587
+ n: 0.526,
115588
+ o: 0.6,
115589
+ p: 0.537,
115590
+ q: 0.539,
115591
+ r: 0.412,
115592
+ s: 0.543,
115593
+ t: 0.553,
115594
+ u: 0.548,
115595
+ v: 0.525,
115596
+ w: 0.693,
115597
+ x: 0.591,
115598
+ y: 0.53,
115599
+ z: 0.572,
115600
+ "{": 0.504,
115601
+ "|": 0.299,
115602
+ "}": 0.544,
115603
+ "~": 0.669,
115604
+ " ": 0.4,
115605
+ "¡": 0.29,
115606
+ "¢": 0.489,
115607
+ "£": 0.71,
115608
+ "¥": 0.656,
115609
+ "¦": 0.299,
115610
+ "¨": 0.6,
115611
+ "©": 0.858,
115612
+ ª: 0.422,
115613
+ "«": 0.649,
115614
+ "®": 0.65,
115615
+ "¯": 0.6,
115616
+ "°": 0.412,
115617
+ "±": 0.55,
115618
+ "´": 0.6,
115619
+ "¶": 0.643,
115620
+ "·": 0.2,
115621
+ "¸": 0.6,
115622
+ º: 0.422,
115623
+ "»": 0.668,
115624
+ "¼": 0.762,
115625
+ "½": 0.762,
115626
+ "¾": 0.868,
115627
+ "¿": 0.455,
115628
+ À: 0.676,
115629
+ Á: 0.676,
115630
+ Â: 0.676,
115631
+ Ã: 0.676,
115632
+ Ä: 0.676,
115633
+ Å: 0.676,
115634
+ Æ: 1.028,
115635
+ Ç: 0.629,
115636
+ È: 0.707,
115637
+ É: 0.707,
115638
+ Ê: 0.707,
115639
+ Ë: 0.707,
115640
+ Ì: 0.545,
115641
+ Í: 0.545,
115642
+ Î: 0.545,
115643
+ Ï: 0.545,
115644
+ Ð: 0.815,
115645
+ Ñ: 0.632,
115646
+ Ò: 0.767,
115647
+ Ó: 0.767,
115648
+ Ô: 0.767,
115649
+ Õ: 0.767,
115650
+ Ö: 0.767,
115651
+ "×": 0.55,
115652
+ Ø: 0.772,
115653
+ Ù: 0.73,
115654
+ Ú: 0.73,
115655
+ Û: 0.73,
115656
+ Ü: 0.73,
115657
+ Ý: 0.564,
115658
+ Þ: 0.678,
115659
+ ß: 0.573,
115660
+ à: 0.542,
115661
+ á: 0.542,
115662
+ â: 0.542,
115663
+ ã: 0.542,
115664
+ ä: 0.542,
115665
+ å: 0.542,
115666
+ æ: 0.909,
115667
+ ç: 0.504,
115668
+ è: 0.551,
115669
+ é: 0.551,
115670
+ ê: 0.551,
115671
+ ë: 0.551,
115672
+ ì: 0.244,
115673
+ í: 0.244,
115674
+ î: 0.244,
115675
+ ï: 0.244,
115676
+ ð: 0.514,
115677
+ ñ: 0.526,
115678
+ ò: 0.561,
115679
+ ó: 0.561,
115680
+ ô: 0.561,
115681
+ õ: 0.561,
115682
+ ö: 0.561,
115683
+ "÷": 0.55,
115684
+ ø: 0.617,
115685
+ ù: 0.508,
115686
+ ú: 0.508,
115687
+ û: 0.508,
115688
+ ü: 0.508,
115689
+ ý: 0.522,
115690
+ þ: 0.568,
115691
+ ÿ: 0.522,
115692
+ Ā: 0.676,
115693
+ ā: 0.576,
115694
+ Ă: 0.676,
115695
+ ă: 0.542,
115696
+ Ą: 0.676,
115697
+ ą: 0.542,
115698
+ Ć: 0.629,
115699
+ ć: 0.504,
115700
+ Ĉ: 0.629,
115701
+ ĉ: 0.504,
115702
+ Ċ: 0.629,
115703
+ ċ: 0.504,
115704
+ Č: 0.629,
115705
+ č: 0.504,
115706
+ Ď: 0.78,
115707
+ ď: 0.605,
115708
+ Đ: 0.815,
115709
+ đ: 0.615,
115710
+ Ē: 0.707,
115711
+ ē: 0.537,
115712
+ Ĕ: 0.707,
115713
+ ĕ: 0.551,
115714
+ Ė: 0.707,
115715
+ ė: 0.551,
115716
+ Ę: 0.707,
115717
+ ę: 0.551,
115718
+ Ě: 0.707,
115719
+ ě: 0.551,
115720
+ Ĝ: 0.78,
115721
+ ĝ: 0.555,
115722
+ Ğ: 0.78,
115723
+ ğ: 0.555,
115724
+ Ġ: 0.78,
115725
+ ġ: 0.555,
115726
+ Ģ: 0.78,
115727
+ ģ: 0.555,
115728
+ Ĥ: 0.573,
115729
+ ĥ: 0.567,
115730
+ Ħ: 0.664,
115731
+ ħ: 0.621,
115732
+ Ĩ: 0.545,
115733
+ ĩ: 0.244,
115734
+ Ī: 0.545,
115735
+ ī: 0.244,
115736
+ Ĭ: 0.545,
115737
+ ĭ: 0.244,
115738
+ Į: 0.545,
115739
+ į: 0.244,
115740
+ İ: 0.545,
115741
+ ı: 0.244,
115742
+ IJ: 0.905,
115743
+ ij: 0.572,
115744
+ Ĵ: 0.569,
115745
+ ĵ: 0.328,
115746
+ Ķ: 0.613,
115747
+ ķ: 0.533,
115748
+ Ĺ: 0.543,
115749
+ ĺ: 0.225,
115750
+ Ļ: 0.543,
115751
+ ļ: 0.225,
115752
+ Ľ: 0.543,
115753
+ ľ: 0.225,
115754
+ Ŀ: 0.543,
115755
+ ŀ: 0.331,
115756
+ Ł: 0.63,
115757
+ ł: 0.408,
115758
+ Ń: 0.632,
115759
+ ń: 0.526,
115760
+ Ņ: 0.632,
115761
+ ņ: 0.526,
115762
+ Ň: 0.632,
115763
+ ň: 0.526,
115764
+ ʼn: 0.573,
115765
+ Ō: 0.767,
115766
+ ō: 0.6,
115767
+ Ŏ: 0.767,
115768
+ ŏ: 0.561,
115769
+ Ő: 0.767,
115770
+ ő: 0.561,
115771
+ Œ: 1.21,
115772
+ œ: 0.92,
115773
+ Ŕ: 0.736,
115774
+ ŕ: 0.412,
115775
+ Ŗ: 0.736,
115776
+ ŗ: 0.412,
115777
+ Ř: 0.736,
115778
+ ř: 0.412,
115779
+ Ś: 0.622,
115780
+ ś: 0.543,
115781
+ Ŝ: 0.622,
115782
+ ŝ: 0.543,
115783
+ Ş: 0.622,
115784
+ ş: 0.543,
115785
+ Š: 0.622,
115786
+ š: 0.543,
115787
+ Ţ: 0.857,
115788
+ ţ: 0.553,
115789
+ Ť: 0.857,
115790
+ ť: 0.553,
115791
+ Ŧ: 0.857,
115792
+ ŧ: 0.608,
115793
+ Ũ: 0.73,
115794
+ ũ: 0.508,
115795
+ Ū: 0.73,
115796
+ ū: 0.548,
115797
+ Ŭ: 0.73,
115798
+ ŭ: 0.508,
115799
+ Ů: 0.73,
115800
+ ů: 0.508,
115801
+ Ű: 0.73,
115802
+ ű: 0.508,
115803
+ Ų: 0.73,
115804
+ ų: 0.548,
115805
+ Ŵ: 0.786,
115806
+ ŵ: 0.693,
115807
+ Ŷ: 0.564,
115808
+ ŷ: 0.522,
115809
+ Ÿ: 0.564,
115810
+ Ź: 0.832,
115811
+ ź: 0.572,
115812
+ Ż: 0.832,
115813
+ ż: 0.572,
115814
+ Ž: 0.832,
115815
+ ž: 0.572,
115816
+ ";": 0.298,
115817
+ "΄": 0.262,
115818
+ "΅": 0.669,
115819
+ Ά: 0.671,
115820
+ "·": 0.2,
115821
+ Έ: 0.823,
115822
+ Ή: 0.662,
115823
+ Ί: 0.664,
115824
+ Ό: 0.846,
115825
+ Ύ: 0.892,
115826
+ Ώ: 0.785,
115827
+ ΐ: 0.301,
115828
+ Α: 0.676,
115829
+ Β: 0.761,
115830
+ Γ: 0.558,
115831
+ Ε: 0.707,
115832
+ Ζ: 0.832,
115833
+ Η: 0.573,
115834
+ Θ: 0.748,
115835
+ Ι: 0.545,
115836
+ Κ: 0.613,
115837
+ Λ: 0.645,
115838
+ Μ: 0.766,
115839
+ Ν: 0.632,
115840
+ Ξ: 0.604,
115841
+ Ο: 0.767,
115842
+ Π: 0.586,
115843
+ Ρ: 0.698,
115844
+ Σ: 0.723,
115845
+ Τ: 0.857,
115846
+ Υ: 0.706,
115847
+ Φ: 0.693,
115848
+ Χ: 0.628,
115849
+ Ψ: 0.649,
115850
+ Ϊ: 0.545,
115851
+ Ϋ: 0.706,
115852
+ ά: 0.575,
115853
+ έ: 0.478,
115854
+ ή: 0.464,
115855
+ ί: 0.301,
115856
+ ΰ: 0.514,
115857
+ α: 0.575,
115858
+ β: 0.578,
115859
+ γ: 0.478,
115860
+ δ: 0.552,
115861
+ ε: 0.478,
115862
+ ζ: 0.431,
115863
+ η: 0.464,
115864
+ θ: 0.585,
115865
+ ι: 0.301,
115866
+ κ: 0.527,
115867
+ λ: 0.483,
115868
+ μ: 0.528,
115869
+ ν: 0.477,
115870
+ ξ: 0.47,
115871
+ ο: 0.536,
115872
+ π: 0.599,
115873
+ ρ: 0.52,
115874
+ ς: 0.411,
115875
+ σ: 0.516,
115876
+ τ: 0.479,
115877
+ υ: 0.514,
115878
+ φ: 0.643,
115879
+ χ: 0.486,
115880
+ ψ: 0.605,
115881
+ ω: 0.692,
115882
+ ϊ: 0.301,
115883
+ ϋ: 0.514,
115884
+ ό: 0.536,
115885
+ ύ: 0.514,
115886
+ ώ: 0.692,
115887
+ Ϗ: 0.613,
115888
+ ϗ: 0.566,
115889
+ Ѐ: 0.707,
115890
+ Ё: 0.707,
115891
+ Ђ: 0.73,
115892
+ Ѓ: 0.558,
115893
+ Є: 0.657,
115894
+ Ѕ: 0.622,
115895
+ І: 0.545,
115896
+ Ї: 0.545,
115897
+ Ј: 0.569,
115898
+ Љ: 1.029,
115899
+ Њ: 0.887,
115900
+ Ћ: 0.744,
115901
+ Ќ: 0.613,
115902
+ Ѝ: 0.62,
115903
+ Ў: 0.582,
115904
+ Џ: 0.607,
115905
+ А: 0.676,
115906
+ Б: 0.637,
115907
+ В: 0.761,
115908
+ Г: 0.558,
115909
+ Д: 0.745,
115910
+ Е: 0.707,
115911
+ Ж: 0.833,
115912
+ З: 0.632,
115913
+ И: 0.62,
115914
+ Й: 0.62,
115915
+ К: 0.613,
115916
+ Л: 0.666,
115917
+ М: 0.766,
115918
+ Н: 0.573,
115919
+ О: 0.767,
115920
+ П: 0.586,
115921
+ Р: 0.698,
115922
+ С: 0.629,
115923
+ Т: 0.857,
115924
+ У: 0.582,
115925
+ Ф: 0.693,
115926
+ Х: 0.628,
115927
+ Ц: 0.607,
115928
+ Ч: 0.591,
115929
+ Ш: 0.781,
115930
+ Щ: 0.792,
115931
+ Ъ: 0.687,
115932
+ Ы: 0.789,
115933
+ Ь: 0.637,
115934
+ Э: 0.65,
115935
+ Ю: 0.876,
115936
+ Я: 0.64,
115937
+ а: 0.576,
115938
+ б: 0.573,
115939
+ в: 0.513,
115940
+ г: 0.419,
115941
+ д: 0.553,
115942
+ е: 0.537,
115943
+ ж: 0.648,
115944
+ з: 0.509,
115945
+ и: 0.53,
115946
+ й: 0.53,
115947
+ к: 0.529,
115948
+ л: 0.548,
115949
+ м: 0.595,
115950
+ н: 0.541,
115951
+ о: 0.6,
115952
+ п: 0.551,
115953
+ р: 0.537,
115954
+ с: 0.504,
115955
+ т: 0.489,
115956
+ у: 0.53,
115957
+ ф: 0.602,
115958
+ х: 0.591,
115959
+ ц: 0.506,
115960
+ ч: 0.508,
115961
+ ш: 0.653,
115962
+ щ: 0.672,
115963
+ ъ: 0.598,
115964
+ ы: 0.699,
115965
+ ь: 0.509,
115966
+ э: 0.539,
115967
+ ю: 0.743,
115968
+ я: 0.554,
115969
+ ѐ: 0.551,
115970
+ ё: 0.551,
115971
+ ђ: 0.604,
115972
+ ѓ: 0.419,
115973
+ є: 0.543,
115974
+ ѕ: 0.543,
115975
+ і: 0.244,
115976
+ ї: 0.244,
115977
+ ј: 0.328,
115978
+ љ: 0.806,
115979
+ њ: 0.739,
115980
+ ћ: 0.621,
115981
+ ќ: 0.529,
115982
+ ѝ: 0.53,
115983
+ ў: 0.522,
115984
+ џ: 0.513,
115985
+ Ѣ: 0.784,
115986
+ ѣ: 0.64,
115987
+ Ѳ: 0.767,
115988
+ ѳ: 0.6,
115989
+ Ѵ: 0.609,
115990
+ ѵ: 0.531,
115991
+ Ґ: 0.558,
115992
+ ґ: 0.44,
115993
+ Ә: 0.657,
115994
+ ә: 0.544,
115995
+ Ӣ: 0.62,
115996
+ ӣ: 0.53,
115997
+ Ӧ: 0.767,
115998
+ ӧ: 0.6,
115999
+ Ө: 0.767,
116000
+ ө: 0.6,
116001
+ Ӯ: 0.582,
116002
+ ӯ: 0.53,
116003
+ "–": 0.702,
116004
+ "—": 0.935,
116005
+ "‘": 0.267,
116006
+ "’": 0.304,
116007
+ "‚": 0.239,
116008
+ "“": 0.412,
116009
+ "”": 0.428,
116010
+ "„": 0.428,
116011
+ "†": 0.549,
116012
+ "•": 0.522,
116013
+ "․": 0.274,
116014
+ "‥": 0.548,
116015
+ "…": 0.709
116016
+ }
116017
+ };
116018
+ });
116019
+
116020
+ // src/be/primitives/boards/elements.ts
116021
+ function measureText(text, fontSize) {
116022
+ const lines = text.split(`
116023
+ `);
116024
+ const em = Math.max(...lines.map((line) => [...line].reduce((sum, char) => {
116025
+ const known = widths[char];
116026
+ if (known !== undefined)
116027
+ return sum + known;
116028
+ return sum + ((char.codePointAt(0) ?? 0) >= 11904 ? excalifont_metrics_default.wide : excalifont_metrics_default.fallback);
116029
+ }, 0)));
116030
+ return {
116031
+ width: Math.max(1, Math.ceil(em * fontSize * WIDTH_SAFETY)),
116032
+ height: Math.ceil(lines.length * fontSize * LINE_HEIGHT)
116033
+ };
116034
+ }
116035
+ function newElementId() {
116036
+ const bytes = crypto.getRandomValues(new Uint8Array(21));
116037
+ return Array.from(bytes, (b) => ID_ALPHABET[b & 63]).join("");
116038
+ }
116039
+ function colorPair(color, where) {
116040
+ if (color === undefined)
116041
+ return;
116042
+ const named = Object.hasOwn(PALETTE, color) ? PALETTE[color] : undefined;
116043
+ if (named)
116044
+ return [named[0], named[1]];
116045
+ if (HEX.test(color))
116046
+ return [STROKE, color];
116047
+ throw new ObjectsError(`${where}: color '${color}' is not a palette name (${Object.keys(PALETTE).join(", ")}) or #rrggbb`);
116048
+ }
116049
+ function baseElement(type, geometry, now) {
116050
+ return {
116051
+ id: newElementId(),
116052
+ type,
116053
+ ...geometry,
116054
+ angle: 0,
116055
+ strokeColor: STROKE,
116056
+ backgroundColor: "transparent",
116057
+ fillStyle: "solid",
116058
+ strokeWidth: 2,
116059
+ strokeStyle: "solid",
116060
+ roughness: 1,
116061
+ opacity: 100,
116062
+ groupIds: [],
116063
+ frameId: null,
116064
+ index: null,
116065
+ roundness: type === "rectangle" ? { type: 3 } : type === "diamond" || type === "arrow" ? { type: 2 } : null,
116066
+ seed: randomInt(),
116067
+ version: 1,
116068
+ versionNonce: randomInt(),
116069
+ isDeleted: false,
116070
+ boundElements: [],
116071
+ updated: now,
116072
+ link: null,
116073
+ locked: false
116074
+ };
116075
+ }
116076
+ function textElement(text, fontSize, at, containerId, now) {
116077
+ const size = measureText(text, fontSize);
116078
+ return {
116079
+ ...baseElement("text", { ...at, ...size }, now),
116080
+ boundElements: null,
116081
+ text,
116082
+ originalText: text,
116083
+ fontSize,
116084
+ fontFamily: FONT_FAMILY_EXCALIFONT,
116085
+ textAlign: containerId ? "center" : "left",
116086
+ verticalAlign: containerId ? "middle" : "top",
116087
+ containerId,
116088
+ autoResize: true,
116089
+ lineHeight: LINE_HEIGHT
116090
+ };
116091
+ }
116092
+ function fitContainer(type, label, min) {
116093
+ const inner = {
116094
+ width: label.width + 2 * BOUND_TEXT_PADDING + LABEL_MARGIN,
116095
+ height: label.height + 2 * BOUND_TEXT_PADDING + LABEL_MARGIN
116096
+ };
116097
+ const scale = type === "ellipse" ? Math.SQRT2 : type === "diamond" ? 2 : 1;
116098
+ return {
116099
+ width: Math.max(min.width, Math.ceil(inner.width * scale)),
116100
+ height: Math.max(min.height, Math.ceil(inner.height * scale))
116101
+ };
116102
+ }
116103
+ function centerLabel(container, label) {
116104
+ if (container.type === "arrow") {
116105
+ const points = container.points ?? [[0, 0]];
116106
+ const first = points[0] ?? [0, 0];
116107
+ const last = points[points.length - 1] ?? first;
116108
+ label.x = container.x + ((first[0] ?? 0) + (last[0] ?? 0)) / 2 - label.width / 2;
116109
+ label.y = container.y + ((first[1] ?? 0) + (last[1] ?? 0)) / 2 - label.height / 2;
116110
+ return;
116111
+ }
116112
+ const c = center(container);
116113
+ label.x = c.x - label.width / 2;
116114
+ label.y = c.y - label.height / 2;
116115
+ }
116116
+ function route2(from, to) {
116117
+ const a = { x: from.x + from.width / 2, y: from.y + from.height / 2 };
116118
+ const b = { x: to.x + to.width / 2, y: to.y + to.height / 2 };
116119
+ const dx = b.x - a.x;
116120
+ const dy = b.y - a.y;
116121
+ const gapFrom = from.bound ? BINDING_GAP : 0;
116122
+ const gapTo = to.bound ? BINDING_GAP : 0;
116123
+ if (Math.abs(dx) >= Math.abs(dy)) {
116124
+ const s = dx >= 0 ? 1 : -1;
116125
+ return {
116126
+ start: [a.x + s * (from.width / 2 + gapFrom), a.y],
116127
+ end: [b.x - s * (to.width / 2 + gapTo), b.y]
116128
+ };
116129
+ }
116130
+ const s = dy >= 0 ? 1 : -1;
116131
+ return {
116132
+ start: [a.x, a.y + s * (from.height / 2 + gapFrom)],
116133
+ end: [b.x, b.y - s * (to.height / 2 + gapTo)]
116134
+ };
116135
+ }
116136
+ function placeArrow(arrow, from, to) {
116137
+ const { start, end } = route2(from, to);
116138
+ arrow.x = start[0];
116139
+ arrow.y = start[1];
116140
+ arrow.points = [
116141
+ [0, 0],
116142
+ [end[0] - start[0], end[1] - start[1]]
116143
+ ];
116144
+ arrow.width = Math.abs(end[0] - start[0]);
116145
+ arrow.height = Math.abs(end[1] - start[1]);
116146
+ }
116147
+ function boxOf(element) {
116148
+ return { x: element.x, y: element.y, width: element.width, height: element.height, bound: true };
116149
+ }
116150
+ function pointBox(arrow, end) {
116151
+ const points = arrow.points ?? [[0, 0]];
116152
+ const p = (end === "start" ? points[0] : points[points.length - 1]) ?? [0, 0];
116153
+ return { x: arrow.x + (p[0] ?? 0), y: arrow.y + (p[1] ?? 0), width: 0, height: 0, bound: false };
116154
+ }
116155
+ function parseScene(content, path) {
116156
+ if (!content || typeof content !== "object" || Array.isArray(content)) {
116157
+ throw new ObjectsError(`'${path}' is not an Excalidraw scene (not a JSON object)`);
116158
+ }
116159
+ const scene = content;
116160
+ if (scene.elements === undefined)
116161
+ scene.elements = [];
116162
+ if (!Array.isArray(scene.elements)) {
116163
+ throw new ObjectsError(`'${path}' is not an Excalidraw scene (elements is not an array)`);
116164
+ }
116165
+ for (const element of scene.elements) {
116166
+ if (!element || typeof element.id !== "string" || typeof element.type !== "string") {
116167
+ throw new ObjectsError(`'${path}' has an element without a string id and type`);
116168
+ }
116169
+ }
116170
+ return scene;
116171
+ }
116172
+ function liveById(scene) {
116173
+ return new Map(live(scene).map((e) => [e.id, e]));
116174
+ }
116175
+ function bump(elements, now) {
116176
+ for (const element of new Set(elements)) {
116177
+ element.version = (typeof element.version === "number" ? element.version : 0) + 1;
116178
+ element.versionNonce = randomInt();
116179
+ element.updated = now;
116180
+ }
116181
+ }
116182
+ function addRef(element, ref) {
116183
+ const refs = Array.isArray(element.boundElements) ? element.boundElements : [];
116184
+ if (!refs.some((r) => r.id === ref.id))
116185
+ refs.push(ref);
116186
+ element.boundElements = refs;
116187
+ }
116188
+ function dropRef(element, id) {
116189
+ if (Array.isArray(element.boundElements)) {
116190
+ element.boundElements = element.boundElements.filter((r) => r.id !== id);
116191
+ }
116192
+ }
116193
+ function assignIndexes(scene, added) {
116194
+ if (added.length === 0)
116195
+ return;
116196
+ const existing = scene.elements.filter((e) => !added.includes(e)).map((e) => e.index).filter((i) => typeof i === "string").sort();
116197
+ let keys;
116198
+ try {
116199
+ keys = generateNKeysBetween(existing[existing.length - 1] ?? null, null, added.length);
116200
+ } catch {
116201
+ keys = generateNKeysBetween(null, null, added.length);
116202
+ }
116203
+ added.forEach((element, i) => {
116204
+ element.index = keys[i] ?? null;
116205
+ });
116206
+ }
116207
+ function layoutOrigin(scene) {
116208
+ const elements = live(scene);
116209
+ if (elements.length === 0)
116210
+ return { x: 0, y: 0 };
116211
+ return {
116212
+ x: Math.min(...elements.map((e) => e.x)),
116213
+ y: Math.max(...elements.map((e) => e.y + e.height)) + LAYOUT_GAP
116214
+ };
116215
+ }
116216
+ function layoutPositions(sizes, layout, origin) {
116217
+ if (layout === "grid") {
116218
+ const cols = Math.max(1, Math.ceil(Math.sqrt(sizes.length)));
116219
+ const cellW = Math.max(...sizes.map((s) => s.width), 0);
116220
+ const cellH = Math.max(...sizes.map((s) => s.height), 0);
116221
+ return sizes.map((s, i) => ({
116222
+ x: origin.x + i % cols * (cellW + LAYOUT_GAP) + (cellW - s.width) / 2,
116223
+ y: origin.y + Math.floor(i / cols) * (cellH + LAYOUT_GAP) + (cellH - s.height) / 2
116224
+ }));
116225
+ }
116226
+ let cursor = 0;
116227
+ return sizes.map((s) => {
116228
+ const at = layout === "row" ? { x: origin.x + cursor, y: origin.y } : { x: origin.x, y: origin.y + cursor };
116229
+ cursor += (layout === "row" ? s.width : s.height) + LAYOUT_GAP;
116230
+ return at;
116231
+ });
116232
+ }
116233
+ function addElements(scene, input, now = Date.now()) {
116234
+ const shapes = input.shapes ?? [];
116235
+ const arrows = input.arrows ?? [];
116236
+ const byKey = new Map;
116237
+ const keys = new Set;
116238
+ const added = {};
116239
+ const appended = [];
116240
+ const touched = [];
116241
+ const existing = liveById(scene);
116242
+ const planned = shapes.map((shape, i) => {
116243
+ const where = `shapes[${i}]`;
116244
+ if (shape.key !== undefined) {
116245
+ if (keys.has(shape.key))
116246
+ throw new ObjectsError(`${where}: duplicate key '${shape.key}'`);
116247
+ keys.add(shape.key);
116248
+ }
116249
+ const label = shape.label ?? "";
116250
+ if (shape.type === "text" && label.trim() === "") {
116251
+ throw new ObjectsError(`${where}: a text shape needs a non-empty label`);
116252
+ }
116253
+ const colors = colorPair(shape.color, where);
116254
+ const min = {
116255
+ width: shape.width ?? DEFAULT_SIZE.width,
116256
+ height: shape.height ?? DEFAULT_SIZE.height
116257
+ };
116258
+ const labelSize = label ? measureText(label, SHAPE_FONT_SIZE) : { width: 0, height: 0 };
116259
+ const size = shape.type === "text" ? labelSize : fitContainer(shape.type, labelSize, min);
116260
+ return { shape, label, colors, size };
116261
+ });
116262
+ const auto = planned.filter((p) => p.shape.x === undefined || p.shape.y === undefined);
116263
+ const positions = layoutPositions(auto.map((p) => p.size), input.layout ?? "row", layoutOrigin(scene));
116264
+ for (const [i, p] of planned.entries()) {
116265
+ const slot = auto.indexOf(p);
116266
+ const at = slot >= 0 ? positions[slot] : undefined;
116267
+ const x = p.shape.x ?? at?.x ?? 0;
116268
+ const y = p.shape.y ?? at?.y ?? 0;
116269
+ let element;
116270
+ if (p.shape.type === "text") {
116271
+ element = textElement(p.label, SHAPE_FONT_SIZE, { x, y }, null, now);
116272
+ if (p.colors)
116273
+ element.strokeColor = p.colors[0];
116274
+ appended.push(element);
116275
+ } else {
116276
+ element = baseElement(p.shape.type, { x, y, ...p.size }, now);
116277
+ if (p.colors)
116278
+ [element.strokeColor, element.backgroundColor] = p.colors;
116279
+ appended.push(element);
116280
+ if (p.label) {
116281
+ const text = textElement(p.label, SHAPE_FONT_SIZE, { x, y }, element.id, now);
116282
+ centerLabel(element, text);
116283
+ addRef(element, { type: "text", id: text.id });
116284
+ appended.push(text);
116285
+ }
116286
+ }
116287
+ if (p.shape.key !== undefined)
116288
+ byKey.set(p.shape.key, element);
116289
+ added[p.shape.key ?? `shapes[${i}]`] = element.id;
116290
+ }
116291
+ const resolve = (ref, where) => {
116292
+ const element = byKey.get(ref) ?? existing.get(ref);
116293
+ if (!element) {
116294
+ throw new ObjectsError(`${where}: '${ref}' is not a shape key in this call or a live element id`);
116295
+ }
116296
+ if (element.type === "arrow" || element.type === "line" || element.containerId) {
116297
+ throw new ObjectsError(`${where}: '${ref}' is a ${element.containerId ? "label" : element.type}; bind arrows to shapes`);
116298
+ }
116299
+ return element;
116300
+ };
116301
+ for (const [i, input] of arrows.entries()) {
116302
+ const where = `arrows[${i}]`;
116303
+ const from = resolve(input.from, `${where}.from`);
116304
+ const to = resolve(input.to, `${where}.to`);
116305
+ if (from === to)
116306
+ throw new ObjectsError(`${where}: an arrow needs two different shapes`);
116307
+ const arrow = {
116308
+ ...baseElement("arrow", { x: 0, y: 0, width: 0, height: 0 }, now),
116309
+ points: [],
116310
+ lastCommittedPoint: null,
116311
+ startBinding: { elementId: from.id, focus: 0, gap: BINDING_GAP },
116312
+ endBinding: { elementId: to.id, focus: 0, gap: BINDING_GAP },
116313
+ startArrowhead: null,
116314
+ endArrowhead: "arrow",
116315
+ elbowed: false
116316
+ };
116317
+ placeArrow(arrow, boxOf(from), boxOf(to));
116318
+ addRef(from, { type: "arrow", id: arrow.id });
116319
+ addRef(to, { type: "arrow", id: arrow.id });
116320
+ for (const end of [from, to])
116321
+ if (!appended.includes(end))
116322
+ touched.push(end);
116323
+ appended.push(arrow);
116324
+ if (input.label) {
116325
+ const text = textElement(input.label, ARROW_FONT_SIZE, { x: 0, y: 0 }, arrow.id, now);
116326
+ text.textAlign = "center";
116327
+ text.verticalAlign = "middle";
116328
+ centerLabel(arrow, text);
116329
+ addRef(arrow, { type: "text", id: text.id });
116330
+ appended.push(text);
116331
+ }
116332
+ added[`arrows[${i}]`] = arrow.id;
116333
+ }
116334
+ scene.elements.push(...appended);
116335
+ assignIndexes(scene, appended);
116336
+ bump(touched, now);
116337
+ return added;
116338
+ }
116339
+ function rerouteArrows(scene, element, touched) {
116340
+ const byId = liveById(scene);
116341
+ for (const arrow of live(scene)) {
116342
+ if (arrow.type !== "arrow")
116343
+ continue;
116344
+ const startId = arrow.startBinding?.elementId;
116345
+ const endId = arrow.endBinding?.elementId;
116346
+ if (startId !== element.id && endId !== element.id)
116347
+ continue;
116348
+ const start = startId ? byId.get(startId) : undefined;
116349
+ const end = endId ? byId.get(endId) : undefined;
116350
+ placeArrow(arrow, start ? boxOf(start) : pointBox(arrow, "start"), end ? boxOf(end) : pointBox(arrow, "end"));
116351
+ touched.push(arrow);
116352
+ const label = labelOf(scene, arrow);
116353
+ if (label) {
116354
+ centerLabel(arrow, label);
116355
+ touched.push(label);
116356
+ }
116357
+ }
116358
+ }
116359
+ function setLabel(scene, element, label, now, touched, appended) {
116360
+ if (element.type === "text") {
116361
+ if (label.trim() === "")
116362
+ throw new ObjectsError(`${element.id}: a text element needs a non-empty label`);
116363
+ const size = measureText(label, element.fontSize ?? SHAPE_FONT_SIZE);
116364
+ Object.assign(element, { text: label, originalText: label, ...size });
116365
+ return;
116366
+ }
116367
+ const existing = labelOf(scene, element);
116368
+ if (label === "") {
116369
+ if (existing) {
116370
+ dropRef(element, existing.id);
116371
+ if (appended.includes(existing)) {
116372
+ scene.elements.splice(scene.elements.indexOf(existing), 1);
116373
+ appended.splice(appended.indexOf(existing), 1);
116374
+ } else {
116375
+ existing.isDeleted = true;
116376
+ touched.push(existing);
116377
+ }
116378
+ }
116379
+ return;
116380
+ }
116381
+ const fontSize = element.type === "arrow" ? ARROW_FONT_SIZE : SHAPE_FONT_SIZE;
116382
+ if (existing) {
116383
+ Object.assign(existing, {
116384
+ text: label,
116385
+ originalText: label,
116386
+ ...measureText(label, existing.fontSize ?? fontSize)
116387
+ });
116388
+ touched.push(existing);
116389
+ return;
116390
+ }
116391
+ const text = textElement(label, fontSize, { x: element.x, y: element.y }, element.id, now);
116392
+ text.textAlign = "center";
116393
+ text.verticalAlign = "middle";
116394
+ addRef(element, { type: "text", id: text.id });
116395
+ scene.elements.push(text);
116396
+ appended.push(text);
116397
+ }
116398
+ function updateElements(scene, patches, now = Date.now()) {
116399
+ const byId = liveById(scene);
116400
+ const touched = [];
116401
+ const appended = [];
116402
+ for (const [i, patch] of patches.entries()) {
116403
+ const where = `patches[${i}]`;
116404
+ const element = byId.get(patch.elementId);
116405
+ if (!element)
116406
+ throw new ObjectsError(`${where}: no live element '${patch.elementId}'`);
116407
+ if (element.type === "text" && element.containerId) {
116408
+ throw new ObjectsError(`${where}: '${element.id}' is the label of '${element.containerId}'; patch that element`);
116409
+ }
116410
+ const moves = [patch.x, patch.y, patch.width, patch.height].some((v) => v !== undefined);
116411
+ if (element.type === "arrow" && moves) {
116412
+ throw new ObjectsError(`${where}: arrows follow the shapes they bind; move or resize the shapes`);
116413
+ }
116414
+ touched.push(element);
116415
+ const colors = colorPair(patch.color, where);
116416
+ if (colors) {
116417
+ element.strokeColor = colors[0];
116418
+ if (element.type !== "text" && element.type !== "arrow")
116419
+ element.backgroundColor = colors[1];
116420
+ }
116421
+ if (patch.x !== undefined)
116422
+ element.x = patch.x;
116423
+ if (patch.y !== undefined)
116424
+ element.y = patch.y;
116425
+ if (patch.width !== undefined)
116426
+ element.width = patch.width;
116427
+ if (patch.height !== undefined)
116428
+ element.height = patch.height;
116429
+ if (patch.label !== undefined)
116430
+ setLabel(scene, element, patch.label, now, touched, appended);
116431
+ const label = element.type === "text" ? undefined : labelOf(scene, element);
116432
+ if (label) {
116433
+ if (element.type !== "arrow") {
116434
+ Object.assign(element, fitContainer(element.type, label, element));
116435
+ }
116436
+ centerLabel(element, label);
116437
+ touched.push(label);
116438
+ }
116439
+ if (element.type !== "arrow" && (moves || patch.label !== undefined))
116440
+ rerouteArrows(scene, element, touched);
116441
+ }
116442
+ assignIndexes(scene, appended);
116443
+ bump(touched.filter((e) => !appended.includes(e)), now);
116444
+ return patches.map((p) => p.elementId);
116445
+ }
116446
+ function removeElements(scene, elementIds, now = Date.now()) {
116447
+ const byId = liveById(scene);
116448
+ const unknown = elementIds.filter((id) => !byId.has(id));
116449
+ if (unknown.length > 0)
116450
+ throw new ObjectsError(`no live element: ${unknown.join(", ")}`);
116451
+ const touched = [];
116452
+ for (const id of new Set(elementIds)) {
116453
+ const element = byId.get(id);
116454
+ if (!element || element.isDeleted)
116455
+ continue;
116456
+ element.isDeleted = true;
116457
+ touched.push(element);
116458
+ if (element.containerId) {
116459
+ const container = byId.get(element.containerId);
116460
+ if (container) {
116461
+ dropRef(container, element.id);
116462
+ touched.push(container);
116463
+ }
116464
+ }
116465
+ const label = labelOf(scene, element);
116466
+ if (label) {
116467
+ label.isDeleted = true;
116468
+ touched.push(label);
116469
+ }
116470
+ if (element.type === "arrow") {
116471
+ for (const binding of [element.startBinding, element.endBinding]) {
116472
+ const end = binding ? byId.get(binding.elementId) : undefined;
116473
+ if (end) {
116474
+ dropRef(end, element.id);
116475
+ touched.push(end);
116476
+ }
116477
+ }
116478
+ continue;
116479
+ }
116480
+ for (const arrow of live(scene)) {
116481
+ if (arrow.type !== "arrow")
116482
+ continue;
116483
+ if (arrow.startBinding?.elementId === element.id)
116484
+ arrow.startBinding = null;
116485
+ else if (arrow.endBinding?.elementId === element.id)
116486
+ arrow.endBinding = null;
116487
+ else
116488
+ continue;
116489
+ touched.push(arrow);
116490
+ }
116491
+ }
116492
+ bump(touched, now);
116493
+ return [...new Set(elementIds)];
116494
+ }
116495
+ function summarize(scene) {
116496
+ const elements = live(scene);
116497
+ const labels = new Map(elements.filter((e) => e.type === "text" && e.containerId).map((e) => [e.containerId, e.text ?? ""]));
116498
+ const liveIds = new Set(elements.map((e) => e.id));
116499
+ return elements.filter((e) => !(e.type === "text" && e.containerId)).map((e) => ({
116500
+ id: e.id,
116501
+ type: e.type,
116502
+ text: e.type === "text" ? e.text ?? "" : labels.get(e.id) ?? null,
116503
+ x: e.x,
116504
+ y: e.y,
116505
+ width: e.width,
116506
+ height: e.height,
116507
+ boundTo: e.type === "arrow" ? [e.startBinding?.elementId ?? null, e.endBinding?.elementId ?? null] : (e.boundElements ?? []).filter((r) => r.type === "arrow" && liveIds.has(r.id)).map((r) => r.id)
116508
+ }));
116509
+ }
116510
+ var SHAPE_TYPES, LAYOUTS, PALETTE, STROKE = "#1e1e1e", FONT_FAMILY_EXCALIFONT = 5, LINE_HEIGHT, SHAPE_FONT_SIZE = 20, ARROW_FONT_SIZE = 16, BOUND_TEXT_PADDING = 5, LABEL_MARGIN = 20, DEFAULT_SIZE, BINDING_GAP = 4, LAYOUT_GAP = 80, WIDTH_SAFETY = 1.05, HEX, ID_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-", widths, randomInt = () => (crypto.getRandomValues(new Uint32Array(1))[0] ?? 1) >>> 1 || 1, center = (e) => ({ x: e.x + e.width / 2, y: e.y + e.height / 2 }), live = (scene) => scene.elements.filter((e) => !e.isDeleted), labelOf = (scene, container) => live(scene).find((e) => e.type === "text" && e.containerId === container.id);
116511
+ var init_elements = __esm(() => {
116512
+ init_src();
116513
+ init_objects();
116514
+ init_excalifont_metrics();
116515
+ SHAPE_TYPES = ["rectangle", "ellipse", "diamond", "text"];
116516
+ LAYOUTS = ["row", "column", "grid"];
116517
+ PALETTE = {
116518
+ blue: ["#1971c2", "#a5d8ff"],
116519
+ green: ["#2f9e44", "#b2f2bb"],
116520
+ yellow: ["#f08c00", "#ffec99"],
116521
+ red: ["#e03131", "#ffc9c9"],
116522
+ violet: ["#6741d9", "#d0bfff"],
116523
+ orange: ["#e8590c", "#ffd8a8"],
116524
+ gray: ["#495057", "#e9ecef"],
116525
+ teal: ["#0c8599", "#96f2d7"]
116526
+ };
116527
+ LINE_HEIGHT = excalifont_metrics_default.lineHeight;
116528
+ DEFAULT_SIZE = { width: 200, height: 80 };
116529
+ HEX = /^#[0-9a-fA-F]{6}$/;
116530
+ widths = excalifont_metrics_default.widths;
116531
+ });
116532
+
116533
+ // src/be/primitives/write-object.ts
116534
+ async function mutateObject(input) {
116535
+ const kind = PRIMITIVE_KINDS[input.kind];
116536
+ if (!kind)
116537
+ throw new ObjectsError(`unknown kind '${input.kind}'`);
116538
+ const { provider, scope } = await clientFor(input.agentId);
116539
+ for (let attempt = 1;; attempt += 1) {
116540
+ const { object, missing, content } = await getObject({
116541
+ agentId: input.agentId,
116542
+ id: input.id,
116543
+ path: input.path,
116544
+ includeContent: true
116545
+ });
116546
+ if (object.kind !== input.kind) {
116547
+ throw new ObjectsError(`object ${object.id} is a ${object.kind}, not a ${input.kind}`);
116548
+ }
116549
+ if (missing) {
116550
+ throw new ObjectsError(`the file for ${object.kind} ${object.id} at '${object.path}' is missing; run object-reindex`);
116551
+ }
116552
+ if (!content || typeof content !== "object" || Array.isArray(content)) {
116553
+ throw new ObjectsError(`'${object.path}' is not a JSON object`);
116554
+ }
116555
+ if (object.fileVersion === null) {
116556
+ throw new ObjectsError(`agent-fs returned no version for '${object.path}'; refusing an unguarded write`);
116557
+ }
116558
+ const result = input.mutate(content, object);
116559
+ const body = JSON.stringify(kind.withId(content, object.id), null, 2);
116560
+ if (Buffer.byteLength(body) > MAX_OBJECT_BYTES) {
116561
+ throw new ObjectsError(`'${object.path}' would exceed ${MAX_OBJECT_BYTES} bytes; nothing written`);
116562
+ }
116563
+ try {
116564
+ const written = await provider.upload(scope(object.path), body, {
116565
+ contentType: kind.contentType,
116566
+ ifMatch: String(object.fileVersion),
116567
+ message: input.message
116568
+ });
116569
+ const version = Number.isFinite(Number(written.version)) ? Number(written.version) : null;
116570
+ await recordObjectVersion(object.id, version);
116571
+ return { object: { ...object, fileVersion: version }, version, result };
116572
+ } catch (error) {
116573
+ if (!(error instanceof FilesError && error.code === "Conflict"))
116574
+ throw error;
116575
+ if (attempt >= MAX_WRITE_ATTEMPTS) {
116576
+ throw new ObjectsError(`concurrent writers changed '${object.path}' ${attempt} times in a row; retry`);
116577
+ }
116578
+ }
116579
+ }
116580
+ }
116581
+ var MAX_OBJECT_BYTES, MAX_WRITE_ATTEMPTS = 4;
116582
+ var init_write_object = __esm(() => {
116583
+ init_provider();
116584
+ init_objects();
116585
+ MAX_OBJECT_BYTES = 5 * 1024 * 1024;
116586
+ });
116587
+
116588
+ // src/be/primitives/boards/service.ts
116589
+ async function createBoard(input) {
116590
+ let added = {};
116591
+ const object = await createObject({
116592
+ agentId: input.agentId,
116593
+ kind: "board",
116594
+ path: input.path,
116595
+ title: input.title,
116596
+ build: (empty) => {
116597
+ added = addElements(parseScene(empty, input.path), input);
116598
+ return empty;
116599
+ }
116600
+ });
116601
+ return { object, added };
116602
+ }
116603
+ async function getBoard(input) {
116604
+ const { object, missing, content } = await getObject({ ...ref(input), includeContent: true });
116605
+ if (object.kind !== "board")
116606
+ throw new ObjectsError(`object ${object.id} is a ${object.kind}, not a board`);
116607
+ if (missing) {
116608
+ throw new ObjectsError(`the file for board ${object.id} at '${object.path}' is missing; run object-reindex`);
116609
+ }
116610
+ const scene = parseScene(content, object.path);
116611
+ return {
116612
+ object,
116613
+ version: object.fileVersion,
116614
+ elements: input.detail === "full" ? scene.elements.filter((e) => !e.isDeleted) : summarize(scene)
116615
+ };
116616
+ }
116617
+ function listBoards(input) {
116618
+ return listObjects({ ...input, kind: "board" });
116619
+ }
116620
+ async function addBoardElements(input) {
116621
+ if (!input.shapes?.length && !input.arrows?.length) {
116622
+ throw new ObjectsError("pass at least one shape or arrow");
116623
+ }
116624
+ const { object, version, result } = await mutateObject({
116625
+ ...ref(input),
116626
+ message: "add board elements",
116627
+ mutate: (content, o) => addElements(parseScene(content, o.path), input)
116628
+ });
116629
+ return { object, version, added: result };
116630
+ }
116631
+ async function updateBoardElements(input) {
116632
+ if (input.patches.length === 0)
116633
+ throw new ObjectsError("pass at least one patch");
116634
+ const { object, version, result } = await mutateObject({
116635
+ ...ref(input),
116636
+ message: "update board elements",
116637
+ mutate: (content, o) => updateElements(parseScene(content, o.path), input.patches)
116638
+ });
116639
+ return { object, version, updated: result };
116640
+ }
116641
+ async function removeBoardElements(input) {
116642
+ if (input.elementIds.length === 0)
116643
+ throw new ObjectsError("pass at least one element id");
116644
+ const { object, version, result } = await mutateObject({
116645
+ ...ref(input),
116646
+ message: "remove board elements",
116647
+ mutate: (content, o) => removeElements(parseScene(content, o.path), input.elementIds)
116648
+ });
116649
+ return { object, version, removed: result };
116650
+ }
116651
+ var ref = (input) => {
116652
+ if (!input.id && !input.path)
116653
+ throw new ObjectsError("pass `id` or `path`");
116654
+ return { agentId: input.agentId, id: input.id, path: input.path, kind: "board" };
116655
+ };
116656
+ var init_service = __esm(() => {
116657
+ init_objects();
116658
+ init_write_object();
116659
+ init_elements();
116660
+ });
116661
+
116662
+ // src/tools/objects.ts
116663
+ async function refusing(agentId, run) {
116664
+ try {
116665
+ return { value: await run() };
116666
+ } catch (error) {
116667
+ if (error instanceof ObjectsError || error instanceof FilesError) {
116668
+ return { error: toolErr(error.message, { data: { yourAgentId: agentId } }) };
116669
+ }
116670
+ throw error;
116671
+ }
116672
+ }
116673
+ var objectOutputSchema, KindSchema, summary = (o) => `${o.kind} ${o.id} at ${o.path}${o.link ? ` (${o.link})` : ""}`, registerObjectCreateTool = (server) => {
116674
+ createToolRegistrar(server)("object-create", {
116675
+ title: "Create primitive object",
116676
+ annotations: { readOnlyHint: false, idempotentHint: false },
116677
+ description: "Create a primitive object file on your default agent-fs drive, as your own agent-fs identity, and give it a stable id. Create-only: refuses when the path exists (use object-reindex to adopt an existing file). Kind `board` writes an empty Excalidraw scene and needs a `.excalidraw` path. Kind `sheet` writes an empty `swarm-sheet/1` workbook and needs a `.sheet.json` path (edit it with the sheet-* tools).",
116678
+ inputSchema: object2({
116679
+ kind: KindSchema.describe("Object kind. `board`: an Excalidraw scene (.excalidraw). `sheet`: a spreadsheet (.sheet.json)."),
116680
+ path: string2().min(1).describe("Drive path, e.g. /boards/roadmap.excalidraw."),
116681
+ title: string2().max(200).optional()
116682
+ }),
116683
+ outputSchema: swarmToolOutputSchema({
116684
+ yourAgentId: string2().optional(),
116685
+ object: objectOutputSchema.optional()
116686
+ })
116687
+ }, async ({ kind, path, title }, requestInfo) => {
116688
+ const result = await refusing(requestInfo.agentId, () => createObject({ agentId: requestInfo.agentId, kind, path, title }));
116689
+ if ("error" in result)
116690
+ return result.error;
116691
+ return toolOk(`Created ${summary(result.value)}.`, {
116692
+ data: { yourAgentId: requestInfo.agentId, object: result.value }
116693
+ });
116694
+ });
116695
+ }, registerObjectGetTool = (server) => {
116696
+ createToolRegistrar(server)("object-get", {
116697
+ title: "Get primitive object",
116698
+ description: "Get a primitive object on your default agent-fs drive by `id` or `path`. `missing: true` means the row exists but the file is gone. `includeContent` returns the parsed file.",
116699
+ annotations: { readOnlyHint: true },
116700
+ inputSchema: object2({
116701
+ id: string2().min(1).optional(),
116702
+ path: string2().min(1).optional(),
116703
+ includeContent: boolean().optional()
116704
+ }),
116705
+ outputSchema: swarmToolOutputSchema({
116706
+ yourAgentId: string2().optional(),
116707
+ object: objectOutputSchema.optional(),
116708
+ missing: boolean().optional(),
116709
+ content: unknown().optional()
116710
+ })
116711
+ }, async ({ id, path, includeContent }, requestInfo) => {
116712
+ const result = await refusing(requestInfo.agentId, () => getObject({ agentId: requestInfo.agentId, id, path, includeContent }));
116713
+ if ("error" in result)
116714
+ return result.error;
116715
+ const { object, missing, content } = result.value;
116716
+ return toolOk(missing ? `File for ${summary(object)} is missing.` : `Found ${summary(object)}.`, {
116717
+ data: {
116718
+ yourAgentId: requestInfo.agentId,
116719
+ object,
116720
+ missing,
116721
+ ...content === undefined ? {} : { content }
116722
+ }
116723
+ });
116724
+ });
116725
+ }, registerObjectListTool = (server) => {
116726
+ createToolRegistrar(server)("object-list", {
116727
+ title: "List primitive objects",
116728
+ description: "List primitive objects on your default agent-fs drive, newest first. Hides objects whose file agent-fs reported deleted. Filter by `kind` and path `prefix`. Pagination via limit (max 200) and offset.",
116729
+ annotations: { readOnlyHint: true },
116730
+ inputSchema: object2({
116731
+ kind: KindSchema.optional(),
116732
+ prefix: string2().optional(),
116733
+ limit: number2().int().positive().max(200).optional(),
116734
+ offset: number2().int().nonnegative().optional()
116735
+ }),
116736
+ outputSchema: swarmToolOutputSchema({
116737
+ yourAgentId: string2().optional(),
116738
+ objects: array2(objectOutputSchema).optional(),
116739
+ total: number2().optional()
116740
+ })
116741
+ }, async ({ kind, prefix, limit, offset }, requestInfo) => {
116742
+ const result = await refusing(requestInfo.agentId, () => listObjects({ agentId: requestInfo.agentId, kind, prefix, limit, offset }));
116743
+ if ("error" in result)
116744
+ return result.error;
116745
+ const { objects, total } = result.value;
116746
+ return toolOk(`Found ${objects.length} of ${total} objects.`, {
116747
+ details: objects.length > 0 ? objects.map((o) => `- ${summary(o)}`).join(`
116748
+ `) : undefined,
116749
+ data: { yourAgentId: requestInfo.agentId, objects, total }
116750
+ });
116751
+ });
116752
+ }, registerObjectReindexTool = (server) => {
116753
+ createToolRegistrar(server)("object-reindex", {
116754
+ title: "Reindex primitive objects",
116755
+ annotations: { readOnlyHint: false, idempotentHint: true },
116756
+ description: "Rebuild the object index from the files on your default agent-fs drive. Keeps each file's embedded id; a file with no id (for example a stock Excalidraw save) keeps the id of the row at its path, else gets a new one written back. Rows whose file is gone are reported as `missing`, never deleted. Files whose version matches the index are checked, not re-read (`unchanged`); one call reads at most 50 changed files, 16 MiB, or 20 seconds of work, so run it again while `truncated` is true (`cutBy` names the limit). agent-fs file.changed webhooks keep the index current between runs when the swarm can register them.",
116757
+ inputSchema: object2({ kind: KindSchema.optional() }),
116758
+ outputSchema: swarmToolOutputSchema({
116759
+ yourAgentId: string2().optional(),
116760
+ scanned: number2().optional(),
116761
+ unchanged: number2().optional(),
116762
+ adopted: array2(string2()).optional(),
116763
+ restored: array2(string2()).optional(),
116764
+ missing: array2(string2()).optional(),
116765
+ conflicts: array2(looseObject({ path: string2(), reason: string2() })).optional(),
116766
+ truncated: boolean().optional(),
116767
+ cutBy: _enum2(["files", "reads", "time", "bytes"]).nullable().optional()
116768
+ })
116769
+ }, async ({ kind }, requestInfo) => {
116770
+ const result = await refusing(requestInfo.agentId, () => reindexObjects({ agentId: requestInfo.agentId, kind }));
116771
+ if ("error" in result)
116772
+ return result.error;
116773
+ const report = result.value;
116774
+ return toolOk(`Scanned ${report.scanned} files: ${report.unchanged} unchanged, ${report.adopted.length} adopted, ${report.restored.length} restored, ${report.missing.length} missing, ${report.conflicts.length} skipped${report.truncated ? ` (truncated: ${report.cutBy} limit)` : ""}.`, { data: { yourAgentId: requestInfo.agentId, ...report } });
116775
+ });
116776
+ };
116777
+ var init_objects2 = __esm(() => {
116778
+ init_zod();
116779
+ init_objects();
116780
+ init_provider();
116781
+ init_utils();
116782
+ objectOutputSchema = looseObject({
116783
+ id: string2().optional(),
116784
+ kind: string2().optional(),
116785
+ orgId: string2().optional(),
116786
+ driveId: string2().optional(),
116787
+ path: string2().optional(),
116788
+ title: string2().nullable().optional(),
116789
+ fileVersion: number2().nullable().optional(),
116790
+ ownerAgentId: string2().nullable().optional(),
116791
+ deletedAt: string2().nullable().optional(),
116792
+ createdAt: string2().optional(),
116793
+ updatedAt: string2().optional(),
116794
+ link: string2().nullable().optional()
116795
+ });
116796
+ KindSchema = _enum2(PRIMITIVE_KIND_NAMES);
116797
+ });
116798
+
116799
+ // src/tools/boards.ts
116800
+ var Coord, Size, Color, ShapeSchema, ArrowSchema, Shapes, Arrows, LayoutSchema, IdOrPath, boardOut, Added, where = (o) => `${o.path}${o.link ? ` (${o.link})` : ""}`, registerBoardCreateTool = (server) => {
116801
+ createToolRegistrar(server)("board-create", {
116802
+ title: "Create board",
116803
+ annotations: { readOnlyHint: false, idempotentHint: false },
116804
+ description: "Create an Excalidraw board (`.excalidraw`) on your default agent-fs drive, as your own agent-fs identity, optionally with shapes and bound arrows. Create-only: refuses when the path exists. `added` maps each shape key (or `shapes[i]`) and `arrows[i]` to its element id.",
116805
+ inputSchema: object2({
116806
+ path: string2().min(1).describe("Drive path ending in .excalidraw."),
116807
+ title: string2().max(200).optional(),
116808
+ shapes: Shapes,
116809
+ arrows: Arrows,
116810
+ layout: LayoutSchema
116811
+ }),
116812
+ outputSchema: swarmToolOutputSchema({ ...boardOut, added: Added.optional() })
116813
+ }, async (args, requestInfo) => {
116814
+ const agentId = requestInfo.agentId;
116815
+ const result = await refusing(agentId, () => createBoard({ agentId, ...args }));
116816
+ if ("error" in result)
116817
+ return result.error;
116818
+ const { object, added } = result.value;
116819
+ return toolOk(`Created board ${object.id} at ${where(object)}.`, {
116820
+ data: { yourAgentId: agentId, object, version: object.fileVersion, added }
116821
+ });
116822
+ });
116823
+ }, registerBoardGetTool = (server) => {
116824
+ createToolRegistrar(server)("board-get", {
116825
+ title: "Get board",
116826
+ annotations: { readOnlyHint: true },
116827
+ description: "Read a board by `id` or `path`. `detail: summary` (default) lists live elements as id, type, text, x, y, width, height and boundTo (arrow: [from, to]; shape: its arrow ids); a shape's label folds into its text. `detail: full` returns the raw Excalidraw elements.",
116828
+ inputSchema: object2({
116829
+ ...IdOrPath,
116830
+ detail: _enum2(["summary", "full"]).optional()
116831
+ }),
116832
+ outputSchema: swarmToolOutputSchema({
116833
+ ...boardOut,
116834
+ elements: array2(looseObject({})).optional()
116835
+ })
116836
+ }, async (args, requestInfo) => {
116837
+ const agentId = requestInfo.agentId;
116838
+ const result = await refusing(agentId, () => getBoard({ agentId, ...args }));
116839
+ if ("error" in result)
116840
+ return result.error;
116841
+ const { object, version, elements } = result.value;
116842
+ return toolOk(`Board ${object.id} at ${where(object)}: ${elements.length} elements, version ${version}.`, {
116843
+ data: { yourAgentId: agentId, object, version, elements }
116844
+ });
116845
+ });
116846
+ }, registerBoardListTool = (server) => {
116847
+ createToolRegistrar(server)("board-list", {
116848
+ title: "List boards",
116849
+ annotations: { readOnlyHint: true },
116850
+ description: "List boards on your default agent-fs drive, newest first. Filter by path `prefix`. Pagination via limit (max 200) and offset.",
116851
+ inputSchema: object2({
116852
+ prefix: string2().optional(),
116853
+ limit: number2().int().positive().max(200).optional(),
116854
+ offset: number2().int().nonnegative().optional()
116855
+ }),
116856
+ outputSchema: swarmToolOutputSchema({
116857
+ yourAgentId: string2().optional(),
116858
+ objects: array2(objectOutputSchema).optional(),
116859
+ total: number2().optional()
116860
+ })
116861
+ }, async (args, requestInfo) => {
116862
+ const agentId = requestInfo.agentId;
116863
+ const result = await refusing(agentId, () => listBoards({ agentId, ...args }));
116864
+ if ("error" in result)
116865
+ return result.error;
116866
+ const { objects, total } = result.value;
116867
+ return toolOk(`Found ${objects.length} of ${total} boards.`, {
116868
+ details: objects.length > 0 ? objects.map((o) => `- ${o.id} at ${where(o)}`).join(`
116869
+ `) : undefined,
116870
+ data: { yourAgentId: agentId, objects, total }
116871
+ });
116872
+ });
116873
+ }, registerBoardAddElementsTool = (server) => {
116874
+ createToolRegistrar(server)("board-add-elements", {
116875
+ title: "Add board elements",
116876
+ annotations: { readOnlyHint: false, idempotentHint: false },
116877
+ description: "Add shapes (rectangle, ellipse, diamond, text) and arrows to a board. Arrows bind both ends to shapes, named by a `key` from this call or an existing element id. Shapes without x/y are laid out below existing content. Writes with the file version and re-applies on a concurrent change (3 retries).",
116878
+ inputSchema: object2({ ...IdOrPath, shapes: Shapes, arrows: Arrows, layout: LayoutSchema }),
116879
+ outputSchema: swarmToolOutputSchema({ ...boardOut, added: Added.optional() })
116880
+ }, async (args, requestInfo) => {
116881
+ const agentId = requestInfo.agentId;
116882
+ const result = await refusing(agentId, () => addBoardElements({ agentId, ...args }));
116883
+ if ("error" in result)
116884
+ return result.error;
116885
+ const { object, version, added } = result.value;
116886
+ return toolOk(`Added ${Object.keys(added).length} elements to board ${object.id}, version ${version}.`, {
116887
+ data: { yourAgentId: agentId, object, version, added }
116888
+ });
116889
+ });
116890
+ }, registerBoardUpdateElementsTool = (server) => {
116891
+ createToolRegistrar(server)("board-update-elements", {
116892
+ title: "Update board elements",
116893
+ annotations: { readOnlyHint: false, idempotentHint: true },
116894
+ description: "Patch board elements by id: label (empty string removes a shape's label), x, y, width, height, color. Bound labels and arrows follow; arrows themselves take only label and color. Each touched element gets a new version, so an open editor repaints it.",
116895
+ inputSchema: object2({
116896
+ ...IdOrPath,
116897
+ patches: array2(object2({
116898
+ elementId: string2().min(1),
116899
+ label: string2().max(2000).optional(),
116900
+ x: Coord.optional(),
116901
+ y: Coord.optional(),
116902
+ width: Size.optional(),
116903
+ height: Size.optional(),
116904
+ color: Color.optional()
116905
+ })).min(1).max(200)
116906
+ }),
116907
+ outputSchema: swarmToolOutputSchema({ ...boardOut, updated: array2(string2()).optional() })
116908
+ }, async (args, requestInfo) => {
116909
+ const agentId = requestInfo.agentId;
116910
+ const result = await refusing(agentId, () => updateBoardElements({ agentId, ...args }));
116911
+ if ("error" in result)
116912
+ return result.error;
116913
+ const { object, version, updated } = result.value;
116914
+ return toolOk(`Updated ${updated.length} elements on board ${object.id}, version ${version}.`, {
116915
+ data: { yourAgentId: agentId, object, version, updated }
116916
+ });
116917
+ });
116918
+ }, registerBoardRemoveElementsTool = (server) => {
116919
+ createToolRegistrar(server)("board-remove-elements", {
116920
+ title: "Remove board elements",
116921
+ annotations: { readOnlyHint: false, idempotentHint: true, destructiveHint: true },
116922
+ description: "Remove board elements by id (sets `isDeleted: true`, the Excalidraw convention). A shape's label goes with it and its arrows are unbound; a removed arrow leaves its shapes. Refuses unknown ids before writing.",
116923
+ inputSchema: object2({
116924
+ ...IdOrPath,
116925
+ elementIds: array2(string2().min(1)).min(1).max(500)
116926
+ }),
116927
+ outputSchema: swarmToolOutputSchema({ ...boardOut, removed: array2(string2()).optional() })
116928
+ }, async (args, requestInfo) => {
116929
+ const agentId = requestInfo.agentId;
116930
+ const result = await refusing(agentId, () => removeBoardElements({ agentId, ...args }));
116931
+ if ("error" in result)
116932
+ return result.error;
116933
+ const { object, version, removed } = result.value;
116934
+ return toolOk(`Removed ${removed.length} elements from board ${object.id}, version ${version}.`, {
116935
+ data: { yourAgentId: agentId, object, version, removed }
116936
+ });
116937
+ });
116938
+ };
116939
+ var init_boards = __esm(() => {
116940
+ init_zod();
116941
+ init_elements();
116942
+ init_service();
116943
+ init_objects2();
116944
+ init_utils();
116945
+ Coord = number2().min(-1e6).max(1e6);
116946
+ Size = number2().positive().max(1e4);
116947
+ Color = string2().max(32).describe(`A palette name (${Object.keys(PALETTE).join(", ")}) or #rrggbb (background).`);
116948
+ ShapeSchema = object2({
116949
+ key: string2().min(1).max(64).optional().describe("Your name for the shape, so arrows in the same call can point at it."),
116950
+ type: _enum2(SHAPE_TYPES),
116951
+ x: Coord.optional(),
116952
+ y: Coord.optional(),
116953
+ width: Size.optional().describe("Minimum width; a shape grows to fit its label."),
116954
+ height: Size.optional().describe("Minimum height; a shape grows to fit its label."),
116955
+ label: string2().max(2000).optional().describe("Text inside the shape; required for `text`."),
116956
+ color: Color.optional()
116957
+ });
116958
+ ArrowSchema = object2({
116959
+ from: string2().min(1).max(64).describe("A shape `key` from this call or an existing element id."),
116960
+ to: string2().min(1).max(64).describe("A shape `key` from this call or an existing element id."),
116961
+ label: string2().max(500).optional()
116962
+ });
116963
+ Shapes = array2(ShapeSchema).max(200).optional();
116964
+ Arrows = array2(ArrowSchema).max(200).optional();
116965
+ LayoutSchema = _enum2(LAYOUTS).optional().describe("How shapes without x/y are placed, below existing content. Default `row`.");
116966
+ IdOrPath = {
116967
+ id: string2().min(1).optional().describe("Board object id."),
116968
+ path: string2().min(1).optional().describe("Board path on your default drive.")
116969
+ };
116970
+ boardOut = {
116971
+ yourAgentId: string2().optional(),
116972
+ object: objectOutputSchema.optional(),
116973
+ version: number2().nullable().optional()
116974
+ };
116975
+ Added = record2(string2(), string2());
116976
+ });
116977
+
115141
116978
  // src/workflows/approval-cancel.ts
115142
116979
  async function cancelApprovalRequest(input) {
115143
116980
  const finalReason = input.reason ?? "Cancelled through the API";
@@ -136099,6 +137936,655 @@ var init_send_task = __esm(() => {
136099
137936
  ]);
136100
137937
  });
136101
137938
 
137939
+ // src/be/primitives/sheets/engine.ts
137940
+ function workerSpecifier() {
137941
+ if (import.meta.url.includes("/$bunfs/"))
137942
+ return "./be/primitives/sheets/engine-worker.ts";
137943
+ return new URL("./engine-worker.ts", import.meta.url).href;
137944
+ }
137945
+ function cellsAfter(tabs, patches) {
137946
+ const refs = new Map(tabs.map((tab) => [tab.name, new Set(Object.keys(tab.cells))]));
137947
+ for (const patch of patches) {
137948
+ const tab = refs.get(patch.tab);
137949
+ if (!tab)
137950
+ continue;
137951
+ const ref = refOf(patch.row, patch.col);
137952
+ if (patch.input === "")
137953
+ tab.delete(ref);
137954
+ else
137955
+ tab.add(ref);
137956
+ }
137957
+ let total = 0;
137958
+ for (const tab of refs.values())
137959
+ total += tab.size;
137960
+ return total;
137961
+ }
137962
+ function literalSpill(patches) {
137963
+ let total = 0;
137964
+ for (const { input } of patches) {
137965
+ if (!input.startsWith("="))
137966
+ continue;
137967
+ for (const match of input.matchAll(ARRAY_SIZE)) {
137968
+ total += Math.ceil(Number(match[1])) * Math.ceil(Number(match[2] ?? 1));
137969
+ }
137970
+ }
137971
+ return total;
137972
+ }
137973
+
137974
+ class SheetEngine {
137975
+ worker;
137976
+ queue = Promise.resolve();
137977
+ nextId = 1;
137978
+ pending = new Map;
137979
+ total = 0;
137980
+ spawn() {
137981
+ const worker = new Worker(workerSpecifier());
137982
+ worker.unref?.();
137983
+ return new Promise((resolve, reject) => {
137984
+ const timer = setTimeout(() => {
137985
+ worker.terminate();
137986
+ reject(new ObjectsError("sheet engine failed to start in time; retry"));
137987
+ }, ENGINE_TIMEOUT_MS);
137988
+ worker.addEventListener("message", function onReady(event) {
137989
+ if (event.data.type !== "ready")
137990
+ return;
137991
+ clearTimeout(timer);
137992
+ worker.removeEventListener("message", onReady);
137993
+ resolve(worker);
137994
+ });
137995
+ worker.addEventListener("error", (event) => {
137996
+ clearTimeout(timer);
137997
+ reject(new Error(`sheet engine failed to start: ${event.message}`));
137998
+ }, { once: true });
137999
+ });
138000
+ }
138001
+ kill() {
138002
+ const pending = this.worker;
138003
+ this.worker = undefined;
138004
+ pending?.then((worker) => worker.terminate()).catch(() => {});
138005
+ }
138006
+ recalc(tabs, patches, options) {
138007
+ const caller = options.caller ?? "";
138008
+ const mine = this.pending.get(caller) ?? 0;
138009
+ if (this.total >= MAX_ENGINE_CALLS || mine >= MAX_ENGINE_CALLS_PER_CALLER) {
138010
+ return Promise.reject(new ObjectsError("sheet engine is busy with other recalculations; retry in a few seconds"));
138011
+ }
138012
+ const cells = cellsAfter(tabs, patches);
138013
+ const spill = literalSpill(patches);
138014
+ if (cells + spill > options.maxCells) {
138015
+ const spilled = spill > 0 ? ` (${spill} of them spilled by array formulas)` : "";
138016
+ return Promise.reject(new ObjectsError(`the workbook would exceed ${options.maxCells} cells: this write leaves ${cells + spill}${spilled}`));
138017
+ }
138018
+ this.pending.set(caller, mine + 1);
138019
+ this.total++;
138020
+ const release = () => {
138021
+ this.total--;
138022
+ const left = (this.pending.get(caller) ?? 1) - 1;
138023
+ if (left > 0)
138024
+ this.pending.set(caller, left);
138025
+ else
138026
+ this.pending.delete(caller);
138027
+ };
138028
+ const run = async () => {
138029
+ this.worker ??= this.spawn();
138030
+ let worker;
138031
+ try {
138032
+ worker = await this.worker;
138033
+ } catch (error) {
138034
+ this.worker = undefined;
138035
+ throw error;
138036
+ }
138037
+ const id = this.nextId++;
138038
+ const timeoutMs = options.timeoutMs ?? ENGINE_TIMEOUT_MS;
138039
+ return new Promise((resolve, reject) => {
138040
+ const done = () => {
138041
+ clearTimeout(timer);
138042
+ worker.removeEventListener("message", onMessage);
138043
+ worker.removeEventListener("error", onError);
138044
+ };
138045
+ const timer = setTimeout(() => {
138046
+ done();
138047
+ this.kill();
138048
+ reject(new ObjectsError(`sheet engine timed out after ${timeoutMs} ms; the workbook is too heavy to recalculate`));
138049
+ }, timeoutMs);
138050
+ const onMessage = (event) => {
138051
+ const message = event.data;
138052
+ if (message.type === "result" && message.id === id) {
138053
+ done();
138054
+ resolve({ cells: message.cells, changed: message.changed });
138055
+ } else if (message.type === "error" && message.id === id) {
138056
+ done();
138057
+ if (message.fatal)
138058
+ this.kill();
138059
+ reject(new ObjectsError(message.message));
138060
+ }
138061
+ };
138062
+ const onError = (event) => {
138063
+ done();
138064
+ this.kill();
138065
+ reject(new Error(`sheet engine crashed: ${event.message}`));
138066
+ };
138067
+ worker.addEventListener("message", onMessage);
138068
+ worker.addEventListener("error", onError);
138069
+ const request = { id, tabs, patches, maxCells: options.maxCells };
138070
+ worker.postMessage(request);
138071
+ });
138072
+ };
138073
+ const result = this.queue.then(run, run).finally(release);
138074
+ this.queue = result.catch(() => {});
138075
+ return result;
138076
+ }
138077
+ stop() {
138078
+ this.kill();
138079
+ }
138080
+ }
138081
+ var ENGINE_TIMEOUT_MS = 1e4, MAX_ENGINE_CALLS = 8, MAX_ENGINE_CALLS_PER_CALLER = 2, ARRAY_SIZE, shared, sheetEngine = () => {
138082
+ shared ??= new SheetEngine;
138083
+ return shared;
138084
+ };
138085
+ var init_engine2 = __esm(() => {
138086
+ init_objects();
138087
+ init_a1();
138088
+ ARRAY_SIZE = /\b(?:SEQUENCE|RANDARRAY|MAKEARRAY)\(\s*(\d+(?:\.\d+)?)\s*(?:,\s*(\d+(?:\.\d+)?)\s*[,)])?/gi;
138089
+ });
138090
+
138091
+ // src/be/primitives/sheets/service.ts
138092
+ async function load(target) {
138093
+ const { object, missing, content } = await getObject({ ...target, includeContent: true });
138094
+ if (object.kind !== "sheet") {
138095
+ throw new ObjectsError(`object ${object.id} is a ${object.kind}, not a sheet`);
138096
+ }
138097
+ if (missing) {
138098
+ throw new ObjectsError(`the file for ${object.path} is missing on the drive; run object-reindex`);
138099
+ }
138100
+ const parsed = SheetDocSchema.safeParse(content);
138101
+ if (!parsed.success) {
138102
+ const issue = parsed.error.issues[0];
138103
+ throw new ObjectsError(`${object.path} is not a valid swarm-sheet/1 workbook: ${issue?.path.join(".") || "document"}: ${issue?.message}`);
138104
+ }
138105
+ if (object.fileVersion === null) {
138106
+ throw new ObjectsError(`agent-fs returned no version for ${object.path}; cannot write safely`);
138107
+ }
138108
+ return { object, version: object.fileVersion, doc: parsed.data };
138109
+ }
138110
+ async function save(agentId, object, doc, version, op) {
138111
+ const body = JSON.stringify(doc, null, 2);
138112
+ if (Buffer.byteLength(body) > MAX_FILE_BYTES) {
138113
+ throw new ObjectsError(`the sheet would exceed ${MAX_FILE_BYTES} bytes (5 MiB)`);
138114
+ }
138115
+ const client = agentId ? await agentFsClientFor(agentId) : undefined;
138116
+ if (!client)
138117
+ throw new ObjectsError(NO_AGENT_FS_IDENTITY);
138118
+ const { orgId, driveId } = client.identity;
138119
+ const saved = await client.provider.upload({ taskId: "", name: "", key: object.path, orgId, driveId }, body, { contentType: "application/json", ifMatch: String(version), message: `sheet ${op}` });
138120
+ const next = saved.version ? Number(saved.version) : version + 1;
138121
+ await getDbClient2().run("UPDATE primitive_objects SET fileVersion = ?, updatedAt = ? WHERE id = ?", [next, new Date().toISOString(), object.id]);
138122
+ return next;
138123
+ }
138124
+ async function mutate(target, op, apply) {
138125
+ for (let attempt = 1;; attempt++) {
138126
+ const { object, version, doc } = await load(target);
138127
+ const { doc: next, result } = await apply(structuredClone(doc));
138128
+ if (!next)
138129
+ return { version, result };
138130
+ try {
138131
+ return { version: await save(target.agentId, object, next, version, op), result };
138132
+ } catch (error) {
138133
+ if (!(error instanceof FilesError && error.code === "Conflict"))
138134
+ throw error;
138135
+ if (attempt >= MAX_ATTEMPTS) {
138136
+ throw new ObjectsError(`concurrent writers changed ${object.path} ${MAX_ATTEMPTS} times; retry`);
138137
+ }
138138
+ }
138139
+ }
138140
+ }
138141
+ function findTab(doc, name) {
138142
+ if (name === undefined)
138143
+ return doc.tabs[0];
138144
+ const tab = doc.tabs.find((t) => t.name === name) ?? doc.tabs.find((t) => t.name.toLowerCase() === name.toLowerCase());
138145
+ if (!tab) {
138146
+ throw new ObjectsError(`no tab '${name}' (tabs: ${doc.tabs.map((t) => t.name).join(", ")})`);
138147
+ }
138148
+ return tab;
138149
+ }
138150
+ function inputFor(value) {
138151
+ if (typeof value !== "string")
138152
+ return constantInput(value);
138153
+ if (value.length > 1 && value.startsWith("="))
138154
+ return value;
138155
+ if (value.startsWith("'="))
138156
+ return value;
138157
+ return constantInput(value);
138158
+ }
138159
+ async function recalc(agentId, doc, patches) {
138160
+ const { cells, changed } = await sheetEngine().recalc(doc.tabs, patches, {
138161
+ maxCells: MAX_CELLS,
138162
+ caller: agentId
138163
+ });
138164
+ doc.tabs.forEach((tab, i) => {
138165
+ tab.cells = cells[i] ?? {};
138166
+ });
138167
+ return changed;
138168
+ }
138169
+ function checkArea(range, what) {
138170
+ const area = areaOf(range);
138171
+ if (area > MAX_RANGE_CELLS) {
138172
+ throw new ObjectsError(`${what} covers ${area} cells; the limit is ${MAX_RANGE_CELLS} per call`);
138173
+ }
138174
+ }
138175
+ async function createSheet(input) {
138176
+ const { tabs } = input;
138177
+ if (tabs) {
138178
+ refuse(() => {
138179
+ if (tabs.length === 0 || tabs.length > MAX_TABS)
138180
+ throw new A1Error(`tabs: 1-${MAX_TABS} tabs`);
138181
+ const seen = new Set;
138182
+ for (const tab of tabs) {
138183
+ if (seen.has(checkTabName(tab.name).toLowerCase()))
138184
+ throw new A1Error(`duplicate tab '${tab.name}'`);
138185
+ seen.add(tab.name.toLowerCase());
138186
+ const cells = (tab.rows ?? []).reduce((n, row) => n + row.length, 0);
138187
+ if (cells > MAX_RANGE_CELLS)
138188
+ throw new A1Error(`tab '${tab.name}' has ${cells} initial cells; the limit is ${MAX_RANGE_CELLS}`);
138189
+ }
138190
+ });
138191
+ }
138192
+ const created = await createObject({
138193
+ agentId: input.agentId,
138194
+ kind: "sheet",
138195
+ path: input.path,
138196
+ title: input.title
138197
+ });
138198
+ if (!tabs)
138199
+ return { object: created, link: created.link };
138200
+ try {
138201
+ const { version } = await mutate({ agentId: input.agentId, id: created.id }, "create tabs", async (doc) => {
138202
+ doc.tabs = tabs.map((t) => newTab(t.name));
138203
+ const patches = tabs.flatMap((t) => (t.rows ?? []).flatMap((row, r) => row.map((value, c) => ({
138204
+ tab: t.name,
138205
+ row: r + 1,
138206
+ col: c + 1,
138207
+ input: inputFor(value)
138208
+ }))));
138209
+ await recalc(input.agentId, doc, patches);
138210
+ return { doc, result: null };
138211
+ });
138212
+ return { object: { ...created, fileVersion: version }, link: created.link };
138213
+ } catch (error) {
138214
+ if (error instanceof ObjectsError) {
138215
+ throw new ObjectsError(`created ${created.path} (id ${created.id}) but could not write its tabs: ${error.message}`);
138216
+ }
138217
+ throw error;
138218
+ }
138219
+ }
138220
+ async function getSheet(target) {
138221
+ const { object, version, doc } = await load(target);
138222
+ return { object, version, tabs: doc.tabs.map(tabSummary) };
138223
+ }
138224
+ async function getSheetRange(target) {
138225
+ const { version, doc } = await load(target);
138226
+ const spec = refuse(() => parseRange(target.range));
138227
+ const tab = findTab(doc, spec.tab);
138228
+ const range = capToUsed(spec, usedExtent(tab));
138229
+ if (!range)
138230
+ return {
138231
+ range: formatRange(tab.name, { ...spec, r2: spec.r1, c2: spec.c1 }),
138232
+ values: [],
138233
+ version
138234
+ };
138235
+ checkArea(range, "the range");
138236
+ const values = [];
138237
+ const formulas = [];
138238
+ for (let r = range.r1;r <= range.r2; r++) {
138239
+ const row = [];
138240
+ const formulaRow = [];
138241
+ for (let c = range.c1;c <= range.c2; c++) {
138242
+ const cell = tab.cells[refOf(r, c)];
138243
+ const value = cell?.v ?? null;
138244
+ row.push(value);
138245
+ formulaRow.push(cell?.f ?? value);
138246
+ }
138247
+ values.push(row);
138248
+ formulas.push(formulaRow);
138249
+ }
138250
+ return {
138251
+ range: formatRange(tab.name, range),
138252
+ values,
138253
+ ...target.formulas ? { formulas } : {},
138254
+ version
138255
+ };
138256
+ }
138257
+ async function setSheetRange(target) {
138258
+ const spec = refuse(() => parseRange(target.range));
138259
+ if (spec.open)
138260
+ throw new ObjectsError("setRange needs a bounded range such as 'Tab!B2:C3', not a whole column or row");
138261
+ const rows = target.values.length;
138262
+ const cols = Math.max(0, ...target.values.map((row) => row.length));
138263
+ if (rows === 0 || cols === 0)
138264
+ throw new ObjectsError("values is empty");
138265
+ if (target.values.some((row) => row.length !== cols))
138266
+ throw new ObjectsError("values must be a rectangle: every row needs the same length");
138267
+ const single = spec.r1 === spec.r2 && spec.c1 === spec.c2;
138268
+ const range = single ? { ...spec, r2: spec.r1 + rows - 1, c2: spec.c1 + cols - 1 } : spec;
138269
+ const height = range.r2 - range.r1 + 1;
138270
+ const width = range.c2 - range.c1 + 1;
138271
+ if (height !== rows || width !== cols) {
138272
+ throw new ObjectsError(`values is ${rows}x${cols} but the range is ${height}x${width}`);
138273
+ }
138274
+ refuse(() => assertInBounds(range));
138275
+ checkArea(range, "the range");
138276
+ const { version, result } = await mutate(target, "set range", async (doc) => {
138277
+ const tab = findTab(doc, spec.tab);
138278
+ const patches = target.values.flatMap((row, i) => row.map((value, j) => ({
138279
+ tab: tab.name,
138280
+ row: range.r1 + i,
138281
+ col: range.c1 + j,
138282
+ input: inputFor(value)
138283
+ })));
138284
+ const changed = await recalc(target.agentId, doc, patches);
138285
+ const inRange = (ref) => {
138286
+ const [name, a1] = [ref.slice(0, ref.lastIndexOf("!")), ref.slice(ref.lastIndexOf("!") + 1)];
138287
+ const { row, col } = parseCell(a1);
138288
+ return name === tab.name && row >= range.r1 && row <= range.r2 && col >= range.c1 && col <= range.c2;
138289
+ };
138290
+ const direct = changed.filter(inRange).length;
138291
+ return {
138292
+ doc: changed.length ? doc : undefined,
138293
+ result: {
138294
+ range: formatRange(tab.name, range),
138295
+ changed: direct,
138296
+ recalculated: changed.length - direct
138297
+ }
138298
+ };
138299
+ });
138300
+ return { ...result, version };
138301
+ }
138302
+ async function appendSheetRows(target) {
138303
+ const cells = target.rows.reduce((n, row) => n + row.length, 0);
138304
+ if (cells === 0)
138305
+ throw new ObjectsError("rows is empty");
138306
+ if (cells > MAX_RANGE_CELLS)
138307
+ throw new ObjectsError(`rows hold ${cells} cells; the limit is ${MAX_RANGE_CELLS} per call`);
138308
+ const { version, result } = await mutate(target, "append rows", async (doc) => {
138309
+ const tab = findTab(doc, target.tab);
138310
+ const first = usedExtent(tab).rows + 1;
138311
+ const cols = Math.max(...target.rows.map((row) => row.length));
138312
+ const range = { r1: first, c1: 1, r2: first + target.rows.length - 1, c2: cols };
138313
+ refuse(() => assertInBounds(range));
138314
+ const patches = target.rows.flatMap((row, i) => row.flatMap((value, j) => value === null ? [] : [{ tab: tab.name, row: first + i, col: j + 1, input: inputFor(value) }]));
138315
+ const changed = await recalc(target.agentId, doc, patches);
138316
+ return {
138317
+ doc: changed.length ? doc : undefined,
138318
+ result: { range: formatRange(tab.name, range) }
138319
+ };
138320
+ });
138321
+ return { ...result, version };
138322
+ }
138323
+ async function clearSheetRange(target) {
138324
+ const spec = refuse(() => parseRange(target.range));
138325
+ const { version, result } = await mutate(target, "clear range", async (doc) => {
138326
+ const tab = findTab(doc, spec.tab);
138327
+ const range = capToUsed(spec, usedExtent(tab));
138328
+ if (!range)
138329
+ return {
138330
+ result: { range: formatRange(tab.name, { ...spec, r2: spec.r1, c2: spec.c1 }), cleared: 0 }
138331
+ };
138332
+ checkArea(range, "the range");
138333
+ const patches = Object.entries(tab.cells).flatMap(([ref, cell]) => {
138334
+ const { row, col } = parseCell(ref);
138335
+ const inside = row >= range.r1 && row <= range.r2 && col >= range.c1 && col <= range.c2;
138336
+ return inside && !cell.s ? [{ tab: tab.name, row, col, input: "" }] : [];
138337
+ });
138338
+ if (patches.length === 0)
138339
+ return { result: { range: formatRange(tab.name, range), cleared: 0 } };
138340
+ await recalc(target.agentId, doc, patches);
138341
+ return { doc, result: { range: formatRange(tab.name, range), cleared: patches.length } };
138342
+ });
138343
+ return { ...result, version };
138344
+ }
138345
+ async function addSheetTab(target) {
138346
+ const { version, result } = await mutate(target, "add tab", async (doc) => {
138347
+ refuse(() => checkTabName(target.name));
138348
+ if (doc.tabs.some((t) => t.name.toLowerCase() === target.name.toLowerCase())) {
138349
+ throw new ObjectsError(`a tab named '${target.name}' already exists`);
138350
+ }
138351
+ if (doc.tabs.length >= MAX_TABS)
138352
+ throw new ObjectsError(`a sheet holds at most ${MAX_TABS} tabs`);
138353
+ const at = target.after === undefined ? doc.tabs.length : doc.tabs.indexOf(findTab(doc, target.after)) + 1;
138354
+ doc.tabs.splice(at, 0, newTab(target.name));
138355
+ return { doc, result: { tabs: doc.tabs.map((t) => t.name) } };
138356
+ });
138357
+ return { ...result, version };
138358
+ }
138359
+ var MAX_ATTEMPTS = 4, refuse = (run) => {
138360
+ try {
138361
+ return run();
138362
+ } catch (error) {
138363
+ if (error instanceof A1Error)
138364
+ throw new ObjectsError(error.message);
138365
+ throw error;
138366
+ }
138367
+ }, tabSummary = (tab) => {
138368
+ const { rows, cols } = usedExtent(tab);
138369
+ return { name: tab.name, rows, cols, freezeRows: tab.freezeRows ?? 0 };
138370
+ }, listSheets = (input) => listObjects({ ...input, kind: "sheet" });
138371
+ var init_service2 = __esm(() => {
138372
+ init_provider();
138373
+ init_agent_fs_identity();
138374
+ init_db4();
138375
+ init_objects();
138376
+ init_a1();
138377
+ init_engine2();
138378
+ init_format();
138379
+ });
138380
+
138381
+ // src/tools/sheets.ts
138382
+ async function refusing2(agentId, run) {
138383
+ try {
138384
+ return { value: await run() };
138385
+ } catch (error) {
138386
+ if (error instanceof ObjectsError || error instanceof FilesError) {
138387
+ return { error: toolErr(error.message, { data: { yourAgentId: agentId } }) };
138388
+ }
138389
+ throw error;
138390
+ }
138391
+ }
138392
+ var objectOutputSchema2, CellValue, Grid, RANGE_HELP = "A1 range such as `Tasks!B2:C3`, `A1:C10` (first tab), `'My tab'!A:A` (whole column, capped to the used range) or `B2`.", dataShape, outputSchema, ID2 = "Object id (from sheet-create or sheet-list).", PATH = "Drive path of the `.sheet.json` file, instead of `id`.", WRITE, registerSheetCreateTool = (server) => {
138393
+ createToolRegistrar(server)("sheet-create", {
138394
+ title: "Create sheet",
138395
+ annotations: WRITE,
138396
+ description: "Create a spreadsheet (`swarm-sheet/1`, a `.sheet.json` file) on your default agent-fs drive, as your own agent-fs identity. Create-only: refuses when the path exists. Optional `tabs` name the tabs (default one tab `Sheet1`) and may seed each with `rows` from A1. Formulas recompute with a spreadsheet engine; limits: 20 tabs, 50,000 cells, 5 MiB.",
138397
+ inputSchema: object2({
138398
+ path: string2().min(1).describe("Drive path ending in `.sheet.json`, e.g. /qa/tracker.sheet.json."),
138399
+ title: string2().max(200).optional(),
138400
+ tabs: array2(object2({ name: string2().min(1).max(31), rows: Grid.optional() })).optional().describe("Tabs to create, each with an optional `rows` grid written from A1.")
138401
+ }),
138402
+ outputSchema
138403
+ }, async ({ path, title, tabs }, requestInfo) => {
138404
+ const result = await refusing2(requestInfo.agentId, () => createSheet({ agentId: requestInfo.agentId, path, title, tabs }));
138405
+ if ("error" in result)
138406
+ return result.error;
138407
+ const { object, link } = result.value;
138408
+ return toolOk(`Created sheet ${object.id} at ${object.path}${link ? ` (${link})` : ""}.`, {
138409
+ data: { yourAgentId: requestInfo.agentId, ...result.value }
138410
+ });
138411
+ });
138412
+ }, registerSheetGetTool = (server) => {
138413
+ createToolRegistrar(server)("sheet-get", {
138414
+ title: "Get sheet",
138415
+ annotations: { readOnlyHint: true },
138416
+ description: "Get a sheet's object, current agent-fs `version` and its tabs (name, used rows and columns, frozen rows). Read cells with sheet-get-range.",
138417
+ inputSchema: object2({
138418
+ id: string2().min(1).optional().describe(ID2),
138419
+ path: string2().min(1).optional().describe(PATH)
138420
+ }),
138421
+ outputSchema
138422
+ }, async ({ id, path }, requestInfo) => {
138423
+ const result = await refusing2(requestInfo.agentId, () => getSheet({ agentId: requestInfo.agentId, id, path }));
138424
+ if ("error" in result)
138425
+ return result.error;
138426
+ const { object, tabs, version } = result.value;
138427
+ return toolOk(`Sheet ${object.id} at ${object.path}: ${tabs.length} tab(s), version ${version}.`, {
138428
+ data: { yourAgentId: requestInfo.agentId, ...result.value }
138429
+ });
138430
+ });
138431
+ }, registerSheetListTool = (server) => {
138432
+ createToolRegistrar(server)("sheet-list", {
138433
+ title: "List sheets",
138434
+ annotations: { readOnlyHint: true },
138435
+ description: "List sheets on your default agent-fs drive, newest first. Filter by path `prefix`. Pagination via limit (max 200) and offset.",
138436
+ inputSchema: object2({
138437
+ prefix: string2().optional(),
138438
+ limit: number2().int().positive().max(200).optional(),
138439
+ offset: number2().int().nonnegative().optional()
138440
+ }),
138441
+ outputSchema
138442
+ }, async ({ prefix, limit, offset }, requestInfo) => {
138443
+ const result = await refusing2(requestInfo.agentId, () => listSheets({ agentId: requestInfo.agentId, prefix, limit, offset }));
138444
+ if ("error" in result)
138445
+ return result.error;
138446
+ const { objects, total } = result.value;
138447
+ return toolOk(`Found ${objects.length} of ${total} sheets.`, {
138448
+ details: objects.length > 0 ? objects.map((o) => `- ${o.id} at ${o.path}`).join(`
138449
+ `) : undefined,
138450
+ data: { yourAgentId: requestInfo.agentId, ...result.value }
138451
+ });
138452
+ });
138453
+ }, registerSheetGetRangeTool = (server) => {
138454
+ createToolRegistrar(server)("sheet-get-range", {
138455
+ title: "Read sheet range",
138456
+ annotations: { readOnlyHint: true },
138457
+ description: "Read cached values from a range (at most 10,000 cells). Formula cells return their computed value; an error cell returns its error text such as `#DIV/0!`; spilled cells (SEQUENCE, UNIQUE, ...) are included. `formulas: true` also returns the formulas.",
138458
+ inputSchema: object2({
138459
+ id: string2().min(1).optional().describe(ID2),
138460
+ path: string2().min(1).optional().describe(PATH),
138461
+ range: string2().min(1).describe(RANGE_HELP),
138462
+ formulas: boolean().optional().describe("Also return `formulas[][]`: the formula text where a cell has one, else the value.")
138463
+ }),
138464
+ outputSchema
138465
+ }, async ({ id, path, range, formulas }, requestInfo) => {
138466
+ const result = await refusing2(requestInfo.agentId, () => getSheetRange({ agentId: requestInfo.agentId, id, path, range, formulas }));
138467
+ if ("error" in result)
138468
+ return result.error;
138469
+ return toolOk(`Read ${result.value.range} at version ${result.value.version}.`, {
138470
+ data: { yourAgentId: requestInfo.agentId, ...result.value }
138471
+ });
138472
+ });
138473
+ }, registerSheetSetRangeTool = (server) => {
138474
+ createToolRegistrar(server)("sheet-set-range", {
138475
+ title: "Write sheet range",
138476
+ annotations: WRITE,
138477
+ description: "Write a rectangle of `values` and recompute every formula. A string starting with `=` is a formula; start with `'=` to store literal text that begins with `=`; other strings stay text even when they look like numbers, so send numbers as numbers; null clears the cell. A single-cell `range` is the top-left corner; a larger `range` must match the values' size. Retries on a concurrent write: other cells merge, the same cell is last writer wins.",
138478
+ inputSchema: object2({
138479
+ id: string2().min(1).optional().describe(ID2),
138480
+ path: string2().min(1).optional().describe(PATH),
138481
+ range: string2().min(1).describe(RANGE_HELP),
138482
+ values: Grid.describe("Rows of cell values, all the same length (at most 10,000 cells).")
138483
+ }),
138484
+ outputSchema
138485
+ }, async ({ id, path, range, values }, requestInfo) => {
138486
+ const result = await refusing2(requestInfo.agentId, () => setSheetRange({ agentId: requestInfo.agentId, id, path, range, values }));
138487
+ if ("error" in result)
138488
+ return result.error;
138489
+ const r = result.value;
138490
+ return toolOk(`Wrote ${r.range}: ${r.changed} changed, ${r.recalculated} recalculated, version ${r.version}.`, { data: { yourAgentId: requestInfo.agentId, ...r } });
138491
+ });
138492
+ }, registerSheetAppendRowsTool = (server) => {
138493
+ createToolRegistrar(server)("sheet-append-rows", {
138494
+ title: "Append sheet rows",
138495
+ annotations: WRITE,
138496
+ description: "Append rows below the last used row of a tab, starting at column A. Same value rules as sheet-set-range; null skips a cell. Returns the range written.",
138497
+ inputSchema: object2({
138498
+ id: string2().min(1).optional().describe(ID2),
138499
+ path: string2().min(1).optional().describe(PATH),
138500
+ tab: string2().min(1).describe("Tab name."),
138501
+ rows: Grid.describe("Rows to append (at most 10,000 cells).")
138502
+ }),
138503
+ outputSchema
138504
+ }, async ({ id, path, tab, rows }, requestInfo) => {
138505
+ const result = await refusing2(requestInfo.agentId, () => appendSheetRows({ agentId: requestInfo.agentId, id, path, tab, rows }));
138506
+ if ("error" in result)
138507
+ return result.error;
138508
+ return toolOk(`Appended ${result.value.range}, version ${result.value.version}.`, {
138509
+ data: { yourAgentId: requestInfo.agentId, ...result.value }
138510
+ });
138511
+ });
138512
+ }, registerSheetClearRangeTool = (server) => {
138513
+ createToolRegistrar(server)("sheet-clear-range", {
138514
+ title: "Clear sheet range",
138515
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
138516
+ description: "Clear the contents of a range and recompute dependents. A whole-column or whole-row range is capped to the used range. Spilled cells go when their anchor is cleared.",
138517
+ inputSchema: object2({
138518
+ id: string2().min(1).optional().describe(ID2),
138519
+ path: string2().min(1).optional().describe(PATH),
138520
+ range: string2().min(1).describe(RANGE_HELP)
138521
+ }),
138522
+ outputSchema
138523
+ }, async ({ id, path, range }, requestInfo) => {
138524
+ const result = await refusing2(requestInfo.agentId, () => clearSheetRange({ agentId: requestInfo.agentId, id, path, range }));
138525
+ if ("error" in result)
138526
+ return result.error;
138527
+ const r = result.value;
138528
+ return toolOk(`Cleared ${r.cleared} cell(s) in ${r.range}, version ${r.version}.`, {
138529
+ data: { yourAgentId: requestInfo.agentId, ...r }
138530
+ });
138531
+ });
138532
+ }, registerSheetAddTabTool = (server) => {
138533
+ createToolRegistrar(server)("sheet-add-tab", {
138534
+ title: "Add sheet tab",
138535
+ annotations: WRITE,
138536
+ description: "Add an empty tab (1-31 characters, none of `[]:*?/\\`), at the end or after the tab named `after`. A sheet holds at most 20 tabs.",
138537
+ inputSchema: object2({
138538
+ id: string2().min(1).optional().describe(ID2),
138539
+ path: string2().min(1).optional().describe(PATH),
138540
+ name: string2().min(1).max(31).describe("New tab name."),
138541
+ after: string2().optional().describe("Insert after this tab; default: at the end.")
138542
+ }),
138543
+ outputSchema
138544
+ }, async ({ id, path, name, after }, requestInfo) => {
138545
+ const result = await refusing2(requestInfo.agentId, () => addSheetTab({ agentId: requestInfo.agentId, id, path, name, after }));
138546
+ if ("error" in result)
138547
+ return result.error;
138548
+ return toolOk(`Tabs now: ${result.value.tabs.join(", ")} (version ${result.value.version}).`, {
138549
+ data: { yourAgentId: requestInfo.agentId, ...result.value }
138550
+ });
138551
+ });
138552
+ };
138553
+ var init_sheets = __esm(() => {
138554
+ init_zod();
138555
+ init_objects();
138556
+ init_service2();
138557
+ init_provider();
138558
+ init_utils();
138559
+ objectOutputSchema2 = looseObject({
138560
+ id: string2().optional(),
138561
+ kind: string2().optional(),
138562
+ path: string2().optional(),
138563
+ title: string2().nullable().optional(),
138564
+ fileVersion: number2().nullable().optional(),
138565
+ link: string2().nullable().optional()
138566
+ });
138567
+ CellValue = union3([number2(), string2(), boolean(), _null()]);
138568
+ Grid = array2(array2(CellValue));
138569
+ dataShape = {
138570
+ yourAgentId: string2().optional(),
138571
+ object: objectOutputSchema2.optional(),
138572
+ objects: array2(objectOutputSchema2).optional(),
138573
+ total: number2().optional(),
138574
+ link: string2().nullable().optional(),
138575
+ version: number2().optional(),
138576
+ tabs: array2(unknown()).optional(),
138577
+ range: string2().optional(),
138578
+ values: array2(array2(unknown())).optional(),
138579
+ formulas: array2(array2(unknown())).optional(),
138580
+ changed: number2().optional(),
138581
+ recalculated: number2().optional(),
138582
+ cleared: number2().optional()
138583
+ };
138584
+ outputSchema = swarmToolOutputSchema(dataShape);
138585
+ WRITE = { readOnlyHint: false, idempotentHint: false };
138586
+ });
138587
+
136102
138588
  // src/tools/skills/skill-create.ts
136103
138589
  var registerSkillCreateTool = (server) => {
136104
138590
  createToolRegistrar(server)("skill-create", {
@@ -138411,14 +140897,21 @@ var AUTO_DOWNLOAD_DIR = "/app/shared/downloads/slack", USERS_INFO_CONCURRENCY =
138411
140897
  channelId: string2().optional().describe("Slack channel ID to read from (requires lead privileges). A user ID (U…/W…) reads the bot's DM with that user."),
138412
140898
  threadTs: string2().optional().describe("Thread timestamp (required with channelId for thread history)."),
138413
140899
  limit: number2().int().min(1).max(100).default(20).describe("Maximum number of messages to retrieve (default: 20, max: 100)."),
138414
- includeFiles: boolean().default(true).describe("Include file attachments in the response (default: true). From a task, they are also stored as attachments of that task.")
140900
+ includeFiles: boolean().optional().describe("Include and download file attachments. Defaults to false for direct channelId reads, and true for taskId or inboxMessageId reads. From a task, files are also stored as attachments of that task.")
138415
140901
  }),
138416
140902
  outputSchema: swarmToolOutputSchema({
138417
140903
  channelId: string2().optional(),
138418
140904
  threadTs: string2().optional(),
138419
140905
  messages: array2(SlackMessageSchema).optional()
138420
140906
  })
138421
- }, async ({ inboxMessageId, taskId, channelId, threadTs, limit = 20, includeFiles = true }, requestInfo, _meta) => {
140907
+ }, async ({
140908
+ inboxMessageId,
140909
+ taskId,
140910
+ channelId,
140911
+ threadTs,
140912
+ limit = 20,
140913
+ includeFiles = Boolean(inboxMessageId || taskId)
140914
+ }, requestInfo, _meta) => {
138422
140915
  if (!requestInfo.agentId) {
138423
140916
  return toolErr("Agent ID not found.", { data: { messages: [] } });
138424
140917
  }
@@ -139528,7 +142021,7 @@ async function readScriptActionAllowlist() {
139528
142021
  const [row] = await getSwarmConfigs2({ scope: "global", key: UI_SPEC_SCRIPT_ACTIONS_KEY });
139529
142022
  if (row)
139530
142023
  return row.value;
139531
- const { getDeploymentEnvValue } = await import("./core-df1n049h.js");
142024
+ const { getDeploymentEnvValue } = await import("./core-dxcy02sc.js");
139532
142025
  return getDeploymentEnvValue(UI_SPEC_SCRIPT_ACTIONS_KEY);
139533
142026
  }
139534
142027
  async function loadScriptActionLookups() {
@@ -141415,7 +143908,7 @@ async function emitBudgetRefusalSideEffects(ctx, inserted) {
141415
143908
  console.warn(`[budget-refusal-notify] Failed to create follow-up task for budget refusal (task=${ctx.task.id.slice(0, 8)}): ${err}`);
141416
143909
  }
141417
143910
  }
141418
- import("./event-bus-swr88jg5.js").then(({ workflowEventBus }) => {
143911
+ import("./event-bus-v4ywhc2p.js").then(({ workflowEventBus }) => {
141419
143912
  workflowEventBus.emit("task.budget_refused", {
141420
143913
  taskId: ctx.task.id,
141421
143914
  agentId: ctx.agentId,
@@ -142423,7 +144916,7 @@ async function sendAndFormat(params, agentId, contextMessageId) {
142423
144916
  return toolErr(errorMessage, { data: { yourAgentId: agentId } });
142424
144917
  }
142425
144918
  }
142426
- var SESSION_WINDOW_HINT = 'Outside the 24h WhatsApp session window — free-form text is rejected. Use a pre-approved template message (see the `kapso-whatsapp` skill, "Send a template").', outputSchema, registerSendWhatsappMessageTool = (server) => {
144919
+ var SESSION_WINDOW_HINT = 'Outside the 24h WhatsApp session window — free-form text is rejected. Use a pre-approved template message (see the `kapso-whatsapp` skill, "Send a template").', outputSchema2, registerSendWhatsappMessageTool = (server) => {
142427
144920
  createToolRegistrar(server)("send-whatsapp-message", {
142428
144921
  title: "Send WhatsApp Message",
142429
144922
  annotations: { openWorldHint: true },
@@ -142434,7 +144927,7 @@ var SESSION_WINDOW_HINT = 'Outside the 24h WhatsApp session window — free-form
142434
144927
  body: string2().min(1).describe("Message text."),
142435
144928
  previewUrl: boolean().optional().describe("Render a link preview for URLs in the body (default false).")
142436
144929
  }),
142437
- outputSchema
144930
+ outputSchema: outputSchema2
142438
144931
  }, async ({ phoneNumberId, to, body, previewUrl }, requestInfo) => {
142439
144932
  return sendAndFormat({ phoneNumberId, to, body, previewUrl }, requestInfo.agentId, undefined);
142440
144933
  });
@@ -142449,7 +144942,7 @@ var SESSION_WINDOW_HINT = 'Outside the 24h WhatsApp session window — free-form
142449
144942
  inReplyTo: string2().min(1).describe("The inbound WAMID to quote-reply (set as context.message_id)."),
142450
144943
  body: string2().min(1).describe("Reply text.")
142451
144944
  }),
142452
- outputSchema
144945
+ outputSchema: outputSchema2
142453
144946
  }, async ({ phoneNumberId, to, inReplyTo, body }, requestInfo) => {
142454
144947
  return sendAndFormat({ phoneNumberId, to, body }, requestInfo.agentId, inReplyTo);
142455
144948
  });
@@ -142459,7 +144952,7 @@ var init_whatsapp_message = __esm(() => {
142459
144952
  init_client();
142460
144953
  init_config2();
142461
144954
  init_utils();
142462
- outputSchema = swarmToolOutputSchema({
144955
+ outputSchema2 = swarmToolOutputSchema({
142463
144956
  yourAgentId: string2().optional(),
142464
144957
  messageId: string2().optional(),
142465
144958
  sessionWindowExpired: boolean().optional()
@@ -142567,7 +145060,7 @@ var registerCreateWorkflowTool = (server) => {
142567
145060
  definition: WorkflowDefinitionSchema.describe("The workflow definition with nodes (each node has id, type, config, and optional next/retry/validation)"),
142568
145061
  triggers: array2(TriggerConfigSchema).optional().describe("Optional trigger configurations (webhook, schedule, event). A webhook trigger accepts filter (headers and body allowlists) and preset (github, gitlab, standard-webhooks). events and eventHeader remain a deprecated alias of one filter clause. Verification formats: legacy omitted verification, hmac-sha256, timestamped-hmac-sha256, token-equality, standard-webhooks."),
142569
145062
  cooldown: CooldownConfigSchema.optional().describe("Optional cooldown configuration to prevent re-triggering too frequently"),
142570
- input: record2(string2(), InputValueSchema).optional().describe("Optional input values resolved at execution time (env vars like VAR_NAME, secrets secret.NAME, or literals)"),
145063
+ input: record2(string2(), InputValueSchema).optional().describe("Optional input values resolved at execution time (env vars like VAR_NAME, secrets secret.NAME, or literals). Env var and secret references require config.read.secrets (the lead agent)."),
142571
145064
  dir: string2().min(1).startsWith("/").optional().describe("Default working directory for all agent-task nodes (absolute path, e.g. /tmp/workspace)"),
142572
145065
  vcsRepo: string2().min(1).optional().describe("Default VCS repo for all agent-task nodes (e.g. org/repo)"),
142573
145066
  triggerSchema: record2(string2(), unknown()).optional().describe("Optional JSON-Schema object that validates incoming trigger payloads. " + "Supported keywords: type, required, properties, enum, const, items. " + "Other JSON-Schema keywords are silently ignored.")
@@ -142601,6 +145094,10 @@ var registerCreateWorkflowTool = (server) => {
142601
145094
  if (modelErrors.length > 0) {
142602
145095
  return toolErr(`Invalid definition: ${modelErrors.join("; ")}`);
142603
145096
  }
145097
+ const refKeys = serverRefInputKeys(input);
145098
+ if (refKeys.length > 0 && !await agentMaySetServerRefInput(requestInfo.agentId)) {
145099
+ return toolErr(serverRefInputDeniedMessage(refKeys));
145100
+ }
142604
145101
  const createdBy = await resolveTaskAuditUserId(requestInfo.sourceTaskId, requestInfo.agentId) ?? undefined;
142605
145102
  const assetKey = key ? await authorizeAssetKeyWrite(key, createdBy) : undefined;
142606
145103
  const workflow = await createWorkflow2({
@@ -142642,6 +145139,7 @@ var init_create_workflow = __esm(() => {
142642
145139
  init_types5();
142643
145140
  init_workflows();
142644
145141
  init_definition2();
145142
+ init_input();
142645
145143
  init_model_validation();
142646
145144
  init_readiness();
142647
145145
  });
@@ -142899,6 +145397,12 @@ async function patchWorkflowDefinition(options) {
142899
145397
  const existing = await getWorkflow2(id);
142900
145398
  if (!existing)
142901
145399
  return { ok: false, reason: "not_found" };
145400
+ if (options.serverRefInputAllowed === false) {
145401
+ const refKeys = serverRefInputKeys(existing.input);
145402
+ if (refKeys.length > 0) {
145403
+ return { ok: false, reason: "forbidden", errors: [serverRefInputDeniedMessage(refKeys)] };
145404
+ }
145405
+ }
142902
145406
  const patchResult = applyDefinitionPatch(existing.definition, patch);
142903
145407
  if (patchResult.errors.length > 0) {
142904
145408
  return { ok: false, reason: "patch", errors: patchResult.errors };
@@ -142932,6 +145436,7 @@ async function patchWorkflowDefinition(options) {
142932
145436
  var init_patch_definition = __esm(() => {
142933
145437
  init_db4();
142934
145438
  init_definition2();
145439
+ init_input();
142935
145440
  init_model_validation();
142936
145441
  init_version();
142937
145442
  });
@@ -142992,6 +145497,7 @@ var registerPatchWorkflowTool = (server) => {
142992
145497
  },
142993
145498
  registry: getExecutorRegistry2(),
142994
145499
  snapshotAgentId: requestInfo.agentId,
145500
+ serverRefInputAllowed: !!requestInfo.agentId && await agentMaySetServerRefInput(requestInfo.agentId),
142995
145501
  updates
142996
145502
  });
142997
145503
  if (!result.ok) {
@@ -143000,6 +145506,8 @@ var registerPatchWorkflowTool = (server) => {
143000
145506
  if (result.reason === "patch") {
143001
145507
  return toolErr(`Patch errors: ${result.errors.join("; ")}`);
143002
145508
  }
145509
+ if (result.reason === "forbidden")
145510
+ return toolErr(result.errors.join("; "));
143003
145511
  return toolErr(`Invalid definition: ${result.errors.join("; ")}`);
143004
145512
  }
143005
145513
  const { workflow, version } = result;
@@ -143037,6 +145545,7 @@ var init_patch_workflow = __esm(() => {
143037
145545
  init_utils();
143038
145546
  init_types5();
143039
145547
  init_workflows();
145548
+ init_input();
143040
145549
  init_patch_definition();
143041
145550
  init_readiness();
143042
145551
  });
@@ -143065,6 +145574,7 @@ var registerPatchWorkflowNodeTool = (server) => {
143065
145574
  patch: { update: [{ nodeId, node: nodeFields }] },
143066
145575
  registry: getExecutorRegistry2(),
143067
145576
  snapshotAgentId: requestInfo.agentId,
145577
+ serverRefInputAllowed: !!requestInfo.agentId && await agentMaySetServerRefInput(requestInfo.agentId),
143068
145578
  updates: updatedBy !== undefined ? { updatedBy } : {}
143069
145579
  });
143070
145580
  if (!result.ok) {
@@ -143073,6 +145583,8 @@ var registerPatchWorkflowNodeTool = (server) => {
143073
145583
  if (result.reason === "patch") {
143074
145584
  return toolErr(`Patch errors: ${result.errors.join("; ")}`);
143075
145585
  }
145586
+ if (result.reason === "forbidden")
145587
+ return toolErr(result.errors.join("; "));
143076
145588
  return toolErr(`Invalid definition: ${result.errors.join("; ")}`);
143077
145589
  }
143078
145590
  const { workflow, version } = result;
@@ -143101,6 +145613,7 @@ var init_patch_workflow_node = __esm(() => {
143101
145613
  init_utils();
143102
145614
  init_types5();
143103
145615
  init_workflows();
145616
+ init_input();
143104
145617
  init_patch_definition();
143105
145618
  init_readiness();
143106
145619
  });
@@ -143387,6 +145900,10 @@ var registerUpdateWorkflowTool = (server) => {
143387
145900
  return toolErr(`Invalid definition: ${modelErrors.join("; ")}`);
143388
145901
  }
143389
145902
  }
145903
+ const refKeys = serverRefInputKeys(input !== undefined ? input : definition ? existing.input : undefined);
145904
+ if (refKeys.length > 0 && !(requestInfo.agentId && await agentMaySetServerRefInput(requestInfo.agentId))) {
145905
+ return toolErr(serverRefInputDeniedMessage(refKeys));
145906
+ }
143390
145907
  const updatedBy = await resolveTaskAuditUserId(requestInfo.sourceTaskId, requestInfo.agentId) ?? undefined;
143391
145908
  const assetKey = key === undefined ? undefined : await authorizeAssetKeyWrite(key, updatedBy);
143392
145909
  const { workflow, version } = await snapshotAndUpdateWorkflow(id, {
@@ -143431,6 +145948,7 @@ var init_update_workflow = __esm(() => {
143431
145948
  init_types5();
143432
145949
  init_workflows();
143433
145950
  init_definition2();
145951
+ init_input();
143434
145952
  init_model_validation();
143435
145953
  init_readiness();
143436
145954
  init_version();
@@ -143725,6 +146243,26 @@ async function createServer(opts = {}) {
143725
146243
  registerRoomResetTool(server);
143726
146244
  registerRoomDecodeTool(server);
143727
146245
  }
146246
+ if (hasCapability("primitives")) {
146247
+ registerObjectCreateTool(server);
146248
+ registerObjectGetTool(server);
146249
+ registerObjectListTool(server);
146250
+ registerObjectReindexTool(server);
146251
+ registerSheetCreateTool(server);
146252
+ registerSheetGetTool(server);
146253
+ registerSheetListTool(server);
146254
+ registerSheetGetRangeTool(server);
146255
+ registerSheetSetRangeTool(server);
146256
+ registerSheetAppendRowsTool(server);
146257
+ registerSheetClearRangeTool(server);
146258
+ registerSheetAddTabTool(server);
146259
+ registerBoardCreateTool(server);
146260
+ registerBoardGetTool(server);
146261
+ registerBoardListTool(server);
146262
+ registerBoardAddElementsTool(server);
146263
+ registerBoardUpdateElementsTool(server);
146264
+ registerBoardRemoveElementsTool(server);
146265
+ }
143728
146266
  if (hasCapability("slack")) {
143729
146267
  registerSlackReplyTool(server);
143730
146268
  registerSlackReadTool(server);
@@ -143811,6 +146349,7 @@ var init_server = __esm(() => {
143811
146349
  init_app_rows();
143812
146350
  init_app_sync();
143813
146351
  init_app_upsert();
146352
+ init_boards();
143814
146353
  init_cancel_approval_request();
143815
146354
  init_cancel_task();
143816
146355
  init_chat_open_dm();
@@ -143855,6 +146394,7 @@ var init_server = __esm(() => {
143855
146394
  init_list_model_profiles();
143856
146395
  init_my_agent_info();
143857
146396
  init_oauth_access_token();
146397
+ init_objects2();
143858
146398
  init_poll_task();
143859
146399
  init_post_message();
143860
146400
  init_prompt_templates();
@@ -143882,6 +146422,7 @@ var init_server = __esm(() => {
143882
146422
  init_script_search();
143883
146423
  init_script_upsert();
143884
146424
  init_send_task();
146425
+ init_sheets();
143885
146426
  init_skills();
143886
146427
  init_slack_archive_channel();
143887
146428
  init_slack_create_channel();
@@ -143932,7 +146473,8 @@ var init_server = __esm(() => {
143932
146473
  "agentmail",
143933
146474
  "kapso",
143934
146475
  "chat-sdk",
143935
- "swarm-x"
146476
+ "swarm-x",
146477
+ "primitives"
143936
146478
  ];
143937
146479
  DEFAULT_CAPABILITIES = [
143938
146480
  "core",
@@ -143956,4 +146498,4 @@ var init_server = __esm(() => {
143956
146498
  loggedToolAllowlistWarnings = new Set;
143957
146499
  });
143958
146500
 
143959
- export { safeParse, getObjectShape, getLiteralValue, init_zod_compat, LATEST_PROTOCOL_VERSION, DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, isJSONRPCRequest, isJSONRPCResultResponse, ErrorCode, isJSONRPCErrorResponse, JSONRPCMessageSchema, EmptyResultSchema, isInitializeRequest, InitializeResultSchema, CreateTaskResultSchema, ListResourcesResultSchema, ListResourceTemplatesResultSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, ListPromptsResultSchema, GetPromptResultSchema, PromptListChangedNotificationSchema, ListToolsResultSchema, CallToolResultSchema, ToolListChangedNotificationSchema, ListChangedOptionsBaseSchema, CreateMessageRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, ElicitRequestSchema, ElicitResultSchema, CompleteResultSchema, McpError, init_types, Protocol, mergeCapabilities, init_protocol, AjvJsonSchemaValidator, init_ajv_provider, assertToolsCallTaskCapability, assertClientRequestTaskCapability, init_helpers, McpServer, init_mcp, referencedBundlePaths, skillDirs, init_manifest_format, recoverIncompleteRuns, init_recovery, handleWebhookTrigger, verifyHmacSignature, WebhookError, init_triggers, snapshotAndUpdateWorkflow, init_version, applyPreTaskCreate, init_apply_task_create, RawLlmConfigSchema, RawLlmOutputSchema, executeRawLlm, init_raw_llm, getExecutorRegistry2, initWorkflows2, init_workflows, stripSiblingBlock, init_sibling_block, createTaskWithSiblingAwareness, init_sibling_awareness, dispatchScheduleTarget, calculateNextRun2, startScheduler2, stopScheduler2, runScheduleNow2, init_scheduler, ExtensionAssetConflictError, hashOf, scriptHash, liveScriptSpec, liveWorkflowSpec, skillSpecOf, liveSkillSpec, skillHash, init_assets, ExtensionOwnershipError, getExtensionFiles, getExtensionById, getExtensionByName, listExtensions, listExtensionVersions, updateExtensionMeta, listExtensionRuns, init_db, SDK_ALLOWLIST, mcpToolNameForSdkMethod, init_sdk_allowlist, MCP_OVERFLOW_NAMESPACE, mcpOverflowAuthError, init_kv_overflow, hasKvViewArgs, resolveKvView, init_kv_view, COLOR_LITERAL_THRESHOLD, countColorLiterals, init_color_literals, toolErr, createToolRegistrar, init_utils, handleMcpBridge, init_mcp_bridge, Redacted, init_redacted, SCRIPT_SDK_RESPONSE_LIMIT_BYTES, readScriptSdkJsonResponse, init_response_limit, retry, init_retry, ExtensionConfigError, init_loader, ExtensionLifecycleError, setExtensionLoopbackBaseUrl, enableExtension, disableExtension, activateVersion, ExtensionAssetsInvalidError, installExtensionWithAssets, uninstallExtension, reloadExtension, loadEnabledExtensions, stopExtensionRuntime, init_lifecycle, ExtensionAbortedError2, isRegistered2, isExtensionAgentId2, getExtensionBridgeToken2, resolveBridgeCallOrigin2, extensionIdForAgent2, runContext2, registerLoaded2, unregister2, listRegistered2, dispatchPre2, dispatchPost2, init_dispatcher, resolveIdentity, renderIdentity, init_identity, recordUnmappedIdentity, init_unmapped_identities, getDeliveredSlackMessageTs, foldIntoPendingSlackTask, init_slack_fold, MAX_TASK_ATTACHMENT_BYTES, recordTaskAttachmentUpload, scopeFromAttachment, backingProviderId, init_task_attachment_store, transcribeAudioNotes, init_transcription, init_templates, buildEffectiveText, bufferedFileFailures, fetchSlackFiles, createSlackTaskWithFiles, attachSlackFilesToDraft, notifySlackFileFailures, init_inbound_files, pendingWorkForAgent, countPoolRuntimes, computeDesired, init_demand, isRuntimePoolWakeable, isAgentReachable, isAgentOnDemand, init_reachability, isAddressedToOtherUser, broadcastMatches, routeMessage, extractTaskFromMessage, init_router, extractSlackMessageText, slackInboundMessageText, collectSlackMessageFiles, init_message_text, createAdditiveBuffer, init_additive_buffer, isAgentMailEnabled, initAgentMail, verifyAgentMailWebhook, isInboxAllowed, isSenderAllowed, handleMessageReceived, init_agentmail, isAzureDevOpsEnabled, initAzureDevOps, verifyAzureDevOpsWebhook, repointTrackerSyncBySwarmId, init_tracker, isAzureDevOpsUrl, canonicalAzureDevOpsRepoUrl, parseAzureDevOpsRepoUrl, init_azure_devops, createdPullRequestOf, commentedPayloadOf, handlePullRequestCreated, handlePullRequestCommented, handleWorkItemCreated, handleWorkItemUpdated, handleWorkItemCommented, handleWorkItemDeleted, handleWorkItemRestored, initAzureDevOpsOutbound, init_azure_devops2, enqueueAuditRow, enqueueAdmissionRow, flushAuditBuffer, startAuditWriter, stopAuditWriter, startAuditGc, stopAuditGc, init_rbac_audit, getTelemetryIngestAnchor, init_telemetry_ingest_anchor, initApiTelemetry, syncTelemetryEnabled, init_telemetry_enable, isBitbucketEnabled, initBitbucket, verifyBitbucketWebhook, isDuplicateDelivery, markDeliveryProcessed, pullRequestEventOf, pullRequestCommentEventOf, handlePullRequestCreated2, handlePullRequestCommentCreated, handlePullRequestClosed, init_bitbucket, isGitHubEnabled, initGitHub, verifyWebhookSignature, getWorkerInstallationToken, init_app, handlePullRequest, handleIssue, handleComment, handlePullRequestReview, handleCheckRun, handleCheckSuite, handleWorkflowRun, init_github, isGitLabEnabled, initGitLab, verifyGitLabWebhook, handleMergeRequest, handleIssue2, handleNote, handlePipeline, init_gitlab, isChatSdkEnabled, getChatSdkConfig, init_config, errorMessage, init_logger, resolveAdapterApiUrl, init_adapters, trackBackground, init_background, TelegramBotApiError, callTelegramBotApi, init_telegram_api, isTrustedTeamsServiceUrl, init_teams_origin, getSessionLabels, rememberSessionLabel, getResourceSessionLabels, init_session_labels, isChatSdkStopping, startChatSdk, getChatInstance, isChatAdapterConfigured, getChatSdkHealth, stopChatSdk, init_runtime, getJiraMetadata, updateJiraMetadata, clearJiraMetadata, init_metadata, registerJiraWebhook, deleteJiraWebhook, init_webhook_lifecycle, isJiraEnabled, initJira, init_app2, handleJiraWebhook, init_webhook, init_jira, handleAgentSessionEvent, handleIssueUpdate, handleIssueDelete, handleAgentSessionPrompted, init_sync, isLinearEnabled, initLinear, init_app3, init_linear, init_slack, verifyPageSession, LEGACY_PAGE_SESSION_COOKIE, isCookieSafePageId, extractPageSession, extractLegacyPageSession, extractAndVerifyCookie, isLocalDevPageRequest, pageSessionSetCookies, init_page_session, resolveHttpRequestAuth, init_auth, getDeploymentEnvValue2, loadGlobalConfigsIntoEnv2, reloadGlobalConfigsAndIntegrations2, scheduleIntegrationsReload2, handleCore2, init_core, runTaskUiScriptAction, init_script_actions, REBOOT_RETRY_PIN_TAG2, getPinCandidateAgent2, resolveLeadOnlyRecoveryAssignment2, getResumeGeneration2, getNextResumeGeneration2, inheritedModelSelection2, nextFallback2, createWorkerTaskFollowUp2, createResumeFollowUp2, createRerouteDecisionTask2, createPoolStarvationDecisionTask2, init_worker_follow_up, MCP_MAX_TOOL_INPUT_ELEMENTS, MCP_MAX_REQUEST_BODY_BYTES, init_mcp_limits, userCtx, init_task_tool_ctx, resolveRequestPrincipal, requestPrincipal, agentFirstPrincipal, requireAuthKind, rejectGuest, init_request_principal, resolveTaskRequester, init_task_requester, handleApps, init_apps, cancelApprovalRequest, cancelApprovalRequestAndRun, init_approval_cancel, getUserCommsPrefs, init_requester_comms, getTaskDetailsInputSchema, getTaskDetailsOutputSchema, getTaskDetailsHandler, init_get_task_details, cancelTaskInputSchema, cancelTaskOutputSchema, cancelTaskHandler, init_cancel_task, DbQueryTimeoutError, DbQueryConcurrencyCapError, executeReadOnlyQuery, getDbQueryHttpBudgetMs, init_db_query_shared, assertSelectOnlyQuery, executeReadOnlyQueryGated, handleDbQuery, init_db_query, snapshotMetric, init_version2, AssetKeyAuthorizationError, authorizeAssetKeyWrite, init_asset_key_auth, getPageEditCounter, init_page_versions, snapshotPage, init_version3, DEFAULT_THEME_ID, THEME_PRESET_IDS, getThemePreset, init_presets, readThemeFields, init_page_fields, assertOAuthAppUrlsSafe, assertOAuthEgressUrlSafe, init_app_validation, listOAuthPresets, listOAuthPresetIds, getOAuthPreset, hydrateOAuthAppFromPreset, init_presets2, scopedResourceScopeIdSchema, resolveScopedResourceId, init_scoped_resource, MemoryKeyError, init_key_guard, refreshLinks, init_link_resolver, indexMemoryContent, init_index_content, dedupeMemoryDocumentIds, recordMemoryAccesses, recordRetrievals, init_retrieval, ExplicitSelfDuplicateError, applyRating, init_store, shouldPersistAutomaticTaskMemory, init_automatic_task_gate, guardTerminalTaskResultWrite, init_terminal_result_guard, getTasksInputSchema, getTasksOutputSchema, getTasksHandler, init_get_tasks, requiresLeadToWrite, reservedNamespaceError, privateNamespaceError, reservedRoomKeyError, init_kv_reserved_namespaces, updateMcpServerChecked, init_mcp_server_checked_update, updateTouchesStdioExecution, init_mcp_server_stdio_gate, canReadMemory, init_access, getLinksForMemory, init_links_store, attachDemotionEvidence, init_demotion_evidence, expandCandidatesWithGraph, init_graph_expansion, isApiDraining, drainApi, init_api_drain, markKapsoMessageRead, sendKapsoReaction, init_client, getKapsoConfig, getKapsoNumberMapping, markKapsoMessageSeen, init_config2, changesAllowMerge, init_repo_merge_policy, updateSwarmRepoChecked, init_repo_checked_update, getCombConfig, init_config3, resolveRoomNamespace, roomRequestInfo, authorizeRoomNamespace, sessionAccessTopic, sessionPresenceRoot, init_auth2, RoomOperationSchema, init_document, removeAwarenessStates, init_awareness, roomTopic, decodeRoomSnapshot, roomView, getRoom, changeRoom, applyRoomUpdate, resetRoom, sweepRooms, closeRooms, removeNamespaceRooms, init_rooms, init_scheduler2, MEMORY_KEYS_DEFAULT_PREFIX, MEMORY_KEYS_MAX_LIMIT, estimateTokens, posteriorMean, listMemoryKeys, checkChunkIntegrity, getMemoryChunks, getPosteriorsByIds, init_key_browser, createEvent, createEventsBatch, getEventCountsFiltered, getEventsFiltered, init_events, mergeScheduleTiming, validateRecurringTiming, init_validate, followUpThreadForSourceTask, evaluateFollowUpRedelegation, init_follow_up_redelegation_guard, checkOutputSchemaShape, sendTaskOutputSchema, sendTaskHandler, init_send_task, steerTaskUserInputSchema, steerTaskOutputSchema, steerTaskHandler, init_steer_task, skipReasonFrom, finalizeSkippedTaskReaction, init_task_skip, IMPROVEMENT_TEXT_MAX, IMPROVEMENT_STATUSES, IMPROVEMENT_SOURCES, ImprovementError, isImprovementsEnabled, getImprovement, listImprovements, createImprovement, approveAndSend, discardImprovement, improvementLeakHints, init_improvements, recomputeSessionCost, init_session_cost_recompute, canClaim, init_budget_admission, emitBudgetRefusalSideEffects, init_budget_refusal_notify, workflowModelErrors, init_model_validation, patchWorkflowDefinition, init_patch_definition, idempotencyKeyHeader, readIdempotencyKey, replayAcceptedOperation, init_idempotency_key, resolveScriptsOnlyMode, init_scripts_only_mode, ALL_CAPABILITIES, hasCapability, getEnabledCapabilities, createServer, init_server };
146501
+ export { safeParse, getObjectShape, getLiteralValue, init_zod_compat, LATEST_PROTOCOL_VERSION, DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, isJSONRPCRequest, isJSONRPCResultResponse, ErrorCode, isJSONRPCErrorResponse, JSONRPCMessageSchema, EmptyResultSchema, isInitializeRequest, InitializeResultSchema, CreateTaskResultSchema, ListResourcesResultSchema, ListResourceTemplatesResultSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, ListPromptsResultSchema, GetPromptResultSchema, PromptListChangedNotificationSchema, ListToolsResultSchema, CallToolResultSchema, ToolListChangedNotificationSchema, ListChangedOptionsBaseSchema, CreateMessageRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, ElicitRequestSchema, ElicitResultSchema, CompleteResultSchema, McpError, init_types, Protocol, mergeCapabilities, init_protocol, AjvJsonSchemaValidator, init_ajv_provider, assertToolsCallTaskCapability, assertClientRequestTaskCapability, init_helpers, McpServer, init_mcp, referencedBundlePaths, skillDirs, init_manifest_format, recoverIncompleteRuns, init_recovery, handleWebhookTrigger, verifyHmacSignature, decodeStandardWebhookSecret, verifyStandardWebhookSignature, verifyTokenEquality, WebhookError, init_triggers, snapshotAndUpdateWorkflow, init_version, applyPreTaskCreate, init_apply_task_create, RawLlmConfigSchema, RawLlmOutputSchema, executeRawLlm, init_raw_llm, getExecutorRegistry2, initWorkflows2, init_workflows, stripSiblingBlock, init_sibling_block, createTaskWithSiblingAwareness, init_sibling_awareness, dispatchScheduleTarget, calculateNextRun2, startScheduler2, stopScheduler2, runScheduleNow2, init_scheduler, ExtensionAssetConflictError, hashOf, scriptHash, liveScriptSpec, liveWorkflowSpec, skillSpecOf, liveSkillSpec, skillHash, init_assets, ExtensionOwnershipError, getExtensionFiles, getExtensionById, getExtensionByName, listExtensions, listExtensionVersions, updateExtensionMeta, listExtensionRuns, init_db, SDK_ALLOWLIST, mcpToolNameForSdkMethod, init_sdk_allowlist, MCP_OVERFLOW_NAMESPACE, mcpOverflowAuthError, init_kv_overflow, hasKvViewArgs, resolveKvView, init_kv_view, COLOR_LITERAL_THRESHOLD, countColorLiterals, init_color_literals, toolErr, createToolRegistrar, init_utils, handleMcpBridge, init_mcp_bridge, Redacted, init_redacted, SCRIPT_SDK_RESPONSE_LIMIT_BYTES, readScriptSdkJsonResponse, init_response_limit, retry, init_retry, ExtensionConfigError, init_loader, ExtensionLifecycleError, setExtensionLoopbackBaseUrl, enableExtension, disableExtension, activateVersion, ExtensionAssetsInvalidError, installExtensionWithAssets, uninstallExtension, reloadExtension, loadEnabledExtensions, stopExtensionRuntime, init_lifecycle, ExtensionAbortedError2, isRegistered2, isExtensionAgentId2, getExtensionBridgeToken2, resolveBridgeCallOrigin2, extensionIdForAgent2, runContext2, registerLoaded2, unregister2, listRegistered2, dispatchPre2, dispatchPost2, init_dispatcher, resolveIdentity, renderIdentity, init_identity, recordUnmappedIdentity, init_unmapped_identities, getDeliveredSlackMessageTs, foldIntoPendingSlackTask, init_slack_fold, MAX_TASK_ATTACHMENT_BYTES, recordTaskAttachmentUpload, scopeFromAttachment, backingProviderId, init_task_attachment_store, transcribeAudioNotes, init_transcription, init_templates, buildEffectiveText, bufferedFileFailures, fetchSlackFiles, createSlackTaskWithFiles, attachSlackFilesToDraft, notifySlackFileFailures, init_inbound_files, pendingWorkForAgent, countPoolRuntimes, computeDesired, init_demand, isRuntimePoolWakeable, isAgentReachable, isAgentOnDemand, init_reachability, isAddressedToOtherUser, broadcastMatches, routeMessage, extractTaskFromMessage, init_router, extractSlackMessageText, slackInboundMessageText, collectSlackMessageFiles, init_message_text, createAdditiveBuffer, init_additive_buffer, isAgentMailEnabled, initAgentMail, verifyAgentMailWebhook, isInboxAllowed, isSenderAllowed, handleMessageReceived, init_agentmail, isAzureDevOpsEnabled, initAzureDevOps, verifyAzureDevOpsWebhook, repointTrackerSyncBySwarmId, init_tracker, isAzureDevOpsUrl, canonicalAzureDevOpsRepoUrl, parseAzureDevOpsRepoUrl, init_azure_devops, createdPullRequestOf, commentedPayloadOf, handlePullRequestCreated, handlePullRequestCommented, handleWorkItemCreated, handleWorkItemUpdated, handleWorkItemCommented, handleWorkItemDeleted, handleWorkItemRestored, initAzureDevOpsOutbound, init_azure_devops2, enqueueAuditRow, enqueueAdmissionRow, flushAuditBuffer, startAuditWriter, stopAuditWriter, startAuditGc, stopAuditGc, init_rbac_audit, getTelemetryIngestAnchor, init_telemetry_ingest_anchor, initApiTelemetry, syncTelemetryEnabled, init_telemetry_enable, isBitbucketEnabled, initBitbucket, verifyBitbucketWebhook, isDuplicateDelivery, markDeliveryProcessed, pullRequestEventOf, pullRequestCommentEventOf, handlePullRequestCreated2, handlePullRequestCommentCreated, handlePullRequestClosed, init_bitbucket, isGitHubEnabled, initGitHub, verifyWebhookSignature, getWorkerInstallationToken, init_app, handlePullRequest, handleIssue, handleComment, handlePullRequestReview, handleCheckRun, handleCheckSuite, handleWorkflowRun, init_github, isGitLabEnabled, initGitLab, verifyGitLabWebhook, handleMergeRequest, handleIssue2, handleNote, handlePipeline, init_gitlab, isChatSdkEnabled, getChatSdkConfig, init_config, errorMessage, init_logger, resolveAdapterApiUrl, init_adapters, trackBackground, init_background, TelegramBotApiError, callTelegramBotApi, init_telegram_api, isTrustedTeamsServiceUrl, init_teams_origin, getSessionLabels, rememberSessionLabel, getResourceSessionLabels, init_session_labels, isChatSdkStopping, startChatSdk, getChatInstance, isChatAdapterConfigured, getChatSdkHealth, stopChatSdk, init_runtime, getJiraMetadata, updateJiraMetadata, clearJiraMetadata, init_metadata, registerJiraWebhook, deleteJiraWebhook, init_webhook_lifecycle, isJiraEnabled, initJira, init_app2, handleJiraWebhook, init_webhook, init_jira, handleAgentSessionEvent, handleIssueUpdate, handleIssueDelete, handleAgentSessionPrompted, init_sync, isLinearEnabled, initLinear, init_app3, init_linear, init_slack, verifyPageSession, LEGACY_PAGE_SESSION_COOKIE, isCookieSafePageId, extractPageSession, extractLegacyPageSession, extractAndVerifyCookie, isLocalDevPageRequest, pageSessionSetCookies, init_page_session, resolveHttpRequestAuth, init_auth, getDeploymentEnvValue2, loadGlobalConfigsIntoEnv2, reloadGlobalConfigsAndIntegrations2, scheduleIntegrationsReload2, handleCore2, init_core, runTaskUiScriptAction, init_script_actions, REBOOT_RETRY_PIN_TAG2, getPinCandidateAgent2, resolveLeadOnlyRecoveryAssignment2, getResumeGeneration2, getNextResumeGeneration2, inheritedModelSelection2, nextFallback2, createWorkerTaskFollowUp2, createResumeFollowUp2, createRerouteDecisionTask2, createPoolStarvationDecisionTask2, init_worker_follow_up, MCP_MAX_TOOL_INPUT_ELEMENTS, MCP_MAX_REQUEST_BODY_BYTES, init_mcp_limits, userCtx, init_task_tool_ctx, resolveRequestPrincipal, requestPrincipal, agentFirstPrincipal, requireAuthKind, rejectGuest, init_request_principal, resolveTaskRequester, init_task_requester, handleApps, init_apps, cancelApprovalRequest, cancelApprovalRequestAndRun, init_approval_cancel, getUserCommsPrefs, init_requester_comms, getTaskDetailsInputSchema, getTaskDetailsOutputSchema, getTaskDetailsHandler, init_get_task_details, cancelTaskInputSchema, cancelTaskOutputSchema, cancelTaskHandler, init_cancel_task, DbQueryTimeoutError, DbQueryConcurrencyCapError, executeReadOnlyQuery, getDbQueryHttpBudgetMs, init_db_query_shared, assertSelectOnlyQuery, executeReadOnlyQueryGated, handleDbQuery, init_db_query, snapshotMetric, init_version2, AssetKeyAuthorizationError, authorizeAssetKeyWrite, init_asset_key_auth, getPageEditCounter, init_page_versions, snapshotPage, init_version3, DEFAULT_THEME_ID, THEME_PRESET_IDS, getThemePreset, init_presets, readThemeFields, init_page_fields, assertOAuthAppUrlsSafe, assertOAuthEgressUrlSafe, init_app_validation, listOAuthPresets, listOAuthPresetIds, getOAuthPreset, hydrateOAuthAppFromPreset, init_presets2, scopedResourceScopeIdSchema, resolveScopedResourceId, init_scoped_resource, MemoryKeyError, init_key_guard, refreshLinks, init_link_resolver, indexMemoryContent, init_index_content, dedupeMemoryDocumentIds, recordMemoryAccesses, recordRetrievals, init_retrieval, ExplicitSelfDuplicateError, applyRating, init_store, shouldPersistAutomaticTaskMemory, init_automatic_task_gate, guardTerminalTaskResultWrite, init_terminal_result_guard, getTasksInputSchema, getTasksOutputSchema, getTasksHandler, init_get_tasks, requiresLeadToWrite, reservedNamespaceError, privateNamespaceError, reservedRoomKeyError, init_kv_reserved_namespaces, updateMcpServerChecked, init_mcp_server_checked_update, updateTouchesStdioExecution, init_mcp_server_stdio_gate, canReadMemory, init_access, getLinksForMemory, init_links_store, attachDemotionEvidence, init_demotion_evidence, expandCandidatesWithGraph, init_graph_expansion, isApiDraining, drainApi, init_api_drain, markKapsoMessageRead, sendKapsoReaction, init_client, getKapsoConfig, getKapsoNumberMapping, markKapsoMessageSeen, init_config2, changesAllowMerge, init_repo_merge_policy, updateSwarmRepoChecked, init_repo_checked_update, getCombConfig, init_config3, resolveRoomNamespace, roomRequestInfo, authorizeRoomNamespace, sessionAccessTopic, sessionPresenceRoot, init_auth2, RoomOperationSchema, init_document, removeAwarenessStates, init_awareness, roomTopic, decodeRoomSnapshot, roomView, getRoom, changeRoom, applyRoomUpdate, resetRoom, sweepRooms, closeRooms, removeNamespaceRooms, init_rooms, init_scheduler2, MEMORY_KEYS_DEFAULT_PREFIX, MEMORY_KEYS_MAX_LIMIT, estimateTokens, posteriorMean, listMemoryKeys, checkChunkIntegrity, getMemoryChunks, getPosteriorsByIds, init_key_browser, createEvent, createEventsBatch, getEventCountsFiltered, getEventsFiltered, init_events, mergeScheduleTiming, validateRecurringTiming, init_validate, followUpThreadForSourceTask, evaluateFollowUpRedelegation, init_follow_up_redelegation_guard, checkOutputSchemaShape, sendTaskOutputSchema, sendTaskHandler, init_send_task, steerTaskUserInputSchema, steerTaskOutputSchema, steerTaskHandler, init_steer_task, skipReasonFrom, finalizeSkippedTaskReaction, init_task_skip, IMPROVEMENT_TEXT_MAX, IMPROVEMENT_STATUSES, IMPROVEMENT_SOURCES, ImprovementError, isImprovementsEnabled, getImprovement, listImprovements, createImprovement, approveAndSend, discardImprovement, improvementLeakHints, init_improvements, recomputeSessionCost, init_session_cost_recompute, canClaim, init_budget_admission, emitBudgetRefusalSideEffects, init_budget_refusal_notify, workflowModelErrors, init_model_validation, patchWorkflowDefinition, init_patch_definition, idempotencyKeyHeader, readIdempotencyKey, replayAcceptedOperation, init_idempotency_key, resolveScriptsOnlyMode, init_scripts_only_mode, ALL_CAPABILITIES, hasCapability, getEnabledCapabilities, createServer, init_server };