@zvada/agent-server 0.3.18 → 0.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +11 -26
- package/CHANGELOG.md +1005 -1
- package/README.md +35 -39
- package/dist/types/accounts/chatgpt.d.ts +34 -0
- package/dist/types/accounts/chatgpt.d.ts.map +1 -0
- package/dist/types/accounts/check.d.ts +24 -0
- package/dist/types/accounts/check.d.ts.map +1 -0
- package/dist/types/accounts/claude.d.ts +21 -0
- package/dist/types/accounts/claude.d.ts.map +1 -0
- package/dist/types/accounts/endpoint.d.ts +50 -0
- package/dist/types/accounts/endpoint.d.ts.map +1 -0
- package/dist/types/accounts/http.d.ts +38 -0
- package/dist/types/accounts/http.d.ts.map +1 -0
- package/dist/types/accounts/index.d.ts +6 -0
- package/dist/types/accounts/index.d.ts.map +1 -0
- package/dist/types/client/client.d.ts +272 -0
- package/dist/types/client/client.d.ts.map +1 -0
- package/dist/types/client/connection.d.ts +160 -0
- package/dist/types/client/connection.d.ts.map +1 -0
- package/dist/types/client/history.d.ts +8 -0
- package/dist/types/client/history.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +5 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/listeners.d.ts +8 -0
- package/dist/types/client/listeners.d.ts.map +1 -0
- package/dist/types/client/logins.d.ts +35 -0
- package/dist/types/client/logins.d.ts.map +1 -0
- package/dist/types/client/rpc.d.ts +46 -0
- package/dist/types/client/rpc.d.ts.map +1 -0
- package/dist/types/client/streams.d.ts +150 -0
- package/dist/types/client/streams.d.ts.map +1 -0
- package/dist/types/client/transports.d.ts +35 -0
- package/dist/types/client/transports.d.ts.map +1 -0
- package/dist/types/client/turns.d.ts +81 -0
- package/dist/types/client/turns.d.ts.map +1 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts +68 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -0
- package/dist/types/core/agents/acp/adapter.d.ts +39 -0
- package/dist/types/core/agents/acp/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/acp/client.d.ts +90 -0
- package/dist/types/core/agents/acp/client.d.ts.map +1 -0
- package/dist/types/core/agents/acp/known-agents.d.ts +35 -0
- package/dist/types/core/agents/acp/known-agents.d.ts.map +1 -0
- package/dist/types/core/agents/acp/mappings.d.ts +46 -0
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -0
- package/dist/types/core/agents/acp/requests.d.ts +26 -0
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -0
- package/dist/types/core/agents/attachments.d.ts +11 -0
- package/dist/types/core/agents/attachments.d.ts.map +1 -0
- package/dist/types/core/agents/base.d.ts +227 -0
- package/dist/types/core/agents/base.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts +58 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts +26 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +70 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts +54 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/events.d.ts +42 -0
- package/dist/types/core/agents/claude-code/events.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/login.d.ts +61 -0
- package/dist/types/core/agents/claude-code/login.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts +52 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/models.d.ts +30 -0
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/options.d.ts +183 -0
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts +50 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts +36 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session.d.ts +148 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts +29 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spend.d.ts +58 -0
- package/dist/types/core/agents/claude-code/spend.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/tools.d.ts +4 -0
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts +52 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn.d.ts +121 -0
- package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts +59 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts +116 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +113 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts +66 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts +49 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts +12 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts +45 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts +20 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts +26 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts +31 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts +38 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +62 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts +67 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts +40 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts +19 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts +99 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts +42 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts +96 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts +53 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts +87 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts +33 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts +163 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts.map +1 -0
- package/dist/types/core/agents/config-fingerprint.d.ts +5 -0
- package/dist/types/core/agents/config-fingerprint.d.ts.map +1 -0
- package/dist/types/core/agents/credentials.d.ts +28 -0
- package/dist/types/core/agents/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/elicitation.d.ts +37 -0
- package/dist/types/core/agents/elicitation.d.ts.map +1 -0
- package/dist/types/core/agents/inherit-config.d.ts +18 -0
- package/dist/types/core/agents/inherit-config.d.ts.map +1 -0
- package/dist/types/core/agents/login.d.ts +67 -0
- package/dist/types/core/agents/login.d.ts.map +1 -0
- package/dist/types/core/agents/mcp-config.d.ts +57 -0
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -0
- package/dist/types/core/agents/plan.d.ts +16 -0
- package/dist/types/core/agents/plan.d.ts.map +1 -0
- package/dist/types/core/agents/registry.d.ts +30 -0
- package/dist/types/core/agents/registry.d.ts.map +1 -0
- package/dist/types/core/agents/session-agent.d.ts +48 -0
- package/dist/types/core/agents/session-agent.d.ts.map +1 -0
- package/dist/types/core/agents/session-pool.d.ts +41 -0
- package/dist/types/core/agents/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/stderr-tail.d.ts +28 -0
- package/dist/types/core/agents/stderr-tail.d.ts.map +1 -0
- package/dist/types/core/agents/thinking-levels.d.ts +4 -0
- package/dist/types/core/agents/thinking-levels.d.ts.map +1 -0
- package/dist/types/core/agents/types.d.ts +124 -0
- package/dist/types/core/agents/types.d.ts.map +1 -0
- package/dist/types/core/diagnostics.d.ts +36 -0
- package/dist/types/core/diagnostics.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +29 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/presets.d.ts +80 -0
- package/dist/types/core/presets.d.ts.map +1 -0
- package/dist/types/core/processes/identity.d.ts +31 -0
- package/dist/types/core/processes/identity.d.ts.map +1 -0
- package/dist/types/core/processes/lifeline.d.ts +47 -0
- package/dist/types/core/processes/lifeline.d.ts.map +1 -0
- package/dist/types/core/processes/native-processes.d.ts +130 -0
- package/dist/types/core/processes/native-processes.d.ts.map +1 -0
- package/dist/types/core/processes/process-table.d.ts +43 -0
- package/dist/types/core/processes/process-table.d.ts.map +1 -0
- package/dist/types/core/provision/cache-trust.d.ts +13 -0
- package/dist/types/core/provision/cache-trust.d.ts.map +1 -0
- package/dist/types/core/provision/cache-usage.d.ts +14 -0
- package/dist/types/core/provision/cache-usage.d.ts.map +1 -0
- package/dist/types/core/provision/checksums.d.ts +46 -0
- package/dist/types/core/provision/checksums.d.ts.map +1 -0
- package/dist/types/core/provision/extract.d.ts +7 -0
- package/dist/types/core/provision/extract.d.ts.map +1 -0
- package/dist/types/core/provision/index.d.ts +5 -0
- package/dist/types/core/provision/index.d.ts.map +1 -0
- package/dist/types/core/provision/install-build.d.ts +36 -0
- package/dist/types/core/provision/install-build.d.ts.map +1 -0
- package/dist/types/core/provision/npm.d.ts +40 -0
- package/dist/types/core/provision/npm.d.ts.map +1 -0
- package/dist/types/core/provision/pins.d.ts +24 -0
- package/dist/types/core/provision/pins.d.ts.map +1 -0
- package/dist/types/core/provision/platform.d.ts +28 -0
- package/dist/types/core/provision/platform.d.ts.map +1 -0
- package/dist/types/core/provision/provisioner.d.ts +189 -0
- package/dist/types/core/provision/provisioner.d.ts.map +1 -0
- package/dist/types/core/provision/releases.d.ts +8 -0
- package/dist/types/core/provision/releases.d.ts.map +1 -0
- package/dist/types/core/provision/tools.d.ts +81 -0
- package/dist/types/core/provision/tools.d.ts.map +1 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts +52 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts.map +1 -0
- package/dist/types/core/proxy/api-key-store.d.ts +37 -0
- package/dist/types/core/proxy/api-key-store.d.ts.map +1 -0
- package/dist/types/core/proxy/index.d.ts +3 -0
- package/dist/types/core/proxy/index.d.ts.map +1 -0
- package/dist/types/core/proxy/loopback.d.ts +14 -0
- package/dist/types/core/proxy/loopback.d.ts.map +1 -0
- package/dist/types/core/runtime/agent-runtime.d.ts +181 -0
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -0
- package/dist/types/core/runtime/event-processor.d.ts +87 -0
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -0
- package/dist/types/core/runtime/event-sink.d.ts +44 -0
- package/dist/types/core/runtime/event-sink.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-clis.d.ts +10 -0
- package/dist/types/core/runtime/harness-clis.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-logins.d.ts +68 -0
- package/dist/types/core/runtime/harness-logins.d.ts.map +1 -0
- package/dist/types/core/runtime/login-reads.d.ts +28 -0
- package/dist/types/core/runtime/login-reads.d.ts.map +1 -0
- package/dist/types/core/runtime/model-lists.d.ts +37 -0
- package/dist/types/core/runtime/model-lists.d.ts.map +1 -0
- package/dist/types/core/runtime/permission-policy.d.ts +61 -0
- package/dist/types/core/runtime/permission-policy.d.ts.map +1 -0
- package/dist/types/core/runtime/request-broker.d.ts +49 -0
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -0
- package/dist/types/core/runtime/steering.d.ts +38 -0
- package/dist/types/core/runtime/steering.d.ts.map +1 -0
- package/dist/types/core/runtime/turn-outcome.d.ts +21 -0
- package/dist/types/core/runtime/turn-outcome.d.ts.map +1 -0
- package/dist/types/core/runtime/turn.d.ts +121 -0
- package/dist/types/core/runtime/turn.d.ts.map +1 -0
- package/dist/types/core/utils/bounded.d.ts +6 -0
- package/dist/types/core/utils/bounded.d.ts.map +1 -0
- package/dist/types/core/utils/deadline.d.ts +14 -0
- package/dist/types/core/utils/deadline.d.ts.map +1 -0
- package/dist/types/core/utils/errors.d.ts +104 -0
- package/dist/types/core/utils/errors.d.ts.map +1 -0
- package/dist/types/core/utils/is-record.d.ts +3 -0
- package/dist/types/core/utils/is-record.d.ts.map +1 -0
- package/dist/types/core/utils/loopback.d.ts +6 -0
- package/dist/types/core/utils/loopback.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/protocol/account.d.ts +26 -0
- package/dist/types/protocol/account.d.ts.map +1 -0
- package/dist/types/protocol/async-queue.d.ts +21 -0
- package/dist/types/protocol/async-queue.d.ts.map +1 -0
- package/dist/types/protocol/auth.d.ts +228 -0
- package/dist/types/protocol/auth.d.ts.map +1 -0
- package/dist/types/protocol/canonical.d.ts +9 -0
- package/dist/types/protocol/canonical.d.ts.map +1 -0
- package/dist/types/protocol/clis.d.ts +74 -0
- package/dist/types/protocol/clis.d.ts.map +1 -0
- package/dist/types/protocol/config.d.ts +200 -0
- package/dist/types/protocol/config.d.ts.map +1 -0
- package/dist/types/protocol/conversation.d.ts +942 -0
- package/dist/types/protocol/conversation.d.ts.map +1 -0
- package/dist/types/protocol/credentials.d.ts +145 -0
- package/dist/types/protocol/credentials.d.ts.map +1 -0
- package/dist/types/protocol/errors.d.ts +36 -0
- package/dist/types/protocol/errors.d.ts.map +1 -0
- package/dist/types/protocol/execution.d.ts +28 -0
- package/dist/types/protocol/execution.d.ts.map +1 -0
- package/dist/types/protocol/factories.d.ts +94 -0
- package/dist/types/protocol/factories.d.ts.map +1 -0
- package/dist/types/protocol/guards.d.ts +55 -0
- package/dist/types/protocol/guards.d.ts.map +1 -0
- package/dist/types/protocol/harness.d.ts +70 -0
- package/dist/types/protocol/harness.d.ts.map +1 -0
- package/dist/types/protocol/history.d.ts +318 -0
- package/dist/types/protocol/history.d.ts.map +1 -0
- package/dist/types/protocol/ids.d.ts +9 -0
- package/dist/types/protocol/ids.d.ts.map +1 -0
- package/dist/types/protocol/index.d.ts +35 -0
- package/dist/types/protocol/index.d.ts.map +1 -0
- package/dist/types/protocol/lifecycle.d.ts +1190 -0
- package/dist/types/protocol/lifecycle.d.ts.map +1 -0
- package/dist/types/protocol/meta-keys.d.ts +17 -0
- package/dist/types/protocol/meta-keys.d.ts.map +1 -0
- package/dist/types/protocol/meta.d.ts +13 -0
- package/dist/types/protocol/meta.d.ts.map +1 -0
- package/dist/types/protocol/model-catalog.d.ts +11 -0
- package/dist/types/protocol/model-catalog.d.ts.map +1 -0
- package/dist/types/protocol/models.d.ts +107 -0
- package/dist/types/protocol/models.d.ts.map +1 -0
- package/dist/types/protocol/part-input.d.ts +101 -0
- package/dist/types/protocol/part-input.d.ts.map +1 -0
- package/dist/types/protocol/parts.d.ts +357 -0
- package/dist/types/protocol/parts.d.ts.map +1 -0
- package/dist/types/protocol/reduce.d.ts +26 -0
- package/dist/types/protocol/reduce.d.ts.map +1 -0
- package/dist/types/protocol/selectors.d.ts +64 -0
- package/dist/types/protocol/selectors.d.ts.map +1 -0
- package/dist/types/protocol/seq-cursor.d.ts +66 -0
- package/dist/types/protocol/seq-cursor.d.ts.map +1 -0
- package/dist/types/protocol/stop-reasons.d.ts +33 -0
- package/dist/types/protocol/stop-reasons.d.ts.map +1 -0
- package/dist/types/protocol/thinking.d.ts +28 -0
- package/dist/types/protocol/thinking.d.ts.map +1 -0
- package/dist/types/protocol/time.d.ts +21 -0
- package/dist/types/protocol/time.d.ts.map +1 -0
- package/dist/types/protocol/tokens.d.ts +29 -0
- package/dist/types/protocol/tokens.d.ts.map +1 -0
- package/dist/types/protocol/tool-closure.d.ts +25 -0
- package/dist/types/protocol/tool-closure.d.ts.map +1 -0
- package/dist/types/protocol/tool-state.d.ts +209 -0
- package/dist/types/protocol/tool-state.d.ts.map +1 -0
- package/dist/types/protocol/verify.d.ts +52 -0
- package/dist/types/protocol/verify.d.ts.map +1 -0
- package/dist/types/protocol/vocabulary.d.ts +19 -0
- package/dist/types/protocol/vocabulary.d.ts.map +1 -0
- package/dist/types/protocol/wire-api.d.ts +1983 -0
- package/dist/types/protocol/wire-api.d.ts.map +1 -0
- package/dist/types/protocol/wire.d.ts +1758 -0
- package/dist/types/protocol/wire.d.ts.map +1 -0
- package/dist/types/server/acp/binding.d.ts +33 -0
- package/dist/types/server/acp/binding.d.ts.map +1 -0
- package/dist/types/server/acp/session-records.d.ts +17 -0
- package/dist/types/server/acp/session-records.d.ts.map +1 -0
- package/dist/types/server/acp/translate.d.ts +48 -0
- package/dist/types/server/acp/translate.d.ts.map +1 -0
- package/dist/types/server/agent-server.d.ts +121 -0
- package/dist/types/server/agent-server.d.ts.map +1 -0
- package/dist/types/server/feedback.d.ts +37 -0
- package/dist/types/server/feedback.d.ts.map +1 -0
- package/dist/types/server/history.d.ts +15 -0
- package/dist/types/server/history.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +7 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/types/server/install.d.ts +42 -0
- package/dist/types/server/install.d.ts.map +1 -0
- package/dist/types/server/open-parts.d.ts +27 -0
- package/dist/types/server/open-parts.d.ts.map +1 -0
- package/dist/types/server/routes.d.ts +61 -0
- package/dist/types/server/routes.d.ts.map +1 -0
- package/dist/types/server/secrets.d.ts +11 -0
- package/dist/types/server/secrets.d.ts.map +1 -0
- package/dist/types/server/session-gate.d.ts +32 -0
- package/dist/types/server/session-gate.d.ts.map +1 -0
- package/dist/types/server/session-log.d.ts +39 -0
- package/dist/types/server/session-log.d.ts.map +1 -0
- package/dist/types/server/session-store.d.ts +119 -0
- package/dist/types/server/session-store.d.ts.map +1 -0
- package/dist/types/server/subscriptions.d.ts +74 -0
- package/dist/types/server/subscriptions.d.ts.map +1 -0
- package/dist/types/server/transports.d.ts +74 -0
- package/dist/types/server/transports.d.ts.map +1 -0
- package/dist/types/server/wire-error.d.ts +9 -0
- package/dist/types/server/wire-error.d.ts.map +1 -0
- package/dist/types/sync/event-log.d.ts +45 -0
- package/dist/types/sync/event-log.d.ts.map +1 -0
- package/dist/types/sync/fit.d.ts +40 -0
- package/dist/types/sync/fit.d.ts.map +1 -0
- package/dist/types/sync/history-reader.d.ts +8 -0
- package/dist/types/sync/history-reader.d.ts.map +1 -0
- package/dist/types/sync/history-sqlite.d.ts +37 -0
- package/dist/types/sync/history-sqlite.d.ts.map +1 -0
- package/dist/types/sync/history.d.ts +70 -0
- package/dist/types/sync/history.d.ts.map +1 -0
- package/dist/types/sync/index.d.ts +4 -0
- package/dist/types/sync/index.d.ts.map +1 -0
- package/dist/types/sync/journal-sqlite.d.ts +51 -0
- package/dist/types/sync/journal-sqlite.d.ts.map +1 -0
- package/dist/types/sync/journal.d.ts +107 -0
- package/dist/types/sync/journal.d.ts.map +1 -0
- package/dist/types/sync/live-tails.d.ts +30 -0
- package/dist/types/sync/live-tails.d.ts.map +1 -0
- package/dist/types/sync/node-sqlite.d.ts +7 -0
- package/dist/types/sync/node-sqlite.d.ts.map +1 -0
- package/dist/types/sync/projection.d.ts +10 -0
- package/dist/types/sync/projection.d.ts.map +1 -0
- package/dist/types/sync/recovery.d.ts +25 -0
- package/dist/types/sync/recovery.d.ts.map +1 -0
- package/dist/types/sync/retry.d.ts +25 -0
- package/dist/types/sync/retry.d.ts.map +1 -0
- package/dist/types/sync/schema.d.ts +4 -0
- package/dist/types/sync/schema.d.ts.map +1 -0
- package/dist/types/sync/sql.d.ts +38 -0
- package/dist/types/sync/sql.d.ts.map +1 -0
- package/dist/types/sync/sqlite-file.d.ts +9 -0
- package/dist/types/sync/sqlite-file.d.ts.map +1 -0
- package/dist/types/sync/sqlite.d.ts +6 -0
- package/dist/types/sync/sqlite.d.ts.map +1 -0
- package/dist/types/sync/worker.d.ts +63 -0
- package/dist/types/sync/worker.d.ts.map +1 -0
- package/docs/consuming.md +452 -53
- package/docs/deploy.md +218 -47
- package/docs/{sync-experiment.md → durable-sessions.md} +77 -72
- package/docs/feedback.md +116 -0
- package/docs/harnesses.md +212 -88
- package/docs/sync-history.md +29 -13
- package/docs/sync-integration.md +52 -66
- package/package.json +43 -25
- package/src/accounts/chatgpt.ts +194 -0
- package/src/accounts/check.ts +112 -0
- package/src/accounts/claude.ts +111 -0
- package/src/accounts/endpoint.ts +151 -0
- package/src/accounts/http.ts +97 -0
- package/src/accounts/index.ts +19 -0
- package/src/client/client.ts +604 -670
- package/src/client/connection.ts +371 -0
- package/src/client/history.ts +29 -52
- package/src/client/index.ts +11 -2
- package/src/client/listeners.ts +20 -0
- package/src/client/logins.ts +105 -0
- package/src/client/rpc.ts +144 -0
- package/src/client/streams.ts +488 -0
- package/src/client/transports.ts +62 -8
- package/src/client/turns.ts +171 -0
- package/src/core/agents/acp/acp-agent.ts +94 -118
- package/src/core/agents/acp/adapter.ts +20 -9
- package/src/core/agents/acp/client.ts +125 -47
- package/src/core/agents/acp/known-agents.ts +36 -4
- package/src/core/agents/acp/mappings.ts +64 -18
- package/src/core/agents/acp/requests.ts +125 -0
- package/src/core/agents/attachments.ts +18 -0
- package/src/core/agents/base.ts +120 -42
- package/src/core/agents/claude-code/adapter.ts +177 -238
- package/src/core/agents/claude-code/approvals.ts +270 -0
- package/src/core/agents/claude-code/claude-agent.ts +175 -158
- package/src/core/agents/claude-code/credentials.ts +171 -0
- package/src/core/agents/claude-code/events.ts +55 -0
- package/src/core/agents/claude-code/login.ts +269 -0
- package/src/core/agents/claude-code/mcp.ts +206 -0
- package/src/core/agents/claude-code/models.ts +15 -9
- package/src/core/agents/claude-code/options.ts +326 -39
- package/src/core/agents/claude-code/outcome.ts +209 -0
- package/src/core/agents/claude-code/session-pool.ts +136 -0
- package/src/core/agents/claude-code/session.ts +513 -0
- package/src/core/agents/claude-code/spawn.ts +144 -0
- package/src/core/agents/claude-code/spend.ts +160 -0
- package/src/core/agents/claude-code/tools.ts +47 -0
- package/src/core/agents/claude-code/turn-usage.ts +135 -0
- package/src/core/agents/claude-code/turn.ts +232 -0
- package/src/core/agents/codex-app-server/adapter.ts +314 -117
- package/src/core/agents/codex-app-server/client.ts +186 -84
- package/src/core/agents/codex-app-server/codex-agent.ts +343 -0
- package/src/core/agents/codex-app-server/commands.ts +228 -0
- package/src/core/agents/codex-app-server/credentials.ts +126 -0
- package/src/core/agents/codex-app-server/effort.ts +29 -0
- package/src/core/agents/codex-app-server/events.ts +47 -0
- package/src/core/agents/codex-app-server/homes.ts +64 -0
- package/src/core/agents/codex-app-server/input.ts +60 -0
- package/src/core/agents/codex-app-server/items.ts +149 -0
- package/src/core/agents/codex-app-server/login.ts +180 -0
- package/src/core/agents/codex-app-server/mcp.ts +182 -37
- package/src/core/agents/codex-app-server/models.ts +99 -46
- package/src/core/agents/codex-app-server/options.ts +146 -0
- package/src/core/agents/codex-app-server/plan-approval.ts +135 -0
- package/src/core/agents/codex-app-server/protocol.ts +117 -0
- package/src/core/agents/codex-app-server/requests.ts +332 -0
- package/src/core/agents/codex-app-server/session.ts +285 -0
- package/src/core/agents/codex-app-server/subagents.ts +108 -42
- package/src/core/agents/codex-app-server/thread-settings.ts +279 -0
- package/src/core/agents/codex-app-server/turn-items.ts +88 -0
- package/src/core/agents/codex-app-server/turn.ts +463 -0
- package/src/core/agents/config-fingerprint.ts +7 -14
- package/src/core/agents/credentials.ts +98 -0
- package/src/core/agents/elicitation.ts +75 -0
- package/src/core/agents/inherit-config.ts +21 -0
- package/src/core/agents/login.ts +116 -0
- package/src/core/agents/mcp-config.ts +112 -8
- package/src/core/agents/plan.ts +25 -0
- package/src/core/agents/registry.ts +21 -4
- package/src/core/agents/session-agent.ts +96 -4
- package/src/core/agents/{session-store.ts → session-pool.ts} +11 -5
- package/src/core/agents/stderr-tail.ts +75 -0
- package/src/core/agents/types.ts +40 -5
- package/src/core/index.ts +58 -48
- package/src/core/presets.ts +100 -39
- package/src/core/processes/identity.ts +113 -0
- package/src/core/processes/lifeline.ts +170 -0
- package/src/core/processes/native-processes.ts +379 -0
- package/src/core/processes/process-table.ts +174 -0
- package/src/core/provision/cache-trust.ts +121 -0
- package/src/core/provision/cache-usage.ts +69 -0
- package/src/core/provision/checksums.ts +64 -0
- package/src/core/provision/extract.ts +11 -2
- package/src/core/provision/index.ts +4 -1
- package/src/core/provision/install-build.ts +136 -0
- package/src/core/provision/npm.ts +112 -17
- package/src/core/provision/pins.ts +9 -33
- package/src/core/provision/platform.ts +12 -1
- package/src/core/provision/provisioner.ts +329 -397
- package/src/core/provision/releases.ts +86 -0
- package/src/core/provision/tools.ts +329 -0
- package/src/core/proxy/anthropic-proxy.ts +55 -25
- package/src/core/proxy/api-key-store.ts +2 -12
- package/src/core/proxy/loopback.ts +106 -0
- package/src/core/runtime/agent-runtime.ts +327 -498
- package/src/core/runtime/event-processor.ts +197 -70
- package/src/core/runtime/harness-clis.ts +61 -0
- package/src/core/runtime/harness-logins.ts +328 -0
- package/src/core/runtime/login-reads.ts +78 -0
- package/src/core/runtime/model-lists.ts +33 -48
- package/src/core/runtime/permission-policy.ts +113 -0
- package/src/core/runtime/request-broker.ts +204 -0
- package/src/core/runtime/steering.ts +112 -0
- package/src/core/runtime/turn-outcome.ts +30 -0
- package/src/core/runtime/turn.ts +360 -0
- package/src/core/utils/bounded.ts +12 -0
- package/src/core/utils/deadline.ts +38 -0
- package/src/core/utils/errors.ts +113 -21
- package/src/core/utils/is-record.ts +4 -0
- package/src/core/utils/loopback.ts +10 -0
- package/src/protocol/account.ts +104 -0
- package/src/protocol/auth.ts +199 -0
- package/src/protocol/canonical.ts +16 -0
- package/src/protocol/clis.ts +69 -0
- package/src/protocol/config.ts +60 -6
- package/src/protocol/conversation.ts +272 -0
- package/src/protocol/credentials.ts +145 -0
- package/src/protocol/errors.ts +78 -20
- package/src/protocol/execution.ts +5 -2
- package/src/protocol/factories.ts +55 -7
- package/src/protocol/guards.ts +55 -2
- package/src/protocol/harness.ts +56 -6
- package/src/protocol/history.ts +72 -64
- package/src/protocol/ids.ts +0 -12
- package/src/protocol/index.ts +9 -0
- package/src/protocol/lifecycle.ts +250 -79
- package/src/protocol/meta-keys.ts +17 -0
- package/src/protocol/meta.ts +3 -3
- package/src/protocol/models.ts +2 -43
- package/src/protocol/part-input.ts +2 -1
- package/src/protocol/parts.ts +12 -3
- package/src/protocol/reduce.ts +302 -413
- package/src/protocol/selectors.ts +1 -20
- package/src/protocol/seq-cursor.ts +14 -0
- package/src/protocol/stop-reasons.ts +1 -1
- package/src/protocol/thinking.ts +1 -30
- package/src/protocol/time.ts +2 -2
- package/src/protocol/tool-closure.ts +93 -0
- package/src/protocol/tool-state.ts +19 -4
- package/src/protocol/verify.ts +222 -92
- package/src/protocol/vocabulary.ts +21 -5
- package/src/protocol/wire-api.ts +232 -0
- package/src/protocol/wire.ts +351 -64
- package/src/server/acp/binding.ts +63 -103
- package/src/server/acp/session-records.ts +53 -0
- package/src/server/acp/translate.ts +129 -20
- package/src/server/agent-server.ts +223 -387
- package/src/server/bin.ts +280 -78
- package/src/server/feedback.ts +204 -14
- package/src/server/history.ts +116 -122
- package/src/server/index.ts +3 -8
- package/src/server/install.ts +107 -8
- package/src/server/open-parts.ts +95 -0
- package/src/server/routes.ts +391 -0
- package/src/server/secrets.ts +24 -0
- package/src/server/session-gate.ts +69 -0
- package/src/server/session-log.ts +14 -2
- package/src/server/session-store.ts +136 -72
- package/src/server/subscriptions.ts +232 -0
- package/src/server/transports.ts +125 -25
- package/src/server/wire-error.ts +31 -45
- package/src/sync/event-log.ts +31 -3
- package/src/sync/fit.ts +27 -11
- package/src/sync/history-reader.ts +10 -5
- package/src/sync/history-sqlite.ts +37 -42
- package/src/sync/history.ts +9 -15
- package/src/sync/index.ts +17 -5
- package/src/sync/journal-sqlite.ts +162 -76
- package/src/sync/journal.ts +91 -32
- package/src/sync/live-tails.ts +107 -0
- package/src/sync/projection.ts +35 -0
- package/src/sync/recovery.ts +80 -51
- package/src/sync/schema.ts +27 -6
- package/docs/rfds/0001-deterministic-echo-ids.md +0 -44
- package/docs/rfds/0002-native-subagents.md +0 -197
- package/src/client/request.ts +0 -19
- package/src/core/agents/claude-code/generator-session.ts +0 -572
- package/src/core/agents/claude-code/session-manager.ts +0 -166
- package/src/core/agents/codex-app-server/codex-app-server-agent.ts +0 -962
- package/src/core/agents/codex-items.ts +0 -149
- package/src/core/agents/codex-sdk/adapter.ts +0 -237
- package/src/core/agents/codex-sdk/codex-sdk-agent.ts +0 -330
- package/src/core/agents/tool-meta.ts +0 -68
package/docs/sync-integration.md
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
# Integrating durable sessions and shared history
|
|
2
2
|
|
|
3
3
|
The engine can own the durable conversation; the product still owns who may run
|
|
4
|
-
it, who may view it, and where its files and native agent state live.
|
|
5
|
-
|
|
6
|
-
not deploy or change AGNT or Deus Machine. See [the design](sync-experiment.md)
|
|
7
|
-
and [the history SDK](sync-history.md).
|
|
4
|
+
it, who may view it, and where its files and native agent state live. See
|
|
5
|
+
[durable sessions](durable-sessions.md) and [the history SDK](sync-history.md).
|
|
8
6
|
|
|
9
7
|
## The interfaces a product consumes
|
|
10
8
|
|
|
11
9
|
| Caller | Interface | Persistent truth |
|
|
12
10
|
| --- | --- | --- |
|
|
13
|
-
| Executing host | `
|
|
11
|
+
| Executing host | `await AgentServer.open(existingRuntime, {journal, history})` | One journal owner: input and receipt before the ack, each event before broadcast. |
|
|
14
12
|
| Command client | `runTurn` / `startTurn`, `getTurn`, `getSession`, `confirmSessionStopped` | Stable command ids; a retry converges on its receipt (`deduplicated`, saved `terminal`), and `runTurn` re-sends a start whose ack a dropped connection lost; interrupted execution is fenced until confirmed. |
|
|
15
13
|
| Uploader | `startHistorySync(journal.history, cloud, ref)` | The cloud's committed head decides what remains; nothing is queued locally. |
|
|
16
14
|
| Cloud storage | a `HistoryArchive`: `head`, `read`, `import` (+ `wait`, `checkpoint` for viewers) | Verify the prefix and hash chain, then commit the page and head in one transaction. |
|
|
@@ -19,7 +17,7 @@ and [the history SDK](sync-history.md).
|
|
|
19
17
|
`sourceId` identifies a journal, `sessionId` the logical session, and `seq` one
|
|
20
18
|
ordered fact; the native Claude/Codex session id is different, and none is a
|
|
21
19
|
credential. Records are agent-server's canonical events (messages, parts,
|
|
22
|
-
|
|
20
|
+
tools, permissions, terminal facts; no new token deltas), copied as their original JSON,
|
|
23
21
|
future fields included. The native provider session file is never sent. Render
|
|
24
22
|
with the canonical reducer, after storage.
|
|
25
23
|
|
|
@@ -42,65 +40,49 @@ or adapts the storage ports behind the platform's existing authenticated API.
|
|
|
42
40
|
The live proof's loopback `/writer` and `/viewer` paths simulate roles, not
|
|
43
41
|
authentication.
|
|
44
42
|
|
|
45
|
-
##
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
`
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
`
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
`apps/agent-server/index.ts` already constructs the upstream `AgentServer` as
|
|
89
|
-
`WireServer`, with its runtime from `agents/core/engine.ts`; `wire.ts`
|
|
90
|
-
multiplexes `deus/*` tools, auth and app registration, and
|
|
91
|
-
`apps/backend/src/services/agent/client.ts` wraps the standard SDK.
|
|
92
|
-
|
|
93
|
-
Pass a persistent journal at that construction site, close it after the server
|
|
94
|
-
shuts down, and add a worker using the existing cloud session mapping. The
|
|
95
|
-
packaged app runs Node: use `NodeSqliteSessionJournal` from `/sync/node-sqlite`
|
|
96
|
-
(Node 22.16 or later; same schema and guarantees as the Bun adapter), after
|
|
97
|
-
checking the packaged runtime version.
|
|
98
|
-
|
|
99
|
-
A viewer must not send `deus/hello` or register as the tool/auth host; only the
|
|
100
|
-
execution backend owns that role. Hydrate viewers through the projection-only
|
|
101
|
-
path in `event-handler.ts`: replaying history must not retrigger title
|
|
102
|
-
generation, Git checkpoints, automations or tools. Several people commanding one
|
|
103
|
-
running agent still need one execution owner and an authorized command router.
|
|
43
|
+
## A host that already embeds the runtime
|
|
44
|
+
|
|
45
|
+
A sidecar that used to call `runtime.run` directly keeps its customized
|
|
46
|
+
runtime, passes it to `AgentServer`, and from then on starts every turn through
|
|
47
|
+
the server's client, over an in-process `channelTransport` pair or the same
|
|
48
|
+
process's wire. Runtime hooks, auth, tool policies and MCP objects stay at the
|
|
49
|
+
embed tier. A turn started with `runtime.run` bypasses the journal's admission
|
|
50
|
+
and event persistence, and persisting from an `onEvent` observer misses
|
|
51
|
+
admission and failure ordering.
|
|
52
|
+
|
|
53
|
+
The host keeps its own connection to its platform and routing. The platform
|
|
54
|
+
implements a `HistoryArchive` over its transactional store, maps account
|
|
55
|
+
permissions to source identities and fans out committed history. Run one
|
|
56
|
+
worker per shared session; recreate it on startup and reconnect, and make sure
|
|
57
|
+
only one worker runs for a session. Every error goes to the worker's
|
|
58
|
+
`RetryPolicy`: a delay keeps it `retrying`, and only `undefined` moves it to
|
|
59
|
+
`blocked`. Return `undefined` for a `HistoryError`, which no retry fixes.
|
|
60
|
+
|
|
61
|
+
Keep product completion separate from the turn: if the host does work after
|
|
62
|
+
`turn.ended` (saving the workspace, then reporting status), that later step
|
|
63
|
+
needs its own durable record. Do not make the canonical turn end mean the
|
|
64
|
+
product's step finished.
|
|
65
|
+
|
|
66
|
+
The turn fingerprint covers the input and the config that shapes what the
|
|
67
|
+
agent does (`turnIdentity`; only the hash is stored). MCP endpoints, `env`,
|
|
68
|
+
`apiKey` and `includeRaw` stay out, so a retry with refreshed credentials or a
|
|
69
|
+
fresh per-session MCP URL converges on the first turn; any other difference is
|
|
70
|
+
`turnConflict`. After an uncertain start, read `getTurn(sessionId, turnId)`
|
|
71
|
+
before minting a new turn id: `unknownTurn` means the server never admitted it
|
|
72
|
+
(send it again), `unknownSession` that the server does not hold the session.
|
|
73
|
+
|
|
74
|
+
## A host that already serves the wire
|
|
75
|
+
|
|
76
|
+
Pass a persistent journal where the `AgentServer` is constructed, close it
|
|
77
|
+
after the server shuts down, and add a history worker for shared sessions. A
|
|
78
|
+
packaged Node app uses `NodeSqliteSessionJournal` from `/sync/node-sqlite`
|
|
79
|
+
(Node 22.16 or later; same schema and guarantees as the Bun adapter).
|
|
80
|
+
|
|
81
|
+
A viewer must not register as the tool or auth host; only the execution backend
|
|
82
|
+
owns that role. Hydrate viewers through a projection-only path: replaying
|
|
83
|
+
history must not retrigger title generation, checkpoints, automations or tools.
|
|
84
|
+
Several people commanding one running agent still need one execution owner and
|
|
85
|
+
an authorized command router.
|
|
104
86
|
|
|
105
87
|
## What becomes simpler, and what stays the product's
|
|
106
88
|
|
|
@@ -117,7 +99,7 @@ version to resume from instead of a guess about whether a write happened.
|
|
|
117
99
|
|
|
118
100
|
## Reproduce the live proof
|
|
119
101
|
|
|
120
|
-
|
|
102
|
+
In the agent-server repository, with Bun and an existing Claude login:
|
|
121
103
|
|
|
122
104
|
```sh
|
|
123
105
|
bun run control-agent-server doctor
|
|
@@ -131,3 +113,7 @@ commands, the provider version and every named assertion; traces, databases,
|
|
|
131
113
|
viewer snapshots and logs stay alongside, including for failed runs. This is a
|
|
132
114
|
local process, storage and network proof: no public cloud, product UI, real WAN,
|
|
133
115
|
Codex or ACP live run, or native home transfer is exercised. See `gaps`.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
Something here wrong, unclear or missing? [Report it to the maintainers](feedback.md).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zvada/agent-server",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "Harness-agnostic agent execution engine: run Claude Code, Codex (
|
|
3
|
+
"version": "0.3.19",
|
|
4
|
+
"description": "Harness-agnostic agent execution engine: run Claude Code, Codex (app-server), and any ACP agent behind one interface with a normalized event stream, multi-turn sessions, and resume. Root export is the wire contract; /core, /server, /client are the seats.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"keywords": [
|
|
@@ -25,79 +25,100 @@
|
|
|
25
25
|
"engines": {
|
|
26
26
|
"bun": ">=1.2.0"
|
|
27
27
|
},
|
|
28
|
-
"files": ["src", "docs", "AGENTS.md", "README.md", "CHANGELOG.md", "LICENSE"],
|
|
28
|
+
"files": ["src", "dist/types", "docs", "AGENTS.md", "README.md", "CHANGELOG.md", "LICENSE"],
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"bin": {
|
|
33
33
|
"agent-server": "./src/server/bin.ts"
|
|
34
34
|
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"prepack": "rm -rf dist && tsc -p tsconfig.build.json"
|
|
37
|
+
},
|
|
35
38
|
"exports": {
|
|
36
39
|
".": {
|
|
37
|
-
"
|
|
40
|
+
"agent-server-source": "./src/index.ts",
|
|
41
|
+
"types": "./dist/types/index.d.ts",
|
|
38
42
|
"default": "./src/index.ts"
|
|
39
43
|
},
|
|
40
44
|
"./protocol": {
|
|
41
|
-
"
|
|
45
|
+
"agent-server-source": "./src/protocol/index.ts",
|
|
46
|
+
"types": "./dist/types/protocol/index.d.ts",
|
|
42
47
|
"default": "./src/protocol/index.ts"
|
|
43
48
|
},
|
|
44
49
|
"./protocol/factories": {
|
|
45
|
-
"
|
|
50
|
+
"agent-server-source": "./src/protocol/factories.ts",
|
|
51
|
+
"types": "./dist/types/protocol/factories.d.ts",
|
|
46
52
|
"default": "./src/protocol/factories.ts"
|
|
47
53
|
},
|
|
48
54
|
"./protocol/guards": {
|
|
49
|
-
"
|
|
55
|
+
"agent-server-source": "./src/protocol/guards.ts",
|
|
56
|
+
"types": "./dist/types/protocol/guards.d.ts",
|
|
50
57
|
"default": "./src/protocol/guards.ts"
|
|
51
58
|
},
|
|
52
59
|
"./protocol/stop-reasons": {
|
|
53
|
-
"
|
|
60
|
+
"agent-server-source": "./src/protocol/stop-reasons.ts",
|
|
61
|
+
"types": "./dist/types/protocol/stop-reasons.d.ts",
|
|
54
62
|
"default": "./src/protocol/stop-reasons.ts"
|
|
55
63
|
},
|
|
56
64
|
"./protocol/seq-cursor": {
|
|
57
|
-
"
|
|
65
|
+
"agent-server-source": "./src/protocol/seq-cursor.ts",
|
|
66
|
+
"types": "./dist/types/protocol/seq-cursor.d.ts",
|
|
58
67
|
"default": "./src/protocol/seq-cursor.ts"
|
|
59
68
|
},
|
|
60
69
|
"./protocol/selectors": {
|
|
61
|
-
"
|
|
70
|
+
"agent-server-source": "./src/protocol/selectors.ts",
|
|
71
|
+
"types": "./dist/types/protocol/selectors.d.ts",
|
|
62
72
|
"default": "./src/protocol/selectors.ts"
|
|
63
73
|
},
|
|
64
74
|
"./core": {
|
|
65
|
-
"
|
|
75
|
+
"agent-server-source": "./src/core/index.ts",
|
|
76
|
+
"types": "./dist/types/core/index.d.ts",
|
|
66
77
|
"default": "./src/core/index.ts"
|
|
67
78
|
},
|
|
68
79
|
"./core/proxy": {
|
|
69
|
-
"
|
|
80
|
+
"agent-server-source": "./src/core/proxy/index.ts",
|
|
81
|
+
"types": "./dist/types/core/proxy/index.d.ts",
|
|
70
82
|
"default": "./src/core/proxy/index.ts"
|
|
71
83
|
},
|
|
72
84
|
"./server": {
|
|
73
|
-
"
|
|
85
|
+
"agent-server-source": "./src/server/index.ts",
|
|
86
|
+
"types": "./dist/types/server/index.d.ts",
|
|
74
87
|
"default": "./src/server/index.ts"
|
|
75
88
|
},
|
|
76
89
|
"./client": {
|
|
77
|
-
"
|
|
90
|
+
"agent-server-source": "./src/client/index.ts",
|
|
91
|
+
"types": "./dist/types/client/index.d.ts",
|
|
78
92
|
"default": "./src/client/index.ts"
|
|
79
93
|
},
|
|
94
|
+
"./accounts": {
|
|
95
|
+
"agent-server-source": "./src/accounts/index.ts",
|
|
96
|
+
"types": "./dist/types/accounts/index.d.ts",
|
|
97
|
+
"default": "./src/accounts/index.ts"
|
|
98
|
+
},
|
|
80
99
|
"./package.json": "./package.json",
|
|
81
100
|
"./sync": {
|
|
82
|
-
"
|
|
101
|
+
"agent-server-source": "./src/sync/index.ts",
|
|
102
|
+
"types": "./dist/types/sync/index.d.ts",
|
|
83
103
|
"default": "./src/sync/index.ts"
|
|
84
104
|
},
|
|
85
105
|
"./sync/sqlite": {
|
|
86
|
-
"
|
|
106
|
+
"agent-server-source": "./src/sync/sqlite.ts",
|
|
107
|
+
"types": "./dist/types/sync/sqlite.d.ts",
|
|
87
108
|
"default": "./src/sync/sqlite.ts"
|
|
88
109
|
},
|
|
89
110
|
"./sync/node-sqlite": {
|
|
90
|
-
"
|
|
111
|
+
"agent-server-source": "./src/sync/node-sqlite.ts",
|
|
112
|
+
"types": "./dist/types/sync/node-sqlite.d.ts",
|
|
91
113
|
"default": "./src/sync/node-sqlite.ts"
|
|
92
114
|
}
|
|
93
115
|
},
|
|
94
116
|
"dependencies": {
|
|
95
|
-
"zod": "^4.
|
|
117
|
+
"zod": "^4.6.6"
|
|
96
118
|
},
|
|
97
119
|
"peerDependencies": {
|
|
98
|
-
"@agentclientprotocol/sdk": ">=1.
|
|
99
|
-
"@anthropic-ai/claude-agent-sdk": ">=0.
|
|
100
|
-
"@openai/codex-sdk": ">=0.40.0"
|
|
120
|
+
"@agentclientprotocol/sdk": ">=1.3.0",
|
|
121
|
+
"@anthropic-ai/claude-agent-sdk": ">=0.3.277"
|
|
101
122
|
},
|
|
102
123
|
"peerDependenciesMeta": {
|
|
103
124
|
"@agentclientprotocol/sdk": {
|
|
@@ -105,15 +126,12 @@
|
|
|
105
126
|
},
|
|
106
127
|
"@anthropic-ai/claude-agent-sdk": {
|
|
107
128
|
"optional": true
|
|
108
|
-
},
|
|
109
|
-
"@openai/codex-sdk": {
|
|
110
|
-
"optional": true
|
|
111
129
|
}
|
|
112
130
|
},
|
|
113
131
|
"devDependencies": {
|
|
114
132
|
"@agentclientprotocol/sdk": "^1.7.0",
|
|
115
133
|
"@anthropic-ai/claude-agent-sdk": "0.3.288",
|
|
116
|
-
"@openai/codex
|
|
134
|
+
"@openai/codex": "0.160.0",
|
|
117
135
|
"@types/bun": "^1.2.0"
|
|
118
136
|
}
|
|
119
137
|
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import type { CredentialGrant } from "../protocol/credentials.ts";
|
|
2
|
+
import { AccountError, type ProviderOptions, call, claimsOf, isRecord, text } from "./http.ts";
|
|
3
|
+
|
|
4
|
+
// The Codex CLI's own OAuth client, as the `codex` binary carries it, and its
|
|
5
|
+
// device sign-in (codex-rs `login/`). A public client: no secret, the same for
|
|
6
|
+
// every user. The issuer is fixed, so no caller-supplied address ever receives
|
|
7
|
+
// these credentials.
|
|
8
|
+
const ISSUER = "https://auth.openai.com";
|
|
9
|
+
const CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
10
|
+
/** How long a device code waits for its person. */
|
|
11
|
+
const DEVICE_CODE_LIFETIME_MS = 15 * 60_000;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A ChatGPT sign-in under way: show `userCode` and `verificationUrl`, then
|
|
15
|
+
* `pollChatGptLogin` every `intervalMs` until `expiresAt`. Keep it on the
|
|
16
|
+
* server: whoever holds `deviceAuthId` and `userCode` finishes the sign-in.
|
|
17
|
+
*/
|
|
18
|
+
export interface ChatGptLogin {
|
|
19
|
+
deviceAuthId: string;
|
|
20
|
+
userCode: string;
|
|
21
|
+
verificationUrl: string;
|
|
22
|
+
intervalMs: number;
|
|
23
|
+
expiresAt: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A grant from what OpenAI's token endpoint answered: the account and plan are the id token's. */
|
|
27
|
+
function grantFrom(
|
|
28
|
+
body: unknown,
|
|
29
|
+
options: ProviderOptions,
|
|
30
|
+
previous?: CredentialGrant,
|
|
31
|
+
): CredentialGrant {
|
|
32
|
+
const old = previous?.credential.type === "chatgpt" ? previous.credential : undefined;
|
|
33
|
+
const answer = isRecord(body) ? body : {};
|
|
34
|
+
// A renewal answered without a token renewed nothing, and may have spent the refresh token.
|
|
35
|
+
const accessToken = text(answer.access_token);
|
|
36
|
+
const refreshToken = text(answer.refresh_token) ?? previous?.refreshToken;
|
|
37
|
+
const idToken = text(answer.id_token);
|
|
38
|
+
if (!accessToken || !refreshToken) {
|
|
39
|
+
throw new AccountError("OpenAI returned an incomplete login. Sign in again.", true);
|
|
40
|
+
}
|
|
41
|
+
const identity = idToken ? claimsOf(idToken) : {};
|
|
42
|
+
const auth = isRecord(identity["https://api.openai.com/auth"])
|
|
43
|
+
? identity["https://api.openai.com/auth"]
|
|
44
|
+
: {};
|
|
45
|
+
const accountId = text(auth.chatgpt_account_id) ?? old?.accountId;
|
|
46
|
+
const expiry = claimsOf(accessToken).exp;
|
|
47
|
+
if (!accountId)
|
|
48
|
+
throw new AccountError("OpenAI returned no ChatGPT account. Sign in again.", true);
|
|
49
|
+
if (old && old.accountId !== accountId) {
|
|
50
|
+
throw new AccountError("The ChatGPT account changed. Sign in again.", true);
|
|
51
|
+
}
|
|
52
|
+
const plan = text(auth.chatgpt_plan_type) ?? old?.plan;
|
|
53
|
+
const email = text(identity.email) ?? previous?.email;
|
|
54
|
+
return {
|
|
55
|
+
harness: "codex-app-server",
|
|
56
|
+
credential: {
|
|
57
|
+
type: "chatgpt",
|
|
58
|
+
accessToken,
|
|
59
|
+
accountId,
|
|
60
|
+
...(plan && { plan }),
|
|
61
|
+
...(typeof expiry === "number" && { expiresAt: expiry * 1000 }),
|
|
62
|
+
},
|
|
63
|
+
refreshToken,
|
|
64
|
+
...(email && { email }),
|
|
65
|
+
...(plan && { plan }),
|
|
66
|
+
obtainedAt: (options.now ?? Date.now)(),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Start a ChatGPT sign-in with a device code, which a person enters on any
|
|
72
|
+
* device: what a hosted product offers, since Codex's browser sign-in calls
|
|
73
|
+
* back to `localhost` only. The account must allow device codes (ChatGPT
|
|
74
|
+
* settings, Security).
|
|
75
|
+
*/
|
|
76
|
+
export async function startChatGptLogin(options: ProviderOptions = {}): Promise<ChatGptLogin> {
|
|
77
|
+
const answer = await call(
|
|
78
|
+
`${ISSUER}/api/accounts/deviceauth/usercode`,
|
|
79
|
+
{
|
|
80
|
+
method: "POST",
|
|
81
|
+
headers: { "content-type": "application/json" },
|
|
82
|
+
body: JSON.stringify({ client_id: CLIENT_ID }),
|
|
83
|
+
},
|
|
84
|
+
options,
|
|
85
|
+
);
|
|
86
|
+
const body = isRecord(answer.body) ? answer.body : {};
|
|
87
|
+
const deviceAuthId = text(body.device_auth_id);
|
|
88
|
+
const userCode = text(body.user_code) ?? text(body.usercode);
|
|
89
|
+
if (!answer.ok || !deviceAuthId || !userCode) {
|
|
90
|
+
throw new AccountError(
|
|
91
|
+
"OpenAI did not start the sign-in. Allow device code sign-in in ChatGPT settings (Security), then try again.",
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
const interval = Number(body.interval);
|
|
95
|
+
return {
|
|
96
|
+
deviceAuthId,
|
|
97
|
+
userCode,
|
|
98
|
+
verificationUrl: `${ISSUER}/codex/device`,
|
|
99
|
+
intervalMs: Math.max(Number.isFinite(interval) ? interval : 5, 5) * 1000,
|
|
100
|
+
expiresAt: (options.now ?? Date.now)() + DEVICE_CODE_LIFETIME_MS,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Ask once whether the person approved: the grant once they did, `undefined`
|
|
106
|
+
* while they have not. Poll no faster than `intervalMs`. The approval's code is
|
|
107
|
+
* exchanged once, never retried: a lost answer means sign in again.
|
|
108
|
+
*/
|
|
109
|
+
export async function pollChatGptLogin(
|
|
110
|
+
login: ChatGptLogin,
|
|
111
|
+
options: ProviderOptions = {},
|
|
112
|
+
): Promise<CredentialGrant | undefined> {
|
|
113
|
+
if ((options.now ?? Date.now)() > login.expiresAt) {
|
|
114
|
+
throw new AccountError("The sign-in code expired. Start again.");
|
|
115
|
+
}
|
|
116
|
+
const answer = await call(
|
|
117
|
+
`${ISSUER}/api/accounts/deviceauth/token`,
|
|
118
|
+
{
|
|
119
|
+
method: "POST",
|
|
120
|
+
headers: { "content-type": "application/json" },
|
|
121
|
+
body: JSON.stringify({ device_auth_id: login.deviceAuthId, user_code: login.userCode }),
|
|
122
|
+
},
|
|
123
|
+
options,
|
|
124
|
+
).catch(() => undefined);
|
|
125
|
+
// Waiting, as Codex reads it (403, 404), and a failure worth asking again (429, 5xx).
|
|
126
|
+
if (
|
|
127
|
+
!answer ||
|
|
128
|
+
answer.status === 403 ||
|
|
129
|
+
answer.status === 404 ||
|
|
130
|
+
answer.status === 429 ||
|
|
131
|
+
answer.status >= 500
|
|
132
|
+
) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
const body = isRecord(answer.body) ? answer.body : {};
|
|
136
|
+
const code = text(body.authorization_code);
|
|
137
|
+
const verifier = text(body.code_verifier);
|
|
138
|
+
if (!answer.ok || !code || !verifier)
|
|
139
|
+
throw new AccountError("OpenAI did not finish the sign-in. Start again.");
|
|
140
|
+
const token = await call(
|
|
141
|
+
`${ISSUER}/oauth/token`,
|
|
142
|
+
{
|
|
143
|
+
method: "POST",
|
|
144
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
145
|
+
body: new URLSearchParams({
|
|
146
|
+
grant_type: "authorization_code",
|
|
147
|
+
client_id: CLIENT_ID,
|
|
148
|
+
code,
|
|
149
|
+
code_verifier: verifier,
|
|
150
|
+
redirect_uri: `${ISSUER}/deviceauth/callback`,
|
|
151
|
+
}).toString(),
|
|
152
|
+
},
|
|
153
|
+
options,
|
|
154
|
+
);
|
|
155
|
+
if (!token.ok) throw new AccountError("OpenAI refused this sign-in. Start again.");
|
|
156
|
+
return grantFrom(token.body, options);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Renew a ChatGPT grant: the same account with fresh tokens, which the
|
|
161
|
+
* product stores in its place. One renewal at a time per grant: a renewal
|
|
162
|
+
* whose answer was lost may have happened, and is not tried again here.
|
|
163
|
+
*/
|
|
164
|
+
export async function refreshChatGptGrant(
|
|
165
|
+
grant: CredentialGrant,
|
|
166
|
+
options: ProviderOptions = {},
|
|
167
|
+
): Promise<CredentialGrant> {
|
|
168
|
+
if (grant.credential.type !== "chatgpt" || !grant.refreshToken) {
|
|
169
|
+
throw new AccountError("This is not a ChatGPT grant that renews.");
|
|
170
|
+
}
|
|
171
|
+
const answer = await call(
|
|
172
|
+
`${ISSUER}/oauth/token`,
|
|
173
|
+
{
|
|
174
|
+
method: "POST",
|
|
175
|
+
headers: { "content-type": "application/json" },
|
|
176
|
+
body: JSON.stringify({
|
|
177
|
+
client_id: CLIENT_ID,
|
|
178
|
+
grant_type: "refresh_token",
|
|
179
|
+
refresh_token: grant.refreshToken,
|
|
180
|
+
}),
|
|
181
|
+
},
|
|
182
|
+
options,
|
|
183
|
+
);
|
|
184
|
+
if (!answer.ok) {
|
|
185
|
+
const refused = answer.status === 400 || answer.status === 401;
|
|
186
|
+
throw new AccountError(
|
|
187
|
+
refused
|
|
188
|
+
? "The ChatGPT login expired or was revoked. Sign in again."
|
|
189
|
+
: "OpenAI did not renew the login. Try again.",
|
|
190
|
+
refused,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
return grantFrom(answer.body, options, grant);
|
|
194
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ClaudeCredential,
|
|
3
|
+
type CodexCredential,
|
|
4
|
+
type CredentialGrant,
|
|
5
|
+
type HarnessCredential,
|
|
6
|
+
credentialRunsOn,
|
|
7
|
+
} from "../protocol/credentials.ts";
|
|
8
|
+
import type { AgentHarness } from "../protocol/harness.ts";
|
|
9
|
+
import { AccountError, type ProviderOptions, call } from "./http.ts";
|
|
10
|
+
|
|
11
|
+
/** What `checkCredential` found. */
|
|
12
|
+
export type CredentialCheck = { ok: true } | { ok: false; error: string; reconnect: boolean };
|
|
13
|
+
|
|
14
|
+
const ANTHROPIC_MODELS = "https://api.anthropic.com/v1/models?limit=1";
|
|
15
|
+
const OPENAI_MODELS = "https://api.openai.com/v1/models";
|
|
16
|
+
const ANTHROPIC_VERSION = "2023-06-01";
|
|
17
|
+
const OK: CredentialCheck = { ok: true };
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Whether a credential works, by one cheap request to its provider (a model
|
|
21
|
+
* list): a key or token the provider refuses is `reconnect`. A ChatGPT token
|
|
22
|
+
* is checked by its expiry only, as no public request takes it, and a
|
|
23
|
+
* gateway's key (`baseUrl`) not at all.
|
|
24
|
+
*/
|
|
25
|
+
export async function checkCredential(
|
|
26
|
+
harness: AgentHarness,
|
|
27
|
+
credential: HarnessCredential,
|
|
28
|
+
options: ProviderOptions = {},
|
|
29
|
+
): Promise<CredentialCheck> {
|
|
30
|
+
if (harness === "claude-code") {
|
|
31
|
+
const runs = credentialRunsOn(harness, credential);
|
|
32
|
+
return runs.ok ? checkClaude(runs.credential, options) : unrunnable(runs.error);
|
|
33
|
+
}
|
|
34
|
+
if (harness === "codex-app-server") {
|
|
35
|
+
const runs = credentialRunsOn(harness, credential);
|
|
36
|
+
return runs.ok ? checkCodex(runs.credential, options) : unrunnable(runs.error);
|
|
37
|
+
}
|
|
38
|
+
return unrunnable(`${harness} runs on no credential a product holds.`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const unrunnable = (error: string): CredentialCheck => ({ ok: false, error, reconnect: true });
|
|
42
|
+
|
|
43
|
+
function checkClaude(
|
|
44
|
+
credential: ClaudeCredential,
|
|
45
|
+
options: ProviderOptions,
|
|
46
|
+
): Promise<CredentialCheck> | CredentialCheck {
|
|
47
|
+
if (credential.type === "oauth_token") {
|
|
48
|
+
return listModels(
|
|
49
|
+
ANTHROPIC_MODELS,
|
|
50
|
+
{
|
|
51
|
+
authorization: `Bearer ${credential.accessToken}`,
|
|
52
|
+
"anthropic-version": ANTHROPIC_VERSION,
|
|
53
|
+
"anthropic-beta": "oauth-2025-04-20",
|
|
54
|
+
},
|
|
55
|
+
options,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
// A gateway's key: what a person pasted would point this server's
|
|
59
|
+
// requests anywhere, so a product trusts its gateways by its own list.
|
|
60
|
+
if (credential.baseUrl) return OK;
|
|
61
|
+
return listModels(
|
|
62
|
+
ANTHROPIC_MODELS,
|
|
63
|
+
{ "x-api-key": credential.apiKey, "anthropic-version": ANTHROPIC_VERSION },
|
|
64
|
+
options,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function checkCodex(
|
|
69
|
+
credential: CodexCredential,
|
|
70
|
+
options: ProviderOptions,
|
|
71
|
+
): Promise<CredentialCheck> | CredentialCheck {
|
|
72
|
+
if (credential.type === "api_key") {
|
|
73
|
+
return listModels(OPENAI_MODELS, { authorization: `Bearer ${credential.apiKey}` }, options);
|
|
74
|
+
}
|
|
75
|
+
const expired =
|
|
76
|
+
credential.expiresAt !== undefined && credential.expiresAt <= (options.now ?? Date.now)();
|
|
77
|
+
return expired
|
|
78
|
+
? { ok: false, error: "The ChatGPT token expired: renew it.", reconnect: false }
|
|
79
|
+
: OK;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** One cheap request with the credential: a refusal is `reconnect`. */
|
|
83
|
+
async function listModels(
|
|
84
|
+
url: string,
|
|
85
|
+
headers: Record<string, string>,
|
|
86
|
+
options: ProviderOptions,
|
|
87
|
+
): Promise<CredentialCheck> {
|
|
88
|
+
const answer = await call(url, { headers }, options);
|
|
89
|
+
if (answer.ok) return OK;
|
|
90
|
+
const refused = answer.status === 401 || answer.status === 403;
|
|
91
|
+
return {
|
|
92
|
+
ok: false,
|
|
93
|
+
error: refused
|
|
94
|
+
? "The provider refused this credential."
|
|
95
|
+
: `The provider answered ${answer.status}.`,
|
|
96
|
+
reconnect: refused,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* A key or token the person pasted (an API key, a `claude setup-token`
|
|
102
|
+
* token), checked: the grant to store, or why not.
|
|
103
|
+
*/
|
|
104
|
+
export async function pastedGrant(
|
|
105
|
+
harness: AgentHarness,
|
|
106
|
+
credential: HarnessCredential,
|
|
107
|
+
options: ProviderOptions = {},
|
|
108
|
+
): Promise<CredentialGrant> {
|
|
109
|
+
const check = await checkCredential(harness, credential, options);
|
|
110
|
+
if (!check.ok) throw new AccountError(check.error, check.reconnect);
|
|
111
|
+
return { harness, credential, obtainedAt: (options.now ?? Date.now)() };
|
|
112
|
+
}
|