@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
|
@@ -2,33 +2,20 @@ import {
|
|
|
2
2
|
COMPOSIO_HTTP_METHODS,
|
|
3
3
|
composioArgsFromParts,
|
|
4
4
|
executeComposioRequest
|
|
5
|
-
} from "./cli-
|
|
5
|
+
} from "./cli-cat6h73s.js";
|
|
6
6
|
import {
|
|
7
7
|
LlmRater,
|
|
8
8
|
REFERENCES_SOURCE_MAX_LENGTH,
|
|
9
9
|
getMemoryRaterNames,
|
|
10
10
|
sanitizeReferencesSource
|
|
11
|
-
} from "./cli-
|
|
11
|
+
} from "./cli-w0bwte75.js";
|
|
12
12
|
import {
|
|
13
13
|
isMultiRuntimeEnabled
|
|
14
14
|
} from "./cli-re8z5p8p.js";
|
|
15
|
-
import {
|
|
16
|
-
AgentFsProvider,
|
|
17
|
-
getFileStorageProvider,
|
|
18
|
-
providerPath
|
|
19
|
-
} from "./cli-jsp14b6c.js";
|
|
20
15
|
import {
|
|
21
16
|
ensurePricingSeeded,
|
|
22
|
-
ensureRbacSeeded
|
|
23
|
-
|
|
24
|
-
} from "./cli-tzx2ke1v.js";
|
|
25
|
-
import {
|
|
26
|
-
can,
|
|
27
|
-
decideAdmission,
|
|
28
|
-
grantLeadEquivalence,
|
|
29
|
-
isRbacEnabled,
|
|
30
|
-
revokeLeadEquivalence
|
|
31
|
-
} from "./cli-tmqt7dpj.js";
|
|
17
|
+
ensureRbacSeeded
|
|
18
|
+
} from "./cli-wxkkd0e0.js";
|
|
32
19
|
import {
|
|
33
20
|
buildCatalogEntries,
|
|
34
21
|
getCatalogGeneration,
|
|
@@ -38,10 +25,10 @@ import {
|
|
|
38
25
|
requestModelCatalogRefresh,
|
|
39
26
|
startPricingRefreshLoop,
|
|
40
27
|
upsertModelCatalogOverlay
|
|
41
|
-
} from "./cli-
|
|
28
|
+
} from "./cli-zvhd3f64.js";
|
|
42
29
|
import {
|
|
43
30
|
loadModelsDevCache
|
|
44
|
-
} from "./cli-
|
|
31
|
+
} from "./cli-vy3ed88x.js";
|
|
45
32
|
import {
|
|
46
33
|
AppDefinitionSchema,
|
|
47
34
|
AppElementsSchema,
|
|
@@ -121,18 +108,45 @@ import {
|
|
|
121
108
|
validateDefinition,
|
|
122
109
|
validateScriptImports,
|
|
123
110
|
writeBareImportShim
|
|
124
|
-
} from "./cli-
|
|
111
|
+
} from "./cli-5xhpb3kv.js";
|
|
112
|
+
import {
|
|
113
|
+
getApiKey
|
|
114
|
+
} from "./cli-f14fvzag.js";
|
|
125
115
|
import {
|
|
126
116
|
detachedProcessGroup,
|
|
127
117
|
registerProcessGroup,
|
|
128
118
|
terminateProcessGroup
|
|
129
119
|
} from "./cli-y89t4nca.js";
|
|
130
120
|
import {
|
|
131
|
-
|
|
132
|
-
|
|
121
|
+
AgentFsProvider,
|
|
122
|
+
getFileStorageProvider,
|
|
123
|
+
providerPath
|
|
124
|
+
} from "./cli-mzfth0bp.js";
|
|
133
125
|
import {
|
|
134
126
|
embedScript
|
|
135
|
-
} from "./cli-
|
|
127
|
+
} from "./cli-sptrj5f5.js";
|
|
128
|
+
import {
|
|
129
|
+
CANDIDATE_SET_MULTIPLIER,
|
|
130
|
+
LONGTERM_ROOT,
|
|
131
|
+
MEMORY_KEY_MAX_LENGTH,
|
|
132
|
+
MEMORY_KEY_PATTERN,
|
|
133
|
+
MEMORY_KEY_PATTERN_MESSAGE,
|
|
134
|
+
computeScore,
|
|
135
|
+
consolidatedKeyMessage,
|
|
136
|
+
getEmbeddingProvider,
|
|
137
|
+
getMemoryStore,
|
|
138
|
+
init_constants as init_constants2,
|
|
139
|
+
init_key_paths,
|
|
140
|
+
init_reranker,
|
|
141
|
+
init_sqlite_store,
|
|
142
|
+
isConsolidatedKey,
|
|
143
|
+
isGraphExpansionEnabled,
|
|
144
|
+
isLongtermKey,
|
|
145
|
+
longtermKeyError,
|
|
146
|
+
rerank,
|
|
147
|
+
resolveStoreKey,
|
|
148
|
+
rowToCandidate
|
|
149
|
+
} from "./cli-5k6k8ta3.js";
|
|
136
150
|
import {
|
|
137
151
|
buildAuthorizationUrl,
|
|
138
152
|
createOAuthApp,
|
|
@@ -147,23 +161,11 @@ import {
|
|
|
147
161
|
listAuthorizationsForApp,
|
|
148
162
|
onAuthorizationRefreshed,
|
|
149
163
|
upsertOAuthApp
|
|
150
|
-
} from "./cli-
|
|
164
|
+
} from "./cli-kh04eqwe.js";
|
|
151
165
|
import {
|
|
152
166
|
ZodFirstPartyTypeKind,
|
|
153
167
|
objectType
|
|
154
168
|
} from "./cli-fad8m16k.js";
|
|
155
|
-
import {
|
|
156
|
-
CANDIDATE_SET_MULTIPLIER,
|
|
157
|
-
computeScore,
|
|
158
|
-
getEmbeddingProvider,
|
|
159
|
-
getMemoryStore,
|
|
160
|
-
init_constants as init_constants2,
|
|
161
|
-
init_reranker,
|
|
162
|
-
init_sqlite_store,
|
|
163
|
-
isGraphExpansionEnabled,
|
|
164
|
-
rerank,
|
|
165
|
-
rowToCandidate
|
|
166
|
-
} from "./cli-jz4w45qt.js";
|
|
167
169
|
import {
|
|
168
170
|
require_dist
|
|
169
171
|
} from "./cli-51tf7ac3.js";
|
|
@@ -189,13 +191,27 @@ import {
|
|
|
189
191
|
taskCitationWarnings,
|
|
190
192
|
upsertTaskCitations,
|
|
191
193
|
withSpan
|
|
192
|
-
} from "./cli-
|
|
194
|
+
} from "./cli-swfmp1fx.js";
|
|
193
195
|
import {
|
|
194
196
|
init_task_attachment_links,
|
|
195
197
|
taskAttachmentDisplayUrl,
|
|
196
198
|
taskAttachmentFetchCommand
|
|
197
|
-
} from "./cli-
|
|
199
|
+
} from "./cli-cvk6yzw5.js";
|
|
200
|
+
import {
|
|
201
|
+
getUserGrant,
|
|
202
|
+
init_rbac_roles
|
|
203
|
+
} from "./cli-2zy95vhm.js";
|
|
204
|
+
import {
|
|
205
|
+
can,
|
|
206
|
+
decideAdmission,
|
|
207
|
+
grantLeadEquivalence,
|
|
208
|
+
init_elevated_agents,
|
|
209
|
+
init_rbac,
|
|
210
|
+
isRbacEnabled,
|
|
211
|
+
revokeLeadEquivalence
|
|
212
|
+
} from "./cli-kdkwd3yr.js";
|
|
198
213
|
import {
|
|
214
|
+
API_DRAIN_MAX_MS_LIMIT,
|
|
199
215
|
CredentialBindingSchema,
|
|
200
216
|
EXTENSION_AGENT_ROLE,
|
|
201
217
|
KvTypeCollisionError,
|
|
@@ -204,6 +220,7 @@ import {
|
|
|
204
220
|
acceptTask,
|
|
205
221
|
agentContextKey,
|
|
206
222
|
agentmailContextKey,
|
|
223
|
+
azureDevOpsContextKey,
|
|
207
224
|
beginRequestAuthScope,
|
|
208
225
|
buildJiraContextKey,
|
|
209
226
|
buildRoutingAffinityFromAgent,
|
|
@@ -249,6 +266,7 @@ import {
|
|
|
249
266
|
deleteSwarmConfig,
|
|
250
267
|
deleteUser,
|
|
251
268
|
deleteWorkflow,
|
|
269
|
+
detachTaskFromWorkflowRunStep,
|
|
252
270
|
emitMcpServerConnectedTelemetry,
|
|
253
271
|
exports_db,
|
|
254
272
|
extensionAgentAssignmentError,
|
|
@@ -364,6 +382,7 @@ import {
|
|
|
364
382
|
incrKv,
|
|
365
383
|
incrementEmptyPollCount,
|
|
366
384
|
initDb,
|
|
385
|
+
init_api_drain,
|
|
367
386
|
init_context_key,
|
|
368
387
|
init_credential_broker,
|
|
369
388
|
init_date_utils,
|
|
@@ -376,7 +395,8 @@ import {
|
|
|
376
395
|
init_swarm_config_guard,
|
|
377
396
|
init_task_lifecycle_events,
|
|
378
397
|
init_telemetry,
|
|
379
|
-
|
|
398
|
+
init_telemetry_identity,
|
|
399
|
+
init_templates1 as init_templates,
|
|
380
400
|
insertTaskAttachment,
|
|
381
401
|
installMcpServer,
|
|
382
402
|
installSkill,
|
|
@@ -385,6 +405,7 @@ import {
|
|
|
385
405
|
isExtensionAgent,
|
|
386
406
|
isInTransaction,
|
|
387
407
|
isInternalConfigKey,
|
|
408
|
+
isLinearTrackerContextKey,
|
|
388
409
|
isReservedConfigKey,
|
|
389
410
|
isSteeringEnabled,
|
|
390
411
|
kvPrefixUpperBound,
|
|
@@ -423,6 +444,7 @@ import {
|
|
|
423
444
|
resolveWaitState,
|
|
424
445
|
runWithoutRequestAuth,
|
|
425
446
|
scheduleContextKey,
|
|
447
|
+
scheduleOrgDomainRecompute,
|
|
426
448
|
searchSkills,
|
|
427
449
|
setBudgetRefusalFollowUpTaskId,
|
|
428
450
|
setRequestAuth,
|
|
@@ -458,7 +480,7 @@ import {
|
|
|
458
480
|
upsertSwarmConfig,
|
|
459
481
|
validateConfigValue,
|
|
460
482
|
workflowContextKey
|
|
461
|
-
} from "./cli-
|
|
483
|
+
} from "./cli-jf7wmv1r.js";
|
|
462
484
|
import {
|
|
463
485
|
$OpenAPIRegistry,
|
|
464
486
|
$OpenApiGeneratorV31,
|
|
@@ -493,6 +515,7 @@ import {
|
|
|
493
515
|
ReasoningEffortSchema,
|
|
494
516
|
RepoGuidelinesInputSchema,
|
|
495
517
|
RepoHooksSchema,
|
|
518
|
+
RetryPolicySchema,
|
|
496
519
|
RoutingReasonSchema,
|
|
497
520
|
ScheduledTaskTargetTypeSchema,
|
|
498
521
|
ScriptRunStatusSchema,
|
|
@@ -505,6 +528,7 @@ import {
|
|
|
505
528
|
WorkflowNodePatchSchema,
|
|
506
529
|
WorkflowRunStatusSchema,
|
|
507
530
|
canWriteAssetKey,
|
|
531
|
+
checkExtensionInstallSource,
|
|
508
532
|
init_bundle_path,
|
|
509
533
|
init_dist,
|
|
510
534
|
init_key,
|
|
@@ -516,18 +540,30 @@ import {
|
|
|
516
540
|
parseAssetKey,
|
|
517
541
|
parseModelTier,
|
|
518
542
|
splitLegacyModelAlias
|
|
519
|
-
} from "./cli-
|
|
543
|
+
} from "./cli-xqpk3rp7.js";
|
|
520
544
|
import {
|
|
521
545
|
generateDefaultClaudeMd,
|
|
522
546
|
generateDefaultIdentityMd,
|
|
523
547
|
generateDefaultSoulMd,
|
|
524
548
|
init_defaults
|
|
525
|
-
} from "./cli-
|
|
549
|
+
} from "./cli-7af8yhav.js";
|
|
526
550
|
import {
|
|
527
551
|
getSlackConfiguration,
|
|
528
552
|
init_config,
|
|
529
553
|
isSlackConfigured
|
|
530
554
|
} from "./cli-n7h1kqpf.js";
|
|
555
|
+
import {
|
|
556
|
+
MAX_PROFILE_FILE_LENGTH,
|
|
557
|
+
getAgentFsDefaultDriveId,
|
|
558
|
+
getAgentFsDefaultOrgId,
|
|
559
|
+
getAgentFsLiveUrl,
|
|
560
|
+
getAppUrl,
|
|
561
|
+
getConfiguredAppUrls,
|
|
562
|
+
getMcpBaseUrl,
|
|
563
|
+
getPublicMcpBaseUrl,
|
|
564
|
+
init_constants,
|
|
565
|
+
isCombEnabled
|
|
566
|
+
} from "./cli-gd4favx9.js";
|
|
531
567
|
import {
|
|
532
568
|
deepInterpolate,
|
|
533
569
|
findInterpolationTokens,
|
|
@@ -538,14 +574,7 @@ import {
|
|
|
538
574
|
interpolate,
|
|
539
575
|
registerTemplate,
|
|
540
576
|
resolveTemplate
|
|
541
|
-
} from "./cli-
|
|
542
|
-
import {
|
|
543
|
-
MAX_PROFILE_FILE_LENGTH,
|
|
544
|
-
getAppUrl,
|
|
545
|
-
getMcpBaseUrl,
|
|
546
|
-
getPublicMcpBaseUrl,
|
|
547
|
-
init_constants
|
|
548
|
-
} from "./cli-dv6cdjs2.js";
|
|
577
|
+
} from "./cli-qjjvzwzd.js";
|
|
549
578
|
import {
|
|
550
579
|
init_env_flag,
|
|
551
580
|
isEnvFlagEnabled,
|
|
@@ -562,7 +591,7 @@ import {
|
|
|
562
591
|
modelFamilyKey,
|
|
563
592
|
parseAlias,
|
|
564
593
|
resolveAlias
|
|
565
|
-
} from "./cli-
|
|
594
|
+
} from "./cli-jyy6pm2f.js";
|
|
566
595
|
import {
|
|
567
596
|
exports_zod,
|
|
568
597
|
init_zod
|
|
@@ -611,7 +640,7 @@ import {
|
|
|
611
640
|
import {
|
|
612
641
|
init_package,
|
|
613
642
|
package_default
|
|
614
|
-
} from "./cli-
|
|
643
|
+
} from "./cli-sqvfa090.js";
|
|
615
644
|
import {
|
|
616
645
|
init_secret_scrubber,
|
|
617
646
|
isSensitiveKey,
|
|
@@ -619,7 +648,7 @@ import {
|
|
|
619
648
|
registerVolatileSecret,
|
|
620
649
|
scrubObject,
|
|
621
650
|
scrubSecrets
|
|
622
|
-
} from "./cli-
|
|
651
|
+
} from "./cli-nexqx4ve.js";
|
|
623
652
|
import {
|
|
624
653
|
init_event_bus,
|
|
625
654
|
workflowEventBus
|
|
@@ -14350,7 +14379,7 @@ async function notifyAutomationPreflightFailure(preflight) {
|
|
|
14350
14379
|
return;
|
|
14351
14380
|
}
|
|
14352
14381
|
try {
|
|
14353
|
-
const { getSlackApp: getSlackApp2 } = await import("./app-
|
|
14382
|
+
const { getSlackApp: getSlackApp2 } = await import("./app-pt68fbwp.js");
|
|
14354
14383
|
const app = getSlackApp2();
|
|
14355
14384
|
if (!app) {
|
|
14356
14385
|
console.warn("[Automation Preflight] Slack not available, cannot send notification");
|
|
@@ -16148,12 +16177,19 @@ function computeNextPort(mode, status) {
|
|
|
16148
16177
|
|
|
16149
16178
|
// src/workflows/task-step-routing.ts
|
|
16150
16179
|
init_db();
|
|
16151
|
-
|
|
16180
|
+
init_types();
|
|
16181
|
+
async function isTaskBoundToStep(taskId, stepId) {
|
|
16182
|
+
const task = await getTaskById(taskId);
|
|
16183
|
+
return task?.workflowRunStepId === stepId;
|
|
16184
|
+
}
|
|
16185
|
+
async function failStepAndRunIfWaiting(stepId, runId, reason, ownerTaskId) {
|
|
16152
16186
|
const now = new Date().toISOString();
|
|
16153
16187
|
return await getDbClient().transaction(async () => {
|
|
16154
16188
|
const current = await getWorkflowRunStep(stepId);
|
|
16155
16189
|
if (!current || current.status !== "waiting")
|
|
16156
16190
|
return false;
|
|
16191
|
+
if (ownerTaskId && !await isTaskBoundToStep(ownerTaskId, stepId))
|
|
16192
|
+
return false;
|
|
16157
16193
|
await updateWorkflowRunStep(stepId, {
|
|
16158
16194
|
status: "failed",
|
|
16159
16195
|
error: reason,
|
|
@@ -16177,17 +16213,40 @@ async function checkpointPortStepAndResolveSuccessors(def, runId, stepId, nodeId
|
|
|
16177
16213
|
return { claimed: true, successors: getSuccessors(def, nodeId, nextPort) };
|
|
16178
16214
|
});
|
|
16179
16215
|
}
|
|
16216
|
+
async function scheduleTaskStepRetry(def, runId, step, taskId, reason) {
|
|
16217
|
+
const node = def.nodes.find((n) => n.id === step.nodeId);
|
|
16218
|
+
if (!node || node.type !== "agent-task" || !node.retry)
|
|
16219
|
+
return "not-eligible";
|
|
16220
|
+
const parsed = RetryPolicySchema.safeParse(node.retry);
|
|
16221
|
+
if (!parsed.success)
|
|
16222
|
+
return "not-eligible";
|
|
16223
|
+
const policy = parsed.data;
|
|
16224
|
+
return await getDbClient().transaction(async () => {
|
|
16225
|
+
const current = await getWorkflowRunStep(step.id);
|
|
16226
|
+
if (!current || current.status !== "waiting")
|
|
16227
|
+
return "not-claimed";
|
|
16228
|
+
if (!await isTaskBoundToStep(taskId, step.id))
|
|
16229
|
+
return "not-claimed";
|
|
16230
|
+
if (current.retryCount >= policy.maxRetries)
|
|
16231
|
+
return "not-eligible";
|
|
16232
|
+
await detachTaskFromWorkflowRunStep(taskId);
|
|
16233
|
+
await checkpointStepFailure(runId, step.id, reason, current.retryCount, policy);
|
|
16234
|
+
return "scheduled";
|
|
16235
|
+
});
|
|
16236
|
+
}
|
|
16180
16237
|
var UNCLAIMED = {
|
|
16181
16238
|
claimed: false,
|
|
16182
16239
|
foreachChild: false,
|
|
16183
16240
|
joined: false,
|
|
16184
16241
|
successors: []
|
|
16185
16242
|
};
|
|
16186
|
-
async function completeTaskStepAndResolveSuccessors(def, runId, step, output, ctx, failureReason) {
|
|
16243
|
+
async function completeTaskStepAndResolveSuccessors(def, runId, step, output, ctx, failureReason, ownerTaskId) {
|
|
16187
16244
|
return await getDbClient().transaction(async () => {
|
|
16188
16245
|
const current = await getWorkflowRunStep(step.id);
|
|
16189
16246
|
if (!current || current.status !== "waiting")
|
|
16190
16247
|
return UNCLAIMED;
|
|
16248
|
+
if (ownerTaskId && !await isTaskBoundToStep(ownerTaskId, step.id))
|
|
16249
|
+
return UNCLAIMED;
|
|
16191
16250
|
const foreachParent = resolveForeachParent(def, step.nodeId);
|
|
16192
16251
|
if (foreachParent) {
|
|
16193
16252
|
await updateWorkflowRunStep(step.id, {
|
|
@@ -16234,7 +16293,9 @@ function setupWorkflowResumeListener(eventBus, registry) {
|
|
|
16234
16293
|
const event = data;
|
|
16235
16294
|
if (!event.workflowRunId || !event.workflowRunStepId)
|
|
16236
16295
|
return;
|
|
16237
|
-
await handleTaskFailure(event, event.failureReason ?? "Task failed", registry
|
|
16296
|
+
await handleTaskFailure(event, event.failureReason ?? "Task failed", registry, {
|
|
16297
|
+
retryable: true
|
|
16298
|
+
});
|
|
16238
16299
|
} catch (err) {
|
|
16239
16300
|
console.error("[workflows] Handle task failure error:", err);
|
|
16240
16301
|
}
|
|
@@ -16245,7 +16306,7 @@ function setupWorkflowResumeListener(eventBus, registry) {
|
|
|
16245
16306
|
const event = data;
|
|
16246
16307
|
if (!event.workflowRunId || !event.workflowRunStepId)
|
|
16247
16308
|
return;
|
|
16248
|
-
await handleTaskFailure(event, "Task was cancelled", registry);
|
|
16309
|
+
await handleTaskFailure(event, "Task was cancelled", registry, { retryable: false });
|
|
16249
16310
|
} catch (err) {
|
|
16250
16311
|
console.error("[workflows] Handle task cancellation error:", err);
|
|
16251
16312
|
}
|
|
@@ -16312,7 +16373,7 @@ async function finalizeOrWait(runId) {
|
|
|
16312
16373
|
await updateWorkflowRun(runId, { status: "running" });
|
|
16313
16374
|
return;
|
|
16314
16375
|
}
|
|
16315
|
-
const hasWaiting = steps.some((s) => s.status === "waiting");
|
|
16376
|
+
const hasWaiting = steps.some((s) => s.status === "waiting" || s.status === "failed" && s.nextRetryAt != null);
|
|
16316
16377
|
if (hasWaiting) {
|
|
16317
16378
|
await updateWorkflowRun(runId, { status: "waiting" });
|
|
16318
16379
|
} else {
|
|
@@ -16323,7 +16384,7 @@ async function finalizeOrWait(runId) {
|
|
|
16323
16384
|
}
|
|
16324
16385
|
});
|
|
16325
16386
|
}
|
|
16326
|
-
async function handleTaskFailure(event, reason, registry) {
|
|
16387
|
+
async function handleTaskFailure(event, reason, registry, options) {
|
|
16327
16388
|
const run = await getWorkflowRun(event.workflowRunId);
|
|
16328
16389
|
if (!run || run.status !== "waiting" && run.status !== "running")
|
|
16329
16390
|
return;
|
|
@@ -16335,6 +16396,15 @@ async function handleTaskFailure(event, reason, registry) {
|
|
|
16335
16396
|
const workflow = await getWorkflow(run.workflowId);
|
|
16336
16397
|
if (!workflow)
|
|
16337
16398
|
return;
|
|
16399
|
+
if (options.retryable) {
|
|
16400
|
+
const retry = await scheduleTaskStepRetry(workflow.definition, run.id, step, event.taskId, reason);
|
|
16401
|
+
if (retry === "scheduled") {
|
|
16402
|
+
console.log(`[workflows] Task ${event.taskId} failed; step ${step.nodeId} of run ${run.id} queued for retry ${step.retryCount + 1}`);
|
|
16403
|
+
return;
|
|
16404
|
+
}
|
|
16405
|
+
if (retry === "not-claimed")
|
|
16406
|
+
return;
|
|
16407
|
+
}
|
|
16338
16408
|
const onFailure = workflow.definition.onNodeFailure ?? "fail";
|
|
16339
16409
|
if (onFailure === "fail") {
|
|
16340
16410
|
await markRunFailed(event, reason);
|
|
@@ -16720,9 +16790,19 @@ async function recoverWaitingRuns(registry) {
|
|
|
16720
16790
|
if (!run || run.status !== "waiting" || !workflow)
|
|
16721
16791
|
continue;
|
|
16722
16792
|
const taskCompleted = stuck.taskStatus === "completed";
|
|
16793
|
+
if (stuck.taskStatus === "failed") {
|
|
16794
|
+
const failedStep = await getWorkflowRunStep(stuck.stepId);
|
|
16795
|
+
if (!failedStep)
|
|
16796
|
+
continue;
|
|
16797
|
+
const retry = await scheduleTaskStepRetry(workflow.definition, stuck.runId, failedStep, stuck.taskId, "Task failed (recovered)");
|
|
16798
|
+
if (retry === "scheduled")
|
|
16799
|
+
recovered++;
|
|
16800
|
+
if (retry !== "not-eligible")
|
|
16801
|
+
continue;
|
|
16802
|
+
}
|
|
16723
16803
|
if (!taskCompleted && (workflow.definition.onNodeFailure ?? "fail") === "fail") {
|
|
16724
16804
|
const reason2 = stuck.taskStatus === "failed" ? "Task failed (recovered)" : "Task cancelled (recovered)";
|
|
16725
|
-
const claimed = await failStepAndRunIfWaiting(stuck.stepId, stuck.runId, reason2);
|
|
16805
|
+
const claimed = await failStepAndRunIfWaiting(stuck.stepId, stuck.runId, reason2, stuck.taskId);
|
|
16726
16806
|
if (!claimed)
|
|
16727
16807
|
continue;
|
|
16728
16808
|
recovered++;
|
|
@@ -16737,7 +16817,7 @@ async function recoverWaitingRuns(registry) {
|
|
|
16737
16817
|
const step = await getWorkflowRunStep(stuck.stepId);
|
|
16738
16818
|
if (!step)
|
|
16739
16819
|
continue;
|
|
16740
|
-
const routing = await completeTaskStepAndResolveSuccessors(workflow.definition, stuck.runId, step, stepOutput, ctx, taskCompleted ? undefined : reason);
|
|
16820
|
+
const routing = await completeTaskStepAndResolveSuccessors(workflow.definition, stuck.runId, step, stepOutput, ctx, taskCompleted ? undefined : reason, stuck.taskId);
|
|
16741
16821
|
if (!routing.claimed)
|
|
16742
16822
|
continue;
|
|
16743
16823
|
if (routing.foreachChild && !routing.joined) {
|
|
@@ -19670,6 +19750,7 @@ async function listExtensionRuns(extensionId, limit = 100) {
|
|
|
19670
19750
|
}
|
|
19671
19751
|
|
|
19672
19752
|
// src/extensions/dispatcher.ts
|
|
19753
|
+
init_elevated_agents();
|
|
19673
19754
|
init_secret_scrubber();
|
|
19674
19755
|
|
|
19675
19756
|
// node_modules/zod/v4/mini/external.js
|
|
@@ -24152,6 +24233,10 @@ init_steering();
|
|
|
24152
24233
|
|
|
24153
24234
|
// src/github/task-reactions.ts
|
|
24154
24235
|
init_task_lifecycle_events();
|
|
24236
|
+
init_secret_scrubber();
|
|
24237
|
+
|
|
24238
|
+
// src/github/reactions.ts
|
|
24239
|
+
init_secret_scrubber();
|
|
24155
24240
|
|
|
24156
24241
|
// src/github/app.ts
|
|
24157
24242
|
var initialized = false;
|
|
@@ -24303,18 +24388,25 @@ async function getInstallationToken(installationId) {
|
|
|
24303
24388
|
}
|
|
24304
24389
|
|
|
24305
24390
|
// src/github/reactions.ts
|
|
24306
|
-
async function
|
|
24307
|
-
if (
|
|
24308
|
-
|
|
24309
|
-
|
|
24310
|
-
|
|
24311
|
-
|
|
24312
|
-
|
|
24313
|
-
|
|
24391
|
+
async function resolveReactionToken(installationId) {
|
|
24392
|
+
if (installationId && isReactionsEnabled()) {
|
|
24393
|
+
const appToken = await getInstallationToken(installationId);
|
|
24394
|
+
if (appToken)
|
|
24395
|
+
return appToken;
|
|
24396
|
+
console.log("[GitHub] No installation token, trying GITHUB_TOKEN for reaction");
|
|
24397
|
+
}
|
|
24398
|
+
const pat = process.env.GITHUB_TOKEN?.trim();
|
|
24399
|
+
if (pat)
|
|
24400
|
+
return pat;
|
|
24401
|
+
console.log("[GitHub] No App installation and no GITHUB_TOKEN, skipping reaction");
|
|
24402
|
+
return null;
|
|
24403
|
+
}
|
|
24404
|
+
async function postRestReaction(repo, target, reaction, installationId, label) {
|
|
24405
|
+
const token = await resolveReactionToken(installationId);
|
|
24406
|
+
if (!token)
|
|
24314
24407
|
return false;
|
|
24315
|
-
}
|
|
24316
24408
|
try {
|
|
24317
|
-
const response = await fetch(`https://api.github.com/repos/${repo}
|
|
24409
|
+
const response = await fetch(`https://api.github.com/repos/${repo}/${target}/reactions`, {
|
|
24318
24410
|
method: "POST",
|
|
24319
24411
|
headers: {
|
|
24320
24412
|
Accept: "application/vnd.github+json",
|
|
@@ -24326,92 +24418,29 @@ async function addReaction(repo, commentId, reaction, installationId) {
|
|
|
24326
24418
|
});
|
|
24327
24419
|
if (!response.ok) {
|
|
24328
24420
|
const errorText2 = await response.text();
|
|
24329
|
-
console.error(`[GitHub] Failed to add reaction: ${response.status} ${errorText2}`);
|
|
24421
|
+
console.error(`[GitHub] Failed to add ${label} reaction: ${response.status} ${scrubSecrets(errorText2)}`);
|
|
24330
24422
|
return false;
|
|
24331
24423
|
}
|
|
24332
|
-
console.log(`[GitHub] Added ${reaction} reaction to
|
|
24424
|
+
console.log(`[GitHub] Added ${reaction} reaction to ${label}`);
|
|
24333
24425
|
return true;
|
|
24334
24426
|
} catch (error) {
|
|
24335
|
-
console.error(
|
|
24427
|
+
console.error(`[GitHub] Error adding ${label} reaction:`, scrubSecrets(error instanceof Error ? error.message : String(error)));
|
|
24336
24428
|
return false;
|
|
24337
24429
|
}
|
|
24338
24430
|
}
|
|
24431
|
+
async function addReaction(repo, commentId, reaction, installationId) {
|
|
24432
|
+
return postRestReaction(repo, `issues/comments/${commentId}`, reaction, installationId, `comment ${commentId}`);
|
|
24433
|
+
}
|
|
24339
24434
|
async function addIssueReaction(repo, issueNumber, reaction, installationId) {
|
|
24340
|
-
|
|
24341
|
-
console.log("[GitHub] Reactions not enabled, skipping");
|
|
24342
|
-
return false;
|
|
24343
|
-
}
|
|
24344
|
-
const token = await getInstallationToken(installationId);
|
|
24345
|
-
if (!token) {
|
|
24346
|
-
console.log("[GitHub] No installation token, skipping reaction");
|
|
24347
|
-
return false;
|
|
24348
|
-
}
|
|
24349
|
-
try {
|
|
24350
|
-
const response = await fetch(`https://api.github.com/repos/${repo}/issues/${issueNumber}/reactions`, {
|
|
24351
|
-
method: "POST",
|
|
24352
|
-
headers: {
|
|
24353
|
-
Accept: "application/vnd.github+json",
|
|
24354
|
-
Authorization: `Bearer ${token}`,
|
|
24355
|
-
"X-GitHub-Api-Version": "2022-11-28",
|
|
24356
|
-
"Content-Type": "application/json"
|
|
24357
|
-
},
|
|
24358
|
-
body: JSON.stringify({ content: reaction })
|
|
24359
|
-
});
|
|
24360
|
-
if (!response.ok) {
|
|
24361
|
-
const errorText2 = await response.text();
|
|
24362
|
-
console.error(`[GitHub] Failed to add issue reaction: ${response.status} ${errorText2}`);
|
|
24363
|
-
return false;
|
|
24364
|
-
}
|
|
24365
|
-
console.log(`[GitHub] Added ${reaction} reaction to issue/PR #${issueNumber}`);
|
|
24366
|
-
return true;
|
|
24367
|
-
} catch (error) {
|
|
24368
|
-
console.error("[GitHub] Error adding issue reaction:", error);
|
|
24369
|
-
return false;
|
|
24370
|
-
}
|
|
24435
|
+
return postRestReaction(repo, `issues/${issueNumber}`, reaction, installationId, `issue/PR #${issueNumber}`);
|
|
24371
24436
|
}
|
|
24372
24437
|
async function addPullReviewCommentReaction(repo, commentId, reaction, installationId) {
|
|
24373
|
-
|
|
24374
|
-
console.log("[GitHub] Reactions not enabled, skipping");
|
|
24375
|
-
return false;
|
|
24376
|
-
}
|
|
24377
|
-
const token = await getInstallationToken(installationId);
|
|
24378
|
-
if (!token) {
|
|
24379
|
-
console.log("[GitHub] No installation token, skipping reaction");
|
|
24380
|
-
return false;
|
|
24381
|
-
}
|
|
24382
|
-
try {
|
|
24383
|
-
const response = await fetch(`https://api.github.com/repos/${repo}/pulls/comments/${commentId}/reactions`, {
|
|
24384
|
-
method: "POST",
|
|
24385
|
-
headers: {
|
|
24386
|
-
Accept: "application/vnd.github+json",
|
|
24387
|
-
Authorization: `Bearer ${token}`,
|
|
24388
|
-
"X-GitHub-Api-Version": "2022-11-28",
|
|
24389
|
-
"Content-Type": "application/json"
|
|
24390
|
-
},
|
|
24391
|
-
body: JSON.stringify({ content: reaction })
|
|
24392
|
-
});
|
|
24393
|
-
if (!response.ok) {
|
|
24394
|
-
const errorText2 = await response.text();
|
|
24395
|
-
console.error(`[GitHub] Failed to add PR review comment reaction: ${response.status} ${errorText2}`);
|
|
24396
|
-
return false;
|
|
24397
|
-
}
|
|
24398
|
-
console.log(`[GitHub] Added ${reaction} reaction to PR review comment ${commentId}`);
|
|
24399
|
-
return true;
|
|
24400
|
-
} catch (error) {
|
|
24401
|
-
console.error("[GitHub] Error adding PR review comment reaction:", error);
|
|
24402
|
-
return false;
|
|
24403
|
-
}
|
|
24438
|
+
return postRestReaction(repo, `pulls/comments/${commentId}`, reaction, installationId, `PR review comment ${commentId}`);
|
|
24404
24439
|
}
|
|
24405
24440
|
async function addGraphQLReaction(nodeId, reaction, installationId) {
|
|
24406
|
-
|
|
24407
|
-
|
|
24408
|
-
return false;
|
|
24409
|
-
}
|
|
24410
|
-
const token = await getInstallationToken(installationId);
|
|
24411
|
-
if (!token) {
|
|
24412
|
-
console.log("[GitHub] No installation token, skipping GraphQL reaction");
|
|
24441
|
+
const token = await resolveReactionToken(installationId);
|
|
24442
|
+
if (!token)
|
|
24413
24443
|
return false;
|
|
24414
|
-
}
|
|
24415
24444
|
try {
|
|
24416
24445
|
const response = await fetch("https://api.github.com/graphql", {
|
|
24417
24446
|
method: "POST",
|
|
@@ -24432,28 +24461,26 @@ async function addGraphQLReaction(nodeId, reaction, installationId) {
|
|
|
24432
24461
|
});
|
|
24433
24462
|
if (!response.ok) {
|
|
24434
24463
|
const errorText2 = await response.text();
|
|
24435
|
-
console.error(`[GitHub] GraphQL reaction failed: ${response.status} ${errorText2}`);
|
|
24464
|
+
console.error(`[GitHub] GraphQL reaction failed: ${response.status} ${scrubSecrets(errorText2)}`);
|
|
24436
24465
|
return false;
|
|
24437
24466
|
}
|
|
24438
24467
|
const data = await response.json();
|
|
24439
24468
|
if (data.errors?.length) {
|
|
24440
|
-
console.error(`[GitHub] GraphQL reaction errors: ${JSON.stringify(data.errors)}`);
|
|
24469
|
+
console.error(`[GitHub] GraphQL reaction errors: ${scrubSecrets(JSON.stringify(data.errors))}`);
|
|
24441
24470
|
return false;
|
|
24442
24471
|
}
|
|
24443
24472
|
console.log(`[GitHub] Added ${reaction} GraphQL reaction to node ${nodeId}`);
|
|
24444
24473
|
return true;
|
|
24445
24474
|
} catch (error) {
|
|
24446
|
-
console.error("[GitHub] Error adding GraphQL reaction:", error);
|
|
24475
|
+
console.error("[GitHub] Error adding GraphQL reaction:", scrubSecrets(error instanceof Error ? error.message : String(error)));
|
|
24447
24476
|
return false;
|
|
24448
24477
|
}
|
|
24449
24478
|
}
|
|
24450
24479
|
|
|
24451
24480
|
// src/github/task-reactions.ts
|
|
24452
|
-
async function
|
|
24481
|
+
async function addEyesReactionToTaskSource(task) {
|
|
24453
24482
|
if (task.source !== "github" || task.vcsProvider !== "github")
|
|
24454
24483
|
return;
|
|
24455
|
-
if (!task.vcsInstallationId)
|
|
24456
|
-
return;
|
|
24457
24484
|
const installationId = task.vcsInstallationId;
|
|
24458
24485
|
const repo = task.vcsRepo;
|
|
24459
24486
|
if (!repo)
|
|
@@ -24475,6 +24502,8 @@ async function addEyesReactionOnTaskStart(task) {
|
|
|
24475
24502
|
case "pull_request_review": {
|
|
24476
24503
|
if (task.vcsNodeId) {
|
|
24477
24504
|
await addGraphQLReaction(task.vcsNodeId, "EYES", installationId);
|
|
24505
|
+
} else if (task.vcsNumber) {
|
|
24506
|
+
await addIssueReaction(repo, task.vcsNumber, "eyes", installationId);
|
|
24478
24507
|
}
|
|
24479
24508
|
break;
|
|
24480
24509
|
}
|
|
@@ -24487,9 +24516,12 @@ async function addEyesReactionOnTaskStart(task) {
|
|
|
24487
24516
|
}
|
|
24488
24517
|
}
|
|
24489
24518
|
} catch (error) {
|
|
24490
|
-
console.error("[GitHub] Failed to add eyes reaction
|
|
24519
|
+
console.error("[GitHub] Failed to add eyes reaction:", scrubSecrets(error instanceof Error ? error.message : String(error)));
|
|
24491
24520
|
}
|
|
24492
24521
|
}
|
|
24522
|
+
async function addEyesReactionOnTaskStart(task) {
|
|
24523
|
+
await addEyesReactionToTaskSource(task);
|
|
24524
|
+
}
|
|
24493
24525
|
var registered = false;
|
|
24494
24526
|
function registerGithubTaskReactions() {
|
|
24495
24527
|
if (registered)
|
|
@@ -24552,6 +24584,7 @@ function verifyAgentMailWebhook(rawBody, headers) {
|
|
|
24552
24584
|
init_db();
|
|
24553
24585
|
|
|
24554
24586
|
// src/be/users.ts
|
|
24587
|
+
init_telemetry_identity();
|
|
24555
24588
|
init_db();
|
|
24556
24589
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
24557
24590
|
function actorString(actor) {
|
|
@@ -24695,6 +24728,7 @@ async function findOrCreateUserByEmail(email, hints, actor) {
|
|
|
24695
24728
|
await recordIdentityEvent(id, "identity_added", actor, null, { email, name });
|
|
24696
24729
|
return rowToUser(row);
|
|
24697
24730
|
});
|
|
24731
|
+
getDbClient().afterCommit(scheduleOrgDomainRecompute);
|
|
24698
24732
|
return { user: created, created: true };
|
|
24699
24733
|
}
|
|
24700
24734
|
async function linkIdentity(userId, kind, externalId, actor) {
|
|
@@ -25352,6 +25386,510 @@ async function handleMessageReceived(payload) {
|
|
|
25352
25386
|
console.log(`[AgentMail] Created unassigned task ${task.id} (no lead or mapping available)`);
|
|
25353
25387
|
return { created: true, taskId: task.id };
|
|
25354
25388
|
}
|
|
25389
|
+
// src/azure-devops/auth.ts
|
|
25390
|
+
init_env_flag();
|
|
25391
|
+
var initialized3 = false;
|
|
25392
|
+
var webhookSecret3 = null;
|
|
25393
|
+
var apiToken = null;
|
|
25394
|
+
var orgUrl = null;
|
|
25395
|
+
function isAzureDevOpsEnabled() {
|
|
25396
|
+
return !!process.env.AZURE_DEVOPS_WEBHOOK_SECRET && !isEnvFlagEnabled("AZURE_DEVOPS_DISABLE", false);
|
|
25397
|
+
}
|
|
25398
|
+
function initAzureDevOps() {
|
|
25399
|
+
if (initialized3)
|
|
25400
|
+
return;
|
|
25401
|
+
if (!isAzureDevOpsEnabled()) {
|
|
25402
|
+
console.log("[AzureDevOps] Integration disabled (AZURE_DEVOPS_WEBHOOK_SECRET not set)");
|
|
25403
|
+
return;
|
|
25404
|
+
}
|
|
25405
|
+
webhookSecret3 = process.env.AZURE_DEVOPS_WEBHOOK_SECRET;
|
|
25406
|
+
apiToken = process.env.AZURE_DEVOPS_TOKEN ?? null;
|
|
25407
|
+
orgUrl = normalizeOrgUrl(process.env.AZURE_DEVOPS_ORG_URL);
|
|
25408
|
+
initialized3 = true;
|
|
25409
|
+
console.log(`[AzureDevOps] Integration initialized (org: ${orgUrl ?? "from payload"})`);
|
|
25410
|
+
}
|
|
25411
|
+
function verifyAzureDevOpsWebhook(authorizationHeader) {
|
|
25412
|
+
if (!webhookSecret3)
|
|
25413
|
+
return false;
|
|
25414
|
+
if (!authorizationHeader?.startsWith("Basic "))
|
|
25415
|
+
return false;
|
|
25416
|
+
const decoded = Buffer.from(authorizationHeader.slice("Basic ".length), "base64").toString();
|
|
25417
|
+
const separator = decoded.indexOf(":");
|
|
25418
|
+
if (separator === -1)
|
|
25419
|
+
return false;
|
|
25420
|
+
const password = decoded.slice(separator + 1);
|
|
25421
|
+
if (password.length !== webhookSecret3.length)
|
|
25422
|
+
return false;
|
|
25423
|
+
return crypto.timingSafeEqual(Buffer.from(password), Buffer.from(webhookSecret3));
|
|
25424
|
+
}
|
|
25425
|
+
function getAzureDevOpsToken() {
|
|
25426
|
+
return apiToken;
|
|
25427
|
+
}
|
|
25428
|
+
function getAzureDevOpsOrgUrl() {
|
|
25429
|
+
return orgUrl;
|
|
25430
|
+
}
|
|
25431
|
+
function normalizeOrgUrl(url) {
|
|
25432
|
+
const trimmed = url?.trim().replace(/\/+$/, "");
|
|
25433
|
+
return trimmed ? trimmed : null;
|
|
25434
|
+
}
|
|
25435
|
+
var AZURE_DEVOPS_BOT_NAME = process.env.AZURE_DEVOPS_BOT_NAME ?? "agent-swarm-bot";
|
|
25436
|
+
function resetAzureDevOps() {
|
|
25437
|
+
initialized3 = false;
|
|
25438
|
+
webhookSecret3 = null;
|
|
25439
|
+
apiToken = null;
|
|
25440
|
+
orgUrl = null;
|
|
25441
|
+
}
|
|
25442
|
+
|
|
25443
|
+
// src/azure-devops/api.ts
|
|
25444
|
+
var API_VERSION = "7.1";
|
|
25445
|
+
function headers() {
|
|
25446
|
+
const token = getAzureDevOpsToken();
|
|
25447
|
+
if (!token)
|
|
25448
|
+
throw new Error("[AzureDevOps] No API token configured");
|
|
25449
|
+
return {
|
|
25450
|
+
Authorization: `Basic ${Buffer.from(`:${token}`).toString("base64")}`,
|
|
25451
|
+
"Content-Type": "application/json",
|
|
25452
|
+
Accept: "application/json"
|
|
25453
|
+
};
|
|
25454
|
+
}
|
|
25455
|
+
function pullRequestBase(ref) {
|
|
25456
|
+
return `${ref.orgUrl}/${encodeURIComponent(ref.projectId)}/_apis/git/repositories/` + `${encodeURIComponent(ref.repositoryId)}/pullRequests/${ref.pullRequestId}`;
|
|
25457
|
+
}
|
|
25458
|
+
var cachedBotId = null;
|
|
25459
|
+
async function resolveAzureDevOpsBotId(orgBaseUrl) {
|
|
25460
|
+
const fromEnv = process.env.AZURE_DEVOPS_BOT_ID?.trim();
|
|
25461
|
+
if (fromEnv)
|
|
25462
|
+
return fromEnv;
|
|
25463
|
+
const orgUrl2 = normalizeOrgUrl(orgBaseUrl) ?? getAzureDevOpsOrgUrl();
|
|
25464
|
+
if (!orgUrl2 || !getAzureDevOpsToken())
|
|
25465
|
+
return null;
|
|
25466
|
+
if (cachedBotId?.orgUrl === orgUrl2)
|
|
25467
|
+
return cachedBotId.id;
|
|
25468
|
+
try {
|
|
25469
|
+
const resp = await fetch(`${orgUrl2}/_apis/connectionData`, { headers: headers() });
|
|
25470
|
+
if (!resp.ok) {
|
|
25471
|
+
console.error(`[AzureDevOps] Failed to resolve bot identity: ${resp.status}`);
|
|
25472
|
+
return null;
|
|
25473
|
+
}
|
|
25474
|
+
const data = await resp.json();
|
|
25475
|
+
const id = data.authenticatedUser?.id;
|
|
25476
|
+
if (!id)
|
|
25477
|
+
return null;
|
|
25478
|
+
cachedBotId = { orgUrl: orgUrl2, id };
|
|
25479
|
+
return id;
|
|
25480
|
+
} catch (err) {
|
|
25481
|
+
console.error(`[AzureDevOps] Error resolving bot identity:`, err);
|
|
25482
|
+
return null;
|
|
25483
|
+
}
|
|
25484
|
+
}
|
|
25485
|
+
function resetAzureDevOpsBotIdCache() {
|
|
25486
|
+
cachedBotId = null;
|
|
25487
|
+
}
|
|
25488
|
+
async function likeAzureDevOpsComment(ref, threadId, commentId) {
|
|
25489
|
+
const url = `${pullRequestBase(ref)}/threads/${threadId}/comments/${commentId}/likes?api-version=${API_VERSION}`;
|
|
25490
|
+
try {
|
|
25491
|
+
const resp = await fetch(url, { method: "POST", headers: headers() });
|
|
25492
|
+
if (!resp.ok) {
|
|
25493
|
+
console.error(`[AzureDevOps] Failed to like comment: ${resp.status} ${await resp.text()}`);
|
|
25494
|
+
}
|
|
25495
|
+
} catch (err) {
|
|
25496
|
+
console.error(`[AzureDevOps] Error liking comment:`, err);
|
|
25497
|
+
}
|
|
25498
|
+
}
|
|
25499
|
+
// src/azure-devops/handlers.ts
|
|
25500
|
+
init_db();
|
|
25501
|
+
init_resolver();
|
|
25502
|
+
init_context_key();
|
|
25503
|
+
|
|
25504
|
+
// src/vcs/azure-devops.ts
|
|
25505
|
+
function isAzureDevOpsUrl(url) {
|
|
25506
|
+
return /(^|[/@.])dev\.azure\.com[/:]|\.visualstudio\.com[/:]/i.test(url);
|
|
25507
|
+
}
|
|
25508
|
+
function canonicalAzureDevOpsRepoUrl(url) {
|
|
25509
|
+
const trimmed = url.trim();
|
|
25510
|
+
const ssh = trimmed.match(/^(?:ssh:\/\/)?[^@]+@ssh\.dev\.azure\.com[:/]v3\/([^/]+)\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/);
|
|
25511
|
+
if (ssh)
|
|
25512
|
+
return `https://dev.azure.com/${ssh[1]}/${ssh[2]}/_git/${ssh[3]}`;
|
|
25513
|
+
let parsed;
|
|
25514
|
+
try {
|
|
25515
|
+
parsed = new URL(trimmed);
|
|
25516
|
+
} catch {
|
|
25517
|
+
return trimmed;
|
|
25518
|
+
}
|
|
25519
|
+
parsed.username = "";
|
|
25520
|
+
parsed.password = "";
|
|
25521
|
+
parsed.search = "";
|
|
25522
|
+
parsed.hash = "";
|
|
25523
|
+
const parts = parsed.pathname.replace(/\.git\/?$/, "").split("/").filter(Boolean);
|
|
25524
|
+
if (parsed.hostname === "dev.azure.com" && parts.length === 3 && parts[1] === "_git") {
|
|
25525
|
+
parts.splice(1, 0, parts[2]);
|
|
25526
|
+
}
|
|
25527
|
+
parsed.pathname = `/${parts.join("/")}`;
|
|
25528
|
+
return parsed.toString().replace(/\/+$/, "");
|
|
25529
|
+
}
|
|
25530
|
+
function parseAzureDevOpsRepoUrl(url) {
|
|
25531
|
+
const canonical = canonicalAzureDevOpsRepoUrl(url);
|
|
25532
|
+
let parsed;
|
|
25533
|
+
try {
|
|
25534
|
+
parsed = new URL(canonical);
|
|
25535
|
+
} catch {
|
|
25536
|
+
return null;
|
|
25537
|
+
}
|
|
25538
|
+
const parts = parsed.pathname.split("/").filter(Boolean);
|
|
25539
|
+
const gitIndex = parts.indexOf("_git");
|
|
25540
|
+
const repository = parts[gitIndex + 1];
|
|
25541
|
+
if (gitIndex < 1 || !repository) {
|
|
25542
|
+
if (gitIndex === 0 && repository) {
|
|
25543
|
+
return { orgUrl: parsed.origin, project: repository, repository };
|
|
25544
|
+
}
|
|
25545
|
+
return null;
|
|
25546
|
+
}
|
|
25547
|
+
const collectionOnly = parts[gitIndex - 1]?.toLowerCase() === "defaultcollection";
|
|
25548
|
+
const project = collectionOnly ? repository : parts[gitIndex - 1];
|
|
25549
|
+
const orgPath = parts.slice(0, collectionOnly ? gitIndex : gitIndex - 1).join("/");
|
|
25550
|
+
return {
|
|
25551
|
+
orgUrl: orgPath ? `${parsed.origin}/${orgPath}` : parsed.origin,
|
|
25552
|
+
project: decodeURIComponent(project),
|
|
25553
|
+
repository: decodeURIComponent(repository)
|
|
25554
|
+
};
|
|
25555
|
+
}
|
|
25556
|
+
|
|
25557
|
+
// src/azure-devops/templates.ts
|
|
25558
|
+
init_registry();
|
|
25559
|
+
registerTemplate({
|
|
25560
|
+
eventType: "common.delegation_instruction.azure_devops",
|
|
25561
|
+
header: "",
|
|
25562
|
+
defaultBody: "\n\n**Delegation instruction:** As the lead agent, analyze this and decide whether to handle it yourself or delegate to a worker agent. Use `send-task` to delegate with clear instructions.",
|
|
25563
|
+
variables: [],
|
|
25564
|
+
category: "common"
|
|
25565
|
+
});
|
|
25566
|
+
registerTemplate({
|
|
25567
|
+
eventType: "common.command_suggestions.azure_devops_pr",
|
|
25568
|
+
header: "",
|
|
25569
|
+
defaultBody: 'Workers have the `az` CLI with the azure-devops extension, authenticated with the swarm PAT. Inspect the PR with `az repos pr show --id {{pr_id}}`. To reply on the PR, write `{"comments":[{"content":"<reply>"}],"status":1}` to a JSON file and run `az devops invoke --area git --resource pullRequestThreads --route-parameters project={{project}} repositoryId={{repository}} pullRequestId={{pr_id}} --http-method POST --in-file <file> --api-version 7.1`.',
|
|
25570
|
+
variables: [
|
|
25571
|
+
{ name: "pr_id", description: "Pull request ID" },
|
|
25572
|
+
{ name: "project", description: "Azure DevOps project name" },
|
|
25573
|
+
{ name: "repository", description: "Azure Repos repository name" }
|
|
25574
|
+
],
|
|
25575
|
+
category: "common"
|
|
25576
|
+
});
|
|
25577
|
+
var SHARED_VARIABLES = [
|
|
25578
|
+
{ name: "pr_id", description: "Pull request ID" },
|
|
25579
|
+
{ name: "pr_title", description: "Pull request title" },
|
|
25580
|
+
{
|
|
25581
|
+
name: "repo",
|
|
25582
|
+
description: "Repository clone URL (https://dev.azure.com/<org>/<project>/_git/<repo>)"
|
|
25583
|
+
},
|
|
25584
|
+
{ name: "project", description: "Azure DevOps project name" },
|
|
25585
|
+
{ name: "repository", description: "Azure Repos repository name" },
|
|
25586
|
+
{ name: "pr_url", description: "Pull request web URL" }
|
|
25587
|
+
];
|
|
25588
|
+
registerTemplate({
|
|
25589
|
+
eventType: "azure-devops.pull_request.opened",
|
|
25590
|
+
header: "[Azure DevOps PR #{{pr_id}}] {{pr_title}}",
|
|
25591
|
+
defaultBody: `Repo: {{repo}}
|
|
25592
|
+
Author: {{username}}
|
|
25593
|
+
Branch: {{source_branch}} → {{target_branch}}
|
|
25594
|
+
URL: {{pr_url}}
|
|
25595
|
+
|
|
25596
|
+
{{context_section}}{{@template[common.command_suggestions.azure_devops_pr]}}{{@template[common.delegation_instruction.azure_devops]}}`,
|
|
25597
|
+
variables: [
|
|
25598
|
+
...SHARED_VARIABLES,
|
|
25599
|
+
{
|
|
25600
|
+
name: "username",
|
|
25601
|
+
description: "Author identity — resolved canonical name (e.g. 'Luis (azure-devops:luis@example.com)') or the UNKNOWN sentinel"
|
|
25602
|
+
},
|
|
25603
|
+
{ name: "source_branch", description: "Source branch name" },
|
|
25604
|
+
{ name: "target_branch", description: "Target branch name" },
|
|
25605
|
+
{ name: "context_section", description: "Context section with description or empty string" }
|
|
25606
|
+
],
|
|
25607
|
+
category: "event"
|
|
25608
|
+
});
|
|
25609
|
+
registerTemplate({
|
|
25610
|
+
eventType: "azure-devops.comment.mentioned",
|
|
25611
|
+
header: "[Azure DevOps Comment on PR #{{pr_id}}] {{username}} mentioned bot",
|
|
25612
|
+
defaultBody: `Repo: {{repo}}
|
|
25613
|
+
PR: {{pr_title}}
|
|
25614
|
+
URL: {{pr_url}}
|
|
25615
|
+
|
|
25616
|
+
Comment:
|
|
25617
|
+
{{context}}{{existing_task_note}}
|
|
25618
|
+
|
|
25619
|
+
{{@template[common.command_suggestions.azure_devops_pr]}}{{@template[common.delegation_instruction.azure_devops]}}`,
|
|
25620
|
+
variables: [
|
|
25621
|
+
...SHARED_VARIABLES,
|
|
25622
|
+
{
|
|
25623
|
+
name: "username",
|
|
25624
|
+
description: "Comment author identity — resolved canonical name (e.g. 'Luis (azure-devops:luis@example.com)') or the UNKNOWN sentinel"
|
|
25625
|
+
},
|
|
25626
|
+
{ name: "context", description: "Extracted mention context from comment" },
|
|
25627
|
+
{
|
|
25628
|
+
name: "existing_task_note",
|
|
25629
|
+
description: "Note about existing active task, or empty string"
|
|
25630
|
+
}
|
|
25631
|
+
],
|
|
25632
|
+
category: "event"
|
|
25633
|
+
});
|
|
25634
|
+
|
|
25635
|
+
// src/azure-devops/handlers.ts
|
|
25636
|
+
var processedEvents2 = new Map;
|
|
25637
|
+
var DEDUP_TTL_MS = 60000;
|
|
25638
|
+
function isDuplicate2(key) {
|
|
25639
|
+
const now = Date.now();
|
|
25640
|
+
for (const [k, ts] of processedEvents2) {
|
|
25641
|
+
if (now - ts > DEDUP_TTL_MS)
|
|
25642
|
+
processedEvents2.delete(k);
|
|
25643
|
+
}
|
|
25644
|
+
if (processedEvents2.has(key))
|
|
25645
|
+
return true;
|
|
25646
|
+
processedEvents2.set(key, now);
|
|
25647
|
+
return false;
|
|
25648
|
+
}
|
|
25649
|
+
function escapeRegExp(value) {
|
|
25650
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25651
|
+
}
|
|
25652
|
+
function mentionPatterns(botId) {
|
|
25653
|
+
const patterns = [new RegExp(`@${escapeRegExp(AZURE_DEVOPS_BOT_NAME)}\\b`, "gi")];
|
|
25654
|
+
if (botId)
|
|
25655
|
+
patterns.push(new RegExp(`@<${escapeRegExp(botId)}>`, "gi"));
|
|
25656
|
+
return patterns;
|
|
25657
|
+
}
|
|
25658
|
+
function detectMention(text, botId) {
|
|
25659
|
+
if (!text)
|
|
25660
|
+
return false;
|
|
25661
|
+
return mentionPatterns(botId).some((re) => {
|
|
25662
|
+
re.lastIndex = 0;
|
|
25663
|
+
return re.test(text);
|
|
25664
|
+
});
|
|
25665
|
+
}
|
|
25666
|
+
function extractMentionContext(text, botId) {
|
|
25667
|
+
return mentionPatterns(botId).reduce((acc, re) => acc.replace(re, ""), text).trim();
|
|
25668
|
+
}
|
|
25669
|
+
function isBot(identity, botId) {
|
|
25670
|
+
return !!botId && identity.id.toLowerCase() === botId.toLowerCase();
|
|
25671
|
+
}
|
|
25672
|
+
function pullRequestWebUrl(pr) {
|
|
25673
|
+
const web = pr._links?.web?.href;
|
|
25674
|
+
if (web)
|
|
25675
|
+
return web.split("#")[0];
|
|
25676
|
+
return `${canonicalAzureDevOpsRepoUrl(pr.repository.remoteUrl)}/pullrequest/${pr.pullRequestId}`;
|
|
25677
|
+
}
|
|
25678
|
+
function branchName(refName) {
|
|
25679
|
+
return refName.replace(/^refs\/heads\//, "");
|
|
25680
|
+
}
|
|
25681
|
+
function orgUrlFor(event) {
|
|
25682
|
+
const containers = event.resourceContainers;
|
|
25683
|
+
return normalizeOrgUrl(containers?.account?.baseUrl ?? containers?.collection?.baseUrl) ?? getAzureDevOpsOrgUrl();
|
|
25684
|
+
}
|
|
25685
|
+
function threadIdOf(links) {
|
|
25686
|
+
const href = links?.threads?.href ?? links?.self?.href ?? "";
|
|
25687
|
+
const match = href.match(/\/threads\/(\d+)/);
|
|
25688
|
+
return match ? Number(match[1]) : null;
|
|
25689
|
+
}
|
|
25690
|
+
function isPullRequest(value) {
|
|
25691
|
+
const pr = value;
|
|
25692
|
+
return typeof pr?.pullRequestId === "number" && typeof pr.repository?.id === "string" && typeof pr.repository.remoteUrl === "string" && !!pr.repository.project && !!pr.createdBy;
|
|
25693
|
+
}
|
|
25694
|
+
function createdPullRequestOf(event) {
|
|
25695
|
+
return isPullRequest(event?.resource) ? event.resource : null;
|
|
25696
|
+
}
|
|
25697
|
+
function commentedPayloadOf(event) {
|
|
25698
|
+
const resource = event?.resource;
|
|
25699
|
+
const comment = resource?.comment;
|
|
25700
|
+
const pullRequest = resource?.pullRequest;
|
|
25701
|
+
if (!isPullRequest(pullRequest) || typeof comment?.id !== "number" || !comment.author) {
|
|
25702
|
+
return null;
|
|
25703
|
+
}
|
|
25704
|
+
return { comment, pullRequest };
|
|
25705
|
+
}
|
|
25706
|
+
function warnMalformed(event) {
|
|
25707
|
+
console.warn(`[AzureDevOps] Ignoring ${event?.eventType} event with resourceVersion ${event?.resourceVersion ?? "unknown"}: required resource fields are missing`);
|
|
25708
|
+
}
|
|
25709
|
+
async function findLeadAgent2() {
|
|
25710
|
+
const agents = await getAllAgents();
|
|
25711
|
+
return agents.find((a) => a.role === "lead" && a.status === "idle") ?? agents.find((a) => a.role === "lead") ?? null;
|
|
25712
|
+
}
|
|
25713
|
+
var UNMAPPED_NAMESPACE = "integration:unmapped:azure-devops";
|
|
25714
|
+
var UNMAPPED_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
|
25715
|
+
var AZURE_DEVOPS_WEBHOOK_ACTOR = { kind: "system", id: "webhook:azure-devops" };
|
|
25716
|
+
function externalIdOf(identity) {
|
|
25717
|
+
return identity.uniqueName?.trim() || identity.id;
|
|
25718
|
+
}
|
|
25719
|
+
async function resolveAzureDevOpsSender(identity, sampleEventType, sampleContext) {
|
|
25720
|
+
const externalId = externalIdOf(identity);
|
|
25721
|
+
const existing = await findUserByExternalId("azure-devops", externalId);
|
|
25722
|
+
if (existing)
|
|
25723
|
+
return existing.id;
|
|
25724
|
+
if (externalId.includes("@")) {
|
|
25725
|
+
const { user: linked } = await findOrCreateUserByEmail(externalId, { name: identity.displayName }, AZURE_DEVOPS_WEBHOOK_ACTOR);
|
|
25726
|
+
await linkIdentity(linked.id, "azure-devops", externalId, AZURE_DEVOPS_WEBHOOK_ACTOR);
|
|
25727
|
+
return linked.id;
|
|
25728
|
+
}
|
|
25729
|
+
await upsertKv({
|
|
25730
|
+
namespace: UNMAPPED_NAMESPACE,
|
|
25731
|
+
key: `${externalId}:meta`,
|
|
25732
|
+
value: {
|
|
25733
|
+
lastSeenAt: new Date().toISOString(),
|
|
25734
|
+
sampleEventType,
|
|
25735
|
+
sampleContext: sampleContext.slice(0, 100)
|
|
25736
|
+
},
|
|
25737
|
+
valueType: "json",
|
|
25738
|
+
expiresAt: Date.now() + UNMAPPED_TTL_MS
|
|
25739
|
+
});
|
|
25740
|
+
await incrKv(UNMAPPED_NAMESPACE, `${externalId}:count`, 1);
|
|
25741
|
+
return;
|
|
25742
|
+
}
|
|
25743
|
+
async function renderAzureDevOpsIdentity(identity) {
|
|
25744
|
+
return renderIdentity(await resolveIdentity("azure-devops", externalIdOf(identity)));
|
|
25745
|
+
}
|
|
25746
|
+
async function handlePullRequestCreated(event) {
|
|
25747
|
+
const pr = createdPullRequestOf(event);
|
|
25748
|
+
if (!pr) {
|
|
25749
|
+
warnMalformed(event);
|
|
25750
|
+
return { created: false };
|
|
25751
|
+
}
|
|
25752
|
+
const repo = canonicalAzureDevOpsRepoUrl(pr.repository.remoteUrl);
|
|
25753
|
+
console.log(`[AzureDevOps] PR #${pr.pullRequestId} created by ${pr.createdBy.displayName} in ${repo}`);
|
|
25754
|
+
const orgUrl2 = orgUrlFor(event);
|
|
25755
|
+
const botId = await resolveAzureDevOpsBotId(orgUrl2);
|
|
25756
|
+
if (isBot(pr.createdBy, botId)) {
|
|
25757
|
+
console.log(`[AzureDevOps] PR opened by the bot itself, skipping`);
|
|
25758
|
+
return { created: false };
|
|
25759
|
+
}
|
|
25760
|
+
if (!detectMention(pr.description, botId)) {
|
|
25761
|
+
console.log(`[AzureDevOps] PR opened without bot mention, skipping`);
|
|
25762
|
+
return { created: false };
|
|
25763
|
+
}
|
|
25764
|
+
const dedupKey = `azure-devops-pr-${pr.repository.id}-${pr.pullRequestId}-created`;
|
|
25765
|
+
if (isDuplicate2(dedupKey)) {
|
|
25766
|
+
console.log(`[AzureDevOps] Skipping duplicate PR event`);
|
|
25767
|
+
return { created: false };
|
|
25768
|
+
}
|
|
25769
|
+
const requestedByUserId = await resolveAzureDevOpsSender(pr.createdBy, "pull_request", `PR !${pr.pullRequestId}: ${pr.title}`);
|
|
25770
|
+
const context = pr.description ? extractMentionContext(pr.description, botId) : "";
|
|
25771
|
+
const prUrl = pullRequestWebUrl(pr);
|
|
25772
|
+
const result = resolveTemplate("azure-devops.pull_request.opened", {
|
|
25773
|
+
pr_id: pr.pullRequestId,
|
|
25774
|
+
pr_title: pr.title,
|
|
25775
|
+
repo,
|
|
25776
|
+
project: pr.repository.project.name,
|
|
25777
|
+
repository: pr.repository.name,
|
|
25778
|
+
username: await renderAzureDevOpsIdentity(pr.createdBy),
|
|
25779
|
+
source_branch: branchName(pr.sourceRefName),
|
|
25780
|
+
target_branch: branchName(pr.targetRefName),
|
|
25781
|
+
pr_url: prUrl,
|
|
25782
|
+
context_section: context ? `Context: ${context}
|
|
25783
|
+
|
|
25784
|
+
` : ""
|
|
25785
|
+
});
|
|
25786
|
+
if (result.skipped) {
|
|
25787
|
+
return { created: false };
|
|
25788
|
+
}
|
|
25789
|
+
const lead = await findLeadAgent2();
|
|
25790
|
+
const task = await createTaskWithSiblingAwareness(result.text, {
|
|
25791
|
+
agentId: lead?.id ?? null,
|
|
25792
|
+
routingReason: lead ? "skill" : undefined,
|
|
25793
|
+
routingSource: lead ? "engine_default" : undefined,
|
|
25794
|
+
source: "azure-devops",
|
|
25795
|
+
vcsProvider: "azure-devops",
|
|
25796
|
+
taskType: "azure-devops-pr",
|
|
25797
|
+
vcsRepo: repo,
|
|
25798
|
+
vcsEventType: "pull_request",
|
|
25799
|
+
vcsNumber: pr.pullRequestId,
|
|
25800
|
+
vcsAuthor: externalIdOf(pr.createdBy),
|
|
25801
|
+
requestedByUserId,
|
|
25802
|
+
vcsUrl: prUrl,
|
|
25803
|
+
contextKey: azureDevOpsContextKey({
|
|
25804
|
+
repositoryId: pr.repository.id,
|
|
25805
|
+
pullRequestId: pr.pullRequestId
|
|
25806
|
+
})
|
|
25807
|
+
}, { origin: "webhook" });
|
|
25808
|
+
return { created: true, taskId: task.id };
|
|
25809
|
+
}
|
|
25810
|
+
async function handlePullRequestCommented(event) {
|
|
25811
|
+
const payload = commentedPayloadOf(event);
|
|
25812
|
+
if (!payload) {
|
|
25813
|
+
warnMalformed(event);
|
|
25814
|
+
return { created: false };
|
|
25815
|
+
}
|
|
25816
|
+
const { comment, pullRequest: pr } = payload;
|
|
25817
|
+
const repo = canonicalAzureDevOpsRepoUrl(pr.repository.remoteUrl);
|
|
25818
|
+
if (comment.commentType === "system") {
|
|
25819
|
+
return { created: false };
|
|
25820
|
+
}
|
|
25821
|
+
if (comment.lastContentUpdatedDate && comment.lastContentUpdatedDate !== comment.publishedDate) {
|
|
25822
|
+
console.log(`[AzureDevOps] Ignoring edited comment ${comment.id} on PR #${pr.pullRequestId}`);
|
|
25823
|
+
return { created: false };
|
|
25824
|
+
}
|
|
25825
|
+
const orgUrl2 = orgUrlFor(event);
|
|
25826
|
+
const botId = await resolveAzureDevOpsBotId(orgUrl2);
|
|
25827
|
+
if (isBot(comment.author, botId)) {
|
|
25828
|
+
return { created: false };
|
|
25829
|
+
}
|
|
25830
|
+
if (!detectMention(comment.content, botId)) {
|
|
25831
|
+
return { created: false };
|
|
25832
|
+
}
|
|
25833
|
+
console.log(`[AzureDevOps] Comment by ${comment.author.displayName} on PR #${pr.pullRequestId} in ${repo}`);
|
|
25834
|
+
const threadId = threadIdOf(comment._links);
|
|
25835
|
+
const dedupKey = `azure-devops-comment-${pr.repository.id}-${pr.pullRequestId}-${threadId}-${comment.id}`;
|
|
25836
|
+
if (isDuplicate2(dedupKey)) {
|
|
25837
|
+
return { created: false };
|
|
25838
|
+
}
|
|
25839
|
+
const requestedByUserId = await resolveAzureDevOpsSender(comment.author, "pull_request_comment", comment.content);
|
|
25840
|
+
const existingTask = await findTaskByVcs(repo, pr.pullRequestId);
|
|
25841
|
+
const existingTaskNote = existingTask ? `
|
|
25842
|
+
|
|
25843
|
+
_Note: There's an active task (${existingTask.id}) for this PR #${pr.pullRequestId}._` : "";
|
|
25844
|
+
const prUrl = pullRequestWebUrl(pr);
|
|
25845
|
+
const result = resolveTemplate("azure-devops.comment.mentioned", {
|
|
25846
|
+
pr_id: pr.pullRequestId,
|
|
25847
|
+
pr_title: pr.title,
|
|
25848
|
+
username: await renderAzureDevOpsIdentity(comment.author),
|
|
25849
|
+
repo,
|
|
25850
|
+
project: pr.repository.project.name,
|
|
25851
|
+
repository: pr.repository.name,
|
|
25852
|
+
pr_url: prUrl,
|
|
25853
|
+
context: extractMentionContext(comment.content, botId),
|
|
25854
|
+
existing_task_note: existingTaskNote
|
|
25855
|
+
});
|
|
25856
|
+
if (result.skipped) {
|
|
25857
|
+
return { created: false };
|
|
25858
|
+
}
|
|
25859
|
+
const lead = await findLeadAgent2();
|
|
25860
|
+
const task = await createTaskWithSiblingAwareness(result.text, {
|
|
25861
|
+
agentId: lead?.id ?? null,
|
|
25862
|
+
routingReason: lead ? "skill" : undefined,
|
|
25863
|
+
routingSource: lead ? "engine_default" : undefined,
|
|
25864
|
+
source: "azure-devops",
|
|
25865
|
+
vcsProvider: "azure-devops",
|
|
25866
|
+
taskType: "azure-devops-comment",
|
|
25867
|
+
vcsRepo: repo,
|
|
25868
|
+
vcsEventType: "pull_request_comment",
|
|
25869
|
+
vcsNumber: pr.pullRequestId,
|
|
25870
|
+
vcsCommentId: comment.id,
|
|
25871
|
+
vcsAuthor: externalIdOf(comment.author),
|
|
25872
|
+
requestedByUserId,
|
|
25873
|
+
vcsUrl: prUrl,
|
|
25874
|
+
parentTaskId: existingTask?.id,
|
|
25875
|
+
contextKey: azureDevOpsContextKey({
|
|
25876
|
+
repositoryId: pr.repository.id,
|
|
25877
|
+
pullRequestId: pr.pullRequestId
|
|
25878
|
+
})
|
|
25879
|
+
}, { origin: "webhook" });
|
|
25880
|
+
if (orgUrl2 && threadId !== null) {
|
|
25881
|
+
const ref = {
|
|
25882
|
+
orgUrl: orgUrl2,
|
|
25883
|
+
projectId: pr.repository.project.id,
|
|
25884
|
+
repositoryId: pr.repository.id,
|
|
25885
|
+
pullRequestId: pr.pullRequestId
|
|
25886
|
+
};
|
|
25887
|
+
try {
|
|
25888
|
+
await likeAzureDevOpsComment(ref, threadId, comment.id);
|
|
25889
|
+
} catch {}
|
|
25890
|
+
}
|
|
25891
|
+
return { created: true, taskId: task.id };
|
|
25892
|
+
}
|
|
25355
25893
|
// src/http/core.ts
|
|
25356
25894
|
init_db();
|
|
25357
25895
|
|
|
@@ -25719,11 +26257,13 @@ function stopAuditGc() {
|
|
|
25719
26257
|
auditGcTimer = null;
|
|
25720
26258
|
}
|
|
25721
26259
|
}
|
|
26260
|
+
|
|
26261
|
+
// src/http/core.ts
|
|
26262
|
+
init_rbac_roles();
|
|
25722
26263
|
// src/github/handlers.ts
|
|
25723
26264
|
init_db();
|
|
25724
26265
|
init_resolver();
|
|
25725
26266
|
init_context_key();
|
|
25726
|
-
init_secret_scrubber();
|
|
25727
26267
|
|
|
25728
26268
|
// src/github/mentions.ts
|
|
25729
26269
|
var GITHUB_BOT_NAME = process.env.GITHUB_BOT_NAME || "agent-swarm-bot";
|
|
@@ -25742,12 +26282,12 @@ function computeMentionPattern(names) {
|
|
|
25742
26282
|
}
|
|
25743
26283
|
var BOT_NAMES = computeBotNames();
|
|
25744
26284
|
var MENTION_PATTERN = computeMentionPattern(BOT_NAMES);
|
|
25745
|
-
function
|
|
26285
|
+
function detectMention2(text) {
|
|
25746
26286
|
if (!text)
|
|
25747
26287
|
return false;
|
|
25748
26288
|
return MENTION_PATTERN.test(text);
|
|
25749
26289
|
}
|
|
25750
|
-
function
|
|
26290
|
+
function extractMentionContext2(text) {
|
|
25751
26291
|
if (!text)
|
|
25752
26292
|
return "";
|
|
25753
26293
|
return text.replace(MENTION_PATTERN, "").trim();
|
|
@@ -26190,7 +26730,7 @@ Related task: {{related_task_id}}
|
|
|
26190
26730
|
});
|
|
26191
26731
|
|
|
26192
26732
|
// src/github/handlers.ts
|
|
26193
|
-
var
|
|
26733
|
+
var processedEvents3 = new Map;
|
|
26194
26734
|
var EVENT_TTL2 = 60000;
|
|
26195
26735
|
function buildGithubContextKey(fullName, kind, number3) {
|
|
26196
26736
|
const [owner, repo] = fullName.split("/");
|
|
@@ -26234,34 +26774,34 @@ function getCommandSuggestions(taskType, targetType) {
|
|
|
26234
26774
|
return "";
|
|
26235
26775
|
}
|
|
26236
26776
|
}
|
|
26237
|
-
function
|
|
26777
|
+
function isDuplicate3(eventKey) {
|
|
26238
26778
|
const now = Date.now();
|
|
26239
|
-
for (const [key, timestamp] of
|
|
26779
|
+
for (const [key, timestamp] of processedEvents3) {
|
|
26240
26780
|
if (now - timestamp > EVENT_TTL2) {
|
|
26241
|
-
|
|
26781
|
+
processedEvents3.delete(key);
|
|
26242
26782
|
}
|
|
26243
26783
|
}
|
|
26244
|
-
if (
|
|
26784
|
+
if (processedEvents3.has(eventKey)) {
|
|
26245
26785
|
return true;
|
|
26246
26786
|
}
|
|
26247
|
-
|
|
26787
|
+
processedEvents3.set(eventKey, now);
|
|
26248
26788
|
return false;
|
|
26249
26789
|
}
|
|
26250
|
-
async function
|
|
26790
|
+
async function findLeadAgent3() {
|
|
26251
26791
|
const agents = await getAllAgents();
|
|
26252
26792
|
const onlineLead = agents.find((a) => a.isLead && a.status !== "offline");
|
|
26253
26793
|
if (onlineLead)
|
|
26254
26794
|
return onlineLead;
|
|
26255
26795
|
return agents.find((a) => a.isLead) ?? null;
|
|
26256
26796
|
}
|
|
26257
|
-
var
|
|
26258
|
-
var
|
|
26797
|
+
var UNMAPPED_NAMESPACE2 = "integration:unmapped:github";
|
|
26798
|
+
var UNMAPPED_TTL_MS2 = 30 * 24 * 60 * 60 * 1000;
|
|
26259
26799
|
async function resolveGitHubSender(login, sampleEventType, sampleContext) {
|
|
26260
26800
|
const existing = await findUserByExternalId("github", login);
|
|
26261
26801
|
if (existing)
|
|
26262
26802
|
return existing.id;
|
|
26263
26803
|
await upsertKv({
|
|
26264
|
-
namespace:
|
|
26804
|
+
namespace: UNMAPPED_NAMESPACE2,
|
|
26265
26805
|
key: `${login}:meta`,
|
|
26266
26806
|
value: {
|
|
26267
26807
|
lastSeenAt: new Date().toISOString(),
|
|
@@ -26269,9 +26809,9 @@ async function resolveGitHubSender(login, sampleEventType, sampleContext) {
|
|
|
26269
26809
|
sampleContext: sampleContext.slice(0, 100)
|
|
26270
26810
|
},
|
|
26271
26811
|
valueType: "json",
|
|
26272
|
-
expiresAt: Date.now() +
|
|
26812
|
+
expiresAt: Date.now() + UNMAPPED_TTL_MS2
|
|
26273
26813
|
});
|
|
26274
|
-
await incrKv(
|
|
26814
|
+
await incrKv(UNMAPPED_NAMESPACE2, `${login}:count`, 1);
|
|
26275
26815
|
return;
|
|
26276
26816
|
}
|
|
26277
26817
|
async function handlePullRequest(event) {
|
|
@@ -26290,10 +26830,10 @@ async function handlePullRequest(event) {
|
|
|
26290
26830
|
return { created: false };
|
|
26291
26831
|
}
|
|
26292
26832
|
const eventKey2 = `pr-assigned:${repository.full_name}:${pr.number}`;
|
|
26293
|
-
if (
|
|
26833
|
+
if (isDuplicate3(eventKey2)) {
|
|
26294
26834
|
return { created: false };
|
|
26295
26835
|
}
|
|
26296
|
-
const lead2 = await
|
|
26836
|
+
const lead2 = await findLeadAgent3();
|
|
26297
26837
|
const result2 = resolveTemplate("github.pull_request.assigned", {
|
|
26298
26838
|
pr_number: pr.number,
|
|
26299
26839
|
pr_title: pr.title,
|
|
@@ -26329,9 +26869,7 @@ async function handlePullRequest(event) {
|
|
|
26329
26869
|
} else {
|
|
26330
26870
|
console.log(`[GitHub] Created unassigned task ${task2.id} for PR #${pr.number} (assigned, no lead available)`);
|
|
26331
26871
|
}
|
|
26332
|
-
|
|
26333
|
-
addIssueReaction(repository.full_name, pr.number, "eyes", installation.id).catch((err) => console.error("[GitHub] failed to add issue reaction:", scrubSecrets(err instanceof Error ? err.message : String(err))));
|
|
26334
|
-
}
|
|
26872
|
+
addEyesReactionToTaskSource(task2).catch(() => {});
|
|
26335
26873
|
return { created: true, taskId: task2.id };
|
|
26336
26874
|
}
|
|
26337
26875
|
if (action === "unassigned") {
|
|
@@ -26359,7 +26897,7 @@ async function handlePullRequest(event) {
|
|
|
26359
26897
|
return { created: false };
|
|
26360
26898
|
}
|
|
26361
26899
|
const eventKey2 = `pr-review-requested:${repository.full_name}:${pr.number}`;
|
|
26362
|
-
if (
|
|
26900
|
+
if (isDuplicate3(eventKey2)) {
|
|
26363
26901
|
return { created: false };
|
|
26364
26902
|
}
|
|
26365
26903
|
const existingTask = await findTaskByVcs(repository.full_name, pr.number);
|
|
@@ -26367,7 +26905,7 @@ async function handlePullRequest(event) {
|
|
|
26367
26905
|
console.log(`[GitHub] Skipping review task for PR #${pr.number} — active task ${existingTask.id} already exists`);
|
|
26368
26906
|
return { created: false };
|
|
26369
26907
|
}
|
|
26370
|
-
const lead2 = await
|
|
26908
|
+
const lead2 = await findLeadAgent3();
|
|
26371
26909
|
const result2 = resolveTemplate("github.pull_request.review_requested", {
|
|
26372
26910
|
pr_number: pr.number,
|
|
26373
26911
|
pr_title: pr.title,
|
|
@@ -26403,9 +26941,7 @@ async function handlePullRequest(event) {
|
|
|
26403
26941
|
} else {
|
|
26404
26942
|
console.log(`[GitHub] Created unassigned task ${task2.id} for PR #${pr.number} (review requested, no lead available)`);
|
|
26405
26943
|
}
|
|
26406
|
-
|
|
26407
|
-
addIssueReaction(repository.full_name, pr.number, "eyes", installation.id).catch((err) => console.error("[GitHub] failed to add issue reaction:", scrubSecrets(err instanceof Error ? err.message : String(err))));
|
|
26408
|
-
}
|
|
26944
|
+
addEyesReactionToTaskSource(task2).catch(() => {});
|
|
26409
26945
|
return { created: true, taskId: task2.id };
|
|
26410
26946
|
}
|
|
26411
26947
|
if (action === "review_request_removed") {
|
|
@@ -26434,10 +26970,10 @@ async function handlePullRequest(event) {
|
|
|
26434
26970
|
return { created: false };
|
|
26435
26971
|
}
|
|
26436
26972
|
const eventKey2 = `pr-labeled:${repository.full_name}:${pr.number}:${labelName}`;
|
|
26437
|
-
if (
|
|
26973
|
+
if (isDuplicate3(eventKey2)) {
|
|
26438
26974
|
return { created: false };
|
|
26439
26975
|
}
|
|
26440
|
-
const lead2 = await
|
|
26976
|
+
const lead2 = await findLeadAgent3();
|
|
26441
26977
|
const result2 = resolveTemplate("github.pull_request.labeled", {
|
|
26442
26978
|
pr_number: pr.number,
|
|
26443
26979
|
pr_title: pr.title,
|
|
@@ -26473,9 +27009,7 @@ async function handlePullRequest(event) {
|
|
|
26473
27009
|
} else {
|
|
26474
27010
|
console.log(`[GitHub] Created unassigned task ${task2.id} for PR #${pr.number} (labeled: ${labelName}, no lead available)`);
|
|
26475
27011
|
}
|
|
26476
|
-
|
|
26477
|
-
addIssueReaction(repository.full_name, pr.number, "eyes", installation.id).catch((err) => console.error("[GitHub] failed to add issue reaction:", scrubSecrets(err instanceof Error ? err.message : String(err))));
|
|
26478
|
-
}
|
|
27012
|
+
addEyesReactionToTaskSource(task2).catch(() => {});
|
|
26479
27013
|
return { created: true, taskId: task2.id };
|
|
26480
27014
|
}
|
|
26481
27015
|
if (action === "closed") {
|
|
@@ -26489,16 +27023,16 @@ async function handlePullRequest(event) {
|
|
|
26489
27023
|
if (action !== "opened" && action !== "edited") {
|
|
26490
27024
|
return { created: false };
|
|
26491
27025
|
}
|
|
26492
|
-
const hasMention =
|
|
27026
|
+
const hasMention = detectMention2(pr.title) || detectMention2(pr.body);
|
|
26493
27027
|
if (!hasMention) {
|
|
26494
27028
|
return { created: false };
|
|
26495
27029
|
}
|
|
26496
27030
|
const eventKey = `pr:${repository.full_name}:${pr.number}:${action}`;
|
|
26497
|
-
if (
|
|
27031
|
+
if (isDuplicate3(eventKey)) {
|
|
26498
27032
|
return { created: false };
|
|
26499
27033
|
}
|
|
26500
|
-
const lead = await
|
|
26501
|
-
const context =
|
|
27034
|
+
const lead = await findLeadAgent3();
|
|
27035
|
+
const context = extractMentionContext2(pr.body) || pr.title;
|
|
26502
27036
|
const result = resolveTemplate("github.pull_request.mentioned", {
|
|
26503
27037
|
pr_number: pr.number,
|
|
26504
27038
|
pr_title: pr.title,
|
|
@@ -26533,9 +27067,7 @@ async function handlePullRequest(event) {
|
|
|
26533
27067
|
} else {
|
|
26534
27068
|
console.log(`[GitHub] Created unassigned task ${task.id} for PR #${pr.number} (no lead available)`);
|
|
26535
27069
|
}
|
|
26536
|
-
|
|
26537
|
-
addIssueReaction(repository.full_name, pr.number, "eyes", installation.id).catch((err) => console.error("[GitHub] failed to add issue reaction:", scrubSecrets(err instanceof Error ? err.message : String(err))));
|
|
26538
|
-
}
|
|
27070
|
+
addEyesReactionToTaskSource(task).catch(() => {});
|
|
26539
27071
|
return { created: true, taskId: task.id };
|
|
26540
27072
|
}
|
|
26541
27073
|
async function handleIssue(event) {
|
|
@@ -26546,10 +27078,10 @@ async function handleIssue(event) {
|
|
|
26546
27078
|
return { created: false };
|
|
26547
27079
|
}
|
|
26548
27080
|
const eventKey2 = `issue-assigned:${repository.full_name}:${issue.number}`;
|
|
26549
|
-
if (
|
|
27081
|
+
if (isDuplicate3(eventKey2)) {
|
|
26550
27082
|
return { created: false };
|
|
26551
27083
|
}
|
|
26552
|
-
const lead2 = await
|
|
27084
|
+
const lead2 = await findLeadAgent3();
|
|
26553
27085
|
const result2 = resolveTemplate("github.issue.assigned", {
|
|
26554
27086
|
issue_number: issue.number,
|
|
26555
27087
|
issue_title: issue.title,
|
|
@@ -26583,9 +27115,7 @@ async function handleIssue(event) {
|
|
|
26583
27115
|
} else {
|
|
26584
27116
|
console.log(`[GitHub] Created unassigned task ${task2.id} for issue #${issue.number} (assigned, no lead available)`);
|
|
26585
27117
|
}
|
|
26586
|
-
|
|
26587
|
-
addIssueReaction(repository.full_name, issue.number, "eyes", installation.id).catch((err) => console.error("[GitHub] failed to add issue reaction:", scrubSecrets(err instanceof Error ? err.message : String(err))));
|
|
26588
|
-
}
|
|
27118
|
+
addEyesReactionToTaskSource(task2).catch(() => {});
|
|
26589
27119
|
return { created: true, taskId: task2.id };
|
|
26590
27120
|
}
|
|
26591
27121
|
if (action === "unassigned") {
|
|
@@ -26614,10 +27144,10 @@ async function handleIssue(event) {
|
|
|
26614
27144
|
return { created: false };
|
|
26615
27145
|
}
|
|
26616
27146
|
const eventKey2 = `issue-labeled:${repository.full_name}:${issue.number}:${labelName}`;
|
|
26617
|
-
if (
|
|
27147
|
+
if (isDuplicate3(eventKey2)) {
|
|
26618
27148
|
return { created: false };
|
|
26619
27149
|
}
|
|
26620
|
-
const lead2 = await
|
|
27150
|
+
const lead2 = await findLeadAgent3();
|
|
26621
27151
|
const result2 = resolveTemplate("github.issue.labeled", {
|
|
26622
27152
|
issue_number: issue.number,
|
|
26623
27153
|
issue_title: issue.title,
|
|
@@ -26651,24 +27181,22 @@ async function handleIssue(event) {
|
|
|
26651
27181
|
} else {
|
|
26652
27182
|
console.log(`[GitHub] Created unassigned task ${task2.id} for issue #${issue.number} (labeled: ${labelName}, no lead available)`);
|
|
26653
27183
|
}
|
|
26654
|
-
|
|
26655
|
-
addIssueReaction(repository.full_name, issue.number, "eyes", installation.id).catch((err) => console.error("[GitHub] failed to add issue reaction:", scrubSecrets(err instanceof Error ? err.message : String(err))));
|
|
26656
|
-
}
|
|
27184
|
+
addEyesReactionToTaskSource(task2).catch(() => {});
|
|
26657
27185
|
return { created: true, taskId: task2.id };
|
|
26658
27186
|
}
|
|
26659
27187
|
if (action !== "opened" && action !== "edited") {
|
|
26660
27188
|
return { created: false };
|
|
26661
27189
|
}
|
|
26662
|
-
const hasMention =
|
|
27190
|
+
const hasMention = detectMention2(issue.title) || detectMention2(issue.body);
|
|
26663
27191
|
if (!hasMention) {
|
|
26664
27192
|
return { created: false };
|
|
26665
27193
|
}
|
|
26666
27194
|
const eventKey = `issue:${repository.full_name}:${issue.number}:${action}`;
|
|
26667
|
-
if (
|
|
27195
|
+
if (isDuplicate3(eventKey)) {
|
|
26668
27196
|
return { created: false };
|
|
26669
27197
|
}
|
|
26670
|
-
const lead = await
|
|
26671
|
-
const context =
|
|
27198
|
+
const lead = await findLeadAgent3();
|
|
27199
|
+
const context = extractMentionContext2(issue.body) || issue.title;
|
|
26672
27200
|
const result = resolveTemplate("github.issue.mentioned", {
|
|
26673
27201
|
issue_number: issue.number,
|
|
26674
27202
|
issue_title: issue.title,
|
|
@@ -26701,9 +27229,7 @@ async function handleIssue(event) {
|
|
|
26701
27229
|
} else {
|
|
26702
27230
|
console.log(`[GitHub] Created unassigned task ${task.id} for issue #${issue.number} (no lead available)`);
|
|
26703
27231
|
}
|
|
26704
|
-
|
|
26705
|
-
addIssueReaction(repository.full_name, issue.number, "eyes", installation.id).catch((err) => console.error("[GitHub] failed to add issue reaction:", scrubSecrets(err instanceof Error ? err.message : String(err))));
|
|
26706
|
-
}
|
|
27232
|
+
addEyesReactionToTaskSource(task).catch(() => {});
|
|
26707
27233
|
return { created: true, taskId: task.id };
|
|
26708
27234
|
}
|
|
26709
27235
|
async function handleComment(event, eventType) {
|
|
@@ -26712,21 +27238,21 @@ async function handleComment(event, eventType) {
|
|
|
26712
27238
|
if (action !== "created") {
|
|
26713
27239
|
return { created: false };
|
|
26714
27240
|
}
|
|
26715
|
-
if (!
|
|
27241
|
+
if (!detectMention2(comment.body)) {
|
|
26716
27242
|
return { created: false };
|
|
26717
27243
|
}
|
|
26718
27244
|
const eventKey = `comment:${repository.full_name}:${comment.id}`;
|
|
26719
|
-
if (
|
|
27245
|
+
if (isDuplicate3(eventKey)) {
|
|
26720
27246
|
return { created: false };
|
|
26721
27247
|
}
|
|
26722
|
-
const lead = await
|
|
27248
|
+
const lead = await findLeadAgent3();
|
|
26723
27249
|
const target = pull_request || issue;
|
|
26724
27250
|
const targetType = pull_request ? "PR" : "Issue";
|
|
26725
27251
|
const targetNumber = target?.number ?? 0;
|
|
26726
27252
|
const targetTitle = target?.title ?? "Unknown";
|
|
26727
27253
|
const targetUrl = target?.html_url ?? comment.html_url;
|
|
26728
27254
|
const existingTask = targetNumber ? await findTaskByVcs(repository.full_name, targetNumber) : null;
|
|
26729
|
-
const context =
|
|
27255
|
+
const context = extractMentionContext2(comment.body);
|
|
26730
27256
|
const suggestions = getCommandSuggestions("github-comment", targetType);
|
|
26731
27257
|
const relatedTaskSection = existingTask ? `Related task: ${existingTask.id}
|
|
26732
27258
|
\uD83D\uDD00 Consider routing to the same agent working on the related task.
|
|
@@ -26768,9 +27294,7 @@ async function handleComment(event, eventType) {
|
|
|
26768
27294
|
} else {
|
|
26769
27295
|
console.log(`[GitHub] Created unassigned task ${task.id} for comment on #${targetNumber} (no lead available)`);
|
|
26770
27296
|
}
|
|
26771
|
-
|
|
26772
|
-
addReaction(repository.full_name, comment.id, "eyes", installation.id).catch((err) => console.error("[GitHub] failed to add comment reaction:", scrubSecrets(err instanceof Error ? err.message : String(err))));
|
|
26773
|
-
}
|
|
27297
|
+
addEyesReactionToTaskSource(task).catch(() => {});
|
|
26774
27298
|
return { created: true, taskId: task.id };
|
|
26775
27299
|
}
|
|
26776
27300
|
function parseNextPageLink(linkHeader) {
|
|
@@ -26789,12 +27313,12 @@ function buildReviewCommentsHeaders(token) {
|
|
|
26789
27313
|
"X-GitHub-Api-Version": "2022-11-28"
|
|
26790
27314
|
};
|
|
26791
27315
|
}
|
|
26792
|
-
async function fetchPaginatedReviewComments(initialUrl,
|
|
27316
|
+
async function fetchPaginatedReviewComments(initialUrl, headers2) {
|
|
26793
27317
|
const allComments = [];
|
|
26794
27318
|
let url = initialUrl;
|
|
26795
27319
|
try {
|
|
26796
27320
|
while (url) {
|
|
26797
|
-
const response = await fetch(url, { headers });
|
|
27321
|
+
const response = await fetch(url, { headers: headers2 });
|
|
26798
27322
|
if (!response.ok) {
|
|
26799
27323
|
console.error(`[GitHub] Failed to fetch review inline comments: ${response.status}`);
|
|
26800
27324
|
return { comments: allComments, degraded: true };
|
|
@@ -26811,24 +27335,24 @@ async function fetchPaginatedReviewComments(initialUrl, headers) {
|
|
|
26811
27335
|
return { comments: allComments, degraded: true };
|
|
26812
27336
|
}
|
|
26813
27337
|
}
|
|
26814
|
-
async function fetchReviewScopedComments(repo, prNumber, reviewId,
|
|
27338
|
+
async function fetchReviewScopedComments(repo, prNumber, reviewId, headers2) {
|
|
26815
27339
|
const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}/reviews/${reviewId}/comments?per_page=100`;
|
|
26816
|
-
let result = await fetchPaginatedReviewComments(url,
|
|
27340
|
+
let result = await fetchPaginatedReviewComments(url, headers2);
|
|
26817
27341
|
if (result.degraded || result.comments.length > 0) {
|
|
26818
27342
|
return result;
|
|
26819
27343
|
}
|
|
26820
27344
|
for (const delayMs of REVIEW_COMMENTS_EMPTY_RETRY_DELAYS_MS) {
|
|
26821
27345
|
await reviewCommentsRetryDelay(delayMs);
|
|
26822
|
-
result = await fetchPaginatedReviewComments(url,
|
|
27346
|
+
result = await fetchPaginatedReviewComments(url, headers2);
|
|
26823
27347
|
if (result.degraded || result.comments.length > 0) {
|
|
26824
27348
|
return result;
|
|
26825
27349
|
}
|
|
26826
27350
|
}
|
|
26827
27351
|
return result;
|
|
26828
27352
|
}
|
|
26829
|
-
async function fetchPrLevelReviewComments(repo, prNumber, reviewId,
|
|
27353
|
+
async function fetchPrLevelReviewComments(repo, prNumber, reviewId, headers2) {
|
|
26830
27354
|
const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}/comments?per_page=100`;
|
|
26831
|
-
const result = await fetchPaginatedReviewComments(url,
|
|
27355
|
+
const result = await fetchPaginatedReviewComments(url, headers2);
|
|
26832
27356
|
return {
|
|
26833
27357
|
comments: result.comments.filter((comment) => comment.pull_request_review_id === reviewId),
|
|
26834
27358
|
degraded: result.degraded
|
|
@@ -26848,12 +27372,12 @@ async function fetchReviewComments(repo, prNumber, reviewId, installationId) {
|
|
|
26848
27372
|
if (!token) {
|
|
26849
27373
|
return { comments: [], degraded: true };
|
|
26850
27374
|
}
|
|
26851
|
-
const
|
|
26852
|
-
const scopedResult = await fetchReviewScopedComments(repo, prNumber, reviewId,
|
|
27375
|
+
const headers2 = buildReviewCommentsHeaders(token);
|
|
27376
|
+
const scopedResult = await fetchReviewScopedComments(repo, prNumber, reviewId, headers2);
|
|
26853
27377
|
if (!scopedResult.degraded && scopedResult.comments.length > 0) {
|
|
26854
27378
|
return scopedResult;
|
|
26855
27379
|
}
|
|
26856
|
-
const fallbackResult = await fetchPrLevelReviewComments(repo, prNumber, reviewId,
|
|
27380
|
+
const fallbackResult = await fetchPrLevelReviewComments(repo, prNumber, reviewId, headers2);
|
|
26857
27381
|
const mergedComments = dedupeReviewComments([
|
|
26858
27382
|
...scopedResult.comments,
|
|
26859
27383
|
...fallbackResult.comments
|
|
@@ -26904,7 +27428,7 @@ async function handlePullRequestReview(event) {
|
|
|
26904
27428
|
return { created: false };
|
|
26905
27429
|
}
|
|
26906
27430
|
const eventKey = `pr-review:${repository.full_name}:${pr.number}:${review.id}`;
|
|
26907
|
-
if (
|
|
27431
|
+
if (isDuplicate3(eventKey)) {
|
|
26908
27432
|
return { created: false };
|
|
26909
27433
|
}
|
|
26910
27434
|
const { comments: inlineComments, degraded } = installation?.id ? await fetchReviewComments(repository.full_name, pr.number, review.id, installation.id) : { comments: [], degraded: true };
|
|
@@ -26916,7 +27440,7 @@ async function handlePullRequestReview(event) {
|
|
|
26916
27440
|
if (!isBotCreator && !existingTask) {
|
|
26917
27441
|
return { created: false };
|
|
26918
27442
|
}
|
|
26919
|
-
const lead = await
|
|
27443
|
+
const lead = await findLeadAgent3();
|
|
26920
27444
|
const { emoji, label } = getReviewStateInfo(review.state);
|
|
26921
27445
|
const reviewBodySection = review.body ? `
|
|
26922
27446
|
|
|
@@ -26968,9 +27492,7 @@ ${review.body}` : "";
|
|
|
26968
27492
|
} else {
|
|
26969
27493
|
console.log(`[GitHub] Created unassigned task ${task.id} for PR #${pr.number} review (${review.state}, no lead available)`);
|
|
26970
27494
|
}
|
|
26971
|
-
|
|
26972
|
-
addIssueReaction(repository.full_name, pr.number, "eyes", installation.id).catch((err) => console.error("[GitHub] failed to add issue reaction:", scrubSecrets(err instanceof Error ? err.message : String(err))));
|
|
26973
|
-
}
|
|
27495
|
+
addEyesReactionToTaskSource(task).catch(() => {});
|
|
26974
27496
|
return { created: true, taskId: task.id };
|
|
26975
27497
|
}
|
|
26976
27498
|
async function handleCheckRun(event) {
|
|
@@ -26993,46 +27515,46 @@ async function handleWorkflowRun(event) {
|
|
|
26993
27515
|
}
|
|
26994
27516
|
// src/gitlab/auth.ts
|
|
26995
27517
|
init_env_flag();
|
|
26996
|
-
var
|
|
26997
|
-
var
|
|
26998
|
-
var
|
|
27518
|
+
var initialized4 = false;
|
|
27519
|
+
var webhookSecret4 = null;
|
|
27520
|
+
var apiToken2 = null;
|
|
26999
27521
|
var gitlabUrl = "https://gitlab.com";
|
|
27000
27522
|
function isGitLabEnabled() {
|
|
27001
27523
|
return !!process.env.GITLAB_WEBHOOK_SECRET && !isEnvFlagEnabled("GITLAB_DISABLE", false);
|
|
27002
27524
|
}
|
|
27003
27525
|
function initGitLab() {
|
|
27004
|
-
if (
|
|
27526
|
+
if (initialized4)
|
|
27005
27527
|
return;
|
|
27006
27528
|
if (!isGitLabEnabled()) {
|
|
27007
27529
|
console.log("[GitLab] Integration disabled (GITLAB_WEBHOOK_SECRET not set)");
|
|
27008
27530
|
return;
|
|
27009
27531
|
}
|
|
27010
|
-
|
|
27011
|
-
|
|
27532
|
+
webhookSecret4 = process.env.GITLAB_WEBHOOK_SECRET;
|
|
27533
|
+
apiToken2 = process.env.GITLAB_TOKEN ?? null;
|
|
27012
27534
|
gitlabUrl = process.env.GITLAB_URL ?? "https://gitlab.com";
|
|
27013
|
-
|
|
27535
|
+
initialized4 = true;
|
|
27014
27536
|
console.log(`[GitLab] Integration initialized (url: ${gitlabUrl})`);
|
|
27015
27537
|
}
|
|
27016
27538
|
function verifyGitLabWebhook(tokenHeader) {
|
|
27017
|
-
if (!
|
|
27539
|
+
if (!webhookSecret4)
|
|
27018
27540
|
return false;
|
|
27019
27541
|
if (!tokenHeader)
|
|
27020
27542
|
return false;
|
|
27021
|
-
if (tokenHeader.length !==
|
|
27543
|
+
if (tokenHeader.length !== webhookSecret4.length)
|
|
27022
27544
|
return false;
|
|
27023
|
-
return crypto.timingSafeEqual(Buffer.from(tokenHeader), Buffer.from(
|
|
27545
|
+
return crypto.timingSafeEqual(Buffer.from(tokenHeader), Buffer.from(webhookSecret4));
|
|
27024
27546
|
}
|
|
27025
27547
|
function getGitLabToken() {
|
|
27026
|
-
return
|
|
27548
|
+
return apiToken2;
|
|
27027
27549
|
}
|
|
27028
27550
|
function getGitLabUrl() {
|
|
27029
27551
|
return gitlabUrl;
|
|
27030
27552
|
}
|
|
27031
27553
|
var GITLAB_BOT_NAME = process.env.GITLAB_BOT_NAME ?? "agent-swarm-bot";
|
|
27032
27554
|
function resetGitLab() {
|
|
27033
|
-
|
|
27034
|
-
|
|
27035
|
-
|
|
27555
|
+
initialized4 = false;
|
|
27556
|
+
webhookSecret4 = null;
|
|
27557
|
+
apiToken2 = null;
|
|
27036
27558
|
gitlabUrl = "https://gitlab.com";
|
|
27037
27559
|
}
|
|
27038
27560
|
// src/gitlab/handlers.ts
|
|
@@ -27041,7 +27563,7 @@ init_resolver();
|
|
|
27041
27563
|
init_context_key();
|
|
27042
27564
|
|
|
27043
27565
|
// src/gitlab/reactions.ts
|
|
27044
|
-
function
|
|
27566
|
+
function headers2() {
|
|
27045
27567
|
const token = getGitLabToken();
|
|
27046
27568
|
if (!token)
|
|
27047
27569
|
throw new Error("[GitLab] No API token configured");
|
|
@@ -27062,7 +27584,7 @@ async function addGitLabReaction(project, entityType, iid, emojiName) {
|
|
|
27062
27584
|
try {
|
|
27063
27585
|
const resp = await fetch(url, {
|
|
27064
27586
|
method: "POST",
|
|
27065
|
-
headers:
|
|
27587
|
+
headers: headers2(),
|
|
27066
27588
|
body: JSON.stringify({ name: emojiName })
|
|
27067
27589
|
});
|
|
27068
27590
|
if (!resp.ok) {
|
|
@@ -27078,7 +27600,7 @@ async function addGitLabNoteReaction(project, entityType, iid, noteId, emojiName
|
|
|
27078
27600
|
try {
|
|
27079
27601
|
const resp = await fetch(url, {
|
|
27080
27602
|
method: "POST",
|
|
27081
|
-
headers:
|
|
27603
|
+
headers: headers2(),
|
|
27082
27604
|
body: JSON.stringify({ name: emojiName })
|
|
27083
27605
|
});
|
|
27084
27606
|
if (!resp.ok) {
|
|
@@ -27202,33 +27724,33 @@ The CI pipeline has failed. Please investigate and fix the issues.{{@template[co
|
|
|
27202
27724
|
});
|
|
27203
27725
|
|
|
27204
27726
|
// src/gitlab/handlers.ts
|
|
27205
|
-
var
|
|
27206
|
-
var
|
|
27207
|
-
function
|
|
27727
|
+
var processedEvents4 = new Map;
|
|
27728
|
+
var DEDUP_TTL_MS2 = 60000;
|
|
27729
|
+
function isDuplicate4(key) {
|
|
27208
27730
|
const now = Date.now();
|
|
27209
|
-
for (const [k, ts] of
|
|
27210
|
-
if (now - ts >
|
|
27211
|
-
|
|
27731
|
+
for (const [k, ts] of processedEvents4) {
|
|
27732
|
+
if (now - ts > DEDUP_TTL_MS2)
|
|
27733
|
+
processedEvents4.delete(k);
|
|
27212
27734
|
}
|
|
27213
|
-
if (
|
|
27735
|
+
if (processedEvents4.has(key))
|
|
27214
27736
|
return true;
|
|
27215
|
-
|
|
27737
|
+
processedEvents4.set(key, now);
|
|
27216
27738
|
return false;
|
|
27217
27739
|
}
|
|
27218
|
-
function
|
|
27740
|
+
function detectMention3(text) {
|
|
27219
27741
|
if (!text)
|
|
27220
27742
|
return false;
|
|
27221
27743
|
return new RegExp(`@${GITLAB_BOT_NAME}\\b`, "i").test(text);
|
|
27222
27744
|
}
|
|
27223
|
-
function
|
|
27745
|
+
function extractMentionContext3(text) {
|
|
27224
27746
|
return text.replace(new RegExp(`@${GITLAB_BOT_NAME}\\b`, "gi"), "").trim();
|
|
27225
27747
|
}
|
|
27226
|
-
async function
|
|
27748
|
+
async function findLeadAgent4() {
|
|
27227
27749
|
const agents = await getAllAgents();
|
|
27228
27750
|
return agents.find((a) => a.role === "lead" && a.status === "idle") ?? agents.find((a) => a.role === "lead") ?? null;
|
|
27229
27751
|
}
|
|
27230
|
-
var
|
|
27231
|
-
var
|
|
27752
|
+
var UNMAPPED_NAMESPACE3 = "integration:unmapped:gitlab";
|
|
27753
|
+
var UNMAPPED_TTL_MS3 = 30 * 24 * 60 * 60 * 1000;
|
|
27232
27754
|
var GITLAB_WEBHOOK_ACTOR = { kind: "system", id: "webhook:gitlab" };
|
|
27233
27755
|
async function resolveGitLabSender(user, sampleEventType, sampleContext) {
|
|
27234
27756
|
const existing = await findUserByExternalId("gitlab", user.username);
|
|
@@ -27241,7 +27763,7 @@ async function resolveGitLabSender(user, sampleEventType, sampleContext) {
|
|
|
27241
27763
|
return linked.id;
|
|
27242
27764
|
}
|
|
27243
27765
|
await upsertKv({
|
|
27244
|
-
namespace:
|
|
27766
|
+
namespace: UNMAPPED_NAMESPACE3,
|
|
27245
27767
|
key: `${user.username}:meta`,
|
|
27246
27768
|
value: {
|
|
27247
27769
|
lastSeenAt: new Date().toISOString(),
|
|
@@ -27249,9 +27771,9 @@ async function resolveGitLabSender(user, sampleEventType, sampleContext) {
|
|
|
27249
27771
|
sampleContext: sampleContext.slice(0, 100)
|
|
27250
27772
|
},
|
|
27251
27773
|
valueType: "json",
|
|
27252
|
-
expiresAt: Date.now() +
|
|
27774
|
+
expiresAt: Date.now() + UNMAPPED_TTL_MS3
|
|
27253
27775
|
});
|
|
27254
|
-
await incrKv(
|
|
27776
|
+
await incrKv(UNMAPPED_NAMESPACE3, `${user.username}:count`, 1);
|
|
27255
27777
|
return;
|
|
27256
27778
|
}
|
|
27257
27779
|
async function renderGitLabIdentity(username) {
|
|
@@ -27264,19 +27786,19 @@ async function handleMergeRequest(event) {
|
|
|
27264
27786
|
const requestedByUserId = await resolveGitLabSender(user, "merge_request", `MR !${mr.iid}: ${mr.title}`);
|
|
27265
27787
|
console.log(`[GitLab] MR #${mr.iid} ${action} by ${user.username} in ${repo}`);
|
|
27266
27788
|
const dedupKey = `gitlab-mr-${repo}-${mr.iid}-${action}-${user.username}`;
|
|
27267
|
-
if (
|
|
27789
|
+
if (isDuplicate4(dedupKey)) {
|
|
27268
27790
|
console.log(`[GitLab] Skipping duplicate MR event`);
|
|
27269
27791
|
return { created: false };
|
|
27270
27792
|
}
|
|
27271
|
-
const lead = await
|
|
27793
|
+
const lead = await findLeadAgent4();
|
|
27272
27794
|
switch (action) {
|
|
27273
27795
|
case "open": {
|
|
27274
|
-
const hasMention =
|
|
27796
|
+
const hasMention = detectMention3(mr.description);
|
|
27275
27797
|
if (!hasMention) {
|
|
27276
27798
|
console.log(`[GitLab] MR opened without bot mention, skipping`);
|
|
27277
27799
|
return { created: false };
|
|
27278
27800
|
}
|
|
27279
|
-
const context = mr.description ?
|
|
27801
|
+
const context = mr.description ? extractMentionContext3(mr.description) : "";
|
|
27280
27802
|
const contextSection = context ? `Context: ${context}
|
|
27281
27803
|
|
|
27282
27804
|
` : "";
|
|
@@ -27348,13 +27870,13 @@ async function handleIssue2(event) {
|
|
|
27348
27870
|
const requestedByUserId = await resolveGitLabSender(user, "issue", `Issue #${issue.iid}: ${issue.title}`);
|
|
27349
27871
|
console.log(`[GitLab] Issue #${issue.iid} ${action} by ${user.username} in ${repo}`);
|
|
27350
27872
|
const dedupKey = `gitlab-issue-${repo}-${issue.iid}-${action}-${user.username}`;
|
|
27351
|
-
if (
|
|
27873
|
+
if (isDuplicate4(dedupKey)) {
|
|
27352
27874
|
return { created: false };
|
|
27353
27875
|
}
|
|
27354
|
-
const lead = await
|
|
27876
|
+
const lead = await findLeadAgent4();
|
|
27355
27877
|
switch (action) {
|
|
27356
27878
|
case "open": {
|
|
27357
|
-
const hasMention =
|
|
27879
|
+
const hasMention = detectMention3(issue.description);
|
|
27358
27880
|
if (!hasMention) {
|
|
27359
27881
|
const isBotAssigned = event.assignees?.some((a) => a.username.toLowerCase() === GITLAB_BOT_NAME.toLowerCase());
|
|
27360
27882
|
if (!isBotAssigned) {
|
|
@@ -27362,7 +27884,7 @@ async function handleIssue2(event) {
|
|
|
27362
27884
|
return { created: false };
|
|
27363
27885
|
}
|
|
27364
27886
|
}
|
|
27365
|
-
const context = issue.description ?
|
|
27887
|
+
const context = issue.description ? extractMentionContext3(issue.description) : "";
|
|
27366
27888
|
const contextSection = context ? `Context: ${context}
|
|
27367
27889
|
|
|
27368
27890
|
` : "";
|
|
@@ -27418,16 +27940,16 @@ async function handleNote(event) {
|
|
|
27418
27940
|
const { user, project, object_attributes: note } = event;
|
|
27419
27941
|
const repo = project.path_with_namespace;
|
|
27420
27942
|
const requestedByUserId = await resolveGitLabSender(user, "note", note.note);
|
|
27421
|
-
if (!
|
|
27943
|
+
if (!detectMention3(note.note)) {
|
|
27422
27944
|
return { created: false };
|
|
27423
27945
|
}
|
|
27424
27946
|
console.log(`[GitLab] Note by ${user.username} in ${repo} (${note.noteable_type})`);
|
|
27425
27947
|
const dedupKey = `gitlab-note-${note.id}`;
|
|
27426
|
-
if (
|
|
27948
|
+
if (isDuplicate4(dedupKey)) {
|
|
27427
27949
|
return { created: false };
|
|
27428
27950
|
}
|
|
27429
|
-
const lead = await
|
|
27430
|
-
const context =
|
|
27951
|
+
const lead = await findLeadAgent4();
|
|
27952
|
+
const context = extractMentionContext3(note.note);
|
|
27431
27953
|
let targetNumber;
|
|
27432
27954
|
let targetUrl;
|
|
27433
27955
|
let eventType;
|
|
@@ -27501,14 +28023,14 @@ async function handlePipeline(event) {
|
|
|
27501
28023
|
}
|
|
27502
28024
|
const mrIid = event.merge_request.iid;
|
|
27503
28025
|
const dedupKey = `gitlab-pipeline-${pipeline2.id}`;
|
|
27504
|
-
if (
|
|
28026
|
+
if (isDuplicate4(dedupKey)) {
|
|
27505
28027
|
return { created: false };
|
|
27506
28028
|
}
|
|
27507
28029
|
const existingTask = await findTaskByVcs(repo, mrIid);
|
|
27508
28030
|
if (!existingTask) {
|
|
27509
28031
|
return { created: false };
|
|
27510
28032
|
}
|
|
27511
|
-
const lead = await
|
|
28033
|
+
const lead = await findLeadAgent4();
|
|
27512
28034
|
const pipelineResult = resolveTemplate("gitlab.pipeline.failed", {
|
|
27513
28035
|
pipeline_id: pipeline2.id,
|
|
27514
28036
|
mr_iid: mrIid,
|
|
@@ -27870,14 +28392,14 @@ async function jiraFetch(path, init) {
|
|
|
27870
28392
|
const send = async (token2) => {
|
|
27871
28393
|
const cloudId = await getJiraCloudId();
|
|
27872
28394
|
const url = `https://api.atlassian.com/ex/jira/${cloudId}${path}`;
|
|
27873
|
-
const
|
|
27874
|
-
|
|
27875
|
-
if (!
|
|
27876
|
-
|
|
27877
|
-
if (init?.body && !
|
|
27878
|
-
|
|
27879
|
-
}
|
|
27880
|
-
return fetch(url, { ...init, headers:
|
|
28395
|
+
const headers3 = new Headers(init?.headers);
|
|
28396
|
+
headers3.set("Authorization", `Bearer ${token2}`);
|
|
28397
|
+
if (!headers3.has("Accept"))
|
|
28398
|
+
headers3.set("Accept", "application/json");
|
|
28399
|
+
if (init?.body && !headers3.has("Content-Type")) {
|
|
28400
|
+
headers3.set("Content-Type", "application/json");
|
|
28401
|
+
}
|
|
28402
|
+
return fetch(url, { ...init, headers: headers3 });
|
|
27881
28403
|
};
|
|
27882
28404
|
let token = await getJiraAccessToken();
|
|
27883
28405
|
let response = await send(token);
|
|
@@ -28201,7 +28723,7 @@ async function resolveBotAccountId() {
|
|
|
28201
28723
|
function resetBotAccountIdCache() {
|
|
28202
28724
|
setCachedBotAccountId(null);
|
|
28203
28725
|
}
|
|
28204
|
-
async function
|
|
28726
|
+
async function findLeadAgent5() {
|
|
28205
28727
|
const agents = await getAllAgents();
|
|
28206
28728
|
const onlineLead = agents.find((a) => a.isLead && a.status !== "offline");
|
|
28207
28729
|
if (onlineLead)
|
|
@@ -28405,7 +28927,7 @@ async function handleIssueDeleteEvent(event) {
|
|
|
28405
28927
|
}
|
|
28406
28928
|
}
|
|
28407
28929
|
async function createInitialJiraTask(input) {
|
|
28408
|
-
const lead = await
|
|
28930
|
+
const lead = await findLeadAgent5();
|
|
28409
28931
|
const descriptionSection = input.descriptionText ? `
|
|
28410
28932
|
Description:
|
|
28411
28933
|
${input.descriptionText}
|
|
@@ -28443,7 +28965,7 @@ ${input.descriptionText}
|
|
|
28443
28965
|
console.log(`[Jira Sync] Created ${action} task ${task.id} for ${input.issueKey} -> ${lead?.name ?? "unassigned"}`);
|
|
28444
28966
|
}
|
|
28445
28967
|
async function createCommentMentionTask(input) {
|
|
28446
|
-
const lead = await
|
|
28968
|
+
const lead = await findLeadAgent5();
|
|
28447
28969
|
const descriptionSection = input.descriptionText ? `
|
|
28448
28970
|
Description:
|
|
28449
28971
|
${input.descriptionText}
|
|
@@ -28503,7 +29025,7 @@ async function notifySlack(text) {
|
|
|
28503
29025
|
return;
|
|
28504
29026
|
}
|
|
28505
29027
|
try {
|
|
28506
|
-
const { getSlackApp: getSlackApp2 } = await import("./app-
|
|
29028
|
+
const { getSlackApp: getSlackApp2 } = await import("./app-pt68fbwp.js");
|
|
28507
29029
|
const app = getSlackApp2();
|
|
28508
29030
|
if (!app) {
|
|
28509
29031
|
console.warn("[Jira webhook keepalive] Slack not available, cannot send notification");
|
|
@@ -28574,7 +29096,7 @@ async function deleteJiraWebhook(webhookId) {
|
|
|
28574
29096
|
console.log(`[Jira webhook keepalive] Deleted webhook id=${webhookId}`);
|
|
28575
29097
|
}
|
|
28576
29098
|
async function overwriteWebhookIds(next) {
|
|
28577
|
-
const { getDbClient: getDbClient2 } = await import("./db-
|
|
29099
|
+
const { getDbClient: getDbClient2 } = await import("./db-7f5pecwg.js");
|
|
28578
29100
|
await getDbClient2().transaction(async (tx) => {
|
|
28579
29101
|
const row = await tx.get("SELECT metadata FROM oauth_apps WHERE provider = 'jira'");
|
|
28580
29102
|
if (!row) {
|
|
@@ -28681,7 +29203,7 @@ function stopJiraWebhookKeepalive() {
|
|
|
28681
29203
|
}
|
|
28682
29204
|
|
|
28683
29205
|
// src/jira/app.ts
|
|
28684
|
-
var
|
|
29206
|
+
var initialized5 = false;
|
|
28685
29207
|
function isJiraEnabled() {
|
|
28686
29208
|
const disabled = process.env.JIRA_DISABLE;
|
|
28687
29209
|
if (disabled === "true" || disabled === "1")
|
|
@@ -28695,12 +29217,12 @@ function resetJira() {
|
|
|
28695
29217
|
resetBotAccountIdCache();
|
|
28696
29218
|
teardownJiraOutboundSync();
|
|
28697
29219
|
stopJiraWebhookKeepalive();
|
|
28698
|
-
|
|
29220
|
+
initialized5 = false;
|
|
28699
29221
|
}
|
|
28700
29222
|
async function initJira() {
|
|
28701
|
-
if (
|
|
29223
|
+
if (initialized5)
|
|
28702
29224
|
return isJiraEnabled();
|
|
28703
|
-
|
|
29225
|
+
initialized5 = true;
|
|
28704
29226
|
if (!isJiraEnabled()) {
|
|
28705
29227
|
console.log("[Jira] Integration disabled or JIRA_CLIENT_ID not set");
|
|
28706
29228
|
return false;
|
|
@@ -28921,14 +29443,14 @@ var InvalidInputLinearError = class extends LinearError {
|
|
|
28921
29443
|
var RatelimitedLinearError = class extends LinearError {
|
|
28922
29444
|
constructor(error, errors) {
|
|
28923
29445
|
super(error, errors, LinearErrorType.Ratelimited);
|
|
28924
|
-
const
|
|
28925
|
-
this.retryAfter = this.parseNumber(
|
|
28926
|
-
this.requestsLimit = this.parseNumber(
|
|
28927
|
-
this.requestsRemaining = this.parseNumber(
|
|
28928
|
-
this.requestsResetAt = this.parseNumber(
|
|
28929
|
-
this.complexityLimit = this.parseNumber(
|
|
28930
|
-
this.complexityRemaining = this.parseNumber(
|
|
28931
|
-
this.complexityResetAt = this.parseNumber(
|
|
29446
|
+
const headers3 = error?.response?.headers;
|
|
29447
|
+
this.retryAfter = this.parseNumber(headers3?.get("retry-after"));
|
|
29448
|
+
this.requestsLimit = this.parseNumber(headers3?.get("x-ratelimit-requests-limit"));
|
|
29449
|
+
this.requestsRemaining = this.parseNumber(headers3?.get("x-ratelimit-requests-remaining"));
|
|
29450
|
+
this.requestsResetAt = this.parseNumber(headers3?.get("x-ratelimit-requests-reset"));
|
|
29451
|
+
this.complexityLimit = this.parseNumber(headers3?.get("x-ratelimit-complexity-limit"));
|
|
29452
|
+
this.complexityRemaining = this.parseNumber(headers3?.get("x-ratelimit-complexity-remaining"));
|
|
29453
|
+
this.complexityResetAt = this.parseNumber(headers3?.get("x-ratelimit-complexity-reset"));
|
|
28932
29454
|
}
|
|
28933
29455
|
retryAfter;
|
|
28934
29456
|
requestsLimit;
|
|
@@ -29951,7 +30473,7 @@ var LinearGraphQLClient = class {
|
|
|
29951
30473
|
this.options = options || {};
|
|
29952
30474
|
}
|
|
29953
30475
|
async rawRequest(query, variables, requestHeaders) {
|
|
29954
|
-
const { headers:
|
|
30476
|
+
const { headers: headers3, ...others } = this.options;
|
|
29955
30477
|
const body = JSON.stringify({
|
|
29956
30478
|
query,
|
|
29957
30479
|
variables
|
|
@@ -29961,7 +30483,7 @@ var LinearGraphQLClient = class {
|
|
|
29961
30483
|
method: "POST",
|
|
29962
30484
|
headers: {
|
|
29963
30485
|
...typeof body === "string" ? { "Content-Type": "application/json" } : {},
|
|
29964
|
-
...resolveHeaders(
|
|
30486
|
+
...resolveHeaders(headers3),
|
|
29965
30487
|
...resolveHeaders(requestHeaders)
|
|
29966
30488
|
},
|
|
29967
30489
|
body,
|
|
@@ -29985,7 +30507,7 @@ var LinearGraphQLClient = class {
|
|
|
29985
30507
|
}));
|
|
29986
30508
|
}
|
|
29987
30509
|
async request(document2, variables, requestHeaders) {
|
|
29988
|
-
const { headers:
|
|
30510
|
+
const { headers: headers3, ...others } = this.options;
|
|
29989
30511
|
const query = typeof document2 === "string" ? document2 : (0, import_printer.print)(document2);
|
|
29990
30512
|
const body = JSON.stringify({
|
|
29991
30513
|
query,
|
|
@@ -29995,7 +30517,7 @@ var LinearGraphQLClient = class {
|
|
|
29995
30517
|
method: "POST",
|
|
29996
30518
|
headers: {
|
|
29997
30519
|
...typeof body === "string" ? { "Content-Type": "application/json" } : {},
|
|
29998
|
-
...resolveHeaders(
|
|
30520
|
+
...resolveHeaders(headers3),
|
|
29999
30521
|
...resolveHeaders(requestHeaders)
|
|
30000
30522
|
},
|
|
30001
30523
|
body,
|
|
@@ -30014,14 +30536,14 @@ var LinearGraphQLClient = class {
|
|
|
30014
30536
|
variables
|
|
30015
30537
|
});
|
|
30016
30538
|
}
|
|
30017
|
-
setHeaders(
|
|
30018
|
-
this.options.headers =
|
|
30539
|
+
setHeaders(headers3) {
|
|
30540
|
+
this.options.headers = headers3;
|
|
30019
30541
|
return this;
|
|
30020
30542
|
}
|
|
30021
30543
|
setHeader(key, value) {
|
|
30022
|
-
const { headers:
|
|
30023
|
-
if (
|
|
30024
|
-
|
|
30544
|
+
const { headers: headers3 } = this.options;
|
|
30545
|
+
if (headers3)
|
|
30546
|
+
headers3[key] = value;
|
|
30025
30547
|
else
|
|
30026
30548
|
this.options.headers = { [key]: value };
|
|
30027
30549
|
return this;
|
|
@@ -30034,22 +30556,22 @@ function getResult(response) {
|
|
|
30034
30556
|
else
|
|
30035
30557
|
return response.text();
|
|
30036
30558
|
}
|
|
30037
|
-
function resolveHeaders(
|
|
30559
|
+
function resolveHeaders(headers3) {
|
|
30038
30560
|
let oHeaders = {};
|
|
30039
|
-
if (
|
|
30040
|
-
if (typeof Headers !== "undefined" &&
|
|
30041
|
-
oHeaders = headersToObject(
|
|
30042
|
-
else if (Array.isArray(
|
|
30043
|
-
|
|
30561
|
+
if (headers3)
|
|
30562
|
+
if (typeof Headers !== "undefined" && headers3 instanceof Headers)
|
|
30563
|
+
oHeaders = headersToObject(headers3);
|
|
30564
|
+
else if (Array.isArray(headers3))
|
|
30565
|
+
headers3.forEach(([name, value]) => {
|
|
30044
30566
|
oHeaders[name] = value;
|
|
30045
30567
|
});
|
|
30046
30568
|
else
|
|
30047
|
-
oHeaders =
|
|
30569
|
+
oHeaders = headers3;
|
|
30048
30570
|
return oHeaders;
|
|
30049
30571
|
}
|
|
30050
|
-
function headersToObject(
|
|
30572
|
+
function headersToObject(headers3) {
|
|
30051
30573
|
const o = {};
|
|
30052
|
-
|
|
30574
|
+
headers3.forEach((v, k) => {
|
|
30053
30575
|
o[k] = v;
|
|
30054
30576
|
});
|
|
30055
30577
|
return o;
|
|
@@ -93912,8 +94434,8 @@ var IssueVcsBranchSearchQuery = class extends Request2 {
|
|
|
93912
94434
|
constructor(request) {
|
|
93913
94435
|
super(request);
|
|
93914
94436
|
}
|
|
93915
|
-
async fetch(
|
|
93916
|
-
const data = (await this._request(IssueVcsBranchSearchDocument.toString(), { branchName })).issueVcsBranchSearch;
|
|
94437
|
+
async fetch(branchName2) {
|
|
94438
|
+
const data = (await this._request(IssueVcsBranchSearchDocument.toString(), { branchName: branchName2 })).issueVcsBranchSearch;
|
|
93917
94439
|
return data ? new Issue(this._request, data) : undefined;
|
|
93918
94440
|
}
|
|
93919
94441
|
};
|
|
@@ -99246,8 +99768,8 @@ var LinearSdk = class extends Request2 {
|
|
|
99246
99768
|
issueTitleSuggestionFromCustomerRequest(request) {
|
|
99247
99769
|
return new IssueTitleSuggestionFromCustomerRequestQuery(this._request).fetch(request);
|
|
99248
99770
|
}
|
|
99249
|
-
issueVcsBranchSearch(
|
|
99250
|
-
return new IssueVcsBranchSearchQuery(this._request).fetch(
|
|
99771
|
+
issueVcsBranchSearch(branchName2) {
|
|
99772
|
+
return new IssueVcsBranchSearchQuery(this._request).fetch(branchName2);
|
|
99251
99773
|
}
|
|
99252
99774
|
issues(variables) {
|
|
99253
99775
|
return new IssuesQuery(this._request).fetch(variables);
|
|
@@ -100264,13 +100786,13 @@ var LinearSdk = class extends Request2 {
|
|
|
100264
100786
|
return new UpdateWorkflowStateMutation(this._request).fetch(id, input);
|
|
100265
100787
|
}
|
|
100266
100788
|
};
|
|
100267
|
-
function parseClientOptions({ apiKey, accessToken, apiUrl, headers:
|
|
100789
|
+
function parseClientOptions({ apiKey, accessToken, apiUrl, headers: headers3, ...opts }) {
|
|
100268
100790
|
if (!accessToken && !apiKey)
|
|
100269
100791
|
throw new Error("No accessToken or apiKey provided to the LinearClient - create one here: https://linear.app/settings/account/security");
|
|
100270
100792
|
return {
|
|
100271
100793
|
headers: {
|
|
100272
100794
|
Authorization: accessToken ? accessToken.startsWith("Bearer ") ? accessToken : `Bearer ${accessToken}` : apiKey ?? "",
|
|
100273
|
-
...
|
|
100795
|
+
...headers3,
|
|
100274
100796
|
"User-Agent": serializeUserAgent({ [process.env.npm_package_name ?? "@linear/sdk"]: process.env.npm_package_version ?? "unknown" })
|
|
100275
100797
|
},
|
|
100276
100798
|
apiUrl: apiUrl ?? "https://api.linear.app/graphql",
|
|
@@ -100586,15 +101108,15 @@ async function _fetchIssueGatingInfo(issueId) {
|
|
|
100586
101108
|
const labelNames = (json.data?.issue?.labels?.nodes ?? []).map((n) => n?.name ?? "").filter((n) => n.length > 0);
|
|
100587
101109
|
return { stateType, labelNames };
|
|
100588
101110
|
}
|
|
100589
|
-
async function
|
|
101111
|
+
async function findLeadAgent6() {
|
|
100590
101112
|
const agents = await getAllAgents();
|
|
100591
101113
|
const onlineLead = agents.find((a) => a.isLead && a.status !== "offline");
|
|
100592
101114
|
if (onlineLead)
|
|
100593
101115
|
return onlineLead;
|
|
100594
101116
|
return agents.find((a) => a.isLead) ?? null;
|
|
100595
101117
|
}
|
|
100596
|
-
var
|
|
100597
|
-
var
|
|
101118
|
+
var UNMAPPED_NAMESPACE4 = "integration:unmapped:linear";
|
|
101119
|
+
var UNMAPPED_TTL_MS4 = 30 * 24 * 60 * 60 * 1000;
|
|
100598
101120
|
var LINEAR_WEBHOOK_ACTOR = { kind: "system", id: "webhook:linear" };
|
|
100599
101121
|
var APP_USER_ID_NAMESPACE = "integration:linear:bot-app-user-id";
|
|
100600
101122
|
async function getStoredAppUserId(workspaceId) {
|
|
@@ -100625,7 +101147,7 @@ async function resolveLinearActor(linearUserId, email, name, workspaceId, sample
|
|
|
100625
101147
|
return linked.id;
|
|
100626
101148
|
}
|
|
100627
101149
|
await upsertKv({
|
|
100628
|
-
namespace:
|
|
101150
|
+
namespace: UNMAPPED_NAMESPACE4,
|
|
100629
101151
|
key: `${linearUserId}:meta`,
|
|
100630
101152
|
value: {
|
|
100631
101153
|
lastSeenAt: new Date().toISOString(),
|
|
@@ -100633,9 +101155,9 @@ async function resolveLinearActor(linearUserId, email, name, workspaceId, sample
|
|
|
100633
101155
|
sampleContext: sampleContext ? sampleContext.slice(0, 100) : null
|
|
100634
101156
|
},
|
|
100635
101157
|
valueType: "json",
|
|
100636
|
-
expiresAt: Date.now() +
|
|
101158
|
+
expiresAt: Date.now() + UNMAPPED_TTL_MS4
|
|
100637
101159
|
});
|
|
100638
|
-
await incrKv(
|
|
101160
|
+
await incrKv(UNMAPPED_NAMESPACE4, `${linearUserId}:count`, 1);
|
|
100639
101161
|
return;
|
|
100640
101162
|
}
|
|
100641
101163
|
async function handleAgentSessionEvent(event) {
|
|
@@ -100706,7 +101228,7 @@ async function handleAgentSessionEvent(event) {
|
|
|
100706
101228
|
}
|
|
100707
101229
|
return;
|
|
100708
101230
|
}
|
|
100709
|
-
const lead = await
|
|
101231
|
+
const lead = await findLeadAgent6();
|
|
100710
101232
|
const sessionSection = sessionUrl ? `
|
|
100711
101233
|
Session: ${sessionUrl}` : "";
|
|
100712
101234
|
const descriptionSection = issueDescription ? `
|
|
@@ -100907,7 +101429,7 @@ async function handleAgentSessionPrompted(event) {
|
|
|
100907
101429
|
return;
|
|
100908
101430
|
}
|
|
100909
101431
|
}
|
|
100910
|
-
const lead = await
|
|
101432
|
+
const lead = await findLeadAgent6();
|
|
100911
101433
|
const activity = event.agentActivity;
|
|
100912
101434
|
const promptUser = activity?.user;
|
|
100913
101435
|
const promptedActorLinearId = promptUser ? String(promptUser.id ?? "") : "";
|
|
@@ -101189,7 +101711,7 @@ function shouldSkipForLoopPrevention2(sync) {
|
|
|
101189
101711
|
}
|
|
101190
101712
|
|
|
101191
101713
|
// src/linear/app.ts
|
|
101192
|
-
var
|
|
101714
|
+
var initialized6 = false;
|
|
101193
101715
|
var unsubscribeRefresh = null;
|
|
101194
101716
|
function isLinearEnabled() {
|
|
101195
101717
|
const disabled = process.env.LINEAR_DISABLE;
|
|
@@ -101206,12 +101728,12 @@ function resetLinear() {
|
|
|
101206
101728
|
unsubscribeRefresh();
|
|
101207
101729
|
unsubscribeRefresh = null;
|
|
101208
101730
|
}
|
|
101209
|
-
|
|
101731
|
+
initialized6 = false;
|
|
101210
101732
|
}
|
|
101211
101733
|
async function initLinear() {
|
|
101212
|
-
if (
|
|
101734
|
+
if (initialized6)
|
|
101213
101735
|
return isLinearEnabled();
|
|
101214
|
-
|
|
101736
|
+
initialized6 = true;
|
|
101215
101737
|
if (!isLinearEnabled()) {
|
|
101216
101738
|
console.log("[Linear] Integration disabled or LINEAR_CLIENT_ID not set");
|
|
101217
101739
|
return false;
|
|
@@ -101257,6 +101779,8 @@ function warnIfMcpBaseUrlLooksLikeAppUrl2() {
|
|
|
101257
101779
|
console.warn(`[Linear] WARNING: MCP_BASE_URL (${mcp}) equals APP_URL — surfaced webhook URL points at the dashboard host, not the API. Configure Linear with this URL only if the dashboard host also serves /api/*.`);
|
|
101258
101780
|
}
|
|
101259
101781
|
}
|
|
101782
|
+
// src/http/core.ts
|
|
101783
|
+
init_rbac();
|
|
101260
101784
|
// src/slack/files.ts
|
|
101261
101785
|
import { createWriteStream } from "node:fs";
|
|
101262
101786
|
import { mkdir } from "node:fs/promises";
|
|
@@ -102306,11 +102830,11 @@ async function reloadGlobalConfigsAndIntegrations() {
|
|
|
102306
102830
|
return runWithoutRequestAuth(() => reloadGlobalConfigsAndIntegrationsInner());
|
|
102307
102831
|
}
|
|
102308
102832
|
async function reloadGlobalConfigsAndIntegrationsInner() {
|
|
102309
|
-
const { getEmbeddingProvider: getEmbeddingProvider2, resetEmbeddingProvider } = await import("./index-
|
|
102833
|
+
const { getEmbeddingProvider: getEmbeddingProvider2, resetEmbeddingProvider } = await import("./index-s75wc4wd.js");
|
|
102310
102834
|
const wasEmbeddingsConfigured = getEmbeddingProvider2().isConfigured();
|
|
102311
102835
|
const updated = await loadGlobalConfigsIntoEnv(true);
|
|
102312
102836
|
await stopSlackApp();
|
|
102313
|
-
const { resetFileStorageProvider } = await import("./registry-
|
|
102837
|
+
const { resetFileStorageProvider } = await import("./registry-km6t1jd2.js");
|
|
102314
102838
|
resetFileStorageProvider();
|
|
102315
102839
|
resetEmbeddingProvider();
|
|
102316
102840
|
const isEmbeddingsConfigured = getEmbeddingProvider2().isConfigured();
|
|
@@ -102319,10 +102843,10 @@ async function reloadGlobalConfigsAndIntegrationsInner() {
|
|
|
102319
102843
|
integrations.push("embeddings");
|
|
102320
102844
|
}
|
|
102321
102845
|
if (!wasEmbeddingsConfigured && isEmbeddingsConfigured) {
|
|
102322
|
-
import("./boot-reembed-
|
|
102846
|
+
import("./boot-reembed-nxpcvpj9.js").then(({ runBootReembed }) => runBootReembed()).catch((err) => {
|
|
102323
102847
|
console.error("[config-reload] memory backfill failed (non-fatal):", err);
|
|
102324
102848
|
});
|
|
102325
|
-
import("./boot-reembed-
|
|
102849
|
+
import("./boot-reembed-4ht4gqth.js").then(({ runBootReembedScripts }) => runBootReembedScripts()).catch((err) => {
|
|
102326
102850
|
console.error("[config-reload] script backfill failed (non-fatal):", err);
|
|
102327
102851
|
});
|
|
102328
102852
|
}
|
|
@@ -102336,6 +102860,11 @@ async function reloadGlobalConfigsAndIntegrationsInner() {
|
|
|
102336
102860
|
initGitLab();
|
|
102337
102861
|
if (isGitLabEnabled())
|
|
102338
102862
|
integrations.push("gitlab");
|
|
102863
|
+
resetAzureDevOps();
|
|
102864
|
+
resetAzureDevOpsBotIdCache();
|
|
102865
|
+
initAzureDevOps();
|
|
102866
|
+
if (isAzureDevOpsEnabled())
|
|
102867
|
+
integrations.push("azure-devops");
|
|
102339
102868
|
resetLinear();
|
|
102340
102869
|
if (await initLinear())
|
|
102341
102870
|
integrations.push("linear");
|
|
@@ -102392,7 +102921,7 @@ var pingRoute = route({
|
|
|
102392
102921
|
path: "/ping",
|
|
102393
102922
|
pattern: ["ping"],
|
|
102394
102923
|
summary: "Report agent liveness",
|
|
102395
|
-
description: `Refreshes the calling agent's status. ${RUNTIME_HEADER_DOC} With multi-runtime mode on, the header must identify a live runtime of this agent; an absent, unknown, offline, or foreign identifier makes the call a no-op instead of an error, so workers predating the flag keep running.`,
|
|
102924
|
+
description: `Refreshes the calling agent's status. ${RUNTIME_HEADER_DOC} With multi-runtime mode on, the header must identify a live runtime of this agent; an absent, unknown, offline, or foreign identifier makes the call a no-op instead of an error, so workers predating the flag keep running. While the API is draining after SIGTERM, every response (this one included) carries \`X-Swarm-Draining: 1\`: workers hand off in-flight tasks and take no new work.`,
|
|
102396
102925
|
tags: ["Core"],
|
|
102397
102926
|
auth: { apiKey: true, agentId: true },
|
|
102398
102927
|
headers: runtimeInstanceHeader("refresh a runtime's liveness"),
|
|
@@ -102643,12 +103172,16 @@ async function handleCore(req, res, myAgentId, apiKey) {
|
|
|
102643
103172
|
|
|
102644
103173
|
// src/server.ts
|
|
102645
103174
|
init_resolver();
|
|
103175
|
+
init_rbac();
|
|
102646
103176
|
init_config();
|
|
102647
103177
|
|
|
102648
103178
|
// src/tools/accept-steer.ts
|
|
102649
103179
|
init_zod();
|
|
102650
103180
|
init_db();
|
|
102651
103181
|
|
|
103182
|
+
// src/tools/task-tool-ctx.ts
|
|
103183
|
+
init_rbac();
|
|
103184
|
+
|
|
102652
103185
|
// src/tools/utils.ts
|
|
102653
103186
|
init_zod();
|
|
102654
103187
|
init_db();
|
|
@@ -103135,7 +103668,7 @@ function setPreloadedTools(server, names) {
|
|
|
103135
103668
|
async function applyPreToolCall(name, args, requestInfo, inputSchema) {
|
|
103136
103669
|
if (requestInfo.callOrigin !== "mcp")
|
|
103137
103670
|
return { args };
|
|
103138
|
-
const dispatcher = await import("./dispatcher-
|
|
103671
|
+
const dispatcher = await import("./dispatcher-fh9at8nz.js");
|
|
103139
103672
|
const result = await dispatcher.dispatchPre("pre.tool.call", { tool: name, args, requestInfo }, inputSchema ? {
|
|
103140
103673
|
validateModify: async (data) => {
|
|
103141
103674
|
const schema = normalizeObjectSchema(inputSchema) ?? inputSchema;
|
|
@@ -105147,10 +105680,12 @@ async function rollbackApp(input) {
|
|
|
105147
105680
|
|
|
105148
105681
|
// src/tools/app-diff.ts
|
|
105149
105682
|
init_db();
|
|
105683
|
+
init_rbac();
|
|
105150
105684
|
|
|
105151
105685
|
// src/tools/context-diff.ts
|
|
105152
105686
|
init_zod();
|
|
105153
105687
|
init_db();
|
|
105688
|
+
init_rbac();
|
|
105154
105689
|
import { tmpdir } from "node:os";
|
|
105155
105690
|
import { join } from "node:path";
|
|
105156
105691
|
async function computeDiff(oldContent, newContent, labels = { old: "old", new: "new" }) {
|
|
@@ -105187,6 +105722,7 @@ var registerContextDiffTool = (server) => {
|
|
|
105187
105722
|
fromVersion: number().optional(),
|
|
105188
105723
|
toVersion: number().optional(),
|
|
105189
105724
|
diff: string().optional(),
|
|
105725
|
+
predecessorPruned: boolean().optional(),
|
|
105190
105726
|
changeSource: string().optional(),
|
|
105191
105727
|
createdAt: string().optional()
|
|
105192
105728
|
})
|
|
@@ -105234,6 +105770,20 @@ var registerContextDiffTool = (server) => {
|
|
|
105234
105770
|
} else if (version.previousVersionId) {
|
|
105235
105771
|
compareVersion = await getContextVersion(version.previousVersionId);
|
|
105236
105772
|
}
|
|
105773
|
+
if (!compareToVersionId && !compareVersion && version.version > 1) {
|
|
105774
|
+
const message = `No predecessor for ${version.field} v${version.version}: v${version.version - 1} was removed by context version retention. Pass compareToVersionId with a surviving version from context-history.`;
|
|
105775
|
+
return toolOk(message, {
|
|
105776
|
+
details: message,
|
|
105777
|
+
data: {
|
|
105778
|
+
yourAgentId: requestInfo.agentId,
|
|
105779
|
+
field: version.field,
|
|
105780
|
+
toVersion: version.version,
|
|
105781
|
+
predecessorPruned: true,
|
|
105782
|
+
changeSource: version.changeSource,
|
|
105783
|
+
createdAt: version.createdAt
|
|
105784
|
+
}
|
|
105785
|
+
});
|
|
105786
|
+
}
|
|
105237
105787
|
const oldContent = compareVersion?.content ?? "";
|
|
105238
105788
|
const diff = await computeDiff(oldContent, version.content);
|
|
105239
105789
|
const fromVersion = compareVersion?.version ?? 0;
|
|
@@ -105406,6 +105956,7 @@ async function upsertAppUserConfigValues(appId2, scope, values) {
|
|
|
105406
105956
|
init_key();
|
|
105407
105957
|
init_db();
|
|
105408
105958
|
init_resolver();
|
|
105959
|
+
init_rbac();
|
|
105409
105960
|
init_types();
|
|
105410
105961
|
init_request_auth_context();
|
|
105411
105962
|
init_secret_scrubber();
|
|
@@ -106849,6 +107400,7 @@ async function handleApps(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
106849
107400
|
}
|
|
106850
107401
|
|
|
106851
107402
|
// src/tools/app-get.ts
|
|
107403
|
+
init_rbac();
|
|
106852
107404
|
function escapeTableCell(value) {
|
|
106853
107405
|
const rendered = typeof value === "object" && value !== null ? JSON.stringify(value) : value;
|
|
106854
107406
|
return String(rendered ?? "—").replaceAll("\\", "\\\\").replaceAll("|", "\\|").replace(/\r\n|\r|\n/g, "<br>");
|
|
@@ -106960,6 +107512,7 @@ var registerAppQueryTool = (server) => {
|
|
|
106960
107512
|
// src/tools/app-history.ts
|
|
106961
107513
|
init_zod();
|
|
106962
107514
|
init_db();
|
|
107515
|
+
init_rbac();
|
|
106963
107516
|
function escapeTableCell2(value) {
|
|
106964
107517
|
return String(value ?? "—").replaceAll("\\", "\\\\").replaceAll("|", "\\|").replace(/\r\n|\r|\n/g, "<br>");
|
|
106965
107518
|
}
|
|
@@ -107064,6 +107617,7 @@ var registerAppListTool = (server) => {
|
|
|
107064
107617
|
// src/tools/app-patch.ts
|
|
107065
107618
|
init_zod();
|
|
107066
107619
|
init_db();
|
|
107620
|
+
init_rbac();
|
|
107067
107621
|
var registerAppPatchTool = (server) => {
|
|
107068
107622
|
createToolRegistrar(server)("app-patch", {
|
|
107069
107623
|
title: "Patch an app",
|
|
@@ -107184,6 +107738,7 @@ var registerAppPatchTool = (server) => {
|
|
|
107184
107738
|
// src/tools/app-rollback.ts
|
|
107185
107739
|
init_zod();
|
|
107186
107740
|
init_db();
|
|
107741
|
+
init_rbac();
|
|
107187
107742
|
var registerAppRollbackTool = (server) => {
|
|
107188
107743
|
createToolRegistrar(server)("app-rollback", {
|
|
107189
107744
|
title: "Rollback an app",
|
|
@@ -107263,6 +107818,7 @@ var registerAppRollbackTool = (server) => {
|
|
|
107263
107818
|
// src/tools/app-sync.ts
|
|
107264
107819
|
init_zod();
|
|
107265
107820
|
init_db();
|
|
107821
|
+
init_rbac();
|
|
107266
107822
|
function cell(value) {
|
|
107267
107823
|
return String(value ?? "—").replaceAll("\\", "\\\\").replaceAll("|", "\\|").replace(/\r\n|\r|\n/g, "<br>");
|
|
107268
107824
|
}
|
|
@@ -107349,6 +107905,7 @@ var registerAppSyncTool = (server) => {
|
|
|
107349
107905
|
// src/tools/app-upsert.ts
|
|
107350
107906
|
init_zod();
|
|
107351
107907
|
init_db();
|
|
107908
|
+
init_rbac();
|
|
107352
107909
|
var registerAppUpsertTool = (server) => {
|
|
107353
107910
|
createToolRegistrar(server)("app-upsert", {
|
|
107354
107911
|
title: "Create or update an app",
|
|
@@ -107495,6 +108052,7 @@ init_db();
|
|
|
107495
108052
|
|
|
107496
108053
|
// src/workflows/approval-cancel.ts
|
|
107497
108054
|
init_db();
|
|
108055
|
+
init_rbac();
|
|
107498
108056
|
var LIVE_RUN_STATUSES = new Set(["running", "waiting"]);
|
|
107499
108057
|
async function cancelApprovalRequest(input) {
|
|
107500
108058
|
const finalReason = input.reason ?? "Cancelled through the API";
|
|
@@ -107634,6 +108192,7 @@ var registerCancelApprovalRequestTool = (server) => {
|
|
|
107634
108192
|
// src/tools/cancel-task.ts
|
|
107635
108193
|
init_zod();
|
|
107636
108194
|
init_db();
|
|
108195
|
+
init_rbac();
|
|
107637
108196
|
|
|
107638
108197
|
// src/tools/get-task-details.ts
|
|
107639
108198
|
init_zod();
|
|
@@ -107951,6 +108510,7 @@ var registerCancelTaskTool = (server) => {
|
|
|
107951
108510
|
// src/tools/context-history.ts
|
|
107952
108511
|
init_zod();
|
|
107953
108512
|
init_db();
|
|
108513
|
+
init_rbac();
|
|
107954
108514
|
var registerContextHistoryTool = (server) => {
|
|
107955
108515
|
createToolRegistrar(server)("context-history", {
|
|
107956
108516
|
title: "Context History",
|
|
@@ -108935,6 +109495,7 @@ function hydrateOAuthAppFromPreset(preset, overrides = {}) {
|
|
|
108935
109495
|
}
|
|
108936
109496
|
|
|
108937
109497
|
// src/tools/credential-bindings/tool.ts
|
|
109498
|
+
init_rbac();
|
|
108938
109499
|
init_credential_broker();
|
|
108939
109500
|
init_constants();
|
|
108940
109501
|
|
|
@@ -109548,8 +110109,8 @@ async function applyRating(events, ctx = {}) {
|
|
|
109548
110109
|
const UPDATE_MEMORY_SQL = "UPDATE agent_memory SET alpha = alpha + ?, beta = beta + ? WHERE id = ?";
|
|
109549
110110
|
const CHECK_EXISTS_SQL = "SELECT id FROM agent_memory WHERE id = ?";
|
|
109550
110111
|
const INSERT_RATING_SQL = `INSERT INTO memory_rating
|
|
109551
|
-
(id, memoryId, taskId, source, signal, weight, reasoning, createdAt, contextKey)
|
|
109552
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`;
|
|
110112
|
+
(id, memoryId, taskId, source, signal, weight, reasoning, createdAt, contextKey, model)
|
|
110113
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`;
|
|
109553
110114
|
const UPSERT_EDGE_SQL = `INSERT INTO agent_memory_edge (from_id, to_id, type, alpha, beta, createdAt)
|
|
109554
110115
|
VALUES (?, ?, 'references-source', ?, ?, ?)
|
|
109555
110116
|
ON CONFLICT(from_id, to_id, type) DO UPDATE SET
|
|
@@ -109578,7 +110139,8 @@ async function applyRating(events, ctx = {}) {
|
|
|
109578
110139
|
event.weight,
|
|
109579
110140
|
event.reasoning ?? null,
|
|
109580
110141
|
new Date().toISOString(),
|
|
109581
|
-
ctx.contextKey ?? null
|
|
110142
|
+
ctx.contextKey ?? null,
|
|
110143
|
+
event.source === "llm" ? event.model ?? null : null
|
|
109582
110144
|
]);
|
|
109583
110145
|
} catch (err) {
|
|
109584
110146
|
if (isUniqueConstraintError(err)) {
|
|
@@ -110511,6 +111073,7 @@ Deferred until ${nextRunAt} (schedule ${schedule.id}). Pending: ${note}${checksB
|
|
|
110511
111073
|
// src/tools/delete-channel.ts
|
|
110512
111074
|
init_zod();
|
|
110513
111075
|
init_db();
|
|
111076
|
+
init_rbac();
|
|
110514
111077
|
var GENERAL_CHANNEL_ID = "00000000-0000-4000-8000-000000000001";
|
|
110515
111078
|
var registerDeleteChannelTool = (server) => {
|
|
110516
111079
|
createToolRegistrar(server)("delete-channel", {
|
|
@@ -110588,6 +111151,7 @@ var registerDeleteChannelTool = (server) => {
|
|
|
110588
111151
|
// src/tools/delete-page.ts
|
|
110589
111152
|
init_zod();
|
|
110590
111153
|
init_db();
|
|
111154
|
+
init_rbac();
|
|
110591
111155
|
var DeletedPageSchema = looseObject({
|
|
110592
111156
|
id: string().optional(),
|
|
110593
111157
|
slug: string().optional(),
|
|
@@ -110782,20 +111346,20 @@ async function proxySwarmApi(args) {
|
|
|
110782
111346
|
if (!args.requestInfo.agentId)
|
|
110783
111347
|
return toolErr(args.transportError);
|
|
110784
111348
|
const apiKey = getApiKey();
|
|
110785
|
-
const
|
|
111349
|
+
const headers3 = {
|
|
110786
111350
|
Authorization: `Bearer ${apiKey}`,
|
|
110787
111351
|
"X-Agent-ID": args.requestInfo.agentId,
|
|
110788
111352
|
"Content-Type": "application/json"
|
|
110789
111353
|
};
|
|
110790
111354
|
if (args.requestInfo.sourceTaskId) {
|
|
110791
|
-
|
|
111355
|
+
headers3["X-Source-Task-Id"] = args.requestInfo.sourceTaskId;
|
|
110792
111356
|
}
|
|
110793
111357
|
if (args.requestInfo.runtimeInstanceId) {
|
|
110794
|
-
|
|
111358
|
+
headers3["X-Runtime-Instance-ID"] = args.requestInfo.runtimeInstanceId;
|
|
110795
111359
|
}
|
|
110796
111360
|
const res = await fetch(`${apiBaseUrl()}${args.path}`, {
|
|
110797
111361
|
method: args.method,
|
|
110798
|
-
headers:
|
|
111362
|
+
headers: headers3,
|
|
110799
111363
|
body: args.body === undefined ? undefined : JSON.stringify(args.body)
|
|
110800
111364
|
});
|
|
110801
111365
|
const text = await res.text();
|
|
@@ -111030,7 +111594,15 @@ var registerExtensionEnableTool = (server) => {
|
|
|
111030
111594
|
|
|
111031
111595
|
// src/tools/extension-install.ts
|
|
111032
111596
|
init_zod();
|
|
111033
|
-
|
|
111597
|
+
init_types();
|
|
111598
|
+
var EXTENSION_INSTALL_DESCRIPTION = "Install an extension from the catalog by `template` name (extension-catalog, GET /api/extensions/catalog), or from an inline bundle: `manifest` plus a `files` map keyed by bundle path. `template` and `manifest`/`files` are mutually exclusive. Inline bundles are accepted only when the deployment sets EXTENSION_ALLOW_INLINE_INSTALL=true, and only from lead, operator and dashboard-user callers. Workers are denied (403) and stay catalog-only; with the flag off the call fails with inline_install_disabled. Before writing an inline bundle, fetch the hook contract: GET /api/extensions/type-defs returns swarm-extension.d.ts. Install creates the extension, its ext:<name> agent and every asset it declares (scripts, and disabled schedules, workflows and skills). Any authenticated agent may install from the catalog; the installing agent is recorded as createdByAgentId. Workers may install subsequent versions only for their own extensions; those versions remain inactive. A new extension remains disabled until a lead, operator, or dashboard user enables it with extension-enable.";
|
|
111599
|
+
var extensionInstallInputSchema = object({
|
|
111600
|
+
template: string().min(1).optional().describe("Name of a predefined extension from extension-catalog. Mutually exclusive with manifest and files."),
|
|
111601
|
+
manifest: ExtensionManifestSchema.optional().describe("Inline bundle manifest. Requires files. Needs EXTENSION_ALLOW_INLINE_INSTALL and a lead, operator, or dashboard-user caller."),
|
|
111602
|
+
files: record(string(), string()).optional().describe("Inline bundle files keyed by relative path. Requires manifest."),
|
|
111603
|
+
priority: number().int().optional().describe("Handler priority. Lower values run first."),
|
|
111604
|
+
config: record(string(), unknown()).optional().describe("Extension configuration.")
|
|
111605
|
+
}).strict().superRefine(checkExtensionInstallSource);
|
|
111034
111606
|
function extensionInstallResult(data, fallbackName) {
|
|
111035
111607
|
const body = data;
|
|
111036
111608
|
const extension = coerceExtensionSummary(body.extension);
|
|
@@ -111051,18 +111623,14 @@ var registerExtensionInstallTool = (server) => {
|
|
|
111051
111623
|
title: "Extension Install",
|
|
111052
111624
|
description: EXTENSION_INSTALL_DESCRIPTION,
|
|
111053
111625
|
annotations: { openWorldHint: false },
|
|
111054
|
-
inputSchema:
|
|
111055
|
-
template: string().min(1).describe("Name of a predefined extension from extension-catalog."),
|
|
111056
|
-
priority: number().int().optional().describe("Handler priority. Lower values run first."),
|
|
111057
|
-
config: record(string(), unknown()).optional().describe("Extension configuration.")
|
|
111058
|
-
}).strict(),
|
|
111626
|
+
inputSchema: extensionInstallInputSchema,
|
|
111059
111627
|
outputSchema: extensionToolOutputSchema
|
|
111060
111628
|
}, async (args, requestInfo) => proxyExtensionsApi({
|
|
111061
111629
|
method: "POST",
|
|
111062
111630
|
path: "/api/extensions/install",
|
|
111063
111631
|
body: args,
|
|
111064
111632
|
requestInfo,
|
|
111065
|
-
success: (data) => extensionInstallResult(data, args.template)
|
|
111633
|
+
success: (data) => extensionInstallResult(data, args.template ?? args.manifest?.name ?? "extension")
|
|
111066
111634
|
}));
|
|
111067
111635
|
};
|
|
111068
111636
|
|
|
@@ -111362,6 +111930,7 @@ var registerGetTasksTool = (server) => {
|
|
|
111362
111930
|
// src/tools/inject-learning.ts
|
|
111363
111931
|
init_zod();
|
|
111364
111932
|
init_db();
|
|
111933
|
+
init_rbac();
|
|
111365
111934
|
var LearningCategoryEnum = _enum([
|
|
111366
111935
|
"mistake-pattern",
|
|
111367
111936
|
"best-practice",
|
|
@@ -111544,17 +112113,19 @@ init_types();
|
|
|
111544
112113
|
init_db();
|
|
111545
112114
|
|
|
111546
112115
|
// src/kv-reserved-namespaces.ts
|
|
111547
|
-
|
|
111548
|
-
|
|
111549
|
-
|
|
112116
|
+
var RESERVED_FAMILIES = new Map([
|
|
112117
|
+
["apps", "namespace is reserved for swarm apps; use the app row endpoints"],
|
|
112118
|
+
["comb", "namespace is reserved for Comb; use POST /api/comb/review-batches"]
|
|
112119
|
+
]);
|
|
111550
112120
|
function reservedNamespaceError(namespace2) {
|
|
111551
|
-
return
|
|
112121
|
+
return RESERVED_FAMILIES.get(namespace2.split(":", 1)[0] ?? "") ?? null;
|
|
111552
112122
|
}
|
|
111553
112123
|
function reservedRoomKeyError(key) {
|
|
111554
112124
|
return key.startsWith("_room/") ? "room snapshot keys are reserved; use the room endpoints" : null;
|
|
111555
112125
|
}
|
|
111556
112126
|
|
|
111557
112127
|
// src/tools/kv/kv-write-auth.ts
|
|
112128
|
+
init_rbac();
|
|
111558
112129
|
async function kvWriteAuthError(namespace2, info, key) {
|
|
111559
112130
|
if (key) {
|
|
111560
112131
|
const reservedKeyErr = reservedRoomKeyError(key);
|
|
@@ -112050,6 +112621,7 @@ var registerListServicesTool = (server) => {
|
|
|
112050
112621
|
// src/tools/manage-user.ts
|
|
112051
112622
|
init_zod();
|
|
112052
112623
|
init_db();
|
|
112624
|
+
init_rbac();
|
|
112053
112625
|
var userOutputShape = looseObject({
|
|
112054
112626
|
id: string().optional(),
|
|
112055
112627
|
name: string().optional(),
|
|
@@ -112264,6 +112836,7 @@ var registerManageUserTool = (server) => {
|
|
|
112264
112836
|
// src/tools/mcp-servers/mcp-server-create.ts
|
|
112265
112837
|
init_zod();
|
|
112266
112838
|
init_db();
|
|
112839
|
+
init_rbac();
|
|
112267
112840
|
var registerMcpServerCreateTool = (server) => {
|
|
112268
112841
|
createToolRegistrar(server)("mcp-server-create", {
|
|
112269
112842
|
title: "Create MCP Server",
|
|
@@ -112350,6 +112923,7 @@ var registerMcpServerCreateTool = (server) => {
|
|
|
112350
112923
|
// src/tools/mcp-servers/mcp-server-delete.ts
|
|
112351
112924
|
init_zod();
|
|
112352
112925
|
init_db();
|
|
112926
|
+
init_rbac();
|
|
112353
112927
|
var registerMcpServerDeleteTool = (server) => {
|
|
112354
112928
|
createToolRegistrar(server)("mcp-server-delete", {
|
|
112355
112929
|
title: "Delete MCP Server",
|
|
@@ -112431,6 +113005,7 @@ var registerMcpServerGetTool = (server) => {
|
|
|
112431
113005
|
// src/tools/mcp-servers/mcp-server-install.ts
|
|
112432
113006
|
init_zod();
|
|
112433
113007
|
init_db();
|
|
113008
|
+
init_rbac();
|
|
112434
113009
|
var registerMcpServerInstallTool = (server) => {
|
|
112435
113010
|
createToolRegistrar(server)("mcp-server-install", {
|
|
112436
113011
|
title: "Install MCP Server",
|
|
@@ -112537,6 +113112,7 @@ var registerMcpServerListTool = (server) => {
|
|
|
112537
113112
|
// src/tools/mcp-servers/mcp-server-uninstall.ts
|
|
112538
113113
|
init_zod();
|
|
112539
113114
|
init_db();
|
|
113115
|
+
init_rbac();
|
|
112540
113116
|
var registerMcpServerUninstallTool = (server) => {
|
|
112541
113117
|
createToolRegistrar(server)("mcp-server-uninstall", {
|
|
112542
113118
|
title: "Uninstall MCP Server",
|
|
@@ -112580,6 +113156,7 @@ var registerMcpServerUninstallTool = (server) => {
|
|
|
112580
113156
|
// src/tools/mcp-servers/mcp-server-update.ts
|
|
112581
113157
|
init_zod();
|
|
112582
113158
|
init_db();
|
|
113159
|
+
init_rbac();
|
|
112583
113160
|
var registerMcpServerUpdateTool = (server) => {
|
|
112584
113161
|
createToolRegistrar(server)("mcp-server-update", {
|
|
112585
113162
|
title: "Update MCP Server",
|
|
@@ -112667,6 +113244,7 @@ var registerMcpServerUpdateTool = (server) => {
|
|
|
112667
113244
|
// src/tools/memory-delete.ts
|
|
112668
113245
|
init_zod();
|
|
112669
113246
|
init_db();
|
|
113247
|
+
init_rbac();
|
|
112670
113248
|
var registerMemoryDeleteTool = (server) => {
|
|
112671
113249
|
createToolRegistrar(server)("memory-delete", {
|
|
112672
113250
|
title: "Delete a memory",
|
|
@@ -112713,13 +113291,62 @@ var registerMemoryDeleteTool = (server) => {
|
|
|
112713
113291
|
init_zod();
|
|
112714
113292
|
init_db();
|
|
112715
113293
|
|
|
113294
|
+
// src/be/memory/key-guard.ts
|
|
113295
|
+
init_rbac();
|
|
113296
|
+
init_key_paths();
|
|
113297
|
+
|
|
113298
|
+
class MemoryKeyError extends Error {
|
|
113299
|
+
reason;
|
|
113300
|
+
constructor(message, reason) {
|
|
113301
|
+
super(message);
|
|
113302
|
+
this.reason = reason;
|
|
113303
|
+
this.name = "MemoryKeyError";
|
|
113304
|
+
}
|
|
113305
|
+
}
|
|
113306
|
+
var NO_AUTHORITY = {
|
|
113307
|
+
principal: { kind: "agent", agentId: "", isLead: false },
|
|
113308
|
+
source: "http"
|
|
113309
|
+
};
|
|
113310
|
+
function shapeError(key, origin) {
|
|
113311
|
+
if (key.length <= MEMORY_KEY_MAX_LENGTH && MEMORY_KEY_PATTERN.test(key))
|
|
113312
|
+
return null;
|
|
113313
|
+
const subject = origin === "sourcePath" ? `sourcePath "${key}" starts with ${LONGTERM_ROOT}, so it is used as the key, but it is not a valid key.` : `Key "${key}" is not a valid key.`;
|
|
113314
|
+
return `${subject} ${MEMORY_KEY_PATTERN_MESSAGE}`;
|
|
113315
|
+
}
|
|
113316
|
+
function assertKeyWritable(key, origin, writer) {
|
|
113317
|
+
if (origin === "sourcePath" && !isLongtermKey(key))
|
|
113318
|
+
return;
|
|
113319
|
+
const shape = shapeError(key, origin);
|
|
113320
|
+
if (shape)
|
|
113321
|
+
throw new MemoryKeyError(shape, "invalid");
|
|
113322
|
+
const pathError = longtermKeyError(key);
|
|
113323
|
+
if (pathError)
|
|
113324
|
+
throw new MemoryKeyError(pathError, "invalid");
|
|
113325
|
+
if (!isConsolidatedKey(key))
|
|
113326
|
+
return;
|
|
113327
|
+
const { principal, source } = writer ?? NO_AUTHORITY;
|
|
113328
|
+
const decision = can({
|
|
113329
|
+
principal,
|
|
113330
|
+
verb: "memory.write.consolidated",
|
|
113331
|
+
resource: { kind: "none" },
|
|
113332
|
+
source
|
|
113333
|
+
});
|
|
113334
|
+
if (!decision.allow)
|
|
113335
|
+
throw new MemoryKeyError(consolidatedKeyMessage(key), "forbidden");
|
|
113336
|
+
}
|
|
113337
|
+
|
|
113338
|
+
// src/tools/memory-edit.ts
|
|
113339
|
+
init_key_paths();
|
|
113340
|
+
|
|
112716
113341
|
// src/be/memory/link-resolver.ts
|
|
112717
113342
|
init_db();
|
|
113343
|
+
init_constants();
|
|
112718
113344
|
var WIKILINK_RE = /\[\[([^\]]+)\]\]/g;
|
|
112719
113345
|
var PR_HASH_RE = /(?:^|[\s(])#(\d{1,5})(?=[\s,.)!?]|$)/gm;
|
|
112720
113346
|
var PR_PREFIX_RE = /\bPR\s*#(\d{1,5})\b/gi;
|
|
112721
113347
|
var GITHUB_PR_URL_RE = /https?:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/g;
|
|
112722
|
-
var
|
|
113348
|
+
var AGENT_FS_LIVE_HOSTS = String.raw`agent-fs|live\.agent-fs\.dev`;
|
|
113349
|
+
var AGENT_FS_FILE_ROUTE = String.raw`\/file\/~\/([a-f0-9-]+)\/([a-f0-9-]+)\/([\w/.%-]+)`;
|
|
112723
113350
|
var AGENT_UI_PAGE_RE = /(?:app\.[^/]+|localhost:\d+)\/pages\/([a-f0-9-]+)/g;
|
|
112724
113351
|
var AGENT_UI_TASK_RE = /(?:app\.[^/]+|localhost:\d+)\/tasks\/([a-f0-9-]+)/g;
|
|
112725
113352
|
var wikilinkMatcher = (content) => {
|
|
@@ -112785,9 +113412,24 @@ var prMatcher = (content) => {
|
|
|
112785
113412
|
}
|
|
112786
113413
|
return results;
|
|
112787
113414
|
};
|
|
113415
|
+
function escapeRegExp2(value) {
|
|
113416
|
+
return value.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
113417
|
+
}
|
|
113418
|
+
function agentFsPathRegex() {
|
|
113419
|
+
const appHosts = getConfiguredAppUrls().flatMap((value) => {
|
|
113420
|
+
try {
|
|
113421
|
+
const url = new URL(value);
|
|
113422
|
+
return [escapeRegExp2(`${url.host}${url.pathname.replace(/\/+$/, "")}`)];
|
|
113423
|
+
} catch {
|
|
113424
|
+
return [];
|
|
113425
|
+
}
|
|
113426
|
+
});
|
|
113427
|
+
const hosts = [AGENT_FS_LIVE_HOSTS, ...appHosts, String.raw`localhost:\d+`].join("|");
|
|
113428
|
+
return new RegExp(`(?<![\\w.-])(?:${hosts})${AGENT_FS_FILE_ROUTE}`, "gi");
|
|
113429
|
+
}
|
|
112788
113430
|
var agentFsMatcher = (content) => {
|
|
112789
113431
|
const results = [];
|
|
112790
|
-
for (const match of content.matchAll(
|
|
113432
|
+
for (const match of content.matchAll(agentFsPathRegex())) {
|
|
112791
113433
|
const orgId = match[1];
|
|
112792
113434
|
const driveId = match[2];
|
|
112793
113435
|
const path2 = match[3];
|
|
@@ -112900,6 +113542,7 @@ async function refreshLinks(memoryId, agentId, content) {
|
|
|
112900
113542
|
}
|
|
112901
113543
|
|
|
112902
113544
|
// src/tools/memory-edit.ts
|
|
113545
|
+
init_rbac();
|
|
112903
113546
|
init_types();
|
|
112904
113547
|
var agentMemoryOutputSchema = looseObject({
|
|
112905
113548
|
id: string().optional(),
|
|
@@ -112927,7 +113570,7 @@ var agentMemoryOutputSchema = looseObject({
|
|
|
112927
113570
|
var registerMemoryEditTool = (server) => {
|
|
112928
113571
|
createToolRegistrar(server)("memory-edit", {
|
|
112929
113572
|
title: "Edit a memory",
|
|
112930
|
-
description: "Edit a single memory in place while preserving its ID, usefulness posterior, and audit history. Two modes: 'replace' overwrites the entire content (requires `content`); 'exact' performs a surgical find-and-replace of `oldString` with `newString` within the existing content (fails if `oldString` is missing or ambiguous). Use 'replace' for full rewrites, 'exact' for targeted edits. Agents can edit their own memories; lead agents can edit any scope.",
|
|
113573
|
+
description: "Edit a single memory in place while preserving its ID, usefulness posterior, and audit history. Two modes: 'replace' overwrites the entire content (requires `content`); 'exact' performs a surgical find-and-replace of `oldString` with `newString` within the existing content (fails if `oldString` is missing or ambiguous). Use 'replace' for full rewrites, 'exact' for targeted edits. Pass `newKey` alone to move the memory to another logical path (every chunk, same ID, posterior, access counts and author). A move into /longterm also clears the expiry. Agents can edit their own memories; lead agents can edit any scope.",
|
|
112931
113574
|
annotations: { destructiveHint: true },
|
|
112932
113575
|
inputSchema: object({
|
|
112933
113576
|
memoryId: uuid().optional().describe("The memory ID to edit."),
|
|
@@ -112938,7 +113581,8 @@ var registerMemoryEditTool = (server) => {
|
|
|
112938
113581
|
oldString: string().min(1).optional().describe("Substring to find in existing content. Required for 'exact' mode. Must appear exactly once."),
|
|
112939
113582
|
newString: string().optional().describe("Replacement for oldString. Required for 'exact' mode. Can be empty to delete."),
|
|
112940
113583
|
intent: string().min(1).describe("Why you are editing this memory."),
|
|
112941
|
-
expectedVersion: number().int().min(1).optional()
|
|
113584
|
+
expectedVersion: number().int().min(1).optional(),
|
|
113585
|
+
newKey: string().max(MEMORY_KEY_MAX_LENGTH).regex(MEMORY_KEY_PATTERN, MEMORY_KEY_PATTERN_MESSAGE).optional().describe("Move the memory to this logical path, for example '/longterm/facts/swarm-runtime/slug'. Alone it is a pure move: omit content/oldString/newString. Fails when the key is already used in this scope by the same owner. Moving into /longterm marks the memory as curated on every chunk: it stops expiring and is protected from cleanup, and moving it out later does not bring the expiry back. A key under /longterm must start with /longterm/company-story, /longterm/entities/people, /longterm/entities/customers, /longterm/facts, /longterm/decisions, /longterm/workstreams or /longterm/timeline. Paths under /longterm/company-story, /longterm/entities and /longterm/timeline are lead-only.")
|
|
112942
113586
|
}),
|
|
112943
113587
|
outputSchema: swarmToolOutputSchema({
|
|
112944
113588
|
yourAgentId: string().optional(),
|
|
@@ -112947,7 +113591,18 @@ var registerMemoryEditTool = (server) => {
|
|
|
112947
113591
|
previousVersion: number().int().optional(),
|
|
112948
113592
|
version: number().int().optional()
|
|
112949
113593
|
})
|
|
112950
|
-
}, async ({
|
|
113594
|
+
}, async ({
|
|
113595
|
+
memoryId,
|
|
113596
|
+
key,
|
|
113597
|
+
scope,
|
|
113598
|
+
mode,
|
|
113599
|
+
content,
|
|
113600
|
+
oldString,
|
|
113601
|
+
newString,
|
|
113602
|
+
intent,
|
|
113603
|
+
expectedVersion,
|
|
113604
|
+
newKey
|
|
113605
|
+
}, requestInfo, _meta) => {
|
|
112951
113606
|
if (!requestInfo.agentId) {
|
|
112952
113607
|
return toolErr("Agent ID required. Are you registered in the swarm?");
|
|
112953
113608
|
}
|
|
@@ -112957,6 +113612,17 @@ var registerMemoryEditTool = (server) => {
|
|
|
112957
113612
|
});
|
|
112958
113613
|
}
|
|
112959
113614
|
try {
|
|
113615
|
+
if (newKey) {
|
|
113616
|
+
const agent = await getAgentById(requestInfo.agentId);
|
|
113617
|
+
assertKeyWritable(newKey, "key", {
|
|
113618
|
+
principal: {
|
|
113619
|
+
kind: "agent",
|
|
113620
|
+
agentId: requestInfo.agentId,
|
|
113621
|
+
isLead: agent?.isLead ?? false
|
|
113622
|
+
},
|
|
113623
|
+
source: "mcp"
|
|
113624
|
+
});
|
|
113625
|
+
}
|
|
112960
113626
|
const store = getMemoryStore();
|
|
112961
113627
|
if (memoryId) {
|
|
112962
113628
|
const memory = await store.peek(memoryId);
|
|
@@ -112993,9 +113659,11 @@ var registerMemoryEditTool = (server) => {
|
|
|
112993
113659
|
newString,
|
|
112994
113660
|
intent,
|
|
112995
113661
|
expectedVersion,
|
|
112996
|
-
changedByAgentId: requestInfo.agentId
|
|
113662
|
+
changedByAgentId: requestInfo.agentId,
|
|
113663
|
+
newKey
|
|
112997
113664
|
});
|
|
112998
|
-
|
|
113665
|
+
const contentEdited = content !== undefined || oldString !== undefined || newString !== undefined;
|
|
113666
|
+
if (result.changed && (newKey === undefined || contentEdited)) {
|
|
112999
113667
|
const provider = getEmbeddingProvider();
|
|
113000
113668
|
const embedding = await provider.embed(result.memory.content);
|
|
113001
113669
|
if (embedding)
|
|
@@ -113016,6 +113684,9 @@ var registerMemoryEditTool = (server) => {
|
|
|
113016
113684
|
}
|
|
113017
113685
|
});
|
|
113018
113686
|
} catch (err) {
|
|
113687
|
+
if (err instanceof MemoryKeyError) {
|
|
113688
|
+
return toolErr(err.message, { data: { yourAgentId: requestInfo.agentId } });
|
|
113689
|
+
}
|
|
113019
113690
|
return toolErr(`Memory edit failed: ${err.message}`, {
|
|
113020
113691
|
data: { yourAgentId: requestInfo.agentId }
|
|
113021
113692
|
});
|
|
@@ -113353,7 +114024,7 @@ function addNeighborScopeConditions(conditions, params, agentId, scope, isLead)
|
|
|
113353
114024
|
async function expandCandidatesWithGraph(candidates, agentId, options = {}) {
|
|
113354
114025
|
if (!isGraphExpansionEnabled())
|
|
113355
114026
|
return candidates;
|
|
113356
|
-
const { cap = 5, damping = 0.7, scope = "all", source, isLead = false } = options;
|
|
114027
|
+
const { cap = 5, damping = 0.7, scope = "all", source, keyPrefix, isLead = false } = options;
|
|
113357
114028
|
if (candidates.length === 0 || cap <= 0)
|
|
113358
114029
|
return candidates;
|
|
113359
114030
|
const parentById = new Map(candidates.map((c) => [c.id, c]));
|
|
@@ -113369,6 +114040,10 @@ async function expandCandidatesWithGraph(candidates, agentId, options = {}) {
|
|
|
113369
114040
|
conditions.push("m.source = ?");
|
|
113370
114041
|
params.push(source);
|
|
113371
114042
|
}
|
|
114043
|
+
if (keyPrefix) {
|
|
114044
|
+
conditions.push("substr(m.key, 1, length(?)) = ?");
|
|
114045
|
+
params.push(keyPrefix, keyPrefix);
|
|
114046
|
+
}
|
|
113372
114047
|
let rows;
|
|
113373
114048
|
try {
|
|
113374
114049
|
rows = await getDbClient().query(`SELECT m.*, ml.from_memory_id AS fromMemoryId, ml.strength AS linkStrength
|
|
@@ -113425,6 +114100,7 @@ async function expandCandidatesWithGraph(candidates, agentId, options = {}) {
|
|
|
113425
114100
|
}
|
|
113426
114101
|
|
|
113427
114102
|
// src/tools/memory-search.ts
|
|
114103
|
+
init_key_paths();
|
|
113428
114104
|
init_reranker();
|
|
113429
114105
|
init_types();
|
|
113430
114106
|
var NUDGE_ELIGIBLE_SOURCES2 = new Set(["manual", "file_index"]);
|
|
@@ -113467,10 +114143,11 @@ var registerMemorySearchTool = (server) => {
|
|
|
113467
114143
|
intent: string().min(1).optional().describe("Optional reason for searching for this memory. E.g. 'looking for auth pattern to fix login bug'."),
|
|
113468
114144
|
scope: _enum(["all", "agent", "swarm"]).default("all").describe("Search scope: 'all' (own + swarm), 'agent' (own only), 'swarm' (shared only)."),
|
|
113469
114145
|
limit: number().int().min(1).max(50).default(10).describe("Max results to return."),
|
|
113470
|
-
source: AgentMemorySourceSchema.optional().describe("Filter by memory source type.")
|
|
114146
|
+
source: AgentMemorySourceSchema.optional().describe("Filter by memory source type."),
|
|
114147
|
+
keyPrefix: string().min(1).max(MEMORY_KEY_MAX_LENGTH).optional().describe("Only return memories whose key starts with this text, for example '/longterm/facts/' or '/longterm/entities/people/'. Matched literally, case-sensitive. Include the trailing '/' to stay inside one folder.")
|
|
113471
114148
|
}),
|
|
113472
114149
|
outputSchema: memorySearchOutputSchema
|
|
113473
|
-
}, async ({ query, intent, scope, limit, source }, requestInfo, _meta) => {
|
|
114150
|
+
}, async ({ query, intent, scope, limit, source, keyPrefix }, requestInfo, _meta) => {
|
|
113474
114151
|
if (!requestInfo.agentId) {
|
|
113475
114152
|
return toolErr("Agent ID required. Are you registered in the swarm?");
|
|
113476
114153
|
}
|
|
@@ -113485,11 +114162,13 @@ var registerMemorySearchTool = (server) => {
|
|
|
113485
114162
|
limit: candidateLimit,
|
|
113486
114163
|
source,
|
|
113487
114164
|
isLead,
|
|
113488
|
-
queryText: query
|
|
114165
|
+
queryText: query,
|
|
114166
|
+
keyPrefix
|
|
113489
114167
|
});
|
|
113490
114168
|
const expanded = await expandCandidatesWithGraph(candidates, requestInfo.agentId, {
|
|
113491
114169
|
scope,
|
|
113492
114170
|
source,
|
|
114171
|
+
keyPrefix,
|
|
113493
114172
|
isLead
|
|
113494
114173
|
});
|
|
113495
114174
|
if (expanded.length > 0) {
|
|
@@ -113536,7 +114215,8 @@ var registerMemorySearchTool = (server) => {
|
|
|
113536
114215
|
scope,
|
|
113537
114216
|
limit,
|
|
113538
114217
|
isLead,
|
|
113539
|
-
source
|
|
114218
|
+
source,
|
|
114219
|
+
keyPrefix
|
|
113540
114220
|
});
|
|
113541
114221
|
const consumedIds = dedupeMemoryDocumentIds(recent);
|
|
113542
114222
|
try {
|
|
@@ -113564,6 +114244,7 @@ var registerMemorySearchTool = (server) => {
|
|
|
113564
114244
|
|
|
113565
114245
|
// src/tools/memory-store.ts
|
|
113566
114246
|
init_zod();
|
|
114247
|
+
init_db();
|
|
113567
114248
|
|
|
113568
114249
|
// src/be/chunking.ts
|
|
113569
114250
|
var MAX_CHUNK_SIZE = 2000;
|
|
@@ -113716,6 +114397,9 @@ function addOverlap(chunks, _originalText) {
|
|
|
113716
114397
|
init_secret_scrubber();
|
|
113717
114398
|
async function indexMemoryContent(params) {
|
|
113718
114399
|
const { agentId, content, name, scope, source, sourceTaskId, sourcePath, tags } = params;
|
|
114400
|
+
const rowKey2 = params.key ?? (sourcePath || null);
|
|
114401
|
+
if (rowKey2)
|
|
114402
|
+
assertKeyWritable(rowKey2, params.key != null ? "key" : "sourcePath", params.writer);
|
|
113719
114403
|
const contentChunks = chunkContent(content);
|
|
113720
114404
|
if (contentChunks.length === 0) {
|
|
113721
114405
|
contentChunks.push({
|
|
@@ -113769,7 +114453,7 @@ async function indexMemoryContent(params) {
|
|
|
113769
114453
|
tags: tags || [],
|
|
113770
114454
|
contextKey: params.contextKey ?? null,
|
|
113771
114455
|
intent: params.intent ?? "index memory content",
|
|
113772
|
-
key:
|
|
114456
|
+
key: rowKey2
|
|
113773
114457
|
})));
|
|
113774
114458
|
if (agentId) {
|
|
113775
114459
|
for (const memory of memories) {
|
|
@@ -113796,6 +114480,7 @@ async function indexMemoryContent(params) {
|
|
|
113796
114480
|
}
|
|
113797
114481
|
|
|
113798
114482
|
// src/tools/memory-store.ts
|
|
114483
|
+
init_key_paths();
|
|
113799
114484
|
init_types();
|
|
113800
114485
|
var registerMemoryStoreTool = (server) => {
|
|
113801
114486
|
createToolRegistrar(server)("memory-store", {
|
|
@@ -113804,11 +114489,12 @@ var registerMemoryStoreTool = (server) => {
|
|
|
113804
114489
|
annotations: { destructiveHint: false },
|
|
113805
114490
|
inputSchema: object({
|
|
113806
114491
|
content: string().min(1).describe("The memory body. Markdown is fine. State the fact, the context it applies to, and the evidence."),
|
|
113807
|
-
name: string().min(1).max(200).optional().describe("Short title used in search results and the UI. Defaults to the first non-empty content line (up to 200 characters)."),
|
|
114492
|
+
name: string().min(1).max(200).optional().describe("Short title used in search results and the UI. Defaults to the first non-empty content line (up to 200 characters). A name that starts with /longterm/ is also used as the key when no key is given."),
|
|
113808
114493
|
scope: AgentMemoryScopeSchema.default("agent").describe("'agent' (default): only you can recall it. 'swarm': every agent can recall it."),
|
|
113809
114494
|
tags: union([array(string()), string()]).optional().describe("Free-form tags as an array or a comma-separated string, for example a repo name or a topic."),
|
|
113810
114495
|
taskId: uuid().optional().describe("The task this learning came from, when there is one."),
|
|
113811
|
-
intent: string().min(1).optional().describe("Why this is worth remembering. Kept in the audit trail.")
|
|
114496
|
+
intent: string().min(1).optional().describe("Why this is worth remembering. Kept in the audit trail."),
|
|
114497
|
+
key: string().max(MEMORY_KEY_MAX_LENGTH).regex(MEMORY_KEY_PATTERN, MEMORY_KEY_PATTERN_MESSAGE).optional().describe("Optional logical path for this memory, for example '/longterm/facts/swarm-runtime/sqlite-busy-retry'. Lowercase segments joined by '/', starting with '/'. Search it with memory-search keyPrefix and move it with memory-edit newKey. Fails when you already have a memory with this key in this scope. A key under /longterm marks the memory as curated: it never expires and is protected from cleanup. It must start with /longterm/company-story, /longterm/entities/people, /longterm/entities/customers, /longterm/facts, /longterm/decisions, /longterm/workstreams or /longterm/timeline. Paths under /longterm/company-story, /longterm/entities and /longterm/timeline are lead-only. Defaults to an auto key, which makes the memory inbox material.")
|
|
113812
114498
|
}),
|
|
113813
114499
|
outputSchema: swarmToolOutputSchema({
|
|
113814
114500
|
yourAgentId: string().optional(),
|
|
@@ -113816,13 +114502,18 @@ var registerMemoryStoreTool = (server) => {
|
|
|
113816
114502
|
chunks: number().int().optional(),
|
|
113817
114503
|
queued: boolean().optional()
|
|
113818
114504
|
})
|
|
113819
|
-
}, async ({ content, name: requestedName, scope, tags, taskId, intent }, requestInfo, _meta) => {
|
|
114505
|
+
}, async ({ content, name: requestedName, scope, tags, taskId, intent, key }, requestInfo, _meta) => {
|
|
113820
114506
|
const name = requestedName ?? content.split(/\r?\n/).find((line) => line.trim())?.trim().slice(0, 200) ?? "Untitled memory";
|
|
113821
114507
|
const normalizedTags = typeof tags === "string" ? tags.split(",").map((tag) => tag.trim()).filter(Boolean) : tags;
|
|
113822
114508
|
if (!requestInfo.agentId) {
|
|
113823
114509
|
return toolErr("Agent ID required. Are you registered in the swarm?");
|
|
113824
114510
|
}
|
|
114511
|
+
const storeKey = resolveStoreKey(key, requestedName);
|
|
114512
|
+
if (storeKey && !key && !MEMORY_KEY_PATTERN.test(storeKey)) {
|
|
114513
|
+
return toolErr(`Name "${storeKey}" starts with /longterm/, so it is used as the key, but it is not a valid key. ${MEMORY_KEY_PATTERN_MESSAGE}`, { data: { yourAgentId: requestInfo.agentId } });
|
|
114514
|
+
}
|
|
113825
114515
|
try {
|
|
114516
|
+
const agent = storeKey ? await getAgentById(requestInfo.agentId) : undefined;
|
|
113826
114517
|
const result = await indexMemoryContent({
|
|
113827
114518
|
agentId: requestInfo.agentId,
|
|
113828
114519
|
content,
|
|
@@ -113831,7 +114522,16 @@ var registerMemoryStoreTool = (server) => {
|
|
|
113831
114522
|
source: "manual",
|
|
113832
114523
|
sourceTaskId: taskId ?? null,
|
|
113833
114524
|
tags: normalizedTags,
|
|
113834
|
-
intent
|
|
114525
|
+
intent,
|
|
114526
|
+
key: storeKey,
|
|
114527
|
+
writer: {
|
|
114528
|
+
principal: {
|
|
114529
|
+
kind: "agent",
|
|
114530
|
+
agentId: requestInfo.agentId,
|
|
114531
|
+
isLead: agent?.isLead ?? false
|
|
114532
|
+
},
|
|
114533
|
+
source: "mcp"
|
|
114534
|
+
}
|
|
113835
114535
|
});
|
|
113836
114536
|
return toolOk(`Memory "${name}" stored as ${result.chunks} chunk(s) in ${scope} scope. Embedding runs in the background.`, {
|
|
113837
114537
|
data: {
|
|
@@ -113842,7 +114542,14 @@ var registerMemoryStoreTool = (server) => {
|
|
|
113842
114542
|
}
|
|
113843
114543
|
});
|
|
113844
114544
|
} catch (err) {
|
|
113845
|
-
|
|
114545
|
+
if (err instanceof MemoryKeyError) {
|
|
114546
|
+
return toolErr(err.message, { data: { yourAgentId: requestInfo.agentId } });
|
|
114547
|
+
}
|
|
114548
|
+
const message = err.message;
|
|
114549
|
+
if (storeKey && /UNIQUE constraint failed/i.test(message)) {
|
|
114550
|
+
return toolErr(`Memory store failed: key "${storeKey}" is already used in ${scope} scope. Edit that memory with memory-edit, or pick another key.`, { data: { yourAgentId: requestInfo.agentId } });
|
|
114551
|
+
}
|
|
114552
|
+
return toolErr(`Memory store failed: ${message}`, {
|
|
113846
114553
|
data: { yourAgentId: requestInfo.agentId }
|
|
113847
114554
|
});
|
|
113848
114555
|
}
|
|
@@ -113852,6 +114559,7 @@ var registerMemoryStoreTool = (server) => {
|
|
|
113852
114559
|
// src/tools/model-catalog/index.ts
|
|
113853
114560
|
init_zod();
|
|
113854
114561
|
init_db();
|
|
114562
|
+
init_rbac();
|
|
113855
114563
|
async function denyUnlessCatalogWriter(agentId) {
|
|
113856
114564
|
const agent = await getAgentById(agentId);
|
|
113857
114565
|
const decision = can({
|
|
@@ -114125,6 +114833,108 @@ function addMinutes(date2, amount, options) {
|
|
|
114125
114833
|
|
|
114126
114834
|
// src/tools/poll-task.ts
|
|
114127
114835
|
init_zod();
|
|
114836
|
+
|
|
114837
|
+
// src/be/api-drain.ts
|
|
114838
|
+
init_api_drain();
|
|
114839
|
+
init_secret_scrubber();
|
|
114840
|
+
init_db();
|
|
114841
|
+
var DEFAULT_API_DRAIN_MAX_MS = 0;
|
|
114842
|
+
var DRAIN_CHECK_INTERVAL_MS = 500;
|
|
114843
|
+
var LIVE_WORKER_WINDOW_MS = 30000;
|
|
114844
|
+
var drainStartedAt = null;
|
|
114845
|
+
function isApiDraining() {
|
|
114846
|
+
return drainStartedAt !== null;
|
|
114847
|
+
}
|
|
114848
|
+
function beginApiDrain(now = Date.now()) {
|
|
114849
|
+
if (drainStartedAt !== null)
|
|
114850
|
+
return false;
|
|
114851
|
+
drainStartedAt = now;
|
|
114852
|
+
return true;
|
|
114853
|
+
}
|
|
114854
|
+
function resolveApiDrainMaxMs(env = process.env) {
|
|
114855
|
+
const raw = env.API_DRAIN_MAX_MS;
|
|
114856
|
+
if (raw === undefined || raw.trim() === "")
|
|
114857
|
+
return DEFAULT_API_DRAIN_MAX_MS;
|
|
114858
|
+
const parsed = Number(raw);
|
|
114859
|
+
if (!Number.isFinite(parsed) || parsed < 0)
|
|
114860
|
+
return DEFAULT_API_DRAIN_MAX_MS;
|
|
114861
|
+
return Math.min(Math.floor(parsed), API_DRAIN_MAX_MS_LIMIT);
|
|
114862
|
+
}
|
|
114863
|
+
async function listLiveInFlightTaskIds(now = Date.now()) {
|
|
114864
|
+
const cutoff = new Date(now - LIVE_WORKER_WINDOW_MS).toISOString();
|
|
114865
|
+
const rows = await getDbClient().query(`SELECT t.id AS id
|
|
114866
|
+
FROM agent_tasks t
|
|
114867
|
+
JOIN agents a ON a.id = t.agentId
|
|
114868
|
+
WHERE t.status = 'in_progress' AND a.status != 'offline' AND a.lastUpdatedAt >= ?`, [cutoff]);
|
|
114869
|
+
return rows.map((row) => row.id);
|
|
114870
|
+
}
|
|
114871
|
+
async function countStillInProgress(taskIds) {
|
|
114872
|
+
if (taskIds.length === 0)
|
|
114873
|
+
return 0;
|
|
114874
|
+
const row = await getDbClient().get(`SELECT count(*) AS n FROM agent_tasks
|
|
114875
|
+
WHERE status = 'in_progress' AND id IN (SELECT value FROM json_each(?))`, [JSON.stringify(taskIds)]);
|
|
114876
|
+
return row?.n ?? 0;
|
|
114877
|
+
}
|
|
114878
|
+
async function drainApi(deps = {}) {
|
|
114879
|
+
const now = deps.now ?? Date.now;
|
|
114880
|
+
const sleep = deps.sleep ?? ((ms) => Bun.sleep(ms));
|
|
114881
|
+
const log = deps.log ?? ((message) => console.log(message));
|
|
114882
|
+
const listInFlight = deps.listInFlight ?? (() => listLiveInFlightTaskIds(now()));
|
|
114883
|
+
const countRemaining = deps.countRemaining ?? countStillInProgress;
|
|
114884
|
+
const maxMs = resolveApiDrainMaxMs(deps.env);
|
|
114885
|
+
const startedAt = now();
|
|
114886
|
+
if (maxMs === 0) {
|
|
114887
|
+
log("[drain] off (API_DRAIN_MAX_MS is 0 or unset): closing without waiting for handoffs");
|
|
114888
|
+
return { enabled: false, inFlight: 0, remaining: 0, waitedMs: 0, timedOut: false };
|
|
114889
|
+
}
|
|
114890
|
+
beginApiDrain(startedAt);
|
|
114891
|
+
let taskIds;
|
|
114892
|
+
try {
|
|
114893
|
+
taskIds = await listInFlight();
|
|
114894
|
+
} catch (err) {
|
|
114895
|
+
log(`[drain] could not read in-flight tasks, closing without waiting: ${describe2(err)}`);
|
|
114896
|
+
return {
|
|
114897
|
+
enabled: true,
|
|
114898
|
+
inFlight: 0,
|
|
114899
|
+
remaining: 0,
|
|
114900
|
+
waitedMs: now() - startedAt,
|
|
114901
|
+
timedOut: false
|
|
114902
|
+
};
|
|
114903
|
+
}
|
|
114904
|
+
if (taskIds.length === 0) {
|
|
114905
|
+
log("[drain] draining: no in-flight tasks on live workers");
|
|
114906
|
+
return {
|
|
114907
|
+
enabled: true,
|
|
114908
|
+
inFlight: 0,
|
|
114909
|
+
remaining: 0,
|
|
114910
|
+
waitedMs: now() - startedAt,
|
|
114911
|
+
timedOut: false
|
|
114912
|
+
};
|
|
114913
|
+
}
|
|
114914
|
+
log(`[drain] draining: waiting up to ${maxMs}ms for ${taskIds.length} in-flight task(s) to be handed off`);
|
|
114915
|
+
const deadline = startedAt + maxMs;
|
|
114916
|
+
let remaining = taskIds.length;
|
|
114917
|
+
while (true) {
|
|
114918
|
+
try {
|
|
114919
|
+
remaining = await countRemaining(taskIds);
|
|
114920
|
+
} catch (err) {
|
|
114921
|
+
log(`[drain] could not re-read in-flight tasks, closing now: ${describe2(err)}`);
|
|
114922
|
+
break;
|
|
114923
|
+
}
|
|
114924
|
+
if (remaining === 0 || now() >= deadline)
|
|
114925
|
+
break;
|
|
114926
|
+
await sleep(Math.min(DRAIN_CHECK_INTERVAL_MS, Math.max(0, deadline - now())));
|
|
114927
|
+
}
|
|
114928
|
+
const waitedMs = now() - startedAt;
|
|
114929
|
+
const timedOut = remaining > 0;
|
|
114930
|
+
log(timedOut ? `[drain] timed out after ${waitedMs}ms with ${remaining} of ${taskIds.length} task(s) still in_progress` : `[drain] all ${taskIds.length} in-flight task(s) handed off after ${waitedMs}ms`);
|
|
114931
|
+
return { enabled: true, inFlight: taskIds.length, remaining, waitedMs, timedOut };
|
|
114932
|
+
}
|
|
114933
|
+
function describe2(err) {
|
|
114934
|
+
return scrubSecrets(err instanceof Error ? err.message : String(err));
|
|
114935
|
+
}
|
|
114936
|
+
|
|
114937
|
+
// src/tools/poll-task.ts
|
|
114128
114938
|
init_db();
|
|
114129
114939
|
var DEFAULT_POLL_INTERVAL_MS = 2000;
|
|
114130
114940
|
var MAX_POLL_DURATION_MS = 1 * 60 * 1000;
|
|
@@ -114199,6 +115009,8 @@ var registerPollTaskTool = (server) => {
|
|
|
114199
115009
|
if (isMultiRuntimeEnabled() && !(requestInfo.runtimeInstanceId && await touchRuntimeInstance(requestInfo.runtimeInstanceId, agentId))) {
|
|
114200
115010
|
return "runtime-unavailable";
|
|
114201
115011
|
}
|
|
115012
|
+
if (isApiDraining())
|
|
115013
|
+
return "draining";
|
|
114202
115014
|
const agentNow = await getAgentById(agentId);
|
|
114203
115015
|
if (agentNow.status !== "busy") {
|
|
114204
115016
|
await updateAgentStatus(agentId, "idle");
|
|
@@ -114225,6 +115037,17 @@ var registerPollTaskTool = (server) => {
|
|
|
114225
115037
|
}
|
|
114226
115038
|
});
|
|
114227
115039
|
}
|
|
115040
|
+
if (outcome === "draining") {
|
|
115041
|
+
return toolOk("No task available.", {
|
|
115042
|
+
details: "The API is draining for a restart and dispatches no new work. Retry shortly.",
|
|
115043
|
+
data: {
|
|
115044
|
+
yourAgentId: requestInfo.agentId,
|
|
115045
|
+
offeredTasks: [],
|
|
115046
|
+
availableCount: 0,
|
|
115047
|
+
waitedForSeconds: Math.round((Date.now() - now.getTime()) / 1000)
|
|
115048
|
+
}
|
|
115049
|
+
});
|
|
115050
|
+
}
|
|
114228
115051
|
if (outcome === "at-capacity") {
|
|
114229
115052
|
return toolOk("No task available.", {
|
|
114230
115053
|
details: `You are at capacity (${await getActiveTaskCount(agentId)} active task(s)). Complete a task before polling for more.`,
|
|
@@ -115053,6 +115876,7 @@ async function markKapsoMessageSeen(messageId) {
|
|
|
115053
115876
|
}
|
|
115054
115877
|
|
|
115055
115878
|
// src/tools/register-kapso-number.ts
|
|
115879
|
+
init_rbac();
|
|
115056
115880
|
init_constants();
|
|
115057
115881
|
function nativeWebhookUrl() {
|
|
115058
115882
|
return `${getPublicMcpBaseUrl()}/api/integrations/kapso/webhook`;
|
|
@@ -115572,7 +116396,30 @@ init_zod();
|
|
|
115572
116396
|
|
|
115573
116397
|
// src/realtime/auth.ts
|
|
115574
116398
|
init_db();
|
|
116399
|
+
init_rbac_roles();
|
|
116400
|
+
|
|
116401
|
+
// src/comb/config.ts
|
|
116402
|
+
init_constants();
|
|
116403
|
+
function trimUrl(value) {
|
|
116404
|
+
const trimmed = value?.trim().replace(/\/+$/, "");
|
|
116405
|
+
return trimmed || null;
|
|
116406
|
+
}
|
|
116407
|
+
function getCombConfig() {
|
|
116408
|
+
const internalUrl = trimUrl(process.env.AGENT_FS_API_URL);
|
|
116409
|
+
return {
|
|
116410
|
+
enabled: isCombEnabled(),
|
|
116411
|
+
apiUrl: trimUrl(process.env.AGENT_FS_PUBLIC_URL) ?? internalUrl,
|
|
116412
|
+
liveUrl: getAgentFsLiveUrl(),
|
|
116413
|
+
orgId: getAgentFsDefaultOrgId() ?? null,
|
|
116414
|
+
driveId: getAgentFsDefaultDriveId() ?? null
|
|
116415
|
+
};
|
|
116416
|
+
}
|
|
116417
|
+
|
|
116418
|
+
// src/realtime/auth.ts
|
|
116419
|
+
init_rbac();
|
|
115575
116420
|
init_context_key();
|
|
116421
|
+
var COMB_PRESENCE_NAMESPACE = /^presence:comb:[A-Za-z0-9_-]{1,64}:[A-Za-z0-9_-]{1,64}$/;
|
|
116422
|
+
var COMB_PRESENCE_OPERATIONS = new Set(["join", "leave", "presence"]);
|
|
115576
116423
|
function pageNamespace(pageId) {
|
|
115577
116424
|
try {
|
|
115578
116425
|
return pageContextKey({ pageId });
|
|
@@ -115617,13 +116464,47 @@ function roomRequestInfo(req, auth) {
|
|
|
115617
116464
|
pageId: header("x-page-id")
|
|
115618
116465
|
};
|
|
115619
116466
|
}
|
|
115620
|
-
async function authorizeRoomNamespace(namespace2, info,
|
|
116467
|
+
async function authorizeRoomNamespace(namespace2, info, access) {
|
|
115621
116468
|
const overflowError = mcpOverflowAuthError(namespace2, info.agentId);
|
|
115622
116469
|
if (overflowError)
|
|
115623
116470
|
return overflowError;
|
|
116471
|
+
if (namespace2.startsWith("presence:comb:")) {
|
|
116472
|
+
if (!COMB_PRESENCE_NAMESPACE.test(namespace2)) {
|
|
116473
|
+
return "invalid Comb presence namespace";
|
|
116474
|
+
}
|
|
116475
|
+
const comb = getCombConfig();
|
|
116476
|
+
if (!comb.enabled)
|
|
116477
|
+
return "Comb is off";
|
|
116478
|
+
if (!comb.orgId || !comb.driveId || namespace2 !== `presence:comb:${comb.orgId}:${comb.driveId}`) {
|
|
116479
|
+
return "Comb presence is only available for the configured Comb drive";
|
|
116480
|
+
}
|
|
116481
|
+
if (info.pageId || info.agentId || !info.isOperator && !info.userId) {
|
|
116482
|
+
return "Comb presence requires dashboard authentication";
|
|
116483
|
+
}
|
|
116484
|
+
if (typeof access !== "string" || !COMB_PRESENCE_OPERATIONS.has(access)) {
|
|
116485
|
+
return "Comb presence rooms only allow join, leave, and presence";
|
|
116486
|
+
}
|
|
116487
|
+
const principal = info.isOperator ? { kind: "operator" } : { kind: "user", userId: info.userId };
|
|
116488
|
+
if (!can({
|
|
116489
|
+
principal,
|
|
116490
|
+
verb: "comb.presence",
|
|
116491
|
+
resource: { kind: "kv-namespace", namespace: namespace2 },
|
|
116492
|
+
source: info.callOrigin === "mcp" ? "mcp" : "http"
|
|
116493
|
+
}).allow) {
|
|
116494
|
+
return "Comb presence requires the comb.presence permission";
|
|
116495
|
+
}
|
|
116496
|
+
if (info.userId && isRbacEnabled()) {
|
|
116497
|
+
const grant = await getUserGrant(info.userId);
|
|
116498
|
+
if (!grant.grantsAll && !grant.verbs.has("comb.presence")) {
|
|
116499
|
+
return "Comb presence requires the comb.presence permission";
|
|
116500
|
+
}
|
|
116501
|
+
}
|
|
116502
|
+
return null;
|
|
116503
|
+
}
|
|
115624
116504
|
const reservedError = reservedNamespaceError(namespace2);
|
|
115625
116505
|
if (reservedError)
|
|
115626
116506
|
return reservedError;
|
|
116507
|
+
const write = typeof access === "boolean" ? access : ["update", "change", "reset", "presence", "publish"].includes(access);
|
|
115627
116508
|
if (!write)
|
|
115628
116509
|
return null;
|
|
115629
116510
|
if (info.userId && !info.isOperator && isRbacEnabled()) {
|
|
@@ -123090,6 +123971,7 @@ var registerUpdateScheduleTool = (server) => {
|
|
|
123090
123971
|
// src/tools/script-apis.ts
|
|
123091
123972
|
init_zod();
|
|
123092
123973
|
init_db();
|
|
123974
|
+
init_rbac();
|
|
123093
123975
|
init_secret_scrubber();
|
|
123094
123976
|
var scriptApisInputSchema = object({
|
|
123095
123977
|
action: _enum(["list", "create", "update", "rotate", "delete"]).describe("list: endpoints for a script, tokens masked unless includeSecrets=true. create: expose the script as a new endpoint (returns the plaintext token once). update: enable/disable or relabel an endpoint. rotate: issue a new token (returns it once). delete: remove an endpoint."),
|
|
@@ -123262,6 +124144,7 @@ var registerScriptApisTool = (server) => {
|
|
|
123262
124144
|
// src/tools/script-connections/tool.ts
|
|
123263
124145
|
init_zod();
|
|
123264
124146
|
init_db();
|
|
124147
|
+
init_rbac();
|
|
123265
124148
|
var scriptConnectionsInputSchema = object({
|
|
123266
124149
|
action: _enum(["list", "upsert-openapi", "upsert-mcp", "upsert-graphql", "refresh", "disable"]).describe("List, create/update, refresh, or disable a script connection."),
|
|
123267
124150
|
id: string().uuid().optional().describe("Existing connection ID for update, refresh, or disable."),
|
|
@@ -124120,11 +125003,11 @@ async function sendTaskHandler(ctx, {
|
|
|
124120
125003
|
const taskDescription = preCreate.description;
|
|
124121
125004
|
const taskOptions = preCreate.options;
|
|
124122
125005
|
const evaluateDedupGuards = async () => {
|
|
124123
|
-
const existingTrackerWork = await findExistingLinearTrackerContextWork(effectiveParentTask?.contextKey);
|
|
125006
|
+
const existingTrackerWork = await findExistingLinearTrackerContextWork(effectiveParentTask?.contextKey, effectiveParentTask?.id);
|
|
124124
125007
|
if (existingTrackerWork) {
|
|
124125
125008
|
const msg = `Skipped: Linear tracker contextKey ${effectiveParentTask?.contextKey} already has ${existingTrackerWork.reason === "active_task" ? "active task" : "linked open PR"} ${existingTrackerWork.task.id.slice(0, 8)}.`;
|
|
124126
125009
|
console.log(`[send-task] ${msg}`);
|
|
124127
|
-
return { ok:
|
|
125010
|
+
return { ok: false, message: msg, task: existingTrackerWork.task };
|
|
124128
125011
|
}
|
|
124129
125012
|
if (!allowDuplicate && creatorAgentId) {
|
|
124130
125013
|
const duplicate = await findDuplicateTask({
|
|
@@ -124169,6 +125052,9 @@ async function sendTaskHandler(ctx, {
|
|
|
124169
125052
|
const raced = await evaluateDedupGuards();
|
|
124170
125053
|
if (raced)
|
|
124171
125054
|
return { success: raced.ok, message: raced.message, task: raced.task };
|
|
125055
|
+
if (isLinearTrackerContextKey(effectiveParentTask?.contextKey)) {
|
|
125056
|
+
taskOptions.bypassTrackerContextDedup = true;
|
|
125057
|
+
}
|
|
124172
125058
|
const targetAgentId = taskOptions.offeredTo ?? taskOptions.agentId ?? undefined;
|
|
124173
125059
|
if (!targetAgentId) {
|
|
124174
125060
|
const newTask2 = await createTaskExtended(taskDescription, taskOptions);
|
|
@@ -124251,6 +125137,7 @@ var registerSendTaskTool = (server) => {
|
|
|
124251
125137
|
// src/tools/skills/skill-create.ts
|
|
124252
125138
|
init_zod();
|
|
124253
125139
|
init_db();
|
|
125140
|
+
init_rbac();
|
|
124254
125141
|
var registerSkillCreateTool = (server) => {
|
|
124255
125142
|
createToolRegistrar(server)("skill-create", {
|
|
124256
125143
|
title: "Create Skill",
|
|
@@ -124319,6 +125206,7 @@ var registerSkillCreateTool = (server) => {
|
|
|
124319
125206
|
// src/tools/skills/skill-delete.ts
|
|
124320
125207
|
init_zod();
|
|
124321
125208
|
init_db();
|
|
125209
|
+
init_rbac();
|
|
124322
125210
|
var SYSTEM_DEFAULT_SKILL_LOCKED_MESSAGE = "This skill is system-managed and cannot be edited from the UI; it is re-seeded on each start. Fork it under a new name to customize.";
|
|
124323
125211
|
var registerSkillDeleteTool = (server) => {
|
|
124324
125212
|
createToolRegistrar(server)("skill-delete", {
|
|
@@ -124446,6 +125334,7 @@ ${file.content}`,
|
|
|
124446
125334
|
// src/tools/skills/skill-install.ts
|
|
124447
125335
|
init_zod();
|
|
124448
125336
|
init_db();
|
|
125337
|
+
init_rbac();
|
|
124449
125338
|
var registerSkillInstallTool = (server) => {
|
|
124450
125339
|
createToolRegistrar(server)("skill-install", {
|
|
124451
125340
|
title: "Install Skill",
|
|
@@ -124504,6 +125393,7 @@ var registerSkillInstallTool = (server) => {
|
|
|
124504
125393
|
// src/tools/skills/skill-install-remote.ts
|
|
124505
125394
|
init_zod();
|
|
124506
125395
|
init_db();
|
|
125396
|
+
init_rbac();
|
|
124507
125397
|
var registerSkillInstallRemoteTool = (server) => {
|
|
124508
125398
|
createToolRegistrar(server)("skill-install-remote", {
|
|
124509
125399
|
title: "Install Remote Skill",
|
|
@@ -124850,6 +125740,7 @@ var registerSkillSyncRemoteTool = (server) => {
|
|
|
124850
125740
|
// src/tools/skills/skill-uninstall.ts
|
|
124851
125741
|
init_zod();
|
|
124852
125742
|
init_db();
|
|
125743
|
+
init_rbac();
|
|
124853
125744
|
var registerSkillUninstallTool = (server) => {
|
|
124854
125745
|
createToolRegistrar(server)("skill-uninstall", {
|
|
124855
125746
|
title: "Uninstall Skill",
|
|
@@ -124893,6 +125784,7 @@ var registerSkillUninstallTool = (server) => {
|
|
|
124893
125784
|
// src/tools/skills/skill-update.ts
|
|
124894
125785
|
init_zod();
|
|
124895
125786
|
init_db();
|
|
125787
|
+
init_rbac();
|
|
124896
125788
|
var SYSTEM_DEFAULT_SKILL_LOCKED_MESSAGE2 = "This skill is system-managed and cannot be edited from the UI; it is re-seeded on each start. Fork it under a new name to customize.";
|
|
124897
125789
|
var registerSkillUpdateTool = (server) => {
|
|
124898
125790
|
createToolRegistrar(server)("skill-update", {
|
|
@@ -124996,6 +125888,7 @@ var registerSkillUpdateTool = (server) => {
|
|
|
124996
125888
|
// src/tools/slack-archive-channel.ts
|
|
124997
125889
|
init_zod();
|
|
124998
125890
|
init_db();
|
|
125891
|
+
init_rbac();
|
|
124999
125892
|
|
|
125000
125893
|
// src/slack/channel-join.ts
|
|
125001
125894
|
var logger = console;
|
|
@@ -125173,6 +126066,7 @@ var registerSlackArchiveChannelTool = (server) => {
|
|
|
125173
126066
|
// src/tools/slack-create-channel.ts
|
|
125174
126067
|
init_zod();
|
|
125175
126068
|
init_db();
|
|
126069
|
+
init_rbac();
|
|
125176
126070
|
var registerSlackCreateChannelTool = (server) => {
|
|
125177
126071
|
createToolRegistrar(server)("slack-create-channel", {
|
|
125178
126072
|
title: "Create a Slack channel",
|
|
@@ -125228,6 +126122,7 @@ var registerSlackCreateChannelTool = (server) => {
|
|
|
125228
126122
|
// src/tools/slack-delete.ts
|
|
125229
126123
|
init_zod();
|
|
125230
126124
|
init_db();
|
|
126125
|
+
init_rbac();
|
|
125231
126126
|
|
|
125232
126127
|
// src/slack/message-text.ts
|
|
125233
126128
|
function collectRichTextParts(node, parts) {
|
|
@@ -125922,6 +126817,7 @@ ${fetchCommand}`,
|
|
|
125922
126817
|
// src/tools/slack-invite-to-channel.ts
|
|
125923
126818
|
init_zod();
|
|
125924
126819
|
init_db();
|
|
126820
|
+
init_rbac();
|
|
125925
126821
|
var registerSlackInviteToChannelTool = (server) => {
|
|
125926
126822
|
createToolRegistrar(server)("slack-invite-to-channel", {
|
|
125927
126823
|
title: "Invite users to a Slack channel",
|
|
@@ -126071,6 +126967,7 @@ var registerSlackListChannelsTool = (server) => {
|
|
|
126071
126967
|
// src/tools/slack-post.ts
|
|
126072
126968
|
init_zod();
|
|
126073
126969
|
init_db();
|
|
126970
|
+
init_rbac();
|
|
126074
126971
|
var registerSlackPostTool = (server) => {
|
|
126075
126972
|
createToolRegistrar(server)("slack-post", {
|
|
126076
126973
|
title: "Post message to Slack channel",
|
|
@@ -126174,6 +127071,7 @@ var registerSlackPostTool = (server) => {
|
|
|
126174
127071
|
// src/tools/slack-read.ts
|
|
126175
127072
|
init_zod();
|
|
126176
127073
|
init_db();
|
|
127074
|
+
init_rbac();
|
|
126177
127075
|
var AUTO_DOWNLOAD_DIR = "/app/shared/downloads/slack";
|
|
126178
127076
|
var SlackFileSchema = looseObject({
|
|
126179
127077
|
id: string().optional(),
|
|
@@ -126308,9 +127206,9 @@ var registerSlackReadTool = (server) => {
|
|
|
126308
127206
|
const extractedText = extractSlackMessageText(m);
|
|
126309
127207
|
if (!extractedText && (!m.files || m.files.length === 0))
|
|
126310
127208
|
continue;
|
|
126311
|
-
const
|
|
127209
|
+
const isBot2 = m.user === botUserId || m.bot_id !== undefined || m.subtype === "bot_message";
|
|
126312
127210
|
let username;
|
|
126313
|
-
if (
|
|
127211
|
+
if (isBot2) {
|
|
126314
127212
|
username = m.username || "Agent";
|
|
126315
127213
|
} else if (m.user) {
|
|
126316
127214
|
username = await getUserDisplayName(m.user);
|
|
@@ -126348,7 +127246,7 @@ var registerSlackReadTool = (server) => {
|
|
|
126348
127246
|
messages.push({
|
|
126349
127247
|
user: m.user,
|
|
126350
127248
|
username,
|
|
126351
|
-
isBot,
|
|
127249
|
+
isBot: isBot2,
|
|
126352
127250
|
text: extractedText,
|
|
126353
127251
|
ts: m.ts,
|
|
126354
127252
|
files
|
|
@@ -126543,6 +127441,7 @@ var registerSlackReplyTool = (server) => {
|
|
|
126543
127441
|
// src/tools/slack-start-thread.ts
|
|
126544
127442
|
init_zod();
|
|
126545
127443
|
init_db();
|
|
127444
|
+
init_rbac();
|
|
126546
127445
|
var registerSlackStartThreadTool = (server) => {
|
|
126547
127446
|
createToolRegistrar(server)("slack-start-thread", {
|
|
126548
127447
|
title: "Start a new Slack thread",
|
|
@@ -126631,6 +127530,7 @@ var registerSlackStartThreadTool = (server) => {
|
|
|
126631
127530
|
// src/tools/slack-update.ts
|
|
126632
127531
|
init_zod();
|
|
126633
127532
|
init_db();
|
|
127533
|
+
init_rbac();
|
|
126634
127534
|
var registerSlackUpdateTool = (server) => {
|
|
126635
127535
|
createToolRegistrar(server)("slack-update", {
|
|
126636
127536
|
title: "Edit a Slack message",
|
|
@@ -126717,6 +127617,7 @@ var registerSlackUpdateTool = (server) => {
|
|
|
126717
127617
|
// src/tools/slack-upload-file.ts
|
|
126718
127618
|
init_zod();
|
|
126719
127619
|
init_db();
|
|
127620
|
+
init_rbac();
|
|
126720
127621
|
var WORKSPACE_DIR = "/workspace";
|
|
126721
127622
|
function resolveTaskUploadThreadTs(task) {
|
|
126722
127623
|
if (!task)
|
|
@@ -126909,6 +127810,7 @@ ${triedPathsList}
|
|
|
126909
127810
|
init_zod();
|
|
126910
127811
|
init_db();
|
|
126911
127812
|
init_steering();
|
|
127813
|
+
init_rbac();
|
|
126912
127814
|
init_types();
|
|
126913
127815
|
var steerTaskInputSchema = object({
|
|
126914
127816
|
taskId: uuid().describe("The ID of the running task to steer."),
|
|
@@ -127004,6 +127906,7 @@ var registerSteerTaskTool = (server) => {
|
|
|
127004
127906
|
// src/tools/store-progress.ts
|
|
127005
127907
|
init_zod();
|
|
127006
127908
|
init_db();
|
|
127909
|
+
init_rbac();
|
|
127007
127910
|
init_types();
|
|
127008
127911
|
init_secret_scrubber();
|
|
127009
127912
|
var BLOCKED_WAITING_PATTERN = /\b(waiting (for|on)|blocked (on|until|by)|still waiting|awaiting)\b/i;
|
|
@@ -127227,8 +128130,8 @@ var registerStoreProgressTool = (server) => {
|
|
|
127227
128130
|
return terminalResultGuard;
|
|
127228
128131
|
}
|
|
127229
128132
|
if (progress && !isTerminal2) {
|
|
127230
|
-
const
|
|
127231
|
-
if (!
|
|
128133
|
+
const isDuplicate5 = existingTask.progress === progress && existingTask.lastUpdatedAt && Date.now() - new Date(existingTask.lastUpdatedAt).getTime() < 5 * 60 * 1000;
|
|
128134
|
+
if (!isDuplicate5) {
|
|
127232
128135
|
const result2 = await updateTaskProgress(taskId, progress);
|
|
127233
128136
|
if (result2)
|
|
127234
128137
|
updatedTask = result2;
|
|
@@ -127362,6 +128265,7 @@ This check refuses once per task; the next completion is accepted and unfixed ci
|
|
|
127362
128265
|
init_zod();
|
|
127363
128266
|
init_db();
|
|
127364
128267
|
init_swarm_config_guard();
|
|
128268
|
+
init_rbac();
|
|
127365
128269
|
var registerDeleteConfigTool = (server) => {
|
|
127366
128270
|
createToolRegistrar(server)("delete-config", {
|
|
127367
128271
|
title: "Delete Config",
|
|
@@ -127433,6 +128337,7 @@ var registerDeleteConfigTool = (server) => {
|
|
|
127433
128337
|
init_zod();
|
|
127434
128338
|
init_db();
|
|
127435
128339
|
init_swarm_config_guard();
|
|
128340
|
+
init_rbac();
|
|
127436
128341
|
init_types();
|
|
127437
128342
|
init_secret_scrubber();
|
|
127438
128343
|
var configEntryShape = looseObject({
|
|
@@ -127523,6 +128428,7 @@ var registerGetConfigTool = (server) => {
|
|
|
127523
128428
|
init_zod();
|
|
127524
128429
|
init_db();
|
|
127525
128430
|
init_swarm_config_guard();
|
|
128431
|
+
init_rbac();
|
|
127526
128432
|
init_types();
|
|
127527
128433
|
init_secret_scrubber();
|
|
127528
128434
|
var configEntryShape2 = looseObject({
|
|
@@ -127613,6 +128519,7 @@ var registerListConfigTool = (server) => {
|
|
|
127613
128519
|
init_zod();
|
|
127614
128520
|
init_db();
|
|
127615
128521
|
init_swarm_config_guard();
|
|
128522
|
+
init_rbac();
|
|
127616
128523
|
init_types();
|
|
127617
128524
|
var configEntryShape3 = looseObject({
|
|
127618
128525
|
id: string().optional(),
|
|
@@ -127977,6 +128884,12 @@ async function staleRuntimeResult(ctx, agentId) {
|
|
|
127977
128884
|
message: "This runtime is no longer registered. Re-register before taking work."
|
|
127978
128885
|
};
|
|
127979
128886
|
}
|
|
128887
|
+
function apiDrainingResult(action) {
|
|
128888
|
+
return {
|
|
128889
|
+
success: false,
|
|
128890
|
+
message: `The API is draining for a restart and dispatches no new work, so this ${action} was not made. Retry shortly.`
|
|
128891
|
+
};
|
|
128892
|
+
}
|
|
127980
128893
|
function taskActionResult(result, agentId) {
|
|
127981
128894
|
const { refusalSideEffects: _omit, success, message, ...rest } = result;
|
|
127982
128895
|
const data = {
|
|
@@ -128120,6 +129033,8 @@ async function taskActionHandler(ctx, input) {
|
|
|
128120
129033
|
const staleClaimRuntime = await staleRuntimeResult(ctx, agentId);
|
|
128121
129034
|
if (staleClaimRuntime)
|
|
128122
129035
|
return staleClaimRuntime;
|
|
129036
|
+
if (isApiDraining())
|
|
129037
|
+
return apiDrainingResult("claim");
|
|
128123
129038
|
if (!await hasCapacity(agentId)) {
|
|
128124
129039
|
const activeCount = await getActiveTaskCount(agentId);
|
|
128125
129040
|
const agent = await getAgentById(agentId);
|
|
@@ -128210,6 +129125,8 @@ async function taskActionHandler(ctx, input) {
|
|
|
128210
129125
|
const staleAcceptRuntime = await staleRuntimeResult(ctx, agentId);
|
|
128211
129126
|
if (staleAcceptRuntime)
|
|
128212
129127
|
return staleAcceptRuntime;
|
|
129128
|
+
if (isApiDraining())
|
|
129129
|
+
return apiDrainingResult("accept");
|
|
128213
129130
|
const existingTask = await getTaskById(taskId);
|
|
128214
129131
|
if (!existingTask) {
|
|
128215
129132
|
return { success: false, message: `Task "${taskId}" not found.` };
|
|
@@ -128593,6 +129510,7 @@ var registerUnregisterServiceTool = (server) => {
|
|
|
128593
129510
|
// src/tools/update-profile.ts
|
|
128594
129511
|
init_zod();
|
|
128595
129512
|
init_db();
|
|
129513
|
+
init_rbac();
|
|
128596
129514
|
import { mkdtemp as mkdtemp2, rm as rm2 } from "node:fs/promises";
|
|
128597
129515
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
128598
129516
|
import { join as join3 } from "node:path";
|
|
@@ -130419,7 +131337,7 @@ async function readScriptSdkJsonResponse(response, operation, limitBytes = SCRIP
|
|
|
130419
131337
|
}
|
|
130420
131338
|
|
|
130421
131339
|
// src/scripts-runtime/swarm-sdk.ts
|
|
130422
|
-
function
|
|
131340
|
+
function headers3(config) {
|
|
130423
131341
|
return {
|
|
130424
131342
|
Authorization: `Bearer ${Redacted.value(config.apiKey)}`,
|
|
130425
131343
|
"X-Agent-ID": Redacted.value(config.agentId),
|
|
@@ -130852,7 +131770,7 @@ async function callBridgeApi(name, args2, config, options = {}) {
|
|
|
130852
131770
|
const mcpToolName = mcpToolNameForSdkMethod(name);
|
|
130853
131771
|
const res2 = await fetch(`${baseUrl}/api/mcp-bridge`, {
|
|
130854
131772
|
method: "POST",
|
|
130855
|
-
headers:
|
|
131773
|
+
headers: headers3(config),
|
|
130856
131774
|
body: JSON.stringify({ tool: mcpToolName, args: args2 ?? {} })
|
|
130857
131775
|
});
|
|
130858
131776
|
const data2 = await readScriptSdkJsonResponse(res2, `ctx.swarm.${name}`);
|
|
@@ -130864,7 +131782,7 @@ async function callBridgeApi(name, args2, config, options = {}) {
|
|
|
130864
131782
|
}
|
|
130865
131783
|
const res = await fetch(`${baseUrl}${request.path}`, {
|
|
130866
131784
|
method: request.method,
|
|
130867
|
-
headers:
|
|
131785
|
+
headers: headers3(config),
|
|
130868
131786
|
body: request.body === undefined ? undefined : JSON.stringify(request.body)
|
|
130869
131787
|
});
|
|
130870
131788
|
const data = await readScriptSdkJsonResponse(res, `ctx.swarm.${name}`);
|
|
@@ -132420,7 +133338,7 @@ class NotifyExecutor extends BaseExecutor {
|
|
|
132420
133338
|
}
|
|
132421
133339
|
}
|
|
132422
133340
|
case "slack": {
|
|
132423
|
-
const { getSlackApp: getSlackApp2 } = await import("./app-
|
|
133341
|
+
const { getSlackApp: getSlackApp2 } = await import("./app-pt68fbwp.js");
|
|
132424
133342
|
const app = getSlackApp2();
|
|
132425
133343
|
if (!app) {
|
|
132426
133344
|
return {
|
|
@@ -133225,4 +134143,4 @@ async function initWorkflows() {
|
|
|
133225
134143
|
logOpenWebhookTriggers();
|
|
133226
134144
|
}
|
|
133227
134145
|
|
|
133228
|
-
export { DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, isJSONRPCRequest, isJSONRPCResultResponse, isJSONRPCErrorResponse, JSONRPCMessageSchema, isInitializeRequest, McpServer, isGitHubEnabled, initGitHub, verifyWebhookSignature, isAgentMailEnabled, initAgentMail, verifyAgentMailWebhook, findUserById, findUserByExternalId, getUserIdentities, listUserEvents, listUserTokens, recordIdentityEvent, findOrCreateUserByEmail, linkIdentity, unlinkIdentity, mintToken, revokeToken, resolveUserByToken, mintSessionToken, revokeSessionToken, fingerprintApiKey, resolveIdentity, renderIdentity, createAdditiveBuffer, listHarnessModelSupport, recordHarnessModelSupport, agentRanModel, getAgentHarnessCliVersion, setAgentHarnessCliVersion, sanitizeModelTierOverrides, parseModelTierOverridesHeader, setAgentModelTierOverrides, previewModelTiers, recordClaimModelResolution, harnessModelErrorFor, poolTaskRunsOnHarness, explicitModelError, explicitModelErrorForAgent, referencedBundlePaths, skillDirs, TaskCreationBlockedError, recordUnmappedIdentity, MAX_TASK_ATTACHMENT_BYTES, recordTaskAttachmentUpload, buildEffectiveText, bufferedFileFailures, fetchSlackFiles, createSlackTaskWithFiles, notifySlackFileFailures, hasOtherUserMention, broadcastMatches, routeMessage, extractTaskFromMessage, extractSlackMessageText, automationIntegrationFixUrl, preflightAutomation, getAutomationSetupStates, listEnabledAutomationPreflightInputs, validateJsonSchema, workflowSaveWarnings, TriggerSchemaError, startWorkflowExecution, setupWorkflowResumeListener, retryFailedRun, cancelWorkflowRun, resumeWaitState, initWaitBusSubscriptions, subscribeWaitToBus, recoverIncompleteRuns, startRetryPoller, stopRetryPoller, validateTemplateVariables, instantiateTemplate, handleWebhookTrigger, logOpenWebhookTriggers, handleEventTrigger, handleScheduleTrigger, verifyHmacSignature, WebhookError, snapshotWorkflow, snapshotAndUpdateWorkflow, startWaitPoller, stopWaitPoller, RawLlmConfigSchema, RawLlmOutputSchema, executeRawLlm, getExecutorRegistry, initWorkflows, dispatchScheduleTarget, calculateNextRun, startScheduler, stopScheduler, runScheduleNow, parseSkillContent, ExtensionAssetConflictError, ExtensionOwnershipError, getExtensionFiles, getExtensionById, getExtensionByName, listExtensions, listExtensionVersions, updateExtensionMeta, listExtensionRuns, SDK_ALLOWLIST, mcpToolNameForSdkMethod, mcpOverflowAuthError, toolErr, createToolRegistrar, warnIfCorsAllowsAnyOrigin, isOriginAllowedForCredentials, allowedCredentialRedirect, setCorsHeaders, parseQueryParams, getPathSegments, wireHttpSpanLifecycle, safeRequestUrlForLog, agentWithCapacity, parseBody, BODY_TOO_LARGE, enforceContentLengthCap, json, jsonError, triggerSchemaErrorResponse, deriveApiBaseUrl, httpServerSemconvAttributes, runtimeInstanceHeader, describeRequestRoute, route, handleMcpBridge, Redacted, SCRIPT_SDK_RESPONSE_LIMIT_BYTES, readScriptSdkJsonResponse, ExtensionConfigError, ExtensionLifecycleError, setExtensionLoopbackBaseUrl, enableExtension, disableExtension, activateVersion, ExtensionAssetsInvalidError, installExtensionWithAssets, uninstallExtension, reloadExtension, loadEnabledExtensions, stopExtensionRuntime, ExtensionAbortedError, isRegistered, isExtensionAgentId, getExtensionBridgeToken, resolveBridgeCallOrigin, extensionIdForAgent, runContext, registerLoaded, unregister, listRegistered, dispatchPre, dispatchPost, stripSiblingBlock, createTaskWithSiblingAwareness, isInboxAllowed, isSenderAllowed, handleMessageReceived, AGENT_MAX_TASKS_CONFIG_KEY, reconcileAgentMaxTasksPolicy, resetAgentMaxTasksMirror, upsertSwarmConfigWithPolicyMirror, runtimeStaleThresholdMinutes, upsertRuntimeInstance, getRuntimeInstanceById, touchRuntimeInstance, countActiveRuntimeInstancesForAgent, listRuntimeInstancesForAgent, setRuntimeCredentialReady, reconcileAgentStatusFromRuntimes, agentsWithLiveRuntime, expireStaleRuntimeInstances, enqueueAuditRow, enqueueAdmissionRow, flushAuditBuffer, startAuditWriter, stopAuditWriter, startAuditGc, stopAuditGc, handlePullRequest, handleIssue, handleComment, handlePullRequestReview, handleCheckRun, handleCheckSuite, handleWorkflowRun, isGitLabEnabled, initGitLab, verifyGitLabWebhook, handleMergeRequest, handleIssue2 as handleIssue1, handleNote, handlePipeline, repointTrackerSyncBySwarmId, getJiraMetadata, updateJiraMetadata, clearJiraMetadata, registerJiraWebhook, deleteJiraWebhook, isJiraEnabled, initJira, handleJiraWebhook, handleAgentSessionEvent, handleIssueUpdate, handleIssueDelete, handleAgentSessionPrompted, isLinearEnabled, initLinear, parseCookieHeader, extractAndVerifyCookie, issuePageSessionCookie, resolveHttpRequestAuth, loadGlobalConfigsIntoEnv, reloadGlobalConfigsAndIntegrations, scheduleIntegrationsReload, handleCore, userCtx, resolveTaskAuditUserId, resolveHttpAuditUserId, resolveHttpFavoriteOwner, handleApps, cancelApprovalRequest, cancelApprovalRequestAndRun, getUserCommsPrefs, getTaskDetailsInputSchema, getTaskDetailsOutputSchema, getTaskDetailsHandler, cancelTaskInputSchema, cancelTaskOutputSchema, cancelTaskHandler, executeReadOnlyQuery, assertSelectOnlyQuery, handleDbQuery, snapshotMetric, AssetKeyAuthorizationError, authorizeAssetKeyWrite, snapshotPage, assertOAuthAppUrlsSafe, assertOAuthEgressUrlSafe, listOAuthPresets, listOAuthPresetIds, getOAuthPreset, hydrateOAuthAppFromPreset, scopedResourceScopeIdSchema, resolveScopedResourceId, dedupeMemoryDocumentIds, recordMemoryAccesses, recordRetrievals, ExplicitSelfDuplicateError, applyRating, shouldPersistAutomaticTaskMemory, REBOOT_RETRY_PIN_TAG, getPinCandidateAgent, resolveLeadOnlyRecoveryAssignment, getResumeGeneration, getNextResumeGeneration, createWorkerTaskFollowUp, createResumeFollowUp, createRerouteDecisionTask, createPoolStarvationDecisionTask, guardTerminalTaskResultWrite, getTasksInputSchema, getTasksOutputSchema, getTasksHandler, reservedNamespaceError, reservedRoomKeyError, refreshLinks, canReadMemory, getLinksForMemory, expandCandidatesWithGraph, indexMemoryContent, markKapsoMessageRead, sendKapsoReaction, getKapsoConfig, getKapsoNumberMapping, markKapsoMessageSeen, resolveRoomNamespace, roomRequestInfo, authorizeRoomNamespace, RoomOperationSchema, removeAwarenessStates, roomTopic, decodeRoomSnapshot, roomView, getRoom, changeRoom, applyRoomUpdate, resetRoom, sweepRooms, closeRooms, removeNamespaceRooms, createEvent, createEventsBatch, getEventCountsFiltered, getEventsFiltered, mergeScheduleTiming, validateRecurringTiming, checkOutputSchemaShape, sendTaskOutputSchema, sendTaskHandler, steerTaskUserInputSchema, steerTaskOutputSchema, steerTaskHandler, canClaim, emitBudgetRefusalSideEffects, taskActionInputSchema, taskActionOutputSchema, taskActionHandler, workflowModelErrors, patchWorkflowDefinition, resolveScriptsOnlyMode, ALL_CAPABILITIES, hasCapability, getEnabledCapabilities, createServer };
|
|
134146
|
+
export { DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, isJSONRPCRequest, isJSONRPCResultResponse, isJSONRPCErrorResponse, JSONRPCMessageSchema, isInitializeRequest, McpServer, isGitHubEnabled, initGitHub, verifyWebhookSignature, isAgentMailEnabled, initAgentMail, verifyAgentMailWebhook, findUserById, findUserByExternalId, getUserIdentities, listUserEvents, listUserTokens, recordIdentityEvent, findOrCreateUserByEmail, linkIdentity, unlinkIdentity, mintToken, revokeToken, resolveUserByToken, mintSessionToken, revokeSessionToken, fingerprintApiKey, resolveIdentity, renderIdentity, createAdditiveBuffer, listHarnessModelSupport, recordHarnessModelSupport, agentRanModel, getAgentHarnessCliVersion, setAgentHarnessCliVersion, sanitizeModelTierOverrides, parseModelTierOverridesHeader, setAgentModelTierOverrides, previewModelTiers, recordClaimModelResolution, harnessModelErrorFor, poolTaskRunsOnHarness, explicitModelError, explicitModelErrorForAgent, referencedBundlePaths, skillDirs, TaskCreationBlockedError, recordUnmappedIdentity, MAX_TASK_ATTACHMENT_BYTES, recordTaskAttachmentUpload, buildEffectiveText, bufferedFileFailures, fetchSlackFiles, createSlackTaskWithFiles, notifySlackFileFailures, hasOtherUserMention, broadcastMatches, routeMessage, extractTaskFromMessage, extractSlackMessageText, automationIntegrationFixUrl, preflightAutomation, getAutomationSetupStates, listEnabledAutomationPreflightInputs, validateJsonSchema, workflowSaveWarnings, TriggerSchemaError, startWorkflowExecution, setupWorkflowResumeListener, retryFailedRun, cancelWorkflowRun, resumeWaitState, initWaitBusSubscriptions, subscribeWaitToBus, recoverIncompleteRuns, startRetryPoller, stopRetryPoller, validateTemplateVariables, instantiateTemplate, handleWebhookTrigger, logOpenWebhookTriggers, handleEventTrigger, handleScheduleTrigger, verifyHmacSignature, WebhookError, snapshotWorkflow, snapshotAndUpdateWorkflow, startWaitPoller, stopWaitPoller, RawLlmConfigSchema, RawLlmOutputSchema, executeRawLlm, getExecutorRegistry, initWorkflows, dispatchScheduleTarget, calculateNextRun, startScheduler, stopScheduler, runScheduleNow, parseSkillContent, ExtensionAssetConflictError, ExtensionOwnershipError, getExtensionFiles, getExtensionById, getExtensionByName, listExtensions, listExtensionVersions, updateExtensionMeta, listExtensionRuns, SDK_ALLOWLIST, mcpToolNameForSdkMethod, mcpOverflowAuthError, toolErr, createToolRegistrar, warnIfCorsAllowsAnyOrigin, isOriginAllowedForCredentials, allowedCredentialRedirect, setCorsHeaders, parseQueryParams, getPathSegments, wireHttpSpanLifecycle, safeRequestUrlForLog, agentWithCapacity, parseBody, BODY_TOO_LARGE, enforceContentLengthCap, json, jsonError, triggerSchemaErrorResponse, deriveApiBaseUrl, httpServerSemconvAttributes, runtimeInstanceHeader, describeRequestRoute, route, handleMcpBridge, Redacted, SCRIPT_SDK_RESPONSE_LIMIT_BYTES, readScriptSdkJsonResponse, ExtensionConfigError, ExtensionLifecycleError, setExtensionLoopbackBaseUrl, enableExtension, disableExtension, activateVersion, ExtensionAssetsInvalidError, installExtensionWithAssets, uninstallExtension, reloadExtension, loadEnabledExtensions, stopExtensionRuntime, ExtensionAbortedError, isRegistered, isExtensionAgentId, getExtensionBridgeToken, resolveBridgeCallOrigin, extensionIdForAgent, runContext, registerLoaded, unregister, listRegistered, dispatchPre, dispatchPost, stripSiblingBlock, createTaskWithSiblingAwareness, isInboxAllowed, isSenderAllowed, handleMessageReceived, isAzureDevOpsEnabled, initAzureDevOps, verifyAzureDevOpsWebhook, isAzureDevOpsUrl, canonicalAzureDevOpsRepoUrl, parseAzureDevOpsRepoUrl, createdPullRequestOf, commentedPayloadOf, handlePullRequestCreated, handlePullRequestCommented, AGENT_MAX_TASKS_CONFIG_KEY, reconcileAgentMaxTasksPolicy, resetAgentMaxTasksMirror, upsertSwarmConfigWithPolicyMirror, runtimeStaleThresholdMinutes, upsertRuntimeInstance, getRuntimeInstanceById, touchRuntimeInstance, countActiveRuntimeInstancesForAgent, listRuntimeInstancesForAgent, setRuntimeCredentialReady, reconcileAgentStatusFromRuntimes, agentsWithLiveRuntime, expireStaleRuntimeInstances, enqueueAuditRow, enqueueAdmissionRow, flushAuditBuffer, startAuditWriter, stopAuditWriter, startAuditGc, stopAuditGc, handlePullRequest, handleIssue, handleComment, handlePullRequestReview, handleCheckRun, handleCheckSuite, handleWorkflowRun, isGitLabEnabled, initGitLab, verifyGitLabWebhook, handleMergeRequest, handleIssue2 as handleIssue1, handleNote, handlePipeline, repointTrackerSyncBySwarmId, getJiraMetadata, updateJiraMetadata, clearJiraMetadata, registerJiraWebhook, deleteJiraWebhook, isJiraEnabled, initJira, handleJiraWebhook, handleAgentSessionEvent, handleIssueUpdate, handleIssueDelete, handleAgentSessionPrompted, isLinearEnabled, initLinear, parseCookieHeader, extractAndVerifyCookie, issuePageSessionCookie, resolveHttpRequestAuth, loadGlobalConfigsIntoEnv, reloadGlobalConfigsAndIntegrations, scheduleIntegrationsReload, handleCore, userCtx, resolveTaskAuditUserId, resolveHttpAuditUserId, resolveHttpFavoriteOwner, handleApps, cancelApprovalRequest, cancelApprovalRequestAndRun, getUserCommsPrefs, getTaskDetailsInputSchema, getTaskDetailsOutputSchema, getTaskDetailsHandler, cancelTaskInputSchema, cancelTaskOutputSchema, cancelTaskHandler, executeReadOnlyQuery, assertSelectOnlyQuery, handleDbQuery, snapshotMetric, AssetKeyAuthorizationError, authorizeAssetKeyWrite, snapshotPage, assertOAuthAppUrlsSafe, assertOAuthEgressUrlSafe, listOAuthPresets, listOAuthPresetIds, getOAuthPreset, hydrateOAuthAppFromPreset, scopedResourceScopeIdSchema, resolveScopedResourceId, dedupeMemoryDocumentIds, recordMemoryAccesses, recordRetrievals, ExplicitSelfDuplicateError, applyRating, shouldPersistAutomaticTaskMemory, REBOOT_RETRY_PIN_TAG, getPinCandidateAgent, resolveLeadOnlyRecoveryAssignment, getResumeGeneration, getNextResumeGeneration, createWorkerTaskFollowUp, createResumeFollowUp, createRerouteDecisionTask, createPoolStarvationDecisionTask, guardTerminalTaskResultWrite, getTasksInputSchema, getTasksOutputSchema, getTasksHandler, reservedNamespaceError, reservedRoomKeyError, MemoryKeyError, refreshLinks, canReadMemory, getLinksForMemory, expandCandidatesWithGraph, indexMemoryContent, isApiDraining, drainApi, markKapsoMessageRead, sendKapsoReaction, getKapsoConfig, getKapsoNumberMapping, markKapsoMessageSeen, getCombConfig, resolveRoomNamespace, roomRequestInfo, authorizeRoomNamespace, RoomOperationSchema, removeAwarenessStates, roomTopic, decodeRoomSnapshot, roomView, getRoom, changeRoom, applyRoomUpdate, resetRoom, sweepRooms, closeRooms, removeNamespaceRooms, createEvent, createEventsBatch, getEventCountsFiltered, getEventsFiltered, mergeScheduleTiming, validateRecurringTiming, checkOutputSchemaShape, sendTaskOutputSchema, sendTaskHandler, steerTaskUserInputSchema, steerTaskOutputSchema, steerTaskHandler, canClaim, emitBudgetRefusalSideEffects, taskActionInputSchema, taskActionOutputSchema, taskActionHandler, workflowModelErrors, patchWorkflowDefinition, resolveScriptsOnlyMode, ALL_CAPABILITIES, hasCapability, getEnabledCapabilities, createServer };
|