@desplega.ai/agent-swarm 1.158.0 → 1.160.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 +1 -1
- package/dist/{acp-adapter-xaq4n6pc.js → acp-adapter-2mjwcsfh.js} +124 -27
- package/dist/{actions-p9hz5yat.js → actions-e43rxskr.js} +35 -30
- package/dist/{anthropic-messages-51pz26qe.js → anthropic-messages-5qx80j9k.js} +106 -16
- package/dist/{app-g26wdcz6.js → app-mc7xfagn.js} +12 -10
- package/dist/{assistant-wydfqkb3.js → assistant-sedkzv3b.js} +42 -31
- package/dist/{azure-openai-responses-8gksqtmz.js → azure-openai-responses-nfb21z9a.js} +13 -14
- package/dist/{boot-reembed-se8zmdcp.js → boot-reembed-cqz9swn5.js} +13 -12
- package/dist/{boot-reembed-g5ckg9yb.js → boot-reembed-m3656j2n.js} +14 -13
- package/dist/{boot-scrub-logs-wfxqan61.js → boot-scrub-logs-xbxf5d7w.js} +11 -9
- package/dist/boot-seeds-gsetbs5y.js +28 -0
- package/dist/{claude-adapter-tv2x4f36.js → claude-adapter-dc6289mc.js} +28 -23
- package/dist/{claude-managed-adapter-41b2s7fd.js → claude-managed-adapter-naaw51me.js} +4 -3
- package/dist/{claude-managed-setup-60g8aazx.js → claude-managed-setup-eacvchx0.js} +12 -3
- package/dist/claude-sdk-session-bqp2xvym.js +29722 -0
- package/dist/{cli-987hg0aa.js → cli-0jwe9034.js} +2 -2
- package/dist/{cli-vj6h9kc2.js → cli-0m7wct0d.js} +59 -1
- package/dist/{cli-c07r9a2m.js → cli-0q3avq3s.js} +12 -11
- package/dist/{cli-19jenss3.js → cli-0wgxmwf6.js} +31 -10
- package/dist/cli-0x01kwrd.js +491 -0
- package/dist/cli-0xqde53b.js +176 -0
- package/dist/cli-10nhj6xq.js +8355 -0
- package/dist/{cli-tt9k8r35.js → cli-12tszpk9.js} +479 -910
- package/dist/{cli-5b6b62tz.js → cli-13hw4z91.js} +1 -1
- package/dist/{cli-cqt19wg6.js → cli-1a2j50m0.js} +11 -2
- package/dist/{cli-xberxa1r.js → cli-25fcq4b4.js} +2 -2
- package/dist/{cli-npssxgaz.js → cli-2pdaysab.js} +52 -2
- package/dist/cli-3qhyh31j.js +166 -0
- package/dist/cli-447dt1h3.js +3828 -0
- package/dist/cli-4derpgyk.js +115 -0
- package/dist/{cli-00w2c66p.js → cli-523679eh.js} +13 -2
- package/dist/{cli-y95wp3tg.js → cli-58e8yr0d.js} +1 -1
- package/dist/{cli-24k806sc.js → cli-5nbmpy8w.js} +3 -3
- package/dist/{cli-53sz8gkz.js → cli-6cs6wzxt.js} +1 -1
- package/dist/cli-741yb0xx.js +1027 -0
- package/dist/cli-74h9hscv.js +69 -0
- package/dist/cli-7cxw8b60.js +14910 -0
- package/dist/{cli-xhaeg2nc.js → cli-7e398j1h.js} +1 -1
- package/dist/cli-7kyk9jr3.js +22 -0
- package/dist/cli-89s4ngw3.js +183 -0
- package/dist/{cli-9b13ggd1.js → cli-89v6kyq7.js} +1 -0
- package/dist/{cli-ftfvggzx.js → cli-9hsgwz4w.js} +1045 -581
- package/dist/{cli-rqz8qbw7.js → cli-a8dvhzrt.js} +59 -20
- package/dist/{cli-j57qkrpq.js → cli-azhgzetg.js} +395 -56
- package/dist/cli-br0qdrnp.js +2150 -0
- package/dist/{cli-rj19hc34.js → cli-btfv8y88.js} +1 -1
- package/dist/{cli-8qmme6vd.js → cli-c8a36vcc.js} +2 -2
- package/dist/cli-cpvsaqsw.js +333 -0
- package/dist/cli-d5czme6m.js +17805 -0
- package/dist/{cli-h38x0qhg.js → cli-et8m9xsv.js} +4 -3
- package/dist/{cli-x24pshtq.js → cli-evvtk35y.js} +6 -6
- package/dist/{cli-7s3syk22.js → cli-f8gy6r2r.js} +5 -5
- package/dist/{cli-zt1227k1.js → cli-fkqhbg8g.js} +5 -3
- package/dist/{cli-9httdpyq.js → cli-g2whhdrf.js} +1 -1
- package/dist/cli-gt4hxb8p.js +99 -0
- package/dist/{cli-s8eet254.js → cli-jajnsm8q.js} +37184 -53838
- package/dist/{cli-7gtvvpbh.js → cli-jayjpjmb.js} +21 -12
- package/dist/{cli-68w09sjw.js → cli-jyk0ynw2.js} +27 -89
- package/dist/{cli-aehm1rbq.js → cli-jz4w45qt.js} +1152 -61
- package/dist/cli-kmcpfwn2.js +333856 -0
- package/dist/{cli-4198qc9v.js → cli-ktmyrtpn.js} +19 -3
- package/dist/{cli-j55n64b6.js → cli-mfe5btp9.js} +505 -189
- package/dist/{cli-q67y4wzm.js → cli-phsaj4xq.js} +24 -2
- package/dist/{cli-1hkrch3k.js → cli-pm1rst0h.js} +46 -7
- package/dist/{cli-pw9rj5t9.js → cli-pqetb83f.js} +1 -176
- package/dist/{cli-ggm92wcn.js → cli-ptr8h7kp.js} +20 -1
- package/dist/{cli-s8s499xy.js → cli-qbksc292.js} +3 -2
- package/dist/{cli-47m6dkd3.js → cli-qydf22qq.js} +597 -346
- package/dist/{cli-3gmcwfyx.js → cli-r1mxd1xh.js} +13 -6
- package/dist/cli-rb9m6rpe.js +4980 -0
- package/dist/cli-rykfmgwg.js +102 -0
- package/dist/{cli-5d10vd2m.js → cli-shkxm1vn.js} +6 -5
- package/dist/{cli-eetrvv91.js → cli-t3p77qk1.js} +1 -1
- package/dist/cli-tfky2838.js +756 -0
- package/dist/{cli-g8djp6qe.js → cli-tmqt7dpj.js} +40 -0
- package/dist/{cli-fgqxwrpv.js → cli-tpq83z89.js} +1631 -127
- package/dist/cli-trc24wk2.js +143 -0
- package/dist/{cli-aky8tctm.js → cli-tzx2ke1v.js} +3 -3
- package/dist/cli-v7fn5gms.js +1425 -0
- package/dist/{cli-wscdvcqz.js → cli-vctdqs5h.js} +1 -1
- package/dist/{cli-cw9zck8j.js → cli-xjcywfsf.js} +8 -4
- package/dist/{cli-k0g1sjzm.js → cli-ybgv4kw2.js} +18 -11
- package/dist/{cli-rjehvrts.js → cli-ydmcgve1.js} +8 -8
- package/dist/{cli-vhjwh6cz.js → cli-ygwm91nt.js} +1 -1
- package/dist/{cli-mcnhgnn1.js → cli-ykk5jaax.js} +184 -26
- package/dist/{cli-de1396j2.js → cli-ywybs5as.js} +7 -1
- package/dist/cli-zpep9q5e.js +491 -0
- package/dist/cli.js +41 -32
- package/dist/cloudflare-workers-ai-system-one-k6fbxw9d.js +46 -0
- package/dist/{codex-adapter-cnm8wk11.js → codex-adapter-nmxcatww.js} +26 -17
- package/dist/{codex-hook-9hptmdhj.js → codex-hook-20me6byw.js} +2 -2
- package/dist/{codex-login-x3jk4etn.js → codex-login-w6fz4xbz.js} +50 -5
- package/dist/{codex-session-runner-gfg547zj.js → codex-session-runner-90aa80ev.js} +24 -17
- package/dist/{commands-e3bn0p75.js → commands-8wcq1kn7.js} +11 -9
- package/dist/{db-03v9kzr2.js → db-j40kc4se.js} +25 -11
- package/dist/{devin-adapter-8vgkwh29.js → devin-adapter-dpsv6hd9.js} +1 -1
- package/dist/{dispatcher-nrmg8yht.js → dispatcher-4zqy768d.js} +34 -29
- package/dist/{dsh-adapter-k03nfqa6.js → dsh-adapter-mpnzgztj.js} +3 -3
- package/dist/{e2b-93x1k0j5.js → e2b-ez07znam.js} +4 -3
- package/dist/execute-6e7qeyk4.js +1017 -0
- package/dist/{google-generative-ai-bxmv50nc.js → google-generative-ai-k6n5nbpp.js} +6 -5
- package/dist/{google-vertex-809af514.js → google-vertex-44xxtcvp.js} +6 -5
- package/dist/{handlers-aqcedbyb.js → handlers-kjdce1w5.js} +37 -32
- package/dist/{hook-ybvmrmhq.js → hook-czx13n12.js} +19 -15
- package/dist/{hook-7vkskkre.js → hook-r2t4bqfg.js} +18 -14
- package/dist/{http-2eqa8t24.js → http-3bbb19be.js} +900 -145
- package/dist/{index-f6cryxwe.js → index-4a5njnm1.js} +2 -59
- package/dist/{index-x71bvq0p.js → index-668me3f0.js} +35 -30
- package/dist/{index-c6zsv1bd.js → index-7aj368tw.js} +13 -12
- package/dist/{index-1yks3qcr.js → index-fg0dsp6c.js} +34 -29
- package/dist/{index-chgdkq36.js → index-kkv84jq9.js} +34 -29
- package/dist/{index-a3vn96n8.js → index-zg7vp46x.js} +198 -54
- package/dist/{keepalive-vtkf5n99.js → keepalive-yra8dy57.js} +13 -11
- package/dist/{lead-h3sp357x.js → lead-va0pad2c.js} +54 -49
- package/dist/llama-cpp-classify-tgj35k8d.js +335 -0
- package/dist/{maintenance-jzeqtk3q.js → maintenance-hqewtmyg.js} +14 -13
- package/dist/{mistral-conversations-zx0kn554.js → mistral-conversations-pc3ntnxt.js} +14 -17
- package/dist/{oauth-refresh-sweep-qp3dzmdp.js → oauth-refresh-sweep-7rdt1m9n.js} +12 -10
- package/dist/{onboard-tmsp0qbz.js → onboard-j6ms6d0x.js} +6 -5
- package/dist/{openai-codex-responses-4vjqzvjp.js → openai-codex-responses-bbancrr0.js} +21 -8
- package/dist/{openai-completions-9hjrqbw8.js → openai-completions-jpaj5g2b.js} +9 -12
- package/dist/{openai-responses-7b1pn0xt.js → openai-responses-200k1wx4.js} +23 -18
- package/dist/{opencode-adapter-x6x2da1z.js → opencode-adapter-89rabkw2.js} +8 -7
- package/dist/{openrouter-images-9f9ek4rw.js → openrouter-images-8yx3487g.js} +5 -7
- package/dist/{otel-impl-9mz73q65.js → otel-impl-a792rjz0.js} +1 -1
- package/dist/{pi-messages-txpjj39q.js → pi-messages-vxdt8v7j.js} +2 -1
- package/dist/{pi-mono-adapter-m6dvv0dz.js → pi-mono-adapter-g7qzvr3v.js} +295 -70
- package/dist/pricing-refresh-wx0tp7cb.js +39 -0
- package/dist/quickjs-r1pq2107.wasm +0 -0
- package/dist/{rbac-roles-c9wqz83x.js → rbac-roles-8tzawacv.js} +12 -10
- package/dist/{render-v2-gryrh9h8.js → render-v2-mm7zswb8.js} +12 -10
- package/dist/runtime-zyssgse0.js +24 -0
- package/dist/{setup-q9720bt6.js → setup-8y70ys6t.js} +6 -5
- package/dist/typesafe-system-one-2ef30pec.js +27 -0
- package/dist/{virtual-modules-3htpgn8x.js → virtual-modules-6nmk7h3n.js} +22 -13
- package/dist/{work-objects-b76x7deb.js → work-objects-fg6xkb0n.js} +37 -32
- package/dist/{worker-6vrxbv41.js → worker-wmwhxsph.js} +54 -49
- package/openapi.json +1314 -91
- package/package.json +12 -11
- package/src/be/db/agents.ts +20 -0
- package/src/be/db/api-keys.ts +70 -0
- package/src/be/db/tasks/human-free.ts +442 -0
- package/src/be/db/tasks/read.ts +56 -1
- package/src/be/db/tasks/write.ts +107 -11
- package/src/be/db.ts +274 -188
- package/src/be/harness-model-support.ts +182 -0
- package/src/be/human-free-drain.ts +67 -0
- package/src/be/memory/providers/sqlite-store.ts +51 -15
- package/src/be/migrations/182_task_human_free_flag.sql +63 -0
- package/src/be/migrations/183_human_free_reclassify_queue.sql +25 -0
- package/src/be/migrations/184_model_catalog.sql +120 -0
- package/src/be/migrations/185_api_key_auth_failures.sql +6 -0
- package/src/be/migrations/186_api_key_seat_mismatch.sql +8 -0
- package/src/be/model-catalog-store.ts +644 -0
- package/src/be/model-tier-keys.ts +46 -0
- package/src/be/model-tier-resolution.ts +534 -0
- package/src/be/model-validation.ts +188 -0
- package/src/be/models-catalog.ts +61 -7
- package/src/be/modelsdev-cache.json +82 -0
- package/src/be/modelsdev-cache.ts +2 -0
- package/src/be/pricing-refresh.ts +154 -12
- package/src/be/scripts/typecheck.ts +15 -0
- package/src/be/seed/runner.ts +18 -12
- package/src/be/seed/types.ts +1 -0
- package/src/be/seed-scripts/catalog/task-failure-audit.ts +61 -9
- package/src/be/swarm-config-guard.ts +8 -0
- package/src/cli.tsx +10 -0
- package/src/commands/claude-managed-setup.ts +3 -1
- package/src/commands/codex-login.ts +67 -0
- package/src/commands/credential-outcome-report.ts +191 -0
- package/src/commands/rate-limit-outcome.ts +34 -4
- package/src/commands/runner.ts +357 -186
- package/src/commands/seat-mismatch-report.ts +46 -0
- package/src/extensions/apply-task-create.ts +27 -1
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/heartbeat/heartbeat.ts +79 -17
- package/src/heartbeat/templates.ts +2 -2
- package/src/http/agents.ts +62 -1
- package/src/http/api-keys.ts +140 -2
- package/src/http/codex-oauth-keep-warm.ts +3 -5
- package/src/http/index.ts +8 -0
- package/src/http/memory.ts +12 -5
- package/src/http/models-catalog.ts +357 -8
- package/src/http/poll.ts +54 -3
- package/src/http/schedules.ts +51 -6
- package/src/http/script-runs.ts +12 -0
- package/src/http/session-data.ts +2 -5
- package/src/http/stats.ts +6 -8
- package/src/http/status.ts +15 -1
- package/src/http/tasks.ts +90 -7
- package/src/http/usage-cache.ts +56 -15
- package/src/http/workflows.ts +46 -8
- package/src/mcp-client/http-client.ts +5 -0
- package/src/memory/recall-query.ts +74 -0
- package/src/prompts/base-prompt.ts +15 -4
- package/src/prompts/session-templates.ts +23 -1
- package/src/providers/acp-adapter.ts +1 -0
- package/src/providers/claude-adapter.ts +14 -5
- package/src/providers/claude-managed-adapter.ts +1 -0
- package/src/providers/claude-managed-models.ts +47 -161
- package/src/providers/claude-sdk-session.ts +3 -1
- package/src/providers/codex-adapter.ts +14 -14
- package/src/providers/codex-models.ts +65 -198
- package/src/providers/devin-adapter.ts +1 -0
- package/src/providers/dsh-adapter.ts +2 -1
- package/src/providers/harness-version.ts +83 -7
- package/src/providers/opencode-adapter.ts +53 -1
- package/src/providers/pi-binary-root/src/extensions/codemode/worker.ts +11 -0
- package/src/providers/pi-codemode-runtime.ts +17 -0
- package/src/providers/pi-mono-adapter.ts +361 -83
- package/src/providers/pi-mono-extension.ts +16 -1
- package/src/providers/reasoning-effort.ts +44 -140
- package/src/providers/types.ts +8 -0
- package/src/rbac/legacy-policy.ts +43 -0
- package/src/rbac/permissions.ts +15 -0
- package/src/scripts-runtime/sdk-allowlist.ts +4 -0
- package/src/scripts-runtime/types/stdlib.d.ts +15 -0
- package/src/scripts-runtime/types/swarm-extension.d.ts +3 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +15 -0
- package/src/server.ts +6 -0
- package/src/slack/assistant.ts +13 -0
- package/src/slack/message-text.ts +56 -2
- package/src/slack/render-v2.ts +87 -37
- package/src/slack/session-status.ts +541 -0
- package/src/slack/thread-buffer.ts +10 -2
- package/src/tasks/sibling-awareness.ts +3 -2
- package/src/telemetry.ts +5 -4
- package/src/templates.d.ts +6 -0
- package/src/tests/agents-list-model-display.test.ts +4 -6
- package/src/tests/api-key-auth-failure-route.test.ts +142 -0
- package/src/tests/api-key-tracking.test.ts +368 -1
- package/src/tests/base-prompt.test.ts +43 -2
- package/src/tests/claude-adapter.test.ts +68 -0
- package/src/tests/claude-managed-adapter.test.ts +12 -18
- package/src/tests/codex-adapter.test.ts +2 -1
- package/src/tests/codex-auth-failure.test.ts +52 -0
- package/src/tests/codex-gpt6-release.test.ts +66 -5
- package/src/tests/codex-login.test.ts +116 -0
- package/src/tests/context-window.test.ts +7 -5
- package/src/tests/credential-exhaustion-policy.test.ts +118 -3
- package/src/tests/credential-outcome-report.test.ts +171 -0
- package/src/tests/credential-status-api.test.ts +103 -2
- package/src/tests/db-extraction-contract.test.ts +1 -0
- package/src/tests/db-task-read-contract.test.ts +10 -1
- package/src/tests/db-task-write-contract.test.ts +535 -2
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/dokploy-deploy.test.ts +315 -0
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/explicit-model-validation.test.ts +583 -0
- package/src/tests/extensions-pre-task.test.ts +73 -0
- package/src/tests/fetch-resolved-env.test.ts +46 -0
- package/src/tests/hang-watchdog-worker.ts +47 -0
- package/src/tests/hang-watchdog.test.ts +45 -0
- package/src/tests/hang-watchdog.ts +30 -0
- package/src/tests/harness-model-guard.test.ts +123 -0
- package/src/tests/harness-model-support.test.ts +374 -0
- package/src/tests/harness-version.test.ts +70 -3
- package/src/tests/heartbeat-checklist-config.test.ts +71 -0
- package/src/tests/heartbeat-checklist.test.ts +4 -2
- package/src/tests/heartbeat-orphan-resume.test.ts +48 -0
- package/src/tests/http-task-write-ownership.test.ts +172 -0
- package/src/tests/human-free-flag.test.ts +279 -0
- package/src/tests/human-free-oracle.ts +57 -0
- package/src/tests/human-free-reclassify.test.ts +669 -0
- package/src/tests/memory-fts-populate.test.ts +139 -0
- package/src/tests/memory-http-recall-gating.test.ts +125 -1
- package/src/tests/migration-046-budgets.test.ts +3 -3
- package/src/tests/model-catalog-migration.test.ts +134 -0
- package/src/tests/model-catalog-table.test.ts +249 -0
- package/src/tests/model-catalog-write-access.test.ts +387 -0
- package/src/tests/model-rate-limit-windows.test.ts +19 -0
- package/src/tests/model-tier-resolution.test.ts +611 -0
- package/src/tests/models-catalog.test.ts +1 -1
- package/src/tests/multi-runtime-enabled-stats.test.ts +65 -1
- package/src/tests/opencode-adapter.test.ts +157 -2
- package/src/tests/package-publish.test.ts +137 -36
- package/src/tests/pi-codemode.test.ts +246 -0
- package/src/tests/pi-mono-adapter.test.ts +3 -0
- package/src/tests/pi-native-mcp.test.ts +193 -0
- package/src/tests/pi-tool-exposure.test.ts +374 -0
- package/src/tests/preload.ts +3 -0
- package/src/tests/pricing-routes.test.ts +2 -2
- package/src/tests/prompt-template-session.test.ts +5 -3
- package/src/tests/rate-limit-event.test.ts +65 -0
- package/src/tests/rate-limit-outcome.test.ts +90 -0
- package/src/tests/rbac-engine.test.ts +77 -3
- package/src/tests/reasoning-effort.test.ts +109 -0
- package/src/tests/refresh-modelsdev-carryforward.test.ts +5 -5
- package/src/tests/runner-key-completion-outcome.test.ts +112 -0
- package/src/tests/runner-key-outcome-late-reset.test.ts +224 -0
- package/src/tests/runner-registration-retry.test.ts +149 -0
- package/src/tests/runtime-model-catalog.test.ts +86 -0
- package/src/tests/script-connections.test.ts +9 -0
- package/src/tests/seat-mismatch-report.test.ts +85 -0
- package/src/tests/seed-scripts.test.ts +138 -0
- package/src/tests/seed.test.ts +25 -0
- package/src/tests/session-costs.test.ts +14 -11
- package/src/tests/slack-message-text.test.ts +101 -0
- package/src/tests/slack-render-v2.test.ts +96 -0
- package/src/tests/slack-session-status.test.ts +626 -0
- package/src/tests/slack-thread-buffer-context.test.ts +93 -0
- package/src/tests/status.test.ts +29 -0
- package/src/tests/steering-promotion.test.ts +51 -0
- package/src/tests/store-progress-ownership.test.ts +136 -0
- package/src/tests/subscription-plans.test.ts +28 -0
- package/src/tests/task-cascade-fail.test.ts +148 -2
- package/src/tests/task-citations.test.ts +3 -2
- package/src/tests/tool-annotations.test.ts +1 -1
- package/src/tests/usage-cache.test.ts +166 -0
- package/src/tests/workflow-agent-task.test.ts +30 -0
- package/src/tests/workflow-executors.test.ts +5 -2
- package/src/tests/workflow-system-one-decision-review.test.ts +1021 -0
- package/src/tests/workflow-system-one-decision-save-warnings.test.ts +365 -0
- package/src/tests/workflow-system-one-decision.test.ts +2063 -0
- package/src/tests/workflow-triggers-v2.test.ts +320 -0
- package/src/tools/model-catalog/index.ts +137 -0
- package/src/tools/schedules/create-schedule.ts +17 -2
- package/src/tools/schedules/patch-schedule.ts +31 -1
- package/src/tools/schedules/update-schedule.ts +31 -1
- package/src/tools/send-task.ts +18 -1
- package/src/tools/store-progress.ts +49 -4
- package/src/tools/task-action.ts +14 -1
- package/src/tools/tool-config.ts +3 -1
- package/src/tools/workflows/create-workflow.ts +17 -4
- package/src/tools/workflows/patch-workflow-node.ts +17 -7
- package/src/tools/workflows/patch-workflow.ts +9 -2
- package/src/tools/workflows/update-workflow.ts +17 -4
- package/src/types.ts +41 -1
- package/src/utils/codex-auth-failure.ts +34 -0
- package/src/utils/context-window.ts +47 -53
- package/src/utils/credentials.ts +72 -30
- package/src/utils/error-tracker.ts +80 -0
- package/src/utils/harness-cli-version.ts +115 -0
- package/src/utils/harness-model-error.ts +33 -0
- package/src/utils/model-rate-limit-windows.ts +12 -0
- package/src/utils/runtime-model-catalog.ts +152 -0
- package/src/utils/spawn-model-guard.ts +43 -0
- package/src/utils/subscription-plans.ts +22 -0
- package/src/workflows/approval-resolution.ts +39 -0
- package/src/workflows/definition.ts +7 -0
- package/src/workflows/engine.ts +69 -1
- package/src/workflows/executors/agent-task.ts +16 -6
- package/src/workflows/executors/base.ts +53 -0
- package/src/workflows/executors/human-in-the-loop.ts +8 -8
- package/src/workflows/executors/index.ts +1 -0
- package/src/workflows/executors/registry.ts +2 -0
- package/src/workflows/executors/system-one-decision.ts +1232 -0
- package/src/workflows/executors/system-one-providers.ts +301 -0
- package/src/workflows/executors/workflow-llm.ts +13 -1
- package/src/workflows/model-validation.ts +45 -0
- package/src/workflows/patch-definition.ts +5 -0
- package/src/workflows/readiness.ts +86 -0
- package/src/workflows/recovery.ts +12 -12
- package/src/workflows/resume.ts +23 -9
- package/src/workflows/triggers.ts +85 -0
- package/templates/schedules/daily-blocker-digest/content.md +4 -5
- package/templates/skills/agent-browser/SKILL.md +6 -5
- package/templates/skills/agent-browser/content.md +6 -5
- package/templates/skills/heartbeat-runbook/config.json +1 -1
- package/templates/skills/heartbeat-runbook/content.md +2 -2
- package/templates/skills/swarm-scripts/SKILL.md +1 -1
- package/templates/skills/swarm-scripts/content.md +1 -1
- package/templates/skills/workflow-iterate/content.md +82 -1
- package/templates/workflows/claude-code-changelog-watch/content.md +2 -0
- package/templates/workflows/pr-review-status-sweep/content.md +2 -0
- package/dist/boot-seeds-s3q01xj3.js +0 -26
- package/dist/claude-sdk-session-t442qz6f.js +0 -39108
- package/dist/cli-0xjkj1j7.js +0 -61
- package/dist/cli-20cj37vt.js +0 -335561
- package/dist/cli-2djtr51b.js +0 -48
- package/dist/cli-65hjmev5.js +0 -1141
- package/dist/cli-aw1jwp1r.js +0 -14075
- package/dist/cli-h967nb6r.js +0 -6603
- package/dist/cli-vapyk8sw.js +0 -20
- package/dist/cli-ws6rqycm.js +0 -247
- package/dist/pricing-refresh-v1cbr9te.js +0 -27
- package/src/providers/modelsdev-reasoning.json +0 -6453
- package/dist/{index-f24115ge.js → index-2wsdsnmm.js} +3 -3
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_proper_lockfile
|
|
3
|
+
} from "./cli-447dt1h3.js";
|
|
4
|
+
import {
|
|
5
|
+
CONFIG_DIR_NAME,
|
|
6
|
+
canonicalizePath,
|
|
7
|
+
resolvePath,
|
|
8
|
+
stripBom
|
|
9
|
+
} from "./cli-d5czme6m.js";
|
|
10
|
+
import {
|
|
11
|
+
__toESM
|
|
12
|
+
} from "./cli-bc05qbss.js";
|
|
13
|
+
|
|
14
|
+
// node_modules/@earendil-works/pi-coding-agent/dist/core/mcp-servers.js
|
|
15
|
+
var MCP_EXPOSURES = ["codemode", "deferred", "direct", "hidden"];
|
|
16
|
+
var MCP_EXPOSURE_ALIASES = { "codemode-deferred": "codemode" };
|
|
17
|
+
var LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "[::1]"];
|
|
18
|
+
function isLoopbackRedirectUri(value) {
|
|
19
|
+
if (!URL.canParse(value))
|
|
20
|
+
return false;
|
|
21
|
+
const url = new URL(value);
|
|
22
|
+
return url.protocol === "http:" && LOOPBACK_HOSTS.includes(url.hostname) && url.search === "" && url.hash === "";
|
|
23
|
+
}
|
|
24
|
+
var SERVER_NAME = /^[A-Za-z0-9_-]+$/;
|
|
25
|
+
function mcpNamespace(server) {
|
|
26
|
+
return `mcp__${server.replace(/-/g, "_")}`;
|
|
27
|
+
}
|
|
28
|
+
function isRecord(value) {
|
|
29
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30
|
+
}
|
|
31
|
+
function isStringRecord(value) {
|
|
32
|
+
return isRecord(value) && Object.values(value).every((entry) => typeof entry === "string");
|
|
33
|
+
}
|
|
34
|
+
function validateOAuth(value) {
|
|
35
|
+
if (value === undefined)
|
|
36
|
+
return;
|
|
37
|
+
if (!isRecord(value))
|
|
38
|
+
return "oauth must be an object";
|
|
39
|
+
if (value.clientId !== undefined && typeof value.clientId !== "string")
|
|
40
|
+
return "oauth.clientId must be a string";
|
|
41
|
+
if (value.clientSecret !== undefined && typeof value.clientSecret !== "string") {
|
|
42
|
+
return "oauth.clientSecret must be a string";
|
|
43
|
+
}
|
|
44
|
+
const port = value.callbackPort;
|
|
45
|
+
if (port !== undefined && (typeof port !== "number" || !Number.isInteger(port) || port < 1 || port > 65535)) {
|
|
46
|
+
return "oauth.callbackPort must be a port number";
|
|
47
|
+
}
|
|
48
|
+
if (value.callbackUrl !== undefined) {
|
|
49
|
+
if (typeof value.callbackUrl !== "string" || !isLoopbackRedirectUri(value.callbackUrl)) {
|
|
50
|
+
return "oauth.callbackUrl must be an http URI on localhost, 127.0.0.1, or [::1] without query or fragment";
|
|
51
|
+
}
|
|
52
|
+
const urlPort = new URL(value.callbackUrl).port;
|
|
53
|
+
if (urlPort && port !== undefined && Number(urlPort) !== port) {
|
|
54
|
+
return "oauth.callbackUrl and oauth.callbackPort name different ports";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (value.scope !== undefined && typeof value.scope !== "string")
|
|
58
|
+
return "oauth.scope must be a string";
|
|
59
|
+
if (value.clientName !== undefined && (typeof value.clientName !== "string" || !value.clientName.trim())) {
|
|
60
|
+
return "oauth.clientName must be a non-empty string";
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
function isExposure(value) {
|
|
65
|
+
return typeof value === "string" && MCP_EXPOSURES.includes(value);
|
|
66
|
+
}
|
|
67
|
+
function resolveExposureAlias(value) {
|
|
68
|
+
return typeof value === "string" ? MCP_EXPOSURE_ALIASES[value] ?? value : value;
|
|
69
|
+
}
|
|
70
|
+
function resolveExposureAliases(value) {
|
|
71
|
+
const { exposure, toolExposure } = value;
|
|
72
|
+
const resolved = { ...value };
|
|
73
|
+
if (exposure !== undefined)
|
|
74
|
+
resolved.exposure = resolveExposureAlias(exposure);
|
|
75
|
+
if (isRecord(toolExposure)) {
|
|
76
|
+
resolved.toolExposure = Object.fromEntries(Object.entries(toolExposure).map(([tool, entry]) => [tool, resolveExposureAlias(entry)]));
|
|
77
|
+
}
|
|
78
|
+
return resolved;
|
|
79
|
+
}
|
|
80
|
+
function toolPatternRegExp(pattern) {
|
|
81
|
+
const source = pattern.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
82
|
+
return new RegExp(`^${source}$`);
|
|
83
|
+
}
|
|
84
|
+
function getMcpToolExposure(config, toolName) {
|
|
85
|
+
const overrides = config.toolExposure ?? {};
|
|
86
|
+
const exact = overrides[toolName];
|
|
87
|
+
if (exact !== undefined)
|
|
88
|
+
return exact;
|
|
89
|
+
for (const [pattern, exposure] of Object.entries(overrides)) {
|
|
90
|
+
if (pattern.includes("*") && toolPatternRegExp(pattern).test(toolName))
|
|
91
|
+
return exposure;
|
|
92
|
+
}
|
|
93
|
+
return config.exposure ?? "codemode";
|
|
94
|
+
}
|
|
95
|
+
function validateMcpServerConfig(name, raw) {
|
|
96
|
+
if (!SERVER_NAME.test(name))
|
|
97
|
+
return `invalid server name "${name}" (use letters, digits, "_" and "-")`;
|
|
98
|
+
if (!isRecord(raw))
|
|
99
|
+
return `server "${name}" must be an object`;
|
|
100
|
+
const value = resolveExposureAliases(raw);
|
|
101
|
+
const { type, exposure, enabled, timeout, toolExposure, description } = value;
|
|
102
|
+
const exposures = MCP_EXPOSURES.map((value2) => `"${value2}"`).join(", ");
|
|
103
|
+
if (exposure !== undefined && !isExposure(exposure)) {
|
|
104
|
+
return `server "${name}": exposure must be one of ${exposures}`;
|
|
105
|
+
}
|
|
106
|
+
if (toolExposure !== undefined) {
|
|
107
|
+
if (!isRecord(toolExposure))
|
|
108
|
+
return `server "${name}": toolExposure must map tool names to exposures`;
|
|
109
|
+
for (const [tool, value2] of Object.entries(toolExposure)) {
|
|
110
|
+
if (!isExposure(value2))
|
|
111
|
+
return `server "${name}": toolExposure "${tool}" must be one of ${exposures}`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (enabled !== undefined && typeof enabled !== "boolean")
|
|
115
|
+
return `server "${name}": enabled must be a boolean`;
|
|
116
|
+
if (description !== undefined && typeof description !== "string") {
|
|
117
|
+
return `server "${name}": description must be a string`;
|
|
118
|
+
}
|
|
119
|
+
if (timeout !== undefined && (typeof timeout !== "number" || !(timeout > 0))) {
|
|
120
|
+
return `server "${name}": timeout must be a positive number of seconds`;
|
|
121
|
+
}
|
|
122
|
+
if (type === "sse")
|
|
123
|
+
return `server "${name}": legacy SSE transport is not supported; use the streamable HTTP URL`;
|
|
124
|
+
if (typeof value.url === "string" && (type === undefined || type === "http" || type === "streamable-http")) {
|
|
125
|
+
if (!URL.canParse(value.url) || !/^https?:$/.test(new URL(value.url).protocol)) {
|
|
126
|
+
return `server "${name}": url must be an http or https URL`;
|
|
127
|
+
}
|
|
128
|
+
if (value.headers !== undefined && !isStringRecord(value.headers)) {
|
|
129
|
+
return `server "${name}": headers must map names to strings`;
|
|
130
|
+
}
|
|
131
|
+
const oauthError = validateOAuth(value.oauth);
|
|
132
|
+
if (oauthError)
|
|
133
|
+
return `server "${name}": ${oauthError}`;
|
|
134
|
+
if (value.auth !== undefined) {
|
|
135
|
+
if (!isRecord(value.auth) || typeof value.auth.provider !== "string" || !value.auth.provider) {
|
|
136
|
+
return `server "${name}": auth.provider must be a provider name`;
|
|
137
|
+
}
|
|
138
|
+
const url = new URL(value.url);
|
|
139
|
+
if (url.protocol !== "https:" && !LOOPBACK_HOSTS.includes(url.hostname)) {
|
|
140
|
+
return `server "${name}": auth requires an https URL, or http on localhost, 127.0.0.1, or [::1]`;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return value;
|
|
144
|
+
}
|
|
145
|
+
if (typeof value.command === "string" && (type === undefined || type === "stdio")) {
|
|
146
|
+
if (value.args !== undefined && !(Array.isArray(value.args) && value.args.every((arg) => typeof arg === "string"))) {
|
|
147
|
+
return `server "${name}": args must be an array of strings`;
|
|
148
|
+
}
|
|
149
|
+
if (value.env !== undefined && !isStringRecord(value.env))
|
|
150
|
+
return `server "${name}": env must map names to strings`;
|
|
151
|
+
if (value.cwd !== undefined && typeof value.cwd !== "string")
|
|
152
|
+
return `server "${name}": cwd must be a string`;
|
|
153
|
+
return value;
|
|
154
|
+
}
|
|
155
|
+
return `server "${name}" needs either "command" (stdio) or "url" (streamable HTTP)`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
class McpServerRegistry {
|
|
159
|
+
servers = new Map;
|
|
160
|
+
changeListener;
|
|
161
|
+
register(server) {
|
|
162
|
+
this.servers.set(server.name, server);
|
|
163
|
+
this.changeListener?.();
|
|
164
|
+
}
|
|
165
|
+
unregister(name, extensionPath) {
|
|
166
|
+
if (this.servers.get(name)?.extensionPath !== extensionPath)
|
|
167
|
+
return;
|
|
168
|
+
this.servers.delete(name);
|
|
169
|
+
this.changeListener?.();
|
|
170
|
+
}
|
|
171
|
+
get(name) {
|
|
172
|
+
return this.servers.get(name);
|
|
173
|
+
}
|
|
174
|
+
list() {
|
|
175
|
+
return [...this.servers.values()].map((server) => ({ ...server, config: structuredClone(server.config) }));
|
|
176
|
+
}
|
|
177
|
+
setChangeListener(listener) {
|
|
178
|
+
this.changeListener = listener;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// node_modules/@earendil-works/pi-coding-agent/dist/core/trust-manager.js
|
|
183
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
184
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
185
|
+
import { homedir } from "node:os";
|
|
186
|
+
import { dirname, join } from "node:path";
|
|
187
|
+
var TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES = [
|
|
188
|
+
"settings.json",
|
|
189
|
+
"mcp.json",
|
|
190
|
+
"extensions",
|
|
191
|
+
"skills",
|
|
192
|
+
"prompts",
|
|
193
|
+
"themes",
|
|
194
|
+
"SYSTEM.md",
|
|
195
|
+
"APPEND_SYSTEM.md"
|
|
196
|
+
];
|
|
197
|
+
function normalizeCwd(cwd) {
|
|
198
|
+
return canonicalizePath(resolvePath(cwd));
|
|
199
|
+
}
|
|
200
|
+
function findNearestTrustEntry(data, cwd) {
|
|
201
|
+
let currentDir = normalizeCwd(cwd);
|
|
202
|
+
while (true) {
|
|
203
|
+
const value = data[currentDir];
|
|
204
|
+
if (value === true || value === false) {
|
|
205
|
+
return { path: currentDir, decision: value };
|
|
206
|
+
}
|
|
207
|
+
const parentDir = dirname(currentDir);
|
|
208
|
+
if (parentDir === currentDir) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
currentDir = parentDir;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function getProjectTrustParentPath(cwd) {
|
|
215
|
+
const trustPath = normalizeCwd(cwd);
|
|
216
|
+
const parentDir = dirname(trustPath);
|
|
217
|
+
return parentDir === trustPath ? undefined : parentDir;
|
|
218
|
+
}
|
|
219
|
+
function getProjectTrustOptions(cwd, options) {
|
|
220
|
+
const trustPath = normalizeCwd(cwd);
|
|
221
|
+
const trustOptions = [
|
|
222
|
+
{ label: "Trust", trusted: true, updates: [{ path: trustPath, decision: true }], savedPath: trustPath }
|
|
223
|
+
];
|
|
224
|
+
const parentPath = getProjectTrustParentPath(cwd);
|
|
225
|
+
if (parentPath !== undefined) {
|
|
226
|
+
trustOptions.push({
|
|
227
|
+
label: `Trust parent folder (${parentPath})`,
|
|
228
|
+
trusted: true,
|
|
229
|
+
updates: [
|
|
230
|
+
{ path: parentPath, decision: true },
|
|
231
|
+
{ path: trustPath, decision: null }
|
|
232
|
+
],
|
|
233
|
+
savedPath: parentPath
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
if (options?.includeSessionOnly) {
|
|
237
|
+
trustOptions.push({ label: "Trust (this session only)", trusted: true, updates: [] });
|
|
238
|
+
}
|
|
239
|
+
trustOptions.push({
|
|
240
|
+
label: "Do not trust",
|
|
241
|
+
trusted: false,
|
|
242
|
+
updates: [{ path: trustPath, decision: false }],
|
|
243
|
+
savedPath: trustPath
|
|
244
|
+
});
|
|
245
|
+
if (options?.includeSessionOnly) {
|
|
246
|
+
trustOptions.push({ label: "Do not trust (this session only)", trusted: false, updates: [] });
|
|
247
|
+
}
|
|
248
|
+
return trustOptions;
|
|
249
|
+
}
|
|
250
|
+
function readTrustFile(path) {
|
|
251
|
+
if (!existsSync(path)) {
|
|
252
|
+
return {};
|
|
253
|
+
}
|
|
254
|
+
let parsed;
|
|
255
|
+
try {
|
|
256
|
+
parsed = JSON.parse(stripBom(readFileSync(path, "utf-8")));
|
|
257
|
+
} catch (error) {
|
|
258
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
259
|
+
throw new Error(`Failed to read trust store ${path}: ${message}`);
|
|
260
|
+
}
|
|
261
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
262
|
+
throw new Error(`Invalid trust store ${path}: expected an object`);
|
|
263
|
+
}
|
|
264
|
+
const data = {};
|
|
265
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
266
|
+
if (value !== true && value !== false && value !== null) {
|
|
267
|
+
throw new Error(`Invalid trust store ${path}: value for ${JSON.stringify(key)} must be true, false, or null`);
|
|
268
|
+
}
|
|
269
|
+
data[key] = value;
|
|
270
|
+
}
|
|
271
|
+
return data;
|
|
272
|
+
}
|
|
273
|
+
function writeTrustFile(path, data) {
|
|
274
|
+
const sorted = {};
|
|
275
|
+
for (const key of Object.keys(data).sort()) {
|
|
276
|
+
const value = data[key];
|
|
277
|
+
if (value === true || value === false || value === null) {
|
|
278
|
+
sorted[key] = value;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
282
|
+
writeFileSync(path, `${JSON.stringify(sorted, null, 2)}
|
|
283
|
+
`, "utf-8");
|
|
284
|
+
}
|
|
285
|
+
function acquireTrustLockSync(path) {
|
|
286
|
+
const trustDir = dirname(path);
|
|
287
|
+
mkdirSync(trustDir, { recursive: true });
|
|
288
|
+
const maxAttempts = 10;
|
|
289
|
+
const delayMs = 20;
|
|
290
|
+
let lastError;
|
|
291
|
+
for (let attempt = 1;attempt <= maxAttempts; attempt++) {
|
|
292
|
+
try {
|
|
293
|
+
return import_proper_lockfile.default.lockSync(trustDir, { realpath: false, lockfilePath: `${path}.lock` });
|
|
294
|
+
} catch (error) {
|
|
295
|
+
const code = typeof error === "object" && error !== null && "code" in error ? String(error.code) : undefined;
|
|
296
|
+
if (code !== "ELOCKED" || attempt === maxAttempts) {
|
|
297
|
+
throw error;
|
|
298
|
+
}
|
|
299
|
+
lastError = error;
|
|
300
|
+
const start = Date.now();
|
|
301
|
+
while (Date.now() - start < delayMs) {}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (lastError instanceof Error) {
|
|
305
|
+
throw lastError;
|
|
306
|
+
}
|
|
307
|
+
throw new Error("Failed to acquire trust store lock");
|
|
308
|
+
}
|
|
309
|
+
function withTrustFileLock(path, fn) {
|
|
310
|
+
const release = acquireTrustLockSync(path);
|
|
311
|
+
try {
|
|
312
|
+
return fn();
|
|
313
|
+
} finally {
|
|
314
|
+
release();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function hasTrustRequiringProjectResources(cwd) {
|
|
318
|
+
const homeDir = canonicalizePath(resolvePath(process.env.HOME || homedir()));
|
|
319
|
+
const userAgentsSkillsDir = join(homeDir, ".agents", "skills");
|
|
320
|
+
let currentDir = canonicalizePath(resolvePath(cwd));
|
|
321
|
+
const configDir = join(currentDir, CONFIG_DIR_NAME);
|
|
322
|
+
if (TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES.some((entry) => existsSync(join(configDir, entry)))) {
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
while (true) {
|
|
326
|
+
const agentsSkillsDir = join(currentDir, ".agents", "skills");
|
|
327
|
+
if (agentsSkillsDir !== userAgentsSkillsDir && existsSync(agentsSkillsDir)) {
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
const parentDir = dirname(currentDir);
|
|
331
|
+
if (parentDir === currentDir) {
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
currentDir = parentDir;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
class ProjectTrustStore {
|
|
339
|
+
trustPath;
|
|
340
|
+
constructor(agentDir) {
|
|
341
|
+
this.trustPath = join(resolvePath(agentDir), "trust.json");
|
|
342
|
+
}
|
|
343
|
+
get(cwd) {
|
|
344
|
+
return this.getEntry(cwd)?.decision ?? null;
|
|
345
|
+
}
|
|
346
|
+
getEntry(cwd) {
|
|
347
|
+
return withTrustFileLock(this.trustPath, () => {
|
|
348
|
+
const data = readTrustFile(this.trustPath);
|
|
349
|
+
return findNearestTrustEntry(data, cwd);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
set(cwd, decision) {
|
|
353
|
+
this.setMany([{ path: cwd, decision }]);
|
|
354
|
+
}
|
|
355
|
+
setMany(decisions) {
|
|
356
|
+
withTrustFileLock(this.trustPath, () => {
|
|
357
|
+
const data = readTrustFile(this.trustPath);
|
|
358
|
+
for (const { path, decision } of decisions) {
|
|
359
|
+
const key = normalizeCwd(path);
|
|
360
|
+
if (decision === null) {
|
|
361
|
+
delete data[key];
|
|
362
|
+
} else {
|
|
363
|
+
data[key] = decision;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
writeTrustFile(this.trustPath, data);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// node_modules/@earendil-works/pi-coding-agent/dist/utils/open-browser.js
|
|
372
|
+
import { spawn } from "node:child_process";
|
|
373
|
+
function openBrowser(target) {
|
|
374
|
+
const [cmd, args] = process.platform === "darwin" ? ["open", [target]] : process.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", target]] : ["xdg-open", [target]];
|
|
375
|
+
spawn(cmd, args, { stdio: "ignore", detached: true }).on("error", () => {}).unref();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/config.js
|
|
379
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
380
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
381
|
+
function isRecord2(value) {
|
|
382
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
383
|
+
}
|
|
384
|
+
function readConfigFile(path, scope, state) {
|
|
385
|
+
const { servers, errors } = state;
|
|
386
|
+
if (!existsSync2(path))
|
|
387
|
+
return;
|
|
388
|
+
let parsed;
|
|
389
|
+
try {
|
|
390
|
+
parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
391
|
+
} catch (error) {
|
|
392
|
+
errors.push(`${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (!isRecord2(parsed) || parsed.mcpServers !== undefined && !isRecord2(parsed.mcpServers)) {
|
|
396
|
+
errors.push(`${path}: expected an object with an "mcpServers" object`);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
if (typeof parsed.autoEnableCodemode === "boolean")
|
|
400
|
+
state.autoEnableCodemode = parsed.autoEnableCodemode;
|
|
401
|
+
else if (parsed.autoEnableCodemode !== undefined)
|
|
402
|
+
errors.push(`${path}: autoEnableCodemode must be a boolean`);
|
|
403
|
+
for (const [name, value] of Object.entries(parsed.mcpServers ?? {})) {
|
|
404
|
+
const config = validateMcpServerConfig(name, value);
|
|
405
|
+
if (typeof config === "string") {
|
|
406
|
+
errors.push(`${path}: ${config}`);
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
const clash = [...servers.keys()].find((other) => other !== name && mcpNamespace(other) === mcpNamespace(name));
|
|
410
|
+
if (clash) {
|
|
411
|
+
errors.push(`${path}: server "${name}" conflicts with "${clash}"`);
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
if (scope === "project" && "url" in config && config.auth) {
|
|
415
|
+
errors.push(`${path}: server "${name}": auth is only allowed in the global mcp.json`);
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
servers.set(name, { name, config, source: path, scope });
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function loadMcpConfig(options) {
|
|
422
|
+
const state = { servers: new Map, errors: [] };
|
|
423
|
+
readConfigFile(join2(options.agentDir, "mcp.json"), "global", state);
|
|
424
|
+
if (options.projectTrusted)
|
|
425
|
+
readConfigFile(join2(options.cwd, CONFIG_DIR_NAME, "mcp.json"), "project", state);
|
|
426
|
+
return {
|
|
427
|
+
servers: [...state.servers.values()],
|
|
428
|
+
...state.autoEnableCodemode === undefined ? {} : { autoEnableCodemode: state.autoEnableCodemode },
|
|
429
|
+
errors: state.errors
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function updateMcpServerConfig(path, name, patch) {
|
|
433
|
+
editMcpServers(path, (servers) => {
|
|
434
|
+
const server = servers?.[name];
|
|
435
|
+
if (!isRecord2(server))
|
|
436
|
+
throw new Error(`${path} does not define MCP server "${name}"`);
|
|
437
|
+
if (patch.enabled !== undefined) {
|
|
438
|
+
if (patch.enabled)
|
|
439
|
+
delete server.enabled;
|
|
440
|
+
else
|
|
441
|
+
server.enabled = false;
|
|
442
|
+
}
|
|
443
|
+
if (patch.exposure !== undefined) {
|
|
444
|
+
if (patch.exposure === "codemode")
|
|
445
|
+
delete server.exposure;
|
|
446
|
+
else
|
|
447
|
+
server.exposure = patch.exposure;
|
|
448
|
+
}
|
|
449
|
+
return true;
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
function addMcpServerConfig(path, name, config) {
|
|
453
|
+
let replaced = false;
|
|
454
|
+
editMcpServers(path, (servers, parsed) => {
|
|
455
|
+
const target = servers ?? {};
|
|
456
|
+
replaced = target[name] !== undefined;
|
|
457
|
+
target[name] = config;
|
|
458
|
+
parsed.mcpServers = target;
|
|
459
|
+
return true;
|
|
460
|
+
});
|
|
461
|
+
return replaced;
|
|
462
|
+
}
|
|
463
|
+
function removeMcpServerConfig(path, name) {
|
|
464
|
+
if (!existsSync2(path))
|
|
465
|
+
return false;
|
|
466
|
+
let removed = false;
|
|
467
|
+
editMcpServers(path, (servers) => {
|
|
468
|
+
if (!servers || servers[name] === undefined)
|
|
469
|
+
return false;
|
|
470
|
+
delete servers[name];
|
|
471
|
+
removed = true;
|
|
472
|
+
return true;
|
|
473
|
+
});
|
|
474
|
+
return removed;
|
|
475
|
+
}
|
|
476
|
+
function editMcpServers(path, edit) {
|
|
477
|
+
const text = existsSync2(path) ? readFileSync2(path, "utf8") : undefined;
|
|
478
|
+
const parsed = text === undefined ? {} : JSON.parse(text);
|
|
479
|
+
if (!isRecord2(parsed) || parsed.mcpServers !== undefined && !isRecord2(parsed.mcpServers)) {
|
|
480
|
+
throw new Error(`${path}: expected an object with an "mcpServers" object`);
|
|
481
|
+
}
|
|
482
|
+
const servers = isRecord2(parsed.mcpServers) ? parsed.mcpServers : undefined;
|
|
483
|
+
if (!edit(servers, parsed))
|
|
484
|
+
return;
|
|
485
|
+
const indent = text && /^([ \t]+)\S/m.exec(text)?.[1] || " ";
|
|
486
|
+
mkdirSync2(dirname2(path), { recursive: true });
|
|
487
|
+
writeFileSync2(path, `${JSON.stringify(parsed, null, indent)}
|
|
488
|
+
`);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export { mcpNamespace, getMcpToolExposure, validateMcpServerConfig, McpServerRegistry, getProjectTrustOptions, hasTrustRequiringProjectResources, ProjectTrustStore, openBrowser, loadMcpConfig, updateMcpServerConfig, addMcpServerConfig, removeMcpServerConfig };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__require
|
|
4
|
+
} from "./cli-bc05qbss.js";
|
|
5
|
+
|
|
6
|
+
// node_modules/signal-exit/signals.js
|
|
7
|
+
var require_signals = __commonJS(function(exports, module) {
|
|
8
|
+
module.exports = [
|
|
9
|
+
"SIGABRT",
|
|
10
|
+
"SIGALRM",
|
|
11
|
+
"SIGHUP",
|
|
12
|
+
"SIGINT",
|
|
13
|
+
"SIGTERM"
|
|
14
|
+
];
|
|
15
|
+
if (process.platform !== "win32") {
|
|
16
|
+
module.exports.push("SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
17
|
+
}
|
|
18
|
+
if (process.platform === "linux") {
|
|
19
|
+
module.exports.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT", "SIGUNUSED");
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// node_modules/signal-exit/index.js
|
|
24
|
+
var require_signal_exit = __commonJS(function(exports, module) {
|
|
25
|
+
var process2 = global.process;
|
|
26
|
+
var processOk = function(process3) {
|
|
27
|
+
return process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
|
|
28
|
+
};
|
|
29
|
+
if (!processOk(process2)) {
|
|
30
|
+
module.exports = function() {
|
|
31
|
+
return function() {};
|
|
32
|
+
};
|
|
33
|
+
} else {
|
|
34
|
+
assert = __require("assert");
|
|
35
|
+
signals = require_signals();
|
|
36
|
+
isWin = /^win/i.test(process2.platform);
|
|
37
|
+
EE = __require("events");
|
|
38
|
+
if (typeof EE !== "function") {
|
|
39
|
+
EE = EE.EventEmitter;
|
|
40
|
+
}
|
|
41
|
+
if (process2.__signal_exit_emitter__) {
|
|
42
|
+
emitter = process2.__signal_exit_emitter__;
|
|
43
|
+
} else {
|
|
44
|
+
emitter = process2.__signal_exit_emitter__ = new EE;
|
|
45
|
+
emitter.count = 0;
|
|
46
|
+
emitter.emitted = {};
|
|
47
|
+
}
|
|
48
|
+
if (!emitter.infinite) {
|
|
49
|
+
emitter.setMaxListeners(Infinity);
|
|
50
|
+
emitter.infinite = true;
|
|
51
|
+
}
|
|
52
|
+
module.exports = function(cb, opts) {
|
|
53
|
+
if (!processOk(global.process)) {
|
|
54
|
+
return function() {};
|
|
55
|
+
}
|
|
56
|
+
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
57
|
+
if (loaded === false) {
|
|
58
|
+
load();
|
|
59
|
+
}
|
|
60
|
+
var ev = "exit";
|
|
61
|
+
if (opts && opts.alwaysLast) {
|
|
62
|
+
ev = "afterexit";
|
|
63
|
+
}
|
|
64
|
+
var remove = function() {
|
|
65
|
+
emitter.removeListener(ev, cb);
|
|
66
|
+
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
|
|
67
|
+
unload();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
emitter.on(ev, cb);
|
|
71
|
+
return remove;
|
|
72
|
+
};
|
|
73
|
+
unload = function unload2() {
|
|
74
|
+
if (!loaded || !processOk(global.process)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
loaded = false;
|
|
78
|
+
signals.forEach(function(sig) {
|
|
79
|
+
try {
|
|
80
|
+
process2.removeListener(sig, sigListeners[sig]);
|
|
81
|
+
} catch (er) {}
|
|
82
|
+
});
|
|
83
|
+
process2.emit = originalProcessEmit;
|
|
84
|
+
process2.reallyExit = originalProcessReallyExit;
|
|
85
|
+
emitter.count -= 1;
|
|
86
|
+
};
|
|
87
|
+
module.exports.unload = unload;
|
|
88
|
+
emit = function emit2(event, code, signal) {
|
|
89
|
+
if (emitter.emitted[event]) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
emitter.emitted[event] = true;
|
|
93
|
+
emitter.emit(event, code, signal);
|
|
94
|
+
};
|
|
95
|
+
sigListeners = {};
|
|
96
|
+
signals.forEach(function(sig) {
|
|
97
|
+
sigListeners[sig] = function listener() {
|
|
98
|
+
if (!processOk(global.process)) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
var listeners = process2.listeners(sig);
|
|
102
|
+
if (listeners.length === emitter.count) {
|
|
103
|
+
unload();
|
|
104
|
+
emit("exit", null, sig);
|
|
105
|
+
emit("afterexit", null, sig);
|
|
106
|
+
if (isWin && sig === "SIGHUP") {
|
|
107
|
+
sig = "SIGINT";
|
|
108
|
+
}
|
|
109
|
+
process2.kill(process2.pid, sig);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
module.exports.signals = function() {
|
|
114
|
+
return signals;
|
|
115
|
+
};
|
|
116
|
+
loaded = false;
|
|
117
|
+
load = function load2() {
|
|
118
|
+
if (loaded || !processOk(global.process)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
loaded = true;
|
|
122
|
+
emitter.count += 1;
|
|
123
|
+
signals = signals.filter(function(sig) {
|
|
124
|
+
try {
|
|
125
|
+
process2.on(sig, sigListeners[sig]);
|
|
126
|
+
return true;
|
|
127
|
+
} catch (er) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
process2.emit = processEmit;
|
|
132
|
+
process2.reallyExit = processReallyExit;
|
|
133
|
+
};
|
|
134
|
+
module.exports.load = load;
|
|
135
|
+
originalProcessReallyExit = process2.reallyExit;
|
|
136
|
+
processReallyExit = function processReallyExit2(code) {
|
|
137
|
+
if (!processOk(global.process)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
process2.exitCode = code || 0;
|
|
141
|
+
emit("exit", process2.exitCode, null);
|
|
142
|
+
emit("afterexit", process2.exitCode, null);
|
|
143
|
+
originalProcessReallyExit.call(process2, process2.exitCode);
|
|
144
|
+
};
|
|
145
|
+
originalProcessEmit = process2.emit;
|
|
146
|
+
processEmit = function processEmit2(ev, arg) {
|
|
147
|
+
if (ev === "exit" && processOk(global.process)) {
|
|
148
|
+
if (arg !== undefined) {
|
|
149
|
+
process2.exitCode = arg;
|
|
150
|
+
}
|
|
151
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
152
|
+
emit("exit", process2.exitCode, null);
|
|
153
|
+
emit("afterexit", process2.exitCode, null);
|
|
154
|
+
return ret;
|
|
155
|
+
} else {
|
|
156
|
+
return originalProcessEmit.apply(this, arguments);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
var assert;
|
|
161
|
+
var signals;
|
|
162
|
+
var isWin;
|
|
163
|
+
var EE;
|
|
164
|
+
var emitter;
|
|
165
|
+
var unload;
|
|
166
|
+
var emit;
|
|
167
|
+
var sigListeners;
|
|
168
|
+
var loaded;
|
|
169
|
+
var load;
|
|
170
|
+
var originalProcessReallyExit;
|
|
171
|
+
var processReallyExit;
|
|
172
|
+
var originalProcessEmit;
|
|
173
|
+
var processEmit;
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
export { require_signal_exit };
|