@desplega.ai/agent-swarm 2.13.0 → 2.13.2
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/README.md +1 -1
- package/dist/acp-adapter-x1qqgzwx.js +17 -0
- package/dist/{acp-targets-86f0sh6g.js → acp-targets-mz8c5dnt.js} +10 -10
- package/dist/{actions-zv8vcxvr.js → actions-5ft3qp5a.js} +27 -27
- package/dist/{agent-fs-provision-jqshb33y.js → agent-fs-provision-6fgz7wvz.js} +4 -4
- package/dist/{amp-adapter-gt503ywc.js → amp-adapter-nthn8ezm.js} +3 -3
- package/dist/{app-6t4k5rh1.js → app-535m78qw.js} +10 -10
- package/dist/{approval-notifications-fcfw063h.js → approval-notifications-dewbk403.js} +11 -11
- package/dist/{assistant-9dzybh12.js → assistant-39zyabv2.js} +28 -28
- package/dist/{boot-args-schema-xzfp2feg.js → boot-args-schema-bqv5bf77.js} +1 -1
- package/dist/{boot-reembed-3jz0p2jk.js → boot-reembed-157c0gcz.js} +1 -1
- package/dist/{boot-reembed-r88wngfg.js → boot-reembed-fas7z3zn.js} +1 -1
- package/dist/{boot-scrub-sweep-scrqhw48.js → boot-scrub-sweep-tmec0be2.js} +2 -2
- package/dist/{boot-seeds-vb2dcrrb.js → boot-seeds-32zm50x2.js} +4 -4
- package/dist/{boxd-68n75y1s.js → boxd-hr8rsxzq.js} +1 -1
- package/dist/{claude-adapter-h3mp9hgs.js → claude-adapter-gwq7x2nj.js} +9 -9
- package/dist/{claude-managed-adapter-kpbyj2vb.js → claude-managed-adapter-rkvw6fvq.js} +4 -4
- package/dist/{claude-managed-setup-0efr3wkg.js → claude-managed-setup-0vgz4d1j.js} +6 -6
- package/dist/{claude-sdk-session-03dw669q.js → claude-sdk-session-5wbwxy8c.js} +20967 -19390
- package/dist/{cli-z64t9pe6.js → cli-0f7n3td3.js} +1 -1
- package/dist/{cli-j53hpbsm.js → cli-0xwb7zpt.js} +2 -2
- package/dist/{cli-wxwv3t11.js → cli-1f48qdnb.js} +55 -13
- package/dist/{cli-gfcv679k.js → cli-1gevjrc1.js} +1 -1
- package/dist/{cli-0jkenasr.js → cli-2v4xxnx2.js} +1 -1
- package/dist/{cli-hc6e4tac.js → cli-2wde56gv.js} +6 -6
- package/dist/{cli-mh7pdxe0.js → cli-31vt7baf.js} +17 -17
- package/dist/{cli-ercwc8xn.js → cli-3mf04tkh.js} +1 -1
- package/dist/{cli-s6zk31gr.js → cli-43dsqhcp.js} +4 -4
- package/dist/{cli-1dbv9mj9.js → cli-4djg31jh.js} +1 -1
- package/dist/{cli-tn91wc6e.js → cli-50whymxq.js} +1 -1
- package/dist/{cli-js10kdk7.js → cli-5basv0e7.js} +19 -5
- package/dist/{cli-b2jh3dyb.js → cli-5k1hvycs.js} +4 -4
- package/dist/{cli-dkejt425.js → cli-62fjschk.js} +7 -7
- package/dist/{cli-zqmmy073.js → cli-69eq6gdk.js} +18 -18
- package/dist/{cli-qm3ntjqs.js → cli-6rmryz03.js} +13 -13
- package/dist/{cli-mz34pxbk.js → cli-7m6bbtab.js} +11 -11
- package/dist/{cli-wv20kbr3.js → cli-8a4qg44m.js} +5 -5
- package/dist/{cli-2m6yaq6b.js → cli-8fj8yfmk.js} +1 -1
- package/dist/{cli-9m9kyw77.js → cli-8qvte9hn.js} +2 -2
- package/dist/{cli-x05p2d05.js → cli-9tevdxyf.js} +1 -1
- package/dist/{cli-qec9bynj.js → cli-a6rzw649.js} +3 -3
- package/dist/{cli-ex1y88j3.js → cli-at67kvnp.js} +1 -1
- package/dist/{cli-yn4kt85g.js → cli-b0kqw55g.js} +1 -1
- package/dist/{cli-n3qe7tyr.js → cli-b0m3bg0f.js} +134 -3
- package/dist/{cli-xfjn2kyq.js → cli-bp2rt28p.js} +9 -9
- package/dist/{cli-2jk4s7z1.js → cli-c9bwawf9.js} +3 -3
- package/dist/{cli-wndegmns.js → cli-cmgdptmx.js} +3 -3
- package/dist/{cli-3p288654.js → cli-cpkxh68d.js} +2 -2
- package/dist/{cli-117g15t4.js → cli-cs26ed89.js} +8 -8
- package/dist/{cli-prf7kz78.js → cli-d0jb2qnt.js} +603 -78
- package/dist/{cli-8hp56wat.js → cli-d2epqm0y.js} +1 -1
- package/dist/{cli-wrhbym01.js → cli-d528acsw.js} +6 -6
- package/dist/{cli-tstj6e8e.js → cli-dnvmwsvc.js} +310 -88
- package/dist/{cli-9fsagra4.js → cli-e87fg3en.js} +1 -1
- package/dist/{cli-jj3c5nyb.js → cli-erh1rgh4.js} +116 -56
- package/dist/{cli-f1952kjy.js → cli-ewb028rs.js} +4 -4
- package/dist/{cli-ct8sz3np.js → cli-f1sdh8ca.js} +6 -6
- package/dist/{cli-0b655smz.js → cli-fcwrd7bh.js} +5 -5
- package/dist/{cli-eb279wn3.js → cli-fgm2mad9.js} +2 -2
- package/dist/{cli-bpje8n65.js → cli-fp65jdp2.js} +31 -6
- package/dist/{cli-dnh64e8e.js → cli-g0b3ma7r.js} +7 -7
- package/dist/{cli-avxh26pd.js → cli-gc7jkf4a.js} +4 -4
- package/dist/{cli-2skf1mdf.js → cli-gedf48yw.js} +4 -4
- package/dist/{cli-ajjvqhf3.js → cli-getrvmtx.js} +27 -6
- package/dist/{cli-c8v2yvej.js → cli-gq6qhmrr.js} +2 -2
- package/dist/{cli-mbwmqb5w.js → cli-h0ewec3d.js} +1 -1
- package/dist/{cli-tdk7jtka.js → cli-hv3820ez.js} +1 -1
- package/dist/{cli-avqkr20b.js → cli-j2ybkdk2.js} +2 -2
- package/dist/{cli-pqfecppn.js → cli-je587f74.js} +1 -1
- package/dist/{cli-hgsxnjyg.js → cli-jkkcm72j.js} +13 -13
- package/dist/{cli-g6j6ac3h.js → cli-ka13xx6b.js} +2 -2
- package/dist/{cli-t35hx078.js → cli-m1wddksc.js} +2 -2
- package/dist/{cli-50w82h6m.js → cli-mwxez0pz.js} +1 -0
- package/dist/{cli-nc6a8b5b.js → cli-n14r8h4n.js} +2 -2
- package/dist/{cli-y4a4458j.js → cli-n46d87mj.js} +3 -3
- package/dist/{cli-0dg7ytxm.js → cli-nkfv398a.js} +1096 -75
- package/dist/{cli-fhvk2nvp.js → cli-nvqq3232.js} +9 -9
- package/dist/{cli-bhgrhedp.js → cli-q8aq48v1.js} +1 -1
- package/dist/{cli-6a40p4kv.js → cli-qn79645p.js} +1 -1
- package/dist/{cli-hbq0kwxz.js → cli-r4fphq38.js} +4 -4
- package/dist/{cli-47hz21se.js → cli-r8ddn0hf.js} +4 -5
- package/dist/{cli-hpb9x72z.js → cli-rvhaahfv.js} +9 -9
- package/dist/{cli-qhhb30e8.js → cli-s08zsqva.js} +9 -9
- package/dist/{cli-sdh61g52.js → cli-s6fhqbz1.js} +2 -2
- package/dist/{cli-y518qkjg.js → cli-sjk85d7v.js} +13 -12
- package/dist/{cli-ytc7fpza.js → cli-t25rq8mg.js} +4 -4
- package/dist/{cli-sq913bh1.js → cli-t9nxq30h.js} +8 -8
- package/dist/{cli-49f5jyhh.js → cli-tbdw3f92.js} +3 -3
- package/dist/{cli-1v82d2w6.js → cli-tceqvv6h.js} +4 -4
- package/dist/{cli-fz9pcjsw.js → cli-tgmate57.js} +4 -4
- package/dist/{cli-rtmqzat7.js → cli-vdfngx2g.js} +2 -2
- package/dist/{cli-9w8712tq.js → cli-vr4eyq6p.js} +43 -14
- package/dist/{cli-z4f346g5.js → cli-vx9acp12.js} +1 -1
- package/dist/{cli-7dbhnsj9.js → cli-wdtqkqnq.js} +4 -4
- package/dist/{cli-kde4ky90.js → cli-x5yb8zc8.js} +2 -2
- package/dist/{cli-w14j2z4k.js → cli-x7aqhxj5.js} +2 -2
- package/dist/{cli-kspxjftk.js → cli-xerdrnqs.js} +15 -6
- package/dist/{cli-48nvk6sb.js → cli-xhkek467.js} +2 -2
- package/dist/{cli-dka73bak.js → cli-xysy1g8x.js} +152 -12
- package/dist/{cli-7wy8gbwb.js → cli-ya1cj689.js} +1 -1
- package/dist/{cli-n85m2wkq.js → cli-zkbz8m2q.js} +3 -2
- package/dist/{cli-0pazkmd4.js → cli-zm6bkx3e.js} +4 -4
- package/dist/{cli-6h88mn9q.js → cli-zqy28rwx.js} +4 -4
- package/dist/cli.js +30 -29
- package/dist/{codex-adapter-f3yp0kaj.js → codex-adapter-x25xfbnh.js} +8 -8
- package/dist/{codex-hook-262cekfp.js → codex-hook-c0nvm30r.js} +2 -2
- package/dist/{codex-login-1ven7yje.js → codex-login-ven5cz5j.js} +1 -1
- package/dist/{codex-session-runner-ns4mv70p.js → codex-session-runner-kn5xnrvp.js} +9 -9
- package/dist/{commands-5bzf2tfw.js → commands-8n59gxmy.js} +3 -3
- package/dist/{controller-5xt7kvfm.js → controller-wn3vd217.js} +3 -3
- package/dist/{controllers-connect-0gg13mzp.js → controllers-connect-09gvkrhc.js} +28 -28
- package/dist/core-2b8bv6ny.js +42 -0
- package/dist/{cursor-adapter-p0c5zv6r.js → cursor-adapter-w1681kp1.js} +2 -2
- package/dist/{db-2s68ycq7.js → db-e71keqxk.js} +3 -3
- package/dist/{db-q7q639k5.js → db-spg81qtr.js} +2 -2
- package/dist/{devin-adapter-t8d86q9x.js → devin-adapter-fs90ab4v.js} +1 -1
- package/dist/{dispatcher-j2y1q7ae.js → dispatcher-fr4vawwb.js} +25 -25
- package/dist/{docker-1b41eysj.js → docker-1h33jvh9.js} +2 -2
- package/dist/{dsh-adapter-pgnkf4st.js → dsh-adapter-g9yqv09y.js} +2 -2
- package/dist/{e2b-xm60c8ad.js → e2b-jnk0yeva.js} +2 -2
- package/dist/{e2b-ew8c5j5v.js → e2b-y7e5kmzf.js} +2 -2
- package/dist/{easter-egg-3d-0kea97jf.js → easter-egg-3d-ac9tv9a6.js} +1 -1
- package/dist/{embedding-space-3n6mhhmy.js → embedding-space-an77f45k.js} +6 -6
- package/dist/{embeddings-jfmj6yme.js → embeddings-jkrehejr.js} +1 -1
- package/dist/{event-bus-v4ywhc2p.js → event-bus-08t2b4y2.js} +1 -1
- package/dist/{execute-tjrej979.js → execute-3mys4nta.js} +1 -1
- package/dist/{external-channel-jy8w2gg3.js → external-channel-s6zxpts9.js} +2 -2
- package/dist/fx-adapter-4yet1c4f.js +20 -0
- package/dist/grok-adapter-8ge6tw7m.js +20 -0
- package/dist/handlers-0r9evrdj.js +41 -0
- package/dist/heartbeat-jjpb44e5.js +50 -0
- package/dist/{hook-fv1jwrv7.js → hook-68gbs87k.js} +6 -6
- package/dist/{hook-bpnncsec.js → hook-y6n23zzj.js} +8 -8
- package/dist/{http-bpa26czn.js → http-8c6y008s.js} +404 -146
- package/dist/{index-w216g9y9.js → index-0vthtbc2.js} +38 -22
- package/dist/index-1v23363p.js +39 -0
- package/dist/index-30qw6vyw.js +44 -0
- package/dist/index-6bm3w6cn.js +40 -0
- package/dist/{index-s8re7mvq.js → index-6h3r0vpe.js} +1 -1
- package/dist/{index-620y7jzq.js → index-7dgxveck.js} +3 -3
- package/dist/{index-4k7m5dgj.js → index-maddg9ys.js} +143 -103
- package/dist/{index-0h6qd4p1.js → index-mbpxhc4w.js} +3 -4
- package/dist/index-rz8ve510.js +569 -0
- package/dist/{index-mpj0z9e0.js → index-we3nd2t0.js} +1 -1
- package/dist/{index-pe3d8jfy.js → index-whysn1wf.js} +1 -1
- package/dist/{index-52tgbhrw.js → index-xcw7hjt5.js} +28 -28
- package/dist/{index-8p0j4h4j.js → index-ym9fgxad.js} +94 -89
- package/dist/{k8s-fy8hbhkg.js → k8s-8326q0rq.js} +2 -2
- package/dist/{keepalive-d6z12s04.js → keepalive-7e9r5dvp.js} +5 -4
- package/dist/lead-3jpc7kcr.js +79 -0
- package/dist/{maintenance-7kac6g2g.js → maintenance-d3erjvcg.js} +1 -1
- package/dist/{oauth-refresh-sweep-t1xjetbh.js → oauth-refresh-sweep-0qh70988.js} +4 -3
- package/dist/{object-webhooks-6rdagg0r.js → object-webhooks-ac7v2q5p.js} +7 -7
- package/dist/{onboard-32y1cfxy.js → onboard-5yphtken.js} +4 -4
- package/dist/{opencode-adapter-enp3v31n.js → opencode-adapter-0xvyba4m.js} +8 -8
- package/dist/{otel-impl-k0tm5ptj.js → otel-impl-svqp691q.js} +2 -2
- package/dist/{pending-24zebgvs.js → pending-bn4xe5br.js} +26 -26
- package/dist/{pi-mono-adapter-yj72xxxe.js → pi-mono-adapter-763s8a3w.js} +20 -18
- package/dist/{pricing-refresh-cf25x38j.js → pricing-refresh-kfc215mf.js} +2 -2
- package/dist/{rbac-roles-0wydd22m.js → rbac-roles-3bznvkpt.js} +3 -3
- package/dist/{rbac-roles-at6crb3r.js → rbac-roles-6r4h2ghj.js} +2 -2
- package/dist/{render-v2-nvcw0jd7.js → render-v2-f3qedbpy.js} +10 -10
- package/dist/{resume-y4w0k5v3.js → resume-vcag4ann.js} +13 -13
- package/dist/{runtime-vpe43hx0.js → runtime-x0s55z2t.js} +1 -1
- package/dist/{session-access-gkyvnfye.js → session-access-nwzve8q2.js} +5 -5
- package/dist/{session-source-backfill-3w2st4m2.js → session-source-backfill-jpqfzmgz.js} +2 -2
- package/dist/{setup-axxvqtys.js → setup-d2smwaem.js} +1 -1
- package/dist/thread-buffer-8fc703jc.js +42 -0
- package/dist/{tree-visibility-y4fqvab5.js → tree-visibility-dwzc8en0.js} +2 -2
- package/dist/{user-merge-jobs-kcmwvrc6.js → user-merge-jobs-4ce7kma2.js} +3 -3
- package/dist/{virtual-modules-7d92dct1.js → virtual-modules-78a6yw71.js} +3 -3
- package/dist/{work-objects-f708e069.js → work-objects-m0w1e7q8.js} +28 -28
- package/dist/worker-3p2vq107.js +79 -0
- package/dist/{worker-follow-up-0by8wztc.js → worker-follow-up-e3t6f895.js} +25 -25
- package/dist/{x-3dtaf2r9.js → x-asbrnafg.js} +2 -2
- package/openapi.json +1795 -1623
- package/package.json +13 -12
- package/src/apps/catalog.generated.json +726 -0
- package/src/apps/definition.ts +24 -7
- package/src/apps/page-validator.ts +225 -3
- package/src/be/db.ts +38 -10
- package/src/be/mcp-proxy.ts +5 -4
- package/src/be/migrations/340_api_key_spend_cap.sql +5 -0
- package/src/be/migrations/341_user_token_expiry.sql +4 -0
- package/src/be/schedules/validate.ts +26 -0
- package/src/be/scripts/run-credential.ts +55 -1
- package/src/be/scripts/typecheck.ts +4 -4
- package/src/be/scripts/user-code-mode.ts +160 -0
- package/src/be/swarm-config-guard.ts +4 -0
- package/src/be/users.ts +48 -7
- package/src/commands/credential-outcome-report.ts +5 -2
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/provider-credentials.ts +19 -0
- package/src/commands/provider-error-class.ts +4 -1
- package/src/commands/rate-limit-outcome.ts +48 -3
- package/src/commands/runner.ts +113 -55
- package/src/commands/worktree-reaper.ts +600 -0
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/http/agents.ts +4 -0
- package/src/http/api-keys.ts +27 -3
- package/src/http/pages-public.ts +40 -4
- package/src/http/pool-keys.ts +21 -2
- package/src/http/schedules.ts +28 -3
- package/src/http/script-connection-proxy.ts +18 -6
- package/src/http/script-connections.ts +12 -4
- package/src/http/script-runs.ts +12 -3
- package/src/http/scripts.ts +2 -11
- package/src/http/tasks.ts +6 -10
- package/src/http/users.ts +1 -0
- package/src/integrations/chat-sdk/adapters.ts +29 -0
- package/src/integrations/chat-sdk/limits.ts +3 -0
- package/src/integrations/chat-sdk/rocketchat/README.md +8 -0
- package/src/integrations/chat-sdk/rocketchat/index.ts +790 -0
- package/src/integrations/chat-sdk/rocketchat/markdown.ts +210 -0
- package/src/integrations/chat-sdk/rocketchat/types.ts +249 -0
- package/src/integrations/chat-sdk/runtime.ts +11 -5
- package/src/integrations/chat-sdk/schema.ts +37 -3
- package/src/integrations/chat-sdk/status.ts +9 -0
- package/src/mcp-client/http-client.ts +3 -1
- package/src/oauth/identity-capture.ts +6 -1
- package/src/oauth/mcp-wrapper.ts +10 -3
- package/src/oauth/wrapper.ts +15 -3
- package/src/prompts/session-templates.ts +1 -0
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/dsh-adapter.ts +1 -1
- package/src/providers/pi-mono-adapter.ts +4 -2
- package/src/providers/runtime-dependencies.ts +1 -1
- package/src/rbac/legacy-policy.ts +3 -0
- package/src/rbac/permissions.ts +9 -0
- package/src/scripts-runtime/executors/native.ts +225 -67
- package/src/scripts-runtime/mcp-client.ts +2 -1
- package/src/scripts-runtime/swarm-sdk.ts +2 -1
- package/src/scripts-runtime/types/stdlib.d.ts +4 -4
- package/src/scripts-runtime/types/swarm-extension.d.ts +7 -7
- package/src/scripts-runtime/types/swarm-sdk.d.ts +4 -4
- package/src/server-user.ts +98 -0
- package/src/slack/enrich.ts +14 -11
- package/src/tests/agents-list-model-display.test.ts +23 -0
- package/src/tests/apps-spike2.test.ts +35 -0
- package/src/tests/base-prompt.test.ts +1 -0
- package/src/tests/chat-sdk-rocketchat-vendored.test.ts +67 -0
- package/src/tests/chat-sdk-status-route.test.ts +13 -1
- package/src/tests/codex-app-server.test.ts +4 -6
- package/src/tests/deploy-guard.test.ts +24 -0
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/ensure-token.test.ts +2 -2
- package/src/tests/entrypoint-repo-autoclone-args.test.ts +202 -0
- package/src/tests/fake-dns.ts +47 -0
- package/src/tests/fixtures/base-prompt-baseline.json +12 -12
- package/src/tests/latest-model-report.test.ts +138 -0
- package/src/tests/mcp-oauth-dcr-reuse.test.ts +5 -2
- package/src/tests/mcp-oauth-ensure-token.test.ts +3 -2
- package/src/tests/mcp-oauth-manual-client.test.ts +6 -1
- package/src/tests/mcp-oauth-wrapper.test.ts +20 -4
- package/src/tests/mcp-outbound-fetch-guard.test.ts +169 -0
- package/src/tests/mcp-server-ssrf.test.ts +2 -0
- package/src/tests/mcp-user-route.test.ts +10 -1
- package/src/tests/memory-search-stall.test.ts +5 -0
- package/src/tests/oauth-connection-fetch-guard.test.ts +162 -0
- package/src/tests/oauth-token-endpoint-fetch-guard.test.ts +121 -0
- package/src/tests/oauth-wrapper.test.ts +1 -2
- package/src/tests/pages-head-v2.test.ts +2 -1
- package/src/tests/script-connections-http.test.ts +8 -3
- package/src/tests/script-connections-mcp.test.ts +14 -10
- package/src/tests/script-connections-sql.test.ts +6 -2
- package/src/tests/script-connections.test.ts +4 -0
- package/src/tests/slack-thread-participants.test.ts +14 -3
- package/src/tests/spend-cap-credentials.test.ts +34 -0
- package/src/tests/spend-cap-outcome.test.ts +67 -0
- package/src/tests/subscription-first.test.ts +119 -0
- package/src/tests/worktree-reaper.test.ts +424 -0
- package/src/tools/get-task-details.ts +247 -5
- package/src/tools/schedules/patch-schedule.ts +26 -1
- package/src/tools/schedules/update-schedule.ts +28 -2
- package/src/tools/script-common.ts +37 -22
- package/src/tools/script-query-types.ts +1 -1
- package/src/tools/script-run.ts +1 -1
- package/src/tools/script-search.ts +12 -10
- package/src/tools/utils.ts +7 -1
- package/src/utils/credentials.ts +36 -1
- package/src/utils/egress-guard.ts +40 -10
- package/src/utils/error-tracker.ts +17 -0
- package/templates/skills/apps/SKILL.md +191 -2
- package/templates/skills/apps/content.md +191 -2
- package/templates/skills/boards-and-sheets/content.md +11 -0
- package/templates/skills/chat-sdk/content.md +2 -2
- package/templates/skills/pages/content.md +11 -0
- package/templates/skills/swarm-docs/content.md +4 -0
- package/templates/skills/swarm-scripts/SKILL.md +1 -0
- package/templates/skills/swarm-scripts/content.md +1 -0
- package/templates/workflows/ralph-loop/content.md +6 -6
- package/dist/acp-adapter-cn53011z.js +0 -17
- package/dist/cli-pr0eze3x.js +0 -149
- package/dist/core-0fqtbrxa.js +0 -42
- package/dist/fx-adapter-k6w3jvz9.js +0 -20
- package/dist/grok-adapter-4q5tssw0.js +0 -20
- package/dist/handlers-qxgfvvsf.js +0 -41
- package/dist/heartbeat-6tr2w2da.js +0 -50
- package/dist/index-0mcxjdsa.js +0 -44
- package/dist/index-dz4q23ag.js +0 -40
- package/dist/index-s175jckx.js +0 -39
- package/dist/lead-p3hx7h35.js +0 -79
- package/dist/thread-buffer-rwa7d4dx.js +0 -42
- package/dist/worker-8rg9gz74.js +0 -79
- /package/dist/{cli-m4ejz4nj.js → cli-cah298e5.js} +0 -0
package/src/oauth/wrapper.ts
CHANGED
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
storeOAuthTokens,
|
|
8
8
|
updateOAuthTokensAfterRefresh,
|
|
9
9
|
} from "../be/db-queries/oauth";
|
|
10
|
+
import { createSsrfGuardedFetch } from "../utils/egress-guard";
|
|
11
|
+
import { publicEndpointSsrfOptions } from "./mcp-wrapper";
|
|
10
12
|
|
|
11
13
|
// ─── Types ───────────────────────────────────────────────────────────────────
|
|
12
14
|
|
|
@@ -145,6 +147,16 @@ function tokenRequestInit(
|
|
|
145
147
|
return { headers, body: new URLSearchParams(bodyParams).toString() };
|
|
146
148
|
}
|
|
147
149
|
|
|
150
|
+
/**
|
|
151
|
+
* The token endpoint receives the client secret plus the code or refresh
|
|
152
|
+
* token, so it goes through the guarded fetch: a public name that resolves to
|
|
153
|
+
* a private address is refused, and each redirect hop is re-checked. Built per
|
|
154
|
+
* call because the SSRF options read the environment.
|
|
155
|
+
*/
|
|
156
|
+
function tokenEndpointFetch(): typeof fetch {
|
|
157
|
+
return createSsrfGuardedFetch(publicEndpointSsrfOptions());
|
|
158
|
+
}
|
|
159
|
+
|
|
148
160
|
export interface OAuthTokenResponse {
|
|
149
161
|
accessToken: string;
|
|
150
162
|
refreshToken?: string;
|
|
@@ -165,7 +177,7 @@ export async function exchangeAuthorizationCode(
|
|
|
165
177
|
config: OAuthProviderConfig,
|
|
166
178
|
params: { code: string; codeVerifier: string; redirectUri: string },
|
|
167
179
|
): Promise<OAuthTokenResponse> {
|
|
168
|
-
const response = await
|
|
180
|
+
const response = await tokenEndpointFetch()(config.tokenUrl, {
|
|
169
181
|
method: "POST",
|
|
170
182
|
...tokenRequestInit(config, {
|
|
171
183
|
grant_type: "authorization_code",
|
|
@@ -242,7 +254,7 @@ export async function refreshTokenGrant(
|
|
|
242
254
|
config: OAuthProviderConfig,
|
|
243
255
|
refreshToken: string,
|
|
244
256
|
): Promise<OAuthTokenResponse> {
|
|
245
|
-
const response = await
|
|
257
|
+
const response = await tokenEndpointFetch()(config.tokenUrl, {
|
|
246
258
|
method: "POST",
|
|
247
259
|
...tokenRequestInit(config, {
|
|
248
260
|
grant_type: "refresh_token",
|
|
@@ -297,7 +309,7 @@ export async function performTokenRefreshRequest(
|
|
|
297
309
|
scope?: string;
|
|
298
310
|
expiresAt: string | null;
|
|
299
311
|
}> {
|
|
300
|
-
const response = await
|
|
312
|
+
const response = await tokenEndpointFetch()(config.tokenUrl, {
|
|
301
313
|
method: "POST",
|
|
302
314
|
...tokenRequestInit(config, {
|
|
303
315
|
grant_type: "refresh_token",
|
|
@@ -181,6 +181,7 @@ registerTemplate({
|
|
|
181
181
|
## Workspace
|
|
182
182
|
|
|
183
183
|
\`/workspace/personal/\` is yours. \`get-repos\` returns where a repository is cloned.
|
|
184
|
+
Worktrees without unsaved work are removed after your task. To keep one: \`git worktree lock <path>\`.
|
|
184
185
|
Your profile lives in the database. Edit it with \`update-profile\`: \`soulMd\`, \`identityMd\`, \`heartbeatMd\`, \`setupScript\`, \`toolsMd\`. The files in \`/workspace/\` are mirrors.
|
|
185
186
|
Your setup script runs at every container start.
|
|
186
187
|
\`/workspace/TOOLS.md\` holds your environment notes: repos, hosts, services, tool quirks. Read it when a task touches a repo, host, or service you have not used this session. Update it with \`update-profile\` \`toolsMd\`.
|
|
@@ -427,7 +427,7 @@ const copilotTargetProfile: AcpTargetProfile = {
|
|
|
427
427
|
},
|
|
428
428
|
};
|
|
429
429
|
|
|
430
|
-
/** Qwen Code's `--auth-type` choices (0.27.
|
|
430
|
+
/** Qwen Code's `--auth-type` choices (0.27.3). `qwen-oauth` and `qwen-subscription` need an interactive sign-in, so they are left out. */
|
|
431
431
|
const QWEN_AUTH_TYPES = ["openai", "openai-responses", "anthropic", "gemini", "vertex-ai"] as const;
|
|
432
432
|
|
|
433
433
|
// Qwen Code is a Gemini CLI fork: QWEN_SYSTEM_MD replaces its built-in prompt
|
|
@@ -480,7 +480,7 @@ const qwenTargetProfile: AcpTargetProfile = {
|
|
|
480
480
|
* Kiro CLI reads its prompt from a Kiro agent config, not from a flag or an
|
|
481
481
|
* env var, so the swarm system prompt is not injected (as with OpenCode).
|
|
482
482
|
* Kiro advertises no ACP config options (checked on 2.29.1), so the model
|
|
483
|
-
* rides on argv as `--model`, which `kiro-cli acp` still accepts in 3.
|
|
483
|
+
* rides on argv as `--model`, which `kiro-cli acp` still accepts in 3.3.0.
|
|
484
484
|
*/
|
|
485
485
|
const kiroTargetProfile: AcpTargetProfile = {
|
|
486
486
|
target: "kiro",
|
|
@@ -45,7 +45,7 @@ import type {
|
|
|
45
45
|
* default; the image installs exactly this version and the per-task settings
|
|
46
46
|
* set `amp.updates.mode: "disabled"`. Bump it deliberately, with a live run.
|
|
47
47
|
*/
|
|
48
|
-
export const AMP_PACKAGE = "@ampcode/cli@0.0.
|
|
48
|
+
export const AMP_PACKAGE = "@ampcode/cli@0.0.1794657642-gc1e41b";
|
|
49
49
|
|
|
50
50
|
/** MCP server name. Amp exposes its tools as `agent_swarm` / `store_progress` (dashes become underscores). */
|
|
51
51
|
const AMP_MCP_SERVER_NAME = "agent-swarm";
|
|
@@ -37,7 +37,7 @@ import type {
|
|
|
37
37
|
} from "./types";
|
|
38
38
|
|
|
39
39
|
// npm's `latest` is older and lacks the JSON/stdin contract used here.
|
|
40
|
-
export const DSH_PACKAGE = "@deepseek-ai/dsh@0.2.2-rc.
|
|
40
|
+
export const DSH_PACKAGE = "@deepseek-ai/dsh@0.2.2-rc.3";
|
|
41
41
|
|
|
42
42
|
export function checkDshCredentials(env: Record<string, string | undefined>): CredStatus {
|
|
43
43
|
return env.DEEPSEEK_API_KEY?.trim() || env.OPENROUTER_API_KEY?.trim()
|
|
@@ -1018,10 +1018,12 @@ function resolveModelInner(
|
|
|
1018
1018
|
return modelRuntime?.getModel(provider, modelId);
|
|
1019
1019
|
}
|
|
1020
1020
|
|
|
1021
|
-
// Try as a full model ID with common providers
|
|
1021
|
+
// Try as a full model ID with common providers. getModel returns undefined
|
|
1022
|
+
// for an unknown id, so keep looking instead of returning the first miss.
|
|
1022
1023
|
for (const provider of ["anthropic", "openai", "google"]) {
|
|
1023
1024
|
try {
|
|
1024
|
-
|
|
1025
|
+
const model = getModel(provider as "anthropic", modelStr as never);
|
|
1026
|
+
if (model) return model;
|
|
1025
1027
|
} catch {}
|
|
1026
1028
|
}
|
|
1027
1029
|
|
|
@@ -94,7 +94,7 @@ export async function validateProviderDependencies(
|
|
|
94
94
|
case "dsh":
|
|
95
95
|
requireExecutable(
|
|
96
96
|
env.DSH_BINARY || "dsh",
|
|
97
|
-
"Use worker-full, install @deepseek-ai/dsh@0.2.2-rc.
|
|
97
|
+
"Use worker-full, install @deepseek-ai/dsh@0.2.2-rc.3, or set DSH_BINARY to a trusted executable.",
|
|
98
98
|
);
|
|
99
99
|
return;
|
|
100
100
|
case "amp":
|
|
@@ -356,12 +356,15 @@ export const LEGACY_POLICY = {
|
|
|
356
356
|
"script.global.write": leadOnly,
|
|
357
357
|
"script.global.delete": leadOnly,
|
|
358
358
|
"script.search": anyAuthenticated,
|
|
359
|
+
"script.run": anyAuthenticated,
|
|
359
360
|
"script.api.read.secrets": leadOnly,
|
|
360
361
|
"script.api.create": leadOnly,
|
|
361
362
|
"script.api.update": leadOnly,
|
|
362
363
|
"script.api.rotate": leadOnly,
|
|
363
364
|
"script.api.delete": leadOnly,
|
|
364
365
|
"schedule.deferral.update.any": leadOrResourceOwner,
|
|
366
|
+
// A schedule fires as its creator, so only the creator or a lead picks what it runs.
|
|
367
|
+
"schedule.target.update.any": leadOrResourceOwner,
|
|
365
368
|
// Pool writes pick the image that receives a runtime token, so only humans
|
|
366
369
|
// may make them. The lead may only place agents into operator-made pools.
|
|
367
370
|
"runtime_pool.write": operatorOrUser,
|
package/src/rbac/permissions.ts
CHANGED
|
@@ -386,6 +386,10 @@ export const PERMISSIONS = {
|
|
|
386
386
|
description: "Search reusable scripts visible to the caller.",
|
|
387
387
|
namespace: "script",
|
|
388
388
|
},
|
|
389
|
+
"script.run": {
|
|
390
|
+
description: "Run a global or inline script as yourself from the user MCP.",
|
|
391
|
+
namespace: "script",
|
|
392
|
+
},
|
|
389
393
|
"script.api.read.secrets": {
|
|
390
394
|
description: "Reveal an external script API endpoint bearer token.",
|
|
391
395
|
namespace: "script",
|
|
@@ -410,6 +414,11 @@ export const PERMISSIONS = {
|
|
|
410
414
|
description: "Change a defer-task schedule the caller did not create.",
|
|
411
415
|
namespace: "schedule",
|
|
412
416
|
},
|
|
417
|
+
"schedule.target.update.any": {
|
|
418
|
+
description:
|
|
419
|
+
"Change what a schedule the caller did not create runs (its target, task template, workflow, script, script args or params).",
|
|
420
|
+
namespace: "schedule",
|
|
421
|
+
},
|
|
413
422
|
"runtime_pool.write": {
|
|
414
423
|
description: "Create, update, or delete runtime pools (image, provider kind, placement).",
|
|
415
424
|
namespace: "runtime_pool",
|
|
@@ -247,27 +247,203 @@ async function linkOrWriteBareImportShims(baseTmpDir: string, tmpdir: string): P
|
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
250
|
+
type HarnessProcess = Bun.Subprocess<"pipe", "pipe", "pipe">;
|
|
251
|
+
|
|
252
|
+
/** Everything a harness spawn depends on, apart from its run dir. */
|
|
253
|
+
interface HarnessSpec {
|
|
254
|
+
harnessPath: string;
|
|
255
|
+
baseTmpDir: string;
|
|
256
|
+
runAs: SandboxIdentity | undefined;
|
|
257
|
+
hostValidatedArgs: boolean;
|
|
258
|
+
resources: ExecutorInput["resources"];
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function harnessRunPaths(tmpdir: string) {
|
|
262
|
+
return {
|
|
263
|
+
argsFile: `${tmpdir}/args.json`,
|
|
264
|
+
sourceFile: `${tmpdir}/user-module/user-script.ts`,
|
|
265
|
+
resultFile: `${tmpdir}/result.json`,
|
|
266
|
+
errorFile: `${tmpdir}/error.json`,
|
|
267
|
+
startedFile: `${tmpdir}/started.marker`,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function harnessEnvFor(spec: HarnessSpec, tmpdir: string): Record<string, string> {
|
|
272
|
+
const paths = harnessRunPaths(tmpdir);
|
|
273
|
+
return {
|
|
274
|
+
PATH: process.env.PATH ?? "/usr/bin:/bin",
|
|
275
|
+
// The dropped identity cannot use the API's HOME.
|
|
276
|
+
HOME: spec.runAs ? tmpdir : (process.env.HOME ?? "/tmp"),
|
|
277
|
+
LANG: process.env.LANG ?? "C.UTF-8",
|
|
278
|
+
LC_ALL: process.env.LC_ALL ?? "C.UTF-8",
|
|
279
|
+
TMPDIR: tmpdir,
|
|
280
|
+
SWARM_SCRIPT_TMPDIR: tmpdir,
|
|
281
|
+
SWARM_SCRIPT_ARGS_FILE: paths.argsFile,
|
|
282
|
+
SWARM_SCRIPT_SOURCE_FILE: paths.sourceFile,
|
|
283
|
+
SWARM_SCRIPT_RESULT_FILE: paths.resultFile,
|
|
284
|
+
SWARM_SCRIPT_ERROR_FILE: paths.errorFile,
|
|
285
|
+
SWARM_SCRIPT_STARTED_FILE: paths.startedFile,
|
|
286
|
+
...(spec.hostValidatedArgs ? { SWARM_SCRIPT_HOST_VALIDATED_ARGS: "1" } : {}),
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function spawnHarness(spec: HarnessSpec, tmpdir: string): HarnessProcess {
|
|
291
|
+
const harnessEnv = harnessEnvFor(spec, tmpdir);
|
|
292
|
+
const limits = {
|
|
293
|
+
virtualMemoryMb: spec.resources.memoryMb,
|
|
294
|
+
cpuTimeSec: spec.resources.cpuTimeSec,
|
|
295
|
+
maxProcs: spec.resources.maxProcs,
|
|
296
|
+
maxFileKb: Math.floor(spec.resources.maxFileBytes / 1024),
|
|
297
|
+
maxFdCount: spec.resources.maxFdCount,
|
|
298
|
+
};
|
|
299
|
+
return registerProcessGroup(
|
|
300
|
+
Bun.spawn(
|
|
301
|
+
buildSandboxedCommand(
|
|
302
|
+
["bun", "run", spec.harnessPath],
|
|
303
|
+
harnessEnv,
|
|
304
|
+
limits,
|
|
305
|
+
"inline",
|
|
306
|
+
spec.runAs,
|
|
307
|
+
),
|
|
308
|
+
{
|
|
309
|
+
// On POSIX, Bun.spawn only needs PATH itself to locate the `sh`
|
|
310
|
+
// binary for argv[0] — the sandboxed command's `env -i` prelude is
|
|
311
|
+
// what actually scrubs the child's environment down to `harnessEnv`
|
|
312
|
+
// above. On win32 there is no such prelude, so `sandboxSpawnEnv`
|
|
313
|
+
// passes `harnessEnv` through directly instead — see
|
|
314
|
+
// `buildSandboxedCommand`'s win32 doc comment.
|
|
315
|
+
env: sandboxSpawnEnv(harnessEnv),
|
|
316
|
+
cwd: tmpdir,
|
|
317
|
+
detached: detachedProcessGroup,
|
|
318
|
+
stdin: "pipe",
|
|
319
|
+
stdout: "pipe",
|
|
320
|
+
stderr: "pipe",
|
|
321
|
+
},
|
|
322
|
+
),
|
|
268
323
|
);
|
|
269
324
|
}
|
|
270
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Warm harness pool. A harness spends most of a short run loading its own
|
|
328
|
+
* modules (ctx, SDK, zod) before it reads the config payload from stdin, and
|
|
329
|
+
* none of that depends on the run. So after each spawn the executor starts
|
|
330
|
+
* one spare harness with the same spec in a fresh run dir; it loads and then
|
|
331
|
+
* blocks on stdin. The next run with that spec writes its args and source
|
|
332
|
+
* into the spare's run dir and sends the payload, skipping spawn and module
|
|
333
|
+
* load. The script itself still runs once per call, in its own process, with
|
|
334
|
+
* the same env, limits and identity, so outputs and side effects are those of
|
|
335
|
+
* a cold run. A spare holds no credentials (they arrive on stdin), is
|
|
336
|
+
* single-use, and is stopped after WARM_IDLE_MS unused.
|
|
337
|
+
*
|
|
338
|
+
* The user module dir is created only after the spare has started: Bun
|
|
339
|
+
* snapshots the cwd listing at startup, and a subdir created later is
|
|
340
|
+
* resolved from disk (see the note above `userModulePath` in eval-harness.ts).
|
|
341
|
+
*
|
|
342
|
+
* Under a dropped identity the spare's run dir stays owned by the API until a
|
|
343
|
+
* run takes it. Every script shares that identity, so a dir it owned while
|
|
344
|
+
* idle could hold links planted by another script, and the API's writes and
|
|
345
|
+
* chowns below would follow them. The harness writes nothing before it reads
|
|
346
|
+
* stdin, so the spare needs no write access while it waits. A taken spare's
|
|
347
|
+
* dir gets the cold path's order: write as the API, then chown.
|
|
348
|
+
*/
|
|
349
|
+
interface WarmHarness {
|
|
350
|
+
key: string;
|
|
351
|
+
tmpdir: string;
|
|
352
|
+
proc: HarnessProcess;
|
|
353
|
+
idleTimer: ReturnType<typeof setTimeout>;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const WARM_IDLE_MS = 30_000;
|
|
357
|
+
const MAX_WARM_SPECS = 4;
|
|
358
|
+
const warmHarnesses = new Map<string, WarmHarness>();
|
|
359
|
+
const warmingSpecs = new Set<string>();
|
|
360
|
+
|
|
361
|
+
function harnessSpecKey(spec: HarnessSpec): string {
|
|
362
|
+
return JSON.stringify([
|
|
363
|
+
spec.harnessPath,
|
|
364
|
+
spec.baseTmpDir,
|
|
365
|
+
spec.runAs ?? null,
|
|
366
|
+
spec.hostValidatedArgs,
|
|
367
|
+
spec.resources.memoryMb,
|
|
368
|
+
spec.resources.cpuTimeSec,
|
|
369
|
+
spec.resources.maxProcs,
|
|
370
|
+
spec.resources.maxFileBytes,
|
|
371
|
+
spec.resources.maxFdCount,
|
|
372
|
+
process.env.PATH ?? null,
|
|
373
|
+
process.env.HOME ?? null,
|
|
374
|
+
process.env.LANG ?? null,
|
|
375
|
+
process.env.LC_ALL ?? null,
|
|
376
|
+
]);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function harnessAlive(proc: HarnessProcess): boolean {
|
|
380
|
+
return proc.exitCode === null && proc.signalCode === null && !proc.killed;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function discardWarmHarness(entry: WarmHarness): void {
|
|
384
|
+
clearTimeout(entry.idleTimer);
|
|
385
|
+
if (warmHarnesses.get(entry.key) === entry) warmHarnesses.delete(entry.key);
|
|
386
|
+
void terminateProcessGroup(entry.proc.pid)
|
|
387
|
+
.catch(() => {})
|
|
388
|
+
.finally(() => rm(entry.tmpdir, { recursive: true, force: true }).catch(() => {}));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** Removes and returns the spare for `key` when it is still waiting on stdin. */
|
|
392
|
+
function takeWarmHarness(key: string): WarmHarness | undefined {
|
|
393
|
+
const entry = warmHarnesses.get(key);
|
|
394
|
+
if (!entry) return undefined;
|
|
395
|
+
warmHarnesses.delete(key);
|
|
396
|
+
clearTimeout(entry.idleTimer);
|
|
397
|
+
if (!harnessAlive(entry.proc)) {
|
|
398
|
+
discardWarmHarness(entry);
|
|
399
|
+
return undefined;
|
|
400
|
+
}
|
|
401
|
+
entry.proc.ref();
|
|
402
|
+
return entry;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
async function startWarmHarness(key: string, spec: HarnessSpec): Promise<void> {
|
|
406
|
+
if (process.platform === "win32") return;
|
|
407
|
+
if (warmHarnesses.has(key) || warmingSpecs.has(key)) return;
|
|
408
|
+
warmingSpecs.add(key);
|
|
409
|
+
const tmpdir = `${spec.baseTmpDir}/swarm-script-${crypto.randomUUID()}`;
|
|
410
|
+
let started = false;
|
|
411
|
+
try {
|
|
412
|
+
// The run dir stays owned by the API until a run takes the spare (see
|
|
413
|
+
// above): no chown here.
|
|
414
|
+
await mkdir(tmpdir, { recursive: true, mode: 0o755 });
|
|
415
|
+
await linkOrWriteBareImportShims(spec.baseTmpDir, tmpdir);
|
|
416
|
+
if (warmHarnesses.has(key)) return;
|
|
417
|
+
const proc = spawnHarness(spec, tmpdir);
|
|
418
|
+
// A spare must not keep the API (or a CLI / test process) alive.
|
|
419
|
+
proc.unref();
|
|
420
|
+
started = true;
|
|
421
|
+
const entry: WarmHarness = {
|
|
422
|
+
key,
|
|
423
|
+
tmpdir,
|
|
424
|
+
proc,
|
|
425
|
+
idleTimer: setTimeout(() => discardWarmHarness(entry), WARM_IDLE_MS),
|
|
426
|
+
};
|
|
427
|
+
entry.idleTimer.unref?.();
|
|
428
|
+
if (warmHarnesses.size >= MAX_WARM_SPECS) {
|
|
429
|
+
const oldest = warmHarnesses.values().next().value;
|
|
430
|
+
if (oldest) discardWarmHarness(oldest);
|
|
431
|
+
}
|
|
432
|
+
warmHarnesses.set(key, entry);
|
|
433
|
+
void proc.exited.then(
|
|
434
|
+
() => {
|
|
435
|
+
if (warmHarnesses.get(key) === entry) discardWarmHarness(entry);
|
|
436
|
+
},
|
|
437
|
+
() => {},
|
|
438
|
+
);
|
|
439
|
+
} catch {
|
|
440
|
+
// Best-effort: the next run spawns cold.
|
|
441
|
+
} finally {
|
|
442
|
+
warmingSpecs.delete(key);
|
|
443
|
+
if (!started) await rm(tmpdir, { recursive: true, force: true }).catch(() => {});
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
271
447
|
export class NativeScriptExecutor implements ScriptExecutor {
|
|
272
448
|
readonly name = "native";
|
|
273
449
|
|
|
@@ -278,24 +454,24 @@ export class NativeScriptExecutor implements ScriptExecutor {
|
|
|
278
454
|
|
|
279
455
|
const start = Date.now();
|
|
280
456
|
const baseTmpDir = process.env.TMPDIR ?? (process.platform === "win32" ? osTmpdir() : "/tmp");
|
|
281
|
-
const tmpdir = `${baseTmpDir}/swarm-script-${crypto.randomUUID()}`;
|
|
282
|
-
await mkdir(`${tmpdir}/user-module`, { recursive: true });
|
|
283
|
-
|
|
284
|
-
const argsFile = `${tmpdir}/args.json`;
|
|
285
|
-
const sourceFile = `${tmpdir}/user-module/user-script.ts`;
|
|
286
|
-
const resultFile = `${tmpdir}/result.json`;
|
|
287
|
-
const errorFile = `${tmpdir}/error.json`;
|
|
288
|
-
const startedFile = `${tmpdir}/started.marker`;
|
|
289
457
|
const runAs = resolveSandboxIdentity();
|
|
290
458
|
// In compiled binary mode, import.meta.url points into /$bunfs/ which spawned
|
|
291
459
|
// subprocesses cannot access. Use the pre-built bundle from real filesystem instead.
|
|
292
460
|
const harnessPath = process.env.SCRIPT_RUNTIME_DIR
|
|
293
461
|
? `${process.env.SCRIPT_RUNTIME_DIR}/eval-harness.bundle.js`
|
|
294
462
|
: fileURLToPath(new URL("../eval-harness.ts", import.meta.url));
|
|
463
|
+
const spec: HarnessSpec = {
|
|
464
|
+
harnessPath,
|
|
465
|
+
baseTmpDir,
|
|
466
|
+
runAs,
|
|
467
|
+
hostValidatedArgs: Boolean(input.hostValidatedArgs),
|
|
468
|
+
resources: input.resources,
|
|
469
|
+
};
|
|
470
|
+
const specKey = harnessSpecKey(spec);
|
|
295
471
|
let timedOut = false;
|
|
296
472
|
let killed = input.signal?.aborted ?? false;
|
|
297
473
|
let removeAbortListener: (() => void) | undefined;
|
|
298
|
-
let proc:
|
|
474
|
+
let proc: HarnessProcess | undefined;
|
|
299
475
|
|
|
300
476
|
const killedOutput = (): ExecutorOutput => ({
|
|
301
477
|
result: undefined,
|
|
@@ -307,9 +483,16 @@ export class NativeScriptExecutor implements ScriptExecutor {
|
|
|
307
483
|
error: "killed",
|
|
308
484
|
});
|
|
309
485
|
|
|
310
|
-
|
|
311
|
-
|
|
486
|
+
if (killed) return killedOutput();
|
|
487
|
+
|
|
488
|
+
const warm = takeWarmHarness(specKey);
|
|
489
|
+
const tmpdir = warm?.tmpdir ?? `${baseTmpDir}/swarm-script-${crypto.randomUUID()}`;
|
|
490
|
+
const { argsFile, sourceFile, resultFile, errorFile, startedFile } = harnessRunPaths(tmpdir);
|
|
491
|
+
// A taken spare is this run's process from here on: an abort or error
|
|
492
|
+
// below terminates it and removes its run dir like a cold child's.
|
|
493
|
+
if (warm) proc = warm.proc;
|
|
312
494
|
|
|
495
|
+
try {
|
|
313
496
|
// Listen before the first await: an abort during the file writes below
|
|
314
497
|
// must stop the spawn, not land between the writes and the listener.
|
|
315
498
|
const onExternalAbort = () => {
|
|
@@ -319,11 +502,14 @@ export class NativeScriptExecutor implements ScriptExecutor {
|
|
|
319
502
|
input.signal?.addEventListener("abort", onExternalAbort, { once: true });
|
|
320
503
|
removeAbortListener = () => input.signal?.removeEventListener("abort", onExternalAbort);
|
|
321
504
|
|
|
505
|
+
// A spare's run dir already has its node_modules link, and is still
|
|
506
|
+
// owned by the API: write as the API first, then chown, on both paths.
|
|
507
|
+
await mkdir(`${tmpdir}/user-module`, { recursive: true });
|
|
322
508
|
await Promise.all([
|
|
323
509
|
Bun.write(argsFile, JSON.stringify(input.args ?? null)),
|
|
324
510
|
Bun.write(sourceFile, input.source),
|
|
325
|
-
linkOrWriteBareImportShims(baseTmpDir, tmpdir),
|
|
326
511
|
]);
|
|
512
|
+
if (!warm) await linkOrWriteBareImportShims(baseTmpDir, tmpdir);
|
|
327
513
|
if (runAs) {
|
|
328
514
|
// The child writes its result and marker files into the run dir.
|
|
329
515
|
await Promise.all(
|
|
@@ -341,46 +527,18 @@ export class NativeScriptExecutor implements ScriptExecutor {
|
|
|
341
527
|
if (proc) void terminateProcessGroup(proc.pid);
|
|
342
528
|
}, input.resources.wallClockMs);
|
|
343
529
|
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
LANG: process.env.LANG ?? "C.UTF-8",
|
|
349
|
-
LC_ALL: process.env.LC_ALL ?? "C.UTF-8",
|
|
350
|
-
TMPDIR: tmpdir,
|
|
351
|
-
SWARM_SCRIPT_TMPDIR: tmpdir,
|
|
352
|
-
SWARM_SCRIPT_ARGS_FILE: argsFile,
|
|
353
|
-
SWARM_SCRIPT_SOURCE_FILE: sourceFile,
|
|
354
|
-
SWARM_SCRIPT_RESULT_FILE: resultFile,
|
|
355
|
-
SWARM_SCRIPT_ERROR_FILE: errorFile,
|
|
356
|
-
SWARM_SCRIPT_STARTED_FILE: startedFile,
|
|
357
|
-
...(input.hostValidatedArgs ? { SWARM_SCRIPT_HOST_VALIDATED_ARGS: "1" } : {}),
|
|
358
|
-
};
|
|
530
|
+
const child = proc ?? spawnHarness(spec, tmpdir);
|
|
531
|
+
proc = child;
|
|
532
|
+
// Load the next run's harness while this one runs.
|
|
533
|
+
void startWarmHarness(specKey, spec);
|
|
359
534
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
// On POSIX, Bun.spawn only needs PATH itself to locate the `sh`
|
|
363
|
-
// binary for argv[0] — the sandboxed command's `env -i` prelude is
|
|
364
|
-
// what actually scrubs the child's environment down to `harnessEnv`
|
|
365
|
-
// above. On win32 there is no such prelude, so `sandboxSpawnEnv`
|
|
366
|
-
// passes `harnessEnv` through directly instead — see
|
|
367
|
-
// `buildSandboxedCommand`'s win32 doc comment.
|
|
368
|
-
env: sandboxSpawnEnv(harnessEnv),
|
|
369
|
-
cwd: tmpdir,
|
|
370
|
-
detached: detachedProcessGroup,
|
|
371
|
-
stdin: "pipe",
|
|
372
|
-
stdout: "pipe",
|
|
373
|
-
stderr: "pipe",
|
|
374
|
-
}),
|
|
375
|
-
);
|
|
376
|
-
|
|
377
|
-
proc.stdin.write(JSON.stringify(input.configPayload));
|
|
378
|
-
proc.stdin.end();
|
|
535
|
+
child.stdin.write(JSON.stringify(input.configPayload));
|
|
536
|
+
child.stdin.end();
|
|
379
537
|
|
|
380
538
|
const [stdout, stderr, exitCode] = await Promise.all([
|
|
381
|
-
readStreamCapped(
|
|
382
|
-
readStreamCapped(
|
|
383
|
-
|
|
539
|
+
readStreamCapped(child.stdout, input.resources.maxStdoutBytes),
|
|
540
|
+
readStreamCapped(child.stderr, input.resources.maxStdoutBytes),
|
|
541
|
+
child.exited.catch(() => (timedOut ? 124 : 1)),
|
|
384
542
|
]).finally(() => clearTimeout(timeout));
|
|
385
543
|
// The child owns the run dir: read its files only through the checked reader.
|
|
386
544
|
const runDirCheck: RunDirFileCheck = {
|
|
@@ -35,7 +35,8 @@ function methodNames(
|
|
|
35
35
|
function headers(config: SwarmConfig): Record<string, string> {
|
|
36
36
|
return {
|
|
37
37
|
Authorization: `Bearer ${Redacted.value(config.apiKey)}`,
|
|
38
|
-
|
|
38
|
+
// A user-scoped run has no agent; its user token must not name one.
|
|
39
|
+
...(Redacted.value(config.agentId) ? { "X-Agent-ID": Redacted.value(config.agentId) } : {}),
|
|
39
40
|
// Audit-only header: X-Source-Task-Id would also rescope kv, parent send-task, etc.
|
|
40
41
|
...(config.auditSourceTaskId
|
|
41
42
|
? { "X-Audit-Source-Task-Id": Redacted.value(config.auditSourceTaskId) }
|
|
@@ -23,7 +23,8 @@ type BridgeRequest = {
|
|
|
23
23
|
function headers(config: SwarmConfig): Record<string, string> {
|
|
24
24
|
return {
|
|
25
25
|
Authorization: `Bearer ${Redacted.value(config.apiKey)}`,
|
|
26
|
-
|
|
26
|
+
// A user-scoped run has no agent; its user token must not name one.
|
|
27
|
+
...(Redacted.value(config.agentId) ? { "X-Agent-ID": Redacted.value(config.agentId) } : {}),
|
|
27
28
|
// Per-boot identity of the invoking worker process (system context, not
|
|
28
29
|
// script input) — work-acquisition endpoints gate on it in multi-runtime
|
|
29
30
|
// mode.
|
|
@@ -847,25 +847,25 @@ declare module "swarm-sdk" {
|
|
|
847
847
|
// --- write: chat sdk ---
|
|
848
848
|
chat_reply(args: { text?: string; card?: unknown }): Promise<unknown>;
|
|
849
849
|
chat_post(args: {
|
|
850
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
850
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
851
851
|
threadId?: string;
|
|
852
852
|
channelId?: string;
|
|
853
853
|
text?: string;
|
|
854
854
|
card?: unknown;
|
|
855
855
|
}): Promise<unknown>;
|
|
856
856
|
chat_openDm(args: {
|
|
857
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
857
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
858
858
|
userId: string;
|
|
859
859
|
}): Promise<unknown>;
|
|
860
860
|
chat_registerChannel(args: {
|
|
861
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
861
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
862
862
|
channelId: string;
|
|
863
863
|
agentId?: string;
|
|
864
864
|
workflowId?: string;
|
|
865
865
|
name?: string;
|
|
866
866
|
}): Promise<unknown>;
|
|
867
867
|
chat_unregisterChannel(args: {
|
|
868
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
868
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
869
869
|
channelId: string;
|
|
870
870
|
}): Promise<unknown>;
|
|
871
871
|
|
|
@@ -118,13 +118,13 @@ declare module "swarm-extension" {
|
|
|
118
118
|
sourceAgentId?: string | undefined;
|
|
119
119
|
role?: string | undefined;
|
|
120
120
|
harnessProvider?:
|
|
121
|
+
| "codex"
|
|
121
122
|
| "pi"
|
|
123
|
+
| "opencode"
|
|
122
124
|
| "claude"
|
|
123
125
|
| "claude-managed"
|
|
124
|
-
| "codex"
|
|
125
126
|
| "grok"
|
|
126
127
|
| "fx"
|
|
127
|
-
| "opencode"
|
|
128
128
|
| "dsh"
|
|
129
129
|
| "cursor"
|
|
130
130
|
| "amp"
|
|
@@ -286,13 +286,13 @@ declare module "swarm-extension" {
|
|
|
286
286
|
requestedByUserId?: string | undefined;
|
|
287
287
|
swarmVersion?: string | undefined;
|
|
288
288
|
provider?:
|
|
289
|
+
| "codex"
|
|
289
290
|
| "pi"
|
|
291
|
+
| "opencode"
|
|
290
292
|
| "claude"
|
|
291
293
|
| "claude-managed"
|
|
292
|
-
| "codex"
|
|
293
294
|
| "grok"
|
|
294
295
|
| "fx"
|
|
295
|
-
| "opencode"
|
|
296
296
|
| "dsh"
|
|
297
297
|
| "cursor"
|
|
298
298
|
| "amp"
|
|
@@ -309,13 +309,13 @@ declare module "swarm-extension" {
|
|
|
309
309
|
sourceAgentId?: string | undefined;
|
|
310
310
|
role?: string | undefined;
|
|
311
311
|
harnessProvider?:
|
|
312
|
+
| "codex"
|
|
312
313
|
| "pi"
|
|
314
|
+
| "opencode"
|
|
313
315
|
| "claude"
|
|
314
316
|
| "claude-managed"
|
|
315
|
-
| "codex"
|
|
316
317
|
| "grok"
|
|
317
318
|
| "fx"
|
|
318
|
-
| "opencode"
|
|
319
319
|
| "dsh"
|
|
320
320
|
| "cursor"
|
|
321
321
|
| "amp"
|
|
@@ -353,7 +353,7 @@ declare module "swarm-extension" {
|
|
|
353
353
|
sourceTaskId: string | undefined;
|
|
354
354
|
auditSourceTaskId: string | undefined;
|
|
355
355
|
contextKey: string | undefined;
|
|
356
|
-
callOrigin: "
|
|
356
|
+
callOrigin: "native" | "mcp" | "extension" | "script-sdk";
|
|
357
357
|
harness?: string | undefined;
|
|
358
358
|
};
|
|
359
359
|
|
|
@@ -805,25 +805,25 @@ declare module "swarm-sdk" {
|
|
|
805
805
|
// --- write: chat sdk ---
|
|
806
806
|
chat_reply(args: { text?: string; card?: unknown }): Promise<unknown>;
|
|
807
807
|
chat_post(args: {
|
|
808
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
808
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
809
809
|
threadId?: string;
|
|
810
810
|
channelId?: string;
|
|
811
811
|
text?: string;
|
|
812
812
|
card?: unknown;
|
|
813
813
|
}): Promise<unknown>;
|
|
814
814
|
chat_openDm(args: {
|
|
815
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
815
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
816
816
|
userId: string;
|
|
817
817
|
}): Promise<unknown>;
|
|
818
818
|
chat_registerChannel(args: {
|
|
819
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
819
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
820
820
|
channelId: string;
|
|
821
821
|
agentId?: string;
|
|
822
822
|
workflowId?: string;
|
|
823
823
|
name?: string;
|
|
824
824
|
}): Promise<unknown>;
|
|
825
825
|
chat_unregisterChannel(args: {
|
|
826
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
826
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
827
827
|
channelId: string;
|
|
828
828
|
}): Promise<unknown>;
|
|
829
829
|
|