@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
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AccountInfoSchema } from "./account.js";
|
|
3
|
+
import { AgentHarnessSchema, HarnessIdSchema } from "./harness.js";
|
|
4
|
+
import { openVocabulary } from "./vocabulary.js";
|
|
5
|
+
/**
|
|
6
|
+
* Whether a harness's turns can authenticate:
|
|
7
|
+
* - `signed_in` — they run with `credential`;
|
|
8
|
+
* - `signed_out` — they would fail: log in with one of `methods`, or give
|
|
9
|
+
* each turn an `apiKey`;
|
|
10
|
+
* - `unknown` — the CLI could not say, `error` says why.
|
|
11
|
+
* OPEN: treat a state this build does not know as `unknown`.
|
|
12
|
+
*/
|
|
13
|
+
export const AUTH_STATES = ["signed_in", "signed_out", "unknown"];
|
|
14
|
+
/**
|
|
15
|
+
* What kind of credential a signed-in harness's turns run on: a
|
|
16
|
+
* `subscription` (a Claude or ChatGPT plan, also as a token such as
|
|
17
|
+
* `CLAUDE_CODE_OAUTH_TOKEN`; `source` says where it comes from), an
|
|
18
|
+
* `api_key`, or a `cloud` provider's credentials (Bedrock, Vertex, Foundry).
|
|
19
|
+
* OPEN.
|
|
20
|
+
*/
|
|
21
|
+
export const AUTH_CREDENTIALS = ["subscription", "api_key", "cloud"];
|
|
22
|
+
/**
|
|
23
|
+
* Where that credential comes from: the CLI's own `login` (what `auth/login`
|
|
24
|
+
* and the CLI's login command store), the server's `environment`, which wins
|
|
25
|
+
* over a login, the CLI's `settings` (Claude's `apiKeyHelper`), or the
|
|
26
|
+
* `product`, which holds it and hands it to each turn (`grantAuth`). A turn's
|
|
27
|
+
* own `apiKey` wins over the first three. OPEN.
|
|
28
|
+
*/
|
|
29
|
+
export const AUTH_SOURCES = ["login", "environment", "settings", "product"];
|
|
30
|
+
/**
|
|
31
|
+
* How a login method signs in:
|
|
32
|
+
* - `browser` — the user signs in at the login's `url`, and the CLI hears
|
|
33
|
+
* back on the server's machine; where the login has a `codeUrl`, a browser
|
|
34
|
+
* on another device signs in there and the user pastes the code it shows
|
|
35
|
+
* (`auth/complete`);
|
|
36
|
+
* - `device_code` — the user enters the login's `userCode` at its `url`, on
|
|
37
|
+
* any device;
|
|
38
|
+
* - `api_key` — `auth/login` carries the key;
|
|
39
|
+
* - `terminal` — the user runs the method's `command` in a terminal; it is
|
|
40
|
+
* not an `auth/login` method.
|
|
41
|
+
* OPEN.
|
|
42
|
+
*/
|
|
43
|
+
export const AUTH_METHOD_KINDS = ["browser", "device_code", "api_key", "terminal"];
|
|
44
|
+
/** One way to log a harness in. */
|
|
45
|
+
export const AuthMethodSchema = z.object({
|
|
46
|
+
/** What `auth/login` names (`claudeai`, `chatgpt`, `api_key`, …). */
|
|
47
|
+
id: z.string().min(1),
|
|
48
|
+
kind: openVocabulary(AUTH_METHOD_KINDS),
|
|
49
|
+
label: z.string(),
|
|
50
|
+
/**
|
|
51
|
+
* What a login by this method runs on (`subscription`, `api_key`); absent
|
|
52
|
+
* for a `terminal` login, which may sign in either way.
|
|
53
|
+
*/
|
|
54
|
+
credential: openVocabulary(AUTH_CREDENTIALS).optional(),
|
|
55
|
+
/** `terminal`: the command line, the CLI's path first. */
|
|
56
|
+
command: z.array(z.string()).optional(),
|
|
57
|
+
/** `terminal`: what to set in its environment, to sign in where turns look. */
|
|
58
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* A login under way, answered at once: the user signs in at `url` (entering
|
|
62
|
+
* `userCode` there, for a device code) or, from another device, at `codeUrl`
|
|
63
|
+
* and pastes the code it shows (`auth/complete`). An `api_key` login has none
|
|
64
|
+
* of them. `auth/updated` says how it ended.
|
|
65
|
+
*/
|
|
66
|
+
export const AuthLoginSchema = z.object({
|
|
67
|
+
loginId: z.string(),
|
|
68
|
+
harness: HarnessIdSchema,
|
|
69
|
+
method: z.string(),
|
|
70
|
+
url: z.string().optional(),
|
|
71
|
+
codeUrl: z.string().optional(),
|
|
72
|
+
userCode: z.string().optional(),
|
|
73
|
+
/** When the server gives up on it (epoch ms). */
|
|
74
|
+
expiresAt: z.number().int().nonnegative(),
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* One harness's login, as `auth/status` and `auth/logout` answer it, and as
|
|
78
|
+
* a product shows one it holds (`grantAuth`): who, on what kind of
|
|
79
|
+
* credential, from where, and what to call it.
|
|
80
|
+
*/
|
|
81
|
+
export const HarnessAuthSchema = AccountInfoSchema.extend({
|
|
82
|
+
harness: HarnessIdSchema,
|
|
83
|
+
state: openVocabulary(AUTH_STATES),
|
|
84
|
+
credential: openVocabulary(AUTH_CREDENTIALS).optional(),
|
|
85
|
+
source: openVocabulary(AUTH_SOURCES).optional(),
|
|
86
|
+
/** What to show for it (`Claude Max`, `ChatGPT Pro`, `OpenAI API key`): `accountLabel`. */
|
|
87
|
+
label: z.string().optional(),
|
|
88
|
+
/** When the credential stops working (epoch ms), where known. */
|
|
89
|
+
expiresAt: z.number().int().optional(),
|
|
90
|
+
/** The logins this harness offers here; none where its agent signs in on its own. */
|
|
91
|
+
methods: z.array(AuthMethodSchema),
|
|
92
|
+
error: z.string().optional(),
|
|
93
|
+
/**
|
|
94
|
+
* The login under way to this harness and store, as `auth/login` answered
|
|
95
|
+
* it: present from its start until its end is told, in every status read
|
|
96
|
+
* and `auth/updated`, so every window shows it (its `url`, `userCode`)
|
|
97
|
+
* and can cancel it; absent otherwise.
|
|
98
|
+
*/
|
|
99
|
+
loginUnderWay: AuthLoginSchema.optional(),
|
|
100
|
+
});
|
|
101
|
+
/**
|
|
102
|
+
* Whether the harness already runs on the login this method would make: the
|
|
103
|
+
* CLI's own, of the method's credential. A product then shows it connected
|
|
104
|
+
* and starts no sign-in, as a local login is picked up where the user already
|
|
105
|
+
* made one. A credential from the environment or settings is not one.
|
|
106
|
+
*/
|
|
107
|
+
export function signedInBy(auth, method) {
|
|
108
|
+
return (auth.state === "signed_in" &&
|
|
109
|
+
auth.source === "login" &&
|
|
110
|
+
method.credential !== undefined &&
|
|
111
|
+
auth.credential === method.credential);
|
|
112
|
+
}
|
|
113
|
+
/** The environment a turn would run with: it picks the CLI's store (`CLAUDE_CONFIG_DIR`, `CODEX_HOME`) and the environment's credentials. */
|
|
114
|
+
const AuthEnvSchema = z.record(z.string(), z.string());
|
|
115
|
+
/** `auth/status`: each harness's login; every registered harness's when `harnesses` is absent. */
|
|
116
|
+
export const AuthStatusParamsSchema = z.object({
|
|
117
|
+
harnesses: z.array(AgentHarnessSchema).optional(),
|
|
118
|
+
env: AuthEnvSchema.optional(),
|
|
119
|
+
});
|
|
120
|
+
export const AuthStatusResultSchema = z.object({ auth: z.array(HarnessAuthSchema) });
|
|
121
|
+
/**
|
|
122
|
+
* `auth/login`: start one of a harness's `methods`. A newer login for the same
|
|
123
|
+
* harness and store cancels this one.
|
|
124
|
+
*/
|
|
125
|
+
export const AuthLoginParamsSchema = z.object({
|
|
126
|
+
harness: AgentHarnessSchema,
|
|
127
|
+
method: z.string().min(1),
|
|
128
|
+
/** An `api_key` method's key: never answered back, logged or journaled. */
|
|
129
|
+
apiKey: z.string().min(1).optional(),
|
|
130
|
+
env: AuthEnvSchema.optional(),
|
|
131
|
+
});
|
|
132
|
+
/** `auth/complete`: the code a `codeUrl` page showed, as pasted (`code#state`, or the page's address). */
|
|
133
|
+
export const AuthCompleteParamsSchema = z.object({
|
|
134
|
+
loginId: z.string(),
|
|
135
|
+
code: z.string().min(1),
|
|
136
|
+
});
|
|
137
|
+
/** How a login ended; `disconnected`: the client lost its connection first, and reads the status again. OPEN. */
|
|
138
|
+
export const LOGIN_OUTCOMES = [
|
|
139
|
+
"succeeded",
|
|
140
|
+
"failed",
|
|
141
|
+
"cancelled",
|
|
142
|
+
"expired",
|
|
143
|
+
"disconnected",
|
|
144
|
+
];
|
|
145
|
+
/** How a login ended, as `auth/updated` carries it. */
|
|
146
|
+
export const AuthLoginEndSchema = z.object({
|
|
147
|
+
loginId: z.string(),
|
|
148
|
+
outcome: openVocabulary(LOGIN_OUTCOMES),
|
|
149
|
+
error: z.string().optional(),
|
|
150
|
+
});
|
|
151
|
+
/**
|
|
152
|
+
* `auth/updated` (server -> every connection): a harness's login changed, a
|
|
153
|
+
* login started (`auth.loginUnderWay`, no `login`), or a login ended
|
|
154
|
+
* (`login`), whoever caused it: `auth/login`, `auth/logout`, or a login in a
|
|
155
|
+
* terminal that a status read noticed. A login's end is always one of these,
|
|
156
|
+
* with the harness's login after it, as `auth/complete` answers it.
|
|
157
|
+
*/
|
|
158
|
+
export const AuthUpdatedSchema = z.object({
|
|
159
|
+
auth: HarnessAuthSchema,
|
|
160
|
+
login: AuthLoginEndSchema.optional(),
|
|
161
|
+
});
|
|
162
|
+
/** `auth/cancel`: stop a login under way. */
|
|
163
|
+
export const AuthCancelParamsSchema = z.object({ loginId: z.string() });
|
|
164
|
+
export const AuthCancelResultSchema = z.object({ outcome: z.enum(["cancelled", "not_found"]) });
|
|
165
|
+
/** `auth/logout`: remove the CLI's own login; answers the harness's login after it. */
|
|
166
|
+
export const AuthLogoutParamsSchema = z.object({
|
|
167
|
+
harness: AgentHarnessSchema,
|
|
168
|
+
env: AuthEnvSchema.optional(),
|
|
169
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic JSON: object keys sorted, `undefined` members dropped, as
|
|
3
|
+
* `JSON.stringify` drops them. The one definition of "the same value" here:
|
|
4
|
+
* a turn's identity (the runtime's admission and the journal's fingerprint
|
|
5
|
+
* agree on it) and the history hash chain, whose stored versions depend on
|
|
6
|
+
* this exact output. Pure JS, so the contract stays safe in any runtime.
|
|
7
|
+
*/
|
|
8
|
+
export function canonicalJson(value) {
|
|
9
|
+
if (value === null || typeof value !== "object")
|
|
10
|
+
return JSON.stringify(value) ?? "null";
|
|
11
|
+
if (Array.isArray(value))
|
|
12
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
13
|
+
return `{${Object.entries(value)
|
|
14
|
+
.filter(([, v]) => v !== undefined)
|
|
15
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
16
|
+
.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`)
|
|
17
|
+
.join(",")}}`;
|
|
18
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ErrorCategorySchema } from "./errors.js";
|
|
3
|
+
import { AgentHarnessSchema, HarnessIdSchema } from "./harness.js";
|
|
4
|
+
import { openVocabulary } from "./vocabulary.js";
|
|
5
|
+
/**
|
|
6
|
+
* Where a harness's CLI is:
|
|
7
|
+
* - `ready` — a turn runs it at once;
|
|
8
|
+
* - `missing` — its first turn (or `clis/prepare`) installs `version`;
|
|
9
|
+
* without a `version`, nothing will (a `system` server): the harness
|
|
10
|
+
* cannot run here;
|
|
11
|
+
* - `installing` — being installed now, `receivedBytes` of `totalBytes`
|
|
12
|
+
* downloaded (none before its download starts);
|
|
13
|
+
* - `failed` — the last install failed, `error` says why and `category`
|
|
14
|
+
* what failed (the error vocabulary's: `network` for a registry that
|
|
15
|
+
* cannot be reached or answers 5xx, or a transfer that was cut); the next
|
|
16
|
+
* turn or prepare tries again;
|
|
17
|
+
* - `unmanaged` — the engine does not install this harness's agent (ACP: the
|
|
18
|
+
* operator's launch command).
|
|
19
|
+
* OPEN: treat a state this build does not know as `missing`.
|
|
20
|
+
*/
|
|
21
|
+
export const CLI_STATES = ["ready", "missing", "installing", "failed", "unmanaged"];
|
|
22
|
+
/**
|
|
23
|
+
* Where a ready CLI comes from: the operator's `override`, a `bundled`
|
|
24
|
+
* folder, the `host`'s install, or the engine's `cache` (where an install
|
|
25
|
+
* puts it). OPEN.
|
|
26
|
+
*/
|
|
27
|
+
export const CLI_SOURCES = ["override", "bundled", "host", "cache"];
|
|
28
|
+
/** One harness's CLI, as `clis/list` and `clis/prepare` answer it. */
|
|
29
|
+
export const HarnessCliSchema = z.object({
|
|
30
|
+
harness: HarnessIdSchema,
|
|
31
|
+
state: openVocabulary(CLI_STATES),
|
|
32
|
+
/** What runs when `ready`; what an install fetches otherwise. */
|
|
33
|
+
version: z.string().optional(),
|
|
34
|
+
source: openVocabulary(CLI_SOURCES).optional(),
|
|
35
|
+
receivedBytes: z.number().int().nonnegative().optional(),
|
|
36
|
+
totalBytes: z.number().int().nonnegative().optional(),
|
|
37
|
+
error: z.string().optional(),
|
|
38
|
+
/** What failed, with `error` (`failed` only). OPEN, as every category is. */
|
|
39
|
+
category: ErrorCategorySchema.optional(),
|
|
40
|
+
});
|
|
41
|
+
/** Which harnesses' CLIs to list or prepare: every registered harness's when absent. */
|
|
42
|
+
export const ClisParamsSchema = z.object({
|
|
43
|
+
harnesses: z.array(AgentHarnessSchema).optional(),
|
|
44
|
+
});
|
|
45
|
+
export const ClisResultSchema = z.object({ clis: z.array(HarnessCliSchema) });
|
|
46
|
+
/** An install's phases: `downloading`, then `verifying`, then `ready`; `failed` at any point. OPEN. */
|
|
47
|
+
export const CLI_PHASES = ["downloading", "verifying", "ready", "failed"];
|
|
48
|
+
/**
|
|
49
|
+
* `clis/progress` (server -> every connection): a harness's CLI being
|
|
50
|
+
* installed, whoever caused it (a turn, `clis/prepare`, `auth/login`,
|
|
51
|
+
* `auth/logout`; a read such as `models/list` or `auth/status` installs
|
|
52
|
+
* nothing). At most four a second per install, and always its last phase.
|
|
53
|
+
*/
|
|
54
|
+
export const HarnessCliProgressSchema = z.object({
|
|
55
|
+
harness: HarnessIdSchema,
|
|
56
|
+
version: z.string(),
|
|
57
|
+
phase: openVocabulary(CLI_PHASES),
|
|
58
|
+
receivedBytes: z.number().int().nonnegative(),
|
|
59
|
+
totalBytes: z.number().int().nonnegative().optional(),
|
|
60
|
+
error: z.string().optional(),
|
|
61
|
+
/** What failed, with `error` (`failed` only), as on `HarnessCli`. */
|
|
62
|
+
category: ErrorCategorySchema.optional(),
|
|
63
|
+
});
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AgentHarnessSchema } from "./harness.js";
|
|
3
|
+
import { AgentInputSchema } from "./part-input.js";
|
|
4
|
+
import { ThinkingLevelSchema } from "./thinking.js";
|
|
5
|
+
import { openVocabulary } from "./vocabulary.js";
|
|
6
|
+
/**
|
|
7
|
+
* Permission posture for a turn. `bypass_permissions` auto-approves every
|
|
8
|
+
* tool (the right default inside a sandbox); `plan` is read-only planning;
|
|
9
|
+
* `dont_ask` never prompts — unapproved tools are denied, sandboxes stay at
|
|
10
|
+
* their normal (non-dangerous) level. Values are snake_case (LLP 0002, Casing);
|
|
11
|
+
* adapters map to provider vocabulary at the edge (Claude SDK: acceptEdits,
|
|
12
|
+
* bypassPermissions).
|
|
13
|
+
*/
|
|
14
|
+
export const PermissionModeSchema = z.enum([
|
|
15
|
+
"default",
|
|
16
|
+
"plan",
|
|
17
|
+
"accept_edits",
|
|
18
|
+
"dont_ask",
|
|
19
|
+
"bypass_permissions",
|
|
20
|
+
]);
|
|
21
|
+
export const ReportedPermissionModeSchema = openVocabulary(PermissionModeSchema.options);
|
|
22
|
+
/** The longest `requestTimeoutMs`: a timer's own limit, about 24.8 days. */
|
|
23
|
+
export const MAX_REQUEST_TIMEOUT_MS = 2_147_483_647;
|
|
24
|
+
/**
|
|
25
|
+
* Whether a turn needs the server (default `true`). A turn fails before the
|
|
26
|
+
* model runs when a required server cannot connect (`mcp_unavailable`); one
|
|
27
|
+
* that is not required is said as a recoverable `error` of that category, and
|
|
28
|
+
* the turn goes on without its tools. Claude and Codex keep the rule; an ACP
|
|
29
|
+
* agent connects its servers itself and decides.
|
|
30
|
+
*/
|
|
31
|
+
const required = z.boolean().optional();
|
|
32
|
+
/** Minimal external MCP server descriptor (stdio or http/sse). */
|
|
33
|
+
export const McpServerConfigSchema = z.discriminatedUnion("type", [
|
|
34
|
+
z.object({
|
|
35
|
+
type: z.literal("stdio"),
|
|
36
|
+
command: z.string(),
|
|
37
|
+
args: z.array(z.string()).optional(),
|
|
38
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
39
|
+
required,
|
|
40
|
+
}),
|
|
41
|
+
z.object({
|
|
42
|
+
type: z.literal("http"),
|
|
43
|
+
url: z.string(),
|
|
44
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
45
|
+
required,
|
|
46
|
+
}),
|
|
47
|
+
z.object({
|
|
48
|
+
type: z.literal("sse"),
|
|
49
|
+
url: z.string(),
|
|
50
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
51
|
+
required,
|
|
52
|
+
}),
|
|
53
|
+
]);
|
|
54
|
+
/** Everything needed to configure a turn against a harness. */
|
|
55
|
+
export const RunConfigSchema = z.object({
|
|
56
|
+
harness: AgentHarnessSchema,
|
|
57
|
+
/** Free-form model id/alias; omit to use the harness default. */
|
|
58
|
+
model: z.string().optional(),
|
|
59
|
+
thinkingLevel: ThinkingLevelSchema.optional(),
|
|
60
|
+
/** Working directory the agent operates in. */
|
|
61
|
+
cwd: z.string(),
|
|
62
|
+
/**
|
|
63
|
+
* Extra directories the agent may access beyond `cwd`. Mapped by every
|
|
64
|
+
* built-in harness (codex-app-server makes them writable roots of its
|
|
65
|
+
* workspace-write sandbox), and by acp for agents that advertise the capability.
|
|
66
|
+
*/
|
|
67
|
+
additionalDirectories: z.array(z.string()).optional(),
|
|
68
|
+
systemPromptAppend: z.string().optional(),
|
|
69
|
+
maxTurns: z.number().int().positive().optional(),
|
|
70
|
+
/** Native workers must settle before this managed execution releases its context. */
|
|
71
|
+
subagentMode: z.literal("turn").optional(),
|
|
72
|
+
permissionMode: PermissionModeSchema.optional(),
|
|
73
|
+
/**
|
|
74
|
+
* This turn's client answers `elicitation.requested`: the agent's questions
|
|
75
|
+
* and its MCP servers' requests for input. Absent or false, the harness
|
|
76
|
+
* declines them on the user's behalf and the agent carries on, so a turn
|
|
77
|
+
* never waits for an answer nobody will give.
|
|
78
|
+
*/
|
|
79
|
+
elicitation: z.boolean().optional(),
|
|
80
|
+
/**
|
|
81
|
+
* How long a permission request or question waits for an answer, in
|
|
82
|
+
* milliseconds. Unanswered by then, it is resolved as cancelled, as a
|
|
83
|
+
* cancel would resolve it (`*.resolved` on the stream; a cancelled
|
|
84
|
+
* permission ends a Claude turn). Absent, it waits until the turn ends.
|
|
85
|
+
*/
|
|
86
|
+
requestTimeoutMs: z.number().int().positive().max(MAX_REQUEST_TIMEOUT_MS).optional(),
|
|
87
|
+
/**
|
|
88
|
+
* Native session/thread id to resume (from a prior `session.created`). When
|
|
89
|
+
* set, the harness continues that conversation instead of starting fresh.
|
|
90
|
+
*/
|
|
91
|
+
resumeSessionId: z.string().min(1).optional(),
|
|
92
|
+
/**
|
|
93
|
+
* Resume from a specific historical message within the resumed session
|
|
94
|
+
* (branch/retry flows). Claude-only today; other harnesses ignore it.
|
|
95
|
+
*/
|
|
96
|
+
resumeSessionAt: z.string().optional(),
|
|
97
|
+
mcpServers: z.record(z.string(), McpServerConfigSchema).optional(),
|
|
98
|
+
/** Extra env vars layered onto the agent subprocess. */
|
|
99
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
100
|
+
/** Per-turn API key override (BYOK). Falls back to ambient/proxy auth. */
|
|
101
|
+
apiKey: z.string().optional(),
|
|
102
|
+
/**
|
|
103
|
+
* Disable all built-in tools for this turn (text-only). Claude honors it.
|
|
104
|
+
* Codex cannot turn its tools off (a read-only sandbox still runs
|
|
105
|
+
* commands), so it fails such a turn as `invalid_request` before any model
|
|
106
|
+
* call. ACP has no way to ask an agent for it, and the acp harness ignores it.
|
|
107
|
+
*/
|
|
108
|
+
disableTools: z.boolean().optional(),
|
|
109
|
+
/**
|
|
110
|
+
* Interleave `raw` passthrough events (the harness's unparsed events) with
|
|
111
|
+
* the normalized stream. Migration/debug escape hatch — see `RawEvent`.
|
|
112
|
+
*/
|
|
113
|
+
includeRaw: z.boolean().optional(),
|
|
114
|
+
});
|
|
115
|
+
/**
|
|
116
|
+
* A single request to run one turn.
|
|
117
|
+
* - `sessionId` is OUR stable logical id (the session-manager key). It is the
|
|
118
|
+
* same across every turn of a conversation.
|
|
119
|
+
* - the harness-native id (for resume) is discovered at runtime and surfaced
|
|
120
|
+
* via the `session.created` lifecycle event.
|
|
121
|
+
*/
|
|
122
|
+
export const RunRequestSchema = z.object({
|
|
123
|
+
sessionId: z.string(),
|
|
124
|
+
turnId: z.string(),
|
|
125
|
+
input: AgentInputSchema,
|
|
126
|
+
config: RunConfigSchema,
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* What makes a turn the same turn when a client sends its ids again: its input
|
|
130
|
+
* and the config that shapes what the agent does. What a client's own restart
|
|
131
|
+
* can change without making it another turn stays out: MCP endpoints (a fresh
|
|
132
|
+
* per-session URL), the environment, the API key, and raw passthrough.
|
|
133
|
+
*/
|
|
134
|
+
export function turnIdentity(request) {
|
|
135
|
+
const { mcpServers: _mcp, env: _env, apiKey: _key, includeRaw: _raw, ...config } = request.config;
|
|
136
|
+
return { input: request.input, config };
|
|
137
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ReportedPermissionModeSchema } from "./config.js";
|
|
3
|
+
import { ErrorCategorySchema, ErrorInfoSchema } from "./errors.js";
|
|
4
|
+
import { TurnExecutionSchema } from "./execution.js";
|
|
5
|
+
import { HarnessIdSchema } from "./harness.js";
|
|
6
|
+
import { CompactionStatusSchema, CompactionTriggerSchema, ElicitationOutcomeSchema, ElicitationRequestedEventSchema, ErrorEventSchema, LimitStatusSchema, LimitWindowSchema, PermissionOutcomeSchema, PermissionRequestedEventSchema, SessionEndReasonSchema, StopReasonSchema, UnknownEventSchema, } from "./lifecycle.js";
|
|
7
|
+
import { PartSchema, UnknownPartSchema } from "./parts.js";
|
|
8
|
+
import { EpochMsSchema } from "./time.js";
|
|
9
|
+
import { DEFAULT_TOKEN_USAGE, TokenUsageSchema } from "./tokens.js";
|
|
10
|
+
/**
|
|
11
|
+
* The conversation state the canonical reducer folds the stream into
|
|
12
|
+
* (`reduce.ts`), and what a fold reports it touched. The state types are zod
|
|
13
|
+
* schemas because products persist `ConversationState` and read it back (LLP
|
|
14
|
+
* 0002, "Reducer state is persistable"); derived state that is not wire
|
|
15
|
+
* vocabulary is namespaced or documented as such.
|
|
16
|
+
*/
|
|
17
|
+
export const ConversationMessageSchema = z.object({
|
|
18
|
+
kind: z.literal("message"),
|
|
19
|
+
messageId: z.string(),
|
|
20
|
+
sessionId: z.string(),
|
|
21
|
+
turnId: z.string(),
|
|
22
|
+
outputIndex: z.number(),
|
|
23
|
+
role: z.enum(["user", "assistant"]),
|
|
24
|
+
/** Set when this is a sub-agent's output — nest it under that tool call. */
|
|
25
|
+
parentToolCallId: z.string().optional(),
|
|
26
|
+
model: z.string().optional(),
|
|
27
|
+
parts: z.array(z.union([PartSchema, UnknownPartSchema])),
|
|
28
|
+
startedAt: EpochMsSchema,
|
|
29
|
+
endedAt: EpochMsSchema.optional(),
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* The folded compaction entity. Upserts MERGE (a later event that omits
|
|
33
|
+
* `summary`/`preTokens` keeps the ones already known) — deliberately unlike
|
|
34
|
+
* `message.part`, whose snapshots fully REPLACE. A compaction's fields arrive
|
|
35
|
+
* from different harness events at different times ("started, 150k in" then
|
|
36
|
+
* "done, here's the summary"), so replace-semantics would make every producer
|
|
37
|
+
* restate everything or lose it. The cost is stated plainly: a producer cannot
|
|
38
|
+
* clear a compaction field once set.
|
|
39
|
+
*/
|
|
40
|
+
export const ConversationCompactionSchema = z.object({
|
|
41
|
+
kind: z.literal("compaction"),
|
|
42
|
+
compactionId: z.string(),
|
|
43
|
+
turnId: z.string(),
|
|
44
|
+
status: CompactionStatusSchema,
|
|
45
|
+
trigger: CompactionTriggerSchema.optional(),
|
|
46
|
+
preTokens: z.number().optional(),
|
|
47
|
+
postTokens: z.number().optional(),
|
|
48
|
+
summary: z.string().optional(),
|
|
49
|
+
abstractsIds: z.array(z.string()).optional(),
|
|
50
|
+
timestamp: EpochMsSchema,
|
|
51
|
+
});
|
|
52
|
+
/** The ordered render list: messages and compactions interleaved in stream order. */
|
|
53
|
+
export const TimelineEntrySchema = z.discriminatedUnion("kind", [
|
|
54
|
+
ConversationMessageSchema,
|
|
55
|
+
ConversationCompactionSchema,
|
|
56
|
+
]);
|
|
57
|
+
/** A non-terminal `error` event as the state keeps it, a turn's or the session's. */
|
|
58
|
+
export const ErrorEntrySchema = z.object({
|
|
59
|
+
category: ErrorCategorySchema,
|
|
60
|
+
message: z.string(),
|
|
61
|
+
recoverable: z.boolean(),
|
|
62
|
+
/** A retry the harness is waiting on, when it said. */
|
|
63
|
+
retry: ErrorEventSchema.shape.retry,
|
|
64
|
+
timestamp: EpochMsSchema,
|
|
65
|
+
});
|
|
66
|
+
export const ConversationTurnSchema = z.object({
|
|
67
|
+
turnId: z.string(),
|
|
68
|
+
execution: TurnExecutionSchema.optional(),
|
|
69
|
+
/** Derived view state, not wire vocabulary. */
|
|
70
|
+
status: z.enum(["active", "ended"]),
|
|
71
|
+
stopReason: StopReasonSchema.optional(),
|
|
72
|
+
finishReason: z.string().optional(),
|
|
73
|
+
tokens: TokenUsageSchema.optional(),
|
|
74
|
+
cost: z.number().optional(),
|
|
75
|
+
/** Terminal error from `turn.ended`, when the turn failed. */
|
|
76
|
+
error: ErrorInfoSchema.optional(),
|
|
77
|
+
/** Steers the turn accepted but ended without delivering (`turn.ended`). */
|
|
78
|
+
undeliveredSteers: z.array(z.string()).optional(),
|
|
79
|
+
/** Non-terminal `error` events attributed to this turn. */
|
|
80
|
+
errors: z.array(ErrorEntrySchema),
|
|
81
|
+
startedAt: EpochMsSchema,
|
|
82
|
+
endedAt: EpochMsSchema.optional(),
|
|
83
|
+
});
|
|
84
|
+
/** A request as the state keeps it: its event without the envelope, then how it resolved. */
|
|
85
|
+
const REQUEST_ENVELOPE = { type: true, sessionId: true, timestamp: true, _meta: true };
|
|
86
|
+
export const ConversationPermissionSchema = PermissionRequestedEventSchema.omit(REQUEST_ENVELOPE).extend({
|
|
87
|
+
requestedAt: EpochMsSchema,
|
|
88
|
+
/** Absent while the request is pending. */
|
|
89
|
+
outcome: PermissionOutcomeSchema.optional(),
|
|
90
|
+
resolvedAt: EpochMsSchema.optional(),
|
|
91
|
+
});
|
|
92
|
+
export const ConversationElicitationSchema = ElicitationRequestedEventSchema.omit(REQUEST_ENVELOPE).extend({
|
|
93
|
+
requestedAt: EpochMsSchema,
|
|
94
|
+
/** Absent while the request is pending. */
|
|
95
|
+
outcome: ElicitationOutcomeSchema.optional(),
|
|
96
|
+
resolvedAt: EpochMsSchema.optional(),
|
|
97
|
+
});
|
|
98
|
+
export const ConversationStateSchema = z.object({
|
|
99
|
+
sessionId: z.string().optional(),
|
|
100
|
+
/** Persist this and pass it back as `config.resumeSessionId` to resume. */
|
|
101
|
+
nativeSessionId: z.string().optional(),
|
|
102
|
+
harness: HarnessIdSchema.optional(),
|
|
103
|
+
model: z.string().optional(),
|
|
104
|
+
/** From the last resume-requesting turn: false = fresh-session fallback. */
|
|
105
|
+
resumed: z.boolean().optional(),
|
|
106
|
+
timeline: z.array(TimelineEntrySchema),
|
|
107
|
+
turns: z.array(ConversationTurnSchema),
|
|
108
|
+
permissions: z.array(ConversationPermissionSchema),
|
|
109
|
+
/**
|
|
110
|
+
* The agent's questions and its MCP servers' requests for input. Defaults to
|
|
111
|
+
* empty, so a state saved before elicitations existed still loads.
|
|
112
|
+
*/
|
|
113
|
+
elicitations: z.array(ConversationElicitationSchema).default([]),
|
|
114
|
+
/** Live context gauge (`session.usage`) — how full the window is NOW. */
|
|
115
|
+
usage: z
|
|
116
|
+
.object({
|
|
117
|
+
used: z.number(),
|
|
118
|
+
size: z.number().optional(),
|
|
119
|
+
cost: z.number().optional(),
|
|
120
|
+
updatedAt: EpochMsSchema,
|
|
121
|
+
})
|
|
122
|
+
.optional(),
|
|
123
|
+
/** The account's plan usage (`session.limits`), windows merged by id. */
|
|
124
|
+
limits: z
|
|
125
|
+
.object({
|
|
126
|
+
status: LimitStatusSchema.optional(),
|
|
127
|
+
windows: z.array(LimitWindowSchema),
|
|
128
|
+
planType: z.string().optional(),
|
|
129
|
+
updatedAt: EpochMsSchema,
|
|
130
|
+
})
|
|
131
|
+
.optional(),
|
|
132
|
+
/**
|
|
133
|
+
* The permission mode the session runs in: the last turn's request
|
|
134
|
+
* (`turn.started.execution`), then the agent's switches (`session.mode`).
|
|
135
|
+
*/
|
|
136
|
+
permissionMode: ReportedPermissionModeSchema.optional(),
|
|
137
|
+
/** Sum of every ended turn's billing tokens. */
|
|
138
|
+
totals: TokenUsageSchema,
|
|
139
|
+
totalCost: z.number().optional(),
|
|
140
|
+
/** `error` events that carried no turnId. */
|
|
141
|
+
errors: z.array(ErrorEntrySchema),
|
|
142
|
+
/** The harness session is over (`session.ended`). */
|
|
143
|
+
ended: z.object({ reason: SessionEndReasonSchema, timestamp: EpochMsSchema }).optional(),
|
|
144
|
+
/** Unknown event types, preserved in arrival order. */
|
|
145
|
+
unknownEvents: z.array(UnknownEventSchema),
|
|
146
|
+
/**
|
|
147
|
+
* Raw JSON accumulated from `tool_input` deltas per part id, for UIs that
|
|
148
|
+
* stream tool input as it is typed. Cleared when the part's snapshot
|
|
149
|
+
* arrives with the parsed input (the authoritative form).
|
|
150
|
+
*/
|
|
151
|
+
toolInputJson: z.record(z.string(), z.string()),
|
|
152
|
+
});
|
|
153
|
+
/** A fresh, empty conversation state. */
|
|
154
|
+
export function emptyConversation() {
|
|
155
|
+
return {
|
|
156
|
+
timeline: [],
|
|
157
|
+
turns: [],
|
|
158
|
+
permissions: [],
|
|
159
|
+
elicitations: [],
|
|
160
|
+
// The same zero as `addTokenUsage` produces, so "nothing yet" and "summed
|
|
161
|
+
// nothing" are the same shape — a UI never has to handle two empties.
|
|
162
|
+
totals: { ...DEFAULT_TOKEN_USAGE },
|
|
163
|
+
errors: [],
|
|
164
|
+
unknownEvents: [],
|
|
165
|
+
toolInputJson: {},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/** The permission requests still awaiting an answer — render these. */
|
|
169
|
+
export function pendingPermissions(state) {
|
|
170
|
+
return state.permissions.filter((p) => p.outcome === undefined);
|
|
171
|
+
}
|
|
172
|
+
/** The elicitations still awaiting an answer — render these. */
|
|
173
|
+
export function pendingElicitations(state) {
|
|
174
|
+
return state.elicitations.filter((e) => e.outcome === undefined);
|
|
175
|
+
}
|
|
176
|
+
/** The message entries of the timeline, in order (convenience accessor). */
|
|
177
|
+
export function conversationMessages(state) {
|
|
178
|
+
return state.timeline.filter((e) => e.kind === "message");
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* What one fold actually touched — the seam between "the stream says this" and
|
|
182
|
+
* "so write these rows / invalidate these queries".
|
|
183
|
+
*
|
|
184
|
+
* Emitted by `reduceConversationWithChanges`, which INSTRUMENTS the fold
|
|
185
|
+
* rather than diffing states: every mutation site reports itself, so a change
|
|
186
|
+
* list is exactly the set of writes the reducer performed, in the order it
|
|
187
|
+
* performed them. A no-op fold (a replayed duplicate) reports nothing.
|
|
188
|
+
*
|
|
189
|
+
* The addressing is the wire's: `messageId`/`partId`/`turnId`/`requestId` are
|
|
190
|
+
* the same ids the events carry, so a sink can upsert by them without holding
|
|
191
|
+
* a second index. `outputIndex`/`partIndex` are the event's positions when the
|
|
192
|
+
* change came from a `message.part`; for the tools the reducer closes itself
|
|
193
|
+
* (at their turn's end) they are the message's `outputIndex` and the part's
|
|
194
|
+
* position in that message — the same numbers for any stream that arrived in
|
|
195
|
+
* order.
|
|
196
|
+
*/
|
|
197
|
+
export const ConversationChangeSchema = z.discriminatedUnion("kind", [
|
|
198
|
+
/** A message was added to the timeline (started, or shelled in by a part). */
|
|
199
|
+
z.object({ kind: z.literal("message_upserted"), messageId: z.string(), turnId: z.string() }),
|
|
200
|
+
/** A part snapshot landed in its message (or a delta extended one in place). */
|
|
201
|
+
z.object({
|
|
202
|
+
kind: z.literal("part_upserted"),
|
|
203
|
+
messageId: z.string(),
|
|
204
|
+
partId: z.string(),
|
|
205
|
+
outputIndex: z.number(),
|
|
206
|
+
partIndex: z.number(),
|
|
207
|
+
}),
|
|
208
|
+
/** A message got its `endedAt` (once — a repeat is not a change). */
|
|
209
|
+
z.object({ kind: z.literal("message_ended"), messageId: z.string() }),
|
|
210
|
+
/** Streamed tool-input JSON was appended to `toolInputJson[partId]`. */
|
|
211
|
+
z.object({ kind: z.literal("delta_buffered"), partId: z.string() }),
|
|
212
|
+
/** A turn was opened, ended, or gained a non-terminal error. */
|
|
213
|
+
z.object({ kind: z.literal("turn_updated"), turnId: z.string() }),
|
|
214
|
+
z.object({ kind: z.literal("compaction_upserted"), compactionId: z.string() }),
|
|
215
|
+
/** A permission was requested, answered, or cancelled by its turn ending. */
|
|
216
|
+
z.object({ kind: z.literal("permission_updated"), requestId: z.string() }),
|
|
217
|
+
/** An elicitation was requested, answered, or cancelled by its turn ending. */
|
|
218
|
+
z.object({ kind: z.literal("elicitation_updated"), requestId: z.string() }),
|
|
219
|
+
/** The context gauge (`session.usage`) or the billing totals moved. */
|
|
220
|
+
z.object({ kind: z.literal("usage_updated") }),
|
|
221
|
+
/** The account's plan usage (`session.limits`) moved. */
|
|
222
|
+
z.object({ kind: z.literal("limits_updated") }),
|
|
223
|
+
/**
|
|
224
|
+
* Session-scoped facts changed: the `session.created` identity fields, the
|
|
225
|
+
* permission mode (a turn's, or `session.mode`), or an `error` event with no
|
|
226
|
+
* turn to attribute (it lands in `state.errors`).
|
|
227
|
+
*/
|
|
228
|
+
z.object({ kind: z.literal("session_meta_updated") }),
|
|
229
|
+
z.object({ kind: z.literal("session_ended") }),
|
|
230
|
+
z.object({ kind: z.literal("unknown_event_recorded") }),
|
|
231
|
+
]);
|