@zvada/agent-server 0.3.18 → 0.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +11 -26
- package/CHANGELOG.md +1005 -1
- package/README.md +35 -39
- package/dist/types/accounts/chatgpt.d.ts +34 -0
- package/dist/types/accounts/chatgpt.d.ts.map +1 -0
- package/dist/types/accounts/check.d.ts +24 -0
- package/dist/types/accounts/check.d.ts.map +1 -0
- package/dist/types/accounts/claude.d.ts +21 -0
- package/dist/types/accounts/claude.d.ts.map +1 -0
- package/dist/types/accounts/endpoint.d.ts +50 -0
- package/dist/types/accounts/endpoint.d.ts.map +1 -0
- package/dist/types/accounts/http.d.ts +38 -0
- package/dist/types/accounts/http.d.ts.map +1 -0
- package/dist/types/accounts/index.d.ts +6 -0
- package/dist/types/accounts/index.d.ts.map +1 -0
- package/dist/types/client/client.d.ts +272 -0
- package/dist/types/client/client.d.ts.map +1 -0
- package/dist/types/client/connection.d.ts +160 -0
- package/dist/types/client/connection.d.ts.map +1 -0
- package/dist/types/client/history.d.ts +8 -0
- package/dist/types/client/history.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +5 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/listeners.d.ts +8 -0
- package/dist/types/client/listeners.d.ts.map +1 -0
- package/dist/types/client/logins.d.ts +35 -0
- package/dist/types/client/logins.d.ts.map +1 -0
- package/dist/types/client/rpc.d.ts +46 -0
- package/dist/types/client/rpc.d.ts.map +1 -0
- package/dist/types/client/streams.d.ts +150 -0
- package/dist/types/client/streams.d.ts.map +1 -0
- package/dist/types/client/transports.d.ts +35 -0
- package/dist/types/client/transports.d.ts.map +1 -0
- package/dist/types/client/turns.d.ts +81 -0
- package/dist/types/client/turns.d.ts.map +1 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts +68 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -0
- package/dist/types/core/agents/acp/adapter.d.ts +39 -0
- package/dist/types/core/agents/acp/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/acp/client.d.ts +90 -0
- package/dist/types/core/agents/acp/client.d.ts.map +1 -0
- package/dist/types/core/agents/acp/known-agents.d.ts +35 -0
- package/dist/types/core/agents/acp/known-agents.d.ts.map +1 -0
- package/dist/types/core/agents/acp/mappings.d.ts +46 -0
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -0
- package/dist/types/core/agents/acp/requests.d.ts +26 -0
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -0
- package/dist/types/core/agents/attachments.d.ts +11 -0
- package/dist/types/core/agents/attachments.d.ts.map +1 -0
- package/dist/types/core/agents/base.d.ts +227 -0
- package/dist/types/core/agents/base.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts +58 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts +26 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +70 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts +54 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/events.d.ts +42 -0
- package/dist/types/core/agents/claude-code/events.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/login.d.ts +61 -0
- package/dist/types/core/agents/claude-code/login.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts +52 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/models.d.ts +30 -0
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/options.d.ts +183 -0
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts +50 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts +36 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session.d.ts +148 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts +29 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spend.d.ts +58 -0
- package/dist/types/core/agents/claude-code/spend.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/tools.d.ts +4 -0
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts +52 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn.d.ts +121 -0
- package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts +59 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts +116 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +113 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts +66 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts +49 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts +12 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts +45 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts +20 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts +26 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts +31 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts +38 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +62 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts +67 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts +40 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts +19 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts +99 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts +42 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts +96 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts +53 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts +87 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts +33 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts +163 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts.map +1 -0
- package/dist/types/core/agents/config-fingerprint.d.ts +5 -0
- package/dist/types/core/agents/config-fingerprint.d.ts.map +1 -0
- package/dist/types/core/agents/credentials.d.ts +28 -0
- package/dist/types/core/agents/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/elicitation.d.ts +37 -0
- package/dist/types/core/agents/elicitation.d.ts.map +1 -0
- package/dist/types/core/agents/inherit-config.d.ts +18 -0
- package/dist/types/core/agents/inherit-config.d.ts.map +1 -0
- package/dist/types/core/agents/login.d.ts +67 -0
- package/dist/types/core/agents/login.d.ts.map +1 -0
- package/dist/types/core/agents/mcp-config.d.ts +57 -0
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -0
- package/dist/types/core/agents/plan.d.ts +16 -0
- package/dist/types/core/agents/plan.d.ts.map +1 -0
- package/dist/types/core/agents/registry.d.ts +30 -0
- package/dist/types/core/agents/registry.d.ts.map +1 -0
- package/dist/types/core/agents/session-agent.d.ts +48 -0
- package/dist/types/core/agents/session-agent.d.ts.map +1 -0
- package/dist/types/core/agents/session-pool.d.ts +41 -0
- package/dist/types/core/agents/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/stderr-tail.d.ts +28 -0
- package/dist/types/core/agents/stderr-tail.d.ts.map +1 -0
- package/dist/types/core/agents/thinking-levels.d.ts +4 -0
- package/dist/types/core/agents/thinking-levels.d.ts.map +1 -0
- package/dist/types/core/agents/types.d.ts +124 -0
- package/dist/types/core/agents/types.d.ts.map +1 -0
- package/dist/types/core/diagnostics.d.ts +36 -0
- package/dist/types/core/diagnostics.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +29 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/presets.d.ts +80 -0
- package/dist/types/core/presets.d.ts.map +1 -0
- package/dist/types/core/processes/identity.d.ts +31 -0
- package/dist/types/core/processes/identity.d.ts.map +1 -0
- package/dist/types/core/processes/lifeline.d.ts +47 -0
- package/dist/types/core/processes/lifeline.d.ts.map +1 -0
- package/dist/types/core/processes/native-processes.d.ts +130 -0
- package/dist/types/core/processes/native-processes.d.ts.map +1 -0
- package/dist/types/core/processes/process-table.d.ts +43 -0
- package/dist/types/core/processes/process-table.d.ts.map +1 -0
- package/dist/types/core/provision/cache-trust.d.ts +13 -0
- package/dist/types/core/provision/cache-trust.d.ts.map +1 -0
- package/dist/types/core/provision/cache-usage.d.ts +14 -0
- package/dist/types/core/provision/cache-usage.d.ts.map +1 -0
- package/dist/types/core/provision/checksums.d.ts +46 -0
- package/dist/types/core/provision/checksums.d.ts.map +1 -0
- package/dist/types/core/provision/extract.d.ts +7 -0
- package/dist/types/core/provision/extract.d.ts.map +1 -0
- package/dist/types/core/provision/index.d.ts +5 -0
- package/dist/types/core/provision/index.d.ts.map +1 -0
- package/dist/types/core/provision/install-build.d.ts +36 -0
- package/dist/types/core/provision/install-build.d.ts.map +1 -0
- package/dist/types/core/provision/npm.d.ts +40 -0
- package/dist/types/core/provision/npm.d.ts.map +1 -0
- package/dist/types/core/provision/pins.d.ts +24 -0
- package/dist/types/core/provision/pins.d.ts.map +1 -0
- package/dist/types/core/provision/platform.d.ts +28 -0
- package/dist/types/core/provision/platform.d.ts.map +1 -0
- package/dist/types/core/provision/provisioner.d.ts +189 -0
- package/dist/types/core/provision/provisioner.d.ts.map +1 -0
- package/dist/types/core/provision/releases.d.ts +8 -0
- package/dist/types/core/provision/releases.d.ts.map +1 -0
- package/dist/types/core/provision/tools.d.ts +81 -0
- package/dist/types/core/provision/tools.d.ts.map +1 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts +52 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts.map +1 -0
- package/dist/types/core/proxy/api-key-store.d.ts +37 -0
- package/dist/types/core/proxy/api-key-store.d.ts.map +1 -0
- package/dist/types/core/proxy/index.d.ts +3 -0
- package/dist/types/core/proxy/index.d.ts.map +1 -0
- package/dist/types/core/proxy/loopback.d.ts +14 -0
- package/dist/types/core/proxy/loopback.d.ts.map +1 -0
- package/dist/types/core/runtime/agent-runtime.d.ts +181 -0
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -0
- package/dist/types/core/runtime/event-processor.d.ts +87 -0
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -0
- package/dist/types/core/runtime/event-sink.d.ts +44 -0
- package/dist/types/core/runtime/event-sink.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-clis.d.ts +10 -0
- package/dist/types/core/runtime/harness-clis.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-logins.d.ts +68 -0
- package/dist/types/core/runtime/harness-logins.d.ts.map +1 -0
- package/dist/types/core/runtime/login-reads.d.ts +28 -0
- package/dist/types/core/runtime/login-reads.d.ts.map +1 -0
- package/dist/types/core/runtime/model-lists.d.ts +37 -0
- package/dist/types/core/runtime/model-lists.d.ts.map +1 -0
- package/dist/types/core/runtime/permission-policy.d.ts +61 -0
- package/dist/types/core/runtime/permission-policy.d.ts.map +1 -0
- package/dist/types/core/runtime/request-broker.d.ts +49 -0
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -0
- package/dist/types/core/runtime/steering.d.ts +38 -0
- package/dist/types/core/runtime/steering.d.ts.map +1 -0
- package/dist/types/core/runtime/turn-outcome.d.ts +21 -0
- package/dist/types/core/runtime/turn-outcome.d.ts.map +1 -0
- package/dist/types/core/runtime/turn.d.ts +121 -0
- package/dist/types/core/runtime/turn.d.ts.map +1 -0
- package/dist/types/core/utils/bounded.d.ts +6 -0
- package/dist/types/core/utils/bounded.d.ts.map +1 -0
- package/dist/types/core/utils/deadline.d.ts +14 -0
- package/dist/types/core/utils/deadline.d.ts.map +1 -0
- package/dist/types/core/utils/errors.d.ts +104 -0
- package/dist/types/core/utils/errors.d.ts.map +1 -0
- package/dist/types/core/utils/is-record.d.ts +3 -0
- package/dist/types/core/utils/is-record.d.ts.map +1 -0
- package/dist/types/core/utils/loopback.d.ts +6 -0
- package/dist/types/core/utils/loopback.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/protocol/account.d.ts +26 -0
- package/dist/types/protocol/account.d.ts.map +1 -0
- package/dist/types/protocol/async-queue.d.ts +21 -0
- package/dist/types/protocol/async-queue.d.ts.map +1 -0
- package/dist/types/protocol/auth.d.ts +228 -0
- package/dist/types/protocol/auth.d.ts.map +1 -0
- package/dist/types/protocol/canonical.d.ts +9 -0
- package/dist/types/protocol/canonical.d.ts.map +1 -0
- package/dist/types/protocol/clis.d.ts +74 -0
- package/dist/types/protocol/clis.d.ts.map +1 -0
- package/dist/types/protocol/config.d.ts +200 -0
- package/dist/types/protocol/config.d.ts.map +1 -0
- package/dist/types/protocol/conversation.d.ts +942 -0
- package/dist/types/protocol/conversation.d.ts.map +1 -0
- package/dist/types/protocol/credentials.d.ts +145 -0
- package/dist/types/protocol/credentials.d.ts.map +1 -0
- package/dist/types/protocol/errors.d.ts +36 -0
- package/dist/types/protocol/errors.d.ts.map +1 -0
- package/dist/types/protocol/execution.d.ts +28 -0
- package/dist/types/protocol/execution.d.ts.map +1 -0
- package/dist/types/protocol/factories.d.ts +94 -0
- package/dist/types/protocol/factories.d.ts.map +1 -0
- package/dist/types/protocol/guards.d.ts +55 -0
- package/dist/types/protocol/guards.d.ts.map +1 -0
- package/dist/types/protocol/harness.d.ts +70 -0
- package/dist/types/protocol/harness.d.ts.map +1 -0
- package/dist/types/protocol/history.d.ts +318 -0
- package/dist/types/protocol/history.d.ts.map +1 -0
- package/dist/types/protocol/ids.d.ts +9 -0
- package/dist/types/protocol/ids.d.ts.map +1 -0
- package/dist/types/protocol/index.d.ts +35 -0
- package/dist/types/protocol/index.d.ts.map +1 -0
- package/dist/types/protocol/lifecycle.d.ts +1190 -0
- package/dist/types/protocol/lifecycle.d.ts.map +1 -0
- package/dist/types/protocol/meta-keys.d.ts +17 -0
- package/dist/types/protocol/meta-keys.d.ts.map +1 -0
- package/dist/types/protocol/meta.d.ts +13 -0
- package/dist/types/protocol/meta.d.ts.map +1 -0
- package/dist/types/protocol/model-catalog.d.ts +11 -0
- package/dist/types/protocol/model-catalog.d.ts.map +1 -0
- package/dist/types/protocol/models.d.ts +107 -0
- package/dist/types/protocol/models.d.ts.map +1 -0
- package/dist/types/protocol/part-input.d.ts +101 -0
- package/dist/types/protocol/part-input.d.ts.map +1 -0
- package/dist/types/protocol/parts.d.ts +357 -0
- package/dist/types/protocol/parts.d.ts.map +1 -0
- package/dist/types/protocol/reduce.d.ts +26 -0
- package/dist/types/protocol/reduce.d.ts.map +1 -0
- package/dist/types/protocol/selectors.d.ts +64 -0
- package/dist/types/protocol/selectors.d.ts.map +1 -0
- package/dist/types/protocol/seq-cursor.d.ts +66 -0
- package/dist/types/protocol/seq-cursor.d.ts.map +1 -0
- package/dist/types/protocol/stop-reasons.d.ts +33 -0
- package/dist/types/protocol/stop-reasons.d.ts.map +1 -0
- package/dist/types/protocol/thinking.d.ts +28 -0
- package/dist/types/protocol/thinking.d.ts.map +1 -0
- package/dist/types/protocol/time.d.ts +21 -0
- package/dist/types/protocol/time.d.ts.map +1 -0
- package/dist/types/protocol/tokens.d.ts +29 -0
- package/dist/types/protocol/tokens.d.ts.map +1 -0
- package/dist/types/protocol/tool-closure.d.ts +25 -0
- package/dist/types/protocol/tool-closure.d.ts.map +1 -0
- package/dist/types/protocol/tool-state.d.ts +209 -0
- package/dist/types/protocol/tool-state.d.ts.map +1 -0
- package/dist/types/protocol/verify.d.ts +52 -0
- package/dist/types/protocol/verify.d.ts.map +1 -0
- package/dist/types/protocol/vocabulary.d.ts +19 -0
- package/dist/types/protocol/vocabulary.d.ts.map +1 -0
- package/dist/types/protocol/wire-api.d.ts +1983 -0
- package/dist/types/protocol/wire-api.d.ts.map +1 -0
- package/dist/types/protocol/wire.d.ts +1758 -0
- package/dist/types/protocol/wire.d.ts.map +1 -0
- package/dist/types/server/acp/binding.d.ts +33 -0
- package/dist/types/server/acp/binding.d.ts.map +1 -0
- package/dist/types/server/acp/session-records.d.ts +17 -0
- package/dist/types/server/acp/session-records.d.ts.map +1 -0
- package/dist/types/server/acp/translate.d.ts +48 -0
- package/dist/types/server/acp/translate.d.ts.map +1 -0
- package/dist/types/server/agent-server.d.ts +121 -0
- package/dist/types/server/agent-server.d.ts.map +1 -0
- package/dist/types/server/feedback.d.ts +37 -0
- package/dist/types/server/feedback.d.ts.map +1 -0
- package/dist/types/server/history.d.ts +15 -0
- package/dist/types/server/history.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +7 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/types/server/install.d.ts +42 -0
- package/dist/types/server/install.d.ts.map +1 -0
- package/dist/types/server/open-parts.d.ts +27 -0
- package/dist/types/server/open-parts.d.ts.map +1 -0
- package/dist/types/server/routes.d.ts +61 -0
- package/dist/types/server/routes.d.ts.map +1 -0
- package/dist/types/server/secrets.d.ts +11 -0
- package/dist/types/server/secrets.d.ts.map +1 -0
- package/dist/types/server/session-gate.d.ts +32 -0
- package/dist/types/server/session-gate.d.ts.map +1 -0
- package/dist/types/server/session-log.d.ts +39 -0
- package/dist/types/server/session-log.d.ts.map +1 -0
- package/dist/types/server/session-store.d.ts +119 -0
- package/dist/types/server/session-store.d.ts.map +1 -0
- package/dist/types/server/subscriptions.d.ts +74 -0
- package/dist/types/server/subscriptions.d.ts.map +1 -0
- package/dist/types/server/transports.d.ts +74 -0
- package/dist/types/server/transports.d.ts.map +1 -0
- package/dist/types/server/wire-error.d.ts +9 -0
- package/dist/types/server/wire-error.d.ts.map +1 -0
- package/dist/types/sync/event-log.d.ts +45 -0
- package/dist/types/sync/event-log.d.ts.map +1 -0
- package/dist/types/sync/fit.d.ts +40 -0
- package/dist/types/sync/fit.d.ts.map +1 -0
- package/dist/types/sync/history-reader.d.ts +8 -0
- package/dist/types/sync/history-reader.d.ts.map +1 -0
- package/dist/types/sync/history-sqlite.d.ts +37 -0
- package/dist/types/sync/history-sqlite.d.ts.map +1 -0
- package/dist/types/sync/history.d.ts +70 -0
- package/dist/types/sync/history.d.ts.map +1 -0
- package/dist/types/sync/index.d.ts +4 -0
- package/dist/types/sync/index.d.ts.map +1 -0
- package/dist/types/sync/journal-sqlite.d.ts +51 -0
- package/dist/types/sync/journal-sqlite.d.ts.map +1 -0
- package/dist/types/sync/journal.d.ts +107 -0
- package/dist/types/sync/journal.d.ts.map +1 -0
- package/dist/types/sync/live-tails.d.ts +30 -0
- package/dist/types/sync/live-tails.d.ts.map +1 -0
- package/dist/types/sync/node-sqlite.d.ts +7 -0
- package/dist/types/sync/node-sqlite.d.ts.map +1 -0
- package/dist/types/sync/projection.d.ts +10 -0
- package/dist/types/sync/projection.d.ts.map +1 -0
- package/dist/types/sync/recovery.d.ts +25 -0
- package/dist/types/sync/recovery.d.ts.map +1 -0
- package/dist/types/sync/retry.d.ts +25 -0
- package/dist/types/sync/retry.d.ts.map +1 -0
- package/dist/types/sync/schema.d.ts +4 -0
- package/dist/types/sync/schema.d.ts.map +1 -0
- package/dist/types/sync/sql.d.ts +38 -0
- package/dist/types/sync/sql.d.ts.map +1 -0
- package/dist/types/sync/sqlite-file.d.ts +9 -0
- package/dist/types/sync/sqlite-file.d.ts.map +1 -0
- package/dist/types/sync/sqlite.d.ts +6 -0
- package/dist/types/sync/sqlite.d.ts.map +1 -0
- package/dist/types/sync/worker.d.ts +63 -0
- package/dist/types/sync/worker.d.ts.map +1 -0
- package/docs/consuming.md +452 -53
- package/docs/deploy.md +218 -47
- package/docs/{sync-experiment.md → durable-sessions.md} +77 -72
- package/docs/feedback.md +116 -0
- package/docs/harnesses.md +212 -88
- package/docs/sync-history.md +29 -13
- package/docs/sync-integration.md +52 -66
- package/package.json +43 -25
- package/src/accounts/chatgpt.ts +194 -0
- package/src/accounts/check.ts +112 -0
- package/src/accounts/claude.ts +111 -0
- package/src/accounts/endpoint.ts +151 -0
- package/src/accounts/http.ts +97 -0
- package/src/accounts/index.ts +19 -0
- package/src/client/client.ts +604 -670
- package/src/client/connection.ts +371 -0
- package/src/client/history.ts +29 -52
- package/src/client/index.ts +11 -2
- package/src/client/listeners.ts +20 -0
- package/src/client/logins.ts +105 -0
- package/src/client/rpc.ts +144 -0
- package/src/client/streams.ts +488 -0
- package/src/client/transports.ts +62 -8
- package/src/client/turns.ts +171 -0
- package/src/core/agents/acp/acp-agent.ts +94 -118
- package/src/core/agents/acp/adapter.ts +20 -9
- package/src/core/agents/acp/client.ts +125 -47
- package/src/core/agents/acp/known-agents.ts +36 -4
- package/src/core/agents/acp/mappings.ts +64 -18
- package/src/core/agents/acp/requests.ts +125 -0
- package/src/core/agents/attachments.ts +18 -0
- package/src/core/agents/base.ts +120 -42
- package/src/core/agents/claude-code/adapter.ts +177 -238
- package/src/core/agents/claude-code/approvals.ts +270 -0
- package/src/core/agents/claude-code/claude-agent.ts +175 -158
- package/src/core/agents/claude-code/credentials.ts +171 -0
- package/src/core/agents/claude-code/events.ts +55 -0
- package/src/core/agents/claude-code/login.ts +269 -0
- package/src/core/agents/claude-code/mcp.ts +206 -0
- package/src/core/agents/claude-code/models.ts +15 -9
- package/src/core/agents/claude-code/options.ts +326 -39
- package/src/core/agents/claude-code/outcome.ts +209 -0
- package/src/core/agents/claude-code/session-pool.ts +136 -0
- package/src/core/agents/claude-code/session.ts +513 -0
- package/src/core/agents/claude-code/spawn.ts +144 -0
- package/src/core/agents/claude-code/spend.ts +160 -0
- package/src/core/agents/claude-code/tools.ts +47 -0
- package/src/core/agents/claude-code/turn-usage.ts +135 -0
- package/src/core/agents/claude-code/turn.ts +232 -0
- package/src/core/agents/codex-app-server/adapter.ts +314 -117
- package/src/core/agents/codex-app-server/client.ts +186 -84
- package/src/core/agents/codex-app-server/codex-agent.ts +343 -0
- package/src/core/agents/codex-app-server/commands.ts +228 -0
- package/src/core/agents/codex-app-server/credentials.ts +126 -0
- package/src/core/agents/codex-app-server/effort.ts +29 -0
- package/src/core/agents/codex-app-server/events.ts +47 -0
- package/src/core/agents/codex-app-server/homes.ts +64 -0
- package/src/core/agents/codex-app-server/input.ts +60 -0
- package/src/core/agents/codex-app-server/items.ts +149 -0
- package/src/core/agents/codex-app-server/login.ts +180 -0
- package/src/core/agents/codex-app-server/mcp.ts +182 -37
- package/src/core/agents/codex-app-server/models.ts +99 -46
- package/src/core/agents/codex-app-server/options.ts +146 -0
- package/src/core/agents/codex-app-server/plan-approval.ts +135 -0
- package/src/core/agents/codex-app-server/protocol.ts +117 -0
- package/src/core/agents/codex-app-server/requests.ts +332 -0
- package/src/core/agents/codex-app-server/session.ts +285 -0
- package/src/core/agents/codex-app-server/subagents.ts +108 -42
- package/src/core/agents/codex-app-server/thread-settings.ts +279 -0
- package/src/core/agents/codex-app-server/turn-items.ts +88 -0
- package/src/core/agents/codex-app-server/turn.ts +463 -0
- package/src/core/agents/config-fingerprint.ts +7 -14
- package/src/core/agents/credentials.ts +98 -0
- package/src/core/agents/elicitation.ts +75 -0
- package/src/core/agents/inherit-config.ts +21 -0
- package/src/core/agents/login.ts +116 -0
- package/src/core/agents/mcp-config.ts +112 -8
- package/src/core/agents/plan.ts +25 -0
- package/src/core/agents/registry.ts +21 -4
- package/src/core/agents/session-agent.ts +96 -4
- package/src/core/agents/{session-store.ts → session-pool.ts} +11 -5
- package/src/core/agents/stderr-tail.ts +75 -0
- package/src/core/agents/types.ts +40 -5
- package/src/core/index.ts +58 -48
- package/src/core/presets.ts +100 -39
- package/src/core/processes/identity.ts +113 -0
- package/src/core/processes/lifeline.ts +170 -0
- package/src/core/processes/native-processes.ts +379 -0
- package/src/core/processes/process-table.ts +174 -0
- package/src/core/provision/cache-trust.ts +121 -0
- package/src/core/provision/cache-usage.ts +69 -0
- package/src/core/provision/checksums.ts +64 -0
- package/src/core/provision/extract.ts +11 -2
- package/src/core/provision/index.ts +4 -1
- package/src/core/provision/install-build.ts +136 -0
- package/src/core/provision/npm.ts +112 -17
- package/src/core/provision/pins.ts +9 -33
- package/src/core/provision/platform.ts +12 -1
- package/src/core/provision/provisioner.ts +329 -397
- package/src/core/provision/releases.ts +86 -0
- package/src/core/provision/tools.ts +329 -0
- package/src/core/proxy/anthropic-proxy.ts +55 -25
- package/src/core/proxy/api-key-store.ts +2 -12
- package/src/core/proxy/loopback.ts +106 -0
- package/src/core/runtime/agent-runtime.ts +327 -498
- package/src/core/runtime/event-processor.ts +197 -70
- package/src/core/runtime/harness-clis.ts +61 -0
- package/src/core/runtime/harness-logins.ts +328 -0
- package/src/core/runtime/login-reads.ts +78 -0
- package/src/core/runtime/model-lists.ts +33 -48
- package/src/core/runtime/permission-policy.ts +113 -0
- package/src/core/runtime/request-broker.ts +204 -0
- package/src/core/runtime/steering.ts +112 -0
- package/src/core/runtime/turn-outcome.ts +30 -0
- package/src/core/runtime/turn.ts +360 -0
- package/src/core/utils/bounded.ts +12 -0
- package/src/core/utils/deadline.ts +38 -0
- package/src/core/utils/errors.ts +113 -21
- package/src/core/utils/is-record.ts +4 -0
- package/src/core/utils/loopback.ts +10 -0
- package/src/protocol/account.ts +104 -0
- package/src/protocol/auth.ts +199 -0
- package/src/protocol/canonical.ts +16 -0
- package/src/protocol/clis.ts +69 -0
- package/src/protocol/config.ts +60 -6
- package/src/protocol/conversation.ts +272 -0
- package/src/protocol/credentials.ts +145 -0
- package/src/protocol/errors.ts +78 -20
- package/src/protocol/execution.ts +5 -2
- package/src/protocol/factories.ts +55 -7
- package/src/protocol/guards.ts +55 -2
- package/src/protocol/harness.ts +56 -6
- package/src/protocol/history.ts +72 -64
- package/src/protocol/ids.ts +0 -12
- package/src/protocol/index.ts +9 -0
- package/src/protocol/lifecycle.ts +250 -79
- package/src/protocol/meta-keys.ts +17 -0
- package/src/protocol/meta.ts +3 -3
- package/src/protocol/models.ts +2 -43
- package/src/protocol/part-input.ts +2 -1
- package/src/protocol/parts.ts +12 -3
- package/src/protocol/reduce.ts +302 -413
- package/src/protocol/selectors.ts +1 -20
- package/src/protocol/seq-cursor.ts +14 -0
- package/src/protocol/stop-reasons.ts +1 -1
- package/src/protocol/thinking.ts +1 -30
- package/src/protocol/time.ts +2 -2
- package/src/protocol/tool-closure.ts +93 -0
- package/src/protocol/tool-state.ts +19 -4
- package/src/protocol/verify.ts +222 -92
- package/src/protocol/vocabulary.ts +21 -5
- package/src/protocol/wire-api.ts +232 -0
- package/src/protocol/wire.ts +351 -64
- package/src/server/acp/binding.ts +63 -103
- package/src/server/acp/session-records.ts +53 -0
- package/src/server/acp/translate.ts +129 -20
- package/src/server/agent-server.ts +223 -387
- package/src/server/bin.ts +280 -78
- package/src/server/feedback.ts +204 -14
- package/src/server/history.ts +116 -122
- package/src/server/index.ts +3 -8
- package/src/server/install.ts +107 -8
- package/src/server/open-parts.ts +95 -0
- package/src/server/routes.ts +391 -0
- package/src/server/secrets.ts +24 -0
- package/src/server/session-gate.ts +69 -0
- package/src/server/session-log.ts +14 -2
- package/src/server/session-store.ts +136 -72
- package/src/server/subscriptions.ts +232 -0
- package/src/server/transports.ts +125 -25
- package/src/server/wire-error.ts +31 -45
- package/src/sync/event-log.ts +31 -3
- package/src/sync/fit.ts +27 -11
- package/src/sync/history-reader.ts +10 -5
- package/src/sync/history-sqlite.ts +37 -42
- package/src/sync/history.ts +9 -15
- package/src/sync/index.ts +17 -5
- package/src/sync/journal-sqlite.ts +162 -76
- package/src/sync/journal.ts +91 -32
- package/src/sync/live-tails.ts +107 -0
- package/src/sync/projection.ts +35 -0
- package/src/sync/recovery.ts +80 -51
- package/src/sync/schema.ts +27 -6
- package/docs/rfds/0001-deterministic-echo-ids.md +0 -44
- package/docs/rfds/0002-native-subagents.md +0 -197
- package/src/client/request.ts +0 -19
- package/src/core/agents/claude-code/generator-session.ts +0 -572
- package/src/core/agents/claude-code/session-manager.ts +0 -166
- package/src/core/agents/codex-app-server/codex-app-server-agent.ts +0 -962
- package/src/core/agents/codex-items.ts +0 -149
- package/src/core/agents/codex-sdk/adapter.ts +0 -237
- package/src/core/agents/codex-sdk/codex-sdk-agent.ts +0 -330
- package/src/core/agents/tool-meta.ts +0 -68
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ThinkingLevel, clampThinkingLevel } from "../../../protocol/index.ts";
|
|
2
|
+
|
|
3
|
+
/** Codex reasoning-effort string for a level (matches the `ReasoningEffort` enum). */
|
|
4
|
+
export type CodexReasoningEffort =
|
|
5
|
+
| "none"
|
|
6
|
+
| "minimal"
|
|
7
|
+
| "low"
|
|
8
|
+
| "medium"
|
|
9
|
+
| "high"
|
|
10
|
+
| "xhigh"
|
|
11
|
+
| "max"
|
|
12
|
+
| "ultra";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The effort Codex runs for `level`. `supported` is what the model accepts, in
|
|
16
|
+
* this vocabulary, where `off` stands for its least effort: `offEffort`, the
|
|
17
|
+
* native `none` or `minimal` the model advertises. A level it lacks becomes the
|
|
18
|
+
* nearest one it has. Without `supported`, `off` becomes `low`: no model the
|
|
19
|
+
* pinned CLI lists accepts `none` or `minimal`, and every one accepts `low`.
|
|
20
|
+
*/
|
|
21
|
+
export function codexReasoningEffort<Off extends "none" | "minimal" = "minimal">(
|
|
22
|
+
level: ThinkingLevel,
|
|
23
|
+
supported?: readonly ThinkingLevel[],
|
|
24
|
+
offEffort?: Off,
|
|
25
|
+
): Exclude<CodexReasoningEffort, "none" | "minimal"> | Off {
|
|
26
|
+
const clamped = supported?.length ? clampThinkingLevel(level, supported) : undefined;
|
|
27
|
+
const effective = clamped ?? (level === "off" ? "low" : level);
|
|
28
|
+
return effective === "off" ? (offEffort ?? ("minimal" as Off)) : effective;
|
|
29
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { PermissionMode } from "../../../protocol/index.ts";
|
|
2
|
+
import type { CodexNotification } from "./protocol.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Synthetic: what the user decided about the plan Codex proposed. Codex ends
|
|
6
|
+
* its Plan-mode turn with the plan and asks nothing; the agent puts it to the
|
|
7
|
+
* user and reports the answer with this method, which Codex never sends.
|
|
8
|
+
*/
|
|
9
|
+
export const CODEX_PLAN_DECIDED = "agentServer/planDecided";
|
|
10
|
+
export interface CodexPlanDecided {
|
|
11
|
+
itemId: string;
|
|
12
|
+
/**
|
|
13
|
+
* `presented`: nobody could be asked (no broker), so the plan stands as
|
|
14
|
+
* written. `cancelled`: the question was cancelled, unanswered.
|
|
15
|
+
*/
|
|
16
|
+
decision: "approved" | "kept_planning" | "presented" | "cancelled";
|
|
17
|
+
/** The mode an approved plan is implemented in. */
|
|
18
|
+
permissionMode?: PermissionMode;
|
|
19
|
+
/** What the user said, keeping planning. */
|
|
20
|
+
message?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Synthetic: commands that may still be running when their turn ends
|
|
25
|
+
* cancelled, which Codex never sends. Codex keeps a command running as a
|
|
26
|
+
* background terminal after `turn/interrupt`; the agent stops the turn's own
|
|
27
|
+
* and reports the ones it could not confirm, and the ones a finished plan
|
|
28
|
+
* turn left running on purpose when its question is cancelled.
|
|
29
|
+
*/
|
|
30
|
+
export const CODEX_STOP_UNCONFIRMED = "agentServer/stopUnconfirmed";
|
|
31
|
+
export interface CodexStopUnconfirmed {
|
|
32
|
+
/** The commands' item ids. */
|
|
33
|
+
itemIds: string[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** An event the agent makes, which Codex never sends. */
|
|
37
|
+
export type CodexSyntheticEvent =
|
|
38
|
+
| { method: typeof CODEX_PLAN_DECIDED; params: CodexPlanDecided }
|
|
39
|
+
| { method: typeof CODEX_STOP_UNCONFIRMED; params: CodexStopUnconfirmed };
|
|
40
|
+
|
|
41
|
+
/** What the Codex agent yields and its adapter reads: Codex's notifications, and its own. */
|
|
42
|
+
export type CodexRawEvent = CodexNotification | CodexSyntheticEvent;
|
|
43
|
+
|
|
44
|
+
/** Whether the agent made the event, not Codex. */
|
|
45
|
+
export function isSyntheticEvent(event: CodexRawEvent): event is CodexSyntheticEvent {
|
|
46
|
+
return event.method === CODEX_PLAN_DECIDED || event.method === CODEX_STOP_UNCONFIRMED;
|
|
47
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { isAbsolute, resolve } from "node:path";
|
|
4
|
+
import { InvalidRequestError } from "../../utils/errors.ts";
|
|
5
|
+
import type { AgentExecuteOptions } from "../base.ts";
|
|
6
|
+
import type { InheritConfig } from "../inherit-config.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Which logical session owns each `CODEX_HOME` its turns name. A turn that
|
|
10
|
+
* names one claims it for its session, which keeps it until it is released,
|
|
11
|
+
* through process eviction and failed preparation: one session to a home. A
|
|
12
|
+
* turn with MCP servers must name one, since the engine writes them there,
|
|
13
|
+
* and below `inheritConfig: "all"` every turn must: the user's own home holds
|
|
14
|
+
* the user's configuration. That home is never claimed, nor written to.
|
|
15
|
+
*/
|
|
16
|
+
export class CodexHomes {
|
|
17
|
+
private readonly owners = new Map<string, string>();
|
|
18
|
+
|
|
19
|
+
constructor(private readonly level: InheritConfig = "all") {}
|
|
20
|
+
|
|
21
|
+
/** Whether the turn runs in a home of its session's own, which it claims. */
|
|
22
|
+
claim(options: AgentExecuteOptions, hasServers: boolean): boolean {
|
|
23
|
+
const home = options.env?.CODEX_HOME;
|
|
24
|
+
// @ref LLP 0001#d17--a-turn-inherits-what-the-operator-chooses-all-the-projects-or-none — every turn's home, below `all`
|
|
25
|
+
const needs =
|
|
26
|
+
this.level === "all" ? "Codex per-turn MCP" : `Codex at inheritConfig ${this.level}`;
|
|
27
|
+
// Each is the caller's to put right: the turn never starts.
|
|
28
|
+
const refused = (message: string) =>
|
|
29
|
+
new InvalidRequestError([{ path: "env.CODEX_HOME", message }]);
|
|
30
|
+
if (!home) {
|
|
31
|
+
if (this.level === "all" && !hasServers) return false;
|
|
32
|
+
throw refused(
|
|
33
|
+
`${needs} requires a session-specific one (an existing absolute folder no other session uses)`,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
if (!isAbsolute(home)) throw refused("must be an absolute path");
|
|
37
|
+
const shared = resolve(process.env.CODEX_HOME ?? `${homedir()}/.codex`);
|
|
38
|
+
if (resolve(home) === shared) throw refused(`${needs} cannot use the user's shared one`);
|
|
39
|
+
let path: string;
|
|
40
|
+
try {
|
|
41
|
+
path = realpathSync(home);
|
|
42
|
+
} catch {
|
|
43
|
+
throw refused(`${home} must be an existing folder`);
|
|
44
|
+
}
|
|
45
|
+
if (existsSync(shared) && path === realpathSync(shared))
|
|
46
|
+
throw refused(`${needs} cannot use the user's shared one`);
|
|
47
|
+
const owner = this.owners.get(path);
|
|
48
|
+
if (owner && owner !== options.sessionId) {
|
|
49
|
+
throw refused(
|
|
50
|
+
`${path} belongs to another session (${owner}); continue or close that session before starting a new one there`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
this.owners.set(path, options.sessionId);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
release(sessionId: string): void {
|
|
58
|
+
for (const [home, owner] of this.owners) if (owner === sessionId) this.owners.delete(home);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
clear(): void {
|
|
62
|
+
this.owners.clear();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { basename, isAbsolute } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import type { AgentInput } from "../../../protocol/index.ts";
|
|
4
|
+
import { UnsupportedAttachmentError, inlineTextAttachment, isTextMedia } from "../attachments.ts";
|
|
5
|
+
|
|
6
|
+
/** One part of what a turn or a steer gives Codex (`UserInput`). */
|
|
7
|
+
export type UserInput =
|
|
8
|
+
| { type: "text"; text: string; text_elements: [] }
|
|
9
|
+
| { type: "image"; url: string }
|
|
10
|
+
| { type: "localImage"; path: string }
|
|
11
|
+
| { type: "mention"; name: string; path: string };
|
|
12
|
+
|
|
13
|
+
export const textInput = (text: string): UserInput => ({ type: "text", text, text_elements: [] });
|
|
14
|
+
|
|
15
|
+
/** A local file named by a `file://` URL or an absolute path. */
|
|
16
|
+
function localPath(url: string): string | undefined {
|
|
17
|
+
if (url.startsWith("file://")) {
|
|
18
|
+
try {
|
|
19
|
+
return fileURLToPath(url);
|
|
20
|
+
} catch {
|
|
21
|
+
throw new UnsupportedAttachmentError(`Codex cannot read ${url}: not a local file`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return isAbsolute(url) ? url : undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Codex takes images as data URLs or local paths (it refuses remote image URLs
|
|
29
|
+
* at turn/start, which fails the turn loudly) and has no input for file
|
|
30
|
+
* content: a text file given as data is inlined, a local file is mentioned for
|
|
31
|
+
* the agent to read, and anything else fails the turn instead of vanishing.
|
|
32
|
+
*/
|
|
33
|
+
export function toUserInput(input: AgentInput): UserInput[] {
|
|
34
|
+
if (typeof input === "string") return [textInput(input)];
|
|
35
|
+
const out: UserInput[] = [];
|
|
36
|
+
for (const part of input) {
|
|
37
|
+
if (part.type === "text") out.push(textInput(part.text));
|
|
38
|
+
else if (part.data !== undefined) {
|
|
39
|
+
if (part.type === "image") {
|
|
40
|
+
out.push({ type: "image", url: `data:${part.mimeType};base64,${part.data}` });
|
|
41
|
+
} else if (isTextMedia(part.mimeType)) {
|
|
42
|
+
out.push(textInput(inlineTextAttachment({ ...part, data: part.data })));
|
|
43
|
+
} else {
|
|
44
|
+
throw new UnsupportedAttachmentError(
|
|
45
|
+
`Codex cannot take ${part.mimeType} file attachments; send text, an image, or a local file path`,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
} else if (part.url !== undefined) {
|
|
49
|
+
const path = localPath(part.url);
|
|
50
|
+
if (part.type === "image")
|
|
51
|
+
out.push(path ? { type: "localImage", path } : { type: "image", url: part.url });
|
|
52
|
+
else if (path) out.push({ type: "mention", name: part.filename ?? basename(path), path });
|
|
53
|
+
else
|
|
54
|
+
out.push(
|
|
55
|
+
textInput(`Attached file${part.filename ? ` ${part.filename}` : ""}: ${part.url}`),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out.length ? out : [textInput("")];
|
|
60
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { ToolKind, ToolLocation, ToolMeta } from "../../../protocol/index.ts";
|
|
2
|
+
import type { CodexFileChange, CodexItem } from "./protocol.ts";
|
|
3
|
+
|
|
4
|
+
/** Codex tools are already normalized names; kinds are fixed per item type. */
|
|
5
|
+
export const CODEX_TOOL_KINDS = {
|
|
6
|
+
shell: "execute",
|
|
7
|
+
apply_patch: "edit",
|
|
8
|
+
web_search: "fetch",
|
|
9
|
+
mcp: "other",
|
|
10
|
+
/** The plan Codex proposes in Plan mode, put to the user like Claude's ExitPlanMode. */
|
|
11
|
+
plan: "switch_mode",
|
|
12
|
+
} as const satisfies Record<string, ToolKind>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* What an item that is a tool is to the stream. Descriptors are pure: the
|
|
16
|
+
* adapter keeps its own streaming mechanics and calls these for naming,
|
|
17
|
+
* input/meta shaping, and completion-result extraction.
|
|
18
|
+
*/
|
|
19
|
+
export interface CodexToolDescriptor {
|
|
20
|
+
toolName(item: CodexItem): string;
|
|
21
|
+
input(item: CodexItem): Record<string, unknown>;
|
|
22
|
+
meta(item: CodexItem): ToolMeta;
|
|
23
|
+
result(item: CodexItem): { output: string; isError: boolean };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function pickCodexError(err: CodexItem["error"]): string {
|
|
27
|
+
if (!err) return "";
|
|
28
|
+
return typeof err === "string" ? err : (err.message ?? "");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Join `{text}` blocks of an MCP content array; JSON-stringify anything else. */
|
|
32
|
+
function stringifyMcpResult(result: unknown): string {
|
|
33
|
+
const content =
|
|
34
|
+
result && typeof result === "object" && "content" in result
|
|
35
|
+
? (result as { content?: unknown }).content
|
|
36
|
+
: result;
|
|
37
|
+
if (content == null) return "";
|
|
38
|
+
if (typeof content === "string") return content;
|
|
39
|
+
if (Array.isArray(content)) {
|
|
40
|
+
return content
|
|
41
|
+
.map((b) =>
|
|
42
|
+
b && typeof b === "object" && "text" in b
|
|
43
|
+
? String((b as { text: unknown }).text)
|
|
44
|
+
: JSON.stringify(b),
|
|
45
|
+
)
|
|
46
|
+
.join("");
|
|
47
|
+
}
|
|
48
|
+
return JSON.stringify(content);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const failed = (item: CodexItem) => item.status === "failed";
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Why a declined command or change failed: Codex 0.160 completes it as
|
|
55
|
+
* `declined` when its approval was refused, by the user or for them.
|
|
56
|
+
*/
|
|
57
|
+
const CODEX_COMMAND_DECLINED = "Declined: the command was not approved, so it did not run.";
|
|
58
|
+
const CODEX_CHANGE_DECLINED = "Declined: the change was not approved, so no file was changed.";
|
|
59
|
+
|
|
60
|
+
/** One file change as text: `update path`, `move from -> to`. */
|
|
61
|
+
function describeChange(change: CodexFileChange): string {
|
|
62
|
+
const kind = typeof change.kind === "string" ? change.kind : change.kind?.type;
|
|
63
|
+
const to = typeof change.kind === "object" ? change.kind?.move_path : undefined;
|
|
64
|
+
return `${kind ?? "change"} ${change.path}${to ? ` -> ${to}` : ""}`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function codexFileChangeLocations(
|
|
68
|
+
changes: Array<{ path: string }> | undefined,
|
|
69
|
+
): ToolLocation[] | undefined {
|
|
70
|
+
if (!changes?.length) return undefined;
|
|
71
|
+
return changes.map((c) => ({ path: c.path }));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const CODEX_TOOL_ITEMS: Record<string, CodexToolDescriptor> = {
|
|
75
|
+
collabAgentToolCall: {
|
|
76
|
+
toolName: (item) => item.tool ?? "collabAgentToolCall",
|
|
77
|
+
input: (item) => ({
|
|
78
|
+
...(item.prompt != null && { prompt: item.prompt }),
|
|
79
|
+
...(item.model != null && { model: item.model }),
|
|
80
|
+
receiverThreadIds: item.receiverThreadIds ?? [],
|
|
81
|
+
}),
|
|
82
|
+
meta: (item) => ({
|
|
83
|
+
kind: "task",
|
|
84
|
+
...(item.tool === "spawnAgent" && {
|
|
85
|
+
subagent: {
|
|
86
|
+
...(item.model && { model: item.model }),
|
|
87
|
+
...(item.receiverThreadIds?.[0] && { agentId: item.receiverThreadIds[0] }),
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
}),
|
|
91
|
+
result: (item) => ({
|
|
92
|
+
output: JSON.stringify(item.agentsStates ?? {}),
|
|
93
|
+
isError: failed(item) || item.status === "interrupted",
|
|
94
|
+
}),
|
|
95
|
+
},
|
|
96
|
+
commandExecution: {
|
|
97
|
+
toolName: () => "shell",
|
|
98
|
+
input: (item) => ({ command: item.command ?? "" }),
|
|
99
|
+
meta: () => ({ kind: CODEX_TOOL_KINDS.shell }),
|
|
100
|
+
result: (item) =>
|
|
101
|
+
item.status === "declined"
|
|
102
|
+
? { output: CODEX_COMMAND_DECLINED, isError: true }
|
|
103
|
+
: {
|
|
104
|
+
output: item.aggregatedOutput ?? "",
|
|
105
|
+
isError: failed(item) || (item.exitCode ?? 0) !== 0,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
fileChange: {
|
|
109
|
+
toolName: () => "apply_patch",
|
|
110
|
+
input: (item) => ({ changes: item.changes ?? [] }),
|
|
111
|
+
meta: (item) => ({
|
|
112
|
+
kind: CODEX_TOOL_KINDS.apply_patch,
|
|
113
|
+
locations: codexFileChangeLocations(item.changes),
|
|
114
|
+
}),
|
|
115
|
+
result: (item) =>
|
|
116
|
+
item.status === "declined"
|
|
117
|
+
? { output: CODEX_CHANGE_DECLINED, isError: true }
|
|
118
|
+
: {
|
|
119
|
+
output: (item.changes ?? []).map(describeChange).join("\n"),
|
|
120
|
+
isError: failed(item),
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
mcpToolCall: {
|
|
124
|
+
toolName: (item) => `${item.server ?? "mcp"}.${item.tool ?? "tool"}`,
|
|
125
|
+
input: (item) => ({ arguments: item.arguments }),
|
|
126
|
+
meta: () => ({ kind: CODEX_TOOL_KINDS.mcp }),
|
|
127
|
+
result: (item) => {
|
|
128
|
+
const err = pickCodexError(item.error);
|
|
129
|
+
return {
|
|
130
|
+
output: err || stringifyMcpResult(item.result),
|
|
131
|
+
isError: failed(item) || Boolean(err),
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
webSearch: {
|
|
136
|
+
toolName: () => "web_search",
|
|
137
|
+
input: (item) => ({ query: item.query ?? "" }),
|
|
138
|
+
meta: () => ({ kind: CODEX_TOOL_KINDS.web_search }),
|
|
139
|
+
result: (item) => ({ output: item.query ?? "", isError: failed(item) }),
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The descriptor of an item type that is a tool. Its own keys only: an item
|
|
145
|
+
* typed `constructor` is no tool, whatever the object's prototype holds.
|
|
146
|
+
*/
|
|
147
|
+
export function codexToolDescriptor(itemType: string): CodexToolDescriptor | undefined {
|
|
148
|
+
return Object.hasOwn(CODEX_TOOL_ITEMS, itemType) ? CODEX_TOOL_ITEMS[itemType] : undefined;
|
|
149
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { AuthMethod } from "../../../protocol/index.ts";
|
|
2
|
+
import { onAbort } from "../../utils/deadline.ts";
|
|
3
|
+
import { InvalidRequestError } from "../../utils/errors.ts";
|
|
4
|
+
import { isRecord } from "../../utils/is-record.ts";
|
|
5
|
+
import {
|
|
6
|
+
type CliLogin,
|
|
7
|
+
type LoginOptions,
|
|
8
|
+
type LoginStatus,
|
|
9
|
+
type NativeLogin,
|
|
10
|
+
loginMethod,
|
|
11
|
+
terminalMethod,
|
|
12
|
+
} from "../login.ts";
|
|
13
|
+
import type { CodexConnection } from "./client.ts";
|
|
14
|
+
|
|
15
|
+
/** The logins Codex's app-server runs itself, each with its `account/login/start` type. */
|
|
16
|
+
const LOGINS: readonly (AuthMethod & { type: string })[] = [
|
|
17
|
+
{ id: "chatgpt", kind: "browser", label: "ChatGPT", credential: "subscription", type: "chatgpt" },
|
|
18
|
+
{
|
|
19
|
+
id: "chatgpt_device_code",
|
|
20
|
+
kind: "device_code",
|
|
21
|
+
label: "ChatGPT, with a device code",
|
|
22
|
+
credential: "subscription",
|
|
23
|
+
type: "chatgptDeviceCode",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "api_key",
|
|
27
|
+
kind: "api_key",
|
|
28
|
+
label: "OpenAI API key",
|
|
29
|
+
credential: "api_key",
|
|
30
|
+
type: "apiKey",
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
export interface CodexCliLoginOptions {
|
|
35
|
+
/**
|
|
36
|
+
* A new app-server, not yet initialized, for a turn's `env`: its
|
|
37
|
+
* `CODEX_HOME` is the store a login lands in.
|
|
38
|
+
*/
|
|
39
|
+
connect(env: Record<string, string> | undefined): Promise<CodexConnection>;
|
|
40
|
+
/** The CLI turns run, for a terminal login. */
|
|
41
|
+
cliPath(): Promise<string>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** What `account/read` answers. */
|
|
45
|
+
interface CodexAccountRead {
|
|
46
|
+
account?: { type?: string; email?: string | null; planType?: string | null } | null;
|
|
47
|
+
requiresOpenaiAuth?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A login as Codex's app-server says it (`account/read`). */
|
|
51
|
+
export function codexLoginStatus(read: CodexAccountRead): LoginStatus {
|
|
52
|
+
const account = read.account;
|
|
53
|
+
if (!account) {
|
|
54
|
+
// A model provider that needs no OpenAI login runs without one.
|
|
55
|
+
return { state: read.requiresOpenaiAuth === false ? "signed_in" : "signed_out" };
|
|
56
|
+
}
|
|
57
|
+
switch (account.type) {
|
|
58
|
+
case "chatgpt":
|
|
59
|
+
return {
|
|
60
|
+
state: "signed_in",
|
|
61
|
+
credential: "subscription",
|
|
62
|
+
source: "login",
|
|
63
|
+
provider: "openai",
|
|
64
|
+
...(account.email && { email: account.email }),
|
|
65
|
+
...(account.planType && account.planType !== "unknown" && { plan: account.planType }),
|
|
66
|
+
};
|
|
67
|
+
case "apiKey":
|
|
68
|
+
return {
|
|
69
|
+
state: "signed_in",
|
|
70
|
+
credential: "api_key",
|
|
71
|
+
source: "login",
|
|
72
|
+
provider: "openai",
|
|
73
|
+
};
|
|
74
|
+
case "amazonBedrock":
|
|
75
|
+
return { state: "signed_in", credential: "cloud", provider: "bedrock" };
|
|
76
|
+
default:
|
|
77
|
+
return { state: "signed_in" };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Codex's login, through its app-server: `account/read`, `account/login/start`, `account/logout`. */
|
|
82
|
+
export class CodexCliLogin implements CliLogin {
|
|
83
|
+
constructor(private readonly options: CodexCliLoginOptions) {}
|
|
84
|
+
|
|
85
|
+
/** Initialize a new app-server, run `use` on it, and end it. */
|
|
86
|
+
private async with<T>(
|
|
87
|
+
options: LoginOptions,
|
|
88
|
+
use: (client: CodexConnection) => Promise<T>,
|
|
89
|
+
): Promise<T> {
|
|
90
|
+
const client = await this.options.connect(options.env);
|
|
91
|
+
const offAbort = onAbort(options.signal, () => client.close());
|
|
92
|
+
try {
|
|
93
|
+
options.signal?.throwIfAborted();
|
|
94
|
+
await client.initialize();
|
|
95
|
+
return await use(client);
|
|
96
|
+
} finally {
|
|
97
|
+
offAbort();
|
|
98
|
+
client.close();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async methods(options: LoginOptions): Promise<AuthMethod[]> {
|
|
103
|
+
return [
|
|
104
|
+
...LOGINS.map(({ type: _type, ...method }) => method),
|
|
105
|
+
terminalMethod(
|
|
106
|
+
[await this.options.cliPath(), "login"],
|
|
107
|
+
{ ...process.env, ...options.env },
|
|
108
|
+
"CODEX_HOME",
|
|
109
|
+
),
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async status(options: LoginOptions): Promise<LoginStatus> {
|
|
114
|
+
const read = await this.with(options, (client) =>
|
|
115
|
+
client.request("account/read", { refreshToken: false }),
|
|
116
|
+
);
|
|
117
|
+
return isRecord(read)
|
|
118
|
+
? codexLoginStatus(read as CodexAccountRead)
|
|
119
|
+
: { state: "unknown", error: "codex answered no account" };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async start(id: string, options: LoginOptions & { apiKey?: string }): Promise<NativeLogin> {
|
|
123
|
+
const method = loginMethod(LOGINS, id);
|
|
124
|
+
if (method.kind === "api_key" && !options.apiKey)
|
|
125
|
+
throw new InvalidRequestError([
|
|
126
|
+
{ path: "apiKey", message: "an API key login needs the key" },
|
|
127
|
+
]);
|
|
128
|
+
const client = await this.options.connect(options.env);
|
|
129
|
+
// A start the engine gave up on stops its app-server.
|
|
130
|
+
const offAbort = onAbort(options.signal, () => client.close());
|
|
131
|
+
try {
|
|
132
|
+
await client.initialize();
|
|
133
|
+
// This app-server runs this one login, so its end is this login's;
|
|
134
|
+
// waited for from before the request, which its end may follow at once.
|
|
135
|
+
const ended = new Promise<void>((resolve, reject) => {
|
|
136
|
+
client.onNotification(({ method: name, params }) => {
|
|
137
|
+
if (name !== "account/login/completed" || !isRecord(params)) return;
|
|
138
|
+
if (params.success === true) resolve();
|
|
139
|
+
else reject(new Error(String(params.error ?? "Codex did not log in.")));
|
|
140
|
+
});
|
|
141
|
+
client.onClose((error) =>
|
|
142
|
+
reject(error ?? new Error("codex app-server closed before the login ended")),
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
ended.catch(() => {});
|
|
146
|
+
const started = await client.request(
|
|
147
|
+
"account/login/start",
|
|
148
|
+
method.kind === "api_key"
|
|
149
|
+
? { type: method.type, apiKey: options.apiKey }
|
|
150
|
+
: { type: method.type },
|
|
151
|
+
);
|
|
152
|
+
const answer = isRecord(started) ? started : {};
|
|
153
|
+
// A key is stored by the time its login answers.
|
|
154
|
+
if (method.kind === "api_key") {
|
|
155
|
+
client.close();
|
|
156
|
+
return { done: Promise.resolve(), cancel: () => {} };
|
|
157
|
+
}
|
|
158
|
+
const url = answer.authUrl ?? answer.verificationUrl;
|
|
159
|
+
if (typeof url !== "string") throw new Error("Codex answered no sign-in address.");
|
|
160
|
+
const done = ended.finally(() => client.close());
|
|
161
|
+
// A caller that only cancels has nothing to hear.
|
|
162
|
+
done.catch(() => {});
|
|
163
|
+
return {
|
|
164
|
+
url,
|
|
165
|
+
...(typeof answer.userCode === "string" && { userCode: answer.userCode }),
|
|
166
|
+
done,
|
|
167
|
+
cancel: () => client.close(),
|
|
168
|
+
};
|
|
169
|
+
} catch (error) {
|
|
170
|
+
client.close();
|
|
171
|
+
throw error;
|
|
172
|
+
} finally {
|
|
173
|
+
offAbort();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async logout(options: LoginOptions): Promise<void> {
|
|
178
|
+
await this.with(options, (client) => client.request("account/logout", undefined));
|
|
179
|
+
}
|
|
180
|
+
}
|