@desplega.ai/agent-swarm 2.13.4 → 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-zrk9k0n7.js → acp-targets-23exz4z4.js} +10 -10
- package/dist/{actions-acqqj9jn.js → actions-zcr25x27.js} +61 -40
- package/dist/{agent-fs-provision-zmaykqnd.js → agent-fs-provision-7fa9e12e.js} +4 -4
- package/dist/{amp-adapter-a7ts8tmw.js → amp-adapter-s7ytmv6b.js} +3 -3
- package/dist/{anthropic-messages-88b7s3n9.js → anthropic-messages-vdd1zmha.js} +10 -10
- package/dist/{app-tmwa442h.js → app-5d3sz1hy.js} +7 -7
- package/dist/{approval-notifications-6psaaaye.js → approval-notifications-7qgkzkzx.js} +8 -8
- package/dist/{assistant-564v6emv.js → assistant-p2yvhc3j.js} +37 -32
- package/dist/{boot-args-schema-n099e0f2.js → boot-args-schema-ry6cb0p7.js} +1 -1
- package/dist/{boot-reembed-epvg4fp9.js → boot-reembed-2hkm3vz2.js} +1 -1
- package/dist/{boot-reembed-chx66qfk.js → boot-reembed-c9643ms3.js} +1 -1
- package/dist/{boot-scrub-sweep-dhkfp0a7.js → boot-scrub-sweep-3ycxr51t.js} +2 -2
- package/dist/{boot-seeds-m74fc07r.js → boot-seeds-2hzvvzg0.js} +4 -4
- package/dist/{boxd-451q55ys.js → boxd-9py3x0jb.js} +2 -2
- package/dist/{claude-adapter-hw63yj3j.js → claude-adapter-dnkww93e.js} +9 -9
- package/dist/{claude-managed-adapter-z5s7fx6p.js → claude-managed-adapter-yk0cr5x6.js} +4 -4
- package/dist/{claude-managed-setup-wee1762m.js → claude-managed-setup-4byxpp47.js} +5 -5
- package/dist/{claude-sdk-session-cktyqkpk.js → claude-sdk-session-4wf3dbvs.js} +13163 -12195
- package/dist/{cli-5rxsb3wq.js → cli-096aftq6.js} +12 -7
- package/dist/{cli-5rgm8p39.js → cli-0e914dp9.js} +3 -3
- package/dist/{cli-bzcwwebm.js → cli-0h6m6z5g.js} +1 -1
- package/dist/{cli-cah298e5.js → cli-0k7ppk9k.js} +231 -124
- package/dist/{cli-ja450998.js → cli-1nfabrt4.js} +8 -8
- package/dist/{cli-jzerrzgc.js → cli-2414h5r9.js} +8 -8
- package/dist/{cli-b768ek79.js → cli-24wervhz.js} +38 -0
- package/dist/{cli-93n305hm.js → cli-2ayk9gn8.js} +2 -2
- package/dist/{cli-kr0jpw9c.js → cli-2ckwgs7q.js} +1 -1
- package/dist/{cli-d5pc8ep0.js → cli-2savn6mm.js} +11 -100
- package/dist/{cli-jbrc98qb.js → cli-2zjxake1.js} +4 -4
- package/dist/{cli-4q2c8rxw.js → cli-37p61fcg.js} +15 -9
- package/dist/{cli-2vp0z049.js → cli-39t9d248.js} +1 -1
- package/dist/{cli-sa02jsqt.js → cli-3mhdmcd4.js} +1 -1
- package/dist/{cli-x2cem5vy.js → cli-3wsabyt0.js} +2 -2
- package/dist/{cli-dqgnbnxs.js → cli-466jjrwe.js} +16 -2
- package/dist/{cli-zhwjdhjr.js → cli-6ajyhxh7.js} +2 -2
- package/dist/{cli-3bxrrh53.js → cli-6yy4fepf.js} +4 -4
- package/dist/{cli-hhtbandk.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-m1sns1da.js → cli-7w1fs01q.js} +2 -2
- package/dist/{cli-xwsm6xkr.js → cli-84wxwt3z.js} +1 -1
- package/dist/{cli-qzz6tz8s.js → cli-84xn7bgz.js} +1 -1
- package/dist/{cli-49aq3cyn.js → cli-879txsac.js} +5 -5
- package/dist/{cli-bv4vvnmg.js → cli-8vbxjzk0.js} +3 -3
- package/dist/{cli-7by7vp6m.js → cli-91amj3md.js} +3 -3
- package/dist/{cli-60dwk8tx.js → cli-930zbczq.js} +3 -3
- package/dist/{cli-7g3fg4gf.js → cli-9fwznq4p.js} +10 -10
- package/dist/{cli-4pbwg7sn.js → cli-9j1t3kf6.js} +2 -2
- package/dist/{cli-tzw1jr2t.js → cli-9j47sgzy.js} +2 -2
- package/dist/{cli-0fgvnb0x.js → cli-ad00h1st.js} +7 -7
- package/dist/{cli-kj84fqxz.js → cli-adzmmcvf.js} +19 -7
- package/dist/{cli-3tzmh38q.js → cli-ayxxkk3p.js} +68 -25
- package/dist/{cli-4vynxtrb.js → cli-bqfx72e6.js} +10 -3
- package/dist/{cli-8cas2xvp.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-jg5txpm6.js → cli-dy754erz.js} +83 -1
- package/dist/{cli-tsc3pdfd.js → cli-edxfzgah.js} +4 -4
- package/dist/{cli-hyqksecw.js → cli-ejnhs815.js} +15 -15
- package/dist/{cli-k0nebh10.js → cli-enavhq6r.js} +1 -1
- package/dist/{cli-ea7nz50q.js → cli-f2rwt43y.js} +14 -14
- package/dist/{cli-zjdhrzm0.js → cli-f9g96z28.js} +8 -8
- package/dist/{cli-rmgvwcmy.js → cli-fww016hh.js} +534 -70
- package/dist/{cli-rv3y60bt.js → cli-g6a696c0.js} +4 -4
- package/dist/{cli-z1vam71h.js → cli-gc6b94tj.js} +2 -2
- package/dist/{cli-p436yrzp.js → cli-gcyws2bp.js} +2 -2
- package/dist/{cli-srktrbby.js → cli-hzhv7yac.js} +1 -1
- package/dist/{cli-0p76my9q.js → cli-jcnc5ret.js} +44 -32
- package/dist/{cli-tr19nyn9.js → cli-jgq9xptq.js} +7 -7
- package/dist/{cli-pz1dp12c.js → cli-jwnac23b.js} +1 -1
- package/dist/{cli-904wk98s.js → cli-kc7vd07m.js} +917 -350
- package/dist/{cli-t0jmkcah.js → cli-kg63yp1r.js} +14 -14
- package/dist/{cli-ts5yv7dn.js → cli-krk8y8c7.js} +835 -157
- package/dist/{cli-jyhbvdga.js → cli-m0ea8ggd.js} +8 -10
- package/dist/{cli-944w9wb4.js → cli-md4tn21h.js} +20 -15
- package/dist/{cli-zexwhj3f.js → cli-mv8ft7b0.js} +10 -9
- package/dist/{cli-phdzn699.js → cli-mw1tmn3x.js} +217 -27
- package/dist/{cli-5ashycw3.js → cli-njvpngc6.js} +3 -3
- package/dist/{cli-9ah37a8a.js → cli-phe2vcw5.js} +10 -7
- package/dist/{cli-eds5xnsz.js → cli-phmy14hb.js} +2 -2
- package/dist/{cli-n1kjs58m.js → cli-pq0kv31y.js} +5 -5
- package/dist/{cli-pz1nq5xm.js → cli-q457ga28.js} +6 -6
- package/dist/{cli-s33bzmk0.js → cli-q5n3deaf.js} +1 -1
- package/dist/{cli-4fpa0zns.js → cli-qkbevqer.js} +3 -3
- package/dist/{cli-29h5239w.js → cli-qrwjk4xy.js} +5 -5
- package/dist/{cli-kezzteka.js → cli-r04ve9xw.js} +1 -1
- package/dist/{cli-3xqad83h.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-fkpnx3vf.js → cli-rs1rzwp4.js} +3 -2
- package/dist/{cli-h9d3sdnc.js → cli-rzbsh6bw.js} +1 -1
- package/dist/{cli-94gx6ze9.js → cli-s4pccby1.js} +1 -1
- package/dist/{cli-cq4am6vg.js → cli-shyhb4t5.js} +10 -10
- package/dist/{cli-gtj12v95.js → cli-srq69pn1.js} +1 -1
- package/dist/{cli-azj9t1f9.js → cli-tc165vrb.js} +48 -5
- package/dist/{cli-gse7bp3z.js → cli-v4z5v3jd.js} +300 -81
- package/dist/{cli-p3knvk62.js → cli-vxmmttmt.js} +132 -53
- package/dist/{cli-404am6f3.js → cli-w4bvtxet.js} +7 -7
- package/dist/{cli-gkv0r2hq.js → cli-wd7b5hgc.js} +71 -9
- package/dist/{cli-akm6y2a8.js → cli-wvbaq052.js} +1 -1
- package/dist/{cli-ywy8yz6t.js → cli-wvgg7r4j.js} +2 -2
- package/dist/{cli-ka48vpev.js → cli-wym6rxgt.js} +165 -6
- package/dist/{cli-nc4pbwmp.js → cli-yd7e590v.js} +12 -12
- package/dist/{cli-3zrwrnz7.js → cli-yjb3cddd.js} +1 -1
- package/dist/{cli-7gbff32z.js → cli-z8t4485r.js} +2 -2
- package/dist/{cli-hdhpdrka.js → cli-ze1ndjs4.js} +4 -6
- package/dist/{cli-50wa8k4h.js → cli-zy9bb22b.js} +1 -2
- package/dist/cli.js +28 -28
- package/dist/{codex-adapter-2fs2c0n6.js → codex-adapter-eq61radw.js} +8 -8
- package/dist/{codex-hook-jxjv6dy5.js → codex-hook-8nmepvz6.js} +3 -3
- package/dist/{codex-login-ktfg1cxk.js → codex-login-vbd9707w.js} +1 -1
- package/dist/{codex-session-runner-r55tmx4c.js → codex-session-runner-rfx355h4.js} +9 -9
- package/dist/{commands-0mxdy9x8.js → commands-d1z0sx62.js} +3 -3
- package/dist/{controller-g3vkfhr4.js → controller-9hz6d8x3.js} +4 -4
- package/dist/{controllers-connect-4wdmncqt.js → controllers-connect-tz07d2xr.js} +24 -25
- package/dist/core-dynsv289.js +41 -0
- package/dist/{cursor-adapter-t9qb96q2.js → cursor-adapter-ef22ze3j.js} +2 -2
- package/dist/{db-487vvyv9.js → db-gd81d68c.js} +3 -3
- package/dist/{db-76p7w3gr.js → db-vrckks6q.js} +4 -2
- package/dist/{devin-adapter-3bp6rape.js → devin-adapter-kdt6a2bh.js} +1 -1
- package/dist/{dispatcher-64rp6w67.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-dc8f6ctq.js → e2b-05kn3kpq.js} +16 -5
- package/dist/{e2b-3ykbe805.js → e2b-dm9r8hpy.js} +3 -3
- package/dist/{easter-egg-3d-jrrwyf55.js → easter-egg-3d-sg21j15g.js} +1 -1
- package/dist/{embedding-space-001hhhpk.js → embedding-space-zsdw37bb.js} +13 -23
- package/dist/{embeddings-esj19cnw.js → embeddings-p4e3e1m6.js} +1 -1
- package/dist/{event-bus-7gbsr0g4.js → event-bus-tvf2grf4.js} +1 -1
- package/dist/{execute-301hkxqg.js → execute-nztd0af0.js} +1 -1
- package/dist/{external-channel-w10e2j05.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-tbrj7vhq.js → heartbeat-vfb1gy84.js} +24 -25
- package/dist/{hook-tx917rqw.js → hook-ctz0xmp3.js} +11 -11
- package/dist/{hook-3am1sq68.js → hook-eh52p7yd.js} +6 -6
- package/dist/{http-3rmemtqy.js → http-zregegrx.js} +902 -198
- package/dist/{index-s7xtvc0f.js → index-5kx15d19.js} +1 -1
- package/dist/index-7w8p6em0.js +41 -0
- package/dist/index-evay0xyk.js +17 -0
- package/dist/{index-2jw11t8s.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-gfnq66t1.js → index-x9qf8dg7.js} +294 -29
- package/dist/index-y3s0xp2v.js +43 -0
- package/dist/{k8s-36gfn847.js → k8s-ejkk0aw7.js} +2 -2
- package/dist/{keepalive-9px3t7qj.js → keepalive-zdqay870.js} +4 -5
- package/dist/lead-6cscw8a5.js +82 -0
- package/dist/{maintenance-vwqjwst6.js → maintenance-t5ndg11m.js} +1 -1
- package/dist/{node-2wfcey7d.js → node-0as4n1ef.js} +3 -3
- package/dist/{node-zd6shky9.js → node-dhxbt01p.js} +3 -3
- package/dist/{node-z67yjre7.js → node-jkdd5w7m.js} +290 -70
- package/dist/{node-hjn5n1yp.js → node-t0ct2zpw.js} +3 -5
- package/dist/{oauth-refresh-sweep-yqry3wn4.js → oauth-refresh-sweep-y9zyd7t6.js} +3 -4
- package/dist/{object-webhooks-8s1wtths.js → object-webhooks-mkca91s0.js} +7 -7
- package/dist/{onboard-hb8czx0p.js → onboard-ss995244.js} +11 -9
- package/dist/{opencode-adapter-djd6m6dk.js → opencode-adapter-mwpz0278.js} +8 -8
- package/dist/{otel-impl-2ymwyczz.js → otel-impl-6n6vva3x.js} +2 -2
- package/dist/{pending-nxavtvx7.js → pending-2sxh1t6j.js} +22 -23
- package/dist/{pi-mono-adapter-d2cpmcy4.js → pi-mono-adapter-sfb7zy43.js} +13 -13
- package/dist/{pricing-refresh-1yz8jkqv.js → pricing-refresh-h79bg4cf.js} +2 -2
- package/dist/{rbac-roles-7s6m31xw.js → rbac-roles-ckq0czp4.js} +2 -2
- package/dist/{rbac-roles-dbpx0x9v.js → rbac-roles-jg2e260w.js} +3 -3
- package/dist/{render-v2-7y20rjrn.js → render-v2-ymbshmn0.js} +7 -7
- package/dist/{resume-wz546x47.js → resume-jdhnt4jk.js} +10 -10
- package/dist/{runtime-cb5bd9tz.js → runtime-y28jhhnf.js} +1 -1
- package/dist/{session-access-4vcft8kq.js → session-access-k4ta5hvp.js} +5 -5
- package/dist/{session-source-backfill-57b50tpw.js → session-source-backfill-528j4s8j.js} +3 -3
- package/dist/{setup-e1tevjyj.js → setup-d6pj82fr.js} +15 -6
- package/dist/thread-buffer-9w6x5zec.js +40 -0
- package/dist/{tree-visibility-07wf1nct.js → tree-visibility-kjxv3nxk.js} +2 -2
- package/dist/{user-merge-jobs-n20qpv6s.js → user-merge-jobs-rabbncf6.js} +3 -3
- package/dist/{virtual-modules-6fxmn1yv.js → virtual-modules-22k51txd.js} +3 -3
- package/dist/{work-objects-eg7y48pe.js → work-objects-xtjbar3r.js} +26 -30
- package/dist/{worker-follow-up-jnvnnf2b.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 +633 -25
- 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/apps/sync.ts +20 -5
- package/src/azure-devops/boards-sync.ts +1 -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 +38 -1
- package/src/be/db/task-idempotency.ts +63 -0
- package/src/be/db/tasks/read.ts +27 -1
- package/src/be/db/tasks/write.ts +51 -14
- package/src/be/db/users/avatar.ts +12 -0
- package/src/be/db/workflow-idempotency.ts +6 -1
- package/src/be/db/workflows/read.ts +79 -0
- package/src/be/db.ts +129 -152
- 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/344_user_avatar.sql +4 -0
- package/src/be/migrations/345_task_status_kind.sql +6 -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/primitives/object-embed.ts +2 -2
- package/src/be/primitives/objects.ts +2 -2
- package/src/be/repo-checked-update.ts +58 -5
- package/src/be/requester-timezone.ts +10 -0
- package/src/be/runtime-pools/supervisor.ts +1 -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 +33 -8
- 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 +91 -7
- package/src/be/users.ts +33 -12
- package/src/bitbucket/handlers.ts +1 -1
- package/src/comb/review-batch.ts +16 -5
- package/src/commands/context-preamble.ts +237 -0
- package/src/commands/credential-outcome-report.ts +96 -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 +72 -10
- package/src/commands/setup.tsx +17 -3
- package/src/event-waits/github.ts +39 -6
- package/src/event-waits/index.ts +4 -2
- package/src/event-waits/types.ts +10 -3
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/github/app.ts +177 -13
- package/src/github/handlers.ts +7 -2
- package/src/github/pull-request-state.ts +100 -11
- package/src/gitlab/handlers.ts +2 -2
- package/src/heartbeat/heartbeat.ts +6 -1
- package/src/hooks/hook.ts +8 -2
- package/src/hooks/native-tool-hooks.ts +4 -2
- package/src/http/api-keys.ts +26 -0
- package/src/http/apps.ts +82 -42
- package/src/http/asset-key-write.ts +45 -0
- package/src/http/assets.ts +4 -3
- package/src/http/comb.ts +21 -5
- package/src/http/config.ts +8 -4
- package/src/http/github-token.ts +27 -6
- 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/pages.ts +4 -10
- package/src/http/repos.ts +27 -11
- package/src/http/request-principal.ts +27 -1
- package/src/http/schedules.ts +42 -14
- 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/sessions.ts +7 -2
- package/src/http/skills.ts +70 -0
- package/src/http/status.ts +2 -0
- package/src/http/tasks.ts +115 -19
- package/src/http/trackers/jira.ts +18 -3
- package/src/http/trackers/linear.ts +3 -0
- package/src/http/users.ts +5 -0
- package/src/http/webhooks.ts +19 -1
- package/src/http/workflows.ts +5 -10
- package/src/integrations/chat-sdk/commands.ts +3 -1
- package/src/jira/sync.ts +1 -1
- package/src/kv-limits.ts +2 -0
- package/src/kv-reserved-namespaces.ts +25 -2
- package/src/linear/sync.ts +5 -3
- package/src/prompts/session-templates.ts +50 -0
- package/src/prompts/session-turns.ts +30 -0
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +5 -0
- package/src/providers/claude-managed-adapter.ts +14 -0
- package/src/providers/claude-sdk-session.ts +19 -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/deferred-task-waits.ts +74 -13
- 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 +12 -2
- package/src/scripts-runtime/types/stdlib.d.ts +27 -1
- package/src/scripts-runtime/types/swarm-extension.d.ts +20 -2
- package/src/scripts-runtime/types/swarm-sdk.d.ts +27 -1
- package/src/slack/actions.ts +25 -1
- 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 +403 -17
- 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/api-drain-worker-e2e.test.ts +0 -2
- package/src/tests/approval-auto-cancellation-migration.test.ts +8 -19
- package/src/tests/approval-card-resolution.test.ts +2 -17
- package/src/tests/approval-requests-notifications.test.ts +41 -27
- package/src/tests/approval-requests.test.ts +137 -369
- package/src/tests/apps-script-types.test.ts +63 -16
- package/src/tests/apps-sort-order.test.ts +87 -0
- package/src/tests/apps-sync-engine.test.ts +5 -3
- package/src/tests/apps-table-filters-migration.test.ts +44 -25
- package/src/tests/bedrock-model-groups.test.ts +4 -0
- package/src/tests/bitbucket-handlers.test.ts +2 -0
- package/src/tests/channel-activity.test.ts +9 -0
- package/src/tests/chat-sdk-commands.test.ts +1 -0
- package/src/tests/chatgpt-subscription-model-groups.test.ts +4 -0
- package/src/tests/claude-adapter.test.ts +35 -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-adapter.test.ts +3 -92
- package/src/tests/codex-gpt6-release.test.ts +4 -9
- package/src/tests/codex-oauth-credential-info.test.ts +35 -18
- package/src/tests/codex-oauth.test.ts +0 -6
- package/src/tests/codex-pool.test.ts +5 -214
- package/src/tests/codex-rate-limit-parse.test.ts +0 -7
- package/src/tests/codex-swarm-events.test.ts +11 -54
- package/src/tests/comb-review-batch.test.ts +17 -4
- package/src/tests/comb-status.test.ts +1 -0
- package/src/tests/db-client-busy-retry.test.ts +49 -16
- 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 +24 -1
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/e2b-dispatch.test.ts +13 -1
- package/src/tests/e2e-shards.test.ts +9 -9
- package/src/tests/enabled-tools.test.ts +0 -2
- package/src/tests/entrypoint-mcp-config.test.ts +642 -0
- package/src/tests/fixtures/base-prompt-baseline.json +6 -6
- 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/github-app-worker-auth-helper.test.ts +147 -1
- package/src/tests/gitlab-handlers.test.ts +2 -0
- package/src/tests/heartbeat-jev-gate.test.ts +9 -241
- package/src/tests/heartbeat-reroute-decision.test.ts +2 -0
- package/src/tests/heartbeat-supersede-resume.test.ts +2 -0
- package/src/tests/heartbeat.test.ts +1 -0
- 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/key-usage-selection.test.ts +302 -0
- package/src/tests/memory-e2e.test.ts +34 -103
- package/src/tests/memory-key-paths.test.ts +5 -0
- package/src/tests/memory-rater-llm.test.ts +33 -149
- package/src/tests/memory-store.test.ts +24 -125
- package/src/tests/memory.test.ts +31 -100
- package/src/tests/merge-gate-detect-changes.test.ts +108 -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/otel-service-name.test.ts +0 -9
- package/src/tests/otel-session-cost-metrics.test.ts +1 -38
- package/src/tests/pool-session-logs.test.ts +8 -42
- package/src/tests/pre-push-affected-tests.test.ts +106 -0
- package/src/tests/prompt-template-session.test.ts +3 -0
- package/src/tests/provider-runtime-dependencies.test.ts +26 -15
- package/src/tests/routing-affinity-inventory.test.ts +11 -0
- package/src/tests/runner-api-drain.test.ts +2 -17
- package/src/tests/runner-context-preamble.test.ts +202 -0
- package/src/tests/runner-repo-clone-args.test.ts +116 -0
- package/src/tests/runner-terminal-window-report.test.ts +132 -0
- package/src/tests/runtime-supervisor-failures.test.ts +1 -0
- package/src/tests/sandboxed-process.test.ts +26 -21
- package/src/tests/schedule-http-triage-tools.test.ts +12 -9
- package/src/tests/scheduled-tasks.test.ts +14 -51
- 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/script-executor-conformance.test.ts +4 -48
- package/src/tests/script-executor-quickjs-pool.test.ts +9 -7
- package/src/tests/script-native-startup.test.ts +21 -25
- package/src/tests/scripts-namespaces.test.ts +3 -1
- package/src/tests/secret-rules.test.ts +4 -2
- 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-logs.test.ts +1 -260
- 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 +14 -152
- 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/task-cascade-fail.test.ts +1 -0
- package/src/tests/task-supersede-resume.test.ts +1 -0
- package/src/tests/test-proc.ts +5 -2
- package/src/tests/ui-spec-script-actions-config.test.ts +7 -3
- package/src/tests/window-stream-reporter.test.ts +122 -0
- package/src/tests/workflow-agent-task-retry.test.ts +1 -3
- package/src/tests/workflow-cascade-cancel.test.ts +1 -0
- package/src/tests/workflow-retry-v2.test.ts +34 -43
- package/src/tests/workflow-retry-validation.test.ts +8 -48
- package/src/tests/workflow-triggers-v2.test.ts +35 -11
- package/src/tests/worktree-reaper.test.ts +2 -2
- package/src/tools/app-patch.ts +6 -2
- package/src/tools/app-upsert.ts +8 -4
- package/src/tools/cancel-task.ts +2 -2
- package/src/tools/defer-task.ts +24 -79
- package/src/tools/get-task-details.ts +8 -4
- package/src/tools/get-tasks.ts +13 -2
- 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/manage-user.ts +9 -0
- 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/store-progress.ts +5 -3
- 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 +101 -2
- package/src/utils/constants.ts +32 -0
- package/src/utils/credentials.ts +42 -5
- package/src/utils/deferral-time.ts +61 -0
- package/src/utils/error-tracker.ts +6 -0
- package/src/utils/key-usage.ts +114 -0
- package/src/utils/request-auth-context.ts +15 -16
- package/src/utils/sandboxed-process.ts +1 -0
- 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/resume.ts +5 -2
- 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 +6 -2
- package/templates/skills/apps/content.md +6 -2
- package/templates/skills/boards-and-sheets/content.md +4 -2
- package/templates/skills/code-quality/content.md +4 -4
- package/templates/skills/pages/content.md +7 -0
- 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 +8 -0
- package/templates/skills/swarm-scripts/SKILL.md +45 -0
- package/templates/skills/swarm-scripts/content.md +45 -0
- package/dist/acp-adapter-mr4temec.js +0 -17
- package/dist/cli-1vmhnncj.js +0 -173
- package/dist/cli-kj0hyr43.js +0 -51
- package/dist/cli-ysv0k1we.js +0 -459
- package/dist/core-gsvj5f3z.js +0 -42
- package/dist/dsh-adapter-8abzqk5c.js +0 -9
- package/dist/fx-adapter-4sjrbdne.js +0 -20
- package/dist/grok-adapter-3a0ezfee.js +0 -20
- package/dist/handlers-ef3k11hb.js +0 -41
- package/dist/index-aetfyx6p.js +0 -13
- package/dist/index-e6bq0exk.js +0 -42
- package/dist/index-hf2k1vge.js +0 -39
- package/dist/index-taxmejj3.js +0 -44
- package/dist/lead-5vt6f174.js +0 -83
- package/dist/thread-buffer-686pa1p1.js +0 -42
- package/dist/worker-4vp616ms.js +0 -83
- package/src/tests/apps-table-selection-migration.test.ts +0 -95
- package/src/tests/extensions-example-heartbeat-remediate.test.ts +0 -69
- package/src/tests/extensions-example-rewrite-and-suppress.test.ts +0 -70
|
@@ -52,7 +52,7 @@ import { createStandaloneScheduleTask, prepareStandaloneScheduleTask } from "./s
|
|
|
52
52
|
export { createStandaloneScheduleTask } from "./schedule-task";
|
|
53
53
|
|
|
54
54
|
let schedulerInterval: ReturnType<typeof setInterval> | null = null;
|
|
55
|
-
let schedulerRun:
|
|
55
|
+
let schedulerRun: AbortController | null = null;
|
|
56
56
|
let isProcessing = false;
|
|
57
57
|
let lastDeferredReapAt = 0;
|
|
58
58
|
const DEFERRED_REAP_INTERVAL_MS = 60 * 60 * 1000;
|
|
@@ -349,13 +349,24 @@ async function throwIfWorkflowNeedsSetup(scheduleId: string, runIds: string[]):
|
|
|
349
349
|
* Claim the snapshot's occurrence under BEGIN IMMEDIATE. A competing poller,
|
|
350
350
|
* recovery pass, or schedule edit invalidates it before any target is dispatched.
|
|
351
351
|
*/
|
|
352
|
-
async function claimScheduleOccurrence(
|
|
352
|
+
async function claimScheduleOccurrence(
|
|
353
|
+
snapshot: ScheduledTask,
|
|
354
|
+
extraTags: string[],
|
|
355
|
+
signal?: AbortSignal,
|
|
356
|
+
) {
|
|
357
|
+
if (signal?.aborted) return null;
|
|
353
358
|
// Run extension pre-hooks before opening the claim transaction. The snapshot
|
|
354
359
|
// guard below still prevents a moved ceiling from consuming this preparation.
|
|
355
360
|
const preparedWait = await prepareDeferredTaskWait(snapshot.id, "ceiling", extraTags);
|
|
361
|
+
if (signal?.aborted) return null;
|
|
356
362
|
return getDbClient().transaction(async () => {
|
|
357
363
|
const current = await getScheduledTaskById(snapshot.id);
|
|
358
|
-
if (
|
|
364
|
+
if (
|
|
365
|
+
signal?.aborted ||
|
|
366
|
+
!current?.enabled ||
|
|
367
|
+
!current.nextRunAt ||
|
|
368
|
+
current.nextRunAt !== snapshot.nextRunAt
|
|
369
|
+
) {
|
|
359
370
|
return null;
|
|
360
371
|
}
|
|
361
372
|
const schedule = renderScheduledTaskParams(current);
|
|
@@ -407,10 +418,11 @@ async function updateClaimedSchedule(claimed: ScheduledTask, updates: UpdateSche
|
|
|
407
418
|
}
|
|
408
419
|
|
|
409
420
|
/** Recover ONE catch-up occurrence per schedule, using the poller's same claim. */
|
|
410
|
-
async function recoverMissedSchedules(): Promise<void> {
|
|
421
|
+
async function recoverMissedSchedules(signal: AbortSignal): Promise<void> {
|
|
411
422
|
const now = Date.now();
|
|
412
423
|
const dueSchedules = await getDueScheduledTasks();
|
|
413
424
|
for (const schedule of dueSchedules) {
|
|
425
|
+
if (signal.aborted) return;
|
|
414
426
|
if (!schedule.nextRunAt) continue;
|
|
415
427
|
const missedBy = now - new Date(schedule.nextRunAt).getTime();
|
|
416
428
|
if (missedBy < 15000) continue; // Less than 15s — normal timing jitter
|
|
@@ -418,7 +430,7 @@ async function recoverMissedSchedules(): Promise<void> {
|
|
|
418
430
|
`[Scheduler] Recovering missed schedule "${schedule.name}" ` +
|
|
419
431
|
`(was due ${Math.round(missedBy / 1000)}s ago)`,
|
|
420
432
|
);
|
|
421
|
-
await executeSchedule(schedule, ["recovered"]);
|
|
433
|
+
await executeSchedule(schedule, ["recovered"], signal);
|
|
422
434
|
}
|
|
423
435
|
}
|
|
424
436
|
|
|
@@ -472,12 +484,13 @@ function getBackoffMs(consecutiveErrors: number): number {
|
|
|
472
484
|
export async function executeSchedule(
|
|
473
485
|
schedule: ScheduledTask,
|
|
474
486
|
extraTags: string[] = [],
|
|
487
|
+
signal?: AbortSignal,
|
|
475
488
|
): Promise<void> {
|
|
476
|
-
let claimed
|
|
489
|
+
let claimed: ScheduledTask | undefined;
|
|
477
490
|
let triggeredWorkflows = false;
|
|
478
491
|
const wasRecovered = extraTags.includes("recovered");
|
|
479
492
|
try {
|
|
480
|
-
const occurrence = await claimScheduleOccurrence(schedule, extraTags);
|
|
493
|
+
const occurrence = await claimScheduleOccurrence(schedule, extraTags, signal);
|
|
481
494
|
if (!occurrence) return;
|
|
482
495
|
({ schedule, claimed } = occurrence);
|
|
483
496
|
// The claim has committed before external workflow/script dispatch begins.
|
|
@@ -499,6 +512,7 @@ export async function executeSchedule(
|
|
|
499
512
|
wasRecovered,
|
|
500
513
|
});
|
|
501
514
|
} catch (err) {
|
|
515
|
+
if (signal?.aborted && !claimed) return;
|
|
502
516
|
if (err instanceof AutomationNeedsSetupError) {
|
|
503
517
|
// Preflight records its own diagnostic. The claim already advanced the
|
|
504
518
|
// cadence, so no retry/backoff or second schedule advancement is needed.
|
|
@@ -549,7 +563,7 @@ export async function executeSchedule(
|
|
|
549
563
|
console.log(`[Scheduler] Backing off "${schedule.name}" for ${backoff / 1000}s`);
|
|
550
564
|
}
|
|
551
565
|
|
|
552
|
-
await updateClaimedSchedule(claimed, updates);
|
|
566
|
+
await updateClaimedSchedule(claimed ?? schedule, updates);
|
|
553
567
|
telemetry.schedule("error", {
|
|
554
568
|
scheduleType: schedule.scheduleType,
|
|
555
569
|
triggeredWorkflows,
|
|
@@ -596,24 +610,25 @@ export function startScheduler(
|
|
|
596
610
|
return;
|
|
597
611
|
}
|
|
598
612
|
|
|
599
|
-
const run =
|
|
613
|
+
const run = new AbortController();
|
|
600
614
|
schedulerRun = run;
|
|
615
|
+
const { signal } = run;
|
|
601
616
|
executorRegistry = registry;
|
|
602
617
|
console.log(`[Scheduler] Starting with ${intervalMs}ms polling interval`);
|
|
603
618
|
|
|
604
619
|
// Both success and failure resume polling, but only after recovery settles.
|
|
605
|
-
//
|
|
620
|
+
// A stopped run cannot install a timer even if another run starts in the meantime.
|
|
606
621
|
void initDeferredTaskWaits()
|
|
607
|
-
.then(() => (
|
|
622
|
+
.then(() => (signal.aborted ? undefined : recoverMissedSchedules(signal)))
|
|
608
623
|
.catch((err) => console.error("[Scheduler] Recovery failed:", err))
|
|
609
624
|
.then(async () => {
|
|
610
|
-
if (
|
|
625
|
+
if (signal.aborted) return;
|
|
611
626
|
schedulerInterval = setInterval(() => {
|
|
612
|
-
void withLoopPath("scheduler.poll", () => processSchedules()).catch((err) =>
|
|
627
|
+
void withLoopPath("scheduler.poll", () => processSchedules(signal)).catch((err) =>
|
|
613
628
|
console.error("[Scheduler] Poll failed:", err),
|
|
614
629
|
);
|
|
615
630
|
}, intervalMs);
|
|
616
|
-
await processSchedules();
|
|
631
|
+
await processSchedules(signal);
|
|
617
632
|
})
|
|
618
633
|
.catch((err) => console.error("[Scheduler] Poll failed:", err));
|
|
619
634
|
|
|
@@ -640,24 +655,26 @@ export function startScheduler(
|
|
|
640
655
|
/**
|
|
641
656
|
* Process all due schedules (called by interval).
|
|
642
657
|
*/
|
|
643
|
-
async function processSchedules(): Promise<void> {
|
|
644
|
-
if (isProcessing) return;
|
|
658
|
+
async function processSchedules(signal: AbortSignal): Promise<void> {
|
|
659
|
+
if (signal.aborted || isProcessing) return;
|
|
645
660
|
isProcessing = true;
|
|
646
661
|
|
|
647
662
|
try {
|
|
648
663
|
await reconcileDeferredTaskWaits();
|
|
664
|
+
if (signal.aborted) return;
|
|
649
665
|
const dueSchedules = await getDueScheduledTasks();
|
|
650
666
|
|
|
651
667
|
for (const schedule of dueSchedules) {
|
|
668
|
+
if (signal.aborted) return;
|
|
652
669
|
try {
|
|
653
|
-
await executeSchedule(schedule);
|
|
670
|
+
await executeSchedule(schedule, [], signal);
|
|
654
671
|
} catch (err) {
|
|
655
672
|
console.error(`[Scheduler] Error executing "${schedule.name}":`, err);
|
|
656
673
|
}
|
|
657
674
|
}
|
|
658
675
|
|
|
659
676
|
// After dispatch, so a slow or failing reap never delays a due schedule.
|
|
660
|
-
if (Date.now() - lastDeferredReapAt >= DEFERRED_REAP_INTERVAL_MS) {
|
|
677
|
+
if (!signal.aborted && Date.now() - lastDeferredReapAt >= DEFERRED_REAP_INTERVAL_MS) {
|
|
661
678
|
lastDeferredReapAt = Date.now();
|
|
662
679
|
try {
|
|
663
680
|
const reaped = await reapSpentDeferredSchedules();
|
|
@@ -675,6 +692,7 @@ async function processSchedules(): Promise<void> {
|
|
|
675
692
|
* Stop the scheduler polling loop.
|
|
676
693
|
*/
|
|
677
694
|
export function stopScheduler(): void {
|
|
695
|
+
schedulerRun?.abort();
|
|
678
696
|
schedulerRun = null;
|
|
679
697
|
stopDeferredTaskWaits();
|
|
680
698
|
if (schedulerInterval) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import { mkdtemp, rm } from "node:fs/promises";
|
|
3
|
+
import { chown, mkdtemp, rm } from "node:fs/promises";
|
|
4
4
|
import { createServer, type Server, type Socket } from "node:net";
|
|
5
5
|
import { join, resolve } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { type RunDirFileCheck, readRunDirFile } from "../scripts-runtime/executors/native";
|
|
7
8
|
import { SCRIPT_SDK_RESPONSE_LIMIT_BYTES } from "../scripts-runtime/response-limit";
|
|
8
9
|
import type { ScriptRun } from "../types";
|
|
9
10
|
import {
|
|
@@ -15,7 +16,9 @@ import {
|
|
|
15
16
|
} from "../utils/process-group";
|
|
16
17
|
import {
|
|
17
18
|
buildSandboxedCommand,
|
|
19
|
+
DEFAULT_SANDBOX_LIMITS,
|
|
18
20
|
readStreamCapped,
|
|
21
|
+
resolveSandboxIdentity,
|
|
19
22
|
sandboxSpawnEnv,
|
|
20
23
|
} from "../utils/sandboxed-process";
|
|
21
24
|
import { handleCapabilityRequest, MAX_PENDING_CAPABILITY_CALLS } from "./capability-bridge";
|
|
@@ -170,6 +173,8 @@ export class LocalProcessScriptExecutor implements ScriptExecutor {
|
|
|
170
173
|
const { run, apiKey } = input;
|
|
171
174
|
const baseUrl = input.baseUrl.replace(/\/$/, "");
|
|
172
175
|
const harnessPath = getScriptWorkflowHarnessPath();
|
|
176
|
+
// Same identity as the native script executor: nobody:nogroup on a root API.
|
|
177
|
+
const runAs = resolveSandboxIdentity();
|
|
173
178
|
const tmpdir = await mkdtemp(join(process.env.TMPDIR ?? "/tmp", `script-workflow-${run.id}-`));
|
|
174
179
|
const sourceFile = `${tmpdir}/source.ts`;
|
|
175
180
|
const argsFile = `${tmpdir}/args.json`;
|
|
@@ -358,7 +363,8 @@ export class LocalProcessScriptExecutor implements ScriptExecutor {
|
|
|
358
363
|
// or API base URL; status, heartbeat, and ctx.swarm HTTP stay above it.
|
|
359
364
|
const harnessEnv = {
|
|
360
365
|
PATH: process.env.PATH ?? "/usr/bin:/bin",
|
|
361
|
-
|
|
366
|
+
// The dropped identity cannot use the API's HOME.
|
|
367
|
+
HOME: runAs ? tmpdir : (process.env.HOME ?? "/tmp"),
|
|
362
368
|
LANG: process.env.LANG ?? "C.UTF-8",
|
|
363
369
|
LC_ALL: process.env.LC_ALL ?? "C.UTF-8",
|
|
364
370
|
TMPDIR: tmpdir,
|
|
@@ -374,8 +380,24 @@ export class LocalProcessScriptExecutor implements ScriptExecutor {
|
|
|
374
380
|
};
|
|
375
381
|
|
|
376
382
|
try {
|
|
383
|
+
if (runAs) {
|
|
384
|
+
// The guest writes its user module and result files into the run dir
|
|
385
|
+
// and connects to the capability socket.
|
|
386
|
+
await Promise.all(
|
|
387
|
+
[tmpdir, sourceFile, argsFile, socketPath].map((path) =>
|
|
388
|
+
chown(path, runAs.uid, runAs.gid),
|
|
389
|
+
),
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
const command = buildSandboxedCommand(
|
|
393
|
+
["bun", "run", harnessPath],
|
|
394
|
+
harnessEnv,
|
|
395
|
+
DEFAULT_SANDBOX_LIMITS,
|
|
396
|
+
"inline",
|
|
397
|
+
runAs,
|
|
398
|
+
);
|
|
377
399
|
proc = registerProcessGroup(
|
|
378
|
-
Bun.spawn(
|
|
400
|
+
Bun.spawn(command, {
|
|
379
401
|
cwd: tmpdir,
|
|
380
402
|
detached: detachedProcessGroup,
|
|
381
403
|
// On POSIX, Bun.spawn only needs PATH itself to find the `sh` binary
|
|
@@ -410,6 +432,12 @@ export class LocalProcessScriptExecutor implements ScriptExecutor {
|
|
|
410
432
|
() => "",
|
|
411
433
|
);
|
|
412
434
|
const spawned = proc;
|
|
435
|
+
// The guest owns the run dir: read its files only through the checked reader.
|
|
436
|
+
const runDirCheck: RunDirFileCheck = {
|
|
437
|
+
// ulimit -f already bounds what the guest can write.
|
|
438
|
+
maxBytes: DEFAULT_SANDBOX_LIMITS.maxFileKb * 1024,
|
|
439
|
+
...(runAs ? { ownerUid: runAs.uid } : {}),
|
|
440
|
+
};
|
|
413
441
|
const exited = spawned.exited.then(async (processExitCode) => {
|
|
414
442
|
clearInterval(heartbeat);
|
|
415
443
|
await terminateProcessGroup(spawned.pid);
|
|
@@ -420,17 +448,18 @@ export class LocalProcessScriptExecutor implements ScriptExecutor {
|
|
|
420
448
|
try {
|
|
421
449
|
if (protocolFailure) throw protocolFailure;
|
|
422
450
|
if (processExitCode !== 0) {
|
|
423
|
-
const
|
|
424
|
-
const failure =
|
|
425
|
-
? (JSON.parse(
|
|
426
|
-
: undefined;
|
|
451
|
+
const errorText = await readRunDirFile(errorFile, runDirCheck);
|
|
452
|
+
const failure =
|
|
453
|
+
errorText === undefined ? undefined : (JSON.parse(errorText) as { message?: unknown });
|
|
427
454
|
const message =
|
|
428
455
|
typeof failure?.message === "string"
|
|
429
456
|
? failure.message
|
|
430
457
|
: `guest exited with ${processExitCode}`;
|
|
431
458
|
throw new Error(message);
|
|
432
459
|
}
|
|
433
|
-
const
|
|
460
|
+
const resultText = await readRunDirFile(resultFile, runDirCheck);
|
|
461
|
+
if (resultText === undefined) throw new Error("guest wrote no readable result file");
|
|
462
|
+
const output = JSON.parse(resultText);
|
|
434
463
|
await postStatus(run, baseUrl, apiKey, { status: "completed", output });
|
|
435
464
|
return { exitCode: 0, stderr };
|
|
436
465
|
} catch (error) {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
updateScriptRun,
|
|
6
6
|
updateScriptRunIfRunning,
|
|
7
7
|
} from "../be/db";
|
|
8
|
+
import { isExecutorAllowedByDeployment } from "../scripts-runtime/executors/registry";
|
|
8
9
|
import type { ScriptRun } from "../types";
|
|
9
10
|
import { getApiKey } from "../utils/api-key";
|
|
10
11
|
import { scrubSecrets } from "../utils/secret-scrubber";
|
|
@@ -31,6 +32,17 @@ export function setScriptRunExecutor(executor: ScriptExecutor): void {
|
|
|
31
32
|
scriptExecutor = executor;
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
export const DURABLE_RUNS_NATIVE_REFUSED =
|
|
36
|
+
'Durable script runs use the native executor, which is not permitted when deployment SCRIPT_EXECUTOR="quickjs"';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Durable runs only have a native harness (a `bun` subprocess), so they follow
|
|
40
|
+
* the same deployment ceiling as an inline run that asks for `native`.
|
|
41
|
+
*/
|
|
42
|
+
export function durableScriptRunsAllowed(): boolean {
|
|
43
|
+
return isExecutorAllowedByDeployment("native");
|
|
44
|
+
}
|
|
45
|
+
|
|
34
46
|
export async function startScriptRunProcess(
|
|
35
47
|
run: ScriptRun,
|
|
36
48
|
baseUrl: string,
|
|
@@ -38,6 +50,8 @@ export async function startScriptRunProcess(
|
|
|
38
50
|
): Promise<void> {
|
|
39
51
|
if (supervisorDisabled()) return;
|
|
40
52
|
if (managed.has(run.id)) return;
|
|
53
|
+
// Also covers reconcile respawns of runs created before the setting changed.
|
|
54
|
+
if (!durableScriptRunsAllowed()) throw new Error(DURABLE_RUNS_NATIVE_REFUSED);
|
|
41
55
|
const apiKey = apiKeyOverride ?? getApiKey();
|
|
42
56
|
if (!apiKey) throw new Error("AGENT_SWARM_API_KEY is required to spawn script runs");
|
|
43
57
|
if (process.env.SCRIPT_WORKFLOW_DEBUG === "true") {
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
ScriptMcpConnectionDescriptor,
|
|
6
6
|
ScriptMcpRegistryClient,
|
|
7
7
|
} from "./api-types";
|
|
8
|
-
import type { ScriptAgentFsDescriptor } from "./executors/types";
|
|
8
|
+
import type { ScriptAgentFsDescriptor, ScriptCaller } from "./executors/types";
|
|
9
9
|
import { createMcpRegistryClient } from "./mcp-client";
|
|
10
10
|
import {
|
|
11
11
|
createScriptFs,
|
|
@@ -19,6 +19,7 @@ import type { SwarmConfig } from "./swarm-config";
|
|
|
19
19
|
import { createNamespaceClients, createSwarmSdk } from "./swarm-sdk";
|
|
20
20
|
|
|
21
21
|
export type RuntimeCtx = {
|
|
22
|
+
caller: ScriptCaller;
|
|
22
23
|
swarm: Record<string, unknown> & { config: SwarmConfig };
|
|
23
24
|
api: ScriptApiRegistryClient;
|
|
24
25
|
mcp: ScriptMcpRegistryClient;
|
|
@@ -39,6 +40,7 @@ export function buildCtx({
|
|
|
39
40
|
apiConnections,
|
|
40
41
|
mcpConnections,
|
|
41
42
|
agentFs,
|
|
43
|
+
caller = null,
|
|
42
44
|
signal,
|
|
43
45
|
namespaces,
|
|
44
46
|
}: {
|
|
@@ -46,6 +48,7 @@ export function buildCtx({
|
|
|
46
48
|
apiConnections?: ScriptApiConnectionDescriptor[];
|
|
47
49
|
mcpConnections?: ScriptMcpConnectionDescriptor[];
|
|
48
50
|
agentFs?: ScriptAgentFsDescriptor;
|
|
51
|
+
caller?: ScriptCaller;
|
|
49
52
|
/** Aborts in-flight `ctx.sh` commands when the run ends (quickjs passes its run signal). */
|
|
50
53
|
signal?: AbortSignal;
|
|
51
54
|
/** Tests inject a fixture; production uses `SDK_NAMESPACES`. */
|
|
@@ -56,6 +59,7 @@ export function buildCtx({
|
|
|
56
59
|
return {
|
|
57
60
|
// Spread first: assertNamespaces already rejects a namespace named like a ctx key.
|
|
58
61
|
...createNamespaceClients(swarmConfig, { signal, registry: namespaces }),
|
|
62
|
+
caller: caller === null ? null : Object.freeze(JSON.parse(JSON.stringify(caller))),
|
|
59
63
|
swarm,
|
|
60
64
|
api: createApiRegistryClient(apiConnections, { swarmConfig }),
|
|
61
65
|
mcp: createMcpRegistryClient(mcpConnections, swarmConfig),
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Shared JavaScript source for the native SDK and the QuickJS virtual module. */
|
|
2
|
+
export const DURABLE_OBJECT_BASE_JS = `class DurableObject {
|
|
3
|
+
static __swarmDurable = true;
|
|
4
|
+
state;
|
|
5
|
+
constructor(id) {
|
|
6
|
+
this._id = id;
|
|
7
|
+
this._destroyed = false;
|
|
8
|
+
}
|
|
9
|
+
get id() { return this._id; }
|
|
10
|
+
destroy() { this._destroyed = true; }
|
|
11
|
+
}`;
|
|
12
|
+
|
|
13
|
+
// Static methods and names that start with "_" are also not callable.
|
|
14
|
+
export const DURABLE_OBJECT_RESERVED_METHODS = new Set([
|
|
15
|
+
"constructor",
|
|
16
|
+
"initialState",
|
|
17
|
+
"migrate",
|
|
18
|
+
"destroy",
|
|
19
|
+
]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { buildCtx } from "./ctx";
|
|
2
|
+
import { DURABLE_OBJECT_RESERVED_METHODS } from "./durable-object-base";
|
|
2
3
|
import { patchFetchWithEgressSubstitution } from "./egress-secrets";
|
|
3
4
|
import { type SwarmConfigPayload, UNAWAITED_WORK_DRAIN_MS } from "./executors/types";
|
|
4
5
|
import { isHostValidationEquivalent } from "./host-validated-args";
|
|
@@ -114,6 +115,12 @@ try {
|
|
|
114
115
|
apiConnections: payload.apiConnections,
|
|
115
116
|
mcpConnections: payload.mcpConnections,
|
|
116
117
|
agentFs: payload.agentFs,
|
|
118
|
+
caller:
|
|
119
|
+
payload.durable?.caller ??
|
|
120
|
+
payload.caller ??
|
|
121
|
+
(payload.system.agentId.value
|
|
122
|
+
? { kind: "agent", agentId: payload.system.agentId.value }
|
|
123
|
+
: null),
|
|
117
124
|
});
|
|
118
125
|
|
|
119
126
|
const sourceFile = requiredEnv("SWARM_SCRIPT_SOURCE_FILE");
|
|
@@ -129,6 +136,13 @@ try {
|
|
|
129
136
|
// dynamic absolute-path import through that symlink ("Cannot find module ...
|
|
130
137
|
// from ''"). The URL form resolves identically on all supported versions.
|
|
131
138
|
const mod = await import(Bun.pathToFileURL(userModulePath).href);
|
|
139
|
+
const durable = payload.durable;
|
|
140
|
+
if (durable && !mod.default?.__swarmDurable) {
|
|
141
|
+
throw new Error("this script is not a DurableObject");
|
|
142
|
+
}
|
|
143
|
+
if (!durable && mod.default?.__swarmDurable) {
|
|
144
|
+
throw new Error("this script is a DurableObject. Call it with object: { id, method }");
|
|
145
|
+
}
|
|
132
146
|
if (typeof mod.default !== "function") {
|
|
133
147
|
throw new Error(
|
|
134
148
|
"Swarm script must export a default function. Script must export default async function (args, ctx) — args FIRST, ctx second.",
|
|
@@ -165,7 +179,38 @@ try {
|
|
|
165
179
|
}
|
|
166
180
|
}
|
|
167
181
|
|
|
168
|
-
|
|
182
|
+
let result: unknown;
|
|
183
|
+
if (durable) {
|
|
184
|
+
const obj = new mod.default(durable.id);
|
|
185
|
+
obj.state = durable.state === undefined ? await obj.initialState() : durable.state;
|
|
186
|
+
if (durable.storedCodeVersion < durable.codeVersion && typeof obj.migrate === "function") {
|
|
187
|
+
obj.state = await obj.migrate(obj.state, durable.storedCodeVersion);
|
|
188
|
+
}
|
|
189
|
+
const method = durable.method;
|
|
190
|
+
let prototype = mod.default.prototype;
|
|
191
|
+
let descriptor: PropertyDescriptor | undefined;
|
|
192
|
+
while (Object.getPrototypeOf(prototype)?.constructor?.__swarmDurable) {
|
|
193
|
+
descriptor = Object.getOwnPropertyDescriptor(prototype, method);
|
|
194
|
+
if (descriptor) break;
|
|
195
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
196
|
+
}
|
|
197
|
+
if (
|
|
198
|
+
method.startsWith("_") ||
|
|
199
|
+
DURABLE_OBJECT_RESERVED_METHODS.has(method) ||
|
|
200
|
+
typeof descriptor?.value !== "function"
|
|
201
|
+
) {
|
|
202
|
+
throw new Error(`DurableObject method "${method}" is not callable`);
|
|
203
|
+
}
|
|
204
|
+
result = {
|
|
205
|
+
__swarmDurable: 1,
|
|
206
|
+
result: (await obj[method](validatedArgs, ctx)) ?? null,
|
|
207
|
+
state: obj.state,
|
|
208
|
+
destroyed: Boolean(obj._destroyed),
|
|
209
|
+
idleTtlSec: mod.default.idleTtlSec ?? null,
|
|
210
|
+
};
|
|
211
|
+
} else {
|
|
212
|
+
result = await mod.default(validatedArgs, ctx);
|
|
213
|
+
}
|
|
169
214
|
await Bun.write(requiredEnv("SWARM_SCRIPT_RESULT_FILE"), JSON.stringify(result ?? null));
|
|
170
215
|
// The run settles once the entry function resolves. Bun would otherwise keep
|
|
171
216
|
// the process alive while any call the script did not await is pending (a
|
|
@@ -547,6 +547,17 @@ export class NativeScriptExecutor implements ScriptExecutor {
|
|
|
547
547
|
...(runAs ? { ownerUid: runAs.uid } : {}),
|
|
548
548
|
};
|
|
549
549
|
const result = exitCode === 0 ? await readResultFile(resultFile, runDirCheck) : undefined;
|
|
550
|
+
const envelope = result as { __swarmDurable?: number; result?: unknown } & NonNullable<
|
|
551
|
+
ExecutorOutput["durable"]
|
|
552
|
+
>;
|
|
553
|
+
const durable =
|
|
554
|
+
input.configPayload.durable && envelope?.__swarmDurable === 1
|
|
555
|
+
? {
|
|
556
|
+
state: envelope.state,
|
|
557
|
+
destroyed: envelope.destroyed,
|
|
558
|
+
idleTtlSec: envelope.idleTtlSec,
|
|
559
|
+
}
|
|
560
|
+
: undefined;
|
|
550
561
|
const runtimeError =
|
|
551
562
|
exitCode === 0 ? undefined : await readRuntimeError(errorFile, runDirCheck);
|
|
552
563
|
// Presence only; anything at the path (even a planted link) reads as started,
|
|
@@ -555,7 +566,8 @@ export class NativeScriptExecutor implements ScriptExecutor {
|
|
|
555
566
|
const error = classifyExit(exitCode, timedOut, killed, userCodeStarted);
|
|
556
567
|
|
|
557
568
|
return {
|
|
558
|
-
result,
|
|
569
|
+
result: durable ? envelope.result : result,
|
|
570
|
+
...(durable ? { durable } : {}),
|
|
559
571
|
stdout: stdout.text,
|
|
560
572
|
stderr: stderr.text,
|
|
561
573
|
truncated: { stdout: stdout.truncated, stderr: stderr.truncated },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DURABLE_OBJECT_BASE_JS } from "../durable-object-base";
|
|
1
2
|
import { SourceMapReader } from "./sourcemap";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -27,7 +28,9 @@ export const retry = s.retry;
|
|
|
27
28
|
export const Redacted = s.Redacted;
|
|
28
29
|
`;
|
|
29
30
|
|
|
30
|
-
const SWARM_SDK_MODULE =
|
|
31
|
+
const SWARM_SDK_MODULE = `${DURABLE_OBJECT_BASE_JS}
|
|
32
|
+
export { DurableObject };
|
|
33
|
+
export function createSwarmSdk() {
|
|
31
34
|
return globalThis.__swarm_ctx.swarm;
|
|
32
35
|
}
|
|
33
36
|
`;
|
|
@@ -131,6 +134,22 @@ export async function bundleForQuickJS(source: string): Promise<QuickJSBundle> {
|
|
|
131
134
|
}
|
|
132
135
|
return { path: zodEntry };
|
|
133
136
|
});
|
|
137
|
+
// Registered last, so it sees only the imports the handlers above do not
|
|
138
|
+
// claim. The two in-memory files resolve to themselves. Every other import
|
|
139
|
+
// from them fails, so the bundle never reads a host file. Imports inside
|
|
140
|
+
// the resolved zod sources keep Bun's default resolution.
|
|
141
|
+
build.onResolve({ filter: /.*/ }, (args) => {
|
|
142
|
+
if (args.importer === "" && args.path === ENTRY_PATH) return { path: ENTRY_PATH };
|
|
143
|
+
if (args.importer === ENTRY_PATH && args.path === `./${USER_SCRIPT_FILE}`) {
|
|
144
|
+
return { path: USER_PATH };
|
|
145
|
+
}
|
|
146
|
+
if (args.importer === "" || args.importer.startsWith(`${VIRTUAL_DIR}/`)) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
`Import '${args.path}' is not available to the quickjs executor. Allowed imports are "stdlib", "swarm-sdk", "zod" and "zod/mini".`,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
return undefined;
|
|
152
|
+
});
|
|
134
153
|
},
|
|
135
154
|
},
|
|
136
155
|
],
|
|
@@ -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,
|