@zvada/agent-server 0.3.18 → 0.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +11 -26
- package/CHANGELOG.md +1005 -1
- package/README.md +35 -39
- package/dist/types/accounts/chatgpt.d.ts +34 -0
- package/dist/types/accounts/chatgpt.d.ts.map +1 -0
- package/dist/types/accounts/check.d.ts +24 -0
- package/dist/types/accounts/check.d.ts.map +1 -0
- package/dist/types/accounts/claude.d.ts +21 -0
- package/dist/types/accounts/claude.d.ts.map +1 -0
- package/dist/types/accounts/endpoint.d.ts +50 -0
- package/dist/types/accounts/endpoint.d.ts.map +1 -0
- package/dist/types/accounts/http.d.ts +38 -0
- package/dist/types/accounts/http.d.ts.map +1 -0
- package/dist/types/accounts/index.d.ts +6 -0
- package/dist/types/accounts/index.d.ts.map +1 -0
- package/dist/types/client/client.d.ts +272 -0
- package/dist/types/client/client.d.ts.map +1 -0
- package/dist/types/client/connection.d.ts +160 -0
- package/dist/types/client/connection.d.ts.map +1 -0
- package/dist/types/client/history.d.ts +8 -0
- package/dist/types/client/history.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +5 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/listeners.d.ts +8 -0
- package/dist/types/client/listeners.d.ts.map +1 -0
- package/dist/types/client/logins.d.ts +35 -0
- package/dist/types/client/logins.d.ts.map +1 -0
- package/dist/types/client/rpc.d.ts +46 -0
- package/dist/types/client/rpc.d.ts.map +1 -0
- package/dist/types/client/streams.d.ts +150 -0
- package/dist/types/client/streams.d.ts.map +1 -0
- package/dist/types/client/transports.d.ts +35 -0
- package/dist/types/client/transports.d.ts.map +1 -0
- package/dist/types/client/turns.d.ts +81 -0
- package/dist/types/client/turns.d.ts.map +1 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts +68 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -0
- package/dist/types/core/agents/acp/adapter.d.ts +39 -0
- package/dist/types/core/agents/acp/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/acp/client.d.ts +90 -0
- package/dist/types/core/agents/acp/client.d.ts.map +1 -0
- package/dist/types/core/agents/acp/known-agents.d.ts +35 -0
- package/dist/types/core/agents/acp/known-agents.d.ts.map +1 -0
- package/dist/types/core/agents/acp/mappings.d.ts +46 -0
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -0
- package/dist/types/core/agents/acp/requests.d.ts +26 -0
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -0
- package/dist/types/core/agents/attachments.d.ts +11 -0
- package/dist/types/core/agents/attachments.d.ts.map +1 -0
- package/dist/types/core/agents/base.d.ts +227 -0
- package/dist/types/core/agents/base.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts +58 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts +26 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +70 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts +54 -0
- package/dist/types/core/agents/claude-code/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/events.d.ts +42 -0
- package/dist/types/core/agents/claude-code/events.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/login.d.ts +61 -0
- package/dist/types/core/agents/claude-code/login.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts +52 -0
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/models.d.ts +30 -0
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/options.d.ts +183 -0
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts +50 -0
- package/dist/types/core/agents/claude-code/outcome.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts +36 -0
- package/dist/types/core/agents/claude-code/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session.d.ts +148 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts +29 -0
- package/dist/types/core/agents/claude-code/spawn.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/spend.d.ts +58 -0
- package/dist/types/core/agents/claude-code/spend.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/tools.d.ts +4 -0
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts +52 -0
- package/dist/types/core/agents/claude-code/turn-usage.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/turn.d.ts +121 -0
- package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts +59 -0
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts +116 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +113 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts +66 -0
- package/dist/types/core/agents/codex-app-server/commands.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts +49 -0
- package/dist/types/core/agents/codex-app-server/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts +12 -0
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts +45 -0
- package/dist/types/core/agents/codex-app-server/events.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts +20 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts +26 -0
- package/dist/types/core/agents/codex-app-server/input.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts +31 -0
- package/dist/types/core/agents/codex-app-server/items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts +38 -0
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +62 -0
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts +67 -0
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts +40 -0
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts +19 -0
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts +99 -0
- package/dist/types/core/agents/codex-app-server/protocol.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts +42 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts +96 -0
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts +53 -0
- package/dist/types/core/agents/codex-app-server/subagents.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts +87 -0
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts +33 -0
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts.map +1 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts +163 -0
- package/dist/types/core/agents/codex-app-server/turn.d.ts.map +1 -0
- package/dist/types/core/agents/config-fingerprint.d.ts +5 -0
- package/dist/types/core/agents/config-fingerprint.d.ts.map +1 -0
- package/dist/types/core/agents/credentials.d.ts +28 -0
- package/dist/types/core/agents/credentials.d.ts.map +1 -0
- package/dist/types/core/agents/elicitation.d.ts +37 -0
- package/dist/types/core/agents/elicitation.d.ts.map +1 -0
- package/dist/types/core/agents/inherit-config.d.ts +18 -0
- package/dist/types/core/agents/inherit-config.d.ts.map +1 -0
- package/dist/types/core/agents/login.d.ts +67 -0
- package/dist/types/core/agents/login.d.ts.map +1 -0
- package/dist/types/core/agents/mcp-config.d.ts +57 -0
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -0
- package/dist/types/core/agents/plan.d.ts +16 -0
- package/dist/types/core/agents/plan.d.ts.map +1 -0
- package/dist/types/core/agents/registry.d.ts +30 -0
- package/dist/types/core/agents/registry.d.ts.map +1 -0
- package/dist/types/core/agents/session-agent.d.ts +48 -0
- package/dist/types/core/agents/session-agent.d.ts.map +1 -0
- package/dist/types/core/agents/session-pool.d.ts +41 -0
- package/dist/types/core/agents/session-pool.d.ts.map +1 -0
- package/dist/types/core/agents/stderr-tail.d.ts +28 -0
- package/dist/types/core/agents/stderr-tail.d.ts.map +1 -0
- package/dist/types/core/agents/thinking-levels.d.ts +4 -0
- package/dist/types/core/agents/thinking-levels.d.ts.map +1 -0
- package/dist/types/core/agents/types.d.ts +124 -0
- package/dist/types/core/agents/types.d.ts.map +1 -0
- package/dist/types/core/diagnostics.d.ts +36 -0
- package/dist/types/core/diagnostics.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +29 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/presets.d.ts +80 -0
- package/dist/types/core/presets.d.ts.map +1 -0
- package/dist/types/core/processes/identity.d.ts +31 -0
- package/dist/types/core/processes/identity.d.ts.map +1 -0
- package/dist/types/core/processes/lifeline.d.ts +47 -0
- package/dist/types/core/processes/lifeline.d.ts.map +1 -0
- package/dist/types/core/processes/native-processes.d.ts +130 -0
- package/dist/types/core/processes/native-processes.d.ts.map +1 -0
- package/dist/types/core/processes/process-table.d.ts +43 -0
- package/dist/types/core/processes/process-table.d.ts.map +1 -0
- package/dist/types/core/provision/cache-trust.d.ts +13 -0
- package/dist/types/core/provision/cache-trust.d.ts.map +1 -0
- package/dist/types/core/provision/cache-usage.d.ts +14 -0
- package/dist/types/core/provision/cache-usage.d.ts.map +1 -0
- package/dist/types/core/provision/checksums.d.ts +46 -0
- package/dist/types/core/provision/checksums.d.ts.map +1 -0
- package/dist/types/core/provision/extract.d.ts +7 -0
- package/dist/types/core/provision/extract.d.ts.map +1 -0
- package/dist/types/core/provision/index.d.ts +5 -0
- package/dist/types/core/provision/index.d.ts.map +1 -0
- package/dist/types/core/provision/install-build.d.ts +36 -0
- package/dist/types/core/provision/install-build.d.ts.map +1 -0
- package/dist/types/core/provision/npm.d.ts +40 -0
- package/dist/types/core/provision/npm.d.ts.map +1 -0
- package/dist/types/core/provision/pins.d.ts +24 -0
- package/dist/types/core/provision/pins.d.ts.map +1 -0
- package/dist/types/core/provision/platform.d.ts +28 -0
- package/dist/types/core/provision/platform.d.ts.map +1 -0
- package/dist/types/core/provision/provisioner.d.ts +189 -0
- package/dist/types/core/provision/provisioner.d.ts.map +1 -0
- package/dist/types/core/provision/releases.d.ts +8 -0
- package/dist/types/core/provision/releases.d.ts.map +1 -0
- package/dist/types/core/provision/tools.d.ts +81 -0
- package/dist/types/core/provision/tools.d.ts.map +1 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts +52 -0
- package/dist/types/core/proxy/anthropic-proxy.d.ts.map +1 -0
- package/dist/types/core/proxy/api-key-store.d.ts +37 -0
- package/dist/types/core/proxy/api-key-store.d.ts.map +1 -0
- package/dist/types/core/proxy/index.d.ts +3 -0
- package/dist/types/core/proxy/index.d.ts.map +1 -0
- package/dist/types/core/proxy/loopback.d.ts +14 -0
- package/dist/types/core/proxy/loopback.d.ts.map +1 -0
- package/dist/types/core/runtime/agent-runtime.d.ts +181 -0
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -0
- package/dist/types/core/runtime/event-processor.d.ts +87 -0
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -0
- package/dist/types/core/runtime/event-sink.d.ts +44 -0
- package/dist/types/core/runtime/event-sink.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-clis.d.ts +10 -0
- package/dist/types/core/runtime/harness-clis.d.ts.map +1 -0
- package/dist/types/core/runtime/harness-logins.d.ts +68 -0
- package/dist/types/core/runtime/harness-logins.d.ts.map +1 -0
- package/dist/types/core/runtime/login-reads.d.ts +28 -0
- package/dist/types/core/runtime/login-reads.d.ts.map +1 -0
- package/dist/types/core/runtime/model-lists.d.ts +37 -0
- package/dist/types/core/runtime/model-lists.d.ts.map +1 -0
- package/dist/types/core/runtime/permission-policy.d.ts +61 -0
- package/dist/types/core/runtime/permission-policy.d.ts.map +1 -0
- package/dist/types/core/runtime/request-broker.d.ts +49 -0
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -0
- package/dist/types/core/runtime/steering.d.ts +38 -0
- package/dist/types/core/runtime/steering.d.ts.map +1 -0
- package/dist/types/core/runtime/turn-outcome.d.ts +21 -0
- package/dist/types/core/runtime/turn-outcome.d.ts.map +1 -0
- package/dist/types/core/runtime/turn.d.ts +121 -0
- package/dist/types/core/runtime/turn.d.ts.map +1 -0
- package/dist/types/core/utils/bounded.d.ts +6 -0
- package/dist/types/core/utils/bounded.d.ts.map +1 -0
- package/dist/types/core/utils/deadline.d.ts +14 -0
- package/dist/types/core/utils/deadline.d.ts.map +1 -0
- package/dist/types/core/utils/errors.d.ts +104 -0
- package/dist/types/core/utils/errors.d.ts.map +1 -0
- package/dist/types/core/utils/is-record.d.ts +3 -0
- package/dist/types/core/utils/is-record.d.ts.map +1 -0
- package/dist/types/core/utils/loopback.d.ts +6 -0
- package/dist/types/core/utils/loopback.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/protocol/account.d.ts +26 -0
- package/dist/types/protocol/account.d.ts.map +1 -0
- package/dist/types/protocol/async-queue.d.ts +21 -0
- package/dist/types/protocol/async-queue.d.ts.map +1 -0
- package/dist/types/protocol/auth.d.ts +228 -0
- package/dist/types/protocol/auth.d.ts.map +1 -0
- package/dist/types/protocol/canonical.d.ts +9 -0
- package/dist/types/protocol/canonical.d.ts.map +1 -0
- package/dist/types/protocol/clis.d.ts +74 -0
- package/dist/types/protocol/clis.d.ts.map +1 -0
- package/dist/types/protocol/config.d.ts +200 -0
- package/dist/types/protocol/config.d.ts.map +1 -0
- package/dist/types/protocol/conversation.d.ts +942 -0
- package/dist/types/protocol/conversation.d.ts.map +1 -0
- package/dist/types/protocol/credentials.d.ts +145 -0
- package/dist/types/protocol/credentials.d.ts.map +1 -0
- package/dist/types/protocol/errors.d.ts +36 -0
- package/dist/types/protocol/errors.d.ts.map +1 -0
- package/dist/types/protocol/execution.d.ts +28 -0
- package/dist/types/protocol/execution.d.ts.map +1 -0
- package/dist/types/protocol/factories.d.ts +94 -0
- package/dist/types/protocol/factories.d.ts.map +1 -0
- package/dist/types/protocol/guards.d.ts +55 -0
- package/dist/types/protocol/guards.d.ts.map +1 -0
- package/dist/types/protocol/harness.d.ts +70 -0
- package/dist/types/protocol/harness.d.ts.map +1 -0
- package/dist/types/protocol/history.d.ts +318 -0
- package/dist/types/protocol/history.d.ts.map +1 -0
- package/dist/types/protocol/ids.d.ts +9 -0
- package/dist/types/protocol/ids.d.ts.map +1 -0
- package/dist/types/protocol/index.d.ts +35 -0
- package/dist/types/protocol/index.d.ts.map +1 -0
- package/dist/types/protocol/lifecycle.d.ts +1190 -0
- package/dist/types/protocol/lifecycle.d.ts.map +1 -0
- package/dist/types/protocol/meta-keys.d.ts +17 -0
- package/dist/types/protocol/meta-keys.d.ts.map +1 -0
- package/dist/types/protocol/meta.d.ts +13 -0
- package/dist/types/protocol/meta.d.ts.map +1 -0
- package/dist/types/protocol/model-catalog.d.ts +11 -0
- package/dist/types/protocol/model-catalog.d.ts.map +1 -0
- package/dist/types/protocol/models.d.ts +107 -0
- package/dist/types/protocol/models.d.ts.map +1 -0
- package/dist/types/protocol/part-input.d.ts +101 -0
- package/dist/types/protocol/part-input.d.ts.map +1 -0
- package/dist/types/protocol/parts.d.ts +357 -0
- package/dist/types/protocol/parts.d.ts.map +1 -0
- package/dist/types/protocol/reduce.d.ts +26 -0
- package/dist/types/protocol/reduce.d.ts.map +1 -0
- package/dist/types/protocol/selectors.d.ts +64 -0
- package/dist/types/protocol/selectors.d.ts.map +1 -0
- package/dist/types/protocol/seq-cursor.d.ts +66 -0
- package/dist/types/protocol/seq-cursor.d.ts.map +1 -0
- package/dist/types/protocol/stop-reasons.d.ts +33 -0
- package/dist/types/protocol/stop-reasons.d.ts.map +1 -0
- package/dist/types/protocol/thinking.d.ts +28 -0
- package/dist/types/protocol/thinking.d.ts.map +1 -0
- package/dist/types/protocol/time.d.ts +21 -0
- package/dist/types/protocol/time.d.ts.map +1 -0
- package/dist/types/protocol/tokens.d.ts +29 -0
- package/dist/types/protocol/tokens.d.ts.map +1 -0
- package/dist/types/protocol/tool-closure.d.ts +25 -0
- package/dist/types/protocol/tool-closure.d.ts.map +1 -0
- package/dist/types/protocol/tool-state.d.ts +209 -0
- package/dist/types/protocol/tool-state.d.ts.map +1 -0
- package/dist/types/protocol/verify.d.ts +52 -0
- package/dist/types/protocol/verify.d.ts.map +1 -0
- package/dist/types/protocol/vocabulary.d.ts +19 -0
- package/dist/types/protocol/vocabulary.d.ts.map +1 -0
- package/dist/types/protocol/wire-api.d.ts +1983 -0
- package/dist/types/protocol/wire-api.d.ts.map +1 -0
- package/dist/types/protocol/wire.d.ts +1758 -0
- package/dist/types/protocol/wire.d.ts.map +1 -0
- package/dist/types/server/acp/binding.d.ts +33 -0
- package/dist/types/server/acp/binding.d.ts.map +1 -0
- package/dist/types/server/acp/session-records.d.ts +17 -0
- package/dist/types/server/acp/session-records.d.ts.map +1 -0
- package/dist/types/server/acp/translate.d.ts +48 -0
- package/dist/types/server/acp/translate.d.ts.map +1 -0
- package/dist/types/server/agent-server.d.ts +121 -0
- package/dist/types/server/agent-server.d.ts.map +1 -0
- package/dist/types/server/feedback.d.ts +37 -0
- package/dist/types/server/feedback.d.ts.map +1 -0
- package/dist/types/server/history.d.ts +15 -0
- package/dist/types/server/history.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +7 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/types/server/install.d.ts +42 -0
- package/dist/types/server/install.d.ts.map +1 -0
- package/dist/types/server/open-parts.d.ts +27 -0
- package/dist/types/server/open-parts.d.ts.map +1 -0
- package/dist/types/server/routes.d.ts +61 -0
- package/dist/types/server/routes.d.ts.map +1 -0
- package/dist/types/server/secrets.d.ts +11 -0
- package/dist/types/server/secrets.d.ts.map +1 -0
- package/dist/types/server/session-gate.d.ts +32 -0
- package/dist/types/server/session-gate.d.ts.map +1 -0
- package/dist/types/server/session-log.d.ts +39 -0
- package/dist/types/server/session-log.d.ts.map +1 -0
- package/dist/types/server/session-store.d.ts +119 -0
- package/dist/types/server/session-store.d.ts.map +1 -0
- package/dist/types/server/subscriptions.d.ts +74 -0
- package/dist/types/server/subscriptions.d.ts.map +1 -0
- package/dist/types/server/transports.d.ts +74 -0
- package/dist/types/server/transports.d.ts.map +1 -0
- package/dist/types/server/wire-error.d.ts +9 -0
- package/dist/types/server/wire-error.d.ts.map +1 -0
- package/dist/types/sync/event-log.d.ts +45 -0
- package/dist/types/sync/event-log.d.ts.map +1 -0
- package/dist/types/sync/fit.d.ts +40 -0
- package/dist/types/sync/fit.d.ts.map +1 -0
- package/dist/types/sync/history-reader.d.ts +8 -0
- package/dist/types/sync/history-reader.d.ts.map +1 -0
- package/dist/types/sync/history-sqlite.d.ts +37 -0
- package/dist/types/sync/history-sqlite.d.ts.map +1 -0
- package/dist/types/sync/history.d.ts +70 -0
- package/dist/types/sync/history.d.ts.map +1 -0
- package/dist/types/sync/index.d.ts +4 -0
- package/dist/types/sync/index.d.ts.map +1 -0
- package/dist/types/sync/journal-sqlite.d.ts +51 -0
- package/dist/types/sync/journal-sqlite.d.ts.map +1 -0
- package/dist/types/sync/journal.d.ts +107 -0
- package/dist/types/sync/journal.d.ts.map +1 -0
- package/dist/types/sync/live-tails.d.ts +30 -0
- package/dist/types/sync/live-tails.d.ts.map +1 -0
- package/dist/types/sync/node-sqlite.d.ts +7 -0
- package/dist/types/sync/node-sqlite.d.ts.map +1 -0
- package/dist/types/sync/projection.d.ts +10 -0
- package/dist/types/sync/projection.d.ts.map +1 -0
- package/dist/types/sync/recovery.d.ts +25 -0
- package/dist/types/sync/recovery.d.ts.map +1 -0
- package/dist/types/sync/retry.d.ts +25 -0
- package/dist/types/sync/retry.d.ts.map +1 -0
- package/dist/types/sync/schema.d.ts +4 -0
- package/dist/types/sync/schema.d.ts.map +1 -0
- package/dist/types/sync/sql.d.ts +38 -0
- package/dist/types/sync/sql.d.ts.map +1 -0
- package/dist/types/sync/sqlite-file.d.ts +9 -0
- package/dist/types/sync/sqlite-file.d.ts.map +1 -0
- package/dist/types/sync/sqlite.d.ts +6 -0
- package/dist/types/sync/sqlite.d.ts.map +1 -0
- package/dist/types/sync/worker.d.ts +63 -0
- package/dist/types/sync/worker.d.ts.map +1 -0
- package/docs/consuming.md +452 -53
- package/docs/deploy.md +218 -47
- package/docs/{sync-experiment.md → durable-sessions.md} +77 -72
- package/docs/feedback.md +116 -0
- package/docs/harnesses.md +212 -88
- package/docs/sync-history.md +29 -13
- package/docs/sync-integration.md +52 -66
- package/package.json +43 -25
- package/src/accounts/chatgpt.ts +194 -0
- package/src/accounts/check.ts +112 -0
- package/src/accounts/claude.ts +111 -0
- package/src/accounts/endpoint.ts +151 -0
- package/src/accounts/http.ts +97 -0
- package/src/accounts/index.ts +19 -0
- package/src/client/client.ts +604 -670
- package/src/client/connection.ts +371 -0
- package/src/client/history.ts +29 -52
- package/src/client/index.ts +11 -2
- package/src/client/listeners.ts +20 -0
- package/src/client/logins.ts +105 -0
- package/src/client/rpc.ts +144 -0
- package/src/client/streams.ts +488 -0
- package/src/client/transports.ts +62 -8
- package/src/client/turns.ts +171 -0
- package/src/core/agents/acp/acp-agent.ts +94 -118
- package/src/core/agents/acp/adapter.ts +20 -9
- package/src/core/agents/acp/client.ts +125 -47
- package/src/core/agents/acp/known-agents.ts +36 -4
- package/src/core/agents/acp/mappings.ts +64 -18
- package/src/core/agents/acp/requests.ts +125 -0
- package/src/core/agents/attachments.ts +18 -0
- package/src/core/agents/base.ts +120 -42
- package/src/core/agents/claude-code/adapter.ts +177 -238
- package/src/core/agents/claude-code/approvals.ts +270 -0
- package/src/core/agents/claude-code/claude-agent.ts +175 -158
- package/src/core/agents/claude-code/credentials.ts +171 -0
- package/src/core/agents/claude-code/events.ts +55 -0
- package/src/core/agents/claude-code/login.ts +269 -0
- package/src/core/agents/claude-code/mcp.ts +206 -0
- package/src/core/agents/claude-code/models.ts +15 -9
- package/src/core/agents/claude-code/options.ts +326 -39
- package/src/core/agents/claude-code/outcome.ts +209 -0
- package/src/core/agents/claude-code/session-pool.ts +136 -0
- package/src/core/agents/claude-code/session.ts +513 -0
- package/src/core/agents/claude-code/spawn.ts +144 -0
- package/src/core/agents/claude-code/spend.ts +160 -0
- package/src/core/agents/claude-code/tools.ts +47 -0
- package/src/core/agents/claude-code/turn-usage.ts +135 -0
- package/src/core/agents/claude-code/turn.ts +232 -0
- package/src/core/agents/codex-app-server/adapter.ts +314 -117
- package/src/core/agents/codex-app-server/client.ts +186 -84
- package/src/core/agents/codex-app-server/codex-agent.ts +343 -0
- package/src/core/agents/codex-app-server/commands.ts +228 -0
- package/src/core/agents/codex-app-server/credentials.ts +126 -0
- package/src/core/agents/codex-app-server/effort.ts +29 -0
- package/src/core/agents/codex-app-server/events.ts +47 -0
- package/src/core/agents/codex-app-server/homes.ts +64 -0
- package/src/core/agents/codex-app-server/input.ts +60 -0
- package/src/core/agents/codex-app-server/items.ts +149 -0
- package/src/core/agents/codex-app-server/login.ts +180 -0
- package/src/core/agents/codex-app-server/mcp.ts +182 -37
- package/src/core/agents/codex-app-server/models.ts +99 -46
- package/src/core/agents/codex-app-server/options.ts +146 -0
- package/src/core/agents/codex-app-server/plan-approval.ts +135 -0
- package/src/core/agents/codex-app-server/protocol.ts +117 -0
- package/src/core/agents/codex-app-server/requests.ts +332 -0
- package/src/core/agents/codex-app-server/session.ts +285 -0
- package/src/core/agents/codex-app-server/subagents.ts +108 -42
- package/src/core/agents/codex-app-server/thread-settings.ts +279 -0
- package/src/core/agents/codex-app-server/turn-items.ts +88 -0
- package/src/core/agents/codex-app-server/turn.ts +463 -0
- package/src/core/agents/config-fingerprint.ts +7 -14
- package/src/core/agents/credentials.ts +98 -0
- package/src/core/agents/elicitation.ts +75 -0
- package/src/core/agents/inherit-config.ts +21 -0
- package/src/core/agents/login.ts +116 -0
- package/src/core/agents/mcp-config.ts +112 -8
- package/src/core/agents/plan.ts +25 -0
- package/src/core/agents/registry.ts +21 -4
- package/src/core/agents/session-agent.ts +96 -4
- package/src/core/agents/{session-store.ts → session-pool.ts} +11 -5
- package/src/core/agents/stderr-tail.ts +75 -0
- package/src/core/agents/types.ts +40 -5
- package/src/core/index.ts +58 -48
- package/src/core/presets.ts +100 -39
- package/src/core/processes/identity.ts +113 -0
- package/src/core/processes/lifeline.ts +170 -0
- package/src/core/processes/native-processes.ts +379 -0
- package/src/core/processes/process-table.ts +174 -0
- package/src/core/provision/cache-trust.ts +121 -0
- package/src/core/provision/cache-usage.ts +69 -0
- package/src/core/provision/checksums.ts +64 -0
- package/src/core/provision/extract.ts +11 -2
- package/src/core/provision/index.ts +4 -1
- package/src/core/provision/install-build.ts +136 -0
- package/src/core/provision/npm.ts +112 -17
- package/src/core/provision/pins.ts +9 -33
- package/src/core/provision/platform.ts +12 -1
- package/src/core/provision/provisioner.ts +329 -397
- package/src/core/provision/releases.ts +86 -0
- package/src/core/provision/tools.ts +329 -0
- package/src/core/proxy/anthropic-proxy.ts +55 -25
- package/src/core/proxy/api-key-store.ts +2 -12
- package/src/core/proxy/loopback.ts +106 -0
- package/src/core/runtime/agent-runtime.ts +327 -498
- package/src/core/runtime/event-processor.ts +197 -70
- package/src/core/runtime/harness-clis.ts +61 -0
- package/src/core/runtime/harness-logins.ts +328 -0
- package/src/core/runtime/login-reads.ts +78 -0
- package/src/core/runtime/model-lists.ts +33 -48
- package/src/core/runtime/permission-policy.ts +113 -0
- package/src/core/runtime/request-broker.ts +204 -0
- package/src/core/runtime/steering.ts +112 -0
- package/src/core/runtime/turn-outcome.ts +30 -0
- package/src/core/runtime/turn.ts +360 -0
- package/src/core/utils/bounded.ts +12 -0
- package/src/core/utils/deadline.ts +38 -0
- package/src/core/utils/errors.ts +113 -21
- package/src/core/utils/is-record.ts +4 -0
- package/src/core/utils/loopback.ts +10 -0
- package/src/protocol/account.ts +104 -0
- package/src/protocol/auth.ts +199 -0
- package/src/protocol/canonical.ts +16 -0
- package/src/protocol/clis.ts +69 -0
- package/src/protocol/config.ts +60 -6
- package/src/protocol/conversation.ts +272 -0
- package/src/protocol/credentials.ts +145 -0
- package/src/protocol/errors.ts +78 -20
- package/src/protocol/execution.ts +5 -2
- package/src/protocol/factories.ts +55 -7
- package/src/protocol/guards.ts +55 -2
- package/src/protocol/harness.ts +56 -6
- package/src/protocol/history.ts +72 -64
- package/src/protocol/ids.ts +0 -12
- package/src/protocol/index.ts +9 -0
- package/src/protocol/lifecycle.ts +250 -79
- package/src/protocol/meta-keys.ts +17 -0
- package/src/protocol/meta.ts +3 -3
- package/src/protocol/models.ts +2 -43
- package/src/protocol/part-input.ts +2 -1
- package/src/protocol/parts.ts +12 -3
- package/src/protocol/reduce.ts +302 -413
- package/src/protocol/selectors.ts +1 -20
- package/src/protocol/seq-cursor.ts +14 -0
- package/src/protocol/stop-reasons.ts +1 -1
- package/src/protocol/thinking.ts +1 -30
- package/src/protocol/time.ts +2 -2
- package/src/protocol/tool-closure.ts +93 -0
- package/src/protocol/tool-state.ts +19 -4
- package/src/protocol/verify.ts +222 -92
- package/src/protocol/vocabulary.ts +21 -5
- package/src/protocol/wire-api.ts +232 -0
- package/src/protocol/wire.ts +351 -64
- package/src/server/acp/binding.ts +63 -103
- package/src/server/acp/session-records.ts +53 -0
- package/src/server/acp/translate.ts +129 -20
- package/src/server/agent-server.ts +223 -387
- package/src/server/bin.ts +280 -78
- package/src/server/feedback.ts +204 -14
- package/src/server/history.ts +116 -122
- package/src/server/index.ts +3 -8
- package/src/server/install.ts +107 -8
- package/src/server/open-parts.ts +95 -0
- package/src/server/routes.ts +391 -0
- package/src/server/secrets.ts +24 -0
- package/src/server/session-gate.ts +69 -0
- package/src/server/session-log.ts +14 -2
- package/src/server/session-store.ts +136 -72
- package/src/server/subscriptions.ts +232 -0
- package/src/server/transports.ts +125 -25
- package/src/server/wire-error.ts +31 -45
- package/src/sync/event-log.ts +31 -3
- package/src/sync/fit.ts +27 -11
- package/src/sync/history-reader.ts +10 -5
- package/src/sync/history-sqlite.ts +37 -42
- package/src/sync/history.ts +9 -15
- package/src/sync/index.ts +17 -5
- package/src/sync/journal-sqlite.ts +162 -76
- package/src/sync/journal.ts +91 -32
- package/src/sync/live-tails.ts +107 -0
- package/src/sync/projection.ts +35 -0
- package/src/sync/recovery.ts +80 -51
- package/src/sync/schema.ts +27 -6
- package/docs/rfds/0001-deterministic-echo-ids.md +0 -44
- package/docs/rfds/0002-native-subagents.md +0 -197
- package/src/client/request.ts +0 -19
- package/src/core/agents/claude-code/generator-session.ts +0 -572
- package/src/core/agents/claude-code/session-manager.ts +0 -166
- package/src/core/agents/codex-app-server/codex-app-server-agent.ts +0 -962
- package/src/core/agents/codex-items.ts +0 -149
- package/src/core/agents/codex-sdk/adapter.ts +0 -237
- package/src/core/agents/codex-sdk/codex-sdk-agent.ts +0 -330
- package/src/core/agents/tool-meta.ts +0 -68
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { mkdir, readdir, rm, stat, utimes, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
/** Builds unused this long are pruned. */
|
|
5
|
+
const PRUNE_AFTER_MS = 14 * 24 * 60 * 60 * 1000;
|
|
6
|
+
/** What an install that died left in `.tmp`; no live install takes this long. */
|
|
7
|
+
const LEFTOVER_AFTER_MS = 24 * 60 * 60 * 1000;
|
|
8
|
+
|
|
9
|
+
/** Where the last use of a cached build is recorded: outside the build, which stays as installed. */
|
|
10
|
+
function usedMarker(root: string, tool: string, entry: string): string {
|
|
11
|
+
return join(root, ".used", `${tool}-${entry}`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Record that a cached build was used now. Best effort: a read-only cache still runs. */
|
|
15
|
+
export async function markUsed(root: string, tool: string, entry: string): Promise<void> {
|
|
16
|
+
const marker = usedMarker(root, tool, entry);
|
|
17
|
+
const now = new Date();
|
|
18
|
+
try {
|
|
19
|
+
await utimes(marker, now, now);
|
|
20
|
+
} catch {
|
|
21
|
+
await mkdir(join(root, ".used"), { recursive: true, mode: 0o700 }).catch(() => {});
|
|
22
|
+
await writeFile(marker, "", { mode: 0o600 }).catch(() => {});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function mtimeOf(path: string): Promise<number | undefined> {
|
|
27
|
+
return (await stat(path).catch(() => undefined))?.mtimeMs;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Remove the cached builds of `tools` whose recorded last use is 14 days old,
|
|
32
|
+
* never one `keep` names (`<tool>/<entry>`), and what dead installs left in
|
|
33
|
+
* `.tmp`. Several products may share one cache with their own pins: each
|
|
34
|
+
* keeps its builds by using them. A build no use was ever recorded for was
|
|
35
|
+
* written by an agent-server that records none (0.3.18 and earlier, which
|
|
36
|
+
* share the default cache and may be running it): only `unrecorded` removes
|
|
37
|
+
* those, by when they were installed (`install --prune`). Returns the builds
|
|
38
|
+
* removed.
|
|
39
|
+
*/
|
|
40
|
+
export async function pruneCache(
|
|
41
|
+
root: string,
|
|
42
|
+
tools: readonly string[],
|
|
43
|
+
keep: ReadonlySet<string>,
|
|
44
|
+
unrecorded: boolean,
|
|
45
|
+
): Promise<string[]> {
|
|
46
|
+
const now = Date.now();
|
|
47
|
+
const removed: string[] = [];
|
|
48
|
+
for (const tool of tools) {
|
|
49
|
+
const entries = await readdir(join(root, tool)).catch(() => [] as string[]);
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
if (entry.startsWith(".") || keep.has(`${tool}/${entry}`)) continue;
|
|
52
|
+
const marker = usedMarker(root, tool, entry);
|
|
53
|
+
const used =
|
|
54
|
+
(await mtimeOf(marker)) ??
|
|
55
|
+
(unrecorded ? await mtimeOf(join(root, tool, entry)) : undefined);
|
|
56
|
+
if (used === undefined || now - used < PRUNE_AFTER_MS) continue;
|
|
57
|
+
await rm(join(root, tool, entry), { recursive: true, force: true });
|
|
58
|
+
await rm(marker, { force: true });
|
|
59
|
+
removed.push(`${tool}/${entry}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (const entry of await readdir(join(root, ".tmp")).catch(() => [] as string[])) {
|
|
63
|
+
const path = join(root, ".tmp", entry);
|
|
64
|
+
const changed = await mtimeOf(path);
|
|
65
|
+
if (changed !== undefined && now - changed > LEFTOVER_AFTER_MS)
|
|
66
|
+
await rm(path, { recursive: true, force: true });
|
|
67
|
+
}
|
|
68
|
+
return removed;
|
|
69
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { createReadStream } from "node:fs";
|
|
3
|
+
import type { CliTool } from "./tools.ts";
|
|
4
|
+
|
|
5
|
+
/** One platform's build of a pinned version, as `bun run releases:refresh` recorded it. */
|
|
6
|
+
export interface CliBuild {
|
|
7
|
+
/** The npm tarball's subresource integrity (`sha512-…`). */
|
|
8
|
+
readonly integrity: string;
|
|
9
|
+
/** The binary's sha256, where its vendor signs a manifest of it (Claude). */
|
|
10
|
+
readonly sha256?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** A pinned version of one CLI and its builds, by platform as the cache names them. */
|
|
14
|
+
export interface CliRelease {
|
|
15
|
+
readonly version: string;
|
|
16
|
+
/** For the reader: the version the binary reports, where the package's is another (Claude's SDK version). */
|
|
17
|
+
readonly cli?: string;
|
|
18
|
+
readonly builds: Readonly<Record<string, CliBuild>>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type CliReleases = Readonly<Record<CliTool, CliRelease>>;
|
|
22
|
+
|
|
23
|
+
/** A binary's sha256 that something on this machine vouches for, and what. */
|
|
24
|
+
export interface LocalBuild {
|
|
25
|
+
readonly sha256: string;
|
|
26
|
+
/** Said once when it is what a download is checked against: "the installed Claude SDK's manifest". */
|
|
27
|
+
readonly vouchedBy: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* What a download must match, and what vouches for it: this release's table
|
|
32
|
+
* (`release`), something on this machine (`local`), or only the registry it
|
|
33
|
+
* comes from (`registry`).
|
|
34
|
+
*/
|
|
35
|
+
export type ExpectedBuild =
|
|
36
|
+
| { readonly source: "release"; readonly integrity: string; readonly sha256?: string }
|
|
37
|
+
| { readonly source: "local"; readonly sha256: string; readonly vouchedBy: string }
|
|
38
|
+
| { readonly source: "registry" };
|
|
39
|
+
|
|
40
|
+
// @ref LLP 0010#p1--the-release-pins-every-build-it-can-download — trust is pinned at release, not read from the registry
|
|
41
|
+
/**
|
|
42
|
+
* What the build of `tool` at `version` for `suffix` must be. A version this
|
|
43
|
+
* release pins is checked against its table, whatever registry serves it; any
|
|
44
|
+
* other against what this machine knows of it, else only the registry.
|
|
45
|
+
*/
|
|
46
|
+
export function expectedBuild(
|
|
47
|
+
tool: CliTool,
|
|
48
|
+
version: string,
|
|
49
|
+
suffix: string,
|
|
50
|
+
releases: CliReleases,
|
|
51
|
+
local?: (suffix: string, version: string) => LocalBuild | undefined,
|
|
52
|
+
): ExpectedBuild {
|
|
53
|
+
const release = releases[tool];
|
|
54
|
+
const build = release.version === version ? release.builds[suffix] : undefined;
|
|
55
|
+
if (build) return { source: "release", ...build };
|
|
56
|
+
const known = local?.(suffix, version);
|
|
57
|
+
return known ? { source: "local", ...known } : { source: "registry" };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function sha256Of(path: string): Promise<string> {
|
|
61
|
+
const hash = createHash("sha256");
|
|
62
|
+
for await (const chunk of createReadStream(path)) hash.update(chunk as Buffer);
|
|
63
|
+
return hash.digest("hex");
|
|
64
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { CliProvisionError } from "../utils/errors.ts";
|
|
3
3
|
|
|
4
|
+
/** Extracting a few hundred megabytes takes seconds; a `tar` still running after this is stuck. */
|
|
5
|
+
const EXTRACT_TIMEOUT_MS = 5 * 60_000;
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* Extract a .tgz into a directory using the system `tar` (BSD, GNU, and
|
|
6
9
|
* Windows 10+ libarchive all accept these flags). npm tarballs are small
|
|
@@ -10,6 +13,7 @@ export async function extractTarGz(tgzPath: string, destDir: string): Promise<vo
|
|
|
10
13
|
await new Promise<void>((resolve, reject) => {
|
|
11
14
|
const proc = spawn("tar", ["-xzf", tgzPath, "-C", destDir], {
|
|
12
15
|
stdio: ["ignore", "ignore", "pipe"],
|
|
16
|
+
timeout: EXTRACT_TIMEOUT_MS,
|
|
13
17
|
});
|
|
14
18
|
let stderr = "";
|
|
15
19
|
proc.stderr?.on("data", (chunk: Buffer) => {
|
|
@@ -23,9 +27,14 @@ export async function extractTarGz(tgzPath: string, destDir: string): Promise<vo
|
|
|
23
27
|
),
|
|
24
28
|
),
|
|
25
29
|
);
|
|
26
|
-
proc.on("exit", (code) => {
|
|
30
|
+
proc.on("exit", (code, signal) => {
|
|
27
31
|
if (code === 0) resolve();
|
|
28
|
-
else
|
|
32
|
+
else
|
|
33
|
+
reject(
|
|
34
|
+
new CliProvisionError(
|
|
35
|
+
`tar -xzf ${tgzPath} ${signal ? `was stopped (${signal}) after ${EXTRACT_TIMEOUT_MS / 60_000} min` : `exited ${code}`}: ${stderr.trim()}`,
|
|
36
|
+
),
|
|
37
|
+
);
|
|
29
38
|
});
|
|
30
39
|
});
|
|
31
40
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// CLI provisioning — resolve/download the native CLIs the harnesses spawn.
|
|
2
|
-
export {
|
|
2
|
+
export { DEFAULT_PINS } from "./pins.ts";
|
|
3
|
+
export { CLI_TOOLS, type CliTool, toolForHarness } from "./tools.ts";
|
|
3
4
|
export { type PlatformInfo, detectPlatform } from "./platform.ts";
|
|
4
5
|
export {
|
|
6
|
+
type CliProgress,
|
|
5
7
|
CliProvisioner,
|
|
8
|
+
type CliStatus,
|
|
6
9
|
type ProvisionMode,
|
|
7
10
|
type ProvisionOptions,
|
|
8
11
|
type ProvisionerDeps,
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { chmod, lstat, mkdir, readdir, rename, rm } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { CliProvisionError } from "../utils/errors.ts";
|
|
5
|
+
import { managedDirectory, trustedBinaryIn } from "./cache-trust.ts";
|
|
6
|
+
import { type ExpectedBuild, sha256Of } from "./checksums.ts";
|
|
7
|
+
import { type DownloadTimeouts, downloadWithIntegrity, fetchDist, withoutSecrets } from "./npm.ts";
|
|
8
|
+
import { type CliToolSpec, type ToolPackage, binaryIn } from "./tools.ts";
|
|
9
|
+
|
|
10
|
+
/** At most this often an install reports its bytes. */
|
|
11
|
+
const PROGRESS_INTERVAL_MS = 250;
|
|
12
|
+
|
|
13
|
+
/** One build to install into the cache, and what it must match. */
|
|
14
|
+
export interface BuildInstall {
|
|
15
|
+
spec: CliToolSpec;
|
|
16
|
+
pkg: ToolPackage;
|
|
17
|
+
expected: ExpectedBuild;
|
|
18
|
+
/** The trusted cache root, and the build's folder in it. */
|
|
19
|
+
root: string;
|
|
20
|
+
dir: string;
|
|
21
|
+
registry: string;
|
|
22
|
+
fetch: typeof fetch;
|
|
23
|
+
timeouts: DownloadTimeouts;
|
|
24
|
+
extract: (tgzPath: string, destDir: string) => Promise<void>;
|
|
25
|
+
/** The bytes so far: downloading, then verifying. */
|
|
26
|
+
onProgress: (
|
|
27
|
+
phase: "downloading" | "verifying",
|
|
28
|
+
receivedBytes: number,
|
|
29
|
+
totalBytes?: number,
|
|
30
|
+
) => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A tree every user may read and run, and only its owner write: folders
|
|
35
|
+
* 0755, files 0644, runnable ones 0755, never through a symlink. A staged
|
|
36
|
+
* build gets it before its rename, so what a 002 umask unpacked (Ubuntu's
|
|
37
|
+
* default) is not refused as writable by others, and a process killed after
|
|
38
|
+
* the rename leaves a finished build.
|
|
39
|
+
*/
|
|
40
|
+
export async function openToAll(path: string): Promise<void> {
|
|
41
|
+
const info = await lstat(path);
|
|
42
|
+
if (info.isSymbolicLink()) return;
|
|
43
|
+
if (info.isDirectory()) {
|
|
44
|
+
await chmod(path, 0o755);
|
|
45
|
+
for (const entry of await readdir(path)) await openToAll(join(path, entry));
|
|
46
|
+
} else if (info.isFile()) await chmod(path, info.mode & 0o100 ? 0o755 : 0o644);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function noBinary(pkg: ToolPackage): CliProvisionError {
|
|
50
|
+
return new CliProvisionError(`downloaded ${pkg.name}@${pkg.registryVersion} has no binary`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Download a build, check it against what it must match, unpack it in a
|
|
55
|
+
* staging folder and rename it into `dir`. Two processes installing the same
|
|
56
|
+
* build at once both download it, and the version-keyed rename decides: the
|
|
57
|
+
* one that loses adopts the winner's tree. Answers the bytes downloaded.
|
|
58
|
+
*/
|
|
59
|
+
export async function installBuild(job: BuildInstall): Promise<number> {
|
|
60
|
+
const { spec, pkg, expected, root, dir } = job;
|
|
61
|
+
const staging = join(
|
|
62
|
+
root,
|
|
63
|
+
".tmp",
|
|
64
|
+
`${pkg.name.replace("/", "-")}-${pkg.registryVersion}-${process.pid}-${randomBytes(4).toString("hex")}`,
|
|
65
|
+
);
|
|
66
|
+
try {
|
|
67
|
+
managedDirectory(root, dirname(staging), true);
|
|
68
|
+
await mkdir(staging, { mode: 0o700 });
|
|
69
|
+
const dist = await fetchDist(
|
|
70
|
+
job.registry,
|
|
71
|
+
pkg.name,
|
|
72
|
+
pkg.registryVersion,
|
|
73
|
+
job.fetch,
|
|
74
|
+
job.timeouts,
|
|
75
|
+
);
|
|
76
|
+
if (expected.source === "release" && dist.integrity !== expected.integrity) {
|
|
77
|
+
throw new CliProvisionError(
|
|
78
|
+
`${withoutSecrets(job.registry)} serves another ${pkg.name}@${pkg.registryVersion} than this release pins ` +
|
|
79
|
+
`(${dist.integrity.slice(0, 24)}…, pinned ${expected.integrity.slice(0, 24)}…)`,
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
const tgz = join(staging, "package.tgz");
|
|
83
|
+
let reportedAt = 0;
|
|
84
|
+
const bytes = await downloadWithIntegrity(
|
|
85
|
+
dist.tarball,
|
|
86
|
+
tgz,
|
|
87
|
+
expected.source === "release" ? expected.integrity : dist.integrity,
|
|
88
|
+
job.fetch,
|
|
89
|
+
{
|
|
90
|
+
timeouts: job.timeouts,
|
|
91
|
+
onBytes: (receivedBytes, totalBytes) => {
|
|
92
|
+
const now = Date.now();
|
|
93
|
+
if (now - reportedAt < PROGRESS_INTERVAL_MS && receivedBytes !== totalBytes) return;
|
|
94
|
+
reportedAt = now;
|
|
95
|
+
job.onProgress("downloading", receivedBytes, totalBytes);
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
);
|
|
99
|
+
job.onProgress("verifying", bytes, bytes);
|
|
100
|
+
const extracted = join(staging, "x");
|
|
101
|
+
await mkdir(extracted, { mode: 0o700 });
|
|
102
|
+
await job.extract(tgz, extracted);
|
|
103
|
+
const payload = await spec.payload(extracted);
|
|
104
|
+
const binary = binaryIn(payload, spec.binaries);
|
|
105
|
+
if (!binary) throw noBinary(pkg);
|
|
106
|
+
const sha256 = expected.source === "registry" ? undefined : expected.sha256;
|
|
107
|
+
if (sha256) {
|
|
108
|
+
const actual = await sha256Of(binary);
|
|
109
|
+
if (actual !== sha256) {
|
|
110
|
+
throw new CliProvisionError(
|
|
111
|
+
`${pkg.name}@${pkg.registryVersion}'s binary is not the build ${
|
|
112
|
+
expected.source === "local" ? expected.vouchedBy : "this release pins"
|
|
113
|
+
} names (sha256 ${actual}, expected ${sha256})`,
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
await chmod(binary, 0o755);
|
|
118
|
+
await openToAll(payload);
|
|
119
|
+
managedDirectory(root, dirname(dir), true);
|
|
120
|
+
try {
|
|
121
|
+
await rename(payload, dir);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
// Lost the race with another process installing the same build: the
|
|
124
|
+
// directory is version-keyed, so its tree is what we would have written.
|
|
125
|
+
if (trustedBinaryIn(root, dir, spec.binaries)) return bytes;
|
|
126
|
+
throw new CliProvisionError(
|
|
127
|
+
`${dir} is there but holds no ${spec.binaries[0]}: remove it, and it installs again`,
|
|
128
|
+
{ cause: error },
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
if (!trustedBinaryIn(root, dir, spec.binaries)) throw noBinary(pkg);
|
|
132
|
+
return bytes;
|
|
133
|
+
} finally {
|
|
134
|
+
await rm(staging, { recursive: true, force: true });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { once } from "node:events";
|
|
3
3
|
import { createWriteStream } from "node:fs";
|
|
4
|
+
import { withTimeout } from "../utils/deadline.ts";
|
|
4
5
|
import { CliProvisionError } from "../utils/errors.ts";
|
|
5
6
|
|
|
6
7
|
export const DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org";
|
|
@@ -14,22 +15,70 @@ export interface NpmDist {
|
|
|
14
15
|
|
|
15
16
|
type FetchLike = (url: string, init?: RequestInit) => Promise<Response>;
|
|
16
17
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* `text` with each URL in it shown without credentials or query, where a
|
|
20
|
+
* mirror's token or a signed link would be: what an error or a log line may
|
|
21
|
+
* say, since a turn's error reaches every connection and the journal.
|
|
22
|
+
*/
|
|
23
|
+
export function withoutSecrets(text: string): string {
|
|
24
|
+
return text.replace(/\b[a-z][a-z0-9+.-]*:\/\/[^\s'"()]+/gi, (found) => {
|
|
25
|
+
try {
|
|
26
|
+
const url = new URL(found);
|
|
27
|
+
// A bare host keeps no slash it did not have.
|
|
28
|
+
const path = url.pathname === "/" && !found.endsWith("/") ? "" : url.pathname;
|
|
29
|
+
return `${url.protocol}//${url.host}${path}`;
|
|
30
|
+
} catch {
|
|
31
|
+
return "<url>";
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** How long a request may wait for its response, and a download for its next bytes. */
|
|
37
|
+
export interface DownloadTimeouts {
|
|
38
|
+
responseMs: number;
|
|
39
|
+
stallMs: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const DEFAULT_DOWNLOAD_TIMEOUTS: DownloadTimeouts = { responseMs: 30_000, stallMs: 30_000 };
|
|
43
|
+
|
|
44
|
+
/** A response, and the abort that ends its body (a stalled download's). */
|
|
45
|
+
interface OpenResponse {
|
|
46
|
+
res: Response;
|
|
47
|
+
abort: AbortController;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** One retry on network-level failures and a response that never came; 4xx/5xx are not retried. */
|
|
51
|
+
async function fetchOk(
|
|
52
|
+
fetchImpl: FetchLike,
|
|
53
|
+
url: string,
|
|
54
|
+
timeouts: DownloadTimeouts,
|
|
55
|
+
): Promise<OpenResponse> {
|
|
19
56
|
let lastError: unknown;
|
|
20
57
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
58
|
+
const abort = new AbortController();
|
|
59
|
+
const timer = setTimeout(() => abort.abort(), timeouts.responseMs);
|
|
21
60
|
try {
|
|
22
|
-
const res = await fetchImpl(url);
|
|
61
|
+
const res = await fetchImpl(url, { signal: abort.signal });
|
|
23
62
|
if (!res.ok) {
|
|
24
|
-
|
|
63
|
+
await res.body?.cancel().catch(() => {});
|
|
64
|
+
throw new CliProvisionError(
|
|
65
|
+
`GET ${withoutSecrets(url)} failed: ${res.status} ${res.statusText}`,
|
|
66
|
+
);
|
|
25
67
|
}
|
|
26
|
-
return res;
|
|
68
|
+
return { res, abort };
|
|
27
69
|
} catch (error) {
|
|
28
70
|
if (error instanceof CliProvisionError) throw error;
|
|
29
|
-
lastError =
|
|
71
|
+
lastError = abort.signal.aborted
|
|
72
|
+
? new Error(`no response within ${timeouts.responseMs / 1000} s`)
|
|
73
|
+
: error;
|
|
74
|
+
} finally {
|
|
75
|
+
clearTimeout(timer);
|
|
30
76
|
}
|
|
31
77
|
}
|
|
32
|
-
throw new CliProvisionError(
|
|
78
|
+
throw new CliProvisionError(
|
|
79
|
+
`GET ${withoutSecrets(url)} failed: ${withoutSecrets(lastError instanceof Error ? lastError.message : String(lastError))}`,
|
|
80
|
+
{ cause: lastError },
|
|
81
|
+
);
|
|
33
82
|
}
|
|
34
83
|
|
|
35
84
|
/**
|
|
@@ -42,12 +91,21 @@ export async function fetchDist(
|
|
|
42
91
|
packageName: string,
|
|
43
92
|
version: string,
|
|
44
93
|
fetchImpl: FetchLike = fetch,
|
|
94
|
+
timeouts: DownloadTimeouts = DEFAULT_DOWNLOAD_TIMEOUTS,
|
|
45
95
|
): Promise<NpmDist> {
|
|
46
96
|
// Scoped names keep the literal `@` but escape the inner slash.
|
|
47
97
|
const base = registry.replace(/\/+$/, "");
|
|
48
98
|
const url = `${base}/${packageName.replace("/", "%2F")}/${version}`;
|
|
49
|
-
const res = await fetchOk(fetchImpl, url);
|
|
50
|
-
|
|
99
|
+
const { res, abort } = await fetchOk(fetchImpl, url, timeouts);
|
|
100
|
+
// The body has the same deadline as the headers: a proxy can send those and stall.
|
|
101
|
+
const read = await withTimeout(res.json(), timeouts.responseMs);
|
|
102
|
+
if (!read) {
|
|
103
|
+
abort.abort();
|
|
104
|
+
throw new CliProvisionError(
|
|
105
|
+
`GET ${withoutSecrets(url)} failed: no response within ${timeouts.responseMs / 1000} s`,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
const body = read.value as { dist?: { tarball?: string; integrity?: string } };
|
|
51
109
|
const { tarball, integrity } = body.dist ?? {};
|
|
52
110
|
if (!tarball || !integrity) {
|
|
53
111
|
throw new CliProvisionError(
|
|
@@ -57,23 +115,46 @@ export async function fetchDist(
|
|
|
57
115
|
return { tarball, integrity };
|
|
58
116
|
}
|
|
59
117
|
|
|
118
|
+
export interface DownloadOptions {
|
|
119
|
+
timeouts?: DownloadTimeouts;
|
|
120
|
+
/** The bytes received so far, and the total when the response states it. */
|
|
121
|
+
onBytes?: (received: number, total: number | undefined) => void;
|
|
122
|
+
}
|
|
123
|
+
|
|
60
124
|
/**
|
|
61
125
|
* Stream a tarball to disk, hashing as it lands, and reject on integrity
|
|
62
126
|
* mismatch. Only sha512 (what the npm registry publishes) is supported.
|
|
63
|
-
*
|
|
127
|
+
* A download that receives nothing for `stallMs` fails. Returns the byte
|
|
128
|
+
* count for progress logs.
|
|
64
129
|
*/
|
|
65
130
|
export async function downloadWithIntegrity(
|
|
66
131
|
url: string,
|
|
67
132
|
destFile: string,
|
|
68
133
|
integrity: string,
|
|
69
134
|
fetchImpl: FetchLike = fetch,
|
|
135
|
+
options: DownloadOptions = {},
|
|
70
136
|
): Promise<number> {
|
|
71
137
|
const expected = /^sha512-([A-Za-z0-9+/=]+)$/.exec(integrity)?.[1];
|
|
72
138
|
if (!expected) {
|
|
73
139
|
throw new CliProvisionError(`Unsupported integrity format (want sha512-…): ${integrity}`);
|
|
74
140
|
}
|
|
75
|
-
const
|
|
76
|
-
|
|
141
|
+
const timeouts = options.timeouts ?? DEFAULT_DOWNLOAD_TIMEOUTS;
|
|
142
|
+
const { res, abort } = await fetchOk(fetchImpl, url, timeouts);
|
|
143
|
+
if (!res.body) throw new CliProvisionError(`GET ${withoutSecrets(url)} returned no body`);
|
|
144
|
+
const length = Number(res.headers.get("content-length"));
|
|
145
|
+
const stated = Number.isSafeInteger(length) && length > 0 ? length : undefined;
|
|
146
|
+
// Read by hand, so a stall ends the read even where the fetch ignores its signal.
|
|
147
|
+
const reader = res.body.getReader();
|
|
148
|
+
let stalled = false;
|
|
149
|
+
let stall: ReturnType<typeof setTimeout> | undefined;
|
|
150
|
+
const armStall = () => {
|
|
151
|
+
clearTimeout(stall);
|
|
152
|
+
stall = setTimeout(() => {
|
|
153
|
+
stalled = true;
|
|
154
|
+
abort.abort();
|
|
155
|
+
void reader.cancel().catch(() => {});
|
|
156
|
+
}, timeouts.stallMs);
|
|
157
|
+
};
|
|
77
158
|
|
|
78
159
|
const hash = createHash("sha512");
|
|
79
160
|
const out = createWriteStream(destFile);
|
|
@@ -85,12 +166,20 @@ export async function downloadWithIntegrity(
|
|
|
85
166
|
});
|
|
86
167
|
let bytes = 0;
|
|
87
168
|
try {
|
|
88
|
-
|
|
169
|
+
while (true) {
|
|
170
|
+
// Only the wait for the network counts as a stall, not for the disk.
|
|
171
|
+
armStall();
|
|
172
|
+
const { done, value } = await reader.read();
|
|
173
|
+
clearTimeout(stall);
|
|
174
|
+
if (stalled) throw new Error("stalled");
|
|
175
|
+
if (done) break;
|
|
89
176
|
if (streamError) throw streamError;
|
|
90
|
-
hash.update(
|
|
91
|
-
bytes +=
|
|
177
|
+
hash.update(value);
|
|
178
|
+
bytes += value.byteLength;
|
|
179
|
+
// A size the response got wrong is no size.
|
|
180
|
+
options.onBytes?.(bytes, stated !== undefined && bytes <= stated ? stated : undefined);
|
|
92
181
|
// events.once rejects on 'error' and removes its listeners either way.
|
|
93
|
-
if (!out.write(
|
|
182
|
+
if (!out.write(value)) await once(out, "drain");
|
|
94
183
|
}
|
|
95
184
|
if (streamError) throw streamError;
|
|
96
185
|
// Reject on 'error' too: a failure during the terminal flush (e.g.
|
|
@@ -101,13 +190,19 @@ export async function downloadWithIntegrity(
|
|
|
101
190
|
out.end(() => (streamError ? reject(streamError as Error) : resolve()));
|
|
102
191
|
});
|
|
103
192
|
} catch (error) {
|
|
193
|
+
clearTimeout(stall);
|
|
194
|
+
void reader.cancel().catch(() => {});
|
|
104
195
|
out.destroy();
|
|
196
|
+
if (stalled)
|
|
197
|
+
throw new CliProvisionError(
|
|
198
|
+
`GET ${withoutSecrets(url)} stalled: nothing received for ${timeouts.stallMs / 1000} s after ${bytes} bytes`,
|
|
199
|
+
);
|
|
105
200
|
throw error;
|
|
106
201
|
}
|
|
107
202
|
const actual = hash.digest("base64");
|
|
108
203
|
if (actual !== expected) {
|
|
109
204
|
throw new CliProvisionError(
|
|
110
|
-
`Integrity mismatch for ${url}: expected sha512-${expected}, got sha512-${actual}`,
|
|
205
|
+
`Integrity mismatch for ${withoutSecrets(url)}: expected sha512-${expected}, got sha512-${actual}`,
|
|
111
206
|
);
|
|
112
207
|
}
|
|
113
208
|
return bytes;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The managed CLIs. Each native harness maps onto exactly one of these; the
|
|
5
|
-
* `acp` harness maps onto none (its agent binaries are arbitrary third-party
|
|
6
|
-
* commands the operator supplies, not something we pin or download).
|
|
7
|
-
*/
|
|
8
|
-
export const CLI_TOOLS = ["claude", "codex"] as const;
|
|
9
|
-
export type CliTool = (typeof CLI_TOOLS)[number];
|
|
1
|
+
import type { CliTool } from "./tools.ts";
|
|
10
2
|
|
|
11
3
|
/**
|
|
12
4
|
* The CLI versions this engine release is tested against — the versions
|
|
@@ -19,15 +11,15 @@ export type CliTool = (typeof CLI_TOOLS)[number];
|
|
|
19
11
|
* version wins over this pin so the pair can never skew.
|
|
20
12
|
* - `codex` is the `@openai/codex` platform-package version the
|
|
21
13
|
* codex-app-server adapter's protocol snapshot was verified against (see
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* `pinned` mode); embedders wanting an exact codex-sdk pairing there can
|
|
27
|
-
* set `provision.pins.codex` to their SDK's vendored version.
|
|
14
|
+
* AGENTS.md "Verifying harness protocols"). Bump after re-verifying. The pin
|
|
15
|
+
* governs downloads (compiled binaries, bare sandboxes, `pinned` mode); in
|
|
16
|
+
* `auto` an installed `@openai/codex` package (a lockfile's) runs instead,
|
|
17
|
+
* and a `codex` on PATH only in `system` mode.
|
|
28
18
|
*
|
|
29
|
-
* After any bump, run `bun run
|
|
30
|
-
*
|
|
19
|
+
* After any bump, run `bun run releases:refresh` (each platform's build and
|
|
20
|
+
* its checksums, `releases.ts`) and `bun run models:refresh` (the model
|
|
21
|
+
* catalog, which records the versions that listed it); tests fail until both
|
|
22
|
+
* match these pins.
|
|
31
23
|
*/
|
|
32
24
|
export const DEFAULT_PINS: Record<CliTool, string> = {
|
|
33
25
|
// 0.3.288 verified 2026-10-03: the paired CLI honors `--thinking-display
|
|
@@ -43,19 +35,3 @@ export const DEFAULT_PINS: Record<CliTool, string> = {
|
|
|
43
35
|
// fails until the first releases it.
|
|
44
36
|
codex: "0.160.0",
|
|
45
37
|
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Which managed CLI a harness runs on — `undefined` for unmanaged harnesses
|
|
49
|
-
* (`acp`). Exhaustive by construction: adding a harness fails to compile here
|
|
50
|
-
* until someone decides whether it is provisioner-managed.
|
|
51
|
-
*/
|
|
52
|
-
const TOOL_FOR_HARNESS: Record<AgentHarness, CliTool | undefined> = {
|
|
53
|
-
"claude-code": "claude",
|
|
54
|
-
"codex-sdk": "codex",
|
|
55
|
-
"codex-app-server": "codex",
|
|
56
|
-
acp: undefined,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export function toolForHarness(harness: AgentHarness): CliTool | undefined {
|
|
60
|
-
return TOOL_FOR_HARNESS[harness];
|
|
61
|
-
}
|
|
@@ -33,12 +33,23 @@ export function detectPlatform(): PlatformInfo {
|
|
|
33
33
|
return { platform: process.platform, arch: process.arch, musl: isMusl() };
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/** A platform as the cache and `install --platform` name it: `darwin-arm64`, `linux-x64-musl`. */
|
|
37
|
+
export function platformName(p: PlatformInfo): string {
|
|
38
|
+
return `${p.platform}-${p.arch}${p.musl ? "-musl" : ""}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The platform a name from `platformName` stands for (one a vendor publishes: `CliToolSpec.platforms`). */
|
|
42
|
+
export function parsePlatform(name: string): PlatformInfo {
|
|
43
|
+
const [platform = "", arch = "", musl] = name.split("-");
|
|
44
|
+
return { platform, arch, musl: musl === "musl" };
|
|
45
|
+
}
|
|
46
|
+
|
|
36
47
|
/**
|
|
37
48
|
* Suffix of `@anthropic-ai/claude-agent-sdk-<suffix>` — the platform package
|
|
38
49
|
* carrying the native `claude` binary. Claude ships dedicated musl builds.
|
|
39
50
|
*/
|
|
40
51
|
export function claudePackageSuffix(p: PlatformInfo): string {
|
|
41
|
-
return
|
|
52
|
+
return platformName(p);
|
|
42
53
|
}
|
|
43
54
|
|
|
44
55
|
/**
|