@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
|
@@ -11,13 +11,22 @@ import type {
|
|
|
11
11
|
import { AsyncQueue, generateUUIDv7 } from "../../../protocol/index.ts";
|
|
12
12
|
import type { McpServerConfig, PermissionMode } from "../../../protocol/index.ts";
|
|
13
13
|
import type { NativeProcess } from "../../processes/native-processes.ts";
|
|
14
|
-
import { withTimeout } from "../../utils/deadline.ts";
|
|
14
|
+
import { onAbort, untilAborted, withTimeout } from "../../utils/deadline.ts";
|
|
15
15
|
import { SessionResumeError } from "../../utils/errors.ts";
|
|
16
|
-
import {
|
|
16
|
+
import { CANCEL_CONFIRM_MS } from "../base.ts";
|
|
17
|
+
import {
|
|
18
|
+
IDLE_TIMEOUT_MS,
|
|
19
|
+
type PooledClient,
|
|
20
|
+
type PooledProcess,
|
|
21
|
+
type ProcessEndReason,
|
|
22
|
+
ProcessPool,
|
|
23
|
+
} from "../process-pool.ts";
|
|
17
24
|
import { createCanUseTool, createOnElicitation, startQuery } from "./approvals.ts";
|
|
18
25
|
import { commandStarted } from "./events.ts";
|
|
26
|
+
import { claudeLoginStore } from "./login.ts";
|
|
19
27
|
import { ClaudeMcpConnections } from "./mcp.ts";
|
|
20
28
|
import {
|
|
29
|
+
type ClaudeCodeAgentOptions,
|
|
21
30
|
type ClaudeSessionConfig,
|
|
22
31
|
type ClaudeSessionEndReason,
|
|
23
32
|
type ClaudeSessionSettings,
|
|
@@ -27,6 +36,7 @@ import {
|
|
|
27
36
|
toSdkPermissionMode,
|
|
28
37
|
} from "./options.ts";
|
|
29
38
|
import { planUsedUp } from "./outcome.ts";
|
|
39
|
+
import { notePairedReleases } from "./sdk-pair.ts";
|
|
30
40
|
import { withStderr } from "./spawn.ts";
|
|
31
41
|
import { ClaudeSpend } from "./spend.ts";
|
|
32
42
|
import { ClaudeTurn, type ClaudeTurnStart } from "./turn.ts";
|
|
@@ -34,9 +44,6 @@ import { ClaudeTurn, type ClaudeTurnStart } from "./turn.ts";
|
|
|
34
44
|
type SessionState = "starting" | "idle" | "busy" | "terminated";
|
|
35
45
|
type ClaudeContent = SDKUserMessage["message"]["content"];
|
|
36
46
|
|
|
37
|
-
/** How long Claude has to confirm an interrupt before the turn counts as still running. */
|
|
38
|
-
export const INTERRUPT_TIMEOUT_MS = 2_000;
|
|
39
|
-
|
|
40
47
|
/** Claude repeats a message it was sent, where it reads it (`--replay-user-messages`). */
|
|
41
48
|
function isReplay(event: SDKMessage): event is Extract<SDKMessage, { isReplay: true }> {
|
|
42
49
|
return event.type === "user" && "isReplay" in event && event.isReplay === true;
|
|
@@ -47,6 +54,20 @@ function consumed(event: SDKMessage): readonly string[] {
|
|
|
47
54
|
return ("user_message_uuids" in event && event.user_message_uuids) || [];
|
|
48
55
|
}
|
|
49
56
|
|
|
57
|
+
/** Why the pool ended a session, in the reasons `onSessionEnd` has always given. */
|
|
58
|
+
function endReason(reason: ProcessEndReason | undefined): ClaudeSessionEndReason {
|
|
59
|
+
if (reason === "idle" || reason === "shutdown") return reason;
|
|
60
|
+
return reason?.startsWith("replaced:") ? "replaced" : "released";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** What a session asks of the pool that holds it. */
|
|
64
|
+
interface ClaudeSessionPooling {
|
|
65
|
+
/** A host resume came since its process began to start (`startedBeforeResume`). */
|
|
66
|
+
hostResumed(): boolean;
|
|
67
|
+
/** Claude answered a query of its own between turns: the idle wait starts again. */
|
|
68
|
+
betweenTurns(): void;
|
|
69
|
+
}
|
|
70
|
+
|
|
50
71
|
/**
|
|
51
72
|
* Wraps one long-lived Claude `query()` call. The prompt input is an AsyncQueue
|
|
52
73
|
* that stays open across turns, so the same subprocess (and its context) is
|
|
@@ -54,9 +75,11 @@ function consumed(event: SDKMessage): readonly string[] {
|
|
|
54
75
|
* of the session (`observe`) and hands it to the running turn (`route`); the
|
|
55
76
|
* `result` answering the turn ends it.
|
|
56
77
|
*
|
|
57
|
-
* Lifecycle: starting → idle ⇄ busy → terminated.
|
|
78
|
+
* Lifecycle: starting → idle ⇄ busy → terminated. To the process pool it is
|
|
79
|
+
* both the process and its client: `closed` once its end began, from any
|
|
80
|
+
* state; `close` ends it whatever it is doing, a running turn with it.
|
|
58
81
|
*/
|
|
59
|
-
export class ClaudeSession {
|
|
82
|
+
export class ClaudeSession implements PooledProcess, PooledClient {
|
|
60
83
|
private state: SessionState = "starting";
|
|
61
84
|
/** What the session runs with; its MCP servers are `mcp`'s. */
|
|
62
85
|
private config: Omit<ClaudeSessionConfig, "mcpServers">;
|
|
@@ -85,25 +108,45 @@ export class ClaudeSession {
|
|
|
85
108
|
* changes, so a turn after a used-up window starts from that report.
|
|
86
109
|
*/
|
|
87
110
|
private readonly planWindows = new Map<string, SDKRateLimitEvent>();
|
|
88
|
-
private idleTimer?: ReturnType<typeof setTimeout>;
|
|
89
111
|
/** The `claude` process the engine started for it; none under an operator's spawner. */
|
|
90
112
|
private native?: NativeProcess;
|
|
91
113
|
/** Its end, once it began: settles when its process is stopped. */
|
|
92
114
|
private ending?: Promise<void>;
|
|
115
|
+
private readonly closeHandlers = new Set<() => void>();
|
|
93
116
|
|
|
94
117
|
constructor(
|
|
95
118
|
readonly id: string,
|
|
96
119
|
config: ClaudeSessionConfig,
|
|
97
120
|
private readonly settings: ClaudeSessionSettings,
|
|
98
121
|
private readonly onTerminated?: (reason: ClaudeSessionEndReason) => void,
|
|
122
|
+
private readonly pooling?: ClaudeSessionPooling,
|
|
99
123
|
) {
|
|
100
124
|
const { mcpServers, ...spawn } = config;
|
|
101
125
|
this.config = spawn;
|
|
102
126
|
this.spawnKey = claudeSpawnKey(config);
|
|
103
|
-
this.mcp = new ClaudeMcpConnections(mcpServers);
|
|
127
|
+
this.mcp = new ClaudeMcpConnections(mcpServers, () => pooling?.hostResumed() ?? false);
|
|
104
128
|
this.spend = config.resumeSessionId ? ClaudeSpend.unknown() : ClaudeSpend.fresh();
|
|
105
129
|
}
|
|
106
130
|
|
|
131
|
+
/** The pool's process is its own client. */
|
|
132
|
+
get client(): this {
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
get closed(): boolean {
|
|
136
|
+
return this.state === "terminated";
|
|
137
|
+
}
|
|
138
|
+
close(reason?: ProcessEndReason): void {
|
|
139
|
+
void this.terminate(endReason(reason));
|
|
140
|
+
}
|
|
141
|
+
onClose(handler: () => void): () => void {
|
|
142
|
+
this.closeHandlers.add(handler);
|
|
143
|
+
return () => this.closeHandlers.delete(handler);
|
|
144
|
+
}
|
|
145
|
+
/** Settles once its process is stopped and its end reported. */
|
|
146
|
+
gone(): Promise<void> {
|
|
147
|
+
return this.ending ?? Promise.resolve();
|
|
148
|
+
}
|
|
149
|
+
|
|
107
150
|
get currentState(): SessionState {
|
|
108
151
|
return this.state;
|
|
109
152
|
}
|
|
@@ -148,9 +191,30 @@ export class ClaudeSession {
|
|
|
148
191
|
);
|
|
149
192
|
}
|
|
150
193
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
194
|
+
// @ref LLP 0013#f13-a-live-change-held-a-claude-turn-a-cancel-could-not-end — a cancel ends the change, and the process
|
|
195
|
+
/**
|
|
196
|
+
* Switch what the live process can switch for the turn: its model, its
|
|
197
|
+
* permission mode, its MCP servers. All else is in its spawn key, so this
|
|
198
|
+
* never asks for a new process. The SDK gives these control requests no
|
|
199
|
+
* deadline: the turn's cancel (`signal`) ends the wait for each, and the
|
|
200
|
+
* process, since what it applied is not known; the session's next turn
|
|
201
|
+
* resumes the conversation on a new one.
|
|
202
|
+
*/
|
|
203
|
+
async applyLiveChange(next: ClaudeSessionConfig, signal: AbortSignal): Promise<boolean> {
|
|
204
|
+
try {
|
|
205
|
+
if (next.model !== this.config.model) await untilAborted(this.setModel(next.model), signal);
|
|
206
|
+
if ((next.permissionMode ?? "default") !== (this.config.permissionMode ?? "default")) {
|
|
207
|
+
await untilAborted(this.setPermissionMode(next.permissionMode), signal);
|
|
208
|
+
}
|
|
209
|
+
// Text-only sessions must stay tool-free when the MCP configuration changes.
|
|
210
|
+
if (!next.disableTools && this.mcp.needsUpdate(next.mcpServers)) {
|
|
211
|
+
await untilAborted(this.setMcpServers(next.mcpServers ?? {}), signal);
|
|
212
|
+
}
|
|
213
|
+
} catch (error) {
|
|
214
|
+
if (signal.aborted) void this.terminate("replaced");
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
return true;
|
|
154
218
|
}
|
|
155
219
|
|
|
156
220
|
async start(): Promise<void> {
|
|
@@ -183,6 +247,7 @@ export class ClaudeSession {
|
|
|
183
247
|
sessionId: this.id,
|
|
184
248
|
policy: this.settings.toolPolicy,
|
|
185
249
|
turn,
|
|
250
|
+
mcpServers: () => this.mcp.names,
|
|
186
251
|
});
|
|
187
252
|
options.onElicitation = createOnElicitation(turn);
|
|
188
253
|
// Release/shutdown may finish while an async options/tool factory is
|
|
@@ -191,6 +256,8 @@ export class ClaudeSession {
|
|
|
191
256
|
this.query = startQuery(options.permissionMode, () =>
|
|
192
257
|
sdk.query({ prompt: this.promptQueue, options }),
|
|
193
258
|
);
|
|
259
|
+
// Right after `query()`, which names the SDK that ran it.
|
|
260
|
+
notePairedReleases(this.config.cliPath, this.settings.onDiagnostic, this.id);
|
|
194
261
|
const events = this.consumeEvents();
|
|
195
262
|
if (!this.config.disableTools && Object.keys(this.mcp.servers).length) {
|
|
196
263
|
try {
|
|
@@ -213,7 +280,6 @@ export class ClaudeSession {
|
|
|
213
280
|
if ((this.state as SessionState) === "terminated")
|
|
214
281
|
throw new Error("Session terminated during startup");
|
|
215
282
|
this.state = "idle";
|
|
216
|
-
this.resetIdleTimer();
|
|
217
283
|
}
|
|
218
284
|
|
|
219
285
|
/**
|
|
@@ -224,14 +290,13 @@ export class ClaudeSession {
|
|
|
224
290
|
sendMessage(content: ClaudeContent, start: ClaudeTurnStart): ClaudeTurn {
|
|
225
291
|
if (this.state === "terminated") throw this.startupError ?? new Error("Session is terminated");
|
|
226
292
|
if (this.state !== "idle") throw new Error(`Claude session is ${this.state}, not idle`);
|
|
227
|
-
//
|
|
293
|
+
// A host resume can land during preparation. Never enqueue a prompt on a
|
|
228
294
|
// process whose network pool predates suspension.
|
|
229
295
|
if (this.mcp.respawnRequired || (!this.config.disableTools && this.mcp.uncertain)) {
|
|
230
296
|
throw new Error(
|
|
231
297
|
"MCP network connections changed during turn preparation; session is not ready",
|
|
232
298
|
);
|
|
233
299
|
}
|
|
234
|
-
this.clearIdleTimer();
|
|
235
300
|
this.state = "busy";
|
|
236
301
|
const prompt = this.userMessage(content);
|
|
237
302
|
const turn = new ClaudeTurn(start, prompt.uuid);
|
|
@@ -279,6 +344,11 @@ export class ClaudeSession {
|
|
|
279
344
|
};
|
|
280
345
|
}
|
|
281
346
|
|
|
347
|
+
/** How long Claude has to confirm an interrupt before the turn counts as still running. */
|
|
348
|
+
private get confirmMs(): number {
|
|
349
|
+
return this.settings.cancelConfirmMs ?? CANCEL_CONFIRM_MS;
|
|
350
|
+
}
|
|
351
|
+
|
|
282
352
|
/**
|
|
283
353
|
* Stop the in-flight turn without killing the session. Returns whether the
|
|
284
354
|
* interrupt was CONFIRMED: true when there was nothing to interrupt or the
|
|
@@ -290,7 +360,7 @@ export class ClaudeSession {
|
|
|
290
360
|
* instead: it has begun no turn, an interrupt would wait out its startup, and
|
|
291
361
|
* a prompt the CLI has not dequeued survives an interrupt and runs anyway.
|
|
292
362
|
*/
|
|
293
|
-
interruptTurn(timeoutMs =
|
|
363
|
+
interruptTurn(timeoutMs = this.confirmMs): Promise<boolean> {
|
|
294
364
|
const turn = this.turn;
|
|
295
365
|
if (!turn) return this.interrupt(undefined, timeoutMs);
|
|
296
366
|
return turn.interruptOnce(() => this.interrupt(turn, timeoutMs));
|
|
@@ -302,12 +372,25 @@ export class ClaudeSession {
|
|
|
302
372
|
* and end the process when the turn has not ended within the interrupt
|
|
303
373
|
* timeout. The session is idle or terminated when this returns.
|
|
304
374
|
*/
|
|
305
|
-
async stopTurn(turn: ClaudeTurn, timeoutMs =
|
|
375
|
+
async stopTurn(turn: ClaudeTurn, timeoutMs = this.confirmMs): Promise<void> {
|
|
306
376
|
if (this.turn !== turn) return;
|
|
307
377
|
await Promise.all([this.interruptTurn(timeoutMs), withTimeout(turn.ended, timeoutMs)]);
|
|
308
378
|
if (this.turn === turn) await this.terminate("replaced");
|
|
309
379
|
}
|
|
310
380
|
|
|
381
|
+
// @ref LLP 0001#d9--the-wire-is-quick-ack-json-rpc-requests-flow-one-way — cancelGraceMs: an agent that has not stopped is ended
|
|
382
|
+
/**
|
|
383
|
+
* End the process of a cancelled `turn` that has not ended within
|
|
384
|
+
* `graceMs`: Claude did not stop it (a frozen or hung CLI), and nothing
|
|
385
|
+
* else would. The turn's events end, so it ends cancelled, and the pool
|
|
386
|
+
* hears `replaced` (`onSessionEnd`); the next turn resumes on a new
|
|
387
|
+
* process. A turn that ended, and any turn after it, is left alone.
|
|
388
|
+
*/
|
|
389
|
+
async endUnstopped(turn: ClaudeTurn, graceMs: number): Promise<void> {
|
|
390
|
+
if ((await withTimeout(turn.ended, graceMs)) === undefined && this.turn === turn)
|
|
391
|
+
await this.terminate("replaced");
|
|
392
|
+
}
|
|
393
|
+
|
|
311
394
|
private async interrupt(turn: ClaudeTurn | undefined, timeoutMs: number): Promise<boolean> {
|
|
312
395
|
if (this.state === "idle" || this.state === "terminated") return true;
|
|
313
396
|
if (this.state === "starting" || !this.cliStarted || !this.query) {
|
|
@@ -363,15 +446,19 @@ export class ClaudeSession {
|
|
|
363
446
|
/**
|
|
364
447
|
* End the session: close its query, and stop its process with its tool
|
|
365
448
|
* sessions and MCP servers. Settles once they are gone (at most the grace);
|
|
366
|
-
* every call shares that end.
|
|
449
|
+
* every call shares that end, and the first one's reason is reported.
|
|
367
450
|
*/
|
|
368
451
|
terminate(reason: ClaudeSessionEndReason = "released"): Promise<void> {
|
|
369
|
-
this.ending
|
|
452
|
+
if (!this.ending) {
|
|
453
|
+
this.ending = this.end(reason);
|
|
454
|
+
// Once `gone()` has its answer: the pool waits on it from its handler.
|
|
455
|
+
for (const handler of this.closeHandlers) handler();
|
|
456
|
+
this.closeHandlers.clear();
|
|
457
|
+
}
|
|
370
458
|
return this.ending;
|
|
371
459
|
}
|
|
372
460
|
|
|
373
461
|
private async end(reason: ClaudeSessionEndReason): Promise<void> {
|
|
374
|
-
this.clearIdleTimer();
|
|
375
462
|
this.state = "terminated";
|
|
376
463
|
const query = this.query;
|
|
377
464
|
this.query = undefined;
|
|
@@ -392,7 +479,7 @@ export class ClaudeSession {
|
|
|
392
479
|
this.onTerminated?.(reason);
|
|
393
480
|
} catch {
|
|
394
481
|
// Observer failures (incl. the host's onSessionEnd) must never make
|
|
395
|
-
// terminate() reject
|
|
482
|
+
// terminate() reject: the pool's idle timer ends it unawaited.
|
|
396
483
|
}
|
|
397
484
|
}
|
|
398
485
|
}
|
|
@@ -421,6 +508,9 @@ export class ClaudeSession {
|
|
|
421
508
|
this.queryBegun = true;
|
|
422
509
|
if (event.session_id) this.nativeSessionId = event.session_id;
|
|
423
510
|
this.cancelsQueued = (event.capabilities ?? []).includes("interrupt_cancel_queued_v1");
|
|
511
|
+
// An older CLI may leave the list out.
|
|
512
|
+
if (Array.isArray(event.mcp_servers))
|
|
513
|
+
this.mcp.sawLoaded(event.mcp_servers.map((server) => server.name));
|
|
424
514
|
}
|
|
425
515
|
// The mode Claude runs in now: approving a plan switches it mid-turn,
|
|
426
516
|
// so the next turn compares against this, not the mode it asked for.
|
|
@@ -487,29 +577,81 @@ export class ClaudeSession {
|
|
|
487
577
|
: new Error(reason);
|
|
488
578
|
}
|
|
489
579
|
this.spend.charge(result);
|
|
490
|
-
if (this.state === "idle") this.
|
|
580
|
+
if (this.state === "idle") this.pooling?.betweenTurns();
|
|
491
581
|
}
|
|
492
582
|
|
|
493
583
|
private endTurn(): void {
|
|
494
584
|
this.turn?.end();
|
|
495
585
|
this.turn = null;
|
|
496
586
|
this.state = "idle";
|
|
497
|
-
this.resetIdleTimer();
|
|
498
587
|
}
|
|
588
|
+
}
|
|
499
589
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
590
|
+
/** What a turn brings to the pool. `spawn` notes on it whether its process is new. */
|
|
591
|
+
export interface ClaudePoolTurn {
|
|
592
|
+
sessionId: string;
|
|
593
|
+
config: ClaudeSessionConfig;
|
|
594
|
+
/** The turn's process was started for it: a resume it asks for is not confirmed yet. */
|
|
595
|
+
spawned?: boolean;
|
|
596
|
+
}
|
|
508
597
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
598
|
+
/** Each logical session's Claude process, on the pool every harness runs on. */
|
|
599
|
+
export type ClaudeSessionPool = ProcessPool<ClaudeSession, ClaudePoolTurn>;
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* An agent's Claude sessions. Claude decides of a warm process only whether
|
|
603
|
+
* its spawn key is the turn's and what it switches live; the pool decides
|
|
604
|
+
* the rest (LLP 0001, D10).
|
|
605
|
+
*/
|
|
606
|
+
export function claudeSessionPool(
|
|
607
|
+
settings: ClaudeSessionSettings & Pick<ClaudeCodeAgentOptions, "onSessionEnd">,
|
|
608
|
+
): ClaudeSessionPool {
|
|
609
|
+
const pool: ClaudeSessionPool = new ProcessPool<ClaudeSession, ClaudePoolTurn>(
|
|
610
|
+
{
|
|
611
|
+
// @ref LLP 0011#a-login-change-starts-the-next-turn-on-a-new-cli — only the store it changed in
|
|
612
|
+
store: ({ config }) => claudeLoginStore(config.env),
|
|
613
|
+
resumeOf: ({ config }) => config.resumeSessionId || undefined,
|
|
614
|
+
// Claude may rekey a conversation it resumed: the id it started on still names it.
|
|
615
|
+
conversationsOf: (session) =>
|
|
616
|
+
[session.currentSessionId, session.currentConfig.resumeSessionId].filter(
|
|
617
|
+
(id): id is string => Boolean(id),
|
|
618
|
+
),
|
|
619
|
+
fits: (session, { config }) => session.spawnKey === claudeSpawnKey(config),
|
|
620
|
+
applyLiveChange: (session, { config }, signal) => session.applyLiveChange(config, signal),
|
|
621
|
+
spawn: async (turn, own, signal, replacing) => {
|
|
622
|
+
const { sessionId, config } = turn;
|
|
623
|
+
const session: ClaudeSession = new ClaudeSession(
|
|
624
|
+
sessionId,
|
|
625
|
+
config,
|
|
626
|
+
settings,
|
|
627
|
+
(reason) => settings.onSessionEnd?.(sessionId, reason),
|
|
628
|
+
{
|
|
629
|
+
hostResumed: () => pool.startedBeforeResume(session),
|
|
630
|
+
betweenTurns: () => pool.touch(sessionId, session),
|
|
631
|
+
},
|
|
632
|
+
);
|
|
633
|
+
// The same native conversation continues in a new process, and so
|
|
634
|
+
// does its running cost: the new process restores the total the old one saved.
|
|
635
|
+
if (replacing?.currentSessionId && replacing.currentSessionId === config.resumeSessionId)
|
|
636
|
+
session.spend.continueFrom(replacing.spend);
|
|
637
|
+
own(session);
|
|
638
|
+
turn.spawned = true;
|
|
639
|
+
// A cancel ends a start under way: it has begun no turn, and an
|
|
640
|
+
// interrupt would wait out its startup.
|
|
641
|
+
const offAbort = onAbort(signal, () => void session.terminate());
|
|
642
|
+
try {
|
|
643
|
+
await session.start();
|
|
644
|
+
return session;
|
|
645
|
+
} catch (error) {
|
|
646
|
+
// Never leave a half-started session: it could serve no turn.
|
|
647
|
+
await session.terminate();
|
|
648
|
+
throw error;
|
|
649
|
+
} finally {
|
|
650
|
+
offAbort();
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
},
|
|
654
|
+
{ idleMs: settings.idleTimeoutMs ?? IDLE_TIMEOUT_MS },
|
|
655
|
+
);
|
|
656
|
+
return pool;
|
|
515
657
|
}
|
|
@@ -6,7 +6,7 @@ import type { TokenUsage } from "../../../protocol/index.ts";
|
|
|
6
6
|
* in `modelUsage`: every call through its query pipeline, sub-agents and
|
|
7
7
|
* compaction included, where a result's `usage` counts only the main loop.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
interface ClaudeUsageTotals {
|
|
10
10
|
input: number;
|
|
11
11
|
output: number;
|
|
12
12
|
cacheRead: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ToolKind, ToolLocation, ToolMeta } from "../../../protocol/index.ts";
|
|
1
|
+
import type { McpTool, ToolKind, ToolLocation, ToolMeta } from "../../../protocol/index.ts";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Maps Claude Code's tool names onto the normalized ToolKind taxonomy and
|
|
@@ -6,32 +6,67 @@ import type { ToolKind, ToolLocation, ToolMeta } from "../../../protocol/index.t
|
|
|
6
6
|
* tools are `other` and produce no locations.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// @ref LLP 0002#a-tool-call-says-what-it-acts-on — every tool the pinned CLI offers has a decided kind
|
|
10
|
+
/**
|
|
11
|
+
* Each Claude tool's kind, decided on what the tool does. A map, not an
|
|
12
|
+
* object: a tool named `constructor` is no object member's kind. The free
|
|
13
|
+
* live check (`claude-tool-kinds.live.test.ts`) fails on a tool the pinned
|
|
14
|
+
* CLI offers that is not here, so a pin bump decides it.
|
|
15
|
+
*/
|
|
16
|
+
export const CLAUDE_TOOL_KINDS: ReadonlyMap<string, ToolKind> = new Map<string, ToolKind>([
|
|
17
|
+
// What the pinned CLI (2.1.288) offers, with the engine's options or a product's.
|
|
11
18
|
["Read", "read"],
|
|
12
|
-
["NotebookRead", "read"],
|
|
13
19
|
["Edit", "edit"],
|
|
14
20
|
["Write", "edit"],
|
|
15
|
-
["MultiEdit", "edit"],
|
|
16
21
|
["NotebookEdit", "edit"],
|
|
17
22
|
["Bash", "execute"],
|
|
18
|
-
|
|
19
|
-
["
|
|
20
|
-
|
|
21
|
-
["
|
|
22
|
-
["LS", "search"],
|
|
23
|
+
// Stops a background shell or sub-agent the agent started.
|
|
24
|
+
["TaskStop", "execute"],
|
|
25
|
+
// Runs a script the agent wrote, which starts sub-agents of its own.
|
|
26
|
+
["Workflow", "execute"],
|
|
23
27
|
["WebFetch", "fetch"],
|
|
24
28
|
["WebSearch", "fetch"],
|
|
29
|
+
// Loads a skill's instructions into the conversation.
|
|
30
|
+
["Skill", "read"],
|
|
31
|
+
// The sub-agent tool: `init` names it `Task`, the model `Agent`. A spawn is `task` by its subagent.
|
|
25
32
|
["Task", "think"],
|
|
26
33
|
["Agent", "think"],
|
|
34
|
+
// The agent's own task list, as `TodoWrite` was.
|
|
35
|
+
["TaskCreate", "think"],
|
|
36
|
+
["TaskGet", "think"],
|
|
37
|
+
["TaskList", "think"],
|
|
38
|
+
["TaskUpdate", "think"],
|
|
27
39
|
["TodoWrite", "think"],
|
|
28
40
|
["ExitPlanMode", "switch_mode"],
|
|
29
41
|
["EnterPlanMode", "switch_mode"],
|
|
42
|
+
// Moves the session into a git worktree and back: no mode, no file of the agent's.
|
|
43
|
+
["EnterWorktree", "other"],
|
|
44
|
+
["ExitWorktree", "other"],
|
|
45
|
+
// A question to the person, through the engine's elicitation.
|
|
46
|
+
["AskUserQuestion", "other"],
|
|
47
|
+
// Talk among agents: which there are, a message to one, the findings sent back.
|
|
48
|
+
["ListAgents", "other"],
|
|
49
|
+
["SendMessage", "other"],
|
|
50
|
+
["ReportFindings", "other"],
|
|
51
|
+
// Prompts the session schedules for later, and the agent's own wake-up.
|
|
52
|
+
["CronCreate", "other"],
|
|
53
|
+
["CronDelete", "other"],
|
|
54
|
+
["CronList", "other"],
|
|
55
|
+
["ScheduleWakeup", "other"],
|
|
56
|
+
// Names the pinned CLI no longer offers: a product may pin an older CLI
|
|
57
|
+
// (`provision.pins`), whose calls keep their kinds.
|
|
58
|
+
["NotebookRead", "read"],
|
|
59
|
+
["MultiEdit", "edit"],
|
|
60
|
+
["BashOutput", "execute"],
|
|
61
|
+
["KillShell", "execute"],
|
|
62
|
+
["Grep", "search"],
|
|
63
|
+
["Glob", "search"],
|
|
64
|
+
["LS", "search"],
|
|
30
65
|
]);
|
|
31
66
|
|
|
32
67
|
const PATH_INPUT_KEYS = ["file_path", "filePath", "path", "notebook_path"] as const;
|
|
33
68
|
|
|
34
|
-
|
|
69
|
+
function toolLocationsFromInput(input: Record<string, unknown>): ToolLocation[] | undefined {
|
|
35
70
|
for (const key of PATH_INPUT_KEYS) {
|
|
36
71
|
const v = input[key];
|
|
37
72
|
if (typeof v === "string" && v) return [{ path: v }];
|
|
@@ -39,9 +74,70 @@ export function toolLocationsFromInput(input: Record<string, unknown>): ToolLoca
|
|
|
39
74
|
return undefined;
|
|
40
75
|
}
|
|
41
76
|
|
|
42
|
-
|
|
77
|
+
const MCP_PREFIX = "mcp__";
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A server's name as Claude Code spells it in a tool name (the pinned CLI
|
|
81
|
+
* 2.1.288, SDK 0.3.288, and 2.1.325 alike):
|
|
82
|
+
* other than letters, digits, `_` and `-` become `_`, and a claude.ai
|
|
83
|
+
* connector's runs of `_` collapse.
|
|
84
|
+
*/
|
|
85
|
+
function spelledInToolName(server: string): string {
|
|
86
|
+
const spelled = server.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
87
|
+
return server.startsWith("claude.ai ")
|
|
88
|
+
? spelled.replace(/_+/g, "_").replace(/^_|_$/g, "")
|
|
89
|
+
: spelled;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The server and tool of a Claude MCP tool name, `mcp__<server>__<tool>`. A
|
|
94
|
+
* server's name may hold `__` itself, so the longest name the session
|
|
95
|
+
* attached that fits wins; with none, the name splits at its first `__`.
|
|
96
|
+
* Undefined for a name that is no MCP tool.
|
|
97
|
+
*/
|
|
98
|
+
export function claudeMcpTool(
|
|
99
|
+
toolName: string,
|
|
100
|
+
servers: Iterable<string> = [],
|
|
101
|
+
): McpTool | undefined {
|
|
102
|
+
if (!toolName.startsWith(MCP_PREFIX)) return undefined;
|
|
103
|
+
const rest = toolName.slice(MCP_PREFIX.length);
|
|
104
|
+
let known: { server: string; spelled: string } | undefined;
|
|
105
|
+
for (const server of servers) {
|
|
106
|
+
const spelled = spelledInToolName(server);
|
|
107
|
+
const fits = rest.startsWith(`${spelled}__`) && rest.length > spelled.length + 2;
|
|
108
|
+
if (fits && (!known || spelled.length > known.spelled.length)) known = { server, spelled };
|
|
109
|
+
}
|
|
110
|
+
if (known) return { server: known.server, tool: rest.slice(known.spelled.length + 2) };
|
|
111
|
+
const split = rest.indexOf("__");
|
|
112
|
+
if (split <= 0 || split + 2 >= rest.length) return undefined;
|
|
113
|
+
return { server: rest.slice(0, split), tool: rest.slice(split + 2) };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** `input[key]` when it is a string with something in it. */
|
|
117
|
+
function textOf(input: Record<string, unknown> | undefined, key: string): string | undefined {
|
|
118
|
+
const value = input?.[key];
|
|
119
|
+
return typeof value === "string" && value ? value : undefined;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// @ref LLP 0002#a-tool-call-says-what-it-acts-on — Claude's own keys, read once here
|
|
123
|
+
/**
|
|
124
|
+
* A Claude tool's kind and touched files, a `Bash` call's command and a
|
|
125
|
+
* `WebFetch` call's address; for an MCP tool, its server and tool among
|
|
126
|
+
* `servers`.
|
|
127
|
+
*/
|
|
128
|
+
export function claudeToolMeta(
|
|
129
|
+
toolName: string,
|
|
130
|
+
input?: Record<string, unknown>,
|
|
131
|
+
servers?: Iterable<string>,
|
|
132
|
+
): ToolMeta {
|
|
133
|
+
const mcp = claudeMcpTool(toolName, servers);
|
|
134
|
+
const command = toolName === "Bash" ? textOf(input, "command") : undefined;
|
|
135
|
+
const url = toolName === "WebFetch" ? textOf(input, "url") : undefined;
|
|
43
136
|
return {
|
|
44
137
|
kind: CLAUDE_TOOL_KINDS.get(toolName) ?? "other",
|
|
138
|
+
...(mcp && { mcp }),
|
|
139
|
+
...(command && { command }),
|
|
140
|
+
...(url && { url }),
|
|
45
141
|
...(input ? { locations: toolLocationsFromInput(input) } : {}),
|
|
46
142
|
};
|
|
47
143
|
}
|
|
@@ -60,12 +60,27 @@ function codexError(value: unknown): { message?: string; codexErrorInfo?: unknow
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Which attempt a Codex retry is, of how many. Codex 0.160 sends the count
|
|
65
|
+
* only in its text ("Reconnecting... 2/5"), with no field for it and no
|
|
66
|
+
* wait: a text of any other shape, or a count past its total, gives none.
|
|
67
|
+
*/
|
|
68
|
+
// @ref LLP 0002#plan-usage-and-retries — a field the harness did not say is left out
|
|
69
|
+
function codexRetryCount(message: string): { attempt?: number; maxAttempts?: number } {
|
|
70
|
+
const match = /^Reconnecting\.\.\. (\d{1,3})\/(\d{1,3})$/.exec(message);
|
|
71
|
+
if (!match) return {};
|
|
72
|
+
const attempt = Number(match[1]);
|
|
73
|
+
const maxAttempts = Number(match[2]);
|
|
74
|
+
if (attempt < 1 || attempt > maxAttempts) return {};
|
|
75
|
+
return { attempt, maxAttempts };
|
|
76
|
+
}
|
|
77
|
+
|
|
63
78
|
/**
|
|
64
79
|
* Parses `codex app-server` v2 notifications into AdapterEvents. This harness
|
|
65
80
|
* streams token-level deltas (item/agentMessage/delta, item/reasoning/*Delta),
|
|
66
81
|
* so no diffing is needed. Items carry camelCase fields. Tool-like items
|
|
67
|
-
* (commandExecution/fileChange/mcpToolCall/webSearch) become
|
|
68
|
-
* complete on item/completed.
|
|
82
|
+
* (commandExecution/fileChange/mcpToolCall/webSearch/imageGeneration) become
|
|
83
|
+
* tool parts that complete on item/completed.
|
|
69
84
|
*/
|
|
70
85
|
export class CodexAppServerTransformer implements EventTransformer<unknown> {
|
|
71
86
|
private readonly ctx: StreamContext;
|
|
@@ -166,13 +181,14 @@ export class CodexAppServerTransformer implements EventTransformer<unknown> {
|
|
|
166
181
|
case "account/rateLimits/updated":
|
|
167
182
|
return codexLimits(params.rateLimits);
|
|
168
183
|
case "turn/completed": {
|
|
169
|
-
//
|
|
170
|
-
// the agent
|
|
184
|
+
// A failed turn's `error` that Codex will not retry comes before this,
|
|
185
|
+
// some time before on 0.160, and the agent holds the turn open until
|
|
186
|
+
// this comes: what that error said stays the turn's.
|
|
171
187
|
const turn = codexTurn(n);
|
|
172
|
-
if (turn?.error) {
|
|
188
|
+
if (!this.error && turn?.error) {
|
|
173
189
|
this.error = turn.error.message ?? "codex turn error";
|
|
174
190
|
this.errorCategory = codexErrorCategory(turn.error.codexErrorInfo);
|
|
175
|
-
} else if (turn?.status === "failed") {
|
|
191
|
+
} else if (!this.error && turn?.status === "failed") {
|
|
176
192
|
this.error = "Codex ended the turn as failed without saying why";
|
|
177
193
|
}
|
|
178
194
|
// @ref LLP 0001#d4--permission-requests-are-first-class-protocol — a cancelled answer stops the turn
|
|
@@ -185,15 +201,22 @@ export class CodexAppServerTransformer implements EventTransformer<unknown> {
|
|
|
185
201
|
}
|
|
186
202
|
case "error": {
|
|
187
203
|
// v2 errors carry a nested TurnError and may be transient. A retrying
|
|
188
|
-
// one tells the user why the turn is waiting;
|
|
189
|
-
//
|
|
204
|
+
// one tells the user why the turn is waiting; one Codex will not
|
|
205
|
+
// retry says why its turn failed, and its turn/completed follows.
|
|
190
206
|
const error = codexError(params.error);
|
|
191
207
|
const message =
|
|
192
208
|
error?.message ??
|
|
193
209
|
(typeof params.message === "string" ? params.message : "codex app-server error");
|
|
194
210
|
const category = codexErrorCategory(error?.codexErrorInfo);
|
|
195
211
|
if (params.willRetry) {
|
|
196
|
-
return [
|
|
212
|
+
return [
|
|
213
|
+
{
|
|
214
|
+
kind: "retry",
|
|
215
|
+
category: category ?? classifyError(message),
|
|
216
|
+
message,
|
|
217
|
+
...codexRetryCount(message),
|
|
218
|
+
},
|
|
219
|
+
];
|
|
197
220
|
}
|
|
198
221
|
this.error = message;
|
|
199
222
|
this.errorCategory = category;
|
|
@@ -227,9 +250,9 @@ export class CodexAppServerTransformer implements EventTransformer<unknown> {
|
|
|
227
250
|
return [{ kind: "part-open", part }];
|
|
228
251
|
}
|
|
229
252
|
default: {
|
|
230
|
-
// commandExecution / fileChange / mcpToolCall / webSearch
|
|
231
|
-
// descriptor vocabulary; userMessage and
|
|
232
|
-
// no assistant output.
|
|
253
|
+
// commandExecution / fileChange / mcpToolCall / webSearch /
|
|
254
|
+
// imageGeneration share one descriptor vocabulary; userMessage and
|
|
255
|
+
// unknown item types produce no assistant output.
|
|
233
256
|
const d = codexToolDescriptor(item.type);
|
|
234
257
|
return d ? [{ kind: "part-open", part: this.openTool(item, d) }] : [];
|
|
235
258
|
}
|
|
@@ -271,6 +294,8 @@ export class CodexAppServerTransformer implements EventTransformer<unknown> {
|
|
|
271
294
|
const d = codexToolDescriptor(item.type);
|
|
272
295
|
if (!d) return [];
|
|
273
296
|
const tool = this.tools.get(item.id) ?? this.openTool(item, d);
|
|
297
|
+
if (d.inputAtCompletion && tool.state.status === "in_progress")
|
|
298
|
+
tool.state = { ...tool.state, input: d.input(item) };
|
|
274
299
|
setToolMeta(tool, d.meta(item));
|
|
275
300
|
completeToolPart(tool, d.result(item));
|
|
276
301
|
return [{ kind: "part-update", part: tool }];
|