@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
package/src/server/bin.ts
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
// # (with $AGENT_SERVER_DIAL_TOKEN as its bearer token)
|
|
9
9
|
// agent-server --harness a,b # restrict registered harnesses
|
|
10
10
|
// agent-server --acp-agent "npx -y pi-acp" # enable the acp harness
|
|
11
|
+
// agent-server --script turns.jsonl # the scripted harness plays this script
|
|
12
|
+
// agent-server --script turns.jsonl --script-position at.json # and goes on after a restart
|
|
11
13
|
// agent-server --acp --harness claude-code # BE an ACP agent on stdio (for Zed etc.)
|
|
14
|
+
// agent-server --acp --harness codex-app-server --model gpt-6-luna --thinking low
|
|
12
15
|
// agent-server --buffer 8192 # replay buffer size per session
|
|
13
16
|
// agent-server --inherit-config none # a turn loads no ambient settings, MCP, hooks, memory
|
|
14
17
|
// agent-server install # prefetch the pinned agent CLIs
|
|
@@ -22,15 +25,18 @@ import {
|
|
|
22
25
|
type CredentialSource,
|
|
23
26
|
type InheritConfig,
|
|
24
27
|
type ProvisionMode,
|
|
28
|
+
type ScriptSource,
|
|
25
29
|
createAgentRuntime,
|
|
26
30
|
credentialsFromUrl,
|
|
27
31
|
isInheritConfig,
|
|
28
32
|
resolveAcpLaunch,
|
|
29
33
|
resolveHarnessName,
|
|
34
|
+
scriptedFile,
|
|
30
35
|
} from "../core/index.ts";
|
|
36
|
+
import { THINKING_LEVELS, type ThinkingLevel, isThinkingLevel } from "../protocol/index.ts";
|
|
31
37
|
import { AgentServer } from "./agent-server.ts";
|
|
32
38
|
import { runFeedbackCommand } from "./feedback.ts";
|
|
33
|
-
import { runInstall } from "./install.ts";
|
|
39
|
+
import { installedLine, nothingToInstall, runInstall, toolsFor } from "./install.ts";
|
|
34
40
|
import { takeSecrets } from "./secrets.ts";
|
|
35
41
|
import {
|
|
36
42
|
type ListenOptions,
|
|
@@ -55,10 +61,17 @@ interface Args {
|
|
|
55
61
|
dialUrl?: string;
|
|
56
62
|
harnesses?: string[];
|
|
57
63
|
acpAgent?: string;
|
|
64
|
+
/** --script: the JSONL file the scripted harness plays. */
|
|
65
|
+
script?: string;
|
|
66
|
+
/** --script-position: where the script's position is kept across restarts. */
|
|
67
|
+
scriptPosition?: string;
|
|
58
68
|
bufferSize?: number;
|
|
59
69
|
journalPath?: string;
|
|
60
70
|
provisionMode?: ProvisionMode;
|
|
61
71
|
inheritConfig?: InheritConfig;
|
|
72
|
+
/** --acp: the model and thinking level of every turn, the operator's alone. */
|
|
73
|
+
model?: string;
|
|
74
|
+
thinking?: ThinkingLevel;
|
|
62
75
|
/** A product's credential endpoint, asked before each turn (LLP 0012). */
|
|
63
76
|
credentialsUrl?: string;
|
|
64
77
|
/** install: the platforms to stage, the folder to stage them into, and whether to prune. */
|
|
@@ -74,6 +87,9 @@ function usage(exitCode: number): never {
|
|
|
74
87
|
"",
|
|
75
88
|
" --stdio serve NDJSON JSON-RPC on stdio (the default)",
|
|
76
89
|
" --acp speak ACP v1 on stdio instead (be the agent)",
|
|
90
|
+
" --model <id> every turn runs on this model (default: the harness's own)",
|
|
91
|
+
` --thinking <level> and at this thinking level (${THINKING_LEVELS.join(", ")});`,
|
|
92
|
+
" the operator's choice: an ACP client cannot change either",
|
|
77
93
|
" install download the pinned agent CLIs into the managed cache",
|
|
78
94
|
" (always downloads — run at image build time to erase",
|
|
79
95
|
" sandbox cold starts; --provision applies to serving only)",
|
|
@@ -86,7 +102,7 @@ function usage(exitCode: number): never {
|
|
|
86
102
|
" (no key; see feedback --help for categories, evals,",
|
|
87
103
|
" thread replies and --dry-run)",
|
|
88
104
|
" --listen [host:]port accept WebSocket clients (an IPv6 host in brackets: [::1]:4747);",
|
|
89
|
-
" beyond loopback only with a token",
|
|
105
|
+
" beyond loopback only with a token; under Bun only",
|
|
90
106
|
" --token-file <path> the token a listener's clients send (Authorization: Bearer);",
|
|
91
107
|
" or $AGENT_SERVER_TOKEN, never argv (ps shows it to every user)",
|
|
92
108
|
" --allow-origin <url> a browser origin that may connect to the listener (repeatable;",
|
|
@@ -95,6 +111,11 @@ function usage(exitCode: number): never {
|
|
|
95
111
|
" $AGENT_SERVER_DIAL_TOKEN, never argv or the URL",
|
|
96
112
|
" --harness <a,b> restrict harnesses (default: all installed)",
|
|
97
113
|
" --acp-agent <spec> ACP agent: known name (pi|gemini) or launch command",
|
|
114
|
+
" --script <file> the scripted harness plays this JSONL script, one step a",
|
|
115
|
+
" line (its only harness unless --harness names others);",
|
|
116
|
+
" one turn plays at a time, from the start at each start",
|
|
117
|
+
" --script-position <file> keep the script's position here, so a restarted",
|
|
118
|
+
" server goes on where the last one stopped",
|
|
98
119
|
" --provision <mode> CLI provisioning: auto | pinned | system (default auto)",
|
|
99
120
|
" --inherit-config <level> what a turn loads by itself (settings, MCP servers, hooks,",
|
|
100
121
|
" memory): all, the user's and the repository's (the default),",
|
|
@@ -103,7 +124,7 @@ function usage(exitCode: number): never {
|
|
|
103
124
|
" --credentials-url <url> ask this product endpoint for each turn's credential",
|
|
104
125
|
" (LLP 0012); its token in $AGENT_SERVER_CREDENTIALS_TOKEN",
|
|
105
126
|
" --buffer <n> replay buffer size per session (default 4096; not with --journal)",
|
|
106
|
-
" --journal <path> durable session history (wire modes only; Bun
|
|
127
|
+
" --journal <path> durable session history (wire modes only; SQLite: Bun's, or Node's)",
|
|
107
128
|
" --version, --help (an option's value may also follow `=`: --journal=<path>)",
|
|
108
129
|
"",
|
|
109
130
|
"env: AGENT_SERVER_TOKEN (the listener's token, if no --token-file),",
|
|
@@ -145,8 +166,12 @@ const VALUE_OPTIONS = new Set([
|
|
|
145
166
|
"--dial",
|
|
146
167
|
"--harness",
|
|
147
168
|
"--acp-agent",
|
|
169
|
+
"--script",
|
|
170
|
+
"--script-position",
|
|
148
171
|
"--provision",
|
|
149
172
|
"--inherit-config",
|
|
173
|
+
"--model",
|
|
174
|
+
"--thinking",
|
|
150
175
|
"--credentials-url",
|
|
151
176
|
"--journal",
|
|
152
177
|
"--buffer",
|
|
@@ -192,6 +217,12 @@ function parseArgs(argv: string[]): Args {
|
|
|
192
217
|
if (spec === undefined || !spec.trim() || spec.startsWith("-"))
|
|
193
218
|
fail("--acp-agent needs a known agent name (pi, gemini) or a launch command");
|
|
194
219
|
args.acpAgent = spec;
|
|
220
|
+
} else if (arg === "--script") {
|
|
221
|
+
args.script = next();
|
|
222
|
+
if (!args.script) fail("--script needs a file path");
|
|
223
|
+
} else if (arg === "--script-position") {
|
|
224
|
+
args.scriptPosition = next();
|
|
225
|
+
if (!args.scriptPosition) fail("--script-position needs a file path");
|
|
195
226
|
} else if (arg === "--provision") {
|
|
196
227
|
const mode = next();
|
|
197
228
|
if (mode !== "auto" && mode !== "pinned" && mode !== "system")
|
|
@@ -201,6 +232,16 @@ function parseArgs(argv: string[]): Args {
|
|
|
201
232
|
const level = next();
|
|
202
233
|
if (!isInheritConfig(level)) fail(`--inherit-config ${level}: use all, project or none`);
|
|
203
234
|
args.inheritConfig = level;
|
|
235
|
+
} else if (arg === "--model") {
|
|
236
|
+
args.model = next();
|
|
237
|
+
if (!args.model) fail("--model needs a model id");
|
|
238
|
+
} else if (arg === "--thinking") {
|
|
239
|
+
const level = next();
|
|
240
|
+
if (!isThinkingLevel(level))
|
|
241
|
+
fail(
|
|
242
|
+
`--thinking ${level}: use ${THINKING_LEVELS.slice(0, -1).join(", ")} or ${THINKING_LEVELS.at(-1)}`,
|
|
243
|
+
);
|
|
244
|
+
args.thinking = level;
|
|
204
245
|
} else if (arg === "--credentials-url") {
|
|
205
246
|
args.credentialsUrl = next();
|
|
206
247
|
} else if (arg === "--journal") {
|
|
@@ -225,8 +266,9 @@ function parseArgs(argv: string[]): Args {
|
|
|
225
266
|
return args;
|
|
226
267
|
}
|
|
227
268
|
|
|
228
|
-
/** `host:port`,
|
|
229
|
-
function hostPort(
|
|
269
|
+
/** Where `--listen` listens (loopback, port 0, unless it says) as `host:port`, IPv6 in brackets. */
|
|
270
|
+
function hostPort(listen: Args["listen"]): string {
|
|
271
|
+
const { hostname = "127.0.0.1", port = 0 } = listen ?? {};
|
|
230
272
|
return `${hostname.includes(":") ? `[${hostname}]` : hostname}:${port}`;
|
|
231
273
|
}
|
|
232
274
|
|
|
@@ -268,6 +310,10 @@ function listenToken(file: string | undefined): string | undefined {
|
|
|
268
310
|
* before a runtime or journal starts, and in the bin's terms.
|
|
269
311
|
*/
|
|
270
312
|
function listenOptions(args: Args): ListenOptions {
|
|
313
|
+
if (!("Bun" in globalThis))
|
|
314
|
+
fail(
|
|
315
|
+
`--listen ${hostPort(args.listen)} needs Bun (its WebSocket server is Bun.serve): run this bin with bun, or serve over --stdio or --dial here`,
|
|
316
|
+
);
|
|
271
317
|
const options = {
|
|
272
318
|
...args.listen,
|
|
273
319
|
token: listenToken(args.tokenFile),
|
|
@@ -276,7 +322,7 @@ function listenOptions(args: Args): ListenOptions {
|
|
|
276
322
|
try {
|
|
277
323
|
assertListenOptions(options);
|
|
278
324
|
} catch (error) {
|
|
279
|
-
const where = hostPort(args.listen
|
|
325
|
+
const where = hostPort(args.listen);
|
|
280
326
|
if ((error as { code?: string }).code === "tokenRequired")
|
|
281
327
|
fail(
|
|
282
328
|
`--listen ${where} can be reached from other machines: give it a token (--token-file <path> or $AGENT_SERVER_TOKEN), or listen on 127.0.0.1`,
|
|
@@ -286,30 +332,64 @@ function listenOptions(args: Args): ListenOptions {
|
|
|
286
332
|
return options;
|
|
287
333
|
}
|
|
288
334
|
|
|
335
|
+
/**
|
|
336
|
+
* The journal on this runtime's SQLite: `bun:sqlite` under Bun, `node:sqlite`
|
|
337
|
+
* under Node (the compiled bin). Each adapter loads only when chosen, since
|
|
338
|
+
* neither runtime has the other's module.
|
|
339
|
+
*/
|
|
340
|
+
async function openJournal(path: string) {
|
|
341
|
+
// @ref LLP 0001#d24--bun-runs-the-packages-sources-every-other-runtime-its-compiled-javascript — the bin on either runtime
|
|
342
|
+
return "Bun" in globalThis
|
|
343
|
+
? new (await import("../sync/sqlite.ts")).SqliteSessionJournal(path)
|
|
344
|
+
: new (await import("../sync/node-sqlite.ts")).NodeSqliteSessionJournal(path);
|
|
345
|
+
}
|
|
346
|
+
|
|
289
347
|
const args = parseArgs(process.argv.slice(2));
|
|
290
348
|
if (args.journalPath && (args.mode === "acp" || args.command !== "serve"))
|
|
291
349
|
fail("--journal is supported only for the stdio/listen/dial wire server");
|
|
292
350
|
if (args.command !== "install" && (args.platforms || args.installDir || args.prune))
|
|
293
351
|
fail("--platform, --dir and --prune are install's: agent-server install --dir <path> …");
|
|
352
|
+
// A wire client names each turn's model and level itself.
|
|
353
|
+
if (
|
|
354
|
+
(args.model !== undefined || args.thinking) &&
|
|
355
|
+
(args.mode !== "acp" || args.command !== "serve")
|
|
356
|
+
)
|
|
357
|
+
fail("--model and --thinking apply to --acp only (a wire client names them on each turn)");
|
|
294
358
|
const listening = args.command === "serve" && args.mode === "listen";
|
|
295
359
|
if (!listening && args.tokenFile !== undefined) fail("--token-file applies to --listen only");
|
|
296
360
|
if (!listening && args.allowedOrigins) fail("--allow-origin applies to --listen only");
|
|
297
361
|
const listener = listening ? listenOptions(args) : undefined;
|
|
298
362
|
const credential = args.command === "serve" && args.mode === "dial" ? dialToken() : undefined;
|
|
299
363
|
|
|
300
|
-
const
|
|
364
|
+
const named = args.harnesses?.map((h) => {
|
|
301
365
|
const choice = resolveHarnessName(h);
|
|
302
366
|
if (!choice) fail(`unknown harness: ${h}`);
|
|
303
367
|
// Friendly ACP agent names ("pi", "gemini") ride the acp harness.
|
|
304
368
|
if (choice.acpAgent) args.acpAgent ??= choice.acpAgent;
|
|
305
369
|
return choice.harness;
|
|
306
370
|
});
|
|
371
|
+
// A script plays the scripted harness, alone unless --harness names others too.
|
|
372
|
+
if (args.scriptPosition !== undefined && args.script === undefined)
|
|
373
|
+
fail("--script-position keeps a script's position: give --script <file> too");
|
|
374
|
+
if (args.script !== undefined && args.command === "install")
|
|
375
|
+
fail("--script is the server's: agent-server --script <file>");
|
|
376
|
+
if (args.script !== undefined && named && !named.includes("scripted"))
|
|
377
|
+
fail("--script plays the scripted harness: name it in --harness (--harness scripted,…)");
|
|
378
|
+
if (args.command !== "install" && named?.includes("scripted") && args.script === undefined)
|
|
379
|
+
fail("the scripted harness needs a script: --script <file>");
|
|
380
|
+
const harnesses = named ?? (args.script !== undefined ? ["scripted" as const] : undefined);
|
|
307
381
|
const provision = args.provisionMode ? { mode: args.provisionMode } : {};
|
|
308
382
|
const acpLaunch = resolveAcpLaunch(args.acpAgent ?? process.env.AGENT_SERVER_ACP_AGENT);
|
|
309
|
-
|
|
383
|
+
// `install` runs no agent: an acp harness there has nothing to install, and says so.
|
|
384
|
+
if (args.command !== "install" && harnesses?.includes("acp") && !acpLaunch)
|
|
310
385
|
fail('the acp harness needs an agent: --harness pi|gemini or --acp-agent "<spec>"');
|
|
311
386
|
|
|
312
387
|
if (args.command === "install") {
|
|
388
|
+
// A harness the engine installs nothing for is said, not passed over in silence.
|
|
389
|
+
for (const [i, harness] of (harnesses ?? []).entries())
|
|
390
|
+
if (!toolsFor([harness]).length)
|
|
391
|
+
console.error(nothingToInstall(args.harnesses?.[i] ?? harness, harness));
|
|
392
|
+
if (harnesses && !toolsFor(harnesses).length) process.exit(0);
|
|
313
393
|
try {
|
|
314
394
|
// install always downloads, into the managed cache or --dir; --provision
|
|
315
395
|
// (a serving concern) is deliberately not forwarded.
|
|
@@ -319,11 +399,7 @@ if (args.command === "install") {
|
|
|
319
399
|
...(args.installDir && { dir: args.installDir }),
|
|
320
400
|
...(args.prune && { prune: true }),
|
|
321
401
|
});
|
|
322
|
-
for (const
|
|
323
|
-
console.error(
|
|
324
|
-
`${tool} ${cli.version ?? ""} (${platform}) ready: ${cli.path} (${cli.source})`,
|
|
325
|
-
);
|
|
326
|
-
}
|
|
402
|
+
for (const result of results) console.error(installedLine(result));
|
|
327
403
|
process.exit(0);
|
|
328
404
|
} catch (error) {
|
|
329
405
|
console.error(`install failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -353,9 +429,22 @@ if (args.credentialsUrl) {
|
|
|
353
429
|
}
|
|
354
430
|
}
|
|
355
431
|
|
|
432
|
+
let script: ScriptSource | undefined;
|
|
433
|
+
if (args.script !== undefined) {
|
|
434
|
+
try {
|
|
435
|
+
script = scriptedFile(args.script, {
|
|
436
|
+
...(args.scriptPosition && { position: args.scriptPosition }),
|
|
437
|
+
});
|
|
438
|
+
} catch (error) {
|
|
439
|
+
fail(`--script: ${error instanceof Error ? error.message : String(error)}`);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
356
443
|
const runtime = createAgentRuntime({
|
|
357
444
|
...(harnesses ? { harnesses } : {}),
|
|
358
|
-
|
|
445
|
+
// An ACP agent is told which release drives it (`clientInfo`).
|
|
446
|
+
...(acpLaunch ? { acp: { resolveLaunch: () => acpLaunch, clientVersion: VERSION } } : {}),
|
|
447
|
+
...(script && { scripted: { turn: script } }),
|
|
359
448
|
provision,
|
|
360
449
|
...(args.inheritConfig && { inheritConfig: args.inheritConfig }),
|
|
361
450
|
...(credentials && { credentials }),
|
|
@@ -369,6 +458,8 @@ if (args.mode === "acp") {
|
|
|
369
458
|
const connection = await serveAcpStdio({
|
|
370
459
|
runtime,
|
|
371
460
|
harness: frontedHarness,
|
|
461
|
+
...(args.model && { model: args.model }),
|
|
462
|
+
...(args.thinking && { thinkingLevel: args.thinking }),
|
|
372
463
|
version: VERSION,
|
|
373
464
|
sessionDir:
|
|
374
465
|
process.env.AGENT_SERVER_ACP_SESSION_DIR ??
|
|
@@ -385,11 +476,9 @@ if (args.mode === "acp") {
|
|
|
385
476
|
} else {
|
|
386
477
|
if (args.journalPath && args.bufferSize !== undefined)
|
|
387
478
|
console.error("agent-server: --buffer has no effect with --journal (the journal replays all)");
|
|
388
|
-
let journal:
|
|
479
|
+
let journal: Awaited<ReturnType<typeof openJournal>> | undefined;
|
|
389
480
|
try {
|
|
390
|
-
journal = args.journalPath
|
|
391
|
-
? new (await import("../sync/sqlite.ts")).SqliteSessionJournal(args.journalPath)
|
|
392
|
-
: undefined;
|
|
481
|
+
journal = args.journalPath ? await openJournal(args.journalPath) : undefined;
|
|
393
482
|
} catch (error) {
|
|
394
483
|
// Locked by another server, not a database, a newer schema: say which.
|
|
395
484
|
const why = error instanceof Error ? error.message : String(error);
|
|
@@ -420,7 +509,7 @@ if (args.mode === "acp") {
|
|
|
420
509
|
} catch (error) {
|
|
421
510
|
const code = (error as { code?: string }).code;
|
|
422
511
|
fail(
|
|
423
|
-
`cannot listen on ${hostPort(args.listen
|
|
512
|
+
`cannot listen on ${hostPort(args.listen)}: ${code === "EADDRINUSE" ? "the port is in use" : error instanceof Error ? error.message : error}`,
|
|
424
513
|
);
|
|
425
514
|
}
|
|
426
515
|
console.error(`agent-server ${VERSION} listening on ${bound.url}`);
|
package/src/server/feedback.ts
CHANGED
|
@@ -34,7 +34,7 @@ export interface FeedbackOptions {
|
|
|
34
34
|
fetchImpl?: (url: string, init: RequestInit) => Promise<Response>;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
interface FeedbackResult {
|
|
38
38
|
delivered: boolean;
|
|
39
39
|
threadId: string;
|
|
40
40
|
/** Human-readable lines to print (thread id, guidance, ask). */
|
package/src/server/install.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { chmod, mkdir, readdir, realpath, rm, stat } from "node:fs/promises";
|
|
3
|
+
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
3
4
|
import {
|
|
4
5
|
CLI_TOOLS,
|
|
5
6
|
CliProvisioner,
|
|
@@ -11,7 +12,8 @@ import {
|
|
|
11
12
|
} from "../core/index.ts";
|
|
12
13
|
import { openToAll } from "../core/provision/install-build.ts";
|
|
13
14
|
import { detectPlatform, parsePlatform, platformName } from "../core/provision/platform.ts";
|
|
14
|
-
import {
|
|
15
|
+
import { CLI_RELEASES } from "../core/provision/releases.ts";
|
|
16
|
+
import { CLI_TOOL_SPECS, claudeSdkOnDisk } from "../core/provision/tools.ts";
|
|
15
17
|
import type { AgentHarness } from "../protocol/index.ts";
|
|
16
18
|
|
|
17
19
|
export interface InstallOptions {
|
|
@@ -56,6 +58,50 @@ export function toolsFor(harnesses: AgentHarness[] | undefined): CliTool[] {
|
|
|
56
58
|
return CLI_TOOLS.filter((tool) => needed.has(tool));
|
|
57
59
|
}
|
|
58
60
|
|
|
61
|
+
/**
|
|
62
|
+
* What `install` says of a harness it installs nothing for (`acp`, the ACP
|
|
63
|
+
* agents by name, `scripted`): there is no CLI the engine installs.
|
|
64
|
+
*/
|
|
65
|
+
export function nothingToInstall(name: string, harness: AgentHarness): string {
|
|
66
|
+
const why =
|
|
67
|
+
harness === "scripted"
|
|
68
|
+
? "the scripted harness runs no CLI"
|
|
69
|
+
: "an ACP agent runs from its launch command, which the operator installs";
|
|
70
|
+
return `${name}: nothing to install: the engine installs no CLI for it (${why})`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The Claude Code version the Claude SDK package `version` carries, where
|
|
75
|
+
* this release pins it or the SDK on disk is that version.
|
|
76
|
+
*/
|
|
77
|
+
function claudeCodeVersion(version: string): string | undefined {
|
|
78
|
+
if (CLI_RELEASES.claude.version === version) return CLI_RELEASES.claude.cli;
|
|
79
|
+
const sdk = claudeSdkOnDisk();
|
|
80
|
+
if (sdk?.version !== version) return undefined;
|
|
81
|
+
try {
|
|
82
|
+
return (
|
|
83
|
+
JSON.parse(readFileSync(join(sdk.dir, "package.json"), "utf8")) as {
|
|
84
|
+
claudeCodeVersion?: string;
|
|
85
|
+
}
|
|
86
|
+
).claudeCodeVersion;
|
|
87
|
+
} catch {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The line `install` prints for a CLI it installed, saying what its version
|
|
94
|
+
* is: Claude's is the Claude SDK package's (`0.3.288`), which carries a
|
|
95
|
+
* Claude Code of its own number (`2.1.288`), the one `claude --version` says.
|
|
96
|
+
*/
|
|
97
|
+
export function installedLine({ tool, platform, cli }: InstallResult): string {
|
|
98
|
+
const where = `for ${platform} ready: ${cli.path} (${cli.source})`;
|
|
99
|
+
if (tool === "codex") return `codex: Codex CLI ${cli.version ?? "(version not known)"} ${where}`;
|
|
100
|
+
if (!cli.version) return `claude: Claude Code (version not known) ${where}`;
|
|
101
|
+
const code = claudeCodeVersion(cli.version);
|
|
102
|
+
return `claude: Claude SDK package ${cli.version}${code ? ` (Claude Code ${code})` : ""} ${where}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
59
105
|
/** The platforms named, each one some CLI is published for, or what is wrong. */
|
|
60
106
|
export function platformsFor(names: readonly string[]): PlatformInfo[] {
|
|
61
107
|
const known = [...new Set(CLI_TOOLS.flatMap((tool) => CLI_TOOL_SPECS[tool].platforms))];
|
|
@@ -88,6 +134,34 @@ function stagedBuild(dir: string, path: string): string {
|
|
|
88
134
|
return join(tool, entry);
|
|
89
135
|
}
|
|
90
136
|
|
|
137
|
+
/**
|
|
138
|
+
* `dir` and the parents of it that are missing, created readable and
|
|
139
|
+
* traversable by every user (0755, whatever the umask), as the builds staged
|
|
140
|
+
* in it are: run as root in an image build, the engine's own 0700 would leave
|
|
141
|
+
* a runtime user unable to reach them. A folder that was there is left as it
|
|
142
|
+
* is. The engine's own cache keeps its 0700 (`trustedCacheDirectory`).
|
|
143
|
+
*/
|
|
144
|
+
async function createStagingFolders(dir: string): Promise<void> {
|
|
145
|
+
const missing: string[] = [];
|
|
146
|
+
for (let path = resolve(dir); ; path = dirname(path)) {
|
|
147
|
+
const exists = await stat(path).then(
|
|
148
|
+
() => true,
|
|
149
|
+
(error: NodeJS.ErrnoException) => {
|
|
150
|
+
if (error.code === "ENOENT") return false;
|
|
151
|
+
throw error;
|
|
152
|
+
},
|
|
153
|
+
);
|
|
154
|
+
if (exists || dirname(path) === path) break;
|
|
155
|
+
missing.unshift(path);
|
|
156
|
+
}
|
|
157
|
+
for (const path of missing) {
|
|
158
|
+
await mkdir(path, { mode: 0o755 }).catch((error: NodeJS.ErrnoException) => {
|
|
159
|
+
if (error.code !== "EEXIST") throw error;
|
|
160
|
+
});
|
|
161
|
+
await chmod(path, 0o755);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
91
165
|
/**
|
|
92
166
|
* The builds just staged, readable and runnable by every user, and the
|
|
93
167
|
* folder without the install's records: an owner-only tree baked into an
|
|
@@ -116,7 +190,11 @@ export async function runInstall(options: InstallOptions = {}): Promise<InstallR
|
|
|
116
190
|
...(options.dir && { mode: "pinned", cacheDir: options.dir }),
|
|
117
191
|
};
|
|
118
192
|
const platforms = options.platforms ? platformsFor(options.platforms) : [detectPlatform()];
|
|
119
|
-
if (options.dir)
|
|
193
|
+
if (options.dir) {
|
|
194
|
+
await stageable(options.dir);
|
|
195
|
+
// @ref LLP 0010#p4--staging-for-images-and-app-bundles — what staging creates, every user may reach
|
|
196
|
+
await createStagingFolders(options.dir);
|
|
197
|
+
}
|
|
120
198
|
const create =
|
|
121
199
|
options.createProvisioner ??
|
|
122
200
|
((provisionOptions: ProvisionOptions, platform: PlatformInfo) =>
|
|
@@ -242,8 +242,12 @@ export class JournalSessionStore implements SessionLogStore {
|
|
|
242
242
|
receipt(sessionId: string, turnId: string): TurnReceipt | undefined {
|
|
243
243
|
return this.journal.turn(sessionId, turnId);
|
|
244
244
|
}
|
|
245
|
+
// @ref LLP 0003#commit-before-acknowledging — the latest turn is read for `session/get` alone
|
|
246
|
+
/** `session/get`'s answer: the journal's summary and its latest turn. */
|
|
245
247
|
session(sessionId: string): DurableSession | undefined {
|
|
246
|
-
|
|
248
|
+
const session = this.journal.session(sessionId);
|
|
249
|
+
const lastTurn = session && this.journal.lastTurn(sessionId);
|
|
250
|
+
return session && { ...session, ...(lastTurn && { lastTurn }) };
|
|
247
251
|
}
|
|
248
252
|
confirmStopped(sessionId: string, expectedHeadSeq: number): boolean {
|
|
249
253
|
return this.write(() => this.journal.confirmStopped(sessionId, expectedHeadSeq));
|
package/src/server/transports.ts
CHANGED
|
@@ -30,6 +30,13 @@ export function stdioTransport(
|
|
|
30
30
|
return transport;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* How far past the server's backlog bound (`maxBacklogBytes`) a listener's
|
|
35
|
+
* socket may buffer before Bun closes it: room for the frame that crossed the
|
|
36
|
+
* bound, the `session/overflow` notice behind it, and the responses after it.
|
|
37
|
+
*/
|
|
38
|
+
const SOCKET_HEADROOM_BYTES = 64 * 1024 * 1024;
|
|
39
|
+
|
|
33
40
|
/** A WebSocket as a wire transport: its frames come in line by line, each line goes out as a frame. */
|
|
34
41
|
function socketTransport(
|
|
35
42
|
ws: { send(line: string): unknown; close(): void },
|
|
@@ -135,13 +142,18 @@ function carries(authorization: string | null, token: Buffer): boolean {
|
|
|
135
142
|
* Accept WebSocket clients (agnt's model: the consumer connects to us). Each
|
|
136
143
|
* accepted socket becomes an attached transport, which receives the sessions
|
|
137
144
|
* it subscribes to. It answers native clients, and browsers only from
|
|
138
|
-
* `allowedOrigins`; beyond loopback it requires a `token`.
|
|
145
|
+
* `allowedOrigins`; beyond loopback it requires a `token`. Bun only: under
|
|
146
|
+
* any other runtime it throws an error that says what works there.
|
|
139
147
|
*/
|
|
140
148
|
export function listen(
|
|
141
149
|
server: AgentServer,
|
|
142
150
|
opts: ListenOptions = {},
|
|
143
151
|
): { url: string; port: number; stop(): void } {
|
|
144
152
|
assertListenOptions(opts);
|
|
153
|
+
if (!("Bun" in globalThis))
|
|
154
|
+
throw new Error(
|
|
155
|
+
"listen needs Bun (its WebSocket server is Bun.serve): run under Bun, or here serve the wire over stdio (stdioTransport), dial out to the client (dial), or attach each socket of a WebSocket server of your own (channelTransport, server.attach)",
|
|
156
|
+
);
|
|
145
157
|
const guard = upgradeGuard(opts);
|
|
146
158
|
const bun = Bun.serve<{ socket?: ReturnType<typeof socketTransport> }>({
|
|
147
159
|
port: opts.port ?? 0,
|
|
@@ -157,6 +169,13 @@ export function listen(
|
|
|
157
169
|
: new Response("websocket upgrade required", { status: 426 });
|
|
158
170
|
},
|
|
159
171
|
websocket: {
|
|
172
|
+
// Above the server's own bound: the overflow notice it sends there is
|
|
173
|
+
// never dropped by Bun's (16 MiB by default, the bound's own default).
|
|
174
|
+
backpressureLimit: server.maxBacklogBytes + SOCKET_HEADROOM_BYTES,
|
|
175
|
+
// @ref LLP 0008#backpressure-and-overflow — a connection is told it overflowed, or closed
|
|
176
|
+
// Past it, a send Bun would drop closes the connection instead: the
|
|
177
|
+
// client redials and replays rather than wait for a lost line.
|
|
178
|
+
closeOnBackpressureLimit: true,
|
|
160
179
|
open(ws) {
|
|
161
180
|
ws.data.socket = socketTransport(ws, () => ws.getBufferedAmount());
|
|
162
181
|
server.attach(ws.data.socket.transport);
|