@1agents/acp-service 0.10.11 → 0.11.0

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 (126) hide show
  1. package/README.md +26 -0
  2. package/dist/bin/acp-service.js +6 -0
  3. package/dist/bin/dsh.d.ts +21 -0
  4. package/dist/bin/dsh.js +171 -0
  5. package/dist/src/catalog.js +13 -3
  6. package/dist/src/dsh-archive.d.ts +123 -0
  7. package/dist/src/dsh-archive.js +99 -0
  8. package/dist/src/dsh-host-client.d.ts +97 -0
  9. package/dist/src/dsh-host-client.js +275 -0
  10. package/dist/src/dsh-registry-file.d.ts +22 -0
  11. package/dist/src/dsh-registry-file.js +55 -0
  12. package/dist/src/dsh-session-files.d.ts +7 -0
  13. package/dist/src/dsh-session-files.js +63 -0
  14. package/dist/src/dsh.js +1 -1
  15. package/package.json +4 -4
  16. package/skills/acp-service/SKILL.md +1 -1
  17. package/vendor/dsh/README.md +1 -20
  18. package/vendor/dsh/index.d.ts +1 -4
  19. package/vendor/dsh/index.js +0 -17
  20. package/vendor/runtime/README.md +36 -11
  21. package/vendor/runtime/dist/{agent-registry-DxcyXXqb.js → agent-registry-CsdsVpJb.js} +209 -177
  22. package/vendor/runtime/dist/agent-registry-CsdsVpJb.js.map +1 -0
  23. package/vendor/runtime/dist/agent-registry.d.ts +0 -2
  24. package/vendor/runtime/dist/agent-registry.d.ts.map +1 -1
  25. package/vendor/runtime/dist/agent-registry.js +1 -1
  26. package/vendor/runtime/dist/{cli-BKmMxgix.js → cli-B5gQOSDl.js} +33 -14
  27. package/vendor/runtime/dist/cli-B5gQOSDl.js.map +1 -0
  28. package/vendor/runtime/dist/cli.d.ts +2 -6
  29. package/vendor/runtime/dist/cli.d.ts.map +1 -1
  30. package/vendor/runtime/dist/cli.js +189 -164
  31. package/vendor/runtime/dist/cli.js.map +1 -1
  32. package/vendor/runtime/dist/{client-C5zneoBs.d.ts → client-D5y4RXME.d.ts} +4 -12
  33. package/vendor/runtime/dist/client-D5y4RXME.d.ts.map +1 -0
  34. package/vendor/runtime/dist/docs-site/CLI.html +19 -21
  35. package/vendor/runtime/dist/docs-site/VISION.html +3 -2
  36. package/vendor/runtime/dist/docs-site/agents.html +10 -15
  37. package/vendor/runtime/dist/docs-site/assets/agents/Apache-2.0.txt +202 -0
  38. package/vendor/runtime/dist/docs-site/assets/agents/LobeHub-MIT.txt +21 -0
  39. package/vendor/runtime/dist/docs-site/assets/agents/Mux-AGPL-3.0.txt +661 -0
  40. package/vendor/runtime/dist/docs-site/assets/agents/README.md +41 -0
  41. package/vendor/runtime/dist/docs-site/assets/agents/ante.png +0 -0
  42. package/vendor/runtime/dist/docs-site/assets/agents/antigravity.png +0 -0
  43. package/vendor/runtime/dist/docs-site/assets/agents/claude.png +0 -0
  44. package/vendor/runtime/dist/docs-site/assets/agents/codex.png +0 -0
  45. package/vendor/runtime/dist/docs-site/assets/agents/copilot.png +0 -0
  46. package/vendor/runtime/dist/docs-site/assets/agents/cursor.png +0 -0
  47. package/vendor/runtime/dist/docs-site/assets/agents/deepseek-harness.png +0 -0
  48. package/vendor/runtime/dist/docs-site/assets/agents/devin.png +0 -0
  49. package/vendor/runtime/dist/docs-site/assets/agents/droid.png +0 -0
  50. package/vendor/runtime/dist/docs-site/assets/agents/fast-agent.png +0 -0
  51. package/vendor/runtime/dist/docs-site/assets/agents/fx.png +0 -0
  52. package/vendor/runtime/dist/docs-site/assets/agents/gemini.png +0 -0
  53. package/vendor/runtime/dist/docs-site/assets/agents/goose.png +0 -0
  54. package/vendor/runtime/dist/docs-site/assets/agents/grok-build.png +0 -0
  55. package/vendor/runtime/dist/docs-site/assets/agents/iflow.png +0 -0
  56. package/vendor/runtime/dist/docs-site/assets/agents/junie.png +0 -0
  57. package/vendor/runtime/dist/docs-site/assets/agents/kilocode.png +0 -0
  58. package/vendor/runtime/dist/docs-site/assets/agents/kimi.png +0 -0
  59. package/vendor/runtime/dist/docs-site/assets/agents/kiro.png +0 -0
  60. package/vendor/runtime/dist/docs-site/assets/agents/mcode.png +0 -0
  61. package/vendor/runtime/dist/docs-site/assets/agents/mux.png +0 -0
  62. package/vendor/runtime/dist/docs-site/assets/agents/octomind.png +0 -0
  63. package/vendor/runtime/dist/docs-site/assets/agents/openclaw.png +0 -0
  64. package/vendor/runtime/dist/docs-site/assets/agents/opencode.png +0 -0
  65. package/vendor/runtime/dist/docs-site/assets/agents/pi.png +0 -0
  66. package/vendor/runtime/dist/docs-site/assets/agents/pool.png +0 -0
  67. package/vendor/runtime/dist/docs-site/assets/agents/qoder.png +0 -0
  68. package/vendor/runtime/dist/docs-site/assets/agents/qwen.png +0 -0
  69. package/vendor/runtime/dist/docs-site/assets/agents/trae.png +0 -0
  70. package/vendor/runtime/dist/docs-site/assets/agents/zeroclaw.png +0 -0
  71. package/vendor/runtime/dist/docs-site/compare.html +8 -7
  72. package/vendor/runtime/dist/docs-site/config.html +5 -4
  73. package/vendor/runtime/dist/docs-site/custom-agents.html +13 -13
  74. package/vendor/runtime/dist/docs-site/exit-codes.html +4 -3
  75. package/vendor/runtime/dist/docs-site/flows.html +21 -8
  76. package/vendor/runtime/dist/docs-site/index.html +7 -6
  77. package/vendor/runtime/dist/docs-site/install.html +7 -6
  78. package/vendor/runtime/dist/docs-site/llms.txt +6 -6
  79. package/vendor/runtime/dist/docs-site/output-formats.html +9 -8
  80. package/vendor/runtime/dist/docs-site/permissions.html +5 -4
  81. package/vendor/runtime/dist/docs-site/prompting.html +9 -7
  82. package/vendor/runtime/dist/docs-site/quickstart.html +5 -4
  83. package/vendor/runtime/dist/docs-site/releasing.html +9 -8
  84. package/vendor/runtime/dist/docs-site/runtime-environment.html +28 -5
  85. package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +13 -7
  86. package/vendor/runtime/dist/docs-site/safe-errors.html +3 -2
  87. package/vendor/runtime/dist/docs-site/session-control.html +7 -6
  88. package/vendor/runtime/dist/docs-site/session-watch.html +6 -5
  89. package/vendor/runtime/dist/docs-site/sessions.html +13 -10
  90. package/vendor/runtime/dist/docs-site/shared-sessions.html +7 -4
  91. package/vendor/runtime/dist/{flows-VrII9VKZ.js → flows-CDj5YcTh.js} +136 -68
  92. package/vendor/runtime/dist/flows-CDj5YcTh.js.map +1 -0
  93. package/vendor/runtime/dist/flows.d.ts +28 -19
  94. package/vendor/runtime/dist/flows.d.ts.map +1 -1
  95. package/vendor/runtime/dist/flows.js +1 -1
  96. package/vendor/runtime/dist/{invocation-options-DHMZ5Rrb.js → input-file-BsfVGZgn.js} +30 -15
  97. package/vendor/runtime/dist/input-file-BsfVGZgn.js.map +1 -0
  98. package/vendor/runtime/dist/{ipc-CNNM5DP_.js → ipc-DfqJsbk6.js} +114 -146
  99. package/vendor/runtime/dist/ipc-DfqJsbk6.js.map +1 -0
  100. package/vendor/runtime/dist/{output-DtzXtiBc.js → output-DOIF4iFc.js} +20 -47
  101. package/vendor/runtime/dist/output-DOIF4iFc.js.map +1 -0
  102. package/vendor/runtime/dist/{queue-owner-runtime-ehuh3SQU.js → queue-owner-runtime-DHBQbjXo.js} +394 -258
  103. package/vendor/runtime/dist/queue-owner-runtime-DHBQbjXo.js.map +1 -0
  104. package/vendor/runtime/dist/runtime.d.ts +37 -36
  105. package/vendor/runtime/dist/runtime.d.ts.map +1 -1
  106. package/vendor/runtime/dist/runtime.js +117 -172
  107. package/vendor/runtime/dist/runtime.js.map +1 -1
  108. package/vendor/runtime/dist/{session-options-NjpFwf-c.d.ts → session-options-Ci4aw1oD.d.ts} +13 -16
  109. package/vendor/runtime/dist/session-options-Ci4aw1oD.d.ts.map +1 -0
  110. package/vendor/runtime/dist/{session-watch-CbKfGRkZ.js → session-watch-DRwFHcWw.js} +5 -6
  111. package/vendor/runtime/dist/{session-watch-CbKfGRkZ.js.map → session-watch-DRwFHcWw.js.map} +1 -1
  112. package/vendor/runtime/dist/{watch-BGt4kcE6.js → watch-CUDGkljG.js} +3 -4
  113. package/vendor/runtime/dist/{watch-BGt4kcE6.js.map → watch-CUDGkljG.js.map} +1 -1
  114. package/vendor/runtime/package.json +3 -3
  115. package/vendor/runtime/skills/acpx/SKILL.md +42 -11
  116. package/vendor/dsh/auto-archive.d.ts +0 -103
  117. package/vendor/dsh/auto-archive.js +0 -175
  118. package/vendor/runtime/dist/agent-registry-DxcyXXqb.js.map +0 -1
  119. package/vendor/runtime/dist/cli-BKmMxgix.js.map +0 -1
  120. package/vendor/runtime/dist/client-C5zneoBs.d.ts.map +0 -1
  121. package/vendor/runtime/dist/flows-VrII9VKZ.js.map +0 -1
  122. package/vendor/runtime/dist/invocation-options-DHMZ5Rrb.js.map +0 -1
  123. package/vendor/runtime/dist/ipc-CNNM5DP_.js.map +0 -1
  124. package/vendor/runtime/dist/output-DtzXtiBc.js.map +0 -1
  125. package/vendor/runtime/dist/queue-owner-runtime-ehuh3SQU.js.map +0 -1
  126. package/vendor/runtime/dist/session-options-NjpFwf-c.d.ts.map +0 -1
