@zvada/agent-server 0.3.24 → 0.3.26
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 +110 -0
- package/README.md +3 -0
- package/dist/client/client.js +93 -34
- package/dist/core/agents/acp/acp-agent.js +91 -14
- package/dist/core/agents/acp/mappings.js +5 -1
- package/dist/core/agents/claude-code/approvals.js +2 -1
- package/dist/core/agents/claude-code/claude-agent.js +12 -2
- package/dist/core/agents/claude-code/mcp.js +9 -1
- package/dist/core/agents/claude-code/models.js +16 -10
- package/dist/core/agents/claude-code/options.js +23 -2
- package/dist/core/agents/claude-code/session.js +21 -1
- package/dist/core/agents/claude-code/tools.js +9 -4
- package/dist/core/agents/claude-code/turn.js +2 -0
- package/dist/core/agents/codex-app-server/adapter.js +2 -0
- package/dist/core/agents/codex-app-server/client.js +8 -5
- package/dist/core/agents/codex-app-server/codex-agent.js +35 -2
- package/dist/core/agents/codex-app-server/effort.js +13 -6
- package/dist/core/agents/codex-app-server/mcp.js +35 -18
- package/dist/core/agents/codex-app-server/models.js +10 -10
- package/dist/core/agents/codex-app-server/options.js +11 -2
- package/dist/core/agents/codex-app-server/session.js +11 -4
- package/dist/core/agents/codex-app-server/thread-settings.js +30 -11
- package/dist/core/agents/host-tools.js +493 -0
- package/dist/core/agents/mcp-config.js +6 -2
- package/dist/core/agents/scripted/scripted-agent.js +11 -4
- package/dist/core/agents/scripted/steps.js +5 -1
- package/dist/core/agents/session-agent.js +70 -2
- package/dist/core/agents/thinking-levels.js +8 -5
- package/dist/core/index.js +1 -0
- package/dist/core/presets.js +12 -2
- package/dist/core/processes/identity.js +1 -0
- package/dist/core/processes/lifeline.js +13 -1
- package/dist/core/processes/process-table.js +1 -0
- package/dist/core/provision/extract.js +1 -0
- package/dist/core/provision/pins.js +7 -16
- package/dist/core/provision/releases.js +25 -25
- package/dist/core/proxy/loopback.js +22 -4
- package/dist/core/runtime/agent-runtime.js +6 -3
- package/dist/core/runtime/turn.js +20 -10
- package/dist/protocol/config.js +21 -1
- package/dist/protocol/credentials.js +2 -1
- package/dist/protocol/errors.js +12 -3
- package/dist/protocol/model-catalog.js +58 -18
- package/dist/protocol/models.js +6 -27
- package/dist/protocol/thinking.js +22 -9
- package/dist/protocol/wire-api.js +2 -2
- package/dist/server/bin.js +6 -4
- package/dist/server/routes.js +3 -2
- package/dist/types/client/client.d.ts +6 -1
- package/dist/types/client/client.d.ts.map +1 -1
- package/dist/types/core/agents/acp/acp-agent.d.ts +15 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
- package/dist/types/core/agents/acp/mappings.d.ts +5 -1
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
- package/dist/types/core/agents/acp/requests.d.ts +2 -0
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/approvals.d.ts +2 -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 +1 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/mcp.d.ts +8 -1
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/models.d.ts +9 -5
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/options.d.ts +14 -1
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/session.d.ts +2 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/turn.d.ts +3 -0
- package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -1
- 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 +2 -0
- 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 +11 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/effort.d.ts +7 -7
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +11 -3
- 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 +4 -1
- 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 +9 -2
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/requests.d.ts +2 -0
- 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 +6 -3
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -1
- package/dist/types/core/agents/host-tools.d.ts +162 -0
- package/dist/types/core/agents/host-tools.d.ts.map +1 -0
- package/dist/types/core/agents/mcp-config.d.ts +11 -2
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -1
- package/dist/types/core/agents/scripted/scripted-agent.d.ts.map +1 -1
- package/dist/types/core/agents/scripted/steps.d.ts +1 -1
- package/dist/types/core/agents/scripted/steps.d.ts.map +1 -1
- package/dist/types/core/agents/session-agent.d.ts +2 -7
- package/dist/types/core/agents/session-agent.d.ts.map +1 -1
- package/dist/types/core/agents/thinking-levels.d.ts +7 -3
- package/dist/types/core/agents/thinking-levels.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/index.d.ts.map +1 -1
- package/dist/types/core/presets.d.ts +11 -1
- package/dist/types/core/presets.d.ts.map +1 -1
- package/dist/types/core/processes/identity.d.ts.map +1 -1
- package/dist/types/core/processes/lifeline.d.ts.map +1 -1
- package/dist/types/core/processes/process-table.d.ts.map +1 -1
- package/dist/types/core/provision/extract.d.ts.map +1 -1
- package/dist/types/core/provision/pins.d.ts +5 -4
- package/dist/types/core/provision/pins.d.ts.map +1 -1
- package/dist/types/core/proxy/loopback.d.ts.map +1 -1
- package/dist/types/core/runtime/agent-runtime.d.ts +4 -1
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
- package/dist/types/core/runtime/turn.d.ts +12 -7
- package/dist/types/core/runtime/turn.d.ts.map +1 -1
- package/dist/types/protocol/clis.d.ts +3 -3
- package/dist/types/protocol/config.d.ts +12 -19
- package/dist/types/protocol/config.d.ts.map +1 -1
- package/dist/types/protocol/conversation.d.ts +10 -42
- package/dist/types/protocol/conversation.d.ts.map +1 -1
- package/dist/types/protocol/credentials.d.ts +13 -1
- package/dist/types/protocol/credentials.d.ts.map +1 -1
- package/dist/types/protocol/errors.d.ts +6 -4
- package/dist/types/protocol/errors.d.ts.map +1 -1
- package/dist/types/protocol/execution.d.ts +2 -18
- package/dist/types/protocol/execution.d.ts.map +1 -1
- package/dist/types/protocol/lifecycle.d.ts +12 -76
- 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 +4 -42
- package/dist/types/protocol/models.d.ts.map +1 -1
- package/dist/types/protocol/thinking.d.ts +19 -19
- package/dist/types/protocol/thinking.d.ts.map +1 -1
- package/dist/types/protocol/wire-api.d.ts +32 -117
- package/dist/types/protocol/wire-api.d.ts.map +1 -1
- package/dist/types/protocol/wire.d.ts +24 -125
- package/dist/types/protocol/wire.d.ts.map +1 -1
- package/dist/types/server/routes.d.ts.map +1 -1
- package/docs/consuming.md +92 -12
- package/docs/deploy.md +8 -0
- package/docs/harnesses.md +88 -27
- package/package.json +4 -4
- package/src/client/client.ts +114 -44
- package/src/core/agents/acp/acp-agent.ts +123 -17
- package/src/core/agents/acp/mappings.ts +5 -1
- package/src/core/agents/acp/requests.ts +2 -0
- package/src/core/agents/claude-code/approvals.ts +2 -1
- package/src/core/agents/claude-code/claude-agent.ts +14 -2
- package/src/core/agents/claude-code/mcp.ts +11 -1
- package/src/core/agents/claude-code/models.ts +15 -10
- package/src/core/agents/claude-code/options.ts +37 -3
- package/src/core/agents/claude-code/session.ts +26 -1
- package/src/core/agents/claude-code/tools.ts +10 -4
- package/src/core/agents/claude-code/turn.ts +4 -0
- package/src/core/agents/codex-app-server/adapter.ts +2 -0
- package/src/core/agents/codex-app-server/client.ts +11 -5
- package/src/core/agents/codex-app-server/codex-agent.ts +45 -1
- package/src/core/agents/codex-app-server/effort.ts +15 -20
- package/src/core/agents/codex-app-server/mcp.ts +46 -23
- package/src/core/agents/codex-app-server/models.ts +10 -10
- package/src/core/agents/codex-app-server/options.ts +16 -2
- package/src/core/agents/codex-app-server/requests.ts +2 -0
- package/src/core/agents/codex-app-server/session.ts +19 -4
- package/src/core/agents/codex-app-server/thread-settings.ts +31 -11
- package/src/core/agents/host-tools.ts +649 -0
- package/src/core/agents/mcp-config.ts +15 -3
- package/src/core/agents/scripted/scripted-agent.ts +11 -3
- package/src/core/agents/scripted/steps.ts +5 -1
- package/src/core/agents/session-agent.ts +78 -2
- package/src/core/agents/thinking-levels.ts +9 -6
- package/src/core/index.ts +9 -0
- package/src/core/presets.ts +24 -3
- package/src/core/processes/identity.ts +1 -0
- package/src/core/processes/lifeline.ts +14 -1
- package/src/core/processes/process-table.ts +1 -0
- package/src/core/provision/extract.ts +1 -0
- package/src/core/provision/pins.ts +7 -16
- package/src/core/provision/releases.ts +25 -25
- package/src/core/proxy/loopback.ts +25 -4
- package/src/core/runtime/agent-runtime.ts +6 -3
- package/src/core/runtime/turn.ts +21 -9
- package/src/protocol/config.ts +22 -1
- package/src/protocol/credentials.ts +19 -5
- package/src/protocol/errors.ts +12 -3
- package/src/protocol/model-catalog.ts +58 -18
- package/src/protocol/models.ts +6 -26
- package/src/protocol/thinking.ts +27 -14
- package/src/protocol/wire-api.ts +2 -2
- package/src/server/bin.ts +6 -4
- package/src/server/routes.ts +3 -2
package/docs/harnesses.md
CHANGED
|
@@ -145,6 +145,29 @@ the engine writes them (LLP 0001, D21; see
|
|
|
145
145
|
ACP server binding, a client's stdio and HTTP servers take the first path;
|
|
146
146
|
an SSE server or one named `codex_apps` is refused at `session/new` or
|
|
147
147
|
`session/resume`, naming it.
|
|
148
|
+
|
|
149
|
+
An MCP server's `timeoutMs` says how long one call to its tools may run, in
|
|
150
|
+
milliseconds, on any transport: past it the call fails and the model is told
|
|
151
|
+
it timed out. The engine gives it to Claude as that server's `timeout`
|
|
152
|
+
(Claude ignores a value under 1000) and to Codex as its `tool_timeout_sec`,
|
|
153
|
+
in whole seconds rounded up (1118 becomes 2 s). It is at most 2,147,483,647,
|
|
154
|
+
a timer's own limit. A changed value applies from a warm session's
|
|
155
|
+
next turn. Without it each agent's own limit applies. Claude cuts a call to an HTTP or SSE server at 60 s: the tool part
|
|
156
|
+
fails with "The operation timed out." and the turn goes on.
|
|
157
|
+
`MCP_TOOL_TIMEOUT` (milliseconds) in the turn's `env`, or in the engine's
|
|
158
|
+
own, still sets that limit on Claude. A call to a stdio server or to an
|
|
159
|
+
in-process SDK server is not cut at 60 s (one ran 70 s, one 75 s); longer
|
|
160
|
+
was not measured, and Claude's own limits for those still apply. Codex cuts a call at 300 s ("timed
|
|
161
|
+
out awaiting tools/call after 300s"). Neither agent sends the server a
|
|
162
|
+
cancel when it cuts a call. An ACP agent is not given the limit, since ACP
|
|
163
|
+
has no field for it, and keeps its own. What was measured: LLP 0015.001, How long an
|
|
164
|
+
MCP tool call may run. The host's own tools
|
|
165
|
+
(`hostTools`) run 30 minutes unless their source says otherwise (LLP 0018,
|
|
166
|
+
Timeouts). Over ACP a host tool not marked read-only runs only when the
|
|
167
|
+
session has full access (`bypass_permissions`): an ACP agent need not ask
|
|
168
|
+
before it calls one, so the engine answers it that the tool needs full
|
|
169
|
+
access (LLP 0018, Permissions).
|
|
170
|
+
|
|
148
171
|
Below `inheritConfig: "all"` every Codex turn needs a home of its session's
|
|
149
172
|
own, so the bin refuses `--acp --harness codex-app-server` with
|
|
150
173
|
`--inherit-config project` or `none`.
|
|
@@ -190,20 +213,37 @@ turn runs at `none`. Claude's built-in plugins and skills and the host's
|
|
|
190
213
|
managed policy load at every level, and `~/.claude.json` is read for the
|
|
191
214
|
account (its MCP servers follow the user and local sources). A Codex session at `project` or `none`
|
|
192
215
|
runs in the `CODEX_HOME` its turn names, of the session's own, with Codex's
|
|
193
|
-
apps (the ChatGPT account's connectors) off,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
216
|
+
apps (the ChatGPT account's connectors) off, Codex's plugin catalogue not
|
|
217
|
+
downloaded (plugins off from the moment its process starts,
|
|
218
|
+
`-c features.plugins=false`: a fresh home otherwise clones the catalogue,
|
|
219
|
+
about 85 MB and 5,500 files, before any thread opens) while a plugin a
|
|
220
|
+
product installs in a home it owns still loads, and at `none` without the
|
|
221
|
+
repository's `AGENTS.md`. A session whose
|
|
197
222
|
home was removed or made again under its warm process starts a new one on its
|
|
198
223
|
next turn, which resumes the thread there or fails `resume_failed` as a cold
|
|
199
224
|
start would; the repository's skills and `~/.agents/skills` load
|
|
200
225
|
at every level. With `codexAppServer.userLogin` such a session runs on the
|
|
201
226
|
user's own Codex login ([below](#the-users-own-codex-login-in-a-sessions-home)).
|
|
202
227
|
|
|
203
|
-
`thinkingLevel`
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
228
|
+
`thinkingLevel` names one of the model's `thinking.levels`: the harness's own
|
|
229
|
+
names, in the order it lists them (both CLIs list lowest first). `off`, `low`,
|
|
230
|
+
`medium`, `high`, `xhigh`, `max` and `ultra` are the levels agent-server knows
|
|
231
|
+
and orders (`THINKING_LEVELS`); a model may list others, and they are kept as
|
|
232
|
+
named. agent-server fits a level to the model's levels when it knows them. A
|
|
233
|
+
level the model lists is sent as it is. A level the model does not list is
|
|
234
|
+
fitted to the nearest level the engine can order: a level above the model's
|
|
235
|
+
top becomes that top (`ultra` on a model whose top is `max` runs `max`), and
|
|
236
|
+
on Codex `off` becomes the model's lowest (current models reject `minimal`).
|
|
237
|
+
When there is none (a level agent-server does not know, or a model that lists
|
|
238
|
+
none it knows), it is not applied: the harness is sent no level, the model
|
|
239
|
+
runs as on a turn that names none, and `turn.ended.execution.notApplied`
|
|
240
|
+
names `thinkingLevel`. When the model's levels are unknown (no list read, and
|
|
241
|
+
not in the catalog), any level is sent as asked (on Claude, `ultra` as
|
|
242
|
+
`max`). Measured on Claude Code
|
|
243
|
+
2.1.327 on 2026-11-19, Claude Code ignores an effort it does not know and
|
|
244
|
+
runs the model's default (it warns `Unknown --effort value` on stderr); on
|
|
245
|
+
Codex 0.169.1, the same day, Codex passes it to the provider as the request's
|
|
246
|
+
`reasoning.effort`, and the provider decides. The levels come
|
|
207
247
|
from the list `models()` read for the turn's login and folder; for a concrete
|
|
208
248
|
model id, any login's list or the catalog also serves, even one that names the
|
|
209
249
|
model only as what an alias runs (an API key's Claude list names Opus 5.5 only
|
|
@@ -215,15 +255,20 @@ cancelled before the model answered:
|
|
|
215
255
|
- **claude-code** fits the level before starting Claude, because Claude Code
|
|
216
256
|
lowers a level its model lacks without saying so (`xhigh` on Sonnet 4.6 runs
|
|
217
257
|
`high`). With no known levels the level passes through and no applied level
|
|
218
|
-
is reported. A model known to have no levels (`thinking.levels: []`, Haiku
|
|
219
|
-
is started without one, as Claude Code runs it by default (Haiku
|
|
220
|
-
thinks
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
258
|
+
is reported. A model known to have no levels (`thinking.levels: []`, Haiku
|
|
259
|
+
4.5) is started without one, as Claude Code runs it by default (Haiku 4.5
|
|
260
|
+
then still thinks: 53 reasoning tokens on a turn that asked for `high`),
|
|
261
|
+
and no applied level is reported. `off` is sent as is, on Haiku 4.5 too,
|
|
262
|
+
where it stops that default thinking. Some models do not let thinking be
|
|
263
|
+
disabled: Haiku 5.5 at `off` still spends thinking tokens (36, with one
|
|
264
|
+
empty reasoning part; both measured on Claude Code 2.1.327, 2026-11-19).
|
|
265
|
+
An operator `sdkOptions` that sets `effort` or `thinking` wins, and then no
|
|
266
|
+
level is reported.
|
|
224
267
|
- **codex-app-server** reads what the thread's model accepts from its own
|
|
225
268
|
`model/list`. A model it lists with no efforts at all, or the engine knows
|
|
226
|
-
has no levels, is sent no effort, and no level is reported.
|
|
269
|
+
has no levels, is sent no effort, and no level is reported. A level with no
|
|
270
|
+
fit among the levels the model lists runs as a turn that names no level,
|
|
271
|
+
below, and the thread's effort is the level reported. With no level
|
|
227
272
|
requested it reports the thread's effort (for
|
|
228
273
|
example from `~/.codex/config.toml`), and the thread's model in
|
|
229
274
|
`reportedModels` when the stream names none. Codex runs the effort it is
|
|
@@ -283,8 +328,9 @@ operator's, and not named as not applied.
|
|
|
283
328
|
|
|
284
329
|
## What each permission mode does, per agent
|
|
285
330
|
|
|
286
|
-
Measured on
|
|
287
|
-
Haiku
|
|
331
|
+
Measured on macOS on Claude Code 2.1.327 (Claude SDK 0.3.327, model `haiku`,
|
|
332
|
+
which is Haiku 5.5 and runs its `plan` turns on Sonnet 5.5) on 2026-11-19, and
|
|
333
|
+
on Codex 0.160.0 on 2026-11-15, through the engine at `inheritConfig: "none"`. Each
|
|
288
334
|
call ran in a fresh session and folder, with every `permission.requested`
|
|
289
335
|
answered `allow_once`, and each call that asked ran again with the request
|
|
290
336
|
answered `reject_once`. Whether a call ran is read from the file on disk, the
|
|
@@ -300,8 +346,10 @@ bun run harness -- --harness=claude-code,codex-app-server --scenario=permission-
|
|
|
300
346
|
```
|
|
301
347
|
|
|
302
348
|
On Claude it costs one small paid turn per cell on this computer's own Claude
|
|
303
|
-
login (64 turns
|
|
304
|
-
|
|
349
|
+
login (64 turns before retries: one per cell, and one more for each of the 19
|
|
350
|
+
that ask). On
|
|
351
|
+
Codex it is free; its 5 web-search turns are paid and run only with
|
|
352
|
+
`PERMISSION_MODES_PAID=1`.
|
|
305
353
|
|
|
306
354
|
In each cell, Claude's result comes first, then Codex's. **asks**: a
|
|
307
355
|
`permission.requested` arrives, and the call runs when allowed and does not
|
|
@@ -324,7 +372,12 @@ nothing is asked and the call does not run.
|
|
|
324
372
|
Claude reads with `Read` and runs commands with `Bash`. Codex runs both reads
|
|
325
373
|
and commands as shell commands (`cat`, `echo pm > file`). \*Claude's `WebFetch`
|
|
326
374
|
of a page on loopback switches to https and fails, so for it only whether it
|
|
327
|
-
asks is measured.
|
|
375
|
+
asks is measured. On a Claude login that has Claude's `web-fetch` agent, a
|
|
376
|
+
direct `WebFetch` is refused and names that agent, which makes the call: its
|
|
377
|
+
request reaches the broker as any other, from the sub-agent
|
|
378
|
+
(`parentToolCallId` is the `Agent` call), and the cell reads that request
|
|
379
|
+
(Claude Code 2.1.288 and 2.1.327 alike, 2026-11-19; behind a custom base URL
|
|
380
|
+
neither has the agent, and a direct call runs).
|
|
328
381
|
|
|
329
382
|
What differs, and so what a product should not assume of one agent from the
|
|
330
383
|
other:
|
|
@@ -341,7 +394,10 @@ other:
|
|
|
341
394
|
in every mode. Claude asks for it as for any MCP tool, and refuses it in
|
|
342
395
|
`dont_ask`.
|
|
343
396
|
- **`plan` does not stop writes.** On Claude every write the model makes is
|
|
344
|
-
asked and runs when allowed
|
|
397
|
+
asked and runs when allowed: the engine keeps plan mode off auto mode's
|
|
398
|
+
semantics (`useAutoModeDuringPlan: false`), under which a model that has
|
|
399
|
+
auto mode, Sonnet 5.5 among them, runs a read outside the folder, a shell
|
|
400
|
+
write and an MCP tool unasked. On Codex `apply_patch` is refused, but a shell
|
|
345
401
|
write the model retries with escalation is asked and runs when allowed.
|
|
346
402
|
- **`dont_ask` refuses different calls.** Claude runs only a read in the
|
|
347
403
|
folder and a command that writes nothing. Codex refuses writes and MCP tools
|
|
@@ -361,7 +417,7 @@ a turn with the same `cwd`, `env` and `apiKey` would use:
|
|
|
361
417
|
|
|
362
418
|
| Harness | Source | Notes |
|
|
363
419
|
| --- | --- | --- |
|
|
364
|
-
| `claude-code` | `query().supportedModels()` on an idle CLI (no prompt, MCP servers or hooks), at the operator's `inheritConfig` | The folder's `availableModels` setting narrows the list. `default` is a model id: the account's default. Haiku lists no levels. Operator `sdkOptions` are not applied. |
|
|
420
|
+
| `claude-code` | `query().supportedModels()` on an idle CLI (no prompt, MCP servers or hooks), at the operator's `inheritConfig` | The folder's `availableModels` setting narrows the list. `default` is a model id: the account's default. Haiku 4.5 lists no levels; `haiku` runs Haiku 5.5, which does. Operator `sdkOptions` are not applied. |
|
|
365
421
|
| `codex-app-server` | `model/list`, on the session's own process when `sessionId` has one | Lists what the login can run (a ChatGPT login gets no `gpt-5.5`). The default is the model `~/.codex/config.toml` selects, else Codex's own. With host-managed auth, pass the `sessionId` whose account to list. |
|
|
366
422
|
| `acp` | none | The catalog (empty). ACP agents describe models as session config options. |
|
|
367
423
|
| `scripted` | the harness | One model, `scripted`, with no thinking levels. |
|
|
@@ -492,7 +548,8 @@ account: the engine refuses another account and a renewal that outlives its
|
|
|
492
548
|
turn. The host owns sign-in, durable refresh-token storage, serialized
|
|
493
549
|
renewal and revocation (`@zvada/agent-server/accounts` has them). No
|
|
494
550
|
credentials are added to `RunConfig` or the engine's public wire.
|
|
495
|
-
The protocol
|
|
551
|
+
The protocol is checked at every pin bump against the pinned Codex CLI (the
|
|
552
|
+
version `core/provision/pins.ts` names) and the
|
|
496
553
|
[official app-server authentication documentation](https://learn.chatgpt.com/docs/app-server#3c-log-in-with-externally-managed-chatgpt-tokens-chatgptauthtokens).
|
|
497
554
|
|
|
498
555
|
## What a tool call says, per harness
|
|
@@ -651,7 +708,7 @@ refused when the script is read, never skipped.
|
|
|
651
708
|
| `{ echo: "input" }` | Says the turn's input as a model reads it (`inputToText`). |
|
|
652
709
|
| `{ echo: "config" }` | Says the turn's config as JSON: `model`, `thinkingLevel`, `cwd`, `additionalDirectories`, `systemPromptAppend`, `permissionMode`, the names of its MCP servers and the keys of its `env`, never their values. |
|
|
653
710
|
| `{ wait: ms }` | A pause; a cancel ends it. |
|
|
654
|
-
| `{ hang: true, stopTakes?: ms }` | Runs until the turn is cancelled; `stopTakes` ms more before it stops, as a harness slow to stop. The cancel is confirmed at once. |
|
|
711
|
+
| `{ hang: true, stopTakes?: ms }` | Runs until the turn is cancelled; `stopTakes` ms more before it stops, as a harness slow to stop, also when the cancel came before the hang began, the turn's start included; not in a script an async generator makes, whose next step a cancel does not wait for. The cancel is confirmed at once. |
|
|
655
712
|
| `{ fail: string, category? }` | Ends the turn in an error: of `category` when given, else what the engine's classifier makes of the text. |
|
|
656
713
|
| `{ end: true, stopReason?, usage?, cost? }` | Ends the turn: `end_turn` and zero usage by default. |
|
|
657
714
|
|
|
@@ -742,9 +799,13 @@ once. Unstable methods (`session/list`, `session/fork`, `session/delete`,
|
|
|
742
799
|
for Codex home ownership, supported transports, and live-update behavior.
|
|
743
800
|
- **Codex app-server threads have one writer** (CLI 0.160 and newer). A
|
|
744
801
|
thread still loaded by a live session cannot be resumed from another
|
|
745
|
-
process; the turn fails with `
|
|
746
|
-
writer")
|
|
747
|
-
|
|
802
|
+
process; the turn fails with `resume_busy` ("already has an active
|
|
803
|
+
writer"), and the same resume succeeds once the other process has let the
|
|
804
|
+
thread go. Close the first session (`session/close`) or let its process end
|
|
805
|
+
before resuming elsewhere. A thread that is gone fails `resume_failed` ("no
|
|
806
|
+
rollout found for thread id"): offer a fresh start for that one, not a
|
|
807
|
+
retry. Claude has no such case: its CLI takes no writer lock, so a
|
|
808
|
+
conversation is resumed or `resume_failed`.
|
|
748
809
|
- The **BYOK proxy** (`/core/proxy`) is a building block, not yet auto-wired
|
|
749
810
|
into the harnesses (they use ambient/explicit keys today).
|
|
750
811
|
- **Hook bridge** (PreToolUse/Stop decisions) is exposed for the claude
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zvada/agent-server",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.26",
|
|
4
4
|
"description": "Harness-agnostic agent execution engine: run Claude Code, Codex (app-server), and any ACP agent behind one interface with a normalized event stream, multi-turn sessions, and resume. Root export is the wire contract; /core, /server, /client are the seats.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"bin": {
|
|
42
|
-
"agent-server": "
|
|
42
|
+
"agent-server": "src/server/bin.ts"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"prepack": "rm -rf dist && tsc -p tsconfig.build.json"
|
|
@@ -162,9 +162,9 @@
|
|
|
162
162
|
},
|
|
163
163
|
"devDependencies": {
|
|
164
164
|
"@agentclientprotocol/sdk": "^1.7.0",
|
|
165
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
165
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.327",
|
|
166
166
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
167
|
-
"@openai/codex": "0.
|
|
167
|
+
"@openai/codex": "0.169.1",
|
|
168
168
|
"@types/bun": "^1.2.0",
|
|
169
169
|
"zod": "^4.6.7"
|
|
170
170
|
}
|
package/src/client/client.ts
CHANGED
|
@@ -121,6 +121,51 @@ function stopOn(handle: Handle, signal: AbortSignal | undefined): void {
|
|
|
121
121
|
void handle.result.then(off, off);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
/** A `turn/start` this client has not sent yet: `gone` settles at its first send or its end. */
|
|
125
|
+
interface Start {
|
|
126
|
+
sessionId: string;
|
|
127
|
+
turnId: string;
|
|
128
|
+
gone: Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// @ref LLP 0001#d9--the-wire-is-quick-ack-json-rpc-requests-flow-one-way — a cancel sent right behind its start reaches the turn
|
|
132
|
+
/**
|
|
133
|
+
* The `turn/start`s this client has not sent yet, each from before its
|
|
134
|
+
* first `await` until its first send or its end. The server takes a
|
|
135
|
+
* connection's requests in order and admits a turn in its start's handler,
|
|
136
|
+
* so a cancel for one of their turns goes out after that first send. Once
|
|
137
|
+
* sent, a start delays no cancel: after a redial a cancel can overtake its
|
|
138
|
+
* re-send, and is answered `no_active_turn`. Before its first send a start
|
|
139
|
+
* waits only on the handshake, a request the client's close fails, so no
|
|
140
|
+
* cancel waits past the close.
|
|
141
|
+
*/
|
|
142
|
+
class Starts {
|
|
143
|
+
private readonly unsent = new Set<Start>();
|
|
144
|
+
|
|
145
|
+
/** Record a start; the function returned lets it go (its first send, or its end), and may be called again. */
|
|
146
|
+
begin(sessionId: string, turnId: string): () => void {
|
|
147
|
+
let settle = () => {};
|
|
148
|
+
const gone = new Promise<void>((resolve) => {
|
|
149
|
+
settle = resolve;
|
|
150
|
+
});
|
|
151
|
+
const start: Start = { sessionId, turnId, gone };
|
|
152
|
+
this.unsent.add(start);
|
|
153
|
+
return () => {
|
|
154
|
+
this.unsent.delete(start);
|
|
155
|
+
settle();
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** `send`, once no start of `turnId` (without one, of the session) is unsent; in the call when none is. */
|
|
160
|
+
after<T>(sessionId: string, turnId: string | undefined, send: () => Promise<T>): Promise<T> {
|
|
161
|
+
const waiting = [...this.unsent].filter(
|
|
162
|
+
(start) => start.sessionId === sessionId && (turnId === undefined || start.turnId === turnId),
|
|
163
|
+
);
|
|
164
|
+
if (waiting.length === 0) return send();
|
|
165
|
+
return Promise.all(waiting.map((start) => start.gone)).then(send);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
124
169
|
/** How often `prepareClis` asks again while an install runs, besides when one ends. */
|
|
125
170
|
const PREPARE_POLL_MS = 2_000;
|
|
126
171
|
|
|
@@ -136,6 +181,7 @@ const PREPARE_POLL_MS = 2_000;
|
|
|
136
181
|
export class AgentServerClient {
|
|
137
182
|
private readonly connection: Connection;
|
|
138
183
|
private readonly turns = new Turns();
|
|
184
|
+
private readonly starts = new Starts();
|
|
139
185
|
private readonly progress = new Listeners<HarnessCliProgress>();
|
|
140
186
|
private readonly authUpdates = new Listeners<AuthUpdated>();
|
|
141
187
|
private readonly streams: Streams;
|
|
@@ -270,41 +316,50 @@ export class AgentServerClient {
|
|
|
270
316
|
* it), and `onEvent` hears it to its end.
|
|
271
317
|
*/
|
|
272
318
|
async runTurn(params: TurnStartParams, options: FollowOptions = {}): Promise<TurnHandle> {
|
|
273
|
-
await this.initialize();
|
|
274
319
|
const sessionId = params.sessionId ?? generateUUIDv7();
|
|
275
320
|
const turnId = params.turnId ?? generateUUIDv7();
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const handle = this.turns.open(sessionId, turnId, true);
|
|
279
|
-
stopOn(handle, options.signal);
|
|
321
|
+
// Before the first `await`: a cancel sent right behind this call goes out after the start.
|
|
322
|
+
const release = this.starts.begin(sessionId, turnId);
|
|
280
323
|
try {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
else
|
|
296
|
-
await this.catchUp(
|
|
297
|
-
handle,
|
|
298
|
-
accepted.deduplicated
|
|
299
|
-
? (accepted.startedSeq ?? accepted.headSeq + 1)
|
|
300
|
-
: accepted.headSeq + 1,
|
|
301
|
-
accepted.headSeq,
|
|
324
|
+
await this.initialize();
|
|
325
|
+
if (this.turns.running(sessionId))
|
|
326
|
+
throw new Error(`session ${sessionId} already has an active turn`);
|
|
327
|
+
const handle = this.turns.open(sessionId, turnId, true);
|
|
328
|
+
try {
|
|
329
|
+
stopOn(handle, options.signal);
|
|
330
|
+
// `resend` sends (or fails for no connection) before its first `await`, in this call.
|
|
331
|
+
const sending = this.connection.resend(
|
|
332
|
+
WIRE_METHODS.turnStart,
|
|
333
|
+
{ ...params, sessionId, turnId, subscribe: true },
|
|
334
|
+
// A turn that already ended streams nothing: its end is in the ack.
|
|
335
|
+
(ack) => {
|
|
336
|
+
if (!ack.terminal) this.joinAt(handle, ack.headSeq, { turnId });
|
|
337
|
+
},
|
|
302
338
|
);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
339
|
+
release();
|
|
340
|
+
const accepted = await sending;
|
|
341
|
+
const { terminal } = accepted;
|
|
342
|
+
if (terminal && (terminal.sessionId !== sessionId || terminal.turnId !== turnId))
|
|
343
|
+
throw new Error("Turn receipt belongs to a different request");
|
|
344
|
+
// A retried start of a turn that already ended: its end, without its events
|
|
345
|
+
// (`replay` or `history` serve its transcript).
|
|
346
|
+
if (terminal) handle.push(terminal);
|
|
347
|
+
else
|
|
348
|
+
await this.catchUp(
|
|
349
|
+
handle,
|
|
350
|
+
accepted.deduplicated
|
|
351
|
+
? (accepted.startedSeq ?? accepted.headSeq + 1)
|
|
352
|
+
: accepted.headSeq + 1,
|
|
353
|
+
accepted.headSeq,
|
|
354
|
+
);
|
|
355
|
+
} catch (error) {
|
|
356
|
+
handle.fail(error);
|
|
357
|
+
throw error;
|
|
358
|
+
}
|
|
359
|
+
return this.handleOf(handle);
|
|
360
|
+
} finally {
|
|
361
|
+
release();
|
|
306
362
|
}
|
|
307
|
-
return this.handleOf(handle);
|
|
308
363
|
}
|
|
309
364
|
|
|
310
365
|
/**
|
|
@@ -313,17 +368,26 @@ export class AgentServerClient {
|
|
|
313
368
|
* before.
|
|
314
369
|
*/
|
|
315
370
|
async startTurn(params: TurnStartParams): Promise<TurnStartResult> {
|
|
316
|
-
await this.initialize();
|
|
317
371
|
const sessionId = params.sessionId ?? generateUUIDv7();
|
|
318
372
|
const turnId = params.turnId ?? generateUUIDv7();
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
(
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
373
|
+
// As in `runTurn`: a cancel sent right behind this call goes out after the start.
|
|
374
|
+
const release = this.starts.begin(sessionId, turnId);
|
|
375
|
+
try {
|
|
376
|
+
await this.initialize();
|
|
377
|
+
// `request` sends (or fails for no connection) in this call.
|
|
378
|
+
const answer = this.connection.request(
|
|
379
|
+
WIRE_METHODS.turnStart,
|
|
380
|
+
{ ...params, sessionId, turnId },
|
|
381
|
+
(ack) => {
|
|
382
|
+
if (params.subscribe !== false && !ack.terminal)
|
|
383
|
+
this.streams.joined(sessionId, ack.headSeq, { turnId });
|
|
384
|
+
},
|
|
385
|
+
);
|
|
386
|
+
release();
|
|
387
|
+
return await answer;
|
|
388
|
+
} finally {
|
|
389
|
+
release();
|
|
390
|
+
}
|
|
327
391
|
}
|
|
328
392
|
|
|
329
393
|
/**
|
|
@@ -388,13 +452,19 @@ export class AgentServerClient {
|
|
|
388
452
|
* finished turn then returns `{outcome: "no_active_turn", activeTurnId}`
|
|
389
453
|
* instead of killing the turn that replaced it. `{outcome: "unconfirmed"}`
|
|
390
454
|
* means the harness did not acknowledge the interrupt — the agent may still
|
|
391
|
-
* be running; `turn.ended` remains the source of truth.
|
|
455
|
+
* be running; `turn.ended` remains the source of truth. A cancel for a
|
|
456
|
+
* turn this client is starting (`runTurn`, `startTurn`) goes out after
|
|
457
|
+
* that start's first send, so one sent right behind the start reaches the
|
|
458
|
+
* turn. After a reconnect a cancel can reach the server before a re-sent
|
|
459
|
+
* start, and is then answered `no_active_turn`.
|
|
392
460
|
*/
|
|
393
461
|
cancelTurn(sessionId: string, turnId?: string): Promise<TurnCancelResult> {
|
|
394
|
-
return this.
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
462
|
+
return this.starts.after(sessionId, turnId, () =>
|
|
463
|
+
this.connection.request(WIRE_METHODS.turnCancel, {
|
|
464
|
+
sessionId,
|
|
465
|
+
...(turnId !== undefined ? { turnId } : {}),
|
|
466
|
+
}),
|
|
467
|
+
);
|
|
398
468
|
}
|
|
399
469
|
|
|
400
470
|
/** Answer a `permission.requested` event. */
|