@zvada/agent-server 0.3.18 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +11 -26
- package/CHANGELOG.md +1041 -1
- package/README.md +40 -40
- package/dist/types/accounts/chatgpt.d.ts +34 -0
- package/dist/types/accounts/chatgpt.d.ts.map +1 -0
- package/dist/types/accounts/check.d.ts +24 -0
- package/dist/types/accounts/check.d.ts.map +1 -0
- package/dist/types/accounts/claude.d.ts +21 -0
- package/dist/types/accounts/claude.d.ts.map +1 -0
- package/dist/types/accounts/endpoint.d.ts +50 -0
- package/dist/types/accounts/endpoint.d.ts.map +1 -0
- package/dist/types/accounts/http.d.ts +38 -0
- package/dist/types/accounts/http.d.ts.map +1 -0
- package/dist/types/accounts/index.d.ts +6 -0
- package/dist/types/accounts/index.d.ts.map +1 -0
- package/dist/types/client/client.d.ts +272 -0
- package/dist/types/client/client.d.ts.map +1 -0
- package/dist/types/client/connection.d.ts +160 -0
- package/dist/types/client/connection.d.ts.map +1 -0
- package/dist/types/client/history.d.ts +8 -0
- package/dist/types/client/history.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +5 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/listeners.d.ts +8 -0
- package/dist/types/client/listeners.d.ts.map +1 -0
- package/dist/types/client/logins.d.ts +35 -0
- package/dist/types/client/logins.d.ts.map +1 -0
- package/dist/types/client/rpc.d.ts +46 -0
- package/dist/types/client/rpc.d.ts.map +1 -0
- package/dist/types/client/streams.d.ts +150 -0
- package/dist/types/client/streams.d.ts.map +1 -0
- package/dist/types/client/transports.d.ts +35 -0
- package/dist/types/client/transports.d.ts.map +1 -0
- package/dist/types/client/turns.d.ts +81 -0
- package/dist/types/client/turns.d.ts.map +1 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts +68 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -0
- package/dist/types/core/agents/acp/adapter.d.ts +39 -0
- package/dist/types/core/agents/acp/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/acp/client.d.ts +90 -0
- package/dist/types/core/agents/acp/client.d.ts.map +1 -0
- package/dist/types/core/agents/acp/known-agents.d.ts +35 -0
- package/dist/types/core/agents/acp/known-agents.d.ts.map +1 -0
- package/dist/types/core/agents/acp/mappings.d.ts +46 -0
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -0
- package/dist/types/core/agents/acp/requests.d.ts +26 -0
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -0
- package/dist/types/core/agents/attachments.d.ts +11 -0
- package/dist/types/core/agents/attachments.d.ts.map +1 -0
- package/dist/types/core/agents/base.d.ts +227 -0
- package/dist/types/core/agents/base.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts +58 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts +26 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +70 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts +54 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/events.d.ts +42 -0
- package/dist/types/core/agents/claude-code/events.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/login.d.ts +61 -0
- package/dist/types/core/agents/claude-code/login.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts +52 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/models.d.ts +30 -0
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/options.d.ts +183 -0
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts +50 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts +36 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session.d.ts +148 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts +29 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spend.d.ts +58 -0
- package/dist/types/core/agents/claude-code/spend.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/tools.d.ts +4 -0
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts +52 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn.d.ts +121 -0
- package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts +59 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts +116 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +113 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts +66 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts +49 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts +12 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts +45 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts +20 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts +26 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts +31 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts +38 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +62 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts +67 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts +40 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts +19 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts +99 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts +42 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts +96 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts +53 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts +87 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts +33 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts +163 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts.map +1 -0
- package/dist/types/core/agents/config-fingerprint.d.ts +5 -0
- package/dist/types/core/agents/config-fingerprint.d.ts.map +1 -0
- package/dist/types/core/agents/credentials.d.ts +28 -0
- package/dist/types/core/agents/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/elicitation.d.ts +37 -0
- package/dist/types/core/agents/elicitation.d.ts.map +1 -0
- package/dist/types/core/agents/inherit-config.d.ts +18 -0
- package/dist/types/core/agents/inherit-config.d.ts.map +1 -0
- package/dist/types/core/agents/login.d.ts +67 -0
- package/dist/types/core/agents/login.d.ts.map +1 -0
- package/dist/types/core/agents/mcp-config.d.ts +57 -0
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -0
- package/dist/types/core/agents/plan.d.ts +16 -0
- package/dist/types/core/agents/plan.d.ts.map +1 -0
- package/dist/types/core/agents/registry.d.ts +30 -0
- package/dist/types/core/agents/registry.d.ts.map +1 -0
- package/dist/types/core/agents/session-agent.d.ts +48 -0
- package/dist/types/core/agents/session-agent.d.ts.map +1 -0
- package/dist/types/core/agents/session-pool.d.ts +41 -0
- package/dist/types/core/agents/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/stderr-tail.d.ts +28 -0
- package/dist/types/core/agents/stderr-tail.d.ts.map +1 -0
- package/dist/types/core/agents/thinking-levels.d.ts +4 -0
- package/dist/types/core/agents/thinking-levels.d.ts.map +1 -0
- package/dist/types/core/agents/types.d.ts +124 -0
- package/dist/types/core/agents/types.d.ts.map +1 -0
- package/dist/types/core/diagnostics.d.ts +36 -0
- package/dist/types/core/diagnostics.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +29 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/presets.d.ts +80 -0
- package/dist/types/core/presets.d.ts.map +1 -0
- package/dist/types/core/processes/identity.d.ts +31 -0
- package/dist/types/core/processes/identity.d.ts.map +1 -0
- package/dist/types/core/processes/lifeline.d.ts +47 -0
- package/dist/types/core/processes/lifeline.d.ts.map +1 -0
- package/dist/types/core/processes/native-processes.d.ts +130 -0
- package/dist/types/core/processes/native-processes.d.ts.map +1 -0
- package/dist/types/core/processes/process-table.d.ts +43 -0
- package/dist/types/core/processes/process-table.d.ts.map +1 -0
- package/dist/types/core/provision/cache-trust.d.ts +13 -0
- package/dist/types/core/provision/cache-trust.d.ts.map +1 -0
- package/dist/types/core/provision/cache-usage.d.ts +14 -0
- package/dist/types/core/provision/cache-usage.d.ts.map +1 -0
- package/dist/types/core/provision/checksums.d.ts +46 -0
- package/dist/types/core/provision/checksums.d.ts.map +1 -0
- package/dist/types/core/provision/extract.d.ts +7 -0
- package/dist/types/core/provision/extract.d.ts.map +1 -0
- package/dist/types/core/provision/index.d.ts +5 -0
- package/dist/types/core/provision/index.d.ts.map +1 -0
- package/dist/types/core/provision/install-build.d.ts +36 -0
- package/dist/types/core/provision/install-build.d.ts.map +1 -0
- package/dist/types/core/provision/npm.d.ts +40 -0
- package/dist/types/core/provision/npm.d.ts.map +1 -0
- package/dist/types/core/provision/pins.d.ts +24 -0
- package/dist/types/core/provision/pins.d.ts.map +1 -0
- package/dist/types/core/provision/platform.d.ts +28 -0
- package/dist/types/core/provision/platform.d.ts.map +1 -0
- package/dist/types/core/provision/provisioner.d.ts +189 -0
- package/dist/types/core/provision/provisioner.d.ts.map +1 -0
- package/dist/types/core/provision/releases.d.ts +8 -0
- package/dist/types/core/provision/releases.d.ts.map +1 -0
- package/dist/types/core/provision/tools.d.ts +81 -0
- package/dist/types/core/provision/tools.d.ts.map +1 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts +52 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts.map +1 -0
- package/dist/types/core/proxy/api-key-store.d.ts +37 -0
- package/dist/types/core/proxy/api-key-store.d.ts.map +1 -0
- package/dist/types/core/proxy/index.d.ts +3 -0
- package/dist/types/core/proxy/index.d.ts.map +1 -0
- package/dist/types/core/proxy/loopback.d.ts +14 -0
- package/dist/types/core/proxy/loopback.d.ts.map +1 -0
- package/dist/types/core/runtime/agent-runtime.d.ts +181 -0
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -0
- package/dist/types/core/runtime/event-processor.d.ts +87 -0
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -0
- package/dist/types/core/runtime/event-sink.d.ts +44 -0
- package/dist/types/core/runtime/event-sink.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-clis.d.ts +10 -0
- package/dist/types/core/runtime/harness-clis.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-logins.d.ts +68 -0
- package/dist/types/core/runtime/harness-logins.d.ts.map +1 -0
- package/dist/types/core/runtime/login-reads.d.ts +28 -0
- package/dist/types/core/runtime/login-reads.d.ts.map +1 -0
- package/dist/types/core/runtime/model-lists.d.ts +37 -0
- package/dist/types/core/runtime/model-lists.d.ts.map +1 -0
- package/dist/types/core/runtime/permission-policy.d.ts +61 -0
- package/dist/types/core/runtime/permission-policy.d.ts.map +1 -0
- package/dist/types/core/runtime/request-broker.d.ts +49 -0
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -0
- package/dist/types/core/runtime/steering.d.ts +38 -0
- package/dist/types/core/runtime/steering.d.ts.map +1 -0
- package/dist/types/core/runtime/turn-outcome.d.ts +21 -0
- package/dist/types/core/runtime/turn-outcome.d.ts.map +1 -0
- package/dist/types/core/runtime/turn.d.ts +121 -0
- package/dist/types/core/runtime/turn.d.ts.map +1 -0
- package/dist/types/core/utils/bounded.d.ts +6 -0
- package/dist/types/core/utils/bounded.d.ts.map +1 -0
- package/dist/types/core/utils/deadline.d.ts +14 -0
- package/dist/types/core/utils/deadline.d.ts.map +1 -0
- package/dist/types/core/utils/errors.d.ts +104 -0
- package/dist/types/core/utils/errors.d.ts.map +1 -0
- package/dist/types/core/utils/is-record.d.ts +3 -0
- package/dist/types/core/utils/is-record.d.ts.map +1 -0
- package/dist/types/core/utils/loopback.d.ts +6 -0
- package/dist/types/core/utils/loopback.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/protocol/account.d.ts +26 -0
- package/dist/types/protocol/account.d.ts.map +1 -0
- package/dist/types/protocol/async-queue.d.ts +21 -0
- package/dist/types/protocol/async-queue.d.ts.map +1 -0
- package/dist/types/protocol/auth.d.ts +228 -0
- package/dist/types/protocol/auth.d.ts.map +1 -0
- package/dist/types/protocol/canonical.d.ts +9 -0
- package/dist/types/protocol/canonical.d.ts.map +1 -0
- package/dist/types/protocol/clis.d.ts +74 -0
- package/dist/types/protocol/clis.d.ts.map +1 -0
- package/dist/types/protocol/config.d.ts +200 -0
- package/dist/types/protocol/config.d.ts.map +1 -0
- package/dist/types/protocol/conversation.d.ts +942 -0
- package/dist/types/protocol/conversation.d.ts.map +1 -0
- package/dist/types/protocol/credentials.d.ts +145 -0
- package/dist/types/protocol/credentials.d.ts.map +1 -0
- package/dist/types/protocol/errors.d.ts +36 -0
- package/dist/types/protocol/errors.d.ts.map +1 -0
- package/dist/types/protocol/execution.d.ts +28 -0
- package/dist/types/protocol/execution.d.ts.map +1 -0
- package/dist/types/protocol/factories.d.ts +94 -0
- package/dist/types/protocol/factories.d.ts.map +1 -0
- package/dist/types/protocol/guards.d.ts +55 -0
- package/dist/types/protocol/guards.d.ts.map +1 -0
- package/dist/types/protocol/harness.d.ts +70 -0
- package/dist/types/protocol/harness.d.ts.map +1 -0
- package/dist/types/protocol/history.d.ts +318 -0
- package/dist/types/protocol/history.d.ts.map +1 -0
- package/dist/types/protocol/ids.d.ts +9 -0
- package/dist/types/protocol/ids.d.ts.map +1 -0
- package/dist/types/protocol/index.d.ts +35 -0
- package/dist/types/protocol/index.d.ts.map +1 -0
- package/dist/types/protocol/lifecycle.d.ts +1190 -0
- package/dist/types/protocol/lifecycle.d.ts.map +1 -0
- package/dist/types/protocol/meta-keys.d.ts +17 -0
- package/dist/types/protocol/meta-keys.d.ts.map +1 -0
- package/dist/types/protocol/meta.d.ts +13 -0
- package/dist/types/protocol/meta.d.ts.map +1 -0
- package/dist/types/protocol/model-catalog.d.ts +11 -0
- package/dist/types/protocol/model-catalog.d.ts.map +1 -0
- package/dist/types/protocol/models.d.ts +107 -0
- package/dist/types/protocol/models.d.ts.map +1 -0
- package/dist/types/protocol/part-input.d.ts +101 -0
- package/dist/types/protocol/part-input.d.ts.map +1 -0
- package/dist/types/protocol/parts.d.ts +357 -0
- package/dist/types/protocol/parts.d.ts.map +1 -0
- package/dist/types/protocol/reduce.d.ts +26 -0
- package/dist/types/protocol/reduce.d.ts.map +1 -0
- package/dist/types/protocol/selectors.d.ts +64 -0
- package/dist/types/protocol/selectors.d.ts.map +1 -0
- package/dist/types/protocol/seq-cursor.d.ts +66 -0
- package/dist/types/protocol/seq-cursor.d.ts.map +1 -0
- package/dist/types/protocol/stop-reasons.d.ts +33 -0
- package/dist/types/protocol/stop-reasons.d.ts.map +1 -0
- package/dist/types/protocol/thinking.d.ts +28 -0
- package/dist/types/protocol/thinking.d.ts.map +1 -0
- package/dist/types/protocol/time.d.ts +21 -0
- package/dist/types/protocol/time.d.ts.map +1 -0
- package/dist/types/protocol/tokens.d.ts +29 -0
- package/dist/types/protocol/tokens.d.ts.map +1 -0
- package/dist/types/protocol/tool-closure.d.ts +25 -0
- package/dist/types/protocol/tool-closure.d.ts.map +1 -0
- package/dist/types/protocol/tool-state.d.ts +209 -0
- package/dist/types/protocol/tool-state.d.ts.map +1 -0
- package/dist/types/protocol/verify.d.ts +52 -0
- package/dist/types/protocol/verify.d.ts.map +1 -0
- package/dist/types/protocol/vocabulary.d.ts +19 -0
- package/dist/types/protocol/vocabulary.d.ts.map +1 -0
- package/dist/types/protocol/wire-api.d.ts +1983 -0
- package/dist/types/protocol/wire-api.d.ts.map +1 -0
- package/dist/types/protocol/wire.d.ts +1758 -0
- package/dist/types/protocol/wire.d.ts.map +1 -0
- package/dist/types/server/acp/binding.d.ts +33 -0
- package/dist/types/server/acp/binding.d.ts.map +1 -0
- package/dist/types/server/acp/session-records.d.ts +17 -0
- package/dist/types/server/acp/session-records.d.ts.map +1 -0
- package/dist/types/server/acp/translate.d.ts +48 -0
- package/dist/types/server/acp/translate.d.ts.map +1 -0
- package/dist/types/server/agent-server.d.ts +121 -0
- package/dist/types/server/agent-server.d.ts.map +1 -0
- package/dist/types/server/feedback.d.ts +37 -0
- package/dist/types/server/feedback.d.ts.map +1 -0
- package/dist/types/server/history.d.ts +15 -0
- package/dist/types/server/history.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +7 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/types/server/install.d.ts +42 -0
- package/dist/types/server/install.d.ts.map +1 -0
- package/dist/types/server/open-parts.d.ts +27 -0
- package/dist/types/server/open-parts.d.ts.map +1 -0
- package/dist/types/server/routes.d.ts +61 -0
- package/dist/types/server/routes.d.ts.map +1 -0
- package/dist/types/server/secrets.d.ts +11 -0
- package/dist/types/server/secrets.d.ts.map +1 -0
- package/dist/types/server/session-gate.d.ts +32 -0
- package/dist/types/server/session-gate.d.ts.map +1 -0
- package/dist/types/server/session-log.d.ts +39 -0
- package/dist/types/server/session-log.d.ts.map +1 -0
- package/dist/types/server/session-store.d.ts +119 -0
- package/dist/types/server/session-store.d.ts.map +1 -0
- package/dist/types/server/subscriptions.d.ts +74 -0
- package/dist/types/server/subscriptions.d.ts.map +1 -0
- package/dist/types/server/transports.d.ts +74 -0
- package/dist/types/server/transports.d.ts.map +1 -0
- package/dist/types/server/wire-error.d.ts +9 -0
- package/dist/types/server/wire-error.d.ts.map +1 -0
- package/dist/types/sync/event-log.d.ts +45 -0
- package/dist/types/sync/event-log.d.ts.map +1 -0
- package/dist/types/sync/fit.d.ts +40 -0
- package/dist/types/sync/fit.d.ts.map +1 -0
- package/dist/types/sync/history-reader.d.ts +8 -0
- package/dist/types/sync/history-reader.d.ts.map +1 -0
- package/dist/types/sync/history-sqlite.d.ts +37 -0
- package/dist/types/sync/history-sqlite.d.ts.map +1 -0
- package/dist/types/sync/history.d.ts +70 -0
- package/dist/types/sync/history.d.ts.map +1 -0
- package/dist/types/sync/index.d.ts +4 -0
- package/dist/types/sync/index.d.ts.map +1 -0
- package/dist/types/sync/journal-sqlite.d.ts +51 -0
- package/dist/types/sync/journal-sqlite.d.ts.map +1 -0
- package/dist/types/sync/journal.d.ts +107 -0
- package/dist/types/sync/journal.d.ts.map +1 -0
- package/dist/types/sync/live-tails.d.ts +30 -0
- package/dist/types/sync/live-tails.d.ts.map +1 -0
- package/dist/types/sync/node-sqlite.d.ts +7 -0
- package/dist/types/sync/node-sqlite.d.ts.map +1 -0
- package/dist/types/sync/projection.d.ts +10 -0
- package/dist/types/sync/projection.d.ts.map +1 -0
- package/dist/types/sync/recovery.d.ts +25 -0
- package/dist/types/sync/recovery.d.ts.map +1 -0
- package/dist/types/sync/retry.d.ts +25 -0
- package/dist/types/sync/retry.d.ts.map +1 -0
- package/dist/types/sync/schema.d.ts +4 -0
- package/dist/types/sync/schema.d.ts.map +1 -0
- package/dist/types/sync/sql.d.ts +38 -0
- package/dist/types/sync/sql.d.ts.map +1 -0
- package/dist/types/sync/sqlite-file.d.ts +9 -0
- package/dist/types/sync/sqlite-file.d.ts.map +1 -0
- package/dist/types/sync/sqlite.d.ts +6 -0
- package/dist/types/sync/sqlite.d.ts.map +1 -0
- package/dist/types/sync/worker.d.ts +63 -0
- package/dist/types/sync/worker.d.ts.map +1 -0
- package/docs/consuming.md +452 -53
- package/docs/deploy.md +218 -47
- package/docs/{sync-experiment.md → durable-sessions.md} +77 -72
- package/docs/feedback.md +116 -0
- package/docs/harnesses.md +212 -88
- package/docs/sync-history.md +29 -13
- package/docs/sync-integration.md +52 -66
- package/package.json +45 -28
- package/src/accounts/chatgpt.ts +194 -0
- package/src/accounts/check.ts +112 -0
- package/src/accounts/claude.ts +111 -0
- package/src/accounts/endpoint.ts +151 -0
- package/src/accounts/http.ts +97 -0
- package/src/accounts/index.ts +19 -0
- package/src/client/client.ts +604 -670
- package/src/client/connection.ts +371 -0
- package/src/client/history.ts +29 -52
- package/src/client/index.ts +11 -2
- package/src/client/listeners.ts +20 -0
- package/src/client/logins.ts +105 -0
- package/src/client/rpc.ts +155 -0
- package/src/client/streams.ts +488 -0
- package/src/client/transports.ts +62 -8
- package/src/client/turns.ts +171 -0
- package/src/core/agents/acp/acp-agent.ts +94 -118
- package/src/core/agents/acp/adapter.ts +20 -9
- package/src/core/agents/acp/client.ts +125 -47
- package/src/core/agents/acp/known-agents.ts +36 -4
- package/src/core/agents/acp/mappings.ts +64 -18
- package/src/core/agents/acp/requests.ts +125 -0
- package/src/core/agents/attachments.ts +18 -0
- package/src/core/agents/base.ts +120 -42
- package/src/core/agents/claude-code/adapter.ts +177 -238
- package/src/core/agents/claude-code/approvals.ts +270 -0
- package/src/core/agents/claude-code/claude-agent.ts +175 -158
- package/src/core/agents/claude-code/credentials.ts +171 -0
- package/src/core/agents/claude-code/events.ts +55 -0
- package/src/core/agents/claude-code/login.ts +269 -0
- package/src/core/agents/claude-code/mcp.ts +206 -0
- package/src/core/agents/claude-code/models.ts +15 -9
- package/src/core/agents/claude-code/options.ts +326 -39
- package/src/core/agents/claude-code/outcome.ts +209 -0
- package/src/core/agents/claude-code/session-pool.ts +136 -0
- package/src/core/agents/claude-code/session.ts +513 -0
- package/src/core/agents/claude-code/spawn.ts +144 -0
- package/src/core/agents/claude-code/spend.ts +160 -0
- package/src/core/agents/claude-code/tools.ts +47 -0
- package/src/core/agents/claude-code/turn-usage.ts +135 -0
- package/src/core/agents/claude-code/turn.ts +232 -0
- package/src/core/agents/codex-app-server/adapter.ts +314 -117
- package/src/core/agents/codex-app-server/client.ts +186 -84
- package/src/core/agents/codex-app-server/codex-agent.ts +343 -0
- package/src/core/agents/codex-app-server/commands.ts +228 -0
- package/src/core/agents/codex-app-server/credentials.ts +126 -0
- package/src/core/agents/codex-app-server/effort.ts +29 -0
- package/src/core/agents/codex-app-server/events.ts +47 -0
- package/src/core/agents/codex-app-server/homes.ts +64 -0
- package/src/core/agents/codex-app-server/input.ts +60 -0
- package/src/core/agents/codex-app-server/items.ts +149 -0
- package/src/core/agents/codex-app-server/login.ts +180 -0
- package/src/core/agents/codex-app-server/mcp.ts +182 -37
- package/src/core/agents/codex-app-server/models.ts +99 -46
- package/src/core/agents/codex-app-server/options.ts +146 -0
- package/src/core/agents/codex-app-server/plan-approval.ts +135 -0
- package/src/core/agents/codex-app-server/protocol.ts +117 -0
- package/src/core/agents/codex-app-server/requests.ts +332 -0
- package/src/core/agents/codex-app-server/session.ts +285 -0
- package/src/core/agents/codex-app-server/subagents.ts +108 -42
- package/src/core/agents/codex-app-server/thread-settings.ts +279 -0
- package/src/core/agents/codex-app-server/turn-items.ts +88 -0
- package/src/core/agents/codex-app-server/turn.ts +463 -0
- package/src/core/agents/config-fingerprint.ts +7 -14
- package/src/core/agents/credentials.ts +98 -0
- package/src/core/agents/elicitation.ts +75 -0
- package/src/core/agents/inherit-config.ts +21 -0
- package/src/core/agents/login.ts +116 -0
- package/src/core/agents/mcp-config.ts +112 -8
- package/src/core/agents/plan.ts +25 -0
- package/src/core/agents/registry.ts +21 -4
- package/src/core/agents/session-agent.ts +96 -4
- package/src/core/agents/{session-store.ts → session-pool.ts} +11 -5
- package/src/core/agents/stderr-tail.ts +75 -0
- package/src/core/agents/types.ts +40 -5
- package/src/core/index.ts +58 -48
- package/src/core/presets.ts +100 -39
- package/src/core/processes/identity.ts +113 -0
- package/src/core/processes/lifeline.ts +170 -0
- package/src/core/processes/native-processes.ts +379 -0
- package/src/core/processes/process-table.ts +174 -0
- package/src/core/provision/cache-trust.ts +121 -0
- package/src/core/provision/cache-usage.ts +69 -0
- package/src/core/provision/checksums.ts +64 -0
- package/src/core/provision/extract.ts +11 -2
- package/src/core/provision/index.ts +4 -1
- package/src/core/provision/install-build.ts +136 -0
- package/src/core/provision/npm.ts +112 -17
- package/src/core/provision/pins.ts +9 -33
- package/src/core/provision/platform.ts +12 -1
- package/src/core/provision/provisioner.ts +329 -397
- package/src/core/provision/releases.ts +86 -0
- package/src/core/provision/tools.ts +329 -0
- package/src/core/proxy/anthropic-proxy.ts +55 -25
- package/src/core/proxy/api-key-store.ts +2 -12
- package/src/core/proxy/loopback.ts +106 -0
- package/src/core/runtime/agent-runtime.ts +327 -498
- package/src/core/runtime/event-processor.ts +197 -70
- package/src/core/runtime/harness-clis.ts +61 -0
- package/src/core/runtime/harness-logins.ts +328 -0
- package/src/core/runtime/login-reads.ts +78 -0
- package/src/core/runtime/model-lists.ts +33 -48
- package/src/core/runtime/permission-policy.ts +113 -0
- package/src/core/runtime/request-broker.ts +204 -0
- package/src/core/runtime/steering.ts +112 -0
- package/src/core/runtime/turn-outcome.ts +30 -0
- package/src/core/runtime/turn.ts +360 -0
- package/src/core/utils/bounded.ts +12 -0
- package/src/core/utils/deadline.ts +38 -0
- package/src/core/utils/errors.ts +113 -21
- package/src/core/utils/is-record.ts +4 -0
- package/src/core/utils/loopback.ts +10 -0
- package/src/protocol/account.ts +104 -0
- package/src/protocol/auth.ts +199 -0
- package/src/protocol/canonical.ts +16 -0
- package/src/protocol/clis.ts +69 -0
- package/src/protocol/config.ts +60 -6
- package/src/protocol/conversation.ts +272 -0
- package/src/protocol/credentials.ts +145 -0
- package/src/protocol/errors.ts +78 -20
- package/src/protocol/execution.ts +5 -2
- package/src/protocol/factories.ts +55 -7
- package/src/protocol/guards.ts +55 -2
- package/src/protocol/harness.ts +56 -6
- package/src/protocol/history.ts +72 -64
- package/src/protocol/ids.ts +0 -12
- package/src/protocol/index.ts +9 -0
- package/src/protocol/lifecycle.ts +250 -79
- package/src/protocol/meta-keys.ts +17 -0
- package/src/protocol/meta.ts +3 -3
- package/src/protocol/models.ts +2 -43
- package/src/protocol/part-input.ts +2 -1
- package/src/protocol/parts.ts +12 -3
- package/src/protocol/reduce.ts +302 -413
- package/src/protocol/selectors.ts +1 -20
- package/src/protocol/seq-cursor.ts +14 -0
- package/src/protocol/stop-reasons.ts +1 -1
- package/src/protocol/thinking.ts +1 -30
- package/src/protocol/time.ts +2 -2
- package/src/protocol/tool-closure.ts +93 -0
- package/src/protocol/tool-state.ts +19 -4
- package/src/protocol/verify.ts +222 -92
- package/src/protocol/vocabulary.ts +21 -5
- package/src/protocol/wire-api.ts +232 -0
- package/src/protocol/wire.ts +351 -64
- package/src/server/acp/binding.ts +63 -103
- package/src/server/acp/session-records.ts +53 -0
- package/src/server/acp/translate.ts +129 -20
- package/src/server/agent-server.ts +223 -387
- package/src/server/bin.ts +280 -78
- package/src/server/feedback.ts +204 -14
- package/src/server/history.ts +116 -122
- package/src/server/index.ts +3 -8
- package/src/server/install.ts +107 -8
- package/src/server/open-parts.ts +95 -0
- package/src/server/routes.ts +391 -0
- package/src/server/secrets.ts +24 -0
- package/src/server/session-gate.ts +69 -0
- package/src/server/session-log.ts +14 -2
- package/src/server/session-store.ts +136 -72
- package/src/server/subscriptions.ts +232 -0
- package/src/server/transports.ts +125 -25
- package/src/server/wire-error.ts +31 -45
- package/src/sync/event-log.ts +31 -3
- package/src/sync/fit.ts +27 -11
- package/src/sync/history-reader.ts +10 -5
- package/src/sync/history-sqlite.ts +37 -42
- package/src/sync/history.ts +9 -15
- package/src/sync/index.ts +17 -5
- package/src/sync/journal-sqlite.ts +162 -76
- package/src/sync/journal.ts +91 -32
- package/src/sync/live-tails.ts +107 -0
- package/src/sync/projection.ts +35 -0
- package/src/sync/recovery.ts +80 -51
- package/src/sync/schema.ts +27 -6
- package/docs/rfds/0001-deterministic-echo-ids.md +0 -44
- package/docs/rfds/0002-native-subagents.md +0 -197
- package/src/client/request.ts +0 -19
- package/src/core/agents/claude-code/generator-session.ts +0 -572
- package/src/core/agents/claude-code/session-manager.ts +0 -166
- package/src/core/agents/codex-app-server/codex-app-server-agent.ts +0 -962
- package/src/core/agents/codex-items.ts +0 -149
- package/src/core/agents/codex-sdk/adapter.ts +0 -237
- package/src/core/agents/codex-sdk/codex-sdk-agent.ts +0 -330
- package/src/core/agents/tool-meta.ts +0 -68
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ReportedPermissionModeSchema } from "./config.ts";
|
|
3
|
+
import { ErrorCategorySchema, ErrorInfoSchema } from "./errors.ts";
|
|
4
|
+
import { TurnExecutionSchema } from "./execution.ts";
|
|
5
|
+
import { HarnessIdSchema } from "./harness.ts";
|
|
6
|
+
import {
|
|
7
|
+
CompactionStatusSchema,
|
|
8
|
+
CompactionTriggerSchema,
|
|
9
|
+
ElicitationOutcomeSchema,
|
|
10
|
+
ElicitationRequestedEventSchema,
|
|
11
|
+
ErrorEventSchema,
|
|
12
|
+
LimitStatusSchema,
|
|
13
|
+
LimitWindowSchema,
|
|
14
|
+
PermissionOutcomeSchema,
|
|
15
|
+
PermissionRequestedEventSchema,
|
|
16
|
+
SessionEndReasonSchema,
|
|
17
|
+
StopReasonSchema,
|
|
18
|
+
UnknownEventSchema,
|
|
19
|
+
} from "./lifecycle.ts";
|
|
20
|
+
import { PartSchema, UnknownPartSchema } from "./parts.ts";
|
|
21
|
+
import { EpochMsSchema } from "./time.ts";
|
|
22
|
+
import { DEFAULT_TOKEN_USAGE, TokenUsageSchema } from "./tokens.ts";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The conversation state the canonical reducer folds the stream into
|
|
26
|
+
* (`reduce.ts`), and what a fold reports it touched. The state types are zod
|
|
27
|
+
* schemas because products persist `ConversationState` and read it back (LLP
|
|
28
|
+
* 0002, "Reducer state is persistable"); derived state that is not wire
|
|
29
|
+
* vocabulary is namespaced or documented as such.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
export const ConversationMessageSchema = z.object({
|
|
33
|
+
kind: z.literal("message"),
|
|
34
|
+
messageId: z.string(),
|
|
35
|
+
sessionId: z.string(),
|
|
36
|
+
turnId: z.string(),
|
|
37
|
+
outputIndex: z.number(),
|
|
38
|
+
role: z.enum(["user", "assistant"]),
|
|
39
|
+
/** Set when this is a sub-agent's output — nest it under that tool call. */
|
|
40
|
+
parentToolCallId: z.string().optional(),
|
|
41
|
+
model: z.string().optional(),
|
|
42
|
+
parts: z.array(z.union([PartSchema, UnknownPartSchema])),
|
|
43
|
+
startedAt: EpochMsSchema,
|
|
44
|
+
endedAt: EpochMsSchema.optional(),
|
|
45
|
+
});
|
|
46
|
+
export type ConversationMessage = z.infer<typeof ConversationMessageSchema>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The folded compaction entity. Upserts MERGE (a later event that omits
|
|
50
|
+
* `summary`/`preTokens` keeps the ones already known) — deliberately unlike
|
|
51
|
+
* `message.part`, whose snapshots fully REPLACE. A compaction's fields arrive
|
|
52
|
+
* from different harness events at different times ("started, 150k in" then
|
|
53
|
+
* "done, here's the summary"), so replace-semantics would make every producer
|
|
54
|
+
* restate everything or lose it. The cost is stated plainly: a producer cannot
|
|
55
|
+
* clear a compaction field once set.
|
|
56
|
+
*/
|
|
57
|
+
export const ConversationCompactionSchema = z.object({
|
|
58
|
+
kind: z.literal("compaction"),
|
|
59
|
+
compactionId: z.string(),
|
|
60
|
+
turnId: z.string(),
|
|
61
|
+
status: CompactionStatusSchema,
|
|
62
|
+
trigger: CompactionTriggerSchema.optional(),
|
|
63
|
+
preTokens: z.number().optional(),
|
|
64
|
+
postTokens: z.number().optional(),
|
|
65
|
+
summary: z.string().optional(),
|
|
66
|
+
abstractsIds: z.array(z.string()).optional(),
|
|
67
|
+
timestamp: EpochMsSchema,
|
|
68
|
+
});
|
|
69
|
+
export type ConversationCompaction = z.infer<typeof ConversationCompactionSchema>;
|
|
70
|
+
|
|
71
|
+
/** The ordered render list: messages and compactions interleaved in stream order. */
|
|
72
|
+
export const TimelineEntrySchema = z.discriminatedUnion("kind", [
|
|
73
|
+
ConversationMessageSchema,
|
|
74
|
+
ConversationCompactionSchema,
|
|
75
|
+
]);
|
|
76
|
+
export type TimelineEntry = z.infer<typeof TimelineEntrySchema>;
|
|
77
|
+
|
|
78
|
+
/** A non-terminal `error` event as the state keeps it, a turn's or the session's. */
|
|
79
|
+
export const ErrorEntrySchema = z.object({
|
|
80
|
+
category: ErrorCategorySchema,
|
|
81
|
+
message: z.string(),
|
|
82
|
+
recoverable: z.boolean(),
|
|
83
|
+
/** A retry the harness is waiting on, when it said. */
|
|
84
|
+
retry: ErrorEventSchema.shape.retry,
|
|
85
|
+
timestamp: EpochMsSchema,
|
|
86
|
+
});
|
|
87
|
+
export type ErrorEntry = z.infer<typeof ErrorEntrySchema>;
|
|
88
|
+
|
|
89
|
+
export const ConversationTurnSchema = z.object({
|
|
90
|
+
turnId: z.string(),
|
|
91
|
+
execution: TurnExecutionSchema.optional(),
|
|
92
|
+
/** Derived view state, not wire vocabulary. */
|
|
93
|
+
status: z.enum(["active", "ended"]),
|
|
94
|
+
stopReason: StopReasonSchema.optional(),
|
|
95
|
+
finishReason: z.string().optional(),
|
|
96
|
+
tokens: TokenUsageSchema.optional(),
|
|
97
|
+
cost: z.number().optional(),
|
|
98
|
+
/** Terminal error from `turn.ended`, when the turn failed. */
|
|
99
|
+
error: ErrorInfoSchema.optional(),
|
|
100
|
+
/** Steers the turn accepted but ended without delivering (`turn.ended`). */
|
|
101
|
+
undeliveredSteers: z.array(z.string()).optional(),
|
|
102
|
+
/** Non-terminal `error` events attributed to this turn. */
|
|
103
|
+
errors: z.array(ErrorEntrySchema),
|
|
104
|
+
startedAt: EpochMsSchema,
|
|
105
|
+
endedAt: EpochMsSchema.optional(),
|
|
106
|
+
});
|
|
107
|
+
export type ConversationTurn = z.infer<typeof ConversationTurnSchema>;
|
|
108
|
+
|
|
109
|
+
/** A request as the state keeps it: its event without the envelope, then how it resolved. */
|
|
110
|
+
const REQUEST_ENVELOPE = { type: true, sessionId: true, timestamp: true, _meta: true } as const;
|
|
111
|
+
|
|
112
|
+
export const ConversationPermissionSchema = PermissionRequestedEventSchema.omit(
|
|
113
|
+
REQUEST_ENVELOPE,
|
|
114
|
+
).extend({
|
|
115
|
+
requestedAt: EpochMsSchema,
|
|
116
|
+
/** Absent while the request is pending. */
|
|
117
|
+
outcome: PermissionOutcomeSchema.optional(),
|
|
118
|
+
resolvedAt: EpochMsSchema.optional(),
|
|
119
|
+
});
|
|
120
|
+
export type ConversationPermission = z.infer<typeof ConversationPermissionSchema>;
|
|
121
|
+
|
|
122
|
+
export const ConversationElicitationSchema = ElicitationRequestedEventSchema.omit(
|
|
123
|
+
REQUEST_ENVELOPE,
|
|
124
|
+
).extend({
|
|
125
|
+
requestedAt: EpochMsSchema,
|
|
126
|
+
/** Absent while the request is pending. */
|
|
127
|
+
outcome: ElicitationOutcomeSchema.optional(),
|
|
128
|
+
resolvedAt: EpochMsSchema.optional(),
|
|
129
|
+
});
|
|
130
|
+
export type ConversationElicitation = z.infer<typeof ConversationElicitationSchema>;
|
|
131
|
+
|
|
132
|
+
export const ConversationStateSchema = z.object({
|
|
133
|
+
sessionId: z.string().optional(),
|
|
134
|
+
/** Persist this and pass it back as `config.resumeSessionId` to resume. */
|
|
135
|
+
nativeSessionId: z.string().optional(),
|
|
136
|
+
harness: HarnessIdSchema.optional(),
|
|
137
|
+
model: z.string().optional(),
|
|
138
|
+
/** From the last resume-requesting turn: false = fresh-session fallback. */
|
|
139
|
+
resumed: z.boolean().optional(),
|
|
140
|
+
timeline: z.array(TimelineEntrySchema),
|
|
141
|
+
turns: z.array(ConversationTurnSchema),
|
|
142
|
+
permissions: z.array(ConversationPermissionSchema),
|
|
143
|
+
/**
|
|
144
|
+
* The agent's questions and its MCP servers' requests for input. Defaults to
|
|
145
|
+
* empty, so a state saved before elicitations existed still loads.
|
|
146
|
+
*/
|
|
147
|
+
elicitations: z.array(ConversationElicitationSchema).default([]),
|
|
148
|
+
/** Live context gauge (`session.usage`) — how full the window is NOW. */
|
|
149
|
+
usage: z
|
|
150
|
+
.object({
|
|
151
|
+
used: z.number(),
|
|
152
|
+
size: z.number().optional(),
|
|
153
|
+
cost: z.number().optional(),
|
|
154
|
+
updatedAt: EpochMsSchema,
|
|
155
|
+
})
|
|
156
|
+
.optional(),
|
|
157
|
+
/** The account's plan usage (`session.limits`), windows merged by id. */
|
|
158
|
+
limits: z
|
|
159
|
+
.object({
|
|
160
|
+
status: LimitStatusSchema.optional(),
|
|
161
|
+
windows: z.array(LimitWindowSchema),
|
|
162
|
+
planType: z.string().optional(),
|
|
163
|
+
updatedAt: EpochMsSchema,
|
|
164
|
+
})
|
|
165
|
+
.optional(),
|
|
166
|
+
/**
|
|
167
|
+
* The permission mode the session runs in: the last turn's request
|
|
168
|
+
* (`turn.started.execution`), then the agent's switches (`session.mode`).
|
|
169
|
+
*/
|
|
170
|
+
permissionMode: ReportedPermissionModeSchema.optional(),
|
|
171
|
+
/** Sum of every ended turn's billing tokens. */
|
|
172
|
+
totals: TokenUsageSchema,
|
|
173
|
+
totalCost: z.number().optional(),
|
|
174
|
+
/** `error` events that carried no turnId. */
|
|
175
|
+
errors: z.array(ErrorEntrySchema),
|
|
176
|
+
/** The harness session is over (`session.ended`). */
|
|
177
|
+
ended: z.object({ reason: SessionEndReasonSchema, timestamp: EpochMsSchema }).optional(),
|
|
178
|
+
/** Unknown event types, preserved in arrival order. */
|
|
179
|
+
unknownEvents: z.array(UnknownEventSchema),
|
|
180
|
+
/**
|
|
181
|
+
* Raw JSON accumulated from `tool_input` deltas per part id, for UIs that
|
|
182
|
+
* stream tool input as it is typed. Cleared when the part's snapshot
|
|
183
|
+
* arrives with the parsed input (the authoritative form).
|
|
184
|
+
*/
|
|
185
|
+
toolInputJson: z.record(z.string(), z.string()),
|
|
186
|
+
});
|
|
187
|
+
export type ConversationState = z.infer<typeof ConversationStateSchema>;
|
|
188
|
+
|
|
189
|
+
/** A fresh, empty conversation state. */
|
|
190
|
+
export function emptyConversation(): ConversationState {
|
|
191
|
+
return {
|
|
192
|
+
timeline: [],
|
|
193
|
+
turns: [],
|
|
194
|
+
permissions: [],
|
|
195
|
+
elicitations: [],
|
|
196
|
+
// The same zero as `addTokenUsage` produces, so "nothing yet" and "summed
|
|
197
|
+
// nothing" are the same shape — a UI never has to handle two empties.
|
|
198
|
+
totals: { ...DEFAULT_TOKEN_USAGE },
|
|
199
|
+
errors: [],
|
|
200
|
+
unknownEvents: [],
|
|
201
|
+
toolInputJson: {},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** The permission requests still awaiting an answer — render these. */
|
|
206
|
+
export function pendingPermissions(state: ConversationState): ConversationPermission[] {
|
|
207
|
+
return state.permissions.filter((p) => p.outcome === undefined);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** The elicitations still awaiting an answer — render these. */
|
|
211
|
+
export function pendingElicitations(state: ConversationState): ConversationElicitation[] {
|
|
212
|
+
return state.elicitations.filter((e) => e.outcome === undefined);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** The message entries of the timeline, in order (convenience accessor). */
|
|
216
|
+
export function conversationMessages(state: ConversationState): ConversationMessage[] {
|
|
217
|
+
return state.timeline.filter((e): e is ConversationMessage => e.kind === "message");
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* What one fold actually touched — the seam between "the stream says this" and
|
|
222
|
+
* "so write these rows / invalidate these queries".
|
|
223
|
+
*
|
|
224
|
+
* Emitted by `reduceConversationWithChanges`, which INSTRUMENTS the fold
|
|
225
|
+
* rather than diffing states: every mutation site reports itself, so a change
|
|
226
|
+
* list is exactly the set of writes the reducer performed, in the order it
|
|
227
|
+
* performed them. A no-op fold (a replayed duplicate) reports nothing.
|
|
228
|
+
*
|
|
229
|
+
* The addressing is the wire's: `messageId`/`partId`/`turnId`/`requestId` are
|
|
230
|
+
* the same ids the events carry, so a sink can upsert by them without holding
|
|
231
|
+
* a second index. `outputIndex`/`partIndex` are the event's positions when the
|
|
232
|
+
* change came from a `message.part`; for the tools the reducer closes itself
|
|
233
|
+
* (at their turn's end) they are the message's `outputIndex` and the part's
|
|
234
|
+
* position in that message — the same numbers for any stream that arrived in
|
|
235
|
+
* order.
|
|
236
|
+
*/
|
|
237
|
+
export const ConversationChangeSchema = z.discriminatedUnion("kind", [
|
|
238
|
+
/** A message was added to the timeline (started, or shelled in by a part). */
|
|
239
|
+
z.object({ kind: z.literal("message_upserted"), messageId: z.string(), turnId: z.string() }),
|
|
240
|
+
/** A part snapshot landed in its message (or a delta extended one in place). */
|
|
241
|
+
z.object({
|
|
242
|
+
kind: z.literal("part_upserted"),
|
|
243
|
+
messageId: z.string(),
|
|
244
|
+
partId: z.string(),
|
|
245
|
+
outputIndex: z.number(),
|
|
246
|
+
partIndex: z.number(),
|
|
247
|
+
}),
|
|
248
|
+
/** A message got its `endedAt` (once — a repeat is not a change). */
|
|
249
|
+
z.object({ kind: z.literal("message_ended"), messageId: z.string() }),
|
|
250
|
+
/** Streamed tool-input JSON was appended to `toolInputJson[partId]`. */
|
|
251
|
+
z.object({ kind: z.literal("delta_buffered"), partId: z.string() }),
|
|
252
|
+
/** A turn was opened, ended, or gained a non-terminal error. */
|
|
253
|
+
z.object({ kind: z.literal("turn_updated"), turnId: z.string() }),
|
|
254
|
+
z.object({ kind: z.literal("compaction_upserted"), compactionId: z.string() }),
|
|
255
|
+
/** A permission was requested, answered, or cancelled by its turn ending. */
|
|
256
|
+
z.object({ kind: z.literal("permission_updated"), requestId: z.string() }),
|
|
257
|
+
/** An elicitation was requested, answered, or cancelled by its turn ending. */
|
|
258
|
+
z.object({ kind: z.literal("elicitation_updated"), requestId: z.string() }),
|
|
259
|
+
/** The context gauge (`session.usage`) or the billing totals moved. */
|
|
260
|
+
z.object({ kind: z.literal("usage_updated") }),
|
|
261
|
+
/** The account's plan usage (`session.limits`) moved. */
|
|
262
|
+
z.object({ kind: z.literal("limits_updated") }),
|
|
263
|
+
/**
|
|
264
|
+
* Session-scoped facts changed: the `session.created` identity fields, the
|
|
265
|
+
* permission mode (a turn's, or `session.mode`), or an `error` event with no
|
|
266
|
+
* turn to attribute (it lands in `state.errors`).
|
|
267
|
+
*/
|
|
268
|
+
z.object({ kind: z.literal("session_meta_updated") }),
|
|
269
|
+
z.object({ kind: z.literal("session_ended") }),
|
|
270
|
+
z.object({ kind: z.literal("unknown_event_recorded") }),
|
|
271
|
+
]);
|
|
272
|
+
export type ConversationChange = z.infer<typeof ConversationChangeSchema>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AccountInfoSchema } from "./account.ts";
|
|
3
|
+
import { AgentHarnessSchema } from "./harness.ts";
|
|
4
|
+
|
|
5
|
+
const ApiKeySchema = z.object({
|
|
6
|
+
type: z.literal("api_key"),
|
|
7
|
+
apiKey: z.string().min(1),
|
|
8
|
+
/** A gateway the key is for, in place of the provider's own API (Claude only). */
|
|
9
|
+
baseUrl: z.string().url().optional(),
|
|
10
|
+
});
|
|
11
|
+
const OAuthTokenSchema = z.object({
|
|
12
|
+
type: z.literal("oauth_token"),
|
|
13
|
+
accessToken: z.string().min(1),
|
|
14
|
+
/** Epoch ms; absent when unknown. */
|
|
15
|
+
expiresAt: z.number().int().optional(),
|
|
16
|
+
});
|
|
17
|
+
const ChatGptSchema = z.object({
|
|
18
|
+
type: z.literal("chatgpt"),
|
|
19
|
+
accessToken: z.string().min(1),
|
|
20
|
+
accountId: z.string().min(1),
|
|
21
|
+
plan: z.string().optional(),
|
|
22
|
+
expiresAt: z.number().int().optional(),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* What a turn runs with when the product holds the login (LLP 0012), not the
|
|
27
|
+
* CLI: an `api_key` (either harness), Claude's `oauth_token` (the one-year
|
|
28
|
+
* token `setup-token` makes, or an access token), or Codex's `chatgpt` access
|
|
29
|
+
* token with its account. Secret: never answered back, logged or journaled.
|
|
30
|
+
*/
|
|
31
|
+
export const HarnessCredentialSchema = z.discriminatedUnion("type", [
|
|
32
|
+
ApiKeySchema,
|
|
33
|
+
OAuthTokenSchema,
|
|
34
|
+
ChatGptSchema,
|
|
35
|
+
]);
|
|
36
|
+
export type HarnessCredential = z.infer<typeof HarnessCredentialSchema>;
|
|
37
|
+
|
|
38
|
+
/** What Claude Code runs on: a key (to a gateway, too) or an OAuth token. */
|
|
39
|
+
export const ClaudeCredentialSchema = z.discriminatedUnion("type", [
|
|
40
|
+
ApiKeySchema,
|
|
41
|
+
OAuthTokenSchema,
|
|
42
|
+
]);
|
|
43
|
+
export type ClaudeCredential = z.infer<typeof ClaudeCredentialSchema>;
|
|
44
|
+
|
|
45
|
+
/** What Codex runs on: a key to OpenAI's own API, or a ChatGPT token. */
|
|
46
|
+
export const CodexCredentialSchema = z.discriminatedUnion("type", [
|
|
47
|
+
// A key for another endpoint is Claude's alone; one whose `baseUrl` is there but undefined is not one.
|
|
48
|
+
ApiKeySchema.extend({ baseUrl: z.undefined().optional() }),
|
|
49
|
+
ChatGptSchema,
|
|
50
|
+
]);
|
|
51
|
+
export type CodexCredential = z.infer<typeof CodexCredentialSchema>;
|
|
52
|
+
|
|
53
|
+
/** What each harness runs on. */
|
|
54
|
+
export interface HarnessCredentials {
|
|
55
|
+
"claude-code": ClaudeCredential;
|
|
56
|
+
"codex-app-server": CodexCredential;
|
|
57
|
+
}
|
|
58
|
+
const RUNS_ON = {
|
|
59
|
+
"claude-code": ClaudeCredentialSchema,
|
|
60
|
+
"codex-app-server": CodexCredentialSchema,
|
|
61
|
+
} as const;
|
|
62
|
+
|
|
63
|
+
/** The credential as the kind `harness` runs on, or why that harness cannot run it. */
|
|
64
|
+
export function credentialRunsOn<H extends keyof HarnessCredentials>(
|
|
65
|
+
harness: H,
|
|
66
|
+
credential: HarnessCredential,
|
|
67
|
+
): { ok: true; credential: HarnessCredentials[H] } | { ok: false; error: string } {
|
|
68
|
+
const parsed = RUNS_ON[harness].safeParse(credential);
|
|
69
|
+
if (parsed.success) return { ok: true, credential: parsed.data as HarnessCredentials[H] };
|
|
70
|
+
const what =
|
|
71
|
+
credential.type === "api_key" && credential.baseUrl
|
|
72
|
+
? "a key for another endpoint"
|
|
73
|
+
: `a ${credential.type} credential`;
|
|
74
|
+
return { ok: false, error: `${harness} does not run on ${what}.` };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The SHA-256 (hex) a credential request names a refused token by
|
|
79
|
+
* (`rejectedSha256`): an engine sends it, a product compares it, never the token.
|
|
80
|
+
*/
|
|
81
|
+
export async function tokenDigest(token: string): Promise<string> {
|
|
82
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(token));
|
|
83
|
+
return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* What a product stores for an account it holds: who it is (`AccountInfo`),
|
|
88
|
+
* the credential a turn gets, and what renews it (a ChatGPT login's refresh
|
|
89
|
+
* token; nothing renews a key or Claude's one-year token). Secret, as its
|
|
90
|
+
* credential; `grantAuth` is what to show of it.
|
|
91
|
+
*/
|
|
92
|
+
export const CredentialGrantSchema = AccountInfoSchema.extend({
|
|
93
|
+
harness: AgentHarnessSchema,
|
|
94
|
+
credential: HarnessCredentialSchema,
|
|
95
|
+
refreshToken: z.string().min(1).optional(),
|
|
96
|
+
/** Epoch ms, when it was obtained or last renewed. */
|
|
97
|
+
obtainedAt: z.number().int(),
|
|
98
|
+
});
|
|
99
|
+
export type CredentialGrant = z.infer<typeof CredentialGrantSchema>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* What an engine asks a product's credential endpoint before a turn: whose
|
|
103
|
+
* credential (the session, the harness), and, when the harness refused the
|
|
104
|
+
* last one, its SHA-256 (hex), never the token: answer a fresher one.
|
|
105
|
+
*/
|
|
106
|
+
export const CredentialRequestSchema = z.object({
|
|
107
|
+
harness: AgentHarnessSchema,
|
|
108
|
+
sessionId: z.string().min(1),
|
|
109
|
+
/** The turn it is for, where the engine knows it: a product that picks who pays per turn reads it. */
|
|
110
|
+
turnId: z.string().min(1).optional(),
|
|
111
|
+
rejectedSha256: z
|
|
112
|
+
.string()
|
|
113
|
+
.regex(/^[0-9a-f]{64}$/)
|
|
114
|
+
.optional(),
|
|
115
|
+
});
|
|
116
|
+
export type CredentialRequest = z.infer<typeof CredentialRequestSchema>;
|
|
117
|
+
|
|
118
|
+
/** The endpoint's answer: the credential, or none (the engine's own CLI login runs the turn). */
|
|
119
|
+
export const CredentialAnswerSchema = z.object({
|
|
120
|
+
credential: HarnessCredentialSchema.nullable(),
|
|
121
|
+
});
|
|
122
|
+
export type CredentialAnswer = z.infer<typeof CredentialAnswerSchema>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The code a sign-in page showed, as pasted: `code#state`, the page's
|
|
126
|
+
* address, or the bare code (the sign-in's own state then goes with it). A
|
|
127
|
+
* state from another sign-in is refused.
|
|
128
|
+
*/
|
|
129
|
+
export function pastedSignInCode(pasted: string, state: string): { code: string; state: string } {
|
|
130
|
+
const text = pasted.trim();
|
|
131
|
+
let code = text;
|
|
132
|
+
let returned: string | null = null;
|
|
133
|
+
if (/^https?:\/\//i.test(text)) {
|
|
134
|
+
const url = URL.canParse(text) ? new URL(text) : undefined;
|
|
135
|
+
code = url?.searchParams.get("code") ?? "";
|
|
136
|
+
returned = url?.searchParams.get("state") ?? null;
|
|
137
|
+
} else if (text.includes("#")) {
|
|
138
|
+
[code = "", returned = null] = text.split("#", 2);
|
|
139
|
+
}
|
|
140
|
+
if (returned !== null && returned !== state) {
|
|
141
|
+
throw new Error("This code is from another sign-in: paste the code this sign-in's page shows.");
|
|
142
|
+
}
|
|
143
|
+
if (!code) throw new Error("Paste the code the sign-in page shows.");
|
|
144
|
+
return { code, state };
|
|
145
|
+
}
|
package/src/protocol/errors.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { z } from "zod";
|
|
|
2
2
|
import { openVocabulary } from "./vocabulary.ts";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The one error vocabulary (
|
|
5
|
+
* The one error vocabulary (one shape per concept). Used by
|
|
6
6
|
* `turn.ended.error`, the standalone `error` event, and `RunSummary.error`.
|
|
7
7
|
*
|
|
8
|
-
* OPEN
|
|
9
|
-
*
|
|
8
|
+
* OPEN: products may extend it with their own categories (a "db_write", say);
|
|
9
|
+
* unknown non-`_` values are reserved for this protocol.
|
|
10
10
|
* `usage_limit` (plan/quota exhausted) and `rate_limit` (429/backoff) are
|
|
11
11
|
* deliberately distinct — they need different user guidance; collapsing them
|
|
12
12
|
* is a display choice, never a wire merge.
|
|
@@ -14,6 +14,7 @@ import { openVocabulary } from "./vocabulary.ts";
|
|
|
14
14
|
export const ERROR_CATEGORIES = [
|
|
15
15
|
"auth",
|
|
16
16
|
"rate_limit",
|
|
17
|
+
"overloaded",
|
|
17
18
|
"usage_limit",
|
|
18
19
|
"context_limit",
|
|
19
20
|
"network",
|
|
@@ -21,10 +22,20 @@ export const ERROR_CATEGORIES = [
|
|
|
21
22
|
"invalid_request",
|
|
22
23
|
"process_exit",
|
|
23
24
|
"resume_failed",
|
|
25
|
+
"mcp_unavailable",
|
|
26
|
+
"server_restart",
|
|
24
27
|
"internal",
|
|
25
28
|
] as const;
|
|
26
29
|
export type ErrorCategory = (typeof ERROR_CATEGORIES)[number] | (string & {});
|
|
27
|
-
export const ErrorCategorySchema = openVocabulary
|
|
30
|
+
export const ErrorCategorySchema = openVocabulary(ERROR_CATEGORIES);
|
|
31
|
+
|
|
32
|
+
/** A category this build knows, or a product's `_`-prefixed extension. */
|
|
33
|
+
function isErrorCategory(value: unknown): value is ErrorCategory {
|
|
34
|
+
return (
|
|
35
|
+
typeof value === "string" &&
|
|
36
|
+
((ERROR_CATEGORIES as readonly string[]).includes(value) || /^_\S/.test(value))
|
|
37
|
+
);
|
|
38
|
+
}
|
|
28
39
|
|
|
29
40
|
export const ErrorInfoSchema = z.object({
|
|
30
41
|
category: ErrorCategorySchema,
|
|
@@ -56,8 +67,29 @@ const RULES: ReadonlyArray<[ErrorCategory, readonly string[]]> = [
|
|
|
56
67
|
],
|
|
57
68
|
],
|
|
58
69
|
["rate_limit", ["rate limit", "rate_limit", "429", "too many requests"]],
|
|
59
|
-
["
|
|
60
|
-
[
|
|
70
|
+
["overloaded", ["overloaded", "at capacity", "server_overloaded"]],
|
|
71
|
+
[
|
|
72
|
+
"usage_limit",
|
|
73
|
+
[
|
|
74
|
+
"usage limit",
|
|
75
|
+
"quota",
|
|
76
|
+
"insufficient_quota",
|
|
77
|
+
"billing",
|
|
78
|
+
"credit",
|
|
79
|
+
// Claude Code's "You've hit your session limit · resets …" and the like.
|
|
80
|
+
"ve hit your",
|
|
81
|
+
],
|
|
82
|
+
],
|
|
83
|
+
[
|
|
84
|
+
"context_limit",
|
|
85
|
+
[
|
|
86
|
+
"context length",
|
|
87
|
+
"context_length",
|
|
88
|
+
"maximum context",
|
|
89
|
+
"too many tokens",
|
|
90
|
+
"prompt is too long",
|
|
91
|
+
],
|
|
92
|
+
],
|
|
61
93
|
[
|
|
62
94
|
"network",
|
|
63
95
|
[
|
|
@@ -82,26 +114,45 @@ const RULES: ReadonlyArray<[ErrorCategory, readonly string[]]> = [
|
|
|
82
114
|
"issue with the selected model",
|
|
83
115
|
],
|
|
84
116
|
],
|
|
85
|
-
[
|
|
117
|
+
[
|
|
118
|
+
"process_exit",
|
|
119
|
+
[
|
|
120
|
+
"exited with code",
|
|
121
|
+
"process exited",
|
|
122
|
+
// Claude's SDK when its CLI died to a signal (SIGKILL, an OOM kill).
|
|
123
|
+
"terminated by signal",
|
|
124
|
+
"spawn",
|
|
125
|
+
"enoent",
|
|
126
|
+
"killed",
|
|
127
|
+
],
|
|
128
|
+
],
|
|
86
129
|
];
|
|
87
130
|
|
|
88
131
|
export function classifyError(error: unknown): ErrorCategory {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
return "resume_failed";
|
|
97
|
-
}
|
|
132
|
+
// An error that names its own category (the engine's typed errors do) is
|
|
133
|
+
// already classified: an agent's exit carries its stderr, whose words
|
|
134
|
+
// ("aborted", a "429" in a stack trace) must not pass for a cancel or a
|
|
135
|
+
// rate limit, and an MCP server's cause is not the model provider's.
|
|
136
|
+
if (error instanceof Error && "category" in error && isErrorCategory(error.category))
|
|
137
|
+
return error.category;
|
|
98
138
|
const message = (error instanceof Error ? error.message : String(error)).toLowerCase();
|
|
99
139
|
for (const [category, needles] of RULES) {
|
|
100
|
-
if (needles.some((n) => message
|
|
140
|
+
if (needles.some((n) => mentions(message, n))) return category;
|
|
101
141
|
}
|
|
102
142
|
return "internal";
|
|
103
143
|
}
|
|
104
144
|
|
|
145
|
+
/** A status code counts on its own, never inside a longer number ("240129 tokens"). */
|
|
146
|
+
function mentions(message: string, needle: string): boolean {
|
|
147
|
+
if (!/\d$/.test(needle)) return message.includes(needle);
|
|
148
|
+
for (let at = message.indexOf(needle); at >= 0; at = message.indexOf(needle, at + 1)) {
|
|
149
|
+
const before = message[at - 1] ?? "";
|
|
150
|
+
const after = message[at + needle.length] ?? "";
|
|
151
|
+
if (!/\d/.test(before) && !/\d/.test(after)) return true;
|
|
152
|
+
}
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
|
|
105
156
|
/**
|
|
106
157
|
* The message to show for a failure. Providers often answer with a JSON
|
|
107
158
|
* envelope (`{"error":{"message":…}}`), sometimes behind a transport prefix;
|
|
@@ -123,9 +174,16 @@ export function readableErrorMessage(message: string): string {
|
|
|
123
174
|
}
|
|
124
175
|
}
|
|
125
176
|
|
|
126
|
-
/**
|
|
127
|
-
|
|
128
|
-
|
|
177
|
+
/**
|
|
178
|
+
* The one mapping from a failure to the `ErrorInfo` the stream carries: its
|
|
179
|
+
* category, from the harness's typed code when it has one (that beats its
|
|
180
|
+
* text), else classified from its raw text, and its readable message.
|
|
181
|
+
*/
|
|
182
|
+
export function errorInfo(error: unknown, typedCategory?: ErrorCategory): ErrorInfo {
|
|
183
|
+
return {
|
|
184
|
+
category: typedCategory ?? classifyError(error),
|
|
185
|
+
message: readableErrorMessage(error instanceof Error ? error.message : String(error)),
|
|
186
|
+
};
|
|
129
187
|
}
|
|
130
188
|
|
|
131
189
|
/** Abort is a user action, not a failure to report. */
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { ReportedPermissionModeSchema } from "./config.ts";
|
|
3
|
+
import { HarnessIdSchema } from "./harness.ts";
|
|
3
4
|
import { ThinkingLevelSchema } from "./thinking.ts";
|
|
4
5
|
|
|
5
6
|
/** Safe, per-turn execution metadata. Never serialize the full RunConfig here. */
|
|
6
7
|
export const TurnExecutionSchema = z.object({
|
|
7
|
-
harness:
|
|
8
|
+
harness: HarnessIdSchema,
|
|
8
9
|
/** Model id/alias passed to the harness. Absent means the harness chose its default. */
|
|
9
10
|
model: z.string().optional(),
|
|
10
11
|
/** Requested setting, not a measurement of the model's internal reasoning. */
|
|
11
12
|
thinkingLevel: ThinkingLevelSchema.optional(),
|
|
13
|
+
/** The permission mode the turn asked for; the agent may switch it (`session.mode`). */
|
|
14
|
+
permissionMode: ReportedPermissionModeSchema.optional(),
|
|
12
15
|
/** The level the harness ran this turn at: the request fitted to the model's levels
|
|
13
16
|
* (`ultra` on a model topping out at `max` runs `max`), or the harness's own setting
|
|
14
17
|
* when the turn requested none. Only on `turn.ended`; absent when unknown or when the
|