@desplega.ai/agent-swarm 2.13.2 → 2.13.4
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.
- package/dist/acp-adapter-mr4temec.js +17 -0
- package/dist/{acp-targets-mz8c5dnt.js → acp-targets-zrk9k0n7.js} +10 -10
- package/dist/{actions-5ft3qp5a.js → actions-acqqj9jn.js} +236 -26
- package/dist/{agent-fs-provision-6fgz7wvz.js → agent-fs-provision-zmaykqnd.js} +4 -4
- package/dist/{amp-adapter-nthn8ezm.js → amp-adapter-a7ts8tmw.js} +3 -3
- package/dist/{app-535m78qw.js → app-tmwa442h.js} +7 -7
- package/dist/{approval-notifications-dewbk403.js → approval-notifications-6psaaaye.js} +8 -8
- package/dist/{assistant-39zyabv2.js → assistant-564v6emv.js} +25 -25
- package/dist/{boot-args-schema-bqv5bf77.js → boot-args-schema-n099e0f2.js} +1 -1
- package/dist/{boot-reembed-fas7z3zn.js → boot-reembed-chx66qfk.js} +1 -1
- package/dist/{boot-reembed-157c0gcz.js → boot-reembed-epvg4fp9.js} +1 -1
- package/dist/{boot-scrub-sweep-tmec0be2.js → boot-scrub-sweep-dhkfp0a7.js} +2 -2
- package/dist/{boot-seeds-32zm50x2.js → boot-seeds-m74fc07r.js} +4 -4
- package/dist/{boxd-hr8rsxzq.js → boxd-451q55ys.js} +1 -1
- package/dist/{claude-adapter-gwq7x2nj.js → claude-adapter-hw63yj3j.js} +12 -9
- package/dist/{claude-managed-adapter-rkvw6fvq.js → claude-managed-adapter-z5s7fx6p.js} +3 -3
- package/dist/{claude-managed-setup-0vgz4d1j.js → claude-managed-setup-wee1762m.js} +3 -3
- package/dist/{claude-sdk-session-5wbwxy8c.js → claude-sdk-session-cktyqkpk.js} +27 -13
- package/dist/{cli-d528acsw.js → cli-0fgvnb0x.js} +7 -7
- package/dist/{cli-2v4xxnx2.js → cli-0h8skzss.js} +1 -1
- package/dist/{cli-jkkcm72j.js → cli-0p76my9q.js} +31 -16
- package/dist/{cli-fp65jdp2.js → cli-1kvcsd2f.js} +219 -155
- package/dist/{cli-gc7jkf4a.js → cli-1vmhnncj.js} +3 -3
- package/dist/{cli-tceqvv6h.js → cli-29h5239w.js} +5 -5
- package/dist/cli-2ap1the6.js +11 -0
- package/dist/{cli-8fj8yfmk.js → cli-2vp0z049.js} +1 -1
- package/dist/{cli-ewb028rs.js → cli-3bxrrh53.js} +4 -4
- package/dist/{cli-nvqq3232.js → cli-3tzmh38q.js} +9 -9
- package/dist/{cli-0xwb7zpt.js → cli-3xqad83h.js} +2 -2
- package/dist/{cli-0f7n3td3.js → cli-3zrwrnz7.js} +1 -1
- package/dist/{cli-2wde56gv.js → cli-404am6f3.js} +7 -7
- package/dist/{cli-r4fphq38.js → cli-49aq3cyn.js} +4 -4
- package/dist/{cli-8qvte9hn.js → cli-4fpa0zns.js} +3 -3
- package/dist/{cli-x5yb8zc8.js → cli-4pbwg7sn.js} +2 -2
- package/dist/{cli-s08zsqva.js → cli-4q2c8rxw.js} +76 -10
- package/dist/{cli-3mf04tkh.js → cli-4vynxtrb.js} +1 -1
- package/dist/{cli-tbdw3f92.js → cli-5ashycw3.js} +3 -3
- package/dist/{cli-c9bwawf9.js → cli-5rgm8p39.js} +3 -3
- package/dist/{cli-g0b3ma7r.js → cli-5rxsb3wq.js} +6 -6
- package/dist/{cli-a6rzw649.js → cli-60dwk8tx.js} +3 -3
- package/dist/{cli-xhkek467.js → cli-7by7vp6m.js} +30 -4
- package/dist/{cli-62fjschk.js → cli-7g3fg4gf.js} +7 -7
- package/dist/{cli-ka13xx6b.js → cli-7gbff32z.js} +2 -2
- package/dist/{cli-q8aq48v1.js → cli-8b4rpnwj.js} +1 -1
- package/dist/{cli-1f48qdnb.js → cli-8cas2xvp.js} +3 -3
- package/dist/{cli-dnvmwsvc.js → cli-904wk98s.js} +799 -371
- package/dist/{cli-m1wddksc.js → cli-93n305hm.js} +2 -2
- package/dist/{cli-31vt7baf.js → cli-944w9wb4.js} +21 -17
- package/dist/{cli-je587f74.js → cli-94gx6ze9.js} +1 -1
- package/dist/{cli-fcwrd7bh.js → cli-9ah37a8a.js} +6 -6
- package/dist/{cli-rfejbpe1.js → cli-akm6y2a8.js} +1 -1
- package/dist/{cli-f8rcvf2x.js → cli-azj9t1f9.js} +37 -2
- package/dist/{cli-mwxez0pz.js → cli-b768ek79.js} +1 -1
- package/dist/{cli-cmgdptmx.js → cli-bv4vvnmg.js} +31 -7
- package/dist/{cli-1gevjrc1.js → cli-bzcwwebm.js} +1 -1
- package/dist/{cli-sjk85d7v.js → cli-cq4am6vg.js} +3 -3
- package/dist/{cli-f1sdh8ca.js → cli-d5pc8ep0.js} +103 -9
- package/dist/{cli-7m6bbtab.js → cli-ea7nz50q.js} +12 -12
- package/dist/{cli-zkbz8m2q.js → cli-fkpnx3vf.js} +1 -1
- package/dist/{cli-ya1cj689.js → cli-fw67mnyc.js} +1 -1
- package/dist/{cli-5basv0e7.js → cli-gkv0r2hq.js} +1 -1
- package/dist/{cli-nkfv398a.js → cli-gse7bp3z.js} +12 -10
- package/dist/{cli-4djg31jh.js → cli-gtj12v95.js} +1 -1
- package/dist/{cli-qn79645p.js → cli-h9d3sdnc.js} +1 -1
- package/dist/{cli-tgmate57.js → cli-hdhpdrka.js} +6 -23
- package/dist/{cli-fgm2mad9.js → cli-hhtbandk.js} +2 -2
- package/dist/cli-hyqksecw.js +1907 -0
- package/dist/{cli-t25rq8mg.js → cli-ja450998.js} +40 -11
- package/dist/{cli-43dsqhcp.js → cli-jbrc98qb.js} +4 -4
- package/dist/{cli-82j36f2m.js → cli-jjzxsk47.js} +9 -3
- package/dist/{cli-xerdrnqs.js → cli-jyhbvdga.js} +3 -3
- package/dist/{cli-t9nxq30h.js → cli-jzerrzgc.js} +8 -8
- package/dist/{cli-hv3820ez.js → cli-k0nebh10.js} +1 -1
- package/dist/{cli-s6fhqbz1.js → cli-ka48vpev.js} +6 -6
- package/dist/{cli-d2epqm0y.js → cli-kezzteka.js} +1 -1
- package/dist/{cli-getrvmtx.js → cli-kj84fqxz.js} +2 -2
- package/dist/{cli-h0ewec3d.js → cli-kr0jpw9c.js} +1 -1
- package/dist/{cli-gq6qhmrr.js → cli-m1sns1da.js} +3 -3
- package/dist/{cli-bp2rt28p.js → cli-n1kjs58m.js} +5 -5
- package/dist/{cli-rvhaahfv.js → cli-nc4pbwmp.js} +9 -9
- package/dist/{cli-d0jb2qnt.js → cli-p3knvk62.js} +74 -47
- package/dist/{cli-50whymxq.js → cli-p436yrzp.js} +2 -2
- package/dist/{cli-cs26ed89.js → cli-phdzn699.js} +8 -8
- package/dist/{cli-b0kqw55g.js → cli-pz1dp12c.js} +1 -1
- package/dist/{cli-8a4qg44m.js → cli-pz1nq5xm.js} +6 -6
- package/dist/{cli-e87fg3en.js → cli-qzz6tz8s.js} +1 -1
- package/dist/{cli-69eq6gdk.js → cli-rmgvwcmy.js} +38 -29
- package/dist/{cli-5k1hvycs.js → cli-rv3y60bt.js} +4 -4
- package/dist/cli-s33bzmk0.js +27 -0
- package/dist/{cli-at67kvnp.js → cli-srktrbby.js} +1 -1
- package/dist/{cli-6rmryz03.js → cli-t0jmkcah.js} +14 -14
- package/dist/{cli-eetzmsy5.js → cli-t9pzz2eq.js} +2 -2
- package/dist/{cli-wdtqkqnq.js → cli-tr19nyn9.js} +4 -4
- package/dist/{cli-erh1rgh4.js → cli-ts5yv7dn.js} +165 -88
- package/dist/{cli-zqy28rwx.js → cli-tsc3pdfd.js} +4 -4
- package/dist/{cli-x7aqhxj5.js → cli-tzw1jr2t.js} +2 -2
- package/dist/{cli-n14r8h4n.js → cli-x2cem5vy.js} +6 -4
- package/dist/{cli-vx9acp12.js → cli-ybte1fqc.js} +1 -1
- package/dist/{cli-xysy1g8x.js → cli-ysv0k1we.js} +2 -2
- package/dist/{cli-vdfngx2g.js → cli-ywy8yz6t.js} +2 -2
- package/dist/{cli-cpkxh68d.js → cli-z1vam71h.js} +2 -2
- package/dist/{cli-zm6bkx3e.js → cli-zexwhj3f.js} +3 -3
- package/dist/{cli-j2ybkdk2.js → cli-zhwjdhjr.js} +2 -2
- package/dist/{cli-gedf48yw.js → cli-zjdhrzm0.js} +8 -8
- package/dist/cli.js +20 -20
- package/dist/{codex-adapter-x25xfbnh.js → codex-adapter-2fs2c0n6.js} +8 -8
- package/dist/{codex-hook-c0nvm30r.js → codex-hook-jxjv6dy5.js} +10 -3
- package/dist/{codex-login-ven5cz5j.js → codex-login-ktfg1cxk.js} +1 -1
- package/dist/{codex-session-runner-kn5xnrvp.js → codex-session-runner-r55tmx4c.js} +9 -9
- package/dist/{commands-8n59gxmy.js → commands-0mxdy9x8.js} +3 -3
- package/dist/{controller-wn3vd217.js → controller-g3vkfhr4.js} +4 -4
- package/dist/{controllers-connect-09gvkrhc.js → controllers-connect-4wdmncqt.js} +25 -25
- package/dist/core-gsvj5f3z.js +42 -0
- package/dist/{cursor-adapter-w1681kp1.js → cursor-adapter-t9qb96q2.js} +2 -2
- package/dist/{db-e71keqxk.js → db-487vvyv9.js} +3 -3
- package/dist/{db-spg81qtr.js → db-76p7w3gr.js} +2 -2
- package/dist/{devin-adapter-fs90ab4v.js → devin-adapter-3bp6rape.js} +1 -1
- package/dist/{dispatcher-fr4vawwb.js → dispatcher-64rp6w67.js} +22 -22
- package/dist/{docker-1h33jvh9.js → docker-a59g3ebm.js} +2 -2
- package/dist/{dsh-adapter-g9yqv09y.js → dsh-adapter-8abzqk5c.js} +2 -2
- package/dist/{e2b-y7e5kmzf.js → e2b-3ykbe805.js} +2 -2
- package/dist/{e2b-jnk0yeva.js → e2b-dc8f6ctq.js} +2 -2
- package/dist/{easter-egg-3d-ac9tv9a6.js → easter-egg-3d-jrrwyf55.js} +1 -1
- package/dist/{embedding-space-an77f45k.js → embedding-space-001hhhpk.js} +6 -6
- package/dist/{embeddings-jkrehejr.js → embeddings-esj19cnw.js} +1 -1
- package/dist/{event-bus-08t2b4y2.js → event-bus-7gbsr0g4.js} +1 -1
- package/dist/{execute-3mys4nta.js → execute-301hkxqg.js} +1 -1
- package/dist/{external-channel-s6zxpts9.js → external-channel-w10e2j05.js} +2 -2
- package/dist/fx-adapter-4sjrbdne.js +20 -0
- package/dist/grok-adapter-3a0ezfee.js +20 -0
- package/dist/handlers-ef3k11hb.js +41 -0
- package/dist/{heartbeat-jjpb44e5.js → heartbeat-tbrj7vhq.js} +25 -25
- package/dist/hook-3am1sq68.js +22 -0
- package/dist/{hook-y6n23zzj.js → hook-tx917rqw.js} +11 -8
- package/dist/{http-8c6y008s.js → http-3rmemtqy.js} +340 -1841
- package/dist/{index-mbpxhc4w.js → index-126v2d0t.js} +1 -4
- package/dist/{index-xcw7hjt5.js → index-2jw11t8s.js} +26 -26
- package/dist/{index-p2f5xg64.js → index-3j803vnb.js} +36259 -34299
- package/dist/{index-we3nd2t0.js → index-aetfyx6p.js} +1 -1
- package/dist/index-e6bq0exk.js +42 -0
- package/dist/{index-0vthtbc2.js → index-gfnq66t1.js} +231 -25
- package/dist/index-hf2k1vge.js +39 -0
- package/dist/{index-6h3r0vpe.js → index-s7xtvc0f.js} +1 -1
- package/dist/index-taxmejj3.js +44 -0
- package/dist/{k8s-8326q0rq.js → k8s-36gfn847.js} +2 -2
- package/dist/{keepalive-7e9r5dvp.js → keepalive-9px3t7qj.js} +5 -5
- package/dist/lead-5vt6f174.js +83 -0
- package/dist/{maintenance-d3erjvcg.js → maintenance-vwqjwst6.js} +1 -1
- package/dist/{oauth-refresh-sweep-0qh70988.js → oauth-refresh-sweep-yqry3wn4.js} +4 -4
- package/dist/{object-webhooks-ac7v2q5p.js → object-webhooks-8s1wtths.js} +7 -7
- package/dist/{onboard-5yphtken.js → onboard-hb8czx0p.js} +7 -7
- package/dist/{opencode-adapter-0xvyba4m.js → opencode-adapter-djd6m6dk.js} +8 -8
- package/dist/{otel-impl-svqp691q.js → otel-impl-2ymwyczz.js} +2 -2
- package/dist/{pending-bn4xe5br.js → pending-nxavtvx7.js} +23 -23
- package/dist/{pi-mono-adapter-763s8a3w.js → pi-mono-adapter-d2cpmcy4.js} +13 -13
- package/dist/{pricing-refresh-kfc215mf.js → pricing-refresh-1yz8jkqv.js} +2 -2
- package/dist/{rbac-roles-6r4h2ghj.js → rbac-roles-7s6m31xw.js} +6 -4
- package/dist/{rbac-roles-3bznvkpt.js → rbac-roles-dbpx0x9v.js} +3 -3
- package/dist/{render-v2-f3qedbpy.js → render-v2-7y20rjrn.js} +7 -7
- package/dist/{resume-vcag4ann.js → resume-wz546x47.js} +10 -10
- package/dist/{runtime-x0s55z2t.js → runtime-cb5bd9tz.js} +1 -1
- package/dist/{session-access-nwzve8q2.js → session-access-4vcft8kq.js} +5 -5
- package/dist/{session-source-backfill-jpqfzmgz.js → session-source-backfill-57b50tpw.js} +3 -3
- package/dist/{setup-d2smwaem.js → setup-e1tevjyj.js} +1 -1
- package/dist/thread-buffer-686pa1p1.js +42 -0
- package/dist/{tree-visibility-dwzc8en0.js → tree-visibility-07wf1nct.js} +2 -2
- package/dist/{user-merge-jobs-4ce7kma2.js → user-merge-jobs-n20qpv6s.js} +3 -3
- package/dist/{virtual-modules-78a6yw71.js → virtual-modules-6fxmn1yv.js} +3 -3
- package/dist/{work-objects-m0w1e7q8.js → work-objects-eg7y48pe.js} +25 -25
- package/dist/worker-4vp616ms.js +83 -0
- package/dist/{worker-follow-up-e3t6f895.js → worker-follow-up-jnvnnf2b.js} +22 -22
- package/dist/{x-asbrnafg.js → x-d27jj7z7.js} +2 -2
- package/openapi.json +478 -28
- package/package.json +3 -3
- package/src/be/db/approvals.ts +2 -0
- package/src/be/db/runtime.ts +5 -0
- package/src/be/db/script-run-sources.ts +17 -0
- package/src/be/db-retention.ts +1 -1
- package/src/be/db.ts +71 -62
- package/src/be/design-system.ts +63 -0
- package/src/be/migrations/342_script_run_sources.sql +20 -0
- package/src/be/migrations/runner.ts +8 -0
- package/src/be/migrations/script-run-sources.ts +51 -0
- package/src/be/rbac-roles.ts +2 -0
- package/src/be/scripts/typecheck.ts +4 -2
- package/src/be/seed-scripts/catalog/design-system-seed.ts +158 -0
- package/src/be/seed-scripts/index.ts +9 -0
- package/src/be/swarm-config-guard.ts +21 -1
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/runner.ts +62 -6
- package/src/heartbeat/heartbeat.ts +18 -4
- package/src/hooks/codex-hook.ts +15 -4
- package/src/hooks/hook.ts +7 -0
- package/src/http/all-routes.ts +1 -0
- package/src/http/approval-chat-answer.ts +99 -0
- package/src/http/approval-requests.ts +280 -225
- package/src/http/design-system.ts +103 -0
- package/src/http/index.ts +10 -6
- package/src/http/pages-public.ts +25 -10
- package/src/http/pages.ts +17 -0
- package/src/http/person-responder.ts +28 -0
- package/src/http/session-cost-recompute.ts +3 -1
- package/src/http/session-data.ts +3 -0
- package/src/integrations/chat-sdk/adapters.ts +33 -3
- package/src/integrations/chat-sdk/inbound.ts +6 -18
- package/src/integrations/chat-sdk/mentions.ts +188 -0
- package/src/integrations/chat-sdk/outbound.ts +20 -3
- package/src/integrations/chat-sdk/router.ts +8 -0
- package/src/integrations/chat-sdk/telegram-thread.ts +12 -0
- package/src/jira/adf.ts +35 -9
- package/src/kv-reserved-namespaces.ts +5 -0
- package/src/pages/page-head.ts +11 -1
- package/src/prompts/base-prompt.ts +1 -1
- package/src/prompts/session-templates.ts +1 -1
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +21 -1
- package/src/providers/claude-sdk-session.ts +22 -3
- package/src/providers/claude-session-events.ts +76 -1
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/providers/dsh-adapter.ts +48 -13
- package/src/providers/fx-adapter.ts +2 -2
- package/src/providers/pricing-sources.md +3 -0
- package/src/providers/types.ts +13 -0
- package/src/rbac/legacy-policy.ts +4 -0
- package/src/rbac/permissions.ts +8 -0
- package/src/scheduler/index.ts +1 -0
- package/src/scheduler/scheduler.test.ts +32 -1
- package/src/scheduler/scheduler.ts +24 -1
- package/src/script-workflows/executor.ts +6 -0
- package/src/script-workflows/supervisor.ts +2 -1
- package/src/scripts-runtime/sdk-allowlist.ts +2 -0
- package/src/scripts-runtime/swarm-sdk.ts +12 -23
- package/src/scripts-runtime/types/stdlib.d.ts +4 -1
- package/src/scripts-runtime/types/swarm-sdk.d.ts +4 -1
- package/src/server.ts +2 -0
- package/src/slack/actions.ts +3 -0
- package/src/slack/approval-actions.ts +148 -0
- package/src/slack/approval-buttons.ts +28 -0
- package/src/slack/render-v2.ts +27 -7
- package/src/tests/base-prompt.test.ts +6 -2
- package/src/tests/chat-sdk-mentions.test.ts +183 -0
- package/src/tests/claude-adapter.test.ts +115 -0
- package/src/tests/create-page-tool.test.ts +5 -0
- package/src/tests/dsh-adapter.test.ts +53 -1
- package/src/tests/fixtures/compiled-source-schema-boot.ts +24 -0
- package/src/tests/fixtures/fx/acp-updates-recorded.jsonl +1 -1
- package/src/tests/fixtures/secret-corpus.ts +43 -1
- package/src/tests/heartbeat-stall-thresholds.test.ts +174 -0
- package/src/tests/internal-ai/complete-structured.test.ts +105 -0
- package/src/tests/internal-ai/credentials.test.ts +149 -0
- package/src/tests/internal-ai/task-title.test.ts +78 -0
- package/src/tests/jira-adf.test.ts +42 -2
- package/src/tests/mcp-input-caps.test.ts +16 -11
- package/src/tests/merge-gate-detect-changes.test.ts +208 -16
- package/src/tests/migration-342-script-run-sources.test.ts +196 -0
- package/src/tests/migration-bunfs-compat.test.ts +129 -9
- package/src/tests/rbac-e2e-helpers.test.ts +10 -4
- package/src/tests/rbac-e2e-helpers.ts +13 -4
- package/src/tests/rbac-roles.test.ts +2 -0
- package/src/tests/runner-slot-reconcile.test.ts +102 -0
- package/src/tests/runtime-e2b-pools.test.ts +7 -1
- package/src/tests/schedule-target-type.test.ts +4 -1
- package/src/tests/script-connections.test.ts +2 -0
- package/src/tests/script-runs-retention.test.ts +43 -16
- package/src/tests/script-workflows-runtime-e2e.test.ts +56 -22
- package/src/tests/scripts-http.test.ts +9 -3
- package/src/tests/sdk-allowlist.test.ts +26 -13
- package/src/tests/sdk-store-progress-skipped.test.ts +12 -5
- package/src/tests/secret-rules.test.ts +34 -0
- package/src/tests/secret-scrub-gate.test.ts +7 -0
- package/src/tests/secret-scrubber.test.ts +62 -2
- package/src/tests/seed-scripts.test.ts +2 -2
- package/src/tests/slack-render-v2.test.ts +85 -0
- package/src/tests/system-one-hosts-ui-mirror.test.ts +1 -0
- package/src/tests/vcs-azure-devops.test.ts +10 -0
- package/src/tests/vcs-provider.test.ts +8 -0
- package/src/themes/design-system.ts +163 -0
- package/src/themes/page-theme.ts +28 -19
- package/src/tools/chat-post.ts +7 -3
- package/src/tools/create-page.ts +3 -0
- package/src/tools/design-system.ts +102 -0
- package/src/tools/mcp-servers/mcp-server-get.ts +1 -1
- package/src/tools/mcp-servers/mcp-server-list.ts +1 -1
- package/src/tools/register-chat-channel.ts +11 -2
- package/src/tools/skills/skill-get-file.ts +1 -1
- package/src/tools/skills/skill-get.ts +1 -1
- package/src/tools/skills/skill-list.ts +1 -1
- package/src/tools/skills/skill-search.ts +1 -1
- package/src/tools/utils.ts +49 -4
- package/src/tools/workflows/get-workflow-run.ts +1 -1
- package/src/tools/workflows/get-workflow.ts +1 -1
- package/src/tools/workflows/list-workflow-runs.ts +1 -1
- package/src/tools/workflows/list-workflows.ts +1 -1
- package/src/types.ts +67 -1
- package/src/utils/internal-ai/complete-structured.ts +36 -5
- package/src/utils/internal-ai/credentials.ts +78 -2
- package/src/utils/internal-ai/models.ts +37 -1
- package/src/utils/internal-ai/task-title.ts +31 -1
- package/src/utils/secret-rules.generated.ts +149 -149
- package/src/utils/secret-scrubber.ts +111 -5
- package/src/vcs/azure-devops.ts +22 -1
- package/src/vcs/index.ts +3 -1
- package/src/workflows/approval-inline.ts +122 -0
- package/src/workflows/approval-notifications.ts +7 -2
- package/src/workflows/engine.ts +6 -5
- package/src/workflows/executors/agent-task.ts +14 -0
- package/src/workflows/executors/system-one-providers.ts +23 -0
- package/templates/skills/pages/content.md +34 -8
- package/templates/skills/swarm-docs/content.md +13 -0
- package/templates/skills/workflow-iterate/content.md +1 -1
- package/dist/acp-adapter-x1qqgzwx.js +0 -17
- package/dist/cli-n46d87mj.js +0 -98
- package/dist/core-2b8bv6ny.js +0 -42
- package/dist/fx-adapter-4yet1c4f.js +0 -20
- package/dist/grok-adapter-8ge6tw7m.js +0 -20
- package/dist/handlers-0r9evrdj.js +0 -41
- package/dist/hook-68gbs87k.js +0 -19
- package/dist/index-1v23363p.js +0 -39
- package/dist/index-30qw6vyw.js +0 -44
- package/dist/index-6bm3w6cn.js +0 -40
- package/dist/lead-3jpc7kcr.js +0 -79
- package/dist/thread-buffer-8fc703jc.js +0 -42
- package/dist/worker-3p2vq107.js +0 -79
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
} from "./cli-6p8p2e6r.js";
|
|
1
|
+
import"./cli-6p8p2e6r.js";
|
|
2
|
+
import"./cli-2ap1the6.js";
|
|
4
3
|
import {
|
|
5
4
|
auditAssetKeys,
|
|
6
5
|
init_asset_key_audit,
|
|
@@ -49,14 +48,9 @@ import {
|
|
|
49
48
|
catalog_default,
|
|
50
49
|
COMPANY_TEAM_SIZES,
|
|
51
50
|
COMPANY_USE_CASES,
|
|
52
|
-
USER_FUNCTIONS,
|
|
53
51
|
reportedUseCase,
|
|
54
|
-
reportedUserFunction,
|
|
55
52
|
init_company_profile,
|
|
56
|
-
TELEMETRY_PROXY_ORIGIN,
|
|
57
53
|
normalizeOrgWebsite,
|
|
58
|
-
orgLogoUrl,
|
|
59
|
-
isFilledOrgLogoUrl,
|
|
60
54
|
init_org_website,
|
|
61
55
|
setRequestAuth,
|
|
62
56
|
getRequestAuth,
|
|
@@ -86,15 +80,6 @@ import {
|
|
|
86
80
|
CHAT_SDK_ADAPTER_NAMES,
|
|
87
81
|
isAdapterEntryEnabled,
|
|
88
82
|
init_schema,
|
|
89
|
-
TELEMETRY_RANKING_KEY,
|
|
90
|
-
PUBLIC_RANKING_ENABLED_KEY,
|
|
91
|
-
RANKING_CATEGORIES,
|
|
92
|
-
readTelemetryRanking,
|
|
93
|
-
rankingFormSchema,
|
|
94
|
-
buildListing,
|
|
95
|
-
init_telemetry_ranking,
|
|
96
|
-
isSlackIconConfigKey,
|
|
97
|
-
init_reaction_shortcode,
|
|
98
83
|
API_DRAINING_HEADER,
|
|
99
84
|
init_api_drain2,
|
|
100
85
|
parseTaskToolManifest,
|
|
@@ -102,12 +87,6 @@ import {
|
|
|
102
87
|
isChatSdkTask,
|
|
103
88
|
selectTaskTools,
|
|
104
89
|
init_task_tool_manifest,
|
|
105
|
-
isApiOnlyConfigKey,
|
|
106
|
-
isInternalConfigKey,
|
|
107
|
-
internalConfigKeyError,
|
|
108
|
-
isHumanOnlyConfigKey,
|
|
109
|
-
humanOnlyConfigKeyError,
|
|
110
|
-
humanOnlyConfigKeyPageError,
|
|
111
90
|
MAX_DB_RETENTION_DAYS,
|
|
112
91
|
DB_RETENTION_TUNING_BOUNDS,
|
|
113
92
|
CODEX_OAUTH_KEEP_WARM_MAX_AGE_HOURS_BOUNDS,
|
|
@@ -248,7 +227,6 @@ import {
|
|
|
248
227
|
explicitModelError,
|
|
249
228
|
explicitModelErrorForAgent,
|
|
250
229
|
init_model_validation2,
|
|
251
|
-
runtimeReadsRepoSecrets,
|
|
252
230
|
checkProfileForAgent,
|
|
253
231
|
formatProfileCheckFailures,
|
|
254
232
|
init_model_profile_check,
|
|
@@ -289,9 +267,6 @@ import {
|
|
|
289
267
|
markSteeringUndeliverable,
|
|
290
268
|
requestSteering,
|
|
291
269
|
init_steering2,
|
|
292
|
-
listApprovalRequestSummaries2,
|
|
293
|
-
getPendingApprovalVoteState2,
|
|
294
|
-
recordApprovalVotes2,
|
|
295
270
|
getPendingApprovalsForTasks2,
|
|
296
271
|
computeContentHash2,
|
|
297
272
|
AssetKeyMovesBlockedError2,
|
|
@@ -396,13 +371,9 @@ import {
|
|
|
396
371
|
createScheduledTask2,
|
|
397
372
|
updateScheduledTask2,
|
|
398
373
|
deleteScheduledTask2,
|
|
399
|
-
maskSecrets2,
|
|
400
374
|
getSwarmConfigs2,
|
|
401
|
-
getSwarmConfigById2,
|
|
402
|
-
getSwarmConfigLookupById2,
|
|
403
375
|
upsertSwarmConfig2,
|
|
404
376
|
emitBuiltInIntegrationConnectedOnce2,
|
|
405
|
-
deleteSwarmConfig2,
|
|
406
377
|
deleteSwarmConfigByKey2,
|
|
407
378
|
getResolvedConfig2,
|
|
408
379
|
getSwarmRepos2,
|
|
@@ -423,7 +394,6 @@ import {
|
|
|
423
394
|
deleteWorkflow2,
|
|
424
395
|
getWorkflowRun2,
|
|
425
396
|
listWorkflowRunsPage2,
|
|
426
|
-
getWorkflowRunStep2,
|
|
427
397
|
getWorkflowRunStepsByRunId2,
|
|
428
398
|
getWorkflowVersions2,
|
|
429
399
|
getWorkflowVersion2,
|
|
@@ -460,10 +430,6 @@ import {
|
|
|
460
430
|
checkoutPromptTemplate2,
|
|
461
431
|
getAllChannelActivityCursors2,
|
|
462
432
|
upsertChannelActivityCursor2,
|
|
463
|
-
createApprovalRequest2,
|
|
464
|
-
getApprovalRequestById2,
|
|
465
|
-
resolveApprovalRequest2,
|
|
466
|
-
listApprovalRequests2,
|
|
467
433
|
createSkill2,
|
|
468
434
|
updateSkill2,
|
|
469
435
|
listSkillFileManifest2,
|
|
@@ -557,7 +523,7 @@ import {
|
|
|
557
523
|
countScriptRunJournalSteps2,
|
|
558
524
|
countScriptRunJournalAgentTaskSteps2,
|
|
559
525
|
init_db4
|
|
560
|
-
} from "./cli-
|
|
526
|
+
} from "./cli-ts5yv7dn.js";
|
|
561
527
|
import {
|
|
562
528
|
PRIMARY_ROLE_NAMES2,
|
|
563
529
|
OperatorGrantedTargetError2,
|
|
@@ -571,7 +537,7 @@ import {
|
|
|
571
537
|
assertNotLastAdmin2,
|
|
572
538
|
setUserRoles2,
|
|
573
539
|
init_rbac_roles
|
|
574
|
-
} from "./cli-
|
|
540
|
+
} from "./cli-x2cem5vy.js";
|
|
575
541
|
import {
|
|
576
542
|
MAX_MODEL_GROUP_MEMBERS,
|
|
577
543
|
listModelGroups,
|
|
@@ -581,17 +547,17 @@ import {
|
|
|
581
547
|
modelGroupReferences,
|
|
582
548
|
deleteModelGroup,
|
|
583
549
|
init_model_groups
|
|
584
|
-
} from "./cli-
|
|
550
|
+
} from "./cli-4fpa0zns.js";
|
|
585
551
|
import {
|
|
586
552
|
requestModelCatalogRefresh2,
|
|
587
553
|
init_pricing_refresh
|
|
588
|
-
} from "./cli-
|
|
554
|
+
} from "./cli-93n305hm.js";
|
|
589
555
|
import {
|
|
590
556
|
workflowEventBus2,
|
|
591
557
|
init_event_bus
|
|
592
|
-
} from "./cli-
|
|
593
|
-
import"./cli-
|
|
594
|
-
import"./cli-
|
|
558
|
+
} from "./cli-ybte1fqc.js";
|
|
559
|
+
import"./cli-7gbff32z.js";
|
|
560
|
+
import"./cli-qzz6tz8s.js";
|
|
595
561
|
import"./cli-vr4eyq6p.js";
|
|
596
562
|
import"./cli-r8ddn0hf.js";
|
|
597
563
|
import {
|
|
@@ -631,11 +597,9 @@ import {
|
|
|
631
597
|
startSlackApp2,
|
|
632
598
|
stopSlackApp2,
|
|
633
599
|
init_app4
|
|
634
|
-
} from "./cli-
|
|
600
|
+
} from "./cli-rmgvwcmy.js";
|
|
635
601
|
import {
|
|
636
|
-
AGENT_MAX_TASKS_CONFIG_KEY,
|
|
637
602
|
reconcileAgentMaxTasksPolicy,
|
|
638
|
-
resetAgentMaxTasksMirror,
|
|
639
603
|
upsertSwarmConfigWithPolicyMirror,
|
|
640
604
|
runtimeStaleThresholdMinutes,
|
|
641
605
|
upsertRuntimeInstance,
|
|
@@ -646,26 +610,13 @@ import {
|
|
|
646
610
|
setRuntimeCredentialReady,
|
|
647
611
|
reconcileAgentStatusFromRuntimes,
|
|
648
612
|
listRuntimeInstancesForPool,
|
|
649
|
-
init_multi_runtime
|
|
650
|
-
|
|
651
|
-
ConfigStateSchema,
|
|
652
|
-
readConfigState,
|
|
653
|
-
normalizeApprovalQuestions,
|
|
654
|
-
isConfigQuestion,
|
|
655
|
-
parseConfigAnswer,
|
|
656
|
-
skippedConfigResult,
|
|
657
|
-
keptConfigResult,
|
|
658
|
-
applyConfigAnswer,
|
|
659
|
-
init_approval_config_question,
|
|
660
|
-
dispatchApprovalNotifications2,
|
|
661
|
-
createApprovalFollowUpTask2,
|
|
662
|
-
init_approval_notifications
|
|
663
|
-
} from "./cli-f1sdh8ca.js";
|
|
613
|
+
init_multi_runtime
|
|
614
|
+
} from "./cli-d5pc8ep0.js";
|
|
664
615
|
import {
|
|
665
616
|
retryFailedRun2,
|
|
666
617
|
cancelWorkflowRun2,
|
|
667
618
|
init_resume
|
|
668
|
-
} from "./cli-
|
|
619
|
+
} from "./cli-9ah37a8a.js";
|
|
669
620
|
import {
|
|
670
621
|
safeParse,
|
|
671
622
|
getObjectShape,
|
|
@@ -880,7 +831,7 @@ import {
|
|
|
880
831
|
init_gitlab,
|
|
881
832
|
isChatSdkEnabled,
|
|
882
833
|
getChatSdkConfig,
|
|
883
|
-
|
|
834
|
+
init_config2,
|
|
884
835
|
errorMessage,
|
|
885
836
|
init_logger,
|
|
886
837
|
resolveAdapterApiUrl,
|
|
@@ -939,10 +890,15 @@ import {
|
|
|
939
890
|
init_auth,
|
|
940
891
|
getDeploymentEnvValue2,
|
|
941
892
|
loadGlobalConfigsIntoEnv2,
|
|
942
|
-
reloadGlobalConfigsAndIntegrations2,
|
|
943
893
|
scheduleIntegrationsReload2,
|
|
944
894
|
handleCore2,
|
|
945
895
|
init_core,
|
|
896
|
+
resolveRequestPrincipal,
|
|
897
|
+
requestPrincipal,
|
|
898
|
+
agentFirstPrincipal,
|
|
899
|
+
requireAuthKind,
|
|
900
|
+
rejectGuest,
|
|
901
|
+
init_request_principal,
|
|
946
902
|
nextFallback2,
|
|
947
903
|
createWorkerTaskFollowUp2,
|
|
948
904
|
createResumeFollowUp2,
|
|
@@ -952,12 +908,6 @@ import {
|
|
|
952
908
|
init_mcp_limits,
|
|
953
909
|
userCtx,
|
|
954
910
|
init_task_tool_ctx,
|
|
955
|
-
resolveRequestPrincipal,
|
|
956
|
-
requestPrincipal,
|
|
957
|
-
agentFirstPrincipal,
|
|
958
|
-
requireAuthKind,
|
|
959
|
-
rejectGuest,
|
|
960
|
-
init_request_principal,
|
|
961
911
|
resolveTaskRequester,
|
|
962
912
|
init_task_requester,
|
|
963
913
|
handleApps,
|
|
@@ -966,8 +916,6 @@ import {
|
|
|
966
916
|
init_elements,
|
|
967
917
|
MAX_OBJECT_BYTES,
|
|
968
918
|
init_write_object,
|
|
969
|
-
cancelApprovalRequest,
|
|
970
|
-
init_approval_cancel,
|
|
971
919
|
getUserCommsPrefs,
|
|
972
920
|
init_requester_comms,
|
|
973
921
|
getTaskDetailsInputSchema,
|
|
@@ -994,12 +942,19 @@ import {
|
|
|
994
942
|
init_asset_key_auth,
|
|
995
943
|
getPageEditCounter,
|
|
996
944
|
init_page_versions,
|
|
997
|
-
snapshotPage,
|
|
998
|
-
init_version3,
|
|
999
945
|
DEFAULT_THEME_ID,
|
|
1000
946
|
THEME_PRESET_IDS,
|
|
1001
947
|
getThemePreset,
|
|
1002
948
|
init_presets,
|
|
949
|
+
DesignSystemError,
|
|
950
|
+
buildDesignSystem,
|
|
951
|
+
init_design_system,
|
|
952
|
+
getDesignSystem,
|
|
953
|
+
getActiveDesignSystem,
|
|
954
|
+
saveDesignSystem,
|
|
955
|
+
init_design_system2,
|
|
956
|
+
snapshotPage,
|
|
957
|
+
init_version3,
|
|
1003
958
|
readThemeFields,
|
|
1004
959
|
init_page_fields,
|
|
1005
960
|
assertOAuthAppUrlsSafe,
|
|
@@ -1064,13 +1019,13 @@ import {
|
|
|
1064
1019
|
getKapsoConfig,
|
|
1065
1020
|
getKapsoNumberMapping,
|
|
1066
1021
|
markKapsoMessageSeen,
|
|
1067
|
-
|
|
1022
|
+
init_config3,
|
|
1068
1023
|
changesMergePolicy,
|
|
1069
1024
|
init_repo_merge_policy,
|
|
1070
1025
|
updateSwarmRepoChecked,
|
|
1071
1026
|
init_repo_checked_update,
|
|
1072
1027
|
getCombConfig,
|
|
1073
|
-
|
|
1028
|
+
init_config4,
|
|
1074
1029
|
resolveRoomNamespace,
|
|
1075
1030
|
roomRequestInfo,
|
|
1076
1031
|
authorizeRoomNamespace,
|
|
@@ -1168,7 +1123,7 @@ import {
|
|
|
1168
1123
|
getEnabledCapabilities,
|
|
1169
1124
|
createServer,
|
|
1170
1125
|
init_server
|
|
1171
|
-
} from "./cli-
|
|
1126
|
+
} from "./cli-904wk98s.js";
|
|
1172
1127
|
import {
|
|
1173
1128
|
getFileStorageProvider2,
|
|
1174
1129
|
init_registry2
|
|
@@ -1194,9 +1149,8 @@ import {
|
|
|
1194
1149
|
resolvePoolDelivery2,
|
|
1195
1150
|
createPoolAgent2,
|
|
1196
1151
|
init_db2
|
|
1197
|
-
} from "./cli-
|
|
1152
|
+
} from "./cli-29h5239w.js";
|
|
1198
1153
|
import {
|
|
1199
|
-
duplicateGuardedQueryKey,
|
|
1200
1154
|
warnIfCorsAllowsAnyOrigin,
|
|
1201
1155
|
isOriginAllowedForCredentials,
|
|
1202
1156
|
allowedCredentialRedirect,
|
|
@@ -1219,7 +1173,6 @@ import {
|
|
|
1219
1173
|
deriveApiBaseUrl,
|
|
1220
1174
|
httpServerSemconvAttributes,
|
|
1221
1175
|
init_utils2,
|
|
1222
|
-
resolveTaskAuditUserId,
|
|
1223
1176
|
resolveHttpRequesterUserId,
|
|
1224
1177
|
resolveHttpAuditUserId,
|
|
1225
1178
|
resolveHttpAuditActor,
|
|
@@ -1245,7 +1198,7 @@ import {
|
|
|
1245
1198
|
describeRequestRoute,
|
|
1246
1199
|
route,
|
|
1247
1200
|
init_route_def
|
|
1248
|
-
} from "./cli-
|
|
1201
|
+
} from "./cli-404am6f3.js";
|
|
1249
1202
|
import {
|
|
1250
1203
|
startPoolRouting,
|
|
1251
1204
|
stopPoolRouting,
|
|
@@ -1258,39 +1211,29 @@ import {
|
|
|
1258
1211
|
checkHeartbeatChecklist2,
|
|
1259
1212
|
runHeartbeatSweep2,
|
|
1260
1213
|
stopHeartbeat2
|
|
1261
|
-
} from "./cli-
|
|
1262
|
-
import"./cli-
|
|
1214
|
+
} from "./cli-944w9wb4.js";
|
|
1215
|
+
import"./cli-p436yrzp.js";
|
|
1263
1216
|
import {
|
|
1264
1217
|
runtimeSupervisorStatus,
|
|
1265
1218
|
startRuntimeSupervisor,
|
|
1266
1219
|
stopRuntimeSupervisor
|
|
1267
|
-
} from "./cli-
|
|
1220
|
+
} from "./cli-ea7nz50q.js";
|
|
1268
1221
|
import {
|
|
1269
1222
|
TASK_TITLE_TIMEOUT_MS,
|
|
1270
1223
|
generateTaskTitle
|
|
1271
|
-
} from "./cli-
|
|
1224
|
+
} from "./cli-bv4vvnmg.js";
|
|
1272
1225
|
import"./cli-ns59dc6r.js";
|
|
1273
1226
|
import {
|
|
1274
1227
|
ACP_TARGET_IDS
|
|
1275
|
-
} from "./cli-
|
|
1228
|
+
} from "./cli-k0nebh10.js";
|
|
1276
1229
|
import {
|
|
1277
1230
|
reasoningCapability,
|
|
1278
1231
|
supportedReasoningLevels
|
|
1279
|
-
} from "./cli-
|
|
1232
|
+
} from "./cli-ywy8yz6t.js";
|
|
1280
1233
|
import {
|
|
1281
1234
|
MAX_RATE_LIMIT_RESET_MS,
|
|
1282
1235
|
MAX_SPEND_CAP_HOLD_MS
|
|
1283
|
-
} from "./cli-
|
|
1284
|
-
import {
|
|
1285
|
-
isLeadChannelMonitoringEnabled,
|
|
1286
|
-
ORG_IDENTITY_KEYS,
|
|
1287
|
-
orgIdentityStatus,
|
|
1288
|
-
SIMILARITY_THRESHOLD,
|
|
1289
|
-
memoryRelevance,
|
|
1290
|
-
isUnknownModelError,
|
|
1291
|
-
checkProviderPoolKey,
|
|
1292
|
-
writeSkillsToFilesystem
|
|
1293
|
-
} from "./cli-tgmate57.js";
|
|
1236
|
+
} from "./cli-fkpnx3vf.js";
|
|
1294
1237
|
import {
|
|
1295
1238
|
AgentFsRequestError2,
|
|
1296
1239
|
resolveAgentFsSharedContext2,
|
|
@@ -1301,16 +1244,24 @@ import {
|
|
|
1301
1244
|
agentFsRequest2,
|
|
1302
1245
|
resolveApiUrl2,
|
|
1303
1246
|
init_agent_fs_provision
|
|
1304
|
-
} from "./cli-
|
|
1247
|
+
} from "./cli-60dwk8tx.js";
|
|
1305
1248
|
import {
|
|
1306
1249
|
Anthropic
|
|
1307
1250
|
} from "./cli-cah298e5.js";
|
|
1251
|
+
import {
|
|
1252
|
+
isLeadChannelMonitoringEnabled,
|
|
1253
|
+
SIMILARITY_THRESHOLD,
|
|
1254
|
+
memoryRelevance,
|
|
1255
|
+
isUnknownModelError,
|
|
1256
|
+
checkProviderPoolKey,
|
|
1257
|
+
writeSkillsToFilesystem
|
|
1258
|
+
} from "./cli-hdhpdrka.js";
|
|
1308
1259
|
import {
|
|
1309
1260
|
objectWebhookSecret2,
|
|
1310
1261
|
handleObjectWebhookEvent2,
|
|
1311
1262
|
init_object_webhooks
|
|
1312
|
-
} from "./cli-
|
|
1313
|
-
import"./cli-
|
|
1263
|
+
} from "./cli-49aq3cyn.js";
|
|
1264
|
+
import"./cli-tsc3pdfd.js";
|
|
1314
1265
|
import {
|
|
1315
1266
|
createUserMergeJob2,
|
|
1316
1267
|
getUserMergeJob2,
|
|
@@ -1319,7 +1270,7 @@ import {
|
|
|
1319
1270
|
findFailedUserMergeJob2,
|
|
1320
1271
|
requeueUserMergeJob2,
|
|
1321
1272
|
runUserMergeJobs2
|
|
1322
|
-
} from "./cli-
|
|
1273
|
+
} from "./cli-5ashycw3.js";
|
|
1323
1274
|
import {
|
|
1324
1275
|
isCodexOAuthConfigKey
|
|
1325
1276
|
} from "./cli-j4bwnpkm.js";
|
|
@@ -1329,8 +1280,28 @@ import {
|
|
|
1329
1280
|
} from "./cli-9fzgd3hg.js";
|
|
1330
1281
|
import {
|
|
1331
1282
|
runTaskUiAction,
|
|
1332
|
-
init_actions
|
|
1333
|
-
|
|
1283
|
+
init_actions,
|
|
1284
|
+
globalConfig,
|
|
1285
|
+
init_global_config,
|
|
1286
|
+
telemetryProxyEndpoint,
|
|
1287
|
+
handleUsedBy,
|
|
1288
|
+
init_used_by,
|
|
1289
|
+
handleRanking,
|
|
1290
|
+
init_ranking,
|
|
1291
|
+
readsRepoSecrets,
|
|
1292
|
+
requestSecretReadScope,
|
|
1293
|
+
ensureConfigAdmin,
|
|
1294
|
+
runConfigWriteSideEffects,
|
|
1295
|
+
ensureHttpPermission,
|
|
1296
|
+
handleConfig,
|
|
1297
|
+
init_config,
|
|
1298
|
+
approvalResponder,
|
|
1299
|
+
responderKey,
|
|
1300
|
+
init_person_responder,
|
|
1301
|
+
handleApprovalRequests,
|
|
1302
|
+
init_approval_requests
|
|
1303
|
+
} from "./cli-hyqksecw.js";
|
|
1304
|
+
import"./cli-s33bzmk0.js";
|
|
1334
1305
|
import {
|
|
1335
1306
|
RATING_MODEL_MAX_LENGTH,
|
|
1336
1307
|
REFERENCES_SOURCE_MAX_LENGTH,
|
|
@@ -1426,7 +1397,7 @@ import {
|
|
|
1426
1397
|
init_typecheck,
|
|
1427
1398
|
parseSkillContent,
|
|
1428
1399
|
init_skill_parser
|
|
1429
|
-
} from "./cli-
|
|
1400
|
+
} from "./cli-gse7bp3z.js";
|
|
1430
1401
|
import {
|
|
1431
1402
|
signalProcessGroup,
|
|
1432
1403
|
detachedProcessGroup,
|
|
@@ -1443,17 +1414,17 @@ import {
|
|
|
1443
1414
|
forceRefreshAuthorizationOrThrow,
|
|
1444
1415
|
forceRefreshTokenOrThrow,
|
|
1445
1416
|
init_ensure_token
|
|
1446
|
-
} from "./cli-
|
|
1417
|
+
} from "./cli-jyhbvdga.js";
|
|
1447
1418
|
import {
|
|
1448
1419
|
PRIMITIVE_KINDS,
|
|
1449
1420
|
ObjectsError,
|
|
1450
1421
|
recordObjectVersion,
|
|
1451
1422
|
init_objects
|
|
1452
|
-
} from "./cli-
|
|
1423
|
+
} from "./cli-tr19nyn9.js";
|
|
1453
1424
|
import {
|
|
1454
1425
|
agentFsClientFor,
|
|
1455
1426
|
init_agent_fs_identity
|
|
1456
|
-
} from "./cli-
|
|
1427
|
+
} from "./cli-zhwjdhjr.js";
|
|
1457
1428
|
import {
|
|
1458
1429
|
FilesError,
|
|
1459
1430
|
normalizeFilesError,
|
|
@@ -1462,7 +1433,7 @@ import {
|
|
|
1462
1433
|
AgentFsProvider,
|
|
1463
1434
|
init_agent_fs_provider
|
|
1464
1435
|
} from "./cli-skd2c4ej.js";
|
|
1465
|
-
import"./cli-
|
|
1436
|
+
import"./cli-gtj12v95.js";
|
|
1466
1437
|
import {
|
|
1467
1438
|
automationIntegrationFixUrl,
|
|
1468
1439
|
preflightAutomation,
|
|
@@ -1484,7 +1455,7 @@ import {
|
|
|
1484
1455
|
definitionNodeIds,
|
|
1485
1456
|
validateDefinition,
|
|
1486
1457
|
init_definition2
|
|
1487
|
-
} from "./cli-
|
|
1458
|
+
} from "./cli-0p76my9q.js";
|
|
1488
1459
|
import {
|
|
1489
1460
|
_fetchHolder,
|
|
1490
1461
|
CLIENT_ID,
|
|
@@ -1500,7 +1471,7 @@ import {
|
|
|
1500
1471
|
loadAllCodexOAuthSlots,
|
|
1501
1472
|
getValidCodexOAuth,
|
|
1502
1473
|
init_storage
|
|
1503
|
-
} from "./cli-
|
|
1474
|
+
} from "./cli-2vp0z049.js";
|
|
1504
1475
|
import {
|
|
1505
1476
|
isMultiRuntimeEnabled,
|
|
1506
1477
|
init_multi_runtime2
|
|
@@ -1512,7 +1483,7 @@ import {
|
|
|
1512
1483
|
import {
|
|
1513
1484
|
createRuntimeProvider,
|
|
1514
1485
|
init_runtime_providers
|
|
1515
|
-
} from "./cli-
|
|
1486
|
+
} from "./cli-jbrc98qb.js";
|
|
1516
1487
|
import {
|
|
1517
1488
|
require_content_type
|
|
1518
1489
|
} from "./cli-1jx0srjt.js";
|
|
@@ -1526,7 +1497,7 @@ import {
|
|
|
1526
1497
|
toSessionSharesState,
|
|
1527
1498
|
setSessionShares,
|
|
1528
1499
|
init_session_shares
|
|
1529
|
-
} from "./cli-
|
|
1500
|
+
} from "./cli-pz1dp12c.js";
|
|
1530
1501
|
import {
|
|
1531
1502
|
isInvalidClientError,
|
|
1532
1503
|
publicEndpointSsrfOptions,
|
|
@@ -1544,12 +1515,8 @@ import {
|
|
|
1544
1515
|
revokeMcpToken,
|
|
1545
1516
|
computeExpiresAt,
|
|
1546
1517
|
init_mcp_wrapper
|
|
1547
|
-
} from "./cli-
|
|
1518
|
+
} from "./cli-ysv0k1we.js";
|
|
1548
1519
|
import"./cli-v41kn3cd.js";
|
|
1549
|
-
import {
|
|
1550
|
-
setBedrockProviderModule,
|
|
1551
|
-
init_bedrock_converse_stream_lazy
|
|
1552
|
-
} from "./cli-k3facve0.js";
|
|
1553
1520
|
import {
|
|
1554
1521
|
import_websocket,
|
|
1555
1522
|
import_websocket_server,
|
|
@@ -1584,7 +1551,7 @@ import {
|
|
|
1584
1551
|
revokeAllAgentSessionTokens,
|
|
1585
1552
|
fingerprintApiKey,
|
|
1586
1553
|
init_users
|
|
1587
|
-
} from "./cli-
|
|
1554
|
+
} from "./cli-kj84fqxz.js";
|
|
1588
1555
|
import {
|
|
1589
1556
|
CORE_TOOLS,
|
|
1590
1557
|
init_tool_config
|
|
@@ -1597,7 +1564,7 @@ import {
|
|
|
1597
1564
|
providerAccountTelemetrySchema,
|
|
1598
1565
|
rateLimitReplacementSchema,
|
|
1599
1566
|
init_provider_account_telemetry
|
|
1600
|
-
} from "./cli-
|
|
1567
|
+
} from "./cli-fw67mnyc.js";
|
|
1601
1568
|
import {
|
|
1602
1569
|
CODEX_AUTH_FAILURE_BENCH_THRESHOLD,
|
|
1603
1570
|
CODEX_AUTH_WATCH_NAMESPACE,
|
|
@@ -1612,11 +1579,11 @@ import {
|
|
|
1612
1579
|
IDENTITY_FIELD_BUDGETS,
|
|
1613
1580
|
IdentityFieldBudgetError,
|
|
1614
1581
|
init_identity_field_budget
|
|
1615
|
-
} from "./cli-
|
|
1582
|
+
} from "./cli-ka48vpev.js";
|
|
1616
1583
|
import {
|
|
1617
1584
|
getSlackConfiguration,
|
|
1618
|
-
|
|
1619
|
-
} from "./cli-
|
|
1585
|
+
init_config5
|
|
1586
|
+
} from "./cli-t9pzz2eq.js";
|
|
1620
1587
|
import {
|
|
1621
1588
|
isSteeringEnabled2,
|
|
1622
1589
|
init_steering_enabled
|
|
@@ -1640,7 +1607,7 @@ import {
|
|
|
1640
1607
|
splitCredentialPool,
|
|
1641
1608
|
selectCredential,
|
|
1642
1609
|
init_credentials2
|
|
1643
|
-
} from "./cli-
|
|
1610
|
+
} from "./cli-gkv0r2hq.js";
|
|
1644
1611
|
import {
|
|
1645
1612
|
interpolate,
|
|
1646
1613
|
init_template2,
|
|
@@ -1650,7 +1617,7 @@ import {
|
|
|
1650
1617
|
resolveTemplate,
|
|
1651
1618
|
init_resolver,
|
|
1652
1619
|
init_session_templates
|
|
1653
|
-
} from "./cli-
|
|
1620
|
+
} from "./cli-b768ek79.js";
|
|
1654
1621
|
import {
|
|
1655
1622
|
getOpenRouterAttributionHeaders,
|
|
1656
1623
|
init_openrouter_base_url
|
|
@@ -1741,7 +1708,6 @@ import {
|
|
|
1741
1708
|
AutomationIntegrationIdSchema,
|
|
1742
1709
|
ScheduledTaskTargetTypeSchema,
|
|
1743
1710
|
ScheduledTaskSchema,
|
|
1744
|
-
SwarmConfigSchema,
|
|
1745
1711
|
RepoGuidelinesInputSchema,
|
|
1746
1712
|
RepoHooksSchema,
|
|
1747
1713
|
SwarmRepoSchema,
|
|
@@ -1771,6 +1737,8 @@ import {
|
|
|
1771
1737
|
PageContentTypeSchema,
|
|
1772
1738
|
PageAuthModeSchema,
|
|
1773
1739
|
PageThemeTokensInputSchema,
|
|
1740
|
+
DesignSystemSchema,
|
|
1741
|
+
DesignSystemInputSchema,
|
|
1774
1742
|
PageSchema,
|
|
1775
1743
|
PageVersionSchema,
|
|
1776
1744
|
MetricWidgetSchema,
|
|
@@ -1828,14 +1796,13 @@ import {
|
|
|
1828
1796
|
KvKeySchema,
|
|
1829
1797
|
KvEntrySchema,
|
|
1830
1798
|
init_types5
|
|
1831
|
-
} from "./cli-
|
|
1799
|
+
} from "./cli-azj9t1f9.js";
|
|
1832
1800
|
import {
|
|
1833
1801
|
init_zod
|
|
1834
1802
|
} from "./cli-96234j5w.js";
|
|
1835
1803
|
import {
|
|
1836
1804
|
NEVER,
|
|
1837
1805
|
toJSONSchema,
|
|
1838
|
-
ZodError,
|
|
1839
1806
|
string2,
|
|
1840
1807
|
email,
|
|
1841
1808
|
uuid,
|
|
@@ -1882,7 +1849,7 @@ import {
|
|
|
1882
1849
|
import {
|
|
1883
1850
|
init_package,
|
|
1884
1851
|
package_default
|
|
1885
|
-
} from "./cli-
|
|
1852
|
+
} from "./cli-cq4am6vg.js";
|
|
1886
1853
|
import {
|
|
1887
1854
|
realtimeBus,
|
|
1888
1855
|
init_bus
|
|
@@ -1898,7 +1865,7 @@ import {
|
|
|
1898
1865
|
registerVolatileSecret,
|
|
1899
1866
|
registerEnvSecrets,
|
|
1900
1867
|
init_secret_scrubber
|
|
1901
|
-
} from "./cli-
|
|
1868
|
+
} from "./cli-1kvcsd2f.js";
|
|
1902
1869
|
import {
|
|
1903
1870
|
__toESM
|
|
1904
1871
|
} from "./cli-242037k3.js";
|
|
@@ -1945,10 +1912,6 @@ function installConsoleScrub() {
|
|
|
1945
1912
|
// src/utils/console-scrub-install.ts
|
|
1946
1913
|
installConsoleScrub();
|
|
1947
1914
|
|
|
1948
|
-
// src/utils/internal-ai/register-bedrock.ts
|
|
1949
|
-
init_bedrock_converse_stream_lazy();
|
|
1950
|
-
setBedrockProviderModule(bedrockProviderModule);
|
|
1951
|
-
|
|
1952
1915
|
// src/http/index.ts
|
|
1953
1916
|
init_server();
|
|
1954
1917
|
init_agentmail();
|
|
@@ -6405,6 +6368,7 @@ class LocalProcessScriptExecutor {
|
|
|
6405
6368
|
let proc;
|
|
6406
6369
|
let capabilitySocket;
|
|
6407
6370
|
let protocolFailure;
|
|
6371
|
+
let terminated = false;
|
|
6408
6372
|
const sockets = new Set;
|
|
6409
6373
|
const server = createServer2((socket) => {
|
|
6410
6374
|
sockets.add(socket);
|
|
@@ -6602,6 +6566,8 @@ class LocalProcessScriptExecutor {
|
|
|
6602
6566
|
clearInterval(heartbeat);
|
|
6603
6567
|
await terminateProcessGroup(spawned.pid);
|
|
6604
6568
|
let stderr = await stderrPromise;
|
|
6569
|
+
if (terminated)
|
|
6570
|
+
return { exitCode: processExitCode, stderr, terminated: true };
|
|
6605
6571
|
try {
|
|
6606
6572
|
if (protocolFailure)
|
|
6607
6573
|
throw protocolFailure;
|
|
@@ -6635,6 +6601,7 @@ class LocalProcessScriptExecutor {
|
|
|
6635
6601
|
startedAtMs: Date.now(),
|
|
6636
6602
|
exited,
|
|
6637
6603
|
terminate: async (signal = "SIGTERM") => {
|
|
6604
|
+
terminated = true;
|
|
6638
6605
|
built.abortInFlightSteps();
|
|
6639
6606
|
if (signal === "SIGTERM")
|
|
6640
6607
|
await terminateProcessGroup(spawned.pid);
|
|
@@ -6699,7 +6666,9 @@ async function startScriptRunProcess(run, baseUrl, apiKeyOverride) {
|
|
|
6699
6666
|
pid: execution.pid,
|
|
6700
6667
|
lastHeartbeatAt: new Date().toISOString()
|
|
6701
6668
|
});
|
|
6702
|
-
execution.exited.then(async ({ exitCode, stderr }) => {
|
|
6669
|
+
execution.exited.then(async ({ exitCode, stderr, terminated }) => {
|
|
6670
|
+
if (terminated)
|
|
6671
|
+
return;
|
|
6703
6672
|
const current = await getScriptRun2(run.id);
|
|
6704
6673
|
if (current && current.status === "running") {
|
|
6705
6674
|
if (exitCode !== 0) {
|
|
@@ -10181,1623 +10150,8 @@ async function handleApiKeys(req, res, pathSegments, queryParams) {
|
|
|
10181
10150
|
return false;
|
|
10182
10151
|
}
|
|
10183
10152
|
|
|
10184
|
-
// src/http/approval-requests.ts
|
|
10185
|
-
init_zod();
|
|
10186
|
-
init_approval_config_question();
|
|
10187
|
-
init_audit_user();
|
|
10188
|
-
init_db4();
|
|
10189
|
-
init_rbac_roles();
|
|
10190
|
-
init_users();
|
|
10191
|
-
init_rbac();
|
|
10192
|
-
init_request_auth_context();
|
|
10193
|
-
init_secret_scrubber();
|
|
10194
|
-
init_approval_cancel();
|
|
10195
|
-
init_approval_notifications();
|
|
10196
|
-
init_event_bus();
|
|
10197
|
-
|
|
10198
|
-
// src/http/config.ts
|
|
10199
|
-
init_zod();
|
|
10200
|
-
init_db4();
|
|
10201
|
-
init_model_profiles();
|
|
10202
|
-
init_model_profile_check();
|
|
10203
|
-
init_multi_runtime();
|
|
10204
|
-
|
|
10205
|
-
// src/be/org-profile.ts
|
|
10206
|
-
init_org_website();
|
|
10207
|
-
init_db4();
|
|
10208
|
-
var LOGO_KEY = "SWARM_ORG_LOGO_URL";
|
|
10209
|
-
var FILLED_LOGO_KEY = "SWARM_ORG_LOGO_FILLED_URL";
|
|
10210
|
-
async function globalValue(key) {
|
|
10211
|
-
const stored = (await getSwarmConfigs2({ scope: "global", key }))?.[0]?.value?.trim();
|
|
10212
|
-
return stored || process.env[key]?.trim() || "";
|
|
10213
|
-
}
|
|
10214
|
-
async function fillOrgLogoFromWebsite(website) {
|
|
10215
|
-
const host = normalizeOrgWebsite(website);
|
|
10216
|
-
if (!host)
|
|
10217
|
-
return false;
|
|
10218
|
-
const current = await globalValue(LOGO_KEY);
|
|
10219
|
-
if (current && !(isFilledOrgLogoUrl(current) && current === await globalValue(FILLED_LOGO_KEY))) {
|
|
10220
|
-
return false;
|
|
10221
|
-
}
|
|
10222
|
-
const next = orgLogoUrl(host);
|
|
10223
|
-
if (current === next)
|
|
10224
|
-
return false;
|
|
10225
|
-
await upsertSwarmConfig2({ scope: "global", key: LOGO_KEY, value: next, isSecret: false });
|
|
10226
|
-
await upsertSwarmConfig2({ scope: "global", key: FILLED_LOGO_KEY, value: next, isSecret: false });
|
|
10227
|
-
return true;
|
|
10228
|
-
}
|
|
10229
|
-
|
|
10230
|
-
// src/http/config.ts
|
|
10231
|
-
init_rbac_roles();
|
|
10232
|
-
init_swarm_config_guard();
|
|
10233
|
-
init_users();
|
|
10234
|
-
init_rbac();
|
|
10235
|
-
init_reaction_shortcode();
|
|
10236
|
-
init_types5();
|
|
10237
|
-
init_request_auth_context();
|
|
10238
|
-
init_secret_scrubber();
|
|
10239
|
-
init_core();
|
|
10240
|
-
|
|
10241
|
-
// src/http/ranking.ts
|
|
10242
|
-
init_zod();
|
|
10243
|
-
init_db4();
|
|
10244
|
-
init_telemetry_ranking();
|
|
10245
|
-
init_telemetry();
|
|
10246
|
-
init_env_flag();
|
|
10247
|
-
init_core();
|
|
10248
|
-
|
|
10249
|
-
// src/http/global-config.ts
|
|
10250
|
-
init_db4();
|
|
10251
|
-
async function globalConfig(key) {
|
|
10252
|
-
const stored = (await getSwarmConfigs2({ scope: "global", key }))?.[0]?.value;
|
|
10253
|
-
return (stored ?? process.env[key])?.trim() || undefined;
|
|
10254
|
-
}
|
|
10255
|
-
|
|
10256
|
-
// src/http/ranking.ts
|
|
10257
|
-
init_route_def();
|
|
10258
|
-
|
|
10259
|
-
// src/http/used-by.ts
|
|
10260
|
-
init_zod();
|
|
10261
|
-
init_db4();
|
|
10262
|
-
init_telemetry();
|
|
10263
|
-
init_company_profile();
|
|
10264
|
-
init_org_website();
|
|
10265
|
-
init_core();
|
|
10266
|
-
init_favorite_owner();
|
|
10267
|
-
init_route_def();
|
|
10268
|
-
init_utils2();
|
|
10269
|
-
var CONSENT_KEY = "SWARM_USED_BY_CONSENT";
|
|
10270
|
-
var CONSENT_AT_KEY = "SWARM_USED_BY_CONSENT_AT";
|
|
10271
|
-
var GRANTED_NAME_KEY = "SWARM_USED_BY_ORG_NAME";
|
|
10272
|
-
var GRANTED_WEBSITE_KEY = "SWARM_USED_BY_ORG_WEBSITE";
|
|
10273
|
-
var CONTACT_EMAIL_KEY = "SWARM_USED_BY_CONTACT_EMAIL";
|
|
10274
|
-
var CONTACT_FUNCTION_KEY = "SWARM_USED_BY_CONTACT_FUNCTION";
|
|
10275
|
-
var QUOTE_KEY = "SWARM_USED_BY_QUOTE";
|
|
10276
|
-
var TIMEOUT_MS = 1e4;
|
|
10277
|
-
var usedBy = route({
|
|
10278
|
-
method: "post",
|
|
10279
|
-
path: "/api/used-by",
|
|
10280
|
-
pattern: ["api", "used-by"],
|
|
10281
|
-
summary: "Grant or revoke the 'used by' logo consent",
|
|
10282
|
-
description: "Records consent to show the organization's logo on agent-swarm.dev. A grant requires a valid contact email. It sends organization identity, contact details, and an optional quote to the proxy for manual review. This explicit admin action works when telemetry is off. A revoke clears the stored contact details and quote.",
|
|
10283
|
-
tags: ["Telemetry"],
|
|
10284
|
-
body: object2({
|
|
10285
|
-
granted: boolean(),
|
|
10286
|
-
contactEmail: string2().max(320, "Contact email must be at most 320 characters").email("Contact email must be a valid email address").optional(),
|
|
10287
|
-
contactFunction: _enum2(USER_FUNCTIONS).optional(),
|
|
10288
|
-
quote: string2().max(280).optional()
|
|
10289
|
-
}).refine((body) => !body.granted || body.contactEmail !== undefined, {
|
|
10290
|
-
path: ["contactEmail"],
|
|
10291
|
-
message: "Contact email is required when granting logo consent"
|
|
10292
|
-
}),
|
|
10293
|
-
responses: {
|
|
10294
|
-
200: {
|
|
10295
|
-
description: "Consent recorded",
|
|
10296
|
-
schema: object2({ granted: boolean(), changedAt: string2() })
|
|
10297
|
-
},
|
|
10298
|
-
400: {
|
|
10299
|
-
description: "Invalid contact details, or missing organization name or website"
|
|
10300
|
-
},
|
|
10301
|
-
401: { description: "Unauthorized" },
|
|
10302
|
-
403: { description: "Only a config admin can change the consent" },
|
|
10303
|
-
502: { description: "The telemetry proxy did not accept the consent" }
|
|
10304
|
-
},
|
|
10305
|
-
rbac: { permission: "config.write.any" }
|
|
10306
|
-
});
|
|
10307
|
-
async function telemetryProxyEndpoint(path) {
|
|
10308
|
-
const feedback = await globalConfig("feedback_endpoint");
|
|
10309
|
-
if (feedback && /^https?:\/\/[^/]+\/v1\/feedback\/?$/.test(feedback)) {
|
|
10310
|
-
return feedback.replace(/\/v1\/feedback\/?$/, path);
|
|
10311
|
-
}
|
|
10312
|
-
return `${TELEMETRY_PROXY_ORIGIN}${path}`;
|
|
10313
|
-
}
|
|
10314
|
-
function usedByEndpoint() {
|
|
10315
|
-
return telemetryProxyEndpoint("/v1/used-by");
|
|
10316
|
-
}
|
|
10317
|
-
async function handleUsedBy(req, res, pathSegments, queryParams, myAgentId) {
|
|
10318
|
-
if (!usedBy.match(req.method, pathSegments))
|
|
10319
|
-
return false;
|
|
10320
|
-
const parsed = await usedBy.parse(req, res, pathSegments, queryParams);
|
|
10321
|
-
if (!parsed)
|
|
10322
|
-
return true;
|
|
10323
|
-
if (!await ensureConfigAdmin(req, res, "config.write.any"))
|
|
10324
|
-
return true;
|
|
10325
|
-
const { granted, contactEmail, contactFunction, quote } = parsed.body;
|
|
10326
|
-
const current = orgIdentityStatus({
|
|
10327
|
-
SWARM_ORG_NAME: await globalConfig("SWARM_ORG_NAME"),
|
|
10328
|
-
SWARM_ORG_WEBSITE: await globalConfig("SWARM_ORG_WEBSITE")
|
|
10329
|
-
});
|
|
10330
|
-
const currentName = current.name ?? undefined;
|
|
10331
|
-
const currentWebsite = current.website;
|
|
10332
|
-
const grantedName = granted ? undefined : await globalConfig(GRANTED_NAME_KEY);
|
|
10333
|
-
const grantedWebsite = granted ? null : normalizeOrgWebsite(await globalConfig(GRANTED_WEBSITE_KEY));
|
|
10334
|
-
const [orgName, orgWebsite] = grantedName && grantedWebsite ? [grantedName, grantedWebsite] : [currentName, currentWebsite];
|
|
10335
|
-
if (!orgName || !orgWebsite) {
|
|
10336
|
-
jsonError(res, "Set the organization name and website first", 400);
|
|
10337
|
-
return true;
|
|
10338
|
-
}
|
|
10339
|
-
const installId = isTelemetryEnabled() ? await globalConfig("telemetry_installation_id") : undefined;
|
|
10340
|
-
const orgDomain = await globalConfig("telemetry_org_domain");
|
|
10341
|
-
const changedAt = new Date().toISOString();
|
|
10342
|
-
try {
|
|
10343
|
-
const response = await fetch(await usedByEndpoint(), {
|
|
10344
|
-
method: "POST",
|
|
10345
|
-
headers: { "Content-Type": "application/json" },
|
|
10346
|
-
body: JSON.stringify({
|
|
10347
|
-
...installId ? { install_id: installId } : {},
|
|
10348
|
-
org_name: orgName,
|
|
10349
|
-
org_website: orgWebsite,
|
|
10350
|
-
...orgDomain ? { org_domain: orgDomain } : {},
|
|
10351
|
-
granted,
|
|
10352
|
-
...granted ? {
|
|
10353
|
-
contact_email: contactEmail,
|
|
10354
|
-
contact_function: reportedUserFunction(contactFunction),
|
|
10355
|
-
quote
|
|
10356
|
-
} : {},
|
|
10357
|
-
changed_at: changedAt
|
|
10358
|
-
}),
|
|
10359
|
-
signal: AbortSignal.timeout(TIMEOUT_MS)
|
|
10360
|
-
});
|
|
10361
|
-
if (!response.ok) {
|
|
10362
|
-
jsonError(res, `The telemetry proxy answered ${response.status}`, 502);
|
|
10363
|
-
return true;
|
|
10364
|
-
}
|
|
10365
|
-
} catch {
|
|
10366
|
-
jsonError(res, "Could not reach the telemetry proxy", 502);
|
|
10367
|
-
return true;
|
|
10368
|
-
}
|
|
10369
|
-
await getDbClient2().transaction(async () => {
|
|
10370
|
-
await upsertSwarmConfig2({ scope: "global", key: CONSENT_KEY, value: String(granted) });
|
|
10371
|
-
await upsertSwarmConfig2({ scope: "global", key: CONSENT_AT_KEY, value: changedAt });
|
|
10372
|
-
if (granted) {
|
|
10373
|
-
await upsertSwarmConfig2({ scope: "global", key: GRANTED_NAME_KEY, value: orgName });
|
|
10374
|
-
await upsertSwarmConfig2({ scope: "global", key: GRANTED_WEBSITE_KEY, value: orgWebsite });
|
|
10375
|
-
}
|
|
10376
|
-
for (const [key, value, isSecret] of [
|
|
10377
|
-
[CONTACT_EMAIL_KEY, contactEmail, true],
|
|
10378
|
-
[CONTACT_FUNCTION_KEY, contactFunction, false],
|
|
10379
|
-
[QUOTE_KEY, quote, false]
|
|
10380
|
-
]) {
|
|
10381
|
-
await upsertSwarmConfig2({
|
|
10382
|
-
scope: "global",
|
|
10383
|
-
key,
|
|
10384
|
-
value: granted ? value ?? "" : "",
|
|
10385
|
-
isSecret,
|
|
10386
|
-
exportToEnv: false
|
|
10387
|
-
});
|
|
10388
|
-
}
|
|
10389
|
-
});
|
|
10390
|
-
scheduleIntegrationsReload2();
|
|
10391
|
-
const owner = await resolveHttpFavoriteOwner(req, myAgentId);
|
|
10392
|
-
trackRelayed("used_by.consent_changed", {
|
|
10393
|
-
granted,
|
|
10394
|
-
has_quote: granted && Boolean(quote),
|
|
10395
|
-
has_function: granted && Boolean(contactFunction)
|
|
10396
|
-
}, { actor: owner?.userId ? { userId: owner.userId } : undefined, emitter: "ui" });
|
|
10397
|
-
usedBy.respond(res, 200, { granted, changedAt });
|
|
10398
|
-
return true;
|
|
10399
|
-
}
|
|
10400
|
-
|
|
10401
|
-
// src/http/ranking.ts
|
|
10402
|
-
var ListingSchema = object2({
|
|
10403
|
-
v: literal2(1),
|
|
10404
|
-
name: string2(),
|
|
10405
|
-
domain: string2(),
|
|
10406
|
-
category: _enum2(RANKING_CATEGORIES),
|
|
10407
|
-
subcategory: string2().nullable(),
|
|
10408
|
-
description: string2().nullable(),
|
|
10409
|
-
sourceCodeUrl: string2().nullable(),
|
|
10410
|
-
updatedAt: string2()
|
|
10411
|
-
});
|
|
10412
|
-
var RankingStateSchema = object2({
|
|
10413
|
-
eligible: boolean(),
|
|
10414
|
-
missing: array2(_enum2(ORG_IDENTITY_KEYS)),
|
|
10415
|
-
telemetryOn: boolean(),
|
|
10416
|
-
enabled: boolean(),
|
|
10417
|
-
name: string2().nullable(),
|
|
10418
|
-
domain: string2().nullable(),
|
|
10419
|
-
listing: ListingSchema.nullable(),
|
|
10420
|
-
listingMatchesDomain: boolean(),
|
|
10421
|
-
verifyUrl: string2().nullable()
|
|
10422
|
-
});
|
|
10423
|
-
var OptInResponseSchema = object2({
|
|
10424
|
-
domain: string2(),
|
|
10425
|
-
listing: ListingSchema,
|
|
10426
|
-
verifyUrl: string2()
|
|
10427
|
-
});
|
|
10428
|
-
var OptOutResponseSchema = object2({
|
|
10429
|
-
enabled: literal2(false)
|
|
10430
|
-
});
|
|
10431
|
-
var getRanking = route({
|
|
10432
|
-
method: "get",
|
|
10433
|
-
path: "/api/ranking",
|
|
10434
|
-
pattern: ["api", "ranking"],
|
|
10435
|
-
summary: "Public ranking state",
|
|
10436
|
-
description: "Whether this install can join the public agent-swarm.dev ranking (telemetry on, organization name and website set), whether it is opted in, and its stored listing. Only a config admin can read it.",
|
|
10437
|
-
tags: ["Telemetry"],
|
|
10438
|
-
responses: {
|
|
10439
|
-
200: { description: "Ranking state", schema: RankingStateSchema },
|
|
10440
|
-
401: { description: "Unauthorized" },
|
|
10441
|
-
403: { description: "Only a config admin can read the ranking state" }
|
|
10442
|
-
},
|
|
10443
|
-
rbac: { permission: "config.write.any" }
|
|
10444
|
-
});
|
|
10445
|
-
var optIn = route({
|
|
10446
|
-
method: "post",
|
|
10447
|
-
path: "/api/ranking/opt-in",
|
|
10448
|
-
pattern: ["api", "ranking", "opt-in"],
|
|
10449
|
-
summary: "Opt this install into the public ranking",
|
|
10450
|
-
description: "Builds the telemetry_ranking listing from the organization name and website plus the chosen category, stores it, turns PUBLIC_RANKING_ENABLED on and sends ranking.opted_in. That is the whole opt-in: the install shows on agent-swarm.dev/ranking at the next hourly refresh.",
|
|
10451
|
-
tags: ["Telemetry"],
|
|
10452
|
-
body: rankingFormSchema,
|
|
10453
|
-
responses: {
|
|
10454
|
-
200: { description: "Opted in", schema: OptInResponseSchema },
|
|
10455
|
-
400: { description: "A listing field is invalid" },
|
|
10456
|
-
401: { description: "Unauthorized" },
|
|
10457
|
-
403: { description: "Only a config admin can opt in" },
|
|
10458
|
-
409: {
|
|
10459
|
-
description: "telemetry_off: telemetry is off or the install has no ID. org_identity_missing: the organization name or website is not set (`missing` lists which)."
|
|
10460
|
-
}
|
|
10461
|
-
},
|
|
10462
|
-
rbac: { permission: "config.write.any" }
|
|
10463
|
-
});
|
|
10464
|
-
var optOut = route({
|
|
10465
|
-
method: "post",
|
|
10466
|
-
path: "/api/ranking/opt-out",
|
|
10467
|
-
pattern: ["api", "ranking", "opt-out"],
|
|
10468
|
-
summary: "Leave the public ranking",
|
|
10469
|
-
description: "Turns PUBLIC_RANKING_ENABLED off and sends ranking.opted_out, so workers stop sending ranking.usage. The install leaves agent-swarm.dev/ranking at the next hourly refresh.",
|
|
10470
|
-
tags: ["Telemetry"],
|
|
10471
|
-
responses: {
|
|
10472
|
-
200: { description: "Opted out", schema: OptOutResponseSchema },
|
|
10473
|
-
401: { description: "Unauthorized" },
|
|
10474
|
-
403: { description: "Only a config admin can opt out" }
|
|
10475
|
-
},
|
|
10476
|
-
rbac: { permission: "config.write.any" }
|
|
10477
|
-
});
|
|
10478
|
-
var RANKING_CONFIG_KEYS = new Set([...ORG_IDENTITY_KEYS, PUBLIC_RANKING_ENABLED_KEY]);
|
|
10479
|
-
async function currentIdentity(changed) {
|
|
10480
|
-
const read = async (key) => changed?.key === key ? changed.value : await globalConfig(key);
|
|
10481
|
-
return orgIdentityStatus({
|
|
10482
|
-
SWARM_ORG_NAME: await read("SWARM_ORG_NAME"),
|
|
10483
|
-
SWARM_ORG_WEBSITE: await read("SWARM_ORG_WEBSITE")
|
|
10484
|
-
});
|
|
10485
|
-
}
|
|
10486
|
-
async function storedListing() {
|
|
10487
|
-
return readTelemetryRanking(await globalConfig(TELEMETRY_RANKING_KEY));
|
|
10488
|
-
}
|
|
10489
|
-
async function rankingEnabled() {
|
|
10490
|
-
const raw = await globalConfig(PUBLIC_RANKING_ENABLED_KEY);
|
|
10491
|
-
return isEnvFlagEnabled(PUBLIC_RANKING_ENABLED_KEY, false, {
|
|
10492
|
-
[PUBLIC_RANKING_ENABLED_KEY]: raw
|
|
10493
|
-
});
|
|
10494
|
-
}
|
|
10495
|
-
async function telemetryReady() {
|
|
10496
|
-
return isTelemetryEnabled() && Boolean(await globalConfig("telemetry_installation_id"));
|
|
10497
|
-
}
|
|
10498
|
-
async function verifyUrl(domain) {
|
|
10499
|
-
const params = new URLSearchParams({ domain });
|
|
10500
|
-
return `${await telemetryProxyEndpoint("/v1/ranking/verify")}?${params.toString()}`;
|
|
10501
|
-
}
|
|
10502
|
-
function withoutClaim(listing) {
|
|
10503
|
-
const { claim: _claim, ...rest } = listing;
|
|
10504
|
-
return rest;
|
|
10505
|
-
}
|
|
10506
|
-
async function setEnabled(enabled) {
|
|
10507
|
-
await upsertSwarmConfig2({
|
|
10508
|
-
scope: "global",
|
|
10509
|
-
key: PUBLIC_RANKING_ENABLED_KEY,
|
|
10510
|
-
value: String(enabled)
|
|
10511
|
-
});
|
|
10512
|
-
}
|
|
10513
|
-
function emitOptedIn(listing) {
|
|
10514
|
-
telemetry.ranking("opted_in", { listing: JSON.stringify(withoutClaim(listing)) }, { orgName: listing.name, orgWebsite: listing.domain });
|
|
10515
|
-
}
|
|
10516
|
-
function emitOptedOut(domain) {
|
|
10517
|
-
telemetry.ranking("opted_out", { domain });
|
|
10518
|
-
}
|
|
10519
|
-
async function buildRankingState() {
|
|
10520
|
-
const [identity, listing, enabled, telemetryOn] = await Promise.all([
|
|
10521
|
-
currentIdentity(),
|
|
10522
|
-
storedListing(),
|
|
10523
|
-
rankingEnabled(),
|
|
10524
|
-
telemetryReady()
|
|
10525
|
-
]);
|
|
10526
|
-
const listingMatchesDomain = Boolean(listing && listing.domain === identity.website);
|
|
10527
|
-
const current = listingMatchesDomain ? listing : null;
|
|
10528
|
-
return {
|
|
10529
|
-
eligible: telemetryOn && identity.ok,
|
|
10530
|
-
missing: identity.missing,
|
|
10531
|
-
telemetryOn,
|
|
10532
|
-
enabled: enabled && listingMatchesDomain,
|
|
10533
|
-
name: identity.name,
|
|
10534
|
-
domain: identity.website,
|
|
10535
|
-
listing: listing ? withoutClaim(listing) : null,
|
|
10536
|
-
listingMatchesDomain,
|
|
10537
|
-
verifyUrl: current ? await verifyUrl(current.domain) : null
|
|
10538
|
-
};
|
|
10539
|
-
}
|
|
10540
|
-
async function syncRankingAfterConfigChange(key, value) {
|
|
10541
|
-
if (!RANKING_CONFIG_KEYS.has(key))
|
|
10542
|
-
return;
|
|
10543
|
-
const listing = await storedListing();
|
|
10544
|
-
if (!listing)
|
|
10545
|
-
return;
|
|
10546
|
-
if (key === PUBLIC_RANKING_ENABLED_KEY) {
|
|
10547
|
-
if (!isEnvFlagEnabled(key, false, { [key]: value ?? undefined })) {
|
|
10548
|
-
emitOptedOut(listing.domain);
|
|
10549
|
-
}
|
|
10550
|
-
return;
|
|
10551
|
-
}
|
|
10552
|
-
if (!await rankingEnabled())
|
|
10553
|
-
return;
|
|
10554
|
-
const identity = await currentIdentity({ key, value });
|
|
10555
|
-
let rebuilt = null;
|
|
10556
|
-
if (identity.ok && identity.website === listing.domain) {
|
|
10557
|
-
if (identity.name === listing.name)
|
|
10558
|
-
return;
|
|
10559
|
-
try {
|
|
10560
|
-
rebuilt = buildListing(identity, listing);
|
|
10561
|
-
} catch {}
|
|
10562
|
-
}
|
|
10563
|
-
if (!rebuilt) {
|
|
10564
|
-
await setEnabled(false);
|
|
10565
|
-
emitOptedOut(listing.domain);
|
|
10566
|
-
return;
|
|
10567
|
-
}
|
|
10568
|
-
await upsertSwarmConfig2({
|
|
10569
|
-
scope: "global",
|
|
10570
|
-
key: TELEMETRY_RANKING_KEY,
|
|
10571
|
-
value: JSON.stringify(rebuilt)
|
|
10572
|
-
});
|
|
10573
|
-
emitOptedIn(rebuilt);
|
|
10574
|
-
}
|
|
10575
|
-
function conflict(res, body) {
|
|
10576
|
-
res.writeHead(409, { "Content-Type": "application/json" });
|
|
10577
|
-
res.end(JSON.stringify(body));
|
|
10578
|
-
}
|
|
10579
|
-
async function handleRanking(req, res, pathSegments, queryParams) {
|
|
10580
|
-
if (getRanking.match(req.method, pathSegments)) {
|
|
10581
|
-
const parsed = await getRanking.parse(req, res, pathSegments, queryParams);
|
|
10582
|
-
if (!parsed)
|
|
10583
|
-
return true;
|
|
10584
|
-
if (!await ensureConfigAdmin(req, res, "config.write.any"))
|
|
10585
|
-
return true;
|
|
10586
|
-
getRanking.respond(res, 200, await buildRankingState());
|
|
10587
|
-
return true;
|
|
10588
|
-
}
|
|
10589
|
-
if (optIn.match(req.method, pathSegments)) {
|
|
10590
|
-
const parsed = await optIn.parse(req, res, pathSegments, queryParams);
|
|
10591
|
-
if (!parsed)
|
|
10592
|
-
return true;
|
|
10593
|
-
if (!await ensureConfigAdmin(req, res, "config.write.any"))
|
|
10594
|
-
return true;
|
|
10595
|
-
if (!await telemetryReady()) {
|
|
10596
|
-
conflict(res, {
|
|
10597
|
-
error: "telemetry_off",
|
|
10598
|
-
message: "Turn telemetry on first: the ranking counts tokens from telemetry."
|
|
10599
|
-
});
|
|
10600
|
-
return true;
|
|
10601
|
-
}
|
|
10602
|
-
const identity = await currentIdentity();
|
|
10603
|
-
if (!identity.ok || !identity.website) {
|
|
10604
|
-
conflict(res, {
|
|
10605
|
-
error: "org_identity_missing",
|
|
10606
|
-
message: "Set the organization name and website first",
|
|
10607
|
-
missing: identity.missing
|
|
10608
|
-
});
|
|
10609
|
-
return true;
|
|
10610
|
-
}
|
|
10611
|
-
const db = getDbClient2();
|
|
10612
|
-
const built = await db.transaction(async () => {
|
|
10613
|
-
let listing;
|
|
10614
|
-
try {
|
|
10615
|
-
listing = buildListing(identity, parsed.body);
|
|
10616
|
-
} catch (error) {
|
|
10617
|
-
return { ok: false, error };
|
|
10618
|
-
}
|
|
10619
|
-
await upsertSwarmConfig2({
|
|
10620
|
-
scope: "global",
|
|
10621
|
-
key: TELEMETRY_RANKING_KEY,
|
|
10622
|
-
value: JSON.stringify(listing)
|
|
10623
|
-
});
|
|
10624
|
-
await setEnabled(true);
|
|
10625
|
-
db.afterCommit(() => emitOptedIn(listing));
|
|
10626
|
-
return { ok: true, listing };
|
|
10627
|
-
});
|
|
10628
|
-
if (!built.ok) {
|
|
10629
|
-
const issue = built.error instanceof ZodError ? built.error.issues[0] : undefined;
|
|
10630
|
-
res.writeHead(400, { "Content-Type": "application/json" });
|
|
10631
|
-
res.end(JSON.stringify({
|
|
10632
|
-
error: issue ? `Invalid ${issue.path.join(".") || "listing"}: ${issue.message}` : "Invalid listing"
|
|
10633
|
-
}));
|
|
10634
|
-
return true;
|
|
10635
|
-
}
|
|
10636
|
-
const { listing } = built;
|
|
10637
|
-
scheduleIntegrationsReload2();
|
|
10638
|
-
optIn.respond(res, 200, {
|
|
10639
|
-
domain: listing.domain,
|
|
10640
|
-
listing,
|
|
10641
|
-
verifyUrl: await verifyUrl(listing.domain)
|
|
10642
|
-
});
|
|
10643
|
-
return true;
|
|
10644
|
-
}
|
|
10645
|
-
if (optOut.match(req.method, pathSegments)) {
|
|
10646
|
-
const parsed = await optOut.parse(req, res, pathSegments, queryParams);
|
|
10647
|
-
if (!parsed)
|
|
10648
|
-
return true;
|
|
10649
|
-
if (!await ensureConfigAdmin(req, res, "config.write.any"))
|
|
10650
|
-
return true;
|
|
10651
|
-
const listing = await storedListing();
|
|
10652
|
-
await setEnabled(false);
|
|
10653
|
-
if (listing)
|
|
10654
|
-
emitOptedOut(listing.domain);
|
|
10655
|
-
scheduleIntegrationsReload2();
|
|
10656
|
-
optOut.respond(res, 200, { enabled: false });
|
|
10657
|
-
return true;
|
|
10658
|
-
}
|
|
10659
|
-
return false;
|
|
10660
|
-
}
|
|
10661
|
-
|
|
10662
|
-
// src/http/config.ts
|
|
10663
|
-
init_request_principal();
|
|
10664
|
-
init_route_def();
|
|
10665
|
-
init_utils2();
|
|
10666
|
-
var MAX_ENV_PRESENCE_KEYS = 200;
|
|
10667
|
-
var SECRETS_FORCE_MASK_NOTE = " (secret values masked: this token cannot read secrets in this scope)";
|
|
10668
|
-
function stripApiOnlyKeys(configs) {
|
|
10669
|
-
return configs.filter((config) => !isApiOnlyConfigKey(config.key) && !isInternalConfigKey(config.key));
|
|
10670
|
-
}
|
|
10671
|
-
function singleHeader(req, name) {
|
|
10672
|
-
const raw = req.headers[name];
|
|
10673
|
-
return Array.isArray(raw) ? raw[0] : raw;
|
|
10674
|
-
}
|
|
10675
|
-
function readsRepoSecrets(auth, agent) {
|
|
10676
|
-
if (auth?.kind !== "agent" || !auth.runtimeId)
|
|
10677
|
-
return true;
|
|
10678
|
-
return runtimeReadsRepoSecrets({ id: auth.agentId, isLead: agent?.isLead });
|
|
10679
|
-
}
|
|
10680
|
-
async function requestSecretReadScope(req, resolvedScope) {
|
|
10681
|
-
const principal = await requestPrincipal(req, undefined);
|
|
10682
|
-
if (!principal || principal.kind === "operator")
|
|
10683
|
-
return "all";
|
|
10684
|
-
if (principal.kind === "guest")
|
|
10685
|
-
return "none";
|
|
10686
|
-
if (principal.kind === "agent") {
|
|
10687
|
-
if (can({
|
|
10688
|
-
principal,
|
|
10689
|
-
verb: "config.read.secrets",
|
|
10690
|
-
resource: { kind: "none" },
|
|
10691
|
-
source: "http"
|
|
10692
|
-
}).allow)
|
|
10693
|
-
return "all";
|
|
10694
|
-
const auth = getRequestAuth(req);
|
|
10695
|
-
if (auth?.kind === "agent" && auth.tokenKind === "task" || resolvedScope?.agentId !== principal.agentId)
|
|
10696
|
-
return "none";
|
|
10697
|
-
return "self";
|
|
10698
|
-
}
|
|
10699
|
-
if (!isRbacEnabled())
|
|
10700
|
-
return "all";
|
|
10701
|
-
const grant = await getUserGrant2(principal.userId);
|
|
10702
|
-
return grant.grantsAll || grant.verbs.has("config.read.secrets") ? "all" : "none";
|
|
10703
|
-
}
|
|
10704
|
-
async function resolveSecretsRead(req, includeSecrets, resolvedScope) {
|
|
10705
|
-
const scope = await requestSecretReadScope(req, resolvedScope);
|
|
10706
|
-
const auth = getRequestAuth(req);
|
|
10707
|
-
return {
|
|
10708
|
-
effectiveIncludeSecrets: includeSecrets && scope !== "none",
|
|
10709
|
-
includeRepoSecrets: !(auth?.kind === "agent" && auth.tokenKind !== "task" && scope !== "all"),
|
|
10710
|
-
secretsNote: includeSecrets && scope === "none" ? SECRETS_FORCE_MASK_NOTE : ""
|
|
10711
|
-
};
|
|
10712
|
-
}
|
|
10713
|
-
async function scriptRunHeldConfigIds(req) {
|
|
10714
|
-
const auth = getRequestAuth(req);
|
|
10715
|
-
if (auth?.kind !== "agent" || auth.tokenKind !== "agent")
|
|
10716
|
-
return;
|
|
10717
|
-
if (!await isScriptRunToken(auth.tokenId))
|
|
10718
|
-
return;
|
|
10719
|
-
const held = stripApiOnlyKeys(await getResolvedConfig2(auth.agentId, undefined, { includeRepoSecrets: false }));
|
|
10720
|
-
return new Set(held.map((config) => config.id));
|
|
10721
|
-
}
|
|
10722
|
-
async function maskConfigRead(req, configs, includeSecrets) {
|
|
10723
|
-
const { effectiveIncludeSecrets, secretsNote } = await resolveSecretsRead(req, includeSecrets);
|
|
10724
|
-
const held = includeSecrets && !effectiveIncludeSecrets ? await scriptRunHeldConfigIds(req) : undefined;
|
|
10725
|
-
const reveal = (config) => effectiveIncludeSecrets || !!held?.has(config.id);
|
|
10726
|
-
const result = configs.map((config) => config.isSecret && !reveal(config) ? maskSecrets2([config])[0] : config);
|
|
10727
|
-
for (const config of result) {
|
|
10728
|
-
if (config.isSecret && config.value && reveal(config)) {
|
|
10729
|
-
registerVolatileSecret(config.value, `config:${config.key}`);
|
|
10730
|
-
}
|
|
10731
|
-
}
|
|
10732
|
-
const anyMasked = result.some((config) => config.isSecret && !reveal(config));
|
|
10733
|
-
return { result, secretsNote: held && !anyMasked ? "" : secretsNote };
|
|
10734
|
-
}
|
|
10735
|
-
async function ensureConfigAdmin(req, res, verb) {
|
|
10736
|
-
return ensureHttpPermission(req, res, verb, verb === "config.write.any" ? "Writing swarm config requires the lead agent" : "Deleting swarm config requires the lead agent");
|
|
10737
|
-
}
|
|
10738
|
-
async function ensureHumanOnlyConfigWrite(req, res, key) {
|
|
10739
|
-
if (!isHumanOnlyConfigKey(key))
|
|
10740
|
-
return true;
|
|
10741
|
-
const auth = getRequestAuth(req);
|
|
10742
|
-
if (auth?.page) {
|
|
10743
|
-
jsonError(res, humanOnlyConfigKeyPageError(key), 403);
|
|
10744
|
-
return false;
|
|
10745
|
-
}
|
|
10746
|
-
const userId = authUserId(auth);
|
|
10747
|
-
if (userId && (!isRbacEnabled() || (await getUserGrant2(userId)).grantsAll))
|
|
10748
|
-
return true;
|
|
10749
|
-
jsonError(res, humanOnlyConfigKeyError(key), 403);
|
|
10750
|
-
return false;
|
|
10751
|
-
}
|
|
10752
|
-
async function runConfigWriteSideEffects(scope, key, value) {
|
|
10753
|
-
if (scope !== "global")
|
|
10754
|
-
return;
|
|
10755
|
-
if (key === "SWARM_ORG_WEBSITE")
|
|
10756
|
-
await fillOrgLogoFromWebsite(value);
|
|
10757
|
-
await syncRankingAfterConfigChange(key, value);
|
|
10758
|
-
scheduleIntegrationsReload2();
|
|
10759
|
-
}
|
|
10760
|
-
async function ensureHttpPermission(req, res, verb, forbiddenMessage, callerAgentId) {
|
|
10761
|
-
const principal = await requestPrincipal(req, callerAgentId ?? singleHeader(req, "x-agent-id"), {
|
|
10762
|
-
unauthenticatedFallback: "anonymous-agent"
|
|
10763
|
-
});
|
|
10764
|
-
if (principal.kind === "operator" || principal.kind === "user")
|
|
10765
|
-
return true;
|
|
10766
|
-
if (principal.kind === "guest") {
|
|
10767
|
-
jsonError(res, "Forbidden", 403);
|
|
10768
|
-
return false;
|
|
10769
|
-
}
|
|
10770
|
-
const decision = can({
|
|
10771
|
-
principal,
|
|
10772
|
-
verb,
|
|
10773
|
-
resource: { kind: "none" },
|
|
10774
|
-
source: "http"
|
|
10775
|
-
});
|
|
10776
|
-
if (!decision.allow) {
|
|
10777
|
-
jsonError(res, forbiddenMessage, 403);
|
|
10778
|
-
return false;
|
|
10779
|
-
}
|
|
10780
|
-
return true;
|
|
10781
|
-
}
|
|
10782
|
-
var getResolvedConfigRoute = route({
|
|
10783
|
-
method: "get",
|
|
10784
|
-
path: "/api/config/resolved",
|
|
10785
|
-
pattern: ["api", "config", "resolved"],
|
|
10786
|
-
summary: "Get resolved config (merged global + agent + repo scopes)",
|
|
10787
|
-
tags: ["Config"],
|
|
10788
|
-
query: object2({
|
|
10789
|
-
agentId: string2().optional(),
|
|
10790
|
-
repoId: string2().optional(),
|
|
10791
|
-
key: string2().min(1).optional().describe("Return only the entry with this exact key. Omit to return every resolved entry."),
|
|
10792
|
-
includeSecrets: _enum2(["true", "false"]).optional()
|
|
10793
|
-
}),
|
|
10794
|
-
responses: {
|
|
10795
|
-
200: {
|
|
10796
|
-
description: "Resolved config entries",
|
|
10797
|
-
schema: object2({
|
|
10798
|
-
configs: array2(SwarmConfigSchema),
|
|
10799
|
-
message: string2().optional()
|
|
10800
|
-
})
|
|
10801
|
-
}
|
|
10802
|
-
}
|
|
10803
|
-
});
|
|
10804
|
-
var envPresence = route({
|
|
10805
|
-
method: "get",
|
|
10806
|
-
path: "/api/config/env-presence",
|
|
10807
|
-
pattern: ["api", "config", "env-presence"],
|
|
10808
|
-
summary: "Check which of the given env var keys are currently set in process.env (presence only, no values)",
|
|
10809
|
-
tags: ["Config"],
|
|
10810
|
-
query: object2({
|
|
10811
|
-
keys: string2().min(1)
|
|
10812
|
-
}),
|
|
10813
|
-
responses: {
|
|
10814
|
-
200: {
|
|
10815
|
-
description: "Map of key -> boolean (true iff set in process.env)",
|
|
10816
|
-
schema: object2({ presence: record2(string2(), boolean()) })
|
|
10817
|
-
},
|
|
10818
|
-
400: { description: "Validation error" }
|
|
10819
|
-
}
|
|
10820
|
-
});
|
|
10821
|
-
var reloadConfigRoute = route({
|
|
10822
|
-
method: "post",
|
|
10823
|
-
path: "/api/config/reload",
|
|
10824
|
-
pattern: ["api", "config", "reload"],
|
|
10825
|
-
summary: "Reload global swarm_config into process.env (override=true) and re-init integrations (Slack, GitHub, Linear, AgentMail)",
|
|
10826
|
-
tags: ["Config"],
|
|
10827
|
-
body: object2({}).optional(),
|
|
10828
|
-
responses: {
|
|
10829
|
-
200: {
|
|
10830
|
-
description: "Reload result",
|
|
10831
|
-
schema: object2({
|
|
10832
|
-
success: literal2(true),
|
|
10833
|
-
configsLoaded: number2(),
|
|
10834
|
-
keysUpdated: array2(string2()),
|
|
10835
|
-
integrationsReinitialized: array2(string2())
|
|
10836
|
-
})
|
|
10837
|
-
},
|
|
10838
|
-
500: { description: "Reload failed" }
|
|
10839
|
-
}
|
|
10840
|
-
});
|
|
10841
|
-
var getConfigById = route({
|
|
10842
|
-
method: "get",
|
|
10843
|
-
path: "/api/config/{id}",
|
|
10844
|
-
pattern: ["api", "config", null],
|
|
10845
|
-
summary: "Get a single config entry by ID",
|
|
10846
|
-
tags: ["Config"],
|
|
10847
|
-
params: object2({ id: string2() }),
|
|
10848
|
-
query: object2({
|
|
10849
|
-
includeSecrets: _enum2(["true", "false"]).optional()
|
|
10850
|
-
}),
|
|
10851
|
-
responses: {
|
|
10852
|
-
200: {
|
|
10853
|
-
description: "Config entry",
|
|
10854
|
-
schema: SwarmConfigSchema.extend({ message: string2().optional() })
|
|
10855
|
-
},
|
|
10856
|
-
404: { description: "Config not found" }
|
|
10857
|
-
}
|
|
10858
|
-
});
|
|
10859
|
-
var listConfig = route({
|
|
10860
|
-
method: "get",
|
|
10861
|
-
path: "/api/config",
|
|
10862
|
-
pattern: ["api", "config"],
|
|
10863
|
-
summary: "List config entries with optional filters",
|
|
10864
|
-
tags: ["Config"],
|
|
10865
|
-
query: object2({
|
|
10866
|
-
scope: string2().optional(),
|
|
10867
|
-
scopeId: string2().optional(),
|
|
10868
|
-
key: string2().min(1).optional().describe("Return only entries with this exact key. Omit to return every entry."),
|
|
10869
|
-
includeSecrets: _enum2(["true", "false"]).optional()
|
|
10870
|
-
}),
|
|
10871
|
-
responses: {
|
|
10872
|
-
200: {
|
|
10873
|
-
description: "List of config entries",
|
|
10874
|
-
schema: object2({
|
|
10875
|
-
configs: array2(SwarmConfigSchema),
|
|
10876
|
-
message: string2().optional()
|
|
10877
|
-
})
|
|
10878
|
-
}
|
|
10879
|
-
}
|
|
10880
|
-
});
|
|
10881
|
-
var upsertConfig = route({
|
|
10882
|
-
method: "put",
|
|
10883
|
-
path: "/api/config",
|
|
10884
|
-
pattern: ["api", "config"],
|
|
10885
|
-
summary: "Create or update a config entry (reserved env-only keys are rejected). Global-scope writes auto-trigger an integrations reload (debounced ~250ms) so Slack/GitHub/Linear/Jira/AgentMail pick up new credentials without an explicit /api/config/reload call.",
|
|
10886
|
-
tags: ["Config"],
|
|
10887
|
-
rbac: { permission: "config.write.any" },
|
|
10888
|
-
body: object2({
|
|
10889
|
-
scope: _enum2(["global", "agent", "repo"]),
|
|
10890
|
-
scopeId: string2().nullish(),
|
|
10891
|
-
key: string2().min(1),
|
|
10892
|
-
value: unknown(),
|
|
10893
|
-
isSecret: boolean().optional(),
|
|
10894
|
-
envPath: string2().nullish(),
|
|
10895
|
-
description: string2().nullish(),
|
|
10896
|
-
exportToEnv: boolean().optional().describe("Export this row into agent process env (default true on create, false for a few server-side secrets; omitted on update keeps the stored flag). Rejected as true for keys only the API server reads.")
|
|
10897
|
-
}),
|
|
10898
|
-
responses: {
|
|
10899
|
-
200: { description: "Config entry upserted", schema: SwarmConfigSchema },
|
|
10900
|
-
400: { description: "Validation error" }
|
|
10901
|
-
}
|
|
10902
|
-
});
|
|
10903
|
-
var deleteConfig = route({
|
|
10904
|
-
method: "delete",
|
|
10905
|
-
path: "/api/config/{id}",
|
|
10906
|
-
pattern: ["api", "config", null],
|
|
10907
|
-
summary: "Delete a config entry by ID (including legacy reserved rows for cleanup). Global-scope deletes auto-trigger an integrations reload.",
|
|
10908
|
-
tags: ["Config"],
|
|
10909
|
-
rbac: { permission: "config.delete.any" },
|
|
10910
|
-
params: object2({ id: string2() }),
|
|
10911
|
-
responses: {
|
|
10912
|
-
200: {
|
|
10913
|
-
description: "Config deleted",
|
|
10914
|
-
schema: object2({ success: literal2(true) })
|
|
10915
|
-
},
|
|
10916
|
-
404: { description: "Config not found" }
|
|
10917
|
-
}
|
|
10918
|
-
});
|
|
10919
|
-
async function handleConfig(req, res, pathSegments, queryParams) {
|
|
10920
|
-
if (getRequestAuth(req)?.kind === "agent") {
|
|
10921
|
-
const duplicate = duplicateGuardedQueryKey(queryParams);
|
|
10922
|
-
if (duplicate) {
|
|
10923
|
-
jsonError(res, `Duplicate query parameter: ${duplicate}`, 400);
|
|
10924
|
-
return true;
|
|
10925
|
-
}
|
|
10926
|
-
}
|
|
10927
|
-
if (getResolvedConfigRoute.match(req.method, pathSegments)) {
|
|
10928
|
-
const parsed = await getResolvedConfigRoute.parse(req, res, pathSegments, queryParams);
|
|
10929
|
-
if (!parsed)
|
|
10930
|
-
return true;
|
|
10931
|
-
const includeSecrets = parsed.query.includeSecrets === "true";
|
|
10932
|
-
const key = parsed.query.key;
|
|
10933
|
-
const auth = getRequestAuth(req);
|
|
10934
|
-
const resolvedScope = {
|
|
10935
|
-
agentId: parsed.query.agentId || (auth?.kind === "agent" && auth.tokenKind !== "task" ? auth.agentId : undefined),
|
|
10936
|
-
repoId: parsed.query.repoId || undefined
|
|
10937
|
-
};
|
|
10938
|
-
const { effectiveIncludeSecrets, includeRepoSecrets, secretsNote } = await resolveSecretsRead(req, includeSecrets, resolvedScope);
|
|
10939
|
-
const configs = stripApiOnlyKeys(await getResolvedConfig2(resolvedScope.agentId, resolvedScope.repoId, { includeRepoSecrets })).filter((c) => !key || c.key === key);
|
|
10940
|
-
const result = effectiveIncludeSecrets ? configs : maskSecrets2(configs);
|
|
10941
|
-
if (effectiveIncludeSecrets) {
|
|
10942
|
-
for (const c of result) {
|
|
10943
|
-
if (c.isSecret && c.value) {
|
|
10944
|
-
registerVolatileSecret(c.value, `config:${c.key}`);
|
|
10945
|
-
}
|
|
10946
|
-
}
|
|
10947
|
-
}
|
|
10948
|
-
getResolvedConfigRoute.respond(res, 200, {
|
|
10949
|
-
configs: result,
|
|
10950
|
-
...secretsNote ? { message: `Found ${result.length} config(s).${secretsNote}` } : {}
|
|
10951
|
-
});
|
|
10952
|
-
return true;
|
|
10953
|
-
}
|
|
10954
|
-
if (envPresence.match(req.method, pathSegments)) {
|
|
10955
|
-
const parsed = await envPresence.parse(req, res, pathSegments, queryParams);
|
|
10956
|
-
if (!parsed)
|
|
10957
|
-
return true;
|
|
10958
|
-
const keys = parsed.query.keys.split(",").map((k) => k.trim()).filter(Boolean);
|
|
10959
|
-
if (keys.length > MAX_ENV_PRESENCE_KEYS) {
|
|
10960
|
-
jsonError(res, `Too many keys (max ${MAX_ENV_PRESENCE_KEYS})`, 400);
|
|
10961
|
-
return true;
|
|
10962
|
-
}
|
|
10963
|
-
const presence = {};
|
|
10964
|
-
for (const key of keys) {
|
|
10965
|
-
const value = key === "SWARM_ORG_NAME" ? process.env[key]?.trim() : process.env[key];
|
|
10966
|
-
presence[key] = value !== undefined && (isSlackIconConfigKey(key) || value !== "");
|
|
10967
|
-
}
|
|
10968
|
-
envPresence.respond(res, 200, { presence });
|
|
10969
|
-
return true;
|
|
10970
|
-
}
|
|
10971
|
-
if (reloadConfigRoute.match(req.method, pathSegments)) {
|
|
10972
|
-
try {
|
|
10973
|
-
const result = await reloadGlobalConfigsAndIntegrations2();
|
|
10974
|
-
console.log(`[reload-config] Loaded ${result.configsLoaded} config(s), re-initialized: ${result.integrationsReinitialized.join(", ") || "none"}`);
|
|
10975
|
-
reloadConfigRoute.respond(res, 200, { success: true, ...result });
|
|
10976
|
-
} catch (e) {
|
|
10977
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
10978
|
-
console.error("[reload-config] Failed:", message);
|
|
10979
|
-
jsonError(res, `Failed to reload config: ${message}`, 500);
|
|
10980
|
-
}
|
|
10981
|
-
return true;
|
|
10982
|
-
}
|
|
10983
|
-
if (getConfigById.match(req.method, pathSegments)) {
|
|
10984
|
-
const parsed = await getConfigById.parse(req, res, pathSegments, queryParams);
|
|
10985
|
-
if (!parsed)
|
|
10986
|
-
return true;
|
|
10987
|
-
const includeSecrets = parsed.query.includeSecrets === "true";
|
|
10988
|
-
const config = await getSwarmConfigById2(parsed.params.id);
|
|
10989
|
-
if (!config || isInternalConfigKey(config.key)) {
|
|
10990
|
-
jsonError(res, "Config not found", 404);
|
|
10991
|
-
return true;
|
|
10992
|
-
}
|
|
10993
|
-
const { result, secretsNote } = await maskConfigRead(req, [config], includeSecrets);
|
|
10994
|
-
getConfigById.respond(res, 200, {
|
|
10995
|
-
...result[0],
|
|
10996
|
-
...secretsNote ? { message: `Found 1 config(s).${secretsNote}` } : {}
|
|
10997
|
-
});
|
|
10998
|
-
return true;
|
|
10999
|
-
}
|
|
11000
|
-
if (listConfig.match(req.method, pathSegments)) {
|
|
11001
|
-
const parsed = await listConfig.parse(req, res, pathSegments, queryParams);
|
|
11002
|
-
if (!parsed)
|
|
11003
|
-
return true;
|
|
11004
|
-
const includeSecrets = parsed.query.includeSecrets === "true";
|
|
11005
|
-
const configs = stripApiOnlyKeys(await getSwarmConfigs2({
|
|
11006
|
-
scope: parsed.query.scope || undefined,
|
|
11007
|
-
scopeId: parsed.query.scopeId || undefined,
|
|
11008
|
-
key: parsed.query.key
|
|
11009
|
-
}));
|
|
11010
|
-
const { result: listResult, secretsNote } = await maskConfigRead(req, configs, includeSecrets);
|
|
11011
|
-
listConfig.respond(res, 200, {
|
|
11012
|
-
configs: listResult,
|
|
11013
|
-
...secretsNote ? { message: `Found ${listResult.length} config(s).${secretsNote}` } : {}
|
|
11014
|
-
});
|
|
11015
|
-
return true;
|
|
11016
|
-
}
|
|
11017
|
-
if (upsertConfig.match(req.method, pathSegments)) {
|
|
11018
|
-
const parsed = await upsertConfig.parse(req, res, pathSegments, queryParams);
|
|
11019
|
-
if (!parsed)
|
|
11020
|
-
return true;
|
|
11021
|
-
if (!await ensureConfigAdmin(req, res, "config.write.any"))
|
|
11022
|
-
return true;
|
|
11023
|
-
const { scope, scopeId, key, value, isSecret, envPath, description, exportToEnv } = parsed.body;
|
|
11024
|
-
if (!await ensureHumanOnlyConfigWrite(req, res, key))
|
|
11025
|
-
return true;
|
|
11026
|
-
const validationError = validateConfigEntry({ scope, scopeId, key, value, exportToEnv });
|
|
11027
|
-
if (validationError) {
|
|
11028
|
-
jsonError(res, validationError, 400);
|
|
11029
|
-
return true;
|
|
11030
|
-
}
|
|
11031
|
-
try {
|
|
11032
|
-
const includeSecrets = queryParams.get("includeSecrets") === "true";
|
|
11033
|
-
const config = await upsertSwarmConfigWithPolicyMirror({
|
|
11034
|
-
scope,
|
|
11035
|
-
scopeId: scopeId || null,
|
|
11036
|
-
key,
|
|
11037
|
-
value: String(value),
|
|
11038
|
-
isSecret: isSecret || false,
|
|
11039
|
-
envPath: envPath || null,
|
|
11040
|
-
description: description || null,
|
|
11041
|
-
exportToEnv
|
|
11042
|
-
});
|
|
11043
|
-
await runConfigWriteSideEffects(scope, key, String(value));
|
|
11044
|
-
const result = includeSecrets || !config.isSecret ? config : maskSecrets2([config])[0];
|
|
11045
|
-
upsertConfig.respond(res, 200, result);
|
|
11046
|
-
} catch (error) {
|
|
11047
|
-
if (modelProfileRefError(error) === "missing") {
|
|
11048
|
-
jsonError(res, `Unknown model profile "${String(value)}"`, 400);
|
|
11049
|
-
return true;
|
|
11050
|
-
}
|
|
11051
|
-
jsonError(res, "Failed to upsert config", 500);
|
|
11052
|
-
}
|
|
11053
|
-
return true;
|
|
11054
|
-
}
|
|
11055
|
-
if (deleteConfig.match(req.method, pathSegments)) {
|
|
11056
|
-
const parsed = await deleteConfig.parse(req, res, pathSegments, queryParams);
|
|
11057
|
-
if (!parsed)
|
|
11058
|
-
return true;
|
|
11059
|
-
if (!await ensureConfigAdmin(req, res, "config.delete.any"))
|
|
11060
|
-
return true;
|
|
11061
|
-
const existing = await getSwarmConfigLookupById2(parsed.params.id);
|
|
11062
|
-
if (!existing) {
|
|
11063
|
-
jsonError(res, "Config not found", 404);
|
|
11064
|
-
return true;
|
|
11065
|
-
}
|
|
11066
|
-
if (isInternalConfigKey(existing.key)) {
|
|
11067
|
-
jsonError(res, internalConfigKeyError(existing.key).message, 400);
|
|
11068
|
-
return true;
|
|
11069
|
-
}
|
|
11070
|
-
if (!await ensureHumanOnlyConfigWrite(req, res, existing.key))
|
|
11071
|
-
return true;
|
|
11072
|
-
const deleted = await deleteSwarmConfig2(parsed.params.id);
|
|
11073
|
-
if (!deleted) {
|
|
11074
|
-
jsonError(res, "Config not found", 404);
|
|
11075
|
-
return true;
|
|
11076
|
-
}
|
|
11077
|
-
if (existing.scope === "global") {
|
|
11078
|
-
await syncRankingAfterConfigChange(existing.key, null);
|
|
11079
|
-
scheduleIntegrationsReload2();
|
|
11080
|
-
}
|
|
11081
|
-
if (existing.scope === "agent" && existing.scopeId && existing.key === AGENT_MAX_TASKS_CONFIG_KEY) {
|
|
11082
|
-
await resetAgentMaxTasksMirror(existing.scopeId);
|
|
11083
|
-
}
|
|
11084
|
-
deleteConfig.respond(res, 200, { success: true });
|
|
11085
|
-
return true;
|
|
11086
|
-
}
|
|
11087
|
-
return false;
|
|
11088
|
-
}
|
|
11089
|
-
|
|
11090
|
-
// src/http/person-responder.ts
|
|
11091
|
-
init_rbac_roles();
|
|
11092
|
-
init_rbac();
|
|
11093
|
-
init_request_auth_context();
|
|
11094
|
-
init_request_principal();
|
|
11095
|
-
var AGENT_RESPONSE_REFUSED = "Agents cannot answer approval requests. A person must respond with a user token or the dashboard.";
|
|
11096
|
-
async function approvalResponder(req, options) {
|
|
11097
|
-
const auth = getRequestAuth(req);
|
|
11098
|
-
const rawAgentId = req.headers["x-agent-id"];
|
|
11099
|
-
const headerAgentId = Array.isArray(rawAgentId) ? rawAgentId[0] : rawAgentId;
|
|
11100
|
-
const principal = await agentFirstPrincipal(req, headerAgentId);
|
|
11101
|
-
if (principal.kind !== "user" && principal.kind !== "agent" && auth?.page) {
|
|
11102
|
-
return {
|
|
11103
|
-
ok: false,
|
|
11104
|
-
message: options?.pageMessage ?? "A page session without a signed-in user cannot answer approval requests."
|
|
11105
|
-
};
|
|
11106
|
-
}
|
|
11107
|
-
const user = authUser(auth);
|
|
11108
|
-
const responder = principal.kind === "user" && user ? { kind: "user", user } : principal.kind === "operator" ? { kind: "operator" } : null;
|
|
11109
|
-
const verb = options?.verb ?? "approval.respond";
|
|
11110
|
-
const refused = {
|
|
11111
|
-
ok: false,
|
|
11112
|
-
message: options?.refusedMessage ?? AGENT_RESPONSE_REFUSED
|
|
11113
|
-
};
|
|
11114
|
-
const decision = can({ principal, verb, source: "http" });
|
|
11115
|
-
if (!decision.allow || !responder)
|
|
11116
|
-
return refused;
|
|
11117
|
-
if (responder.kind === "user" && isRbacEnabled()) {
|
|
11118
|
-
const grant = await getUserGrant2(responder.user.id);
|
|
11119
|
-
if (!grant.grantsAll && !grant.verbs.has(verb))
|
|
11120
|
-
return refused;
|
|
11121
|
-
}
|
|
11122
|
-
return { ok: true, responder };
|
|
11123
|
-
}
|
|
11124
|
-
function responderKey(responder) {
|
|
11125
|
-
return responder.kind === "user" ? responder.user.id : "operator";
|
|
11126
|
-
}
|
|
11127
|
-
|
|
11128
|
-
// src/http/approval-requests.ts
|
|
11129
|
-
init_request_principal();
|
|
11130
|
-
init_route_def();
|
|
11131
|
-
init_utils2();
|
|
11132
|
-
var QuestionSchema = object2({
|
|
11133
|
-
id: string2(),
|
|
11134
|
-
type: _enum2(["approval", "text", "single-select", "multi-select", "boolean", "config"]),
|
|
11135
|
-
label: string2(),
|
|
11136
|
-
required: boolean().optional(),
|
|
11137
|
-
description: string2().optional(),
|
|
11138
|
-
placeholder: string2().optional(),
|
|
11139
|
-
multiline: boolean().optional(),
|
|
11140
|
-
options: array2(object2({
|
|
11141
|
-
value: string2(),
|
|
11142
|
-
label: string2(),
|
|
11143
|
-
description: string2().optional()
|
|
11144
|
-
})).optional(),
|
|
11145
|
-
minSelections: number2().int().min(0).optional(),
|
|
11146
|
-
maxSelections: number2().int().min(1).optional(),
|
|
11147
|
-
defaultValue: boolean().optional(),
|
|
11148
|
-
config: ConfigQuestionSettingsSchema.optional().describe("Config question settings. Answers are written to swarm_config and replaced by a result that never holds a secret value.")
|
|
11149
|
-
});
|
|
11150
|
-
var QuestionInputSchema = QuestionSchema.extend({
|
|
11151
|
-
label: string2().optional(),
|
|
11152
|
-
required: boolean().default(true)
|
|
11153
|
-
});
|
|
11154
|
-
var ApproversSchema = object2({
|
|
11155
|
-
users: array2(string2()).optional(),
|
|
11156
|
-
roles: array2(string2()).optional(),
|
|
11157
|
-
policy: union3([literal2("any"), literal2("all"), object2({ min: number2().int().min(1) })])
|
|
11158
|
-
});
|
|
11159
|
-
var NotificationChannelSchema = object2({
|
|
11160
|
-
channel: _enum2(["slack", "email"]),
|
|
11161
|
-
target: string2(),
|
|
11162
|
-
messageTs: string2().optional()
|
|
11163
|
-
});
|
|
11164
|
-
var ApprovalVoteSchema = object2({
|
|
11165
|
-
responder: string2().describe("Who answered, from the credential: a user id, or `operator` for the shared key."),
|
|
11166
|
-
approved: boolean(),
|
|
11167
|
-
responses: record2(string2(), unknown()),
|
|
11168
|
-
claimedRespondedBy: string2().optional().describe("The `respondedBy` the client sent. Unverified; display only."),
|
|
11169
|
-
respondedAt: string2()
|
|
11170
|
-
});
|
|
11171
|
-
var ApprovalProgressSchema = object2({
|
|
11172
|
-
approved: number2().int().describe("Approvals that count toward the policy so far."),
|
|
11173
|
-
required: number2().int().describe("Approvals the policy needs before the request resolves.")
|
|
11174
|
-
}).nullable().describe("Quorum progress while the request is pending; null once it is resolved.");
|
|
11175
|
-
var ApprovalRequestSchema = object2({
|
|
11176
|
-
id: string2(),
|
|
11177
|
-
title: string2(),
|
|
11178
|
-
questions: array2(QuestionSchema),
|
|
11179
|
-
workflowRunId: string2().nullable(),
|
|
11180
|
-
workflowRunStepId: string2().nullable(),
|
|
11181
|
-
sourceTaskId: string2().nullable(),
|
|
11182
|
-
approvers: ApproversSchema,
|
|
11183
|
-
status: _enum2(["pending", "approved", "rejected", "timeout", "cancelled"]),
|
|
11184
|
-
responses: record2(string2(), unknown()).nullable(),
|
|
11185
|
-
approvals: array2(ApprovalVoteSchema).nullable().describe("Every accepted answer, in order. A request with an `all` or `{ min: N }` policy stays pending until enough approve."),
|
|
11186
|
-
approvalProgress: ApprovalProgressSchema,
|
|
11187
|
-
resolvedBy: string2().nullable().describe("Who resolved the request, from the credential: a user id, `operator` for the shared key, or an agent id for a cancellation."),
|
|
11188
|
-
resolvedAt: string2().nullable(),
|
|
11189
|
-
resolutionReason: string2().nullable(),
|
|
11190
|
-
timeoutSeconds: number2().nullable(),
|
|
11191
|
-
expiresAt: string2().nullable(),
|
|
11192
|
-
notificationChannels: array2(NotificationChannelSchema).nullable(),
|
|
11193
|
-
createdBy: string2().optional(),
|
|
11194
|
-
createdAt: string2(),
|
|
11195
|
-
updatedAt: string2(),
|
|
11196
|
-
configState: record2(string2(), ConfigStateSchema).optional().describe("Live state of each config question's key, by question id. Read at request time and never stored. `value` appears only for non-secret keys.")
|
|
11197
|
-
});
|
|
11198
|
-
var ApprovalRequestSummarySchema = ApprovalRequestSchema.omit({
|
|
11199
|
-
questions: true,
|
|
11200
|
-
approvers: true,
|
|
11201
|
-
responses: true,
|
|
11202
|
-
approvals: true,
|
|
11203
|
-
resolutionReason: true,
|
|
11204
|
-
notificationChannels: true,
|
|
11205
|
-
configState: true
|
|
11206
|
-
}).extend({
|
|
11207
|
-
questionCount: number2().int(),
|
|
11208
|
-
viewerCanRespond: boolean().optional().describe("Pending rows only: whether the caller may answer, by the same rule as the respond route (a listed user or role, or no users and roles listed).")
|
|
11209
|
-
});
|
|
11210
|
-
async function toApprovalRequestResponse(request, options = {}) {
|
|
11211
|
-
const approvers = request.approvers;
|
|
11212
|
-
const approvals = request.approvals ?? null;
|
|
11213
|
-
const configState = options.withConfigState ? await readConfigStates(request.questions) : undefined;
|
|
11214
|
-
return {
|
|
11215
|
-
...request,
|
|
11216
|
-
...configState ? { configState } : {},
|
|
11217
|
-
questions: request.questions,
|
|
11218
|
-
approvers,
|
|
11219
|
-
responses: request.responses,
|
|
11220
|
-
approvals,
|
|
11221
|
-
approvalProgress: request.status === "pending" ? await approvalProgress(approvers, approvals ?? []) : null,
|
|
11222
|
-
notificationChannels: request.notificationChannels
|
|
11223
|
-
};
|
|
11224
|
-
}
|
|
11225
|
-
async function withApprovalProgress(rows, viewer) {
|
|
11226
|
-
const pendingIds = rows.filter((row) => row.status === "pending").map((row) => row.id);
|
|
11227
|
-
const state = new Map((await getPendingApprovalVoteState2(pendingIds)).map((entry) => [entry.id, entry]));
|
|
11228
|
-
return Promise.all(rows.map(async (row) => {
|
|
11229
|
-
const entry = state.get(row.id);
|
|
11230
|
-
return {
|
|
11231
|
-
...row,
|
|
11232
|
-
approvalProgress: entry ? await approvalProgress(entry.approvers, entry.approvals ?? []) : null,
|
|
11233
|
-
...entry && {
|
|
11234
|
-
viewerCanRespond: viewer !== null && isListedApprover(entry.approvers, viewer)
|
|
11235
|
-
}
|
|
11236
|
-
};
|
|
11237
|
-
}));
|
|
11238
|
-
}
|
|
11239
|
-
async function readConfigStates(questions) {
|
|
11240
|
-
const configQuestions = questions.filter(isConfigQuestion);
|
|
11241
|
-
if (configQuestions.length === 0)
|
|
11242
|
-
return;
|
|
11243
|
-
const entries = await Promise.all(configQuestions.map(async (q) => [q.id, await readConfigState(q.config)]));
|
|
11244
|
-
return Object.fromEntries(entries);
|
|
11245
|
-
}
|
|
11246
|
-
|
|
11247
|
-
class ConfigRespondAbort extends Error {
|
|
11248
|
-
kind;
|
|
11249
|
-
constructor(kind, message = kind) {
|
|
11250
|
-
super(message);
|
|
11251
|
-
this.kind = kind;
|
|
11252
|
-
}
|
|
11253
|
-
}
|
|
11254
|
-
async function getWorkflowApprovalUnavailableReason(request) {
|
|
11255
|
-
if (!request.workflowRunId || !request.workflowRunStepId)
|
|
11256
|
-
return null;
|
|
11257
|
-
const run = await getWorkflowRun2(request.workflowRunId);
|
|
11258
|
-
if (!run)
|
|
11259
|
-
return "The workflow run no longer exists";
|
|
11260
|
-
if (run.status !== "running" && run.status !== "waiting") {
|
|
11261
|
-
return `The workflow run is ${run.status} and this approval is no longer actionable`;
|
|
11262
|
-
}
|
|
11263
|
-
const step = await getWorkflowRunStep2(request.workflowRunStepId);
|
|
11264
|
-
if (!step)
|
|
11265
|
-
return "The human-in-the-loop step no longer exists";
|
|
11266
|
-
if (step.runId !== run.id) {
|
|
11267
|
-
return "The human-in-the-loop step belongs to a different workflow run";
|
|
11268
|
-
}
|
|
11269
|
-
if (step.status !== "waiting") {
|
|
11270
|
-
return `The human-in-the-loop step is ${step.status} and this approval is no longer actionable`;
|
|
11271
|
-
}
|
|
11272
|
-
return null;
|
|
11273
|
-
}
|
|
11274
|
-
function hasRequiredResponse(question, response) {
|
|
11275
|
-
switch (question.type) {
|
|
11276
|
-
case "approval":
|
|
11277
|
-
return typeof response === "object" && response !== null && typeof response.approved === "boolean";
|
|
11278
|
-
case "text":
|
|
11279
|
-
return typeof response === "string" && response.trim().length > 0;
|
|
11280
|
-
case "single-select":
|
|
11281
|
-
return typeof response === "string" && response.length > 0 && (!question.options || question.options.some((option) => option.value === response));
|
|
11282
|
-
case "multi-select": {
|
|
11283
|
-
if (!Array.isArray(response))
|
|
11284
|
-
return false;
|
|
11285
|
-
const minimum = Math.max(1, question.minSelections ?? 0);
|
|
11286
|
-
if (response.length < minimum)
|
|
11287
|
-
return false;
|
|
11288
|
-
if (question.maxSelections !== undefined && response.length > question.maxSelections) {
|
|
11289
|
-
return false;
|
|
11290
|
-
}
|
|
11291
|
-
return response.every((value) => typeof value === "string" && (!question.options || question.options.some((option) => option.value === value)));
|
|
11292
|
-
}
|
|
11293
|
-
case "boolean":
|
|
11294
|
-
return typeof response === "boolean";
|
|
11295
|
-
case "config": {
|
|
11296
|
-
if (typeof response !== "object" || response === null)
|
|
11297
|
-
return false;
|
|
11298
|
-
const answer = response;
|
|
11299
|
-
if (answer.action === "keep")
|
|
11300
|
-
return true;
|
|
11301
|
-
return answer.action === "set" && typeof answer.value === "string" && answer.value.trim() !== "";
|
|
11302
|
-
}
|
|
11303
|
-
}
|
|
11304
|
-
}
|
|
11305
|
-
function isUnanswered(response) {
|
|
11306
|
-
return response === undefined || response === null || typeof response === "string" && response.trim() === "" || Array.isArray(response) && response.length === 0;
|
|
11307
|
-
}
|
|
11308
|
-
function missingRequiredResponseIds(questions, responses) {
|
|
11309
|
-
return questions.filter((question) => {
|
|
11310
|
-
const response = responses[question.id];
|
|
11311
|
-
if (hasRequiredResponse(question, response))
|
|
11312
|
-
return false;
|
|
11313
|
-
if (question.required)
|
|
11314
|
-
return true;
|
|
11315
|
-
return question.type !== "config" && !isUnanswered(response);
|
|
11316
|
-
}).map((question) => question.id);
|
|
11317
|
-
}
|
|
11318
|
-
var createRoute = route({
|
|
11319
|
-
method: "post",
|
|
11320
|
-
path: "/api/approval-requests",
|
|
11321
|
-
pattern: ["api", "approval-requests"],
|
|
11322
|
-
session: bodyTask("sourceTaskId"),
|
|
11323
|
-
summary: "Create a new approval request",
|
|
11324
|
-
tags: ["ApprovalRequests"],
|
|
11325
|
-
body: object2({
|
|
11326
|
-
title: string2().min(1),
|
|
11327
|
-
questions: array2(QuestionInputSchema).min(1).describe('A request with a `config` question needs `approvers.policy: "any"`. The answer is written to swarm_config; the request stores only `{ key, scope, scopeId, isSecret, status, updatedAt }` (plus `value` for non-secret keys).'),
|
|
11328
|
-
approvers: object2({
|
|
11329
|
-
users: array2(string2()).optional(),
|
|
11330
|
-
roles: array2(string2()).optional(),
|
|
11331
|
-
policy: union3([
|
|
11332
|
-
literal2("any"),
|
|
11333
|
-
literal2("all"),
|
|
11334
|
-
object2({ min: number2().int().min(1) })
|
|
11335
|
-
])
|
|
11336
|
-
}),
|
|
11337
|
-
workflowRunId: string2().uuid().optional(),
|
|
11338
|
-
workflowRunStepId: string2().uuid().optional(),
|
|
11339
|
-
sourceTaskId: string2().uuid().optional(),
|
|
11340
|
-
timeoutSeconds: number2().int().min(1).optional().describe("Seconds until the request expires. After that the request becomes 'timeout' and you get a hitl-follow-up task. A request with no timeout is cancelled after APPROVAL_REQUEST_AUTO_CANCELLATION_DAYS days (default 7)."),
|
|
11341
|
-
notifications: array2(object2({
|
|
11342
|
-
channel: _enum2(["slack", "email"]),
|
|
11343
|
-
target: string2()
|
|
11344
|
-
})).optional().describe("Where to announce the request. A Slack target (channel or user ID) gets a card with the title, the questions and a link to the dashboard page that answers it. Slack targets need a lead agent caller (403 otherwise). Email is not supported yet and is skipped.")
|
|
11345
|
-
}),
|
|
11346
|
-
responses: {
|
|
11347
|
-
201: {
|
|
11348
|
-
description: "Approval request created",
|
|
11349
|
-
schema: object2({ approvalRequest: ApprovalRequestSchema })
|
|
11350
|
-
},
|
|
11351
|
-
400: { description: "Validation error" },
|
|
11352
|
-
403: { description: "Slack notifications require a lead agent" }
|
|
11353
|
-
},
|
|
11354
|
-
auth: { apiKey: true }
|
|
11355
|
-
});
|
|
11356
|
-
var getByIdRoute = route({
|
|
11357
|
-
method: "get",
|
|
11358
|
-
path: "/api/approval-requests/{id}",
|
|
11359
|
-
pattern: ["api", "approval-requests", null],
|
|
11360
|
-
summary: "Get approval request details",
|
|
11361
|
-
tags: ["ApprovalRequests"],
|
|
11362
|
-
params: object2({ id: string2().uuid() }),
|
|
11363
|
-
responses: {
|
|
11364
|
-
200: {
|
|
11365
|
-
description: "Approval request details",
|
|
11366
|
-
schema: object2({ approvalRequest: ApprovalRequestSchema })
|
|
11367
|
-
},
|
|
11368
|
-
404: { description: "Not found" }
|
|
11369
|
-
},
|
|
11370
|
-
auth: { apiKey: true },
|
|
11371
|
-
description: "Includes `configState` when the request has `config` questions: the live state of each target key, read now."
|
|
11372
|
-
});
|
|
11373
|
-
var respondRoute = route({
|
|
11374
|
-
method: "post",
|
|
11375
|
-
path: "/api/approval-requests/{id}/respond",
|
|
11376
|
-
pattern: ["api", "approval-requests", null, "respond"],
|
|
11377
|
-
summary: "Submit a response to an approval request",
|
|
11378
|
-
description: 'Only a person may answer: a user token, a page session signed for a user, or the shared key with no agent identity (recorded as `operator`). The responder is taken from the credential. When the request lists `approvers.users` or `approvers.roles`, a user must match one of them. A rejection resolves the request at once; approvals resolve it when the `any`, `all` or `{ min: N }` policy is met, and until then it stays pending with the answer recorded in `approvals`. A `config` question takes `{ action: "set", value }`, `{ action: "keep" }` (key must exist) or `{ action: "skip" }` (optional questions only); `set` also needs the config write permission. The value is written only when the request is approved, and the stored answer is the result, never a secret value.',
|
|
11379
|
-
tags: ["ApprovalRequests"],
|
|
11380
|
-
params: object2({ id: string2().uuid() }),
|
|
11381
|
-
body: object2({
|
|
11382
|
-
responses: record2(string2(), unknown()),
|
|
11383
|
-
respondedBy: string2().optional().describe("Unverified display name. Stored as `claimedRespondedBy` on the answer; never used as the responder.")
|
|
11384
|
-
}),
|
|
11385
|
-
responses: {
|
|
11386
|
-
200: {
|
|
11387
|
-
description: "Response recorded. `status` stays `pending` while the policy needs more approvals.",
|
|
11388
|
-
schema: object2({ approvalRequest: ApprovalRequestSchema })
|
|
11389
|
-
},
|
|
11390
|
-
400: { description: "Validation error" },
|
|
11391
|
-
403: { description: "Caller is an agent, or is not one of the request's approvers" },
|
|
11392
|
-
404: { description: "Not found" },
|
|
11393
|
-
409: { description: "Already resolved, or this responder already answered" }
|
|
11394
|
-
},
|
|
11395
|
-
auth: { apiKey: true },
|
|
11396
|
-
rbac: { permission: "approval.respond" }
|
|
11397
|
-
});
|
|
11398
|
-
var cancelRoute = route({
|
|
11399
|
-
method: "post",
|
|
11400
|
-
path: "/api/approval-requests/{id}/cancel",
|
|
11401
|
-
pattern: ["api", "approval-requests", null, "cancel"],
|
|
11402
|
-
summary: "Cancel a pending approval request",
|
|
11403
|
-
tags: ["ApprovalRequests"],
|
|
11404
|
-
params: object2({ id: string2().uuid() }),
|
|
11405
|
-
body: object2({ reason: string2().max(500).optional() }),
|
|
11406
|
-
responses: {
|
|
11407
|
-
200: {
|
|
11408
|
-
description: "Request cancelled, or already cancelled. A request that gates a running or waiting workflow run cancels that run too.",
|
|
11409
|
-
schema: object2({
|
|
11410
|
-
approvalRequest: ApprovalRequestSchema,
|
|
11411
|
-
alreadyCancelled: boolean(),
|
|
11412
|
-
runCancelled: boolean()
|
|
11413
|
-
})
|
|
11414
|
-
},
|
|
11415
|
-
403: { description: "Caller may not cancel this request" },
|
|
11416
|
-
404: { description: "Not found" },
|
|
11417
|
-
409: {
|
|
11418
|
-
description: "Already resolved with approved, rejected, or timeout, or its expiresAt passed"
|
|
11419
|
-
}
|
|
11420
|
-
},
|
|
11421
|
-
auth: { apiKey: true },
|
|
11422
|
-
rbac: { permission: "approval.cancel.any" }
|
|
11423
|
-
});
|
|
11424
|
-
var listRoute = route({
|
|
11425
|
-
method: "get",
|
|
11426
|
-
path: "/api/approval-requests",
|
|
11427
|
-
pattern: ["api", "approval-requests"],
|
|
11428
|
-
summary: "List approval requests with optional filters",
|
|
11429
|
-
description: "Returns full approval requests by default. Pass `fields=slim` for the list-view shape: `questions`, `approvers`, `responses`, `resolutionReason` and `notificationChannels` are dropped and `questionCount` is added, plus `viewerCanRespond` on pending rows. Fetch one request in full via `GET /api/approval-requests/{id}`.",
|
|
11430
|
-
tags: ["ApprovalRequests"],
|
|
11431
|
-
query: object2({
|
|
11432
|
-
status: string2().optional(),
|
|
11433
|
-
workflowRunId: string2().optional(),
|
|
11434
|
-
limit: exports_coerce.number().optional(),
|
|
11435
|
-
fields: _enum2(["full", "slim"]).optional()
|
|
11436
|
-
}),
|
|
11437
|
-
responses: {
|
|
11438
|
-
200: {
|
|
11439
|
-
description: "List of approval requests",
|
|
11440
|
-
schema: object2({
|
|
11441
|
-
approvalRequests: union3([
|
|
11442
|
-
array2(ApprovalRequestSchema),
|
|
11443
|
-
array2(ApprovalRequestSummarySchema)
|
|
11444
|
-
])
|
|
11445
|
-
})
|
|
11446
|
-
}
|
|
11447
|
-
},
|
|
11448
|
-
auth: { apiKey: true }
|
|
11449
|
-
});
|
|
11450
|
-
async function handleApprovalRequests(req, res, pathSegments, queryParams) {
|
|
11451
|
-
if (respondRoute.match(req.method, pathSegments)) {
|
|
11452
|
-
const parsed = await respondRoute.parse(req, res, pathSegments, queryParams);
|
|
11453
|
-
if (!parsed)
|
|
11454
|
-
return true;
|
|
11455
|
-
const responder = await approvalResponder(req);
|
|
11456
|
-
if (!responder.ok) {
|
|
11457
|
-
jsonError(res, responder.message, 403);
|
|
11458
|
-
return true;
|
|
11459
|
-
}
|
|
11460
|
-
const existing = await getApprovalRequestById2(parsed.params.id);
|
|
11461
|
-
if (!existing) {
|
|
11462
|
-
jsonError(res, "Approval request not found", 404);
|
|
11463
|
-
return true;
|
|
11464
|
-
}
|
|
11465
|
-
if (existing.status !== "pending") {
|
|
11466
|
-
const reason = existing.resolutionReason ? `: ${existing.resolutionReason}` : "";
|
|
11467
|
-
jsonError(res, `Approval request already resolved with status: ${existing.status}${reason}`, 409);
|
|
11468
|
-
return true;
|
|
11469
|
-
}
|
|
11470
|
-
if (existing.expiresAt && new Date(existing.expiresAt) < new Date) {
|
|
11471
|
-
await getDbClient2().transaction(async () => {
|
|
11472
|
-
const timedOut = await resolveApprovalRequest2(existing.id, {
|
|
11473
|
-
status: "timeout",
|
|
11474
|
-
resolutionReason: `Timed out: the answer arrived after the deadline ${existing.expiresAt}`
|
|
11475
|
-
});
|
|
11476
|
-
if (timedOut && !existing.workflowRunId) {
|
|
11477
|
-
await createApprovalFollowUpTask2(timedOut, "hitl.timeout");
|
|
11478
|
-
}
|
|
11479
|
-
});
|
|
11480
|
-
jsonError(res, `Approval request expired at ${existing.expiresAt}`, 409);
|
|
11481
|
-
return true;
|
|
11482
|
-
}
|
|
11483
|
-
const unavailableReason = await getWorkflowApprovalUnavailableReason(existing);
|
|
11484
|
-
if (unavailableReason) {
|
|
11485
|
-
jsonError(res, unavailableReason, 409);
|
|
11486
|
-
return true;
|
|
11487
|
-
}
|
|
11488
|
-
const approvers = existing.approvers;
|
|
11489
|
-
if (!isListedApprover(approvers, responder.responder)) {
|
|
11490
|
-
jsonError(res, "You are not one of this request's approvers", 403);
|
|
11491
|
-
return true;
|
|
11492
|
-
}
|
|
11493
|
-
const questions = existing.questions;
|
|
11494
|
-
const missingRequired = missingRequiredResponseIds(questions, parsed.body.responses);
|
|
11495
|
-
if (missingRequired.length > 0) {
|
|
11496
|
-
jsonError(res, `Responses missing or invalid: ${missingRequired.join(", ")}`, 400);
|
|
11497
|
-
return true;
|
|
11498
|
-
}
|
|
11499
|
-
const configQuestions = questions.filter(isConfigQuestion);
|
|
11500
|
-
const configAnswers = new Map;
|
|
11501
|
-
for (const question of configQuestions) {
|
|
11502
|
-
const state = await readConfigState(question.config);
|
|
11503
|
-
const answer = parseConfigAnswer(question, parsed.body.responses[question.id], state);
|
|
11504
|
-
if (!answer.ok) {
|
|
11505
|
-
jsonError(res, answer.error, 400);
|
|
11506
|
-
return true;
|
|
11507
|
-
}
|
|
11508
|
-
configAnswers.set(question.id, { question, answer: answer.answer });
|
|
11509
|
-
}
|
|
11510
|
-
if (configAnswers.size > 0 && approvers.policy !== "any") {
|
|
11511
|
-
jsonError(res, 'Config questions need approvers.policy "any"', 409);
|
|
11512
|
-
return true;
|
|
11513
|
-
}
|
|
11514
|
-
if ([...configAnswers.values()].some(({ answer }) => answer.action === "set")) {
|
|
11515
|
-
if (!await ensureConfigAdmin(req, res, "config.write.any"))
|
|
11516
|
-
return true;
|
|
11517
|
-
for (const { question, answer } of configAnswers.values()) {
|
|
11518
|
-
if (answer.action !== "set")
|
|
11519
|
-
continue;
|
|
11520
|
-
if (!await ensureHumanOnlyConfigWrite(req, res, question.config.key))
|
|
11521
|
-
return true;
|
|
11522
|
-
}
|
|
11523
|
-
const userId = authUserId(getRequestAuth(req));
|
|
11524
|
-
if (userId && isRbacEnabled()) {
|
|
11525
|
-
const grant = await getUserGrant2(userId);
|
|
11526
|
-
if (!grant.grantsAll && !grant.verbs.has("config.write.any")) {
|
|
11527
|
-
jsonError(res, "Forbidden: setting a config value needs 'config.write.any'", 403);
|
|
11528
|
-
return true;
|
|
11529
|
-
}
|
|
11530
|
-
}
|
|
11531
|
-
}
|
|
11532
|
-
const safeResponses = { ...parsed.body.responses };
|
|
11533
|
-
for (const id of configAnswers.keys())
|
|
11534
|
-
delete safeResponses[id];
|
|
11535
|
-
let status = "approved";
|
|
11536
|
-
for (const q of questions) {
|
|
11537
|
-
if (q.type === "approval") {
|
|
11538
|
-
const answer = safeResponses[q.id];
|
|
11539
|
-
if (answer && answer.approved === false) {
|
|
11540
|
-
status = "rejected";
|
|
11541
|
-
break;
|
|
11542
|
-
}
|
|
11543
|
-
}
|
|
11544
|
-
}
|
|
11545
|
-
const responderId = responderKey(responder.responder);
|
|
11546
|
-
const respondedAt = new Date().toISOString();
|
|
11547
|
-
const configWrites = [];
|
|
11548
|
-
const outcome = await getDbClient2().transaction(async () => {
|
|
11549
|
-
const current = await getApprovalRequestById2(parsed.params.id);
|
|
11550
|
-
if (!current || current.status !== "pending")
|
|
11551
|
-
return { kind: "unavailable" };
|
|
11552
|
-
const prior = current.approvals ?? [];
|
|
11553
|
-
if (prior.some((v) => v.responder === responderId))
|
|
11554
|
-
return { kind: "duplicate" };
|
|
11555
|
-
const responses = { ...safeResponses };
|
|
11556
|
-
for (const [id, { question, answer }] of configAnswers) {
|
|
11557
|
-
if (status === "rejected" || answer.action === "skip") {
|
|
11558
|
-
responses[id] = skippedConfigResult(question);
|
|
11559
|
-
} else if (answer.action === "keep") {
|
|
11560
|
-
const kept = await keptConfigResult(question);
|
|
11561
|
-
if (!kept) {
|
|
11562
|
-
throw new ConfigRespondAbort("conflict", `config question "${id}": the key was removed before the answer was saved`);
|
|
11563
|
-
}
|
|
11564
|
-
responses[id] = kept;
|
|
11565
|
-
} else {
|
|
11566
|
-
const written = await applyConfigAnswer(question, answer.value);
|
|
11567
|
-
configWrites.push({ result: written, value: answer.value });
|
|
11568
|
-
responses[id] = written;
|
|
11569
|
-
}
|
|
11570
|
-
}
|
|
11571
|
-
const vote = {
|
|
11572
|
-
responder: responderId,
|
|
11573
|
-
approved: status === "approved",
|
|
11574
|
-
responses,
|
|
11575
|
-
...parsed.body.respondedBy ? { claimedRespondedBy: parsed.body.respondedBy } : {},
|
|
11576
|
-
respondedAt
|
|
11577
|
-
};
|
|
11578
|
-
const votes = [...prior, vote];
|
|
11579
|
-
if (status === "rejected" || await approvalQuorumMet(approvers, votes)) {
|
|
11580
|
-
const resolved = await resolveApprovalRequest2(parsed.params.id, { status, responses, approvals: votes, resolvedBy: responderId }, { requireActionableWorkflow: true });
|
|
11581
|
-
if (!resolved && configWrites.length > 0)
|
|
11582
|
-
throw new ConfigRespondAbort("unavailable");
|
|
11583
|
-
return resolved ? { kind: "resolved", request: resolved } : { kind: "unavailable" };
|
|
11584
|
-
}
|
|
11585
|
-
const recorded = await recordApprovalVotes2(parsed.params.id, votes) ? await getApprovalRequestById2(parsed.params.id) : null;
|
|
11586
|
-
return recorded ? { kind: "recorded", request: recorded } : { kind: "unavailable" };
|
|
11587
|
-
}).catch((error) => {
|
|
11588
|
-
if (!(error instanceof ConfigRespondAbort))
|
|
11589
|
-
throw error;
|
|
11590
|
-
configWrites.length = 0;
|
|
11591
|
-
return error.kind === "conflict" ? { kind: "conflict", message: error.message } : { kind: "unavailable" };
|
|
11592
|
-
});
|
|
11593
|
-
if (outcome.kind === "conflict") {
|
|
11594
|
-
jsonError(res, outcome.message, 409);
|
|
11595
|
-
return true;
|
|
11596
|
-
}
|
|
11597
|
-
for (const { result, value } of configWrites) {
|
|
11598
|
-
try {
|
|
11599
|
-
await runConfigWriteSideEffects(result.scope, result.key, value);
|
|
11600
|
-
} catch (err) {
|
|
11601
|
-
console.error("[approval-requests] Config side effects failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
11602
|
-
}
|
|
11603
|
-
}
|
|
11604
|
-
if (outcome.kind === "duplicate") {
|
|
11605
|
-
jsonError(res, "You already answered this approval request", 409);
|
|
11606
|
-
return true;
|
|
11607
|
-
}
|
|
11608
|
-
if (outcome.kind === "recorded") {
|
|
11609
|
-
respondRoute.respond(res, 200, {
|
|
11610
|
-
approvalRequest: await toApprovalRequestResponse(outcome.request)
|
|
11611
|
-
});
|
|
11612
|
-
return true;
|
|
11613
|
-
}
|
|
11614
|
-
const updated = outcome.kind === "resolved" ? outcome.request : null;
|
|
11615
|
-
if (!updated) {
|
|
11616
|
-
const latest = await getApprovalRequestById2(parsed.params.id);
|
|
11617
|
-
const unavailableAfterRace = latest ? await getWorkflowApprovalUnavailableReason(latest) : null;
|
|
11618
|
-
jsonError(res, unavailableAfterRace ?? `Failed to resolve approval request (status: ${latest?.status ?? "unknown"})`, 409);
|
|
11619
|
-
return true;
|
|
11620
|
-
}
|
|
11621
|
-
workflowEventBus2.emit("approval.resolved", {
|
|
11622
|
-
requestId: updated.id,
|
|
11623
|
-
status: updated.status,
|
|
11624
|
-
responses: updated.responses,
|
|
11625
|
-
workflowRunId: updated.workflowRunId ?? undefined,
|
|
11626
|
-
workflowRunStepId: updated.workflowRunStepId ?? undefined,
|
|
11627
|
-
sourceTaskId: updated.sourceTaskId ?? undefined
|
|
11628
|
-
});
|
|
11629
|
-
await createApprovalFollowUpTask2(updated, "hitl.follow_up");
|
|
11630
|
-
respondRoute.respond(res, 200, {
|
|
11631
|
-
approvalRequest: await toApprovalRequestResponse(updated, { withConfigState: true })
|
|
11632
|
-
});
|
|
11633
|
-
return true;
|
|
11634
|
-
}
|
|
11635
|
-
if (cancelRoute.match(req.method, pathSegments)) {
|
|
11636
|
-
const parsed = await cancelRoute.parse(req, res, pathSegments, queryParams);
|
|
11637
|
-
if (!parsed)
|
|
11638
|
-
return true;
|
|
11639
|
-
const { principal, resolvedBy } = await approvalCallerPrincipal(req);
|
|
11640
|
-
const result = await cancelApprovalRequest({
|
|
11641
|
-
id: parsed.params.id,
|
|
11642
|
-
reason: parsed.body.reason,
|
|
11643
|
-
principal,
|
|
11644
|
-
resolvedBy
|
|
11645
|
-
});
|
|
11646
|
-
if (!result.ok) {
|
|
11647
|
-
jsonError(res, result.message, result.status);
|
|
11648
|
-
return true;
|
|
11649
|
-
}
|
|
11650
|
-
cancelRoute.respond(res, 200, {
|
|
11651
|
-
approvalRequest: await toApprovalRequestResponse(result.request),
|
|
11652
|
-
alreadyCancelled: result.alreadyCancelled,
|
|
11653
|
-
runCancelled: result.runCancelled
|
|
11654
|
-
});
|
|
11655
|
-
return true;
|
|
11656
|
-
}
|
|
11657
|
-
if (getByIdRoute.match(req.method, pathSegments)) {
|
|
11658
|
-
const parsed = await getByIdRoute.parse(req, res, pathSegments, queryParams);
|
|
11659
|
-
if (!parsed)
|
|
11660
|
-
return true;
|
|
11661
|
-
const request = await getApprovalRequestById2(parsed.params.id);
|
|
11662
|
-
if (!request) {
|
|
11663
|
-
jsonError(res, "Approval request not found", 404);
|
|
11664
|
-
return true;
|
|
11665
|
-
}
|
|
11666
|
-
getByIdRoute.respond(res, 200, {
|
|
11667
|
-
approvalRequest: await toApprovalRequestResponse(request, { withConfigState: true })
|
|
11668
|
-
});
|
|
11669
|
-
return true;
|
|
11670
|
-
}
|
|
11671
|
-
if (createRoute.match(req.method, pathSegments)) {
|
|
11672
|
-
const parsed = await createRoute.parse(req, res, pathSegments, queryParams);
|
|
11673
|
-
if (!parsed)
|
|
11674
|
-
return true;
|
|
11675
|
-
if (parsed.body.notifications?.some((notification) => notification.channel === "slack")) {
|
|
11676
|
-
const { principal } = await approvalCallerPrincipal(req);
|
|
11677
|
-
const decision = can({ principal, verb: "integration.slack.post", source: "http" });
|
|
11678
|
-
if (!decision.allow) {
|
|
11679
|
-
jsonError(res, SLACK_NOTIFICATION_REFUSED, 403);
|
|
11680
|
-
return true;
|
|
11681
|
-
}
|
|
11682
|
-
}
|
|
11683
|
-
const normalized = await normalizeApprovalQuestions(parsed.body.questions, {
|
|
11684
|
-
approvers: parsed.body.approvers
|
|
11685
|
-
});
|
|
11686
|
-
if (!normalized.ok) {
|
|
11687
|
-
jsonError(res, normalized.error, 400);
|
|
11688
|
-
return true;
|
|
11689
|
-
}
|
|
11690
|
-
const questions = normalized.questions;
|
|
11691
|
-
const id = crypto.randomUUID();
|
|
11692
|
-
const rawCallerAgentId = req.headers["x-agent-id"];
|
|
11693
|
-
const callerAgentId = Array.isArray(rawCallerAgentId) ? rawCallerAgentId[0] : rawCallerAgentId;
|
|
11694
|
-
const createdBy = authUserId(getRequestAuth(req)) ?? await resolveTaskAuditUserId(parsed.body.sourceTaskId, callerAgentId) ?? undefined;
|
|
11695
|
-
const request = await createApprovalRequest2({
|
|
11696
|
-
id,
|
|
11697
|
-
title: parsed.body.title,
|
|
11698
|
-
questions,
|
|
11699
|
-
approvers: parsed.body.approvers,
|
|
11700
|
-
workflowRunId: parsed.body.workflowRunId,
|
|
11701
|
-
workflowRunStepId: parsed.body.workflowRunStepId,
|
|
11702
|
-
sourceTaskId: parsed.body.sourceTaskId,
|
|
11703
|
-
timeoutSeconds: parsed.body.timeoutSeconds,
|
|
11704
|
-
notificationChannels: parsed.body.notifications,
|
|
11705
|
-
createdBy
|
|
11706
|
-
});
|
|
11707
|
-
const notifications = parsed.body.notifications;
|
|
11708
|
-
if (notifications?.length && request.status === "pending") {
|
|
11709
|
-
dispatchApprovalNotifications2({
|
|
11710
|
-
requestId: request.id,
|
|
11711
|
-
title: request.title,
|
|
11712
|
-
questions,
|
|
11713
|
-
timeoutSeconds: parsed.body.timeoutSeconds,
|
|
11714
|
-
notifications
|
|
11715
|
-
}).catch((err) => {
|
|
11716
|
-
console.error("[approval-requests] Unexpected error dispatching notifications:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
11717
|
-
});
|
|
11718
|
-
}
|
|
11719
|
-
createRoute.respond(res, 201, {
|
|
11720
|
-
approvalRequest: await toApprovalRequestResponse(request)
|
|
11721
|
-
});
|
|
11722
|
-
return true;
|
|
11723
|
-
}
|
|
11724
|
-
if (listRoute.match(req.method, pathSegments)) {
|
|
11725
|
-
const parsed = await listRoute.parse(req, res, pathSegments, queryParams);
|
|
11726
|
-
if (!parsed)
|
|
11727
|
-
return true;
|
|
11728
|
-
const filters = {
|
|
11729
|
-
status: parsed.query.status || undefined,
|
|
11730
|
-
workflowRunId: parsed.query.workflowRunId || undefined,
|
|
11731
|
-
limit: parsed.query.limit || undefined
|
|
11732
|
-
};
|
|
11733
|
-
if (parsed.query.fields === "slim") {
|
|
11734
|
-
const viewer = await approvalResponder(req);
|
|
11735
|
-
listRoute.respond(res, 200, {
|
|
11736
|
-
approvalRequests: await withApprovalProgress(await listApprovalRequestSummaries2(filters), viewer.ok ? viewer.responder : null)
|
|
11737
|
-
});
|
|
11738
|
-
return true;
|
|
11739
|
-
}
|
|
11740
|
-
const requests = await listApprovalRequests2(filters);
|
|
11741
|
-
listRoute.respond(res, 200, {
|
|
11742
|
-
approvalRequests: await Promise.all(requests.map((request) => toApprovalRequestResponse(request)))
|
|
11743
|
-
});
|
|
11744
|
-
return true;
|
|
11745
|
-
}
|
|
11746
|
-
return false;
|
|
11747
|
-
}
|
|
11748
|
-
var SLACK_NOTIFICATION_REFUSED = "Slack notifications require lead privileges (integration.slack.post). Create the request without them, or ask the lead to post the link.";
|
|
11749
|
-
async function approvalCallerPrincipal(req) {
|
|
11750
|
-
const rawAgentId = req.headers["x-agent-id"];
|
|
11751
|
-
const headerAgentId = Array.isArray(rawAgentId) ? rawAgentId[0] : rawAgentId;
|
|
11752
|
-
const principal = await agentFirstPrincipal(req, headerAgentId);
|
|
11753
|
-
const resolvedBy = principal.kind === "user" ? principal.userId : principal.kind === "agent" ? principal.agentId : principal.kind === "operator" ? "operator" : null;
|
|
11754
|
-
return { principal, resolvedBy };
|
|
11755
|
-
}
|
|
11756
|
-
function userMatchesListed(user, listed) {
|
|
11757
|
-
if (listed === user.id)
|
|
11758
|
-
return true;
|
|
11759
|
-
return !!user.email && listed.toLowerCase() === user.email.toLowerCase();
|
|
11760
|
-
}
|
|
11761
|
-
function isListedApprover(approvers, responder) {
|
|
11762
|
-
const users = approvers.users ?? [];
|
|
11763
|
-
const roles = approvers.roles ?? [];
|
|
11764
|
-
if (users.length === 0 && roles.length === 0)
|
|
11765
|
-
return true;
|
|
11766
|
-
if (responder.kind === "operator")
|
|
11767
|
-
return true;
|
|
11768
|
-
const { user } = responder;
|
|
11769
|
-
if (users.some((listed) => userMatchesListed(user, listed)))
|
|
11770
|
-
return true;
|
|
11771
|
-
return !!user.role && roles.includes(user.role);
|
|
11772
|
-
}
|
|
11773
|
-
async function approvalProgress(approvers, votes) {
|
|
11774
|
-
const approving = votes.filter((v) => v.approved);
|
|
11775
|
-
const distinct = new Set(approving.map((v) => v.responder)).size;
|
|
11776
|
-
const policy = approvers.policy;
|
|
11777
|
-
if (policy === "any")
|
|
11778
|
-
return { approved: Math.min(distinct, 1), required: 1 };
|
|
11779
|
-
if (policy === "all") {
|
|
11780
|
-
const listed = approvers.users ?? [];
|
|
11781
|
-
if (listed.length === 0)
|
|
11782
|
-
return { approved: Math.min(distinct, 1), required: 1 };
|
|
11783
|
-
const approvingUsers = [];
|
|
11784
|
-
for (const vote of approving) {
|
|
11785
|
-
if (vote.responder === "operator")
|
|
11786
|
-
continue;
|
|
11787
|
-
const user = await findUserById(vote.responder);
|
|
11788
|
-
approvingUsers.push(user ?? { id: vote.responder });
|
|
11789
|
-
}
|
|
11790
|
-
const approved = listed.filter((entry) => approvingUsers.some((u) => userMatchesListed(u, entry))).length;
|
|
11791
|
-
return { approved, required: listed.length };
|
|
11792
|
-
}
|
|
11793
|
-
return { approved: Math.min(distinct, policy.min), required: policy.min };
|
|
11794
|
-
}
|
|
11795
|
-
async function approvalQuorumMet(approvers, votes) {
|
|
11796
|
-
const { approved, required } = await approvalProgress(approvers, votes);
|
|
11797
|
-
return approved >= required;
|
|
11798
|
-
}
|
|
11799
|
-
|
|
11800
10153
|
// src/http/index.ts
|
|
10154
|
+
init_approval_requests();
|
|
11801
10155
|
init_apps();
|
|
11802
10156
|
|
|
11803
10157
|
// src/http/assets.ts
|
|
@@ -12317,7 +10671,7 @@ init_constants3();
|
|
|
12317
10671
|
init_env_flag();
|
|
12318
10672
|
init_secret_scrubber();
|
|
12319
10673
|
init_adapters();
|
|
12320
|
-
|
|
10674
|
+
init_config2();
|
|
12321
10675
|
|
|
12322
10676
|
// src/integrations/chat-sdk/discord-api.ts
|
|
12323
10677
|
init_secret_scrubber();
|
|
@@ -12907,6 +11261,7 @@ init_auth_json();
|
|
|
12907
11261
|
init_flow();
|
|
12908
11262
|
init_storage();
|
|
12909
11263
|
init_codex_auth_failure();
|
|
11264
|
+
init_config();
|
|
12910
11265
|
init_route_def();
|
|
12911
11266
|
init_utils2();
|
|
12912
11267
|
var CodexAccountSchema = object2({
|
|
@@ -13806,6 +12161,7 @@ async function exchangeDeviceAuthorizationCode(authorizationCode, codeVerifier)
|
|
|
13806
12161
|
// src/http/codex-oauth-device.ts
|
|
13807
12162
|
init_storage();
|
|
13808
12163
|
init_secret_scrubber();
|
|
12164
|
+
init_config();
|
|
13809
12165
|
init_route_def();
|
|
13810
12166
|
init_utils2();
|
|
13811
12167
|
var FLOW_TTL_MS = 15 * 60 * 1000;
|
|
@@ -14181,7 +12537,7 @@ async function handleCodexOAuthKeepWarm(req, res, pathSegments) {
|
|
|
14181
12537
|
// src/http/comb.ts
|
|
14182
12538
|
init_zod();
|
|
14183
12539
|
init_audit_user();
|
|
14184
|
-
|
|
12540
|
+
init_config4();
|
|
14185
12541
|
|
|
14186
12542
|
// src/comb/review-batch.ts
|
|
14187
12543
|
init_db4();
|
|
@@ -14221,7 +12577,7 @@ async function getCombServiceUserId() {
|
|
|
14221
12577
|
}
|
|
14222
12578
|
|
|
14223
12579
|
// src/comb/review-batch.ts
|
|
14224
|
-
|
|
12580
|
+
init_config4();
|
|
14225
12581
|
|
|
14226
12582
|
// src/comb/markers.ts
|
|
14227
12583
|
var SENT_MARKER_PREFIX = "[comb:sent task=";
|
|
@@ -14699,6 +13055,9 @@ async function handleComb(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
14699
13055
|
return true;
|
|
14700
13056
|
}
|
|
14701
13057
|
|
|
13058
|
+
// src/http/index.ts
|
|
13059
|
+
init_config();
|
|
13060
|
+
|
|
14702
13061
|
// src/http/context.ts
|
|
14703
13062
|
init_zod();
|
|
14704
13063
|
init_db4();
|
|
@@ -14816,6 +13175,95 @@ async function handleContext(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
14816
13175
|
init_core();
|
|
14817
13176
|
init_db_query();
|
|
14818
13177
|
|
|
13178
|
+
// src/http/design-system.ts
|
|
13179
|
+
init_zod();
|
|
13180
|
+
init_design_system2();
|
|
13181
|
+
init_rbac();
|
|
13182
|
+
init_design_system();
|
|
13183
|
+
init_types5();
|
|
13184
|
+
init_request_principal();
|
|
13185
|
+
init_route_def();
|
|
13186
|
+
init_utils2();
|
|
13187
|
+
var DesignSystemStateSchema = object2({
|
|
13188
|
+
status: _enum2(["none", "invalid", "active", "declined"]),
|
|
13189
|
+
designSystem: DesignSystemSchema.nullable(),
|
|
13190
|
+
invalidReason: string2().optional(),
|
|
13191
|
+
previous: DesignSystemSchema.nullable()
|
|
13192
|
+
});
|
|
13193
|
+
var getDesignSystemRoute = route({
|
|
13194
|
+
method: "get",
|
|
13195
|
+
path: "/api/design-system",
|
|
13196
|
+
pattern: ["api", "design-system"],
|
|
13197
|
+
summary: "Get the org design system",
|
|
13198
|
+
tags: ["Pages"],
|
|
13199
|
+
responses: {
|
|
13200
|
+
200: {
|
|
13201
|
+
description: "The org design system and the value it replaced",
|
|
13202
|
+
schema: DesignSystemStateSchema
|
|
13203
|
+
}
|
|
13204
|
+
}
|
|
13205
|
+
});
|
|
13206
|
+
var putDesignSystemRoute = route({
|
|
13207
|
+
method: "put",
|
|
13208
|
+
path: "/api/design-system",
|
|
13209
|
+
pattern: ["api", "design-system"],
|
|
13210
|
+
summary: "Set or decline the org design system",
|
|
13211
|
+
tags: ["Pages"],
|
|
13212
|
+
rbac: { permission: "design-system.write" },
|
|
13213
|
+
body: DesignSystemInputSchema,
|
|
13214
|
+
responses: {
|
|
13215
|
+
200: {
|
|
13216
|
+
description: "The saved, normalized design system",
|
|
13217
|
+
schema: object2({ designSystem: DesignSystemSchema, ignoredTokens: array2(string2()) })
|
|
13218
|
+
},
|
|
13219
|
+
400: { description: "Invalid design system" },
|
|
13220
|
+
403: { description: "Permission denied" }
|
|
13221
|
+
}
|
|
13222
|
+
});
|
|
13223
|
+
function recordOf(stored) {
|
|
13224
|
+
return "record" in stored ? stored.record : null;
|
|
13225
|
+
}
|
|
13226
|
+
async function handleDesignSystem(req, res, pathSegments, queryParams, myAgentId) {
|
|
13227
|
+
if (getDesignSystemRoute.match(req.method, pathSegments)) {
|
|
13228
|
+
const parsed = await getDesignSystemRoute.parse(req, res, pathSegments, queryParams);
|
|
13229
|
+
if (!parsed)
|
|
13230
|
+
return true;
|
|
13231
|
+
const { current, previous } = await getDesignSystem();
|
|
13232
|
+
getDesignSystemRoute.respond(res, 200, {
|
|
13233
|
+
status: current.status,
|
|
13234
|
+
designSystem: recordOf(current),
|
|
13235
|
+
..."reason" in current ? { invalidReason: current.reason } : {},
|
|
13236
|
+
previous: recordOf(previous)
|
|
13237
|
+
});
|
|
13238
|
+
return true;
|
|
13239
|
+
}
|
|
13240
|
+
if (putDesignSystemRoute.match(req.method, pathSegments)) {
|
|
13241
|
+
const parsed = await putDesignSystemRoute.parse(req, res, pathSegments, queryParams);
|
|
13242
|
+
if (!parsed)
|
|
13243
|
+
return true;
|
|
13244
|
+
const principal = await agentFirstPrincipal(req, myAgentId);
|
|
13245
|
+
const decision = can({ principal, verb: "design-system.write", source: "http" });
|
|
13246
|
+
if (!decision.allow) {
|
|
13247
|
+
jsonError(res, decision.reason, 403);
|
|
13248
|
+
return true;
|
|
13249
|
+
}
|
|
13250
|
+
try {
|
|
13251
|
+
const { record, ignored } = buildDesignSystem(parsed.body, {
|
|
13252
|
+
userId: principal.kind === "user" ? principal.userId : null,
|
|
13253
|
+
...principal.kind === "agent" ? { agentId: principal.agentId } : {}
|
|
13254
|
+
});
|
|
13255
|
+
await saveDesignSystem(record);
|
|
13256
|
+
putDesignSystemRoute.respond(res, 200, { designSystem: record, ignoredTokens: ignored });
|
|
13257
|
+
} catch (err) {
|
|
13258
|
+
if (!(err instanceof DesignSystemError))
|
|
13259
|
+
throw err;
|
|
13260
|
+
jsonError(res, err.message, 400);
|
|
13261
|
+
}
|
|
13262
|
+
return true;
|
|
13263
|
+
}
|
|
13264
|
+
return false;
|
|
13265
|
+
}
|
|
13266
|
+
|
|
14819
13267
|
// src/http/events.ts
|
|
14820
13268
|
init_zod();
|
|
14821
13269
|
init_events();
|
|
@@ -18317,7 +16765,7 @@ var catalogRoute = route({
|
|
|
18317
16765
|
}
|
|
18318
16766
|
}
|
|
18319
16767
|
});
|
|
18320
|
-
var
|
|
16768
|
+
var listRoute = route({
|
|
18321
16769
|
method: "get",
|
|
18322
16770
|
path: "/api/extensions",
|
|
18323
16771
|
pattern: ["api", "extensions"],
|
|
@@ -18638,11 +17086,11 @@ async function handleExtensions(req, res, pathSegments, queryParams, agentId) {
|
|
|
18638
17086
|
});
|
|
18639
17087
|
return true;
|
|
18640
17088
|
}
|
|
18641
|
-
if (
|
|
18642
|
-
const parsed = await
|
|
17089
|
+
if (listRoute.match(req.method, pathSegments)) {
|
|
17090
|
+
const parsed = await listRoute.parse(req, res, pathSegments, queryParams);
|
|
18643
17091
|
if (!parsed)
|
|
18644
17092
|
return true;
|
|
18645
|
-
|
|
17093
|
+
listRoute.respond(res, 200, { extensions: (await listExtensions()).map(redactExtension) });
|
|
18646
17094
|
return true;
|
|
18647
17095
|
}
|
|
18648
17096
|
if (catalogRoute.match(req.method, pathSegments)) {
|
|
@@ -19077,12 +17525,14 @@ async function getLocalFleetStats(now = new Date, { requireIngestAnchor = true }
|
|
|
19077
17525
|
init_telemetry();
|
|
19078
17526
|
init_company_profile();
|
|
19079
17527
|
init_org_website();
|
|
17528
|
+
init_global_config();
|
|
19080
17529
|
init_request_principal();
|
|
19081
17530
|
init_route_def();
|
|
17531
|
+
init_used_by();
|
|
19082
17532
|
var FLEET_TTL_MS = 24 * 60 * 60 * 1000;
|
|
19083
17533
|
var FLEET_FAILURE_TTL_MS = 60 * 60 * 1000;
|
|
19084
17534
|
var LOCAL_TTL_MS = 10 * 60 * 1000;
|
|
19085
|
-
var
|
|
17535
|
+
var TIMEOUT_MS = 1e4;
|
|
19086
17536
|
var FleetStateSchema = _enum2([
|
|
19087
17537
|
"ready",
|
|
19088
17538
|
"telemetry_off",
|
|
@@ -19176,7 +17626,7 @@ async function fleetBenchmarks(now, peerGroup) {
|
|
|
19176
17626
|
return fleetCache.value;
|
|
19177
17627
|
let value = null;
|
|
19178
17628
|
try {
|
|
19179
|
-
const response = await fetch(key, { signal: AbortSignal.timeout(
|
|
17629
|
+
const response = await fetch(key, { signal: AbortSignal.timeout(TIMEOUT_MS) });
|
|
19180
17630
|
if (response.ok) {
|
|
19181
17631
|
const parsed = ProxyFleetBenchmarksSchema.safeParse(await response.json());
|
|
19182
17632
|
if (parsed.success)
|
|
@@ -19416,7 +17866,7 @@ init_rbac_roles();
|
|
|
19416
17866
|
init_agent_fs_provision();
|
|
19417
17867
|
init_task_attachment_store();
|
|
19418
17868
|
init_users();
|
|
19419
|
-
|
|
17869
|
+
init_config4();
|
|
19420
17870
|
init_provider();
|
|
19421
17871
|
init_registry2();
|
|
19422
17872
|
init_rbac();
|
|
@@ -20046,7 +18496,7 @@ async function sendUpload(req, res, taskId, query, agentId, isDraft) {
|
|
|
20046
18496
|
return true;
|
|
20047
18497
|
}
|
|
20048
18498
|
const provider = getFileStorageProvider2();
|
|
20049
|
-
const contentType =
|
|
18499
|
+
const contentType = singleHeader(req, "content-type") ?? "application/octet-stream";
|
|
20050
18500
|
const scope = { taskId, name: query.name };
|
|
20051
18501
|
let uploaded;
|
|
20052
18502
|
const uploadStartedAt = performance.now();
|
|
@@ -20199,7 +18649,7 @@ async function readRawBody(req, maxBytes) {
|
|
|
20199
18649
|
}
|
|
20200
18650
|
return Buffer.concat(chunks);
|
|
20201
18651
|
}
|
|
20202
|
-
function
|
|
18652
|
+
function singleHeader(req, name) {
|
|
20203
18653
|
const raw = req.headers[name];
|
|
20204
18654
|
return Array.isArray(raw) ? raw[0] : raw;
|
|
20205
18655
|
}
|
|
@@ -20349,8 +18799,10 @@ async function handleHeartbeat(req, res, pathSegments) {
|
|
|
20349
18799
|
init_zod();
|
|
20350
18800
|
init_improvements();
|
|
20351
18801
|
init_rbac();
|
|
18802
|
+
init_person_responder();
|
|
20352
18803
|
init_request_principal();
|
|
20353
18804
|
init_route_def();
|
|
18805
|
+
init_used_by();
|
|
20354
18806
|
init_utils2();
|
|
20355
18807
|
var ImprovementSchema = object2({
|
|
20356
18808
|
id: string2(),
|
|
@@ -20371,7 +18823,7 @@ var ImprovementSchema = object2({
|
|
|
20371
18823
|
});
|
|
20372
18824
|
var EmailSchema = string2().max(320, "Email must be at most 320 characters").email("Email must be a valid email address");
|
|
20373
18825
|
var PERSON_REFUSED = "Agents cannot approve improvements. A person must approve with a user token or the dashboard.";
|
|
20374
|
-
var
|
|
18826
|
+
var listRoute2 = route({
|
|
20375
18827
|
method: "get",
|
|
20376
18828
|
path: "/api/improvements",
|
|
20377
18829
|
pattern: ["api", "improvements"],
|
|
@@ -20386,7 +18838,7 @@ var listRoute3 = route({
|
|
|
20386
18838
|
},
|
|
20387
18839
|
auth: { apiKey: true }
|
|
20388
18840
|
});
|
|
20389
|
-
var
|
|
18841
|
+
var createRoute = route({
|
|
20390
18842
|
method: "post",
|
|
20391
18843
|
path: "/api/improvements",
|
|
20392
18844
|
pattern: ["api", "improvements"],
|
|
@@ -20483,19 +18935,19 @@ async function improvementsEndpoint() {
|
|
|
20483
18935
|
return telemetryProxyEndpoint("/v1/improvements");
|
|
20484
18936
|
}
|
|
20485
18937
|
async function handleImprovements(req, res, pathSegments, queryParams) {
|
|
20486
|
-
if (
|
|
20487
|
-
const parsed = await
|
|
18938
|
+
if (listRoute2.match(req.method, pathSegments)) {
|
|
18939
|
+
const parsed = await listRoute2.parse(req, res, pathSegments, queryParams);
|
|
20488
18940
|
if (!parsed)
|
|
20489
18941
|
return true;
|
|
20490
18942
|
const rows = await listImprovements();
|
|
20491
|
-
|
|
18943
|
+
listRoute2.respond(res, 200, {
|
|
20492
18944
|
enabled: await isImprovementsEnabled(),
|
|
20493
18945
|
improvements: await Promise.all(rows.map(withLeakHints))
|
|
20494
18946
|
});
|
|
20495
18947
|
return true;
|
|
20496
18948
|
}
|
|
20497
|
-
if (
|
|
20498
|
-
const parsed = await
|
|
18949
|
+
if (createRoute.match(req.method, pathSegments)) {
|
|
18950
|
+
const parsed = await createRoute.parse(req, res, pathSegments, queryParams);
|
|
20499
18951
|
if (!parsed)
|
|
20500
18952
|
return true;
|
|
20501
18953
|
const { text, email, sendNow, source } = parsed.body;
|
|
@@ -20530,11 +18982,11 @@ async function handleImprovements(req, res, pathSegments, queryParams) {
|
|
|
20530
18982
|
endpoint: await improvementsEndpoint(),
|
|
20531
18983
|
updatedBy: person.responder.kind === "user" ? person.responder.user.id : null
|
|
20532
18984
|
});
|
|
20533
|
-
|
|
18985
|
+
createRoute.respond(res, 200, { improvement: sent });
|
|
20534
18986
|
return true;
|
|
20535
18987
|
}
|
|
20536
18988
|
}
|
|
20537
|
-
|
|
18989
|
+
createRoute.respond(res, 201, { improvement: await withLeakHints(improvement) });
|
|
20538
18990
|
} catch (error) {
|
|
20539
18991
|
if (!writeImprovementError(res, error))
|
|
20540
18992
|
throw error;
|
|
@@ -20931,6 +19383,7 @@ function buildSlackManifest(name) {
|
|
|
20931
19383
|
|
|
20932
19384
|
// src/http/integrations.ts
|
|
20933
19385
|
init_credentials2();
|
|
19386
|
+
init_config();
|
|
20934
19387
|
|
|
20935
19388
|
// src/http/config-values.ts
|
|
20936
19389
|
init_db4();
|
|
@@ -21331,14 +19784,14 @@ function decodeKvSegment(res, raw, label) {
|
|
|
21331
19784
|
}
|
|
21332
19785
|
return decoded;
|
|
21333
19786
|
}
|
|
21334
|
-
function
|
|
19787
|
+
function singleHeader2(req, name) {
|
|
21335
19788
|
const raw = req.headers[name];
|
|
21336
19789
|
if (raw === undefined)
|
|
21337
19790
|
return;
|
|
21338
19791
|
return Array.isArray(raw) ? raw[0] : raw;
|
|
21339
19792
|
}
|
|
21340
19793
|
async function resolveNamespaceFromHeaders(req) {
|
|
21341
|
-
const pageId =
|
|
19794
|
+
const pageId = singleHeader2(req, "x-page-id");
|
|
21342
19795
|
if (pageId) {
|
|
21343
19796
|
try {
|
|
21344
19797
|
return pageContextKey({ pageId });
|
|
@@ -21346,7 +19799,7 @@ async function resolveNamespaceFromHeaders(req) {
|
|
|
21346
19799
|
return null;
|
|
21347
19800
|
}
|
|
21348
19801
|
}
|
|
21349
|
-
const sourceTaskId =
|
|
19802
|
+
const sourceTaskId = singleHeader2(req, "x-source-task-id");
|
|
21350
19803
|
if (sourceTaskId) {
|
|
21351
19804
|
const task = await getTaskById2(sourceTaskId);
|
|
21352
19805
|
if (task?.contextKey)
|
|
@@ -21357,7 +19810,7 @@ async function resolveNamespaceFromHeaders(req) {
|
|
|
21357
19810
|
} catch {}
|
|
21358
19811
|
}
|
|
21359
19812
|
}
|
|
21360
|
-
const agentId =
|
|
19813
|
+
const agentId = singleHeader2(req, "x-agent-id");
|
|
21361
19814
|
if (agentId) {
|
|
21362
19815
|
try {
|
|
21363
19816
|
return agentContextKey({ agentId });
|
|
@@ -21368,8 +19821,8 @@ async function resolveNamespaceFromHeaders(req) {
|
|
|
21368
19821
|
return null;
|
|
21369
19822
|
}
|
|
21370
19823
|
async function buildAuthCtx(req) {
|
|
21371
|
-
const callerAgentId =
|
|
21372
|
-
const pageId =
|
|
19824
|
+
const callerAgentId = singleHeader2(req, "x-agent-id");
|
|
19825
|
+
const pageId = singleHeader2(req, "x-page-id");
|
|
21373
19826
|
let isLead = false;
|
|
21374
19827
|
if (callerAgentId) {
|
|
21375
19828
|
const agent = await getAgentById2(callerAgentId);
|
|
@@ -21456,7 +19909,7 @@ function encodeValueOrError(res, value, valueType) {
|
|
|
21456
19909
|
}
|
|
21457
19910
|
}
|
|
21458
19911
|
async function handleKv(req, res, pathSegments, queryParams) {
|
|
21459
|
-
const hasPageHeader =
|
|
19912
|
+
const hasPageHeader = singleHeader2(req, "x-page-id") !== undefined;
|
|
21460
19913
|
if (hasPageHeader && pathSegments[0] === "api" && pathSegments[1] === "kv" && pathSegments[2] === "_") {
|
|
21461
19914
|
pathSegments = [pathSegments[0], pathSegments[1], ...pathSegments.slice(4)];
|
|
21462
19915
|
}
|
|
@@ -24320,12 +22773,12 @@ async function canResolveMcpSecretsForHttpUser(req) {
|
|
|
24320
22773
|
});
|
|
24321
22774
|
return decision.allow;
|
|
24322
22775
|
}
|
|
24323
|
-
function
|
|
22776
|
+
function singleHeader3(req, name) {
|
|
24324
22777
|
const raw = req.headers[name];
|
|
24325
22778
|
return Array.isArray(raw) ? raw[0] : raw;
|
|
24326
22779
|
}
|
|
24327
22780
|
async function mcpServerPrincipal(req) {
|
|
24328
|
-
return agentFirstPrincipal(req,
|
|
22781
|
+
return agentFirstPrincipal(req, singleHeader3(req, "x-agent-id"), {
|
|
24329
22782
|
unauthenticatedFallback: "anonymous-agent"
|
|
24330
22783
|
});
|
|
24331
22784
|
}
|
|
@@ -29078,6 +27531,7 @@ init_constants3();
|
|
|
29078
27531
|
init_credentials2();
|
|
29079
27532
|
init_egress_guard();
|
|
29080
27533
|
init_openrouter_base_url();
|
|
27534
|
+
init_config();
|
|
29081
27535
|
init_core();
|
|
29082
27536
|
init_route_def();
|
|
29083
27537
|
|
|
@@ -29104,9 +27558,9 @@ async function getInstanceFeedbackSignals() {
|
|
|
29104
27558
|
|
|
29105
27559
|
// src/http/status.ts
|
|
29106
27560
|
init_memory();
|
|
29107
|
-
init_config3();
|
|
29108
|
-
init_registry2();
|
|
29109
27561
|
init_config4();
|
|
27562
|
+
init_registry2();
|
|
27563
|
+
init_config5();
|
|
29110
27564
|
init_connection_state();
|
|
29111
27565
|
init_telemetry();
|
|
29112
27566
|
init_types5();
|
|
@@ -30236,6 +28690,7 @@ init_page_versions();
|
|
|
30236
28690
|
init_version3();
|
|
30237
28691
|
init_resolver();
|
|
30238
28692
|
init_session_templates();
|
|
28693
|
+
init_rbac();
|
|
30239
28694
|
init_sibling_awareness();
|
|
30240
28695
|
init_page_fields();
|
|
30241
28696
|
init_presets();
|
|
@@ -30244,6 +28699,7 @@ init_constants3();
|
|
|
30244
28699
|
init_page_session();
|
|
30245
28700
|
init_request_auth_context();
|
|
30246
28701
|
init_favorite_owner();
|
|
28702
|
+
init_request_principal();
|
|
30247
28703
|
init_route_def();
|
|
30248
28704
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
30249
28705
|
|
|
@@ -30273,6 +28729,7 @@ init_business_use();
|
|
|
30273
28729
|
init_request_auth_context();
|
|
30274
28730
|
init_secret_scrubber();
|
|
30275
28731
|
init_vcs_repo_match();
|
|
28732
|
+
init_config();
|
|
30276
28733
|
|
|
30277
28734
|
// src/http/list-total-cache.ts
|
|
30278
28735
|
var LIST_TOTAL_TTL_MS = 30000;
|
|
@@ -32329,9 +30786,11 @@ var launchPageRoute = route({
|
|
|
32329
30786
|
summary: "Launch a page session (issues HttpOnly cookie)",
|
|
32330
30787
|
tags: ["Pages"],
|
|
32331
30788
|
params: object2({ id: string2() }),
|
|
30789
|
+
rbac: { permission: "page.launch" },
|
|
32332
30790
|
responses: {
|
|
32333
30791
|
204: { description: "Cookie issued" },
|
|
32334
30792
|
400: { description: "Launch not supported for this page (e.g. password mode)" },
|
|
30793
|
+
403: { description: "Caller may not open pages" },
|
|
32335
30794
|
404: { description: "Page not found" }
|
|
32336
30795
|
}
|
|
32337
30796
|
});
|
|
@@ -32926,6 +31385,15 @@ ${defuseFeedbackTags(note)}
|
|
|
32926
31385
|
const parsed = await launchPageRoute.parse(req, res, pathSegments, queryParams);
|
|
32927
31386
|
if (!parsed)
|
|
32928
31387
|
return true;
|
|
31388
|
+
const principal = await resolveRequestPrincipal(req, myAgentId, {
|
|
31389
|
+
unauthenticatedFallback: "operator"
|
|
31390
|
+
});
|
|
31391
|
+
const decision = principal ? can({ principal, verb: "page.launch", resource: { kind: "none" }, source: "http" }) : { allow: false, reason: "no authenticated principal" };
|
|
31392
|
+
if (!decision.allow) {
|
|
31393
|
+
applyLaunchCors(req, res);
|
|
31394
|
+
jsonError(res, decision.reason, 403);
|
|
31395
|
+
return true;
|
|
31396
|
+
}
|
|
32929
31397
|
const page = await getPage2(parsed.params.id);
|
|
32930
31398
|
if (!page) {
|
|
32931
31399
|
applyLaunchCors(req, res);
|
|
@@ -32957,6 +31425,7 @@ ${defuseFeedbackTags(note)}
|
|
|
32957
31425
|
// src/http/pages-public.ts
|
|
32958
31426
|
init_zod();
|
|
32959
31427
|
init_db4();
|
|
31428
|
+
init_design_system2();
|
|
32960
31429
|
|
|
32961
31430
|
// src/pages/browser-sdk.ts
|
|
32962
31431
|
var BROWSER_SDK_JS = `
|
|
@@ -34376,21 +32845,22 @@ function contractValues(vars) {
|
|
|
34376
32845
|
function resolvePageTheme({
|
|
34377
32846
|
pageTheme,
|
|
34378
32847
|
viewerTheme,
|
|
34379
|
-
overrides
|
|
32848
|
+
overrides,
|
|
32849
|
+
designSystem
|
|
34380
32850
|
}) {
|
|
34381
|
-
const preset = getThemePreset(pageTheme) ?? getThemePreset(viewerTheme) ?? getThemePreset(DEFAULT_THEME_ID);
|
|
34382
|
-
const
|
|
34383
|
-
const
|
|
34384
|
-
const
|
|
34385
|
-
|
|
34386
|
-
|
|
34387
|
-
|
|
34388
|
-
|
|
34389
|
-
|
|
34390
|
-
|
|
34391
|
-
|
|
34392
|
-
|
|
34393
|
-
|
|
32851
|
+
const preset = getThemePreset(pageTheme) ?? getThemePreset(designSystem?.basePreset) ?? getThemePreset(viewerTheme) ?? getThemePreset(DEFAULT_THEME_ID);
|
|
32852
|
+
const light = { ...HIVE_PAGE_TOKENS.light, ...contractValues(preset?.vars.light) };
|
|
32853
|
+
const dark = { ...HIVE_PAGE_TOKENS.dark, ...contractValues(preset?.vars.dark) };
|
|
32854
|
+
for (const layer of [designSystem?.tokens, overrides]) {
|
|
32855
|
+
const lightValues = contractValues(layer?.light);
|
|
32856
|
+
const darkValues = contractValues(layer?.dark);
|
|
32857
|
+
Object.assign(light, lightValues);
|
|
32858
|
+
Object.assign(dark, darkValues);
|
|
32859
|
+
for (const token of PAGE_THEME_SHARED_TOKENS) {
|
|
32860
|
+
const value = lightValues[token];
|
|
32861
|
+
if (value !== undefined && darkValues[token] === undefined)
|
|
32862
|
+
dark[token] = value;
|
|
32863
|
+
}
|
|
34394
32864
|
}
|
|
34395
32865
|
return { presetId: preset?.id ?? DEFAULT_THEME_ID, light, dark };
|
|
34396
32866
|
}
|
|
@@ -34491,6 +32961,12 @@ var IN_PAGE_LINK_SCRIPT = `<script>document.addEventListener("click", function (
|
|
|
34491
32961
|
var FONT_LINKS = `<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
34492
32962
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
34493
32963
|
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">`;
|
|
32964
|
+
function fontLinks(href) {
|
|
32965
|
+
const escaped = href.replaceAll("&", "&").replaceAll('"', """);
|
|
32966
|
+
return `<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
32967
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
32968
|
+
<link href="${escaped}" rel="stylesheet">`;
|
|
32969
|
+
}
|
|
34494
32970
|
var TAILWIND_SOURCE = [
|
|
34495
32971
|
'@import "tailwindcss/theme" layer(theme);',
|
|
34496
32972
|
'@import "tailwindcss/utilities" layer(utilities);',
|
|
@@ -35067,13 +33543,14 @@ ${TONE_RULES}
|
|
|
35067
33543
|
}`;
|
|
35068
33544
|
function buildPageHeadV2({
|
|
35069
33545
|
theme,
|
|
35070
|
-
mode
|
|
33546
|
+
mode,
|
|
33547
|
+
fontsHref
|
|
35071
33548
|
}) {
|
|
35072
33549
|
return [
|
|
35073
33550
|
'<base target="_blank">',
|
|
35074
33551
|
IN_PAGE_LINK_SCRIPT,
|
|
35075
33552
|
"<style>@layer properties, theme, base, components, utilities;</style>",
|
|
35076
|
-
FONT_LINKS,
|
|
33553
|
+
fontsHref ? fontLinks(fontsHref) : FONT_LINKS,
|
|
35077
33554
|
`<style id="swarm-theme">
|
|
35078
33555
|
${renderPageThemeCss(theme)}
|
|
35079
33556
|
</style>`,
|
|
@@ -35088,6 +33565,7 @@ ${PAGE_DESIGN_CSS}
|
|
|
35088
33565
|
}
|
|
35089
33566
|
|
|
35090
33567
|
// src/http/pages-public.ts
|
|
33568
|
+
init_presets();
|
|
35091
33569
|
init_types5();
|
|
35092
33570
|
init_constants3();
|
|
35093
33571
|
init_page_session();
|
|
@@ -35137,16 +33615,24 @@ var publicPageJsonRoute = route({
|
|
|
35137
33615
|
},
|
|
35138
33616
|
auth: { apiKey: false }
|
|
35139
33617
|
});
|
|
35140
|
-
function pageHead(page, queryParams, wantsPrint) {
|
|
33618
|
+
async function pageHead(page, queryParams, wantsPrint) {
|
|
35141
33619
|
if (page.designVersion === 1)
|
|
35142
33620
|
return PAGE_HEAD_V1;
|
|
33621
|
+
const designSystem = getThemePreset(page.theme) ? null : await getActiveDesignSystem();
|
|
35143
33622
|
const theme = resolvePageTheme({
|
|
35144
33623
|
pageTheme: page.theme,
|
|
35145
33624
|
viewerTheme: queryParams.get(PAGE_THEME_PARAM),
|
|
35146
|
-
overrides: page.themeTokens
|
|
33625
|
+
overrides: page.themeTokens,
|
|
33626
|
+
designSystem
|
|
33627
|
+
});
|
|
33628
|
+
const mode = designSystem?.mode ?? "viewer";
|
|
33629
|
+
const wantsDark = mode === "dark" || mode === "viewer" && queryParams.get(PAGE_MODE_PARAM) === "dark";
|
|
33630
|
+
const dark = !wantsPrint && wantsDark && countColorLiterals(page.body) < COLOR_LITERAL_THRESHOLD;
|
|
33631
|
+
return buildPageHeadV2({
|
|
33632
|
+
theme,
|
|
33633
|
+
mode: dark ? "dark" : "light",
|
|
33634
|
+
fontsHref: designSystem?.fontsHref
|
|
35147
33635
|
});
|
|
35148
|
-
const dark = !wantsPrint && queryParams.get(PAGE_MODE_PARAM) === "dark" && countColorLiterals(page.body) < COLOR_LITERAL_THRESHOLD;
|
|
35149
|
-
return buildPageHeadV2({ theme, mode: dark ? "dark" : "light" });
|
|
35150
33636
|
}
|
|
35151
33637
|
var LEADING_DOCTYPE_RE = /^\s*<!doctype\b[^>]*>/i;
|
|
35152
33638
|
var LEADING_HTML_TAG_RE = /^\s*<!doctype\b[^>]*>\s*<html\b[^>]*>/i;
|
|
@@ -35495,7 +33981,7 @@ async function handlePagesPublic(req, res, pathSegments, queryParams) {
|
|
|
35495
33981
|
}
|
|
35496
33982
|
const feedback = isPageFeedbackRequested(queryParams);
|
|
35497
33983
|
const html = injectBrowserSdk(page.body, {
|
|
35498
|
-
head: `${pageHead(page, queryParams, wantsPrint)}<meta name="swarm-viewer" content="${pageViewer(cookiePayload)}">`,
|
|
33984
|
+
head: `${await pageHead(page, queryParams, wantsPrint)}<meta name="swarm-viewer" content="${pageViewer(cookiePayload)}">`,
|
|
35499
33985
|
headFirst: feedback ? feedbackKeyGuardScript() : "",
|
|
35500
33986
|
standardsMode: page.designVersion !== 1
|
|
35501
33987
|
}) + (wantsPrint ? PRINT_AUTOTRIGGER_SCRIPT : "") + (feedback ? feedbackOverlayScripts(page.id) : "");
|
|
@@ -35645,6 +34131,7 @@ init_multi_runtime2();
|
|
|
35645
34131
|
init_request_auth_context();
|
|
35646
34132
|
init_runtime_pools_flag();
|
|
35647
34133
|
init_secret_scrubber();
|
|
34134
|
+
init_config();
|
|
35648
34135
|
init_route_def();
|
|
35649
34136
|
init_utils2();
|
|
35650
34137
|
function buildBudgetRefusedTrigger(refusal) {
|
|
@@ -36188,6 +34675,7 @@ init_multi_runtime();
|
|
|
36188
34675
|
init_swarm_config_guard();
|
|
36189
34676
|
init_credentials2();
|
|
36190
34677
|
init_secret_scrubber();
|
|
34678
|
+
init_config();
|
|
36191
34679
|
init_core();
|
|
36192
34680
|
init_route_def();
|
|
36193
34681
|
init_utils2();
|
|
@@ -36814,7 +35302,7 @@ var resetRoute = route({
|
|
|
36814
35302
|
},
|
|
36815
35303
|
auth: { apiKey: true }
|
|
36816
35304
|
});
|
|
36817
|
-
var
|
|
35305
|
+
var getByIdRoute = route({
|
|
36818
35306
|
method: "get",
|
|
36819
35307
|
path: "/api/prompt-templates/{id}",
|
|
36820
35308
|
pattern: ["api", "prompt-templates", null],
|
|
@@ -36850,7 +35338,7 @@ var deleteByIdRoute = route({
|
|
|
36850
35338
|
},
|
|
36851
35339
|
auth: { apiKey: true }
|
|
36852
35340
|
});
|
|
36853
|
-
var
|
|
35341
|
+
var listRoute3 = route({
|
|
36854
35342
|
method: "get",
|
|
36855
35343
|
path: "/api/prompt-templates",
|
|
36856
35344
|
pattern: ["api", "prompt-templates"],
|
|
@@ -37000,8 +35488,8 @@ ${templateBody}` : templateBody;
|
|
|
37000
35488
|
}
|
|
37001
35489
|
return true;
|
|
37002
35490
|
}
|
|
37003
|
-
if (
|
|
37004
|
-
const parsed = await
|
|
35491
|
+
if (getByIdRoute.match(req.method, pathSegments)) {
|
|
35492
|
+
const parsed = await getByIdRoute.parse(req, res, pathSegments, queryParams);
|
|
37005
35493
|
if (!parsed)
|
|
37006
35494
|
return true;
|
|
37007
35495
|
const template = await getPromptTemplateById2(parsed.params.id);
|
|
@@ -37010,7 +35498,7 @@ ${templateBody}` : templateBody;
|
|
|
37010
35498
|
return true;
|
|
37011
35499
|
}
|
|
37012
35500
|
const history = await getPromptTemplateHistory2(parsed.params.id);
|
|
37013
|
-
|
|
35501
|
+
getByIdRoute.respond(res, 200, { template: toPromptTemplateResponse(template), history });
|
|
37014
35502
|
return true;
|
|
37015
35503
|
}
|
|
37016
35504
|
if (deleteByIdRoute.match(req.method, pathSegments)) {
|
|
@@ -37030,8 +35518,8 @@ ${templateBody}` : templateBody;
|
|
|
37030
35518
|
}
|
|
37031
35519
|
return true;
|
|
37032
35520
|
}
|
|
37033
|
-
if (
|
|
37034
|
-
const parsed = await
|
|
35521
|
+
if (listRoute3.match(req.method, pathSegments)) {
|
|
35522
|
+
const parsed = await listRoute3.parse(req, res, pathSegments, queryParams);
|
|
37035
35523
|
if (!parsed)
|
|
37036
35524
|
return true;
|
|
37037
35525
|
const templates = getPromptTemplates2({
|
|
@@ -37040,7 +35528,7 @@ ${templateBody}` : templateBody;
|
|
|
37040
35528
|
scopeId: parsed.query.scopeId || undefined,
|
|
37041
35529
|
isDefault: parsed.query.isDefault ? parsed.query.isDefault === "true" : undefined
|
|
37042
35530
|
});
|
|
37043
|
-
|
|
35531
|
+
listRoute3.respond(res, 200, { templates: templates.map(toPromptTemplateResponse) });
|
|
37044
35532
|
return true;
|
|
37045
35533
|
}
|
|
37046
35534
|
if (upsertRoute.match(req.method, pathSegments)) {
|
|
@@ -37085,6 +35573,9 @@ ${templateBody}` : templateBody;
|
|
|
37085
35573
|
return false;
|
|
37086
35574
|
}
|
|
37087
35575
|
|
|
35576
|
+
// src/http/index.ts
|
|
35577
|
+
init_ranking();
|
|
35578
|
+
|
|
37088
35579
|
// src/http/realtime.ts
|
|
37089
35580
|
init_zod();
|
|
37090
35581
|
init_users();
|
|
@@ -40672,6 +39163,7 @@ async function calibrate(sql, opts) {
|
|
|
40672
39163
|
}
|
|
40673
39164
|
|
|
40674
39165
|
// src/http/savings-calibration.ts
|
|
39166
|
+
init_config();
|
|
40675
39167
|
init_db_query_shared();
|
|
40676
39168
|
init_route_def();
|
|
40677
39169
|
init_utils2();
|
|
@@ -41718,6 +40210,7 @@ init_telemetry();
|
|
|
41718
40210
|
init_egress_guard();
|
|
41719
40211
|
init_scoped_resource();
|
|
41720
40212
|
init_secret_scrubber();
|
|
40213
|
+
init_config();
|
|
41721
40214
|
init_route_def();
|
|
41722
40215
|
init_utils2();
|
|
41723
40216
|
var providerSchema = string2().min(1).max(255).regex(/^[A-Za-z0-9_-]+$/);
|
|
@@ -45426,6 +43919,7 @@ var createSessionCostRoute = route({
|
|
|
45426
43919
|
harness: ProviderNameSchema.nullable().optional(),
|
|
45427
43920
|
totalCostUsd: number2(),
|
|
45428
43921
|
harnessCostBilled: boolean().optional(),
|
|
43922
|
+
estimated: boolean().optional(),
|
|
45429
43923
|
taskId: string2().optional(),
|
|
45430
43924
|
inputTokens: number2().int().nonnegative().optional(),
|
|
45431
43925
|
outputTokens: number2().int().nonnegative().optional(),
|
|
@@ -45601,6 +44095,7 @@ async function handleSessionData(req, res, pathSegments, queryParams, myAgentId)
|
|
|
45601
44095
|
model,
|
|
45602
44096
|
harnessCostUsd: parsed.body.totalCostUsd,
|
|
45603
44097
|
harnessCostBilled: parsed.body.harnessCostBilled,
|
|
44098
|
+
estimated: parsed.body.estimated,
|
|
45604
44099
|
inputTokens,
|
|
45605
44100
|
outputTokens,
|
|
45606
44101
|
cacheReadTokens: cachedInputTokens,
|
|
@@ -48021,7 +46516,7 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
48021
46516
|
|
|
48022
46517
|
// src/http/slack-events.ts
|
|
48023
46518
|
init_app4();
|
|
48024
|
-
|
|
46519
|
+
init_config5();
|
|
48025
46520
|
init_route_def();
|
|
48026
46521
|
init_utils2();
|
|
48027
46522
|
var slackEventsRoute = route({
|
|
@@ -48553,6 +47048,7 @@ function validateUiEvent(event, properties) {
|
|
|
48553
47048
|
}
|
|
48554
47049
|
|
|
48555
47050
|
// src/http/telemetry-ui.ts
|
|
47051
|
+
init_config();
|
|
48556
47052
|
init_core();
|
|
48557
47053
|
init_favorite_owner();
|
|
48558
47054
|
init_request_principal();
|
|
@@ -48778,6 +47274,7 @@ init_utils2();
|
|
|
48778
47274
|
// src/http/trackers/authorize-gate.ts
|
|
48779
47275
|
init_zod();
|
|
48780
47276
|
init_audit_user();
|
|
47277
|
+
init_config();
|
|
48781
47278
|
var TrackerAuthorizeQuerySchema = object2({
|
|
48782
47279
|
redirect: string2().optional(),
|
|
48783
47280
|
format: _enum2(["redirect", "json"]).optional()
|
|
@@ -49506,6 +48003,9 @@ async function handleTrackers(req, res, pathSegments) {
|
|
|
49506
48003
|
return await handleLinearTracker(req, res, pathSegments);
|
|
49507
48004
|
}
|
|
49508
48005
|
|
|
48006
|
+
// src/http/index.ts
|
|
48007
|
+
init_used_by();
|
|
48008
|
+
|
|
49509
48009
|
// src/http/user-roles.ts
|
|
49510
48010
|
init_zod();
|
|
49511
48011
|
init_db4();
|
|
@@ -51195,11 +49695,11 @@ function gitlabWorkflowActionName(action) {
|
|
|
51195
49695
|
|
|
51196
49696
|
// src/http/webhooks.ts
|
|
51197
49697
|
init_background();
|
|
51198
|
-
|
|
49698
|
+
init_config2();
|
|
51199
49699
|
init_runtime();
|
|
51200
49700
|
init_teams_origin();
|
|
51201
49701
|
init_client();
|
|
51202
|
-
|
|
49702
|
+
init_config3();
|
|
51203
49703
|
|
|
51204
49704
|
// src/integrations/kapso/inbound.ts
|
|
51205
49705
|
init_resolver();
|
|
@@ -51208,7 +49708,7 @@ init_event_bus();
|
|
|
51208
49708
|
init_templates3();
|
|
51209
49709
|
init_identity();
|
|
51210
49710
|
init_unmapped_identities();
|
|
51211
|
-
|
|
49711
|
+
init_config3();
|
|
51212
49712
|
var KAPSO_IDENTITY_KIND = "kapso";
|
|
51213
49713
|
var WHATSAPP_IDENTITY_KIND = "whatsapp";
|
|
51214
49714
|
function extractText(message) {
|
|
@@ -52304,6 +50804,7 @@ init_readiness();
|
|
|
52304
50804
|
init_resume();
|
|
52305
50805
|
init_triggers();
|
|
52306
50806
|
init_version();
|
|
50807
|
+
init_config();
|
|
52307
50808
|
init_favorite_owner();
|
|
52308
50809
|
init_idempotency_key();
|
|
52309
50810
|
init_route_def();
|
|
@@ -53679,6 +52180,7 @@ var httpServer = createHttpServer(async (req, res) => {
|
|
|
53679
52180
|
() => handlePagesPublic(req, res, pathSegments, queryParams),
|
|
53680
52181
|
() => handlePageProxy(req, res),
|
|
53681
52182
|
() => handlePages(req, res, pathSegments, queryParams, myAgentId),
|
|
52183
|
+
() => handleDesignSystem(req, res, pathSegments, queryParams, myAgentId),
|
|
53682
52184
|
() => handleApiKeys(req, res, pathSegments, queryParams),
|
|
53683
52185
|
() => handleHeartbeat(req, res, pathSegments),
|
|
53684
52186
|
() => handleEvents(req, res, pathSegments, queryParams, myAgentId),
|
|
@@ -53724,7 +52226,7 @@ var httpServer = createHttpServer(async (req, res) => {
|
|
|
53724
52226
|
});
|
|
53725
52227
|
});
|
|
53726
52228
|
var detachRealtime = attachRealtimeTransport(httpServer);
|
|
53727
|
-
var { attachControllerTransport } = await import("./controllers-connect-
|
|
52229
|
+
var { attachControllerTransport } = await import("./controllers-connect-4wdmncqt.js");
|
|
53728
52230
|
var detachControllers = attachControllerTransport(httpServer);
|
|
53729
52231
|
var stopWorkerNudges = startWorkerNudgeListener();
|
|
53730
52232
|
var taskAutoTitles = startTaskAutoTitleListener();
|
|
@@ -53755,7 +52257,7 @@ async function shutdown() {
|
|
|
53755
52257
|
sessionsProcessed: getServerSessionsProcessed()
|
|
53756
52258
|
});
|
|
53757
52259
|
if (hasCapability("scheduling")) {
|
|
53758
|
-
const { stopScheduler } = await import("./index-
|
|
52260
|
+
const { stopScheduler } = await import("./index-e6bq0exk.js");
|
|
53759
52261
|
stopScheduler();
|
|
53760
52262
|
}
|
|
53761
52263
|
stopHeartbeat2();
|
|
@@ -53767,7 +52269,7 @@ async function shutdown() {
|
|
|
53767
52269
|
await stopSlackApp2();
|
|
53768
52270
|
await stopChatSdk();
|
|
53769
52271
|
if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
|
|
53770
|
-
const { stopOAuthKeepalive } = await import("./keepalive-
|
|
52272
|
+
const { stopOAuthKeepalive } = await import("./keepalive-9px3t7qj.js");
|
|
53771
52273
|
await stopOAuthKeepalive();
|
|
53772
52274
|
}
|
|
53773
52275
|
stopOAuthPendingGc();
|
|
@@ -53857,21 +52359,21 @@ try {
|
|
|
53857
52359
|
console.warn("[startup] CAPABILITIES upgrade seed failed (non-fatal):", err);
|
|
53858
52360
|
}
|
|
53859
52361
|
try {
|
|
53860
|
-
const { ensurePricingSeeded } = await import("./boot-seeds-
|
|
52362
|
+
const { ensurePricingSeeded } = await import("./boot-seeds-m74fc07r.js");
|
|
53861
52363
|
ensurePricingSeeded();
|
|
53862
|
-
const { startPricingRefreshLoop } = await import("./pricing-refresh-
|
|
52364
|
+
const { startPricingRefreshLoop } = await import("./pricing-refresh-1yz8jkqv.js");
|
|
53863
52365
|
startPricingRefreshLoop();
|
|
53864
52366
|
} catch (err) {
|
|
53865
52367
|
console.error("[startup] Failed to seed pricing rows:", err);
|
|
53866
52368
|
}
|
|
53867
52369
|
try {
|
|
53868
|
-
const { ensureModelProfilesSeeded } = await import("./boot-seeds-
|
|
52370
|
+
const { ensureModelProfilesSeeded } = await import("./boot-seeds-m74fc07r.js");
|
|
53869
52371
|
await ensureModelProfilesSeeded();
|
|
53870
52372
|
} catch (err) {
|
|
53871
52373
|
console.error("[startup] Failed to seed model profiles:", err);
|
|
53872
52374
|
}
|
|
53873
52375
|
try {
|
|
53874
|
-
const { ensureRbacSeeded } = await import("./boot-seeds-
|
|
52376
|
+
const { ensureRbacSeeded } = await import("./boot-seeds-m74fc07r.js");
|
|
53875
52377
|
ensureRbacSeeded();
|
|
53876
52378
|
} catch (err) {
|
|
53877
52379
|
console.error("[startup] Failed to sync RBAC seed rows:", err);
|
|
@@ -53879,13 +52381,13 @@ try {
|
|
|
53879
52381
|
throw err;
|
|
53880
52382
|
}
|
|
53881
52383
|
try {
|
|
53882
|
-
const { runAllSeeders } = await import("./index-
|
|
52384
|
+
const { runAllSeeders } = await import("./index-gfnq66t1.js");
|
|
53883
52385
|
await runAllSeeders({ scriptEmbeddingMode: "skip" });
|
|
53884
52386
|
} catch (err) {
|
|
53885
52387
|
console.error("[startup] Failed to seed built-in entities:", err);
|
|
53886
52388
|
}
|
|
53887
52389
|
try {
|
|
53888
|
-
const { runImports } = await import("./index-
|
|
52390
|
+
const { runImports } = await import("./index-2jw11t8s.js");
|
|
53889
52391
|
await runImports();
|
|
53890
52392
|
} catch (err) {
|
|
53891
52393
|
console.error("[startup] File import failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
@@ -53936,10 +52438,10 @@ httpServer.listen(port, async () => {
|
|
|
53936
52438
|
startChatSdk().catch((err) => {
|
|
53937
52439
|
console.error("[chat-sdk] Failed to start, continuing without Chat SDK:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
53938
52440
|
});
|
|
53939
|
-
import("./agent-fs-provision-
|
|
52441
|
+
import("./agent-fs-provision-zmaykqnd.js").then(({ syncAgentFsOrgSwarmUrl }) => syncAgentFsOrgSwarmUrl(getConfiguredAppUrls()[0])).catch((err) => {
|
|
53940
52442
|
console.warn("[agent-fs] Failed to set the org swarm URL:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
53941
52443
|
});
|
|
53942
|
-
import("./object-webhooks-
|
|
52444
|
+
import("./object-webhooks-8s1wtths.js").then(({ ensureObjectWebhooksForKnownDrives }) => ensureObjectWebhooksForKnownDrives()).catch((err) => {
|
|
53943
52445
|
console.warn("[objects] agent-fs webhook boot check failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
53944
52446
|
});
|
|
53945
52447
|
startQueueStallAlarm();
|
|
@@ -53955,25 +52457,22 @@ httpServer.listen(port, async () => {
|
|
|
53955
52457
|
await initWorkflows2();
|
|
53956
52458
|
await startScriptRunSupervisor(getMcpBaseUrl());
|
|
53957
52459
|
if (hasCapability("scheduling")) {
|
|
53958
|
-
const { startScheduler } = await import("./index-
|
|
53959
|
-
const { getExecutorRegistry } = await import("./index-
|
|
53960
|
-
|
|
53961
|
-
startScheduler(getExecutorRegistry(), intervalMs, {
|
|
53962
|
-
runId: globalState.__runId
|
|
53963
|
-
});
|
|
52460
|
+
const { parseSchedulerIntervalMs, startScheduler } = await import("./index-e6bq0exk.js");
|
|
52461
|
+
const { getExecutorRegistry } = await import("./index-taxmejj3.js");
|
|
52462
|
+
startScheduler(getExecutorRegistry(), parseSchedulerIntervalMs(process.env.SCHEDULER_INTERVAL_MS), { runId: globalState.__runId });
|
|
53964
52463
|
}
|
|
53965
52464
|
if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
|
|
53966
|
-
const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-
|
|
52465
|
+
const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-hf2k1vge.js");
|
|
53967
52466
|
startHeartbeat(parseHeartbeatIntervalMs(process.env.HEARTBEAT_INTERVAL_MS));
|
|
53968
52467
|
}
|
|
53969
52468
|
startPoolRouting();
|
|
53970
52469
|
startRuntimeSupervisor();
|
|
53971
52470
|
if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
|
|
53972
|
-
const { startOAuthKeepalive } = await import("./keepalive-
|
|
52471
|
+
const { startOAuthKeepalive } = await import("./keepalive-9px3t7qj.js");
|
|
53973
52472
|
startOAuthKeepalive();
|
|
53974
52473
|
}
|
|
53975
52474
|
if (!isEnvFlagEnabled("OAUTH_REFRESH_SWEEP_DISABLE", false)) {
|
|
53976
|
-
const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-
|
|
52475
|
+
const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-yqry3wn4.js");
|
|
53977
52476
|
startOAuthRefreshSweep();
|
|
53978
52477
|
}
|
|
53979
52478
|
startOAuthPendingGc();
|
|
@@ -53983,22 +52482,22 @@ httpServer.listen(port, async () => {
|
|
|
53983
52482
|
startSavingsRollup(savingsRollupSql);
|
|
53984
52483
|
startHumanFreeDrain();
|
|
53985
52484
|
startTaskSearchBackfill();
|
|
53986
|
-
import("./embedding-space-
|
|
52485
|
+
import("./embedding-space-001hhhpk.js").then(({ runEmbeddingMaintenance, setDeploymentEnvReader }) => {
|
|
53987
52486
|
setDeploymentEnvReader(getDeploymentEnvValue2);
|
|
53988
52487
|
return runEmbeddingMaintenance({ backfill: true });
|
|
53989
52488
|
}).catch((err) => {
|
|
53990
52489
|
console.error("[embedding-space] startup maintenance failed (non-fatal):", err);
|
|
53991
52490
|
});
|
|
53992
|
-
import("./boot-args-schema-
|
|
52491
|
+
import("./boot-args-schema-n099e0f2.js").then(({ runBootArgsSchemaBackfill }) => runBootArgsSchemaBackfill()).catch((err) => {
|
|
53993
52492
|
console.error("[boot-args-schema] startup backfill failed (non-fatal):", err);
|
|
53994
52493
|
});
|
|
53995
|
-
import("./boot-scrub-sweep-
|
|
52494
|
+
import("./boot-scrub-sweep-dhkfp0a7.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
|
|
53996
52495
|
console.error("[boot-scrub-sweep] startup scrub failed (non-fatal):", err);
|
|
53997
52496
|
});
|
|
53998
|
-
import("./user-merge-jobs-
|
|
52497
|
+
import("./user-merge-jobs-n20qpv6s.js").then(({ resumeUserMergeJobs }) => resumeUserMergeJobs()).catch((err) => {
|
|
53999
52498
|
console.error("[user-merge] startup resume failed (non-fatal):", err);
|
|
54000
52499
|
});
|
|
54001
|
-
import("./session-source-backfill-
|
|
52500
|
+
import("./session-source-backfill-57b50tpw.js").then(({ runSessionSourceBackfill }) => runSessionSourceBackfill()).catch((err) => {
|
|
54002
52501
|
console.error("[session-source-backfill] startup run failed (non-fatal):", err);
|
|
54003
52502
|
});
|
|
54004
52503
|
}).on("error", (err) => {
|