@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.
Files changed (190) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/README.md +3 -0
  3. package/dist/client/client.js +93 -34
  4. package/dist/core/agents/acp/acp-agent.js +91 -14
  5. package/dist/core/agents/acp/mappings.js +5 -1
  6. package/dist/core/agents/claude-code/approvals.js +2 -1
  7. package/dist/core/agents/claude-code/claude-agent.js +12 -2
  8. package/dist/core/agents/claude-code/mcp.js +9 -1
  9. package/dist/core/agents/claude-code/models.js +16 -10
  10. package/dist/core/agents/claude-code/options.js +23 -2
  11. package/dist/core/agents/claude-code/session.js +21 -1
  12. package/dist/core/agents/claude-code/tools.js +9 -4
  13. package/dist/core/agents/claude-code/turn.js +2 -0
  14. package/dist/core/agents/codex-app-server/adapter.js +2 -0
  15. package/dist/core/agents/codex-app-server/client.js +8 -5
  16. package/dist/core/agents/codex-app-server/codex-agent.js +35 -2
  17. package/dist/core/agents/codex-app-server/effort.js +13 -6
  18. package/dist/core/agents/codex-app-server/mcp.js +35 -18
  19. package/dist/core/agents/codex-app-server/models.js +10 -10
  20. package/dist/core/agents/codex-app-server/options.js +11 -2
  21. package/dist/core/agents/codex-app-server/session.js +11 -4
  22. package/dist/core/agents/codex-app-server/thread-settings.js +30 -11
  23. package/dist/core/agents/host-tools.js +493 -0
  24. package/dist/core/agents/mcp-config.js +6 -2
  25. package/dist/core/agents/scripted/scripted-agent.js +11 -4
  26. package/dist/core/agents/scripted/steps.js +5 -1
  27. package/dist/core/agents/session-agent.js +70 -2
  28. package/dist/core/agents/thinking-levels.js +8 -5
  29. package/dist/core/index.js +1 -0
  30. package/dist/core/presets.js +12 -2
  31. package/dist/core/processes/identity.js +1 -0
  32. package/dist/core/processes/lifeline.js +13 -1
  33. package/dist/core/processes/process-table.js +1 -0
  34. package/dist/core/provision/extract.js +1 -0
  35. package/dist/core/provision/pins.js +7 -16
  36. package/dist/core/provision/releases.js +25 -25
  37. package/dist/core/proxy/loopback.js +22 -4
  38. package/dist/core/runtime/agent-runtime.js +6 -3
  39. package/dist/core/runtime/turn.js +20 -10
  40. package/dist/protocol/config.js +21 -1
  41. package/dist/protocol/credentials.js +2 -1
  42. package/dist/protocol/errors.js +12 -3
  43. package/dist/protocol/model-catalog.js +58 -18
  44. package/dist/protocol/models.js +6 -27
  45. package/dist/protocol/thinking.js +22 -9
  46. package/dist/protocol/wire-api.js +2 -2
  47. package/dist/server/bin.js +6 -4
  48. package/dist/server/routes.js +3 -2
  49. package/dist/types/client/client.d.ts +6 -1
  50. package/dist/types/client/client.d.ts.map +1 -1
  51. package/dist/types/core/agents/acp/acp-agent.d.ts +15 -0
  52. package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
  53. package/dist/types/core/agents/acp/mappings.d.ts +5 -1
  54. package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
  55. package/dist/types/core/agents/acp/requests.d.ts +2 -0
  56. package/dist/types/core/agents/acp/requests.d.ts.map +1 -1
  57. package/dist/types/core/agents/claude-code/approvals.d.ts +2 -1
  58. package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -1
  59. package/dist/types/core/agents/claude-code/claude-agent.d.ts +1 -0
  60. package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -1
  61. package/dist/types/core/agents/claude-code/mcp.d.ts +8 -1
  62. package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -1
  63. package/dist/types/core/agents/claude-code/models.d.ts +9 -5
  64. package/dist/types/core/agents/claude-code/models.d.ts.map +1 -1
  65. package/dist/types/core/agents/claude-code/options.d.ts +14 -1
  66. package/dist/types/core/agents/claude-code/options.d.ts.map +1 -1
  67. package/dist/types/core/agents/claude-code/session.d.ts +2 -0
  68. package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
  69. package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -1
  70. package/dist/types/core/agents/claude-code/turn.d.ts +3 -0
  71. package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -1
  72. package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -1
  73. package/dist/types/core/agents/codex-app-server/client.d.ts +2 -0
  74. package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
  75. package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +11 -0
  76. package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -1
  77. package/dist/types/core/agents/codex-app-server/effort.d.ts +7 -7
  78. package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -1
  79. package/dist/types/core/agents/codex-app-server/mcp.d.ts +11 -3
  80. package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -1
  81. package/dist/types/core/agents/codex-app-server/models.d.ts +4 -1
  82. package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -1
  83. package/dist/types/core/agents/codex-app-server/options.d.ts +9 -2
  84. package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -1
  85. package/dist/types/core/agents/codex-app-server/requests.d.ts +2 -0
  86. package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -1
  87. package/dist/types/core/agents/codex-app-server/session.d.ts +6 -3
  88. package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -1
  89. package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -1
  90. package/dist/types/core/agents/host-tools.d.ts +162 -0
  91. package/dist/types/core/agents/host-tools.d.ts.map +1 -0
  92. package/dist/types/core/agents/mcp-config.d.ts +11 -2
  93. package/dist/types/core/agents/mcp-config.d.ts.map +1 -1
  94. package/dist/types/core/agents/scripted/scripted-agent.d.ts.map +1 -1
  95. package/dist/types/core/agents/scripted/steps.d.ts +1 -1
  96. package/dist/types/core/agents/scripted/steps.d.ts.map +1 -1
  97. package/dist/types/core/agents/session-agent.d.ts +2 -7
  98. package/dist/types/core/agents/session-agent.d.ts.map +1 -1
  99. package/dist/types/core/agents/thinking-levels.d.ts +7 -3
  100. package/dist/types/core/agents/thinking-levels.d.ts.map +1 -1
  101. package/dist/types/core/index.d.ts +1 -0
  102. package/dist/types/core/index.d.ts.map +1 -1
  103. package/dist/types/core/presets.d.ts +11 -1
  104. package/dist/types/core/presets.d.ts.map +1 -1
  105. package/dist/types/core/processes/identity.d.ts.map +1 -1
  106. package/dist/types/core/processes/lifeline.d.ts.map +1 -1
  107. package/dist/types/core/processes/process-table.d.ts.map +1 -1
  108. package/dist/types/core/provision/extract.d.ts.map +1 -1
  109. package/dist/types/core/provision/pins.d.ts +5 -4
  110. package/dist/types/core/provision/pins.d.ts.map +1 -1
  111. package/dist/types/core/proxy/loopback.d.ts.map +1 -1
  112. package/dist/types/core/runtime/agent-runtime.d.ts +4 -1
  113. package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
  114. package/dist/types/core/runtime/turn.d.ts +12 -7
  115. package/dist/types/core/runtime/turn.d.ts.map +1 -1
  116. package/dist/types/protocol/clis.d.ts +3 -3
  117. package/dist/types/protocol/config.d.ts +12 -19
  118. package/dist/types/protocol/config.d.ts.map +1 -1
  119. package/dist/types/protocol/conversation.d.ts +10 -42
  120. package/dist/types/protocol/conversation.d.ts.map +1 -1
  121. package/dist/types/protocol/credentials.d.ts +13 -1
  122. package/dist/types/protocol/credentials.d.ts.map +1 -1
  123. package/dist/types/protocol/errors.d.ts +6 -4
  124. package/dist/types/protocol/errors.d.ts.map +1 -1
  125. package/dist/types/protocol/execution.d.ts +2 -18
  126. package/dist/types/protocol/execution.d.ts.map +1 -1
  127. package/dist/types/protocol/lifecycle.d.ts +12 -76
  128. package/dist/types/protocol/lifecycle.d.ts.map +1 -1
  129. package/dist/types/protocol/model-catalog.d.ts.map +1 -1
  130. package/dist/types/protocol/models.d.ts +4 -42
  131. package/dist/types/protocol/models.d.ts.map +1 -1
  132. package/dist/types/protocol/thinking.d.ts +19 -19
  133. package/dist/types/protocol/thinking.d.ts.map +1 -1
  134. package/dist/types/protocol/wire-api.d.ts +32 -117
  135. package/dist/types/protocol/wire-api.d.ts.map +1 -1
  136. package/dist/types/protocol/wire.d.ts +24 -125
  137. package/dist/types/protocol/wire.d.ts.map +1 -1
  138. package/dist/types/server/routes.d.ts.map +1 -1
  139. package/docs/consuming.md +92 -12
  140. package/docs/deploy.md +8 -0
  141. package/docs/harnesses.md +88 -27
  142. package/package.json +4 -4
  143. package/src/client/client.ts +114 -44
  144. package/src/core/agents/acp/acp-agent.ts +123 -17
  145. package/src/core/agents/acp/mappings.ts +5 -1
  146. package/src/core/agents/acp/requests.ts +2 -0
  147. package/src/core/agents/claude-code/approvals.ts +2 -1
  148. package/src/core/agents/claude-code/claude-agent.ts +14 -2
  149. package/src/core/agents/claude-code/mcp.ts +11 -1
  150. package/src/core/agents/claude-code/models.ts +15 -10
  151. package/src/core/agents/claude-code/options.ts +37 -3
  152. package/src/core/agents/claude-code/session.ts +26 -1
  153. package/src/core/agents/claude-code/tools.ts +10 -4
  154. package/src/core/agents/claude-code/turn.ts +4 -0
  155. package/src/core/agents/codex-app-server/adapter.ts +2 -0
  156. package/src/core/agents/codex-app-server/client.ts +11 -5
  157. package/src/core/agents/codex-app-server/codex-agent.ts +45 -1
  158. package/src/core/agents/codex-app-server/effort.ts +15 -20
  159. package/src/core/agents/codex-app-server/mcp.ts +46 -23
  160. package/src/core/agents/codex-app-server/models.ts +10 -10
  161. package/src/core/agents/codex-app-server/options.ts +16 -2
  162. package/src/core/agents/codex-app-server/requests.ts +2 -0
  163. package/src/core/agents/codex-app-server/session.ts +19 -4
  164. package/src/core/agents/codex-app-server/thread-settings.ts +31 -11
  165. package/src/core/agents/host-tools.ts +649 -0
  166. package/src/core/agents/mcp-config.ts +15 -3
  167. package/src/core/agents/scripted/scripted-agent.ts +11 -3
  168. package/src/core/agents/scripted/steps.ts +5 -1
  169. package/src/core/agents/session-agent.ts +78 -2
  170. package/src/core/agents/thinking-levels.ts +9 -6
  171. package/src/core/index.ts +9 -0
  172. package/src/core/presets.ts +24 -3
  173. package/src/core/processes/identity.ts +1 -0
  174. package/src/core/processes/lifeline.ts +14 -1
  175. package/src/core/processes/process-table.ts +1 -0
  176. package/src/core/provision/extract.ts +1 -0
  177. package/src/core/provision/pins.ts +7 -16
  178. package/src/core/provision/releases.ts +25 -25
  179. package/src/core/proxy/loopback.ts +25 -4
  180. package/src/core/runtime/agent-runtime.ts +6 -3
  181. package/src/core/runtime/turn.ts +21 -9
  182. package/src/protocol/config.ts +22 -1
  183. package/src/protocol/credentials.ts +19 -5
  184. package/src/protocol/errors.ts +12 -3
  185. package/src/protocol/model-catalog.ts +58 -18
  186. package/src/protocol/models.ts +6 -26
  187. package/src/protocol/thinking.ts +27 -14
  188. package/src/protocol/wire-api.ts +2 -2
  189. package/src/server/bin.ts +6 -4
  190. 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, its plugins off from the moment
