@zvada/agent-server 0.3.22 → 0.3.24

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 (558) hide show
  1. package/CHANGELOG.md +295 -0
  2. package/README.md +14 -5
  3. package/dist/accounts/chatgpt.js +144 -0
  4. package/dist/accounts/check.js +71 -0
  5. package/dist/accounts/claude.js +80 -0
  6. package/dist/accounts/endpoint.js +104 -0
  7. package/dist/accounts/http.js +58 -0
  8. package/dist/accounts/index.js +9 -0
  9. package/dist/client/client.js +686 -0
  10. package/dist/client/connection.js +338 -0
  11. package/dist/client/history.js +49 -0
  12. package/dist/client/index.js +6 -0
  13. package/dist/client/listeners.js +19 -0
  14. package/dist/client/logins.js +92 -0
  15. package/dist/client/rpc.js +105 -0
  16. package/dist/client/streams.js +432 -0
  17. package/dist/client/transports.js +118 -0
  18. package/dist/client/turns.js +122 -0
  19. package/dist/core/agents/acp/acp-agent.js +425 -0
  20. package/dist/core/agents/acp/adapter.js +231 -0
  21. package/dist/core/agents/acp/client.js +222 -0
  22. package/dist/core/agents/acp/known-agents.js +57 -0
  23. package/dist/core/agents/acp/mappings.js +164 -0
  24. package/dist/core/agents/acp/requests.js +79 -0
  25. package/dist/core/agents/attachments.js +14 -0
  26. package/dist/core/agents/base.js +64 -0
  27. package/dist/core/agents/claude-code/adapter.js +474 -0
  28. package/dist/core/agents/claude-code/approvals.js +245 -0
  29. package/dist/core/agents/claude-code/claude-agent.js +319 -0
  30. package/dist/core/agents/claude-code/credentials.js +142 -0
  31. package/dist/core/agents/claude-code/events.js +11 -0
  32. package/dist/core/agents/claude-code/login.js +217 -0
  33. package/dist/core/agents/claude-code/mcp.js +181 -0
  34. package/dist/core/agents/claude-code/models.js +74 -0
  35. package/dist/core/agents/claude-code/options.js +240 -0
  36. package/dist/core/agents/claude-code/outcome.js +204 -0
  37. package/dist/core/agents/claude-code/results.js +58 -0
  38. package/dist/core/agents/claude-code/sdk-pair.js +59 -0
  39. package/dist/core/agents/claude-code/session.js +593 -0
  40. package/dist/core/agents/claude-code/spawn.js +125 -0
  41. package/dist/core/agents/claude-code/spend.js +118 -0
  42. package/dist/core/agents/claude-code/tools.js +131 -0
  43. package/dist/core/agents/claude-code/turn-usage.js +121 -0
  44. package/dist/core/agents/claude-code/turn.js +199 -0
  45. package/dist/core/agents/codex-app-server/adapter.js +463 -0
  46. package/dist/core/agents/codex-app-server/client.js +338 -0
  47. package/dist/core/agents/codex-app-server/codex-agent.js +294 -0
  48. package/dist/core/agents/codex-app-server/commands.js +184 -0
  49. package/dist/core/agents/codex-app-server/credentials.js +92 -0
  50. package/dist/core/agents/codex-app-server/effort.js +13 -0
  51. package/dist/core/agents/codex-app-server/events.js +18 -0
  52. package/dist/core/agents/codex-app-server/homes.js +118 -0
  53. package/dist/core/agents/codex-app-server/input.js +52 -0
  54. package/dist/core/agents/codex-app-server/items.js +307 -0
  55. package/dist/core/agents/codex-app-server/login.js +183 -0
  56. package/dist/core/agents/codex-app-server/mcp.js +323 -0
  57. package/dist/core/agents/codex-app-server/models.js +160 -0
  58. package/dist/core/agents/codex-app-server/options.js +155 -0
  59. package/dist/core/agents/codex-app-server/plan-approval.js +124 -0
  60. package/dist/core/agents/codex-app-server/protocol.js +38 -0
  61. package/dist/core/agents/codex-app-server/requests.js +250 -0
  62. package/dist/core/agents/codex-app-server/session.js +278 -0
  63. package/dist/core/agents/codex-app-server/subagents.js +260 -0
  64. package/dist/core/agents/codex-app-server/thread-settings.js +214 -0
  65. package/dist/core/agents/codex-app-server/turn-items.js +69 -0
  66. package/dist/core/agents/codex-app-server/turn.js +448 -0
  67. package/dist/core/agents/codex-app-server/user-login.js +78 -0
  68. package/dist/core/agents/config-fingerprint.js +10 -0
  69. package/dist/core/agents/credentials.js +71 -0
  70. package/dist/core/agents/diffs.js +27 -0
  71. package/dist/core/agents/elicitation.js +42 -0
  72. package/dist/core/agents/inherit-config.js +5 -0
  73. package/dist/core/agents/login.js +56 -0
  74. package/dist/core/agents/mcp-config.js +109 -0
  75. package/dist/core/agents/plan.js +6 -0
  76. package/dist/core/agents/process-pool.js +307 -0
  77. package/dist/core/agents/registry.js +49 -0
  78. package/dist/core/agents/scripted/adapter.js +86 -0
  79. package/dist/core/agents/scripted/mcp-call.js +74 -0
  80. package/dist/core/agents/scripted/scripted-agent.js +330 -0
  81. package/dist/core/agents/scripted/scripts.js +154 -0
  82. package/dist/core/agents/scripted/steps.js +87 -0
  83. package/dist/core/agents/session-agent.js +209 -0
  84. package/dist/core/agents/stderr-tail.js +71 -0
  85. package/dist/core/agents/thinking-levels.js +9 -0
  86. package/dist/core/agents/types.js +1 -0
  87. package/dist/core/diagnostics.js +23 -0
  88. package/dist/core/index.js +31 -0
  89. package/dist/core/presets.js +114 -0
  90. package/dist/core/processes/identity.js +91 -0
  91. package/dist/core/processes/lifeline.js +210 -0
  92. package/dist/core/processes/native-processes.js +299 -0
  93. package/dist/core/processes/process-table.js +163 -0
  94. package/dist/core/provision/cache-trust.js +121 -0
  95. package/dist/core/provision/cache-usage.js +61 -0
  96. package/dist/core/provision/checksums.js +22 -0
  97. package/dist/core/provision/extract.js +28 -0
  98. package/dist/core/provision/index.js +4 -0
  99. package/dist/core/provision/install-build.js +99 -0
  100. package/dist/core/provision/npm.js +316 -0
  101. package/dist/core/provision/pins.js +35 -0
  102. package/dist/core/provision/platform.js +65 -0
  103. package/dist/core/provision/provisioner.js +372 -0
  104. package/dist/core/provision/releases.js +68 -0
  105. package/dist/core/provision/tools.js +279 -0
  106. package/dist/core/proxy/anthropic-proxy.js +163 -0
  107. package/dist/core/proxy/api-key-store.js +30 -0
  108. package/dist/core/proxy/index.js +3 -0
  109. package/dist/core/proxy/loopback.js +86 -0
  110. package/dist/core/runtime/agent-runtime.js +434 -0
  111. package/dist/core/runtime/event-processor.js +379 -0
  112. package/dist/core/runtime/event-sink.js +65 -0
  113. package/dist/core/runtime/harness-clis.js +83 -0
  114. package/dist/core/runtime/harness-logins.js +313 -0
  115. package/dist/core/runtime/login-reads.js +71 -0
  116. package/dist/core/runtime/model-lists.js +160 -0
  117. package/dist/core/runtime/permission-policy.js +84 -0
  118. package/dist/core/runtime/request-broker.js +139 -0
  119. package/dist/core/runtime/steering.js +79 -0
  120. package/dist/core/runtime/turn-outcome.js +16 -0
  121. package/dist/core/runtime/turn.js +329 -0
  122. package/dist/core/utils/bounded.js +13 -0
  123. package/dist/core/utils/deadline.js +57 -0
  124. package/dist/core/utils/errors.js +176 -0
  125. package/dist/core/utils/is-record.js +4 -0
  126. package/dist/core/utils/loopback.js +11 -0
  127. package/dist/index.js +4 -0
  128. package/dist/operator/index.js +10 -0
  129. package/dist/operator/mcp.js +139 -0
  130. package/dist/operator/operator.js +499 -0
  131. package/dist/operator/render.js +408 -0
  132. package/dist/operator/view.js +35 -0
  133. package/dist/protocol/account.js +96 -0
  134. package/dist/protocol/async-queue.js +65 -0
  135. package/dist/protocol/auth.js +169 -0
  136. package/dist/protocol/canonical.js +18 -0
  137. package/dist/protocol/clis.js +63 -0
  138. package/dist/protocol/config.js +137 -0
  139. package/dist/protocol/conversation.js +231 -0
  140. package/dist/protocol/credentials.js +141 -0
  141. package/dist/protocol/errors.js +181 -0
  142. package/dist/protocol/execution.js +28 -0
  143. package/dist/protocol/factories.js +231 -0
  144. package/dist/protocol/guards.js +71 -0
  145. package/dist/protocol/harness.js +93 -0
  146. package/dist/protocol/history.js +201 -0
  147. package/dist/protocol/ids.js +37 -0
  148. package/dist/protocol/index.js +36 -0
  149. package/dist/protocol/lifecycle.js +562 -0
  150. package/dist/protocol/meta-keys.js +17 -0
  151. package/dist/protocol/meta.js +13 -0
  152. package/dist/protocol/model-catalog.js +223 -0
  153. package/dist/protocol/models.js +84 -0
  154. package/dist/protocol/part-input.js +94 -0
  155. package/dist/protocol/parts.js +166 -0
  156. package/dist/protocol/plan.js +31 -0
  157. package/dist/protocol/reduce.js +484 -0
  158. package/dist/protocol/selectors.js +136 -0
  159. package/dist/protocol/seq-cursor.js +37 -0
  160. package/dist/protocol/stop-reasons.js +41 -0
  161. package/dist/protocol/thinking.js +31 -0
  162. package/dist/protocol/time.js +21 -0
  163. package/dist/protocol/tokens.js +57 -0
  164. package/dist/protocol/tool-closure.js +70 -0
  165. package/dist/protocol/tool-state.js +153 -0
  166. package/dist/protocol/verify.js +467 -0
  167. package/dist/protocol/vocabulary.js +27 -0
  168. package/dist/protocol/wire-api.js +94 -0
  169. package/dist/protocol/wire.js +669 -0
  170. package/dist/server/acp/binding.js +251 -0
  171. package/dist/server/acp/session-records.js +53 -0
  172. package/dist/server/acp/translate.js +401 -0
  173. package/dist/server/agent-server.js +338 -0
  174. package/dist/server/bin.js +492 -0
  175. package/dist/server/feedback.js +216 -0
  176. package/dist/server/history.js +123 -0
  177. package/dist/server/index.js +8 -0
  178. package/dist/server/install.js +171 -0
  179. package/dist/server/open-parts.js +87 -0
  180. package/dist/server/routes.js +291 -0
  181. package/dist/server/secrets.js +19 -0
  182. package/dist/server/session-gate.js +54 -0
  183. package/dist/server/session-log.js +66 -0
  184. package/dist/server/session-store.js +243 -0
  185. package/dist/server/subscriptions.js +189 -0
  186. package/dist/server/transports.js +214 -0
  187. package/dist/server/wire-error.js +26 -0
  188. package/dist/sync/event-log.js +89 -0
  189. package/dist/sync/fit.js +202 -0
  190. package/dist/sync/history-reader.js +33 -0
  191. package/dist/sync/history-sqlite.js +281 -0
  192. package/dist/sync/history.js +163 -0
  193. package/dist/sync/index.js +5 -0
  194. package/dist/sync/journal-sqlite.js +316 -0
  195. package/dist/sync/journal.js +10 -0
  196. package/dist/sync/live-tails.js +85 -0
  197. package/dist/sync/node-sqlite.js +27 -0
  198. package/dist/sync/projection.js +32 -0
  199. package/dist/sync/recovery.js +117 -0
  200. package/dist/sync/retry.js +45 -0
  201. package/dist/sync/schema.js +73 -0
  202. package/dist/sync/sql.js +94 -0
  203. package/dist/sync/sqlite-file.js +31 -0
  204. package/dist/sync/sqlite.js +18 -0
  205. package/dist/sync/worker.js +212 -0
  206. package/dist/types/accounts/chatgpt.d.ts +1 -1
  207. package/dist/types/accounts/chatgpt.d.ts.map +1 -1
  208. package/dist/types/accounts/http.d.ts +2 -4
  209. package/dist/types/accounts/http.d.ts.map +1 -1
  210. package/dist/types/client/client.d.ts +37 -11
  211. package/dist/types/client/client.d.ts.map +1 -1
  212. package/dist/types/client/connection.d.ts +64 -13
  213. package/dist/types/client/connection.d.ts.map +1 -1
  214. package/dist/types/client/index.d.ts +1 -1
  215. package/dist/types/client/index.d.ts.map +1 -1
  216. package/dist/types/client/logins.d.ts +2 -1
  217. package/dist/types/client/logins.d.ts.map +1 -1
  218. package/dist/types/client/streams.d.ts +9 -3
  219. package/dist/types/client/streams.d.ts.map +1 -1
  220. package/dist/types/client/turns.d.ts +1 -1
  221. package/dist/types/client/turns.d.ts.map +1 -1
  222. package/dist/types/core/agents/acp/acp-agent.d.ts +34 -1
  223. package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
  224. package/dist/types/core/agents/acp/adapter.d.ts.map +1 -1
  225. package/dist/types/core/agents/acp/client.d.ts +12 -3
  226. package/dist/types/core/agents/acp/client.d.ts.map +1 -1
  227. package/dist/types/core/agents/acp/mappings.d.ts +8 -2
  228. package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
  229. package/dist/types/core/agents/base.d.ts +22 -8
  230. package/dist/types/core/agents/base.d.ts.map +1 -1
  231. package/dist/types/core/agents/claude-code/adapter.d.ts +7 -0
  232. package/dist/types/core/agents/claude-code/adapter.d.ts.map +1 -1
  233. package/dist/types/core/agents/claude-code/approvals.d.ts +4 -1
  234. package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -1
  235. package/dist/types/core/agents/claude-code/claude-agent.d.ts +19 -5
  236. package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -1
  237. package/dist/types/core/agents/claude-code/events.d.ts +9 -1
  238. package/dist/types/core/agents/claude-code/events.d.ts.map +1 -1
  239. package/dist/types/core/agents/claude-code/login.d.ts +4 -1
  240. package/dist/types/core/agents/claude-code/login.d.ts.map +1 -1
  241. package/dist/types/core/agents/claude-code/mcp.d.ts +21 -7
  242. package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -1
  243. package/dist/types/core/agents/claude-code/models.d.ts +5 -1
  244. package/dist/types/core/agents/claude-code/models.d.ts.map +1 -1
  245. package/dist/types/core/agents/claude-code/options.d.ts +29 -10
  246. package/dist/types/core/agents/claude-code/options.d.ts.map +1 -1
  247. package/dist/types/core/agents/claude-code/outcome.d.ts +3 -5
  248. package/dist/types/core/agents/claude-code/outcome.d.ts.map +1 -1
  249. package/dist/types/core/agents/claude-code/results.d.ts +16 -0
  250. package/dist/types/core/agents/claude-code/results.d.ts.map +1 -0
  251. package/dist/types/core/agents/claude-code/sdk-pair.d.ts +13 -0
  252. package/dist/types/core/agents/claude-code/sdk-pair.d.ts.map +1 -0
  253. package/dist/types/core/agents/claude-code/session.d.ts +58 -12
  254. package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
  255. package/dist/types/core/agents/claude-code/spend.d.ts +2 -1
  256. package/dist/types/core/agents/claude-code/spend.d.ts.map +1 -1
  257. package/dist/types/core/agents/claude-code/tools.d.ts +26 -3
  258. package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -1
  259. package/dist/types/core/agents/codex-app-server/adapter.d.ts +2 -2
  260. package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -1
  261. package/dist/types/core/agents/codex-app-server/client.d.ts +12 -2
  262. package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
  263. package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +58 -13
  264. package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -1
  265. package/dist/types/core/agents/codex-app-server/commands.d.ts +2 -2
  266. package/dist/types/core/agents/codex-app-server/commands.d.ts.map +1 -1
  267. package/dist/types/core/agents/codex-app-server/credentials.d.ts +5 -1
  268. package/dist/types/core/agents/codex-app-server/credentials.d.ts.map +1 -1
  269. package/dist/types/core/agents/codex-app-server/effort.d.ts +2 -1
  270. package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -1
  271. package/dist/types/core/agents/codex-app-server/homes.d.ts +25 -0
  272. package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -1
  273. package/dist/types/core/agents/codex-app-server/items.d.ts +27 -2
  274. package/dist/types/core/agents/codex-app-server/items.d.ts.map +1 -1
  275. package/dist/types/core/agents/codex-app-server/login.d.ts +16 -1
  276. package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -1
  277. package/dist/types/core/agents/codex-app-server/mcp.d.ts +15 -30
  278. package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -1
  279. package/dist/types/core/agents/codex-app-server/models.d.ts +3 -10
  280. package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -1
  281. package/dist/types/core/agents/codex-app-server/options.d.ts +27 -4
  282. package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -1
  283. package/dist/types/core/agents/codex-app-server/plan-approval.d.ts +2 -1
  284. package/dist/types/core/agents/codex-app-server/plan-approval.d.ts.map +1 -1
  285. package/dist/types/core/agents/codex-app-server/protocol.d.ts +16 -3
  286. package/dist/types/core/agents/codex-app-server/protocol.d.ts.map +1 -1
  287. package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -1
  288. package/dist/types/core/agents/codex-app-server/session.d.ts +71 -40
  289. package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -1
  290. package/dist/types/core/agents/codex-app-server/subagents.d.ts +9 -4
  291. package/dist/types/core/agents/codex-app-server/subagents.d.ts.map +1 -1
  292. package/dist/types/core/agents/codex-app-server/thread-settings.d.ts +3 -2
  293. package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -1
  294. package/dist/types/core/agents/codex-app-server/turn-items.d.ts +2 -1
  295. package/dist/types/core/agents/codex-app-server/turn-items.d.ts.map +1 -1
  296. package/dist/types/core/agents/codex-app-server/turn.d.ts +31 -8
  297. package/dist/types/core/agents/codex-app-server/turn.d.ts.map +1 -1
  298. package/dist/types/core/agents/codex-app-server/user-login.d.ts +28 -0
  299. package/dist/types/core/agents/codex-app-server/user-login.d.ts.map +1 -0
  300. package/dist/types/core/agents/credentials.d.ts +3 -1
  301. package/dist/types/core/agents/credentials.d.ts.map +1 -1
  302. package/dist/types/core/agents/diffs.d.ts +9 -0
  303. package/dist/types/core/agents/diffs.d.ts.map +1 -0
  304. package/dist/types/core/agents/elicitation.d.ts +3 -2
  305. package/dist/types/core/agents/elicitation.d.ts.map +1 -1
  306. package/dist/types/core/agents/login.d.ts +6 -0
  307. package/dist/types/core/agents/login.d.ts.map +1 -1
  308. package/dist/types/core/agents/mcp-config.d.ts +0 -4
  309. package/dist/types/core/agents/mcp-config.d.ts.map +1 -1
  310. package/dist/types/core/agents/process-pool.d.ts +201 -0
  311. package/dist/types/core/agents/process-pool.d.ts.map +1 -0
  312. package/dist/types/core/agents/scripted/adapter.d.ts +68 -0
  313. package/dist/types/core/agents/scripted/adapter.d.ts.map +1 -0
  314. package/dist/types/core/agents/scripted/mcp-call.d.ts +56 -0
  315. package/dist/types/core/agents/scripted/mcp-call.d.ts.map +1 -0
  316. package/dist/types/core/agents/scripted/scripted-agent.d.ts +73 -0
  317. package/dist/types/core/agents/scripted/scripted-agent.d.ts.map +1 -0
  318. package/dist/types/core/agents/scripted/scripts.d.ts +29 -0
  319. package/dist/types/core/agents/scripted/scripts.d.ts.map +1 -0
  320. package/dist/types/core/agents/scripted/steps.d.ts +132 -0
  321. package/dist/types/core/agents/scripted/steps.d.ts.map +1 -0
  322. package/dist/types/core/agents/session-agent.d.ts +49 -6
  323. package/dist/types/core/agents/session-agent.d.ts.map +1 -1
  324. package/dist/types/core/diagnostics.d.ts +4 -1
  325. package/dist/types/core/diagnostics.d.ts.map +1 -1
  326. package/dist/types/core/index.d.ts +5 -0
  327. package/dist/types/core/index.d.ts.map +1 -1
  328. package/dist/types/core/presets.d.ts +32 -6
  329. package/dist/types/core/presets.d.ts.map +1 -1
  330. package/dist/types/core/processes/lifeline.d.ts +0 -20
  331. package/dist/types/core/processes/lifeline.d.ts.map +1 -1
  332. package/dist/types/core/provision/index.d.ts +2 -2
  333. package/dist/types/core/provision/index.d.ts.map +1 -1
  334. package/dist/types/core/provision/install-build.d.ts +2 -1
  335. package/dist/types/core/provision/install-build.d.ts.map +1 -1
  336. package/dist/types/core/provision/npm.d.ts +20 -8
  337. package/dist/types/core/provision/npm.d.ts.map +1 -1
  338. package/dist/types/core/provision/provisioner.d.ts +4 -1
  339. package/dist/types/core/provision/provisioner.d.ts.map +1 -1
  340. package/dist/types/core/provision/tools.d.ts +2 -1
  341. package/dist/types/core/provision/tools.d.ts.map +1 -1
  342. package/dist/types/core/runtime/agent-runtime.d.ts +16 -8
  343. package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
  344. package/dist/types/core/runtime/event-processor.d.ts +5 -1
  345. package/dist/types/core/runtime/event-processor.d.ts.map +1 -1
  346. package/dist/types/core/runtime/harness-clis.d.ts +9 -0
  347. package/dist/types/core/runtime/harness-clis.d.ts.map +1 -1
  348. package/dist/types/core/runtime/harness-logins.d.ts +33 -5
  349. package/dist/types/core/runtime/harness-logins.d.ts.map +1 -1
  350. package/dist/types/core/runtime/model-lists.d.ts +2 -0
  351. package/dist/types/core/runtime/model-lists.d.ts.map +1 -1
  352. package/dist/types/core/runtime/permission-policy.d.ts +5 -3
  353. package/dist/types/core/runtime/permission-policy.d.ts.map +1 -1
  354. package/dist/types/core/runtime/request-broker.d.ts +2 -1
  355. package/dist/types/core/runtime/request-broker.d.ts.map +1 -1
  356. package/dist/types/core/runtime/turn.d.ts +12 -1
  357. package/dist/types/core/runtime/turn.d.ts.map +1 -1
  358. package/dist/types/core/utils/deadline.d.ts +6 -0
  359. package/dist/types/core/utils/deadline.d.ts.map +1 -1
  360. package/dist/types/core/utils/errors.d.ts +7 -1
  361. package/dist/types/core/utils/errors.d.ts.map +1 -1
  362. package/dist/types/operator/operator.d.ts.map +1 -1
  363. package/dist/types/operator/render.d.ts +6 -4
  364. package/dist/types/operator/render.d.ts.map +1 -1
  365. package/dist/types/protocol/auth.d.ts +54 -24
  366. package/dist/types/protocol/auth.d.ts.map +1 -1
  367. package/dist/types/protocol/clis.d.ts +14 -7
  368. package/dist/types/protocol/clis.d.ts.map +1 -1
  369. package/dist/types/protocol/config.d.ts +2 -0
  370. package/dist/types/protocol/config.d.ts.map +1 -1
  371. package/dist/types/protocol/conversation.d.ts +40 -3
  372. package/dist/types/protocol/conversation.d.ts.map +1 -1
  373. package/dist/types/protocol/credentials.d.ts +7 -0
  374. package/dist/types/protocol/credentials.d.ts.map +1 -1
  375. package/dist/types/protocol/execution.d.ts +2 -1
  376. package/dist/types/protocol/execution.d.ts.map +1 -1
  377. package/dist/types/protocol/factories.d.ts +12 -2
  378. package/dist/types/protocol/factories.d.ts.map +1 -1
  379. package/dist/types/protocol/harness.d.ts +6 -2
  380. package/dist/types/protocol/harness.d.ts.map +1 -1
  381. package/dist/types/protocol/history.d.ts +19 -0
  382. package/dist/types/protocol/history.d.ts.map +1 -1
  383. package/dist/types/protocol/lifecycle.d.ts +47 -8
  384. package/dist/types/protocol/lifecycle.d.ts.map +1 -1
  385. package/dist/types/protocol/model-catalog.d.ts.map +1 -1
  386. package/dist/types/protocol/models.d.ts +3 -0
  387. package/dist/types/protocol/models.d.ts.map +1 -1
  388. package/dist/types/protocol/parts.d.ts +14 -0
  389. package/dist/types/protocol/parts.d.ts.map +1 -1
  390. package/dist/types/protocol/tool-state.d.ts +12 -0
  391. package/dist/types/protocol/tool-state.d.ts.map +1 -1
  392. package/dist/types/protocol/wire-api.d.ts +129 -23
  393. package/dist/types/protocol/wire-api.d.ts.map +1 -1
  394. package/dist/types/protocol/wire.d.ts +70 -10
  395. package/dist/types/protocol/wire.d.ts.map +1 -1
  396. package/dist/types/server/acp/binding.d.ts +6 -1
  397. package/dist/types/server/acp/binding.d.ts.map +1 -1
  398. package/dist/types/server/acp/translate.d.ts +33 -7
  399. package/dist/types/server/acp/translate.d.ts.map +1 -1
  400. package/dist/types/server/agent-server.d.ts +6 -0
  401. package/dist/types/server/agent-server.d.ts.map +1 -1
  402. package/dist/types/server/bin.d.ts +3 -0
  403. package/dist/types/server/bin.d.ts.map +1 -0
  404. package/dist/types/server/feedback.d.ts +2 -1
  405. package/dist/types/server/feedback.d.ts.map +1 -1
  406. package/dist/types/server/install.d.ts +11 -0
  407. package/dist/types/server/install.d.ts.map +1 -1
  408. package/dist/types/server/session-gate.d.ts +2 -1
  409. package/dist/types/server/session-gate.d.ts.map +1 -1
  410. package/dist/types/server/session-store.d.ts +1 -0
  411. package/dist/types/server/session-store.d.ts.map +1 -1
  412. package/dist/types/server/subscriptions.d.ts +2 -1
  413. package/dist/types/server/subscriptions.d.ts.map +1 -1
  414. package/dist/types/server/transports.d.ts +2 -1
  415. package/dist/types/server/transports.d.ts.map +1 -1
  416. package/dist/types/sync/fit.d.ts +8 -7
  417. package/dist/types/sync/fit.d.ts.map +1 -1
  418. package/dist/types/sync/history-sqlite.d.ts.map +1 -1
  419. package/dist/types/sync/index.d.ts +1 -0
  420. package/dist/types/sync/index.d.ts.map +1 -1
  421. package/dist/types/sync/journal-sqlite.d.ts +2 -1
  422. package/dist/types/sync/journal-sqlite.d.ts.map +1 -1
  423. package/dist/types/sync/journal.d.ts +11 -3
  424. package/dist/types/sync/journal.d.ts.map +1 -1
  425. package/dist/types/sync/node-sqlite.d.ts +4 -1
  426. package/dist/types/sync/node-sqlite.d.ts.map +1 -1
  427. package/dist/types/sync/projection.d.ts +6 -0
  428. package/dist/types/sync/projection.d.ts.map +1 -1
  429. package/dist/types/sync/recovery.d.ts +2 -1
  430. package/dist/types/sync/recovery.d.ts.map +1 -1
  431. package/dist/types/sync/schema.d.ts +10 -0
  432. package/dist/types/sync/schema.d.ts.map +1 -1
  433. package/dist/types/sync/sql.d.ts +2 -1
  434. package/dist/types/sync/sql.d.ts.map +1 -1
  435. package/docs/consuming.md +304 -28
  436. package/docs/deploy.md +64 -8
  437. package/docs/durable-sessions.md +35 -5
  438. package/docs/harnesses.md +398 -25
  439. package/package.json +48 -18
  440. package/src/accounts/chatgpt.ts +2 -2
  441. package/src/accounts/http.ts +2 -16
  442. package/src/client/client.ts +92 -31
  443. package/src/client/connection.ts +103 -22
  444. package/src/client/index.ts +1 -0
  445. package/src/client/logins.ts +1 -1
  446. package/src/client/streams.ts +12 -4
  447. package/src/client/turns.ts +1 -1
  448. package/src/core/agents/acp/acp-agent.ts +181 -52
  449. package/src/core/agents/acp/adapter.ts +9 -1
  450. package/src/core/agents/acp/client.ts +16 -4
  451. package/src/core/agents/acp/mappings.ts +27 -0
  452. package/src/core/agents/base.ts +25 -10
  453. package/src/core/agents/claude-code/adapter.ts +47 -17
  454. package/src/core/agents/claude-code/approvals.ts +11 -6
  455. package/src/core/agents/claude-code/claude-agent.ts +89 -32
  456. package/src/core/agents/claude-code/events.ts +11 -1
  457. package/src/core/agents/claude-code/login.ts +14 -2
  458. package/src/core/agents/claude-code/mcp.ts +31 -15
  459. package/src/core/agents/claude-code/models.ts +7 -2
  460. package/src/core/agents/claude-code/options.ts +30 -9
  461. package/src/core/agents/claude-code/outcome.ts +10 -2
  462. package/src/core/agents/claude-code/results.ts +73 -0
  463. package/src/core/agents/claude-code/sdk-pair.ts +66 -0
  464. package/src/core/agents/claude-code/session.ts +179 -37
  465. package/src/core/agents/claude-code/spend.ts +1 -1
  466. package/src/core/agents/claude-code/tools.ts +108 -12
  467. package/src/core/agents/codex-app-server/adapter.ts +37 -12
  468. package/src/core/agents/codex-app-server/client.ts +37 -8
  469. package/src/core/agents/codex-app-server/codex-agent.ts +115 -50
  470. package/src/core/agents/codex-app-server/commands.ts +2 -2
  471. package/src/core/agents/codex-app-server/credentials.ts +10 -5
  472. package/src/core/agents/codex-app-server/effort.ts +1 -1
  473. package/src/core/agents/codex-app-server/homes.ts +54 -3
  474. package/src/core/agents/codex-app-server/items.ts +219 -31
  475. package/src/core/agents/codex-app-server/login.ts +44 -2
  476. package/src/core/agents/codex-app-server/mcp.ts +47 -32
  477. package/src/core/agents/codex-app-server/models.ts +9 -8
  478. package/src/core/agents/codex-app-server/options.ts +69 -10
  479. package/src/core/agents/codex-app-server/plan-approval.ts +1 -1
  480. package/src/core/agents/codex-app-server/protocol.ts +14 -4
  481. package/src/core/agents/codex-app-server/requests.ts +17 -8
  482. package/src/core/agents/codex-app-server/session.ts +160 -113
  483. package/src/core/agents/codex-app-server/subagents.ts +21 -14
  484. package/src/core/agents/codex-app-server/thread-settings.ts +18 -8
  485. package/src/core/agents/codex-app-server/turn-items.ts +1 -1
  486. package/src/core/agents/codex-app-server/turn.ts +79 -32
  487. package/src/core/agents/codex-app-server/user-login.ts +107 -0
  488. package/src/core/agents/credentials.ts +5 -2
  489. package/src/core/agents/diffs.ts +25 -0
  490. package/src/core/agents/elicitation.ts +2 -2
  491. package/src/core/agents/login.ts +6 -0
  492. package/src/core/agents/mcp-config.ts +2 -2
  493. package/src/core/agents/process-pool.ts +458 -0
  494. package/src/core/agents/scripted/adapter.ts +142 -0
  495. package/src/core/agents/scripted/mcp-call.ts +134 -0
  496. package/src/core/agents/scripted/scripted-agent.ts +418 -0
  497. package/src/core/agents/scripted/scripts.ts +171 -0
  498. package/src/core/agents/scripted/steps.ts +127 -0
  499. package/src/core/agents/session-agent.ts +105 -8
  500. package/src/core/diagnostics.ts +9 -1
  501. package/src/core/index.ts +11 -0
  502. package/src/core/presets.ts +100 -14
  503. package/src/core/processes/lifeline.ts +99 -25
  504. package/src/core/provision/index.ts +1 -2
  505. package/src/core/provision/install-build.ts +4 -1
  506. package/src/core/provision/npm.ts +309 -97
  507. package/src/core/provision/provisioner.ts +22 -8
  508. package/src/core/provision/tools.ts +44 -19
  509. package/src/core/runtime/agent-runtime.ts +48 -18
  510. package/src/core/runtime/event-processor.ts +18 -2
  511. package/src/core/runtime/harness-clis.ts +36 -1
  512. package/src/core/runtime/harness-logins.ts +82 -31
  513. package/src/core/runtime/model-lists.ts +1 -1
  514. package/src/core/runtime/permission-policy.ts +4 -3
  515. package/src/core/runtime/request-broker.ts +1 -1
  516. package/src/core/runtime/turn.ts +51 -3
  517. package/src/core/utils/deadline.ts +23 -0
  518. package/src/core/utils/errors.ts +11 -4
  519. package/src/operator/operator.ts +8 -4
  520. package/src/operator/render.ts +46 -8
  521. package/src/protocol/auth.ts +30 -23
  522. package/src/protocol/clis.ts +12 -4
  523. package/src/protocol/credentials.ts +19 -0
  524. package/src/protocol/execution.ts +5 -0
  525. package/src/protocol/factories.ts +25 -3
  526. package/src/protocol/harness.ts +11 -1
  527. package/src/protocol/history.ts +20 -0
  528. package/src/protocol/lifecycle.ts +10 -1
  529. package/src/protocol/model-catalog.ts +19 -8
  530. package/src/protocol/parts.ts +12 -1
  531. package/src/protocol/tool-state.ts +14 -1
  532. package/src/protocol/wire.ts +14 -0
  533. package/src/server/acp/binding.ts +113 -23
  534. package/src/server/acp/translate.ts +161 -8
  535. package/src/server/agent-server.ts +10 -1
  536. package/src/server/bin.ts +108 -19
  537. package/src/server/feedback.ts +1 -1
  538. package/src/server/install.ts +82 -4
  539. package/src/server/session-gate.ts +1 -1
  540. package/src/server/session-store.ts +5 -1
  541. package/src/server/subscriptions.ts +1 -1
  542. package/src/server/transports.ts +20 -1
  543. package/src/sync/fit.ts +115 -28
  544. package/src/sync/history-sqlite.ts +6 -2
  545. package/src/sync/index.ts +1 -0
  546. package/src/sync/journal-sqlite.ts +20 -2
  547. package/src/sync/journal.ts +10 -2
  548. package/src/sync/node-sqlite.ts +19 -3
  549. package/src/sync/projection.ts +10 -0
  550. package/src/sync/recovery.ts +11 -4
  551. package/src/sync/schema.ts +7 -5
  552. package/src/sync/sql.ts +1 -1
  553. package/dist/types/core/agents/claude-code/session-pool.d.ts +0 -36
  554. package/dist/types/core/agents/claude-code/session-pool.d.ts.map +0 -1
  555. package/dist/types/core/agents/session-pool.d.ts +0 -41
  556. package/dist/types/core/agents/session-pool.d.ts.map +0 -1
  557. package/src/core/agents/claude-code/session-pool.ts +0 -136
  558. package/src/core/agents/session-pool.ts +0 -111
