@eminent337/aery 0.1.52 → 0.1.54

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 (684) hide show
  1. package/CHANGELOG.md +0 -0
  2. package/README.md +0 -0
  3. package/dist/bun/cli.d.ts +3 -0
  4. package/dist/bun/cli.d.ts.map +1 -0
  5. package/dist/bun/cli.js +7 -0
  6. package/dist/bun/cli.js.map +1 -0
  7. package/dist/bun/register-bedrock.d.ts +2 -0
  8. package/dist/bun/register-bedrock.d.ts.map +1 -0
  9. package/dist/bun/register-bedrock.js +4 -0
  10. package/dist/bun/register-bedrock.js.map +1 -0
  11. package/dist/cli/args.d.ts +52 -0
  12. package/dist/cli/args.d.ts.map +1 -0
  13. package/dist/cli/args.js +321 -0
  14. package/dist/cli/args.js.map +1 -0
  15. package/dist/cli/config-selector.d.ts +14 -0
  16. package/dist/cli/config-selector.d.ts.map +1 -0
  17. package/dist/cli/config-selector.js +31 -0
  18. package/dist/cli/config-selector.js.map +1 -0
  19. package/dist/cli/file-processor.d.ts +15 -0
  20. package/dist/cli/file-processor.d.ts.map +1 -0
  21. package/dist/cli/file-processor.js +83 -0
  22. package/dist/cli/file-processor.js.map +1 -0
  23. package/dist/cli/initial-message.d.ts +18 -0
  24. package/dist/cli/initial-message.d.ts.map +1 -0
  25. package/dist/cli/initial-message.js +22 -0
  26. package/dist/cli/initial-message.js.map +1 -0
  27. package/dist/cli/list-models.d.ts +9 -0
  28. package/dist/cli/list-models.d.ts.map +1 -0
  29. package/dist/cli/list-models.js +97 -0
  30. package/dist/cli/list-models.js.map +1 -0
  31. package/dist/cli/session-picker.d.ts +9 -0
  32. package/dist/cli/session-picker.d.ts.map +1 -0
  33. package/dist/cli/session-picker.js +35 -0
  34. package/dist/cli/session-picker.js.map +1 -0
  35. package/dist/cli.d.ts +3 -0
  36. package/dist/cli.d.ts.map +1 -0
  37. package/dist/cli.js +15 -0
  38. package/dist/cli.js.map +1 -0
  39. package/dist/config.d.ts +77 -0
  40. package/dist/config.d.ts.map +1 -0
  41. package/dist/config.js +221 -0
  42. package/dist/config.js.map +1 -0
  43. package/dist/core/agent-session-runtime.d.ts +99 -0
  44. package/dist/core/agent-session-runtime.d.ts.map +1 -0
  45. package/dist/core/agent-session-runtime.js +261 -0
  46. package/dist/core/agent-session-runtime.js.map +1 -0
  47. package/dist/core/agent-session-services.d.ts +85 -0
  48. package/dist/core/agent-session-services.d.ts.map +1 -0
  49. package/dist/core/agent-session-services.js +116 -0
  50. package/dist/core/agent-session-services.js.map +1 -0
  51. package/dist/core/agent-session.d.ts +590 -0
  52. package/dist/core/agent-session.d.ts.map +1 -0
  53. package/dist/core/agent-session.js +2505 -0
  54. package/dist/core/agent-session.js.map +1 -0
  55. package/dist/core/auth-storage.d.ts +132 -0
  56. package/dist/core/auth-storage.d.ts.map +1 -0
  57. package/dist/core/auth-storage.js +422 -0
  58. package/dist/core/auth-storage.js.map +1 -0
  59. package/dist/core/bash-executor.d.ts +32 -0
  60. package/dist/core/bash-executor.d.ts.map +1 -0
  61. package/dist/core/bash-executor.js +108 -0
  62. package/dist/core/bash-executor.js.map +1 -0
  63. package/dist/core/compaction/branch-summarization.d.ts +88 -0
  64. package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  65. package/dist/core/compaction/branch-summarization.js +243 -0
  66. package/dist/core/compaction/branch-summarization.js.map +1 -0
  67. package/dist/core/compaction/compaction.d.ts +121 -0
  68. package/dist/core/compaction/compaction.d.ts.map +1 -0
  69. package/dist/core/compaction/compaction.js +615 -0
  70. package/dist/core/compaction/compaction.js.map +1 -0
  71. package/dist/core/compaction/index.d.ts +7 -0
  72. package/dist/core/compaction/index.d.ts.map +1 -0
  73. package/dist/core/compaction/index.js +7 -0
  74. package/dist/core/compaction/index.js.map +1 -0
  75. package/dist/core/compaction/utils.d.ts +38 -0
  76. package/dist/core/compaction/utils.d.ts.map +1 -0
  77. package/dist/core/compaction/utils.js +153 -0
  78. package/dist/core/compaction/utils.js.map +1 -0
  79. package/dist/core/defaults.d.ts +3 -0
  80. package/dist/core/defaults.d.ts.map +1 -0
  81. package/dist/core/defaults.js +2 -0
  82. package/dist/core/defaults.js.map +1 -0
  83. package/dist/core/diagnostics.d.ts +15 -0
  84. package/dist/core/diagnostics.d.ts.map +1 -0
  85. package/dist/core/diagnostics.js +2 -0
  86. package/dist/core/diagnostics.js.map +1 -0
  87. package/dist/core/event-bus.d.ts +9 -0
  88. package/dist/core/event-bus.d.ts.map +1 -0
  89. package/dist/core/event-bus.js +25 -0
  90. package/dist/core/event-bus.js.map +1 -0
  91. package/dist/core/exec.d.ts +29 -0
  92. package/dist/core/exec.d.ts.map +1 -0
  93. package/dist/core/exec.js +75 -0
  94. package/dist/core/exec.js.map +1 -0
  95. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  96. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  97. package/dist/core/export-html/ansi-to-html.js +249 -0
  98. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  99. package/dist/core/export-html/index.d.ts +37 -0
  100. package/dist/core/export-html/index.d.ts.map +1 -0
  101. package/dist/core/export-html/index.js +224 -0
  102. package/dist/core/export-html/index.js.map +1 -0
  103. package/dist/core/export-html/template.css +1017 -0
  104. package/dist/core/export-html/template.html +55 -0
  105. package/dist/core/export-html/template.js +1729 -0
  106. package/dist/core/export-html/tool-renderer.d.ts +40 -0
  107. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  108. package/dist/core/export-html/tool-renderer.js +95 -0
  109. package/dist/core/export-html/tool-renderer.js.map +1 -0
  110. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  111. package/dist/core/export-html/vendor/marked.min.js +6 -0
  112. package/dist/core/extensions/index.d.ts +12 -0
  113. package/dist/core/extensions/index.d.ts.map +1 -0
  114. package/dist/core/extensions/index.js +9 -0
  115. package/dist/core/extensions/index.js.map +1 -0
  116. package/dist/core/extensions/loader.d.ts +25 -0
  117. package/dist/core/extensions/loader.d.ts.map +1 -0
  118. package/dist/core/extensions/loader.js +436 -0
  119. package/dist/core/extensions/loader.js.map +1 -0
  120. package/dist/core/extensions/runner.d.ts +150 -0
  121. package/dist/core/extensions/runner.d.ts.map +1 -0
  122. package/dist/core/extensions/runner.js +706 -0
  123. package/dist/core/extensions/runner.js.map +1 -0
  124. package/dist/core/extensions/types.d.ts +1111 -0
  125. package/dist/core/extensions/types.d.ts.map +1 -0
  126. package/dist/core/extensions/types.js +45 -0
  127. package/dist/core/extensions/types.js.map +1 -0
  128. package/dist/core/extensions/wrapper.d.ts +20 -0
  129. package/dist/core/extensions/wrapper.d.ts.map +1 -0
  130. package/dist/core/extensions/wrapper.js +22 -0
  131. package/dist/core/extensions/wrapper.js.map +1 -0
  132. package/dist/core/footer-data-provider.d.ts +48 -0
  133. package/dist/core/footer-data-provider.d.ts.map +1 -0
  134. package/dist/core/footer-data-provider.js +314 -0
  135. package/dist/core/footer-data-provider.js.map +1 -0
  136. package/dist/core/index.d.ts +12 -0
  137. package/dist/core/index.d.ts.map +1 -0
  138. package/dist/core/index.js +12 -0
  139. package/dist/core/index.js.map +1 -0
  140. package/dist/core/keybindings.d.ts +353 -0
  141. package/dist/core/keybindings.d.ts.map +1 -0
  142. package/dist/core/keybindings.js +295 -0
  143. package/dist/core/keybindings.js.map +1 -0
  144. package/dist/core/messages.d.ts +77 -0
  145. package/dist/core/messages.d.ts.map +1 -0
  146. package/dist/core/messages.js +123 -0
  147. package/dist/core/messages.js.map +1 -0
  148. package/dist/core/model-registry.d.ts +132 -0
  149. package/dist/core/model-registry.d.ts.map +1 -0
  150. package/dist/core/model-registry.js +635 -0
  151. package/dist/core/model-registry.js.map +1 -0
  152. package/dist/core/model-resolver.d.ts +110 -0
  153. package/dist/core/model-resolver.d.ts.map +1 -0
  154. package/dist/core/model-resolver.js +486 -0
  155. package/dist/core/model-resolver.js.map +1 -0
  156. package/dist/core/output-guard.d.ts +6 -0
  157. package/dist/core/output-guard.d.ts.map +1 -0
  158. package/dist/core/output-guard.js +59 -0
  159. package/dist/core/output-guard.js.map +1 -0
  160. package/dist/core/package-manager.d.ts +194 -0
  161. package/dist/core/package-manager.d.ts.map +1 -0
  162. package/dist/core/package-manager.js +1882 -0
  163. package/dist/core/package-manager.js.map +1 -0
  164. package/dist/core/prompt-templates.d.ts +52 -0
  165. package/dist/core/prompt-templates.d.ts.map +1 -0
  166. package/dist/core/prompt-templates.js +250 -0
  167. package/dist/core/prompt-templates.js.map +1 -0
  168. package/dist/core/resolve-config-value.d.ts +23 -0
  169. package/dist/core/resolve-config-value.d.ts.map +1 -0
  170. package/dist/core/resolve-config-value.js +126 -0
  171. package/dist/core/resolve-config-value.js.map +1 -0
  172. package/dist/core/resource-loader.d.ts +194 -0
  173. package/dist/core/resource-loader.d.ts.map +1 -0
  174. package/dist/core/resource-loader.js +726 -0
  175. package/dist/core/resource-loader.js.map +1 -0
  176. package/dist/core/sdk.d.ts +99 -0
  177. package/dist/core/sdk.d.ts.map +1 -0
  178. package/dist/core/sdk.js +261 -0
  179. package/dist/core/sdk.js.map +1 -0
  180. package/dist/core/session-cwd.d.ts +19 -0
  181. package/dist/core/session-cwd.d.ts.map +1 -0
  182. package/dist/core/session-cwd.js +38 -0
  183. package/dist/core/session-cwd.js.map +1 -0
  184. package/dist/core/session-manager.d.ts +333 -0
  185. package/dist/core/session-manager.d.ts.map +1 -0
  186. package/dist/core/session-manager.js +1109 -0
  187. package/dist/core/session-manager.js.map +1 -0
  188. package/dist/core/settings-manager.d.ts +240 -0
  189. package/dist/core/settings-manager.d.ts.map +1 -0
  190. package/dist/core/settings-manager.js +711 -0
  191. package/dist/core/settings-manager.js.map +1 -0
  192. package/dist/core/skills.d.ts +60 -0
  193. package/dist/core/skills.d.ts.map +1 -0
  194. package/dist/core/skills.js +409 -0
  195. package/dist/core/skills.js.map +1 -0
  196. package/dist/core/slash-commands.d.ts +14 -0
  197. package/dist/core/slash-commands.d.ts.map +1 -0
  198. package/dist/core/slash-commands.js +24 -0
  199. package/dist/core/slash-commands.js.map +1 -0
  200. package/dist/core/source-info.d.ts +18 -0
  201. package/dist/core/source-info.d.ts.map +1 -0
  202. package/dist/core/source-info.js +19 -0
  203. package/dist/core/source-info.js.map +1 -0
  204. package/dist/core/system-prompt.d.ts +28 -0
  205. package/dist/core/system-prompt.d.ts.map +1 -0
  206. package/dist/core/system-prompt.js +120 -0
  207. package/dist/core/system-prompt.js.map +1 -0
  208. package/dist/core/telemetry.d.ts +3 -0
  209. package/dist/core/telemetry.d.ts.map +1 -0
  210. package/dist/core/telemetry.js +9 -0
  211. package/dist/core/telemetry.js.map +1 -0
  212. package/dist/core/timings.d.ts +8 -0
  213. package/dist/core/timings.d.ts.map +1 -0
  214. package/dist/core/timings.js +31 -0
  215. package/dist/core/timings.js.map +1 -0
  216. package/dist/core/tools/bash.d.ts +64 -0
  217. package/dist/core/tools/bash.d.ts.map +1 -0
  218. package/dist/core/tools/bash.js +355 -0
  219. package/dist/core/tools/bash.js.map +1 -0
  220. package/dist/core/tools/edit-diff.d.ts +85 -0
  221. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  222. package/dist/core/tools/edit-diff.js +337 -0
  223. package/dist/core/tools/edit-diff.js.map +1 -0
  224. package/dist/core/tools/edit.d.ts +49 -0
  225. package/dist/core/tools/edit.d.ts.map +1 -0
  226. package/dist/core/tools/edit.js +323 -0
  227. package/dist/core/tools/edit.js.map +1 -0
  228. package/dist/core/tools/file-mutation-queue.d.ts +6 -0
  229. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
  230. package/dist/core/tools/file-mutation-queue.js +37 -0
  231. package/dist/core/tools/file-mutation-queue.js.map +1 -0
  232. package/dist/core/tools/find.d.ts +35 -0
  233. package/dist/core/tools/find.d.ts.map +1 -0
  234. package/dist/core/tools/find.js +298 -0
  235. package/dist/core/tools/find.js.map +1 -0
  236. package/dist/core/tools/grep.d.ts +37 -0
  237. package/dist/core/tools/grep.d.ts.map +1 -0
  238. package/dist/core/tools/grep.js +304 -0
  239. package/dist/core/tools/grep.js.map +1 -0
  240. package/dist/core/tools/index.d.ts +40 -0
  241. package/dist/core/tools/index.d.ts.map +1 -0
  242. package/dist/core/tools/index.js +112 -0
  243. package/dist/core/tools/index.js.map +1 -0
  244. package/dist/core/tools/ls.d.ts +37 -0
  245. package/dist/core/tools/ls.d.ts.map +1 -0
  246. package/dist/core/tools/ls.js +169 -0
  247. package/dist/core/tools/ls.js.map +1 -0
  248. package/dist/core/tools/path-utils.d.ts +8 -0
  249. package/dist/core/tools/path-utils.d.ts.map +1 -0
  250. package/dist/core/tools/path-utils.js +81 -0
  251. package/dist/core/tools/path-utils.js.map +1 -0
  252. package/dist/core/tools/read.d.ts +35 -0
  253. package/dist/core/tools/read.d.ts.map +1 -0
  254. package/dist/core/tools/read.js +232 -0
  255. package/dist/core/tools/read.js.map +1 -0
  256. package/dist/core/tools/render-utils.d.ts +21 -0
  257. package/dist/core/tools/render-utils.d.ts.map +1 -0
  258. package/dist/core/tools/render-utils.js +49 -0
  259. package/dist/core/tools/render-utils.js.map +1 -0
  260. package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
  261. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
  262. package/dist/core/tools/tool-definition-wrapper.js +34 -0
  263. package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
  264. package/dist/core/tools/truncate.d.ts +70 -0
  265. package/dist/core/tools/truncate.d.ts.map +1 -0
  266. package/dist/core/tools/truncate.js +205 -0
  267. package/dist/core/tools/truncate.js.map +1 -0
  268. package/dist/core/tools/write.d.ts +26 -0
  269. package/dist/core/tools/write.d.ts.map +1 -0
  270. package/dist/core/tools/write.js +213 -0
  271. package/dist/core/tools/write.js.map +1 -0
  272. package/dist/index.d.ts +28 -0
  273. package/dist/index.d.ts.map +1 -0
  274. package/dist/index.js +41 -0
  275. package/dist/index.js.map +1 -0
  276. package/dist/main.d.ts +12 -0
  277. package/dist/main.d.ts.map +1 -0
  278. package/dist/main.js +589 -0
  279. package/dist/main.js.map +1 -0
  280. package/dist/migrations.d.ts +33 -0
  281. package/dist/migrations.d.ts.map +1 -0
  282. package/dist/migrations.js +281 -0
  283. package/dist/migrations.js.map +1 -0
  284. package/dist/modes/index.d.ts +9 -0
  285. package/dist/modes/index.d.ts.map +1 -0
  286. package/dist/modes/index.js +8 -0
  287. package/dist/modes/index.js.map +1 -0
  288. package/dist/modes/interactive/assets/clankolas.png +0 -0
  289. package/dist/modes/interactive/components/aery-splash.d.ts +18 -0
  290. package/dist/modes/interactive/components/aery-splash.d.ts.map +1 -0
  291. package/dist/modes/interactive/components/aery-splash.js +60 -0
  292. package/dist/modes/interactive/components/aery-splash.js.map +1 -0
  293. package/dist/modes/interactive/components/armin.d.ts +34 -0
  294. package/dist/modes/interactive/components/armin.d.ts.map +1 -0
  295. package/dist/modes/interactive/components/armin.js +333 -0
  296. package/dist/modes/interactive/components/armin.js.map +1 -0
  297. package/dist/modes/interactive/components/assistant-message.d.ts +20 -0
  298. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  299. package/dist/modes/interactive/components/assistant-message.js +121 -0
  300. package/dist/modes/interactive/components/assistant-message.js.map +1 -0
  301. package/dist/modes/interactive/components/bash-execution.d.ts +34 -0
  302. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  303. package/dist/modes/interactive/components/bash-execution.js +175 -0
  304. package/dist/modes/interactive/components/bash-execution.js.map +1 -0
  305. package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
  306. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  307. package/dist/modes/interactive/components/bordered-loader.js +54 -0
  308. package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  309. package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
  310. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  311. package/dist/modes/interactive/components/branch-summary-message.js +44 -0
  312. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  313. package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
  314. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  315. package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
  316. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  317. package/dist/modes/interactive/components/config-selector.d.ts +71 -0
  318. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  319. package/dist/modes/interactive/components/config-selector.js +479 -0
  320. package/dist/modes/interactive/components/config-selector.js.map +1 -0
  321. package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  322. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  323. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  324. package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  325. package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
  326. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  327. package/dist/modes/interactive/components/custom-editor.js +70 -0
  328. package/dist/modes/interactive/components/custom-editor.js.map +1 -0
  329. package/dist/modes/interactive/components/custom-message.d.ts +20 -0
  330. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  331. package/dist/modes/interactive/components/custom-message.js +79 -0
  332. package/dist/modes/interactive/components/custom-message.js.map +1 -0
  333. package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
  334. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
  335. package/dist/modes/interactive/components/daxnuts.js +140 -0
  336. package/dist/modes/interactive/components/daxnuts.js.map +1 -0
  337. package/dist/modes/interactive/components/diff.d.ts +12 -0
  338. package/dist/modes/interactive/components/diff.d.ts.map +1 -0
  339. package/dist/modes/interactive/components/diff.js +133 -0
  340. package/dist/modes/interactive/components/diff.js.map +1 -0
  341. package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  342. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  343. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  344. package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  345. package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
  346. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
  347. package/dist/modes/interactive/components/earendil-announcement.js +40 -0
  348. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
  349. package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
  350. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  351. package/dist/modes/interactive/components/extension-editor.js +111 -0
  352. package/dist/modes/interactive/components/extension-editor.js.map +1 -0
  353. package/dist/modes/interactive/components/extension-input.d.ts +23 -0
  354. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  355. package/dist/modes/interactive/components/extension-input.js +61 -0
  356. package/dist/modes/interactive/components/extension-input.js.map +1 -0
  357. package/dist/modes/interactive/components/extension-selector.d.ts +24 -0
  358. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  359. package/dist/modes/interactive/components/extension-selector.js +78 -0
  360. package/dist/modes/interactive/components/extension-selector.js.map +1 -0
  361. package/dist/modes/interactive/components/footer.d.ts +27 -0
  362. package/dist/modes/interactive/components/footer.d.ts.map +1 -0
  363. package/dist/modes/interactive/components/footer.js +201 -0
  364. package/dist/modes/interactive/components/footer.js.map +1 -0
  365. package/dist/modes/interactive/components/index.d.ts +32 -0
  366. package/dist/modes/interactive/components/index.d.ts.map +1 -0
  367. package/dist/modes/interactive/components/index.js +33 -0
  368. package/dist/modes/interactive/components/index.js.map +1 -0
  369. package/dist/modes/interactive/components/keybinding-hints.d.ts +8 -0
  370. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  371. package/dist/modes/interactive/components/keybinding-hints.js +22 -0
  372. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  373. package/dist/modes/interactive/components/login-dialog.d.ts +42 -0
  374. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
  375. package/dist/modes/interactive/components/login-dialog.js +145 -0
  376. package/dist/modes/interactive/components/login-dialog.js.map +1 -0
  377. package/dist/modes/interactive/components/model-selector.d.ts +47 -0
  378. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  379. package/dist/modes/interactive/components/model-selector.js +278 -0
  380. package/dist/modes/interactive/components/model-selector.js.map +1 -0
  381. package/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
  382. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
  383. package/dist/modes/interactive/components/oauth-selector.js +97 -0
  384. package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
  385. package/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
  386. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
  387. package/dist/modes/interactive/components/scoped-models-selector.js +290 -0
  388. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
  389. package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
  390. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  391. package/dist/modes/interactive/components/session-selector-search.js +155 -0
  392. package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  393. package/dist/modes/interactive/components/session-selector.d.ts +96 -0
  394. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  395. package/dist/modes/interactive/components/session-selector.js +865 -0
  396. package/dist/modes/interactive/components/session-selector.js.map +1 -0
  397. package/dist/modes/interactive/components/settings-selector.d.ts +60 -0
  398. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  399. package/dist/modes/interactive/components/settings-selector.js +311 -0
  400. package/dist/modes/interactive/components/settings-selector.js.map +1 -0
  401. package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  402. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  403. package/dist/modes/interactive/components/show-images-selector.js +39 -0
  404. package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  405. package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
  406. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  407. package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
  408. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  409. package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  410. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  411. package/dist/modes/interactive/components/theme-selector.js +50 -0
  412. package/dist/modes/interactive/components/theme-selector.js.map +1 -0
  413. package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
  414. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  415. package/dist/modes/interactive/components/thinking-selector.js +51 -0
  416. package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  417. package/dist/modes/interactive/components/tool-execution.d.ts +60 -0
  418. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  419. package/dist/modes/interactive/components/tool-execution.js +289 -0
  420. package/dist/modes/interactive/components/tool-execution.js.map +1 -0
  421. package/dist/modes/interactive/components/tree-selector.d.ts +89 -0
  422. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  423. package/dist/modes/interactive/components/tree-selector.js +1092 -0
  424. package/dist/modes/interactive/components/tree-selector.js.map +1 -0
  425. package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
  426. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  427. package/dist/modes/interactive/components/user-message-selector.js +114 -0
  428. package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  429. package/dist/modes/interactive/components/user-message.d.ts +10 -0
  430. package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  431. package/dist/modes/interactive/components/user-message.js +29 -0
  432. package/dist/modes/interactive/components/user-message.js.map +1 -0
  433. package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
  434. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  435. package/dist/modes/interactive/components/visual-truncate.js +33 -0
  436. package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  437. package/dist/modes/interactive/interactive-mode.d.ts +344 -0
  438. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  439. package/dist/modes/interactive/interactive-mode.js +4352 -0
  440. package/dist/modes/interactive/interactive-mode.js.map +1 -0
  441. package/dist/modes/interactive/theme/aery.json +84 -0
  442. package/dist/modes/interactive/theme/catppuccin-mocha.json +81 -0
  443. package/dist/modes/interactive/theme/dark.json +85 -0
  444. package/dist/modes/interactive/theme/dracula.json +81 -0
  445. package/dist/modes/interactive/theme/light.json +84 -0
  446. package/dist/modes/interactive/theme/nord.json +81 -0
  447. package/dist/modes/interactive/theme/theme-schema.json +335 -0
  448. package/dist/modes/interactive/theme/theme.d.ts +81 -0
  449. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  450. package/dist/modes/interactive/theme/theme.js +983 -0
  451. package/dist/modes/interactive/theme/theme.js.map +1 -0
  452. package/dist/modes/interactive/theme/tokyo-night.json +81 -0
  453. package/dist/modes/print-mode.d.ts +28 -0
  454. package/dist/modes/print-mode.d.ts.map +1 -0
  455. package/dist/modes/print-mode.js +141 -0
  456. package/dist/modes/print-mode.js.map +1 -0
  457. package/dist/modes/rpc/jsonl.d.ts +17 -0
  458. package/dist/modes/rpc/jsonl.d.ts.map +1 -0
  459. package/dist/modes/rpc/jsonl.js +49 -0
  460. package/dist/modes/rpc/jsonl.js.map +1 -0
  461. package/dist/modes/rpc/rpc-client.d.ts +224 -0
  462. package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  463. package/dist/modes/rpc/rpc-client.js +410 -0
  464. package/dist/modes/rpc/rpc-client.js.map +1 -0
  465. package/dist/modes/rpc/rpc-mode.d.ts +20 -0
  466. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  467. package/dist/modes/rpc/rpc-mode.js +601 -0
  468. package/dist/modes/rpc/rpc-mode.js.map +1 -0
  469. package/dist/modes/rpc/rpc-types.d.ts +419 -0
  470. package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  471. package/dist/modes/rpc/rpc-types.js +8 -0
  472. package/dist/modes/rpc/rpc-types.js.map +1 -0
  473. package/dist/package-manager-cli.d.ts +4 -0
  474. package/dist/package-manager-cli.d.ts.map +1 -0
  475. package/dist/package-manager-cli.js +234 -0
  476. package/dist/package-manager-cli.js.map +1 -0
  477. package/dist/utils/changelog.d.ts +21 -0
  478. package/dist/utils/changelog.d.ts.map +1 -0
  479. package/dist/utils/changelog.js +87 -0
  480. package/dist/utils/changelog.js.map +1 -0
  481. package/dist/utils/child-process.d.ts +11 -0
  482. package/dist/utils/child-process.d.ts.map +1 -0
  483. package/dist/utils/child-process.js +78 -0
  484. package/dist/utils/child-process.js.map +1 -0
  485. package/dist/utils/clipboard-image.d.ts +11 -0
  486. package/dist/utils/clipboard-image.d.ts.map +1 -0
  487. package/dist/utils/clipboard-image.js +245 -0
  488. package/dist/utils/clipboard-image.js.map +1 -0
  489. package/dist/utils/clipboard-native.d.ts +8 -0
  490. package/dist/utils/clipboard-native.d.ts.map +1 -0
  491. package/dist/utils/clipboard-native.js +14 -0
  492. package/dist/utils/clipboard-native.js.map +1 -0
  493. package/dist/utils/clipboard.d.ts +2 -0
  494. package/dist/utils/clipboard.d.ts.map +1 -0
  495. package/dist/utils/clipboard.js +78 -0
  496. package/dist/utils/clipboard.js.map +1 -0
  497. package/dist/utils/exif-orientation.d.ts +5 -0
  498. package/dist/utils/exif-orientation.d.ts.map +1 -0
  499. package/dist/utils/exif-orientation.js +158 -0
  500. package/dist/utils/exif-orientation.js.map +1 -0
  501. package/dist/utils/frontmatter.d.ts +8 -0
  502. package/dist/utils/frontmatter.d.ts.map +1 -0
  503. package/dist/utils/frontmatter.js +26 -0
  504. package/dist/utils/frontmatter.js.map +1 -0
  505. package/dist/utils/git.d.ts +26 -0
  506. package/dist/utils/git.d.ts.map +1 -0
  507. package/dist/utils/git.js +163 -0
  508. package/dist/utils/git.js.map +1 -0
  509. package/dist/utils/image-convert.d.ts +9 -0
  510. package/dist/utils/image-convert.d.ts.map +1 -0
  511. package/dist/utils/image-convert.js +39 -0
  512. package/dist/utils/image-convert.js.map +1 -0
  513. package/dist/utils/image-resize.d.ts +36 -0
  514. package/dist/utils/image-resize.d.ts.map +1 -0
  515. package/dist/utils/image-resize.js +137 -0
  516. package/dist/utils/image-resize.js.map +1 -0
  517. package/dist/utils/mime.d.ts +2 -0
  518. package/dist/utils/mime.d.ts.map +1 -0
  519. package/dist/utils/mime.js +26 -0
  520. package/dist/utils/mime.js.map +1 -0
  521. package/dist/utils/paths.d.ts +7 -0
  522. package/dist/utils/paths.d.ts.map +1 -0
  523. package/dist/utils/paths.js +19 -0
  524. package/dist/utils/paths.js.map +1 -0
  525. package/dist/utils/photon.d.ts +21 -0
  526. package/dist/utils/photon.d.ts.map +1 -0
  527. package/dist/utils/photon.js +121 -0
  528. package/dist/utils/photon.js.map +1 -0
  529. package/dist/utils/shell.d.ts +29 -0
  530. package/dist/utils/shell.d.ts.map +1 -0
  531. package/dist/utils/shell.js +203 -0
  532. package/dist/utils/shell.js.map +1 -0
  533. package/dist/utils/sleep.d.ts +5 -0
  534. package/dist/utils/sleep.d.ts.map +1 -0
  535. package/dist/utils/sleep.js +17 -0
  536. package/dist/utils/sleep.js.map +1 -0
  537. package/dist/utils/tools-manager.d.ts +3 -0
  538. package/dist/utils/tools-manager.d.ts.map +1 -0
  539. package/dist/utils/tools-manager.js +252 -0
  540. package/dist/utils/tools-manager.js.map +1 -0
  541. package/docs/compaction.md +0 -0
  542. package/docs/custom-provider.md +0 -0
  543. package/docs/development.md +0 -0
  544. package/docs/extensions.md +0 -0
  545. package/docs/images/doom-extension.png +0 -0
  546. package/docs/images/exy.png +0 -0
  547. package/docs/images/interactive-mode.png +0 -0
  548. package/docs/images/tree-view.png +0 -0
  549. package/docs/json.md +0 -0
  550. package/docs/keybindings.md +0 -0
  551. package/docs/models.md +0 -0
  552. package/docs/packages.md +0 -0
  553. package/docs/prompt-templates.md +0 -0
  554. package/docs/providers.md +0 -0
  555. package/docs/rpc.md +0 -0
  556. package/docs/sdk.md +0 -0
  557. package/docs/session.md +0 -0
  558. package/docs/settings.md +0 -0
  559. package/docs/shell-aliases.md +0 -0
  560. package/docs/skills.md +0 -0
  561. package/docs/terminal-setup.md +0 -0
  562. package/docs/termux.md +0 -0
  563. package/docs/themes.md +0 -0
  564. package/docs/tmux.md +0 -0
  565. package/docs/tree.md +0 -0
  566. package/docs/tui.md +0 -0
  567. package/docs/windows.md +0 -0
  568. package/examples/README.md +0 -0
  569. package/examples/extensions/README.md +0 -0
  570. package/examples/extensions/antigravity-image-gen.ts +0 -0
  571. package/examples/extensions/auto-commit-on-exit.ts +0 -0
  572. package/examples/extensions/bash-spawn-hook.ts +0 -0
  573. package/examples/extensions/bookmark.ts +0 -0
  574. package/examples/extensions/built-in-tool-renderer.ts +0 -0
  575. package/examples/extensions/claude-rules.ts +0 -0
  576. package/examples/extensions/commands.ts +0 -0
  577. package/examples/extensions/confirm-destructive.ts +0 -0
  578. package/examples/extensions/custom-compaction.ts +0 -0
  579. package/examples/extensions/custom-footer.ts +0 -0
  580. package/examples/extensions/custom-header.ts +0 -0
  581. package/examples/extensions/custom-provider-anthropic/index.ts +0 -0
  582. package/examples/extensions/custom-provider-anthropic/package-lock.json +0 -0
  583. package/examples/extensions/custom-provider-anthropic/package.json +0 -0
  584. package/examples/extensions/custom-provider-gitlab-duo/index.ts +0 -0
  585. package/examples/extensions/custom-provider-gitlab-duo/package.json +0 -0
  586. package/examples/extensions/custom-provider-gitlab-duo/test.ts +0 -0
  587. package/examples/extensions/custom-provider-qwen-cli/index.ts +0 -0
  588. package/examples/extensions/custom-provider-qwen-cli/package.json +0 -0
  589. package/examples/extensions/dirty-repo-guard.ts +0 -0
  590. package/examples/extensions/doom-overlay/README.md +0 -0
  591. package/examples/extensions/doom-overlay/doom/build/doom.js +0 -0
  592. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +0 -0
  593. package/examples/extensions/doom-overlay/doom-component.ts +0 -0
  594. package/examples/extensions/doom-overlay/doom-engine.ts +0 -0
  595. package/examples/extensions/doom-overlay/doom-keys.ts +0 -0
  596. package/examples/extensions/doom-overlay/index.ts +0 -0
  597. package/examples/extensions/doom-overlay/wad-finder.ts +0 -0
  598. package/examples/extensions/dynamic-resources/SKILL.md +0 -0
  599. package/examples/extensions/dynamic-resources/dynamic.json +0 -0
  600. package/examples/extensions/dynamic-resources/dynamic.md +0 -0
  601. package/examples/extensions/dynamic-resources/index.ts +0 -0
  602. package/examples/extensions/dynamic-tools.ts +0 -0
  603. package/examples/extensions/event-bus.ts +0 -0
  604. package/examples/extensions/file-trigger.ts +0 -0
  605. package/examples/extensions/git-checkpoint.ts +0 -0
  606. package/examples/extensions/handoff.ts +0 -0
  607. package/examples/extensions/hello.ts +0 -0
  608. package/examples/extensions/hidden-thinking-label.ts +0 -0
  609. package/examples/extensions/inline-bash.ts +0 -0
  610. package/examples/extensions/input-transform.ts +0 -0
  611. package/examples/extensions/interactive-shell.ts +0 -0
  612. package/examples/extensions/mac-system-theme.ts +0 -0
  613. package/examples/extensions/message-renderer.ts +0 -0
  614. package/examples/extensions/minimal-mode.ts +0 -0
  615. package/examples/extensions/modal-editor.ts +0 -0
  616. package/examples/extensions/model-status.ts +0 -0
  617. package/examples/extensions/notify.ts +0 -0
  618. package/examples/extensions/overlay-qa-tests.ts +0 -0
  619. package/examples/extensions/overlay-test.ts +0 -0
  620. package/examples/extensions/permission-gate.ts +0 -0
  621. package/examples/extensions/pirate.ts +0 -0
  622. package/examples/extensions/plan-mode/README.md +0 -0
  623. package/examples/extensions/plan-mode/index.ts +0 -0
  624. package/examples/extensions/plan-mode/utils.ts +0 -0
  625. package/examples/extensions/preset.ts +0 -0
  626. package/examples/extensions/protected-paths.ts +0 -0
  627. package/examples/extensions/provider-payload.ts +0 -0
  628. package/examples/extensions/qna.ts +0 -0
  629. package/examples/extensions/question.ts +0 -0
  630. package/examples/extensions/questionnaire.ts +0 -0
  631. package/examples/extensions/rainbow-editor.ts +0 -0
  632. package/examples/extensions/reload-runtime.ts +0 -0
  633. package/examples/extensions/rpc-demo.ts +0 -0
  634. package/examples/extensions/sandbox/index.ts +0 -0
  635. package/examples/extensions/sandbox/package-lock.json +0 -0
  636. package/examples/extensions/sandbox/package.json +0 -0
  637. package/examples/extensions/send-user-message.ts +0 -0
  638. package/examples/extensions/session-name.ts +0 -0
  639. package/examples/extensions/shutdown-command.ts +0 -0
  640. package/examples/extensions/snake.ts +0 -0
  641. package/examples/extensions/space-invaders.ts +0 -0
  642. package/examples/extensions/ssh.ts +0 -0
  643. package/examples/extensions/status-line.ts +0 -0
  644. package/examples/extensions/subagent/README.md +0 -0
  645. package/examples/extensions/subagent/agents/planner.md +0 -0
  646. package/examples/extensions/subagent/agents/reviewer.md +0 -0
  647. package/examples/extensions/subagent/agents/scout.md +0 -0
  648. package/examples/extensions/subagent/agents/worker.md +0 -0
  649. package/examples/extensions/subagent/agents.ts +0 -0
  650. package/examples/extensions/subagent/index.ts +0 -0
  651. package/examples/extensions/subagent/prompts/implement-and-review.md +0 -0
  652. package/examples/extensions/subagent/prompts/implement.md +0 -0
  653. package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -0
  654. package/examples/extensions/summarize.ts +0 -0
  655. package/examples/extensions/system-prompt-header.ts +0 -0
  656. package/examples/extensions/tic-tac-toe.ts +0 -0
  657. package/examples/extensions/timed-confirm.ts +0 -0
  658. package/examples/extensions/titlebar-spinner.ts +0 -0
  659. package/examples/extensions/todo.ts +0 -0
  660. package/examples/extensions/tool-override.ts +0 -0
  661. package/examples/extensions/tools.ts +0 -0
  662. package/examples/extensions/trigger-compact.ts +0 -0
  663. package/examples/extensions/truncated-tool.ts +0 -0
  664. package/examples/extensions/widget-placement.ts +0 -0
  665. package/examples/extensions/with-deps/index.ts +0 -0
  666. package/examples/extensions/with-deps/package-lock.json +0 -0
  667. package/examples/extensions/with-deps/package.json +0 -0
  668. package/examples/extensions/working-indicator.ts +0 -0
  669. package/examples/rpc-extension-ui.ts +0 -0
  670. package/examples/sdk/01-minimal.ts +0 -0
  671. package/examples/sdk/02-custom-model.ts +0 -0
  672. package/examples/sdk/03-custom-prompt.ts +0 -0
  673. package/examples/sdk/04-skills.ts +0 -0
  674. package/examples/sdk/05-tools.ts +0 -0
  675. package/examples/sdk/06-extensions.ts +0 -0
  676. package/examples/sdk/07-context-files.ts +0 -0
  677. package/examples/sdk/08-prompt-templates.ts +0 -0
  678. package/examples/sdk/09-api-keys-and-oauth.ts +0 -0
  679. package/examples/sdk/10-settings.ts +0 -0
  680. package/examples/sdk/11-sessions.ts +0 -0
  681. package/examples/sdk/12-full-control.ts +0 -0
  682. package/examples/sdk/13-session-runtime.ts +0 -0
  683. package/examples/sdk/README.md +0 -0
  684. package/package.json +3 -3
