@zvada/agent-server 0.3.18 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +11 -26
- package/CHANGELOG.md +1041 -1
- package/README.md +40 -40
- package/dist/types/accounts/chatgpt.d.ts +34 -0
- package/dist/types/accounts/chatgpt.d.ts.map +1 -0
- package/dist/types/accounts/check.d.ts +24 -0
- package/dist/types/accounts/check.d.ts.map +1 -0
- package/dist/types/accounts/claude.d.ts +21 -0
- package/dist/types/accounts/claude.d.ts.map +1 -0
- package/dist/types/accounts/endpoint.d.ts +50 -0
- package/dist/types/accounts/endpoint.d.ts.map +1 -0
- package/dist/types/accounts/http.d.ts +38 -0
- package/dist/types/accounts/http.d.ts.map +1 -0
- package/dist/types/accounts/index.d.ts +6 -0
- package/dist/types/accounts/index.d.ts.map +1 -0
- package/dist/types/client/client.d.ts +272 -0
- package/dist/types/client/client.d.ts.map +1 -0
- package/dist/types/client/connection.d.ts +160 -0
- package/dist/types/client/connection.d.ts.map +1 -0
- package/dist/types/client/history.d.ts +8 -0
- package/dist/types/client/history.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +5 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/listeners.d.ts +8 -0
- package/dist/types/client/listeners.d.ts.map +1 -0
- package/dist/types/client/logins.d.ts +35 -0
- package/dist/types/client/logins.d.ts.map +1 -0
- package/dist/types/client/rpc.d.ts +46 -0
- package/dist/types/client/rpc.d.ts.map +1 -0
- package/dist/types/client/streams.d.ts +150 -0
- package/dist/types/client/streams.d.ts.map +1 -0
- package/dist/types/client/transports.d.ts +35 -0
- package/dist/types/client/transports.d.ts.map +1 -0
- package/dist/types/client/turns.d.ts +81 -0
- package/dist/types/client/turns.d.ts.map +1 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts +68 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -0
- package/dist/types/core/agents/acp/adapter.d.ts +39 -0
- package/dist/types/core/agents/acp/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/acp/client.d.ts +90 -0
- package/dist/types/core/agents/acp/client.d.ts.map +1 -0
- package/dist/types/core/agents/acp/known-agents.d.ts +35 -0
- package/dist/types/core/agents/acp/known-agents.d.ts.map +1 -0
- package/dist/types/core/agents/acp/mappings.d.ts +46 -0
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -0
- package/dist/types/core/agents/acp/requests.d.ts +26 -0
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -0
- package/dist/types/core/agents/attachments.d.ts +11 -0
- package/dist/types/core/agents/attachments.d.ts.map +1 -0
- package/dist/types/core/agents/base.d.ts +227 -0
- package/dist/types/core/agents/base.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts +58 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts +26 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +70 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts +54 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/events.d.ts +42 -0
- package/dist/types/core/agents/claude-code/events.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/login.d.ts +61 -0
- package/dist/types/core/agents/claude-code/login.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts +52 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/models.d.ts +30 -0
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/options.d.ts +183 -0
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts +50 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts +36 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session.d.ts +148 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts +29 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spend.d.ts +58 -0
- package/dist/types/core/agents/claude-code/spend.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/tools.d.ts +4 -0
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts +52 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn.d.ts +121 -0
- package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts +59 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts +116 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +113 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts +66 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts +49 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts +12 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts +45 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts +20 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts +26 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts +31 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts +38 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +62 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts +67 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts +40 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts +19 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts +99 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts +42 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts +96 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts +53 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts +87 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts +33 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts +163 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts.map +1 -0
- package/dist/types/core/agents/config-fingerprint.d.ts +5 -0
- package/dist/types/core/agents/config-fingerprint.d.ts.map +1 -0
- package/dist/types/core/agents/credentials.d.ts +28 -0
- package/dist/types/core/agents/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/elicitation.d.ts +37 -0
- package/dist/types/core/agents/elicitation.d.ts.map +1 -0
- package/dist/types/core/agents/inherit-config.d.ts +18 -0
- package/dist/types/core/agents/inherit-config.d.ts.map +1 -0
- package/dist/types/core/agents/login.d.ts +67 -0
- package/dist/types/core/agents/login.d.ts.map +1 -0
- package/dist/types/core/agents/mcp-config.d.ts +57 -0
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -0
- package/dist/types/core/agents/plan.d.ts +16 -0
- package/dist/types/core/agents/plan.d.ts.map +1 -0
- package/dist/types/core/agents/registry.d.ts +30 -0
- package/dist/types/core/agents/registry.d.ts.map +1 -0
- package/dist/types/core/agents/session-agent.d.ts +48 -0
- package/dist/types/core/agents/session-agent.d.ts.map +1 -0
- package/dist/types/core/agents/session-pool.d.ts +41 -0
- package/dist/types/core/agents/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/stderr-tail.d.ts +28 -0
- package/dist/types/core/agents/stderr-tail.d.ts.map +1 -0
- package/dist/types/core/agents/thinking-levels.d.ts +4 -0
- package/dist/types/core/agents/thinking-levels.d.ts.map +1 -0
- package/dist/types/core/agents/types.d.ts +124 -0
- package/dist/types/core/agents/types.d.ts.map +1 -0
- package/dist/types/core/diagnostics.d.ts +36 -0
- package/dist/types/core/diagnostics.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +29 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/presets.d.ts +80 -0
- package/dist/types/core/presets.d.ts.map +1 -0
- package/dist/types/core/processes/identity.d.ts +31 -0
- package/dist/types/core/processes/identity.d.ts.map +1 -0
- package/dist/types/core/processes/lifeline.d.ts +47 -0
- package/dist/types/core/processes/lifeline.d.ts.map +1 -0
- package/dist/types/core/processes/native-processes.d.ts +130 -0
- package/dist/types/core/processes/native-processes.d.ts.map +1 -0
- package/dist/types/core/processes/process-table.d.ts +43 -0
- package/dist/types/core/processes/process-table.d.ts.map +1 -0
- package/dist/types/core/provision/cache-trust.d.ts +13 -0
- package/dist/types/core/provision/cache-trust.d.ts.map +1 -0
- package/dist/types/core/provision/cache-usage.d.ts +14 -0
- package/dist/types/core/provision/cache-usage.d.ts.map +1 -0
- package/dist/types/core/provision/checksums.d.ts +46 -0
- package/dist/types/core/provision/checksums.d.ts.map +1 -0
- package/dist/types/core/provision/extract.d.ts +7 -0
- package/dist/types/core/provision/extract.d.ts.map +1 -0
- package/dist/types/core/provision/index.d.ts +5 -0
- package/dist/types/core/provision/index.d.ts.map +1 -0
- package/dist/types/core/provision/install-build.d.ts +36 -0
- package/dist/types/core/provision/install-build.d.ts.map +1 -0
- package/dist/types/core/provision/npm.d.ts +40 -0
- package/dist/types/core/provision/npm.d.ts.map +1 -0
- package/dist/types/core/provision/pins.d.ts +24 -0
- package/dist/types/core/provision/pins.d.ts.map +1 -0
- package/dist/types/core/provision/platform.d.ts +28 -0
- package/dist/types/core/provision/platform.d.ts.map +1 -0
- package/dist/types/core/provision/provisioner.d.ts +189 -0
- package/dist/types/core/provision/provisioner.d.ts.map +1 -0
- package/dist/types/core/provision/releases.d.ts +8 -0
- package/dist/types/core/provision/releases.d.ts.map +1 -0
- package/dist/types/core/provision/tools.d.ts +81 -0
- package/dist/types/core/provision/tools.d.ts.map +1 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts +52 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts.map +1 -0
- package/dist/types/core/proxy/api-key-store.d.ts +37 -0
- package/dist/types/core/proxy/api-key-store.d.ts.map +1 -0
- package/dist/types/core/proxy/index.d.ts +3 -0
- package/dist/types/core/proxy/index.d.ts.map +1 -0
- package/dist/types/core/proxy/loopback.d.ts +14 -0
- package/dist/types/core/proxy/loopback.d.ts.map +1 -0
- package/dist/types/core/runtime/agent-runtime.d.ts +181 -0
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -0
- package/dist/types/core/runtime/event-processor.d.ts +87 -0
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -0
- package/dist/types/core/runtime/event-sink.d.ts +44 -0
- package/dist/types/core/runtime/event-sink.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-clis.d.ts +10 -0
- package/dist/types/core/runtime/harness-clis.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-logins.d.ts +68 -0
- package/dist/types/core/runtime/harness-logins.d.ts.map +1 -0
- package/dist/types/core/runtime/login-reads.d.ts +28 -0
- package/dist/types/core/runtime/login-reads.d.ts.map +1 -0
- package/dist/types/core/runtime/model-lists.d.ts +37 -0
- package/dist/types/core/runtime/model-lists.d.ts.map +1 -0
- package/dist/types/core/runtime/permission-policy.d.ts +61 -0
- package/dist/types/core/runtime/permission-policy.d.ts.map +1 -0
- package/dist/types/core/runtime/request-broker.d.ts +49 -0
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -0
- package/dist/types/core/runtime/steering.d.ts +38 -0
- package/dist/types/core/runtime/steering.d.ts.map +1 -0
- package/dist/types/core/runtime/turn-outcome.d.ts +21 -0
- package/dist/types/core/runtime/turn-outcome.d.ts.map +1 -0
- package/dist/types/core/runtime/turn.d.ts +121 -0
- package/dist/types/core/runtime/turn.d.ts.map +1 -0
- package/dist/types/core/utils/bounded.d.ts +6 -0
- package/dist/types/core/utils/bounded.d.ts.map +1 -0
- package/dist/types/core/utils/deadline.d.ts +14 -0
- package/dist/types/core/utils/deadline.d.ts.map +1 -0
- package/dist/types/core/utils/errors.d.ts +104 -0
- package/dist/types/core/utils/errors.d.ts.map +1 -0
- package/dist/types/core/utils/is-record.d.ts +3 -0
- package/dist/types/core/utils/is-record.d.ts.map +1 -0
- package/dist/types/core/utils/loopback.d.ts +6 -0
- package/dist/types/core/utils/loopback.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/protocol/account.d.ts +26 -0
- package/dist/types/protocol/account.d.ts.map +1 -0
- package/dist/types/protocol/async-queue.d.ts +21 -0
- package/dist/types/protocol/async-queue.d.ts.map +1 -0
- package/dist/types/protocol/auth.d.ts +228 -0
- package/dist/types/protocol/auth.d.ts.map +1 -0
- package/dist/types/protocol/canonical.d.ts +9 -0
- package/dist/types/protocol/canonical.d.ts.map +1 -0
- package/dist/types/protocol/clis.d.ts +74 -0
- package/dist/types/protocol/clis.d.ts.map +1 -0
- package/dist/types/protocol/config.d.ts +200 -0
- package/dist/types/protocol/config.d.ts.map +1 -0
- package/dist/types/protocol/conversation.d.ts +942 -0
- package/dist/types/protocol/conversation.d.ts.map +1 -0
- package/dist/types/protocol/credentials.d.ts +145 -0
- package/dist/types/protocol/credentials.d.ts.map +1 -0
- package/dist/types/protocol/errors.d.ts +36 -0
- package/dist/types/protocol/errors.d.ts.map +1 -0
- package/dist/types/protocol/execution.d.ts +28 -0
- package/dist/types/protocol/execution.d.ts.map +1 -0
- package/dist/types/protocol/factories.d.ts +94 -0
- package/dist/types/protocol/factories.d.ts.map +1 -0
- package/dist/types/protocol/guards.d.ts +55 -0
- package/dist/types/protocol/guards.d.ts.map +1 -0
- package/dist/types/protocol/harness.d.ts +70 -0
- package/dist/types/protocol/harness.d.ts.map +1 -0
- package/dist/types/protocol/history.d.ts +318 -0
- package/dist/types/protocol/history.d.ts.map +1 -0
- package/dist/types/protocol/ids.d.ts +9 -0
- package/dist/types/protocol/ids.d.ts.map +1 -0
- package/dist/types/protocol/index.d.ts +35 -0
- package/dist/types/protocol/index.d.ts.map +1 -0
- package/dist/types/protocol/lifecycle.d.ts +1190 -0
- package/dist/types/protocol/lifecycle.d.ts.map +1 -0
- package/dist/types/protocol/meta-keys.d.ts +17 -0
- package/dist/types/protocol/meta-keys.d.ts.map +1 -0
- package/dist/types/protocol/meta.d.ts +13 -0
- package/dist/types/protocol/meta.d.ts.map +1 -0
- package/dist/types/protocol/model-catalog.d.ts +11 -0
- package/dist/types/protocol/model-catalog.d.ts.map +1 -0
- package/dist/types/protocol/models.d.ts +107 -0
- package/dist/types/protocol/models.d.ts.map +1 -0
- package/dist/types/protocol/part-input.d.ts +101 -0
- package/dist/types/protocol/part-input.d.ts.map +1 -0
- package/dist/types/protocol/parts.d.ts +357 -0
- package/dist/types/protocol/parts.d.ts.map +1 -0
- package/dist/types/protocol/reduce.d.ts +26 -0
- package/dist/types/protocol/reduce.d.ts.map +1 -0
- package/dist/types/protocol/selectors.d.ts +64 -0
- package/dist/types/protocol/selectors.d.ts.map +1 -0
- package/dist/types/protocol/seq-cursor.d.ts +66 -0
- package/dist/types/protocol/seq-cursor.d.ts.map +1 -0
- package/dist/types/protocol/stop-reasons.d.ts +33 -0
- package/dist/types/protocol/stop-reasons.d.ts.map +1 -0
- package/dist/types/protocol/thinking.d.ts +28 -0
- package/dist/types/protocol/thinking.d.ts.map +1 -0
- package/dist/types/protocol/time.d.ts +21 -0
- package/dist/types/protocol/time.d.ts.map +1 -0
- package/dist/types/protocol/tokens.d.ts +29 -0
- package/dist/types/protocol/tokens.d.ts.map +1 -0
- package/dist/types/protocol/tool-closure.d.ts +25 -0
- package/dist/types/protocol/tool-closure.d.ts.map +1 -0
- package/dist/types/protocol/tool-state.d.ts +209 -0
- package/dist/types/protocol/tool-state.d.ts.map +1 -0
- package/dist/types/protocol/verify.d.ts +52 -0
- package/dist/types/protocol/verify.d.ts.map +1 -0
- package/dist/types/protocol/vocabulary.d.ts +19 -0
- package/dist/types/protocol/vocabulary.d.ts.map +1 -0
- package/dist/types/protocol/wire-api.d.ts +1983 -0
- package/dist/types/protocol/wire-api.d.ts.map +1 -0
- package/dist/types/protocol/wire.d.ts +1758 -0
- package/dist/types/protocol/wire.d.ts.map +1 -0
- package/dist/types/server/acp/binding.d.ts +33 -0
- package/dist/types/server/acp/binding.d.ts.map +1 -0
- package/dist/types/server/acp/session-records.d.ts +17 -0
- package/dist/types/server/acp/session-records.d.ts.map +1 -0
- package/dist/types/server/acp/translate.d.ts +48 -0
- package/dist/types/server/acp/translate.d.ts.map +1 -0
- package/dist/types/server/agent-server.d.ts +121 -0
- package/dist/types/server/agent-server.d.ts.map +1 -0
- package/dist/types/server/feedback.d.ts +37 -0
- package/dist/types/server/feedback.d.ts.map +1 -0
- package/dist/types/server/history.d.ts +15 -0
- package/dist/types/server/history.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +7 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/types/server/install.d.ts +42 -0
- package/dist/types/server/install.d.ts.map +1 -0
- package/dist/types/server/open-parts.d.ts +27 -0
- package/dist/types/server/open-parts.d.ts.map +1 -0
- package/dist/types/server/routes.d.ts +61 -0
- package/dist/types/server/routes.d.ts.map +1 -0
- package/dist/types/server/secrets.d.ts +11 -0
- package/dist/types/server/secrets.d.ts.map +1 -0
- package/dist/types/server/session-gate.d.ts +32 -0
- package/dist/types/server/session-gate.d.ts.map +1 -0
- package/dist/types/server/session-log.d.ts +39 -0
- package/dist/types/server/session-log.d.ts.map +1 -0
- package/dist/types/server/session-store.d.ts +119 -0
- package/dist/types/server/session-store.d.ts.map +1 -0
- package/dist/types/server/subscriptions.d.ts +74 -0
- package/dist/types/server/subscriptions.d.ts.map +1 -0
- package/dist/types/server/transports.d.ts +74 -0
- package/dist/types/server/transports.d.ts.map +1 -0
- package/dist/types/server/wire-error.d.ts +9 -0
- package/dist/types/server/wire-error.d.ts.map +1 -0
- package/dist/types/sync/event-log.d.ts +45 -0
- package/dist/types/sync/event-log.d.ts.map +1 -0
- package/dist/types/sync/fit.d.ts +40 -0
- package/dist/types/sync/fit.d.ts.map +1 -0
- package/dist/types/sync/history-reader.d.ts +8 -0
- package/dist/types/sync/history-reader.d.ts.map +1 -0
- package/dist/types/sync/history-sqlite.d.ts +37 -0
- package/dist/types/sync/history-sqlite.d.ts.map +1 -0
- package/dist/types/sync/history.d.ts +70 -0
- package/dist/types/sync/history.d.ts.map +1 -0
- package/dist/types/sync/index.d.ts +4 -0
- package/dist/types/sync/index.d.ts.map +1 -0
- package/dist/types/sync/journal-sqlite.d.ts +51 -0
- package/dist/types/sync/journal-sqlite.d.ts.map +1 -0
- package/dist/types/sync/journal.d.ts +107 -0
- package/dist/types/sync/journal.d.ts.map +1 -0
- package/dist/types/sync/live-tails.d.ts +30 -0
- package/dist/types/sync/live-tails.d.ts.map +1 -0
- package/dist/types/sync/node-sqlite.d.ts +7 -0
- package/dist/types/sync/node-sqlite.d.ts.map +1 -0
- package/dist/types/sync/projection.d.ts +10 -0
- package/dist/types/sync/projection.d.ts.map +1 -0
- package/dist/types/sync/recovery.d.ts +25 -0
- package/dist/types/sync/recovery.d.ts.map +1 -0
- package/dist/types/sync/retry.d.ts +25 -0
- package/dist/types/sync/retry.d.ts.map +1 -0
- package/dist/types/sync/schema.d.ts +4 -0
- package/dist/types/sync/schema.d.ts.map +1 -0
- package/dist/types/sync/sql.d.ts +38 -0
- package/dist/types/sync/sql.d.ts.map +1 -0
- package/dist/types/sync/sqlite-file.d.ts +9 -0
- package/dist/types/sync/sqlite-file.d.ts.map +1 -0
- package/dist/types/sync/sqlite.d.ts +6 -0
- package/dist/types/sync/sqlite.d.ts.map +1 -0
- package/dist/types/sync/worker.d.ts +63 -0
- package/dist/types/sync/worker.d.ts.map +1 -0
- package/docs/consuming.md +452 -53
- package/docs/deploy.md +218 -47
- package/docs/{sync-experiment.md → durable-sessions.md} +77 -72
- package/docs/feedback.md +116 -0
- package/docs/harnesses.md +212 -88
- package/docs/sync-history.md +29 -13
- package/docs/sync-integration.md +52 -66
- package/package.json +45 -28
- package/src/accounts/chatgpt.ts +194 -0
- package/src/accounts/check.ts +112 -0
- package/src/accounts/claude.ts +111 -0
- package/src/accounts/endpoint.ts +151 -0
- package/src/accounts/http.ts +97 -0
- package/src/accounts/index.ts +19 -0
- package/src/client/client.ts +604 -670
- package/src/client/connection.ts +371 -0
- package/src/client/history.ts +29 -52
- package/src/client/index.ts +11 -2
- package/src/client/listeners.ts +20 -0
- package/src/client/logins.ts +105 -0
- package/src/client/rpc.ts +155 -0
- package/src/client/streams.ts +488 -0
- package/src/client/transports.ts +62 -8
- package/src/client/turns.ts +171 -0
- package/src/core/agents/acp/acp-agent.ts +94 -118
- package/src/core/agents/acp/adapter.ts +20 -9
- package/src/core/agents/acp/client.ts +125 -47
- package/src/core/agents/acp/known-agents.ts +36 -4
- package/src/core/agents/acp/mappings.ts +64 -18
- package/src/core/agents/acp/requests.ts +125 -0
- package/src/core/agents/attachments.ts +18 -0
- package/src/core/agents/base.ts +120 -42
- package/src/core/agents/claude-code/adapter.ts +177 -238
- package/src/core/agents/claude-code/approvals.ts +270 -0
- package/src/core/agents/claude-code/claude-agent.ts +175 -158
- package/src/core/agents/claude-code/credentials.ts +171 -0
- package/src/core/agents/claude-code/events.ts +55 -0
- package/src/core/agents/claude-code/login.ts +269 -0
- package/src/core/agents/claude-code/mcp.ts +206 -0
- package/src/core/agents/claude-code/models.ts +15 -9
- package/src/core/agents/claude-code/options.ts +326 -39
- package/src/core/agents/claude-code/outcome.ts +209 -0
- package/src/core/agents/claude-code/session-pool.ts +136 -0
- package/src/core/agents/claude-code/session.ts +513 -0
- package/src/core/agents/claude-code/spawn.ts +144 -0
- package/src/core/agents/claude-code/spend.ts +160 -0
- package/src/core/agents/claude-code/tools.ts +47 -0
- package/src/core/agents/claude-code/turn-usage.ts +135 -0
- package/src/core/agents/claude-code/turn.ts +232 -0
- package/src/core/agents/codex-app-server/adapter.ts +314 -117
- package/src/core/agents/codex-app-server/client.ts +186 -84
- package/src/core/agents/codex-app-server/codex-agent.ts +343 -0
- package/src/core/agents/codex-app-server/commands.ts +228 -0
- package/src/core/agents/codex-app-server/credentials.ts +126 -0
- package/src/core/agents/codex-app-server/effort.ts +29 -0
- package/src/core/agents/codex-app-server/events.ts +47 -0
- package/src/core/agents/codex-app-server/homes.ts +64 -0
- package/src/core/agents/codex-app-server/input.ts +60 -0
- package/src/core/agents/codex-app-server/items.ts +149 -0
- package/src/core/agents/codex-app-server/login.ts +180 -0
- package/src/core/agents/codex-app-server/mcp.ts +182 -37
- package/src/core/agents/codex-app-server/models.ts +99 -46
- package/src/core/agents/codex-app-server/options.ts +146 -0
- package/src/core/agents/codex-app-server/plan-approval.ts +135 -0
- package/src/core/agents/codex-app-server/protocol.ts +117 -0
- package/src/core/agents/codex-app-server/requests.ts +332 -0
- package/src/core/agents/codex-app-server/session.ts +285 -0
- package/src/core/agents/codex-app-server/subagents.ts +108 -42
- package/src/core/agents/codex-app-server/thread-settings.ts +279 -0
- package/src/core/agents/codex-app-server/turn-items.ts +88 -0
- package/src/core/agents/codex-app-server/turn.ts +463 -0
- package/src/core/agents/config-fingerprint.ts +7 -14
- package/src/core/agents/credentials.ts +98 -0
- package/src/core/agents/elicitation.ts +75 -0
- package/src/core/agents/inherit-config.ts +21 -0
- package/src/core/agents/login.ts +116 -0
- package/src/core/agents/mcp-config.ts +112 -8
- package/src/core/agents/plan.ts +25 -0
- package/src/core/agents/registry.ts +21 -4
- package/src/core/agents/session-agent.ts +96 -4
- package/src/core/agents/{session-store.ts → session-pool.ts} +11 -5
- package/src/core/agents/stderr-tail.ts +75 -0
- package/src/core/agents/types.ts +40 -5
- package/src/core/index.ts +58 -48
- package/src/core/presets.ts +100 -39
- package/src/core/processes/identity.ts +113 -0
- package/src/core/processes/lifeline.ts +170 -0
- package/src/core/processes/native-processes.ts +379 -0
- package/src/core/processes/process-table.ts +174 -0
- package/src/core/provision/cache-trust.ts +121 -0
- package/src/core/provision/cache-usage.ts +69 -0
- package/src/core/provision/checksums.ts +64 -0
- package/src/core/provision/extract.ts +11 -2
- package/src/core/provision/index.ts +4 -1
- package/src/core/provision/install-build.ts +136 -0
- package/src/core/provision/npm.ts +112 -17
- package/src/core/provision/pins.ts +9 -33
- package/src/core/provision/platform.ts +12 -1
- package/src/core/provision/provisioner.ts +329 -397
- package/src/core/provision/releases.ts +86 -0
- package/src/core/provision/tools.ts +329 -0
- package/src/core/proxy/anthropic-proxy.ts +55 -25
- package/src/core/proxy/api-key-store.ts +2 -12
- package/src/core/proxy/loopback.ts +106 -0
- package/src/core/runtime/agent-runtime.ts +327 -498
- package/src/core/runtime/event-processor.ts +197 -70
- package/src/core/runtime/harness-clis.ts +61 -0
- package/src/core/runtime/harness-logins.ts +328 -0
- package/src/core/runtime/login-reads.ts +78 -0
- package/src/core/runtime/model-lists.ts +33 -48
- package/src/core/runtime/permission-policy.ts +113 -0
- package/src/core/runtime/request-broker.ts +204 -0
- package/src/core/runtime/steering.ts +112 -0
- package/src/core/runtime/turn-outcome.ts +30 -0
- package/src/core/runtime/turn.ts +360 -0
- package/src/core/utils/bounded.ts +12 -0
- package/src/core/utils/deadline.ts +38 -0
- package/src/core/utils/errors.ts +113 -21
- package/src/core/utils/is-record.ts +4 -0
- package/src/core/utils/loopback.ts +10 -0
- package/src/protocol/account.ts +104 -0
- package/src/protocol/auth.ts +199 -0
- package/src/protocol/canonical.ts +16 -0
- package/src/protocol/clis.ts +69 -0
- package/src/protocol/config.ts +60 -6
- package/src/protocol/conversation.ts +272 -0
- package/src/protocol/credentials.ts +145 -0
- package/src/protocol/errors.ts +78 -20
- package/src/protocol/execution.ts +5 -2
- package/src/protocol/factories.ts +55 -7
- package/src/protocol/guards.ts +55 -2
- package/src/protocol/harness.ts +56 -6
- package/src/protocol/history.ts +72 -64
- package/src/protocol/ids.ts +0 -12
- package/src/protocol/index.ts +9 -0
- package/src/protocol/lifecycle.ts +250 -79
- package/src/protocol/meta-keys.ts +17 -0
- package/src/protocol/meta.ts +3 -3
- package/src/protocol/models.ts +2 -43
- package/src/protocol/part-input.ts +2 -1
- package/src/protocol/parts.ts +12 -3
- package/src/protocol/reduce.ts +302 -413
- package/src/protocol/selectors.ts +1 -20
- package/src/protocol/seq-cursor.ts +14 -0
- package/src/protocol/stop-reasons.ts +1 -1
- package/src/protocol/thinking.ts +1 -30
- package/src/protocol/time.ts +2 -2
- package/src/protocol/tool-closure.ts +93 -0
- package/src/protocol/tool-state.ts +19 -4
- package/src/protocol/verify.ts +222 -92
- package/src/protocol/vocabulary.ts +21 -5
- package/src/protocol/wire-api.ts +232 -0
- package/src/protocol/wire.ts +351 -64
- package/src/server/acp/binding.ts +63 -103
- package/src/server/acp/session-records.ts +53 -0
- package/src/server/acp/translate.ts +129 -20
- package/src/server/agent-server.ts +223 -387
- package/src/server/bin.ts +280 -78
- package/src/server/feedback.ts +204 -14
- package/src/server/history.ts +116 -122
- package/src/server/index.ts +3 -8
- package/src/server/install.ts +107 -8
- package/src/server/open-parts.ts +95 -0
- package/src/server/routes.ts +391 -0
- package/src/server/secrets.ts +24 -0
- package/src/server/session-gate.ts +69 -0
- package/src/server/session-log.ts +14 -2
- package/src/server/session-store.ts +136 -72
- package/src/server/subscriptions.ts +232 -0
- package/src/server/transports.ts +125 -25
- package/src/server/wire-error.ts +31 -45
- package/src/sync/event-log.ts +31 -3
- package/src/sync/fit.ts +27 -11
- package/src/sync/history-reader.ts +10 -5
- package/src/sync/history-sqlite.ts +37 -42
- package/src/sync/history.ts +9 -15
- package/src/sync/index.ts +17 -5
- package/src/sync/journal-sqlite.ts +162 -76
- package/src/sync/journal.ts +91 -32
- package/src/sync/live-tails.ts +107 -0
- package/src/sync/projection.ts +35 -0
- package/src/sync/recovery.ts +80 -51
- package/src/sync/schema.ts +27 -6
- package/docs/rfds/0001-deterministic-echo-ids.md +0 -44
- package/docs/rfds/0002-native-subagents.md +0 -197
- package/src/client/request.ts +0 -19
- package/src/core/agents/claude-code/generator-session.ts +0 -572
- package/src/core/agents/claude-code/session-manager.ts +0 -166
- package/src/core/agents/codex-app-server/codex-app-server-agent.ts +0 -962
- package/src/core/agents/codex-items.ts +0 -149
- package/src/core/agents/codex-sdk/adapter.ts +0 -237
- package/src/core/agents/codex-sdk/codex-sdk-agent.ts +0 -330
- package/src/core/agents/tool-meta.ts +0 -68
package/src/protocol/wire.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { RunConfigSchema } from "./config.ts";
|
|
|
3
3
|
import { AgentCapabilitiesSchema, AgentHarnessSchema } from "./harness.ts";
|
|
4
4
|
import {
|
|
5
5
|
type DecodedLifecycleEvent,
|
|
6
|
+
ElicitationOutcomeSchema,
|
|
6
7
|
LifecycleEventSchema,
|
|
7
8
|
PermissionOutcomeSchema,
|
|
8
9
|
TurnEndedEventSchema,
|
|
@@ -13,14 +14,35 @@ import { ModelListSchema } from "./models.ts";
|
|
|
13
14
|
import { AgentInputSchema } from "./part-input.ts";
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
* The standard wire
|
|
17
|
+
* The standard wire: JSON-RPC 2.0 over a newline-delimited JSON
|
|
17
18
|
* stream (stdio, WebSocket, or any duplex byte channel). Requests flow
|
|
18
19
|
* client -> server only; the server pushes `event` notifications. Turns are
|
|
19
20
|
* quick-ack: `turn/start` acknowledges immediately and completion is observed
|
|
20
21
|
* via the `turn.ended` lifecycle event, mirroring the engine's event-driven
|
|
21
22
|
* model (and ACP v2's prompt lifecycle).
|
|
23
|
+
*
|
|
24
|
+
* Version 3: a `message.part.delta` is no longer sequenced. It carries the
|
|
25
|
+
* `seq` of the session's last kept event, and replay and history never return
|
|
26
|
+
* it (see `MessagePartDeltaEventSchema`).
|
|
27
|
+
*
|
|
28
|
+
* Version 4: one vocabulary — snake_case values (`in_session`), `history/read`,
|
|
29
|
+
* `unknownTurn`.
|
|
30
|
+
*
|
|
31
|
+
* Version 5: a connection receives the sessions it subscribes to
|
|
32
|
+
* (`session/subscribe`; `turn/start` subscribes its caller), and a frame the
|
|
33
|
+
* server does not keep says so (`live: true`): token deltas, and the open
|
|
34
|
+
* parts that follow a subscription. The engine no longer checkpoints a
|
|
35
|
+
* streaming part. A peer of another version is refused at `initialize`, never
|
|
36
|
+
* half served by values it cannot read.
|
|
37
|
+
*
|
|
38
|
+
* Version 6: a connection watches a session (`session/subscribe {sessionId}`)
|
|
39
|
+
* or follows one of its running turns (`turn/start`, `session/subscribe
|
|
40
|
+
* {sessionId, turnId}`), and a turn's subscription ends with the turn.
|
|
41
|
+
* `session/subscribe` takes no `afterSeq`: a client catches up with
|
|
42
|
+
* `events/replay`. Every session is `session/subscribeAll` and
|
|
43
|
+
* `session/unsubscribeAll`, each with its own answer, not `{all: true}`.
|
|
22
44
|
*/
|
|
23
|
-
export const WIRE_PROTOCOL_VERSION =
|
|
45
|
+
export const WIRE_PROTOCOL_VERSION = 6;
|
|
24
46
|
|
|
25
47
|
// ---- JSON-RPC 2.0 envelopes --------------------------------------------------
|
|
26
48
|
|
|
@@ -53,14 +75,18 @@ export const WIRE_ERROR_CODES = {
|
|
|
53
75
|
protocolVersionMismatch: -32004,
|
|
54
76
|
/** A session/close for this session is still in flight; retry after it settles. */
|
|
55
77
|
sessionClosing: -32005,
|
|
56
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* A turn with this turnId already ran (or is running) with DIFFERENT input,
|
|
80
|
+
* or a steerId was reused with different input or in another turn.
|
|
81
|
+
*/
|
|
57
82
|
turnConflict: -32006,
|
|
58
83
|
/** A durable session was closed; its id is not reused. */
|
|
59
84
|
sessionClosed: -32007,
|
|
60
85
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* with `data.headSeq`)
|
|
86
|
+
* A server restart cut off the session's last turn and could not confirm
|
|
87
|
+
* its native process stopped (`data.reason`, a `RecoveryReason`). Check it
|
|
88
|
+
* stopped, then confirm (`session/confirmStopped` with `data.headSeq`)
|
|
89
|
+
* before starting another turn.
|
|
64
90
|
*/
|
|
65
91
|
recoveryRequired: -32008,
|
|
66
92
|
/**
|
|
@@ -74,7 +100,43 @@ export const WIRE_ERROR_CODES = {
|
|
|
74
100
|
unknownHistory: -32011,
|
|
75
101
|
/** The request contradicts committed history (payload, hash, expected head or commit id). */
|
|
76
102
|
historyConflict: -32012,
|
|
103
|
+
/** The session is known, but no turn with this turnId was admitted to it. */
|
|
104
|
+
unknownTurn: -32013,
|
|
105
|
+
/** The connection watches `maxSubscriptions` sessions already (`data.limit`): unsubscribe one first. */
|
|
106
|
+
subscriptionLimit: -32014,
|
|
107
|
+
/** No login under way has this loginId: it ended, expired, was cancelled or never started. */
|
|
108
|
+
unknownLogin: -32015,
|
|
77
109
|
} as const;
|
|
110
|
+
export type WireErrorName = keyof typeof WIRE_ERROR_CODES;
|
|
111
|
+
const WIRE_ERROR_NAMES = new Map(
|
|
112
|
+
Object.entries(WIRE_ERROR_CODES).map(([name, code]) => [code as number, name as WireErrorName]),
|
|
113
|
+
);
|
|
114
|
+
/** Whether a name is one of `WIRE_ERROR_CODES`'. */
|
|
115
|
+
export function isWireErrorName(name: string): name is WireErrorName {
|
|
116
|
+
return Object.hasOwn(WIRE_ERROR_CODES, name);
|
|
117
|
+
}
|
|
118
|
+
/** The name `WIRE_ERROR_CODES` gives an error response's code, if it is one of them. */
|
|
119
|
+
export function wireErrorName(code: number): WireErrorName | undefined {
|
|
120
|
+
return WIRE_ERROR_NAMES.get(code);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* A refusal: a request this side will not carry out, answered with the wire
|
|
125
|
+
* error it names — as opposed to a fault, which answers `internalError`. The
|
|
126
|
+
* history port's and the journal's refusals are refusals of this kind, so a
|
|
127
|
+
* caller in-process and one over the wire see the same code.
|
|
128
|
+
*/
|
|
129
|
+
export class WireRefusal<Code extends WireErrorName = WireErrorName, Data = unknown> extends Error {
|
|
130
|
+
override readonly name: string = "WireRefusal";
|
|
131
|
+
constructor(
|
|
132
|
+
readonly code: Code,
|
|
133
|
+
message: string,
|
|
134
|
+
/** What the caller needs to act on the refusal, e.g. the `headSeq` to confirm. */
|
|
135
|
+
readonly data?: Data,
|
|
136
|
+
) {
|
|
137
|
+
super(message);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
78
140
|
|
|
79
141
|
// ---- methods -----------------------------------------------------------------
|
|
80
142
|
|
|
@@ -82,19 +144,38 @@ export const WIRE_METHODS = {
|
|
|
82
144
|
initialize: "initialize",
|
|
83
145
|
turnStart: "turn/start",
|
|
84
146
|
turnCancel: "turn/cancel",
|
|
147
|
+
turnSteer: "turn/steer",
|
|
85
148
|
sessionClose: "session/close",
|
|
86
149
|
permissionRespond: "permission/respond",
|
|
150
|
+
elicitationRespond: "elicitation/respond",
|
|
87
151
|
eventsReplay: "events/replay",
|
|
88
152
|
modelsList: "models/list",
|
|
153
|
+
clisList: "clis/list",
|
|
154
|
+
clisPrepare: "clis/prepare",
|
|
155
|
+
authStatus: "auth/status",
|
|
156
|
+
authLogin: "auth/login",
|
|
157
|
+
authComplete: "auth/complete",
|
|
158
|
+
authCancel: "auth/cancel",
|
|
159
|
+
authLogout: "auth/logout",
|
|
89
160
|
/** Durable servers only (`historyId` in `initialize`); others answer methodNotFound. */
|
|
90
161
|
turnGet: "turn/get",
|
|
91
162
|
sessionGet: "session/get",
|
|
92
163
|
sessionConfirmStopped: "session/confirmStopped",
|
|
164
|
+
sessionRelease: "session/release",
|
|
165
|
+
sessionSubscribe: "session/subscribe",
|
|
166
|
+
sessionUnsubscribe: "session/unsubscribe",
|
|
167
|
+
sessionSubscribeAll: "session/subscribeAll",
|
|
168
|
+
sessionUnsubscribeAll: "session/unsubscribeAll",
|
|
93
169
|
shutdown: "shutdown",
|
|
94
170
|
/** Server -> client notification carrying one sequenced lifecycle event. */
|
|
95
171
|
event: "event",
|
|
172
|
+
/** Server -> client notification: a subscription the server dropped because the connection fell behind. */
|
|
173
|
+
sessionOverflow: "session/overflow",
|
|
174
|
+
/** Server -> client notification: a harness's CLI being installed. */
|
|
175
|
+
clisProgress: "clis/progress",
|
|
176
|
+
/** Server -> client notification: a harness's login changed, or a login ended. */
|
|
177
|
+
authUpdated: "auth/updated",
|
|
96
178
|
} as const;
|
|
97
|
-
export type WireMethod = (typeof WIRE_METHODS)[keyof typeof WIRE_METHODS];
|
|
98
179
|
|
|
99
180
|
export const WireImplementationInfoSchema = z.object({
|
|
100
181
|
name: z.string(),
|
|
@@ -141,6 +222,13 @@ export const TurnStartParamsSchema = z.object({
|
|
|
141
222
|
turnId: z.string().min(1).optional(),
|
|
142
223
|
input: AgentInputSchema,
|
|
143
224
|
config: RunConfigSchema,
|
|
225
|
+
/**
|
|
226
|
+
* Stream the session to the caller from the head at admission until the
|
|
227
|
+
* turn ends, as `session/subscribe {sessionId, turnId}` does. Default true;
|
|
228
|
+
* a deduplicated start of a running turn subscribes too, a refused one
|
|
229
|
+
* changes nothing.
|
|
230
|
+
*/
|
|
231
|
+
subscribe: z.boolean().optional(),
|
|
144
232
|
});
|
|
145
233
|
export type TurnStartParams = z.infer<typeof TurnStartParamsSchema>;
|
|
146
234
|
|
|
@@ -154,8 +242,16 @@ export const TurnStartResultSchema = z.object({
|
|
|
154
242
|
* execution happened; catch up on its events via `events/replay`.
|
|
155
243
|
*/
|
|
156
244
|
deduplicated: z.boolean().optional(),
|
|
157
|
-
/** A deduplicated turn that already ended
|
|
245
|
+
/** A deduplicated turn that already ended: its `turn.ended`. */
|
|
158
246
|
terminal: TurnEndedEventSchema.optional(),
|
|
247
|
+
/**
|
|
248
|
+
* The session's last kept seq at admission, the subscription point: a new
|
|
249
|
+
* turn's first event follows it. A client with no cursor for the session
|
|
250
|
+
* starts one here, so it downloads none of the session's history.
|
|
251
|
+
*/
|
|
252
|
+
headSeq: z.number().int().nonnegative(),
|
|
253
|
+
/** A deduplicated turn whose `turn.started` is kept: its seq, to catch up from. */
|
|
254
|
+
startedSeq: z.number().int().positive().optional(),
|
|
159
255
|
});
|
|
160
256
|
export type TurnStartResult = z.infer<typeof TurnStartResultSchema>;
|
|
161
257
|
|
|
@@ -163,17 +259,16 @@ export const TurnCancelParamsSchema = z.object({
|
|
|
163
259
|
sessionId: z.string().min(1),
|
|
164
260
|
/**
|
|
165
261
|
* Cancel only if THIS turn is the active one — a late cancel meant for a
|
|
166
|
-
* finished turn must not kill its successor. Omitted
|
|
167
|
-
*
|
|
168
|
-
*
|
|
262
|
+
* finished turn must not kill its successor. Omitted: cancel whatever turn
|
|
263
|
+
* the session is running. Empty ids are rejected rather than silently
|
|
264
|
+
* treated as unstamped.
|
|
169
265
|
*/
|
|
170
266
|
turnId: z.string().min(1).optional(),
|
|
171
267
|
});
|
|
172
268
|
export type TurnCancelParams = z.infer<typeof TurnCancelParamsSchema>;
|
|
173
269
|
|
|
174
270
|
/**
|
|
175
|
-
*
|
|
176
|
-
* combinations included illegal states):
|
|
271
|
+
* What a cancel did, as one outcome:
|
|
177
272
|
* - `cancelled` — the harness confirmed the interrupt.
|
|
178
273
|
* - `unconfirmed` — best-effort dispatched but unacknowledged; the agent
|
|
179
274
|
* process may still be running and the turn's `turn.ended` remains the
|
|
@@ -188,6 +283,47 @@ export const TurnCancelResultSchema = z.discriminatedUnion("outcome", [
|
|
|
188
283
|
]);
|
|
189
284
|
export type TurnCancelResult = z.infer<typeof TurnCancelResultSchema>;
|
|
190
285
|
|
|
286
|
+
/**
|
|
287
|
+
* More input for a running turn. `turnId` is required: a steer meant for one
|
|
288
|
+
* turn must never land in the next. `steerId` names the user message the steer
|
|
289
|
+
* becomes (`steerMessageId`), so it is unique in the session, as a turn id is;
|
|
290
|
+
* the server mints one when it is omitted. A retry with the same `steerId` and
|
|
291
|
+
* input converges instead of steering twice; reusing it otherwise is
|
|
292
|
+
* `turnConflict`.
|
|
293
|
+
*/
|
|
294
|
+
export const TurnSteerParamsSchema = z.object({
|
|
295
|
+
sessionId: z.string().min(1),
|
|
296
|
+
turnId: z.string().min(1),
|
|
297
|
+
steerId: z.string().min(1).optional(),
|
|
298
|
+
input: AgentInputSchema.refine(
|
|
299
|
+
(input) => (typeof input === "string" ? input.trim() !== "" : input.length > 0),
|
|
300
|
+
"a steer carries input",
|
|
301
|
+
),
|
|
302
|
+
});
|
|
303
|
+
export type TurnSteerParams = z.infer<typeof TurnSteerParamsSchema>;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* What a steer did, as one outcome:
|
|
307
|
+
* - `steered` — accepted. It reaches the agent at its next step and
|
|
308
|
+
* appears as a user message in the turn, or, if the turn ends first, in
|
|
309
|
+
* the turn's `turn.ended.undeliveredSteers`.
|
|
310
|
+
* - `no_active_turn` — the turn is not taking input: it ended or is ending,
|
|
311
|
+
* or another turn is active (`activeTurnId`). Send it as a new turn.
|
|
312
|
+
* - `unsupported` — this harness cannot take input mid-turn
|
|
313
|
+
* (`AgentCapabilities.steering`).
|
|
314
|
+
*/
|
|
315
|
+
export const TurnSteerResultSchema = z.discriminatedUnion("outcome", [
|
|
316
|
+
z.object({
|
|
317
|
+
outcome: z.literal("steered"),
|
|
318
|
+
steerId: z.string(),
|
|
319
|
+
/** A retry of a steer already accepted: nothing was sent twice. */
|
|
320
|
+
deduplicated: z.boolean().optional(),
|
|
321
|
+
}),
|
|
322
|
+
z.object({ outcome: z.literal("no_active_turn"), activeTurnId: z.string().optional() }),
|
|
323
|
+
z.object({ outcome: z.literal("unsupported") }),
|
|
324
|
+
]);
|
|
325
|
+
export type TurnSteerResult = z.infer<typeof TurnSteerResultSchema>;
|
|
326
|
+
|
|
191
327
|
export const SessionCloseParamsSchema = z.object({ sessionId: z.string() });
|
|
192
328
|
export type SessionCloseParams = z.infer<typeof SessionCloseParamsSchema>;
|
|
193
329
|
|
|
@@ -206,29 +342,41 @@ export type PermissionRespondParams = z.infer<typeof PermissionRespondParamsSche
|
|
|
206
342
|
export const PermissionRespondResultSchema = z.object({ accepted: z.boolean() });
|
|
207
343
|
export type PermissionRespondResult = z.infer<typeof PermissionRespondResultSchema>;
|
|
208
344
|
|
|
209
|
-
|
|
210
|
-
* One sequenced event as broadcast on the wire. `seq` is per-session,
|
|
211
|
-
* monotonic, and starts at 1 — a client that has seen nothing replays from 1.
|
|
212
|
-
* The envelope duplicates `sessionId` so consumers can route without parsing
|
|
213
|
-
* the event body.
|
|
214
|
-
*/
|
|
215
|
-
export const WireEventEnvelopeSchema = z.object({
|
|
345
|
+
export const ElicitationRespondParamsSchema = z.object({
|
|
216
346
|
sessionId: z.string(),
|
|
217
|
-
|
|
218
|
-
|
|
347
|
+
requestId: z.string(),
|
|
348
|
+
outcome: ElicitationOutcomeSchema,
|
|
219
349
|
});
|
|
220
|
-
export type
|
|
350
|
+
export type ElicitationRespondParams = z.infer<typeof ElicitationRespondParamsSchema>;
|
|
351
|
+
|
|
352
|
+
/** `accepted: false` means the request was unknown or already resolved. */
|
|
353
|
+
export const ElicitationRespondResultSchema = z.object({ accepted: z.boolean() });
|
|
354
|
+
export type ElicitationRespondResult = z.infer<typeof ElicitationRespondResultSchema>;
|
|
221
355
|
|
|
222
356
|
/** The routing fields of an envelope — strict, because the wire owns them. */
|
|
223
357
|
const WireEventEnvelopeHeaderSchema = z.object({
|
|
224
358
|
sessionId: z.string(),
|
|
225
359
|
seq: z.number().int().positive(),
|
|
360
|
+
live: z.literal(true).optional(),
|
|
226
361
|
});
|
|
362
|
+
// @ref LLP 0002#snapshots-win-over-deltas — a frame no one keeps says so
|
|
363
|
+
/**
|
|
364
|
+
* One frame of a session as sent on the wire. `seq` is per-session,
|
|
365
|
+
* monotonic, and starts at 1. A frame the server does not keep says
|
|
366
|
+
* `live: true`: a token delta, or an open part sent after a subscription (a
|
|
367
|
+
* `message.part` carrying the part's content so far). It takes no seq of its
|
|
368
|
+
* own, carries that of the last kept event before it (fold it with
|
|
369
|
+
* `SeqCursor.advanceLive`; `isLiveEnvelope` tells), and replay and history
|
|
370
|
+
* never return it. The envelope duplicates `sessionId` so consumers can route
|
|
371
|
+
* without parsing the event body.
|
|
372
|
+
*/
|
|
373
|
+
export const WireEventEnvelopeSchema = WireEventEnvelopeHeaderSchema.extend({
|
|
374
|
+
event: LifecycleEventSchema,
|
|
375
|
+
});
|
|
376
|
+
export type WireEventEnvelope = z.infer<typeof WireEventEnvelopeSchema>;
|
|
227
377
|
|
|
228
|
-
/** An envelope whose event was decoded
|
|
229
|
-
export interface DecodedWireEventEnvelope {
|
|
230
|
-
sessionId: string;
|
|
231
|
-
seq: number;
|
|
378
|
+
/** An envelope whose event was decoded tolerantly (unknowns preserved). */
|
|
379
|
+
export interface DecodedWireEventEnvelope extends Omit<WireEventEnvelope, "event"> {
|
|
232
380
|
event: DecodedLifecycleEvent | UnknownEvent;
|
|
233
381
|
}
|
|
234
382
|
|
|
@@ -243,36 +391,11 @@ export function decodeWireEventEnvelope(value: unknown): DecodedWireEventEnvelop
|
|
|
243
391
|
return {
|
|
244
392
|
sessionId: header.sessionId,
|
|
245
393
|
seq: header.seq,
|
|
394
|
+
...(header.live && { live: true }),
|
|
246
395
|
event: decodeLifecycleEvent((value as { event?: unknown }).event),
|
|
247
396
|
};
|
|
248
397
|
}
|
|
249
398
|
|
|
250
|
-
/** `events/replay` with its envelopes decoded leniently. */
|
|
251
|
-
export interface DecodedEventsReplayResult {
|
|
252
|
-
events: DecodedWireEventEnvelope[];
|
|
253
|
-
firstAvailableSeq: number | null;
|
|
254
|
-
latestSeq: number | null;
|
|
255
|
-
hasMore?: boolean;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* The replay result, decoded envelope-by-envelope. `EventsReplayResultSchema`
|
|
260
|
-
* embeds the CLOSED event union, so parsing a buffer with it makes one unknown
|
|
261
|
-
* event type poison the whole replay — the healing path for a gap must not be
|
|
262
|
-
* the thing that cannot survive an unknown.
|
|
263
|
-
*/
|
|
264
|
-
export function decodeEventsReplayResult(value: unknown): DecodedEventsReplayResult {
|
|
265
|
-
const parsed = z
|
|
266
|
-
.object({
|
|
267
|
-
events: z.array(z.unknown()),
|
|
268
|
-
firstAvailableSeq: z.number().int().positive().nullable(),
|
|
269
|
-
latestSeq: z.number().int().positive().nullable(),
|
|
270
|
-
hasMore: z.boolean().optional(),
|
|
271
|
-
})
|
|
272
|
-
.parse(value);
|
|
273
|
-
return { ...parsed, events: parsed.events.map((event) => decodeWireEventEnvelope(event)) };
|
|
274
|
-
}
|
|
275
|
-
|
|
276
399
|
export const EventsReplayParamsSchema = z.object({
|
|
277
400
|
sessionId: z.string(),
|
|
278
401
|
/** Replay buffered events with `seq >= fromSeq`. */
|
|
@@ -294,6 +417,24 @@ export const EventsReplayResultSchema = z.object({
|
|
|
294
417
|
});
|
|
295
418
|
export type EventsReplayResult = z.infer<typeof EventsReplayResultSchema>;
|
|
296
419
|
|
|
420
|
+
/** `events/replay` with its envelopes decoded leniently. */
|
|
421
|
+
export interface DecodedEventsReplayResult extends Omit<EventsReplayResult, "events"> {
|
|
422
|
+
events: DecodedWireEventEnvelope[];
|
|
423
|
+
}
|
|
424
|
+
/** A replay result with its events left to decode one by one. */
|
|
425
|
+
const ReplayResultFrameSchema = EventsReplayResultSchema.extend({ events: z.array(z.unknown()) });
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* The replay result, decoded envelope-by-envelope. `EventsReplayResultSchema`
|
|
429
|
+
* embeds the CLOSED event union, so parsing a buffer with it makes one unknown
|
|
430
|
+
* event type poison the whole replay — the healing path for a gap must not be
|
|
431
|
+
* the thing that cannot survive an unknown.
|
|
432
|
+
*/
|
|
433
|
+
export function decodeEventsReplayResult(value: unknown): DecodedEventsReplayResult {
|
|
434
|
+
const parsed = ReplayResultFrameSchema.parse(value);
|
|
435
|
+
return { ...parsed, events: parsed.events.map((event) => decodeWireEventEnvelope(event)) };
|
|
436
|
+
}
|
|
437
|
+
|
|
297
438
|
/**
|
|
298
439
|
* `models/list`: the models a harness offers, read from its CLI for the login
|
|
299
440
|
* and folder a turn with the same `cwd`, `env` and `apiKey` would use (Claude
|
|
@@ -312,9 +453,6 @@ export const ModelsListParamsSchema = z.object({
|
|
|
312
453
|
});
|
|
313
454
|
export type ModelsListParams = z.infer<typeof ModelsListParamsSchema>;
|
|
314
455
|
|
|
315
|
-
/** Never an error for an available harness: without a live list it is the catalog, with `error`. */
|
|
316
|
-
export const ModelsListResultSchema = ModelListSchema;
|
|
317
|
-
|
|
318
456
|
/**
|
|
319
457
|
* `turn/get`: a durable turn's receipt. Admission records it, with the input,
|
|
320
458
|
* before the `turn/start` ack, so a turn whose process died before its first
|
|
@@ -332,6 +470,16 @@ export type TurnReceipt = z.infer<typeof TurnReceiptSchema>;
|
|
|
332
470
|
/** `session/get`: what a durable server knows about a session. */
|
|
333
471
|
export const SessionGetParamsSchema = z.object({ sessionId: z.string() });
|
|
334
472
|
export type SessionGetParams = z.infer<typeof SessionGetParamsSchema>;
|
|
473
|
+
/**
|
|
474
|
+
* Why a restart could not lift a session's fence: `not_owned`, a host's own
|
|
475
|
+
* spawner started its agent; `not_verified`, nothing could tell whether its
|
|
476
|
+
* process still runs (no sweep, no process table, a pid it may not signal);
|
|
477
|
+
* `not_stopped`, it was still there after SIGKILL.
|
|
478
|
+
*/
|
|
479
|
+
export const RECOVERY_REASONS = ["not_owned", "not_verified", "not_stopped"] as const;
|
|
480
|
+
export const RecoveryReasonSchema = z.enum(RECOVERY_REASONS);
|
|
481
|
+
export type RecoveryReason = z.infer<typeof RecoveryReasonSchema>;
|
|
482
|
+
|
|
335
483
|
export const DurableSessionSchema = z.object({
|
|
336
484
|
sessionId: z.string(),
|
|
337
485
|
harness: AgentHarnessSchema,
|
|
@@ -339,8 +487,13 @@ export const DurableSessionSchema = z.object({
|
|
|
339
487
|
headSeq: z.number().int().nonnegative(),
|
|
340
488
|
nativeSessionId: z.string().nullable(),
|
|
341
489
|
closed: z.boolean(),
|
|
342
|
-
/**
|
|
490
|
+
/**
|
|
491
|
+
* A restart cut off a turn and could not confirm its agent stopped: see
|
|
492
|
+
* `recoveryRequired` and `session/confirmStopped`.
|
|
493
|
+
*/
|
|
343
494
|
recoveryRequired: z.boolean(),
|
|
495
|
+
/** Why, while `recoveryRequired` is set. */
|
|
496
|
+
recoveryReason: RecoveryReasonSchema.optional(),
|
|
344
497
|
});
|
|
345
498
|
export type DurableSession = z.infer<typeof DurableSessionSchema>;
|
|
346
499
|
|
|
@@ -360,7 +513,98 @@ export type SessionConfirmStoppedParams = z.infer<typeof SessionConfirmStoppedPa
|
|
|
360
513
|
export const SessionConfirmStoppedResultSchema = z.object({ recovered: z.boolean() });
|
|
361
514
|
export type SessionConfirmStoppedResult = z.infer<typeof SessionConfirmStoppedResultSchema>;
|
|
362
515
|
|
|
363
|
-
|
|
516
|
+
/**
|
|
517
|
+
* `session/release`: let an idle session's agent go (its process and what it
|
|
518
|
+
* holds, a Codex home included) while the session stays open. Its next turn
|
|
519
|
+
* names its native conversation (`config.resumeSessionId`; until then
|
|
520
|
+
* `resumeRequired`), as after a restart. `session/close` ends a session;
|
|
521
|
+
* this only frees what it runs on. Nothing is broadcast: another client of
|
|
522
|
+
* the session learns of it when its next turn is refused `resumeRequired`,
|
|
523
|
+
* whose data names the conversation, the answer a client that survives a
|
|
524
|
+
* restart already handles.
|
|
525
|
+
*/
|
|
526
|
+
export const SessionReleaseParamsSchema = z.object({ sessionId: z.string() });
|
|
527
|
+
export type SessionReleaseParams = z.infer<typeof SessionReleaseParamsSchema>;
|
|
528
|
+
/** `released: false` when the server holds no open session by that id. */
|
|
529
|
+
export const SessionReleaseResultSchema = z.object({ released: z.boolean() });
|
|
530
|
+
export type SessionReleaseResult = z.infer<typeof SessionReleaseResultSchema>;
|
|
531
|
+
|
|
532
|
+
// @ref LLP 0008#ordering-joining-without-a-gap-or-a-duplicate — the answer marks the point
|
|
533
|
+
/**
|
|
534
|
+
* `session/subscribe`: stream a session to this connection. The answer marks
|
|
535
|
+
* the subscription point in the connection's frames. After it come, first,
|
|
536
|
+
* the session's open parts (`live` `message.part` frames at `headSeq`), then
|
|
537
|
+
* every kept event after `headSeq` and every delta after the point, each
|
|
538
|
+
* once. Kept events up to `headSeq` the caller does not hold it reads with
|
|
539
|
+
* `events/replay`: the server pushes no catch-up. Subscribing again answers
|
|
540
|
+
* a new point and sends the open parts again; no other frame is sent twice.
|
|
541
|
+
*
|
|
542
|
+
* Without `turnId` the connection watches the session until it unsubscribes
|
|
543
|
+
* or the session ends; with one it follows that turn, while it runs, until
|
|
544
|
+
* its `turn.ended` (a turn that is not running subscribes nothing, and the
|
|
545
|
+
* answer's `activeTurn` says so). Refused `unknownSession` when the server has
|
|
546
|
+
* no log for the session (it never ran, or it was closed), and
|
|
547
|
+
* `subscriptionLimit` past the connection's cap, which counts the sessions it
|
|
548
|
+
* watches (`session/subscribeAll` once), never the turns it follows.
|
|
549
|
+
*/
|
|
550
|
+
export const SessionSubscribeParamsSchema = z.object({
|
|
551
|
+
sessionId: z.string().min(1),
|
|
552
|
+
/** Follow this running turn of the session, until it ends, instead of watching the session. */
|
|
553
|
+
turnId: z.string().min(1).optional(),
|
|
554
|
+
});
|
|
555
|
+
export type SessionSubscribeParams = z.infer<typeof SessionSubscribeParamsSchema>;
|
|
556
|
+
/** The turn a session runs at a subscription point. */
|
|
557
|
+
export const RunningTurnSchema = z.object({
|
|
558
|
+
turnId: z.string(),
|
|
559
|
+
/** Once its `turn.started` is kept: where to catch up on the turn from. */
|
|
560
|
+
startedSeq: z.number().int().positive().optional(),
|
|
561
|
+
});
|
|
562
|
+
export type RunningTurn = z.infer<typeof RunningTurnSchema>;
|
|
563
|
+
export const SessionSubscribeResultSchema = z.object({
|
|
564
|
+
/** The session's last kept seq at the subscription point (0: none yet). */
|
|
565
|
+
headSeq: z.number().int().nonnegative(),
|
|
566
|
+
/** The oldest kept seq replay still holds (null: none): a ring may have evicted what a catch-up needs. */
|
|
567
|
+
firstAvailableSeq: z.number().int().positive().nullable(),
|
|
568
|
+
/** The turn running at the point. */
|
|
569
|
+
activeTurn: RunningTurnSchema.optional(),
|
|
570
|
+
});
|
|
571
|
+
export type SessionSubscribeResult = z.infer<typeof SessionSubscribeResultSchema>;
|
|
572
|
+
/**
|
|
573
|
+
* `session/subscribeAll`: stream every session to this connection, live from
|
|
574
|
+
* now, with no catch-up: for observers. It counts once against the cap.
|
|
575
|
+
*/
|
|
576
|
+
export const SessionSubscribeAllParamsSchema = z.object({});
|
|
577
|
+
/** Each session with a running turn, at its point; their open parts follow. */
|
|
578
|
+
export const SessionSubscribeAllResultSchema = z.object({
|
|
579
|
+
sessions: z.array(SessionSubscribeResultSchema.extend({ sessionId: z.string() })),
|
|
580
|
+
});
|
|
581
|
+
export type SessionSubscribeAllResult = z.infer<typeof SessionSubscribeAllResultSchema>;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* `session/unsubscribe`: stop watching a session. A turn the connection
|
|
585
|
+
* follows streams on until it ends.
|
|
586
|
+
*/
|
|
587
|
+
export const SessionUnsubscribeParamsSchema = z.object({ sessionId: z.string().min(1) });
|
|
588
|
+
export type SessionUnsubscribeParams = z.infer<typeof SessionUnsubscribeParamsSchema>;
|
|
589
|
+
/** `session/unsubscribeAll`: stop streaming every session; those watched by name stream on. */
|
|
590
|
+
export const SessionUnsubscribeAllParamsSchema = z.object({});
|
|
591
|
+
/** `unsubscribed: false` when this connection did not watch it (or every session). */
|
|
592
|
+
export const SessionUnsubscribeResultSchema = z.object({ unsubscribed: z.boolean() });
|
|
593
|
+
export type SessionUnsubscribeResult = z.infer<typeof SessionUnsubscribeResultSchema>;
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* `session/overflow` (server -> client): this connection fell
|
|
597
|
+
* `maxBacklogBytes` behind, so the server stopped sending the session after
|
|
598
|
+
* `lastSeq`, the last kept seq it sent, and dropped the subscription.
|
|
599
|
+
* Subscribe again after the last seq you hold; its open parts come with it.
|
|
600
|
+
* `{all: true}`: the subscription to every session was dropped.
|
|
601
|
+
*/
|
|
602
|
+
export const SessionOverflowParamsSchema = z.union([
|
|
603
|
+
z.object({ sessionId: z.string(), lastSeq: z.number().int().nonnegative() }),
|
|
604
|
+
z.object({ all: z.literal(true) }),
|
|
605
|
+
]);
|
|
606
|
+
export type SessionOverflowParams = z.infer<typeof SessionOverflowParamsSchema>;
|
|
607
|
+
|
|
364
608
|
export const ShutdownResultSchema = z.object({});
|
|
365
609
|
|
|
366
610
|
// ---- codec -------------------------------------------------------------------
|
|
@@ -371,8 +615,8 @@ export type WireMessage =
|
|
|
371
615
|
| { kind: "notification"; method: string; params?: unknown }
|
|
372
616
|
/** `id` is null on protocol-level errors answering unparseable requests. */
|
|
373
617
|
| { kind: "response"; id: JsonRpcId | null; result?: unknown; error?: JsonRpcError }
|
|
374
|
-
/**
|
|
375
|
-
| { kind: "invalid"; error: string; parseError
|
|
618
|
+
/** `parseError`: the line was not JSON at all (JSON-RPC's -32700), not just a bad envelope. */
|
|
619
|
+
| { kind: "invalid"; error: string; parseError: boolean };
|
|
376
620
|
|
|
377
621
|
/** Decode one NDJSON line into a JSON-RPC message (never throws). */
|
|
378
622
|
export function decodeWireMessage(line: string): WireMessage {
|
|
@@ -435,11 +679,17 @@ export function encodeErrorResponse(
|
|
|
435
679
|
|
|
436
680
|
/**
|
|
437
681
|
* A duplex line channel the wire runs over. Implementations exist for stdio,
|
|
438
|
-
* WebSocket, and in-
|
|
439
|
-
* never called; `send` after close is a silent no-op.
|
|
682
|
+
* WebSocket, and in-process pairs (`channelPair`). Handlers registered after
|
|
683
|
+
* close are never called; `send` after close is a silent no-op.
|
|
440
684
|
*/
|
|
441
685
|
export interface WireTransport {
|
|
442
686
|
send(line: string): void;
|
|
687
|
+
/**
|
|
688
|
+
* Bytes sent but not yet written out (a socket's buffered amount, a pipe's
|
|
689
|
+
* writable length), where the channel can tell: the server stops streaming
|
|
690
|
+
* a session to a connection this far behind (`session/overflow`).
|
|
691
|
+
*/
|
|
692
|
+
bufferedAmount?(): number;
|
|
443
693
|
/** Register a line handler; returns an unsubscribe function. */
|
|
444
694
|
onLine(handler: (line: string) => void): () => void;
|
|
445
695
|
/** Register a close handler; returns an unsubscribe function. */
|
|
@@ -466,10 +716,14 @@ export function pushNdjsonLines(push: (line: string) => void, data: unknown): vo
|
|
|
466
716
|
/**
|
|
467
717
|
* Build a WireTransport from a raw byte-channel binding: the caller supplies
|
|
468
718
|
* the outbound `send`/`close`, and pushes inbound lines / close through the
|
|
469
|
-
* returned handles. Every concrete transport (stdio, WebSocket,
|
|
719
|
+
* returned handles. Every concrete transport (stdio, WebSocket, `channelPair`)
|
|
470
720
|
* is this bridge plus platform wiring.
|
|
471
721
|
*/
|
|
472
|
-
export function channelTransport(io: {
|
|
722
|
+
export function channelTransport(io: {
|
|
723
|
+
send(line: string): void;
|
|
724
|
+
close?(): void;
|
|
725
|
+
bufferedAmount?(): number;
|
|
726
|
+
}): {
|
|
473
727
|
transport: WireTransport;
|
|
474
728
|
push(line: string): void;
|
|
475
729
|
end(reason?: string): void;
|
|
@@ -486,10 +740,12 @@ export function channelTransport(io: { send(line: string): void; close?(): void
|
|
|
486
740
|
closeHandlers.clear();
|
|
487
741
|
};
|
|
488
742
|
|
|
743
|
+
const { bufferedAmount } = io;
|
|
489
744
|
const transport: WireTransport = {
|
|
490
745
|
send(line) {
|
|
491
746
|
if (!closed) io.send(line);
|
|
492
747
|
},
|
|
748
|
+
...(bufferedAmount && { bufferedAmount: () => bufferedAmount.call(io) }),
|
|
493
749
|
onLine(handler) {
|
|
494
750
|
lineHandlers.add(handler);
|
|
495
751
|
return () => lineHandlers.delete(handler);
|
|
@@ -517,3 +773,34 @@ export function channelTransport(io: { send(line: string): void; close?(): void
|
|
|
517
773
|
end,
|
|
518
774
|
};
|
|
519
775
|
}
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Two transports wired to each other in one process: the in-process wire
|
|
779
|
+
* between an `AgentServer` and its client (`server.attach(pair.server)`,
|
|
780
|
+
* `AgentServerClient.attach(pair.client)`). `deliver` schedules each line's
|
|
781
|
+
* arrival, a microtask later by default, as a socket's arrives on a later
|
|
782
|
+
* tick; `kill` drops the connection at both ends.
|
|
783
|
+
*/
|
|
784
|
+
export function channelPair(deliver: (arrive: () => void) => void = queueMicrotask): {
|
|
785
|
+
client: WireTransport;
|
|
786
|
+
server: WireTransport;
|
|
787
|
+
kill(reason?: string): void;
|
|
788
|
+
} {
|
|
789
|
+
type Channel = ReturnType<typeof channelTransport>;
|
|
790
|
+
const ends: Channel[] = [];
|
|
791
|
+
const end = (peer: number) =>
|
|
792
|
+
channelTransport({
|
|
793
|
+
send: (line) => deliver(() => ends[peer]?.push(line)),
|
|
794
|
+
close: () => deliver(() => ends[peer]?.end("peer closed")),
|
|
795
|
+
});
|
|
796
|
+
ends.push(end(1), end(0));
|
|
797
|
+
const [client, server] = ends as [Channel, Channel];
|
|
798
|
+
return {
|
|
799
|
+
client: client.transport,
|
|
800
|
+
server: server.transport,
|
|
801
|
+
kill(reason = "connection dropped") {
|
|
802
|
+
client.end(reason);
|
|
803
|
+
server.end(reason);
|
|
804
|
+
},
|
|
805
|
+
};
|
|
806
|
+
}
|