package/docs/harnesses.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Harness support matrix
2
2
 
3
- Three harnesses, one event stream. The lifecycle event *structure* is identical
3
+ Four harnesses, one event stream. The lifecycle event *structure* is identical
4
4
  across harnesses (one generic `EventProcessor` drives it); payloads and config
5
5
  support differ only where the backends genuinely do.
6
6
 
@@ -9,6 +9,7 @@ support differ only where the backends genuinely do.
9
9
  | `claude-code` | `@anthropic-ai/claude-agent-sdk` (claude CLI) | token-level | yes (`resume`) | `in_session` (`setModel`) |
10
10
  | `codex-app-server` | `codex app-server` (JSON-RPC subprocess) | token-level | yes (`thread/resume`) | `in_session` (per-turn) |
11
11
  | `acp` | any ACP v1 agent via `@agentclientprotocol/sdk` | per-agent | yes (`session/resume`, else `session/load`) | when the agent offers a `model` config option (so the capability says `unsupported`) |
12
+ | `scripted` | a script the operator gives, no process ([below](#the-scripted-harness)) | a word at a time (`stream` steps) | any id (nothing to lose) | `unsupported`: it runs no model |
12
13
 
13
14
  The `acp` harness is opt-in (an operator-supplied launch command, never
14
15
  wire-sourced): well-known agents run by name (`--harness=pi`,
@@ -26,6 +27,11 @@ offers it (checked against SDK 1.7.0 with `claude-agent-acp` and `codex-acp`):
26
27
  `thought_level` config options (`session/set_config_option`). An agent
27
28
  without the option keeps its default. A model the agent does not list fails
28
29
  the turn as `invalid_request`; an unlisted thinking level is left alone.
30
+ - **Permission mode:** an agent that offers modes is put in the turn's
31
+ (`default` when it names none) with `session/set_mode`, by the agent's own
32
+ id (`acceptEdits`, `bypassPermissions` and the like are read as the
33
+ engine's); one it offers none of is reported not applied. The engine also
34
+ answers the agent's permission requests by the mode.
29
35
  - **Extra directories:** `additionalDirectories` is sent to agents that
30
36
  advertise the capability and ignored otherwise.
31
37
  - **Token usage:** read from the prompt response when the agent sends it. The
@@ -36,6 +42,9 @@ offers it (checked against SDK 1.7.0 with `claude-agent-acp` and `codex-acp`):
36
42
  those words never decide the category. A child it left running cannot hold
37
43
  the turn open, and an agent that ignores SIGTERM is killed after three
38
44
  seconds.
45
+ - **Its own name:** `initialize` names the client `agent-server`, with the
46
+ stock program's release as its version; embedded, `acp.clientName` and
47
+ `acp.clientVersion` say them (else `agent-server` and `0.0.0`).
39
48
  - **`pi`** runs a pinned `pi-acp@0.0.34` through `npx`, not whatever version
40
49
  npm published last; bump the pin after checking a new release.
41
50
 
@@ -55,12 +64,13 @@ warm multi-turn reuse, a unified `ThinkingLevel`, and normalized token usage.
55
64
  | `additionalDirectories` | ✅ | ✅ (writable roots of the workspace-write sandbox; a change starts a new process) |
56
65
  | `maxTurns` | ✅ | ❌ |
57
66
  | `mcpServers` | ✅ | ✅ (stdio / Streamable HTTP; in the thread's config, or written to the `CODEX_HOME` the turn names) |
58
- | `apiKey` / `env` | ✅ | ✅ (the key logs in that session's process, in memory only; a credential the product holds wins) |
67
+ | `apiKey` / `env` | ✅ | ✅ (the key logs in that session's process, in memory only; a credential the product holds wins; under `userLogin` it wins over the user's own login) |
59
68
  | `disableTools` | ✅ | ❌ refused as `invalid_request`: Codex gives the model its tools however it is configured (use `plan` or `default`) |
60
69
  | permission requests (capability `permissionRequests`) | ✅ (`canUseTool`) | ✅ (`on-request` approvals in `default`, `accept_edits` and `plan`, MCP tool consent included; a plan turn's edits are declined) |
61
70
  | the words said with a refusal (capability `rejectionMessages`) | ✅ the denial tells Claude what the user said | ❌ a bare verdict (a plan's answer carries them) |
62
- | `elicitation` (questions, MCP input) | `AskUserQuestion`; MCP `onElicitation` (form, url) | `request_user_input` (plan mode); MCP elicitation (form, url) |
71
+ | `elicitation` (questions, MCP input) | `AskUserQuestion`; MCP `onElicitation` (form, url) | `request_user_input` in every mode (each thread starts with Codex's `default_mode_request_user_input`; declined in a turn that does not opt in); MCP elicitation (form, url) |
63
72
  | steering (`turn/steer`) | ✅ uuid-stamped messages, read where Claude replays them; a late steer runs as one more query in the turn | ✅ `turn/steer`, read where Codex starts its user message |
73
+ | a cancel (`turn/cancel`) | the SDK's interrupt, confirmed once Claude acknowledges it or the turn ends within `cancelConfirmMs`; a turn Claude has not ended `cancelGraceMs` (10 s) after it has its process ended, and the next turn resumes on a new one | `turn/interrupt`, then the turn's commands stopped (below); its process ended when either is not done within `cancelGraceMs` (2 s) |
64
74
  | image / file input (capabilities `images`, `files`) | images (data or http(s) URL), PDFs, text files (`files: text, pdf`) | images (data or local path), text files inline (`files: text`), local files as mentions |
65
75
  | `includeRaw` | ✅ | ✅ |
66
76
 
@@ -96,9 +106,11 @@ engine (`permission.requested`) only in `default`, `accept_edits` and
96
106
  boundary is its sandbox, so a command that writes in the folder
97
107
  (`printf > e1.txt`) or in `/tmp` runs unasked too.
98
108
 
99
- A Codex approval shows what it approves: a command's `rawInput` is its
100
- `command` and `cwd`, a file change's its `changes` (each `{path, kind, diff}`,
101
- with `locations`), and an MCP tool's its arguments, as Claude's are. A command
109
+ A Codex approval shows what it approves: a command's line is its `command`
110
+ (its `rawInput` is Codex's wrapped `command` and `cwd`), a file change's
111
+ hunks are its `locations` (its `rawInput` the `changes`, each `{path, kind,
112
+ diff}`), and an MCP tool's `rawInput` its arguments, as Claude's are. Why
113
+ Codex asks is `reason` ([below](#what-a-tool-call-says-per-harness)). A command
102
114
  or change the user declines fails, saying it was not approved (Codex
103
115
  completes it as `declined`).
104
116
 
@@ -106,7 +118,8 @@ A cancelled Codex turn stops the commands it started before it ends. Codex
106
118
  0.160 ends a turn on `turn/interrupt` but keeps a running command alive as a
107
119
  background terminal, so the engine terminates the terminals the turn started
108
120
  (not those it only polled or wrote to) and checks that they are gone,
109
- reading Codex's list again for a while, since a terminal can register late.
121
+ reading Codex's list again for `cancelGraceMs` (2 s by default), since a
122
+ terminal can register late.
110
123
  When Codex cannot stop one, the engine ends the app-server, whose shutdown
111
124
  stops every terminal, an earlier turn's too (the next turn resumes the
112
125
  thread). Otherwise terminals an earlier turn left running, such as a server
@@ -114,13 +127,24 @@ the agent started on purpose, keep running. A command whose stop could not be
114
127
  confirmed fails with its outcome unknown, and the cancel answers
115
128
  `unconfirmed`. A cancel that arrives after Codex's turn ended stops nothing.
116
129
 
130
+ A Codex MCP tool's image comes as `content` on its tool part (`{type:
131
+ "image", data, mimeType}` beside its text), with `[image <mimeType>]` where it
132
+ was in `output`, as a Claude tool result's does; no block's base64 is ever
133
+ text (`[<type> <mimeType>]` stands for it). A picture Codex makes itself is a
134
+ tool part too, `image_generation` (`kind: "other"`): the prompt Codex wrote as
135
+ `input.prompt` when it gives one, and the file Codex saved it to in
136
+ `metadata.savedPath`, never the picture's bytes. A code-mode `exec` cell is no item of Codex's, so
137
+ only the items it causes reach the stream (LLP 0001, D14).
138
+
117
139
  Codex per-turn MCP is supported through the engine and JSON-RPC API, and the
118
140
  repository CLI: in the user's own Codex home at `inheritConfig: "all"`, where
119
141
  the servers ride the thread's config and nothing is written, or in a home of
120
142
  the session's own (`config.env.CODEX_HOME`, the CLI's `--codex-home`), where
121
143
  the engine writes them (LLP 0001, D21; see
122
- [MCP configuration](consuming.md#configure-mcp-between-turns)). The ACP
123
- server binding rejects Codex MCP at session admission.
144
+ [MCP configuration](consuming.md#configure-mcp-between-turns)). Behind the
145
+ ACP server binding, a client's stdio and HTTP servers take the first path;
146
+ an SSE server or one named `codex_apps` is refused at `session/new` or
147
+ `session/resume`, naming it.
124
148
  Below `inheritConfig: "all"` every Codex turn needs a home of its session's
125
149
  own, so the bin refuses `--acp --harness codex-app-server` with
126
150
  `--inherit-config project` or `none`.
@@ -128,13 +152,27 @@ own, so the bin refuses `--acp --harness codex-app-server` with
128
152
  The ACP server binding (`agent-server --acp`) records each session's native
129
153
  id under `$AGENT_SERVER_ACP_SESSION_DIR` (default
130
154
  `~/.local/state/agent-server/acp-sessions`), so a client's `session/resume`
131
- works after the agent process restarts. It reports per-turn usage on the prompt
132
- response and advertises HTTP/SSE MCP when fronting `claude-code`. It offers
155
+ works after the agent process restarts. A prompt's text and images reach
156
+ the turn, and a resource link (an editor's @-mention of a file) as a
157
+ Markdown link in its text; it advertises no audio or embedded context. It reports per-turn usage on the prompt
158
+ response and advertises the MCP transports the harness it fronts attaches
159
+ beside stdio: HTTP and SSE for `claude-code`, HTTP for `codex-app-server`
160
+ and `scripted`, none for `acp` (the agent behind decides). It offers
133
161
  session modes (`default`, `accept_edits`, `plan`, and the mode it was started
134
162
  in): the client picks one with `session/set_mode`, and when the agent switches
135
163
  (an approved plan) the session follows and the client hears
136
164
  `current_mode_update`. A client cannot pick a mode above the one the operator
137
- started it in.
165
+ started it in. Every turn runs on the harness's own default model and
166
+ thinking level (in front of Codex, the user's `~/.codex` default) unless the
167
+ operator names them: `--model <id>` and `--thinking <level>` hold for every
168
+ turn the binding runs, and no ACP client can change them (it is offered no
169
+ config options). A client that advertises form elicitation at `initialize`
170
+ is asked the agent's questions, as one ACP form with a required field per
171
+ question (ACP v1 has no question mode, and no masked field for a `secret`
172
+ one), and an MCP server's forms as they are; one that advertises URL
173
+ elicitation, an MCP server's URLs. A request in a mode the client did not
174
+ advertise is declined; for a client that advertises neither, the turn runs
175
+ without `elicitation`, so the agent is told no one can answer.
138
176
 
139
177
  What a Claude or Codex session loads by itself is the operator's
140
178
  `inheritConfig` (LLP 0001, D17; choosing one: [consuming.md](consuming.md#choose-what-a-turn-inherits)).
@@ -151,9 +189,16 @@ and the connectors stay off whatever either env says, and a `disableTools`
151
189
  turn runs at `none`. Claude's built-in plugins and skills and the host's
152
190
  managed policy load at every level, and `~/.claude.json` is read for the
153
191
  account (its MCP servers follow the user and local sources). A Codex session at `project` or `none`
154
- runs in the `CODEX_HOME` its turn names, of the session's own, and at `none`
155
- without the repository's `AGENTS.md`; the repository's skills and
156
- `~/.agents/skills` load at every level.
192
+ 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
197
+ home was removed or made again under its warm process starts a new one on its
198
+ next turn, which resumes the thread there or fails `resume_failed` as a cold
199
+ start would; the repository's skills and `~/.agents/skills` load
200
+ at every level. With `codexAppServer.userLogin` such a session runs on the
201
+ user's own Codex login ([below](#the-users-own-codex-login-in-a-sessions-home)).
157
202
 
158
203
  `thinkingLevel` runs from `off` to `ultra`. agent-server fits it to the
159
204
  model's levels when it knows them: a level above the model's top becomes that
@@ -170,11 +215,16 @@ cancelled before the model answered:
170
215
  - **claude-code** fits the level before starting Claude, because Claude Code
171
216
  lowers a level its model lacks without saying so (`xhigh` on Sonnet 4.6 runs
172
217
  `high`). With no known levels the level passes through and no applied level
173
- is reported. `off` is sent as is: some models do not let thinking be
174
- disabled. An operator `sdkOptions` that sets `effort` or `thinking` wins, and
175
- then no level is reported.
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.
176
224
  - **codex-app-server** reads what the thread's model accepts from its own
177
- `model/list`. With no level requested it reports the thread's effort (for
225
+ `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
227
+ requested it reports the thread's effort (for
178
228
  example from `~/.codex/config.toml`), and the thread's model in
179
229
  `reportedModels` when the stream names none. Codex runs the effort it is
180
230
  given, so that is the one reported.
@@ -194,6 +244,115 @@ cancelled before the model answered:
194
244
 
195
245
  `clampThinkingLevel` picks the nearest level when a picker switches models.
196
246
 
247
+ ## What each harness does with each turn setting
248
+
249
+ Read from the code. **Applied**: as `RunConfig` documents it. **Another
250
+ meaning**: it has an effect, a different one. **Ignored**: the turn runs
251
+ without it; the harness lists it in `capabilities.ignoredSettings`, and a turn
252
+ that sets it names it in `turn.started.execution.notApplied`. **Refused**: the
253
+ turn fails. **The agent's**: an ACP agent decides, by what it advertises.
254
+ **The engine**: applied by the engine, the same on every harness. A cell that
255
+ ends "(not applied: …)" is a case a harness finds as the turn runs, named in
256
+ `turn.ended.execution.notApplied`.
257
+
258
+ | Setting | claude-code | codex-app-server | acp | scripted |
259
+ | --- | --- | --- | --- | --- |
260
+ | `harness` | the engine | the engine | the engine | the engine |
261
+ | `model` | applied, switched live | applied (`turn/start`) | the agent's: set through its `model` config option; an agent without one keeps its own (not applied: `model`); a value it does not list is refused | ignored: `echo: "config"` says it |
262
+ | `thinkingLevel` | applied, fitted to the model's levels (a model with none: not applied: `thinkingLevel`) | applied as reasoning effort, fitted to the model; `off` is its lowest effort (a model with no reasoning control: not applied: `thinkingLevel`) | the agent's: set through its `thought_level` option when it lists the level (otherwise not applied: `thinkingLevel`) | ignored: `echo: "config"` says it |
263
+ | `cwd` | applied | applied | applied | another meaning: a change needs a resume (as on every harness), and `echo: "config"` says it |
264
+ | `additionalDirectories` | applied | another meaning: writable roots of the `accept_edits` sandbox, nothing in the other modes | the agent's: sent only to an agent that takes them (otherwise not applied: `additionalDirectories`) | ignored: `echo: "config"` says them |
265
+ | `systemPromptAppend` | applied, appended to Claude Code's system prompt | another meaning: a developer message (`developerInstructions`) | ignored: ACP v1 has no system prompt | ignored: `echo: "config"` says it |
266
+ | `maxTurns` | applied (unset is 100) | ignored | ignored | ignored |
267
+ | `subagentMode` | applied | another meaning: Codex's `multi_agent` on, an instruction to collect every sub-agent, a native cleanup at the end | refused | refused |
268
+ | `permissionMode` | applied (SDK modes) | another meaning: a sandbox and an approval policy (the table below) | applied where the agent offers a mode of that meaning (`session/set_mode`, by its own id; `default` when the turn names none), and the engine answers its requests by the mode; one it offers none of is not applied (`permissionMode`), nor `plan` on an agent with no modes | ignored: the script says which calls ask (`ask: true`); `echo: "config"` says it |
269
+ | `elicitation` | applied | applied | applied: the agent's form and URL requests (ACP v1 has no question tool) | applied: an `ask` step asks the person, else the agent is told no one can answer |
270
+ | `requestTimeoutMs` | the engine | the engine | the engine | the engine |
271
+ | `resumeSessionId` | applied | applied (`thread/resume`) | the agent's: `session/resume`, else `session/load`; refused for an agent with neither | applied: reported as the native id, resumed |
272
+ | `resumeSessionAt` | applied with a resume (without one: not applied: `resumeSessionAt`) | ignored | ignored | ignored |
273
+ | `mcpServers` | applied, switched live | applied; SSE and the name `codex_apps` refused | the agent's: every server is sent, whatever it advertises; `required` is not checked | applied: a `call` step calls an `http` one |
274
+ | `env` | applied | applied; `CODEX_HOME` is the session's home (below `all`, required) | applied | another meaning: a change needs a resume, and `echo: "config"` says its keys |
275
+ | `apiKey` | applied (`ANTHROPIC_API_KEY`) | applied (an in-memory login) | ignored: the agent's credentials are its launch command's | ignored: it runs on no credential |
276
+ | `disableTools` | applied (no tools, no MCP servers) | refused (`invalid_request`) | ignored: ACP v1 cannot ask for it | ignored: its tool calls are the script's |
277
+ | `includeRaw` | the engine | the engine | the engine | the engine |
278
+
279
+ `test/core/agents/ignored-settings.test.ts` holds this table's verdicts; a
280
+ new `RunConfig` field fails it until each harness's verdict is written there.
281
+ A setting an operator's own options replace (Claude's `sdkOptions`) is the
282
+ operator's, and not named as not applied.
283
+
284
+ ## What each permission mode does, per agent
285
+
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
288
+ call ran in a fresh session and folder, with every `permission.requested`
289
+ answered `allow_once`, and each call that asked ran again with the request
290
+ answered `reject_once`. Whether a call ran is read from the file on disk, the
291
+ test's own MCP server or the tool's output, never from the model's reply.
292
+ Codex's calls came from a scripted stand-in model that makes the calls
293
+ `gpt-6-luna` makes, and its web search came from the real model. The
294
+ `permission-modes` harness scenario checks every cell against the expected
295
+ tables in `apps/harness/src/scenarios/permission-modes.ts`, so a pin bump that
296
+ changes what a mode does fails it:
297
+
298
+ ```sh
299
+ bun run harness -- --harness=claude-code,codex-app-server --scenario=permission-modes
300
+ ```
301
+
302
+ 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`.
305
+
306
+ In each cell, Claude's result comes first, then Codex's. **asks**: a
307
+ `permission.requested` arrives, and the call runs when allowed and does not
308
+ run when rejected. **runs**: nothing is asked and the call runs. **refused**:
309
+ nothing is asked and the call does not run.
310
+
311
+ | Call | `default` | `accept_edits` | `bypass_permissions` | `dont_ask` | `plan` |
312
+ | --- | --- | --- | --- | --- | --- |
313
+ | Read a file in the folder | runs / runs | runs / runs | runs / runs | runs / runs | runs / runs |
314
+ | Read a file in a sibling temp folder | asks / runs | asks / runs | runs / runs | refused / runs | asks / runs |
315
+ | Write a file in the folder (Claude's `Write`, Codex's `apply_patch`) | asks / asks | runs / runs | runs / runs | refused / refused | asks / refused |
316
+ | Write a file in the folder through the shell | asks / asks | runs / runs | runs / runs | refused / refused | asks / asks |
317
+ | `echo hi` | runs / runs | runs / runs | runs / runs | runs / runs | runs / runs |
318
+ | Write a file in a sibling temp folder | asks / asks | asks / runs | runs / runs | refused / refused | asks / refused |
319
+ | Write a file outside the folder and outside temp | not measured / asks | not measured / asks | not measured / runs | not measured / refused | not measured / refused |
320
+ | An MCP tool with no hints | asks / asks | asks / asks | runs / runs | refused / refused | asks / asks |
321
+ | An MCP tool marked `readOnlyHint` | asks / runs | asks / runs | runs / runs | refused / runs | asks / runs |
322
+ | Web (Claude's `WebFetch`\*, Codex's hosted web search) | asks / runs | asks / runs | not asked / runs | not asked / runs | asks / runs |
323
+
324
+ Claude reads with `Read` and runs commands with `Bash`. Codex runs both reads
325
+ and commands as shell commands (`cat`, `echo pm > file`). \*Claude's `WebFetch`
326
+ of a page on loopback switches to https and fails, so for it only whether it
327
+ asks is measured.
328
+
329
+ What differs, and so what a product should not assume of one agent from the
330
+ other:
331
+
332
+ - **`accept_edits` is not the same mode.** Claude runs a write in the folder
333
+ unasked, by `Write` or the shell, and still asks for a read or write outside
334
+ it, a temp folder included, and for every MCP tool. Codex runs unasked
335
+ whatever its workspace sandbox allows, a write to a sibling temp folder
336
+ included, and asks only beyond it and for an MCP tool without `readOnlyHint`.
337
+ - **Codex never asked before a read**, one in a sibling temp folder included,
338
+ in any mode. Claude asks before a read outside the folder in `default`,
339
+ `accept_edits` and `plan`, and refuses it in `dont_ask`.
340
+ - **`readOnlyHint` counts on Codex only.** Codex runs such an MCP tool unasked
341
+ in every mode. Claude asks for it as for any MCP tool, and refuses it in
342
+ `dont_ask`.
343
+ - **`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
345
+ write the model retries with escalation is asked and runs when allowed.
346
+ - **`dont_ask` refuses different calls.** Claude runs only a read in the
347
+ folder and a command that writes nothing. Codex refuses writes and MCP tools
348
+ without `readOnlyHint`, and runs reads outside the folder, `readOnlyHint`
349
+ tools and web search.
350
+ - **Codex never asks before a web search**, in any mode.
351
+ - A Codex shell write asks only when the model retries it with escalation
352
+ after the sandbox refused it, as the stand-in does. In one paid run in
353
+ `default`, `gpt-6-luna` did not retry: no request came, and no tool part
354
+ reached the stream.
355
+
197
356
  ## Model lists
198
357
 
199
358
  `runtime.models({ harness, cwd })` (wire `models/list`, `client.listModels()`)
@@ -205,6 +364,7 @@ a turn with the same `cwd`, `env` and `apiKey` would use:
205
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. |
206
365
  | `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. |
207
366
  | `acp` | none | The catalog (empty). ACP agents describe models as session config options. |
367
+ | `scripted` | the harness | One model, `scripted`, with no thinking levels. |
208
368
 
209
369
  Each `ModelDescriptor` has `id` (pass as `config.model`), `label`,
210
370
  `description`, `resolvedId` (what an alias runs), `isDefault`, `thinking`
@@ -218,12 +378,23 @@ the harness's lists; pass `refresh: true` after one it cannot see. Listing costs
218
378
  0.1 s for Codex once warm, a few seconds for the first read after the server
219
379
  starts. A CLI that cannot answer within 20 s (logged out, too old) gets the
220
380
  catalog with `source: "catalog"` and an `error`, or the last live list with the
221
- `error` when one was read; a failed read is retried after 30 seconds.
381
+ `error` when one was read; a failed read is retried after 30 seconds. A
382
+ list installs nothing: while the harness's CLI is not installed yet, being
383
+ installed or failed to install, the answer is the catalog with an `error`
384
+ saying so, cached by nothing, so the first list after the install is live
385
+ (LLP 0010).
222
386
 
223
387
  The catalog (`CATALOG_MODELS`) is what
224
388
  the pinned CLIs listed when the release was built (`bun run models:refresh`):
225
389
  Claude for the maintainer's login, Codex logged in and logged out (which adds
226
- the API-key models such as `gpt-5.5`). Keep the user's thinking choice per
390
+ the API-key models such as `gpt-5.5`). Claude's rows depend on the route:
391
+ on a login that reaches `api.anthropic.com` the CLI takes them from the list
392
+ Anthropic serves the account ("Opus 5.5"), which the catalog records. Where
393
+ it does not get that list (a product's held credentials, listed on the
394
+ placeholder key; `ANTHROPIC_BASE_URL` elsewhere; a cloud provider), it uses the
395
+ picker built into it ("Opus", "Sonnet", "Haiku", a `claude-fable-5-1[1m]` row, other
396
+ descriptions), so a picker shown from the catalog there renames its rows once
397
+ the CLI answers. Keep the user's thinking choice per
227
398
  model in your app; start from `thinking.default`, and use `clampThinkingLevel`
228
399
  only for a model the user has not set.
229
400
 
@@ -231,8 +402,10 @@ Consult `runtime.capabilities(harness)` before relying on a capability.
231
402
 
232
403
  ## Logins
233
404
 
234
- `auth/status` reads each harness's login from its CLI; `auth/login` runs the
235
- CLI's own flow (LLP 0011; the recipe is in
405
+ `auth/status` reads each harness's login from its CLI, and installs none: a
406
+ harness whose CLI is not installed yet is `unknown`, with no methods.
407
+ `auth/login` runs the CLI's own flow, installing it first (LLP 0011; the
408
+ recipe is in
236
409
  [consuming.md](consuming.md#show-each-harnesss-login-and-sign-it-in)).
237
410
 
238
411
  | Harness | Status from | Logins (`methods`) | Logout |
@@ -240,15 +413,50 @@ CLI's own flow (LLP 0011; the recipe is in
240
413
  | `claude-code` | `claude auth status --json`, with the turn's environment | `claudeai`, `console` (`browser`, with a `codeUrl` for another device; over the SDK's control requests, CLI 2.1.220 and later), `terminal` (`claude auth login`) | `claude auth logout` |
241
414
  | `codex-app-server` | `account/read` on an app-server of its own | `chatgpt` (`browser`, callback on `127.0.0.1:1455`, one per machine), `chatgpt_device_code`, `api_key`, `terminal` (`codex login`) | `account/logout` |
242
415
  | `acp` | — (`unknown`: the agent signs in on its own) | none | — |
416
+ | `scripted` | — (`signed_in`: it runs on nothing, so there is nothing to sign in to) | none | refused (`invalid_request`) |
243
417
 
244
418
  A login lands in the store a turn with the same `env` uses (`CLAUDE_CONFIG_DIR`,
245
419
  `CODEX_HOME`). Claude reports the credential a turn would run with, so a key in
246
420
  the environment shows as `source: "environment"` over any login. A login change
247
- starts each session's next turn on a new CLI. Codex logins below `inheritConfig:
248
- "all"` land in the `CODEX_HOME` the request's `env` names. The engine reads and
421
+ starts each session's next turn on a new CLI. A Codex session on its home's own
422
+ login also follows a change made outside the engine (`codex login` in a
423
+ terminal, another app): when the home's `auth.json` (a link followed to its
424
+ target) changed since its app-server started, the next turn starts a new one,
425
+ which resumes the thread; a turn already running finishes first. The engine
426
+ never opens the file, so any rewrite counts, a ChatGPT token Codex renewed
427
+ (about every ten days per login) included: one colder turn. A sign-out removes
428
+ the file, and the next turn fails `auth`. Not followed: a keychain store
429
+ (`cli_auth_credentials_store = "keyring"`, or `auto` with a keychain), and a
430
+ session the engine hands a login to (`credentials`, `userLogin`, `apiKey`),
431
+ which is logged in again at each turn. A warm Claude CLI reads its store on
432
+ each request (LLP 0011). Codex logins below `inheritConfig:
433
+ "all"` land in the `CODEX_HOME` the request's `env` names; under
434
+ `codexAppServer.userLogin` the turns in those homes run on the user's own
435
+ login, which a request with no `env` reads and signs in. The engine reads and
249
436
  runs the CLI it starts: a host that starts Claude its own way
250
437
  (`claudeCode.sdkOptions`, a spawner of its own) signs it in where it runs it.
251
438
 
439
+ ## The user's own Codex login in a session's home
440
+
441
+ `codexAppServer.userLogin: true` (`createAgentRuntime`; operator-level and
442
+ embed-tier only, never from the wire) runs a Codex turn
443
+ that names a `CODEX_HOME` of its session's own on the user's own Codex login,
444
+ the one of the engine's own home (`$CODEX_HOME`, else `~/.codex`) (LLP 0017).
445
+ Before each turn, and each model list for an `env` naming a home, the engine
446
+ starts an app-server there with its own environment and asks
447
+ `getAuthStatus {includeToken: true, refreshToken: false}`: a ChatGPT login
448
+ logs the session's process in with `chatgptAuthTokens` (account and plan from
449
+ the access token's claims), an API key as `apiKey`, both in that process's
450
+ memory; nothing is written to the session's home. A product's `credentials`
451
+ and the turn's `apiKey` come first. No login there, or one that cannot be
452
+ handed over, fails the turn `auth` (`credentialsReconnect`) before the
453
+ session's process starts. When Codex refuses the token, the login is read
454
+ again, and when it still holds the refused token Codex renews it in the
455
+ user's own home; another account is refused. Nothing is cached: a login the
456
+ user changes in a terminal is the next turn's, and another account starts a
457
+ new process that resumes the thread. A turn that names no home runs on its
458
+ home's own login as before.
459
+
252
460
  ## Host-managed Codex authentication
253
461
 
254
462
  An embedding host hands Codex a login of its own with `credentials`, the same
@@ -287,6 +495,34 @@ credentials are added to `RunConfig` or the engine's public wire.
287
495
  The protocol was checked against Codex CLI 0.160.0 and the
288
496
  [official app-server authentication documentation](https://learn.chatgpt.com/docs/app-server#3c-log-in-with-externally-managed-chatgpt-tokens-chatgptauthtokens).
289
497
 
498
+ ## What a tool call says, per harness
499
+
500
+ What a product draws a terminal step, a fetch, a diff or a permission card
501
+ from, without reading a harness's own input keys (LLP 0002, A tool call says
502
+ what it acts on). A field a harness does not give is left out.
503
+
504
+ | Field | claude-code | codex-app-server | acp |
505
+ | --- | --- | --- | --- |
506
+ | `command` (part and request) | a `Bash` call's `input.command` | the line apart from the shell Codex wraps it in (`/bin/zsh -lc '…'`), unquoted; any other shape as Codex reports it. `input.command` stays wrapped | none: an agent's `title` is all ACP v1 gives |
507
+ | `url` | a `WebFetch` call's `input.url` | none: its network approval was not observed | none |
508
+ | `locations` | a file tool's path; once an `Edit` or a `Write` over a file is done, each hunk at its start line in the new file | a file change's hunks, each at its start line in the new file; a move's source and destination; an add's or a delete's path | the agent's own |
509
+ | `reason` (request) | the CLI's `decisionReason`, when it sends one ("Path is outside allowed working directories") | the approval's `reason`, the model's own justification. `title` is never it | none: ACP v1's request has no field for it |
510
+ | `diff` content | from the CLI's structured result: an `Edit`'s or an overwriting `Write`'s hunks; a created file's content as `newText`; a `NotebookEdit`'s cell, `old_source` to `new_source`. None on a failed edit | a hunk per entry for an update (at a move's destination, without its `Moved to:` trailer); an add's content as `newText`; a delete's as `oldText`, `newText` `""`. None on a failed or declined change | the agent's `diff` and `terminal` content, as it sent them, the latest update's winning |
511
+ | `metadata.exitCode` | on a failed `Bash` call only, from the `Exit code N` its result begins with: the CLI reports no code for a success, and counts some non-zero exits as one | Codex's `exitCode`, on a completed and a failed command alike | none |
512
+
513
+ Every tool the pinned Claude CLI offers has a decided `kind`. A Claude pin
514
+ bump runs `bun run test:live:free`: its `claude-tool-kinds` check starts the
515
+ pinned CLI for free and names each tool it offers that has none.
516
+
517
+ Behind `agent-server --acp`, a part's `diff` entries reach the client as ACP
518
+ `diff` content, after its output; a `terminal` is the agent's, so it is
519
+ not sent. A permission request carries the call's `name`, `kind`,
520
+ `locations` and `rawInput`; ACP v1's request has no field for its
521
+ `command`, `url`, `reason` or `mcp`.
522
+
523
+ A hunk's `oldText` is its context and removed lines, its `newText` its
524
+ context and added lines; a `` marker is dropped.
525
+
290
526
  ## Payload notes
291
527
 
292
528
  - A turn ends with a normalized `stopReason`
@@ -342,6 +578,143 @@ turn totals take precedence over intermediate message usage.
342
578
  cache accounting. An ACP/custom agent that exposes only this gauge cannot
343
579
  provide the cache breakdown without an additional native usage report.
344
580
 
581
+ ## The scripted harness
582
+
583
+ `scripted` plays a script instead of a model, so a product can test its whole
584
+ integration (its turns, its tool server, its permission and question
585
+ handling, resume, close) for nothing, and so the engine has one small,
586
+ complete example of a harness (`core/agents/scripted/`; LLP 0016, The
587
+ scripted harness). It has a name of its own: `initialize`, `session.created`
588
+ and every event say `scripted`, so a stream never passes a script off as a
589
+ real agent. It is registered only when the operator gives it a script, and
590
+ never otherwise: no default set holds it.
591
+
592
+ ```ts
593
+ import { createAgentRuntime, scriptedQueue } from "@zvada/agent-server/core";
594
+
595
+ const runtime = createAgentRuntime({
596
+ harnesses: ["scripted"],
597
+ scripted: { turn: scriptedQueue([{ say: "Hello." }, { end: true }]) },
598
+ });
599
+ ```
600
+
601
+ **Where a turn's steps come from: one function.**
602
+ `scripted: { turn: (request) => steps }` returns an iterable, or an async
603
+ iterable a test can release a step at a time, of `ScriptStep`s. `request`
604
+ holds the turn's `sessionId`, `turnId`, `input`, `config` (the turn's
605
+ `RunConfig`, as a harness gets it), `turnIndex` (how many turns the session
606
+ ran before, in this engine) and `signal`. A turn plays its steps until they
607
+ end or an `end` step.
608
+
609
+ A step's `yield` evaluates to what the step did (`ScriptStepOutcome`): the
610
+ agent passes it to the next `next()`, so a script written as a generator can
611
+ use an earlier answer, and an array, the helpers and a file ignore it.
612
+
613
+ ```ts
614
+ scripted: {
615
+ turn: async function* () {
616
+ const made = yield { call: { server: "notes", tool: "save_note", arguments: { text: "a" } } };
617
+ if (!made || !("output" in made)) throw new Error("the save failed");
618
+ const id = made.metadata?.structuredContent?.id;
619
+ yield { call: { server: "notes", tool: "update_note", arguments: { id } } };
620
+ yield { say: "Done." };
621
+ },
622
+ }
623
+ ```
624
+
625
+ A `tool` or `call` step that completed hands back `{ output, content?,
626
+ metadata? }`, what its part completed with (a call's `structuredContent` under
627
+ `metadata`); one that failed `{ error, metadata? }`, with `rejected: true`
628
+ when the person denied it; an `ask` step `{ answer }`, the elicitation outcome, and
629
+ `undefined` when the turn's client answers no questions; every other step
630
+ `undefined`. A permission request answered as a cancel ends the turn, so
631
+ nothing is handed back.
632
+
633
+ Built on it, all from `./core`:
634
+
635
+ | Helper | What it plays |
636
+ | --- | --- |
637
+ | `scriptedQueue(steps)` | One queue for the runtime, turn by turn whatever the session, one turn at a time: `end` closes a turn, and the next plays on from the step after it. A turn that stops before its `end` (a `fail`, a cancel) skips through that `end`. A turn that finds the queue empty fails, saying the script ran out; one that starts while another plays the queue fails, saying sessions that run at once need `scriptedBySession`. |
638
+ | `scriptedFile(path, { position? })` | The same, from a JSONL file, one step per line; a bad line is refused when the file is read, by its number. It plays from its start each time an engine reads it, and writes nothing. With `position`, how far it has played is kept in that file, so an engine restarted mid-script goes on where the last stopped (stopped inside a turn, from the next turn); a changed file plays from its start, and a queue that runs out says where its position is kept. |
639
+ | `scriptedBySession(scripts, otherwise?)` | A queue per session id; any other session plays `otherwise` from its start, or fails without one. |
640
+
641
+ **The steps** are plain JSON (the type `ScriptStep`). Each is strict: a step or a field the schema does not know is
642
+ refused when the script is read, never skipped.
643
+
644
+ | Step | What it does |
645
+ | --- | --- |
646
+ | `{ say: string }` | A complete text part. |
647
+ | `{ stream: string, every?: ms }` | A text part streamed a word at a time, `every` ms apart, then its snapshot. |
648
+ | `{ tool, input?, kind?, mcp?, command?, url?, locations?, reason?, output?, error?, content?, metadata?, ask? }` | A tool call the script answers: the part opens in progress and completes with `output`, or fails with `error`. `command`, `url` and `locations` are on the part and on its request; `reason` on the request only, so it is refused without `ask`. `metadata` (a command's `exitCode`) is kept completed or failed; `content` (a `diff`) only on a completed call, as a failed one shows nothing ([What a tool call says](#what-a-tool-call-says-per-harness)). With `ask: true` the engine's permission broker is asked first, with the same call: a rejection fails the part (`The user rejected this tool call.`, then the user's words) and the turn goes on; an approval that edits the input runs the edit; a request answered as a cancel (or one that expires) ends the turn `cancelled`, the part closed `cancelled`. |
649
+ | `{ call: { server, tool, arguments? }, ask? }` | A real call to the turn's own `mcpServers[server]` (`http` only), with the official MCP SDK (`@modelcontextprotocol/sdk`, an optional peer, loaded at the first call). Its text goes into `output`, an image into `content`, the server's `structuredContent` into `metadata.structuredContent`, and `mcp` names the server and tool. A server the turn lacks, one not over `http`, or a missing SDK fails the turn; a call the server fails fails the part. Each call runs on a connection of its own, so a server that keeps state per MCP session sees a new session each call. `ask` as for `tool`; a cancelled request calls nothing. |
650
+ | `{ ask: Question[] }` | Questions to the person (`elicitation.requested`, the protocol's `ElicitationQuestion`); the outcome is said back as a text part of JSON. A turn whose client answers no questions is told so in the words Claude and Codex are told, and goes on. |
651
+ | `{ echo: "input" }` | Says the turn's input as a model reads it (`inputToText`). |
652
+ | `{ 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
+ | `{ 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. |
655
+ | `{ fail: string, category? }` | Ends the turn in an error: of `category` when given, else what the engine's classifier makes of the text. |
656
+ | `{ end: true, stopReason?, usage?, cost? }` | Ends the turn: `end_turn` and zero usage by default. |
657
+
658
+ **The stock program** plays a script too, for a product in any language or
659
+ one that spawns it: `agent-server --script turns.jsonl` registers the
660
+ scripted harness with `scriptedFile`, as its only harness unless `--harness`
661
+ names others beside `scripted`. One queue serves every session, one turn at
662
+ a time, from its start each time the program starts; `--script-position
663
+ <file>` keeps its position in that file across restarts. `--script` with a
664
+ `--harness` that does not name `scripted`, `--harness scripted` without
665
+ `--script`, `--script-position` without `--script`, and a script that cannot
666
+ be read (`--script: <why>`) are refused at start, in one line.
667
+
668
+ **As a harness.** Its native session id is `scripted-<sessionId>`, or the
669
+ turn's `resumeSessionId`, reported as resumed; any id resumes, since a script
670
+ keeps no conversation. It declares multi-turn, resume, MCP servers and
671
+ permission requests, and no steering, sub-agents or thinking levels; the
672
+ settings it never applies are its `ignoredSettings` (the table above).
673
+ `models/list` answers one model, `scripted`; `auth/status` answers
674
+ `signed_in` with no methods, since it runs on nothing; `clis/list` answers
675
+ `unmanaged`. It runs no process and takes no credential, so a durable
676
+ server's restart that cuts one of its turns off fences nothing: the turn ends
677
+ `server_restart` and the next names its conversation (`resumeRequired`), as
678
+ for Claude or Codex once the restart saw them stopped.
679
+
680
+ **Not in it:** Claude's or Codex's tool names and consent rules (a call asks
681
+ only when the script says `ask`, whatever the permission mode), sub-agents,
682
+ steering, pending tools and input deltas, reasoning. The engine's own tests
683
+ keep a richer fixture for those (`test/server/fixtures.ts`).
684
+
685
+ ## ACP v1, as each side speaks it
686
+
687
+ The engine speaks ACP v1 (`@agentclientprotocol/sdk` 1.7.0) as a client,
688
+ the `acp` harness, and as an agent, `agent-server --acp`. What each side
689
+ does with each method and capability, and which test holds it. The
690
+ loopback test (`test/server/acp-loopback.test.ts`) runs the harness in
691
+ front of the binding over the scripted harness, so it holds both sides at
692
+ once. Unstable methods (`session/list`, `session/fork`, `session/delete`,
693
+ `providers/*`, `nes/*`, `mcp/message`) are used by neither.
694
+
695
+ | Method or capability | Client (`acp` harness) | Agent (`--acp`) | Held by |
696
+ | --- | --- | --- | --- |
697
+ | `initialize` | protocol 1; `clientInfo` (`agent-server`, the stock program's release); advertises form and URL elicitation, no `fs`, no `terminal` | answers protocol 1; images; MCP transports per harness; `resume` and `close`; no `loadSession`; no auth methods | loopback, `acp-session-config`, `bin.test` |
698
+ | `authenticate`, `authMethods` | never called: an agent signs in on its own, and a turn fails with its words | none offered | — |
699
+ | `session/new` | the turn's folder, MCP servers, extra directories when advertised | a session, its modes | loopback |
700
+ | `session/resume` | when advertised | from memory, else the session record | loopback (a new engine), `acp-session-config` |
701
+ | `session/load` | when no resume (the replay is dropped) | not offered | `acp-session-config` |
702
+ | `session/close` | not sent: the agent's process is ended | ends the session's turn and process | `acp-close-during-turn`, loopback (process table) |
703
+ | `session/prompt`, `session/cancel` | yes; a cancel confirmed when the prompt ends within 2 s | yes | loopback, `acp-cancel` |
704
+ | `session/set_mode` | the turn's permission mode, by the agent's own id | `default`, `accept_edits`, `plan` and the operator's own | loopback, `acp-session-config`, `acp-binding-modes` |
705
+ | `session/set_config_option` | `model` and `thought_level` | none offered: the operator's `--model`, `--thinking` | `acp-session-config`, `bin.test` |
706
+ | `session/request_permission` | to the engine's broker (an option id back; edited input denies) | from the broker: `name`, `kind`, `locations`, `rawInput`; no `content` | loopback |
707
+ | `elicitation/create` | to the broker, form and URL | questions as one form; MCP forms and URLs as they are | loopback, `acp-elicitation` |
708
+ | `elicitation/complete` | ignored | not sent | — |
709
+ | `fs/*`, `terminal/*` | not advertised, not served | never asked: each harness's agent uses its own | — |
710
+ | Updates: message and thought chunks, `tool_call`, `tool_call_update`, `usage_update`, `current_mode_update` | to parts and events | from them (sub-agent parts dropped) | loopback, `acp-agent`, `acp-binding` |
711
+ | Updates: `plan`, `available_commands_update`, `session_info_update`, `user_message_chunk` | dropped (`includeRaw` keeps them) | not sent | — |
712
+ | Content: text, image | sent; image when advertised | taken | loopback |
713
+ | Content: `resource_link` | for a file by URL | as a Markdown link in the text | loopback |
714
+ | Content: `resource` (embedded) | a file's data, when advertised | not advertised; dropped | `acp-agent` |
715
+ | Content: audio | never sent | not advertised; dropped | — |
716
+ | Tool content: `diff`, `terminal` | kept on the part | `diff` sent; `terminal` not | loopback, `acp-drawable` |
717
+
345
718
  ## Known limitations (roadmap)
346
719
 
347
720
  - **Work after a turn:** a turn is the unit the stream shows, so the agent