@desplega.ai/agent-swarm 2.13.2 → 2.13.4
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-mr4temec.js +17 -0
- package/dist/{acp-targets-mz8c5dnt.js → acp-targets-zrk9k0n7.js} +10 -10
- package/dist/{actions-5ft3qp5a.js → actions-acqqj9jn.js} +236 -26
- package/dist/{agent-fs-provision-6fgz7wvz.js → agent-fs-provision-zmaykqnd.js} +4 -4
- package/dist/{amp-adapter-nthn8ezm.js → amp-adapter-a7ts8tmw.js} +3 -3
- package/dist/{app-535m78qw.js → app-tmwa442h.js} +7 -7
- package/dist/{approval-notifications-dewbk403.js → approval-notifications-6psaaaye.js} +8 -8
- package/dist/{assistant-39zyabv2.js → assistant-564v6emv.js} +25 -25
- package/dist/{boot-args-schema-bqv5bf77.js → boot-args-schema-n099e0f2.js} +1 -1
- package/dist/{boot-reembed-fas7z3zn.js → boot-reembed-chx66qfk.js} +1 -1
- package/dist/{boot-reembed-157c0gcz.js → boot-reembed-epvg4fp9.js} +1 -1
- package/dist/{boot-scrub-sweep-tmec0be2.js → boot-scrub-sweep-dhkfp0a7.js} +2 -2
- package/dist/{boot-seeds-32zm50x2.js → boot-seeds-m74fc07r.js} +4 -4
- package/dist/{boxd-hr8rsxzq.js → boxd-451q55ys.js} +1 -1
- package/dist/{claude-adapter-gwq7x2nj.js → claude-adapter-hw63yj3j.js} +12 -9
- package/dist/{claude-managed-adapter-rkvw6fvq.js → claude-managed-adapter-z5s7fx6p.js} +3 -3
- package/dist/{claude-managed-setup-0vgz4d1j.js → claude-managed-setup-wee1762m.js} +3 -3
- package/dist/{claude-sdk-session-5wbwxy8c.js → claude-sdk-session-cktyqkpk.js} +27 -13
- package/dist/{cli-d528acsw.js → cli-0fgvnb0x.js} +7 -7
- package/dist/{cli-2v4xxnx2.js → cli-0h8skzss.js} +1 -1
- package/dist/{cli-jkkcm72j.js → cli-0p76my9q.js} +31 -16
- package/dist/{cli-fp65jdp2.js → cli-1kvcsd2f.js} +219 -155
- package/dist/{cli-gc7jkf4a.js → cli-1vmhnncj.js} +3 -3
- package/dist/{cli-tceqvv6h.js → cli-29h5239w.js} +5 -5
- package/dist/cli-2ap1the6.js +11 -0
- package/dist/{cli-8fj8yfmk.js → cli-2vp0z049.js} +1 -1
- package/dist/{cli-ewb028rs.js → cli-3bxrrh53.js} +4 -4
- package/dist/{cli-nvqq3232.js → cli-3tzmh38q.js} +9 -9
- package/dist/{cli-0xwb7zpt.js → cli-3xqad83h.js} +2 -2
- package/dist/{cli-0f7n3td3.js → cli-3zrwrnz7.js} +1 -1
- package/dist/{cli-2wde56gv.js → cli-404am6f3.js} +7 -7
- package/dist/{cli-r4fphq38.js → cli-49aq3cyn.js} +4 -4
- package/dist/{cli-8qvte9hn.js → cli-4fpa0zns.js} +3 -3
- package/dist/{cli-x5yb8zc8.js → cli-4pbwg7sn.js} +2 -2
- package/dist/{cli-s08zsqva.js → cli-4q2c8rxw.js} +76 -10
- package/dist/{cli-3mf04tkh.js → cli-4vynxtrb.js} +1 -1
- package/dist/{cli-tbdw3f92.js → cli-5ashycw3.js} +3 -3
- package/dist/{cli-c9bwawf9.js → cli-5rgm8p39.js} +3 -3
- package/dist/{cli-g0b3ma7r.js → cli-5rxsb3wq.js} +6 -6
- package/dist/{cli-a6rzw649.js → cli-60dwk8tx.js} +3 -3
- package/dist/{cli-xhkek467.js → cli-7by7vp6m.js} +30 -4
- package/dist/{cli-62fjschk.js → cli-7g3fg4gf.js} +7 -7
- package/dist/{cli-ka13xx6b.js → cli-7gbff32z.js} +2 -2
- package/dist/{cli-q8aq48v1.js → cli-8b4rpnwj.js} +1 -1
- package/dist/{cli-1f48qdnb.js → cli-8cas2xvp.js} +3 -3
- package/dist/{cli-dnvmwsvc.js → cli-904wk98s.js} +799 -371
- package/dist/{cli-m1wddksc.js → cli-93n305hm.js} +2 -2
- package/dist/{cli-31vt7baf.js → cli-944w9wb4.js} +21 -17
- package/dist/{cli-je587f74.js → cli-94gx6ze9.js} +1 -1
- package/dist/{cli-fcwrd7bh.js → cli-9ah37a8a.js} +6 -6
- package/dist/{cli-rfejbpe1.js → cli-akm6y2a8.js} +1 -1
- package/dist/{cli-f8rcvf2x.js → cli-azj9t1f9.js} +37 -2
- package/dist/{cli-mwxez0pz.js → cli-b768ek79.js} +1 -1
- package/dist/{cli-cmgdptmx.js → cli-bv4vvnmg.js} +31 -7
- package/dist/{cli-1gevjrc1.js → cli-bzcwwebm.js} +1 -1
- package/dist/{cli-sjk85d7v.js → cli-cq4am6vg.js} +3 -3
- package/dist/{cli-f1sdh8ca.js → cli-d5pc8ep0.js} +103 -9
- package/dist/{cli-7m6bbtab.js → cli-ea7nz50q.js} +12 -12
- package/dist/{cli-zkbz8m2q.js → cli-fkpnx3vf.js} +1 -1
- package/dist/{cli-ya1cj689.js → cli-fw67mnyc.js} +1 -1
- package/dist/{cli-5basv0e7.js → cli-gkv0r2hq.js} +1 -1
- package/dist/{cli-nkfv398a.js → cli-gse7bp3z.js} +12 -10
- package/dist/{cli-4djg31jh.js → cli-gtj12v95.js} +1 -1
- package/dist/{cli-qn79645p.js → cli-h9d3sdnc.js} +1 -1
- package/dist/{cli-tgmate57.js → cli-hdhpdrka.js} +6 -23
- package/dist/{cli-fgm2mad9.js → cli-hhtbandk.js} +2 -2
- package/dist/cli-hyqksecw.js +1907 -0
- package/dist/{cli-t25rq8mg.js → cli-ja450998.js} +40 -11
- package/dist/{cli-43dsqhcp.js → cli-jbrc98qb.js} +4 -4
- package/dist/{cli-82j36f2m.js → cli-jjzxsk47.js} +9 -3
- package/dist/{cli-xerdrnqs.js → cli-jyhbvdga.js} +3 -3
- package/dist/{cli-t9nxq30h.js → cli-jzerrzgc.js} +8 -8
- package/dist/{cli-hv3820ez.js → cli-k0nebh10.js} +1 -1
- package/dist/{cli-s6fhqbz1.js → cli-ka48vpev.js} +6 -6
- package/dist/{cli-d2epqm0y.js → cli-kezzteka.js} +1 -1
- package/dist/{cli-getrvmtx.js → cli-kj84fqxz.js} +2 -2
- package/dist/{cli-h0ewec3d.js → cli-kr0jpw9c.js} +1 -1
- package/dist/{cli-gq6qhmrr.js → cli-m1sns1da.js} +3 -3
- package/dist/{cli-bp2rt28p.js → cli-n1kjs58m.js} +5 -5
- package/dist/{cli-rvhaahfv.js → cli-nc4pbwmp.js} +9 -9
- package/dist/{cli-d0jb2qnt.js → cli-p3knvk62.js} +74 -47
- package/dist/{cli-50whymxq.js → cli-p436yrzp.js} +2 -2
- package/dist/{cli-cs26ed89.js → cli-phdzn699.js} +8 -8
- package/dist/{cli-b0kqw55g.js → cli-pz1dp12c.js} +1 -1
- package/dist/{cli-8a4qg44m.js → cli-pz1nq5xm.js} +6 -6
- package/dist/{cli-e87fg3en.js → cli-qzz6tz8s.js} +1 -1
- package/dist/{cli-69eq6gdk.js → cli-rmgvwcmy.js} +38 -29
- package/dist/{cli-5k1hvycs.js → cli-rv3y60bt.js} +4 -4
- package/dist/cli-s33bzmk0.js +27 -0
- package/dist/{cli-at67kvnp.js → cli-srktrbby.js} +1 -1
- package/dist/{cli-6rmryz03.js → cli-t0jmkcah.js} +14 -14
- package/dist/{cli-eetzmsy5.js → cli-t9pzz2eq.js} +2 -2
- package/dist/{cli-wdtqkqnq.js → cli-tr19nyn9.js} +4 -4
- package/dist/{cli-erh1rgh4.js → cli-ts5yv7dn.js} +165 -88
- package/dist/{cli-zqy28rwx.js → cli-tsc3pdfd.js} +4 -4
- package/dist/{cli-x7aqhxj5.js → cli-tzw1jr2t.js} +2 -2
- package/dist/{cli-n14r8h4n.js → cli-x2cem5vy.js} +6 -4
- package/dist/{cli-vx9acp12.js → cli-ybte1fqc.js} +1 -1
- package/dist/{cli-xysy1g8x.js → cli-ysv0k1we.js} +2 -2
- package/dist/{cli-vdfngx2g.js → cli-ywy8yz6t.js} +2 -2
- package/dist/{cli-cpkxh68d.js → cli-z1vam71h.js} +2 -2
- package/dist/{cli-zm6bkx3e.js → cli-zexwhj3f.js} +3 -3
- package/dist/{cli-j2ybkdk2.js → cli-zhwjdhjr.js} +2 -2
- package/dist/{cli-gedf48yw.js → cli-zjdhrzm0.js} +8 -8
- package/dist/cli.js +20 -20
- package/dist/{codex-adapter-x25xfbnh.js → codex-adapter-2fs2c0n6.js} +8 -8
- package/dist/{codex-hook-c0nvm30r.js → codex-hook-jxjv6dy5.js} +10 -3
- package/dist/{codex-login-ven5cz5j.js → codex-login-ktfg1cxk.js} +1 -1
- package/dist/{codex-session-runner-kn5xnrvp.js → codex-session-runner-r55tmx4c.js} +9 -9
- package/dist/{commands-8n59gxmy.js → commands-0mxdy9x8.js} +3 -3
- package/dist/{controller-wn3vd217.js → controller-g3vkfhr4.js} +4 -4
- package/dist/{controllers-connect-09gvkrhc.js → controllers-connect-4wdmncqt.js} +25 -25
- package/dist/core-gsvj5f3z.js +42 -0
- package/dist/{cursor-adapter-w1681kp1.js → cursor-adapter-t9qb96q2.js} +2 -2
- package/dist/{db-e71keqxk.js → db-487vvyv9.js} +3 -3
- package/dist/{db-spg81qtr.js → db-76p7w3gr.js} +2 -2
- package/dist/{devin-adapter-fs90ab4v.js → devin-adapter-3bp6rape.js} +1 -1
- package/dist/{dispatcher-fr4vawwb.js → dispatcher-64rp6w67.js} +22 -22
- package/dist/{docker-1h33jvh9.js → docker-a59g3ebm.js} +2 -2
- package/dist/{dsh-adapter-g9yqv09y.js → dsh-adapter-8abzqk5c.js} +2 -2
- package/dist/{e2b-y7e5kmzf.js → e2b-3ykbe805.js} +2 -2
- package/dist/{e2b-jnk0yeva.js → e2b-dc8f6ctq.js} +2 -2
- package/dist/{easter-egg-3d-ac9tv9a6.js → easter-egg-3d-jrrwyf55.js} +1 -1
- package/dist/{embedding-space-an77f45k.js → embedding-space-001hhhpk.js} +6 -6
- package/dist/{embeddings-jkrehejr.js → embeddings-esj19cnw.js} +1 -1
- package/dist/{event-bus-08t2b4y2.js → event-bus-7gbsr0g4.js} +1 -1
- package/dist/{execute-3mys4nta.js → execute-301hkxqg.js} +1 -1
- package/dist/{external-channel-s6zxpts9.js → external-channel-w10e2j05.js} +2 -2
- package/dist/fx-adapter-4sjrbdne.js +20 -0
- package/dist/grok-adapter-3a0ezfee.js +20 -0
- package/dist/handlers-ef3k11hb.js +41 -0
- package/dist/{heartbeat-jjpb44e5.js → heartbeat-tbrj7vhq.js} +25 -25
- package/dist/hook-3am1sq68.js +22 -0
- package/dist/{hook-y6n23zzj.js → hook-tx917rqw.js} +11 -8
- package/dist/{http-8c6y008s.js → http-3rmemtqy.js} +340 -1841
- package/dist/{index-mbpxhc4w.js → index-126v2d0t.js} +1 -4
- package/dist/{index-xcw7hjt5.js → index-2jw11t8s.js} +26 -26
- package/dist/{index-p2f5xg64.js → index-3j803vnb.js} +36259 -34299
- package/dist/{index-we3nd2t0.js → index-aetfyx6p.js} +1 -1
- package/dist/index-e6bq0exk.js +42 -0
- package/dist/{index-0vthtbc2.js → index-gfnq66t1.js} +231 -25
- package/dist/index-hf2k1vge.js +39 -0
- package/dist/{index-6h3r0vpe.js → index-s7xtvc0f.js} +1 -1
- package/dist/index-taxmejj3.js +44 -0
- package/dist/{k8s-8326q0rq.js → k8s-36gfn847.js} +2 -2
- package/dist/{keepalive-7e9r5dvp.js → keepalive-9px3t7qj.js} +5 -5
- package/dist/lead-5vt6f174.js +83 -0
- package/dist/{maintenance-d3erjvcg.js → maintenance-vwqjwst6.js} +1 -1
- package/dist/{oauth-refresh-sweep-0qh70988.js → oauth-refresh-sweep-yqry3wn4.js} +4 -4
- package/dist/{object-webhooks-ac7v2q5p.js → object-webhooks-8s1wtths.js} +7 -7
- package/dist/{onboard-5yphtken.js → onboard-hb8czx0p.js} +7 -7
- package/dist/{opencode-adapter-0xvyba4m.js → opencode-adapter-djd6m6dk.js} +8 -8
- package/dist/{otel-impl-svqp691q.js → otel-impl-2ymwyczz.js} +2 -2
- package/dist/{pending-bn4xe5br.js → pending-nxavtvx7.js} +23 -23
- package/dist/{pi-mono-adapter-763s8a3w.js → pi-mono-adapter-d2cpmcy4.js} +13 -13
- package/dist/{pricing-refresh-kfc215mf.js → pricing-refresh-1yz8jkqv.js} +2 -2
- package/dist/{rbac-roles-6r4h2ghj.js → rbac-roles-7s6m31xw.js} +6 -4
- package/dist/{rbac-roles-3bznvkpt.js → rbac-roles-dbpx0x9v.js} +3 -3
- package/dist/{render-v2-f3qedbpy.js → render-v2-7y20rjrn.js} +7 -7
- package/dist/{resume-vcag4ann.js → resume-wz546x47.js} +10 -10
- package/dist/{runtime-x0s55z2t.js → runtime-cb5bd9tz.js} +1 -1
- package/dist/{session-access-nwzve8q2.js → session-access-4vcft8kq.js} +5 -5
- package/dist/{session-source-backfill-jpqfzmgz.js → session-source-backfill-57b50tpw.js} +3 -3
- package/dist/{setup-d2smwaem.js → setup-e1tevjyj.js} +1 -1
- package/dist/thread-buffer-686pa1p1.js +42 -0
- package/dist/{tree-visibility-dwzc8en0.js → tree-visibility-07wf1nct.js} +2 -2
- package/dist/{user-merge-jobs-4ce7kma2.js → user-merge-jobs-n20qpv6s.js} +3 -3
- package/dist/{virtual-modules-78a6yw71.js → virtual-modules-6fxmn1yv.js} +3 -3
- package/dist/{work-objects-m0w1e7q8.js → work-objects-eg7y48pe.js} +25 -25
- package/dist/worker-4vp616ms.js +83 -0
- package/dist/{worker-follow-up-e3t6f895.js → worker-follow-up-jnvnnf2b.js} +22 -22
- package/dist/{x-asbrnafg.js → x-d27jj7z7.js} +2 -2
- package/openapi.json +478 -28
- package/package.json +3 -3
- package/src/be/db/approvals.ts +2 -0
- package/src/be/db/runtime.ts +5 -0
- package/src/be/db/script-run-sources.ts +17 -0
- package/src/be/db-retention.ts +1 -1
- package/src/be/db.ts +71 -62
- package/src/be/design-system.ts +63 -0
- package/src/be/migrations/342_script_run_sources.sql +20 -0
- package/src/be/migrations/runner.ts +8 -0
- package/src/be/migrations/script-run-sources.ts +51 -0
- package/src/be/rbac-roles.ts +2 -0
- package/src/be/scripts/typecheck.ts +4 -2
- package/src/be/seed-scripts/catalog/design-system-seed.ts +158 -0
- package/src/be/seed-scripts/index.ts +9 -0
- package/src/be/swarm-config-guard.ts +21 -1
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/runner.ts +62 -6
- package/src/heartbeat/heartbeat.ts +18 -4
- package/src/hooks/codex-hook.ts +15 -4
- package/src/hooks/hook.ts +7 -0
- package/src/http/all-routes.ts +1 -0
- package/src/http/approval-chat-answer.ts +99 -0
- package/src/http/approval-requests.ts +280 -225
- package/src/http/design-system.ts +103 -0
- package/src/http/index.ts +10 -6
- package/src/http/pages-public.ts +25 -10
- package/src/http/pages.ts +17 -0
- package/src/http/person-responder.ts +28 -0
- package/src/http/session-cost-recompute.ts +3 -1
- package/src/http/session-data.ts +3 -0
- package/src/integrations/chat-sdk/adapters.ts +33 -3
- package/src/integrations/chat-sdk/inbound.ts +6 -18
- package/src/integrations/chat-sdk/mentions.ts +188 -0
- package/src/integrations/chat-sdk/outbound.ts +20 -3
- package/src/integrations/chat-sdk/router.ts +8 -0
- package/src/integrations/chat-sdk/telegram-thread.ts +12 -0
- package/src/jira/adf.ts +35 -9
- package/src/kv-reserved-namespaces.ts +5 -0
- package/src/pages/page-head.ts +11 -1
- package/src/prompts/base-prompt.ts +1 -1
- package/src/prompts/session-templates.ts +1 -1
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +21 -1
- package/src/providers/claude-sdk-session.ts +22 -3
- package/src/providers/claude-session-events.ts +76 -1
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/providers/dsh-adapter.ts +48 -13
- package/src/providers/fx-adapter.ts +2 -2
- package/src/providers/pricing-sources.md +3 -0
- package/src/providers/types.ts +13 -0
- package/src/rbac/legacy-policy.ts +4 -0
- package/src/rbac/permissions.ts +8 -0
- package/src/scheduler/index.ts +1 -0
- package/src/scheduler/scheduler.test.ts +32 -1
- package/src/scheduler/scheduler.ts +24 -1
- package/src/script-workflows/executor.ts +6 -0
- package/src/script-workflows/supervisor.ts +2 -1
- package/src/scripts-runtime/sdk-allowlist.ts +2 -0
- package/src/scripts-runtime/swarm-sdk.ts +12 -23
- package/src/scripts-runtime/types/stdlib.d.ts +4 -1
- package/src/scripts-runtime/types/swarm-sdk.d.ts +4 -1
- package/src/server.ts +2 -0
- package/src/slack/actions.ts +3 -0
- package/src/slack/approval-actions.ts +148 -0
- package/src/slack/approval-buttons.ts +28 -0
- package/src/slack/render-v2.ts +27 -7
- package/src/tests/base-prompt.test.ts +6 -2
- package/src/tests/chat-sdk-mentions.test.ts +183 -0
- package/src/tests/claude-adapter.test.ts +115 -0
- package/src/tests/create-page-tool.test.ts +5 -0
- package/src/tests/dsh-adapter.test.ts +53 -1
- package/src/tests/fixtures/compiled-source-schema-boot.ts +24 -0
- package/src/tests/fixtures/fx/acp-updates-recorded.jsonl +1 -1
- package/src/tests/fixtures/secret-corpus.ts +43 -1
- package/src/tests/heartbeat-stall-thresholds.test.ts +174 -0
- package/src/tests/internal-ai/complete-structured.test.ts +105 -0
- package/src/tests/internal-ai/credentials.test.ts +149 -0
- package/src/tests/internal-ai/task-title.test.ts +78 -0
- package/src/tests/jira-adf.test.ts +42 -2
- package/src/tests/mcp-input-caps.test.ts +16 -11
- package/src/tests/merge-gate-detect-changes.test.ts +208 -16
- package/src/tests/migration-342-script-run-sources.test.ts +196 -0
- package/src/tests/migration-bunfs-compat.test.ts +129 -9
- package/src/tests/rbac-e2e-helpers.test.ts +10 -4
- package/src/tests/rbac-e2e-helpers.ts +13 -4
- package/src/tests/rbac-roles.test.ts +2 -0
- package/src/tests/runner-slot-reconcile.test.ts +102 -0
- package/src/tests/runtime-e2b-pools.test.ts +7 -1
- package/src/tests/schedule-target-type.test.ts +4 -1
- package/src/tests/script-connections.test.ts +2 -0
- package/src/tests/script-runs-retention.test.ts +43 -16
- package/src/tests/script-workflows-runtime-e2e.test.ts +56 -22
- package/src/tests/scripts-http.test.ts +9 -3
- package/src/tests/sdk-allowlist.test.ts +26 -13
- package/src/tests/sdk-store-progress-skipped.test.ts +12 -5
- package/src/tests/secret-rules.test.ts +34 -0
- package/src/tests/secret-scrub-gate.test.ts +7 -0
- package/src/tests/secret-scrubber.test.ts +62 -2
- package/src/tests/seed-scripts.test.ts +2 -2
- package/src/tests/slack-render-v2.test.ts +85 -0
- package/src/tests/system-one-hosts-ui-mirror.test.ts +1 -0
- package/src/tests/vcs-azure-devops.test.ts +10 -0
- package/src/tests/vcs-provider.test.ts +8 -0
- package/src/themes/design-system.ts +163 -0
- package/src/themes/page-theme.ts +28 -19
- package/src/tools/chat-post.ts +7 -3
- package/src/tools/create-page.ts +3 -0
- package/src/tools/design-system.ts +102 -0
- package/src/tools/mcp-servers/mcp-server-get.ts +1 -1
- package/src/tools/mcp-servers/mcp-server-list.ts +1 -1
- package/src/tools/register-chat-channel.ts +11 -2
- package/src/tools/skills/skill-get-file.ts +1 -1
- package/src/tools/skills/skill-get.ts +1 -1
- package/src/tools/skills/skill-list.ts +1 -1
- package/src/tools/skills/skill-search.ts +1 -1
- package/src/tools/utils.ts +49 -4
- package/src/tools/workflows/get-workflow-run.ts +1 -1
- package/src/tools/workflows/get-workflow.ts +1 -1
- package/src/tools/workflows/list-workflow-runs.ts +1 -1
- package/src/tools/workflows/list-workflows.ts +1 -1
- package/src/types.ts +67 -1
- package/src/utils/internal-ai/complete-structured.ts +36 -5
- package/src/utils/internal-ai/credentials.ts +78 -2
- package/src/utils/internal-ai/models.ts +37 -1
- package/src/utils/internal-ai/task-title.ts +31 -1
- package/src/utils/secret-rules.generated.ts +149 -149
- package/src/utils/secret-scrubber.ts +111 -5
- package/src/vcs/azure-devops.ts +22 -1
- package/src/vcs/index.ts +3 -1
- package/src/workflows/approval-inline.ts +122 -0
- package/src/workflows/approval-notifications.ts +7 -2
- package/src/workflows/engine.ts +6 -5
- package/src/workflows/executors/agent-task.ts +14 -0
- package/src/workflows/executors/system-one-providers.ts +23 -0
- package/templates/skills/pages/content.md +34 -8
- package/templates/skills/swarm-docs/content.md +13 -0
- package/templates/skills/workflow-iterate/content.md +1 -1
- package/dist/acp-adapter-x1qqgzwx.js +0 -17
- package/dist/cli-n46d87mj.js +0 -98
- package/dist/core-2b8bv6ny.js +0 -42
- package/dist/fx-adapter-4yet1c4f.js +0 -20
- package/dist/grok-adapter-8ge6tw7m.js +0 -20
- package/dist/handlers-0r9evrdj.js +0 -41
- package/dist/hook-68gbs87k.js +0 -19
- package/dist/index-1v23363p.js +0 -39
- package/dist/index-30qw6vyw.js +0 -44
- package/dist/index-6bm3w6cn.js +0 -40
- package/dist/lead-3jpc7kcr.js +0 -79
- package/dist/thread-buffer-8fc703jc.js +0 -42
- package/dist/worker-3p2vq107.js +0 -79
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { slackMrkdwnToMarkdown } from "@chat-adapter/slack/format";
|
|
3
|
+
import { teamsHtmlToMarkdown } from "@chat-adapter/teams/format";
|
|
4
|
+
import { TelegramFormatConverter } from "@chat-adapter/telegram";
|
|
5
|
+
import type { Adapter, Logger, Message } from "chat";
|
|
6
|
+
import { parseMarkdown } from "chat";
|
|
7
|
+
import { loadAdapter } from "../integrations/chat-sdk/adapters";
|
|
8
|
+
import { botMentionForms, stripBotMention } from "../integrations/chat-sdk/mentions";
|
|
9
|
+
import { chatMessageText } from "../integrations/chat-sdk/message-text";
|
|
10
|
+
|
|
11
|
+
const silent: Logger = {
|
|
12
|
+
debug() {},
|
|
13
|
+
info() {},
|
|
14
|
+
warn() {},
|
|
15
|
+
error() {},
|
|
16
|
+
child() {
|
|
17
|
+
return silent;
|
|
18
|
+
},
|
|
19
|
+
} as unknown as Logger;
|
|
20
|
+
|
|
21
|
+
/** The handler-side text for `message`: what inbound.ts hands the router. */
|
|
22
|
+
async function inboundText(adapter: Adapter, message: Message): Promise<string> {
|
|
23
|
+
return stripBotMention(chatMessageText(message), await botMentionForms(adapter, message));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A message as the SDK builds it, from markdown the adapter produced. */
|
|
27
|
+
function messageFromMarkdown(markdown: string, raw: unknown = {}): Message {
|
|
28
|
+
return { text: markdown, formatted: parseMarkdown(markdown), raw } as unknown as Message;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe("Discord mentions", () => {
|
|
32
|
+
const BOT = "1511371327469129869";
|
|
33
|
+
|
|
34
|
+
async function discordAdapter(): Promise<{ adapter: Adapter; received: Message[] }> {
|
|
35
|
+
const adapter = await loadAdapter(
|
|
36
|
+
"discord",
|
|
37
|
+
{ botToken: "discord-bot-token", publicKey: "a".repeat(64), applicationId: BOT },
|
|
38
|
+
silent,
|
|
39
|
+
);
|
|
40
|
+
const received: Message[] = [];
|
|
41
|
+
(adapter as unknown as { chat: unknown }).chat = {
|
|
42
|
+
handleIncomingMessage: async (_adapter: unknown, _threadId: string, message: Message) => {
|
|
43
|
+
received.push(message);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
return { adapter, received };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** A discord.js Gateway message in an existing thread, with its mention collections. */
|
|
50
|
+
function gatewayMessage(content: string) {
|
|
51
|
+
return {
|
|
52
|
+
id: "1600000000000000001",
|
|
53
|
+
guildId: "1400000000000000000",
|
|
54
|
+
channelId: "1500000000000000002",
|
|
55
|
+
channel: { isThread: () => true, parentId: "1500000000000000001" },
|
|
56
|
+
content,
|
|
57
|
+
attachments: new Map(),
|
|
58
|
+
messageSnapshots: new Map(),
|
|
59
|
+
author: { id: "1300000000000000001", username: "taras", displayName: "Taras", bot: false },
|
|
60
|
+
createdAt: new Date("2026-11-16T10:00:00Z"),
|
|
61
|
+
editedAt: null,
|
|
62
|
+
mentions: {
|
|
63
|
+
users: new Map([
|
|
64
|
+
[BOT, { displayName: "swarm", username: "swarm" }],
|
|
65
|
+
["1300000000000000002", { displayName: "Eze Global", username: "eze" }],
|
|
66
|
+
]),
|
|
67
|
+
members: new Map([["1300000000000000002", { displayName: "Eze" }]]),
|
|
68
|
+
roles: new Map([["1700000000000000001", { name: "oncall" }]]),
|
|
69
|
+
channels: new Map([["1500000000000000009", { name: "deploys" }]]),
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function deliver(content: string): Promise<{ adapter: Adapter; message: Message }> {
|
|
75
|
+
const { adapter, received } = await discordAdapter();
|
|
76
|
+
await (
|
|
77
|
+
adapter as unknown as { handleGatewayMessage(m: unknown, mentioned: boolean): Promise<void> }
|
|
78
|
+
).handleGatewayMessage(gatewayMessage(content), true);
|
|
79
|
+
expect(received).toHaveLength(1);
|
|
80
|
+
return { adapter, message: received[0] as Message };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
test("strips the bot mention and resolves user, role and channel names", async () => {
|
|
84
|
+
const { adapter, message } = await deliver(
|
|
85
|
+
`<@${BOT}> ask <@1300000000000000002> and <@&1700000000000000001> about <#1500000000000000009>`,
|
|
86
|
+
);
|
|
87
|
+
expect(await inboundText(adapter, message)).toBe("ask @Eze and @oncall about #deploys");
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("the legacy <@!id> nickname form strips too", async () => {
|
|
91
|
+
const { adapter, message } = await deliver(`<@!${BOT}> status?`);
|
|
92
|
+
expect(await inboundText(adapter, message)).toBe("status?");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("negative control: an id with no name stays as @id, never dropped", async () => {
|
|
96
|
+
const { adapter, message } = await deliver(`<@${BOT}> ping <@1300000000000000077> now`);
|
|
97
|
+
expect(await inboundText(adapter, message)).toBe("ping @1300000000000000077 now");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("bare @id form (adapter output) strips only the exact bot id", () => {
|
|
101
|
+
const forms = { names: ["swarm"], ids: [BOT] };
|
|
102
|
+
expect(stripBotMention(`@${BOT} hi`, forms)).toBe("hi");
|
|
103
|
+
expect(stripBotMention(`@${BOT}0 hi`, forms)).toBe(`@${BOT}0 hi`);
|
|
104
|
+
expect(stripBotMention(`@&${BOT} hi`, forms)).toBe(`@&${BOT} hi`);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe("Slack mentions", () => {
|
|
109
|
+
const slack = (displayName: string | null) =>
|
|
110
|
+
({
|
|
111
|
+
name: "slack",
|
|
112
|
+
userName: "agent_swarm",
|
|
113
|
+
botUserId: "U0BOT",
|
|
114
|
+
lookupUser: async (id: string) => (id === "U0BOT" && displayName ? { displayName } : null),
|
|
115
|
+
}) as unknown as Adapter;
|
|
116
|
+
|
|
117
|
+
test("strips the bot mention rendered under its display name", async () => {
|
|
118
|
+
// The adapter rewrites <@U0BOT> to <@U0BOT|display name> before converting.
|
|
119
|
+
const markdown = slackMrkdwnToMarkdown("<@U0BOT|Agent Swarm> ask <@U0BOB|Bob> to review");
|
|
120
|
+
const message = messageFromMarkdown(markdown);
|
|
121
|
+
expect(await inboundText(slack("Agent Swarm"), message)).toBe("ask @Bob to review");
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("negative control: another user's display name stays", async () => {
|
|
125
|
+
const markdown = slackMrkdwnToMarkdown("<@U0BOB|Bob> can you check?");
|
|
126
|
+
expect(await inboundText(slack("Agent Swarm"), messageFromMarkdown(markdown))).toBe(
|
|
127
|
+
"@Bob can you check?",
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("a failed lookup still strips the handle form", async () => {
|
|
132
|
+
const markdown = slackMrkdwnToMarkdown("@agent_swarm hi");
|
|
133
|
+
expect(await inboundText(slack(null), messageFromMarkdown(markdown))).toBe("hi");
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe("Teams mentions", () => {
|
|
138
|
+
const APP = "00000000-0000-0000-0000-00000000a99";
|
|
139
|
+
const teams = { name: "teams", userName: "swarm", botUserId: `28:${APP}` } as unknown as Adapter;
|
|
140
|
+
|
|
141
|
+
function activity(text: string, entities: unknown[]) {
|
|
142
|
+
return {
|
|
143
|
+
type: "message",
|
|
144
|
+
text,
|
|
145
|
+
from: { id: "29:user-1", name: "Tester" },
|
|
146
|
+
recipient: { id: `28:${APP}`, name: "Agent Swarm" },
|
|
147
|
+
entities,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
test("strips the bot mention whose display name differs from userName", async () => {
|
|
152
|
+
const bot = { id: `28:${APP}`, name: "Agent Swarm" };
|
|
153
|
+
const raw = activity("<at>Agent Swarm</at> triage with <at>Dana</at>", [
|
|
154
|
+
{ type: "mention", mentioned: bot, text: "<at>Agent Swarm</at>" },
|
|
155
|
+
{ type: "mention", mentioned: { id: "29:user-2", name: "Dana" }, text: "<at>Dana</at>" },
|
|
156
|
+
]);
|
|
157
|
+
const message = messageFromMarkdown(teamsHtmlToMarkdown(raw.text), raw);
|
|
158
|
+
expect(await inboundText(teams, message)).toBe("triage with @Dana");
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("negative control: a user mention with no bot entity stays", async () => {
|
|
162
|
+
const raw = activity("<at>Dana</at> ping", [
|
|
163
|
+
{ type: "mention", mentioned: { id: "29:user-2", name: "Dana" }, text: "<at>Dana</at>" },
|
|
164
|
+
]);
|
|
165
|
+
const message = messageFromMarkdown(teamsHtmlToMarkdown(raw.text), raw);
|
|
166
|
+
expect(await inboundText(teams, message)).toBe("@Dana ping");
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
describe("Telegram and Rocket.Chat mentions", () => {
|
|
171
|
+
test("Telegram: @bot_username strips, @other stays", async () => {
|
|
172
|
+
const telegram = { name: "telegram", userName: "swarm_bot", botUserId: "8000000001" };
|
|
173
|
+
const parsed = new TelegramFormatConverter().parseIncoming("@swarm_bot ask @alice");
|
|
174
|
+
const message = { text: parsed.text, formatted: parsed.formatted, raw: {} } as Message;
|
|
175
|
+
expect(await inboundText(telegram as unknown as Adapter, message)).toBe("ask @alice");
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test("Rocket.Chat: @my-bot strips, @my-bot-two stays", async () => {
|
|
179
|
+
const rocket = { name: "rocketchat", userName: "my-bot", botUserId: "rcBotId" };
|
|
180
|
+
const message = messageFromMarkdown("@my-bot hi @my-bot-two");
|
|
181
|
+
expect(await inboundText(rocket as unknown as Adapter, message)).toBe("hi @my-bot-two");
|
|
182
|
+
});
|
|
183
|
+
});
|
|
@@ -426,6 +426,121 @@ describe("ClaudeSession processStreams — ProviderResult.output capture", () =>
|
|
|
426
426
|
expect(result.output).toBeUndefined();
|
|
427
427
|
});
|
|
428
428
|
|
|
429
|
+
test("a session that ends without a result reports per-message usage as an estimated cost", async () => {
|
|
430
|
+
const usageA = {
|
|
431
|
+
input_tokens: 10,
|
|
432
|
+
output_tokens: 5,
|
|
433
|
+
cache_read_input_tokens: 100,
|
|
434
|
+
cache_creation_input_tokens: 50,
|
|
435
|
+
cache_creation: { ephemeral_5m_input_tokens: 20, ephemeral_1h_input_tokens: 30 },
|
|
436
|
+
};
|
|
437
|
+
const lines = [
|
|
438
|
+
JSON.stringify({ type: "system", subtype: "init", session_id: "sess-1" }),
|
|
439
|
+
// One API message split over two lines: its usage counts once.
|
|
440
|
+
JSON.stringify({
|
|
441
|
+
type: "assistant",
|
|
442
|
+
message: { id: "msg-a", model: "claude-sonnet-5-5", content: [], usage: usageA },
|
|
443
|
+
}),
|
|
444
|
+
JSON.stringify({
|
|
445
|
+
type: "assistant",
|
|
446
|
+
message: { id: "msg-a", model: "claude-sonnet-5-5", content: [], usage: usageA },
|
|
447
|
+
}),
|
|
448
|
+
JSON.stringify({
|
|
449
|
+
type: "assistant",
|
|
450
|
+
message: {
|
|
451
|
+
id: "msg-b",
|
|
452
|
+
model: "claude-sonnet-5-5",
|
|
453
|
+
content: [],
|
|
454
|
+
usage: { input_tokens: 1, output_tokens: 7, cache_read_input_tokens: 200 },
|
|
455
|
+
},
|
|
456
|
+
}),
|
|
457
|
+
// A subagent on another model is billed too.
|
|
458
|
+
JSON.stringify({
|
|
459
|
+
type: "assistant",
|
|
460
|
+
parent_tool_use_id: "tool-1",
|
|
461
|
+
message: {
|
|
462
|
+
id: "msg-c",
|
|
463
|
+
model: "claude-haiku-4-5",
|
|
464
|
+
content: [],
|
|
465
|
+
usage: { input_tokens: 3, output_tokens: 4 },
|
|
466
|
+
},
|
|
467
|
+
}),
|
|
468
|
+
// Claude's local error message carries zero usage and is dropped.
|
|
469
|
+
JSON.stringify({
|
|
470
|
+
type: "assistant",
|
|
471
|
+
message: {
|
|
472
|
+
id: "msg-d",
|
|
473
|
+
model: "<synthetic>",
|
|
474
|
+
content: [],
|
|
475
|
+
usage: { input_tokens: 0, output_tokens: 0 },
|
|
476
|
+
},
|
|
477
|
+
}),
|
|
478
|
+
];
|
|
479
|
+
spawnSpy.mockImplementation((() => makeStreamingFakeProc(lines)) as typeof Bun.spawn);
|
|
480
|
+
|
|
481
|
+
const adapter = new ClaudeAdapter(async () => {});
|
|
482
|
+
const session = await adapter.createSession(makeConfig({ env: CLEAN_ENV }));
|
|
483
|
+
const result = await session.waitForCompletion();
|
|
484
|
+
|
|
485
|
+
expect(result.cost).toMatchObject({
|
|
486
|
+
totalCostUsd: 0,
|
|
487
|
+
estimated: true,
|
|
488
|
+
provider: "claude",
|
|
489
|
+
numTurns: null,
|
|
490
|
+
inputTokens: 14,
|
|
491
|
+
outputTokens: 16,
|
|
492
|
+
cacheReadTokens: 300,
|
|
493
|
+
cacheWriteTokens: 50,
|
|
494
|
+
cacheWrite5mTokens: 20,
|
|
495
|
+
cacheWrite1hTokens: 30,
|
|
496
|
+
models: [
|
|
497
|
+
{
|
|
498
|
+
model: "claude-sonnet-5-5",
|
|
499
|
+
inputTokens: 11,
|
|
500
|
+
outputTokens: 12,
|
|
501
|
+
cacheReadTokens: 300,
|
|
502
|
+
cacheWriteTokens: 50,
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
model: "claude-haiku-4-5",
|
|
506
|
+
inputTokens: 3,
|
|
507
|
+
outputTokens: 4,
|
|
508
|
+
cacheReadTokens: 0,
|
|
509
|
+
cacheWriteTokens: 0,
|
|
510
|
+
},
|
|
511
|
+
],
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
test("the result event's cost wins over the per-message estimate", async () => {
|
|
516
|
+
const lines = [
|
|
517
|
+
JSON.stringify({
|
|
518
|
+
type: "assistant",
|
|
519
|
+
message: { id: "msg-a", content: [], usage: { input_tokens: 10, output_tokens: 5 } },
|
|
520
|
+
}),
|
|
521
|
+
JSON.stringify({ type: "result", total_cost_usd: 0.01, duration_ms: 100, num_turns: 1 }),
|
|
522
|
+
];
|
|
523
|
+
spawnSpy.mockImplementation((() => makeStreamingFakeProc(lines)) as typeof Bun.spawn);
|
|
524
|
+
|
|
525
|
+
const adapter = new ClaudeAdapter(async () => {});
|
|
526
|
+
const session = await adapter.createSession(makeConfig({ env: CLEAN_ENV }));
|
|
527
|
+
const result = await session.waitForCompletion();
|
|
528
|
+
|
|
529
|
+
expect(result.cost?.totalCostUsd).toBe(0.01);
|
|
530
|
+
expect(result.cost?.estimated).toBeUndefined();
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
test("a session with no usage at all reports no cost", async () => {
|
|
534
|
+
const lines = [JSON.stringify({ type: "system", subtype: "init", session_id: "sess-1" })];
|
|
535
|
+
spawnSpy.mockImplementation((() => makeStreamingFakeProc(lines)) as typeof Bun.spawn);
|
|
536
|
+
|
|
537
|
+
const adapter = new ClaudeAdapter(async () => {});
|
|
538
|
+
const session = await adapter.createSession(makeConfig({ env: CLEAN_ENV }));
|
|
539
|
+
const result = await session.waitForCompletion();
|
|
540
|
+
|
|
541
|
+
expect(result.cost).toBeUndefined();
|
|
542
|
+
});
|
|
543
|
+
|
|
429
544
|
test("result cost includes Claude cache TTL split and complete per-model usage", async () => {
|
|
430
545
|
const lines = [
|
|
431
546
|
JSON.stringify({
|
|
@@ -24,7 +24,9 @@ import {
|
|
|
24
24
|
getPageVersions,
|
|
25
25
|
initDb,
|
|
26
26
|
} from "../be/db";
|
|
27
|
+
import { saveDesignSystem } from "../be/design-system";
|
|
27
28
|
import { COLOR_LITERAL_THRESHOLD, countColorLiterals } from "../pages/color-literals";
|
|
29
|
+
import { buildDesignSystem } from "../themes/design-system";
|
|
28
30
|
import { registerCreatePageTool } from "../tools/create-page";
|
|
29
31
|
|
|
30
32
|
const TEST_DB_PATH = "./test-create-page-tool.sqlite";
|
|
@@ -58,6 +60,9 @@ describe("create_page MCP tool", () => {
|
|
|
58
60
|
} catch {}
|
|
59
61
|
}
|
|
60
62
|
initDb(TEST_DB_PATH);
|
|
63
|
+
// A declined design system keeps the first-page ask out of the nudge assertions below
|
|
64
|
+
// (the ask itself is covered by the design-system E2E scenario).
|
|
65
|
+
await saveDesignSystem(buildDesignSystem({ status: "declined" }, { userId: null }).record);
|
|
61
66
|
// The tool reads MCP_BASE_URL / APP_URL when building share URLs.
|
|
62
67
|
delete process.env.PUBLIC_MCP_BASE_URL;
|
|
63
68
|
process.env.MCP_BASE_URL = "http://test-api:9999";
|
|
@@ -4,7 +4,7 @@ import { tmpdir } from "node:os";
|
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { checkProviderCredentials } from "../commands/provider-credentials";
|
|
6
6
|
import { createProviderAdapter } from "../providers";
|
|
7
|
-
import { checkDshCredentials, DshAdapter } from "../providers/dsh-adapter";
|
|
7
|
+
import { checkDshCredentials, DshAdapter, stderrFlushLength } from "../providers/dsh-adapter";
|
|
8
8
|
import type { ProviderEvent, ProviderSessionConfig } from "../providers/types";
|
|
9
9
|
import { DEFAULT_MODEL_TIER_MAP } from "../types";
|
|
10
10
|
import { getModelAwareCredentialVars } from "../utils/credentials";
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
DEFAULT_OPENROUTER_BASE_URL,
|
|
14
14
|
OPENROUTER_APP_ATTRIBUTION_HEADERS,
|
|
15
15
|
} from "../utils/openrouter-base-url";
|
|
16
|
+
import { randomToken } from "./synthetic-secret-helpers";
|
|
16
17
|
|
|
17
18
|
const directories: string[] = [];
|
|
18
19
|
afterEach(async () => {
|
|
@@ -41,6 +42,18 @@ else if (mode === "mcp-fail") {
|
|
|
41
42
|
console.error("dsh: warning: 1 entry did not activate\\nswarm-mcp (@deepseek-ai/dsh-mcp-client): Error: mcp-client(agent-swarm): initial connection or tool synchronization failed");
|
|
42
43
|
setInterval(() => {}, 1000);
|
|
43
44
|
}
|
|
45
|
+
else if (mode === "split-stderr") {
|
|
46
|
+
// A token split across two stderr writes, then a PEM block written one line at a time.
|
|
47
|
+
const value = process.env.DSH_TEST_SPLIT_VALUE;
|
|
48
|
+
process.stderr.write("dsh: upstream echoed " + value.slice(0, 12));
|
|
49
|
+
await Bun.sleep(30);
|
|
50
|
+
process.stderr.write(value.slice(12) + " and failed\\n");
|
|
51
|
+
for (const line of process.env.DSH_TEST_PEM.split("\\n")) {
|
|
52
|
+
await Bun.sleep(5);
|
|
53
|
+
process.stderr.write(line + "\\n");
|
|
54
|
+
}
|
|
55
|
+
process.exitCode = 3;
|
|
56
|
+
}
|
|
44
57
|
else {
|
|
45
58
|
if (mode === "usage") {
|
|
46
59
|
emit({ type: "status", phase: "step_end", turn: 1, step: 1, usage: { inputTokens: 1000, outputTokens: 50, cacheReadTokens: 9000 } });
|
|
@@ -412,6 +425,45 @@ describe("dsh harness", () => {
|
|
|
412
425
|
});
|
|
413
426
|
}
|
|
414
427
|
|
|
428
|
+
test("scrubs stderr per line, so a token split across chunks is still redacted", async () => {
|
|
429
|
+
const config = await fixture("split-stderr");
|
|
430
|
+
const token = ["ghp", randomToken(36)].join("_");
|
|
431
|
+
const body = [randomToken(64), randomToken(64), randomToken(20)];
|
|
432
|
+
// Armor lines are joined at runtime so repo secret scanners never see a BEGIN/END pair.
|
|
433
|
+
const [begin, end] = ["BEGIN", "END"].map((word) =>
|
|
434
|
+
["-----", word, " PRIVATE KEY-----"].join(""),
|
|
435
|
+
);
|
|
436
|
+
const pem = [begin, ...body, end].join("\n");
|
|
437
|
+
config.env = { ...config.env, DSH_TEST_SPLIT_VALUE: token, DSH_TEST_PEM: pem };
|
|
438
|
+
const session = await new DshAdapter().createSession(config);
|
|
439
|
+
const events: ProviderEvent[] = [];
|
|
440
|
+
session.onEvent((event) => events.push(event));
|
|
441
|
+
const result = await session.waitForCompletion();
|
|
442
|
+
expect(result.isError).toBe(true);
|
|
443
|
+
const wire = JSON.stringify({ result, events });
|
|
444
|
+
for (const secret of [token, token.slice(0, 12), token.slice(12), ...body]) {
|
|
445
|
+
expect(wire).not.toContain(secret);
|
|
446
|
+
}
|
|
447
|
+
const stderr = events.flatMap((event) => (event.type === "raw_stderr" ? [event.content] : []));
|
|
448
|
+
expect(stderr.join("")).toContain("dsh: upstream echoed [REDACTED:github_token] and failed\n");
|
|
449
|
+
expect(stderr.join("")).toContain(`${begin}[REDACTED:private_key]${end}\n`);
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
test("stderrFlushLength holds a partial line and an open private-key block", () => {
|
|
453
|
+
expect(stderrFlushLength("no newline yet")).toBe(0);
|
|
454
|
+
expect(stderrFlushLength("one\ntwo")).toBe(4);
|
|
455
|
+
const [begin, end] = ["BEGIN", "END"].map((word) =>
|
|
456
|
+
["-----", word, " RSA PRIVATE KEY-----"].join(""),
|
|
457
|
+
);
|
|
458
|
+
expect(stderrFlushLength(`log line\n${begin}\nAAAA\n`)).toBe(9);
|
|
459
|
+
expect(stderrFlushLength(`${begin}\nAAAA\n${end}\nnext`)).toBe(begin.length + 1 + 5 + 30);
|
|
460
|
+
// A public certificate is not held.
|
|
461
|
+
expect(stderrFlushLength("-----BEGIN CERTIFICATE-----\nAAAA\n")).toBe(33);
|
|
462
|
+
// Past the hold cap everything goes; the scrubber's truncated-PEM rule covers the cut block.
|
|
463
|
+
const big = `${begin}\n${"A".repeat(70_000)}`;
|
|
464
|
+
expect(stderrFlushLength(big)).toBe(big.length);
|
|
465
|
+
});
|
|
466
|
+
|
|
415
467
|
test("abort terminates a running process and removes its patch", async () => {
|
|
416
468
|
const config = await fixture("abort");
|
|
417
469
|
const session = await new DshAdapter().createSession(config);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Exercise the API's real database boot against a packaged migration directory.
|
|
2
|
+
import { closeDb, initDb } from "../../be/db";
|
|
3
|
+
|
|
4
|
+
const dbPath = process.argv[2];
|
|
5
|
+
if (!dbPath) throw new Error("usage: compiled-source-schema-boot <db-path>");
|
|
6
|
+
|
|
7
|
+
const realLog = console.log;
|
|
8
|
+
console.log = () => {};
|
|
9
|
+
console.debug = () => {};
|
|
10
|
+
console.warn = () => {};
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
initDb(dbPath);
|
|
14
|
+
realLog(JSON.stringify({ ok: true }));
|
|
15
|
+
} catch (error) {
|
|
16
|
+
realLog(
|
|
17
|
+
JSON.stringify({
|
|
18
|
+
ok: false,
|
|
19
|
+
error: error instanceof Error ? error.message : String(error),
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
} finally {
|
|
23
|
+
closeDb();
|
|
24
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{"sessionUpdate":"agent_message_chunk","messageId":"b86bad695b6f80234f85a6ae84770a00","content":{"type":"text","text":"[context] 114 always-loaded MCP tools exceeded the mcp_selected_schema_bytes budget and stay available through
|
|
1
|
+
{"sessionUpdate":"agent_message_chunk","messageId":"b86bad695b6f80234f85a6ae84770a00","content":{"type":"text","text":"[context] 114 always-loaded MCP tools exceeded the mcp_selected_schema_bytes budget and stay available through toolbox"}}
|
|
2
2
|
{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":"**Following developer instructions**\n\nI need to ensure I follow the developer's instructions perfectly. First, I’ll send a brief update to the user about the goal and the next step. Then, I’ll call th…"}}
|
|
3
3
|
{"sessionUpdate":"agent_message_chunk","messageId":"e6788e35f07ecb7d4b22767ec6028538","content":{"type":"text","text":"Goal: fetch the swarm agent list with mcp_swarm_get-swarm as the next step, then run the sleep command. I'll call mcp_swarm_get-swarm now."}}
|
|
4
4
|
{"sessionUpdate":"tool_call","toolCallId":"call_kK1rqCaYaXn16uKH9e6fmb7v","name":"mcp_swarm_get-swarm","title":"Get the agent swarm","kind":"other","status":"pending","rawInput":{},"_meta":{"fx":{"toolCall":{"internal":false,"mcp":{"server":"swarm","tool":"get-swarm"}}}}}
|
|
@@ -93,6 +93,37 @@ export function buildPositives(): CorpusPositive[] {
|
|
|
93
93
|
),
|
|
94
94
|
positive("xai", join("xai", "-", rand(ALNUM, 80))),
|
|
95
95
|
|
|
96
|
+
// Shapes from svn-arv/redacted's benchmark that no pass caught.
|
|
97
|
+
positive("stripe webhook secret", join("whsec", "_", rand(ALNUM, 32))),
|
|
98
|
+
positive("groq", join("gsk", "_", rand(ALNUM, 52))),
|
|
99
|
+
positive("tavily", join("tvly", "-", rand(ALNUM, 32))),
|
|
100
|
+
positive("tavily dev", join("tvly", "-dev-", rand(ALNUM, 32))),
|
|
101
|
+
positive("langsmith personal token", join("lsv2", "_pt_", rand(HEX, 32), "_", rand(HEX, 10))),
|
|
102
|
+
positive("langsmith service key", join("lsv2", "_sk_", rand(HEX, 32), "_", rand(HEX, 10))),
|
|
103
|
+
positive("circleci", join("CCIPAT", "_", rand(ALNUM, 22), "_", rand(HEX, 40))),
|
|
104
|
+
positive("google api key v2", join("AQ", ".", rand(URLSAFE, 53))),
|
|
105
|
+
positive(
|
|
106
|
+
"hubspot private app",
|
|
107
|
+
join(
|
|
108
|
+
"pat",
|
|
109
|
+
"-na1-",
|
|
110
|
+
rand(HEX, 8),
|
|
111
|
+
"-",
|
|
112
|
+
rand(HEX, 4),
|
|
113
|
+
"-",
|
|
114
|
+
rand(HEX, 4),
|
|
115
|
+
"-",
|
|
116
|
+
rand(HEX, 4),
|
|
117
|
+
"-",
|
|
118
|
+
rand(HEX, 12),
|
|
119
|
+
),
|
|
120
|
+
),
|
|
121
|
+
positive("new relic without keyword", join("NRAK", "-", rand(UPPER_ALNUM, 27))),
|
|
122
|
+
positive("sentry dsn key", rand(HEX, 32), {
|
|
123
|
+
context: (s) =>
|
|
124
|
+
`Sentry.init({ dsn: "https://${s}@o${rand(DIGITS, 6)}.ingest.us.sentry.io/${rand(DIGITS, 7)}" })`,
|
|
125
|
+
}),
|
|
126
|
+
|
|
96
127
|
// Providers we integrate with.
|
|
97
128
|
positive("github classic pat", join("ghp", "_", rand(ALNUM, 36))),
|
|
98
129
|
positive("github fine-grained pat", join("github", "_pat_", rand(ALNUM, 82))),
|
|
@@ -148,9 +179,9 @@ export function buildPositives(): CorpusPositive[] {
|
|
|
148
179
|
context: (s) => `mailgun: ${s}`,
|
|
149
180
|
gitleaksRule: "mailgun-private-api-token",
|
|
150
181
|
}),
|
|
182
|
+
// Pass 2's newrelic_key takes it first; the keyword context still redacts.
|
|
151
183
|
positive("new relic", join("NRAK", "-", rand(UPPER_ALNUM, 27)), {
|
|
152
184
|
context: (s) => `newrelic = ${s}`,
|
|
153
|
-
gitleaksRule: "new-relic-user-api-key",
|
|
154
185
|
}),
|
|
155
186
|
positive("vault service token", join("hvs", ".", rand(ALNUM, 96)), {
|
|
156
187
|
gitleaksRule: "vault-service-token",
|
|
@@ -315,6 +346,17 @@ export function buildNegatives(): string[] {
|
|
|
315
346
|
"ntn_ prefix belongs to Notion",
|
|
316
347
|
"fo1_ prefix belongs to Fly.io",
|
|
317
348
|
"the stripe dashboard shows sk_live_ keys masked",
|
|
349
|
+
"https://docs.sentry.io/platforms/javascript/configuration/options/#dsn",
|
|
350
|
+
"https://o123.ingest.us.sentry.io/api/123/envelope/",
|
|
351
|
+
"whsec_ prefix marks a Stripe webhook secret",
|
|
352
|
+
"gsk_ is the Groq key prefix",
|
|
353
|
+
"tvly-dev keys are rate limited",
|
|
354
|
+
"lsv2_pt_ tokens belong to LangSmith",
|
|
355
|
+
"CCIPAT_ is a CircleCI token prefix",
|
|
356
|
+
"AQ. is the prefix of a newer Gemini key",
|
|
357
|
+
"pat-na1 is the HubSpot US region",
|
|
358
|
+
"NRAK-1234 is a ticket id",
|
|
359
|
+
"-----BEGIN PRIVATE KEY----- marks a PEM key, see docs",
|
|
318
360
|
);
|
|
319
361
|
return out;
|
|
320
362
|
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import { unlink } from "node:fs/promises";
|
|
3
|
+
import {
|
|
4
|
+
closeDb,
|
|
5
|
+
createAgent,
|
|
6
|
+
createTaskExtended,
|
|
7
|
+
getDbClient,
|
|
8
|
+
getTaskById,
|
|
9
|
+
initDb,
|
|
10
|
+
insertActiveSession,
|
|
11
|
+
startTask,
|
|
12
|
+
} from "../be/db";
|
|
13
|
+
import { codeLevelTriage } from "../heartbeat/heartbeat";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* #3170: `HEARTBEAT_STALL_NO_SESSION_MIN` and `HEARTBEAT_STALL_STALE_HB_MIN` kept a
|
|
17
|
+
* non-positive or non-finite value through `Number(value) || default`, and a
|
|
18
|
+
* threshold <= 0 makes `taskAgeMs >= threshold * 60_000` true for every task, so the
|
|
19
|
+
* first sweep auto-superseded a task seconds after it started.
|
|
20
|
+
*
|
|
21
|
+
* These branches are unreachable black-box: the values arrive only through the
|
|
22
|
+
* deployment environment (`swarm_config`'s guard already rejects them, and the E2E
|
|
23
|
+
* runner fixes the SUT env at boot). That is the reason carried by this file's line
|
|
24
|
+
* in `scripts/unit-test-allowlist.txt`; the cases drive the public
|
|
25
|
+
* `codeLevelTriage()` rather than exporting the parsers.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const TEST_DB_PATH = "./test-heartbeat-stall-thresholds.sqlite";
|
|
29
|
+
|
|
30
|
+
const ORIGINAL_ENV = {
|
|
31
|
+
HEARTBEAT_STALL_NO_SESSION_MIN: process.env.HEARTBEAT_STALL_NO_SESSION_MIN,
|
|
32
|
+
HEARTBEAT_STALL_STALE_HB_MIN: process.env.HEARTBEAT_STALL_STALE_HB_MIN,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type StartedTask = { taskId: string; agentId: string };
|
|
36
|
+
|
|
37
|
+
function minutesAgo(minutes: number): string {
|
|
38
|
+
return new Date(Date.now() - minutes * 60 * 1000).toISOString();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A busy worker with one in_progress task whose last update is `ageMin` minutes old. */
|
|
42
|
+
async function startedTask(ageMin: number): Promise<StartedTask> {
|
|
43
|
+
const agent = await createAgent({
|
|
44
|
+
name: "stall-threshold-worker",
|
|
45
|
+
isLead: false,
|
|
46
|
+
status: "busy",
|
|
47
|
+
});
|
|
48
|
+
const task = await createTaskExtended(`Task last updated ${ageMin} min ago`, {
|
|
49
|
+
agentId: agent.id,
|
|
50
|
+
});
|
|
51
|
+
await startTask(task.id);
|
|
52
|
+
await getDbClient().run("UPDATE agent_tasks SET lastUpdatedAt = ? WHERE id = ?", [
|
|
53
|
+
minutesAgo(ageMin),
|
|
54
|
+
task.id,
|
|
55
|
+
]);
|
|
56
|
+
return { taskId: task.id, agentId: agent.id };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Attach an active session whose heartbeat is `ageMin` minutes old. */
|
|
60
|
+
async function withSessionHeartbeat(
|
|
61
|
+
{ taskId, agentId }: StartedTask,
|
|
62
|
+
ageMin: number,
|
|
63
|
+
): Promise<void> {
|
|
64
|
+
await insertActiveSession({ agentId, taskId, triggerType: "task_assigned" });
|
|
65
|
+
await getDbClient().run("UPDATE active_sessions SET lastHeartbeatAt = ? WHERE taskId = ?", [
|
|
66
|
+
minutesAgo(ageMin),
|
|
67
|
+
taskId,
|
|
68
|
+
]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function expectNoStall(...tasks: StartedTask[]): Promise<void> {
|
|
72
|
+
const findings = await codeLevelTriage();
|
|
73
|
+
expect(findings.stalledTasks).toEqual([]);
|
|
74
|
+
expect(findings.autoResumedTasks).toEqual([]);
|
|
75
|
+
expect(findings.autoFailedTasks).toEqual([]);
|
|
76
|
+
for (const { taskId } of tasks) {
|
|
77
|
+
expect((await getTaskById(taskId))?.status).toBe("in_progress");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
describe("Heartbeat stall thresholds (#3170)", () => {
|
|
82
|
+
beforeAll(async () => {
|
|
83
|
+
try {
|
|
84
|
+
await unlink(TEST_DB_PATH);
|
|
85
|
+
} catch {
|
|
86
|
+
// File doesn't exist
|
|
87
|
+
}
|
|
88
|
+
closeDb();
|
|
89
|
+
initDb(TEST_DB_PATH);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
afterAll(async () => {
|
|
93
|
+
closeDb();
|
|
94
|
+
try {
|
|
95
|
+
await unlink(TEST_DB_PATH);
|
|
96
|
+
await unlink(`${TEST_DB_PATH}-wal`);
|
|
97
|
+
await unlink(`${TEST_DB_PATH}-shm`);
|
|
98
|
+
} catch {
|
|
99
|
+
// Files may not exist
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
beforeEach(async () => {
|
|
104
|
+
await getDbClient().run("DELETE FROM agent_tasks");
|
|
105
|
+
await getDbClient().run("DELETE FROM agents");
|
|
106
|
+
await getDbClient().run("DELETE FROM active_sessions");
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
afterEach(() => {
|
|
110
|
+
for (const [key, value] of Object.entries(ORIGINAL_ENV)) {
|
|
111
|
+
if (value === undefined) delete process.env[key];
|
|
112
|
+
else process.env[key] = value;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe("HEARTBEAT_STALL_NO_SESSION_MIN", () => {
|
|
117
|
+
for (const raw of ["-1", "0", "NaN", "Infinity", "-Infinity"]) {
|
|
118
|
+
test(`falls back to 5 minutes when set to ${raw}`, async () => {
|
|
119
|
+
process.env.HEARTBEAT_STALL_NO_SESSION_MIN = raw;
|
|
120
|
+
// One minute old, no active session: well inside the documented 5-minute window.
|
|
121
|
+
const recent = await startedTask(1);
|
|
122
|
+
|
|
123
|
+
await expectNoStall(recent);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
test("keeps a fractional threshold", async () => {
|
|
128
|
+
process.env.HEARTBEAT_STALL_NO_SESSION_MIN = "0.5";
|
|
129
|
+
// 12 s old: inside 0.5 min, and below the candidate scan's 30 s cutoff.
|
|
130
|
+
const recent = await startedTask(0.2);
|
|
131
|
+
// 2 min old: past 0.5 min (and spared by the 5-minute default this PR restores).
|
|
132
|
+
const stalled = await startedTask(2);
|
|
133
|
+
|
|
134
|
+
const findings = await codeLevelTriage();
|
|
135
|
+
|
|
136
|
+
expect(findings.autoResumedTasks.map((resume) => resume.taskId)).toEqual([stalled.taskId]);
|
|
137
|
+
expect(findings.autoResumedTasks[0]!.reason).toContain("no active session");
|
|
138
|
+
expect((await getTaskById(stalled.taskId))?.status).toBe("superseded");
|
|
139
|
+
expect((await getTaskById(recent.taskId))?.status).toBe("in_progress");
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe("HEARTBEAT_STALL_STALE_HB_MIN", () => {
|
|
144
|
+
for (const raw of ["-1", "0", "NaN", "Infinity", "-Infinity"]) {
|
|
145
|
+
test(`falls back to 15 minutes when set to ${raw}`, async () => {
|
|
146
|
+
process.env.HEARTBEAT_STALL_STALE_HB_MIN = raw;
|
|
147
|
+
// Six minutes old: past the 5-minute candidate scan, inside the 30-minute
|
|
148
|
+
// fresh-stalled threshold, and its one-minute-old heartbeat is fresh.
|
|
149
|
+
const recent = await startedTask(6);
|
|
150
|
+
await withSessionHeartbeat(recent, 1);
|
|
151
|
+
|
|
152
|
+
await expectNoStall(recent);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
test("keeps a fractional threshold", async () => {
|
|
157
|
+
process.env.HEARTBEAT_STALL_STALE_HB_MIN = "0.5";
|
|
158
|
+
// A one-minute-old heartbeat is stale at 0.5 min, so a 6-minute-old task is past
|
|
159
|
+
// both halves of the threshold. The 15-minute default spares it.
|
|
160
|
+
const crashed = await startedTask(6);
|
|
161
|
+
await withSessionHeartbeat(crashed, 1);
|
|
162
|
+
// A 6 s heartbeat stays fresh at any threshold.
|
|
163
|
+
const alive = await startedTask(6);
|
|
164
|
+
await withSessionHeartbeat(alive, 0.1);
|
|
165
|
+
|
|
166
|
+
const findings = await codeLevelTriage();
|
|
167
|
+
|
|
168
|
+
expect(findings.autoResumedTasks.map((resume) => resume.taskId)).toEqual([crashed.taskId]);
|
|
169
|
+
expect(findings.autoResumedTasks[0]!.reason).toContain("stale");
|
|
170
|
+
expect((await getTaskById(crashed.taskId))?.status).toBe("superseded");
|
|
171
|
+
expect((await getTaskById(alive.taskId))?.status).toBe("in_progress");
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
});
|