@desplega.ai/agent-swarm 2.13.5 → 2.14.0
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-99n6z9ky.js +17 -0
- package/dist/{acp-targets-w8dbs4nr.js → acp-targets-23exz4z4.js} +10 -10
- package/dist/{actions-8zrcbjrx.js → actions-zcr25x27.js} +60 -39
- package/dist/{agent-fs-provision-cbt2ttds.js → agent-fs-provision-7fa9e12e.js} +4 -4
- package/dist/{amp-adapter-8x6zp8w4.js → amp-adapter-s7ytmv6b.js} +3 -3
- package/dist/{app-zfa9dwjw.js → app-5d3sz1hy.js} +7 -7
- package/dist/{approval-notifications-rv92zmza.js → approval-notifications-7qgkzkzx.js} +8 -8
- package/dist/{assistant-q7s7rm1q.js → assistant-p2yvhc3j.js} +37 -32
- package/dist/{boot-args-schema-g27kpzr1.js → boot-args-schema-ry6cb0p7.js} +1 -1
- package/dist/{boot-reembed-1mjs52nt.js → boot-reembed-2hkm3vz2.js} +1 -1
- package/dist/{boot-reembed-m62dpdkg.js → boot-reembed-c9643ms3.js} +1 -1
- package/dist/{boot-scrub-sweep-ss1vcamw.js → boot-scrub-sweep-3ycxr51t.js} +2 -2
- package/dist/{boot-seeds-hwnvgbb3.js → boot-seeds-2hzvvzg0.js} +4 -4
- package/dist/{boxd-y0szhp0g.js → boxd-9py3x0jb.js} +2 -2
- package/dist/{claude-adapter-0rjmbhjk.js → claude-adapter-dnkww93e.js} +9 -9
- package/dist/{claude-managed-adapter-6k032agg.js → claude-managed-adapter-yk0cr5x6.js} +4 -4
- package/dist/{claude-managed-setup-6czvve8q.js → claude-managed-setup-4byxpp47.js} +5 -5
- package/dist/{claude-sdk-session-pr0znb81.js → claude-sdk-session-4wf3dbvs.js} +12467 -12285
- package/dist/{cli-t0n9svkb.js → cli-096aftq6.js} +12 -7
- package/dist/{cli-2wzkvfgm.js → cli-0e914dp9.js} +3 -3
- package/dist/{cli-vcpyttcw.js → cli-0h6m6z5g.js} +1 -1
- package/dist/{cli-q41qar56.js → cli-0k7ppk9k.js} +130 -8
- package/dist/{cli-ks06cd0n.js → cli-1nfabrt4.js} +8 -8
- package/dist/{cli-ebpq3c5z.js → cli-2414h5r9.js} +8 -8
- package/dist/{cli-nrt048ys.js → cli-24wervhz.js} +37 -0
- package/dist/{cli-pedm2kht.js → cli-2ayk9gn8.js} +2 -2
- package/dist/{cli-kr0jpw9c.js → cli-2ckwgs7q.js} +1 -1
- package/dist/{cli-evy3egte.js → cli-2savn6mm.js} +11 -100
- package/dist/{cli-n79j1vxc.js → cli-2zjxake1.js} +4 -4
- package/dist/{cli-z3x7h79n.js → cli-37p61fcg.js} +9 -9
- package/dist/{cli-2vp0z049.js → cli-39t9d248.js} +1 -1
- package/dist/{cli-sa02jsqt.js → cli-3mhdmcd4.js} +1 -1
- package/dist/{cli-34fygf87.js → cli-3wsabyt0.js} +2 -2
- package/dist/{cli-grbngev5.js → cli-466jjrwe.js} +11 -2
- package/dist/{cli-zxa1vmx7.js → cli-6ajyhxh7.js} +2 -2
- package/dist/{cli-bvamr9g0.js → cli-6yy4fepf.js} +4 -4
- package/dist/{cli-3vw6dd4g.js → cli-73rmgm45.js} +2 -2
- package/dist/{cli-8b4rpnwj.js → cli-7ca8hczj.js} +1 -1
- package/dist/{cli-0h8skzss.js → cli-7g5qj2ca.js} +4 -3
- package/dist/{cli-srre41gb.js → cli-7w1fs01q.js} +2 -2
- package/dist/{cli-tgc1kgg3.js → cli-84wxwt3z.js} +1 -1
- package/dist/{cli-4gaf3tx5.js → cli-84xn7bgz.js} +1 -1
- package/dist/{cli-s8dhq7rj.js → cli-879txsac.js} +5 -5
- package/dist/{cli-9n6g14vs.js → cli-8vbxjzk0.js} +3 -3
- package/dist/{cli-cmbb2t8a.js → cli-91amj3md.js} +2 -2
- package/dist/{cli-ewk3sg68.js → cli-930zbczq.js} +3 -3
- package/dist/{cli-6msnpj1z.js → cli-9fwznq4p.js} +10 -10
- package/dist/{cli-qmx8bnt4.js → cli-9j1t3kf6.js} +2 -2
- package/dist/{cli-t879ww0y.js → cli-9j47sgzy.js} +2 -2
- package/dist/{cli-0qt3epg4.js → cli-ad00h1st.js} +7 -7
- package/dist/{cli-avax5mp9.js → cli-adzmmcvf.js} +19 -7
- package/dist/{cli-ffn0a515.js → cli-ayxxkk3p.js} +68 -25
- package/dist/{cli-4vynxtrb.js → cli-bqfx72e6.js} +10 -3
- package/dist/{cli-887vhew6.js → cli-cbg0j1yt.js} +2716 -2643
- package/dist/{cli-fw67mnyc.js → cli-cg1q8ymp.js} +1 -1
- package/dist/{cli-he5nxaa8.js → cli-dw9rtjm3.js} +1 -1
- package/dist/{cli-emdfd8fh.js → cli-dy754erz.js} +9 -1
- package/dist/{cli-3860pmrq.js → cli-edxfzgah.js} +4 -4
- package/dist/{cli-v09eza21.js → cli-ejnhs815.js} +15 -15
- package/dist/{cli-k0nebh10.js → cli-enavhq6r.js} +1 -1
- package/dist/{cli-b42yfn17.js → cli-f2rwt43y.js} +13 -13
- package/dist/{cli-tvyt8w6n.js → cli-f9g96z28.js} +8 -8
- package/dist/{cli-zbbtp02a.js → cli-fww016hh.js} +457 -70
- package/dist/{cli-vbge4rsp.js → cli-g6a696c0.js} +4 -4
- package/dist/{cli-z1vam71h.js → cli-gc6b94tj.js} +2 -2
- package/dist/{cli-5tq15aa7.js → cli-gcyws2bp.js} +2 -2
- package/dist/{cli-srktrbby.js → cli-hzhv7yac.js} +1 -1
- package/dist/{cli-cp163xga.js → cli-jcnc5ret.js} +44 -32
- package/dist/{cli-j69pzrrz.js → cli-jgq9xptq.js} +5 -5
- package/dist/{cli-kwj3131p.js → cli-jwnac23b.js} +1 -1
- package/dist/{cli-wzecestt.js → cli-kc7vd07m.js} +616 -289
- package/dist/{cli-8pd1t17c.js → cli-kg63yp1r.js} +14 -14
- package/dist/{cli-zzq96q57.js → cli-krk8y8c7.js} +727 -139
- package/dist/{cli-5web09sb.js → cli-m0ea8ggd.js} +8 -10
- package/dist/{cli-qrvk9nka.js → cli-md4tn21h.js} +13 -13
- package/dist/{cli-1jq2em7b.js → cli-mv8ft7b0.js} +10 -9
- package/dist/{cli-ryem5cfq.js → cli-mw1tmn3x.js} +217 -27
- package/dist/{cli-abby987g.js → cli-njvpngc6.js} +3 -3
- package/dist/{cli-55h8m1x3.js → cli-phe2vcw5.js} +6 -6
- package/dist/{cli-prz1p3ft.js → cli-pq0kv31y.js} +5 -5
- package/dist/{cli-q1h041y8.js → cli-q457ga28.js} +6 -6
- package/dist/{cli-z40t85ms.js → cli-q5n3deaf.js} +1 -1
- package/dist/{cli-7ypg8hka.js → cli-qkbevqer.js} +3 -3
- package/dist/{cli-f9xw9pr4.js → cli-qrwjk4xy.js} +5 -5
- package/dist/{cli-kezzteka.js → cli-r04ve9xw.js} +1 -1
- package/dist/{cli-zntvmqmm.js → cli-r495stwd.js} +2 -2
- package/dist/{cli-1kvcsd2f.js → cli-r9d2tya0.js} +71 -3
- package/dist/{cli-ybte1fqc.js → cli-rp1n2xpd.js} +1 -1
- package/dist/{cli-sejvnjvw.js → cli-rs1rzwp4.js} +1 -1
- package/dist/{cli-94mxerrp.js → cli-rzbsh6bw.js} +1 -1
- package/dist/{cli-94gx6ze9.js → cli-s4pccby1.js} +1 -1
- package/dist/{cli-hd5bm1e1.js → cli-shyhb4t5.js} +10 -10
- package/dist/{cli-r3dxpmyt.js → cli-srq69pn1.js} +1 -1
- package/dist/{cli-7r9tvk8v.js → cli-tc165vrb.js} +8 -3
- package/dist/{cli-ced4azn1.js → cli-v4z5v3jd.js} +298 -80
- package/dist/{cli-ehg90jd1.js → cli-vxmmttmt.js} +55 -50
- package/dist/{cli-tt7dkwjj.js → cli-w4bvtxet.js} +7 -7
- package/dist/{cli-x2adbg4j.js → cli-wd7b5hgc.js} +1 -1
- package/dist/{cli-htb5bpz2.js → cli-wvbaq052.js} +1 -1
- package/dist/{cli-ywy8yz6t.js → cli-wvgg7r4j.js} +2 -2
- package/dist/{cli-19d6v8er.js → cli-wym6rxgt.js} +165 -6
- package/dist/{cli-f7b9nyvk.js → cli-yd7e590v.js} +12 -12
- package/dist/{cli-69zzpjgh.js → cli-yjb3cddd.js} +1 -1
- package/dist/{cli-5n9w2xzx.js → cli-z8t4485r.js} +2 -2
- package/dist/{cli-jdq3jmny.js → cli-ze1ndjs4.js} +4 -6
- package/dist/cli.js +28 -28
- package/dist/{codex-adapter-bn7eaxk5.js → codex-adapter-eq61radw.js} +8 -8
- package/dist/{codex-hook-nnmezjg9.js → codex-hook-8nmepvz6.js} +3 -3
- package/dist/{codex-login-ktfg1cxk.js → codex-login-vbd9707w.js} +1 -1
- package/dist/{codex-session-runner-j1e9hffc.js → codex-session-runner-rfx355h4.js} +9 -9
- package/dist/{commands-amhpafrr.js → commands-d1z0sx62.js} +3 -3
- package/dist/{controller-tw7g10j2.js → controller-9hz6d8x3.js} +4 -4
- package/dist/{controllers-connect-2ssqz7f4.js → controllers-connect-tz07d2xr.js} +24 -25
- package/dist/core-dynsv289.js +41 -0
- package/dist/{cursor-adapter-d6knjmwa.js → cursor-adapter-ef22ze3j.js} +2 -2
- package/dist/{db-fd6xxm77.js → db-gd81d68c.js} +3 -3
- package/dist/{db-sc59379z.js → db-vrckks6q.js} +4 -2
- package/dist/{devin-adapter-3bp6rape.js → devin-adapter-kdt6a2bh.js} +1 -1
- package/dist/{dispatcher-a2gdqz8c.js → dispatcher-76as8w2t.js} +21 -22
- package/dist/{docker-a59g3ebm.js → docker-51ta7jsh.js} +2 -2
- package/dist/dsh-adapter-ypfvcdyz.js +11 -0
- package/dist/{e2b-cn7cvjqy.js → e2b-05kn3kpq.js} +16 -5
- package/dist/{e2b-qnxyfea6.js → e2b-dm9r8hpy.js} +3 -3
- package/dist/{easter-egg-3d-a0pphy71.js → easter-egg-3d-sg21j15g.js} +1 -1
- package/dist/{embedding-space-qepzrach.js → embedding-space-zsdw37bb.js} +13 -23
- package/dist/{embeddings-d7vr881x.js → embeddings-p4e3e1m6.js} +1 -1
- package/dist/{event-bus-7gbsr0g4.js → event-bus-tvf2grf4.js} +1 -1
- package/dist/{execute-6afts2bn.js → execute-nztd0af0.js} +1 -1
- package/dist/{external-channel-881zq1x4.js → external-channel-717yzn4d.js} +2 -2
- package/dist/fx-adapter-9k0hptnz.js +20 -0
- package/dist/grok-adapter-skdj2pce.js +20 -0
- package/dist/handlers-5btjqkz6.js +39 -0
- package/dist/{heartbeat-4c022m6a.js → heartbeat-vfb1gy84.js} +24 -25
- package/dist/{hook-a7eh6zty.js → hook-ctz0xmp3.js} +11 -11
- package/dist/{hook-4k84x499.js → hook-eh52p7yd.js} +6 -6
- package/dist/{http-6aw5wanc.js → http-zregegrx.js} +784 -166
- package/dist/{index-xhad0n8m.js → index-5kx15d19.js} +1 -1
- package/dist/index-7w8p6em0.js +41 -0
- package/dist/index-evay0xyk.js +17 -0
- package/dist/{index-yq9hhhhy.js → index-fdym6ryb.js} +25 -26
- package/dist/{index-3j803vnb.js → index-mtnbhe12.js} +20533 -19786
- package/dist/index-vz4semsx.js +38 -0
- package/dist/{index-z2g9469g.js → index-x9qf8dg7.js} +108 -28
- package/dist/index-y3s0xp2v.js +43 -0
- package/dist/{k8s-36gfn847.js → k8s-ejkk0aw7.js} +2 -2
- package/dist/{keepalive-zhbmztqw.js → keepalive-zdqay870.js} +4 -5
- package/dist/lead-6cscw8a5.js +82 -0
- package/dist/{maintenance-rsp0591h.js → maintenance-t5ndg11m.js} +1 -1
- package/dist/{node-rxte5hc6.js → node-jkdd5w7m.js} +1 -1
- package/dist/{oauth-refresh-sweep-w3cqmxq7.js → oauth-refresh-sweep-y9zyd7t6.js} +3 -4
- package/dist/{object-webhooks-331hay92.js → object-webhooks-mkca91s0.js} +7 -7
- package/dist/{onboard-n2w80m2n.js → onboard-ss995244.js} +11 -9
- package/dist/{opencode-adapter-z98127cz.js → opencode-adapter-mwpz0278.js} +8 -8
- package/dist/{otel-impl-xsk35tvf.js → otel-impl-6n6vva3x.js} +2 -2
- package/dist/{pending-2e6trkxd.js → pending-2sxh1t6j.js} +22 -23
- package/dist/{pi-mono-adapter-wh6yndtm.js → pi-mono-adapter-sfb7zy43.js} +13 -13
- package/dist/{pricing-refresh-9355dj1t.js → pricing-refresh-h79bg4cf.js} +2 -2
- package/dist/{rbac-roles-8eajw4s6.js → rbac-roles-ckq0czp4.js} +2 -2
- package/dist/{rbac-roles-58y3m912.js → rbac-roles-jg2e260w.js} +3 -3
- package/dist/{render-v2-7gskkmd4.js → render-v2-ymbshmn0.js} +7 -7
- package/dist/{resume-0drnmpja.js → resume-jdhnt4jk.js} +10 -10
- package/dist/{runtime-d2tcmqte.js → runtime-y28jhhnf.js} +1 -1
- package/dist/{session-access-0ztys6bd.js → session-access-k4ta5hvp.js} +5 -5
- package/dist/{session-source-backfill-cdm5s046.js → session-source-backfill-528j4s8j.js} +3 -3
- package/dist/{setup-pqwb9tcc.js → setup-d6pj82fr.js} +15 -6
- package/dist/thread-buffer-9w6x5zec.js +40 -0
- package/dist/{tree-visibility-rwz67mje.js → tree-visibility-kjxv3nxk.js} +2 -2
- package/dist/{user-merge-jobs-mxrhamwt.js → user-merge-jobs-rabbncf6.js} +3 -3
- package/dist/{virtual-modules-71y1gsmg.js → virtual-modules-22k51txd.js} +3 -3
- package/dist/{work-objects-3k4ykt9j.js → work-objects-xtjbar3r.js} +26 -30
- package/dist/{worker-follow-up-y0h64xpr.js → worker-follow-up-fg48vk6d.js} +21 -22
- package/dist/worker-g4aj93dt.js +82 -0
- package/dist/{x-d27jj7z7.js → x-vfsqypht.js} +2 -2
- package/openapi.json +247 -20
- package/package.json +10 -10
- package/src/apps/definition.ts +76 -24
- package/src/apps/row-store.ts +67 -0
- package/src/apps/script-types.ts +131 -21
- package/src/apps/store.ts +4 -1
- package/src/be/db/script-runs.ts +33 -0
- package/src/be/db/slack-card-groups.ts +147 -0
- package/src/be/db/slack-trees.ts +26 -0
- package/src/be/db/task-idempotency.ts +63 -0
- package/src/be/db/tasks/read.ts +2 -0
- package/src/be/db/tasks/write.ts +4 -2
- package/src/be/db/workflow-idempotency.ts +6 -1
- package/src/be/db/workflows/read.ts +79 -0
- package/src/be/db.ts +51 -147
- package/src/be/improvements.ts +24 -2
- package/src/be/mcp-proxy.ts +45 -11
- package/src/be/memory/embedding-space.ts +10 -20
- package/src/be/memory/index.ts +35 -0
- package/src/be/memory/providers/openai-embedding.ts +10 -0
- package/src/be/migrations/348_task_deferred_until.sql +4 -0
- package/src/be/migrations/354_durable_objects.sql +9 -0
- package/src/be/migrations/356_slack_outcome_card_groups.sql +14 -0
- package/src/be/migrations/357_task_idempotency_keys.sql +27 -0
- package/src/be/migrations/362_favorites_app.sql +36 -0
- package/src/be/repo-checked-update.ts +58 -5
- package/src/be/requester-timezone.ts +10 -0
- package/src/be/script-connections.ts +5 -1
- package/src/be/script-credential-broker.ts +29 -2
- package/src/be/scripts/durable.ts +204 -0
- package/src/be/scripts/extract-schema.ts +29 -4
- package/src/be/scripts/run-credential.ts +1 -8
- package/src/be/scripts/typecheck.ts +32 -7
- package/src/be/seed-scripts/catalog/memory-eval.ts +11 -2
- package/src/be/seed-scripts/catalog/tool-usage.ts +27 -8
- package/src/be/swarm-config-guard.ts +87 -7
- package/src/be/users.ts +33 -12
- package/src/comb/review-batch.ts +16 -5
- package/src/commands/context-preamble.ts +237 -0
- package/src/commands/e2b.ts +14 -0
- package/src/commands/entrypoint-mcp-config.ts +231 -0
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/onboard/compose-generator.ts +2 -1
- package/src/commands/onboard/env-generator.ts +16 -7
- package/src/commands/runner.ts +23 -7
- package/src/commands/setup.tsx +17 -3
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/hooks/hook.ts +8 -2
- package/src/hooks/native-tool-hooks.ts +4 -2
- package/src/http/apps.ts +82 -42
- package/src/http/comb.ts +21 -5
- package/src/http/config.ts +8 -4
- package/src/http/heartbeat.ts +5 -0
- package/src/http/index.ts +12 -6
- package/src/http/kv.ts +7 -5
- package/src/http/mcp-oauth.ts +16 -0
- package/src/http/mcp-servers.ts +43 -3
- package/src/http/memory.ts +28 -1
- package/src/http/metrics.ts +11 -4
- package/src/http/onboarding.ts +12 -1
- package/src/http/repos.ts +27 -11
- package/src/http/request-principal.ts +27 -1
- package/src/http/schedules.ts +36 -8
- package/src/http/script-connection-proxy.ts +3 -1
- package/src/http/script-runs.ts +21 -10
- package/src/http/scripts.ts +177 -26
- package/src/http/session-cost-recompute.ts +9 -4
- package/src/http/skills.ts +70 -0
- package/src/http/status.ts +2 -0
- package/src/http/tasks.ts +92 -14
- package/src/http/trackers/jira.ts +18 -3
- package/src/http/trackers/linear.ts +3 -0
- package/src/kv-limits.ts +2 -0
- package/src/kv-reserved-namespaces.ts +25 -2
- package/src/prompts/session-templates.ts +49 -0
- package/src/prompts/session-turns.ts +30 -0
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-managed-adapter.ts +14 -0
- package/src/providers/claude-sdk-session.ts +14 -1
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/providers/dsh-adapter.ts +1 -1
- package/src/providers/opencode-adapter.ts +3 -5
- package/src/providers/runtime-dependencies.ts +11 -8
- package/src/rbac/legacy-policy.ts +7 -0
- package/src/rbac/permissions.ts +27 -0
- package/src/scheduler/scheduler.ts +36 -18
- package/src/script-workflows/executor.ts +37 -8
- package/src/script-workflows/supervisor.ts +14 -0
- package/src/scripts-runtime/ctx.ts +5 -1
- package/src/scripts-runtime/durable-object-base.ts +19 -0
- package/src/scripts-runtime/eval-harness.ts +46 -1
- package/src/scripts-runtime/executors/native.ts +13 -1
- package/src/scripts-runtime/executors/quickjs-bundle.ts +20 -1
- package/src/scripts-runtime/executors/quickjs-prelude.ts +40 -1
- package/src/scripts-runtime/executors/quickjs-runner.ts +26 -3
- package/src/scripts-runtime/executors/quickjs-worker.ts +2 -1
- package/src/scripts-runtime/executors/types.ts +26 -0
- package/src/scripts-runtime/extract-signature.ts +96 -1
- package/src/scripts-runtime/loader.ts +11 -5
- package/src/scripts-runtime/mcp-client.ts +1 -1
- package/src/scripts-runtime/sdk-allowlist.ts +1 -0
- package/src/scripts-runtime/swarm-config.ts +7 -0
- package/src/scripts-runtime/swarm-sdk.ts +4 -1
- package/src/scripts-runtime/types/stdlib.d.ts +19 -0
- package/src/scripts-runtime/types/swarm-extension.d.ts +1 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +19 -0
- package/src/slack/actions.ts +24 -0
- package/src/slack/assistant.ts +8 -0
- package/src/slack/blocks.ts +35 -0
- package/src/slack/channel-activity.ts +7 -0
- package/src/slack/enrich.ts +46 -54
- package/src/slack/files.ts +173 -23
- package/src/slack/handlers.test.ts +17 -19
- package/src/slack/handlers.ts +15 -14
- package/src/slack/render-v2.ts +264 -19
- package/src/slack/responses.ts +61 -5
- package/src/slack/session-mirror.ts +10 -5
- package/src/slack/task-output.ts +25 -14
- package/src/slack/templates.ts +9 -0
- package/src/slack/thread-participants.ts +64 -24
- package/src/slack/watcher.ts +4 -4
- package/src/slack/work-objects.ts +1 -1
- package/src/stdio.ts +5 -0
- package/src/tests/agents-list-model-display.test.ts +4 -0
- package/src/tests/apps-script-types.test.ts +63 -16
- package/src/tests/apps-sort-order.test.ts +87 -0
- package/src/tests/bedrock-model-groups.test.ts +4 -0
- package/src/tests/channel-activity.test.ts +9 -0
- package/src/tests/chatgpt-subscription-model-groups.test.ts +4 -0
- package/src/tests/claude-hook-output.test.ts +2 -0
- package/src/tests/claude-managed-adapter.test.ts +15 -3
- package/src/tests/claude-sdk-stderr.test.ts +28 -0
- package/src/tests/codex-gpt6-release.test.ts +4 -0
- package/src/tests/comb-review-batch.test.ts +17 -4
- package/src/tests/comb-status.test.ts +1 -0
- package/src/tests/db-client.test.ts +11 -5
- package/src/tests/db-task-read-contract.test.ts +1 -0
- package/src/tests/db-task-write-contract.test.ts +2 -2
- package/src/tests/defer-task.test.ts +23 -1
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/e2b-dispatch.test.ts +13 -1
- package/src/tests/entrypoint-mcp-config.test.ts +642 -0
- package/src/tests/fixtures/onboard/content.env.txt +2 -2
- package/src/tests/fixtures/onboard/dev.env.txt +2 -2
- package/src/tests/fixtures/onboard/full-all.env.txt +2 -2
- package/src/tests/fixtures/onboard/full.env.txt +2 -2
- package/src/tests/fixtures/onboard/research.env.txt +2 -2
- package/src/tests/fixtures/onboard/solo.env.txt +2 -2
- package/src/tests/fixtures/runner-missing-dependency.ts +2 -1
- package/src/tests/fx-adapter.test.ts +4 -5
- package/src/tests/hook-mcp-config-precedence.test.ts +59 -0
- package/src/tests/hook-ping-me-order.test.ts +1 -0
- package/src/tests/hook-runtime-close.test.ts +1 -0
- package/src/tests/improvements-payload.test.ts +2 -2
- package/src/tests/model-groups-live-catalog.test.ts +4 -0
- package/src/tests/oauth-credential-bindings.test.ts +8 -3
- package/src/tests/oauth-refresh-failure.test.ts +15 -3
- package/src/tests/onboard-env.test.ts +1 -1
- package/src/tests/openai-compatible-providers.test.ts +5 -0
- package/src/tests/openapi-route-headers.test.ts +2 -1
- package/src/tests/opus-5-5-registry.test.ts +4 -0
- package/src/tests/provider-runtime-dependencies.test.ts +26 -15
- package/src/tests/routing-affinity-inventory.test.ts +11 -0
- package/src/tests/runner-context-preamble.test.ts +202 -0
- package/src/tests/runner-repo-clone-args.test.ts +116 -0
- package/src/tests/scheduler-occurrence.test.ts +60 -9
- package/src/tests/script-connections-mcp.test.ts +6 -3
- package/src/tests/script-connections.test.ts +4 -0
- package/src/tests/scripts-namespaces.test.ts +3 -1
- package/src/tests/secret-scrubber.test.ts +8 -2
- package/src/tests/session-cost-recompute-unit.test.ts +39 -0
- package/src/tests/session-costs-recompute-all-providers.test.ts +6 -3
- package/src/tests/session-route-posture.test.ts +7 -1
- package/src/tests/slack-file-tools-attachments.test.ts +14 -9
- package/src/tests/slack-identity-resolution.test.ts +10 -3
- package/src/tests/slack-inline-output.test.ts +10 -8
- package/src/tests/slack-render-v2.test.ts +9 -4
- package/src/tests/slack-steering.test.ts +8 -2
- package/src/tests/slack-thread-participants.test.ts +11 -1
- package/src/tests/sonnet-5-5-registry.test.ts +4 -0
- package/src/tests/swarm-config-encryption.test.ts +5 -8
- package/src/tests/ui-spec-script-actions-config.test.ts +7 -3
- package/src/tests/workflow-triggers-v2.test.ts +35 -11
- package/src/tools/app-patch.ts +6 -2
- package/src/tools/app-upsert.ts +8 -4
- package/src/tools/defer-task.ts +17 -77
- package/src/tools/kv/kv-get.ts +2 -0
- package/src/tools/kv/kv-list.ts +11 -5
- package/src/tools/kv/kv-set.ts +1 -3
- package/src/tools/repos/update-repo.ts +37 -19
- package/src/tools/schedules/run-schedule-now.ts +21 -1
- package/src/tools/script-apis.ts +9 -4
- package/src/tools/script-common.ts +2 -2
- package/src/tools/script-run.ts +8 -0
- package/src/tools/script-upsert.ts +1 -1
- package/src/tools/slack-download-file.ts +15 -12
- package/src/tools/slack-post.ts +7 -1
- package/src/tools/slack-read.ts +3 -1
- package/src/tools/slack-reply.ts +16 -0
- package/src/tools/slack-start-thread.ts +8 -1
- package/src/tools/slack-upload-file.ts +99 -96
- package/src/tools/swarm-config/set-config.ts +3 -1
- package/src/tools/swarm-x.ts +0 -2
- package/src/tools/utils.ts +3 -0
- package/src/types.ts +8 -2
- package/src/utils/constants.ts +20 -0
- package/src/utils/deferral-time.ts +61 -0
- package/src/utils/request-auth-context.ts +15 -16
- package/src/utils/secret-scrubber.ts +1 -1
- package/src/workflows/engine.ts +6 -11
- package/src/workflows/executors/swarm-script.ts +0 -2
- package/src/workflows/foreach-driver.ts +6 -12
- package/src/workflows/input.ts +24 -1
- package/src/workflows/node-timeout.ts +18 -0
- package/src/workflows/retry-poller.ts +2 -1
- package/src/workflows/triggers.ts +21 -11
- package/src/x/composio.ts +10 -1
- package/templates/skills/apps/SKILL.md +4 -2
- package/templates/skills/apps/content.md +4 -2
- package/templates/skills/code-quality/content.md +4 -4
- package/templates/skills/scheduled-task-resilience/SKILL.md +2 -0
- package/templates/skills/scheduled-task-resilience/content.md +2 -0
- package/templates/skills/swarm-docs/content.md +7 -0
- package/templates/skills/swarm-scripts/SKILL.md +44 -0
- package/templates/skills/swarm-scripts/content.md +44 -0
- package/dist/acp-adapter-tbt61zkm.js +0 -17
- package/dist/cli-b9ygp1kz.js +0 -459
- package/dist/cli-kj0hyr43.js +0 -51
- package/dist/cli-m8f4379k.js +0 -173
- package/dist/core-bwp98v4w.js +0 -42
- package/dist/dsh-adapter-43ygwqn7.js +0 -9
- package/dist/fx-adapter-cr2hq17y.js +0 -20
- package/dist/grok-adapter-ayddnbsc.js +0 -20
- package/dist/handlers-7ghs84x2.js +0 -41
- package/dist/index-dtt0d634.js +0 -44
- package/dist/index-hmszyqkk.js +0 -42
- package/dist/index-j6rm1rtn.js +0 -39
- package/dist/index-rwwhsmjg.js +0 -13
- package/dist/lead-g2j4q39z.js +0 -83
- package/dist/thread-buffer-epx3san4.js +0 -42
- package/dist/worker-09gqn9xy.js +0 -83
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DURABLE_OBJECT_RESERVED_METHODS } from "../durable-object-base";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* JavaScript that the quickjs runner evaluates inside the sandbox before the
|
|
3
5
|
* user bundle. It rebuilds the script `ctx` (swarm, api, mcp, stdlib, logger)
|
|
@@ -452,7 +454,8 @@ const namespaces = Object.fromEntries(
|
|
|
452
454
|
Object.freeze(Object.fromEntries(names.map((name) => [name, method(ns + "." + name)]))),
|
|
453
455
|
]),
|
|
454
456
|
);
|
|
455
|
-
const
|
|
457
|
+
const caller = globalThis.__swarm_caller;
|
|
458
|
+
const ctx = Object.freeze({ ...namespaces, swarm, api: registry("api"), mcp: registry("mcp"), fs, sh, stdlib, logger: console, caller: caller === null ? null : Object.freeze(caller) });
|
|
456
459
|
|
|
457
460
|
const define = (name, value) =>
|
|
458
461
|
Object.defineProperty(globalThis, name, { value, writable: true, configurable: true, enumerable: false });
|
|
@@ -572,6 +575,13 @@ export const SANDBOX_EPILOGUE = String.raw`(async () => {
|
|
|
572
575
|
}
|
|
573
576
|
};
|
|
574
577
|
const mod = globalThis.__swarm_module;
|
|
578
|
+
const durable = globalThis.__swarm_durable;
|
|
579
|
+
if (durable && !mod?.default?.__swarmDurable) {
|
|
580
|
+
throw new Error("this script is not a DurableObject");
|
|
581
|
+
}
|
|
582
|
+
if (!durable && mod?.default?.__swarmDurable) {
|
|
583
|
+
throw new Error("this script is a DurableObject. Call it with object: { id, method }");
|
|
584
|
+
}
|
|
575
585
|
if (!mod || typeof mod.default !== "function") {
|
|
576
586
|
throw new Error(
|
|
577
587
|
"Swarm script must export a default function. Script must export default async function (args, ctx): args FIRST, ctx second.",
|
|
@@ -597,6 +607,35 @@ export const SANDBOX_EPILOGUE = String.raw`(async () => {
|
|
|
597
607
|
throw error;
|
|
598
608
|
}
|
|
599
609
|
}
|
|
610
|
+
if (durable) {
|
|
611
|
+
const obj = new mod.default(durable.id);
|
|
612
|
+
obj.state = durable.state === undefined ? await obj.initialState() : durable.state;
|
|
613
|
+
if (durable.storedCodeVersion < durable.codeVersion && typeof obj.migrate === "function") {
|
|
614
|
+
obj.state = await obj.migrate(obj.state, durable.storedCodeVersion);
|
|
615
|
+
}
|
|
616
|
+
const method = durable.method;
|
|
617
|
+
let prototype = mod.default.prototype;
|
|
618
|
+
let descriptor;
|
|
619
|
+
while (Object.getPrototypeOf(prototype)?.constructor?.__swarmDurable) {
|
|
620
|
+
descriptor = Object.getOwnPropertyDescriptor(prototype, method);
|
|
621
|
+
if (descriptor) break;
|
|
622
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
623
|
+
}
|
|
624
|
+
if (
|
|
625
|
+
method.startsWith("_") ||
|
|
626
|
+
${JSON.stringify([...DURABLE_OBJECT_RESERVED_METHODS])}.includes(method) ||
|
|
627
|
+
typeof descriptor?.value !== "function"
|
|
628
|
+
) {
|
|
629
|
+
throw new Error('DurableObject method "' + method + '" is not callable');
|
|
630
|
+
}
|
|
631
|
+
return {
|
|
632
|
+
__swarmDurable: 1,
|
|
633
|
+
result: (await obj[method](args, globalThis.__swarm_ctx)) ?? null,
|
|
634
|
+
state: obj.state,
|
|
635
|
+
destroyed: Boolean(obj._destroyed),
|
|
636
|
+
idleTtlSec: mod.default.idleTtlSec ?? null,
|
|
637
|
+
};
|
|
638
|
+
}
|
|
600
639
|
return await mod.default(args, globalThis.__swarm_ctx);
|
|
601
640
|
})().then(
|
|
602
641
|
(value) => {
|
|
@@ -40,7 +40,7 @@ export type QuickJSJob = {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
// Set while a ctx.swarm or ctx.mcp host call runs. Those calls go to the swarm
|
|
43
|
-
// API (
|
|
43
|
+
// API (sdkBaseUrl) with the host bearer; the egress guard trusts that origin
|
|
44
44
|
// only inside this scope; a direct script fetch of it follows the policy.
|
|
45
45
|
const swarmHostCalls = new AsyncLocalStorage<true>();
|
|
46
46
|
|
|
@@ -545,6 +545,12 @@ async function evaluateJob(
|
|
|
545
545
|
apiConnections: job.configPayload.apiConnections,
|
|
546
546
|
mcpConnections: job.configPayload.mcpConnections,
|
|
547
547
|
agentFs: job.configPayload.agentFs,
|
|
548
|
+
caller:
|
|
549
|
+
job.configPayload.durable?.caller ??
|
|
550
|
+
job.configPayload.caller ??
|
|
551
|
+
(job.configPayload.system.agentId.value
|
|
552
|
+
? { kind: "agent", agentId: job.configPayload.system.agentId.value }
|
|
553
|
+
: null),
|
|
548
554
|
signal: host.signal,
|
|
549
555
|
});
|
|
550
556
|
const sqlApiSlugs = new Set(
|
|
@@ -672,7 +678,7 @@ async function evaluateJob(
|
|
|
672
678
|
|
|
673
679
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
674
680
|
try {
|
|
675
|
-
const init = `globalThis.__swarm_shape = ${JSON.stringify(shape)};\nglobalThis.__swarm_args = ${JSON.stringify(args)};\nglobalThis.__swarm_host_validated_args = ${Boolean(job.hostValidatedArgs)};`;
|
|
681
|
+
const init = `globalThis.__swarm_shape = ${JSON.stringify(shape)};\nglobalThis.__swarm_args = ${JSON.stringify(args)};\nglobalThis.__swarm_host_validated_args = ${Boolean(job.hostValidatedArgs)};\nglobalThis.__swarm_durable = ${JSON.stringify(job.configPayload.durable ?? null)};\nglobalThis.__swarm_caller = ${JSON.stringify(hostCtx.caller)};`;
|
|
676
682
|
const ok =
|
|
677
683
|
evaluate(init, "swarm-init.js") &&
|
|
678
684
|
evaluate(SANDBOX_WEB_SHIMS, "swarm-web-shims.js") &&
|
|
@@ -696,7 +702,24 @@ async function evaluateJob(
|
|
|
696
702
|
});
|
|
697
703
|
const outcome = await Promise.race([done, timeout]);
|
|
698
704
|
|
|
699
|
-
if (outcome.ok)
|
|
705
|
+
if (outcome.ok) {
|
|
706
|
+
const envelope = outcome.result as {
|
|
707
|
+
__swarmDurable?: number;
|
|
708
|
+
result?: unknown;
|
|
709
|
+
} & NonNullable<ExecutorOutput["durable"]>;
|
|
710
|
+
if (job.configPayload.durable && envelope?.__swarmDurable === 1) {
|
|
711
|
+
return output({
|
|
712
|
+
result: envelope.result,
|
|
713
|
+
durable: {
|
|
714
|
+
state: envelope.state,
|
|
715
|
+
destroyed: envelope.destroyed,
|
|
716
|
+
idleTtlSec: envelope.idleTtlSec,
|
|
717
|
+
},
|
|
718
|
+
exitCode: 0,
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
return output({ result: outcome.result, exitCode: 0 });
|
|
722
|
+
}
|
|
700
723
|
const error = classify(outcome.error);
|
|
701
724
|
if (error === "timeout") {
|
|
702
725
|
stderr.append(`Script exceeded its ${job.resources.wallClockMs} ms wall-clock limit\n`);
|
|
@@ -46,7 +46,8 @@ function egressFetch(job: QuickJSJob): typeof fetch {
|
|
|
46
46
|
if (job.network === "open") return pristineFetch;
|
|
47
47
|
let swarmOrigin: string | null = null;
|
|
48
48
|
try {
|
|
49
|
-
|
|
49
|
+
const { sdkBaseUrl, mcpBaseUrl } = job.configPayload.system;
|
|
50
|
+
swarmOrigin = new URL((sdkBaseUrl ?? mcpBaseUrl).value).origin;
|
|
50
51
|
} catch {}
|
|
51
52
|
return createGuardedFetch(pristineFetch, {
|
|
52
53
|
policy: job.network,
|
|
@@ -13,11 +13,33 @@ export type EgressSecretEntry = ResolvedCredentialBinding;
|
|
|
13
13
|
*/
|
|
14
14
|
export type ScriptAgentFsDescriptor = { apiUrl: string; orgId: string; driveId: string };
|
|
15
15
|
|
|
16
|
+
/** The invoking agent, or the saved script that made a nested call. */
|
|
17
|
+
export type ScriptCaller =
|
|
18
|
+
| { kind: "agent"; agentId: string }
|
|
19
|
+
| { kind: "script"; agentId: string; scriptId?: string; objectId?: string }
|
|
20
|
+
| null;
|
|
21
|
+
|
|
22
|
+
/** Host-owned snapshot and call target for one DurableObject method invocation. */
|
|
23
|
+
export type DurableInvocation = {
|
|
24
|
+
id: string;
|
|
25
|
+
method: string;
|
|
26
|
+
state?: unknown;
|
|
27
|
+
codeVersion: number;
|
|
28
|
+
storedCodeVersion: number;
|
|
29
|
+
caller?: ScriptCaller;
|
|
30
|
+
};
|
|
31
|
+
|
|
16
32
|
export type SwarmConfigPayload = {
|
|
17
33
|
system: {
|
|
18
34
|
apiKey: { value: string; isSecret: true };
|
|
19
35
|
agentId: { value: string; isSecret: false };
|
|
20
36
|
mcpBaseUrl: { value: string; isSecret: false };
|
|
37
|
+
/**
|
|
38
|
+
* Where `ctx.swarm` and `ctx.mcp` send their requests, when it differs from
|
|
39
|
+
* `mcpBaseUrl` (API-side runs: this server's loopback address). Script code
|
|
40
|
+
* sees only `mcpBaseUrl`.
|
|
41
|
+
*/
|
|
42
|
+
sdkBaseUrl?: { value: string; isSecret: false };
|
|
21
43
|
/**
|
|
22
44
|
* Per-boot runtime identity of the invoking worker process. System
|
|
23
45
|
* context like the agent identity — scripts never supply or override it.
|
|
@@ -40,6 +62,8 @@ export type SwarmConfigPayload = {
|
|
|
40
62
|
apiConnections?: ScriptApiConnectionDescriptor[];
|
|
41
63
|
mcpConnections?: ScriptMcpConnectionDescriptor[];
|
|
42
64
|
agentFs?: ScriptAgentFsDescriptor;
|
|
65
|
+
caller?: ScriptCaller;
|
|
66
|
+
durable?: DurableInvocation;
|
|
43
67
|
};
|
|
44
68
|
|
|
45
69
|
export type ScriptResourcePolicy = {
|
|
@@ -111,6 +135,8 @@ export type ScriptRuntimeError = {
|
|
|
111
135
|
|
|
112
136
|
export type ExecutorOutput = {
|
|
113
137
|
result: unknown | undefined;
|
|
138
|
+
/** State stays separate from the result so the loader does not scrub it. */
|
|
139
|
+
durable?: { state: unknown; destroyed: boolean; idleTtlSec: number | null };
|
|
114
140
|
stdout: string;
|
|
115
141
|
stderr: string;
|
|
116
142
|
truncated: { stdout: boolean; stderr: boolean };
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
|
+
import { DURABLE_OBJECT_RESERVED_METHODS } from "./durable-object-base";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
type MethodSignature = {
|
|
4
5
|
argsType: string;
|
|
5
6
|
resultType: string;
|
|
6
7
|
description: string;
|
|
7
8
|
};
|
|
8
9
|
|
|
10
|
+
export type ScriptSignature = MethodSignature & {
|
|
11
|
+
kind?: "durable";
|
|
12
|
+
methods?: Record<string, MethodSignature>;
|
|
13
|
+
};
|
|
14
|
+
|
|
9
15
|
const FALLBACK_SIGNATURE: ScriptSignature = {
|
|
10
16
|
argsType: "unknown",
|
|
11
17
|
resultType: "unknown",
|
|
@@ -61,7 +67,96 @@ export function extractScriptSignature(source: string): ScriptSignature {
|
|
|
61
67
|
).parseDiagnostics;
|
|
62
68
|
if (parseDiagnostics && parseDiagnostics.length > 0) return FALLBACK_SIGNATURE;
|
|
63
69
|
|
|
70
|
+
const durableNames = new Set<string>();
|
|
71
|
+
const durableNamespaces = new Set<string>();
|
|
72
|
+
const classes = new Map<string, ts.ClassDeclaration>();
|
|
64
73
|
for (const statement of sourceFile.statements) {
|
|
74
|
+
if (ts.isClassDeclaration(statement) && statement.name) {
|
|
75
|
+
classes.set(statement.name.text, statement);
|
|
76
|
+
}
|
|
77
|
+
if (
|
|
78
|
+
ts.isImportDeclaration(statement) &&
|
|
79
|
+
ts.isStringLiteral(statement.moduleSpecifier) &&
|
|
80
|
+
statement.moduleSpecifier.text === "swarm-sdk"
|
|
81
|
+
) {
|
|
82
|
+
const bindings = statement.importClause?.namedBindings;
|
|
83
|
+
if (bindings && ts.isNamespaceImport(bindings)) {
|
|
84
|
+
durableNamespaces.add(bindings.name.text);
|
|
85
|
+
}
|
|
86
|
+
if (bindings && ts.isNamedImports(bindings)) {
|
|
87
|
+
for (const binding of bindings.elements) {
|
|
88
|
+
if ((binding.propertyName ?? binding.name).text === "DurableObject") {
|
|
89
|
+
durableNames.add(binding.name.text);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
for (const statement of sourceFile.statements) {
|
|
97
|
+
const exportedClass =
|
|
98
|
+
ts.isClassDeclaration(statement) && isExportDefault(statement)
|
|
99
|
+
? statement
|
|
100
|
+
: ts.isExportAssignment(statement) && ts.isIdentifier(statement.expression)
|
|
101
|
+
? classes.get(statement.expression.text)
|
|
102
|
+
: undefined;
|
|
103
|
+
const lineage: ts.ClassDeclaration[] = [];
|
|
104
|
+
let current = exportedClass;
|
|
105
|
+
let durable = false;
|
|
106
|
+
while (current && !lineage.includes(current)) {
|
|
107
|
+
lineage.push(current);
|
|
108
|
+
const base = current.heritageClauses?.find(
|
|
109
|
+
(clause) => clause.token === ts.SyntaxKind.ExtendsKeyword,
|
|
110
|
+
)?.types[0]?.expression;
|
|
111
|
+
if (
|
|
112
|
+
base &&
|
|
113
|
+
((ts.isIdentifier(base) && durableNames.has(base.text)) ||
|
|
114
|
+
(ts.isPropertyAccessExpression(base) &&
|
|
115
|
+
ts.isIdentifier(base.expression) &&
|
|
116
|
+
durableNamespaces.has(base.expression.text) &&
|
|
117
|
+
base.name.text === "DurableObject"))
|
|
118
|
+
) {
|
|
119
|
+
durable = true;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
current = base && ts.isIdentifier(base) ? classes.get(base.text) : undefined;
|
|
123
|
+
}
|
|
124
|
+
if (durable && exportedClass) {
|
|
125
|
+
const methods: Record<string, MethodSignature> = Object.create(null);
|
|
126
|
+
const seen = new Set<string>();
|
|
127
|
+
for (const declaration of lineage) {
|
|
128
|
+
for (const member of declaration.members) {
|
|
129
|
+
if (
|
|
130
|
+
(ts.canHaveModifiers(member) &&
|
|
131
|
+
ts
|
|
132
|
+
.getModifiers(member)
|
|
133
|
+
?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword)) ||
|
|
134
|
+
!member.name ||
|
|
135
|
+
!(ts.isIdentifier(member.name) || ts.isStringLiteral(member.name))
|
|
136
|
+
) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const name = member.name.text;
|
|
140
|
+
if (seen.has(name)) continue;
|
|
141
|
+
seen.add(name);
|
|
142
|
+
if (
|
|
143
|
+
!ts.isMethodDeclaration(member) ||
|
|
144
|
+
name.startsWith("_") ||
|
|
145
|
+
DURABLE_OBJECT_RESERVED_METHODS.has(name)
|
|
146
|
+
) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
methods[name] = fromFunctionLike(member, sourceFile);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
kind: "durable",
|
|
154
|
+
methods,
|
|
155
|
+
argsType: "unknown",
|
|
156
|
+
resultType: "unknown",
|
|
157
|
+
description: getJsDocDescription(exportedClass, sourceFile),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
65
160
|
if (ts.isFunctionDeclaration(statement) && isExportDefault(statement)) {
|
|
66
161
|
return fromFunctionLike(statement, sourceFile);
|
|
67
162
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getApiKey } from "../utils/api-key";
|
|
2
|
-
import { getMcpBaseUrl } from "../utils/constants";
|
|
2
|
+
import { getMcpBaseUrl, getScriptApiBaseUrl } from "../utils/constants";
|
|
3
3
|
import { type EgressPolicy, parseEgressAllowlist } from "../utils/egress-guard";
|
|
4
4
|
import { isEnvFlagEnabled } from "../utils/env-flag";
|
|
5
5
|
import { createValueScrubber, scrubObject, scrubSecrets } from "../utils/secret-scrubber";
|
|
@@ -9,9 +9,11 @@ import { buildEgressSecrets } from "./egress-secrets";
|
|
|
9
9
|
import { isExecutorAllowedByDeployment, resolveScriptExecutor } from "./executors/registry";
|
|
10
10
|
import {
|
|
11
11
|
DEFAULT_SCRIPT_RESOURCES,
|
|
12
|
+
type DurableInvocation,
|
|
12
13
|
type EgressSecretEntry,
|
|
13
14
|
type ExecutorOutput,
|
|
14
15
|
type ScriptAgentFsDescriptor,
|
|
16
|
+
type ScriptCaller,
|
|
15
17
|
type ScriptExecutorName,
|
|
16
18
|
type ScriptFsMode,
|
|
17
19
|
type ScriptResourcePolicy,
|
|
@@ -39,6 +41,8 @@ const CAPACITY_EXCEEDED_RETRY_DELAYS_MS = [200, 750];
|
|
|
39
41
|
|
|
40
42
|
export type RunScriptInput = {
|
|
41
43
|
source: string;
|
|
44
|
+
durable?: DurableInvocation;
|
|
45
|
+
caller?: ScriptCaller;
|
|
42
46
|
args?: unknown;
|
|
43
47
|
/**
|
|
44
48
|
* Unforgeable host-only capability symbol set only when the host has already
|
|
@@ -107,10 +111,10 @@ async function buildConfigPayload(input: RunScriptInput): Promise<SwarmConfigPay
|
|
|
107
111
|
system: {
|
|
108
112
|
apiKey: { value: apiKey, isSecret: true },
|
|
109
113
|
agentId: { value: input.agentId, isSecret: false },
|
|
110
|
-
mcpBaseUrl
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
+
// Script code reads mcpBaseUrl (and may fetch it, which the quickjs egress
|
|
115
|
+
// guard allows only for a public host). The SDK clients use sdkBaseUrl.
|
|
116
|
+
mcpBaseUrl: { value: input.mcpBaseUrl ?? getMcpBaseUrl(), isSecret: false },
|
|
117
|
+
sdkBaseUrl: { value: input.mcpBaseUrl ?? getScriptApiBaseUrl(), isSecret: false },
|
|
114
118
|
...(input.runtimeInstanceId
|
|
115
119
|
? { runtimeInstanceId: { value: input.runtimeInstanceId, isSecret: false as const } }
|
|
116
120
|
: {}),
|
|
@@ -119,6 +123,8 @@ async function buildConfigPayload(input: RunScriptInput): Promise<SwarmConfigPay
|
|
|
119
123
|
: {}),
|
|
120
124
|
},
|
|
121
125
|
user: input.userConfig ?? {},
|
|
126
|
+
durable: input.durable,
|
|
127
|
+
caller: input.caller,
|
|
122
128
|
egressSecrets: input.egressSecrets ?? (await buildEgressSecrets()),
|
|
123
129
|
failedBindings: input.failedBindings ?? [],
|
|
124
130
|
apiConnections: input.apiConnections ?? [],
|
|
@@ -60,7 +60,7 @@ export async function postSwarmJson(
|
|
|
60
60
|
body: unknown,
|
|
61
61
|
label: string,
|
|
62
62
|
): Promise<Record<string, unknown>> {
|
|
63
|
-
const baseUrl = Redacted.value(config.
|
|
63
|
+
const baseUrl = Redacted.value(config.sdkBaseUrl).replace(/\/$/, "");
|
|
64
64
|
const response = await fetch(`${baseUrl}${path}`, {
|
|
65
65
|
method: "POST",
|
|
66
66
|
headers: headers(config),
|
|
@@ -5,6 +5,8 @@ export class SwarmConfig {
|
|
|
5
5
|
readonly apiKey: RedactedValue<string>;
|
|
6
6
|
readonly agentId: RedactedValue<string>;
|
|
7
7
|
readonly mcpBaseUrl: RedactedValue<string>;
|
|
8
|
+
/** Base URL of `ctx.swarm` / `ctx.mcp` requests: `system.sdkBaseUrl`, else `mcpBaseUrl`. */
|
|
9
|
+
readonly sdkBaseUrl: RedactedValue<string>;
|
|
8
10
|
/** Per-boot runtime identity of the invoking worker; system context, never script input. */
|
|
9
11
|
readonly runtimeInstanceId: RedactedValue<string> | undefined;
|
|
10
12
|
/** Task the run acts for; system context, sent as `X-Audit-Source-Task-Id`. */
|
|
@@ -27,6 +29,11 @@ export class SwarmConfig {
|
|
|
27
29
|
type: "system",
|
|
28
30
|
isSecret: payload.system.mcpBaseUrl.isSecret,
|
|
29
31
|
});
|
|
32
|
+
const sdkBaseUrl = payload.system.sdkBaseUrl ?? payload.system.mcpBaseUrl;
|
|
33
|
+
this.sdkBaseUrl = Redacted.make(sdkBaseUrl.value, {
|
|
34
|
+
type: "system",
|
|
35
|
+
isSecret: sdkBaseUrl.isSecret,
|
|
36
|
+
});
|
|
30
37
|
this.runtimeInstanceId = payload.system.runtimeInstanceId
|
|
31
38
|
? Redacted.make(payload.system.runtimeInstanceId.value, {
|
|
32
39
|
type: "system",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { scrubObject } from "../utils/secret-scrubber";
|
|
2
|
+
import { DURABLE_OBJECT_BASE_JS } from "./durable-object-base";
|
|
2
3
|
import { Redacted } from "./redacted";
|
|
3
4
|
import { readScriptSdkJsonResponse } from "./response-limit";
|
|
4
5
|
import {
|
|
@@ -13,6 +14,8 @@ import {
|
|
|
13
14
|
import { backoffMs, retryAfterMs } from "./stdlib/retry";
|
|
14
15
|
import type { SwarmConfig } from "./swarm-config";
|
|
15
16
|
|
|
17
|
+
export const DurableObject = new Function(`${DURABLE_OBJECT_BASE_JS}; return DurableObject;`)();
|
|
18
|
+
|
|
16
19
|
type BridgeRequest = {
|
|
17
20
|
method: string;
|
|
18
21
|
path: string;
|
|
@@ -639,7 +642,7 @@ async function callBridgeApi(
|
|
|
639
642
|
config: SwarmConfig,
|
|
640
643
|
options: { throwOnError?: boolean; preserveData?: boolean; signal?: AbortSignal } = {},
|
|
641
644
|
): Promise<unknown> {
|
|
642
|
-
const baseUrl = Redacted.value(config.
|
|
645
|
+
const baseUrl = Redacted.value(config.sdkBaseUrl).replace(/\/$/, "");
|
|
643
646
|
const request = bridgeRequestFor(name, args);
|
|
644
647
|
|
|
645
648
|
// Tools without a specific REST route go through the generic MCP bridge
|
|
@@ -637,6 +637,7 @@ declare module "swarm-sdk" {
|
|
|
637
637
|
script_run(args: {
|
|
638
638
|
name?: string;
|
|
639
639
|
source?: string;
|
|
640
|
+
object?: { id: string; method: string };
|
|
640
641
|
args?: unknown;
|
|
641
642
|
intent?: string;
|
|
642
643
|
scope?: ScriptScope;
|
|
@@ -1252,7 +1253,25 @@ declare module "swarm-sdk" {
|
|
|
1252
1253
|
exitCode: number;
|
|
1253
1254
|
}
|
|
1254
1255
|
|
|
1256
|
+
/** The invoking agent, or the saved script that made a nested call. */
|
|
1257
|
+
export type ScriptCaller =
|
|
1258
|
+
| { kind: "agent"; agentId: string }
|
|
1259
|
+
| { kind: "script"; agentId: string; scriptId?: string; objectId?: string }
|
|
1260
|
+
| null;
|
|
1261
|
+
|
|
1262
|
+
export abstract class DurableObject<S> {
|
|
1263
|
+
constructor(id: string);
|
|
1264
|
+
readonly id: string;
|
|
1265
|
+
state: S;
|
|
1266
|
+
abstract initialState(): S | Promise<S>;
|
|
1267
|
+
migrate?(state: unknown, fromVersion: number): S | Promise<S>;
|
|
1268
|
+
destroy(): void;
|
|
1269
|
+
static idleTtlSec?: number;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1255
1272
|
export interface ScriptContext {
|
|
1273
|
+
/** Frozen caller identity supplied by the host. */
|
|
1274
|
+
caller: ScriptCaller;
|
|
1256
1275
|
run?: ScriptRunContext;
|
|
1257
1276
|
step?: ScriptWorkflowSteps;
|
|
1258
1277
|
swarm: SwarmSdk & { config: SwarmConfig };
|
|
@@ -294,6 +294,7 @@ declare module "swarm-extension" {
|
|
|
294
294
|
}
|
|
295
295
|
| undefined;
|
|
296
296
|
deferredAt?: string | undefined;
|
|
297
|
+
deferredUntil?: string | undefined;
|
|
297
298
|
compactionCount?: number | undefined;
|
|
298
299
|
peakContextPercent?: number | undefined;
|
|
299
300
|
peakContextTokens?: number | undefined;
|
|
@@ -595,6 +595,7 @@ declare module "swarm-sdk" {
|
|
|
595
595
|
script_run(args: {
|
|
596
596
|
name?: string;
|
|
597
597
|
source?: string;
|
|
598
|
+
object?: { id: string; method: string };
|
|
598
599
|
args?: unknown;
|
|
599
600
|
intent?: string;
|
|
600
601
|
scope?: ScriptScope;
|
|
@@ -1210,7 +1211,25 @@ declare module "swarm-sdk" {
|
|
|
1210
1211
|
exitCode: number;
|
|
1211
1212
|
}
|
|
1212
1213
|
|
|
1214
|
+
/** The invoking agent, or the saved script that made a nested call. */
|
|
1215
|
+
export type ScriptCaller =
|
|
1216
|
+
| { kind: "agent"; agentId: string }
|
|
1217
|
+
| { kind: "script"; agentId: string; scriptId?: string; objectId?: string }
|
|
1218
|
+
| null;
|
|
1219
|
+
|
|
1220
|
+
export abstract class DurableObject<S> {
|
|
1221
|
+
constructor(id: string);
|
|
1222
|
+
readonly id: string;
|
|
1223
|
+
state: S;
|
|
1224
|
+
abstract initialState(): S | Promise<S>;
|
|
1225
|
+
migrate?(state: unknown, fromVersion: number): S | Promise<S>;
|
|
1226
|
+
destroy(): void;
|
|
1227
|
+
static idleTtlSec?: number;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1213
1230
|
export interface ScriptContext {
|
|
1231
|
+
/** Frozen caller identity supplied by the host. */
|
|
1232
|
+
caller: ScriptCaller;
|
|
1214
1233
|
run?: ScriptRunContext;
|
|
1215
1234
|
step?: ScriptWorkflowSteps;
|
|
1216
1235
|
swarm: SwarmSdk & { config: SwarmConfig };
|
package/src/slack/actions.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { registerApprovalActionHandlers } from "./approval-actions";
|
|
|
9
9
|
import { buildCancelledBlocks, getTaskLink } from "./blocks";
|
|
10
10
|
import { resolveSlackUserId } from "./enrich";
|
|
11
11
|
import { EXTERNAL_CHANNEL_BLOCKED_REPLY, shouldBlockChannel } from "./external-channel";
|
|
12
|
+
import { isUserAllowed } from "./handlers";
|
|
12
13
|
import { ignoreSlackInbound, noteSlackInboundSideEffect } from "./inbound-dispatch";
|
|
13
14
|
import { ensureSlackThreadPresentation, isSlackRenderV2Enabled } from "./render-v2";
|
|
14
15
|
import { getAgentDisplayName, getAgentSlackIcon } from "./responses";
|
|
@@ -141,6 +142,11 @@ export function registerActionHandlers(app: App): void {
|
|
|
141
142
|
return ignoreSlackInbound("external_channel");
|
|
142
143
|
}
|
|
143
144
|
|
|
145
|
+
if (!(await isUserAllowed(client, body.user.id, body.user.team_id))) {
|
|
146
|
+
console.log(`[Slack] Ignoring follow-up from unauthorized user ${body.user.id}`);
|
|
147
|
+
return ignoreSlackInbound("unauthorized_user");
|
|
148
|
+
}
|
|
149
|
+
|
|
144
150
|
const lead = await getLeadAgent();
|
|
145
151
|
// Resolve via the shared cascade. Sample context = the modal callback ID
|
|
146
152
|
// so operators can see *which* modal-submit triggered an unmapped entry.
|
|
@@ -254,6 +260,24 @@ export function registerActionHandlers(app: App): void {
|
|
|
254
260
|
const task = await getTaskById(taskId);
|
|
255
261
|
if (!task) return;
|
|
256
262
|
|
|
263
|
+
// The click must come from the channel the task belongs to, from a sender the
|
|
264
|
+
// message handler would accept.
|
|
265
|
+
const channelId = "channel" in body ? body.channel?.id : undefined;
|
|
266
|
+
if (!channelId || channelId !== task.slackChannelId) {
|
|
267
|
+
console.log(`[Slack] Ignoring cancel of task ${taskId} from channel ${channelId}`);
|
|
268
|
+
return ignoreSlackInbound("cancel_channel_mismatch");
|
|
269
|
+
}
|
|
270
|
+
if (await shouldBlockChannel(client, channelId)) {
|
|
271
|
+
await postExternalChannelNotice(client, channelId, body.user.id);
|
|
272
|
+
return ignoreSlackInbound("external_channel");
|
|
273
|
+
}
|
|
274
|
+
if (!(await isUserAllowed(client, body.user.id, body.user.team_id))) {
|
|
275
|
+
console.log(
|
|
276
|
+
`[Slack] Ignoring cancel of task ${taskId} from unauthorized user ${body.user.id}`,
|
|
277
|
+
);
|
|
278
|
+
return ignoreSlackInbound("unauthorized_user");
|
|
279
|
+
}
|
|
280
|
+
|
|
257
281
|
// Cancel the task in DB
|
|
258
282
|
const cancelled = await cancelTask(taskId, "Cancelled via Slack", { statusKind: "user" });
|
|
259
283
|
if (!cancelled) {
|
package/src/slack/assistant.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { resolveSlackUserId, rewriteSlackMentions } from "./enrich";
|
|
|
8
8
|
import { wasEventSeen } from "./event-dedup";
|
|
9
9
|
import { shouldBlockChannel } from "./external-channel";
|
|
10
10
|
import type { SlackFile } from "./files";
|
|
11
|
+
import { isUserAllowed } from "./handlers";
|
|
11
12
|
import {
|
|
12
13
|
ignoreSlackInbound,
|
|
13
14
|
isAdmittedSlackDelivery,
|
|
@@ -158,6 +159,13 @@ export function createAssistant(
|
|
|
158
159
|
return ignoreSlackInbound("external_channel");
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
// Same SLACK_ALLOWED_* sender gate as the channel message handler.
|
|
163
|
+
const sender = message as { user?: string; user_team?: string };
|
|
164
|
+
if (!(await isUserAllowed(client, sender.user ?? "", sender.user_team))) {
|
|
165
|
+
console.log(`[Slack] Ignoring assistant message from unauthorized user ${sender.user}`);
|
|
166
|
+
return ignoreSlackInbound("unauthorized_user");
|
|
167
|
+
}
|
|
168
|
+
|
|
161
169
|
// Wrap setStatus/setTitle to swallow all errors gracefully.
|
|
162
170
|
// These calls can fail for various reasons (no_permission when the thread
|
|
163
171
|
// wasn't started by the assistant, network errors, etc.), so we log and continue.
|
package/src/slack/blocks.ts
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
import type { AgentTaskStatus, TaskAttachment } from "../types";
|
|
9
9
|
import { getAppUrl } from "../utils/constants";
|
|
10
10
|
import { taskAttachmentDisplayUrl } from "../utils/task-attachment-links";
|
|
11
|
+
import { UI_SPEC_ACTION_PREFIX } from "../utils/task-ui-spec";
|
|
12
|
+
import { APPROVAL_ACTION_PREFIX } from "./approval-buttons";
|
|
11
13
|
import { completedStatusIcon, iconPrefix } from "./reaction-shortcode";
|
|
12
14
|
|
|
13
15
|
// Slack limits section text to 3000 chars; we use 2900 for safety.
|
|
@@ -129,6 +131,39 @@ export function splitSlackSectionText(text: string): string[] {
|
|
|
129
131
|
return chunks;
|
|
130
132
|
}
|
|
131
133
|
|
|
134
|
+
/** Action ids the swarm's own Slack handlers act on (see `actions.ts`, `approval-actions.ts`). */
|
|
135
|
+
const RESERVED_ACTION_IDS = new Set(["cancel_task", "follow_up_task", "view_task_logs"]);
|
|
136
|
+
const RESERVED_ACTION_PREFIXES = [APPROVAL_ACTION_PREFIX, UI_SPEC_ACTION_PREFIX];
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The first `action_id` in caller-supplied Block Kit that one of the swarm's
|
|
140
|
+
* own action handlers would act on, or `undefined` when there is none.
|
|
141
|
+
* Searches nested objects and arrays.
|
|
142
|
+
*/
|
|
143
|
+
export function findReservedActionId(value: unknown): string | undefined {
|
|
144
|
+
if (Array.isArray(value)) {
|
|
145
|
+
for (const item of value) {
|
|
146
|
+
const found = findReservedActionId(item);
|
|
147
|
+
if (found) return found;
|
|
148
|
+
}
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
if (!value || typeof value !== "object") return undefined;
|
|
152
|
+
for (const [key, child] of Object.entries(value)) {
|
|
153
|
+
if (
|
|
154
|
+
key === "action_id" &&
|
|
155
|
+
typeof child === "string" &&
|
|
156
|
+
(RESERVED_ACTION_IDS.has(child) ||
|
|
157
|
+
RESERVED_ACTION_PREFIXES.some((prefix) => child.startsWith(prefix)))
|
|
158
|
+
) {
|
|
159
|
+
return child;
|
|
160
|
+
}
|
|
161
|
+
const found = findReservedActionId(child);
|
|
162
|
+
if (found) return found;
|
|
163
|
+
}
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
|
|
132
167
|
// Slack's hard cap on section text.
|
|
133
168
|
const SLACK_SECTION_TEXT_LIMIT = 3000;
|
|
134
169
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { getSlackApp } from "./app";
|
|
2
|
+
import { shouldBlockChannel } from "./external-channel";
|
|
3
|
+
import { isUserAllowed, LOOKUP_USER_TEAM } from "./handlers";
|
|
2
4
|
|
|
3
5
|
export interface ChannelMessage {
|
|
4
6
|
channelId: string;
|
|
@@ -70,6 +72,9 @@ export async function fetchChannelActivity(
|
|
|
70
72
|
const cursor = cursors.get(channelId);
|
|
71
73
|
|
|
72
74
|
try {
|
|
75
|
+
// Same external-channel gate as the message handler (SLACK_BLOCK_EXTERNAL_CHANNELS).
|
|
76
|
+
if (await shouldBlockChannel(client, channelId)) continue;
|
|
77
|
+
|
|
73
78
|
// Cold-start: no cursor for this channel — seed it without triggering
|
|
74
79
|
if (!cursor) {
|
|
75
80
|
const seedResult = await client.conversations.history({
|
|
@@ -100,6 +105,8 @@ export async function fetchChannelActivity(
|
|
|
100
105
|
if (!msg.text?.trim() || !msg.user) continue;
|
|
101
106
|
// Skip thread replies (only top-level channel messages)
|
|
102
107
|
if (msg.thread_ts && msg.thread_ts !== msg.ts) continue;
|
|
108
|
+
// Same SLACK_ALLOWED_* sender gate as the message handler.
|
|
109
|
+
if (!(await isUserAllowed(client, msg.user, LOOKUP_USER_TEAM))) continue;
|
|
103
110
|
|
|
104
111
|
messages.push({
|
|
105
112
|
channelId,
|