@desplega.ai/agent-swarm 2.13.3 → 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-k8xs4tj8.js → acp-targets-zrk9k0n7.js} +10 -10
- package/dist/{actions-pg5fxjer.js → actions-acqqj9jn.js} +236 -26
- package/dist/{agent-fs-provision-vbk3fppw.js → agent-fs-provision-zmaykqnd.js} +4 -4
- package/dist/{amp-adapter-adbhxsz9.js → amp-adapter-a7ts8tmw.js} +3 -3
- package/dist/{app-b267ggx1.js → app-tmwa442h.js} +7 -7
- package/dist/{approval-notifications-evc1a9z5.js → approval-notifications-6psaaaye.js} +8 -8
- package/dist/{assistant-wgz2ab84.js → assistant-564v6emv.js} +24 -24
- package/dist/{boot-args-schema-6tpk28j4.js → boot-args-schema-n099e0f2.js} +1 -1
- package/dist/{boot-reembed-ankp369c.js → boot-reembed-chx66qfk.js} +1 -1
- package/dist/{boot-reembed-r1zyvefv.js → boot-reembed-epvg4fp9.js} +1 -1
- package/dist/{boot-scrub-sweep-cgb6r5bd.js → boot-scrub-sweep-dhkfp0a7.js} +2 -2
- package/dist/{boot-seeds-bjceqg7b.js → boot-seeds-m74fc07r.js} +4 -4
- package/dist/{boxd-hr8rsxzq.js → boxd-451q55ys.js} +1 -1
- package/dist/{claude-adapter-knztdnff.js → claude-adapter-hw63yj3j.js} +9 -9
- package/dist/{claude-managed-adapter-qwejzqkk.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-c3g6dv0g.js → claude-sdk-session-cktyqkpk.js} +11 -11
- package/dist/{cli-7fa6yv98.js → cli-0fgvnb0x.js} +6 -6
- package/dist/{cli-2v4xxnx2.js → cli-0h8skzss.js} +1 -1
- package/dist/{cli-hhb8kbwd.js → cli-0p76my9q.js} +29 -14
- package/dist/{cli-fp65jdp2.js → cli-1kvcsd2f.js} +219 -155
- package/dist/{cli-wtffytm8.js → cli-1vmhnncj.js} +3 -3
- package/dist/{cli-268b3dgn.js → cli-29h5239w.js} +5 -5
- package/dist/{cli-8fj8yfmk.js → cli-2vp0z049.js} +1 -1
- package/dist/{cli-bh53ppqm.js → cli-3bxrrh53.js} +4 -4
- package/dist/{cli-61fzwtjk.js → cli-3tzmh38q.js} +9 -9
- package/dist/{cli-88np9va3.js → cli-3xqad83h.js} +1 -1
- package/dist/{cli-gc715jrc.js → cli-3zrwrnz7.js} +1 -1
- package/dist/{cli-dw43pnzp.js → cli-404am6f3.js} +7 -7
- package/dist/{cli-8pnawt98.js → cli-49aq3cyn.js} +4 -4
- package/dist/{cli-fbmgpt72.js → cli-4fpa0zns.js} +3 -3
- package/dist/{cli-kwm1bek7.js → cli-4pbwg7sn.js} +2 -2
- package/dist/{cli-djwt4mtn.js → cli-4q2c8rxw.js} +9 -9
- package/dist/{cli-3mf04tkh.js → cli-4vynxtrb.js} +1 -1
- package/dist/{cli-80d5g0fa.js → cli-5ashycw3.js} +3 -3
- package/dist/{cli-61p7ty8d.js → cli-5rgm8p39.js} +3 -3
- package/dist/{cli-r6xnchva.js → cli-5rxsb3wq.js} +6 -6
- package/dist/{cli-a21cwm89.js → cli-60dwk8tx.js} +3 -3
- package/dist/{cli-v1v49t36.js → cli-7by7vp6m.js} +2 -2
- package/dist/{cli-vgh5adn9.js → cli-7g3fg4gf.js} +7 -7
- package/dist/{cli-hxj888w3.js → cli-7gbff32z.js} +2 -2
- package/dist/{cli-q8aq48v1.js → cli-8b4rpnwj.js} +1 -1
- package/dist/{cli-xc8m5cjn.js → cli-8cas2xvp.js} +3 -3
- package/dist/{cli-1606qw3n.js → cli-904wk98s.js} +797 -369
- package/dist/{cli-h3drhntp.js → cli-93n305hm.js} +2 -2
- package/dist/{cli-1wew39p0.js → cli-944w9wb4.js} +20 -16
- package/dist/{cli-je587f74.js → cli-94gx6ze9.js} +1 -1
- package/dist/{cli-hpxcfvdm.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-ef590376.js → cli-bv4vvnmg.js} +3 -3
- package/dist/{cli-ppf9ap9n.js → cli-bzcwwebm.js} +1 -1
- package/dist/{cli-sy2ge2ye.js → cli-cq4am6vg.js} +2 -2
- package/dist/{cli-gxqwm3k3.js → cli-d5pc8ep0.js} +102 -8
- package/dist/{cli-hd2a204w.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-ka4tqjzd.js → cli-gse7bp3z.js} +12 -10
- package/dist/{cli-v8rpjrnx.js → cli-gtj12v95.js} +1 -1
- package/dist/{cli-g4dhd3pr.js → cli-hdhpdrka.js} +6 -23
- package/dist/{cli-dq30fq3q.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-8sayvj48.js → cli-jyhbvdga.js} +3 -3
- package/dist/{cli-55fqpd9q.js → cli-jzerrzgc.js} +8 -8
- package/dist/{cli-hv3820ez.js → cli-k0nebh10.js} +1 -1
- package/dist/{cli-aytna2fm.js → cli-ka48vpev.js} +5 -5
- package/dist/{cli-d2epqm0y.js → cli-kezzteka.js} +1 -1
- package/dist/{cli-grk77aen.js → cli-kj84fqxz.js} +2 -2
- package/dist/{cli-h0ewec3d.js → cli-kr0jpw9c.js} +1 -1
- package/dist/{cli-wsnradtk.js → cli-m1sns1da.js} +2 -2
- package/dist/{cli-7kv5d674.js → cli-n1kjs58m.js} +4 -4
- package/dist/{cli-syqcny89.js → cli-nc4pbwmp.js} +9 -9
- package/dist/{cli-9gmkw6xn.js → cli-p3knvk62.js} +48 -42
- package/dist/{cli-50whymxq.js → cli-p436yrzp.js} +2 -2
- package/dist/{cli-0j4qmc80.js → cli-phdzn699.js} +7 -7
- package/dist/{cli-1gnf5c7x.js → cli-pz1dp12c.js} +1 -1
- package/dist/{cli-nbawx3s0.js → cli-pz1nq5xm.js} +6 -6
- package/dist/{cli-4dyhzhpx.js → cli-qzz6tz8s.js} +1 -1
- package/dist/{cli-ea367bdn.js → cli-rmgvwcmy.js} +22 -22
- package/dist/{cli-mgr3gatr.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-pzsedyb0.js → cli-t0jmkcah.js} +14 -14
- package/dist/{cli-eetzmsy5.js → cli-t9pzz2eq.js} +2 -2
- package/dist/{cli-w24741sm.js → cli-tr19nyn9.js} +4 -4
- package/dist/{cli-e4gx499y.js → cli-ts5yv7dn.js} +163 -86
- package/dist/{cli-czeh7x13.js → cli-tsc3pdfd.js} +4 -4
- package/dist/{cli-y0q92v4r.js → cli-tzw1jr2t.js} +2 -2
- package/dist/{cli-tjf1bh1v.js → cli-x2cem5vy.js} +6 -4
- package/dist/{cli-vx9acp12.js → cli-ybte1fqc.js} +1 -1
- package/dist/{cli-gkjw33x5.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-8m6gqnf1.js → cli-zexwhj3f.js} +3 -3
- package/dist/{cli-snwz16eg.js → cli-zhwjdhjr.js} +2 -2
- package/dist/{cli-y754psdt.js → cli-zjdhrzm0.js} +4 -4
- package/dist/cli.js +19 -19
- package/dist/{codex-adapter-493vb8cv.js → codex-adapter-2fs2c0n6.js} +8 -8
- package/dist/{codex-hook-ej8hn6z5.js → codex-hook-jxjv6dy5.js} +1 -1
- package/dist/{codex-login-ven5cz5j.js → codex-login-ktfg1cxk.js} +1 -1
- package/dist/{codex-session-runner-ps5m4z1g.js → codex-session-runner-r55tmx4c.js} +9 -9
- package/dist/{commands-shktk0b8.js → commands-0mxdy9x8.js} +3 -3
- package/dist/{controller-wn3vd217.js → controller-g3vkfhr4.js} +4 -4
- package/dist/{controllers-connect-yft057ws.js → controllers-connect-4wdmncqt.js} +25 -25
- package/dist/core-gsvj5f3z.js +42 -0
- package/dist/{cursor-adapter-8fpm4dng.js → cursor-adapter-t9qb96q2.js} +2 -2
- package/dist/{db-0ezhdhz5.js → db-487vvyv9.js} +3 -3
- package/dist/{db-84pz2w5c.js → db-76p7w3gr.js} +2 -2
- package/dist/{devin-adapter-fs90ab4v.js → devin-adapter-3bp6rape.js} +1 -1
- package/dist/{dispatcher-h2rz69f6.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-m41ad78v.js → easter-egg-3d-jrrwyf55.js} +1 -1
- package/dist/{embedding-space-yam9zwzj.js → embedding-space-001hhhpk.js} +6 -6
- package/dist/{embeddings-g2be0y8q.js → embeddings-esj19cnw.js} +1 -1
- package/dist/{event-bus-08t2b4y2.js → event-bus-7gbsr0g4.js} +1 -1
- package/dist/{execute-hhdejgzf.js → execute-301hkxqg.js} +1 -1
- package/dist/{external-channel-kjt2yzfj.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-2e5jdexj.js → heartbeat-tbrj7vhq.js} +25 -25
- package/dist/{hook-acg9saz7.js → hook-3am1sq68.js} +6 -6
- package/dist/{hook-34s8cmgn.js → hook-tx917rqw.js} +8 -8
- package/dist/{http-ra2zr2f8.js → http-3rmemtqy.js} +335 -1829
- package/dist/{index-mbpxhc4w.js → index-126v2d0t.js} +1 -4
- package/dist/{index-2z1z7qx6.js → index-2jw11t8s.js} +26 -26
- package/dist/{index-9q42cr54.js → index-aetfyx6p.js} +1 -1
- package/dist/index-e6bq0exk.js +42 -0
- package/dist/{index-9r4j0a60.js → index-gfnq66t1.js} +223 -25
- package/dist/index-hf2k1vge.js +39 -0
- package/dist/{index-93bw5wds.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-vjnnqbkm.js → keepalive-9px3t7qj.js} +5 -5
- package/dist/lead-5vt6f174.js +83 -0
- package/dist/{maintenance-px2g599e.js → maintenance-vwqjwst6.js} +1 -1
- package/dist/{oauth-refresh-sweep-nkykf09m.js → oauth-refresh-sweep-yqry3wn4.js} +4 -4
- package/dist/{object-webhooks-gt9xnq21.js → object-webhooks-8s1wtths.js} +7 -7
- package/dist/{onboard-1f134p65.js → onboard-hb8czx0p.js} +7 -7
- package/dist/{opencode-adapter-94976yab.js → opencode-adapter-djd6m6dk.js} +8 -8
- package/dist/{otel-impl-5d4p2fqs.js → otel-impl-2ymwyczz.js} +2 -2
- package/dist/{pending-vkk0vx6n.js → pending-nxavtvx7.js} +23 -23
- package/dist/{pi-mono-adapter-cyzdv5er.js → pi-mono-adapter-d2cpmcy4.js} +12 -12
- package/dist/{pricing-refresh-jtmjwss9.js → pricing-refresh-1yz8jkqv.js} +2 -2
- package/dist/{rbac-roles-1fvmdyeb.js → rbac-roles-7s6m31xw.js} +6 -4
- package/dist/{rbac-roles-yd1fgpsn.js → rbac-roles-dbpx0x9v.js} +3 -3
- package/dist/{render-v2-kb5s3vx4.js → render-v2-7y20rjrn.js} +7 -7
- package/dist/{resume-z1vs44n5.js → resume-wz546x47.js} +10 -10
- package/dist/{runtime-gk6ct7r7.js → runtime-cb5bd9tz.js} +1 -1
- package/dist/{session-access-nz6nre4d.js → session-access-4vcft8kq.js} +5 -5
- package/dist/{session-source-backfill-wb60zjkd.js → session-source-backfill-57b50tpw.js} +3 -3
- package/dist/{setup-2x8g8j4s.js → setup-e1tevjyj.js} +1 -1
- package/dist/thread-buffer-686pa1p1.js +42 -0
- package/dist/{tree-visibility-ts3z30kw.js → tree-visibility-07wf1nct.js} +2 -2
- package/dist/{user-merge-jobs-zetg26e0.js → user-merge-jobs-n20qpv6s.js} +3 -3
- package/dist/{virtual-modules-674fka8x.js → virtual-modules-6fxmn1yv.js} +3 -3
- package/dist/{work-objects-w52yyjxm.js → work-objects-eg7y48pe.js} +25 -25
- package/dist/worker-4vp616ms.js +83 -0
- package/dist/{worker-follow-up-dyfxyjbj.js → worker-follow-up-jnvnnf2b.js} +22 -22
- package/dist/{x-asbrnafg.js → x-d27jj7z7.js} +2 -2
- package/openapi.json +475 -28
- package/package.json +2 -2
- 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/heartbeat/heartbeat.ts +18 -4
- 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/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/providers/amp-adapter.ts +1 -1
- package/src/providers/dsh-adapter.ts +48 -13
- 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/tests/chat-sdk-mentions.test.ts +183 -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/secret-corpus.ts +43 -1
- package/src/tests/heartbeat-stall-thresholds.test.ts +174 -0
- package/src/tests/jira-adf.test.ts +42 -2
- 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/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/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 +65 -0
- 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 +5 -0
- package/templates/skills/workflow-iterate/content.md +1 -1
- package/dist/acp-adapter-t2q6nsqv.js +0 -17
- package/dist/cli-kh973792.js +0 -98
- package/dist/core-nheayfgm.js +0 -42
- package/dist/fx-adapter-8g7xsp8q.js +0 -20
- package/dist/grok-adapter-ztk2zkz1.js +0 -20
- package/dist/handlers-9ywssz71.js +0 -41
- package/dist/index-6mgbdtv1.js +0 -44
- package/dist/index-hqdsn2t2.js +0 -39
- package/dist/index-st231bqv.js +0 -40
- package/dist/lead-mk0xkth2.js +0 -82
- package/dist/thread-buffer-d50rqpev.js +0 -42
- package/dist/worker-662x1vse.js +0 -82
|
@@ -48,14 +48,9 @@ import {
|
|
|
48
48
|
catalog_default,
|
|
49
49
|
COMPANY_TEAM_SIZES,
|
|
50
50
|
COMPANY_USE_CASES,
|
|
51
|
-
USER_FUNCTIONS,
|
|
52
51
|
reportedUseCase,
|
|
53
|
-
reportedUserFunction,
|
|
54
52
|
init_company_profile,
|
|
55
|
-
TELEMETRY_PROXY_ORIGIN,
|
|
56
53
|
normalizeOrgWebsite,
|
|
57
|
-
orgLogoUrl,
|
|
58
|
-
isFilledOrgLogoUrl,
|
|
59
54
|
init_org_website,
|
|
60
55
|
setRequestAuth,
|
|
61
56
|
getRequestAuth,
|
|
@@ -85,15 +80,6 @@ import {
|
|
|
85
80
|
CHAT_SDK_ADAPTER_NAMES,
|
|
86
81
|
isAdapterEntryEnabled,
|
|
87
82
|
init_schema,
|
|
88
|
-
TELEMETRY_RANKING_KEY,
|
|
89
|
-
PUBLIC_RANKING_ENABLED_KEY,
|
|
90
|
-
RANKING_CATEGORIES,
|
|
91
|
-
readTelemetryRanking,
|
|
92
|
-
rankingFormSchema,
|
|
93
|
-
buildListing,
|
|
94
|
-
init_telemetry_ranking,
|
|
95
|
-
isSlackIconConfigKey,
|
|
96
|
-
init_reaction_shortcode,
|
|
97
83
|
API_DRAINING_HEADER,
|
|
98
84
|
init_api_drain2,
|
|
99
85
|
parseTaskToolManifest,
|
|
@@ -101,12 +87,6 @@ import {
|
|
|
101
87
|
isChatSdkTask,
|
|
102
88
|
selectTaskTools,
|
|
103
89
|
init_task_tool_manifest,
|
|
104
|
-
isApiOnlyConfigKey,
|
|
105
|
-
isInternalConfigKey,
|
|
106
|
-
internalConfigKeyError,
|
|
107
|
-
isHumanOnlyConfigKey,
|
|
108
|
-
humanOnlyConfigKeyError,
|
|
109
|
-
humanOnlyConfigKeyPageError,
|
|
110
90
|
MAX_DB_RETENTION_DAYS,
|
|
111
91
|
DB_RETENTION_TUNING_BOUNDS,
|
|
112
92
|
CODEX_OAUTH_KEEP_WARM_MAX_AGE_HOURS_BOUNDS,
|
|
@@ -247,7 +227,6 @@ import {
|
|
|
247
227
|
explicitModelError,
|
|
248
228
|
explicitModelErrorForAgent,
|
|
249
229
|
init_model_validation2,
|
|
250
|
-
runtimeReadsRepoSecrets,
|
|
251
230
|
checkProfileForAgent,
|
|
252
231
|
formatProfileCheckFailures,
|
|
253
232
|
init_model_profile_check,
|
|
@@ -288,9 +267,6 @@ import {
|
|
|
288
267
|
markSteeringUndeliverable,
|
|
289
268
|
requestSteering,
|
|
290
269
|
init_steering2,
|
|
291
|
-
listApprovalRequestSummaries2,
|
|
292
|
-
getPendingApprovalVoteState2,
|
|
293
|
-
recordApprovalVotes2,
|
|
294
270
|
getPendingApprovalsForTasks2,
|
|
295
271
|
computeContentHash2,
|
|
296
272
|
AssetKeyMovesBlockedError2,
|
|
@@ -395,13 +371,9 @@ import {
|
|
|
395
371
|
createScheduledTask2,
|
|
396
372
|
updateScheduledTask2,
|
|
397
373
|
deleteScheduledTask2,
|
|
398
|
-
maskSecrets2,
|
|
399
374
|
getSwarmConfigs2,
|
|
400
|
-
getSwarmConfigById2,
|
|
401
|
-
getSwarmConfigLookupById2,
|
|
402
375
|
upsertSwarmConfig2,
|
|
403
376
|
emitBuiltInIntegrationConnectedOnce2,
|
|
404
|
-
deleteSwarmConfig2,
|
|
405
377
|
deleteSwarmConfigByKey2,
|
|
406
378
|
getResolvedConfig2,
|
|
407
379
|
getSwarmRepos2,
|
|
@@ -422,7 +394,6 @@ import {
|
|
|
422
394
|
deleteWorkflow2,
|
|
423
395
|
getWorkflowRun2,
|
|
424
396
|
listWorkflowRunsPage2,
|
|
425
|
-
getWorkflowRunStep2,
|
|
426
397
|
getWorkflowRunStepsByRunId2,
|
|
427
398
|
getWorkflowVersions2,
|
|
428
399
|
getWorkflowVersion2,
|
|
@@ -459,10 +430,6 @@ import {
|
|
|
459
430
|
checkoutPromptTemplate2,
|
|
460
431
|
getAllChannelActivityCursors2,
|
|
461
432
|
upsertChannelActivityCursor2,
|
|
462
|
-
createApprovalRequest2,
|
|
463
|
-
getApprovalRequestById2,
|
|
464
|
-
resolveApprovalRequest2,
|
|
465
|
-
listApprovalRequests2,
|
|
466
433
|
createSkill2,
|
|
467
434
|
updateSkill2,
|
|
468
435
|
listSkillFileManifest2,
|
|
@@ -556,7 +523,7 @@ import {
|
|
|
556
523
|
countScriptRunJournalSteps2,
|
|
557
524
|
countScriptRunJournalAgentTaskSteps2,
|
|
558
525
|
init_db4
|
|
559
|
-
} from "./cli-
|
|
526
|
+
} from "./cli-ts5yv7dn.js";
|
|
560
527
|
import {
|
|
561
528
|
PRIMARY_ROLE_NAMES2,
|
|
562
529
|
OperatorGrantedTargetError2,
|
|
@@ -570,7 +537,7 @@ import {
|
|
|
570
537
|
assertNotLastAdmin2,
|
|
571
538
|
setUserRoles2,
|
|
572
539
|
init_rbac_roles
|
|
573
|
-
} from "./cli-
|
|
540
|
+
} from "./cli-x2cem5vy.js";
|
|
574
541
|
import {
|
|
575
542
|
MAX_MODEL_GROUP_MEMBERS,
|
|
576
543
|
listModelGroups,
|
|
@@ -580,17 +547,17 @@ import {
|
|
|
580
547
|
modelGroupReferences,
|
|
581
548
|
deleteModelGroup,
|
|
582
549
|
init_model_groups
|
|
583
|
-
} from "./cli-
|
|
550
|
+
} from "./cli-4fpa0zns.js";
|
|
584
551
|
import {
|
|
585
552
|
requestModelCatalogRefresh2,
|
|
586
553
|
init_pricing_refresh
|
|
587
|
-
} from "./cli-
|
|
554
|
+
} from "./cli-93n305hm.js";
|
|
588
555
|
import {
|
|
589
556
|
workflowEventBus2,
|
|
590
557
|
init_event_bus
|
|
591
|
-
} from "./cli-
|
|
592
|
-
import"./cli-
|
|
593
|
-
import"./cli-
|
|
558
|
+
} from "./cli-ybte1fqc.js";
|
|
559
|
+
import"./cli-7gbff32z.js";
|
|
560
|
+
import"./cli-qzz6tz8s.js";
|
|
594
561
|
import"./cli-vr4eyq6p.js";
|
|
595
562
|
import"./cli-r8ddn0hf.js";
|
|
596
563
|
import {
|
|
@@ -630,11 +597,9 @@ import {
|
|
|
630
597
|
startSlackApp2,
|
|
631
598
|
stopSlackApp2,
|
|
632
599
|
init_app4
|
|
633
|
-
} from "./cli-
|
|
600
|
+
} from "./cli-rmgvwcmy.js";
|
|
634
601
|
import {
|
|
635
|
-
AGENT_MAX_TASKS_CONFIG_KEY,
|
|
636
602
|
reconcileAgentMaxTasksPolicy,
|
|
637
|
-
resetAgentMaxTasksMirror,
|
|
638
603
|
upsertSwarmConfigWithPolicyMirror,
|
|
639
604
|
runtimeStaleThresholdMinutes,
|
|
640
605
|
upsertRuntimeInstance,
|
|
@@ -645,26 +610,13 @@ import {
|
|
|
645
610
|
setRuntimeCredentialReady,
|
|
646
611
|
reconcileAgentStatusFromRuntimes,
|
|
647
612
|
listRuntimeInstancesForPool,
|
|
648
|
-
init_multi_runtime
|
|
649
|
-
|
|
650
|
-
ConfigStateSchema,
|
|
651
|
-
readConfigState,
|
|
652
|
-
normalizeApprovalQuestions,
|
|
653
|
-
isConfigQuestion,
|
|
654
|
-
parseConfigAnswer,
|
|
655
|
-
skippedConfigResult,
|
|
656
|
-
keptConfigResult,
|
|
657
|
-
applyConfigAnswer,
|
|
658
|
-
init_approval_config_question,
|
|
659
|
-
dispatchApprovalNotifications2,
|
|
660
|
-
createApprovalFollowUpTask2,
|
|
661
|
-
init_approval_notifications
|
|
662
|
-
} from "./cli-gxqwm3k3.js";
|
|
613
|
+
init_multi_runtime
|
|
614
|
+
} from "./cli-d5pc8ep0.js";
|
|
663
615
|
import {
|
|
664
616
|
retryFailedRun2,
|
|
665
617
|
cancelWorkflowRun2,
|
|
666
618
|
init_resume
|
|
667
|
-
} from "./cli-
|
|
619
|
+
} from "./cli-9ah37a8a.js";
|
|
668
620
|
import {
|
|
669
621
|
safeParse,
|
|
670
622
|
getObjectShape,
|
|
@@ -879,7 +831,7 @@ import {
|
|
|
879
831
|
init_gitlab,
|
|
880
832
|
isChatSdkEnabled,
|
|
881
833
|
getChatSdkConfig,
|
|
882
|
-
|
|
834
|
+
init_config2,
|
|
883
835
|
errorMessage,
|
|
884
836
|
init_logger,
|
|
885
837
|
resolveAdapterApiUrl,
|
|
@@ -938,10 +890,15 @@ import {
|
|
|
938
890
|
init_auth,
|
|
939
891
|
getDeploymentEnvValue2,
|
|
940
892
|
loadGlobalConfigsIntoEnv2,
|
|
941
|
-
reloadGlobalConfigsAndIntegrations2,
|
|
942
893
|
scheduleIntegrationsReload2,
|
|
943
894
|
handleCore2,
|
|
944
895
|
init_core,
|
|
896
|
+
resolveRequestPrincipal,
|
|
897
|
+
requestPrincipal,
|
|
898
|
+
agentFirstPrincipal,
|
|
899
|
+
requireAuthKind,
|
|
900
|
+
rejectGuest,
|
|
901
|
+
init_request_principal,
|
|
945
902
|
nextFallback2,
|
|
946
903
|
createWorkerTaskFollowUp2,
|
|
947
904
|
createResumeFollowUp2,
|
|
@@ -951,12 +908,6 @@ import {
|
|
|
951
908
|
init_mcp_limits,
|
|
952
909
|
userCtx,
|
|
953
910
|
init_task_tool_ctx,
|
|
954
|
-
resolveRequestPrincipal,
|
|
955
|
-
requestPrincipal,
|
|
956
|
-
agentFirstPrincipal,
|
|
957
|
-
requireAuthKind,
|
|
958
|
-
rejectGuest,
|
|
959
|
-
init_request_principal,
|
|
960
911
|
resolveTaskRequester,
|
|
961
912
|
init_task_requester,
|
|
962
913
|
handleApps,
|
|
@@ -965,8 +916,6 @@ import {
|
|
|
965
916
|
init_elements,
|
|
966
917
|
MAX_OBJECT_BYTES,
|
|
967
918
|
init_write_object,
|
|
968
|
-
cancelApprovalRequest,
|
|
969
|
-
init_approval_cancel,
|
|
970
919
|
getUserCommsPrefs,
|
|
971
920
|
init_requester_comms,
|
|
972
921
|
getTaskDetailsInputSchema,
|
|
@@ -993,12 +942,19 @@ import {
|
|
|
993
942
|
init_asset_key_auth,
|
|
994
943
|
getPageEditCounter,
|
|
995
944
|
init_page_versions,
|
|
996
|
-
snapshotPage,
|
|
997
|
-
init_version3,
|
|
998
945
|
DEFAULT_THEME_ID,
|
|
999
946
|
THEME_PRESET_IDS,
|
|
1000
947
|
getThemePreset,
|
|
1001
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,
|
|
1002
958
|
readThemeFields,
|
|
1003
959
|
init_page_fields,
|
|
1004
960
|
assertOAuthAppUrlsSafe,
|
|
@@ -1063,13 +1019,13 @@ import {
|
|
|
1063
1019
|
getKapsoConfig,
|
|
1064
1020
|
getKapsoNumberMapping,
|
|
1065
1021
|
markKapsoMessageSeen,
|
|
1066
|
-
|
|
1022
|
+
init_config3,
|
|
1067
1023
|
changesMergePolicy,
|
|
1068
1024
|
init_repo_merge_policy,
|
|
1069
1025
|
updateSwarmRepoChecked,
|
|
1070
1026
|
init_repo_checked_update,
|
|
1071
1027
|
getCombConfig,
|
|
1072
|
-
|
|
1028
|
+
init_config4,
|
|
1073
1029
|
resolveRoomNamespace,
|
|
1074
1030
|
roomRequestInfo,
|
|
1075
1031
|
authorizeRoomNamespace,
|
|
@@ -1167,7 +1123,7 @@ import {
|
|
|
1167
1123
|
getEnabledCapabilities,
|
|
1168
1124
|
createServer,
|
|
1169
1125
|
init_server
|
|
1170
|
-
} from "./cli-
|
|
1126
|
+
} from "./cli-904wk98s.js";
|
|
1171
1127
|
import {
|
|
1172
1128
|
getFileStorageProvider2,
|
|
1173
1129
|
init_registry2
|
|
@@ -1193,9 +1149,8 @@ import {
|
|
|
1193
1149
|
resolvePoolDelivery2,
|
|
1194
1150
|
createPoolAgent2,
|
|
1195
1151
|
init_db2
|
|
1196
|
-
} from "./cli-
|
|
1152
|
+
} from "./cli-29h5239w.js";
|
|
1197
1153
|
import {
|
|
1198
|
-
duplicateGuardedQueryKey,
|
|
1199
1154
|
warnIfCorsAllowsAnyOrigin,
|
|
1200
1155
|
isOriginAllowedForCredentials,
|
|
1201
1156
|
allowedCredentialRedirect,
|
|
@@ -1218,7 +1173,6 @@ import {
|
|
|
1218
1173
|
deriveApiBaseUrl,
|
|
1219
1174
|
httpServerSemconvAttributes,
|
|
1220
1175
|
init_utils2,
|
|
1221
|
-
resolveTaskAuditUserId,
|
|
1222
1176
|
resolveHttpRequesterUserId,
|
|
1223
1177
|
resolveHttpAuditUserId,
|
|
1224
1178
|
resolveHttpAuditActor,
|
|
@@ -1244,7 +1198,7 @@ import {
|
|
|
1244
1198
|
describeRequestRoute,
|
|
1245
1199
|
route,
|
|
1246
1200
|
init_route_def
|
|
1247
|
-
} from "./cli-
|
|
1201
|
+
} from "./cli-404am6f3.js";
|
|
1248
1202
|
import {
|
|
1249
1203
|
startPoolRouting,
|
|
1250
1204
|
stopPoolRouting,
|
|
@@ -1257,39 +1211,29 @@ import {
|
|
|
1257
1211
|
checkHeartbeatChecklist2,
|
|
1258
1212
|
runHeartbeatSweep2,
|
|
1259
1213
|
stopHeartbeat2
|
|
1260
|
-
} from "./cli-
|
|
1261
|
-
import"./cli-
|
|
1214
|
+
} from "./cli-944w9wb4.js";
|
|
1215
|
+
import"./cli-p436yrzp.js";
|
|
1262
1216
|
import {
|
|
1263
1217
|
runtimeSupervisorStatus,
|
|
1264
1218
|
startRuntimeSupervisor,
|
|
1265
1219
|
stopRuntimeSupervisor
|
|
1266
|
-
} from "./cli-
|
|
1220
|
+
} from "./cli-ea7nz50q.js";
|
|
1267
1221
|
import {
|
|
1268
1222
|
TASK_TITLE_TIMEOUT_MS,
|
|
1269
1223
|
generateTaskTitle
|
|
1270
|
-
} from "./cli-
|
|
1224
|
+
} from "./cli-bv4vvnmg.js";
|
|
1271
1225
|
import"./cli-ns59dc6r.js";
|
|
1272
1226
|
import {
|
|
1273
1227
|
ACP_TARGET_IDS
|
|
1274
|
-
} from "./cli-
|
|
1228
|
+
} from "./cli-k0nebh10.js";
|
|
1275
1229
|
import {
|
|
1276
1230
|
reasoningCapability,
|
|
1277
1231
|
supportedReasoningLevels
|
|
1278
|
-
} from "./cli-
|
|
1232
|
+
} from "./cli-ywy8yz6t.js";
|
|
1279
1233
|
import {
|
|
1280
1234
|
MAX_RATE_LIMIT_RESET_MS,
|
|
1281
1235
|
MAX_SPEND_CAP_HOLD_MS
|
|
1282
|
-
} from "./cli-
|
|
1283
|
-
import {
|
|
1284
|
-
isLeadChannelMonitoringEnabled,
|
|
1285
|
-
ORG_IDENTITY_KEYS,
|
|
1286
|
-
orgIdentityStatus,
|
|
1287
|
-
SIMILARITY_THRESHOLD,
|
|
1288
|
-
memoryRelevance,
|
|
1289
|
-
isUnknownModelError,
|
|
1290
|
-
checkProviderPoolKey,
|
|
1291
|
-
writeSkillsToFilesystem
|
|
1292
|
-
} from "./cli-g4dhd3pr.js";
|
|
1236
|
+
} from "./cli-fkpnx3vf.js";
|
|
1293
1237
|
import {
|
|
1294
1238
|
AgentFsRequestError2,
|
|
1295
1239
|
resolveAgentFsSharedContext2,
|
|
@@ -1300,16 +1244,24 @@ import {
|
|
|
1300
1244
|
agentFsRequest2,
|
|
1301
1245
|
resolveApiUrl2,
|
|
1302
1246
|
init_agent_fs_provision
|
|
1303
|
-
} from "./cli-
|
|
1247
|
+
} from "./cli-60dwk8tx.js";
|
|
1304
1248
|
import {
|
|
1305
1249
|
Anthropic
|
|
1306
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";
|
|
1307
1259
|
import {
|
|
1308
1260
|
objectWebhookSecret2,
|
|
1309
1261
|
handleObjectWebhookEvent2,
|
|
1310
1262
|
init_object_webhooks
|
|
1311
|
-
} from "./cli-
|
|
1312
|
-
import"./cli-
|
|
1263
|
+
} from "./cli-49aq3cyn.js";
|
|
1264
|
+
import"./cli-tsc3pdfd.js";
|
|
1313
1265
|
import {
|
|
1314
1266
|
createUserMergeJob2,
|
|
1315
1267
|
getUserMergeJob2,
|
|
@@ -1318,7 +1270,7 @@ import {
|
|
|
1318
1270
|
findFailedUserMergeJob2,
|
|
1319
1271
|
requeueUserMergeJob2,
|
|
1320
1272
|
runUserMergeJobs2
|
|
1321
|
-
} from "./cli-
|
|
1273
|
+
} from "./cli-5ashycw3.js";
|
|
1322
1274
|
import {
|
|
1323
1275
|
isCodexOAuthConfigKey
|
|
1324
1276
|
} from "./cli-j4bwnpkm.js";
|
|
@@ -1328,8 +1280,28 @@ import {
|
|
|
1328
1280
|
} from "./cli-9fzgd3hg.js";
|
|
1329
1281
|
import {
|
|
1330
1282
|
runTaskUiAction,
|
|
1331
|
-
init_actions
|
|
1332
|
-
|
|
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";
|
|
1333
1305
|
import {
|
|
1334
1306
|
RATING_MODEL_MAX_LENGTH,
|
|
1335
1307
|
REFERENCES_SOURCE_MAX_LENGTH,
|
|
@@ -1425,7 +1397,7 @@ import {
|
|
|
1425
1397
|
init_typecheck,
|
|
1426
1398
|
parseSkillContent,
|
|
1427
1399
|
init_skill_parser
|
|
1428
|
-
} from "./cli-
|
|
1400
|
+
} from "./cli-gse7bp3z.js";
|
|
1429
1401
|
import {
|
|
1430
1402
|
signalProcessGroup,
|
|
1431
1403
|
detachedProcessGroup,
|
|
@@ -1442,17 +1414,17 @@ import {
|
|
|
1442
1414
|
forceRefreshAuthorizationOrThrow,
|
|
1443
1415
|
forceRefreshTokenOrThrow,
|
|
1444
1416
|
init_ensure_token
|
|
1445
|
-
} from "./cli-
|
|
1417
|
+
} from "./cli-jyhbvdga.js";
|
|
1446
1418
|
import {
|
|
1447
1419
|
PRIMITIVE_KINDS,
|
|
1448
1420
|
ObjectsError,
|
|
1449
1421
|
recordObjectVersion,
|
|
1450
1422
|
init_objects
|
|
1451
|
-
} from "./cli-
|
|
1423
|
+
} from "./cli-tr19nyn9.js";
|
|
1452
1424
|
import {
|
|
1453
1425
|
agentFsClientFor,
|
|
1454
1426
|
init_agent_fs_identity
|
|
1455
|
-
} from "./cli-
|
|
1427
|
+
} from "./cli-zhwjdhjr.js";
|
|
1456
1428
|
import {
|
|
1457
1429
|
FilesError,
|
|
1458
1430
|
normalizeFilesError,
|
|
@@ -1461,7 +1433,7 @@ import {
|
|
|
1461
1433
|
AgentFsProvider,
|
|
1462
1434
|
init_agent_fs_provider
|
|
1463
1435
|
} from "./cli-skd2c4ej.js";
|
|
1464
|
-
import"./cli-
|
|
1436
|
+
import"./cli-gtj12v95.js";
|
|
1465
1437
|
import {
|
|
1466
1438
|
automationIntegrationFixUrl,
|
|
1467
1439
|
preflightAutomation,
|
|
@@ -1483,7 +1455,7 @@ import {
|
|
|
1483
1455
|
definitionNodeIds,
|
|
1484
1456
|
validateDefinition,
|
|
1485
1457
|
init_definition2
|
|
1486
|
-
} from "./cli-
|
|
1458
|
+
} from "./cli-0p76my9q.js";
|
|
1487
1459
|
import {
|
|
1488
1460
|
_fetchHolder,
|
|
1489
1461
|
CLIENT_ID,
|
|
@@ -1499,7 +1471,7 @@ import {
|
|
|
1499
1471
|
loadAllCodexOAuthSlots,
|
|
1500
1472
|
getValidCodexOAuth,
|
|
1501
1473
|
init_storage
|
|
1502
|
-
} from "./cli-
|
|
1474
|
+
} from "./cli-2vp0z049.js";
|
|
1503
1475
|
import {
|
|
1504
1476
|
isMultiRuntimeEnabled,
|
|
1505
1477
|
init_multi_runtime2
|
|
@@ -1511,7 +1483,7 @@ import {
|
|
|
1511
1483
|
import {
|
|
1512
1484
|
createRuntimeProvider,
|
|
1513
1485
|
init_runtime_providers
|
|
1514
|
-
} from "./cli-
|
|
1486
|
+
} from "./cli-jbrc98qb.js";
|
|
1515
1487
|
import {
|
|
1516
1488
|
require_content_type
|
|
1517
1489
|
} from "./cli-1jx0srjt.js";
|
|
@@ -1525,7 +1497,7 @@ import {
|
|
|
1525
1497
|
toSessionSharesState,
|
|
1526
1498
|
setSessionShares,
|
|
1527
1499
|
init_session_shares
|
|
1528
|
-
} from "./cli-
|
|
1500
|
+
} from "./cli-pz1dp12c.js";
|
|
1529
1501
|
import {
|
|
1530
1502
|
isInvalidClientError,
|
|
1531
1503
|
publicEndpointSsrfOptions,
|
|
@@ -1543,7 +1515,7 @@ import {
|
|
|
1543
1515
|
revokeMcpToken,
|
|
1544
1516
|
computeExpiresAt,
|
|
1545
1517
|
init_mcp_wrapper
|
|
1546
|
-
} from "./cli-
|
|
1518
|
+
} from "./cli-ysv0k1we.js";
|
|
1547
1519
|
import"./cli-v41kn3cd.js";
|
|
1548
1520
|
import {
|
|
1549
1521
|
import_websocket,
|
|
@@ -1579,7 +1551,7 @@ import {
|
|
|
1579
1551
|
revokeAllAgentSessionTokens,
|
|
1580
1552
|
fingerprintApiKey,
|
|
1581
1553
|
init_users
|
|
1582
|
-
} from "./cli-
|
|
1554
|
+
} from "./cli-kj84fqxz.js";
|
|
1583
1555
|
import {
|
|
1584
1556
|
CORE_TOOLS,
|
|
1585
1557
|
init_tool_config
|
|
@@ -1592,7 +1564,7 @@ import {
|
|
|
1592
1564
|
providerAccountTelemetrySchema,
|
|
1593
1565
|
rateLimitReplacementSchema,
|
|
1594
1566
|
init_provider_account_telemetry
|
|
1595
|
-
} from "./cli-
|
|
1567
|
+
} from "./cli-fw67mnyc.js";
|
|
1596
1568
|
import {
|
|
1597
1569
|
CODEX_AUTH_FAILURE_BENCH_THRESHOLD,
|
|
1598
1570
|
CODEX_AUTH_WATCH_NAMESPACE,
|
|
@@ -1607,11 +1579,11 @@ import {
|
|
|
1607
1579
|
IDENTITY_FIELD_BUDGETS,
|
|
1608
1580
|
IdentityFieldBudgetError,
|
|
1609
1581
|
init_identity_field_budget
|
|
1610
|
-
} from "./cli-
|
|
1582
|
+
} from "./cli-ka48vpev.js";
|
|
1611
1583
|
import {
|
|
1612
1584
|
getSlackConfiguration,
|
|
1613
|
-
|
|
1614
|
-
} from "./cli-
|
|
1585
|
+
init_config5
|
|
1586
|
+
} from "./cli-t9pzz2eq.js";
|
|
1615
1587
|
import {
|
|
1616
1588
|
isSteeringEnabled2,
|
|
1617
1589
|
init_steering_enabled
|
|
@@ -1635,7 +1607,7 @@ import {
|
|
|
1635
1607
|
splitCredentialPool,
|
|
1636
1608
|
selectCredential,
|
|
1637
1609
|
init_credentials2
|
|
1638
|
-
} from "./cli-
|
|
1610
|
+
} from "./cli-gkv0r2hq.js";
|
|
1639
1611
|
import {
|
|
1640
1612
|
interpolate,
|
|
1641
1613
|
init_template2,
|
|
@@ -1736,7 +1708,6 @@ import {
|
|
|
1736
1708
|
AutomationIntegrationIdSchema,
|
|
1737
1709
|
ScheduledTaskTargetTypeSchema,
|
|
1738
1710
|
ScheduledTaskSchema,
|
|
1739
|
-
SwarmConfigSchema,
|
|
1740
1711
|
RepoGuidelinesInputSchema,
|
|
1741
1712
|
RepoHooksSchema,
|
|
1742
1713
|
SwarmRepoSchema,
|
|
@@ -1766,6 +1737,8 @@ import {
|
|
|
1766
1737
|
PageContentTypeSchema,
|
|
1767
1738
|
PageAuthModeSchema,
|
|
1768
1739
|
PageThemeTokensInputSchema,
|
|
1740
|
+
DesignSystemSchema,
|
|
1741
|
+
DesignSystemInputSchema,
|
|
1769
1742
|
PageSchema,
|
|
1770
1743
|
PageVersionSchema,
|
|
1771
1744
|
MetricWidgetSchema,
|
|
@@ -1823,14 +1796,13 @@ import {
|
|
|
1823
1796
|
KvKeySchema,
|
|
1824
1797
|
KvEntrySchema,
|
|
1825
1798
|
init_types5
|
|
1826
|
-
} from "./cli-
|
|
1799
|
+
} from "./cli-azj9t1f9.js";
|
|
1827
1800
|
import {
|
|
1828
1801
|
init_zod
|
|
1829
1802
|
} from "./cli-96234j5w.js";
|
|
1830
1803
|
import {
|
|
1831
1804
|
NEVER,
|
|
1832
1805
|
toJSONSchema,
|
|
1833
|
-
ZodError,
|
|
1834
1806
|
string2,
|
|
1835
1807
|
email,
|
|
1836
1808
|
uuid,
|
|
@@ -1877,7 +1849,7 @@ import {
|
|
|
1877
1849
|
import {
|
|
1878
1850
|
init_package,
|
|
1879
1851
|
package_default
|
|
1880
|
-
} from "./cli-
|
|
1852
|
+
} from "./cli-cq4am6vg.js";
|
|
1881
1853
|
import {
|
|
1882
1854
|
realtimeBus,
|
|
1883
1855
|
init_bus
|
|
@@ -1893,7 +1865,7 @@ import {
|
|
|
1893
1865
|
registerVolatileSecret,
|
|
1894
1866
|
registerEnvSecrets,
|
|
1895
1867
|
init_secret_scrubber
|
|
1896
|
-
} from "./cli-
|
|
1868
|
+
} from "./cli-1kvcsd2f.js";
|
|
1897
1869
|
import {
|
|
1898
1870
|
__toESM
|
|
1899
1871
|
} from "./cli-242037k3.js";
|
|
@@ -6396,6 +6368,7 @@ class LocalProcessScriptExecutor {
|
|
|
6396
6368
|
let proc;
|
|
6397
6369
|
let capabilitySocket;
|
|
6398
6370
|
let protocolFailure;
|
|
6371
|
+
let terminated = false;
|
|
6399
6372
|
const sockets = new Set;
|
|
6400
6373
|
const server = createServer2((socket) => {
|
|
6401
6374
|
sockets.add(socket);
|
|
@@ -6593,6 +6566,8 @@ class LocalProcessScriptExecutor {
|
|
|
6593
6566
|
clearInterval(heartbeat);
|
|
6594
6567
|
await terminateProcessGroup(spawned.pid);
|
|
6595
6568
|
let stderr = await stderrPromise;
|
|
6569
|
+
if (terminated)
|
|
6570
|
+
return { exitCode: processExitCode, stderr, terminated: true };
|
|
6596
6571
|
try {
|
|
6597
6572
|
if (protocolFailure)
|
|
6598
6573
|
throw protocolFailure;
|
|
@@ -6626,6 +6601,7 @@ class LocalProcessScriptExecutor {
|
|
|
6626
6601
|
startedAtMs: Date.now(),
|
|
6627
6602
|
exited,
|
|
6628
6603
|
terminate: async (signal = "SIGTERM") => {
|
|
6604
|
+
terminated = true;
|
|
6629
6605
|
built.abortInFlightSteps();
|
|
6630
6606
|
if (signal === "SIGTERM")
|
|
6631
6607
|
await terminateProcessGroup(spawned.pid);
|
|
@@ -6690,7 +6666,9 @@ async function startScriptRunProcess(run, baseUrl, apiKeyOverride) {
|
|
|
6690
6666
|
pid: execution.pid,
|
|
6691
6667
|
lastHeartbeatAt: new Date().toISOString()
|
|
6692
6668
|
});
|
|
6693
|
-
execution.exited.then(async ({ exitCode, stderr }) => {
|
|
6669
|
+
execution.exited.then(async ({ exitCode, stderr, terminated }) => {
|
|
6670
|
+
if (terminated)
|
|
6671
|
+
return;
|
|
6694
6672
|
const current = await getScriptRun2(run.id);
|
|
6695
6673
|
if (current && current.status === "running") {
|
|
6696
6674
|
if (exitCode !== 0) {
|
|
@@ -10172,1623 +10150,8 @@ async function handleApiKeys(req, res, pathSegments, queryParams) {
|
|
|
10172
10150
|
return false;
|
|
10173
10151
|
}
|
|
10174
10152
|
|
|
10175
|
-
// src/http/approval-requests.ts
|
|
10176
|
-
init_zod();
|
|
10177
|
-
init_approval_config_question();
|
|
10178
|
-
init_audit_user();
|
|
10179
|
-
init_db4();
|
|
10180
|
-
init_rbac_roles();
|
|
10181
|
-
init_users();
|
|
10182
|
-
init_rbac();
|
|
10183
|
-
init_request_auth_context();
|
|
10184
|
-
init_secret_scrubber();
|
|
10185
|
-
init_approval_cancel();
|
|
10186
|
-
init_approval_notifications();
|
|
10187
|
-
init_event_bus();
|
|
10188
|
-
|
|
10189
|
-
// src/http/config.ts
|
|
10190
|
-
init_zod();
|
|
10191
|
-
init_db4();
|
|
10192
|
-
init_model_profiles();
|
|
10193
|
-
init_model_profile_check();
|
|
10194
|
-
init_multi_runtime();
|
|
10195
|
-
|
|
10196
|
-
// src/be/org-profile.ts
|
|
10197
|
-
init_org_website();
|
|
10198
|
-
init_db4();
|
|
10199
|
-
var LOGO_KEY = "SWARM_ORG_LOGO_URL";
|
|
10200
|
-
var FILLED_LOGO_KEY = "SWARM_ORG_LOGO_FILLED_URL";
|
|
10201
|
-
async function globalValue(key) {
|
|
10202
|
-
const stored = (await getSwarmConfigs2({ scope: "global", key }))?.[0]?.value?.trim();
|
|
10203
|
-
return stored || process.env[key]?.trim() || "";
|
|
10204
|
-
}
|
|
10205
|
-
async function fillOrgLogoFromWebsite(website) {
|
|
10206
|
-
const host = normalizeOrgWebsite(website);
|
|
10207
|
-
if (!host)
|
|
10208
|
-
return false;
|
|
10209
|
-
const current = await globalValue(LOGO_KEY);
|
|
10210
|
-
if (current && !(isFilledOrgLogoUrl(current) && current === await globalValue(FILLED_LOGO_KEY))) {
|
|
10211
|
-
return false;
|
|
10212
|
-
}
|
|
10213
|
-
const next = orgLogoUrl(host);
|
|
10214
|
-
if (current === next)
|
|
10215
|
-
return false;
|
|
10216
|
-
await upsertSwarmConfig2({ scope: "global", key: LOGO_KEY, value: next, isSecret: false });
|
|
10217
|
-
await upsertSwarmConfig2({ scope: "global", key: FILLED_LOGO_KEY, value: next, isSecret: false });
|
|
10218
|
-
return true;
|
|
10219
|
-
}
|
|
10220
|
-
|
|
10221
|
-
// src/http/config.ts
|
|
10222
|
-
init_rbac_roles();
|
|
10223
|
-
init_swarm_config_guard();
|
|
10224
|
-
init_users();
|
|
10225
|
-
init_rbac();
|
|
10226
|
-
init_reaction_shortcode();
|
|
10227
|
-
init_types5();
|
|
10228
|
-
init_request_auth_context();
|
|
10229
|
-
init_secret_scrubber();
|
|
10230
|
-
init_core();
|
|
10231
|
-
|
|
10232
|
-
// src/http/ranking.ts
|
|
10233
|
-
init_zod();
|
|
10234
|
-
init_db4();
|
|
10235
|
-
init_telemetry_ranking();
|
|
10236
|
-
init_telemetry();
|
|
10237
|
-
init_env_flag();
|
|
10238
|
-
init_core();
|
|
10239
|
-
|
|
10240
|
-
// src/http/global-config.ts
|
|
10241
|
-
init_db4();
|
|
10242
|
-
async function globalConfig(key) {
|
|
10243
|
-
const stored = (await getSwarmConfigs2({ scope: "global", key }))?.[0]?.value;
|
|
10244
|
-
return (stored ?? process.env[key])?.trim() || undefined;
|
|
10245
|
-
}
|
|
10246
|
-
|
|
10247
|
-
// src/http/ranking.ts
|
|
10248
|
-
init_route_def();
|
|
10249
|
-
|
|
10250
|
-
// src/http/used-by.ts
|
|
10251
|
-
init_zod();
|
|
10252
|
-
init_db4();
|
|
10253
|
-
init_telemetry();
|
|
10254
|
-
init_company_profile();
|
|
10255
|
-
init_org_website();
|
|
10256
|
-
init_core();
|
|
10257
|
-
init_favorite_owner();
|
|
10258
|
-
init_route_def();
|
|
10259
|
-
init_utils2();
|
|
10260
|
-
var CONSENT_KEY = "SWARM_USED_BY_CONSENT";
|
|
10261
|
-
var CONSENT_AT_KEY = "SWARM_USED_BY_CONSENT_AT";
|
|
10262
|
-
var GRANTED_NAME_KEY = "SWARM_USED_BY_ORG_NAME";
|
|
10263
|
-
var GRANTED_WEBSITE_KEY = "SWARM_USED_BY_ORG_WEBSITE";
|
|
10264
|
-
var CONTACT_EMAIL_KEY = "SWARM_USED_BY_CONTACT_EMAIL";
|
|
10265
|
-
var CONTACT_FUNCTION_KEY = "SWARM_USED_BY_CONTACT_FUNCTION";
|
|
10266
|
-
var QUOTE_KEY = "SWARM_USED_BY_QUOTE";
|
|
10267
|
-
var TIMEOUT_MS = 1e4;
|
|
10268
|
-
var usedBy = route({
|
|
10269
|
-
method: "post",
|
|
10270
|
-
path: "/api/used-by",
|
|
10271
|
-
pattern: ["api", "used-by"],
|
|
10272
|
-
summary: "Grant or revoke the 'used by' logo consent",
|
|
10273
|
-
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.",
|
|
10274
|
-
tags: ["Telemetry"],
|
|
10275
|
-
body: object2({
|
|
10276
|
-
granted: boolean(),
|
|
10277
|
-
contactEmail: string2().max(320, "Contact email must be at most 320 characters").email("Contact email must be a valid email address").optional(),
|
|
10278
|
-
contactFunction: _enum2(USER_FUNCTIONS).optional(),
|
|
10279
|
-
quote: string2().max(280).optional()
|
|
10280
|
-
}).refine((body) => !body.granted || body.contactEmail !== undefined, {
|
|
10281
|
-
path: ["contactEmail"],
|
|
10282
|
-
message: "Contact email is required when granting logo consent"
|
|
10283
|
-
}),
|
|
10284
|
-
responses: {
|
|
10285
|
-
200: {
|
|
10286
|
-
description: "Consent recorded",
|
|
10287
|
-
schema: object2({ granted: boolean(), changedAt: string2() })
|
|
10288
|
-
},
|
|
10289
|
-
400: {
|
|
10290
|
-
description: "Invalid contact details, or missing organization name or website"
|
|
10291
|
-
},
|
|
10292
|
-
401: { description: "Unauthorized" },
|
|
10293
|
-
403: { description: "Only a config admin can change the consent" },
|
|
10294
|
-
502: { description: "The telemetry proxy did not accept the consent" }
|
|
10295
|
-
},
|
|
10296
|
-
rbac: { permission: "config.write.any" }
|
|
10297
|
-
});
|
|
10298
|
-
async function telemetryProxyEndpoint(path) {
|
|
10299
|
-
const feedback = await globalConfig("feedback_endpoint");
|
|
10300
|
-
if (feedback && /^https?:\/\/[^/]+\/v1\/feedback\/?$/.test(feedback)) {
|
|
10301
|
-
return feedback.replace(/\/v1\/feedback\/?$/, path);
|
|
10302
|
-
}
|
|
10303
|
-
return `${TELEMETRY_PROXY_ORIGIN}${path}`;
|
|
10304
|
-
}
|
|
10305
|
-
function usedByEndpoint() {
|
|
10306
|
-
return telemetryProxyEndpoint("/v1/used-by");
|
|
10307
|
-
}
|
|
10308
|
-
async function handleUsedBy(req, res, pathSegments, queryParams, myAgentId) {
|
|
10309
|
-
if (!usedBy.match(req.method, pathSegments))
|
|
10310
|
-
return false;
|
|
10311
|
-
const parsed = await usedBy.parse(req, res, pathSegments, queryParams);
|
|
10312
|
-
if (!parsed)
|
|
10313
|
-
return true;
|
|
10314
|
-
if (!await ensureConfigAdmin(req, res, "config.write.any"))
|
|
10315
|
-
return true;
|
|
10316
|
-
const { granted, contactEmail, contactFunction, quote } = parsed.body;
|
|
10317
|
-
const current = orgIdentityStatus({
|
|
10318
|
-
SWARM_ORG_NAME: await globalConfig("SWARM_ORG_NAME"),
|
|
10319
|
-
SWARM_ORG_WEBSITE: await globalConfig("SWARM_ORG_WEBSITE")
|
|
10320
|
-
});
|
|
10321
|
-
const currentName = current.name ?? undefined;
|
|
10322
|
-
const currentWebsite = current.website;
|
|
10323
|
-
const grantedName = granted ? undefined : await globalConfig(GRANTED_NAME_KEY);
|
|
10324
|
-
const grantedWebsite = granted ? null : normalizeOrgWebsite(await globalConfig(GRANTED_WEBSITE_KEY));
|
|
10325
|
-
const [orgName, orgWebsite] = grantedName && grantedWebsite ? [grantedName, grantedWebsite] : [currentName, currentWebsite];
|
|
10326
|
-
if (!orgName || !orgWebsite) {
|
|
10327
|
-
jsonError(res, "Set the organization name and website first", 400);
|
|
10328
|
-
return true;
|
|
10329
|
-
}
|
|
10330
|
-
const installId = isTelemetryEnabled() ? await globalConfig("telemetry_installation_id") : undefined;
|
|
10331
|
-
const orgDomain = await globalConfig("telemetry_org_domain");
|
|
10332
|
-
const changedAt = new Date().toISOString();
|
|
10333
|
-
try {
|
|
10334
|
-
const response = await fetch(await usedByEndpoint(), {
|
|
10335
|
-
method: "POST",
|
|
10336
|
-
headers: { "Content-Type": "application/json" },
|
|
10337
|
-
body: JSON.stringify({
|
|
10338
|
-
...installId ? { install_id: installId } : {},
|
|
10339
|
-
org_name: orgName,
|
|
10340
|
-
org_website: orgWebsite,
|
|
10341
|
-
...orgDomain ? { org_domain: orgDomain } : {},
|
|
10342
|
-
granted,
|
|
10343
|
-
...granted ? {
|
|
10344
|
-
contact_email: contactEmail,
|
|
10345
|
-
contact_function: reportedUserFunction(contactFunction),
|
|
10346
|
-
quote
|
|
10347
|
-
} : {},
|
|
10348
|
-
changed_at: changedAt
|
|
10349
|
-
}),
|
|
10350
|
-
signal: AbortSignal.timeout(TIMEOUT_MS)
|
|
10351
|
-
});
|
|
10352
|
-
if (!response.ok) {
|
|
10353
|
-
jsonError(res, `The telemetry proxy answered ${response.status}`, 502);
|
|
10354
|
-
return true;
|
|
10355
|
-
}
|
|
10356
|
-
} catch {
|
|
10357
|
-
jsonError(res, "Could not reach the telemetry proxy", 502);
|
|
10358
|
-
return true;
|
|
10359
|
-
}
|
|
10360
|
-
await getDbClient2().transaction(async () => {
|
|
10361
|
-
await upsertSwarmConfig2({ scope: "global", key: CONSENT_KEY, value: String(granted) });
|
|
10362
|
-
await upsertSwarmConfig2({ scope: "global", key: CONSENT_AT_KEY, value: changedAt });
|
|
10363
|
-
if (granted) {
|
|
10364
|
-
await upsertSwarmConfig2({ scope: "global", key: GRANTED_NAME_KEY, value: orgName });
|
|
10365
|
-
await upsertSwarmConfig2({ scope: "global", key: GRANTED_WEBSITE_KEY, value: orgWebsite });
|
|
10366
|
-
}
|
|
10367
|
-
for (const [key, value, isSecret] of [
|
|
10368
|
-
[CONTACT_EMAIL_KEY, contactEmail, true],
|
|
10369
|
-
[CONTACT_FUNCTION_KEY, contactFunction, false],
|
|
10370
|
-
[QUOTE_KEY, quote, false]
|
|
10371
|
-
]) {
|
|
10372
|
-
await upsertSwarmConfig2({
|
|
10373
|
-
scope: "global",
|
|
10374
|
-
key,
|
|
10375
|
-
value: granted ? value ?? "" : "",
|
|
10376
|
-
isSecret,
|
|
10377
|
-
exportToEnv: false
|
|
10378
|
-
});
|
|
10379
|
-
}
|
|
10380
|
-
});
|
|
10381
|
-
scheduleIntegrationsReload2();
|
|
10382
|
-
const owner = await resolveHttpFavoriteOwner(req, myAgentId);
|
|
10383
|
-
trackRelayed("used_by.consent_changed", {
|
|
10384
|
-
granted,
|
|
10385
|
-
has_quote: granted && Boolean(quote),
|
|
10386
|
-
has_function: granted && Boolean(contactFunction)
|
|
10387
|
-
}, { actor: owner?.userId ? { userId: owner.userId } : undefined, emitter: "ui" });
|
|
10388
|
-
usedBy.respond(res, 200, { granted, changedAt });
|
|
10389
|
-
return true;
|
|
10390
|
-
}
|
|
10391
|
-
|
|
10392
|
-
// src/http/ranking.ts
|
|
10393
|
-
var ListingSchema = object2({
|
|
10394
|
-
v: literal2(1),
|
|
10395
|
-
name: string2(),
|
|
10396
|
-
domain: string2(),
|
|
10397
|
-
category: _enum2(RANKING_CATEGORIES),
|
|
10398
|
-
subcategory: string2().nullable(),
|
|
10399
|
-
description: string2().nullable(),
|
|
10400
|
-
sourceCodeUrl: string2().nullable(),
|
|
10401
|
-
updatedAt: string2()
|
|
10402
|
-
});
|
|
10403
|
-
var RankingStateSchema = object2({
|
|
10404
|
-
eligible: boolean(),
|
|
10405
|
-
missing: array2(_enum2(ORG_IDENTITY_KEYS)),
|
|
10406
|
-
telemetryOn: boolean(),
|
|
10407
|
-
enabled: boolean(),
|
|
10408
|
-
name: string2().nullable(),
|
|
10409
|
-
domain: string2().nullable(),
|
|
10410
|
-
listing: ListingSchema.nullable(),
|
|
10411
|
-
listingMatchesDomain: boolean(),
|
|
10412
|
-
verifyUrl: string2().nullable()
|
|
10413
|
-
});
|
|
10414
|
-
var OptInResponseSchema = object2({
|
|
10415
|
-
domain: string2(),
|
|
10416
|
-
listing: ListingSchema,
|
|
10417
|
-
verifyUrl: string2()
|
|
10418
|
-
});
|
|
10419
|
-
var OptOutResponseSchema = object2({
|
|
10420
|
-
enabled: literal2(false)
|
|
10421
|
-
});
|
|
10422
|
-
var getRanking = route({
|
|
10423
|
-
method: "get",
|
|
10424
|
-
path: "/api/ranking",
|
|
10425
|
-
pattern: ["api", "ranking"],
|
|
10426
|
-
summary: "Public ranking state",
|
|
10427
|
-
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.",
|
|
10428
|
-
tags: ["Telemetry"],
|
|
10429
|
-
responses: {
|
|
10430
|
-
200: { description: "Ranking state", schema: RankingStateSchema },
|
|
10431
|
-
401: { description: "Unauthorized" },
|
|
10432
|
-
403: { description: "Only a config admin can read the ranking state" }
|
|
10433
|
-
},
|
|
10434
|
-
rbac: { permission: "config.write.any" }
|
|
10435
|
-
});
|
|
10436
|
-
var optIn = route({
|
|
10437
|
-
method: "post",
|
|
10438
|
-
path: "/api/ranking/opt-in",
|
|
10439
|
-
pattern: ["api", "ranking", "opt-in"],
|
|
10440
|
-
summary: "Opt this install into the public ranking",
|
|
10441
|
-
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.",
|
|
10442
|
-
tags: ["Telemetry"],
|
|
10443
|
-
body: rankingFormSchema,
|
|
10444
|
-
responses: {
|
|
10445
|
-
200: { description: "Opted in", schema: OptInResponseSchema },
|
|
10446
|
-
400: { description: "A listing field is invalid" },
|
|
10447
|
-
401: { description: "Unauthorized" },
|
|
10448
|
-
403: { description: "Only a config admin can opt in" },
|
|
10449
|
-
409: {
|
|
10450
|
-
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)."
|
|
10451
|
-
}
|
|
10452
|
-
},
|
|
10453
|
-
rbac: { permission: "config.write.any" }
|
|
10454
|
-
});
|
|
10455
|
-
var optOut = route({
|
|
10456
|
-
method: "post",
|
|
10457
|
-
path: "/api/ranking/opt-out",
|
|
10458
|
-
pattern: ["api", "ranking", "opt-out"],
|
|
10459
|
-
summary: "Leave the public ranking",
|
|
10460
|
-
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.",
|
|
10461
|
-
tags: ["Telemetry"],
|
|
10462
|
-
responses: {
|
|
10463
|
-
200: { description: "Opted out", schema: OptOutResponseSchema },
|
|
10464
|
-
401: { description: "Unauthorized" },
|
|
10465
|
-
403: { description: "Only a config admin can opt out" }
|
|
10466
|
-
},
|
|
10467
|
-
rbac: { permission: "config.write.any" }
|
|
10468
|
-
});
|
|
10469
|
-
var RANKING_CONFIG_KEYS = new Set([...ORG_IDENTITY_KEYS, PUBLIC_RANKING_ENABLED_KEY]);
|
|
10470
|
-
async function currentIdentity(changed) {
|
|
10471
|
-
const read = async (key) => changed?.key === key ? changed.value : await globalConfig(key);
|
|
10472
|
-
return orgIdentityStatus({
|
|
10473
|
-
SWARM_ORG_NAME: await read("SWARM_ORG_NAME"),
|
|
10474
|
-
SWARM_ORG_WEBSITE: await read("SWARM_ORG_WEBSITE")
|
|
10475
|
-
});
|
|
10476
|
-
}
|
|
10477
|
-
async function storedListing() {
|
|
10478
|
-
return readTelemetryRanking(await globalConfig(TELEMETRY_RANKING_KEY));
|
|
10479
|
-
}
|
|
10480
|
-
async function rankingEnabled() {
|
|
10481
|
-
const raw = await globalConfig(PUBLIC_RANKING_ENABLED_KEY);
|
|
10482
|
-
return isEnvFlagEnabled(PUBLIC_RANKING_ENABLED_KEY, false, {
|
|
10483
|
-
[PUBLIC_RANKING_ENABLED_KEY]: raw
|
|
10484
|
-
});
|
|
10485
|
-
}
|
|
10486
|
-
async function telemetryReady() {
|
|
10487
|
-
return isTelemetryEnabled() && Boolean(await globalConfig("telemetry_installation_id"));
|
|
10488
|
-
}
|
|
10489
|
-
async function verifyUrl(domain) {
|
|
10490
|
-
const params = new URLSearchParams({ domain });
|
|
10491
|
-
return `${await telemetryProxyEndpoint("/v1/ranking/verify")}?${params.toString()}`;
|
|
10492
|
-
}
|
|
10493
|
-
function withoutClaim(listing) {
|
|
10494
|
-
const { claim: _claim, ...rest } = listing;
|
|
10495
|
-
return rest;
|
|
10496
|
-
}
|
|
10497
|
-
async function setEnabled(enabled) {
|
|
10498
|
-
await upsertSwarmConfig2({
|
|
10499
|
-
scope: "global",
|
|
10500
|
-
key: PUBLIC_RANKING_ENABLED_KEY,
|
|
10501
|
-
value: String(enabled)
|
|
10502
|
-
});
|
|
10503
|
-
}
|
|
10504
|
-
function emitOptedIn(listing) {
|
|
10505
|
-
telemetry.ranking("opted_in", { listing: JSON.stringify(withoutClaim(listing)) }, { orgName: listing.name, orgWebsite: listing.domain });
|
|
10506
|
-
}
|
|
10507
|
-
function emitOptedOut(domain) {
|
|
10508
|
-
telemetry.ranking("opted_out", { domain });
|
|
10509
|
-
}
|
|
10510
|
-
async function buildRankingState() {
|
|
10511
|
-
const [identity, listing, enabled, telemetryOn] = await Promise.all([
|
|
10512
|
-
currentIdentity(),
|
|
10513
|
-
storedListing(),
|
|
10514
|
-
rankingEnabled(),
|
|
10515
|
-
telemetryReady()
|
|
10516
|
-
]);
|
|
10517
|
-
const listingMatchesDomain = Boolean(listing && listing.domain === identity.website);
|
|
10518
|
-
const current = listingMatchesDomain ? listing : null;
|
|
10519
|
-
return {
|
|
10520
|
-
eligible: telemetryOn && identity.ok,
|
|
10521
|
-
missing: identity.missing,
|
|
10522
|
-
telemetryOn,
|
|
10523
|
-
enabled: enabled && listingMatchesDomain,
|
|
10524
|
-
name: identity.name,
|
|
10525
|
-
domain: identity.website,
|
|
10526
|
-
listing: listing ? withoutClaim(listing) : null,
|
|
10527
|
-
listingMatchesDomain,
|
|
10528
|
-
verifyUrl: current ? await verifyUrl(current.domain) : null
|
|
10529
|
-
};
|
|
10530
|
-
}
|
|
10531
|
-
async function syncRankingAfterConfigChange(key, value) {
|
|
10532
|
-
if (!RANKING_CONFIG_KEYS.has(key))
|
|
10533
|
-
return;
|
|
10534
|
-
const listing = await storedListing();
|
|
10535
|
-
if (!listing)
|
|
10536
|
-
return;
|
|
10537
|
-
if (key === PUBLIC_RANKING_ENABLED_KEY) {
|
|
10538
|
-
if (!isEnvFlagEnabled(key, false, { [key]: value ?? undefined })) {
|
|
10539
|
-
emitOptedOut(listing.domain);
|
|
10540
|
-
}
|
|
10541
|
-
return;
|
|
10542
|
-
}
|
|
10543
|
-
if (!await rankingEnabled())
|
|
10544
|
-
return;
|
|
10545
|
-
const identity = await currentIdentity({ key, value });
|
|
10546
|
-
let rebuilt = null;
|
|
10547
|
-
if (identity.ok && identity.website === listing.domain) {
|
|
10548
|
-
if (identity.name === listing.name)
|
|
10549
|
-
return;
|
|
10550
|
-
try {
|
|
10551
|
-
rebuilt = buildListing(identity, listing);
|
|
10552
|
-
} catch {}
|
|
10553
|
-
}
|
|
10554
|
-
if (!rebuilt) {
|
|
10555
|
-
await setEnabled(false);
|
|
10556
|
-
emitOptedOut(listing.domain);
|
|
10557
|
-
return;
|
|
10558
|
-
}
|
|
10559
|
-
await upsertSwarmConfig2({
|
|
10560
|
-
scope: "global",
|
|
10561
|
-
key: TELEMETRY_RANKING_KEY,
|
|
10562
|
-
value: JSON.stringify(rebuilt)
|
|
10563
|
-
});
|
|
10564
|
-
emitOptedIn(rebuilt);
|
|
10565
|
-
}
|
|
10566
|
-
function conflict(res, body) {
|
|
10567
|
-
res.writeHead(409, { "Content-Type": "application/json" });
|
|
10568
|
-
res.end(JSON.stringify(body));
|
|
10569
|
-
}
|
|
10570
|
-
async function handleRanking(req, res, pathSegments, queryParams) {
|
|
10571
|
-
if (getRanking.match(req.method, pathSegments)) {
|
|
10572
|
-
const parsed = await getRanking.parse(req, res, pathSegments, queryParams);
|
|
10573
|
-
if (!parsed)
|
|
10574
|
-
return true;
|
|
10575
|
-
if (!await ensureConfigAdmin(req, res, "config.write.any"))
|
|
10576
|
-
return true;
|
|
10577
|
-
getRanking.respond(res, 200, await buildRankingState());
|
|
10578
|
-
return true;
|
|
10579
|
-
}
|
|
10580
|
-
if (optIn.match(req.method, pathSegments)) {
|
|
10581
|
-
const parsed = await optIn.parse(req, res, pathSegments, queryParams);
|
|
10582
|
-
if (!parsed)
|
|
10583
|
-
return true;
|
|
10584
|
-
if (!await ensureConfigAdmin(req, res, "config.write.any"))
|
|
10585
|
-
return true;
|
|
10586
|
-
if (!await telemetryReady()) {
|
|
10587
|
-
conflict(res, {
|
|
10588
|
-
error: "telemetry_off",
|
|
10589
|
-
message: "Turn telemetry on first: the ranking counts tokens from telemetry."
|
|
10590
|
-
});
|
|
10591
|
-
return true;
|
|
10592
|
-
}
|
|
10593
|
-
const identity = await currentIdentity();
|
|
10594
|
-
if (!identity.ok || !identity.website) {
|
|
10595
|
-
conflict(res, {
|
|
10596
|
-
error: "org_identity_missing",
|
|
10597
|
-
message: "Set the organization name and website first",
|
|
10598
|
-
missing: identity.missing
|
|
10599
|
-
});
|
|
10600
|
-
return true;
|
|
10601
|
-
}
|
|
10602
|
-
const db = getDbClient2();
|
|
10603
|
-
const built = await db.transaction(async () => {
|
|
10604
|
-
let listing;
|
|
10605
|
-
try {
|
|
10606
|
-
listing = buildListing(identity, parsed.body);
|
|
10607
|
-
} catch (error) {
|
|
10608
|
-
return { ok: false, error };
|
|
10609
|
-
}
|
|
10610
|
-
await upsertSwarmConfig2({
|
|
10611
|
-
scope: "global",
|
|
10612
|
-
key: TELEMETRY_RANKING_KEY,
|
|
10613
|
-
value: JSON.stringify(listing)
|
|
10614
|
-
});
|
|
10615
|
-
await setEnabled(true);
|
|
10616
|
-
db.afterCommit(() => emitOptedIn(listing));
|
|
10617
|
-
return { ok: true, listing };
|
|
10618
|
-
});
|
|
10619
|
-
if (!built.ok) {
|
|
10620
|
-
const issue = built.error instanceof ZodError ? built.error.issues[0] : undefined;
|
|
10621
|
-
res.writeHead(400, { "Content-Type": "application/json" });
|
|
10622
|
-
res.end(JSON.stringify({
|
|
10623
|
-
error: issue ? `Invalid ${issue.path.join(".") || "listing"}: ${issue.message}` : "Invalid listing"
|
|
10624
|
-
}));
|
|
10625
|
-
return true;
|
|
10626
|
-
}
|
|
10627
|
-
const { listing } = built;
|
|
10628
|
-
scheduleIntegrationsReload2();
|
|
10629
|
-
optIn.respond(res, 200, {
|
|
10630
|
-
domain: listing.domain,
|
|
10631
|
-
listing,
|
|
10632
|
-
verifyUrl: await verifyUrl(listing.domain)
|
|
10633
|
-
});
|
|
10634
|
-
return true;
|
|
10635
|
-
}
|
|
10636
|
-
if (optOut.match(req.method, pathSegments)) {
|
|
10637
|
-
const parsed = await optOut.parse(req, res, pathSegments, queryParams);
|
|
10638
|
-
if (!parsed)
|
|
10639
|
-
return true;
|
|
10640
|
-
if (!await ensureConfigAdmin(req, res, "config.write.any"))
|
|
10641
|
-
return true;
|
|
10642
|
-
const listing = await storedListing();
|
|
10643
|
-
await setEnabled(false);
|
|
10644
|
-
if (listing)
|
|
10645
|
-
emitOptedOut(listing.domain);
|
|
10646
|
-
scheduleIntegrationsReload2();
|
|
10647
|
-
optOut.respond(res, 200, { enabled: false });
|
|
10648
|
-
return true;
|
|
10649
|
-
}
|
|
10650
|
-
return false;
|
|
10651
|
-
}
|
|
10652
|
-
|
|
10653
|
-
// src/http/config.ts
|
|
10654
|
-
init_request_principal();
|
|
10655
|
-
init_route_def();
|
|
10656
|
-
init_utils2();
|
|
10657
|
-
var MAX_ENV_PRESENCE_KEYS = 200;
|
|
10658
|
-
var SECRETS_FORCE_MASK_NOTE = " (secret values masked: this token cannot read secrets in this scope)";
|
|
10659
|
-
function stripApiOnlyKeys(configs) {
|
|
10660
|
-
return configs.filter((config) => !isApiOnlyConfigKey(config.key) && !isInternalConfigKey(config.key));
|
|
10661
|
-
}
|
|
10662
|
-
function singleHeader(req, name) {
|
|
10663
|
-
const raw = req.headers[name];
|
|
10664
|
-
return Array.isArray(raw) ? raw[0] : raw;
|
|
10665
|
-
}
|
|
10666
|
-
function readsRepoSecrets(auth, agent) {
|
|
10667
|
-
if (auth?.kind !== "agent" || !auth.runtimeId)
|
|
10668
|
-
return true;
|
|
10669
|
-
return runtimeReadsRepoSecrets({ id: auth.agentId, isLead: agent?.isLead });
|
|
10670
|
-
}
|
|
10671
|
-
async function requestSecretReadScope(req, resolvedScope) {
|
|
10672
|
-
const principal = await requestPrincipal(req, undefined);
|
|
10673
|
-
if (!principal || principal.kind === "operator")
|
|
10674
|
-
return "all";
|
|
10675
|
-
if (principal.kind === "guest")
|
|
10676
|
-
return "none";
|
|
10677
|
-
if (principal.kind === "agent") {
|
|
10678
|
-
if (can({
|
|
10679
|
-
principal,
|
|
10680
|
-
verb: "config.read.secrets",
|
|
10681
|
-
resource: { kind: "none" },
|
|
10682
|
-
source: "http"
|
|
10683
|
-
}).allow)
|
|
10684
|
-
return "all";
|
|
10685
|
-
const auth = getRequestAuth(req);
|
|
10686
|
-
if (auth?.kind === "agent" && auth.tokenKind === "task" || resolvedScope?.agentId !== principal.agentId)
|
|
10687
|
-
return "none";
|
|
10688
|
-
return "self";
|
|
10689
|
-
}
|
|
10690
|
-
if (!isRbacEnabled())
|
|
10691
|
-
return "all";
|
|
10692
|
-
const grant = await getUserGrant2(principal.userId);
|
|
10693
|
-
return grant.grantsAll || grant.verbs.has("config.read.secrets") ? "all" : "none";
|
|
10694
|
-
}
|
|
10695
|
-
async function resolveSecretsRead(req, includeSecrets, resolvedScope) {
|
|
10696
|
-
const scope = await requestSecretReadScope(req, resolvedScope);
|
|
10697
|
-
const auth = getRequestAuth(req);
|
|
10698
|
-
return {
|
|
10699
|
-
effectiveIncludeSecrets: includeSecrets && scope !== "none",
|
|
10700
|
-
includeRepoSecrets: !(auth?.kind === "agent" && auth.tokenKind !== "task" && scope !== "all"),
|
|
10701
|
-
secretsNote: includeSecrets && scope === "none" ? SECRETS_FORCE_MASK_NOTE : ""
|
|
10702
|
-
};
|
|
10703
|
-
}
|
|
10704
|
-
async function scriptRunHeldConfigIds(req) {
|
|
10705
|
-
const auth = getRequestAuth(req);
|
|
10706
|
-
if (auth?.kind !== "agent" || auth.tokenKind !== "agent")
|
|
10707
|
-
return;
|
|
10708
|
-
if (!await isScriptRunToken(auth.tokenId))
|
|
10709
|
-
return;
|
|
10710
|
-
const held = stripApiOnlyKeys(await getResolvedConfig2(auth.agentId, undefined, { includeRepoSecrets: false }));
|
|
10711
|
-
return new Set(held.map((config) => config.id));
|
|
10712
|
-
}
|
|
10713
|
-
async function maskConfigRead(req, configs, includeSecrets) {
|
|
10714
|
-
const { effectiveIncludeSecrets, secretsNote } = await resolveSecretsRead(req, includeSecrets);
|
|
10715
|
-
const held = includeSecrets && !effectiveIncludeSecrets ? await scriptRunHeldConfigIds(req) : undefined;
|
|
10716
|
-
const reveal = (config) => effectiveIncludeSecrets || !!held?.has(config.id);
|
|
10717
|
-
const result = configs.map((config) => config.isSecret && !reveal(config) ? maskSecrets2([config])[0] : config);
|
|
10718
|
-
for (const config of result) {
|
|
10719
|
-
if (config.isSecret && config.value && reveal(config)) {
|
|
10720
|
-
registerVolatileSecret(config.value, `config:${config.key}`);
|
|
10721
|
-
}
|
|
10722
|
-
}
|
|
10723
|
-
const anyMasked = result.some((config) => config.isSecret && !reveal(config));
|
|
10724
|
-
return { result, secretsNote: held && !anyMasked ? "" : secretsNote };
|
|
10725
|
-
}
|
|
10726
|
-
async function ensureConfigAdmin(req, res, verb) {
|
|
10727
|
-
return ensureHttpPermission(req, res, verb, verb === "config.write.any" ? "Writing swarm config requires the lead agent" : "Deleting swarm config requires the lead agent");
|
|
10728
|
-
}
|
|
10729
|
-
async function ensureHumanOnlyConfigWrite(req, res, key) {
|
|
10730
|
-
if (!isHumanOnlyConfigKey(key))
|
|
10731
|
-
return true;
|
|
10732
|
-
const auth = getRequestAuth(req);
|
|
10733
|
-
if (auth?.page) {
|
|
10734
|
-
jsonError(res, humanOnlyConfigKeyPageError(key), 403);
|
|
10735
|
-
return false;
|
|
10736
|
-
}
|
|
10737
|
-
const userId = authUserId(auth);
|
|
10738
|
-
if (userId && (!isRbacEnabled() || (await getUserGrant2(userId)).grantsAll))
|
|
10739
|
-
return true;
|
|
10740
|
-
jsonError(res, humanOnlyConfigKeyError(key), 403);
|
|
10741
|
-
return false;
|
|
10742
|
-
}
|
|
10743
|
-
async function runConfigWriteSideEffects(scope, key, value) {
|
|
10744
|
-
if (scope !== "global")
|
|
10745
|
-
return;
|
|
10746
|
-
if (key === "SWARM_ORG_WEBSITE")
|
|
10747
|
-
await fillOrgLogoFromWebsite(value);
|
|
10748
|
-
await syncRankingAfterConfigChange(key, value);
|
|
10749
|
-
scheduleIntegrationsReload2();
|
|
10750
|
-
}
|
|
10751
|
-
async function ensureHttpPermission(req, res, verb, forbiddenMessage, callerAgentId) {
|
|
10752
|
-
const principal = await requestPrincipal(req, callerAgentId ?? singleHeader(req, "x-agent-id"), {
|
|
10753
|
-
unauthenticatedFallback: "anonymous-agent"
|
|
10754
|
-
});
|
|
10755
|
-
if (principal.kind === "operator" || principal.kind === "user")
|
|
10756
|
-
return true;
|
|
10757
|
-
if (principal.kind === "guest") {
|
|
10758
|
-
jsonError(res, "Forbidden", 403);
|
|
10759
|
-
return false;
|
|
10760
|
-
}
|
|
10761
|
-
const decision = can({
|
|
10762
|
-
principal,
|
|
10763
|
-
verb,
|
|
10764
|
-
resource: { kind: "none" },
|
|
10765
|
-
source: "http"
|
|
10766
|
-
});
|
|
10767
|
-
if (!decision.allow) {
|
|
10768
|
-
jsonError(res, forbiddenMessage, 403);
|
|
10769
|
-
return false;
|
|
10770
|
-
}
|
|
10771
|
-
return true;
|
|
10772
|
-
}
|
|
10773
|
-
var getResolvedConfigRoute = route({
|
|
10774
|
-
method: "get",
|
|
10775
|
-
path: "/api/config/resolved",
|
|
10776
|
-
pattern: ["api", "config", "resolved"],
|
|
10777
|
-
summary: "Get resolved config (merged global + agent + repo scopes)",
|
|
10778
|
-
tags: ["Config"],
|
|
10779
|
-
query: object2({
|
|
10780
|
-
agentId: string2().optional(),
|
|
10781
|
-
repoId: string2().optional(),
|
|
10782
|
-
key: string2().min(1).optional().describe("Return only the entry with this exact key. Omit to return every resolved entry."),
|
|
10783
|
-
includeSecrets: _enum2(["true", "false"]).optional()
|
|
10784
|
-
}),
|
|
10785
|
-
responses: {
|
|
10786
|
-
200: {
|
|
10787
|
-
description: "Resolved config entries",
|
|
10788
|
-
schema: object2({
|
|
10789
|
-
configs: array2(SwarmConfigSchema),
|
|
10790
|
-
message: string2().optional()
|
|
10791
|
-
})
|
|
10792
|
-
}
|
|
10793
|
-
}
|
|
10794
|
-
});
|
|
10795
|
-
var envPresence = route({
|
|
10796
|
-
method: "get",
|
|
10797
|
-
path: "/api/config/env-presence",
|
|
10798
|
-
pattern: ["api", "config", "env-presence"],
|
|
10799
|
-
summary: "Check which of the given env var keys are currently set in process.env (presence only, no values)",
|
|
10800
|
-
tags: ["Config"],
|
|
10801
|
-
query: object2({
|
|
10802
|
-
keys: string2().min(1)
|
|
10803
|
-
}),
|
|
10804
|
-
responses: {
|
|
10805
|
-
200: {
|
|
10806
|
-
description: "Map of key -> boolean (true iff set in process.env)",
|
|
10807
|
-
schema: object2({ presence: record2(string2(), boolean()) })
|
|
10808
|
-
},
|
|
10809
|
-
400: { description: "Validation error" }
|
|
10810
|
-
}
|
|
10811
|
-
});
|
|
10812
|
-
var reloadConfigRoute = route({
|
|
10813
|
-
method: "post",
|
|
10814
|
-
path: "/api/config/reload",
|
|
10815
|
-
pattern: ["api", "config", "reload"],
|
|
10816
|
-
summary: "Reload global swarm_config into process.env (override=true) and re-init integrations (Slack, GitHub, Linear, AgentMail)",
|
|
10817
|
-
tags: ["Config"],
|
|
10818
|
-
body: object2({}).optional(),
|
|
10819
|
-
responses: {
|
|
10820
|
-
200: {
|
|
10821
|
-
description: "Reload result",
|
|
10822
|
-
schema: object2({
|
|
10823
|
-
success: literal2(true),
|
|
10824
|
-
configsLoaded: number2(),
|
|
10825
|
-
keysUpdated: array2(string2()),
|
|
10826
|
-
integrationsReinitialized: array2(string2())
|
|
10827
|
-
})
|
|
10828
|
-
},
|
|
10829
|
-
500: { description: "Reload failed" }
|
|
10830
|
-
}
|
|
10831
|
-
});
|
|
10832
|
-
var getConfigById = route({
|
|
10833
|
-
method: "get",
|
|
10834
|
-
path: "/api/config/{id}",
|
|
10835
|
-
pattern: ["api", "config", null],
|
|
10836
|
-
summary: "Get a single config entry by ID",
|
|
10837
|
-
tags: ["Config"],
|
|
10838
|
-
params: object2({ id: string2() }),
|
|
10839
|
-
query: object2({
|
|
10840
|
-
includeSecrets: _enum2(["true", "false"]).optional()
|
|
10841
|
-
}),
|
|
10842
|
-
responses: {
|
|
10843
|
-
200: {
|
|
10844
|
-
description: "Config entry",
|
|
10845
|
-
schema: SwarmConfigSchema.extend({ message: string2().optional() })
|
|
10846
|
-
},
|
|
10847
|
-
404: { description: "Config not found" }
|
|
10848
|
-
}
|
|
10849
|
-
});
|
|
10850
|
-
var listConfig = route({
|
|
10851
|
-
method: "get",
|
|
10852
|
-
path: "/api/config",
|
|
10853
|
-
pattern: ["api", "config"],
|
|
10854
|
-
summary: "List config entries with optional filters",
|
|
10855
|
-
tags: ["Config"],
|
|
10856
|
-
query: object2({
|
|
10857
|
-
scope: string2().optional(),
|
|
10858
|
-
scopeId: string2().optional(),
|
|
10859
|
-
key: string2().min(1).optional().describe("Return only entries with this exact key. Omit to return every entry."),
|
|
10860
|
-
includeSecrets: _enum2(["true", "false"]).optional()
|
|
10861
|
-
}),
|
|
10862
|
-
responses: {
|
|
10863
|
-
200: {
|
|
10864
|
-
description: "List of config entries",
|
|
10865
|
-
schema: object2({
|
|
10866
|
-
configs: array2(SwarmConfigSchema),
|
|
10867
|
-
message: string2().optional()
|
|
10868
|
-
})
|
|
10869
|
-
}
|
|
10870
|
-
}
|
|
10871
|
-
});
|
|
10872
|
-
var upsertConfig = route({
|
|
10873
|
-
method: "put",
|
|
10874
|
-
path: "/api/config",
|
|
10875
|
-
pattern: ["api", "config"],
|
|
10876
|
-
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.",
|
|
10877
|
-
tags: ["Config"],
|
|
10878
|
-
rbac: { permission: "config.write.any" },
|
|
10879
|
-
body: object2({
|
|
10880
|
-
scope: _enum2(["global", "agent", "repo"]),
|
|
10881
|
-
scopeId: string2().nullish(),
|
|
10882
|
-
key: string2().min(1),
|
|
10883
|
-
value: unknown(),
|
|
10884
|
-
isSecret: boolean().optional(),
|
|
10885
|
-
envPath: string2().nullish(),
|
|
10886
|
-
description: string2().nullish(),
|
|
10887
|
-
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.")
|
|
10888
|
-
}),
|
|
10889
|
-
responses: {
|
|
10890
|
-
200: { description: "Config entry upserted", schema: SwarmConfigSchema },
|
|
10891
|
-
400: { description: "Validation error" }
|
|
10892
|
-
}
|
|
10893
|
-
});
|
|
10894
|
-
var deleteConfig = route({
|
|
10895
|
-
method: "delete",
|
|
10896
|
-
path: "/api/config/{id}",
|
|
10897
|
-
pattern: ["api", "config", null],
|
|
10898
|
-
summary: "Delete a config entry by ID (including legacy reserved rows for cleanup). Global-scope deletes auto-trigger an integrations reload.",
|
|
10899
|
-
tags: ["Config"],
|
|
10900
|
-
rbac: { permission: "config.delete.any" },
|
|
10901
|
-
params: object2({ id: string2() }),
|
|
10902
|
-
responses: {
|
|
10903
|
-
200: {
|
|
10904
|
-
description: "Config deleted",
|
|
10905
|
-
schema: object2({ success: literal2(true) })
|
|
10906
|
-
},
|
|
10907
|
-
404: { description: "Config not found" }
|
|
10908
|
-
}
|
|
10909
|
-
});
|
|
10910
|
-
async function handleConfig(req, res, pathSegments, queryParams) {
|
|
10911
|
-
if (getRequestAuth(req)?.kind === "agent") {
|
|
10912
|
-
const duplicate = duplicateGuardedQueryKey(queryParams);
|
|
10913
|
-
if (duplicate) {
|
|
10914
|
-
jsonError(res, `Duplicate query parameter: ${duplicate}`, 400);
|
|
10915
|
-
return true;
|
|
10916
|
-
}
|
|
10917
|
-
}
|
|
10918
|
-
if (getResolvedConfigRoute.match(req.method, pathSegments)) {
|
|
10919
|
-
const parsed = await getResolvedConfigRoute.parse(req, res, pathSegments, queryParams);
|
|
10920
|
-
if (!parsed)
|
|
10921
|
-
return true;
|
|
10922
|
-
const includeSecrets = parsed.query.includeSecrets === "true";
|
|
10923
|
-
const key = parsed.query.key;
|
|
10924
|
-
const auth = getRequestAuth(req);
|
|
10925
|
-
const resolvedScope = {
|
|
10926
|
-
agentId: parsed.query.agentId || (auth?.kind === "agent" && auth.tokenKind !== "task" ? auth.agentId : undefined),
|
|
10927
|
-
repoId: parsed.query.repoId || undefined
|
|
10928
|
-
};
|
|
10929
|
-
const { effectiveIncludeSecrets, includeRepoSecrets, secretsNote } = await resolveSecretsRead(req, includeSecrets, resolvedScope);
|
|
10930
|
-
const configs = stripApiOnlyKeys(await getResolvedConfig2(resolvedScope.agentId, resolvedScope.repoId, { includeRepoSecrets })).filter((c) => !key || c.key === key);
|
|
10931
|
-
const result = effectiveIncludeSecrets ? configs : maskSecrets2(configs);
|
|
10932
|
-
if (effectiveIncludeSecrets) {
|
|
10933
|
-
for (const c of result) {
|
|
10934
|
-
if (c.isSecret && c.value) {
|
|
10935
|
-
registerVolatileSecret(c.value, `config:${c.key}`);
|
|
10936
|
-
}
|
|
10937
|
-
}
|
|
10938
|
-
}
|
|
10939
|
-
getResolvedConfigRoute.respond(res, 200, {
|
|
10940
|
-
configs: result,
|
|
10941
|
-
...secretsNote ? { message: `Found ${result.length} config(s).${secretsNote}` } : {}
|
|
10942
|
-
});
|
|
10943
|
-
return true;
|
|
10944
|
-
}
|
|
10945
|
-
if (envPresence.match(req.method, pathSegments)) {
|
|
10946
|
-
const parsed = await envPresence.parse(req, res, pathSegments, queryParams);
|
|
10947
|
-
if (!parsed)
|
|
10948
|
-
return true;
|
|
10949
|
-
const keys = parsed.query.keys.split(",").map((k) => k.trim()).filter(Boolean);
|
|
10950
|
-
if (keys.length > MAX_ENV_PRESENCE_KEYS) {
|
|
10951
|
-
jsonError(res, `Too many keys (max ${MAX_ENV_PRESENCE_KEYS})`, 400);
|
|
10952
|
-
return true;
|
|
10953
|
-
}
|
|
10954
|
-
const presence = {};
|
|
10955
|
-
for (const key of keys) {
|
|
10956
|
-
const value = key === "SWARM_ORG_NAME" ? process.env[key]?.trim() : process.env[key];
|
|
10957
|
-
presence[key] = value !== undefined && (isSlackIconConfigKey(key) || value !== "");
|
|
10958
|
-
}
|
|
10959
|
-
envPresence.respond(res, 200, { presence });
|
|
10960
|
-
return true;
|
|
10961
|
-
}
|
|
10962
|
-
if (reloadConfigRoute.match(req.method, pathSegments)) {
|
|
10963
|
-
try {
|
|
10964
|
-
const result = await reloadGlobalConfigsAndIntegrations2();
|
|
10965
|
-
console.log(`[reload-config] Loaded ${result.configsLoaded} config(s), re-initialized: ${result.integrationsReinitialized.join(", ") || "none"}`);
|
|
10966
|
-
reloadConfigRoute.respond(res, 200, { success: true, ...result });
|
|
10967
|
-
} catch (e) {
|
|
10968
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
10969
|
-
console.error("[reload-config] Failed:", message);
|
|
10970
|
-
jsonError(res, `Failed to reload config: ${message}`, 500);
|
|
10971
|
-
}
|
|
10972
|
-
return true;
|
|
10973
|
-
}
|
|
10974
|
-
if (getConfigById.match(req.method, pathSegments)) {
|
|
10975
|
-
const parsed = await getConfigById.parse(req, res, pathSegments, queryParams);
|
|
10976
|
-
if (!parsed)
|
|
10977
|
-
return true;
|
|
10978
|
-
const includeSecrets = parsed.query.includeSecrets === "true";
|
|
10979
|
-
const config = await getSwarmConfigById2(parsed.params.id);
|
|
10980
|
-
if (!config || isInternalConfigKey(config.key)) {
|
|
10981
|
-
jsonError(res, "Config not found", 404);
|
|
10982
|
-
return true;
|
|
10983
|
-
}
|
|
10984
|
-
const { result, secretsNote } = await maskConfigRead(req, [config], includeSecrets);
|
|
10985
|
-
getConfigById.respond(res, 200, {
|
|
10986
|
-
...result[0],
|
|
10987
|
-
...secretsNote ? { message: `Found 1 config(s).${secretsNote}` } : {}
|
|
10988
|
-
});
|
|
10989
|
-
return true;
|
|
10990
|
-
}
|
|
10991
|
-
if (listConfig.match(req.method, pathSegments)) {
|
|
10992
|
-
const parsed = await listConfig.parse(req, res, pathSegments, queryParams);
|
|
10993
|
-
if (!parsed)
|
|
10994
|
-
return true;
|
|
10995
|
-
const includeSecrets = parsed.query.includeSecrets === "true";
|
|
10996
|
-
const configs = stripApiOnlyKeys(await getSwarmConfigs2({
|
|
10997
|
-
scope: parsed.query.scope || undefined,
|
|
10998
|
-
scopeId: parsed.query.scopeId || undefined,
|
|
10999
|
-
key: parsed.query.key
|
|
11000
|
-
}));
|
|
11001
|
-
const { result: listResult, secretsNote } = await maskConfigRead(req, configs, includeSecrets);
|
|
11002
|
-
listConfig.respond(res, 200, {
|
|
11003
|
-
configs: listResult,
|
|
11004
|
-
...secretsNote ? { message: `Found ${listResult.length} config(s).${secretsNote}` } : {}
|
|
11005
|
-
});
|
|
11006
|
-
return true;
|
|
11007
|
-
}
|
|
11008
|
-
if (upsertConfig.match(req.method, pathSegments)) {
|
|
11009
|
-
const parsed = await upsertConfig.parse(req, res, pathSegments, queryParams);
|
|
11010
|
-
if (!parsed)
|
|
11011
|
-
return true;
|
|
11012
|
-
if (!await ensureConfigAdmin(req, res, "config.write.any"))
|
|
11013
|
-
return true;
|
|
11014
|
-
const { scope, scopeId, key, value, isSecret, envPath, description, exportToEnv } = parsed.body;
|
|
11015
|
-
if (!await ensureHumanOnlyConfigWrite(req, res, key))
|
|
11016
|
-
return true;
|
|
11017
|
-
const validationError = validateConfigEntry({ scope, scopeId, key, value, exportToEnv });
|
|
11018
|
-
if (validationError) {
|
|
11019
|
-
jsonError(res, validationError, 400);
|
|
11020
|
-
return true;
|
|
11021
|
-
}
|
|
11022
|
-
try {
|
|
11023
|
-
const includeSecrets = queryParams.get("includeSecrets") === "true";
|
|
11024
|
-
const config = await upsertSwarmConfigWithPolicyMirror({
|
|
11025
|
-
scope,
|
|
11026
|
-
scopeId: scopeId || null,
|
|
11027
|
-
key,
|
|
11028
|
-
value: String(value),
|
|
11029
|
-
isSecret: isSecret || false,
|
|
11030
|
-
envPath: envPath || null,
|
|
11031
|
-
description: description || null,
|
|
11032
|
-
exportToEnv
|
|
11033
|
-
});
|
|
11034
|
-
await runConfigWriteSideEffects(scope, key, String(value));
|
|
11035
|
-
const result = includeSecrets || !config.isSecret ? config : maskSecrets2([config])[0];
|
|
11036
|
-
upsertConfig.respond(res, 200, result);
|
|
11037
|
-
} catch (error) {
|
|
11038
|
-
if (modelProfileRefError(error) === "missing") {
|
|
11039
|
-
jsonError(res, `Unknown model profile "${String(value)}"`, 400);
|
|
11040
|
-
return true;
|
|
11041
|
-
}
|
|
11042
|
-
jsonError(res, "Failed to upsert config", 500);
|
|
11043
|
-
}
|
|
11044
|
-
return true;
|
|
11045
|
-
}
|
|
11046
|
-
if (deleteConfig.match(req.method, pathSegments)) {
|
|
11047
|
-
const parsed = await deleteConfig.parse(req, res, pathSegments, queryParams);
|
|
11048
|
-
if (!parsed)
|
|
11049
|
-
return true;
|
|
11050
|
-
if (!await ensureConfigAdmin(req, res, "config.delete.any"))
|
|
11051
|
-
return true;
|
|
11052
|
-
const existing = await getSwarmConfigLookupById2(parsed.params.id);
|
|
11053
|
-
if (!existing) {
|
|
11054
|
-
jsonError(res, "Config not found", 404);
|
|
11055
|
-
return true;
|
|
11056
|
-
}
|
|
11057
|
-
if (isInternalConfigKey(existing.key)) {
|
|
11058
|
-
jsonError(res, internalConfigKeyError(existing.key).message, 400);
|
|
11059
|
-
return true;
|
|
11060
|
-
}
|
|
11061
|
-
if (!await ensureHumanOnlyConfigWrite(req, res, existing.key))
|
|
11062
|
-
return true;
|
|
11063
|
-
const deleted = await deleteSwarmConfig2(parsed.params.id);
|
|
11064
|
-
if (!deleted) {
|
|
11065
|
-
jsonError(res, "Config not found", 404);
|
|
11066
|
-
return true;
|
|
11067
|
-
}
|
|
11068
|
-
if (existing.scope === "global") {
|
|
11069
|
-
await syncRankingAfterConfigChange(existing.key, null);
|
|
11070
|
-
scheduleIntegrationsReload2();
|
|
11071
|
-
}
|
|
11072
|
-
if (existing.scope === "agent" && existing.scopeId && existing.key === AGENT_MAX_TASKS_CONFIG_KEY) {
|
|
11073
|
-
await resetAgentMaxTasksMirror(existing.scopeId);
|
|
11074
|
-
}
|
|
11075
|
-
deleteConfig.respond(res, 200, { success: true });
|
|
11076
|
-
return true;
|
|
11077
|
-
}
|
|
11078
|
-
return false;
|
|
11079
|
-
}
|
|
11080
|
-
|
|
11081
|
-
// src/http/person-responder.ts
|
|
11082
|
-
init_rbac_roles();
|
|
11083
|
-
init_rbac();
|
|
11084
|
-
init_request_auth_context();
|
|
11085
|
-
init_request_principal();
|
|
11086
|
-
var AGENT_RESPONSE_REFUSED = "Agents cannot answer approval requests. A person must respond with a user token or the dashboard.";
|
|
11087
|
-
async function approvalResponder(req, options) {
|
|
11088
|
-
const auth = getRequestAuth(req);
|
|
11089
|
-
const rawAgentId = req.headers["x-agent-id"];
|
|
11090
|
-
const headerAgentId = Array.isArray(rawAgentId) ? rawAgentId[0] : rawAgentId;
|
|
11091
|
-
const principal = await agentFirstPrincipal(req, headerAgentId);
|
|
11092
|
-
if (principal.kind !== "user" && principal.kind !== "agent" && auth?.page) {
|
|
11093
|
-
return {
|
|
11094
|
-
ok: false,
|
|
11095
|
-
message: options?.pageMessage ?? "A page session without a signed-in user cannot answer approval requests."
|
|
11096
|
-
};
|
|
11097
|
-
}
|
|
11098
|
-
const user = authUser(auth);
|
|
11099
|
-
const responder = principal.kind === "user" && user ? { kind: "user", user } : principal.kind === "operator" ? { kind: "operator" } : null;
|
|
11100
|
-
const verb = options?.verb ?? "approval.respond";
|
|
11101
|
-
const refused = {
|
|
11102
|
-
ok: false,
|
|
11103
|
-
message: options?.refusedMessage ?? AGENT_RESPONSE_REFUSED
|
|
11104
|
-
};
|
|
11105
|
-
const decision = can({ principal, verb, source: "http" });
|
|
11106
|
-
if (!decision.allow || !responder)
|
|
11107
|
-
return refused;
|
|
11108
|
-
if (responder.kind === "user" && isRbacEnabled()) {
|
|
11109
|
-
const grant = await getUserGrant2(responder.user.id);
|
|
11110
|
-
if (!grant.grantsAll && !grant.verbs.has(verb))
|
|
11111
|
-
return refused;
|
|
11112
|
-
}
|
|
11113
|
-
return { ok: true, responder };
|
|
11114
|
-
}
|
|
11115
|
-
function responderKey(responder) {
|
|
11116
|
-
return responder.kind === "user" ? responder.user.id : "operator";
|
|
11117
|
-
}
|
|
11118
|
-
|
|
11119
|
-
// src/http/approval-requests.ts
|
|
11120
|
-
init_request_principal();
|
|
11121
|
-
init_route_def();
|
|
11122
|
-
init_utils2();
|
|
11123
|
-
var QuestionSchema = object2({
|
|
11124
|
-
id: string2(),
|
|
11125
|
-
type: _enum2(["approval", "text", "single-select", "multi-select", "boolean", "config"]),
|
|
11126
|
-
label: string2(),
|
|
11127
|
-
required: boolean().optional(),
|
|
11128
|
-
description: string2().optional(),
|
|
11129
|
-
placeholder: string2().optional(),
|
|
11130
|
-
multiline: boolean().optional(),
|
|
11131
|
-
options: array2(object2({
|
|
11132
|
-
value: string2(),
|
|
11133
|
-
label: string2(),
|
|
11134
|
-
description: string2().optional()
|
|
11135
|
-
})).optional(),
|
|
11136
|
-
minSelections: number2().int().min(0).optional(),
|
|
11137
|
-
maxSelections: number2().int().min(1).optional(),
|
|
11138
|
-
defaultValue: boolean().optional(),
|
|
11139
|
-
config: ConfigQuestionSettingsSchema.optional().describe("Config question settings. Answers are written to swarm_config and replaced by a result that never holds a secret value.")
|
|
11140
|
-
});
|
|
11141
|
-
var QuestionInputSchema = QuestionSchema.extend({
|
|
11142
|
-
label: string2().optional(),
|
|
11143
|
-
required: boolean().default(true)
|
|
11144
|
-
});
|
|
11145
|
-
var ApproversSchema = object2({
|
|
11146
|
-
users: array2(string2()).optional(),
|
|
11147
|
-
roles: array2(string2()).optional(),
|
|
11148
|
-
policy: union3([literal2("any"), literal2("all"), object2({ min: number2().int().min(1) })])
|
|
11149
|
-
});
|
|
11150
|
-
var NotificationChannelSchema = object2({
|
|
11151
|
-
channel: _enum2(["slack", "email"]),
|
|
11152
|
-
target: string2(),
|
|
11153
|
-
messageTs: string2().optional()
|
|
11154
|
-
});
|
|
11155
|
-
var ApprovalVoteSchema = object2({
|
|
11156
|
-
responder: string2().describe("Who answered, from the credential: a user id, or `operator` for the shared key."),
|
|
11157
|
-
approved: boolean(),
|
|
11158
|
-
responses: record2(string2(), unknown()),
|
|
11159
|
-
claimedRespondedBy: string2().optional().describe("The `respondedBy` the client sent. Unverified; display only."),
|
|
11160
|
-
respondedAt: string2()
|
|
11161
|
-
});
|
|
11162
|
-
var ApprovalProgressSchema = object2({
|
|
11163
|
-
approved: number2().int().describe("Approvals that count toward the policy so far."),
|
|
11164
|
-
required: number2().int().describe("Approvals the policy needs before the request resolves.")
|
|
11165
|
-
}).nullable().describe("Quorum progress while the request is pending; null once it is resolved.");
|
|
11166
|
-
var ApprovalRequestSchema = object2({
|
|
11167
|
-
id: string2(),
|
|
11168
|
-
title: string2(),
|
|
11169
|
-
questions: array2(QuestionSchema),
|
|
11170
|
-
workflowRunId: string2().nullable(),
|
|
11171
|
-
workflowRunStepId: string2().nullable(),
|
|
11172
|
-
sourceTaskId: string2().nullable(),
|
|
11173
|
-
approvers: ApproversSchema,
|
|
11174
|
-
status: _enum2(["pending", "approved", "rejected", "timeout", "cancelled"]),
|
|
11175
|
-
responses: record2(string2(), unknown()).nullable(),
|
|
11176
|
-
approvals: array2(ApprovalVoteSchema).nullable().describe("Every accepted answer, in order. A request with an `all` or `{ min: N }` policy stays pending until enough approve."),
|
|
11177
|
-
approvalProgress: ApprovalProgressSchema,
|
|
11178
|
-
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."),
|
|
11179
|
-
resolvedAt: string2().nullable(),
|
|
11180
|
-
resolutionReason: string2().nullable(),
|
|
11181
|
-
timeoutSeconds: number2().nullable(),
|
|
11182
|
-
expiresAt: string2().nullable(),
|
|
11183
|
-
notificationChannels: array2(NotificationChannelSchema).nullable(),
|
|
11184
|
-
createdBy: string2().optional(),
|
|
11185
|
-
createdAt: string2(),
|
|
11186
|
-
updatedAt: string2(),
|
|
11187
|
-
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.")
|
|
11188
|
-
});
|
|
11189
|
-
var ApprovalRequestSummarySchema = ApprovalRequestSchema.omit({
|
|
11190
|
-
questions: true,
|
|
11191
|
-
approvers: true,
|
|
11192
|
-
responses: true,
|
|
11193
|
-
approvals: true,
|
|
11194
|
-
resolutionReason: true,
|
|
11195
|
-
notificationChannels: true,
|
|
11196
|
-
configState: true
|
|
11197
|
-
}).extend({
|
|
11198
|
-
questionCount: number2().int(),
|
|
11199
|
-
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).")
|
|
11200
|
-
});
|
|
11201
|
-
async function toApprovalRequestResponse(request, options = {}) {
|
|
11202
|
-
const approvers = request.approvers;
|
|
11203
|
-
const approvals = request.approvals ?? null;
|
|
11204
|
-
const configState = options.withConfigState ? await readConfigStates(request.questions) : undefined;
|
|
11205
|
-
return {
|
|
11206
|
-
...request,
|
|
11207
|
-
...configState ? { configState } : {},
|
|
11208
|
-
questions: request.questions,
|
|
11209
|
-
approvers,
|
|
11210
|
-
responses: request.responses,
|
|
11211
|
-
approvals,
|
|
11212
|
-
approvalProgress: request.status === "pending" ? await approvalProgress(approvers, approvals ?? []) : null,
|
|
11213
|
-
notificationChannels: request.notificationChannels
|
|
11214
|
-
};
|
|
11215
|
-
}
|
|
11216
|
-
async function withApprovalProgress(rows, viewer) {
|
|
11217
|
-
const pendingIds = rows.filter((row) => row.status === "pending").map((row) => row.id);
|
|
11218
|
-
const state = new Map((await getPendingApprovalVoteState2(pendingIds)).map((entry) => [entry.id, entry]));
|
|
11219
|
-
return Promise.all(rows.map(async (row) => {
|
|
11220
|
-
const entry = state.get(row.id);
|
|
11221
|
-
return {
|
|
11222
|
-
...row,
|
|
11223
|
-
approvalProgress: entry ? await approvalProgress(entry.approvers, entry.approvals ?? []) : null,
|
|
11224
|
-
...entry && {
|
|
11225
|
-
viewerCanRespond: viewer !== null && isListedApprover(entry.approvers, viewer)
|
|
11226
|
-
}
|
|
11227
|
-
};
|
|
11228
|
-
}));
|
|
11229
|
-
}
|
|
11230
|
-
async function readConfigStates(questions) {
|
|
11231
|
-
const configQuestions = questions.filter(isConfigQuestion);
|
|
11232
|
-
if (configQuestions.length === 0)
|
|
11233
|
-
return;
|
|
11234
|
-
const entries = await Promise.all(configQuestions.map(async (q) => [q.id, await readConfigState(q.config)]));
|
|
11235
|
-
return Object.fromEntries(entries);
|
|
11236
|
-
}
|
|
11237
|
-
|
|
11238
|
-
class ConfigRespondAbort extends Error {
|
|
11239
|
-
kind;
|
|
11240
|
-
constructor(kind, message = kind) {
|
|
11241
|
-
super(message);
|
|
11242
|
-
this.kind = kind;
|
|
11243
|
-
}
|
|
11244
|
-
}
|
|
11245
|
-
async function getWorkflowApprovalUnavailableReason(request) {
|
|
11246
|
-
if (!request.workflowRunId || !request.workflowRunStepId)
|
|
11247
|
-
return null;
|
|
11248
|
-
const run = await getWorkflowRun2(request.workflowRunId);
|
|
11249
|
-
if (!run)
|
|
11250
|
-
return "The workflow run no longer exists";
|
|
11251
|
-
if (run.status !== "running" && run.status !== "waiting") {
|
|
11252
|
-
return `The workflow run is ${run.status} and this approval is no longer actionable`;
|
|
11253
|
-
}
|
|
11254
|
-
const step = await getWorkflowRunStep2(request.workflowRunStepId);
|
|
11255
|
-
if (!step)
|
|
11256
|
-
return "The human-in-the-loop step no longer exists";
|
|
11257
|
-
if (step.runId !== run.id) {
|
|
11258
|
-
return "The human-in-the-loop step belongs to a different workflow run";
|
|
11259
|
-
}
|
|
11260
|
-
if (step.status !== "waiting") {
|
|
11261
|
-
return `The human-in-the-loop step is ${step.status} and this approval is no longer actionable`;
|
|
11262
|
-
}
|
|
11263
|
-
return null;
|
|
11264
|
-
}
|
|
11265
|
-
function hasRequiredResponse(question, response) {
|
|
11266
|
-
switch (question.type) {
|
|
11267
|
-
case "approval":
|
|
11268
|
-
return typeof response === "object" && response !== null && typeof response.approved === "boolean";
|
|
11269
|
-
case "text":
|
|
11270
|
-
return typeof response === "string" && response.trim().length > 0;
|
|
11271
|
-
case "single-select":
|
|
11272
|
-
return typeof response === "string" && response.length > 0 && (!question.options || question.options.some((option) => option.value === response));
|
|
11273
|
-
case "multi-select": {
|
|
11274
|
-
if (!Array.isArray(response))
|
|
11275
|
-
return false;
|
|
11276
|
-
const minimum = Math.max(1, question.minSelections ?? 0);
|
|
11277
|
-
if (response.length < minimum)
|
|
11278
|
-
return false;
|
|
11279
|
-
if (question.maxSelections !== undefined && response.length > question.maxSelections) {
|
|
11280
|
-
return false;
|
|
11281
|
-
}
|
|
11282
|
-
return response.every((value) => typeof value === "string" && (!question.options || question.options.some((option) => option.value === value)));
|
|
11283
|
-
}
|
|
11284
|
-
case "boolean":
|
|
11285
|
-
return typeof response === "boolean";
|
|
11286
|
-
case "config": {
|
|
11287
|
-
if (typeof response !== "object" || response === null)
|
|
11288
|
-
return false;
|
|
11289
|
-
const answer = response;
|
|
11290
|
-
if (answer.action === "keep")
|
|
11291
|
-
return true;
|
|
11292
|
-
return answer.action === "set" && typeof answer.value === "string" && answer.value.trim() !== "";
|
|
11293
|
-
}
|
|
11294
|
-
}
|
|
11295
|
-
}
|
|
11296
|
-
function isUnanswered(response) {
|
|
11297
|
-
return response === undefined || response === null || typeof response === "string" && response.trim() === "" || Array.isArray(response) && response.length === 0;
|
|
11298
|
-
}
|
|
11299
|
-
function missingRequiredResponseIds(questions, responses) {
|
|
11300
|
-
return questions.filter((question) => {
|
|
11301
|
-
const response = responses[question.id];
|
|
11302
|
-
if (hasRequiredResponse(question, response))
|
|
11303
|
-
return false;
|
|
11304
|
-
if (question.required)
|
|
11305
|
-
return true;
|
|
11306
|
-
return question.type !== "config" && !isUnanswered(response);
|
|
11307
|
-
}).map((question) => question.id);
|
|
11308
|
-
}
|
|
11309
|
-
var createRoute = route({
|
|
11310
|
-
method: "post",
|
|
11311
|
-
path: "/api/approval-requests",
|
|
11312
|
-
pattern: ["api", "approval-requests"],
|
|
11313
|
-
session: bodyTask("sourceTaskId"),
|
|
11314
|
-
summary: "Create a new approval request",
|
|
11315
|
-
tags: ["ApprovalRequests"],
|
|
11316
|
-
body: object2({
|
|
11317
|
-
title: string2().min(1),
|
|
11318
|
-
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).'),
|
|
11319
|
-
approvers: object2({
|
|
11320
|
-
users: array2(string2()).optional(),
|
|
11321
|
-
roles: array2(string2()).optional(),
|
|
11322
|
-
policy: union3([
|
|
11323
|
-
literal2("any"),
|
|
11324
|
-
literal2("all"),
|
|
11325
|
-
object2({ min: number2().int().min(1) })
|
|
11326
|
-
])
|
|
11327
|
-
}),
|
|
11328
|
-
workflowRunId: string2().uuid().optional(),
|
|
11329
|
-
workflowRunStepId: string2().uuid().optional(),
|
|
11330
|
-
sourceTaskId: string2().uuid().optional(),
|
|
11331
|
-
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)."),
|
|
11332
|
-
notifications: array2(object2({
|
|
11333
|
-
channel: _enum2(["slack", "email"]),
|
|
11334
|
-
target: string2()
|
|
11335
|
-
})).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.")
|
|
11336
|
-
}),
|
|
11337
|
-
responses: {
|
|
11338
|
-
201: {
|
|
11339
|
-
description: "Approval request created",
|
|
11340
|
-
schema: object2({ approvalRequest: ApprovalRequestSchema })
|
|
11341
|
-
},
|
|
11342
|
-
400: { description: "Validation error" },
|
|
11343
|
-
403: { description: "Slack notifications require a lead agent" }
|
|
11344
|
-
},
|
|
11345
|
-
auth: { apiKey: true }
|
|
11346
|
-
});
|
|
11347
|
-
var getByIdRoute = route({
|
|
11348
|
-
method: "get",
|
|
11349
|
-
path: "/api/approval-requests/{id}",
|
|
11350
|
-
pattern: ["api", "approval-requests", null],
|
|
11351
|
-
summary: "Get approval request details",
|
|
11352
|
-
tags: ["ApprovalRequests"],
|
|
11353
|
-
params: object2({ id: string2().uuid() }),
|
|
11354
|
-
responses: {
|
|
11355
|
-
200: {
|
|
11356
|
-
description: "Approval request details",
|
|
11357
|
-
schema: object2({ approvalRequest: ApprovalRequestSchema })
|
|
11358
|
-
},
|
|
11359
|
-
404: { description: "Not found" }
|
|
11360
|
-
},
|
|
11361
|
-
auth: { apiKey: true },
|
|
11362
|
-
description: "Includes `configState` when the request has `config` questions: the live state of each target key, read now."
|
|
11363
|
-
});
|
|
11364
|
-
var respondRoute = route({
|
|
11365
|
-
method: "post",
|
|
11366
|
-
path: "/api/approval-requests/{id}/respond",
|
|
11367
|
-
pattern: ["api", "approval-requests", null, "respond"],
|
|
11368
|
-
summary: "Submit a response to an approval request",
|
|
11369
|
-
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.',
|
|
11370
|
-
tags: ["ApprovalRequests"],
|
|
11371
|
-
params: object2({ id: string2().uuid() }),
|
|
11372
|
-
body: object2({
|
|
11373
|
-
responses: record2(string2(), unknown()),
|
|
11374
|
-
respondedBy: string2().optional().describe("Unverified display name. Stored as `claimedRespondedBy` on the answer; never used as the responder.")
|
|
11375
|
-
}),
|
|
11376
|
-
responses: {
|
|
11377
|
-
200: {
|
|
11378
|
-
description: "Response recorded. `status` stays `pending` while the policy needs more approvals.",
|
|
11379
|
-
schema: object2({ approvalRequest: ApprovalRequestSchema })
|
|
11380
|
-
},
|
|
11381
|
-
400: { description: "Validation error" },
|
|
11382
|
-
403: { description: "Caller is an agent, or is not one of the request's approvers" },
|
|
11383
|
-
404: { description: "Not found" },
|
|
11384
|
-
409: { description: "Already resolved, or this responder already answered" }
|
|
11385
|
-
},
|
|
11386
|
-
auth: { apiKey: true },
|
|
11387
|
-
rbac: { permission: "approval.respond" }
|
|
11388
|
-
});
|
|
11389
|
-
var cancelRoute = route({
|
|
11390
|
-
method: "post",
|
|
11391
|
-
path: "/api/approval-requests/{id}/cancel",
|
|
11392
|
-
pattern: ["api", "approval-requests", null, "cancel"],
|
|
11393
|
-
summary: "Cancel a pending approval request",
|
|
11394
|
-
tags: ["ApprovalRequests"],
|
|
11395
|
-
params: object2({ id: string2().uuid() }),
|
|
11396
|
-
body: object2({ reason: string2().max(500).optional() }),
|
|
11397
|
-
responses: {
|
|
11398
|
-
200: {
|
|
11399
|
-
description: "Request cancelled, or already cancelled. A request that gates a running or waiting workflow run cancels that run too.",
|
|
11400
|
-
schema: object2({
|
|
11401
|
-
approvalRequest: ApprovalRequestSchema,
|
|
11402
|
-
alreadyCancelled: boolean(),
|
|
11403
|
-
runCancelled: boolean()
|
|
11404
|
-
})
|
|
11405
|
-
},
|
|
11406
|
-
403: { description: "Caller may not cancel this request" },
|
|
11407
|
-
404: { description: "Not found" },
|
|
11408
|
-
409: {
|
|
11409
|
-
description: "Already resolved with approved, rejected, or timeout, or its expiresAt passed"
|
|
11410
|
-
}
|
|
11411
|
-
},
|
|
11412
|
-
auth: { apiKey: true },
|
|
11413
|
-
rbac: { permission: "approval.cancel.any" }
|
|
11414
|
-
});
|
|
11415
|
-
var listRoute = route({
|
|
11416
|
-
method: "get",
|
|
11417
|
-
path: "/api/approval-requests",
|
|
11418
|
-
pattern: ["api", "approval-requests"],
|
|
11419
|
-
summary: "List approval requests with optional filters",
|
|
11420
|
-
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}`.",
|
|
11421
|
-
tags: ["ApprovalRequests"],
|
|
11422
|
-
query: object2({
|
|
11423
|
-
status: string2().optional(),
|
|
11424
|
-
workflowRunId: string2().optional(),
|
|
11425
|
-
limit: exports_coerce.number().optional(),
|
|
11426
|
-
fields: _enum2(["full", "slim"]).optional()
|
|
11427
|
-
}),
|
|
11428
|
-
responses: {
|
|
11429
|
-
200: {
|
|
11430
|
-
description: "List of approval requests",
|
|
11431
|
-
schema: object2({
|
|
11432
|
-
approvalRequests: union3([
|
|
11433
|
-
array2(ApprovalRequestSchema),
|
|
11434
|
-
array2(ApprovalRequestSummarySchema)
|
|
11435
|
-
])
|
|
11436
|
-
})
|
|
11437
|
-
}
|
|
11438
|
-
},
|
|
11439
|
-
auth: { apiKey: true }
|
|
11440
|
-
});
|
|
11441
|
-
async function handleApprovalRequests(req, res, pathSegments, queryParams) {
|
|
11442
|
-
if (respondRoute.match(req.method, pathSegments)) {
|
|
11443
|
-
const parsed = await respondRoute.parse(req, res, pathSegments, queryParams);
|
|
11444
|
-
if (!parsed)
|
|
11445
|
-
return true;
|
|
11446
|
-
const responder = await approvalResponder(req);
|
|
11447
|
-
if (!responder.ok) {
|
|
11448
|
-
jsonError(res, responder.message, 403);
|
|
11449
|
-
return true;
|
|
11450
|
-
}
|
|
11451
|
-
const existing = await getApprovalRequestById2(parsed.params.id);
|
|
11452
|
-
if (!existing) {
|
|
11453
|
-
jsonError(res, "Approval request not found", 404);
|
|
11454
|
-
return true;
|
|
11455
|
-
}
|
|
11456
|
-
if (existing.status !== "pending") {
|
|
11457
|
-
const reason = existing.resolutionReason ? `: ${existing.resolutionReason}` : "";
|
|
11458
|
-
jsonError(res, `Approval request already resolved with status: ${existing.status}${reason}`, 409);
|
|
11459
|
-
return true;
|
|
11460
|
-
}
|
|
11461
|
-
if (existing.expiresAt && new Date(existing.expiresAt) < new Date) {
|
|
11462
|
-
await getDbClient2().transaction(async () => {
|
|
11463
|
-
const timedOut = await resolveApprovalRequest2(existing.id, {
|
|
11464
|
-
status: "timeout",
|
|
11465
|
-
resolutionReason: `Timed out: the answer arrived after the deadline ${existing.expiresAt}`
|
|
11466
|
-
});
|
|
11467
|
-
if (timedOut && !existing.workflowRunId) {
|
|
11468
|
-
await createApprovalFollowUpTask2(timedOut, "hitl.timeout");
|
|
11469
|
-
}
|
|
11470
|
-
});
|
|
11471
|
-
jsonError(res, `Approval request expired at ${existing.expiresAt}`, 409);
|
|
11472
|
-
return true;
|
|
11473
|
-
}
|
|
11474
|
-
const unavailableReason = await getWorkflowApprovalUnavailableReason(existing);
|
|
11475
|
-
if (unavailableReason) {
|
|
11476
|
-
jsonError(res, unavailableReason, 409);
|
|
11477
|
-
return true;
|
|
11478
|
-
}
|
|
11479
|
-
const approvers = existing.approvers;
|
|
11480
|
-
if (!isListedApprover(approvers, responder.responder)) {
|
|
11481
|
-
jsonError(res, "You are not one of this request's approvers", 403);
|
|
11482
|
-
return true;
|
|
11483
|
-
}
|
|
11484
|
-
const questions = existing.questions;
|
|
11485
|
-
const missingRequired = missingRequiredResponseIds(questions, parsed.body.responses);
|
|
11486
|
-
if (missingRequired.length > 0) {
|
|
11487
|
-
jsonError(res, `Responses missing or invalid: ${missingRequired.join(", ")}`, 400);
|
|
11488
|
-
return true;
|
|
11489
|
-
}
|
|
11490
|
-
const configQuestions = questions.filter(isConfigQuestion);
|
|
11491
|
-
const configAnswers = new Map;
|
|
11492
|
-
for (const question of configQuestions) {
|
|
11493
|
-
const state = await readConfigState(question.config);
|
|
11494
|
-
const answer = parseConfigAnswer(question, parsed.body.responses[question.id], state);
|
|
11495
|
-
if (!answer.ok) {
|
|
11496
|
-
jsonError(res, answer.error, 400);
|
|
11497
|
-
return true;
|
|
11498
|
-
}
|
|
11499
|
-
configAnswers.set(question.id, { question, answer: answer.answer });
|
|
11500
|
-
}
|
|
11501
|
-
if (configAnswers.size > 0 && approvers.policy !== "any") {
|
|
11502
|
-
jsonError(res, 'Config questions need approvers.policy "any"', 409);
|
|
11503
|
-
return true;
|
|
11504
|
-
}
|
|
11505
|
-
if ([...configAnswers.values()].some(({ answer }) => answer.action === "set")) {
|
|
11506
|
-
if (!await ensureConfigAdmin(req, res, "config.write.any"))
|
|
11507
|
-
return true;
|
|
11508
|
-
for (const { question, answer } of configAnswers.values()) {
|
|
11509
|
-
if (answer.action !== "set")
|
|
11510
|
-
continue;
|
|
11511
|
-
if (!await ensureHumanOnlyConfigWrite(req, res, question.config.key))
|
|
11512
|
-
return true;
|
|
11513
|
-
}
|
|
11514
|
-
const userId = authUserId(getRequestAuth(req));
|
|
11515
|
-
if (userId && isRbacEnabled()) {
|
|
11516
|
-
const grant = await getUserGrant2(userId);
|
|
11517
|
-
if (!grant.grantsAll && !grant.verbs.has("config.write.any")) {
|
|
11518
|
-
jsonError(res, "Forbidden: setting a config value needs 'config.write.any'", 403);
|
|
11519
|
-
return true;
|
|
11520
|
-
}
|
|
11521
|
-
}
|
|
11522
|
-
}
|
|
11523
|
-
const safeResponses = { ...parsed.body.responses };
|
|
11524
|
-
for (const id of configAnswers.keys())
|
|
11525
|
-
delete safeResponses[id];
|
|
11526
|
-
let status = "approved";
|
|
11527
|
-
for (const q of questions) {
|
|
11528
|
-
if (q.type === "approval") {
|
|
11529
|
-
const answer = safeResponses[q.id];
|
|
11530
|
-
if (answer && answer.approved === false) {
|
|
11531
|
-
status = "rejected";
|
|
11532
|
-
break;
|
|
11533
|
-
}
|
|
11534
|
-
}
|
|
11535
|
-
}
|
|
11536
|
-
const responderId = responderKey(responder.responder);
|
|
11537
|
-
const respondedAt = new Date().toISOString();
|
|
11538
|
-
const configWrites = [];
|
|
11539
|
-
const outcome = await getDbClient2().transaction(async () => {
|
|
11540
|
-
const current = await getApprovalRequestById2(parsed.params.id);
|
|
11541
|
-
if (!current || current.status !== "pending")
|
|
11542
|
-
return { kind: "unavailable" };
|
|
11543
|
-
const prior = current.approvals ?? [];
|
|
11544
|
-
if (prior.some((v) => v.responder === responderId))
|
|
11545
|
-
return { kind: "duplicate" };
|
|
11546
|
-
const responses = { ...safeResponses };
|
|
11547
|
-
for (const [id, { question, answer }] of configAnswers) {
|
|
11548
|
-
if (status === "rejected" || answer.action === "skip") {
|
|
11549
|
-
responses[id] = skippedConfigResult(question);
|
|
11550
|
-
} else if (answer.action === "keep") {
|
|
11551
|
-
const kept = await keptConfigResult(question);
|
|
11552
|
-
if (!kept) {
|
|
11553
|
-
throw new ConfigRespondAbort("conflict", `config question "${id}": the key was removed before the answer was saved`);
|
|
11554
|
-
}
|
|
11555
|
-
responses[id] = kept;
|
|
11556
|
-
} else {
|
|
11557
|
-
const written = await applyConfigAnswer(question, answer.value);
|
|
11558
|
-
configWrites.push({ result: written, value: answer.value });
|
|
11559
|
-
responses[id] = written;
|
|
11560
|
-
}
|
|
11561
|
-
}
|
|
11562
|
-
const vote = {
|
|
11563
|
-
responder: responderId,
|
|
11564
|
-
approved: status === "approved",
|
|
11565
|
-
responses,
|
|
11566
|
-
...parsed.body.respondedBy ? { claimedRespondedBy: parsed.body.respondedBy } : {},
|
|
11567
|
-
respondedAt
|
|
11568
|
-
};
|
|
11569
|
-
const votes = [...prior, vote];
|
|
11570
|
-
if (status === "rejected" || await approvalQuorumMet(approvers, votes)) {
|
|
11571
|
-
const resolved = await resolveApprovalRequest2(parsed.params.id, { status, responses, approvals: votes, resolvedBy: responderId }, { requireActionableWorkflow: true });
|
|
11572
|
-
if (!resolved && configWrites.length > 0)
|
|
11573
|
-
throw new ConfigRespondAbort("unavailable");
|
|
11574
|
-
return resolved ? { kind: "resolved", request: resolved } : { kind: "unavailable" };
|
|
11575
|
-
}
|
|
11576
|
-
const recorded = await recordApprovalVotes2(parsed.params.id, votes) ? await getApprovalRequestById2(parsed.params.id) : null;
|
|
11577
|
-
return recorded ? { kind: "recorded", request: recorded } : { kind: "unavailable" };
|
|
11578
|
-
}).catch((error) => {
|
|
11579
|
-
if (!(error instanceof ConfigRespondAbort))
|
|
11580
|
-
throw error;
|
|
11581
|
-
configWrites.length = 0;
|
|
11582
|
-
return error.kind === "conflict" ? { kind: "conflict", message: error.message } : { kind: "unavailable" };
|
|
11583
|
-
});
|
|
11584
|
-
if (outcome.kind === "conflict") {
|
|
11585
|
-
jsonError(res, outcome.message, 409);
|
|
11586
|
-
return true;
|
|
11587
|
-
}
|
|
11588
|
-
for (const { result, value } of configWrites) {
|
|
11589
|
-
try {
|
|
11590
|
-
await runConfigWriteSideEffects(result.scope, result.key, value);
|
|
11591
|
-
} catch (err) {
|
|
11592
|
-
console.error("[approval-requests] Config side effects failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
11593
|
-
}
|
|
11594
|
-
}
|
|
11595
|
-
if (outcome.kind === "duplicate") {
|
|
11596
|
-
jsonError(res, "You already answered this approval request", 409);
|
|
11597
|
-
return true;
|
|
11598
|
-
}
|
|
11599
|
-
if (outcome.kind === "recorded") {
|
|
11600
|
-
respondRoute.respond(res, 200, {
|
|
11601
|
-
approvalRequest: await toApprovalRequestResponse(outcome.request)
|
|
11602
|
-
});
|
|
11603
|
-
return true;
|
|
11604
|
-
}
|
|
11605
|
-
const updated = outcome.kind === "resolved" ? outcome.request : null;
|
|
11606
|
-
if (!updated) {
|
|
11607
|
-
const latest = await getApprovalRequestById2(parsed.params.id);
|
|
11608
|
-
const unavailableAfterRace = latest ? await getWorkflowApprovalUnavailableReason(latest) : null;
|
|
11609
|
-
jsonError(res, unavailableAfterRace ?? `Failed to resolve approval request (status: ${latest?.status ?? "unknown"})`, 409);
|
|
11610
|
-
return true;
|
|
11611
|
-
}
|
|
11612
|
-
workflowEventBus2.emit("approval.resolved", {
|
|
11613
|
-
requestId: updated.id,
|
|
11614
|
-
status: updated.status,
|
|
11615
|
-
responses: updated.responses,
|
|
11616
|
-
workflowRunId: updated.workflowRunId ?? undefined,
|
|
11617
|
-
workflowRunStepId: updated.workflowRunStepId ?? undefined,
|
|
11618
|
-
sourceTaskId: updated.sourceTaskId ?? undefined
|
|
11619
|
-
});
|
|
11620
|
-
await createApprovalFollowUpTask2(updated, "hitl.follow_up");
|
|
11621
|
-
respondRoute.respond(res, 200, {
|
|
11622
|
-
approvalRequest: await toApprovalRequestResponse(updated, { withConfigState: true })
|
|
11623
|
-
});
|
|
11624
|
-
return true;
|
|
11625
|
-
}
|
|
11626
|
-
if (cancelRoute.match(req.method, pathSegments)) {
|
|
11627
|
-
const parsed = await cancelRoute.parse(req, res, pathSegments, queryParams);
|
|
11628
|
-
if (!parsed)
|
|
11629
|
-
return true;
|
|
11630
|
-
const { principal, resolvedBy } = await approvalCallerPrincipal(req);
|
|
11631
|
-
const result = await cancelApprovalRequest({
|
|
11632
|
-
id: parsed.params.id,
|
|
11633
|
-
reason: parsed.body.reason,
|
|
11634
|
-
principal,
|
|
11635
|
-
resolvedBy
|
|
11636
|
-
});
|
|
11637
|
-
if (!result.ok) {
|
|
11638
|
-
jsonError(res, result.message, result.status);
|
|
11639
|
-
return true;
|
|
11640
|
-
}
|
|
11641
|
-
cancelRoute.respond(res, 200, {
|
|
11642
|
-
approvalRequest: await toApprovalRequestResponse(result.request),
|
|
11643
|
-
alreadyCancelled: result.alreadyCancelled,
|
|
11644
|
-
runCancelled: result.runCancelled
|
|
11645
|
-
});
|
|
11646
|
-
return true;
|
|
11647
|
-
}
|
|
11648
|
-
if (getByIdRoute.match(req.method, pathSegments)) {
|
|
11649
|
-
const parsed = await getByIdRoute.parse(req, res, pathSegments, queryParams);
|
|
11650
|
-
if (!parsed)
|
|
11651
|
-
return true;
|
|
11652
|
-
const request = await getApprovalRequestById2(parsed.params.id);
|
|
11653
|
-
if (!request) {
|
|
11654
|
-
jsonError(res, "Approval request not found", 404);
|
|
11655
|
-
return true;
|
|
11656
|
-
}
|
|
11657
|
-
getByIdRoute.respond(res, 200, {
|
|
11658
|
-
approvalRequest: await toApprovalRequestResponse(request, { withConfigState: true })
|
|
11659
|
-
});
|
|
11660
|
-
return true;
|
|
11661
|
-
}
|
|
11662
|
-
if (createRoute.match(req.method, pathSegments)) {
|
|
11663
|
-
const parsed = await createRoute.parse(req, res, pathSegments, queryParams);
|
|
11664
|
-
if (!parsed)
|
|
11665
|
-
return true;
|
|
11666
|
-
if (parsed.body.notifications?.some((notification) => notification.channel === "slack")) {
|
|
11667
|
-
const { principal } = await approvalCallerPrincipal(req);
|
|
11668
|
-
const decision = can({ principal, verb: "integration.slack.post", source: "http" });
|
|
11669
|
-
if (!decision.allow) {
|
|
11670
|
-
jsonError(res, SLACK_NOTIFICATION_REFUSED, 403);
|
|
11671
|
-
return true;
|
|
11672
|
-
}
|
|
11673
|
-
}
|
|
11674
|
-
const normalized = await normalizeApprovalQuestions(parsed.body.questions, {
|
|
11675
|
-
approvers: parsed.body.approvers
|
|
11676
|
-
});
|
|
11677
|
-
if (!normalized.ok) {
|
|
11678
|
-
jsonError(res, normalized.error, 400);
|
|
11679
|
-
return true;
|
|
11680
|
-
}
|
|
11681
|
-
const questions = normalized.questions;
|
|
11682
|
-
const id = crypto.randomUUID();
|
|
11683
|
-
const rawCallerAgentId = req.headers["x-agent-id"];
|
|
11684
|
-
const callerAgentId = Array.isArray(rawCallerAgentId) ? rawCallerAgentId[0] : rawCallerAgentId;
|
|
11685
|
-
const createdBy = authUserId(getRequestAuth(req)) ?? await resolveTaskAuditUserId(parsed.body.sourceTaskId, callerAgentId) ?? undefined;
|
|
11686
|
-
const request = await createApprovalRequest2({
|
|
11687
|
-
id,
|
|
11688
|
-
title: parsed.body.title,
|
|
11689
|
-
questions,
|
|
11690
|
-
approvers: parsed.body.approvers,
|
|
11691
|
-
workflowRunId: parsed.body.workflowRunId,
|
|
11692
|
-
workflowRunStepId: parsed.body.workflowRunStepId,
|
|
11693
|
-
sourceTaskId: parsed.body.sourceTaskId,
|
|
11694
|
-
timeoutSeconds: parsed.body.timeoutSeconds,
|
|
11695
|
-
notificationChannels: parsed.body.notifications,
|
|
11696
|
-
createdBy
|
|
11697
|
-
});
|
|
11698
|
-
const notifications = parsed.body.notifications;
|
|
11699
|
-
if (notifications?.length && request.status === "pending") {
|
|
11700
|
-
dispatchApprovalNotifications2({
|
|
11701
|
-
requestId: request.id,
|
|
11702
|
-
title: request.title,
|
|
11703
|
-
questions,
|
|
11704
|
-
timeoutSeconds: parsed.body.timeoutSeconds,
|
|
11705
|
-
notifications
|
|
11706
|
-
}).catch((err) => {
|
|
11707
|
-
console.error("[approval-requests] Unexpected error dispatching notifications:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
11708
|
-
});
|
|
11709
|
-
}
|
|
11710
|
-
createRoute.respond(res, 201, {
|
|
11711
|
-
approvalRequest: await toApprovalRequestResponse(request)
|
|
11712
|
-
});
|
|
11713
|
-
return true;
|
|
11714
|
-
}
|
|
11715
|
-
if (listRoute.match(req.method, pathSegments)) {
|
|
11716
|
-
const parsed = await listRoute.parse(req, res, pathSegments, queryParams);
|
|
11717
|
-
if (!parsed)
|
|
11718
|
-
return true;
|
|
11719
|
-
const filters = {
|
|
11720
|
-
status: parsed.query.status || undefined,
|
|
11721
|
-
workflowRunId: parsed.query.workflowRunId || undefined,
|
|
11722
|
-
limit: parsed.query.limit || undefined
|
|
11723
|
-
};
|
|
11724
|
-
if (parsed.query.fields === "slim") {
|
|
11725
|
-
const viewer = await approvalResponder(req);
|
|
11726
|
-
listRoute.respond(res, 200, {
|
|
11727
|
-
approvalRequests: await withApprovalProgress(await listApprovalRequestSummaries2(filters), viewer.ok ? viewer.responder : null)
|
|
11728
|
-
});
|
|
11729
|
-
return true;
|
|
11730
|
-
}
|
|
11731
|
-
const requests = await listApprovalRequests2(filters);
|
|
11732
|
-
listRoute.respond(res, 200, {
|
|
11733
|
-
approvalRequests: await Promise.all(requests.map((request) => toApprovalRequestResponse(request)))
|
|
11734
|
-
});
|
|
11735
|
-
return true;
|
|
11736
|
-
}
|
|
11737
|
-
return false;
|
|
11738
|
-
}
|
|
11739
|
-
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.";
|
|
11740
|
-
async function approvalCallerPrincipal(req) {
|
|
11741
|
-
const rawAgentId = req.headers["x-agent-id"];
|
|
11742
|
-
const headerAgentId = Array.isArray(rawAgentId) ? rawAgentId[0] : rawAgentId;
|
|
11743
|
-
const principal = await agentFirstPrincipal(req, headerAgentId);
|
|
11744
|
-
const resolvedBy = principal.kind === "user" ? principal.userId : principal.kind === "agent" ? principal.agentId : principal.kind === "operator" ? "operator" : null;
|
|
11745
|
-
return { principal, resolvedBy };
|
|
11746
|
-
}
|
|
11747
|
-
function userMatchesListed(user, listed) {
|
|
11748
|
-
if (listed === user.id)
|
|
11749
|
-
return true;
|
|
11750
|
-
return !!user.email && listed.toLowerCase() === user.email.toLowerCase();
|
|
11751
|
-
}
|
|
11752
|
-
function isListedApprover(approvers, responder) {
|
|
11753
|
-
const users = approvers.users ?? [];
|
|
11754
|
-
const roles = approvers.roles ?? [];
|
|
11755
|
-
if (users.length === 0 && roles.length === 0)
|
|
11756
|
-
return true;
|
|
11757
|
-
if (responder.kind === "operator")
|
|
11758
|
-
return true;
|
|
11759
|
-
const { user } = responder;
|
|
11760
|
-
if (users.some((listed) => userMatchesListed(user, listed)))
|
|
11761
|
-
return true;
|
|
11762
|
-
return !!user.role && roles.includes(user.role);
|
|
11763
|
-
}
|
|
11764
|
-
async function approvalProgress(approvers, votes) {
|
|
11765
|
-
const approving = votes.filter((v) => v.approved);
|
|
11766
|
-
const distinct = new Set(approving.map((v) => v.responder)).size;
|
|
11767
|
-
const policy = approvers.policy;
|
|
11768
|
-
if (policy === "any")
|
|
11769
|
-
return { approved: Math.min(distinct, 1), required: 1 };
|
|
11770
|
-
if (policy === "all") {
|
|
11771
|
-
const listed = approvers.users ?? [];
|
|
11772
|
-
if (listed.length === 0)
|
|
11773
|
-
return { approved: Math.min(distinct, 1), required: 1 };
|
|
11774
|
-
const approvingUsers = [];
|
|
11775
|
-
for (const vote of approving) {
|
|
11776
|
-
if (vote.responder === "operator")
|
|
11777
|
-
continue;
|
|
11778
|
-
const user = await findUserById(vote.responder);
|
|
11779
|
-
approvingUsers.push(user ?? { id: vote.responder });
|
|
11780
|
-
}
|
|
11781
|
-
const approved = listed.filter((entry) => approvingUsers.some((u) => userMatchesListed(u, entry))).length;
|
|
11782
|
-
return { approved, required: listed.length };
|
|
11783
|
-
}
|
|
11784
|
-
return { approved: Math.min(distinct, policy.min), required: policy.min };
|
|
11785
|
-
}
|
|
11786
|
-
async function approvalQuorumMet(approvers, votes) {
|
|
11787
|
-
const { approved, required } = await approvalProgress(approvers, votes);
|
|
11788
|
-
return approved >= required;
|
|
11789
|
-
}
|
|
11790
|
-
|
|
11791
10153
|
// src/http/index.ts
|
|
10154
|
+
init_approval_requests();
|
|
11792
10155
|
init_apps();
|
|
11793
10156
|
|
|
11794
10157
|
// src/http/assets.ts
|
|
@@ -12308,7 +10671,7 @@ init_constants3();
|
|
|
12308
10671
|
init_env_flag();
|
|
12309
10672
|
init_secret_scrubber();
|
|
12310
10673
|
init_adapters();
|
|
12311
|
-
|
|
10674
|
+
init_config2();
|
|
12312
10675
|
|
|
12313
10676
|
// src/integrations/chat-sdk/discord-api.ts
|
|
12314
10677
|
init_secret_scrubber();
|
|
@@ -12898,6 +11261,7 @@ init_auth_json();
|
|
|
12898
11261
|
init_flow();
|
|
12899
11262
|
init_storage();
|
|
12900
11263
|
init_codex_auth_failure();
|
|
11264
|
+
init_config();
|
|
12901
11265
|
init_route_def();
|
|
12902
11266
|
init_utils2();
|
|
12903
11267
|
var CodexAccountSchema = object2({
|
|
@@ -13797,6 +12161,7 @@ async function exchangeDeviceAuthorizationCode(authorizationCode, codeVerifier)
|
|
|
13797
12161
|
// src/http/codex-oauth-device.ts
|
|
13798
12162
|
init_storage();
|
|
13799
12163
|
init_secret_scrubber();
|
|
12164
|
+
init_config();
|
|
13800
12165
|
init_route_def();
|
|
13801
12166
|
init_utils2();
|
|
13802
12167
|
var FLOW_TTL_MS = 15 * 60 * 1000;
|
|
@@ -14172,7 +12537,7 @@ async function handleCodexOAuthKeepWarm(req, res, pathSegments) {
|
|
|
14172
12537
|
// src/http/comb.ts
|
|
14173
12538
|
init_zod();
|
|
14174
12539
|
init_audit_user();
|
|
14175
|
-
|
|
12540
|
+
init_config4();
|
|
14176
12541
|
|
|
14177
12542
|
// src/comb/review-batch.ts
|
|
14178
12543
|
init_db4();
|
|
@@ -14212,7 +12577,7 @@ async function getCombServiceUserId() {
|
|
|
14212
12577
|
}
|
|
14213
12578
|
|
|
14214
12579
|
// src/comb/review-batch.ts
|
|
14215
|
-
|
|
12580
|
+
init_config4();
|
|
14216
12581
|
|
|
14217
12582
|
// src/comb/markers.ts
|
|
14218
12583
|
var SENT_MARKER_PREFIX = "[comb:sent task=";
|
|
@@ -14690,6 +13055,9 @@ async function handleComb(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
14690
13055
|
return true;
|
|
14691
13056
|
}
|
|
14692
13057
|
|
|
13058
|
+
// src/http/index.ts
|
|
13059
|
+
init_config();
|
|
13060
|
+
|
|
14693
13061
|
// src/http/context.ts
|
|
14694
13062
|
init_zod();
|
|
14695
13063
|
init_db4();
|
|
@@ -14807,6 +13175,95 @@ async function handleContext(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
14807
13175
|
init_core();
|
|
14808
13176
|
init_db_query();
|
|
14809
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
|
+
|
|
14810
13267
|
// src/http/events.ts
|
|
14811
13268
|
init_zod();
|
|
14812
13269
|
init_events();
|
|
@@ -18308,7 +16765,7 @@ var catalogRoute = route({
|
|
|
18308
16765
|
}
|
|
18309
16766
|
}
|
|
18310
16767
|
});
|
|
18311
|
-
var
|
|
16768
|
+
var listRoute = route({
|
|
18312
16769
|
method: "get",
|
|
18313
16770
|
path: "/api/extensions",
|
|
18314
16771
|
pattern: ["api", "extensions"],
|
|
@@ -18629,11 +17086,11 @@ async function handleExtensions(req, res, pathSegments, queryParams, agentId) {
|
|
|
18629
17086
|
});
|
|
18630
17087
|
return true;
|
|
18631
17088
|
}
|
|
18632
|
-
if (
|
|
18633
|
-
const parsed = await
|
|
17089
|
+
if (listRoute.match(req.method, pathSegments)) {
|
|
17090
|
+
const parsed = await listRoute.parse(req, res, pathSegments, queryParams);
|
|
18634
17091
|
if (!parsed)
|
|
18635
17092
|
return true;
|
|
18636
|
-
|
|
17093
|
+
listRoute.respond(res, 200, { extensions: (await listExtensions()).map(redactExtension) });
|
|
18637
17094
|
return true;
|
|
18638
17095
|
}
|
|
18639
17096
|
if (catalogRoute.match(req.method, pathSegments)) {
|
|
@@ -19068,12 +17525,14 @@ async function getLocalFleetStats(now = new Date, { requireIngestAnchor = true }
|
|
|
19068
17525
|
init_telemetry();
|
|
19069
17526
|
init_company_profile();
|
|
19070
17527
|
init_org_website();
|
|
17528
|
+
init_global_config();
|
|
19071
17529
|
init_request_principal();
|
|
19072
17530
|
init_route_def();
|
|
17531
|
+
init_used_by();
|
|
19073
17532
|
var FLEET_TTL_MS = 24 * 60 * 60 * 1000;
|
|
19074
17533
|
var FLEET_FAILURE_TTL_MS = 60 * 60 * 1000;
|
|
19075
17534
|
var LOCAL_TTL_MS = 10 * 60 * 1000;
|
|
19076
|
-
var
|
|
17535
|
+
var TIMEOUT_MS = 1e4;
|
|
19077
17536
|
var FleetStateSchema = _enum2([
|
|
19078
17537
|
"ready",
|
|
19079
17538
|
"telemetry_off",
|
|
@@ -19167,7 +17626,7 @@ async function fleetBenchmarks(now, peerGroup) {
|
|
|
19167
17626
|
return fleetCache.value;
|
|
19168
17627
|
let value = null;
|
|
19169
17628
|
try {
|
|
19170
|
-
const response = await fetch(key, { signal: AbortSignal.timeout(
|
|
17629
|
+
const response = await fetch(key, { signal: AbortSignal.timeout(TIMEOUT_MS) });
|
|
19171
17630
|
if (response.ok) {
|
|
19172
17631
|
const parsed = ProxyFleetBenchmarksSchema.safeParse(await response.json());
|
|
19173
17632
|
if (parsed.success)
|
|
@@ -19407,7 +17866,7 @@ init_rbac_roles();
|
|
|
19407
17866
|
init_agent_fs_provision();
|
|
19408
17867
|
init_task_attachment_store();
|
|
19409
17868
|
init_users();
|
|
19410
|
-
|
|
17869
|
+
init_config4();
|
|
19411
17870
|
init_provider();
|
|
19412
17871
|
init_registry2();
|
|
19413
17872
|
init_rbac();
|
|
@@ -20037,7 +18496,7 @@ async function sendUpload(req, res, taskId, query, agentId, isDraft) {
|
|
|
20037
18496
|
return true;
|
|
20038
18497
|
}
|
|
20039
18498
|
const provider = getFileStorageProvider2();
|
|
20040
|
-
const contentType =
|
|
18499
|
+
const contentType = singleHeader(req, "content-type") ?? "application/octet-stream";
|
|
20041
18500
|
const scope = { taskId, name: query.name };
|
|
20042
18501
|
let uploaded;
|
|
20043
18502
|
const uploadStartedAt = performance.now();
|
|
@@ -20190,7 +18649,7 @@ async function readRawBody(req, maxBytes) {
|
|
|
20190
18649
|
}
|
|
20191
18650
|
return Buffer.concat(chunks);
|
|
20192
18651
|
}
|
|
20193
|
-
function
|
|
18652
|
+
function singleHeader(req, name) {
|
|
20194
18653
|
const raw = req.headers[name];
|
|
20195
18654
|
return Array.isArray(raw) ? raw[0] : raw;
|
|
20196
18655
|
}
|
|
@@ -20340,8 +18799,10 @@ async function handleHeartbeat(req, res, pathSegments) {
|
|
|
20340
18799
|
init_zod();
|
|
20341
18800
|
init_improvements();
|
|
20342
18801
|
init_rbac();
|
|
18802
|
+
init_person_responder();
|
|
20343
18803
|
init_request_principal();
|
|
20344
18804
|
init_route_def();
|
|
18805
|
+
init_used_by();
|
|
20345
18806
|
init_utils2();
|
|
20346
18807
|
var ImprovementSchema = object2({
|
|
20347
18808
|
id: string2(),
|
|
@@ -20362,7 +18823,7 @@ var ImprovementSchema = object2({
|
|
|
20362
18823
|
});
|
|
20363
18824
|
var EmailSchema = string2().max(320, "Email must be at most 320 characters").email("Email must be a valid email address");
|
|
20364
18825
|
var PERSON_REFUSED = "Agents cannot approve improvements. A person must approve with a user token or the dashboard.";
|
|
20365
|
-
var
|
|
18826
|
+
var listRoute2 = route({
|
|
20366
18827
|
method: "get",
|
|
20367
18828
|
path: "/api/improvements",
|
|
20368
18829
|
pattern: ["api", "improvements"],
|
|
@@ -20377,7 +18838,7 @@ var listRoute3 = route({
|
|
|
20377
18838
|
},
|
|
20378
18839
|
auth: { apiKey: true }
|
|
20379
18840
|
});
|
|
20380
|
-
var
|
|
18841
|
+
var createRoute = route({
|
|
20381
18842
|
method: "post",
|
|
20382
18843
|
path: "/api/improvements",
|
|
20383
18844
|
pattern: ["api", "improvements"],
|
|
@@ -20474,19 +18935,19 @@ async function improvementsEndpoint() {
|
|
|
20474
18935
|
return telemetryProxyEndpoint("/v1/improvements");
|
|
20475
18936
|
}
|
|
20476
18937
|
async function handleImprovements(req, res, pathSegments, queryParams) {
|
|
20477
|
-
if (
|
|
20478
|
-
const parsed = await
|
|
18938
|
+
if (listRoute2.match(req.method, pathSegments)) {
|
|
18939
|
+
const parsed = await listRoute2.parse(req, res, pathSegments, queryParams);
|
|
20479
18940
|
if (!parsed)
|
|
20480
18941
|
return true;
|
|
20481
18942
|
const rows = await listImprovements();
|
|
20482
|
-
|
|
18943
|
+
listRoute2.respond(res, 200, {
|
|
20483
18944
|
enabled: await isImprovementsEnabled(),
|
|
20484
18945
|
improvements: await Promise.all(rows.map(withLeakHints))
|
|
20485
18946
|
});
|
|
20486
18947
|
return true;
|
|
20487
18948
|
}
|
|
20488
|
-
if (
|
|
20489
|
-
const parsed = await
|
|
18949
|
+
if (createRoute.match(req.method, pathSegments)) {
|
|
18950
|
+
const parsed = await createRoute.parse(req, res, pathSegments, queryParams);
|
|
20490
18951
|
if (!parsed)
|
|
20491
18952
|
return true;
|
|
20492
18953
|
const { text, email, sendNow, source } = parsed.body;
|
|
@@ -20521,11 +18982,11 @@ async function handleImprovements(req, res, pathSegments, queryParams) {
|
|
|
20521
18982
|
endpoint: await improvementsEndpoint(),
|
|
20522
18983
|
updatedBy: person.responder.kind === "user" ? person.responder.user.id : null
|
|
20523
18984
|
});
|
|
20524
|
-
|
|
18985
|
+
createRoute.respond(res, 200, { improvement: sent });
|
|
20525
18986
|
return true;
|
|
20526
18987
|
}
|
|
20527
18988
|
}
|
|
20528
|
-
|
|
18989
|
+
createRoute.respond(res, 201, { improvement: await withLeakHints(improvement) });
|
|
20529
18990
|
} catch (error) {
|
|
20530
18991
|
if (!writeImprovementError(res, error))
|
|
20531
18992
|
throw error;
|
|
@@ -20922,6 +19383,7 @@ function buildSlackManifest(name) {
|
|
|
20922
19383
|
|
|
20923
19384
|
// src/http/integrations.ts
|
|
20924
19385
|
init_credentials2();
|
|
19386
|
+
init_config();
|
|
20925
19387
|
|
|
20926
19388
|
// src/http/config-values.ts
|
|
20927
19389
|
init_db4();
|
|
@@ -21322,14 +19784,14 @@ function decodeKvSegment(res, raw, label) {
|
|
|
21322
19784
|
}
|
|
21323
19785
|
return decoded;
|
|
21324
19786
|
}
|
|
21325
|
-
function
|
|
19787
|
+
function singleHeader2(req, name) {
|
|
21326
19788
|
const raw = req.headers[name];
|
|
21327
19789
|
if (raw === undefined)
|
|
21328
19790
|
return;
|
|
21329
19791
|
return Array.isArray(raw) ? raw[0] : raw;
|
|
21330
19792
|
}
|
|
21331
19793
|
async function resolveNamespaceFromHeaders(req) {
|
|
21332
|
-
const pageId =
|
|
19794
|
+
const pageId = singleHeader2(req, "x-page-id");
|
|
21333
19795
|
if (pageId) {
|
|
21334
19796
|
try {
|
|
21335
19797
|
return pageContextKey({ pageId });
|
|
@@ -21337,7 +19799,7 @@ async function resolveNamespaceFromHeaders(req) {
|
|
|
21337
19799
|
return null;
|
|
21338
19800
|
}
|
|
21339
19801
|
}
|
|
21340
|
-
const sourceTaskId =
|
|
19802
|
+
const sourceTaskId = singleHeader2(req, "x-source-task-id");
|
|
21341
19803
|
if (sourceTaskId) {
|
|
21342
19804
|
const task = await getTaskById2(sourceTaskId);
|
|
21343
19805
|
if (task?.contextKey)
|
|
@@ -21348,7 +19810,7 @@ async function resolveNamespaceFromHeaders(req) {
|
|
|
21348
19810
|
} catch {}
|
|
21349
19811
|
}
|
|
21350
19812
|
}
|
|
21351
|
-
const agentId =
|
|
19813
|
+
const agentId = singleHeader2(req, "x-agent-id");
|
|
21352
19814
|
if (agentId) {
|
|
21353
19815
|
try {
|
|
21354
19816
|
return agentContextKey({ agentId });
|
|
@@ -21359,8 +19821,8 @@ async function resolveNamespaceFromHeaders(req) {
|
|
|
21359
19821
|
return null;
|
|
21360
19822
|
}
|
|
21361
19823
|
async function buildAuthCtx(req) {
|
|
21362
|
-
const callerAgentId =
|
|
21363
|
-
const pageId =
|
|
19824
|
+
const callerAgentId = singleHeader2(req, "x-agent-id");
|
|
19825
|
+
const pageId = singleHeader2(req, "x-page-id");
|
|
21364
19826
|
let isLead = false;
|
|
21365
19827
|
if (callerAgentId) {
|
|
21366
19828
|
const agent = await getAgentById2(callerAgentId);
|
|
@@ -21447,7 +19909,7 @@ function encodeValueOrError(res, value, valueType) {
|
|
|
21447
19909
|
}
|
|
21448
19910
|
}
|
|
21449
19911
|
async function handleKv(req, res, pathSegments, queryParams) {
|
|
21450
|
-
const hasPageHeader =
|
|
19912
|
+
const hasPageHeader = singleHeader2(req, "x-page-id") !== undefined;
|
|
21451
19913
|
if (hasPageHeader && pathSegments[0] === "api" && pathSegments[1] === "kv" && pathSegments[2] === "_") {
|
|
21452
19914
|
pathSegments = [pathSegments[0], pathSegments[1], ...pathSegments.slice(4)];
|
|
21453
19915
|
}
|
|
@@ -24311,12 +22773,12 @@ async function canResolveMcpSecretsForHttpUser(req) {
|
|
|
24311
22773
|
});
|
|
24312
22774
|
return decision.allow;
|
|
24313
22775
|
}
|
|
24314
|
-
function
|
|
22776
|
+
function singleHeader3(req, name) {
|
|
24315
22777
|
const raw = req.headers[name];
|
|
24316
22778
|
return Array.isArray(raw) ? raw[0] : raw;
|
|
24317
22779
|
}
|
|
24318
22780
|
async function mcpServerPrincipal(req) {
|
|
24319
|
-
return agentFirstPrincipal(req,
|
|
22781
|
+
return agentFirstPrincipal(req, singleHeader3(req, "x-agent-id"), {
|
|
24320
22782
|
unauthenticatedFallback: "anonymous-agent"
|
|
24321
22783
|
});
|
|
24322
22784
|
}
|
|
@@ -29069,6 +27531,7 @@ init_constants3();
|
|
|
29069
27531
|
init_credentials2();
|
|
29070
27532
|
init_egress_guard();
|
|
29071
27533
|
init_openrouter_base_url();
|
|
27534
|
+
init_config();
|
|
29072
27535
|
init_core();
|
|
29073
27536
|
init_route_def();
|
|
29074
27537
|
|
|
@@ -29095,9 +27558,9 @@ async function getInstanceFeedbackSignals() {
|
|
|
29095
27558
|
|
|
29096
27559
|
// src/http/status.ts
|
|
29097
27560
|
init_memory();
|
|
29098
|
-
init_config3();
|
|
29099
|
-
init_registry2();
|
|
29100
27561
|
init_config4();
|
|
27562
|
+
init_registry2();
|
|
27563
|
+
init_config5();
|
|
29101
27564
|
init_connection_state();
|
|
29102
27565
|
init_telemetry();
|
|
29103
27566
|
init_types5();
|
|
@@ -30227,6 +28690,7 @@ init_page_versions();
|
|
|
30227
28690
|
init_version3();
|
|
30228
28691
|
init_resolver();
|
|
30229
28692
|
init_session_templates();
|
|
28693
|
+
init_rbac();
|
|
30230
28694
|
init_sibling_awareness();
|
|
30231
28695
|
init_page_fields();
|
|
30232
28696
|
init_presets();
|
|
@@ -30235,6 +28699,7 @@ init_constants3();
|
|
|
30235
28699
|
init_page_session();
|
|
30236
28700
|
init_request_auth_context();
|
|
30237
28701
|
init_favorite_owner();
|
|
28702
|
+
init_request_principal();
|
|
30238
28703
|
init_route_def();
|
|
30239
28704
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
30240
28705
|
|
|
@@ -30264,6 +28729,7 @@ init_business_use();
|
|
|
30264
28729
|
init_request_auth_context();
|
|
30265
28730
|
init_secret_scrubber();
|
|
30266
28731
|
init_vcs_repo_match();
|
|
28732
|
+
init_config();
|
|
30267
28733
|
|
|
30268
28734
|
// src/http/list-total-cache.ts
|
|
30269
28735
|
var LIST_TOTAL_TTL_MS = 30000;
|
|
@@ -32320,9 +30786,11 @@ var launchPageRoute = route({
|
|
|
32320
30786
|
summary: "Launch a page session (issues HttpOnly cookie)",
|
|
32321
30787
|
tags: ["Pages"],
|
|
32322
30788
|
params: object2({ id: string2() }),
|
|
30789
|
+
rbac: { permission: "page.launch" },
|
|
32323
30790
|
responses: {
|
|
32324
30791
|
204: { description: "Cookie issued" },
|
|
32325
30792
|
400: { description: "Launch not supported for this page (e.g. password mode)" },
|
|
30793
|
+
403: { description: "Caller may not open pages" },
|
|
32326
30794
|
404: { description: "Page not found" }
|
|
32327
30795
|
}
|
|
32328
30796
|
});
|
|
@@ -32917,6 +31385,15 @@ ${defuseFeedbackTags(note)}
|
|
|
32917
31385
|
const parsed = await launchPageRoute.parse(req, res, pathSegments, queryParams);
|
|
32918
31386
|
if (!parsed)
|
|
32919
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
|
+
}
|
|
32920
31397
|
const page = await getPage2(parsed.params.id);
|
|
32921
31398
|
if (!page) {
|
|
32922
31399
|
applyLaunchCors(req, res);
|
|
@@ -32948,6 +31425,7 @@ ${defuseFeedbackTags(note)}
|
|
|
32948
31425
|
// src/http/pages-public.ts
|
|
32949
31426
|
init_zod();
|
|
32950
31427
|
init_db4();
|
|
31428
|
+
init_design_system2();
|
|
32951
31429
|
|
|
32952
31430
|
// src/pages/browser-sdk.ts
|
|
32953
31431
|
var BROWSER_SDK_JS = `
|
|
@@ -34367,21 +32845,22 @@ function contractValues(vars) {
|
|
|
34367
32845
|
function resolvePageTheme({
|
|
34368
32846
|
pageTheme,
|
|
34369
32847
|
viewerTheme,
|
|
34370
|
-
overrides
|
|
32848
|
+
overrides,
|
|
32849
|
+
designSystem
|
|
34371
32850
|
}) {
|
|
34372
|
-
const preset = getThemePreset(pageTheme) ?? getThemePreset(viewerTheme) ?? getThemePreset(DEFAULT_THEME_ID);
|
|
34373
|
-
const
|
|
34374
|
-
const
|
|
34375
|
-
const
|
|
34376
|
-
|
|
34377
|
-
|
|
34378
|
-
|
|
34379
|
-
|
|
34380
|
-
|
|
34381
|
-
|
|
34382
|
-
|
|
34383
|
-
|
|
34384
|
-
|
|
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
|
+
}
|
|
34385
32864
|
}
|
|
34386
32865
|
return { presetId: preset?.id ?? DEFAULT_THEME_ID, light, dark };
|
|
34387
32866
|
}
|
|
@@ -34482,6 +32961,12 @@ var IN_PAGE_LINK_SCRIPT = `<script>document.addEventListener("click", function (
|
|
|
34482
32961
|
var FONT_LINKS = `<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
34483
32962
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
34484
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
|
+
}
|
|
34485
32970
|
var TAILWIND_SOURCE = [
|
|
34486
32971
|
'@import "tailwindcss/theme" layer(theme);',
|
|
34487
32972
|
'@import "tailwindcss/utilities" layer(utilities);',
|
|
@@ -35058,13 +33543,14 @@ ${TONE_RULES}
|
|
|
35058
33543
|
}`;
|
|
35059
33544
|
function buildPageHeadV2({
|
|
35060
33545
|
theme,
|
|
35061
|
-
mode
|
|
33546
|
+
mode,
|
|
33547
|
+
fontsHref
|
|
35062
33548
|
}) {
|
|
35063
33549
|
return [
|
|
35064
33550
|
'<base target="_blank">',
|
|
35065
33551
|
IN_PAGE_LINK_SCRIPT,
|
|
35066
33552
|
"<style>@layer properties, theme, base, components, utilities;</style>",
|
|
35067
|
-
FONT_LINKS,
|
|
33553
|
+
fontsHref ? fontLinks(fontsHref) : FONT_LINKS,
|
|
35068
33554
|
`<style id="swarm-theme">
|
|
35069
33555
|
${renderPageThemeCss(theme)}
|
|
35070
33556
|
</style>`,
|
|
@@ -35079,6 +33565,7 @@ ${PAGE_DESIGN_CSS}
|
|
|
35079
33565
|
}
|
|
35080
33566
|
|
|
35081
33567
|
// src/http/pages-public.ts
|
|
33568
|
+
init_presets();
|
|
35082
33569
|
init_types5();
|
|
35083
33570
|
init_constants3();
|
|
35084
33571
|
init_page_session();
|
|
@@ -35128,16 +33615,24 @@ var publicPageJsonRoute = route({
|
|
|
35128
33615
|
},
|
|
35129
33616
|
auth: { apiKey: false }
|
|
35130
33617
|
});
|
|
35131
|
-
function pageHead(page, queryParams, wantsPrint) {
|
|
33618
|
+
async function pageHead(page, queryParams, wantsPrint) {
|
|
35132
33619
|
if (page.designVersion === 1)
|
|
35133
33620
|
return PAGE_HEAD_V1;
|
|
33621
|
+
const designSystem = getThemePreset(page.theme) ? null : await getActiveDesignSystem();
|
|
35134
33622
|
const theme = resolvePageTheme({
|
|
35135
33623
|
pageTheme: page.theme,
|
|
35136
33624
|
viewerTheme: queryParams.get(PAGE_THEME_PARAM),
|
|
35137
|
-
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
|
|
35138
33635
|
});
|
|
35139
|
-
const dark = !wantsPrint && queryParams.get(PAGE_MODE_PARAM) === "dark" && countColorLiterals(page.body) < COLOR_LITERAL_THRESHOLD;
|
|
35140
|
-
return buildPageHeadV2({ theme, mode: dark ? "dark" : "light" });
|
|
35141
33636
|
}
|
|
35142
33637
|
var LEADING_DOCTYPE_RE = /^\s*<!doctype\b[^>]*>/i;
|
|
35143
33638
|
var LEADING_HTML_TAG_RE = /^\s*<!doctype\b[^>]*>\s*<html\b[^>]*>/i;
|
|
@@ -35486,7 +33981,7 @@ async function handlePagesPublic(req, res, pathSegments, queryParams) {
|
|
|
35486
33981
|
}
|
|
35487
33982
|
const feedback = isPageFeedbackRequested(queryParams);
|
|
35488
33983
|
const html = injectBrowserSdk(page.body, {
|
|
35489
|
-
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)}">`,
|
|
35490
33985
|
headFirst: feedback ? feedbackKeyGuardScript() : "",
|
|
35491
33986
|
standardsMode: page.designVersion !== 1
|
|
35492
33987
|
}) + (wantsPrint ? PRINT_AUTOTRIGGER_SCRIPT : "") + (feedback ? feedbackOverlayScripts(page.id) : "");
|
|
@@ -35636,6 +34131,7 @@ init_multi_runtime2();
|
|
|
35636
34131
|
init_request_auth_context();
|
|
35637
34132
|
init_runtime_pools_flag();
|
|
35638
34133
|
init_secret_scrubber();
|
|
34134
|
+
init_config();
|
|
35639
34135
|
init_route_def();
|
|
35640
34136
|
init_utils2();
|
|
35641
34137
|
function buildBudgetRefusedTrigger(refusal) {
|
|
@@ -36179,6 +34675,7 @@ init_multi_runtime();
|
|
|
36179
34675
|
init_swarm_config_guard();
|
|
36180
34676
|
init_credentials2();
|
|
36181
34677
|
init_secret_scrubber();
|
|
34678
|
+
init_config();
|
|
36182
34679
|
init_core();
|
|
36183
34680
|
init_route_def();
|
|
36184
34681
|
init_utils2();
|
|
@@ -36805,7 +35302,7 @@ var resetRoute = route({
|
|
|
36805
35302
|
},
|
|
36806
35303
|
auth: { apiKey: true }
|
|
36807
35304
|
});
|
|
36808
|
-
var
|
|
35305
|
+
var getByIdRoute = route({
|
|
36809
35306
|
method: "get",
|
|
36810
35307
|
path: "/api/prompt-templates/{id}",
|
|
36811
35308
|
pattern: ["api", "prompt-templates", null],
|
|
@@ -36841,7 +35338,7 @@ var deleteByIdRoute = route({
|
|
|
36841
35338
|
},
|
|
36842
35339
|
auth: { apiKey: true }
|
|
36843
35340
|
});
|
|
36844
|
-
var
|
|
35341
|
+
var listRoute3 = route({
|
|
36845
35342
|
method: "get",
|
|
36846
35343
|
path: "/api/prompt-templates",
|
|
36847
35344
|
pattern: ["api", "prompt-templates"],
|
|
@@ -36991,8 +35488,8 @@ ${templateBody}` : templateBody;
|
|
|
36991
35488
|
}
|
|
36992
35489
|
return true;
|
|
36993
35490
|
}
|
|
36994
|
-
if (
|
|
36995
|
-
const parsed = await
|
|
35491
|
+
if (getByIdRoute.match(req.method, pathSegments)) {
|
|
35492
|
+
const parsed = await getByIdRoute.parse(req, res, pathSegments, queryParams);
|
|
36996
35493
|
if (!parsed)
|
|
36997
35494
|
return true;
|
|
36998
35495
|
const template = await getPromptTemplateById2(parsed.params.id);
|
|
@@ -37001,7 +35498,7 @@ ${templateBody}` : templateBody;
|
|
|
37001
35498
|
return true;
|
|
37002
35499
|
}
|
|
37003
35500
|
const history = await getPromptTemplateHistory2(parsed.params.id);
|
|
37004
|
-
|
|
35501
|
+
getByIdRoute.respond(res, 200, { template: toPromptTemplateResponse(template), history });
|
|
37005
35502
|
return true;
|
|
37006
35503
|
}
|
|
37007
35504
|
if (deleteByIdRoute.match(req.method, pathSegments)) {
|
|
@@ -37021,8 +35518,8 @@ ${templateBody}` : templateBody;
|
|
|
37021
35518
|
}
|
|
37022
35519
|
return true;
|
|
37023
35520
|
}
|
|
37024
|
-
if (
|
|
37025
|
-
const parsed = await
|
|
35521
|
+
if (listRoute3.match(req.method, pathSegments)) {
|
|
35522
|
+
const parsed = await listRoute3.parse(req, res, pathSegments, queryParams);
|
|
37026
35523
|
if (!parsed)
|
|
37027
35524
|
return true;
|
|
37028
35525
|
const templates = getPromptTemplates2({
|
|
@@ -37031,7 +35528,7 @@ ${templateBody}` : templateBody;
|
|
|
37031
35528
|
scopeId: parsed.query.scopeId || undefined,
|
|
37032
35529
|
isDefault: parsed.query.isDefault ? parsed.query.isDefault === "true" : undefined
|
|
37033
35530
|
});
|
|
37034
|
-
|
|
35531
|
+
listRoute3.respond(res, 200, { templates: templates.map(toPromptTemplateResponse) });
|
|
37035
35532
|
return true;
|
|
37036
35533
|
}
|
|
37037
35534
|
if (upsertRoute.match(req.method, pathSegments)) {
|
|
@@ -37076,6 +35573,9 @@ ${templateBody}` : templateBody;
|
|
|
37076
35573
|
return false;
|
|
37077
35574
|
}
|
|
37078
35575
|
|
|
35576
|
+
// src/http/index.ts
|
|
35577
|
+
init_ranking();
|
|
35578
|
+
|
|
37079
35579
|
// src/http/realtime.ts
|
|
37080
35580
|
init_zod();
|
|
37081
35581
|
init_users();
|
|
@@ -40663,6 +39163,7 @@ async function calibrate(sql, opts) {
|
|
|
40663
39163
|
}
|
|
40664
39164
|
|
|
40665
39165
|
// src/http/savings-calibration.ts
|
|
39166
|
+
init_config();
|
|
40666
39167
|
init_db_query_shared();
|
|
40667
39168
|
init_route_def();
|
|
40668
39169
|
init_utils2();
|
|
@@ -41709,6 +40210,7 @@ init_telemetry();
|
|
|
41709
40210
|
init_egress_guard();
|
|
41710
40211
|
init_scoped_resource();
|
|
41711
40212
|
init_secret_scrubber();
|
|
40213
|
+
init_config();
|
|
41712
40214
|
init_route_def();
|
|
41713
40215
|
init_utils2();
|
|
41714
40216
|
var providerSchema = string2().min(1).max(255).regex(/^[A-Za-z0-9_-]+$/);
|
|
@@ -48014,7 +46516,7 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
48014
46516
|
|
|
48015
46517
|
// src/http/slack-events.ts
|
|
48016
46518
|
init_app4();
|
|
48017
|
-
|
|
46519
|
+
init_config5();
|
|
48018
46520
|
init_route_def();
|
|
48019
46521
|
init_utils2();
|
|
48020
46522
|
var slackEventsRoute = route({
|
|
@@ -48546,6 +47048,7 @@ function validateUiEvent(event, properties) {
|
|
|
48546
47048
|
}
|
|
48547
47049
|
|
|
48548
47050
|
// src/http/telemetry-ui.ts
|
|
47051
|
+
init_config();
|
|
48549
47052
|
init_core();
|
|
48550
47053
|
init_favorite_owner();
|
|
48551
47054
|
init_request_principal();
|
|
@@ -48771,6 +47274,7 @@ init_utils2();
|
|
|
48771
47274
|
// src/http/trackers/authorize-gate.ts
|
|
48772
47275
|
init_zod();
|
|
48773
47276
|
init_audit_user();
|
|
47277
|
+
init_config();
|
|
48774
47278
|
var TrackerAuthorizeQuerySchema = object2({
|
|
48775
47279
|
redirect: string2().optional(),
|
|
48776
47280
|
format: _enum2(["redirect", "json"]).optional()
|
|
@@ -49499,6 +48003,9 @@ async function handleTrackers(req, res, pathSegments) {
|
|
|
49499
48003
|
return await handleLinearTracker(req, res, pathSegments);
|
|
49500
48004
|
}
|
|
49501
48005
|
|
|
48006
|
+
// src/http/index.ts
|
|
48007
|
+
init_used_by();
|
|
48008
|
+
|
|
49502
48009
|
// src/http/user-roles.ts
|
|
49503
48010
|
init_zod();
|
|
49504
48011
|
init_db4();
|
|
@@ -51188,11 +49695,11 @@ function gitlabWorkflowActionName(action) {
|
|
|
51188
49695
|
|
|
51189
49696
|
// src/http/webhooks.ts
|
|
51190
49697
|
init_background();
|
|
51191
|
-
|
|
49698
|
+
init_config2();
|
|
51192
49699
|
init_runtime();
|
|
51193
49700
|
init_teams_origin();
|
|
51194
49701
|
init_client();
|
|
51195
|
-
|
|
49702
|
+
init_config3();
|
|
51196
49703
|
|
|
51197
49704
|
// src/integrations/kapso/inbound.ts
|
|
51198
49705
|
init_resolver();
|
|
@@ -51201,7 +49708,7 @@ init_event_bus();
|
|
|
51201
49708
|
init_templates3();
|
|
51202
49709
|
init_identity();
|
|
51203
49710
|
init_unmapped_identities();
|
|
51204
|
-
|
|
49711
|
+
init_config3();
|
|
51205
49712
|
var KAPSO_IDENTITY_KIND = "kapso";
|
|
51206
49713
|
var WHATSAPP_IDENTITY_KIND = "whatsapp";
|
|
51207
49714
|
function extractText(message) {
|
|
@@ -52297,6 +50804,7 @@ init_readiness();
|
|
|
52297
50804
|
init_resume();
|
|
52298
50805
|
init_triggers();
|
|
52299
50806
|
init_version();
|
|
50807
|
+
init_config();
|
|
52300
50808
|
init_favorite_owner();
|
|
52301
50809
|
init_idempotency_key();
|
|
52302
50810
|
init_route_def();
|
|
@@ -53672,6 +52180,7 @@ var httpServer = createHttpServer(async (req, res) => {
|
|
|
53672
52180
|
() => handlePagesPublic(req, res, pathSegments, queryParams),
|
|
53673
52181
|
() => handlePageProxy(req, res),
|
|
53674
52182
|
() => handlePages(req, res, pathSegments, queryParams, myAgentId),
|
|
52183
|
+
() => handleDesignSystem(req, res, pathSegments, queryParams, myAgentId),
|
|
53675
52184
|
() => handleApiKeys(req, res, pathSegments, queryParams),
|
|
53676
52185
|
() => handleHeartbeat(req, res, pathSegments),
|
|
53677
52186
|
() => handleEvents(req, res, pathSegments, queryParams, myAgentId),
|
|
@@ -53717,7 +52226,7 @@ var httpServer = createHttpServer(async (req, res) => {
|
|
|
53717
52226
|
});
|
|
53718
52227
|
});
|
|
53719
52228
|
var detachRealtime = attachRealtimeTransport(httpServer);
|
|
53720
|
-
var { attachControllerTransport } = await import("./controllers-connect-
|
|
52229
|
+
var { attachControllerTransport } = await import("./controllers-connect-4wdmncqt.js");
|
|
53721
52230
|
var detachControllers = attachControllerTransport(httpServer);
|
|
53722
52231
|
var stopWorkerNudges = startWorkerNudgeListener();
|
|
53723
52232
|
var taskAutoTitles = startTaskAutoTitleListener();
|
|
@@ -53748,7 +52257,7 @@ async function shutdown() {
|
|
|
53748
52257
|
sessionsProcessed: getServerSessionsProcessed()
|
|
53749
52258
|
});
|
|
53750
52259
|
if (hasCapability("scheduling")) {
|
|
53751
|
-
const { stopScheduler } = await import("./index-
|
|
52260
|
+
const { stopScheduler } = await import("./index-e6bq0exk.js");
|
|
53752
52261
|
stopScheduler();
|
|
53753
52262
|
}
|
|
53754
52263
|
stopHeartbeat2();
|
|
@@ -53760,7 +52269,7 @@ async function shutdown() {
|
|
|
53760
52269
|
await stopSlackApp2();
|
|
53761
52270
|
await stopChatSdk();
|
|
53762
52271
|
if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
|
|
53763
|
-
const { stopOAuthKeepalive } = await import("./keepalive-
|
|
52272
|
+
const { stopOAuthKeepalive } = await import("./keepalive-9px3t7qj.js");
|
|
53764
52273
|
await stopOAuthKeepalive();
|
|
53765
52274
|
}
|
|
53766
52275
|
stopOAuthPendingGc();
|
|
@@ -53850,21 +52359,21 @@ try {
|
|
|
53850
52359
|
console.warn("[startup] CAPABILITIES upgrade seed failed (non-fatal):", err);
|
|
53851
52360
|
}
|
|
53852
52361
|
try {
|
|
53853
|
-
const { ensurePricingSeeded } = await import("./boot-seeds-
|
|
52362
|
+
const { ensurePricingSeeded } = await import("./boot-seeds-m74fc07r.js");
|
|
53854
52363
|
ensurePricingSeeded();
|
|
53855
|
-
const { startPricingRefreshLoop } = await import("./pricing-refresh-
|
|
52364
|
+
const { startPricingRefreshLoop } = await import("./pricing-refresh-1yz8jkqv.js");
|
|
53856
52365
|
startPricingRefreshLoop();
|
|
53857
52366
|
} catch (err) {
|
|
53858
52367
|
console.error("[startup] Failed to seed pricing rows:", err);
|
|
53859
52368
|
}
|
|
53860
52369
|
try {
|
|
53861
|
-
const { ensureModelProfilesSeeded } = await import("./boot-seeds-
|
|
52370
|
+
const { ensureModelProfilesSeeded } = await import("./boot-seeds-m74fc07r.js");
|
|
53862
52371
|
await ensureModelProfilesSeeded();
|
|
53863
52372
|
} catch (err) {
|
|
53864
52373
|
console.error("[startup] Failed to seed model profiles:", err);
|
|
53865
52374
|
}
|
|
53866
52375
|
try {
|
|
53867
|
-
const { ensureRbacSeeded } = await import("./boot-seeds-
|
|
52376
|
+
const { ensureRbacSeeded } = await import("./boot-seeds-m74fc07r.js");
|
|
53868
52377
|
ensureRbacSeeded();
|
|
53869
52378
|
} catch (err) {
|
|
53870
52379
|
console.error("[startup] Failed to sync RBAC seed rows:", err);
|
|
@@ -53872,13 +52381,13 @@ try {
|
|
|
53872
52381
|
throw err;
|
|
53873
52382
|
}
|
|
53874
52383
|
try {
|
|
53875
|
-
const { runAllSeeders } = await import("./index-
|
|
52384
|
+
const { runAllSeeders } = await import("./index-gfnq66t1.js");
|
|
53876
52385
|
await runAllSeeders({ scriptEmbeddingMode: "skip" });
|
|
53877
52386
|
} catch (err) {
|
|
53878
52387
|
console.error("[startup] Failed to seed built-in entities:", err);
|
|
53879
52388
|
}
|
|
53880
52389
|
try {
|
|
53881
|
-
const { runImports } = await import("./index-
|
|
52390
|
+
const { runImports } = await import("./index-2jw11t8s.js");
|
|
53882
52391
|
await runImports();
|
|
53883
52392
|
} catch (err) {
|
|
53884
52393
|
console.error("[startup] File import failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
@@ -53929,10 +52438,10 @@ httpServer.listen(port, async () => {
|
|
|
53929
52438
|
startChatSdk().catch((err) => {
|
|
53930
52439
|
console.error("[chat-sdk] Failed to start, continuing without Chat SDK:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
53931
52440
|
});
|
|
53932
|
-
import("./agent-fs-provision-
|
|
52441
|
+
import("./agent-fs-provision-zmaykqnd.js").then(({ syncAgentFsOrgSwarmUrl }) => syncAgentFsOrgSwarmUrl(getConfiguredAppUrls()[0])).catch((err) => {
|
|
53933
52442
|
console.warn("[agent-fs] Failed to set the org swarm URL:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
53934
52443
|
});
|
|
53935
|
-
import("./object-webhooks-
|
|
52444
|
+
import("./object-webhooks-8s1wtths.js").then(({ ensureObjectWebhooksForKnownDrives }) => ensureObjectWebhooksForKnownDrives()).catch((err) => {
|
|
53936
52445
|
console.warn("[objects] agent-fs webhook boot check failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
53937
52446
|
});
|
|
53938
52447
|
startQueueStallAlarm();
|
|
@@ -53948,25 +52457,22 @@ httpServer.listen(port, async () => {
|
|
|
53948
52457
|
await initWorkflows2();
|
|
53949
52458
|
await startScriptRunSupervisor(getMcpBaseUrl());
|
|
53950
52459
|
if (hasCapability("scheduling")) {
|
|
53951
|
-
const { startScheduler } = await import("./index-
|
|
53952
|
-
const { getExecutorRegistry } = await import("./index-
|
|
53953
|
-
|
|
53954
|
-
startScheduler(getExecutorRegistry(), intervalMs, {
|
|
53955
|
-
runId: globalState.__runId
|
|
53956
|
-
});
|
|
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 });
|
|
53957
52463
|
}
|
|
53958
52464
|
if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
|
|
53959
|
-
const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-
|
|
52465
|
+
const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-hf2k1vge.js");
|
|
53960
52466
|
startHeartbeat(parseHeartbeatIntervalMs(process.env.HEARTBEAT_INTERVAL_MS));
|
|
53961
52467
|
}
|
|
53962
52468
|
startPoolRouting();
|
|
53963
52469
|
startRuntimeSupervisor();
|
|
53964
52470
|
if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
|
|
53965
|
-
const { startOAuthKeepalive } = await import("./keepalive-
|
|
52471
|
+
const { startOAuthKeepalive } = await import("./keepalive-9px3t7qj.js");
|
|
53966
52472
|
startOAuthKeepalive();
|
|
53967
52473
|
}
|
|
53968
52474
|
if (!isEnvFlagEnabled("OAUTH_REFRESH_SWEEP_DISABLE", false)) {
|
|
53969
|
-
const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-
|
|
52475
|
+
const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-yqry3wn4.js");
|
|
53970
52476
|
startOAuthRefreshSweep();
|
|
53971
52477
|
}
|
|
53972
52478
|
startOAuthPendingGc();
|
|
@@ -53976,22 +52482,22 @@ httpServer.listen(port, async () => {
|
|
|
53976
52482
|
startSavingsRollup(savingsRollupSql);
|
|
53977
52483
|
startHumanFreeDrain();
|
|
53978
52484
|
startTaskSearchBackfill();
|
|
53979
|
-
import("./embedding-space-
|
|
52485
|
+
import("./embedding-space-001hhhpk.js").then(({ runEmbeddingMaintenance, setDeploymentEnvReader }) => {
|
|
53980
52486
|
setDeploymentEnvReader(getDeploymentEnvValue2);
|
|
53981
52487
|
return runEmbeddingMaintenance({ backfill: true });
|
|
53982
52488
|
}).catch((err) => {
|
|
53983
52489
|
console.error("[embedding-space] startup maintenance failed (non-fatal):", err);
|
|
53984
52490
|
});
|
|
53985
|
-
import("./boot-args-schema-
|
|
52491
|
+
import("./boot-args-schema-n099e0f2.js").then(({ runBootArgsSchemaBackfill }) => runBootArgsSchemaBackfill()).catch((err) => {
|
|
53986
52492
|
console.error("[boot-args-schema] startup backfill failed (non-fatal):", err);
|
|
53987
52493
|
});
|
|
53988
|
-
import("./boot-scrub-sweep-
|
|
52494
|
+
import("./boot-scrub-sweep-dhkfp0a7.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
|
|
53989
52495
|
console.error("[boot-scrub-sweep] startup scrub failed (non-fatal):", err);
|
|
53990
52496
|
});
|
|
53991
|
-
import("./user-merge-jobs-
|
|
52497
|
+
import("./user-merge-jobs-n20qpv6s.js").then(({ resumeUserMergeJobs }) => resumeUserMergeJobs()).catch((err) => {
|
|
53992
52498
|
console.error("[user-merge] startup resume failed (non-fatal):", err);
|
|
53993
52499
|
});
|
|
53994
|
-
import("./session-source-backfill-
|
|
52500
|
+
import("./session-source-backfill-57b50tpw.js").then(({ runSessionSourceBackfill }) => runSessionSourceBackfill()).catch((err) => {
|
|
53995
52501
|
console.error("[session-source-backfill] startup run failed (non-fatal):", err);
|
|
53996
52502
|
});
|
|
53997
52503
|
}).on("error", (err) => {
|