@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
package/src/core/agents/base.ts
CHANGED
|
@@ -141,6 +141,12 @@ export interface AppliedExecution {
|
|
|
141
141
|
thinkingLevel?: ThinkingLevel;
|
|
142
142
|
/** A model the harness reported for this turn (joins `reportedModels`). */
|
|
143
143
|
model?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Settings this turn set that the harness found, as it ran, it could not
|
|
146
|
+
* apply (`execution.notApplied`); those it never applies are its
|
|
147
|
+
* `capabilities.ignoredSettings`, which the engine adds itself.
|
|
148
|
+
*/
|
|
149
|
+
notApplied?: Array<keyof RunConfig>;
|
|
144
150
|
}
|
|
145
151
|
|
|
146
152
|
/** Whose models to list: the same login and folder a turn would use. */
|
|
@@ -156,6 +162,13 @@ export interface ListModelsOptions {
|
|
|
156
162
|
/** Raw, harness-specific event. Adapters interpret it; the engine never does. */
|
|
157
163
|
export type RawAgentEvent = unknown;
|
|
158
164
|
|
|
165
|
+
/**
|
|
166
|
+
* How long a cancel waits for the harness to show its turn stopped before it
|
|
167
|
+
* answers `confirmed: false`, unless `cancelConfirmMs` says otherwise. One
|
|
168
|
+
* value for every built-in harness.
|
|
169
|
+
*/
|
|
170
|
+
export const CANCEL_CONFIRM_MS = 2_000;
|
|
171
|
+
|
|
159
172
|
/**
|
|
160
173
|
* What `cancel` reports back. `confirmed: true` = the cancelled state holds —
|
|
161
174
|
* either nothing was running (`hadTurn: false`, a clean no-op ack) or the
|
|
@@ -217,16 +230,18 @@ export interface Agent {
|
|
|
217
230
|
/** Its CLI's own login: what it is, signing in through the CLI's flows, signing out. */
|
|
218
231
|
readonly login?: CliLogin;
|
|
219
232
|
/**
|
|
220
|
-
* The CLI's login changed
|
|
221
|
-
*
|
|
222
|
-
*
|
|
233
|
+
* The CLI's login changed in `store` (its login's `store`), or in every
|
|
234
|
+
* store when none is named: each of that store's sessions starts its next
|
|
235
|
+
* turn on a new process, which resumes its conversation, since a running
|
|
236
|
+
* CLI keeps the credentials it started with.
|
|
223
237
|
*/
|
|
224
|
-
loginChanged?(): void;
|
|
238
|
+
loginChanged?(store?: string): void;
|
|
225
239
|
/**
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
240
|
+
* The `NativeProcesses` through which this agent starts every native
|
|
241
|
+
* process it starts, or, for an agent that starts none, the one it names
|
|
242
|
+
* to say so: the runtime whose registry holds the same one can vouch for
|
|
243
|
+
* its sessions after a restart (`AgentRuntime.recordedHarnesses`). An
|
|
244
|
+
* agent without it has its sessions fenced whenever a restart cuts one off.
|
|
230
245
|
*/
|
|
231
246
|
readonly processes?: NativeProcesses;
|
|
232
247
|
/** Tear down every live session (process shutdown). Built-ins reject subsequent turns. */
|
|
@@ -257,8 +272,8 @@ export abstract class BaseAgent implements Agent {
|
|
|
257
272
|
for (const controller of controllers ?? []) controller.abort();
|
|
258
273
|
// Idle sessions are a clean no-op ack, and the abort signal
|
|
259
274
|
// deterministically ends the engine's execute loop for tracked turns —
|
|
260
|
-
// both confirmed.
|
|
261
|
-
//
|
|
275
|
+
// both confirmed. `SessionAgent` answers for a harness whose backend
|
|
276
|
+
// has a stop of its own to confirm.
|
|
262
277
|
return { confirmed: true, hadTurn };
|
|
263
278
|
}
|
|
264
279
|
|
|
@@ -26,7 +26,8 @@ import type { AdapterEvent, EventTransformer, TransformResult } from "../types.t
|
|
|
26
26
|
import type { ClaudeQuerySettled, ClaudeRawEvent } from "./events.ts";
|
|
27
27
|
import { fromSdkPermissionMode } from "./options.ts";
|
|
28
28
|
import { ClaudeTurnOutcome, claudeErrorCategory } from "./outcome.ts";
|
|
29
|
-
import {
|
|
29
|
+
import { claudeResultView } from "./results.ts";
|
|
30
|
+
import { claudeToolMeta } from "./tools.ts";
|
|
30
31
|
import { ClaudeTurnUsage } from "./turn-usage.ts";
|
|
31
32
|
|
|
32
33
|
/**
|
|
@@ -159,6 +160,8 @@ export class ClaudeCodeTransformer implements EventTransformer<unknown> {
|
|
|
159
160
|
private settled?: ClaudeQuerySettled;
|
|
160
161
|
private readonly usage = new ClaudeTurnUsage();
|
|
161
162
|
private readonly outcome = new ClaudeTurnOutcome();
|
|
163
|
+
/** The MCP servers the session knows, which name its MCP tools. */
|
|
164
|
+
private mcpServers = new Set<string>();
|
|
162
165
|
|
|
163
166
|
constructor(ctx: { sessionId: string }) {
|
|
164
167
|
this.ctx = { sessionId: ctx.sessionId, messageId: "" };
|
|
@@ -173,7 +176,10 @@ export class ClaudeCodeTransformer implements EventTransformer<unknown> {
|
|
|
173
176
|
case "assistant":
|
|
174
177
|
return this.handleAssistant(event);
|
|
175
178
|
case "user":
|
|
176
|
-
return this.handleToolResults(event.message?.content);
|
|
179
|
+
return this.handleToolResults(event.message?.content, event.tool_use_result);
|
|
180
|
+
case "agentServer/mcpServers":
|
|
181
|
+
for (const name of event.names) this.mcpServers.add(name);
|
|
182
|
+
return [];
|
|
177
183
|
case "agentServer/querySettled":
|
|
178
184
|
this.settled = event;
|
|
179
185
|
return [];
|
|
@@ -210,6 +216,8 @@ export class ClaudeCodeTransformer implements EventTransformer<unknown> {
|
|
|
210
216
|
switch (event.subtype) {
|
|
211
217
|
case "init":
|
|
212
218
|
if (typeof event.model === "string") this.usage.requested(event.model);
|
|
219
|
+
for (const server of Array.isArray(event.mcp_servers) ? event.mcp_servers : [])
|
|
220
|
+
this.mcpServers.add(server.name);
|
|
213
221
|
return [];
|
|
214
222
|
case "api_retry": {
|
|
215
223
|
const message = `Claude API ${event.error_status ? `error ${event.error_status}` : "connection failed"}${event.error ? ` (${event.error})` : ""}`;
|
|
@@ -308,7 +316,7 @@ export class ClaudeCodeTransformer implements EventTransformer<unknown> {
|
|
|
308
316
|
const input = isRecord(block.input) ? block.input : {};
|
|
309
317
|
const subagent = subagentFromInput(name, input);
|
|
310
318
|
const part = createToolPart(this.ctxFor(), block.id, name, input, {
|
|
311
|
-
...claudeToolMeta(name, input),
|
|
319
|
+
...claudeToolMeta(name, input, this.mcpServers),
|
|
312
320
|
...(subagent && { subagent }),
|
|
313
321
|
});
|
|
314
322
|
this.toolPartsById.set(block.id, part);
|
|
@@ -376,7 +384,12 @@ export class ClaudeCodeTransformer implements EventTransformer<unknown> {
|
|
|
376
384
|
}
|
|
377
385
|
if (cb.type === "tool_use") {
|
|
378
386
|
const name = cb.name ?? "tool";
|
|
379
|
-
const part = createPendingToolPart(
|
|
387
|
+
const part = createPendingToolPart(
|
|
388
|
+
this.ctxFor(),
|
|
389
|
+
cb.id ?? "",
|
|
390
|
+
name,
|
|
391
|
+
claudeToolMeta(name, undefined, this.mcpServers),
|
|
392
|
+
);
|
|
380
393
|
this.blocks.set(index, { partId: part.id, kind: "tool", part });
|
|
381
394
|
if (cb.id) this.toolPartsById.set(cb.id, part);
|
|
382
395
|
return [{ kind: "part-open", part }];
|
|
@@ -439,7 +452,7 @@ export class ClaudeCodeTransformer implements EventTransformer<unknown> {
|
|
|
439
452
|
if (tool?.state.status !== "in_progress") continue;
|
|
440
453
|
if (JSON.stringify(tool.state.input) === JSON.stringify(block.input)) continue;
|
|
441
454
|
tool.state = { ...tool.state, input: block.input };
|
|
442
|
-
setToolMeta(tool, claudeToolMeta(tool.toolName, block.input));
|
|
455
|
+
setToolMeta(tool, claudeToolMeta(tool.toolName, block.input, this.mcpServers));
|
|
443
456
|
events.push({ kind: "part-update", part: tool });
|
|
444
457
|
}
|
|
445
458
|
return events;
|
|
@@ -462,30 +475,47 @@ export class ClaudeCodeTransformer implements EventTransformer<unknown> {
|
|
|
462
475
|
const input = this.completeInputs.get(tool.toolCallId) ?? safeParseJson(partial);
|
|
463
476
|
this.completeInputs.delete(tool.toolCallId);
|
|
464
477
|
startToolPart(tool, input);
|
|
465
|
-
// The streamed open carried no input, so
|
|
466
|
-
// read now that the partial JSON has parsed.
|
|
467
|
-
const locations = toolLocationsFromInput(input);
|
|
478
|
+
// The streamed open carried no input, so what the call acts on and its
|
|
479
|
+
// subagent can only be read now that the partial JSON has parsed.
|
|
468
480
|
const subagent = subagentFromInput(tool.toolName, input);
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
481
|
+
setToolMeta(tool, {
|
|
482
|
+
...claudeToolMeta(tool.toolName, input, this.mcpServers),
|
|
483
|
+
...(subagent && { subagent }),
|
|
484
|
+
});
|
|
472
485
|
return [{ kind: "part-update", part: tool }];
|
|
473
486
|
}
|
|
474
487
|
|
|
488
|
+
/**
|
|
489
|
+
* Tool results complete their parts. The message's `tool_use_result` is the
|
|
490
|
+
* structured result of its one tool result: the CLI sends each in a
|
|
491
|
+
* message of its own, so a message with several has none that is theirs.
|
|
492
|
+
*/
|
|
475
493
|
private handleToolResults(
|
|
476
494
|
content: Extract<SDKMessage, { type: "user" }>["message"]["content"] | undefined,
|
|
495
|
+
structured: unknown,
|
|
477
496
|
): AdapterEvent[] {
|
|
478
497
|
if (!Array.isArray(content)) return [];
|
|
498
|
+
const results = content.filter((block) => block.type === "tool_result");
|
|
479
499
|
const events: AdapterEvent[] = [];
|
|
480
|
-
for (const block of
|
|
481
|
-
if (
|
|
500
|
+
for (const block of results) {
|
|
501
|
+
if (!block.tool_use_id) continue;
|
|
482
502
|
const tool = this.toolPartsById.get(block.tool_use_id);
|
|
483
503
|
if (!tool) continue;
|
|
484
|
-
const
|
|
504
|
+
const output = stringifyToolResult(block.content);
|
|
505
|
+
const isError = block.is_error === true;
|
|
506
|
+
const view = claudeResultView(
|
|
507
|
+
tool.toolName,
|
|
508
|
+
results.length === 1 ? structured : undefined,
|
|
509
|
+
output,
|
|
510
|
+
isError,
|
|
511
|
+
);
|
|
512
|
+
const shown = [...(toolResultContent(block.content) ?? []), ...(view.content ?? [])];
|
|
513
|
+
if (view.locations) setToolMeta(tool, { locations: view.locations });
|
|
485
514
|
completeToolPart(tool, {
|
|
486
|
-
output
|
|
487
|
-
isError
|
|
488
|
-
...(
|
|
515
|
+
output,
|
|
516
|
+
isError,
|
|
517
|
+
...(shown.length && { content: shown }),
|
|
518
|
+
...(view.metadata && { metadata: view.metadata }),
|
|
489
519
|
});
|
|
490
520
|
events.push({ kind: "part-update", part: tool });
|
|
491
521
|
}
|
|
@@ -15,14 +15,11 @@ import {
|
|
|
15
15
|
} from "../elicitation.ts";
|
|
16
16
|
import { PLAN_OPTIONS, PLAN_TITLE, approvedPlanMode } from "../plan.ts";
|
|
17
17
|
import { type ClaudeToolPolicy, fromSdkPermissionMode, toSdkPermissionMode } from "./options.ts";
|
|
18
|
-
import { claudeToolMeta } from "./tools.ts";
|
|
18
|
+
import { claudeMcpTool, claudeToolMeta } from "./tools.ts";
|
|
19
19
|
import type { ClaudeTurn } from "./turn.ts";
|
|
20
20
|
|
|
21
21
|
/** What a request needs of the turn it is asked in. */
|
|
22
|
-
|
|
23
|
-
ClaudeTurn,
|
|
24
|
-
"permissions" | "elicitation" | "cancelByRequest"
|
|
25
|
-
>;
|
|
22
|
+
type ClaudeTurnRequests = Pick<ClaudeTurn, "permissions" | "elicitation" | "cancelByRequest">;
|
|
26
23
|
|
|
27
24
|
/** What Claude is told when it asks while no turn runs. */
|
|
28
25
|
const NO_TURN = "No turn is running, so nobody can answer this.";
|
|
@@ -67,9 +64,14 @@ export function createCanUseTool(deps: {
|
|
|
67
64
|
policy?: ClaudeToolPolicy;
|
|
68
65
|
/** The turn running now; null between turns. */
|
|
69
66
|
turn: () => ClaudeTurnRequests | null;
|
|
67
|
+
/** The MCP servers the session knows, which name its MCP tools. */
|
|
68
|
+
mcpServers?: () => readonly string[];
|
|
70
69
|
}): CanUseTool {
|
|
71
70
|
return async (toolName, input, options) => {
|
|
72
71
|
const { signal, toolUseID, agentID, suggestions, blockedPath, decisionReason } = options;
|
|
72
|
+
// The policy gets the `mcp` the request will carry; the rest of the
|
|
73
|
+
// request's metadata is read after the policy, which may change `input`.
|
|
74
|
+
const mcp = claudeMcpTool(toolName, deps.mcpServers?.());
|
|
73
75
|
// The host's policy sees every call first, questions and plans too: a
|
|
74
76
|
// host answers a plan through its own channel (AGNT does). A policy
|
|
75
77
|
// that wants the user to answer them returns undefined.
|
|
@@ -81,6 +83,7 @@ export function createCanUseTool(deps: {
|
|
|
81
83
|
suggestions,
|
|
82
84
|
blockedPath,
|
|
83
85
|
decisionReason,
|
|
86
|
+
...(mcp && { mcp }),
|
|
84
87
|
});
|
|
85
88
|
if (verdict) return verdict;
|
|
86
89
|
const turn = deps.turn();
|
|
@@ -100,12 +103,14 @@ export function createCanUseTool(deps: {
|
|
|
100
103
|
opts: { options?: PermissionOption[]; always?: { rule: string } | null },
|
|
101
104
|
): Promise<PermissionDecision | undefined> => {
|
|
102
105
|
if (!turn.permissions) return undefined;
|
|
106
|
+
// @ref LLP 0002#a-tool-call-says-what-it-acts-on — why Claude asks is `reason`, in the CLI's words
|
|
103
107
|
const toolCall: PermissionToolCall = {
|
|
104
108
|
toolCallId: toolUseID,
|
|
105
109
|
toolName,
|
|
106
110
|
...(title && { title }),
|
|
111
|
+
...(decisionReason && { reason: decisionReason }),
|
|
107
112
|
rawInput: input,
|
|
108
|
-
...claudeToolMeta(toolName, input),
|
|
113
|
+
...claudeToolMeta(toolName, input, deps.mcpServers?.()),
|
|
109
114
|
};
|
|
110
115
|
const decision = await turn.permissions(toolCall, { signal, ...opts });
|
|
111
116
|
// A request Claude withdrew itself (a hook decided first) is not a cancel.
|
|
@@ -8,24 +8,36 @@ import type {
|
|
|
8
8
|
AgentInput,
|
|
9
9
|
McpServerConfig,
|
|
10
10
|
ModelDescriptor,
|
|
11
|
+
RunConfig,
|
|
11
12
|
} from "../../../protocol/index.ts";
|
|
12
13
|
import { emitDiagnostic } from "../../diagnostics.ts";
|
|
13
14
|
import { type NativeProcesses, sharedNativeProcesses } from "../../processes/native-processes.ts";
|
|
14
|
-
import { onAbort } from "../../utils/deadline.ts";
|
|
15
|
+
import { onAbort, untilAborted } from "../../utils/deadline.ts";
|
|
15
16
|
import { SessionResumeError } from "../../utils/errors.ts";
|
|
16
17
|
import { UnsupportedAttachmentError, attachedText, isTextMedia } from "../attachments.ts";
|
|
17
|
-
import type { AgentExecuteOptions,
|
|
18
|
+
import type { AgentExecuteOptions, ListModelsOptions } from "../base.ts";
|
|
18
19
|
import { SessionAgent } from "../session-agent.ts";
|
|
19
20
|
import { ClaudeCredentials, type ClaudeDelivery, ON_PLACEHOLDER } from "./credentials.ts";
|
|
20
21
|
import type { ClaudeRawEvent } from "./events.ts";
|
|
21
22
|
import { ClaudeCliLogin } from "./login.ts";
|
|
22
23
|
import { claudeModelDescriptors, fitClaudeThinking, readClaudeModels } from "./models.ts";
|
|
23
24
|
import { type ClaudeCodeAgentOptions, claudeSessionConfig } from "./options.ts";
|
|
24
|
-
import {
|
|
25
|
-
|
|
25
|
+
import {
|
|
26
|
+
type ClaudePoolTurn,
|
|
27
|
+
type ClaudeSession,
|
|
28
|
+
type ClaudeSessionPool,
|
|
29
|
+
claudeSessionPool,
|
|
30
|
+
} from "./session.ts";
|
|
31
|
+
import type { ClaudeTurn } from "./turn.ts";
|
|
26
32
|
|
|
27
33
|
type ClaudeContent = SDKUserMessage["message"]["content"];
|
|
28
34
|
|
|
35
|
+
/**
|
|
36
|
+
* How long after a cancel a turn Claude has not ended has its process ended,
|
|
37
|
+
* unless `cancelGraceMs` says otherwise (LLP 0001, D9).
|
|
38
|
+
*/
|
|
39
|
+
const CANCEL_GRACE_MS = 10_000;
|
|
40
|
+
|
|
29
41
|
const CAPABILITIES: AgentCapabilities = {
|
|
30
42
|
multiTurn: true,
|
|
31
43
|
sessionResume: true,
|
|
@@ -40,6 +52,8 @@ const CAPABILITIES: AgentCapabilities = {
|
|
|
40
52
|
rejectionMessages: true,
|
|
41
53
|
turnScopedSubagents: true,
|
|
42
54
|
steering: true,
|
|
55
|
+
// Every turn setting reaches the SDK (`buildClaudeOptions`).
|
|
56
|
+
ignoredSettings: [],
|
|
43
57
|
};
|
|
44
58
|
|
|
45
59
|
/**
|
|
@@ -110,11 +124,13 @@ export class ClaudeCodeAgent extends SessionAgent {
|
|
|
110
124
|
readonly login: ClaudeCliLogin;
|
|
111
125
|
private readonly pool: ClaudeSessionPool;
|
|
112
126
|
private readonly credentials?: ClaudeCredentials;
|
|
127
|
+
private readonly cancelGraceMs: number;
|
|
113
128
|
|
|
114
129
|
constructor(private readonly agentOptions: ClaudeCodeAgentOptions = {}) {
|
|
115
|
-
super();
|
|
130
|
+
super({ cancelConfirmMs: agentOptions.cancelConfirmMs });
|
|
131
|
+
this.cancelGraceMs = agentOptions.cancelGraceMs ?? CANCEL_GRACE_MS;
|
|
116
132
|
this.processes = agentOptions.processes ?? sharedNativeProcesses();
|
|
117
|
-
this.pool =
|
|
133
|
+
this.pool = claudeSessionPool({ ...agentOptions, processes: this.processes });
|
|
118
134
|
this.login = new ClaudeCliLogin({
|
|
119
135
|
resolveCliPath: agentOptions.resolveCliPath,
|
|
120
136
|
processes: this.processes,
|
|
@@ -134,8 +150,8 @@ export class ClaudeCodeAgent extends SessionAgent {
|
|
|
134
150
|
: options;
|
|
135
151
|
}
|
|
136
152
|
|
|
137
|
-
loginChanged(): void {
|
|
138
|
-
this.pool.loginChanged();
|
|
153
|
+
loginChanged(store?: string): void {
|
|
154
|
+
this.pool.loginChanged(store);
|
|
139
155
|
}
|
|
140
156
|
|
|
141
157
|
protected override async *executeTurn(
|
|
@@ -143,11 +159,21 @@ export class ClaudeCodeAgent extends SessionAgent {
|
|
|
143
159
|
options: AgentExecuteOptions,
|
|
144
160
|
controller: AbortController,
|
|
145
161
|
): AsyncIterableIterator<ClaudeRawEvent> {
|
|
162
|
+
let held: ClaudeSession | undefined;
|
|
163
|
+
// The turn a cancel may interrupt, once it is sent.
|
|
164
|
+
let interruptible: ClaudeTurn | undefined;
|
|
146
165
|
let unconfirmedSession: ClaudeSession | undefined;
|
|
147
166
|
let removeInterrupt: (() => void) | undefined;
|
|
167
|
+
// @ref LLP 0001#d10--built-in-turns-own-their-logical-session-through-cleanup — a start under way ends at the abort, at once
|
|
168
|
+
// Until the turn has its process, the abort is the whole stop.
|
|
169
|
+
this.cancelWith(options, async () =>
|
|
170
|
+
held ? this.interrupt(held, interruptible, options.sessionId) : true,
|
|
171
|
+
);
|
|
148
172
|
try {
|
|
149
173
|
controller.signal.throwIfAborted();
|
|
150
|
-
|
|
174
|
+
// @ref LLP 0010#a-turn-waits-for-its-cli-until-it-is-cancelled — the install is the server's
|
|
175
|
+
const { resolveCliPath } = this.agentOptions;
|
|
176
|
+
const cliPath = resolveCliPath && (await untilAborted(resolveCliPath(), controller.signal));
|
|
151
177
|
const content = toClaudeContent(input);
|
|
152
178
|
controller.signal.throwIfAborted();
|
|
153
179
|
const thinking = fitClaudeThinking(options.thinkingLevel, options.modelThinking);
|
|
@@ -156,16 +182,26 @@ export class ClaudeCodeAgent extends SessionAgent {
|
|
|
156
182
|
await this.credentials?.forTurn(options.sessionId, options.turnId, controller.signal),
|
|
157
183
|
);
|
|
158
184
|
controller.signal.throwIfAborted();
|
|
159
|
-
const
|
|
160
|
-
options.sessionId,
|
|
161
|
-
claudeSessionConfig(
|
|
185
|
+
const wanted: ClaudePoolTurn = {
|
|
186
|
+
sessionId: options.sessionId,
|
|
187
|
+
config: claudeSessionConfig(
|
|
162
188
|
{ ...turnOptions, thinkingLevel: thinking.send },
|
|
163
189
|
cliPath,
|
|
164
190
|
this.agentOptions.inheritConfig,
|
|
165
191
|
),
|
|
166
|
-
|
|
192
|
+
};
|
|
193
|
+
const session = await this.pool.acquire(options.sessionId, wanted, controller.signal);
|
|
194
|
+
held = session;
|
|
195
|
+
const spawned = wanted.spawned === true;
|
|
167
196
|
if (thinking.applied && !session.operatorThinking)
|
|
168
197
|
options.onExecution?.({ thinkingLevel: thinking.applied });
|
|
198
|
+
const notApplied: Array<keyof RunConfig> = [];
|
|
199
|
+
// A model known to have no effort levels is sent no level (`fitClaudeThinking`).
|
|
200
|
+
if (options.thinkingLevel !== undefined && thinking.send === undefined)
|
|
201
|
+
notApplied.push("thinkingLevel");
|
|
202
|
+
// A message to resume at goes only with a resume (`buildClaudeOptions`).
|
|
203
|
+
if (options.resumeSessionAt && !options.resumeSessionId) notApplied.push("resumeSessionAt");
|
|
204
|
+
if (notApplied.length) options.onExecution?.({ notApplied });
|
|
169
205
|
const attemptedResume = spawned && Boolean(options.resumeSessionId);
|
|
170
206
|
if (spawned) unconfirmedSession = session;
|
|
171
207
|
// A cancel during connection repair must never submit the prompt.
|
|
@@ -188,13 +224,19 @@ export class ClaudeCodeAgent extends SessionAgent {
|
|
|
188
224
|
permissions: options.onPermissionRequest,
|
|
189
225
|
elicitation: options.onElicitationRequest,
|
|
190
226
|
});
|
|
227
|
+
interruptible = turn;
|
|
191
228
|
try {
|
|
192
229
|
await this.openSteering(options, (request) =>
|
|
193
230
|
session.steer(toClaudeContent(request.input), request.steerId)
|
|
194
231
|
? "steered"
|
|
195
232
|
: "no_active_turn",
|
|
196
233
|
);
|
|
197
|
-
removeInterrupt = onAbort(controller.signal, () =>
|
|
234
|
+
removeInterrupt = onAbort(controller.signal, () => {
|
|
235
|
+
void session.interruptTurn();
|
|
236
|
+
void session.endUnstopped(turn, this.cancelGraceMs);
|
|
237
|
+
});
|
|
238
|
+
const mcpServers = session.mcp.names;
|
|
239
|
+
if (mcpServers.length) yield { type: "agentServer/mcpServers", names: mcpServers };
|
|
198
240
|
let sawOutput = false;
|
|
199
241
|
for await (const event of turn.events) {
|
|
200
242
|
if (event.type === "assistant" || event.type === "stream_event") sawOutput = true;
|
|
@@ -245,6 +287,8 @@ export class ClaudeCodeAgent extends SessionAgent {
|
|
|
245
287
|
// A cancelled/failed preparation must not leave an unconfirmed query
|
|
246
288
|
// looking like a healthy warm conversation on the next attempt.
|
|
247
289
|
await unconfirmedSession?.terminate();
|
|
290
|
+
// A warm one waits for the next turn, at most the idle time.
|
|
291
|
+
if (held) this.pool.leave(options.sessionId, held);
|
|
248
292
|
}
|
|
249
293
|
}
|
|
250
294
|
|
|
@@ -274,32 +318,43 @@ export class ClaudeCodeAgent extends SessionAgent {
|
|
|
274
318
|
|
|
275
319
|
/**
|
|
276
320
|
* Hot-swap the live session's wire MCP servers without a restart (context
|
|
277
|
-
* intact).
|
|
278
|
-
*
|
|
321
|
+
* intact). A session still starting takes it once ready, after the servers
|
|
322
|
+
* its turn attaches. Returns undefined when the session isn't live. In-process servers
|
|
323
|
+
* are preserved across swaps. The next turn's own `mcpServers` swap back
|
|
324
|
+
* when they still name the old set: keep them in step.
|
|
279
325
|
*/
|
|
280
326
|
async setMcpServers(
|
|
281
327
|
sessionId: string,
|
|
282
328
|
servers: Record<string, McpServerConfig>,
|
|
283
329
|
): Promise<McpSetServersResult | undefined> {
|
|
284
|
-
return this.pool.setMcpServers(
|
|
330
|
+
return this.pool.client(sessionId)?.setMcpServers(servers);
|
|
285
331
|
}
|
|
286
332
|
|
|
287
333
|
/** Resume saved history in a fresh subprocess on the next turn after host suspension. */
|
|
288
334
|
invalidateMcpConnections(): void {
|
|
289
|
-
this.pool.
|
|
335
|
+
this.pool.invalidate();
|
|
290
336
|
}
|
|
291
337
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
338
|
+
/**
|
|
339
|
+
* Interrupt the turn's process for a cancel, which has already aborted the
|
|
340
|
+
* turn: the controller ends the engine's execute loop, so this turn
|
|
341
|
+
* classifies as cancelled even when the generator drains to a natural end
|
|
342
|
+
* before the SDK interrupt lands (the abort-order race that could surface
|
|
343
|
+
* a clean user cancel as `error`/`end_turn`). The SDK interrupt's
|
|
344
|
+
* round-trip confirms the cancel, and so does the turn's end, whoever ended
|
|
345
|
+
* it: Claude, or the grace that ended its process (`endUnstopped`). An
|
|
346
|
+
* interrupt that fails while the turn runs is unconfirmed at once.
|
|
347
|
+
*/
|
|
348
|
+
private async interrupt(
|
|
349
|
+
session: ClaudeSession,
|
|
350
|
+
turn: ClaudeTurn | undefined,
|
|
351
|
+
sessionId: string,
|
|
352
|
+
): Promise<boolean> {
|
|
353
|
+
// @ref LLP 0016.000#the-cancel-answer — a turn that ended is confirmed stopped, however it ended
|
|
354
|
+
const interrupting = session.interruptTurn();
|
|
355
|
+
const interrupted = turn
|
|
356
|
+
? await Promise.race([interrupting, turn.ended.then(() => true)])
|
|
357
|
+
: await interrupting;
|
|
303
358
|
if (!interrupted) {
|
|
304
359
|
emitDiagnostic(this.agentOptions.onDiagnostic, {
|
|
305
360
|
type: "interruptTimeout",
|
|
@@ -307,18 +362,20 @@ export class ClaudeCodeAgent extends SessionAgent {
|
|
|
307
362
|
message: "cancel dispatched but the SDK interrupt was not acknowledged in time",
|
|
308
363
|
});
|
|
309
364
|
}
|
|
310
|
-
return
|
|
365
|
+
return interrupted;
|
|
311
366
|
}
|
|
312
367
|
|
|
313
368
|
override async release(sessionId: string): Promise<void> {
|
|
314
369
|
await super.release(sessionId);
|
|
315
|
-
await this.pool.
|
|
370
|
+
await this.pool.release(sessionId);
|
|
316
371
|
this.credentials?.release(sessionId);
|
|
317
372
|
}
|
|
318
373
|
|
|
319
374
|
override async terminateAll(): Promise<void> {
|
|
375
|
+
// Before the turns are aborted: a start under way ends for shutdown, not as a cancel.
|
|
376
|
+
const closed = this.pool.closeAll();
|
|
320
377
|
await super.terminateAll();
|
|
321
|
-
await
|
|
378
|
+
await closed;
|
|
322
379
|
await this.credentials?.close();
|
|
323
380
|
}
|
|
324
381
|
}
|
|
@@ -14,7 +14,17 @@ export type ClaudeRawEvent =
|
|
|
14
14
|
| SDKMessage
|
|
15
15
|
| ClaudeTurnInterrupted
|
|
16
16
|
| ClaudeSteerRead
|
|
17
|
-
| ClaudeQuerySettled
|
|
17
|
+
| ClaudeQuerySettled
|
|
18
|
+
| ClaudeMcpServerNames;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The MCP servers the session knows as the turn begins, which name its MCP
|
|
22
|
+
* tools (`mcp__<server>__<tool>`): a server's name may hold `__` itself.
|
|
23
|
+
*/
|
|
24
|
+
export interface ClaudeMcpServerNames {
|
|
25
|
+
type: "agentServer/mcpServers";
|
|
26
|
+
names: string[];
|
|
27
|
+
}
|
|
18
28
|
|
|
19
29
|
/**
|
|
20
30
|
* The turn was asked to stop. An interrupted query and one that failed end on
|
|
@@ -47,7 +47,7 @@ type ClaudeQuery = (params: {
|
|
|
47
47
|
options: CCOptions;
|
|
48
48
|
}) => Query & ClaudeLoginControl;
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
interface ClaudeCliLoginOptions {
|
|
51
51
|
resolveCliPath?: () => Promise<string | undefined>;
|
|
52
52
|
processes: NativeProcesses;
|
|
53
53
|
inheritConfig?: InheritConfig;
|
|
@@ -113,10 +113,22 @@ function httpsUrl(value: unknown): string {
|
|
|
113
113
|
return value;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
/** The variable that picks Claude Code's login store. */
|
|
117
|
+
const STORE_VARIABLE = "CLAUDE_CONFIG_DIR";
|
|
118
|
+
|
|
119
|
+
/** The login store a turn or a login with this `env` uses: its `CLAUDE_CONFIG_DIR`, empty when unset. */
|
|
120
|
+
export function claudeLoginStore(env: Record<string, string> | undefined): string {
|
|
121
|
+
return env?.[STORE_VARIABLE] ?? "";
|
|
122
|
+
}
|
|
123
|
+
|
|
116
124
|
/** Claude Code's login: `claude auth status`, its OAuth flows over the SDK, `claude auth logout`. */
|
|
117
125
|
export class ClaudeCliLogin implements CliLogin {
|
|
118
126
|
constructor(private readonly options: ClaudeCliLoginOptions) {}
|
|
119
127
|
|
|
128
|
+
store(env: Record<string, string> | undefined): string {
|
|
129
|
+
return claudeLoginStore(env);
|
|
130
|
+
}
|
|
131
|
+
|
|
120
132
|
/** The CLI to run a command of: the one turns run, else `$CLAUDE_CLI_PATH`, else `claude` on PATH. */
|
|
121
133
|
private async commandPath(): Promise<string> {
|
|
122
134
|
return (await this.options.resolveCliPath?.()) ?? process.env.CLAUDE_CLI_PATH ?? "claude";
|
|
@@ -134,7 +146,7 @@ export class ClaudeCliLogin implements CliLogin {
|
|
|
134
146
|
const cliPath = await this.commandPath();
|
|
135
147
|
return [
|
|
136
148
|
...LOGINS,
|
|
137
|
-
terminalMethod([cliPath, "auth", "login"], this.env(options),
|
|
149
|
+
terminalMethod([cliPath, "auth", "login"], this.env(options), STORE_VARIABLE),
|
|
138
150
|
];
|
|
139
151
|
}
|
|
140
152
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import type { SdkMcpServers } from "./options.ts";
|
|
12
12
|
|
|
13
13
|
/** What an MCP update asks of the live query. */
|
|
14
|
-
|
|
14
|
+
type McpControl = Pick<Query, "setMcpServers" | "mcpServerStatus">;
|
|
15
15
|
|
|
16
16
|
function remoteMcpServer(server: McpServerConfig): boolean {
|
|
17
17
|
return server.type === "http" || server.type === "sse";
|
|
@@ -33,6 +33,7 @@ function transientMcpError(error: string): boolean {
|
|
|
33
33
|
export class ClaudeMcpConnections {
|
|
34
34
|
private wire: Record<string, McpServerConfig>;
|
|
35
35
|
private host: SdkMcpServers = {};
|
|
36
|
+
private loaded: string[] = [];
|
|
36
37
|
private updates = Promise.resolve();
|
|
37
38
|
/**
|
|
38
39
|
* Set while an update has not finished, with the servers that failed in it.
|
|
@@ -41,12 +42,18 @@ export class ClaudeMcpConnections {
|
|
|
41
42
|
* uncertainty holds until a verified reattachment succeeds.
|
|
42
43
|
*/
|
|
43
44
|
private failed?: Set<string>;
|
|
44
|
-
private invalidated = false;
|
|
45
45
|
/** Servers not required that could not connect: the session's turns go on without them. */
|
|
46
46
|
readonly unavailable = new UnavailableMcpServers();
|
|
47
47
|
|
|
48
|
-
/**
|
|
49
|
-
|
|
48
|
+
/**
|
|
49
|
+
* `servers`: the spawning turn's, attached before its prompt.
|
|
50
|
+
* `hostResumed`: whether a host resume came since the process began to
|
|
51
|
+
* start (the pool's `startedBeforeResume`).
|
|
52
|
+
*/
|
|
53
|
+
constructor(
|
|
54
|
+
servers: Record<string, McpServerConfig> | undefined,
|
|
55
|
+
private readonly hostResumed: () => boolean = () => false,
|
|
56
|
+
) {
|
|
50
57
|
this.wire = snapshotMcpServers(servers);
|
|
51
58
|
}
|
|
52
59
|
|
|
@@ -55,6 +62,20 @@ export class ClaudeMcpConnections {
|
|
|
55
62
|
return this.wire;
|
|
56
63
|
}
|
|
57
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Every server name the session knows: the wire's, the host's, and those
|
|
67
|
+
* Claude loaded from the person's configuration (above `inheritConfig:
|
|
68
|
+
* "none"`), which its `system/init` lists. A tool name is matched against them.
|
|
69
|
+
*/
|
|
70
|
+
get names(): string[] {
|
|
71
|
+
return [...new Set([...Object.keys(this.wire), ...Object.keys(this.host), ...this.loaded])];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The servers Claude's `system/init` listed. */
|
|
75
|
+
sawLoaded(names: readonly string[]): void {
|
|
76
|
+
this.loaded = [...names];
|
|
77
|
+
}
|
|
78
|
+
|
|
58
79
|
/** The last update did not finish: what the CLI holds now is not known. */
|
|
59
80
|
get uncertain(): boolean {
|
|
60
81
|
return this.failed !== undefined;
|
|
@@ -62,17 +83,12 @@ export class ClaudeMcpConnections {
|
|
|
62
83
|
|
|
63
84
|
/**
|
|
64
85
|
* The process must be replaced: host suspension invalidated its
|
|
65
|
-
* subprocess-wide HTTP pool, which replacing MCP clients cannot clear.
|
|
86
|
+
* subprocess-wide HTTP pool, which replacing MCP clients cannot clear. A
|
|
87
|
+
* thawed VM can retain clients whose sockets still appear connected, so it
|
|
88
|
+
* holds until the process is replaced, whatever an update says after.
|
|
66
89
|
*/
|
|
67
90
|
get respawnRequired(): boolean {
|
|
68
|
-
return this.
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** A thawed VM can retain clients whose sockets still appear connected. */
|
|
72
|
-
invalidate(): void {
|
|
73
|
-
// Latch until process replacement, even if an in-flight MCP update
|
|
74
|
-
// succeeds or the current config no longer contains remote servers.
|
|
75
|
-
this.invalidated = true;
|
|
91
|
+
return this.hostResumed();
|
|
76
92
|
}
|
|
77
93
|
|
|
78
94
|
/** The host's in-process servers, resolved at spawn: every update keeps them, and they win a name. */
|
|
@@ -84,7 +100,7 @@ export class ClaudeMcpConnections {
|
|
|
84
100
|
needsUpdate(servers: Record<string, McpServerConfig> | undefined): boolean {
|
|
85
101
|
return (
|
|
86
102
|
this.uncertain ||
|
|
87
|
-
this.
|
|
103
|
+
this.respawnRequired ||
|
|
88
104
|
// A server the last turn went without is tried again once due, or at
|
|
89
105
|
// once when this turn requires it.
|
|
90
106
|
this.unavailable.retryNow(servers ?? {}).length > 0 ||
|
|
@@ -118,7 +134,7 @@ export class ClaudeMcpConnections {
|
|
|
118
134
|
query: McpControl,
|
|
119
135
|
servers: Record<string, McpServerConfig>,
|
|
120
136
|
): Promise<McpSetServersResult> {
|
|
121
|
-
if (this.
|
|
137
|
+
if (this.respawnRequired) throw new Error("Claude process must resume after host suspension");
|
|
122
138
|
const reconnect = this.failed !== undefined;
|
|
123
139
|
// What failed last time stays uncertain through this update, with what fails in it.
|
|
124
140
|
const failed = new Set(this.failed);
|