@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
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { AsyncQueue, type McpServerConfig } from "../../../protocol/index.ts";
|
|
1
|
+
import { AsyncQueue, type ErrorInfo, type McpServerConfig } from "../../../protocol/index.ts";
|
|
2
|
+
import type { AgentExecuteOptions } from "../base.ts";
|
|
2
3
|
import { configFingerprint } from "../config-fingerprint.ts";
|
|
3
|
-
import {
|
|
4
|
-
|
|
4
|
+
import {
|
|
5
|
+
UnavailableMcpServers,
|
|
6
|
+
mcpConnectionErrors,
|
|
7
|
+
settleMcpFailures,
|
|
8
|
+
snapshotMcpServers,
|
|
9
|
+
} from "../mcp-config.ts";
|
|
10
|
+
import { type CodexConnection, pages } from "./client.ts";
|
|
11
|
+
import type { CodexHomes } from "./homes.ts";
|
|
12
|
+
import type { CodexNotification } from "./protocol.ts";
|
|
5
13
|
|
|
6
14
|
/** Codex supports stdio and Streamable HTTP, not the legacy SSE transport. */
|
|
7
15
|
export function codexMcpServers(servers: Record<string, McpServerConfig>): Record<string, unknown> {
|
|
@@ -27,7 +35,7 @@ export function codexMcpServers(servers: Record<string, McpServerConfig>): Recor
|
|
|
27
35
|
|
|
28
36
|
/** Only call against an explicitly isolated, engine-managed CODEX_HOME. */
|
|
29
37
|
export async function writeCodexMcpServers(
|
|
30
|
-
client:
|
|
38
|
+
client: Pick<CodexConnection, "request">,
|
|
31
39
|
servers: Record<string, unknown>,
|
|
32
40
|
): Promise<void> {
|
|
33
41
|
const result = (await client.request("config/batchWrite", {
|
|
@@ -60,7 +68,7 @@ function normalizedConfig(value: unknown): unknown {
|
|
|
60
68
|
|
|
61
69
|
/** User-layer write acknowledgements do not account for repository overrides. */
|
|
62
70
|
export async function assertCodexMcpConfig(
|
|
63
|
-
client:
|
|
71
|
+
client: Pick<CodexConnection, "request">,
|
|
64
72
|
cwd: string,
|
|
65
73
|
servers: Record<string, unknown>,
|
|
66
74
|
): Promise<void> {
|
|
@@ -78,12 +86,39 @@ export async function assertCodexMcpConfig(
|
|
|
78
86
|
}
|
|
79
87
|
}
|
|
80
88
|
|
|
81
|
-
|
|
82
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Codex's startup error for a server, readable: its Rust type paths out, a
|
|
91
|
+
* chain it repeats said once, and no prefix naming the server again.
|
|
92
|
+
*/
|
|
93
|
+
export function codexMcpCause(name: string, error: string): string {
|
|
94
|
+
const segments = error
|
|
95
|
+
// A Rust path (`[codex_rmcp_client::…]`), never an IPv6 host (`[fe80::1]`).
|
|
96
|
+
.replace(/\s*\[([^\]]*::[^\]]*)\]/g, (path, inside: string) =>
|
|
97
|
+
/^[0-9a-f:.%]+$/i.test(inside) ? path : "",
|
|
98
|
+
)
|
|
99
|
+
.replace(`MCP client for \`${name}\` failed to start: `, "")
|
|
100
|
+
.split(": ");
|
|
101
|
+
return segments.filter((segment, i) => segments.indexOf(segment) === i).join(": ");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** How long a turn waits for its MCP servers to start. */
|
|
105
|
+
const MCP_STARTUP_MS = 30_000;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Wait for the thread's MCP servers to start, and settle the ones that did
|
|
109
|
+
* not: a required server's failure fails the turn (`McpUnavailableError`);
|
|
110
|
+
* the others are returned, each with why, for the turn to say and go on
|
|
111
|
+
* without. `servers` is the turn's wire configuration, by name, and `causes`
|
|
112
|
+
* why each server last failed, as Codex said.
|
|
113
|
+
*/
|
|
114
|
+
export async function settleCodexMcp(
|
|
115
|
+
client: CodexConnection,
|
|
83
116
|
threadId: string,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
117
|
+
servers: Readonly<Record<string, McpServerConfig>>,
|
|
118
|
+
causes: ReadonlyMap<string, string>,
|
|
119
|
+
): Promise<Record<string, string>> {
|
|
120
|
+
const names = Object.keys(servers);
|
|
121
|
+
if (!names.length) return {};
|
|
87
122
|
// A status snapshot can arrive while startup is still in progress. Subscribe
|
|
88
123
|
// first so completion during the request cannot be lost. Native notifications
|
|
89
124
|
// trigger another authoritative read; no setup, model or tool is retried.
|
|
@@ -92,42 +127,62 @@ export async function assertCodexMcpReady(
|
|
|
92
127
|
if (
|
|
93
128
|
method === "mcpServer/startupStatus/updated" &&
|
|
94
129
|
params.threadId === threadId &&
|
|
95
|
-
|
|
130
|
+
names.includes(String(params.name))
|
|
96
131
|
)
|
|
97
132
|
updates.push(undefined);
|
|
98
133
|
});
|
|
99
|
-
const offClose = client.onClose(() =>
|
|
100
|
-
|
|
101
|
-
|
|
134
|
+
const offClose = client.onClose((error) =>
|
|
135
|
+
updates.fail(error ?? new Error("Codex closed during MCP startup")),
|
|
136
|
+
);
|
|
137
|
+
const deadline = Date.now() + MCP_STARTUP_MS;
|
|
138
|
+
// At the deadline the loop reads once more and settles what still starts:
|
|
139
|
+
// the timer says so itself, as a clock can read short of the deadline then.
|
|
140
|
+
let late = false;
|
|
141
|
+
const timer = setTimeout(() => {
|
|
142
|
+
late = true;
|
|
143
|
+
updates.push(undefined);
|
|
144
|
+
}, MCP_STARTUP_MS);
|
|
102
145
|
try {
|
|
103
146
|
for (;;) {
|
|
104
|
-
const statuses: Array<{ name: string; status: string | null }> = [];
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
147
|
+
const statuses: Array<{ name: string; status: string | null; error?: string }> = [];
|
|
148
|
+
// Asked by name, Codex answers from the thread's own connection.
|
|
149
|
+
// Asked for every server, it connects to each again (initialize,
|
|
150
|
+
// tools/list) on every turn (0.160, `.context/rehearsal/m1-mcp-reinit.ts`).
|
|
151
|
+
for (const serverName of names) {
|
|
152
|
+
for await (const page of pages<{ name: string; runtimeStatus: string | null }>(
|
|
153
|
+
client,
|
|
108
154
|
"mcpServerStatus/list",
|
|
109
|
-
{ threadId, detail: "toolsAndAuthOnly", limit: 100
|
|
110
|
-
Math.max(
|
|
111
|
-
))
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
155
|
+
{ threadId, serverName, detail: "toolsAndAuthOnly", limit: 100 },
|
|
156
|
+
{ timeoutMs: Math.max(5_000, deadline - Date.now()) },
|
|
157
|
+
))
|
|
158
|
+
statuses.push(
|
|
159
|
+
...page
|
|
160
|
+
.filter(({ name }) => name === serverName)
|
|
161
|
+
.map(({ name, runtimeStatus }) => {
|
|
162
|
+
const cause = causes.get(name);
|
|
163
|
+
return { name, status: runtimeStatus, ...(cause && { error: cause }) };
|
|
164
|
+
}),
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
// Read once, after the pass: past the deadline every server settles.
|
|
168
|
+
const settling = late;
|
|
169
|
+
const starting = settling
|
|
170
|
+
? []
|
|
171
|
+
: names.filter(
|
|
172
|
+
(name) => statuses.find((entry) => entry.name === name)?.status === "starting",
|
|
173
|
+
);
|
|
174
|
+
const unavailable = settleMcpFailures(
|
|
125
175
|
mcpConnectionErrors(
|
|
126
|
-
|
|
127
|
-
statuses
|
|
176
|
+
names.filter((name) => !starting.includes(name)),
|
|
177
|
+
statuses.map((entry) =>
|
|
178
|
+
entry.status === "starting" && !entry.error
|
|
179
|
+
? { ...entry, error: `did not start within ${MCP_STARTUP_MS / 1000} s` }
|
|
180
|
+
: entry,
|
|
181
|
+
),
|
|
128
182
|
),
|
|
183
|
+
servers,
|
|
129
184
|
);
|
|
130
|
-
if (!starting.length) return;
|
|
185
|
+
if (!starting.length) return unavailable;
|
|
131
186
|
await updates.next();
|
|
132
187
|
}
|
|
133
188
|
} finally {
|
|
@@ -137,3 +192,93 @@ export async function assertCodexMcpReady(
|
|
|
137
192
|
updates.end();
|
|
138
193
|
}
|
|
139
194
|
}
|
|
195
|
+
|
|
196
|
+
/** A turn's MCP servers: as the wire gave them, and as Codex takes them, when its home is the engine's. */
|
|
197
|
+
export interface CodexTurnMcp {
|
|
198
|
+
wire: Record<string, McpServerConfig>;
|
|
199
|
+
/** Absent when the turn runs in a home the engine does not write. */
|
|
200
|
+
servers?: Record<string, unknown>;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** The turn's servers, snapshotted before anything asynchronous can let the caller change them. */
|
|
204
|
+
export function codexTurnMcp(options: AgentExecuteOptions, homes: CodexHomes): CodexTurnMcp {
|
|
205
|
+
const wire = snapshotMcpServers(options.mcpServers);
|
|
206
|
+
const servers = codexMcpServers(wire);
|
|
207
|
+
return homes.claim(options, Object.keys(servers).length > 0) ? { wire, servers } : { wire };
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* A session's MCP servers on Codex: the configuration last written to its
|
|
212
|
+
* home, why each server last failed to start, and the ones its turns went
|
|
213
|
+
* without.
|
|
214
|
+
*/
|
|
215
|
+
export class CodexMcpState {
|
|
216
|
+
/** Last native config write; readiness is checked separately before every prompt. */
|
|
217
|
+
private fingerprint?: string;
|
|
218
|
+
/**
|
|
219
|
+
* Why each MCP server last failed to start, as Codex said, from the
|
|
220
|
+
* client's first notification: a fast failure can come before a turn asks.
|
|
221
|
+
*/
|
|
222
|
+
private readonly causes = new Map<string, string>();
|
|
223
|
+
/** The servers a turn went without, and when each was last tried. */
|
|
224
|
+
private readonly unavailable = new UnavailableMcpServers();
|
|
225
|
+
|
|
226
|
+
constructor(
|
|
227
|
+
private readonly client: CodexConnection,
|
|
228
|
+
private readonly cwd: string,
|
|
229
|
+
) {}
|
|
230
|
+
|
|
231
|
+
/** Note what Codex says of a server's startup on the session's own thread, not a subagent's. */
|
|
232
|
+
observe({ method, params }: CodexNotification, threadId: string): void {
|
|
233
|
+
if (method !== "mcpServer/startupStatus/updated") return;
|
|
234
|
+
if (threadId && params.threadId && params.threadId !== threadId) return;
|
|
235
|
+
const name = String(params.name);
|
|
236
|
+
if (typeof params.error === "string" && params.error)
|
|
237
|
+
this.causes.set(name, codexMcpCause(name, params.error));
|
|
238
|
+
// Ready, or starting again: an old cause says nothing of now.
|
|
239
|
+
else if (params.status === "ready" || params.status === "starting") this.causes.delete(name);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** Write the turn's servers to the session's home, check Codex took them, and reload them when they changed. */
|
|
243
|
+
async configure(servers: Record<string, unknown> | undefined): Promise<void> {
|
|
244
|
+
if (servers === undefined) return;
|
|
245
|
+
const fingerprint = configFingerprint(servers);
|
|
246
|
+
const changed = this.fingerprint !== fingerprint;
|
|
247
|
+
// A rejected write or changed project layer invalidates the cached identity.
|
|
248
|
+
this.fingerprint = undefined;
|
|
249
|
+
if (changed) await writeCodexMcpServers(this.client, servers);
|
|
250
|
+
await assertCodexMcpConfig(this.client, this.cwd, servers);
|
|
251
|
+
if (changed) await this.client.request("config/mcpServer/reload", undefined);
|
|
252
|
+
this.fingerprint = fingerprint;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Get the thread's servers ready for a turn: configured, started, and the
|
|
257
|
+
* ones it goes on without said through `onWarning`. A required server that
|
|
258
|
+
* cannot connect fails the turn.
|
|
259
|
+
*/
|
|
260
|
+
async prepare(
|
|
261
|
+
threadId: string,
|
|
262
|
+
{ wire, servers }: CodexTurnMcp,
|
|
263
|
+
onWarning: ((warning: ErrorInfo) => Promise<void>) | undefined,
|
|
264
|
+
): Promise<void> {
|
|
265
|
+
// A server the last turn went without is reloaded once due (a reload
|
|
266
|
+
// restarts the thread's servers, so not on every turn), or at once
|
|
267
|
+
// when this turn requires it: its old failure must not decide.
|
|
268
|
+
if (this.unavailable.retryNow(wire).length) this.fingerprint = undefined;
|
|
269
|
+
const reloading = servers !== undefined && this.fingerprint !== configFingerprint(servers);
|
|
270
|
+
await this.configure(servers);
|
|
271
|
+
let unavailable: Record<string, string>;
|
|
272
|
+
try {
|
|
273
|
+
unavailable = await settleCodexMcp(this.client, threadId, servers ? wire : {}, this.causes);
|
|
274
|
+
} catch (error) {
|
|
275
|
+
// A later explicit turn must reload failed clients even if config is unchanged.
|
|
276
|
+
this.fingerprint = undefined;
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
// The turn goes on without a server it does not require, and says so;
|
|
280
|
+
// a reload restarts every server of the thread, so it tried them all.
|
|
281
|
+
this.unavailable.record(unavailable, () => reloading);
|
|
282
|
+
await this.unavailable.announce(onWarning);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { AgentHarness, ModelDescriptor, ThinkingLevel } from "../../../protocol/index.ts";
|
|
2
2
|
import { isThinkingLevel } from "../../../protocol/index.ts";
|
|
3
|
+
import { onAbort } from "../../utils/deadline.ts";
|
|
3
4
|
import { knownThinkingLevels } from "../thinking-levels.ts";
|
|
4
|
-
import {
|
|
5
|
+
import { type CodexConnection, pages } from "./client.ts";
|
|
5
6
|
|
|
6
7
|
const MODEL_LIST_TIMEOUT_MS = 5_000;
|
|
7
8
|
|
|
9
|
+
/** How many pages of `model/list` are read; Codex lists a dozen models in one. */
|
|
10
|
+
const MODEL_LIST_PAGES = 10;
|
|
11
|
+
|
|
8
12
|
/** One `model/list` entry, as far as agent-server reads it. */
|
|
9
13
|
export type CodexModel = Record<string, unknown>;
|
|
10
14
|
|
|
@@ -12,6 +16,8 @@ export type CodexModel = Record<string, unknown>;
|
|
|
12
16
|
export interface CodexModelThinking {
|
|
13
17
|
levels: readonly ThinkingLevel[];
|
|
14
18
|
off?: "none" | "minimal";
|
|
19
|
+
/** The native effort the model runs when the thread sets none. */
|
|
20
|
+
defaultEffort?: string;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
/** The level a native Codex effort is: `none` and `minimal` are `off`. */
|
|
@@ -32,21 +38,16 @@ function efforts(model: CodexModel): unknown[] {
|
|
|
32
38
|
|
|
33
39
|
/** Every page of `model/list`, hidden models included. Throws when the CLI cannot answer. */
|
|
34
40
|
export async function readCodexModels(
|
|
35
|
-
client: Pick<
|
|
41
|
+
client: Pick<CodexConnection, "request">,
|
|
36
42
|
): Promise<CodexModel[]> {
|
|
37
43
|
const models: CodexModel[] = [];
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
45
|
-
if (!Array.isArray(result?.data)) throw new Error("codex model/list returned no models");
|
|
46
|
-
models.push(...(result.data as CodexModel[]));
|
|
47
|
-
cursor = typeof result.nextCursor === "string" ? result.nextCursor : undefined;
|
|
48
|
-
if (!cursor) break;
|
|
49
|
-
}
|
|
44
|
+
for await (const page of pages<CodexModel>(
|
|
45
|
+
client,
|
|
46
|
+
"model/list",
|
|
47
|
+
{ includeHidden: true },
|
|
48
|
+
{ timeoutMs: MODEL_LIST_TIMEOUT_MS, maxPages: MODEL_LIST_PAGES },
|
|
49
|
+
))
|
|
50
|
+
models.push(...page);
|
|
50
51
|
return models;
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -66,39 +67,89 @@ export function codexModelThinking(models: readonly CodexModel[]): Map<string, C
|
|
|
66
67
|
: undefined;
|
|
67
68
|
const levels = knownThinkingLevels(native.map(codexThinkingLevel));
|
|
68
69
|
if (!levels.length) continue;
|
|
70
|
+
const defaultEffort =
|
|
71
|
+
typeof model.defaultReasoningEffort === "string" ? model.defaultReasoningEffort : undefined;
|
|
69
72
|
for (const name of [model.model, model.id])
|
|
70
|
-
if (typeof name === "string")
|
|
73
|
+
if (typeof name === "string")
|
|
74
|
+
thinking.set(name, {
|
|
75
|
+
levels,
|
|
76
|
+
...(off && { off }),
|
|
77
|
+
...(defaultEffort && { defaultEffort }),
|
|
78
|
+
});
|
|
71
79
|
}
|
|
72
80
|
return thinking;
|
|
73
81
|
}
|
|
74
82
|
|
|
75
83
|
/**
|
|
76
|
-
* The
|
|
77
|
-
*
|
|
78
|
-
*
|
|
84
|
+
* The thinking levels each model the logged-in account can run accepts, from
|
|
85
|
+
* `model/list`. `undefined` when the CLI cannot answer; callers fall back to
|
|
86
|
+
* the catalog.
|
|
79
87
|
*/
|
|
80
|
-
export async function
|
|
81
|
-
client: Pick<
|
|
82
|
-
|
|
83
|
-
): Promise<string | undefined> {
|
|
88
|
+
export async function readCodexModelThinking(
|
|
89
|
+
client: Pick<CodexConnection, "request">,
|
|
90
|
+
): Promise<ReadonlyMap<string, CodexModelThinking> | undefined> {
|
|
84
91
|
try {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
| undefined;
|
|
88
|
-
return typeof result?.config?.model === "string" ? result.config.model : undefined;
|
|
92
|
+
const thinking = codexModelThinking(await readCodexModels(client));
|
|
93
|
+
return thinking.size ? thinking : undefined;
|
|
89
94
|
} catch {
|
|
95
|
+
// An older CLI, a slow answer or a closed process: the catalog decides.
|
|
90
96
|
return undefined;
|
|
91
97
|
}
|
|
92
98
|
}
|
|
93
99
|
|
|
100
|
+
/** What a new thread runs when its turns name no model or effort. */
|
|
101
|
+
export interface CodexThreadDefaults {
|
|
102
|
+
model?: string;
|
|
103
|
+
/** The configured effort; `null` when none is, so each model runs its own default. */
|
|
104
|
+
effort?: string | null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* What Codex's configuration (`~/.codex/config.toml`, a project layer)
|
|
109
|
+
* selects for a new thread in `cwd`. Throws when Codex cannot say.
|
|
110
|
+
*/
|
|
111
|
+
async function readCodexConfig(
|
|
112
|
+
client: Pick<CodexConnection, "request">,
|
|
113
|
+
cwd: string,
|
|
114
|
+
): Promise<{ model?: string; effort: string | null }> {
|
|
115
|
+
const result = (await client.request("config/read", { cwd }, MODEL_LIST_TIMEOUT_MS)) as
|
|
116
|
+
| { config?: { model?: unknown; model_reasoning_effort?: unknown } }
|
|
117
|
+
| undefined;
|
|
118
|
+
const config = result?.config;
|
|
119
|
+
if (!config) throw new Error("codex config/read returned no config");
|
|
120
|
+
return {
|
|
121
|
+
...(typeof config.model === "string" && { model: config.model }),
|
|
122
|
+
effort:
|
|
123
|
+
typeof config.model_reasoning_effort === "string" ? config.model_reasoning_effort : null,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Codex's defaults for a new thread in `cwd`: the model and effort its
|
|
129
|
+
* configuration selects, else the model `model/list` marks default. Throws
|
|
130
|
+
* when Codex cannot say.
|
|
131
|
+
*/
|
|
132
|
+
export async function readCodexThreadDefaults(
|
|
133
|
+
client: Pick<CodexConnection, "request">,
|
|
134
|
+
cwd: string,
|
|
135
|
+
): Promise<CodexThreadDefaults> {
|
|
136
|
+
const { model, effort } = await readCodexConfig(client, cwd);
|
|
137
|
+
if (model !== undefined) return { model, effort };
|
|
138
|
+
const listed = (await readCodexModels(client)).find((entry) => entry.isDefault === true);
|
|
139
|
+
return {
|
|
140
|
+
...(typeof listed?.model === "string" && { model: listed.model }),
|
|
141
|
+
effort,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
94
145
|
/**
|
|
95
146
|
* The models Codex offers in a picker, in the shared shape. Hidden models are
|
|
96
|
-
* left out. `configuredModel`
|
|
97
|
-
*
|
|
147
|
+
* left out. `configuredModel` is the default when given; otherwise Codex's
|
|
148
|
+
* own default is.
|
|
98
149
|
*/
|
|
99
150
|
export function codexModelDescriptors(
|
|
100
151
|
models: readonly CodexModel[],
|
|
101
|
-
harness: Extract<AgentHarness, "codex-
|
|
152
|
+
harness: Extract<AgentHarness, "codex-app-server">,
|
|
102
153
|
configuredModel?: string,
|
|
103
154
|
): ModelDescriptor[] {
|
|
104
155
|
return models.flatMap((model) => {
|
|
@@ -131,47 +182,49 @@ export function codexModelDescriptors(
|
|
|
131
182
|
/** What one `codex app-server` says about its models. */
|
|
132
183
|
export interface CodexModelListing {
|
|
133
184
|
models: CodexModel[];
|
|
134
|
-
/**
|
|
185
|
+
/**
|
|
186
|
+
* The model a new thread in the listing's folder runs when the turn names
|
|
187
|
+
* none, when Codex's configuration selects one. Codex's own `isDefault`
|
|
188
|
+
* ignores it.
|
|
189
|
+
*/
|
|
135
190
|
configuredModel?: string;
|
|
136
191
|
}
|
|
137
192
|
|
|
138
193
|
/** Read the models and the configured default from a running app-server. */
|
|
139
194
|
export async function readCodexListing(
|
|
140
|
-
client: Pick<
|
|
195
|
+
client: Pick<CodexConnection, "request">,
|
|
141
196
|
cwd: string,
|
|
142
197
|
): Promise<CodexModelListing> {
|
|
143
198
|
const models = await readCodexModels(client);
|
|
144
|
-
const configuredModel = await
|
|
199
|
+
const configuredModel = await readCodexConfig(client, cwd).then(
|
|
200
|
+
({ model }) => model,
|
|
201
|
+
() => undefined,
|
|
202
|
+
);
|
|
145
203
|
return { models, ...(configuredModel && { configuredModel }) };
|
|
146
204
|
}
|
|
147
205
|
|
|
148
206
|
/**
|
|
149
207
|
* Start `codex app-server` only to list its models, for the login its
|
|
150
|
-
* environment selects (or `login` performs). No thread is started
|
|
208
|
+
* environment selects (or `login` performs). No thread is started, and the
|
|
209
|
+
* process ends with the listing.
|
|
151
210
|
*/
|
|
152
211
|
export async function listCodexModels(
|
|
153
|
-
|
|
212
|
+
client: CodexConnection,
|
|
213
|
+
cwd: string,
|
|
154
214
|
{
|
|
155
215
|
signal,
|
|
156
|
-
createClient = (clientOptions) => new CodexAppServerClient(clientOptions),
|
|
157
216
|
login,
|
|
158
|
-
}: {
|
|
159
|
-
signal?: AbortSignal;
|
|
160
|
-
createClient?: (options: CodexAppServerClientOptions) => CodexAppServerClient;
|
|
161
|
-
login?: (client: CodexAppServerClient) => Promise<void>;
|
|
162
|
-
} = {},
|
|
217
|
+
}: { signal?: AbortSignal; login?: (client: CodexConnection) => Promise<void> } = {},
|
|
163
218
|
): Promise<CodexModelListing> {
|
|
164
|
-
signal
|
|
165
|
-
const client = createClient(options);
|
|
166
|
-
const stop = () => client.close();
|
|
167
|
-
signal?.addEventListener("abort", stop, { once: true });
|
|
219
|
+
const offAbort = onAbort(signal, () => client.close());
|
|
168
220
|
try {
|
|
221
|
+
signal?.throwIfAborted();
|
|
169
222
|
await client.initialize();
|
|
170
223
|
await login?.(client);
|
|
171
224
|
signal?.throwIfAborted();
|
|
172
|
-
return await readCodexListing(client,
|
|
225
|
+
return await readCodexListing(client, cwd);
|
|
173
226
|
} finally {
|
|
174
|
-
|
|
227
|
+
offAbort();
|
|
175
228
|
client.close();
|
|
176
229
|
}
|
|
177
230
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { PermissionMode } from "../../../protocol/index.ts";
|
|
2
|
+
import type { AgentExecuteOptions } from "../base.ts";
|
|
3
|
+
import { configFingerprint, directoriesFingerprint } from "../config-fingerprint.ts";
|
|
4
|
+
import type { InheritConfig } from "../inherit-config.ts";
|
|
5
|
+
import type { CodexAppServerClientOptions } from "./client.ts";
|
|
6
|
+
import type { CodexAuth } from "./credentials.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Why a turn without tools (`disableTools`) fails on Codex. With every
|
|
10
|
+
* feature that offers one turned off, Codex 0.160 still gives a code-mode
|
|
11
|
+
* model its `exec` and `wait`, `apply_patch` inside `exec`, its sub-agent
|
|
12
|
+
* tools and `request_user_input` (`.context/rehearsal/m3-tools.ts`), so the
|
|
13
|
+
* model would still act: the turn is refused instead of running tools the
|
|
14
|
+
* caller turned off.
|
|
15
|
+
*/
|
|
16
|
+
export const CODEX_TOOLS_REQUIRED =
|
|
17
|
+
"Invalid request: Codex cannot run a turn without tools (disableTools), since it gives the model its tools however it is configured. Turn tools on; permission mode plan or default keeps it from changing anything unasked.";
|
|
18
|
+
|
|
19
|
+
export function mapSandbox(mode: PermissionMode | undefined): string {
|
|
20
|
+
switch (mode) {
|
|
21
|
+
case "bypass_permissions":
|
|
22
|
+
return "danger-full-access";
|
|
23
|
+
case "accept_edits":
|
|
24
|
+
// Inside the normal sandbox — danger-full is reserved for the
|
|
25
|
+
// explicitly dangerous mode.
|
|
26
|
+
return "workspace-write";
|
|
27
|
+
default:
|
|
28
|
+
// `dont_ask` never asks, so nothing is approved: it reads, and a write,
|
|
29
|
+
// which would need an approval, is refused, as Claude denies what was
|
|
30
|
+
// not approved beforehand.
|
|
31
|
+
return "read-only";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* `default`, `accept_edits` and `plan` ask through the engine broker when one
|
|
37
|
+
* is attached; every other posture auto-decides and the sandbox enforces
|
|
38
|
+
* safety. Under `never` Codex refuses every MCP tool call that needs consent,
|
|
39
|
+
* so a posture that should run them has to ask. In `accept_edits` Codex
|
|
40
|
+
* approves edits inside its workspace-write roots by itself: the file changes
|
|
41
|
+
* it asks about are writes beyond them, which a person decides. A plan turn
|
|
42
|
+
* reads, runs what the user allows and writes nothing: the edits it asks for
|
|
43
|
+
* are declined unasked.
|
|
44
|
+
*/
|
|
45
|
+
function approvalPolicyFor(options: AgentExecuteOptions): string {
|
|
46
|
+
const mode = options.permissionMode ?? "default";
|
|
47
|
+
const asks = mode === "default" || mode === "accept_edits" || mode === "plan";
|
|
48
|
+
return asks && options.onPermissionRequest ? "on-request" : "never";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** What a Codex process runs with: a turn that asks for anything else runs in another. */
|
|
52
|
+
export interface CodexProcessIdentity {
|
|
53
|
+
cwd: string;
|
|
54
|
+
approvalPolicy: string;
|
|
55
|
+
/** The thread's sandbox: the one it started in, or the one an approved plan switched it to. */
|
|
56
|
+
sandbox: string;
|
|
57
|
+
systemPromptAppend?: string;
|
|
58
|
+
subagentMode?: "turn";
|
|
59
|
+
envFingerprint: string;
|
|
60
|
+
directoriesFingerprint: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The process a turn with these options runs in. */
|
|
64
|
+
export function processIdentity(options: AgentExecuteOptions): CodexProcessIdentity {
|
|
65
|
+
return {
|
|
66
|
+
cwd: options.cwd,
|
|
67
|
+
approvalPolicy: approvalPolicyFor(options),
|
|
68
|
+
sandbox: mapSandbox(options.permissionMode),
|
|
69
|
+
systemPromptAppend: options.systemPromptAppend,
|
|
70
|
+
subagentMode: options.subagentMode,
|
|
71
|
+
envFingerprint: configFingerprint(options.env),
|
|
72
|
+
directoriesFingerprint: directoriesFingerprint(options.additionalDirectories),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Whether a turn with these options can run in a process of `existing`'s, on its thread. */
|
|
77
|
+
export function codexSessionCompatible(
|
|
78
|
+
existing: CodexProcessIdentity & { threadId: string },
|
|
79
|
+
options: AgentExecuteOptions,
|
|
80
|
+
): boolean {
|
|
81
|
+
const wanted = processIdentity(options);
|
|
82
|
+
return (
|
|
83
|
+
existing.cwd === wanted.cwd &&
|
|
84
|
+
existing.approvalPolicy === wanted.approvalPolicy &&
|
|
85
|
+
existing.sandbox === wanted.sandbox &&
|
|
86
|
+
existing.directoriesFingerprint === wanted.directoriesFingerprint &&
|
|
87
|
+
(existing.systemPromptAppend ?? "") === (wanted.systemPromptAppend ?? "") &&
|
|
88
|
+
existing.subagentMode === wanted.subagentMode &&
|
|
89
|
+
existing.envFingerprint === wanted.envFingerprint &&
|
|
90
|
+
(!options.resumeSessionId || options.resumeSessionId === existing.threadId)
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** How the harness starts `codex app-server` for a folder, its `env` and a login. */
|
|
95
|
+
export function clientOptionsFor(
|
|
96
|
+
codexPath: string,
|
|
97
|
+
{ cwd, env }: { cwd: string; env?: Record<string, string> },
|
|
98
|
+
auth: CodexAuth | undefined,
|
|
99
|
+
experimentalApi: boolean,
|
|
100
|
+
): Omit<CodexAppServerClientOptions, "processes"> {
|
|
101
|
+
return {
|
|
102
|
+
codexPath,
|
|
103
|
+
cwd,
|
|
104
|
+
env: env ? { ...process.env, ...env } : process.env,
|
|
105
|
+
...(experimentalApi && { experimentalApi: true }),
|
|
106
|
+
...(auth && { ephemeralCredentials: true }),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** What a turn whose thread runs managed sub-agents tells the model. */
|
|
111
|
+
const MANAGED_SUBAGENTS =
|
|
112
|
+
"Collect the results of every subagent before ending your turn. Stop any worker you no longer need. Delegated work cannot continue after this task completes.";
|
|
113
|
+
|
|
114
|
+
/** The params `thread/start` and `thread/resume` take for a turn with these options. */
|
|
115
|
+
export function threadParams(
|
|
116
|
+
options: AgentExecuteOptions,
|
|
117
|
+
inheritConfig: InheritConfig = "all",
|
|
118
|
+
): Record<string, unknown> {
|
|
119
|
+
const identity = processIdentity(options);
|
|
120
|
+
// @ref LLP 0001#d14--nothing-the-agent-does-is-off-the-stream — Codex continues a goal by itself
|
|
121
|
+
// While a thread goal is active, Codex starts the next turn itself.
|
|
122
|
+
const config: Record<string, unknown> = { "features.goals": false };
|
|
123
|
+
// Extra directories become writable roots of the workspace-write sandbox;
|
|
124
|
+
// read-only reads everywhere already, full access writes too.
|
|
125
|
+
if (options.additionalDirectories?.length)
|
|
126
|
+
config["sandbox_workspace_write.writable_roots"] = [...new Set(options.additionalDirectories)];
|
|
127
|
+
if (options.subagentMode === "turn") config["features.multi_agent"] = true;
|
|
128
|
+
// @ref LLP 0001#d17--a-turn-inherits-what-the-operator-chooses-all-the-projects-or-none — the repository's AGENTS.md
|
|
129
|
+
// Codex reads every AGENTS.md from the repository's root to the working
|
|
130
|
+
// folder by itself; at `none`, none of them. The home's own still loads.
|
|
131
|
+
if (inheritConfig === "none") config.project_doc_max_bytes = 0;
|
|
132
|
+
const instructions =
|
|
133
|
+
options.subagentMode === "turn"
|
|
134
|
+
? [options.systemPromptAppend, MANAGED_SUBAGENTS].filter(Boolean).join("\n\n")
|
|
135
|
+
: options.systemPromptAppend;
|
|
136
|
+
return {
|
|
137
|
+
cwd: options.cwd,
|
|
138
|
+
sandbox: identity.sandbox,
|
|
139
|
+
approvalPolicy: identity.approvalPolicy,
|
|
140
|
+
experimentalRawEvents: false,
|
|
141
|
+
persistExtendedHistory: false,
|
|
142
|
+
...(options.model && { model: options.model }),
|
|
143
|
+
...(instructions && { developerInstructions: instructions }),
|
|
144
|
+
config,
|
|
145
|
+
};
|
|
146
|
+
}
|