@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
package/docs/consuming.md
CHANGED
|
@@ -22,7 +22,7 @@ for await (const event of turn.events) {
|
|
|
22
22
|
The reducer encodes the rules consumers get wrong first:
|
|
23
23
|
|
|
24
24
|
- **Every turn starts with your own prompt echoed back.** See below — this is
|
|
25
|
-
the rule that surprises consumers
|
|
25
|
+
the rule that surprises consumers first.
|
|
26
26
|
|
|
27
27
|
- **Upsert parts by `part.id`.** A tool part can complete AFTER its message —
|
|
28
28
|
or its turn — ended; the event's `messageId` names the original message and
|
|
@@ -31,12 +31,76 @@ The reducer encodes the rules consumers get wrong first:
|
|
|
31
31
|
- **Snapshots are authoritative; deltas are streaming sugar.** `message.part`
|
|
32
32
|
replaces whatever `message.part.delta`s built. Never append a snapshot's
|
|
33
33
|
text onto delta-accumulated text.
|
|
34
|
+
- **Deltas are live only; a streaming part is kept at its opening, its
|
|
35
|
+
changes and its end.** A delta notification carries the `seq` of the last
|
|
36
|
+
kept event, not one of its own, and is not retained. The engine keeps no
|
|
37
|
+
snapshots of a part while it streams (no checkpoints): it flushes what
|
|
38
|
+
streamed before `turn.ended`, including cancellation. History viewers see a
|
|
39
|
+
part when it opens and when it ends. A journal keeps what a part streamed,
|
|
40
|
+
a row per delta, before the delta is delivered, so a server process that
|
|
41
|
+
dies loses none of what a client was shown; a server without a journal can
|
|
42
|
+
lose it.
|
|
43
|
+
- **Joining receives the open parts.** A subscription's answer
|
|
44
|
+
(`session/subscribe`, or `turn/start`'s ack) marks a point in the
|
|
45
|
+
connection's frames; right after it come the session's open parts, each a
|
|
46
|
+
`message.part` with its content so far, sent `live: true` at the head seq.
|
|
47
|
+
Fold it like any snapshot, then the deltas after it. Tokens missed while
|
|
48
|
+
disconnected have no sequence gap, so the wire client delivers a part's
|
|
49
|
+
deltas only after a snapshot of it on the current connection, which the
|
|
50
|
+
open part a redial's subscription sends is. Custom raw-wire consumers fold
|
|
51
|
+
every `live: true` frame with `advanceLive` (`isLiveEnvelope`), never
|
|
52
|
+
`advance`; `SeqCursor` only orders retained events and cannot recover lost
|
|
53
|
+
tokens.
|
|
34
54
|
- **`turn.ended.tokens` ≠ `session.usage`.** The first is the turn's billing
|
|
35
55
|
total (sum for spend); the second is the live context-window gauge (render
|
|
36
56
|
for "how full"). Different numbers, both kept by the reducer.
|
|
37
57
|
- **Permissions resolve exactly once.** Turn end or cancel resolves pending
|
|
38
58
|
requests as `cancelled`; you will always observe a `permission.resolved`
|
|
39
59
|
before that turn's `turn.ended`.
|
|
60
|
+
- **Render the request's own options.** A plan's approval (`toolCall.kind:
|
|
61
|
+
"switch_mode"`, the plan in `toolCall.rawInput.plan`) offers the modes to go
|
|
62
|
+
on in instead of the standard four: `accept_edits`, `default`, `plan` ("keep
|
|
63
|
+
planning"). Answer with the `optionId` picked, and a `message` to say what
|
|
64
|
+
should change; a plain `allow` approves it in `default`. Each turn runs in
|
|
65
|
+
the mode it asks for: `state.permissionMode` holds the current one (the
|
|
66
|
+
turn's, then the agent's switch), so send that mode next to stay with the
|
|
67
|
+
agent.
|
|
68
|
+
- **Say why where the harness hears it.** A refused tool call's `message`
|
|
69
|
+
reaches the agent when `initialize().harnesses[h].rejectionMessages` is
|
|
70
|
+
true (Claude). Codex's refusal is a bare verdict and an ACP agent's an
|
|
71
|
+
option id: send the user's words as the next input (a steer) instead.
|
|
72
|
+
- **Check an attachment before sending it.** `harnesses[h].images` and
|
|
73
|
+
`harnesses[h].files`, the kinds of file it reads as data
|
|
74
|
+
(`fileKind(mimeType)`: `text`, `pdf`, `binary`), say what a turn may
|
|
75
|
+
carry; anything else fails the turn as `invalid_request`.
|
|
76
|
+
- **A tool its turn left running is closed for you.** At `turn.ended` the
|
|
77
|
+
reducer closes it: `cancelled` when the turn was cancelled, else `failed`
|
|
78
|
+
with a `closure` that says how: `outcome_unknown` (it may have run, its
|
|
79
|
+
effects stand), `never_ran` (its input never finished streaming, or its
|
|
80
|
+
approval was refused), or `interrupted` (agent-server stopped under it;
|
|
81
|
+
journal recovery). Match on `closure`: the `error` sentence
|
|
82
|
+
(`TOOL_OUTCOME_UNKNOWN`, `TOOL_NEVER_RAN`, `TOOL_INTERRUPTED`) is for the
|
|
83
|
+
model and the user, and a failure the harness reported has no `closure`.
|
|
84
|
+
- **The agent's questions are elicitations, not permissions.** A turn whose
|
|
85
|
+
`config.elicitation` is true may raise `elicitation.requested`: the agent's
|
|
86
|
+
own question with choices (`mode: "question"`: Claude's AskUserQuestion,
|
|
87
|
+
Codex's plan-mode questions) or an MCP server's request for input (`form`, a
|
|
88
|
+
JSON schema; `url`, a link to visit). Answer with `respondElicitation` —
|
|
89
|
+
`accept` with `content` (question id → array of answers, or the form's
|
|
90
|
+
values), `decline`, or `cancel`; `pendingElicitations(state)` lists what to
|
|
91
|
+
render. Like permissions they resolve exactly once, before `turn.ended`.
|
|
92
|
+
Without `elicitation: true` the engine declines on the user's behalf and the
|
|
93
|
+
agent carries on, so an unattended turn never waits for an answer.
|
|
94
|
+
- **A request can expire.** `config.requestTimeoutMs` bounds how long a
|
|
95
|
+
permission request or question waits: unanswered by then, it resolves as a
|
|
96
|
+
cancel would (`cancelled` / `cancel` on its `*.resolved`; a cancelled
|
|
97
|
+
permission ends a Claude turn). Absent, it waits until the turn ends.
|
|
98
|
+
|
|
99
|
+
- **Plan usage arrives as `session.limits`.** Each report carries the windows
|
|
100
|
+
that changed (`five_hour`, `seven_day`, … with `usedPercent` and
|
|
101
|
+
`resetsAt`); `state.limits` merges them by id. A recoverable `error` with
|
|
102
|
+
`retry` means the harness is waiting to try again — show it, don't fail the
|
|
103
|
+
turn.
|
|
40
104
|
|
|
41
105
|
Branch on the outcome with `isCleanStop` / `isFailureStopReason` rather than
|
|
42
106
|
your own list: `cancelled` is clean (the user asked for the stop), `error` is
|
|
@@ -52,11 +116,11 @@ Rendering needs the state; persisting needs to know what moved. Use
|
|
|
52
116
|
const { state, changes } = reduceConversationWithChanges(previous, event);
|
|
53
117
|
for (const change of changes) {
|
|
54
118
|
switch (change.kind) {
|
|
55
|
-
case "
|
|
56
|
-
case "
|
|
57
|
-
case "
|
|
58
|
-
// …
|
|
59
|
-
//
|
|
119
|
+
case "message_upserted": upsertMessageRow(state, change.messageId); break;
|
|
120
|
+
case "part_upserted": upsertPartRow(state, change.messageId, change.partId); break;
|
|
121
|
+
case "turn_updated": upsertTurnRow(state, change.turnId); break;
|
|
122
|
+
// …message_ended · delta_buffered · compaction_upserted · permission_updated · elicitation_updated
|
|
123
|
+
// usage_updated · session_meta_updated · session_ended · unknown_event_recorded
|
|
60
124
|
}
|
|
61
125
|
}
|
|
62
126
|
```
|
|
@@ -71,7 +135,7 @@ knowledge.
|
|
|
71
135
|
|
|
72
136
|
## Project the state with the shipped selectors
|
|
73
137
|
|
|
74
|
-
|
|
138
|
+
Three pure functions over `ConversationState`, so a UI does not re-derive them:
|
|
75
139
|
|
|
76
140
|
- `groupIntoTurns(state)` — turn cards: consecutive entries of the same turn
|
|
77
141
|
and the same speaker. `isLatest` is true for the FINAL group only; render
|
|
@@ -86,9 +150,6 @@ Four pure functions over `ConversationState`, so a UI does not re-derive them:
|
|
|
86
150
|
message of the last ACTIVE turn. `idle` during an active turn means
|
|
87
151
|
"between observable activities", not "finished" — combine it with your own
|
|
88
152
|
busy flag.
|
|
89
|
-
- `toolResultText(toolPart.state)` — the display fallback: completed →
|
|
90
|
-
`output`, failed → `error`, everything else → `""` (deliberately empty, not
|
|
91
|
-
invented placeholder prose).
|
|
92
153
|
|
|
93
154
|
## Track `seq` with the shared cursor
|
|
94
155
|
|
|
@@ -97,7 +158,12 @@ from a log — use `createSeqCursor()` instead of comparing numbers by hand:
|
|
|
97
158
|
|
|
98
159
|
```ts
|
|
99
160
|
const cursor = createSeqCursor();
|
|
100
|
-
|
|
161
|
+
// A live frame (a delta, an open part) carries the seq of the kept event
|
|
162
|
+
// before it; replay never returns one.
|
|
163
|
+
const verdict = isLiveEnvelope(envelope)
|
|
164
|
+
? cursor.advanceLive(envelope.sessionId, envelope.seq)
|
|
165
|
+
: cursor.advance(envelope.sessionId, envelope.seq);
|
|
166
|
+
switch (verdict) {
|
|
101
167
|
case "deliver": return fold(envelope.event);
|
|
102
168
|
case "duplicate": return; // already folded
|
|
103
169
|
case "gap": return holdAndReplay(envelope); // request events/replay
|
|
@@ -114,12 +180,12 @@ object — there is no second implementation.
|
|
|
114
180
|
Restarts themselves are not guessed from seq patterns on the wire: `initialize`
|
|
115
181
|
returns a per-process `instanceId`, the client re-handshakes on every
|
|
116
182
|
reconnect, and a changed id adopts the fresh logs outright (cursors reset,
|
|
117
|
-
sessions
|
|
118
|
-
fold envelopes without a handshake of their own.
|
|
183
|
+
sessions subscribed again from seq 0). The `reset` verdict remains for
|
|
184
|
+
consumers that fold envelopes without a handshake of their own.
|
|
119
185
|
|
|
120
186
|
## Render by role — the turn opens with the user echo
|
|
121
187
|
|
|
122
|
-
Every turn
|
|
188
|
+
Every turn begins with the submitted input echoed back as a complete user
|
|
123
189
|
message, before any harness output:
|
|
124
190
|
|
|
125
191
|
```text
|
|
@@ -134,7 +200,7 @@ turn.ended
|
|
|
134
200
|
|
|
135
201
|
Consequences, in the order they bite:
|
|
136
202
|
|
|
137
|
-
- **A consumer that renders every `message.part` as model output
|
|
203
|
+
- **A consumer that renders every `message.part` as model output prints the
|
|
138
204
|
user's own prompt.** Filter by the role of the part's message — never by
|
|
139
205
|
position. `conversationMessages(state)` gives the timeline's messages in
|
|
140
206
|
order, each with its `role`, so `messages.filter(m => m.role === "assistant")`
|
|
@@ -159,7 +225,7 @@ Consequences, in the order they bite:
|
|
|
159
225
|
approach is where file and image parts got dropped). These two are the
|
|
160
226
|
documented exception to engine-minted UUIDv7 ids — everything else on the
|
|
161
227
|
wire stays opaque, and nothing may parse structure out of an id.
|
|
162
|
-
- The stream is
|
|
228
|
+
- The stream is a complete transcript. Multi-client attach, replay and
|
|
163
229
|
persistence no longer need the client's private copy of the prompt — which
|
|
164
230
|
is the point: a second UI attaching mid-turn sees what was asked.
|
|
165
231
|
|
|
@@ -183,6 +249,142 @@ known `type`, and **store and forward what you don't understand** — a
|
|
|
183
249
|
round trip through your persistence layer must not be where a newer server's
|
|
184
250
|
data disappears. A known type with a malformed body still fails loudly.
|
|
185
251
|
|
|
252
|
+
## Install the CLIs before the first turn
|
|
253
|
+
|
|
254
|
+
A harness's first turn on a machine without its CLI downloads it, about
|
|
255
|
+
100 MB, and its stream is silent meanwhile. Install at setup and show it:
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
client.onCliProgress(({ harness, phase, receivedBytes, totalBytes }) => progressBar(harness, phase, receivedBytes, totalBytes));
|
|
259
|
+
const [claude] = await client.prepareClis(["claude-code"]);
|
|
260
|
+
if (claude?.state === "failed") showRetry(claude.error); // e.g. offline
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
`listClis()` says where each CLI is without installing (`ready`, `missing`,
|
|
264
|
+
`installing`, `failed`, `unmanaged`); every connection hears `clis/progress`,
|
|
265
|
+
whoever caused the install. `prepareClis()` waits on those, since the server
|
|
266
|
+
answers `clis/prepare` at once; its `signal` stops the waiting, not the
|
|
267
|
+
install. In-process, `runtime.prepareClis()`, `runtime.listClis()` and
|
|
268
|
+
`runtime.onCliProgress()` do the same. A product that bundles the Claude SDK
|
|
269
|
+
sets `provision.pins.claude` to its version. See
|
|
270
|
+
[Ready before the first turn](deploy.md#ready-before-the-first-turn).
|
|
271
|
+
|
|
272
|
+
## Show each harness's login, and sign it in
|
|
273
|
+
|
|
274
|
+
A settings page shows whether each harness is logged in and offers a way in.
|
|
275
|
+
The engine reads the login from the CLI and runs the CLI's own sign-in; the
|
|
276
|
+
credential lands in the CLI's store, the one a turn with the same `env` uses:
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
const [codex] = await client.authStatus({ harnesses: ["codex-app-server"] });
|
|
280
|
+
// { state: "signed_in", credential: "subscription", provider: "openai", plan: "pro", email, methods }
|
|
281
|
+
const chatgpt = codex.methods.find((method) => method.id === "chatgpt");
|
|
282
|
+
|
|
283
|
+
// Signed in on this computer already (a terminal, another app): nothing to open.
|
|
284
|
+
if (!signedInBy(codex, chatgpt)) {
|
|
285
|
+
const login = await client.login("codex-app-server", "chatgpt");
|
|
286
|
+
openBrowser(login.url); // a device code instead: show login.userCode with login.url
|
|
287
|
+
await login.done; // the login after it; rejects with a LoginError (failed, cancelled, expired)
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
A login reads the same for every harness: `label` says what to show ("Claude
|
|
292
|
+
Max", "ChatGPT Pro", "OpenAI API key"), `source` where it comes from, and
|
|
293
|
+
`email`, `organization`, `plan`, `expiresAt` who and until when.
|
|
294
|
+
|
|
295
|
+
Read the login first, as a "Sign in with ChatGPT" button should: with no
|
|
296
|
+
`env`, status is the user's own CLI login, so one they already made is picked
|
|
297
|
+
up and the button opens nothing. `signedInBy(auth, method)` says whether the
|
|
298
|
+
harness already runs on the CLI's own login of that method's `credential`
|
|
299
|
+
(`subscription`, `api_key`); a key from the environment is not one.
|
|
300
|
+
|
|
301
|
+
Each harness lists its `methods`, by `kind`:
|
|
302
|
+
|
|
303
|
+
- `browser`: the user signs in at `url` in a browser on the server's machine,
|
|
304
|
+
and the login finishes by itself. Where the login also has a `codeUrl`
|
|
305
|
+
(Claude), a browser on another device signs in there and the user pastes
|
|
306
|
+
the code the page shows: `login.complete(code)`.
|
|
307
|
+
- `device_code`: the user enters `userCode` at `url`, on any device (Codex).
|
|
308
|
+
- `api_key`: `client.login("codex-app-server", "api_key", { apiKey })`
|
|
309
|
+
stores the key in Codex's own login. Claude Code keeps no pasted key: keep
|
|
310
|
+
it yourself and send it with each turn (`config.apiKey`), or sign in with
|
|
311
|
+
`console`, whose key the CLI mints and keeps.
|
|
312
|
+
- `terminal`: a CLI login for a terminal of your own, `command` (the engine's
|
|
313
|
+
CLI, not `PATH`'s) and the `env` naming the store.
|
|
314
|
+
|
|
315
|
+
`state: "signed_in"` with `source: "environment"` means a key in the server's
|
|
316
|
+
environment wins over the login; say so. Every connection hears
|
|
317
|
+
`auth/updated` (`client.onAuthUpdated`) when a login changes, whoever changed
|
|
318
|
+
it, and a status read notices a login made in a terminal. After a change,
|
|
319
|
+
each session's next turn starts a new CLI, resuming its conversation. A turn
|
|
320
|
+
that fails for its credential ends with `error.category: "auth"`: send the
|
|
321
|
+
user to the login. A login handle that loses its connection settles at once:
|
|
322
|
+
read the status again. Status reports the
|
|
323
|
+
CLI's own login and environment: a turn that brings its own `apiKey`, or runs
|
|
324
|
+
on a credential the product holds (`credentials`), runs with that instead. In-process, `runtime.authStatus()`, `runtime.login()`,
|
|
325
|
+
`runtime.completeLogin()`, `runtime.cancelLogin()`, `runtime.logout()` and
|
|
326
|
+
`runtime.onAuthUpdated()` do the same. [`apps/login-demo`](../../../apps/login-demo)
|
|
327
|
+
is such a settings page, end to end.
|
|
328
|
+
|
|
329
|
+
## Hold the login yourself, for sandboxes and other devices
|
|
330
|
+
|
|
331
|
+
A login on the engine's machine (above) stays on that machine. To run turns
|
|
332
|
+
in cloud sandboxes, or one account on all of a person's devices, hold the
|
|
333
|
+
login in your product and let each turn ask for it (LLP 0012). Your backend
|
|
334
|
+
signs the person in with `@zvada/agent-server/accounts`, which needs only
|
|
335
|
+
`fetch` (a Worker runs it), and stores the grant:
|
|
336
|
+
|
|
337
|
+
```ts
|
|
338
|
+
import { completeClaudeLogin, pollChatGptLogin, startChatGptLogin, startClaudeLogin } from "@zvada/agent-server/accounts";
|
|
339
|
+
|
|
340
|
+
const claude = await startClaudeLogin(); // show claude.url; the page shows a code
|
|
341
|
+
const grant = await completeClaudeLogin(claude, pastedCode); // a one-year token: store `grant`
|
|
342
|
+
|
|
343
|
+
const chatgpt = await startChatGptLogin(); // show chatgpt.userCode at chatgpt.verificationUrl
|
|
344
|
+
const codexGrant = await pollChatGptLogin(chatgpt); // every intervalMs until it is not undefined
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
`pastedGrant(harness, credential)` checks a pasted API key or a
|
|
348
|
+
`claude setup-token` token first. Mount the endpoint your engines ask before
|
|
349
|
+
each turn over your store; `credentialsFrom` answers each request with the
|
|
350
|
+
grant's credential, renewing a ChatGPT grant first when it is about to expire
|
|
351
|
+
or the harness refused it (one renewal at a time, deciding on the grant as
|
|
352
|
+
read inside it), and writes the renewal back:
|
|
353
|
+
|
|
354
|
+
```ts
|
|
355
|
+
import { createCredentialHandler, credentialsFrom } from "@zvada/agent-server/accounts";
|
|
356
|
+
|
|
357
|
+
export const credentials = createCredentialHandler({
|
|
358
|
+
authorize: (request) => sandboxOwner(request.headers.get("authorization")), // undefined: 401
|
|
359
|
+
resolve: credentialsFrom({
|
|
360
|
+
read: (request, user) => db.grantFor(user, request.harness, request.turnId), // who pays for this turn
|
|
361
|
+
write: (grant, request, user) => db.saveGrant(user, grant), // compare a revision across processes
|
|
362
|
+
}),
|
|
363
|
+
});
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Show a login you hold with the same view as a CLI's own: `grantAuth(grant)`
|
|
367
|
+
answers a `HarnessAuth` (`source: "product"`, its `label` and expiry), never
|
|
368
|
+
the secret.
|
|
369
|
+
|
|
370
|
+
A grant that is not there answers none: that turn runs on the engine's own
|
|
371
|
+
CLI login. A Claude Code turn runs on an `api_key` (with a `baseUrl` for a
|
|
372
|
+
gateway) or an `oauth_token`, a Codex turn on an `api_key` to OpenAI or a
|
|
373
|
+
`chatgpt` token; a credential its harness cannot run fails the turn before it
|
|
374
|
+
starts.
|
|
375
|
+
|
|
376
|
+
Start each sandbox's engine with `agent-server --credentials-url
|
|
377
|
+
https://you/agent-credentials` and the token that `authorize` takes in
|
|
378
|
+
`$AGENT_SERVER_CREDENTIALS_TOKEN`; in-process, `createAgentRuntime({
|
|
379
|
+
credentials: credentialsFromUrl({url, token}) })`, or any
|
|
380
|
+
`CredentialSource` of your own, which gets the same `CredentialRequest` an
|
|
381
|
+
endpoint does. Claude runs through the engine's own proxy, so the CLI and its
|
|
382
|
+
tools hold only a placeholder; the credential is held there while a turn
|
|
383
|
+
runs, and a token the API refuses is asked for again and the request retried.
|
|
384
|
+
Codex holds ChatGPT tokens in memory, never a refresh token. A refusal
|
|
385
|
+
reaches your source as `rejectedSha256`, the token's digest (`tokenDigest`). [`apps/login-demo`](../../../apps/login-demo)'s
|
|
386
|
+
"Held by the product" mode is all of this, with a sandbox.
|
|
387
|
+
|
|
186
388
|
## Offer models and show what ran
|
|
187
389
|
|
|
188
390
|
Fill a model picker from the harness's own list rather than a hard-coded one:
|
|
@@ -204,8 +406,12 @@ the model ran at (`ultra` on a model whose top is `max` shows `max`), and
|
|
|
204
406
|
`reportedModels` the models the harness reported (Claude's API model, Codex's
|
|
205
407
|
thread model). Show those, not the requested `model` and `thinkingLevel`,
|
|
206
408
|
when they are present. Both are absent when a turn failed before its model
|
|
207
|
-
answered.
|
|
208
|
-
|
|
409
|
+
answered. Each assistant `message.started` names its own `model` the same
|
|
410
|
+
way: the API model that wrote it on Claude (a plan turn can mix two, and a
|
|
411
|
+
sub-agent's message names the sub-agent's), the thread's model on Codex (the
|
|
412
|
+
model it rerouted to, after a reroute), and the requested `model` only where
|
|
413
|
+
a harness names none. List models with the `cwd` (and credentials) your turns use: an alias
|
|
414
|
+
such as `opus` is fitted only from its own login's list.
|
|
209
415
|
|
|
210
416
|
## Persist for resume
|
|
211
417
|
|
|
@@ -231,6 +437,45 @@ A successful Claude resume can mint a new native ID; use the reported `resumed`
|
|
|
231
437
|
flag rather than comparing Claude IDs. The `resumed: false` wire value remains
|
|
232
438
|
readable for older engines and custom harnesses.
|
|
233
439
|
|
|
440
|
+
## Steer a running turn
|
|
441
|
+
|
|
442
|
+
A user who types while the agent works means "and also…" or "stop, do this
|
|
443
|
+
instead". Send it into the running turn rather than queueing a new one:
|
|
444
|
+
|
|
445
|
+
```ts
|
|
446
|
+
const handle = await client.runTurn({ sessionId, input, config });
|
|
447
|
+
// …the user types while it runs:
|
|
448
|
+
const result = await handle.steer("Use the staging database instead", steerId);
|
|
449
|
+
// or: client.steerTurn({ sessionId, turnId: handle.turnId, steerId, input })
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
- **`steered`**: the harness accepted it. The agent reads it at its next step
|
|
453
|
+
(after the tool it is running, or as one more query when it was already
|
|
454
|
+
answering), and the stream shows it there as a user message whose ids derive
|
|
455
|
+
from the steer id: `steerMessageId(steerId)`, parts `steerPartId(steerId, i)`.
|
|
456
|
+
Show a pending bubble under that id outside the folded state (an overlay):
|
|
457
|
+
folding your own `message.started` for it would make the reducer keep your
|
|
458
|
+
bubble's position and ignore the real one, which lands where the agent read
|
|
459
|
+
the steer.
|
|
460
|
+
- **Delivered means echoed.** A steer reached the agent exactly when its user
|
|
461
|
+
message appears in the turn. A turn that ends first lists it in
|
|
462
|
+
`turn.ended.undeliveredSteers`, and it never runs later: a cancel drops
|
|
463
|
+
unread steers; for a turn that ended normally, send the text as a new turn.
|
|
464
|
+
A turn a durable server lost to a crash lists nothing it never journaled, so
|
|
465
|
+
go by the echo.
|
|
466
|
+
- **`no_active_turn`**: the turn is not taking input (it ended, is ending, or
|
|
467
|
+
another turn runs, see `activeTurnId`). Send the input as a new turn.
|
|
468
|
+
- **`unsupported`**: this harness cannot steer
|
|
469
|
+
(`initialize().harnesses[h].steering`; ACP agents cannot).
|
|
470
|
+
|
|
471
|
+
A turn takes steers from the moment `turn/start` acks. A steer id, like a turn
|
|
472
|
+
id, is unique in its session (mint a UUIDv7): a retry with the same `steerId`
|
|
473
|
+
and input converges (`deduplicated: true`), even after the turn ended; the
|
|
474
|
+
same id with other input, or in another turn, is `turnConflict`. Inside the
|
|
475
|
+
turn, a later user message (`outputIndex > 0`) is always a steer, so a steered
|
|
476
|
+
turn has several user and assistant groups under one `turnId`: render by role
|
|
477
|
+
and order, never one card per (turn, role).
|
|
478
|
+
|
|
234
479
|
## Retry safely
|
|
235
480
|
|
|
236
481
|
Turn admission is idempotent on `{sessionId, turnId}`: mint the `turnId`
|
|
@@ -261,6 +506,11 @@ interrupt; `unconfirmed` means it did not land — including the window between
|
|
|
261
506
|
the `turn/start` quick-ack and the harness registering its abortable turn —
|
|
262
507
|
and the agent may still be running. On `unconfirmed`, report "stopping…" and
|
|
263
508
|
treat `turn.ended` as the source of truth, not the cancel response.
|
|
509
|
+
`cancelled` also covers what the turn started: Codex keeps a command running
|
|
510
|
+
after an interrupt, so the engine stops the turn's commands and checks before
|
|
511
|
+
the turn ends. A command whose stop could not be confirmed is not closed as
|
|
512
|
+
cancelled: its tool part fails with `TOOL_OUTCOME_UNKNOWN`, a failure the
|
|
513
|
+
harness reports itself (no `closure`).
|
|
264
514
|
|
|
265
515
|
Embedded `runtime.cancel(harness, sessionId)` cancels the session's active
|
|
266
516
|
turn without a turn ID check. Prefer a per-turn `AbortSignal` when cancellation
|
|
@@ -275,9 +525,9 @@ seq monotonicity — then folds it twice: once to assert the reducer's final
|
|
|
275
525
|
state agrees with the authoritative snapshots, and once with every upsert
|
|
276
526
|
delivered TWICE to assert re-delivery changes nothing (the property a replay
|
|
277
527
|
overlap or a reconnect resync depends on). Run it in CI over recorded fixtures
|
|
278
|
-
and in staging over
|
|
279
|
-
|
|
280
|
-
|
|
528
|
+
and in staging over the events of live turns, failing on any violation; a
|
|
529
|
+
product pipeline (a Durable Object, a persistence shim) can run it on replay to
|
|
530
|
+
fail loudly instead of storing a corrupt projection.
|
|
281
531
|
|
|
282
532
|
It takes **one session's** stream, of any length: `session.created` is expected
|
|
283
533
|
once per turn (not once per stream), deltas that trail the last snapshot of a
|
|
@@ -285,6 +535,52 @@ cancelled turn are legal (a snapshot is a prefix of the fold, not a ceiling),
|
|
|
285
535
|
and unknown event/part types are forward-compat rather than violations. Pass
|
|
286
536
|
`{expectEcho: false}` for a partial capture that begins mid-turn.
|
|
287
537
|
|
|
538
|
+
## Choose what a turn inherits
|
|
539
|
+
|
|
540
|
+
A Claude or Codex turn loads configuration by itself when it starts, from the
|
|
541
|
+
host user and from the repository: settings, MCP servers, hooks, instructions
|
|
542
|
+
and memory. `createAgentRuntime({ inheritConfig })`, and the bin's and the
|
|
543
|
+
CLI's `--inherit-config`, choose how much (LLP 0001, D17):
|
|
544
|
+
|
|
545
|
+
| Level | Claude Code | Codex app-server |
|
|
546
|
+
| --- | --- | --- |
|
|
547
|
+
| `all` (default) | every settings source (user, project, local) and the auto-memory Claude keeps for the repository, as the CLI itself does | the turn's `env.CODEX_HOME`, else the process's: the user's `~/.codex` |
|
|
548
|
+
| `project` | the repository's settings, hooks, `.mcp.json` servers and instruction files; nothing of the user's, no auto-memory, no claude.ai connectors | the repository's `AGENTS.md` and skills, in a home of the session's own |
|
|
549
|
+
| `none` | only the servers the host and the turn name | as `project`, without the repository's `AGENTS.md` |
|
|
550
|
+
|
|
551
|
+
Choose by whose machine and whose repository it is. A desktop product that
|
|
552
|
+
works in its user's own repositories can stay at `all`, or take `project` to
|
|
553
|
+
keep the user's personal settings and memory out of its turns. A cloud
|
|
554
|
+
sandbox, a test, an eval or CI takes `project` for a repository you trust and
|
|
555
|
+
`none` for any other.
|
|
556
|
+
|
|
557
|
+
The level never changes where the agent may read or run: the permission mode,
|
|
558
|
+
Codex's sandbox and your `toolPolicy` decide that. But `all` and `project`
|
|
559
|
+
load the repository's configuration, and an SDK session never asks to trust a
|
|
560
|
+
folder: the repository's hooks and `.mcp.json` servers run at session start
|
|
561
|
+
as the server's user, a PreToolUse hook can approve a tool call your policy
|
|
562
|
+
and the broker never see, and one `env` line can send the turn's API traffic,
|
|
563
|
+
with its API key or subscription token, elsewhere. Give a repository you do
|
|
564
|
+
not trust `none`, and keep real API keys out of the agent's environment: the
|
|
565
|
+
`./core/proxy` building block hands the agent a placeholder key and swaps in
|
|
566
|
+
the real one.
|
|
567
|
+
|
|
568
|
+
At `project` and `none` every Codex turn needs `config.env.CODEX_HOME`, an
|
|
569
|
+
existing absolute folder of the session's own: never the user's `~/.codex`,
|
|
570
|
+
never another session's. A turn without one fails `invalid_request` before
|
|
571
|
+
Codex starts. The engine owns that home's `mcp_servers` table, as for
|
|
572
|
+
per-turn MCP below. A fresh home has no login: hand one over with
|
|
573
|
+
[`credentials`](harnesses.md#host-managed-codex-authentication) or the turn's
|
|
574
|
+
`apiKey`. Codex loads the repository's skills and
|
|
575
|
+
`~/.agents/skills` at every level; turn one off by name in the home you
|
|
576
|
+
supply (`[[skills.config]]` with `enabled = false`).
|
|
577
|
+
|
|
578
|
+
On Claude a `disableTools` turn runs at `none` whatever the level.
|
|
579
|
+
`claudeCode.sdkOptions` can still name `settingSources` (and
|
|
580
|
+
`strictMcpConfig`) itself, and wins over the level's; the level still decides
|
|
581
|
+
auto-memory and the connectors. An ACP agent loads what its launch command
|
|
582
|
+
says.
|
|
583
|
+
|
|
288
584
|
## Own your session resources
|
|
289
585
|
|
|
290
586
|
### Configure MCP between turns
|
|
@@ -296,7 +592,20 @@ applied through the harness's native configuration API before the prompt;
|
|
|
296
592
|
finishing a turn does not restart the agent or its servers. Omitting the map
|
|
297
593
|
on a later turn removes the previous wire-configured set, just like `{}`.
|
|
298
594
|
Claude's host `sdkMcpServers` remain attached. The native CLI may also load MCP servers
|
|
299
|
-
from settings or plugins
|
|
595
|
+
from settings or plugins (Claude not at `inheritConfig: "none"`); this map is
|
|
596
|
+
not an exclusive tool allowlist.
|
|
597
|
+
|
|
598
|
+
Each server is one the turn needs unless it says `required: false`. A turn
|
|
599
|
+
fails before the model runs when a server it needs cannot connect: the error is
|
|
600
|
+
`mcp_unavailable`, names each server and why, and says how to drop it. A
|
|
601
|
+
server that is not required and cannot connect is said as a recoverable
|
|
602
|
+
`error` of the same category (no `retry`), and the turn goes on without its
|
|
603
|
+
tools. A later turn tries it again once 30 s have passed (`MCP_RETRY_MS`),
|
|
604
|
+
and at once when its configuration changes or a turn requires it. The
|
|
605
|
+
flag is the engine's: Claude and Codex never see it. An ACP agent connects
|
|
606
|
+
its servers itself and decides. The repository's CLI gives turns the servers
|
|
607
|
+
a user adds as not required, as Claude Code treats them;
|
|
608
|
+
`/mcp <name> required` makes turns need one.
|
|
300
609
|
|
|
301
610
|
The engine snapshots the supplied wire configuration, including headers,
|
|
302
611
|
before asynchronous setup. Credential rotation therefore works even if the
|
|
@@ -308,15 +617,22 @@ expiry; ending a turn does not itself revoke an attached credential.
|
|
|
308
617
|
|
|
309
618
|
Codex supports stdio and Streamable HTTP servers; legacy SSE is rejected. Its
|
|
310
619
|
per-turn MCP configuration requires an existing, absolute, session-specific
|
|
311
|
-
`config.env.CODEX_HOME` directory
|
|
620
|
+
`config.env.CODEX_HOME` directory (below `inheritConfig: "all"` every Codex
|
|
621
|
+
turn does). Create it with mode `0700`, retain it while
|
|
312
622
|
the conversation may resume, and delete it when that logical session is
|
|
313
623
|
released. It contains conversation history and MCP credentials. Never share
|
|
314
|
-
it between sessions or use the operator's normal Codex home.
|
|
315
|
-
|
|
624
|
+
it between sessions or use the operator's normal Codex home.
|
|
625
|
+
|
|
626
|
+
This isolates writable MCP configuration and conversation state; it does not
|
|
627
|
+
require a separate ChatGPT login for each home. An embedding host can supply
|
|
628
|
+
access credentials through [`credentials`](harnesses.md#host-managed-codex-authentication)
|
|
629
|
+
while retaining login and token renewal in its own account manager.
|
|
316
630
|
|
|
317
631
|
The repository's interactive CLI accepts `--codex-home=/absolute/private/path`
|
|
318
|
-
and remembers the path for `--continue`; the operator supplies
|
|
319
|
-
|
|
632
|
+
and remembers the path for `--continue`; the operator supplies the existing home.
|
|
633
|
+
Standalone CLI use relies on native authentication in that home. `--connect`
|
|
634
|
+
can use an embedded server's external authentication instead.
|
|
635
|
+
The ACP **server binding** (`createAcpAgentApp` /
|
|
320
636
|
`agent-server --acp --harness codex-app-server`) has no per-session environment
|
|
321
637
|
resource seam in this release. It rejects supplied Codex MCP servers explicitly
|
|
322
638
|
at `session/new` or `session/resume`. Use the engine or standard JSON-RPC API
|
|
@@ -334,8 +650,12 @@ is reserved.
|
|
|
334
650
|
Codex writes changed configuration without reloading, verifies its effective
|
|
335
651
|
settings, then reloads MCP and checks readiness before submitting the prompt.
|
|
336
652
|
Servers still starting are awaited through native startup notifications, with
|
|
337
|
-
a bounded deadline;
|
|
338
|
-
|
|
653
|
+
a bounded deadline (30 seconds); a required server that failed fails
|
|
654
|
+
preparation at once, with the cause Codex gave.
|
|
655
|
+
Unchanged configuration is checked without reloading, and readiness is read
|
|
656
|
+
for each requested server by name on the turn's thread, which answers from
|
|
657
|
+
the thread's connection: Codex connects to a server once per process, not on
|
|
658
|
+
every turn. A failed setup fails
|
|
339
659
|
the turn; an explicitly submitted next turn reapplies the configuration so a
|
|
340
660
|
previously failed native client can reconnect. No model turn or tool call is
|
|
341
661
|
automatically replayed.
|
|
@@ -362,8 +682,9 @@ are unaffected. Other harnesses without this lifecycle hook are unaffected.
|
|
|
362
682
|
Claude MCP updates also repair a transient socket setup failure once. Recovery
|
|
363
683
|
removes and re-adds the affected connection: an identical SDK update can cache
|
|
364
684
|
a failed client, and the SDK's reconnect-by-name command can restore startup
|
|
365
|
-
credentials.
|
|
366
|
-
turn before prompt submission. Tool calls and model turns
|
|
685
|
+
credentials. A required server's persistent connection failure or invalid
|
|
686
|
+
credentials fail the turn before prompt submission. Tool calls and model turns
|
|
687
|
+
are never replayed.
|
|
367
688
|
|
|
368
689
|
### Release a session
|
|
369
690
|
|
|
@@ -381,7 +702,7 @@ completion before starting another turn on that ID. Await shutdown before
|
|
|
381
702
|
disposing the runtime. Cancellation acknowledgement alone does not mean the
|
|
382
703
|
old execution has finished cleaning up.
|
|
383
704
|
|
|
384
|
-
`session/close` also broadcasts `session.ended {reason: "
|
|
705
|
+
`session/close` also broadcasts `session.ended {reason: "closed"}` — but
|
|
385
706
|
only to subscribers **connected at that moment**, because the replay log is
|
|
386
707
|
retired in the same operation. A subscriber that was detached does not get the
|
|
387
708
|
event later: its `events/replay` answers `unknownSession`, and that answer *is*
|
|
@@ -399,12 +720,79 @@ product that doesn't surface them debugs blind.
|
|
|
399
720
|
|
|
400
721
|
`spawn` (stdio subprocess), `connect` (dial a `--listen` server; reconnects
|
|
401
722
|
and replays by default), `attach` (an accepted socket, e.g. the server dialed
|
|
402
|
-
OUT to you via `--dial`).
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
723
|
+
OUT to you via `--dial`). In one process, `channelPair()` (root and
|
|
724
|
+
`/protocol`) is the wire between them: `server.attach(pair.server)`, then
|
|
725
|
+
`AgentServerClient.attach(pair.client)`; `kill()` drops it at both ends.
|
|
726
|
+
|
|
727
|
+
A connection receives the sessions it subscribes to, not every session on
|
|
728
|
+
the server, in two ways. A turn's subscription: `runTurn` and `startTurn`
|
|
729
|
+
subscribe the client to their turn from the head at admission (the ack's
|
|
730
|
+
`headSeq`) until the turn's `turn.ended`, so a turn in a session with
|
|
731
|
+
history downloads none of it, and `runTurn`'s handle starts at its own
|
|
732
|
+
`turn.started`. A watch: `subscribe(sessionId, {afterSeq})` follows a session
|
|
733
|
+
from `afterSeq` (its kept events after it reach `onEvent` first, then its
|
|
734
|
+
open parts, then its frames live; omitted, from the head) until
|
|
735
|
+
`unsubscribe`, which ends the watch (a turn of this client's there is still
|
|
736
|
+
followed to its end); `subscribeAll()` is for observers: every session, live
|
|
737
|
+
from then, with no history (`session/subscribeAll` on the wire; `unsubscribeAll()`
|
|
738
|
+
is `session/unsubscribeAll`). `joinTurn(sessionId, {fromSeq})` watches the
|
|
739
|
+
session and joins the turn it runs (`undefined` when none): a handle that
|
|
740
|
+
yields the kept events from `fromSeq` (default: the turn's start), then the
|
|
741
|
+
turn's open parts, then live frames through its `turn.ended`, each once,
|
|
742
|
+
however many handles join; its `catchUp` says how many of its first events
|
|
743
|
+
were replayed. `runTurn(params, {signal})` and `joinTurn(sessionId,
|
|
744
|
+
{signal})` stop following when the signal aborts: the handle's `events` and
|
|
745
|
+
`result` fail with an `AbortError`, the turn runs on (`cancelTurn` stops it),
|
|
746
|
+
and `onEvent` still hears it to its end. `steerTurn` follows the turn it
|
|
747
|
+
steers in a session the client does not follow, so the steer's user message
|
|
748
|
+
reaches it.
|
|
749
|
+
|
|
750
|
+
`onEvent` delivers a session's events while the client watches it or one of
|
|
751
|
+
its turns runs in it (`AgentServer.onEvent`, in process, still sees every
|
|
752
|
+
session): a session whose turn ended, and that it does not watch, is let go,
|
|
753
|
+
with what the client kept of it. A redial subscribes again to each session
|
|
754
|
+
followed, from what the client holds, the running turns' first, and so does a
|
|
755
|
+
`session/overflow`: the notice a server sends when the connection fell
|
|
756
|
+
`maxBacklogBytes` (16 MiB) behind and it stopped streaming the session; what
|
|
757
|
+
was dropped heals by replay and the open parts. A refused re-subscription
|
|
758
|
+
fails the session's turns with `EventGapError` (`onEventGap`:
|
|
759
|
+
`session_missing`, or `subscription_refused`) instead of leaving them
|
|
760
|
+
waiting. When the answer says the turn it subscribed again for runs no more
|
|
761
|
+
(it ended while the client was away), the client replays up to the answer's
|
|
762
|
+
`headSeq`, the turn's end with it unless the window evicted it, and lets the
|
|
763
|
+
session go unless it watches it. A connection may watch at most `maxSubscriptions` sessions (256;
|
|
764
|
+
`subscribeAll` counts once), past which `subscribe` is refused
|
|
765
|
+
`subscriptionLimit`: unsubscribe what you no longer watch. A turn's
|
|
766
|
+
subscription never counts and ends with the turn, so a backend that runs
|
|
767
|
+
every session's turns over one connection is never refused a turn, and
|
|
768
|
+
follows only the sessions whose turns run and those it watches.
|
|
769
|
+
|
|
770
|
+
The client dedupes by per-session `seq` and heals gaps via `events/replay`;
|
|
771
|
+
an unfillable gap raises `EventGapError` instead of silently losing events.
|
|
772
|
+
`replay(sessionId, fromSeq)` is one page of a session's kept events;
|
|
773
|
+
`replayAll(sessionId, fromSeq, throughSeq?)` reads every page through
|
|
774
|
+
`throughSeq` (default: the last), failing `EventGapError` when some were
|
|
775
|
+
evicted.
|
|
776
|
+
When using `startTurn` with `onEvent`, subscribe to `onEventGap` before
|
|
777
|
+
starting work. It runs synchronously before any surviving suffix and returns
|
|
778
|
+
an unsubscribe function. `runTurn().result` continues to reject on these same
|
|
779
|
+
gaps.
|
|
780
|
+
|
|
781
|
+
`onConnection` says what the connection does, so a product can show an
|
|
782
|
+
outage instead of going quiet: `disconnected` (with the reason), `reconnecting`
|
|
783
|
+
before each redial (`attempt`, `delayMs`, and the `error` the one before
|
|
784
|
+
failed with), `reconnected` (`attempts`, `downMs`, the new `initialize`, and
|
|
785
|
+
`serverChanged` when the server no longer holds the logs this client followed:
|
|
786
|
+
another journal, none, or a volatile restart), `refused` (`reason`:
|
|
787
|
+
`token_refused` or `token_required`) when the server refused a redial, which every
|
|
788
|
+
redial would get, so the client stops and fails what waits with
|
|
789
|
+
`ConnectionRefusedError`, and `closed` (`close()`, a connection that does not
|
|
790
|
+
redial, redialing that gave up after `maxReconnectAttempts`, default 8,
|
|
791
|
+
`Infinity` redials until `close()`, or a refusal).
|
|
792
|
+
Handlers run before requests waiting on the redial are sent again. After
|
|
793
|
+
`serverChanged`, a turn under a session id the old server knew starts a new
|
|
794
|
+
history there: name its native conversation (`config.resumeSessionId`) to
|
|
795
|
+
continue it.
|
|
408
796
|
|
|
409
797
|
A gap describes incomplete delivery, not a successful stop. Keep the affected
|
|
410
798
|
turn's output marked incomplete even if its native terminal says `end_turn`.
|
|
@@ -413,19 +801,37 @@ turn's output marked incomplete even if its native terminal says `end_turn`.
|
|
|
413
801
|
`cancelTurn(sessionId, turnId)` to reconcile execution. Never cancel a successor
|
|
414
802
|
by reading its ID after an asynchronous recovery operation.
|
|
415
803
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
804
|
+
Localhost is not a trusted channel against browsers: any page the user
|
|
805
|
+
visits may open a WebSocket to `127.0.0.1` (CORS does not apply to
|
|
806
|
+
WebSockets) and run a turn there, tools and `bypass_permissions` included.
|
|
807
|
+
So a listener answers native clients only (LLP 0001, D16). An upgrade that
|
|
808
|
+
carries an `Origin` header, which a browser always sends and Bun's and
|
|
809
|
+
Node's WebSocket never do, is refused 403 unless that origin is allowed
|
|
810
|
+
(`--allow-origin`, `ListenOptions.allowedOrigins`): exactly
|
|
811
|
+
`scheme://host[:port]` as the browser sends it, never `null` or a wildcard.
|
|
812
|
+
A product whose browser, Electron or Tauri renderer connects directly allows
|
|
813
|
+
its own origin, on a loopback listener without a token, since a browser
|
|
814
|
+
cannot send one. A token (`--token-file <path>` or `$AGENT_SERVER_TOKEN`;
|
|
815
|
+
`ListenOptions.token`) makes every upgrade carry `Authorization: Bearer
|
|
816
|
+
<token>` or be refused 401, and a listener beyond loopback will not start
|
|
817
|
+
without one: `AgentServerClient.connect(url, {token})` sends it with every
|
|
818
|
+
dial and redial. A server that refuses the client fails `connect` with
|
|
819
|
+
`ConnectionRefusedError` (a `ConnectionClosedError`; `reason`
|
|
820
|
+
`token_refused` for a token it sent, `token_required` for none), and is not
|
|
821
|
+
redialed: since a WebSocket does not say why its handshake failed, the client
|
|
822
|
+
asks once with a plain request carrying the same headers, and only a 401
|
|
823
|
+
answer is a refusal. A 403 is not (`listen` sends it only for an `Origin`,
|
|
824
|
+
which a native client never sends): it comes from something in front of the
|
|
825
|
+
server, a proxy, and the client redials on. The token
|
|
826
|
+
authenticates the connection, not a user, and the wire has no TLS of its own:
|
|
827
|
+
put a `wss://` proxy in front of a listener other machines reach. stdio
|
|
828
|
+
inherits its spawner's trust, and `dial` connects out (`dial(server, url,
|
|
829
|
+
{headers})` sends a credential in a header, not the URL; the bin's `--dial`
|
|
830
|
+
sends `$AGENT_SERVER_DIAL_TOKEN` so, the credential it presents to the
|
|
831
|
+
platform it dials, never `$AGENT_SERVER_TOKEN`, which a listener's clients
|
|
832
|
+
present).
|
|
833
|
+
Subscriptions filter delivery; they are not an authorization boundary.
|
|
834
|
+
|
|
835
|
+
---
|
|
836
|
+
|
|
837
|
+
Something here wrong, unclear or missing? [Report it to the maintainers](feedback.md).
|