@zvada/agent-server 0.3.22 → 0.3.24
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/CHANGELOG.md +295 -0
- package/README.md +14 -5
- package/dist/accounts/chatgpt.js +144 -0
- package/dist/accounts/check.js +71 -0
- package/dist/accounts/claude.js +80 -0
- package/dist/accounts/endpoint.js +104 -0
- package/dist/accounts/http.js +58 -0
- package/dist/accounts/index.js +9 -0
- package/dist/client/client.js +686 -0
- package/dist/client/connection.js +338 -0
- package/dist/client/history.js +49 -0
- package/dist/client/index.js +6 -0
- package/dist/client/listeners.js +19 -0
- package/dist/client/logins.js +92 -0
- package/dist/client/rpc.js +105 -0
- package/dist/client/streams.js +432 -0
- package/dist/client/transports.js +118 -0
- package/dist/client/turns.js +122 -0
- package/dist/core/agents/acp/acp-agent.js +425 -0
- package/dist/core/agents/acp/adapter.js +231 -0
- package/dist/core/agents/acp/client.js +222 -0
- package/dist/core/agents/acp/known-agents.js +57 -0
- package/dist/core/agents/acp/mappings.js +164 -0
- package/dist/core/agents/acp/requests.js +79 -0
- package/dist/core/agents/attachments.js +14 -0
- package/dist/core/agents/base.js +64 -0
- package/dist/core/agents/claude-code/adapter.js +474 -0
- package/dist/core/agents/claude-code/approvals.js +245 -0
- package/dist/core/agents/claude-code/claude-agent.js +319 -0
- package/dist/core/agents/claude-code/credentials.js +142 -0
- package/dist/core/agents/claude-code/events.js +11 -0
- package/dist/core/agents/claude-code/login.js +217 -0
- package/dist/core/agents/claude-code/mcp.js +181 -0
- package/dist/core/agents/claude-code/models.js +74 -0
- package/dist/core/agents/claude-code/options.js +240 -0
- package/dist/core/agents/claude-code/outcome.js +204 -0
- package/dist/core/agents/claude-code/results.js +58 -0
- package/dist/core/agents/claude-code/sdk-pair.js +59 -0
- package/dist/core/agents/claude-code/session.js +593 -0
- package/dist/core/agents/claude-code/spawn.js +125 -0
- package/dist/core/agents/claude-code/spend.js +118 -0
- package/dist/core/agents/claude-code/tools.js +131 -0
- package/dist/core/agents/claude-code/turn-usage.js +121 -0
- package/dist/core/agents/claude-code/turn.js +199 -0
- package/dist/core/agents/codex-app-server/adapter.js +463 -0
- package/dist/core/agents/codex-app-server/client.js +338 -0
- package/dist/core/agents/codex-app-server/codex-agent.js +294 -0
- package/dist/core/agents/codex-app-server/commands.js +184 -0
- package/dist/core/agents/codex-app-server/credentials.js +92 -0
- package/dist/core/agents/codex-app-server/effort.js +13 -0
- package/dist/core/agents/codex-app-server/events.js +18 -0
- package/dist/core/agents/codex-app-server/homes.js +118 -0
- package/dist/core/agents/codex-app-server/input.js +52 -0
- package/dist/core/agents/codex-app-server/items.js +307 -0
- package/dist/core/agents/codex-app-server/login.js +183 -0
- package/dist/core/agents/codex-app-server/mcp.js +323 -0
- package/dist/core/agents/codex-app-server/models.js +160 -0
- package/dist/core/agents/codex-app-server/options.js +155 -0
- package/dist/core/agents/codex-app-server/plan-approval.js +124 -0
- package/dist/core/agents/codex-app-server/protocol.js +38 -0
- package/dist/core/agents/codex-app-server/requests.js +250 -0
- package/dist/core/agents/codex-app-server/session.js +278 -0
- package/dist/core/agents/codex-app-server/subagents.js +260 -0
- package/dist/core/agents/codex-app-server/thread-settings.js +214 -0
- package/dist/core/agents/codex-app-server/turn-items.js +69 -0
- package/dist/core/agents/codex-app-server/turn.js +448 -0
- package/dist/core/agents/codex-app-server/user-login.js +78 -0
- package/dist/core/agents/config-fingerprint.js +10 -0
- package/dist/core/agents/credentials.js +71 -0
- package/dist/core/agents/diffs.js +27 -0
- package/dist/core/agents/elicitation.js +42 -0
- package/dist/core/agents/inherit-config.js +5 -0
- package/dist/core/agents/login.js +56 -0
- package/dist/core/agents/mcp-config.js +109 -0
- package/dist/core/agents/plan.js +6 -0
- package/dist/core/agents/process-pool.js +307 -0
- package/dist/core/agents/registry.js +49 -0
- package/dist/core/agents/scripted/adapter.js +86 -0
- package/dist/core/agents/scripted/mcp-call.js +74 -0
- package/dist/core/agents/scripted/scripted-agent.js +330 -0
- package/dist/core/agents/scripted/scripts.js +154 -0
- package/dist/core/agents/scripted/steps.js +87 -0
- package/dist/core/agents/session-agent.js +209 -0
- package/dist/core/agents/stderr-tail.js +71 -0
- package/dist/core/agents/thinking-levels.js +9 -0
- package/dist/core/agents/types.js +1 -0
- package/dist/core/diagnostics.js +23 -0
- package/dist/core/index.js +31 -0
- package/dist/core/presets.js +114 -0
- package/dist/core/processes/identity.js +91 -0
- package/dist/core/processes/lifeline.js +210 -0
- package/dist/core/processes/native-processes.js +299 -0
- package/dist/core/processes/process-table.js +163 -0
- package/dist/core/provision/cache-trust.js +121 -0
- package/dist/core/provision/cache-usage.js +61 -0
- package/dist/core/provision/checksums.js +22 -0
- package/dist/core/provision/extract.js +28 -0
- package/dist/core/provision/index.js +4 -0
- package/dist/core/provision/install-build.js +99 -0
- package/dist/core/provision/npm.js +316 -0
- package/dist/core/provision/pins.js +35 -0
- package/dist/core/provision/platform.js +65 -0
- package/dist/core/provision/provisioner.js +372 -0
- package/dist/core/provision/releases.js +68 -0
- package/dist/core/provision/tools.js +279 -0
- package/dist/core/proxy/anthropic-proxy.js +163 -0
- package/dist/core/proxy/api-key-store.js +30 -0
- package/dist/core/proxy/index.js +3 -0
- package/dist/core/proxy/loopback.js +86 -0
- package/dist/core/runtime/agent-runtime.js +434 -0
- package/dist/core/runtime/event-processor.js +379 -0
- package/dist/core/runtime/event-sink.js +65 -0
- package/dist/core/runtime/harness-clis.js +83 -0
- package/dist/core/runtime/harness-logins.js +313 -0
- package/dist/core/runtime/login-reads.js +71 -0
- package/dist/core/runtime/model-lists.js +160 -0
- package/dist/core/runtime/permission-policy.js +84 -0
- package/dist/core/runtime/request-broker.js +139 -0
- package/dist/core/runtime/steering.js +79 -0
- package/dist/core/runtime/turn-outcome.js +16 -0
- package/dist/core/runtime/turn.js +329 -0
- package/dist/core/utils/bounded.js +13 -0
- package/dist/core/utils/deadline.js +57 -0
- package/dist/core/utils/errors.js +176 -0
- package/dist/core/utils/is-record.js +4 -0
- package/dist/core/utils/loopback.js +11 -0
- package/dist/index.js +4 -0
- package/dist/operator/index.js +10 -0
- package/dist/operator/mcp.js +139 -0
- package/dist/operator/operator.js +499 -0
- package/dist/operator/render.js +408 -0
- package/dist/operator/view.js +35 -0
- package/dist/protocol/account.js +96 -0
- package/dist/protocol/async-queue.js +65 -0
- package/dist/protocol/auth.js +169 -0
- package/dist/protocol/canonical.js +18 -0
- package/dist/protocol/clis.js +63 -0
- package/dist/protocol/config.js +137 -0
- package/dist/protocol/conversation.js +231 -0
- package/dist/protocol/credentials.js +141 -0
- package/dist/protocol/errors.js +181 -0
- package/dist/protocol/execution.js +28 -0
- package/dist/protocol/factories.js +231 -0
- package/dist/protocol/guards.js +71 -0
- package/dist/protocol/harness.js +93 -0
- package/dist/protocol/history.js +201 -0
- package/dist/protocol/ids.js +37 -0
- package/dist/protocol/index.js +36 -0
- package/dist/protocol/lifecycle.js +562 -0
- package/dist/protocol/meta-keys.js +17 -0
- package/dist/protocol/meta.js +13 -0
- package/dist/protocol/model-catalog.js +223 -0
- package/dist/protocol/models.js +84 -0
- package/dist/protocol/part-input.js +94 -0
- package/dist/protocol/parts.js +166 -0
- package/dist/protocol/plan.js +31 -0
- package/dist/protocol/reduce.js +484 -0
- package/dist/protocol/selectors.js +136 -0
- package/dist/protocol/seq-cursor.js +37 -0
- package/dist/protocol/stop-reasons.js +41 -0
- package/dist/protocol/thinking.js +31 -0
- package/dist/protocol/time.js +21 -0
- package/dist/protocol/tokens.js +57 -0
- package/dist/protocol/tool-closure.js +70 -0
- package/dist/protocol/tool-state.js +153 -0
- package/dist/protocol/verify.js +467 -0
- package/dist/protocol/vocabulary.js +27 -0
- package/dist/protocol/wire-api.js +94 -0
- package/dist/protocol/wire.js +669 -0
- package/dist/server/acp/binding.js +251 -0
- package/dist/server/acp/session-records.js +53 -0
- package/dist/server/acp/translate.js +401 -0
- package/dist/server/agent-server.js +338 -0
- package/dist/server/bin.js +492 -0
- package/dist/server/feedback.js +216 -0
- package/dist/server/history.js +123 -0
- package/dist/server/index.js +8 -0
- package/dist/server/install.js +171 -0
- package/dist/server/open-parts.js +87 -0
- package/dist/server/routes.js +291 -0
- package/dist/server/secrets.js +19 -0
- package/dist/server/session-gate.js +54 -0
- package/dist/server/session-log.js +66 -0
- package/dist/server/session-store.js +243 -0
- package/dist/server/subscriptions.js +189 -0
- package/dist/server/transports.js +214 -0
- package/dist/server/wire-error.js +26 -0
- package/dist/sync/event-log.js +89 -0
- package/dist/sync/fit.js +202 -0
- package/dist/sync/history-reader.js +33 -0
- package/dist/sync/history-sqlite.js +281 -0
- package/dist/sync/history.js +163 -0
- package/dist/sync/index.js +5 -0
- package/dist/sync/journal-sqlite.js +316 -0
- package/dist/sync/journal.js +10 -0
- package/dist/sync/live-tails.js +85 -0
- package/dist/sync/node-sqlite.js +27 -0
- package/dist/sync/projection.js +32 -0
- package/dist/sync/recovery.js +117 -0
- package/dist/sync/retry.js +45 -0
- package/dist/sync/schema.js +73 -0
- package/dist/sync/sql.js +94 -0
- package/dist/sync/sqlite-file.js +31 -0
- package/dist/sync/sqlite.js +18 -0
- package/dist/sync/worker.js +212 -0
- package/dist/types/accounts/chatgpt.d.ts +1 -1
- package/dist/types/accounts/chatgpt.d.ts.map +1 -1
- package/dist/types/accounts/http.d.ts +2 -4
- package/dist/types/accounts/http.d.ts.map +1 -1
- package/dist/types/client/client.d.ts +37 -11
- package/dist/types/client/client.d.ts.map +1 -1
- package/dist/types/client/connection.d.ts +64 -13
- package/dist/types/client/connection.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +1 -1
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/logins.d.ts +2 -1
- package/dist/types/client/logins.d.ts.map +1 -1
- package/dist/types/client/streams.d.ts +9 -3
- package/dist/types/client/streams.d.ts.map +1 -1
- package/dist/types/client/turns.d.ts +1 -1
- package/dist/types/client/turns.d.ts.map +1 -1
- package/dist/types/core/agents/acp/acp-agent.d.ts +34 -1
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
- package/dist/types/core/agents/acp/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/acp/client.d.ts +12 -3
- package/dist/types/core/agents/acp/client.d.ts.map +1 -1
- package/dist/types/core/agents/acp/mappings.d.ts +8 -2
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
- package/dist/types/core/agents/base.d.ts +22 -8
- package/dist/types/core/agents/base.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/adapter.d.ts +7 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/approvals.d.ts +4 -1
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +19 -5
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/events.d.ts +9 -1
- package/dist/types/core/agents/claude-code/events.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/login.d.ts +4 -1
- package/dist/types/core/agents/claude-code/login.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/mcp.d.ts +21 -7
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/models.d.ts +5 -1
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/options.d.ts +29 -10
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/outcome.d.ts +3 -5
- package/dist/types/core/agents/claude-code/outcome.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/results.d.ts +16 -0
- package/dist/types/core/agents/claude-code/results.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/sdk-pair.d.ts +13 -0
- package/dist/types/core/agents/claude-code/sdk-pair.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session.d.ts +58 -12
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/spend.d.ts +2 -1
- package/dist/types/core/agents/claude-code/spend.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/tools.d.ts +26 -3
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/adapter.d.ts +2 -2
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/client.d.ts +12 -2
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +58 -13
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/commands.d.ts +2 -2
- package/dist/types/core/agents/codex-app-server/commands.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/credentials.d.ts +5 -1
- package/dist/types/core/agents/codex-app-server/credentials.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/effort.d.ts +2 -1
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/homes.d.ts +25 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/items.d.ts +27 -2
- package/dist/types/core/agents/codex-app-server/items.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/login.d.ts +16 -1
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +15 -30
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/models.d.ts +3 -10
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/options.d.ts +27 -4
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts +2 -1
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/protocol.d.ts +16 -3
- package/dist/types/core/agents/codex-app-server/protocol.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/session.d.ts +71 -40
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/subagents.d.ts +9 -4
- package/dist/types/core/agents/codex-app-server/subagents.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts +3 -2
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts +2 -1
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/turn.d.ts +31 -8
- package/dist/types/core/agents/codex-app-server/turn.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/user-login.d.ts +28 -0
- package/dist/types/core/agents/codex-app-server/user-login.d.ts.map +1 -0
- package/dist/types/core/agents/credentials.d.ts +3 -1
- package/dist/types/core/agents/credentials.d.ts.map +1 -1
- package/dist/types/core/agents/diffs.d.ts +9 -0
- package/dist/types/core/agents/diffs.d.ts.map +1 -0
- package/dist/types/core/agents/elicitation.d.ts +3 -2
- package/dist/types/core/agents/elicitation.d.ts.map +1 -1
- package/dist/types/core/agents/login.d.ts +6 -0
- package/dist/types/core/agents/login.d.ts.map +1 -1
- package/dist/types/core/agents/mcp-config.d.ts +0 -4
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -1
- package/dist/types/core/agents/process-pool.d.ts +201 -0
- package/dist/types/core/agents/process-pool.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/adapter.d.ts +68 -0
- package/dist/types/core/agents/scripted/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/mcp-call.d.ts +56 -0
- package/dist/types/core/agents/scripted/mcp-call.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/scripted-agent.d.ts +73 -0
- package/dist/types/core/agents/scripted/scripted-agent.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/scripts.d.ts +29 -0
- package/dist/types/core/agents/scripted/scripts.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/steps.d.ts +132 -0
- package/dist/types/core/agents/scripted/steps.d.ts.map +1 -0
- package/dist/types/core/agents/session-agent.d.ts +49 -6
- package/dist/types/core/agents/session-agent.d.ts.map +1 -1
- package/dist/types/core/diagnostics.d.ts +4 -1
- package/dist/types/core/diagnostics.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +5 -0
- package/dist/types/core/index.d.ts.map +1 -1
- package/dist/types/core/presets.d.ts +32 -6
- package/dist/types/core/presets.d.ts.map +1 -1
- package/dist/types/core/processes/lifeline.d.ts +0 -20
- package/dist/types/core/processes/lifeline.d.ts.map +1 -1
- package/dist/types/core/provision/index.d.ts +2 -2
- package/dist/types/core/provision/index.d.ts.map +1 -1
- package/dist/types/core/provision/install-build.d.ts +2 -1
- package/dist/types/core/provision/install-build.d.ts.map +1 -1
- package/dist/types/core/provision/npm.d.ts +20 -8
- package/dist/types/core/provision/npm.d.ts.map +1 -1
- package/dist/types/core/provision/provisioner.d.ts +4 -1
- package/dist/types/core/provision/provisioner.d.ts.map +1 -1
- package/dist/types/core/provision/tools.d.ts +2 -1
- package/dist/types/core/provision/tools.d.ts.map +1 -1
- package/dist/types/core/runtime/agent-runtime.d.ts +16 -8
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
- package/dist/types/core/runtime/event-processor.d.ts +5 -1
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -1
- package/dist/types/core/runtime/harness-clis.d.ts +9 -0
- package/dist/types/core/runtime/harness-clis.d.ts.map +1 -1
- package/dist/types/core/runtime/harness-logins.d.ts +33 -5
- package/dist/types/core/runtime/harness-logins.d.ts.map +1 -1
- package/dist/types/core/runtime/model-lists.d.ts +2 -0
- package/dist/types/core/runtime/model-lists.d.ts.map +1 -1
- package/dist/types/core/runtime/permission-policy.d.ts +5 -3
- package/dist/types/core/runtime/permission-policy.d.ts.map +1 -1
- package/dist/types/core/runtime/request-broker.d.ts +2 -1
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -1
- package/dist/types/core/runtime/turn.d.ts +12 -1
- package/dist/types/core/runtime/turn.d.ts.map +1 -1
- package/dist/types/core/utils/deadline.d.ts +6 -0
- package/dist/types/core/utils/deadline.d.ts.map +1 -1
- package/dist/types/core/utils/errors.d.ts +7 -1
- package/dist/types/core/utils/errors.d.ts.map +1 -1
- package/dist/types/operator/operator.d.ts.map +1 -1
- package/dist/types/operator/render.d.ts +6 -4
- package/dist/types/operator/render.d.ts.map +1 -1
- package/dist/types/protocol/auth.d.ts +54 -24
- package/dist/types/protocol/auth.d.ts.map +1 -1
- package/dist/types/protocol/clis.d.ts +14 -7
- package/dist/types/protocol/clis.d.ts.map +1 -1
- package/dist/types/protocol/config.d.ts +2 -0
- package/dist/types/protocol/config.d.ts.map +1 -1
- package/dist/types/protocol/conversation.d.ts +40 -3
- package/dist/types/protocol/conversation.d.ts.map +1 -1
- package/dist/types/protocol/credentials.d.ts +7 -0
- package/dist/types/protocol/credentials.d.ts.map +1 -1
- package/dist/types/protocol/execution.d.ts +2 -1
- package/dist/types/protocol/execution.d.ts.map +1 -1
- package/dist/types/protocol/factories.d.ts +12 -2
- package/dist/types/protocol/factories.d.ts.map +1 -1
- package/dist/types/protocol/harness.d.ts +6 -2
- package/dist/types/protocol/harness.d.ts.map +1 -1
- package/dist/types/protocol/history.d.ts +19 -0
- package/dist/types/protocol/history.d.ts.map +1 -1
- package/dist/types/protocol/lifecycle.d.ts +47 -8
- package/dist/types/protocol/lifecycle.d.ts.map +1 -1
- package/dist/types/protocol/model-catalog.d.ts.map +1 -1
- package/dist/types/protocol/models.d.ts +3 -0
- package/dist/types/protocol/models.d.ts.map +1 -1
- package/dist/types/protocol/parts.d.ts +14 -0
- package/dist/types/protocol/parts.d.ts.map +1 -1
- package/dist/types/protocol/tool-state.d.ts +12 -0
- package/dist/types/protocol/tool-state.d.ts.map +1 -1
- package/dist/types/protocol/wire-api.d.ts +129 -23
- package/dist/types/protocol/wire-api.d.ts.map +1 -1
- package/dist/types/protocol/wire.d.ts +70 -10
- package/dist/types/protocol/wire.d.ts.map +1 -1
- package/dist/types/server/acp/binding.d.ts +6 -1
- package/dist/types/server/acp/binding.d.ts.map +1 -1
- package/dist/types/server/acp/translate.d.ts +33 -7
- package/dist/types/server/acp/translate.d.ts.map +1 -1
- package/dist/types/server/agent-server.d.ts +6 -0
- package/dist/types/server/agent-server.d.ts.map +1 -1
- package/dist/types/server/bin.d.ts +3 -0
- package/dist/types/server/bin.d.ts.map +1 -0
- package/dist/types/server/feedback.d.ts +2 -1
- package/dist/types/server/feedback.d.ts.map +1 -1
- package/dist/types/server/install.d.ts +11 -0
- package/dist/types/server/install.d.ts.map +1 -1
- package/dist/types/server/session-gate.d.ts +2 -1
- package/dist/types/server/session-gate.d.ts.map +1 -1
- package/dist/types/server/session-store.d.ts +1 -0
- package/dist/types/server/session-store.d.ts.map +1 -1
- package/dist/types/server/subscriptions.d.ts +2 -1
- package/dist/types/server/subscriptions.d.ts.map +1 -1
- package/dist/types/server/transports.d.ts +2 -1
- package/dist/types/server/transports.d.ts.map +1 -1
- package/dist/types/sync/fit.d.ts +8 -7
- package/dist/types/sync/fit.d.ts.map +1 -1
- package/dist/types/sync/history-sqlite.d.ts.map +1 -1
- package/dist/types/sync/index.d.ts +1 -0
- package/dist/types/sync/index.d.ts.map +1 -1
- package/dist/types/sync/journal-sqlite.d.ts +2 -1
- package/dist/types/sync/journal-sqlite.d.ts.map +1 -1
- package/dist/types/sync/journal.d.ts +11 -3
- package/dist/types/sync/journal.d.ts.map +1 -1
- package/dist/types/sync/node-sqlite.d.ts +4 -1
- package/dist/types/sync/node-sqlite.d.ts.map +1 -1
- package/dist/types/sync/projection.d.ts +6 -0
- package/dist/types/sync/projection.d.ts.map +1 -1
- package/dist/types/sync/recovery.d.ts +2 -1
- package/dist/types/sync/recovery.d.ts.map +1 -1
- package/dist/types/sync/schema.d.ts +10 -0
- package/dist/types/sync/schema.d.ts.map +1 -1
- package/dist/types/sync/sql.d.ts +2 -1
- package/dist/types/sync/sql.d.ts.map +1 -1
- package/docs/consuming.md +304 -28
- package/docs/deploy.md +64 -8
- package/docs/durable-sessions.md +35 -5
- package/docs/harnesses.md +398 -25
- package/package.json +48 -18
- package/src/accounts/chatgpt.ts +2 -2
- package/src/accounts/http.ts +2 -16
- package/src/client/client.ts +92 -31
- package/src/client/connection.ts +103 -22
- package/src/client/index.ts +1 -0
- package/src/client/logins.ts +1 -1
- package/src/client/streams.ts +12 -4
- package/src/client/turns.ts +1 -1
- package/src/core/agents/acp/acp-agent.ts +181 -52
- package/src/core/agents/acp/adapter.ts +9 -1
- package/src/core/agents/acp/client.ts +16 -4
- package/src/core/agents/acp/mappings.ts +27 -0
- package/src/core/agents/base.ts +25 -10
- package/src/core/agents/claude-code/adapter.ts +47 -17
- package/src/core/agents/claude-code/approvals.ts +11 -6
- package/src/core/agents/claude-code/claude-agent.ts +89 -32
- package/src/core/agents/claude-code/events.ts +11 -1
- package/src/core/agents/claude-code/login.ts +14 -2
- package/src/core/agents/claude-code/mcp.ts +31 -15
- package/src/core/agents/claude-code/models.ts +7 -2
- package/src/core/agents/claude-code/options.ts +30 -9
- package/src/core/agents/claude-code/outcome.ts +10 -2
- package/src/core/agents/claude-code/results.ts +73 -0
- package/src/core/agents/claude-code/sdk-pair.ts +66 -0
- package/src/core/agents/claude-code/session.ts +179 -37
- package/src/core/agents/claude-code/spend.ts +1 -1
- package/src/core/agents/claude-code/tools.ts +108 -12
- package/src/core/agents/codex-app-server/adapter.ts +37 -12
- package/src/core/agents/codex-app-server/client.ts +37 -8
- package/src/core/agents/codex-app-server/codex-agent.ts +115 -50
- package/src/core/agents/codex-app-server/commands.ts +2 -2
- package/src/core/agents/codex-app-server/credentials.ts +10 -5
- package/src/core/agents/codex-app-server/effort.ts +1 -1
- package/src/core/agents/codex-app-server/homes.ts +54 -3
- package/src/core/agents/codex-app-server/items.ts +219 -31
- package/src/core/agents/codex-app-server/login.ts +44 -2
- package/src/core/agents/codex-app-server/mcp.ts +47 -32
- package/src/core/agents/codex-app-server/models.ts +9 -8
- package/src/core/agents/codex-app-server/options.ts +69 -10
- package/src/core/agents/codex-app-server/plan-approval.ts +1 -1
- package/src/core/agents/codex-app-server/protocol.ts +14 -4
- package/src/core/agents/codex-app-server/requests.ts +17 -8
- package/src/core/agents/codex-app-server/session.ts +160 -113
- package/src/core/agents/codex-app-server/subagents.ts +21 -14
- package/src/core/agents/codex-app-server/thread-settings.ts +18 -8
- package/src/core/agents/codex-app-server/turn-items.ts +1 -1
- package/src/core/agents/codex-app-server/turn.ts +79 -32
- package/src/core/agents/codex-app-server/user-login.ts +107 -0
- package/src/core/agents/credentials.ts +5 -2
- package/src/core/agents/diffs.ts +25 -0
- package/src/core/agents/elicitation.ts +2 -2
- package/src/core/agents/login.ts +6 -0
- package/src/core/agents/mcp-config.ts +2 -2
- package/src/core/agents/process-pool.ts +458 -0
- package/src/core/agents/scripted/adapter.ts +142 -0
- package/src/core/agents/scripted/mcp-call.ts +134 -0
- package/src/core/agents/scripted/scripted-agent.ts +418 -0
- package/src/core/agents/scripted/scripts.ts +171 -0
- package/src/core/agents/scripted/steps.ts +127 -0
- package/src/core/agents/session-agent.ts +105 -8
- package/src/core/diagnostics.ts +9 -1
- package/src/core/index.ts +11 -0
- package/src/core/presets.ts +100 -14
- package/src/core/processes/lifeline.ts +99 -25
- package/src/core/provision/index.ts +1 -2
- package/src/core/provision/install-build.ts +4 -1
- package/src/core/provision/npm.ts +309 -97
- package/src/core/provision/provisioner.ts +22 -8
- package/src/core/provision/tools.ts +44 -19
- package/src/core/runtime/agent-runtime.ts +48 -18
- package/src/core/runtime/event-processor.ts +18 -2
- package/src/core/runtime/harness-clis.ts +36 -1
- package/src/core/runtime/harness-logins.ts +82 -31
- package/src/core/runtime/model-lists.ts +1 -1
- package/src/core/runtime/permission-policy.ts +4 -3
- package/src/core/runtime/request-broker.ts +1 -1
- package/src/core/runtime/turn.ts +51 -3
- package/src/core/utils/deadline.ts +23 -0
- package/src/core/utils/errors.ts +11 -4
- package/src/operator/operator.ts +8 -4
- package/src/operator/render.ts +46 -8
- package/src/protocol/auth.ts +30 -23
- package/src/protocol/clis.ts +12 -4
- package/src/protocol/credentials.ts +19 -0
- package/src/protocol/execution.ts +5 -0
- package/src/protocol/factories.ts +25 -3
- package/src/protocol/harness.ts +11 -1
- package/src/protocol/history.ts +20 -0
- package/src/protocol/lifecycle.ts +10 -1
- package/src/protocol/model-catalog.ts +19 -8
- package/src/protocol/parts.ts +12 -1
- package/src/protocol/tool-state.ts +14 -1
- package/src/protocol/wire.ts +14 -0
- package/src/server/acp/binding.ts +113 -23
- package/src/server/acp/translate.ts +161 -8
- package/src/server/agent-server.ts +10 -1
- package/src/server/bin.ts +108 -19
- package/src/server/feedback.ts +1 -1
- package/src/server/install.ts +82 -4
- package/src/server/session-gate.ts +1 -1
- package/src/server/session-store.ts +5 -1
- package/src/server/subscriptions.ts +1 -1
- package/src/server/transports.ts +20 -1
- package/src/sync/fit.ts +115 -28
- package/src/sync/history-sqlite.ts +6 -2
- package/src/sync/index.ts +1 -0
- package/src/sync/journal-sqlite.ts +20 -2
- package/src/sync/journal.ts +10 -2
- package/src/sync/node-sqlite.ts +19 -3
- package/src/sync/projection.ts +10 -0
- package/src/sync/recovery.ts +11 -4
- package/src/sync/schema.ts +7 -5
- package/src/sync/sql.ts +1 -1
- package/dist/types/core/agents/claude-code/session-pool.d.ts +0 -36
- package/dist/types/core/agents/claude-code/session-pool.d.ts.map +0 -1
- package/dist/types/core/agents/session-pool.d.ts +0 -41
- package/dist/types/core/agents/session-pool.d.ts.map +0 -1
- package/src/core/agents/claude-code/session-pool.ts +0 -136
- package/src/core/agents/session-pool.ts +0 -111
|
@@ -35,21 +35,21 @@ export const GENERATED_MODEL_CATALOG: {
|
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
|
-
id: "
|
|
38
|
+
id: "sonnet",
|
|
39
39
|
harness: "claude-code",
|
|
40
|
-
label: "
|
|
41
|
-
description: "
|
|
42
|
-
resolvedId: "claude-
|
|
40
|
+
label: "Sonnet 5.5",
|
|
41
|
+
description: "Most efficient for simpler tasks",
|
|
42
|
+
resolvedId: "claude-sonnet-5-5",
|
|
43
43
|
thinking: {
|
|
44
44
|
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
|
-
id: "
|
|
48
|
+
id: "fable",
|
|
49
49
|
harness: "claude-code",
|
|
50
|
-
label: "
|
|
51
|
-
description: "Most
|
|
52
|
-
resolvedId: "claude-
|
|
50
|
+
label: "Fable 5.1",
|
|
51
|
+
description: "Most capable for your hardest and longest-running tasks",
|
|
52
|
+
resolvedId: "claude-fable-5-1",
|
|
53
53
|
thinking: {
|
|
54
54
|
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
55
55
|
},
|
|
@@ -150,6 +150,17 @@ export const GENERATED_MODEL_CATALOG: {
|
|
|
150
150
|
},
|
|
151
151
|
images: true,
|
|
152
152
|
},
|
|
153
|
+
{
|
|
154
|
+
id: "gpt-6.1-terra",
|
|
155
|
+
harness: "codex-app-server",
|
|
156
|
+
label: "GPT-6.1 Terra",
|
|
157
|
+
description: "GPT-6.1 Terra Codex model.",
|
|
158
|
+
thinking: {
|
|
159
|
+
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
160
|
+
default: "low",
|
|
161
|
+
},
|
|
162
|
+
images: true,
|
|
163
|
+
},
|
|
153
164
|
{
|
|
154
165
|
id: "gpt-6-sol",
|
|
155
166
|
harness: "codex-app-server",
|
package/src/protocol/parts.ts
CHANGED
|
@@ -2,7 +2,12 @@ import { z } from "zod";
|
|
|
2
2
|
import { isKnownPartType } from "./guards.ts";
|
|
3
3
|
import { MetaSchema } from "./meta.ts";
|
|
4
4
|
import { OpenTimeSpanSchema } from "./time.ts";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
McpToolSchema,
|
|
7
|
+
ToolKindSchema,
|
|
8
|
+
ToolLocationSchema,
|
|
9
|
+
ToolStateSchema,
|
|
10
|
+
} from "./tool-state.ts";
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* A Part is the atomic unit of message content, normalized across harnesses.
|
|
@@ -71,8 +76,14 @@ export const ToolPartSchema = PartBase.extend({
|
|
|
71
76
|
toolName: z.string(),
|
|
72
77
|
/** Normalized classification of what the call does (ACP ToolKind + `task`). */
|
|
73
78
|
kind: ToolKindSchema.optional(),
|
|
79
|
+
/** A call to an MCP tool: its server and tool, when the harness knows both. `toolName` stays the harness's own. */
|
|
80
|
+
mcp: McpToolSchema.optional(),
|
|
74
81
|
/** Human-readable label when the harness provides one. */
|
|
75
82
|
title: z.string().optional(),
|
|
83
|
+
/** A command's line as the agent wrote it, apart from any wrapper the harness adds. `state.input` stays the harness's own. */
|
|
84
|
+
command: z.string().optional(),
|
|
85
|
+
/** A fetch's address. */
|
|
86
|
+
url: z.string().optional(),
|
|
76
87
|
/** Files this call touches, for follow-along UIs. */
|
|
77
88
|
locations: z.array(ToolLocationSchema).optional(),
|
|
78
89
|
/** Present when this tool spawned a subagent (implies kind "task"). */
|
|
@@ -60,6 +60,17 @@ export const ToolLocationSchema = z.object({
|
|
|
60
60
|
});
|
|
61
61
|
export type ToolLocation = z.infer<typeof ToolLocationSchema>;
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* The MCP server and tool a call is to, as names, on every harness that
|
|
65
|
+
* knows both: what a product reads instead of each harness's spelling of
|
|
66
|
+
* `toolName` (`mcp__docs__search` on Claude, `docs.search` on Codex).
|
|
67
|
+
*/
|
|
68
|
+
export const McpToolSchema = z.object({
|
|
69
|
+
server: z.string(),
|
|
70
|
+
tool: z.string(),
|
|
71
|
+
});
|
|
72
|
+
export type McpTool = z.infer<typeof McpToolSchema>;
|
|
73
|
+
|
|
63
74
|
/**
|
|
64
75
|
* Structured, display-grade tool output. Three-audience doctrine:
|
|
65
76
|
* `ToolStateCompleted.output` (string) is the MODEL-facing factual record and
|
|
@@ -116,7 +127,7 @@ export const ToolStateCompletedSchema = z.object({
|
|
|
116
127
|
output: z.string(),
|
|
117
128
|
/** Display-grade structured output, when expressible (diffs, images, terminals). */
|
|
118
129
|
content: z.array(ToolResultContentSchema).optional(),
|
|
119
|
-
/** Machine channel: harness-native extras (
|
|
130
|
+
/** Machine channel: harness-native extras (a command's `exitCode`, …). */
|
|
120
131
|
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
121
132
|
title: z.string().optional(),
|
|
122
133
|
time: TimeSpanSchema,
|
|
@@ -141,6 +152,8 @@ export const ToolStateFailedSchema = z.object({
|
|
|
141
152
|
error: z.string(),
|
|
142
153
|
/** Set when the engine closed the tool, absent when the harness reported the failure. */
|
|
143
154
|
closure: ToolClosureSchema.optional(),
|
|
155
|
+
/** Machine channel, as on a completed tool: a failed command's `exitCode`. */
|
|
156
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
144
157
|
time: TimeSpanSchema,
|
|
145
158
|
_meta: MetaSchema,
|
|
146
159
|
});
|
package/src/protocol/wire.ts
CHANGED
|
@@ -480,6 +480,18 @@ export const RECOVERY_REASONS = ["not_owned", "not_verified", "not_stopped"] as
|
|
|
480
480
|
export const RecoveryReasonSchema = z.enum(RECOVERY_REASONS);
|
|
481
481
|
export type RecoveryReason = z.infer<typeof RecoveryReasonSchema>;
|
|
482
482
|
|
|
483
|
+
/**
|
|
484
|
+
* A session's latest turn: `stopReason` and `error` as its `turn.ended` said,
|
|
485
|
+
* both absent while it runs. One a restart cut off ended `error`, category
|
|
486
|
+
* `server_restart`.
|
|
487
|
+
*/
|
|
488
|
+
export const LastTurnSchema = TurnEndedEventSchema.pick({
|
|
489
|
+
turnId: true,
|
|
490
|
+
stopReason: true,
|
|
491
|
+
error: true,
|
|
492
|
+
}).partial({ stopReason: true });
|
|
493
|
+
export type LastTurn = z.infer<typeof LastTurnSchema>;
|
|
494
|
+
|
|
483
495
|
export const DurableSessionSchema = z.object({
|
|
484
496
|
sessionId: z.string(),
|
|
485
497
|
harness: AgentHarnessSchema,
|
|
@@ -494,6 +506,8 @@ export const DurableSessionSchema = z.object({
|
|
|
494
506
|
recoveryRequired: z.boolean(),
|
|
495
507
|
/** Why, while `recoveryRequired` is set. */
|
|
496
508
|
recoveryReason: RecoveryReasonSchema.optional(),
|
|
509
|
+
/** Its latest turn, once it has admitted one (`session/get` only). */
|
|
510
|
+
lastTurn: LastTurnSchema.optional(),
|
|
497
511
|
});
|
|
498
512
|
export type DurableSession = z.infer<typeof DurableSessionSchema>;
|
|
499
513
|
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import { Readable, Writable } from "node:stream";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
AgentApp,
|
|
4
|
+
AgentConnection,
|
|
5
|
+
ElicitationCapabilities,
|
|
6
|
+
McpCapabilities,
|
|
7
|
+
McpServer,
|
|
8
|
+
} from "@agentclientprotocol/sdk";
|
|
3
9
|
import type { AgentRuntime, EventSink } from "../../core/index.ts";
|
|
4
10
|
import { generateUUIDv7 } from "../../core/index.ts";
|
|
5
11
|
import type {
|
|
6
12
|
AgentHarness,
|
|
13
|
+
ElicitationOutcome,
|
|
7
14
|
LifecycleEvent,
|
|
8
15
|
PermissionMode,
|
|
9
16
|
PermissionOutcome,
|
|
17
|
+
ThinkingLevel,
|
|
10
18
|
} from "../../protocol/index.ts";
|
|
11
19
|
import { SessionRecords } from "./session-records.ts";
|
|
12
20
|
import {
|
|
13
21
|
AcpUpdateTranslator,
|
|
22
|
+
fromAcpElicitation,
|
|
14
23
|
fromAcpMcpServers,
|
|
15
24
|
fromPromptBlocks,
|
|
25
|
+
toAcpElicitation,
|
|
16
26
|
toAcpPermissionRequest,
|
|
17
27
|
toAcpPromptResponse,
|
|
18
28
|
} from "./translate.ts";
|
|
@@ -24,7 +34,12 @@ export interface AcpBindingOptions {
|
|
|
24
34
|
runtime: AgentRuntime;
|
|
25
35
|
/** The harness this ACP agent fronts (operator-chosen at launch). */
|
|
26
36
|
harness: AgentHarness;
|
|
37
|
+
/**
|
|
38
|
+
* The model and thinking level every turn runs at: the operator's, never an
|
|
39
|
+
* ACP client's. Absent: the harness's own default.
|
|
40
|
+
*/
|
|
27
41
|
model?: string;
|
|
42
|
+
thinkingLevel?: ThinkingLevel;
|
|
28
43
|
/** Defaults to `default` so tool approvals flow to the ACP client. */
|
|
29
44
|
permissionMode?: PermissionMode;
|
|
30
45
|
name?: string;
|
|
@@ -45,6 +60,19 @@ interface BoundSession {
|
|
|
45
60
|
permissionMode: PermissionMode;
|
|
46
61
|
}
|
|
47
62
|
|
|
63
|
+
/**
|
|
64
|
+
* The MCP transports beside stdio the fronted harness attaches, as the
|
|
65
|
+
* binding advertises them. The `acp` harness has none: the agent behind it
|
|
66
|
+
* decides what it takes, and this binding cannot ask.
|
|
67
|
+
*/
|
|
68
|
+
const MCP_TRANSPORTS: Partial<Record<AgentHarness, McpCapabilities>> = {
|
|
69
|
+
"claude-code": { http: true, sse: true },
|
|
70
|
+
// Codex takes Streamable HTTP, never legacy SSE.
|
|
71
|
+
"codex-app-server": { http: true },
|
|
72
|
+
// Its `call` step speaks HTTP alone.
|
|
73
|
+
scripted: { http: true },
|
|
74
|
+
};
|
|
75
|
+
|
|
48
76
|
/** What each permission mode is called in an ACP client's mode picker. */
|
|
49
77
|
const MODE_NAMES: Record<PermissionMode, string> = {
|
|
50
78
|
default: "Default",
|
|
@@ -69,19 +97,34 @@ export async function createAcpAgentApp(options: AcpBindingOptions): Promise<Age
|
|
|
69
97
|
const acp = await import("@agentclientprotocol/sdk");
|
|
70
98
|
const { runtime, harness } = options;
|
|
71
99
|
const sessions = new Map<string, BoundSession>();
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
//
|
|
100
|
+
/** A session's MCP servers as the engine takes them, or the request refused. */
|
|
101
|
+
const mcpServersOf = (servers: McpServer[] | undefined) => {
|
|
102
|
+
try {
|
|
103
|
+
const taken = fromAcpMcpServers(servers);
|
|
104
|
+
// @ref LLP 0001#d21--a-codex-turn-that-names-no-home-carries-its-mcp-servers-in-its-thread — what Codex cannot attach is refused at admission
|
|
105
|
+
// A Codex turn that names no home carries its servers in its thread,
|
|
106
|
+
// so they pass on; what Codex would fail the turn over is refused here.
|
|
107
|
+
if (harness === "codex-app-server")
|
|
108
|
+
for (const [name, server] of Object.entries(taken ?? {})) {
|
|
109
|
+
if (server.type === "sse")
|
|
110
|
+
throw new Error(
|
|
111
|
+
`MCP server "${name}" uses the sse transport, which Codex does not attach (it takes stdio and http)`,
|
|
112
|
+
);
|
|
113
|
+
if (name === "codex_apps")
|
|
114
|
+
throw new Error("MCP server name codex_apps is reserved by Codex");
|
|
115
|
+
}
|
|
116
|
+
return taken;
|
|
117
|
+
} catch (error) {
|
|
77
118
|
throw acp.RequestError.invalidParams(
|
|
78
119
|
undefined,
|
|
79
|
-
|
|
120
|
+
error instanceof Error ? error.message : String(error),
|
|
80
121
|
);
|
|
81
122
|
}
|
|
82
123
|
};
|
|
83
124
|
|
|
84
125
|
const records = new SessionRecords(options.sessionDir, harness);
|
|
126
|
+
/** What the client said at `initialize` it can ask the person: none until it says. */
|
|
127
|
+
let elicitation: ElicitationCapabilities | null | undefined;
|
|
85
128
|
|
|
86
129
|
const requireSession = (sessionId: string): BoundSession => {
|
|
87
130
|
const session = sessions.get(sessionId);
|
|
@@ -101,30 +144,33 @@ export async function createAcpAgentApp(options: AcpBindingOptions): Promise<Age
|
|
|
101
144
|
|
|
102
145
|
return acp
|
|
103
146
|
.agent({ name: options.name ?? "agent-server" })
|
|
104
|
-
.onRequest("initialize", (ctx) =>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
147
|
+
.onRequest("initialize", (ctx) => {
|
|
148
|
+
elicitation = ctx.params.clientCapabilities?.elicitation;
|
|
149
|
+
return {
|
|
150
|
+
protocolVersion: Math.min(ctx.params.protocolVersion, PROTOCOL_VERSION),
|
|
151
|
+
agentInfo: { name: options.name ?? "agent-server", version: options.version ?? "0.0.0" },
|
|
152
|
+
agentCapabilities: {
|
|
153
|
+
promptCapabilities: { image: true },
|
|
154
|
+
// Clients send HTTP/SSE servers only to agents that advertise them.
|
|
155
|
+
...(MCP_TRANSPORTS[harness] && { mcpCapabilities: MCP_TRANSPORTS[harness] }),
|
|
156
|
+
sessionCapabilities: { resume: {}, close: {} },
|
|
157
|
+
},
|
|
158
|
+
authMethods: [],
|
|
159
|
+
};
|
|
160
|
+
})
|
|
115
161
|
.onRequest("session/new", (ctx) => {
|
|
116
|
-
|
|
162
|
+
const mcpServers = mcpServersOf(ctx.params.mcpServers);
|
|
117
163
|
const sessionId = generateUUIDv7();
|
|
118
164
|
const session: BoundSession = {
|
|
119
165
|
cwd: ctx.params.cwd,
|
|
120
|
-
mcpServers
|
|
166
|
+
mcpServers,
|
|
121
167
|
permissionMode: startMode,
|
|
122
168
|
};
|
|
123
169
|
sessions.set(sessionId, session);
|
|
124
170
|
return { sessionId, modes: modes(session) };
|
|
125
171
|
})
|
|
126
172
|
.onRequest("session/resume", async (ctx) => {
|
|
127
|
-
|
|
173
|
+
const mcpServers = mcpServersOf(ctx.params.mcpServers);
|
|
128
174
|
let session = sessions.get(ctx.params.sessionId);
|
|
129
175
|
if (!session) {
|
|
130
176
|
const resumeSessionId = await records.recall(ctx.params.sessionId);
|
|
@@ -133,7 +179,7 @@ export async function createAcpAgentApp(options: AcpBindingOptions): Promise<Age
|
|
|
133
179
|
sessions.set(ctx.params.sessionId, session);
|
|
134
180
|
}
|
|
135
181
|
session.cwd = ctx.params.cwd;
|
|
136
|
-
if (ctx.params.mcpServers) session.mcpServers =
|
|
182
|
+
if (ctx.params.mcpServers) session.mcpServers = mcpServers;
|
|
137
183
|
return { modes: modes(session) };
|
|
138
184
|
})
|
|
139
185
|
.onRequest("session/set_mode", (ctx) => {
|
|
@@ -158,6 +204,8 @@ export async function createAcpAgentApp(options: AcpBindingOptions): Promise<Age
|
|
|
158
204
|
.onRequest("session/prompt", async (ctx) => {
|
|
159
205
|
const session = requireSession(ctx.params.sessionId);
|
|
160
206
|
const translator = new AcpUpdateTranslator();
|
|
207
|
+
/** The questions asked of the client and not yet answered, by request id. */
|
|
208
|
+
const asked = new Map<string, AbortController>();
|
|
161
209
|
const sink: EventSink = {
|
|
162
210
|
emit: async (event: LifecycleEvent) => {
|
|
163
211
|
if (event.type === "permission.requested") {
|
|
@@ -175,6 +223,39 @@ export async function createAcpAgentApp(options: AcpBindingOptions): Promise<Age
|
|
|
175
223
|
runtime.respondPermission(ctx.params.sessionId, event.requestId, outcome);
|
|
176
224
|
return;
|
|
177
225
|
}
|
|
226
|
+
if (event.type === "elicitation.requested") {
|
|
227
|
+
// Asked of the client in a mode it said it takes; any other is declined.
|
|
228
|
+
const request = toAcpElicitation(ctx.params.sessionId, event, elicitation);
|
|
229
|
+
if (!request) {
|
|
230
|
+
runtime.respondElicitation(ctx.params.sessionId, event.requestId, {
|
|
231
|
+
action: "decline",
|
|
232
|
+
});
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
// Sent in order, its answer not awaited here: the person may take
|
|
236
|
+
// as long as they like, and the turn's cancel and end must not
|
|
237
|
+
// wait behind them.
|
|
238
|
+
const abort = new AbortController();
|
|
239
|
+
asked.set(event.requestId, abort);
|
|
240
|
+
// Answered by other means first (a cancel, the turn's end): a reply is too late.
|
|
241
|
+
const open = () => asked.get(event.requestId) === abort;
|
|
242
|
+
void ctx.client
|
|
243
|
+
.request("elicitation/create", request, { cancellationSignal: abort.signal })
|
|
244
|
+
.then((response) => (open() ? fromAcpElicitation(event, response) : undefined))
|
|
245
|
+
// A failed request, or a reply that does not read, is a cancel.
|
|
246
|
+
.catch((): ElicitationOutcome => ({ action: "cancel" }))
|
|
247
|
+
.then((outcome) => {
|
|
248
|
+
if (!outcome || !open()) return;
|
|
249
|
+
asked.delete(event.requestId);
|
|
250
|
+
runtime.respondElicitation(ctx.params.sessionId, event.requestId, outcome);
|
|
251
|
+
});
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (event.type === "elicitation.resolved") {
|
|
255
|
+
// The broker answered it without the client: the question is withdrawn.
|
|
256
|
+
asked.get(event.requestId)?.abort();
|
|
257
|
+
asked.delete(event.requestId);
|
|
258
|
+
}
|
|
178
259
|
if (event.type === "session.mode") {
|
|
179
260
|
// The agent switched modes (an approved plan, or Claude planning by
|
|
180
261
|
// itself): the session goes on in it, and the client hears so.
|
|
@@ -195,7 +276,7 @@ export async function createAcpAgentApp(options: AcpBindingOptions): Promise<Age
|
|
|
195
276
|
}
|
|
196
277
|
},
|
|
197
278
|
};
|
|
198
|
-
const
|
|
279
|
+
const run = runtime.run(
|
|
199
280
|
{
|
|
200
281
|
sessionId: ctx.params.sessionId,
|
|
201
282
|
turnId: generateUUIDv7(),
|
|
@@ -204,13 +285,22 @@ export async function createAcpAgentApp(options: AcpBindingOptions): Promise<Age
|
|
|
204
285
|
harness,
|
|
205
286
|
cwd: session.cwd,
|
|
206
287
|
model: options.model,
|
|
288
|
+
thinkingLevel: options.thinkingLevel,
|
|
207
289
|
permissionMode: session.permissionMode,
|
|
290
|
+
// A client that takes a form or a URL is asked what it takes; any
|
|
291
|
+
// other request is declined (`toAcpElicitation`).
|
|
292
|
+
elicitation: Boolean(elicitation?.form || elicitation?.url),
|
|
208
293
|
mcpServers: session.mcpServers,
|
|
209
294
|
resumeSessionId: session.resumeSessionId,
|
|
210
295
|
},
|
|
211
296
|
},
|
|
212
297
|
sink,
|
|
213
298
|
);
|
|
299
|
+
// The turn's end answers every question still open; none outlives it.
|
|
300
|
+
const summary = await run.finally(() => {
|
|
301
|
+
for (const abort of asked.values()) abort.abort();
|
|
302
|
+
asked.clear();
|
|
303
|
+
});
|
|
214
304
|
if (summary.nativeSessionId) {
|
|
215
305
|
session.resumeSessionId = undefined;
|
|
216
306
|
await records.remember(ctx.params.sessionId, summary.nativeSessionId);
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ToolKind as AcpToolKind,
|
|
3
3
|
ContentBlock,
|
|
4
|
+
CreateElicitationRequest,
|
|
5
|
+
CreateElicitationResponse,
|
|
6
|
+
ElicitationCapabilities,
|
|
7
|
+
ElicitationPropertySchema,
|
|
8
|
+
ElicitationSchema,
|
|
9
|
+
EnumOption,
|
|
4
10
|
McpServer,
|
|
5
11
|
PermissionOption,
|
|
6
12
|
PermissionOptionKind,
|
|
@@ -8,9 +14,13 @@ import type {
|
|
|
8
14
|
RequestPermissionRequest,
|
|
9
15
|
SessionUpdate,
|
|
10
16
|
StopReason,
|
|
17
|
+
ToolCallContent,
|
|
11
18
|
} from "@agentclientprotocol/sdk";
|
|
12
19
|
import type { RunSummary } from "../../core/index.ts";
|
|
13
20
|
import {
|
|
21
|
+
type ElicitationOutcome,
|
|
22
|
+
type ElicitationQuestion,
|
|
23
|
+
type ElicitationRequestedEvent,
|
|
14
24
|
type LifecycleEvent,
|
|
15
25
|
META_KEYS,
|
|
16
26
|
type McpServerConfig,
|
|
@@ -19,6 +29,7 @@ import {
|
|
|
19
29
|
type TokenUsage,
|
|
20
30
|
type ToolKind,
|
|
21
31
|
type ToolPart,
|
|
32
|
+
type ToolResultContent,
|
|
22
33
|
} from "../../protocol/index.ts";
|
|
23
34
|
|
|
24
35
|
/** ACP v1's ToolKind set: ours without `task` and the extensions. */
|
|
@@ -64,7 +75,7 @@ function isAcpOption(option: { kind: string }): option is PermissionOption {
|
|
|
64
75
|
}
|
|
65
76
|
|
|
66
77
|
/** The engine's disjoint token buckets as ACP's (still unstable) turn usage. */
|
|
67
|
-
|
|
78
|
+
function toAcpUsage(usage: TokenUsage): NonNullable<PromptResponse["usage"]> {
|
|
68
79
|
const read = usage.cache?.read ?? 0;
|
|
69
80
|
const write = usage.cache?.write ?? 0;
|
|
70
81
|
return {
|
|
@@ -104,7 +115,9 @@ export function toAcpPromptResponse(
|
|
|
104
115
|
/**
|
|
105
116
|
* A brokered permission request as ACP's `session/request_permission`: the
|
|
106
117
|
* option vocabulary is ACP's, so the options pass through (one of a kind ACP
|
|
107
|
-
* cannot carry is not offered, never read as an approval).
|
|
118
|
+
* cannot carry is not offered, never read as an approval). The call's name
|
|
119
|
+
* and locations ride ACP's own fields; its command, address, reason and MCP
|
|
120
|
+
* identity have none.
|
|
108
121
|
*/
|
|
109
122
|
export function toAcpPermissionRequest(
|
|
110
123
|
sessionId: string,
|
|
@@ -116,14 +129,108 @@ export function toAcpPermissionRequest(
|
|
|
116
129
|
toolCall: {
|
|
117
130
|
toolCallId: call?.toolCallId ?? event.requestId,
|
|
118
131
|
title: event.title,
|
|
132
|
+
...(call && { name: call.toolName }),
|
|
119
133
|
status: "pending",
|
|
120
134
|
...(call?.kind && { kind: toAcpToolKind(call.kind) }),
|
|
135
|
+
...(call?.locations?.length && { locations: call.locations }),
|
|
121
136
|
...(call?.rawInput && { rawInput: call.rawInput }),
|
|
122
137
|
},
|
|
123
138
|
options: event.options.filter(isAcpOption),
|
|
124
139
|
};
|
|
125
140
|
}
|
|
126
141
|
|
|
142
|
+
// @ref LLP 0001#d12--what-the-agent-asks-the-user-is-first-class-protocol-opted-into-per-turn — a question reaches an ACP client as a form
|
|
143
|
+
/**
|
|
144
|
+
* A request for the person's input as ACP's `elicitation/create`, or
|
|
145
|
+
* `undefined` when the client cannot take it. ACP v1 has a form and a URL
|
|
146
|
+
* mode and no question mode, so the agent's own questions are a form, one
|
|
147
|
+
* required field per question: its choices a single or multiple select, a
|
|
148
|
+
* free answer (or one beside the choices) a string. ACP has no masked
|
|
149
|
+
* field, so a `secret` question is an ordinary one.
|
|
150
|
+
*/
|
|
151
|
+
export function toAcpElicitation(
|
|
152
|
+
sessionId: string,
|
|
153
|
+
event: ElicitationRequestedEvent,
|
|
154
|
+
client: ElicitationCapabilities | null | undefined,
|
|
155
|
+
): CreateElicitationRequest | undefined {
|
|
156
|
+
const scope = {
|
|
157
|
+
sessionId,
|
|
158
|
+
...(event.toolCallId && { toolCallId: event.toolCallId }),
|
|
159
|
+
message: event.message,
|
|
160
|
+
};
|
|
161
|
+
if (event.mode === "question" && client?.form && event.questions?.length)
|
|
162
|
+
return {
|
|
163
|
+
...scope,
|
|
164
|
+
mode: "form",
|
|
165
|
+
requestedSchema: {
|
|
166
|
+
type: "object",
|
|
167
|
+
properties: Object.fromEntries(event.questions.map((q) => [q.id, questionField(q)])),
|
|
168
|
+
required: event.questions.map((q) => q.id),
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
if (event.mode === "form" && client?.form && event.requestedSchema)
|
|
172
|
+
return {
|
|
173
|
+
...scope,
|
|
174
|
+
mode: "form",
|
|
175
|
+
// An MCP server's schema, which ACP's form mode takes as MCP defines it.
|
|
176
|
+
requestedSchema: event.requestedSchema as ElicitationSchema,
|
|
177
|
+
};
|
|
178
|
+
if (event.mode === "url" && client?.url && event.url && event.elicitationId)
|
|
179
|
+
return { ...scope, mode: "url", url: event.url, elicitationId: event.elicitationId };
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** One question as a form field. */
|
|
184
|
+
function questionField(question: ElicitationQuestion): ElicitationPropertySchema {
|
|
185
|
+
const label = {
|
|
186
|
+
title: question.header ?? question.question,
|
|
187
|
+
...(question.header && { description: question.question }),
|
|
188
|
+
};
|
|
189
|
+
const choices = question.options?.map(
|
|
190
|
+
(option): EnumOption => ({
|
|
191
|
+
const: option.label,
|
|
192
|
+
title: option.label,
|
|
193
|
+
...(option.description && { description: option.description }),
|
|
194
|
+
}),
|
|
195
|
+
);
|
|
196
|
+
// Words of the person's own beside the choices: a string, the choices named.
|
|
197
|
+
if (!choices?.length || question.allowOther)
|
|
198
|
+
return {
|
|
199
|
+
type: "string",
|
|
200
|
+
...label,
|
|
201
|
+
...(choices?.length && {
|
|
202
|
+
description: `${question.question} (${choices.map((c) => c.const).join(", ")}, or your own words)`,
|
|
203
|
+
}),
|
|
204
|
+
};
|
|
205
|
+
if (question.multiSelect) return { type: "array", ...label, items: { anyOf: choices } };
|
|
206
|
+
return { type: "string", ...label, oneOf: choices };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* The client's answer as the engine's outcome: a question's answers are each
|
|
211
|
+
* an array (a form's single value becomes one), a form's content passes as
|
|
212
|
+
* it is, and an action ACP may add later is a cancel.
|
|
213
|
+
*/
|
|
214
|
+
export function fromAcpElicitation(
|
|
215
|
+
event: ElicitationRequestedEvent,
|
|
216
|
+
response: CreateElicitationResponse,
|
|
217
|
+
): ElicitationOutcome {
|
|
218
|
+
if (response.action === "decline") return { action: "decline" };
|
|
219
|
+
if (response.action !== "accept") return { action: "cancel" };
|
|
220
|
+
const content = (response as { content?: Record<string, unknown> | null }).content;
|
|
221
|
+
if (!content) return { action: "accept" };
|
|
222
|
+
if (event.mode !== "question") return { action: "accept", content };
|
|
223
|
+
return {
|
|
224
|
+
action: "accept",
|
|
225
|
+
content: Object.fromEntries(
|
|
226
|
+
Object.entries(content).map(([id, value]) => [
|
|
227
|
+
id,
|
|
228
|
+
Array.isArray(value) ? value.map(String) : [String(value)],
|
|
229
|
+
]),
|
|
230
|
+
),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
127
234
|
/**
|
|
128
235
|
* Per-prompt translator from the engine's LifecycleEvents to ACP v1
|
|
129
236
|
* `session/update` payloads — the exact inverse of the acp harness adapter
|
|
@@ -256,18 +363,43 @@ export class AcpUpdateTranslator {
|
|
|
256
363
|
: part.state.status === "completed"
|
|
257
364
|
? part.state.output
|
|
258
365
|
: undefined;
|
|
366
|
+
const content: ToolCallContent[] = [
|
|
367
|
+
...(output
|
|
368
|
+
? [{ type: "content" as const, content: { type: "text" as const, text: output } }]
|
|
369
|
+
: []),
|
|
370
|
+
...toAcpDiffs(part.state.status === "completed" ? part.state.content : undefined),
|
|
371
|
+
];
|
|
259
372
|
updates.push({
|
|
260
373
|
sessionUpdate: "tool_call_update",
|
|
261
374
|
toolCallId: part.toolCallId,
|
|
262
375
|
status,
|
|
263
|
-
...(
|
|
264
|
-
content: [{ type: "content", content: { type: "text", text: output } }],
|
|
265
|
-
}),
|
|
376
|
+
...(content.length && { content }),
|
|
266
377
|
});
|
|
267
378
|
return updates;
|
|
268
379
|
}
|
|
269
380
|
}
|
|
270
381
|
|
|
382
|
+
// @ref LLP 0002#tool-output-has-three-audiences — a part's diffs reach an ACP client as ACP diffs
|
|
383
|
+
/**
|
|
384
|
+
* A part's `diff` entries as ACP's, which a client draws. A `terminal`
|
|
385
|
+
* names a terminal of the agent's, which no client of ours can show, so it
|
|
386
|
+
* is not sent; text is the part's output.
|
|
387
|
+
*/
|
|
388
|
+
function toAcpDiffs(content: ToolResultContent[] | undefined): ToolCallContent[] {
|
|
389
|
+
return (content ?? []).flatMap((item): ToolCallContent[] =>
|
|
390
|
+
item.type === "diff"
|
|
391
|
+
? [
|
|
392
|
+
{
|
|
393
|
+
type: "diff",
|
|
394
|
+
path: item.path,
|
|
395
|
+
...(item.oldText !== undefined && { oldText: item.oldText }),
|
|
396
|
+
newText: item.newText,
|
|
397
|
+
},
|
|
398
|
+
]
|
|
399
|
+
: [],
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
|
|
271
403
|
function chunk(
|
|
272
404
|
kind: "agent_message_chunk" | "agent_thought_chunk",
|
|
273
405
|
text: string,
|
|
@@ -276,11 +408,21 @@ function chunk(
|
|
|
276
408
|
return { sessionUpdate: kind, content: { type: "text", text }, messageId };
|
|
277
409
|
}
|
|
278
410
|
|
|
279
|
-
/**
|
|
411
|
+
/**
|
|
412
|
+
* ACP prompt content → engine input: text, base64 images, and a resource
|
|
413
|
+
* link as a Markdown link in the text, which ACP v1 has every agent take (a
|
|
414
|
+
* client's @-mention of a file) and any harness's agent can follow. Audio
|
|
415
|
+
* and embedded resources, which the binding does not advertise, are dropped.
|
|
416
|
+
*/
|
|
280
417
|
export function fromPromptBlocks(prompt: ContentBlock[]): string | PartInput[] {
|
|
281
418
|
const parts: PartInput[] = [];
|
|
282
419
|
for (const block of prompt) {
|
|
283
420
|
if (block.type === "text" && block.text) parts.push({ type: "text", text: block.text });
|
|
421
|
+
else if (block.type === "resource_link")
|
|
422
|
+
parts.push({
|
|
423
|
+
type: "text",
|
|
424
|
+
text: block.name && block.name !== block.uri ? `[${block.name}](${block.uri})` : block.uri,
|
|
425
|
+
});
|
|
284
426
|
else if (block.type === "image" && block.data) {
|
|
285
427
|
parts.push({ type: "image", data: block.data, mimeType: block.mimeType });
|
|
286
428
|
}
|
|
@@ -289,13 +431,18 @@ export function fromPromptBlocks(prompt: ContentBlock[]): string | PartInput[] {
|
|
|
289
431
|
return parts.length ? parts : "";
|
|
290
432
|
}
|
|
291
433
|
|
|
292
|
-
/**
|
|
434
|
+
/**
|
|
435
|
+
* ACP `McpServer[]` → engine MCP config map (inverse of the harness-side
|
|
436
|
+
* mapping). A server of another transport throws, naming it: ACP v1 lets a
|
|
437
|
+
* client send one only to an agent that advertised it, says nothing of what
|
|
438
|
+
* an agent does with one it did not, and a session without a server it
|
|
439
|
+
* asked for must not run as if it had it.
|
|
440
|
+
*/
|
|
293
441
|
export function fromAcpMcpServers(
|
|
294
442
|
servers: McpServer[] | undefined,
|
|
295
443
|
): Record<string, McpServerConfig> | undefined {
|
|
296
444
|
if (!servers?.length) return undefined;
|
|
297
445
|
const out: Record<string, McpServerConfig> = {};
|
|
298
|
-
// Note: the SDK's `type: "acp"` nested-agent variant is silently dropped.
|
|
299
446
|
for (const server of servers) {
|
|
300
447
|
if ("command" in server) {
|
|
301
448
|
out[server.name] = {
|
|
@@ -310,6 +457,12 @@ export function fromAcpMcpServers(
|
|
|
310
457
|
url: server.url,
|
|
311
458
|
headers: Object.fromEntries((server.headers ?? []).map((h) => [h.name, h.value])),
|
|
312
459
|
};
|
|
460
|
+
} else {
|
|
461
|
+
// The SDK's `acp` transport (MCP over the ACP channel, unstable) or one newer still.
|
|
462
|
+
const transport = (server as { type?: unknown }).type;
|
|
463
|
+
throw new Error(
|
|
464
|
+
`MCP server "${server.name}" uses the ${String(transport)} transport, which agent-server cannot attach (it takes stdio, http and sse)`,
|
|
465
|
+
);
|
|
313
466
|
}
|
|
314
467
|
}
|
|
315
468
|
return Object.keys(out).length ? out : undefined;
|
|
@@ -134,7 +134,7 @@ export class AgentServer {
|
|
|
134
134
|
this.store = journal ?? new MemorySessionStore(options.bufferSize);
|
|
135
135
|
this.subscriptions = new Subscriptions({
|
|
136
136
|
maxSubscriptions: options.maxSubscriptions ?? DEFAULT_MAX_SUBSCRIPTIONS,
|
|
137
|
-
maxBacklogBytes:
|
|
137
|
+
maxBacklogBytes: this.maxBacklogBytes,
|
|
138
138
|
});
|
|
139
139
|
// Each native process a session's turn starts is in the journal before it gets work.
|
|
140
140
|
this.unrecord = journal
|
|
@@ -179,6 +179,15 @@ export class AgentServer {
|
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
/**
|
|
183
|
+
* How far behind a connection may fall before it is sent `session/overflow`
|
|
184
|
+
* (`AgentServerOptions.maxBacklogBytes`): `listen` keeps its socket's own
|
|
185
|
+
* limit above it, so the notice is never the frame the socket drops.
|
|
186
|
+
*/
|
|
187
|
+
get maxBacklogBytes(): number {
|
|
188
|
+
return this.options.maxBacklogBytes ?? DEFAULT_MAX_BACKLOG_BYTES;
|
|
189
|
+
}
|
|
190
|
+
|
|
182
191
|
/** Serve the wire on a transport; returns a detach function, which drops its subscriptions. */
|
|
183
192
|
attach(transport: WireTransport): () => void {
|
|
184
193
|
this.subscriptions.attach(transport);
|