@desplega.ai/agent-swarm 2.7.7 → 2.7.9
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-dn4gdsgr.js +16 -0
- package/dist/{actions-3tt153af.js → actions-g563mbn2.js} +19 -19
- package/dist/{amp-adapter-njpts0yr.js → amp-adapter-q61w05eb.js} +3 -3
- package/dist/{anthropic-messages-xey2skwx.js → anthropic-messages-jkva0zps.js} +68 -78
- package/dist/{app-nky4378f.js → app-a66ssc4k.js} +3 -3
- package/dist/{assistant-jnb669pa.js → assistant-p477rjwj.js} +22 -22
- package/dist/{azure-openai-responses-26t7j9ra.js → azure-openai-responses-wgtqkbr3.js} +5 -10
- package/dist/boot-args-schema-h4qj462e.js +89 -0
- package/dist/{boot-reembed-9mgvaztt.js → boot-reembed-n1ehfbsw.js} +1 -1
- package/dist/{boot-reembed-qs2djdej.js → boot-reembed-qw4mc0pt.js} +1 -1
- package/dist/{boot-scrub-sweep-yjpdj7s1.js → boot-scrub-sweep-9w9jp4sm.js} +4 -4
- package/dist/{boot-seeds-5cm6ambd.js → boot-seeds-qdaf3sdy.js} +5 -4
- package/dist/{boxd-nv507va8.js → boxd-qbkxy6ap.js} +1 -1
- package/dist/{claude-adapter-fn287zmm.js → claude-adapter-348p5hx9.js} +8 -8
- package/dist/{claude-managed-adapter-dvs2xw5n.js → claude-managed-adapter-h74d06yz.js} +4 -4
- package/dist/{claude-managed-setup-wtdz2mj2.js → claude-managed-setup-7787fxtp.js} +5 -5
- package/dist/{claude-sdk-session-x91kqyhm.js → claude-sdk-session-hbszbt8a.js} +7901 -7718
- package/dist/{cli-cb2a8pna.js → cli-09kmfkmq.js} +4 -6
- package/dist/{cli-m0da8j35.js → cli-0whpms1z.js} +15 -10
- package/dist/{cli-5zx699j9.js → cli-12xyjhws.js} +29 -12
- package/dist/{cli-snpj5zbj.js → cli-1z4qggfe.js} +9 -36
- package/dist/{cli-e0kmphd6.js → cli-21159vea.js} +35 -12
- package/dist/{cli-s0qnd4wv.js → cli-28fq781p.js} +1 -1
- package/dist/{cli-qh4d4tvk.js → cli-2a8py3sx.js} +6 -6
- package/dist/{cli-adeegh7d.js → cli-2ccpqyyf.js} +412 -116
- package/dist/{cli-1p89xny0.js → cli-2r0jcc3k.js} +1 -1
- package/dist/{cli-rvtm68yy.js → cli-2xv18ywz.js} +2 -2
- package/dist/{cli-5xaqj21p.js → cli-3kd08rej.js} +1 -1
- package/dist/{cli-1c6tzt8g.js → cli-3tqcamp6.js} +13 -13
- package/dist/{cli-ae7mrdf9.js → cli-3vjhs18n.js} +4 -6
- package/dist/{cli-vfym7wmz.js → cli-3xcwp3z8.js} +10 -12
- package/dist/{cli-az48n0nr.js → cli-4caa1x7d.js} +67 -64
- package/dist/{cli-5jnhv72d.js → cli-4t0fmf3z.js} +30 -7
- package/dist/{cli-5b456bpf.js → cli-530hkwdy.js} +7 -9
- package/dist/{cli-pz4rk021.js → cli-54vrpgm0.js} +1 -1
- package/dist/{cli-ddaanqkd.js → cli-587857ys.js} +7 -7
- package/dist/{cli-r9jqcehk.js → cli-5mpy301f.js} +38 -2
- package/dist/{cli-cppkf404.js → cli-605nn699.js} +80 -43
- package/dist/{cli-6pfd54vx.js → cli-650zv9q9.js} +10 -10
- package/dist/cli-6pzk82fd.js +778 -0
- package/dist/{cli-gz6q4eve.js → cli-715t1gx6.js} +9 -9
- package/dist/{cli-08bmz9z9.js → cli-9aezs55w.js} +10 -12
- package/dist/{cli-tgrv9cjx.js → cli-9r5gtwjr.js} +3 -3
- package/dist/{cli-pc6n7fre.js → cli-a0657jmf.js} +2 -2
- package/dist/{cli-pjctyea3.js → cli-agyaeef4.js} +3 -3
- package/dist/cli-b932gexn.js +5266 -0
- package/dist/{cli-e46hg0xw.js → cli-bc779n4v.js} +3 -3
- package/dist/{cli-jtjtabxe.js → cli-btc9cb4c.js} +78 -5
- package/dist/{cli-caj33vcq.js → cli-btf6fw39.js} +5 -5
- package/dist/{cli-q3tkegby.js → cli-cseh6f8w.js} +5 -5
- package/dist/{cli-n6bv12jn.js → cli-cvs2r2vq.js} +23 -14
- package/dist/{cli-tfyyvzx6.js → cli-cyn9v8zr.js} +17 -2
- package/dist/{cli-a22h291q.js → cli-d6521kb5.js} +1 -1
- package/dist/{cli-1b7btd38.js → cli-d84byzn8.js} +869 -5
- package/dist/{cli-wx3rhnm0.js → cli-eddnyg3t.js} +1 -1
- package/dist/{cli-nmzhp1b5.js → cli-ejkvvqbe.js} +55 -46
- package/dist/{cli-ftyxyspd.js → cli-eqtfgfr6.js} +1 -1
- package/dist/{cli-mthwvjre.js → cli-f2zenhja.js} +1 -1
- package/dist/{cli-ws19768n.js → cli-fayav105.js} +624 -227
- package/dist/{cli-ferkkrg9.js → cli-fjggej24.js} +2 -2
- package/dist/{cli-g7s47cc5.js → cli-fsgttth8.js} +123 -102
- package/dist/{cli-8305gbq0.js → cli-gce09r66.js} +5 -5
- package/dist/{cli-mkk9rnzz.js → cli-gxy8y1dt.js} +51 -4
- package/dist/{cli-fyt2g4wd.js → cli-hae9j8sv.js} +288 -76
- package/dist/{cli-agfm16v9.js → cli-hg42n3hx.js} +12 -12
- package/dist/{cli-qghe0h66.js → cli-hwprv9e4.js} +8 -10
- package/dist/{cli-yndmfxb3.js → cli-hxpyc9sn.js} +3 -3
- package/dist/{cli-72v799xn.js → cli-jfx48xrj.js} +10 -12
- package/dist/{cli-dhar9qay.js → cli-jrp1dt73.js} +2 -2
- package/dist/{cli-98rw5dt5.js → cli-jrzkw01m.js} +2 -2
- package/dist/{cli-ayayvfg4.js → cli-k70e3x9e.js} +24 -20
- package/dist/{cli-583frbyr.js → cli-kchjb7qy.js} +1 -1
- package/dist/{cli-cm5yqn35.js → cli-kf3pxxdg.js} +1 -0
- package/dist/{cli-fmjd0t1y.js → cli-m0cy2vyf.js} +2 -2
- package/dist/{cli-4zsenjhy.js → cli-m5akxq8q.js} +16 -3
- package/dist/{cli-73jzwksr.js → cli-m88rpzkh.js} +6 -3
- package/dist/{cli-95jzxcp3.js → cli-mnrkgg60.js} +4 -4
- package/dist/{cli-p82cnnjq.js → cli-ms5m5r1y.js} +1 -1
- package/dist/{cli-fy6x31ps.js → cli-n5yexkdg.js} +1 -0
- package/dist/{cli-wk5yrfwd.js → cli-neyag5p6.js} +191 -85
- package/dist/cli-p0m0p34z.js +9321 -0
- package/dist/{cli-yyj3j5m4.js → cli-p17970qv.js} +8 -10
- package/dist/{cli-6vcp76qk.js → cli-p74md7t8.js} +42 -23
- package/dist/{cli-rjcbm574.js → cli-pr0eze3x.js} +2 -2
- package/dist/{cli-35rsp8ye.js → cli-qkdmz8c8.js} +1 -1
- package/dist/{cli-rtt8g4v9.js → cli-qmd3mse0.js} +2 -2
- package/dist/{cli-je518txm.js → cli-qzt90yze.js} +20 -20
- package/dist/cli-rkc97c6a.js +39 -0
- package/dist/{cli-75gkpjvw.js → cli-rvhdmjvt.js} +8 -12
- package/dist/{cli-6g0hb4cp.js → cli-rwymrnaz.js} +18608 -9089
- package/dist/{cli-3fg0bdcv.js → cli-serm8zrx.js} +6 -6
- package/dist/{cli-g08zdaec.js → cli-sgs5k6yd.js} +1 -1
- package/dist/{cli-afkqkrtw.js → cli-sya22y84.js} +21 -9
- package/dist/{cli-318r69gq.js → cli-t73cas91.js} +440 -9
- package/dist/{cli-e5bzrn01.js → cli-tqq0hspb.js} +2 -2
- package/dist/{cli-pq73h5mz.js → cli-v3cf1ts9.js} +3 -3
- package/dist/{cli-bfv7vdg6.js → cli-varqt4d1.js} +28 -16
- package/dist/{cli-k899ehvh.js → cli-vxh6acp7.js} +6 -6
- package/dist/{cli-g83s9ewh.js → cli-xfjrc279.js} +1 -1
- package/dist/{cli-k1nje3v3.js → cli-xk879m3k.js} +129 -115
- package/dist/{cli-7cx2m6t2.js → cli-y5rbvxhc.js} +2 -2
- package/dist/{cli-8sckt74b.js → cli-y8nbefpb.js} +41 -19
- package/dist/{cli-81p9jd57.js → cli-yab6sh8p.js} +9 -3
- package/dist/{cli-srye3vdt.js → cli-ybjdc978.js} +1 -1
- package/dist/{cli-k5671be5.js → cli-zcfpsfzf.js} +5 -5
- package/dist/{cli-vf078p3e.js → cli-zfqg6fzn.js} +1 -1
- package/dist/{cli-k8196sh2.js → cli-zgv8gxgs.js} +9 -8
- package/dist/cli.js +34 -52
- package/dist/{cloudflare-workers-ai-system-one-ef2a980q.js → cloudflare-workers-ai-system-one-9y1zx3pt.js} +2 -2
- package/dist/{codex-adapter-cf2yxe9m.js → codex-adapter-ysq6bzha.js} +7 -7
- package/dist/{codex-hook-a0c6g6t6.js → codex-hook-fac6175r.js} +1 -1
- package/dist/{codex-login-y0pmff1c.js → codex-login-bcda78ge.js} +2 -2
- package/dist/{codex-session-runner-6vfzdgbd.js → codex-session-runner-qakzfx93.js} +8 -8
- package/dist/{commands-t3mfy7vn.js → commands-rs7hkv9r.js} +3 -3
- package/dist/{controller-q7xrbaz0.js → controller-r5x9bg6e.js} +4 -4
- package/dist/{controllers-connect-c6nm70kg.js → controllers-connect-498hrxvk.js} +24 -24
- package/dist/{cursor-adapter-ftd81ga8.js → cursor-adapter-d46qszer.js} +2 -2
- package/dist/{db-vemtpmcc.js → db-pm96nhdb.js} +6 -2
- package/dist/{db-dk572x25.js → db-s13dqhr6.js} +3 -3
- package/dist/{devin-adapter-r9phbnc9.js → devin-adapter-z46ep5ph.js} +1 -1
- package/dist/{dispatcher-kh7ecxh9.js → dispatcher-j3h81t7m.js} +18 -18
- package/dist/{docker-c1a3gqmf.js → docker-866qpzt9.js} +2 -2
- package/dist/{dsh-adapter-v8628r89.js → dsh-adapter-rw0d5rc4.js} +2 -2
- package/dist/{e2b-fr12yccx.js → e2b-jkwfhbcv.js} +2 -2
- package/dist/{e2b-x6ywzak3.js → e2b-s16txnpx.js} +2 -3
- package/dist/{easter-egg-3d-nenw4x63.js → easter-egg-3d-qtgfxgze.js} +1 -1
- package/dist/{embedding-space-0jepb239.js → embedding-space-xh8p4q4x.js} +6 -6
- package/dist/{embeddings-xxt49yxg.js → embeddings-wp745m91.js} +1 -1
- package/dist/{event-bus-g0ka3pbw.js → event-bus-e66gh7cc.js} +1 -1
- package/dist/{execute-1mhw6e4x.js → execute-2fzb9z74.js} +1 -1
- package/dist/{external-channel-55v12e60.js → external-channel-ys21h3sy.js} +2 -2
- package/dist/fx-adapter-vz0b9z3g.js +19 -0
- package/dist/{google-generative-ai-v94hr7h0.js → google-generative-ai-ytpgncx9.js} +7 -12
- package/dist/{google-vertex-g7vr6cf8.js → google-vertex-tqhze5j7.js} +7 -12
- package/dist/grok-adapter-spea7zkj.js +19 -0
- package/dist/handlers-crckt5dq.js +32 -0
- package/dist/{heartbeat-k42svnr0.js → heartbeat-8phn1kdq.js} +21 -21
- package/dist/{hook-6nphweh0.js → hook-amcj4s10.js} +16 -11
- package/dist/{hook-114m7hap.js → hook-bc6n49qn.js} +5 -5
- package/dist/{http-r8cc4wz7.js → http-7374brv5.js} +854 -332
- package/dist/index-4x08sjtk.js +30 -0
- package/dist/{index-6cxzwfen.js → index-5a9jtqde.js} +26 -26
- package/dist/index-8ybffts4.js +37 -0
- package/dist/{index-nh3wyqdt.js → index-c9y31ytf.js} +16 -16
- package/dist/{index-h39zbx67.js → index-hsad2t3r.js} +31 -31
- package/dist/index-nfy4kkg5.js +33 -0
- package/dist/{index-e3s8wmxy.js → index-p4hjwbvw.js} +1 -1
- package/dist/{index-k7fj52d3.js → index-q5cmtbz5.js} +6 -6
- package/dist/{index-fpk4bcd9.js → index-w4m9z29z.js} +1 -1
- package/dist/{keepalive-x060nt9p.js → keepalive-wy29kbrg.js} +4 -4
- package/dist/lead-zdqxsvjn.js +71 -0
- package/dist/{llama-cpp-classify-s5c47rwh.js → llama-cpp-classify-nfgswa1m.js} +2 -2
- package/dist/{maintenance-2xxfexhf.js → maintenance-h2ds9w6c.js} +1 -1
- package/dist/{mistral-conversations-3gjpdb4b.js → mistral-conversations-a45tx39a.js} +29 -51
- package/dist/{oauth-refresh-sweep-fckc4ar5.js → oauth-refresh-sweep-q7mtbyp3.js} +3 -3
- package/dist/{onboard-zc48j237.js → onboard-vw8r2fdw.js} +68 -16
- package/dist/{openai-codex-responses-8pbxq9h5.js → openai-codex-responses-k9gapdze.js} +7 -11
- package/dist/{openai-completions-rm00s912.js → openai-completions-xd579js7.js} +50 -58
- package/dist/{openai-decisions-8v957r2r.js → openai-decisions-q3hh60wr.js} +2 -2
- package/dist/{openai-responses-agxpf96k.js → openai-responses-4d5dx3c7.js} +5 -10
- package/dist/{opencode-adapter-r690h1cr.js → opencode-adapter-mtb0953j.js} +6 -6
- package/dist/{openrouter-images-3ecegv0d.js → openrouter-images-xr9gme9x.js} +4 -3
- package/dist/{otel-impl-r5xbh81q.js → otel-impl-j42czw3r.js} +2 -2
- package/dist/{pi-messages-pchtw4he.js → pi-messages-hjbv8v10.js} +28 -12
- package/dist/{pi-mono-adapter-c7v8sdec.js → pi-mono-adapter-zk8pg9jr.js} +30 -27
- package/dist/{pricing-refresh-3pmre11v.js → pricing-refresh-x7nhv23d.js} +3 -3
- package/dist/{rbac-roles-3vbshwsb.js → rbac-roles-9044425x.js} +16 -2
- package/dist/rbac-roles-bzvee6cf.js +37 -0
- package/dist/{render-v2-pxykkbab.js → render-v2-t7bn4skz.js} +3 -3
- package/dist/{resume-adda0bwy.js → resume-x94gemep.js} +7 -7
- package/dist/{runtime-fnbm7stk.js → runtime-breq6fmv.js} +1 -1
- package/dist/{session-access-2fvamrdc.js → session-access-q7dmqjvt.js} +7 -5
- package/dist/{session-source-backfill-08xvv0sm.js → session-source-backfill-440ysamr.js} +3 -3
- package/dist/{setup-1aqmvmh1.js → setup-07n4727s.js} +1 -1
- package/dist/{typesafe-system-one-0bmqcxfg.js → typesafe-system-one-f2en2knd.js} +2 -2
- package/dist/virtual-modules-z5h6mcyf.js +362 -0
- package/dist/{work-objects-9s0yrm5j.js → work-objects-pnq5y534.js} +21 -21
- package/dist/{worker-follow-up-3q78fqmr.js → worker-follow-up-7z1gfkr8.js} +18 -18
- package/dist/worker-y62rvvq3.js +71 -0
- package/dist/{x-vmmye1kb.js → x-2fyrt5pp.js} +2 -2
- package/openapi.json +1268 -276
- package/package.json +10 -10
- package/src/apps/catalog.generated.json +299 -82
- package/src/apps/page-validator.ts +115 -2
- package/src/be/connector-codes.ts +21 -6
- package/src/be/db/model-profiles.ts +1 -1
- package/src/be/db/session-tree.ts +9 -5
- package/src/be/db/session-visibility.ts +25 -9
- package/src/be/db/tasks/read.ts +33 -6
- package/src/be/db/tasks/write.ts +77 -7
- package/src/be/db-queries/tracker.ts +4 -2
- package/src/be/db.ts +53 -19
- package/src/be/improvements.ts +416 -0
- package/src/be/migrations/271_subscription_usage_model.sql +30 -0
- package/src/be/migrations/274_improvements.sql +27 -0
- package/src/be/migrations/275_task_dispatched_by.sql +8 -0
- package/src/be/model-validation.ts +19 -1
- package/src/be/rbac-roles.ts +144 -1
- package/src/be/runtime-pools/routing.ts +1 -1
- package/src/be/scripts/boot-args-schema.ts +95 -0
- package/src/be/scripts/extract-schema.ts +15 -10
- package/src/be/seed-scripts/catalog/boot-triage.inline.ts +1 -1
- package/src/be/seed-scripts/catalog/boot-triage.ts +1 -1
- package/src/be/seed-scripts/catalog/get-child-outputs.ts +1 -1
- package/src/be/seed-scripts/catalog/wait-for-task.ts +1 -1
- package/src/be/swarm-config-guard.ts +8 -0
- package/src/be/users.ts +64 -5
- package/src/cli.tsx +5 -25
- package/src/commands/claude-managed-setup.ts +1 -1
- package/src/commands/codex-login.ts +1 -1
- package/src/commands/e2b.ts +0 -1
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/onboard/compose-generator.ts +0 -1
- package/src/commands/onboard/dashboard-url.ts +31 -0
- package/src/commands/onboard/steps/generate.tsx +17 -1
- package/src/commands/onboard/steps/post-dashboard.tsx +9 -3
- package/src/commands/onboard.tsx +19 -6
- package/src/commands/runner.ts +143 -105
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/hooks/hook.ts +13 -5
- package/src/http/agents.ts +7 -1
- package/src/http/all-routes.ts +1 -0
- package/src/http/approval-requests.ts +32 -50
- package/src/http/auth.ts +5 -4
- package/src/http/codex-oauth-accounts.ts +31 -23
- package/src/http/codex-oauth-device.ts +3 -3
- package/src/http/codex-oauth-keep-warm.ts +1 -1
- package/src/http/improvements.ts +317 -0
- package/src/http/index.ts +10 -0
- package/src/http/mcp-oauth.ts +6 -0
- package/src/http/mcp-servers.ts +8 -0
- package/src/http/models-catalog.ts +1 -1
- package/src/http/operator-actor.ts +2 -1
- package/src/http/pages-public.ts +38 -1
- package/src/http/person-responder.ts +66 -0
- package/src/http/poll.ts +3 -4
- package/src/http/prompt-templates.ts +1 -1
- package/src/http/schedules.ts +4 -0
- package/src/http/script-runs.ts +6 -1
- package/src/http/session-access.ts +61 -6
- package/src/http/sessions.ts +67 -9
- package/src/http/tasks.ts +53 -9
- package/src/http/user-roles.ts +11 -2
- package/src/http/users.ts +224 -105
- package/src/http/utils.ts +2 -1
- package/src/http/workflows.ts +11 -7
- package/src/prompts/session-templates.ts +1 -0
- package/src/providers/acp-targets.ts +1 -1
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/codex-adapter.ts +17 -3
- package/src/providers/codex-models.ts +4 -3
- package/src/providers/codex-oauth/auth-json.ts +14 -18
- package/src/providers/codex-oauth/device.ts +49 -15
- package/src/providers/codex-oauth/flow.ts +2 -1
- package/src/providers/codex-oauth/storage.ts +2 -2
- package/src/providers/pi-mono-adapter.ts +8 -0
- package/src/providers/pricing-sources.md +16 -1
- package/src/providers/swarm-events-shared.ts +15 -2
- package/src/rbac/legacy-policy.ts +3 -0
- package/src/rbac/permissions.ts +15 -0
- package/src/scheduler/deferred-task-waits.ts +9 -4
- package/src/scripts-runtime/extract-args-schema.ts +3 -1
- package/src/scripts-runtime/swarm-sdk.ts +1 -1
- package/src/scripts-runtime/types/swarm-extension.d.ts +31 -28
- package/src/server-user.ts +1 -1
- package/src/server.ts +2 -0
- package/src/slack/ack.ts +68 -26
- package/src/slack/blocks.ts +1 -0
- package/src/slack/reaction-shortcode.ts +8 -2
- package/src/slack/render-v2.ts +72 -20
- package/src/slack/task-output.ts +4 -1
- package/src/slack/thread-buffer.ts +2 -2
- package/src/tasks/task-skip.ts +28 -0
- package/src/tasks/terminal-result-guard.ts +3 -2
- package/src/telemetry.ts +28 -1
- package/src/tests/agentmail-inbox-mapping.test.ts +73 -0
- package/src/tests/api-drain-worker-e2e.test.ts +69 -2
- package/src/tests/approval-requests.test.ts +58 -0
- package/src/tests/apps-catalog-drift.test.ts +35 -0
- package/src/tests/apps-catalog-table.test.ts +203 -0
- package/src/tests/apps-element-assembly.test.ts +28 -0
- package/src/tests/apps-smart-links.test.ts +151 -0
- package/src/tests/apps-table-filters-migration.test.ts +96 -0
- package/src/tests/apps-table-selection-migration.test.ts +95 -0
- package/src/tests/chatgpt-subscription-session-bench.test.ts +2 -2
- package/src/tests/claude-managed-setup.test.ts +36 -0
- package/src/tests/claude-worker-parity.test.ts +2 -2
- package/src/tests/codex-adapter.test.ts +32 -2
- package/src/tests/codex-login.test.ts +2 -2
- package/src/tests/codex-oauth-accounts.test.ts +48 -12
- package/src/tests/codex-oauth-credential-info.test.ts +77 -1
- package/src/tests/codex-oauth-device.test.ts +61 -1
- package/src/tests/codex-oauth-keep-warm.test.ts +2 -2
- package/src/tests/codex-oauth.test.ts +25 -4
- package/src/tests/codex-pool.test.ts +2 -2
- package/src/tests/codex-swarm-events.test.ts +43 -1
- package/src/tests/context-window.test.ts +14 -0
- package/src/tests/db-queries-tracker.test.ts +2 -1
- package/src/tests/db-task-read-contract.test.ts +3 -0
- package/src/tests/db-task-write-contract.test.ts +3 -0
- package/src/tests/deferred-task-wake.test.ts +7 -2
- package/src/tests/deploy-one-box.test.ts +39 -1
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/e2e-coverage-contract.test.ts +235 -0
- package/src/tests/empty-output-schema.test.ts +160 -0
- package/src/tests/env-flag.test.ts +1 -0
- package/src/tests/explicit-model-validation.test.ts +14 -0
- package/src/tests/fixtures/onboard/content.compose.yml.txt +0 -4
- package/src/tests/fixtures/onboard/dev.compose.yml.txt +0 -3
- package/src/tests/fixtures/onboard/full-all.compose.yml.txt +0 -11
- package/src/tests/fixtures/onboard/full.compose.yml.txt +0 -11
- package/src/tests/fixtures/onboard/research.compose.yml.txt +0 -3
- package/src/tests/fixtures/onboard/solo.compose.yml.txt +0 -1
- package/src/tests/fixtures/prs-app-definition.json.txt +784 -0
- package/src/tests/fixtures/prs-filters-migration.patch.json.txt +318 -0
- package/src/tests/fixtures/prs-selection-migration.patch.json.txt +373 -0
- package/src/tests/fixtures/runner-identity-refresh.ts +3 -0
- package/src/tests/fixtures/runner-legacy-resume-prompt.ts +3 -0
- package/src/tests/fixtures/runner-task-start-reads.ts +140 -0
- package/src/tests/hook-ping-me-order.test.ts +85 -0
- package/src/tests/http-api-integration.test.ts +2 -2
- package/src/tests/http-users.test.ts +63 -0
- package/src/tests/improvements-payload.test.ts +200 -0
- package/src/tests/improvements-route.test.ts +419 -0
- package/src/tests/install-sh-setup-url.test.ts +190 -0
- package/src/tests/mcp-input-caps.test.ts +4 -3
- package/src/tests/merge-gate-detect-changes.test.ts +22 -0
- package/src/tests/onboard-dashboard-output.test.ts +109 -0
- package/src/tests/onboard-dashboard-url.test.ts +83 -0
- package/src/tests/operator-granted-credentials.test.ts +561 -0
- package/src/tests/operator-granted-role-wire.test.ts +222 -0
- package/src/tests/pages-authed-mode.test.ts +13 -2
- package/src/tests/pi-mono-adapter.test.ts +39 -4
- package/src/tests/rbac-engine.test.ts +3 -0
- package/src/tests/runner-context-usage.test.ts +118 -0
- package/src/tests/runner-legacy-options.test.ts +55 -0
- package/src/tests/runner-slot-reconcile.test.ts +38 -0
- package/src/tests/runner-task-start-reads.test.ts +58 -0
- package/src/tests/script-connections.test.ts +2 -0
- package/src/tests/script-executor-quickjs.test.ts +2 -0
- package/src/tests/script-runs-http.test.ts +57 -0
- package/src/tests/scripts-boot-args-schema.test.ts +181 -0
- package/src/tests/scripts-runtime.test.ts +24 -0
- package/src/tests/sdk-store-progress-skipped.test.ts +155 -0
- package/src/tests/send-task-dispatched-by.test.ts +129 -0
- package/src/tests/session-costs-model-key-normalize.test.ts +59 -0
- package/src/tests/session-dispatched-tasks.test.ts +115 -0
- package/src/tests/session-sharing.test.ts +402 -3
- package/src/tests/slack-file-tools-attachments.test.ts +95 -3
- package/src/tests/slack-reaction-config.test.ts +40 -0
- package/src/tests/slack-render-v2.test.ts +120 -0
- package/src/tests/slack-skip-reaction.test.ts +203 -0
- package/src/tests/store-progress-skipped.test.ts +159 -0
- package/src/tests/submit-improvement-tool.test.ts +82 -0
- package/src/tests/subscription-usage-migration.test.ts +57 -0
- package/src/tests/swarm-config-reserved-keys.test.ts +3 -0
- package/src/tests/telemetry-endpoint-override.test.ts +27 -0
- package/src/tests/tool-annotations.test.ts +1 -1
- package/src/tests/trigger-claiming.test.ts +2 -0
- package/src/tests/workflow-system-one-extraction.test.ts +29 -0
- package/src/tools/create-channel.ts +1 -1
- package/src/tools/defer-task.ts +1 -1
- package/src/tools/manage-user.ts +88 -58
- package/src/tools/register-agentmail-inbox.ts +5 -0
- package/src/tools/repos/update-repo.ts +1 -1
- package/src/tools/request-human-input.ts +1 -1
- package/src/tools/send-task.ts +4 -1
- package/src/tools/slack-read.ts +61 -33
- package/src/tools/store-progress.ts +39 -8
- package/src/tools/submit-improvement.ts +68 -0
- package/src/tools/tool-config.ts +3 -0
- package/src/tools/tracker/tracker-unlink.ts +2 -1
- package/src/tools/workflows/retry-workflow-run.ts +3 -0
- package/src/types.ts +16 -2
- package/src/utils/context-window.ts +6 -1
- package/src/utils/output-schema.ts +23 -0
- package/src/utils/request-auth-context.ts +6 -1
- package/src/workflows/executors/system-one-providers.ts +25 -6
- package/src/workflows/recovery.ts +8 -4
- package/src/workflows/resume.ts +19 -0
- package/templates/skills/apps/SKILL.md +22 -11
- package/templates/skills/apps/content.md +22 -11
- package/templates/skills/swarm-scripts/SKILL.md +1 -1
- package/templates/skills/swarm-scripts/content.md +1 -1
- package/templates/skills/work-on-task/SKILL.md +1 -1
- package/templates/skills/work-on-task/content.md +1 -1
- package/dist/acp-adapter-7b4vk3h5.js +0 -16
- package/dist/cli-5c4hjzne.js +0 -873
- package/dist/cli-excnnjg2.js +0 -20222
- package/dist/cli-pc5znp64.js +0 -364
- package/dist/cli-vz22fyqv.js +0 -428
- package/dist/fx-adapter-bs8wqrk5.js +0 -19
- package/dist/grok-adapter-gpjqmkcq.js +0 -19
- package/dist/handlers-zxmp1ta4.js +0 -32
- package/dist/index-a8phxqnk.js +0 -37
- package/dist/index-k6h00t4c.js +0 -30
- package/dist/index-xrz7te8h.js +0 -33
- package/dist/lead-956sd2yc.js +0 -71
- package/dist/rbac-roles-910mmkgz.js +0 -26
- package/dist/virtual-modules-d2pjk9j1.js +0 -59
- package/dist/worker-y15hy08h.js +0 -71
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bedrockProviderModule
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-fsgttth8.js";
|
|
4
4
|
import {
|
|
5
5
|
chatThreadOfContextKey,
|
|
6
6
|
agentContextKey,
|
|
@@ -60,6 +60,32 @@ import {
|
|
|
60
60
|
closeDb2,
|
|
61
61
|
getDbClient2,
|
|
62
62
|
init_runtime2,
|
|
63
|
+
CHAT_SDK_ADAPTER_NAMES,
|
|
64
|
+
isAdapterEntryEnabled,
|
|
65
|
+
init_schema,
|
|
66
|
+
TELEMETRY_RANKING_KEY,
|
|
67
|
+
PUBLIC_RANKING_ENABLED_KEY,
|
|
68
|
+
RANKING_CATEGORIES,
|
|
69
|
+
readTelemetryRanking,
|
|
70
|
+
rankingFormSchema,
|
|
71
|
+
buildListing,
|
|
72
|
+
init_telemetry_ranking,
|
|
73
|
+
API_DRAINING_HEADER,
|
|
74
|
+
init_api_drain2,
|
|
75
|
+
parseTaskToolManifest,
|
|
76
|
+
CHAT_TASK_ONLY_TOOLS,
|
|
77
|
+
isChatSdkTask,
|
|
78
|
+
selectTaskTools,
|
|
79
|
+
init_task_tool_manifest,
|
|
80
|
+
isApiOnlyConfigKey,
|
|
81
|
+
isInternalConfigKey,
|
|
82
|
+
internalConfigKeyError,
|
|
83
|
+
MAX_DB_RETENTION_DAYS,
|
|
84
|
+
DB_RETENTION_TUNING_BOUNDS,
|
|
85
|
+
CODEX_OAUTH_KEEP_WARM_MAX_AGE_HOURS_BOUNDS,
|
|
86
|
+
validateConfigValue,
|
|
87
|
+
validateConfigEntry,
|
|
88
|
+
init_swarm_config_guard,
|
|
63
89
|
cachedUserRole,
|
|
64
90
|
cachedUserFunction,
|
|
65
91
|
configureOrgDomainPersistence,
|
|
@@ -110,6 +136,7 @@ import {
|
|
|
110
136
|
getTaskById2,
|
|
111
137
|
TASK_LINEAGE_LIMITS2,
|
|
112
138
|
getTaskLineage2,
|
|
139
|
+
getTasksDispatchedFrom2,
|
|
113
140
|
getAllTasks2,
|
|
114
141
|
getTasksCount2,
|
|
115
142
|
getTaskStats2,
|
|
@@ -147,32 +174,6 @@ import {
|
|
|
147
174
|
init_channels,
|
|
148
175
|
publishWorkerNudge,
|
|
149
176
|
init_worker_nudges,
|
|
150
|
-
CHAT_SDK_ADAPTER_NAMES,
|
|
151
|
-
isAdapterEntryEnabled,
|
|
152
|
-
init_schema,
|
|
153
|
-
TELEMETRY_RANKING_KEY,
|
|
154
|
-
PUBLIC_RANKING_ENABLED_KEY,
|
|
155
|
-
RANKING_CATEGORIES,
|
|
156
|
-
readTelemetryRanking,
|
|
157
|
-
rankingFormSchema,
|
|
158
|
-
buildListing,
|
|
159
|
-
init_telemetry_ranking,
|
|
160
|
-
API_DRAINING_HEADER,
|
|
161
|
-
init_api_drain2,
|
|
162
|
-
parseTaskToolManifest,
|
|
163
|
-
CHAT_TASK_ONLY_TOOLS,
|
|
164
|
-
isChatSdkTask,
|
|
165
|
-
selectTaskTools,
|
|
166
|
-
init_task_tool_manifest,
|
|
167
|
-
isApiOnlyConfigKey,
|
|
168
|
-
isInternalConfigKey,
|
|
169
|
-
internalConfigKeyError,
|
|
170
|
-
MAX_DB_RETENTION_DAYS,
|
|
171
|
-
DB_RETENTION_TUNING_BOUNDS,
|
|
172
|
-
CODEX_OAUTH_KEEP_WARM_MAX_AGE_HOURS_BOUNDS,
|
|
173
|
-
validateConfigValue,
|
|
174
|
-
validateConfigEntry,
|
|
175
|
-
init_swarm_config_guard,
|
|
176
177
|
getDefaultAuthorizationIdForProvider,
|
|
177
178
|
getOAuthApp,
|
|
178
179
|
getOAuthAppById,
|
|
@@ -252,6 +253,7 @@ import {
|
|
|
252
253
|
completeTask2,
|
|
253
254
|
failTask2,
|
|
254
255
|
cancelTask2,
|
|
256
|
+
skipTask2,
|
|
255
257
|
supersedeTask2,
|
|
256
258
|
settleSupersededTaskDependents2,
|
|
257
259
|
backfillSupersedeTaskResumeTaskId2,
|
|
@@ -299,7 +301,6 @@ import {
|
|
|
299
301
|
getUnassignedTaskIdsForAgent2,
|
|
300
302
|
updateAgentProfile2,
|
|
301
303
|
updateAgentName2,
|
|
302
|
-
getInboxSummary2,
|
|
303
304
|
claimMentions2,
|
|
304
305
|
createSessionLogs2,
|
|
305
306
|
getSessionLogsByTaskId2,
|
|
@@ -479,19 +480,22 @@ import {
|
|
|
479
480
|
countScriptRunJournalSteps2,
|
|
480
481
|
countScriptRunJournalAgentTaskSteps2,
|
|
481
482
|
init_db4
|
|
482
|
-
} from "./cli-
|
|
483
|
+
} from "./cli-neyag5p6.js";
|
|
483
484
|
import {
|
|
484
485
|
PRIMARY_ROLE_NAMES2,
|
|
486
|
+
OperatorGrantedTargetError2,
|
|
487
|
+
assertMayActOnOperatorGrantedTarget2,
|
|
485
488
|
getUserGrant2,
|
|
486
489
|
listUserRoles2,
|
|
487
490
|
listRbacRoles2,
|
|
488
491
|
InvalidRoleSetError2,
|
|
492
|
+
OperatorGrantedRoleError2,
|
|
489
493
|
LastAdminError2,
|
|
490
494
|
assertNotLastAdmin2,
|
|
491
495
|
setUserRoles2,
|
|
492
496
|
init_rbac_roles
|
|
493
|
-
} from "./cli-
|
|
494
|
-
import"./cli-
|
|
497
|
+
} from "./cli-btc9cb4c.js";
|
|
498
|
+
import"./cli-2a8py3sx.js";
|
|
495
499
|
import {
|
|
496
500
|
upsertModelCatalogOverlay,
|
|
497
501
|
deleteModelCatalogOverlay,
|
|
@@ -499,12 +503,12 @@ import {
|
|
|
499
503
|
init_model_catalog_store,
|
|
500
504
|
requestModelCatalogRefresh2,
|
|
501
505
|
init_pricing_refresh
|
|
502
|
-
} from "./cli-
|
|
506
|
+
} from "./cli-530hkwdy.js";
|
|
503
507
|
import {
|
|
504
508
|
workflowEventBus2,
|
|
505
509
|
init_event_bus
|
|
506
|
-
} from "./cli-
|
|
507
|
-
import"./cli-
|
|
510
|
+
} from "./cli-eddnyg3t.js";
|
|
511
|
+
import"./cli-qmd3mse0.js";
|
|
508
512
|
import {
|
|
509
513
|
require_dist4,
|
|
510
514
|
getSlackConnectionState,
|
|
@@ -535,12 +539,12 @@ import {
|
|
|
535
539
|
startSlackApp2,
|
|
536
540
|
stopSlackApp2,
|
|
537
541
|
init_app3
|
|
538
|
-
} from "./cli-
|
|
542
|
+
} from "./cli-605nn699.js";
|
|
539
543
|
import {
|
|
540
544
|
retryFailedRun2,
|
|
541
545
|
cancelWorkflowRun2,
|
|
542
546
|
init_resume
|
|
543
|
-
} from "./cli-
|
|
547
|
+
} from "./cli-sya22y84.js";
|
|
544
548
|
import {
|
|
545
549
|
DEFAULT_NEGOTIATED_PROTOCOL_VERSION,
|
|
546
550
|
SUPPORTED_PROTOCOL_VERSIONS,
|
|
@@ -771,6 +775,8 @@ import {
|
|
|
771
775
|
init_app2,
|
|
772
776
|
init_linear,
|
|
773
777
|
init_slack,
|
|
778
|
+
verifyPageSession,
|
|
779
|
+
LEGACY_PAGE_SESSION_COOKIE,
|
|
774
780
|
isCookieSafePageId,
|
|
775
781
|
extractPageSession,
|
|
776
782
|
extractLegacyPageSession,
|
|
@@ -940,6 +946,21 @@ import {
|
|
|
940
946
|
steerTaskOutputSchema,
|
|
941
947
|
steerTaskHandler,
|
|
942
948
|
init_steer_task,
|
|
949
|
+
skipReasonFrom,
|
|
950
|
+
finalizeSkippedTaskReaction,
|
|
951
|
+
init_task_skip,
|
|
952
|
+
IMPROVEMENT_TEXT_MAX,
|
|
953
|
+
IMPROVEMENT_STATUSES,
|
|
954
|
+
IMPROVEMENT_SOURCES,
|
|
955
|
+
ImprovementError,
|
|
956
|
+
isImprovementsEnabled,
|
|
957
|
+
getImprovement,
|
|
958
|
+
listImprovements,
|
|
959
|
+
createImprovement,
|
|
960
|
+
approveAndSend,
|
|
961
|
+
discardImprovement,
|
|
962
|
+
improvementLeakHints,
|
|
963
|
+
init_improvements,
|
|
943
964
|
canClaim,
|
|
944
965
|
init_budget_admission,
|
|
945
966
|
emitBudgetRefusalSideEffects,
|
|
@@ -959,7 +980,7 @@ import {
|
|
|
959
980
|
getEnabledCapabilities,
|
|
960
981
|
createServer,
|
|
961
982
|
init_server
|
|
962
|
-
} from "./cli-
|
|
983
|
+
} from "./cli-fayav105.js";
|
|
963
984
|
import {
|
|
964
985
|
FilesError,
|
|
965
986
|
normalizeFilesError,
|
|
@@ -991,7 +1012,7 @@ import {
|
|
|
991
1012
|
resolvePoolDelivery2,
|
|
992
1013
|
createPoolAgent2,
|
|
993
1014
|
init_db2
|
|
994
|
-
} from "./cli-
|
|
1015
|
+
} from "./cli-587857ys.js";
|
|
995
1016
|
import {
|
|
996
1017
|
duplicateGuardedQueryKey,
|
|
997
1018
|
warnIfCorsAllowsAnyOrigin,
|
|
@@ -1017,6 +1038,7 @@ import {
|
|
|
1017
1038
|
init_utils2,
|
|
1018
1039
|
hasSessionAccess,
|
|
1019
1040
|
getSessionRoot,
|
|
1041
|
+
getSessionRoots,
|
|
1020
1042
|
sessionAccessForRoot,
|
|
1021
1043
|
listActiveSessionShares,
|
|
1022
1044
|
toSessionSharesState,
|
|
@@ -1029,6 +1051,7 @@ import {
|
|
|
1029
1051
|
resolveHttpFavoriteOwner,
|
|
1030
1052
|
init_favorite_owner,
|
|
1031
1053
|
resolveSessionActor2,
|
|
1054
|
+
withReadAll2,
|
|
1032
1055
|
sessionAccessFor2,
|
|
1033
1056
|
SESSION_READ_DENIED2,
|
|
1034
1057
|
canReadSession2,
|
|
@@ -1045,7 +1068,7 @@ import {
|
|
|
1045
1068
|
describeRequestRoute,
|
|
1046
1069
|
route,
|
|
1047
1070
|
init_route_def
|
|
1048
|
-
} from "./cli-
|
|
1071
|
+
} from "./cli-y8nbefpb.js";
|
|
1049
1072
|
import {
|
|
1050
1073
|
startPoolRouting,
|
|
1051
1074
|
stopPoolRouting,
|
|
@@ -1058,28 +1081,28 @@ import {
|
|
|
1058
1081
|
checkHeartbeatChecklist2,
|
|
1059
1082
|
runHeartbeatSweep2,
|
|
1060
1083
|
stopHeartbeat2
|
|
1061
|
-
} from "./cli-
|
|
1062
|
-
import"./cli-
|
|
1084
|
+
} from "./cli-varqt4d1.js";
|
|
1085
|
+
import"./cli-serm8zrx.js";
|
|
1063
1086
|
import {
|
|
1064
1087
|
runtimeSupervisorStatus,
|
|
1065
1088
|
startRuntimeSupervisor,
|
|
1066
1089
|
stopRuntimeSupervisor
|
|
1067
|
-
} from "./cli-
|
|
1090
|
+
} from "./cli-qzt90yze.js";
|
|
1068
1091
|
import {
|
|
1069
1092
|
TASK_TITLE_TIMEOUT_MS,
|
|
1070
1093
|
generateTaskTitle
|
|
1071
|
-
} from "./cli-
|
|
1094
|
+
} from "./cli-b932gexn.js";
|
|
1072
1095
|
import"./cli-ns59dc6r.js";
|
|
1073
1096
|
import {
|
|
1074
1097
|
ACP_TARGET_IDS
|
|
1075
|
-
} from "./cli-
|
|
1098
|
+
} from "./cli-d6521kb5.js";
|
|
1076
1099
|
import {
|
|
1077
1100
|
reasoningCapability,
|
|
1078
1101
|
supportedReasoningLevels
|
|
1079
|
-
} from "./cli-
|
|
1102
|
+
} from "./cli-jrzkw01m.js";
|
|
1080
1103
|
import {
|
|
1081
1104
|
MAX_RATE_LIMIT_RESET_MS
|
|
1082
|
-
} from "./cli-
|
|
1105
|
+
} from "./cli-f2zenhja.js";
|
|
1083
1106
|
import {
|
|
1084
1107
|
isLeadChannelMonitoringEnabled,
|
|
1085
1108
|
ORG_IDENTITY_KEYS,
|
|
@@ -1089,14 +1112,14 @@ import {
|
|
|
1089
1112
|
isUnknownModelError,
|
|
1090
1113
|
checkProviderPoolKey,
|
|
1091
1114
|
writeSkillsToFilesystem
|
|
1092
|
-
} from "./cli-
|
|
1115
|
+
} from "./cli-p17970qv.js";
|
|
1093
1116
|
import {
|
|
1094
1117
|
inviteEmailToSharedOrg,
|
|
1095
1118
|
ensureAgentFsCredentialsForAgent
|
|
1096
|
-
} from "./cli-
|
|
1119
|
+
} from "./cli-agyaeef4.js";
|
|
1097
1120
|
import {
|
|
1098
1121
|
Anthropic
|
|
1099
|
-
} from "./cli-
|
|
1122
|
+
} from "./cli-t73cas91.js";
|
|
1100
1123
|
import {
|
|
1101
1124
|
isCodexOAuthConfigKey
|
|
1102
1125
|
} from "./cli-j4bwnpkm.js";
|
|
@@ -1109,17 +1132,17 @@ import {
|
|
|
1109
1132
|
ampBillsCacheWrites,
|
|
1110
1133
|
resolveAmpModel,
|
|
1111
1134
|
init_amp_models
|
|
1112
|
-
} from "./cli-
|
|
1135
|
+
} from "./cli-qkdmz8c8.js";
|
|
1113
1136
|
import {
|
|
1114
1137
|
RATING_MODEL_MAX_LENGTH,
|
|
1115
1138
|
REFERENCES_SOURCE_MAX_LENGTH,
|
|
1116
1139
|
sanitizeReferencesSource,
|
|
1117
1140
|
init_types2
|
|
1118
|
-
} from "./cli-
|
|
1141
|
+
} from "./cli-2xv18ywz.js";
|
|
1119
1142
|
import {
|
|
1120
1143
|
normalizeModelKey,
|
|
1121
1144
|
init_pricing_normalize
|
|
1122
|
-
} from "./cli-
|
|
1145
|
+
} from "./cli-a0657jmf.js";
|
|
1123
1146
|
import {
|
|
1124
1147
|
require_dist2,
|
|
1125
1148
|
getMcpOAuthToken,
|
|
@@ -1208,7 +1231,7 @@ import {
|
|
|
1208
1231
|
init_typecheck,
|
|
1209
1232
|
parseSkillContent,
|
|
1210
1233
|
init_skill_parser
|
|
1211
|
-
} from "./cli-
|
|
1234
|
+
} from "./cli-2ccpqyyf.js";
|
|
1212
1235
|
import {
|
|
1213
1236
|
signalProcessGroup,
|
|
1214
1237
|
detachedProcessGroup,
|
|
@@ -1225,7 +1248,7 @@ import {
|
|
|
1225
1248
|
forceRefreshAuthorizationOrThrow,
|
|
1226
1249
|
forceRefreshTokenOrThrow,
|
|
1227
1250
|
init_ensure_token
|
|
1228
|
-
} from "./cli-
|
|
1251
|
+
} from "./cli-cseh6f8w.js";
|
|
1229
1252
|
import {
|
|
1230
1253
|
automationIntegrationFixUrl,
|
|
1231
1254
|
preflightAutomation,
|
|
@@ -1269,7 +1292,7 @@ import {
|
|
|
1269
1292
|
definitionNodeIds,
|
|
1270
1293
|
validateDefinition,
|
|
1271
1294
|
init_definition2
|
|
1272
|
-
} from "./cli-
|
|
1295
|
+
} from "./cli-ejkvvqbe.js";
|
|
1273
1296
|
import {
|
|
1274
1297
|
_fetchHolder,
|
|
1275
1298
|
CLIENT_ID,
|
|
@@ -1285,7 +1308,7 @@ import {
|
|
|
1285
1308
|
loadAllCodexOAuthSlots,
|
|
1286
1309
|
getValidCodexOAuth,
|
|
1287
1310
|
init_storage
|
|
1288
|
-
} from "./cli-
|
|
1311
|
+
} from "./cli-rvhdmjvt.js";
|
|
1289
1312
|
import {
|
|
1290
1313
|
isMultiRuntimeEnabled,
|
|
1291
1314
|
init_multi_runtime2
|
|
@@ -1293,7 +1316,7 @@ import {
|
|
|
1293
1316
|
import {
|
|
1294
1317
|
require_content_type
|
|
1295
1318
|
} from "./cli-yjdgea32.js";
|
|
1296
|
-
import"./cli-
|
|
1319
|
+
import"./cli-sgs5k6yd.js";
|
|
1297
1320
|
import {
|
|
1298
1321
|
isInvalidClientError,
|
|
1299
1322
|
publicEndpointSsrfOptions,
|
|
@@ -1311,11 +1334,30 @@ import {
|
|
|
1311
1334
|
revokeMcpToken,
|
|
1312
1335
|
computeExpiresAt,
|
|
1313
1336
|
init_mcp_wrapper
|
|
1314
|
-
} from "./cli-
|
|
1337
|
+
} from "./cli-btf6fw39.js";
|
|
1315
1338
|
import {
|
|
1316
1339
|
createRuntimeProvider,
|
|
1317
1340
|
init_runtime_providers
|
|
1318
|
-
} from "./cli-
|
|
1341
|
+
} from "./cli-hxpyc9sn.js";
|
|
1342
|
+
import"./cli-v41kn3cd.js";
|
|
1343
|
+
import {
|
|
1344
|
+
setBedrockProviderModule,
|
|
1345
|
+
init_bedrock_converse_stream_lazy
|
|
1346
|
+
} from "./cli-54vrpgm0.js";
|
|
1347
|
+
import {
|
|
1348
|
+
import_websocket,
|
|
1349
|
+
import_websocket_server,
|
|
1350
|
+
init_wrapper2
|
|
1351
|
+
} from "./cli-69szn7w7.js";
|
|
1352
|
+
import {
|
|
1353
|
+
isRbacEnabled,
|
|
1354
|
+
decideToolAdmission,
|
|
1355
|
+
LEGACY_RULES,
|
|
1356
|
+
setAuditSink,
|
|
1357
|
+
clearAuditSink,
|
|
1358
|
+
can,
|
|
1359
|
+
init_rbac
|
|
1360
|
+
} from "./cli-cyn9v8zr.js";
|
|
1319
1361
|
import {
|
|
1320
1362
|
registerSessionTokenConnection,
|
|
1321
1363
|
init_session_token_connections,
|
|
@@ -1342,26 +1384,7 @@ import {
|
|
|
1342
1384
|
revokeAgentTokens,
|
|
1343
1385
|
fingerprintApiKey,
|
|
1344
1386
|
init_users
|
|
1345
|
-
} from "./cli-
|
|
1346
|
-
import"./cli-v41kn3cd.js";
|
|
1347
|
-
import {
|
|
1348
|
-
setBedrockProviderModule,
|
|
1349
|
-
init_bedrock_converse_stream_lazy
|
|
1350
|
-
} from "./cli-pz4rk021.js";
|
|
1351
|
-
import {
|
|
1352
|
-
import_websocket,
|
|
1353
|
-
import_websocket_server,
|
|
1354
|
-
init_wrapper2
|
|
1355
|
-
} from "./cli-69szn7w7.js";
|
|
1356
|
-
import {
|
|
1357
|
-
isRbacEnabled,
|
|
1358
|
-
decideToolAdmission,
|
|
1359
|
-
LEGACY_RULES,
|
|
1360
|
-
setAuditSink,
|
|
1361
|
-
clearAuditSink,
|
|
1362
|
-
can,
|
|
1363
|
-
init_rbac
|
|
1364
|
-
} from "./cli-tfyyvzx6.js";
|
|
1387
|
+
} from "./cli-4t0fmf3z.js";
|
|
1365
1388
|
import {
|
|
1366
1389
|
ASSET_KEY_MAX_LENGTH,
|
|
1367
1390
|
normalizeAssetKey,
|
|
@@ -1519,7 +1542,7 @@ import {
|
|
|
1519
1542
|
KvKeySchema,
|
|
1520
1543
|
KvEntrySchema,
|
|
1521
1544
|
init_types4
|
|
1522
|
-
} from "./cli-
|
|
1545
|
+
} from "./cli-cvs2r2vq.js";
|
|
1523
1546
|
import {
|
|
1524
1547
|
CODEX_AUTH_FAILURE_BENCH_THRESHOLD,
|
|
1525
1548
|
CODEX_AUTH_WATCH_NAMESPACE,
|
|
@@ -1530,7 +1553,7 @@ import {
|
|
|
1530
1553
|
IDENTITY_FIELD_BUDGETS,
|
|
1531
1554
|
IdentityFieldBudgetError,
|
|
1532
1555
|
init_identity_field_budget
|
|
1533
|
-
} from "./cli-
|
|
1556
|
+
} from "./cli-9r5gtwjr.js";
|
|
1534
1557
|
import {
|
|
1535
1558
|
getSlackConfiguration,
|
|
1536
1559
|
init_config4
|
|
@@ -1557,7 +1580,7 @@ import {
|
|
|
1557
1580
|
splitCredentialPool,
|
|
1558
1581
|
selectCredential,
|
|
1559
1582
|
init_credentials2
|
|
1560
|
-
} from "./cli-
|
|
1583
|
+
} from "./cli-xfjrc279.js";
|
|
1561
1584
|
import {
|
|
1562
1585
|
interpolate,
|
|
1563
1586
|
init_template2,
|
|
@@ -1567,10 +1590,10 @@ import {
|
|
|
1567
1590
|
resolveTemplate,
|
|
1568
1591
|
init_resolver,
|
|
1569
1592
|
init_session_templates
|
|
1570
|
-
} from "./cli-
|
|
1593
|
+
} from "./cli-kf3pxxdg.js";
|
|
1571
1594
|
import {
|
|
1572
1595
|
init_zod
|
|
1573
|
-
} from "./cli-
|
|
1596
|
+
} from "./cli-zcfpsfzf.js";
|
|
1574
1597
|
import {
|
|
1575
1598
|
NEVER,
|
|
1576
1599
|
toJSONSchema,
|
|
@@ -1585,7 +1608,7 @@ import {
|
|
|
1585
1608
|
array2,
|
|
1586
1609
|
object2,
|
|
1587
1610
|
looseObject,
|
|
1588
|
-
|
|
1611
|
+
union3,
|
|
1589
1612
|
discriminatedUnion,
|
|
1590
1613
|
record2,
|
|
1591
1614
|
partialRecord,
|
|
@@ -1595,11 +1618,11 @@ import {
|
|
|
1595
1618
|
preprocess,
|
|
1596
1619
|
ZodIssueCode,
|
|
1597
1620
|
exports_coerce
|
|
1598
|
-
} from "./cli-
|
|
1621
|
+
} from "./cli-hg42n3hx.js";
|
|
1599
1622
|
import {
|
|
1600
1623
|
init_package,
|
|
1601
1624
|
package_default
|
|
1602
|
-
} from "./cli-
|
|
1625
|
+
} from "./cli-650zv9q9.js";
|
|
1603
1626
|
import {
|
|
1604
1627
|
realtimeBus,
|
|
1605
1628
|
init_bus
|
|
@@ -1627,19 +1650,17 @@ import {
|
|
|
1627
1650
|
init_api_key
|
|
1628
1651
|
} from "./cli-pax9q4ff.js";
|
|
1629
1652
|
import {
|
|
1653
|
+
isAlias,
|
|
1654
|
+
baseUrlEnvVar,
|
|
1655
|
+
providerForKeyVar,
|
|
1656
|
+
init_src2,
|
|
1630
1657
|
scrubSecrets,
|
|
1631
1658
|
findSecretsIn,
|
|
1632
1659
|
scrubObject,
|
|
1633
1660
|
registerVolatileSecret,
|
|
1634
1661
|
registerEnvSecrets,
|
|
1635
1662
|
init_secret_scrubber
|
|
1636
|
-
} from "./cli-
|
|
1637
|
-
import {
|
|
1638
|
-
isAlias,
|
|
1639
|
-
baseUrlEnvVar,
|
|
1640
|
-
providerForKeyVar,
|
|
1641
|
-
init_src2
|
|
1642
|
-
} from "./cli-5c4hjzne.js";
|
|
1663
|
+
} from "./cli-d84byzn8.js";
|
|
1643
1664
|
import {
|
|
1644
1665
|
__toESM
|
|
1645
1666
|
} from "./cli-242037k3.js";
|
|
@@ -5162,7 +5183,7 @@ var AcpRuntimeConfigSchema = object2({
|
|
|
5162
5183
|
args: array2(string2()).optional(),
|
|
5163
5184
|
envKeys: array2(string2().regex(/^[A-Za-z_][A-Za-z0-9_]*$/)).optional(),
|
|
5164
5185
|
modelEnvKey: string2().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).nullable().optional(),
|
|
5165
|
-
options: record2(string2(),
|
|
5186
|
+
options: record2(string2(), union3([string2(), boolean()])).optional()
|
|
5166
5187
|
}).superRefine((value, ctx) => {
|
|
5167
5188
|
if (value.target === "custom" && !value.command) {
|
|
5168
5189
|
ctx.addIssue({
|
|
@@ -5407,7 +5428,7 @@ var updateAgentProfileRoute = route({
|
|
|
5407
5428
|
profileSyncRejection: ProfileSyncRejectionSchema.optional()
|
|
5408
5429
|
})
|
|
5409
5430
|
},
|
|
5410
|
-
404: { description: "Agent not found" }
|
|
5431
|
+
404: { description: "Agent not found, or changedByAgentId names no agent" }
|
|
5411
5432
|
}
|
|
5412
5433
|
});
|
|
5413
5434
|
var updateAgentActivityRoute = route({
|
|
@@ -5722,6 +5743,10 @@ async function handleAgentsRest(req, res, pathSegments, queryParams, myAgentId)
|
|
|
5722
5743
|
jsonError(res, "At least one field (role, description, capabilities, claudeMd, soulMd, identityMd, setupScript, toolsMd, heartbeatMd, avatar, or slackIcon) must be provided", 400);
|
|
5723
5744
|
return true;
|
|
5724
5745
|
}
|
|
5746
|
+
if (body.changedByAgentId && !await getAgentById2(body.changedByAgentId)) {
|
|
5747
|
+
jsonError(res, "changed_by_agent_not_found", 404);
|
|
5748
|
+
return true;
|
|
5749
|
+
}
|
|
5725
5750
|
const validChangeSources = ["self_edit", "lead_coaching", "api", "system", "session_sync"];
|
|
5726
5751
|
const versionMeta = body.changeSource || body.changedByAgentId || body.changeReason ? {
|
|
5727
5752
|
changeSource: validChangeSources.includes(body.changeSource ?? "") ? body.changeSource : undefined,
|
|
@@ -7793,6 +7818,44 @@ async function handleConfig(req, res, pathSegments, queryParams) {
|
|
|
7793
7818
|
return false;
|
|
7794
7819
|
}
|
|
7795
7820
|
|
|
7821
|
+
// src/http/person-responder.ts
|
|
7822
|
+
init_rbac_roles();
|
|
7823
|
+
init_rbac();
|
|
7824
|
+
init_request_auth_context();
|
|
7825
|
+
init_request_principal();
|
|
7826
|
+
var AGENT_RESPONSE_REFUSED = "Agents cannot answer approval requests. A person must respond with a user token or the dashboard.";
|
|
7827
|
+
async function approvalResponder(req, options) {
|
|
7828
|
+
const auth = getRequestAuth(req);
|
|
7829
|
+
const rawAgentId = req.headers["x-agent-id"];
|
|
7830
|
+
const headerAgentId = Array.isArray(rawAgentId) ? rawAgentId[0] : rawAgentId;
|
|
7831
|
+
const principal = await agentFirstPrincipal(req, headerAgentId);
|
|
7832
|
+
if (principal.kind !== "user" && principal.kind !== "agent" && auth?.page) {
|
|
7833
|
+
return {
|
|
7834
|
+
ok: false,
|
|
7835
|
+
message: options?.pageMessage ?? "A page session without a signed-in user cannot answer approval requests."
|
|
7836
|
+
};
|
|
7837
|
+
}
|
|
7838
|
+
const user = authUser(auth);
|
|
7839
|
+
const responder = principal.kind === "user" && user ? { kind: "user", user } : principal.kind === "operator" ? { kind: "operator" } : null;
|
|
7840
|
+
const verb = options?.verb ?? "approval.respond";
|
|
7841
|
+
const refused = {
|
|
7842
|
+
ok: false,
|
|
7843
|
+
message: options?.refusedMessage ?? AGENT_RESPONSE_REFUSED
|
|
7844
|
+
};
|
|
7845
|
+
const decision = can({ principal, verb, source: "http" });
|
|
7846
|
+
if (!decision.allow || !responder)
|
|
7847
|
+
return refused;
|
|
7848
|
+
if (responder.kind === "user" && isRbacEnabled()) {
|
|
7849
|
+
const grant = await getUserGrant2(responder.user.id);
|
|
7850
|
+
if (!grant.grantsAll && !grant.verbs.has(verb))
|
|
7851
|
+
return refused;
|
|
7852
|
+
}
|
|
7853
|
+
return { ok: true, responder };
|
|
7854
|
+
}
|
|
7855
|
+
function responderKey(responder) {
|
|
7856
|
+
return responder.kind === "user" ? responder.user.id : "operator";
|
|
7857
|
+
}
|
|
7858
|
+
|
|
7796
7859
|
// src/http/approval-requests.ts
|
|
7797
7860
|
init_request_principal();
|
|
7798
7861
|
init_route_def();
|
|
@@ -7815,11 +7878,14 @@ var QuestionSchema = object2({
|
|
|
7815
7878
|
defaultValue: boolean().optional(),
|
|
7816
7879
|
config: ConfigQuestionSettingsSchema.optional().describe("Config question settings. Answers are written to swarm_config and replaced by a result that never holds a secret value.")
|
|
7817
7880
|
});
|
|
7818
|
-
var QuestionInputSchema = QuestionSchema.extend({
|
|
7881
|
+
var QuestionInputSchema = QuestionSchema.extend({
|
|
7882
|
+
label: string2().optional(),
|
|
7883
|
+
required: boolean().default(true)
|
|
7884
|
+
});
|
|
7819
7885
|
var ApproversSchema = object2({
|
|
7820
7886
|
users: array2(string2()).optional(),
|
|
7821
7887
|
roles: array2(string2()).optional(),
|
|
7822
|
-
policy:
|
|
7888
|
+
policy: union3([literal2("any"), literal2("all"), object2({ min: number2().int().min(1) })])
|
|
7823
7889
|
});
|
|
7824
7890
|
var NotificationChannelSchema = object2({
|
|
7825
7891
|
channel: _enum2(["slack", "email"]),
|
|
@@ -7961,8 +8027,18 @@ function hasRequiredResponse(question, response) {
|
|
|
7961
8027
|
}
|
|
7962
8028
|
}
|
|
7963
8029
|
}
|
|
8030
|
+
function isUnanswered(response) {
|
|
8031
|
+
return response === undefined || response === null || typeof response === "string" && response.trim() === "" || Array.isArray(response) && response.length === 0;
|
|
8032
|
+
}
|
|
7964
8033
|
function missingRequiredResponseIds(questions, responses) {
|
|
7965
|
-
return questions.filter((question) =>
|
|
8034
|
+
return questions.filter((question) => {
|
|
8035
|
+
const response = responses[question.id];
|
|
8036
|
+
if (hasRequiredResponse(question, response))
|
|
8037
|
+
return false;
|
|
8038
|
+
if (question.required)
|
|
8039
|
+
return true;
|
|
8040
|
+
return question.type !== "config" && !isUnanswered(response);
|
|
8041
|
+
}).map((question) => question.id);
|
|
7966
8042
|
}
|
|
7967
8043
|
var createRoute = route({
|
|
7968
8044
|
method: "post",
|
|
@@ -7977,7 +8053,7 @@ var createRoute = route({
|
|
|
7977
8053
|
approvers: object2({
|
|
7978
8054
|
users: array2(string2()).optional(),
|
|
7979
8055
|
roles: array2(string2()).optional(),
|
|
7980
|
-
policy:
|
|
8056
|
+
policy: union3([
|
|
7981
8057
|
literal2("any"),
|
|
7982
8058
|
literal2("all"),
|
|
7983
8059
|
object2({ min: number2().int().min(1) })
|
|
@@ -8087,7 +8163,7 @@ var listRoute = route({
|
|
|
8087
8163
|
200: {
|
|
8088
8164
|
description: "List of approval requests",
|
|
8089
8165
|
schema: object2({
|
|
8090
|
-
approvalRequests:
|
|
8166
|
+
approvalRequests: union3([
|
|
8091
8167
|
array2(ApprovalRequestSchema),
|
|
8092
8168
|
array2(ApprovalRequestSummarySchema)
|
|
8093
8169
|
])
|
|
@@ -8142,7 +8218,7 @@ async function handleApprovalRequests(req, res, pathSegments, queryParams) {
|
|
|
8142
8218
|
const questions = existing.questions;
|
|
8143
8219
|
const missingRequired = missingRequiredResponseIds(questions, parsed.body.responses);
|
|
8144
8220
|
if (missingRequired.length > 0) {
|
|
8145
|
-
jsonError(res, `
|
|
8221
|
+
jsonError(res, `Responses missing or invalid: ${missingRequired.join(", ")}`, 400);
|
|
8146
8222
|
return true;
|
|
8147
8223
|
}
|
|
8148
8224
|
const configQuestions = questions.filter(isConfigQuestion);
|
|
@@ -8395,28 +8471,6 @@ async function approvalCallerPrincipal(req) {
|
|
|
8395
8471
|
const resolvedBy = principal.kind === "user" ? principal.userId : principal.kind === "agent" ? principal.agentId : principal.kind === "operator" ? "operator" : null;
|
|
8396
8472
|
return { principal, resolvedBy };
|
|
8397
8473
|
}
|
|
8398
|
-
var AGENT_RESPONSE_REFUSED = "Agents cannot answer approval requests. A person must respond with a user token or the dashboard.";
|
|
8399
|
-
async function approvalResponder(req) {
|
|
8400
|
-
const auth = getRequestAuth(req);
|
|
8401
|
-
const rawAgentId = req.headers["x-agent-id"];
|
|
8402
|
-
const headerAgentId = Array.isArray(rawAgentId) ? rawAgentId[0] : rawAgentId;
|
|
8403
|
-
const principal = await agentFirstPrincipal(req, headerAgentId);
|
|
8404
|
-
if (principal.kind !== "user" && principal.kind !== "agent" && auth?.page) {
|
|
8405
|
-
return {
|
|
8406
|
-
ok: false,
|
|
8407
|
-
message: "A page session without a signed-in user cannot answer approval requests."
|
|
8408
|
-
};
|
|
8409
|
-
}
|
|
8410
|
-
const user = authUser(auth);
|
|
8411
|
-
const responder = principal.kind === "user" && user ? { kind: "user", user } : principal.kind === "operator" ? { kind: "operator" } : null;
|
|
8412
|
-
const decision = can({ principal, verb: "approval.respond", source: "http" });
|
|
8413
|
-
if (!decision.allow || !responder)
|
|
8414
|
-
return { ok: false, message: AGENT_RESPONSE_REFUSED };
|
|
8415
|
-
return { ok: true, responder };
|
|
8416
|
-
}
|
|
8417
|
-
function responderKey(responder) {
|
|
8418
|
-
return responder.kind === "user" ? responder.user.id : "operator";
|
|
8419
|
-
}
|
|
8420
8474
|
function userMatchesListed(user, listed) {
|
|
8421
8475
|
if (listed === user.id)
|
|
8422
8476
|
return true;
|
|
@@ -8972,7 +9026,6 @@ async function handleBudgets(req, res, pathSegments, queryParams, _myAgentId) {
|
|
|
8972
9026
|
init_zod();
|
|
8973
9027
|
init_crypto();
|
|
8974
9028
|
init_db4();
|
|
8975
|
-
init_api_keys();
|
|
8976
9029
|
init_auth_json();
|
|
8977
9030
|
init_flow();
|
|
8978
9031
|
init_storage();
|
|
@@ -9042,10 +9095,6 @@ function readCredentials(row) {
|
|
|
9042
9095
|
return null;
|
|
9043
9096
|
}
|
|
9044
9097
|
}
|
|
9045
|
-
function accountSuffix(row) {
|
|
9046
|
-
const credentials = readCredentials(row);
|
|
9047
|
-
return credentials ? deriveCodexKeySuffix(credentials.access, credentials.accountId) : null;
|
|
9048
|
-
}
|
|
9049
9098
|
async function accountsResponse() {
|
|
9050
9099
|
const rows = await accountRows();
|
|
9051
9100
|
const statuses = await getKeyStatuses2("CODEX_OAUTH", "global", null);
|
|
@@ -9065,15 +9114,16 @@ async function accountsResponse() {
|
|
|
9065
9114
|
accounts.push(account);
|
|
9066
9115
|
continue;
|
|
9067
9116
|
}
|
|
9068
|
-
account.suffix = deriveCodexKeySuffix(credentials.access, credentials.accountId);
|
|
9117
|
+
account.suffix = deriveCodexKeySuffix(credentials.access, credentials.accountId, row.slot);
|
|
9069
9118
|
account.plan = extractChatgptPlanType(credentials.access);
|
|
9070
9119
|
const profile = decodeJwt(credentials.access)?.["https://api.openai.com/profile"];
|
|
9071
9120
|
if (profile && typeof profile === "object" && "email" in profile) {
|
|
9072
9121
|
account.email = typeof profile.email === "string" && profile.email ? profile.email : null;
|
|
9073
9122
|
}
|
|
9074
|
-
const
|
|
9123
|
+
const slotStatuses = statuses.filter((entry) => entry.keySuffix === account.suffix || entry.keyIndex === row.slot);
|
|
9124
|
+
const status = slotStatuses.find((entry) => entry.keySuffix === account.suffix);
|
|
9075
9125
|
const marker = await getKv2(CODEX_AUTH_WATCH_NAMESPACE, codexAuthBenchMarkerKey(account.suffix));
|
|
9076
|
-
const statusBenched =
|
|
9126
|
+
const statusBenched = slotStatuses.some((entry) => entry.consecutiveAuthFailures >= CODEX_AUTH_FAILURE_BENCH_THRESHOLD && entry.status === "rate_limited");
|
|
9077
9127
|
account.status = marker || statusBenched ? "needs_login" : status ? "ok" : "unchecked";
|
|
9078
9128
|
accounts.push(account);
|
|
9079
9129
|
}
|
|
@@ -9108,16 +9158,17 @@ async function handleCodexOAuthAccounts(req, res, pathSegments, queryParams) {
|
|
|
9108
9158
|
const account = rows.find((row) => row.slot === parsed.params.slot);
|
|
9109
9159
|
if (!account || !await deleteSwarmConfigByKey2("global", null, account.key))
|
|
9110
9160
|
return null;
|
|
9111
|
-
const
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
9117
|
-
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
|
|
9161
|
+
const credentials = readCredentials(account);
|
|
9162
|
+
const suffix = credentials ? deriveCodexKeySuffix(credentials.access, credentials.accountId, account.slot) : null;
|
|
9163
|
+
const retired = await getDbClient2().query(`DELETE FROM api_key_status
|
|
9164
|
+
WHERE keyType = 'CODEX_OAUTH' AND scope = 'global' AND scopeId = ''
|
|
9165
|
+
AND (keyIndex = ? OR keySuffix = ?)
|
|
9166
|
+
RETURNING keySuffix`, [account.slot, suffix]);
|
|
9167
|
+
for (const keySuffix of new Set([
|
|
9168
|
+
...suffix ? [suffix] : [],
|
|
9169
|
+
...retired.map((r) => r.keySuffix)
|
|
9170
|
+
])) {
|
|
9171
|
+
await deleteKv2(CODEX_AUTH_WATCH_NAMESPACE, codexAuthBenchMarkerKey(keySuffix));
|
|
9121
9172
|
}
|
|
9122
9173
|
return account.key;
|
|
9123
9174
|
});
|
|
@@ -9229,7 +9280,7 @@ var OnboardingIntegrationMethodSchema = _enum2([
|
|
|
9229
9280
|
]);
|
|
9230
9281
|
var OnboardingFilesMethodSchema = _enum2(["created", "connected"]);
|
|
9231
9282
|
var OnboardingFirstTaskMethodSchema = _enum2(["suggestion", "free_form"]);
|
|
9232
|
-
var OnboardingStepMethodSchema =
|
|
9283
|
+
var OnboardingStepMethodSchema = union3([
|
|
9233
9284
|
OnboardingConnectMethodSchema,
|
|
9234
9285
|
OnboardingNameMethodSchema,
|
|
9235
9286
|
OnboardingAiMethodSchema,
|
|
@@ -9316,7 +9367,7 @@ var OnboardingResponseSchema = object2({
|
|
|
9316
9367
|
state: OnboardingStateSchema,
|
|
9317
9368
|
signals: OnboardingSignalsSchema
|
|
9318
9369
|
});
|
|
9319
|
-
var OnboardingActionSchema =
|
|
9370
|
+
var OnboardingActionSchema = union3([
|
|
9320
9371
|
object2({ action: literal2("view"), step: OnboardingStepIdSchema }).strict(),
|
|
9321
9372
|
object2({
|
|
9322
9373
|
action: literal2("complete"),
|
|
@@ -9779,11 +9830,27 @@ init_auth_json();
|
|
|
9779
9830
|
|
|
9780
9831
|
// src/providers/codex-oauth/device.ts
|
|
9781
9832
|
init_flow();
|
|
9782
|
-
var
|
|
9783
|
-
var DEVICE_TOKEN_URL = "https://auth.openai.com/api/accounts/deviceauth/token";
|
|
9784
|
-
var DEVICE_REDIRECT_URI = "https://auth.openai.com/deviceauth/callback";
|
|
9833
|
+
var DEFAULT_DEVICE_BASE_URL = "https://auth.openai.com";
|
|
9785
9834
|
var UPSTREAM_TIMEOUT_MS = 15000;
|
|
9786
|
-
|
|
9835
|
+
function resolveCodexDeviceBaseUrl(raw) {
|
|
9836
|
+
const configured = raw?.trim();
|
|
9837
|
+
if (!configured)
|
|
9838
|
+
return DEFAULT_DEVICE_BASE_URL;
|
|
9839
|
+
try {
|
|
9840
|
+
const url = new URL(configured);
|
|
9841
|
+
const loopback = url.hostname === "127.0.0.1" || url.hostname === "localhost" || url.hostname === "[::1]";
|
|
9842
|
+
if (url.protocol === "http:" && loopback)
|
|
9843
|
+
return url.origin;
|
|
9844
|
+
} catch {}
|
|
9845
|
+
console.warn("[codex-oauth] CODEX_OAUTH_DEVICE_BASE_URL must be a loopback http origin; ignored");
|
|
9846
|
+
return DEFAULT_DEVICE_BASE_URL;
|
|
9847
|
+
}
|
|
9848
|
+
function deviceBaseUrl() {
|
|
9849
|
+
return resolveCodexDeviceBaseUrl(process.env.CODEX_OAUTH_DEVICE_BASE_URL);
|
|
9850
|
+
}
|
|
9851
|
+
function codexDeviceVerificationUrl() {
|
|
9852
|
+
return `${deviceBaseUrl()}/codex/device`;
|
|
9853
|
+
}
|
|
9787
9854
|
|
|
9788
9855
|
class DeviceCodeNotEnabledError extends Error {
|
|
9789
9856
|
}
|
|
@@ -9798,7 +9865,7 @@ function parseInterval(value) {
|
|
|
9798
9865
|
return 5;
|
|
9799
9866
|
}
|
|
9800
9867
|
async function requestDeviceCode() {
|
|
9801
|
-
const response = await _fetchHolder.current(
|
|
9868
|
+
const response = await _fetchHolder.current(`${deviceBaseUrl()}/api/accounts/deviceauth/usercode`, {
|
|
9802
9869
|
method: "POST",
|
|
9803
9870
|
headers: {
|
|
9804
9871
|
"Content-Type": "application/json",
|
|
@@ -9825,7 +9892,7 @@ async function requestDeviceCode() {
|
|
|
9825
9892
|
};
|
|
9826
9893
|
}
|
|
9827
9894
|
async function pollDeviceToken(deviceAuthId, userCode) {
|
|
9828
|
-
const response = await _fetchHolder.current(
|
|
9895
|
+
const response = await _fetchHolder.current(`${deviceBaseUrl()}/api/accounts/deviceauth/token`, {
|
|
9829
9896
|
method: "POST",
|
|
9830
9897
|
headers: {
|
|
9831
9898
|
"Content-Type": "application/json",
|
|
@@ -9850,7 +9917,7 @@ async function pollDeviceToken(deviceAuthId, userCode) {
|
|
|
9850
9917
|
};
|
|
9851
9918
|
}
|
|
9852
9919
|
async function exchangeDeviceAuthorizationCode(authorizationCode, codeVerifier) {
|
|
9853
|
-
const token = await exchangeAuthorizationCode2(authorizationCode, codeVerifier,
|
|
9920
|
+
const token = await exchangeAuthorizationCode2(authorizationCode, codeVerifier, `${deviceBaseUrl()}/deviceauth/callback`, AbortSignal.timeout(UPSTREAM_TIMEOUT_MS), `${deviceBaseUrl()}/oauth/token`);
|
|
9854
9921
|
if (token.type !== "success")
|
|
9855
9922
|
return null;
|
|
9856
9923
|
const accountId = getAccountId(token.access);
|
|
@@ -10027,7 +10094,7 @@ async function completeFlow(flowId, credentials) {
|
|
|
10027
10094
|
isSecret: true,
|
|
10028
10095
|
description: `Codex ChatGPT OAuth credentials slot ${slot} (stored by dashboard device login)`
|
|
10029
10096
|
});
|
|
10030
|
-
const keySuffix = deriveCodexKeySuffix(credentials.access, credentials.accountId);
|
|
10097
|
+
const keySuffix = deriveCodexKeySuffix(credentials.access, credentials.accountId, slot);
|
|
10031
10098
|
const checked = [{ keyIndex: slot, keySuffix, ok: true }];
|
|
10032
10099
|
await recordKeyValidation2("CODEX_OAUTH", checked, "global", null, { retireAbsent: false });
|
|
10033
10100
|
await updateOnboardingAiFromCodexDevice({ status: "complete" });
|
|
@@ -10101,7 +10168,7 @@ async function handleCodexOAuthDevice(req, res, pathSegments, queryParams) {
|
|
|
10101
10168
|
startDeviceFlow.respond(res, 200, {
|
|
10102
10169
|
flowId,
|
|
10103
10170
|
userCode: device.userCode,
|
|
10104
|
-
verificationUrl:
|
|
10171
|
+
verificationUrl: codexDeviceVerificationUrl(),
|
|
10105
10172
|
intervalSeconds: device.intervalSeconds,
|
|
10106
10173
|
expiresAt: new Date(expiresAt).toISOString()
|
|
10107
10174
|
});
|
|
@@ -10207,7 +10274,7 @@ async function handleCodexOAuthKeepWarm(req, res, pathSegments) {
|
|
|
10207
10274
|
const slots = await loadAllCodexOAuthSlots(apiUrl, apiKey);
|
|
10208
10275
|
const results = [];
|
|
10209
10276
|
for (const { slot, creds } of slots) {
|
|
10210
|
-
const keySuffix = deriveCodexKeySuffix(creds.access, creds.accountId);
|
|
10277
|
+
const keySuffix = deriveCodexKeySuffix(creds.access, creds.accountId, slot);
|
|
10211
10278
|
if (await getKv2(CODEX_AUTH_WATCH_NAMESPACE, codexAuthBenchMarkerKey(keySuffix))) {
|
|
10212
10279
|
results.push({ slot, keySuffix, outcome: "skipped-benched" });
|
|
10213
10280
|
continue;
|
|
@@ -11088,6 +11155,7 @@ declare module "swarm-extension" {
|
|
|
11088
11155
|
agentId?: string | null | undefined;
|
|
11089
11156
|
creatorAgentId?: string | undefined;
|
|
11090
11157
|
source?:
|
|
11158
|
+
| "chat"
|
|
11091
11159
|
| "workflow"
|
|
11092
11160
|
| "schedule"
|
|
11093
11161
|
| "slack"
|
|
@@ -11103,7 +11171,6 @@ declare module "swarm-extension" {
|
|
|
11103
11171
|
| "ui"
|
|
11104
11172
|
| "system"
|
|
11105
11173
|
| "comb"
|
|
11106
|
-
| "chat"
|
|
11107
11174
|
| undefined;
|
|
11108
11175
|
routingReason?:
|
|
11109
11176
|
| "skill"
|
|
@@ -11143,12 +11210,13 @@ declare module "swarm-extension" {
|
|
|
11143
11210
|
parentTaskId?: string | undefined;
|
|
11144
11211
|
model?: string | undefined;
|
|
11145
11212
|
modelTier?: "smol" | "regular" | "smart" | "ultra" | undefined;
|
|
11146
|
-
effort?: "
|
|
11213
|
+
effort?: "low" | "medium" | "high" | "max" | "off" | "xhigh" | undefined;
|
|
11147
11214
|
profile?: string | undefined;
|
|
11148
11215
|
scheduleId?: string | undefined;
|
|
11149
11216
|
workflowRunId?: string | undefined;
|
|
11150
11217
|
workflowRunStepId?: string | undefined;
|
|
11151
11218
|
sourceTaskId?: string | undefined;
|
|
11219
|
+
dispatchedByTaskId?: string | undefined;
|
|
11152
11220
|
outputSchema?: Record<string, unknown> | undefined;
|
|
11153
11221
|
inheritParentOutputSchema?: boolean | undefined;
|
|
11154
11222
|
inheritParentRequester?: boolean | undefined;
|
|
@@ -11170,18 +11238,18 @@ declare module "swarm-extension" {
|
|
|
11170
11238
|
sourceAgentId?: string | undefined;
|
|
11171
11239
|
role?: string | undefined;
|
|
11172
11240
|
harnessProvider?:
|
|
11173
|
-
| "claude"
|
|
11174
|
-
| "codex"
|
|
11175
11241
|
| "pi"
|
|
11176
|
-
| "
|
|
11242
|
+
| "claude"
|
|
11177
11243
|
| "claude-managed"
|
|
11244
|
+
| "codex"
|
|
11245
|
+
| "grok"
|
|
11246
|
+
| "fx"
|
|
11178
11247
|
| "opencode"
|
|
11179
|
-
| "acp"
|
|
11180
11248
|
| "dsh"
|
|
11181
|
-
| "amp"
|
|
11182
11249
|
| "cursor"
|
|
11183
|
-
| "
|
|
11184
|
-
| "
|
|
11250
|
+
| "amp"
|
|
11251
|
+
| "devin"
|
|
11252
|
+
| "acp"
|
|
11185
11253
|
| undefined;
|
|
11186
11254
|
leadOnly?: boolean | undefined;
|
|
11187
11255
|
}
|
|
@@ -11194,6 +11262,7 @@ declare module "swarm-extension" {
|
|
|
11194
11262
|
agentId: string | null;
|
|
11195
11263
|
task: string;
|
|
11196
11264
|
status:
|
|
11265
|
+
| "skipped"
|
|
11197
11266
|
| "draft"
|
|
11198
11267
|
| "backlog"
|
|
11199
11268
|
| "unassigned"
|
|
@@ -11207,6 +11276,7 @@ declare module "swarm-extension" {
|
|
|
11207
11276
|
| "cancelled"
|
|
11208
11277
|
| "superseded";
|
|
11209
11278
|
source:
|
|
11279
|
+
| "chat"
|
|
11210
11280
|
| "workflow"
|
|
11211
11281
|
| "schedule"
|
|
11212
11282
|
| "slack"
|
|
@@ -11221,8 +11291,7 @@ declare module "swarm-extension" {
|
|
|
11221
11291
|
| "api"
|
|
11222
11292
|
| "ui"
|
|
11223
11293
|
| "system"
|
|
11224
|
-
| "comb"
|
|
11225
|
-
| "chat";
|
|
11294
|
+
| "comb";
|
|
11226
11295
|
tags: string[];
|
|
11227
11296
|
priority: number;
|
|
11228
11297
|
dependsOn: string[];
|
|
@@ -11274,14 +11343,15 @@ declare module "swarm-extension" {
|
|
|
11274
11343
|
mentionChannelId?: string | undefined;
|
|
11275
11344
|
dir?: string | undefined;
|
|
11276
11345
|
parentTaskId?: string | undefined;
|
|
11346
|
+
dispatchedByTaskId?: string | undefined;
|
|
11277
11347
|
claudeSessionId?: string | undefined;
|
|
11278
11348
|
model?: string | undefined;
|
|
11279
11349
|
modelTier?: "smol" | "regular" | "smart" | "ultra" | undefined;
|
|
11280
|
-
effort?: "
|
|
11350
|
+
effort?: "low" | "medium" | "high" | "max" | "off" | "xhigh" | undefined;
|
|
11281
11351
|
resolvedModel?: string | undefined;
|
|
11282
11352
|
modelSource?: string | undefined;
|
|
11283
11353
|
modelAlias?: string | undefined;
|
|
11284
|
-
resolvedEffort?: "
|
|
11354
|
+
resolvedEffort?: "low" | "medium" | "high" | "max" | "off" | "xhigh" | undefined;
|
|
11285
11355
|
profile?: string | undefined;
|
|
11286
11356
|
resolvedProfile?: string | undefined;
|
|
11287
11357
|
scheduleId?: string | undefined;
|
|
@@ -11306,18 +11376,18 @@ declare module "swarm-extension" {
|
|
|
11306
11376
|
requestedByUserId?: string | undefined;
|
|
11307
11377
|
swarmVersion?: string | undefined;
|
|
11308
11378
|
provider?:
|
|
11309
|
-
| "claude"
|
|
11310
|
-
| "codex"
|
|
11311
11379
|
| "pi"
|
|
11312
|
-
| "
|
|
11380
|
+
| "claude"
|
|
11313
11381
|
| "claude-managed"
|
|
11382
|
+
| "codex"
|
|
11383
|
+
| "grok"
|
|
11384
|
+
| "fx"
|
|
11314
11385
|
| "opencode"
|
|
11315
|
-
| "acp"
|
|
11316
11386
|
| "dsh"
|
|
11317
|
-
| "amp"
|
|
11318
11387
|
| "cursor"
|
|
11319
|
-
| "
|
|
11320
|
-
| "
|
|
11388
|
+
| "amp"
|
|
11389
|
+
| "devin"
|
|
11390
|
+
| "acp"
|
|
11321
11391
|
| undefined;
|
|
11322
11392
|
providerMeta?: Record<string, unknown> | undefined;
|
|
11323
11393
|
harnessVariant?: string | undefined;
|
|
@@ -11329,18 +11399,18 @@ declare module "swarm-extension" {
|
|
|
11329
11399
|
sourceAgentId?: string | undefined;
|
|
11330
11400
|
role?: string | undefined;
|
|
11331
11401
|
harnessProvider?:
|
|
11332
|
-
| "claude"
|
|
11333
|
-
| "codex"
|
|
11334
11402
|
| "pi"
|
|
11335
|
-
| "
|
|
11403
|
+
| "claude"
|
|
11336
11404
|
| "claude-managed"
|
|
11405
|
+
| "codex"
|
|
11406
|
+
| "grok"
|
|
11407
|
+
| "fx"
|
|
11337
11408
|
| "opencode"
|
|
11338
|
-
| "acp"
|
|
11339
11409
|
| "dsh"
|
|
11340
|
-
| "amp"
|
|
11341
11410
|
| "cursor"
|
|
11342
|
-
| "
|
|
11343
|
-
| "
|
|
11411
|
+
| "amp"
|
|
11412
|
+
| "devin"
|
|
11413
|
+
| "acp"
|
|
11344
11414
|
| undefined;
|
|
11345
11415
|
leadOnly?: boolean | undefined;
|
|
11346
11416
|
}
|
|
@@ -11364,7 +11434,7 @@ declare module "swarm-extension" {
|
|
|
11364
11434
|
|
|
11365
11435
|
export type SteerMode = "steer" | "queue";
|
|
11366
11436
|
|
|
11367
|
-
export type SteeringSource = "script" | "slack" | "mcp" | "api" | "ui"
|
|
11437
|
+
export type SteeringSource = "chat" | "script" | "slack" | "mcp" | "api" | "ui";
|
|
11368
11438
|
|
|
11369
11439
|
export type RequestInfo = {
|
|
11370
11440
|
sessionId: string | undefined;
|
|
@@ -15628,6 +15698,268 @@ async function handleHeartbeat(req, res, pathSegments) {
|
|
|
15628
15698
|
return false;
|
|
15629
15699
|
}
|
|
15630
15700
|
|
|
15701
|
+
// src/http/improvements.ts
|
|
15702
|
+
init_zod();
|
|
15703
|
+
init_improvements();
|
|
15704
|
+
init_rbac();
|
|
15705
|
+
init_request_principal();
|
|
15706
|
+
init_route_def();
|
|
15707
|
+
init_utils2();
|
|
15708
|
+
var ImprovementSchema = object2({
|
|
15709
|
+
id: string2(),
|
|
15710
|
+
text: string2(),
|
|
15711
|
+
email: string2().nullable(),
|
|
15712
|
+
status: _enum2(IMPROVEMENT_STATUSES),
|
|
15713
|
+
source: _enum2(IMPROVEMENT_SOURCES),
|
|
15714
|
+
requestedByAgentId: string2().nullable(),
|
|
15715
|
+
approvedBy: string2().nullable(),
|
|
15716
|
+
approvedAt: string2().nullable(),
|
|
15717
|
+
sentAt: string2().nullable(),
|
|
15718
|
+
proxyStatus: number2().nullable(),
|
|
15719
|
+
proxyId: string2().nullable(),
|
|
15720
|
+
proxyError: string2().nullable(),
|
|
15721
|
+
createdAt: string2(),
|
|
15722
|
+
updatedAt: string2(),
|
|
15723
|
+
leakHints: array2(string2()).optional().describe("Substrings that look install-specific (agent, repo, host, org or user email). Pending and failed rows only. They warn; they never block.")
|
|
15724
|
+
});
|
|
15725
|
+
var EmailSchema = string2().max(320, "Email must be at most 320 characters").email("Email must be a valid email address");
|
|
15726
|
+
var PERSON_REFUSED = "Agents cannot approve improvements. A person must approve with a user token or the dashboard.";
|
|
15727
|
+
var listRoute3 = route({
|
|
15728
|
+
method: "get",
|
|
15729
|
+
path: "/api/improvements",
|
|
15730
|
+
pattern: ["api", "improvements"],
|
|
15731
|
+
summary: "List product improvements",
|
|
15732
|
+
description: "Lists improvements newest first, with `enabled` for the `IMPROVEMENTS_ENABLED` switch: every pending and failed row, plus the newest 100 other rows. Pending and failed rows carry `leakHints` for the approver.",
|
|
15733
|
+
tags: ["Improvements"],
|
|
15734
|
+
responses: {
|
|
15735
|
+
200: {
|
|
15736
|
+
description: "Improvements and the switch state",
|
|
15737
|
+
schema: object2({ enabled: boolean(), improvements: array2(ImprovementSchema) })
|
|
15738
|
+
}
|
|
15739
|
+
},
|
|
15740
|
+
auth: { apiKey: true }
|
|
15741
|
+
});
|
|
15742
|
+
var createRoute2 = route({
|
|
15743
|
+
method: "post",
|
|
15744
|
+
path: "/api/improvements",
|
|
15745
|
+
pattern: ["api", "improvements"],
|
|
15746
|
+
summary: "Draft a product improvement, or send one as a person",
|
|
15747
|
+
description: "Stores the text, scrubbed of known secrets, as `pending_approval`. An agent caller always gets a pending draft. A person (user token, or the shared key with no agent identity) may pass `sendNow: true` to approve and send in one call, unless scrubbing changed the text: then it stays pending so they can review it. `sendNow` needs a valid `email` (400 without one); a draft does not. Only `install_id` (always), `text` and `email` are sent to desplega.",
|
|
15748
|
+
tags: ["Improvements"],
|
|
15749
|
+
body: object2({
|
|
15750
|
+
text: string2().max(IMPROVEMENT_TEXT_MAX * 2),
|
|
15751
|
+
email: EmailSchema.optional(),
|
|
15752
|
+
sendNow: boolean().optional(),
|
|
15753
|
+
source: _enum2(["ui", "api"]).optional()
|
|
15754
|
+
}),
|
|
15755
|
+
responses: {
|
|
15756
|
+
200: {
|
|
15757
|
+
description: "A person's `sendNow` was approved and sent (see `status`)",
|
|
15758
|
+
schema: object2({ improvement: ImprovementSchema })
|
|
15759
|
+
},
|
|
15760
|
+
201: {
|
|
15761
|
+
description: "Draft stored as `pending_approval`",
|
|
15762
|
+
schema: object2({ improvement: ImprovementSchema })
|
|
15763
|
+
},
|
|
15764
|
+
400: { description: "Invalid text or email, or `sendNow` without an email" },
|
|
15765
|
+
403: { description: "The caller may not draft improvements" },
|
|
15766
|
+
409: { description: "Improvements are turned off" }
|
|
15767
|
+
},
|
|
15768
|
+
auth: { apiKey: true },
|
|
15769
|
+
rbac: { permission: "improvement.submit" }
|
|
15770
|
+
});
|
|
15771
|
+
var approveRoute = route({
|
|
15772
|
+
method: "post",
|
|
15773
|
+
path: "/api/improvements/{id}/approve",
|
|
15774
|
+
pattern: ["api", "improvements", null, "approve"],
|
|
15775
|
+
summary: "Approve and send a drafted improvement",
|
|
15776
|
+
description: "Only a person may approve: a user token, or the shared key with no agent identity (recorded as `operator`). `approvedBy` is taken from the credential, never the body. `email` is required and is sent with the text and the install id. The stored text is sent as is; to change it, discard and draft again. A failed send can be approved again. There is no automatic retry.",
|
|
15777
|
+
tags: ["Improvements"],
|
|
15778
|
+
params: object2({ id: string2().uuid() }),
|
|
15779
|
+
body: object2({ email: EmailSchema.describe("The approver's email, sent with the text.") }),
|
|
15780
|
+
responses: {
|
|
15781
|
+
200: {
|
|
15782
|
+
description: "Approved. `status` is `sent`, or `failed` with the proxy status and error.",
|
|
15783
|
+
schema: object2({ improvement: ImprovementSchema })
|
|
15784
|
+
},
|
|
15785
|
+
400: { description: "Missing or invalid email" },
|
|
15786
|
+
403: { description: "Caller is an agent" },
|
|
15787
|
+
404: { description: "Not found" },
|
|
15788
|
+
409: { description: "Already sent, sending or discarded, or improvements are turned off" }
|
|
15789
|
+
},
|
|
15790
|
+
auth: { apiKey: true },
|
|
15791
|
+
rbac: { permission: "improvement.approve" }
|
|
15792
|
+
});
|
|
15793
|
+
var discardRoute = route({
|
|
15794
|
+
method: "post",
|
|
15795
|
+
path: "/api/improvements/{id}/discard",
|
|
15796
|
+
pattern: ["api", "improvements", null, "discard"],
|
|
15797
|
+
summary: "Discard a drafted improvement",
|
|
15798
|
+
description: "A person may discard any pending or failed improvement. An agent may discard only a draft it requested.",
|
|
15799
|
+
tags: ["Improvements"],
|
|
15800
|
+
params: object2({ id: string2().uuid() }),
|
|
15801
|
+
responses: {
|
|
15802
|
+
200: {
|
|
15803
|
+
description: "Discarded",
|
|
15804
|
+
schema: object2({ improvement: ImprovementSchema })
|
|
15805
|
+
},
|
|
15806
|
+
403: { description: "Caller is an agent that did not request this draft" },
|
|
15807
|
+
404: { description: "Not found" },
|
|
15808
|
+
409: { description: "Already sent or discarded, or improvements are turned off" }
|
|
15809
|
+
},
|
|
15810
|
+
auth: { apiKey: true },
|
|
15811
|
+
rbac: { permission: "improvement.submit" }
|
|
15812
|
+
});
|
|
15813
|
+
function headerAgentId(req) {
|
|
15814
|
+
const raw = req.headers["x-agent-id"];
|
|
15815
|
+
return Array.isArray(raw) ? raw[0] : raw;
|
|
15816
|
+
}
|
|
15817
|
+
function writeImprovementError(res, error) {
|
|
15818
|
+
if (!(error instanceof ImprovementError))
|
|
15819
|
+
return false;
|
|
15820
|
+
const status = error.code === "invalid_text" || error.code === "invalid_email" ? 400 : error.code === "not_found" ? 404 : 409;
|
|
15821
|
+
if (error.code === "improvements_disabled") {
|
|
15822
|
+
res.writeHead(409, { "Content-Type": "application/json" });
|
|
15823
|
+
res.end(JSON.stringify({ error: error.message, code: error.code }));
|
|
15824
|
+
return true;
|
|
15825
|
+
}
|
|
15826
|
+
jsonError(res, error.message, status);
|
|
15827
|
+
return true;
|
|
15828
|
+
}
|
|
15829
|
+
async function withLeakHints(improvement) {
|
|
15830
|
+
if (improvement.status !== "pending_approval" && improvement.status !== "failed") {
|
|
15831
|
+
return improvement;
|
|
15832
|
+
}
|
|
15833
|
+
return { ...improvement, leakHints: await improvementLeakHints(improvement.text) };
|
|
15834
|
+
}
|
|
15835
|
+
async function improvementsEndpoint() {
|
|
15836
|
+
return telemetryProxyEndpoint("/v1/improvements");
|
|
15837
|
+
}
|
|
15838
|
+
async function handleImprovements(req, res, pathSegments, queryParams) {
|
|
15839
|
+
if (listRoute3.match(req.method, pathSegments)) {
|
|
15840
|
+
const parsed = await listRoute3.parse(req, res, pathSegments, queryParams);
|
|
15841
|
+
if (!parsed)
|
|
15842
|
+
return true;
|
|
15843
|
+
const rows = await listImprovements();
|
|
15844
|
+
listRoute3.respond(res, 200, {
|
|
15845
|
+
enabled: await isImprovementsEnabled(),
|
|
15846
|
+
improvements: await Promise.all(rows.map(withLeakHints))
|
|
15847
|
+
});
|
|
15848
|
+
return true;
|
|
15849
|
+
}
|
|
15850
|
+
if (createRoute2.match(req.method, pathSegments)) {
|
|
15851
|
+
const parsed = await createRoute2.parse(req, res, pathSegments, queryParams);
|
|
15852
|
+
if (!parsed)
|
|
15853
|
+
return true;
|
|
15854
|
+
const { text, email, sendNow, source } = parsed.body;
|
|
15855
|
+
if (sendNow && !email) {
|
|
15856
|
+
jsonError(res, "sendNow needs a valid email.", 400);
|
|
15857
|
+
return true;
|
|
15858
|
+
}
|
|
15859
|
+
const principal = await agentFirstPrincipal(req, headerAgentId(req));
|
|
15860
|
+
const decision = can({ principal, verb: "improvement.submit", source: "http" });
|
|
15861
|
+
if (!decision.allow) {
|
|
15862
|
+
jsonError(res, decision.reason, 403);
|
|
15863
|
+
return true;
|
|
15864
|
+
}
|
|
15865
|
+
const agentId = principal.kind === "agent" ? principal.agentId || null : null;
|
|
15866
|
+
const userId = principal.kind === "user" ? principal.userId : null;
|
|
15867
|
+
try {
|
|
15868
|
+
const { improvement, scrubChanged } = await createImprovement({
|
|
15869
|
+
text,
|
|
15870
|
+
source: source ?? "api",
|
|
15871
|
+
requestedByAgentId: agentId,
|
|
15872
|
+
createdBy: userId
|
|
15873
|
+
});
|
|
15874
|
+
if (sendNow && email && !scrubChanged) {
|
|
15875
|
+
const person = await approvalResponder(req, {
|
|
15876
|
+
verb: "improvement.approve",
|
|
15877
|
+
refusedMessage: PERSON_REFUSED
|
|
15878
|
+
});
|
|
15879
|
+
if (person.ok) {
|
|
15880
|
+
const sent = await approveAndSend(improvement.id, {
|
|
15881
|
+
approvedBy: responderKey(person.responder),
|
|
15882
|
+
email,
|
|
15883
|
+
endpoint: await improvementsEndpoint(),
|
|
15884
|
+
updatedBy: person.responder.kind === "user" ? person.responder.user.id : null
|
|
15885
|
+
});
|
|
15886
|
+
createRoute2.respond(res, 200, { improvement: sent });
|
|
15887
|
+
return true;
|
|
15888
|
+
}
|
|
15889
|
+
}
|
|
15890
|
+
createRoute2.respond(res, 201, { improvement: await withLeakHints(improvement) });
|
|
15891
|
+
} catch (error) {
|
|
15892
|
+
if (!writeImprovementError(res, error))
|
|
15893
|
+
throw error;
|
|
15894
|
+
}
|
|
15895
|
+
return true;
|
|
15896
|
+
}
|
|
15897
|
+
if (approveRoute.match(req.method, pathSegments)) {
|
|
15898
|
+
const parsed = await approveRoute.parse(req, res, pathSegments, queryParams);
|
|
15899
|
+
if (!parsed)
|
|
15900
|
+
return true;
|
|
15901
|
+
const person = await approvalResponder(req, {
|
|
15902
|
+
verb: "improvement.approve",
|
|
15903
|
+
refusedMessage: PERSON_REFUSED,
|
|
15904
|
+
pageMessage: "A page session without a signed-in user cannot approve improvements."
|
|
15905
|
+
});
|
|
15906
|
+
if (!person.ok) {
|
|
15907
|
+
jsonError(res, person.message, 403);
|
|
15908
|
+
return true;
|
|
15909
|
+
}
|
|
15910
|
+
try {
|
|
15911
|
+
const improvement = await approveAndSend(parsed.params.id, {
|
|
15912
|
+
approvedBy: responderKey(person.responder),
|
|
15913
|
+
email: parsed.body.email,
|
|
15914
|
+
endpoint: await improvementsEndpoint(),
|
|
15915
|
+
updatedBy: person.responder.kind === "user" ? person.responder.user.id : null
|
|
15916
|
+
});
|
|
15917
|
+
approveRoute.respond(res, 200, { improvement });
|
|
15918
|
+
} catch (error) {
|
|
15919
|
+
if (!writeImprovementError(res, error))
|
|
15920
|
+
throw error;
|
|
15921
|
+
}
|
|
15922
|
+
return true;
|
|
15923
|
+
}
|
|
15924
|
+
if (discardRoute.match(req.method, pathSegments)) {
|
|
15925
|
+
const parsed = await discardRoute.parse(req, res, pathSegments, queryParams);
|
|
15926
|
+
if (!parsed)
|
|
15927
|
+
return true;
|
|
15928
|
+
const existing = await getImprovement(parsed.params.id);
|
|
15929
|
+
if (!existing) {
|
|
15930
|
+
jsonError(res, "Improvement not found", 404);
|
|
15931
|
+
return true;
|
|
15932
|
+
}
|
|
15933
|
+
const principal = await agentFirstPrincipal(req, headerAgentId(req));
|
|
15934
|
+
let updatedBy = null;
|
|
15935
|
+
if (principal.kind === "agent") {
|
|
15936
|
+
if (!principal.agentId || principal.agentId !== existing.requestedByAgentId) {
|
|
15937
|
+
jsonError(res, "An agent may discard only an improvement it drafted.", 403);
|
|
15938
|
+
return true;
|
|
15939
|
+
}
|
|
15940
|
+
} else {
|
|
15941
|
+
const person = await approvalResponder(req, {
|
|
15942
|
+
verb: "improvement.approve",
|
|
15943
|
+
refusedMessage: "Only a person or the drafting agent may discard this improvement."
|
|
15944
|
+
});
|
|
15945
|
+
if (!person.ok) {
|
|
15946
|
+
jsonError(res, person.message, 403);
|
|
15947
|
+
return true;
|
|
15948
|
+
}
|
|
15949
|
+
updatedBy = person.responder.kind === "user" ? person.responder.user.id : null;
|
|
15950
|
+
}
|
|
15951
|
+
try {
|
|
15952
|
+
const improvement = await discardImprovement(parsed.params.id, { updatedBy });
|
|
15953
|
+
discardRoute.respond(res, 200, { improvement });
|
|
15954
|
+
} catch (error) {
|
|
15955
|
+
if (!writeImprovementError(res, error))
|
|
15956
|
+
throw error;
|
|
15957
|
+
}
|
|
15958
|
+
return true;
|
|
15959
|
+
}
|
|
15960
|
+
return false;
|
|
15961
|
+
}
|
|
15962
|
+
|
|
15631
15963
|
// src/http/inbox-state.ts
|
|
15632
15964
|
init_zod();
|
|
15633
15965
|
init_db4();
|
|
@@ -16186,7 +16518,7 @@ async function resolveAppUrl() {
|
|
|
16186
16518
|
// src/http/integrations.ts
|
|
16187
16519
|
init_route_def();
|
|
16188
16520
|
init_utils2();
|
|
16189
|
-
var ClaudeManagedTestResultSchema =
|
|
16521
|
+
var ClaudeManagedTestResultSchema = union3([
|
|
16190
16522
|
object2({
|
|
16191
16523
|
ok: literal2(true),
|
|
16192
16524
|
agentName: string2().nullable(),
|
|
@@ -18609,7 +18941,7 @@ var DiscoveryResultSchema = object2({
|
|
|
18609
18941
|
bearerMethodsSupported: array2(string2()).nullable(),
|
|
18610
18942
|
tokenEndpointAuthMethodsSupported: array2(string2()).nullable()
|
|
18611
18943
|
});
|
|
18612
|
-
var MetadataResponseSchema =
|
|
18944
|
+
var MetadataResponseSchema = union3([
|
|
18613
18945
|
object2({ requiresOAuth: literal2(false) }),
|
|
18614
18946
|
DiscoveryResultSchema
|
|
18615
18947
|
]);
|
|
@@ -18720,7 +19052,10 @@ var metadataRoute = route({
|
|
|
18720
19052
|
schema: MetadataResponseSchema
|
|
18721
19053
|
},
|
|
18722
19054
|
400: { description: "MCP has no URL / invalid transport" },
|
|
18723
|
-
404: { description: "MCP server not found" }
|
|
19055
|
+
404: { description: "MCP server not found" },
|
|
19056
|
+
502: {
|
|
19057
|
+
description: "Metadata discovery failed: the protected-resource or authorization-server metadata could not be fetched or was refused by the egress guard"
|
|
19058
|
+
}
|
|
18724
19059
|
}
|
|
18725
19060
|
});
|
|
18726
19061
|
var statusRoute = route({
|
|
@@ -18820,6 +19155,7 @@ var disconnectRoute = route({
|
|
|
18820
19155
|
path: "/api/mcp-oauth/{mcpServerId}",
|
|
18821
19156
|
pattern: ["api", "mcp-oauth", null],
|
|
18822
19157
|
summary: "Revoke and delete the OAuth token for an MCP server",
|
|
19158
|
+
description: "Idempotent: the connection row is kept with status revoked (its tokens are cleared) and the server returns to static auth, so a repeat call answers 200 and /status keeps returning the revoked token object.",
|
|
18823
19159
|
tags: ["MCP OAuth"],
|
|
18824
19160
|
auth: { apiKey: true },
|
|
18825
19161
|
params: object2({ mcpServerId: string2() }),
|
|
@@ -19393,7 +19729,10 @@ var createMcpServerRoute = route({
|
|
|
19393
19729
|
}),
|
|
19394
19730
|
responses: {
|
|
19395
19731
|
201: { description: "MCP server created", schema: object2({ server: McpServerSchema }) },
|
|
19396
|
-
400: { description: "Validation error" }
|
|
19732
|
+
400: { description: "Validation error" },
|
|
19733
|
+
409: {
|
|
19734
|
+
description: "A server with this name already exists in the same scope and owner (mcp_server_name_taken)"
|
|
19735
|
+
}
|
|
19397
19736
|
},
|
|
19398
19737
|
rbac: { permission: "mcp-server.create.swarm" }
|
|
19399
19738
|
});
|
|
@@ -19716,6 +20055,10 @@ async function handleMcpServers(req, res, pathSegments, queryParams) {
|
|
|
19716
20055
|
await emitMcpServerConnectedTelemetry2();
|
|
19717
20056
|
createMcpServerRoute.respond(res, 201, { server });
|
|
19718
20057
|
} catch (err) {
|
|
20058
|
+
if (err instanceof Error && err.message.includes("UNIQUE constraint")) {
|
|
20059
|
+
jsonError(res, "mcp_server_name_taken", 409);
|
|
20060
|
+
return true;
|
|
20061
|
+
}
|
|
19719
20062
|
jsonError(res, err instanceof Error ? err.message : "Create failed", 400);
|
|
19720
20063
|
}
|
|
19721
20064
|
return true;
|
|
@@ -19815,7 +20158,7 @@ var userSendTaskInputSchema = object2({
|
|
|
19815
20158
|
priority: number2().int().min(0).max(100).optional().describe("Priority 0-100 (default: 50)."),
|
|
19816
20159
|
model: string2().trim().min(1).optional().describe("Concrete model override interpreted by the assignee's harness/provider."),
|
|
19817
20160
|
modelTier: ModelTierSchema.optional().describe("Portable model tier: 'smol', 'regular', 'smart', or 'ultra'. Resolved by the assignee's harness/provider."),
|
|
19818
|
-
outputSchema: record2(string2(), unknown()).optional().describe("Optional JSON Schema the assignee's final output must satisfy. store-progress rejects a completion that does not match. Supported keywords: type, required, properties, enum, const, items.")
|
|
20161
|
+
outputSchema: record2(string2(), unknown()).optional().describe("Optional JSON Schema the assignee's final output must satisfy. store-progress rejects a completion that does not match. Supported keywords: type, required, properties, enum, const, items. An empty object {} means no schema.")
|
|
19819
20162
|
}).superRefine((data, ctx) => checkOutputSchemaShape(data.outputSchema, ctx));
|
|
19820
20163
|
function permission(verb) {
|
|
19821
20164
|
return { permission: verb };
|
|
@@ -21553,7 +21896,7 @@ var DEFAULT_METRIC_MAX_ROWS = 100;
|
|
|
21553
21896
|
var HARD_METRIC_MAX_ROWS = 500;
|
|
21554
21897
|
var VARIABLE_TOKEN_RE = /^\{\{([a-zA-Z][a-zA-Z0-9_]*)\}\}$/;
|
|
21555
21898
|
var MetricRunBodySchema = object2({
|
|
21556
|
-
variables: record2(string2(),
|
|
21899
|
+
variables: record2(string2(), union3([string2(), number2(), boolean(), _null()])).optional()
|
|
21557
21900
|
}).optional();
|
|
21558
21901
|
function slugify(input) {
|
|
21559
21902
|
const slug = input.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -21714,7 +22057,7 @@ var listMetricsRoute = route({
|
|
|
21714
22057
|
200: {
|
|
21715
22058
|
description: "Metric definitions",
|
|
21716
22059
|
schema: object2({
|
|
21717
|
-
metrics: array2(
|
|
22060
|
+
metrics: array2(union3([MetricSchema, metricSummarySchema])),
|
|
21718
22061
|
total: number2(),
|
|
21719
22062
|
limit: number2(),
|
|
21720
22063
|
offset: number2()
|
|
@@ -21769,7 +22112,7 @@ var metricRunWidgetResultSchema = object2({
|
|
|
21769
22112
|
});
|
|
21770
22113
|
var metricRunResultSchema = object2({
|
|
21771
22114
|
metric: MetricSchema,
|
|
21772
|
-
variables: record2(string2(),
|
|
22115
|
+
variables: record2(string2(), union3([string2(), number2(), boolean(), _null()])),
|
|
21773
22116
|
widgets: array2(object2({
|
|
21774
22117
|
widget: MetricWidgetSchema,
|
|
21775
22118
|
result: metricRunWidgetResultSchema
|
|
@@ -22322,7 +22665,7 @@ var getCatalog = route({
|
|
|
22322
22665
|
path: "/api/models-catalog",
|
|
22323
22666
|
pattern: ["api", "models-catalog"],
|
|
22324
22667
|
summary: "Get the live model catalog for the picker-reachable providers",
|
|
22325
|
-
description: "Slim projection of the models.dev payload (
|
|
22668
|
+
description: "Slim projection of the models.dev payload (the vendored models.dev snapshot, or the live fetch once one succeeds) plus the OpenAI-compatible registry providers; see the `providers` field for the live list. Refreshed server-side at boot and every 12h by the pricing-refresh loop. `source` is 'snapshot' with `updatedAt: null` until the first successful fetch (or when models.dev is unreachable), in which case the vendored snapshot is served instead.",
|
|
22326
22669
|
tags: ["Pricing"],
|
|
22327
22670
|
responses: {
|
|
22328
22671
|
200: {
|
|
@@ -24292,6 +24635,7 @@ init_rbac();
|
|
|
24292
24635
|
init_context_key();
|
|
24293
24636
|
init_errors2();
|
|
24294
24637
|
init_sibling_awareness();
|
|
24638
|
+
init_task_skip();
|
|
24295
24639
|
init_terminal_result_guard();
|
|
24296
24640
|
init_worker_follow_up();
|
|
24297
24641
|
init_types4();
|
|
@@ -24470,7 +24814,7 @@ var listTasks = route({
|
|
|
24470
24814
|
path: "/api/tasks",
|
|
24471
24815
|
pattern: ["api", "tasks"],
|
|
24472
24816
|
summary: "List tasks with filters",
|
|
24473
|
-
description: "Returns tasks with the full `task` text replaced by a bounded `taskPreview` and completion/integration blobs dropped by default — list views only need the preview. Pass `fields=full` to restore the full `AgentTask`, or `fields=timeline` for the narrow shape the dashboard timeline draws. Every shape gives a user caller only tasks of sessions they can read. Fetch a single task in full via `GET /api/tasks/{id}`. `total` (the filtered row count, ignoring limit/offset) is computed only with `includeTotal=true`.",
|
|
24817
|
+
description: "Returns tasks with the full `task` text replaced by a bounded `taskPreview` and completion/integration blobs dropped by default — list views only need the preview. Pass `fields=full` to restore the full `AgentTask`, or `fields=timeline` for the narrow shape the dashboard timeline draws. Every shape gives a user caller only tasks of sessions they can read, unless `scope=all` applies. Fetch a single task in full via `GET /api/tasks/{id}`. `total` (the filtered row count, ignoring limit/offset) is computed only with `includeTotal=true`.",
|
|
24474
24818
|
tags: ["Tasks"],
|
|
24475
24819
|
query: object2({
|
|
24476
24820
|
status: string2().optional(),
|
|
@@ -24489,13 +24833,14 @@ var listTasks = route({
|
|
|
24489
24833
|
limit: exports_coerce.number().int().optional(),
|
|
24490
24834
|
offset: exports_coerce.number().int().optional(),
|
|
24491
24835
|
fields: _enum2(["full", "slim", "timeline"]).optional(),
|
|
24492
|
-
includeTotal: _enum2(["true", "false"]).optional()
|
|
24836
|
+
includeTotal: _enum2(["true", "false"]).optional(),
|
|
24837
|
+
scope: _enum2(["all"]).optional().describe("all: every user's tasks, read-only, for a user whose role lists session.read.all (the built-in auditor role; the grant-all admin role alone does not count); ignored for anyone else. The X-Swarm-Session-Scope: all header opts in the same way.")
|
|
24493
24838
|
}),
|
|
24494
24839
|
responses: {
|
|
24495
24840
|
200: {
|
|
24496
24841
|
description: "Paginated task list",
|
|
24497
24842
|
schema: object2({
|
|
24498
|
-
tasks:
|
|
24843
|
+
tasks: union3([
|
|
24499
24844
|
array2(AgentTaskSchema),
|
|
24500
24845
|
array2(AgentTaskSummarySchema),
|
|
24501
24846
|
array2(AgentTaskTimelineItemSchema)
|
|
@@ -24587,7 +24932,7 @@ var updateSession = route({
|
|
|
24587
24932
|
summary: "Update provider session ID and harness metadata for a task",
|
|
24588
24933
|
tags: ["Tasks"],
|
|
24589
24934
|
params: object2({ id: string2() }),
|
|
24590
|
-
body:
|
|
24935
|
+
body: union3([
|
|
24591
24936
|
object2({
|
|
24592
24937
|
claudeSessionId: string2().min(1),
|
|
24593
24938
|
provider: literal2("devin"),
|
|
@@ -24823,11 +25168,12 @@ var finishTask = route({
|
|
|
24823
25168
|
path: "/api/tasks/{id}/finish",
|
|
24824
25169
|
pattern: ["api", "tasks", null, "finish"],
|
|
24825
25170
|
session: { taskParam: "id" },
|
|
24826
|
-
summary: "Mark task as completed or
|
|
25171
|
+
summary: "Mark task as completed, failed, or skipped (runner endpoint)",
|
|
25172
|
+
description: "`skipped` ends a task that is not the caller's to handle. It needs a one-line reason in `failureReason` (or `output`), keeps `output` empty, posts nothing, and creates no follow-up.",
|
|
24827
25173
|
tags: ["Tasks"],
|
|
24828
25174
|
params: object2({ id: string2() }),
|
|
24829
25175
|
body: object2({
|
|
24830
|
-
status: _enum2(["completed", "failed"]),
|
|
25176
|
+
status: _enum2(["completed", "failed", "skipped"]),
|
|
24831
25177
|
output: string2().optional(),
|
|
24832
25178
|
failureReason: string2().optional(),
|
|
24833
25179
|
force: boolean().optional(),
|
|
@@ -24836,7 +25182,7 @@ var finishTask = route({
|
|
|
24836
25182
|
auth: { apiKey: true, agentId: true },
|
|
24837
25183
|
responses: {
|
|
24838
25184
|
200: { description: "Task finished", schema: FinishTaskSuccessSchema },
|
|
24839
|
-
400: { description: "Invalid status" },
|
|
25185
|
+
400: { description: "Invalid status, or a skip without a reason" },
|
|
24840
25186
|
403: { description: "Not assigned to this agent" },
|
|
24841
25187
|
404: { description: "Task not found" },
|
|
24842
25188
|
409: {
|
|
@@ -25067,7 +25413,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
25067
25413
|
if (validated.length > 0)
|
|
25068
25414
|
source = validated;
|
|
25069
25415
|
}
|
|
25070
|
-
const actor = await resolveSessionActor2(req, myAgentId
|
|
25416
|
+
const actor = await resolveSessionActor2(req, myAgentId, {
|
|
25417
|
+
allUsers: parsed.query.scope === "all"
|
|
25418
|
+
});
|
|
25071
25419
|
const filters = {
|
|
25072
25420
|
status,
|
|
25073
25421
|
agentId: parsed.query.agentId || undefined,
|
|
@@ -25085,7 +25433,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
25085
25433
|
orderBy: parsed.query.orderBy,
|
|
25086
25434
|
limit: parsed.query.limit,
|
|
25087
25435
|
offset: parsed.query.offset,
|
|
25088
|
-
readableBy: actor
|
|
25436
|
+
readableBy: readableByFor2(actor)
|
|
25089
25437
|
};
|
|
25090
25438
|
const tasks = parsed.query.fields === "full" ? await getAllTasks2(filters) : parsed.query.fields === "timeline" ? await getAllTasks2(filters, { fields: "timeline" }) : await getAllTasks2(filters, { slim: true });
|
|
25091
25439
|
if (parsed.query.includeTotal === "true") {
|
|
@@ -25643,7 +25991,14 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
25643
25991
|
if (task.agentId && task.agentId !== myAgentId) {
|
|
25644
25992
|
return { error: "Task is assigned to another agent", status: 403 };
|
|
25645
25993
|
}
|
|
25646
|
-
const
|
|
25994
|
+
const skipReason = parsed.body.status === "skipped" ? skipReasonFrom(parsed.body.failureReason, parsed.body.output) : undefined;
|
|
25995
|
+
if (parsed.body.status === "skipped" && !skipReason) {
|
|
25996
|
+
return {
|
|
25997
|
+
error: 'Status "skipped" needs a one-line reason in failureReason',
|
|
25998
|
+
status: 400
|
|
25999
|
+
};
|
|
26000
|
+
}
|
|
26001
|
+
const terminalResultGuard = await guardTerminalTaskResultWrite(task, parsed.body.status === "skipped" ? { status: "skipped", failureReason: skipReason, force: parsed.body.force } : parsed.body);
|
|
25647
26002
|
if (terminalResultGuard.handled) {
|
|
25648
26003
|
const { handled: _handled, ...guardResult } = terminalResultGuard;
|
|
25649
26004
|
return { ...guardResult, alreadyFinished: true };
|
|
@@ -25662,6 +26017,12 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
25662
26017
|
return { error: "Failed to complete task", status: 500 };
|
|
25663
26018
|
}
|
|
25664
26019
|
updatedTask = result;
|
|
26020
|
+
} else if (parsed.body.status === "skipped") {
|
|
26021
|
+
const result = await skipTask2(parsed.params.id, skipReason);
|
|
26022
|
+
if (!result) {
|
|
26023
|
+
return { error: "Failed to mark task as skipped", status: 500 };
|
|
26024
|
+
}
|
|
26025
|
+
updatedTask = result;
|
|
25665
26026
|
} else {
|
|
25666
26027
|
const result = await failTask2(parsed.params.id, parsed.body.failureReason || "Process exited without explicit completion");
|
|
25667
26028
|
if (!result) {
|
|
@@ -25685,7 +26046,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
25685
26046
|
});
|
|
25686
26047
|
return true;
|
|
25687
26048
|
}
|
|
25688
|
-
if (result.task && isFreshFinishResult(result)) {
|
|
26049
|
+
if (result.task && isFreshFinishResult(result) && parsed.body.status === "skipped") {
|
|
26050
|
+
finalizeSkippedTaskReaction(result.task, "tasks.finish");
|
|
26051
|
+
} else if (result.task && isFreshFinishResult(result)) {
|
|
25689
26052
|
const finishEventId = parsed.body.status === "completed" ? "completed" : "failed";
|
|
25690
26053
|
ensure({
|
|
25691
26054
|
id: finishEventId,
|
|
@@ -25705,7 +26068,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
25705
26068
|
try {
|
|
25706
26069
|
const followUp = await createWorkerTaskFollowUp2({
|
|
25707
26070
|
task: result.task,
|
|
25708
|
-
status:
|
|
26071
|
+
status: finishEventId,
|
|
25709
26072
|
output: parsed.body.output,
|
|
25710
26073
|
failureReason: parsed.body.failureReason
|
|
25711
26074
|
});
|
|
@@ -25904,6 +26267,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
25904
26267
|
}
|
|
25905
26268
|
if (task.workflowRunStepId != null) {
|
|
25906
26269
|
const failed = await failTask2(parsed.params.id, SUPERSEDED_WORKFLOW_TASK_REASON);
|
|
26270
|
+
if (task.agentId) {
|
|
26271
|
+
await updateAgentStatusFromCapacity2(task.agentId);
|
|
26272
|
+
}
|
|
25907
26273
|
ensure({
|
|
25908
26274
|
id: "task.workflow_step_failed_on_supersede",
|
|
25909
26275
|
flow: "task",
|
|
@@ -25937,6 +26303,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
25937
26303
|
});
|
|
25938
26304
|
return true;
|
|
25939
26305
|
}
|
|
26306
|
+
if (task.agentId) {
|
|
26307
|
+
await updateAgentStatusFromCapacity2(task.agentId);
|
|
26308
|
+
}
|
|
25940
26309
|
const followUp = await createResumeFollowUp2({
|
|
25941
26310
|
parentId: parsed.params.id,
|
|
25942
26311
|
reason: parsed.body.reason
|
|
@@ -29051,6 +29420,25 @@ function isAccessible(page, cookiePayload) {
|
|
|
29051
29420
|
needsPassword: true
|
|
29052
29421
|
};
|
|
29053
29422
|
}
|
|
29423
|
+
async function hasSessionForOtherPage(req, pageId) {
|
|
29424
|
+
const header = req.headers.cookie;
|
|
29425
|
+
if (!header)
|
|
29426
|
+
return false;
|
|
29427
|
+
const pairs = (Array.isArray(header) ? header.join("; ") : header).split(";");
|
|
29428
|
+
for (const pair of pairs) {
|
|
29429
|
+
const eq = pair.indexOf("=");
|
|
29430
|
+
if (eq === -1)
|
|
29431
|
+
continue;
|
|
29432
|
+
const name = pair.slice(0, eq).trim();
|
|
29433
|
+
if (name !== LEGACY_PAGE_SESSION_COOKIE && !name.startsWith(`${LEGACY_PAGE_SESSION_COOKIE}_`)) {
|
|
29434
|
+
continue;
|
|
29435
|
+
}
|
|
29436
|
+
const payload = await verifyPageSession(pair.slice(eq + 1).trim());
|
|
29437
|
+
if (payload && payload.pageId !== pageId)
|
|
29438
|
+
return true;
|
|
29439
|
+
}
|
|
29440
|
+
return false;
|
|
29441
|
+
}
|
|
29054
29442
|
function extractPasswordCandidate(req, queryParams) {
|
|
29055
29443
|
const fromQuery = queryParams.get("key");
|
|
29056
29444
|
if (fromQuery !== null)
|
|
@@ -29132,6 +29520,13 @@ async function handlePagesPublic(req, res, pathSegments, queryParams) {
|
|
|
29132
29520
|
return true;
|
|
29133
29521
|
}
|
|
29134
29522
|
} else {
|
|
29523
|
+
if (await hasSessionForOtherPage(req, page.id)) {
|
|
29524
|
+
res.writeHead(403, { "Content-Type": "application/json" });
|
|
29525
|
+
res.end(JSON.stringify({
|
|
29526
|
+
error: "page-session cookie does not match this page id; POST /api/pages/:id/launch"
|
|
29527
|
+
}));
|
|
29528
|
+
return true;
|
|
29529
|
+
}
|
|
29135
29530
|
res.writeHead(access.status, { "Content-Type": "application/json" });
|
|
29136
29531
|
res.end(JSON.stringify({ error: scrubSecrets(access.reason) }));
|
|
29137
29532
|
return true;
|
|
@@ -29642,11 +30037,10 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
29642
30037
|
}
|
|
29643
30038
|
const claimedChannels = hasCapability("messaging") ? await claimMentions2(myAgentId) : [];
|
|
29644
30039
|
if (claimedChannels.length > 0) {
|
|
29645
|
-
const inbox = await getInboxSummary2(myAgentId);
|
|
29646
30040
|
return {
|
|
29647
30041
|
trigger: {
|
|
29648
30042
|
type: "unread_mentions",
|
|
29649
|
-
mentionsCount:
|
|
30043
|
+
mentionsCount: claimedChannels.reduce((sum, c) => sum + c.mentionsCount, 0),
|
|
29650
30044
|
claimedChannels: claimedChannels.map((c) => c.channelId)
|
|
29651
30045
|
}
|
|
29652
30046
|
};
|
|
@@ -30307,7 +30701,7 @@ var ResolveResultSchema = object2({
|
|
|
30307
30701
|
skipped: boolean(),
|
|
30308
30702
|
unresolved: array2(string2())
|
|
30309
30703
|
});
|
|
30310
|
-
var DbResolveResultSchema =
|
|
30704
|
+
var DbResolveResultSchema = union3([
|
|
30311
30705
|
object2({ template: PromptTemplateResponseSchema }),
|
|
30312
30706
|
object2({ skip: literal2(true) })
|
|
30313
30707
|
]).nullable();
|
|
@@ -30457,7 +30851,7 @@ var deleteByIdRoute = route({
|
|
|
30457
30851
|
},
|
|
30458
30852
|
auth: { apiKey: true }
|
|
30459
30853
|
});
|
|
30460
|
-
var
|
|
30854
|
+
var listRoute4 = route({
|
|
30461
30855
|
method: "get",
|
|
30462
30856
|
path: "/api/prompt-templates",
|
|
30463
30857
|
pattern: ["api", "prompt-templates"],
|
|
@@ -30576,7 +30970,7 @@ ${templateBody}` : templateBody;
|
|
|
30576
30970
|
checkoutRoute.respond(res, 200, { template: toPromptTemplateResponse(template) });
|
|
30577
30971
|
} catch (error) {
|
|
30578
30972
|
const message = error instanceof Error ? error.message : "Unknown error";
|
|
30579
|
-
if (message.includes("not found")) {
|
|
30973
|
+
if (message.includes("not found") || message.startsWith("No history entry")) {
|
|
30580
30974
|
jsonError(res, message, 404);
|
|
30581
30975
|
} else {
|
|
30582
30976
|
jsonError(res, message, 400);
|
|
@@ -30637,8 +31031,8 @@ ${templateBody}` : templateBody;
|
|
|
30637
31031
|
}
|
|
30638
31032
|
return true;
|
|
30639
31033
|
}
|
|
30640
|
-
if (
|
|
30641
|
-
const parsed = await
|
|
31034
|
+
if (listRoute4.match(req.method, pathSegments)) {
|
|
31035
|
+
const parsed = await listRoute4.parse(req, res, pathSegments, queryParams);
|
|
30642
31036
|
if (!parsed)
|
|
30643
31037
|
return true;
|
|
30644
31038
|
const templates = getPromptTemplates2({
|
|
@@ -30647,7 +31041,7 @@ ${templateBody}` : templateBody;
|
|
|
30647
31041
|
scopeId: parsed.query.scopeId || undefined,
|
|
30648
31042
|
isDefault: parsed.query.isDefault ? parsed.query.isDefault === "true" : undefined
|
|
30649
31043
|
});
|
|
30650
|
-
|
|
31044
|
+
listRoute4.respond(res, 200, { templates: templates.map(toPromptTemplateResponse) });
|
|
30651
31045
|
return true;
|
|
30652
31046
|
}
|
|
30653
31047
|
if (upsertRoute.match(req.method, pathSegments)) {
|
|
@@ -31823,7 +32217,7 @@ var listSchedules = route({
|
|
|
31823
32217
|
200: {
|
|
31824
32218
|
description: "List of schedules",
|
|
31825
32219
|
schema: object2({
|
|
31826
|
-
schedules:
|
|
32220
|
+
schedules: union3([
|
|
31827
32221
|
array2(scheduleSummaryWithFavoriteSchema),
|
|
31828
32222
|
array2(scheduleWithFavoriteSchema)
|
|
31829
32223
|
]),
|
|
@@ -31950,6 +32344,10 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
31950
32344
|
jsonError(res, "delayMs and runAt are only for one-time schedules. Set scheduleType to 'one_time'.", 400);
|
|
31951
32345
|
return true;
|
|
31952
32346
|
}
|
|
32347
|
+
if (!body.cronExpression && !body.intervalMs) {
|
|
32348
|
+
jsonError(res, "Either cronExpression or intervalMs must be provided.", 400);
|
|
32349
|
+
return true;
|
|
32350
|
+
}
|
|
31953
32351
|
}
|
|
31954
32352
|
if (body.cronExpression) {
|
|
31955
32353
|
try {
|
|
@@ -32321,9 +32719,9 @@ var McpJsonRpcErrorSchema = object2({
|
|
|
32321
32719
|
message: string2().optional(),
|
|
32322
32720
|
data: unknown().optional()
|
|
32323
32721
|
});
|
|
32324
|
-
var McpToolCallEnvelopeSchema =
|
|
32722
|
+
var McpToolCallEnvelopeSchema = union3([
|
|
32325
32723
|
object2({ ok: literal2(true), result: McpToolCallResultSchema }),
|
|
32326
|
-
object2({ ok: literal2(false), error:
|
|
32724
|
+
object2({ ok: literal2(false), error: union3([McpJsonRpcErrorSchema, string2()]) })
|
|
32327
32725
|
]);
|
|
32328
32726
|
var mcpCallRoute = route({
|
|
32329
32727
|
method: "post",
|
|
@@ -32345,7 +32743,7 @@ var mcpCallRoute = route({
|
|
|
32345
32743
|
404: { description: "Script connection or agent not found" }
|
|
32346
32744
|
}
|
|
32347
32745
|
});
|
|
32348
|
-
var SqlQueryEnvelopeSchema =
|
|
32746
|
+
var SqlQueryEnvelopeSchema = union3([
|
|
32349
32747
|
object2({
|
|
32350
32748
|
ok: literal2(true),
|
|
32351
32749
|
rows: array2(record2(string2(), unknown())),
|
|
@@ -33149,7 +33547,7 @@ var disconnectOAuthAppRoute = route({
|
|
|
33149
33547
|
responses: {
|
|
33150
33548
|
200: {
|
|
33151
33549
|
description: "Disconnect result",
|
|
33152
|
-
schema:
|
|
33550
|
+
schema: union3([
|
|
33153
33551
|
object2({ disconnected: literal2(false), message: string2() }),
|
|
33154
33552
|
object2({ disconnected: literal2(true), revocationAttempted: boolean() })
|
|
33155
33553
|
])
|
|
@@ -34608,6 +35006,7 @@ var postInternalStepRoute = route({
|
|
|
34608
35006
|
pattern: ["api", "internal", "script-runs", null, "steps"],
|
|
34609
35007
|
operationId: "script_runs_internal_step_create",
|
|
34610
35008
|
summary: "Write a script run journal step",
|
|
35009
|
+
description: "Write-once per stepKey; a replay keeps the first journal entry and still answers 201.",
|
|
34611
35010
|
tags: ["Script Runs"],
|
|
34612
35011
|
params: runIdParamsSchema,
|
|
34613
35012
|
body: journalStepBodySchema,
|
|
@@ -35109,7 +35508,7 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
|
|
|
35109
35508
|
agentTaskRoute.respond(res, 200, { taskId: latest.id, taskOutput: latest.output ?? null });
|
|
35110
35509
|
return true;
|
|
35111
35510
|
}
|
|
35112
|
-
if (latest.status === "failed" || latest.status === "cancelled" || latest.status === "superseded") {
|
|
35511
|
+
if (latest.status === "failed" || latest.status === "cancelled" || latest.status === "superseded" || latest.status === "skipped") {
|
|
35113
35512
|
json(res, { error: `Agent task ${latest.status}`, taskId: latest.id }, 409);
|
|
35114
35513
|
return true;
|
|
35115
35514
|
}
|
|
@@ -35492,7 +35891,7 @@ var patchScriptApiRoute = route({
|
|
|
35492
35891
|
responses: {
|
|
35493
35892
|
200: {
|
|
35494
35893
|
description: "Updated endpoint",
|
|
35495
|
-
schema:
|
|
35894
|
+
schema: union3([ScriptApiRecordSchema, _null()])
|
|
35496
35895
|
},
|
|
35497
35896
|
404: { description: "Endpoint not found" }
|
|
35498
35897
|
},
|
|
@@ -36727,7 +37126,7 @@ var AgentTaskSummarySchema2 = AgentTaskSchema.pick({
|
|
|
36727
37126
|
totalCostUsd: true
|
|
36728
37127
|
});
|
|
36729
37128
|
var SessionListItemSchema = object2({
|
|
36730
|
-
root:
|
|
37129
|
+
root: union3([AgentTaskSchema, AgentTaskSummarySchema2]),
|
|
36731
37130
|
chainTaskCount: number2().int(),
|
|
36732
37131
|
lastActivityAt: string2(),
|
|
36733
37132
|
latestStatus: AgentTaskStatusSchema,
|
|
@@ -37045,7 +37444,7 @@ var listSessions = route({
|
|
|
37045
37444
|
status: _enum2(["running", "failed", "needs"]).optional(),
|
|
37046
37445
|
withUserId: string2().min(1).optional(),
|
|
37047
37446
|
fields: _enum2(["full", "slim"]).optional(),
|
|
37048
|
-
scope: _enum2(["mine", "shared", "tree"]).optional().describe("mine: owned sessions. shared: sessions shared with me. tree: Sessions that GET /api/session-tree counts: mine plus shared with me, no ownerless roots. A bypass actor sees every root with tree scope."),
|
|
37447
|
+
scope: _enum2(["mine", "shared", "tree", "all"]).optional().describe("mine: owned sessions. shared: sessions shared with me. tree: Sessions that GET /api/session-tree counts: mine plus shared with me, no ownerless roots. A bypass actor sees every root with tree scope. all: every user's sessions, read-only, for a user whose role lists session.read.all (the built-in auditor role; the grant-all admin role alone does not count); ignored for anyone else. The X-Swarm-Session-Scope: all header opts in the same way, also for tree."),
|
|
37049
37448
|
show: SessionShowSchema,
|
|
37050
37449
|
hideSource: SessionHideSourceSchema,
|
|
37051
37450
|
showSource: SessionShowSourceSchema
|
|
@@ -37205,6 +37604,29 @@ async function checkSessionMove(rootTaskId, actor, req, myAgentId, options = {})
|
|
|
37205
37604
|
}
|
|
37206
37605
|
return { taskIds: tasks.map((task) => task.id) };
|
|
37207
37606
|
}
|
|
37607
|
+
async function withDispatchedTasks(chain, sessionRootId, actor) {
|
|
37608
|
+
const dispatched = await getTasksDispatchedFrom2(chain.map((task) => task.id));
|
|
37609
|
+
if (dispatched.length === 0)
|
|
37610
|
+
return chain;
|
|
37611
|
+
const roots = await getSessionRoots(dispatched.map((task) => task.id));
|
|
37612
|
+
const foreignRoots = new Map;
|
|
37613
|
+
for (const root of roots.values()) {
|
|
37614
|
+
if (root.id !== sessionRootId)
|
|
37615
|
+
foreignRoots.set(root.id, root);
|
|
37616
|
+
}
|
|
37617
|
+
const readable = new Set([sessionRootId]);
|
|
37618
|
+
await Promise.all([...foreignRoots.values()].map(async (root) => {
|
|
37619
|
+
if (await accessForRoot(actor, root) !== "none")
|
|
37620
|
+
readable.add(root.id);
|
|
37621
|
+
}));
|
|
37622
|
+
const visible = dispatched.filter((task) => {
|
|
37623
|
+
const root = roots.get(task.id);
|
|
37624
|
+
return root !== undefined && readable.has(root.id);
|
|
37625
|
+
});
|
|
37626
|
+
if (visible.length === 0)
|
|
37627
|
+
return chain;
|
|
37628
|
+
return [...chain, ...visible].sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
37629
|
+
}
|
|
37208
37630
|
var getSession = route({
|
|
37209
37631
|
method: "get",
|
|
37210
37632
|
path: "/api/sessions/{rootTaskId}",
|
|
@@ -37215,7 +37637,7 @@ var getSession = route({
|
|
|
37215
37637
|
params: object2({ rootTaskId: string2() }),
|
|
37216
37638
|
responses: {
|
|
37217
37639
|
200: {
|
|
37218
|
-
description: "Root task + chain (ordered by createdAt), plus the caller's `access` and the session `owner`",
|
|
37640
|
+
description: "Root task + chain (ordered by createdAt), plus the caller's `access` and the session `owner`. The chain also holds tasks a chain task dispatched (`dispatchedByTaskId`) that sit elsewhere: in the same session, or in another session the caller can read.",
|
|
37219
37641
|
schema: object2({
|
|
37220
37642
|
root: TaskWithSteeringSchema,
|
|
37221
37643
|
chain: array2(TaskWithSteeringSchema),
|
|
@@ -37272,7 +37694,7 @@ var putSessionShares = route({
|
|
|
37272
37694
|
rbac: { permission: "session.share" }
|
|
37273
37695
|
});
|
|
37274
37696
|
async function accessForRoot(actor, root) {
|
|
37275
|
-
return actor.kind === "bypass" ? "owner" : sessionAccessForRoot(actor.userId, root);
|
|
37697
|
+
return actor.kind === "bypass" ? "owner" : withReadAll2(actor, await sessionAccessForRoot(actor.userId, root));
|
|
37276
37698
|
}
|
|
37277
37699
|
async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
|
|
37278
37700
|
if (await handleAgentTokens(req, res, pathSegments, queryParams))
|
|
@@ -37354,9 +37776,10 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
37354
37776
|
if (!parsed)
|
|
37355
37777
|
return true;
|
|
37356
37778
|
const sources = parsed.query.source ? parsed.query.source.split(",").map((s) => s.trim()).filter(Boolean) : undefined;
|
|
37357
|
-
const
|
|
37779
|
+
const allUsers = parsed.query.scope === "all";
|
|
37780
|
+
const actor = await resolveSessionActor2(req, myAgentId, { allUsers });
|
|
37358
37781
|
const limit = Math.min(200, Math.max(0, parsed.query.limit ?? 25));
|
|
37359
|
-
if (actor.kind === "bypass" && parsed.query.scope
|
|
37782
|
+
if (actor.kind === "bypass" && (parsed.query.scope === "mine" || parsed.query.scope === "shared")) {
|
|
37360
37783
|
listSessions.respond(res, 200, {
|
|
37361
37784
|
sessions: [],
|
|
37362
37785
|
total: 0,
|
|
@@ -37384,7 +37807,8 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
37384
37807
|
...actor.kind === "user" ? {
|
|
37385
37808
|
viewer: {
|
|
37386
37809
|
userId: actor.userId,
|
|
37387
|
-
scope: parsed.query.scope === "
|
|
37810
|
+
scope: parsed.query.scope === "mine" || parsed.query.scope === "shared" ? parsed.query.scope : "all",
|
|
37811
|
+
readAll: actor.readAll
|
|
37388
37812
|
}
|
|
37389
37813
|
} : {}
|
|
37390
37814
|
};
|
|
@@ -37430,7 +37854,7 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
37430
37854
|
return true;
|
|
37431
37855
|
}
|
|
37432
37856
|
const { action, show, ...list } = parsed.body;
|
|
37433
|
-
const updated = await triageSessionList(actor.userId, { ...list, mine: show !== "all" }, action);
|
|
37857
|
+
const updated = await triageSessionList(actor.userId, { ...list, mine: show !== "all" }, action, actor.readAll);
|
|
37434
37858
|
triageSessionListRoute.respond(res, 200, { updated });
|
|
37435
37859
|
return true;
|
|
37436
37860
|
}
|
|
@@ -37551,13 +37975,13 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
37551
37975
|
id: sessionRoot.requestedByUserId,
|
|
37552
37976
|
name: ownerUser?.name ?? sessionRoot.requestedByUserId
|
|
37553
37977
|
} : null;
|
|
37554
|
-
const chain = await getRootTaskChain2(parsed.params.rootTaskId);
|
|
37978
|
+
const chain = await withDispatchedTasks(await getRootTaskChain2(parsed.params.rootTaskId), sessionRoot.id, actor);
|
|
37555
37979
|
const tasks = [root, ...chain];
|
|
37556
37980
|
const [steering, citations, approvals, read, groupKey] = await Promise.all([
|
|
37557
37981
|
getTaskSteeringFieldsForTasks(tasks),
|
|
37558
37982
|
getTaskCitationsForTasks(tasks.map((task) => task.id)),
|
|
37559
37983
|
getPendingApprovalsForTasks2(tasks.map((task) => task.id)),
|
|
37560
|
-
actor.kind === "user" && actor.userId ? getSessionReadState(sessionRoot.id, actor.userId) : Promise.resolve(null),
|
|
37984
|
+
actor.kind === "user" && actor.userId ? getSessionReadState(sessionRoot.id, actor.userId, undefined, actor.readAll) : Promise.resolve(null),
|
|
37561
37985
|
getSessionGroupKey(root)
|
|
37562
37986
|
]);
|
|
37563
37987
|
const decorate = (task) => ({
|
|
@@ -39056,7 +39480,7 @@ var listScheduledTasks = route({
|
|
|
39056
39480
|
200: {
|
|
39057
39481
|
description: "Scheduled tasks list",
|
|
39058
39482
|
schema: object2({
|
|
39059
|
-
scheduledTasks:
|
|
39483
|
+
scheduledTasks: union3([
|
|
39060
39484
|
array2(ScheduledTaskSchema),
|
|
39061
39485
|
array2(scheduleSummaryWithFavoriteSchema)
|
|
39062
39486
|
])
|
|
@@ -39386,7 +39810,7 @@ var JiraStatusPayloadSchema = object2({
|
|
|
39386
39810
|
webhookIds: array2(JiraWebhookIdEntrySchema),
|
|
39387
39811
|
manualWebhookInstructions: string2().optional()
|
|
39388
39812
|
});
|
|
39389
|
-
var JiraWebhookEventResultSchema =
|
|
39813
|
+
var JiraWebhookEventResultSchema = union3([
|
|
39390
39814
|
object2({ status: literal2("accepted") }),
|
|
39391
39815
|
object2({ status: literal2("duplicate") }),
|
|
39392
39816
|
object2({ status: literal2("ignored"), reason: literal2("invalid-json") })
|
|
@@ -40082,7 +40506,8 @@ function getOperatorActor(req, res) {
|
|
|
40082
40506
|
const auth = getRequestAuth(req);
|
|
40083
40507
|
const userId = authUserId(auth);
|
|
40084
40508
|
if (userId) {
|
|
40085
|
-
|
|
40509
|
+
const tokenId = auth?.kind === "user" ? auth.tokenId : undefined;
|
|
40510
|
+
return tokenId ? { kind: "user", id: userId, tokenId } : { kind: "user", id: userId };
|
|
40086
40511
|
}
|
|
40087
40512
|
if (isOperatorAuth(auth)) {
|
|
40088
40513
|
return { kind: "operator", id: auth.fingerprint };
|
|
@@ -40133,14 +40558,16 @@ var setUserRolesRoute = route({
|
|
|
40133
40558
|
pattern: ["api", "users", null, "roles"],
|
|
40134
40559
|
operationId: "users_setRbacRoles",
|
|
40135
40560
|
summary: "Set a user's RBAC roles",
|
|
40136
|
-
description: `Replaces the user's roles. The set holds exactly one of ${PRIMARY_ROLE_NAMES2.join(", ")} plus any extra roles. Demoting a user below admin removes the ability to answer approval requests, even when the user is listed as an approver. Fails with 409 when it would leave no active admin.`,
|
|
40561
|
+
description: `Replaces the user's roles. The set holds exactly one of ${PRIMARY_ROLE_NAMES2.join(", ")} plus any extra roles. Demoting a user below admin removes the ability to answer approval requests, even when the user is listed as an approver. Fails with 409 when it would leave no active admin. Adding a role that grants session.read.all (the built-in auditor role) requires the operator key: every new user is a grant-all admin, so a user token could grant it to itself. Adding such a role revokes the user's MCP tokens and spends its unused connector and invite codes.`,
|
|
40137
40562
|
tags: ["Users"],
|
|
40138
40563
|
params: object2({ id: string2().min(1) }),
|
|
40139
40564
|
body: object2({ roles: array2(string2().min(1)).min(1) }).strict(),
|
|
40140
40565
|
responses: {
|
|
40141
40566
|
200: { description: "The user's roles after the change", schema: UserRbacRolesSchema },
|
|
40142
40567
|
400: { description: "Invalid role set" },
|
|
40143
|
-
403: {
|
|
40568
|
+
403: {
|
|
40569
|
+
description: "Not allowed to change roles, or adding an operator-only role with a user token"
|
|
40570
|
+
},
|
|
40144
40571
|
404: { description: "User not found" },
|
|
40145
40572
|
409: { description: "Would leave no active admin" }
|
|
40146
40573
|
},
|
|
@@ -40221,6 +40648,10 @@ async function handleUserRoles(req, res, pathSegments, queryParams) {
|
|
|
40221
40648
|
jsonError(res, err.message, 400);
|
|
40222
40649
|
return true;
|
|
40223
40650
|
}
|
|
40651
|
+
if (err instanceof OperatorGrantedRoleError2) {
|
|
40652
|
+
jsonError(res, err.message, 403);
|
|
40653
|
+
return true;
|
|
40654
|
+
}
|
|
40224
40655
|
throw err;
|
|
40225
40656
|
}
|
|
40226
40657
|
setUserRolesRoute.respond(res, 200, await composeRoles(userId));
|
|
@@ -40240,6 +40671,7 @@ init_constants3();
|
|
|
40240
40671
|
init_egress_guard();
|
|
40241
40672
|
init_request_auth_context();
|
|
40242
40673
|
init_route_def();
|
|
40674
|
+
init_session_access();
|
|
40243
40675
|
init_utils2();
|
|
40244
40676
|
async function composeUser(userId, recentEventLimit = 5) {
|
|
40245
40677
|
const user = await getUserById2(userId);
|
|
@@ -40312,12 +40744,13 @@ var whoamiRoute = route({
|
|
|
40312
40744
|
description: "Authenticated principal",
|
|
40313
40745
|
schema: object2({
|
|
40314
40746
|
kind: _enum2(["operator", "user"]),
|
|
40315
|
-
user:
|
|
40747
|
+
user: union3([UserSchema, _null()]),
|
|
40316
40748
|
grants: object2({
|
|
40317
40749
|
grantsAll: boolean(),
|
|
40318
40750
|
verbs: array2(string2()),
|
|
40319
40751
|
roles: array2(string2())
|
|
40320
|
-
}).optional()
|
|
40752
|
+
}).optional(),
|
|
40753
|
+
sessionReadAll: boolean().optional()
|
|
40321
40754
|
})
|
|
40322
40755
|
},
|
|
40323
40756
|
401: { description: "Unauthorized" }
|
|
@@ -40367,7 +40800,8 @@ var createUserRoute = route({
|
|
|
40367
40800
|
schema: object2({ user: ComposedUserSchema.nullable() })
|
|
40368
40801
|
},
|
|
40369
40802
|
400: { description: "Validation error" },
|
|
40370
|
-
401: { description: "Unauthorized" }
|
|
40803
|
+
401: { description: "Unauthorized" },
|
|
40804
|
+
409: { description: "A user with this email already exists (user_exists)" }
|
|
40371
40805
|
},
|
|
40372
40806
|
auth: { apiKey: true }
|
|
40373
40807
|
});
|
|
@@ -40397,7 +40831,7 @@ var resolveUnmapped = route({
|
|
|
40397
40831
|
summary: "Resolve an unmapped identity — link to an existing user or create a new one",
|
|
40398
40832
|
tags: ["Users"],
|
|
40399
40833
|
params: object2({ kind: string2(), externalId: string2() }),
|
|
40400
|
-
body:
|
|
40834
|
+
body: union3([
|
|
40401
40835
|
object2({ userId: string2().min(1) }),
|
|
40402
40836
|
object2({
|
|
40403
40837
|
name: string2().min(1),
|
|
@@ -40412,6 +40846,9 @@ var resolveUnmapped = route({
|
|
|
40412
40846
|
},
|
|
40413
40847
|
400: { description: "Validation error" },
|
|
40414
40848
|
401: { description: "Unauthorized" },
|
|
40849
|
+
403: {
|
|
40850
|
+
description: "Target holds an operator-granted role (auditor) and the caller is not the operator key"
|
|
40851
|
+
},
|
|
40415
40852
|
404: { description: "Target user not found" }
|
|
40416
40853
|
},
|
|
40417
40854
|
auth: { apiKey: true }
|
|
@@ -40466,6 +40903,9 @@ var updateUserRoute = route({
|
|
|
40466
40903
|
},
|
|
40467
40904
|
400: { description: "Validation error or empty body" },
|
|
40468
40905
|
401: { description: "Unauthorized" },
|
|
40906
|
+
403: {
|
|
40907
|
+
description: "Target holds an operator-granted role (auditor) and the caller is not the operator key"
|
|
40908
|
+
},
|
|
40469
40909
|
404: { description: "User not found" }
|
|
40470
40910
|
},
|
|
40471
40911
|
auth: { apiKey: true }
|
|
@@ -40491,6 +40931,9 @@ var mintUserMcpTokenRoute = route({
|
|
|
40491
40931
|
})
|
|
40492
40932
|
},
|
|
40493
40933
|
401: { description: "Unauthorized" },
|
|
40934
|
+
403: {
|
|
40935
|
+
description: "Target holds an operator-granted role (auditor) and the caller is not the operator key"
|
|
40936
|
+
},
|
|
40494
40937
|
404: { description: "User not found" }
|
|
40495
40938
|
},
|
|
40496
40939
|
auth: { apiKey: true }
|
|
@@ -40534,6 +40977,9 @@ var createConnectorCodeRoute = route({
|
|
|
40534
40977
|
},
|
|
40535
40978
|
400: { description: "The public API origin or CONNECTOR_CONNECT_URL is not HTTPS" },
|
|
40536
40979
|
401: { description: "Unauthorized" },
|
|
40980
|
+
403: {
|
|
40981
|
+
description: "Target holds an operator-granted role (auditor) and the caller is not the operator key"
|
|
40982
|
+
},
|
|
40537
40983
|
404: { description: "User not found" }
|
|
40538
40984
|
},
|
|
40539
40985
|
auth: { apiKey: true },
|
|
@@ -40666,6 +41112,9 @@ var mergeUsersRoute = route({
|
|
|
40666
41112
|
},
|
|
40667
41113
|
400: { description: "Validation error (e.g. target == source)" },
|
|
40668
41114
|
401: { description: "Unauthorized" },
|
|
41115
|
+
403: {
|
|
41116
|
+
description: "Target holds an operator-granted role (auditor) and the caller is not the operator key"
|
|
41117
|
+
},
|
|
40669
41118
|
404: { description: "Target or source user not found" },
|
|
40670
41119
|
409: { description: "Source is the last active admin (last_admin)" }
|
|
40671
41120
|
},
|
|
@@ -40705,9 +41154,13 @@ var addIdentityRoute = route({
|
|
|
40705
41154
|
description: "Updated identity list",
|
|
40706
41155
|
schema: object2({ identities: array2(UserIdentityLinkSchema) })
|
|
40707
41156
|
},
|
|
40708
|
-
400: { description: "Validation error
|
|
41157
|
+
400: { description: "Validation error" },
|
|
40709
41158
|
401: { description: "Unauthorized" },
|
|
40710
|
-
|
|
41159
|
+
403: {
|
|
41160
|
+
description: "Target holds an operator-granted role (auditor) and the caller is not the operator key"
|
|
41161
|
+
},
|
|
41162
|
+
404: { description: "User not found" },
|
|
41163
|
+
409: { description: "The (kind, externalId) identity is already linked (identity_taken)" }
|
|
40711
41164
|
},
|
|
40712
41165
|
auth: { apiKey: true }
|
|
40713
41166
|
});
|
|
@@ -40728,6 +41181,21 @@ var deleteIdentityRoute = route({
|
|
|
40728
41181
|
},
|
|
40729
41182
|
auth: { apiKey: true }
|
|
40730
41183
|
});
|
|
41184
|
+
function writeGuarded(actor, targetUserId, write) {
|
|
41185
|
+
return getDbClient2().transaction(async () => {
|
|
41186
|
+
await assertMayActOnOperatorGrantedTarget2(actor, targetUserId);
|
|
41187
|
+
return await write();
|
|
41188
|
+
});
|
|
41189
|
+
}
|
|
41190
|
+
function respondOperatorGrantedRefusal(res, err) {
|
|
41191
|
+
if (!(err instanceof OperatorGrantedTargetError2))
|
|
41192
|
+
return false;
|
|
41193
|
+
jsonError(res, err.message, 403);
|
|
41194
|
+
return true;
|
|
41195
|
+
}
|
|
41196
|
+
function isUniqueViolation(err, target) {
|
|
41197
|
+
return err instanceof Error && err.message.includes("UNIQUE constraint") && err.message.includes(target);
|
|
41198
|
+
}
|
|
40731
41199
|
var UNMAPPED_KINDS = [
|
|
40732
41200
|
"slack",
|
|
40733
41201
|
"github",
|
|
@@ -40838,6 +41306,8 @@ async function handleUsers(req, res, pathSegments, queryParams) {
|
|
|
40838
41306
|
if (!parsed)
|
|
40839
41307
|
return true;
|
|
40840
41308
|
const user = authUser(getRequestAuth(req));
|
|
41309
|
+
const scopeActor = await resolveSessionActor2(req, undefined, { allUsers: true });
|
|
41310
|
+
const sessionReadAll = scopeActor.kind === "bypass" || scopeActor.readAll === true;
|
|
40841
41311
|
if (user) {
|
|
40842
41312
|
const [grant, roles] = await Promise.all([getUserGrant2(user.id), listUserRoles2(user.id)]);
|
|
40843
41313
|
const grantsAll = !isRbacEnabled() || grant.grantsAll;
|
|
@@ -40848,13 +41318,15 @@ async function handleUsers(req, res, pathSegments, queryParams) {
|
|
|
40848
41318
|
grantsAll,
|
|
40849
41319
|
verbs: grantsAll ? [] : [...grant.verbs].sort(),
|
|
40850
41320
|
roles: roles.map((role) => role.name)
|
|
40851
|
-
}
|
|
41321
|
+
},
|
|
41322
|
+
sessionReadAll
|
|
40852
41323
|
});
|
|
40853
41324
|
} else {
|
|
40854
41325
|
whoamiRoute.respond(res, 200, {
|
|
40855
41326
|
kind: "operator",
|
|
40856
41327
|
user: null,
|
|
40857
|
-
grants: { grantsAll: true, verbs: [], roles: [] }
|
|
41328
|
+
grants: { grantsAll: true, verbs: [], roles: [] },
|
|
41329
|
+
sessionReadAll
|
|
40858
41330
|
});
|
|
40859
41331
|
}
|
|
40860
41332
|
return true;
|
|
@@ -40878,19 +41350,26 @@ async function handleUsers(req, res, pathSegments, queryParams) {
|
|
|
40878
41350
|
return true;
|
|
40879
41351
|
try {
|
|
40880
41352
|
const { identities, ...userFields } = parsed.body;
|
|
40881
|
-
const user = await
|
|
40882
|
-
|
|
40883
|
-
|
|
40884
|
-
|
|
40885
|
-
|
|
40886
|
-
|
|
40887
|
-
|
|
40888
|
-
|
|
40889
|
-
|
|
40890
|
-
|
|
41353
|
+
const user = await getDbClient2().transaction(async () => {
|
|
41354
|
+
const created = await createUser2(userFields);
|
|
41355
|
+
await syncUserBudgetMirror(created.id, userFields.dailyBudgetUsd);
|
|
41356
|
+
for (const ident of identities ?? []) {
|
|
41357
|
+
await linkIdentity(created.id, ident.kind, ident.externalId, actor);
|
|
41358
|
+
}
|
|
41359
|
+
if (userFields.dailyBudgetUsd !== undefined) {
|
|
41360
|
+
await recordIdentityEvent(created.id, "budget_changed", actor, null, {
|
|
41361
|
+
dailyBudgetUsd: userFields.dailyBudgetUsd
|
|
41362
|
+
});
|
|
41363
|
+
}
|
|
41364
|
+
return created;
|
|
41365
|
+
});
|
|
40891
41366
|
const composed = await composeUser(user.id);
|
|
40892
41367
|
createUserRoute.respond(res, 200, { user: composed });
|
|
40893
41368
|
} catch (err) {
|
|
41369
|
+
if (isUniqueViolation(err, "users.email")) {
|
|
41370
|
+
jsonError(res, "user_exists", 409);
|
|
41371
|
+
return true;
|
|
41372
|
+
}
|
|
40894
41373
|
jsonError(res, err instanceof Error ? err.message : "Failed to create user", 500);
|
|
40895
41374
|
}
|
|
40896
41375
|
return true;
|
|
@@ -40930,21 +41409,27 @@ async function handleUsers(req, res, pathSegments, queryParams) {
|
|
|
40930
41409
|
return true;
|
|
40931
41410
|
}
|
|
40932
41411
|
targetUserId = existing.id;
|
|
41412
|
+
await writeGuarded(actor, targetUserId, () => linkIdentity(targetUserId, kind, externalId, actor));
|
|
40933
41413
|
} else {
|
|
40934
|
-
const
|
|
40935
|
-
|
|
40936
|
-
|
|
40937
|
-
|
|
41414
|
+
const body = parsed.body;
|
|
41415
|
+
targetUserId = await getDbClient2().transaction(async () => {
|
|
41416
|
+
const created = await createUser2({
|
|
41417
|
+
name: body.name,
|
|
41418
|
+
email: body.email,
|
|
41419
|
+
notes: body.notes
|
|
41420
|
+
});
|
|
41421
|
+
await linkIdentity(created.id, kind, externalId, actor);
|
|
41422
|
+
return created.id;
|
|
40938
41423
|
});
|
|
40939
|
-
targetUserId = created.id;
|
|
40940
41424
|
}
|
|
40941
|
-
await linkIdentity(targetUserId, kind, externalId, actor);
|
|
40942
41425
|
const ns = `integration:unmapped:${kind}`;
|
|
40943
41426
|
await deleteKv2(ns, `${externalId}:meta`);
|
|
40944
41427
|
await deleteKv2(ns, `${externalId}:count`);
|
|
40945
41428
|
const user = await composeUser(targetUserId);
|
|
40946
41429
|
resolveUnmapped.respond(res, 200, { user });
|
|
40947
41430
|
} catch (err) {
|
|
41431
|
+
if (respondOperatorGrantedRefusal(res, err))
|
|
41432
|
+
return true;
|
|
40948
41433
|
jsonError(res, err instanceof Error ? err.message : "Failed to resolve unmapped", 500);
|
|
40949
41434
|
}
|
|
40950
41435
|
return true;
|
|
@@ -40976,7 +41461,7 @@ async function handleUsers(req, res, pathSegments, queryParams) {
|
|
|
40976
41461
|
return true;
|
|
40977
41462
|
}
|
|
40978
41463
|
try {
|
|
40979
|
-
const { tokenId, plaintext } = await mintToken(parsed.params.id, parsed.body.label ?? null, actor);
|
|
41464
|
+
const { tokenId, plaintext } = await writeGuarded(actor, parsed.params.id, () => mintToken(parsed.params.id, parsed.body.label ?? null, actor));
|
|
40980
41465
|
const token = (await listUserTokens(parsed.params.id)).find((t) => t.id === tokenId);
|
|
40981
41466
|
mintUserMcpTokenRoute.respond(res, 200, {
|
|
40982
41467
|
plaintext,
|
|
@@ -40984,6 +41469,8 @@ async function handleUsers(req, res, pathSegments, queryParams) {
|
|
|
40984
41469
|
user: await composeUser(parsed.params.id)
|
|
40985
41470
|
});
|
|
40986
41471
|
} catch (err) {
|
|
41472
|
+
if (respondOperatorGrantedRefusal(res, err))
|
|
41473
|
+
return true;
|
|
40987
41474
|
jsonError(res, err instanceof Error ? err.message : "Failed to mint token", 500);
|
|
40988
41475
|
}
|
|
40989
41476
|
return true;
|
|
@@ -41016,6 +41503,8 @@ async function handleUsers(req, res, pathSegments, queryParams) {
|
|
|
41016
41503
|
const connectUrl = connect.toString();
|
|
41017
41504
|
createConnectorCodeRoute.respond(res, 201, { code, expiresAt, connectUrl });
|
|
41018
41505
|
} catch (err) {
|
|
41506
|
+
if (respondOperatorGrantedRefusal(res, err))
|
|
41507
|
+
return true;
|
|
41019
41508
|
jsonError(res, err instanceof Error ? err.message : "Failed to create connector code", 500);
|
|
41020
41509
|
}
|
|
41021
41510
|
return true;
|
|
@@ -41204,11 +41693,17 @@ async function handleUsers(req, res, pathSegments, queryParams) {
|
|
|
41204
41693
|
return true;
|
|
41205
41694
|
}
|
|
41206
41695
|
try {
|
|
41207
|
-
await linkIdentity(parsed.params.id, parsed.body.kind, parsed.body.externalId, actor);
|
|
41696
|
+
await writeGuarded(actor, parsed.params.id, () => linkIdentity(parsed.params.id, parsed.body.kind, parsed.body.externalId, actor));
|
|
41208
41697
|
addIdentityRoute.respond(res, 200, {
|
|
41209
41698
|
identities: await getUserIdentities(parsed.params.id)
|
|
41210
41699
|
});
|
|
41211
41700
|
} catch (err) {
|
|
41701
|
+
if (respondOperatorGrantedRefusal(res, err))
|
|
41702
|
+
return true;
|
|
41703
|
+
if (isUniqueViolation(err, "user_external_ids")) {
|
|
41704
|
+
jsonError(res, "identity_taken", 409);
|
|
41705
|
+
return true;
|
|
41706
|
+
}
|
|
41212
41707
|
jsonError(res, err instanceof Error ? err.message : "Failed to link identity", 400);
|
|
41213
41708
|
}
|
|
41214
41709
|
return true;
|
|
@@ -41261,6 +41756,7 @@ async function handleUsers(req, res, pathSegments, queryParams) {
|
|
|
41261
41756
|
}
|
|
41262
41757
|
try {
|
|
41263
41758
|
const mergedUser = await getDbClient2().transaction(async () => {
|
|
41759
|
+
await assertMayActOnOperatorGrantedTarget2(actor, targetId);
|
|
41264
41760
|
for (const ident of sourceBefore.identities) {
|
|
41265
41761
|
await unlinkIdentity(sourceId, ident.kind, ident.externalId, actor);
|
|
41266
41762
|
await linkIdentity(targetId, ident.kind, ident.externalId, actor);
|
|
@@ -41302,6 +41798,8 @@ async function handleUsers(req, res, pathSegments, queryParams) {
|
|
|
41302
41798
|
});
|
|
41303
41799
|
mergeUsersRoute.respond(res, 200, { user: mergedUser });
|
|
41304
41800
|
} catch (err) {
|
|
41801
|
+
if (respondOperatorGrantedRefusal(res, err))
|
|
41802
|
+
return true;
|
|
41305
41803
|
if (err instanceof LastAdminError2) {
|
|
41306
41804
|
jsonError(res, "last_admin", 409);
|
|
41307
41805
|
return true;
|
|
@@ -41334,6 +41832,8 @@ async function handleUsers(req, res, pathSegments, queryParams) {
|
|
|
41334
41832
|
jsonError(res, "User not found", 404);
|
|
41335
41833
|
return true;
|
|
41336
41834
|
}
|
|
41835
|
+
const { identities: newIdentities, email: newEmail, emailAliases: newAliases } = parsed.body;
|
|
41836
|
+
const bindsIdentity = newIdentities !== undefined || newEmail !== undefined || newAliases !== undefined;
|
|
41337
41837
|
try {
|
|
41338
41838
|
const { identities, metadata, comms, ...rest } = parsed.body;
|
|
41339
41839
|
const update = { ...rest };
|
|
@@ -41350,68 +41850,77 @@ async function handleUsers(req, res, pathSegments, queryParams) {
|
|
|
41350
41850
|
} else if (metadata !== undefined) {
|
|
41351
41851
|
update.metadata = metadata;
|
|
41352
41852
|
}
|
|
41353
|
-
const
|
|
41354
|
-
|
|
41355
|
-
|
|
41356
|
-
|
|
41357
|
-
|
|
41358
|
-
|
|
41359
|
-
|
|
41360
|
-
|
|
41361
|
-
|
|
41362
|
-
if (parsed.body.status !== undefined && before.status !== parsed.body.status) {
|
|
41363
|
-
await recordIdentityEvent(parsed.params.id, "status_changed", actor, { status: before.status }, { status: parsed.body.status });
|
|
41364
|
-
}
|
|
41365
|
-
if (parsed.body.emailAliases !== undefined) {
|
|
41366
|
-
const beforeSet = new Set((before.emailAliases ?? []).map((a) => a.toLowerCase()));
|
|
41367
|
-
const afterSet = new Set(parsed.body.emailAliases.map((a) => a.toLowerCase()));
|
|
41368
|
-
for (const a of parsed.body.emailAliases) {
|
|
41369
|
-
if (!beforeSet.has(a.toLowerCase())) {
|
|
41370
|
-
await recordIdentityEvent(parsed.params.id, "email_added", actor, null, { email: a });
|
|
41371
|
-
}
|
|
41853
|
+
const found = await getDbClient2().transaction(async () => {
|
|
41854
|
+
if (bindsIdentity)
|
|
41855
|
+
await assertMayActOnOperatorGrantedTarget2(actor, parsed.params.id);
|
|
41856
|
+
const updated = await updateUser2(parsed.params.id, update);
|
|
41857
|
+
if (!updated)
|
|
41858
|
+
return false;
|
|
41859
|
+
await syncUserBudgetMirror(parsed.params.id, parsed.body.dailyBudgetUsd);
|
|
41860
|
+
if (parsed.body.dailyBudgetUsd !== undefined && (before.dailyBudgetUsd ?? null) !== (parsed.body.dailyBudgetUsd ?? null)) {
|
|
41861
|
+
await recordIdentityEvent(parsed.params.id, "budget_changed", actor, { dailyBudgetUsd: before.dailyBudgetUsd ?? null }, { dailyBudgetUsd: parsed.body.dailyBudgetUsd ?? null });
|
|
41372
41862
|
}
|
|
41373
|
-
|
|
41374
|
-
|
|
41375
|
-
await recordIdentityEvent(parsed.params.id, "email_removed", actor, { email: a }, null);
|
|
41376
|
-
}
|
|
41863
|
+
if (parsed.body.status !== undefined && before.status !== parsed.body.status) {
|
|
41864
|
+
await recordIdentityEvent(parsed.params.id, "status_changed", actor, { status: before.status }, { status: parsed.body.status });
|
|
41377
41865
|
}
|
|
41378
|
-
|
|
41379
|
-
|
|
41380
|
-
|
|
41381
|
-
|
|
41382
|
-
|
|
41383
|
-
|
|
41384
|
-
|
|
41385
|
-
|
|
41386
|
-
|
|
41387
|
-
|
|
41388
|
-
|
|
41389
|
-
|
|
41390
|
-
continue;
|
|
41391
|
-
const beforeVal = before[field] ?? null;
|
|
41392
|
-
const afterVal = parsed.body[field] ?? null;
|
|
41393
|
-
if (JSON.stringify(beforeVal) === JSON.stringify(afterVal))
|
|
41394
|
-
continue;
|
|
41395
|
-
await recordIdentityEvent(parsed.params.id, "profile_changed", actor, { [field]: beforeVal }, { [field]: afterVal });
|
|
41396
|
-
}
|
|
41397
|
-
if (identities !== undefined) {
|
|
41398
|
-
const beforeIds = await getUserIdentities(parsed.params.id);
|
|
41399
|
-
const beforeKeys = new Set(beforeIds.map((i) => `${i.kind}:${i.externalId}`));
|
|
41400
|
-
const afterKeys = new Set(identities.map((i) => `${i.kind}:${i.externalId}`));
|
|
41401
|
-
for (const i of identities) {
|
|
41402
|
-
if (!beforeKeys.has(`${i.kind}:${i.externalId}`)) {
|
|
41403
|
-
await linkIdentity(parsed.params.id, i.kind, i.externalId, actor);
|
|
41866
|
+
if (parsed.body.emailAliases !== undefined) {
|
|
41867
|
+
const beforeSet = new Set((before.emailAliases ?? []).map((a) => a.toLowerCase()));
|
|
41868
|
+
const afterSet = new Set(parsed.body.emailAliases.map((a) => a.toLowerCase()));
|
|
41869
|
+
for (const a of parsed.body.emailAliases) {
|
|
41870
|
+
if (!beforeSet.has(a.toLowerCase())) {
|
|
41871
|
+
await recordIdentityEvent(parsed.params.id, "email_added", actor, null, { email: a });
|
|
41872
|
+
}
|
|
41873
|
+
}
|
|
41874
|
+
for (const a of before.emailAliases ?? []) {
|
|
41875
|
+
if (!afterSet.has(a.toLowerCase())) {
|
|
41876
|
+
await recordIdentityEvent(parsed.params.id, "email_removed", actor, { email: a }, null);
|
|
41877
|
+
}
|
|
41404
41878
|
}
|
|
41405
41879
|
}
|
|
41406
|
-
|
|
41407
|
-
|
|
41408
|
-
|
|
41880
|
+
const PROFILE_FIELDS = [
|
|
41881
|
+
"name",
|
|
41882
|
+
"email",
|
|
41883
|
+
"role",
|
|
41884
|
+
"timezone",
|
|
41885
|
+
"preferredChannel",
|
|
41886
|
+
"notes",
|
|
41887
|
+
"metadata"
|
|
41888
|
+
];
|
|
41889
|
+
for (const field of PROFILE_FIELDS) {
|
|
41890
|
+
if (parsed.body[field] === undefined)
|
|
41891
|
+
continue;
|
|
41892
|
+
const beforeVal = before[field] ?? null;
|
|
41893
|
+
const afterVal = parsed.body[field] ?? null;
|
|
41894
|
+
if (JSON.stringify(beforeVal) === JSON.stringify(afterVal))
|
|
41895
|
+
continue;
|
|
41896
|
+
await recordIdentityEvent(parsed.params.id, "profile_changed", actor, { [field]: beforeVal }, { [field]: afterVal });
|
|
41897
|
+
}
|
|
41898
|
+
if (identities !== undefined) {
|
|
41899
|
+
const beforeIds = await getUserIdentities(parsed.params.id);
|
|
41900
|
+
const beforeKeys = new Set(beforeIds.map((i) => `${i.kind}:${i.externalId}`));
|
|
41901
|
+
const afterKeys = new Set(identities.map((i) => `${i.kind}:${i.externalId}`));
|
|
41902
|
+
for (const i of identities) {
|
|
41903
|
+
if (!beforeKeys.has(`${i.kind}:${i.externalId}`)) {
|
|
41904
|
+
await linkIdentity(parsed.params.id, i.kind, i.externalId, actor);
|
|
41905
|
+
}
|
|
41906
|
+
}
|
|
41907
|
+
for (const i of beforeIds) {
|
|
41908
|
+
if (!afterKeys.has(`${i.kind}:${i.externalId}`)) {
|
|
41909
|
+
await unlinkIdentity(parsed.params.id, i.kind, i.externalId, actor);
|
|
41910
|
+
}
|
|
41409
41911
|
}
|
|
41410
41912
|
}
|
|
41913
|
+
return true;
|
|
41914
|
+
});
|
|
41915
|
+
if (!found) {
|
|
41916
|
+
jsonError(res, "User not found", 404);
|
|
41917
|
+
return true;
|
|
41411
41918
|
}
|
|
41412
41919
|
const composed = await composeUser(parsed.params.id);
|
|
41413
41920
|
updateUserRoute.respond(res, 200, { user: composed });
|
|
41414
41921
|
} catch (err) {
|
|
41922
|
+
if (respondOperatorGrantedRefusal(res, err))
|
|
41923
|
+
return true;
|
|
41415
41924
|
jsonError(res, err instanceof Error ? err.message : "Failed to update user", 500);
|
|
41416
41925
|
}
|
|
41417
41926
|
return true;
|
|
@@ -41652,7 +42161,7 @@ var githubWebhook = route({
|
|
|
41652
42161
|
responses: {
|
|
41653
42162
|
200: {
|
|
41654
42163
|
description: "Event processed",
|
|
41655
|
-
schema:
|
|
42164
|
+
schema: union3([object2({ message: literal2("pong") }), WebhookDispatchResultSchema])
|
|
41656
42165
|
},
|
|
41657
42166
|
401: { description: "Invalid signature" },
|
|
41658
42167
|
503: { description: "GitHub integration not configured" }
|
|
@@ -42621,7 +43130,7 @@ var listWorkflowsRoute = route({
|
|
|
42621
43130
|
responses: {
|
|
42622
43131
|
200: {
|
|
42623
43132
|
description: "Workflow list",
|
|
42624
|
-
schema:
|
|
43133
|
+
schema: union3([array2(WorkflowSummarySchema), array2(WorkflowWithFavoriteSchema)])
|
|
42625
43134
|
}
|
|
42626
43135
|
}
|
|
42627
43136
|
});
|
|
@@ -42824,7 +43333,7 @@ var getWorkflowRunRoute = route({
|
|
|
42824
43333
|
responses: {
|
|
42825
43334
|
200: {
|
|
42826
43335
|
description: "Workflow run details with steps including retry info",
|
|
42827
|
-
schema:
|
|
43336
|
+
schema: union3([
|
|
42828
43337
|
object2({
|
|
42829
43338
|
run: WorkflowRunSchema,
|
|
42830
43339
|
steps: array2(WorkflowRunStepSchema),
|
|
@@ -42863,7 +43372,8 @@ var retryWorkflowRunRoute = route({
|
|
|
42863
43372
|
params: object2({ id: string2() }),
|
|
42864
43373
|
responses: {
|
|
42865
43374
|
200: { description: "Retry started", schema: SuccessResponseSchema },
|
|
42866
|
-
400: { description: "Cannot retry" }
|
|
43375
|
+
400: { description: "Cannot retry" },
|
|
43376
|
+
404: { description: "Run not found" }
|
|
42867
43377
|
}
|
|
42868
43378
|
});
|
|
42869
43379
|
var cancelWorkflowRunRoute = route({
|
|
@@ -43164,7 +43674,11 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
43164
43674
|
res.end();
|
|
43165
43675
|
return true;
|
|
43166
43676
|
}
|
|
43167
|
-
|
|
43677
|
+
if (result.reason === "patch") {
|
|
43678
|
+
jsonError(res, result.errors.join("; "), 404);
|
|
43679
|
+
return true;
|
|
43680
|
+
}
|
|
43681
|
+
jsonError(res, `Invalid definition: ${result.errors.join("; ")}`, 400);
|
|
43168
43682
|
return true;
|
|
43169
43683
|
}
|
|
43170
43684
|
patchWorkflowNodeRoute.respond(res, 200, await withSaveWarnings(result.workflow));
|
|
@@ -43447,6 +43961,10 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
43447
43961
|
const parsed = await retryWorkflowRunRoute.parse(req, res, pathSegments, queryParams);
|
|
43448
43962
|
if (!parsed)
|
|
43449
43963
|
return true;
|
|
43964
|
+
if (!await getWorkflowRunSummary(parsed.params.id)) {
|
|
43965
|
+
jsonError(res, `Workflow run not found: ${parsed.params.id}`, 404);
|
|
43966
|
+
return true;
|
|
43967
|
+
}
|
|
43450
43968
|
try {
|
|
43451
43969
|
await retryFailedRun2(parsed.params.id, getExecutorRegistry2());
|
|
43452
43970
|
} catch (err) {
|
|
@@ -43863,6 +44381,7 @@ var httpServer = createHttpServer(async (req, res) => {
|
|
|
43863
44381
|
() => handleInboxState(req, res, pathSegments, queryParams),
|
|
43864
44382
|
() => handleTelemetryUi(req, res, pathSegments, queryParams, myAgentId),
|
|
43865
44383
|
() => handleUsedBy(req, res, pathSegments, queryParams, myAgentId),
|
|
44384
|
+
() => handleImprovements(req, res, pathSegments, queryParams),
|
|
43866
44385
|
() => handleRanking(req, res, pathSegments, queryParams),
|
|
43867
44386
|
() => handleFleetBenchmark(req, res, pathSegments, queryParams),
|
|
43868
44387
|
() => handleTaskTemplates(req, res, pathSegments, queryParams),
|
|
@@ -43895,7 +44414,7 @@ var httpServer = createHttpServer(async (req, res) => {
|
|
|
43895
44414
|
});
|
|
43896
44415
|
});
|
|
43897
44416
|
var detachRealtime = attachRealtimeTransport(httpServer);
|
|
43898
|
-
var { attachControllerTransport } = await import("./controllers-connect-
|
|
44417
|
+
var { attachControllerTransport } = await import("./controllers-connect-498hrxvk.js");
|
|
43899
44418
|
var detachControllers = attachControllerTransport(httpServer);
|
|
43900
44419
|
var stopWorkerNudges = startWorkerNudgeListener();
|
|
43901
44420
|
var taskAutoTitles = startTaskAutoTitleListener();
|
|
@@ -43926,7 +44445,7 @@ async function shutdown() {
|
|
|
43926
44445
|
sessionsProcessed: getServerSessionsProcessed()
|
|
43927
44446
|
});
|
|
43928
44447
|
if (hasCapability("scheduling")) {
|
|
43929
|
-
const { stopScheduler } = await import("./index-
|
|
44448
|
+
const { stopScheduler } = await import("./index-nfy4kkg5.js");
|
|
43930
44449
|
stopScheduler();
|
|
43931
44450
|
}
|
|
43932
44451
|
stopHeartbeat2();
|
|
@@ -43938,7 +44457,7 @@ async function shutdown() {
|
|
|
43938
44457
|
await stopSlackApp2();
|
|
43939
44458
|
await stopChatSdk();
|
|
43940
44459
|
if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
|
|
43941
|
-
const { stopOAuthKeepalive } = await import("./keepalive-
|
|
44460
|
+
const { stopOAuthKeepalive } = await import("./keepalive-wy29kbrg.js");
|
|
43942
44461
|
await stopOAuthKeepalive();
|
|
43943
44462
|
}
|
|
43944
44463
|
stopOAuthPendingGc();
|
|
@@ -44020,21 +44539,21 @@ try {
|
|
|
44020
44539
|
console.warn("[startup] CAPABILITIES upgrade seed failed (non-fatal):", err);
|
|
44021
44540
|
}
|
|
44022
44541
|
try {
|
|
44023
|
-
const { ensurePricingSeeded } = await import("./boot-seeds-
|
|
44542
|
+
const { ensurePricingSeeded } = await import("./boot-seeds-qdaf3sdy.js");
|
|
44024
44543
|
ensurePricingSeeded();
|
|
44025
|
-
const { startPricingRefreshLoop } = await import("./pricing-refresh-
|
|
44544
|
+
const { startPricingRefreshLoop } = await import("./pricing-refresh-x7nhv23d.js");
|
|
44026
44545
|
startPricingRefreshLoop();
|
|
44027
44546
|
} catch (err) {
|
|
44028
44547
|
console.error("[startup] Failed to seed pricing rows:", err);
|
|
44029
44548
|
}
|
|
44030
44549
|
try {
|
|
44031
|
-
const { ensureModelProfilesSeeded } = await import("./boot-seeds-
|
|
44550
|
+
const { ensureModelProfilesSeeded } = await import("./boot-seeds-qdaf3sdy.js");
|
|
44032
44551
|
await ensureModelProfilesSeeded();
|
|
44033
44552
|
} catch (err) {
|
|
44034
44553
|
console.error("[startup] Failed to seed model profiles:", err);
|
|
44035
44554
|
}
|
|
44036
44555
|
try {
|
|
44037
|
-
const { ensureRbacSeeded } = await import("./boot-seeds-
|
|
44556
|
+
const { ensureRbacSeeded } = await import("./boot-seeds-qdaf3sdy.js");
|
|
44038
44557
|
ensureRbacSeeded();
|
|
44039
44558
|
} catch (err) {
|
|
44040
44559
|
console.error("[startup] Failed to sync RBAC seed rows:", err);
|
|
@@ -44042,7 +44561,7 @@ try {
|
|
|
44042
44561
|
throw err;
|
|
44043
44562
|
}
|
|
44044
44563
|
try {
|
|
44045
|
-
const { runAllSeeders } = await import("./index-
|
|
44564
|
+
const { runAllSeeders } = await import("./index-c9y31ytf.js");
|
|
44046
44565
|
await runAllSeeders({ scriptEmbeddingMode: "skip" });
|
|
44047
44566
|
} catch (err) {
|
|
44048
44567
|
console.error("[startup] Failed to seed built-in entities:", err);
|
|
@@ -44105,26 +44624,26 @@ httpServer.listen(port, async () => {
|
|
|
44105
44624
|
await initWorkflows2();
|
|
44106
44625
|
await startScriptRunSupervisor(getMcpBaseUrl());
|
|
44107
44626
|
if (hasCapability("scheduling")) {
|
|
44108
|
-
const { startScheduler } = await import("./index-
|
|
44109
|
-
const { getExecutorRegistry } = await import("./index-
|
|
44627
|
+
const { startScheduler } = await import("./index-nfy4kkg5.js");
|
|
44628
|
+
const { getExecutorRegistry } = await import("./index-8ybffts4.js");
|
|
44110
44629
|
const intervalMs = Number(process.env.SCHEDULER_INTERVAL_MS) || 1e4;
|
|
44111
44630
|
startScheduler(getExecutorRegistry(), intervalMs, {
|
|
44112
44631
|
runId: globalState.__runId
|
|
44113
44632
|
});
|
|
44114
44633
|
}
|
|
44115
44634
|
if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
|
|
44116
|
-
const { startHeartbeat } = await import("./index-
|
|
44635
|
+
const { startHeartbeat } = await import("./index-4x08sjtk.js");
|
|
44117
44636
|
const heartbeatMs = Number(process.env.HEARTBEAT_INTERVAL_MS) || 90000;
|
|
44118
44637
|
startHeartbeat(heartbeatMs);
|
|
44119
44638
|
}
|
|
44120
44639
|
startPoolRouting();
|
|
44121
44640
|
startRuntimeSupervisor();
|
|
44122
44641
|
if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
|
|
44123
|
-
const { startOAuthKeepalive } = await import("./keepalive-
|
|
44642
|
+
const { startOAuthKeepalive } = await import("./keepalive-wy29kbrg.js");
|
|
44124
44643
|
startOAuthKeepalive();
|
|
44125
44644
|
}
|
|
44126
44645
|
if (!isEnvFlagEnabled("OAUTH_REFRESH_SWEEP_DISABLE", false)) {
|
|
44127
|
-
const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-
|
|
44646
|
+
const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-q7mtbyp3.js");
|
|
44128
44647
|
startOAuthRefreshSweep();
|
|
44129
44648
|
}
|
|
44130
44649
|
startOAuthPendingGc();
|
|
@@ -44133,16 +44652,19 @@ httpServer.listen(port, async () => {
|
|
|
44133
44652
|
await startDbRetention();
|
|
44134
44653
|
startHumanFreeDrain();
|
|
44135
44654
|
startTaskSearchBackfill();
|
|
44136
|
-
import("./embedding-space-
|
|
44655
|
+
import("./embedding-space-xh8p4q4x.js").then(({ runEmbeddingMaintenance, setDeploymentEnvReader }) => {
|
|
44137
44656
|
setDeploymentEnvReader(getDeploymentEnvValue);
|
|
44138
44657
|
return runEmbeddingMaintenance({ backfill: true });
|
|
44139
44658
|
}).catch((err) => {
|
|
44140
44659
|
console.error("[embedding-space] startup maintenance failed (non-fatal):", err);
|
|
44141
44660
|
});
|
|
44142
|
-
import("./boot-
|
|
44661
|
+
import("./boot-args-schema-h4qj462e.js").then(({ runBootArgsSchemaBackfill }) => runBootArgsSchemaBackfill()).catch((err) => {
|
|
44662
|
+
console.error("[boot-args-schema] startup backfill failed (non-fatal):", err);
|
|
44663
|
+
});
|
|
44664
|
+
import("./boot-scrub-sweep-9w9jp4sm.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
|
|
44143
44665
|
console.error("[boot-scrub-sweep] startup scrub failed (non-fatal):", err);
|
|
44144
44666
|
});
|
|
44145
|
-
import("./session-source-backfill-
|
|
44667
|
+
import("./session-source-backfill-440ysamr.js").then(({ runSessionSourceBackfill }) => runSessionSourceBackfill()).catch((err) => {
|
|
44146
44668
|
console.error("[session-source-backfill] startup run failed (non-fatal):", err);
|
|
44147
44669
|
});
|
|
44148
44670
|
}).on("error", (err) => {
|