@zvada/agent-server 0.3.17 → 0.3.19
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/AGENTS.md +11 -26
- package/CHANGELOG.md +1060 -0
- package/README.md +50 -26
- package/dist/types/accounts/chatgpt.d.ts +34 -0
- package/dist/types/accounts/chatgpt.d.ts.map +1 -0
- package/dist/types/accounts/check.d.ts +24 -0
- package/dist/types/accounts/check.d.ts.map +1 -0
- package/dist/types/accounts/claude.d.ts +21 -0
- package/dist/types/accounts/claude.d.ts.map +1 -0
- package/dist/types/accounts/endpoint.d.ts +50 -0
- package/dist/types/accounts/endpoint.d.ts.map +1 -0
- package/dist/types/accounts/http.d.ts +38 -0
- package/dist/types/accounts/http.d.ts.map +1 -0
- package/dist/types/accounts/index.d.ts +6 -0
- package/dist/types/accounts/index.d.ts.map +1 -0
- package/dist/types/client/client.d.ts +272 -0
- package/dist/types/client/client.d.ts.map +1 -0
- package/dist/types/client/connection.d.ts +160 -0
- package/dist/types/client/connection.d.ts.map +1 -0
- package/dist/types/client/history.d.ts +8 -0
- package/dist/types/client/history.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +5 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/listeners.d.ts +8 -0
- package/dist/types/client/listeners.d.ts.map +1 -0
- package/dist/types/client/logins.d.ts +35 -0
- package/dist/types/client/logins.d.ts.map +1 -0
- package/dist/types/client/rpc.d.ts +46 -0
- package/dist/types/client/rpc.d.ts.map +1 -0
- package/dist/types/client/streams.d.ts +150 -0
- package/dist/types/client/streams.d.ts.map +1 -0
- package/dist/types/client/transports.d.ts +35 -0
- package/dist/types/client/transports.d.ts.map +1 -0
- package/dist/types/client/turns.d.ts +81 -0
- package/dist/types/client/turns.d.ts.map +1 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts +68 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -0
- package/dist/types/core/agents/acp/adapter.d.ts +39 -0
- package/dist/types/core/agents/acp/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/acp/client.d.ts +90 -0
- package/dist/types/core/agents/acp/client.d.ts.map +1 -0
- package/dist/types/core/agents/acp/known-agents.d.ts +35 -0
- package/dist/types/core/agents/acp/known-agents.d.ts.map +1 -0
- package/dist/types/core/agents/acp/mappings.d.ts +46 -0
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -0
- package/dist/types/core/agents/acp/requests.d.ts +26 -0
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -0
- package/dist/types/core/agents/attachments.d.ts +11 -0
- package/dist/types/core/agents/attachments.d.ts.map +1 -0
- package/dist/types/core/agents/base.d.ts +227 -0
- package/dist/types/core/agents/base.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts +58 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts +26 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +70 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts +54 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/events.d.ts +42 -0
- package/dist/types/core/agents/claude-code/events.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/login.d.ts +61 -0
- package/dist/types/core/agents/claude-code/login.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts +52 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/models.d.ts +30 -0
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/options.d.ts +183 -0
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts +50 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts +36 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session.d.ts +148 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts +29 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spend.d.ts +58 -0
- package/dist/types/core/agents/claude-code/spend.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/tools.d.ts +4 -0
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts +52 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn.d.ts +121 -0
- package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts +59 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts +116 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +113 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts +66 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts +49 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts +12 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts +45 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts +20 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts +26 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts +31 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts +38 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +62 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts +67 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts +40 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts +19 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts +99 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts +42 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts +96 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts +53 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts +87 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts +33 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts +163 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts.map +1 -0
- package/dist/types/core/agents/config-fingerprint.d.ts +5 -0
- package/dist/types/core/agents/config-fingerprint.d.ts.map +1 -0
- package/dist/types/core/agents/credentials.d.ts +28 -0
- package/dist/types/core/agents/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/elicitation.d.ts +37 -0
- package/dist/types/core/agents/elicitation.d.ts.map +1 -0
- package/dist/types/core/agents/inherit-config.d.ts +18 -0
- package/dist/types/core/agents/inherit-config.d.ts.map +1 -0
- package/dist/types/core/agents/login.d.ts +67 -0
- package/dist/types/core/agents/login.d.ts.map +1 -0
- package/dist/types/core/agents/mcp-config.d.ts +57 -0
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -0
- package/dist/types/core/agents/plan.d.ts +16 -0
- package/dist/types/core/agents/plan.d.ts.map +1 -0
- package/dist/types/core/agents/registry.d.ts +30 -0
- package/dist/types/core/agents/registry.d.ts.map +1 -0
- package/dist/types/core/agents/session-agent.d.ts +48 -0
- package/dist/types/core/agents/session-agent.d.ts.map +1 -0
- package/dist/types/core/agents/session-pool.d.ts +41 -0
- package/dist/types/core/agents/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/stderr-tail.d.ts +28 -0
- package/dist/types/core/agents/stderr-tail.d.ts.map +1 -0
- package/dist/types/core/agents/thinking-levels.d.ts +4 -0
- package/dist/types/core/agents/thinking-levels.d.ts.map +1 -0
- package/dist/types/core/agents/types.d.ts +124 -0
- package/dist/types/core/agents/types.d.ts.map +1 -0
- package/dist/types/core/diagnostics.d.ts +36 -0
- package/dist/types/core/diagnostics.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +29 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/presets.d.ts +80 -0
- package/dist/types/core/presets.d.ts.map +1 -0
- package/dist/types/core/processes/identity.d.ts +31 -0
- package/dist/types/core/processes/identity.d.ts.map +1 -0
- package/dist/types/core/processes/lifeline.d.ts +47 -0
- package/dist/types/core/processes/lifeline.d.ts.map +1 -0
- package/dist/types/core/processes/native-processes.d.ts +130 -0
- package/dist/types/core/processes/native-processes.d.ts.map +1 -0
- package/dist/types/core/processes/process-table.d.ts +43 -0
- package/dist/types/core/processes/process-table.d.ts.map +1 -0
- package/dist/types/core/provision/cache-trust.d.ts +13 -0
- package/dist/types/core/provision/cache-trust.d.ts.map +1 -0
- package/dist/types/core/provision/cache-usage.d.ts +14 -0
- package/dist/types/core/provision/cache-usage.d.ts.map +1 -0
- package/dist/types/core/provision/checksums.d.ts +46 -0
- package/dist/types/core/provision/checksums.d.ts.map +1 -0
- package/dist/types/core/provision/extract.d.ts +7 -0
- package/dist/types/core/provision/extract.d.ts.map +1 -0
- package/dist/types/core/provision/index.d.ts +5 -0
- package/dist/types/core/provision/index.d.ts.map +1 -0
- package/dist/types/core/provision/install-build.d.ts +36 -0
- package/dist/types/core/provision/install-build.d.ts.map +1 -0
- package/dist/types/core/provision/npm.d.ts +40 -0
- package/dist/types/core/provision/npm.d.ts.map +1 -0
- package/dist/types/core/provision/pins.d.ts +24 -0
- package/dist/types/core/provision/pins.d.ts.map +1 -0
- package/dist/types/core/provision/platform.d.ts +28 -0
- package/dist/types/core/provision/platform.d.ts.map +1 -0
- package/dist/types/core/provision/provisioner.d.ts +189 -0
- package/dist/types/core/provision/provisioner.d.ts.map +1 -0
- package/dist/types/core/provision/releases.d.ts +8 -0
- package/dist/types/core/provision/releases.d.ts.map +1 -0
- package/dist/types/core/provision/tools.d.ts +81 -0
- package/dist/types/core/provision/tools.d.ts.map +1 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts +52 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts.map +1 -0
- package/dist/types/core/proxy/api-key-store.d.ts +37 -0
- package/dist/types/core/proxy/api-key-store.d.ts.map +1 -0
- package/dist/types/core/proxy/index.d.ts +3 -0
- package/dist/types/core/proxy/index.d.ts.map +1 -0
- package/dist/types/core/proxy/loopback.d.ts +14 -0
- package/dist/types/core/proxy/loopback.d.ts.map +1 -0
- package/dist/types/core/runtime/agent-runtime.d.ts +181 -0
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -0
- package/dist/types/core/runtime/event-processor.d.ts +87 -0
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -0
- package/dist/types/core/runtime/event-sink.d.ts +44 -0
- package/dist/types/core/runtime/event-sink.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-clis.d.ts +10 -0
- package/dist/types/core/runtime/harness-clis.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-logins.d.ts +68 -0
- package/dist/types/core/runtime/harness-logins.d.ts.map +1 -0
- package/dist/types/core/runtime/login-reads.d.ts +28 -0
- package/dist/types/core/runtime/login-reads.d.ts.map +1 -0
- package/dist/types/core/runtime/model-lists.d.ts +37 -0
- package/dist/types/core/runtime/model-lists.d.ts.map +1 -0
- package/dist/types/core/runtime/permission-policy.d.ts +61 -0
- package/dist/types/core/runtime/permission-policy.d.ts.map +1 -0
- package/dist/types/core/runtime/request-broker.d.ts +49 -0
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -0
- package/dist/types/core/runtime/steering.d.ts +38 -0
- package/dist/types/core/runtime/steering.d.ts.map +1 -0
- package/dist/types/core/runtime/turn-outcome.d.ts +21 -0
- package/dist/types/core/runtime/turn-outcome.d.ts.map +1 -0
- package/dist/types/core/runtime/turn.d.ts +121 -0
- package/dist/types/core/runtime/turn.d.ts.map +1 -0
- package/dist/types/core/utils/bounded.d.ts +6 -0
- package/dist/types/core/utils/bounded.d.ts.map +1 -0
- package/dist/types/core/utils/deadline.d.ts +14 -0
- package/dist/types/core/utils/deadline.d.ts.map +1 -0
- package/dist/types/core/utils/errors.d.ts +104 -0
- package/dist/types/core/utils/errors.d.ts.map +1 -0
- package/dist/types/core/utils/is-record.d.ts +3 -0
- package/dist/types/core/utils/is-record.d.ts.map +1 -0
- package/dist/types/core/utils/loopback.d.ts +6 -0
- package/dist/types/core/utils/loopback.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/protocol/account.d.ts +26 -0
- package/dist/types/protocol/account.d.ts.map +1 -0
- package/dist/types/protocol/async-queue.d.ts +21 -0
- package/dist/types/protocol/async-queue.d.ts.map +1 -0
- package/dist/types/protocol/auth.d.ts +228 -0
- package/dist/types/protocol/auth.d.ts.map +1 -0
- package/dist/types/protocol/canonical.d.ts +9 -0
- package/dist/types/protocol/canonical.d.ts.map +1 -0
- package/dist/types/protocol/clis.d.ts +74 -0
- package/dist/types/protocol/clis.d.ts.map +1 -0
- package/dist/types/protocol/config.d.ts +200 -0
- package/dist/types/protocol/config.d.ts.map +1 -0
- package/dist/types/protocol/conversation.d.ts +942 -0
- package/dist/types/protocol/conversation.d.ts.map +1 -0
- package/dist/types/protocol/credentials.d.ts +145 -0
- package/dist/types/protocol/credentials.d.ts.map +1 -0
- package/dist/types/protocol/errors.d.ts +36 -0
- package/dist/types/protocol/errors.d.ts.map +1 -0
- package/dist/types/protocol/execution.d.ts +28 -0
- package/dist/types/protocol/execution.d.ts.map +1 -0
- package/dist/types/protocol/factories.d.ts +94 -0
- package/dist/types/protocol/factories.d.ts.map +1 -0
- package/dist/types/protocol/guards.d.ts +55 -0
- package/dist/types/protocol/guards.d.ts.map +1 -0
- package/dist/types/protocol/harness.d.ts +70 -0
- package/dist/types/protocol/harness.d.ts.map +1 -0
- package/dist/types/protocol/history.d.ts +318 -0
- package/dist/types/protocol/history.d.ts.map +1 -0
- package/dist/types/protocol/ids.d.ts +9 -0
- package/dist/types/protocol/ids.d.ts.map +1 -0
- package/dist/types/protocol/index.d.ts +35 -0
- package/dist/types/protocol/index.d.ts.map +1 -0
- package/dist/types/protocol/lifecycle.d.ts +1190 -0
- package/dist/types/protocol/lifecycle.d.ts.map +1 -0
- package/dist/types/protocol/meta-keys.d.ts +17 -0
- package/dist/types/protocol/meta-keys.d.ts.map +1 -0
- package/dist/types/protocol/meta.d.ts +13 -0
- package/dist/types/protocol/meta.d.ts.map +1 -0
- package/dist/types/protocol/model-catalog.d.ts +11 -0
- package/dist/types/protocol/model-catalog.d.ts.map +1 -0
- package/dist/types/protocol/models.d.ts +107 -0
- package/dist/types/protocol/models.d.ts.map +1 -0
- package/dist/types/protocol/part-input.d.ts +101 -0
- package/dist/types/protocol/part-input.d.ts.map +1 -0
- package/dist/types/protocol/parts.d.ts +357 -0
- package/dist/types/protocol/parts.d.ts.map +1 -0
- package/dist/types/protocol/reduce.d.ts +26 -0
- package/dist/types/protocol/reduce.d.ts.map +1 -0
- package/dist/types/protocol/selectors.d.ts +64 -0
- package/dist/types/protocol/selectors.d.ts.map +1 -0
- package/dist/types/protocol/seq-cursor.d.ts +66 -0
- package/dist/types/protocol/seq-cursor.d.ts.map +1 -0
- package/dist/types/protocol/stop-reasons.d.ts +33 -0
- package/dist/types/protocol/stop-reasons.d.ts.map +1 -0
- package/dist/types/protocol/thinking.d.ts +28 -0
- package/dist/types/protocol/thinking.d.ts.map +1 -0
- package/dist/types/protocol/time.d.ts +21 -0
- package/dist/types/protocol/time.d.ts.map +1 -0
- package/dist/types/protocol/tokens.d.ts +29 -0
- package/dist/types/protocol/tokens.d.ts.map +1 -0
- package/dist/types/protocol/tool-closure.d.ts +25 -0
- package/dist/types/protocol/tool-closure.d.ts.map +1 -0
- package/dist/types/protocol/tool-state.d.ts +209 -0
- package/dist/types/protocol/tool-state.d.ts.map +1 -0
- package/dist/types/protocol/verify.d.ts +52 -0
- package/dist/types/protocol/verify.d.ts.map +1 -0
- package/dist/types/protocol/vocabulary.d.ts +19 -0
- package/dist/types/protocol/vocabulary.d.ts.map +1 -0
- package/dist/types/protocol/wire-api.d.ts +1983 -0
- package/dist/types/protocol/wire-api.d.ts.map +1 -0
- package/dist/types/protocol/wire.d.ts +1758 -0
- package/dist/types/protocol/wire.d.ts.map +1 -0
- package/dist/types/server/acp/binding.d.ts +33 -0
- package/dist/types/server/acp/binding.d.ts.map +1 -0
- package/dist/types/server/acp/session-records.d.ts +17 -0
- package/dist/types/server/acp/session-records.d.ts.map +1 -0
- package/dist/types/server/acp/translate.d.ts +48 -0
- package/dist/types/server/acp/translate.d.ts.map +1 -0
- package/dist/types/server/agent-server.d.ts +121 -0
- package/dist/types/server/agent-server.d.ts.map +1 -0
- package/dist/types/server/feedback.d.ts +37 -0
- package/dist/types/server/feedback.d.ts.map +1 -0
- package/dist/types/server/history.d.ts +15 -0
- package/dist/types/server/history.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +7 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/types/server/install.d.ts +42 -0
- package/dist/types/server/install.d.ts.map +1 -0
- package/dist/types/server/open-parts.d.ts +27 -0
- package/dist/types/server/open-parts.d.ts.map +1 -0
- package/dist/types/server/routes.d.ts +61 -0
- package/dist/types/server/routes.d.ts.map +1 -0
- package/dist/types/server/secrets.d.ts +11 -0
- package/dist/types/server/secrets.d.ts.map +1 -0
- package/dist/types/server/session-gate.d.ts +32 -0
- package/dist/types/server/session-gate.d.ts.map +1 -0
- package/dist/types/server/session-log.d.ts +39 -0
- package/dist/types/server/session-log.d.ts.map +1 -0
- package/dist/types/server/session-store.d.ts +119 -0
- package/dist/types/server/session-store.d.ts.map +1 -0
- package/dist/types/server/subscriptions.d.ts +74 -0
- package/dist/types/server/subscriptions.d.ts.map +1 -0
- package/dist/types/server/transports.d.ts +74 -0
- package/dist/types/server/transports.d.ts.map +1 -0
- package/dist/types/server/wire-error.d.ts +9 -0
- package/dist/types/server/wire-error.d.ts.map +1 -0
- package/dist/types/sync/event-log.d.ts +45 -0
- package/dist/types/sync/event-log.d.ts.map +1 -0
- package/dist/types/sync/fit.d.ts +40 -0
- package/dist/types/sync/fit.d.ts.map +1 -0
- package/dist/types/sync/history-reader.d.ts +8 -0
- package/dist/types/sync/history-reader.d.ts.map +1 -0
- package/dist/types/sync/history-sqlite.d.ts +37 -0
- package/dist/types/sync/history-sqlite.d.ts.map +1 -0
- package/dist/types/sync/history.d.ts +70 -0
- package/dist/types/sync/history.d.ts.map +1 -0
- package/dist/types/sync/index.d.ts +4 -0
- package/dist/types/sync/index.d.ts.map +1 -0
- package/dist/types/sync/journal-sqlite.d.ts +51 -0
- package/dist/types/sync/journal-sqlite.d.ts.map +1 -0
- package/dist/types/sync/journal.d.ts +107 -0
- package/dist/types/sync/journal.d.ts.map +1 -0
- package/dist/types/sync/live-tails.d.ts +30 -0
- package/dist/types/sync/live-tails.d.ts.map +1 -0
- package/dist/types/sync/node-sqlite.d.ts +7 -0
- package/dist/types/sync/node-sqlite.d.ts.map +1 -0
- package/dist/types/sync/projection.d.ts +10 -0
- package/dist/types/sync/projection.d.ts.map +1 -0
- package/dist/types/sync/recovery.d.ts +25 -0
- package/dist/types/sync/recovery.d.ts.map +1 -0
- package/dist/types/sync/retry.d.ts +25 -0
- package/dist/types/sync/retry.d.ts.map +1 -0
- package/dist/types/sync/schema.d.ts +4 -0
- package/dist/types/sync/schema.d.ts.map +1 -0
- package/dist/types/sync/sql.d.ts +38 -0
- package/dist/types/sync/sql.d.ts.map +1 -0
- package/dist/types/sync/sqlite-file.d.ts +9 -0
- package/dist/types/sync/sqlite-file.d.ts.map +1 -0
- package/dist/types/sync/sqlite.d.ts +6 -0
- package/dist/types/sync/sqlite.d.ts.map +1 -0
- package/dist/types/sync/worker.d.ts +63 -0
- package/dist/types/sync/worker.d.ts.map +1 -0
- package/docs/consuming.md +460 -54
- package/docs/deploy.md +218 -47
- package/docs/durable-sessions.md +195 -0
- package/docs/feedback.md +116 -0
- package/docs/harnesses.md +219 -87
- package/docs/sync-history.md +197 -0
- package/docs/sync-integration.md +119 -0
- package/package.json +53 -23
- package/src/accounts/chatgpt.ts +194 -0
- package/src/accounts/check.ts +112 -0
- package/src/accounts/claude.ts +111 -0
- package/src/accounts/endpoint.ts +151 -0
- package/src/accounts/http.ts +97 -0
- package/src/accounts/index.ts +19 -0
- package/src/client/client.ts +641 -602
- package/src/client/connection.ts +371 -0
- package/src/client/history.ts +65 -0
- package/src/client/index.ts +11 -2
- package/src/client/listeners.ts +20 -0
- package/src/client/logins.ts +105 -0
- package/src/client/rpc.ts +144 -0
- package/src/client/streams.ts +488 -0
- package/src/client/transports.ts +62 -8
- package/src/client/turns.ts +171 -0
- package/src/core/agents/acp/acp-agent.ts +94 -118
- package/src/core/agents/acp/adapter.ts +20 -9
- package/src/core/agents/acp/client.ts +125 -47
- package/src/core/agents/acp/known-agents.ts +36 -4
- package/src/core/agents/acp/mappings.ts +64 -18
- package/src/core/agents/acp/requests.ts +125 -0
- package/src/core/agents/attachments.ts +18 -0
- package/src/core/agents/base.ts +120 -42
- package/src/core/agents/claude-code/adapter.ts +177 -238
- package/src/core/agents/claude-code/approvals.ts +270 -0
- package/src/core/agents/claude-code/claude-agent.ts +175 -158
- package/src/core/agents/claude-code/credentials.ts +171 -0
- package/src/core/agents/claude-code/events.ts +55 -0
- package/src/core/agents/claude-code/login.ts +269 -0
- package/src/core/agents/claude-code/mcp.ts +206 -0
- package/src/core/agents/claude-code/models.ts +15 -9
- package/src/core/agents/claude-code/options.ts +326 -39
- package/src/core/agents/claude-code/outcome.ts +209 -0
- package/src/core/agents/claude-code/session-pool.ts +136 -0
- package/src/core/agents/claude-code/session.ts +513 -0
- package/src/core/agents/claude-code/spawn.ts +144 -0
- package/src/core/agents/claude-code/spend.ts +160 -0
- package/src/core/agents/claude-code/tools.ts +47 -0
- package/src/core/agents/claude-code/turn-usage.ts +135 -0
- package/src/core/agents/claude-code/turn.ts +232 -0
- package/src/core/agents/codex-app-server/adapter.ts +314 -117
- package/src/core/agents/codex-app-server/client.ts +186 -84
- package/src/core/agents/codex-app-server/codex-agent.ts +343 -0
- package/src/core/agents/codex-app-server/commands.ts +228 -0
- package/src/core/agents/codex-app-server/credentials.ts +126 -0
- package/src/core/agents/codex-app-server/effort.ts +29 -0
- package/src/core/agents/codex-app-server/events.ts +47 -0
- package/src/core/agents/codex-app-server/homes.ts +64 -0
- package/src/core/agents/codex-app-server/input.ts +60 -0
- package/src/core/agents/codex-app-server/items.ts +149 -0
- package/src/core/agents/codex-app-server/login.ts +180 -0
- package/src/core/agents/codex-app-server/mcp.ts +182 -37
- package/src/core/agents/codex-app-server/models.ts +99 -46
- package/src/core/agents/codex-app-server/options.ts +146 -0
- package/src/core/agents/codex-app-server/plan-approval.ts +135 -0
- package/src/core/agents/codex-app-server/protocol.ts +117 -0
- package/src/core/agents/codex-app-server/requests.ts +332 -0
- package/src/core/agents/codex-app-server/session.ts +285 -0
- package/src/core/agents/codex-app-server/subagents.ts +108 -42
- package/src/core/agents/codex-app-server/thread-settings.ts +279 -0
- package/src/core/agents/codex-app-server/turn-items.ts +88 -0
- package/src/core/agents/codex-app-server/turn.ts +463 -0
- package/src/core/agents/config-fingerprint.ts +7 -14
- package/src/core/agents/credentials.ts +98 -0
- package/src/core/agents/elicitation.ts +75 -0
- package/src/core/agents/inherit-config.ts +21 -0
- package/src/core/agents/login.ts +116 -0
- package/src/core/agents/mcp-config.ts +112 -8
- package/src/core/agents/plan.ts +25 -0
- package/src/core/agents/registry.ts +21 -4
- package/src/core/agents/session-agent.ts +96 -4
- package/src/core/agents/{session-store.ts → session-pool.ts} +11 -5
- package/src/core/agents/stderr-tail.ts +75 -0
- package/src/core/agents/types.ts +40 -5
- package/src/core/index.ts +60 -48
- package/src/core/presets.ts +100 -39
- package/src/core/processes/identity.ts +113 -0
- package/src/core/processes/lifeline.ts +170 -0
- package/src/core/processes/native-processes.ts +379 -0
- package/src/core/processes/process-table.ts +174 -0
- package/src/core/provision/cache-trust.ts +121 -0
- package/src/core/provision/cache-usage.ts +69 -0
- package/src/core/provision/checksums.ts +64 -0
- package/src/core/provision/extract.ts +11 -2
- package/src/core/provision/index.ts +4 -1
- package/src/core/provision/install-build.ts +136 -0
- package/src/core/provision/npm.ts +112 -17
- package/src/core/provision/pins.ts +11 -34
- package/src/core/provision/platform.ts +12 -1
- package/src/core/provision/provisioner.ts +329 -397
- package/src/core/provision/releases.ts +86 -0
- package/src/core/provision/tools.ts +329 -0
- package/src/core/proxy/anthropic-proxy.ts +55 -25
- package/src/core/proxy/api-key-store.ts +2 -12
- package/src/core/proxy/loopback.ts +106 -0
- package/src/core/runtime/agent-runtime.ts +340 -481
- package/src/core/runtime/event-processor.ts +207 -75
- package/src/core/runtime/event-sink.ts +45 -2
- package/src/core/runtime/harness-clis.ts +61 -0
- package/src/core/runtime/harness-logins.ts +328 -0
- package/src/core/runtime/login-reads.ts +78 -0
- package/src/core/runtime/model-lists.ts +57 -57
- package/src/core/runtime/permission-policy.ts +113 -0
- package/src/core/runtime/request-broker.ts +204 -0
- package/src/core/runtime/steering.ts +112 -0
- package/src/core/runtime/turn-outcome.ts +30 -0
- package/src/core/runtime/turn.ts +360 -0
- package/src/core/utils/bounded.ts +12 -0
- package/src/core/utils/deadline.ts +38 -0
- package/src/core/utils/errors.ts +113 -21
- package/src/core/utils/is-record.ts +4 -0
- package/src/core/utils/loopback.ts +10 -0
- package/src/protocol/account.ts +104 -0
- package/src/protocol/auth.ts +199 -0
- package/src/protocol/canonical.ts +16 -0
- package/src/protocol/clis.ts +69 -0
- package/src/protocol/config.ts +60 -6
- package/src/protocol/conversation.ts +272 -0
- package/src/protocol/credentials.ts +145 -0
- package/src/protocol/errors.ts +78 -20
- package/src/protocol/execution.ts +5 -2
- package/src/protocol/factories.ts +55 -7
- package/src/protocol/guards.ts +55 -2
- package/src/protocol/harness.ts +56 -6
- package/src/protocol/history.ts +275 -0
- package/src/protocol/ids.ts +4 -17
- package/src/protocol/index.ts +10 -0
- package/src/protocol/lifecycle.ts +250 -79
- package/src/protocol/meta-keys.ts +17 -0
- package/src/protocol/meta.ts +3 -3
- package/src/protocol/models.ts +2 -43
- package/src/protocol/part-input.ts +2 -1
- package/src/protocol/parts.ts +12 -3
- package/src/protocol/reduce.ts +302 -413
- package/src/protocol/selectors.ts +1 -20
- package/src/protocol/seq-cursor.ts +14 -0
- package/src/protocol/stop-reasons.ts +1 -1
- package/src/protocol/thinking.ts +1 -30
- package/src/protocol/time.ts +2 -2
- package/src/protocol/tool-closure.ts +93 -0
- package/src/protocol/tool-state.ts +19 -4
- package/src/protocol/verify.ts +222 -92
- package/src/protocol/vocabulary.ts +21 -5
- package/src/protocol/wire-api.ts +232 -0
- package/src/protocol/wire.ts +425 -57
- package/src/server/acp/binding.ts +63 -103
- package/src/server/acp/session-records.ts +53 -0
- package/src/server/acp/translate.ts +129 -20
- package/src/server/agent-server.ts +275 -366
- package/src/server/bin.ts +295 -72
- package/src/server/feedback.ts +204 -14
- package/src/server/history.ts +160 -0
- package/src/server/index.ts +4 -8
- package/src/server/install.ts +107 -8
- package/src/server/open-parts.ts +95 -0
- package/src/server/routes.ts +391 -0
- package/src/server/secrets.ts +24 -0
- package/src/server/session-gate.ts +69 -0
- package/src/server/session-log.ts +14 -2
- package/src/server/session-store.ts +289 -0
- package/src/server/subscriptions.ts +232 -0
- package/src/server/transports.ts +125 -25
- package/src/server/wire-error.ts +38 -0
- package/src/sync/event-log.ts +160 -0
- package/src/sync/fit.ts +140 -0
- package/src/sync/history-reader.ts +57 -0
- package/src/sync/history-sqlite.ts +339 -0
- package/src/sync/history.ts +220 -0
- package/src/sync/index.ts +18 -0
- package/src/sync/journal-sqlite.ts +439 -0
- package/src/sync/journal.ts +132 -0
- package/src/sync/live-tails.ts +107 -0
- package/src/sync/node-sqlite.ts +20 -0
- package/src/sync/projection.ts +35 -0
- package/src/sync/recovery.ts +141 -0
- package/src/sync/retry.ts +49 -0
- package/src/sync/schema.ts +77 -0
- package/src/sync/sql.ts +106 -0
- package/src/sync/sqlite-file.ts +38 -0
- package/src/sync/sqlite.ts +21 -0
- package/src/sync/worker.ts +259 -0
- package/docs/rfds/0001-deterministic-echo-ids.md +0 -44
- package/docs/rfds/0002-native-subagents.md +0 -197
- package/src/core/agents/claude-code/generator-session.ts +0 -572
- package/src/core/agents/claude-code/session-manager.ts +0 -166
- package/src/core/agents/codex-app-server/codex-app-server-agent.ts +0 -962
- package/src/core/agents/codex-items.ts +0 -149
- package/src/core/agents/codex-sdk/adapter.ts +0 -237
- package/src/core/agents/codex-sdk/codex-sdk-agent.ts +0 -330
- package/src/core/agents/tool-meta.ts +0 -68
|
@@ -22,13 +22,14 @@ import {
|
|
|
22
22
|
setToolMeta,
|
|
23
23
|
startToolPart,
|
|
24
24
|
} from "../../../protocol/index.ts";
|
|
25
|
+
import { isRecord } from "../../utils/is-record.ts";
|
|
25
26
|
import type { AdapterEvent, EventTransformer, TransformResult } from "../types.ts";
|
|
26
|
-
import {
|
|
27
|
+
import { permissionModeOf, toToolLocations, toolKindOf } from "./mappings.ts";
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Parses ACP v1 raw events into AdapterEvents. The mapping is nearly identity:
|
|
30
31
|
* our part vocabulary (ToolKind, tool status, locations) was aligned to ACP up
|
|
31
|
-
* front
|
|
32
|
+
* front, so chunks append to text/reasoning parts and
|
|
32
33
|
* `tool_call`/`tool_call_update` upsert tool parts by `toolCallId`. Everything
|
|
33
34
|
* arrives through the SDK connection, which zod-validates inbound payloads —
|
|
34
35
|
* so the SDK's own types ARE the raw shapes (no defensive re-modelling).
|
|
@@ -44,11 +45,17 @@ import { isRecord, toToolLocations, toolKindOf } from "./mappings.ts";
|
|
|
44
45
|
* wire message; when absent the whole turn is one message (the processor
|
|
45
46
|
* synthesizes the boundary).
|
|
46
47
|
*/
|
|
47
|
-
type
|
|
48
|
+
export type AcpRawEvent =
|
|
48
49
|
| { method: "session/update"; params: SessionNotification }
|
|
49
50
|
| { method: "session/prompt_result"; params: Partial<PromptResponse> }
|
|
50
51
|
| { method: "error"; params: { message?: string } };
|
|
51
52
|
|
|
53
|
+
/** How a turn the agent did not get to answer ends: cancelled. */
|
|
54
|
+
export const CANCELLED_PROMPT_RESULT: AcpRawEvent = {
|
|
55
|
+
method: "session/prompt_result",
|
|
56
|
+
params: { stopReason: "cancelled" },
|
|
57
|
+
};
|
|
58
|
+
|
|
52
59
|
function stopReasonOf(value: string | undefined): StopReason | undefined {
|
|
53
60
|
return value && (STOP_REASONS as readonly string[]).includes(value)
|
|
54
61
|
? (value as StopReason)
|
|
@@ -82,7 +89,7 @@ function toolOutput(content: ToolCallContent[] | null | undefined, rawOutput: un
|
|
|
82
89
|
|
|
83
90
|
type StreamSlot = "text" | "reasoning";
|
|
84
91
|
|
|
85
|
-
|
|
92
|
+
class AcpTransformer implements EventTransformer<AcpRawEvent> {
|
|
86
93
|
private readonly ctx: StreamContext;
|
|
87
94
|
private readonly toolParts = new Map<string, ToolPart>();
|
|
88
95
|
private readonly streamParts = new Map<StreamSlot, TextPart | ReasoningPart>();
|
|
@@ -99,8 +106,7 @@ export class AcpTransformer implements EventTransformer<unknown> {
|
|
|
99
106
|
this.ctx = { sessionId: ctx.sessionId, messageId: "" };
|
|
100
107
|
}
|
|
101
108
|
|
|
102
|
-
process(
|
|
103
|
-
const event = raw as RawEvent;
|
|
109
|
+
process(event: AcpRawEvent): AdapterEvent[] {
|
|
104
110
|
switch (event.method) {
|
|
105
111
|
case "session/update":
|
|
106
112
|
return this.onUpdate(event.params.update);
|
|
@@ -153,10 +159,15 @@ export class AcpTransformer implements EventTransformer<unknown> {
|
|
|
153
159
|
},
|
|
154
160
|
];
|
|
155
161
|
}
|
|
162
|
+
case "current_mode_update": {
|
|
163
|
+
// Only a mode the engine has a name for (claude-agent-acp's are
|
|
164
|
+
// Claude's own); another agent's mode stays raw.
|
|
165
|
+
const permissionMode = permissionModeOf(update.currentModeId);
|
|
166
|
+
return permissionMode ? [{ kind: "mode", permissionMode }] : [];
|
|
167
|
+
}
|
|
156
168
|
default:
|
|
157
|
-
// plan / available_commands /
|
|
158
|
-
//
|
|
159
|
-
// `includeRaw` consumers still see them.
|
|
169
|
+
// plan / available_commands / config_option / session_info updates
|
|
170
|
+
// have no part representation yet; `includeRaw` consumers still see them.
|
|
160
171
|
return [];
|
|
161
172
|
}
|
|
162
173
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type ChildProcess, spawn } from "node:child_process";
|
|
2
1
|
import { Readable, Writable } from "node:stream";
|
|
3
2
|
import type {
|
|
4
3
|
AgentNotificationMethod,
|
|
@@ -7,10 +6,19 @@ import type {
|
|
|
7
6
|
AgentRequestParamsByMethod,
|
|
8
7
|
AgentRequestResponsesByMethod,
|
|
9
8
|
ClientConnection,
|
|
9
|
+
CreateElicitationRequest,
|
|
10
|
+
CreateElicitationResponse,
|
|
10
11
|
RequestPermissionRequest,
|
|
11
12
|
RequestPermissionResponse,
|
|
12
13
|
SessionNotification,
|
|
13
14
|
} from "@agentclientprotocol/sdk";
|
|
15
|
+
import type {
|
|
16
|
+
NativeExit,
|
|
17
|
+
NativeProcess,
|
|
18
|
+
NativeProcesses,
|
|
19
|
+
} from "../../processes/native-processes.ts";
|
|
20
|
+
import { withTimeout } from "../../utils/deadline.ts";
|
|
21
|
+
import { AgentExitedError } from "../../utils/errors.ts";
|
|
14
22
|
|
|
15
23
|
/**
|
|
16
24
|
* How to start one ACP agent subprocess. Operator-level only — the wire never
|
|
@@ -24,16 +32,13 @@ export interface AcpLaunch {
|
|
|
24
32
|
env?: Record<string, string>;
|
|
25
33
|
}
|
|
26
34
|
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (!command) return undefined;
|
|
35
|
-
return { command, ...(args.length && { args }) };
|
|
36
|
-
}
|
|
35
|
+
/** How much of the agent's stderr tail an exit error carries: its last lines say why. */
|
|
36
|
+
const REASON_LINES = 2;
|
|
37
|
+
const REASON_MAX = 400;
|
|
38
|
+
/** How long an agent gets to stop on SIGTERM before it is killed. */
|
|
39
|
+
const KILL_GRACE_MS = 3_000;
|
|
40
|
+
/** How long a closed connection waits for the process's own exit, which says why. */
|
|
41
|
+
const EXIT_REASON_WAIT_MS = 500;
|
|
37
42
|
|
|
38
43
|
export type SessionUpdateHandler = (notification: SessionNotification) => void;
|
|
39
44
|
|
|
@@ -42,12 +47,24 @@ export type AcpPermissionHandler = (
|
|
|
42
47
|
request: RequestPermissionRequest,
|
|
43
48
|
) => Promise<RequestPermissionResponse>;
|
|
44
49
|
|
|
50
|
+
/** Answers agent→client `elicitation/create`. Absent handler → declined. */
|
|
51
|
+
export type AcpElicitationHandler = (
|
|
52
|
+
request: CreateElicitationRequest,
|
|
53
|
+
) => Promise<CreateElicitationResponse>;
|
|
54
|
+
|
|
45
55
|
export interface AcpClientOptions {
|
|
46
56
|
launch: AcpLaunch;
|
|
47
57
|
cwd: string;
|
|
48
58
|
/** Per-session env on top of the launch env (RunConfig.env). */
|
|
49
59
|
env?: Record<string, string>;
|
|
50
60
|
clientName?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Where the agent starts: in a group of its own, held by the lifeline and
|
|
63
|
+
* recorded for `sessionId` (`createAgentRegistry` passes the runtime's).
|
|
64
|
+
*/
|
|
65
|
+
processes: NativeProcesses;
|
|
66
|
+
/** The logical session it serves, which its record names. */
|
|
67
|
+
sessionId?: string;
|
|
51
68
|
}
|
|
52
69
|
|
|
53
70
|
/**
|
|
@@ -60,12 +77,16 @@ export interface AcpClientOptions {
|
|
|
60
77
|
* codex-app-server client's `setRequestHandler` pattern).
|
|
61
78
|
*/
|
|
62
79
|
export class AcpClient {
|
|
63
|
-
private
|
|
80
|
+
private native?: NativeProcess;
|
|
64
81
|
private connection?: ClientConnection;
|
|
65
82
|
private readonly updateHandlers = new Set<SessionUpdateHandler>();
|
|
66
83
|
private readonly closeHandlers = new Set<(error?: Error) => void>();
|
|
67
84
|
private permissionHandler?: AcpPermissionHandler;
|
|
85
|
+
private elicitationHandler?: AcpElicitationHandler;
|
|
68
86
|
private exited = false;
|
|
87
|
+
/** Why the agent stopped, once it has: its exit code and stderr tail. */
|
|
88
|
+
private exitError?: Error;
|
|
89
|
+
private connectionEnded = false;
|
|
69
90
|
|
|
70
91
|
private constructor(private readonly opts: AcpClientOptions) {}
|
|
71
92
|
|
|
@@ -87,13 +108,18 @@ export class AcpClient {
|
|
|
87
108
|
this.permissionHandler = handler;
|
|
88
109
|
}
|
|
89
110
|
|
|
111
|
+
/** Install the answerer for the agent's requests for user input. */
|
|
112
|
+
setElicitationHandler(handler: AcpElicitationHandler | undefined): void {
|
|
113
|
+
this.elicitationHandler = handler;
|
|
114
|
+
}
|
|
115
|
+
|
|
90
116
|
onClose(handler: (error?: Error) => void): () => void {
|
|
91
117
|
this.closeHandlers.add(handler);
|
|
92
118
|
return () => this.closeHandlers.delete(handler);
|
|
93
119
|
}
|
|
94
120
|
|
|
95
121
|
get closed(): boolean {
|
|
96
|
-
return this.exited;
|
|
122
|
+
return this.exited || this.connectionEnded;
|
|
97
123
|
}
|
|
98
124
|
|
|
99
125
|
/**
|
|
@@ -109,26 +135,40 @@ export class AcpClient {
|
|
|
109
135
|
params: AgentRequestParamsByMethod[M],
|
|
110
136
|
timeoutMs?: number,
|
|
111
137
|
): Promise<AgentRequestResponsesByMethod[M]> {
|
|
112
|
-
if (!this.connection || this.exited) throw new Error("acp agent not running");
|
|
138
|
+
if (!this.connection || this.exited) throw this.exitError ?? new Error("acp agent not running");
|
|
139
|
+
try {
|
|
140
|
+
return await this.send(method, params, timeoutMs);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
// Cut short by the agent's exit: say why it exited, not just that the
|
|
143
|
+
// connection closed. (The SDK marks the connection closed before it
|
|
144
|
+
// fails the requests it held.)
|
|
145
|
+
if (this.exited || this.connectionEnded) throw (await this.whyExited()) ?? error;
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Why the agent exited, waiting briefly for its exit when the connection went first. */
|
|
151
|
+
private async whyExited(): Promise<Error | undefined> {
|
|
152
|
+
if (!this.exitError && this.native) await withTimeout(this.native.exited, EXIT_REASON_WAIT_MS);
|
|
153
|
+
return this.exitError;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private async send<M extends AgentRequestMethod>(
|
|
157
|
+
method: M,
|
|
158
|
+
params: AgentRequestParamsByMethod[M],
|
|
159
|
+
timeoutMs?: number,
|
|
160
|
+
): Promise<AgentRequestResponsesByMethod[M]> {
|
|
161
|
+
if (!this.connection) throw this.exitError ?? new Error("acp agent not running");
|
|
113
162
|
const agent = this.connection.agent;
|
|
114
163
|
if (!timeoutMs) return agent.request(method, params);
|
|
115
164
|
const abort = new AbortController();
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
});
|
|
124
|
-
try {
|
|
125
|
-
return await Promise.race([
|
|
126
|
-
agent.request(method, params, { cancellationSignal: abort.signal }),
|
|
127
|
-
deadline,
|
|
128
|
-
]);
|
|
129
|
-
} finally {
|
|
130
|
-
if (timer) clearTimeout(timer);
|
|
131
|
-
}
|
|
165
|
+
const answered = await withTimeout(
|
|
166
|
+
agent.request(method, params, { cancellationSignal: abort.signal }),
|
|
167
|
+
timeoutMs,
|
|
168
|
+
);
|
|
169
|
+
if (answered) return answered.value;
|
|
170
|
+
abort.abort();
|
|
171
|
+
throw new Error(`acp agent '${method}' timed out after ${timeoutMs}ms`);
|
|
132
172
|
}
|
|
133
173
|
|
|
134
174
|
/** Send a notification to the agent (`session/cancel`). */
|
|
@@ -141,40 +181,51 @@ export class AcpClient {
|
|
|
141
181
|
}
|
|
142
182
|
|
|
143
183
|
close(): void {
|
|
144
|
-
const
|
|
184
|
+
const native = this.native;
|
|
145
185
|
const wasOpen = !this.exited;
|
|
146
186
|
this.exited = true;
|
|
147
|
-
this.
|
|
187
|
+
this.native = undefined;
|
|
148
188
|
this.connection?.close();
|
|
149
189
|
this.connection = undefined;
|
|
150
|
-
if (
|
|
190
|
+
if (native) this.stop(native);
|
|
151
191
|
if (wasOpen) this.notifyClosed();
|
|
152
192
|
}
|
|
153
193
|
|
|
194
|
+
/**
|
|
195
|
+
* SIGTERM the agent's group and the tool sessions under it, and SIGKILL
|
|
196
|
+
* what is left after the grace. An agent that runs Claude through the SDK's
|
|
197
|
+
* own spawner keeps that `claude` in its group, which the SIGTERM reaches.
|
|
198
|
+
*/
|
|
199
|
+
private stop(native: NativeProcess): void {
|
|
200
|
+
void native.stop({ graceMs: KILL_GRACE_MS });
|
|
201
|
+
}
|
|
202
|
+
|
|
154
203
|
private async start(): Promise<void> {
|
|
155
204
|
const acp = await import("@agentclientprotocol/sdk");
|
|
156
205
|
const { launch } = this.opts;
|
|
157
|
-
const
|
|
206
|
+
const native = this.opts.processes.spawn({
|
|
207
|
+
command: launch.command,
|
|
208
|
+
args: launch.args ?? [],
|
|
158
209
|
cwd: this.opts.cwd,
|
|
159
210
|
env: { ...process.env, ...launch.env, ...this.opts.env },
|
|
160
|
-
|
|
211
|
+
harness: "acp",
|
|
212
|
+
...(this.opts.sessionId !== undefined && { sessionId: this.opts.sessionId }),
|
|
161
213
|
});
|
|
162
|
-
this.
|
|
214
|
+
this.native = native;
|
|
215
|
+
const proc = native.child;
|
|
163
216
|
if (!proc.stdin || !proc.stdout) {
|
|
164
|
-
|
|
217
|
+
this.stop(native);
|
|
165
218
|
throw new Error("acp agent subprocess has no stdio");
|
|
166
219
|
}
|
|
167
|
-
// Drain stderr so the agent can't block on a full pipe; its logs are not ours.
|
|
168
|
-
proc.stderr?.on("data", () => {});
|
|
169
220
|
proc.on("error", (err) => this.onExit(err));
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
);
|
|
221
|
+
// Once its output closed, or a moment after its exit when a child it left
|
|
222
|
+
// running holds the pipes: its stderr's last lines usually say why.
|
|
223
|
+
void native.exited.then((exit) => this.onExit(exitedWith(exit, native.stderrTail)));
|
|
173
224
|
|
|
174
225
|
const stream = acp.ndJsonStream(
|
|
175
226
|
Writable.toWeb(proc.stdin),
|
|
176
|
-
// Kept cast:
|
|
177
|
-
//
|
|
227
|
+
// Kept cast: some lib.dom versions type Readable.toWeb as
|
|
228
|
+
// ReadableStream<any>.
|
|
178
229
|
Readable.toWeb(proc.stdout) as unknown as ReadableStream<Uint8Array>,
|
|
179
230
|
);
|
|
180
231
|
this.connection = acp
|
|
@@ -184,22 +235,35 @@ export class AcpClient {
|
|
|
184
235
|
if (!handler) return { outcome: { outcome: "cancelled" } };
|
|
185
236
|
return handler(ctx.params);
|
|
186
237
|
})
|
|
238
|
+
.onRequest("elicitation/create", async (ctx): Promise<CreateElicitationResponse> => {
|
|
239
|
+
const handler = this.elicitationHandler;
|
|
240
|
+
if (!handler) return { action: "decline" };
|
|
241
|
+
return handler(ctx.params);
|
|
242
|
+
})
|
|
187
243
|
.onNotification("session/update", (ctx) => {
|
|
188
244
|
for (const handler of this.updateHandlers) handler(ctx.params);
|
|
189
245
|
})
|
|
190
246
|
.connect(stream);
|
|
191
247
|
// A closed connection without a process exit (stream error) still ends the
|
|
192
|
-
// client; a rejected `closed` must not become an unhandled rejection.
|
|
248
|
+
// client; a rejected `closed` must not become an unhandled rejection. The
|
|
249
|
+
// process's own exit usually follows at once and says why: let it.
|
|
250
|
+
const ended = async (error: Error) => {
|
|
251
|
+
this.connectionEnded = true;
|
|
252
|
+
if (!(await withTimeout(native.exited, EXIT_REASON_WAIT_MS))) this.onExit(error);
|
|
253
|
+
};
|
|
193
254
|
this.connection.closed.then(
|
|
194
|
-
() =>
|
|
255
|
+
() => ended(new Error("acp connection closed")),
|
|
195
256
|
(err: unknown) =>
|
|
196
|
-
|
|
257
|
+
ended(err instanceof Error ? err : new Error(`acp connection failed: ${err}`)),
|
|
197
258
|
);
|
|
198
259
|
}
|
|
199
260
|
|
|
200
261
|
private onExit(error: Error): void {
|
|
262
|
+
this.exitError ??= error;
|
|
201
263
|
if (this.exited) return;
|
|
202
264
|
this.exited = true;
|
|
265
|
+
// The connection can end while the process lives on: stop it.
|
|
266
|
+
if (this.native) this.stop(this.native);
|
|
203
267
|
this.connection?.close(error);
|
|
204
268
|
this.connection = undefined;
|
|
205
269
|
this.notifyClosed(error);
|
|
@@ -210,3 +274,17 @@ export class AcpClient {
|
|
|
210
274
|
this.closeHandlers.clear();
|
|
211
275
|
}
|
|
212
276
|
}
|
|
277
|
+
|
|
278
|
+
/** Why the agent exited: its code, and the last lines of its stderr. */
|
|
279
|
+
function exitedWith({ code, signal }: NativeExit, stderr: string): AgentExitedError {
|
|
280
|
+
const reason = stderr
|
|
281
|
+
.split("\n")
|
|
282
|
+
.map((line) => line.trim())
|
|
283
|
+
.filter(Boolean)
|
|
284
|
+
.slice(-REASON_LINES)
|
|
285
|
+
.join(" | ")
|
|
286
|
+
.slice(-REASON_MAX);
|
|
287
|
+
return new AgentExitedError(
|
|
288
|
+
`acp agent exited (code=${code} signal=${signal})${reason ? `: ${reason}` : ""}`,
|
|
289
|
+
);
|
|
290
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type AgentHarness, isAgentHarness } from "../../../protocol/index.ts";
|
|
2
|
+
import type { AcpLaunch } from "./client.ts";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Advisory catalog of well-known ACP agents — UX sugar, not wire vocabulary
|
|
5
|
-
* (like
|
|
6
|
+
* (like the model catalog). On the wire the harness is always `acp`; these names
|
|
6
7
|
* let entry points offer "pi" or "gemini" as first-class choices and expand
|
|
7
8
|
* them to launch commands at the operator edge. Anything not listed here runs
|
|
8
9
|
* via an explicit launch command — any ACP-compatible agent works.
|
|
@@ -10,7 +11,9 @@ import { type AcpLaunch, parseAcpLaunch } from "./client.ts";
|
|
|
10
11
|
export const KNOWN_ACP_AGENTS: Record<string, { label: string; launch: AcpLaunch }> = {
|
|
11
12
|
pi: {
|
|
12
13
|
label: "pi.dev (Pi coding agent, via the pi-acp adapter)",
|
|
13
|
-
|
|
14
|
+
// Pinned: an unpinned `npx -y` runs whatever was published last, unreviewed.
|
|
15
|
+
// Bump after checking the new release.
|
|
16
|
+
launch: { command: "npx", args: ["-y", "pi-acp@0.0.34"] },
|
|
14
17
|
},
|
|
15
18
|
gemini: {
|
|
16
19
|
label: "Gemini CLI (native ACP mode)",
|
|
@@ -18,6 +21,35 @@ export const KNOWN_ACP_AGENTS: Record<string, { label: string; launch: AcpLaunch
|
|
|
18
21
|
},
|
|
19
22
|
};
|
|
20
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Parse an operator-supplied launch spec (`"npx -y pi-acp"`) into an AcpLaunch.
|
|
26
|
+
* Naive whitespace split — no shell quoting; env vars come from the caller.
|
|
27
|
+
* The canonical parser for `--acp-agent` flags / `$AGENT_SERVER_ACP_AGENT`.
|
|
28
|
+
*/
|
|
29
|
+
export function parseAcpLaunch(spec: string | undefined): AcpLaunch | undefined {
|
|
30
|
+
const [command, ...args] = spec?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
31
|
+
if (!command) return undefined;
|
|
32
|
+
return { command, ...(args.length && { args }) };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** A catalog entry by its own name; never one inherited from `Object.prototype`. */
|
|
36
|
+
function knownAgent(name: string) {
|
|
37
|
+
return Object.hasOwn(KNOWN_ACP_AGENTS, name) ? KNOWN_ACP_AGENTS[name] : undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Read a harness name typed at an operator edge (`--harness`, the CLI's
|
|
42
|
+
* `/harness`): a harness, or a known ACP agent's name, which rides the `acp`
|
|
43
|
+
* harness. Undefined for anything else.
|
|
44
|
+
*/
|
|
45
|
+
export function resolveHarnessName(
|
|
46
|
+
name: string,
|
|
47
|
+
): { harness: AgentHarness; acpAgent?: string } | undefined {
|
|
48
|
+
if (isAgentHarness(name)) return { harness: name };
|
|
49
|
+
if (knownAgent(name)) return { harness: "acp", acpAgent: name };
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
21
53
|
/**
|
|
22
54
|
* Resolve an operator spec that is either a known agent name (`"pi"`) or a
|
|
23
55
|
* raw launch command (`"npx -y pi-acp"`). The canonical resolver behind
|
|
@@ -25,5 +57,5 @@ export const KNOWN_ACP_AGENTS: Record<string, { label: string; launch: AcpLaunch
|
|
|
25
57
|
*/
|
|
26
58
|
export function resolveAcpLaunch(spec: string | undefined): AcpLaunch | undefined {
|
|
27
59
|
if (!spec) return undefined;
|
|
28
|
-
return
|
|
60
|
+
return knownAgent(spec.trim())?.launch ?? parseAcpLaunch(spec);
|
|
29
61
|
}
|
|
@@ -15,16 +15,24 @@ import type {
|
|
|
15
15
|
ToolLocation,
|
|
16
16
|
} from "../../../protocol/index.ts";
|
|
17
17
|
import { TOOL_KINDS } from "../../../protocol/index.ts";
|
|
18
|
+
import { isRecord } from "../../utils/is-record.ts";
|
|
19
|
+
import {
|
|
20
|
+
UnsupportedAttachmentError,
|
|
21
|
+
attachedText,
|
|
22
|
+
inlineTextAttachment,
|
|
23
|
+
isTextMedia,
|
|
24
|
+
} from "../attachments.ts";
|
|
18
25
|
|
|
19
26
|
/**
|
|
20
27
|
* The single bridge between ACP's vocabulary and the engine's. Everything here
|
|
21
28
|
* is a pure conversion shared by the agent (outbound requests, permission
|
|
22
29
|
* round-trips) and the adapter (inbound session updates) — the harness
|
|
23
30
|
* seat's single bridge, so its two halves cannot drift. (The ACP *server*
|
|
24
|
-
* binding in
|
|
31
|
+
* binding in src/server/acp/ is the inverse direction, not a copy.)
|
|
25
32
|
*/
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
// @ref LLP 0001#d2--acp-supplies-the-vocabulary-wherever-concepts-overlap — ACP's names, so bridges pass through
|
|
35
|
+
/** ACP's ToolKind strings are ours verbatim; narrow with a membership check. */
|
|
28
36
|
export function toolKindOf(kind: string | null | undefined): ToolKind | undefined {
|
|
29
37
|
return kind && (TOOL_KINDS as readonly string[]).includes(kind) ? (kind as ToolKind) : undefined;
|
|
30
38
|
}
|
|
@@ -60,21 +68,46 @@ export function toAcpMcpServers(
|
|
|
60
68
|
});
|
|
61
69
|
}
|
|
62
70
|
|
|
63
|
-
/**
|
|
64
|
-
export
|
|
71
|
+
/** What an ACP agent's `initialize` says its prompts accept beyond text and links. */
|
|
72
|
+
export interface AcpPromptCapabilities {
|
|
73
|
+
image: boolean;
|
|
74
|
+
embeddedContext: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Engine turn input → ACP prompt content blocks. Every agent takes text and
|
|
79
|
+
* resource links; image data needs the `image` capability and inline files
|
|
80
|
+
* `embeddedContext`. A text file falls back to prompt text, and anything else
|
|
81
|
+
* the agent cannot take fails the turn instead of vanishing.
|
|
82
|
+
*/
|
|
83
|
+
export function toPromptBlocks(input: AgentInput, prompt: AcpPromptCapabilities): ContentBlock[] {
|
|
65
84
|
if (typeof input === "string") return [{ type: "text", text: input }];
|
|
66
85
|
const blocks: ContentBlock[] = [];
|
|
67
86
|
for (const part of input) {
|
|
68
87
|
if (part.type === "text") {
|
|
69
88
|
blocks.push({ type: "text", text: part.text });
|
|
70
|
-
} else if (part.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
89
|
+
} else if (part.url !== undefined) {
|
|
90
|
+
const name = (part.type === "file" && part.filename) || part.url;
|
|
91
|
+
blocks.push({ type: "resource_link", uri: part.url, name, mimeType: part.mimeType });
|
|
92
|
+
} else if (part.type === "image") {
|
|
93
|
+
if (!prompt.image)
|
|
94
|
+
throw new UnsupportedAttachmentError("This ACP agent does not accept images");
|
|
95
|
+
blocks.push({ type: "image", data: part.data ?? "", mimeType: part.mimeType });
|
|
96
|
+
} else if (prompt.embeddedContext) {
|
|
97
|
+
const uri = `attachment:${encodeURIComponent(part.filename ?? "file")}`;
|
|
98
|
+
const data = part.data ?? "";
|
|
99
|
+
blocks.push({
|
|
100
|
+
type: "resource",
|
|
101
|
+
resource: isTextMedia(part.mimeType)
|
|
102
|
+
? { uri, mimeType: part.mimeType, text: attachedText(data) }
|
|
103
|
+
: { uri, mimeType: part.mimeType, blob: data },
|
|
104
|
+
});
|
|
105
|
+
} else if (isTextMedia(part.mimeType)) {
|
|
106
|
+
blocks.push({ type: "text", text: inlineTextAttachment({ ...part, data: part.data ?? "" }) });
|
|
107
|
+
} else {
|
|
108
|
+
throw new UnsupportedAttachmentError(
|
|
109
|
+
`This ACP agent cannot take ${part.mimeType} file attachments`,
|
|
110
|
+
);
|
|
78
111
|
}
|
|
79
112
|
}
|
|
80
113
|
return blocks.length ? blocks : [{ type: "text", text: "" }];
|
|
@@ -100,14 +133,17 @@ export const CANCELLED_OUTCOME: RequestPermissionResponse = {
|
|
|
100
133
|
};
|
|
101
134
|
|
|
102
135
|
/**
|
|
103
|
-
* Pick the option matching the decision: allow →
|
|
104
|
-
*
|
|
136
|
+
* Pick the option matching the decision: allow → `allow_once` only, deny →
|
|
137
|
+
* `reject_once`, else `reject_always`; no matching option → cancelled. An
|
|
138
|
+
* allow never selects `allow_always`: that would leave a standing rule in the
|
|
139
|
+
* agent nobody chose, and the engine already keeps the user's own "always"
|
|
140
|
+
* answers.
|
|
105
141
|
*/
|
|
106
142
|
export function chooseOutcome(
|
|
107
143
|
options: PermissionOption[],
|
|
108
144
|
allow: boolean,
|
|
109
145
|
): RequestPermissionResponse {
|
|
110
|
-
const kinds = allow ? ["allow_once"
|
|
146
|
+
const kinds = allow ? ["allow_once"] : ["reject_once", "reject_always"];
|
|
111
147
|
for (const kind of kinds) {
|
|
112
148
|
const match = options.find((o) => o.kind === kind);
|
|
113
149
|
if (match) return { outcome: { outcome: "selected", optionId: match.optionId } };
|
|
@@ -130,7 +166,17 @@ export function autoDecide(
|
|
|
130
166
|
return chooseOutcome(request.options, allowed);
|
|
131
167
|
}
|
|
132
168
|
|
|
133
|
-
/**
|
|
134
|
-
export function
|
|
135
|
-
|
|
169
|
+
/** An ACP mode id the engine has a name for: its own, or Claude's (claude-agent-acp). */
|
|
170
|
+
export function permissionModeOf(modeId: string): PermissionMode | undefined {
|
|
171
|
+
const known: Record<string, PermissionMode> = {
|
|
172
|
+
default: "default",
|
|
173
|
+
plan: "plan",
|
|
174
|
+
acceptEdits: "accept_edits",
|
|
175
|
+
accept_edits: "accept_edits",
|
|
176
|
+
dontAsk: "dont_ask",
|
|
177
|
+
dont_ask: "dont_ask",
|
|
178
|
+
bypassPermissions: "bypass_permissions",
|
|
179
|
+
bypass_permissions: "bypass_permissions",
|
|
180
|
+
};
|
|
181
|
+
return Object.hasOwn(known, modeId) ? known[modeId] : undefined;
|
|
136
182
|
}
|