@@ -170,7 +170,8 @@ body:not(.home) .doc>h1:first-child{display:none}
170
170
  .doc pre .copy.copied{background:var(--accent);border-color:var(--accent);color:#04121d;opacity:1}
171
171
  .doc blockquote{margin:1.4em 0;padding:10px 16px;border-left:3px solid var(--accent);background:var(--accent-soft);border-radius:0 8px 8px 0;color:var(--text)}
172
172
  .doc blockquote p:last-child{margin-bottom:0}
173
- .doc table{width:100%;border-collapse:collapse;margin:1.2em 0;font-size:.92em}
173
+ .doc .table-scroll{overflow-x:auto;margin:1.2em 0}
174
+ .doc table{width:100%;border-collapse:collapse;margin:0;font-size:.92em}
174
175
  .doc th,.doc td{border-bottom:1px solid var(--line);padding:9px 10px;text-align:left;vertical-align:top}
175
176
  .doc th{font-weight:600;color:var(--ink);background:var(--line-soft);border-bottom:1px solid var(--line)}
176
177
  .doc hr{border:0;border-top:1px solid var(--line);margin:2.2em 0}
@@ -236,12 +237,12 @@ body:not(.home) .doc>h1:first-child{display:none}
236
237
  </button>
237
238
  </div>
238
239
  <label class="search"><span>Search</span><input id="doc-search" type="search" placeholder="sessions, flows, json…"></label>
239
- <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a></section><section><h2>Sessions</h2><a class="nav-link" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link" href="session-control.html">Session control</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
+ <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a><a class="nav-link" href="compare.html">Compare Command</a></section><section><h2>Sessions</h2><a class="nav-link" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link" href="session-control.html">Session control</a><a class="nav-link" href="session-watch.html">Watching sessions</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Embedding</h2><a class="nav-link" href="shared-sessions.html">Shared sessions</a><a class="nav-link active" href="runtime-environment.html">Transient runtime environment</a><a class="nav-link" href="runtime-process-lifecycle.html">Runtime process lifecycle</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
241
  </aside>
241
242
  <main>
242
243
  <header class="hero">
243
244
  <div class="hero-text">
244
- <p class="eyebrow">Reference</p>
245
+ <p class="eyebrow">Embedding</p>
245
246
  <h1>Transient runtime environment</h1>
246
247
  </div>
247
248
  <div class="hero-meta">
@@ -255,15 +256,37 @@ body:not(.home) .doc>h1:first-child{display:none}
255
256
  <p>Precedence is protected authentication values, then <code>agentProcessEnv</code>, then persisted <code>sessionOptions.env</code>, then the inherited process environment. Windows uses the same case-insensitive collision handling as session environment values. The overlay does not change the parent process environment.</p>
256
257
  <p>Per-session <code>SessionAgentOptions.env</code> is saved for reconnects. Its own string keys and values are preserved exactly, including names such as <code>__proto__</code>.</p>
257
258
  <p>This is trusted embedding-host configuration: executable, loader and other process settings can change what the child runs. ACPX does not sanitize arbitrary environment variables. Existing credential protection remains in effect. Invalid environment entries are rejected without echoing their values.</p>
259
+ <h2 id="limiting-inherited-variables"><a class="anchor" href="#limiting-inherited-variables" aria-label="Anchor link">#</a>Limiting inherited variables</h2>
260
+ <p>By default, agent children, command probes and ACP terminals inherit the whole parent environment. Two opt-in lists narrow that inheritance. Both are off by default; with neither set, the child environment is exactly what it was before these options existed.</p>
261
+ <ul>
262
+ <li><code>AcpRuntimeOptions.agentProcessEnvBlock</code> lists parent names children do not</li>
263
+ <p>inherit, for example a host&#39;s own service token.</p>
264
+ <li><code>AcpRuntimeOptions.agentProcessEnvAllow</code> switches to an allowlist: children</li>
265
+ <p>inherit only process essentials plus the listed parent names. An empty list keeps only the essentials and explicit grants.</p>
266
+ </ul>
267
+ <p>The essentials keep processes able to start and find their tools: <code>PATH</code>, <code>HOME</code>, <code>USER</code>, <code>LOGNAME</code>, <code>SHELL</code>, <code>LANG</code>, <code>LANGUAGE</code>, <code>TZ</code>, <code>TMPDIR</code>, <code>TMP</code>, <code>TEMP</code>, and every <code>LC_*</code> and <code>XDG_*</code> name. On Windows they also include <code>SystemRoot</code>, <code>windir</code>, <code>SystemDrive</code>, <code>ComSpec</code>, <code>PATHEXT</code>, <code>USERPROFILE</code>, <code>HOMEDRIVE</code>, <code>HOMEPATH</code>, <code>USERNAME</code>, <code>USERDOMAIN</code>, <code>APPDATA</code>, <code>LOCALAPPDATA</code>, <code>ProgramData</code>, <code>ALLUSERSPROFILE</code>, and the <code>ProgramFiles</code> and <code>CommonProgramFiles</code> directories.</p>
268
+ <p>ACPX applies the allowlist first, then removes blocked names from the result, so a name on both lists is not inherited. Explicit grants apply last and always win: <code>ACPX_AUTH_&lt;NAME&gt;</code> variables pass through both lists, and protected authentication values, <code>agentProcessEnv</code>, persisted <code>sessionOptions.env</code> and a terminal request&#39;s own <code>env</code> still apply. When ACPX picks an environment credential for ACP authentication, it skips agent-specific variables such as Grok Build&#39;s <code>XAI_API_KEY</code> that children would not inherit, even when the host environment has them. To keep such a credential, list it in the allowlist and leave it off the blocklist, or pass it as an <code>ACPX_AUTH_&lt;METHOD_ID&gt;</code> grant such as <code>ACPX_AUTH_XAI_API_KEY</code>. Provider keys that an agent reads from its own environment follow the same lists: allow them by name or supply them through <code>agentProcessEnv</code>.</p>
269
+ <p>ACPX snapshots both lists at construction and rejects a list that is not an array of non-empty names without <code>=</code> or NUL. Windows matches names case-insensitively. The parent process environment is not changed.</p>
270
+ <h2 id="persistence"><a class="anchor" href="#persistence" aria-label="Anchor link">#</a>Persistence</h2>
258
271
  <p>ACPX does not copy the overlay into session records, events, status or diagnostics. An adapter can still echo its own environment into output; this option cannot prevent that. A new runtime must supply its own overlay, and a previously saved session environment retains its existing persistence behavior.</p>
272
+ <h2 id="example"><a class="anchor" href="#example" aria-label="Anchor link">#</a>Example</h2>
259
273
  <pre><code class="language-ts"><span class="hl-kw">const</span> runtime = createAcpRuntime({
260
274
  cwd,
261
275
  sessionStore,
262
276
  agentRegistry,
263
277
  permissionMode: <span class="hl-str">&quot;approve-reads&quot;</span>,
264
278
  agentProcessEnv: { <span class="hl-typ">ADAPTER_EXECUTABLE</span>: <span class="hl-str">&quot;/opt/agent/bin/agent&quot;</span> },
265
- });</code></pre></article>
266
-
279
+ agentProcessEnvBlock: [<span class="hl-str">&quot;HOST_SERVICE_TOKEN&quot;</span>],
280
+ });</code></pre>
281
+ <p>An allowlist instead of a blocklist:</p>
282
+ <pre><code class="language-ts"><span class="hl-kw">const</span> runtime = createAcpRuntime({
283
+ cwd,
284
+ sessionStore,
285
+ agentRegistry,
286
+ permissionMode: <span class="hl-str">&quot;approve-reads&quot;</span>,
287
+ agentProcessEnvAllow: [<span class="hl-str">&quot;ANTHROPIC_API_KEY&quot;</span>, <span class="hl-str">&quot;NODE_EXTRA_CA_CERTS&quot;</span>],
288
+ });</code></pre><nav class="page-nav" aria-label="Pager"><a class="page-nav-prev" href="shared-sessions.html"><small>Previous</small><span>Shared sessions</span></a><a class="page-nav-next" href="runtime-process-lifecycle.html"><small>Next</small><span>Runtime process lifecycle</span></a></nav></article>
289
+ <nav class="toc" aria-label="On this page"><h2>On this page</h2><a class="toc-l2" href="#limiting-inherited-variables">#Limiting inherited variables</a><a class="toc-l2" href="#persistence">#Persistence</a><a class="toc-l2" href="#example">#Example</a></nav>
267
290
  </div>
268
291
  </main>
269
292
  </div>
