@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
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import { unlink } from "node:fs/promises";
|
|
3
|
+
import { closeDb, initDb } from "../be/db";
|
|
4
|
+
import { resetFileStorageProvider } from "../fs/registry";
|
|
5
|
+
import { buildStatusPayload } from "../http/status";
|
|
6
|
+
|
|
7
|
+
const TEST_DB_PATH = "./test-comb-status.sqlite";
|
|
8
|
+
|
|
9
|
+
const ENV_KEYS = [
|
|
10
|
+
"COMB_ENABLED",
|
|
11
|
+
"AGENT_FS_API_URL",
|
|
12
|
+
"AGENT_FS_PUBLIC_URL",
|
|
13
|
+
"AGENT_FS_LIVE_URL",
|
|
14
|
+
"AGENT_FS_DEFAULT_ORG_ID",
|
|
15
|
+
"AGENT_FS_DEFAULT_DRIVE_ID",
|
|
16
|
+
"API_AGENT_FS_API_KEY",
|
|
17
|
+
"AGENT_FS_API_KEY",
|
|
18
|
+
];
|
|
19
|
+
const savedEnv = new Map<string, string | undefined>();
|
|
20
|
+
|
|
21
|
+
async function removeDbFiles(): Promise<void> {
|
|
22
|
+
for (const suffix of ["", "-wal", "-shm"]) {
|
|
23
|
+
await unlink(TEST_DB_PATH + suffix).catch(() => {});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function restoreEnv(): void {
|
|
28
|
+
for (const key of ENV_KEYS) {
|
|
29
|
+
const value = savedEnv.get(key);
|
|
30
|
+
if (value === undefined) delete process.env[key];
|
|
31
|
+
else process.env[key] = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function comb() {
|
|
36
|
+
return (await buildStatusPayload()).agent_fs.comb;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
beforeAll(async () => {
|
|
40
|
+
for (const key of ENV_KEYS) savedEnv.set(key, process.env[key]);
|
|
41
|
+
await removeDbFiles();
|
|
42
|
+
initDb(TEST_DB_PATH);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterAll(async () => {
|
|
46
|
+
closeDb();
|
|
47
|
+
await removeDbFiles();
|
|
48
|
+
restoreEnv();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
beforeEach(() => {
|
|
52
|
+
for (const key of ENV_KEYS) delete process.env[key];
|
|
53
|
+
resetFileStorageProvider();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
afterEach(() => {
|
|
57
|
+
restoreEnv();
|
|
58
|
+
resetFileStorageProvider();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe("/status agent_fs.comb", () => {
|
|
62
|
+
test("is off by default", async () => {
|
|
63
|
+
process.env.AGENT_FS_API_URL = "http://agent-fs:7433";
|
|
64
|
+
const result = await comb();
|
|
65
|
+
expect(result.enabled).toBe(false);
|
|
66
|
+
expect(result.api_url).toBe("http://agent-fs:7433");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("stays off with the flag on but no AGENT_FS_API_URL", async () => {
|
|
70
|
+
process.env.COMB_ENABLED = "true";
|
|
71
|
+
process.env.AGENT_FS_PUBLIC_URL = "http://localhost:7433";
|
|
72
|
+
expect((await comb()).enabled).toBe(false);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("turns on with the flag and AGENT_FS_API_URL", async () => {
|
|
76
|
+
process.env.AGENT_FS_API_URL = "http://agent-fs:7433";
|
|
77
|
+
for (const value of ["true", " TRUE ", "1"]) {
|
|
78
|
+
process.env.COMB_ENABLED = value;
|
|
79
|
+
expect((await comb()).enabled).toBe(true);
|
|
80
|
+
}
|
|
81
|
+
for (const value of ["false", "0", "yes", ""]) {
|
|
82
|
+
process.env.COMB_ENABLED = value;
|
|
83
|
+
expect((await comb()).enabled).toBe(false);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("AGENT_FS_PUBLIC_URL wins over AGENT_FS_API_URL, without a trailing slash", async () => {
|
|
88
|
+
process.env.COMB_ENABLED = "true";
|
|
89
|
+
process.env.AGENT_FS_API_URL = "http://agent-fs:7433/";
|
|
90
|
+
expect((await comb()).api_url).toBe("http://agent-fs:7433");
|
|
91
|
+
process.env.AGENT_FS_PUBLIC_URL = "https://files.example.com/";
|
|
92
|
+
expect((await comb()).api_url).toBe("https://files.example.com");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("ids come from AGENT_FS_DEFAULT_*, and live_url from AGENT_FS_LIVE_URL", async () => {
|
|
96
|
+
process.env.COMB_ENABLED = "true";
|
|
97
|
+
process.env.AGENT_FS_API_URL = "http://agent-fs:7433";
|
|
98
|
+
let result = await comb();
|
|
99
|
+
expect(result.org_id).toBeNull();
|
|
100
|
+
expect(result.drive_id).toBeNull();
|
|
101
|
+
expect(result.live_url).toBe("https://live.agent-fs.dev");
|
|
102
|
+
|
|
103
|
+
process.env.AGENT_FS_DEFAULT_ORG_ID = "org-1";
|
|
104
|
+
process.env.AGENT_FS_DEFAULT_DRIVE_ID = "drive-1";
|
|
105
|
+
process.env.AGENT_FS_LIVE_URL = "https://live.example.com/";
|
|
106
|
+
result = await comb();
|
|
107
|
+
expect(result).toEqual({
|
|
108
|
+
enabled: true,
|
|
109
|
+
api_url: "http://agent-fs:7433",
|
|
110
|
+
live_url: "https://live.example.com",
|
|
111
|
+
org_id: "org-1",
|
|
112
|
+
drive_id: "drive-1",
|
|
113
|
+
service_user_id: null,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test("service_user_id is the bootstrap key's agent-fs user, asked once", async () => {
|
|
118
|
+
let meCalls = 0;
|
|
119
|
+
const agentFs = Bun.serve({
|
|
120
|
+
port: 0,
|
|
121
|
+
fetch: (request) => {
|
|
122
|
+
if (new URL(request.url).pathname !== "/auth/me") return new Response("", { status: 404 });
|
|
123
|
+
meCalls++;
|
|
124
|
+
return request.headers.get("authorization") === "Bearer af_boot"
|
|
125
|
+
? Response.json({ userId: "svc-user", email: "swarm-admin@agent-fs.local" })
|
|
126
|
+
: Response.json({ error: "UNAUTHORIZED" }, { status: 401 });
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
try {
|
|
130
|
+
process.env.AGENT_FS_API_URL = `http://localhost:${agentFs.port}`;
|
|
131
|
+
process.env.API_AGENT_FS_API_KEY = "af_boot";
|
|
132
|
+
process.env.AGENT_FS_DEFAULT_ORG_ID = "org-1";
|
|
133
|
+
process.env.AGENT_FS_DEFAULT_DRIVE_ID = "drive-1";
|
|
134
|
+
|
|
135
|
+
// Comb off: no lookup.
|
|
136
|
+
expect((await comb()).service_user_id).toBeNull();
|
|
137
|
+
expect(meCalls).toBe(0);
|
|
138
|
+
|
|
139
|
+
process.env.COMB_ENABLED = "true";
|
|
140
|
+
expect((await comb()).service_user_id).toBe("svc-user");
|
|
141
|
+
expect((await comb()).service_user_id).toBe("svc-user");
|
|
142
|
+
expect(meCalls).toBe(1);
|
|
143
|
+
|
|
144
|
+
// A rejected key reports null instead of failing /status.
|
|
145
|
+
process.env.API_AGENT_FS_API_KEY = "af_other";
|
|
146
|
+
resetFileStorageProvider();
|
|
147
|
+
expect((await comb()).service_user_id).toBeNull();
|
|
148
|
+
} finally {
|
|
149
|
+
agentFs.stop(true);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import { unlink } from "node:fs/promises";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import {
|
|
5
|
+
closeDb,
|
|
6
|
+
createAgent,
|
|
7
|
+
getContextVersionHistory,
|
|
8
|
+
getDbClient,
|
|
9
|
+
getLatestContextVersion,
|
|
10
|
+
initDb,
|
|
11
|
+
updateAgentProfile,
|
|
12
|
+
} from "../be/db";
|
|
13
|
+
import {
|
|
14
|
+
DB_RETENTION_TABLES,
|
|
15
|
+
getDbRetentionStats,
|
|
16
|
+
resetDbRetentionForTests,
|
|
17
|
+
runDbRetentionTick,
|
|
18
|
+
sweepStatements,
|
|
19
|
+
} from "../be/db-retention";
|
|
20
|
+
import { registerContextDiffTool } from "../tools/context-diff";
|
|
21
|
+
import { registerContextHistoryTool } from "../tools/context-history";
|
|
22
|
+
|
|
23
|
+
const TEST_DB_PATH = "./test-context-versions-retention.sqlite";
|
|
24
|
+
const KEEP_KEY = "CONTEXT_VERSIONS_KEEP_LATEST";
|
|
25
|
+
const AGENT_A = "cccc0000-0000-4000-8000-000000000001";
|
|
26
|
+
const AGENT_B = "cccc0000-0000-4000-8000-000000000002";
|
|
27
|
+
|
|
28
|
+
const CONTEXT_VERSIONS = DB_RETENTION_TABLES.find((table) => table.table === "context_versions");
|
|
29
|
+
if (!CONTEXT_VERSIONS) throw new Error("context_versions is not in the retention allowlist");
|
|
30
|
+
|
|
31
|
+
type ToolResult = {
|
|
32
|
+
content: Array<{ type: string; text: string }>;
|
|
33
|
+
structuredContent: Record<string, unknown>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
let server: McpServer;
|
|
37
|
+
|
|
38
|
+
async function callTool(
|
|
39
|
+
name: string,
|
|
40
|
+
callerAgentId: string,
|
|
41
|
+
args: Record<string, unknown>,
|
|
42
|
+
): Promise<ToolResult> {
|
|
43
|
+
// biome-ignore lint/complexity/noBannedTypes: accessing internal MCP SDK type for test
|
|
44
|
+
const tools = (server as unknown as { _registeredTools: Record<string, { handler: Function }> })
|
|
45
|
+
._registeredTools;
|
|
46
|
+
const handler = tools[name]?.handler;
|
|
47
|
+
if (!handler) throw new Error(`Tool not registered: ${name}`);
|
|
48
|
+
return (await handler(args, {
|
|
49
|
+
sessionId: "test-session",
|
|
50
|
+
requestInfo: { headers: { "x-agent-id": callerAgentId } },
|
|
51
|
+
})) as ToolResult;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function removeDbFiles(): Promise<void> {
|
|
55
|
+
for (const suffix of ["", "-wal", "-shm"])
|
|
56
|
+
await unlink(`${TEST_DB_PATH}${suffix}`).catch(() => undefined);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Write `count` distinct edits through the real profile path, which chains previousVersionId. */
|
|
60
|
+
async function edit(
|
|
61
|
+
agentId: string,
|
|
62
|
+
field: "heartbeatMd" | "toolsMd" | "setupScript",
|
|
63
|
+
count: number,
|
|
64
|
+
tag = field,
|
|
65
|
+
): Promise<void> {
|
|
66
|
+
for (let i = 1; i <= count; i++) {
|
|
67
|
+
await updateAgentProfile(agentId, { [field]: `${tag} edit ${i}` });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function versionsOf(agentId: string, field: string): Promise<number[]> {
|
|
72
|
+
const rows = await getDbClient().query<{ version: number }>(
|
|
73
|
+
"SELECT version FROM context_versions WHERE agentId = ? AND field = ? ORDER BY version",
|
|
74
|
+
[agentId, field],
|
|
75
|
+
);
|
|
76
|
+
return rows.map((row) => row.version);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function rowFor(agentId: string, field: string, version: number) {
|
|
80
|
+
return getDbClient().get<{ id: string; previousVersionId: string | null }>(
|
|
81
|
+
"SELECT id, previousVersionId FROM context_versions WHERE agentId = ? AND field = ? AND version = ?",
|
|
82
|
+
[agentId, field, version],
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
beforeAll(async () => {
|
|
87
|
+
closeDb();
|
|
88
|
+
await removeDbFiles();
|
|
89
|
+
initDb(TEST_DB_PATH);
|
|
90
|
+
await createAgent({ id: AGENT_A, name: "Retention A", isLead: true, status: "idle" });
|
|
91
|
+
await createAgent({ id: AGENT_B, name: "Retention B", isLead: false, status: "idle" });
|
|
92
|
+
server = new McpServer({ name: "test-context-versions-retention", version: "1.0.0" });
|
|
93
|
+
registerContextHistoryTool(server);
|
|
94
|
+
registerContextDiffTool(server);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
afterAll(async () => {
|
|
98
|
+
await resetDbRetentionForTests();
|
|
99
|
+
delete process.env[KEEP_KEY];
|
|
100
|
+
delete process.env.DB_RETENTION_DRY_RUN;
|
|
101
|
+
closeDb();
|
|
102
|
+
await removeDbFiles();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
beforeEach(async () => {
|
|
106
|
+
await resetDbRetentionForTests();
|
|
107
|
+
delete process.env[KEEP_KEY];
|
|
108
|
+
delete process.env.DB_RETENTION_DRY_RUN;
|
|
109
|
+
await getDbClient().run("DELETE FROM context_versions");
|
|
110
|
+
// The profile path diffs against the agents row, so reset it with the history.
|
|
111
|
+
await getDbClient().run(
|
|
112
|
+
"UPDATE agents SET heartbeatMd = NULL, toolsMd = NULL, setupScript = NULL WHERE id IN (?, ?)",
|
|
113
|
+
[AGENT_A, AGENT_B],
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe("context_versions count-based retention", () => {
|
|
118
|
+
test("is opt-in: an unset key deletes nothing", async () => {
|
|
119
|
+
await edit(AGENT_A, "heartbeatMd", 12);
|
|
120
|
+
|
|
121
|
+
await runDbRetentionTick();
|
|
122
|
+
|
|
123
|
+
expect(await versionsOf(AGENT_A, "heartbeatMd")).toHaveLength(12);
|
|
124
|
+
expect(getDbRetentionStats().contextVersions).toBeUndefined();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test.each([
|
|
128
|
+
1, 3, 10,
|
|
129
|
+
])("keeps exactly the newest %i versions of every (agentId, field) and never the age", async (keep) => {
|
|
130
|
+
await edit(AGENT_A, "heartbeatMd", 15);
|
|
131
|
+
await edit(AGENT_A, "toolsMd", 4);
|
|
132
|
+
await edit(AGENT_A, "setupScript", 1); // rarely edited: its only version
|
|
133
|
+
await edit(AGENT_B, "heartbeatMd", 7, "b-heartbeat");
|
|
134
|
+
// Age plays no part: make the lone setupScript version years old.
|
|
135
|
+
await getDbClient().run(
|
|
136
|
+
"UPDATE context_versions SET createdAt = '2020-01-01T00:00:00.000Z' WHERE field = 'setupScript'",
|
|
137
|
+
);
|
|
138
|
+
process.env[KEEP_KEY] = String(keep);
|
|
139
|
+
|
|
140
|
+
await runDbRetentionTick();
|
|
141
|
+
|
|
142
|
+
const newest = (total: number) =>
|
|
143
|
+
Array.from(
|
|
144
|
+
{ length: Math.min(total, keep) },
|
|
145
|
+
(_, i) => total - Math.min(total, keep) + i + 1,
|
|
146
|
+
);
|
|
147
|
+
expect(await versionsOf(AGENT_A, "heartbeatMd")).toEqual(newest(15));
|
|
148
|
+
expect(await versionsOf(AGENT_A, "toolsMd")).toEqual(newest(4));
|
|
149
|
+
expect(await versionsOf(AGENT_A, "setupScript")).toEqual([1]);
|
|
150
|
+
expect(await versionsOf(AGENT_B, "heartbeatMd")).toEqual(newest(7));
|
|
151
|
+
|
|
152
|
+
const expectedDeleted = Math.max(0, 15 - keep) + Math.max(0, 4 - keep) + Math.max(0, 7 - keep);
|
|
153
|
+
expect(getDbRetentionStats().contextVersions).toMatchObject({
|
|
154
|
+
rowsDeleted: expectedDeleted,
|
|
155
|
+
backlogRemaining: 0,
|
|
156
|
+
drained: true,
|
|
157
|
+
outcome: "converged",
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("dry run counts the would-delete rows without deleting", async () => {
|
|
162
|
+
await edit(AGENT_A, "heartbeatMd", 9);
|
|
163
|
+
await edit(AGENT_A, "toolsMd", 2);
|
|
164
|
+
process.env[KEEP_KEY] = "3";
|
|
165
|
+
process.env.DB_RETENTION_DRY_RUN = "true";
|
|
166
|
+
|
|
167
|
+
await runDbRetentionTick();
|
|
168
|
+
|
|
169
|
+
expect(await versionsOf(AGENT_A, "heartbeatMd")).toHaveLength(9);
|
|
170
|
+
expect(getDbRetentionStats().contextVersions).toMatchObject({
|
|
171
|
+
rowsDeleted: 0,
|
|
172
|
+
backlogRemaining: 6,
|
|
173
|
+
dryRun: true,
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("drains a backlog larger than one batch, deepest history first, within the batch ceiling", async () => {
|
|
178
|
+
await edit(AGENT_A, "heartbeatMd", 260);
|
|
179
|
+
process.env[KEEP_KEY] = "5";
|
|
180
|
+
|
|
181
|
+
for (let tick = 0; tick < 10; tick++) {
|
|
182
|
+
await runDbRetentionTick();
|
|
183
|
+
if (getDbRetentionStats().contextVersions?.drained) break;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const stats = getDbRetentionStats().contextVersions;
|
|
187
|
+
expect(stats?.drained).toBe(true);
|
|
188
|
+
expect(stats?.cumulativeRowsDeleted).toBe(255);
|
|
189
|
+
expect(stats?.batchSize).toBeLessThanOrEqual(100);
|
|
190
|
+
expect(await versionsOf(AGENT_A, "heartbeatMd")).toEqual([256, 257, 258, 259, 260]);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
test("version numbering continues from the newest survivor after a prune", async () => {
|
|
194
|
+
await edit(AGENT_A, "heartbeatMd", 8);
|
|
195
|
+
process.env[KEEP_KEY] = "2";
|
|
196
|
+
await runDbRetentionTick();
|
|
197
|
+
|
|
198
|
+
const latest = await getLatestContextVersion(AGENT_A, "heartbeatMd");
|
|
199
|
+
expect(latest?.version).toBe(8);
|
|
200
|
+
|
|
201
|
+
await updateAgentProfile(AGENT_A, { heartbeatMd: "after prune" });
|
|
202
|
+
|
|
203
|
+
const next = await getLatestContextVersion(AGENT_A, "heartbeatMd");
|
|
204
|
+
expect(next?.version).toBe(9);
|
|
205
|
+
expect(next?.previousVersionId).toBe(latest?.id ?? "missing");
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
test("the oldest survivor's previousVersionId is set to NULL; the rest of the chain is intact", async () => {
|
|
209
|
+
await edit(AGENT_A, "heartbeatMd", 6);
|
|
210
|
+
process.env[KEEP_KEY] = "3";
|
|
211
|
+
|
|
212
|
+
await runDbRetentionTick();
|
|
213
|
+
|
|
214
|
+
const v4 = await rowFor(AGENT_A, "heartbeatMd", 4);
|
|
215
|
+
const v5 = await rowFor(AGENT_A, "heartbeatMd", 5);
|
|
216
|
+
const v6 = await rowFor(AGENT_A, "heartbeatMd", 6);
|
|
217
|
+
expect(v4?.previousVersionId).toBeNull();
|
|
218
|
+
expect(v5?.previousVersionId).toBe(v4?.id ?? "missing");
|
|
219
|
+
expect(v6?.previousVersionId).toBe(v5?.id ?? "missing");
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test("context-diff reports a pruned predecessor instead of diffing against an empty file", async () => {
|
|
223
|
+
await edit(AGENT_A, "heartbeatMd", 6);
|
|
224
|
+
process.env[KEEP_KEY] = "3";
|
|
225
|
+
await runDbRetentionTick();
|
|
226
|
+
const v4 = await rowFor(AGENT_A, "heartbeatMd", 4);
|
|
227
|
+
const v5 = await rowFor(AGENT_A, "heartbeatMd", 5);
|
|
228
|
+
const v6 = await rowFor(AGENT_A, "heartbeatMd", 6);
|
|
229
|
+
|
|
230
|
+
const pruned = await callTool("context-diff", AGENT_A, { versionId: v4?.id });
|
|
231
|
+
expect(pruned.structuredContent.success).toBe(true);
|
|
232
|
+
expect(pruned.structuredContent).toMatchObject({
|
|
233
|
+
field: "heartbeatMd",
|
|
234
|
+
toVersion: 4,
|
|
235
|
+
predecessorPruned: true,
|
|
236
|
+
});
|
|
237
|
+
expect(pruned.structuredContent.diff).toBeUndefined();
|
|
238
|
+
expect(pruned.content[0]?.text).toContain("v3 was removed by context version retention");
|
|
239
|
+
|
|
240
|
+
// A survivor whose predecessor survived still diffs normally.
|
|
241
|
+
const intact = await callTool("context-diff", AGENT_A, { versionId: v5?.id });
|
|
242
|
+
expect(intact.structuredContent).toMatchObject({ fromVersion: 4, toVersion: 5 });
|
|
243
|
+
expect(String(intact.structuredContent.diff)).toContain("+heartbeatMd edit 5");
|
|
244
|
+
|
|
245
|
+
// An explicit comparison against a surviving version also works.
|
|
246
|
+
const explicit = await callTool("context-diff", AGENT_A, {
|
|
247
|
+
versionId: v6?.id,
|
|
248
|
+
compareToVersionId: v4?.id,
|
|
249
|
+
});
|
|
250
|
+
expect(explicit.structuredContent).toMatchObject({ fromVersion: 4, toVersion: 6 });
|
|
251
|
+
expect(explicit.structuredContent.predecessorPruned).toBeUndefined();
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
test("context-diff on a genuine first version still diffs against an empty file", async () => {
|
|
255
|
+
await edit(AGENT_A, "setupScript", 1);
|
|
256
|
+
process.env[KEEP_KEY] = "1";
|
|
257
|
+
await runDbRetentionTick();
|
|
258
|
+
const v1 = await rowFor(AGENT_A, "setupScript", 1);
|
|
259
|
+
|
|
260
|
+
const result = await callTool("context-diff", AGENT_A, { versionId: v1?.id });
|
|
261
|
+
|
|
262
|
+
expect(result.structuredContent).toMatchObject({ fromVersion: 0, toVersion: 1 });
|
|
263
|
+
expect(result.structuredContent.predecessorPruned).toBeUndefined();
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
test("context-history lists only the surviving versions after a prune", async () => {
|
|
267
|
+
await edit(AGENT_A, "toolsMd", 7);
|
|
268
|
+
process.env[KEEP_KEY] = "2";
|
|
269
|
+
await runDbRetentionTick();
|
|
270
|
+
|
|
271
|
+
const history = await getContextVersionHistory({ agentId: AGENT_A, field: "toolsMd" });
|
|
272
|
+
expect(history.map((v) => v.version)).toEqual([7, 6]);
|
|
273
|
+
|
|
274
|
+
const result = await callTool("context-history", AGENT_A, {
|
|
275
|
+
agentId: AGENT_A,
|
|
276
|
+
field: "toolsMd",
|
|
277
|
+
});
|
|
278
|
+
expect(result.structuredContent.success).toBe(true);
|
|
279
|
+
const versions = result.structuredContent.versions as Array<{ version: number }>;
|
|
280
|
+
expect(versions.map((v) => v.version)).toEqual([7, 6]);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
test("the ranking, the delete, and the FK child lookup all use an index", async () => {
|
|
284
|
+
const statements = sweepStatements(CONTEXT_VERSIONS, 100, new Date());
|
|
285
|
+
const client = getDbClient();
|
|
286
|
+
|
|
287
|
+
const deletePlan = await client.query<{ detail: string }>(
|
|
288
|
+
`EXPLAIN QUERY PLAN ${statements.deleteSql}`,
|
|
289
|
+
[...statements.params, 50],
|
|
290
|
+
);
|
|
291
|
+
const deleteDetail = deletePlan.map((row) => row.detail).join("\n");
|
|
292
|
+
expect(deleteDetail).toContain("USING COVERING INDEX idx_cv_agent_field");
|
|
293
|
+
expect(deleteDetail).not.toMatch(/SCAN context_versions(?! USING)/);
|
|
294
|
+
|
|
295
|
+
const countPlan = await client.query<{ detail: string }>(
|
|
296
|
+
`EXPLAIN QUERY PLAN ${statements.backlogSql}`,
|
|
297
|
+
statements.params,
|
|
298
|
+
);
|
|
299
|
+
const countDetail = countPlan.map((row) => row.detail).join("\n");
|
|
300
|
+
expect(countDetail).toContain("USING COVERING INDEX idx_cv_agent_field");
|
|
301
|
+
expect(countDetail).not.toMatch(/SCAN context_versions(?! USING)/);
|
|
302
|
+
|
|
303
|
+
// ON DELETE SET NULL makes SQLite look up children of every deleted row by
|
|
304
|
+
// previousVersionId. Without idx_cv_previous_version that is a full scan
|
|
305
|
+
// over every version's content, once per deleted row.
|
|
306
|
+
const fkPlan = await client.query<{ detail: string }>(
|
|
307
|
+
"EXPLAIN QUERY PLAN SELECT rowid FROM context_versions WHERE previousVersionId = ?",
|
|
308
|
+
["x"],
|
|
309
|
+
);
|
|
310
|
+
expect(fkPlan.map((row) => row.detail).join("\n")).toContain(
|
|
311
|
+
"USING COVERING INDEX idx_cv_previous_version",
|
|
312
|
+
);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
@@ -81,6 +81,13 @@ describe("handleCore auth middleware (route() auth.apiKey=false is honored)", ()
|
|
|
81
81
|
expect(res.status).not.toBe(401);
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
+
test("Azure DevOps webhook is still public", async () => {
|
|
85
|
+
const res = await fetch(`http://localhost:${port}/api/azure-devops/webhook`, {
|
|
86
|
+
method: "POST",
|
|
87
|
+
});
|
|
88
|
+
expect(res.status).not.toBe(401);
|
|
89
|
+
});
|
|
90
|
+
|
|
84
91
|
test("AgentMail webhook is still public", async () => {
|
|
85
92
|
const res = await fetch(`http://localhost:${port}/api/agentmail/webhook`, { method: "POST" });
|
|
86
93
|
expect(res.status).not.toBe(401);
|
|
@@ -19,6 +19,9 @@ import {
|
|
|
19
19
|
const TEST_DB_PATH = "./test-db-retention.sqlite";
|
|
20
20
|
const NOW = new Date("2026-08-23T12:00:00.000Z");
|
|
21
21
|
const RETENTION_KEYS = DB_RETENTION_TABLES.map((table) => table.envKey);
|
|
22
|
+
/** Time-horizon tables. Count-based context_versions has its own suite. */
|
|
23
|
+
const AGE_TABLES = DB_RETENTION_TABLES.filter((table) => table.policy === "age");
|
|
24
|
+
type AgeTable = (typeof AGE_TABLES)[number];
|
|
22
25
|
const TUNING_KEYS = [
|
|
23
26
|
"DB_RETENTION_TICK_BUDGET_MS",
|
|
24
27
|
"DB_RETENTION_CATCHUP_INTERVAL_MS",
|
|
@@ -30,11 +33,7 @@ async function removeDbFiles(): Promise<void> {
|
|
|
30
33
|
await unlink(`${TEST_DB_PATH}${suffix}`).catch(() => undefined);
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
async function insertRow(
|
|
34
|
-
table: (typeof DB_RETENTION_TABLES)[number]["table"],
|
|
35
|
-
id: string,
|
|
36
|
-
createdAt: string,
|
|
37
|
-
): Promise<void> {
|
|
36
|
+
async function insertRow(table: AgeTable["table"], id: string, createdAt: string): Promise<void> {
|
|
38
37
|
const client = getDbClient();
|
|
39
38
|
if (table === "session_logs") {
|
|
40
39
|
await client.run(
|
|
@@ -104,11 +103,12 @@ afterEach(async () => {
|
|
|
104
103
|
});
|
|
105
104
|
|
|
106
105
|
describe("DB retention", () => {
|
|
107
|
-
test("keeps the closed allowlist limited to the
|
|
106
|
+
test("keeps the closed allowlist limited to the four approved tables", () => {
|
|
108
107
|
expect(DB_RETENTION_TABLES.map((table) => table.table)).toEqual([
|
|
109
108
|
"session_logs",
|
|
110
109
|
"agent_log",
|
|
111
110
|
"events",
|
|
111
|
+
"context_versions",
|
|
112
112
|
]);
|
|
113
113
|
});
|
|
114
114
|
|
|
@@ -164,7 +164,7 @@ describe("DB retention", () => {
|
|
|
164
164
|
});
|
|
165
165
|
|
|
166
166
|
test("is opt-in and rejects invalid retention windows", async () => {
|
|
167
|
-
for (const table of
|
|
167
|
+
for (const table of AGE_TABLES)
|
|
168
168
|
await insertRow(table.table, `${table.table}-old`, "2026-08-01T00:00:00.000Z");
|
|
169
169
|
process.env.SESSION_LOG_RETENTION_DAYS = "0";
|
|
170
170
|
process.env.AGENT_LOG_RETENTION_DAYS = "abc";
|
|
@@ -172,12 +172,12 @@ describe("DB retention", () => {
|
|
|
172
172
|
|
|
173
173
|
await runDbRetentionTick({ now: NOW });
|
|
174
174
|
|
|
175
|
-
for (const table of
|
|
175
|
+
for (const table of AGE_TABLES) expect(await countRows(table.table)).toBe(1);
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
test("sweeps only enabled tables and preserves rows at or after the ISO cutoff", async () => {
|
|
179
179
|
const cutoff = "2026-08-22T12:00:00.000Z";
|
|
180
|
-
for (const table of
|
|
180
|
+
for (const table of AGE_TABLES) {
|
|
181
181
|
await insertRow(table.table, `${table.table}-old`, "2026-08-22T11:59:59.999Z");
|
|
182
182
|
await insertRow(table.table, `${table.table}-cutoff`, cutoff);
|
|
183
183
|
}
|
|
@@ -226,7 +226,7 @@ describe("DB retention", () => {
|
|
|
226
226
|
});
|
|
227
227
|
|
|
228
228
|
test("dry run reports candidates without deleting any enabled table rows", async () => {
|
|
229
|
-
for (const table of
|
|
229
|
+
for (const table of AGE_TABLES) {
|
|
230
230
|
process.env[table.envKey] = "1";
|
|
231
231
|
await insertRow(table.table, `${table.table}-old`, "2026-08-01T00:00:00.000Z");
|
|
232
232
|
}
|
|
@@ -234,7 +234,7 @@ describe("DB retention", () => {
|
|
|
234
234
|
|
|
235
235
|
await runDbRetentionTick({ now: NOW });
|
|
236
236
|
|
|
237
|
-
for (const table of
|
|
237
|
+
for (const table of AGE_TABLES) expect(await countRows(table.table)).toBe(1);
|
|
238
238
|
// A dry run is a single indexed COUNT(*): rowsDeleted is always 0, and the
|
|
239
239
|
// candidate count lives in backlogRemaining instead.
|
|
240
240
|
expect(getDbRetentionStats()).toMatchObject({
|
|
@@ -341,7 +341,7 @@ describe("DB retention", () => {
|
|
|
341
341
|
});
|
|
342
342
|
|
|
343
343
|
test("delete plan uses the index", async () => {
|
|
344
|
-
for (const table of
|
|
344
|
+
for (const table of AGE_TABLES) {
|
|
345
345
|
const plan = await getDbClient().query<{ detail: string }>(
|
|
346
346
|
`EXPLAIN QUERY PLAN DELETE FROM ${table.table} WHERE rowid IN (
|
|
347
347
|
SELECT rowid FROM ${table.table} WHERE ${table.timeColumn} < ? ORDER BY ${table.timeColumn} LIMIT 500
|
|
@@ -375,7 +375,7 @@ describe("DB retention", () => {
|
|
|
375
375
|
process.env.AGENT_LOG_RETENTION_DAYS = "1";
|
|
376
376
|
process.env.EVENTS_RETENTION_DAYS = "1";
|
|
377
377
|
process.env.DB_RETENTION_TICK_BUDGET_MS = "3000";
|
|
378
|
-
for (const table of
|
|
378
|
+
for (const table of AGE_TABLES) {
|
|
379
379
|
await insertRow(table.table, `${table.table}-budget`, "2026-08-01T00:00:00.000Z");
|
|
380
380
|
}
|
|
381
381
|
|
|
@@ -408,7 +408,7 @@ describe("DB retention", () => {
|
|
|
408
408
|
firstCounts[first] = (firstCounts[first] ?? 0) + 1;
|
|
409
409
|
}
|
|
410
410
|
|
|
411
|
-
for (const table of
|
|
411
|
+
for (const table of AGE_TABLES) {
|
|
412
412
|
expect(firstCounts[table.metricsKey]).toBe(2);
|
|
413
413
|
}
|
|
414
414
|
});
|
|
@@ -441,6 +441,7 @@ value:installSkill
|
|
|
441
441
|
value:installSystemDefaultSkillsForAgent
|
|
442
442
|
value:isAgentEligibleForTask
|
|
443
443
|
value:isExtensionAgent
|
|
444
|
+
value:isLinearTrackerContextKey
|
|
444
445
|
value:isPendingSlackMessage
|
|
445
446
|
value:isPoolAffinityEnforcementEnabled
|
|
446
447
|
value:isSettledSlackMessage
|
|
@@ -505,6 +506,7 @@ value:recordKeyRateLimitWindows
|
|
|
505
506
|
value:recordKeySeatMismatch
|
|
506
507
|
value:recordKeyUsage
|
|
507
508
|
value:recordSlackMessage
|
|
509
|
+
value:recordTaskProviderIfUnset
|
|
508
510
|
value:recordTaskPullRequestAttachments
|
|
509
511
|
value:refreshDraftTaskLease
|
|
510
512
|
value:rejectTask
|
|
@@ -620,6 +622,7 @@ value:getTasksByStatus
|
|
|
620
622
|
value:getTasksCount
|
|
621
623
|
value:hasNonTerminalRerouteDecisionChild
|
|
622
624
|
value:hasNonTerminalResumeChild
|
|
625
|
+
value:isLinearTrackerContextKey
|
|
623
626
|
value:markFinalizedSlackRelaysDelivered
|
|
624
627
|
value:markSlackRelayAttempted
|
|
625
628
|
value:markSlackRelayDelivered
|
|
@@ -464,6 +464,7 @@ value:installSkill
|
|
|
464
464
|
value:installSystemDefaultSkillsForAgent
|
|
465
465
|
value:isAgentEligibleForTask
|
|
466
466
|
value:isExtensionAgent
|
|
467
|
+
value:isLinearTrackerContextKey
|
|
467
468
|
value:isPendingSlackMessage
|
|
468
469
|
value:isPoolAffinityEnforcementEnabled
|
|
469
470
|
value:isSettledSlackMessage
|
|
@@ -528,6 +529,7 @@ value:recordKeyRateLimitWindows
|
|
|
528
529
|
value:recordKeySeatMismatch
|
|
529
530
|
value:recordKeyUsage
|
|
530
531
|
value:recordSlackMessage
|
|
532
|
+
value:recordTaskProviderIfUnset
|
|
531
533
|
value:recordTaskPullRequestAttachments
|
|
532
534
|
value:refreshDraftTaskLease
|
|
533
535
|
value:rejectTask
|
|
@@ -624,6 +626,7 @@ value:getPendingTaskForAgent
|
|
|
624
626
|
value:getRecentlyCancelledTasksForAgent
|
|
625
627
|
value:overwriteTerminalTaskResultText
|
|
626
628
|
value:pauseTask
|
|
629
|
+
value:recordTaskProviderIfUnset
|
|
627
630
|
value:resetOrphanedInProgressTasksForAgent
|
|
628
631
|
value:resumeTask
|
|
629
632
|
value:settleSupersededTaskDependents
|
|
@@ -78,7 +78,7 @@ describe("docs API index footprint", () => {
|
|
|
78
78
|
expect(tasks).toContain('"path":"/api/task-templates","method":"get"');
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
test("OpenAPI and generated pages keep all
|
|
81
|
+
test("OpenAPI and generated pages keep all 394 operations", async () => {
|
|
82
82
|
const spec = await Bun.file(resolve(repoRoot, "openapi.json")).json();
|
|
83
83
|
const operationKeys = [];
|
|
84
84
|
const tags = new Set();
|
|
@@ -103,8 +103,8 @@ describe("docs API index footprint", () => {
|
|
|
103
103
|
expect(spec.paths["/api/agents/{id}/runtime"]?.get).toBeDefined();
|
|
104
104
|
|
|
105
105
|
const generatedKeys = await generatedOperationKeys();
|
|
106
|
-
expect(operationKeys).toHaveLength(
|
|
107
|
-
expect(generatedKeys).toHaveLength(
|
|
106
|
+
expect(operationKeys).toHaveLength(394);
|
|
107
|
+
expect(generatedKeys).toHaveLength(394);
|
|
108
108
|
expect(new Set(generatedKeys)).toEqual(new Set(operationKeys));
|
|
109
109
|
});
|
|
110
110
|
|