194
- its process starts (`-c features.plugins=false`: a fresh home otherwise clones
195
- Codex's plugin catalogue, about 85 MB and 5,500 files, before any thread
196
- opens), and at `none` without the repository's `AGENTS.md`. A session whose
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` runs from `off` to `ultra`. agent-server fits it to the
204
- model's levels when it knows them: a level above the model's top becomes that
205
- top (`ultra` on a model whose top is `max` runs `max`), and on Codex `off`
206
- becomes the model's lowest (current models reject `minimal`). The levels come
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 then still
220
- thinks), and no applied level is reported. `off` is sent as is, on Haiku
221
- too, where it stops that default thinking: some models do not let thinking
222
- be disabled. An operator `sdkOptions` that sets `effort` or `thinking` wins,
223
- and then no level is reported.
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. With no level
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 2026-11-15 on macOS, on Claude Code 2.1.288 (SDK 0.3.288, model
287
- Haiku) and Codex 0.160.0, through the engine at `inheritConfig: "none"`. Each
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). On Codex it is free; its 5 web-search turns are paid and run
304
- only with `PERMISSION_MODES_PAID=1`.
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. On Codex `apply_patch` is refused, but a shell
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 was checked against Codex CLI 0.160.0 and the
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 `resume_failed` ("already has an active
746
- writer"). Close the first session (`session/close`) or let its process end
747
- before resuming elsewhere.
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.24",
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": "./src/server/bin.ts"
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.288",
165
+ "@anthropic-ai/claude-agent-sdk": "0.3.327",
166
166
  "@modelcontextprotocol/sdk": "1.32.1",
167
- "@openai/codex": "0.160.0",
167
+ "@openai/codex": "0.169.1",
168
168
  "@types/bun": "^1.2.0",
169
169
  "zod": "^4.6.7"
170
170
  }
@@ -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
- if (this.turns.running(sessionId))
277
- throw new Error(`session ${sessionId} already has an active turn`);
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
- const accepted = await this.connection.resend(
282
- WIRE_METHODS.turnStart,
283
- { ...params, sessionId, turnId, subscribe: true },
284
- // A turn that already ended streams nothing: its end is in the ack.
285
- (ack) => {
286
- if (!ack.terminal) this.joinAt(handle, ack.headSeq, { turnId });
287
- },
288
- );
289
- const { terminal } = accepted;
290
- if (terminal && (terminal.sessionId !== sessionId || terminal.turnId !== turnId))
291
- throw new Error("Turn receipt belongs to a different request");
292
- // A retried start of a turn that already ended: its end, without its events
293
- // (`replay` or `history` serve its transcript).
294
- if (terminal) handle.push(terminal);
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
- } catch (error) {
304
- handle.fail(error);
305
- throw error;
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
- return this.connection.request(
320
- WIRE_METHODS.turnStart,
321
- { ...params, sessionId, turnId },
322
- (ack) => {
323
- if (params.subscribe !== false && !ack.terminal)
324
- this.streams.joined(sessionId, ack.headSeq, { turnId });
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.connection.request(WIRE_METHODS.turnCancel, {
395
- sessionId,
396
- ...(turnId !== undefined ? { turnId } : {}),
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. */