@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
package/src/prompts/memories.ts
CHANGED
|
@@ -19,8 +19,46 @@ export type RelevantMemory = {
|
|
|
19
19
|
content: string;
|
|
20
20
|
similarity: number;
|
|
21
21
|
rawSimilarity?: number;
|
|
22
|
+
/** Memory provenance (`task_completion`, `manual`, ...). Older servers omit it. */
|
|
23
|
+
source?: string;
|
|
24
|
+
summary?: string | null;
|
|
25
|
+
createdAt?: string;
|
|
22
26
|
};
|
|
23
27
|
|
|
28
|
+
const SNIPPET_CHARS = 300;
|
|
29
|
+
const OUTPUT_MARKER = "\n\nOutput:\n";
|
|
30
|
+
const FAILURE_MARKER = "\n\nFailure reason:\n";
|
|
31
|
+
const FAILURE_SUFFIX = "\n\nThis task failed. Learn from this to avoid repeating the mistake.";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The text a memory line shows: its `summary` when set, else, for a
|
|
35
|
+
* `task_completion` row, the outcome after `Output:` / `Failure reason:`
|
|
36
|
+
* instead of the start of the old task prompt. The last marker wins because a
|
|
37
|
+
* follow-up task prompt can itself embed an earlier worker's `Output:` block.
|
|
38
|
+
*/
|
|
39
|
+
export function memorySnippet(memory: RelevantMemory): string {
|
|
40
|
+
const summary = memory.summary?.trim();
|
|
41
|
+
if (summary) return summary;
|
|
42
|
+
const { content } = memory;
|
|
43
|
+
if (memory.source !== "task_completion") return content;
|
|
44
|
+
|
|
45
|
+
const outputAt = content.lastIndexOf(OUTPUT_MARKER);
|
|
46
|
+
const failureAt = content.lastIndexOf(FAILURE_MARKER);
|
|
47
|
+
if (outputAt === -1 && failureAt === -1) return content;
|
|
48
|
+
if (outputAt > failureAt) return content.slice(outputAt + OUTPUT_MARKER.length).trim();
|
|
49
|
+
|
|
50
|
+
let reason = content.slice(failureAt + FAILURE_MARKER.length);
|
|
51
|
+
if (reason.endsWith(FAILURE_SUFFIX)) reason = reason.slice(0, -FAILURE_SUFFIX.length);
|
|
52
|
+
return `FAILED: ${reason.trim()}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** `[2026-09-29, task_completion] ` from whatever of createdAt/source the server sent. */
|
|
56
|
+
function memoryLinePrefix(memory: RelevantMemory): string {
|
|
57
|
+
const date = /^\d{4}-\d{2}-\d{2}/.exec(memory.createdAt ?? "")?.[0];
|
|
58
|
+
const parts = [date, memory.source].filter(Boolean);
|
|
59
|
+
return parts.length > 0 ? `[${parts.join(", ")}] ` : "";
|
|
60
|
+
}
|
|
61
|
+
|
|
24
62
|
/**
|
|
25
63
|
* Minimum pre-boost relevance for a memory to be injected into a task prompt.
|
|
26
64
|
*
|
|
@@ -56,7 +94,10 @@ export function renderMemoriesPrompt(memories: RelevantMemory[]): string | null
|
|
|
56
94
|
if (useful.length === 0) return null;
|
|
57
95
|
|
|
58
96
|
const memoryContext = useful
|
|
59
|
-
.map(
|
|
97
|
+
.map(
|
|
98
|
+
(m) =>
|
|
99
|
+
`- ${memoryLinePrefix(m)}**${m.name}** (id: ${m.id}): ${memorySnippet(m).substring(0, SNIPPET_CHARS)}`,
|
|
100
|
+
)
|
|
60
101
|
.join("\n");
|
|
61
102
|
|
|
62
103
|
let prompt = `\n\n### Relevant Past Knowledge\n\nThese memories from your previous sessions may be useful. Use \`memory-get\` with the memory ID to retrieve full details.\n\n${memoryContext}\n`;
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "../utils/process-group";
|
|
22
22
|
import { scrubSecrets } from "../utils/secret-scrubber";
|
|
23
23
|
import { acpReportedCostUsd, translateAcpSessionNotification } from "./acp-swarm-events";
|
|
24
|
-
import { resolveAcpTarget } from "./acp-targets";
|
|
24
|
+
import { type AcpTargetProfile, resolveAcpTarget } from "./acp-targets";
|
|
25
25
|
import type {
|
|
26
26
|
CostData,
|
|
27
27
|
ProviderAdapter,
|
|
@@ -33,7 +33,15 @@ import type {
|
|
|
33
33
|
} from "./types";
|
|
34
34
|
|
|
35
35
|
type EventListener = (event: ProviderEvent) => void;
|
|
36
|
+
/** Providers that run on this ACP client. */
|
|
37
|
+
export type AcpProviderName = "acp" | "grok";
|
|
36
38
|
const ACP_LOG_MAX_CHARS = 30_000;
|
|
39
|
+
/**
|
|
40
|
+
* How long an abort waits after `session/cancel` for the prompt to answer
|
|
41
|
+
* `cancelled`. That answer carries the turn's usage (Grok's `_meta.usage`),
|
|
42
|
+
* so killing the process first would drop the session's cost row.
|
|
43
|
+
*/
|
|
44
|
+
const ACP_CANCEL_SETTLE_MS = 3_000;
|
|
37
45
|
const ACP_LOG_FIELD_MAX_CHARS = 12_000;
|
|
38
46
|
const ACP_LOG_PREVIEW_MAX_CHARS = 10_000;
|
|
39
47
|
const CREDENTIAL_HEADER_NAMES = new Set([
|
|
@@ -150,7 +158,10 @@ class SwarmAcpClient implements Client {
|
|
|
150
158
|
/** Latest cumulative USD cost the target reported for the session. */
|
|
151
159
|
reportedCostUsd: number | null = null;
|
|
152
160
|
|
|
153
|
-
constructor(
|
|
161
|
+
constructor(
|
|
162
|
+
private readonly emit: (event: ProviderEvent) => void,
|
|
163
|
+
private readonly target?: AcpTargetProfile,
|
|
164
|
+
) {}
|
|
154
165
|
|
|
155
166
|
async requestPermission(params: RequestPermissionRequest): Promise<RequestPermissionResponse> {
|
|
156
167
|
const selected =
|
|
@@ -166,7 +177,7 @@ class SwarmAcpClient implements Client {
|
|
|
166
177
|
const costUsd = acpReportedCostUsd(params.update);
|
|
167
178
|
if (costUsd !== null) this.reportedCostUsd = costUsd;
|
|
168
179
|
for (const event of translateAcpSessionNotification(params)) {
|
|
169
|
-
this.emit(event);
|
|
180
|
+
this.emit(this.target?.rewriteEvent?.(event) ?? event);
|
|
170
181
|
}
|
|
171
182
|
}
|
|
172
183
|
}
|
|
@@ -193,6 +204,8 @@ class ACPSession implements ProviderSession {
|
|
|
193
204
|
private readonly process: Bun.Subprocess<"pipe", "pipe", "pipe">,
|
|
194
205
|
private readonly config: ProviderSessionConfig,
|
|
195
206
|
sessionId: string,
|
|
207
|
+
private readonly providerName: AcpProviderName,
|
|
208
|
+
private readonly target: AcpTargetProfile,
|
|
196
209
|
providerMeta?: Record<string, unknown>,
|
|
197
210
|
ephemeralTokenId?: string,
|
|
198
211
|
) {
|
|
@@ -202,7 +215,7 @@ class ACPSession implements ProviderSession {
|
|
|
202
215
|
this.completionResolve = resolve;
|
|
203
216
|
});
|
|
204
217
|
void this.consumeStderr();
|
|
205
|
-
this.emit({ type: "session_init", sessionId, provider:
|
|
218
|
+
this.emit({ type: "session_init", sessionId, provider: providerName, providerMeta });
|
|
206
219
|
void this.runPrompt();
|
|
207
220
|
}
|
|
208
221
|
|
|
@@ -222,6 +235,7 @@ class ACPSession implements ProviderSession {
|
|
|
222
235
|
this.aborted = true;
|
|
223
236
|
try {
|
|
224
237
|
await this.connection.cancel({ sessionId: this.sessionId });
|
|
238
|
+
await Promise.race([this.completionPromise, Bun.sleep(ACP_CANCEL_SETTLE_MS)]);
|
|
225
239
|
} catch (err) {
|
|
226
240
|
this.emit({
|
|
227
241
|
type: "error",
|
|
@@ -285,8 +299,10 @@ class ACPSession implements ProviderSession {
|
|
|
285
299
|
},
|
|
286
300
|
}),
|
|
287
301
|
});
|
|
302
|
+
const context = this.target.promptContext?.(response._meta, this.config.model);
|
|
303
|
+
if (context) this.emit(context);
|
|
288
304
|
const isError = response.stopReason === "refusal" || response.stopReason === "cancelled";
|
|
289
|
-
const cost = this.buildCostData(isError, response.usage);
|
|
305
|
+
const cost = this.buildCostData(isError, response.usage, response._meta);
|
|
290
306
|
result = {
|
|
291
307
|
exitCode: isError ? 1 : 0,
|
|
292
308
|
sessionId: this.sessionId,
|
|
@@ -297,7 +313,7 @@ class ACPSession implements ProviderSession {
|
|
|
297
313
|
};
|
|
298
314
|
this.emit({ type: "result", cost, output: this.output, isError });
|
|
299
315
|
} catch (err) {
|
|
300
|
-
const message = scrubSecrets(formatError(err));
|
|
316
|
+
const message = describeTargetError(this.target, scrubSecrets(formatError(err)));
|
|
301
317
|
this.emit({ type: "error", message, category: "protocol" });
|
|
302
318
|
result = {
|
|
303
319
|
exitCode: 1,
|
|
@@ -321,7 +337,11 @@ class ACPSession implements ProviderSession {
|
|
|
321
337
|
const { done, value } = await reader.read();
|
|
322
338
|
if (done) break;
|
|
323
339
|
if (value.length > 0) {
|
|
324
|
-
|
|
340
|
+
// Targets such as Grok color their tracing output; the log view shows text.
|
|
341
|
+
this.emit({
|
|
342
|
+
type: "raw_stderr",
|
|
343
|
+
content: scrubSecrets(Bun.stripANSI(decoder.decode(value))),
|
|
344
|
+
});
|
|
325
345
|
}
|
|
326
346
|
}
|
|
327
347
|
} catch {
|
|
@@ -329,7 +349,12 @@ class ACPSession implements ProviderSession {
|
|
|
329
349
|
}
|
|
330
350
|
}
|
|
331
351
|
|
|
332
|
-
private buildCostData(
|
|
352
|
+
private buildCostData(
|
|
353
|
+
isError: boolean,
|
|
354
|
+
usage?: Usage | null,
|
|
355
|
+
responseMeta?: Record<string, unknown> | null,
|
|
356
|
+
): CostData {
|
|
357
|
+
const targetCost = this.target.promptCost?.(responseMeta, this.config.model);
|
|
333
358
|
return {
|
|
334
359
|
sessionId: this.sessionId,
|
|
335
360
|
taskId: this.config.taskId,
|
|
@@ -345,7 +370,8 @@ class ACPSession implements ProviderSession {
|
|
|
345
370
|
numTurns: 1,
|
|
346
371
|
model: this.config.model,
|
|
347
372
|
isError,
|
|
348
|
-
provider:
|
|
373
|
+
provider: this.providerName,
|
|
374
|
+
...targetCost,
|
|
349
375
|
};
|
|
350
376
|
}
|
|
351
377
|
|
|
@@ -361,8 +387,15 @@ class ACPSession implements ProviderSession {
|
|
|
361
387
|
}
|
|
362
388
|
}
|
|
363
389
|
|
|
390
|
+
export interface ACPAdapterOptions {
|
|
391
|
+
/** Provider recorded on session_init and cost rows. Defaults to `acp`. */
|
|
392
|
+
providerName?: AcpProviderName;
|
|
393
|
+
/** A fixed target profile. Defaults to the `ACP_TARGET` resolution. */
|
|
394
|
+
target?: AcpTargetProfile;
|
|
395
|
+
}
|
|
396
|
+
|
|
364
397
|
export class ACPAdapter implements ProviderAdapter {
|
|
365
|
-
readonly name
|
|
398
|
+
readonly name: AcpProviderName;
|
|
366
399
|
|
|
367
400
|
readonly traits: ProviderTraits = {
|
|
368
401
|
hasMcp: true,
|
|
@@ -370,27 +403,43 @@ export class ACPAdapter implements ProviderAdapter {
|
|
|
370
403
|
hasLocalEnvironment: true,
|
|
371
404
|
};
|
|
372
405
|
|
|
406
|
+
constructor(private readonly options: ACPAdapterOptions = {}) {
|
|
407
|
+
this.name = options.providerName ?? "acp";
|
|
408
|
+
}
|
|
409
|
+
|
|
373
410
|
async createSession(config: ProviderSessionConfig): Promise<ProviderSession> {
|
|
374
|
-
const target = resolveAcpTarget(config);
|
|
411
|
+
const target = this.options.target ?? resolveAcpTarget(config);
|
|
375
412
|
await target.writeSystemPromptArtifact(config);
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
413
|
+
const cleanupArtifact = async () => {
|
|
414
|
+
try {
|
|
415
|
+
await target.cleanupSystemPromptArtifact?.(config);
|
|
416
|
+
} catch (err) {
|
|
417
|
+
console.warn(`\x1b[33m[acp]\x1b[0m System prompt cleanup failed: ${formatError(err)}`);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
let proc: Bun.Subprocess<"pipe", "pipe", "pipe">;
|
|
421
|
+
try {
|
|
422
|
+
proc = registerProcessGroup(
|
|
423
|
+
Bun.spawn(target.command(config), {
|
|
424
|
+
cwd: config.cwd,
|
|
425
|
+
detached: detachedProcessGroup,
|
|
426
|
+
env: target.env(config),
|
|
427
|
+
stdin: "pipe",
|
|
428
|
+
stdout: "pipe",
|
|
429
|
+
stderr: "pipe",
|
|
430
|
+
}),
|
|
431
|
+
);
|
|
432
|
+
} catch (err) {
|
|
433
|
+
await cleanupArtifact();
|
|
434
|
+
throw err;
|
|
435
|
+
}
|
|
387
436
|
|
|
388
437
|
let session: ACPSession | null = null;
|
|
389
438
|
const preSessionEvents: ProviderEvent[] = [];
|
|
390
439
|
const client = new SwarmAcpClient((event) => {
|
|
391
440
|
if (session) session.emitFromAcp(event);
|
|
392
441
|
else preSessionEvents.push(event);
|
|
393
|
-
});
|
|
442
|
+
}, target);
|
|
394
443
|
const stream = ndJsonStream(fileSinkWritableStream(proc.stdin), proc.stdout);
|
|
395
444
|
const connection = new ClientSideConnection(() => client, stream);
|
|
396
445
|
|
|
@@ -423,7 +472,9 @@ export class ACPAdapter implements ProviderAdapter {
|
|
|
423
472
|
// (mcp/connect, mcp/message, mcp/disconnect) instead of a network hop -- the
|
|
424
473
|
// shape for an ACP agent with no network route to the swarm API. Gated on
|
|
425
474
|
// `mcpCapabilities.acp` and UNSTABLE; not adopted here.
|
|
475
|
+
const sessionMeta = target.sessionMeta?.(config);
|
|
426
476
|
const newSession = await connection.newSession({
|
|
477
|
+
...(sessionMeta ? { _meta: sessionMeta } : {}),
|
|
427
478
|
cwd: config.cwd,
|
|
428
479
|
mcpServers: [
|
|
429
480
|
{
|
|
@@ -451,6 +502,8 @@ export class ACPAdapter implements ProviderAdapter {
|
|
|
451
502
|
proc,
|
|
452
503
|
config,
|
|
453
504
|
newSession.sessionId,
|
|
505
|
+
this.name,
|
|
506
|
+
target,
|
|
454
507
|
{
|
|
455
508
|
target: target.target,
|
|
456
509
|
configOptions: sanitizeAcpConfigOptions(configOptions),
|
|
@@ -458,6 +511,7 @@ export class ACPAdapter implements ProviderAdapter {
|
|
|
458
511
|
ephemeralToken.tokenId,
|
|
459
512
|
);
|
|
460
513
|
for (const event of preSessionEvents) session.emitFromAcp(event);
|
|
514
|
+
void session.waitForCompletion().finally(cleanupArtifact);
|
|
461
515
|
return session;
|
|
462
516
|
} catch (err) {
|
|
463
517
|
// Revoke the ephemeral token before re-throwing if ACPSession has not yet
|
|
@@ -467,7 +521,10 @@ export class ACPAdapter implements ProviderAdapter {
|
|
|
467
521
|
void revokeAcpSessionToken(config.apiUrl, config.apiKey, ephemeralToken.tokenId);
|
|
468
522
|
}
|
|
469
523
|
await terminateProcessGroup(proc.pid);
|
|
470
|
-
|
|
524
|
+
await cleanupArtifact();
|
|
525
|
+
throw new Error(
|
|
526
|
+
`ACP target failed during startup: ${describeTargetError(target, scrubSecrets(formatError(err)))}`,
|
|
527
|
+
);
|
|
471
528
|
}
|
|
472
529
|
}
|
|
473
530
|
|
|
@@ -603,6 +660,10 @@ export function toAcpMcpServers(
|
|
|
603
660
|
return servers;
|
|
604
661
|
}
|
|
605
662
|
|
|
663
|
+
function describeTargetError(target: AcpTargetProfile, message: string): string {
|
|
664
|
+
return target.describeError?.(message) ?? message;
|
|
665
|
+
}
|
|
666
|
+
|
|
606
667
|
function formatError(err: unknown): string {
|
|
607
668
|
return err instanceof Error ? err.message : String(err);
|
|
608
669
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const ACP_TARGET_IDS = ["opencode", "custom"] as const;
|
|
1
|
+
export const ACP_TARGET_IDS = ["opencode", "gemini", "copilot", "custom"] as const;
|
|
2
2
|
|
|
3
3
|
export type AcpTarget = (typeof ACP_TARGET_IDS)[number];
|
|
4
4
|
|
|
@@ -42,6 +42,59 @@ export const ACP_TARGET_CATALOG: readonly AcpTargetCatalogEntry[] = [
|
|
|
42
42
|
],
|
|
43
43
|
knobs: [{ id: "model", label: "Model", category: "model" }],
|
|
44
44
|
},
|
|
45
|
+
{
|
|
46
|
+
id: "gemini",
|
|
47
|
+
label: "Gemini CLI",
|
|
48
|
+
description: "Google's Gemini CLI, launched with `gemini --acp`.",
|
|
49
|
+
command: "gemini",
|
|
50
|
+
args: ["--acp"],
|
|
51
|
+
envKeys: [
|
|
52
|
+
"GEMINI_API_KEY",
|
|
53
|
+
"GOOGLE_API_KEY",
|
|
54
|
+
"GOOGLE_GENAI_USE_VERTEXAI",
|
|
55
|
+
"GOOGLE_CLOUD_PROJECT",
|
|
56
|
+
"GOOGLE_CLOUD_LOCATION",
|
|
57
|
+
"GOOGLE_APPLICATION_CREDENTIALS",
|
|
58
|
+
"GOOGLE_GEMINI_BASE_URL",
|
|
59
|
+
"GOOGLE_VERTEX_BASE_URL",
|
|
60
|
+
"GEMINI_CLI_HOME",
|
|
61
|
+
],
|
|
62
|
+
knobs: [{ id: "model", label: "Model", category: "model" }],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "copilot",
|
|
66
|
+
label: "GitHub Copilot CLI",
|
|
67
|
+
description:
|
|
68
|
+
"GitHub Copilot CLI's ACP server, launched with `copilot --acp`. Uses a Copilot-entitled COPILOT_GITHUB_TOKEN, or a BYOK provider via COPILOT_PROVIDER_*.",
|
|
69
|
+
command: "copilot",
|
|
70
|
+
args: ["--acp"],
|
|
71
|
+
envKeys: [
|
|
72
|
+
"COPILOT_GITHUB_TOKEN",
|
|
73
|
+
"COPILOT_GH_HOST",
|
|
74
|
+
"GH_HOST",
|
|
75
|
+
"COPILOT_HOME",
|
|
76
|
+
"COPILOT_MODEL",
|
|
77
|
+
"COPILOT_AUTO_TIER",
|
|
78
|
+
"COPILOT_OFFLINE",
|
|
79
|
+
"COPILOT_PROVIDER_BASE_URL",
|
|
80
|
+
"COPILOT_PROVIDER_TYPE",
|
|
81
|
+
"COPILOT_PROVIDER_API_KEY",
|
|
82
|
+
"COPILOT_PROVIDER_API_KEY_COMMAND",
|
|
83
|
+
"COPILOT_PROVIDER_BEARER_TOKEN",
|
|
84
|
+
"COPILOT_PROVIDER_WIRE_API",
|
|
85
|
+
"COPILOT_PROVIDER_TRANSPORT",
|
|
86
|
+
"COPILOT_PROVIDER_AZURE_API_VERSION",
|
|
87
|
+
"COPILOT_PROVIDER_MODEL_ID",
|
|
88
|
+
"COPILOT_PROVIDER_WIRE_MODEL",
|
|
89
|
+
"COPILOT_PROVIDER_MAX_PROMPT_TOKENS",
|
|
90
|
+
"COPILOT_PROVIDER_MAX_OUTPUT_TOKENS",
|
|
91
|
+
"COPILOT_PROVIDER_HEADERS",
|
|
92
|
+
"HTTP_PROXY",
|
|
93
|
+
"HTTPS_PROXY",
|
|
94
|
+
"NO_PROXY",
|
|
95
|
+
],
|
|
96
|
+
knobs: [{ id: "model", label: "Model", category: "model" }],
|
|
97
|
+
},
|
|
45
98
|
{
|
|
46
99
|
id: "custom",
|
|
47
100
|
label: "Custom",
|