@zvada/agent-server 0.3.17 → 0.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +11 -26
- package/CHANGELOG.md +1060 -0
- package/README.md +50 -26
- package/dist/types/accounts/chatgpt.d.ts +34 -0
- package/dist/types/accounts/chatgpt.d.ts.map +1 -0
- package/dist/types/accounts/check.d.ts +24 -0
- package/dist/types/accounts/check.d.ts.map +1 -0
- package/dist/types/accounts/claude.d.ts +21 -0
- package/dist/types/accounts/claude.d.ts.map +1 -0
- package/dist/types/accounts/endpoint.d.ts +50 -0
- package/dist/types/accounts/endpoint.d.ts.map +1 -0
- package/dist/types/accounts/http.d.ts +38 -0
- package/dist/types/accounts/http.d.ts.map +1 -0
- package/dist/types/accounts/index.d.ts +6 -0
- package/dist/types/accounts/index.d.ts.map +1 -0
- package/dist/types/client/client.d.ts +272 -0
- package/dist/types/client/client.d.ts.map +1 -0
- package/dist/types/client/connection.d.ts +160 -0
- package/dist/types/client/connection.d.ts.map +1 -0
- package/dist/types/client/history.d.ts +8 -0
- package/dist/types/client/history.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +5 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/listeners.d.ts +8 -0
- package/dist/types/client/listeners.d.ts.map +1 -0
- package/dist/types/client/logins.d.ts +35 -0
- package/dist/types/client/logins.d.ts.map +1 -0
- package/dist/types/client/rpc.d.ts +46 -0
- package/dist/types/client/rpc.d.ts.map +1 -0
- package/dist/types/client/streams.d.ts +150 -0
- package/dist/types/client/streams.d.ts.map +1 -0
- package/dist/types/client/transports.d.ts +35 -0
- package/dist/types/client/transports.d.ts.map +1 -0
- package/dist/types/client/turns.d.ts +81 -0
- package/dist/types/client/turns.d.ts.map +1 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts +68 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -0
- package/dist/types/core/agents/acp/adapter.d.ts +39 -0
- package/dist/types/core/agents/acp/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/acp/client.d.ts +90 -0
- package/dist/types/core/agents/acp/client.d.ts.map +1 -0
- package/dist/types/core/agents/acp/known-agents.d.ts +35 -0
- package/dist/types/core/agents/acp/known-agents.d.ts.map +1 -0
- package/dist/types/core/agents/acp/mappings.d.ts +46 -0
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -0
- package/dist/types/core/agents/acp/requests.d.ts +26 -0
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -0
- package/dist/types/core/agents/attachments.d.ts +11 -0
- package/dist/types/core/agents/attachments.d.ts.map +1 -0
- package/dist/types/core/agents/base.d.ts +227 -0
- package/dist/types/core/agents/base.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts +58 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts +26 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +70 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts +54 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/events.d.ts +42 -0
- package/dist/types/core/agents/claude-code/events.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/login.d.ts +61 -0
- package/dist/types/core/agents/claude-code/login.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts +52 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/models.d.ts +30 -0
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/options.d.ts +183 -0
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts +50 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts +36 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session.d.ts +148 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts +29 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spend.d.ts +58 -0
- package/dist/types/core/agents/claude-code/spend.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/tools.d.ts +4 -0
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts +52 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn.d.ts +121 -0
- package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts +59 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts +116 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +113 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts +66 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts +49 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts +12 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts +45 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts +20 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts +26 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts +31 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts +38 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +62 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts +67 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts +40 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts +19 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts +99 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts +42 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts +96 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts +53 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts +87 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts +33 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts +163 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts.map +1 -0
- package/dist/types/core/agents/config-fingerprint.d.ts +5 -0
- package/dist/types/core/agents/config-fingerprint.d.ts.map +1 -0
- package/dist/types/core/agents/credentials.d.ts +28 -0
- package/dist/types/core/agents/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/elicitation.d.ts +37 -0
- package/dist/types/core/agents/elicitation.d.ts.map +1 -0
- package/dist/types/core/agents/inherit-config.d.ts +18 -0
- package/dist/types/core/agents/inherit-config.d.ts.map +1 -0
- package/dist/types/core/agents/login.d.ts +67 -0
- package/dist/types/core/agents/login.d.ts.map +1 -0
- package/dist/types/core/agents/mcp-config.d.ts +57 -0
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -0
- package/dist/types/core/agents/plan.d.ts +16 -0
- package/dist/types/core/agents/plan.d.ts.map +1 -0
- package/dist/types/core/agents/registry.d.ts +30 -0
- package/dist/types/core/agents/registry.d.ts.map +1 -0
- package/dist/types/core/agents/session-agent.d.ts +48 -0
- package/dist/types/core/agents/session-agent.d.ts.map +1 -0
- package/dist/types/core/agents/session-pool.d.ts +41 -0
- package/dist/types/core/agents/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/stderr-tail.d.ts +28 -0
- package/dist/types/core/agents/stderr-tail.d.ts.map +1 -0
- package/dist/types/core/agents/thinking-levels.d.ts +4 -0
- package/dist/types/core/agents/thinking-levels.d.ts.map +1 -0
- package/dist/types/core/agents/types.d.ts +124 -0
- package/dist/types/core/agents/types.d.ts.map +1 -0
- package/dist/types/core/diagnostics.d.ts +36 -0
- package/dist/types/core/diagnostics.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +29 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/presets.d.ts +80 -0
- package/dist/types/core/presets.d.ts.map +1 -0
- package/dist/types/core/processes/identity.d.ts +31 -0
- package/dist/types/core/processes/identity.d.ts.map +1 -0
- package/dist/types/core/processes/lifeline.d.ts +47 -0
- package/dist/types/core/processes/lifeline.d.ts.map +1 -0
- package/dist/types/core/processes/native-processes.d.ts +130 -0
- package/dist/types/core/processes/native-processes.d.ts.map +1 -0
- package/dist/types/core/processes/process-table.d.ts +43 -0
- package/dist/types/core/processes/process-table.d.ts.map +1 -0
- package/dist/types/core/provision/cache-trust.d.ts +13 -0
- package/dist/types/core/provision/cache-trust.d.ts.map +1 -0
- package/dist/types/core/provision/cache-usage.d.ts +14 -0
- package/dist/types/core/provision/cache-usage.d.ts.map +1 -0
- package/dist/types/core/provision/checksums.d.ts +46 -0
- package/dist/types/core/provision/checksums.d.ts.map +1 -0
- package/dist/types/core/provision/extract.d.ts +7 -0
- package/dist/types/core/provision/extract.d.ts.map +1 -0
- package/dist/types/core/provision/index.d.ts +5 -0
- package/dist/types/core/provision/index.d.ts.map +1 -0
- package/dist/types/core/provision/install-build.d.ts +36 -0
- package/dist/types/core/provision/install-build.d.ts.map +1 -0
- package/dist/types/core/provision/npm.d.ts +40 -0
- package/dist/types/core/provision/npm.d.ts.map +1 -0
- package/dist/types/core/provision/pins.d.ts +24 -0
- package/dist/types/core/provision/pins.d.ts.map +1 -0
- package/dist/types/core/provision/platform.d.ts +28 -0
- package/dist/types/core/provision/platform.d.ts.map +1 -0
- package/dist/types/core/provision/provisioner.d.ts +189 -0
- package/dist/types/core/provision/provisioner.d.ts.map +1 -0
- package/dist/types/core/provision/releases.d.ts +8 -0
- package/dist/types/core/provision/releases.d.ts.map +1 -0
- package/dist/types/core/provision/tools.d.ts +81 -0
- package/dist/types/core/provision/tools.d.ts.map +1 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts +52 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts.map +1 -0
- package/dist/types/core/proxy/api-key-store.d.ts +37 -0
- package/dist/types/core/proxy/api-key-store.d.ts.map +1 -0
- package/dist/types/core/proxy/index.d.ts +3 -0
- package/dist/types/core/proxy/index.d.ts.map +1 -0
- package/dist/types/core/proxy/loopback.d.ts +14 -0
- package/dist/types/core/proxy/loopback.d.ts.map +1 -0
- package/dist/types/core/runtime/agent-runtime.d.ts +181 -0
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -0
- package/dist/types/core/runtime/event-processor.d.ts +87 -0
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -0
- package/dist/types/core/runtime/event-sink.d.ts +44 -0
- package/dist/types/core/runtime/event-sink.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-clis.d.ts +10 -0
- package/dist/types/core/runtime/harness-clis.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-logins.d.ts +68 -0
- package/dist/types/core/runtime/harness-logins.d.ts.map +1 -0
- package/dist/types/core/runtime/login-reads.d.ts +28 -0
- package/dist/types/core/runtime/login-reads.d.ts.map +1 -0
- package/dist/types/core/runtime/model-lists.d.ts +37 -0
- package/dist/types/core/runtime/model-lists.d.ts.map +1 -0
- package/dist/types/core/runtime/permission-policy.d.ts +61 -0
- package/dist/types/core/runtime/permission-policy.d.ts.map +1 -0
- package/dist/types/core/runtime/request-broker.d.ts +49 -0
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -0
- package/dist/types/core/runtime/steering.d.ts +38 -0
- package/dist/types/core/runtime/steering.d.ts.map +1 -0
- package/dist/types/core/runtime/turn-outcome.d.ts +21 -0
- package/dist/types/core/runtime/turn-outcome.d.ts.map +1 -0
- package/dist/types/core/runtime/turn.d.ts +121 -0
- package/dist/types/core/runtime/turn.d.ts.map +1 -0
- package/dist/types/core/utils/bounded.d.ts +6 -0
- package/dist/types/core/utils/bounded.d.ts.map +1 -0
- package/dist/types/core/utils/deadline.d.ts +14 -0
- package/dist/types/core/utils/deadline.d.ts.map +1 -0
- package/dist/types/core/utils/errors.d.ts +104 -0
- package/dist/types/core/utils/errors.d.ts.map +1 -0
- package/dist/types/core/utils/is-record.d.ts +3 -0
- package/dist/types/core/utils/is-record.d.ts.map +1 -0
- package/dist/types/core/utils/loopback.d.ts +6 -0
- package/dist/types/core/utils/loopback.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/protocol/account.d.ts +26 -0
- package/dist/types/protocol/account.d.ts.map +1 -0
- package/dist/types/protocol/async-queue.d.ts +21 -0
- package/dist/types/protocol/async-queue.d.ts.map +1 -0
- package/dist/types/protocol/auth.d.ts +228 -0
- package/dist/types/protocol/auth.d.ts.map +1 -0
- package/dist/types/protocol/canonical.d.ts +9 -0
- package/dist/types/protocol/canonical.d.ts.map +1 -0
- package/dist/types/protocol/clis.d.ts +74 -0
- package/dist/types/protocol/clis.d.ts.map +1 -0
- package/dist/types/protocol/config.d.ts +200 -0
- package/dist/types/protocol/config.d.ts.map +1 -0
- package/dist/types/protocol/conversation.d.ts +942 -0
- package/dist/types/protocol/conversation.d.ts.map +1 -0
- package/dist/types/protocol/credentials.d.ts +145 -0
- package/dist/types/protocol/credentials.d.ts.map +1 -0
- package/dist/types/protocol/errors.d.ts +36 -0
- package/dist/types/protocol/errors.d.ts.map +1 -0
- package/dist/types/protocol/execution.d.ts +28 -0
- package/dist/types/protocol/execution.d.ts.map +1 -0
- package/dist/types/protocol/factories.d.ts +94 -0
- package/dist/types/protocol/factories.d.ts.map +1 -0
- package/dist/types/protocol/guards.d.ts +55 -0
- package/dist/types/protocol/guards.d.ts.map +1 -0
- package/dist/types/protocol/harness.d.ts +70 -0
- package/dist/types/protocol/harness.d.ts.map +1 -0
- package/dist/types/protocol/history.d.ts +318 -0
- package/dist/types/protocol/history.d.ts.map +1 -0
- package/dist/types/protocol/ids.d.ts +9 -0
- package/dist/types/protocol/ids.d.ts.map +1 -0
- package/dist/types/protocol/index.d.ts +35 -0
- package/dist/types/protocol/index.d.ts.map +1 -0
- package/dist/types/protocol/lifecycle.d.ts +1190 -0
- package/dist/types/protocol/lifecycle.d.ts.map +1 -0
- package/dist/types/protocol/meta-keys.d.ts +17 -0
- package/dist/types/protocol/meta-keys.d.ts.map +1 -0
- package/dist/types/protocol/meta.d.ts +13 -0
- package/dist/types/protocol/meta.d.ts.map +1 -0
- package/dist/types/protocol/model-catalog.d.ts +11 -0
- package/dist/types/protocol/model-catalog.d.ts.map +1 -0
- package/dist/types/protocol/models.d.ts +107 -0
- package/dist/types/protocol/models.d.ts.map +1 -0
- package/dist/types/protocol/part-input.d.ts +101 -0
- package/dist/types/protocol/part-input.d.ts.map +1 -0
- package/dist/types/protocol/parts.d.ts +357 -0
- package/dist/types/protocol/parts.d.ts.map +1 -0
- package/dist/types/protocol/reduce.d.ts +26 -0
- package/dist/types/protocol/reduce.d.ts.map +1 -0
- package/dist/types/protocol/selectors.d.ts +64 -0
- package/dist/types/protocol/selectors.d.ts.map +1 -0
- package/dist/types/protocol/seq-cursor.d.ts +66 -0
- package/dist/types/protocol/seq-cursor.d.ts.map +1 -0
- package/dist/types/protocol/stop-reasons.d.ts +33 -0
- package/dist/types/protocol/stop-reasons.d.ts.map +1 -0
- package/dist/types/protocol/thinking.d.ts +28 -0
- package/dist/types/protocol/thinking.d.ts.map +1 -0
- package/dist/types/protocol/time.d.ts +21 -0
- package/dist/types/protocol/time.d.ts.map +1 -0
- package/dist/types/protocol/tokens.d.ts +29 -0
- package/dist/types/protocol/tokens.d.ts.map +1 -0
- package/dist/types/protocol/tool-closure.d.ts +25 -0
- package/dist/types/protocol/tool-closure.d.ts.map +1 -0
- package/dist/types/protocol/tool-state.d.ts +209 -0
- package/dist/types/protocol/tool-state.d.ts.map +1 -0
- package/dist/types/protocol/verify.d.ts +52 -0
- package/dist/types/protocol/verify.d.ts.map +1 -0
- package/dist/types/protocol/vocabulary.d.ts +19 -0
- package/dist/types/protocol/vocabulary.d.ts.map +1 -0
- package/dist/types/protocol/wire-api.d.ts +1983 -0
- package/dist/types/protocol/wire-api.d.ts.map +1 -0
- package/dist/types/protocol/wire.d.ts +1758 -0
- package/dist/types/protocol/wire.d.ts.map +1 -0
- package/dist/types/server/acp/binding.d.ts +33 -0
- package/dist/types/server/acp/binding.d.ts.map +1 -0
- package/dist/types/server/acp/session-records.d.ts +17 -0
- package/dist/types/server/acp/session-records.d.ts.map +1 -0
- package/dist/types/server/acp/translate.d.ts +48 -0
- package/dist/types/server/acp/translate.d.ts.map +1 -0
- package/dist/types/server/agent-server.d.ts +121 -0
- package/dist/types/server/agent-server.d.ts.map +1 -0
- package/dist/types/server/feedback.d.ts +37 -0
- package/dist/types/server/feedback.d.ts.map +1 -0
- package/dist/types/server/history.d.ts +15 -0
- package/dist/types/server/history.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +7 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/types/server/install.d.ts +42 -0
- package/dist/types/server/install.d.ts.map +1 -0
- package/dist/types/server/open-parts.d.ts +27 -0
- package/dist/types/server/open-parts.d.ts.map +1 -0
- package/dist/types/server/routes.d.ts +61 -0
- package/dist/types/server/routes.d.ts.map +1 -0
- package/dist/types/server/secrets.d.ts +11 -0
- package/dist/types/server/secrets.d.ts.map +1 -0
- package/dist/types/server/session-gate.d.ts +32 -0
- package/dist/types/server/session-gate.d.ts.map +1 -0
- package/dist/types/server/session-log.d.ts +39 -0
- package/dist/types/server/session-log.d.ts.map +1 -0
- package/dist/types/server/session-store.d.ts +119 -0
- package/dist/types/server/session-store.d.ts.map +1 -0
- package/dist/types/server/subscriptions.d.ts +74 -0
- package/dist/types/server/subscriptions.d.ts.map +1 -0
- package/dist/types/server/transports.d.ts +74 -0
- package/dist/types/server/transports.d.ts.map +1 -0
- package/dist/types/server/wire-error.d.ts +9 -0
- package/dist/types/server/wire-error.d.ts.map +1 -0
- package/dist/types/sync/event-log.d.ts +45 -0
- package/dist/types/sync/event-log.d.ts.map +1 -0
- package/dist/types/sync/fit.d.ts +40 -0
- package/dist/types/sync/fit.d.ts.map +1 -0
- package/dist/types/sync/history-reader.d.ts +8 -0
- package/dist/types/sync/history-reader.d.ts.map +1 -0
- package/dist/types/sync/history-sqlite.d.ts +37 -0
- package/dist/types/sync/history-sqlite.d.ts.map +1 -0
- package/dist/types/sync/history.d.ts +70 -0
- package/dist/types/sync/history.d.ts.map +1 -0
- package/dist/types/sync/index.d.ts +4 -0
- package/dist/types/sync/index.d.ts.map +1 -0
- package/dist/types/sync/journal-sqlite.d.ts +51 -0
- package/dist/types/sync/journal-sqlite.d.ts.map +1 -0
- package/dist/types/sync/journal.d.ts +107 -0
- package/dist/types/sync/journal.d.ts.map +1 -0
- package/dist/types/sync/live-tails.d.ts +30 -0
- package/dist/types/sync/live-tails.d.ts.map +1 -0
- package/dist/types/sync/node-sqlite.d.ts +7 -0
- package/dist/types/sync/node-sqlite.d.ts.map +1 -0
- package/dist/types/sync/projection.d.ts +10 -0
- package/dist/types/sync/projection.d.ts.map +1 -0
- package/dist/types/sync/recovery.d.ts +25 -0
- package/dist/types/sync/recovery.d.ts.map +1 -0
- package/dist/types/sync/retry.d.ts +25 -0
- package/dist/types/sync/retry.d.ts.map +1 -0
- package/dist/types/sync/schema.d.ts +4 -0
- package/dist/types/sync/schema.d.ts.map +1 -0
- package/dist/types/sync/sql.d.ts +38 -0
- package/dist/types/sync/sql.d.ts.map +1 -0
- package/dist/types/sync/sqlite-file.d.ts +9 -0
- package/dist/types/sync/sqlite-file.d.ts.map +1 -0
- package/dist/types/sync/sqlite.d.ts +6 -0
- package/dist/types/sync/sqlite.d.ts.map +1 -0
- package/dist/types/sync/worker.d.ts +63 -0
- package/dist/types/sync/worker.d.ts.map +1 -0
- package/docs/consuming.md +460 -54
- package/docs/deploy.md +218 -47
- package/docs/durable-sessions.md +195 -0
- package/docs/feedback.md +116 -0
- package/docs/harnesses.md +219 -87
- package/docs/sync-history.md +197 -0
- package/docs/sync-integration.md +119 -0
- package/package.json +53 -23
- package/src/accounts/chatgpt.ts +194 -0
- package/src/accounts/check.ts +112 -0
- package/src/accounts/claude.ts +111 -0
- package/src/accounts/endpoint.ts +151 -0
- package/src/accounts/http.ts +97 -0
- package/src/accounts/index.ts +19 -0
- package/src/client/client.ts +641 -602
- package/src/client/connection.ts +371 -0
- package/src/client/history.ts +65 -0
- package/src/client/index.ts +11 -2
- package/src/client/listeners.ts +20 -0
- package/src/client/logins.ts +105 -0
- package/src/client/rpc.ts +144 -0
- package/src/client/streams.ts +488 -0
- package/src/client/transports.ts +62 -8
- package/src/client/turns.ts +171 -0
- package/src/core/agents/acp/acp-agent.ts +94 -118
- package/src/core/agents/acp/adapter.ts +20 -9
- package/src/core/agents/acp/client.ts +125 -47
- package/src/core/agents/acp/known-agents.ts +36 -4
- package/src/core/agents/acp/mappings.ts +64 -18
- package/src/core/agents/acp/requests.ts +125 -0
- package/src/core/agents/attachments.ts +18 -0
- package/src/core/agents/base.ts +120 -42
- package/src/core/agents/claude-code/adapter.ts +177 -238
- package/src/core/agents/claude-code/approvals.ts +270 -0
- package/src/core/agents/claude-code/claude-agent.ts +175 -158
- package/src/core/agents/claude-code/credentials.ts +171 -0
- package/src/core/agents/claude-code/events.ts +55 -0
- package/src/core/agents/claude-code/login.ts +269 -0
- package/src/core/agents/claude-code/mcp.ts +206 -0
- package/src/core/agents/claude-code/models.ts +15 -9
- package/src/core/agents/claude-code/options.ts +326 -39
- package/src/core/agents/claude-code/outcome.ts +209 -0
- package/src/core/agents/claude-code/session-pool.ts +136 -0
- package/src/core/agents/claude-code/session.ts +513 -0
- package/src/core/agents/claude-code/spawn.ts +144 -0
- package/src/core/agents/claude-code/spend.ts +160 -0
- package/src/core/agents/claude-code/tools.ts +47 -0
- package/src/core/agents/claude-code/turn-usage.ts +135 -0
- package/src/core/agents/claude-code/turn.ts +232 -0
- package/src/core/agents/codex-app-server/adapter.ts +314 -117
- package/src/core/agents/codex-app-server/client.ts +186 -84
- package/src/core/agents/codex-app-server/codex-agent.ts +343 -0
- package/src/core/agents/codex-app-server/commands.ts +228 -0
- package/src/core/agents/codex-app-server/credentials.ts +126 -0
- package/src/core/agents/codex-app-server/effort.ts +29 -0
- package/src/core/agents/codex-app-server/events.ts +47 -0
- package/src/core/agents/codex-app-server/homes.ts +64 -0
- package/src/core/agents/codex-app-server/input.ts +60 -0
- package/src/core/agents/codex-app-server/items.ts +149 -0
- package/src/core/agents/codex-app-server/login.ts +180 -0
- package/src/core/agents/codex-app-server/mcp.ts +182 -37
- package/src/core/agents/codex-app-server/models.ts +99 -46
- package/src/core/agents/codex-app-server/options.ts +146 -0
- package/src/core/agents/codex-app-server/plan-approval.ts +135 -0
- package/src/core/agents/codex-app-server/protocol.ts +117 -0
- package/src/core/agents/codex-app-server/requests.ts +332 -0
- package/src/core/agents/codex-app-server/session.ts +285 -0
- package/src/core/agents/codex-app-server/subagents.ts +108 -42
- package/src/core/agents/codex-app-server/thread-settings.ts +279 -0
- package/src/core/agents/codex-app-server/turn-items.ts +88 -0
- package/src/core/agents/codex-app-server/turn.ts +463 -0
- package/src/core/agents/config-fingerprint.ts +7 -14
- package/src/core/agents/credentials.ts +98 -0
- package/src/core/agents/elicitation.ts +75 -0
- package/src/core/agents/inherit-config.ts +21 -0
- package/src/core/agents/login.ts +116 -0
- package/src/core/agents/mcp-config.ts +112 -8
- package/src/core/agents/plan.ts +25 -0
- package/src/core/agents/registry.ts +21 -4
- package/src/core/agents/session-agent.ts +96 -4
- package/src/core/agents/{session-store.ts → session-pool.ts} +11 -5
- package/src/core/agents/stderr-tail.ts +75 -0
- package/src/core/agents/types.ts +40 -5
- package/src/core/index.ts +60 -48
- package/src/core/presets.ts +100 -39
- package/src/core/processes/identity.ts +113 -0
- package/src/core/processes/lifeline.ts +170 -0
- package/src/core/processes/native-processes.ts +379 -0
- package/src/core/processes/process-table.ts +174 -0
- package/src/core/provision/cache-trust.ts +121 -0
- package/src/core/provision/cache-usage.ts +69 -0
- package/src/core/provision/checksums.ts +64 -0
- package/src/core/provision/extract.ts +11 -2
- package/src/core/provision/index.ts +4 -1
- package/src/core/provision/install-build.ts +136 -0
- package/src/core/provision/npm.ts +112 -17
- package/src/core/provision/pins.ts +11 -34
- package/src/core/provision/platform.ts +12 -1
- package/src/core/provision/provisioner.ts +329 -397
- package/src/core/provision/releases.ts +86 -0
- package/src/core/provision/tools.ts +329 -0
- package/src/core/proxy/anthropic-proxy.ts +55 -25
- package/src/core/proxy/api-key-store.ts +2 -12
- package/src/core/proxy/loopback.ts +106 -0
- package/src/core/runtime/agent-runtime.ts +340 -481
- package/src/core/runtime/event-processor.ts +207 -75
- package/src/core/runtime/event-sink.ts +45 -2
- package/src/core/runtime/harness-clis.ts +61 -0
- package/src/core/runtime/harness-logins.ts +328 -0
- package/src/core/runtime/login-reads.ts +78 -0
- package/src/core/runtime/model-lists.ts +57 -57
- package/src/core/runtime/permission-policy.ts +113 -0
- package/src/core/runtime/request-broker.ts +204 -0
- package/src/core/runtime/steering.ts +112 -0
- package/src/core/runtime/turn-outcome.ts +30 -0
- package/src/core/runtime/turn.ts +360 -0
- package/src/core/utils/bounded.ts +12 -0
- package/src/core/utils/deadline.ts +38 -0
- package/src/core/utils/errors.ts +113 -21
- package/src/core/utils/is-record.ts +4 -0
- package/src/core/utils/loopback.ts +10 -0
- package/src/protocol/account.ts +104 -0
- package/src/protocol/auth.ts +199 -0
- package/src/protocol/canonical.ts +16 -0
- package/src/protocol/clis.ts +69 -0
- package/src/protocol/config.ts +60 -6
- package/src/protocol/conversation.ts +272 -0
- package/src/protocol/credentials.ts +145 -0
- package/src/protocol/errors.ts +78 -20
- package/src/protocol/execution.ts +5 -2
- package/src/protocol/factories.ts +55 -7
- package/src/protocol/guards.ts +55 -2
- package/src/protocol/harness.ts +56 -6
- package/src/protocol/history.ts +275 -0
- package/src/protocol/ids.ts +4 -17
- package/src/protocol/index.ts +10 -0
- package/src/protocol/lifecycle.ts +250 -79
- package/src/protocol/meta-keys.ts +17 -0
- package/src/protocol/meta.ts +3 -3
- package/src/protocol/models.ts +2 -43
- package/src/protocol/part-input.ts +2 -1
- package/src/protocol/parts.ts +12 -3
- package/src/protocol/reduce.ts +302 -413
- package/src/protocol/selectors.ts +1 -20
- package/src/protocol/seq-cursor.ts +14 -0
- package/src/protocol/stop-reasons.ts +1 -1
- package/src/protocol/thinking.ts +1 -30
- package/src/protocol/time.ts +2 -2
- package/src/protocol/tool-closure.ts +93 -0
- package/src/protocol/tool-state.ts +19 -4
- package/src/protocol/verify.ts +222 -92
- package/src/protocol/vocabulary.ts +21 -5
- package/src/protocol/wire-api.ts +232 -0
- package/src/protocol/wire.ts +425 -57
- package/src/server/acp/binding.ts +63 -103
- package/src/server/acp/session-records.ts +53 -0
- package/src/server/acp/translate.ts +129 -20
- package/src/server/agent-server.ts +275 -366
- package/src/server/bin.ts +295 -72
- package/src/server/feedback.ts +204 -14
- package/src/server/history.ts +160 -0
- package/src/server/index.ts +4 -8
- package/src/server/install.ts +107 -8
- package/src/server/open-parts.ts +95 -0
- package/src/server/routes.ts +391 -0
- package/src/server/secrets.ts +24 -0
- package/src/server/session-gate.ts +69 -0
- package/src/server/session-log.ts +14 -2
- package/src/server/session-store.ts +289 -0
- package/src/server/subscriptions.ts +232 -0
- package/src/server/transports.ts +125 -25
- package/src/server/wire-error.ts +38 -0
- package/src/sync/event-log.ts +160 -0
- package/src/sync/fit.ts +140 -0
- package/src/sync/history-reader.ts +57 -0
- package/src/sync/history-sqlite.ts +339 -0
- package/src/sync/history.ts +220 -0
- package/src/sync/index.ts +18 -0
- package/src/sync/journal-sqlite.ts +439 -0
- package/src/sync/journal.ts +132 -0
- package/src/sync/live-tails.ts +107 -0
- package/src/sync/node-sqlite.ts +20 -0
- package/src/sync/projection.ts +35 -0
- package/src/sync/recovery.ts +141 -0
- package/src/sync/retry.ts +49 -0
- package/src/sync/schema.ts +77 -0
- package/src/sync/sql.ts +106 -0
- package/src/sync/sqlite-file.ts +38 -0
- package/src/sync/sqlite.ts +21 -0
- package/src/sync/worker.ts +259 -0
- package/docs/rfds/0001-deterministic-echo-ids.md +0 -44
- package/docs/rfds/0002-native-subagents.md +0 -197
- package/src/core/agents/claude-code/generator-session.ts +0 -572
- package/src/core/agents/claude-code/session-manager.ts +0 -166
- package/src/core/agents/codex-app-server/codex-app-server-agent.ts +0 -962
- package/src/core/agents/codex-items.ts +0 -149
- package/src/core/agents/codex-sdk/adapter.ts +0 -237
- package/src/core/agents/codex-sdk/codex-sdk-agent.ts +0 -330
- package/src/core/agents/tool-meta.ts +0 -68
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import type { AgentRuntime, RunSummary } from "../core/index.ts";
|
|
2
|
+
import {
|
|
3
|
+
type AgentCapabilities,
|
|
4
|
+
type AgentHarness,
|
|
5
|
+
type HistoryMethod,
|
|
6
|
+
type InitializeResult,
|
|
7
|
+
type RunRequest,
|
|
8
|
+
type SessionSubscribeResult,
|
|
9
|
+
type TurnEndedEvent,
|
|
10
|
+
WIRE_METHODS,
|
|
11
|
+
WIRE_PROTOCOL_VERSION,
|
|
12
|
+
type WireEventEnvelope,
|
|
13
|
+
type WireParsedParams,
|
|
14
|
+
WireRefusal,
|
|
15
|
+
type WireRequestMethod,
|
|
16
|
+
type WireResult,
|
|
17
|
+
type WireTransport,
|
|
18
|
+
generateUUIDv7,
|
|
19
|
+
} from "../protocol/index.ts";
|
|
20
|
+
import type { OpenParts } from "./open-parts.ts";
|
|
21
|
+
import type { SessionGate } from "./session-gate.ts";
|
|
22
|
+
import type { JournalSessionStore, SessionLogStore } from "./session-store.ts";
|
|
23
|
+
import type { SubscriptionScope, Subscriptions } from "./subscriptions.ts";
|
|
24
|
+
|
|
25
|
+
/** What a request's handler may ask of the connection it came on. */
|
|
26
|
+
export interface RouteContext {
|
|
27
|
+
transport: WireTransport;
|
|
28
|
+
/** Run `then` once the response is sent, or failed to send: work that must not precede it. */
|
|
29
|
+
afterResponse(then: () => void): void;
|
|
30
|
+
}
|
|
31
|
+
type Answer<M extends WireRequestMethod> = WireResult<M> | Promise<WireResult<M>>;
|
|
32
|
+
/**
|
|
33
|
+
* A request's handler, given its params as `WIRE_API` parses them: what it
|
|
34
|
+
* returns is the response; what it throws, the error response.
|
|
35
|
+
*/
|
|
36
|
+
export type Route<M extends WireRequestMethod> = (
|
|
37
|
+
params: WireParsedParams<M>,
|
|
38
|
+
context: RouteContext,
|
|
39
|
+
) => Answer<M>;
|
|
40
|
+
/** A handler that reads its own params: one that must refuse a caller before it reads what it sent. */
|
|
41
|
+
export interface UnparsedRoute<M extends WireRequestMethod> {
|
|
42
|
+
readonly unparsed: (params: unknown, context: RouteContext) => Answer<M>;
|
|
43
|
+
}
|
|
44
|
+
/** One handler per method: a method without one does not compile. */
|
|
45
|
+
export type Routes<Methods extends WireRequestMethod> = {
|
|
46
|
+
readonly [M in Methods]: Route<M> | UnparsedRoute<M>;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** The methods only a server with a journal answers. */
|
|
50
|
+
type DurableMethod =
|
|
51
|
+
| typeof WIRE_METHODS.turnGet
|
|
52
|
+
| typeof WIRE_METHODS.sessionGet
|
|
53
|
+
| typeof WIRE_METHODS.sessionConfirmStopped
|
|
54
|
+
| typeof WIRE_METHODS.sessionRelease;
|
|
55
|
+
/** What every server answers (a server serving history answers `history/*` too). */
|
|
56
|
+
type ExecutionMethod = Exclude<WireRequestMethod, DurableMethod | HistoryMethod>;
|
|
57
|
+
|
|
58
|
+
/** What the routes run on: the server's runtime, session logs and turns. */
|
|
59
|
+
export interface RouteHost {
|
|
60
|
+
readonly runtime: AgentRuntime;
|
|
61
|
+
readonly store: SessionLogStore;
|
|
62
|
+
/** Each session's open parts and latest turn start, as the server delivered them. */
|
|
63
|
+
readonly openParts: OpenParts;
|
|
64
|
+
readonly gate: SessionGate;
|
|
65
|
+
/** Which connections receive which sessions. */
|
|
66
|
+
readonly subscriptions: Subscriptions;
|
|
67
|
+
/** The `initialize` result's fixed fields. */
|
|
68
|
+
readonly identity: Pick<InitializeResult, "server" | "instanceId" | "historyId">;
|
|
69
|
+
/** False once the server stopped taking turns. */
|
|
70
|
+
accepting(): boolean;
|
|
71
|
+
/** Run an admitted turn: its events go to its log and every transport. */
|
|
72
|
+
executeTurn(request: RunRequest): void;
|
|
73
|
+
broadcast(envelope: WireEventEnvelope): void;
|
|
74
|
+
/** Cancel every turn, and wait until each one's `turn.ended` was broadcast. */
|
|
75
|
+
drainTurns(): Promise<void>;
|
|
76
|
+
shutdown(): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function assertHarness(runtime: AgentRuntime, harness: AgentHarness): void {
|
|
80
|
+
if (!runtime.harnesses.includes(harness))
|
|
81
|
+
throw new WireRefusal("harnessNotAvailable", `harness not available: ${harness}`, {
|
|
82
|
+
available: runtime.harnesses,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** A settled turn's end, from the summary the runtime converges a retry on. */
|
|
87
|
+
function endedOf(summary: RunSummary): TurnEndedEvent {
|
|
88
|
+
return {
|
|
89
|
+
type: "turn.ended",
|
|
90
|
+
sessionId: summary.sessionId,
|
|
91
|
+
turnId: summary.turnId,
|
|
92
|
+
stopReason: summary.stopReason,
|
|
93
|
+
finishReason: summary.finishReason,
|
|
94
|
+
tokens: summary.usage,
|
|
95
|
+
cost: summary.cost,
|
|
96
|
+
execution: summary.execution,
|
|
97
|
+
error: summary.error,
|
|
98
|
+
...(summary.undeliveredSteers?.length && { undeliveredSteers: summary.undeliveredSteers }),
|
|
99
|
+
timestamp: Date.now(),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The routes every server has, one per method: a method without one does not compile. */
|
|
104
|
+
export function executionRoutes(host: RouteHost): Routes<ExecutionMethod> {
|
|
105
|
+
const { runtime, store, openParts, gate, subscriptions } = host;
|
|
106
|
+
/** A retried start the runtime converges on: a volatile store holds no receipts, only its log. */
|
|
107
|
+
const converged = (request: RunRequest): { terminal?: TurnEndedEvent } | undefined => {
|
|
108
|
+
const admission = runtime.admission(request);
|
|
109
|
+
if (admission.status === "new") return undefined;
|
|
110
|
+
// Its `turn.ended` may be out before the runtime settles it.
|
|
111
|
+
const terminal =
|
|
112
|
+
store.terminal(request.sessionId, request.turnId) ??
|
|
113
|
+
(admission.status === "completed" ? endedOf(admission.summary) : undefined);
|
|
114
|
+
return terminal ? { terminal } : {};
|
|
115
|
+
};
|
|
116
|
+
/** Where a subscription to the session starts now, with the turn it runs. */
|
|
117
|
+
const pointOf = (sessionId: string): SessionSubscribeResult | undefined => {
|
|
118
|
+
const point = store.point(sessionId);
|
|
119
|
+
if (!point) return undefined;
|
|
120
|
+
const active = gate.activeTurn(sessionId);
|
|
121
|
+
const startedSeq = active && openParts.startedSeq(sessionId, active.turnId);
|
|
122
|
+
return {
|
|
123
|
+
...point,
|
|
124
|
+
...(active && {
|
|
125
|
+
activeTurn: { turnId: active.turnId, ...(startedSeq !== undefined && { startedSeq }) },
|
|
126
|
+
}),
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
// @ref LLP 0008#ordering-joining-without-a-gap-or-a-duplicate — read, register, answer, send: one synchronous block
|
|
130
|
+
/**
|
|
131
|
+
* Subscribe the connection at `headSeq`, the point its answer marks; the
|
|
132
|
+
* session's open parts follow the answer. All of it before any other frame
|
|
133
|
+
* can be sent, so each of the session's frames reaches the connection once:
|
|
134
|
+
* kept events up to the point by replay, after it pushed, deltas before it
|
|
135
|
+
* folded into an open part, after it pushed.
|
|
136
|
+
*/
|
|
137
|
+
const subscribeAt = (
|
|
138
|
+
context: RouteContext,
|
|
139
|
+
sessionId: string,
|
|
140
|
+
headSeq: number,
|
|
141
|
+
scope: SubscriptionScope,
|
|
142
|
+
) => {
|
|
143
|
+
subscriptions.subscribe(context.transport, sessionId, headSeq, scope);
|
|
144
|
+
const open = openParts.of(sessionId, headSeq);
|
|
145
|
+
if (open.length) context.afterResponse(() => subscriptions.sendTo(context.transport, open));
|
|
146
|
+
};
|
|
147
|
+
const runs = (sessionId: string, turnId: string) => gate.activeTurn(sessionId)?.turnId === turnId;
|
|
148
|
+
return {
|
|
149
|
+
[WIRE_METHODS.initialize]: ({ protocolVersion }) => {
|
|
150
|
+
if (protocolVersion !== WIRE_PROTOCOL_VERSION)
|
|
151
|
+
throw new WireRefusal(
|
|
152
|
+
"protocolVersionMismatch",
|
|
153
|
+
`unsupported protocol version: ${protocolVersion}`,
|
|
154
|
+
{ supported: [WIRE_PROTOCOL_VERSION] },
|
|
155
|
+
);
|
|
156
|
+
const harnesses: Record<string, AgentCapabilities> = {};
|
|
157
|
+
for (const harness of runtime.harnesses) harnesses[harness] = runtime.capabilities(harness);
|
|
158
|
+
return { protocolVersion: WIRE_PROTOCOL_VERSION, ...host.identity, harnesses };
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
[WIRE_METHODS.turnStart]: (parsed, context) => {
|
|
162
|
+
if (!host.accepting()) throw new WireRefusal("shuttingDown", "server is shutting down");
|
|
163
|
+
const { config, input } = parsed;
|
|
164
|
+
assertHarness(runtime, config.harness);
|
|
165
|
+
const sessionId = parsed.sessionId ?? generateUUIDv7();
|
|
166
|
+
const turnId = parsed.turnId ?? generateUUIDv7();
|
|
167
|
+
// Refused in this order: a session closing, then a retry (which
|
|
168
|
+
// converges instead), another harness, a running turn.
|
|
169
|
+
gate.assertOpen(sessionId);
|
|
170
|
+
// The caller wants the turn's stream (unless it says otherwise), until
|
|
171
|
+
// the turn ends. Never refused: the cap bounds what a connection
|
|
172
|
+
// watches, not the turns it runs.
|
|
173
|
+
const subscribe = parsed.subscribe !== false;
|
|
174
|
+
// Idempotent admission: a retried start (same turnId, identical
|
|
175
|
+
// input) converges — ack again, never run twice, and subscribe its
|
|
176
|
+
// caller to the turn while it runs. A durable store remembers every
|
|
177
|
+
// turn it admitted, the runtime only its recent ones. The same turnId
|
|
178
|
+
// with different input is a caller bug → turnConflict.
|
|
179
|
+
const request = { sessionId, turnId, input, config };
|
|
180
|
+
const duplicate = store.duplicateOf(request) ?? converged(request);
|
|
181
|
+
if (duplicate) {
|
|
182
|
+
const headSeq = store.point(sessionId)?.headSeq;
|
|
183
|
+
if (subscribe && headSeq !== undefined && runs(sessionId, turnId))
|
|
184
|
+
subscribeAt(context, sessionId, headSeq, { turnId });
|
|
185
|
+
const startedSeq = duplicate.terminal ? undefined : openParts.startedSeq(sessionId, turnId);
|
|
186
|
+
return {
|
|
187
|
+
sessionId,
|
|
188
|
+
turnId,
|
|
189
|
+
deduplicated: true,
|
|
190
|
+
headSeq: headSeq ?? 0,
|
|
191
|
+
...(startedSeq !== undefined && { startedSeq }),
|
|
192
|
+
...(duplicate.terminal && { terminal: duplicate.terminal }),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const bound = store.harnessOf(sessionId);
|
|
196
|
+
if (bound && bound !== config.harness)
|
|
197
|
+
throw new WireRefusal("invalidParams", `session ${sessionId} is bound to harness ${bound}`);
|
|
198
|
+
gate.assertIdle(sessionId);
|
|
199
|
+
store.open(request);
|
|
200
|
+
gate.begin(sessionId, { turnId, harness: config.harness });
|
|
201
|
+
// The point before the turn's first event: its caller downloads no history.
|
|
202
|
+
const headSeq = store.point(sessionId)?.headSeq ?? 0;
|
|
203
|
+
if (subscribe) subscriptions.subscribe(context.transport, sessionId, headSeq, { turnId });
|
|
204
|
+
// Quick-ack before the first event can possibly be emitted. The turn
|
|
205
|
+
// runs (and releases its session) even if the requester is gone.
|
|
206
|
+
context.afterResponse(() => host.executeTurn(request));
|
|
207
|
+
return { sessionId, turnId, headSeq };
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
[WIRE_METHODS.turnCancel]: async ({ sessionId, turnId }) => {
|
|
211
|
+
const active = gate.activeTurn(sessionId);
|
|
212
|
+
if (!active) return { outcome: "no_active_turn" };
|
|
213
|
+
// Turn-stamped cancel for a turn that is no longer the active one —
|
|
214
|
+
// refuse to kill its successor; report who IS active instead.
|
|
215
|
+
if (turnId && turnId !== active.turnId)
|
|
216
|
+
return { outcome: "no_active_turn", activeTurnId: active.turnId };
|
|
217
|
+
const { confirmed, hadTurn } = await runtime.cancel(active.harness, sessionId);
|
|
218
|
+
// An unacknowledged interrupt is NOT a cancel: the agent may still be
|
|
219
|
+
// running and `turn.ended` stays the source of truth. `hadTurn: false`
|
|
220
|
+
// while the server tracks an active turn is the pre-first-yield window
|
|
221
|
+
// (between the turn/start quick-ack and the harness registering its
|
|
222
|
+
// abortable turn) — the abort landed on nothing and the turn may run
|
|
223
|
+
// to completion, so it must report `unconfirmed`, never a clean cancel.
|
|
224
|
+
return {
|
|
225
|
+
outcome: confirmed && hadTurn ? "cancelled" : "unconfirmed",
|
|
226
|
+
turnId: active.turnId,
|
|
227
|
+
};
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
// @ref LLP 0001#d13--input-while-a-turn-runs-steers-it — the runtime decides
|
|
231
|
+
[WIRE_METHODS.turnSteer]: ({ sessionId, turnId, steerId, input }) =>
|
|
232
|
+
runtime.steer(sessionId, { turnId, steerId: steerId ?? generateUUIDv7(), input }),
|
|
233
|
+
|
|
234
|
+
[WIRE_METHODS.sessionClose]: async ({ sessionId }) => {
|
|
235
|
+
gate.assertIdle(sessionId);
|
|
236
|
+
const harness = store.closing(sessionId);
|
|
237
|
+
if (!harness) return { closed: false };
|
|
238
|
+
return gate.whileClosing(sessionId, "closing", async () => {
|
|
239
|
+
await runtime.closeSession(harness, sessionId);
|
|
240
|
+
// The terminal fact for CONNECTED subscribers: they learn the
|
|
241
|
+
// session is over from the stream, not from the RPC result (which
|
|
242
|
+
// only the closer sees). Appending it retires the session.
|
|
243
|
+
host.broadcast(
|
|
244
|
+
store.append(sessionId, {
|
|
245
|
+
type: "session.ended",
|
|
246
|
+
sessionId,
|
|
247
|
+
reason: "closed",
|
|
248
|
+
timestamp: Date.now(),
|
|
249
|
+
}),
|
|
250
|
+
);
|
|
251
|
+
return { closed: true };
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
[WIRE_METHODS.permissionRespond]: ({ sessionId, requestId, outcome }) => ({
|
|
256
|
+
accepted: runtime.respondPermission(sessionId, requestId, outcome),
|
|
257
|
+
}),
|
|
258
|
+
|
|
259
|
+
[WIRE_METHODS.elicitationRespond]: ({ sessionId, requestId, outcome }) => ({
|
|
260
|
+
accepted: runtime.respondElicitation(sessionId, requestId, outcome),
|
|
261
|
+
}),
|
|
262
|
+
|
|
263
|
+
[WIRE_METHODS.sessionSubscribe]: ({ sessionId, turnId }, context) => {
|
|
264
|
+
const point = pointOf(sessionId);
|
|
265
|
+
if (!point) throw new WireRefusal("unknownSession", `unknown session: ${sessionId}`);
|
|
266
|
+
// A turn that is not running subscribes nothing: its events, its end
|
|
267
|
+
// included, are kept up to the point (the answer's `activeTurn` tells).
|
|
268
|
+
if (turnId === undefined) subscribeAt(context, sessionId, point.headSeq, "watch");
|
|
269
|
+
else if (runs(sessionId, turnId)) subscribeAt(context, sessionId, point.headSeq, { turnId });
|
|
270
|
+
return point;
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
[WIRE_METHODS.sessionUnsubscribe]: ({ sessionId }, { transport }) => ({
|
|
274
|
+
unsubscribed: subscriptions.unsubscribe(transport, sessionId),
|
|
275
|
+
}),
|
|
276
|
+
|
|
277
|
+
[WIRE_METHODS.sessionSubscribeAll]: (_params, context) => {
|
|
278
|
+
subscriptions.subscribeAll(context.transport);
|
|
279
|
+
const sessions = gate.running().flatMap((sessionId) => {
|
|
280
|
+
const point = pointOf(sessionId);
|
|
281
|
+
return point ? [{ sessionId, ...point }] : [];
|
|
282
|
+
});
|
|
283
|
+
const open = sessions.flatMap(({ sessionId, headSeq }) => openParts.of(sessionId, headSeq));
|
|
284
|
+
if (open.length) context.afterResponse(() => subscriptions.sendTo(context.transport, open));
|
|
285
|
+
return { sessions };
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
[WIRE_METHODS.sessionUnsubscribeAll]: (_params, { transport }) => ({
|
|
289
|
+
unsubscribed: subscriptions.unsubscribeAll(transport),
|
|
290
|
+
}),
|
|
291
|
+
|
|
292
|
+
[WIRE_METHODS.eventsReplay]: ({ sessionId, fromSeq }) => {
|
|
293
|
+
const replayed = store.replay(sessionId, fromSeq);
|
|
294
|
+
if (!replayed) throw new WireRefusal("unknownSession", `unknown session: ${sessionId}`);
|
|
295
|
+
return replayed;
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
[WIRE_METHODS.modelsList]: (parsed) => {
|
|
299
|
+
assertHarness(runtime, parsed.harness);
|
|
300
|
+
return runtime.models(parsed);
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
[WIRE_METHODS.clisList]: async ({ harnesses }) => {
|
|
304
|
+
for (const harness of harnesses ?? []) assertHarness(runtime, harness);
|
|
305
|
+
return { clis: await runtime.listClis(harnesses) };
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
// @ref LLP 0001#d9--the-wire-is-quick-ack-json-rpc-requests-flow-one-way — an install outlasts any request's deadline
|
|
309
|
+
[WIRE_METHODS.clisPrepare]: async ({ harnesses }) => {
|
|
310
|
+
for (const harness of harnesses ?? []) assertHarness(runtime, harness);
|
|
311
|
+
// Started, and answered at once: what is not ready yet is `installing`,
|
|
312
|
+
// and `clis/progress` and `clis/list` say how it ends.
|
|
313
|
+
void runtime.prepareClis(harnesses).catch(() => {});
|
|
314
|
+
return { clis: await runtime.listClis(harnesses) };
|
|
315
|
+
},
|
|
316
|
+
|
|
317
|
+
[WIRE_METHODS.authStatus]: async ({ harnesses, env }) => {
|
|
318
|
+
for (const harness of harnesses ?? []) assertHarness(runtime, harness);
|
|
319
|
+
return { auth: await runtime.authStatus(harnesses, env) };
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
// @ref LLP 0011#the-wire — answered once the CLI says where to sign in; `auth/updated` says how it ended
|
|
323
|
+
[WIRE_METHODS.authLogin]: (params) => {
|
|
324
|
+
assertHarness(runtime, params.harness);
|
|
325
|
+
return runtime.login(params);
|
|
326
|
+
},
|
|
327
|
+
|
|
328
|
+
[WIRE_METHODS.authComplete]: ({ loginId, code }) => runtime.completeLogin(loginId, code),
|
|
329
|
+
|
|
330
|
+
[WIRE_METHODS.authCancel]: ({ loginId }) => ({ outcome: runtime.cancelLogin(loginId) }),
|
|
331
|
+
|
|
332
|
+
[WIRE_METHODS.authLogout]: ({ harness, env }) => {
|
|
333
|
+
assertHarness(runtime, harness);
|
|
334
|
+
return runtime.logout(harness, env);
|
|
335
|
+
},
|
|
336
|
+
|
|
337
|
+
[WIRE_METHODS.shutdown]: async (_params, { afterResponse }) => {
|
|
338
|
+
// Answer once the turns drained, so the client that asked hears their
|
|
339
|
+
// turn.ended (cancelled) before the answer, then close. A drain that
|
|
340
|
+
// throws still gets its one answer: shutting down reports nothing more.
|
|
341
|
+
await host.drainTurns().catch(() => {});
|
|
342
|
+
afterResponse(() => void host.shutdown().catch(() => {}));
|
|
343
|
+
return {};
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* The routes only a server with a journal has: a volatile session has no
|
|
350
|
+
* receipt, no fence to lift and no journal to ask its next turn for a
|
|
351
|
+
* conversation it let go (`session/close` frees it), so a volatile server
|
|
352
|
+
* answers these `methodNotFound`.
|
|
353
|
+
*/
|
|
354
|
+
export function durableRoutes(
|
|
355
|
+
store: JournalSessionStore,
|
|
356
|
+
{ runtime, gate }: Pick<RouteHost, "runtime" | "gate">,
|
|
357
|
+
): Routes<DurableMethod> {
|
|
358
|
+
return {
|
|
359
|
+
[WIRE_METHODS.turnGet]: ({ sessionId, turnId }) => {
|
|
360
|
+
const receipt = store.receipt(sessionId, turnId);
|
|
361
|
+
if (receipt) return receipt;
|
|
362
|
+
throw store.session(sessionId)
|
|
363
|
+
? new WireRefusal("unknownTurn", `unknown turn: ${turnId}`)
|
|
364
|
+
: new WireRefusal("unknownSession", `unknown session: ${sessionId}`);
|
|
365
|
+
},
|
|
366
|
+
|
|
367
|
+
[WIRE_METHODS.sessionGet]: ({ sessionId }) => {
|
|
368
|
+
const session = store.session(sessionId);
|
|
369
|
+
if (!session) throw new WireRefusal("unknownSession", `unknown session: ${sessionId}`);
|
|
370
|
+
return session;
|
|
371
|
+
},
|
|
372
|
+
|
|
373
|
+
[WIRE_METHODS.sessionConfirmStopped]: ({ sessionId, expectedHeadSeq }) => ({
|
|
374
|
+
recovered: store.confirmStopped(sessionId, expectedHeadSeq),
|
|
375
|
+
}),
|
|
376
|
+
|
|
377
|
+
// @ref LLP 0003#releasing-without-closing — free the agent, keep the session
|
|
378
|
+
[WIRE_METHODS.sessionRelease]: async ({ sessionId }) => {
|
|
379
|
+
gate.assertIdle(sessionId);
|
|
380
|
+
const harness = store.harnessOf(sessionId);
|
|
381
|
+
if (!harness) return { released: false };
|
|
382
|
+
return gate.whileClosing(sessionId, "releasing", async () => {
|
|
383
|
+
// First, so no turn admitted later runs without naming its
|
|
384
|
+
// conversation: the runtime is about to forget which one it was.
|
|
385
|
+
store.releaseNative(sessionId);
|
|
386
|
+
await runtime.closeSession(harness, sessionId);
|
|
387
|
+
return { released: true };
|
|
388
|
+
});
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** The secrets the server reads from its environment: what a listener, `--dial` and `--credentials-url` present. */
|
|
2
|
+
const SERVER_SECRETS = [
|
|
3
|
+
"AGENT_SERVER_TOKEN",
|
|
4
|
+
"AGENT_SERVER_DIAL_TOKEN",
|
|
5
|
+
"AGENT_SERVER_CREDENTIALS_TOKEN",
|
|
6
|
+
] as const;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Take this server's secrets out of its environment, answering them: every
|
|
10
|
+
* CLI the server starts inherits the environment, and the tools those run
|
|
11
|
+
* with it, so a secret left there is one an agent can read. An empty one
|
|
12
|
+
* stays empty, for its user to refuse.
|
|
13
|
+
*/
|
|
14
|
+
export function takeSecrets(
|
|
15
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
16
|
+
): Record<(typeof SERVER_SECRETS)[number], string | undefined> {
|
|
17
|
+
return Object.fromEntries(
|
|
18
|
+
SERVER_SECRETS.map((name) => {
|
|
19
|
+
const value = env[name]?.trim();
|
|
20
|
+
delete env[name];
|
|
21
|
+
return [name, value];
|
|
22
|
+
}),
|
|
23
|
+
) as Record<(typeof SERVER_SECRETS)[number], string | undefined>;
|
|
24
|
+
}
|
|
@@ -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;
|