@1agents/acp-service 0.10.8 → 0.10.10

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 (94) hide show
  1. package/dist/bin/a2a.js +12 -1
  2. package/dist/src/a2a/gateway.d.ts +268 -2
  3. package/dist/src/a2a/gateway.js +337 -25
  4. package/dist/src/a2a/job-directory.d.ts +5 -0
  5. package/dist/src/a2a/job-directory.js +15 -0
  6. package/dist/src/a2a/preflight.d.ts +38 -0
  7. package/dist/src/a2a/preflight.js +56 -8
  8. package/dist/src/a2a/types.d.ts +8 -0
  9. package/dist/src/execution/case-view.d.ts +109 -0
  10. package/dist/src/execution/case-view.js +125 -0
  11. package/dist/src/execution/cases.d.ts +56 -0
  12. package/dist/src/execution/cases.js +77 -0
  13. package/dist/src/execution/externals.d.ts +83 -0
  14. package/dist/src/execution/externals.js +61 -0
  15. package/dist/src/execution/handoff.d.ts +54 -1
  16. package/dist/src/execution/handoff.js +80 -15
  17. package/dist/src/execution/ledger.d.ts +35 -2
  18. package/dist/src/execution/ledger.js +72 -2
  19. package/dist/src/execution/snapshots.d.ts +28 -0
  20. package/dist/src/execution/snapshots.js +64 -0
  21. package/dist/src/execution/targets.d.ts +63 -0
  22. package/dist/src/execution/targets.js +15 -1
  23. package/dist/src/execution/workbench.d.ts +5 -1
  24. package/dist/src/execution/workbench.js +13 -4
  25. package/dist/workbench-ui/app.css +18 -0
  26. package/dist/workbench-ui/app.js +13 -13
  27. package/package.json +12 -13
  28. package/vendor/dsh/a2a-executor.d.ts +2 -2
  29. package/vendor/dsh/adapter.d.ts +4 -4
  30. package/vendor/dsh/cordis.patch.yml +6 -5
  31. package/vendor/dsh/handoff-executor.d.ts +7 -0
  32. package/vendor/dsh/handoff-executor.js +28 -0
  33. package/vendor/dsh/handoff-spec.d.ts +26 -0
  34. package/vendor/dsh/handoff-spec.js +14 -0
  35. package/vendor/dsh/handoff-tools.d.ts +4 -0
  36. package/vendor/dsh/handoff-tools.js +20 -0
  37. package/vendor/dsh/index.js +8 -0
  38. package/vendor/dsh/review-mcp.js +6 -2
  39. package/vendor/dsh/review.d.ts +3 -0
  40. package/vendor/dsh/review.js +19 -0
  41. package/vendor/dsh/service-process.d.ts +9 -1
  42. package/vendor/dsh/service-process.js +69 -3
  43. package/vendor/dsh/ticket-tools.d.ts +1 -1
  44. package/vendor/runtime/dist/{cli-DXmYwv3U.js → cli-BwanDcOo.js} +4 -4
  45. package/vendor/runtime/dist/{cli-DXmYwv3U.js.map → cli-BwanDcOo.js.map} +1 -1
  46. package/vendor/runtime/dist/cli.js +8 -8
  47. package/vendor/runtime/dist/{client-VQsqcIOJ.d.ts → client-C5zneoBs.d.ts} +3 -1
  48. package/vendor/runtime/dist/{client-VQsqcIOJ.d.ts.map → client-C5zneoBs.d.ts.map} +1 -1
  49. package/vendor/runtime/dist/docs-site/.nojekyll +0 -0
  50. package/vendor/runtime/dist/docs-site/CLI.html +833 -0
  51. package/vendor/runtime/dist/docs-site/VISION.html +415 -0
  52. package/vendor/runtime/dist/docs-site/agents.html +391 -0
  53. package/vendor/runtime/dist/docs-site/compare.html +359 -0
  54. package/vendor/runtime/dist/docs-site/config.html +450 -0
  55. package/vendor/runtime/dist/docs-site/custom-agents.html +408 -0
  56. package/vendor/runtime/dist/docs-site/exit-codes.html +347 -0
  57. package/vendor/runtime/dist/docs-site/favicon.svg +21 -0
  58. package/vendor/runtime/dist/docs-site/flows.html +498 -0
  59. package/vendor/runtime/dist/docs-site/index.html +367 -0
  60. package/vendor/runtime/dist/docs-site/install.html +386 -0
  61. package/vendor/runtime/dist/docs-site/llms.txt +36 -0
  62. package/vendor/runtime/dist/docs-site/output-formats.html +407 -0
  63. package/vendor/runtime/dist/docs-site/permissions.html +422 -0
  64. package/vendor/runtime/dist/docs-site/prompting.html +460 -0
  65. package/vendor/runtime/dist/docs-site/quickstart.html +382 -0
  66. package/vendor/runtime/dist/docs-site/releasing.html +341 -0
  67. package/vendor/runtime/dist/docs-site/runtime-environment.html +329 -0
  68. package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +336 -0
  69. package/vendor/runtime/dist/docs-site/safe-errors.html +323 -0
  70. package/vendor/runtime/dist/docs-site/session-control.html +408 -0
  71. package/vendor/runtime/dist/docs-site/session-watch.html +354 -0
  72. package/vendor/runtime/dist/docs-site/sessions.html +488 -0
  73. package/vendor/runtime/dist/docs-site/shared-sessions.html +377 -0
  74. package/vendor/runtime/dist/{flows-DJ17ajbw.js → flows-CzLUHUTS.js} +4 -4
  75. package/vendor/runtime/dist/{flows-DJ17ajbw.js.map → flows-CzLUHUTS.js.map} +1 -1
  76. package/vendor/runtime/dist/flows.d.ts +1 -1
  77. package/vendor/runtime/dist/flows.js +1 -1
  78. package/vendor/runtime/dist/{invocation-options-PBfCgrdi.js → invocation-options-B6pIpdpR.js} +4 -4
  79. package/vendor/runtime/dist/{invocation-options-PBfCgrdi.js.map → invocation-options-B6pIpdpR.js.map} +1 -1
  80. package/vendor/runtime/dist/{ipc-BQQpcEdP.js → ipc-ivLtSAdL.js} +21 -3
  81. package/vendor/runtime/dist/ipc-ivLtSAdL.js.map +1 -0
  82. package/vendor/runtime/dist/{output-B3MDn7kv.js → output-BqKnXXb0.js} +3 -3
  83. package/vendor/runtime/dist/{output-B3MDn7kv.js.map → output-BqKnXXb0.js.map} +1 -1
  84. package/vendor/runtime/dist/{queue-owner-runtime-DXCVngwU.js → queue-owner-runtime-DXJND10J.js} +11 -2
  85. package/vendor/runtime/dist/queue-owner-runtime-DXJND10J.js.map +1 -0
  86. package/vendor/runtime/dist/runtime.d.ts +1 -1
  87. package/vendor/runtime/dist/runtime.d.ts.map +1 -1
  88. package/vendor/runtime/dist/runtime.js +3 -3
  89. package/vendor/runtime/dist/{session-watch-DURyCw31.js → session-watch-BHB3_PXm.js} +4 -4
  90. package/vendor/runtime/dist/{session-watch-DURyCw31.js.map → session-watch-BHB3_PXm.js.map} +1 -1
  91. package/vendor/runtime/dist/{watch-CIpoMaWD.js → watch-UjokHUfS.js} +2 -2
  92. package/vendor/runtime/dist/{watch-CIpoMaWD.js.map → watch-UjokHUfS.js.map} +1 -1
  93. package/vendor/runtime/dist/ipc-BQQpcEdP.js.map +0 -1
  94. package/vendor/runtime/dist/queue-owner-runtime-DXCVngwU.js.map +0 -1
