@zvada/agent-server 0.3.22 → 0.3.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +261 -0
- package/dist/types/accounts/chatgpt.d.ts +1 -1
- package/dist/types/accounts/chatgpt.d.ts.map +1 -1
- package/dist/types/accounts/http.d.ts +2 -4
- package/dist/types/accounts/http.d.ts.map +1 -1
- package/dist/types/client/client.d.ts +37 -11
- package/dist/types/client/client.d.ts.map +1 -1
- package/dist/types/client/connection.d.ts +64 -13
- package/dist/types/client/connection.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +1 -1
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/logins.d.ts +2 -1
- package/dist/types/client/logins.d.ts.map +1 -1
- package/dist/types/client/streams.d.ts +9 -3
- package/dist/types/client/streams.d.ts.map +1 -1
- package/dist/types/client/turns.d.ts +1 -1
- package/dist/types/client/turns.d.ts.map +1 -1
- package/dist/types/core/agents/acp/acp-agent.d.ts +34 -1
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
- package/dist/types/core/agents/acp/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/acp/client.d.ts +12 -3
- package/dist/types/core/agents/acp/client.d.ts.map +1 -1
- package/dist/types/core/agents/acp/mappings.d.ts +8 -2
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
- package/dist/types/core/agents/base.d.ts +22 -8
- package/dist/types/core/agents/base.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/adapter.d.ts +7 -0
- package/dist/types/core/agents/claude-code/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/approvals.d.ts +4 -1
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +16 -5
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/events.d.ts +9 -1
- package/dist/types/core/agents/claude-code/events.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/login.d.ts +4 -1
- package/dist/types/core/agents/claude-code/login.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/mcp.d.ts +21 -7
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/models.d.ts +5 -1
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/options.d.ts +10 -4
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/outcome.d.ts +3 -5
- package/dist/types/core/agents/claude-code/outcome.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/results.d.ts +16 -0
- package/dist/types/core/agents/claude-code/results.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/sdk-pair.d.ts +13 -0
- package/dist/types/core/agents/claude-code/sdk-pair.d.ts.map +1 -0
- package/dist/types/core/agents/claude-code/session.d.ts +50 -12
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/spend.d.ts +2 -1
- package/dist/types/core/agents/claude-code/spend.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/tools.d.ts +26 -3
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/adapter.d.ts +2 -2
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/client.d.ts +12 -2
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +58 -13
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/commands.d.ts +2 -2
- package/dist/types/core/agents/codex-app-server/commands.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/credentials.d.ts +5 -1
- package/dist/types/core/agents/codex-app-server/credentials.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/effort.d.ts +2 -1
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/homes.d.ts +19 -0
- package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/items.d.ts +27 -2
- package/dist/types/core/agents/codex-app-server/items.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/login.d.ts +4 -1
- package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +15 -30
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/models.d.ts +3 -10
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/options.d.ts +27 -4
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts +2 -1
- package/dist/types/core/agents/codex-app-server/plan-approval.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/protocol.d.ts +16 -3
- package/dist/types/core/agents/codex-app-server/protocol.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/session.d.ts +68 -40
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/subagents.d.ts +9 -4
- package/dist/types/core/agents/codex-app-server/subagents.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts +3 -2
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts +2 -1
- package/dist/types/core/agents/codex-app-server/turn-items.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/turn.d.ts +31 -8
- package/dist/types/core/agents/codex-app-server/turn.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/user-login.d.ts +28 -0
- package/dist/types/core/agents/codex-app-server/user-login.d.ts.map +1 -0
- package/dist/types/core/agents/credentials.d.ts +3 -1
- package/dist/types/core/agents/credentials.d.ts.map +1 -1
- package/dist/types/core/agents/diffs.d.ts +9 -0
- package/dist/types/core/agents/diffs.d.ts.map +1 -0
- package/dist/types/core/agents/elicitation.d.ts +3 -2
- package/dist/types/core/agents/elicitation.d.ts.map +1 -1
- package/dist/types/core/agents/login.d.ts +6 -0
- package/dist/types/core/agents/login.d.ts.map +1 -1
- package/dist/types/core/agents/mcp-config.d.ts +0 -4
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -1
- package/dist/types/core/agents/process-pool.d.ts +193 -0
- package/dist/types/core/agents/process-pool.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/adapter.d.ts +68 -0
- package/dist/types/core/agents/scripted/adapter.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/mcp-call.d.ts +56 -0
- package/dist/types/core/agents/scripted/mcp-call.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/scripted-agent.d.ts +73 -0
- package/dist/types/core/agents/scripted/scripted-agent.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/scripts.d.ts +29 -0
- package/dist/types/core/agents/scripted/scripts.d.ts.map +1 -0
- package/dist/types/core/agents/scripted/steps.d.ts +132 -0
- package/dist/types/core/agents/scripted/steps.d.ts.map +1 -0
- package/dist/types/core/agents/session-agent.d.ts +49 -6
- package/dist/types/core/agents/session-agent.d.ts.map +1 -1
- package/dist/types/core/diagnostics.d.ts +4 -1
- package/dist/types/core/diagnostics.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +5 -0
- package/dist/types/core/index.d.ts.map +1 -1
- package/dist/types/core/presets.d.ts +32 -6
- package/dist/types/core/presets.d.ts.map +1 -1
- package/dist/types/core/processes/lifeline.d.ts +0 -20
- package/dist/types/core/processes/lifeline.d.ts.map +1 -1
- package/dist/types/core/provision/index.d.ts +2 -2
- package/dist/types/core/provision/index.d.ts.map +1 -1
- package/dist/types/core/provision/install-build.d.ts +2 -1
- package/dist/types/core/provision/install-build.d.ts.map +1 -1
- package/dist/types/core/provision/npm.d.ts +20 -8
- package/dist/types/core/provision/npm.d.ts.map +1 -1
- package/dist/types/core/provision/provisioner.d.ts +4 -1
- package/dist/types/core/provision/provisioner.d.ts.map +1 -1
- package/dist/types/core/provision/tools.d.ts +2 -1
- package/dist/types/core/provision/tools.d.ts.map +1 -1
- package/dist/types/core/runtime/agent-runtime.d.ts +16 -8
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
- package/dist/types/core/runtime/event-processor.d.ts +5 -1
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -1
- package/dist/types/core/runtime/harness-clis.d.ts +9 -0
- package/dist/types/core/runtime/harness-clis.d.ts.map +1 -1
- package/dist/types/core/runtime/harness-logins.d.ts +33 -5
- package/dist/types/core/runtime/harness-logins.d.ts.map +1 -1
- package/dist/types/core/runtime/model-lists.d.ts +2 -0
- package/dist/types/core/runtime/model-lists.d.ts.map +1 -1
- package/dist/types/core/runtime/permission-policy.d.ts +5 -3
- package/dist/types/core/runtime/permission-policy.d.ts.map +1 -1
- package/dist/types/core/runtime/request-broker.d.ts +2 -1
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -1
- package/dist/types/core/runtime/turn.d.ts +12 -1
- package/dist/types/core/runtime/turn.d.ts.map +1 -1
- package/dist/types/core/utils/deadline.d.ts +6 -0
- package/dist/types/core/utils/deadline.d.ts.map +1 -1
- package/dist/types/core/utils/errors.d.ts +7 -1
- package/dist/types/core/utils/errors.d.ts.map +1 -1
- package/dist/types/operator/operator.d.ts.map +1 -1
- package/dist/types/operator/render.d.ts +6 -4
- package/dist/types/operator/render.d.ts.map +1 -1
- package/dist/types/protocol/auth.d.ts +54 -24
- package/dist/types/protocol/auth.d.ts.map +1 -1
- package/dist/types/protocol/clis.d.ts +14 -7
- package/dist/types/protocol/clis.d.ts.map +1 -1
- package/dist/types/protocol/config.d.ts +2 -0
- package/dist/types/protocol/config.d.ts.map +1 -1
- package/dist/types/protocol/conversation.d.ts +40 -3
- package/dist/types/protocol/conversation.d.ts.map +1 -1
- package/dist/types/protocol/credentials.d.ts +7 -0
- package/dist/types/protocol/credentials.d.ts.map +1 -1
- package/dist/types/protocol/execution.d.ts +2 -1
- package/dist/types/protocol/execution.d.ts.map +1 -1
- package/dist/types/protocol/factories.d.ts +12 -2
- package/dist/types/protocol/factories.d.ts.map +1 -1
- package/dist/types/protocol/harness.d.ts +6 -2
- package/dist/types/protocol/harness.d.ts.map +1 -1
- package/dist/types/protocol/history.d.ts +19 -0
- package/dist/types/protocol/history.d.ts.map +1 -1
- package/dist/types/protocol/lifecycle.d.ts +47 -8
- package/dist/types/protocol/lifecycle.d.ts.map +1 -1
- package/dist/types/protocol/model-catalog.d.ts.map +1 -1
- package/dist/types/protocol/models.d.ts +3 -0
- package/dist/types/protocol/models.d.ts.map +1 -1
- package/dist/types/protocol/parts.d.ts +14 -0
- package/dist/types/protocol/parts.d.ts.map +1 -1
- package/dist/types/protocol/tool-state.d.ts +12 -0
- package/dist/types/protocol/tool-state.d.ts.map +1 -1
- package/dist/types/protocol/wire-api.d.ts +129 -23
- package/dist/types/protocol/wire-api.d.ts.map +1 -1
- package/dist/types/protocol/wire.d.ts +70 -10
- package/dist/types/protocol/wire.d.ts.map +1 -1
- package/dist/types/server/acp/binding.d.ts +6 -1
- package/dist/types/server/acp/binding.d.ts.map +1 -1
- package/dist/types/server/acp/translate.d.ts +33 -7
- package/dist/types/server/acp/translate.d.ts.map +1 -1
- package/dist/types/server/agent-server.d.ts +6 -0
- package/dist/types/server/agent-server.d.ts.map +1 -1
- package/dist/types/server/feedback.d.ts +2 -1
- package/dist/types/server/feedback.d.ts.map +1 -1
- package/dist/types/server/install.d.ts +11 -0
- package/dist/types/server/install.d.ts.map +1 -1
- package/dist/types/server/session-gate.d.ts +2 -1
- package/dist/types/server/session-gate.d.ts.map +1 -1
- package/dist/types/server/session-store.d.ts +1 -0
- package/dist/types/server/session-store.d.ts.map +1 -1
- package/dist/types/server/subscriptions.d.ts +2 -1
- package/dist/types/server/subscriptions.d.ts.map +1 -1
- package/dist/types/server/transports.d.ts.map +1 -1
- package/dist/types/sync/fit.d.ts +8 -7
- package/dist/types/sync/fit.d.ts.map +1 -1
- package/dist/types/sync/history-sqlite.d.ts.map +1 -1
- package/dist/types/sync/index.d.ts +1 -0
- package/dist/types/sync/index.d.ts.map +1 -1
- package/dist/types/sync/journal-sqlite.d.ts +2 -1
- package/dist/types/sync/journal-sqlite.d.ts.map +1 -1
- package/dist/types/sync/journal.d.ts +11 -3
- package/dist/types/sync/journal.d.ts.map +1 -1
- package/dist/types/sync/projection.d.ts +6 -0
- package/dist/types/sync/projection.d.ts.map +1 -1
- package/dist/types/sync/recovery.d.ts +2 -1
- package/dist/types/sync/recovery.d.ts.map +1 -1
- package/dist/types/sync/schema.d.ts +10 -0
- package/dist/types/sync/schema.d.ts.map +1 -1
- package/dist/types/sync/sql.d.ts +2 -1
- package/dist/types/sync/sql.d.ts.map +1 -1
- package/docs/consuming.md +278 -28
- package/docs/deploy.md +36 -8
- package/docs/durable-sessions.md +35 -5
- package/docs/harnesses.md +385 -24
- package/package.json +6 -1
- package/src/accounts/chatgpt.ts +2 -2
- package/src/accounts/http.ts +2 -16
- package/src/client/client.ts +92 -31
- package/src/client/connection.ts +103 -22
- package/src/client/index.ts +1 -0
- package/src/client/logins.ts +1 -1
- package/src/client/streams.ts +12 -4
- package/src/client/turns.ts +1 -1
- package/src/core/agents/acp/acp-agent.ts +181 -52
- package/src/core/agents/acp/adapter.ts +9 -1
- package/src/core/agents/acp/client.ts +16 -4
- package/src/core/agents/acp/mappings.ts +27 -0
- package/src/core/agents/base.ts +25 -10
- package/src/core/agents/claude-code/adapter.ts +47 -17
- package/src/core/agents/claude-code/approvals.ts +6 -5
- package/src/core/agents/claude-code/claude-agent.ts +60 -30
- package/src/core/agents/claude-code/events.ts +11 -1
- package/src/core/agents/claude-code/login.ts +14 -2
- package/src/core/agents/claude-code/mcp.ts +31 -15
- package/src/core/agents/claude-code/models.ts +7 -2
- package/src/core/agents/claude-code/options.ts +11 -3
- package/src/core/agents/claude-code/outcome.ts +10 -2
- package/src/core/agents/claude-code/results.ts +73 -0
- package/src/core/agents/claude-code/sdk-pair.ts +66 -0
- package/src/core/agents/claude-code/session.ts +166 -37
- package/src/core/agents/claude-code/spend.ts +1 -1
- package/src/core/agents/claude-code/tools.ts +108 -12
- package/src/core/agents/codex-app-server/adapter.ts +37 -12
- package/src/core/agents/codex-app-server/client.ts +37 -8
- package/src/core/agents/codex-app-server/codex-agent.ts +115 -50
- package/src/core/agents/codex-app-server/commands.ts +2 -2
- package/src/core/agents/codex-app-server/credentials.ts +10 -5
- package/src/core/agents/codex-app-server/effort.ts +1 -1
- package/src/core/agents/codex-app-server/homes.ts +43 -1
- package/src/core/agents/codex-app-server/items.ts +219 -31
- package/src/core/agents/codex-app-server/login.ts +14 -2
- package/src/core/agents/codex-app-server/mcp.ts +47 -32
- package/src/core/agents/codex-app-server/models.ts +9 -8
- package/src/core/agents/codex-app-server/options.ts +69 -10
- package/src/core/agents/codex-app-server/plan-approval.ts +1 -1
- package/src/core/agents/codex-app-server/protocol.ts +14 -4
- package/src/core/agents/codex-app-server/requests.ts +14 -6
- package/src/core/agents/codex-app-server/session.ts +151 -113
- package/src/core/agents/codex-app-server/subagents.ts +21 -14
- package/src/core/agents/codex-app-server/thread-settings.ts +18 -8
- package/src/core/agents/codex-app-server/turn-items.ts +1 -1
- package/src/core/agents/codex-app-server/turn.ts +79 -32
- package/src/core/agents/codex-app-server/user-login.ts +107 -0
- package/src/core/agents/credentials.ts +5 -2
- package/src/core/agents/diffs.ts +25 -0
- package/src/core/agents/elicitation.ts +2 -2
- package/src/core/agents/login.ts +6 -0
- package/src/core/agents/mcp-config.ts +2 -2
- package/src/core/agents/process-pool.ts +432 -0
- package/src/core/agents/scripted/adapter.ts +142 -0
- package/src/core/agents/scripted/mcp-call.ts +134 -0
- package/src/core/agents/scripted/scripted-agent.ts +418 -0
- package/src/core/agents/scripted/scripts.ts +171 -0
- package/src/core/agents/scripted/steps.ts +127 -0
- package/src/core/agents/session-agent.ts +105 -8
- package/src/core/diagnostics.ts +9 -1
- package/src/core/index.ts +11 -0
- package/src/core/presets.ts +99 -14
- package/src/core/processes/lifeline.ts +99 -25
- package/src/core/provision/index.ts +1 -2
- package/src/core/provision/install-build.ts +4 -1
- package/src/core/provision/npm.ts +309 -97
- package/src/core/provision/provisioner.ts +22 -8
- package/src/core/provision/tools.ts +44 -19
- package/src/core/runtime/agent-runtime.ts +48 -18
- package/src/core/runtime/event-processor.ts +18 -2
- package/src/core/runtime/harness-clis.ts +36 -1
- package/src/core/runtime/harness-logins.ts +82 -31
- package/src/core/runtime/model-lists.ts +1 -1
- package/src/core/runtime/permission-policy.ts +4 -3
- package/src/core/runtime/request-broker.ts +1 -1
- package/src/core/runtime/turn.ts +51 -3
- package/src/core/utils/deadline.ts +23 -0
- package/src/core/utils/errors.ts +11 -4
- package/src/operator/operator.ts +8 -4
- package/src/operator/render.ts +46 -8
- package/src/protocol/auth.ts +30 -23
- package/src/protocol/clis.ts +12 -4
- package/src/protocol/credentials.ts +19 -0
- package/src/protocol/execution.ts +5 -0
- package/src/protocol/factories.ts +25 -3
- package/src/protocol/harness.ts +11 -1
- package/src/protocol/history.ts +20 -0
- package/src/protocol/lifecycle.ts +10 -1
- package/src/protocol/model-catalog.ts +19 -8
- package/src/protocol/parts.ts +12 -1
- package/src/protocol/tool-state.ts +14 -1
- package/src/protocol/wire.ts +14 -0
- package/src/server/acp/binding.ts +113 -23
- package/src/server/acp/translate.ts +161 -8
- package/src/server/agent-server.ts +10 -1
- package/src/server/bin.ts +83 -9
- package/src/server/feedback.ts +1 -1
- package/src/server/install.ts +82 -4
- package/src/server/session-gate.ts +1 -1
- package/src/server/session-store.ts +5 -1
- package/src/server/subscriptions.ts +1 -1
- package/src/server/transports.ts +14 -0
- package/src/sync/fit.ts +115 -28
- package/src/sync/history-sqlite.ts +6 -2
- package/src/sync/index.ts +1 -0
- package/src/sync/journal-sqlite.ts +20 -2
- package/src/sync/journal.ts +10 -2
- package/src/sync/projection.ts +10 -0
- package/src/sync/recovery.ts +11 -4
- package/src/sync/schema.ts +7 -5
- package/src/sync/sql.ts +1 -1
- package/dist/types/core/agents/claude-code/session-pool.d.ts +0 -36
- package/dist/types/core/agents/claude-code/session-pool.d.ts.map +0 -1
- package/dist/types/core/agents/session-pool.d.ts +0 -41
- package/dist/types/core/agents/session-pool.d.ts.map +0 -1
- package/src/core/agents/claude-code/session-pool.ts +0 -136
- package/src/core/agents/session-pool.ts +0 -111
package/docs/consuming.md
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
The integration recipe, written down once — every rule here was re-derived
|
|
4
4
|
independently by at least one real consumer before it landed in this file.
|
|
5
5
|
|
|
6
|
+
Short on time? Read [What products got wrong](#what-products-got-wrong-so-you-need-not)
|
|
7
|
+
first: each line is a mistake a real integration made, and what to do instead.
|
|
8
|
+
|
|
6
9
|
## Fold events with the shipped reducer
|
|
7
10
|
|
|
8
11
|
Do not hand-roll a `switch (event.type)` state fold. The package ships the
|
|
@@ -65,6 +68,15 @@ The reducer encodes the rules consumers get wrong first:
|
|
|
65
68
|
the mode it asks for: `state.permissionMode` holds the current one (the
|
|
66
69
|
turn's, then the agent's switch), so send that mode next to stay with the
|
|
67
70
|
agent.
|
|
71
|
+
- **Draw a tool call from its fields, not its input.** A tool part and a
|
|
72
|
+
request's `toolCall` say what the call acts on: `command` (the line as the
|
|
73
|
+
agent wrote it, never Codex's `/bin/zsh -lc` wrapper), `url`, and
|
|
74
|
+
`locations` (each hunk's start `line` once an edit is done); a request's
|
|
75
|
+
`reason` says why it asks, and its `title` is only a label. A result's
|
|
76
|
+
`content` holds its `diff` entries and `state.metadata.exitCode` a
|
|
77
|
+
command's exit code, failed or not, where the harness reports them.
|
|
78
|
+
`rawInput` and `state.input` stay each harness's own keys
|
|
79
|
+
(`docs/harnesses.md`, What a tool call says, per harness).
|
|
68
80
|
- **Say why where the harness hears it.** A refused tool call's `message`
|
|
69
81
|
reaches the agent when `initialize().harnesses[h].rejectionMessages` is
|
|
70
82
|
true (Claude). Codex's refusal is a bare verdict and an ACP agent's an
|
|
@@ -100,7 +112,8 @@ The reducer encodes the rules consumers get wrong first:
|
|
|
100
112
|
that changed (`five_hour`, `seven_day`, … with `usedPercent` and
|
|
101
113
|
`resetsAt`); `state.limits` merges them by id. A recoverable `error` with
|
|
102
114
|
`retry` means the harness is waiting to try again — show it, don't fail the
|
|
103
|
-
turn.
|
|
115
|
+
turn. It reports a retry under way: its `category` is the failing call's,
|
|
116
|
+
not the turn's outcome, so show the attempt and the message, not "auth".
|
|
104
117
|
|
|
105
118
|
Branch on the outcome with `isCleanStop` / `isFailureStopReason` rather than
|
|
106
119
|
your own list: `cancelled` is clean (the user asked for the stop), `error` is
|
|
@@ -257,12 +270,18 @@ A harness's first turn on a machine without its CLI downloads it, about
|
|
|
257
270
|
```ts
|
|
258
271
|
client.onCliProgress(({ harness, phase, receivedBytes, totalBytes }) => progressBar(harness, phase, receivedBytes, totalBytes));
|
|
259
272
|
const [claude] = await client.prepareClis(["claude-code"]);
|
|
260
|
-
if (claude?.state === "failed") showRetry(claude.error); //
|
|
273
|
+
if (claude?.state === "failed") showRetry(claude.error, claude.category); // "network": offline, ask again later
|
|
261
274
|
```
|
|
262
275
|
|
|
263
276
|
`listClis()` says where each CLI is without installing (`ready`, `missing`,
|
|
264
|
-
`installing`, `failed`, `unmanaged`
|
|
265
|
-
|
|
277
|
+
`installing`, `failed`, `unmanaged`; a `failed` one's `category` says what
|
|
278
|
+
failed, as a turn's error does); every connection hears `clis/progress`,
|
|
279
|
+
whoever caused the install. A read installs nothing: until a harness's CLI is
|
|
280
|
+
there, `authStatus()` answers it `unknown` with no `methods` and
|
|
281
|
+
`listModels()` the catalog, each with an `error` saying the CLI is not
|
|
282
|
+
installed yet, being installed, or failed to install; read again once
|
|
283
|
+
`clis/progress` says `ready` (the first model list after it is live). What
|
|
284
|
+
installs is an act: a turn, `prepareClis()`, `login()` and `logout()`. `prepareClis()` waits on those, since the server
|
|
266
285
|
answers `clis/prepare` at once; its `signal` stops the waiting, not the
|
|
267
286
|
install. In-process, `runtime.prepareClis()`, `runtime.listClis()` and
|
|
268
287
|
`runtime.onCliProgress()` do the same. A product that bundles the Claude SDK
|
|
@@ -318,8 +337,12 @@ environment wins over the login; say so. Every connection hears
|
|
|
318
337
|
it, and a status read notices a login made in a terminal. After a change,
|
|
319
338
|
each session's next turn starts a new CLI, resuming its conversation. A turn
|
|
320
339
|
that fails for its credential ends with `error.category: "auth"`: send the
|
|
321
|
-
user to the login. A login
|
|
322
|
-
|
|
340
|
+
user to the login. A login under way is `auth.loginUnderWay` (what
|
|
341
|
+
`client.login` answered: `loginId`, `url`, `codeUrl`, `userCode`,
|
|
342
|
+
`expiresAt`) in every status read and every `auth/updated`, which tells it as
|
|
343
|
+
it starts too, so a second window shows the same sign-in page and can cancel
|
|
344
|
+
it (`auth/cancel`). A login handle that loses its connection settles at once:
|
|
345
|
+
read the status again, which says whether the login still goes on. Status reports the
|
|
323
346
|
CLI's own login and environment: a turn that brings its own `apiKey`, or runs
|
|
324
347
|
on a credential the product holds (`credentials`), runs with that instead. In-process, `runtime.authStatus()`, `runtime.login()`,
|
|
325
348
|
`runtime.completeLogin()`, `runtime.cancelLogin()`, `runtime.logout()` and
|
|
@@ -391,12 +414,15 @@ Fill a model picker from the harness's own list rather than a hard-coded one:
|
|
|
391
414
|
|
|
392
415
|
```ts
|
|
393
416
|
const { models, source, error } = await client.listModels({ harness: "codex-app-server", cwd });
|
|
394
|
-
// source: "catalog" + error = the CLI did not answer (e.g. logged out
|
|
417
|
+
// source: "catalog" + error = the CLI did not answer (e.g. logged out; offer a login)
|
|
418
|
+
// or is not installed yet (prepareClis, then list again).
|
|
395
419
|
const choice = models.find((m) => m.isDefault) ?? models[0];
|
|
396
420
|
const level = savedLevelFor(choice.id) ?? choice.thinking.default; // never invent one
|
|
397
421
|
```
|
|
398
422
|
|
|
399
|
-
`thinking.levels` empty means the model has no thinking control
|
|
423
|
+
`thinking.levels` empty means the model has no thinking control: a turn
|
|
424
|
+
that names a level for it runs without one (`off` is still sent on Claude),
|
|
425
|
+
and reports no `appliedThinkingLevel`. Keep the
|
|
400
426
|
user's level per model, and use `clampThinkingLevel(level, model.thinking.levels)`
|
|
401
427
|
only for a model the user has not set. Pass `refresh: true` after a login;
|
|
402
428
|
lists are cached ten minutes.
|
|
@@ -413,6 +439,16 @@ model it rerouted to, after a reroute), and the requested `model` only where
|
|
|
413
439
|
a harness names none. List models with the `cwd` (and credentials) your turns use: an alias
|
|
414
440
|
such as `opus` is fitted only from its own login's list.
|
|
415
441
|
|
|
442
|
+
A setting a harness does not apply is said, not dropped in silence. Read
|
|
443
|
+
`capabilities.ignoredSettings` (from `initialize`) up front: the `RunConfig`
|
|
444
|
+
fields that harness never applies (`maxTurns` and `resumeSessionAt` on
|
|
445
|
+
Codex). Each turn names the ones it set in `turn.started.execution.notApplied`,
|
|
446
|
+
and `turn.ended.execution.notApplied` adds those the harness found it could
|
|
447
|
+
not apply as it ran (a model with no thinking control, an ACP agent that
|
|
448
|
+
takes no extra directories); the reducer keeps it on the turn. A product's own
|
|
449
|
+
"not on this harness" checks can go. `docs/harnesses.md`, "What each harness
|
|
450
|
+
does with each turn setting", has every field.
|
|
451
|
+
|
|
416
452
|
## Persist for resume
|
|
417
453
|
|
|
418
454
|
Store `state.nativeSessionId` (from `session.created`) keyed by your logical
|
|
@@ -514,6 +550,14 @@ the turn ends. A command whose stop could not be confirmed is not closed as
|
|
|
514
550
|
cancelled: its tool part fails with `TOOL_OUTCOME_UNKNOWN`, a failure the
|
|
515
551
|
harness reports itself (no `closure`).
|
|
516
552
|
|
|
553
|
+
Two operator options time a cancel, each set once on `createAgentRuntime`
|
|
554
|
+
for every harness. `cancelConfirmMs` (2 s by default) is how long a cancel
|
|
555
|
+
waits for the agent to confirm it stopped before it answers `unconfirmed`;
|
|
556
|
+
a turn still starting is confirmed once it has ended within it.
|
|
557
|
+
`cancelGraceMs` is how long after a cancel the engine ends an agent that has
|
|
558
|
+
not stopped, and its turn then ends `cancelled`: 2 s on Codex, 10 s on an
|
|
559
|
+
ACP agent; Claude is not ended for it.
|
|
560
|
+
|
|
517
561
|
Embedded `runtime.cancel(harness, sessionId)` cancels the session's active
|
|
518
562
|
turn without a turn ID check. Prefer a per-turn `AbortSignal` when cancellation
|
|
519
563
|
can arrive late; a completed turn's signal is detached before the next turn.
|
|
@@ -547,7 +591,7 @@ CLI's `--inherit-config`, choose how much (LLP 0001, D17):
|
|
|
547
591
|
| Level | Claude Code | Codex app-server |
|
|
548
592
|
| --- | --- | --- |
|
|
549
593
|
| `all` (default) | every settings source (user, project, local) and the auto-memory Claude keeps for the repository, as the CLI itself does | the turn's `env.CODEX_HOME`, else the process's: the user's `~/.codex`, which the engine never writes |
|
|
550
|
-
| `project` | the repository's settings, hooks, `.mcp.json` servers and instruction files; nothing of the user's, no auto-memory, no claude.ai connectors | the repository's `AGENTS.md` and skills, in a home of the session's own |
|
|
594
|
+
| `project` | the repository's settings, hooks, `.mcp.json` servers and instruction files; nothing of the user's, no auto-memory, no claude.ai connectors | the repository's `AGENTS.md` and skills, in a home of the session's own; no apps (the ChatGPT account's connectors) |
|
|
551
595
|
| `none` | only the servers the host and the turn name | as `project`, without the repository's `AGENTS.md` |
|
|
552
596
|
|
|
553
597
|
Choose by whose machine and whose repository it is. A desktop product that
|
|
@@ -571,9 +615,18 @@ At `project` and `none` every Codex turn needs `config.env.CODEX_HOME`, an
|
|
|
571
615
|
existing absolute folder of the session's own: never the user's `~/.codex`,
|
|
572
616
|
never another session's. A turn without one fails `invalid_request` before
|
|
573
617
|
Codex starts. The engine owns that home's `mcp_servers` table, as for
|
|
574
|
-
per-turn MCP in a home below. A fresh home has no login:
|
|
575
|
-
|
|
576
|
-
`
|
|
618
|
+
per-turn MCP in a home below. A fresh home has no login: run it on the
|
|
619
|
+
person's own Codex login (`codexAppServer.userLogin`, below), or hand one over
|
|
620
|
+
with [`credentials`](harnesses.md#host-managed-codex-authentication) or the
|
|
621
|
+
turn's `apiKey`. Below `all` Codex's apps, the ChatGPT account's connectors,
|
|
622
|
+
are off in every thread, as Claude's claude.ai connectors are, and its
|
|
623
|
+
plugins are off in every app-server that runs in such a home
|
|
624
|
+
(`-c features.plugins=false`), so a fresh home stays about 4 MB where it
|
|
625
|
+
cloned Codex's plugin catalogue (about 85 MB); a product that wants a plugin
|
|
626
|
+
runs at `all` or brings it as an MCP server. A home removed and made again
|
|
627
|
+
under a session's warm process starts a new process on the next turn, which
|
|
628
|
+
resumes the thread if the home still holds it, or fails `resume_failed`.
|
|
629
|
+
Codex loads the repository's skills and
|
|
577
630
|
`~/.agents/skills` at every level; turn one off by name in the home you
|
|
578
631
|
supply (`[[skills.config]]` with `enabled = false`).
|
|
579
632
|
|
|
@@ -583,6 +636,89 @@ On Claude a `disableTools` turn runs at `none` whatever the level.
|
|
|
583
636
|
auto-memory and the connectors. An ACP agent loads what its launch command
|
|
584
637
|
says.
|
|
585
638
|
|
|
639
|
+
### A product's own agent on the person's own login
|
|
640
|
+
|
|
641
|
+
A product whose agent works only through the product's own tools, on the
|
|
642
|
+
person's own Claude or Codex login and with none of their configuration,
|
|
643
|
+
runs its turns at `inheritConfig: "none"` (LLP 0017). Nothing of it comes
|
|
644
|
+
from the wire.
|
|
645
|
+
|
|
646
|
+
```ts
|
|
647
|
+
createAgentRuntime({
|
|
648
|
+
inheritConfig: "none",
|
|
649
|
+
claudeCode: { sdkOptions: () => ({ tools: [] }), toolPolicy },
|
|
650
|
+
codexAppServer: {
|
|
651
|
+
userLogin: true,
|
|
652
|
+
builtInTools: { local: false, webSearch: false, imageGeneration: false },
|
|
653
|
+
},
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
// Each Codex turn names a home of its session's own: an existing folder you
|
|
657
|
+
// make for the session and keep for its resume, never ~/.codex.
|
|
658
|
+
await runtime.run({
|
|
659
|
+
sessionId,
|
|
660
|
+
turnId,
|
|
661
|
+
input,
|
|
662
|
+
config: { harness: "codex-app-server", cwd, mcpServers, env: { CODEX_HOME: sessionHome } },
|
|
663
|
+
}, sink);
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
- **Claude** runs on the login of the person's own Claude Code (no
|
|
667
|
+
`CLAUDE_CONFIG_DIR`). At `none` it loads no settings source, no
|
|
668
|
+
settings file's, plugin's or claude.ai connector's server and no
|
|
669
|
+
auto-memory: only the servers you name. `sdkOptions: () => ({ tools: [] })`
|
|
670
|
+
takes Claude's own tools away and keeps the MCP servers; to keep a few,
|
|
671
|
+
list their names (`tools: ["Read", "Grep"]`, the SDK's option, passed
|
|
672
|
+
through). `toolPolicy` is asked only about the calls Claude itself would
|
|
673
|
+
ask about, so it cannot keep a tool off alone: with the policy alone, a
|
|
674
|
+
`Read` of a file in the turn's folder ran and the policy was asked 0 times,
|
|
675
|
+
with 29 of Claude's own tools offered (measured, Claude Code 2.1.288).
|
|
676
|
+
`disableTools` is no substitute: it drops the MCP servers too. In `default`
|
|
677
|
+
mode Claude asks about every MCP call, so `toolPolicy` sees each of
|
|
678
|
+
yours. Claude keeps each session's transcript under the person's own
|
|
679
|
+
`~/.claude/projects/<folder>/`, at `none` too, and it stays after
|
|
680
|
+
`session/close`: a resume needs it.
|
|
681
|
+
- **Codex** runs each turn in the home it names, which holds the session's
|
|
682
|
+
conversation (its transcript goes with the home) and the turn's MCP
|
|
683
|
+
servers and nothing of the person's: no
|
|
684
|
+
`config.toml`, MCP servers, hooks, profiles, `AGENTS.md` or skills of
|
|
685
|
+
theirs, no apps or plugins, and at `none` not the repository's `AGENTS.md`.
|
|
686
|
+
`userLogin` runs it on the person's own Codex login (the one `codex login`
|
|
687
|
+
keeps in `$CODEX_HOME`, else `~/.codex`), read from Codex before each turn
|
|
688
|
+
and held in the session's process's memory: nothing is copied or written
|
|
689
|
+
to the session's home, and Codex renews the login in the person's own home
|
|
690
|
+
when it needs to. A product's `credentials` and the turn's `apiKey` come
|
|
691
|
+
first. Signed out, the turn fails `auth` before Codex starts. Codex still
|
|
692
|
+
loads the repository's skills and `~/.agents/skills`.
|
|
693
|
+
- `builtInTools`: each of Codex's own tool groups is on unless set `false`.
|
|
694
|
+
`local: false` takes away the shell, `apply_patch`, `view_image` and
|
|
695
|
+
`write_stdin`, from the sub-agents Codex spawns too, so nothing the agent
|
|
696
|
+
runs reads or writes the disk;
|
|
697
|
+
`webSearch: false` and `imageGeneration: false` take away those. With
|
|
698
|
+
image generation on, a picture comes as an `image_generation` tool part
|
|
699
|
+
without its bytes: `metadata.savedPath`, when Codex gives one, names a file
|
|
700
|
+
on the engine's machine, which a client elsewhere cannot open; a client
|
|
701
|
+
that asks for `includeRaw` still receives Codex's own item, bytes included.
|
|
702
|
+
Codex still gives the model code mode's `exec`, its sub-agent tools and
|
|
703
|
+
its question tool, so `disableTools` stays refused.
|
|
704
|
+
- **Status and sign-in** are the person's own: read `auth/status` and start
|
|
705
|
+
`auth/login` with no `env`, since the turns run on the person's own login,
|
|
706
|
+
not on anything in a session's home.
|
|
707
|
+
|
|
708
|
+
Codex holds MCP tools back from the model until it searches for them, so
|
|
709
|
+
name your tools in the turn's `systemPromptAppend`.
|
|
710
|
+
|
|
711
|
+
Codex asks about an MCP tool call (a `permission.requested`) unless the
|
|
712
|
+
server marks the tool `readOnlyHint: true`, and never asks about one it
|
|
713
|
+
marks so: on Codex your server's annotations decide what is asked, not a
|
|
714
|
+
rule of yours (measured, Codex 0.160.0: a `save_note` marked read-only ran
|
|
715
|
+
with nothing asked; unmarked, it was asked about). Annotate your tools to
|
|
716
|
+
match what you want asked. To tell which of your tools a call is, read
|
|
717
|
+
`mcp.server` and `mcp.tool` on the tool part or the permission request's
|
|
718
|
+
`toolCall`, the same on both harnesses: `toolName` is each harness's own
|
|
719
|
+
spelling (`mcp__<server>__<tool>` on Claude, `<server>.<tool>` on Codex).
|
|
720
|
+
Only a Claude `toolPolicy`, which sees no part, gets Claude's own name.
|
|
721
|
+
|
|
586
722
|
## Own your session resources
|
|
587
723
|
|
|
588
724
|
### Configure MCP between turns
|
|
@@ -659,7 +795,8 @@ every Codex turn names one). An existing, absolute, session-specific
|
|
|
659
795
|
directory, where the engine writes the turn's servers. Create it with mode
|
|
660
796
|
`0700`, retain it while
|
|
661
797
|
the conversation may resume, and delete it when that logical session is
|
|
662
|
-
released
|
|
798
|
+
released: `session/close` and `session/release` answer once the session's
|
|
799
|
+
processes have exited, so nothing writes to the home after the answer. It contains conversation history and MCP credentials. Never share
|
|
663
800
|
it between sessions or use the operator's normal Codex home.
|
|
664
801
|
|
|
665
802
|
This isolates writable MCP configuration and conversation state; it does not
|
|
@@ -674,11 +811,11 @@ can use an embedded server's external authentication instead. Without
|
|
|
674
811
|
`--codex-home`, at `--inherit-config=all`, the CLI's Codex turns run in the
|
|
675
812
|
user's own home with their `--mcp` servers in the thread's config.
|
|
676
813
|
The ACP **server binding** (`createAcpAgentApp` /
|
|
677
|
-
`agent-server --acp --harness codex-app-server`)
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
814
|
+
`agent-server --acp --harness codex-app-server`) names no home for a session,
|
|
815
|
+
so it runs at `all` and a client's stdio and HTTP servers ride the thread's
|
|
816
|
+
config, as above; it refuses an SSE server and the name `codex_apps` at
|
|
817
|
+
`session/new` or `session/resume`. A session that needs a home of its own
|
|
818
|
+
uses the engine or the JSON-RPC API.
|
|
682
819
|
|
|
683
820
|
An explicitly supplied `CODEX_HOME` gives the engine ownership of that home's
|
|
684
821
|
user-layer `mcp_servers` table: each turn replaces that table, including
|
|
@@ -706,9 +843,11 @@ automatically replayed.
|
|
|
706
843
|
After thawing a VM, call `runtime.invalidateMcpConnections()` before admitting
|
|
707
844
|
new turns. Drain active turns before suspending the host. This embed-tier
|
|
708
845
|
lifecycle signal retains conversation state and turn-admission receipts.
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
that turn's current MCP credentials
|
|
846
|
+
It ends no process: before each session's next prompt, the Claude, Codex
|
|
847
|
+
app-server and ACP harnesses replace the retained subprocess and strictly
|
|
848
|
+
resume its saved conversation, using that turn's current MCP credentials
|
|
849
|
+
before reconnecting the tools. An ACP agent that can neither resume nor load
|
|
850
|
+
keeps its process, as it holds the only copy of its conversation.
|
|
712
851
|
Missing history fails with `resume_failed`; it never silently starts an empty
|
|
713
852
|
conversation. Ordinary warm turns still reuse the process.
|
|
714
853
|
|
|
@@ -886,7 +1025,12 @@ line (`The tool failed: "…"`); turn your own refusals into `OperatorError`s.
|
|
|
886
1025
|
## Listen to the engine's diagnostics
|
|
887
1026
|
|
|
888
1027
|
Pass `onDiagnostic` (registry/runtime/proxy options) and log what arrives:
|
|
889
|
-
`interruptTimeout`, `sinkError`, `proxyUpstreamAuth
|
|
1028
|
+
`interruptTimeout`, `sinkError`, `proxyUpstreamAuth`, and `claudeSdkMismatch`:
|
|
1029
|
+
the Claude SDK that loaded (as it names itself when `query()` runs) and the
|
|
1030
|
+
CLI build it drives (its platform package's version) are different releases,
|
|
1031
|
+
said once per process with `detail: {sdkVersion, cliVersion, cliPath}` and on
|
|
1032
|
+
stderr. A package manager that lets another SDK in (bun says nothing of an
|
|
1033
|
+
exact peer) shows up here; the turn still runs.
|
|
890
1034
|
These are the signals the engine deliberately does not fail turns over — a
|
|
891
1035
|
product that doesn't surface them debugs blind.
|
|
892
1036
|
|
|
@@ -909,7 +1053,9 @@ open parts, then its frames live; omitted, from the head) until
|
|
|
909
1053
|
`unsubscribe`, which ends the watch (a turn of this client's there is still
|
|
910
1054
|
followed to its end); `subscribeAll()` is for observers: every session, live
|
|
911
1055
|
from then, with no history (`session/subscribeAll` on the wire; `unsubscribeAll()`
|
|
912
|
-
is `session/unsubscribeAll`).
|
|
1056
|
+
is `session/unsubscribeAll`). The client follows every session from the
|
|
1057
|
+
call until `unsubscribeAll()`: a connection that drops before the answer asks
|
|
1058
|
+
the server it redials, and `subscribeAll()` resolves on that answer. `joinTurn(sessionId, {fromSeq})` watches the
|
|
913
1059
|
session and joins the turn it runs (`undefined` when none): a handle that
|
|
914
1060
|
yields the kept events from `fromSeq` (default: the turn's start), then the
|
|
915
1061
|
turn's open parts, then live frames through its `turn.ended`, each once,
|
|
@@ -928,7 +1074,11 @@ with what the client kept of it. A redial subscribes again to each session
|
|
|
928
1074
|
followed, from what the client holds, the running turns' first, and so does a
|
|
929
1075
|
`session/overflow`: the notice a server sends when the connection fell
|
|
930
1076
|
`maxBacklogBytes` (16 MiB) behind and it stopped streaming the session; what
|
|
931
|
-
was dropped heals by replay and the open parts. A
|
|
1077
|
+
was dropped heals by replay and the open parts. A connection is always told
|
|
1078
|
+
it overflowed, or closed: `listen` keeps Bun's own `backpressureLimit` 64 MiB
|
|
1079
|
+
above the bound, so the notice gets through, and a socket that still refuses
|
|
1080
|
+
a send (one frame larger than that headroom) is closed, which a client that
|
|
1081
|
+
reconnects heals by its redial and replay. Over stdio nothing is dropped. A refused re-subscription
|
|
932
1082
|
fails the session's turns with `EventGapError` (`onEventGap`:
|
|
933
1083
|
`session_missing`, or `subscription_refused`) instead of leaving them
|
|
934
1084
|
waiting. When the answer says the turn it subscribed again for runs no more
|
|
@@ -957,10 +1107,15 @@ outage instead of going quiet: `disconnected` (with the reason), `reconnecting`
|
|
|
957
1107
|
before each redial (`attempt`, `delayMs`, and the `error` the one before
|
|
958
1108
|
failed with), `reconnected` (`attempts`, `downMs`, the new `initialize`, and
|
|
959
1109
|
`serverChanged` when the server no longer holds the logs this client followed:
|
|
960
|
-
another journal, none, or a volatile restart), `refused`
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
`
|
|
1110
|
+
another journal, none, or a volatile restart), `refused` when the server
|
|
1111
|
+
refused the client, which every redial would get, so the client stops and
|
|
1112
|
+
fails what waits with `ConnectionRefusedError`: `reason` `token_refused` or
|
|
1113
|
+
`token_required` for a redial refused its token, or `protocol_mismatch`
|
|
1114
|
+
(with `protocolVersion`, this client's, and `supported`, the server's) for
|
|
1115
|
+
any handshake with a server of another wire protocol version, whose error is
|
|
1116
|
+
the `ProtocolVersionMismatchError` subclass (it carries the wire error's
|
|
1117
|
+
`code` and `data` too): only upgrading the older of the two helps, and `closed`
|
|
1118
|
+
(`close()`, a connection that does not
|
|
964
1119
|
redial, redialing that gave up after `maxReconnectAttempts`, default 8,
|
|
965
1120
|
`Infinity` redials until `close()`, or a refusal).
|
|
966
1121
|
Handlers run before requests waiting on the redial are sent again. After
|
|
@@ -1006,6 +1161,101 @@ platform it dials, never `$AGENT_SERVER_TOKEN`, which a listener's clients
|
|
|
1006
1161
|
present).
|
|
1007
1162
|
Subscriptions filter delivery; they are not an authorization boundary.
|
|
1008
1163
|
|
|
1164
|
+
## Test your integration for nothing
|
|
1165
|
+
|
|
1166
|
+
The `scripted` harness plays a script instead of a model, through the same
|
|
1167
|
+
runtime, server and client your product uses, under its own name, so your
|
|
1168
|
+
own code runs unchanged and costs nothing ([the steps](harnesses.md#the-scripted-harness)).
|
|
1169
|
+
A `call` step calls your real MCP server; `ask: true` goes through your
|
|
1170
|
+
permission handling; `echo: "config"` shows what your code sent.
|
|
1171
|
+
|
|
1172
|
+
```ts
|
|
1173
|
+
const runtime = createAgentRuntime({
|
|
1174
|
+
harnesses: ["scripted"],
|
|
1175
|
+
scripted: {
|
|
1176
|
+
turn: scriptedQueue([
|
|
1177
|
+
{ call: { server: "notes", tool: "search_notes", arguments: { query: "garden" } } },
|
|
1178
|
+
{ say: "Found it." },
|
|
1179
|
+
{ end: true },
|
|
1180
|
+
]),
|
|
1181
|
+
},
|
|
1182
|
+
});
|
|
1183
|
+
```
|
|
1184
|
+
|
|
1185
|
+
A product that spawns the stock program, or is not written in TypeScript,
|
|
1186
|
+
gives it a JSONL file instead, one step per line:
|
|
1187
|
+
`agent-server --script turns.jsonl --listen 4747`. `apps/agent-demo` runs
|
|
1188
|
+
its product checks this way: `bun run agent-demo -- --harness=scripted`.
|
|
1189
|
+
|
|
1190
|
+
## What products got wrong, so you need not
|
|
1191
|
+
|
|
1192
|
+
Each of these was found in a product built on the engine, or measured against
|
|
1193
|
+
the agents themselves (LLP 0015). None needs code of your own to avoid.
|
|
1194
|
+
|
|
1195
|
+
**Sessions**
|
|
1196
|
+
|
|
1197
|
+
- **Close a session when you are done with it** (`closeSession`). Until then
|
|
1198
|
+
the engine keeps it bound to its harness and its process warm for the idle
|
|
1199
|
+
time (`idleTimeoutMs`, 5 minutes by default), and an ACP agent that cannot resume is never ended for idleness. One
|
|
1200
|
+
product never closed any. Remove what you made for the session (a Codex
|
|
1201
|
+
home) after the close answers: it answers once the agent's process has
|
|
1202
|
+
exited.
|
|
1203
|
+
- **Persist the native id** from `session.created` and pass it back as
|
|
1204
|
+
`resumeSessionId`. A wrong one fails every later turn of that `sessionId`
|
|
1205
|
+
on purpose; start a new `sessionId` to start over.
|
|
1206
|
+
- **Read how a reopened durable session's last turn ended from `getSession`**
|
|
1207
|
+
(`lastTurn`: `stopReason`, and `error` with the category `server_restart`
|
|
1208
|
+
for a turn a restart cut off), not by replaying its history; and whether it
|
|
1209
|
+
still waits for `confirmSessionStopped` from `recoveryRequired`, never from
|
|
1210
|
+
that turn's words, which a confirmation does not change.
|
|
1211
|
+
- **Name a journal file from `JOURNAL_SCHEMA_VERSION`**
|
|
1212
|
+
([durable sessions](durable-sessions.md)), not from a number you copied.
|
|
1213
|
+
|
|
1214
|
+
**Logins and credentials**
|
|
1215
|
+
|
|
1216
|
+
- **Sign in through the engine** (`auth/login`), not by typing a CLI command
|
|
1217
|
+
into a terminal. The engine learns of a login made elsewhere only at the
|
|
1218
|
+
next status read.
|
|
1219
|
+
- **Hold a credential with [`./accounts`](#hold-the-login-yourself-for-sandboxes-and-other-devices),**
|
|
1220
|
+
not with a copy of it. One product rewrote about 550 lines of it.
|
|
1221
|
+
- **Offer models from `models/list`,** not from the built-in catalog: the
|
|
1222
|
+
live list belongs to the login and its route.
|
|
1223
|
+
- **Do not check the Claude SDK's version yourself.** The engine says when the
|
|
1224
|
+
SDK and the CLI build differ (`claudeSdkMismatch`, above); pin the CLI with
|
|
1225
|
+
`provision.pins` when your bundle carries its own SDK.
|
|
1226
|
+
|
|
1227
|
+
**What the agent may do**
|
|
1228
|
+
|
|
1229
|
+
- **Limit Claude's own tools with the SDK's `tools` list,** not with a
|
|
1230
|
+
`toolPolicy` alone: the policy hears only what Claude asks about, and a read
|
|
1231
|
+
in the turn's folder is not asked ([a product's own agent](#a-products-own-agent-on-the-persons-own-login)).
|
|
1232
|
+
- **Do not assume a permission mode means the same on both agents.**
|
|
1233
|
+
`accept_edits` lets Codex run shell writes unasked, `plan` stops writes on
|
|
1234
|
+
neither once a call is approved, and Codex never asks before a read
|
|
1235
|
+
([the table](harnesses.md#what-each-permission-mode-does-per-agent)). Under
|
|
1236
|
+
`bypass_permissions` your policy and your approvals never run at all.
|
|
1237
|
+
- **Choose what a turn inherits with `inheritConfig`,** not with raw SDK
|
|
1238
|
+
options: `none` for a repository you do not trust.
|
|
1239
|
+
- **On Codex, mark your MCP tools as what they are.** A tool marked
|
|
1240
|
+
`readOnlyHint` is never asked about, any other always is.
|
|
1241
|
+
|
|
1242
|
+
**Reading the stream**
|
|
1243
|
+
|
|
1244
|
+
- **Read `mcp.server` and `mcp.tool`** on a tool part or a permission request,
|
|
1245
|
+
not the spelling of `toolName`, which differs by agent.
|
|
1246
|
+
- **Read `capabilities.ignoredSettings` and `execution.notApplied`,** not a
|
|
1247
|
+
table of your own of what each agent supports.
|
|
1248
|
+
- **Read an error's `category`,** not its text. One product classified
|
|
1249
|
+
failures by regular expressions on a provider's words.
|
|
1250
|
+
- **Ask `isFailureStopReason`** whether a turn failed. `max_tokens`,
|
|
1251
|
+
`max_turn_requests`, `refusal` and `cancelled` are clean ends; one product
|
|
1252
|
+
treated everything but `end_turn` as an interruption.
|
|
1253
|
+
- **Test against the engine, not a stand-in of your own,** where you can: the
|
|
1254
|
+
free scenario (`bun run harness -- --harness=codex-app-server
|
|
1255
|
+
--scenario=codex-tools-off`) and `apps/agent-demo` run real CLIs. Three
|
|
1256
|
+
products wrote a scripted agent of their own; the engine now ships one,
|
|
1257
|
+
the `scripted` harness ([test your integration for nothing](#test-your-integration-for-nothing)).
|
|
1258
|
+
|
|
1009
1259
|
---
|
|
1010
1260
|
|
|
1011
1261
|
Something here wrong, unclear or missing? [Report it to the maintainers](feedback.md).
|
package/docs/deploy.md
CHANGED
|
@@ -49,8 +49,15 @@ only, and the log says so once.
|
|
|
49
49
|
|
|
50
50
|
**A product that bundles the Claude SDK** (an ESM or single-file build of its
|
|
51
51
|
own) sets `provision.pins.claude` to the SDK's version: nothing on disk says
|
|
52
|
-
which SDK runs, so the engine runs the CLI of its own pin and logs that once
|
|
53
|
-
|
|
52
|
+
which SDK runs, so the engine runs the CLI of its own pin and logs that once,
|
|
53
|
+
naming the folder it looked up from. The engine looks from where its own
|
|
54
|
+
module (or the bundle holding it) is, under Bun, Node's ESM (tsx, an ESM
|
|
55
|
+
bundle) and CJS alike, never from the working folder. Within a compiled
|
|
56
|
+
`agent-server` binary the pin is the SDK it bundles. When the SDK that
|
|
57
|
+
loaded and the CLI build it drives are different releases, the engine says
|
|
58
|
+
so once, on stderr and as the `claudeSdkMismatch` diagnostic
|
|
59
|
+
([consuming.md](consuming.md#listen-to-the-engines-diagnostics)); the turn
|
|
60
|
+
still runs.
|
|
54
61
|
|
|
55
62
|
Pins live in `src/core/provision/pins.ts`: the claude pin tracks the
|
|
56
63
|
lockfile's `@anthropic-ai/claude-agent-sdk` version (test-enforced); the codex
|
|
@@ -62,9 +69,18 @@ test-enforced).
|
|
|
62
69
|
image layers and shared volumes dedupe naturally. Processes that cold-start
|
|
63
70
|
together on one cache each download, and the build's atomic rename leaves one
|
|
64
71
|
copy (four at once took 15.8 s instead of 4.9 s): bake the CLIs into the
|
|
65
|
-
image instead. A
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
image instead. A download that is cut (a reset connection, nothing
|
|
73
|
+
received for 30 s, or an end short of its stated size) goes on from the
|
|
74
|
+
bytes it has with an HTTP `Range` request, or starts over where the server
|
|
75
|
+
does not honour one; it gives up after five attempts in a row that get no
|
|
76
|
+
further into the file (25 in all), as a `network` failure saying how far it
|
|
77
|
+
got ("the transfer ended after 10485760 of 100276474 bytes"). The checksum is
|
|
78
|
+
checked once, over the whole file, so "Integrity mismatch" is said only of a
|
|
79
|
+
file that arrived whole (one put together from several responses is first
|
|
80
|
+
downloaded once more in one piece), and a build whose checksum is wrong is
|
|
81
|
+
never installed. The registry metadata is asked up to three times, waiting
|
|
82
|
+
30 s, 60 s, then 90 s for its answer (headers and body); a `tar` still
|
|
83
|
+
running after 5 min fails rather than holding a turn. Each use of a build is
|
|
68
84
|
recorded (again hourly while a process keeps resolving it), and after each
|
|
69
85
|
download builds whose recorded use is 14 days old are removed: several
|
|
70
86
|
products may share one cache, each keeping its own pins by using them.
|
|
@@ -102,7 +118,12 @@ await client.listClis(); // ready | missing | installing | failed | unmanaged, i
|
|
|
102
118
|
```
|
|
103
119
|
|
|
104
120
|
`prepareClis` joins an install already running and answers once each CLI is
|
|
105
|
-
ready or failed (`error` says why
|
|
121
|
+
ready or failed (`error` says why, and `category` what failed, from the
|
|
122
|
+
error vocabulary: `network` for a registry that cannot be reached or answers
|
|
123
|
+
5xx and for a transfer that was cut, so ask again later; `internal` for a
|
|
124
|
+
build whose checksum is wrong; `invalid_request` for an override that points
|
|
125
|
+
nowhere); it never throws for a failed install. A turn that fails on the
|
|
126
|
+
install carries the same category.
|
|
106
127
|
Over the wire, `clis/prepare` answers at once (`installing`), since an
|
|
107
128
|
install outlasts a request's timeout, and the client waits on `clis/progress`
|
|
108
129
|
and `clis/list`. `missing` without a `version` means the server installs
|
|
@@ -166,7 +187,10 @@ remotely with `clis/prepare`, its progress streaming back.
|
|
|
166
187
|
|
|
167
188
|
`agent-server install` respects `--harness a,b` (only fetch what you run) and
|
|
168
189
|
`$AGENT_SERVER_CACHE_DIR` (e.g. point it at a persistent volume instead of
|
|
169
|
-
baking).
|
|
190
|
+
baking). It says what each version is: Claude's is the Claude SDK package's
|
|
191
|
+
(`claude: Claude SDK package 0.3.288 (Claude Code 2.1.288) for linux-x64
|
|
192
|
+
ready: …`), Codex's its CLI's. A harness it installs nothing for (an ACP
|
|
193
|
+
agent such as `pi`, which runs from its launch command) is said as such.
|
|
170
194
|
|
|
171
195
|
Measured (2026-10-31, `debian:bookworm-slim` arm64 under Docker, from a home
|
|
172
196
|
connection): `install` of both CLIs 5 s; a cold sandbox prepared over the
|
|
@@ -203,7 +227,11 @@ agent-server install --platform darwin-arm64,darwin-x64 --dir build/agent-clis
|
|
|
203
227
|
`--dir` writes the cache's layout into a new or empty folder (or one it wrote
|
|
204
228
|
before; any other is refused, as staging opens what it writes to every
|
|
205
229
|
user), makes the builds it staged readable by every user, never through a
|
|
206
|
-
symlink,
|
|
230
|
+
symlink, creates the folder and the parents of it that are missing readable
|
|
231
|
+
and traversable by every user (0755, whatever the umask: `install --dir
|
|
232
|
+
/opt/app/clis` as root in an image build leaves `/opt/app` reachable by the
|
|
233
|
+
runtime user; a folder that was there is left as it is), and leaves out the
|
|
234
|
+
install's records; `--harness` selects
|
|
207
235
|
as usual. Where it runs, the app names the folder: `provision.bundleDirs`
|
|
208
236
|
(or `$AGENT_SERVER_BUNDLE_DIR`, a path list). A bundle folder is used in
|
|
209
237
|
every mode when it holds the version this engine runs, before the host and
|
package/docs/durable-sessions.md
CHANGED
|
@@ -70,7 +70,7 @@ file; serve other readers over the wire.
|
|
|
70
70
|
| `turn/start` | Admission is committed (with the input) before the ack. A retry converges on the receipt: `deduplicated: true`, plus `terminal` once the turn ended. A redialing client re-sends a start whose ack it lost, unless the server's logs are new (a volatile restart). |
|
|
71
71
|
| `events/replay` | Served from the journal, a page at a time; `hasMore` asks for the next. Closed sessions answer `unknownSession`, as on volatile servers. |
|
|
72
72
|
| `turn/get` | A turn's receipt: `admitted`, `completed` or `interrupted`, its input and terminal event. |
|
|
73
|
-
| `session/get` | `headSeq`, `nativeSessionId`, `closed`, `recoveryRequired
|
|
73
|
+
| `session/get` | `headSeq`, `nativeSessionId`, `closed`, `recoveryRequired` (and `recoveryReason`), and `lastTurn`: the latest turn's `turnId`, with its `stopReason` and `error` once it ended (`server_restart` for one a restart cut off). |
|
|
74
74
|
| `session/confirmStopped` | Lifts the fence a restart put on a session, fenced by `expectedHeadSeq`. |
|
|
75
75
|
| `session/release` | Lets an idle session's agent go (its process, a Codex home it holds) and keeps the session open. Its next turn names its native conversation (`resumeRequired` until it does), as after a restart. Nothing is broadcast: another client of the session meets `resumeRequired` on its next turn. `released: false` for no open session by that id; `turnActive` while a turn runs. |
|
|
76
76
|
| `history/*` | Opt-in (`history` option): the [history protocol](sync-history.md). |
|
|
@@ -93,7 +93,10 @@ refusal carries in `data` is typed by `WIRE_REFUSAL_DATA`, and
|
|
|
93
93
|
| `unknownTurn` (-32013) | `turn/get` for a turn the session never admitted (`unknownSession` when the session itself is unknown). | |
|
|
94
94
|
|
|
95
95
|
A request the journal cannot store (an id over 512 characters, input over the
|
|
96
|
-
record limit, `includeRaw`) is `invalidParams`, never a server fault.
|
|
96
|
+
record limit, `includeRaw`) is `invalidParams`, never a server fault. Input
|
|
97
|
+
over the limit says both sizes in its message, `Input is N bytes; the durable
|
|
98
|
+
record limit is 8355840 bytes`: the record limit below, 8 MB less 32 KB, of
|
|
99
|
+
the input's canonical JSON.
|
|
97
100
|
|
|
98
101
|
## Guarantees
|
|
99
102
|
|
|
@@ -105,8 +108,25 @@ record limit, `includeRaw`) is `invalidParams`, never a server fault.
|
|
|
105
108
|
2. **Event before delivery.** Each event commits (and advances its hash chain)
|
|
106
109
|
before broadcast. `turn.ended` settles the receipt and `session.ended` closes
|
|
107
110
|
the session in the same transaction. An event the journal cannot store is
|
|
108
|
-
stored cut down to fit,
|
|
109
|
-
|
|
111
|
+
stored cut down to fit, or as a notice in its place; the turn and other
|
|
112
|
+
sessions go on. Cutting takes the event's longest string first, until it
|
|
113
|
+
fits: text is cut, marked `[agent-server: N bytes omitted to fit the
|
|
114
|
+
journal]`; an image or file (an object whose `type` is `image` or `file`,
|
|
115
|
+
with base64 `data` and a `mimeType`: a tool result's `content` image, an
|
|
116
|
+
image or file part) is never cut, but replaced whole by text saying what it
|
|
117
|
+
was, `[agent-server: image/png image of N bytes omitted to fit the
|
|
118
|
+
journal]`: a `content` entry by a `text` entry, a part by a `text` part
|
|
119
|
+
with the same `id`. Its `_meta` holds the facts under
|
|
120
|
+
`OMITTED_BINARY_META_KEY` (`"agent-server/omittedBinary"`):
|
|
121
|
+
`{ type, mimeType, bytes, filename? }`, `bytes` the binary's decoded size.
|
|
122
|
+
What the journal keeps is what every client receives, live and on replay
|
|
123
|
+
alike: an entry too large for a record is the marker for everyone, and a
|
|
124
|
+
product that needs larger pictures delivers them outside the stream. A
|
|
125
|
+
checkpoint (`createCheckpoint`) replaces images and files the same way, largest first,
|
|
126
|
+
saying `omitted to fit this checkpoint`, until it fits `HISTORY_MAX_BYTES`
|
|
127
|
+
(8 MB); only text alone can still make one too large. A reader that opens a
|
|
128
|
+
history from a checkpoint sees its markers where a full replay sees the
|
|
129
|
+
images the events kept.
|
|
110
130
|
3. **A decision follows its record.** The harness receives a permission
|
|
111
131
|
decision only after `permission.resolved` is written; a failed write refuses
|
|
112
132
|
the tool. Async sinks that must record a request before a reentrant response
|
|
@@ -134,7 +154,9 @@ record limit, `includeRaw`) is `invalidParams`, never a server fault.
|
|
|
134
154
|
it; `not_verified`; `not_stopped`, it survived SIGKILL); a host checks it
|
|
135
155
|
and confirms (`session/confirmStopped`). Either way the next turn resumes
|
|
136
156
|
the native session explicitly (`resumeRequired` names it). The turn's error
|
|
137
|
-
message says which it was
|
|
157
|
+
message says which it was, and `session/get` says it without the history:
|
|
158
|
+
`lastTurn.error.category` is `server_restart`, and `recoveryRequired` is
|
|
159
|
+
whether the fence is still up.
|
|
138
160
|
|
|
139
161
|
While the server lives, its lifeline (one `/bin/sh` per process, holding a
|
|
140
162
|
pipe from it) stops every agent and tool it started when the server dies
|
|
@@ -170,6 +192,14 @@ started, until each is seen gone; `commits` and `checkpoints` serve branches
|
|
|
170
192
|
and cached projections. `EventLog.append` is the one write path for execution, commits,
|
|
171
193
|
imports and recovery.
|
|
172
194
|
|
|
195
|
+
The schema's number is exported: `JOURNAL_SCHEMA_VERSION` from
|
|
196
|
+
`@zvada/agent-server/sync`, which loads no SQLite driver. A product that
|
|
197
|
+
starts a new journal file per schema names the file from it
|
|
198
|
+
(`` `journal-${JOURNAL_SCHEMA_VERSION}.sqlite` ``) rather than from a number
|
|
199
|
+
of its own: a release that changes the schema then opens a new file for its
|
|
200
|
+
existing users too, where a hardcoded name would refuse their old one, which
|
|
201
|
+
a test on a fresh file never meets.
|
|
202
|
+
|
|
173
203
|
## Not covered
|
|
174
204
|
|
|
175
205
|
- No product integration, public relay, deployment or credential exchange.
|