@zvada/agent-server 0.3.22 → 0.3.24
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/CHANGELOG.md +295 -0
- package/README.md +14 -5
- package/dist/accounts/chatgpt.js +144 -0
- package/dist/accounts/check.js +71 -0
- package/dist/accounts/claude.js +80 -0
- package/dist/accounts/endpoint.js +104 -0
- package/dist/accounts/http.js +58 -0
- package/dist/accounts/index.js +9 -0
- package/dist/client/client.js +686 -0
- package/dist/client/connection.js +338 -0
- package/dist/client/history.js +49 -0
- package/dist/client/index.js +6 -0
- package/dist/client/listeners.js +19 -0
- package/dist/client/logins.js +92 -0
- package/dist/client/rpc.js +105 -0
- package/dist/client/streams.js +432 -0
- package/dist/client/transports.js +118 -0
- package/dist/client/turns.js +122 -0
- package/dist/core/agents/acp/acp-agent.js +425 -0
- package/dist/core/agents/acp/adapter.js +231 -0
- package/dist/core/agents/acp/client.js +222 -0
- package/dist/core/agents/acp/known-agents.js +57 -0
- package/dist/core/agents/acp/mappings.js +164 -0
- package/dist/core/agents/acp/requests.js +79 -0
- package/dist/core/agents/attachments.js +14 -0
- package/dist/core/agents/base.js +64 -0
- package/dist/core/agents/claude-code/adapter.js +474 -0
- package/dist/core/agents/claude-code/approvals.js +245 -0
- package/dist/core/agents/claude-code/claude-agent.js +319 -0
- package/dist/core/agents/claude-code/credentials.js +142 -0
- package/dist/core/agents/claude-code/events.js +11 -0
- package/dist/core/agents/claude-code/login.js +217 -0
- package/dist/core/agents/claude-code/mcp.js +181 -0
- package/dist/core/agents/claude-code/models.js +74 -0
- package/dist/core/agents/claude-code/options.js +240 -0
- package/dist/core/agents/claude-code/outcome.js +204 -0
- package/dist/core/agents/claude-code/results.js +58 -0
- package/dist/core/agents/claude-code/sdk-pair.js +59 -0
- package/dist/core/agents/claude-code/session.js +593 -0
- package/dist/core/agents/claude-code/spawn.js +125 -0
- package/dist/core/agents/claude-code/spend.js +118 -0
- package/dist/core/agents/claude-code/tools.js +131 -0
- package/dist/core/agents/claude-code/turn-usage.js +121 -0
- package/dist/core/agents/claude-code/turn.js +199 -0
- package/dist/core/agents/codex-app-server/adapter.js +463 -0
- package/dist/core/agents/codex-app-server/client.js +338 -0
- package/dist/core/agents/codex-app-server/codex-agent.js +294 -0
- package/dist/core/agents/codex-app-server/commands.js +184 -0
- package/dist/core/agents/codex-app-server/credentials.js +92 -0
- package/dist/core/agents/codex-app-server/effort.js +13 -0
- package/dist/core/agents/codex-app-server/events.js +18 -0
- package/dist/core/agents/codex-app-server/homes.js +118 -0
- package/dist/core/agents/codex-app-server/input.js +52 -0
- package/dist/core/agents/codex-app-server/items.js +307 -0
- package/dist/core/agents/codex-app-server/login.js +183 -0
- package/dist/core/agents/codex-app-server/mcp.js +323 -0
- package/dist/core/agents/codex-app-server/models.js +160 -0
- package/dist/core/agents/codex-app-server/options.js +155 -0
- package/dist/core/agents/codex-app-server/plan-approval.js +124 -0
- package/dist/core/agents/codex-app-server/protocol.js +38 -0
- package/dist/core/agents/codex-app-server/requests.js +250 -0
- package/dist/core/agents/codex-app-server/session.js +278 -0
- package/dist/core/agents/codex-app-server/subagents.js +260 -0
- package/dist/core/agents/codex-app-server/thread-settings.js +214 -0
- package/dist/core/agents/codex-app-server/turn-items.js +69 -0
- package/dist/core/agents/codex-app-server/turn.js +448 -0
- package/dist/core/agents/codex-app-server/user-login.js +78 -0
- package/dist/core/agents/config-fingerprint.js +10 -0
- package/dist/core/agents/credentials.js +71 -0
- package/dist/core/agents/diffs.js +27 -0
- package/dist/core/agents/elicitation.js +42 -0
- package/dist/core/agents/inherit-config.js +5 -0
- package/dist/core/agents/login.js +56 -0
- package/dist/core/agents/mcp-config.js +109 -0
- package/dist/core/agents/plan.js +6 -0
- package/dist/core/agents/process-pool.js +307 -0
- package/dist/core/agents/registry.js +49 -0
- package/dist/core/agents/scripted/adapter.js +86 -0
- package/dist/core/agents/scripted/mcp-call.js +74 -0
- package/dist/core/agents/scripted/scripted-agent.js +330 -0
- package/dist/core/agents/scripted/scripts.js +154 -0
- package/dist/core/agents/scripted/steps.js +87 -0
- package/dist/core/agents/session-agent.js +209 -0
- package/dist/core/agents/stderr-tail.js +71 -0
- package/dist/core/agents/thinking-levels.js +9 -0
- package/dist/core/agents/types.js +1 -0
- package/dist/core/diagnostics.js +23 -0
- package/dist/core/index.js +31 -0
- package/dist/core/presets.js +114 -0
- package/dist/core/processes/identity.js +91 -0
- package/dist/core/processes/lifeline.js +210 -0
- package/dist/core/processes/native-processes.js +299 -0
- package/dist/core/processes/process-table.js +163 -0
- package/dist/core/provision/cache-trust.js +121 -0
- package/dist/core/provision/cache-usage.js +61 -0
- package/dist/core/provision/checksums.js +22 -0
- package/dist/core/provision/extract.js +28 -0
- package/dist/core/provision/index.js +4 -0
- package/dist/core/provision/install-build.js +99 -0
- package/dist/core/provision/npm.js +316 -0
- package/dist/core/provision/pins.js +35 -0
- package/dist/core/provision/platform.js +65 -0
- package/dist/core/provision/provisioner.js +372 -0
- package/dist/core/provision/releases.js +68 -0
- package/dist/core/provision/tools.js +279 -0
- package/dist/core/proxy/anthropic-proxy.js +163 -0
- package/dist/core/proxy/api-key-store.js +30 -0
- package/dist/core/proxy/index.js +3 -0
- package/dist/core/proxy/loopback.js +86 -0
- package/dist/core/runtime/agent-runtime.js +434 -0
- package/dist/core/runtime/event-processor.js +379 -0
- package/dist/core/runtime/event-sink.js +65 -0
- package/dist/core/runtime/harness-clis.js +83 -0
- package/dist/core/runtime/harness-logins.js +313 -0
- package/dist/core/runtime/login-reads.js +71 -0
- package/dist/core/runtime/model-lists.js +160 -0
- package/dist/core/runtime/permission-policy.js +84 -0
- package/dist/core/runtime/request-broker.js +139 -0
- package/dist/core/runtime/steering.js +79 -0
- package/dist/core/runtime/turn-outcome.js +16 -0
- package/dist/core/runtime/turn.js +329 -0
- package/dist/core/utils/bounded.js +13 -0
- package/dist/core/utils/deadline.js +57 -0
- package/dist/core/utils/errors.js +176 -0
- package/dist/core/utils/is-record.js +4 -0
- package/dist/core/utils/loopback.js +11 -0
- package/dist/index.js +4 -0
- package/dist/operator/index.js +10 -0
- package/dist/operator/mcp.js +139 -0
- package/dist/operator/operator.js +499 -0
- package/dist/operator/render.js +408 -0
- package/dist/operator/view.js +35 -0
- package/dist/protocol/account.js +96 -0
- package/dist/protocol/async-queue.js +65 -0
- package/dist/protocol/auth.js +169 -0
- package/dist/protocol/canonical.js +18 -0
- package/dist/protocol/clis.js +63 -0
- package/dist/protocol/config.js +137 -0
- package/dist/protocol/conversation.js +231 -0
- package/dist/protocol/credentials.js +141 -0
- package/dist/protocol/errors.js +181 -0
- package/dist/protocol/execution.js +28 -0
- package/dist/protocol/factories.js +231 -0
- package/dist/protocol/guards.js +71 -0
- package/dist/protocol/harness.js +93 -0
- package/dist/protocol/history.js +201 -0
- package/dist/protocol/ids.js +37 -0
- package/dist/protocol/index.js +36 -0
- package/dist/protocol/lifecycle.js +562 -0
- package/dist/protocol/meta-keys.js +17 -0
- package/dist/protocol/meta.js +13 -0
- package/dist/protocol/model-catalog.js +223 -0
- package/dist/protocol/models.js +84 -0
- package/dist/protocol/part-input.js +94 -0
- package/dist/protocol/parts.js +166 -0
- package/dist/protocol/plan.js +31 -0
- package/dist/protocol/reduce.js +484 -0
- package/dist/protocol/selectors.js +136 -0
- package/dist/protocol/seq-cursor.js +37 -0
- package/dist/protocol/stop-reasons.js +41 -0
- package/dist/protocol/thinking.js +31 -0
- package/dist/protocol/time.js +21 -0
- package/dist/protocol/tokens.js +57 -0
- package/dist/protocol/tool-closure.js +70 -0
- package/dist/protocol/tool-state.js +153 -0
- package/dist/protocol/verify.js +467 -0
- package/dist/protocol/vocabulary.js +27 -0
- package/dist/protocol/wire-api.js +94 -0
- package/dist/protocol/wire.js +669 -0
- package/dist/server/acp/binding.js +251 -0
- package/dist/server/acp/session-records.js +53 -0
- package/dist/server/acp/translate.js +401 -0
- package/dist/server/agent-server.js +338 -0
- package/dist/server/bin.js +492 -0
- package/dist/server/feedback.js +216 -0
- package/dist/server/history.js +123 -0
- package/dist/server/index.js +8 -0
- package/dist/server/install.js +171 -0
- package/dist/server/open-parts.js +87 -0
- package/dist/server/routes.js +291 -0
- package/dist/server/secrets.js +19 -0
- package/dist/server/session-gate.js +54 -0
- package/dist/server/session-log.js +66 -0
- package/dist/server/session-store.js +243 -0
- package/dist/server/subscriptions.js +189 -0
- package/dist/server/transports.js +214 -0
- package/dist/server/wire-error.js +26 -0
- package/dist/sync/event-log.js +89 -0
- package/dist/sync/fit.js +202 -0
- package/dist/sync/history-reader.js +33 -0
- package/dist/sync/history-sqlite.js +281 -0
- package/dist/sync/history.js +163 -0
- package/dist/sync/index.js +5 -0
- package/dist/sync/journal-sqlite.js +316 -0
- package/dist/sync/journal.js +10 -0
- package/dist/sync/live-tails.js +85 -0
- package/dist/sync/node-sqlite.js +27 -0
- package/dist/sync/projection.js +32 -0
- package/dist/sync/recovery.js +117 -0
- package/dist/sync/retry.js +45 -0
- package/dist/sync/schema.js +73 -0
- package/dist/sync/sql.js +94 -0
- package/dist/sync/sqlite-file.js +31 -0
- package/dist/sync/sqlite.js +18 -0
- package/dist/sync/worker.js +212 -0
- package/dist/types/accounts/chatgpt.d.ts +1 -1
- package/dist/types/accounts/chatgpt.d.ts.map +1 -1
- package/dist/types/accounts/http.d.ts +2 -4
- package/dist/types/accounts/http.d.ts.map +1 -1
- package/dist/types/client/client.d.ts +37 -11
- package/dist/types/client/client.d.ts.map +1 -1
- package/dist/types/client/connection.d.ts +64 -13
- package/dist/types/client/connection.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +1 -1
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/logins.d.ts +2 -1
- package/dist/types/client/logins.d.ts.map +1 -1
- package/dist/types/client/streams.d.ts +9 -3
- package/dist/types/client/streams.d.ts.map +1 -1
- package/dist/types/client/turns.d.ts +1 -1
- package/dist/types/client/turns.d.ts.map +1 -1
- package/dist/types/core/agents/acp/acp-agent.d.ts +34 -1
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
- package/dist/types/core/agents/acp/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/acp/client.d.ts +12 -3
- package/dist/types/core/agents/acp/client.d.ts.map +1 -1
- package/dist/types/core/agents/acp/mappings.d.ts +8 -2
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
- package/dist/types/core/agents/base.d.ts +22 -8
- package/dist/types/core/agents/base.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/adapter.d.ts +7 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/approvals.d.ts +4 -1
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +19 -5
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/events.d.ts +9 -1
- package/dist/types/core/agents/claude-code/events.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/login.d.ts +4 -1
- package/dist/types/core/agents/claude-code/login.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/mcp.d.ts +21 -7
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/models.d.ts +5 -1
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/options.d.ts +29 -10
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/outcome.d.ts +3 -5
- package/dist/types/core/agents/claude-code/outcome.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/results.d.ts +16 -0
- package/dist/types/core/agents/claude-code/results.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/sdk-pair.d.ts +13 -0
- package/dist/types/core/agents/claude-code/sdk-pair.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session.d.ts +58 -12
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/spend.d.ts +2 -1
- package/dist/types/core/agents/claude-code/spend.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/tools.d.ts +26 -3
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/adapter.d.ts +2 -2
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/client.d.ts +12 -2
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +58 -13
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/commands.d.ts +2 -2
- package/dist/types/core/agents/codex-app-server/commands.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/credentials.d.ts +5 -1
- package/dist/types/core/agents/codex-app-server/credentials.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/effort.d.ts +2 -1
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/homes.d.ts +25 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/items.d.ts +27 -2
- package/dist/types/core/agents/codex-app-server/items.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/login.d.ts +16 -1
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +15 -30
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/models.d.ts +3 -10
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/options.d.ts +27 -4
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts +2 -1
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/protocol.d.ts +16 -3
- package/dist/types/core/agents/codex-app-server/protocol.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/session.d.ts +71 -40
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/subagents.d.ts +9 -4
- package/dist/types/core/agents/codex-app-server/subagents.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts +3 -2
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts +2 -1
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/turn.d.ts +31 -8
- package/dist/types/core/agents/codex-app-server/turn.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/user-login.d.ts +28 -0
- package/dist/types/core/agents/codex-app-server/user-login.d.ts.map +1 -0
- package/dist/types/core/agents/credentials.d.ts +3 -1
- package/dist/types/core/agents/credentials.d.ts.map +1 -1
- package/dist/types/core/agents/diffs.d.ts +9 -0
- package/dist/types/core/agents/diffs.d.ts.map +1 -0
- package/dist/types/core/agents/elicitation.d.ts +3 -2
- package/dist/types/core/agents/elicitation.d.ts.map +1 -1
- package/dist/types/core/agents/login.d.ts +6 -0
- package/dist/types/core/agents/login.d.ts.map +1 -1
- package/dist/types/core/agents/mcp-config.d.ts +0 -4
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -1
- package/dist/types/core/agents/process-pool.d.ts +201 -0
- package/dist/types/core/agents/process-pool.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/adapter.d.ts +68 -0
- package/dist/types/core/agents/scripted/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/mcp-call.d.ts +56 -0
- package/dist/types/core/agents/scripted/mcp-call.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/scripted-agent.d.ts +73 -0
- package/dist/types/core/agents/scripted/scripted-agent.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/scripts.d.ts +29 -0
- package/dist/types/core/agents/scripted/scripts.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/steps.d.ts +132 -0
- package/dist/types/core/agents/scripted/steps.d.ts.map +1 -0
- package/dist/types/core/agents/session-agent.d.ts +49 -6
- package/dist/types/core/agents/session-agent.d.ts.map +1 -1
- package/dist/types/core/diagnostics.d.ts +4 -1
- package/dist/types/core/diagnostics.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +5 -0
- package/dist/types/core/index.d.ts.map +1 -1
- package/dist/types/core/presets.d.ts +32 -6
- package/dist/types/core/presets.d.ts.map +1 -1
- package/dist/types/core/processes/lifeline.d.ts +0 -20
- package/dist/types/core/processes/lifeline.d.ts.map +1 -1
- package/dist/types/core/provision/index.d.ts +2 -2
- package/dist/types/core/provision/index.d.ts.map +1 -1
- package/dist/types/core/provision/install-build.d.ts +2 -1
- package/dist/types/core/provision/install-build.d.ts.map +1 -1
- package/dist/types/core/provision/npm.d.ts +20 -8
- package/dist/types/core/provision/npm.d.ts.map +1 -1
- package/dist/types/core/provision/provisioner.d.ts +4 -1
- package/dist/types/core/provision/provisioner.d.ts.map +1 -1
- package/dist/types/core/provision/tools.d.ts +2 -1
- package/dist/types/core/provision/tools.d.ts.map +1 -1
- package/dist/types/core/runtime/agent-runtime.d.ts +16 -8
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
- package/dist/types/core/runtime/event-processor.d.ts +5 -1
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -1
- package/dist/types/core/runtime/harness-clis.d.ts +9 -0
- package/dist/types/core/runtime/harness-clis.d.ts.map +1 -1
- package/dist/types/core/runtime/harness-logins.d.ts +33 -5
- package/dist/types/core/runtime/harness-logins.d.ts.map +1 -1
- package/dist/types/core/runtime/model-lists.d.ts +2 -0
- package/dist/types/core/runtime/model-lists.d.ts.map +1 -1
- package/dist/types/core/runtime/permission-policy.d.ts +5 -3
- package/dist/types/core/runtime/permission-policy.d.ts.map +1 -1
- package/dist/types/core/runtime/request-broker.d.ts +2 -1
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -1
- package/dist/types/core/runtime/turn.d.ts +12 -1
- package/dist/types/core/runtime/turn.d.ts.map +1 -1
- package/dist/types/core/utils/deadline.d.ts +6 -0
- package/dist/types/core/utils/deadline.d.ts.map +1 -1
- package/dist/types/core/utils/errors.d.ts +7 -1
- package/dist/types/core/utils/errors.d.ts.map +1 -1
- package/dist/types/operator/operator.d.ts.map +1 -1
- package/dist/types/operator/render.d.ts +6 -4
- package/dist/types/operator/render.d.ts.map +1 -1
- package/dist/types/protocol/auth.d.ts +54 -24
- package/dist/types/protocol/auth.d.ts.map +1 -1
- package/dist/types/protocol/clis.d.ts +14 -7
- package/dist/types/protocol/clis.d.ts.map +1 -1
- package/dist/types/protocol/config.d.ts +2 -0
- package/dist/types/protocol/config.d.ts.map +1 -1
- package/dist/types/protocol/conversation.d.ts +40 -3
- package/dist/types/protocol/conversation.d.ts.map +1 -1
- package/dist/types/protocol/credentials.d.ts +7 -0
- package/dist/types/protocol/credentials.d.ts.map +1 -1
- package/dist/types/protocol/execution.d.ts +2 -1
- package/dist/types/protocol/execution.d.ts.map +1 -1
- package/dist/types/protocol/factories.d.ts +12 -2
- package/dist/types/protocol/factories.d.ts.map +1 -1
- package/dist/types/protocol/harness.d.ts +6 -2
- package/dist/types/protocol/harness.d.ts.map +1 -1
- package/dist/types/protocol/history.d.ts +19 -0
- package/dist/types/protocol/history.d.ts.map +1 -1
- package/dist/types/protocol/lifecycle.d.ts +47 -8
- package/dist/types/protocol/lifecycle.d.ts.map +1 -1
- package/dist/types/protocol/model-catalog.d.ts.map +1 -1
- package/dist/types/protocol/models.d.ts +3 -0
- package/dist/types/protocol/models.d.ts.map +1 -1
- package/dist/types/protocol/parts.d.ts +14 -0
- package/dist/types/protocol/parts.d.ts.map +1 -1
- package/dist/types/protocol/tool-state.d.ts +12 -0
- package/dist/types/protocol/tool-state.d.ts.map +1 -1
- package/dist/types/protocol/wire-api.d.ts +129 -23
- package/dist/types/protocol/wire-api.d.ts.map +1 -1
- package/dist/types/protocol/wire.d.ts +70 -10
- package/dist/types/protocol/wire.d.ts.map +1 -1
- package/dist/types/server/acp/binding.d.ts +6 -1
- package/dist/types/server/acp/binding.d.ts.map +1 -1
- package/dist/types/server/acp/translate.d.ts +33 -7
- package/dist/types/server/acp/translate.d.ts.map +1 -1
- package/dist/types/server/agent-server.d.ts +6 -0
- package/dist/types/server/agent-server.d.ts.map +1 -1
- package/dist/types/server/bin.d.ts +3 -0
- package/dist/types/server/bin.d.ts.map +1 -0
- package/dist/types/server/feedback.d.ts +2 -1
- package/dist/types/server/feedback.d.ts.map +1 -1
- package/dist/types/server/install.d.ts +11 -0
- package/dist/types/server/install.d.ts.map +1 -1
- package/dist/types/server/session-gate.d.ts +2 -1
- package/dist/types/server/session-gate.d.ts.map +1 -1
- package/dist/types/server/session-store.d.ts +1 -0
- package/dist/types/server/session-store.d.ts.map +1 -1
- package/dist/types/server/subscriptions.d.ts +2 -1
- package/dist/types/server/subscriptions.d.ts.map +1 -1
- package/dist/types/server/transports.d.ts +2 -1
- package/dist/types/server/transports.d.ts.map +1 -1
- package/dist/types/sync/fit.d.ts +8 -7
- package/dist/types/sync/fit.d.ts.map +1 -1
- package/dist/types/sync/history-sqlite.d.ts.map +1 -1
- package/dist/types/sync/index.d.ts +1 -0
- package/dist/types/sync/index.d.ts.map +1 -1
- package/dist/types/sync/journal-sqlite.d.ts +2 -1
- package/dist/types/sync/journal-sqlite.d.ts.map +1 -1
- package/dist/types/sync/journal.d.ts +11 -3
- package/dist/types/sync/journal.d.ts.map +1 -1
- package/dist/types/sync/node-sqlite.d.ts +4 -1
- package/dist/types/sync/node-sqlite.d.ts.map +1 -1
- package/dist/types/sync/projection.d.ts +6 -0
- package/dist/types/sync/projection.d.ts.map +1 -1
- package/dist/types/sync/recovery.d.ts +2 -1
- package/dist/types/sync/recovery.d.ts.map +1 -1
- package/dist/types/sync/schema.d.ts +10 -0
- package/dist/types/sync/schema.d.ts.map +1 -1
- package/dist/types/sync/sql.d.ts +2 -1
- package/dist/types/sync/sql.d.ts.map +1 -1
- package/docs/consuming.md +304 -28
- package/docs/deploy.md +64 -8
- package/docs/durable-sessions.md +35 -5
- package/docs/harnesses.md +398 -25
- package/package.json +48 -18
- package/src/accounts/chatgpt.ts +2 -2
- package/src/accounts/http.ts +2 -16
- package/src/client/client.ts +92 -31
- package/src/client/connection.ts +103 -22
- package/src/client/index.ts +1 -0
- package/src/client/logins.ts +1 -1
- package/src/client/streams.ts +12 -4
- package/src/client/turns.ts +1 -1
- package/src/core/agents/acp/acp-agent.ts +181 -52
- package/src/core/agents/acp/adapter.ts +9 -1
- package/src/core/agents/acp/client.ts +16 -4
- package/src/core/agents/acp/mappings.ts +27 -0
- package/src/core/agents/base.ts +25 -10
- package/src/core/agents/claude-code/adapter.ts +47 -17
- package/src/core/agents/claude-code/approvals.ts +11 -6
- package/src/core/agents/claude-code/claude-agent.ts +89 -32
- package/src/core/agents/claude-code/events.ts +11 -1
- package/src/core/agents/claude-code/login.ts +14 -2
- package/src/core/agents/claude-code/mcp.ts +31 -15
- package/src/core/agents/claude-code/models.ts +7 -2
- package/src/core/agents/claude-code/options.ts +30 -9
- package/src/core/agents/claude-code/outcome.ts +10 -2
- package/src/core/agents/claude-code/results.ts +73 -0
- package/src/core/agents/claude-code/sdk-pair.ts +66 -0
- package/src/core/agents/claude-code/session.ts +179 -37
- package/src/core/agents/claude-code/spend.ts +1 -1
- package/src/core/agents/claude-code/tools.ts +108 -12
- package/src/core/agents/codex-app-server/adapter.ts +37 -12
- package/src/core/agents/codex-app-server/client.ts +37 -8
- package/src/core/agents/codex-app-server/codex-agent.ts +115 -50
- package/src/core/agents/codex-app-server/commands.ts +2 -2
- package/src/core/agents/codex-app-server/credentials.ts +10 -5
- package/src/core/agents/codex-app-server/effort.ts +1 -1
- package/src/core/agents/codex-app-server/homes.ts +54 -3
- package/src/core/agents/codex-app-server/items.ts +219 -31
- package/src/core/agents/codex-app-server/login.ts +44 -2
- package/src/core/agents/codex-app-server/mcp.ts +47 -32
- package/src/core/agents/codex-app-server/models.ts +9 -8
- package/src/core/agents/codex-app-server/options.ts +69 -10
- package/src/core/agents/codex-app-server/plan-approval.ts +1 -1
- package/src/core/agents/codex-app-server/protocol.ts +14 -4
- package/src/core/agents/codex-app-server/requests.ts +17 -8
- package/src/core/agents/codex-app-server/session.ts +160 -113
- package/src/core/agents/codex-app-server/subagents.ts +21 -14
- package/src/core/agents/codex-app-server/thread-settings.ts +18 -8
- package/src/core/agents/codex-app-server/turn-items.ts +1 -1
- package/src/core/agents/codex-app-server/turn.ts +79 -32
- package/src/core/agents/codex-app-server/user-login.ts +107 -0
- package/src/core/agents/credentials.ts +5 -2
- package/src/core/agents/diffs.ts +25 -0
- package/src/core/agents/elicitation.ts +2 -2
- package/src/core/agents/login.ts +6 -0
- package/src/core/agents/mcp-config.ts +2 -2
- package/src/core/agents/process-pool.ts +458 -0
- package/src/core/agents/scripted/adapter.ts +142 -0
- package/src/core/agents/scripted/mcp-call.ts +134 -0
- package/src/core/agents/scripted/scripted-agent.ts +418 -0
- package/src/core/agents/scripted/scripts.ts +171 -0
- package/src/core/agents/scripted/steps.ts +127 -0
- package/src/core/agents/session-agent.ts +105 -8
- package/src/core/diagnostics.ts +9 -1
- package/src/core/index.ts +11 -0
- package/src/core/presets.ts +100 -14
- package/src/core/processes/lifeline.ts +99 -25
- package/src/core/provision/index.ts +1 -2
- package/src/core/provision/install-build.ts +4 -1
- package/src/core/provision/npm.ts +309 -97
- package/src/core/provision/provisioner.ts +22 -8
- package/src/core/provision/tools.ts +44 -19
- package/src/core/runtime/agent-runtime.ts +48 -18
- package/src/core/runtime/event-processor.ts +18 -2
- package/src/core/runtime/harness-clis.ts +36 -1
- package/src/core/runtime/harness-logins.ts +82 -31
- package/src/core/runtime/model-lists.ts +1 -1
- package/src/core/runtime/permission-policy.ts +4 -3
- package/src/core/runtime/request-broker.ts +1 -1
- package/src/core/runtime/turn.ts +51 -3
- package/src/core/utils/deadline.ts +23 -0
- package/src/core/utils/errors.ts +11 -4
- package/src/operator/operator.ts +8 -4
- package/src/operator/render.ts +46 -8
- package/src/protocol/auth.ts +30 -23
- package/src/protocol/clis.ts +12 -4
- package/src/protocol/credentials.ts +19 -0
- package/src/protocol/execution.ts +5 -0
- package/src/protocol/factories.ts +25 -3
- package/src/protocol/harness.ts +11 -1
- package/src/protocol/history.ts +20 -0
- package/src/protocol/lifecycle.ts +10 -1
- package/src/protocol/model-catalog.ts +19 -8
- package/src/protocol/parts.ts +12 -1
- package/src/protocol/tool-state.ts +14 -1
- package/src/protocol/wire.ts +14 -0
- package/src/server/acp/binding.ts +113 -23
- package/src/server/acp/translate.ts +161 -8
- package/src/server/agent-server.ts +10 -1
- package/src/server/bin.ts +108 -19
- package/src/server/feedback.ts +1 -1
- package/src/server/install.ts +82 -4
- package/src/server/session-gate.ts +1 -1
- package/src/server/session-store.ts +5 -1
- package/src/server/subscriptions.ts +1 -1
- package/src/server/transports.ts +20 -1
- package/src/sync/fit.ts +115 -28
- package/src/sync/history-sqlite.ts +6 -2
- package/src/sync/index.ts +1 -0
- package/src/sync/journal-sqlite.ts +20 -2
- package/src/sync/journal.ts +10 -2
- package/src/sync/node-sqlite.ts +19 -3
- package/src/sync/projection.ts +10 -0
- package/src/sync/recovery.ts +11 -4
- package/src/sync/schema.ts +7 -5
- package/src/sync/sql.ts +1 -1
- package/dist/types/core/agents/claude-code/session-pool.d.ts +0 -36
- package/dist/types/core/agents/claude-code/session-pool.d.ts.map +0 -1
- package/dist/types/core/agents/session-pool.d.ts +0 -41
- package/dist/types/core/agents/session-pool.d.ts.map +0 -1
- package/src/core/agents/claude-code/session-pool.ts +0 -136
- package/src/core/agents/session-pool.ts +0 -111
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ToolKind,
|
|
3
|
+
ToolLocation,
|
|
4
|
+
ToolMeta,
|
|
5
|
+
ToolResultContent,
|
|
6
|
+
} from "../../../protocol/index.ts";
|
|
7
|
+
import { isRecord } from "../../utils/is-record.ts";
|
|
8
|
+
import { hunkDiff } from "../diffs.ts";
|
|
2
9
|
import type { CodexFileChange, CodexItem } from "./protocol.ts";
|
|
3
10
|
|
|
4
11
|
/** Codex tools are already normalized names; kinds are fixed per item type. */
|
|
@@ -7,6 +14,7 @@ export const CODEX_TOOL_KINDS = {
|
|
|
7
14
|
apply_patch: "edit",
|
|
8
15
|
web_search: "fetch",
|
|
9
16
|
mcp: "other",
|
|
17
|
+
image_generation: "other",
|
|
10
18
|
/** The plan Codex proposes in Plan mode, put to the user like Claude's ExitPlanMode. */
|
|
11
19
|
plan: "switch_mode",
|
|
12
20
|
} as const satisfies Record<string, ToolKind>;
|
|
@@ -19,8 +27,15 @@ export const CODEX_TOOL_KINDS = {
|
|
|
19
27
|
export interface CodexToolDescriptor {
|
|
20
28
|
toolName(item: CodexItem): string;
|
|
21
29
|
input(item: CodexItem): Record<string, unknown>;
|
|
30
|
+
/** Codex says this tool's input only once it is done: its completed item sets it again. */
|
|
31
|
+
inputAtCompletion?: true;
|
|
22
32
|
meta(item: CodexItem): ToolMeta;
|
|
23
|
-
result(item: CodexItem): {
|
|
33
|
+
result(item: CodexItem): {
|
|
34
|
+
output: string;
|
|
35
|
+
isError: boolean;
|
|
36
|
+
content?: ToolResultContent[];
|
|
37
|
+
metadata?: Record<string, unknown>;
|
|
38
|
+
};
|
|
24
39
|
}
|
|
25
40
|
|
|
26
41
|
function pickCodexError(err: CodexItem["error"]): string {
|
|
@@ -28,24 +43,53 @@ function pickCodexError(err: CodexItem["error"]): string {
|
|
|
28
43
|
return typeof err === "string" ? err : (err.message ?? "");
|
|
29
44
|
}
|
|
30
45
|
|
|
31
|
-
/**
|
|
32
|
-
function
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
/** Base64 a block carries (an image's or audio's `data`, an embedded resource's `blob`). */
|
|
47
|
+
function carriesBytes(block: Record<string, unknown>): boolean {
|
|
48
|
+
const resource = isRecord(block.resource) ? block.resource : {};
|
|
49
|
+
return typeof block.data === "string" || typeof resource.blob === "string";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A block's MIME type, its own or its embedded resource's. */
|
|
53
|
+
function blockMimeType(block: Record<string, unknown>): string | undefined {
|
|
54
|
+
const resource = isRecord(block.resource) ? block.resource : {};
|
|
55
|
+
const mimeType = block.mimeType ?? resource.mimeType;
|
|
56
|
+
return typeof mimeType === "string" ? mimeType : undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* One MCP content block, as the stream shows it: what `output` says of it,
|
|
61
|
+
* and its `content` entry. Text is text and an image an image; another
|
|
62
|
+
* block is the text `output` has for it. No block's bytes are ever text: a
|
|
63
|
+
* placeholder naming its type (and MIME type) stands for them.
|
|
64
|
+
*/
|
|
65
|
+
function mcpBlock(block: unknown): { shown: string; entry: ToolResultContent } {
|
|
66
|
+
if (isRecord(block) && block.type === "text" && typeof block.text === "string")
|
|
67
|
+
return { shown: block.text, entry: { type: "text", text: block.text } };
|
|
68
|
+
let shown = JSON.stringify(block);
|
|
69
|
+
if (isRecord(block) && carriesBytes(block)) {
|
|
70
|
+
const mimeType = blockMimeType(block);
|
|
71
|
+
shown = `[${String(block.type ?? "binary")}${mimeType ? ` ${mimeType}` : ""}]`;
|
|
72
|
+
if (block.type === "image" && typeof block.data === "string" && mimeType)
|
|
73
|
+
return { shown, entry: { type: "image", data: block.data, mimeType } };
|
|
47
74
|
}
|
|
48
|
-
return
|
|
75
|
+
return { shown, entry: { type: "text", text: shown } };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// @ref LLP 0002#tool-output-has-three-audiences — `content` is display-grade, `output` model-facing
|
|
79
|
+
/**
|
|
80
|
+
* An MCP tool's result: its blocks as `output` shows them, joined. A result
|
|
81
|
+
* with an image also has `content`, every block in order, as Claude's tool
|
|
82
|
+
* results do; one without has nothing `output` does not say.
|
|
83
|
+
*/
|
|
84
|
+
function mcpResult(result: unknown): { output: string; content?: ToolResultContent[] } {
|
|
85
|
+
const blocks = isRecord(result) && "content" in result ? result.content : result;
|
|
86
|
+
if (blocks == null) return { output: "" };
|
|
87
|
+
if (typeof blocks === "string") return { output: blocks };
|
|
88
|
+
if (!Array.isArray(blocks)) return { output: JSON.stringify(blocks) };
|
|
89
|
+
const read = blocks.map(mcpBlock);
|
|
90
|
+
const output = read.map(({ shown }) => shown).join("");
|
|
91
|
+
if (!read.some(({ entry }) => entry.type === "image")) return { output };
|
|
92
|
+
return { output, content: read.map(({ entry }) => entry) };
|
|
49
93
|
}
|
|
50
94
|
|
|
51
95
|
const failed = (item: CodexItem) => item.status === "failed";
|
|
@@ -64,11 +108,125 @@ function describeChange(change: CodexFileChange): string {
|
|
|
64
108
|
return `${kind ?? "change"} ${change.path}${to ? ` -> ${to}` : ""}`;
|
|
65
109
|
}
|
|
66
110
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
111
|
+
/** A shell Codex runs a command in, `-lc` and its one argument, the line. */
|
|
112
|
+
const SHELL_WRAPPER = /^(?:\S*\/)?(?:ba|z)?sh -lc (.+)$/s;
|
|
113
|
+
/** Characters a word may hold unquoted and mean only themselves. */
|
|
114
|
+
const PLAIN = /[A-Za-z0-9_@%+=:,./-]/;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The one shell word `text` is, unquoted as the shell would; undefined when
|
|
118
|
+
* it is several words, unterminated, or would expand (an unquoted special
|
|
119
|
+
* character, a `$` or a backquote inside double quotes).
|
|
120
|
+
*/
|
|
121
|
+
function shellWord(text: string): string | undefined {
|
|
122
|
+
let word = "";
|
|
123
|
+
let i = 0;
|
|
124
|
+
while (i < text.length) {
|
|
125
|
+
const c = text[i] as string;
|
|
126
|
+
if (c === "'") {
|
|
127
|
+
const end = text.indexOf("'", i + 1);
|
|
128
|
+
if (end < 0) return undefined;
|
|
129
|
+
word += text.slice(i + 1, end);
|
|
130
|
+
i = end + 1;
|
|
131
|
+
} else if (c === '"') {
|
|
132
|
+
i++;
|
|
133
|
+
for (;;) {
|
|
134
|
+
const d = text[i];
|
|
135
|
+
if (d === undefined || d === "$" || d === "`") return undefined;
|
|
136
|
+
if (d === '"') break;
|
|
137
|
+
if (d === "\\" && '"\\$`'.includes(text[i + 1] ?? "")) {
|
|
138
|
+
word += text[i + 1];
|
|
139
|
+
i += 2;
|
|
140
|
+
} else {
|
|
141
|
+
word += d;
|
|
142
|
+
i++;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
i++;
|
|
146
|
+
} else if (PLAIN.test(c)) {
|
|
147
|
+
word += c;
|
|
148
|
+
i++;
|
|
149
|
+
} else return undefined;
|
|
150
|
+
}
|
|
151
|
+
return word;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// @ref LLP 0002#a-tool-call-says-what-it-acts-on — the line, apart from the shell Codex adds
|
|
155
|
+
/**
|
|
156
|
+
* The line a Codex command runs: Codex wraps it in a shell
|
|
157
|
+
* (`/bin/zsh -lc '<line>'`, quoted as Codex quotes it), and the line is that
|
|
158
|
+
* shell's one argument, unquoted. Codex's `commandActions` are not it: they
|
|
159
|
+
* keep only the pieces Codex recognizes (`cd sub && cat c.txt` is one read of
|
|
160
|
+
* `cat c.txt`) and normalize their quoting. A command of any other shape is
|
|
161
|
+
* as Codex reports it; one that is not a string, nothing.
|
|
162
|
+
*/
|
|
163
|
+
export function codexCommandLine(command: unknown): string | undefined {
|
|
164
|
+
if (typeof command !== "string" || !command) return undefined;
|
|
165
|
+
const quoted = SHELL_WRAPPER.exec(command)?.[1];
|
|
166
|
+
return (quoted !== undefined && shellWord(quoted)) || command;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** A change's kind (`add`, `delete`, `update`), and where an update moves the file. */
|
|
170
|
+
function changeKind(change: CodexFileChange): { kind?: string; movedTo?: string } {
|
|
171
|
+
if (typeof change.kind === "string") return { kind: change.kind };
|
|
172
|
+
return { kind: change.kind?.type, movedTo: change.kind?.move_path ?? undefined };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* An update's unified diff as hunks: each `@@` header's start line in the
|
|
177
|
+
* new file, and the lines under it. A move's diff ends with Codex's own
|
|
178
|
+
* `Moved to:` trailer, which is no line of the file.
|
|
179
|
+
*/
|
|
180
|
+
function updateHunks(diff: string, movedTo?: string): Array<{ line?: number; lines: string[] }> {
|
|
181
|
+
const trailer = movedTo !== undefined ? `\n\nMoved to: ${movedTo}` : undefined;
|
|
182
|
+
const body = trailer && diff.endsWith(trailer) ? diff.slice(0, -trailer.length) : diff;
|
|
183
|
+
const hunks: Array<{ line?: number; lines: string[] }> = [];
|
|
184
|
+
for (const line of body.replace(/\n$/, "").split("\n")) {
|
|
185
|
+
if (line.startsWith("@@")) {
|
|
186
|
+
const start = /^@@ -\d+(?:,\d+)? \+(\d+)/.exec(line)?.[1];
|
|
187
|
+
hunks.push({ ...(start !== undefined && { line: Number(start) }), lines: [] });
|
|
188
|
+
} else hunks.at(-1)?.lines.push(line);
|
|
189
|
+
}
|
|
190
|
+
return hunks;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* What a file change shows: a `diff` entry per hunk of an update, at the
|
|
195
|
+
* file it leaves (a move's destination); an add's content as `newText`; a
|
|
196
|
+
* delete's as `oldText`, its `newText` empty. Its locations are each hunk's
|
|
197
|
+
* start in the new file, a move's source too, and an add's or a delete's
|
|
198
|
+
* path alone.
|
|
199
|
+
*/
|
|
200
|
+
export function codexChangeView(changes: CodexFileChange[] | undefined): {
|
|
201
|
+
content: ToolResultContent[];
|
|
202
|
+
locations: ToolLocation[];
|
|
203
|
+
} {
|
|
204
|
+
const content: ToolResultContent[] = [];
|
|
205
|
+
const locations: ToolLocation[] = [];
|
|
206
|
+
for (const change of changes ?? []) {
|
|
207
|
+
const { kind, movedTo } = changeKind(change);
|
|
208
|
+
const diff = change.diff ?? "";
|
|
209
|
+
if (kind === "add" || kind === "delete") {
|
|
210
|
+
locations.push({ path: change.path });
|
|
211
|
+
if (change.diff !== undefined)
|
|
212
|
+
content.push(
|
|
213
|
+
kind === "add"
|
|
214
|
+
? { type: "diff", path: change.path, newText: diff }
|
|
215
|
+
: { type: "diff", path: change.path, oldText: diff, newText: "" },
|
|
216
|
+
);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
const path = movedTo ?? change.path;
|
|
220
|
+
if (movedTo) locations.push({ path: change.path });
|
|
221
|
+
const hunks = updateHunks(diff, movedTo);
|
|
222
|
+
if (!hunks.length) locations.push({ path });
|
|
223
|
+
for (const hunk of hunks) {
|
|
224
|
+
locations.push({ path, ...(hunk.line !== undefined && { line: hunk.line }) });
|
|
225
|
+
const entry = hunkDiff(path, hunk.lines);
|
|
226
|
+
if (entry) content.push(entry);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return { content, locations };
|
|
72
230
|
}
|
|
73
231
|
|
|
74
232
|
const CODEX_TOOL_ITEMS: Record<string, CodexToolDescriptor> = {
|
|
@@ -96,13 +254,17 @@ const CODEX_TOOL_ITEMS: Record<string, CodexToolDescriptor> = {
|
|
|
96
254
|
commandExecution: {
|
|
97
255
|
toolName: () => "shell",
|
|
98
256
|
input: (item) => ({ command: item.command ?? "" }),
|
|
99
|
-
meta: () =>
|
|
257
|
+
meta: (item) => {
|
|
258
|
+
const command = codexCommandLine(item.command);
|
|
259
|
+
return { kind: CODEX_TOOL_KINDS.shell, ...(command && { command }) };
|
|
260
|
+
},
|
|
100
261
|
result: (item) =>
|
|
101
262
|
item.status === "declined"
|
|
102
263
|
? { output: CODEX_COMMAND_DECLINED, isError: true }
|
|
103
264
|
: {
|
|
104
265
|
output: item.aggregatedOutput ?? "",
|
|
105
266
|
isError: failed(item) || (item.exitCode ?? 0) !== 0,
|
|
267
|
+
...(typeof item.exitCode === "number" && { metadata: { exitCode: item.exitCode } }),
|
|
106
268
|
},
|
|
107
269
|
},
|
|
108
270
|
fileChange: {
|
|
@@ -110,28 +272,54 @@ const CODEX_TOOL_ITEMS: Record<string, CodexToolDescriptor> = {
|
|
|
110
272
|
input: (item) => ({ changes: item.changes ?? [] }),
|
|
111
273
|
meta: (item) => ({
|
|
112
274
|
kind: CODEX_TOOL_KINDS.apply_patch,
|
|
113
|
-
locations:
|
|
275
|
+
locations: codexChangeView(item.changes).locations,
|
|
114
276
|
}),
|
|
277
|
+
// A failed or declined change shows no diff: `completeToolPart` keeps none.
|
|
115
278
|
result: (item) =>
|
|
116
279
|
item.status === "declined"
|
|
117
280
|
? { output: CODEX_CHANGE_DECLINED, isError: true }
|
|
118
281
|
: {
|
|
119
282
|
output: (item.changes ?? []).map(describeChange).join("\n"),
|
|
120
283
|
isError: failed(item),
|
|
284
|
+
content: codexChangeView(item.changes).content,
|
|
121
285
|
},
|
|
122
286
|
},
|
|
123
287
|
mcpToolCall: {
|
|
124
288
|
toolName: (item) => `${item.server ?? "mcp"}.${item.tool ?? "tool"}`,
|
|
125
289
|
input: (item) => ({ arguments: item.arguments }),
|
|
126
|
-
meta: () => ({
|
|
290
|
+
meta: (item) => ({
|
|
291
|
+
kind: CODEX_TOOL_KINDS.mcp,
|
|
292
|
+
// Codex names both on the item: never read out of `toolName`.
|
|
293
|
+
...(item.server !== undefined &&
|
|
294
|
+
item.tool !== undefined && { mcp: { server: item.server, tool: item.tool } }),
|
|
295
|
+
}),
|
|
127
296
|
result: (item) => {
|
|
128
297
|
const err = pickCodexError(item.error);
|
|
129
|
-
return {
|
|
130
|
-
|
|
131
|
-
isError: failed(item) || Boolean(err),
|
|
132
|
-
};
|
|
298
|
+
if (err) return { output: err, isError: true };
|
|
299
|
+
return { ...mcpResult(item.result), isError: failed(item) };
|
|
133
300
|
},
|
|
134
301
|
},
|
|
302
|
+
// @ref LLP 0017#codexs-own-pictures-and-an-mcp-tools-picture — a picture Codex makes itself, without its bytes
|
|
303
|
+
imageGeneration: {
|
|
304
|
+
toolName: () => "image_generation",
|
|
305
|
+
// The prompt Codex wrote, when it gives one, comes with the picture.
|
|
306
|
+
input: (item) => (item.revisedPrompt ? { prompt: item.revisedPrompt } : {}),
|
|
307
|
+
inputAtCompletion: true,
|
|
308
|
+
meta: () => ({ kind: CODEX_TOOL_KINDS.image_generation }),
|
|
309
|
+
// Megabytes of base64 stay out of the stream, the journal and every
|
|
310
|
+
// checkpoint: the picture is the file Codex saved.
|
|
311
|
+
result: (item) =>
|
|
312
|
+
item.failure || failed(item)
|
|
313
|
+
? {
|
|
314
|
+
output: `Image generation failed${item.failure?.type ? `: ${item.failure.type}` : ""}`,
|
|
315
|
+
isError: true,
|
|
316
|
+
}
|
|
317
|
+
: {
|
|
318
|
+
output: "Generated an image.",
|
|
319
|
+
...(item.savedPath && { metadata: { savedPath: item.savedPath } }),
|
|
320
|
+
isError: false,
|
|
321
|
+
},
|
|
322
|
+
},
|
|
135
323
|
webSearch: {
|
|
136
324
|
toolName: () => "web_search",
|
|
137
325
|
input: (item) => ({ query: item.query ?? "" }),
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { statSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
1
3
|
import type { AuthMethod } from "../../../protocol/index.ts";
|
|
2
4
|
import { onAbort } from "../../utils/deadline.ts";
|
|
3
5
|
import { InvalidRequestError } from "../../utils/errors.ts";
|
|
@@ -11,6 +13,7 @@ import {
|
|
|
11
13
|
terminalMethod,
|
|
12
14
|
} from "../login.ts";
|
|
13
15
|
import type { CodexConnection } from "./client.ts";
|
|
16
|
+
import { codexHome } from "./homes.ts";
|
|
14
17
|
|
|
15
18
|
/** The logins Codex's app-server runs itself, each with its `account/login/start` type. */
|
|
16
19
|
const LOGINS: readonly (AuthMethod & { type: string })[] = [
|
|
@@ -31,7 +34,7 @@ const LOGINS: readonly (AuthMethod & { type: string })[] = [
|
|
|
31
34
|
},
|
|
32
35
|
];
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
interface CodexCliLoginOptions {
|
|
35
38
|
/**
|
|
36
39
|
* A new app-server, not yet initialized, for a turn's `env`: its
|
|
37
40
|
* `CODEX_HOME` is the store a login lands in.
|
|
@@ -78,10 +81,49 @@ export function codexLoginStatus(read: CodexAccountRead): LoginStatus {
|
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
|
|
84
|
+
/** The variable that picks Codex's login store, its home. */
|
|
85
|
+
const STORE_VARIABLE = "CODEX_HOME";
|
|
86
|
+
|
|
87
|
+
/** The login store a turn or a login with this `env` uses: its `CODEX_HOME`, empty when unset. */
|
|
88
|
+
export function codexLoginStore(env: Record<string, string> | undefined): string {
|
|
89
|
+
return env?.[STORE_VARIABLE] ?? "";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// @ref LLP 0011#a-login-change-starts-the-next-turn-on-a-new-cli — the engine reads no login: it sees the file change
|
|
93
|
+
/**
|
|
94
|
+
* What the login file of the store a turn with this `env` runs on looks
|
|
95
|
+
* like (`<CODEX_HOME>/auth.json`, the turn's, else the process's, else
|
|
96
|
+
* `~/.codex`'s; Codex's default `file` store): its device, inode, size and
|
|
97
|
+
* modified and changed times at full precision, or `absent`. Codex writes
|
|
98
|
+
* the file in place on any login change, a token renewal and a rewrite of
|
|
99
|
+
* the same key, and removes it at a sign-out, so a running app-server, which
|
|
100
|
+
* keeps the login it started with, is stale once this differs. A link is
|
|
101
|
+
* followed to its target (a product may link the person's own `auth.json`
|
|
102
|
+
* into a session's home). The file is never opened.
|
|
103
|
+
*/
|
|
104
|
+
export function codexLoginMark(env: Record<string, string> | undefined): string {
|
|
105
|
+
try {
|
|
106
|
+
const file = statSync(join(codexHome(env), "auth.json"), {
|
|
107
|
+
bigint: true,
|
|
108
|
+
throwIfNoEntry: false,
|
|
109
|
+
});
|
|
110
|
+
if (!file) return "absent";
|
|
111
|
+
return `${file.dev}:${file.ino}:${file.size}:${file.mtimeNs}:${file.ctimeNs}`;
|
|
112
|
+
} catch (error) {
|
|
113
|
+
// A folder it may not enter, or under Bun a file on the way (ENOTDIR;
|
|
114
|
+
// Node's stat reads that as absent).
|
|
115
|
+
return `unreadable:${(error as NodeJS.ErrnoException).code ?? "unknown"}`;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
81
119
|
/** Codex's login, through its app-server: `account/read`, `account/login/start`, `account/logout`. */
|
|
82
120
|
export class CodexCliLogin implements CliLogin {
|
|
83
121
|
constructor(private readonly options: CodexCliLoginOptions) {}
|
|
84
122
|
|
|
123
|
+
store(env: Record<string, string> | undefined): string {
|
|
124
|
+
return codexLoginStore(env);
|
|
125
|
+
}
|
|
126
|
+
|
|
85
127
|
/** Initialize a new app-server, run `use` on it, and end it. */
|
|
86
128
|
private async with<T>(
|
|
87
129
|
options: LoginOptions,
|
|
@@ -105,7 +147,7 @@ export class CodexCliLogin implements CliLogin {
|
|
|
105
147
|
terminalMethod(
|
|
106
148
|
[await this.options.cliPath(), "login"],
|
|
107
149
|
{ ...process.env, ...options.env },
|
|
108
|
-
|
|
150
|
+
STORE_VARIABLE,
|
|
109
151
|
),
|
|
110
152
|
];
|
|
111
153
|
}
|
|
@@ -14,7 +14,7 @@ import type { CodexHomes } from "./homes.ts";
|
|
|
14
14
|
import type { CodexNotification } from "./protocol.ts";
|
|
15
15
|
|
|
16
16
|
/** Codex supports stdio and Streamable HTTP, not the legacy SSE transport. */
|
|
17
|
-
|
|
17
|
+
function codexMcpServers(servers: Record<string, McpServerConfig>): Record<string, unknown> {
|
|
18
18
|
return Object.fromEntries(
|
|
19
19
|
Object.entries(servers).map(([name, server]) => {
|
|
20
20
|
if (name === "codex_apps") throw new Error("MCP server name codex_apps is reserved by Codex");
|
|
@@ -36,7 +36,7 @@ export function codexMcpServers(servers: Record<string, McpServerConfig>): Recor
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/** Only call against an explicitly isolated, engine-managed CODEX_HOME. */
|
|
39
|
-
|
|
39
|
+
async function writeCodexMcpServers(
|
|
40
40
|
client: Pick<CodexConnection, "request">,
|
|
41
41
|
servers: Record<string, unknown>,
|
|
42
42
|
): Promise<void> {
|
|
@@ -69,7 +69,7 @@ function normalizedConfig(value: unknown): unknown {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/** User-layer write acknowledgements do not account for repository overrides. */
|
|
72
|
-
|
|
72
|
+
async function assertCodexMcpConfig(
|
|
73
73
|
client: Pick<CodexConnection, "request">,
|
|
74
74
|
cwd: string,
|
|
75
75
|
servers: Record<string, unknown>,
|
|
@@ -98,24 +98,18 @@ function mergedOver(base: unknown, over: unknown): unknown {
|
|
|
98
98
|
|
|
99
99
|
// @ref LLP 0001#d21--a-codex-turn-that-names-no-home-carries-its-mcp-servers-in-its-thread — a name Codex's own configuration has
|
|
100
100
|
/**
|
|
101
|
-
* Refuse a turn's server that Codex's own configuration would
|
|
102
|
-
* server in a thread's config is the top layer of Codex's, merged
|
|
103
|
-
* table over one of the same name in the user's or the
|
|
104
|
-
* turn's values win, and whatever else the other sets
|
|
105
|
-
* and environment sent to the turn's server, its tool
|
|
106
|
-
* false`). One that sets nothing more is the turn's
|
|
107
|
-
*
|
|
101
|
+
* Refuse a turn's server that Codex's own configuration (`native`) would
|
|
102
|
+
* change. A server in a thread's config is the top layer of Codex's, merged
|
|
103
|
+
* table by table over one of the same name in the user's or the
|
|
104
|
+
* repository's: the turn's values win, and whatever else the other sets
|
|
105
|
+
* stays (its headers and environment sent to the turn's server, its tool
|
|
106
|
+
* filter, `enabled = false`). One that sets nothing more is the turn's
|
|
107
|
+
* server whole, and goes on.
|
|
108
108
|
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
cwd: string,
|
|
109
|
+
function assertCodexThreadMcp(
|
|
110
|
+
native: Record<string, unknown>,
|
|
112
111
|
servers: Record<string, unknown>,
|
|
113
|
-
):
|
|
114
|
-
if (!Object.keys(servers).length) return;
|
|
115
|
-
const result = (await client.request("config/read", { cwd })) as {
|
|
116
|
-
config?: { mcp_servers?: Record<string, unknown> };
|
|
117
|
-
};
|
|
118
|
-
const native = result.config?.mcp_servers ?? {};
|
|
112
|
+
): void {
|
|
119
113
|
const changed = Object.entries(servers).flatMap(([name, server]) =>
|
|
120
114
|
native[name] !== undefined &&
|
|
121
115
|
configFingerprint(normalizedConfig(mergedOver(native[name], server))) !==
|
|
@@ -158,7 +152,7 @@ const MCP_STARTUP_MS = 30_000;
|
|
|
158
152
|
* without. `servers` is the turn's wire configuration, by name, and `causes`
|
|
159
153
|
* why each server last failed, as Codex said.
|
|
160
154
|
*/
|
|
161
|
-
|
|
155
|
+
async function settleCodexMcp(
|
|
162
156
|
client: CodexConnection,
|
|
163
157
|
threadId: string,
|
|
164
158
|
servers: Readonly<Record<string, McpServerConfig>>,
|
|
@@ -194,7 +188,7 @@ export async function settleCodexMcp(
|
|
|
194
188
|
const statuses: Array<{ name: string; status: string | null; error?: string }> = [];
|
|
195
189
|
// Asked by name, Codex answers from the thread's own connection.
|
|
196
190
|
// Asked for every server, it connects to each again (initialize,
|
|
197
|
-
// tools/list) on every turn (0.160,
|
|
191
|
+
// tools/list) on every turn (observed on Codex 0.160, 2026-10-28).
|
|
198
192
|
for (const serverName of names) {
|
|
199
193
|
for await (const page of pages<{ name: string; runtimeStatus: string | null }>(
|
|
200
194
|
client,
|
|
@@ -262,9 +256,13 @@ export function codexTurnMcp(options: AgentExecuteOptions, homes: CodexHomes): C
|
|
|
262
256
|
return Object.keys(servers).length ? { wire, thread: servers } : { wire };
|
|
263
257
|
}
|
|
264
258
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
259
|
+
// @ref LLP 0001#d21--a-codex-turn-that-names-no-home-carries-its-mcp-servers-in-its-thread — a thread's config is fixed once it is open
|
|
260
|
+
/**
|
|
261
|
+
* Which `mcp_servers` table a thread was opened with (`threadServers`): a
|
|
262
|
+
* turn that needs another runs on the thread opened again in a new process.
|
|
263
|
+
*/
|
|
264
|
+
export function threadServersFingerprint(table: Record<string, unknown> | undefined): string {
|
|
265
|
+
return configFingerprint(table ?? {});
|
|
268
266
|
}
|
|
269
267
|
|
|
270
268
|
/**
|
|
@@ -304,13 +302,11 @@ export class CodexMcpState {
|
|
|
304
302
|
}
|
|
305
303
|
|
|
306
304
|
/**
|
|
307
|
-
* Before the thread opens, and before each turn
|
|
305
|
+
* Before the thread opens, and before each turn: servers for the home the
|
|
308
306
|
* turn names are written there, checked as Codex took them, and reloaded
|
|
309
|
-
* when they changed
|
|
310
|
-
* Codex's own configuration.
|
|
307
|
+
* when they changed.
|
|
311
308
|
*/
|
|
312
|
-
async configure({ servers
|
|
313
|
-
if (thread) return assertCodexThreadMcp(this.client, this.cwd, thread);
|
|
309
|
+
async configure({ servers }: CodexTurnMcp): Promise<void> {
|
|
314
310
|
if (servers === undefined) return;
|
|
315
311
|
const fingerprint = configFingerprint(servers);
|
|
316
312
|
const changed = this.fingerprint !== fingerprint;
|
|
@@ -322,6 +318,26 @@ export class CodexMcpState {
|
|
|
322
318
|
this.fingerprint = fingerprint;
|
|
323
319
|
}
|
|
324
320
|
|
|
321
|
+
// @ref LLP 0001#d21--a-codex-turn-that-names-no-home-carries-its-mcp-servers-in-its-thread — checked against Codex's own
|
|
322
|
+
/**
|
|
323
|
+
* The `mcp_servers` table the thread carries, for a turn that names no
|
|
324
|
+
* home: the turn's servers, checked against Codex's own configuration.
|
|
325
|
+
* Read before the thread opens, so no connection is made first, and
|
|
326
|
+
* before each turn.
|
|
327
|
+
*/
|
|
328
|
+
async threadServers({
|
|
329
|
+
servers,
|
|
330
|
+
thread,
|
|
331
|
+
}: CodexTurnMcp): Promise<Record<string, unknown> | undefined> {
|
|
332
|
+
// A home the turn names holds the turn's servers, written there.
|
|
333
|
+
if (servers !== undefined || !thread) return undefined;
|
|
334
|
+
const result = (await this.client.request("config/read", { cwd: this.cwd })) as {
|
|
335
|
+
config?: { mcp_servers?: Record<string, unknown> };
|
|
336
|
+
};
|
|
337
|
+
assertCodexThreadMcp(result.config?.mcp_servers ?? {}, thread);
|
|
338
|
+
return thread;
|
|
339
|
+
}
|
|
340
|
+
|
|
325
341
|
/**
|
|
326
342
|
* Get the thread's servers ready for a turn: configured, started, and the
|
|
327
343
|
* ones it goes on without said through `onWarning`. A required server that
|
|
@@ -338,7 +354,7 @@ export class CodexMcpState {
|
|
|
338
354
|
// not decide. So is every server after a turn whose servers did not settle.
|
|
339
355
|
const again = this.unavailable.retryNow(mcp.wire).length > 0 || this.unsettled;
|
|
340
356
|
const started = mcp.thread
|
|
341
|
-
? await this.startThreadServers(
|
|
357
|
+
? await this.startThreadServers(again)
|
|
342
358
|
: await this.startHomeServers(mcp, again);
|
|
343
359
|
let unavailable: Record<string, string>;
|
|
344
360
|
try {
|
|
@@ -374,8 +390,7 @@ export class CodexMcpState {
|
|
|
374
390
|
* not running `again` and leaves the others connected. Whether this turn
|
|
375
391
|
* started them.
|
|
376
392
|
*/
|
|
377
|
-
private async startThreadServers(
|
|
378
|
-
await this.configure(mcp);
|
|
393
|
+
private async startThreadServers(again: boolean): Promise<boolean> {
|
|
379
394
|
const reloading = this.prepared && again;
|
|
380
395
|
if (reloading) await this.client.request("config/mcpServer/reload", undefined);
|
|
381
396
|
const started = reloading || !this.prepared;
|
|
@@ -10,7 +10,7 @@ const MODEL_LIST_TIMEOUT_MS = 5_000;
|
|
|
10
10
|
const MODEL_LIST_PAGES = 10;
|
|
11
11
|
|
|
12
12
|
/** One `model/list` entry, as far as agent-server reads it. */
|
|
13
|
-
|
|
13
|
+
type CodexModel = Record<string, unknown>;
|
|
14
14
|
|
|
15
15
|
/** A model's thinking levels, and the native effort that `off` means for it. */
|
|
16
16
|
export interface CodexModelThinking {
|
|
@@ -37,9 +37,7 @@ function efforts(model: CodexModel): unknown[] {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/** Every page of `model/list`, hidden models included. Throws when the CLI cannot answer. */
|
|
40
|
-
|
|
41
|
-
client: Pick<CodexConnection, "request">,
|
|
42
|
-
): Promise<CodexModel[]> {
|
|
40
|
+
async function readCodexModels(client: Pick<CodexConnection, "request">): Promise<CodexModel[]> {
|
|
43
41
|
const models: CodexModel[] = [];
|
|
44
42
|
for await (const page of pages<CodexModel>(
|
|
45
43
|
client,
|
|
@@ -54,9 +52,11 @@ export async function readCodexModels(
|
|
|
54
52
|
/**
|
|
55
53
|
* What each model accepts, by its `model` and `id`. Codex's `none` or
|
|
56
54
|
* `minimal` is `off`, remembered so `off` sends the value the model
|
|
57
|
-
* advertised (`none` when it offers both).
|
|
55
|
+
* advertised (`none` when it offers both). A model that lists no efforts at
|
|
56
|
+
* all has none (`levels: []`); one that lists only efforts this build does not
|
|
57
|
+
* know, or says nothing, is left out, so what it accepts stays unknown.
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
function codexModelThinking(models: readonly CodexModel[]): Map<string, CodexModelThinking> {
|
|
60
60
|
const thinking = new Map<string, CodexModelThinking>();
|
|
61
61
|
for (const model of models) {
|
|
62
62
|
const native = efforts(model);
|
|
@@ -66,7 +66,8 @@ export function codexModelThinking(models: readonly CodexModel[]): Map<string, C
|
|
|
66
66
|
? "minimal"
|
|
67
67
|
: undefined;
|
|
68
68
|
const levels = knownThinkingLevels(native.map(codexThinkingLevel));
|
|
69
|
-
|
|
69
|
+
const none = Array.isArray(model.supportedReasoningEfforts) && native.length === 0;
|
|
70
|
+
if (!levels.length && !none) continue;
|
|
70
71
|
const defaultEffort =
|
|
71
72
|
typeof model.defaultReasoningEffort === "string" ? model.defaultReasoningEffort : undefined;
|
|
72
73
|
for (const name of [model.model, model.id])
|
|
@@ -180,7 +181,7 @@ export function codexModelDescriptors(
|
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
/** What one `codex app-server` says about its models. */
|
|
183
|
-
|
|
184
|
+
interface CodexModelListing {
|
|
184
185
|
models: CodexModel[];
|
|
185
186
|
/**
|
|
186
187
|
* The model a new thread in the listing's folder runs when the turn names
|