@zvada/agent-server 0.3.17 → 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 +1060 -0
- package/README.md +50 -26
- 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 +460 -54
- package/docs/deploy.md +218 -47
- package/docs/durable-sessions.md +195 -0
- package/docs/feedback.md +116 -0
- package/docs/harnesses.md +219 -87
- package/docs/sync-history.md +197 -0
- package/docs/sync-integration.md +119 -0
- package/package.json +53 -23
- 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 +641 -602
- package/src/client/connection.ts +371 -0
- package/src/client/history.ts +65 -0
- 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 +60 -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 +11 -34
- 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 +340 -481
- package/src/core/runtime/event-processor.ts +207 -75
- package/src/core/runtime/event-sink.ts +45 -2
- 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 +57 -57
- 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 +275 -0
- package/src/protocol/ids.ts +4 -17
- package/src/protocol/index.ts +10 -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 +425 -57
- 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 +275 -366
- package/src/server/bin.ts +295 -72
- package/src/server/feedback.ts +204 -14
- package/src/server/history.ts +160 -0
- package/src/server/index.ts +4 -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 +289 -0
- package/src/server/subscriptions.ts +232 -0
- package/src/server/transports.ts +125 -25
- package/src/server/wire-error.ts +38 -0
- package/src/sync/event-log.ts +160 -0
- package/src/sync/fit.ts +140 -0
- package/src/sync/history-reader.ts +57 -0
- package/src/sync/history-sqlite.ts +339 -0
- package/src/sync/history.ts +220 -0
- package/src/sync/index.ts +18 -0
- package/src/sync/journal-sqlite.ts +439 -0
- package/src/sync/journal.ts +132 -0
- package/src/sync/live-tails.ts +107 -0
- package/src/sync/node-sqlite.ts +20 -0
- package/src/sync/projection.ts +35 -0
- package/src/sync/recovery.ts +141 -0
- package/src/sync/retry.ts +49 -0
- package/src/sync/schema.ts +77 -0
- package/src/sync/sql.ts +106 -0
- package/src/sync/sqlite-file.ts +38 -0
- package/src/sync/sqlite.ts +21 -0
- package/src/sync/worker.ts +259 -0
- package/docs/rfds/0001-deterministic-echo-ids.md +0 -44
- package/docs/rfds/0002-native-subagents.md +0 -197
- 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
package/src/server/bin.ts
CHANGED
|
@@ -3,41 +3,68 @@
|
|
|
3
3
|
//
|
|
4
4
|
// agent-server # NDJSON JSON-RPC over stdio (default)
|
|
5
5
|
// agent-server --listen 4747 # accept WebSocket clients on a port
|
|
6
|
+
// agent-server --listen 0.0.0.0:4747 --token-file <path> # beyond loopback: a token
|
|
6
7
|
// agent-server --dial ws://host/p # dial out to a consumer and reconnect
|
|
8
|
+
// # (with $AGENT_SERVER_DIAL_TOKEN as its bearer token)
|
|
7
9
|
// agent-server --harness a,b # restrict registered harnesses
|
|
8
10
|
// agent-server --acp-agent "npx -y pi-acp" # enable the acp harness
|
|
9
11
|
// agent-server --acp --harness claude-code # BE an ACP agent on stdio (for Zed etc.)
|
|
10
12
|
// agent-server --buffer 8192 # replay buffer size per session
|
|
13
|
+
// agent-server --inherit-config none # a turn loads no ambient settings, MCP, hooks, memory
|
|
11
14
|
// agent-server install # prefetch the pinned agent CLIs
|
|
12
15
|
//
|
|
13
16
|
// All logs go to stderr; stdout is reserved for the wire in stdio mode.
|
|
17
|
+
import { readFileSync, statSync } from "node:fs";
|
|
14
18
|
import { homedir } from "node:os";
|
|
15
19
|
import { join } from "node:path";
|
|
16
20
|
import pkg from "../../package.json" with { type: "json" };
|
|
17
21
|
import {
|
|
18
|
-
|
|
22
|
+
type CredentialSource,
|
|
23
|
+
type InheritConfig,
|
|
19
24
|
type ProvisionMode,
|
|
20
25
|
createAgentRuntime,
|
|
26
|
+
credentialsFromUrl,
|
|
27
|
+
isInheritConfig,
|
|
21
28
|
resolveAcpLaunch,
|
|
29
|
+
resolveHarnessName,
|
|
22
30
|
} from "../core/index.ts";
|
|
23
|
-
import { isAgentHarness } from "../protocol/index.ts";
|
|
24
31
|
import { AgentServer } from "./agent-server.ts";
|
|
25
|
-
import {
|
|
32
|
+
import { runFeedbackCommand } from "./feedback.ts";
|
|
26
33
|
import { runInstall } from "./install.ts";
|
|
27
|
-
import {
|
|
34
|
+
import { takeSecrets } from "./secrets.ts";
|
|
35
|
+
import {
|
|
36
|
+
type ListenOptions,
|
|
37
|
+
assertListenOptions,
|
|
38
|
+
dial,
|
|
39
|
+
listen,
|
|
40
|
+
stdioTransport,
|
|
41
|
+
} from "./transports.ts";
|
|
28
42
|
|
|
29
43
|
const VERSION: string = pkg.version;
|
|
30
44
|
|
|
45
|
+
if (process.argv[2] === "feedback") {
|
|
46
|
+
process.exit(await runFeedbackCommand(process.argv.slice(3), VERSION));
|
|
47
|
+
}
|
|
48
|
+
|
|
31
49
|
interface Args {
|
|
32
|
-
command: "serve" | "install"
|
|
50
|
+
command: "serve" | "install";
|
|
33
51
|
mode: "stdio" | "listen" | "dial" | "acp";
|
|
34
52
|
listen?: { hostname?: string; port: number };
|
|
53
|
+
tokenFile?: string;
|
|
54
|
+
allowedOrigins?: string[];
|
|
35
55
|
dialUrl?: string;
|
|
36
56
|
harnesses?: string[];
|
|
37
57
|
acpAgent?: string;
|
|
38
58
|
bufferSize?: number;
|
|
59
|
+
journalPath?: string;
|
|
39
60
|
provisionMode?: ProvisionMode;
|
|
40
|
-
|
|
61
|
+
inheritConfig?: InheritConfig;
|
|
62
|
+
/** A product's credential endpoint, asked before each turn (LLP 0012). */
|
|
63
|
+
credentialsUrl?: string;
|
|
64
|
+
/** install: the platforms to stage, the folder to stage them into, and whether to prune. */
|
|
65
|
+
platforms?: string[];
|
|
66
|
+
installDir?: string;
|
|
67
|
+
prune?: boolean;
|
|
41
68
|
}
|
|
42
69
|
|
|
43
70
|
function usage(exitCode: number): never {
|
|
@@ -45,121 +72,257 @@ function usage(exitCode: number): never {
|
|
|
45
72
|
[
|
|
46
73
|
"usage: agent-server [install|feedback] [--listen [host:]port | --dial <ws-url>] [options]",
|
|
47
74
|
"",
|
|
48
|
-
"
|
|
75
|
+
" --stdio serve NDJSON JSON-RPC on stdio (the default)",
|
|
49
76
|
" --acp speak ACP v1 on stdio instead (be the agent)",
|
|
50
77
|
" install download the pinned agent CLIs into the managed cache",
|
|
51
78
|
" (always downloads — run at image build time to erase",
|
|
52
79
|
" sandbox cold starts; --provision applies to serving only)",
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
|
|
80
|
+
" --platform <a,b> for these platforms instead of this one (darwin-arm64,",
|
|
81
|
+
" darwin-x64, linux-arm64, linux-x64, linux-*-musl, win32-*)",
|
|
82
|
+
" --dir <path> into this folder, for an app or image to ship",
|
|
83
|
+
" ($AGENT_SERVER_BUNDLE_DIR where it runs)",
|
|
84
|
+
" --prune then remove builds no process used for 14 days",
|
|
85
|
+
' feedback --message "<report>" report friction or a failed task through Hivenet',
|
|
86
|
+
" (no key; see feedback --help for categories, evals,",
|
|
87
|
+
" thread replies and --dry-run)",
|
|
88
|
+
" --listen [host:]port accept WebSocket clients (an IPv6 host in brackets: [::1]:4747);",
|
|
89
|
+
" beyond loopback only with a token",
|
|
90
|
+
" --token-file <path> the token a listener's clients send (Authorization: Bearer);",
|
|
91
|
+
" or $AGENT_SERVER_TOKEN, never argv (ps shows it to every user)",
|
|
92
|
+
" --allow-origin <url> a browser origin that may connect to the listener (repeatable;",
|
|
93
|
+
" scheme://host[:port]); any other browser is refused",
|
|
94
|
+
" --dial <ws-url> dial out to a consumer (auto-reconnect); its credential:",
|
|
95
|
+
" $AGENT_SERVER_DIAL_TOKEN, never argv or the URL",
|
|
59
96
|
" --harness <a,b> restrict harnesses (default: all installed)",
|
|
60
97
|
" --acp-agent <spec> ACP agent: known name (pi|gemini) or launch command",
|
|
61
98
|
" --provision <mode> CLI provisioning: auto | pinned | system (default auto)",
|
|
62
|
-
" --
|
|
63
|
-
"
|
|
99
|
+
" --inherit-config <level> what a turn loads by itself (settings, MCP servers, hooks,",
|
|
100
|
+
" memory): all, the user's and the repository's (the default),",
|
|
101
|
+
" project, the repository's only, or none; Codex below all needs",
|
|
102
|
+
" each session's own env.CODEX_HOME",
|
|
103
|
+
" --credentials-url <url> ask this product endpoint for each turn's credential",
|
|
104
|
+
" (LLP 0012); its token in $AGENT_SERVER_CREDENTIALS_TOKEN",
|
|
105
|
+
" --buffer <n> replay buffer size per session (default 4096; not with --journal)",
|
|
106
|
+
" --journal <path> durable session history (wire modes only; Bun SQLite)",
|
|
107
|
+
" --version, --help (an option's value may also follow `=`: --journal=<path>)",
|
|
64
108
|
"",
|
|
65
|
-
"env:
|
|
109
|
+
"env: AGENT_SERVER_TOKEN (the listener's token, if no --token-file),",
|
|
110
|
+
" AGENT_SERVER_DIAL_TOKEN (what --dial presents: Authorization: Bearer),",
|
|
111
|
+
" AGENT_SERVER_CREDENTIALS_TOKEN (what --credentials-url presents),",
|
|
112
|
+
" CLAUDE_CLI_PATH / CODEX_CLI_PATH (explicit binaries),",
|
|
66
113
|
" AGENT_SERVER_PROVISION, AGENT_SERVER_CACHE_DIR, AGENT_SERVER_NPM_REGISTRY,",
|
|
114
|
+
" AGENT_SERVER_BUNDLE_DIR (folders `install --dir` staged, a path list),",
|
|
67
115
|
" AGENT_SERVER_ACP_SESSION_DIR (--acp: where resumable session ids are kept)",
|
|
68
116
|
].join("\n"),
|
|
69
117
|
);
|
|
70
118
|
process.exit(exitCode);
|
|
71
119
|
}
|
|
72
120
|
|
|
121
|
+
/** A bad invocation or a server that cannot start: one line saying what is wrong, exit 1. */
|
|
122
|
+
function fail(problem: string): never {
|
|
123
|
+
console.error(`agent-server: ${problem}`);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** `port`, `host:port` or `[ipv6]:port`; the port 0-65535 (0: any free one). */
|
|
128
|
+
function parseListen(value: string): { hostname?: string; port: number } {
|
|
129
|
+
const parts = /^(?:\[([^\]]+)\]:|([^:[\]]+):)?(\d+)$/.exec(value);
|
|
130
|
+
const port = Number(parts?.[3]);
|
|
131
|
+
if (!parts || !Number.isInteger(port) || port > 65535)
|
|
132
|
+
fail(
|
|
133
|
+
`--listen ${value}: give [host:]port with a port from 0 to 65535 (an IPv6 host in brackets)`,
|
|
134
|
+
);
|
|
135
|
+
const hostname = parts[1] ?? parts[2];
|
|
136
|
+
return hostname ? { hostname, port } : { port };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The options that take a value, which may follow as the next argument or after `=`. */
|
|
140
|
+
const VALUE_OPTIONS = new Set([
|
|
141
|
+
"--listen",
|
|
142
|
+
"--token",
|
|
143
|
+
"--token-file",
|
|
144
|
+
"--allow-origin",
|
|
145
|
+
"--dial",
|
|
146
|
+
"--harness",
|
|
147
|
+
"--acp-agent",
|
|
148
|
+
"--provision",
|
|
149
|
+
"--inherit-config",
|
|
150
|
+
"--credentials-url",
|
|
151
|
+
"--journal",
|
|
152
|
+
"--buffer",
|
|
153
|
+
"--platform",
|
|
154
|
+
"--dir",
|
|
155
|
+
]);
|
|
156
|
+
|
|
73
157
|
function parseArgs(argv: string[]): Args {
|
|
74
158
|
const args: Args = { command: "serve", mode: "stdio" };
|
|
75
159
|
for (let i = 0; i < argv.length; i++) {
|
|
76
|
-
const
|
|
77
|
-
const
|
|
160
|
+
const given = argv[i] as string;
|
|
161
|
+
const eq = given.indexOf("=");
|
|
162
|
+
const named = given.startsWith("--") && eq > 0 ? given.slice(0, eq) : given;
|
|
163
|
+
const inline = named === given ? undefined : given.slice(eq + 1);
|
|
164
|
+
const arg = VALUE_OPTIONS.has(named) ? named : given;
|
|
165
|
+
const next = (): string => {
|
|
166
|
+
if (inline !== undefined) return inline;
|
|
78
167
|
const v = argv[++i];
|
|
79
|
-
if (v === undefined)
|
|
168
|
+
if (v === undefined) fail(`${arg} needs a value`);
|
|
80
169
|
return v;
|
|
81
170
|
};
|
|
82
171
|
if (arg === "install" && i === 0) args.command = "install";
|
|
83
|
-
else if (arg === "
|
|
84
|
-
args.command = "feedback";
|
|
85
|
-
args.feedback = {};
|
|
86
|
-
} else if (args.command === "feedback" && args.feedback) {
|
|
87
|
-
if (arg === "--category") args.feedback.category = next();
|
|
88
|
-
else if (arg === "--subject") args.feedback.subject = next();
|
|
89
|
-
else if (arg === "--resume") args.feedback.resume = next();
|
|
90
|
-
else if (!arg.startsWith("--") && args.feedback.message === undefined)
|
|
91
|
-
args.feedback.message = arg;
|
|
92
|
-
else usage(1);
|
|
93
|
-
} else if (arg === "--stdio") args.mode = "stdio";
|
|
172
|
+
else if (arg === "--stdio") args.mode = "stdio";
|
|
94
173
|
else if (arg === "--acp") args.mode = "acp";
|
|
95
174
|
else if (arg === "--listen") {
|
|
96
175
|
args.mode = "listen";
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
176
|
+
args.listen = parseListen(next());
|
|
177
|
+
} else if (arg === "--token")
|
|
178
|
+
fail(
|
|
179
|
+
"--token would show the token to every user (ps): put it in a file for --token-file <path>, or in $AGENT_SERVER_TOKEN",
|
|
180
|
+
);
|
|
181
|
+
else if (arg === "--token-file") {
|
|
182
|
+
args.tokenFile = next();
|
|
183
|
+
if (!args.tokenFile) fail("--token-file needs a file path");
|
|
184
|
+
} else if (arg === "--allow-origin")
|
|
185
|
+
args.allowedOrigins = [...(args.allowedOrigins ?? []), next()];
|
|
186
|
+
else if (arg === "--dial") {
|
|
101
187
|
args.mode = "dial";
|
|
102
188
|
args.dialUrl = next();
|
|
103
189
|
} else if (arg === "--harness") args.harnesses = next().split(",").filter(Boolean);
|
|
104
|
-
else if (arg === "--acp-agent"
|
|
105
|
-
const spec =
|
|
106
|
-
if (!spec.trim() || spec.startsWith("-"))
|
|
190
|
+
else if (arg === "--acp-agent") {
|
|
191
|
+
const spec = inline ?? argv[++i];
|
|
192
|
+
if (spec === undefined || !spec.trim() || spec.startsWith("-"))
|
|
193
|
+
fail("--acp-agent needs a known agent name (pi, gemini) or a launch command");
|
|
107
194
|
args.acpAgent = spec;
|
|
108
195
|
} else if (arg === "--provision") {
|
|
109
196
|
const mode = next();
|
|
110
|
-
if (mode !== "auto" && mode !== "pinned" && mode !== "system")
|
|
197
|
+
if (mode !== "auto" && mode !== "pinned" && mode !== "system")
|
|
198
|
+
fail(`--provision ${mode}: use auto, pinned or system`);
|
|
111
199
|
args.provisionMode = mode;
|
|
200
|
+
} else if (arg === "--inherit-config") {
|
|
201
|
+
const level = next();
|
|
202
|
+
if (!isInheritConfig(level)) fail(`--inherit-config ${level}: use all, project or none`);
|
|
203
|
+
args.inheritConfig = level;
|
|
204
|
+
} else if (arg === "--credentials-url") {
|
|
205
|
+
args.credentialsUrl = next();
|
|
206
|
+
} else if (arg === "--journal") {
|
|
207
|
+
args.journalPath = next();
|
|
208
|
+
if (!args.journalPath) fail("--journal needs a file path");
|
|
112
209
|
} else if (arg === "--buffer") {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
210
|
+
const size = next();
|
|
211
|
+
args.bufferSize = Number(size);
|
|
212
|
+
if (!Number.isInteger(args.bufferSize) || args.bufferSize <= 0)
|
|
213
|
+
fail(`--buffer ${size}: give a whole number of events above 0`);
|
|
214
|
+
} else if (arg === "--platform") args.platforms = next().split(",").filter(Boolean);
|
|
215
|
+
else if (arg === "--dir") {
|
|
216
|
+
args.installDir = next();
|
|
217
|
+
if (!args.installDir) fail("--dir needs a folder");
|
|
218
|
+
} else if (arg === "--prune") args.prune = true;
|
|
219
|
+
else if (arg === "--version") {
|
|
116
220
|
console.log(VERSION);
|
|
117
221
|
process.exit(0);
|
|
118
222
|
} else if (arg === "--help") usage(0);
|
|
119
|
-
else
|
|
223
|
+
else fail(`unknown option ${given} (agent-server --help lists the options)`);
|
|
120
224
|
}
|
|
121
225
|
return args;
|
|
122
226
|
}
|
|
123
227
|
|
|
124
|
-
|
|
228
|
+
/** `host:port`, an IPv6 host in brackets. */
|
|
229
|
+
function hostPort({ hostname = "127.0.0.1", port }: { hostname?: string; port: number }): string {
|
|
230
|
+
return `${hostname.includes(":") ? `[${hostname}]` : hostname}:${port}`;
|
|
231
|
+
}
|
|
125
232
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
233
|
+
// Out of the environment before anything starts a CLI.
|
|
234
|
+
const SECRETS = takeSecrets();
|
|
235
|
+
|
|
236
|
+
/** A secret this run needs, refused when it was set but empty. */
|
|
237
|
+
function secret(name: keyof typeof SECRETS): string | undefined {
|
|
238
|
+
if (SECRETS[name] === "") fail(`$${name} is empty`);
|
|
239
|
+
return SECRETS[name];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* What `--dial` presents to the platform it dials, on every dial: from the
|
|
244
|
+
* environment only, never argv (ps) or the URL (logs).
|
|
245
|
+
*/
|
|
246
|
+
function dialToken(): string | undefined {
|
|
247
|
+
return secret("AGENT_SERVER_DIAL_TOKEN");
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** The token a listener's clients must send: from a file or the environment, never argv. */
|
|
251
|
+
function listenToken(file: string | undefined): string | undefined {
|
|
252
|
+
if (file === undefined) return secret("AGENT_SERVER_TOKEN");
|
|
253
|
+
let token: string;
|
|
129
254
|
try {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
255
|
+
token = readFileSync(file, "utf8").trim();
|
|
256
|
+
if (statSync(file).mode & 0o044)
|
|
257
|
+
console.error(`agent-server: --token-file ${file} can be read by other users (chmod 600 it)`);
|
|
133
258
|
} catch (error) {
|
|
134
|
-
|
|
135
|
-
|
|
259
|
+
const missing = (error as { code?: string }).code === "ENOENT";
|
|
260
|
+
fail(`--token-file ${file}: ${missing ? "no such file" : (error as Error).message}`);
|
|
136
261
|
}
|
|
262
|
+
if (!token) fail(`--token-file ${file} is empty`);
|
|
263
|
+
return token;
|
|
137
264
|
}
|
|
138
265
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
266
|
+
/**
|
|
267
|
+
* What `--listen` listens with, refused here as `listen` would refuse it:
|
|
268
|
+
* before a runtime or journal starts, and in the bin's terms.
|
|
269
|
+
*/
|
|
270
|
+
function listenOptions(args: Args): ListenOptions {
|
|
271
|
+
const options = {
|
|
272
|
+
...args.listen,
|
|
273
|
+
token: listenToken(args.tokenFile),
|
|
274
|
+
allowedOrigins: args.allowedOrigins,
|
|
275
|
+
};
|
|
276
|
+
try {
|
|
277
|
+
assertListenOptions(options);
|
|
278
|
+
} catch (error) {
|
|
279
|
+
const where = hostPort(args.listen ?? { port: 0 });
|
|
280
|
+
if ((error as { code?: string }).code === "tokenRequired")
|
|
281
|
+
fail(
|
|
282
|
+
`--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`,
|
|
283
|
+
);
|
|
284
|
+
fail(`cannot listen on ${where}: ${error instanceof Error ? error.message : error}`);
|
|
145
285
|
}
|
|
146
|
-
|
|
147
|
-
|
|
286
|
+
return options;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const args = parseArgs(process.argv.slice(2));
|
|
290
|
+
if (args.journalPath && (args.mode === "acp" || args.command !== "serve"))
|
|
291
|
+
fail("--journal is supported only for the stdio/listen/dial wire server");
|
|
292
|
+
if (args.command !== "install" && (args.platforms || args.installDir || args.prune))
|
|
293
|
+
fail("--platform, --dir and --prune are install's: agent-server install --dir <path> …");
|
|
294
|
+
const listening = args.command === "serve" && args.mode === "listen";
|
|
295
|
+
if (!listening && args.tokenFile !== undefined) fail("--token-file applies to --listen only");
|
|
296
|
+
if (!listening && args.allowedOrigins) fail("--allow-origin applies to --listen only");
|
|
297
|
+
const listener = listening ? listenOptions(args) : undefined;
|
|
298
|
+
const credential = args.command === "serve" && args.mode === "dial" ? dialToken() : undefined;
|
|
299
|
+
|
|
300
|
+
const harnesses = args.harnesses?.map((h) => {
|
|
301
|
+
const choice = resolveHarnessName(h);
|
|
302
|
+
if (!choice) fail(`unknown harness: ${h}`);
|
|
303
|
+
// Friendly ACP agent names ("pi", "gemini") ride the acp harness.
|
|
304
|
+
if (choice.acpAgent) args.acpAgent ??= choice.acpAgent;
|
|
305
|
+
return choice.harness;
|
|
148
306
|
});
|
|
149
307
|
const provision = args.provisionMode ? { mode: args.provisionMode } : {};
|
|
150
308
|
const acpLaunch = resolveAcpLaunch(args.acpAgent ?? process.env.AGENT_SERVER_ACP_AGENT);
|
|
151
|
-
if (harnesses?.includes("acp") && !acpLaunch)
|
|
152
|
-
|
|
153
|
-
process.exit(1);
|
|
154
|
-
}
|
|
309
|
+
if (harnesses?.includes("acp") && !acpLaunch)
|
|
310
|
+
fail('the acp harness needs an agent: --harness pi|gemini or --acp-agent "<spec>"');
|
|
155
311
|
|
|
156
312
|
if (args.command === "install") {
|
|
157
313
|
try {
|
|
158
|
-
// install always downloads
|
|
159
|
-
// concern) is deliberately not forwarded.
|
|
160
|
-
const results = await runInstall({
|
|
161
|
-
|
|
162
|
-
|
|
314
|
+
// install always downloads, into the managed cache or --dir; --provision
|
|
315
|
+
// (a serving concern) is deliberately not forwarded.
|
|
316
|
+
const results = await runInstall({
|
|
317
|
+
harnesses,
|
|
318
|
+
...(args.platforms && { platforms: args.platforms }),
|
|
319
|
+
...(args.installDir && { dir: args.installDir }),
|
|
320
|
+
...(args.prune && { prune: true }),
|
|
321
|
+
});
|
|
322
|
+
for (const { tool, platform, cli } of results) {
|
|
323
|
+
console.error(
|
|
324
|
+
`${tool} ${cli.version ?? ""} (${platform}) ready: ${cli.path} (${cli.source})`,
|
|
325
|
+
);
|
|
163
326
|
}
|
|
164
327
|
process.exit(0);
|
|
165
328
|
} catch (error) {
|
|
@@ -168,10 +331,34 @@ if (args.command === "install") {
|
|
|
168
331
|
}
|
|
169
332
|
}
|
|
170
333
|
|
|
334
|
+
// An ACP client names no Codex home, which every Codex turn below `all` needs.
|
|
335
|
+
if (
|
|
336
|
+
args.mode === "acp" &&
|
|
337
|
+
harnesses?.[0] === "codex-app-server" &&
|
|
338
|
+
(args.inheritConfig ?? "all") !== "all"
|
|
339
|
+
)
|
|
340
|
+
fail(
|
|
341
|
+
`--inherit-config ${args.inheritConfig}: a Codex turn needs a CODEX_HOME of its session's own, which --acp cannot give it`,
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
let credentials: CredentialSource | undefined;
|
|
345
|
+
if (args.credentialsUrl) {
|
|
346
|
+
try {
|
|
347
|
+
credentials = credentialsFromUrl({
|
|
348
|
+
url: args.credentialsUrl,
|
|
349
|
+
token: secret("AGENT_SERVER_CREDENTIALS_TOKEN"),
|
|
350
|
+
});
|
|
351
|
+
} catch (error) {
|
|
352
|
+
fail(`--credentials-url: ${(error as Error).message}`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
171
356
|
const runtime = createAgentRuntime({
|
|
172
357
|
...(harnesses ? { harnesses } : {}),
|
|
173
358
|
...(acpLaunch ? { acp: { resolveLaunch: () => acpLaunch } } : {}),
|
|
174
359
|
provision,
|
|
360
|
+
...(args.inheritConfig && { inheritConfig: args.inheritConfig }),
|
|
361
|
+
...(credentials && { credentials }),
|
|
175
362
|
});
|
|
176
363
|
|
|
177
364
|
let shutdown: () => void;
|
|
@@ -196,19 +383,53 @@ if (args.mode === "acp") {
|
|
|
196
383
|
// Client hung up — shut down cleanly (mirrors the stdio wire transport).
|
|
197
384
|
void connection.closed.then(() => shutdown());
|
|
198
385
|
} else {
|
|
199
|
-
|
|
386
|
+
if (args.journalPath && args.bufferSize !== undefined)
|
|
387
|
+
console.error("agent-server: --buffer has no effect with --journal (the journal replays all)");
|
|
388
|
+
let journal: import("../sync/sqlite.ts").SqliteSessionJournal | undefined;
|
|
389
|
+
try {
|
|
390
|
+
journal = args.journalPath
|
|
391
|
+
? new (await import("../sync/sqlite.ts")).SqliteSessionJournal(args.journalPath)
|
|
392
|
+
: undefined;
|
|
393
|
+
} catch (error) {
|
|
394
|
+
// Locked by another server, not a database, a newer schema: say which.
|
|
395
|
+
const why = error instanceof Error ? error.message : String(error);
|
|
396
|
+
fail(why.includes(args.journalPath ?? "") ? why : `--journal ${args.journalPath}: ${why}`);
|
|
397
|
+
}
|
|
398
|
+
// The restart sweep runs first: what a previous owner left running is stopped.
|
|
399
|
+
const server = await AgentServer.open(runtime, {
|
|
400
|
+
journal,
|
|
401
|
+
// This CLI wire is a trusted local execution surface, not a public relay.
|
|
402
|
+
history: journal ? { store: journal.history, authorize: () => true } : undefined,
|
|
403
|
+
onJournalError: (error) => {
|
|
404
|
+
console.error("Journal failed; restart and inspect interrupted execution:", error);
|
|
405
|
+
process.exitCode = 1;
|
|
406
|
+
},
|
|
200
407
|
bufferSize: args.bufferSize,
|
|
201
408
|
info: { name: "agent-server", version: VERSION },
|
|
202
|
-
onShutdown: () =>
|
|
409
|
+
onShutdown: () => {
|
|
410
|
+
journal?.close();
|
|
411
|
+
process.exit(process.exitCode ?? 0);
|
|
412
|
+
},
|
|
203
413
|
});
|
|
204
414
|
shutdown = () => void server.shutdown();
|
|
205
415
|
|
|
206
416
|
if (args.mode === "listen") {
|
|
207
|
-
|
|
417
|
+
let bound: ReturnType<typeof listen>;
|
|
418
|
+
try {
|
|
419
|
+
bound = listen(server, listener);
|
|
420
|
+
} catch (error) {
|
|
421
|
+
const code = (error as { code?: string }).code;
|
|
422
|
+
fail(
|
|
423
|
+
`cannot listen on ${hostPort(args.listen ?? { port: 0 })}: ${code === "EADDRINUSE" ? "the port is in use" : error instanceof Error ? error.message : error}`,
|
|
424
|
+
);
|
|
425
|
+
}
|
|
208
426
|
console.error(`agent-server ${VERSION} listening on ${bound.url}`);
|
|
209
427
|
} else if (args.mode === "dial") {
|
|
210
428
|
dial(server, args.dialUrl as string, {
|
|
211
429
|
onStateChange: (state) => console.error(`agent-server dial ${args.dialUrl}: ${state}`),
|
|
430
|
+
// @ref LLP 0001#d16--a-listener-answers-native-clients-only-and-needs-a-token-beyond-loopback
|
|
431
|
+
// A credential in a header: in the URL it would be logged, on argv shown by ps.
|
|
432
|
+
...(credential && { headers: { authorization: `Bearer ${credential}` } }),
|
|
212
433
|
});
|
|
213
434
|
} else {
|
|
214
435
|
const transport = stdioTransport();
|
|
@@ -218,6 +439,8 @@ if (args.mode === "acp") {
|
|
|
218
439
|
}
|
|
219
440
|
}
|
|
220
441
|
|
|
221
|
-
|
|
442
|
+
// A terminal that closes sends SIGHUP to its group, which no longer holds the
|
|
443
|
+
// agent CLIs (each leads a group of its own): stopping them is this server's job.
|
|
444
|
+
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"] as const) {
|
|
222
445
|
process.on(signal, () => shutdown());
|
|
223
446
|
}
|