@desplega.ai/agent-swarm 2.10.0 → 2.11.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-weaaxey3.js +16 -0
- package/dist/{acp-targets-arrwv4f0.js → acp-targets-5wyy2b9m.js} +9 -9
- package/dist/{actions-y0d2n1c2.js → actions-4nxq386s.js} +24 -23
- package/dist/{agent-fs-provision-tpj7sktd.js → agent-fs-provision-v6enh76w.js} +4 -4
- package/dist/{amp-adapter-vmmnmw8d.js → amp-adapter-ze3x22qn.js} +3 -3
- package/dist/{anthropic-messages-zdca3gv1.js → anthropic-messages-88b7s3n9.js} +177 -25
- package/dist/{app-wb7w45dq.js → app-kyqt8ehw.js} +7 -6
- package/dist/{approval-notifications-7mqr6vbd.js → approval-notifications-a0db0esw.js} +7 -6
- package/dist/{assistant-gf60454p.js → assistant-9g5jzq25.js} +26 -25
- package/dist/{azure-openai-responses-b3y7fz36.js → azure-openai-responses-jeaas6x0.js} +10 -10
- package/dist/{boot-args-schema-qxmd59sr.js → boot-args-schema-d7fme4q1.js} +1 -1
- package/dist/{boot-reembed-wb44vc3s.js → boot-reembed-6wpazmpw.js} +1 -1
- package/dist/{boot-reembed-5tmeskj2.js → boot-reembed-jrwxeye2.js} +1 -1
- package/dist/{boot-scrub-sweep-25bxhnw4.js → boot-scrub-sweep-52h7yntp.js} +2 -2
- package/dist/{boot-seeds-nj9za0vk.js → boot-seeds-kb3dxjex.js} +4 -4
- package/dist/{boxd-wn235q80.js → boxd-jrrmkv3w.js} +2 -2
- package/dist/{claude-adapter-d3krpdyb.js → claude-adapter-0c0y8fqp.js} +8 -8
- package/dist/{claude-managed-adapter-t8nfgcgz.js → claude-managed-adapter-w2es07qq.js} +4 -4
- package/dist/{claude-managed-setup-7y4pwd81.js → claude-managed-setup-9ssb7ct4.js} +4 -4
- package/dist/{claude-sdk-session-d138zy0e.js → claude-sdk-session-p6t0gyse.js} +10941 -10412
- package/dist/{cli-p0n7b5rz.js → cli-075ccjh6.js} +344 -130
- package/dist/{cli-3caf7pmg.js → cli-0bgj4rh5.js} +3 -3
- package/dist/{cli-7r162fxe.js → cli-14xdms9a.js} +23 -17
- package/dist/{cli-rqx70rcz.js → cli-17qzb39j.js} +5 -2
- package/dist/{cli-y4ccxtz5.js → cli-1h4njv9y.js} +144 -6
- package/dist/{cli-6ym4jhzp.js → cli-27fat7st.js} +7 -7
- package/dist/{cli-k3q2va86.js → cli-2aacfdcn.js} +5 -5
- package/dist/{cli-vq2eg24x.js → cli-2gvdvsxj.js} +3 -3
- package/dist/{cli-sb4426be.js → cli-2jtfm8kh.js} +5 -5
- package/dist/{cli-6ehs4mta.js → cli-2z2c4k6q.js} +18 -4
- package/dist/{cli-6237rnyr.js → cli-3bpr3wks.js} +1 -1
- package/dist/{cli-5qhfv9rw.js → cli-453497a0.js} +44 -17
- package/dist/{cli-2rnd5j3t.js → cli-4aswccje.js} +2 -2
- package/dist/{cli-4ymxrwg5.js → cli-4dyzzkfb.js} +2 -2
- package/dist/{cli-p0c3vtch.js → cli-4g323fjh.js} +772 -515
- package/dist/{cli-3kd08rej.js → cli-4jjrhy48.js} +1 -1
- package/dist/{cli-fcfbct2j.js → cli-4kzp7r0q.js} +5 -5
- package/dist/{cli-kxn3747f.js → cli-4se3x6qm.js} +1 -26
- package/dist/{cli-zeh2mhkg.js → cli-5ptj757f.js} +1 -1
- package/dist/{cli-539h29es.js → cli-6a3j25xd.js} +224 -189
- package/dist/{cli-hnamkvnc.js → cli-6c9ve77f.js} +2 -2
- package/dist/{cli-3et6fmfe.js → cli-6n7y5ypy.js} +1 -1
- package/dist/{cli-8y43jx2r.js → cli-6p8p2e6r.js} +16 -9
- package/dist/{cli-zk7v5s89.js → cli-6tvh1fwq.js} +3 -3
- package/dist/{cli-p74md7t8.js → cli-7b7rxz22.js} +13 -15
- package/dist/{cli-5a6pqy45.js → cli-7e8sxqv5.js} +1 -1
- package/dist/{cli-6037prsx.js → cli-892y3vfp.js} +13 -13
- package/dist/cli-8mfdbdhe.js +43 -0
- package/dist/{cli-s1zqk1aj.js → cli-8zmpwe79.js} +15 -9
- package/dist/{cli-zcfpsfzf.js → cli-96234j5w.js} +3 -3
- package/dist/{cli-1z4qggfe.js → cli-9fvk9mv8.js} +30 -21
- package/dist/{cli-7mv4h3sn.js → cli-9g12h1aq.js} +2 -2
- package/dist/{cli-aw83sr40.js → cli-9knhkkgr.js} +3 -3
- package/dist/{cli-5mpy301f.js → cli-9t7syepg.js} +1 -1
- package/dist/{cli-qj39vrc6.js → cli-9yjhshah.js} +1 -1
- package/dist/{cli-6cwr32fe.js → cli-a02habn6.js} +422 -140
- package/dist/{cli-7evph51z.js → cli-a49frv85.js} +2 -2
- package/dist/{cli-3f8zbtqa.js → cli-a6q6x15h.js} +9 -8
- package/dist/{cli-j6te8keb.js → cli-atm0hkes.js} +8 -8
- package/dist/{cli-9fjr27ez.js → cli-b82a13ga.js} +13 -13
- package/dist/{cli-7zm3b3f5.js → cli-bf0t77nf.js} +1 -1
- package/dist/{cli-2xv18ywz.js → cli-bmqp0ser.js} +2 -2
- package/dist/{cli-mk7c5ac4.js → cli-bq97k63w.js} +2 -2
- package/dist/{cli-vfqvrd82.js → cli-cstggwq7.js} +2 -2
- package/dist/{cli-md50mj0r.js → cli-czvvnfr9.js} +3 -3
- package/dist/{cli-b6px1k1q.js → cli-dd2k2mcd.js} +1 -1
- package/dist/{cli-fq2rr3jb.js → cli-djt6wmrc.js} +6 -6
- package/dist/{cli-tsa40663.js → cli-ebqx630g.js} +3 -3
- package/dist/{cli-z0m452jr.js → cli-f7dhm7hh.js} +1 -1
- package/dist/{cli-mys27d03.js → cli-f8yhybxr.js} +3 -3
- package/dist/{cli-5gpqgs8b.js → cli-fwjwkw66.js} +2 -2
- package/dist/{cli-gabsjg8x.js → cli-g56fxddf.js} +1 -1
- package/dist/{cli-y8p78ekx.js → cli-h2qtafm4.js} +18 -18
- package/dist/{cli-psffsanb.js → cli-ha4ek2nb.js} +6 -1
- package/dist/{cli-th1dkc2v.js → cli-hnh8erra.js} +2 -2
- package/dist/{cli-w16kwbzw.js → cli-htymm48w.js} +1 -1
- package/dist/{cli-124ntmf0.js → cli-j2r1apqm.js} +138 -59
- package/dist/{cli-43ms35q9.js → cli-k3c13za2.js} +3 -3
- package/dist/{cli-54vrpgm0.js → cli-k3facve0.js} +8 -5
- package/dist/{cli-v8z0yga9.js → cli-k4r5sfaj.js} +4 -4
- package/dist/{cli-91pkxres.js → cli-kbm659dk.js} +2 -2
- package/dist/{cli-q5srsxq2.js → cli-m00c47q6.js} +110 -27
- package/dist/{cli-3aaeb78m.js → cli-mhrr4d5b.js} +95 -10
- package/dist/{cli-xqdz5cqm.js → cli-mz7ycqn8.js} +1 -0
- package/dist/{cli-qrta34nb.js → cli-n6ygvrrm.js} +4 -4
- package/dist/{cli-k5yewqgd.js → cli-nbakg5xh.js} +3 -3
- package/dist/{cli-nstkanmx.js → cli-nc39ym5q.js} +8 -8
- package/dist/{cli-01k6wpr9.js → cli-p1a4khta.js} +7 -7
- package/dist/{cli-t9ga4qmb.js → cli-p8zqbbt1.js} +40 -33
- package/dist/{cli-v46zsvqk.js → cli-ph95yejc.js} +2 -2
- package/dist/{cli-k6nejceb.js → cli-q4z9s6zs.js} +2 -2
- package/dist/{cli-kbtzfrxj.js → cli-q71g5q39.js} +3 -3
- package/dist/{cli-vs9vdpy0.js → cli-qncx2r0s.js} +1 -1
- package/dist/{cli-hg42n3hx.js → cli-qrzq3hvg.js} +8 -8
- package/dist/{cli-x40a0w9j.js → cli-r813c7rb.js} +1 -1
- package/dist/{cli-kpgcm7xy.js → cli-ramn8jae.js} +1 -1
- package/dist/{cli-cc93xzes.js → cli-raqw9fw9.js} +28 -17
- package/dist/cli-rhsc2zyx.js +68 -0
- package/dist/{cli-8st34zhr.js → cli-rpmw4fsv.js} +57 -19
- package/dist/{cli-had1p04a.js → cli-rwgwen5v.js} +4 -4
- package/dist/{cli-tr27kwyg.js → cli-rytq7dm2.js} +261 -6
- package/dist/{cli-s1khw52h.js → cli-s9twe4x0.js} +66 -17
- package/dist/{cli-2v2zdm0a.js → cli-t2s7j5cy.js} +2 -2
- package/dist/{cli-nv4xsvmk.js → cli-tb4j757d.js} +7 -7
- package/dist/{cli-q2d3e1k1.js → cli-thd3005a.js} +1 -1
- package/dist/cli-tsfkcd4v.js +30 -0
- package/dist/{cli-jrbq4djp.js → cli-v3zcnr8g.js} +1 -1
- package/dist/{cli-zfqg6fzn.js → cli-vbppqvte.js} +3 -3
- package/dist/{cli-qx4f057j.js → cli-vy3fn0mz.js} +4 -4
- package/dist/{cli-7sf9sb0w.js → cli-w5dar1bk.js} +1 -1
- package/dist/{cli-w1q68d8x.js → cli-wz4e5am2.js} +9 -9
- package/dist/{cli-m9cvf7vs.js → cli-xqbqwpxr.js} +14 -14
- package/dist/{cli-2spnz7ye.js → cli-ynph3b70.js} +11137 -8332
- package/dist/{cli-43evxwj4.js → cli-yvzxbztc.js} +9 -4
- package/dist/{cli-vsw91x06.js → cli-yzxqwcvq.js} +3 -6
- package/dist/{cli-wafmk3fn.js → cli-zb1hff00.js} +12 -12
- package/dist/{cli-yab6sh8p.js → cli-zcghfsdg.js} +23 -4
- package/dist/{cli-wwp1bd3n.js → cli-zhn4r1rz.js} +519 -75
- package/dist/{cli-tvgqesec.js → cli-zqq57pgx.js} +4 -4
- package/dist/cli.js +28 -27
- package/dist/{cloudflare-workers-ai-system-one-4aysy6rh.js → cloudflare-workers-ai-system-one-w3m0fbf8.js} +2 -2
- package/dist/{codex-adapter-exfdbj73.js → codex-adapter-ssahg4h4.js} +8 -8
- package/dist/{codex-hook-59atdwd8.js → codex-hook-aqtj17yr.js} +1 -1
- package/dist/{codex-login-a239g1ah.js → codex-login-9c7aggxe.js} +1 -1
- package/dist/{codex-session-runner-xhznc4g3.js → codex-session-runner-xn63q3h7.js} +9 -9
- package/dist/{commands-d8g349v4.js → commands-ctey7tr5.js} +3 -3
- package/dist/{controller-mwgdmb8y.js → controller-rqhbppg9.js} +4 -4
- package/dist/{controllers-connect-5v7qx04j.js → controllers-connect-w3qbpbt1.js} +22 -21
- package/dist/{core-sxy4epp2.js → core-df1n049h.js} +19 -18
- package/dist/{cursor-adapter-p2q5h35d.js → cursor-adapter-r819hf1a.js} +2 -2
- package/dist/{db-wcw0b2j8.js → db-2ah39cyx.js} +2 -2
- package/dist/{db-qpganbeb.js → db-p5drc1d1.js} +3 -3
- package/dist/{devin-adapter-zp4tqq53.js → devin-adapter-bc6g0x29.js} +1 -1
- package/dist/{dispatcher-8d8s49yz.js → dispatcher-x6w14pde.js} +19 -18
- package/dist/{docker-09tkkg0n.js → docker-6c4reetq.js} +51 -14
- package/dist/{dsh-adapter-me0twn13.js → dsh-adapter-h8qn14n4.js} +2 -2
- package/dist/{e2b-sm28k0k3.js → e2b-jg7kyyef.js} +6 -6
- package/dist/{e2b-3v1e745x.js → e2b-z4ec0qve.js} +3 -3
- package/dist/{easter-egg-3d-wv7w5ty6.js → easter-egg-3d-1y6r9gxy.js} +1 -1
- package/dist/{embedding-space-e48xchqa.js → embedding-space-z6ptw3jk.js} +6 -6
- package/dist/{embeddings-tgq2afbq.js → embeddings-0sxb1d2h.js} +1 -1
- package/dist/{event-bus-xr83x566.js → event-bus-swr88jg5.js} +1 -1
- package/dist/{execute-8rhwrk7f.js → execute-6m1ex8ce.js} +8 -4
- package/dist/{external-channel-8bt3j2pm.js → external-channel-ezer7pk0.js} +2 -2
- package/dist/fx-adapter-zwmps9re.js +19 -0
- package/dist/{google-generative-ai-bh0djqjp.js → google-generative-ai-sw77egmr.js} +9 -9
- package/dist/{google-vertex-prjbw8dj.js → google-vertex-rrw93g8h.js} +9 -9
- package/dist/grok-adapter-q0avf919.js +19 -0
- package/dist/handlers-g5jq0e4q.js +36 -0
- package/dist/{heartbeat-x0056ra5.js → heartbeat-6c4fr49t.js} +22 -21
- package/dist/{hook-mrd2ayxv.js → hook-02rt5tvq.js} +8 -8
- package/dist/{hook-a7vmn2st.js → hook-t1c5avbv.js} +5 -5
- package/dist/{http-ym9c5svp.js → http-qa3h32a1.js} +2049 -148
- package/dist/index-1f6m47mq.js +37 -0
- package/dist/index-1p1mpqda.js +36 -0
- package/dist/{index-p46tvwtx.js → index-akbgsdhh.js} +25 -24
- package/dist/{index-ny60jcat.js → index-e42j998x.js} +16 -13
- package/dist/{index-b5wgnm78.js → index-kdmkfjt7.js} +4 -4
- package/dist/{index-01ns1pkw.js → index-kqv9ebfj.js} +1 -1
- package/dist/{index-9myfj74s.js → index-kzdqn3dd.js} +3 -3
- package/dist/{index-4a0670yh.js → index-p2f5xg64.js} +6 -6
- package/dist/{index-x6azjwm8.js → index-qpjk2hxk.js} +1 -1
- package/dist/index-tnkd410q.js +41 -0
- package/dist/{k8s-m56sw868.js → k8s-7jrh5va2.js} +73 -14
- package/dist/{keepalive-7yxg8z4c.js → keepalive-jmf6pn8c.js} +4 -4
- package/dist/lead-m5e7xt93.js +75 -0
- package/dist/{llama-cpp-classify-nfgswa1m.js → llama-cpp-classify-yvb8vh7w.js} +2 -2
- package/dist/{maintenance-6tefxmk1.js → maintenance-g7v15tj1.js} +1 -1
- package/dist/{mistral-conversations-tm2vd4gc.js → mistral-conversations-w4bncwbt.js} +7 -7
- package/dist/{node-7qsx5kvm.js → node-z67yjre7.js} +19 -13
- package/dist/{oauth-refresh-sweep-70cavc3a.js → oauth-refresh-sweep-ywgf8tbr.js} +3 -3
- package/dist/{onboard-fja65z08.js → onboard-m3fedypq.js} +3 -3
- package/dist/{openai-codex-responses-sxjv60xx.js → openai-codex-responses-70g39cgz.js} +20 -14
- package/dist/{openai-completions-0c7qnhsx.js → openai-completions-cv3hp4h5.js} +18 -11
- package/dist/{openai-decisions-ytp6w6xh.js → openai-decisions-fyq1p9f9.js} +2 -2
- package/dist/{openai-responses-a7h29chp.js → openai-responses-trsvnks6.js} +13 -11
- package/dist/{opencode-adapter-hakkm7yh.js → opencode-adapter-19ktcbb9.js} +7 -7
- package/dist/{openrouter-images-xr9gme9x.js → openrouter-images-0jj12a2q.js} +6 -6
- package/dist/{otel-impl-7zhnt6gj.js → otel-impl-3ehm1hgc.js} +2 -2
- package/dist/{pending-h01yzpx4.js → pending-fwj2fatd.js} +20 -19
- package/dist/{pi-messages-2j0fpqwq.js → pi-messages-zk3g4esn.js} +1 -1
- package/dist/{pi-mono-adapter-f52hz743.js → pi-mono-adapter-xdeesvc4.js} +18 -17
- package/dist/{pricing-refresh-fzxvk2zf.js → pricing-refresh-4j8dzvxg.js} +2 -2
- package/dist/{rbac-roles-9v6vhgbs.js → rbac-roles-8msjr07m.js} +3 -3
- package/dist/{rbac-roles-hfgh8sba.js → rbac-roles-n7t2acv8.js} +2 -2
- package/dist/{render-v2-1rgspxzf.js → render-v2-j7qggj8h.js} +7 -6
- package/dist/{resume-tqy61x24.js → resume-hj1mn65y.js} +9 -8
- package/dist/{runtime-exkxyx5f.js → runtime-z31mdsgv.js} +2 -2
- package/dist/{session-access-3act7vt4.js → session-access-w38fh09a.js} +4 -4
- package/dist/{session-source-backfill-82qe7fqq.js → session-source-backfill-ax6qxv20.js} +3 -3
- package/dist/{setup-ry1vfdef.js → setup-dsqmpfcr.js} +1 -1
- package/dist/thread-buffer-nf55vwx3.js +39 -0
- package/dist/tree-visibility-6vqmnr71.js +24 -0
- package/dist/{typesafe-system-one-vcfj2ak8.js → typesafe-system-one-qkvkgrcz.js} +2 -2
- package/dist/{user-merge-jobs-bx6bf7db.js → user-merge-jobs-mvheb3ed.js} +3 -3
- package/dist/{virtual-modules-s0rjzcqq.js → virtual-modules-w2qk2wew.js} +32 -10
- package/dist/{work-objects-z2e5tv03.js → work-objects-4ahy5es5.js} +22 -21
- package/dist/worker-ews1nyhw.js +75 -0
- package/dist/{worker-follow-up-y3xeg89w.js → worker-follow-up-1gs4aw7y.js} +19 -18
- package/dist/{x-wg164ss9.js → x-3wr8c5sh.js} +2 -2
- package/openapi.json +995 -49
- package/package.json +9 -8
- package/src/be/db/request-composition.ts +190 -0
- package/src/be/db/runtime.ts +15 -0
- package/src/be/db/slack-trees.ts +220 -10
- package/src/be/db/tasks/human-free.ts +3 -2
- package/src/be/db/workflow-run-retention.ts +101 -0
- package/src/be/db-client.ts +23 -1
- package/src/be/db-retention-defaults.ts +46 -0
- package/src/be/db-retention.ts +55 -6
- package/src/be/mcp-events/catalog.ts +108 -0
- package/src/be/mcp-events/dispatcher.ts +202 -0
- package/src/be/mcp-events/protocol.ts +296 -0
- package/src/be/mcp-events/store.ts +231 -0
- package/src/be/mcp-events/webhook.ts +226 -0
- package/src/be/memory/providers/sqlite-store.ts +110 -24
- package/src/be/memory/review-recall-filter.ts +22 -0
- package/src/be/memory/search-candidates.ts +5 -7
- package/src/be/memory/types.ts +5 -0
- package/src/be/migrations/322_runtime_pool_workspace.sql +8 -0
- package/src/be/migrations/323_slack_task_tree_visibility.sql +9 -0
- package/src/be/migrations/326_slack_reconcile_pages.sql +13 -0
- package/src/be/migrations/327_mcp_event_subscriptions.sql +57 -0
- package/src/be/migrations/329_workflow_run_retention.sql +9 -0
- package/src/be/migrations/330_request_composition.sql +22 -0
- package/src/be/model-profile-check.ts +1 -1
- package/src/be/multi-runtime.ts +32 -4
- package/src/be/runtime-pools/controllers.ts +18 -3
- package/src/be/runtime-pools/db.ts +15 -4
- package/src/be/runtime-pools/supervisor.ts +42 -2
- package/src/be/swarm-config-guard.ts +10 -2
- package/src/commands/context-preamble.ts +11 -4
- package/src/commands/credential-outcome-report.ts +33 -9
- package/src/commands/e2b-stack-wizard.tsx +12 -6
- package/src/commands/runner.ts +116 -12
- package/src/extensions/catalog.generated.json +1 -1
- package/src/github/app.ts +59 -14
- package/src/http/all-routes.ts +2 -0
- package/src/http/config.ts +2 -1
- package/src/http/core.ts +2 -0
- package/src/http/github-token.ts +66 -0
- package/src/http/index.ts +21 -0
- package/src/http/mcp-user.ts +11 -8
- package/src/http/mcp.ts +58 -42
- package/src/http/prompt-templates.ts +1 -0
- package/src/http/request-composition.ts +310 -0
- package/src/http/tasks.ts +6 -1
- package/src/http/tool-schema-estimate.ts +95 -0
- package/src/http/workflows.ts +29 -11
- package/src/integrations/chat-sdk/inbound.ts +2 -2
- package/src/prompts/base-prompt.ts +133 -7
- package/src/prompts/resolver.ts +41 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/opencode-adapter.ts +72 -1
- package/src/providers/opencode-swarm-plugin.ts +22 -3
- package/src/providers/pi-mono-adapter.ts +1 -0
- package/src/providers/pi-mono-extension.ts +71 -0
- package/src/providers/pricing-sources.md +4 -0
- package/src/providers/request-composition-hook.ts +312 -0
- package/src/providers/types.ts +5 -0
- package/src/runtime-providers/controller-protocol.ts +7 -0
- package/src/runtime-providers/docker.ts +80 -12
- package/src/runtime-providers/k8s.ts +111 -6
- package/src/runtime-providers/types.ts +17 -0
- package/src/scheduler/scheduler.ts +1 -1
- package/src/server-user.ts +16 -1
- package/src/slack/ack.ts +10 -5
- package/src/slack/actions.ts +3 -3
- package/src/slack/app.ts +2 -0
- package/src/slack/assistant.ts +4 -4
- package/src/slack/blocks.ts +3 -3
- package/src/slack/handlers.ts +3 -3
- package/src/slack/reaction-shortcode.ts +23 -2
- package/src/slack/render-v2.ts +297 -200
- package/src/slack/responses.ts +7 -5
- package/src/slack/thread-buffer.ts +3 -3
- package/src/slack/tree-visibility.ts +64 -0
- package/src/tasks/worker-follow-up.ts +127 -17
- package/src/tests/azure-devops-outbound.test.ts +47 -14
- package/src/tests/base-prompt.test.ts +149 -1
- package/src/tests/check-playwright-version.test.ts +33 -0
- package/src/tests/context-preamble-budget.test.ts +65 -0
- package/src/tests/credential-outcome-report.test.ts +81 -1
- package/src/tests/db-client.test.ts +22 -0
- package/src/tests/db-retention-defaults.test.ts +244 -0
- package/src/tests/db-retention.test.ts +2 -1
- package/src/tests/db-runtime.test.ts +2 -1
- package/src/tests/deploy-release-dispatch.test.ts +332 -0
- package/src/tests/e2b-stack-wizard.test.tsx +156 -0
- package/src/tests/entrypoint-chown-no-follow.test.ts +69 -0
- package/src/tests/entrypoint-repo-clone-target.test.ts +112 -0
- package/src/tests/env-flag.test.ts +4 -2
- package/src/tests/event-loop-lag.test.ts +12 -18
- package/src/tests/extensions-example-slack-reply-gate.test.ts +15 -0
- package/src/tests/fixtures/base-prompt-baseline-cases.ts +78 -0
- package/src/tests/fixtures/base-prompt-baseline.json +18 -0
- package/src/tests/github-app-worker-auth-helper.test.ts +325 -0
- package/src/tests/github-installation-token-route.test.ts +199 -0
- package/src/tests/mcp-user-events.test.ts +708 -0
- package/src/tests/memory-key-paths.test.ts +4 -1
- package/src/tests/memory-search-stall.test.ts +421 -0
- package/src/tests/migration-322-runtime-pool-workspace.test.ts +116 -0
- package/src/tests/migration-329-workflow-run-retention.test.ts +32 -0
- package/src/tests/model-profile-fallbacks.test.ts +236 -2
- package/src/tests/opencode-adapter.test.ts +86 -0
- package/src/tests/pi-mono-extension.test.ts +168 -0
- package/src/tests/preload-env.test.ts +61 -1
- package/src/tests/preload.ts +22 -0
- package/src/tests/prompt-template-resolver.test.ts +85 -0
- package/src/tests/reload-config.test.ts +45 -0
- package/src/tests/request-composition.test.ts +447 -0
- package/src/tests/runner-max-concurrent.test.ts +86 -0
- package/src/tests/runtime-pools-db.test.ts +80 -0
- package/src/tests/runtime-provider-registration.test.ts +8 -0
- package/src/tests/runtime-providers-docker.test.ts +192 -1
- package/src/tests/runtime-providers-k8s.test.ts +127 -0
- package/src/tests/runtime-remote-controller.test.ts +64 -1
- package/src/tests/runtime-supervisor.test.ts +101 -0
- package/src/tests/script-connections.test.ts +8 -0
- package/src/tests/slack-blocks.test.ts +18 -0
- package/src/tests/slack-empty-icon-config.test.ts +113 -0
- package/src/tests/slack-reaction-config.test.ts +38 -2
- package/src/tests/slack-render-v2-query-plans.test.ts +100 -1
- package/src/tests/slack-render-v2-reconcile.test.ts +75 -4
- package/src/tests/slack-render-v2.test.ts +683 -11
- package/src/tests/swarm-config-reserved-keys.test.ts +1 -0
- package/src/tests/task-session-prompts.test.ts +37 -0
- package/src/tests/user-delete-perf.test.ts +36 -9
- package/src/tests/webhook-filter.test.ts +327 -0
- package/src/tests/workflow-async-v2.test.ts +19 -16
- package/src/tests/workflow-definition-telemetry.test.ts +15 -5
- package/src/tests/workflow-e2e.test.ts +1 -9
- package/src/tests/workflow-finalization-races.test.ts +553 -0
- package/src/tests/workflow-foreach.test.ts +2 -0
- package/src/tests/workflow-hitl-routing.test.ts +26 -20
- package/src/tests/workflow-http-v2.test.ts +105 -2
- package/src/tests/workflow-idempotency.test.ts +41 -0
- package/src/tests/workflow-mcp-webhook-filter.test.ts +214 -0
- package/src/tests/workflow-parallel-park.test.ts +297 -0
- package/src/tests/workflow-retry-v2.test.ts +57 -21
- package/src/tests/workflow-retry-validation.test.ts +13 -13
- package/src/tests/workflow-runs-retention.test.ts +533 -0
- package/src/tests/workflow-script-principal.test.ts +7 -2
- package/src/tests/workflow-tla-races.test.ts +7 -2
- package/src/tests/workflow-triggers-v2.test.ts +201 -0
- package/src/tests/workflow-wait-builtin-events.test.ts +3 -1
- package/src/tests/workflow-wait-event.test.ts +28 -2
- package/src/tests/workflow-wait-poller.test.ts +94 -0
- package/src/tests/workflow-wait-time.test.ts +7 -3
- package/src/tests/workflow-wait.test.ts +26 -0
- package/src/tests/workflow-wait.ts +44 -0
- package/src/tools/workflows/create-workflow.ts +7 -3
- package/src/tools/workflows/update-workflow.ts +7 -3
- package/src/types.ts +200 -2
- package/src/utils/credentials.ts +7 -0
- package/src/workflows/checkpoint.ts +18 -0
- package/src/workflows/engine.ts +38 -10
- package/src/workflows/foreach-driver.ts +42 -4
- package/src/workflows/recovery.ts +6 -1
- package/src/workflows/resume.ts +11 -3
- package/src/workflows/retry-poller.ts +17 -4
- package/src/workflows/successor-routing.ts +108 -0
- package/src/workflows/task-step-routing.ts +5 -2
- package/src/workflows/triggers.ts +21 -36
- package/src/workflows/wait-poller.ts +6 -2
- package/src/workflows/webhook-filter.ts +203 -0
- package/templates/extensions/slack-reply-gate/hooks.ts +8 -4
- package/templates/skills/swarm-docs/content.md +2 -0
- package/dist/acp-adapter-bht22g3k.js +0 -16
- package/dist/fx-adapter-adtdb3jb.js +0 -19
- package/dist/grok-adapter-accnn9km.js +0 -19
- package/dist/handlers-1x77561e.js +0 -35
- package/dist/index-48qzcqzj.js +0 -35
- package/dist/index-rkvaambe.js +0 -36
- package/dist/index-xj1mq27m.js +0 -40
- package/dist/lead-enzn86bz.js +0 -74
- package/dist/thread-buffer-3x93yexa.js +0 -38
- package/dist/worker-zfcv2wbf.js +0 -74
package/src/http/workflows.ts
CHANGED
|
@@ -489,12 +489,22 @@ const webhookTriggerRoute = route({
|
|
|
489
489
|
responses: {
|
|
490
490
|
200: {
|
|
491
491
|
description:
|
|
492
|
-
"Delivery skipped
|
|
493
|
-
schema: z.
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
492
|
+
"Delivery skipped after signature verification and before a run was saved. event-not-allowed: the events allowlist missed. filter-not-matched: a header or JSON body field missed. The received value is not echoed for a filter miss.",
|
|
493
|
+
schema: z.discriminatedUnion("reason", [
|
|
494
|
+
z.object({
|
|
495
|
+
skipped: z.literal(true),
|
|
496
|
+
reason: z.literal("event-not-allowed"),
|
|
497
|
+
event: z.string().nullable(),
|
|
498
|
+
}),
|
|
499
|
+
z.object({
|
|
500
|
+
skipped: z.literal(true),
|
|
501
|
+
reason: z.literal("filter-not-matched"),
|
|
502
|
+
match: z.object({
|
|
503
|
+
source: z.enum(["header", "body"]),
|
|
504
|
+
path: z.string(),
|
|
505
|
+
}),
|
|
506
|
+
}),
|
|
507
|
+
]),
|
|
498
508
|
},
|
|
499
509
|
201: { description: "Webhook processed", schema: z.object({ runId: z.string() }) },
|
|
500
510
|
401: { description: "Invalid signature" },
|
|
@@ -596,11 +606,19 @@ export async function handleWorkflows(
|
|
|
596
606
|
// run that already started.
|
|
597
607
|
if (result.skipped) {
|
|
598
608
|
// 2xx, not 4xx: GitHub and similar senders count non-2xx as a failed delivery.
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
609
|
+
if (result.reason === "event-not-allowed") {
|
|
610
|
+
webhookTriggerRoute.respond(res, 200, {
|
|
611
|
+
skipped: true,
|
|
612
|
+
reason: result.reason,
|
|
613
|
+
event: result.event,
|
|
614
|
+
});
|
|
615
|
+
} else {
|
|
616
|
+
webhookTriggerRoute.respond(res, 200, {
|
|
617
|
+
skipped: true,
|
|
618
|
+
reason: result.reason,
|
|
619
|
+
match: result.match,
|
|
620
|
+
});
|
|
621
|
+
}
|
|
604
622
|
} else {
|
|
605
623
|
webhookTriggerRoute.respond(res, 201, { runId: result.runId });
|
|
606
624
|
}
|
|
@@ -511,8 +511,8 @@ export async function flushChatThread(
|
|
|
511
511
|
{ alreadyAuthenticated: true },
|
|
512
512
|
);
|
|
513
513
|
if (result.skipped) {
|
|
514
|
-
//
|
|
515
|
-
// dispatch
|
|
514
|
+
// Header or body filter, or the events allowlist, dropped the delivery.
|
|
515
|
+
// Chat dispatch sends no HTTP headers, so a header clause skips it.
|
|
516
516
|
console.warn(`[chat-sdk] ${threadId}: workflow webhook trigger skipped (${result.reason})`);
|
|
517
517
|
return;
|
|
518
518
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import type { ProviderTraits } from "../providers/types";
|
|
23
23
|
import { getSlackConfiguration } from "../slack/config";
|
|
24
|
-
import type { ProviderName } from "../types";
|
|
24
|
+
import type { ProviderName, RequestCompositionPartInput } from "../types";
|
|
25
25
|
import { agentFsFileLinkQuery, getAppUrl, resolveAgentFsLinkBase } from "../utils/constants";
|
|
26
26
|
import { isEnvFlagEnabled } from "../utils/env-flag";
|
|
27
27
|
import { isSteeringEnabled } from "../utils/steering-enabled";
|
|
@@ -189,7 +189,21 @@ function promptFlags(args: Pick<BasePromptArgs, "traits" | "provider" | "scripts
|
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
/** Collapse block seams to one blank line, as the final prompt does. */
|
|
193
|
+
const collapseSeams = (text: string): string => text.replace(/\n{3,}/g, "\n\n");
|
|
194
|
+
|
|
195
|
+
export const getBasePrompt = async (args: BasePromptArgs): Promise<string> =>
|
|
196
|
+
(await getBasePromptWithParts(args)).prompt;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The base prompt plus the size of each piece in it, for the request
|
|
200
|
+
* composition manifest. Each part's chars are the growth of the collapsed
|
|
201
|
+
* prompt, so the parts sum to `prompt.length` exactly. The prompt text is the
|
|
202
|
+
* same one `getBasePrompt` returns.
|
|
203
|
+
*/
|
|
204
|
+
export const getBasePromptWithParts = async (
|
|
205
|
+
args: BasePromptArgs,
|
|
206
|
+
): Promise<{ prompt: string; parts: RequestCompositionPartInput[] }> => {
|
|
193
207
|
const { role, agentId, traits } = args;
|
|
194
208
|
const { hasMcp, hasToolSearch, hasLocalEnv, nativeSkillDiscovery, provider, scriptsOnlyMode } =
|
|
195
209
|
promptFlags(args);
|
|
@@ -237,11 +251,32 @@ export const getBasePrompt = async (args: BasePromptArgs): Promise<string> => {
|
|
|
237
251
|
const compositeResult = await resolveTemplateAsync(compositeEventType, vars);
|
|
238
252
|
let prompt = compositeResult.text;
|
|
239
253
|
|
|
254
|
+
const parts: RequestCompositionPartInput[] = [];
|
|
255
|
+
let measured = 0;
|
|
256
|
+
// Size of everything appended since the last call, after seam collapsing.
|
|
257
|
+
const grown = (): number => {
|
|
258
|
+
const length = collapseSeams(prompt).length;
|
|
259
|
+
const delta = length - measured;
|
|
260
|
+
measured = length;
|
|
261
|
+
return delta;
|
|
262
|
+
};
|
|
263
|
+
const section = (id: string, chars: number): void => {
|
|
264
|
+
parts.push({ kind: "system_section", id, label: id, chars });
|
|
265
|
+
};
|
|
266
|
+
// The persona counts only as much as it adds to the rendered composite: an
|
|
267
|
+
// override that drops {{persona}} renders none of it, one that moves it
|
|
268
|
+
// elsewhere still counts it. The sections come from the render without it.
|
|
269
|
+
const sectionsResult = persona
|
|
270
|
+
? await resolveTemplateAsync(compositeEventType, { ...vars, persona: "" })
|
|
271
|
+
: compositeResult;
|
|
272
|
+
parts.push(...compositeParts(compositeEventType, sectionsResult, grown()));
|
|
273
|
+
|
|
240
274
|
// Experimental scripts-only MCP surface (code-mode): named swarm tools are
|
|
241
275
|
// not registered, so tell the agent everything goes through script-run.
|
|
242
276
|
if (scriptsOnlyMode) {
|
|
243
277
|
const scriptsOnlyResult = await resolveTemplateAsync("system.agent.scripts_only_mode", {});
|
|
244
278
|
prompt += `\n${scriptsOnlyResult.text}`;
|
|
279
|
+
section("system.agent.scripts_only_mode", grown());
|
|
245
280
|
}
|
|
246
281
|
|
|
247
282
|
// Server-side capability flags gate which MCP tool groups the API server
|
|
@@ -254,12 +289,16 @@ export const getBasePrompt = async (args: BasePromptArgs): Promise<string> => {
|
|
|
254
289
|
// agent-fs CLI needs a local environment with AGENT_FS_API_URL set.
|
|
255
290
|
if (hasMcp && serverHasCapability("pages", true)) {
|
|
256
291
|
const agentFsConfigured = hasLocalEnv && Boolean(process.env.AGENT_FS_API_URL);
|
|
292
|
+
const outputsEvent = agentFsConfigured
|
|
293
|
+
? "system.agent.outputs"
|
|
294
|
+
: "system.agent.outputs.no_agent_fs";
|
|
257
295
|
const fileLinkBase = resolveAgentFsLinkBase("prompt");
|
|
258
|
-
const outputsResult = await resolveTemplateAsync(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
);
|
|
296
|
+
const outputsResult = await resolveTemplateAsync(outputsEvent, {
|
|
297
|
+
fileLinkBase,
|
|
298
|
+
fileLinkQuery: agentFsFileLinkQuery(fileLinkBase),
|
|
299
|
+
});
|
|
262
300
|
prompt += outputsResult.text;
|
|
301
|
+
section(outputsEvent, grown());
|
|
263
302
|
}
|
|
264
303
|
|
|
265
304
|
// H. Slack. One block for both roles; the scripts-only variant covers Slack
|
|
@@ -268,6 +307,7 @@ export const getBasePrompt = async (args: BasePromptArgs): Promise<string> => {
|
|
|
268
307
|
if (hasMcp && slackPromptToolsEnabled && !scriptsOnlyMode) {
|
|
269
308
|
const slackResult = await resolveTemplateAsync("system.agent.slack", {});
|
|
270
309
|
prompt += slackResult.text;
|
|
310
|
+
section("system.agent.slack", grown());
|
|
271
311
|
}
|
|
272
312
|
|
|
273
313
|
// Use-case channel thread (lead only: every posting tool is lead-only).
|
|
@@ -279,6 +319,7 @@ export const getBasePrompt = async (args: BasePromptArgs): Promise<string> => {
|
|
|
279
319
|
) {
|
|
280
320
|
const threadResult = await resolveTemplateAsync("system.agent.lead.channel_thread", {});
|
|
281
321
|
prompt += threadResult.text;
|
|
322
|
+
section("system.agent.lead.channel_thread", grown());
|
|
282
323
|
}
|
|
283
324
|
|
|
284
325
|
if (
|
|
@@ -292,6 +333,7 @@ export const getBasePrompt = async (args: BasePromptArgs): Promise<string> => {
|
|
|
292
333
|
) {
|
|
293
334
|
const steeringResult = await resolveTemplateAsync("system.agent.steering", {});
|
|
294
335
|
prompt += steeringResult.text;
|
|
336
|
+
section("system.agent.steering", grown());
|
|
295
337
|
}
|
|
296
338
|
|
|
297
339
|
// Rich cards (task uiSpec). Read the flag here, never in a module-level
|
|
@@ -299,6 +341,7 @@ export const getBasePrompt = async (args: BasePromptArgs): Promise<string> => {
|
|
|
299
341
|
if (hasMcp && !scriptsOnlyMode && isEnvFlagEnabled("UI_SPEC_ENABLED", false)) {
|
|
300
342
|
const uiSpecResult = await resolveTemplateAsync("system.agent.ui_spec", {});
|
|
301
343
|
prompt += uiSpecResult.text;
|
|
344
|
+
section("system.agent.ui_spec", grown());
|
|
302
345
|
}
|
|
303
346
|
|
|
304
347
|
// I. Tools and skills. Skipped without MCP: the discovery tools are MCP tools.
|
|
@@ -318,6 +361,13 @@ export const getBasePrompt = async (args: BasePromptArgs): Promise<string> => {
|
|
|
318
361
|
}),
|
|
319
362
|
);
|
|
320
363
|
prompt += toolsResult.text;
|
|
364
|
+
// The discovery line rides inside tools_skills as a variable.
|
|
365
|
+
const toolsChars = grown();
|
|
366
|
+
const discoveryChars = toolsResult.text.includes(discoveryResult.text)
|
|
367
|
+
? Math.min(discoveryResult.text.length, toolsChars)
|
|
368
|
+
: 0;
|
|
369
|
+
if (discoveryChars > 0) section(discoveryEvent, discoveryChars);
|
|
370
|
+
section("system.agent.tools_skills", toolsChars - discoveryChars);
|
|
321
371
|
|
|
322
372
|
// Lead docs pointer: only when the lead has the `swarm-docs` skill. The
|
|
323
373
|
// skill list is unknown on claude-managed (the cloud sandbox owns skill
|
|
@@ -325,6 +375,7 @@ export const getBasePrompt = async (args: BasePromptArgs): Promise<string> => {
|
|
|
325
375
|
if (role === "lead" && hasSwarmDocsSkill(args.skillsSummary)) {
|
|
326
376
|
const docsResult = await resolveTemplateAsync("system.agent.lead.docs", {});
|
|
327
377
|
prompt += docsResult.text;
|
|
378
|
+
section("system.agent.lead.docs", grown());
|
|
328
379
|
}
|
|
329
380
|
}
|
|
330
381
|
|
|
@@ -347,12 +398,87 @@ export const getBasePrompt = async (args: BasePromptArgs): Promise<string> => {
|
|
|
347
398
|
claudeMdSourcePath(provider),
|
|
348
399
|
budget,
|
|
349
400
|
);
|
|
401
|
+
const claudeMdChars = grown();
|
|
402
|
+
if (claudeMdChars > 0) {
|
|
403
|
+
parts.push({
|
|
404
|
+
kind: "claude_md",
|
|
405
|
+
id: "claude_md",
|
|
406
|
+
label: "CLAUDE.md (agent notes)",
|
|
407
|
+
chars: claudeMdChars,
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// Claude and pi list installed skills from their local skills tree, outside
|
|
413
|
+
// our prompt. Codex and opencode get the list inside tools_skills, already
|
|
414
|
+
// counted above; a session with no local tree reaches skills through MCP.
|
|
415
|
+
if (hasMcp && hasLocalEnv && nativeSkillDiscovery && args.skillsSummary?.length) {
|
|
416
|
+
parts.push({
|
|
417
|
+
kind: "skills_listing",
|
|
418
|
+
id: "skills_listing",
|
|
419
|
+
label: "skills listing (harness-injected)",
|
|
420
|
+
chars: args.skillsSummary.reduce(
|
|
421
|
+
(sum, skill) => sum + `- ${skill.name}: ${skill.description}\n`.length,
|
|
422
|
+
0,
|
|
423
|
+
),
|
|
424
|
+
fidelity: "estimate",
|
|
425
|
+
});
|
|
350
426
|
}
|
|
351
427
|
|
|
352
428
|
// Blocks start and end with a newline; collapse the seams to one blank line.
|
|
353
|
-
return prompt
|
|
429
|
+
return { prompt: collapseSeams(prompt), parts: parts.filter((part) => part.chars > 0) };
|
|
354
430
|
};
|
|
355
431
|
|
|
432
|
+
/**
|
|
433
|
+
* Split the composite into the persona and its referenced templates.
|
|
434
|
+
* `sections` is the composite rendered with an empty persona, so the persona
|
|
435
|
+
* is the difference in collapsed length and no section is charged for it. The
|
|
436
|
+
* composite's own glue entry absorbs the newlines seam collapsing removed, so
|
|
437
|
+
* the parts sum to `total`, the composite's collapsed length.
|
|
438
|
+
*/
|
|
439
|
+
function compositeParts(
|
|
440
|
+
compositeEventType: string,
|
|
441
|
+
sections: { text: string; segments?: { templateId: string; chars: number }[] },
|
|
442
|
+
total: number,
|
|
443
|
+
): RequestCompositionPartInput[] {
|
|
444
|
+
const personaChars = Math.max(0, total - collapseSeams(sections.text).length);
|
|
445
|
+
const sectionsTotal = total - personaChars;
|
|
446
|
+
const entries = (
|
|
447
|
+
sections.segments ?? [{ templateId: compositeEventType, chars: sectionsTotal }]
|
|
448
|
+
).map((segment) => ({ ...segment }));
|
|
449
|
+
// Glue first (the seam newlines live there), then the largest sections.
|
|
450
|
+
const glue = entries.filter((entry) => entry.templateId === compositeEventType);
|
|
451
|
+
const rest = entries
|
|
452
|
+
.filter((entry) => entry.templateId !== compositeEventType)
|
|
453
|
+
.sort((a, b) => b.chars - a.chars);
|
|
454
|
+
let excess = entries.reduce((sum, entry) => sum + entry.chars, 0) - sectionsTotal;
|
|
455
|
+
for (const entry of [...glue, ...rest]) {
|
|
456
|
+
if (excess === 0) break;
|
|
457
|
+
const take = excess > 0 ? Math.min(excess, entry.chars) : excess;
|
|
458
|
+
entry.chars -= take;
|
|
459
|
+
excess -= take;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
const parts: RequestCompositionPartInput[] = [];
|
|
463
|
+
if (personaChars > 0) {
|
|
464
|
+
parts.push({
|
|
465
|
+
kind: "persona",
|
|
466
|
+
id: "persona",
|
|
467
|
+
label: "persona (description, SOUL.md, IDENTITY.md)",
|
|
468
|
+
chars: personaChars,
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
for (const entry of entries) {
|
|
472
|
+
parts.push({
|
|
473
|
+
kind: "system_section",
|
|
474
|
+
id: entry.templateId,
|
|
475
|
+
label: entry.templateId,
|
|
476
|
+
chars: entry.chars,
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
return parts;
|
|
480
|
+
}
|
|
481
|
+
|
|
356
482
|
/**
|
|
357
483
|
* Per-task context that used to close the system prompt: the repository block
|
|
358
484
|
* and the scripts-only Slack note. It rides in the task prompt so the system
|
package/src/prompts/resolver.ts
CHANGED
|
@@ -54,6 +54,17 @@ export interface ResolveResult {
|
|
|
54
54
|
skipped: boolean;
|
|
55
55
|
/** Any {{var}} tokens that couldn't be resolved */
|
|
56
56
|
unresolved: string[];
|
|
57
|
+
/**
|
|
58
|
+
* Interpolated size of each top-level `{{@template[id]}}` the body expanded,
|
|
59
|
+
* plus one entry for the template's own text (header and glue). The chars
|
|
60
|
+
* sum to `text.length`. Absent when the body references no template.
|
|
61
|
+
*/
|
|
62
|
+
segments?: ResolveSegment[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface ResolveSegment {
|
|
66
|
+
templateId: string;
|
|
67
|
+
chars: number;
|
|
57
68
|
}
|
|
58
69
|
|
|
59
70
|
// ─── HTTP Resolver Mode ─────────────────────────────────────────────────────
|
|
@@ -221,7 +232,8 @@ function resolveTemplateViaDb(
|
|
|
221
232
|
}
|
|
222
233
|
|
|
223
234
|
// Expand {{@template[id]}} references in body
|
|
224
|
-
|
|
235
|
+
const expandedRefs: ExpandedRef[] = [];
|
|
236
|
+
body = expandTemplateRefs(body, variables, options, new Set(), 0, expandedRefs);
|
|
225
237
|
|
|
226
238
|
// Compose header + body
|
|
227
239
|
const composed = header ? `${header}\n\n${body}` : body;
|
|
@@ -235,9 +247,32 @@ function resolveTemplateViaDb(
|
|
|
235
247
|
scope,
|
|
236
248
|
skipped: false,
|
|
237
249
|
unresolved,
|
|
250
|
+
...(expandedRefs.length > 0 && {
|
|
251
|
+
segments: measureSegments(eventType, text, expandedRefs, variables),
|
|
252
|
+
}),
|
|
238
253
|
};
|
|
239
254
|
}
|
|
240
255
|
|
|
256
|
+
type ExpandedRef = { templateId: string; body: string };
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Size each expanded reference by interpolating it alone. The template's own
|
|
260
|
+
* entry takes the remainder, so the segments always sum to the final text.
|
|
261
|
+
*/
|
|
262
|
+
function measureSegments(
|
|
263
|
+
eventType: string,
|
|
264
|
+
text: string,
|
|
265
|
+
refs: ExpandedRef[],
|
|
266
|
+
variables: Record<string, unknown>,
|
|
267
|
+
): ResolveSegment[] {
|
|
268
|
+
const children = refs.map((ref) => ({
|
|
269
|
+
templateId: ref.templateId,
|
|
270
|
+
chars: interpolate(ref.body, variables).result.length,
|
|
271
|
+
}));
|
|
272
|
+
const childChars = children.reduce((sum, segment) => sum + segment.chars, 0);
|
|
273
|
+
return [{ templateId: eventType, chars: Math.max(0, text.length - childChars) }, ...children];
|
|
274
|
+
}
|
|
275
|
+
|
|
241
276
|
/**
|
|
242
277
|
* Recursively expand {{@template[id]}} references in a string.
|
|
243
278
|
* Only used in DB mode (API server). HTTP mode handles expansion server-side.
|
|
@@ -248,6 +283,8 @@ function expandTemplateRefs(
|
|
|
248
283
|
options: ResolveOptions,
|
|
249
284
|
visited: Set<string>,
|
|
250
285
|
depth: number,
|
|
286
|
+
/** Collects each top-level reference with its fully expanded body. */
|
|
287
|
+
expandedRefs?: ExpandedRef[],
|
|
251
288
|
): string {
|
|
252
289
|
if (depth > MAX_TEMPLATE_REF_DEPTH) {
|
|
253
290
|
return text;
|
|
@@ -291,6 +328,8 @@ function expandTemplateRefs(
|
|
|
291
328
|
// Recursively expand nested refs in the referenced body
|
|
292
329
|
const newVisited = new Set(visited);
|
|
293
330
|
newVisited.add(referencedId);
|
|
294
|
-
|
|
331
|
+
const expanded = expandTemplateRefs(refBody, variables, options, newVisited, depth + 1);
|
|
332
|
+
expandedRefs?.push({ templateId: referencedId, body: expanded });
|
|
333
|
+
return expanded;
|
|
295
334
|
});
|
|
296
335
|
}
|
|
@@ -45,7 +45,7 @@ import type {
|
|
|
45
45
|
* default; the image installs exactly this version and the per-task settings
|
|
46
46
|
* set `amp.updates.mode: "disabled"`. Bump it deliberately, with a live run.
|
|
47
47
|
*/
|
|
48
|
-
export const AMP_PACKAGE = "@ampcode/cli@0.0.
|
|
48
|
+
export const AMP_PACKAGE = "@ampcode/cli@0.0.1794312042-g538cd5";
|
|
49
49
|
|
|
50
50
|
/** MCP server name. Amp exposes its tools as `agent_swarm` / `store_progress` (dashes become underscores). */
|
|
51
51
|
const AMP_MCP_SERVER_NAME = "agent-swarm";
|
|
@@ -44,7 +44,11 @@ import { snapshotCatalogRows } from "../utils/runtime-model-catalog";
|
|
|
44
44
|
import { registerVolatileSecret, scrubSecrets } from "../utils/secret-scrubber";
|
|
45
45
|
import { resolveSlashSkillPrompt } from "./codex-skill-resolver";
|
|
46
46
|
import { OpenRouterBilling } from "./opencode-billing";
|
|
47
|
-
import {
|
|
47
|
+
import {
|
|
48
|
+
createOpencodeSwarmPlugin,
|
|
49
|
+
type OpencodeRequestContext,
|
|
50
|
+
type OpencodeToolLister,
|
|
51
|
+
} from "./opencode-swarm-plugin";
|
|
48
52
|
import {
|
|
49
53
|
apiHeaders,
|
|
50
54
|
autoIndexMemoryFile,
|
|
@@ -54,6 +58,16 @@ import {
|
|
|
54
58
|
syncIdentityFilesToServer,
|
|
55
59
|
} from "./pi-mono-extension";
|
|
56
60
|
import { applyReasoningEffort, type ReasoningEffort } from "./reasoning-effort";
|
|
61
|
+
import {
|
|
62
|
+
BUILTIN_TOOL_GROUP,
|
|
63
|
+
HookCompositionReporter,
|
|
64
|
+
type HookRequestMeasure,
|
|
65
|
+
type HookToolGroup,
|
|
66
|
+
measureHookRequest,
|
|
67
|
+
postHookComposition,
|
|
68
|
+
SWARM_TOOL_GROUP,
|
|
69
|
+
textChars,
|
|
70
|
+
} from "./request-composition-hook";
|
|
57
71
|
import { resolveOpencodeSdkSpecifier } from "./runtime-dependencies";
|
|
58
72
|
import type {
|
|
59
73
|
CostData,
|
|
@@ -532,6 +546,40 @@ function toolResultText(content: ReadonlyArray<{ type: string; text?: string }>
|
|
|
532
546
|
.join("");
|
|
533
547
|
}
|
|
534
548
|
|
|
549
|
+
/**
|
|
550
|
+
* Tool name → schema group. OpenCode keys MCP tools `<server>_<tool>`; any
|
|
551
|
+
* other tool is an OpenCode built-in.
|
|
552
|
+
*/
|
|
553
|
+
export function opencodeToolGroupOf(
|
|
554
|
+
mcpServers: readonly string[],
|
|
555
|
+
): (name: string) => HookToolGroup {
|
|
556
|
+
// Longest first, so `a_b` wins over `a` for a tool `a_b_x`.
|
|
557
|
+
const servers = [...mcpServers].sort((a, b) => b.length - a.length);
|
|
558
|
+
return (name) => {
|
|
559
|
+
const server = servers.find((candidate) => name.startsWith(`${candidate}_`));
|
|
560
|
+
if (!server) return BUILTIN_TOOL_GROUP;
|
|
561
|
+
if (server === SWARM_MCP_SERVER) return SWARM_TOOL_GROUP;
|
|
562
|
+
return { id: `mcp:${server}`, label: `${server} tool schemas` };
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/** Measure one primary request from OpenCode's `context` hook event. */
|
|
567
|
+
export function measureOpencodeContext(
|
|
568
|
+
event: OpencodeRequestContext,
|
|
569
|
+
groupOf: (name: string) => HookToolGroup,
|
|
570
|
+
): HookRequestMeasure {
|
|
571
|
+
return measureHookRequest({
|
|
572
|
+
system: event.system.map((part) => part.text ?? "").join("\n"),
|
|
573
|
+
tools: Object.entries(event.tools).map(([name, tool]) => ({
|
|
574
|
+
name,
|
|
575
|
+
description: tool.description,
|
|
576
|
+
schema: tool.input,
|
|
577
|
+
})),
|
|
578
|
+
messageChars: textChars(event.messages),
|
|
579
|
+
groupOf,
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
|
|
535
583
|
export class OpencodeSession implements ProviderSession {
|
|
536
584
|
private listeners: Array<(event: ProviderEvent) => void> = [];
|
|
537
585
|
// The runner attaches its listener after `createSession` resolves; buffer
|
|
@@ -555,6 +603,8 @@ export class OpencodeSession implements ProviderSession {
|
|
|
555
603
|
// Assistant text by message, in part order; the runner keeps the last emit.
|
|
556
604
|
private textByMessage = new Map<string, string[]>();
|
|
557
605
|
private transcript: string[] = [];
|
|
606
|
+
/** Set when the session posts harness-hook request composition manifests. */
|
|
607
|
+
composition: HookCompositionReporter | undefined;
|
|
558
608
|
/** Fed each step's prompt size; steers the one-time context-bound note. */
|
|
559
609
|
private readonly observeContextBound: (contextTokens: number | undefined) => Promise<void>;
|
|
560
610
|
|
|
@@ -723,6 +773,7 @@ export class OpencodeSession implements ProviderSession {
|
|
|
723
773
|
const t = ev.data.tokens;
|
|
724
774
|
const contextUsed = t.input + t.cache.read + t.cache.write + t.output;
|
|
725
775
|
void this.observeContextBound(t.input + t.cache.read + t.cache.write);
|
|
776
|
+
this.composition?.observeUsage(t.input + t.cache.read + t.cache.write, this.model);
|
|
726
777
|
const contextTotal = getContextWindowSize(this.model || "default");
|
|
727
778
|
if (contextTotal > 0 && contextUsed > 0) {
|
|
728
779
|
this.emit({
|
|
@@ -1014,6 +1065,7 @@ export class OpencodeAdapter implements ProviderAdapter {
|
|
|
1014
1065
|
};
|
|
1015
1066
|
const { sdk, version: opencodeVersion } = await loadOpencodeSdkImpl(env);
|
|
1016
1067
|
let listTools: OpencodeToolLister | undefined;
|
|
1068
|
+
let onContext: ((event: OpencodeRequestContext) => void) | undefined;
|
|
1017
1069
|
const billing = config.model.startsWith("openrouter/") ? new OpenRouterBilling() : undefined;
|
|
1018
1070
|
// The config string carries the spliced provider key and the swarm MCP
|
|
1019
1071
|
// bearer. It goes to the SDK only; nothing logs, writes, or uploads it,
|
|
@@ -1029,6 +1081,7 @@ export class OpencodeAdapter implements ProviderAdapter {
|
|
|
1029
1081
|
listTools = lister;
|
|
1030
1082
|
},
|
|
1031
1083
|
...(billing ? { onOpenRouterResponse: (response) => billing.observe(response) } : {}),
|
|
1084
|
+
onContext: (event) => onContext?.(event),
|
|
1032
1085
|
}),
|
|
1033
1086
|
],
|
|
1034
1087
|
log: {
|
|
@@ -1062,6 +1115,24 @@ export class OpencodeAdapter implements ProviderAdapter {
|
|
|
1062
1115
|
billing,
|
|
1063
1116
|
);
|
|
1064
1117
|
session.emitSessionInit(opencodeVersion ? { version: opencodeVersion } : undefined);
|
|
1118
|
+
if (config.runnerSessionId && taskId) {
|
|
1119
|
+
const composition = new HookCompositionReporter(
|
|
1120
|
+
{ sessionId: config.runnerSessionId, provider: "opencode" },
|
|
1121
|
+
(body) =>
|
|
1122
|
+
postHookComposition({ apiUrl: config.apiUrl, taskId, headers: apiHeaders(swarm) }, body),
|
|
1123
|
+
);
|
|
1124
|
+
session.composition = composition;
|
|
1125
|
+
const groupOf = opencodeToolGroupOf(Object.keys(mcp));
|
|
1126
|
+
onContext = (event) => {
|
|
1127
|
+
// Subagent child sessions share the host; only the task session counts.
|
|
1128
|
+
if (event.sessionID !== sessionId) return;
|
|
1129
|
+
try {
|
|
1130
|
+
composition.observeRequest(measureOpencodeContext(event, groupOf));
|
|
1131
|
+
} catch (err) {
|
|
1132
|
+
console.warn(`[opencode] Request composition measure failed: ${err}`);
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1065
1136
|
|
|
1066
1137
|
// Drive the session from the host's event stream. Closing the host ends
|
|
1067
1138
|
// the stream; ending without a terminal event means the host died.
|
|
@@ -30,6 +30,22 @@ export interface OpencodeSwarmPluginOptions {
|
|
|
30
30
|
onToolRegistry?: (listTools: OpencodeToolLister) => void;
|
|
31
31
|
/** Receives every OpenRouter model response, for the billed cost. */
|
|
32
32
|
onOpenRouterResponse?: (response: Response) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Receives each primary model request's final context (system, messages,
|
|
35
|
+
* tools), after this plugin's own edits. OpenCode fires `context` once per
|
|
36
|
+
* agent-loop step, so this sees every primary call.
|
|
37
|
+
*/
|
|
38
|
+
onContext?: (event: OpencodeRequestContext) => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The parts of OpenCode's `context` hook event the request measurement reads. */
|
|
42
|
+
export interface OpencodeRequestContext {
|
|
43
|
+
readonly sessionID: string;
|
|
44
|
+
readonly system: ReadonlyArray<{ readonly text?: string }>;
|
|
45
|
+
readonly messages: ReadonlyArray<unknown>;
|
|
46
|
+
readonly tools: Readonly<
|
|
47
|
+
Record<string, { readonly description: string; readonly input: unknown }>
|
|
48
|
+
>;
|
|
33
49
|
}
|
|
34
50
|
|
|
35
51
|
/** Keys OpenCode sets on each shell call, on top of its base env. */
|
|
@@ -102,10 +118,13 @@ export function createOpencodeSwarmPlugin(
|
|
|
102
118
|
});
|
|
103
119
|
|
|
104
120
|
// Lead only: tell the model what other sessions are already handling.
|
|
121
|
+
// Then hand the final request to the composition measurement.
|
|
105
122
|
await ctx.session.hook("context", async (event) => {
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
123
|
+
if (config.isLead) {
|
|
124
|
+
const concurrent = await fetchConcurrentContext(config);
|
|
125
|
+
if (concurrent) event.system.push({ type: "text", text: concurrent });
|
|
126
|
+
}
|
|
127
|
+
options.onContext?.(event);
|
|
109
128
|
});
|
|
110
129
|
|
|
111
130
|
// Nobody reads a headless session's title. Generating one is a second
|
|
@@ -2138,6 +2138,7 @@ export class PiMonoAdapter implements ProviderAdapter {
|
|
|
2138
2138
|
isLead: config.role === "lead",
|
|
2139
2139
|
env: sessionEnv,
|
|
2140
2140
|
mcpServers: piMcpServers,
|
|
2141
|
+
runnerSessionId: config.runnerSessionId,
|
|
2141
2142
|
});
|
|
2142
2143
|
|
|
2143
2144
|
const features: PiSessionFeatures = {
|
|
@@ -22,6 +22,15 @@ import { summarizeSession as runSummarize } from "../utils/internal-ai";
|
|
|
22
22
|
import { getMemoryRaterNames } from "../utils/memory-raters";
|
|
23
23
|
import { getOpenRouterAttributionHeaders } from "../utils/openrouter-base-url";
|
|
24
24
|
import { scrubSecrets } from "../utils/secret-scrubber";
|
|
25
|
+
import {
|
|
26
|
+
BUILTIN_TOOL_GROUP,
|
|
27
|
+
HookCompositionReporter,
|
|
28
|
+
type HookToolGroup,
|
|
29
|
+
measureHookRequest,
|
|
30
|
+
postHookComposition,
|
|
31
|
+
SWARM_TOOL_GROUP,
|
|
32
|
+
splitProviderPayload,
|
|
33
|
+
} from "./request-composition-hook";
|
|
25
34
|
|
|
26
35
|
export interface SwarmHooksConfig {
|
|
27
36
|
apiUrl: string;
|
|
@@ -40,6 +49,11 @@ export interface SwarmHooksConfig {
|
|
|
40
49
|
* pi's MCP extension on `session_start`, which connects them.
|
|
41
50
|
*/
|
|
42
51
|
mcpServers?: Record<string, McpServerConfig>;
|
|
52
|
+
/**
|
|
53
|
+
* The runner's session id. Keys the harness-hook request composition
|
|
54
|
+
* manifest to the worker's manifest of the same session; unset, none posts.
|
|
55
|
+
*/
|
|
56
|
+
runnerSessionId?: string;
|
|
43
57
|
}
|
|
44
58
|
|
|
45
59
|
/** Standard headers for swarm API requests */
|
|
@@ -485,6 +499,25 @@ function sendNudge(pi: Parameters<ExtensionFactory>[0], text: string): void {
|
|
|
485
499
|
});
|
|
486
500
|
}
|
|
487
501
|
|
|
502
|
+
/** Tool name → schema group: swarm tools, other MCP servers, pi built-ins. */
|
|
503
|
+
export function piToolGroups(
|
|
504
|
+
tools: ReadonlyArray<{ name: string; namespace?: { name: string } }>,
|
|
505
|
+
): Map<string, HookToolGroup> {
|
|
506
|
+
const groups = new Map<string, HookToolGroup>();
|
|
507
|
+
for (const tool of tools) {
|
|
508
|
+
const namespace = tool.namespace?.name;
|
|
509
|
+
if (!namespace) continue;
|
|
510
|
+
groups.set(
|
|
511
|
+
tool.name,
|
|
512
|
+
// `SWARM_TOOL_NAMESPACE` in pi-mono-adapter.ts.
|
|
513
|
+
namespace === "agent-swarm"
|
|
514
|
+
? SWARM_TOOL_GROUP
|
|
515
|
+
: { id: `mcp:${namespace}`, label: `${namespace} tool schemas` },
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
return groups;
|
|
519
|
+
}
|
|
520
|
+
|
|
488
521
|
/**
|
|
489
522
|
* Create the swarm hooks extension factory for pi-mono.
|
|
490
523
|
*
|
|
@@ -495,6 +528,44 @@ export function createSwarmHooksExtension(config: SwarmHooksConfig): ExtensionFa
|
|
|
495
528
|
return (pi) => {
|
|
496
529
|
let lastContextPostTime = 0;
|
|
497
530
|
|
|
531
|
+
// === before_provider_request + message_end → request composition ===
|
|
532
|
+
// The payload is what pi sends, so its system prompt, tool declarations
|
|
533
|
+
// and messages are measured exactly. The call's usage then calibrates the
|
|
534
|
+
// server's chars-to-tokens ratio for pi.
|
|
535
|
+
if (config.taskId && config.runnerSessionId) {
|
|
536
|
+
const composition = new HookCompositionReporter(
|
|
537
|
+
{ sessionId: config.runnerSessionId, provider: "pi" },
|
|
538
|
+
(body) =>
|
|
539
|
+
postHookComposition(
|
|
540
|
+
{ apiUrl: config.apiUrl, taskId: config.taskId, headers: apiHeaders(config) },
|
|
541
|
+
body,
|
|
542
|
+
),
|
|
543
|
+
);
|
|
544
|
+
pi.on("before_provider_request", (event) => {
|
|
545
|
+
try {
|
|
546
|
+
const request = splitProviderPayload(event.payload);
|
|
547
|
+
// Compaction summaries declare no tools; they are not agent calls.
|
|
548
|
+
if (request.tools.length === 0) return undefined;
|
|
549
|
+
const groups = piToolGroups(pi.getAllTools());
|
|
550
|
+
composition.observeRequest(
|
|
551
|
+
measureHookRequest({
|
|
552
|
+
...request,
|
|
553
|
+
groupOf: (name) => groups.get(name) ?? BUILTIN_TOOL_GROUP,
|
|
554
|
+
}),
|
|
555
|
+
);
|
|
556
|
+
} catch (err) {
|
|
557
|
+
console.warn(`[pi] Request composition measure failed: ${err}`);
|
|
558
|
+
}
|
|
559
|
+
return undefined;
|
|
560
|
+
});
|
|
561
|
+
pi.on("message_end", (event, ctx) => {
|
|
562
|
+
const message = event.message;
|
|
563
|
+
if (message.role !== "assistant" || !message.usage) return;
|
|
564
|
+
const { input, cacheRead, cacheWrite } = message.usage;
|
|
565
|
+
composition.observeUsage(input + cacheRead + cacheWrite, ctx.model?.id);
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
|
|
498
569
|
pi.on("before_provider_headers", (event, ctx) => {
|
|
499
570
|
Object.assign(
|
|
500
571
|
event.headers,
|
|
@@ -261,6 +261,10 @@ and heartbeat-classified roots are omitted, and the metrics remain separate.
|
|
|
261
261
|
fall back after rejecting the requested model, so that requested ID alone
|
|
262
262
|
cannot justify a rate alias.
|
|
263
263
|
|
|
264
|
+
## Request composition token ratio
|
|
265
|
+
|
|
266
|
+
Request composition parts estimate tokens as `ceil(chars / 4)`. The per-provider correction lives in KV (namespace `swarm`, key `request-composition/token-ratio/<provider>`), not in the pricing table. Pi and opencode learn it from each harness-hook manifest: `promptTokens / (payloadChars / 4)`, folded into an EMA (α = 0.2, seeded by the first observation, bounded 0.5 to 2.0). Claude and codex stay at 1.0 unless an operator writes the key. Details: the cost-and-context guide, section "Request composition and cache-hit ratio".
|
|
267
|
+
|
|
264
268
|
## When a model is missing
|
|
265
269
|
|
|
266
270
|
Cost POSTs accept an optional UUID `id`. The runner reuses it across retries. Repeated IDs return the stored record without changing its price.
|