@bastani/atomic 0.10.1 → 0.10.2-alpha.1

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 (295) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  3. package/dist/builtin/intercom/broker/watchdog.ts +4 -0
  4. package/dist/builtin/intercom/package.json +1 -1
  5. package/dist/builtin/mcp/package.json +1 -1
  6. package/dist/builtin/subagents/CHANGELOG.md +16 -0
  7. package/dist/builtin/subagents/README.md +2 -0
  8. package/dist/builtin/subagents/package.json +1 -1
  9. package/dist/builtin/subagents/skills/subagent/SKILL.md +3 -3
  10. package/dist/builtin/subagents/src/extension/index.bundle.mjs +269 -144
  11. package/dist/builtin/web-access/CHANGELOG.md +7 -0
  12. package/dist/builtin/web-access/index.bundle.mjs +9 -5
  13. package/dist/builtin/web-access/package.json +1 -1
  14. package/dist/cli/list-models.d.ts.map +1 -1
  15. package/dist/cli/list-models.js +1 -14
  16. package/dist/cli/list-models.js.map +1 -1
  17. package/dist/core/agent-session-export.d.ts.map +1 -1
  18. package/dist/core/agent-session-export.js +13 -9
  19. package/dist/core/agent-session-export.js.map +1 -1
  20. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  21. package/dist/core/agent-session-message-queue.js +6 -3
  22. package/dist/core/agent-session-message-queue.js.map +1 -1
  23. package/dist/core/agent-session-methods.d.ts +3 -0
  24. package/dist/core/agent-session-methods.d.ts.map +1 -1
  25. package/dist/core/agent-session-methods.js.map +1 -1
  26. package/dist/core/agent-session-nested-tools.d.ts.map +1 -1
  27. package/dist/core/agent-session-nested-tools.js +2 -1
  28. package/dist/core/agent-session-nested-tools.js.map +1 -1
  29. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  30. package/dist/core/agent-session-prompt.js +12 -0
  31. package/dist/core/agent-session-prompt.js.map +1 -1
  32. package/dist/core/agent-session-state.d.ts +6 -0
  33. package/dist/core/agent-session-state.d.ts.map +1 -1
  34. package/dist/core/agent-session-state.js +71 -4
  35. package/dist/core/agent-session-state.js.map +1 -1
  36. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  37. package/dist/core/agent-session-tool-hooks.js +9 -1
  38. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  39. package/dist/core/agent-session-types.d.ts +2 -0
  40. package/dist/core/agent-session-types.d.ts.map +1 -1
  41. package/dist/core/agent-session-types.js.map +1 -1
  42. package/dist/core/agent-session.d.ts +3 -0
  43. package/dist/core/agent-session.d.ts.map +1 -1
  44. package/dist/core/agent-session.js +7 -0
  45. package/dist/core/agent-session.js.map +1 -1
  46. package/dist/core/cache-stats.d.ts +15 -0
  47. package/dist/core/cache-stats.d.ts.map +1 -1
  48. package/dist/core/cache-stats.js +40 -2
  49. package/dist/core/cache-stats.js.map +1 -1
  50. package/dist/core/diagnostic-writer.d.ts.map +1 -1
  51. package/dist/core/diagnostic-writer.js +2 -1
  52. package/dist/core/diagnostic-writer.js.map +1 -1
  53. package/dist/core/export-html/template.js +14 -4
  54. package/dist/core/extensions/context-types.d.ts +6 -0
  55. package/dist/core/extensions/context-types.d.ts.map +1 -1
  56. package/dist/core/extensions/context-types.js.map +1 -1
  57. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  58. package/dist/core/extensions/loader-api.js +5 -2
  59. package/dist/core/extensions/loader-api.js.map +1 -1
  60. package/dist/core/queued-message-delivery.d.ts +100 -7
  61. package/dist/core/queued-message-delivery.d.ts.map +1 -1
  62. package/dist/core/queued-message-delivery.js +194 -4
  63. package/dist/core/queued-message-delivery.js.map +1 -1
  64. package/dist/core/resume-cache-checkpoint.d.ts +32 -0
  65. package/dist/core/resume-cache-checkpoint.d.ts.map +1 -0
  66. package/dist/core/resume-cache-checkpoint.js +67 -0
  67. package/dist/core/resume-cache-checkpoint.js.map +1 -0
  68. package/dist/core/sdk-types.d.ts +37 -0
  69. package/dist/core/sdk-types.d.ts.map +1 -1
  70. package/dist/core/sdk-types.js.map +1 -1
  71. package/dist/core/sdk.d.ts.map +1 -1
  72. package/dist/core/sdk.js +57 -28
  73. package/dist/core/sdk.js.map +1 -1
  74. package/dist/core/session-manager-core.d.ts.map +1 -1
  75. package/dist/core/session-manager-core.js +12 -3
  76. package/dist/core/session-manager-core.js.map +1 -1
  77. package/dist/core/session-manager-entries.d.ts +13 -0
  78. package/dist/core/session-manager-entries.d.ts.map +1 -1
  79. package/dist/core/session-manager-entries.js +38 -6
  80. package/dist/core/session-manager-entries.js.map +1 -1
  81. package/dist/core/settings-lock-directory.d.ts.map +1 -1
  82. package/dist/core/settings-lock-directory.js +2 -1
  83. package/dist/core/settings-lock-directory.js.map +1 -1
  84. package/dist/core/storage/node-sqlite-file-gate.d.ts +173 -0
  85. package/dist/core/storage/node-sqlite-file-gate.d.ts.map +1 -0
  86. package/dist/core/storage/node-sqlite-file-gate.js +1033 -0
  87. package/dist/core/storage/node-sqlite-file-gate.js.map +1 -0
  88. package/dist/core/storage/node-sqlite-thread.d.ts +33 -6
  89. package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -1
  90. package/dist/core/storage/node-sqlite-thread.js +72 -2
  91. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  92. package/dist/core/storage/node-sqlite.d.ts.map +1 -1
  93. package/dist/core/storage/node-sqlite.js +216 -15
  94. package/dist/core/storage/node-sqlite.js.map +1 -1
  95. package/dist/core/storage/session/entry-structure.d.ts.map +1 -1
  96. package/dist/core/storage/session/entry-structure.js +39 -2
  97. package/dist/core/storage/session/entry-structure.js.map +1 -1
  98. package/dist/core/storage/session/session-resume.d.ts.map +1 -1
  99. package/dist/core/storage/session/session-resume.js +1 -0
  100. package/dist/core/storage/session/session-resume.js.map +1 -1
  101. package/dist/core/storage/session/session-search-index.d.ts.map +1 -1
  102. package/dist/core/storage/session/session-search-index.js +56 -9
  103. package/dist/core/storage/session/session-search-index.js.map +1 -1
  104. package/dist/core/storage/statement-sequence.d.ts +36 -0
  105. package/dist/core/storage/statement-sequence.d.ts.map +1 -0
  106. package/dist/core/storage/statement-sequence.js +22 -0
  107. package/dist/core/storage/statement-sequence.js.map +1 -0
  108. package/dist/core/system-prompt.d.ts.map +1 -1
  109. package/dist/core/system-prompt.js +13 -4
  110. package/dist/core/system-prompt.js.map +1 -1
  111. package/dist/core/tasks/heartbeat-notice.d.ts.map +1 -1
  112. package/dist/core/tasks/heartbeat-notice.js +2 -1
  113. package/dist/core/tasks/heartbeat-notice.js.map +1 -1
  114. package/dist/core/tool-loadout.d.ts +4 -2
  115. package/dist/core/tool-loadout.d.ts.map +1 -1
  116. package/dist/core/tool-loadout.js +27 -5
  117. package/dist/core/tool-loadout.js.map +1 -1
  118. package/dist/core/tools/history-regex-worker.d.ts.map +1 -1
  119. package/dist/core/tools/history-regex-worker.js +2 -1
  120. package/dist/core/tools/history-regex-worker.js.map +1 -1
  121. package/dist/core/tools/powershell.d.ts +22 -22
  122. package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
  123. package/dist/core/tools/sqlite-selector-connection.js +7 -0
  124. package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
  125. package/dist/core/transformed-system-prompt.d.ts +92 -0
  126. package/dist/core/transformed-system-prompt.d.ts.map +1 -0
  127. package/dist/core/transformed-system-prompt.js +240 -0
  128. package/dist/core/transformed-system-prompt.js.map +1 -0
  129. package/dist/extensions/codemode/execute.js +1 -1
  130. package/dist/extensions/codemode/execute.js.map +1 -1
  131. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  132. package/dist/extensions/codemode/tool.js +16 -3
  133. package/dist/extensions/codemode/tool.js.map +1 -1
  134. package/dist/extensions/llama/ui.d.ts.map +1 -1
  135. package/dist/extensions/llama/ui.js +13 -8
  136. package/dist/extensions/llama/ui.js.map +1 -1
  137. package/dist/extensions/mcp/config.d.ts +2 -0
  138. package/dist/extensions/mcp/config.d.ts.map +1 -1
  139. package/dist/extensions/mcp/config.js +5 -0
  140. package/dist/extensions/mcp/config.js.map +1 -1
  141. package/dist/extensions/mcp/index.d.ts +4 -0
  142. package/dist/extensions/mcp/index.d.ts.map +1 -1
  143. package/dist/extensions/mcp/index.js +289 -64
  144. package/dist/extensions/mcp/index.js.map +1 -1
  145. package/dist/extensions/mcp/runtime.d.ts +1 -1
  146. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  147. package/dist/extensions/mcp/runtime.js +2 -2
  148. package/dist/extensions/mcp/runtime.js.map +1 -1
  149. package/dist/extensions/mcp/tool-records.d.ts +58 -0
  150. package/dist/extensions/mcp/tool-records.d.ts.map +1 -0
  151. package/dist/extensions/mcp/tool-records.js +129 -0
  152. package/dist/extensions/mcp/tool-records.js.map +1 -0
  153. package/dist/index.d.ts +1 -0
  154. package/dist/index.d.ts.map +1 -1
  155. package/dist/index.js +1 -0
  156. package/dist/index.js.map +1 -1
  157. package/dist/modes/interactive/components/agent-panel.d.ts +2 -4
  158. package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
  159. package/dist/modes/interactive/components/agent-panel.js +65 -80
  160. package/dist/modes/interactive/components/agent-panel.js.map +1 -1
  161. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  162. package/dist/modes/interactive/components/compaction-boundary-message.js +3 -3
  163. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  164. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  165. package/dist/modes/interactive/components/footer.js +35 -28
  166. package/dist/modes/interactive/components/footer.js.map +1 -1
  167. package/dist/modes/interactive/components/notice-line.d.ts +16 -0
  168. package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
  169. package/dist/modes/interactive/components/notice-line.js +7 -0
  170. package/dist/modes/interactive/components/notice-line.js.map +1 -1
  171. package/dist/modes/interactive/components/prompt-slot.d.ts +1 -0
  172. package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -1
  173. package/dist/modes/interactive/components/prompt-slot.js +8 -4
  174. package/dist/modes/interactive/components/prompt-slot.js.map +1 -1
  175. package/dist/modes/interactive/components/task-board.d.ts +0 -1
  176. package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
  177. package/dist/modes/interactive/components/task-board.js +6 -14
  178. package/dist/modes/interactive/components/task-board.js.map +1 -1
  179. package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
  180. package/dist/modes/interactive/components/task-row.js +7 -6
  181. package/dist/modes/interactive/components/task-row.js.map +1 -1
  182. package/dist/modes/interactive/components/token-segment.d.ts +2 -1
  183. package/dist/modes/interactive/components/token-segment.d.ts.map +1 -1
  184. package/dist/modes/interactive/components/token-segment.js +2 -4
  185. package/dist/modes/interactive/components/token-segment.js.map +1 -1
  186. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  187. package/dist/modes/interactive/components/tree-selector-content.js +2 -2
  188. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  189. package/dist/modes/interactive/components/working-run-meter.d.ts +0 -1
  190. package/dist/modes/interactive/components/working-run-meter.d.ts.map +1 -1
  191. package/dist/modes/interactive/components/working-run-meter.js +0 -9
  192. package/dist/modes/interactive/components/working-run-meter.js.map +1 -1
  193. package/dist/modes/interactive/extension-command-hold.d.ts +25 -0
  194. package/dist/modes/interactive/extension-command-hold.d.ts.map +1 -0
  195. package/dist/modes/interactive/extension-command-hold.js +45 -0
  196. package/dist/modes/interactive/extension-command-hold.js.map +1 -0
  197. package/dist/modes/interactive/interactive-agent-events.js +2 -1
  198. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  199. package/dist/modes/interactive/interactive-extension-context.js +18 -10
  200. package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
  201. package/dist/modes/interactive/interactive-extension-custom-ui.js +3 -0
  202. package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
  203. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  204. package/dist/modes/interactive/interactive-input-handling.js +54 -13
  205. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  206. package/dist/modes/interactive/interactive-model-routing.d.ts +6 -0
  207. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  208. package/dist/modes/interactive/interactive-model-routing.js +15 -9
  209. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  210. package/dist/modes/interactive/interactive-prompt-turn.js +4 -0
  211. package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
  212. package/dist/modes/interactive/interactive-queueing.d.ts +7 -0
  213. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  214. package/dist/modes/interactive/interactive-queueing.js +47 -1
  215. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  216. package/dist/modes/interactive/interactive-session-routing.js +6 -0
  217. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  218. package/dist/modes/interactive/interactive-slash-commands.js +165 -65
  219. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  220. package/dist/modes/interactive/screen-hold.d.ts +3 -0
  221. package/dist/modes/interactive/screen-hold.d.ts.map +1 -1
  222. package/dist/modes/interactive/screen-hold.js +9 -1
  223. package/dist/modes/interactive/screen-hold.js.map +1 -1
  224. package/dist/modes/interactive-engine/engine-health.d.ts +11 -3
  225. package/dist/modes/interactive-engine/engine-health.d.ts.map +1 -1
  226. package/dist/modes/interactive-engine/engine-health.js +5 -4
  227. package/dist/modes/interactive-engine/engine-health.js.map +1 -1
  228. package/dist/modes/interactive-engine/engine-quit-intent.d.ts +7 -0
  229. package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
  230. package/dist/modes/interactive-engine/engine-quit-intent.js +19 -0
  231. package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
  232. package/dist/modes/interactive-engine/isolated-runtime.d.ts +18 -0
  233. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  234. package/dist/modes/interactive-engine/isolated-runtime.js +56 -4
  235. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  236. package/dist/modes/interactive-engine/protocol.d.ts +7 -0
  237. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  238. package/dist/modes/interactive-engine/protocol.js +1 -0
  239. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  240. package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
  241. package/dist/modes/rpc/agent-panel-bridge.js +0 -13
  242. package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
  243. package/dist/modes/rpc/rpc-client-process.d.ts +14 -1
  244. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  245. package/dist/modes/rpc/rpc-client-process.js +74 -10
  246. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  247. package/dist/modes/rpc/rpc-client.d.ts +27 -1
  248. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  249. package/dist/modes/rpc/rpc-client.js +81 -5
  250. package/dist/modes/rpc/rpc-client.js.map +1 -1
  251. package/dist/modes/rpc/rpc-event-buffer.d.ts +2 -0
  252. package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
  253. package/dist/modes/rpc/rpc-event-buffer.js +9 -0
  254. package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
  255. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  256. package/dist/modes/rpc/rpc-mode.js +16 -3
  257. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  258. package/dist/modes/rpc/rpc-session-binding.d.ts +7 -1
  259. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  260. package/dist/modes/rpc/rpc-session-binding.js +10 -2
  261. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  262. package/dist/utils/image-resize.d.ts.map +1 -1
  263. package/dist/utils/image-resize.js +2 -1
  264. package/dist/utils/image-resize.js.map +1 -1
  265. package/dist/utils/interactive-engine-bootstrap.d.ts +2 -0
  266. package/dist/utils/interactive-engine-bootstrap.d.ts.map +1 -1
  267. package/dist/utils/interactive-engine-bootstrap.js +1 -0
  268. package/dist/utils/interactive-engine-bootstrap.js.map +1 -1
  269. package/dist/utils/interactive-engine-env.d.ts +2 -0
  270. package/dist/utils/interactive-engine-env.d.ts.map +1 -1
  271. package/dist/utils/interactive-engine-env.js +1 -0
  272. package/dist/utils/interactive-engine-env.js.map +1 -1
  273. package/dist/utils/shell.d.ts.map +1 -1
  274. package/dist/utils/shell.js +2 -0
  275. package/dist/utils/shell.js.map +1 -1
  276. package/dist/utils/token-count.d.ts +8 -0
  277. package/dist/utils/token-count.d.ts.map +1 -0
  278. package/dist/utils/token-count.js +25 -0
  279. package/dist/utils/token-count.js.map +1 -0
  280. package/dist/utils/worker-threads.d.ts +18 -0
  281. package/dist/utils/worker-threads.d.ts.map +1 -0
  282. package/dist/utils/worker-threads.js +28 -0
  283. package/dist/utils/worker-threads.js.map +1 -0
  284. package/docs/background-tasks.md +13 -12
  285. package/docs/compaction.md +2 -2
  286. package/docs/development.md +1 -1
  287. package/docs/extensions/api-reference.md +5 -3
  288. package/docs/extensions/events.md +2 -0
  289. package/docs/mcp-servers.md +1 -1
  290. package/docs/settings.md +2 -0
  291. package/docs/storage.md +3 -1
  292. package/docs/subagents.md +6 -2
  293. package/docs/usage.md +1 -1
  294. package/npm-shrinkwrap.json +49 -49
  295. package/package.json +6 -6