@@ -0,0 +1,865 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { existsSync, realpathSync } from "node:fs";
3
+ import { unlink } from "node:fs/promises";
4
+ import * as os from "node:os";
5
+ import { Container, getKeybindings, Input, Spacer, Text, truncateToWidth, visibleWidth, } from "@eminent337/aery-tui";
6
+ import { KeybindingsManager } from "../../../core/keybindings.js";
7
+ import { theme } from "../theme/theme.js";
8
+ import { DynamicBorder } from "./dynamic-border.js";
9
+ import { keyHint, keyText } from "./keybinding-hints.js";
10
+ import { filterAndSortSessions, hasSessionName } from "./session-selector-search.js";
11
+ function shortenPath(path) {
12
+ const home = os.homedir();
13
+ if (!path)
14
+ return path;
15
+ if (path.startsWith(home)) {
16
+ return `~${path.slice(home.length)}`;
17
+ }
18
+ return path;
19
+ }
20
+ function formatSessionDate(date) {
21
+ const now = new Date();
22
+ const diffMs = now.getTime() - date.getTime();
23
+ const diffMins = Math.floor(diffMs / 60000);
24
+ const diffHours = Math.floor(diffMs / 3600000);
25
+ const diffDays = Math.floor(diffMs / 86400000);
26
+ if (diffMins < 1)
27
+ return "now";
28
+ if (diffMins < 60)
29
+ return `${diffMins}m`;
30
+ if (diffHours < 24)
31
+ return `${diffHours}h`;
32
+ if (diffDays < 7)
33
+ return `${diffDays}d`;
34
+ if (diffDays < 30)
35
+ return `${Math.floor(diffDays / 7)}w`;
36
+ if (diffDays < 365)
37
+ return `${Math.floor(diffDays / 30)}mo`;
38
+ return `${Math.floor(diffDays / 365)}y`;
39
+ }
40
+ function canonicalizePath(path) {
41
+ if (!path)
42
+ return path;
43
+ try {
44
+ return realpathSync(path);
45
+ }
46
+ catch {
47
+ return path;
48
+ }
49
+ }
50
+ class SessionSelectorHeader {
51
+ scope;
52
+ sortMode;
53
+ nameFilter;
54
+ requestRender;
55
+ loading = false;
56
+ loadProgress = null;
57
+ showPath = false;
58
+ confirmingDeletePath = null;
59
+ statusMessage = null;
60
+ statusTimeout = null;
61
+ showRenameHint = false;
62
+ constructor(scope, sortMode, nameFilter, requestRender) {
63
+ this.scope = scope;
64
+ this.sortMode = sortMode;
65
+ this.nameFilter = nameFilter;
66
+ this.requestRender = requestRender;
67
+ }
68
+ setScope(scope) {
69
+ this.scope = scope;
70
+ }
71
+ setSortMode(sortMode) {
72
+ this.sortMode = sortMode;
73
+ }
74
+ setNameFilter(nameFilter) {
75
+ this.nameFilter = nameFilter;
76
+ }
77
+ setLoading(loading) {
78
+ this.loading = loading;
79
+ // Progress is scoped to the current load; clear whenever the loading state is set
80
+ this.loadProgress = null;
81
+ }
82
+ setProgress(loaded, total) {
83
+ this.loadProgress = { loaded, total };
84
+ }
85
+ setShowPath(showPath) {
86
+ this.showPath = showPath;
87
+ }
88
+ setShowRenameHint(show) {
89
+ this.showRenameHint = show;
90
+ }
91
+ setConfirmingDeletePath(path) {
92
+ this.confirmingDeletePath = path;
93
+ }
94
+ clearStatusTimeout() {
95
+ if (!this.statusTimeout)
96
+ return;
97
+ clearTimeout(this.statusTimeout);
98
+ this.statusTimeout = null;
99
+ }
100
+ setStatusMessage(msg, autoHideMs) {
101
+ this.clearStatusTimeout();
102
+ this.statusMessage = msg;
103
+ if (!msg || !autoHideMs)
104
+ return;
105
+ this.statusTimeout = setTimeout(() => {
106
+ this.statusMessage = null;
107
+ this.statusTimeout = null;
108
+ this.requestRender();
109
+ }, autoHideMs);
110
+ }
111
+ invalidate() { }
112
+ render(width) {
113
+ const title = this.scope === "current" ? "Resume Session (Current Folder)" : "Resume Session (All)";
114
+ const leftText = theme.bold(title);
115
+ const sortLabel = this.sortMode === "threaded" ? "Threaded" : this.sortMode === "recent" ? "Recent" : "Fuzzy";
116
+ const sortText = theme.fg("muted", "Sort: ") + theme.fg("accent", sortLabel);
117
+ const nameLabel = this.nameFilter === "all" ? "All" : "Named";
118
+ const nameText = theme.fg("muted", "Name: ") + theme.fg("accent", nameLabel);
119
+ let scopeText;
120
+ if (this.loading) {
121
+ const progressText = this.loadProgress ? `${this.loadProgress.loaded}/${this.loadProgress.total}` : "...";
122
+ scopeText = `${theme.fg("muted", "○ Current Folder | ")}${theme.fg("accent", `Loading ${progressText}`)}`;
123
+ }
124
+ else if (this.scope === "current") {
125
+ scopeText = `${theme.fg("accent", "◉ Current Folder")}${theme.fg("muted", " | ○ All")}`;
126
+ }
127
+ else {
128
+ scopeText = `${theme.fg("muted", "○ Current Folder | ")}${theme.fg("accent", "◉ All")}`;
129
+ }
130
+ const rightText = truncateToWidth(`${scopeText} ${nameText} ${sortText}`, width, "");
131
+ const availableLeft = Math.max(0, width - visibleWidth(rightText) - 1);
132
+ const left = truncateToWidth(leftText, availableLeft, "");
133
+ const spacing = Math.max(0, width - visibleWidth(left) - visibleWidth(rightText));
134
+ // Build hint lines - changes based on state (all branches truncate to width)
135
+ let hintLine1;
136
+ let hintLine2;
137
+ if (this.confirmingDeletePath !== null) {
138
+ const confirmHint = `Delete session? ${keyHint("tui.select.confirm", "confirm")} · ${keyHint("tui.select.cancel", "cancel")}`;
139
+ hintLine1 = theme.fg("error", truncateToWidth(confirmHint, width, "…"));
140
+ hintLine2 = "";
141
+ }
142
+ else if (this.statusMessage) {
143
+ const color = this.statusMessage.type === "error" ? "error" : "accent";
144
+ hintLine1 = theme.fg(color, truncateToWidth(this.statusMessage.message, width, "…"));
145
+ hintLine2 = "";
146
+ }
147
+ else {
148
+ const pathState = this.showPath ? "(on)" : "(off)";
149
+ const sep = theme.fg("muted", " · ");
150
+ const hint1 = keyHint("tui.input.tab", "scope") + sep + theme.fg("muted", 're:<pattern> regex · "phrase" exact');
151
+ const hint2Parts = [
152
+ keyHint("app.session.toggleSort", "sort"),
153
+ keyHint("app.session.toggleNamedFilter", "named"),
154
+ keyHint("app.session.delete", "delete"),
155
+ keyHint("app.session.togglePath", `path ${pathState}`),
156
+ ];
157
+ if (this.showRenameHint) {
158
+ hint2Parts.push(keyHint("app.session.rename", "rename"));
159
+ }
160
+ const hint2 = hint2Parts.join(sep);
161
+ hintLine1 = truncateToWidth(hint1, width, "…");
162
+ hintLine2 = truncateToWidth(hint2, width, "…");
163
+ }
164
+ return [`${left}${" ".repeat(spacing)}${rightText}`, hintLine1, hintLine2];
165
+ }
166
+ }
167
+ /**
168
+ * Build a tree structure from sessions based on parentSessionPath.
169
+ * Returns root nodes sorted by modified date (descending).
170
+ */
171
+ function buildSessionTree(sessions) {
172
+ const byPath = new Map();
173
+ for (const session of sessions) {
174
+ const sessionPath = canonicalizePath(session.path) ?? session.path;
175
+ byPath.set(sessionPath, { session, children: [] });
176
+ }
177
+ const roots = [];
178
+ for (const session of sessions) {
179
+ const sessionPath = canonicalizePath(session.path) ?? session.path;
180
+ const node = byPath.get(sessionPath);
181
+ const parentPath = canonicalizePath(session.parentSessionPath);
182
+ if (parentPath && byPath.has(parentPath)) {
183
+ byPath.get(parentPath).children.push(node);
184
+ }
185
+ else {
186
+ roots.push(node);
187
+ }
188
+ }
189
+ // Sort children and roots by modified date (descending)
190
+ const sortNodes = (nodes) => {
191
+ nodes.sort((a, b) => b.session.modified.getTime() - a.session.modified.getTime());
192
+ for (const node of nodes) {
193
+ sortNodes(node.children);
194
+ }
195
+ };
196
+ sortNodes(roots);
197
+ return roots;
198
+ }
199
+ /**
200
+ * Flatten tree into display list with tree structure metadata.
201
+ */
202
+ function flattenSessionTree(roots) {
203
+ const result = [];
204
+ const walk = (node, depth, ancestorContinues, isLast) => {
205
+ result.push({ session: node.session, depth, isLast, ancestorContinues });
206
+ for (let i = 0; i < node.children.length; i++) {
207
+ const childIsLast = i === node.children.length - 1;
208
+ // Only show continuation line for non-root ancestors
209
+ const continues = depth > 0 ? !isLast : false;
210
+ walk(node.children[i], depth + 1, [...ancestorContinues, continues], childIsLast);
211
+ }
212
+ };
213
+ for (let i = 0; i < roots.length; i++) {
214
+ walk(roots[i], 0, [], i === roots.length - 1);
215
+ }
216
+ return result;
217
+ }
218
+ /**
219
+ * Custom session list component with multi-line items and search
220
+ */
221
+ class SessionList {
222
+ getSelectedSessionPath() {
223
+ const selected = this.filteredSessions[this.selectedIndex];
224
+ return selected?.session.path;
225
+ }
226
+ allSessions = [];
227
+ filteredSessions = [];
228
+ selectedIndex = 0;
229
+ searchInput;
230
+ showCwd = false;
231
+ sortMode = "threaded";
232
+ nameFilter = "all";
233
+ keybindings;
234
+ showPath = false;
235
+ confirmingDeletePath = null;
236
+ currentSessionCanonicalPath;
237
+ onSelect;
238
+ onCancel;
239
+ onExit = () => { };
240
+ onToggleScope;
241
+ onToggleSort;
242
+ onToggleNameFilter;
243
+ onTogglePath;
244
+ onDeleteConfirmationChange;
245
+ onDeleteSession;
246
+ onRenameSession;
247
+ onError;
248
+ maxVisible = 10; // Max sessions visible (one line each)
249
+ // Focusable implementation - propagate to searchInput for IME cursor positioning
250
+ _focused = false;
251
+ get focused() {
252
+ return this._focused;
253
+ }
254
+ set focused(value) {
255
+ this._focused = value;
256
+ this.searchInput.focused = value;
257
+ }
258
+ constructor(sessions, showCwd, sortMode, nameFilter, keybindings, currentSessionFilePath) {
259
+ this.allSessions = sessions;
260
+ this.filteredSessions = [];
261
+ this.searchInput = new Input();
262
+ this.showCwd = showCwd;
263
+ this.sortMode = sortMode;
264
+ this.nameFilter = nameFilter;
265
+ this.keybindings = keybindings;
266
+ this.currentSessionCanonicalPath = canonicalizePath(currentSessionFilePath);
267
+ this.filterSessions("");
268
+ // Handle Enter in search input - select current item
269
+ this.searchInput.onSubmit = () => {
270
+ if (this.filteredSessions[this.selectedIndex]) {
271
+ const selected = this.filteredSessions[this.selectedIndex];
272
+ if (this.onSelect) {
273
+ this.onSelect(selected.session.path);
274
+ }
275
+ }
276
+ };
277
+ }
278
+ setSortMode(sortMode) {
279
+ this.sortMode = sortMode;
280
+ this.filterSessions(this.searchInput.getValue());
281
+ }
282
+ setNameFilter(nameFilter) {
283
+ this.nameFilter = nameFilter;
284
+ this.filterSessions(this.searchInput.getValue());
285
+ }
286
+ setSessions(sessions, showCwd) {
287
+ this.allSessions = sessions;
288
+ this.showCwd = showCwd;
289
+ this.filterSessions(this.searchInput.getValue());
290
+ }
291
+ filterSessions(query) {
292
+ const trimmed = query.trim();
293
+ const nameFiltered = this.nameFilter === "all" ? this.allSessions : this.allSessions.filter((session) => hasSessionName(session));
294
+ if (this.sortMode === "threaded" && !trimmed) {
295
+ // Threaded mode without search: show tree structure
296
+ const roots = buildSessionTree(nameFiltered);
297
+ this.filteredSessions = flattenSessionTree(roots);
298
+ }
299
+ else {
300
+ // Other modes or with search: flat list
301
+ const filtered = filterAndSortSessions(nameFiltered, query, this.sortMode, "all");
302
+ this.filteredSessions = filtered.map((session) => ({
303
+ session,
304
+ depth: 0,
305
+ isLast: true,
306
+ ancestorContinues: [],
307
+ }));
308
+ }
309
+ this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredSessions.length - 1));
310
+ }
311
+ setConfirmingDeletePath(path) {
312
+ this.confirmingDeletePath = path;
313
+ this.onDeleteConfirmationChange?.(path);
314
+ }
315
+ startDeleteConfirmationForSelectedSession() {
316
+ const selected = this.filteredSessions[this.selectedIndex];
317
+ if (!selected)
318
+ return;
319
+ // Prevent deleting current session
320
+ if (this.isCurrentSessionPath(selected.session.path)) {
321
+ this.onError?.("Cannot delete the currently active session");
322
+ return;
323
+ }
324
+ this.setConfirmingDeletePath(selected.session.path);
325
+ }
326
+ isCurrentSessionPath(path) {
327
+ if (!this.currentSessionCanonicalPath)
328
+ return false;
329
+ return (canonicalizePath(path) ?? path) === this.currentSessionCanonicalPath;
330
+ }
331
+ invalidate() { }
332
+ render(width) {
333
+ const lines = [];
334
+ // Render search input
335
+ lines.push(...this.searchInput.render(width));
336
+ lines.push(""); // Blank line after search
337
+ if (this.filteredSessions.length === 0) {
338
+ let emptyMessage;
339
+ if (this.nameFilter === "named") {
340
+ const toggleKey = keyText("app.session.toggleNamedFilter");
341
+ if (this.showCwd) {
342
+ emptyMessage = ` No named sessions found. Press ${toggleKey} to show all.`;
343
+ }
344
+ else {
345
+ emptyMessage = ` No named sessions in current folder. Press ${toggleKey} to show all, or Tab to view all.`;
346
+ }
347
+ }
348
+ else if (this.showCwd) {
349
+ // "All" scope - no sessions anywhere that match filter
350
+ emptyMessage = " No sessions found";
351
+ }
352
+ else {
353
+ // "Current folder" scope - hint to try "all"
354
+ emptyMessage = " No sessions in current folder. Press Tab to view all.";
355
+ }
356
+ lines.push(theme.fg("muted", truncateToWidth(emptyMessage, width, "…")));
357
+ return lines;
358
+ }
359
+ // Calculate visible range with scrolling
360
+ const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredSessions.length - this.maxVisible));
361
+ const endIndex = Math.min(startIndex + this.maxVisible, this.filteredSessions.length);
362
+ // Render visible sessions (one line each with tree structure)
363
+ for (let i = startIndex; i < endIndex; i++) {
364
+ const node = this.filteredSessions[i];
365
+ const session = node.session;
366
+ const isSelected = i === this.selectedIndex;
367
+ const isConfirmingDelete = session.path === this.confirmingDeletePath;
368
+ const isCurrent = this.isCurrentSessionPath(session.path);
369
+ // Build tree prefix
370
+ const prefix = this.buildTreePrefix(node);
371
+ // Session display text (name or first message)
372
+ const hasName = !!session.name;
373
+ const displayText = session.name ?? session.firstMessage;
374
+ const normalizedMessage = displayText.replace(/[\x00-\x1f\x7f]/g, " ").trim();
375
+ // Right side: message count and age
376
+ const age = formatSessionDate(session.modified);
377
+ const msgCount = String(session.messageCount);
378
+ let rightPart = `${msgCount} ${age}`;
379
+ if (this.showCwd && session.cwd) {
380
+ rightPart = `${shortenPath(session.cwd)} ${rightPart}`;
381
+ }
382
+ if (this.showPath) {
383
+ rightPart = `${shortenPath(session.path)} ${rightPart}`;
384
+ }
385
+ // Cursor
386
+ const cursor = isSelected ? theme.fg("accent", "› ") : " ";
387
+ // Calculate available width for message
388
+ const prefixWidth = visibleWidth(prefix);
389
+ const rightWidth = visibleWidth(rightPart) + 2; // +2 for spacing
390
+ const availableForMsg = width - 2 - prefixWidth - rightWidth; // -2 for cursor
391
+ const truncatedMsg = truncateToWidth(normalizedMessage, Math.max(10, availableForMsg), "…");
392
+ // Style message
393
+ let messageColor = null;
394
+ if (isConfirmingDelete) {
395
+ messageColor = "error";
396
+ }
397
+ else if (isCurrent) {
398
+ messageColor = "accent";
399
+ }
400
+ else if (hasName) {
401
+ messageColor = "warning";
402
+ }
403
+ let styledMsg = messageColor ? theme.fg(messageColor, truncatedMsg) : truncatedMsg;
404
+ if (isSelected) {
405
+ styledMsg = theme.bold(styledMsg);
406
+ }
407
+ // Build line
408
+ const leftPart = cursor + theme.fg("dim", prefix) + styledMsg;
409
+ const leftWidth = visibleWidth(leftPart);
410
+ const spacing = Math.max(1, width - leftWidth - visibleWidth(rightPart));
411
+ const styledRight = theme.fg(isConfirmingDelete ? "error" : "dim", rightPart);
412
+ let line = leftPart + " ".repeat(spacing) + styledRight;
413
+ if (isSelected) {
414
+ line = theme.bg("selectedBg", line);
415
+ }
416
+ lines.push(truncateToWidth(line, width));
417
+ }
418
+ // Add scroll indicator if needed
419
+ if (startIndex > 0 || endIndex < this.filteredSessions.length) {
420
+ const scrollText = ` (${this.selectedIndex + 1}/${this.filteredSessions.length})`;
421
+ const scrollInfo = theme.fg("muted", truncateToWidth(scrollText, width, ""));
422
+ lines.push(scrollInfo);
423
+ }
424
+ return lines;
425
+ }
426
+ buildTreePrefix(node) {
427
+ if (node.depth === 0) {
428
+ return "";
429
+ }
430
+ const parts = node.ancestorContinues.map((continues) => (continues ? "│ " : " "));
431
+ const branch = node.isLast ? "└─ " : "├─ ";
432
+ return parts.join("") + branch;
433
+ }
434
+ handleInput(keyData) {
435
+ const kb = getKeybindings();
436
+ // Handle delete confirmation state first - intercept all keys
437
+ if (this.confirmingDeletePath !== null) {
438
+ if (kb.matches(keyData, "tui.select.confirm")) {
439
+ const pathToDelete = this.confirmingDeletePath;
440
+ this.setConfirmingDeletePath(null);
441
+ void this.onDeleteSession?.(pathToDelete);
442
+ return;
443
+ }
444
+ if (kb.matches(keyData, "tui.select.cancel")) {
445
+ this.setConfirmingDeletePath(null);
446
+ return;
447
+ }
448
+ // Ignore all other keys while confirming
449
+ return;
450
+ }
451
+ if (kb.matches(keyData, "tui.input.tab")) {
452
+ if (this.onToggleScope) {
453
+ this.onToggleScope();
454
+ }
455
+ return;
456
+ }
457
+ if (kb.matches(keyData, "app.session.toggleSort")) {
458
+ this.onToggleSort?.();
459
+ return;
460
+ }
461
+ if (this.keybindings.matches(keyData, "app.session.toggleNamedFilter")) {
462
+ this.onToggleNameFilter?.();
463
+ return;
464
+ }
465
+ // Ctrl+P: toggle path display
466
+ if (kb.matches(keyData, "app.session.togglePath")) {
467
+ this.showPath = !this.showPath;
468
+ this.onTogglePath?.(this.showPath);
469
+ return;
470
+ }
471
+ // Ctrl+D: initiate delete confirmation (useful on terminals that don't distinguish Ctrl+Backspace from Backspace)
472
+ if (kb.matches(keyData, "app.session.delete")) {
473
+ this.startDeleteConfirmationForSelectedSession();
474
+ return;
475
+ }
476
+ // Rename selected session
477
+ if (kb.matches(keyData, "app.session.rename")) {
478
+ const selected = this.filteredSessions[this.selectedIndex];
479
+ if (selected) {
480
+ this.onRenameSession?.(selected.session.path);
481
+ }
482
+ return;
483
+ }
484
+ // Ctrl+Backspace: non-invasive convenience alias for delete
485
+ // Only triggers deletion when the query is empty; otherwise it is forwarded to the input
486
+ if (kb.matches(keyData, "app.session.deleteNoninvasive")) {
487
+ if (this.searchInput.getValue().length > 0) {
488
+ this.searchInput.handleInput(keyData);
489
+ this.filterSessions(this.searchInput.getValue());
490
+ return;
491
+ }
492
+ this.startDeleteConfirmationForSelectedSession();
493
+ return;
494
+ }
495
+ // Up arrow
496
+ if (kb.matches(keyData, "tui.select.up")) {
497
+ this.selectedIndex = Math.max(0, this.selectedIndex - 1);
498
+ }
499
+ // Down arrow
500
+ else if (kb.matches(keyData, "tui.select.down")) {
501
+ this.selectedIndex = Math.min(this.filteredSessions.length - 1, this.selectedIndex + 1);
502
+ }
503
+ // Page up - jump up by maxVisible items
504
+ else if (kb.matches(keyData, "tui.select.pageUp")) {
505
+ this.selectedIndex = Math.max(0, this.selectedIndex - this.maxVisible);
506
+ }
507
+ // Page down - jump down by maxVisible items
508
+ else if (kb.matches(keyData, "tui.select.pageDown")) {
509
+ this.selectedIndex = Math.min(this.filteredSessions.length - 1, this.selectedIndex + this.maxVisible);
510
+ }
511
+ // Enter
512
+ else if (kb.matches(keyData, "tui.select.confirm")) {
513
+ const selected = this.filteredSessions[this.selectedIndex];
514
+ if (selected && this.onSelect) {
515
+ this.onSelect(selected.session.path);
516
+ }
517
+ }
518
+ // Escape - cancel
519
+ else if (kb.matches(keyData, "tui.select.cancel")) {
520
+ if (this.onCancel) {
521
+ this.onCancel();
522
+ }
523
+ }
524
+ // Pass everything else to search input
525
+ else {
526
+ this.searchInput.handleInput(keyData);
527
+ this.filterSessions(this.searchInput.getValue());
528
+ }
529
+ }
530
+ }
531
+ /**
532
+ * Delete a session file, trying the `trash` CLI first, then falling back to unlink
533
+ */
534
+ async function deleteSessionFile(sessionPath) {
535
+ // Try `trash` first (if installed)
536
+ const trashArgs = sessionPath.startsWith("-") ? ["--", sessionPath] : [sessionPath];
537
+ const trashResult = spawnSync("trash", trashArgs, { encoding: "utf-8" });
538
+ const getTrashErrorHint = () => {
539
+ const parts = [];
540
+ if (trashResult.error) {
541
+ parts.push(trashResult.error.message);
542
+ }
543
+ const stderr = trashResult.stderr?.trim();
544
+ if (stderr) {
545
+ parts.push(stderr.split("\n")[0] ?? stderr);
546
+ }
547
+ if (parts.length === 0)
548
+ return null;
549
+ return `trash: ${parts.join(" · ").slice(0, 200)}`;
550
+ };
551
+ // If trash reports success, or the file is gone afterwards, treat it as successful
552
+ if (trashResult.status === 0 || !existsSync(sessionPath)) {
553
+ return { ok: true, method: "trash" };
554
+ }
555
+ // Fallback to permanent deletion
556
+ try {
557
+ await unlink(sessionPath);
558
+ return { ok: true, method: "unlink" };
559
+ }
560
+ catch (err) {
561
+ const unlinkError = err instanceof Error ? err.message : String(err);
562
+ const trashErrorHint = getTrashErrorHint();
563
+ const error = trashErrorHint ? `${unlinkError} (${trashErrorHint})` : unlinkError;
564
+ return { ok: false, method: "unlink", error };
565
+ }
566
+ }
567
+ /**
568
+ * Component that renders a session selector
569
+ */
570
+ export class SessionSelectorComponent extends Container {
571
+ handleInput(data) {
572
+ if (this.mode === "rename") {
573
+ const kb = getKeybindings();
574
+ if (kb.matches(data, "tui.select.cancel")) {
575
+ this.exitRenameMode();
576
+ return;
577
+ }
578
+ this.renameInput.handleInput(data);
579
+ return;
580
+ }
581
+ this.sessionList.handleInput(data);
582
+ }
583
+ canRename = true;
584
+ sessionList;
585
+ header;
586
+ keybindings;
587
+ scope = "current";
588
+ sortMode = "threaded";
589
+ nameFilter = "all";
590
+ currentSessions = null;
591
+ allSessions = null;
592
+ currentSessionsLoader;
593
+ allSessionsLoader;
594
+ onCancel;
595
+ requestRender;
596
+ renameSession;
597
+ currentLoading = false;
598
+ allLoading = false;
599
+ allLoadSeq = 0;
600
+ mode = "list";
601
+ renameInput = new Input();
602
+ renameTargetPath = null;
603
+ // Focusable implementation - propagate to sessionList for IME cursor positioning
604
+ _focused = false;
605
+ get focused() {
606
+ return this._focused;
607
+ }
608
+ set focused(value) {
609
+ this._focused = value;
610
+ this.sessionList.focused = value;
611
+ this.renameInput.focused = value;
612
+ if (value && this.mode === "rename") {
613
+ this.renameInput.focused = true;
614
+ }
615
+ }
616
+ buildBaseLayout(content, options) {
617
+ this.clear();
618
+ this.addChild(new Spacer(1));
619
+ this.addChild(new DynamicBorder((s) => theme.fg("accent", s)));
620
+ this.addChild(new Spacer(1));
621
+ if (options?.showHeader ?? true) {
622
+ this.addChild(this.header);
623
+ this.addChild(new Spacer(1));
624
+ }
625
+ this.addChild(content);
626
+ this.addChild(new Spacer(1));
627
+ this.addChild(new DynamicBorder((s) => theme.fg("accent", s)));
628
+ }
629
+ constructor(currentSessionsLoader, allSessionsLoader, onSelect, onCancel, onExit, requestRender, options, currentSessionFilePath) {
630
+ super();
631
+ this.keybindings = options?.keybindings ?? KeybindingsManager.create();
632
+ this.currentSessionsLoader = currentSessionsLoader;
633
+ this.allSessionsLoader = allSessionsLoader;
634
+ this.onCancel = onCancel;
635
+ this.requestRender = requestRender;
636
+ this.header = new SessionSelectorHeader(this.scope, this.sortMode, this.nameFilter, this.requestRender);
637
+ const renameSession = options?.renameSession;
638
+ this.renameSession = renameSession;
639
+ this.canRename = !!renameSession;
640
+ this.header.setShowRenameHint(options?.showRenameHint ?? this.canRename);
641
+ // Create session list (starts empty, will be populated after load)
642
+ this.sessionList = new SessionList([], false, this.sortMode, this.nameFilter, this.keybindings, currentSessionFilePath);
643
+ this.buildBaseLayout(this.sessionList);
644
+ this.renameInput.onSubmit = (value) => {
645
+ void this.confirmRename(value);
646
+ };
647
+ // Ensure header status timeouts are cleared when leaving the selector
648
+ const clearStatusMessage = () => this.header.setStatusMessage(null);
649
+ this.sessionList.onSelect = (sessionPath) => {
650
+ clearStatusMessage();
651
+ onSelect(sessionPath);
652
+ };
653
+ this.sessionList.onCancel = () => {
654
+ clearStatusMessage();
655
+ onCancel();
656
+ };
657
+ this.sessionList.onExit = () => {
658
+ clearStatusMessage();
659
+ onExit();
660
+ };
661
+ this.sessionList.onToggleScope = () => this.toggleScope();
662
+ this.sessionList.onToggleSort = () => this.toggleSortMode();
663
+ this.sessionList.onToggleNameFilter = () => this.toggleNameFilter();
664
+ this.sessionList.onRenameSession = (sessionPath) => {
665
+ if (!renameSession)
666
+ return;
667
+ if (this.scope === "current" && this.currentLoading)
668
+ return;
669
+ if (this.scope === "all" && this.allLoading)
670
+ return;
671
+ const sessions = this.scope === "all" ? (this.allSessions ?? []) : (this.currentSessions ?? []);
672
+ const session = sessions.find((s) => s.path === sessionPath);
673
+ this.enterRenameMode(sessionPath, session?.name);
674
+ };
675
+ // Sync list events to header
676
+ this.sessionList.onTogglePath = (showPath) => {
677
+ this.header.setShowPath(showPath);
678
+ this.requestRender();
679
+ };
680
+ this.sessionList.onDeleteConfirmationChange = (path) => {
681
+ this.header.setConfirmingDeletePath(path);
682
+ this.requestRender();
683
+ };
684
+ this.sessionList.onError = (msg) => {
685
+ this.header.setStatusMessage({ type: "error", message: msg }, 3000);
686
+ this.requestRender();
687
+ };
688
+ // Handle session deletion
689
+ this.sessionList.onDeleteSession = async (sessionPath) => {
690
+ const result = await deleteSessionFile(sessionPath);
691
+ if (result.ok) {
692
+ if (this.currentSessions) {
693
+ this.currentSessions = this.currentSessions.filter((s) => s.path !== sessionPath);
694
+ }
695
+ if (this.allSessions) {
696
+ this.allSessions = this.allSessions.filter((s) => s.path !== sessionPath);
697
+ }
698
+ const sessions = this.scope === "all" ? (this.allSessions ?? []) : (this.currentSessions ?? []);
699
+ const showCwd = this.scope === "all";
700
+ this.sessionList.setSessions(sessions, showCwd);
701
+ const msg = result.method === "trash" ? "Session moved to trash" : "Session deleted";
702
+ this.header.setStatusMessage({ type: "info", message: msg }, 2000);
703
+ await this.refreshSessionsAfterMutation();
704
+ }
705
+ else {
706
+ const errorMessage = result.error ?? "Unknown error";
707
+ this.header.setStatusMessage({ type: "error", message: `Failed to delete: ${errorMessage}` }, 3000);
708
+ }
709
+ this.requestRender();
710
+ };
711
+ // Start loading current sessions immediately
712
+ this.loadCurrentSessions();
713
+ }
714
+ loadCurrentSessions() {
715
+ void this.loadScope("current", "initial");
716
+ }
717
+ enterRenameMode(sessionPath, currentName) {
718
+ this.mode = "rename";
719
+ this.renameTargetPath = sessionPath;
720
+ this.renameInput.setValue(currentName ?? "");
721
+ this.renameInput.focused = true;
722
+ const panel = new Container();
723
+ panel.addChild(new Text(theme.bold("Rename Session"), 1, 0));
724
+ panel.addChild(new Spacer(1));
725
+ panel.addChild(this.renameInput);
726
+ panel.addChild(new Spacer(1));
727
+ panel.addChild(new Text(theme.fg("muted", `${keyText("tui.select.confirm")} to save · ${keyText("tui.select.cancel")} to cancel`), 1, 0));
728
+ this.buildBaseLayout(panel, { showHeader: false });
729
+ this.requestRender();
730
+ }
731
+ exitRenameMode() {
732
+ this.mode = "list";
733
+ this.renameTargetPath = null;
734
+ this.buildBaseLayout(this.sessionList);
735
+ this.requestRender();
736
+ }
737
+ async confirmRename(value) {
738
+ const next = value.trim();
739
+ if (!next)
740
+ return;
741
+ const target = this.renameTargetPath;
742
+ if (!target) {
743
+ this.exitRenameMode();
744
+ return;
745
+ }
746
+ // Find current name for callback
747
+ const renameSession = this.renameSession;
748
+ if (!renameSession) {
749
+ this.exitRenameMode();
750
+ return;
751
+ }
752
+ try {
753
+ await renameSession(target, next);
754
+ await this.refreshSessionsAfterMutation();
755
+ }
756
+ finally {
757
+ this.exitRenameMode();
758
+ }
759
+ }
760
+ async loadScope(scope, reason) {
761
+ const showCwd = scope === "all";
762
+ // Mark loading
763
+ if (scope === "current") {
764
+ this.currentLoading = true;
765
+ }
766
+ else {
767
+ this.allLoading = true;
768
+ }
769
+ const seq = scope === "all" ? ++this.allLoadSeq : undefined;
770
+ this.header.setScope(scope);
771
+ this.header.setLoading(true);
772
+ this.requestRender();
773
+ const onProgress = (loaded, total) => {
774
+ if (scope !== this.scope)
775
+ return;
776
+ if (seq !== undefined && seq !== this.allLoadSeq)
777
+ return;
778
+ this.header.setProgress(loaded, total);
779
+ this.requestRender();
780
+ };
781
+ try {
782
+ const sessions = await (scope === "current"
783
+ ? this.currentSessionsLoader(onProgress)
784
+ : this.allSessionsLoader(onProgress));
785
+ if (scope === "current") {
786
+ this.currentSessions = sessions;
787
+ this.currentLoading = false;
788
+ }
789
+ else {
790
+ this.allSessions = sessions;
791
+ this.allLoading = false;
792
+ }
793
+ if (scope !== this.scope)
794
+ return;
795
+ if (seq !== undefined && seq !== this.allLoadSeq)
796
+ return;
797
+ this.header.setLoading(false);
798
+ this.sessionList.setSessions(sessions, showCwd);
799
+ this.requestRender();
800
+ if (scope === "all" && sessions.length === 0 && (this.currentSessions?.length ?? 0) === 0) {
801
+ this.onCancel();
802
+ }
803
+ }
804
+ catch (err) {
805
+ if (scope === "current") {
806
+ this.currentLoading = false;
807
+ }
808
+ else {
809
+ this.allLoading = false;
810
+ }
811
+ if (scope !== this.scope)
812
+ return;
813
+ if (seq !== undefined && seq !== this.allLoadSeq)
814
+ return;
815
+ const message = err instanceof Error ? err.message : String(err);
816
+ this.header.setLoading(false);
817
+ this.header.setStatusMessage({ type: "error", message: `Failed to load sessions: ${message}` }, 4000);
818
+ if (reason === "initial") {
819
+ this.sessionList.setSessions([], showCwd);
820
+ }
821
+ this.requestRender();
822
+ }
823
+ }
824
+ toggleSortMode() {
825
+ // Cycle: threaded -> recent -> relevance -> threaded
826
+ this.sortMode = this.sortMode === "threaded" ? "recent" : this.sortMode === "recent" ? "relevance" : "threaded";
827
+ this.header.setSortMode(this.sortMode);
828
+ this.sessionList.setSortMode(this.sortMode);
829
+ this.requestRender();
830
+ }
831
+ toggleNameFilter() {
832
+ this.nameFilter = this.nameFilter === "all" ? "named" : "all";
833
+ this.header.setNameFilter(this.nameFilter);
834
+ this.sessionList.setNameFilter(this.nameFilter);
835
+ this.requestRender();
836
+ }
837
+ async refreshSessionsAfterMutation() {
838
+ await this.loadScope(this.scope, "refresh");
839
+ }
840
+ toggleScope() {
841
+ if (this.scope === "current") {
842
+ this.scope = "all";
843
+ this.header.setScope(this.scope);
844
+ if (this.allSessions !== null) {
845
+ this.header.setLoading(false);
846
+ this.sessionList.setSessions(this.allSessions, true);
847
+ this.requestRender();
848
+ return;
849
+ }
850
+ if (!this.allLoading) {
851
+ void this.loadScope("all", "toggle");
852
+ }
853
+ return;
854
+ }
855
+ this.scope = "current";
856
+ this.header.setScope(this.scope);
857
+ this.header.setLoading(this.currentLoading);
858
+ this.sessionList.setSessions(this.currentSessions ?? [], false);
859
+ this.requestRender();
860
+ }
861
+ getSessionList() {
862
+ return this.sessionList;
863
+ }
864
+ }
865
+ //# sourceMappingURL=session-selector.js.map