@desplega.ai/agent-swarm 1.160.0 → 1.162.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/README.md +4 -3
- package/dist/{acp-adapter-2mjwcsfh.js → acp-adapter-74m73ae9.js} +163 -49
- package/dist/{actions-e43rxskr.js → actions-4sr14gnt.js} +42 -38
- package/dist/{anthropic-messages-5qx80j9k.js → anthropic-messages-8xxrzky9.js} +22 -26
- package/dist/{app-mc7xfagn.js → app-pt68fbwp.js} +17 -14
- package/dist/{artifact-3v5t9jtg.js → artifact-fey7dvj9.js} +3 -2
- package/dist/{assistant-sedkzv3b.js → assistant-cv3jytks.js} +43 -39
- package/dist/{azure-openai-responses-nfb21z9a.js → azure-openai-responses-f5cqsyj8.js} +15 -10
- package/dist/{boot-reembed-m3656j2n.js → boot-reembed-4ht4gqth.js} +17 -14
- package/dist/{boot-reembed-cqz9swn5.js → boot-reembed-nxpcvpj9.js} +16 -13
- package/dist/{boot-scrub-logs-xbxf5d7w.js → boot-scrub-logs-k93kyw8k.js} +13 -10
- package/dist/boot-seeds-1skcrs0e.js +32 -0
- package/dist/{claude-adapter-dc6289mc.js → claude-adapter-r5g0tzge.js} +39 -30
- package/dist/{claude-managed-adapter-naaw51me.js → claude-managed-adapter-yxkfxg8j.js} +6 -5
- package/dist/{claude-managed-setup-eacvchx0.js → claude-managed-setup-pkyrgshb.js} +27 -27
- package/dist/{claude-sdk-session-bqp2xvym.js → claude-sdk-session-jxyxnrwd.js} +8041 -7910
- package/dist/{cli-4derpgyk.js → cli-2hhfhfq5.js} +6 -1
- package/dist/{cli-rykfmgwg.js → cli-2x0e561b.js} +1 -1
- package/dist/{cli-tzx2ke1v.js → cli-2zy95vhm.js} +137 -64
- package/dist/{cli-0x01kwrd.js → cli-4cwxn7gp.js} +47 -186
- package/dist/{cli-xjcywfsf.js → cli-4dcpaefp.js} +12 -11
- package/dist/{cli-v7fn5gms.js → cli-4x0csdjq.js} +164 -76
- package/dist/{cli-12tszpk9.js → cli-5bcd7sfy.js} +91 -29
- package/dist/{cli-jz4w45qt.js → cli-5k6k8ta3.js} +190 -50
- package/dist/{cli-tpq83z89.js → cli-5xhpb3kv.js} +20 -19
- package/dist/{cli-r1mxd1xh.js → cli-7af8yhav.js} +6 -179
- package/dist/{cli-jajnsm8q.js → cli-7tre70zp.js} +18160 -31345
- package/dist/{cli-447dt1h3.js → cli-8ev9xqnx.js} +218 -25
- package/dist/cli-bsky8g7w.js +449 -0
- package/dist/{cli-0z2v4nhw.js → cli-cat6h73s.js} +1 -1
- package/dist/{cli-25fcq4b4.js → cli-cebmgwsc.js} +15 -11
- package/dist/{cli-shkxm1vn.js → cli-cvatsam7.js} +189 -13
- package/dist/{cli-2658f6at.js → cli-cvk6yzw5.js} +6 -8
- package/dist/cli-dbmwby6a.js +9 -0
- package/dist/{cli-ptr8h7kp.js → cli-eg0b3p0k.js} +5 -218
- package/dist/cli-f9w1semm.js +413 -0
- package/dist/{cli-523679eh.js → cli-g739zqzt.js} +6 -5
- package/dist/{cli-dv6cdjs2.js → cli-gd4favx9.js} +28 -7
- package/dist/{cli-c8a36vcc.js → cli-gpqpmns7.js} +2 -2
- package/dist/{cli-5nbmpy8w.js → cli-hb5c2x5y.js} +1 -1
- package/dist/{cli-741yb0xx.js → cli-hmsw1gpy.js} +55 -169
- package/dist/{cli-qydf22qq.js → cli-jf7wmv1r.js} +2562 -735
- package/dist/{cli-mfe5btp9.js → cli-jxs2ygaw.js} +317 -121
- package/dist/{cli-kmcpfwn2.js → cli-jyy6pm2f.js} +19 -3
- package/dist/cli-kdkwd3yr.js +615 -0
- package/dist/{cli-6cs6wzxt.js → cli-kh04eqwe.js} +2 -2
- package/dist/{cli-9hsgwz4w.js → cli-kp42yek0.js} +1309 -391
- package/dist/cli-ma3zvh39.js +10404 -0
- package/dist/{cli-ybgv4kw2.js → cli-mbssg1xv.js} +9 -2
- package/dist/{cli-jsp14b6c.js → cli-mzfth0bp.js} +38 -1
- package/dist/{cli-r2ap2czm.js → cli-nexqx4ve.js} +6 -0
- package/dist/{cli-f8gy6r2r.js → cli-nq7yqw7b.js} +19 -8
- package/dist/{cli-10nhj6xq.js → cli-nt8hecg9.js} +34 -33
- package/dist/cli-p0r8sxj5.js +303 -0
- package/dist/{cli-58e8yr0d.js → cli-pkd6s2wy.js} +4 -2
- package/dist/{cli-a8dvhzrt.js → cli-q24re23n.js} +7 -5
- package/dist/cli-qjjvzwzd.js +222 -0
- package/dist/cli-qrgt5bqf.js +189 -0
- package/dist/{cli-et8m9xsv.js → cli-rfjw9jw2.js} +22 -10
- package/dist/{cli-7e398j1h.js → cli-rj0gqwwp.js} +3 -3
- package/dist/{cli-btfv8y88.js → cli-rnyzn44p.js} +2 -2
- package/dist/{cli-d5czme6m.js → cli-s3hwpt9v.js} +4754 -4945
- package/dist/{cli-0jwe9034.js → cli-sptrj5f5.js} +3 -3
- package/dist/{cli-0q3avq3s.js → cli-sqvfa090.js} +19 -11
- package/dist/{cli-azhgzetg.js → cli-swfmp1fx.js} +27 -27
- package/dist/{cli-jyk0ynw2.js → cli-t845n9xk.js} +23 -10
- package/dist/{cli-zpep9q5e.js → cli-tcen9p5w.js} +20 -15
- package/dist/{cli-74h9hscv.js → cli-tre4bdgq.js} +1 -1
- package/dist/{cli-pm1rst0h.js → cli-twrh04ap.js} +30 -15
- package/dist/{cli-phsaj4xq.js → cli-v0pvvhfq.js} +1 -1
- package/dist/{cli-ydmcgve1.js → cli-vc9bp061.js} +5 -5
- package/dist/{cli-g2whhdrf.js → cli-vxe6qa4h.js} +1 -1
- package/dist/{cli-vctdqs5h.js → cli-vy3ed88x.js} +15 -2
- package/dist/{cli-br0qdrnp.js → cli-vyqs9ya8.js} +18 -18
- package/dist/{cli-cpvsaqsw.js → cli-w0bwte75.js} +8 -5
- package/dist/cli-wbvnn6tk.js +861 -0
- package/dist/{cli-r94z9p1z.js → cli-wgbezhw2.js} +3 -0
- package/dist/{cli-evvtk35y.js → cli-wjgs5wxe.js} +7 -7
- package/dist/cli-wxkkd0e0.js +33 -0
- package/dist/{cli-0wgxmwf6.js → cli-xk79303e.js} +20 -7
- package/dist/{cli-ktmyrtpn.js → cli-xqpk3rp7.js} +33 -10
- package/dist/{cli-ygwm91nt.js → cli-yy6dew39.js} +1 -1
- package/dist/cli-zp38xvtm.js +9487 -0
- package/dist/{cli-tfky2838.js → cli-zvhd3f64.js} +4 -4
- package/dist/{cli-jayjpjmb.js → cli-zxqx25nz.js} +66 -23
- package/dist/cli.js +40 -32
- package/dist/{cloudflare-workers-ai-system-one-k6fbxw9d.js → cloudflare-workers-ai-system-one-k8ddqjkq.js} +8 -6
- package/dist/{codex-adapter-nmxcatww.js → codex-adapter-esvmnhn7.js} +24 -23
- package/dist/{codex-hook-20me6byw.js → codex-hook-m73jmqgx.js} +19 -3
- package/dist/{codex-login-w6fz4xbz.js → codex-login-cf7mzsgg.js} +2 -2
- package/dist/{codex-session-runner-90aa80ev.js → codex-session-runner-ban9excr.js} +24 -23
- package/dist/{commands-8wcq1kn7.js → commands-75413p2n.js} +13 -10
- package/dist/{db-j40kc4se.js → db-7f5pecwg.js} +17 -10
- package/dist/{dispatcher-4zqy768d.js → dispatcher-fh9at8nz.js} +41 -37
- package/dist/dsh-adapter-wpze65d4.js +24 -0
- package/dist/{e2b-ez07znam.js → e2b-gjgdjp91.js} +12 -9
- package/dist/easter-egg-3d-3w5c2n4c.js +1057 -0
- package/dist/{execute-6e7qeyk4.js → execute-f50wg9nh.js} +203 -49
- package/dist/{google-generative-ai-k6n5nbpp.js → google-generative-ai-jxxpnegy.js} +2 -2
- package/dist/{google-vertex-44xxtcvp.js → google-vertex-x7q1angm.js} +5 -5
- package/dist/{handlers-kjdce1w5.js → handlers-w13787bb.js} +44 -40
- package/dist/{hook-r2t4bqfg.js → hook-46g1jrvx.js} +34 -20
- package/dist/{hook-czx13n12.js → hook-4tpts2ry.js} +25 -21
- package/dist/{http-3bbb19be.js → http-19pzbfrt.js} +1440 -283
- package/dist/{index-668me3f0.js → index-8fd4dm4h.js} +42 -38
- package/dist/{index-fg0dsp6c.js → index-dqmp15bq.js} +41 -37
- package/dist/{index-kkv84jq9.js → index-qb4q1y3e.js} +41 -37
- package/dist/index-s75wc4wd.js +33 -0
- package/dist/{index-zg7vp46x.js → index-scptvdxg.js} +64 -38
- package/dist/{keepalive-yra8dy57.js → keepalive-xa5ts9cd.js} +15 -12
- package/dist/{lead-va0pad2c.js → lead-qp4xkvjq.js} +59 -54
- package/dist/{maintenance-hqewtmyg.js → maintenance-rm5885hm.js} +17 -14
- package/dist/{mistral-conversations-pc3ntnxt.js → mistral-conversations-rw7fbt22.js} +4 -4
- package/dist/{node-a5e00qhp.js → node-8zkdq42h.js} +834 -833
- package/dist/node-f0ykebbv.js +2107 -0
- package/dist/node-wyamey5r.js +19 -0
- package/dist/{oauth-refresh-sweep-7rdt1m9n.js → oauth-refresh-sweep-1csdfebf.js} +14 -11
- package/dist/{onboard-j6ms6d0x.js → onboard-r6b78cs4.js} +10 -10
- package/dist/{openai-codex-responses-bbancrr0.js → openai-codex-responses-efvrgrq3.js} +4 -4
- package/dist/{openai-completions-jpaj5g2b.js → openai-completions-bbbrrz4z.js} +12 -8
- package/dist/{openai-responses-200k1wx4.js → openai-responses-9jjyrcm1.js} +15 -10
- package/dist/{opencode-adapter-89rabkw2.js → opencode-adapter-kb3g6pkf.js} +12 -9
- package/dist/{otel-impl-a792rjz0.js → otel-impl-0y9knpky.js} +6 -6
- package/dist/{pi-mono-adapter-g7qzvr3v.js → pi-mono-adapter-z6s1bme2.js} +128 -37
- package/dist/{pricing-refresh-wx0tp7cb.js → pricing-refresh-mth26tgp.js} +15 -12
- package/dist/{rbac-roles-8tzawacv.js → rbac-roles-kwntb23q.js} +17 -12
- package/dist/rbac-roles-vpk4ebm8.js +45 -0
- package/dist/{registry-v5wytg0s.js → registry-km6t1jd2.js} +1 -1
- package/dist/{render-v2-mm7zswb8.js → render-v2-hcm7h00y.js} +17 -14
- package/dist/{runtime-zyssgse0.js → runtime-vfjsfsc5.js} +5 -4
- package/dist/{setup-8y70ys6t.js → setup-hbyzd65h.js} +2 -2
- package/dist/{virtual-modules-6nmk7h3n.js → virtual-modules-9bv7ry91.js} +9 -7
- package/dist/{work-objects-fg6xkb0n.js → work-objects-m09sxnhe.js} +44 -40
- package/dist/{worker-wmwhxsph.js → worker-0h35rvk4.js} +59 -54
- package/dist/{x-n3e0v3xa.js → x-f1gt1pz3.js} +2 -2
- package/openapi.json +699 -26
- package/package.json +19 -11
- package/src/azure-devops/api.ts +121 -0
- package/src/azure-devops/auth.ts +78 -0
- package/src/azure-devops/handlers.ts +413 -0
- package/src/azure-devops/index.ts +27 -0
- package/src/azure-devops/templates.ts +108 -0
- package/src/azure-devops/types.ts +90 -0
- package/src/be/api-drain.ts +184 -0
- package/src/be/db/tasks/read.ts +32 -7
- package/src/be/db/tasks/write.ts +21 -4
- package/src/be/db-client.ts +11 -2
- package/src/be/db-retention.ts +95 -32
- package/src/be/db.ts +44 -19
- package/src/be/memory/constants.ts +16 -0
- package/src/be/memory/graph-expansion.ts +8 -1
- package/src/be/memory/index-content.ts +20 -1
- package/src/be/memory/key-guard.ts +93 -0
- package/src/be/memory/key-paths.ts +103 -0
- package/src/be/memory/link-resolver.ts +29 -3
- package/src/be/memory/providers/sqlite-store.ts +152 -45
- package/src/be/memory/raters/llm-summarizer.ts +10 -4
- package/src/be/memory/raters/llm.ts +15 -5
- package/src/be/memory/raters/store.ts +6 -3
- package/src/be/memory/raters/types.ts +11 -0
- package/src/be/memory/reranker.ts +38 -7
- package/src/be/memory/types.ts +12 -1
- package/src/be/migrations/190_memory_rating_model.sql +7 -0
- package/src/be/migrations/191_context_versions_previous_index.sql +8 -0
- package/src/be/migrations/192_favorites_agent_fs_path.sql +36 -0
- package/src/be/onboarding.ts +7 -1
- package/src/be/pricing-normalize.ts +4 -2
- package/src/be/scripts/typecheck.ts +4 -3
- package/src/be/seed-pricing.ts +16 -0
- package/src/be/seed-prompt-templates.ts +1 -0
- package/src/be/swarm-config-guard.ts +46 -17
- package/src/be/task-citations.ts +11 -5
- package/src/be/users.ts +3 -0
- package/src/cli.tsx +3 -2
- package/src/comb/agent-fs.ts +39 -0
- package/src/comb/config.ts +37 -0
- package/src/comb/markers.ts +37 -0
- package/src/comb/review-batch.ts +486 -0
- package/src/comb/templates.ts +88 -0
- package/src/commands/claude-managed-setup.ts +33 -31
- package/src/commands/context-preamble.ts +4 -1
- package/src/commands/hook.ts +2 -1
- package/src/commands/provider-credentials.ts +28 -15
- package/src/commands/runner.ts +458 -110
- package/src/commands/templates.ts +10 -0
- package/src/e2b/env.ts +2 -0
- package/src/extensions/catalog.generated.json +17 -0
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/fs/agent-fs-provider.ts +106 -2
- package/src/github/handlers.ts +10 -74
- package/src/github/reactions.ts +119 -138
- package/src/github/task-reactions.ts +34 -11
- package/src/heartbeat/heartbeat.ts +4 -0
- package/src/hooks/codex-hook.ts +25 -1
- package/src/hooks/hook.ts +14 -1
- package/src/hooks/pr-body-guard.ts +983 -0
- package/src/http/agents.ts +1 -1
- package/src/http/all-routes.ts +1 -0
- package/src/http/assets.ts +5 -17
- package/src/http/comb.ts +131 -0
- package/src/http/core.ts +14 -1
- package/src/http/extensions.ts +51 -27
- package/src/http/fs.ts +9 -17
- package/src/http/index.ts +27 -9
- package/src/http/mcp-user.ts +8 -13
- package/src/http/mcp.ts +19 -12
- package/src/http/memory.ts +80 -14
- package/src/http/onboarding.ts +21 -2
- package/src/http/poll.ts +30 -3
- package/src/http/realtime.ts +62 -0
- package/src/http/request-principal.ts +22 -0
- package/src/http/session-data.ts +6 -4
- package/src/http/stats.ts +1 -0
- package/src/http/status.ts +34 -2
- package/src/http/tasks.ts +17 -3
- package/src/http/users.ts +1 -1
- package/src/http/webhooks.ts +120 -2
- package/src/kv-reserved-namespaces.ts +10 -5
- package/src/providers/claude-adapter.ts +84 -16
- package/src/providers/claude-managed-adapter.ts +29 -2
- package/src/providers/codex-adapter.ts +1 -1
- package/src/providers/codex-skill-resolver.ts +6 -0
- package/src/providers/dsh-adapter.ts +204 -7
- package/src/providers/opencode-adapter.ts +24 -3
- package/src/providers/pi-mono-adapter.ts +154 -5
- package/src/providers/pi-mono-extension.ts +1 -1
- package/src/providers/pricing-sources.md +5 -1
- package/src/providers/reasoning-effort.ts +10 -2
- package/src/providers/types.ts +1 -1
- package/src/rbac/legacy-policy.ts +3 -0
- package/src/rbac/permissions.ts +14 -0
- package/src/realtime/auth.ts +63 -1
- package/src/realtime/tickets.ts +52 -0
- package/src/realtime/transport.ts +51 -22
- package/src/scripts-runtime/types/stdlib.d.ts +13 -5
- package/src/scripts-runtime/types/swarm-extension.d.ts +7 -3
- package/src/scripts-runtime/types/swarm-sdk.d.ts +13 -5
- package/src/tasks/context-key.ts +38 -1
- package/src/telemetry-context.ts +175 -0
- package/src/telemetry-contract/EVENTS.md +81 -0
- package/src/telemetry-contract/SOURCE.json +9 -0
- package/src/telemetry-contract/catalog.json +1335 -0
- package/src/telemetry-contract/index.ts +60 -0
- package/src/telemetry-contract/types.gen.ts +1971 -0
- package/src/telemetry-identity.ts +129 -0
- package/src/telemetry-snapshot.ts +211 -0
- package/src/telemetry-trigger.ts +125 -0
- package/src/telemetry-types.typetest.ts +40 -0
- package/src/telemetry.ts +271 -67
- package/src/tests/api-drain-e2e.test.ts +249 -0
- package/src/tests/api-drain-worker-e2e.test.ts +216 -0
- package/src/tests/api-drain.test.ts +351 -0
- package/src/tests/azure-devops-auth.test.ts +100 -0
- package/src/tests/azure-devops-handlers.test.ts +324 -0
- package/src/tests/azure-devops-webhook-malformed.test.ts +96 -0
- package/src/tests/claude-default-route.test.ts +260 -0
- package/src/tests/claude-managed-adapter.test.ts +47 -0
- package/src/tests/claude-managed-setup.test.ts +48 -0
- package/src/tests/claude-prompt-body-once.test.ts +117 -0
- package/src/tests/claude-routes-e2e.test.ts +316 -0
- package/src/tests/comb-config-guard.test.ts +38 -0
- package/src/tests/comb-links.test.ts +162 -0
- package/src/tests/comb-markers.test.ts +68 -0
- package/src/tests/comb-review-batch.test.ts +770 -0
- package/src/tests/comb-status.test.ts +152 -0
- package/src/tests/context-versions-retention.test.ts +314 -0
- package/src/tests/core-auth.test.ts +7 -0
- package/src/tests/db-retention.test.ts +14 -14
- package/src/tests/db-task-read-contract.test.ts +3 -0
- package/src/tests/db-task-write-contract.test.ts +3 -0
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/dsh-adapter.test.ts +134 -2
- package/src/tests/dsh-usage.test.ts +153 -0
- package/src/tests/extensions-catalog.test.ts +1 -0
- package/src/tests/extensions-example-deploy-awareness.test.ts +301 -0
- package/src/tests/extensions-http.test.ts +137 -10
- package/src/tests/extensions-mcp-tools.test.ts +28 -0
- package/src/tests/favorites-agent-fs-path.test.ts +226 -0
- package/src/tests/fetch-resolved-env.test.ts +24 -0
- package/src/tests/fixtures/azure-devops/pull-request-commented.json +129 -0
- package/src/tests/fixtures/azure-devops/pull-request-created.json +88 -0
- package/src/tests/fixtures/fake-claude-routes.ts +229 -0
- package/src/tests/github-handlers-reactions.test.ts +486 -0
- package/src/tests/github-reactions.test.ts +280 -0
- package/src/tests/harness-cli-version.test.ts +62 -0
- package/src/tests/http-api-integration.test.ts +21 -0
- package/src/tests/http-task-write-ownership.test.ts +24 -1
- package/src/tests/internal-ai/complete-structured.test.ts +94 -0
- package/src/tests/internal-ai/credentials.test.ts +22 -0
- package/src/tests/internal-ai/models.test.ts +36 -2
- package/src/tests/internal-ai/schema-parity.test.ts +25 -1
- package/src/tests/internal-ai/summarize-session.test.ts +23 -7
- package/src/tests/mcp-user-route.test.ts +133 -0
- package/src/tests/memory-key-paths.test.ts +1055 -0
- package/src/tests/memory-link-resolver.test.ts +34 -0
- package/src/tests/memory-rate-endpoint.test.ts +66 -0
- package/src/tests/memory-rater-llm-summarizer.test.ts +2 -1
- package/src/tests/memory-rater-llm.test.ts +73 -0
- package/src/tests/memory-rater-store.test.ts +31 -0
- package/src/tests/memory-reranker.test.ts +40 -0
- package/src/tests/onboarding.test.ts +108 -0
- package/src/tests/opencode-adapter.test.ts +57 -0
- package/src/tests/opencode-plugin.test.ts +4 -0
- package/src/tests/pi-codemode.test.ts +82 -4
- package/src/tests/pi-mono-adapter.test.ts +265 -2
- package/src/tests/pr-body-leaks.test.ts +789 -0
- package/src/tests/preload.ts +14 -0
- package/src/tests/provider-registration.test.ts +0 -2
- package/src/tests/providers/pi-cost.test.ts +190 -4
- package/src/tests/rbac-engine.test.ts +25 -1
- package/src/tests/realtime-room-auth.test.ts +104 -1
- package/src/tests/realtime-tickets.test.ts +74 -0
- package/src/tests/realtime-transport.test.ts +131 -4
- package/src/tests/runner-api-drain.test.ts +301 -0
- package/src/tests/runner-fallback-output.test.ts +61 -0
- package/src/tests/runner-fenced-json-output.test.ts +178 -0
- package/src/tests/runner-slot-reconcile.test.ts +199 -0
- package/src/tests/script-connections.test.ts +6 -0
- package/src/tests/send-task-requested-by.test.ts +133 -15
- package/src/tests/session-costs-recompute-all-providers.test.ts +23 -0
- package/src/tests/task-lifecycle-telemetry.test.ts +8 -3
- package/src/tests/task-reactions.test.ts +29 -6
- package/src/tests/telemetry-context.test.ts +314 -0
- package/src/tests/telemetry-init.test.ts +51 -19
- package/src/tests/telemetry-snapshot.test.ts +229 -0
- package/src/tests/telemetry-trigger.test.ts +200 -0
- package/src/tests/template-registry-helpers.ts +1 -0
- package/src/tests/vcs-azure-devops.test.ts +73 -0
- package/src/tests/webhooks-task-blocked.test.ts +23 -0
- package/src/tests/workflow-agent-task-retry.test.ts +363 -0
- package/src/tests/workflow-definition-telemetry.test.ts +4 -4
- package/src/tests/workflow-llm.test.ts +14 -0
- package/src/tools/context-diff.ts +20 -0
- package/src/tools/extension-install.ts +27 -16
- package/src/tools/memory-edit.ts +47 -3
- package/src/tools/memory-search.ts +13 -1
- package/src/tools/memory-store.ts +55 -3
- package/src/tools/poll-task.ts +20 -1
- package/src/tools/send-task.ts +9 -1
- package/src/tools/task-action.ts +11 -0
- package/src/types.ts +45 -8
- package/src/utils/api-drain.ts +24 -0
- package/src/utils/constants.ts +57 -16
- package/src/utils/credentials.test.ts +31 -1
- package/src/utils/credentials.ts +20 -9
- package/src/utils/dsh-usage.ts +53 -0
- package/src/utils/harness-cli-version.ts +6 -4
- package/src/utils/internal-ai/complete-structured.ts +26 -3
- package/src/utils/internal-ai/credentials.ts +23 -9
- package/src/utils/internal-ai/index.ts +8 -1
- package/src/utils/internal-ai/models.ts +34 -8
- package/src/utils/internal-ai/summarize-session.ts +22 -8
- package/src/utils/pr-body-leaks.ts +172 -0
- package/src/utils/secret-scrubber.ts +8 -0
- package/src/utils/task-attachment-links.ts +14 -8
- package/src/vcs/azure-devops.ts +80 -0
- package/src/vcs/index.ts +5 -1
- package/src/vcs/types.ts +2 -2
- package/src/workflows/recovery.ts +26 -1
- package/src/workflows/resume.ts +31 -4
- package/src/workflows/task-step-routing.ts +75 -2
- package/templates/community/open-prompt-showreel/PLAYBOOK.md +336 -0
- package/templates/community/open-prompt-showreel/README.md +33 -0
- package/templates/community/open-prompt-showreel/example/tla-races/facts.ts +145 -0
- package/templates/community/open-prompt-showreel/example/tla-races/facts.v3.json +140 -0
- package/templates/community/open-prompt-showreel/example/tla-races/music.mist-city.json +8 -0
- package/templates/community/open-prompt-showreel/example/tla-races/reel.html +805 -0
- package/templates/community/open-prompt-showreel/example/tla-races/smoke.sh +48 -0
- package/templates/community/open-prompt-showreel/lead-prompt.md +89 -0
- package/templates/community/open-prompt-showreel/setup.sh +167 -0
- package/templates/community/open-prompt-showreel/skills/motion-design-replication/SKILL.md +85 -0
- package/templates/community/open-prompt-showreel/skills/motion-design-video-analysis/SKILL.md +115 -0
- package/templates/community/open-prompt-showreel/skills/open-prompt-showreel/SKILL.md +147 -0
- package/templates/community/open-prompt-showreel/skills/video-generation/SKILL.md +195 -0
- package/templates/community/open-prompt-showreel/tools/fetch-music.sh +65 -0
- package/templates/community/open-prompt-showreel/tools/music-analyze.py +69 -0
- package/templates/community/open-prompt-showreel/tools/music-current.sh +34 -0
- package/templates/community/open-prompt-showreel/tools/music-cut.sh +36 -0
- package/templates/community/open-prompt-showreel/tools/music-refine.py +39 -0
- package/templates/community/open-prompt-showreel/tools/render.mjs +157 -0
- package/templates/community/open-prompt-showreel/tools/sheet.sh +44 -0
- package/templates/community/open-prompt-showreel/tools/web-compress.sh +17 -0
- package/templates/community/open-prompt-showreel/tools/x-reencode.sh +21 -0
- package/templates/extensions/README.md +1 -0
- package/templates/extensions/deploy-awareness/README.md +28 -0
- package/templates/extensions/deploy-awareness/hooks.ts +152 -0
- package/templates/extensions/deploy-awareness/manifest.json +8 -0
- package/templates/skills/memory/config.json +2 -2
- package/templates/skills/memory/content.md +59 -5
- package/templates/skills/swarm-extensions/config.json +1 -1
- package/templates/skills/swarm-extensions/content.md +28 -5
- package/tsconfig.json +3 -0
- package/dist/boot-seeds-gsetbs5y.js +0 -28
- package/dist/cli-j490egb5.js +0 -5632
- package/dist/cli-tjf4cn8z.js +0 -9119
- package/dist/cli-tmqt7dpj.js +0 -572
- package/dist/dsh-adapter-mpnzgztj.js +0 -19
- package/dist/index-7aj368tw.js +0 -30
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
+
import { getAgentById } from "@/be/db";
|
|
3
4
|
import { indexMemoryContent } from "@/be/memory/index-content";
|
|
5
|
+
import { MemoryKeyError } from "@/be/memory/key-guard";
|
|
6
|
+
import {
|
|
7
|
+
MEMORY_KEY_MAX_LENGTH,
|
|
8
|
+
MEMORY_KEY_PATTERN,
|
|
9
|
+
MEMORY_KEY_PATTERN_MESSAGE,
|
|
10
|
+
resolveStoreKey,
|
|
11
|
+
} from "@/be/memory/key-paths";
|
|
4
12
|
import { createToolRegistrar, swarmToolOutputSchema, toolErr, toolOk } from "@/tools/utils";
|
|
5
13
|
import { AgentMemoryScopeSchema } from "@/types";
|
|
6
14
|
|
|
@@ -26,7 +34,7 @@ export const registerMemoryStoreTool = (server: McpServer) => {
|
|
|
26
34
|
.max(200)
|
|
27
35
|
.optional()
|
|
28
36
|
.describe(
|
|
29
|
-
"Short title used in search results and the UI. Defaults to the first non-empty content line (up to 200 characters).",
|
|
37
|
+
"Short title used in search results and the UI. Defaults to the first non-empty content line (up to 200 characters). A name that starts with /longterm/ is also used as the key when no key is given.",
|
|
30
38
|
),
|
|
31
39
|
scope: AgentMemoryScopeSchema.default("agent").describe(
|
|
32
40
|
"'agent' (default): only you can recall it. 'swarm': every agent can recall it.",
|
|
@@ -46,6 +54,14 @@ export const registerMemoryStoreTool = (server: McpServer) => {
|
|
|
46
54
|
.min(1)
|
|
47
55
|
.optional()
|
|
48
56
|
.describe("Why this is worth remembering. Kept in the audit trail."),
|
|
57
|
+
key: z
|
|
58
|
+
.string()
|
|
59
|
+
.max(MEMORY_KEY_MAX_LENGTH)
|
|
60
|
+
.regex(MEMORY_KEY_PATTERN, MEMORY_KEY_PATTERN_MESSAGE)
|
|
61
|
+
.optional()
|
|
62
|
+
.describe(
|
|
63
|
+
"Optional logical path for this memory, for example '/longterm/facts/swarm-runtime/sqlite-busy-retry'. Lowercase segments joined by '/', starting with '/'. Search it with memory-search keyPrefix and move it with memory-edit newKey. Fails when you already have a memory with this key in this scope. A key under /longterm marks the memory as curated: it never expires and is protected from cleanup. It must start with /longterm/company-story, /longterm/entities/people, /longterm/entities/customers, /longterm/facts, /longterm/decisions, /longterm/workstreams or /longterm/timeline. Paths under /longterm/company-story, /longterm/entities and /longterm/timeline are lead-only. Defaults to an auto key, which makes the memory inbox material.",
|
|
64
|
+
),
|
|
49
65
|
}),
|
|
50
66
|
outputSchema: swarmToolOutputSchema({
|
|
51
67
|
yourAgentId: z.string().optional(),
|
|
@@ -54,7 +70,11 @@ export const registerMemoryStoreTool = (server: McpServer) => {
|
|
|
54
70
|
queued: z.boolean().optional(),
|
|
55
71
|
}),
|
|
56
72
|
},
|
|
57
|
-
async (
|
|
73
|
+
async (
|
|
74
|
+
{ content, name: requestedName, scope, tags, taskId, intent, key },
|
|
75
|
+
requestInfo,
|
|
76
|
+
_meta,
|
|
77
|
+
) => {
|
|
58
78
|
const name =
|
|
59
79
|
requestedName ??
|
|
60
80
|
content
|
|
@@ -74,7 +94,20 @@ export const registerMemoryStoreTool = (server: McpServer) => {
|
|
|
74
94
|
return toolErr("Agent ID required. Are you registered in the swarm?");
|
|
75
95
|
}
|
|
76
96
|
|
|
97
|
+
const storeKey = resolveStoreKey(key, requestedName);
|
|
98
|
+
// A /longterm/ name becomes the key, so it must hold up as one. Falling
|
|
99
|
+
// back to an auto key would leave the agent believing it wrote a path.
|
|
100
|
+
if (storeKey && !key && !MEMORY_KEY_PATTERN.test(storeKey)) {
|
|
101
|
+
return toolErr(
|
|
102
|
+
`Name "${storeKey}" starts with /longterm/, so it is used as the key, but it is not a valid key. ${MEMORY_KEY_PATTERN_MESSAGE}`,
|
|
103
|
+
{ data: { yourAgentId: requestInfo.agentId } },
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
77
107
|
try {
|
|
108
|
+
// The key checks (shape, allowed roots, lead-only roots) run inside
|
|
109
|
+
// indexMemoryContent, the same gate POST /api/memory/index passes.
|
|
110
|
+
const agent = storeKey ? await getAgentById(requestInfo.agentId) : undefined;
|
|
78
111
|
// The caller always owns the row, for both scopes: a swarm memory still
|
|
79
112
|
// records who wrote it (mirrors inject-learning).
|
|
80
113
|
const result = await indexMemoryContent({
|
|
@@ -86,6 +119,15 @@ export const registerMemoryStoreTool = (server: McpServer) => {
|
|
|
86
119
|
sourceTaskId: taskId ?? null,
|
|
87
120
|
tags: normalizedTags,
|
|
88
121
|
intent,
|
|
122
|
+
key: storeKey,
|
|
123
|
+
writer: {
|
|
124
|
+
principal: {
|
|
125
|
+
kind: "agent",
|
|
126
|
+
agentId: requestInfo.agentId,
|
|
127
|
+
isLead: agent?.isLead ?? false,
|
|
128
|
+
},
|
|
129
|
+
source: "mcp",
|
|
130
|
+
},
|
|
89
131
|
});
|
|
90
132
|
|
|
91
133
|
return toolOk(
|
|
@@ -100,7 +142,17 @@ export const registerMemoryStoreTool = (server: McpServer) => {
|
|
|
100
142
|
},
|
|
101
143
|
);
|
|
102
144
|
} catch (err) {
|
|
103
|
-
|
|
145
|
+
if (err instanceof MemoryKeyError) {
|
|
146
|
+
return toolErr(err.message, { data: { yourAgentId: requestInfo.agentId } });
|
|
147
|
+
}
|
|
148
|
+
const message = (err as Error).message;
|
|
149
|
+
if (storeKey && /UNIQUE constraint failed/i.test(message)) {
|
|
150
|
+
return toolErr(
|
|
151
|
+
`Memory store failed: key "${storeKey}" is already used in ${scope} scope. Edit that memory with memory-edit, or pick another key.`,
|
|
152
|
+
{ data: { yourAgentId: requestInfo.agentId } },
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
return toolErr(`Memory store failed: ${message}`, {
|
|
104
156
|
data: { yourAgentId: requestInfo.agentId },
|
|
105
157
|
});
|
|
106
158
|
}
|
package/src/tools/poll-task.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { addMinutes } from "date-fns";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
+
import { isApiDraining } from "@/be/api-drain";
|
|
4
5
|
import {
|
|
5
6
|
getActiveTaskCount,
|
|
6
7
|
getAgentById,
|
|
@@ -132,7 +133,9 @@ export const registerPollTaskTool = (server: McpServer) => {
|
|
|
132
133
|
while (new Date() < maxTime) {
|
|
133
134
|
// Fetch and update in a single transaction to avoid race conditions
|
|
134
135
|
const outcome = await getDbClient().transaction(
|
|
135
|
-
async (): Promise<
|
|
136
|
+
async (): Promise<
|
|
137
|
+
AgentTask | "at-capacity" | "runtime-unavailable" | "draining" | null
|
|
138
|
+
> => {
|
|
136
139
|
// The entry gate only proves liveness when the long poll began;
|
|
137
140
|
// the runtime must be live at the exact moment work is acquired,
|
|
138
141
|
// so revalidate in the same transaction that can start the task.
|
|
@@ -147,6 +150,9 @@ export const registerPollTaskTool = (server: McpServer) => {
|
|
|
147
150
|
return "runtime-unavailable";
|
|
148
151
|
}
|
|
149
152
|
|
|
153
|
+
// A draining API dispatches nothing; see src/be/api-drain.ts.
|
|
154
|
+
if (isApiDraining()) return "draining";
|
|
155
|
+
|
|
150
156
|
const agentNow = (await getAgentById(agentId))!;
|
|
151
157
|
|
|
152
158
|
if (agentNow.status !== "busy") {
|
|
@@ -188,6 +194,19 @@ export const registerPollTaskTool = (server: McpServer) => {
|
|
|
188
194
|
});
|
|
189
195
|
}
|
|
190
196
|
|
|
197
|
+
if (outcome === "draining") {
|
|
198
|
+
// Like a runtime refusal, this is not an empty poll: skip the exit counter.
|
|
199
|
+
return toolOk("No task available.", {
|
|
200
|
+
details: "The API is draining for a restart and dispatches no new work. Retry shortly.",
|
|
201
|
+
data: {
|
|
202
|
+
yourAgentId: requestInfo.agentId,
|
|
203
|
+
offeredTasks: [],
|
|
204
|
+
availableCount: 0,
|
|
205
|
+
waitedForSeconds: Math.round((Date.now() - now.getTime()) / 1000),
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
191
210
|
if (outcome === "at-capacity") {
|
|
192
211
|
// A capacity refusal is not an empty poll (refused ≠ empty, D-R3):
|
|
193
212
|
// return without advancing the exit counter.
|
package/src/tools/send-task.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
getUserById,
|
|
16
16
|
hasCapacity,
|
|
17
17
|
isExtensionAgent,
|
|
18
|
+
isLinearTrackerContextKey,
|
|
18
19
|
} from "@/be/db";
|
|
19
20
|
import { repointTrackerSyncBySwarmId } from "@/be/db-queries/tracker";
|
|
20
21
|
import { explicitModelErrorForAgent } from "@/be/model-validation";
|
|
@@ -467,11 +468,12 @@ export async function sendTaskHandler(
|
|
|
467
468
|
} | null> => {
|
|
468
469
|
const existingTrackerWork = await findExistingLinearTrackerContextWork(
|
|
469
470
|
effectiveParentTask?.contextKey,
|
|
471
|
+
effectiveParentTask?.id,
|
|
470
472
|
);
|
|
471
473
|
if (existingTrackerWork) {
|
|
472
474
|
const msg = `Skipped: Linear tracker contextKey ${effectiveParentTask?.contextKey} already has ${existingTrackerWork.reason === "active_task" ? "active task" : "linked open PR"} ${existingTrackerWork.task.id.slice(0, 8)}.`;
|
|
473
475
|
console.log(`[send-task] ${msg}`);
|
|
474
|
-
return { ok:
|
|
476
|
+
return { ok: false, message: msg, task: existingTrackerWork.task };
|
|
475
477
|
}
|
|
476
478
|
|
|
477
479
|
// Dedup guard: check for similar recent tasks
|
|
@@ -559,6 +561,12 @@ export async function sendTaskHandler(
|
|
|
559
561
|
const raced = await evaluateDedupGuards();
|
|
560
562
|
if (raced) return { success: raced.ok, message: raced.message, task: raced.task };
|
|
561
563
|
|
|
564
|
+
// This transaction already checked the tracker key, excluding the caller's
|
|
565
|
+
// lineage. The creation guard would otherwise match work in that lineage.
|
|
566
|
+
if (isLinearTrackerContextKey(effectiveParentTask?.contextKey)) {
|
|
567
|
+
taskOptions.bypassTrackerContextDedup = true;
|
|
568
|
+
}
|
|
569
|
+
|
|
562
570
|
// If no agentId (and no auto-routed agentId), create an unassigned task for the pool
|
|
563
571
|
const targetAgentId = taskOptions.offeredTo ?? taskOptions.agentId ?? undefined;
|
|
564
572
|
if (!targetAgentId) {
|
package/src/tools/task-action.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
+
import { isApiDraining } from "@/be/api-drain";
|
|
3
4
|
import { AssetKeyAuthorizationError, authorizeAssetKeyWrite } from "@/be/asset-key-auth";
|
|
4
5
|
import { resolveTaskAuditUserId } from "@/be/audit-user";
|
|
5
6
|
import { canClaim } from "@/be/budget-admission";
|
|
@@ -177,6 +178,14 @@ async function staleRuntimeResult(ctx: ToolCtx, agentId: string): Promise<TaskAc
|
|
|
177
178
|
};
|
|
178
179
|
}
|
|
179
180
|
|
|
181
|
+
/** A draining API dispatches nothing (src/be/api-drain.ts); claim and accept wait for the next API. */
|
|
182
|
+
function apiDrainingResult(action: "claim" | "accept"): TaskActionResult {
|
|
183
|
+
return {
|
|
184
|
+
success: false,
|
|
185
|
+
message: `The API is draining for a restart and dispatches no new work, so this ${action} was not made. Retry shortly.`,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
180
189
|
function taskActionResult(result: TaskActionResult, agentId?: string): SwarmToolResult {
|
|
181
190
|
const { refusalSideEffects: _omit, success, message, ...rest } = result;
|
|
182
191
|
const data = {
|
|
@@ -353,6 +362,7 @@ export async function taskActionHandler(
|
|
|
353
362
|
}
|
|
354
363
|
const staleClaimRuntime = await staleRuntimeResult(ctx, agentId);
|
|
355
364
|
if (staleClaimRuntime) return staleClaimRuntime;
|
|
365
|
+
if (isApiDraining()) return apiDrainingResult("claim");
|
|
356
366
|
// Check capacity before claiming
|
|
357
367
|
if (!(await hasCapacity(agentId))) {
|
|
358
368
|
const activeCount = await getActiveTaskCount(agentId);
|
|
@@ -462,6 +472,7 @@ export async function taskActionHandler(
|
|
|
462
472
|
// budget admission below so a retired process cannot take the offer.
|
|
463
473
|
const staleAcceptRuntime = await staleRuntimeResult(ctx, agentId);
|
|
464
474
|
if (staleAcceptRuntime) return staleAcceptRuntime;
|
|
475
|
+
if (isApiDraining()) return apiDrainingResult("accept");
|
|
465
476
|
const existingTask = await getTaskById(taskId);
|
|
466
477
|
if (!existingTask) {
|
|
467
478
|
return { success: false, message: `Task "${taskId}" not found.` };
|
package/src/types.ts
CHANGED
|
@@ -357,12 +357,14 @@ export const AgentTaskSourceSchema = z.enum([
|
|
|
357
357
|
"ui",
|
|
358
358
|
"github",
|
|
359
359
|
"gitlab",
|
|
360
|
+
"azure-devops",
|
|
360
361
|
"agentmail",
|
|
361
362
|
"system",
|
|
362
363
|
"schedule",
|
|
363
364
|
"workflow",
|
|
364
365
|
"linear",
|
|
365
366
|
"jira",
|
|
367
|
+
"comb",
|
|
366
368
|
]);
|
|
367
369
|
export type AgentTaskSource = z.infer<typeof AgentTaskSourceSchema>;
|
|
368
370
|
|
|
@@ -591,8 +593,8 @@ export const AgentTaskSchema = z
|
|
|
591
593
|
slackProgressMessageTs: z.string().optional(),
|
|
592
594
|
slackTreeRootMessageTs: z.string().optional(),
|
|
593
595
|
|
|
594
|
-
// VCS metadata (GitHub / GitLab — provider-agnostic)
|
|
595
|
-
vcsProvider: z.enum(["github", "gitlab"]).optional(),
|
|
596
|
+
// VCS metadata (GitHub / GitLab / Azure DevOps — provider-agnostic)
|
|
597
|
+
vcsProvider: z.enum(["github", "gitlab", "azure-devops"]).optional(),
|
|
596
598
|
vcsRepo: z.string().optional(),
|
|
597
599
|
vcsEventType: z.string().optional(),
|
|
598
600
|
vcsNumber: z.number().int().optional(),
|
|
@@ -749,7 +751,7 @@ export const CreateTaskOptionsSchema = z.object({
|
|
|
749
751
|
* this boundary must not let a caller silently persist a mismatch.
|
|
750
752
|
*/
|
|
751
753
|
overrideSlackContext: z.boolean().optional(),
|
|
752
|
-
vcsProvider: z.enum(["github", "gitlab"]).optional(),
|
|
754
|
+
vcsProvider: z.enum(["github", "gitlab", "azure-devops"]).optional(),
|
|
753
755
|
vcsRepo: z.string().optional(),
|
|
754
756
|
vcsEventType: z.string().optional(),
|
|
755
757
|
vcsNumber: z.number().int().optional(),
|
|
@@ -1044,7 +1046,7 @@ export type InboxItemState = z.infer<typeof InboxItemStateSchema>;
|
|
|
1044
1046
|
// User Favorites (principal-scoped stars for app navigation)
|
|
1045
1047
|
// ============================================================================
|
|
1046
1048
|
|
|
1047
|
-
export const FavoriteItemTypeSchema = z.enum(["page", "workflow", "schedule"]);
|
|
1049
|
+
export const FavoriteItemTypeSchema = z.enum(["page", "workflow", "schedule", "agent-fs-path"]);
|
|
1048
1050
|
export type FavoriteItemType = z.infer<typeof FavoriteItemTypeSchema>;
|
|
1049
1051
|
|
|
1050
1052
|
export const UserFavoriteSchema = z
|
|
@@ -3125,15 +3127,50 @@ export const ExtensionRunSchema = z
|
|
|
3125
3127
|
.openapi("ExtensionRun");
|
|
3126
3128
|
export type ExtensionRun = z.infer<typeof ExtensionRunSchema>;
|
|
3127
3129
|
|
|
3130
|
+
/**
|
|
3131
|
+
* An extension install names exactly one source: a catalog `template`, or an inline
|
|
3132
|
+
* `manifest` with its `files`. Shared by the HTTP body and the `extension-install` tool input.
|
|
3133
|
+
*/
|
|
3134
|
+
export function checkExtensionInstallSource(
|
|
3135
|
+
body: { template?: unknown; manifest?: unknown; files?: unknown },
|
|
3136
|
+
ctx: z.RefinementCtx,
|
|
3137
|
+
): void {
|
|
3138
|
+
const inline = body.manifest !== undefined || body.files !== undefined;
|
|
3139
|
+
if (body.template !== undefined && inline) {
|
|
3140
|
+
ctx.addIssue({
|
|
3141
|
+
code: "custom",
|
|
3142
|
+
message: "template is mutually exclusive with manifest and files",
|
|
3143
|
+
});
|
|
3144
|
+
} else if (body.template === undefined && !inline) {
|
|
3145
|
+
ctx.addIssue({ code: "custom", message: "provide either template, or manifest with files" });
|
|
3146
|
+
} else if (inline && body.manifest === undefined) {
|
|
3147
|
+
ctx.addIssue({
|
|
3148
|
+
code: "custom",
|
|
3149
|
+
path: ["manifest"],
|
|
3150
|
+
message: "manifest is required with files",
|
|
3151
|
+
});
|
|
3152
|
+
} else if (inline && body.files === undefined) {
|
|
3153
|
+
ctx.addIssue({ code: "custom", path: ["files"], message: "files is required with manifest" });
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
|
|
3128
3157
|
export const ExtensionInstallBodySchema = z
|
|
3129
3158
|
.object({
|
|
3130
|
-
template: ExtensionNameSchema.describe(
|
|
3131
|
-
"Name of a predefined extension in the catalog (`GET /api/extensions/catalog`).",
|
|
3159
|
+
template: ExtensionNameSchema.optional().describe(
|
|
3160
|
+
"Name of a predefined extension in the catalog (`GET /api/extensions/catalog`). Mutually exclusive with `manifest` and `files`.",
|
|
3161
|
+
),
|
|
3162
|
+
manifest: ExtensionManifestSchema.optional().describe(
|
|
3163
|
+
"Inline bundle manifest. Requires `files`. Accepted only when `EXTENSION_ALLOW_INLINE_INSTALL` is on and the caller is a lead, operator, or dashboard user.",
|
|
3132
3164
|
),
|
|
3133
|
-
|
|
3134
|
-
|
|
3165
|
+
files: z
|
|
3166
|
+
.record(z.string(), z.string())
|
|
3167
|
+
.optional()
|
|
3168
|
+
.describe("Inline bundle files keyed by relative path. Requires `manifest`."),
|
|
3169
|
+
priority: z.number().int().optional().describe("Handler priority. Lower values run first."),
|
|
3170
|
+
config: z.record(z.string(), z.unknown()).optional().describe("Extension configuration."),
|
|
3135
3171
|
})
|
|
3136
3172
|
.strict()
|
|
3173
|
+
.superRefine(checkExtensionInstallSource)
|
|
3137
3174
|
.openapi("ExtensionInstallBody");
|
|
3138
3175
|
export type ExtensionInstallBody = z.infer<typeof ExtensionInstallBodySchema>;
|
|
3139
3176
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire contract for the API drain, shared by the API server and the workers.
|
|
3
|
+
* Keep this file free of DB and server imports: `src/commands/` reads it.
|
|
4
|
+
*
|
|
5
|
+
* While the API is draining (SIGTERM received, still serving) it adds
|
|
6
|
+
* `X-Swarm-Draining: 1` to every response. A worker that sees the header hands
|
|
7
|
+
* off its in-flight tasks and stops taking new ones. An API that never drains
|
|
8
|
+
* never sends the header, so older and newer sides interoperate unchanged.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export const API_DRAINING_HEADER = "X-Swarm-Draining";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Upper bound for `API_DRAIN_MAX_MS`. The config validator and the resolver in
|
|
15
|
+
* `src/be/api-drain.ts` both read it, so the config API cannot accept a value
|
|
16
|
+
* the shutdown path would clamp. Keep the API's `stop_grace_period` above the
|
|
17
|
+
* cap plus the time the API needs to close.
|
|
18
|
+
*/
|
|
19
|
+
export const API_DRAIN_MAX_MS_LIMIT = 120_000;
|
|
20
|
+
|
|
21
|
+
/** True when an API response carries the drain header. */
|
|
22
|
+
export function isApiDrainingResponse(response: { headers: Headers }): boolean {
|
|
23
|
+
return response.headers.get(API_DRAINING_HEADER) === "1";
|
|
24
|
+
}
|
package/src/utils/constants.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Shared constants used across worker- and server-side code.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { isEnvFlagEnabled } from "./env-flag";
|
|
6
|
+
|
|
5
7
|
/** Maximum profile-file length in JavaScript characters (not UTF-8 bytes). */
|
|
6
8
|
export const MAX_PROFILE_FILE_LENGTH = 256 * 1024;
|
|
7
9
|
|
|
@@ -106,20 +108,24 @@ export function getAgentFsDefaultDriveId(): string | undefined {
|
|
|
106
108
|
return raw || undefined;
|
|
107
109
|
}
|
|
108
110
|
|
|
109
|
-
/**
|
|
110
|
-
|
|
111
|
-
* info — `path` plus a matched `orgId`/`driveId` pair. When a row supplies
|
|
112
|
-
* neither ID, the pair may come from env-var defaults. A partial row never
|
|
113
|
-
* mixes its ID with a default; callers fall back to the raw
|
|
114
|
-
* `agent-fs:<path>` display instead.
|
|
115
|
-
*
|
|
116
|
-
* Shape: ${liveHost}/file/~/<orgId>/<driveId>/<normalized-path>
|
|
117
|
-
*/
|
|
118
|
-
export function buildAgentFsLiveUrl(opts: {
|
|
111
|
+
/** An agent-fs file for a link: its path plus an optional org/drive pair. */
|
|
112
|
+
export interface AgentFsFileRef {
|
|
119
113
|
path?: string | null;
|
|
120
114
|
orgId?: string | null;
|
|
121
115
|
driveId?: string | null;
|
|
122
|
-
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** A "." or ".." path segment, raw or encoded (`%2e`). */
|
|
119
|
+
const DOT_SEGMENT_RE = /^(?:\.|%2e){1,2}$/i;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* `<orgId>/<driveId>/<encoded-path>` for an agent-fs file link, when we have
|
|
123
|
+
* enough info: `path` plus a matched `orgId`/`driveId` pair. When a row
|
|
124
|
+
* supplies neither ID, the pair may come from env-var defaults. A partial row
|
|
125
|
+
* never mixes its ID with a default. A "." or ".." segment returns null: the
|
|
126
|
+
* browser would resolve it to a path outside the drive.
|
|
127
|
+
*/
|
|
128
|
+
export function agentFsFileRoute(opts: AgentFsFileRef): string | null {
|
|
123
129
|
const path = opts.path?.trim();
|
|
124
130
|
if (!path) return null;
|
|
125
131
|
const rowOrgId = opts.orgId?.trim();
|
|
@@ -128,13 +134,48 @@ export function buildAgentFsLiveUrl(opts: {
|
|
|
128
134
|
const orgId = hasRowId ? rowOrgId : getAgentFsDefaultOrgId();
|
|
129
135
|
const driveId = hasRowId ? rowDriveId : getAgentFsDefaultDriveId();
|
|
130
136
|
if (!orgId || !driveId) return null;
|
|
131
|
-
const
|
|
132
|
-
|
|
137
|
+
const segments = path.replace(/^\/+/, "").split("/");
|
|
138
|
+
if (segments.some((segment) => DOT_SEGMENT_RE.test(segment))) return null;
|
|
133
139
|
// Never double-encode an already-encoded segment: preserve existing %HH
|
|
134
140
|
// escapes byte-for-byte, including in segments that also contain raw text.
|
|
135
|
-
const encodedPath =
|
|
136
|
-
.split("/")
|
|
141
|
+
const encodedPath = segments
|
|
137
142
|
.map((segment) => encodeURIComponent(segment).replace(/%25([0-9a-f]{2})/gi, "%$1"))
|
|
138
143
|
.join("/");
|
|
139
|
-
return `${
|
|
144
|
+
return `${orgId}/${driveId}/${encodedPath}`;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Resolve a public agent-fs live URL for an attachment (see
|
|
149
|
+
* {@link agentFsFileRoute} for the id, dot-segment, and encoding rules). Null
|
|
150
|
+
* when that route is null; callers fall back to the raw `agent-fs:<path>`
|
|
151
|
+
* display instead.
|
|
152
|
+
*
|
|
153
|
+
* Shape: ${liveHost}/file/~/<orgId>/<driveId>/<normalized-path>
|
|
154
|
+
*/
|
|
155
|
+
export function buildAgentFsLiveUrl(opts: AgentFsFileRef): string | null {
|
|
156
|
+
const route = agentFsFileRoute(opts);
|
|
157
|
+
return route ? `${getAgentFsLiveUrl()}/file/~/${route}` : null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Comb (the agent-fs review space in the dashboard) is on: `COMB_ENABLED` plus
|
|
162
|
+
* an agent-fs API URL. `getCombConfig()` (`src/comb/config.ts`) reports it.
|
|
163
|
+
*/
|
|
164
|
+
export function isCombEnabled(): boolean {
|
|
165
|
+
const apiUrl = process.env.AGENT_FS_API_URL?.trim().replace(/\/+$/, "");
|
|
166
|
+
return isEnvFlagEnabled("COMB_ENABLED", false) && Boolean(apiUrl);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The dashboard (Comb) URL for an agent-fs file, same id and encoding rules as
|
|
171
|
+
* {@link buildAgentFsLiveUrl}. Null unless Comb is on AND an explicit
|
|
172
|
+
* `APP_URL` / `DASHBOARD_URL` is set: the hosted default dashboard cannot open
|
|
173
|
+
* a self-hosted swarm's files.
|
|
174
|
+
*
|
|
175
|
+
* Shape: ${appUrl}/file/~/<orgId>/<driveId>/<normalized-path>
|
|
176
|
+
*/
|
|
177
|
+
export function buildCombFileUrl(opts: AgentFsFileRef): string | null {
|
|
178
|
+
if (!isCombEnabled() || getConfiguredAppUrls().length === 0) return null;
|
|
179
|
+
const route = agentFsFileRoute(opts);
|
|
180
|
+
return route ? `${getAppUrl()}/file/~/${route}` : null;
|
|
140
181
|
}
|
|
@@ -146,10 +146,40 @@ describe("validateClaudeCredentials", () => {
|
|
|
146
146
|
|
|
147
147
|
it("throws when neither credential is set", () => {
|
|
148
148
|
expect(() => validateClaudeCredentials({})).toThrow(
|
|
149
|
-
"No Claude credentials found. Set CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY
|
|
149
|
+
"No Claude credentials found. Set CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY, or route",
|
|
150
150
|
);
|
|
151
151
|
});
|
|
152
152
|
|
|
153
|
+
it("accepts gateway and cloud routes without an Anthropic credential", () => {
|
|
154
|
+
expect(
|
|
155
|
+
validateClaudeCredentials({
|
|
156
|
+
ANTHROPIC_BASE_URL: "http://litellm:4000",
|
|
157
|
+
ANTHROPIC_AUTH_TOKEN: "sk-litellm",
|
|
158
|
+
}),
|
|
159
|
+
).toBe("gateway");
|
|
160
|
+
expect(
|
|
161
|
+
validateClaudeCredentials({
|
|
162
|
+
CLAUDE_CODE_USE_FOUNDRY: "1",
|
|
163
|
+
ANTHROPIC_FOUNDRY_RESOURCE: "res",
|
|
164
|
+
ANTHROPIC_FOUNDRY_API_KEY: "az",
|
|
165
|
+
}),
|
|
166
|
+
).toBe("foundry");
|
|
167
|
+
expect(
|
|
168
|
+
validateClaudeCredentials({ CLAUDE_CODE_USE_BEDROCK: "1", AWS_REGION: "us-east-1" }),
|
|
169
|
+
).toBe("bedrock");
|
|
170
|
+
expect(
|
|
171
|
+
validateClaudeCredentials({
|
|
172
|
+
CLAUDE_CODE_USE_VERTEX: "1",
|
|
173
|
+
CLOUD_ML_REGION: "us-east5",
|
|
174
|
+
ANTHROPIC_VERTEX_PROJECT_ID: "p",
|
|
175
|
+
}),
|
|
176
|
+
).toBe("vertex");
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("names a route's missing env var", () => {
|
|
180
|
+
expect(() => validateClaudeCredentials({ CLAUDE_CODE_USE_BEDROCK: "1" })).toThrow("AWS_REGION");
|
|
181
|
+
});
|
|
182
|
+
|
|
153
183
|
it("treats empty string as missing", () => {
|
|
154
184
|
const env = { CLAUDE_CODE_OAUTH_TOKEN: "", ANTHROPIC_API_KEY: "" };
|
|
155
185
|
expect(() => validateClaudeCredentials(env)).toThrow("No Claude credentials found");
|
package/src/utils/credentials.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
+
import { deriveDefaultRoute, routeCredentialStatus } from "@desplega/model-routing";
|
|
2
3
|
import { type ModelFamily, modelFamilyOf, windowForModelFamily } from "./model-rate-limit-windows";
|
|
3
4
|
|
|
4
5
|
/** Env vars that may contain comma-separated credential pools */
|
|
@@ -271,17 +272,27 @@ export function selectRandomCredential(value: string): {
|
|
|
271
272
|
return { selected: result.selected, index: result.index, total: result.total };
|
|
272
273
|
}
|
|
273
274
|
|
|
275
|
+
export const CLAUDE_CREDENTIALS_HINT =
|
|
276
|
+
"Set CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY, or route Claude Code through a gateway (ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY), Microsoft Foundry (CLAUDE_CODE_USE_FOUNDRY), Amazon Bedrock (CLAUDE_CODE_USE_BEDROCK), or Google Vertex AI (CLAUDE_CODE_USE_VERTEX).";
|
|
277
|
+
|
|
278
|
+
const CLAUDE_CREDENTIAL_TYPE_BY_PROVIDER: Record<string, string> = {
|
|
279
|
+
"claude-subscription": "oauth",
|
|
280
|
+
anthropic: "api_key",
|
|
281
|
+
"anthropic-gateway": "gateway",
|
|
282
|
+
};
|
|
283
|
+
|
|
274
284
|
/**
|
|
275
|
-
* Validate that
|
|
276
|
-
*
|
|
277
|
-
* Returns the credential type found,
|
|
285
|
+
* Validate that the claude harness has a usable default route (see
|
|
286
|
+
* `deriveDefaultRoute` in @desplega/model-routing for the precedence).
|
|
287
|
+
* Returns the credential type found ("oauth", "api_key", "gateway", "foundry",
|
|
288
|
+
* "bedrock", "vertex"), or throws with what is missing.
|
|
278
289
|
*/
|
|
279
|
-
export function validateClaudeCredentials(
|
|
280
|
-
|
|
281
|
-
)
|
|
282
|
-
|
|
283
|
-
if (
|
|
284
|
-
|
|
290
|
+
export function validateClaudeCredentials(env: Record<string, string | undefined>): string {
|
|
291
|
+
const route = deriveDefaultRoute("claude", env);
|
|
292
|
+
if (!route) throw new Error(`No Claude credentials found. ${CLAUDE_CREDENTIALS_HINT}`);
|
|
293
|
+
const status = routeCredentialStatus(route, env);
|
|
294
|
+
if (!status.ready) throw new Error(`No Claude credentials found. ${status.hint}`);
|
|
295
|
+
return CLAUDE_CREDENTIAL_TYPE_BY_PROVIDER[route.provider] ?? route.provider;
|
|
285
296
|
}
|
|
286
297
|
|
|
287
298
|
/**
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh `status.step_end.usage` normalization, shared by the worker adapter
|
|
3
|
+
* (session cost row) and the dashboard log parser (turn summary row) so both
|
|
4
|
+
* surfaces count the same tokens. Pure, no imports: `apps/ui` bundles it.
|
|
5
|
+
*
|
|
6
|
+
* dsh counts are disjoint and `totalTokens` is always their sum:
|
|
7
|
+
* `inputTokens + outputTokens + cacheReadTokens + cacheWriteTokens` on both
|
|
8
|
+
* routes (pi-ai `parseChunkUsage` for OpenRouter, `dsh-llm-deepseek` for the
|
|
9
|
+
* direct API). Reasoning is folded into `outputTokens`, not added on top.
|
|
10
|
+
*
|
|
11
|
+
* The cache buckets can go missing while `totalTokens` keeps them: dsh omits a
|
|
12
|
+
* zero cache field, and when a step is retried `dsh-headless` sums an optional
|
|
13
|
+
* bucket only if every attempt reported it. A failed attempt reports zeroed
|
|
14
|
+
* usage, so the step's `cacheReadTokens` disappears and only `totalTokens`
|
|
15
|
+
* still carries it. The missing remainder is derived from `totalTokens`.
|
|
16
|
+
*/
|
|
17
|
+
export interface DshStepUsage {
|
|
18
|
+
/** Prompt tokens not served from cache. */
|
|
19
|
+
input: number;
|
|
20
|
+
output: number;
|
|
21
|
+
cacheRead: number;
|
|
22
|
+
cacheWrite: number;
|
|
23
|
+
/** Subset of `output`; only some routes report it. */
|
|
24
|
+
reasoning: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function count(value: unknown): number {
|
|
28
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Normalizes one `step_end.usage` object; `null` when the step reported none. */
|
|
32
|
+
export function normalizeDshStepUsage(usage: unknown): DshStepUsage | null {
|
|
33
|
+
if (!usage || typeof usage !== "object") return null;
|
|
34
|
+
const u = usage as Record<string, unknown>;
|
|
35
|
+
const input = count(u.inputTokens);
|
|
36
|
+
const output = count(u.outputTokens);
|
|
37
|
+
const cacheWrite = count(u.cacheWriteTokens);
|
|
38
|
+
const cacheRead =
|
|
39
|
+
typeof u.cacheReadTokens === "number"
|
|
40
|
+
? count(u.cacheReadTokens)
|
|
41
|
+
: Math.max(0, count(u.totalTokens) - input - output - cacheWrite);
|
|
42
|
+
return { input, output, cacheRead, cacheWrite, reasoning: count(u.reasoningTokens) };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function addDshStepUsage(acc: DshStepUsage | undefined, step: DshStepUsage): DshStepUsage {
|
|
46
|
+
return {
|
|
47
|
+
input: (acc?.input ?? 0) + step.input,
|
|
48
|
+
output: (acc?.output ?? 0) + step.output,
|
|
49
|
+
cacheRead: (acc?.cacheRead ?? 0) + step.cacheRead,
|
|
50
|
+
cacheWrite: (acc?.cacheWrite ?? 0) + step.cacheWrite,
|
|
51
|
+
reasoning: (acc?.reasoning ?? 0) + step.reasoning,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The worker's harness CLI version (`claude --version`
|
|
2
|
+
* The worker's harness CLI version (`claude --version`, `codex --version`, or `pi --version`),
|
|
3
3
|
* reported on register and used to key harness_model_support rows. Worker-safe
|
|
4
4
|
* (no DB). Probed once per process; null when the CLI is missing or silent.
|
|
5
|
+
* An unprobed harness returns a blank string to clear stale registration data.
|
|
5
6
|
*/
|
|
6
7
|
import { isUnknownModelError } from "./harness-model-error";
|
|
7
8
|
import { scrubSecrets } from "./secret-scrubber";
|
|
8
9
|
|
|
9
|
-
const CLI_BINARY: Record<string, string> = { claude: "claude", codex: "codex" };
|
|
10
|
+
const CLI_BINARY: Record<string, string> = { claude: "claude", codex: "codex", pi: "pi" };
|
|
10
11
|
const PROBE_TIMEOUT_MS = 10_000;
|
|
11
12
|
const VERSION_RE = /\d+\.\d+\.\d+(?:[-+][\w.]+)?/;
|
|
12
13
|
|
|
@@ -18,7 +19,7 @@ export function parseCliVersion(output: string): string | null {
|
|
|
18
19
|
|
|
19
20
|
export function probeHarnessCliVersion(harness: string): Promise<string | null> {
|
|
20
21
|
const binary = CLI_BINARY[harness];
|
|
21
|
-
if (!binary) return Promise.resolve(
|
|
22
|
+
if (!binary) return Promise.resolve("");
|
|
22
23
|
let pending = probed.get(harness);
|
|
23
24
|
if (!pending) {
|
|
24
25
|
pending = (async () => {
|
|
@@ -66,7 +67,8 @@ export async function reportHarnessModelOutcome(opts: {
|
|
|
66
67
|
failureReason?: string;
|
|
67
68
|
fetchImpl?: typeof fetch;
|
|
68
69
|
}): Promise<void> {
|
|
69
|
-
|
|
70
|
+
// Only harnesses with verified unknown-model error classification report outcomes.
|
|
71
|
+
if (!opts.model || (opts.harness !== "claude" && opts.harness !== "codex")) return;
|
|
70
72
|
const cliVersion = await cachedHarnessCliVersion(opts.harness);
|
|
71
73
|
if (!cliVersion) return;
|
|
72
74
|
const status =
|