@@ -1,3 +1,4 @@
1
+ import { createInterface } from "node:readline";
1
2
  import { createCacheMissModelSource, formatCacheWaste } from "../../core/cache-stats.js";
2
3
  import { formatResumeTimings, latestResumeTimings } from "../../core/resume/timings.js";
3
4
  import { readSessionUsageDetails, sessionUsageDetails, } from "../../core/session-usage-details.js";
@@ -192,105 +193,204 @@ InteractiveModeBase.prototype.handleImportCommand = async function (text) {
192
193
  }
193
194
  };
194
195
  const GH_AUTH_STATUS_TIMEOUT_MS = 30_000;
195
- function ghAuthStatus() {
196
+ /** How long a cancelled gh process gets to exit after it is asked to before it is killed. */
197
+ const GH_CANCEL_GRACE_MS = 2_000;
198
+ /** Stop a gh process the user cancelled: ask it to exit, and kill it if it is still running after the grace period. */
199
+ function stopGh(child) {
200
+ child.kill();
201
+ const timer = setTimeout(() => {
202
+ if (child.exitCode === null && child.signalCode === null)
203
+ child.kill("SIGKILL");
204
+ }, GH_CANCEL_GRACE_MS);
205
+ timer.unref?.();
206
+ child.once("close", () => clearTimeout(timer));
207
+ }
208
+ /** The session id in the header, the first line, of the exported session file `file`. */
209
+ async function exportedSessionId(file) {
210
+ const input = fs.createReadStream(file, { encoding: "utf8" });
211
+ const lines = createInterface({ input, crlfDelay: Number.POSITIVE_INFINITY });
212
+ try {
213
+ for await (const line of lines) {
214
+ const header = JSON.parse(line);
215
+ return typeof header.id === "string" ? header.id : undefined;
216
+ }
217
+ return undefined;
218
+ }
219
+ catch {
220
+ return undefined;
221
+ }
222
+ finally {
223
+ lines.close();
224
+ input.destroy();
225
+ }
226
+ }
227
+ /** Run `gh auth status`; `started` receives the child, so a cancel can stop it. */
228
+ function ghAuthStatus(started) {
196
229
  return new Promise((resolve) => {
197
230
  const child = spawn("gh", ["auth", "status"], {
198
231
  env: createChildProcessEnvironment(),
199
232
  stdio: "ignore",
200
233
  timeout: GH_AUTH_STATUS_TIMEOUT_MS,
201
234
  });
235
+ started(child);
202
236
  child.once("error", () => resolve(null));
203
237
  child.once("close", (code) => resolve(code));
204
238
  });
205
239
  }
206
240
  InteractiveModeBase.prototype.handleShareCommand = async function () {
207
- // Check if gh is available and logged in
208
- try {
209
- if ((await ghAuthStatus()) !== 0) {
210
- this.showError("GitHub CLI is not logged in. Run 'gh auth login' first.");
211
- return;
212
- }
213
- }
214
- catch {
215
- this.showError("GitHub CLI (gh) is not installed. Install it from https://cli.github.com/");
216
- return;
217
- }
218
- // Share an export-only JSONL copy carrying context for the viewer. The
219
- // persisted session is not mutated.
220
- const tempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "atomic-share-"));
221
- const tmpFile = path.join(tempDir, "session.jsonl");
222
- try {
223
- await this.session.exportToJsonl(tmpFile, {
224
- includeShareContext: true,
225
- snapshotContent: false,
226
- toolOutputContent: false,
227
- });
228
- }
229
- catch (error) {
230
- await fs.promises.rm(tempDir, { recursive: true, force: true });
231
- this.showError(`Failed to export session: ${error instanceof Error ? error.message : "Unknown error"}`);
232
- return;
233
- }
234
- // Show cancellable loader, replacing the editor
241
+ // The session to share is the one shown when the command was given.
242
+ const session = this.session;
243
+ const sessionId = session.sessionManager.getSessionId();
244
+ // The cancellable loader takes the prompt's place at once: checking gh and exporting the session take a while.
235
245
  const loader = new BorderedLoader(this.ui, theme, "Creating gist...");
236
246
  this.editorContainer.clear();
237
247
  this.editorContainer.addChild(loader);
238
248
  this.ui.setFocus(loader);
239
249
  this.ui.requestRender();
250
+ let restored = false;
240
251
  const restoreEditor = () => {
252
+ if (restored)
253
+ return;
254
+ restored = true;
241
255
  loader.dispose();
256
+ // A view that has taken the loader's place since keeps it.
257
+ if (!this.editorContainer.children.includes(loader))
258
+ return;
242
259
  this.editorContainer.clear();
243
260
  this.editorContainer.addChild(this.editor);
244
261
  this.ui.setFocus(this.editor);
245
- fs.promises.rm(tempDir, { recursive: true, force: true }).catch(() => {
246
- // Ignore cleanup errors
247
- });
262
+ this.ui.requestRender();
248
263
  };
249
- // Create a secret gist asynchronously
250
- let proc = null;
264
+ // The gh process running now, which a cancel stops.
265
+ let proc;
251
266
  loader.onAbort = () => {
252
- proc?.kill();
267
+ if (proc !== undefined)
268
+ stopGh(proc);
253
269
  restoreEditor();
254
270
  this.showStatus("Share cancelled");
255
271
  };
