@zvada/agent-server 0.3.18 → 0.3.20
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 +1041 -1
- package/README.md +40 -40
- 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 +452 -53
- package/docs/deploy.md +218 -47
- package/docs/{sync-experiment.md → durable-sessions.md} +77 -72
- package/docs/feedback.md +116 -0
- package/docs/harnesses.md +212 -88
- package/docs/sync-history.md +29 -13
- package/docs/sync-integration.md +52 -66
- package/package.json +45 -28
- 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 +604 -670
- package/src/client/connection.ts +371 -0
- package/src/client/history.ts +29 -52
- 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 +155 -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 +58 -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 +9 -33
- 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 +327 -498
- package/src/core/runtime/event-processor.ts +197 -70
- 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 +33 -48
- 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 +72 -64
- package/src/protocol/ids.ts +0 -12
- package/src/protocol/index.ts +9 -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 +351 -64
- 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 +223 -387
- package/src/server/bin.ts +280 -78
- package/src/server/feedback.ts +204 -14
- package/src/server/history.ts +116 -122
- package/src/server/index.ts +3 -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 +136 -72
- package/src/server/subscriptions.ts +232 -0
- package/src/server/transports.ts +125 -25
- package/src/server/wire-error.ts +31 -45
- package/src/sync/event-log.ts +31 -3
- package/src/sync/fit.ts +27 -11
- package/src/sync/history-reader.ts +10 -5
- package/src/sync/history-sqlite.ts +37 -42
- package/src/sync/history.ts +9 -15
- package/src/sync/index.ts +17 -5
- package/src/sync/journal-sqlite.ts +162 -76
- package/src/sync/journal.ts +91 -32
- package/src/sync/live-tails.ts +107 -0
- package/src/sync/projection.ts +35 -0
- package/src/sync/recovery.ts +80 -51
- package/src/sync/schema.ts +27 -6
- package/docs/rfds/0001-deterministic-echo-ids.md +0 -44
- package/docs/rfds/0002-native-subagents.md +0 -197
- package/src/client/request.ts +0 -19
- 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
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
import type { AgentHarness, AuthMethod, HarnessAuth } from "../../protocol/index.ts";
|
|
3
|
+
import type { NativeProcesses } from "../processes/native-processes.ts";
|
|
4
|
+
import { withTimeout } from "../utils/deadline.ts";
|
|
5
|
+
import { InvalidRequestError } from "../utils/errors.ts";
|
|
6
|
+
|
|
7
|
+
/** Whose login: the CLI's store and credentials a turn with this `env` would use. */
|
|
8
|
+
export interface LoginOptions {
|
|
9
|
+
env?: Record<string, string>;
|
|
10
|
+
/** Stops a status read, or a login's start, that took too long. */
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** A harness's login as its CLI says it; the runtime adds the harness and its `methods`. */
|
|
15
|
+
export type LoginStatus = Omit<HarnessAuth, "harness" | "methods">;
|
|
16
|
+
|
|
17
|
+
/** A login the CLI is running: where the user signs in, and how it ends. */
|
|
18
|
+
export interface NativeLogin {
|
|
19
|
+
url?: string;
|
|
20
|
+
/** Where a browser on another device signs in, then the user pastes the code it shows (`complete`). */
|
|
21
|
+
codeUrl?: string;
|
|
22
|
+
/** What the user enters at `url` (a device code). */
|
|
23
|
+
userCode?: string;
|
|
24
|
+
/** Settles when the CLI's flow ends: resolves once it stored the login, rejects with why it did not. */
|
|
25
|
+
readonly done: Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Finish with the code a `codeUrl` page showed; settles once the CLI took
|
|
28
|
+
* or refused it. `InvalidRequestError` for a code it did not send: the
|
|
29
|
+
* login goes on.
|
|
30
|
+
*/
|
|
31
|
+
complete?(code: string): Promise<void>;
|
|
32
|
+
/** Stop the flow and the process running it. */
|
|
33
|
+
cancel(): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A harness's own login, through its CLI: what it is, the CLI's own flows to
|
|
38
|
+
* sign in, and signing out. The CLI keeps what a login stores; the engine
|
|
39
|
+
* never holds a credential.
|
|
40
|
+
*/
|
|
41
|
+
export interface CliLogin {
|
|
42
|
+
/** The ways to sign in to the store a turn with this `env` uses: the CLI's own flows, and its terminal command. */
|
|
43
|
+
methods(options: LoginOptions): Promise<AuthMethod[]>;
|
|
44
|
+
status(options: LoginOptions): Promise<LoginStatus>;
|
|
45
|
+
/** Start one of its `methods` (not a `terminal` one); `apiKey` for an `api_key` method. */
|
|
46
|
+
start(method: string, options: LoginOptions & { apiKey?: string }): Promise<NativeLogin>;
|
|
47
|
+
logout(options: LoginOptions): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The method a login names, refused unless the harness offers it as a login. */
|
|
51
|
+
export function loginMethod<M extends AuthMethod>(methods: readonly M[], id: string): M {
|
|
52
|
+
const method = methods.find((candidate) => candidate.id === id && candidate.kind !== "terminal");
|
|
53
|
+
if (method) return method;
|
|
54
|
+
const offered = methods.filter((candidate) => candidate.kind !== "terminal").map((m) => m.id);
|
|
55
|
+
throw new InvalidRequestError([
|
|
56
|
+
{ path: "method", message: `not a login this harness offers (${offered.join(", ")})` },
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Signing in from a terminal with the CLI's own command. Of the environment a
|
|
62
|
+
* turn would run with, it takes only the variable that picks the CLI's store
|
|
63
|
+
* (`storeVariable`), so the login lands where turns look.
|
|
64
|
+
*/
|
|
65
|
+
export function terminalMethod(
|
|
66
|
+
command: string[],
|
|
67
|
+
env: Record<string, string | undefined>,
|
|
68
|
+
storeVariable: string,
|
|
69
|
+
): AuthMethod {
|
|
70
|
+
const store = env[storeVariable];
|
|
71
|
+
return {
|
|
72
|
+
id: "terminal",
|
|
73
|
+
kind: "terminal",
|
|
74
|
+
label: [basename(command[0] ?? ""), ...command.slice(1)].join(" "),
|
|
75
|
+
command,
|
|
76
|
+
...(store && { env: { [storeVariable]: store } }),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** How long a CLI's own auth command may take. */
|
|
81
|
+
const COMMAND_TIMEOUT_MS = 30_000;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Run one of a CLI's auth commands to its end, held by the lifeline and not
|
|
85
|
+
* recorded (no session waits on it): its exit code and what it wrote.
|
|
86
|
+
*/
|
|
87
|
+
export async function runAuthCommand(
|
|
88
|
+
processes: NativeProcesses,
|
|
89
|
+
spec: {
|
|
90
|
+
command: string;
|
|
91
|
+
args: readonly string[];
|
|
92
|
+
env: NodeJS.ProcessEnv;
|
|
93
|
+
harness: AgentHarness;
|
|
94
|
+
signal?: AbortSignal;
|
|
95
|
+
},
|
|
96
|
+
): Promise<{ code: number | null; stdout: string; stderr: string }> {
|
|
97
|
+
const native = processes.spawn(spec);
|
|
98
|
+
let failed: Error | undefined;
|
|
99
|
+
native.child.once("error", (error) => {
|
|
100
|
+
failed = error;
|
|
101
|
+
});
|
|
102
|
+
native.child.stdin?.end();
|
|
103
|
+
let stdout = "";
|
|
104
|
+
native.child.stdout?.setEncoding("utf8").on("data", (chunk: string) => {
|
|
105
|
+
stdout += chunk;
|
|
106
|
+
});
|
|
107
|
+
const exit = await withTimeout(native.exited, COMMAND_TIMEOUT_MS);
|
|
108
|
+
if (!exit) {
|
|
109
|
+
void native.stop();
|
|
110
|
+
throw new Error(`${spec.command} ${spec.args.join(" ")} did not finish`);
|
|
111
|
+
}
|
|
112
|
+
// It never started: no such CLI, or not one this user may run.
|
|
113
|
+
if (failed) throw new Error(`cannot run ${spec.command}: ${failed.message}`);
|
|
114
|
+
// The tail is redacted already.
|
|
115
|
+
return { code: exit.value.code, stdout, stderr: native.stderrTail.trim() };
|
|
116
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { McpServerConfig } from "../../protocol/index.ts";
|
|
1
|
+
import type { ErrorInfo, McpServerConfig } from "../../protocol/index.ts";
|
|
2
|
+
import { McpUnavailableError } from "../utils/errors.ts";
|
|
2
3
|
|
|
3
4
|
/** A turn owns its wire configuration even when the caller reuses its objects. */
|
|
4
5
|
export function snapshotMcpServers(
|
|
@@ -7,12 +8,24 @@ export function snapshotMcpServers(
|
|
|
7
8
|
return structuredClone(servers ?? {});
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
// @ref LLP 0001#d15--a-turns-mcp-servers-are-required-unless-it-says-otherwise — the caller's check stays
|
|
12
|
+
/** Whether a turn needs the server: each does unless it says `required: false`. */
|
|
13
|
+
export function mcpServerRequired(server: McpServerConfig | undefined): boolean {
|
|
14
|
+
return server?.required !== false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The server as its harness takes it: whether a turn needs it is the engine's rule. */
|
|
18
|
+
export function nativeMcpServer(server: McpServerConfig): McpServerConfig {
|
|
19
|
+
const { required: _required, ...native } = server;
|
|
20
|
+
return native;
|
|
21
|
+
}
|
|
22
|
+
|
|
10
23
|
export function mcpConnectionErrors(
|
|
11
|
-
|
|
24
|
+
names: string[],
|
|
12
25
|
statuses: Array<{ name: string; status: string | null; error?: string }>,
|
|
13
26
|
): Record<string, string> {
|
|
14
27
|
return Object.fromEntries(
|
|
15
|
-
|
|
28
|
+
names.flatMap((name) => {
|
|
16
29
|
const status = statuses.find((entry) => entry.name === name);
|
|
17
30
|
return status?.status === "connected"
|
|
18
31
|
? []
|
|
@@ -21,11 +34,102 @@ export function mcpConnectionErrors(
|
|
|
21
34
|
);
|
|
22
35
|
}
|
|
23
36
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Settle a turn's MCP connection failures: a required server's fails the
|
|
39
|
+
* turn; the others are returned, for the turn to say and go on without.
|
|
40
|
+
* A server missing from `servers` (an operator's in-process one) is required.
|
|
41
|
+
*/
|
|
42
|
+
export function settleMcpFailures(
|
|
43
|
+
errors: Record<string, string>,
|
|
44
|
+
servers: Readonly<Record<string, McpServerConfig | undefined>>,
|
|
45
|
+
): Record<string, string> {
|
|
46
|
+
const causes = Object.entries(errors).map(([name, cause]) => [name, mcpCause(cause)] as const);
|
|
47
|
+
const required = causes.filter(([name]) => mcpServerRequired(servers[name]));
|
|
48
|
+
if (required.length) throw new McpUnavailableError(Object.fromEntries(required));
|
|
49
|
+
return Object.fromEntries(causes);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A connection failure as the stream may carry it: a URL in it names only its
|
|
54
|
+
* origin, since a per-session MCP URL can carry a capability in its path or
|
|
55
|
+
* query, and the stream is journaled, replayed and synced.
|
|
56
|
+
*/
|
|
57
|
+
export function mcpCause(cause: string): string {
|
|
58
|
+
// A URL a JSON string escaped (`https:\/\/…`) is a URL too.
|
|
59
|
+
return cause
|
|
60
|
+
.replace(/:\\\/\\\//g, "://")
|
|
61
|
+
.replace(/\b(?:https?|wss?):\/\/[^\s)"'<>]+/gi, (url) => {
|
|
62
|
+
// Punctuation after it is the sentence's.
|
|
63
|
+
const trailing = /[.,;:!?]+$/.exec(url)?.[0] ?? "";
|
|
64
|
+
try {
|
|
65
|
+
return new URL(url.slice(0, url.length - trailing.length)).origin + trailing;
|
|
66
|
+
} catch {
|
|
67
|
+
return `<url>${trailing}`;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// @ref LLP 0001#d15--a-turns-mcp-servers-are-required-unless-it-says-otherwise — a recoverable error
|
|
73
|
+
/** What a turn says of a server it goes on without. */
|
|
74
|
+
export function mcpUnavailableWarning(name: string, cause: string): ErrorInfo {
|
|
75
|
+
return {
|
|
76
|
+
category: "mcp_unavailable",
|
|
77
|
+
message: `MCP server ${name} could not connect (${cause}); the turn goes on without its tools`,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* How long a turn goes on without a server that could not connect before a
|
|
83
|
+
* turn tries it again: a server that never answers would otherwise hold up
|
|
84
|
+
* every turn by its connection timeout. A changed configuration is tried at
|
|
85
|
+
* once.
|
|
86
|
+
*/
|
|
87
|
+
export const MCP_RETRY_MS = 30_000;
|
|
88
|
+
|
|
89
|
+
// @ref LLP 0001#d15--a-turns-mcp-servers-are-required-unless-it-says-otherwise — tried again after 30 s, or at once when required
|
|
90
|
+
/**
|
|
91
|
+
* The MCP servers a session's turns go on without: why each could not
|
|
92
|
+
* connect, and when it was last tried. A later turn tries one again once
|
|
93
|
+
* `MCP_RETRY_MS` has passed since that try, and at once when it requires it.
|
|
94
|
+
*/
|
|
95
|
+
export class UnavailableMcpServers {
|
|
96
|
+
private servers = new Map<string, { cause: string; triedAt: number }>();
|
|
97
|
+
|
|
98
|
+
/** Why each server could not connect. */
|
|
99
|
+
get causes(): Record<string, string> {
|
|
100
|
+
return Object.fromEntries([...this.servers].map(([name, { cause }]) => [name, cause]));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The servers to try again now: due, or required by the turn's `servers`.
|
|
105
|
+
* One the turn no longer names is returned too: the turn's configuration
|
|
106
|
+
* changed, which reloads the servers anyway.
|
|
107
|
+
*/
|
|
108
|
+
retryNow(servers: Readonly<Record<string, McpServerConfig | undefined>>): string[] {
|
|
109
|
+
const now = Date.now();
|
|
110
|
+
return [...this.servers].flatMap(([name, { triedAt }]) =>
|
|
111
|
+
now - triedAt >= MCP_RETRY_MS || mcpServerRequired(servers[name]) ? [name] : [],
|
|
29
112
|
);
|
|
30
113
|
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* What an attempt to connect went on without, and why. One it tried
|
|
117
|
+
* (`tried`) was last tried now; one it left alone keeps its last try.
|
|
118
|
+
*/
|
|
119
|
+
record(unavailable: Readonly<Record<string, string>>, tried: (name: string) => boolean): void {
|
|
120
|
+
const now = Date.now();
|
|
121
|
+
const before = this.servers;
|
|
122
|
+
this.servers = new Map(
|
|
123
|
+
Object.entries(unavailable).map(([name, cause]) => {
|
|
124
|
+
const at = before.get(name)?.triedAt;
|
|
125
|
+
return [name, { cause, triedAt: at === undefined || tried(name) ? now : at }];
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Say each server the turn goes on without (`AgentExecuteOptions.onWarning`). */
|
|
131
|
+
async announce(onWarning: ((warning: ErrorInfo) => Promise<void>) | undefined): Promise<void> {
|
|
132
|
+
for (const [name, { cause }] of this.servers)
|
|
133
|
+
await onWarning?.(mcpUnavailableWarning(name, cause));
|
|
134
|
+
}
|
|
31
135
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PermissionMode, PermissionOption } from "../../protocol/index.ts";
|
|
2
|
+
|
|
3
|
+
// @ref LLP 0001#d4--permission-requests-are-first-class-protocol — a plan's approval picks the mode
|
|
4
|
+
/**
|
|
5
|
+
* How a user answers an agent's plan: go on in a mode, or keep planning. Each
|
|
6
|
+
* option's id is the permission mode the session goes on in. These are Claude
|
|
7
|
+
* Code's own choices; Codex's TUI asks the same ("implement this plan" / "stay
|
|
8
|
+
* in Plan mode"). Auto-accepting edits is a standing choice for the edits to
|
|
9
|
+
* come (`allow_always`, as claude-agent-acp marks it), so an approver that
|
|
10
|
+
* takes the one-time approval implements asking for each edit. No standing
|
|
11
|
+
* rule answers a later plan: the broker keeps none for a harness's options.
|
|
12
|
+
*/
|
|
13
|
+
export const PLAN_OPTIONS: PermissionOption[] = [
|
|
14
|
+
{ optionId: "accept_edits", name: "Yes, and auto-accept edits", kind: "allow_always" },
|
|
15
|
+
{ optionId: "default", name: "Yes, and manually approve edits", kind: "allow_once" },
|
|
16
|
+
{ optionId: "plan", name: "No, keep planning", kind: "reject_once" },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
/** What a plan's approval asks. */
|
|
20
|
+
export const PLAN_TITLE = "Implement this plan?";
|
|
21
|
+
|
|
22
|
+
/** The mode an approved plan is implemented in. */
|
|
23
|
+
export function approvedPlanMode(optionId: string | undefined): PermissionMode {
|
|
24
|
+
return optionId === "accept_edits" ? "accept_edits" : "default";
|
|
25
|
+
}
|
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
import type { AgentHarness } from "../../protocol/index.ts";
|
|
2
|
-
import {
|
|
2
|
+
import { NativeProcesses } from "../processes/native-processes.ts";
|
|
3
|
+
import type { CliProvisioner } from "../provision/provisioner.ts";
|
|
4
|
+
import { HarnessNotAvailableError } from "../utils/errors.ts";
|
|
3
5
|
import type { Agent } from "./base.ts";
|
|
4
6
|
import type { AdapterFactory } from "./types.ts";
|
|
5
7
|
|
|
6
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Pairs each harness with its agent implementation and event adapter, and
|
|
10
|
+
* holds the native processes its agents start, which the runtime stops at
|
|
11
|
+
* shutdown and a restart sweeps, and the provisioner that installs their
|
|
12
|
+
* CLIs, which the runtime asks for status and installs ahead of a turn.
|
|
13
|
+
*/
|
|
7
14
|
export class AgentRegistry {
|
|
8
15
|
private readonly agents = new Map<AgentHarness, Agent>();
|
|
9
16
|
private readonly adapters = new Map<AgentHarness, AdapterFactory>();
|
|
10
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Agents made for this registry start their CLIs through `processes` and
|
|
20
|
+
* resolve them through `provisioner` (`createAgentRegistry` does both);
|
|
21
|
+
* without one, the runtime reports its harnesses' CLIs `unmanaged`.
|
|
22
|
+
*/
|
|
23
|
+
constructor(
|
|
24
|
+
readonly processes: NativeProcesses = new NativeProcesses(),
|
|
25
|
+
readonly provisioner?: CliProvisioner,
|
|
26
|
+
) {}
|
|
27
|
+
|
|
11
28
|
register(agent: Agent, adapter: AdapterFactory): this {
|
|
12
29
|
this.agents.set(agent.harness, agent);
|
|
13
30
|
this.adapters.set(agent.harness, adapter);
|
|
@@ -16,13 +33,13 @@ export class AgentRegistry {
|
|
|
16
33
|
|
|
17
34
|
getAgent(harness: AgentHarness): Agent {
|
|
18
35
|
const agent = this.agents.get(harness);
|
|
19
|
-
if (!agent) throw new
|
|
36
|
+
if (!agent) throw new HarnessNotAvailableError(harness);
|
|
20
37
|
return agent;
|
|
21
38
|
}
|
|
22
39
|
|
|
23
40
|
getAdapter(harness: AgentHarness): AdapterFactory {
|
|
24
41
|
const adapter = this.adapters.get(harness);
|
|
25
|
-
if (!adapter) throw new
|
|
42
|
+
if (!adapter) throw new HarnessNotAvailableError(harness);
|
|
26
43
|
return adapter;
|
|
27
44
|
}
|
|
28
45
|
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import type { AgentInput } from "../../protocol/index.ts";
|
|
2
2
|
import { SessionResumeError, TurnActiveError } from "../utils/errors.ts";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type AgentExecuteOptions,
|
|
5
|
+
BaseAgent,
|
|
6
|
+
type RawAgentEvent,
|
|
7
|
+
type SteerOutcome,
|
|
8
|
+
type SteerRequest,
|
|
9
|
+
} from "./base.ts";
|
|
4
10
|
import { configFingerprint } from "./config-fingerprint.ts";
|
|
5
11
|
|
|
12
|
+
/** Hands one steer to the harness's native turn. */
|
|
13
|
+
export type DeliverSteer = (request: SteerRequest) => SteerOutcome | Promise<SteerOutcome>;
|
|
14
|
+
|
|
15
|
+
/** A turn's input: steers wait here until its native turn takes them. */
|
|
16
|
+
interface TurnSteering {
|
|
17
|
+
turnId: string;
|
|
18
|
+
/** The executing turn's; absent while the admitted turn waits to execute. */
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
early: SteerRequest[];
|
|
21
|
+
deliver?: DeliverSteer;
|
|
22
|
+
}
|
|
23
|
+
|
|
6
24
|
/**
|
|
7
25
|
* Shared execution lifecycle for built-in harnesses. One turn owns a logical
|
|
8
26
|
* session from preparation through native cleanup. BaseAgent remains available
|
|
@@ -14,6 +32,10 @@ export abstract class SessionAgent extends BaseAgent {
|
|
|
14
32
|
private readonly activeSessions = new Set<string>();
|
|
15
33
|
/** Conversation identity outlives subprocess eviction and failed startup. */
|
|
16
34
|
private readonly conversations = new Map<string, { id: string | undefined; boundary: string }>();
|
|
35
|
+
/** The running turn's input, per session. */
|
|
36
|
+
private readonly steering = new Map<string, TurnSteering>();
|
|
37
|
+
/** The last turn each session executed: a steer for it comes too late. */
|
|
38
|
+
private readonly executed = new Map<string, string>();
|
|
17
39
|
|
|
18
40
|
override async *execute(
|
|
19
41
|
input: AgentInput,
|
|
@@ -27,17 +49,86 @@ export abstract class SessionAgent extends BaseAgent {
|
|
|
27
49
|
if (this.activeSessions.has(sessionId)) throw new TurnActiveError(sessionId);
|
|
28
50
|
this.activeSessions.add(sessionId);
|
|
29
51
|
const controller = this.trackTurn(sessionId, options.signal);
|
|
52
|
+
// Steers sent since the runtime admitted this turn wait in its record.
|
|
53
|
+
const waiting = this.steering.get(sessionId);
|
|
54
|
+
const steering: TurnSteering = {
|
|
55
|
+
turnId: options.turnId,
|
|
56
|
+
signal: controller.signal,
|
|
57
|
+
early: waiting?.turnId === options.turnId ? waiting.early : [],
|
|
58
|
+
};
|
|
59
|
+
this.steering.set(sessionId, steering);
|
|
30
60
|
try {
|
|
31
61
|
// The adapter still produces its native cancellation result for an
|
|
32
62
|
// already-aborted turn. It must not select a conversation or do setup.
|
|
33
63
|
const prepared = controller.signal.aborted ? options : this.prepareSessionOptions(options);
|
|
34
64
|
yield* this.executeTurn(input, prepared, controller);
|
|
35
65
|
} finally {
|
|
66
|
+
this.executed.set(sessionId, options.turnId);
|
|
67
|
+
if (this.steering.get(sessionId) === steering) this.steering.delete(sessionId);
|
|
36
68
|
this.endTurn(sessionId, controller);
|
|
37
69
|
this.activeSessions.delete(sessionId);
|
|
38
70
|
}
|
|
39
71
|
}
|
|
40
72
|
|
|
73
|
+
// @ref LLP 0001#d13--input-while-a-turn-runs-steers-it — held until the native turn takes it
|
|
74
|
+
/**
|
|
75
|
+
* Steer the session's turn. The runtime steers only a turn it admitted, so
|
|
76
|
+
* a steer for a turn not executing yet waits for it; until the native turn
|
|
77
|
+
* can take input (`openSteering`) steers wait in order. A cancelled turn, or
|
|
78
|
+
* a turn other than the one executing, takes none.
|
|
79
|
+
*/
|
|
80
|
+
async steer(sessionId: string, request: SteerRequest): Promise<SteerOutcome> {
|
|
81
|
+
const turn = this.steering.get(sessionId);
|
|
82
|
+
if (turn?.signal && (turn.turnId !== request.turnId || turn.signal.aborted)) {
|
|
83
|
+
return "no_active_turn";
|
|
84
|
+
}
|
|
85
|
+
if (this.executed.get(sessionId) === request.turnId) return "no_active_turn";
|
|
86
|
+
this.checkSteerInput(request.input);
|
|
87
|
+
if (!turn || turn.turnId !== request.turnId) {
|
|
88
|
+
this.steering.set(sessionId, { turnId: request.turnId, early: [request] });
|
|
89
|
+
return "steered";
|
|
90
|
+
}
|
|
91
|
+
if (!turn.deliver) {
|
|
92
|
+
turn.early.push(request);
|
|
93
|
+
return "steered";
|
|
94
|
+
}
|
|
95
|
+
return await turn.deliver(request);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Throw for steer input this harness cannot take, as a turn's input would. */
|
|
99
|
+
protected checkSteerInput(_input: AgentInput): void {}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The native turn takes input now: deliver the steers that came before it,
|
|
103
|
+
* in order, then every later one as it comes. A steer the turn refuses stays
|
|
104
|
+
* undelivered, and `turn.ended` says so.
|
|
105
|
+
*/
|
|
106
|
+
protected async openSteering(options: AgentExecuteOptions, deliver: DeliverSteer): Promise<void> {
|
|
107
|
+
const turn = this.steering.get(options.sessionId);
|
|
108
|
+
if (!turn || turn.turnId !== options.turnId) return;
|
|
109
|
+
// A cancelled turn reads nothing more: its early steers stay undelivered.
|
|
110
|
+
if (turn.signal?.aborted) return;
|
|
111
|
+
while (turn.early.length > 0) {
|
|
112
|
+
const request = turn.early.shift() as SteerRequest;
|
|
113
|
+
try {
|
|
114
|
+
await deliver(request);
|
|
115
|
+
} catch {
|
|
116
|
+
// Undelivered; the turn's end reports it.
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
turn.deliver = deliver;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The native turn takes no more input: it ended, and another may follow in
|
|
124
|
+
* the same turn (Codex implementing an approved plan). Steers wait for the
|
|
125
|
+
* next `openSteering`, or the turn's end lists them undelivered.
|
|
126
|
+
*/
|
|
127
|
+
protected holdSteering(options: AgentExecuteOptions): void {
|
|
128
|
+
const turn = this.steering.get(options.sessionId);
|
|
129
|
+
if (turn?.turnId === options.turnId) turn.deliver = undefined;
|
|
130
|
+
}
|
|
131
|
+
|
|
41
132
|
/** Native protocol execution; options are prepared and the session is exclusively owned. */
|
|
42
133
|
protected abstract executeTurn(
|
|
43
134
|
input: AgentInput,
|
|
@@ -46,9 +137,6 @@ export abstract class SessionAgent extends BaseAgent {
|
|
|
46
137
|
): AsyncIterableIterator<RawAgentEvent>;
|
|
47
138
|
|
|
48
139
|
private prepareSessionOptions(options: AgentExecuteOptions): AgentExecuteOptions {
|
|
49
|
-
if (options.resumeSessionId === "") {
|
|
50
|
-
throw new Error("Invalid request: resumeSessionId must not be empty");
|
|
51
|
-
}
|
|
52
140
|
const boundary = configFingerprint({
|
|
53
141
|
cwd: options.cwd,
|
|
54
142
|
env: options.env,
|
|
@@ -83,12 +171,16 @@ export abstract class SessionAgent extends BaseAgent {
|
|
|
83
171
|
|
|
84
172
|
override async release(sessionId: string): Promise<void> {
|
|
85
173
|
this.conversations.delete(sessionId);
|
|
174
|
+
this.steering.delete(sessionId);
|
|
175
|
+
this.executed.delete(sessionId);
|
|
86
176
|
await super.release(sessionId);
|
|
87
177
|
}
|
|
88
178
|
|
|
89
179
|
override async terminateAll(): Promise<void> {
|
|
90
180
|
this.terminated = true;
|
|
91
181
|
this.conversations.clear();
|
|
182
|
+
this.steering.clear();
|
|
183
|
+
this.executed.clear();
|
|
92
184
|
await super.terminateAll();
|
|
93
185
|
}
|
|
94
186
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Idle time before an unused session's subprocess is shut down, unless its
|
|
3
|
+
* harness's `idleTimeoutMs` says otherwise.
|
|
4
|
+
*/
|
|
5
|
+
export const IDLE_TIMEOUT_MS = 5 * 60_000;
|
|
6
|
+
|
|
7
|
+
/** The slice of a session a SessionPool manages: a closable client + idle timer. */
|
|
8
|
+
export interface PooledSession {
|
|
3
9
|
client: { closed: boolean; close(): void };
|
|
4
10
|
idleTimer?: ReturnType<typeof setTimeout>;
|
|
5
11
|
}
|
|
@@ -7,10 +13,10 @@ export interface StoredSession {
|
|
|
7
13
|
/**
|
|
8
14
|
* Per-logical-session bookkeeping shared by subprocess-backed harnesses
|
|
9
15
|
* (codex-app-server, acp): the sessionId → session map, idle-eviction timers,
|
|
10
|
-
* self-healing when a client dies underneath us, and whole-
|
|
16
|
+
* self-healing when a client dies underneath us, and whole-pool teardown.
|
|
11
17
|
* Harnesses own what a session *is*; this owns when one goes away.
|
|
12
18
|
*/
|
|
13
|
-
export class
|
|
19
|
+
export class SessionPool<S extends PooledSession> {
|
|
14
20
|
private readonly sessions = new Map<string, S>();
|
|
15
21
|
private readonly pending = new Map<string, Set<S["client"]>>();
|
|
16
22
|
private closed = false;
|
|
@@ -19,7 +25,7 @@ export class SessionStore<S extends StoredSession> {
|
|
|
19
25
|
trackPending(sessionId: string, client: S["client"]): () => void {
|
|
20
26
|
if (this.closed) {
|
|
21
27
|
client.close();
|
|
22
|
-
throw new Error("session
|
|
28
|
+
throw new Error("session pool is closed");
|
|
23
29
|
}
|
|
24
30
|
let clients = this.pending.get(sessionId);
|
|
25
31
|
if (!clients) {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { StringDecoder } from "node:string_decoder";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The end of an agent subprocess's stderr: the only place a CLI says why it
|
|
5
|
+
* cannot run (a missing login, a bad flag), so its exit error carries it.
|
|
6
|
+
* Decoded across chunk boundaries, and bounded: the CLI's own error, never a
|
|
7
|
+
* log flood. What it gives is redacted (`redactSecrets`): it becomes part of
|
|
8
|
+
* an error, which the stream, the journal and every log carry.
|
|
9
|
+
*/
|
|
10
|
+
export class StderrTail {
|
|
11
|
+
/** Twice the bound, so that a secret the cut would split is redacted whole first. */
|
|
12
|
+
private tail = "";
|
|
13
|
+
private readonly decoder = new StringDecoder("utf8");
|
|
14
|
+
|
|
15
|
+
constructor(private readonly max: number) {}
|
|
16
|
+
|
|
17
|
+
/** Add a chunk. Returns the tail with it, unredacted, before the tail is cut to size. */
|
|
18
|
+
write(chunk: Buffer): string {
|
|
19
|
+
const text = this.tail + this.decoder.write(chunk);
|
|
20
|
+
this.tail = text.slice(-2 * this.max);
|
|
21
|
+
return text;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Once the stream closed: its last flush, which usually says why. */
|
|
25
|
+
end(): string {
|
|
26
|
+
this.tail = (this.tail + this.decoder.end()).slice(-2 * this.max);
|
|
27
|
+
return this.text;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The last `max` characters, redacted before the cut. */
|
|
31
|
+
get text(): string {
|
|
32
|
+
return redactSecrets(this.tail).slice(-this.max);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** What a secret's place reads once it is taken out. */
|
|
37
|
+
const REDACTED = "[REDACTED]";
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* What a CLI may print that must not reach an error: the stream, the journal
|
|
41
|
+
* and every log carry an exit error's words. Each family, then what of it is
|
|
42
|
+
* replaced; what surrounds a secret is kept.
|
|
43
|
+
*/
|
|
44
|
+
const SECRETS: readonly [RegExp, string][] = [
|
|
45
|
+
// Anthropic API keys and OAuth tokens (`sk-ant-api03-…`, `sk-ant-oat01-…`).
|
|
46
|
+
[/\bsk-ant-[A-Za-z0-9_-]{8,}/g, REDACTED],
|
|
47
|
+
// OpenAI keys (`sk-…`, `sk-proj-…`).
|
|
48
|
+
[/\bsk-[A-Za-z0-9_-]{20,}/g, REDACTED],
|
|
49
|
+
// JWTs: three base64url segments, the first a JSON header.
|
|
50
|
+
[/\beyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g, REDACTED],
|
|
51
|
+
// HTTP credentials: the scheme stays, a credential of 20 or more characters goes.
|
|
52
|
+
[/\b(Bearer|Basic)(\s+)[A-Za-z0-9._~+/=-]{20,}/gi, `$1$2${REDACTED}`],
|
|
53
|
+
// AWS access keys.
|
|
54
|
+
[/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g, REDACTED],
|
|
55
|
+
// Credentials in a URL: `scheme://user:pass@host` keeps its scheme and host.
|
|
56
|
+
[/\b([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/gi, `$1${REDACTED}@`],
|
|
57
|
+
// Assignments to a key, token, secret or password: `NAME=value`, `"name": "value"`.
|
|
58
|
+
[
|
|
59
|
+
/\b([A-Za-z0-9_.-]*(?:key|token|secret|password))(\s*=\s*)(["']?)[^\s"'`,;&]+/gi,
|
|
60
|
+
`$1$2$3${REDACTED}`,
|
|
61
|
+
],
|
|
62
|
+
[/("[A-Za-z0-9_.-]*(?:key|token|secret|password)"\s*:\s*")[^"]+"/gi, `$1${REDACTED}"`],
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* `text` with every secret it holds replaced by `[REDACTED]`, and everything
|
|
67
|
+
* else as it was. For whatever of a CLI's own output becomes part of an
|
|
68
|
+
* error: the Claude SDK redacts the stderr it quotes, and this engine's exit
|
|
69
|
+
* errors (Claude's restored tail, Codex's and ACP's) are redacted the same way.
|
|
70
|
+
*/
|
|
71
|
+
export function redactSecrets(text: string): string {
|
|
72
|
+
let redacted = text;
|
|
73
|
+
for (const [pattern, replacement] of SECRETS) redacted = redacted.replace(pattern, replacement);
|
|
74
|
+
return redacted;
|
|
75
|
+
}
|
package/src/core/agents/types.ts
CHANGED
|
@@ -1,15 +1,30 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ErrorCategory,
|
|
3
|
+
LimitStatus,
|
|
4
|
+
LimitWindow,
|
|
5
|
+
Part,
|
|
6
|
+
PermissionMode,
|
|
7
|
+
StopReason,
|
|
8
|
+
TokenUsage,
|
|
9
|
+
} from "../../protocol/index.ts";
|
|
2
10
|
|
|
3
11
|
/**
|
|
4
12
|
* The normalized intermediate an adapter emits while consuming raw harness
|
|
5
13
|
* events. The engine's EventProcessor turns these into wire `LifecycleEvent`s,
|
|
6
14
|
* assigning message/part indices and ids. Keeping deltas here (rather than
|
|
7
15
|
* diffing snapshots downstream) lets each adapter express its harness's exact
|
|
8
|
-
* streaming granularity — token-level for Claude
|
|
9
|
-
*
|
|
16
|
+
* streaming granularity — token-level for Claude and Codex app-server,
|
|
17
|
+
* chunk-level for ACP agents.
|
|
10
18
|
*/
|
|
11
19
|
export type AdapterEvent =
|
|
12
|
-
|
|
20
|
+
/** `model`: the model that produced the message, when the harness names it per message. */
|
|
21
|
+
| { kind: "message-start"; role: "assistant" | "user"; model?: string }
|
|
22
|
+
/**
|
|
23
|
+
* The model that writes what follows, until another says otherwise: a
|
|
24
|
+
* sub-agent's messages when `parentToolCallId` is set, else the turn's (a
|
|
25
|
+
* Codex reroute). A message's own named model wins.
|
|
26
|
+
*/
|
|
27
|
+
| { kind: "model"; model: string; parentToolCallId?: string }
|
|
13
28
|
| { kind: "message-end" }
|
|
14
29
|
/** A new part appears (streaming text begins, a tool call opens, etc.). */
|
|
15
30
|
| { kind: "part-open"; part: Part }
|
|
@@ -27,7 +42,25 @@ export type AdapterEvent =
|
|
|
27
42
|
/** Context-window gauge snapshot (→ `session.usage`). */
|
|
28
43
|
| { kind: "usage"; used: number; size?: number; cost?: number }
|
|
29
44
|
/** History-compaction boundary (→ the `session.compaction` entity). */
|
|
30
|
-
| { kind: "compacted"; trigger?: string; preTokens?: number; postTokens?: number }
|
|
45
|
+
| { kind: "compacted"; trigger?: string; preTokens?: number; postTokens?: number }
|
|
46
|
+
/** The account's plan usage (→ `session.limits`). */
|
|
47
|
+
| { kind: "limits"; windows: LimitWindow[]; status?: LimitStatus; planType?: string }
|
|
48
|
+
/** The agent switched the session's permission mode (→ `session.mode` when it changed). */
|
|
49
|
+
| { kind: "mode"; permissionMode: PermissionMode }
|
|
50
|
+
/** The harness is retrying a failed request; the turn goes on (→ a recoverable `error`). */
|
|
51
|
+
| {
|
|
52
|
+
kind: "retry";
|
|
53
|
+
category: ErrorCategory;
|
|
54
|
+
message: string;
|
|
55
|
+
attempt?: number;
|
|
56
|
+
maxAttempts?: number;
|
|
57
|
+
delayMs?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The agent read a steer here, at its next step (→ the steer's user
|
|
61
|
+
* message). An id the turn did not accept is ignored.
|
|
62
|
+
*/
|
|
63
|
+
| { kind: "steer-inserted"; steerId: string };
|
|
31
64
|
|
|
32
65
|
/** Terminal result of a turn, surfaced on `turn.ended`. */
|
|
33
66
|
export interface TransformResult {
|
|
@@ -42,6 +75,8 @@ export interface TransformResult {
|
|
|
42
75
|
finishReason?: string;
|
|
43
76
|
cost?: number;
|
|
44
77
|
error?: string;
|
|
78
|
+
/** The harness's own classification of `error`, from a typed code (beats matching its text). */
|
|
79
|
+
errorCategory?: ErrorCategory;
|
|
45
80
|
cancelled?: boolean;
|
|
46
81
|
}
|
|
47
82
|
|