@desplega.ai/agent-swarm 2.13.3 → 2.13.5
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-tbt61zkm.js +17 -0
- package/dist/{acp-targets-k8xs4tj8.js → acp-targets-w8dbs4nr.js} +10 -10
- package/dist/{actions-pg5fxjer.js → actions-8zrcbjrx.js} +237 -27
- package/dist/{agent-fs-provision-vbk3fppw.js → agent-fs-provision-cbt2ttds.js} +4 -4
- package/dist/{amp-adapter-adbhxsz9.js → amp-adapter-8x6zp8w4.js} +3 -3
- package/dist/{anthropic-messages-88b7s3n9.js → anthropic-messages-vdd1zmha.js} +10 -10
- package/dist/{app-b267ggx1.js → app-zfa9dwjw.js} +7 -7
- package/dist/{approval-notifications-evc1a9z5.js → approval-notifications-rv92zmza.js} +8 -8
- package/dist/{assistant-wgz2ab84.js → assistant-q7s7rm1q.js} +25 -25
- package/dist/{boot-args-schema-6tpk28j4.js → boot-args-schema-g27kpzr1.js} +1 -1
- package/dist/{boot-reembed-r1zyvefv.js → boot-reembed-1mjs52nt.js} +1 -1
- package/dist/{boot-reembed-ankp369c.js → boot-reembed-m62dpdkg.js} +1 -1
- package/dist/{boot-scrub-sweep-cgb6r5bd.js → boot-scrub-sweep-ss1vcamw.js} +2 -2
- package/dist/{boot-seeds-bjceqg7b.js → boot-seeds-hwnvgbb3.js} +4 -4
- package/dist/{boxd-hr8rsxzq.js → boxd-y0szhp0g.js} +2 -2
- package/dist/{claude-adapter-knztdnff.js → claude-adapter-0rjmbhjk.js} +9 -9
- package/dist/{claude-managed-adapter-qwejzqkk.js → claude-managed-adapter-6k032agg.js} +4 -4
- package/dist/{claude-managed-setup-0vgz4d1j.js → claude-managed-setup-6czvve8q.js} +5 -5
- package/dist/{claude-sdk-session-c3g6dv0g.js → claude-sdk-session-pr0znb81.js} +12671 -11885
- package/dist/{cli-2v4xxnx2.js → cli-0h8skzss.js} +1 -1
- package/dist/{cli-7fa6yv98.js → cli-0qt3epg4.js} +7 -7
- package/dist/{cli-aytna2fm.js → cli-19d6v8er.js} +7 -7
- package/dist/{cli-8m6gqnf1.js → cli-1jq2em7b.js} +4 -4
- package/dist/{cli-fp65jdp2.js → cli-1kvcsd2f.js} +219 -155
- package/dist/{cli-8fj8yfmk.js → cli-2vp0z049.js} +1 -1
- package/dist/{cli-61p7ty8d.js → cli-2wzkvfgm.js} +3 -3
- package/dist/{cli-tjf1bh1v.js → cli-34fygf87.js} +6 -4
- package/dist/{cli-czeh7x13.js → cli-3860pmrq.js} +4 -4
- package/dist/{cli-dq30fq3q.js → cli-3vw6dd4g.js} +2 -2
- package/dist/{cli-4dyhzhpx.js → cli-4gaf3tx5.js} +1 -1
- package/dist/{cli-3mf04tkh.js → cli-4vynxtrb.js} +1 -1
- package/dist/{cli-hpxcfvdm.js → cli-55h8m1x3.js} +10 -7
- package/dist/{cli-hxj888w3.js → cli-5n9w2xzx.js} +2 -2
- package/dist/{cli-50whymxq.js → cli-5tq15aa7.js} +2 -2
- package/dist/{cli-8sayvj48.js → cli-5web09sb.js} +3 -3
- package/dist/{cli-gc715jrc.js → cli-69zzpjgh.js} +1 -1
- package/dist/{cli-vgh5adn9.js → cli-6msnpj1z.js} +8 -8
- package/dist/{cli-f8rcvf2x.js → cli-7r9tvk8v.js} +76 -3
- package/dist/{cli-fbmgpt72.js → cli-7ypg8hka.js} +3 -3
- package/dist/{cli-xc8m5cjn.js → cli-887vhew6.js} +3 -3
- package/dist/{cli-q8aq48v1.js → cli-8b4rpnwj.js} +1 -1
- package/dist/{cli-pzsedyb0.js → cli-8pd1t17c.js} +14 -14
- package/dist/{cli-je587f74.js → cli-94gx6ze9.js} +1 -1
- package/dist/{cli-h9d3sdnc.js → cli-94mxerrp.js} +1 -1
- package/dist/{cli-ef590376.js → cli-9n6g14vs.js} +3 -3
- package/dist/{cli-80d5g0fa.js → cli-abby987g.js} +3 -3
- package/dist/{cli-grk77aen.js → cli-avax5mp9.js} +2 -2
- package/dist/{cli-hd2a204w.js → cli-b42yfn17.js} +14 -14
- package/dist/{cli-gkjw33x5.js → cli-b9ygp1kz.js} +2 -2
- package/dist/{cli-bh53ppqm.js → cli-bvamr9g0.js} +4 -4
- package/dist/{cli-ka4tqjzd.js → cli-ced4azn1.js} +15 -12
- package/dist/{cli-v1v49t36.js → cli-cmbb2t8a.js} +3 -3
- package/dist/{cli-hhb8kbwd.js → cli-cp163xga.js} +31 -16
- package/dist/{cli-55fqpd9q.js → cli-ebpq3c5z.js} +8 -8
- package/dist/{cli-9gmkw6xn.js → cli-ehg90jd1.js} +128 -48
- package/dist/{cli-jg5txpm6.js → cli-emdfd8fh.js} +75 -1
- package/dist/{cli-gxqwm3k3.js → cli-evy3egte.js} +104 -10
- package/dist/{cli-a21cwm89.js → cli-ewk3sg68.js} +3 -3
- package/dist/{cli-syqcny89.js → cli-f7b9nyvk.js} +9 -9
- package/dist/{cli-268b3dgn.js → cli-f9xw9pr4.js} +5 -5
- package/dist/{cli-61fzwtjk.js → cli-ffn0a515.js} +9 -9
- package/dist/{cli-ya1cj689.js → cli-fw67mnyc.js} +1 -1
- package/dist/{cli-dqgnbnxs.js → cli-grbngev5.js} +6 -1
- package/dist/{cli-sy2ge2ye.js → cli-hd5bm1e1.js} +4 -4
- package/dist/{cli-rfejbpe1.js → cli-htb5bpz2.js} +1 -1
- package/dist/{cli-w24741sm.js → cli-j69pzrrz.js} +7 -7
- package/dist/{cli-g4dhd3pr.js → cli-jdq3jmny.js} +6 -23
- package/dist/{cli-hv3820ez.js → cli-k0nebh10.js} +1 -1
- package/dist/{cli-d2epqm0y.js → cli-kezzteka.js} +1 -1
- package/dist/{cli-h0ewec3d.js → cli-kr0jpw9c.js} +1 -1
- package/dist/{cli-t25rq8mg.js → cli-ks06cd0n.js} +40 -11
- package/dist/{cli-1gnf5c7x.js → cli-kwj3131p.js} +1 -1
- package/dist/{cli-wtffytm8.js → cli-m8f4379k.js} +3 -3
- package/dist/{cli-43dsqhcp.js → cli-n79j1vxc.js} +4 -4
- package/dist/{cli-b768ek79.js → cli-nrt048ys.js} +1 -0
- package/dist/{cli-h3drhntp.js → cli-pedm2kht.js} +2 -2
- package/dist/{cli-eds5xnsz.js → cli-phmy14hb.js} +2 -2
- package/dist/{cli-7kv5d674.js → cli-prz1p3ft.js} +5 -5
- package/dist/{cli-nbawx3s0.js → cli-q1h041y8.js} +6 -6
- package/dist/{cli-cah298e5.js → cli-q41qar56.js} +104 -119
- package/dist/{cli-kwm1bek7.js → cli-qmx8bnt4.js} +2 -2
- package/dist/{cli-1wew39p0.js → cli-qrvk9nka.js} +28 -19
- package/dist/{cli-v8rpjrnx.js → cli-r3dxpmyt.js} +1 -1
- package/dist/{cli-0j4qmc80.js → cli-ryem5cfq.js} +8 -8
- package/dist/{cli-8pnawt98.js → cli-s8dhq7rj.js} +5 -5
- package/dist/{cli-zkbz8m2q.js → cli-sejvnjvw.js} +3 -2
- package/dist/{cli-at67kvnp.js → cli-srktrbby.js} +1 -1
- package/dist/{cli-wsnradtk.js → cli-srre41gb.js} +2 -2
- package/dist/{cli-r6xnchva.js → cli-t0n9svkb.js} +7 -7
- package/dist/{cli-y0q92v4r.js → cli-t879ww0y.js} +2 -2
- package/dist/{cli-eetzmsy5.js → cli-t9pzz2eq.js} +2 -2
- package/dist/{cli-xwsm6xkr.js → cli-tgc1kgg3.js} +1 -1
- package/dist/{cli-dw43pnzp.js → cli-tt7dkwjj.js} +7 -7
- package/dist/{cli-y754psdt.js → cli-tvyt8w6n.js} +5 -5
- package/dist/cli-v09eza21.js +1907 -0
- package/dist/{cli-mgr3gatr.js → cli-vbge4rsp.js} +4 -4
- package/dist/{cli-ppf9ap9n.js → cli-vcpyttcw.js} +1 -1
- package/dist/{cli-1606qw3n.js → cli-wzecestt.js} +1100 -432
- package/dist/{cli-5basv0e7.js → cli-x2adbg4j.js} +71 -9
- package/dist/{cli-vx9acp12.js → cli-ybte1fqc.js} +1 -1
- package/dist/{cli-vdfngx2g.js → cli-ywy8yz6t.js} +2 -2
- package/dist/{cli-cpkxh68d.js → cli-z1vam71h.js} +2 -2
- package/dist/{cli-djwt4mtn.js → cli-z3x7h79n.js} +15 -9
- package/dist/cli-z40t85ms.js +27 -0
- package/dist/{cli-ea367bdn.js → cli-zbbtp02a.js} +104 -27
- package/dist/{cli-88np9va3.js → cli-zntvmqmm.js} +2 -2
- package/dist/{cli-snwz16eg.js → cli-zxa1vmx7.js} +2 -2
- package/dist/{cli-50wa8k4h.js → cli-zy9bb22b.js} +1 -2
- package/dist/{cli-e4gx499y.js → cli-zzq96q57.js} +273 -106
- package/dist/cli.js +21 -21
- package/dist/{codex-adapter-493vb8cv.js → codex-adapter-bn7eaxk5.js} +8 -8
- package/dist/{codex-hook-ej8hn6z5.js → codex-hook-nnmezjg9.js} +3 -3
- package/dist/{codex-login-ven5cz5j.js → codex-login-ktfg1cxk.js} +1 -1
- package/dist/{codex-session-runner-ps5m4z1g.js → codex-session-runner-j1e9hffc.js} +9 -9
- package/dist/{commands-shktk0b8.js → commands-amhpafrr.js} +3 -3
- package/dist/{controller-wn3vd217.js → controller-tw7g10j2.js} +4 -4
- package/dist/{controllers-connect-yft057ws.js → controllers-connect-2ssqz7f4.js} +25 -25
- package/dist/core-bwp98v4w.js +42 -0
- package/dist/{cursor-adapter-8fpm4dng.js → cursor-adapter-d6knjmwa.js} +2 -2
- package/dist/{db-0ezhdhz5.js → db-fd6xxm77.js} +3 -3
- package/dist/{db-84pz2w5c.js → db-sc59379z.js} +2 -2
- package/dist/{devin-adapter-fs90ab4v.js → devin-adapter-3bp6rape.js} +1 -1
- package/dist/{dispatcher-h2rz69f6.js → dispatcher-a2gdqz8c.js} +22 -22
- package/dist/{docker-1h33jvh9.js → docker-a59g3ebm.js} +2 -2
- package/dist/{dsh-adapter-g9yqv09y.js → dsh-adapter-43ygwqn7.js} +2 -2
- package/dist/{e2b-jnk0yeva.js → e2b-cn7cvjqy.js} +3 -3
- package/dist/{e2b-y7e5kmzf.js → e2b-qnxyfea6.js} +3 -3
- package/dist/{easter-egg-3d-m41ad78v.js → easter-egg-3d-a0pphy71.js} +1 -1
- package/dist/{embedding-space-yam9zwzj.js → embedding-space-qepzrach.js} +6 -6
- package/dist/{embeddings-g2be0y8q.js → embeddings-d7vr881x.js} +1 -1
- package/dist/{event-bus-08t2b4y2.js → event-bus-7gbsr0g4.js} +1 -1
- package/dist/{execute-hhdejgzf.js → execute-6afts2bn.js} +1 -1
- package/dist/{external-channel-kjt2yzfj.js → external-channel-881zq1x4.js} +2 -2
- package/dist/fx-adapter-cr2hq17y.js +20 -0
- package/dist/grok-adapter-ayddnbsc.js +20 -0
- package/dist/handlers-7ghs84x2.js +41 -0
- package/dist/{heartbeat-2e5jdexj.js → heartbeat-4c022m6a.js} +25 -25
- package/dist/{hook-acg9saz7.js → hook-4k84x499.js} +6 -6
- package/dist/{hook-34s8cmgn.js → hook-a7eh6zty.js} +9 -9
- package/dist/{http-ra2zr2f8.js → http-6aw5wanc.js} +456 -1864
- package/dist/{index-mbpxhc4w.js → index-126v2d0t.js} +1 -4
- package/dist/index-dtt0d634.js +44 -0
- package/dist/index-hmszyqkk.js +42 -0
- package/dist/index-j6rm1rtn.js +39 -0
- package/dist/{index-9q42cr54.js → index-rwwhsmjg.js} +1 -1
- package/dist/{index-93bw5wds.js → index-xhad0n8m.js} +1 -1
- package/dist/{index-2z1z7qx6.js → index-yq9hhhhy.js} +26 -26
- package/dist/{index-9r4j0a60.js → index-z2g9469g.js} +410 -27
- package/dist/{k8s-8326q0rq.js → k8s-36gfn847.js} +2 -2
- package/dist/{keepalive-vjnnqbkm.js → keepalive-zhbmztqw.js} +5 -5
- package/dist/lead-g2j4q39z.js +83 -0
- package/dist/{maintenance-px2g599e.js → maintenance-rsp0591h.js} +1 -1
- package/dist/{node-2wfcey7d.js → node-0as4n1ef.js} +3 -3
- package/dist/{node-zd6shky9.js → node-dhxbt01p.js} +3 -3
- package/dist/{node-z67yjre7.js → node-rxte5hc6.js} +290 -70
- package/dist/{node-hjn5n1yp.js → node-t0ct2zpw.js} +3 -5
- package/dist/{oauth-refresh-sweep-nkykf09m.js → oauth-refresh-sweep-w3cqmxq7.js} +4 -4
- package/dist/{object-webhooks-gt9xnq21.js → object-webhooks-331hay92.js} +7 -7
- package/dist/{onboard-1f134p65.js → onboard-n2w80m2n.js} +7 -7
- package/dist/{opencode-adapter-94976yab.js → opencode-adapter-z98127cz.js} +8 -8
- package/dist/{otel-impl-5d4p2fqs.js → otel-impl-xsk35tvf.js} +2 -2
- package/dist/{pending-vkk0vx6n.js → pending-2e6trkxd.js} +23 -23
- package/dist/{pi-mono-adapter-cyzdv5er.js → pi-mono-adapter-wh6yndtm.js} +13 -13
- package/dist/{pricing-refresh-jtmjwss9.js → pricing-refresh-9355dj1t.js} +2 -2
- package/dist/{rbac-roles-yd1fgpsn.js → rbac-roles-58y3m912.js} +3 -3
- package/dist/{rbac-roles-1fvmdyeb.js → rbac-roles-8eajw4s6.js} +6 -4
- package/dist/{render-v2-kb5s3vx4.js → render-v2-7gskkmd4.js} +7 -7
- package/dist/{resume-z1vs44n5.js → resume-0drnmpja.js} +10 -10
- package/dist/{runtime-gk6ct7r7.js → runtime-d2tcmqte.js} +1 -1
- package/dist/{session-access-nz6nre4d.js → session-access-0ztys6bd.js} +5 -5
- package/dist/{session-source-backfill-wb60zjkd.js → session-source-backfill-cdm5s046.js} +3 -3
- package/dist/{setup-2x8g8j4s.js → setup-pqwb9tcc.js} +1 -1
- package/dist/thread-buffer-epx3san4.js +42 -0
- package/dist/{tree-visibility-ts3z30kw.js → tree-visibility-rwz67mje.js} +2 -2
- package/dist/{user-merge-jobs-zetg26e0.js → user-merge-jobs-mxrhamwt.js} +3 -3
- package/dist/{virtual-modules-674fka8x.js → virtual-modules-71y1gsmg.js} +3 -3
- package/dist/{work-objects-w52yyjxm.js → work-objects-3k4ykt9j.js} +25 -25
- package/dist/worker-09gqn9xy.js +83 -0
- package/dist/{worker-follow-up-dyfxyjbj.js → worker-follow-up-y0h64xpr.js} +22 -22
- package/dist/{x-asbrnafg.js → x-d27jj7z7.js} +2 -2
- package/openapi.json +861 -33
- package/package.json +4 -4
- package/src/apps/sync.ts +20 -5
- package/src/azure-devops/boards-sync.ts +1 -1
- 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/slack-trees.ts +12 -1
- package/src/be/db/tasks/read.ts +25 -1
- package/src/be/db/tasks/write.ts +47 -12
- package/src/be/db/users/avatar.ts +12 -0
- package/src/be/db-retention.ts +1 -1
- package/src/be/db.ts +149 -67
- package/src/be/design-system.ts +63 -0
- package/src/be/migrations/342_script_run_sources.sql +20 -0
- package/src/be/migrations/344_user_avatar.sql +4 -0
- package/src/be/migrations/345_task_status_kind.sql +6 -0
- package/src/be/migrations/runner.ts +8 -0
- package/src/be/migrations/script-run-sources.ts +51 -0
- package/src/be/primitives/object-embed.ts +2 -2
- package/src/be/primitives/objects.ts +2 -2
- package/src/be/rbac-roles.ts +2 -0
- package/src/be/runtime-pools/supervisor.ts +1 -0
- package/src/be/scripts/typecheck.ts +5 -3
- 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 +25 -1
- package/src/bitbucket/handlers.ts +1 -1
- package/src/commands/credential-outcome-report.ts +96 -0
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/runner.ts +49 -3
- package/src/event-waits/github.ts +39 -6
- package/src/event-waits/index.ts +4 -2
- package/src/event-waits/types.ts +10 -3
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/github/app.ts +177 -13
- package/src/github/handlers.ts +7 -2
- package/src/github/pull-request-state.ts +100 -11
- package/src/gitlab/handlers.ts +2 -2
- package/src/heartbeat/heartbeat.ts +24 -5
- package/src/http/all-routes.ts +1 -0
- package/src/http/api-keys.ts +26 -0
- package/src/http/approval-chat-answer.ts +99 -0
- package/src/http/approval-requests.ts +280 -225
- package/src/http/asset-key-write.ts +45 -0
- package/src/http/assets.ts +4 -3
- package/src/http/design-system.ts +103 -0
- package/src/http/github-token.ts +27 -6
- package/src/http/index.ts +10 -6
- package/src/http/pages-public.ts +25 -10
- package/src/http/pages.ts +21 -10
- package/src/http/person-responder.ts +28 -0
- package/src/http/schedules.ts +6 -6
- package/src/http/sessions.ts +7 -2
- package/src/http/tasks.ts +23 -5
- package/src/http/users.ts +5 -0
- package/src/http/webhooks.ts +19 -1
- package/src/http/workflows.ts +5 -10
- package/src/integrations/chat-sdk/adapters.ts +33 -3
- package/src/integrations/chat-sdk/commands.ts +3 -1
- 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/jira/sync.ts +1 -1
- package/src/kv-reserved-namespaces.ts +5 -0
- package/src/linear/sync.ts +5 -3
- package/src/pages/page-head.ts +11 -1
- package/src/prompts/session-templates.ts +1 -0
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +5 -0
- package/src/providers/claude-sdk-session.ts +5 -0
- package/src/providers/dsh-adapter.ts +48 -13
- package/src/providers/runtime-dependencies.ts +1 -1
- package/src/rbac/legacy-policy.ts +4 -0
- package/src/rbac/permissions.ts +8 -0
- package/src/scheduler/deferred-task-waits.ts +74 -13
- 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 +20 -24
- package/src/scripts-runtime/types/stdlib.d.ts +12 -2
- package/src/scripts-runtime/types/swarm-extension.d.ts +19 -2
- package/src/scripts-runtime/types/swarm-sdk.d.ts +12 -2
- package/src/server.ts +2 -0
- package/src/slack/actions.ts +4 -1
- package/src/slack/approval-actions.ts +148 -0
- package/src/slack/approval-buttons.ts +28 -0
- package/src/slack/render-v2.ts +148 -7
- package/src/tests/api-drain-worker-e2e.test.ts +0 -2
- package/src/tests/approval-auto-cancellation-migration.test.ts +8 -19
- package/src/tests/approval-card-resolution.test.ts +2 -17
- package/src/tests/approval-requests-notifications.test.ts +41 -27
- package/src/tests/approval-requests.test.ts +137 -369
- package/src/tests/apps-sync-engine.test.ts +5 -3
- package/src/tests/apps-table-filters-migration.test.ts +44 -25
- package/src/tests/bitbucket-handlers.test.ts +2 -0
- package/src/tests/chat-sdk-commands.test.ts +1 -0
- package/src/tests/chat-sdk-mentions.test.ts +183 -0
- package/src/tests/claude-adapter.test.ts +35 -0
- package/src/tests/codex-adapter.test.ts +3 -92
- package/src/tests/codex-gpt6-release.test.ts +0 -9
- package/src/tests/codex-oauth-credential-info.test.ts +35 -18
- package/src/tests/codex-oauth.test.ts +0 -6
- package/src/tests/codex-pool.test.ts +5 -214
- package/src/tests/codex-rate-limit-parse.test.ts +0 -7
- package/src/tests/codex-swarm-events.test.ts +11 -54
- package/src/tests/create-page-tool.test.ts +5 -0
- package/src/tests/db-client-busy-retry.test.ts +49 -16
- package/src/tests/defer-task.test.ts +1 -0
- package/src/tests/dsh-adapter.test.ts +53 -1
- package/src/tests/e2e-shards.test.ts +9 -9
- package/src/tests/enabled-tools.test.ts +0 -2
- package/src/tests/fixtures/base-prompt-baseline.json +6 -6
- package/src/tests/fixtures/compiled-source-schema-boot.ts +24 -0
- package/src/tests/fixtures/secret-corpus.ts +43 -1
- package/src/tests/github-app-worker-auth-helper.test.ts +147 -1
- package/src/tests/gitlab-handlers.test.ts +2 -0
- package/src/tests/heartbeat-jev-gate.test.ts +9 -241
- package/src/tests/heartbeat-reroute-decision.test.ts +2 -0
- package/src/tests/heartbeat-stall-thresholds.test.ts +174 -0
- package/src/tests/heartbeat-supersede-resume.test.ts +2 -0
- package/src/tests/heartbeat.test.ts +1 -0
- package/src/tests/jira-adf.test.ts +42 -2
- package/src/tests/key-usage-selection.test.ts +302 -0
- package/src/tests/memory-e2e.test.ts +34 -103
- package/src/tests/memory-key-paths.test.ts +5 -0
- package/src/tests/memory-rater-llm.test.ts +33 -149
- package/src/tests/memory-store.test.ts +24 -125
- package/src/tests/memory.test.ts +31 -100
- package/src/tests/merge-gate-detect-changes.test.ts +314 -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/otel-service-name.test.ts +0 -9
- package/src/tests/otel-session-cost-metrics.test.ts +1 -38
- package/src/tests/pool-session-logs.test.ts +8 -42
- package/src/tests/pre-push-affected-tests.test.ts +106 -0
- package/src/tests/prompt-template-session.test.ts +3 -0
- package/src/tests/rbac-e2e-helpers.test.ts +10 -4
- package/src/tests/rbac-e2e-helpers.ts +13 -4
- package/src/tests/rbac-roles.test.ts +2 -0
- package/src/tests/runner-api-drain.test.ts +2 -17
- package/src/tests/runner-terminal-window-report.test.ts +132 -0
- package/src/tests/runtime-e2b-pools.test.ts +7 -1
- package/src/tests/runtime-supervisor-failures.test.ts +1 -0
- package/src/tests/sandboxed-process.test.ts +26 -21
- package/src/tests/schedule-http-triage-tools.test.ts +12 -9
- package/src/tests/schedule-target-type.test.ts +4 -1
- package/src/tests/scheduled-tasks.test.ts +14 -51
- package/src/tests/script-connections.test.ts +2 -0
- package/src/tests/script-executor-conformance.test.ts +4 -48
- package/src/tests/script-executor-quickjs-pool.test.ts +9 -7
- package/src/tests/script-native-startup.test.ts +21 -25
- 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 +38 -2
- 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/session-logs.test.ts +1 -260
- package/src/tests/slack-render-v2.test.ts +5 -148
- package/src/tests/system-one-hosts-ui-mirror.test.ts +1 -0
- package/src/tests/task-cascade-fail.test.ts +1 -0
- package/src/tests/task-supersede-resume.test.ts +1 -0
- package/src/tests/test-proc.ts +5 -2
- package/src/tests/vcs-azure-devops.test.ts +10 -0
- package/src/tests/vcs-provider.test.ts +8 -0
- package/src/tests/window-stream-reporter.test.ts +122 -0
- package/src/tests/workflow-agent-task-retry.test.ts +1 -3
- package/src/tests/workflow-cascade-cancel.test.ts +1 -0
- package/src/tests/workflow-retry-v2.test.ts +34 -43
- package/src/tests/workflow-retry-validation.test.ts +8 -48
- package/src/tests/worktree-reaper.test.ts +2 -2
- package/src/themes/design-system.ts +163 -0
- package/src/themes/page-theme.ts +28 -19
- package/src/tools/cancel-task.ts +2 -2
- package/src/tools/chat-post.ts +7 -3
- package/src/tools/create-page.ts +3 -0
- package/src/tools/defer-task.ts +7 -2
- package/src/tools/design-system.ts +102 -0
- package/src/tools/get-task-details.ts +8 -4
- package/src/tools/get-tasks.ts +13 -2
- package/src/tools/manage-user.ts +9 -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/store-progress.ts +5 -3
- 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 +158 -0
- package/src/utils/constants.ts +12 -0
- package/src/utils/credentials.ts +42 -5
- package/src/utils/error-tracker.ts +6 -0
- package/src/utils/key-usage.ts +114 -0
- package/src/utils/sandboxed-process.ts +1 -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/src/workflows/resume.ts +5 -2
- package/templates/skills/apps/SKILL.md +2 -0
- package/templates/skills/apps/content.md +2 -0
- package/templates/skills/boards-and-sheets/content.md +4 -2
- package/templates/skills/pages/content.md +41 -8
- package/templates/skills/swarm-docs/content.md +6 -0
- package/templates/skills/swarm-scripts/SKILL.md +1 -0
- package/templates/skills/swarm-scripts/content.md +1 -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
- package/src/tests/apps-table-selection-migration.test.ts +0 -95
- package/src/tests/extensions-example-heartbeat-remediate.test.ts +0 -69
- package/src/tests/extensions-example-rewrite-and-suppress.test.ts +0 -70
|
@@ -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-zzq96q57.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-34fygf87.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-7ypg8hka.js";
|
|
584
551
|
import {
|
|
585
552
|
requestModelCatalogRefresh2,
|
|
586
553
|
init_pricing_refresh
|
|
587
|
-
} from "./cli-
|
|
554
|
+
} from "./cli-pedm2kht.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-5n9w2xzx.js";
|
|
560
|
+
import"./cli-4gaf3tx5.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-zbbtp02a.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-evy3egte.js";
|
|
663
615
|
import {
|
|
664
616
|
retryFailedRun2,
|
|
665
617
|
cancelWorkflowRun2,
|
|
666
618
|
init_resume
|
|
667
|
-
} from "./cli-
|
|
619
|
+
} from "./cli-55h8m1x3.js";
|
|
668
620
|
import {
|
|
669
621
|
safeParse,
|
|
670
622
|
getObjectShape,
|
|
@@ -741,6 +693,8 @@ import {
|
|
|
741
693
|
init_sibling_block,
|
|
742
694
|
createTaskWithSiblingAwareness,
|
|
743
695
|
init_sibling_awareness,
|
|
696
|
+
hasPendingEventWait,
|
|
697
|
+
init_deferred_task_waits,
|
|
744
698
|
dispatchScheduleTarget,
|
|
745
699
|
calculateNextRun2,
|
|
746
700
|
init_scheduler,
|
|
@@ -879,7 +833,7 @@ import {
|
|
|
879
833
|
init_gitlab,
|
|
880
834
|
isChatSdkEnabled,
|
|
881
835
|
getChatSdkConfig,
|
|
882
|
-
|
|
836
|
+
init_config2,
|
|
883
837
|
errorMessage,
|
|
884
838
|
init_logger,
|
|
885
839
|
resolveAdapterApiUrl,
|
|
@@ -938,10 +892,15 @@ import {
|
|
|
938
892
|
init_auth,
|
|
939
893
|
getDeploymentEnvValue2,
|
|
940
894
|
loadGlobalConfigsIntoEnv2,
|
|
941
|
-
reloadGlobalConfigsAndIntegrations2,
|
|
942
895
|
scheduleIntegrationsReload2,
|
|
943
896
|
handleCore2,
|
|
944
897
|
init_core,
|
|
898
|
+
resolveRequestPrincipal,
|
|
899
|
+
requestPrincipal,
|
|
900
|
+
agentFirstPrincipal,
|
|
901
|
+
requireAuthKind,
|
|
902
|
+
rejectGuest,
|
|
903
|
+
init_request_principal,
|
|
945
904
|
nextFallback2,
|
|
946
905
|
createWorkerTaskFollowUp2,
|
|
947
906
|
createResumeFollowUp2,
|
|
@@ -951,12 +910,6 @@ import {
|
|
|
951
910
|
init_mcp_limits,
|
|
952
911
|
userCtx,
|
|
953
912
|
init_task_tool_ctx,
|
|
954
|
-
resolveRequestPrincipal,
|
|
955
|
-
requestPrincipal,
|
|
956
|
-
agentFirstPrincipal,
|
|
957
|
-
requireAuthKind,
|
|
958
|
-
rejectGuest,
|
|
959
|
-
init_request_principal,
|
|
960
913
|
resolveTaskRequester,
|
|
961
914
|
init_task_requester,
|
|
962
915
|
handleApps,
|
|
@@ -965,8 +918,6 @@ import {
|
|
|
965
918
|
init_elements,
|
|
966
919
|
MAX_OBJECT_BYTES,
|
|
967
920
|
init_write_object,
|
|
968
|
-
cancelApprovalRequest,
|
|
969
|
-
init_approval_cancel,
|
|
970
921
|
getUserCommsPrefs,
|
|
971
922
|
init_requester_comms,
|
|
972
923
|
getTaskDetailsInputSchema,
|
|
@@ -993,12 +944,19 @@ import {
|
|
|
993
944
|
init_asset_key_auth,
|
|
994
945
|
getPageEditCounter,
|
|
995
946
|
init_page_versions,
|
|
996
|
-
snapshotPage,
|
|
997
|
-
init_version3,
|
|
998
947
|
DEFAULT_THEME_ID,
|
|
999
948
|
THEME_PRESET_IDS,
|
|
1000
949
|
getThemePreset,
|
|
1001
950
|
init_presets,
|
|
951
|
+
DesignSystemError,
|
|
952
|
+
buildDesignSystem,
|
|
953
|
+
init_design_system,
|
|
954
|
+
getDesignSystem,
|
|
955
|
+
getActiveDesignSystem,
|
|
956
|
+
saveDesignSystem,
|
|
957
|
+
init_design_system2,
|
|
958
|
+
snapshotPage,
|
|
959
|
+
init_version3,
|
|
1002
960
|
readThemeFields,
|
|
1003
961
|
init_page_fields,
|
|
1004
962
|
assertOAuthAppUrlsSafe,
|
|
@@ -1063,13 +1021,13 @@ import {
|
|
|
1063
1021
|
getKapsoConfig,
|
|
1064
1022
|
getKapsoNumberMapping,
|
|
1065
1023
|
markKapsoMessageSeen,
|
|
1066
|
-
|
|
1024
|
+
init_config3,
|
|
1067
1025
|
changesMergePolicy,
|
|
1068
1026
|
init_repo_merge_policy,
|
|
1069
1027
|
updateSwarmRepoChecked,
|
|
1070
1028
|
init_repo_checked_update,
|
|
1071
1029
|
getCombConfig,
|
|
1072
|
-
|
|
1030
|
+
init_config4,
|
|
1073
1031
|
resolveRoomNamespace,
|
|
1074
1032
|
roomRequestInfo,
|
|
1075
1033
|
authorizeRoomNamespace,
|
|
@@ -1167,7 +1125,7 @@ import {
|
|
|
1167
1125
|
getEnabledCapabilities,
|
|
1168
1126
|
createServer,
|
|
1169
1127
|
init_server
|
|
1170
|
-
} from "./cli-
|
|
1128
|
+
} from "./cli-wzecestt.js";
|
|
1171
1129
|
import {
|
|
1172
1130
|
getFileStorageProvider2,
|
|
1173
1131
|
init_registry2
|
|
@@ -1193,9 +1151,8 @@ import {
|
|
|
1193
1151
|
resolvePoolDelivery2,
|
|
1194
1152
|
createPoolAgent2,
|
|
1195
1153
|
init_db2
|
|
1196
|
-
} from "./cli-
|
|
1154
|
+
} from "./cli-f9xw9pr4.js";
|
|
1197
1155
|
import {
|
|
1198
|
-
duplicateGuardedQueryKey,
|
|
1199
1156
|
warnIfCorsAllowsAnyOrigin,
|
|
1200
1157
|
isOriginAllowedForCredentials,
|
|
1201
1158
|
allowedCredentialRedirect,
|
|
@@ -1218,7 +1175,6 @@ import {
|
|
|
1218
1175
|
deriveApiBaseUrl,
|
|
1219
1176
|
httpServerSemconvAttributes,
|
|
1220
1177
|
init_utils2,
|
|
1221
|
-
resolveTaskAuditUserId,
|
|
1222
1178
|
resolveHttpRequesterUserId,
|
|
1223
1179
|
resolveHttpAuditUserId,
|
|
1224
1180
|
resolveHttpAuditActor,
|
|
@@ -1244,7 +1200,7 @@ import {
|
|
|
1244
1200
|
describeRequestRoute,
|
|
1245
1201
|
route,
|
|
1246
1202
|
init_route_def
|
|
1247
|
-
} from "./cli-
|
|
1203
|
+
} from "./cli-tt7dkwjj.js";
|
|
1248
1204
|
import {
|
|
1249
1205
|
startPoolRouting,
|
|
1250
1206
|
stopPoolRouting,
|
|
@@ -1257,39 +1213,29 @@ import {
|
|
|
1257
1213
|
checkHeartbeatChecklist2,
|
|
1258
1214
|
runHeartbeatSweep2,
|
|
1259
1215
|
stopHeartbeat2
|
|
1260
|
-
} from "./cli-
|
|
1261
|
-
import"./cli-
|
|
1216
|
+
} from "./cli-qrvk9nka.js";
|
|
1217
|
+
import"./cli-5tq15aa7.js";
|
|
1262
1218
|
import {
|
|
1263
1219
|
runtimeSupervisorStatus,
|
|
1264
1220
|
startRuntimeSupervisor,
|
|
1265
1221
|
stopRuntimeSupervisor
|
|
1266
|
-
} from "./cli-
|
|
1222
|
+
} from "./cli-b42yfn17.js";
|
|
1267
1223
|
import {
|
|
1268
1224
|
TASK_TITLE_TIMEOUT_MS,
|
|
1269
1225
|
generateTaskTitle
|
|
1270
|
-
} from "./cli-
|
|
1226
|
+
} from "./cli-9n6g14vs.js";
|
|
1271
1227
|
import"./cli-ns59dc6r.js";
|
|
1272
1228
|
import {
|
|
1273
1229
|
ACP_TARGET_IDS
|
|
1274
|
-
} from "./cli-
|
|
1230
|
+
} from "./cli-k0nebh10.js";
|
|
1275
1231
|
import {
|
|
1276
1232
|
reasoningCapability,
|
|
1277
1233
|
supportedReasoningLevels
|
|
1278
|
-
} from "./cli-
|
|
1234
|
+
} from "./cli-ywy8yz6t.js";
|
|
1279
1235
|
import {
|
|
1280
1236
|
MAX_RATE_LIMIT_RESET_MS,
|
|
1281
1237
|
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";
|
|
1238
|
+
} from "./cli-sejvnjvw.js";
|
|
1293
1239
|
import {
|
|
1294
1240
|
AgentFsRequestError2,
|
|
1295
1241
|
resolveAgentFsSharedContext2,
|
|
@@ -1300,16 +1246,24 @@ import {
|
|
|
1300
1246
|
agentFsRequest2,
|
|
1301
1247
|
resolveApiUrl2,
|
|
1302
1248
|
init_agent_fs_provision
|
|
1303
|
-
} from "./cli-
|
|
1249
|
+
} from "./cli-ewk3sg68.js";
|
|
1304
1250
|
import {
|
|
1305
1251
|
Anthropic
|
|
1306
|
-
} from "./cli-
|
|
1252
|
+
} from "./cli-q41qar56.js";
|
|
1253
|
+
import {
|
|
1254
|
+
isLeadChannelMonitoringEnabled,
|
|
1255
|
+
SIMILARITY_THRESHOLD,
|
|
1256
|
+
memoryRelevance,
|
|
1257
|
+
isUnknownModelError,
|
|
1258
|
+
checkProviderPoolKey,
|
|
1259
|
+
writeSkillsToFilesystem
|
|
1260
|
+
} from "./cli-jdq3jmny.js";
|
|
1307
1261
|
import {
|
|
1308
1262
|
objectWebhookSecret2,
|
|
1309
1263
|
handleObjectWebhookEvent2,
|
|
1310
1264
|
init_object_webhooks
|
|
1311
|
-
} from "./cli-
|
|
1312
|
-
import"./cli-
|
|
1265
|
+
} from "./cli-s8dhq7rj.js";
|
|
1266
|
+
import"./cli-3860pmrq.js";
|
|
1313
1267
|
import {
|
|
1314
1268
|
createUserMergeJob2,
|
|
1315
1269
|
getUserMergeJob2,
|
|
@@ -1318,7 +1272,7 @@ import {
|
|
|
1318
1272
|
findFailedUserMergeJob2,
|
|
1319
1273
|
requeueUserMergeJob2,
|
|
1320
1274
|
runUserMergeJobs2
|
|
1321
|
-
} from "./cli-
|
|
1275
|
+
} from "./cli-abby987g.js";
|
|
1322
1276
|
import {
|
|
1323
1277
|
isCodexOAuthConfigKey
|
|
1324
1278
|
} from "./cli-j4bwnpkm.js";
|
|
@@ -1328,8 +1282,28 @@ import {
|
|
|
1328
1282
|
} from "./cli-9fzgd3hg.js";
|
|
1329
1283
|
import {
|
|
1330
1284
|
runTaskUiAction,
|
|
1331
|
-
init_actions
|
|
1332
|
-
|
|
1285
|
+
init_actions,
|
|
1286
|
+
globalConfig,
|
|
1287
|
+
init_global_config,
|
|
1288
|
+
telemetryProxyEndpoint,
|
|
1289
|
+
handleUsedBy,
|
|
1290
|
+
init_used_by,
|
|
1291
|
+
handleRanking,
|
|
1292
|
+
init_ranking,
|
|
1293
|
+
readsRepoSecrets,
|
|
1294
|
+
requestSecretReadScope,
|
|
1295
|
+
ensureConfigAdmin,
|
|
1296
|
+
runConfigWriteSideEffects,
|
|
1297
|
+
ensureHttpPermission,
|
|
1298
|
+
handleConfig,
|
|
1299
|
+
init_config,
|
|
1300
|
+
approvalResponder,
|
|
1301
|
+
responderKey,
|
|
1302
|
+
init_person_responder,
|
|
1303
|
+
handleApprovalRequests,
|
|
1304
|
+
init_approval_requests
|
|
1305
|
+
} from "./cli-v09eza21.js";
|
|
1306
|
+
import"./cli-z40t85ms.js";
|
|
1333
1307
|
import {
|
|
1334
1308
|
RATING_MODEL_MAX_LENGTH,
|
|
1335
1309
|
REFERENCES_SOURCE_MAX_LENGTH,
|
|
@@ -1425,7 +1399,7 @@ import {
|
|
|
1425
1399
|
init_typecheck,
|
|
1426
1400
|
parseSkillContent,
|
|
1427
1401
|
init_skill_parser
|
|
1428
|
-
} from "./cli-
|
|
1402
|
+
} from "./cli-ced4azn1.js";
|
|
1429
1403
|
import {
|
|
1430
1404
|
signalProcessGroup,
|
|
1431
1405
|
detachedProcessGroup,
|
|
@@ -1442,17 +1416,17 @@ import {
|
|
|
1442
1416
|
forceRefreshAuthorizationOrThrow,
|
|
1443
1417
|
forceRefreshTokenOrThrow,
|
|
1444
1418
|
init_ensure_token
|
|
1445
|
-
} from "./cli-
|
|
1419
|
+
} from "./cli-5web09sb.js";
|
|
1446
1420
|
import {
|
|
1447
1421
|
PRIMITIVE_KINDS,
|
|
1448
1422
|
ObjectsError,
|
|
1449
1423
|
recordObjectVersion,
|
|
1450
1424
|
init_objects
|
|
1451
|
-
} from "./cli-
|
|
1425
|
+
} from "./cli-j69pzrrz.js";
|
|
1452
1426
|
import {
|
|
1453
1427
|
agentFsClientFor,
|
|
1454
1428
|
init_agent_fs_identity
|
|
1455
|
-
} from "./cli-
|
|
1429
|
+
} from "./cli-zxa1vmx7.js";
|
|
1456
1430
|
import {
|
|
1457
1431
|
FilesError,
|
|
1458
1432
|
normalizeFilesError,
|
|
@@ -1461,7 +1435,7 @@ import {
|
|
|
1461
1435
|
AgentFsProvider,
|
|
1462
1436
|
init_agent_fs_provider
|
|
1463
1437
|
} from "./cli-skd2c4ej.js";
|
|
1464
|
-
import"./cli-
|
|
1438
|
+
import"./cli-r3dxpmyt.js";
|
|
1465
1439
|
import {
|
|
1466
1440
|
automationIntegrationFixUrl,
|
|
1467
1441
|
preflightAutomation,
|
|
@@ -1483,7 +1457,7 @@ import {
|
|
|
1483
1457
|
definitionNodeIds,
|
|
1484
1458
|
validateDefinition,
|
|
1485
1459
|
init_definition2
|
|
1486
|
-
} from "./cli-
|
|
1460
|
+
} from "./cli-cp163xga.js";
|
|
1487
1461
|
import {
|
|
1488
1462
|
_fetchHolder,
|
|
1489
1463
|
CLIENT_ID,
|
|
@@ -1499,7 +1473,7 @@ import {
|
|
|
1499
1473
|
loadAllCodexOAuthSlots,
|
|
1500
1474
|
getValidCodexOAuth,
|
|
1501
1475
|
init_storage
|
|
1502
|
-
} from "./cli-
|
|
1476
|
+
} from "./cli-2vp0z049.js";
|
|
1503
1477
|
import {
|
|
1504
1478
|
isMultiRuntimeEnabled,
|
|
1505
1479
|
init_multi_runtime2
|
|
@@ -1511,7 +1485,7 @@ import {
|
|
|
1511
1485
|
import {
|
|
1512
1486
|
createRuntimeProvider,
|
|
1513
1487
|
init_runtime_providers
|
|
1514
|
-
} from "./cli-
|
|
1488
|
+
} from "./cli-n79j1vxc.js";
|
|
1515
1489
|
import {
|
|
1516
1490
|
require_content_type
|
|
1517
1491
|
} from "./cli-1jx0srjt.js";
|
|
@@ -1525,7 +1499,7 @@ import {
|
|
|
1525
1499
|
toSessionSharesState,
|
|
1526
1500
|
setSessionShares,
|
|
1527
1501
|
init_session_shares
|
|
1528
|
-
} from "./cli-
|
|
1502
|
+
} from "./cli-kwj3131p.js";
|
|
1529
1503
|
import {
|
|
1530
1504
|
isInvalidClientError,
|
|
1531
1505
|
publicEndpointSsrfOptions,
|
|
@@ -1543,7 +1517,7 @@ import {
|
|
|
1543
1517
|
revokeMcpToken,
|
|
1544
1518
|
computeExpiresAt,
|
|
1545
1519
|
init_mcp_wrapper
|
|
1546
|
-
} from "./cli-
|
|
1520
|
+
} from "./cli-b9ygp1kz.js";
|
|
1547
1521
|
import"./cli-v41kn3cd.js";
|
|
1548
1522
|
import {
|
|
1549
1523
|
import_websocket,
|
|
@@ -1579,7 +1553,7 @@ import {
|
|
|
1579
1553
|
revokeAllAgentSessionTokens,
|
|
1580
1554
|
fingerprintApiKey,
|
|
1581
1555
|
init_users
|
|
1582
|
-
} from "./cli-
|
|
1556
|
+
} from "./cli-avax5mp9.js";
|
|
1583
1557
|
import {
|
|
1584
1558
|
CORE_TOOLS,
|
|
1585
1559
|
init_tool_config
|
|
@@ -1592,7 +1566,7 @@ import {
|
|
|
1592
1566
|
providerAccountTelemetrySchema,
|
|
1593
1567
|
rateLimitReplacementSchema,
|
|
1594
1568
|
init_provider_account_telemetry
|
|
1595
|
-
} from "./cli-
|
|
1569
|
+
} from "./cli-fw67mnyc.js";
|
|
1596
1570
|
import {
|
|
1597
1571
|
CODEX_AUTH_FAILURE_BENCH_THRESHOLD,
|
|
1598
1572
|
CODEX_AUTH_WATCH_NAMESPACE,
|
|
@@ -1607,11 +1581,11 @@ import {
|
|
|
1607
1581
|
IDENTITY_FIELD_BUDGETS,
|
|
1608
1582
|
IdentityFieldBudgetError,
|
|
1609
1583
|
init_identity_field_budget
|
|
1610
|
-
} from "./cli-
|
|
1584
|
+
} from "./cli-19d6v8er.js";
|
|
1611
1585
|
import {
|
|
1612
1586
|
getSlackConfiguration,
|
|
1613
|
-
|
|
1614
|
-
} from "./cli-
|
|
1587
|
+
init_config5
|
|
1588
|
+
} from "./cli-t9pzz2eq.js";
|
|
1615
1589
|
import {
|
|
1616
1590
|
isSteeringEnabled2,
|
|
1617
1591
|
init_steering_enabled
|
|
@@ -1629,13 +1603,16 @@ import {
|
|
|
1629
1603
|
isModelScopedWindow,
|
|
1630
1604
|
activeModelBlocks,
|
|
1631
1605
|
init_model_rate_limit_windows,
|
|
1606
|
+
CREDENTIAL_SELECTION_STRATEGIES,
|
|
1607
|
+
credentialSelectionStrategy,
|
|
1608
|
+
init_key_usage,
|
|
1632
1609
|
CREDENTIAL_POOL_VARS,
|
|
1633
1610
|
PROVIDER_CREDENTIAL_VARS,
|
|
1634
1611
|
getModelAwareCredentialVars,
|
|
1635
1612
|
splitCredentialPool,
|
|
1636
1613
|
selectCredential,
|
|
1637
1614
|
init_credentials2
|
|
1638
|
-
} from "./cli-
|
|
1615
|
+
} from "./cli-x2adbg4j.js";
|
|
1639
1616
|
import {
|
|
1640
1617
|
interpolate,
|
|
1641
1618
|
init_template2,
|
|
@@ -1645,7 +1622,7 @@ import {
|
|
|
1645
1622
|
resolveTemplate,
|
|
1646
1623
|
init_resolver,
|
|
1647
1624
|
init_session_templates
|
|
1648
|
-
} from "./cli-
|
|
1625
|
+
} from "./cli-nrt048ys.js";
|
|
1649
1626
|
import {
|
|
1650
1627
|
getOpenRouterAttributionHeaders,
|
|
1651
1628
|
init_openrouter_base_url
|
|
@@ -1678,6 +1655,7 @@ import {
|
|
|
1678
1655
|
AgentTaskStatusSchema,
|
|
1679
1656
|
TERMINAL_TASK_STATUSES,
|
|
1680
1657
|
isTerminalTaskStatus,
|
|
1658
|
+
TaskStatusKindSchema,
|
|
1681
1659
|
AgentTaskSourceSchema,
|
|
1682
1660
|
RoutingReasonSchema,
|
|
1683
1661
|
ProviderNameSchema,
|
|
@@ -1715,6 +1693,7 @@ import {
|
|
|
1715
1693
|
TaskTemplateSchema,
|
|
1716
1694
|
AgentStatusSchema,
|
|
1717
1695
|
AgentAvatarSchema,
|
|
1696
|
+
UserAvatarSchema,
|
|
1718
1697
|
AgentSlackIconSchema,
|
|
1719
1698
|
AgentSchema,
|
|
1720
1699
|
AgentHistoryEventSchema,
|
|
@@ -1736,7 +1715,6 @@ import {
|
|
|
1736
1715
|
AutomationIntegrationIdSchema,
|
|
1737
1716
|
ScheduledTaskTargetTypeSchema,
|
|
1738
1717
|
ScheduledTaskSchema,
|
|
1739
|
-
SwarmConfigSchema,
|
|
1740
1718
|
RepoGuidelinesInputSchema,
|
|
1741
1719
|
RepoHooksSchema,
|
|
1742
1720
|
SwarmRepoSchema,
|
|
@@ -1766,6 +1744,8 @@ import {
|
|
|
1766
1744
|
PageContentTypeSchema,
|
|
1767
1745
|
PageAuthModeSchema,
|
|
1768
1746
|
PageThemeTokensInputSchema,
|
|
1747
|
+
DesignSystemSchema,
|
|
1748
|
+
DesignSystemInputSchema,
|
|
1769
1749
|
PageSchema,
|
|
1770
1750
|
PageVersionSchema,
|
|
1771
1751
|
MetricWidgetSchema,
|
|
@@ -1823,14 +1803,13 @@ import {
|
|
|
1823
1803
|
KvKeySchema,
|
|
1824
1804
|
KvEntrySchema,
|
|
1825
1805
|
init_types5
|
|
1826
|
-
} from "./cli-
|
|
1806
|
+
} from "./cli-7r9tvk8v.js";
|
|
1827
1807
|
import {
|
|
1828
1808
|
init_zod
|
|
1829
1809
|
} from "./cli-96234j5w.js";
|
|
1830
1810
|
import {
|
|
1831
1811
|
NEVER,
|
|
1832
1812
|
toJSONSchema,
|
|
1833
|
-
ZodError,
|
|
1834
1813
|
string2,
|
|
1835
1814
|
email,
|
|
1836
1815
|
uuid,
|
|
@@ -1864,11 +1843,11 @@ import {
|
|
|
1864
1843
|
getPublicMcpBaseUrl,
|
|
1865
1844
|
getAgentFsLiveUrl,
|
|
1866
1845
|
agentFsFileRoute,
|
|
1867
|
-
|
|
1846
|
+
buildAgentFsFileLink,
|
|
1868
1847
|
isCombEnabled,
|
|
1869
1848
|
isAgentFsProxyEnabled,
|
|
1870
1849
|
init_constants3
|
|
1871
|
-
} from "./cli-
|
|
1850
|
+
} from "./cli-grbngev5.js";
|
|
1872
1851
|
import {
|
|
1873
1852
|
parseEnvFlag,
|
|
1874
1853
|
isEnvFlagEnabled,
|
|
@@ -1877,7 +1856,7 @@ import {
|
|
|
1877
1856
|
import {
|
|
1878
1857
|
init_package,
|
|
1879
1858
|
package_default
|
|
1880
|
-
} from "./cli-
|
|
1859
|
+
} from "./cli-hd5bm1e1.js";
|
|
1881
1860
|
import {
|
|
1882
1861
|
realtimeBus,
|
|
1883
1862
|
init_bus
|
|
@@ -1893,7 +1872,7 @@ import {
|
|
|
1893
1872
|
registerVolatileSecret,
|
|
1894
1873
|
registerEnvSecrets,
|
|
1895
1874
|
init_secret_scrubber
|
|
1896
|
-
} from "./cli-
|
|
1875
|
+
} from "./cli-1kvcsd2f.js";
|
|
1897
1876
|
import {
|
|
1898
1877
|
__toESM
|
|
1899
1878
|
} from "./cli-242037k3.js";
|
|
@@ -6396,6 +6375,7 @@ class LocalProcessScriptExecutor {
|
|
|
6396
6375
|
let proc;
|
|
6397
6376
|
let capabilitySocket;
|
|
6398
6377
|
let protocolFailure;
|
|
6378
|
+
let terminated = false;
|
|
6399
6379
|
const sockets = new Set;
|
|
6400
6380
|
const server = createServer2((socket) => {
|
|
6401
6381
|
sockets.add(socket);
|
|
@@ -6593,6 +6573,8 @@ class LocalProcessScriptExecutor {
|
|
|
6593
6573
|
clearInterval(heartbeat);
|
|
6594
6574
|
await terminateProcessGroup(spawned.pid);
|
|
6595
6575
|
let stderr = await stderrPromise;
|
|
6576
|
+
if (terminated)
|
|
6577
|
+
return { exitCode: processExitCode, stderr, terminated: true };
|
|
6596
6578
|
try {
|
|
6597
6579
|
if (protocolFailure)
|
|
6598
6580
|
throw protocolFailure;
|
|
@@ -6626,6 +6608,7 @@ class LocalProcessScriptExecutor {
|
|
|
6626
6608
|
startedAtMs: Date.now(),
|
|
6627
6609
|
exited,
|
|
6628
6610
|
terminate: async (signal = "SIGTERM") => {
|
|
6611
|
+
terminated = true;
|
|
6629
6612
|
built.abortInFlightSteps();
|
|
6630
6613
|
if (signal === "SIGTERM")
|
|
6631
6614
|
await terminateProcessGroup(spawned.pid);
|
|
@@ -6690,7 +6673,9 @@ async function startScriptRunProcess(run, baseUrl, apiKeyOverride) {
|
|
|
6690
6673
|
pid: execution.pid,
|
|
6691
6674
|
lastHeartbeatAt: new Date().toISOString()
|
|
6692
6675
|
});
|
|
6693
|
-
execution.exited.then(async ({ exitCode, stderr }) => {
|
|
6676
|
+
execution.exited.then(async ({ exitCode, stderr, terminated }) => {
|
|
6677
|
+
if (terminated)
|
|
6678
|
+
return;
|
|
6694
6679
|
const current = await getScriptRun2(run.id);
|
|
6695
6680
|
if (current && current.status === "running") {
|
|
6696
6681
|
if (exitCode !== 0) {
|
|
@@ -9317,6 +9302,7 @@ async function aggregateKeyWindowUsage(windows, through) {
|
|
|
9317
9302
|
}
|
|
9318
9303
|
|
|
9319
9304
|
// src/http/api-keys.ts
|
|
9305
|
+
init_key_usage();
|
|
9320
9306
|
init_model_rate_limit_windows();
|
|
9321
9307
|
init_provider_account_telemetry();
|
|
9322
9308
|
init_subscription_plans();
|
|
@@ -9639,7 +9625,11 @@ var getAvailable = route({
|
|
|
9639
9625
|
earliestModelResetAt: string2().nullable().optional(),
|
|
9640
9626
|
seatBlockedIndices: array2(number2().int()).optional(),
|
|
9641
9627
|
spendCappedIndices: array2(number2().int()),
|
|
9642
|
-
authFailureFence: number2().int()
|
|
9628
|
+
authFailureFence: number2().int(),
|
|
9629
|
+
keyUsage: array2(number2()),
|
|
9630
|
+
keyPace: array2(number2()),
|
|
9631
|
+
selectionStrategy: _enum2(CREDENTIAL_SELECTION_STRATEGIES),
|
|
9632
|
+
activeSessions: array2(number2().int().min(0))
|
|
9643
9633
|
})
|
|
9644
9634
|
},
|
|
9645
9635
|
400: { description: "Validation error" },
|
|
@@ -10009,6 +9999,10 @@ async function handleApiKeys(req, res, pathSegments, queryParams) {
|
|
|
10009
9999
|
spendCappedIndices: result.spendCappedIndices,
|
|
10010
10000
|
totalKeys,
|
|
10011
10001
|
authFailureFence: result.authFailureFence,
|
|
10002
|
+
keyUsage: result.keyUsage,
|
|
10003
|
+
keyPace: result.keyPace,
|
|
10004
|
+
selectionStrategy: credentialSelectionStrategy(process.env.CREDENTIAL_SELECTION_STRATEGY),
|
|
10005
|
+
activeSessions: result.activeSessions,
|
|
10012
10006
|
...model !== undefined ? {
|
|
10013
10007
|
modelBlockedIndices: result.modelBlockedIndices,
|
|
10014
10008
|
earliestModelResetAt: result.earliestModelResetAt,
|
|
@@ -10172,1623 +10166,8 @@ async function handleApiKeys(req, res, pathSegments, queryParams) {
|
|
|
10172
10166
|
return false;
|
|
10173
10167
|
}
|
|
10174
10168
|
|
|
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
10169
|
// src/http/index.ts
|
|
10170
|
+
init_approval_requests();
|
|
11792
10171
|
init_apps();
|
|
11793
10172
|
|
|
11794
10173
|
// src/http/assets.ts
|
|
@@ -11804,6 +10183,27 @@ init_db3();
|
|
|
11804
10183
|
init_session_shares();
|
|
11805
10184
|
init_rbac();
|
|
11806
10185
|
init_types5();
|
|
10186
|
+
|
|
10187
|
+
// src/http/asset-key-write.ts
|
|
10188
|
+
init_asset_key_auth();
|
|
10189
|
+
init_audit_user();
|
|
10190
|
+
init_users();
|
|
10191
|
+
init_request_auth_context();
|
|
10192
|
+
init_favorite_owner();
|
|
10193
|
+
async function resolveDashboardUserId(req, callerAgentId) {
|
|
10194
|
+
const auth = getRequestAuth(req);
|
|
10195
|
+
if (!isOperatorAuth(auth) || auth.page || callerAgentId || req.headers["x-agent-id"])
|
|
10196
|
+
return null;
|
|
10197
|
+
const picked = dashboardUserIdHeader(req);
|
|
10198
|
+
const user = picked ? await findUserById(picked) : null;
|
|
10199
|
+
return user?.status === "active" ? user.id : null;
|
|
10200
|
+
}
|
|
10201
|
+
async function authorizeHttpAssetKeyWrite(req, callerAgentId, key, trustedUserId) {
|
|
10202
|
+
const requester = trustedUserId === undefined ? await resolveHttpRequesterUserId(req, callerAgentId) : trustedUserId;
|
|
10203
|
+
return authorizeAssetKeyWrite(key, requester ?? await resolveDashboardUserId(req, callerAgentId));
|
|
10204
|
+
}
|
|
10205
|
+
|
|
10206
|
+
// src/http/assets.ts
|
|
11807
10207
|
init_request_principal();
|
|
11808
10208
|
init_route_def();
|
|
11809
10209
|
init_session_access();
|
|
@@ -12017,7 +10417,7 @@ async function handleAssets(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
12017
10417
|
return true;
|
|
12018
10418
|
try {
|
|
12019
10419
|
const actor = await resolveHttpRequesterUserId(req, myAgentId);
|
|
12020
|
-
const key = parsed.body.key ? await
|
|
10420
|
+
const key = parsed.body.key ? await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key, actor) : undefined;
|
|
12021
10421
|
const mapping = await upsertAssetKeyMapping2({
|
|
12022
10422
|
providerId: parsed.body.providerId,
|
|
12023
10423
|
providerOrgId: parsed.body.orgId,
|
|
@@ -12100,7 +10500,7 @@ async function handleAssets(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
12100
10500
|
}
|
|
12101
10501
|
try {
|
|
12102
10502
|
const actor = await resolveHttpRequesterUserId(req, myAgentId);
|
|
12103
|
-
const key = await
|
|
10503
|
+
const key = await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key, actor);
|
|
12104
10504
|
const moved = await moveAssetKey2({
|
|
12105
10505
|
entityType: parsed.params.entityType,
|
|
12106
10506
|
id: parsed.params.id,
|
|
@@ -12308,7 +10708,7 @@ init_constants3();
|
|
|
12308
10708
|
init_env_flag();
|
|
12309
10709
|
init_secret_scrubber();
|
|
12310
10710
|
init_adapters();
|
|
12311
|
-
|
|
10711
|
+
init_config2();
|
|
12312
10712
|
|
|
12313
10713
|
// src/integrations/chat-sdk/discord-api.ts
|
|
12314
10714
|
init_secret_scrubber();
|
|
@@ -12898,6 +11298,7 @@ init_auth_json();
|
|
|
12898
11298
|
init_flow();
|
|
12899
11299
|
init_storage();
|
|
12900
11300
|
init_codex_auth_failure();
|
|
11301
|
+
init_config();
|
|
12901
11302
|
init_route_def();
|
|
12902
11303
|
init_utils2();
|
|
12903
11304
|
var CodexAccountSchema = object2({
|
|
@@ -13797,6 +12198,7 @@ async function exchangeDeviceAuthorizationCode(authorizationCode, codeVerifier)
|
|
|
13797
12198
|
// src/http/codex-oauth-device.ts
|
|
13798
12199
|
init_storage();
|
|
13799
12200
|
init_secret_scrubber();
|
|
12201
|
+
init_config();
|
|
13800
12202
|
init_route_def();
|
|
13801
12203
|
init_utils2();
|
|
13802
12204
|
var FLOW_TTL_MS = 15 * 60 * 1000;
|
|
@@ -14172,7 +12574,7 @@ async function handleCodexOAuthKeepWarm(req, res, pathSegments) {
|
|
|
14172
12574
|
// src/http/comb.ts
|
|
14173
12575
|
init_zod();
|
|
14174
12576
|
init_audit_user();
|
|
14175
|
-
|
|
12577
|
+
init_config4();
|
|
14176
12578
|
|
|
14177
12579
|
// src/comb/review-batch.ts
|
|
14178
12580
|
init_db4();
|
|
@@ -14212,7 +12614,7 @@ async function getCombServiceUserId() {
|
|
|
14212
12614
|
}
|
|
14213
12615
|
|
|
14214
12616
|
// src/comb/review-batch.ts
|
|
14215
|
-
|
|
12617
|
+
init_config4();
|
|
14216
12618
|
|
|
14217
12619
|
// src/comb/markers.ts
|
|
14218
12620
|
var SENT_MARKER_PREFIX = "[comb:sent task=";
|
|
@@ -14690,6 +13092,9 @@ async function handleComb(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
14690
13092
|
return true;
|
|
14691
13093
|
}
|
|
14692
13094
|
|
|
13095
|
+
// src/http/index.ts
|
|
13096
|
+
init_config();
|
|
13097
|
+
|
|
14693
13098
|
// src/http/context.ts
|
|
14694
13099
|
init_zod();
|
|
14695
13100
|
init_db4();
|
|
@@ -14807,6 +13212,95 @@ async function handleContext(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
14807
13212
|
init_core();
|
|
14808
13213
|
init_db_query();
|
|
14809
13214
|
|
|
13215
|
+
// src/http/design-system.ts
|
|
13216
|
+
init_zod();
|
|
13217
|
+
init_design_system2();
|
|
13218
|
+
init_rbac();
|
|
13219
|
+
init_design_system();
|
|
13220
|
+
init_types5();
|
|
13221
|
+
init_request_principal();
|
|
13222
|
+
init_route_def();
|
|
13223
|
+
init_utils2();
|
|
13224
|
+
var DesignSystemStateSchema = object2({
|
|
13225
|
+
status: _enum2(["none", "invalid", "active", "declined"]),
|
|
13226
|
+
designSystem: DesignSystemSchema.nullable(),
|
|
13227
|
+
invalidReason: string2().optional(),
|
|
13228
|
+
previous: DesignSystemSchema.nullable()
|
|
13229
|
+
});
|
|
13230
|
+
var getDesignSystemRoute = route({
|
|
13231
|
+
method: "get",
|
|
13232
|
+
path: "/api/design-system",
|
|
13233
|
+
pattern: ["api", "design-system"],
|
|
13234
|
+
summary: "Get the org design system",
|
|
13235
|
+
tags: ["Pages"],
|
|
13236
|
+
responses: {
|
|
13237
|
+
200: {
|
|
13238
|
+
description: "The org design system and the value it replaced",
|
|
13239
|
+
schema: DesignSystemStateSchema
|
|
13240
|
+
}
|
|
13241
|
+
}
|
|
13242
|
+
});
|
|
13243
|
+
var putDesignSystemRoute = route({
|
|
13244
|
+
method: "put",
|
|
13245
|
+
path: "/api/design-system",
|
|
13246
|
+
pattern: ["api", "design-system"],
|
|
13247
|
+
summary: "Set or decline the org design system",
|
|
13248
|
+
tags: ["Pages"],
|
|
13249
|
+
rbac: { permission: "design-system.write" },
|
|
13250
|
+
body: DesignSystemInputSchema,
|
|
13251
|
+
responses: {
|
|
13252
|
+
200: {
|
|
13253
|
+
description: "The saved, normalized design system",
|
|
13254
|
+
schema: object2({ designSystem: DesignSystemSchema, ignoredTokens: array2(string2()) })
|
|
13255
|
+
},
|
|
13256
|
+
400: { description: "Invalid design system" },
|
|
13257
|
+
403: { description: "Permission denied" }
|
|
13258
|
+
}
|
|
13259
|
+
});
|
|
13260
|
+
function recordOf(stored) {
|
|
13261
|
+
return "record" in stored ? stored.record : null;
|
|
13262
|
+
}
|
|
13263
|
+
async function handleDesignSystem(req, res, pathSegments, queryParams, myAgentId) {
|
|
13264
|
+
if (getDesignSystemRoute.match(req.method, pathSegments)) {
|
|
13265
|
+
const parsed = await getDesignSystemRoute.parse(req, res, pathSegments, queryParams);
|
|
13266
|
+
if (!parsed)
|
|
13267
|
+
return true;
|
|
13268
|
+
const { current, previous } = await getDesignSystem();
|
|
13269
|
+
getDesignSystemRoute.respond(res, 200, {
|
|
13270
|
+
status: current.status,
|
|
13271
|
+
designSystem: recordOf(current),
|
|
13272
|
+
..."reason" in current ? { invalidReason: current.reason } : {},
|
|
13273
|
+
previous: recordOf(previous)
|
|
13274
|
+
});
|
|
13275
|
+
return true;
|
|
13276
|
+
}
|
|
13277
|
+
if (putDesignSystemRoute.match(req.method, pathSegments)) {
|
|
13278
|
+
const parsed = await putDesignSystemRoute.parse(req, res, pathSegments, queryParams);
|
|
13279
|
+
if (!parsed)
|
|
13280
|
+
return true;
|
|
13281
|
+
const principal = await agentFirstPrincipal(req, myAgentId);
|
|
13282
|
+
const decision = can({ principal, verb: "design-system.write", source: "http" });
|
|
13283
|
+
if (!decision.allow) {
|
|
13284
|
+
jsonError(res, decision.reason, 403);
|
|
13285
|
+
return true;
|
|
13286
|
+
}
|
|
13287
|
+
try {
|
|
13288
|
+
const { record, ignored } = buildDesignSystem(parsed.body, {
|
|
13289
|
+
userId: principal.kind === "user" ? principal.userId : null,
|
|
13290
|
+
...principal.kind === "agent" ? { agentId: principal.agentId } : {}
|
|
13291
|
+
});
|
|
13292
|
+
await saveDesignSystem(record);
|
|
13293
|
+
putDesignSystemRoute.respond(res, 200, { designSystem: record, ignoredTokens: ignored });
|
|
13294
|
+
} catch (err) {
|
|
13295
|
+
if (!(err instanceof DesignSystemError))
|
|
13296
|
+
throw err;
|
|
13297
|
+
jsonError(res, err.message, 400);
|
|
13298
|
+
}
|
|
13299
|
+
return true;
|
|
13300
|
+
}
|
|
13301
|
+
return false;
|
|
13302
|
+
}
|
|
13303
|
+
|
|
14810
13304
|
// src/http/events.ts
|
|
14811
13305
|
init_zod();
|
|
14812
13306
|
init_events();
|
|
@@ -15026,6 +13520,7 @@ declare module "swarm-extension" {
|
|
|
15026
13520
|
| "chat"
|
|
15027
13521
|
| "workflow"
|
|
15028
13522
|
| "schedule"
|
|
13523
|
+
| "system"
|
|
15029
13524
|
| "slack"
|
|
15030
13525
|
| "agentmail"
|
|
15031
13526
|
| "mcp"
|
|
@@ -15035,7 +13530,6 @@ declare module "swarm-extension" {
|
|
|
15035
13530
|
| "gitlab"
|
|
15036
13531
|
| "azure-devops"
|
|
15037
13532
|
| "bitbucket"
|
|
15038
|
-
| "system"
|
|
15039
13533
|
| "linear"
|
|
15040
13534
|
| "jira"
|
|
15041
13535
|
| "comb"
|
|
@@ -15177,6 +13671,7 @@ declare module "swarm-extension" {
|
|
|
15177
13671
|
| "chat"
|
|
15178
13672
|
| "workflow"
|
|
15179
13673
|
| "schedule"
|
|
13674
|
+
| "system"
|
|
15180
13675
|
| "slack"
|
|
15181
13676
|
| "agentmail"
|
|
15182
13677
|
| "mcp"
|
|
@@ -15186,7 +13681,6 @@ declare module "swarm-extension" {
|
|
|
15186
13681
|
| "gitlab"
|
|
15187
13682
|
| "azure-devops"
|
|
15188
13683
|
| "bitbucket"
|
|
15189
|
-
| "system"
|
|
15190
13684
|
| "linear"
|
|
15191
13685
|
| "jira"
|
|
15192
13686
|
| "comb";
|
|
@@ -15216,6 +13710,23 @@ declare module "swarm-extension" {
|
|
|
15216
13710
|
rejectionReason?: string | undefined;
|
|
15217
13711
|
finishedAt?: string | undefined;
|
|
15218
13712
|
notifiedAt?: string | undefined;
|
|
13713
|
+
statusKind?:
|
|
13714
|
+
| "error"
|
|
13715
|
+
| "workflow"
|
|
13716
|
+
| "external"
|
|
13717
|
+
| "agent"
|
|
13718
|
+
| "runner"
|
|
13719
|
+
| "deferred"
|
|
13720
|
+
| "cascade"
|
|
13721
|
+
| "user"
|
|
13722
|
+
| "system"
|
|
13723
|
+
| "graceful_shutdown"
|
|
13724
|
+
| "context_limits"
|
|
13725
|
+
| "manual_supersede"
|
|
13726
|
+
| "crash_recovery"
|
|
13727
|
+
| "provider_fallback"
|
|
13728
|
+
| "workflow_retry"
|
|
13729
|
+
| undefined;
|
|
15219
13730
|
failureReason?: string | undefined;
|
|
15220
13731
|
output?: string | undefined;
|
|
15221
13732
|
progress?: string | undefined;
|
|
@@ -18308,7 +16819,7 @@ var catalogRoute = route({
|
|
|
18308
16819
|
}
|
|
18309
16820
|
}
|
|
18310
16821
|
});
|
|
18311
|
-
var
|
|
16822
|
+
var listRoute = route({
|
|
18312
16823
|
method: "get",
|
|
18313
16824
|
path: "/api/extensions",
|
|
18314
16825
|
pattern: ["api", "extensions"],
|
|
@@ -18629,11 +17140,11 @@ async function handleExtensions(req, res, pathSegments, queryParams, agentId) {
|
|
|
18629
17140
|
});
|
|
18630
17141
|
return true;
|
|
18631
17142
|
}
|
|
18632
|
-
if (
|
|
18633
|
-
const parsed = await
|
|
17143
|
+
if (listRoute.match(req.method, pathSegments)) {
|
|
17144
|
+
const parsed = await listRoute.parse(req, res, pathSegments, queryParams);
|
|
18634
17145
|
if (!parsed)
|
|
18635
17146
|
return true;
|
|
18636
|
-
|
|
17147
|
+
listRoute.respond(res, 200, { extensions: (await listExtensions()).map(redactExtension) });
|
|
18637
17148
|
return true;
|
|
18638
17149
|
}
|
|
18639
17150
|
if (catalogRoute.match(req.method, pathSegments)) {
|
|
@@ -19068,12 +17579,14 @@ async function getLocalFleetStats(now = new Date, { requireIngestAnchor = true }
|
|
|
19068
17579
|
init_telemetry();
|
|
19069
17580
|
init_company_profile();
|
|
19070
17581
|
init_org_website();
|
|
17582
|
+
init_global_config();
|
|
19071
17583
|
init_request_principal();
|
|
19072
17584
|
init_route_def();
|
|
17585
|
+
init_used_by();
|
|
19073
17586
|
var FLEET_TTL_MS = 24 * 60 * 60 * 1000;
|
|
19074
17587
|
var FLEET_FAILURE_TTL_MS = 60 * 60 * 1000;
|
|
19075
17588
|
var LOCAL_TTL_MS = 10 * 60 * 1000;
|
|
19076
|
-
var
|
|
17589
|
+
var TIMEOUT_MS = 1e4;
|
|
19077
17590
|
var FleetStateSchema = _enum2([
|
|
19078
17591
|
"ready",
|
|
19079
17592
|
"telemetry_off",
|
|
@@ -19167,7 +17680,7 @@ async function fleetBenchmarks(now, peerGroup) {
|
|
|
19167
17680
|
return fleetCache.value;
|
|
19168
17681
|
let value = null;
|
|
19169
17682
|
try {
|
|
19170
|
-
const response = await fetch(key, { signal: AbortSignal.timeout(
|
|
17683
|
+
const response = await fetch(key, { signal: AbortSignal.timeout(TIMEOUT_MS) });
|
|
19171
17684
|
if (response.ok) {
|
|
19172
17685
|
const parsed = ProxyFleetBenchmarksSchema.safeParse(await response.json());
|
|
19173
17686
|
if (parsed.success)
|
|
@@ -19407,7 +17920,7 @@ init_rbac_roles();
|
|
|
19407
17920
|
init_agent_fs_provision();
|
|
19408
17921
|
init_task_attachment_store();
|
|
19409
17922
|
init_users();
|
|
19410
|
-
|
|
17923
|
+
init_config4();
|
|
19411
17924
|
init_provider();
|
|
19412
17925
|
init_registry2();
|
|
19413
17926
|
init_rbac();
|
|
@@ -20037,7 +18550,7 @@ async function sendUpload(req, res, taskId, query, agentId, isDraft) {
|
|
|
20037
18550
|
return true;
|
|
20038
18551
|
}
|
|
20039
18552
|
const provider = getFileStorageProvider2();
|
|
20040
|
-
const contentType =
|
|
18553
|
+
const contentType = singleHeader(req, "content-type") ?? "application/octet-stream";
|
|
20041
18554
|
const scope = { taskId, name: query.name };
|
|
20042
18555
|
let uploaded;
|
|
20043
18556
|
const uploadStartedAt = performance.now();
|
|
@@ -20190,7 +18703,7 @@ async function readRawBody(req, maxBytes) {
|
|
|
20190
18703
|
}
|
|
20191
18704
|
return Buffer.concat(chunks);
|
|
20192
18705
|
}
|
|
20193
|
-
function
|
|
18706
|
+
function singleHeader(req, name) {
|
|
20194
18707
|
const raw = req.headers[name];
|
|
20195
18708
|
return Array.isArray(raw) ? raw[0] : raw;
|
|
20196
18709
|
}
|
|
@@ -20221,21 +18734,27 @@ var installationTokenRoute = route({
|
|
|
20221
18734
|
path: "/api/github/installation-token",
|
|
20222
18735
|
pattern: ["api", "github", "installation-token"],
|
|
20223
18736
|
summary: "Mint a GitHub App installation token for worker git and gh",
|
|
20224
|
-
description: "Internal worker endpoint. Returns a short-lived installation token for
|
|
18737
|
+
description: "Internal worker endpoint. Returns a short-lived installation token for worker `git` and `gh`. With a `repo` (`owner/name`) whose owner is listed in the deployment env `GITHUB_APP_REPO_OWNERS`, the API resolves that repository's App installation with the App JWT and mints for it; the repository must also be registered in `swarm_repos` on the configured GitHub host (403 otherwise). Any other call mints for the installation in `GITHUB_APP_INSTALLATION_ID`, so single-installation deployments are unchanged and a caller never picks an installation the operator did not list. Only a registered agent (swarm API key plus X-Agent-ID, or an agent or runtime token) may call it; user, guest and ACP task tokens are refused. 404 when the App is not configured, so workers fall back to `GITHUB_TOKEN`.",
|
|
20225
18738
|
tags: ["GitHub"],
|
|
20226
|
-
body: object2({
|
|
18739
|
+
body: object2({
|
|
18740
|
+
repo: string2().max(200).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/, "repo must be `owner/name` (letters, digits, dot, dash, underscore)").optional()
|
|
18741
|
+
}).optional(),
|
|
20227
18742
|
responses: {
|
|
20228
18743
|
200: {
|
|
20229
18744
|
description: "Installation token and its expiry (ISO 8601)",
|
|
20230
18745
|
schema: object2({ token: string2(), expiresAt: string2() })
|
|
20231
18746
|
},
|
|
20232
|
-
403: {
|
|
18747
|
+
403: {
|
|
18748
|
+
description: "Caller is not a registered agent, or the repo of a listed owner is not registered in the swarm"
|
|
18749
|
+
},
|
|
20233
18750
|
404: { description: "GitHub App worker auth is not configured" },
|
|
20234
|
-
502: {
|
|
18751
|
+
502: {
|
|
18752
|
+
description: "GitHub refused or failed to mint the token, or the repo has no App installation"
|
|
18753
|
+
}
|
|
20235
18754
|
},
|
|
20236
18755
|
auth: { apiKey: true, agentId: true },
|
|
20237
18756
|
rbac: {
|
|
20238
|
-
ungated: "the handler admits only registered agent principals and mints for
|
|
18757
|
+
ungated: "the handler admits only registered agent principals and mints only for the fixed installation or the installation of a registered repo whose owner the deployment env lists"
|
|
20239
18758
|
}
|
|
20240
18759
|
});
|
|
20241
18760
|
async function handleGitHubToken(req, res, pathSegments, myAgentId) {
|
|
@@ -20254,11 +18773,15 @@ async function handleGitHubToken(req, res, pathSegments, myAgentId) {
|
|
|
20254
18773
|
jsonError(res, "Only a registered agent may mint a GitHub installation token", 403);
|
|
20255
18774
|
return true;
|
|
20256
18775
|
}
|
|
20257
|
-
const result = await getWorkerInstallationToken();
|
|
18776
|
+
const result = await getWorkerInstallationToken(parsed.body?.repo);
|
|
20258
18777
|
if (result.status === "unconfigured") {
|
|
20259
18778
|
jsonError(res, "GitHub App worker auth is not configured", 404);
|
|
20260
18779
|
return true;
|
|
20261
18780
|
}
|
|
18781
|
+
if (result.status === "forbidden") {
|
|
18782
|
+
jsonError(res, "The repo is not registered in the swarm", 403);
|
|
18783
|
+
return true;
|
|
18784
|
+
}
|
|
20262
18785
|
if (result.status === "error") {
|
|
20263
18786
|
jsonError(res, "GitHub did not mint an installation token", 502);
|
|
20264
18787
|
return true;
|
|
@@ -20340,8 +18863,10 @@ async function handleHeartbeat(req, res, pathSegments) {
|
|
|
20340
18863
|
init_zod();
|
|
20341
18864
|
init_improvements();
|
|
20342
18865
|
init_rbac();
|
|
18866
|
+
init_person_responder();
|
|
20343
18867
|
init_request_principal();
|
|
20344
18868
|
init_route_def();
|
|
18869
|
+
init_used_by();
|
|
20345
18870
|
init_utils2();
|
|
20346
18871
|
var ImprovementSchema = object2({
|
|
20347
18872
|
id: string2(),
|
|
@@ -20362,7 +18887,7 @@ var ImprovementSchema = object2({
|
|
|
20362
18887
|
});
|
|
20363
18888
|
var EmailSchema = string2().max(320, "Email must be at most 320 characters").email("Email must be a valid email address");
|
|
20364
18889
|
var PERSON_REFUSED = "Agents cannot approve improvements. A person must approve with a user token or the dashboard.";
|
|
20365
|
-
var
|
|
18890
|
+
var listRoute2 = route({
|
|
20366
18891
|
method: "get",
|
|
20367
18892
|
path: "/api/improvements",
|
|
20368
18893
|
pattern: ["api", "improvements"],
|
|
@@ -20377,7 +18902,7 @@ var listRoute3 = route({
|
|
|
20377
18902
|
},
|
|
20378
18903
|
auth: { apiKey: true }
|
|
20379
18904
|
});
|
|
20380
|
-
var
|
|
18905
|
+
var createRoute = route({
|
|
20381
18906
|
method: "post",
|
|
20382
18907
|
path: "/api/improvements",
|
|
20383
18908
|
pattern: ["api", "improvements"],
|
|
@@ -20474,19 +18999,19 @@ async function improvementsEndpoint() {
|
|
|
20474
18999
|
return telemetryProxyEndpoint("/v1/improvements");
|
|
20475
19000
|
}
|
|
20476
19001
|
async function handleImprovements(req, res, pathSegments, queryParams) {
|
|
20477
|
-
if (
|
|
20478
|
-
const parsed = await
|
|
19002
|
+
if (listRoute2.match(req.method, pathSegments)) {
|
|
19003
|
+
const parsed = await listRoute2.parse(req, res, pathSegments, queryParams);
|
|
20479
19004
|
if (!parsed)
|
|
20480
19005
|
return true;
|
|
20481
19006
|
const rows = await listImprovements();
|
|
20482
|
-
|
|
19007
|
+
listRoute2.respond(res, 200, {
|
|
20483
19008
|
enabled: await isImprovementsEnabled(),
|
|
20484
19009
|
improvements: await Promise.all(rows.map(withLeakHints))
|
|
20485
19010
|
});
|
|
20486
19011
|
return true;
|
|
20487
19012
|
}
|
|
20488
|
-
if (
|
|
20489
|
-
const parsed = await
|
|
19013
|
+
if (createRoute.match(req.method, pathSegments)) {
|
|
19014
|
+
const parsed = await createRoute.parse(req, res, pathSegments, queryParams);
|
|
20490
19015
|
if (!parsed)
|
|
20491
19016
|
return true;
|
|
20492
19017
|
const { text, email, sendNow, source } = parsed.body;
|
|
@@ -20521,11 +19046,11 @@ async function handleImprovements(req, res, pathSegments, queryParams) {
|
|
|
20521
19046
|
endpoint: await improvementsEndpoint(),
|
|
20522
19047
|
updatedBy: person.responder.kind === "user" ? person.responder.user.id : null
|
|
20523
19048
|
});
|
|
20524
|
-
|
|
19049
|
+
createRoute.respond(res, 200, { improvement: sent });
|
|
20525
19050
|
return true;
|
|
20526
19051
|
}
|
|
20527
19052
|
}
|
|
20528
|
-
|
|
19053
|
+
createRoute.respond(res, 201, { improvement: await withLeakHints(improvement) });
|
|
20529
19054
|
} catch (error) {
|
|
20530
19055
|
if (!writeImprovementError(res, error))
|
|
20531
19056
|
throw error;
|
|
@@ -20922,6 +19447,7 @@ function buildSlackManifest(name) {
|
|
|
20922
19447
|
|
|
20923
19448
|
// src/http/integrations.ts
|
|
20924
19449
|
init_credentials2();
|
|
19450
|
+
init_config();
|
|
20925
19451
|
|
|
20926
19452
|
// src/http/config-values.ts
|
|
20927
19453
|
init_db4();
|
|
@@ -21322,14 +19848,14 @@ function decodeKvSegment(res, raw, label) {
|
|
|
21322
19848
|
}
|
|
21323
19849
|
return decoded;
|
|
21324
19850
|
}
|
|
21325
|
-
function
|
|
19851
|
+
function singleHeader2(req, name) {
|
|
21326
19852
|
const raw = req.headers[name];
|
|
21327
19853
|
if (raw === undefined)
|
|
21328
19854
|
return;
|
|
21329
19855
|
return Array.isArray(raw) ? raw[0] : raw;
|
|
21330
19856
|
}
|
|
21331
19857
|
async function resolveNamespaceFromHeaders(req) {
|
|
21332
|
-
const pageId =
|
|
19858
|
+
const pageId = singleHeader2(req, "x-page-id");
|
|
21333
19859
|
if (pageId) {
|
|
21334
19860
|
try {
|
|
21335
19861
|
return pageContextKey({ pageId });
|
|
@@ -21337,7 +19863,7 @@ async function resolveNamespaceFromHeaders(req) {
|
|
|
21337
19863
|
return null;
|
|
21338
19864
|
}
|
|
21339
19865
|
}
|
|
21340
|
-
const sourceTaskId =
|
|
19866
|
+
const sourceTaskId = singleHeader2(req, "x-source-task-id");
|
|
21341
19867
|
if (sourceTaskId) {
|
|
21342
19868
|
const task = await getTaskById2(sourceTaskId);
|
|
21343
19869
|
if (task?.contextKey)
|
|
@@ -21348,7 +19874,7 @@ async function resolveNamespaceFromHeaders(req) {
|
|
|
21348
19874
|
} catch {}
|
|
21349
19875
|
}
|
|
21350
19876
|
}
|
|
21351
|
-
const agentId =
|
|
19877
|
+
const agentId = singleHeader2(req, "x-agent-id");
|
|
21352
19878
|
if (agentId) {
|
|
21353
19879
|
try {
|
|
21354
19880
|
return agentContextKey({ agentId });
|
|
@@ -21359,8 +19885,8 @@ async function resolveNamespaceFromHeaders(req) {
|
|
|
21359
19885
|
return null;
|
|
21360
19886
|
}
|
|
21361
19887
|
async function buildAuthCtx(req) {
|
|
21362
|
-
const callerAgentId =
|
|
21363
|
-
const pageId =
|
|
19888
|
+
const callerAgentId = singleHeader2(req, "x-agent-id");
|
|
19889
|
+
const pageId = singleHeader2(req, "x-page-id");
|
|
21364
19890
|
let isLead = false;
|
|
21365
19891
|
if (callerAgentId) {
|
|
21366
19892
|
const agent = await getAgentById2(callerAgentId);
|
|
@@ -21447,7 +19973,7 @@ function encodeValueOrError(res, value, valueType) {
|
|
|
21447
19973
|
}
|
|
21448
19974
|
}
|
|
21449
19975
|
async function handleKv(req, res, pathSegments, queryParams) {
|
|
21450
|
-
const hasPageHeader =
|
|
19976
|
+
const hasPageHeader = singleHeader2(req, "x-page-id") !== undefined;
|
|
21451
19977
|
if (hasPageHeader && pathSegments[0] === "api" && pathSegments[1] === "kv" && pathSegments[2] === "_") {
|
|
21452
19978
|
pathSegments = [pathSegments[0], pathSegments[1], ...pathSegments.slice(4)];
|
|
21453
19979
|
}
|
|
@@ -24311,12 +22837,12 @@ async function canResolveMcpSecretsForHttpUser(req) {
|
|
|
24311
22837
|
});
|
|
24312
22838
|
return decision.allow;
|
|
24313
22839
|
}
|
|
24314
|
-
function
|
|
22840
|
+
function singleHeader3(req, name) {
|
|
24315
22841
|
const raw = req.headers[name];
|
|
24316
22842
|
return Array.isArray(raw) ? raw[0] : raw;
|
|
24317
22843
|
}
|
|
24318
22844
|
async function mcpServerPrincipal(req) {
|
|
24319
|
-
return agentFirstPrincipal(req,
|
|
22845
|
+
return agentFirstPrincipal(req, singleHeader3(req, "x-agent-id"), {
|
|
24320
22846
|
unauthenticatedFallback: "anonymous-agent"
|
|
24321
22847
|
});
|
|
24322
22848
|
}
|
|
@@ -28730,7 +27256,7 @@ async function open(id) {
|
|
|
28730
27256
|
const scope = { taskId: "", name: "", key: row.path, orgId: row.orgId, driveId: row.driveId };
|
|
28731
27257
|
return { row, owner: row.ownerAgentId, provider: client.provider, scope };
|
|
28732
27258
|
}
|
|
28733
|
-
var withLink = (row) => ({ ...row, link:
|
|
27259
|
+
var withLink = (row) => ({ ...row, link: buildAgentFsFileLink(row) });
|
|
28734
27260
|
async function driveWatched(orgId, driveId) {
|
|
28735
27261
|
const hook = await getDbClient2().get("SELECT status FROM agent_fs_object_webhooks WHERE orgId = ? AND driveId = ?", [orgId, driveId]);
|
|
28736
27262
|
return hook?.status === "active";
|
|
@@ -29069,6 +27595,7 @@ init_constants3();
|
|
|
29069
27595
|
init_credentials2();
|
|
29070
27596
|
init_egress_guard();
|
|
29071
27597
|
init_openrouter_base_url();
|
|
27598
|
+
init_config();
|
|
29072
27599
|
init_core();
|
|
29073
27600
|
init_route_def();
|
|
29074
27601
|
|
|
@@ -29095,9 +27622,9 @@ async function getInstanceFeedbackSignals() {
|
|
|
29095
27622
|
|
|
29096
27623
|
// src/http/status.ts
|
|
29097
27624
|
init_memory();
|
|
29098
|
-
init_config3();
|
|
29099
|
-
init_registry2();
|
|
29100
27625
|
init_config4();
|
|
27626
|
+
init_registry2();
|
|
27627
|
+
init_config5();
|
|
29101
27628
|
init_connection_state();
|
|
29102
27629
|
init_telemetry();
|
|
29103
27630
|
init_types5();
|
|
@@ -30221,12 +28748,13 @@ async function handlePageProxy(req, res) {
|
|
|
30221
28748
|
// src/http/pages.ts
|
|
30222
28749
|
init_zod();
|
|
30223
28750
|
init_asset_key_auth();
|
|
30224
|
-
init_audit_user();
|
|
30225
28751
|
init_db4();
|
|
30226
28752
|
init_page_versions();
|
|
30227
28753
|
init_version3();
|
|
30228
28754
|
init_resolver();
|
|
28755
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
30229
28756
|
init_session_templates();
|
|
28757
|
+
init_rbac();
|
|
30230
28758
|
init_sibling_awareness();
|
|
30231
28759
|
init_page_fields();
|
|
30232
28760
|
init_presets();
|
|
@@ -30235,8 +28763,8 @@ init_constants3();
|
|
|
30235
28763
|
init_page_session();
|
|
30236
28764
|
init_request_auth_context();
|
|
30237
28765
|
init_favorite_owner();
|
|
28766
|
+
init_request_principal();
|
|
30238
28767
|
init_route_def();
|
|
30239
|
-
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
30240
28768
|
|
|
30241
28769
|
// src/http/tasks.ts
|
|
30242
28770
|
init_zod();
|
|
@@ -30264,6 +28792,7 @@ init_business_use();
|
|
|
30264
28792
|
init_request_auth_context();
|
|
30265
28793
|
init_secret_scrubber();
|
|
30266
28794
|
init_vcs_repo_match();
|
|
28795
|
+
init_config();
|
|
30267
28796
|
|
|
30268
28797
|
// src/http/list-total-cache.ts
|
|
30269
28798
|
var LIST_TOTAL_TTL_MS = 30000;
|
|
@@ -30440,6 +28969,7 @@ var AgentTaskSummarySchema = AgentTaskSchema.pick({
|
|
|
30440
28969
|
createdAt: true,
|
|
30441
28970
|
lastUpdatedAt: true,
|
|
30442
28971
|
finishedAt: true,
|
|
28972
|
+
statusKind: true,
|
|
30443
28973
|
peakContextPercent: true,
|
|
30444
28974
|
totalCostUsd: true
|
|
30445
28975
|
});
|
|
@@ -30508,6 +29038,7 @@ var listTasks = route({
|
|
|
30508
29038
|
tags: ["Tasks"],
|
|
30509
29039
|
query: object2({
|
|
30510
29040
|
status: string2().optional(),
|
|
29041
|
+
statusKind: TaskStatusKindSchema.optional().describe("Why the task ended, e.g. `status=failed&statusKind=error` (crash, rate limit, exit code) vs `statusKind=agent` (the agent chose to fail). Valid kinds per status: TASK_STATUS_KINDS in src/types.ts."),
|
|
30511
29042
|
agentId: string2().optional(),
|
|
30512
29043
|
scheduleId: string2().optional(),
|
|
30513
29044
|
workflowRunId: string2().uuid().optional(),
|
|
@@ -31156,6 +29687,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
31156
29687
|
});
|
|
31157
29688
|
const filters = {
|
|
31158
29689
|
status,
|
|
29690
|
+
statusKind: parsed.query.statusKind,
|
|
31159
29691
|
agentId: parsed.query.agentId || undefined,
|
|
31160
29692
|
scheduleId: parsed.query.scheduleId || undefined,
|
|
31161
29693
|
workflowRunId: parsed.query.workflowRunId,
|
|
@@ -31245,7 +29777,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
31245
29777
|
try {
|
|
31246
29778
|
const inheritedKey = parentTask?.key;
|
|
31247
29779
|
const requestedKey = parsed.body.key ?? inheritedKey;
|
|
31248
|
-
assetKey = requestedKey ? await
|
|
29780
|
+
assetKey = requestedKey ? await authorizeHttpAssetKeyWrite(req, myAgentId, requestedKey, trustedUserId) : undefined;
|
|
31249
29781
|
} catch (error) {
|
|
31250
29782
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
31251
29783
|
jsonError(res, error.message, error.statusCode);
|
|
@@ -31406,7 +29938,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
31406
29938
|
reason = body.reason;
|
|
31407
29939
|
} catch {}
|
|
31408
29940
|
}
|
|
31409
|
-
const cancelledTask = await cancelTask2(parsed.params.id, reason
|
|
29941
|
+
const cancelledTask = await cancelTask2(parsed.params.id, reason, {
|
|
29942
|
+
statusKind: principal.kind === "agent" ? "agent" : "user"
|
|
29943
|
+
});
|
|
31410
29944
|
if (!cancelledTask) {
|
|
31411
29945
|
jsonError(res, "Failed to cancel task", 500);
|
|
31412
29946
|
return true;
|
|
@@ -31780,19 +30314,19 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
31780
30314
|
}
|
|
31781
30315
|
let updatedTask;
|
|
31782
30316
|
if (parsed.body.status === "completed") {
|
|
31783
|
-
const result = await completeTask2(parsed.params.id, parsed.body.output || "Completed by runner wrapper (no explicit output)");
|
|
30317
|
+
const result = await completeTask2(parsed.params.id, parsed.body.output || "Completed by runner wrapper (no explicit output)", { statusKind: "runner" });
|
|
31784
30318
|
if (!result) {
|
|
31785
30319
|
return { error: "Failed to complete task", status: 500 };
|
|
31786
30320
|
}
|
|
31787
30321
|
updatedTask = result;
|
|
31788
30322
|
} else if (parsed.body.status === "skipped") {
|
|
31789
|
-
const result = await skipTask2(parsed.params.id, skipReason);
|
|
30323
|
+
const result = await skipTask2(parsed.params.id, skipReason, { statusKind: "runner" });
|
|
31790
30324
|
if (!result) {
|
|
31791
30325
|
return { error: "Failed to mark task as skipped", status: 500 };
|
|
31792
30326
|
}
|
|
31793
30327
|
updatedTask = result;
|
|
31794
30328
|
} else {
|
|
31795
|
-
const result = await failTask2(parsed.params.id, parsed.body.failureReason || "Process exited without explicit completion");
|
|
30329
|
+
const result = await failTask2(parsed.params.id, parsed.body.failureReason || "Process exited without explicit completion", { statusKind: "error" });
|
|
31796
30330
|
if (!result) {
|
|
31797
30331
|
return { error: "Failed to mark task as failed", status: 500 };
|
|
31798
30332
|
}
|
|
@@ -32143,7 +30677,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
32143
30677
|
}
|
|
32144
30678
|
}
|
|
32145
30679
|
if (task.workflowRunStepId != null) {
|
|
32146
|
-
const failed = await failTask2(parsed.params.id, SUPERSEDED_WORKFLOW_TASK_REASON
|
|
30680
|
+
const failed = await failTask2(parsed.params.id, SUPERSEDED_WORKFLOW_TASK_REASON, {
|
|
30681
|
+
statusKind: "error"
|
|
30682
|
+
});
|
|
32147
30683
|
if (task.agentId) {
|
|
32148
30684
|
await updateAgentStatusFromCapacity2(task.agentId);
|
|
32149
30685
|
}
|
|
@@ -32320,9 +30856,11 @@ var launchPageRoute = route({
|
|
|
32320
30856
|
summary: "Launch a page session (issues HttpOnly cookie)",
|
|
32321
30857
|
tags: ["Pages"],
|
|
32322
30858
|
params: object2({ id: string2() }),
|
|
30859
|
+
rbac: { permission: "page.launch" },
|
|
32323
30860
|
responses: {
|
|
32324
30861
|
204: { description: "Cookie issued" },
|
|
32325
30862
|
400: { description: "Launch not supported for this page (e.g. password mode)" },
|
|
30863
|
+
403: { description: "Caller may not open pages" },
|
|
32326
30864
|
404: { description: "Page not found" }
|
|
32327
30865
|
}
|
|
32328
30866
|
});
|
|
@@ -32588,7 +31126,7 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
32588
31126
|
passwordHash = await Bun.password.hash(parsed.body.password, "bcrypt");
|
|
32589
31127
|
}
|
|
32590
31128
|
try {
|
|
32591
|
-
const key = parsed.body.key ? await
|
|
31129
|
+
const key = parsed.body.key ? await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key) : undefined;
|
|
32592
31130
|
const page = await createPage2({
|
|
32593
31131
|
key,
|
|
32594
31132
|
agentId: myAgentId,
|
|
@@ -32792,7 +31330,7 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
32792
31330
|
let key;
|
|
32793
31331
|
if (parsed.body.key !== undefined) {
|
|
32794
31332
|
try {
|
|
32795
|
-
key = await
|
|
31333
|
+
key = await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key);
|
|
32796
31334
|
} catch (error) {
|
|
32797
31335
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
32798
31336
|
jsonError(res, error.message, error.statusCode);
|
|
@@ -32917,6 +31455,15 @@ ${defuseFeedbackTags(note)}
|
|
|
32917
31455
|
const parsed = await launchPageRoute.parse(req, res, pathSegments, queryParams);
|
|
32918
31456
|
if (!parsed)
|
|
32919
31457
|
return true;
|
|
31458
|
+
const principal = await resolveRequestPrincipal(req, myAgentId, {
|
|
31459
|
+
unauthenticatedFallback: "operator"
|
|
31460
|
+
});
|
|
31461
|
+
const decision = principal ? can({ principal, verb: "page.launch", resource: { kind: "none" }, source: "http" }) : { allow: false, reason: "no authenticated principal" };
|
|
31462
|
+
if (!decision.allow) {
|
|
31463
|
+
applyLaunchCors(req, res);
|
|
31464
|
+
jsonError(res, decision.reason, 403);
|
|
31465
|
+
return true;
|
|
31466
|
+
}
|
|
32920
31467
|
const page = await getPage2(parsed.params.id);
|
|
32921
31468
|
if (!page) {
|
|
32922
31469
|
applyLaunchCors(req, res);
|
|
@@ -32948,6 +31495,7 @@ ${defuseFeedbackTags(note)}
|
|
|
32948
31495
|
// src/http/pages-public.ts
|
|
32949
31496
|
init_zod();
|
|
32950
31497
|
init_db4();
|
|
31498
|
+
init_design_system2();
|
|
32951
31499
|
|
|
32952
31500
|
// src/pages/browser-sdk.ts
|
|
32953
31501
|
var BROWSER_SDK_JS = `
|
|
@@ -34367,21 +32915,22 @@ function contractValues(vars) {
|
|
|
34367
32915
|
function resolvePageTheme({
|
|
34368
32916
|
pageTheme,
|
|
34369
32917
|
viewerTheme,
|
|
34370
|
-
overrides
|
|
32918
|
+
overrides,
|
|
32919
|
+
designSystem
|
|
34371
32920
|
}) {
|
|
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
|
-
|
|
32921
|
+
const preset = getThemePreset(pageTheme) ?? getThemePreset(designSystem?.basePreset) ?? getThemePreset(viewerTheme) ?? getThemePreset(DEFAULT_THEME_ID);
|
|
32922
|
+
const light = { ...HIVE_PAGE_TOKENS.light, ...contractValues(preset?.vars.light) };
|
|
32923
|
+
const dark = { ...HIVE_PAGE_TOKENS.dark, ...contractValues(preset?.vars.dark) };
|
|
32924
|
+
for (const layer of [designSystem?.tokens, overrides]) {
|
|
32925
|
+
const lightValues = contractValues(layer?.light);
|
|
32926
|
+
const darkValues = contractValues(layer?.dark);
|
|
32927
|
+
Object.assign(light, lightValues);
|
|
32928
|
+
Object.assign(dark, darkValues);
|
|
32929
|
+
for (const token of PAGE_THEME_SHARED_TOKENS) {
|
|
32930
|
+
const value = lightValues[token];
|
|
32931
|
+
if (value !== undefined && darkValues[token] === undefined)
|
|
32932
|
+
dark[token] = value;
|
|
32933
|
+
}
|
|
34385
32934
|
}
|
|
34386
32935
|
return { presetId: preset?.id ?? DEFAULT_THEME_ID, light, dark };
|
|
34387
32936
|
}
|
|
@@ -34482,6 +33031,12 @@ var IN_PAGE_LINK_SCRIPT = `<script>document.addEventListener("click", function (
|
|
|
34482
33031
|
var FONT_LINKS = `<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
34483
33032
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
34484
33033
|
<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">`;
|
|
33034
|
+
function fontLinks(href) {
|
|
33035
|
+
const escaped = href.replaceAll("&", "&").replaceAll('"', """);
|
|
33036
|
+
return `<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
33037
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
33038
|
+
<link href="${escaped}" rel="stylesheet">`;
|
|
33039
|
+
}
|
|
34485
33040
|
var TAILWIND_SOURCE = [
|
|
34486
33041
|
'@import "tailwindcss/theme" layer(theme);',
|
|
34487
33042
|
'@import "tailwindcss/utilities" layer(utilities);',
|
|
@@ -35058,13 +33613,14 @@ ${TONE_RULES}
|
|
|
35058
33613
|
}`;
|
|
35059
33614
|
function buildPageHeadV2({
|
|
35060
33615
|
theme,
|
|
35061
|
-
mode
|
|
33616
|
+
mode,
|
|
33617
|
+
fontsHref
|
|
35062
33618
|
}) {
|
|
35063
33619
|
return [
|
|
35064
33620
|
'<base target="_blank">',
|
|
35065
33621
|
IN_PAGE_LINK_SCRIPT,
|
|
35066
33622
|
"<style>@layer properties, theme, base, components, utilities;</style>",
|
|
35067
|
-
FONT_LINKS,
|
|
33623
|
+
fontsHref ? fontLinks(fontsHref) : FONT_LINKS,
|
|
35068
33624
|
`<style id="swarm-theme">
|
|
35069
33625
|
${renderPageThemeCss(theme)}
|
|
35070
33626
|
</style>`,
|
|
@@ -35079,6 +33635,7 @@ ${PAGE_DESIGN_CSS}
|
|
|
35079
33635
|
}
|
|
35080
33636
|
|
|
35081
33637
|
// src/http/pages-public.ts
|
|
33638
|
+
init_presets();
|
|
35082
33639
|
init_types5();
|
|
35083
33640
|
init_constants3();
|
|
35084
33641
|
init_page_session();
|
|
@@ -35128,16 +33685,24 @@ var publicPageJsonRoute = route({
|
|
|
35128
33685
|
},
|
|
35129
33686
|
auth: { apiKey: false }
|
|
35130
33687
|
});
|
|
35131
|
-
function pageHead(page, queryParams, wantsPrint) {
|
|
33688
|
+
async function pageHead(page, queryParams, wantsPrint) {
|
|
35132
33689
|
if (page.designVersion === 1)
|
|
35133
33690
|
return PAGE_HEAD_V1;
|
|
33691
|
+
const designSystem = getThemePreset(page.theme) ? null : await getActiveDesignSystem();
|
|
35134
33692
|
const theme = resolvePageTheme({
|
|
35135
33693
|
pageTheme: page.theme,
|
|
35136
33694
|
viewerTheme: queryParams.get(PAGE_THEME_PARAM),
|
|
35137
|
-
overrides: page.themeTokens
|
|
33695
|
+
overrides: page.themeTokens,
|
|
33696
|
+
designSystem
|
|
33697
|
+
});
|
|
33698
|
+
const mode = designSystem?.mode ?? "viewer";
|
|
33699
|
+
const wantsDark = mode === "dark" || mode === "viewer" && queryParams.get(PAGE_MODE_PARAM) === "dark";
|
|
33700
|
+
const dark = !wantsPrint && wantsDark && countColorLiterals(page.body) < COLOR_LITERAL_THRESHOLD;
|
|
33701
|
+
return buildPageHeadV2({
|
|
33702
|
+
theme,
|
|
33703
|
+
mode: dark ? "dark" : "light",
|
|
33704
|
+
fontsHref: designSystem?.fontsHref
|
|
35138
33705
|
});
|
|
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
33706
|
}
|
|
35142
33707
|
var LEADING_DOCTYPE_RE = /^\s*<!doctype\b[^>]*>/i;
|
|
35143
33708
|
var LEADING_HTML_TAG_RE = /^\s*<!doctype\b[^>]*>\s*<html\b[^>]*>/i;
|
|
@@ -35486,7 +34051,7 @@ async function handlePagesPublic(req, res, pathSegments, queryParams) {
|
|
|
35486
34051
|
}
|
|
35487
34052
|
const feedback = isPageFeedbackRequested(queryParams);
|
|
35488
34053
|
const html = injectBrowserSdk(page.body, {
|
|
35489
|
-
head: `${pageHead(page, queryParams, wantsPrint)}<meta name="swarm-viewer" content="${pageViewer(cookiePayload)}">`,
|
|
34054
|
+
head: `${await pageHead(page, queryParams, wantsPrint)}<meta name="swarm-viewer" content="${pageViewer(cookiePayload)}">`,
|
|
35490
34055
|
headFirst: feedback ? feedbackKeyGuardScript() : "",
|
|
35491
34056
|
standardsMode: page.designVersion !== 1
|
|
35492
34057
|
}) + (wantsPrint ? PRINT_AUTOTRIGGER_SCRIPT : "") + (feedback ? feedbackOverlayScripts(page.id) : "");
|
|
@@ -35636,6 +34201,7 @@ init_multi_runtime2();
|
|
|
35636
34201
|
init_request_auth_context();
|
|
35637
34202
|
init_runtime_pools_flag();
|
|
35638
34203
|
init_secret_scrubber();
|
|
34204
|
+
init_config();
|
|
35639
34205
|
init_route_def();
|
|
35640
34206
|
init_utils2();
|
|
35641
34207
|
function buildBudgetRefusedTrigger(refusal) {
|
|
@@ -36179,6 +34745,7 @@ init_multi_runtime();
|
|
|
36179
34745
|
init_swarm_config_guard();
|
|
36180
34746
|
init_credentials2();
|
|
36181
34747
|
init_secret_scrubber();
|
|
34748
|
+
init_config();
|
|
36182
34749
|
init_core();
|
|
36183
34750
|
init_route_def();
|
|
36184
34751
|
init_utils2();
|
|
@@ -36805,7 +35372,7 @@ var resetRoute = route({
|
|
|
36805
35372
|
},
|
|
36806
35373
|
auth: { apiKey: true }
|
|
36807
35374
|
});
|
|
36808
|
-
var
|
|
35375
|
+
var getByIdRoute = route({
|
|
36809
35376
|
method: "get",
|
|
36810
35377
|
path: "/api/prompt-templates/{id}",
|
|
36811
35378
|
pattern: ["api", "prompt-templates", null],
|
|
@@ -36841,7 +35408,7 @@ var deleteByIdRoute = route({
|
|
|
36841
35408
|
},
|
|
36842
35409
|
auth: { apiKey: true }
|
|
36843
35410
|
});
|
|
36844
|
-
var
|
|
35411
|
+
var listRoute3 = route({
|
|
36845
35412
|
method: "get",
|
|
36846
35413
|
path: "/api/prompt-templates",
|
|
36847
35414
|
pattern: ["api", "prompt-templates"],
|
|
@@ -36991,8 +35558,8 @@ ${templateBody}` : templateBody;
|
|
|
36991
35558
|
}
|
|
36992
35559
|
return true;
|
|
36993
35560
|
}
|
|
36994
|
-
if (
|
|
36995
|
-
const parsed = await
|
|
35561
|
+
if (getByIdRoute.match(req.method, pathSegments)) {
|
|
35562
|
+
const parsed = await getByIdRoute.parse(req, res, pathSegments, queryParams);
|
|
36996
35563
|
if (!parsed)
|
|
36997
35564
|
return true;
|
|
36998
35565
|
const template = await getPromptTemplateById2(parsed.params.id);
|
|
@@ -37001,7 +35568,7 @@ ${templateBody}` : templateBody;
|
|
|
37001
35568
|
return true;
|
|
37002
35569
|
}
|
|
37003
35570
|
const history = await getPromptTemplateHistory2(parsed.params.id);
|
|
37004
|
-
|
|
35571
|
+
getByIdRoute.respond(res, 200, { template: toPromptTemplateResponse(template), history });
|
|
37005
35572
|
return true;
|
|
37006
35573
|
}
|
|
37007
35574
|
if (deleteByIdRoute.match(req.method, pathSegments)) {
|
|
@@ -37021,8 +35588,8 @@ ${templateBody}` : templateBody;
|
|
|
37021
35588
|
}
|
|
37022
35589
|
return true;
|
|
37023
35590
|
}
|
|
37024
|
-
if (
|
|
37025
|
-
const parsed = await
|
|
35591
|
+
if (listRoute3.match(req.method, pathSegments)) {
|
|
35592
|
+
const parsed = await listRoute3.parse(req, res, pathSegments, queryParams);
|
|
37026
35593
|
if (!parsed)
|
|
37027
35594
|
return true;
|
|
37028
35595
|
const templates = getPromptTemplates2({
|
|
@@ -37031,7 +35598,7 @@ ${templateBody}` : templateBody;
|
|
|
37031
35598
|
scopeId: parsed.query.scopeId || undefined,
|
|
37032
35599
|
isDefault: parsed.query.isDefault ? parsed.query.isDefault === "true" : undefined
|
|
37033
35600
|
});
|
|
37034
|
-
|
|
35601
|
+
listRoute3.respond(res, 200, { templates: templates.map(toPromptTemplateResponse) });
|
|
37035
35602
|
return true;
|
|
37036
35603
|
}
|
|
37037
35604
|
if (upsertRoute.match(req.method, pathSegments)) {
|
|
@@ -37076,6 +35643,9 @@ ${templateBody}` : templateBody;
|
|
|
37076
35643
|
return false;
|
|
37077
35644
|
}
|
|
37078
35645
|
|
|
35646
|
+
// src/http/index.ts
|
|
35647
|
+
init_ranking();
|
|
35648
|
+
|
|
37079
35649
|
// src/http/realtime.ts
|
|
37080
35650
|
init_zod();
|
|
37081
35651
|
init_users();
|
|
@@ -40663,6 +39233,7 @@ async function calibrate(sql, opts) {
|
|
|
40663
39233
|
}
|
|
40664
39234
|
|
|
40665
39235
|
// src/http/savings-calibration.ts
|
|
39236
|
+
init_config();
|
|
40666
39237
|
init_db_query_shared();
|
|
40667
39238
|
init_route_def();
|
|
40668
39239
|
init_utils2();
|
|
@@ -40878,11 +39449,11 @@ init_db3();
|
|
|
40878
39449
|
init_rbac();
|
|
40879
39450
|
init_scheduler();
|
|
40880
39451
|
init_types5();
|
|
39452
|
+
var import_cron_parser = __toESM(require_dist(), 1);
|
|
40881
39453
|
init_favorite_owner();
|
|
40882
39454
|
init_request_principal();
|
|
40883
39455
|
init_route_def();
|
|
40884
39456
|
init_utils2();
|
|
40885
|
-
var import_cron_parser = __toESM(require_dist(), 1);
|
|
40886
39457
|
var scheduleUpdateBodySchema = object2({
|
|
40887
39458
|
key: AssetKeySchema.optional(),
|
|
40888
39459
|
name: string2().optional(),
|
|
@@ -41208,7 +39779,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
41208
39779
|
const trustedUserId = await resolveHttpRequesterUserId(req, myAgentId);
|
|
41209
39780
|
let key;
|
|
41210
39781
|
try {
|
|
41211
|
-
key = body.key ? await
|
|
39782
|
+
key = body.key ? await authorizeHttpAssetKeyWrite(req, myAgentId, body.key, trustedUserId) : undefined;
|
|
41212
39783
|
} catch (error) {
|
|
41213
39784
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
41214
39785
|
jsonError(res, error.message, error.statusCode);
|
|
@@ -41329,7 +39900,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
41329
39900
|
const body = parsed.body;
|
|
41330
39901
|
if (parsed.body.key !== undefined) {
|
|
41331
39902
|
try {
|
|
41332
|
-
body.key = await
|
|
39903
|
+
body.key = await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key);
|
|
41333
39904
|
} catch (error) {
|
|
41334
39905
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
41335
39906
|
jsonError(res, error.message, error.statusCode);
|
|
@@ -41709,6 +40280,7 @@ init_telemetry();
|
|
|
41709
40280
|
init_egress_guard();
|
|
41710
40281
|
init_scoped_resource();
|
|
41711
40282
|
init_secret_scrubber();
|
|
40283
|
+
init_config();
|
|
41712
40284
|
init_route_def();
|
|
41713
40285
|
init_utils2();
|
|
41714
40286
|
var providerSchema = string2().min(1).max(255).regex(/^[A-Za-z0-9_-]+$/);
|
|
@@ -45843,6 +44415,7 @@ var AgentTaskSummarySchema2 = AgentTaskSchema.pick({
|
|
|
45843
44415
|
createdAt: true,
|
|
45844
44416
|
lastUpdatedAt: true,
|
|
45845
44417
|
finishedAt: true,
|
|
44418
|
+
statusKind: true,
|
|
45846
44419
|
peakContextPercent: true,
|
|
45847
44420
|
totalCostUsd: true
|
|
45848
44421
|
});
|
|
@@ -46294,7 +44867,7 @@ async function withSessionMove(req, res, myAgentId, destination, run) {
|
|
|
46294
44867
|
try {
|
|
46295
44868
|
const changedBy = await resolveHttpRequesterUserId(req, myAgentId);
|
|
46296
44869
|
const actor = await resolveSessionActor2(req, myAgentId);
|
|
46297
|
-
const key = destination === null ? null : await
|
|
44870
|
+
const key = destination === null ? null : await authorizeHttpAssetKeyWrite(req, myAgentId, destination, changedBy);
|
|
46298
44871
|
await assertAssetKeyMovesAllowed2();
|
|
46299
44872
|
await run({ actor, changedBy: changedBy ?? undefined, key });
|
|
46300
44873
|
} catch (error) {
|
|
@@ -48014,7 +46587,7 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
48014
46587
|
|
|
48015
46588
|
// src/http/slack-events.ts
|
|
48016
46589
|
init_app4();
|
|
48017
|
-
|
|
46590
|
+
init_config5();
|
|
48018
46591
|
init_route_def();
|
|
48019
46592
|
init_utils2();
|
|
48020
46593
|
var slackEventsRoute = route({
|
|
@@ -48546,6 +47119,7 @@ function validateUiEvent(event, properties) {
|
|
|
48546
47119
|
}
|
|
48547
47120
|
|
|
48548
47121
|
// src/http/telemetry-ui.ts
|
|
47122
|
+
init_config();
|
|
48549
47123
|
init_core();
|
|
48550
47124
|
init_favorite_owner();
|
|
48551
47125
|
init_request_principal();
|
|
@@ -48771,6 +47345,7 @@ init_utils2();
|
|
|
48771
47345
|
// src/http/trackers/authorize-gate.ts
|
|
48772
47346
|
init_zod();
|
|
48773
47347
|
init_audit_user();
|
|
47348
|
+
init_config();
|
|
48774
47349
|
var TrackerAuthorizeQuerySchema = object2({
|
|
48775
47350
|
redirect: string2().optional(),
|
|
48776
47351
|
format: _enum2(["redirect", "json"]).optional()
|
|
@@ -49499,6 +48074,9 @@ async function handleTrackers(req, res, pathSegments) {
|
|
|
49499
48074
|
return await handleLinearTracker(req, res, pathSegments);
|
|
49500
48075
|
}
|
|
49501
48076
|
|
|
48077
|
+
// src/http/index.ts
|
|
48078
|
+
init_used_by();
|
|
48079
|
+
|
|
49502
48080
|
// src/http/user-roles.ts
|
|
49503
48081
|
init_zod();
|
|
49504
48082
|
init_db4();
|
|
@@ -49780,6 +48358,7 @@ var createUserRoute = route({
|
|
|
49780
48358
|
metadata: record2(string2(), unknown()).optional(),
|
|
49781
48359
|
dailyBudgetUsd: number2().nullable().optional(),
|
|
49782
48360
|
status: _enum2(["invited", "active", "suspended"]).optional(),
|
|
48361
|
+
avatar: UserAvatarSchema.nullable().optional(),
|
|
49783
48362
|
identities: array2(object2({ kind: string2().min(1), externalId: string2().min(1) })).optional()
|
|
49784
48363
|
}),
|
|
49785
48364
|
responses: {
|
|
@@ -49921,6 +48500,7 @@ var updateUserRoute = route({
|
|
|
49921
48500
|
comms: UserCommsPrefsSchema.nullable().optional().describe("Merges into metadata.comms without touching sibling metadata keys; null removes only the comms key. When metadata is also provided, it is applied first and replaces the whole blob."),
|
|
49922
48501
|
dailyBudgetUsd: number2().nullable().optional(),
|
|
49923
48502
|
status: _enum2(["invited", "active", "suspended"]).optional(),
|
|
48503
|
+
avatar: UserAvatarSchema.nullable().optional(),
|
|
49924
48504
|
identities: array2(object2({ kind: string2().min(1), externalId: string2().min(1) })).optional()
|
|
49925
48505
|
}).refine((v) => Object.keys(v).length > 0, {
|
|
49926
48506
|
message: "At least one field must be provided"
|
|
@@ -51062,7 +49642,8 @@ async function handleUsers(req, res, pathSegments, queryParams) {
|
|
|
51062
49642
|
"timezone",
|
|
51063
49643
|
"preferredChannel",
|
|
51064
49644
|
"notes",
|
|
51065
|
-
"metadata"
|
|
49645
|
+
"metadata",
|
|
49646
|
+
"avatar"
|
|
51066
49647
|
];
|
|
51067
49648
|
for (const field of PROFILE_FIELDS) {
|
|
51068
49649
|
if (parsed.body[field] === undefined)
|
|
@@ -51188,11 +49769,11 @@ function gitlabWorkflowActionName(action) {
|
|
|
51188
49769
|
|
|
51189
49770
|
// src/http/webhooks.ts
|
|
51190
49771
|
init_background();
|
|
51191
|
-
|
|
49772
|
+
init_config2();
|
|
51192
49773
|
init_runtime();
|
|
51193
49774
|
init_teams_origin();
|
|
51194
49775
|
init_client();
|
|
51195
|
-
|
|
49776
|
+
init_config3();
|
|
51196
49777
|
|
|
51197
49778
|
// src/integrations/kapso/inbound.ts
|
|
51198
49779
|
init_resolver();
|
|
@@ -51201,7 +49782,7 @@ init_event_bus();
|
|
|
51201
49782
|
init_templates3();
|
|
51202
49783
|
init_identity();
|
|
51203
49784
|
init_unmapped_identities();
|
|
51204
|
-
|
|
49785
|
+
init_config3();
|
|
51205
49786
|
var KAPSO_IDENTITY_KIND = "kapso";
|
|
51206
49787
|
var WHATSAPP_IDENTITY_KIND = "whatsapp";
|
|
51207
49788
|
function extractText(message) {
|
|
@@ -51303,6 +49884,7 @@ async function routeKapsoInbound(payload) {
|
|
|
51303
49884
|
}
|
|
51304
49885
|
|
|
51305
49886
|
// src/http/webhooks.ts
|
|
49887
|
+
init_deferred_task_waits();
|
|
51306
49888
|
init_errors2();
|
|
51307
49889
|
init_constants3();
|
|
51308
49890
|
init_github_host();
|
|
@@ -51560,7 +50142,7 @@ async function handleWebhooks(req, res, pathSegments) {
|
|
|
51560
50142
|
}
|
|
51561
50143
|
const eventType = req.headers["x-github-event"];
|
|
51562
50144
|
const signature = req.headers["x-hub-signature-256"];
|
|
51563
|
-
if (typeof eventType === "string" && eventType && !GITHUB_VERIFIED_EVENTS.has(eventType)) {
|
|
50145
|
+
if (typeof eventType === "string" && eventType && !GITHUB_VERIFIED_EVENTS.has(eventType) && !(eventType === "check_run" && await hasPendingEventWait("github", "vcs.pr.checks_done"))) {
|
|
51564
50146
|
countGithubIgnoredEvent(eventType);
|
|
51565
50147
|
githubWebhook.respond(res, 200, { created: false });
|
|
51566
50148
|
req.resume();
|
|
@@ -51658,6 +50240,17 @@ async function handleWebhooks(req, res, pathSegments) {
|
|
|
51658
50240
|
});
|
|
51659
50241
|
break;
|
|
51660
50242
|
}
|
|
50243
|
+
case "check_run": {
|
|
50244
|
+
const cr = body;
|
|
50245
|
+
workflowEventBus2.emit(`github.check_run.${cr.action}`, {
|
|
50246
|
+
repo: cr.repository.full_name,
|
|
50247
|
+
name: cr.check_run.name,
|
|
50248
|
+
headSha: cr.check_run.check_suite?.head_sha,
|
|
50249
|
+
conclusion: cr.check_run.conclusion,
|
|
50250
|
+
pullRequests: (cr.check_run.pull_requests ?? []).map((pr) => pr.number)
|
|
50251
|
+
});
|
|
50252
|
+
break;
|
|
50253
|
+
}
|
|
51661
50254
|
case "pull_request_review": {
|
|
51662
50255
|
const prr = body;
|
|
51663
50256
|
workflowEventBus2.emit("github.pull_request_review.submitted", {
|
|
@@ -52297,6 +50890,7 @@ init_readiness();
|
|
|
52297
50890
|
init_resume();
|
|
52298
50891
|
init_triggers();
|
|
52299
50892
|
init_version();
|
|
50893
|
+
init_config();
|
|
52300
50894
|
init_favorite_owner();
|
|
52301
50895
|
init_idempotency_key();
|
|
52302
50896
|
init_route_def();
|
|
@@ -52856,7 +51450,7 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
52856
51450
|
const trustedUserId = await resolveHttpRequesterUserId(req, myAgentId);
|
|
52857
51451
|
let key;
|
|
52858
51452
|
try {
|
|
52859
|
-
key = parsed.body.key ? await
|
|
51453
|
+
key = parsed.body.key ? await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key, trustedUserId) : undefined;
|
|
52860
51454
|
} catch (error) {
|
|
52861
51455
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
52862
51456
|
jsonError(res, error.message, error.statusCode);
|
|
@@ -52973,7 +51567,7 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
52973
51567
|
const updateArgs = {};
|
|
52974
51568
|
if (parsed.body.key !== undefined) {
|
|
52975
51569
|
try {
|
|
52976
|
-
updateArgs.key = await
|
|
51570
|
+
updateArgs.key = await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key);
|
|
52977
51571
|
} catch (error) {
|
|
52978
51572
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
52979
51573
|
jsonError(res, error.message, error.statusCode);
|
|
@@ -53061,7 +51655,7 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
53061
51655
|
let key;
|
|
53062
51656
|
if (body.key !== undefined) {
|
|
53063
51657
|
try {
|
|
53064
|
-
key = await
|
|
51658
|
+
key = await authorizeHttpAssetKeyWrite(req, myAgentId, body.key);
|
|
53065
51659
|
} catch (error) {
|
|
53066
51660
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
53067
51661
|
jsonError(res, error.message, error.statusCode);
|
|
@@ -53672,6 +52266,7 @@ var httpServer = createHttpServer(async (req, res) => {
|
|
|
53672
52266
|
() => handlePagesPublic(req, res, pathSegments, queryParams),
|
|
53673
52267
|
() => handlePageProxy(req, res),
|
|
53674
52268
|
() => handlePages(req, res, pathSegments, queryParams, myAgentId),
|
|
52269
|
+
() => handleDesignSystem(req, res, pathSegments, queryParams, myAgentId),
|
|
53675
52270
|
() => handleApiKeys(req, res, pathSegments, queryParams),
|
|
53676
52271
|
() => handleHeartbeat(req, res, pathSegments),
|
|
53677
52272
|
() => handleEvents(req, res, pathSegments, queryParams, myAgentId),
|
|
@@ -53717,7 +52312,7 @@ var httpServer = createHttpServer(async (req, res) => {
|
|
|
53717
52312
|
});
|
|
53718
52313
|
});
|
|
53719
52314
|
var detachRealtime = attachRealtimeTransport(httpServer);
|
|
53720
|
-
var { attachControllerTransport } = await import("./controllers-connect-
|
|
52315
|
+
var { attachControllerTransport } = await import("./controllers-connect-2ssqz7f4.js");
|
|
53721
52316
|
var detachControllers = attachControllerTransport(httpServer);
|
|
53722
52317
|
var stopWorkerNudges = startWorkerNudgeListener();
|
|
53723
52318
|
var taskAutoTitles = startTaskAutoTitleListener();
|
|
@@ -53748,7 +52343,7 @@ async function shutdown() {
|
|
|
53748
52343
|
sessionsProcessed: getServerSessionsProcessed()
|
|
53749
52344
|
});
|
|
53750
52345
|
if (hasCapability("scheduling")) {
|
|
53751
|
-
const { stopScheduler } = await import("./index-
|
|
52346
|
+
const { stopScheduler } = await import("./index-hmszyqkk.js");
|
|
53752
52347
|
stopScheduler();
|
|
53753
52348
|
}
|
|
53754
52349
|
stopHeartbeat2();
|
|
@@ -53760,7 +52355,7 @@ async function shutdown() {
|
|
|
53760
52355
|
await stopSlackApp2();
|
|
53761
52356
|
await stopChatSdk();
|
|
53762
52357
|
if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
|
|
53763
|
-
const { stopOAuthKeepalive } = await import("./keepalive-
|
|
52358
|
+
const { stopOAuthKeepalive } = await import("./keepalive-zhbmztqw.js");
|
|
53764
52359
|
await stopOAuthKeepalive();
|
|
53765
52360
|
}
|
|
53766
52361
|
stopOAuthPendingGc();
|
|
@@ -53850,21 +52445,21 @@ try {
|
|
|
53850
52445
|
console.warn("[startup] CAPABILITIES upgrade seed failed (non-fatal):", err);
|
|
53851
52446
|
}
|
|
53852
52447
|
try {
|
|
53853
|
-
const { ensurePricingSeeded } = await import("./boot-seeds-
|
|
52448
|
+
const { ensurePricingSeeded } = await import("./boot-seeds-hwnvgbb3.js");
|
|
53854
52449
|
ensurePricingSeeded();
|
|
53855
|
-
const { startPricingRefreshLoop } = await import("./pricing-refresh-
|
|
52450
|
+
const { startPricingRefreshLoop } = await import("./pricing-refresh-9355dj1t.js");
|
|
53856
52451
|
startPricingRefreshLoop();
|
|
53857
52452
|
} catch (err) {
|
|
53858
52453
|
console.error("[startup] Failed to seed pricing rows:", err);
|
|
53859
52454
|
}
|
|
53860
52455
|
try {
|
|
53861
|
-
const { ensureModelProfilesSeeded } = await import("./boot-seeds-
|
|
52456
|
+
const { ensureModelProfilesSeeded } = await import("./boot-seeds-hwnvgbb3.js");
|
|
53862
52457
|
await ensureModelProfilesSeeded();
|
|
53863
52458
|
} catch (err) {
|
|
53864
52459
|
console.error("[startup] Failed to seed model profiles:", err);
|
|
53865
52460
|
}
|
|
53866
52461
|
try {
|
|
53867
|
-
const { ensureRbacSeeded } = await import("./boot-seeds-
|
|
52462
|
+
const { ensureRbacSeeded } = await import("./boot-seeds-hwnvgbb3.js");
|
|
53868
52463
|
ensureRbacSeeded();
|
|
53869
52464
|
} catch (err) {
|
|
53870
52465
|
console.error("[startup] Failed to sync RBAC seed rows:", err);
|
|
@@ -53872,13 +52467,13 @@ try {
|
|
|
53872
52467
|
throw err;
|
|
53873
52468
|
}
|
|
53874
52469
|
try {
|
|
53875
|
-
const { runAllSeeders } = await import("./index-
|
|
52470
|
+
const { runAllSeeders } = await import("./index-z2g9469g.js");
|
|
53876
52471
|
await runAllSeeders({ scriptEmbeddingMode: "skip" });
|
|
53877
52472
|
} catch (err) {
|
|
53878
52473
|
console.error("[startup] Failed to seed built-in entities:", err);
|
|
53879
52474
|
}
|
|
53880
52475
|
try {
|
|
53881
|
-
const { runImports } = await import("./index-
|
|
52476
|
+
const { runImports } = await import("./index-yq9hhhhy.js");
|
|
53882
52477
|
await runImports();
|
|
53883
52478
|
} catch (err) {
|
|
53884
52479
|
console.error("[startup] File import failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
@@ -53929,10 +52524,10 @@ httpServer.listen(port, async () => {
|
|
|
53929
52524
|
startChatSdk().catch((err) => {
|
|
53930
52525
|
console.error("[chat-sdk] Failed to start, continuing without Chat SDK:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
53931
52526
|
});
|
|
53932
|
-
import("./agent-fs-provision-
|
|
52527
|
+
import("./agent-fs-provision-cbt2ttds.js").then(({ syncAgentFsOrgSwarmUrl }) => syncAgentFsOrgSwarmUrl(getConfiguredAppUrls()[0])).catch((err) => {
|
|
53933
52528
|
console.warn("[agent-fs] Failed to set the org swarm URL:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
53934
52529
|
});
|
|
53935
|
-
import("./object-webhooks-
|
|
52530
|
+
import("./object-webhooks-331hay92.js").then(({ ensureObjectWebhooksForKnownDrives }) => ensureObjectWebhooksForKnownDrives()).catch((err) => {
|
|
53936
52531
|
console.warn("[objects] agent-fs webhook boot check failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
53937
52532
|
});
|
|
53938
52533
|
startQueueStallAlarm();
|
|
@@ -53948,25 +52543,22 @@ httpServer.listen(port, async () => {
|
|
|
53948
52543
|
await initWorkflows2();
|
|
53949
52544
|
await startScriptRunSupervisor(getMcpBaseUrl());
|
|
53950
52545
|
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
|
-
});
|
|
52546
|
+
const { parseSchedulerIntervalMs, startScheduler } = await import("./index-hmszyqkk.js");
|
|
52547
|
+
const { getExecutorRegistry } = await import("./index-dtt0d634.js");
|
|
52548
|
+
startScheduler(getExecutorRegistry(), parseSchedulerIntervalMs(process.env.SCHEDULER_INTERVAL_MS), { runId: globalState.__runId });
|
|
53957
52549
|
}
|
|
53958
52550
|
if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
|
|
53959
|
-
const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-
|
|
52551
|
+
const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-j6rm1rtn.js");
|
|
53960
52552
|
startHeartbeat(parseHeartbeatIntervalMs(process.env.HEARTBEAT_INTERVAL_MS));
|
|
53961
52553
|
}
|
|
53962
52554
|
startPoolRouting();
|
|
53963
52555
|
startRuntimeSupervisor();
|
|
53964
52556
|
if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
|
|
53965
|
-
const { startOAuthKeepalive } = await import("./keepalive-
|
|
52557
|
+
const { startOAuthKeepalive } = await import("./keepalive-zhbmztqw.js");
|
|
53966
52558
|
startOAuthKeepalive();
|
|
53967
52559
|
}
|
|
53968
52560
|
if (!isEnvFlagEnabled("OAUTH_REFRESH_SWEEP_DISABLE", false)) {
|
|
53969
|
-
const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-
|
|
52561
|
+
const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-w3cqmxq7.js");
|
|
53970
52562
|
startOAuthRefreshSweep();
|
|
53971
52563
|
}
|
|
53972
52564
|
startOAuthPendingGc();
|
|
@@ -53976,22 +52568,22 @@ httpServer.listen(port, async () => {
|
|
|
53976
52568
|
startSavingsRollup(savingsRollupSql);
|
|
53977
52569
|
startHumanFreeDrain();
|
|
53978
52570
|
startTaskSearchBackfill();
|
|
53979
|
-
import("./embedding-space-
|
|
52571
|
+
import("./embedding-space-qepzrach.js").then(({ runEmbeddingMaintenance, setDeploymentEnvReader }) => {
|
|
53980
52572
|
setDeploymentEnvReader(getDeploymentEnvValue2);
|
|
53981
52573
|
return runEmbeddingMaintenance({ backfill: true });
|
|
53982
52574
|
}).catch((err) => {
|
|
53983
52575
|
console.error("[embedding-space] startup maintenance failed (non-fatal):", err);
|
|
53984
52576
|
});
|
|
53985
|
-
import("./boot-args-schema-
|
|
52577
|
+
import("./boot-args-schema-g27kpzr1.js").then(({ runBootArgsSchemaBackfill }) => runBootArgsSchemaBackfill()).catch((err) => {
|
|
53986
52578
|
console.error("[boot-args-schema] startup backfill failed (non-fatal):", err);
|
|
53987
52579
|
});
|
|
53988
|
-
import("./boot-scrub-sweep-
|
|
52580
|
+
import("./boot-scrub-sweep-ss1vcamw.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
|
|
53989
52581
|
console.error("[boot-scrub-sweep] startup scrub failed (non-fatal):", err);
|
|
53990
52582
|
});
|
|
53991
|
-
import("./user-merge-jobs-
|
|
52583
|
+
import("./user-merge-jobs-mxrhamwt.js").then(({ resumeUserMergeJobs }) => resumeUserMergeJobs()).catch((err) => {
|
|
53992
52584
|
console.error("[user-merge] startup resume failed (non-fatal):", err);
|
|
53993
52585
|
});
|
|
53994
|
-
import("./session-source-backfill-
|
|
52586
|
+
import("./session-source-backfill-cdm5s046.js").then(({ runSessionSourceBackfill }) => runSessionSourceBackfill()).catch((err) => {
|
|
53995
52587
|
console.error("[session-source-backfill] startup run failed (non-fatal):", err);
|
|
53996
52588
|
});
|
|
53997
52589
|
}).on("error", (err) => {
|