272
+ const cancelled = () => loader.signal.aborted;
273
+ // Another session took this one's place before it was exported, or while it was: neither is shared.
274
+ const sessionChanged = () => {
275
+ restoreEditor();
276
+ this.showStatus("Share cancelled: the session changed");
277
+ };
278
+ const replaced = () => {
279
+ if (cancelled() || (this.session === session && session.sessionManager.getSessionId() === sessionId))
280
+ return false;
281
+ sessionChanged();
282
+ return true;
283
+ };
284
+ // Each step is awaited before the next, also after a cancel, so the directory is removed only once nothing writes
285
+ // into it any more.
286
+ let tempDir;
256
287
  try {
257
- const result = await new Promise((resolve) => {
258
- proc = spawn("gh", ["gist", "create", "--public=false", tmpFile], { env: createChildProcessEnvironment() });
259
- let stdout = "";
260
- let stderr = "";
261
- proc.stdout?.on("data", (data) => {
262
- stdout += data.toString();
263
- });
264
- proc.stderr?.on("data", (data) => {
265
- stderr += data.toString();
288
+ // Check if gh is available and logged in
289
+ try {
290
+ const status = await ghAuthStatus((child) => {
291
+ proc = child;
266
292
  });
267
- proc.on("error", (error) => resolve({ stdout, stderr: stderr || error.message, code: null }));
268
- proc.on("close", (code) => resolve({ stdout, stderr, code }));
269
- });
270
- if (loader.signal.aborted)
293
+ proc = undefined;
294
+ if (cancelled() || replaced())
295
+ return;
296
+ if (status !== 0) {
297
+ restoreEditor();
298
+ this.showError("GitHub CLI is not logged in. Run 'gh auth login' first.");
299
+ return;
300
+ }
301
+ }
302
+ catch {
303
+ proc = undefined;
304
+ if (cancelled())
305
+ return;
306
+ restoreEditor();
307
+ this.showError("GitHub CLI (gh) is not installed. Install it from https://cli.github.com/");
271
308
  return;
272
- restoreEditor();
273
- if (result.code !== 0) {
274
- const errorMsg = result.stderr?.trim() || "Unknown error";
275
- this.showError(`Failed to create gist: ${errorMsg}`);
309
+ }
310
+ // Share an export-only JSONL copy carrying context for the viewer. The
311
+ // persisted session is not mutated.
312
+ tempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "atomic-share-"));
313
+ if (cancelled() || replaced())
276
314
  return;
315
+ const tmpFile = path.join(tempDir, "session.jsonl");
316
+ try {
317
+ await session.exportToJsonl(tmpFile, {
318
+ includeShareContext: true,
319
+ snapshotContent: false,
320
+ toolOutputContent: false,
321
+ });
277
322
  }
278
- // Extract gist ID from the URL returned by gh
279
- // gh returns something like: https://gist.github.com/username/GIST_ID
280
- const gistUrl = result.stdout?.trim();
281
- const gistId = gistUrl?.split("/").pop();
282
- if (!gistId) {
283
- this.showError("Failed to parse gist ID from gh output");
323
+ catch (error) {
324
+ if (cancelled())
325
+ return;
326
+ restoreEditor();
327
+ this.showError(`Failed to export session: ${error instanceof Error ? error.message : "Unknown error"}`);
284
328
  return;
285
329
  }
286
- // Create the preview URL
287
- const previewUrl = getShareViewerUrl(gistId);
288
- this.showStatus(`Share URL: ${hyperlink(previewUrl, previewUrl)}\nGist: ${hyperlink(gistUrl, gistUrl)}`);
289
- }
290
- catch (error) {
291
- if (!loader.signal.aborted) {
330
+ if (cancelled() || replaced())
331
+ return;
332
+ // The file holds the session asked for, whatever changed on the way: another never leaves under its name.
333
+ const exportedId = await exportedSessionId(tmpFile);
334
+ if (cancelled())
335
+ return;
336
+ if (exportedId !== sessionId) {
337
+ sessionChanged();
338
+ return;
339
+ }
340
+ // Create a secret gist
341
+ try {
342
+ const result = await new Promise((resolve) => {
343
+ const child = spawn("gh", ["gist", "create", "--public=false", tmpFile], {
344
+ env: createChildProcessEnvironment(),
345
+ });
346
+ proc = child;
347
+ let stdout = "";
348
+ let stderr = "";
349
+ child.stdout?.on("data", (data) => {
350
+ stdout += data.toString();
351
+ });
352
+ child.stderr?.on("data", (data) => {
353
+ stderr += data.toString();
354
+ });
355
+ child.on("error", (error) => resolve({ stdout, stderr: stderr || error.message, code: null }));
356
+ child.on("close", (code) => resolve({ stdout, stderr, code }));
357
+ });
358
+ proc = undefined;
359
+ if (cancelled())
360
+ return;
292
361
  restoreEditor();
293
- this.showError(`Failed to create gist: ${error instanceof Error ? error.message : "Unknown error"}`);
362
+ if (result.code !== 0) {
363
+ const errorMsg = result.stderr?.trim() || "Unknown error";
364
+ this.showError(`Failed to create gist: ${errorMsg}`);
365
+ return;
366
+ }
367
+ // Extract gist ID from the URL returned by gh
368
+ // gh returns something like: https://gist.github.com/username/GIST_ID
369
+ const gistUrl = result.stdout?.trim();
370
+ const gistId = gistUrl?.split("/").pop();
371
+ if (!gistId) {
372
+ this.showError("Failed to parse gist ID from gh output");
373
+ return;
374
+ }
375
+ // Create the preview URL
376
+ const previewUrl = getShareViewerUrl(gistId);
377
+ this.showStatus(`Share URL: ${hyperlink(previewUrl, previewUrl)}\nGist: ${hyperlink(gistUrl, gistUrl)}`);
378
+ }
379
+ catch (error) {
380
+ proc = undefined;
381
+ if (!cancelled()) {
382
+ restoreEditor();
383
+ this.showError(`Failed to create gist: ${error instanceof Error ? error.message : "Unknown error"}`);
384
+ }
385
+ }
386
+ }
387
+ finally {
388
+ // Whatever ended the share, the prompt comes back once.
389
+ restoreEditor();
390
+ if (tempDir !== undefined) {
391
+ await fs.promises.rm(tempDir, { recursive: true, force: true }).catch(() => {
392
+ // Ignore cleanup errors
393
+ });
294
394
  }
295
395
  }
296
396
  };
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-slash-commands.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-slash-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxF,OAAO,EACN,uBAAuB,EAEvB,mBAAmB,GACnB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACN,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,6BAA6B,EAC7B,wBAAwB,EACxB,sBAAsB,GACtB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAyB,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AACjG,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACN,cAAc,EAEd,SAAS,EACT,eAAe,EACf,aAAa,EACb,EA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esContent":["import { createCacheMissModelSource, formatCacheWaste } from \"../../core/cache-stats.ts\";\nimport { formatResumeTimings, latestResumeTimings } from \"../../core/resume/timings.ts\";\nimport {\n\treadSessionUsageDetails,\n\ttype SessionUsageDetails,\n\tsessionUsageDetails,\n} from \"../../core/session-usage-details.ts\";\nimport {\n\tcompareWorktreeSnapshot,\n\tcurrentWorktreeSnapshots,\n\tdescribeExportedSnapshots,\n\tdescribeLastCapture,\n\tdescribeSnapshotExport,\n\tdescribeWorktreeRestoreStatus,\n\tdescribeWorktreeSnapshot,\n\tworktreeRestoreNotices,\n} from \"../../core/session-worktree-snapshots.ts\";\nimport { parseSlashCommand } from \"../../core/slash-commands.js\";\nimport { formatToolStatus, type ToolStatusReport } from \"../../core/tool-status.js\";\nimport { isGitUnavailableError, isWorkspaceError } from \"../../core/worktree-snapshot/errors.ts\";\nimport { createChildProcessEnvironment } from \"../../utils/child-process.ts\";\nimport { getEngineSessionStats } from \"../interactive-engine/engine-session-stats.js\";\nimport { IsolatedInteractiveRuntime } from \"../interactive-engine/isolated-runtime.js\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport {\n\tBorderedLoader,\n\ttype Component,\n\tContainer,\n\tcopyToClipboard,\n\tDynamicBorder,\n\tfs,\n\tgetChangelogPath,\n\tgetShareViewerUrl,\n\thyperlink,\n\tMissingSessionCwdError,\n\tnormalizeChangelogLinks,\n\tos,\n\tparseChangelogAsync,\n\tpath,\n\tSessionImportFileNotFoundError,\n\tSpacer,\n\tsetRegisteredThemes,\n\tspawn,\n\tText,\n\ttheme,\n} from \"./interactive-mode-deps.ts\";\nimport { isExpandable } from \"./interactive-mode-helpers.ts\";\nimport { showRestartExtensionErrors } from \"./interactive-session-runtime.ts\";\nimport { showSessionNotices } from \"./session-notices.ts\";\n\nInteractiveModeBase.prototype.handleReloadCommand = async function (this: InteractiveModeBase): Promise<void> {\n\tif (this.session.isStreaming) {\n\t\tthis.showWarning(\"Wait for the current response to finish before reloading.\");\n\t\treturn;\n\t}\n\tif (this.compactionActive) {\n\t\tthis.showWarning(\"Wait for compaction to finish before reloading.\");\n\t\treturn;\n\t}\n\n\tthis.resetExtensionUI();\n\n\tconst reloadBox = new Container();\n\tconst borderColor = (s: string) => theme.fg(\"border\", s);\n\treloadBox.addChild(new DynamicBorder(borderColor));\n\treloadBox.addChild(new Spacer(1));\n\treloadBox.addChild(\n\t\tnew Text(theme.fg(\"muted\", \"Reloading keybindings, extensions, skills, prompts, themes...\"), 1, 0),\n\t);\n\treloadBox.addChild(new Spacer(1));\n\treloadBox.addChild(new DynamicBorder(borderColor));\n\n\tconst previousEditor = this.editor;\n\tthis.editorContainer.clear();\n\tthis.editorContainer.addChild(reloadBox);\n\tthis.ui.setFocus(reloadBox);\n\tthis.ui.requestRender(true);\n\tawait new Promise((resolve) => process.nextTick(resolve));\n\n\tconst dismissReloadBox = (editor: Component) => {\n\t\tthis.editorContainer.clear();\n\t\tthis.editorContainer.addChild(editor);\n\t\tthis.ui.setFocus(editor);\n\t\tthis.ui.requestRender();\n\t};\n\n\ttry {\n\t\tif (this.runtimeHost instanceof IsolatedInteractiveRuntime) await this.session.reload();\n\t\telse await this.reloadCoordinator.reload(this.session);\n\t\tconst activeHeader = this.customHeader ?? this.builtInHeader;\n\t\tif (isExpandable(activeHeader)) {\n\t\t\tactiveHeader.setExpanded(this.toolOutputExpanded);\n\t\t}\n\t\tsetRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n\t\tthis.applyRuntimeSettings();\n\t\tawait this.themeController.applyFromSettings();\n\t\tthis.setupAutocompleteProvider();\n\t\tconst runner = this.session.extensionRunner;\n\t\tthis.setupExtensionShortcuts(runner);\n\t\tthis.rebuildChatFromMessages({ resetStartupDisclosure: true });\n\t\tdismissReloadBox(this.editor as Component);\n\t\tconst savedImplicitProjectTrust = await this.maybeSaveImplicitProjectTrustAfterReload();\n\t\tthis.showLoadedResources({\n\t\t\tforce: false,\n\t\t\tshowDiagnosticsWhenQuiet: true,\n\t\t});\n\t\tshowRestartExtensionErrors(this);\n\t\tif (savedImplicitProjectTrust) {\n\t\t\tthis.showStatus(\"Saved project trust for future sessions\");\n\t\t}\n\t\tconst modelsJsonError = this.session.modelRuntime.getError();\n\t\tif (modelsJsonError) {\n\t\t\tthis.showError(`models.json error: ${modelsJsonError}`);\n\t\t}\n\t\tthis.showStatus(\"Reloaded keybindings, extensions, skills, prompts, themes\");\n\t} catch (error) {\n\t\tshowRestartExtensionErrors(this);\n\t\tdismissReloadBox(previousEditor as Component);\n\t\tthis.showError(`Reload failed: ${error instanceof Error ? error.message : String(error)}`);\n\t}\n};\n\nInteractiveModeBase.prototype.handleExportCommand = async function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n): Promise<void> {\n\tconst outputPath = this.getPathCommandArgument(text, \"/export\");\n\n\ttry {\n\t\tif (outputPath?.endsWith(\".jsonl\")) {\n\t\t\tconst filePath = await this.session.exportToJsonl(outputPath);\n\t\t\tthis.showStatus(`Session exported to: ${filePath}`);\n\t\t\t// A session holding only its window states what the file carries from the file (#5554).\n\t\t\tconst contents =\n\t\t\t\tthis.sessionManager.hasFullHistory?.() === false\n\t\t\t\t\t? await describeExportedSnapshots(filePath)\n\t\t\t\t\t: describeSnapshotExport(\n\t\t\t\t\t\t\tthis.sessionManager.getBranch(),\n\t\t\t\t\t\t\tthis.sessionManager.getWorktreeSnapshotRecords(),\n\t\t\t\t\t\t);\n\t\t\tif (contents) this.showStatus(contents);\n\t\t} else {\n\t\t\tconst filePath = await this.session.exportToHtml(outputPath, { themeName: theme.name });\n\t\t\tthis.showStatus(`Session exported to: ${filePath}`);\n\t\t}\n\t} catch (error: unknown) {\n\t\tthis.showError(`Failed to export session: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t}\n};\n\nInteractiveModeBase.prototype.getPathCommandArgument = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n\tcommand: \"/export\" | \"/import\",\n): string | undefined {\n\tconst { name, args } = parseSlashCommand(text);\n\tif (`/${name}` !== command) {\n\t\treturn undefined;\n\t}\n\n\tconst argsString = args.trimStart();\n\tif (!argsString) {\n\t\treturn undefined;\n\t}\n\n\tconst firstChar = argsString[0];\n\tif (firstChar === '\"' || firstChar === \"'\") {\n\t\tconst closingQuoteIndex = argsString.indexOf(firstChar, 1);\n\t\tif (closingQuoteIndex < 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn argsString.slice(1, closingQuoteIndex);\n\t}\n\n\tconst firstWhitespaceIndex = argsString.search(/\\s/);\n\tif (firstWhitespaceIndex < 0) {\n\t\treturn argsString;\n\t}\n\treturn argsString.slice(0, firstWhitespaceIndex);\n};\n\nInteractiveModeBase.prototype.handleImportCommand = async function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n): Promise<void> {\n\tconst inputPath = this.getPathCommandArgument(text, \"/import\");\n\tif (!inputPath) {\n\t\tthis.showError(\"Usage: /import <path.jsonl>\");\n\t\treturn;\n\t}\n\n\tconst confirmed = await this.showExtensionConfirm(\"Import session\", `Replace current session with ${inputPath}?`);\n\tif (!confirmed) {\n\t\tthis.showStatus(\"Import cancelled\");\n\t\treturn;\n\t}\n\n\tconst importStartedAt = new Date().toISOString();\n\tconst finishSuccessfulImport = () => {\n\t\tthis.renderCurrentSessionState();\n\t\tif (this.firstRunNoticeVisible) {\n\t\t\tthis.clearFirstRunOnboardingUi();\n\t\t}\n\t\tthis.showStatus(`Session imported from: ${inputPath}`);\n\t\tshowSessionNotices(this, [\n\t\t\t...worktreeRestoreNotices(this.sessionManager, importStartedAt),\n\t\t\t...this.runtimeHost.takeResumeNotices(),\n\t\t]);\n\t};\n\n\ttry {\n\t\tInteractiveModeBase.prototype.clearWorkingLoader.call(this);\n\t\tconst result = await this.runtimeHost.importFromJsonl(inputPath);\n\t\tif (result.cancelled) {\n\t\t\tthis.showStatus(\"Import cancelled\");\n\t\t\treturn;\n\t\t}\n\t\tfinishSuccessfulImport();\n\t} catch (error: unknown) {\n\t\tif (error instanceof MissingSessionCwdError) {\n\t\t\tswitch (await this.promptForMissingSessionCwd(error)) {\n\t\t\t\tcase \"continue\": {\n\t\t\t\t\tconst result = await this.runtimeHost.importFromJsonl(inputPath, error.issue.fallbackCwd);\n\t\t\t\t\tif (result.cancelled) {\n\t\t\t\t\t\tthis.showStatus(\"Import cancelled\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tfinishSuccessfulImport();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcase \"fork\": {\n\t\t\t\t\tconst result = await this.switchToForkedSession({ exportPath: inputPath }, error.issue.fallbackCwd);\n\t\t\t\t\tif (result.cancelled) this.showStatus(\"Import cancelled\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcase undefined:\n\t\t\t\t\tthis.showStatus(\"Import cancelled\");\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (error instanceof SessionImportFileNotFoundError) {\n\t\t\tthis.showError(`Failed to import session: ${error.message}`);\n\t\t\treturn;\n\t\t}\n\t\tif (isWorkspaceError(error) || isGitUnavailableError(error)) {\n\t\t\tthis.showError(error.message);\n\t\t\treturn;\n\t\t}\n\t\tawait this.handleFatalRuntimeError(\"Failed to import session\", error);\n\t}\n};\n\nconst GH_AUTH_STATUS_TIMEOUT_MS = 30_000;\n\nfunction ghAuthStatus(): Promise<number | null> {\n\treturn new Promise((resolve) => {\n\t\tconst child = spawn(\"gh\", [\"auth\", \"status\"], {\n\t\t\tenv: createChildProcessEnvironment(),\n\t\t\tstdio: \"ignore\",\n\t\t\ttimeout: GH_AUTH_STATUS_TIMEOUT_MS,\n\t\t});\n\t\tchild.once(\"error\", () => resolve(null));\n\t\tchild.once(\"close\", (code) => resolve(code));\n\t});\n}\n\nInteractiveModeBase.prototype.handleShareCommand = async function (this: InteractiveModeBase): Promise<void> {\n\t// Check if gh is available and logged in\n\ttry {\n\t\tif ((await ghAuthStatus()) !== 0) {\n\t\t\tthis.showError(\"GitHub CLI is not logged in. Run 'gh auth login' first.\");\n\t\t\treturn;\n\t\t}\n\t} catch {\n\t\tthis.showError(\"GitHub CLI (gh) is not installed. Install it from https://cli.github.com/\");\n\t\treturn;\n\t}\n\n\t// Share an export-only JSONL copy carrying context for the viewer. The\n\t// persisted session is not mutated.\n\tconst tempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), \"atomic-share-\"));\n\tconst tmpFile = path.join(tempDir, \"session.jsonl\");\n\ttry {\n\t\tawait this.session.exportToJsonl(tmpFile, {\n\t\t\tincludeShareContext: true,\n\t\t\tsnapshotContent: false,\n\t\t\ttoolOutputContent: false,\n\t\t});\n\t} catch (error: unknown) {\n\t\tawait fs.promises.rm(tempDir, { recursive: true, force: true });\n\t\tthis.showError(`Failed to export session: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\treturn;\n\t}\n\n\t// Show cancellable loader, replacing the editor\n\tconst loader = new BorderedLoader(this.ui, theme, \"Creating gist...\");\n\tthis.editorContainer.clear();\n\tthis.editorContainer.addChild(loader);\n\tthis.ui.setFocus(loader);\n\tthis.ui.requestRender();\n\n\tconst restoreEditor = () => {\n\t\tloader.dispose();\n\t\tthis.editorContainer.clear();\n\t\tthis.editorContainer.addChild(this.editor);\n\t\tthis.ui.setFocus(this.editor);\n\t\tfs.promises.rm(tempDir, { recursive: true, force: true }).catch(() => {\n\t\t\t// Ignore cleanup errors\n\t\t});\n\t};\n\n\t// Create a secret gist asynchronously\n\tlet proc: ReturnType<typeof spawn> | null = null;\n\n\tloader.onAbort = () => {\n\t\tproc?.kill();\n\t\trestoreEditor();\n\t\tthis.showStatus(\"Share cancelled\");\n\t};\n\n\ttry {\n\t\tconst result = await new Promise<{\n\t\t\tstdout: string;\n\t\t\tstderr: string;\n\t\t\tcode: number | null;\n\t\t}>((resolve) => {\n\t\t\tproc = spawn(\"gh\", [\"gist\", \"create\", \"--public=false\", tmpFile], { env: createChildProcessEnvironment() });\n\t\t\tlet stdout = \"\";\n\t\t\tlet stderr = \"\";\n\t\t\tproc.stdout?.on(\"data\", (data) => {\n\t\t\t\tstdout += data.toString();\n\t\t\t});\n\t\t\tproc.stderr?.on(\"data\", (data) => {\n\t\t\t\tstderr += data.toString();\n\t\t\t});\n\t\t\tproc.on(\"error\", (error) => resolve({ stdout, stderr: stderr || error.message, code: null }));\n\t\t\tproc.on(\"close\", (code) => resolve({ stdout, stderr, code }));\n\t\t});\n\n\t\tif (loader.signal.aborted) return;\n\n\t\trestoreEditor();\n\n\t\tif (result.code !== 0) {\n\t\t\tconst errorMsg = result.stderr?.trim() || \"Unknown error\";\n\t\t\tthis.showError(`Failed to create gist: ${errorMsg}`);\n\t\t\treturn;\n\t\t}\n\n\t\t// Extract gist ID from the URL returned by gh\n\t\t// gh returns something like: https://gist.github.com/username/GIST_ID\n\t\tconst gistUrl = result.stdout?.trim();\n\t\tconst gistId = gistUrl?.split(\"/\").pop();\n\t\tif (!gistId) {\n\t\t\tthis.showError(\"Failed to parse gist ID from gh output\");\n\t\t\treturn;\n\t\t}\n\n\t\t// Create the preview URL\n\t\tconst previewUrl = getShareViewerUrl(gistId);\n\t\tthis.showStatus(`Share URL: ${hyperlink(previewUrl, previewUrl)}\\nGist: ${hyperlink(gistUrl, gistUrl)}`);\n\t} catch (error: unknown) {\n\t\tif (!loader.signal.aborted) {\n\t\t\trestoreEditor();\n\t\t\tthis.showError(`Failed to create gist: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t}\n\t}\n};\n\nInteractiveModeBase.prototype.handleCopyCommand = async function (this: InteractiveModeBase): Promise<void> {\n\tconst text = this.session.getLastAssistantText();\n\tif (!text) {\n\t\tthis.showError(\"No agent messages to copy yet.\");\n\t\treturn;\n\t}\n\n\ttry {\n\t\tawait copyToClipboard(text);\n\t\tthis.showStatus(\"Copied last agent message to clipboard\");\n\t} catch (error) {\n\t\tthis.showError(error instanceof Error ? error.message : String(error));\n\t}\n};\n\nInteractiveModeBase.prototype.handleNameCommand = async function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n): Promise<void> {\n\tconst name = text.replace(/^\\/name\\s*/, \"\").trim();\n\tif (!name) {\n\t\tconst currentName = this.sessionManager.getSessionName();\n\t\tif (currentName) {\n\t\t\tthis.chatContainer.addChild(new Spacer(1));\n\t\t\tthis.chatContainer.addChild(new Text(theme.fg(\"dim\", `Session name: ${currentName}`), 1, 0));\n\t\t} else {\n\t\t\tthis.showWarning(\"Usage: /name <name>\");\n\t\t}\n\t\tthis.ui.requestRender();\n\t\treturn;\n\t}\n\n\tawait this.session.setSessionName(name);\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(new Text(theme.fg(\"dim\", `Session name set: ${name}`), 1, 0));\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.handleToolsCommand = async function (this: InteractiveModeBase): Promise<void> {\n\tlet report: ToolStatusReport;\n\ttry {\n\t\treport =\n\t\t\tthis.runtimeHost instanceof IsolatedInteractiveRuntime\n\t\t\t\t? await this.runtimeHost.getToolStatus()\n\t\t\t\t: await this.session.getToolStatusAsync();\n\t} catch (error) {\n\t\tthis.showError(`Could not read tool status: ${error instanceof Error ? error.message : String(error)}`);\n\t\treturn;\n\t}\n\tconst text = formatToolStatus(report, {\n\t\theading: (value) => theme.bold(value),\n\t\tdim: (value) => theme.fg(\"dim\", value),\n\t\twarning: (value) => theme.fg(\"warning\", value),\n\t});\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(new Text(`${theme.bold(\"Tools\")}\\n\\n${text}`, 1, 0));\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.handleSessionSnapshotCommand = async function (this: InteractiveModeBase): Promise<void> {\n\tconst latest = await currentWorktreeSnapshots(this.sessionManager);\n\tif (latest.size === 0) {\n\t\tthis.showStatus(\"No worktree snapshots recorded in this session\");\n\t\treturn;\n\t}\n\tconst settings = this.settingsManager.getWorktreeSnapshotSettings();\n\tconst lines = [theme.bold(\"Worktree Snapshots\"), \"\"];\n\tfor (const [root, snapshot] of latest) {\n\t\tlines.push(...describeWorktreeSnapshot(root, snapshot));\n\t\tconst restoreStatus = describeWorktreeRestoreStatus(this.sessionManager, root);\n\t\tif (restoreStatus) lines.push(theme.fg(\"warning\", ` ${restoreStatus}`));\n\t\tconst capture = await describeLastCapture(this.sessionManager, root);\n\t\tif (capture) lines.push(theme.fg(\"dim\", ` ${capture}`));\n\t\tconst comparison = await compareWorktreeSnapshot(snapshot, root, settings);\n\t\tif (comparison.status === \"match\")\n\t\t\tlines.push(\n\t\t\t\ttheme.fg(\n\t\t\t\t\t\"success\",\n\t\t\t\t\t` matches the current tree${comparison.head ? ` at ${comparison.head.slice(0, 12)}` : \"\"}`,\n\t\t\t\t),\n\t\t\t);\n\t\telse if (comparison.status === \"missing\") lines.push(theme.fg(\"warning\", ` ${comparison.reason.message}`));\n\t\telse {\n\t\t\tlines.push(\n\t\t\t\ttheme.fg(\n\t\t\t\t\t\"warning\",\n\t\t\t\t\t` differs from the current tree ${comparison.tree.slice(0, 12)} at ${comparison.head.slice(0, 12)}`,\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (comparison.stat) lines.push(...comparison.stat.split(\"\\n\").map((line) => ` ${line}`));\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\tconst timings = latestResumeTimings(this.sessionManager);\n\tif (timings !== undefined) {\n\t\tlines.push(theme.bold(\"Last resume\"), \"\", ...formatResumeTimings(timings).map((line) => ` ${line}`));\n\t}\n\tthis.chatContainer.addChild(new Text(lines.join(\"\\n\").trimEnd(), 1, 0));\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.handleSessionCommand = function (this: InteractiveModeBase): void | Promise<void> {\n\t// getSessionStats combines the window with the store's omitted-history totals.\n\tshowSessionInfo.call(this);\n};\n\nconst NO_USAGE_DETAILS: SessionUsageDetails = {\n\tbreakdown: [],\n\tpromptTokens: 0,\n\tcacheRead: 0,\n\tcacheWaste: { missedTokens: 0, missedCost: 0, missCount: 0, unpricedCount: 0 },\n};\n\nfunction showSessionInfo(this: InteractiveModeBase): void {\n\tconst engineStats = getEngineSessionStats(this.session);\n\tconst stats = engineStats ?? this.session.getSessionStats();\n\tconst sessionName = this.session.sessionName;\n\n\tlet info = `${theme.bold(\"Session Info\")}\\n\\n`;\n\tif (sessionName) {\n\t\tinfo += `${theme.fg(\"dim\", \"Name:\")} ${sessionName}\\n`;\n\t}\n\tconst location =\n\t\tstats.sessionFile ??\n\t\t(this.sessionManager.isPersisted() ? this.sessionManager.getSessionStore().descriptor.location : \"In-memory\");\n\tinfo += `${theme.fg(\"dim\", \"File:\")} ${location}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"ID:\")} ${stats.sessionId}\\n\\n`;\n\tinfo += `${theme.bold(\"Messages\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"User:\")} ${stats.userMessages}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Assistant:\")} ${stats.assistantMessages}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Tool Calls:\")} ${stats.toolCalls}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Tool Results:\")} ${stats.toolResults}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.totalMessages}\\n\\n`;\n\tinfo += `${theme.bold(\"Tokens\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Input:\")} ${stats.tokens.input.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Output:\")} ${stats.tokens.output.toLocaleString()}\\n`;\n\tif (stats.tokens.cacheRead > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"Cache Read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n\t}\n\tif (stats.tokens.cacheWrite > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"Cache Write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n`;\n\tconst mirrorStats = engineStats ? this.session.getSessionStats() : stats;\n\tconst mirrorMatchesEngine =\n\t\tmirrorStats.sessionId === stats.sessionId &&\n\t\tmirrorStats.totalMessages === stats.totalMessages &&\n\t\tmirrorStats.cost === stats.cost &&\n\t\tmirrorStats.tokens.input === stats.tokens.input &&\n\t\tmirrorStats.tokens.output === stats.tokens.output &&\n\t\tmirrorStats.tokens.cacheRead === stats.tokens.cacheRead &&\n\t\tmirrorStats.tokens.cacheWrite === stats.tokens.cacheWrite;\n\tconst head = info;\n\tconst block = new Text(\"\", 1, 0);\n\t/** Fill the block; without `details`, only with the lines that do not need them, and `note` when there is one. */\n\tconst show = (details: SessionUsageDetails | undefined, note?: string) => {\n\t\tlet text = head;\n\t\tconst promptTokens = engineStats\n\t\t\t? engineStats.tokens.input + engineStats.tokens.cacheRead + engineStats.tokens.cacheWrite\n\t\t\t: (details?.promptTokens ?? 0);\n\t\tconst cacheRead = engineStats ? engineStats.tokens.cacheRead : (details?.cacheRead ?? 0);\n\t\tif (promptTokens > 0)\n\t\t\ttext += `${theme.fg(\"dim\", \"Cache Hit Rate:\")} ${((cacheRead / promptTokens) * 100).toFixed(1)}%\\n`;\n\t\tif (details && details.cacheWaste.missCount > 0)\n\t\t\ttext += `${theme.fg(\"dim\", \"Wasted Cache Cost:\")} ${formatCacheWaste(details.cacheWaste)}\\n`;\n\n\t\tif (stats.cost > 0) {\n\t\t\ttext += `\\n${theme.bold(\"Cost\")}\\n`;\n\t\t\ttext += `${theme.fg(\"dim\", \"Total:\")} ${stats.cost.toFixed(4)}`;\n\t\t\tfor (const item of details?.breakdown ?? []) {\n\t\t\t\ttext += `\\n${theme.fg(\"dim\", `${item.key}:`)} $${item.cost.toFixed(4)}`;\n\t\t\t}\n\t\t}\n\t\tif (note) text += `\\n${theme.fg(\"warning\", note)}`;\n\t\tblock.setText(text);\n\t};\n\tconst manager = this.sessionManager;\n\tconst models = createCacheMissModelSource(this.session.modelRuntime);\n\t// An isolated host's mirror that is behind its engine lists nothing it would have to guess.\n\tconst mirrorBehind = engineStats !== undefined && (this.session.isStreaming || !mirrorMatchesEngine);\n\tconst paged = !mirrorBehind && manager.hasFullHistory?.() === false;\n\tif (mirrorBehind) show(NO_USAGE_DETAILS);\n\telse if (!paged) show(sessionUsageDetails(manager.getEntries(), models));\n\telse show(undefined);\n\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(block);\n\tthis.ui.requestRender();\n\tif (!paged) return;\n\t// The per-model cost and cache lines cover the whole session (#5554). A manager holding only its window reads the\n\t// rest a page at a time and keeps none of it; the block is shown at once and those lines appear when the read ends.\n\tvoid readSessionUsageDetails(manager, models).then(\n\t\t(details) => {\n\t\t\tshow(details);\n\t\t\tthis.ui.requestRender();\n\t\t},\n\t\t(error: unknown) => {\n\t\t\tshow(\n\t\t\t\tundefined,\n\t\t\t\t`Could not read the earlier history for the per-model cost and cache lines: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t\tthis.ui.requestRender();\n\t\t},\n\t);\n}\n\nInteractiveModeBase.prototype.handleChangelogCommand = async function (this: InteractiveModeBase): Promise<void> {\n\tconst changelogPath = getChangelogPath();\n\tconst allEntries = await parseChangelogAsync(changelogPath);\n\n\tconst changelogMarkdown =\n\t\tallEntries.length > 0\n\t\t\t? allEntries\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.map((e) => normalizeChangelogLinks(e.content, e))\n\t\t\t\t\t.join(\"\\n\\n\")\n\t\t\t: \"No changelog entries found.\";\n\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(new DynamicBorder());\n\tthis.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0));\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(this.createChangelogMarkdown(changelogMarkdown, 1, 1));\n\tthis.chatContainer.addChild(new DynamicBorder());\n\tthis.ui.requestRender();\n};\n"]}
1
+ {"version":3,"file":"interactive-slash-commands.js","sourceRoot":"","sources":["../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I,CAAC,uBAAuB,CAAC,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACnF,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;IACjD,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AACzB,CAAC,CAAC","sourcesContent":["import { createInterface } from \"node:readline\";\nimport { createCacheMissModelSource, formatCacheWaste } from \"../../core/cache-stats.ts\";\nimport { formatResumeTimings, latestResumeTimings } from \"../../core/resume/timings.ts\";\nimport {\n\treadSessionUsageDetails,\n\ttype SessionUsageDetails,\n\tsessionUsageDetails,\n} from \"../../core/session-usage-details.ts\";\nimport {\n\tcompareWorktreeSnapshot,\n\tcurrentWorktreeSnapshots,\n\tdescribeExportedSnapshots,\n\tdescribeLastCapture,\n\tdescribeSnapshotExport,\n\tdescribeWorktreeRestoreStatus,\n\tdescribeWorktreeSnapshot,\n\tworktreeRestoreNotices,\n} from \"../../core/session-worktree-snapshots.ts\";\nimport { parseSlashCommand } from \"../../core/slash-commands.js\";\nimport { formatToolStatus, type ToolStatusReport } from \"../../core/tool-status.js\";\nimport { isGitUnavailableError, isWorkspaceError } from \"../../core/worktree-snapshot/errors.ts\";\nimport { createChildProcessEnvironment } from \"../../utils/child-process.ts\";\nimport { getEngineSessionStats } from \"../interactive-engine/engine-session-stats.js\";\nimport { IsolatedInteractiveRuntime } from \"../interactive-engine/isolated-runtime.js\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport {\n\tBorderedLoader,\n\ttype Component,\n\tContainer,\n\tcopyToClipboard,\n\tDynamicBorder,\n\tfs,\n\tgetChangelogPath,\n\tgetShareViewerUrl,\n\thyperlink,\n\tMissingSessionCwdError,\n\tnormalizeChangelogLinks,\n\tos,\n\tparseChangelogAsync,\n\tpath,\n\tSessionImportFileNotFoundError,\n\tSpacer,\n\tsetRegisteredThemes,\n\tspawn,\n\tText,\n\ttheme,\n} from \"./interactive-mode-deps.ts\";\nimport { isExpandable } from \"./interactive-mode-helpers.ts\";\nimport { showRestartExtensionErrors } from \"./interactive-session-runtime.ts\";\nimport { showSessionNotices } from \"./session-notices.ts\";\n\nInteractiveModeBase.prototype.handleReloadCommand = async function (this: InteractiveModeBase): Promise<void> {\n\tif (this.session.isStreaming) {\n\t\tthis.showWarning(\"Wait for the current response to finish before reloading.\");\n\t\treturn;\n\t}\n\tif (this.compactionActive) {\n\t\tthis.showWarning(\"Wait for compaction to finish before reloading.\");\n\t\treturn;\n\t}\n\n\tthis.resetExtensionUI();\n\n\tconst reloadBox = new Container();\n\tconst borderColor = (s: string) => theme.fg(\"border\", s);\n\treloadBox.addChild(new DynamicBorder(borderColor));\n\treloadBox.addChild(new Spacer(1));\n\treloadBox.addChild(\n\t\tnew Text(theme.fg(\"muted\", \"Reloading keybindings, extensions, skills, prompts, themes...\"), 1, 0),\n\t);\n\treloadBox.addChild(new Spacer(1));\n\treloadBox.addChild(new DynamicBorder(borderColor));\n\n\tconst previousEditor = this.editor;\n\tthis.editorContainer.clear();\n\tthis.editorContainer.addChild(reloadBox);\n\tthis.ui.setFocus(reloadBox);\n\tthis.ui.requestRender(true);\n\tawait new Promise((resolve) => process.nextTick(resolve));\n\n\tconst dismissReloadBox = (editor: Component) => {\n\t\tthis.editorContainer.clear();\n\t\tthis.editorContainer.addChild(editor);\n\t\tthis.ui.setFocus(editor);\n\t\tthis.ui.requestRender();\n\t};\n\n\ttry {\n\t\tif (this.runtimeHost instanceof IsolatedInteractiveRuntime) await this.session.reload();\n\t\telse await this.reloadCoordinator.reload(this.session);\n\t\tconst activeHeader = this.customHeader ?? this.builtInHeader;\n\t\tif (isExpandable(activeHeader)) {\n\t\t\tactiveHeader.setExpanded(this.toolOutputExpanded);\n\t\t}\n\t\tsetRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n\t\tthis.applyRuntimeSettings();\n\t\tawait this.themeController.applyFromSettings();\n\t\tthis.setupAutocompleteProvider();\n\t\tconst runner = this.session.extensionRunner;\n\t\tthis.setupExtensionShortcuts(runner);\n\t\tthis.rebuildChatFromMessages({ resetStartupDisclosure: true });\n\t\tdismissReloadBox(this.editor as Component);\n\t\tconst savedImplicitProjectTrust = await this.maybeSaveImplicitProjectTrustAfterReload();\n\t\tthis.showLoadedResources({\n\t\t\tforce: false,\n\t\t\tshowDiagnosticsWhenQuiet: true,\n\t\t});\n\t\tshowRestartExtensionErrors(this);\n\t\tif (savedImplicitProjectTrust) {\n\t\t\tthis.showStatus(\"Saved project trust for future sessions\");\n\t\t}\n\t\tconst modelsJsonError = this.session.modelRuntime.getError();\n\t\tif (modelsJsonError) {\n\t\t\tthis.showError(`models.json error: ${modelsJsonError}`);\n\t\t}\n\t\tthis.showStatus(\"Reloaded keybindings, extensions, skills, prompts, themes\");\n\t} catch (error) {\n\t\tshowRestartExtensionErrors(this);\n\t\tdismissReloadBox(previousEditor as Component);\n\t\tthis.showError(`Reload failed: ${error instanceof Error ? error.message : String(error)}`);\n\t}\n};\n\nInteractiveModeBase.prototype.handleExportCommand = async function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n): Promise<void> {\n\tconst outputPath = this.getPathCommandArgument(text, \"/export\");\n\n\ttry {\n\t\tif (outputPath?.endsWith(\".jsonl\")) {\n\t\t\tconst filePath = await this.session.exportToJsonl(outputPath);\n\t\t\tthis.showStatus(`Session exported to: ${filePath}`);\n\t\t\t// A session holding only its window states what the file carries from the file (#5554).\n\t\t\tconst contents =\n\t\t\t\tthis.sessionManager.hasFullHistory?.() === false\n\t\t\t\t\t? await describeExportedSnapshots(filePath)\n\t\t\t\t\t: describeSnapshotExport(\n\t\t\t\t\t\t\tthis.sessionManager.getBranch(),\n\t\t\t\t\t\t\tthis.sessionManager.getWorktreeSnapshotRecords(),\n\t\t\t\t\t\t);\n\t\t\tif (contents) this.showStatus(contents);\n\t\t} else {\n\t\t\tconst filePath = await this.session.exportToHtml(outputPath, { themeName: theme.name });\n\t\t\tthis.showStatus(`Session exported to: ${filePath}`);\n\t\t}\n\t} catch (error: unknown) {\n\t\tthis.showError(`Failed to export session: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t}\n};\n\nInteractiveModeBase.prototype.getPathCommandArgument = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n\tcommand: \"/export\" | \"/import\",\n): string | undefined {\n\tconst { name, args } = parseSlashCommand(text);\n\tif (`/${name}` !== command) {\n\t\treturn undefined;\n\t}\n\n\tconst argsString = args.trimStart();\n\tif (!argsString) {\n\t\treturn undefined;\n\t}\n\n\tconst firstChar = argsString[0];\n\tif (firstChar === '\"' || firstChar === \"'\") {\n\t\tconst closingQuoteIndex = argsString.indexOf(firstChar, 1);\n\t\tif (closingQuoteIndex < 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn argsString.slice(1, closingQuoteIndex);\n\t}\n\n\tconst firstWhitespaceIndex = argsString.search(/\\s/);\n\tif (firstWhitespaceIndex < 0) {\n\t\treturn argsString;\n\t}\n\treturn argsString.slice(0, firstWhitespaceIndex);\n};\n\nInteractiveModeBase.prototype.handleImportCommand = async function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n): Promise<void> {\n\tconst inputPath = this.getPathCommandArgument(text, \"/import\");\n\tif (!inputPath) {\n\t\tthis.showError(\"Usage: /import <path.jsonl>\");\n\t\treturn;\n\t}\n\n\tconst confirmed = await this.showExtensionConfirm(\"Import session\", `Replace current session with ${inputPath}?`);\n\tif (!confirmed) {\n\t\tthis.showStatus(\"Import cancelled\");\n\t\treturn;\n\t}\n\n\tconst importStartedAt = new Date().toISOString();\n\tconst finishSuccessfulImport = () => {\n\t\tthis.renderCurrentSessionState();\n\t\tif (this.firstRunNoticeVisible) {\n\t\t\tthis.clearFirstRunOnboardingUi();\n\t\t}\n\t\tthis.showStatus(`Session imported from: ${inputPath}`);\n\t\tshowSessionNotices(this, [\n\t\t\t...worktreeRestoreNotices(this.sessionManager, importStartedAt),\n\t\t\t...this.runtimeHost.takeResumeNotices(),\n\t\t]);\n\t};\n\n\ttry {\n\t\tInteractiveModeBase.prototype.clearWorkingLoader.call(this);\n\t\tconst result = await this.runtimeHost.importFromJsonl(inputPath);\n\t\tif (result.cancelled) {\n\t\t\tthis.showStatus(\"Import cancelled\");\n\t\t\treturn;\n\t\t}\n\t\tfinishSuccessfulImport();\n\t} catch (error: unknown) {\n\t\tif (error instanceof MissingSessionCwdError) {\n\t\t\tswitch (await this.promptForMissingSessionCwd(error)) {\n\t\t\t\tcase \"continue\": {\n\t\t\t\t\tconst result = await this.runtimeHost.importFromJsonl(inputPath, error.issue.fallbackCwd);\n\t\t\t\t\tif (result.cancelled) {\n\t\t\t\t\t\tthis.showStatus(\"Import cancelled\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tfinishSuccessfulImport();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcase \"fork\": {\n\t\t\t\t\tconst result = await this.switchToForkedSession({ exportPath: inputPath }, error.issue.fallbackCwd);\n\t\t\t\t\tif (result.cancelled) this.showStatus(\"Import cancelled\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcase undefined:\n\t\t\t\t\tthis.showStatus(\"Import cancelled\");\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (error instanceof SessionImportFileNotFoundError) {\n\t\t\tthis.showError(`Failed to import session: ${error.message}`);\n\t\t\treturn;\n\t\t}\n\t\tif (isWorkspaceError(error) || isGitUnavailableError(error)) {\n\t\t\tthis.showError(error.message);\n\t\t\treturn;\n\t\t}\n\t\tawait this.handleFatalRuntimeError(\"Failed to import session\", error);\n\t}\n};\n\nconst GH_AUTH_STATUS_TIMEOUT_MS = 30_000;\n/** How long a cancelled gh process gets to exit after it is asked to before it is killed. */\nconst GH_CANCEL_GRACE_MS = 2_000;\n\n/** Stop a gh process the user cancelled: ask it to exit, and kill it if it is still running after the grace period. */\nfunction stopGh(child: ReturnType<typeof spawn>): void {\n\tchild.kill();\n\tconst timer = setTimeout(() => {\n\t\tif (child.exitCode === null && child.signalCode === null) child.kill(\"SIGKILL\");\n\t}, GH_CANCEL_GRACE_MS);\n\ttimer.unref?.();\n\tchild.once(\"close\", () => clearTimeout(timer));\n}\n\n/** The session id in the header, the first line, of the exported session file `file`. */\nasync function exportedSessionId(file: string): Promise<string | undefined> {\n\tconst input = fs.createReadStream(file, { encoding: \"utf8\" });\n\tconst lines = createInterface({ input, crlfDelay: Number.POSITIVE_INFINITY });\n\ttry {\n\t\tfor await (const line of lines) {\n\t\t\tconst header = JSON.parse(line) as { id?: unknown };\n\t\t\treturn typeof header.id === \"string\" ? header.id : undefined;\n\t\t}\n\t\treturn undefined;\n\t} catch {\n\t\treturn undefined;\n\t} finally {\n\t\tlines.close();\n\t\tinput.destroy();\n\t}\n}\n\n/** Run `gh auth status`; `started` receives the child, so a cancel can stop it. */\nfunction ghAuthStatus(started: (child: ReturnType<typeof spawn>) => void): Promise<number | null> {\n\treturn new Promise((resolve) => {\n\t\tconst child = spawn(\"gh\", [\"auth\", \"status\"], {\n\t\t\tenv: createChildProcessEnvironment(),\n\t\t\tstdio: \"ignore\",\n\t\t\ttimeout: GH_AUTH_STATUS_TIMEOUT_MS,\n\t\t});\n\t\tstarted(child);\n\t\tchild.once(\"error\", () => resolve(null));\n\t\tchild.once(\"close\", (code) => resolve(code));\n\t});\n}\n\nInteractiveModeBase.prototype.handleShareCommand = async function (this: InteractiveModeBase): Promise<void> {\n\t// The session to share is the one shown when the command was given.\n\tconst session = this.session;\n\tconst sessionId = session.sessionManager.getSessionId();\n\t// The cancellable loader takes the prompt's place at once: checking gh and exporting the session take a while.\n\tconst loader = new BorderedLoader(this.ui, theme, \"Creating gist...\");\n\tthis.editorContainer.clear();\n\tthis.editorContainer.addChild(loader);\n\tthis.ui.setFocus(loader);\n\tthis.ui.requestRender();\n\n\tlet restored = false;\n\tconst restoreEditor = () => {\n\t\tif (restored) return;\n\t\trestored = true;\n\t\tloader.dispose();\n\t\t// A view that has taken the loader's place since keeps it.\n\t\tif (!this.editorContainer.children.includes(loader)) return;\n\t\tthis.editorContainer.clear();\n\t\tthis.editorContainer.addChild(this.editor);\n\t\tthis.ui.setFocus(this.editor);\n\t\tthis.ui.requestRender();\n\t};\n\n\t// The gh process running now, which a cancel stops.\n\tlet proc: ReturnType<typeof spawn> | undefined;\n\tloader.onAbort = () => {\n\t\tif (proc !== undefined) stopGh(proc);\n\t\trestoreEditor();\n\t\tthis.showStatus(\"Share cancelled\");\n\t};\n\tconst cancelled = () => loader.signal.aborted;\n\t// Another session took this one's place before it was exported, or while it was: neither is shared.\n\tconst sessionChanged = () => {\n\t\trestoreEditor();\n\t\tthis.showStatus(\"Share cancelled: the session changed\");\n\t};\n\tconst replaced = () => {\n\t\tif (cancelled() || (this.session === session && session.sessionManager.getSessionId() === sessionId))\n\t\t\treturn false;\n\t\tsessionChanged();\n\t\treturn true;\n\t};\n\n\t// Each step is awaited before the next, also after a cancel, so the directory is removed only once nothing writes\n\t// into it any more.\n\tlet tempDir: string | undefined;\n\ttry {\n\t\t// Check if gh is available and logged in\n\t\ttry {\n\t\t\tconst status = await ghAuthStatus((child) => {\n\t\t\t\tproc = child;\n\t\t\t});\n\t\t\tproc = undefined;\n\t\t\tif (cancelled() || replaced()) return;\n\t\t\tif (status !== 0) {\n\t\t\t\trestoreEditor();\n\t\t\t\tthis.showError(\"GitHub CLI is not logged in. Run 'gh auth login' first.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t} catch {\n\t\t\tproc = undefined;\n\t\t\tif (cancelled()) return;\n\t\t\trestoreEditor();\n\t\t\tthis.showError(\"GitHub CLI (gh) is not installed. Install it from https://cli.github.com/\");\n\t\t\treturn;\n\t\t}\n\n\t\t// Share an export-only JSONL copy carrying context for the viewer. The\n\t\t// persisted session is not mutated.\n\t\ttempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), \"atomic-share-\"));\n\t\tif (cancelled() || replaced()) return;\n\t\tconst tmpFile = path.join(tempDir, \"session.jsonl\");\n\t\ttry {\n\t\t\tawait session.exportToJsonl(tmpFile, {\n\t\t\t\tincludeShareContext: true,\n\t\t\t\tsnapshotContent: false,\n\t\t\t\ttoolOutputContent: false,\n\t\t\t});\n\t\t} catch (error: unknown) {\n\t\t\tif (cancelled()) return;\n\t\t\trestoreEditor();\n\t\t\tthis.showError(`Failed to export session: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t\treturn;\n\t\t}\n\t\tif (cancelled() || replaced()) return;\n\t\t// The file holds the session asked for, whatever changed on the way: another never leaves under its name.\n\t\tconst exportedId = await exportedSessionId(tmpFile);\n\t\tif (cancelled()) return;\n\t\tif (exportedId !== sessionId) {\n\t\t\tsessionChanged();\n\t\t\treturn;\n\t\t}\n\n\t\t// Create a secret gist\n\t\ttry {\n\t\t\tconst result = await new Promise<{\n\t\t\t\tstdout: string;\n\t\t\t\tstderr: string;\n\t\t\t\tcode: number | null;\n\t\t\t}>((resolve) => {\n\t\t\t\tconst child = spawn(\"gh\", [\"gist\", \"create\", \"--public=false\", tmpFile], {\n\t\t\t\t\tenv: createChildProcessEnvironment(),\n\t\t\t\t});\n\t\t\t\tproc = child;\n\t\t\t\tlet stdout = \"\";\n\t\t\t\tlet stderr = \"\";\n\t\t\t\tchild.stdout?.on(\"data\", (data) => {\n\t\t\t\t\tstdout += data.toString();\n\t\t\t\t});\n\t\t\t\tchild.stderr?.on(\"data\", (data) => {\n\t\t\t\t\tstderr += data.toString();\n\t\t\t\t});\n\t\t\t\tchild.on(\"error\", (error) => resolve({ stdout, stderr: stderr || error.message, code: null }));\n\t\t\t\tchild.on(\"close\", (code) => resolve({ stdout, stderr, code }));\n\t\t\t});\n\t\t\tproc = undefined;\n\n\t\t\tif (cancelled()) return;\n\n\t\t\trestoreEditor();\n\n\t\t\tif (result.code !== 0) {\n\t\t\t\tconst errorMsg = result.stderr?.trim() || \"Unknown error\";\n\t\t\t\tthis.showError(`Failed to create gist: ${errorMsg}`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Extract gist ID from the URL returned by gh\n\t\t\t// gh returns something like: https://gist.github.com/username/GIST_ID\n\t\t\tconst gistUrl = result.stdout?.trim();\n\t\t\tconst gistId = gistUrl?.split(\"/\").pop();\n\t\t\tif (!gistId) {\n\t\t\t\tthis.showError(\"Failed to parse gist ID from gh output\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Create the preview URL\n\t\t\tconst previewUrl = getShareViewerUrl(gistId);\n\t\t\tthis.showStatus(`Share URL: ${hyperlink(previewUrl, previewUrl)}\\nGist: ${hyperlink(gistUrl, gistUrl)}`);\n\t\t} catch (error: unknown) {\n\t\t\tproc = undefined;\n\t\t\tif (!cancelled()) {\n\t\t\t\trestoreEditor();\n\t\t\t\tthis.showError(`Failed to create gist: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t\t}\n\t\t}\n\t} finally {\n\t\t// Whatever ended the share, the prompt comes back once.\n\t\trestoreEditor();\n\t\tif (tempDir !== undefined) {\n\t\t\tawait fs.promises.rm(tempDir, { recursive: true, force: true }).catch(() => {\n\t\t\t\t// Ignore cleanup errors\n\t\t\t});\n\t\t}\n\t}\n};\n\nInteractiveModeBase.prototype.handleCopyCommand = async function (this: InteractiveModeBase): Promise<void> {\n\tconst text = this.session.getLastAssistantText();\n\tif (!text) {\n\t\tthis.showError(\"No agent messages to copy yet.\");\n\t\treturn;\n\t}\n\n\ttry {\n\t\tawait copyToClipboard(text);\n\t\tthis.showStatus(\"Copied last agent message to clipboard\");\n\t} catch (error) {\n\t\tthis.showError(error instanceof Error ? error.message : String(error));\n\t}\n};\n\nInteractiveModeBase.prototype.handleNameCommand = async function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n): Promise<void> {\n\tconst name = text.replace(/^\\/name\\s*/, \"\").trim();\n\tif (!name) {\n\t\tconst currentName = this.sessionManager.getSessionName();\n\t\tif (currentName) {\n\t\t\tthis.chatContainer.addChild(new Spacer(1));\n\t\t\tthis.chatContainer.addChild(new Text(theme.fg(\"dim\", `Session name: ${currentName}`), 1, 0));\n\t\t} else {\n\t\t\tthis.showWarning(\"Usage: /name <name>\");\n\t\t}\n\t\tthis.ui.requestRender();\n\t\treturn;\n\t}\n\n\tawait this.session.setSessionName(name);\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(new Text(theme.fg(\"dim\", `Session name set: ${name}`), 1, 0));\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.handleToolsCommand = async function (this: InteractiveModeBase): Promise<void> {\n\tlet report: ToolStatusReport;\n\ttry {\n\t\treport =\n\t\t\tthis.runtimeHost instanceof IsolatedInteractiveRuntime\n\t\t\t\t? await this.runtimeHost.getToolStatus()\n\t\t\t\t: await this.session.getToolStatusAsync();\n\t} catch (error) {\n\t\tthis.showError(`Could not read tool status: ${error instanceof Error ? error.message : String(error)}`);\n\t\treturn;\n\t}\n\tconst text = formatToolStatus(report, {\n\t\theading: (value) => theme.bold(value),\n\t\tdim: (value) => theme.fg(\"dim\", value),\n\t\twarning: (value) => theme.fg(\"warning\", value),\n\t});\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(new Text(`${theme.bold(\"Tools\")}\\n\\n${text}`, 1, 0));\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.handleSessionSnapshotCommand = async function (this: InteractiveModeBase): Promise<void> {\n\tconst latest = await currentWorktreeSnapshots(this.sessionManager);\n\tif (latest.size === 0) {\n\t\tthis.showStatus(\"No worktree snapshots recorded in this session\");\n\t\treturn;\n\t}\n\tconst settings = this.settingsManager.getWorktreeSnapshotSettings();\n\tconst lines = [theme.bold(\"Worktree Snapshots\"), \"\"];\n\tfor (const [root, snapshot] of latest) {\n\t\tlines.push(...describeWorktreeSnapshot(root, snapshot));\n\t\tconst restoreStatus = describeWorktreeRestoreStatus(this.sessionManager, root);\n\t\tif (restoreStatus) lines.push(theme.fg(\"warning\", ` ${restoreStatus}`));\n\t\tconst capture = await describeLastCapture(this.sessionManager, root);\n\t\tif (capture) lines.push(theme.fg(\"dim\", ` ${capture}`));\n\t\tconst comparison = await compareWorktreeSnapshot(snapshot, root, settings);\n\t\tif (comparison.status === \"match\")\n\t\t\tlines.push(\n\t\t\t\ttheme.fg(\n\t\t\t\t\t\"success\",\n\t\t\t\t\t` matches the current tree${comparison.head ? ` at ${comparison.head.slice(0, 12)}` : \"\"}`,\n\t\t\t\t),\n\t\t\t);\n\t\telse if (comparison.status === \"missing\") lines.push(theme.fg(\"warning\", ` ${comparison.reason.message}`));\n\t\telse {\n\t\t\tlines.push(\n\t\t\t\ttheme.fg(\n\t\t\t\t\t\"warning\",\n\t\t\t\t\t` differs from the current tree ${comparison.tree.slice(0, 12)} at ${comparison.head.slice(0, 12)}`,\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (comparison.stat) lines.push(...comparison.stat.split(\"\\n\").map((line) => ` ${line}`));\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\tconst timings = latestResumeTimings(this.sessionManager);\n\tif (timings !== undefined) {\n\t\tlines.push(theme.bold(\"Last resume\"), \"\", ...formatResumeTimings(timings).map((line) => ` ${line}`));\n\t}\n\tthis.chatContainer.addChild(new Text(lines.join(\"\\n\").trimEnd(), 1, 0));\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.handleSessionCommand = function (this: InteractiveModeBase): void | Promise<void> {\n\t// getSessionStats combines the window with the store's omitted-history totals.\n\tshowSessionInfo.call(this);\n};\n\nconst NO_USAGE_DETAILS: SessionUsageDetails = {\n\tbreakdown: [],\n\tpromptTokens: 0,\n\tcacheRead: 0,\n\tcacheWaste: { missedTokens: 0, missedCost: 0, missCount: 0, unpricedCount: 0 },\n};\n\nfunction showSessionInfo(this: InteractiveModeBase): void {\n\tconst engineStats = getEngineSessionStats(this.session);\n\tconst stats = engineStats ?? this.session.getSessionStats();\n\tconst sessionName = this.session.sessionName;\n\n\tlet info = `${theme.bold(\"Session Info\")}\\n\\n`;\n\tif (sessionName) {\n\t\tinfo += `${theme.fg(\"dim\", \"Name:\")} ${sessionName}\\n`;\n\t}\n\tconst location =\n\t\tstats.sessionFile ??\n\t\t(this.sessionManager.isPersisted() ? this.sessionManager.getSessionStore().descriptor.location : \"In-memory\");\n\tinfo += `${theme.fg(\"dim\", \"File:\")} ${location}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"ID:\")} ${stats.sessionId}\\n\\n`;\n\tinfo += `${theme.bold(\"Messages\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"User:\")} ${stats.userMessages}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Assistant:\")} ${stats.assistantMessages}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Tool Calls:\")} ${stats.toolCalls}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Tool Results:\")} ${stats.toolResults}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.totalMessages}\\n\\n`;\n\tinfo += `${theme.bold(\"Tokens\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Input:\")} ${stats.tokens.input.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Output:\")} ${stats.tokens.output.toLocaleString()}\\n`;\n\tif (stats.tokens.cacheRead > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"Cache Read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n\t}\n\tif (stats.tokens.cacheWrite > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"Cache Write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n`;\n\tconst mirrorStats = engineStats ? this.session.getSessionStats() : stats;\n\tconst mirrorMatchesEngine =\n\t\tmirrorStats.sessionId === stats.sessionId &&\n\t\tmirrorStats.totalMessages === stats.totalMessages &&\n\t\tmirrorStats.cost === stats.cost &&\n\t\tmirrorStats.tokens.input === stats.tokens.input &&\n\t\tmirrorStats.tokens.output === stats.tokens.output &&\n\t\tmirrorStats.tokens.cacheRead === stats.tokens.cacheRead &&\n\t\tmirrorStats.tokens.cacheWrite === stats.tokens.cacheWrite;\n\tconst head = info;\n\tconst block = new Text(\"\", 1, 0);\n\t/** Fill the block; without `details`, only with the lines that do not need them, and `note` when there is one. */\n\tconst show = (details: SessionUsageDetails | undefined, note?: string) => {\n\t\tlet text = head;\n\t\tconst promptTokens = engineStats\n\t\t\t? engineStats.tokens.input + engineStats.tokens.cacheRead + engineStats.tokens.cacheWrite\n\t\t\t: (details?.promptTokens ?? 0);\n\t\tconst cacheRead = engineStats ? engineStats.tokens.cacheRead : (details?.cacheRead ?? 0);\n\t\tif (promptTokens > 0)\n\t\t\ttext += `${theme.fg(\"dim\", \"Cache Hit Rate:\")} ${((cacheRead / promptTokens) * 100).toFixed(1)}%\\n`;\n\t\tif (details && details.cacheWaste.missCount > 0)\n\t\t\ttext += `${theme.fg(\"dim\", \"Wasted Cache Cost:\")} ${formatCacheWaste(details.cacheWaste)}\\n`;\n\n\t\tif (stats.cost > 0) {\n\t\t\ttext += `\\n${theme.bold(\"Cost\")}\\n`;\n\t\t\ttext += `${theme.fg(\"dim\", \"Total:\")} ${stats.cost.toFixed(4)}`;\n\t\t\tfor (const item of details?.breakdown ?? []) {\n\t\t\t\ttext += `\\n${theme.fg(\"dim\", `${item.key}:`)} $${item.cost.toFixed(4)}`;\n\t\t\t}\n\t\t}\n\t\tif (note) text += `\\n${theme.fg(\"warning\", note)}`;\n\t\tblock.setText(text);\n\t};\n\tconst manager = this.sessionManager;\n\tconst models = createCacheMissModelSource(this.session.modelRuntime);\n\t// An isolated host's mirror that is behind its engine lists nothing it would have to guess.\n\tconst mirrorBehind = engineStats !== undefined && (this.session.isStreaming || !mirrorMatchesEngine);\n\tconst paged = !mirrorBehind && manager.hasFullHistory?.() === false;\n\tif (mirrorBehind) show(NO_USAGE_DETAILS);\n\telse if (!paged) show(sessionUsageDetails(manager.getEntries(), models));\n\telse show(undefined);\n\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(block);\n\tthis.ui.requestRender();\n\tif (!paged) return;\n\t// The per-model cost and cache lines cover the whole session (#5554). A manager holding only its window reads the\n\t// rest a page at a time and keeps none of it; the block is shown at once and those lines appear when the read ends.\n\tvoid readSessionUsageDetails(manager, models).then(\n\t\t(details) => {\n\t\t\tshow(details);\n\t\t\tthis.ui.requestRender();\n\t\t},\n\t\t(error: unknown) => {\n\t\t\tshow(\n\t\t\t\tundefined,\n\t\t\t\t`Could not read the earlier history for the per-model cost and cache lines: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t\tthis.ui.requestRender();\n\t\t},\n\t);\n}\n\nInteractiveModeBase.prototype.handleChangelogCommand = async function (this: InteractiveModeBase): Promise<void> {\n\tconst changelogPath = getChangelogPath();\n\tconst allEntries = await parseChangelogAsync(changelogPath);\n\n\tconst changelogMarkdown =\n\t\tallEntries.length > 0\n\t\t\t? allEntries\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.map((e) => normalizeChangelogLinks(e.content, e))\n\t\t\t\t\t.join(\"\\n\\n\")\n\t\t\t: \"No changelog entries found.\";\n\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(new DynamicBorder());\n\tthis.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0));\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(this.createChangelogMarkdown(changelogMarkdown, 1, 1));\n\tthis.chatContainer.addChild(new DynamicBorder());\n\tthis.ui.requestRender();\n};\n"]}
@@ -17,6 +17,9 @@ export type EndScreenHold = (key?: string) => void;
17
17
  export declare class ScreenHold {
18
18
  private state;
19
19
  private statusChanges;
20
+ private keys;
21
+ /** Counts the user's key presses (`isKeyPress`), seen before any handler acts on them. */
22
+ get keyPresses(): number;
20
23
  /** Counts the changes of a run's working status: a dock painted before the latest change shows one that is gone. */
21
24
  get statusEpoch(): number;
22
25
  /** The part held now, if any. */
@@ -1 +1 @@
1
- {"version":3,"file":"screen-hold.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/screen-hold.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEjD,+DAA+D;AAC/D,MAAM,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC;AAI3C,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQhD;AAED,gHAAgH;AAChH,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAMnD;;;;GAIG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,aAAa,CAAK;IAE1B,oHAAoH;IACpH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,iCAAiC;IACjC,IAAI,MAAM,IAAI,gBAAgB,GAAG,SAAS,CAEzC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,IAAI,KAAK,aAAa,GAAG,SAAS,GAAG,iBAAiB,CAc1G;IAED,yDAAyD;IACzD,GAAG,IAAI,IAAI,CAEV;IAED;;;OAGG;IACH,aAAa,IAAI,IAAI,CAGpB;IAED,qGAAqG;IACrG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE5B;CACD;AAID,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAOrD"}
1
+ {"version":3,"file":"screen-hold.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/screen-hold.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEjD,+DAA+D;AAC/D,MAAM,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC;AAI3C,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQhD;AAED,gHAAgH;AAChH,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAMnD;;;;GAIG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,IAAI,CAAK;IAEjB,0FAA0F;IAC1F,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,oHAAoH;IACpH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,iCAAiC;IACjC,IAAI,MAAM,IAAI,gBAAgB,GAAG,SAAS,CAEzC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,IAAI,KAAK,aAAa,GAAG,SAAS,GAAG,iBAAiB,CAc1G;IAED,yDAAyD;IACzD,GAAG,IAAI,IAAI,CAEV;IAED;;;OAGG;IACH,aAAa,IAAI,IAAI,CAGpB;IAED,qGAAqG;IACrG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAI5B;CACD;AAID,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAOrD"}
@@ -16,6 +16,11 @@ export function isKeyPress(data) {
16
16
  export class ScreenHold {
17
17
  state = { kind: "live" };
18
18
  statusChanges = 0;
19
+ keys = 0;
20
+ /** Counts the user's key presses (`isKeyPress`), seen before any handler acts on them. */
21
+ get keyPresses() {
22
+ return this.keys;
23
+ }
19
24
  /** Counts the changes of a run's working status: a dock painted before the latest change shows one that is gone. */
20
25
  get statusEpoch() {
21
26
  return this.statusChanges;
@@ -63,7 +68,10 @@ export class ScreenHold {
63
68
  }
64
69
  /** Input on its way to the screen, before any handler sees it: a key press shows the screen live. */
65
70
  noteInput(data) {
66
- if (this.state.kind === "held" && isKeyPress(data))
71
+ if (!isKeyPress(data))
72
+ return;
73
+ this.keys++;
74
+ if (this.state.kind === "held")
67
75
  this.state.end(data);
68
76
  }
69
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"screen-hold.js","sourceRoot":"","sources":["../../../src/modes/interactive/screen-hold.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAWnD,MAAM,YAAY,GAAsB,GAAG,EAAE,GAAE,CAAC,CAAC;AAEjD,mFAAmF;AACnF,MAAM,UAAU,UAAU,CAAC,IAAY;IACtC,OAAO,CACN,CAAC,YAAY,CAAC,IAAI,CAAC;QACnB,IAAI,KAAK,QAAQ;QACjB,IAAI,KAAK,QAAQ;QACjB,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAC1B,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAC1B,CAAC;AACH,CAAC;AASD;;;;GAIG;AACH,MAAM,OAAO,UAAU;IACd,KAAK,GAAoB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1C,aAAa,GAAG,CAAC,CAAC;IAE1B,oHAAoH;IACpH,IAAI,WAAW;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;IAED,iCAAiC;IACjC,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAwB,EAAE,KAAuD;QACtF,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM;YAAE,OAAO,YAAY,CAAC;QACpD,IAAI,IAAiC,CAAC;QACtC,MAAM,KAAK,GAAG,GAAG,EAAE;YAClB,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,KA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KAAK,SAAS,EAAE,CAAC;QACxB,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC;QACxB,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import { isKeyRelease } from \"@bastani/atomic-tui\";\n\n/**\n * The part of the screen a hold keeps as painted: the prompt's slot while a slash command's view opens, or everything\n * below the transcript while a subagent opened from `/tasks` is on its way.\n */\nexport type ScreenHoldRegion = \"prompt\" | \"dock\";\n\n/** Ends a hold, or nothing for a request that held nothing. */\nexport type ScreenHoldRelease = () => void;\n\nconst NOTHING_HELD: ScreenHoldRelease = () => {};\n\n/** A key the user pressed: not the release of one, nor a mouse or focus report. */\nexport function isKeyPress(data: string): boolean {\n\treturn (\n\t\t!isKeyRelease(data) &&\n\t\tdata !== \"\\x1b[I\" &&\n\t\tdata !== \"\\x1b[O\" &&\n\t\t!data.startsWith(\"\\x1b[<\") &&\n\t\t!data.startsWith(\"\\x1b[M\")\n\t);\n}\n\n/** Shows a held part live again; `key` is the user's key that ends it, which the screen handles right after. */\nexport type EndScreenHold = (key?: string) => void;\n\ntype ScreenHoldState =\n\t| { readonly kind: \"live\" }\n\t| { readonly kind: \"held\"; readonly region: ScreenHoldRegion; readonly end: EndScreenHold };\n\n/**\n * Which part of the screen, if any, is kept as painted while what replaces it is on its way. At most one part is held:\n * a request made while another hold is held joins it, keeps nothing more and does not move its bound. A hold keeps\n * only rows painted from live content, never rows another hold kept. The user's next key press shows the screen live.\n */\nexport class ScreenHold {\n\tprivate state: ScreenHoldState = { kind: \"live\" };\n\tprivate statusChanges = 0;\n\n\t/** Counts the changes of a run's working status: a dock painted before the latest change shows one that is gone. */\n\tget statusEpoch(): number {\n\t\treturn this.statusChanges;\n\t}\n\n\t/** The part held now, if any. */\n\tget region(): ScreenHoldRegion | undefined {\n\t\treturn this.state.kind === \"held\" ? this.state.region : undefined;\n\t}\n\n\t/**\n\t * Hold `region`. `start` keeps it as painted and answers how to show it live again, or undefined when it cannot (what\n\t * it painted is not live content); it calls `ended` once its hold ends on its own. Answers what ends this hold.\n\t */\n\tbegin(region: ScreenHoldRegion, start: (ended: () => void) => EndScreenHold | undefined): ScreenHoldRelease {\n\t\tif (this.state.kind === \"held\") return NOTHING_HELD;\n\t\tlet held: ScreenHoldState | undefined;\n\t\tconst ended = () => {\n\t\t\tif (held !== undefined && this.state === held) this.state = { kind: \"live\" };\n\t\t};\n\t\tconst end = start(ended);\n\t\tif (end === undefined) return NOTHING_HELD;\n\t\theld = { kind: \"held\", region, end };\n\t\tthis.state = held;\n\t\tconst self = held;\n\t\treturn () => {\n\t\t\tif (this.state === self) end();\n\t\t};\n\t}\n\n\t/** Show the screen live again, whatever part is held. */\n\tend(): void {\n\t\tif (this.state.kind === \"held\") this.state.end();\n\t}\n\n\t/**\n\t * A run's working status started or ended: a held dock, which has the status area in it, shows it live again. A held\n\t * prompt never has a working status in it (`PromptSlot` does not hold one that draws it), so it stays held.\n\t */\n\tstatusChanged(): void {\n\t\tthis.statusChanges++;\n\t\tif (this.state.kind === \"held\" && this.state.region === \"dock\") this.state.end();\n\t}\n\n\t/** Input on its way to the screen, before any handler sees it: a key press shows the screen live. */\n\tnoteInput(data: string): void {\n\t\tif (this.state.kind === \"held\" && isKeyPress(data)) this.state.end(data);\n\t}\n}\n\nconst holds = new WeakMap<object, ScreenHold>();\n\n/** The screen hold of the interactive mode `mode`. */\nexport function screenHoldOf(mode: object): ScreenHold {\n\tlet hold = holds.get(mode);\n\tif (hold === undefined) {\n\t\thold = new ScreenHold();\n\t\tholds.set(mode, hold);\n\t}\n\treturn hold;\n}\n"]}
1
+ {"version":3,"file":"screen-hold.js","sourceRoot":"","sources":["../../../src/modes/interactive/screen-hold.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAWnD,MAAM,YAAY,GAAsB,GAAG,EAAE,GAAE,CAAC,CAAC;A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","sourcesContent":["import { isKeyRelease } from \"@bastani/atomic-tui\";\n\n/**\n * The part of the screen a hold keeps as painted: the prompt's slot while a slash command's view opens, or everything\n * below the transcript while a subagent opened from `/tasks` is on its way.\n */\nexport type ScreenHoldRegion = \"prompt\" | \"dock\";\n\n/** Ends a hold, or nothing for a request that held nothing. */\nexport type ScreenHoldRelease = () => void;\n\nconst NOTHING_HELD: ScreenHoldRelease = () => {};\n\n/** A key the user pressed: not the release of one, nor a mouse or focus report. */\nexport function isKeyPress(data: string): boolean {\n\treturn (\n\t\t!isKeyRelease(data) &&\n\t\tdata !== \"\\x1b[I\" &&\n\t\tdata !== \"\\x1b[O\" &&\n\t\t!data.startsWith(\"\\x1b[<\") &&\n\t\t!data.startsWith(\"\\x1b[M\")\n\t);\n}\n\n/** Shows a held part live again; `key` is the user's key that ends it, which the screen handles right after. */\nexport type EndScreenHold = (key?: string) => void;\n\ntype ScreenHoldState =\n\t| { readonly kind: \"live\" }\n\t| { readonly kind: \"held\"; readonly region: ScreenHoldRegion; readonly end: EndScreenHold };\n\n/**\n * Which part of the screen, if any, is kept as painted while what replaces it is on its way. At most one part is held:\n * a request made while another hold is held joins it, keeps nothing more and does not move its bound. A hold keeps\n * only rows painted from live content, never rows another hold kept. The user's next key press shows the screen live.\n */\nexport class ScreenHold {\n\tprivate state: ScreenHoldState = { kind: \"live\" };\n\tprivate statusChanges = 0;\n\tprivate keys = 0;\n\n\t/** Counts the user's key presses (`isKeyPress`), seen before any handler acts on them. */\n\tget keyPresses(): number {\n\t\treturn this.keys;\n\t}\n\n\t/** Counts the changes of a run's working status: a dock painted before the latest change shows one that is gone. */\n\tget statusEpoch(): number {\n\t\treturn this.statusChanges;\n\t}\n\n\t/** The part held now, if any. */\n\tget region(): ScreenHoldRegion | undefined {\n\t\treturn this.state.kind === \"held\" ? this.state.region : undefined;\n\t}\n\n\t/**\n\t * Hold `region`. `start` keeps it as painted and answers how to show it live again, or undefined when it cannot (what\n\t * it painted is not live content); it calls `ended` once its hold ends on its own. Answers what ends this hold.\n\t */\n\tbegin(region: ScreenHoldRegion, start: (ended: () => void) => EndScreenHold | undefined): ScreenHoldRelease {\n\t\tif (this.state.kind === \"held\") return NOTHING_HELD;\n\t\tlet held: ScreenHoldState | undefined;\n\t\tconst ended = () => {\n\t\t\tif (held !== undefined && this.state === held) this.state = { kind: \"live\" };\n\t\t};\n\t\tconst end = start(ended);\n\t\tif (end === undefined) return NOTHING_HELD;\n\t\theld = { kind: \"held\", region, end };\n\t\tthis.state = held;\n\t\tconst self = held;\n\t\treturn () => {\n\t\t\tif (this.state === self) end();\n\t\t};\n\t}\n\n\t/** Show the screen live again, whatever part is held. */\n\tend(): void {\n\t\tif (this.state.kind === \"held\") this.state.end();\n\t}\n\n\t/**\n\t * A run's working status started or ended: a held dock, which has the status area in it, shows it live again. A held\n\t * prompt never has a working status in it (`PromptSlot` does not hold one that draws it), so it stays held.\n\t */\n\tstatusChanged(): void {\n\t\tthis.statusChanges++;\n\t\tif (this.state.kind === \"held\" && this.state.region === \"dock\") this.state.end();\n\t}\n\n\t/** Input on its way to the screen, before any handler sees it: a key press shows the screen live. */\n\tnoteInput(data: string): void {\n\t\tif (!isKeyPress(data)) return;\n\t\tthis.keys++;\n\t\tif (this.state.kind === \"held\") this.state.end(data);\n\t}\n}\n\nconst holds = new WeakMap<object, ScreenHold>();\n\n/** The screen hold of the interactive mode `mode`. */\nexport function screenHoldOf(mode: object): ScreenHold {\n\tlet hold = holds.get(mode);\n\tif (hold === undefined) {\n\t\thold = new ScreenHold();\n\t\tholds.set(mode, hold);\n\t}\n\treturn hold;\n}\n"]}
@@ -2,8 +2,13 @@ import { type ActivityWatchdogDiagnostic } from "./activity-watchdog.ts";
2
2
  import type { InteractiveEngineGenerationEnded } from "./engine-generation.ts";
3
3
  export type EngineDiagnosticListener = (diagnostic: ActivityWatchdogDiagnostic) => void;
4
4
  export interface EngineHealthDeps {
5
- /** Terminate the current (or hung replacement) engine child. */
6
- stop(): Promise<void>;
5
+ /**
6
+ * Terminate the current (or hung replacement) engine child. `graceful` lets a ready
7
+ * engine run its own shutdown first, within the client's bound.
8
+ */
9
+ stop(options?: {
10
+ graceful?: boolean;
11
+ }): Promise<void>;
7
12
  /** Replace the engine child and reload host state from it. */
8
13
  restart(replacementReady: () => void): Promise<void>;
9
14
  /** Drop streaming/compaction/callback activity owned by the dead generation. */
@@ -96,8 +101,11 @@ export declare class EngineHealthController {
96
101
  * its spawn: the client's restart permit is voided by `deps.stop()`, and the
97
102
  * attempt is then awaited so no child, and no host initialization, outlives
98
103
  * teardown. Idempotent, and bounded by the client's own stop deadlines.
104
+ * `graceful` is passed to that stop: a quit lets the engine run its own shutdown.
99
105
  */
100
- shutdown(): Promise<void>;
106
+ shutdown(options?: {
107
+ graceful?: boolean;
108
+ }): Promise<void>;
101
109
  handleGenerationEnded(event: InteractiveEngineGenerationEnded): void;
102
110
  terminate(): Promise<void>;
103
111
  /** Force-stop an overdue replacement, at most once per attempt. */