@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
package/src/http/agents.ts
CHANGED
|
@@ -1128,7 +1128,7 @@ export async function handleAgentsRest(
|
|
|
1128
1128
|
})
|
|
1129
1129
|
)[0]?.value ?? "");
|
|
1130
1130
|
const allowedLevels =
|
|
1131
|
-
harness_provider === "acp"
|
|
1131
|
+
harness_provider === "acp"
|
|
1132
1132
|
? []
|
|
1133
1133
|
: reasoningCapability(harness_provider, modelForValidation ?? "").levels;
|
|
1134
1134
|
if (!allowedLevels.includes(reasoning_effort)) {
|
package/src/http/all-routes.ts
CHANGED
package/src/http/assets.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { auditAssetKeys } from "../be/asset-key-audit";
|
|
|
5
5
|
import { AssetKeyAuthorizationError, authorizeAssetKeyWrite } from "../be/asset-key-auth";
|
|
6
6
|
import { resolveHttpAuditUserId } from "../be/audit-user";
|
|
7
7
|
import {
|
|
8
|
-
getAgentById,
|
|
9
8
|
getDb,
|
|
10
9
|
getDbClient,
|
|
11
10
|
getTaskById,
|
|
@@ -14,7 +13,7 @@ import {
|
|
|
14
13
|
upsertAssetKeyMapping,
|
|
15
14
|
} from "../be/db";
|
|
16
15
|
import { getScriptById } from "../be/scripts/db";
|
|
17
|
-
import { can, type
|
|
16
|
+
import { can, type RbacResource } from "../rbac";
|
|
18
17
|
import {
|
|
19
18
|
type AssetEntityType,
|
|
20
19
|
AssetEntityTypeSchema,
|
|
@@ -23,6 +22,7 @@ import {
|
|
|
23
22
|
AssetSummarySchema,
|
|
24
23
|
} from "../types";
|
|
25
24
|
import { getRequestAuth } from "../utils/request-auth-context";
|
|
25
|
+
import { requestPrincipal } from "./request-principal";
|
|
26
26
|
import { route } from "./route-def";
|
|
27
27
|
import { jsonError } from "./utils";
|
|
28
28
|
|
|
@@ -176,18 +176,6 @@ const moveAssetRoute = route({
|
|
|
176
176
|
},
|
|
177
177
|
});
|
|
178
178
|
|
|
179
|
-
async function assetMovePrincipal(
|
|
180
|
-
req: IncomingMessage,
|
|
181
|
-
myAgentId: string | undefined,
|
|
182
|
-
): Promise<RbacPrincipal | null> {
|
|
183
|
-
const auth = getRequestAuth(req);
|
|
184
|
-
if (auth?.kind === "operator") return { kind: "operator" };
|
|
185
|
-
if (auth?.kind === "user") return { kind: "user", userId: auth.userId };
|
|
186
|
-
if (!myAgentId) return null;
|
|
187
|
-
const agent = await getAgentById(myAgentId);
|
|
188
|
-
return { kind: "agent", agentId: myAgentId, isLead: agent?.isLead ?? false };
|
|
189
|
-
}
|
|
190
|
-
|
|
191
179
|
async function canMutateTaskNamespace(
|
|
192
180
|
task: { id: string; agentId: string | null; creatorAgentId?: string },
|
|
193
181
|
myAgentId: string | undefined,
|
|
@@ -199,7 +187,7 @@ async function canMutateTaskNamespace(
|
|
|
199
187
|
agentId: task.agentId,
|
|
200
188
|
creatorAgentId: task.creatorAgentId,
|
|
201
189
|
};
|
|
202
|
-
const principal = await
|
|
190
|
+
const principal = await requestPrincipal(req, myAgentId);
|
|
203
191
|
if (!principal) return false;
|
|
204
192
|
return can({ principal, verb: "task.fs.mutate", resource, source: "http" }).allow;
|
|
205
193
|
}
|
|
@@ -209,7 +197,7 @@ async function canManageAppNamespace(
|
|
|
209
197
|
req: IncomingMessage,
|
|
210
198
|
myAgentId: string | undefined,
|
|
211
199
|
): Promise<boolean> {
|
|
212
|
-
const principal = await
|
|
200
|
+
const principal = await requestPrincipal(req, myAgentId);
|
|
213
201
|
return (
|
|
214
202
|
!!principal &&
|
|
215
203
|
can({ principal, verb: "app.manage", resource: { kind: "app", appId: id }, source: "http" })
|
|
@@ -222,7 +210,7 @@ async function canManageScriptNamespace(
|
|
|
222
210
|
req: IncomingMessage,
|
|
223
211
|
myAgentId: string | undefined,
|
|
224
212
|
): Promise<boolean> {
|
|
225
|
-
const principal = await
|
|
213
|
+
const principal = await requestPrincipal(req, myAgentId);
|
|
226
214
|
if (!principal) return false;
|
|
227
215
|
if (principal.kind === "operator") return true;
|
|
228
216
|
if (principal.kind !== "agent") return false;
|
package/src/http/comb.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { resolveHttpAuditUserId } from "../be/audit-user";
|
|
4
|
+
import { getCombConfig } from "../comb/config";
|
|
5
|
+
import { REVIEW_BATCH_MAX, ReviewBatchError, sendReviewBatch } from "../comb/review-batch";
|
|
6
|
+
import { can } from "../rbac";
|
|
7
|
+
import { TaskCreationBlockedError } from "../tasks/errors";
|
|
8
|
+
import { scrubSecrets } from "../utils/secret-scrubber";
|
|
9
|
+
import { requestPrincipal } from "./request-principal";
|
|
10
|
+
import { route } from "./route-def";
|
|
11
|
+
import { jsonError } from "./utils";
|
|
12
|
+
|
|
13
|
+
const skippedSchema = z.object({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
reason: z.enum(["not-found", "reply", "resolved", "already-sent"]),
|
|
16
|
+
/** The task an "already-sent" comment went to, when known. */
|
|
17
|
+
taskId: z.string().optional(),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const resultSchema = z.object({
|
|
21
|
+
/** The new task. Null on a 200: the batch only posted missing "sent" replies again. */
|
|
22
|
+
taskId: z.string().nullable(),
|
|
23
|
+
sent: z.array(z.string()),
|
|
24
|
+
skipped: z.array(skippedSchema),
|
|
25
|
+
/** Comments of an earlier send whose missing "sent" reply this batch posted again. */
|
|
26
|
+
repaired: z.array(z.object({ id: z.string(), taskId: z.string() })),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const batchErrorSchema = z.object({ error: z.string(), skipped: z.array(skippedSchema) });
|
|
30
|
+
|
|
31
|
+
/** A drive path: starts with "/", no "." or ".." segment. */
|
|
32
|
+
function isDrivePath(path: string): boolean {
|
|
33
|
+
return (
|
|
34
|
+
path.startsWith("/") && !path.split("/").some((segment) => segment === "." || segment === "..")
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const reviewBatchRoute = route({
|
|
39
|
+
method: "post",
|
|
40
|
+
path: "/api/comb/review-batches",
|
|
41
|
+
pattern: ["api", "comb", "review-batches"],
|
|
42
|
+
summary: "Send agent-fs comments to the swarm as one lead task",
|
|
43
|
+
description:
|
|
44
|
+
"Comb's 'Send to swarm'. The server reads each comment again from agent-fs with its bootstrap key, skips replies, resolved comments, and comments already sent, and creates ONE task for the lead. Each sent comment gets a `[comb:sent task=<id>]` reply from the swarm service account. A comment is sent at most once. When an earlier send lost its reply, the batch posts that reply again (`repaired`). Answers 404 while COMB_ENABLED is off.",
|
|
45
|
+
tags: ["Comb"],
|
|
46
|
+
body: z.object({
|
|
47
|
+
orgId: z.string().min(1),
|
|
48
|
+
driveId: z.string().min(1),
|
|
49
|
+
// agent-fs comment ids are UUIDs, so a malformed id never costs an agent-fs read.
|
|
50
|
+
commentIds: z.array(z.uuid()).min(1).max(REVIEW_BATCH_MAX),
|
|
51
|
+
/** The file or folder the batch was sent from (a Comb path such as "/docs/"). */
|
|
52
|
+
scopePath: z
|
|
53
|
+
.string()
|
|
54
|
+
.min(1)
|
|
55
|
+
.max(1024)
|
|
56
|
+
.refine(isDrivePath, "scopePath must start with '/' and have no '.' or '..' segment"),
|
|
57
|
+
}),
|
|
58
|
+
responses: {
|
|
59
|
+
200: {
|
|
60
|
+
description: "No new task: the batch only posted missing 'sent' replies again",
|
|
61
|
+
schema: resultSchema,
|
|
62
|
+
},
|
|
63
|
+
201: { description: "Task created", schema: resultSchema },
|
|
64
|
+
400: { description: "Invalid body, or not the swarm drive" },
|
|
65
|
+
403: { description: "Caller cannot create tasks" },
|
|
66
|
+
404: { description: "Comb is not enabled" },
|
|
67
|
+
409: {
|
|
68
|
+
description: "Nothing to send (every comment was skipped)",
|
|
69
|
+
schema: batchErrorSchema,
|
|
70
|
+
},
|
|
71
|
+
422: { description: "Task creation blocked by an extension" },
|
|
72
|
+
502: { description: "agent-fs could not read a comment" },
|
|
73
|
+
503: {
|
|
74
|
+
description:
|
|
75
|
+
"agent-fs or the swarm drive is not set up, or an operator disabled a Comb review template",
|
|
76
|
+
schema: batchErrorSchema,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
rbac: { permission: "task.create.own" },
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export async function handleComb(
|
|
83
|
+
req: IncomingMessage,
|
|
84
|
+
res: ServerResponse,
|
|
85
|
+
pathSegments: string[],
|
|
86
|
+
queryParams: URLSearchParams,
|
|
87
|
+
myAgentId?: string,
|
|
88
|
+
): Promise<boolean> {
|
|
89
|
+
if (!reviewBatchRoute.match(req.method, pathSegments)) return false;
|
|
90
|
+
// Comb off: the route does not exist. No body parsing, no RBAC answer.
|
|
91
|
+
if (!getCombConfig().enabled) {
|
|
92
|
+
jsonError(res, "Comb is not enabled", 404);
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const parsed = await reviewBatchRoute.parse(req, res, pathSegments, queryParams);
|
|
97
|
+
if (!parsed) return true;
|
|
98
|
+
const principal = await requestPrincipal(req, myAgentId);
|
|
99
|
+
if (
|
|
100
|
+
!principal ||
|
|
101
|
+
!can({ principal, verb: "task.create.own", resource: { kind: "none" }, source: "http" }).allow
|
|
102
|
+
) {
|
|
103
|
+
jsonError(res, "Not authorized to create tasks", 403);
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
const result = await sendReviewBatch({
|
|
109
|
+
...parsed.body,
|
|
110
|
+
requestedByUserId: await resolveHttpAuditUserId(req, myAgentId),
|
|
111
|
+
});
|
|
112
|
+
reviewBatchRoute.respond(res, result.taskId === null ? 200 : 201, result);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (error instanceof ReviewBatchError) {
|
|
115
|
+
if (error.status === 409 || error.status === 503) {
|
|
116
|
+
reviewBatchRoute.respond(res, error.status, {
|
|
117
|
+
error: error.message,
|
|
118
|
+
skipped: error.skipped,
|
|
119
|
+
});
|
|
120
|
+
} else {
|
|
121
|
+
jsonError(res, error.message, error.status);
|
|
122
|
+
}
|
|
123
|
+
} else if (error instanceof TaskCreationBlockedError) {
|
|
124
|
+
jsonError(res, error.reason, 422);
|
|
125
|
+
} else {
|
|
126
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
127
|
+
jsonError(res, scrubSecrets(`Failed to send comments to the swarm: ${message}`), 500);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
package/src/http/core.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
import { initAgentMail, resetAgentMail } from "../agentmail";
|
|
3
|
+
import {
|
|
4
|
+
initAzureDevOps,
|
|
5
|
+
isAzureDevOpsEnabled,
|
|
6
|
+
resetAzureDevOps,
|
|
7
|
+
resetAzureDevOpsBotIdCache,
|
|
8
|
+
} from "../azure-devops";
|
|
3
9
|
import {
|
|
4
10
|
getAgentById,
|
|
5
11
|
getDbClient,
|
|
@@ -204,6 +210,12 @@ async function reloadGlobalConfigsAndIntegrationsInner(): Promise<ReloadConfigRe
|
|
|
204
210
|
initGitLab();
|
|
205
211
|
if (isGitLabEnabled()) integrations.push("gitlab");
|
|
206
212
|
|
|
213
|
+
// Same reset-then-init as GitLab: the webhook secret is cached at init.
|
|
214
|
+
resetAzureDevOps();
|
|
215
|
+
resetAzureDevOpsBotIdCache();
|
|
216
|
+
initAzureDevOps();
|
|
217
|
+
if (isAzureDevOpsEnabled()) integrations.push("azure-devops");
|
|
218
|
+
|
|
207
219
|
resetLinear();
|
|
208
220
|
if (await initLinear()) integrations.push("linear");
|
|
209
221
|
|
|
@@ -348,7 +360,8 @@ const pingRoute = route({
|
|
|
348
360
|
`Refreshes the calling agent's status. ${RUNTIME_HEADER_DOC} With multi-runtime mode on, ` +
|
|
349
361
|
"the header must identify a live runtime of this agent; an absent, unknown, offline, or " +
|
|
350
362
|
"foreign identifier makes the call a no-op instead of an error, so workers predating the " +
|
|
351
|
-
"flag keep running."
|
|
363
|
+
"flag keep running. While the API is draining after SIGTERM, every response (this one " +
|
|
364
|
+
"included) carries `X-Swarm-Draining: 1`: workers hand off in-flight tasks and take no new work.",
|
|
352
365
|
tags: ["Core"],
|
|
353
366
|
auth: { apiKey: true, agentId: true },
|
|
354
367
|
headers: runtimeInstanceHeader("refresh a runtime's liveness"),
|
package/src/http/extensions.ts
CHANGED
|
@@ -38,11 +38,13 @@ import {
|
|
|
38
38
|
import {
|
|
39
39
|
type Extension,
|
|
40
40
|
ExtensionInstallBodySchema,
|
|
41
|
+
type ExtensionManifest,
|
|
41
42
|
ExtensionManifestSchema,
|
|
42
43
|
ExtensionRunSchema,
|
|
43
44
|
ExtensionSchema,
|
|
44
45
|
ExtensionVersionSchema,
|
|
45
46
|
} from "../types";
|
|
47
|
+
import { isEnvFlagEnabled } from "../utils/env-flag";
|
|
46
48
|
import { getRequestAuth } from "../utils/request-auth-context";
|
|
47
49
|
import { scrubSecrets } from "../utils/secret-scrubber";
|
|
48
50
|
import { route } from "./route-def";
|
|
@@ -52,11 +54,20 @@ const idParamsSchema = z.object({ id: z.string().min(1) });
|
|
|
52
54
|
|
|
53
55
|
class InlineInstallDisabledError extends Error {}
|
|
54
56
|
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Inline bundles run arbitrary code with API-process privileges once enabled, so they stay off
|
|
59
|
+
* until the operator opts in. Runs before schema validation so a disabled install names the
|
|
60
|
+
* switch instead of reporting manifest errors. Read per request: a `swarm_config` reload applies.
|
|
61
|
+
*/
|
|
62
|
+
function gateInlineInstall(body: unknown): unknown {
|
|
63
|
+
if (
|
|
64
|
+
typeof body === "object" &&
|
|
65
|
+
body !== null &&
|
|
66
|
+
("manifest" in body || "files" in body) &&
|
|
67
|
+
!isEnvFlagEnabled("EXTENSION_ALLOW_INLINE_INSTALL", false)
|
|
68
|
+
) {
|
|
58
69
|
throw new InlineInstallDisabledError(
|
|
59
|
-
'Inline extension bundles are disabled. Install a predefined extension by name: {"template": "<name>"} (see GET /api/extensions/catalog).',
|
|
70
|
+
'Inline extension bundles are disabled (EXTENSION_ALLOW_INLINE_INSTALL is off). Install a predefined extension by name: {"template": "<name>"} (see GET /api/extensions/catalog).',
|
|
60
71
|
);
|
|
61
72
|
}
|
|
62
73
|
return body;
|
|
@@ -84,11 +95,11 @@ const installRoute = route({
|
|
|
84
95
|
path: "/api/extensions/install",
|
|
85
96
|
pattern: ["api", "extensions", "install"],
|
|
86
97
|
operationId: "extensions_install",
|
|
87
|
-
summary: "Install
|
|
98
|
+
summary: "Install an extension from the catalog or an inline bundle",
|
|
88
99
|
description:
|
|
89
|
-
"Installs the named template from `GET /api/extensions/catalog
|
|
100
|
+
"Installs the named `template` from `GET /api/extensions/catalog`, or an inline `manifest` plus `files`. Inline bundles are rejected with `inline_install_disabled` unless `EXTENSION_ALLOW_INLINE_INSTALL` is on, and then only lead, operator, and dashboard-user callers may send them (workers get 403). Any authenticated agent can install a catalog draft owned by its agent ID. Workers can update only their own bundles. A new extension is always disabled; activation remains lead/operator-only.",
|
|
90
101
|
tags: ["Extensions"],
|
|
91
|
-
body: z.preprocess(
|
|
102
|
+
body: z.preprocess(gateInlineInstall, ExtensionInstallBodySchema),
|
|
92
103
|
responses: {
|
|
93
104
|
200: {
|
|
94
105
|
description: "Installed extension",
|
|
@@ -99,8 +110,11 @@ const installRoute = route({
|
|
|
99
110
|
assets: ExtensionAssetsReconcileSchema.nullable(),
|
|
100
111
|
}),
|
|
101
112
|
},
|
|
102
|
-
400: {
|
|
103
|
-
|
|
113
|
+
400: {
|
|
114
|
+
description:
|
|
115
|
+
"Inline install disabled, invalid body (template and manifest/files are mutually exclusive), or bundle validation failed",
|
|
116
|
+
},
|
|
117
|
+
403: { description: "Permission denied, including inline bundles from workers" },
|
|
104
118
|
404: { description: "Template not found in the catalog" },
|
|
105
119
|
},
|
|
106
120
|
rbac: { permission: "extension.write" },
|
|
@@ -412,7 +426,10 @@ async function requirePermission(
|
|
|
412
426
|
req: IncomingMessage,
|
|
413
427
|
res: ServerResponse,
|
|
414
428
|
callerAgentId: string | undefined,
|
|
415
|
-
verb: Extract<
|
|
429
|
+
verb: Extract<
|
|
430
|
+
PermissionVerb,
|
|
431
|
+
"extension.write" | "extension.activate" | "extension.install.inline"
|
|
432
|
+
>,
|
|
416
433
|
resource: RbacResource = { kind: "none" },
|
|
417
434
|
): Promise<RbacPrincipal | null> {
|
|
418
435
|
const principal = await extensionPrincipal(req, callerAgentId);
|
|
@@ -458,29 +475,36 @@ export async function handleExtensions(
|
|
|
458
475
|
return true;
|
|
459
476
|
}
|
|
460
477
|
if (!parsed) return true;
|
|
461
|
-
const template =
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
)
|
|
471
|
-
|
|
478
|
+
const { template: templateName, manifest: inlineManifest, files: inlineFiles } = parsed.body;
|
|
479
|
+
let source: { manifest: ExtensionManifest; files: Record<string, string> };
|
|
480
|
+
if (inlineManifest !== undefined && inlineFiles !== undefined) {
|
|
481
|
+
// The flag was checked while parsing; the caller's role is checked here.
|
|
482
|
+
if (!(await requirePermission(req, res, agentId, "extension.install.inline"))) return true;
|
|
483
|
+
source = { manifest: inlineManifest, files: inlineFiles };
|
|
484
|
+
} else {
|
|
485
|
+
// The body schema guarantees a template here.
|
|
486
|
+
const template = getCatalogEntry(templateName ?? "");
|
|
487
|
+
if (!template) {
|
|
488
|
+
json(
|
|
489
|
+
res,
|
|
490
|
+
{
|
|
491
|
+
error: "extension_template_not_found",
|
|
492
|
+
message: `No predefined extension named "${templateName}"`,
|
|
493
|
+
},
|
|
494
|
+
404,
|
|
495
|
+
);
|
|
496
|
+
return true;
|
|
497
|
+
}
|
|
498
|
+
source = { manifest: template.manifest, files: template.files };
|
|
472
499
|
}
|
|
473
|
-
const existing = await getExtensionByName(
|
|
500
|
+
const existing = await getExtensionByName(source.manifest.name);
|
|
474
501
|
const principal = await requirePermission(req, res, agentId, "extension.write", {
|
|
475
502
|
kind: "extension",
|
|
476
503
|
extensionId: existing?.id,
|
|
477
504
|
createdByAgentId: existing?.createdByAgentId,
|
|
478
505
|
});
|
|
479
506
|
if (!principal) return true;
|
|
480
|
-
const validation = await validateBundle(
|
|
481
|
-
manifest: template.manifest,
|
|
482
|
-
files: template.files,
|
|
483
|
-
});
|
|
507
|
+
const validation = await validateBundle(source);
|
|
484
508
|
if (!validation.ok) {
|
|
485
509
|
json(res, { error: "extension_validation_failed", diagnostics: validation.diagnostics }, 400);
|
|
486
510
|
return true;
|
|
@@ -495,7 +519,7 @@ export async function handleExtensions(
|
|
|
495
519
|
try {
|
|
496
520
|
result = await installExtensionWithAssets({
|
|
497
521
|
manifest: validation.manifest,
|
|
498
|
-
files:
|
|
522
|
+
files: source.files,
|
|
499
523
|
priority: parsed.body.priority,
|
|
500
524
|
config: parsed.body.config,
|
|
501
525
|
agentId: writerAgentId,
|
package/src/http/fs.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { deleteTaskAttachment,
|
|
3
|
+
import { deleteTaskAttachment, getTaskAttachments, getTaskById } from "../be/db";
|
|
4
4
|
import {
|
|
5
5
|
ensureAgentFsCredentialsForAgent,
|
|
6
6
|
inviteEmailToSharedOrg,
|
|
@@ -8,11 +8,12 @@ import {
|
|
|
8
8
|
import { MAX_TASK_ATTACHMENT_BYTES, recordTaskAttachmentUpload } from "../be/task-attachment-store";
|
|
9
9
|
import { type FileObject, type FileScope, FilesError, normalizeFilesError } from "../fs/provider";
|
|
10
10
|
import { getFileStorageProvider } from "../fs/registry";
|
|
11
|
-
import { can, type
|
|
11
|
+
import { can, type RbacResource } from "../rbac";
|
|
12
12
|
import { type TaskAttachment, TaskAttachmentSchema } from "../types";
|
|
13
13
|
import { attachmentContentDisposition } from "../utils/content-disposition";
|
|
14
|
-
import { getCurrentRequestAuth
|
|
14
|
+
import { getCurrentRequestAuth } from "../utils/request-auth-context";
|
|
15
15
|
import { scrubSecrets } from "../utils/secret-scrubber";
|
|
16
|
+
import { requestPrincipal } from "./request-principal";
|
|
16
17
|
import { route } from "./route-def";
|
|
17
18
|
import { BODY_TOO_LARGE, enforceContentLengthCap, jsonError } from "./utils";
|
|
18
19
|
|
|
@@ -522,20 +523,11 @@ async function canMutateTask(
|
|
|
522
523
|
// Decision order preserved (plan Appendix A row 36): operator/user request
|
|
523
524
|
// auth short-circuits BEFORE agent identity — an operator bearer with a
|
|
524
525
|
// non-owner X-Agent-ID is still allowed. The agent branches only bind when
|
|
525
|
-
// the request-auth context is unset.
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
} else if (auth?.kind === "user") {
|
|
531
|
-
principal = { kind: "user", userId: auth.userId };
|
|
532
|
-
} else {
|
|
533
|
-
// A missing caller identity cannot be lead/assignee/creator — same denial
|
|
534
|
-
// as before (no separate "agent not found" branch).
|
|
535
|
-
if (!myAgentId) return false;
|
|
536
|
-
const agent = await getAgentById(myAgentId);
|
|
537
|
-
principal = { kind: "agent", agentId: myAgentId, isLead: agent?.isLead ?? false };
|
|
538
|
-
}
|
|
526
|
+
// the request-auth context is unset. A missing caller identity cannot be
|
|
527
|
+
// lead/assignee/creator: same denial as before (no separate "agent not
|
|
528
|
+
// found" branch).
|
|
529
|
+
const principal = await requestPrincipal(req, myAgentId);
|
|
530
|
+
if (!principal) return false;
|
|
539
531
|
return can({ principal, verb: "task.fs.mutate", resource, source: "http" }).allow;
|
|
540
532
|
}
|
|
541
533
|
|
package/src/http/index.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { ensure, initialize } from "@desplega.ai/business-use";
|
|
|
8
8
|
import type { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
9
9
|
import { getEnabledCapabilities, hasCapability } from "@/server";
|
|
10
10
|
import { initAgentMail } from "../agentmail";
|
|
11
|
+
import { initAzureDevOps } from "../azure-devops";
|
|
12
|
+
import { drainApi, isApiDraining } from "../be/api-drain";
|
|
11
13
|
import {
|
|
12
14
|
closeDb,
|
|
13
15
|
emitBuiltInIntegrationConnectedOnce,
|
|
@@ -52,6 +54,8 @@ import { startScriptRunSupervisor, stopScriptRunSupervisor } from "../script-wor
|
|
|
52
54
|
import { getServerSessionsProcessed } from "../server-runtime-counters";
|
|
53
55
|
import { startSlackApp, stopSlackApp } from "../slack";
|
|
54
56
|
import { initTelemetry, telemetry } from "../telemetry";
|
|
57
|
+
import { startTelemetryTicker } from "../telemetry-snapshot";
|
|
58
|
+
import { API_DRAINING_HEADER } from "../utils/api-drain";
|
|
55
59
|
import { getApiKey } from "../utils/api-key";
|
|
56
60
|
import { getMcpBaseUrl } from "../utils/constants";
|
|
57
61
|
import { isEnvFlagEnabled } from "../utils/env-flag";
|
|
@@ -66,6 +70,7 @@ import { handleAssets } from "./assets";
|
|
|
66
70
|
import { handleBudgets } from "./budgets";
|
|
67
71
|
import { handleCodexOAuthDevice } from "./codex-oauth-device";
|
|
68
72
|
import { handleCodexOAuthKeepWarm } from "./codex-oauth-keep-warm";
|
|
73
|
+
import { handleComb } from "./comb";
|
|
69
74
|
import { handleConfig } from "./config";
|
|
70
75
|
import { handleContext } from "./context";
|
|
71
76
|
import { handleCore, loadGlobalConfigsIntoEnv } from "./core";
|
|
@@ -103,7 +108,7 @@ import { handlePagesPublic } from "./pages-public";
|
|
|
103
108
|
import { handlePoll } from "./poll";
|
|
104
109
|
import { handlePricing } from "./pricing";
|
|
105
110
|
import { handlePromptTemplates } from "./prompt-templates";
|
|
106
|
-
import { handleRealtimeAsset } from "./realtime";
|
|
111
|
+
import { handleRealtimeAsset, handleRealtimeTicket } from "./realtime";
|
|
107
112
|
import { handleRepos } from "./repos";
|
|
108
113
|
import { handleRooms } from "./rooms";
|
|
109
114
|
import { describeRequestRoute } from "./route-def";
|
|
@@ -317,6 +322,8 @@ const httpServer = createHttpServer(async (req, res) => {
|
|
|
317
322
|
// nest under it instead of attaching to the root with no parent.
|
|
318
323
|
const handleRequest = async () => {
|
|
319
324
|
setCorsHeaders(req, res);
|
|
325
|
+
// Tells polling workers to hand off in-flight tasks while this API still serves.
|
|
326
|
+
if (isApiDraining()) res.setHeader(API_DRAINING_HEADER, "1");
|
|
320
327
|
|
|
321
328
|
const queryParams = parseQueryParams(req.url || "");
|
|
322
329
|
const myAgentId = req.headers["x-agent-id"] as string | undefined;
|
|
@@ -347,8 +354,10 @@ const httpServer = createHttpServer(async (req, res) => {
|
|
|
347
354
|
() => handleApps(req, res, pathSegments, queryParams, myAgentId),
|
|
348
355
|
() => handleConfig(req, res, pathSegments, queryParams),
|
|
349
356
|
() => handleFs(req, res, pathSegments, queryParams, myAgentId),
|
|
357
|
+
() => handleComb(req, res, pathSegments, queryParams, myAgentId),
|
|
350
358
|
() => handleKv(req, res, pathSegments, queryParams),
|
|
351
359
|
() => handleRooms(req, res, pathSegments, queryParams),
|
|
360
|
+
() => handleRealtimeTicket(req, res, pathSegments, queryParams),
|
|
352
361
|
() => handleRealtimeAsset(req, res),
|
|
353
362
|
() => handleIntegrations(req, res, pathSegments, queryParams),
|
|
354
363
|
() => handlePromptTemplates(req, res, pathSegments, queryParams),
|
|
@@ -468,6 +477,10 @@ async function shutdown() {
|
|
|
468
477
|
// Stop the out-of-band queue alarm before disconnecting its Slack notifier.
|
|
469
478
|
stopQueueStallAlarm();
|
|
470
479
|
|
|
480
|
+
// Dispatch has stopped. Keep serving, bounded, while workers hand off their
|
|
481
|
+
// in-flight tasks; new work waits for the next API (see src/be/api-drain.ts).
|
|
482
|
+
await drainApi();
|
|
483
|
+
|
|
471
484
|
// Stop durable script workflow subprocesses
|
|
472
485
|
await stopScriptRunSupervisor();
|
|
473
486
|
|
|
@@ -683,15 +696,17 @@ httpServer
|
|
|
683
696
|
// The api-server is the sole authority for the install identity — pass
|
|
684
697
|
// generateIfMissing so it mints a new install ID on first boot. Workers
|
|
685
698
|
// must NOT mint (see src/commands/runner.ts).
|
|
686
|
-
|
|
687
|
-
"
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
);
|
|
699
|
+
const telemetryGetConfig = async (key: string) =>
|
|
700
|
+
(await getSwarmConfigs({ scope: "global", key }))?.[0]?.value;
|
|
701
|
+
const telemetrySetConfig = async (key: string, value: string) => {
|
|
702
|
+
await upsertSwarmConfig({ scope: "global", key, value });
|
|
703
|
+
};
|
|
704
|
+
await initTelemetry("api-server", telemetryGetConfig, telemetrySetConfig, {
|
|
705
|
+
generateIfMissing: true,
|
|
706
|
+
});
|
|
694
707
|
telemetry.server("started", { port });
|
|
708
|
+
// Org email domain (hourly + on user changes) and the daily org.snapshot.
|
|
709
|
+
startTelemetryTicker({ getConfig: telemetryGetConfig, setConfig: telemetrySetConfig });
|
|
695
710
|
if (process.env.GITHUB_TOKEN) {
|
|
696
711
|
await emitBuiltInIntegrationConnectedOnce("github");
|
|
697
712
|
}
|
|
@@ -716,6 +731,9 @@ httpServer
|
|
|
716
731
|
// Initialize GitLab webhook handler (if configured)
|
|
717
732
|
initGitLab();
|
|
718
733
|
|
|
734
|
+
// Initialize Azure DevOps service-hook handler (if configured)
|
|
735
|
+
initAzureDevOps();
|
|
736
|
+
|
|
719
737
|
// Initialize AgentMail webhook handler (if configured)
|
|
720
738
|
initAgentMail();
|
|
721
739
|
|
package/src/http/mcp-user.ts
CHANGED
|
@@ -6,7 +6,12 @@ import { resolveUserByToken } from "@/be/users";
|
|
|
6
6
|
import { createUserServer } from "@/server-user";
|
|
7
7
|
import type { User } from "@/types";
|
|
8
8
|
import { setRequestAuth } from "@/utils/request-auth-context";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
closeIdleMcpTransports,
|
|
11
|
+
type McpTransportActivity,
|
|
12
|
+
markMcpTransportActivity,
|
|
13
|
+
respondNoMcpSession,
|
|
14
|
+
} from "./mcp";
|
|
10
15
|
|
|
11
16
|
function unauthorized(res: ServerResponse): true {
|
|
12
17
|
res.writeHead(401, { "Content-Type": "application/json" });
|
|
@@ -91,15 +96,7 @@ export async function handleMcpUser(
|
|
|
91
96
|
const server = createUserServer(user);
|
|
92
97
|
await server.connect(transport);
|
|
93
98
|
} else {
|
|
94
|
-
res
|
|
95
|
-
res.end(
|
|
96
|
-
JSON.stringify({
|
|
97
|
-
jsonrpc: "2.0",
|
|
98
|
-
error: { code: -32000, message: "Invalid session" },
|
|
99
|
-
id: null,
|
|
100
|
-
}),
|
|
101
|
-
);
|
|
102
|
-
return true;
|
|
99
|
+
return respondNoMcpSession(res, sessionId);
|
|
103
100
|
}
|
|
104
101
|
|
|
105
102
|
await transport.handleRequest(req, res, body);
|
|
@@ -113,9 +110,7 @@ export async function handleMcpUser(
|
|
|
113
110
|
await transports[sessionId].handleRequest(req, res);
|
|
114
111
|
return true;
|
|
115
112
|
}
|
|
116
|
-
res
|
|
117
|
-
res.end("Invalid session");
|
|
118
|
-
return true;
|
|
113
|
+
return respondNoMcpSession(res, sessionId);
|
|
119
114
|
}
|
|
120
115
|
|
|
121
116
|
res.writeHead(405);
|
package/src/http/mcp.ts
CHANGED
|
@@ -14,6 +14,23 @@ export type McpSessionAgents = Record<string, string>;
|
|
|
14
14
|
|
|
15
15
|
export const DEFAULT_MCP_TRANSPORT_IDLE_TIMEOUT_MS = 2 * 60 * 60 * 1000;
|
|
16
16
|
|
|
17
|
+
// MCP spec: an unknown or terminated session id MUST get 404 so the client starts a new
|
|
18
|
+
// session. Claude Code reconnects on 404, so redeploys and idle sweeps must not answer 400.
|
|
19
|
+
export function respondNoMcpSession(res: ServerResponse, sessionId: string | undefined): true {
|
|
20
|
+
const notFound = Boolean(sessionId);
|
|
21
|
+
res.writeHead(notFound ? 404 : 400, { "Content-Type": "application/json" });
|
|
22
|
+
res.end(
|
|
23
|
+
JSON.stringify({
|
|
24
|
+
jsonrpc: "2.0",
|
|
25
|
+
error: notFound
|
|
26
|
+
? { code: -32001, message: "Session not found" }
|
|
27
|
+
: { code: -32000, message: "Bad Request: No valid session ID provided" },
|
|
28
|
+
id: null,
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
17
34
|
export function markMcpTransportActivity(
|
|
18
35
|
sessionActivity: McpTransportActivity,
|
|
19
36
|
sessionId: string | undefined,
|
|
@@ -234,15 +251,7 @@ export async function handleMcp(
|
|
|
234
251
|
});
|
|
235
252
|
await server.connect(transport);
|
|
236
253
|
} else {
|
|
237
|
-
res
|
|
238
|
-
res.end(
|
|
239
|
-
JSON.stringify({
|
|
240
|
-
jsonrpc: "2.0",
|
|
241
|
-
error: { code: -32000, message: "Invalid session" },
|
|
242
|
-
id: null,
|
|
243
|
-
}),
|
|
244
|
-
);
|
|
245
|
-
return true;
|
|
254
|
+
return respondNoMcpSession(res, sessionId);
|
|
246
255
|
}
|
|
247
256
|
|
|
248
257
|
await transport.handleRequest(req, res, body);
|
|
@@ -256,9 +265,7 @@ export async function handleMcp(
|
|
|
256
265
|
await transports[sessionId].handleRequest(req, res);
|
|
257
266
|
return true;
|
|
258
267
|
}
|
|
259
|
-
res
|
|
260
|
-
res.end("Invalid session");
|
|
261
|
-
return true;
|
|
268
|
+
return respondNoMcpSession(res, sessionId);
|
|
262
269
|
}
|
|
263
270
|
|
|
264
271
|
res.writeHead(405);
|