@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
|
@@ -61,6 +61,40 @@ describe("resolveLinks", () => {
|
|
|
61
61
|
expect(fsLinks[0]!.resolver).toBe("agent-fs-path");
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
+
test("a dashboard (Comb) file link resolves to the same target as the live URL", () => {
|
|
65
|
+
const route =
|
|
66
|
+
"/file/~/648a5f3c-35c8-4f11-8673-b89de52cd6bd/2faf73ba-4eee-4472-8b3b-359c4ed6bfbb/thoughts/final%20plan.md";
|
|
67
|
+
const savedAppUrl = process.env.APP_URL;
|
|
68
|
+
const savedDashboardUrl = process.env.DASHBOARD_URL;
|
|
69
|
+
process.env.APP_URL = "https://swarm.example.com/dash/";
|
|
70
|
+
delete process.env.DASHBOARD_URL;
|
|
71
|
+
try {
|
|
72
|
+
const fsTargets = (content: string) =>
|
|
73
|
+
resolveLinks(content)
|
|
74
|
+
.filter((l) => l.linkType === "agent-fs-file")
|
|
75
|
+
.map((l) => ({ targetId: l.targetId, metadata: l.metadata }));
|
|
76
|
+
const live = fsTargets(`Plan at https://live.agent-fs.dev${route}`);
|
|
77
|
+
expect(live).toHaveLength(1);
|
|
78
|
+
expect(fsTargets(`Plan at https://swarm.example.com/dash${route}`)).toEqual(live);
|
|
79
|
+
expect(fsTargets(`Plan at http://localhost:5274${route}`)).toEqual(live);
|
|
80
|
+
// Another host, or the app host without its path prefix, is not a file link.
|
|
81
|
+
expect(fsTargets(`Plan at https://other.example.com${route}`)).toEqual([]);
|
|
82
|
+
expect(fsTargets(`Plan at https://swarm.example.com${route}`)).toEqual([]);
|
|
83
|
+
// A known host must start the host name.
|
|
84
|
+
expect(fsTargets(`Plan at https://evil-swarm.example.com/dash${route}`)).toEqual([]);
|
|
85
|
+
expect(fsTargets(`Plan at https://notlocalhost:9${route}`)).toEqual([]);
|
|
86
|
+
expect(fsTargets(`Plan at https://myagent-fs${route}`)).toEqual([]);
|
|
87
|
+
// Hosts are case-insensitive.
|
|
88
|
+
expect(fsTargets(`Plan at https://SWARM.Example.com/dash${route}`)).toEqual(live);
|
|
89
|
+
expect(fsTargets(`Plan at https://LIVE.AGENT-FS.DEV${route}`)).toEqual(live);
|
|
90
|
+
} finally {
|
|
91
|
+
if (savedAppUrl === undefined) delete process.env.APP_URL;
|
|
92
|
+
else process.env.APP_URL = savedAppUrl;
|
|
93
|
+
if (savedDashboardUrl === undefined) delete process.env.DASHBOARD_URL;
|
|
94
|
+
else process.env.DASHBOARD_URL = savedDashboardUrl;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
64
98
|
test("extracts agent-ui page links", () => {
|
|
65
99
|
const links = resolveLinks(
|
|
66
100
|
"See app.agent-swarm.dev/pages/abc12345-1234-1234-1234-123456789abc",
|
|
@@ -188,6 +188,72 @@ describe("POST /api/memory/rate", () => {
|
|
|
188
188
|
expect((await readPosterior(m.id)).alpha).toBeCloseTo(2, 5);
|
|
189
189
|
});
|
|
190
190
|
|
|
191
|
+
async function readModels(
|
|
192
|
+
memoryId: string,
|
|
193
|
+
): Promise<Array<{ source: string; model: string | null }>> {
|
|
194
|
+
return getDbClient().query<{ source: string; model: string | null }>(
|
|
195
|
+
"SELECT source, model FROM memory_rating WHERE memoryId = ? ORDER BY source",
|
|
196
|
+
[memoryId],
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
test("source=llm with model → model is stored on the memory_rating row", async () => {
|
|
201
|
+
const m = await makeMemory("rate-llm-model");
|
|
202
|
+
const r = await api("POST", "/api/memory/rate", {
|
|
203
|
+
agentId: agentA,
|
|
204
|
+
body: {
|
|
205
|
+
events: [
|
|
206
|
+
{
|
|
207
|
+
memoryId: m.id,
|
|
208
|
+
signal: 0.5,
|
|
209
|
+
weight: 0.8,
|
|
210
|
+
source: "llm",
|
|
211
|
+
taskId: taskA,
|
|
212
|
+
model: "openrouter/deepseek/deepseek-v4.1-flash",
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
expect(r.status).toBe(200);
|
|
218
|
+
expect(await readModels(m.id)).toEqual([
|
|
219
|
+
{ source: "llm", model: "openrouter/deepseek/deepseek-v4.1-flash" },
|
|
220
|
+
]);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
test("source=explicit-self ignores a supplied model → model is NULL", async () => {
|
|
224
|
+
const m = await makeMemory("rate-explicit-model");
|
|
225
|
+
await insertRetrieval(taskA, agentA, m.id);
|
|
226
|
+
const r = await api("POST", "/api/memory/rate", {
|
|
227
|
+
agentId: agentA,
|
|
228
|
+
body: {
|
|
229
|
+
events: [
|
|
230
|
+
{
|
|
231
|
+
memoryId: m.id,
|
|
232
|
+
signal: 1,
|
|
233
|
+
weight: 1,
|
|
234
|
+
source: "explicit-self",
|
|
235
|
+
taskId: taskA,
|
|
236
|
+
model: "openrouter/deepseek/deepseek-v4.1-flash",
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
expect(r.status).toBe(200);
|
|
242
|
+
expect(await readModels(m.id)).toEqual([{ source: "explicit-self", model: null }]);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test("empty or over-long model → 400", async () => {
|
|
246
|
+
const m = await makeMemory("rate-bad-model");
|
|
247
|
+
for (const model of ["", " ", "x".repeat(201)]) {
|
|
248
|
+
const r = await api("POST", "/api/memory/rate", {
|
|
249
|
+
agentId: agentA,
|
|
250
|
+
body: { events: [{ memoryId: m.id, signal: 1, weight: 1, source: "llm", model }] },
|
|
251
|
+
});
|
|
252
|
+
expect(r.status).toBe(400);
|
|
253
|
+
}
|
|
254
|
+
expect(await readModels(m.id)).toEqual([]);
|
|
255
|
+
});
|
|
256
|
+
|
|
191
257
|
test("source=explicit-self with no retrieval row → 400 (R6 spam guard)", async () => {
|
|
192
258
|
const m = await makeMemory("explicit-no-retr");
|
|
193
259
|
const r = await api("POST", "/api/memory/rate", {
|
|
@@ -33,7 +33,8 @@ function makeOpenRouterResponse(content: string, init: ResponseInit = { status:
|
|
|
33
33
|
describe("getMemoryRaterModel", () => {
|
|
34
34
|
test("returns the default when MEMORY_RATER_MODEL is unset", () => {
|
|
35
35
|
expect(getMemoryRaterModel({})).toBe(DEFAULT_MEMORY_RATER_MODEL);
|
|
36
|
-
|
|
36
|
+
// The OpenRouter slug of the pinned rater model: one source of truth.
|
|
37
|
+
expect(DEFAULT_MEMORY_RATER_MODEL).toBe("deepseek/deepseek-v4.1-flash");
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
test("returns the env override when set", () => {
|
|
@@ -177,6 +177,79 @@ describe("buildRatingsFromLlm", () => {
|
|
|
177
177
|
const events = buildRatingsFromLlm([], retrievals);
|
|
178
178
|
expect(events).toEqual([]);
|
|
179
179
|
});
|
|
180
|
+
|
|
181
|
+
test("empty or whitespace-only referencesSource keeps the rating and writes no edge source", () => {
|
|
182
|
+
for (const blank of ["", " ", " ", "\t \n", "\u00a0"]) {
|
|
183
|
+
const events = buildRatingsFromLlm(
|
|
184
|
+
[{ id: "mem-A", score: 0.9, reasoning: "useful", referencesSource: blank }],
|
|
185
|
+
retrievals,
|
|
186
|
+
);
|
|
187
|
+
expect(events).toHaveLength(1);
|
|
188
|
+
expect(events[0]!.memoryId).toBe("mem-A");
|
|
189
|
+
expect(events[0]!.signal).toBeCloseTo(0.8, 6);
|
|
190
|
+
expect("referencesSource" in events[0]!).toBe(false);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test("non-blank referencesSource passes through exactly as before", () => {
|
|
195
|
+
const events = buildRatingsFromLlm(
|
|
196
|
+
[
|
|
197
|
+
{ id: "mem-A", score: 0.9, reasoning: "x", referencesSource: "github:foo/bar#1" },
|
|
198
|
+
{ id: "mem-B", score: 0.9, reasoning: "x", referencesSource: " padded " },
|
|
199
|
+
{ id: "mem-C", score: 0.9, reasoning: "x", referencesSource: "a\u0001b" },
|
|
200
|
+
],
|
|
201
|
+
retrievals,
|
|
202
|
+
);
|
|
203
|
+
expect(events.map((e) => e.referencesSource)).toEqual(["github:foo/bar#1", " padded ", "ab"]);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test("stamps the judge model on every event when provided", () => {
|
|
207
|
+
const events = buildRatingsFromLlm(
|
|
208
|
+
[
|
|
209
|
+
{ id: "mem-A", score: 0.9, reasoning: "x" },
|
|
210
|
+
{ id: "mem-B", score: 0.1, reasoning: "y" },
|
|
211
|
+
],
|
|
212
|
+
retrievals,
|
|
213
|
+
"openrouter/deepseek/deepseek-v4.1-flash",
|
|
214
|
+
);
|
|
215
|
+
expect(events.map((e) => e.model)).toEqual([
|
|
216
|
+
"openrouter/deepseek/deepseek-v4.1-flash",
|
|
217
|
+
"openrouter/deepseek/deepseek-v4.1-flash",
|
|
218
|
+
]);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test("omits model entirely when unknown", () => {
|
|
222
|
+
for (const model of [undefined, ""]) {
|
|
223
|
+
const events = buildRatingsFromLlm(
|
|
224
|
+
[{ id: "mem-A", score: 0.9, reasoning: "x" }],
|
|
225
|
+
retrievals,
|
|
226
|
+
model,
|
|
227
|
+
);
|
|
228
|
+
expect("model" in events[0]!).toBe(false);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
describe("postRatings model forwarding", () => {
|
|
234
|
+
test("sends model in the POST body only when the event carries one", async () => {
|
|
235
|
+
let sent: { events: Array<Record<string, unknown>> } | null = null;
|
|
236
|
+
const fetchImpl = (async (_url: string, init?: RequestInit) => {
|
|
237
|
+
sent = JSON.parse(String(init?.body));
|
|
238
|
+
return new Response(JSON.stringify({ applied: 2, rejected: [] }), { status: 200 });
|
|
239
|
+
}) as unknown as typeof fetch;
|
|
240
|
+
await postRatings({
|
|
241
|
+
apiUrl: "http://localhost:3013",
|
|
242
|
+
apiKey: "k",
|
|
243
|
+
agentId: "agent-1",
|
|
244
|
+
events: [
|
|
245
|
+
{ memoryId: "m1", signal: 1, weight: 0.8, source: "llm", model: "p/m" },
|
|
246
|
+
{ memoryId: "m2", signal: 1, weight: 0.8, source: "llm" },
|
|
247
|
+
],
|
|
248
|
+
fetchImpl,
|
|
249
|
+
});
|
|
250
|
+
expect(sent!.events[0]).toMatchObject({ memoryId: "m1", model: "p/m" });
|
|
251
|
+
expect("model" in sent!.events[1]!).toBe(false);
|
|
252
|
+
});
|
|
180
253
|
});
|
|
181
254
|
|
|
182
255
|
describe("buildSummaryWithRatingsPrompt", () => {
|
|
@@ -75,6 +75,37 @@ describe("applyRating", () => {
|
|
|
75
75
|
return row?.n ?? 0;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
test("model is recorded for llm ratings and NULL for every other source", async () => {
|
|
79
|
+
const m = await makeMemory("model-provenance");
|
|
80
|
+
await applyRating(
|
|
81
|
+
[
|
|
82
|
+
{
|
|
83
|
+
memoryId: m.id,
|
|
84
|
+
signal: 1,
|
|
85
|
+
weight: 0.8,
|
|
86
|
+
source: "llm",
|
|
87
|
+
model: "openrouter/deepseek/deepseek-v4.1-flash",
|
|
88
|
+
},
|
|
89
|
+
// A model on a non-llm source is dropped: nothing judged it.
|
|
90
|
+
{ memoryId: m.id, signal: 1, weight: 0.5, source: "test", model: "should-not-persist" },
|
|
91
|
+
{ memoryId: m.id, signal: 1, weight: 0.5, source: "llm" },
|
|
92
|
+
],
|
|
93
|
+
{ taskId },
|
|
94
|
+
);
|
|
95
|
+
const rows = await getDbClient().query<{
|
|
96
|
+
source: string;
|
|
97
|
+
weight: number;
|
|
98
|
+
model: string | null;
|
|
99
|
+
}>("SELECT source, weight, model FROM memory_rating WHERE memoryId = ? ORDER BY weight", [
|
|
100
|
+
m.id,
|
|
101
|
+
]);
|
|
102
|
+
expect(rows).toEqual([
|
|
103
|
+
{ source: "test", weight: 0.5, model: null },
|
|
104
|
+
{ source: "llm", weight: 0.5, model: null },
|
|
105
|
+
{ source: "llm", weight: 0.8, model: "openrouter/deepseek/deepseek-v4.1-flash" },
|
|
106
|
+
]);
|
|
107
|
+
});
|
|
108
|
+
|
|
78
109
|
test("signal=+1, weight=1 → alpha += 1, beta += 0; audit row written", async () => {
|
|
79
110
|
const m = await makeMemory("positive");
|
|
80
111
|
const events: RatingEvent[] = [{ memoryId: m.id, signal: 1, weight: 1, source: "test" }];
|
|
@@ -186,6 +186,46 @@ describe("computeScore", () => {
|
|
|
186
186
|
});
|
|
187
187
|
});
|
|
188
188
|
|
|
189
|
+
describe("computeScore path weight", () => {
|
|
190
|
+
const now = new Date("2026-04-12T12:00:00Z");
|
|
191
|
+
const base = { similarity: 0.8, createdAt: now.toISOString(), accessedAt: now.toISOString() };
|
|
192
|
+
const unkeyed = computeScore(makeCandidate({ ...base, key: null }), now);
|
|
193
|
+
|
|
194
|
+
// Multiplier on the score of an otherwise identical candidate with no key.
|
|
195
|
+
test.each([
|
|
196
|
+
["/longterm/company-story", [], 1.4],
|
|
197
|
+
["/longterm/entities/people/taras", [], 1.3],
|
|
198
|
+
["/longterm/facts/memory/slug", [], 1.2],
|
|
199
|
+
["/longterm/decisions/2026-10-01-pick-x", [], 1.1],
|
|
200
|
+
["/longterm/timeline/daily/2026-10-01", [], 0.8],
|
|
201
|
+
["/longterm/decisions/2026-10-01-pick-x", ["superseded"], 0.3],
|
|
202
|
+
// Only a decision is demoted by the tag; other roots keep their own weight.
|
|
203
|
+
["/longterm/facts/memory/slug", ["superseded"], 1.2],
|
|
204
|
+
// Inbox material: keys outside /longterm score as before, even when the
|
|
205
|
+
// path looks like a taxonomy root.
|
|
206
|
+
["swarm/manual/0b6c6d1e", [], 1.0],
|
|
207
|
+
["/workspace/shared/memory/lead/note.md", [], 1.0],
|
|
208
|
+
["/facts/memory/slug", [], 1.0],
|
|
209
|
+
// A root-lookalike is not under the root.
|
|
210
|
+
["/longterm/entities-archive/old", [], 1.0],
|
|
211
|
+
] as const)("key %s with tags %j scales the score by %p", (key, tags, multiplier) => {
|
|
212
|
+
const score = computeScore(makeCandidate({ ...base, key, tags: [...tags] }), now);
|
|
213
|
+
|
|
214
|
+
expect(score / unkeyed).toBeCloseTo(multiplier, 6);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test("a path weight lifts a lower-similarity doc over an unkeyed one", () => {
|
|
218
|
+
const keyed = makeCandidate({
|
|
219
|
+
...base,
|
|
220
|
+
similarity: 0.6,
|
|
221
|
+
key: "/longterm/entities/people/taras",
|
|
222
|
+
});
|
|
223
|
+
const legacy = makeCandidate({ ...base, similarity: 0.7, key: "swarm/manual/abc" });
|
|
224
|
+
|
|
225
|
+
expect(rerank([legacy, keyed], { limit: 2, now })[0]?.id).toBe(keyed.id);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
189
229
|
describe("rerank", () => {
|
|
190
230
|
const now = new Date("2026-04-12T12:00:00Z");
|
|
191
231
|
|
|
@@ -613,6 +613,114 @@ describe("onboarding memory probe", () => {
|
|
|
613
613
|
});
|
|
614
614
|
});
|
|
615
615
|
|
|
616
|
+
test("splits a 404 into a missing path and a missing model or deployment", async () => {
|
|
617
|
+
const cases = [
|
|
618
|
+
{
|
|
619
|
+
// Azure without `/openai/v1`.
|
|
620
|
+
body: { error: { code: "404", message: "Resource not found" } },
|
|
621
|
+
errorClass: "endpoint",
|
|
622
|
+
error: "The endpoint path was not found (404). Check the base URL.",
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
// A proxy or server page with no JSON body.
|
|
626
|
+
body: "404 page not found",
|
|
627
|
+
errorClass: "endpoint",
|
|
628
|
+
error: "The endpoint path was not found (404). Check the base URL.",
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
body: {
|
|
632
|
+
error: {
|
|
633
|
+
message: "The model `nope` does not exist or you do not have access to it.",
|
|
634
|
+
type: "invalid_request_error",
|
|
635
|
+
code: "model_not_found",
|
|
636
|
+
},
|
|
637
|
+
},
|
|
638
|
+
errorClass: "model",
|
|
639
|
+
error: "The endpoint could not find the embedding model or deployment (404).",
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
body: {
|
|
643
|
+
error: {
|
|
644
|
+
code: "DeploymentNotFound",
|
|
645
|
+
message: "The API deployment for this resource does not exist.",
|
|
646
|
+
},
|
|
647
|
+
},
|
|
648
|
+
errorClass: "model",
|
|
649
|
+
error: "The endpoint could not find the embedding model or deployment (404).",
|
|
650
|
+
},
|
|
651
|
+
] as const;
|
|
652
|
+
|
|
653
|
+
for (const testCase of cases) {
|
|
654
|
+
const fake = startEmbeddingServer(() =>
|
|
655
|
+
typeof testCase.body === "string"
|
|
656
|
+
? new Response(testCase.body, { status: 404 })
|
|
657
|
+
: Response.json(testCase.body, { status: 404 }),
|
|
658
|
+
);
|
|
659
|
+
try {
|
|
660
|
+
const response = await request("/api/onboarding/memory", {
|
|
661
|
+
method: "POST",
|
|
662
|
+
body: {
|
|
663
|
+
preset: "azure",
|
|
664
|
+
baseUrl: fake.baseUrl,
|
|
665
|
+
model: "my-embedding-deployment",
|
|
666
|
+
apiKey: "azure-resource-key",
|
|
667
|
+
},
|
|
668
|
+
});
|
|
669
|
+
expect(response.status).toBe(200);
|
|
670
|
+
expect(await response.json()).toMatchObject({
|
|
671
|
+
ok: false,
|
|
672
|
+
errorClass: testCase.errorClass,
|
|
673
|
+
error: testCase.error,
|
|
674
|
+
});
|
|
675
|
+
} finally {
|
|
676
|
+
fake.server.stop(true);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
// A failed step keeps its first error class.
|
|
680
|
+
expect((await getState()).steps.memory).toMatchObject({
|
|
681
|
+
status: "failed",
|
|
682
|
+
errorClass: "endpoint",
|
|
683
|
+
});
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
test("the azure preset saves its base URL and deployment name", async () => {
|
|
687
|
+
let path = "";
|
|
688
|
+
let model = "";
|
|
689
|
+
const fake = Bun.serve({
|
|
690
|
+
hostname: "127.0.0.1",
|
|
691
|
+
port: 0,
|
|
692
|
+
async fetch(req) {
|
|
693
|
+
path = new URL(req.url).pathname;
|
|
694
|
+
model = ((await req.json()) as { model: string }).model;
|
|
695
|
+
return embeddingResponse(512);
|
|
696
|
+
},
|
|
697
|
+
});
|
|
698
|
+
try {
|
|
699
|
+
const baseUrl = `http://127.0.0.1:${fake.port}/openai/v1`;
|
|
700
|
+
const response = await request("/api/onboarding/memory", {
|
|
701
|
+
method: "POST",
|
|
702
|
+
body: {
|
|
703
|
+
preset: "azure",
|
|
704
|
+
baseUrl,
|
|
705
|
+
model: "my-embedding-deployment",
|
|
706
|
+
apiKey: "azure-resource-key",
|
|
707
|
+
},
|
|
708
|
+
});
|
|
709
|
+
expect(await response.json()).toMatchObject({ ok: true, dimensions: 512 });
|
|
710
|
+
expect(path).toBe("/openai/v1/embeddings");
|
|
711
|
+
expect(model).toBe("my-embedding-deployment");
|
|
712
|
+
const configs = await getSwarmConfigs({ scope: "global" });
|
|
713
|
+
const saved = Object.fromEntries(configs.map((config) => [config.key, config.value]));
|
|
714
|
+
expect(saved).toMatchObject({
|
|
715
|
+
EMBEDDING_API_BASE_URL: baseUrl,
|
|
716
|
+
EMBEDDING_MODEL: "my-embedding-deployment",
|
|
717
|
+
});
|
|
718
|
+
expect((await getState()).steps.memory).toMatchObject({ status: "done", method: "azure" });
|
|
719
|
+
} finally {
|
|
720
|
+
fake.stop(true);
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
|
|
616
724
|
test("a wrong dimension keeps memory done after a successful probe", async () => {
|
|
617
725
|
let dimensions = 512;
|
|
618
726
|
const fake = startEmbeddingServer(() => embeddingResponse(dimensions));
|
|
@@ -1439,3 +1439,60 @@ describe("OpencodeAdapter: session create timeout", () => {
|
|
|
1439
1439
|
expect(closeServer).toHaveBeenCalledTimes(1);
|
|
1440
1440
|
});
|
|
1441
1441
|
});
|
|
1442
|
+
|
|
1443
|
+
describe("OpencodeAdapter: event stream ends without session.idle", () => {
|
|
1444
|
+
beforeEach(() => {
|
|
1445
|
+
mock.restore();
|
|
1446
|
+
});
|
|
1447
|
+
|
|
1448
|
+
afterEach(() => {
|
|
1449
|
+
Bun.$`rm -rf /tmp/opencode-task-stream-end.json /tmp/opencode-data-task-stream-end`
|
|
1450
|
+
.quiet()
|
|
1451
|
+
.nothrow();
|
|
1452
|
+
Bun.$`rm -rf /tmp/test/.opencode`.quiet().nothrow();
|
|
1453
|
+
});
|
|
1454
|
+
|
|
1455
|
+
test("settles the session as failed and caps SSE reconnects so a dead server cannot hold the slot", async () => {
|
|
1456
|
+
let subscribeArgs: { sseMaxRetryAttempts?: number } | undefined;
|
|
1457
|
+
const closeServer = mock(() => {});
|
|
1458
|
+
const fakeClient = {
|
|
1459
|
+
session: {
|
|
1460
|
+
create: async () => ({ data: { id: "sess-stream-end" }, error: undefined }),
|
|
1461
|
+
prompt: async () => ({ data: {}, error: undefined }),
|
|
1462
|
+
},
|
|
1463
|
+
event: {
|
|
1464
|
+
subscribe: async (args: { sseMaxRetryAttempts?: number }) => {
|
|
1465
|
+
subscribeArgs = args;
|
|
1466
|
+
// The server died: the stream closes with no session.idle.
|
|
1467
|
+
return { stream: makeStream([]) };
|
|
1468
|
+
},
|
|
1469
|
+
},
|
|
1470
|
+
};
|
|
1471
|
+
mock.module("@opencode-ai/sdk", () => ({
|
|
1472
|
+
createOpencode: async () => ({
|
|
1473
|
+
client: fakeClient,
|
|
1474
|
+
server: { url: "http://127.0.0.1:12345", close: closeServer },
|
|
1475
|
+
}),
|
|
1476
|
+
}));
|
|
1477
|
+
|
|
1478
|
+
const { OpencodeAdapter, OPENCODE_SSE_MAX_RETRY_ATTEMPTS } = await import(
|
|
1479
|
+
"../providers/opencode-adapter"
|
|
1480
|
+
);
|
|
1481
|
+
const session = await new OpencodeAdapter().createSession(
|
|
1482
|
+
testConfig({ taskId: "task-stream-end" }),
|
|
1483
|
+
);
|
|
1484
|
+
session.onEvent(() => {});
|
|
1485
|
+
|
|
1486
|
+
const settled = await Promise.race([
|
|
1487
|
+
session.waitForCompletion(),
|
|
1488
|
+
Bun.sleep(2_000).then(() => "pending" as const),
|
|
1489
|
+
]);
|
|
1490
|
+
expect(settled).not.toBe("pending");
|
|
1491
|
+
const result = settled as ProviderResult;
|
|
1492
|
+
expect(result.exitCode).toBe(1);
|
|
1493
|
+
expect(result.isError).toBe(true);
|
|
1494
|
+
expect(result.failureReason).toContain("runner exited without result");
|
|
1495
|
+
expect(subscribeArgs?.sseMaxRetryAttempts).toBe(OPENCODE_SSE_MAX_RETRY_ATTEMPTS);
|
|
1496
|
+
expect(closeServer).toHaveBeenCalledTimes(1);
|
|
1497
|
+
});
|
|
1498
|
+
});
|
|
@@ -493,6 +493,10 @@ describe("summarizeSessionForOpencode", () => {
|
|
|
493
493
|
expect(postRatingsArgs!.events.length).toBe(2);
|
|
494
494
|
// Task ID is passed for cross-referencing.
|
|
495
495
|
expect(postRatingsArgs!.taskId).toBe("task-oc-1");
|
|
496
|
+
// Every rating records the judge model that was actually used.
|
|
497
|
+
for (const event of postRatingsArgs!.events as Array<{ model?: string }>) {
|
|
498
|
+
expect(event.model).toBe("openrouter/google/gemini-3-flash-preview");
|
|
499
|
+
}
|
|
496
500
|
});
|
|
497
501
|
});
|
|
498
502
|
|
|
@@ -9,10 +9,12 @@ import type {
|
|
|
9
9
|
ExtensionToolContext,
|
|
10
10
|
ToolDefinition,
|
|
11
11
|
} from "@earendil-works/pi-coding-agent";
|
|
12
|
+
import { validateConfigValue } from "../be/swarm-config-guard";
|
|
12
13
|
import {
|
|
13
14
|
type CodemodeLimits,
|
|
14
15
|
createBoundedCodemodeExtension,
|
|
15
16
|
isPiCodemodeEnabled,
|
|
17
|
+
isPiCodemodeModelsEnabled,
|
|
16
18
|
PiMonoAdapter,
|
|
17
19
|
piDefaultToolAdditions,
|
|
18
20
|
piExtensionFactories,
|
|
@@ -29,6 +31,37 @@ describe("PI_CODEMODE flag", () => {
|
|
|
29
31
|
});
|
|
30
32
|
});
|
|
31
33
|
|
|
34
|
+
describe("PI_CODEMODE_MODELS flag", () => {
|
|
35
|
+
test("off by default and for false values", () => {
|
|
36
|
+
expect(isPiCodemodeModelsEnabled({ PI_CODEMODE: "true" })).toBe(false);
|
|
37
|
+
expect(isPiCodemodeModelsEnabled({ PI_CODEMODE: "true", PI_CODEMODE_MODELS: "false" })).toBe(
|
|
38
|
+
false,
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("on only with codemode on", () => {
|
|
43
|
+
expect(isPiCodemodeModelsEnabled({ PI_CODEMODE: "true", PI_CODEMODE_MODELS: "true" })).toBe(
|
|
44
|
+
true,
|
|
45
|
+
);
|
|
46
|
+
expect(isPiCodemodeModelsEnabled({ PI_CODEMODE_MODELS: "true" })).toBe(false);
|
|
47
|
+
expect(isPiCodemodeModelsEnabled({ PI_CODEMODE: "false", PI_CODEMODE_MODELS: "true" })).toBe(
|
|
48
|
+
false,
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe("pi pilot flags — config validation", () => {
|
|
54
|
+
test.each([
|
|
55
|
+
"PI_TOOL_DEFERRAL",
|
|
56
|
+
"PI_CODEMODE",
|
|
57
|
+
"PI_CODEMODE_MODELS",
|
|
58
|
+
])("%s accepts boolean literals and rejects anything else", (key) => {
|
|
59
|
+
expect(validateConfigValue(key, "true")).toBeNull();
|
|
60
|
+
expect(validateConfigValue(key, "false")).toBeNull();
|
|
61
|
+
expect(validateConfigValue(key, "maybe")).toContain(`Invalid ${key}`);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
32
65
|
describe("pi extension factories and default tools — codemode", () => {
|
|
33
66
|
const swarm: ExtensionFactory = () => {};
|
|
34
67
|
|
|
@@ -37,6 +70,12 @@ describe("pi extension factories and default tools — codemode", () => {
|
|
|
37
70
|
expect(piDefaultToolAdditions({ toolDeferral: false, codemode: true })).toEqual(["+codemode"]);
|
|
38
71
|
});
|
|
39
72
|
|
|
73
|
+
test("codemode models adds no extension or default tool of its own", () => {
|
|
74
|
+
const features = { toolDeferral: false, codemode: true, codemodeModels: true };
|
|
75
|
+
expect(piExtensionFactories(swarm, features)).toHaveLength(2);
|
|
76
|
+
expect(piDefaultToolAdditions(features)).toEqual(["+codemode"]);
|
|
77
|
+
});
|
|
78
|
+
|
|
40
79
|
test("all features together", () => {
|
|
41
80
|
const features = { toolDeferral: true, installedMcp: true, codemode: true };
|
|
42
81
|
expect(piExtensionFactories(swarm, features)).toHaveLength(4);
|
|
@@ -47,6 +86,7 @@ describe("pi extension factories and default tools — codemode", () => {
|
|
|
47
86
|
describe("PiMonoAdapter.createSession — codemode", () => {
|
|
48
87
|
const envKeys = [
|
|
49
88
|
"PI_CODEMODE",
|
|
89
|
+
"PI_CODEMODE_MODELS",
|
|
50
90
|
"PI_TOOL_DEFERRAL",
|
|
51
91
|
"PI_CODING_AGENT_DIR",
|
|
52
92
|
"OPENROUTER_API_KEY",
|
|
@@ -63,6 +103,7 @@ describe("PiMonoAdapter.createSession — codemode", () => {
|
|
|
63
103
|
// The session prompts on creation; keep that request off the network.
|
|
64
104
|
process.env.OPENROUTER_BASE_URL = "http://127.0.0.1:9/api/v1";
|
|
65
105
|
delete process.env.PI_CODEMODE;
|
|
106
|
+
delete process.env.PI_CODEMODE_MODELS;
|
|
66
107
|
delete process.env.PI_TOOL_DEFERRAL;
|
|
67
108
|
});
|
|
68
109
|
afterEach(() => {
|
|
@@ -73,7 +114,7 @@ describe("PiMonoAdapter.createSession — codemode", () => {
|
|
|
73
114
|
rmSync(dir, { recursive: true, force: true });
|
|
74
115
|
});
|
|
75
116
|
|
|
76
|
-
async function
|
|
117
|
+
async function sessionTools(): Promise<{ active: string[]; codemodeDescription: string }> {
|
|
77
118
|
const server = Bun.serve({
|
|
78
119
|
port: 0,
|
|
79
120
|
async fetch(req) {
|
|
@@ -107,13 +148,21 @@ describe("PiMonoAdapter.createSession — codemode", () => {
|
|
|
107
148
|
logFile: join(dir, "session.log"),
|
|
108
149
|
});
|
|
109
150
|
session = (provider as unknown as { agentSession: AgentSession }).agentSession;
|
|
110
|
-
return
|
|
151
|
+
return {
|
|
152
|
+
active: session.getActiveToolNames(),
|
|
153
|
+
codemodeDescription:
|
|
154
|
+
session.getAllTools().find((tool) => tool.name === "codemode")?.description ?? "",
|
|
155
|
+
};
|
|
111
156
|
} finally {
|
|
112
157
|
session?.dispose();
|
|
113
158
|
server.stop(true);
|
|
114
159
|
}
|
|
115
160
|
}
|
|
116
161
|
|
|
162
|
+
async function activeTools(): Promise<string[]> {
|
|
163
|
+
return (await sessionTools()).active;
|
|
164
|
+
}
|
|
165
|
+
|
|
117
166
|
test("flag on: codemode is added and swarm tools stay declared", async () => {
|
|
118
167
|
process.env.PI_CODEMODE = "true";
|
|
119
168
|
const active = await activeTools();
|
|
@@ -122,6 +171,15 @@ describe("PiMonoAdapter.createSession — codemode", () => {
|
|
|
122
171
|
expect(active).toContain("create-page");
|
|
123
172
|
});
|
|
124
173
|
|
|
174
|
+
test("models flag: scripts get the models API only when asked, and only with codemode", async () => {
|
|
175
|
+
process.env.PI_CODEMODE = "true";
|
|
176
|
+
expect((await sessionTools()).codemodeDescription).not.toContain("`models`");
|
|
177
|
+
process.env.PI_CODEMODE_MODELS = "true";
|
|
178
|
+
expect((await sessionTools()).codemodeDescription).toContain("`models`");
|
|
179
|
+
process.env.PI_CODEMODE = "false";
|
|
180
|
+
expect(await activeTools()).not.toContain("codemode");
|
|
181
|
+
});
|
|
182
|
+
|
|
125
183
|
test("flag off: no codemode", async () => {
|
|
126
184
|
expect(await activeTools()).not.toContain("codemode");
|
|
127
185
|
process.env.PI_CODEMODE = "false";
|
|
@@ -132,7 +190,7 @@ describe("PiMonoAdapter.createSession — codemode", () => {
|
|
|
132
190
|
describe("bounded codemode", () => {
|
|
133
191
|
type Registered = ToolDefinition;
|
|
134
192
|
|
|
135
|
-
function registerCodemode(limits: CodemodeLimits): Registered {
|
|
193
|
+
function registerCodemode(limits: CodemodeLimits, options?: { models?: boolean }): Registered {
|
|
136
194
|
let registered: Registered | undefined;
|
|
137
195
|
const pi = {
|
|
138
196
|
registerTool: (tool: Registered) => {
|
|
@@ -142,7 +200,7 @@ describe("bounded codemode", () => {
|
|
|
142
200
|
getAllTools: () => [],
|
|
143
201
|
appendEntry: () => {},
|
|
144
202
|
} as unknown as ExtensionAPI;
|
|
145
|
-
createBoundedCodemodeExtension(limits)(pi);
|
|
203
|
+
createBoundedCodemodeExtension(limits, options)(pi);
|
|
146
204
|
if (!registered) throw new Error("codemode tool was not registered");
|
|
147
205
|
return registered;
|
|
148
206
|
}
|
|
@@ -187,6 +245,26 @@ describe("bounded codemode", () => {
|
|
|
187
245
|
|
|
188
246
|
const limits = { timeoutMs: 30_000, maxNestedCalls: 32, maxConcurrentCalls: 4 };
|
|
189
247
|
|
|
248
|
+
test("scripts have no models API unless models is on", async () => {
|
|
249
|
+
const code = "return typeof models;";
|
|
250
|
+
const off = await registerCodemode(limits).execute(
|
|
251
|
+
"m1",
|
|
252
|
+
{ code },
|
|
253
|
+
undefined,
|
|
254
|
+
undefined,
|
|
255
|
+
fakeCtx().ctx,
|
|
256
|
+
);
|
|
257
|
+
expect(textOf(off)).toContain("undefined");
|
|
258
|
+
const on = await registerCodemode(limits, { models: true }).execute(
|
|
259
|
+
"m2",
|
|
260
|
+
{ code },
|
|
261
|
+
undefined,
|
|
262
|
+
undefined,
|
|
263
|
+
fakeCtx().ctx,
|
|
264
|
+
);
|
|
265
|
+
expect(textOf(on)).toContain("object");
|
|
266
|
+
}, 20_000);
|
|
267
|
+
|
|
190
268
|
test("a non-terminating script is interrupted at the deadline", async () => {
|
|
191
269
|
const tool = registerCodemode({ ...limits, timeoutMs: 300 });
|
|
192
270
|
const started = Date.now();
|