@desplega.ai/agent-swarm 1.164.1 → 1.166.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-yzfxn8vj.js +23 -0
- package/dist/{actions-hp2h32dx.js → actions-qz3m692w.js} +24 -28
- package/dist/{amp-adapter-zfd7djyx.js → amp-adapter-j1xbmsqz.js} +7 -7
- package/dist/{app-w2d26h4f.js → app-43vrdmv8.js} +9 -10
- package/dist/{assistant-45pc4en7.js → assistant-ertffmka.js} +25 -29
- package/dist/{boot-reembed-k1q2s4fc.js → boot-reembed-998jtpdg.js} +12 -15
- package/dist/{boot-reembed-6rhcpsjf.js → boot-reembed-s7k7c6v2.js} +13 -15
- package/dist/boot-scrub-sweep-nepsk4t1.js +211 -0
- package/dist/{boot-seeds-ex93edx7.js → boot-seeds-vvzs1zhk.js} +12 -12
- package/dist/{claude-adapter-hcxd0szm.js → claude-adapter-2zvmekrp.js} +15 -17
- package/dist/{claude-managed-adapter-fz7xps2r.js → claude-managed-adapter-s49wbk8t.js} +5 -5
- package/dist/{claude-managed-setup-xx6f15h9.js → claude-managed-setup-cvhqq8qn.js} +4 -4
- package/dist/{claude-sdk-session-6nb9raem.js → claude-sdk-session-kkbxtw5q.js} +2624 -2606
- package/dist/{cli-etbrt8x1.js → cli-0nhdwxd5.js} +4 -4
- package/dist/{cli-jeefgppq.js → cli-0qjcsxgz.js} +7 -7
- package/dist/{cli-6behs2bt.js → cli-32bca7nr.js} +1 -1
- package/dist/{cli-gt8v96qx.js → cli-3ddybbbx.js} +4 -4
- package/dist/{acp-adapter-rxvek4ym.js → cli-3qn4r334.js} +317 -35
- package/dist/{cli-1d3w4xm3.js → cli-4r1sjfc4.js} +14 -6
- package/dist/{cli-691f2rxm.js → cli-66zh26sp.js} +68 -16
- package/dist/{cli-et8wdyqh.js → cli-68r1j4sg.js} +9 -9
- package/dist/{cli-xb7kyanp.js → cli-8kgvmkak.js} +3 -3
- package/dist/{cli-fdpkw8vk.js → cli-8t229cmr.js} +8 -8
- package/dist/{cli-gc54qc0p.js → cli-aqcey741.js} +1 -1
- package/dist/{cli-4q4cmr4t.js → cli-cpfmqz3n.js} +8 -8
- package/dist/{cli-a9bw0xxt.js → cli-df56tqdw.js} +997 -408
- package/dist/{cli-n7h1kqpf.js → cli-dmtrxqhg.js} +6 -1
- package/dist/{cli-xfb7333f.js → cli-dw2q9f7g.js} +5 -5
- package/dist/{cli-4drstbb9.js → cli-ecknp7p1.js} +81 -23
- package/dist/{cli-v0pvvhfq.js → cli-efnd2kce.js} +36 -1
- package/dist/{cli-1wetf34q.js → cli-f2n17zhp.js} +1 -1
- package/dist/{cli-2c8eky5y.js → cli-feh3dkah.js} +1 -1
- package/dist/cli-fn697bnt.js +126 -0
- package/dist/{cli-v5pr2fgt.js → cli-gt8azyet.js} +3 -3
- package/dist/{cli-dbszf3rw.js → cli-h3x613ze.js} +4 -4
- package/dist/{cli-nwhb8y2e.js → cli-hf5s9pgf.js} +1 -1
- package/dist/cli-j2jbr8af.js +516 -0
- package/dist/{cli-agjzafns.js → cli-jhm6hzjn.js} +593 -10
- package/dist/{cli-j0tmc908.js → cli-jvj6a0cv.js} +484 -477
- package/dist/{cli-xxz89c2n.js → cli-mb75wpxf.js} +1 -1
- package/dist/{cli-07s39g1n.js → cli-mv2520nm.js} +1 -1
- package/dist/{cli-v90vfwyb.js → cli-mwegs4af.js} +5 -5
- package/dist/{cli-bz1gbac9.js → cli-p4ztb80h.js} +2 -2
- package/dist/{cli-1wd1n2ya.js → cli-rfphkzh5.js} +1 -1
- package/dist/{cli-976r1zqx.js → cli-rggdq8wq.js} +5 -5
- package/dist/{cli-3ajw5v5v.js → cli-rsy933yz.js} +6 -6
- package/dist/{cli-yj790e19.js → cli-tadfgd0t.js} +8 -1
- package/dist/{cli-cn53e7vc.js → cli-ttbsse3f.js} +6 -1
- package/dist/{cli-dyqsrqcf.js → cli-v2a8x45d.js} +4 -4
- package/dist/{cli-wbvnn6tk.js → cli-v6vv7dy8.js} +91 -9
- package/dist/{cli-z2ap2c0c.js → cli-vzc73wet.js} +90 -55
- package/dist/cli-wt7ccy4r.js +2654 -0
- package/dist/{cli-4cn19jvn.js → cli-x7kpr72a.js} +3 -3
- package/dist/{cli-003785v9.js → cli-xvc3q9br.js} +1 -1
- package/dist/{cli-v0e7jpr5.js → cli-xvdgasgy.js} +13 -4
- package/dist/{cli-asqeg4ve.js → cli-y59h2pk9.js} +2 -2
- package/dist/{cli-0wn3ypqv.js → cli-yshaazs1.js} +14121 -3478
- package/dist/{cli-wg8yjqtw.js → cli-ysnyhws9.js} +16 -3
- package/dist/cli-zp67qg5x.js +92 -0
- package/dist/{cli-g3qgrzck.js → cli-zsh093hk.js} +71 -3
- package/dist/{cli-ma3zvh39.js → cli-zy7vwsne.js} +6066 -5829
- package/dist/cli.js +79 -26
- package/dist/{codex-adapter-pcxdn10v.js → codex-adapter-dw1wxqt8.js} +10 -10
- package/dist/{codex-hook-b1fb7c2k.js → codex-hook-d2rkvf39.js} +1 -1
- package/dist/{codex-login-059nm145.js → codex-login-terbdsqq.js} +2 -2
- package/dist/{codex-session-runner-xzwwddp8.js → codex-session-runner-3cgb8y1g.js} +10 -10
- package/dist/{commands-98at8mkn.js → commands-mhxam6z2.js} +9 -9
- package/dist/{cursor-adapter-dkg6qnkp.js → cursor-adapter-2qda3st7.js} +6 -6
- package/dist/{db-01g8wtvw.js → db-sjks418k.js} +11 -9
- package/dist/{devin-adapter-qmttt2fz.js → devin-adapter-bffjj5n4.js} +2 -2
- package/dist/{dispatcher-nn2k1wxd.js → dispatcher-1es759rn.js} +22 -26
- package/dist/{dsh-adapter-w4d4vwdq.js → dsh-adapter-bek4cyw9.js} +6 -6
- package/dist/{e2b-9e4g2hvt.js → e2b-nd50eccg.js} +1 -1
- package/dist/{event-bus-z7v2t26e.js → event-bus-vnfthafg.js} +2 -2
- package/dist/grok-adapter-ar9cw9jg.js +29 -0
- package/dist/{handlers-b0kqsbg8.js → handlers-1gkbhktr.js} +25 -29
- package/dist/{hook-sap7v1aj.js → hook-ds2zxq9v.js} +16 -18
- package/dist/{hook-pz50gqep.js → hook-vxa3tcsy.js} +10 -12
- package/dist/{http-ncr8rmd0.js → http-3h21z9md.js} +679 -227
- package/dist/{index-c4aqcyz1.js → index-9b65j1m5.js} +11 -11
- package/dist/{index-r46s01nq.js → index-bn6cy8ps.js} +22 -26
- package/dist/{index-38kqdt3e.js → index-dkfxpkmm.js} +23 -27
- package/dist/{index-630kj5vd.js → index-f8xnqrye.js} +55 -43
- package/dist/{index-fdk1t4d6.js → index-n0rxa4ca.js} +11962 -9900
- package/dist/{index-9nrj7797.js → index-n99fycq7.js} +22 -26
- package/dist/{keepalive-31613r2h.js → keepalive-3xspa9jw.js} +14 -11
- package/dist/{lead-mx59tr5s.js → lead-6qphc124.js} +43 -43
- package/dist/{maintenance-55ff39ca.js → maintenance-0teem1bb.js} +10 -12
- package/dist/{node-f0ykebbv.js → node-9sg7ajby.js} +25 -7
- package/dist/{oauth-refresh-sweep-anma954w.js → oauth-refresh-sweep-sh9q25xp.js} +13 -10
- package/dist/{onboard-b2fy8ftb.js → onboard-54qmnqxe.js} +4 -3
- package/dist/{opencode-adapter-p1s92tmy.js → opencode-adapter-wjfa2wvd.js} +6 -6
- package/dist/{otel-impl-9brvt7xv.js → otel-impl-ycqzp2a1.js} +2 -2
- package/dist/{pi-mono-adapter-kz4rrwvd.js → pi-mono-adapter-e77e9zst.js} +6 -6
- package/dist/{pricing-refresh-7w8mbmva.js → pricing-refresh-atnkngqs.js} +10 -10
- package/dist/{rbac-roles-ejp7qwvb.js → rbac-roles-9pjphh9q.js} +10 -10
- package/dist/{rbac-roles-nhk4r7bc.js → rbac-roles-j78wdksm.js} +10 -10
- package/dist/{render-v2-2gzt8skq.js → render-v2-pxjs49fx.js} +9 -10
- package/dist/{setup-5et8t412.js → setup-ymej0xtx.js} +2 -2
- package/dist/{work-objects-tb0er7qa.js → work-objects-3nh4ymzb.js} +26 -30
- package/dist/{worker-62cv075d.js → worker-qa9fkz5s.js} +43 -43
- package/dist/{x-vbxb31jr.js → x-ma4gnfgy.js} +2 -2
- package/openapi.json +457 -31
- package/package.json +14 -6
- package/plugin/commands/create-pr.md +7 -1
- package/plugin/pi-skills/create-pr/SKILL.md +7 -1
- package/src/agentmail/app.ts +5 -4
- package/src/be/automation-preflight.ts +11 -9
- package/src/be/boot-scrub-sweep.ts +302 -0
- package/src/be/connector-codes.ts +81 -0
- package/src/be/crypto/key-bootstrap.ts +1 -1
- package/src/be/db/approvals.ts +15 -1
- package/src/be/db/codex-oauth-device-flows.ts +40 -0
- package/src/be/db/config-secrets.ts +31 -0
- package/src/be/db/runtime.ts +4 -0
- package/src/be/db/script-runs.ts +15 -0
- package/src/be/db/tasks/write.ts +1 -1
- package/src/be/db-queries/mcp-oauth.ts +5 -0
- package/src/be/db-queries/oauth.ts +77 -0
- package/src/be/db.ts +162 -59
- package/src/be/events.ts +17 -1
- package/src/be/memory/index-content.ts +2 -2
- package/src/be/memory/providers/sqlite-store.ts +63 -11
- package/src/be/memory/types.ts +14 -0
- package/src/be/migrations/197_connector_codes.sql +23 -0
- package/src/be/migrations/198_permission_audit_guest.sql +33 -0
- package/src/be/migrations/200_backfill_auto_memory_expiry.sql +20 -0
- package/src/be/migrations/201_workflow_replay_columns.sql +10 -0
- package/src/be/migrations/202_codex_oauth_device_flows.sql +24 -0
- package/src/be/model-tier-resolution.ts +2 -1
- package/src/be/model-validation.ts +1 -1
- package/src/be/pricing-normalize.ts +3 -0
- package/src/be/rbac-audit.ts +2 -1
- package/src/be/scripts/db.ts +28 -4
- package/src/be/scripts/source-secrets.ts +37 -0
- package/src/be/scripts/typecheck.ts +23 -2
- package/src/be/scrub-json.ts +32 -0
- package/src/be/sealed-json.ts +59 -0
- package/src/be/secret-registry.ts +131 -0
- package/src/be/seed-pricing.ts +14 -0
- package/src/be/users.ts +7 -1
- package/src/be/workflow-replay.ts +77 -0
- package/src/cli.tsx +7 -0
- package/src/commands/provider-credentials.ts +46 -8
- package/src/commands/runner.ts +2 -10
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/github/app.ts +4 -4
- package/src/heartbeat/heartbeat.ts +20 -8
- package/src/hooks/pr-body-guard.ts +1 -1
- package/src/http/agents.ts +1 -0
- package/src/http/approval-requests.ts +1 -0
- package/src/http/apps.ts +3 -0
- package/src/http/auth.ts +4 -1
- package/src/http/codex-oauth-device.ts +8 -10
- package/src/http/codex-oauth-keep-warm.ts +2 -2
- package/src/http/config-values.ts +59 -0
- package/src/http/config.ts +5 -0
- package/src/http/db-query-bounded.ts +3 -0
- package/src/http/db-query-shared.ts +107 -15
- package/src/http/db-query.ts +10 -2
- package/src/http/extensions.ts +1 -0
- package/src/http/index.ts +23 -6
- package/src/http/integrations.ts +1 -38
- package/src/http/ip-rate-limit.ts +82 -0
- package/src/http/kv.ts +38 -4
- package/src/http/mcp-servers.ts +1 -0
- package/src/http/memory.ts +9 -0
- package/src/http/models-catalog.ts +2 -0
- package/src/http/operator-actor.ts +4 -0
- package/src/http/page-proxy.ts +22 -0
- package/src/http/pages.ts +4 -2
- package/src/http/realtime.ts +1 -1
- package/src/http/request-principal.ts +14 -1
- package/src/http/script-connections.ts +8 -0
- package/src/http/script-runs.ts +12 -4
- package/src/http/scripts.ts +15 -0
- package/src/http/session-cost-recompute.ts +3 -2
- package/src/http/tasks.ts +9 -0
- package/src/http/users.ts +226 -0
- package/src/http/workflows.ts +3 -2
- package/src/http.ts +1 -0
- package/src/integrations/kapso/client.ts +3 -1
- package/src/jira/app.ts +2 -2
- package/src/kv-view.ts +324 -0
- package/src/linear/app.ts +2 -2
- package/src/oauth/mcp-wrapper.ts +1 -1
- package/src/prompts/memories.ts +42 -1
- package/src/providers/acp-adapter.ts +85 -24
- package/src/providers/acp-target-catalog.ts +54 -1
- package/src/providers/acp-targets.ts +358 -4
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/providers/grok-adapter.ts +186 -0
- package/src/providers/index.ts +5 -1
- package/src/providers/pricing-sources.md +6 -0
- package/src/providers/reasoning-effort.ts +17 -1
- package/src/providers/types.ts +2 -1
- package/src/rbac/can.ts +4 -3
- package/src/rbac/legacy-policy.ts +3 -3
- package/src/rbac/types.ts +6 -0
- package/src/script-workflows/supervisor.ts +11 -2
- package/src/scripts-runtime/eval-harness.ts +2 -12
- package/src/scripts-runtime/executors/quickjs-bundle.ts +152 -0
- package/src/scripts-runtime/executors/quickjs-prelude.ts +285 -0
- package/src/scripts-runtime/executors/quickjs-runner.ts +580 -0
- package/src/scripts-runtime/executors/quickjs-worker.ts +81 -0
- package/src/scripts-runtime/executors/quickjs.ts +196 -0
- package/src/scripts-runtime/executors/registry.ts +2 -0
- package/src/scripts-runtime/executors/sourcemap.ts +79 -0
- package/src/scripts-runtime/script-error-hints.ts +14 -0
- package/src/scripts-runtime/swarm-sdk.ts +9 -2
- package/src/scripts-runtime/types/stdlib.d.ts +27 -8
- package/src/scripts-runtime/types/swarm-extension.d.ts +3 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +27 -8
- package/src/server-user.ts +2 -20
- package/src/server.ts +3 -1
- package/src/slack/app.ts +4 -0
- package/src/slack/config.ts +3 -1
- package/src/slack/egress-scrub.ts +87 -0
- package/src/tests/acp-adapter.test.ts +191 -2
- package/src/tests/boot-scrub-sweep.test.ts +390 -0
- package/src/tests/budget-user-scope.test.ts +7 -21
- package/src/tests/check-pr-body.test.ts +149 -6
- package/src/tests/check-text-columns.test.ts +145 -0
- package/src/tests/claude-adapter-binary.test.ts +1 -1
- package/src/tests/claude-sdk-process.fixture.ts +13 -2
- package/src/tests/codex-oauth-device.test.ts +23 -37
- package/src/tests/codex-oauth-keep-warm.test.ts +29 -0
- package/src/tests/console-scrub.test.ts +141 -0
- package/src/tests/credential-check.test.ts +90 -0
- package/src/tests/db-query-denylist.test.ts +202 -0
- package/src/tests/db-task-read-contract.test.ts +1 -0
- package/src/tests/db-task-write-contract.test.ts +1 -0
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/entrypoint-acp-target-binary.test.ts +44 -1
- package/src/tests/events-scrub.test.ts +88 -0
- package/src/tests/explicit-model-validation.test.ts +81 -0
- package/src/tests/extensions-pre-task.test.ts +33 -1
- package/src/tests/fixtures/grok/acp-updates-recorded.jsonl +53 -0
- package/src/tests/fixtures/grok/prompt-response-meta.json +36 -0
- package/src/tests/fixtures/secret-corpus.ts +320 -0
- package/src/tests/grok-adapter.test.ts +647 -0
- package/src/tests/heartbeat-checklist.test.ts +44 -0
- package/src/tests/integration-disable-flags.test.ts +156 -0
- package/src/tests/kv-http.test.ts +34 -0
- package/src/tests/kv-tool.test.ts +274 -1
- package/src/tests/kv-view.test.ts +147 -0
- package/src/tests/mcp-user-route.test.ts +257 -15
- package/src/tests/memory-injection-outcome.test.ts +143 -0
- package/src/tests/model-tier-resolution.test.ts +76 -3
- package/src/tests/page-guest-session.test.ts +424 -0
- package/src/tests/page-proxy.test.ts +1 -1
- package/src/tests/page-viewer-auth.test.ts +22 -1
- package/src/tests/pr-body-leaks.test.ts +157 -2
- package/src/tests/preload.ts +10 -0
- package/src/tests/provider-registration.test.ts +3 -1
- package/src/tests/rbac-audit.test.ts +32 -0
- package/src/tests/rbac-mcp-admission-e2e.test.ts +4 -62
- package/src/tests/script-connections.test.ts +9 -0
- package/src/tests/script-executor-conformance.test.ts +3 -0
- package/src/tests/script-executor-quickjs.test.ts +442 -0
- package/src/tests/script-executor-registry.test.ts +6 -1
- package/src/tests/script-runs-http.test.ts +126 -1
- package/src/tests/script-runs-scrub.test.ts +275 -0
- package/src/tests/scripts-http.test.ts +82 -1
- package/src/tests/scripts-mcp-e2e.test.ts +42 -6
- package/src/tests/scripts-runtime.test.ts +37 -0
- package/src/tests/scrubbed-text-12e.test.ts +289 -0
- package/src/tests/sealed-key-guard.test.ts +166 -0
- package/src/tests/secret-canary-sweep.test.ts +958 -0
- package/src/tests/secret-registry.test.ts +355 -0
- package/src/tests/secret-rules.test.ts +230 -0
- package/src/tests/secret-scrubber.test.ts +317 -1
- package/src/tests/session-costs-golden.test.ts +17 -0
- package/src/tests/slack-egress-scrub.test.ts +216 -0
- package/src/tests/swarm-tool-result-gate.test.ts +143 -30
- package/src/tests/task-tools-ctx.test.ts +3 -0
- package/src/tests/user-token-routes.test.ts +342 -3
- package/src/tests/workflow-replay.test.ts +518 -0
- package/src/tests/workflow-scrub.test.ts +242 -0
- package/src/tests/workflow-system-one-decision-providers.test.ts +737 -0
- package/src/tools/db-query.ts +1 -1
- package/src/tools/inject-learning.ts +1 -1
- package/src/tools/kv/kv-get.ts +136 -6
- package/src/tools/send-task.ts +61 -17
- package/src/tools/utils.ts +186 -43
- package/src/tools/workflows/get-workflow-run.ts +3 -2
- package/src/types.ts +16 -1
- package/src/utils/console-scrub-install.ts +5 -0
- package/src/utils/console-scrub.ts +57 -0
- package/src/utils/credentials.ts +8 -0
- package/src/utils/page-session.ts +6 -2
- package/src/utils/pr-body-leaks.ts +149 -10
- package/src/utils/request-auth-context.ts +2 -0
- package/src/utils/secret-rules.generated.ts +2055 -0
- package/src/utils/secret-scrubber.ts +662 -36
- package/src/workflows/engine.ts +39 -4
- package/src/workflows/executors/notify.ts +6 -1
- package/src/workflows/executors/system-one-decision.ts +31 -12
- package/src/workflows/executors/system-one-openai-wire.ts +168 -0
- package/src/workflows/executors/system-one-providers.ts +112 -11
- package/src/workflows/executors/system-one-wire.ts +79 -0
- package/src/workflows/recovery.ts +10 -1
- package/src/workflows/resume.ts +62 -3
- package/src/workflows/retry-poller.ts +3 -0
- package/templates/ai-toolbox.manifest.json +2 -2
- package/templates/skills/agent-browser/SKILL.md +5 -5
- package/templates/skills/agent-browser/config.json +1 -1
- package/templates/skills/agent-browser/content.md +4 -4
- package/templates/skills/artifacts/content.md +17 -7
- package/templates/skills/jira-interaction/config.json +1 -1
- package/templates/skills/jira-interaction/content.md +56 -205
- package/templates/skills/linear-interaction/config.json +1 -1
- package/templates/skills/linear-interaction/content.md +31 -50
- package/templates/skills/pages/content.md +8 -4
- package/templates/skills/qa/content.md +2 -2
- package/templates/skills/workflow-iterate/content.md +4 -4
- package/tsconfig.json +3 -3
- package/dist/boot-scrub-logs-t8xg7wd7.js +0 -99
- package/dist/cli-0a7r5331.js +0 -168
- package/dist/cli-93rxw9yd.js +0 -951
- package/dist/cli-cvk6yzw5.js +0 -40
- package/dist/cli-dgnj0zcc.js +0 -40
- package/dist/cli-qt5wzq6v.js +0 -256
- package/dist/cli-v7fqehqd.js +0 -9281
- package/dist/cli-vbr859rz.js +0 -572
- package/src/be/boot-scrub-logs.ts +0 -132
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
seedPricingFromModelsDev
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-ysnyhws9.js";
|
|
4
4
|
import {
|
|
5
5
|
ensureRbacSeedsSynced,
|
|
6
6
|
init_rbac_roles
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-8kgvmkak.js";
|
|
8
8
|
import {
|
|
9
9
|
getDb,
|
|
10
|
-
init_db
|
|
11
|
-
} from "./cli-
|
|
10
|
+
init_db1 as init_db
|
|
11
|
+
} from "./cli-yshaazs1.js";
|
|
12
12
|
|
|
13
13
|
// src/be/boot-seeds.ts
|
|
14
14
|
init_db();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runStopHookSessionSummarySubprocess
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-rsy933yz.js";
|
|
4
4
|
import {
|
|
5
5
|
buildOtelTraceparentEnv,
|
|
6
6
|
isHarnessOtelEnabled
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
clampContextPercent,
|
|
17
17
|
computeContextUsedUnified,
|
|
18
18
|
getContextWindowSize
|
|
19
|
-
} from "./cli-
|
|
19
|
+
} from "./cli-32bca7nr.js";
|
|
20
20
|
import {
|
|
21
21
|
fetchInstalledMcpServers
|
|
22
22
|
} from "./cli-tng3131n.js";
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
} from "./cli-2pdaysab.js";
|
|
33
33
|
import {
|
|
34
34
|
applyReasoningEffort
|
|
35
|
-
} from "./cli-
|
|
35
|
+
} from "./cli-ttbsse3f.js";
|
|
36
36
|
import {
|
|
37
37
|
swarmRuntimeInstanceId
|
|
38
38
|
} from "./cli-re8z5p8p.js";
|
|
@@ -44,12 +44,12 @@ import {
|
|
|
44
44
|
import {
|
|
45
45
|
init_file_lock,
|
|
46
46
|
withFileLock
|
|
47
|
-
} from "./cli-
|
|
47
|
+
} from "./cli-jhm6hzjn.js";
|
|
48
48
|
import {
|
|
49
49
|
CLAUDE_CREDENTIALS_HINT,
|
|
50
50
|
init_credentials,
|
|
51
51
|
validateClaudeCredentials
|
|
52
|
-
} from "./cli-
|
|
52
|
+
} from "./cli-tadfgd0t.js";
|
|
53
53
|
import {
|
|
54
54
|
deriveDefaultRoute,
|
|
55
55
|
init_src,
|
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
import {
|
|
64
64
|
init_secret_scrubber,
|
|
65
65
|
scrubSecrets
|
|
66
|
-
} from "./cli-
|
|
66
|
+
} from "./cli-wt7ccy4r.js";
|
|
67
67
|
import {
|
|
68
68
|
require_src
|
|
69
69
|
} from "./cli-knd276ed.js";
|
|
@@ -1026,7 +1026,7 @@ class ClaudeAdapter {
|
|
|
1026
1026
|
if (transport === "sdk" && isClaudeBridgeEffective(sourceEnv)) {
|
|
1027
1027
|
throw new Error("CLAUDE_TRANSPORT=sdk cannot run with an effective Claude Bridge configuration. Select CLI transport or disable the bridge.");
|
|
1028
1028
|
}
|
|
1029
|
-
const claudeSdk = transport === "sdk" ? await import("./claude-sdk-session-
|
|
1029
|
+
const claudeSdk = transport === "sdk" ? await import("./claude-sdk-session-kkbxtw5q.js") : undefined;
|
|
1030
1030
|
claudeSdk?.validateClaudeSdkAdditionalArgs([
|
|
1031
1031
|
...claudeBinaryArgv.slice(1),
|
|
1032
1032
|
...config.additionalArgs ?? []
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
CONTEXT_FORMULA,
|
|
12
12
|
clampContextPercent,
|
|
13
13
|
getContextWindowSize
|
|
14
|
-
} from "./cli-
|
|
14
|
+
} from "./cli-32bca7nr.js";
|
|
15
15
|
import {
|
|
16
16
|
fetchInstalledMcpServers
|
|
17
17
|
} from "./cli-tng3131n.js";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from "./cli-5bfdm1ah.js";
|
|
21
21
|
import {
|
|
22
22
|
applyReasoningEffort
|
|
23
|
-
} from "./cli-
|
|
23
|
+
} from "./cli-ttbsse3f.js";
|
|
24
24
|
import {
|
|
25
25
|
swarmRuntimeInstanceId
|
|
26
26
|
} from "./cli-re8z5p8p.js";
|
|
@@ -31,11 +31,11 @@ import {
|
|
|
31
31
|
import {
|
|
32
32
|
init_credentials,
|
|
33
33
|
validateOpencodeCredentials
|
|
34
|
-
} from "./cli-
|
|
34
|
+
} from "./cli-tadfgd0t.js";
|
|
35
35
|
import {
|
|
36
36
|
init_secret_scrubber,
|
|
37
37
|
scrubSecrets
|
|
38
|
-
} from "./cli-
|
|
38
|
+
} from "./cli-wt7ccy4r.js";
|
|
39
39
|
import {
|
|
40
40
|
__toESM
|
|
41
41
|
} from "./cli-bc05qbss.js";
|
|
@@ -1,16 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clampContextPercent,
|
|
3
|
+
getContextWindowSize
|
|
4
|
+
} from "./cli-32bca7nr.js";
|
|
1
5
|
import {
|
|
2
6
|
fetchInstalledMcpServers
|
|
3
7
|
} from "./cli-tng3131n.js";
|
|
4
8
|
import {
|
|
9
|
+
ACP_TARGET_IDS,
|
|
5
10
|
getAcpTargetCatalogEntry,
|
|
6
11
|
isAcpTarget
|
|
7
|
-
} from "./cli-
|
|
8
|
-
import
|
|
12
|
+
} from "./cli-zp67qg5x.js";
|
|
13
|
+
import {
|
|
14
|
+
applyReasoningEffort
|
|
15
|
+
} from "./cli-ttbsse3f.js";
|
|
9
16
|
import {
|
|
10
17
|
detachedProcessGroup,
|
|
11
18
|
registerProcessGroup,
|
|
12
19
|
terminateProcessGroup
|
|
13
20
|
} from "./cli-zt3w1cn1.js";
|
|
21
|
+
import {
|
|
22
|
+
init_src,
|
|
23
|
+
normalizeGrokModel
|
|
24
|
+
} from "./cli-zsh093hk.js";
|
|
14
25
|
import {
|
|
15
26
|
array,
|
|
16
27
|
boolean,
|
|
@@ -30,12 +41,11 @@ import {
|
|
|
30
41
|
import {
|
|
31
42
|
init_package,
|
|
32
43
|
package_default
|
|
33
|
-
} from "./cli-
|
|
44
|
+
} from "./cli-4r1sjfc4.js";
|
|
34
45
|
import {
|
|
35
46
|
init_secret_scrubber,
|
|
36
47
|
scrubSecrets
|
|
37
|
-
} from "./cli-
|
|
38
|
-
import"./cli-bc05qbss.js";
|
|
48
|
+
} from "./cli-wt7ccy4r.js";
|
|
39
49
|
|
|
40
50
|
// node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
41
51
|
var AGENT_METHODS = {
|
|
@@ -4718,6 +4728,9 @@ function translateAcpSessionNotification(notification) {
|
|
|
4718
4728
|
}
|
|
4719
4729
|
|
|
4720
4730
|
// src/providers/acp-targets.ts
|
|
4731
|
+
init_src();
|
|
4732
|
+
import { mkdir, mkdtemp, rm } from "node:fs/promises";
|
|
4733
|
+
import { tmpdir } from "node:os";
|
|
4721
4734
|
import { join } from "node:path";
|
|
4722
4735
|
class AcpTargetResolutionError extends Error {
|
|
4723
4736
|
constructor(message) {
|
|
@@ -4863,14 +4876,247 @@ var opencodeTargetProfile = {
|
|
|
4863
4876
|
configuredOptions,
|
|
4864
4877
|
async writeSystemPromptArtifact() {}
|
|
4865
4878
|
};
|
|
4879
|
+
var geminiSystemPromptPaths = new WeakMap;
|
|
4880
|
+
var geminiTargetProfile = {
|
|
4881
|
+
target: "gemini",
|
|
4882
|
+
command() {
|
|
4883
|
+
const entry = getAcpTargetCatalogEntry("gemini");
|
|
4884
|
+
return [entry.command, ...entry.args ?? []];
|
|
4885
|
+
},
|
|
4886
|
+
env(config) {
|
|
4887
|
+
const env = baseTargetEnv(config);
|
|
4888
|
+
const entry = getAcpTargetCatalogEntry("gemini");
|
|
4889
|
+
copyEnvKeys(config, env, entry.envKeys);
|
|
4890
|
+
env.GEMINI_CLI_TRUST_WORKSPACE = "true";
|
|
4891
|
+
if (config.model.trim())
|
|
4892
|
+
env.GEMINI_MODEL = config.model.trim();
|
|
4893
|
+
const systemPromptPath = geminiSystemPromptPaths.get(config);
|
|
4894
|
+
if (systemPromptPath)
|
|
4895
|
+
env.GEMINI_SYSTEM_MD = systemPromptPath;
|
|
4896
|
+
return env;
|
|
4897
|
+
},
|
|
4898
|
+
configuredOptions,
|
|
4899
|
+
async writeSystemPromptArtifact(config) {
|
|
4900
|
+
if (!config.systemPrompt?.trim())
|
|
4901
|
+
return;
|
|
4902
|
+
const directory = await mkdtemp(join(tmpdir(), "swarm-acp-gemini-"));
|
|
4903
|
+
const path = join(directory, "system.md");
|
|
4904
|
+
await Bun.write(path, config.systemPrompt);
|
|
4905
|
+
geminiSystemPromptPaths.set(config, path);
|
|
4906
|
+
}
|
|
4907
|
+
};
|
|
4908
|
+
function copilotInstructionsDir(config) {
|
|
4909
|
+
const key = new Bun.CryptoHasher("sha256").update(`${config.agentId}:${config.taskId}:${config.cwd}`).digest("hex").slice(0, 16);
|
|
4910
|
+
return join(tmpdir(), "agent-swarm-copilot-instructions", key);
|
|
4911
|
+
}
|
|
4912
|
+
var COPILOT_INSTRUCTIONS_FILE = join(".github", "instructions", "agent-swarm.instructions.md");
|
|
4913
|
+
var copilotTargetProfile = {
|
|
4914
|
+
target: "copilot",
|
|
4915
|
+
command() {
|
|
4916
|
+
const entry = getAcpTargetCatalogEntry("copilot");
|
|
4917
|
+
return [entry.command, ...entry.args ?? []];
|
|
4918
|
+
},
|
|
4919
|
+
env(config) {
|
|
4920
|
+
const env = baseTargetEnv(config);
|
|
4921
|
+
const entry = getAcpTargetCatalogEntry("copilot");
|
|
4922
|
+
copyEnvKeys(config, env, entry.envKeys);
|
|
4923
|
+
if (config.model.trim())
|
|
4924
|
+
env.COPILOT_MODEL = config.model.trim();
|
|
4925
|
+
env.COPILOT_AUTO_UPDATE = "false";
|
|
4926
|
+
const operatorDirs = readEnv(config, "COPILOT_CUSTOM_INSTRUCTIONS_DIRS")?.trim();
|
|
4927
|
+
env.COPILOT_CUSTOM_INSTRUCTIONS_DIRS = [copilotInstructionsDir(config), operatorDirs].filter(Boolean).join(",");
|
|
4928
|
+
return env;
|
|
4929
|
+
},
|
|
4930
|
+
configuredOptions,
|
|
4931
|
+
async writeSystemPromptArtifact(config) {
|
|
4932
|
+
const dir = copilotInstructionsDir(config);
|
|
4933
|
+
await rm(dir, { recursive: true, force: true });
|
|
4934
|
+
if (!config.systemPrompt)
|
|
4935
|
+
return;
|
|
4936
|
+
await mkdir(join(dir, ".github", "instructions"), { recursive: true });
|
|
4937
|
+
await Bun.write(join(dir, COPILOT_INSTRUCTIONS_FILE), `---
|
|
4938
|
+
applyTo: "**"
|
|
4939
|
+
---
|
|
4940
|
+
|
|
4941
|
+
${config.systemPrompt}
|
|
4942
|
+
`);
|
|
4943
|
+
},
|
|
4944
|
+
async cleanupSystemPromptArtifact(config) {
|
|
4945
|
+
await rm(copilotInstructionsDir(config), { recursive: true, force: true });
|
|
4946
|
+
}
|
|
4947
|
+
};
|
|
4948
|
+
var GROK_ISOLATION_ENV = {
|
|
4949
|
+
GROK_DISABLE_AUTOUPDATER: "1",
|
|
4950
|
+
GROK_TELEMETRY_ENABLED: "0",
|
|
4951
|
+
GROK_CLAUDE_HOOKS_ENABLED: "false",
|
|
4952
|
+
GROK_CLAUDE_MCPS_ENABLED: "false",
|
|
4953
|
+
GROK_CLAUDE_AGENTS_ENABLED: "false",
|
|
4954
|
+
GROK_CLAUDE_RULES_ENABLED: "false",
|
|
4955
|
+
GROK_CURSOR_HOOKS_ENABLED: "false",
|
|
4956
|
+
GROK_CURSOR_MCPS_ENABLED: "false",
|
|
4957
|
+
GROK_CURSOR_AGENTS_ENABLED: "false",
|
|
4958
|
+
GROK_CURSOR_RULES_ENABLED: "false",
|
|
4959
|
+
GROK_CURSOR_SKILLS_ENABLED: "false"
|
|
4960
|
+
};
|
|
4961
|
+
var GROK_XAI_ENDPOINT_KEYS = [
|
|
4962
|
+
"GROK_MODELS_BASE_URL",
|
|
4963
|
+
"GROK_MODELS_LIST_URL",
|
|
4964
|
+
"GROK_XAI_API_BASE_URL"
|
|
4965
|
+
];
|
|
4966
|
+
function isGrokOpenRouterModel(model) {
|
|
4967
|
+
return model.trim().startsWith("openrouter/");
|
|
4968
|
+
}
|
|
4969
|
+
function unwrapGrokToolProxy(event) {
|
|
4970
|
+
if (event.type === "tool_start" && event.toolName === "use_tool") {
|
|
4971
|
+
const args = event.args;
|
|
4972
|
+
if (typeof args?.tool_name !== "string" || !args.tool_name)
|
|
4973
|
+
return event;
|
|
4974
|
+
return { ...event, toolName: `mcp__${args.tool_name}`, args: args.tool_input ?? {} };
|
|
4975
|
+
}
|
|
4976
|
+
if (event.type !== "custom" || event.name !== "acp_tool_call_update")
|
|
4977
|
+
return event;
|
|
4978
|
+
const data = event.data;
|
|
4979
|
+
const raw = data?.rawInput;
|
|
4980
|
+
if (!raw || typeof raw !== "object" || typeof raw.variant !== "string")
|
|
4981
|
+
return event;
|
|
4982
|
+
const { variant, ...rest } = raw;
|
|
4983
|
+
const rawInput = variant === "UseTool" ? rest.tool_input ?? {} : rest;
|
|
4984
|
+
return { ...event, data: { ...data, rawInput } };
|
|
4985
|
+
}
|
|
4986
|
+
function finiteCount(value) {
|
|
4987
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;
|
|
4988
|
+
}
|
|
4989
|
+
var XAI_USD_TICKS = 10000000000;
|
|
4990
|
+
function grokReportedModel(reported, sessionModel) {
|
|
4991
|
+
const id = normalizeGrokModel(reported);
|
|
4992
|
+
if (!isGrokOpenRouterModel(sessionModel) || isGrokOpenRouterModel(id))
|
|
4993
|
+
return id;
|
|
4994
|
+
return `openrouter/${id}`;
|
|
4995
|
+
}
|
|
4996
|
+
function grokFinalModel(meta, model) {
|
|
4997
|
+
const reported = typeof meta?.modelId === "string" ? meta.modelId.trim() : "";
|
|
4998
|
+
return reported ? grokReportedModel(reported, model) : normalizeGrokModel(model);
|
|
4999
|
+
}
|
|
5000
|
+
function grokUsageCounts(usage) {
|
|
5001
|
+
const input = finiteCount(usage.inputTokens) ?? 0;
|
|
5002
|
+
const cacheRead = finiteCount(usage.cachedReadTokens) ?? 0;
|
|
5003
|
+
const reasoning = finiteCount(usage.reasoningTokens) ?? 0;
|
|
5004
|
+
const ticks = finiteCount(usage.costUsdTicks);
|
|
5005
|
+
return {
|
|
5006
|
+
inputTokens: Math.max(0, input - cacheRead),
|
|
5007
|
+
cacheReadTokens: cacheRead,
|
|
5008
|
+
cacheWriteTokens: finiteCount(usage.cacheCreationTokens) ?? 0,
|
|
5009
|
+
outputTokens: (finiteCount(usage.outputTokens) ?? 0) + reasoning,
|
|
5010
|
+
reasoningOutputTokens: reasoning,
|
|
5011
|
+
costUsd: ticks ? ticks / XAI_USD_TICKS : undefined
|
|
5012
|
+
};
|
|
5013
|
+
}
|
|
5014
|
+
function grokModelUsage(usage, model) {
|
|
5015
|
+
const byModel = usage.modelUsage;
|
|
5016
|
+
if (!byModel || typeof byModel !== "object" || Array.isArray(byModel))
|
|
5017
|
+
return [];
|
|
5018
|
+
const rows = [];
|
|
5019
|
+
for (const [reported, entry] of Object.entries(byModel)) {
|
|
5020
|
+
if (!reported.trim() || !entry || typeof entry !== "object")
|
|
5021
|
+
continue;
|
|
5022
|
+
const {
|
|
5023
|
+
costUsd,
|
|
5024
|
+
reasoningOutputTokens: _,
|
|
5025
|
+
...counts
|
|
5026
|
+
} = grokUsageCounts(entry);
|
|
5027
|
+
rows.push({
|
|
5028
|
+
model: grokReportedModel(reported, model),
|
|
5029
|
+
...counts,
|
|
5030
|
+
...costUsd !== undefined ? { harnessCostUsd: costUsd } : {}
|
|
5031
|
+
});
|
|
5032
|
+
}
|
|
5033
|
+
return rows;
|
|
5034
|
+
}
|
|
5035
|
+
function grokPromptCost(meta, model) {
|
|
5036
|
+
const usage = meta?.usage;
|
|
5037
|
+
if (!usage || typeof usage !== "object")
|
|
5038
|
+
return;
|
|
5039
|
+
const { costUsd, ...counts } = grokUsageCounts(usage);
|
|
5040
|
+
const turns = finiteCount(usage.numTurns) ?? finiteCount(usage.modelCalls);
|
|
5041
|
+
const models = grokModelUsage(usage, model);
|
|
5042
|
+
return {
|
|
5043
|
+
model: grokFinalModel(meta, model),
|
|
5044
|
+
...counts,
|
|
5045
|
+
...models.length ? { models } : {},
|
|
5046
|
+
...costUsd !== undefined ? { totalCostUsd: costUsd } : {},
|
|
5047
|
+
...turns ? { numTurns: turns } : {}
|
|
5048
|
+
};
|
|
5049
|
+
}
|
|
5050
|
+
function grokPromptContext(meta, model) {
|
|
5051
|
+
const used = finiteCount(meta?.totalTokens);
|
|
5052
|
+
if (!used)
|
|
5053
|
+
return;
|
|
5054
|
+
const id = grokFinalModel(meta, model);
|
|
5055
|
+
const total = getContextWindowSize(isGrokOpenRouterModel(id) ? id : `xai/${id}`);
|
|
5056
|
+
return {
|
|
5057
|
+
type: "context_usage",
|
|
5058
|
+
contextUsedTokens: used,
|
|
5059
|
+
contextTotalTokens: total,
|
|
5060
|
+
contextPercent: clampContextPercent(used, total),
|
|
5061
|
+
outputTokens: finiteCount(meta?.outputTokens) ?? null,
|
|
5062
|
+
contextFormula: "harness-reported"
|
|
5063
|
+
};
|
|
5064
|
+
}
|
|
5065
|
+
var GROK_AUTH_ERROR_RE = /authentication required|not signed in/i;
|
|
5066
|
+
var grokTargetProfile = {
|
|
5067
|
+
target: "grok",
|
|
5068
|
+
command(config) {
|
|
5069
|
+
const binary = readEnv(config, "GROK_BINARY")?.trim() || "grok";
|
|
5070
|
+
const args = [binary, "agent", "--no-leader", "--always-approve"];
|
|
5071
|
+
if (config.model.trim())
|
|
5072
|
+
args.push("--model", config.model.trim());
|
|
5073
|
+
const effort = config.reasoningEffort ? applyReasoningEffort("grok", config.model.trim(), config.reasoningEffort) : null;
|
|
5074
|
+
if (effort?.kind === "grok-effort")
|
|
5075
|
+
args.push("--reasoning-effort", effort.reasoningEffort);
|
|
5076
|
+
args.push("stdio");
|
|
5077
|
+
return args;
|
|
5078
|
+
},
|
|
5079
|
+
env(config) {
|
|
5080
|
+
const env = baseTargetEnv(config);
|
|
5081
|
+
if (isGrokOpenRouterModel(config.model)) {
|
|
5082
|
+
copyEnvKeys(config, env, ["OPENROUTER_API_KEY", "GROK_HOME"]);
|
|
5083
|
+
} else {
|
|
5084
|
+
copyEnvKeys(config, env, ["XAI_API_KEY", "GROK_HOME", ...GROK_XAI_ENDPOINT_KEYS]);
|
|
5085
|
+
}
|
|
5086
|
+
Object.assign(env, GROK_ISOLATION_ENV);
|
|
5087
|
+
return env;
|
|
5088
|
+
},
|
|
5089
|
+
configuredOptions() {
|
|
5090
|
+
return {};
|
|
5091
|
+
},
|
|
5092
|
+
async writeSystemPromptArtifact() {},
|
|
5093
|
+
sessionMeta(config) {
|
|
5094
|
+
return {
|
|
5095
|
+
...config.systemPrompt?.trim() ? { rules: config.systemPrompt } : {},
|
|
5096
|
+
yoloMode: true
|
|
5097
|
+
};
|
|
5098
|
+
},
|
|
5099
|
+
rewriteEvent: unwrapGrokToolProxy,
|
|
5100
|
+
promptCost: grokPromptCost,
|
|
5101
|
+
promptContext: grokPromptContext,
|
|
5102
|
+
describeError(message) {
|
|
5103
|
+
if (!GROK_AUTH_ERROR_RE.test(message))
|
|
5104
|
+
return;
|
|
5105
|
+
return `Grok rejected the credentials (XAI_API_KEY or OPENROUTER_API_KEY invalid or missing): ${message}`;
|
|
5106
|
+
}
|
|
5107
|
+
};
|
|
4866
5108
|
function resolveAcpTarget(config) {
|
|
4867
5109
|
const target = readEnv(config, "ACP_TARGET") ?? "custom";
|
|
4868
5110
|
if (!isAcpTarget(target)) {
|
|
4869
|
-
throw new AcpTargetResolutionError(`Unsupported ACP target "${target}". Supported targets:
|
|
5111
|
+
throw new AcpTargetResolutionError(`Unsupported ACP target "${target}". Supported targets: ${ACP_TARGET_IDS.join(", ")}.`);
|
|
4870
5112
|
}
|
|
4871
5113
|
switch (target) {
|
|
4872
5114
|
case "opencode":
|
|
4873
5115
|
return opencodeTargetProfile;
|
|
5116
|
+
case "gemini":
|
|
5117
|
+
return geminiTargetProfile;
|
|
5118
|
+
case "copilot":
|
|
5119
|
+
return copilotTargetProfile;
|
|
4874
5120
|
case "custom":
|
|
4875
5121
|
return customTargetProfile;
|
|
4876
5122
|
}
|
|
@@ -4878,6 +5124,7 @@ function resolveAcpTarget(config) {
|
|
|
4878
5124
|
|
|
4879
5125
|
// src/providers/acp-adapter.ts
|
|
4880
5126
|
var ACP_LOG_MAX_CHARS = 30000;
|
|
5127
|
+
var ACP_CANCEL_SETTLE_MS = 3000;
|
|
4881
5128
|
var ACP_LOG_FIELD_MAX_CHARS = 12000;
|
|
4882
5129
|
var ACP_LOG_PREVIEW_MAX_CHARS = 1e4;
|
|
4883
5130
|
var CREDENTIAL_HEADER_NAMES = new Set([
|
|
@@ -4974,9 +5221,11 @@ function boundedAcpLogScalar(value) {
|
|
|
4974
5221
|
|
|
4975
5222
|
class SwarmAcpClient {
|
|
4976
5223
|
emit;
|
|
5224
|
+
target;
|
|
4977
5225
|
reportedCostUsd = null;
|
|
4978
|
-
constructor(emit) {
|
|
5226
|
+
constructor(emit, target) {
|
|
4979
5227
|
this.emit = emit;
|
|
5228
|
+
this.target = target;
|
|
4980
5229
|
}
|
|
4981
5230
|
async requestPermission(params) {
|
|
4982
5231
|
const selected = params.options.find((option) => option.kind === "allow_always") ?? params.options.find((option) => option.kind === "allow_once") ?? params.options[0];
|
|
@@ -4990,7 +5239,7 @@ class SwarmAcpClient {
|
|
|
4990
5239
|
if (costUsd !== null)
|
|
4991
5240
|
this.reportedCostUsd = costUsd;
|
|
4992
5241
|
for (const event of translateAcpSessionNotification(params)) {
|
|
4993
|
-
this.emit(event);
|
|
5242
|
+
this.emit(this.target?.rewriteEvent?.(event) ?? event);
|
|
4994
5243
|
}
|
|
4995
5244
|
}
|
|
4996
5245
|
}
|
|
@@ -5000,6 +5249,8 @@ class ACPSession {
|
|
|
5000
5249
|
client;
|
|
5001
5250
|
process;
|
|
5002
5251
|
config;
|
|
5252
|
+
providerName;
|
|
5253
|
+
target;
|
|
5003
5254
|
sessionId;
|
|
5004
5255
|
listeners = new Set;
|
|
5005
5256
|
pendingEvents = [];
|
|
@@ -5010,18 +5261,20 @@ class ACPSession {
|
|
|
5010
5261
|
completionPromise;
|
|
5011
5262
|
completionResolve;
|
|
5012
5263
|
ephemeralTokenId = null;
|
|
5013
|
-
constructor(connection, client2, process2, config, sessionId, providerMeta, ephemeralTokenId) {
|
|
5264
|
+
constructor(connection, client2, process2, config, sessionId, providerName, target, providerMeta, ephemeralTokenId) {
|
|
5014
5265
|
this.connection = connection;
|
|
5015
5266
|
this.client = client2;
|
|
5016
5267
|
this.process = process2;
|
|
5017
5268
|
this.config = config;
|
|
5269
|
+
this.providerName = providerName;
|
|
5270
|
+
this.target = target;
|
|
5018
5271
|
this.sessionId = sessionId;
|
|
5019
5272
|
this.ephemeralTokenId = ephemeralTokenId ?? null;
|
|
5020
5273
|
this.completionPromise = new Promise((resolve) => {
|
|
5021
5274
|
this.completionResolve = resolve;
|
|
5022
5275
|
});
|
|
5023
5276
|
this.consumeStderr();
|
|
5024
|
-
this.emit({ type: "session_init", sessionId, provider:
|
|
5277
|
+
this.emit({ type: "session_init", sessionId, provider: providerName, providerMeta });
|
|
5025
5278
|
this.runPrompt();
|
|
5026
5279
|
}
|
|
5027
5280
|
onEvent(listener) {
|
|
@@ -5039,6 +5292,7 @@ class ACPSession {
|
|
|
5039
5292
|
this.aborted = true;
|
|
5040
5293
|
try {
|
|
5041
5294
|
await this.connection.cancel({ sessionId: this.sessionId });
|
|
5295
|
+
await Promise.race([this.completionPromise, Bun.sleep(ACP_CANCEL_SETTLE_MS)]);
|
|
5042
5296
|
} catch (err) {
|
|
5043
5297
|
this.emit({
|
|
5044
5298
|
type: "error",
|
|
@@ -5098,8 +5352,11 @@ class ACPSession {
|
|
|
5098
5352
|
}
|
|
5099
5353
|
})
|
|
5100
5354
|
});
|
|
5355
|
+
const context = this.target.promptContext?.(response._meta, this.config.model);
|
|
5356
|
+
if (context)
|
|
5357
|
+
this.emit(context);
|
|
5101
5358
|
const isError = response.stopReason === "refusal" || response.stopReason === "cancelled";
|
|
5102
|
-
const cost = this.buildCostData(isError, response.usage);
|
|
5359
|
+
const cost = this.buildCostData(isError, response.usage, response._meta);
|
|
5103
5360
|
result = {
|
|
5104
5361
|
exitCode: isError ? 1 : 0,
|
|
5105
5362
|
sessionId: this.sessionId,
|
|
@@ -5110,7 +5367,7 @@ class ACPSession {
|
|
|
5110
5367
|
};
|
|
5111
5368
|
this.emit({ type: "result", cost, output: this.output, isError });
|
|
5112
5369
|
} catch (err) {
|
|
5113
|
-
const message = scrubSecrets(formatError(err));
|
|
5370
|
+
const message = describeTargetError(this.target, scrubSecrets(formatError(err)));
|
|
5114
5371
|
this.emit({ type: "error", message, category: "protocol" });
|
|
5115
5372
|
result = {
|
|
5116
5373
|
exitCode: 1,
|
|
@@ -5135,12 +5392,16 @@ class ACPSession {
|
|
|
5135
5392
|
if (done)
|
|
5136
5393
|
break;
|
|
5137
5394
|
if (value.length > 0) {
|
|
5138
|
-
this.emit({
|
|
5395
|
+
this.emit({
|
|
5396
|
+
type: "raw_stderr",
|
|
5397
|
+
content: scrubSecrets(Bun.stripANSI(decoder.decode(value)))
|
|
5398
|
+
});
|
|
5139
5399
|
}
|
|
5140
5400
|
}
|
|
5141
5401
|
} catch {}
|
|
5142
5402
|
}
|
|
5143
|
-
buildCostData(isError, usage) {
|
|
5403
|
+
buildCostData(isError, usage, responseMeta) {
|
|
5404
|
+
const targetCost = this.target.promptCost?.(responseMeta, this.config.model);
|
|
5144
5405
|
return {
|
|
5145
5406
|
sessionId: this.sessionId,
|
|
5146
5407
|
taskId: this.config.taskId,
|
|
@@ -5154,7 +5415,8 @@ class ACPSession {
|
|
|
5154
5415
|
numTurns: 1,
|
|
5155
5416
|
model: this.config.model,
|
|
5156
5417
|
isError,
|
|
5157
|
-
provider:
|
|
5418
|
+
provider: this.providerName,
|
|
5419
|
+
...targetCost
|
|
5158
5420
|
};
|
|
5159
5421
|
}
|
|
5160
5422
|
finish(result) {
|
|
@@ -5169,24 +5431,41 @@ class ACPSession {
|
|
|
5169
5431
|
}
|
|
5170
5432
|
|
|
5171
5433
|
class ACPAdapter {
|
|
5172
|
-
|
|
5434
|
+
options;
|
|
5435
|
+
name;
|
|
5173
5436
|
traits = {
|
|
5174
5437
|
hasMcp: true,
|
|
5175
5438
|
hasToolSearch: false,
|
|
5176
5439
|
hasLocalEnvironment: true
|
|
5177
5440
|
};
|
|
5441
|
+
constructor(options = {}) {
|
|
5442
|
+
this.options = options;
|
|
5443
|
+
this.name = options.providerName ?? "acp";
|
|
5444
|
+
}
|
|
5178
5445
|
async createSession(config) {
|
|
5179
|
-
const target = resolveAcpTarget(config);
|
|
5446
|
+
const target = this.options.target ?? resolveAcpTarget(config);
|
|
5180
5447
|
await target.writeSystemPromptArtifact(config);
|
|
5181
|
-
const
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5448
|
+
const cleanupArtifact = async () => {
|
|
5449
|
+
try {
|
|
5450
|
+
await target.cleanupSystemPromptArtifact?.(config);
|
|
5451
|
+
} catch (err) {
|
|
5452
|
+
console.warn(`\x1B[33m[acp]\x1B[0m System prompt cleanup failed: ${formatError(err)}`);
|
|
5453
|
+
}
|
|
5454
|
+
};
|
|
5455
|
+
let proc;
|
|
5456
|
+
try {
|
|
5457
|
+
proc = registerProcessGroup(Bun.spawn(target.command(config), {
|
|
5458
|
+
cwd: config.cwd,
|
|
5459
|
+
detached: detachedProcessGroup,
|
|
5460
|
+
env: target.env(config),
|
|
5461
|
+
stdin: "pipe",
|
|
5462
|
+
stdout: "pipe",
|
|
5463
|
+
stderr: "pipe"
|
|
5464
|
+
}));
|
|
5465
|
+
} catch (err) {
|
|
5466
|
+
await cleanupArtifact();
|
|
5467
|
+
throw err;
|
|
5468
|
+
}
|
|
5190
5469
|
let session = null;
|
|
5191
5470
|
const preSessionEvents = [];
|
|
5192
5471
|
const client2 = new SwarmAcpClient((event) => {
|
|
@@ -5194,7 +5473,7 @@ class ACPAdapter {
|
|
|
5194
5473
|
session.emitFromAcp(event);
|
|
5195
5474
|
else
|
|
5196
5475
|
preSessionEvents.push(event);
|
|
5197
|
-
});
|
|
5476
|
+
}, target);
|
|
5198
5477
|
const stream = ndJsonStream2(fileSinkWritableStream(proc.stdin), proc.stdout);
|
|
5199
5478
|
const connection = new ClientSideConnection(() => client2, stream);
|
|
5200
5479
|
let ephemeralToken = null;
|
|
@@ -5206,7 +5485,9 @@ class ACPAdapter {
|
|
|
5206
5485
|
});
|
|
5207
5486
|
ephemeralToken = await mintAcpSessionToken(config.apiUrl, config.apiKey, config.agentId, config.taskId);
|
|
5208
5487
|
const installedServers = await fetchInstalledMcpServers(config.apiUrl, config.apiKey, config.agentId, "claude");
|
|
5488
|
+
const sessionMeta = target.sessionMeta?.(config);
|
|
5209
5489
|
const newSession = await connection.newSession({
|
|
5490
|
+
...sessionMeta ? { _meta: sessionMeta } : {},
|
|
5210
5491
|
cwd: config.cwd,
|
|
5211
5492
|
mcpServers: [
|
|
5212
5493
|
{
|
|
@@ -5223,19 +5504,21 @@ class ACPAdapter {
|
|
|
5223
5504
|
]
|
|
5224
5505
|
});
|
|
5225
5506
|
const configOptions = await applyConfiguredOptions(connection, newSession.sessionId, newSession.configOptions ?? [], target.configuredOptions(config));
|
|
5226
|
-
session = new ACPSession(connection, client2, proc, config, newSession.sessionId, {
|
|
5507
|
+
session = new ACPSession(connection, client2, proc, config, newSession.sessionId, this.name, target, {
|
|
5227
5508
|
target: target.target,
|
|
5228
5509
|
configOptions: sanitizeAcpConfigOptions(configOptions)
|
|
5229
5510
|
}, ephemeralToken.tokenId);
|
|
5230
5511
|
for (const event of preSessionEvents)
|
|
5231
5512
|
session.emitFromAcp(event);
|
|
5513
|
+
session.waitForCompletion().finally(cleanupArtifact);
|
|
5232
5514
|
return session;
|
|
5233
5515
|
} catch (err) {
|
|
5234
5516
|
if (ephemeralToken && !session) {
|
|
5235
5517
|
revokeAcpSessionToken(config.apiUrl, config.apiKey, ephemeralToken.tokenId);
|
|
5236
5518
|
}
|
|
5237
5519
|
await terminateProcessGroup(proc.pid);
|
|
5238
|
-
|
|
5520
|
+
await cleanupArtifact();
|
|
5521
|
+
throw new Error(`ACP target failed during startup: ${describeTargetError(target, scrubSecrets(formatError(err)))}`);
|
|
5239
5522
|
}
|
|
5240
5523
|
}
|
|
5241
5524
|
async canResume(_sessionId) {
|
|
@@ -5335,6 +5618,9 @@ function toAcpMcpServers(installed) {
|
|
|
5335
5618
|
}
|
|
5336
5619
|
return servers;
|
|
5337
5620
|
}
|
|
5621
|
+
function describeTargetError(target, message) {
|
|
5622
|
+
return target.describeError?.(message) ?? message;
|
|
5623
|
+
}
|
|
5338
5624
|
function formatError(err) {
|
|
5339
5625
|
return err instanceof Error ? err.message : String(err);
|
|
5340
5626
|
}
|
|
@@ -5352,9 +5638,5 @@ function fileSinkWritableStream(sink) {
|
|
|
5352
5638
|
}
|
|
5353
5639
|
});
|
|
5354
5640
|
}
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
applyConfiguredOptions,
|
|
5358
|
-
sanitizeAcpConfigOptions,
|
|
5359
|
-
toAcpMcpServers
|
|
5360
|
-
};
|
|
5641
|
+
|
|
5642
|
+
export { isGrokOpenRouterModel, grokTargetProfile, ACPAdapter, applyConfiguredOptions, sanitizeAcpConfigOptions, toAcpMcpServers };
|