@@ -170,7 +170,8 @@ body:not(.home) .doc>h1:first-child{display:none}
170
170
  .doc pre .copy.copied{background:var(--accent);border-color:var(--accent);color:#04121d;opacity:1}
171
171
  .doc blockquote{margin:1.4em 0;padding:10px 16px;border-left:3px solid var(--accent);background:var(--accent-soft);border-radius:0 8px 8px 0;color:var(--text)}
172
172
  .doc blockquote p:last-child{margin-bottom:0}
173
- .doc table{width:100%;border-collapse:collapse;margin:1.2em 0;font-size:.92em}
173
+ .doc .table-scroll{overflow-x:auto;margin:1.2em 0}
174
+ .doc table{width:100%;border-collapse:collapse;margin:0;font-size:.92em}
174
175
  .doc th,.doc td{border-bottom:1px solid var(--line);padding:9px 10px;text-align:left;vertical-align:top}
175
176
  .doc th{font-weight:600;color:var(--ink);background:var(--line-soft);border-bottom:1px solid var(--line)}
176
177
  .doc hr{border:0;border-top:1px solid var(--line);margin:2.2em 0}
@@ -236,12 +237,12 @@ body:not(.home) .doc>h1:first-child{display:none}
236
237
  </button>
237
238
  </div>
238
239
  <label class="search"><span>Search</span><input id="doc-search" type="search" placeholder="sessions, flows, json…"></label>
239
- <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a></section><section><h2>Sessions</h2><a class="nav-link" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link" href="session-control.html">Session control</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
+ <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a><a class="nav-link" href="compare.html">Compare Command</a></section><section><h2>Sessions</h2><a class="nav-link" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link" href="session-control.html">Session control</a><a class="nav-link" href="session-watch.html">Watching sessions</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Embedding</h2><a class="nav-link" href="shared-sessions.html">Shared sessions</a><a class="nav-link" href="runtime-environment.html">Transient runtime environment</a><a class="nav-link active" href="runtime-process-lifecycle.html">Runtime process lifecycle</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
241
  </aside>
241
242
  <main>
242
243
  <header class="hero">
243
244
  <div class="hero-text">
244
- <p class="eyebrow">Reference</p>
245
+ <p class="eyebrow">Embedding</p>
245
246
  <h1>Runtime process lifecycle</h1>
246
247
  </div>
247
248
  <div class="hero-meta">
@@ -256,7 +257,8 @@ body:not(.home) .doc>h1:first-child{display:none}
256
257
  <p>Compatibility commands retain their execution deadline after spawning. Their owned cleanup can extend settlement beyond that deadline; host admission waits remain under host control. Probe completion does not settle a pending host admission callback or permit a later launch after the client has closed.</p>
257
258
  <p><code>onBeforeSpawn</code> and <code>onSpawned</code> are awaited admission boundaries. Rejecting before spawn prevents launch. Rejecting after spawn terminates the child before startup returns that error. An exit during admission is delivered after the admission callback settles, so a late successful write cannot overwrite an earlier exit observation.</p>
258
259
  <p><code>onSpawnFailed</code> also reports admission rejection and cancellation before spawn, including authority revoked after <code>onBeforeSpawn</code> successfully reserved capacity. The observation retains the original error so hosts can release a reservation even when no child PID was created. A client closed during held compatibility probe admission reports the same failure without launching that probe.</p>
259
- <p>For embedded runtime session creation, a positive <code>timeoutMs</code> bounds ACP initialization. If the agent never completes the handshake, <code>ensureSession()</code> rejects with <code>ACP_SESSION_INIT_FAILED</code> after closing the client and cleaning up its observed processes. Cleanup can extend beyond the initialization deadline. Omitting the timeout preserves unlimited initialization. This deadline does not bound the later <code>session/new</code> or <code>session/load</code> request.</p>
260
+ <p>For embedded runtime session creation, a positive <code>timeoutMs</code> separately bounds ACP initialization and the following <code>session/new</code>, <code>session/load</code> or <code>session/resume</code> request. Each phase receives the full timeout; time spent initializing does not consume the session request&#39;s budget. If either phase stalls, <code>ensureSession()</code> rejects with <code>ACP_SESSION_INIT_FAILED</code> after closing the client and cleaning up its observed processes. The error identifies the stalled phase. Cleanup can extend beyond the deadline. Omitting the timeout or setting it to zero preserves unlimited setup. A failed explicit resume does not create a replacement session.</p>
261
+ <p>Runtime construction rejects finite default <code>timeoutMs</code> values above 2,147,483,647 with <code>ACP_INVALID_RUNTIME_OPTION</code>, before session or agent work. The same bound applies to per-turn overrides: <code>startTurn()</code> throws synchronously, and <code>runTurn()</code> rejects when iteration starts, before prompt dispatch. Each turn uses the timeout value read at admission. The bound applies to raw milliseconds, including fractional overflow; supported values and existing omitted or zero behavior remain unchanged. An omitted override continues to inherit the runtime default.</p>
260
262
  <p>The host owns admission timeouts, cancellation and recovery. A callback that never settles can hold startup indefinitely; <code>close()</code> is not an admission-cancellation mechanism. Hosts should bound their own storage or policy operations and settle or reject admission when abandoning a launch.</p>
261
263
  <p>If a launch finishes admission after the client was closed, acpx stops that child without adopting it or disturbing a replacement connection. The admitted child still produces spawn and exit observations.</p>
262
264
  <p><code>onSpawnFailed</code> and <code>onExit</code> are best-effort observations. They are not awaited, and their failures do not replace the process outcome. They do not guarantee that an asynchronous host write is durable when an ACPX operation returns.</p>
@@ -266,11 +268,15 @@ body:not(.home) .doc>h1:first-child{display:none}
266
268
  <p>On Windows, snapshots use Windows PowerShell and <code>Win32_Process</code> creation times. Processes whose parent PID was reused after their creation are not adopted. Closing stdin remains the graceful step; Node terminates Windows processes forcefully for both <code>SIGTERM</code> and <code>SIGKILL</code>.</p>
267
269
  <p>Bridge and descendant teardown has an eight-second budget. POSIX queue-owner recovery allows twelve seconds before forcibly stopping the owner, leaving room for that cleanup and cancellation. These budgets exclude host admission callbacks and separately managed terminals.</p>
268
270
  <p>This is best-effort cleanup with OS identity precision and process-query races. Linux exit cutoffs have centisecond precision plus the kernel start-tick resolution; macOS birth timestamps have one-second precision. A descendant can escape observation if it starts after the last snapshot and every witnessed ancestor exits before the next one. Unavailable OS process information leaves unverified descendants untouched. Abrupt acpx death still requires separate host supervision.</p>
271
+ <h2 id="observe-session-protocol-messages"><a class="anchor" href="#observe-session-protocol-messages" aria-label="Anchor link">#</a>Observe session protocol messages</h2>
272
+ <p>In-process runtimes can set <code>AcpRuntimeOptions.onAcpMessage</code> to observe inbound and outbound ACP messages on their owned session clients. The observer is installed before initialization and remains available during session setup, prompts, idle updates, reconnects, cold controls, and session discard. Health probes use separate clients and do not invoke it. Shared runtimes reject this option because their connection belongs to another process.</p>
273
+ <p>Observations are best-effort: callback failures are ignored and asynchronous work is not awaited. Synchronous callback work runs on the protocol processing path and can delay it; move slow processing off that path. Treat messages as read-only. Outbound callbacks run before the transport write, so they do not prove delivery or agent acceptance. The callback is runtime-wide and has no separate session context; hosts must use the session identity present in protocol messages when available, and cannot assume every message has one.</p>
274
+ <p>The existing client filters still apply: elicitation requests and their responses are omitted, as are session updates suppressed during history replay. Other messages can contain prompts, tool input and private data. The callback does not persist anything; the embedding host owns redaction, access and retention.</p>
269
275
  <h2 id="inspect-models-without-a-runtime-store"><a class="anchor" href="#inspect-models-without-a-runtime-store" aria-label="Anchor link">#</a>Inspect models without a runtime store</h2>
270
276
  <p><code>inspectAgentModels()</code> from <code>acpx/runtime</code> launches an explicit <code>agentCommand</code> argv in <code>cwd</code>, initializes ACP, creates a session, and returns normalized <code>AcpRuntimeSessionModels</code>, or <code>undefined</code> when no model metadata is advertised. It does not send a prompt, require a session store, or save an ACPX session record. The agent may still create its own native session history.</p>
271
- <p>Inspection denies permission requests and disables ACP filesystem and terminal capabilities. Runtime health probes disable their ACP filesystem and terminal callbacks while retaining the host permission policy; they ignore host <code>fs</code>/<code>terminal</code> options. Disabling those ACP callbacks is a protocol callback policy, not an OS sandbox for the agent&#39;s own filesystem or process access. Inspection inherits the process environment, with an optional trusted <code>agentProcessEnv</code> overlay; it does not isolate the agent process itself.</p>
272
- <p>Pass an optional <code>signal</code> to cancel. <code>timeoutMs</code> is a positive discovery deadline of at most 2,147,483,647 milliseconds and defaults to 120 seconds. Success, failure, cancellation, and timeout all wait for owned client cleanup. Cleanup can extend beyond the discovery deadline. A pre-aborted call does not launch the agent.</p></article>
273
-
277
+ <p>Inspection denies permission requests and disables ACP filesystem and terminal capabilities. Runtime health probes disable their ACP filesystem and terminal callbacks while retaining the host permission policy; they ignore host <code>fs</code>/<code>terminal</code> options. Disabling those ACP callbacks is a protocol callback policy, not an OS sandbox for the agent&#39;s own filesystem or process access. Inspection inherits the process environment, with an optional trusted <code>agentProcessEnv</code> overlay and the optional <code>agentProcessEnvAllow</code> and <code>agentProcessEnvBlock</code> inheritance lists described in <a href="runtime-environment.html">runtime-environment.md</a>; it does not isolate the agent process itself.</p>
278
+ <p>Pass an optional <code>signal</code> to cancel. <code>timeoutMs</code> is a positive discovery deadline of at most 2,147,483,647 milliseconds and defaults to 120 seconds. Success, failure, cancellation, and timeout all wait for owned client cleanup. Cleanup can extend beyond the discovery deadline. A pre-aborted call does not launch the agent.</p><nav class="page-nav" aria-label="Pager"><a class="page-nav-prev" href="runtime-environment.html"><small>Previous</small><span>Transient runtime environment</span></a><a class="page-nav-next" href="CLI.html"><small>Next</small><span>acpx CLI Reference</span></a></nav></article>
279
+ <nav class="toc" aria-label="On this page"><h2>On this page</h2><a class="toc-l2" href="#observe-session-protocol-messages">#Observe session protocol messages</a><a class="toc-l2" href="#inspect-models-without-a-runtime-store">#Inspect models without a runtime store</a></nav>
274
280
  </div>
275
281
  </main>
276
282
  </div>
@@ -170,7 +170,8 @@ body:not(.home) .doc>h1:first-child{display:none}
170
170
  .doc pre .copy.copied{background:var(--accent);border-color:var(--accent);color:#04121d;opacity:1}
171
171
  .doc blockquote{margin:1.4em 0;padding:10px 16px;border-left:3px solid var(--accent);background:var(--accent-soft);border-radius:0 8px 8px 0;color:var(--text)}
172
172
  .doc blockquote p:last-child{margin-bottom:0}
173
- .doc table{width:100%;border-collapse:collapse;margin:1.2em 0;font-size:.92em}
173
+ .doc .table-scroll{overflow-x:auto;margin:1.2em 0}
174
+ .doc table{width:100%;border-collapse:collapse;margin:0;font-size:.92em}
174
175
  .doc th,.doc td{border-bottom:1px solid var(--line);padding:9px 10px;text-align:left;vertical-align:top}
175
176
  .doc th{font-weight:600;color:var(--ink);background:var(--line-soft);border-bottom:1px solid var(--line)}
176
177
  .doc hr{border:0;border-top:1px solid var(--line);margin:2.2em 0}
@@ -236,7 +237,7 @@ body:not(.home) .doc>h1:first-child{display:none}
236
237
  </button>
237
238
  </div>
238
239
  <label class="search"><span>Search</span><input id="doc-search" type="search" placeholder="sessions, flows, json…"></label>
239
- <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a></section><section><h2>Sessions</h2><a class="nav-link" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link" href="session-control.html">Session control</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
+ <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a><a class="nav-link" href="compare.html">Compare Command</a></section><section><h2>Sessions</h2><a class="nav-link" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link" href="session-control.html">Session control</a><a class="nav-link" href="session-watch.html">Watching sessions</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Embedding</h2><a class="nav-link" href="shared-sessions.html">Shared sessions</a><a class="nav-link" href="runtime-environment.html">Transient runtime environment</a><a class="nav-link" href="runtime-process-lifecycle.html">Runtime process lifecycle</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
241
  </aside>
241
242
  <main>
242
243
  <header class="hero">
@@ -170,7 +170,8 @@ body:not(.home) .doc>h1:first-child{display:none}
170
170
  .doc pre .copy.copied{background:var(--accent);border-color:var(--accent);color:#04121d;opacity:1}
171
171
  .doc blockquote{margin:1.4em 0;padding:10px 16px;border-left:3px solid var(--accent);background:var(--accent-soft);border-radius:0 8px 8px 0;color:var(--text)}
172
172
  .doc blockquote p:last-child{margin-bottom:0}
173
- .doc table{width:100%;border-collapse:collapse;margin:1.2em 0;font-size:.92em}
173
+ .doc .table-scroll{overflow-x:auto;margin:1.2em 0}
174
+ .doc table{width:100%;border-collapse:collapse;margin:0;font-size:.92em}
174
175
  .doc th,.doc td{border-bottom:1px solid var(--line);padding:9px 10px;text-align:left;vertical-align:top}
175
176
  .doc th{font-weight:600;color:var(--ink);background:var(--line-soft);border-bottom:1px solid var(--line)}
176
177
  .doc hr{border:0;border-top:1px solid var(--line);margin:2.2em 0}
@@ -236,7 +237,7 @@ body:not(.home) .doc>h1:first-child{display:none}
236
237
  </button>
237
238
  </div>
238
239
  <label class="search"><span>Search</span><input id="doc-search" type="search" placeholder="sessions, flows, json…"></label>
239
- <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a></section><section><h2>Sessions</h2><a class="nav-link" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link active" href="session-control.html">Session control</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
+ <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a><a class="nav-link" href="compare.html">Compare Command</a></section><section><h2>Sessions</h2><a class="nav-link" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link active" href="session-control.html">Session control</a><a class="nav-link" href="session-watch.html">Watching sessions</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Embedding</h2><a class="nav-link" href="shared-sessions.html">Shared sessions</a><a class="nav-link" href="runtime-environment.html">Transient runtime environment</a><a class="nav-link" href="runtime-process-lifecycle.html">Runtime process lifecycle</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
241
  </aside>
241
242
  <main>
242
243
  <header class="hero">
@@ -263,14 +264,14 @@ acpx cancel <span class="hl-com"># defaults to codex</span></code><
263
264
  <li>If a native prompt is active, acpx asks the adapter to cancel it; the adapter&#39;s reply determines the final stop reason.</li>
264
265
  <li>If nothing is running, <code>acpx</code> prints <code>nothing to cancel</code> and exits success.</li>
265
266
  </ul>
266
- <p>This is the same semantics as <code>Ctrl+C</code> during a foreground turn, but available without a TTY signal — useful from scripts and other agents.</p>
267
+ <p>Foreground <code>Ctrl+C</code> cancels only the interrupted invocation&#39;s own prompt: a queued prompt is removed, an active one gets the cooperative cancellation above. Another client&#39;s turn is never cancelled and the shared owner is not killed. The command exits <code>130</code> once the cancel request settles; if the owner does not respond within a few seconds it reports that the outcome is unknown. <code>--no-wait</code> submissions and <code>sessions watch</code> only detach.</p>
267
268
  <p>Accepted cancellation stops remaining queued-turn attempts during retry backoff or before the next transport write. Cancellation during backoff records a cancelled result without sending another prompt. Completed prompt responses and non-retryable failures keep their actual outcomes, including responses received before update draining finishes. Separately queued turns remain eligible to run.</p>
268
269
  <h2 id="set-mode"><a class="anchor" href="#set-mode" aria-label="Anchor link">#</a><code>set-mode</code></h2>
269
270
  <pre><code class="language-bash">acpx codex set-mode auto
270
271
  acpx codex set-mode plan <span class="hl-flag">-s</span> backend
271
272
  acpx set-mode auto <span class="hl-com"># defaults to codex</span></code></pre>
272
273
  <p>Calls ACP <code>session/set_mode</code>. The set of valid <code>&lt;mode&gt;</code> values is <strong>adapter-defined</strong> and not standardized across ACP. Common values seen in the wild:</p>
273
- <table><thead><tr><th>Adapter</th><th>Modes</th></tr></thead><tbody><tr><td><code>codex</code></td><td>adapter-defined (see codex-acp release notes)</td></tr><tr><td><code>claude</code></td><td>adapter-defined; <code>plan</code> and <code>auto</code> are typical</td></tr><tr><td>Others</td><td>check upstream agent docs</td></tr></tbody></table>
274
+ <div class="table-scroll" role="region" aria-label="Scrollable table" tabindex="0"><table><thead><tr><th>Adapter</th><th>Modes</th></tr></thead><tbody><tr><td><code>codex</code></td><td>adapter-defined (see codex-acp release notes)</td></tr><tr><td><code>claude</code></td><td>adapter-defined; <code>plan</code> and <code>auto</code> are typical</td></tr><tr><td>Others</td><td>check upstream agent docs</td></tr></tbody></table></div>
274
275
  <p>Unsupported mode ids are rejected by the adapter, often as <code>Invalid params</code>. <code>acpx</code> surfaces that error code unchanged.</p>
275
276
  <p><code>set-mode</code> routes through the queue owner when active and falls back to a fresh client connection otherwise.</p>
276
277
  <p>When reconnect permits a fresh session, an explicit mode change replaces the saved mode without replaying that previous mode first. This lets you replace a mode the adapter no longer supports. Other saved model and config selections still restore before the requested change. The new mode is saved only after the adapter accepts it; rejection keeps the prior mode preference. Imported records always require their original native session. Persistent runtime sessions also require it, with one exception: when the load fails with an ACP internal load/resume error (-32603) and the session holds no earlier prompt, agent output, or saved resume marker, it is replaced by a fresh one. A prompt turn may hold only the prompt it just recorded; a control must hold none. The error alone does not prove the agent kept nothing.</p>
@@ -307,7 +308,7 @@ acpx claude set model claude-sonnet-<span class="hl-num">4</span>-<span class="h
307
308
  acpx codex status <span class="hl-flag">-s</span> backend
308
309
  acpx status <span class="hl-com"># defaults to codex</span></code></pre>
309
310
  <p>Reports local queue-owner health for the cwd-scoped session. A healthy warm owner may be processing a prompt or waiting for more work during its idle TTL.</p>
310
- <table><thead><tr><th>Text/quiet state</th><th>JSON <code>status</code></th><th>Meaning</th></tr></thead><tbody><tr><td><code>running</code></td><td><code>alive</code></td><td>Queue owner is healthy and its socket is reachable; this does not establish that a prompt is active.</td></tr><tr><td><code>idle</code></td><td><code>idle</code></td><td>Saved session is resumable and no queue owner is present.</td></tr><tr><td><code>dead</code></td><td><code>dead</code></td><td>A queue-owner lease remains but is unhealthy, or the recorded agent exit was abnormal.</td></tr><tr><td><code>no-session</code></td><td><code>no-session</code></td><td>No saved record matches this scope.</td></tr></tbody></table>
311
+ <div class="table-scroll" role="region" aria-label="Scrollable table" tabindex="0"><table><thead><tr><th>Text/quiet state</th><th>JSON <code>status</code></th><th>Meaning</th></tr></thead><tbody><tr><td><code>running</code></td><td><code>alive</code></td><td>Queue owner is healthy and its socket is reachable; this does not establish that a prompt is active.</td></tr><tr><td><code>idle</code></td><td><code>idle</code></td><td>Saved session is resumable and no queue owner is present.</td></tr><tr><td><code>dead</code></td><td><code>dead</code></td><td>A queue-owner lease remains but is unhealthy, or the recorded agent exit was abnormal.</td></tr><tr><td><code>no-session</code></td><td><code>no-session</code></td><td>No saved record matches this scope.</td></tr></tbody></table></div>
311
312
  <p>When available, output also includes the queue-owner PID, model, mode, uptime, and last prompt time. Dead status can include the recorded exit code or signal. The JSON result is a status summary, not a full session record; <code>no-session</code> has no local session identity.</p>
312
313
  <p>Uptime measures wall-clock time since the most recently launched agent process, rounded down to whole seconds. It can keep advancing after that process exits and resets when a replacement starts. The queue-owner PID can stay the same across this reset.</p>
313
314
  <p>Status checks use local lease, process, and socket information and do not send an ACP request to the agent. Use session watch events to observe prompt progress or settlement; owner liveness alone is not a prompt-completion signal.</p>
@@ -341,7 +342,7 @@ acpx status <span class="hl-com"># defaults to codex</span></code><
341
342
  <p>After session acquisition, <code>getStatus({ handle }).models.availableModels</code> optionally supplies <code>{ modelId, name }</code> entries with native display names. <code>availableModelIds</code> remains available. IDs are opaque; pass the selected ID unchanged to <code>setModel</code>. Older session records without name metadata may omit <code>availableModels</code> until refreshed. A missing authenticated catalog remains a setup error even when its executable is installed. Ordinary <code>close</code> releases local inspection resources; optional remote discard and deletion of native history are separate operations.</p>
342
343
  <p>Within one runtime, turns for the same session record run in submission order; different session records remain concurrent. Queued turns can be cancelled without interrupting their predecessor, and controls continue to reach the active turn.</p>
343
344
  <p><code>prepareFreshSession({ handle })</code> releases local session resources and records that the next <code>ensureSession</code> must create a fresh session, including after a runtime restart. Preparation cancels previously submitted turns for that record and waits for their finalization before recording the reset; local finalization or persistence failures reject preparation. Failed cleanup is retried before that owner can be replaced. Omit <code>resumeSessionId</code> on that ensure call. This operation does not require the optional remote <code>session/close</code> capability and does not delete native history. Ordinary <code>close</code> cancels active and queued turns while keeping the session resumable; the active turn may finish cancellation after close returns. Explicit <code>close({ handle, reason, discardPersistentState: true })</code> retains its remote-close requirement.</p>
344
- <p>For the in-process runtime, a failed launch that already saved a session record marks that record closed and requests a fresh session once its local adapter connection has been finalized. If cleanup fails, the runtime retains cleanup ownership and retries before reusing that session key; it preserves the original launch error. A failed explicit discard also marks the local record closed and requests a fresh session after local connection cleanup succeeds, while still rejecting with the backend error. This does not mean that the backend conversation or native history was deleted; retrying the discard still attempts the remote close.</p><nav class="page-nav" aria-label="Pager"><a class="page-nav-prev" href="prompting.html"><small>Previous</small><span>Prompting</span></a><a class="page-nav-next" href="output-formats.html"><small>Next</small><span>Output formats</span></a></nav></article>
345
+ <p>For the in-process runtime, a failed launch that already saved a session record marks that record closed and requests a fresh session once its local adapter connection has been finalized. If cleanup fails, the runtime retains cleanup ownership and retries before reusing that session key; it preserves the original launch error. A failed explicit discard also marks the local record closed and requests a fresh session after local connection cleanup succeeds, while still rejecting with the backend error. This does not mean that the backend conversation or native history was deleted; retrying the discard still attempts the remote close.</p><nav class="page-nav" aria-label="Pager"><a class="page-nav-prev" href="prompting.html"><small>Previous</small><span>Prompting</span></a><a class="page-nav-next" href="session-watch.html"><small>Next</small><span>Watching sessions</span></a></nav></article>
345
346
  <nav class="toc" aria-label="On this page"><h2>On this page</h2><a class="toc-l2" href="#cancel">#cancel</a><a class="toc-l2" href="#set-mode">#set-mode</a><a class="toc-l2" href="#set-key-value">#set &amp;lt;key&amp;gt; &amp;lt;value&amp;gt;</a><a class="toc-l3" href="#set-model-id">#set model &amp;lt;id&amp;gt;</a><a class="toc-l2" href="#status">#status</a><a class="toc-l3" href="#output">#Output</a><a class="toc-l2" href="#routing-rules">#Routing rules</a><a class="toc-l2" href="#see-also">#See also</a><a class="toc-l2" href="#embedded-agent-discovery">#Embedded agent discovery</a></nav>
346
347
  </div>
347
348
  </main>
@@ -170,7 +170,8 @@ body:not(.home) .doc>h1:first-child{display:none}
170
170
  .doc pre .copy.copied{background:var(--accent);border-color:var(--accent);color:#04121d;opacity:1}
171
171
  .doc blockquote{margin:1.4em 0;padding:10px 16px;border-left:3px solid var(--accent);background:var(--accent-soft);border-radius:0 8px 8px 0;color:var(--text)}
172
172
  .doc blockquote p:last-child{margin-bottom:0}
173
- .doc table{width:100%;border-collapse:collapse;margin:1.2em 0;font-size:.92em}
173
+ .doc .table-scroll{overflow-x:auto;margin:1.2em 0}
174
+ .doc table{width:100%;border-collapse:collapse;margin:0;font-size:.92em}
174
175
  .doc th,.doc td{border-bottom:1px solid var(--line);padding:9px 10px;text-align:left;vertical-align:top}
175
176
  .doc th{font-weight:600;color:var(--ink);background:var(--line-soft);border-bottom:1px solid var(--line)}
176
177
  .doc hr{border:0;border-top:1px solid var(--line);margin:2.2em 0}
@@ -236,12 +237,12 @@ body:not(.home) .doc>h1:first-child{display:none}
236
237
  </button>
237
238
  </div>
238
239
  <label class="search"><span>Search</span><input id="doc-search" type="search" placeholder="sessions, flows, json…"></label>
239
- <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a></section><section><h2>Sessions</h2><a class="nav-link" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link" href="session-control.html">Session control</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
+ <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a><a class="nav-link" href="compare.html">Compare Command</a></section><section><h2>Sessions</h2><a class="nav-link" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link" href="session-control.html">Session control</a><a class="nav-link active" href="session-watch.html">Watching sessions</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Embedding</h2><a class="nav-link" href="shared-sessions.html">Shared sessions</a><a class="nav-link" href="runtime-environment.html">Transient runtime environment</a><a class="nav-link" href="runtime-process-lifecycle.html">Runtime process lifecycle</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
241
  </aside>
241
242
  <main>
242
243
  <header class="hero">
243
244
  <div class="hero-text">
244
- <p class="eyebrow">Reference</p>
245
+ <p class="eyebrow">Sessions</p>
245
246
  <h1>Watching sessions</h1>
246
247
  </div>
247
248
  <div class="hero-meta">
@@ -277,7 +278,7 @@ body:not(.home) .doc>h1:first-child{display:none}
277
278
  <p>Breaking out of the loop, calling the iterator&#39;s <code>return()</code>, aborting its signal, or shutting down this shared client stops observation. Use the explicit cancellation methods when you want to cancel work. Custom stores used by the in-process runtime do not automatically publish this CLI/shared journal.</p>
278
279
  <h2 id="event-contract"><a class="anchor" href="#event-contract" aria-label="Anchor link">#</a>Event contract</h2>
279
280
  <p>JSON output is NDJSON with three event kinds:</p>
280
- <table><thead><tr><th>Type</th><th>Fields</th><th>Meaning</th></tr></thead><tbody><tr><td><code>message</code></td><td><code>cursor</code>, <code>requestId</code>, <code>message</code></td><td>An ACP JSON-RPC message, associated with its current prompt attempt. The request ID is null when no attempt owns that message.</td></tr><tr><td><code>turn_started</code></td><td><code>cursor</code>, <code>requestId</code></td><td>The owner has selected an attempt and is preparing or dispatching it. The turn&#39;s separate <code>promptStarted</code> promise indicates actual ACP prompt transport acceptance.</td></tr><tr><td><code>turn_result</code></td><td><code>cursor</code>, <code>requestId</code>, <code>result</code></td><td>The owner has finished normal cleanup and checkpoint attempts. The result is <code>completed</code>, <code>cancelled</code>, or <code>failed</code>.</td></tr></tbody></table>
281
+ <div class="table-scroll" role="region" aria-label="Scrollable table" tabindex="0"><table><thead><tr><th>Type</th><th>Fields</th><th>Meaning</th></tr></thead><tbody><tr><td><code>message</code></td><td><code>cursor</code>, <code>requestId</code>, <code>message</code></td><td>An ACP JSON-RPC message, associated with its current prompt attempt. The request ID is null when no attempt owns that message.</td></tr><tr><td><code>turn_started</code></td><td><code>cursor</code>, <code>requestId</code></td><td>The owner has selected an attempt and is preparing or dispatching it. The turn&#39;s separate <code>promptStarted</code> promise indicates actual ACP prompt transport acceptance.</td></tr><tr><td><code>turn_result</code></td><td><code>cursor</code>, <code>requestId</code>, <code>result</code></td><td>The owner has finished normal cleanup and checkpoint attempts. The result is <code>completed</code>, <code>cancelled</code>, or <code>failed</code>.</td></tr></tbody></table></div>
281
282
  <p><code>requestId</code> is the submitting acpx request ID; it is independent of the ACP message&#39;s own JSON-RPC <code>id</code>. Use <code>turn_result</code> for settlement. A raw ACP response containing <code>stopReason</code> can arrive before local finalization finishes.</p>
282
283
  <p>The stream covers attempts selected for execution. Requests cancelled while still queued receive their ordinary cancellation response without starting an agent attempt or transcript.</p>
283
284
  <p>Text output renders agent content and lifecycle lines with request IDs and cursors. Quiet output prints agent text. <code>--suppress-reads</code> also applies to watching; on resume, unclassified result/tool content is suppressed conservatively when its original announcement is unavailable. This flag suppresses raw read output, not text the agent independently writes about it.</p>
@@ -287,7 +288,7 @@ body:not(.home) .doc>h1:first-child{display:none}
287
288
  <p>History retention remains the existing rotating journal policy. Replay reads bounded pages, approximately 1 MiB plus one larger event. A slow observer whose unread history has been rotated away receives a cursor-expired error rather than silently skipping events.</p>
288
289
  <p>Journal reads retry when segment paths change during capture. A rejected page does not advance the reader&#39;s delivered position; stable corruption and filesystem errors still fail explicitly.</p>
289
290
  <p>Watching can replay only events recorded after watch support is enabled. Earlier history remains available through <code>sessions read</code> and export. Portable imports start a fresh watch history; historical request IDs and local results are not invented.</p>
290
- <p>The existing journal now includes local segment and lifecycle records alongside unchanged ACP messages. Direct <code>.stream.ndjson</code> consumers must distinguish these local records from entries with <code>jsonrpc: &quot;2.0&quot;</code>. Built-in history readers, prompt JSON output, and portable archives continue to expose ACP data without local journal markers. See the <a href="https://github.com/openclaw/acpx/blob/main/docs/2026-02-27-acpx-session-model.md">session model</a> for the storage contract.</p></article>
291
+ <p>The existing journal now includes local segment and lifecycle records alongside unchanged ACP messages. Direct <code>.stream.ndjson</code> consumers must distinguish these local records from entries with <code>jsonrpc: &quot;2.0&quot;</code>. Built-in history readers, prompt JSON output, and portable archives continue to expose ACP data without local journal markers. See the <a href="https://github.com/openclaw/acpx/blob/main/docs/2026-02-27-acpx-session-model.md">session model</a> for the storage contract.</p><nav class="page-nav" aria-label="Pager"><a class="page-nav-prev" href="session-control.html"><small>Previous</small><span>Session control</span></a><a class="page-nav-next" href="output-formats.html"><small>Next</small><span>Output formats</span></a></nav></article>
291
292
  <nav class="toc" aria-label="On this page"><h2>On this page</h2><a class="toc-l2" href="#shared-runtime">#Shared runtime</a><a class="toc-l2" href="#event-contract">#Event contract</a><a class="toc-l2" href="#recovery-and-retained-history">#Recovery and retained history</a></nav>
292
293
  </div>
293
294
  </main>
@@ -170,7 +170,8 @@ body:not(.home) .doc>h1:first-child{display:none}
170
170
  .doc pre .copy.copied{background:var(--accent);border-color:var(--accent);color:#04121d;opacity:1}
171
171
  .doc blockquote{margin:1.4em 0;padding:10px 16px;border-left:3px solid var(--accent);background:var(--accent-soft);border-radius:0 8px 8px 0;color:var(--text)}
172
172
  .doc blockquote p:last-child{margin-bottom:0}
173
- .doc table{width:100%;border-collapse:collapse;margin:1.2em 0;font-size:.92em}
173
+ .doc .table-scroll{overflow-x:auto;margin:1.2em 0}
174
+ .doc table{width:100%;border-collapse:collapse;margin:0;font-size:.92em}
174
175
  .doc th,.doc td{border-bottom:1px solid var(--line);padding:9px 10px;text-align:left;vertical-align:top}
175
176
  .doc th{font-weight:600;color:var(--ink);background:var(--line-soft);border-bottom:1px solid var(--line)}
176
177
  .doc hr{border:0;border-top:1px solid var(--line);margin:2.2em 0}
@@ -236,7 +237,7 @@ body:not(.home) .doc>h1:first-child{display:none}
236
237
  </button>
237
238
  </div>
238
239
  <label class="search"><span>Search</span><input id="doc-search" type="search" placeholder="sessions, flows, json…"></label>
239
- <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a></section><section><h2>Sessions</h2><a class="nav-link active" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link" href="session-control.html">Session control</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
+ <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a><a class="nav-link" href="compare.html">Compare Command</a></section><section><h2>Sessions</h2><a class="nav-link active" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link" href="session-control.html">Session control</a><a class="nav-link" href="session-watch.html">Watching sessions</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Embedding</h2><a class="nav-link" href="shared-sessions.html">Shared sessions</a><a class="nav-link" href="runtime-environment.html">Transient runtime environment</a><a class="nav-link" href="runtime-process-lifecycle.html">Runtime process lifecycle</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
241
  </aside>
241
242
  <main>
242
243
  <header class="hero">
@@ -300,7 +301,7 @@ acpx codex <span class="hl-flag">-s</span> backend <span class="hl-str">&#39;fix
300
301
  acpx codex <span class="hl-flag">-s</span> docs <span class="hl-str">&#39;rewrite the changelog&#39;</span></code></pre>
301
302
  <p>Named sessions are independent. They do not share state, queue owners, or history.</p>
302
303
  <h2 id="sessions-vs-ensure-vs-new"><a class="anchor" href="#sessions-vs-ensure-vs-new" aria-label="Anchor link">#</a>Sessions vs. ensure vs. new</h2>
303
- <table><thead><tr><th>Command</th><th>If a matching session exists</th><th>If not</th></tr></thead><tbody><tr><td><code>sessions new</code></td><td>Soft-close it, create a fresh</td><td>Create a fresh one</td></tr><tr><td><code>sessions ensure</code></td><td>Return it</td><td>Create a fresh one</td></tr><tr><td>(prompt commands)</td><td>Resume it</td><td>Exit <code>4</code> with guidance to run <code>sessions new</code></td></tr></tbody></table>
304
+ <div class="table-scroll" role="region" aria-label="Scrollable table" tabindex="0"><table><thead><tr><th>Command</th><th>If a matching session exists</th><th>If not</th></tr></thead><tbody><tr><td><code>sessions new</code></td><td>Soft-close it, create a fresh</td><td>Create a fresh one</td></tr><tr><td><code>sessions ensure</code></td><td>Return it</td><td>Create a fresh one</td></tr><tr><td>(prompt commands)</td><td>Resume it</td><td>Exit <code>4</code> with guidance to run <code>sessions new</code></td></tr></tbody></table></div>
304
305
  <p><code>new</code> is the explicit &quot;I want to start over&quot; verb. <code>ensure</code> is the idempotent &quot;give me a session&quot; verb for scripts. Bare prompt is conservative: it never auto-creates so you do not accidentally fork a session by running from the wrong directory.</p>
305
306
  <p>Concurrent ensures for the same directory and name share one scope lock, including when callers use current and earlier built-in agent commands. Custom commands, other directories, and other session names retain separate scopes.</p>
306
307
  <p>Explicitly resuming a saved local ID for the same agent command retires its current owner before loading the record&#39;s associated ACP session, even when you choose another cwd or name. This applies to <code>sessions new --resume-session</code> and to <code>sessions ensure --resume-session</code> when ensure needs to create the destination. If resuming fails, the prior record stays closed with its saved history. Ensuring an already-matching session still returns it normally.</p>
@@ -324,7 +325,7 @@ acpx codex sessions import debug.json <span class="hl-flag">--name</span> debug-
324
325
  <p>Exports preserve event order across rotated and active segments, including segments containing hundreds of thousands of events.</p>
325
326
  <p>Exports publish complete archives atomically. On POSIX systems, archives and imported history use <code>0600</code> permissions. Exporting preserves the selected output directory&#39;s permissions and follows existing or dangling output symlinks to their targets. Existing non-regular output targets, such as named pipes, are rejected. Live event segments also use <code>0600</code>; their append and rotation behavior is unchanged. Event-log files must be regular files, not symlink or hardlink aliases.</p>
326
327
  <p>The archive is plain JSON. Paths are stored relative to home, so an imported session lands at <code>~/&lt;original-cwd-relative&gt;</code> on the destination machine without embedding the source machine&#39;s absolute cwd. Override with <code>--cwd</code>.</p>
327
- <p>Imports keep the archive&#39;s provider session id, reopen the copied session as an idle local record, and clear source-machine process metadata. Imported sessions must resume that provider session; if the destination agent cannot load it, prompts fail clearly instead of starting an empty conversation. If the destination already has an active session for the same <code>(agent, cwd, name)</code> scope, import fails; pass <code>--name</code> or <code>--cwd</code> to choose a different scope. If a local record already uses the same provider session id, prune or remove that record before importing.</p>
328
+ <p>Imports keep the archive&#39;s provider session id, reopen the copied session as an idle local record, and clear source-machine process metadata. The imported session launches with the destination&#39;s resolved agent command and arguments, not the launch arguments saved on the source machine. Imported sessions must resume that provider session; if the destination agent cannot load it, prompts fail clearly instead of starting an empty conversation. If the destination already has an active session for the same <code>(agent, cwd, name)</code> scope, import fails; pass <code>--name</code> or <code>--cwd</code> to choose a different scope. If a local record already uses the same provider session id, prune or remove that record before importing.</p>
328
329
  <p>An imported session becomes discoverable after its complete history has been written. If writing the history fails, the import leaves no local session that blocks retrying the archive.</p>
329
330
  <p>New imports cap the saved journal retention setting at 1,024 segments. Existing local journals keep higher saved retention settings: export, watch, and rotation continue to include their retained segments without scanning every possible segment number.</p>
330
331
  <p>Concurrent imports into the same local store wait for one another and recheck scope and provider session id collisions before publishing. Only one of two conflicting imports can succeed; independent destinations still retain their own complete histories.</p>
@@ -348,6 +349,7 @@ acpx codex sessions prune <span class="hl-flag">--include-history</span></code><
348
349
  <li><code>json</code> — <code>{ action, dryRun, count, bytesFreed, pruned }</code></li>
349
350
  <li><code>quiet</code> — one pruned session id per line</li>
350
351
  </ul>
352
+ <p>If a selected file cannot be deleted, pruning fails with the filesystem error instead of printing a success summary. Files already deleted are not restored.</p>
351
353
  <h2 id="queue-ownership"><a class="anchor" href="#queue-ownership" aria-label="Anchor link">#</a>Queue ownership</h2>
352
354
  <p>When a prompt is in flight, <code>acpx</code> becomes the <strong>queue owner</strong> for that session. Subsequent <code>acpx codex …</code> invocations submit through local IPC instead of starting a second adapter:</p>
353
355
  <pre><code class="language-bash">acpx codex <span class="hl-str">&#39;run full test suite and triage failures&#39;</span>
@@ -371,7 +373,7 @@ acpx codex <span class="hl-flag">--no-wait</span> <span class="hl-str">&#39;and
371
373
  <p>By default the submitter blocks until the queued prompt completes, streaming events back. <code>--no-wait</code> returns as soon as the running queue owner acknowledges the submission. Useful for scripted &quot;queue up follow-ups&quot; patterns.</p>
372
374
  <pre><code class="language-bash">acpx codex <span class="hl-flag">--no-wait</span> <span class="hl-str">&#39;after the current turn ends, write the release notes&#39;</span></code></pre>
373
375
  <h2 id="cancelling"><a class="anchor" href="#cancelling" aria-label="Anchor link">#</a>Cancelling</h2>
374
- <p><code>Ctrl+C</code> during an active turn sends ACP <code>session/cancel</code> first, waits briefly for <code>stopReason=cancelled</code>, and only force-kills if cancellation does not finish in time.</p>
376
+ <p>Foreground <code>Ctrl+C</code> cancels only that invocation&#39;s queued or active session prompt. It removes pending work or sends ACP <code>session/cancel</code> for its active turn, without force-killing the shared owner or cancelling another client&#39;s turn. See <a href="session-control.html">Session control</a> for cancellation outcomes and detach-only observers.</p>
375
377
  <p>The <code>cancel</code> subcommand sends the same cooperative cancel without a terminal signal:</p>
376
378
  <pre><code class="language-bash">acpx codex cancel
377
379
  acpx codex cancel <span class="hl-flag">-s</span> backend</code></pre>
@@ -382,12 +384,12 @@ acpx codex cancel <span class="hl-flag">-s</span> backend</code></pre>
382
384
  <ol>
383
385
  <li><code>acpx</code> respawns the agent.</li>
384
386
  <li>Attempts ACP <code>session/resume</code> with the saved provider session id when the agent advertises it, otherwise ACP <code>session/load</code>.</li>
385
- <li>Falls back to <code>session/new</code> if reconnecting fails, transparently updating the saved record.</li>
387
+ <li>Starts a fresh session only when the reconnect policy permits it. Explicit resumes remain strict. Same-session recovery preserves the saved conversation. See <a href="session-control.html">Reconnect and recovery</a> for the narrow empty-session recovery exception.</li>
386
388
  </ol>
387
389
  <p>This makes long-running scripted sessions resilient to crashes, OS restarts, and adapter upgrades. Metadata updates received while reconnecting, including available commands, remain available after saved settings are replayed.</p>
388
390
  <h2 id="status"><a class="anchor" href="#status" aria-label="Anchor link">#</a>Status</h2>
389
391
  <p><code>acpx codex status</code> reports local queue-owner health, not whether a prompt is currently active:</p>
390
- <table><thead><tr><th>Text/quiet state</th><th>JSON <code>status</code></th><th>Meaning</th></tr></thead><tbody><tr><td><code>running</code></td><td><code>alive</code></td><td>Queue owner is healthy, including while it waits during its idle TTL.</td></tr><tr><td><code>idle</code></td><td><code>idle</code></td><td>Saved session is resumable and no queue owner is present.</td></tr><tr><td><code>dead</code></td><td><code>dead</code></td><td>A queue-owner lease remains but is unhealthy, or the recorded agent exit was abnormal.</td></tr><tr><td><code>no-session</code></td><td><code>no-session</code></td><td>No saved record matches this scope.</td></tr></tbody></table>
392
+ <div class="table-scroll" role="region" aria-label="Scrollable table" tabindex="0"><table><thead><tr><th>Text/quiet state</th><th>JSON <code>status</code></th><th>Meaning</th></tr></thead><tbody><tr><td><code>running</code></td><td><code>alive</code></td><td>Queue owner is healthy, including while it waits during its idle TTL.</td></tr><tr><td><code>idle</code></td><td><code>idle</code></td><td>Saved session is resumable and no queue owner is present.</td></tr><tr><td><code>dead</code></td><td><code>dead</code></td><td>A queue-owner lease remains but is unhealthy, or the recorded agent exit was abnormal.</td></tr><tr><td><code>no-session</code></td><td><code>no-session</code></td><td>No saved record matches this scope.</td></tr></tbody></table></div>
391
393
  <p>Checks use local lease, process, and socket information without an ACP request to the agent. Use <a href="session-watch.html">Watching sessions</a> for turn events and completion. <code>closed</code> describes the logical session lifecycle. A helper process can exit while the session remains open and resumable. Status reports a PID only when a live queue-owner lease ties that process to the session; queue owner liveness comes from <code>~/.acpx/queues/*.lock</code> plus its heartbeat and process probe.</p>
392
394
  <h2 id="cwd-scoping"><a class="anchor" href="#cwd-scoping" aria-label="Anchor link">#</a>CWD scoping</h2>
393
395
  <p><code>--cwd &lt;dir&gt;</code> sets both:</p>
@@ -400,8 +402,9 @@ acpx <span class="hl-flag">--cwd</span> ~/repos/shop codex <span class="hl-flag"
400
402
  <p>CWD is stored as an absolute path in the scope key.</p>
401
403
  <h2 id="session-metadata-fields"><a class="anchor" href="#session-metadata-fields" aria-label="Anchor link">#</a>Session metadata fields</h2>
402
404
  <p><code>sessions show</code> with <code>--format json</code> includes the stored normalized conversation, including text, thoughts, and tool results keyed by the adapter&#39;s opaque tool IDs. Retained text and thought chunks keep their whitespace. <code>sessions history</code> joins and trims content for previews; the existing runtime retention limits still apply to saved content.</p>
403
- <p><code>sessions show</code> and the JSON form of <code>sessions new</code>/<code>sessions ensure</code> and <code>status</code> include identity fields:</p>
404
- <table><thead><tr><th>Field</th><th>Meaning</th></tr></thead><tbody><tr><td><code>acpxRecordId</code></td><td>Local record id printed in <code>text</code> and <code>quiet</code> output</td></tr><tr><td><code>acpxSessionId</code></td><td>acpx-side session id (always present)</td></tr><tr><td><code>agentSessionId</code></td><td>Provider-native session id, <strong>only when</strong> the adapter exposes one</td></tr></tbody></table>
405
+ <p><code>sessions show --format json</code> returns the stored record. Lifecycle summaries from <code>sessions new</code>, <code>sessions ensure</code>, and <code>status</code> use a different field name for the ACP session ID:</p>
406
+ <div class="table-scroll" role="region" aria-label="Scrollable table" tabindex="0"><table><thead><tr><th>Field</th><th>Meaning</th></tr></thead><tbody><tr><td><code>acpxRecordId</code></td><td>Local record ID printed in text and quiet output</td></tr><tr><td><code>acpSessionId</code></td><td>ACP session ID in the stored record returned by <code>sessions show</code></td></tr><tr><td><code>acpxSessionId</code></td><td>ACP session ID in lifecycle and status summaries</td></tr><tr><td><code>agentSessionId</code></td><td>Provider-native session ID, only when the adapter exposes one</td></tr></tbody></table></div>
407
+ <p>See <a href="output-formats.html">Output formats</a> for the JSON shapes.</p>
405
408
  <p>Do not pass an <code>acpx</code> session id to a native provider CLI unless <code>agentSessionId</code> is also present.</p>
406
409
  <p>New local records use an independently generated ID, including when resuming a provider session for the first time. If an adapter reuses its ACP session ID, each new session and flow run still retains its own local history. Existing records keep their IDs, and explicitly resuming a saved local ID for the same agent loads its associated ACP session.</p>
407
410
  <h2 id="embedded-session-lifecycle"><a class="anchor" href="#embedded-session-lifecycle" aria-label="Anchor link">#</a>Embedded session lifecycle</h2>
@@ -421,7 +424,7 @@ acpx <span class="hl-flag">--cwd</span> ~/repos/shop codex <span class="hl-flag"
421
424
  <li><a href="output-formats.html">Output formats</a> — JSON envelope for sessions/status payloads.</li>
422
425
  <li><a href="CLI.html#sessions-subcommand">CLI reference</a> — long-form spec and exit codes.</li>
423
426
  </ul>
424
- <p>Embedding hosts can use optional <a href="runtime-process-lifecycle.html">process lifecycle callbacks</a> for launch admission and host-owned process tracking.</p><nav class="page-nav" aria-label="Pager"><a class="page-nav-prev" href="custom-agents.html"><small>Previous</small><span>Custom agents</span></a><a class="page-nav-next" href="prompting.html"><small>Next</small><span>Prompting</span></a></nav></article>
427
+ <p>Embedding hosts can use optional <a href="runtime-process-lifecycle.html">process lifecycle callbacks</a> for launch admission and host-owned process tracking.</p><nav class="page-nav" aria-label="Pager"><a class="page-nav-prev" href="compare.html"><small>Previous</small><span>Compare Command</span></a><a class="page-nav-next" href="prompting.html"><small>Next</small><span>Prompting</span></a></nav></article>
425
428
  <nav class="toc" aria-label="On this page"><h2>On this page</h2><a class="toc-l2" href="#scope-key">#Scope key</a><a class="toc-l2" href="#lifecycle-commands">#Lifecycle commands</a><a class="toc-l2" href="#auto-resume-by-directory-walk">#Auto-resume by directory walk</a><a class="toc-l2" href="#named-sessions">#Named sessions</a><a class="toc-l2" href="#sessions-vs-ensure-vs-new">#Sessions vs. ensure vs. new</a><a class="toc-l2" href="#soft-close">#Soft-close</a><a class="toc-l2" href="#export-import">#Export / import</a><a class="toc-l2" href="#prune">#Prune</a><a class="toc-l2" href="#queue-ownership">#Queue ownership</a><a class="toc-l2" href="#no-wait">#--no-wait</a><a class="toc-l2" href="#cancelling">#Cancelling</a><a class="toc-l2" href="#crash-recovery">#Crash recovery</a><a class="toc-l2" href="#status">#Status</a><a class="toc-l2" href="#cwd-scoping">#CWD scoping</a><a class="toc-l2" href="#session-metadata-fields">#Session metadata fields</a><a class="toc-l2" href="#embedded-session-lifecycle">#Embedded session lifecycle</a><a class="toc-l2" href="#see-also">#See also</a></nav>
426
429
  </div>
427
430
  </main>
@@ -170,7 +170,8 @@ body:not(.home) .doc>h1:first-child{display:none}
170
170
  .doc pre .copy.copied{background:var(--accent);border-color:var(--accent);color:#04121d;opacity:1}
171
171
  .doc blockquote{margin:1.4em 0;padding:10px 16px;border-left:3px solid var(--accent);background:var(--accent-soft);border-radius:0 8px 8px 0;color:var(--text)}
172
172
  .doc blockquote p:last-child{margin-bottom:0}
173
- .doc table{width:100%;border-collapse:collapse;margin:1.2em 0;font-size:.92em}
173
+ .doc .table-scroll{overflow-x:auto;margin:1.2em 0}
174
+ .doc table{width:100%;border-collapse:collapse;margin:0;font-size:.92em}
174
175
  .doc th,.doc td{border-bottom:1px solid var(--line);padding:9px 10px;text-align:left;vertical-align:top}
175
176
  .doc th{font-weight:600;color:var(--ink);background:var(--line-soft);border-bottom:1px solid var(--line)}
176
177
  .doc hr{border:0;border-top:1px solid var(--line);margin:2.2em 0}
@@ -236,12 +237,12 @@ body:not(.home) .doc>h1:first-child{display:none}
236
237
  </button>
237
238
  </div>
238
239
  <label class="search"><span>Search</span><input id="doc-search" type="search" placeholder="sessions, flows, json…"></label>
239
- <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a></section><section><h2>Sessions</h2><a class="nav-link" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link" href="session-control.html">Session control</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
+ <nav><section><h2>Start</h2><a class="nav-link" href="./">Overview</a><a class="nav-link" href="install.html">Install</a><a class="nav-link" href="quickstart.html">Quickstart</a></section><section><h2>Agents</h2><a class="nav-link" href="agents.html">Agents</a><a class="nav-link" href="custom-agents.html">Custom agents</a><a class="nav-link" href="compare.html">Compare Command</a></section><section><h2>Sessions</h2><a class="nav-link" href="sessions.html">Sessions</a><a class="nav-link" href="prompting.html">Prompting</a><a class="nav-link" href="session-control.html">Session control</a><a class="nav-link" href="session-watch.html">Watching sessions</a></section><section><h2>Output &amp; Policy</h2><a class="nav-link" href="output-formats.html">Output formats</a><a class="nav-link" href="permissions.html">Permissions</a><a class="nav-link" href="config.html">Config</a></section><section><h2>Flows</h2><a class="nav-link" href="flows.html">Flows</a></section><section><h2>Embedding</h2><a class="nav-link active" href="shared-sessions.html">Shared sessions</a><a class="nav-link" href="runtime-environment.html">Transient runtime environment</a><a class="nav-link" href="runtime-process-lifecycle.html">Runtime process lifecycle</a></section><section><h2>Reference</h2><a class="nav-link" href="CLI.html">CLI Reference</a><a class="nav-link" href="exit-codes.html">Exit codes</a><a class="nav-link" href="VISION.html">Vision</a></section></nav>
240
241
  </aside>
241
242
  <main>
242
243
  <header class="hero">
243
244
  <div class="hero-text">
244
- <p class="eyebrow">Reference</p>
245
+ <p class="eyebrow">Embedding</p>
245
246
  <h1>Shared sessions</h1>
246
247
  </div>
247
248
  <div class="hero-meta">
@@ -283,6 +284,7 @@ acpx pi cancel <span class="hl-flag">-s</span> reviewer
283
284
  acpx pi sessions show reviewer</code></pre>
284
285
  <h2 id="identity-and-ownership"><a class="anchor" href="#identity-and-ownership" aria-label="Anchor link">#</a>Identity and ownership</h2>
285
286
  <p><code>sessionKey</code> maps to the CLI&#39;s session name. An empty key selects the unnamed default session. Shared lookup uses the exact working directory; it does not walk into parent directories. The scope is the existing <code>(agentCommand, cwd, name)</code> tuple. Concurrent <code>ensureSession()</code> and CLI <code>sessions ensure</code> calls for the same scope select one record.</p>
287
+ <p><code>ensureSession()</code> applies <code>sessionOptions</code>, including <code>model</code>, only when creating a session. Reusing an existing session leaves its model, provider session and history unchanged; it does not open an adapter connection. To change an existing session&#39;s model, use <code>setModel()</code> while its owner is running, or the equivalent CLI command.</p>
286
288
  <p>Imports participate in that same exact-scope admission. An ensure waiting behind an import reuses its completed record; an import waiting behind a newly created shared session reports the occupied scope.</p>
287
289
  <p><code>findSession({ sessionKey, agent, cwd? })</code> looks up an open local session without launching an agent. Handles contain the canonical local record and provider session IDs. Keep shared handles with the shared runtime; the in-process runtime has a different ownership contract.</p>
288
290
  <p>New sessions are created using the normal CLI path. Prompt submission starts or joins the existing queue owner, which keeps the live connection for its idle TTL. Shared turns require the saved provider session to resume successfully; an unavailable session produces an error instead of silently creating a different conversation. The agent must support loading or resuming sessions.</p>
@@ -301,6 +303,7 @@ acpx pi sessions show reviewer</code></pre>
301
303
  <p>On macOS and Linux, the owner disconnects an output observer whose buffered writes stop progressing, while the admitted turn continues and remains observable through session watching; Windows retains stalled output because named pipes do not report partial write progress reliably enough to disconnect without truncating a reader that is still consuming output.</p>
302
304
  <h2 id="configuration-and-compatibility"><a class="anchor" href="#configuration-and-compatibility" aria-label="Anchor link">#</a>Configuration and compatibility</h2>
303
305
  <p>Shared runtime options are <code>cwd</code>, optional <code>agentRegistry</code>, required <code>permissionMode</code>, and optional <code>nonInteractivePermissions</code>, <code>permissionPolicy</code>, <code>authCredentials</code>, <code>authPolicy</code>, <code>timeoutMs</code>, and <code>ttlMs</code>. The default registry uses built-in agent commands. Applications with custom commands should pass <code>createAgentRegistry({ overrides: ... })</code> and use the identical command in CLI configuration or <code>--agent</code>.</p>
306
+ <p>Finite <code>ttlMs</code> values whose rounded millisecond delay exceeds 2,147,483,647 are rejected by <code>createSharedAcpRuntime()</code> with <code>ACP_INVALID_RUNTIME_OPTION</code>, before a session is created or an adapter starts. Zero retains the keep-alive-forever behavior; omitting <code>ttlMs</code> retains the default. This does not change the CLI&#39;s seconds-based <code>--ttl</code> option.</p>
304
307
  <p>Each submitting client supplies its static permission policy. Authentication and the child environment belong to the owner started for that session. Joining a session does not replace the existing owner&#39;s credentials. This is local, same-user IPC; it is not a network service or an isolation boundary between mutually untrusted clients.</p>
305
308
  <p>Custom session stores, process lifecycle callbacks, child environment overlays, MCP resolvers, and per-turn permission or elicitation callbacks belong to <code>createAcpRuntime()</code>. They are not serialized or silently ignored by the shared runtime. Shared sessions currently support persistent prompt turns; use the in-process runtime for oneshot sessions and <code>mode: &quot;steer&quot;</code> turns. In-process steer turns queue like prompts; see <a href="prompting.html#steer-turns">Steer turns</a>. <code>startTurn()</code> still rejects a per-turn <code>assertActive</code>, because a shared turn runs inside the owner and cannot consult the submitting client again after admission.</p>
306
309
  <h2 id="session-controls"><a class="anchor" href="#session-controls" aria-label="Anchor link">#</a>Session controls</h2>
@@ -310,7 +313,7 @@ acpx pi sessions show reviewer</code></pre>
310
313
  <p>An owner that advertises <code>persistsControlState</code> saves the accepted selection itself before reporting success, so updated shared clients do not write the record. Race-free persistence requires updated callers and an updated owner. A running v0.17.1 owner still needs caller-side persistence, and older callers may write even with an updated owner. Those whole-record writes can race other callers or owner checkpoints, leaving saved state stale even though the agent keeps what it accepted. Use updated clients and let an older owner expire while idle before resuming work. One shared client always runs its own controls for a session one at a time.</p>
311
314
  <p>Controls accept the same optional <code>signal</code> and <code>assertActive</code> fields as the in-process runtime. The shared runtime checks them locally on the way in and again immediately before the request is written to the owner&#39;s socket, so authority withdrawn while the control is still finding the owner or opening its connection means nothing was sent. Authority is never consulted after that write: a control the owner has accepted still settles its response and saved state, and cannot be recalled. The check also covers this client only — it does not gate controls the CLI or another application sends to the same owner.</p>
312
315
  <p>An older running owner may lack targeted cancellation and prompt-start notifications. Shared clients detect this before submitting work and report <code>QUEUE_SHARED_RUNTIME_UNSUPPORTED</code>. Allow that owner to expire when idle, or explicitly close the session before ensuring it again. Existing CLI clients can continue using their existing owners.</p>
313
- <p>The explicit session-wide <code>runtime.cancel()</code> and <code>runtime.close()</code> operations retain their CLI semantics with older owners. The compatibility gate protects shared turn submission and targeted turn cancellation.</p></article>
316
+ <p>The explicit session-wide <code>runtime.cancel()</code> and <code>runtime.close()</code> operations retain their CLI semantics with older owners. The compatibility gate protects shared turn submission and targeted turn cancellation.</p><nav class="page-nav" aria-label="Pager"><a class="page-nav-prev" href="flows.html"><small>Previous</small><span>Flows</span></a><a class="page-nav-next" href="runtime-environment.html"><small>Next</small><span>Transient runtime environment</span></a></nav></article>
314
317
  <nav class="toc" aria-label="On this page"><h2>On this page</h2><a class="toc-l2" href="#identity-and-ownership">#Identity and ownership</a><a class="toc-l2" href="#turns-cancellation-and-disconnects">#Turns, cancellation, and disconnects</a><a class="toc-l2" href="#configuration-and-compatibility">#Configuration and compatibility</a><a class="toc-l2" href="#session-controls">#Session controls</a></nav>
315
318
  </div>
316
319
  </main>