@zvada/agent-server 0.3.18 → 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 +1005 -1
- package/README.md +35 -39
- 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 +43 -25
- 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 +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 +58 -48
- package/src/core/presets.ts +100 -39
- package/src/core/processes/identity.ts +113 -0
- package/src/core/processes/lifeline.ts +170 -0
- package/src/core/processes/native-processes.ts +379 -0
- package/src/core/processes/process-table.ts +174 -0
- package/src/core/provision/cache-trust.ts +121 -0
- package/src/core/provision/cache-usage.ts +69 -0
- package/src/core/provision/checksums.ts +64 -0
- package/src/core/provision/extract.ts +11 -2
- package/src/core/provision/index.ts +4 -1
- package/src/core/provision/install-build.ts +136 -0
- package/src/core/provision/npm.ts +112 -17
- package/src/core/provision/pins.ts +9 -33
- package/src/core/provision/platform.ts +12 -1
- package/src/core/provision/provisioner.ts +329 -397
- package/src/core/provision/releases.ts +86 -0
- package/src/core/provision/tools.ts +329 -0
- package/src/core/proxy/anthropic-proxy.ts +55 -25
- package/src/core/proxy/api-key-store.ts +2 -12
- package/src/core/proxy/loopback.ts +106 -0
- package/src/core/runtime/agent-runtime.ts +327 -498
- package/src/core/runtime/event-processor.ts +197 -70
- package/src/core/runtime/harness-clis.ts +61 -0
- package/src/core/runtime/harness-logins.ts +328 -0
- package/src/core/runtime/login-reads.ts +78 -0
- package/src/core/runtime/model-lists.ts +33 -48
- package/src/core/runtime/permission-policy.ts +113 -0
- package/src/core/runtime/request-broker.ts +204 -0
- package/src/core/runtime/steering.ts +112 -0
- package/src/core/runtime/turn-outcome.ts +30 -0
- package/src/core/runtime/turn.ts +360 -0
- package/src/core/utils/bounded.ts +12 -0
- package/src/core/utils/deadline.ts +38 -0
- package/src/core/utils/errors.ts +113 -21
- package/src/core/utils/is-record.ts +4 -0
- package/src/core/utils/loopback.ts +10 -0
- package/src/protocol/account.ts +104 -0
- package/src/protocol/auth.ts +199 -0
- package/src/protocol/canonical.ts +16 -0
- package/src/protocol/clis.ts +69 -0
- package/src/protocol/config.ts +60 -6
- package/src/protocol/conversation.ts +272 -0
- package/src/protocol/credentials.ts +145 -0
- package/src/protocol/errors.ts +78 -20
- package/src/protocol/execution.ts +5 -2
- package/src/protocol/factories.ts +55 -7
- package/src/protocol/guards.ts +55 -2
- package/src/protocol/harness.ts +56 -6
- package/src/protocol/history.ts +72 -64
- package/src/protocol/ids.ts +0 -12
- package/src/protocol/index.ts +9 -0
- package/src/protocol/lifecycle.ts +250 -79
- package/src/protocol/meta-keys.ts +17 -0
- package/src/protocol/meta.ts +3 -3
- package/src/protocol/models.ts +2 -43
- package/src/protocol/part-input.ts +2 -1
- package/src/protocol/parts.ts +12 -3
- package/src/protocol/reduce.ts +302 -413
- package/src/protocol/selectors.ts +1 -20
- package/src/protocol/seq-cursor.ts +14 -0
- package/src/protocol/stop-reasons.ts +1 -1
- package/src/protocol/thinking.ts +1 -30
- package/src/protocol/time.ts +2 -2
- package/src/protocol/tool-closure.ts +93 -0
- package/src/protocol/tool-state.ts +19 -4
- package/src/protocol/verify.ts +222 -92
- package/src/protocol/vocabulary.ts +21 -5
- package/src/protocol/wire-api.ts +232 -0
- package/src/protocol/wire.ts +351 -64
- package/src/server/acp/binding.ts +63 -103
- package/src/server/acp/session-records.ts +53 -0
- package/src/server/acp/translate.ts +129 -20
- package/src/server/agent-server.ts +223 -387
- package/src/server/bin.ts +280 -78
- package/src/server/feedback.ts +204 -14
- package/src/server/history.ts +116 -122
- package/src/server/index.ts +3 -8
- package/src/server/install.ts +107 -8
- package/src/server/open-parts.ts +95 -0
- package/src/server/routes.ts +391 -0
- package/src/server/secrets.ts +24 -0
- package/src/server/session-gate.ts +69 -0
- package/src/server/session-log.ts +14 -2
- package/src/server/session-store.ts +136 -72
- package/src/server/subscriptions.ts +232 -0
- package/src/server/transports.ts +125 -25
- package/src/server/wire-error.ts +31 -45
- package/src/sync/event-log.ts +31 -3
- package/src/sync/fit.ts +27 -11
- package/src/sync/history-reader.ts +10 -5
- package/src/sync/history-sqlite.ts +37 -42
- package/src/sync/history.ts +9 -15
- package/src/sync/index.ts +17 -5
- package/src/sync/journal-sqlite.ts +162 -76
- package/src/sync/journal.ts +91 -32
- package/src/sync/live-tails.ts +107 -0
- package/src/sync/projection.ts +35 -0
- package/src/sync/recovery.ts +80 -51
- package/src/sync/schema.ts +27 -6
- package/docs/rfds/0001-deterministic-echo-ids.md +0 -44
- package/docs/rfds/0002-native-subagents.md +0 -197
- package/src/client/request.ts +0 -19
- package/src/core/agents/claude-code/generator-session.ts +0 -572
- package/src/core/agents/claude-code/session-manager.ts +0 -166
- package/src/core/agents/codex-app-server/codex-app-server-agent.ts +0 -962
- package/src/core/agents/codex-items.ts +0 -149
- package/src/core/agents/codex-sdk/adapter.ts +0 -237
- package/src/core/agents/codex-sdk/codex-sdk-agent.ts +0 -330
- package/src/core/agents/tool-meta.ts +0 -68
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type AgentHarness, WireRefusal } from "../protocol/index.ts";
|
|
2
|
+
|
|
3
|
+
/** The turn a session runs. */
|
|
4
|
+
export interface ActiveTurn {
|
|
5
|
+
turnId: string;
|
|
6
|
+
harness: AgentHarness;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Which sessions are busy: running their one turn, or letting their native
|
|
11
|
+
* state go (`session/close`, `session/release`). A request that would race
|
|
12
|
+
* either is refused before it touches the session.
|
|
13
|
+
*/
|
|
14
|
+
export class SessionGate {
|
|
15
|
+
private readonly turns = new Map<string, ActiveTurn>();
|
|
16
|
+
private readonly closing = new Map<string, "closing" | "releasing">();
|
|
17
|
+
|
|
18
|
+
/** The turn the session runs, if any. */
|
|
19
|
+
activeTurn(sessionId: string): ActiveTurn | undefined {
|
|
20
|
+
return this.turns.get(sessionId);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The sessions running a turn. */
|
|
24
|
+
running(): string[] {
|
|
25
|
+
return [...this.turns.keys()];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Refuse a session whose native state is going: it is idle, not busy, so retry shortly. */
|
|
29
|
+
assertOpen(sessionId: string): void {
|
|
30
|
+
const closing = this.closing.get(sessionId);
|
|
31
|
+
if (closing) throw new WireRefusal("sessionClosing", `session ${sessionId} is ${closing}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Refuse a session that runs a turn, or whose native state is going. */
|
|
35
|
+
assertIdle(sessionId: string): void {
|
|
36
|
+
this.assertOpen(sessionId);
|
|
37
|
+
const turn = this.turns.get(sessionId);
|
|
38
|
+
if (turn)
|
|
39
|
+
throw new WireRefusal("turnActive", `session ${sessionId} has an active turn`, {
|
|
40
|
+
turnId: turn.turnId,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
begin(sessionId: string, turn: ActiveTurn): void {
|
|
45
|
+
this.turns.set(sessionId, turn);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The turn ended: its session is idle — unless a newer turn was admitted
|
|
50
|
+
* between this one's `turn.ended` and its run settling, whose mark stays.
|
|
51
|
+
*/
|
|
52
|
+
settle(sessionId: string, turnId: string): void {
|
|
53
|
+
if (this.turns.get(sessionId)?.turnId === turnId) this.turns.delete(sessionId);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Let the session's native state go with `release`; no turn starts meanwhile. */
|
|
57
|
+
async whileClosing<T>(
|
|
58
|
+
sessionId: string,
|
|
59
|
+
kind: "closing" | "releasing",
|
|
60
|
+
release: () => Promise<T>,
|
|
61
|
+
): Promise<T> {
|
|
62
|
+
this.closing.set(sessionId, kind);
|
|
63
|
+
try {
|
|
64
|
+
return await release();
|
|
65
|
+
} finally {
|
|
66
|
+
this.closing.delete(sessionId);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AgentHarness,
|
|
3
|
+
LifecycleEvent,
|
|
4
|
+
MessagePartDeltaEvent,
|
|
5
|
+
WireEventEnvelope,
|
|
6
|
+
} from "../protocol/index.ts";
|
|
2
7
|
|
|
3
8
|
export const DEFAULT_BUFFER_SIZE = 4096;
|
|
4
9
|
|
|
10
|
+
// @ref LLP 0001#d7--reliability-lives-at-the-wire-binding — seq and bounded replay
|
|
5
11
|
/**
|
|
6
|
-
* Per-session monotonic sequence + bounded replay buffer
|
|
12
|
+
* Per-session monotonic sequence + bounded replay buffer. Every
|
|
7
13
|
* outbound event is stamped with `seq` (starting at 1) and kept in a ring
|
|
8
14
|
* buffer so a reconnecting client can `events/replay({fromSeq})`. Eviction is
|
|
9
15
|
* visible to clients via `firstAvailableSeq`.
|
|
@@ -47,6 +53,12 @@ export class SessionLog {
|
|
|
47
53
|
return envelope;
|
|
48
54
|
}
|
|
49
55
|
|
|
56
|
+
/** A live-only event's envelope: the seq of the last kept event, nothing buffered.
|
|
57
|
+
* A delta follows its turn's `turn.started`, so there always is one. */
|
|
58
|
+
live(event: MessagePartDeltaEvent): WireEventEnvelope {
|
|
59
|
+
return { sessionId: this.sessionId, seq: this.nextSeq - 1, event };
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
/** Buffered envelopes with `seq >= fromSeq` (seq is contiguous — index math). */
|
|
51
63
|
replay(fromSeq: number): WireEventEnvelope[] {
|
|
52
64
|
const first = this.firstAvailableSeq;
|
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
import { EventSinkError } from "../core/index.ts";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { EventSinkError, type NativeProcessEvent, type NativeRecord } from "../core/index.ts";
|
|
2
|
+
import type {
|
|
3
|
+
AgentHarness,
|
|
4
|
+
DurableSession,
|
|
5
|
+
EventsReplayResult,
|
|
6
|
+
LifecycleEvent,
|
|
7
|
+
MessagePartDeltaEvent,
|
|
8
|
+
RunRequest,
|
|
9
|
+
TurnEndedEvent,
|
|
10
|
+
TurnReceipt,
|
|
11
|
+
WireEventEnvelope,
|
|
12
12
|
} from "../protocol/index.ts";
|
|
13
|
-
import { JournalError, type SessionJournal } from "../sync/journal.ts";
|
|
13
|
+
import { type ClaimOptions, JournalError, type SessionJournal } from "../sync/journal.ts";
|
|
14
14
|
import { DEFAULT_BUFFER_SIZE, SessionLog } from "./session-log.ts";
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
/** Where a session's subscription starts: its last kept seq, and the oldest replay still holds. */
|
|
17
|
+
export interface SessionPoint {
|
|
18
|
+
/** 0 before the session's first event. */
|
|
19
|
+
headSeq: number;
|
|
20
|
+
firstAvailableSeq: number | null;
|
|
21
|
+
}
|
|
16
22
|
|
|
17
23
|
/**
|
|
18
24
|
* Where the server keeps its session logs: the seam between execution and
|
|
19
25
|
* persistence. AgentServer picks one at construction; nothing else in its
|
|
20
|
-
* request path knows whether sessions outlive the process
|
|
26
|
+
* request path knows whether sessions outlive the process (a durable store's
|
|
27
|
+
* own methods are routes only a durable server has).
|
|
21
28
|
*/
|
|
22
|
-
export interface
|
|
23
|
-
/** Set when the logs outlive the process: their identity (`initialize.historyId`). */
|
|
24
|
-
readonly historyId?: string;
|
|
29
|
+
export interface SessionLogStore {
|
|
25
30
|
/** The harness a session is bound to (its first turn's). */
|
|
26
31
|
harnessOf(sessionId: string): AgentHarness | undefined;
|
|
27
32
|
/** A retried turn this store already admitted. Refuses a turnId reused with other input. */
|
|
@@ -34,21 +39,26 @@ export interface SessionStore {
|
|
|
34
39
|
* retires the session.
|
|
35
40
|
*/
|
|
36
41
|
append(sessionId: string, event: LifecycleEvent): WireEventEnvelope;
|
|
42
|
+
/**
|
|
43
|
+
* Deliver a token delta without keeping it: its envelope carries the seq of
|
|
44
|
+
* the session's last kept event, and replay never returns it.
|
|
45
|
+
*/
|
|
46
|
+
live(sessionId: string, event: MessagePartDeltaEvent): WireEventEnvelope;
|
|
37
47
|
/** Events from `fromSeq`; undefined for a session without a log (unknown or closed). */
|
|
38
48
|
replay(sessionId: string, fromSeq: number): EventsReplayResult | undefined;
|
|
49
|
+
/** Where a subscription to the session starts now; undefined without a log (unknown or closed). */
|
|
50
|
+
point(sessionId: string): SessionPoint | undefined;
|
|
51
|
+
/** The `turn.ended` of a turn this store still holds. */
|
|
52
|
+
terminal(sessionId: string, turnId: string): TurnEndedEvent | undefined;
|
|
39
53
|
/** The harness to release before `session.ended`; undefined when there is
|
|
40
54
|
* nothing to close. Refuses a session that may not close yet. */
|
|
41
55
|
closing(sessionId: string): AgentHarness | undefined;
|
|
42
|
-
/** Durable stores only. */
|
|
43
|
-
receipt?(sessionId: string, turnId: string): TurnReceipt | undefined;
|
|
44
|
-
session?(sessionId: string): DurableSession | undefined;
|
|
45
|
-
confirmStopped?(sessionId: string, expectedHeadSeq: number): boolean;
|
|
46
56
|
/** Give up execution ownership when the server shuts down. */
|
|
47
|
-
|
|
57
|
+
relinquish(): void;
|
|
48
58
|
}
|
|
49
59
|
|
|
50
60
|
/** A bounded replay ring per session, gone with the process. */
|
|
51
|
-
export class MemorySessionStore implements
|
|
61
|
+
export class MemorySessionStore implements SessionLogStore {
|
|
52
62
|
private readonly sessions = new Map<string, SessionLog>();
|
|
53
63
|
/** Last assigned seq of closed sessions, so a reused id continues
|
|
54
64
|
* monotonically. Memory: one number per closed-and-never-reused session id —
|
|
@@ -75,8 +85,7 @@ export class MemorySessionStore implements SessionStore {
|
|
|
75
85
|
this.retiredSeqs.delete(sessionId);
|
|
76
86
|
}
|
|
77
87
|
append(sessionId: string, event: LifecycleEvent): WireEventEnvelope {
|
|
78
|
-
const log = this.
|
|
79
|
-
if (!log) throw new Error(`session ${sessionId} has no log`);
|
|
88
|
+
const log = this.log(sessionId);
|
|
80
89
|
const envelope = log.append(event);
|
|
81
90
|
// `session.ended` is deliberately NOT replayable: a subscriber detached
|
|
82
91
|
// during the close gets `unknownSession` from `events/replay`, and that
|
|
@@ -87,6 +96,9 @@ export class MemorySessionStore implements SessionStore {
|
|
|
87
96
|
}
|
|
88
97
|
return envelope;
|
|
89
98
|
}
|
|
99
|
+
live(sessionId: string, event: MessagePartDeltaEvent): WireEventEnvelope {
|
|
100
|
+
return this.log(sessionId).live(event);
|
|
101
|
+
}
|
|
90
102
|
replay(sessionId: string, fromSeq: number): EventsReplayResult | undefined {
|
|
91
103
|
const log = this.sessions.get(sessionId);
|
|
92
104
|
if (!log) return undefined;
|
|
@@ -96,29 +108,26 @@ export class MemorySessionStore implements SessionStore {
|
|
|
96
108
|
latestSeq: log.latestSeq,
|
|
97
109
|
};
|
|
98
110
|
}
|
|
111
|
+
point(sessionId: string): SessionPoint | undefined {
|
|
112
|
+
const log = this.sessions.get(sessionId);
|
|
113
|
+
return log && { headSeq: log.latestSeq ?? 0, firstAvailableSeq: log.firstAvailableSeq };
|
|
114
|
+
}
|
|
115
|
+
terminal(sessionId: string, turnId: string): TurnEndedEvent | undefined {
|
|
116
|
+
for (const { event } of this.sessions.get(sessionId)?.replay(1) ?? [])
|
|
117
|
+
if (event.type === "turn.ended" && event.turnId === turnId) return event;
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
99
120
|
closing(sessionId: string): AgentHarness | undefined {
|
|
100
121
|
return this.harnessOf(sessionId);
|
|
101
122
|
}
|
|
102
|
-
|
|
103
|
-
}
|
|
123
|
+
relinquish(): void {}
|
|
104
124
|
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
resumeRequired: WIRE_ERROR_CODES.resumeRequired,
|
|
112
|
-
unknownSession: WIRE_ERROR_CODES.unknownSession,
|
|
113
|
-
staleHead: WIRE_ERROR_CODES.historyConflict,
|
|
114
|
-
invalidRecord: WIRE_ERROR_CODES.invalidParams,
|
|
115
|
-
recordTooLarge: WIRE_ERROR_CODES.invalidParams,
|
|
116
|
-
};
|
|
117
|
-
/** A journal refusal answers the request; any other error is a storage fault. */
|
|
118
|
-
const refusal = (error: unknown) =>
|
|
119
|
-
error instanceof JournalError
|
|
120
|
-
? new WireError(REFUSAL_CODES[error.code], error.message, error.data)
|
|
121
|
-
: undefined;
|
|
125
|
+
private log(sessionId: string): SessionLog {
|
|
126
|
+
const log = this.sessions.get(sessionId);
|
|
127
|
+
if (!log) throw new Error(`session ${sessionId} has no log`);
|
|
128
|
+
return log;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
122
131
|
|
|
123
132
|
/**
|
|
124
133
|
* Every admission and event committed to a journal before it is acknowledged
|
|
@@ -126,19 +135,46 @@ const refusal = (error: unknown) =>
|
|
|
126
135
|
* fails this store for good, and `onFault` stops the server: restart recovery,
|
|
127
136
|
* not this process, decides what the cut-off turns did.
|
|
128
137
|
*/
|
|
129
|
-
export class JournalSessionStore implements
|
|
130
|
-
readonly historyId: string;
|
|
138
|
+
export class JournalSessionStore implements SessionLogStore {
|
|
131
139
|
private fault: { error: unknown } | undefined;
|
|
132
140
|
private readonly releaseClaim: () => void;
|
|
133
141
|
/** After shutdown, a turn that ignored its abort must not write behind a new owner. */
|
|
134
|
-
private
|
|
142
|
+
private relinquished = false;
|
|
143
|
+
/** The seq of each open session's last kept event, which its deltas carry. */
|
|
144
|
+
private readonly heads = new Map<string, number>();
|
|
145
|
+
/** The journal's id for each live native process's record. */
|
|
146
|
+
private readonly recordIds = new Map<NativeRecord, number>();
|
|
135
147
|
|
|
136
148
|
constructor(
|
|
137
149
|
private readonly journal: SessionJournal,
|
|
138
150
|
private readonly onFault: (error: unknown) => void,
|
|
151
|
+
swept?: ClaimOptions,
|
|
139
152
|
) {
|
|
140
|
-
this.
|
|
141
|
-
|
|
153
|
+
this.releaseClaim = journal.claim(swept);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Keep a native process's record from its start until it is seen gone. A
|
|
158
|
+
* record that cannot be written fails its spawn, and the store with it: an
|
|
159
|
+
* agent nobody recorded must get no work. One that cannot be dropped stays
|
|
160
|
+
* for the next start, which finds its process gone.
|
|
161
|
+
*/
|
|
162
|
+
recordNative(event: NativeProcessEvent): void {
|
|
163
|
+
if (event.type === "started") {
|
|
164
|
+
this.recordIds.set(
|
|
165
|
+
event.record,
|
|
166
|
+
this.write(() => this.journal.recordNative(event.record)),
|
|
167
|
+
);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const id = this.recordIds.get(event.record);
|
|
171
|
+
if (id === undefined) return;
|
|
172
|
+
this.recordIds.delete(event.record);
|
|
173
|
+
try {
|
|
174
|
+
this.write(() => this.journal.forgetNative(id));
|
|
175
|
+
} catch {
|
|
176
|
+
// Kept: the next start finds it gone.
|
|
177
|
+
}
|
|
142
178
|
}
|
|
143
179
|
|
|
144
180
|
harnessOf(sessionId: string): AgentHarness | undefined {
|
|
@@ -146,26 +182,32 @@ export class JournalSessionStore implements SessionStore {
|
|
|
146
182
|
return session && !session.closed ? session.harness : undefined;
|
|
147
183
|
}
|
|
148
184
|
duplicateOf(request: RunRequest): { terminal?: TurnEndedEvent } | undefined {
|
|
149
|
-
|
|
150
|
-
if (this.journal.admission(request) === "new") return undefined;
|
|
151
|
-
} catch (error) {
|
|
152
|
-
throw refusal(error) ?? error;
|
|
153
|
-
}
|
|
185
|
+
if (this.journal.admission(request) === "new") return undefined;
|
|
154
186
|
return { terminal: this.journal.turn(request.sessionId, request.turnId)?.terminal };
|
|
155
187
|
}
|
|
156
188
|
open(request: RunRequest): void {
|
|
157
189
|
this.write(() => this.journal.admit(request));
|
|
158
190
|
}
|
|
159
191
|
append(sessionId: string, event: LifecycleEvent): WireEventEnvelope {
|
|
160
|
-
|
|
161
|
-
if (this.fault) throw new EventSinkError(this.fault.error);
|
|
162
|
-
try {
|
|
192
|
+
return this.sink(() => {
|
|
163
193
|
// Only a pre-session `error` may lack its session; this one has one.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
194
|
+
const envelope = this.journal.append(
|
|
195
|
+
event.sessionId === undefined ? { ...event, sessionId } : event,
|
|
196
|
+
);
|
|
197
|
+
if (event.type === "session.ended") this.heads.delete(sessionId);
|
|
198
|
+
else this.heads.set(sessionId, envelope.seq);
|
|
199
|
+
// What the journal stored, as replay and history return it: what the
|
|
200
|
+
// server delivers, and keeps of the session's open parts.
|
|
201
|
+
return envelope;
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
live(sessionId: string, event: MessagePartDeltaEvent): WireEventEnvelope {
|
|
205
|
+
// What a delta streamed is kept until its part's next snapshot, for recovery.
|
|
206
|
+
this.sink(() => this.journal.keepTail(event));
|
|
207
|
+
// A delta follows its turn's `turn.started`, which this store kept.
|
|
208
|
+
const seq = this.heads.get(sessionId);
|
|
209
|
+
if (seq === undefined) throw new Error(`session ${sessionId} has no kept event to follow`);
|
|
210
|
+
return { sessionId, seq, event };
|
|
169
211
|
}
|
|
170
212
|
replay(sessionId: string, fromSeq: number): EventsReplayResult | undefined {
|
|
171
213
|
const session = this.journal.session(sessionId);
|
|
@@ -178,14 +220,22 @@ export class JournalSessionStore implements SessionStore {
|
|
|
178
220
|
hasMore: page.hasMore,
|
|
179
221
|
};
|
|
180
222
|
}
|
|
223
|
+
point(sessionId: string): SessionPoint | undefined {
|
|
224
|
+
const session = this.journal.session(sessionId);
|
|
225
|
+
if (!session || session.closed) return undefined;
|
|
226
|
+
return { headSeq: session.headSeq, firstAvailableSeq: session.headSeq ? 1 : null };
|
|
227
|
+
}
|
|
228
|
+
terminal(sessionId: string, turnId: string): TurnEndedEvent | undefined {
|
|
229
|
+
return this.journal.turn(sessionId, turnId)?.terminal;
|
|
230
|
+
}
|
|
181
231
|
closing(sessionId: string): AgentHarness | undefined {
|
|
182
232
|
const session = this.journal.session(sessionId);
|
|
183
233
|
if (!session || session.closed) return undefined;
|
|
184
234
|
if (session.recoveryRequired)
|
|
185
|
-
throw new
|
|
186
|
-
|
|
235
|
+
throw new JournalError(
|
|
236
|
+
"recoveryRequired",
|
|
187
237
|
"Confirm the native process stopped before closing",
|
|
188
|
-
{ headSeq: session.headSeq },
|
|
238
|
+
{ headSeq: session.headSeq, reason: session.recoveryReason ?? "not_verified" },
|
|
189
239
|
);
|
|
190
240
|
return session.harness;
|
|
191
241
|
}
|
|
@@ -198,25 +248,39 @@ export class JournalSessionStore implements SessionStore {
|
|
|
198
248
|
confirmStopped(sessionId: string, expectedHeadSeq: number): boolean {
|
|
199
249
|
return this.write(() => this.journal.confirmStopped(sessionId, expectedHeadSeq));
|
|
200
250
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this.
|
|
251
|
+
/** The session's native conversation was let go: its next turn must name it. */
|
|
252
|
+
releaseNative(sessionId: string): void {
|
|
253
|
+
this.journal.releaseNative(sessionId);
|
|
254
|
+
}
|
|
255
|
+
relinquish(): void {
|
|
256
|
+
if (this.relinquished) return;
|
|
257
|
+
this.relinquished = true;
|
|
204
258
|
this.releaseClaim();
|
|
205
259
|
}
|
|
206
260
|
|
|
207
|
-
/** A write
|
|
261
|
+
/** A request's write: a refusal answers it, and any other failure fails the store. */
|
|
208
262
|
private write<T>(operation: () => T): T {
|
|
209
|
-
if (this.
|
|
263
|
+
if (this.relinquished) throw new Error("Journal ownership was released");
|
|
210
264
|
if (this.fault) throw new Error("Journal failed; restart and recover before executing");
|
|
211
265
|
try {
|
|
212
266
|
return operation();
|
|
213
267
|
} catch (error) {
|
|
214
|
-
|
|
215
|
-
if (refused) throw refused;
|
|
268
|
+
if (error instanceof JournalError) throw error;
|
|
216
269
|
this.failed(error);
|
|
217
270
|
throw error;
|
|
218
271
|
}
|
|
219
272
|
}
|
|
273
|
+
/** An event's write: one that fails stops its turn (`EventSinkError`) and fails the store. */
|
|
274
|
+
private sink<T>(operation: () => T): T {
|
|
275
|
+
if (this.relinquished) throw new EventSinkError(new Error("Journal ownership was released"));
|
|
276
|
+
if (this.fault) throw new EventSinkError(this.fault.error);
|
|
277
|
+
try {
|
|
278
|
+
return operation();
|
|
279
|
+
} catch (error) {
|
|
280
|
+
this.failed(error);
|
|
281
|
+
throw new EventSinkError(error);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
220
284
|
private failed(error: unknown): void {
|
|
221
285
|
if (this.fault) return;
|
|
222
286
|
this.fault = { error };
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type SessionOverflowParams,
|
|
3
|
+
WIRE_METHODS,
|
|
4
|
+
type WireEventEnvelope,
|
|
5
|
+
WireRefusal,
|
|
6
|
+
type WireTransport,
|
|
7
|
+
encodeNotification,
|
|
8
|
+
isLiveEnvelope,
|
|
9
|
+
} from "../protocol/index.ts";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Sessions a connection may watch (`session/subscribe`; `session/subscribeAll`
|
|
13
|
+
* counts once). The subscriptions its turns hold do not count.
|
|
14
|
+
*/
|
|
15
|
+
export const DEFAULT_MAX_SUBSCRIPTIONS = 256;
|
|
16
|
+
/**
|
|
17
|
+
* How far behind a connection may fall before the server stops streaming it
|
|
18
|
+
* a session: twice a replay page's budget, so one page of catch-up does not
|
|
19
|
+
* overflow a live subscription.
|
|
20
|
+
*/
|
|
21
|
+
export const DEFAULT_MAX_BACKLOG_BYTES = 16 * 1024 * 1024;
|
|
22
|
+
|
|
23
|
+
export interface SubscriptionLimits {
|
|
24
|
+
maxSubscriptions: number;
|
|
25
|
+
maxBacklogBytes: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** What one connection receives. */
|
|
29
|
+
interface Connection {
|
|
30
|
+
/** The sessions it is subscribed to, each with the last kept seq it was sent of it. */
|
|
31
|
+
readonly sessions: Map<string, number>;
|
|
32
|
+
/** Those it watches (`session/subscribe {sessionId}`): until it unsubscribes, or the session ends. */
|
|
33
|
+
readonly watched: Set<string>;
|
|
34
|
+
/** The running turn each other session is streamed to it for: until that turn's `turn.ended`. */
|
|
35
|
+
readonly turns: Map<string, string>;
|
|
36
|
+
/** It subscribed to every session (`session/subscribeAll`). */
|
|
37
|
+
all: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* How a connection is subscribed to a session: it watches it (`session/subscribe
|
|
42
|
+
* {sessionId}`), or follows one running turn of it (`turn/start`,
|
|
43
|
+
* `session/subscribe {sessionId, turnId}`).
|
|
44
|
+
*/
|
|
45
|
+
export type SubscriptionScope = "watch" | { turnId: string };
|
|
46
|
+
|
|
47
|
+
// @ref LLP 0008#design-subscriptions — a connection receives the sessions it subscribes to
|
|
48
|
+
/**
|
|
49
|
+
* The connections the server serves, and the sessions each receives. A
|
|
50
|
+
* session's frames go to the connections subscribed to it, or to every
|
|
51
|
+
* session; filtering delivery, not an authorization boundary. A connection
|
|
52
|
+
* that falls `maxBacklogBytes` behind stops receiving the session it fell
|
|
53
|
+
* behind on (`session/overflow`): every frame it then misses is recoverable,
|
|
54
|
+
* a kept event by replay and a delta by the open part a subscription sends.
|
|
55
|
+
*/
|
|
56
|
+
export class Subscriptions {
|
|
57
|
+
private readonly connections = new Map<WireTransport, Connection>();
|
|
58
|
+
|
|
59
|
+
constructor(private readonly limits: SubscriptionLimits) {}
|
|
60
|
+
|
|
61
|
+
attach(transport: WireTransport): void {
|
|
62
|
+
this.connections.set(transport, {
|
|
63
|
+
sessions: new Map(),
|
|
64
|
+
watched: new Set(),
|
|
65
|
+
turns: new Map(),
|
|
66
|
+
all: false,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** The connection closed: its subscriptions die with it. */
|
|
70
|
+
detach(transport: WireTransport): void {
|
|
71
|
+
this.connections.delete(transport);
|
|
72
|
+
}
|
|
73
|
+
transports(): WireTransport[] {
|
|
74
|
+
return [...this.connections.keys()];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// @ref LLP 0008#caps — the cap bounds what a connection watches, not the turns it runs
|
|
78
|
+
/**
|
|
79
|
+
* Stream `sessionId` to `transport` from `headSeq`. A watch is refused past
|
|
80
|
+
* the cap, before anything changes, and counts from then on, a session
|
|
81
|
+
* first subscribed for its turn included. A turn's subscription is never
|
|
82
|
+
* refused and ends with the turn: each turn is work the caller runs, and
|
|
83
|
+
* bounds itself, and the backlog bound still bounds what the connection is
|
|
84
|
+
* sent.
|
|
85
|
+
*/
|
|
86
|
+
subscribe(
|
|
87
|
+
transport: WireTransport,
|
|
88
|
+
sessionId: string,
|
|
89
|
+
headSeq: number,
|
|
90
|
+
scope: SubscriptionScope,
|
|
91
|
+
): void {
|
|
92
|
+
const connection = this.connections.get(transport);
|
|
93
|
+
if (!connection) return;
|
|
94
|
+
if (scope !== "watch") connection.turns.set(sessionId, scope.turnId);
|
|
95
|
+
else if (!connection.watched.has(sessionId)) {
|
|
96
|
+
this.assertBelowCap(connection);
|
|
97
|
+
connection.watched.add(sessionId);
|
|
98
|
+
}
|
|
99
|
+
connection.sessions.set(sessionId, headSeq);
|
|
100
|
+
}
|
|
101
|
+
subscribeAll(transport: WireTransport): void {
|
|
102
|
+
const connection = this.connections.get(transport);
|
|
103
|
+
if (!connection || connection.all) return;
|
|
104
|
+
this.assertBelowCap(connection);
|
|
105
|
+
connection.all = true;
|
|
106
|
+
}
|
|
107
|
+
/** Stop watching the session; a running turn's own subscription lasts until the turn ends. */
|
|
108
|
+
unsubscribe(transport: WireTransport, sessionId: string): boolean {
|
|
109
|
+
const connection = this.connections.get(transport);
|
|
110
|
+
if (!connection?.watched.delete(sessionId)) return false;
|
|
111
|
+
if (!connection.turns.has(sessionId)) connection.sessions.delete(sessionId);
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
unsubscribeAll(transport: WireTransport): boolean {
|
|
115
|
+
const connection = this.connections.get(transport);
|
|
116
|
+
if (!connection?.all) return false;
|
|
117
|
+
connection.all = false;
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* One frame of a session, to every connection that receives the session.
|
|
123
|
+
* After a `turn.ended`, the connections subscribed for that turn alone are
|
|
124
|
+
* subscribed no more; after `session.ended`, none is: a reused volatile id
|
|
125
|
+
* starts with none.
|
|
126
|
+
*/
|
|
127
|
+
deliver(envelope: WireEventEnvelope): void {
|
|
128
|
+
const { sessionId, event } = envelope;
|
|
129
|
+
let line: string | undefined;
|
|
130
|
+
for (const [transport, connection] of this.connections) {
|
|
131
|
+
if (!receives(connection, sessionId)) continue;
|
|
132
|
+
line ??= encodeNotification(WIRE_METHODS.event, envelope);
|
|
133
|
+
this.send(transport, connection, envelope, line);
|
|
134
|
+
}
|
|
135
|
+
if (event.type === "session.ended")
|
|
136
|
+
for (const connection of this.connections.values()) drop(connection, sessionId);
|
|
137
|
+
else if (event.type === "turn.ended")
|
|
138
|
+
for (const connection of this.connections.values()) {
|
|
139
|
+
if (connection.turns.get(sessionId) !== event.turnId) continue;
|
|
140
|
+
connection.turns.delete(sessionId);
|
|
141
|
+
if (!connection.watched.has(sessionId)) connection.sessions.delete(sessionId);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* A server's own notification, to every connection whatever it follows
|
|
147
|
+
* (`clis/progress`). Small and rare, so no backlog bound; one transport
|
|
148
|
+
* that throws keeps no other from it.
|
|
149
|
+
*/
|
|
150
|
+
notifyAll(method: string, params: unknown): void {
|
|
151
|
+
const line = encodeNotification(method, params);
|
|
152
|
+
for (const transport of this.connections.keys()) {
|
|
153
|
+
try {
|
|
154
|
+
transport.send(line);
|
|
155
|
+
} catch {
|
|
156
|
+
// Its own failure.
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Frames for one connection only: the open parts that follow its subscription. */
|
|
162
|
+
sendTo(transport: WireTransport, envelopes: WireEventEnvelope[]): void {
|
|
163
|
+
const connection = this.connections.get(transport);
|
|
164
|
+
for (const envelope of envelopes) {
|
|
165
|
+
// An overflow on the first of them drops the rest with the subscription.
|
|
166
|
+
if (!connection || !receives(connection, envelope.sessionId)) continue;
|
|
167
|
+
this.send(transport, connection, envelope, encodeNotification(WIRE_METHODS.event, envelope));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private assertBelowCap(connection: Connection): void {
|
|
172
|
+
const held = connection.watched.size + (connection.all ? 1 : 0);
|
|
173
|
+
if (held >= this.limits.maxSubscriptions)
|
|
174
|
+
throw new WireRefusal(
|
|
175
|
+
"subscriptionLimit",
|
|
176
|
+
`this connection watches ${held} sessions; unsubscribe one first`,
|
|
177
|
+
{ limit: this.limits.maxSubscriptions },
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private send(
|
|
182
|
+
transport: WireTransport,
|
|
183
|
+
connection: Connection,
|
|
184
|
+
envelope: WireEventEnvelope,
|
|
185
|
+
line: string,
|
|
186
|
+
): void {
|
|
187
|
+
// @ref LLP 0008#backpressure-and-overflow — over the bound, drop the subscription, not the frame's recovery
|
|
188
|
+
if ((transport.bufferedAmount?.() ?? 0) > this.limits.maxBacklogBytes) {
|
|
189
|
+
this.overflow(transport, connection, envelope.sessionId);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
transport.send(line);
|
|
194
|
+
} catch {
|
|
195
|
+
// One faulty transport must not starve the others; a kept event is in
|
|
196
|
+
// the session log, so the client heals via replay.
|
|
197
|
+
}
|
|
198
|
+
if (!isLiveEnvelope(envelope) && connection.sessions.has(envelope.sessionId))
|
|
199
|
+
connection.sessions.set(envelope.sessionId, envelope.seq);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Stop streaming the session (and, under `session/subscribeAll`, every session) to a connection this far behind. */
|
|
203
|
+
private overflow(transport: WireTransport, connection: Connection, sessionId: string): void {
|
|
204
|
+
const notices: SessionOverflowParams[] = [];
|
|
205
|
+
const lastSeq = connection.sessions.get(sessionId);
|
|
206
|
+
if (lastSeq !== undefined) {
|
|
207
|
+
drop(connection, sessionId);
|
|
208
|
+
notices.push({ sessionId, lastSeq });
|
|
209
|
+
}
|
|
210
|
+
if (connection.all) {
|
|
211
|
+
connection.all = false;
|
|
212
|
+
notices.push({ all: true });
|
|
213
|
+
}
|
|
214
|
+
for (const notice of notices) {
|
|
215
|
+
try {
|
|
216
|
+
transport.send(encodeNotification(WIRE_METHODS.sessionOverflow, notice));
|
|
217
|
+
} catch {
|
|
218
|
+
// A transport that cannot take the notice is closing: its close drops the rest.
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const receives = (connection: Connection, sessionId: string) =>
|
|
225
|
+
connection.all || connection.sessions.has(sessionId);
|
|
226
|
+
|
|
227
|
+
/** The connection's subscription to the session ends, however it was made. */
|
|
228
|
+
function drop(connection: Connection, sessionId: string): void {
|
|
229
|
+
connection.sessions.delete(sessionId);
|
|
230
|
+
connection.watched.delete(sessionId);
|
|
231
|
+
connection.turns.delete(sessionId);
|
|
232
|
+
}
|