@zvada/agent-server 0.3.18 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +11 -26
- package/CHANGELOG.md +1041 -1
- package/README.md +40 -40
- package/dist/types/accounts/chatgpt.d.ts +34 -0
- package/dist/types/accounts/chatgpt.d.ts.map +1 -0
- package/dist/types/accounts/check.d.ts +24 -0
- package/dist/types/accounts/check.d.ts.map +1 -0
- package/dist/types/accounts/claude.d.ts +21 -0
- package/dist/types/accounts/claude.d.ts.map +1 -0
- package/dist/types/accounts/endpoint.d.ts +50 -0
- package/dist/types/accounts/endpoint.d.ts.map +1 -0
- package/dist/types/accounts/http.d.ts +38 -0
- package/dist/types/accounts/http.d.ts.map +1 -0
- package/dist/types/accounts/index.d.ts +6 -0
- package/dist/types/accounts/index.d.ts.map +1 -0
- package/dist/types/client/client.d.ts +272 -0
- package/dist/types/client/client.d.ts.map +1 -0
- package/dist/types/client/connection.d.ts +160 -0
- package/dist/types/client/connection.d.ts.map +1 -0
- package/dist/types/client/history.d.ts +8 -0
- package/dist/types/client/history.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +5 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/listeners.d.ts +8 -0
- package/dist/types/client/listeners.d.ts.map +1 -0
- package/dist/types/client/logins.d.ts +35 -0
- package/dist/types/client/logins.d.ts.map +1 -0
- package/dist/types/client/rpc.d.ts +46 -0
- package/dist/types/client/rpc.d.ts.map +1 -0
- package/dist/types/client/streams.d.ts +150 -0
- package/dist/types/client/streams.d.ts.map +1 -0
- package/dist/types/client/transports.d.ts +35 -0
- package/dist/types/client/transports.d.ts.map +1 -0
- package/dist/types/client/turns.d.ts +81 -0
- package/dist/types/client/turns.d.ts.map +1 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts +68 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -0
- package/dist/types/core/agents/acp/adapter.d.ts +39 -0
- package/dist/types/core/agents/acp/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/acp/client.d.ts +90 -0
- package/dist/types/core/agents/acp/client.d.ts.map +1 -0
- package/dist/types/core/agents/acp/known-agents.d.ts +35 -0
- package/dist/types/core/agents/acp/known-agents.d.ts.map +1 -0
- package/dist/types/core/agents/acp/mappings.d.ts +46 -0
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -0
- package/dist/types/core/agents/acp/requests.d.ts +26 -0
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -0
- package/dist/types/core/agents/attachments.d.ts +11 -0
- package/dist/types/core/agents/attachments.d.ts.map +1 -0
- package/dist/types/core/agents/base.d.ts +227 -0
- package/dist/types/core/agents/base.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts +58 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts +26 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +70 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts +54 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/events.d.ts +42 -0
- package/dist/types/core/agents/claude-code/events.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/login.d.ts +61 -0
- package/dist/types/core/agents/claude-code/login.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts +52 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/models.d.ts +30 -0
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/options.d.ts +183 -0
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts +50 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts +36 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session.d.ts +148 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts +29 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spend.d.ts +58 -0
- package/dist/types/core/agents/claude-code/spend.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/tools.d.ts +4 -0
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts +52 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn.d.ts +121 -0
- package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts +59 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts +116 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +113 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts +66 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts +49 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts +12 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts +45 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts +20 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts +26 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts +31 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts +38 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +62 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts +67 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts +40 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts +19 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts +99 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts +42 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts +96 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts +53 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts +87 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts +33 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts +163 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts.map +1 -0
- package/dist/types/core/agents/config-fingerprint.d.ts +5 -0
- package/dist/types/core/agents/config-fingerprint.d.ts.map +1 -0
- package/dist/types/core/agents/credentials.d.ts +28 -0
- package/dist/types/core/agents/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/elicitation.d.ts +37 -0
- package/dist/types/core/agents/elicitation.d.ts.map +1 -0
- package/dist/types/core/agents/inherit-config.d.ts +18 -0
- package/dist/types/core/agents/inherit-config.d.ts.map +1 -0
- package/dist/types/core/agents/login.d.ts +67 -0
- package/dist/types/core/agents/login.d.ts.map +1 -0
- package/dist/types/core/agents/mcp-config.d.ts +57 -0
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -0
- package/dist/types/core/agents/plan.d.ts +16 -0
- package/dist/types/core/agents/plan.d.ts.map +1 -0
- package/dist/types/core/agents/registry.d.ts +30 -0
- package/dist/types/core/agents/registry.d.ts.map +1 -0
- package/dist/types/core/agents/session-agent.d.ts +48 -0
- package/dist/types/core/agents/session-agent.d.ts.map +1 -0
- package/dist/types/core/agents/session-pool.d.ts +41 -0
- package/dist/types/core/agents/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/stderr-tail.d.ts +28 -0
- package/dist/types/core/agents/stderr-tail.d.ts.map +1 -0
- package/dist/types/core/agents/thinking-levels.d.ts +4 -0
- package/dist/types/core/agents/thinking-levels.d.ts.map +1 -0
- package/dist/types/core/agents/types.d.ts +124 -0
- package/dist/types/core/agents/types.d.ts.map +1 -0
- package/dist/types/core/diagnostics.d.ts +36 -0
- package/dist/types/core/diagnostics.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +29 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/presets.d.ts +80 -0
- package/dist/types/core/presets.d.ts.map +1 -0
- package/dist/types/core/processes/identity.d.ts +31 -0
- package/dist/types/core/processes/identity.d.ts.map +1 -0
- package/dist/types/core/processes/lifeline.d.ts +47 -0
- package/dist/types/core/processes/lifeline.d.ts.map +1 -0
- package/dist/types/core/processes/native-processes.d.ts +130 -0
- package/dist/types/core/processes/native-processes.d.ts.map +1 -0
- package/dist/types/core/processes/process-table.d.ts +43 -0
- package/dist/types/core/processes/process-table.d.ts.map +1 -0
- package/dist/types/core/provision/cache-trust.d.ts +13 -0
- package/dist/types/core/provision/cache-trust.d.ts.map +1 -0
- package/dist/types/core/provision/cache-usage.d.ts +14 -0
- package/dist/types/core/provision/cache-usage.d.ts.map +1 -0
- package/dist/types/core/provision/checksums.d.ts +46 -0
- package/dist/types/core/provision/checksums.d.ts.map +1 -0
- package/dist/types/core/provision/extract.d.ts +7 -0
- package/dist/types/core/provision/extract.d.ts.map +1 -0
- package/dist/types/core/provision/index.d.ts +5 -0
- package/dist/types/core/provision/index.d.ts.map +1 -0
- package/dist/types/core/provision/install-build.d.ts +36 -0
- package/dist/types/core/provision/install-build.d.ts.map +1 -0
- package/dist/types/core/provision/npm.d.ts +40 -0
- package/dist/types/core/provision/npm.d.ts.map +1 -0
- package/dist/types/core/provision/pins.d.ts +24 -0
- package/dist/types/core/provision/pins.d.ts.map +1 -0
- package/dist/types/core/provision/platform.d.ts +28 -0
- package/dist/types/core/provision/platform.d.ts.map +1 -0
- package/dist/types/core/provision/provisioner.d.ts +189 -0
- package/dist/types/core/provision/provisioner.d.ts.map +1 -0
- package/dist/types/core/provision/releases.d.ts +8 -0
- package/dist/types/core/provision/releases.d.ts.map +1 -0
- package/dist/types/core/provision/tools.d.ts +81 -0
- package/dist/types/core/provision/tools.d.ts.map +1 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts +52 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts.map +1 -0
- package/dist/types/core/proxy/api-key-store.d.ts +37 -0
- package/dist/types/core/proxy/api-key-store.d.ts.map +1 -0
- package/dist/types/core/proxy/index.d.ts +3 -0
- package/dist/types/core/proxy/index.d.ts.map +1 -0
- package/dist/types/core/proxy/loopback.d.ts +14 -0
- package/dist/types/core/proxy/loopback.d.ts.map +1 -0
- package/dist/types/core/runtime/agent-runtime.d.ts +181 -0
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -0
- package/dist/types/core/runtime/event-processor.d.ts +87 -0
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -0
- package/dist/types/core/runtime/event-sink.d.ts +44 -0
- package/dist/types/core/runtime/event-sink.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-clis.d.ts +10 -0
- package/dist/types/core/runtime/harness-clis.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-logins.d.ts +68 -0
- package/dist/types/core/runtime/harness-logins.d.ts.map +1 -0
- package/dist/types/core/runtime/login-reads.d.ts +28 -0
- package/dist/types/core/runtime/login-reads.d.ts.map +1 -0
- package/dist/types/core/runtime/model-lists.d.ts +37 -0
- package/dist/types/core/runtime/model-lists.d.ts.map +1 -0
- package/dist/types/core/runtime/permission-policy.d.ts +61 -0
- package/dist/types/core/runtime/permission-policy.d.ts.map +1 -0
- package/dist/types/core/runtime/request-broker.d.ts +49 -0
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -0
- package/dist/types/core/runtime/steering.d.ts +38 -0
- package/dist/types/core/runtime/steering.d.ts.map +1 -0
- package/dist/types/core/runtime/turn-outcome.d.ts +21 -0
- package/dist/types/core/runtime/turn-outcome.d.ts.map +1 -0
- package/dist/types/core/runtime/turn.d.ts +121 -0
- package/dist/types/core/runtime/turn.d.ts.map +1 -0
- package/dist/types/core/utils/bounded.d.ts +6 -0
- package/dist/types/core/utils/bounded.d.ts.map +1 -0
- package/dist/types/core/utils/deadline.d.ts +14 -0
- package/dist/types/core/utils/deadline.d.ts.map +1 -0
- package/dist/types/core/utils/errors.d.ts +104 -0
- package/dist/types/core/utils/errors.d.ts.map +1 -0
- package/dist/types/core/utils/is-record.d.ts +3 -0
- package/dist/types/core/utils/is-record.d.ts.map +1 -0
- package/dist/types/core/utils/loopback.d.ts +6 -0
- package/dist/types/core/utils/loopback.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/protocol/account.d.ts +26 -0
- package/dist/types/protocol/account.d.ts.map +1 -0
- package/dist/types/protocol/async-queue.d.ts +21 -0
- package/dist/types/protocol/async-queue.d.ts.map +1 -0
- package/dist/types/protocol/auth.d.ts +228 -0
- package/dist/types/protocol/auth.d.ts.map +1 -0
- package/dist/types/protocol/canonical.d.ts +9 -0
- package/dist/types/protocol/canonical.d.ts.map +1 -0
- package/dist/types/protocol/clis.d.ts +74 -0
- package/dist/types/protocol/clis.d.ts.map +1 -0
- package/dist/types/protocol/config.d.ts +200 -0
- package/dist/types/protocol/config.d.ts.map +1 -0
- package/dist/types/protocol/conversation.d.ts +942 -0
- package/dist/types/protocol/conversation.d.ts.map +1 -0
- package/dist/types/protocol/credentials.d.ts +145 -0
- package/dist/types/protocol/credentials.d.ts.map +1 -0
- package/dist/types/protocol/errors.d.ts +36 -0
- package/dist/types/protocol/errors.d.ts.map +1 -0
- package/dist/types/protocol/execution.d.ts +28 -0
- package/dist/types/protocol/execution.d.ts.map +1 -0
- package/dist/types/protocol/factories.d.ts +94 -0
- package/dist/types/protocol/factories.d.ts.map +1 -0
- package/dist/types/protocol/guards.d.ts +55 -0
- package/dist/types/protocol/guards.d.ts.map +1 -0
- package/dist/types/protocol/harness.d.ts +70 -0
- package/dist/types/protocol/harness.d.ts.map +1 -0
- package/dist/types/protocol/history.d.ts +318 -0
- package/dist/types/protocol/history.d.ts.map +1 -0
- package/dist/types/protocol/ids.d.ts +9 -0
- package/dist/types/protocol/ids.d.ts.map +1 -0
- package/dist/types/protocol/index.d.ts +35 -0
- package/dist/types/protocol/index.d.ts.map +1 -0
- package/dist/types/protocol/lifecycle.d.ts +1190 -0
- package/dist/types/protocol/lifecycle.d.ts.map +1 -0
- package/dist/types/protocol/meta-keys.d.ts +17 -0
- package/dist/types/protocol/meta-keys.d.ts.map +1 -0
- package/dist/types/protocol/meta.d.ts +13 -0
- package/dist/types/protocol/meta.d.ts.map +1 -0
- package/dist/types/protocol/model-catalog.d.ts +11 -0
- package/dist/types/protocol/model-catalog.d.ts.map +1 -0
- package/dist/types/protocol/models.d.ts +107 -0
- package/dist/types/protocol/models.d.ts.map +1 -0
- package/dist/types/protocol/part-input.d.ts +101 -0
- package/dist/types/protocol/part-input.d.ts.map +1 -0
- package/dist/types/protocol/parts.d.ts +357 -0
- package/dist/types/protocol/parts.d.ts.map +1 -0
- package/dist/types/protocol/reduce.d.ts +26 -0
- package/dist/types/protocol/reduce.d.ts.map +1 -0
- package/dist/types/protocol/selectors.d.ts +64 -0
- package/dist/types/protocol/selectors.d.ts.map +1 -0
- package/dist/types/protocol/seq-cursor.d.ts +66 -0
- package/dist/types/protocol/seq-cursor.d.ts.map +1 -0
- package/dist/types/protocol/stop-reasons.d.ts +33 -0
- package/dist/types/protocol/stop-reasons.d.ts.map +1 -0
- package/dist/types/protocol/thinking.d.ts +28 -0
- package/dist/types/protocol/thinking.d.ts.map +1 -0
- package/dist/types/protocol/time.d.ts +21 -0
- package/dist/types/protocol/time.d.ts.map +1 -0
- package/dist/types/protocol/tokens.d.ts +29 -0
- package/dist/types/protocol/tokens.d.ts.map +1 -0
- package/dist/types/protocol/tool-closure.d.ts +25 -0
- package/dist/types/protocol/tool-closure.d.ts.map +1 -0
- package/dist/types/protocol/tool-state.d.ts +209 -0
- package/dist/types/protocol/tool-state.d.ts.map +1 -0
- package/dist/types/protocol/verify.d.ts +52 -0
- package/dist/types/protocol/verify.d.ts.map +1 -0
- package/dist/types/protocol/vocabulary.d.ts +19 -0
- package/dist/types/protocol/vocabulary.d.ts.map +1 -0
- package/dist/types/protocol/wire-api.d.ts +1983 -0
- package/dist/types/protocol/wire-api.d.ts.map +1 -0
- package/dist/types/protocol/wire.d.ts +1758 -0
- package/dist/types/protocol/wire.d.ts.map +1 -0
- package/dist/types/server/acp/binding.d.ts +33 -0
- package/dist/types/server/acp/binding.d.ts.map +1 -0
- package/dist/types/server/acp/session-records.d.ts +17 -0
- package/dist/types/server/acp/session-records.d.ts.map +1 -0
- package/dist/types/server/acp/translate.d.ts +48 -0
- package/dist/types/server/acp/translate.d.ts.map +1 -0
- package/dist/types/server/agent-server.d.ts +121 -0
- package/dist/types/server/agent-server.d.ts.map +1 -0
- package/dist/types/server/feedback.d.ts +37 -0
- package/dist/types/server/feedback.d.ts.map +1 -0
- package/dist/types/server/history.d.ts +15 -0
- package/dist/types/server/history.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +7 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/types/server/install.d.ts +42 -0
- package/dist/types/server/install.d.ts.map +1 -0
- package/dist/types/server/open-parts.d.ts +27 -0
- package/dist/types/server/open-parts.d.ts.map +1 -0
- package/dist/types/server/routes.d.ts +61 -0
- package/dist/types/server/routes.d.ts.map +1 -0
- package/dist/types/server/secrets.d.ts +11 -0
- package/dist/types/server/secrets.d.ts.map +1 -0
- package/dist/types/server/session-gate.d.ts +32 -0
- package/dist/types/server/session-gate.d.ts.map +1 -0
- package/dist/types/server/session-log.d.ts +39 -0
- package/dist/types/server/session-log.d.ts.map +1 -0
- package/dist/types/server/session-store.d.ts +119 -0
- package/dist/types/server/session-store.d.ts.map +1 -0
- package/dist/types/server/subscriptions.d.ts +74 -0
- package/dist/types/server/subscriptions.d.ts.map +1 -0
- package/dist/types/server/transports.d.ts +74 -0
- package/dist/types/server/transports.d.ts.map +1 -0
- package/dist/types/server/wire-error.d.ts +9 -0
- package/dist/types/server/wire-error.d.ts.map +1 -0
- package/dist/types/sync/event-log.d.ts +45 -0
- package/dist/types/sync/event-log.d.ts.map +1 -0
- package/dist/types/sync/fit.d.ts +40 -0
- package/dist/types/sync/fit.d.ts.map +1 -0
- package/dist/types/sync/history-reader.d.ts +8 -0
- package/dist/types/sync/history-reader.d.ts.map +1 -0
- package/dist/types/sync/history-sqlite.d.ts +37 -0
- package/dist/types/sync/history-sqlite.d.ts.map +1 -0
- package/dist/types/sync/history.d.ts +70 -0
- package/dist/types/sync/history.d.ts.map +1 -0
- package/dist/types/sync/index.d.ts +4 -0
- package/dist/types/sync/index.d.ts.map +1 -0
- package/dist/types/sync/journal-sqlite.d.ts +51 -0
- package/dist/types/sync/journal-sqlite.d.ts.map +1 -0
- package/dist/types/sync/journal.d.ts +107 -0
- package/dist/types/sync/journal.d.ts.map +1 -0
- package/dist/types/sync/live-tails.d.ts +30 -0
- package/dist/types/sync/live-tails.d.ts.map +1 -0
- package/dist/types/sync/node-sqlite.d.ts +7 -0
- package/dist/types/sync/node-sqlite.d.ts.map +1 -0
- package/dist/types/sync/projection.d.ts +10 -0
- package/dist/types/sync/projection.d.ts.map +1 -0
- package/dist/types/sync/recovery.d.ts +25 -0
- package/dist/types/sync/recovery.d.ts.map +1 -0
- package/dist/types/sync/retry.d.ts +25 -0
- package/dist/types/sync/retry.d.ts.map +1 -0
- package/dist/types/sync/schema.d.ts +4 -0
- package/dist/types/sync/schema.d.ts.map +1 -0
- package/dist/types/sync/sql.d.ts +38 -0
- package/dist/types/sync/sql.d.ts.map +1 -0
- package/dist/types/sync/sqlite-file.d.ts +9 -0
- package/dist/types/sync/sqlite-file.d.ts.map +1 -0
- package/dist/types/sync/sqlite.d.ts +6 -0
- package/dist/types/sync/sqlite.d.ts.map +1 -0
- package/dist/types/sync/worker.d.ts +63 -0
- package/dist/types/sync/worker.d.ts.map +1 -0
- package/docs/consuming.md +452 -53
- package/docs/deploy.md +218 -47
- package/docs/{sync-experiment.md → durable-sessions.md} +77 -72
- package/docs/feedback.md +116 -0
- package/docs/harnesses.md +212 -88
- package/docs/sync-history.md +29 -13
- package/docs/sync-integration.md +52 -66
- package/package.json +45 -28
- package/src/accounts/chatgpt.ts +194 -0
- package/src/accounts/check.ts +112 -0
- package/src/accounts/claude.ts +111 -0
- package/src/accounts/endpoint.ts +151 -0
- package/src/accounts/http.ts +97 -0
- package/src/accounts/index.ts +19 -0
- package/src/client/client.ts +604 -670
- package/src/client/connection.ts +371 -0
- package/src/client/history.ts +29 -52
- package/src/client/index.ts +11 -2
- package/src/client/listeners.ts +20 -0
- package/src/client/logins.ts +105 -0
- package/src/client/rpc.ts +155 -0
- package/src/client/streams.ts +488 -0
- package/src/client/transports.ts +62 -8
- package/src/client/turns.ts +171 -0
- package/src/core/agents/acp/acp-agent.ts +94 -118
- package/src/core/agents/acp/adapter.ts +20 -9
- package/src/core/agents/acp/client.ts +125 -47
- package/src/core/agents/acp/known-agents.ts +36 -4
- package/src/core/agents/acp/mappings.ts +64 -18
- package/src/core/agents/acp/requests.ts +125 -0
- package/src/core/agents/attachments.ts +18 -0
- package/src/core/agents/base.ts +120 -42
- package/src/core/agents/claude-code/adapter.ts +177 -238
- package/src/core/agents/claude-code/approvals.ts +270 -0
- package/src/core/agents/claude-code/claude-agent.ts +175 -158
- package/src/core/agents/claude-code/credentials.ts +171 -0
- package/src/core/agents/claude-code/events.ts +55 -0
- package/src/core/agents/claude-code/login.ts +269 -0
- package/src/core/agents/claude-code/mcp.ts +206 -0
- package/src/core/agents/claude-code/models.ts +15 -9
- package/src/core/agents/claude-code/options.ts +326 -39
- package/src/core/agents/claude-code/outcome.ts +209 -0
- package/src/core/agents/claude-code/session-pool.ts +136 -0
- package/src/core/agents/claude-code/session.ts +513 -0
- package/src/core/agents/claude-code/spawn.ts +144 -0
- package/src/core/agents/claude-code/spend.ts +160 -0
- package/src/core/agents/claude-code/tools.ts +47 -0
- package/src/core/agents/claude-code/turn-usage.ts +135 -0
- package/src/core/agents/claude-code/turn.ts +232 -0
- package/src/core/agents/codex-app-server/adapter.ts +314 -117
- package/src/core/agents/codex-app-server/client.ts +186 -84
- package/src/core/agents/codex-app-server/codex-agent.ts +343 -0
- package/src/core/agents/codex-app-server/commands.ts +228 -0
- package/src/core/agents/codex-app-server/credentials.ts +126 -0
- package/src/core/agents/codex-app-server/effort.ts +29 -0
- package/src/core/agents/codex-app-server/events.ts +47 -0
- package/src/core/agents/codex-app-server/homes.ts +64 -0
- package/src/core/agents/codex-app-server/input.ts +60 -0
- package/src/core/agents/codex-app-server/items.ts +149 -0
- package/src/core/agents/codex-app-server/login.ts +180 -0
- package/src/core/agents/codex-app-server/mcp.ts +182 -37
- package/src/core/agents/codex-app-server/models.ts +99 -46
- package/src/core/agents/codex-app-server/options.ts +146 -0
- package/src/core/agents/codex-app-server/plan-approval.ts +135 -0
- package/src/core/agents/codex-app-server/protocol.ts +117 -0
- package/src/core/agents/codex-app-server/requests.ts +332 -0
- package/src/core/agents/codex-app-server/session.ts +285 -0
- package/src/core/agents/codex-app-server/subagents.ts +108 -42
- package/src/core/agents/codex-app-server/thread-settings.ts +279 -0
- package/src/core/agents/codex-app-server/turn-items.ts +88 -0
- package/src/core/agents/codex-app-server/turn.ts +463 -0
- package/src/core/agents/config-fingerprint.ts +7 -14
- package/src/core/agents/credentials.ts +98 -0
- package/src/core/agents/elicitation.ts +75 -0
- package/src/core/agents/inherit-config.ts +21 -0
- package/src/core/agents/login.ts +116 -0
- package/src/core/agents/mcp-config.ts +112 -8
- package/src/core/agents/plan.ts +25 -0
- package/src/core/agents/registry.ts +21 -4
- package/src/core/agents/session-agent.ts +96 -4
- package/src/core/agents/{session-store.ts → session-pool.ts} +11 -5
- package/src/core/agents/stderr-tail.ts +75 -0
- package/src/core/agents/types.ts +40 -5
- package/src/core/index.ts +58 -48
- package/src/core/presets.ts +100 -39
- package/src/core/processes/identity.ts +113 -0
- package/src/core/processes/lifeline.ts +170 -0
- package/src/core/processes/native-processes.ts +379 -0
- package/src/core/processes/process-table.ts +174 -0
- package/src/core/provision/cache-trust.ts +121 -0
- package/src/core/provision/cache-usage.ts +69 -0
- package/src/core/provision/checksums.ts +64 -0
- package/src/core/provision/extract.ts +11 -2
- package/src/core/provision/index.ts +4 -1
- package/src/core/provision/install-build.ts +136 -0
- package/src/core/provision/npm.ts +112 -17
- package/src/core/provision/pins.ts +9 -33
- package/src/core/provision/platform.ts +12 -1
- package/src/core/provision/provisioner.ts +329 -397
- package/src/core/provision/releases.ts +86 -0
- package/src/core/provision/tools.ts +329 -0
- package/src/core/proxy/anthropic-proxy.ts +55 -25
- package/src/core/proxy/api-key-store.ts +2 -12
- package/src/core/proxy/loopback.ts +106 -0
- package/src/core/runtime/agent-runtime.ts +327 -498
- package/src/core/runtime/event-processor.ts +197 -70
- package/src/core/runtime/harness-clis.ts +61 -0
- package/src/core/runtime/harness-logins.ts +328 -0
- package/src/core/runtime/login-reads.ts +78 -0
- package/src/core/runtime/model-lists.ts +33 -48
- package/src/core/runtime/permission-policy.ts +113 -0
- package/src/core/runtime/request-broker.ts +204 -0
- package/src/core/runtime/steering.ts +112 -0
- package/src/core/runtime/turn-outcome.ts +30 -0
- package/src/core/runtime/turn.ts +360 -0
- package/src/core/utils/bounded.ts +12 -0
- package/src/core/utils/deadline.ts +38 -0
- package/src/core/utils/errors.ts +113 -21
- package/src/core/utils/is-record.ts +4 -0
- package/src/core/utils/loopback.ts +10 -0
- package/src/protocol/account.ts +104 -0
- package/src/protocol/auth.ts +199 -0
- package/src/protocol/canonical.ts +16 -0
- package/src/protocol/clis.ts +69 -0
- package/src/protocol/config.ts +60 -6
- package/src/protocol/conversation.ts +272 -0
- package/src/protocol/credentials.ts +145 -0
- package/src/protocol/errors.ts +78 -20
- package/src/protocol/execution.ts +5 -2
- package/src/protocol/factories.ts +55 -7
- package/src/protocol/guards.ts +55 -2
- package/src/protocol/harness.ts +56 -6
- package/src/protocol/history.ts +72 -64
- package/src/protocol/ids.ts +0 -12
- package/src/protocol/index.ts +9 -0
- package/src/protocol/lifecycle.ts +250 -79
- package/src/protocol/meta-keys.ts +17 -0
- package/src/protocol/meta.ts +3 -3
- package/src/protocol/models.ts +2 -43
- package/src/protocol/part-input.ts +2 -1
- package/src/protocol/parts.ts +12 -3
- package/src/protocol/reduce.ts +302 -413
- package/src/protocol/selectors.ts +1 -20
- package/src/protocol/seq-cursor.ts +14 -0
- package/src/protocol/stop-reasons.ts +1 -1
- package/src/protocol/thinking.ts +1 -30
- package/src/protocol/time.ts +2 -2
- package/src/protocol/tool-closure.ts +93 -0
- package/src/protocol/tool-state.ts +19 -4
- package/src/protocol/verify.ts +222 -92
- package/src/protocol/vocabulary.ts +21 -5
- package/src/protocol/wire-api.ts +232 -0
- package/src/protocol/wire.ts +351 -64
- package/src/server/acp/binding.ts +63 -103
- package/src/server/acp/session-records.ts +53 -0
- package/src/server/acp/translate.ts +129 -20
- package/src/server/agent-server.ts +223 -387
- package/src/server/bin.ts +280 -78
- package/src/server/feedback.ts +204 -14
- package/src/server/history.ts +116 -122
- package/src/server/index.ts +3 -8
- package/src/server/install.ts +107 -8
- package/src/server/open-parts.ts +95 -0
- package/src/server/routes.ts +391 -0
- package/src/server/secrets.ts +24 -0
- package/src/server/session-gate.ts +69 -0
- package/src/server/session-log.ts +14 -2
- package/src/server/session-store.ts +136 -72
- package/src/server/subscriptions.ts +232 -0
- package/src/server/transports.ts +125 -25
- package/src/server/wire-error.ts +31 -45
- package/src/sync/event-log.ts +31 -3
- package/src/sync/fit.ts +27 -11
- package/src/sync/history-reader.ts +10 -5
- package/src/sync/history-sqlite.ts +37 -42
- package/src/sync/history.ts +9 -15
- package/src/sync/index.ts +17 -5
- package/src/sync/journal-sqlite.ts +162 -76
- package/src/sync/journal.ts +91 -32
- package/src/sync/live-tails.ts +107 -0
- package/src/sync/projection.ts +35 -0
- package/src/sync/recovery.ts +80 -51
- package/src/sync/schema.ts +27 -6
- package/docs/rfds/0001-deterministic-echo-ids.md +0 -44
- package/docs/rfds/0002-native-subagents.md +0 -197
- package/src/client/request.ts +0 -19
- package/src/core/agents/claude-code/generator-session.ts +0 -572
- package/src/core/agents/claude-code/session-manager.ts +0 -166
- package/src/core/agents/codex-app-server/codex-app-server-agent.ts +0 -962
- package/src/core/agents/codex-items.ts +0 -149
- package/src/core/agents/codex-sdk/adapter.ts +0 -237
- package/src/core/agents/codex-sdk/codex-sdk-agent.ts +0 -330
- package/src/core/agents/tool-meta.ts +0 -68
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_TOKEN_USAGE,
|
|
3
|
-
type
|
|
3
|
+
type ErrorCategory,
|
|
4
|
+
type LimitWindow,
|
|
4
5
|
type ReasoningPart,
|
|
5
6
|
type StopReason,
|
|
6
7
|
type StreamContext,
|
|
7
8
|
type SubagentPart,
|
|
9
|
+
TOOL_OUTCOME_UNKNOWN,
|
|
8
10
|
type TextPart,
|
|
9
11
|
type TokenUsage,
|
|
10
12
|
type ToolPart,
|
|
13
|
+
classifyError,
|
|
11
14
|
completeToolPart,
|
|
12
15
|
createReasoningPart,
|
|
13
16
|
createTextPart,
|
|
@@ -15,143 +18,212 @@ import {
|
|
|
15
18
|
generateUUIDv7,
|
|
16
19
|
setToolMeta,
|
|
17
20
|
} from "../../../protocol/index.ts";
|
|
18
|
-
import {
|
|
19
|
-
type CodexToolDescriptor,
|
|
20
|
-
type CodexToolItem,
|
|
21
|
-
codexToolDescriptor,
|
|
22
|
-
} from "../codex-items.ts";
|
|
21
|
+
import { isRecord } from "../../utils/is-record.ts";
|
|
23
22
|
import type { AdapterEvent, EventTransformer, TransformResult } from "../types.ts";
|
|
23
|
+
import {
|
|
24
|
+
CODEX_PLAN_DECIDED,
|
|
25
|
+
type CodexPlanDecided,
|
|
26
|
+
type CodexRawEvent,
|
|
27
|
+
type CodexStopUnconfirmed,
|
|
28
|
+
type CodexSyntheticEvent,
|
|
29
|
+
isSyntheticEvent,
|
|
30
|
+
} from "./events.ts";
|
|
31
|
+
import { CODEX_TOOL_KINDS, type CodexToolDescriptor, codexToolDescriptor } from "./items.ts";
|
|
32
|
+
import { type CodexItem, type CodexNotification, codexItem, codexTurn } from "./protocol.ts";
|
|
24
33
|
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
* streams token-level deltas (item/agentMessage/delta, item/reasoning/*Delta),
|
|
28
|
-
* so unlike the Codex SDK adapter no diffing is needed. Items carry camelCase
|
|
29
|
-
* fields. Tool-like items (commandExecution/fileChange/mcpToolCall/webSearch)
|
|
30
|
-
* become tool parts that complete on item/completed.
|
|
31
|
-
*/
|
|
34
|
+
/** Codex's token counts: its numbers, by name. */
|
|
35
|
+
type Counts = Record<string, number>;
|
|
32
36
|
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
/** The numbers among a usage breakdown's fields. */
|
|
38
|
+
function counts(value: unknown): Counts | undefined {
|
|
39
|
+
if (!isRecord(value)) return undefined;
|
|
40
|
+
return Object.fromEntries(
|
|
41
|
+
Object.entries(value).filter(
|
|
42
|
+
(entry): entry is [string, number] => typeof entry[1] === "number",
|
|
43
|
+
),
|
|
44
|
+
);
|
|
40
45
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
willRetry?: boolean;
|
|
56
|
-
message?: string;
|
|
57
|
-
toModel?: string;
|
|
46
|
+
|
|
47
|
+
/** Field-by-field `a - b` of two Codex usage breakdowns, never below zero. */
|
|
48
|
+
function subtractUsage(a: Counts, b: Counts): Counts {
|
|
49
|
+
return Object.fromEntries(
|
|
50
|
+
Object.entries(a).map(([key, value]) => [key, Math.max(value - (b[key] ?? 0), 0)]),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** An error's text and typed code, as Codex nests them (`TurnError`). */
|
|
55
|
+
function codexError(value: unknown): { message?: string; codexErrorInfo?: unknown } | undefined {
|
|
56
|
+
if (!isRecord(value)) return undefined;
|
|
57
|
+
return {
|
|
58
|
+
...(typeof value.message === "string" && { message: value.message }),
|
|
59
|
+
codexErrorInfo: value.codexErrorInfo,
|
|
58
60
|
};
|
|
59
61
|
}
|
|
60
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Parses `codex app-server` v2 notifications into AdapterEvents. This harness
|
|
65
|
+
* streams token-level deltas (item/agentMessage/delta, item/reasoning/*Delta),
|
|
66
|
+
* so no diffing is needed. Items carry camelCase fields. Tool-like items
|
|
67
|
+
* (commandExecution/fileChange/mcpToolCall/webSearch) become tool parts that
|
|
68
|
+
* complete on item/completed.
|
|
69
|
+
*/
|
|
61
70
|
export class CodexAppServerTransformer implements EventTransformer<unknown> {
|
|
62
71
|
private readonly ctx: StreamContext;
|
|
63
|
-
|
|
72
|
+
/** The text and reasoning parts, by item id. */
|
|
73
|
+
private readonly texts = new Map<string, TextPart | ReasoningPart>();
|
|
74
|
+
/** The tool parts (commands, changes, MCP calls, searches, plans), by item id. */
|
|
75
|
+
private readonly tools = new Map<string, ToolPart>();
|
|
76
|
+
/** The sub-agents' activities, by item id. */
|
|
77
|
+
private readonly activities = new Map<string, SubagentPart>();
|
|
64
78
|
|
|
65
79
|
private usage: TokenUsage = { ...DEFAULT_TOKEN_USAGE };
|
|
66
80
|
/** The thread's totals when this turn began: Codex's `total` counts the whole thread. */
|
|
67
|
-
private baseline?:
|
|
68
|
-
|
|
81
|
+
private baseline?: Counts;
|
|
82
|
+
/** Codex's turns in this one: a plan's, then the one implementing it. */
|
|
83
|
+
private readonly turnIds = new Set<string>();
|
|
69
84
|
private readonly reportedModels = new Set<string>();
|
|
70
85
|
private stopReason?: StopReason;
|
|
86
|
+
/** From the failure's typed `codexErrorInfo`, when it had one. */
|
|
87
|
+
private errorCategory?: ErrorCategory;
|
|
71
88
|
private finishReason?: string;
|
|
72
89
|
private error?: string;
|
|
90
|
+
/** Codex stopped the turn (`interrupted`), as after an approval answered cancel. */
|
|
91
|
+
private interrupted = false;
|
|
73
92
|
|
|
74
93
|
constructor(ctx: { sessionId: string }) {
|
|
75
94
|
this.ctx = { sessionId: ctx.sessionId, messageId: "" };
|
|
76
95
|
}
|
|
77
96
|
|
|
78
97
|
process(raw: unknown): AdapterEvent[] {
|
|
79
|
-
|
|
80
|
-
|
|
98
|
+
// What the Codex agent yields.
|
|
99
|
+
const event = raw as CodexRawEvent;
|
|
100
|
+
return isSyntheticEvent(event) ? this.synthetic(event) : this.notification(event);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
finish(): TransformResult {
|
|
104
|
+
return {
|
|
105
|
+
usage: this.usage,
|
|
106
|
+
...(this.reportedModels.size && { reportedModels: [...this.reportedModels] }),
|
|
107
|
+
stopReason: this.stopReason,
|
|
108
|
+
finishReason: this.finishReason,
|
|
109
|
+
error: this.error,
|
|
110
|
+
...(this.error && this.errorCategory && { errorCategory: this.errorCategory }),
|
|
111
|
+
...(this.interrupted && { cancelled: true }),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private synthetic(event: CodexSyntheticEvent): AdapterEvent[] {
|
|
116
|
+
return event.method === CODEX_PLAN_DECIDED
|
|
117
|
+
? this.planDecided(event.params)
|
|
118
|
+
: this.stopUnconfirmed(event.params);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private notification(n: CodexNotification): AdapterEvent[] {
|
|
122
|
+
const { params } = n;
|
|
123
|
+
switch (n.method) {
|
|
81
124
|
case "model/rerouted":
|
|
82
|
-
if (params.toModel
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return
|
|
86
|
-
case "item/
|
|
87
|
-
|
|
125
|
+
if (typeof params.toModel !== "string" || !params.toModel) return [];
|
|
126
|
+
this.reportedModels.add(params.toModel);
|
|
127
|
+
// What follows is the rerouted model's.
|
|
128
|
+
return [{ kind: "model", model: params.toModel }];
|
|
129
|
+
case "item/started": {
|
|
130
|
+
const item = codexItem(n);
|
|
131
|
+
return item ? this.openItem(item) : [];
|
|
132
|
+
}
|
|
133
|
+
case "item/completed": {
|
|
134
|
+
const item = codexItem(n);
|
|
135
|
+
return item ? this.completeItem(item) : [];
|
|
136
|
+
}
|
|
88
137
|
case "item/agentMessage/delta":
|
|
89
138
|
return this.textDelta(params.itemId, params.delta, "text");
|
|
90
139
|
case "item/reasoning/textDelta":
|
|
91
140
|
case "item/reasoning/summaryTextDelta":
|
|
92
141
|
return this.textDelta(params.itemId, params.delta, "reasoning");
|
|
93
|
-
case "turn/started":
|
|
94
|
-
|
|
142
|
+
case "turn/started": {
|
|
143
|
+
const id = codexTurn(n)?.id;
|
|
144
|
+
if (id) this.turnIds.add(id);
|
|
95
145
|
return [];
|
|
146
|
+
}
|
|
96
147
|
case "thread/tokenUsage/updated": {
|
|
97
|
-
const
|
|
148
|
+
const usage = isRecord(params.tokenUsage) ? params.tokenUsage : undefined;
|
|
149
|
+
const total = counts(usage?.total);
|
|
98
150
|
if (!total) return [];
|
|
99
151
|
// A resumed thread first restates the previous turn's totals, before
|
|
100
152
|
// `turn/started` names this turn: count only this turn's updates.
|
|
101
|
-
if (params.turnId && params.turnId
|
|
153
|
+
if (params.turnId && !this.turnIds.has(params.turnId)) return [];
|
|
102
154
|
// This turn used what the thread's totals grew by. Its first update's
|
|
103
155
|
// `last` is the turn's first request, so the totals before it are the
|
|
104
156
|
// turn's starting point.
|
|
105
|
-
const last =
|
|
157
|
+
const last = counts(usage?.last);
|
|
106
158
|
this.baseline ??= last ? subtractUsage(total, last) : {};
|
|
107
159
|
this.captureUsage(subtractUsage(total, this.baseline));
|
|
108
160
|
// The context in use is the latest request's.
|
|
109
161
|
const latest = last ?? total;
|
|
110
162
|
const used = latest.totalTokens ?? (latest.inputTokens ?? 0) + (latest.outputTokens ?? 0);
|
|
111
|
-
const size =
|
|
112
|
-
return [{ kind: "usage", used, ...(size
|
|
163
|
+
const size = usage?.modelContextWindow;
|
|
164
|
+
return [{ kind: "usage", used, ...(typeof size === "number" && { size }) }];
|
|
113
165
|
}
|
|
114
|
-
case "
|
|
166
|
+
case "account/rateLimits/updated":
|
|
167
|
+
return codexLimits(params.rateLimits);
|
|
168
|
+
case "turn/completed": {
|
|
115
169
|
// (A pre-completion non-retry `error` cannot reach here in practice:
|
|
116
170
|
// the agent's queue ends the turn on that notification.)
|
|
117
|
-
|
|
118
|
-
|
|
171
|
+
const turn = codexTurn(n);
|
|
172
|
+
if (turn?.error) {
|
|
173
|
+
this.error = turn.error.message ?? "codex turn error";
|
|
174
|
+
this.errorCategory = codexErrorCategory(turn.error.codexErrorInfo);
|
|
175
|
+
} else if (turn?.status === "failed") {
|
|
176
|
+
this.error = "Codex ended the turn as failed without saying why";
|
|
177
|
+
}
|
|
178
|
+
// @ref LLP 0001#d4--permission-requests-are-first-class-protocol — a cancelled answer stops the turn
|
|
179
|
+
// Codex stops a turn whose approval was answered cancel: it ended
|
|
180
|
+
// cancelled, as a Claude turn does, not as finished.
|
|
181
|
+
this.interrupted = !this.error && turn?.status === "interrupted";
|
|
182
|
+
this.finishReason = this.error ? "error" : this.interrupted ? "interrupted" : "completed";
|
|
119
183
|
if (!this.error) this.stopReason = "end_turn";
|
|
120
184
|
return [];
|
|
121
|
-
|
|
185
|
+
}
|
|
186
|
+
case "error": {
|
|
122
187
|
// v2 errors carry a nested TurnError and may be transient. A retrying
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
188
|
+
// one tells the user why the turn is waiting; turn/completed remains
|
|
189
|
+
// authoritative.
|
|
190
|
+
const error = codexError(params.error);
|
|
191
|
+
const message =
|
|
192
|
+
error?.message ??
|
|
193
|
+
(typeof params.message === "string" ? params.message : "codex app-server error");
|
|
194
|
+
const category = codexErrorCategory(error?.codexErrorInfo);
|
|
195
|
+
if (params.willRetry) {
|
|
196
|
+
return [{ kind: "retry", category: category ?? classifyError(message), message }];
|
|
197
|
+
}
|
|
198
|
+
this.error = message;
|
|
199
|
+
this.errorCategory = category;
|
|
126
200
|
this.finishReason = "error";
|
|
127
201
|
return [];
|
|
202
|
+
}
|
|
128
203
|
default:
|
|
129
204
|
return [];
|
|
130
205
|
}
|
|
131
206
|
}
|
|
132
207
|
|
|
133
|
-
finish(): TransformResult {
|
|
134
|
-
return {
|
|
135
|
-
usage: this.usage,
|
|
136
|
-
...(this.reportedModels.size && { reportedModels: [...this.reportedModels] }),
|
|
137
|
-
stopReason: this.stopReason,
|
|
138
|
-
finishReason: this.finishReason,
|
|
139
|
-
error: this.error,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
208
|
private openItem(item: CodexItem): AdapterEvent[] {
|
|
144
209
|
switch (item.type) {
|
|
145
210
|
case "subAgentActivity":
|
|
146
211
|
return this.activity(item);
|
|
212
|
+
case "userMessage":
|
|
213
|
+
// @ref LLP 0002#steering — Codex starts a steer's message where it reads it
|
|
214
|
+
// A message Codex was steered with carries the steer's id; the turn's
|
|
215
|
+
// own message has none (the runtime ignores ids it did not accept).
|
|
216
|
+
return item.clientId ? [{ kind: "steer-inserted", steerId: item.clientId }] : [];
|
|
147
217
|
case "agentMessage": {
|
|
148
218
|
const part = createTextPart(this.ctx, item.text ?? "", true);
|
|
149
|
-
this.
|
|
219
|
+
this.texts.set(item.id, part);
|
|
150
220
|
return [{ kind: "part-open", part }];
|
|
151
221
|
}
|
|
222
|
+
case "plan":
|
|
223
|
+
return [{ kind: "part-open", part: this.plan(item) }];
|
|
152
224
|
case "reasoning": {
|
|
153
225
|
const part = createReasoningPart(this.ctx, item.text ?? "", true);
|
|
154
|
-
this.
|
|
226
|
+
this.texts.set(item.id, part);
|
|
155
227
|
return [{ kind: "part-open", part }];
|
|
156
228
|
}
|
|
157
229
|
default: {
|
|
@@ -159,35 +231,46 @@ export class CodexAppServerTransformer implements EventTransformer<unknown> {
|
|
|
159
231
|
// descriptor vocabulary; userMessage and unknown item types produce
|
|
160
232
|
// no assistant output.
|
|
161
233
|
const d = codexToolDescriptor(item.type);
|
|
162
|
-
return d ? this.openTool(item, d) : [];
|
|
234
|
+
return d ? [{ kind: "part-open", part: this.openTool(item, d) }] : [];
|
|
163
235
|
}
|
|
164
236
|
}
|
|
165
237
|
}
|
|
166
238
|
|
|
167
239
|
private completeItem(item: CodexItem): AdapterEvent[] {
|
|
168
|
-
const part = this.partByItem.get(item.id);
|
|
169
240
|
switch (item.type) {
|
|
170
241
|
case "subAgentActivity":
|
|
171
242
|
return this.activity(item);
|
|
243
|
+
case "plan": {
|
|
244
|
+
// The plan waits on the user: the agent's decision completes it.
|
|
245
|
+
const known = this.tools.has(item.id);
|
|
246
|
+
return [{ kind: known ? "part-update" : "part-open", part: this.plan(item) }];
|
|
247
|
+
}
|
|
248
|
+
case "contextCompaction":
|
|
249
|
+
// Codex compacted the thread's context to keep going: a turn never asks
|
|
250
|
+
// it to (`thread/compact/start` is a turn of its own), so it was automatic.
|
|
251
|
+
// It reports no token counts.
|
|
252
|
+
return [{ kind: "compacted", trigger: "auto" }];
|
|
172
253
|
case "agentMessage":
|
|
173
254
|
case "reasoning": {
|
|
174
|
-
const
|
|
255
|
+
const existing = this.texts.get(item.id);
|
|
256
|
+
const part =
|
|
257
|
+
existing ??
|
|
175
258
|
(item.type === "agentMessage"
|
|
176
259
|
? createTextPart(this.ctx, item.text ?? "", true)
|
|
177
|
-
: createReasoningPart(this.ctx, item.text ?? "", true))
|
|
260
|
+
: createReasoningPart(this.ctx, item.text ?? "", true));
|
|
178
261
|
// Reasoning items complete with text:"" while their thought content
|
|
179
262
|
// streamed via item/reasoning/summaryTextDelta — an empty completed
|
|
180
263
|
// text must not clobber the accumulated delta text (consumers persist
|
|
181
264
|
// the terminal snapshot).
|
|
182
|
-
if (item.text)
|
|
183
|
-
|
|
184
|
-
if (!
|
|
185
|
-
return [{ kind: "part-update", part
|
|
265
|
+
if (item.text) part.text = item.text;
|
|
266
|
+
part.state = "done";
|
|
267
|
+
if (!existing) this.texts.set(item.id, part);
|
|
268
|
+
return [{ kind: "part-update", part }];
|
|
186
269
|
}
|
|
187
270
|
default: {
|
|
188
271
|
const d = codexToolDescriptor(item.type);
|
|
189
272
|
if (!d) return [];
|
|
190
|
-
const tool = this.
|
|
273
|
+
const tool = this.tools.get(item.id) ?? this.openTool(item, d);
|
|
191
274
|
setToolMeta(tool, d.meta(item));
|
|
192
275
|
completeToolPart(tool, d.result(item));
|
|
193
276
|
return [{ kind: "part-update", part: tool }];
|
|
@@ -195,6 +278,71 @@ export class CodexAppServerTransformer implements EventTransformer<unknown> {
|
|
|
195
278
|
}
|
|
196
279
|
}
|
|
197
280
|
|
|
281
|
+
/** Codex's proposed plan, as the switch_mode tool part its approval points at. */
|
|
282
|
+
private plan(item: CodexItem): ToolPart {
|
|
283
|
+
const input = { plan: item.text ?? "" };
|
|
284
|
+
const existing = this.tools.get(item.id);
|
|
285
|
+
if (existing?.state.status === "in_progress") {
|
|
286
|
+
existing.state = { ...existing.state, input };
|
|
287
|
+
return existing;
|
|
288
|
+
}
|
|
289
|
+
const part = createToolPart(this.ctx, item.id, "plan", input, { kind: CODEX_TOOL_KINDS.plan });
|
|
290
|
+
this.tools.set(item.id, part);
|
|
291
|
+
return part;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
private planDecided(decided: CodexPlanDecided): AdapterEvent[] {
|
|
295
|
+
// The turn ends cancelled; its closure cancels the plan's part.
|
|
296
|
+
if (decided.decision === "cancelled") {
|
|
297
|
+
this.interrupted = true;
|
|
298
|
+
this.finishReason = "interrupted";
|
|
299
|
+
return [];
|
|
300
|
+
}
|
|
301
|
+
const tool = this.tools.get(decided.itemId);
|
|
302
|
+
if (tool?.state.status !== "in_progress") return [];
|
|
303
|
+
if (decided.decision === "kept_planning") {
|
|
304
|
+
completeToolPart(tool, {
|
|
305
|
+
output: decided.message
|
|
306
|
+
? `The user wants to keep planning, and said:\n${decided.message}`
|
|
307
|
+
: "The user wants to keep planning.",
|
|
308
|
+
isError: true,
|
|
309
|
+
});
|
|
310
|
+
return [{ kind: "part-update", part: tool }];
|
|
311
|
+
}
|
|
312
|
+
completeToolPart(tool, {
|
|
313
|
+
output: decided.decision === "approved" ? "The user approved the plan." : "",
|
|
314
|
+
});
|
|
315
|
+
return [
|
|
316
|
+
{ kind: "part-update", part: tool },
|
|
317
|
+
...(decided.permissionMode
|
|
318
|
+
? [{ kind: "mode" as const, permissionMode: decided.permissionMode }]
|
|
319
|
+
: []),
|
|
320
|
+
];
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// @ref LLP 0002#tools-a-turn-leaves-open — a command a cancel could not stop is not cancelled
|
|
324
|
+
/**
|
|
325
|
+
* A command the cancel could not confirm stopped may still be running: it
|
|
326
|
+
* fails with its outcome unknown instead of closing as cancelled, closed by
|
|
327
|
+
* the engine as the reducer closes a tool its turn left running.
|
|
328
|
+
*/
|
|
329
|
+
private stopUnconfirmed({ itemIds }: CodexStopUnconfirmed): AdapterEvent[] {
|
|
330
|
+
return itemIds.flatMap((itemId): AdapterEvent[] => {
|
|
331
|
+
const tool = this.tools.get(itemId);
|
|
332
|
+
const open = tool?.state;
|
|
333
|
+
if (!tool || (open?.status !== "pending" && open?.status !== "in_progress")) return [];
|
|
334
|
+
const now = Date.now();
|
|
335
|
+
tool.state = {
|
|
336
|
+
status: "failed",
|
|
337
|
+
input: open.status === "in_progress" ? open.input : {},
|
|
338
|
+
error: TOOL_OUTCOME_UNKNOWN,
|
|
339
|
+
closure: "outcome_unknown",
|
|
340
|
+
time: { start: open.status === "in_progress" ? open.time.start : now, end: now },
|
|
341
|
+
};
|
|
342
|
+
return [{ kind: "part-update", part: tool }];
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
198
346
|
private activity(item: CodexItem): AdapterEvent[] {
|
|
199
347
|
if (
|
|
200
348
|
!item.agentThreadId ||
|
|
@@ -202,7 +350,7 @@ export class CodexAppServerTransformer implements EventTransformer<unknown> {
|
|
|
202
350
|
!["started", "interacted", "interrupted", "completed"].includes(item.kind)
|
|
203
351
|
)
|
|
204
352
|
return [];
|
|
205
|
-
const existing = this.
|
|
353
|
+
const existing = this.activities.get(item.id);
|
|
206
354
|
const part: SubagentPart = {
|
|
207
355
|
...this.ctx,
|
|
208
356
|
id: existing?.id ?? generateUUIDv7(),
|
|
@@ -212,24 +360,20 @@ export class CodexAppServerTransformer implements EventTransformer<unknown> {
|
|
|
212
360
|
...(item.agentPath && { path: item.agentPath }),
|
|
213
361
|
activity: item.kind,
|
|
214
362
|
};
|
|
215
|
-
this.
|
|
363
|
+
this.activities.set(item.id, part);
|
|
216
364
|
return [{ kind: existing ? "part-update" : "part-open", part }];
|
|
217
365
|
}
|
|
218
366
|
|
|
219
|
-
private textDelta(
|
|
220
|
-
itemId
|
|
221
|
-
delta: string | undefined,
|
|
222
|
-
kind: "text" | "reasoning",
|
|
223
|
-
): AdapterEvent[] {
|
|
224
|
-
if (!itemId || !delta) return [];
|
|
367
|
+
private textDelta(itemId: unknown, delta: unknown, kind: "text" | "reasoning"): AdapterEvent[] {
|
|
368
|
+
if (typeof itemId !== "string" || typeof delta !== "string" || !itemId || !delta) return [];
|
|
225
369
|
const events: AdapterEvent[] = [];
|
|
226
|
-
let part = this.
|
|
370
|
+
let part = this.texts.get(itemId);
|
|
227
371
|
if (!part) {
|
|
228
372
|
part =
|
|
229
373
|
kind === "text"
|
|
230
374
|
? createTextPart(this.ctx, "", true)
|
|
231
375
|
: createReasoningPart(this.ctx, "", true);
|
|
232
|
-
this.
|
|
376
|
+
this.texts.set(itemId, part);
|
|
233
377
|
// The processor snapshots at emit time, after the append below. Open
|
|
234
378
|
// with a copy so this delta arrives once.
|
|
235
379
|
events.push({ kind: "part-open", part: structuredClone(part) });
|
|
@@ -243,22 +387,13 @@ export class CodexAppServerTransformer implements EventTransformer<unknown> {
|
|
|
243
387
|
return events;
|
|
244
388
|
}
|
|
245
389
|
|
|
246
|
-
private openTool(item: CodexItem, d: CodexToolDescriptor):
|
|
390
|
+
private openTool(item: CodexItem, d: CodexToolDescriptor): ToolPart {
|
|
247
391
|
const part = createToolPart(this.ctx, item.id, d.toolName(item), d.input(item), d.meta(item));
|
|
248
|
-
this.
|
|
249
|
-
return [{ kind: "part-open", part }];
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
private ensureTool(item: CodexItem, d: CodexToolDescriptor): ToolPart {
|
|
253
|
-
const existing = this.partByItem.get(item.id) as ToolPart | undefined;
|
|
254
|
-
if (existing) return existing;
|
|
255
|
-
const part = createToolPart(this.ctx, item.id, d.toolName(item), d.input(item), d.meta(item));
|
|
256
|
-
this.partByItem.set(item.id, part);
|
|
392
|
+
this.tools.set(item.id, part);
|
|
257
393
|
return part;
|
|
258
394
|
}
|
|
259
395
|
|
|
260
|
-
private captureUsage(total:
|
|
261
|
-
if (!total) return;
|
|
396
|
+
private captureUsage(total: Counts): void {
|
|
262
397
|
this.usage = {
|
|
263
398
|
input: Math.max(
|
|
264
399
|
(total.inputTokens ?? 0) -
|
|
@@ -267,23 +402,85 @@ export class CodexAppServerTransformer implements EventTransformer<unknown> {
|
|
|
267
402
|
0,
|
|
268
403
|
),
|
|
269
404
|
output: total.outputTokens ?? 0,
|
|
270
|
-
reasoning: total.reasoningOutputTokens ??
|
|
405
|
+
reasoning: total.reasoningOutputTokens ?? 0,
|
|
271
406
|
cache: { read: total.cachedInputTokens ?? 0, write: total.cacheWriteInputTokens ?? 0 },
|
|
272
407
|
};
|
|
273
408
|
}
|
|
274
409
|
}
|
|
275
410
|
|
|
276
|
-
/** Field-by-field `a - b` of two Codex usage breakdowns, never below zero. */
|
|
277
|
-
export function subtractUsage(
|
|
278
|
-
a: Record<string, number>,
|
|
279
|
-
b: Record<string, number>,
|
|
280
|
-
): Record<string, number> {
|
|
281
|
-
const out: Record<string, number> = {};
|
|
282
|
-
for (const [key, value] of Object.entries(a))
|
|
283
|
-
if (typeof value === "number") out[key] = Math.max(value - (b[key] ?? 0), 0);
|
|
284
|
-
return out;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
411
|
export function createCodexAppServerTransformer(ctx: { sessionId: string }): EventTransformer {
|
|
288
412
|
return new CodexAppServerTransformer(ctx);
|
|
289
413
|
}
|
|
414
|
+
|
|
415
|
+
/** Codex's usage windows, named by length the way Claude names its own. */
|
|
416
|
+
function windowId(slot: string, minutes: unknown, limitId: unknown): string {
|
|
417
|
+
const name = minutes === 300 ? "five_hour" : minutes === 10_080 ? "seven_day" : slot;
|
|
418
|
+
return typeof limitId === "string" && limitId && limitId !== "codex"
|
|
419
|
+
? `${limitId}:${name}`
|
|
420
|
+
: name;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** `account/rateLimits/updated` as the account's plan usage. */
|
|
424
|
+
function codexLimits(limits: unknown): AdapterEvent[] {
|
|
425
|
+
if (!isRecord(limits)) return [];
|
|
426
|
+
const windows = (["primary", "secondary"] as const).flatMap((slot): LimitWindow[] => {
|
|
427
|
+
const window = limits[slot];
|
|
428
|
+
if (!isRecord(window)) return [];
|
|
429
|
+
const { usedPercent, windowDurationMins, resetsAt } = window;
|
|
430
|
+
return [
|
|
431
|
+
{
|
|
432
|
+
id: windowId(slot, windowDurationMins, limits.limitId),
|
|
433
|
+
...(typeof usedPercent === "number" && { usedPercent }),
|
|
434
|
+
// Unix seconds, like Claude's.
|
|
435
|
+
...(typeof resetsAt === "number" && {
|
|
436
|
+
resetsAt: resetsAt < 1e12 ? resetsAt * 1000 : resetsAt,
|
|
437
|
+
}),
|
|
438
|
+
...(typeof windowDurationMins === "number" && { windowMinutes: windowDurationMins }),
|
|
439
|
+
},
|
|
440
|
+
];
|
|
441
|
+
});
|
|
442
|
+
return [
|
|
443
|
+
{
|
|
444
|
+
kind: "limits",
|
|
445
|
+
// A null reached-type does not clear a limit Codex reported before.
|
|
446
|
+
...(limits.rateLimitReachedType ? { status: "limited" } : {}),
|
|
447
|
+
windows,
|
|
448
|
+
...(typeof limits.planType === "string" && limits.planType && { planType: limits.planType }),
|
|
449
|
+
},
|
|
450
|
+
];
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/** Codex's typed failure (`codexErrorInfo`) as an engine error category. */
|
|
454
|
+
export function codexErrorCategory(info: unknown): ErrorCategory | undefined {
|
|
455
|
+
const code = typeof info === "string" ? info : isRecord(info) ? Object.keys(info)[0] : undefined;
|
|
456
|
+
const detail = isRecord(info) ? Object.values(info)[0] : undefined;
|
|
457
|
+
const status = isRecord(detail) ? detail.httpStatusCode : undefined;
|
|
458
|
+
switch (code) {
|
|
459
|
+
case "usageLimitExceeded":
|
|
460
|
+
case "sessionBudgetExceeded":
|
|
461
|
+
return "usage_limit";
|
|
462
|
+
case "rateLimitExceeded":
|
|
463
|
+
return "rate_limit";
|
|
464
|
+
case "serverOverloaded":
|
|
465
|
+
return "overloaded";
|
|
466
|
+
case "contextWindowExceeded":
|
|
467
|
+
return "context_limit";
|
|
468
|
+
case "unauthorized":
|
|
469
|
+
return "auth";
|
|
470
|
+
case "badRequest":
|
|
471
|
+
return "invalid_request";
|
|
472
|
+
case "internalServerError":
|
|
473
|
+
return "internal";
|
|
474
|
+
case "httpConnectionFailed":
|
|
475
|
+
case "responseStreamConnectionFailed":
|
|
476
|
+
case "responseStreamDisconnected":
|
|
477
|
+
case "responseTooManyFailedAttempts":
|
|
478
|
+
if (status === 429) return "rate_limit";
|
|
479
|
+
if (status === 529 || status === 503) return "overloaded";
|
|
480
|
+
// A key the API refused: Codex reports it as a failed connection.
|
|
481
|
+
if (status === 401) return "auth";
|
|
482
|
+
return "network";
|
|
483
|
+
default:
|
|
484
|
+
return undefined;
|
|
485
|
+
}
|
|
486
|
+
}
|