@@ -0,0 +1,488 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Sessions — acpx</title>
7
+ <meta name="description" content="Persistent multi-turn ACP sessions in acpx — scope rules, named sessions, soft-close, prune, queue ownership, and crash recovery.">
8
+ <link rel="canonical" href="sessions.html">
9
+ <meta property="og:type" content="website">
10
+ <meta property="og:site_name" content="acpx">
11
+ <meta property="og:title" content="Sessions — acpx">
12
+ <meta property="og:description" content="Persistent multi-turn ACP sessions in acpx — scope rules, named sessions, soft-close, prune, queue ownership, and crash recovery.">
13
+ <meta property="og:url" content="sessions.html">
14
+ <meta name="twitter:card" content="summary_large_image">
15
+ <meta name="twitter:title" content="Sessions — acpx">
16
+ <meta name="twitter:description" content="Persistent multi-turn ACP sessions in acpx — scope rules, named sessions, soft-close, prune, queue ownership, and crash recovery.">
17
+ <link rel="icon" href="favicon.svg" type="image/svg+xml">
18
+ <link rel="preconnect" href="https://fonts.googleapis.com">
19
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
20
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
21
+ <script>(function(){var s;try{s=localStorage.getItem('theme')}catch(e){}var d=window.matchMedia&&matchMedia('(prefers-color-scheme: dark)').matches;document.documentElement.dataset.theme=s||(d?'dark':'light')})();</script>
22
+ <style>
23
+ :root{
24
+ --ink:#0b0e14;
25
+ --text:#1f2530;
26
+ --muted:#6a7282;
27
+ --subtle:#9aa1ab;
28
+ --bg:#f7f8fa;
29
+ --paper:#ffffff;
30
+ --accent:#0ea5e9;
31
+ --accent-soft:rgba(14,165,233,.10);
32
+ --accent-strong:#0284c7;
33
+ --accent-2:#a855f7;
34
+ --accent-3:#22c55e;
35
+ --accent-4:#f59e0b;
36
+ --line:#e5e7eb;
37
+ --line-soft:#eef0f3;
38
+ --code-bg:#0a0d14;
39
+ --code-fg:#e6edf3;
40
+ --code-inline-fg:#1c2128;
41
+ --pill-border:#dbe2eb;
42
+ --shadow-card:0 4px 14px rgba(15,17,21,.08);
43
+ --scrollbar:#cbd5e1;
44
+ }
45
+ :root[data-theme="dark"]{
46
+ --ink:#f3f5f9;
47
+ --text:#cdd3dd;
48
+ --muted:#8d96a4;
49
+ --subtle:#5d6371;
50
+ --bg:#08090f;
51
+ --paper:#13161f;
52
+ --accent:#38bdf8;
53
+ --accent-soft:rgba(56,189,248,.18);
54
+ --accent-strong:#7dd3fc;
55
+ --line:#23283a;
56
+ --line-soft:#1a1d28;
57
+ --code-bg:#040611;
58
+ --code-fg:#e6edf3;
59
+ --code-inline-fg:#e6edf3;
60
+ --pill-border:#2a2f3c;
61
+ --shadow-card:0 4px 18px rgba(0,0,0,.45);
62
+ --scrollbar:#3a4154;
63
+ }
64
+ :root{color-scheme:light}
65
+ :root[data-theme="dark"]{color-scheme:dark}
66
+ *{box-sizing:border-box}
67
+ html{scroll-behavior:smooth;scroll-padding-top:24px}
68
+ body{margin:0;background:var(--bg);color:var(--text);font-family:"Inter",ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif;line-height:1.65;overflow-x:hidden;-webkit-font-smoothing:antialiased;font-feature-settings:"cv02","cv03","cv04","cv11";transition:background-color .18s,color .18s}
69
+ ::selection{background:var(--accent);color:#04121d}
70
+ a{color:var(--accent);text-decoration:none;transition:color .12s}
71
+ a:hover{text-decoration:underline;text-underline-offset:.2em}
72
+ .shell{display:grid;grid-template-columns:268px minmax(0,1fr);min-height:100vh}
73
+ .sidebar{position:sticky;top:0;height:100vh;overflow:auto;padding:24px 22px;background:var(--paper);border-right:1px solid var(--line);scrollbar-width:thin;scrollbar-color:var(--line) transparent;transition:background-color .18s,border-color .18s}
74
+ .sidebar::-webkit-scrollbar{width:6px}
75
+ .sidebar::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px}
76
+ .sidebar-head{display:flex;align-items:center;gap:10px;margin-bottom:24px}
77
+ .brand{display:flex;align-items:center;gap:11px;color:var(--ink);text-decoration:none;flex:1;min-width:0}
78
+ .brand:hover{text-decoration:none}
79
+ .brand .mark{flex:0 0 34px;width:34px;height:34px;border-radius:8px;background:linear-gradient(145deg,#08111f 0%,#101827 58%,#172554 100%);position:relative;overflow:hidden;display:grid;place-items:center;box-shadow:0 1px 0 rgba(255,255,255,.08) inset,0 10px 24px -13px rgba(14,165,233,.7)}
80
+ .brand .mark::before{content:"";position:absolute;inset:0;background:linear-gradient(135deg,rgba(125,211,252,.22),transparent 42%),linear-gradient(315deg,rgba(167,139,250,.2),transparent 48%);pointer-events:none}
81
+ .brand .mark::after{content:"";position:absolute;inset:1px;border-radius:7px;border:1px solid rgba(255,255,255,.1);pointer-events:none}
82
+ .brand .mark svg{position:relative;z-index:1;width:23px;height:23px;display:block}
83
+ .brand .mark .cursor{transform-origin:center;animation:acpx-blink 1.2s steps(2,jump-none) infinite}
84
+ @keyframes acpx-blink{0%,49%{opacity:1}50%,100%{opacity:.25}}
85
+ @media (prefers-reduced-motion: reduce){.brand .mark .cursor{animation:none}}
86
+ .brand strong{display:block;font-size:1.05rem;line-height:1.1;font-weight:600;letter-spacing:0;color:var(--ink)}
87
+ .brand small{display:block;color:var(--muted);font-size:.74rem;margin-top:3px;font-weight:400}
88
+ .theme-toggle{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;width:34px;height:34px;border-radius:8px;border:1px solid var(--line);background:var(--paper);color:var(--muted);cursor:pointer;padding:0;transition:border-color .15s,color .15s,background-color .15s,transform .12s}
89
+ .theme-toggle:hover{border-color:var(--ink);color:var(--ink)}
90
+ .theme-toggle:active{transform:scale(.94)}
91
+ .theme-toggle svg{width:16px;height:16px;display:block}
92
+ .theme-icon-sun{display:none}
93
+ :root[data-theme="dark"] .theme-icon-sun{display:block}
94
+ :root[data-theme="dark"] .theme-icon-moon{display:none}
95
+ .search{display:block;margin:0 0 22px}
96
+ .search span{display:block;color:var(--muted);font-size:.7rem;font-weight:600;text-transform:uppercase;letter-spacing:0;margin-bottom:7px}
97
+ .search input{width:100%;border:1px solid var(--line);background:var(--paper);border-radius:8px;padding:9px 12px;font:inherit;font-size:.9rem;color:var(--text);outline:none;transition:border-color .15s,box-shadow .15s,background-color .18s}
98
+ .search input:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
99
+ nav section{margin:0 0 18px}
100
+ nav h2{font-size:.68rem;color:var(--muted);text-transform:uppercase;letter-spacing:0;margin:0 0 6px;font-weight:600}
101
+ .nav-link{display:block;color:var(--text);text-decoration:none;border-radius:6px;padding:5px 10px;margin:1px 0;font-size:.9rem;line-height:1.4;transition:background .12s,color .12s}
102
+ .nav-link:hover{background:var(--line-soft);color:var(--ink);text-decoration:none}
103
+ .nav-link.active{background:var(--accent-soft);color:var(--accent);font-weight:600}
104
+ main{min-width:0;padding:32px clamp(20px,4.5vw,56px) 80px;max-width:1180px;margin:0 auto;width:100%}
105
+ .hero{display:flex;align-items:flex-end;justify-content:space-between;gap:22px;border-bottom:1px solid var(--line);padding:8px 0 22px;margin-bottom:8px;flex-wrap:wrap}
106
+ .hero-text{min-width:0;flex:1 1 320px}
107
+ .eyebrow{margin:0 0 8px;color:var(--muted);font-weight:600;text-transform:uppercase;letter-spacing:0;font-size:.7rem}
108
+ .hero h1{font-size:2.25rem;line-height:1.1;letter-spacing:-.01em;margin:0;font-weight:700;color:var(--ink)}
109
+ .hero-meta{display:flex;gap:8px;flex:0 0 auto;flex-wrap:wrap}
110
+ .repo,.edit,.btn-ghost{border:1px solid var(--line);color:var(--text);text-decoration:none;border-radius:7px;padding:6px 11px;font-weight:500;font-size:.83rem;background:var(--paper);transition:border-color .15s,color .15s,background .15s}
111
+ .repo:hover,.edit:hover,.btn-ghost:hover{border-color:var(--ink);color:var(--ink);text-decoration:none}
112
+ .edit{color:var(--muted)}
113
+ .home-hero{padding:14px 0 28px;margin-bottom:8px;border-bottom:1px solid var(--line)}
114
+ .home-hero .eyebrow{display:inline-flex;align-items:center;gap:8px}
115
+ .home-hero .eyebrow .dot{width:7px;height:7px;border-radius:50%;background:var(--accent-3);box-shadow:0 0 0 3px rgba(34,197,94,.2)}
116
+ .home-hero h1{font-size:3.25rem;line-height:1.04;letter-spacing:-.015em;margin:0 0 .35em;font-weight:700;color:var(--ink)}
117
+ .home-hero h1 .accent{background:linear-gradient(110deg,var(--accent) 0%,var(--accent-2) 70%);-webkit-background-clip:text;background-clip:text;color:transparent}
118
+ .home-hero .lede{font-size:1.18rem;line-height:1.55;color:var(--text);margin:0 0 1.2em;max-width:60ch}
119
+ .home-cta{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin:0 0 18px}
120
+ .home-cta .btn{display:inline-flex;align-items:center;gap:7px;border-radius:8px;padding:10px 16px;font-weight:600;font-size:.92rem;text-decoration:none;transition:background .15s,border-color .15s,color .15s,transform .12s}
121
+ .home-cta .btn-primary{background:var(--ink);color:var(--paper);border:1px solid var(--ink)}
122
+ .home-cta .btn-primary:hover{background:var(--accent);border-color:var(--accent);color:#04121d;text-decoration:none}
123
+ .home-cta .btn-ghost{padding:10px 16px}
124
+ .home-install{display:flex;align-items:center;gap:12px;background:var(--code-bg);color:var(--code-fg);border-radius:8px;padding:10px 10px 10px 16px;font:500 .9rem/1.2 "JetBrains Mono","SF Mono",ui-monospace,monospace;max-width:32em;border:1px solid #1f2937}
125
+ .home-install .prompt{color:#7dd3fc;user-select:none;flex:0 0 auto}
126
+ .home-install code{flex:1;background:transparent;border:0;color:var(--code-fg);font:inherit;padding:0;white-space:pre;overflow:hidden;text-overflow:ellipsis}
127
+ .home-install .copy{flex:0 0 auto;background:rgba(255,255,255,.08);color:var(--code-fg);border:1px solid rgba(255,255,255,.16);border-radius:6px;padding:5px 11px;font:500 .72rem/1 "Inter",sans-serif;cursor:pointer;transition:background .15s,border-color .15s}
128
+ .home-install .copy:hover{background:rgba(255,255,255,.16)}
129
+ .home-install .copy.copied{background:var(--accent);border-color:var(--accent);color:#04121d}
130
+ .home-services{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0 18px}
131
+ .home-services span{display:inline-block;padding:3px 9px;border:1px solid var(--line);border-radius:999px;font-size:.78rem;color:var(--muted);background:var(--paper);font-family:"JetBrains Mono","SF Mono",ui-monospace,monospace}
132
+ .doc-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:48px;margin-top:24px}
133
+ .doc-grid-home{margin-top:8px}
134
+ @media(min-width:1180px){.doc-grid{grid-template-columns:minmax(0,72ch) 200px;justify-content:start}.doc-grid-home{grid-template-columns:minmax(0,76ch);justify-content:start}}
135
+ .doc{min-width:0;max-width:72ch;overflow-wrap:break-word}
136
+ .doc-home{max-width:76ch}
137
+ .doc h1{font-size:2.6rem;line-height:1.08;letter-spacing:-.015em;margin:0 0 .4em;font-weight:700;color:var(--ink)}
138
+ body:not(.home) .doc>h1:first-child{display:none}
139
+ .doc h2{font-size:1.45rem;line-height:1.2;margin:2em 0 .5em;font-weight:600;letter-spacing:-.005em;color:var(--ink);position:relative}
140
+ .doc h3{font-size:1.1rem;margin:1.7em 0 .35em;position:relative;font-weight:600;color:var(--ink);letter-spacing:0}
141
+ .doc h4{font-size:.98rem;margin:1.4em 0 .25em;color:var(--ink);position:relative;font-weight:600}
142
+ .doc h2:first-child,.doc h3:first-child,.doc h4:first-child{margin-top:.2em}
143
+ .doc :is(h2,h3,h4) .anchor{position:absolute;left:-1.05em;top:0;color:var(--subtle);opacity:0;text-decoration:none;font-weight:400;padding-right:.3em;transition:opacity .12s,color .12s}
144
+ .doc :is(h2,h3,h4):hover .anchor{opacity:.7}
145
+ .doc :is(h2,h3,h4) .anchor:hover{opacity:1;color:var(--accent);text-decoration:none}
146
+ .doc p{margin:0 0 1.05em}
147
+ .doc ul,.doc ol{padding-left:1.3rem;margin:0 0 1.15em}
148
+ .doc li{margin:.25em 0}
149
+ .doc li>p{margin:0 0 .4em}
150
+ .doc strong{font-weight:600;color:var(--ink)}
151
+ .doc em{font-style:italic}
152
+ .doc code{font-family:"JetBrains Mono","SF Mono",ui-monospace,monospace;font-size:.84em;background:var(--line-soft);border:1px solid var(--line);border-radius:5px;padding:.08em .35em;color:var(--code-inline-fg)}
153
+ .doc pre{position:relative;overflow:auto;background:var(--code-bg);color:var(--code-fg);border-radius:8px;padding:14px 18px;margin:1.3em 0;font-size:.85em;line-height:1.6;scrollbar-width:thin;scrollbar-color:#334155 transparent;border:1px solid #1f2937}
154
+ .doc pre::-webkit-scrollbar{height:8px;width:8px}
155
+ .doc pre::-webkit-scrollbar-thumb{background:#334155;border-radius:8px}
156
+ .doc pre code{display:block;background:transparent;border:0;color:inherit;padding:0;font-size:1em;white-space:pre}
157
+ .doc pre .hl-com{color:#7a8597;font-style:italic}
158
+ .doc pre .hl-str{color:#86efac}
159
+ .doc pre .hl-num{color:#fbbf24}
160
+ .doc pre .hl-kw{color:#c4b5fd;font-weight:500}
161
+ .doc pre .hl-lit{color:#f0abfc}
162
+ .doc pre .hl-flag{color:#7dd3fc}
163
+ .doc pre .hl-var{color:#fca5a5}
164
+ .doc pre .hl-prop{color:#7dd3fc}
165
+ .doc pre .hl-op{color:#94a3b8}
166
+ .doc pre .hl-typ{color:#fde68a}
167
+ .doc pre .copy{position:absolute;top:8px;right:8px;background:rgba(255,255,255,.06);color:var(--code-fg);border:1px solid rgba(255,255,255,.16);border-radius:6px;padding:3px 9px;font:500 .7rem/1 "Inter",sans-serif;cursor:pointer;opacity:0;transition:opacity .15s,background .15s,border-color .15s}
168
+ .doc pre:hover .copy,.doc pre .copy:focus{opacity:1}
169
+ .doc pre .copy:hover{background:rgba(255,255,255,.12)}
170
+ .doc pre .copy.copied{background:var(--accent);border-color:var(--accent);color:#04121d;opacity:1}
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
+ .doc blockquote p:last-child{margin-bottom:0}
173
+ .doc table{width:100%;border-collapse:collapse;margin:1.2em 0;font-size:.92em}
174
+ .doc th,.doc td{border-bottom:1px solid var(--line);padding:9px 10px;text-align:left;vertical-align:top}
175
+ .doc th{font-weight:600;color:var(--ink);background:var(--line-soft);border-bottom:1px solid var(--line)}
176
+ .doc hr{border:0;border-top:1px solid var(--line);margin:2.2em 0}
177
+ .toc{position:sticky;top:24px;align-self:start;font-size:.84rem;padding-left:14px;border-left:1px solid var(--line);max-height:calc(100vh - 48px);overflow:auto;scrollbar-width:thin;scrollbar-color:var(--line) transparent}
178
+ .toc::-webkit-scrollbar{width:5px}
179
+ .toc::-webkit-scrollbar-thumb{background:var(--line);border-radius:5px}
180
+ .toc h2{font-size:.66rem;color:var(--muted);text-transform:uppercase;letter-spacing:0;margin:0 0 10px;font-weight:600}
181
+ .toc a{display:block;color:var(--muted);text-decoration:none;padding:4px 0 4px 10px;line-height:1.35;border-left:2px solid transparent;margin-left:-12px;transition:color .12s,border-color .12s}
182
+ .toc a:hover{color:var(--ink);text-decoration:none}
183
+ .toc a.active{color:var(--accent);border-left-color:var(--accent);font-weight:500}
184
+ .toc-l3{padding-left:22px!important;font-size:.94em}
185
+ @media(max-width:1179px){.toc{display:none}}
186
+ .page-nav{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:48px;border-top:1px solid var(--line);padding-top:20px}
187
+ .page-nav>a{display:block;border:1px solid var(--line);background:var(--paper);border-radius:9px;padding:13px 16px;text-decoration:none;color:var(--text);transition:border-color .15s,transform .15s,box-shadow .15s,background-color .18s}
188
+ .page-nav>a:hover{border-color:var(--accent);text-decoration:none;color:var(--ink)}
189
+ .page-nav small{display:block;color:var(--muted);font-size:.7rem;text-transform:uppercase;letter-spacing:0;margin-bottom:5px;font-weight:600}
190
+ .page-nav span{display:block;font-weight:600;line-height:1.3;color:var(--ink)}
191
+ .page-nav-prev{text-align:left}
192
+ .page-nav-next{text-align:right;grid-column:2}
193
+ .page-nav-prev:only-child{grid-column:1}
194
+ .nav-toggle{display:none;position:fixed;top:14px;right:14px;top:calc(14px + env(safe-area-inset-top, 0px));right:calc(14px + env(safe-area-inset-right, 0px));z-index:20;width:40px;height:40px;border-radius:9px;background:var(--paper);border:1px solid var(--line);color:var(--ink);cursor:pointer;padding:10px 9px;flex-direction:column;align-items:stretch;justify-content:space-between;box-shadow:var(--shadow-card)}
195
+ .nav-toggle span{display:block;width:100%;height:2px;flex:0 0 2px;background:currentColor;border-radius:2px;transition:transform .2s,opacity .2s}
196
+ .nav-toggle[aria-expanded="true"] span:nth-child(1){transform:translateY(8px) rotate(45deg)}
197
+ .nav-toggle[aria-expanded="true"] span:nth-child(2){opacity:0}
198
+ .nav-toggle[aria-expanded="true"] span:nth-child(3){transform:translateY(-8px) rotate(-45deg)}
199
+ @media(max-width:900px){
200
+ .shell{display:block}
201
+ .sidebar{position:fixed;inset:0 30% 0 0;max-width:320px;height:100vh;z-index:15;transform:translateX(-100%);transition:transform .25s ease,background-color .18s,border-color .18s;box-shadow:0 18px 40px rgba(0,0,0,.18);background:var(--paper);pointer-events:none}
202
+ .sidebar.open{transform:translateX(0);pointer-events:auto}
203
+ .nav-toggle{display:flex}
204
+ main{padding:64px 18px 56px}
205
+ .hero{padding-top:6px}
206
+ .hero h1{font-size:1.8rem}
207
+ .home-hero h1{font-size:2.45rem}
208
+ .doc h1{font-size:2.1rem}
209
+ .hero-meta{width:100%;justify-content:flex-start}
210
+ .home-hero{padding-top:8px}
211
+ .doc{padding:0}
212
+ .doc-grid{margin-top:18px;gap:24px}
213
+ .doc :is(h2,h3,h4) .anchor{display:none}
214
+ }
215
+ @media(max-width:520px){
216
+ main{padding:60px 14px 48px}
217
+ .doc pre{margin-left:-14px;margin-right:-14px;border-radius:0;border-left:0;border-right:0}
218
+ .home-install{flex-wrap:wrap}
219
+ }
220
+ </style>
221
+ </head>
222
+ <body>
223
+ <button class="nav-toggle" type="button" aria-label="Toggle navigation" aria-expanded="false">
224
+ <span aria-hidden="true"></span><span aria-hidden="true"></span><span aria-hidden="true"></span>
225
+ </button>
226
+ <div class="shell">
227
+ <aside class="sidebar">
228
+ <div class="sidebar-head">
229
+ <a class="brand" href="./" aria-label="acpx docs home">
230
+ <span class="mark" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.8 6.8 10 12l-5.2 5.2" stroke="#7dd3fc" stroke-width="2.7" stroke-linecap="round" stroke-linejoin="round"/><path d="M13.2 7.2h2.9c1.7 0 3.1 1.4 3.1 3.1v.5c0 1.7-1.4 3.1-3.1 3.1h-1.4c-1.7 0-3.1 1.4-3.1 3.1v.5" stroke="#a78bfa" stroke-width="1.8" stroke-linecap="round"/><circle cx="13.2" cy="7.2" r="1.6" fill="#7dd3fc"/><circle cx="19.2" cy="12" r="1.6" fill="#a78bfa"/><rect class="cursor" x="13.2" y="16.2" width="6.6" height="2.5" rx="1.25" fill="#e0e7ff"/></svg></span>
231
+ <span><strong>acpx</strong><small>ACP CLI docs</small></span>
232
+ </a>
233
+ <button class="theme-toggle" type="button" aria-label="Toggle dark mode" aria-pressed="false" data-theme-toggle>
234
+ <svg class="theme-icon-moon" viewBox="0 0 20 20" aria-hidden="true"><path d="M14.6 12.1A6.5 6.5 0 0 1 7.4 2.7a6.5 6.5 0 1 0 7.2 9.4z" fill="currentColor"/></svg>
235
+ <svg class="theme-icon-sun" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="3.4" fill="currentColor"/><g stroke="currentColor" stroke-width="1.6" stroke-linecap="round"><line x1="10" y1="2" x2="10" y2="4"/><line x1="10" y1="16" x2="10" y2="18"/><line x1="2" y1="10" x2="4" y2="10"/><line x1="16" y1="10" x2="18" y2="10"/><line x1="4.2" y1="4.2" x2="5.6" y2="5.6"/><line x1="14.4" y1="14.4" x2="15.8" y2="15.8"/><line x1="4.2" y1="15.8" x2="5.6" y2="14.4"/><line x1="14.4" y1="5.6" x2="15.8" y2="4.2"/></g></svg>
236
+ </button>
237
+ </div>
238
+ <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
+ </aside>
241
+ <main>
242
+ <header class="hero">
243
+ <div class="hero-text">
244
+ <p class="eyebrow">Sessions</p>
245
+ <h1>Sessions</h1>
246
+ </div>
247
+ <div class="hero-meta">
248
+ <a class="repo" href="https://github.com/scottzx/agent-workflow" rel="noopener">GitHub</a>
249
+ <a class="edit" href="https://github.com/scottzx/agent-workflow/edit/main/packages/runtime/docs/sessions.md" rel="noopener">Edit page</a>
250
+ </div>
251
+ </header>
252
+ <div class="doc-grid">
253
+ <article class="doc"><p><code>acpx</code> sessions are how multi-turn agent conversations survive between invocations. A session is a JSON record on disk plus, when active, a queue owner process that holds the live ACP connection. The session record tracks the logical conversation; the queue owner lease is the source of truth for whether <code>acpx</code> currently expects a helper process to be alive.</p>
254
+ <h2 id="scope-key"><a class="anchor" href="#scope-key" aria-label="Anchor link">#</a>Scope key</h2>
255
+ <p>Every session is keyed by a tuple:</p>
256
+ <pre><code class="language-text">(agentCommand, absoluteCwd, optional name)</code></pre>
257
+ <p>That is what makes <code>acpx codex</code> in <code>~/repos/api</code> and <code>acpx codex</code> in <code>~/repos/web</code> resume different conversations, and why <code>-s backend</code> and <code>-s docs</code> can run side by side in the same repo.</p>
258
+ <p><code>agentCommand</code> comes from either the built-in registry, an unknown positional name (treated as a raw command), or <code>--agent &lt;command&gt;</code>. Two sessions with different commands are different sessions even if everything else matches.</p>
259
+ <p>One exception keeps saved sessions reachable across acpx upgrades. When a built-in agent&#39;s default command changes, for example because acpx moves the adapter package range, a record saved under an earlier default of that built-in is read as the current default. The record keeps its conversation, is found by the built-in name, and saves the current command the next time it is written. Only exact earlier defaults qualify, and only when the record&#39;s saved arguments are absent, match that earlier command, or match the current default; a record with any other launcher keeps its saved command and arguments. Passing an earlier default with <code>--agent</code> matches both records still saved under that string and records read as the current default. When more than one record matches a scope this way, the most recently used one is selected, the same rule used for any other match.</p>
260
+ <p>Local discovery reads the saved session records and uses their current scope, closed state, IDs, and last-used times. A legacy <code>index.json</code> is ignored. In the local store, a record&#39;s filename must match its encoded local ID; mismatched copies are ignored. Lookup by an exact local record ID reads that file directly; other lookups scan the saved records. Concurrent writes are observed per record, rather than as one atomic snapshot of the entire store.</p>
261
+ <h2 id="lifecycle-commands"><a class="anchor" href="#lifecycle-commands" aria-label="Anchor link">#</a>Lifecycle commands</h2>
262
+ <pre><code class="language-bash">acpx codex sessions <span class="hl-com"># list (alias for `sessions list`)</span>
263
+ acpx codex sessions list <span class="hl-com"># list agent sessions via ACP when supported</span>
264
+ acpx codex sessions list <span class="hl-flag">--filter-cwd</span> . <span class="hl-flag">--cursor</span> <span class="hl-op">&lt;</span>cursor<span class="hl-op">&gt;</span>
265
+ acpx codex sessions list <span class="hl-flag">--local</span> <span class="hl-com"># list saved acpx records</span>
266
+ acpx codex sessions new <span class="hl-com"># create a fresh cwd-scoped default session</span>
267
+ acpx codex sessions new <span class="hl-flag">--name</span> api <span class="hl-com"># create a fresh named session</span>
268
+ acpx codex sessions ensure <span class="hl-com"># idempotent: existing or create</span>
269
+ acpx codex sessions ensure <span class="hl-flag">--name</span> api
270
+ acpx codex sessions show <span class="hl-com"># metadata for the cwd-scoped default</span>
271
+ acpx codex sessions show api <span class="hl-com"># metadata for the named session</span>
272
+ acpx codex sessions history <span class="hl-com"># last 20 turn previews</span>
273
+ acpx codex sessions history <span class="hl-flag">--limit</span> <span class="hl-num">50</span>
274
+ acpx codex sessions export api <span class="hl-flag">--output</span> api-session.json
275
+ acpx codex sessions import api-session.json <span class="hl-flag">--name</span> api-restored
276
+ acpx codex sessions close <span class="hl-com"># soft-close cwd default</span>
277
+ acpx codex sessions close api <span class="hl-com"># soft-close named session</span>
278
+ acpx codex sessions prune <span class="hl-flag">--dry-run</span>
279
+ acpx codex sessions prune <span class="hl-flag">--older-than</span> <span class="hl-num">30</span>
280
+ acpx codex sessions prune <span class="hl-flag">--before</span> <span class="hl-num">2026</span>-<span class="hl-num">01</span>-<span class="hl-num">01</span> <span class="hl-flag">--include-history</span></code></pre>
281
+ <p>Top-level <code>acpx sessions …</code> defaults to <code>codex</code>.</p>
282
+ <p><code>sessions list</code> prefers the agent-side ACP <code>session/list</code> method when the selected agent advertises <code>sessionCapabilities.list</code>. JSON output includes the agent&#39;s <code>SessionInfo</code> fields, any <code>_meta</code> metadata, and <code>nextCursor</code> for manual pagination. Use <code>--filter-cwd &lt;dir&gt;</code> to send the ACP cwd filter; relative paths resolve against global <code>--cwd</code>. Use <code>--local</code> when you specifically want the saved <code>~/.acpx/sessions</code> records.</p>
283
+ <h2 id="auto-resume-by-directory-walk"><a class="anchor" href="#auto-resume-by-directory-walk" aria-label="Anchor link">#</a>Auto-resume by directory walk</h2>
284
+ <p>Prompt commands (<code>acpx codex &#39;fix tests&#39;</code>, <code>acpx codex prompt …</code>) resume an existing session rather than create one. Lookup is a directory walk:</p>
285
+ <ol>
286
+ <li>Detect the nearest git root by walking up from the absolute <code>cwd</code>. A <code>.git</code> directory or file marks the root, including worktrees and submodules.</li>
287
+ <li>If a git root exists, walk from <code>cwd</code> up to that root <strong>inclusive</strong>, checking each directory.</li>
288
+ <li>If no git root is found, only check <code>cwd</code> exactly — no parent walk.</li>
289
+ <li>At each directory, find the first <strong>active</strong> (non-closed) session matching <code>(agentCommand, dir, optionalName)</code>.</li>
290
+ <li>If a match is found, use it. Otherwise exit with code <code>4</code> and tell you to run <code>sessions new</code>.</li>
291
+ </ol>
292
+ <p>This means most workflows feel like &quot;I was talking to codex in this repo&quot;, regardless of whether you happen to be in <code>src/</code> or <code>docs/</code> when the next prompt fires.</p>
293
+ <pre><code class="language-bash">cd ~/repos/api/src/auth
294
+ acpx codex <span class="hl-str">&#39;remind me what we changed&#39;</span> <span class="hl-com"># resumes the session created at ~/repos/api</span></code></pre>
295
+ <h2 id="named-sessions"><a class="anchor" href="#named-sessions" aria-label="Anchor link">#</a>Named sessions</h2>
296
+ <p><code>-s, --session &lt;name&gt;</code> adds the name into the scope key:</p>
297
+ <pre><code class="language-bash">acpx codex sessions new <span class="hl-flag">--name</span> backend
298
+ acpx codex sessions new <span class="hl-flag">--name</span> docs
299
+ acpx codex <span class="hl-flag">-s</span> backend <span class="hl-str">&#39;fix the API pagination bug&#39;</span>
300
+ acpx codex <span class="hl-flag">-s</span> docs <span class="hl-str">&#39;rewrite the changelog&#39;</span></code></pre>
301
+ <p>Named sessions are independent. They do not share state, queue owners, or history.</p>
302
+ <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
+ <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
+ <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
+ <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>
307
+ <h2 id="soft-close"><a class="anchor" href="#soft-close" aria-label="Anchor link">#</a>Soft-close</h2>
308
+ <p><code>sessions close</code> does not delete anything. It marks the record <code>closed: true</code> with <code>closedAt</code>, asks any active queue owner to send ACP <code>session/close</code>, and tears down adapter processes.</p>
309
+ <p>Closing during a turn preserves its final cancellation output, usage and configuration updates in the closed record and history.</p>
310
+ <ul>
311
+ <li>Closed sessions stay on disk with their full record and history.</li>
312
+ <li>Auto-resume by scope skips closed sessions.</li>
313
+ <li>Closed sessions can still be loaded explicitly through embedding APIs.</li>
314
+ <li><code>sessions prune</code> is the explicit way to delete closed records.</li>
315
+ </ul>
316
+ <h2 id="export-import"><a class="anchor" href="#export-import" aria-label="Anchor link">#</a>Export / import</h2>
317
+ <p><code>acpx</code> persists sessions per cwd in <code>~/.acpx/sessions/</code>. To move a session between machines or share one with a teammate:</p>
318
+ <pre><code class="language-bash"><span class="hl-com"># On the source machine:</span>
319
+ acpx codex sessions export my-debug-session <span class="hl-flag">--output</span> debug.json
320
+
321
+ <span class="hl-com"># On the destination machine:</span>
322
+ acpx codex sessions import debug.json <span class="hl-flag">--name</span> debug-on-laptop</code></pre>
323
+ <p>Export refuses to run if the session is locked by a live queue owner. Run <code>acpx codex sessions close my-debug-session</code> first.</p>
324
+ <p>Exports preserve event order across rotated and active segments, including segments containing hundreds of thousands of events.</p>
325
+ <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
+ <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>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
+ <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
+ <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>
331
+ <p>Imports also coordinate with CLI and shared-runtime ensures for the same exact scope. If import publishes first, ensure returns that imported session. If ensure creates first, import reports the existing scope instead of publishing a second active record. This does not make explicit <code>sessions new</code> replacement atomic.</p>
332
+ <h2 id="prune"><a class="anchor" href="#prune" aria-label="Anchor link">#</a>Prune</h2>
333
+ <p><code>sessions prune</code> removes closed records once you actually want them gone:</p>
334
+ <pre><code class="language-bash"><span class="hl-com"># Preview what would be deleted</span>
335
+ acpx codex sessions prune <span class="hl-flag">--dry-run</span>
336
+
337
+ <span class="hl-com"># Delete closed sessions older than 30 days (by closeAt, falling back to lastUsedAt)</span>
338
+ acpx codex sessions prune <span class="hl-flag">--older-than</span> <span class="hl-num">30</span>
339
+
340
+ <span class="hl-com"># Delete closed sessions whose close time is before a date</span>
341
+ acpx codex sessions prune <span class="hl-flag">--before</span> <span class="hl-num">2026</span>-<span class="hl-num">01</span>-<span class="hl-num">01</span>
342
+
343
+ <span class="hl-com"># Also remove the per-session event-stream files</span>
344
+ acpx codex sessions prune <span class="hl-flag">--include-history</span></code></pre>
345
+ <p>Output:</p>
346
+ <ul>
347
+ <li><code>text</code> — summary plus the pruned ids and close/last-used time</li>
348
+ <li><code>json</code> — <code>{ action, dryRun, count, bytesFreed, pruned }</code></li>
349
+ <li><code>quiet</code> — one pruned session id per line</li>
350
+ </ul>
351
+ <h2 id="queue-ownership"><a class="anchor" href="#queue-ownership" aria-label="Anchor link">#</a>Queue ownership</h2>
352
+ <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
+ <pre><code class="language-bash">acpx codex <span class="hl-str">&#39;run full test suite and triage failures&#39;</span>
354
+ <span class="hl-com"># (still running)</span>
355
+ acpx codex <span class="hl-flag">--no-wait</span> <span class="hl-str">&#39;after the suite, summarize root cause in 3 bullets&#39;</span>
356
+ acpx codex <span class="hl-flag">--no-wait</span> <span class="hl-str">&#39;and propose 1 follow-up fix&#39;</span></code></pre>
357
+ <p>Queue mechanics:</p>
358
+ <ul>
359
+ <li>Startup options pass directly to the detached owner through stdin; acpx does not create temporary bootstrap files containing credentials or session environment values.</li>
360
+ <li>On Unix-like systems, the owner uses <code>/tmp/acpx-&lt;home-hash&gt;/&lt;session-hash&gt;.sock</code>; its lease is <code>~/.acpx/queues/&lt;session-hash&gt;.lock</code>. Windows uses a named pipe instead of a Unix socket.</li>
361
+ <li>Sockets and lock files are owner-only.</li>
362
+ <li>After the queue drains, the owner stays alive for an idle TTL (default <code>300s</code>) so quick follow-ups do not pay the spawn cost.</li>
363
+ <li>Override TTL with <code>--ttl &lt;seconds&gt;</code>. <code>--ttl 0</code> keeps it alive indefinitely (until idle shutdown is otherwise triggered).</li>
364
+ <li>Owner generation IDs are cryptographically random so rapid restarts cannot reuse a stale generation token.</li>
365
+ </ul>
366
+ <p>On Windows, forced queue-owner cleanup records observed descendants in the existing lease before terminating the process tree. If cleanup fails, a later client can retry it even after the owner exits. The lease remains pending until every recorded process incarnation is gone; unavailable process information or an invalid cleanup receipt leaves it intact and reports an error. Update all participating clients: older versions can discard this receipt when they refresh or release the lease. This recovery covers witnessed descendants. Abrupt death before observation still requires host supervision.</p>
367
+ <p>Persistent turns from flows and CLI prompts share one owner for each saved session. A waiting prompt reads history after the previous turn finishes its final checkpoint, so both completions are retained. Waiting can be cancelled or timed out. A live writer keeps ownership through its final checkpoint and cleanup. Competing processes recovering a dead writer remain serialized, and cancellation stops a waiting acquisition without releasing an admitted turn.</p>
368
+ <p>Turn ownership uses a private guard alongside the existing session marker. A guard with a definitely dead owner can be recovered; live owners never expire by age. Malformed guards and interrupted-reclamation residue fail closed and require cleanup only after all competing acpx processes have stopped. Older running acpx versions do not honor this guard, so the stronger exclusion applies when all participants use the updated version.</p>
369
+ <h2 id="no-wait"><a class="anchor" href="#no-wait" aria-label="Anchor link">#</a>--no-wait</h2>
370
+ <p>An independent client can follow retained and live prompt events with <a href="session-watch.html"><code>sessions watch</code></a>, including turns submitted with <code>--no-wait</code>.</p>
371
+ <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
+ <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
+ <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>
375
+ <p>The <code>cancel</code> subcommand sends the same cooperative cancel without a terminal signal:</p>
376
+ <pre><code class="language-bash">acpx codex cancel
377
+ acpx codex cancel <span class="hl-flag">-s</span> backend</code></pre>
378
+ <p>If nothing is running, <code>cancel</code> exits success with <code>nothing to cancel</code>.</p>
379
+ <p>See <a href="session-control.html">Session control</a> for <code>set-mode</code>, <code>set &lt;key&gt; &lt;value&gt;</code>, and <code>set model</code>.</p>
380
+ <h2 id="crash-recovery"><a class="anchor" href="#crash-recovery" aria-label="Anchor link">#</a>Crash recovery</h2>
381
+ <p>Saved sessions may include a cached adapter PID from the last connected helper process. That PID is a runtime hint, not proof that the logical session is closed or broken. If a cached PID is gone on the next prompt:</p>
382
+ <ol>
383
+ <li><code>acpx</code> respawns the agent.</li>
384
+ <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>
386
+ </ol>
387
+ <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
+ <h2 id="status"><a class="anchor" href="#status" aria-label="Anchor link">#</a>Status</h2>
389
+ <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>
391
+ <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
+ <h2 id="cwd-scoping"><a class="anchor" href="#cwd-scoping" aria-label="Anchor link">#</a>CWD scoping</h2>
393
+ <p><code>--cwd &lt;dir&gt;</code> sets both:</p>
394
+ <ul>
395
+ <li>the starting point for the directory-walk lookup</li>
396
+ <li>the exact <code>cwd</code> for new sessions created with <code>sessions new</code></li>
397
+ </ul>
398
+ <pre><code class="language-bash">acpx <span class="hl-flag">--cwd</span> ~/repos/shop codex sessions new <span class="hl-flag">--name</span> pr-<span class="hl-num">842</span>
399
+ acpx <span class="hl-flag">--cwd</span> ~/repos/shop codex <span class="hl-flag">-s</span> pr-<span class="hl-num">842</span> <span class="hl-str">&#39;review PR #842&#39;</span></code></pre>
400
+ <p>CWD is stored as an absolute path in the scope key.</p>
401
+ <h2 id="session-metadata-fields"><a class="anchor" href="#session-metadata-fields" aria-label="Anchor link">#</a>Session metadata fields</h2>
402
+ <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>Do not pass an <code>acpx</code> session id to a native provider CLI unless <code>agentSessionId</code> is also present.</p>
406
+ <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
+ <h2 id="embedded-session-lifecycle"><a class="anchor" href="#embedded-session-lifecycle" aria-label="Anchor link">#</a>Embedded session lifecycle</h2>
408
+ <p>Applications that need CLI processes to join the same live connection can use <a href="shared-sessions.html"><code>createSharedAcpRuntime()</code></a>. The shared client uses the CLI&#39;s local session store and queue owner; the in-process runtime below retains caller-owned storage and callbacks.</p>
409
+ <p>Embedding hosts can call <code>findSession({ sessionKey, agent })</code> on <code>acpx/runtime</code> to recover a persistent session handle after restart. It returns <code>undefined</code> when the record is absent, and does not start an agent or change the record. Existing closed records remain available. The handle uses the record&#39;s working directory and session identities. <code>getStatus({ handle }).lastRequestId</code> reports the last host request admitted to that session.</p>
410
+ <p>Compatible persistent <code>ensureSession()</code> calls can reuse a session during a turn; they keep its original creation options and do not rewrite live conversation state. Such reuse can also be awaited from host permission callbacks during a control reconnect. Changing the working directory, adapter command/arguments, or explicit resume identity requires the record&#39;s turns and controls to finish. An incompatible ensure rejects with <code>ACP_SESSION_INIT_FAILED</code> while work is unfinished, without cancelling or rerouting it. Wait for that work to finish, or use another session key. An active close must also finish its turn before ensure can reopen that record.</p>
411
+ <p>Idle replacement waits for the old connection and pending saves to retire before initializing its successor. Retirement failure rejects replacement and leaves cleanup available for retry. Turns and controls on that same record wait for initialization; other records, including distinct one-shot records, remain independent. A one-shot ensure whose previously pending owner has closed creates a fresh record.</p>
412
+ <p>Pending one-shot reuse ignores undefined option fields and empty environment maps. An explicit empty tool list still differs from omitted tools. Ensuring again after a one-shot turn completes creates a fresh record.</p>
413
+ <p>For retained sessions, status and session operations retry pending checkpoint data after storage recovers. Checkpoint retry saves current state without replaying the agent request.</p>
414
+ <p>Call <code>shutdown()</code> when retiring a runtime. It cancels active prompts, closes owned connections, and waits for admitted work and probes to finish. This includes terminal requests that have started a child process but have not yet returned. New sessions, turns, controls and probes then reject. Stored sessions remain available for a new runtime to resume. Hosts must still settle their own pending lifecycle admission callbacks; shutdown cannot complete an external host operation.</p>
415
+ <p>Shutdown reports connection and checkpoint cleanup failures after all owned cleanup has finished. A later cleanup save can recover data while an earlier failure in that shutdown attempt still causes rejection. Earlier admitted operations keep their own results; shutdown can recover a previously failed retirement in its final cleanup pass. Repeated calls share the same shutdown result.</p>
416
+ <p>For temporary model inspection, use <code>ensureSession({ mode: &quot;oneshot&quot;, ... })</code>, <code>getStatus({ handle })</code>, and <code>close({ handle, discardPersistentState: true, ... })</code>. Close requests ACP <code>session/close</code> and marks the host record closed for reset on the next ensure. It does not delete that record or promise removal of an agent&#39;s private session files.</p>
417
+ <h2 id="see-also"><a class="anchor" href="#see-also" aria-label="Anchor link">#</a>See also</h2>
418
+ <ul>
419
+ <li><a href="prompting.html">Prompting</a> — implicit prompt, <code>prompt</code>, <code>exec</code>, stdin, <code>--file</code>, <code>--no-wait</code>.</li>
420
+ <li><a href="session-control.html">Session control</a> — <code>cancel</code>, <code>set-mode</code>, <code>set &lt;key&gt;</code>, <code>set model</code>.</li>
421
+ <li><a href="output-formats.html">Output formats</a> — JSON envelope for sessions/status payloads.</li>
422
+ <li><a href="CLI.html#sessions-subcommand">CLI reference</a> — long-form spec and exit codes.</li>
423
+ </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>
425
+ <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
+ </div>
427
+ </main>
428
+ </div>
429
+ <script>
430
+ const themeRoot=document.documentElement;
431
+ function applyTheme(mode){themeRoot.dataset.theme=mode;document.querySelectorAll('[data-theme-toggle]').forEach(b=>b.setAttribute('aria-pressed',mode==='dark'?'true':'false'))}
432
+ function storedTheme(){try{return localStorage.getItem('theme')}catch(e){return null}}
433
+ function persistTheme(mode){try{localStorage.setItem('theme',mode)}catch(e){}}
434
+ applyTheme(themeRoot.dataset.theme==='dark'?'dark':'light');
435
+ document.querySelectorAll('[data-theme-toggle]').forEach(btn=>{btn.addEventListener('click',()=>{const next=themeRoot.dataset.theme==='dark'?'light':'dark';applyTheme(next);persistTheme(next)})});
436
+ const systemDark=window.matchMedia&&matchMedia('(prefers-color-scheme: dark)');
437
+ function onSystemChange(e){if(storedTheme())return;applyTheme(e.matches?'dark':'light')}
438
+ if(systemDark){if(systemDark.addEventListener)systemDark.addEventListener('change',onSystemChange);else if(systemDark.addListener)systemDark.addListener(onSystemChange)}
439
+ const sidebar=document.querySelector('.sidebar');
440
+ const toggle=document.querySelector('.nav-toggle');
441
+ const mobileNav=window.matchMedia('(max-width: 900px)');
442
+ const sidebarFocusable='a[href],button,input,select,textarea,[tabindex]';
443
+ function setSidebarFocusable(enabled){
444
+ sidebar?.querySelectorAll(sidebarFocusable).forEach((el)=>{
445
+ if(enabled){
446
+ if(el.dataset.sidebarTabindex!==undefined){
447
+ if(el.dataset.sidebarTabindex)el.setAttribute('tabindex',el.dataset.sidebarTabindex);
448
+ else el.removeAttribute('tabindex');
449
+ delete el.dataset.sidebarTabindex;
450
+ }
451
+ }else if(el.dataset.sidebarTabindex===undefined){
452
+ el.dataset.sidebarTabindex=el.getAttribute('tabindex')??'';
453
+ el.setAttribute('tabindex','-1');
454
+ }
455
+ });
456
+ }
457
+ function setSidebarOpen(open){
458
+ if(!sidebar||!toggle)return;
459
+ sidebar.classList.toggle('open',open);
460
+ toggle.setAttribute('aria-expanded',open?'true':'false');
461
+ if(mobileNav.matches){
462
+ sidebar.inert=!open;
463
+ if(open)sidebar.removeAttribute('aria-hidden');
464
+ else sidebar.setAttribute('aria-hidden','true');
465
+ setSidebarFocusable(open);
466
+ }else{
467
+ sidebar.inert=false;
468
+ sidebar.removeAttribute('aria-hidden');
469
+ setSidebarFocusable(true);
470
+ }
471
+ }
472
+ setSidebarOpen(false);
473
+ toggle?.addEventListener('click',()=>setSidebarOpen(!sidebar?.classList.contains('open')));
474
+ document.addEventListener('click',(e)=>{if(!sidebar?.classList.contains('open'))return;if(sidebar.contains(e.target)||toggle?.contains(e.target))return;setSidebarOpen(false)});
475
+ document.addEventListener('keydown',(e)=>{if(e.key==='Escape')setSidebarOpen(false)});
476
+ const syncSidebarForViewport=()=>setSidebarOpen(sidebar?.classList.contains('open')??false);
477
+ if(mobileNav.addEventListener)mobileNav.addEventListener('change',syncSidebarForViewport);
478
+ else mobileNav.addListener?.(syncSidebarForViewport);
479
+ const input=document.getElementById('doc-search');
480
+ input?.addEventListener('input',()=>{const q=input.value.trim().toLowerCase();document.querySelectorAll('nav section').forEach(sec=>{let any=false;sec.querySelectorAll('.nav-link').forEach(a=>{const m=!q||a.textContent.toLowerCase().includes(q);a.style.display=m?'block':'none';if(m)any=true});sec.style.display=any?'block':'none'})});
481
+ function attachCopy(target,getText){const btn=document.createElement('button');btn.type='button';btn.className='copy';btn.textContent='Copy';btn.addEventListener('click',async()=>{try{await navigator.clipboard.writeText(getText());btn.textContent='Copied';btn.classList.add('copied');setTimeout(()=>{btn.textContent='Copy';btn.classList.remove('copied')},1400)}catch{btn.textContent='Failed';setTimeout(()=>{btn.textContent='Copy'},1400)}});target.appendChild(btn)}
482
+ document.querySelectorAll('.doc pre').forEach(pre=>attachCopy(pre,()=>pre.querySelector('code')?.textContent??''));
483
+ document.querySelectorAll('.home-install').forEach(el=>attachCopy(el,()=>el.querySelector('code')?.textContent??''));
484
+ const tocLinks=document.querySelectorAll('.toc a');
485
+ if(tocLinks.length){const map=new Map();tocLinks.forEach(a=>{const id=a.getAttribute('href').slice(1);const el=document.getElementById(id);if(el)map.set(el,a)});const setActive=l=>{tocLinks.forEach(x=>x.classList.remove('active'));l.classList.add('active')};const obs=new IntersectionObserver(entries=>{const visible=entries.filter(e=>e.isIntersecting).sort((a,b)=>a.boundingClientRect.top-b.boundingClientRect.top);if(visible.length){const link=map.get(visible[0].target);if(link)setActive(link)}},{rootMargin:'-15% 0px -65% 0px',threshold:0});map.forEach((_,el)=>obs.observe(el))}
486
+ </script>
487
+ </body>
488
+ </html>