@felan-ai/felan 0.28.3 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (842) hide show
  1. package/NOTICE +20 -0
  2. package/README.md +127 -40
  3. package/dist/acp/daemon-session.d.ts +34 -0
  4. package/dist/acp/daemon-session.d.ts.map +1 -0
  5. package/dist/acp/daemon-session.js +142 -0
  6. package/dist/acp/daemon-session.js.map +1 -0
  7. package/dist/acp/login.d.ts +4 -2
  8. package/dist/acp/login.d.ts.map +1 -1
  9. package/dist/acp/login.js +155 -251
  10. package/dist/acp/login.js.map +1 -1
  11. package/dist/acp/protocol-interactions.d.ts +25 -0
  12. package/dist/acp/protocol-interactions.d.ts.map +1 -0
  13. package/dist/acp/protocol-interactions.js +297 -0
  14. package/dist/acp/protocol-interactions.js.map +1 -0
  15. package/dist/acp/protocol-updates.d.ts +20 -0
  16. package/dist/acp/protocol-updates.d.ts.map +1 -0
  17. package/dist/acp/protocol-updates.js +114 -0
  18. package/dist/acp/protocol-updates.js.map +1 -0
  19. package/dist/acp/session-registry.d.ts +4 -9
  20. package/dist/acp/session-registry.d.ts.map +1 -1
  21. package/dist/acp/session-registry.js +178 -386
  22. package/dist/acp/session-registry.js.map +1 -1
  23. package/dist/cli-config.d.ts +7 -0
  24. package/dist/cli-config.d.ts.map +1 -0
  25. package/dist/cli-config.js +18 -0
  26. package/dist/cli-config.js.map +1 -0
  27. package/dist/cli-main.d.ts +12 -7
  28. package/dist/cli-main.d.ts.map +1 -1
  29. package/dist/cli-main.js +106 -105
  30. package/dist/cli-main.js.map +1 -1
  31. package/dist/client/agent-host.d.ts +52 -0
  32. package/dist/client/agent-host.d.ts.map +1 -0
  33. package/dist/client/agent-host.js +413 -0
  34. package/dist/client/agent-host.js.map +1 -0
  35. package/dist/client/agents-presenter.d.ts +12 -0
  36. package/dist/client/agents-presenter.d.ts.map +1 -0
  37. package/dist/client/agents-presenter.js +66 -0
  38. package/dist/client/agents-presenter.js.map +1 -0
  39. package/dist/client/client.d.ts +181 -0
  40. package/dist/client/client.d.ts.map +1 -0
  41. package/dist/client/client.js +806 -0
  42. package/dist/client/client.js.map +1 -0
  43. package/dist/client/daemon-blocked.d.ts +12 -0
  44. package/dist/client/daemon-blocked.d.ts.map +1 -0
  45. package/dist/client/daemon-blocked.js +27 -0
  46. package/dist/client/daemon-blocked.js.map +1 -0
  47. package/dist/client/daemon-stop.d.ts +5 -0
  48. package/dist/client/daemon-stop.d.ts.map +1 -0
  49. package/dist/client/daemon-stop.js +36 -0
  50. package/dist/client/daemon-stop.js.map +1 -0
  51. package/dist/client/diagnostics.d.ts +55 -0
  52. package/dist/client/diagnostics.d.ts.map +1 -0
  53. package/dist/client/diagnostics.js +47 -0
  54. package/dist/client/diagnostics.js.map +1 -0
  55. package/dist/client/hint-renderers.d.ts +16 -0
  56. package/dist/client/hint-renderers.d.ts.map +1 -0
  57. package/dist/client/hint-renderers.js +28 -0
  58. package/dist/client/hint-renderers.js.map +1 -0
  59. package/dist/client/index.d.ts +5 -0
  60. package/dist/client/index.d.ts.map +1 -0
  61. package/dist/client/index.js +5 -0
  62. package/dist/client/index.js.map +1 -0
  63. package/dist/client/message-display.d.ts +21 -0
  64. package/dist/client/message-display.d.ts.map +1 -0
  65. package/dist/client/message-display.js +115 -0
  66. package/dist/client/message-display.js.map +1 -0
  67. package/dist/client/powerline-presenter.d.ts +13 -0
  68. package/dist/client/powerline-presenter.d.ts.map +1 -0
  69. package/dist/client/powerline-presenter.js +67 -0
  70. package/dist/client/powerline-presenter.js.map +1 -0
  71. package/dist/client/presenters.d.ts +43 -0
  72. package/dist/client/presenters.d.ts.map +1 -0
  73. package/dist/client/presenters.js +118 -0
  74. package/dist/client/presenters.js.map +1 -0
  75. package/dist/client/reducer.d.ts +37 -0
  76. package/dist/client/reducer.d.ts.map +1 -0
  77. package/dist/client/reducer.js +173 -0
  78. package/dist/client/reducer.js.map +1 -0
  79. package/dist/client/session-title.d.ts +6 -0
  80. package/dist/client/session-title.d.ts.map +1 -0
  81. package/dist/client/session-title.js +13 -0
  82. package/dist/client/session-title.js.map +1 -0
  83. package/dist/client/transport.d.ts +14 -0
  84. package/dist/client/transport.d.ts.map +1 -0
  85. package/dist/client/transport.js +46 -0
  86. package/dist/client/transport.js.map +1 -0
  87. package/dist/client/ui.d.ts +25 -0
  88. package/dist/client/ui.d.ts.map +1 -0
  89. package/dist/client/ui.js +123 -0
  90. package/dist/client/ui.js.map +1 -0
  91. package/dist/client-application.d.ts +37 -0
  92. package/dist/client-application.d.ts.map +1 -0
  93. package/dist/client-application.js +126 -0
  94. package/dist/client-application.js.map +1 -0
  95. package/dist/compaction-presentation.d.ts +6 -4
  96. package/dist/compaction-presentation.d.ts.map +1 -1
  97. package/dist/compaction-presentation.js +11 -37
  98. package/dist/compaction-presentation.js.map +1 -1
  99. package/dist/daemon-command.d.ts +10 -0
  100. package/dist/daemon-command.d.ts.map +1 -0
  101. package/dist/daemon-command.js +163 -0
  102. package/dist/daemon-command.js.map +1 -0
  103. package/dist/daemon-entrypoint.d.ts +5 -0
  104. package/dist/daemon-entrypoint.d.ts.map +1 -0
  105. package/dist/daemon-entrypoint.js +17 -0
  106. package/dist/daemon-entrypoint.js.map +1 -0
  107. package/dist/daemon-host.d.ts +2 -0
  108. package/dist/daemon-host.d.ts.map +1 -0
  109. package/dist/daemon-host.js +18 -0
  110. package/dist/daemon-host.js.map +1 -0
  111. package/dist/dependency-onboarding.js +3 -3
  112. package/dist/dependency-onboarding.js.map +1 -1
  113. package/dist/execution-completion.d.ts +3 -0
  114. package/dist/execution-completion.d.ts.map +1 -0
  115. package/dist/execution-completion.js +2 -0
  116. package/dist/execution-completion.js.map +1 -0
  117. package/dist/headless.d.ts +39 -0
  118. package/dist/headless.d.ts.map +1 -0
  119. package/dist/headless.js +315 -0
  120. package/dist/headless.js.map +1 -0
  121. package/dist/host.json +55 -0
  122. package/dist/index.d.ts +9 -19
  123. package/dist/index.d.ts.map +1 -1
  124. package/dist/index.js +4 -10
  125. package/dist/index.js.map +1 -1
  126. package/dist/memory/{history-view.d.ts → history-renderer.d.ts} +13 -6
  127. package/dist/memory/history-renderer.d.ts.map +1 -0
  128. package/dist/memory/{history-view.js → history-renderer.js} +34 -30
  129. package/dist/memory/history-renderer.js.map +1 -0
  130. package/dist/memory/history.d.ts +1 -31
  131. package/dist/memory/history.d.ts.map +1 -1
  132. package/dist/memory/history.js +1 -306
  133. package/dist/memory/history.js.map +1 -1
  134. package/dist/memory/ui.d.ts +5 -0
  135. package/dist/memory/ui.d.ts.map +1 -0
  136. package/dist/memory/ui.js +2 -0
  137. package/dist/memory/ui.js.map +1 -0
  138. package/dist/process-restart.d.ts +4 -6
  139. package/dist/process-restart.d.ts.map +1 -1
  140. package/dist/process-restart.js +17 -96
  141. package/dist/process-restart.js.map +1 -1
  142. package/dist/{browser → providers/browser}/authorization-host.d.ts +2 -1
  143. package/dist/providers/browser/authorization-host.d.ts.map +1 -0
  144. package/dist/{browser → providers/browser}/authorization-host.js +9 -22
  145. package/dist/providers/browser/authorization-host.js.map +1 -0
  146. package/dist/providers/browser/chrome-devtools.d.ts.map +1 -0
  147. package/dist/providers/browser/chrome-devtools.js.map +1 -0
  148. package/dist/providers/browser/connection-lease.d.ts.map +1 -0
  149. package/dist/providers/browser/connection-lease.js.map +1 -0
  150. package/dist/providers/browser-authorization.d.ts +6 -0
  151. package/dist/providers/browser-authorization.d.ts.map +1 -0
  152. package/dist/providers/browser-authorization.js +30 -0
  153. package/dist/providers/browser-authorization.js.map +1 -0
  154. package/dist/providers/classifier.d.ts.map +1 -0
  155. package/dist/providers/classifier.js.map +1 -0
  156. package/dist/providers/codemode.d.ts.map +1 -0
  157. package/dist/providers/codemode.js.map +1 -0
  158. package/dist/providers/configuration.d.ts +23 -0
  159. package/dist/providers/configuration.d.ts.map +1 -0
  160. package/dist/providers/configuration.js +154 -0
  161. package/dist/providers/configuration.js.map +1 -0
  162. package/dist/providers/credential-storage.d.ts +10 -0
  163. package/dist/providers/credential-storage.d.ts.map +1 -0
  164. package/dist/providers/credential-storage.js +57 -0
  165. package/dist/providers/credential-storage.js.map +1 -0
  166. package/dist/providers/dependencies.d.ts +3 -0
  167. package/dist/providers/dependencies.d.ts.map +1 -0
  168. package/dist/providers/dependencies.js +31 -0
  169. package/dist/providers/dependencies.js.map +1 -0
  170. package/dist/providers/execution-binding.d.ts +7 -0
  171. package/dist/providers/execution-binding.d.ts.map +1 -0
  172. package/dist/providers/execution-binding.js +180 -0
  173. package/dist/providers/execution-binding.js.map +1 -0
  174. package/dist/providers/execution-services.d.ts +24 -0
  175. package/dist/providers/execution-services.d.ts.map +1 -0
  176. package/dist/providers/execution-services.js +91 -0
  177. package/dist/providers/execution-services.js.map +1 -0
  178. package/dist/providers/extension-catalog.d.ts +30 -0
  179. package/dist/providers/extension-catalog.d.ts.map +1 -0
  180. package/dist/providers/extension-catalog.js +39 -0
  181. package/dist/providers/extension-catalog.js.map +1 -0
  182. package/dist/providers/extension-services.d.ts +14 -0
  183. package/dist/providers/extension-services.d.ts.map +1 -0
  184. package/dist/providers/extension-services.js +2 -0
  185. package/dist/providers/extension-services.js.map +1 -0
  186. package/dist/providers/extensions.d.ts +7 -0
  187. package/dist/providers/extensions.d.ts.map +1 -0
  188. package/dist/providers/extensions.js +32 -0
  189. package/dist/providers/extensions.js.map +1 -0
  190. package/dist/providers/felan-platform.d.ts +6 -0
  191. package/dist/providers/felan-platform.d.ts.map +1 -0
  192. package/dist/providers/felan-platform.js +11 -0
  193. package/dist/providers/felan-platform.js.map +1 -0
  194. package/dist/providers/global-settings.d.ts +46 -0
  195. package/dist/providers/global-settings.d.ts.map +1 -0
  196. package/dist/providers/global-settings.js +187 -0
  197. package/dist/providers/global-settings.js.map +1 -0
  198. package/dist/providers/llama/extension.d.ts +10 -0
  199. package/dist/providers/llama/extension.d.ts.map +1 -0
  200. package/dist/providers/llama/extension.js +34 -0
  201. package/dist/providers/llama/extension.js.map +1 -0
  202. package/dist/providers/llama/management.d.ts +5 -0
  203. package/dist/providers/llama/management.d.ts.map +1 -0
  204. package/dist/providers/llama/management.js +176 -0
  205. package/dist/providers/llama/management.js.map +1 -0
  206. package/dist/providers/llama/presentation.d.ts +32 -0
  207. package/dist/providers/llama/presentation.d.ts.map +1 -0
  208. package/dist/providers/llama/presentation.js +141 -0
  209. package/dist/providers/llama/presentation.js.map +1 -0
  210. package/dist/providers/llama/sdk.d.ts +71 -0
  211. package/dist/providers/llama/sdk.d.ts.map +1 -0
  212. package/dist/providers/llama/sdk.js +25 -0
  213. package/dist/providers/llama/sdk.js.map +1 -0
  214. package/dist/providers/local-model-runtime.d.ts +4 -0
  215. package/dist/providers/local-model-runtime.d.ts.map +1 -0
  216. package/dist/providers/local-model-runtime.js +11 -0
  217. package/dist/providers/local-model-runtime.js.map +1 -0
  218. package/dist/providers/local-resources.d.ts +6 -0
  219. package/dist/providers/local-resources.d.ts.map +1 -0
  220. package/dist/providers/local-resources.js +13 -0
  221. package/dist/providers/local-resources.js.map +1 -0
  222. package/dist/providers/mcp/callback-server.d.ts +3 -0
  223. package/dist/providers/mcp/callback-server.d.ts.map +1 -0
  224. package/dist/{mcp → providers/mcp}/callback-server.js +5 -1
  225. package/dist/providers/mcp/callback-server.js.map +1 -0
  226. package/dist/providers/mcp-callback.d.ts +6 -0
  227. package/dist/providers/mcp-callback.d.ts.map +1 -0
  228. package/dist/providers/mcp-callback.js +67 -0
  229. package/dist/providers/mcp-callback.js.map +1 -0
  230. package/dist/providers/model-defaults.d.ts.map +1 -0
  231. package/dist/providers/model-defaults.js.map +1 -0
  232. package/dist/providers/models-subscription.d.ts +14 -0
  233. package/dist/providers/models-subscription.d.ts.map +1 -0
  234. package/dist/{powerline.js → providers/models-subscription.js} +28 -83
  235. package/dist/providers/models-subscription.js.map +1 -0
  236. package/dist/providers/models.d.ts +18 -0
  237. package/dist/providers/models.d.ts.map +1 -0
  238. package/dist/providers/models.js +371 -0
  239. package/dist/providers/models.js.map +1 -0
  240. package/dist/providers/pi-lock.d.ts.map +1 -0
  241. package/dist/{pi-lock.js → providers/pi-lock.js} +1 -1
  242. package/dist/providers/pi-lock.js.map +1 -0
  243. package/dist/providers/platform.d.ts +3 -0
  244. package/dist/providers/platform.d.ts.map +1 -0
  245. package/dist/providers/platform.js +14 -0
  246. package/dist/providers/platform.js.map +1 -0
  247. package/dist/providers/process-adapter.d.ts +3 -0
  248. package/dist/providers/process-adapter.d.ts.map +1 -0
  249. package/dist/providers/process-adapter.js +46 -0
  250. package/dist/providers/process-adapter.js.map +1 -0
  251. package/dist/providers/process-bootstrap.d.ts +17 -0
  252. package/dist/providers/process-bootstrap.d.ts.map +1 -0
  253. package/dist/providers/process-bootstrap.js +87 -0
  254. package/dist/providers/process-bootstrap.js.map +1 -0
  255. package/dist/providers/project-trust.d.ts +8 -0
  256. package/dist/providers/project-trust.d.ts.map +1 -0
  257. package/dist/providers/project-trust.js +112 -0
  258. package/dist/providers/project-trust.js.map +1 -0
  259. package/dist/providers/runtime-dependencies.d.ts +6 -0
  260. package/dist/providers/runtime-dependencies.d.ts.map +1 -0
  261. package/dist/providers/runtime-dependencies.js +31 -0
  262. package/dist/providers/runtime-dependencies.js.map +1 -0
  263. package/dist/providers/runtime.d.ts +6 -0
  264. package/dist/providers/runtime.d.ts.map +1 -0
  265. package/dist/providers/runtime.js +15 -0
  266. package/dist/providers/runtime.js.map +1 -0
  267. package/dist/{savings.d.ts → providers/savings.d.ts} +7 -0
  268. package/dist/providers/savings.d.ts.map +1 -0
  269. package/dist/{savings.js → providers/savings.js} +46 -1
  270. package/dist/providers/savings.js.map +1 -0
  271. package/dist/providers/secrets.d.ts +15 -0
  272. package/dist/providers/secrets.d.ts.map +1 -0
  273. package/dist/providers/secrets.js +233 -0
  274. package/dist/providers/secrets.js.map +1 -0
  275. package/dist/providers/session-runtime.d.ts +16 -0
  276. package/dist/providers/session-runtime.d.ts.map +1 -0
  277. package/dist/providers/session-runtime.js +193 -0
  278. package/dist/providers/session-runtime.js.map +1 -0
  279. package/dist/providers/sessions.d.ts +6 -0
  280. package/dist/providers/sessions.d.ts.map +1 -0
  281. package/dist/providers/sessions.js +97 -0
  282. package/dist/providers/sessions.js.map +1 -0
  283. package/dist/providers/settings-store.d.ts +4 -0
  284. package/dist/providers/settings-store.d.ts.map +1 -0
  285. package/dist/providers/settings-store.js +70 -0
  286. package/dist/providers/settings-store.js.map +1 -0
  287. package/dist/{settings.d.ts → providers/settings.d.ts} +7 -24
  288. package/dist/providers/settings.d.ts.map +1 -0
  289. package/dist/providers/settings.js +170 -0
  290. package/dist/providers/settings.js.map +1 -0
  291. package/dist/providers/setup/auth-driver.d.ts +16 -0
  292. package/dist/providers/setup/auth-driver.d.ts.map +1 -0
  293. package/dist/providers/setup/auth-driver.js +92 -0
  294. package/dist/providers/setup/auth-driver.js.map +1 -0
  295. package/dist/providers/setup/auth-wire.d.ts +51 -0
  296. package/dist/providers/setup/auth-wire.d.ts.map +1 -0
  297. package/dist/providers/setup/auth-wire.js +17 -0
  298. package/dist/providers/setup/auth-wire.js.map +1 -0
  299. package/dist/providers/setup/auth-worker.d.ts +14 -0
  300. package/dist/providers/setup/auth-worker.d.ts.map +1 -0
  301. package/dist/providers/setup/auth-worker.js +187 -0
  302. package/dist/providers/setup/auth-worker.js.map +1 -0
  303. package/dist/providers/setup/manager.d.ts +45 -0
  304. package/dist/providers/setup/manager.d.ts.map +1 -0
  305. package/dist/providers/setup/manager.js +283 -0
  306. package/dist/providers/setup/manager.js.map +1 -0
  307. package/dist/providers/setup/parent-guard.d.ts +3 -0
  308. package/dist/providers/setup/parent-guard.d.ts.map +1 -0
  309. package/dist/providers/setup/parent-guard.js +14 -0
  310. package/dist/providers/setup/parent-guard.js.map +1 -0
  311. package/dist/providers/setup-open.d.ts +9 -0
  312. package/dist/providers/setup-open.d.ts.map +1 -0
  313. package/dist/providers/setup-open.js +32 -0
  314. package/dist/providers/setup-open.js.map +1 -0
  315. package/dist/providers/system-prompt.d.ts.map +1 -0
  316. package/dist/providers/system-prompt.js.map +1 -0
  317. package/dist/providers/tool-policy.d.ts +2 -0
  318. package/dist/providers/tool-policy.d.ts.map +1 -0
  319. package/dist/providers/tool-policy.js +14 -0
  320. package/dist/providers/tool-policy.js.map +1 -0
  321. package/dist/providers/ui/extension-ui.d.ts +7 -0
  322. package/dist/providers/ui/extension-ui.d.ts.map +1 -0
  323. package/dist/providers/ui/extension-ui.js +42 -0
  324. package/dist/providers/ui/extension-ui.js.map +1 -0
  325. package/dist/providers/ui/port.d.ts +24 -0
  326. package/dist/providers/ui/port.d.ts.map +1 -0
  327. package/dist/providers/ui/port.js +2 -0
  328. package/dist/providers/ui/port.js.map +1 -0
  329. package/dist/savings-command.d.ts +1 -1
  330. package/dist/savings-command.d.ts.map +1 -1
  331. package/dist/savings-command.js +1 -1
  332. package/dist/savings-command.js.map +1 -1
  333. package/dist/session-picker.d.ts +13 -12
  334. package/dist/session-picker.d.ts.map +1 -1
  335. package/dist/session-picker.js +13 -23
  336. package/dist/session-picker.js.map +1 -1
  337. package/dist/subagents/agent-navigator.d.ts +24 -11
  338. package/dist/subagents/agent-navigator.d.ts.map +1 -1
  339. package/dist/subagents/agent-navigator.js +154 -86
  340. package/dist/subagents/agent-navigator.js.map +1 -1
  341. package/dist/subagents/agent-transcript.d.ts +8 -2
  342. package/dist/subagents/agent-transcript.d.ts.map +1 -1
  343. package/dist/subagents/agent-transcript.js +312 -29
  344. package/dist/subagents/agent-transcript.js.map +1 -1
  345. package/dist/subagents/completion-presentation.d.ts +13 -0
  346. package/dist/subagents/completion-presentation.d.ts.map +1 -1
  347. package/dist/subagents/completion-presentation.js +15 -42
  348. package/dist/subagents/completion-presentation.js.map +1 -1
  349. package/dist/subagents/transcript-components.d.ts +107 -0
  350. package/dist/subagents/transcript-components.d.ts.map +1 -0
  351. package/dist/subagents/transcript-components.js +306 -0
  352. package/dist/subagents/transcript-components.js.map +1 -0
  353. package/dist/subagents/types.d.ts +77 -0
  354. package/dist/subagents/types.d.ts.map +1 -0
  355. package/dist/subagents/types.js +2 -0
  356. package/dist/subagents/types.js.map +1 -0
  357. package/dist/themes/felan-dark.json +1 -1
  358. package/dist/tool-activity/mode.d.ts +5 -0
  359. package/dist/tool-activity/mode.d.ts.map +1 -0
  360. package/dist/tool-activity/mode.js +17 -0
  361. package/dist/tool-activity/mode.js.map +1 -0
  362. package/dist/tool-activity/presentation.d.ts.map +1 -1
  363. package/dist/tool-activity/presentation.js +104 -28
  364. package/dist/tool-activity/presentation.js.map +1 -1
  365. package/dist/tool-activity/state.d.ts +9 -2
  366. package/dist/tool-activity/state.d.ts.map +1 -1
  367. package/dist/tool-activity/state.js +43 -3
  368. package/dist/tool-activity/state.js.map +1 -1
  369. package/dist/tui/ask-user-preferences.d.ts +9 -0
  370. package/dist/tui/ask-user-preferences.d.ts.map +1 -0
  371. package/dist/tui/ask-user-preferences.js +16 -0
  372. package/dist/tui/ask-user-preferences.js.map +1 -0
  373. package/dist/tui/command-help.d.ts +13 -0
  374. package/dist/tui/command-help.d.ts.map +1 -0
  375. package/dist/tui/command-help.js +57 -0
  376. package/dist/tui/command-help.js.map +1 -0
  377. package/dist/tui/commands.d.ts +22 -0
  378. package/dist/tui/commands.d.ts.map +1 -0
  379. package/dist/tui/commands.js +404 -0
  380. package/dist/tui/commands.js.map +1 -0
  381. package/dist/tui/completion-text.d.ts +9 -0
  382. package/dist/tui/completion-text.d.ts.map +1 -0
  383. package/dist/tui/completion-text.js +33 -0
  384. package/dist/tui/completion-text.js.map +1 -0
  385. package/dist/tui/controller.d.ts +110 -0
  386. package/dist/tui/controller.d.ts.map +1 -0
  387. package/dist/tui/controller.js +579 -0
  388. package/dist/tui/controller.js.map +1 -0
  389. package/dist/tui/dialogs.d.ts +57 -0
  390. package/dist/tui/dialogs.d.ts.map +1 -0
  391. package/dist/tui/dialogs.js +242 -0
  392. package/dist/tui/dialogs.js.map +1 -0
  393. package/dist/tui/generic-ui.d.ts +4 -0
  394. package/dist/tui/generic-ui.d.ts.map +1 -0
  395. package/dist/tui/generic-ui.js +132 -0
  396. package/dist/tui/generic-ui.js.map +1 -0
  397. package/dist/tui/herdr.d.ts +56 -0
  398. package/dist/tui/herdr.d.ts.map +1 -0
  399. package/dist/tui/herdr.js +219 -0
  400. package/dist/tui/herdr.js.map +1 -0
  401. package/dist/tui/interactions.d.ts +36 -0
  402. package/dist/tui/interactions.d.ts.map +1 -0
  403. package/dist/tui/interactions.js +253 -0
  404. package/dist/tui/interactions.js.map +1 -0
  405. package/dist/tui/keybindings.d.ts +15 -0
  406. package/dist/tui/keybindings.d.ts.map +1 -0
  407. package/dist/tui/keybindings.js +101 -0
  408. package/dist/tui/keybindings.js.map +1 -0
  409. package/dist/tui/markdown.d.ts +4 -0
  410. package/dist/tui/markdown.d.ts.map +1 -0
  411. package/dist/tui/markdown.js +6 -0
  412. package/dist/tui/markdown.js.map +1 -0
  413. package/dist/tui/preferences-schema.d.ts +121 -0
  414. package/dist/tui/preferences-schema.d.ts.map +1 -0
  415. package/dist/tui/preferences-schema.js +42 -0
  416. package/dist/tui/preferences-schema.js.map +1 -0
  417. package/dist/tui/preferences-store.d.ts +22 -0
  418. package/dist/tui/preferences-store.d.ts.map +1 -0
  419. package/dist/tui/preferences-store.js +240 -0
  420. package/dist/tui/preferences-store.js.map +1 -0
  421. package/dist/tui/preferences.d.ts +42 -0
  422. package/dist/tui/preferences.d.ts.map +1 -0
  423. package/dist/tui/preferences.js +246 -0
  424. package/dist/tui/preferences.js.map +1 -0
  425. package/dist/tui/presentation-preferences.d.ts +11 -0
  426. package/dist/tui/presentation-preferences.d.ts.map +1 -0
  427. package/dist/tui/presentation-preferences.js +29 -0
  428. package/dist/tui/presentation-preferences.js.map +1 -0
  429. package/dist/tui/presentation-ui.d.ts +7 -0
  430. package/dist/tui/presentation-ui.d.ts.map +1 -0
  431. package/dist/tui/presentation-ui.js +17 -0
  432. package/dist/tui/presentation-ui.js.map +1 -0
  433. package/dist/tui/presenters.d.ts +18 -0
  434. package/dist/tui/presenters.d.ts.map +1 -0
  435. package/dist/tui/presenters.js +118 -0
  436. package/dist/tui/presenters.js.map +1 -0
  437. package/dist/tui/remote.d.ts +7 -0
  438. package/dist/tui/remote.d.ts.map +1 -0
  439. package/dist/tui/remote.js +139 -0
  440. package/dist/tui/remote.js.map +1 -0
  441. package/dist/tui/renderers/ask-user/single-select-layout.d.ts +20 -0
  442. package/dist/tui/renderers/ask-user/single-select-layout.d.ts.map +1 -0
  443. package/dist/tui/renderers/ask-user/single-select-layout.js +111 -0
  444. package/dist/tui/renderers/ask-user/single-select-layout.js.map +1 -0
  445. package/dist/tui/renderers/ask-user.d.ts +21 -0
  446. package/dist/tui/renderers/ask-user.d.ts.map +1 -0
  447. package/dist/tui/renderers/ask-user.js +1348 -0
  448. package/dist/tui/renderers/ask-user.js.map +1 -0
  449. package/dist/tui/renderers/codebase-memory.d.ts +3 -0
  450. package/dist/tui/renderers/codebase-memory.d.ts.map +1 -0
  451. package/dist/tui/renderers/codebase-memory.js +38 -0
  452. package/dist/tui/renderers/codebase-memory.js.map +1 -0
  453. package/dist/tui/renderers/codex.d.ts +5 -0
  454. package/dist/tui/renderers/codex.d.ts.map +1 -0
  455. package/dist/tui/renderers/codex.js +9 -0
  456. package/dist/tui/renderers/codex.js.map +1 -0
  457. package/dist/tui/renderers/context-view.d.ts +3 -0
  458. package/dist/tui/renderers/context-view.d.ts.map +1 -0
  459. package/dist/tui/renderers/context-view.js +69 -0
  460. package/dist/tui/renderers/context-view.js.map +1 -0
  461. package/dist/{fusion → tui/renderers/fusion}/model-picker.d.ts +2 -1
  462. package/dist/tui/renderers/fusion/model-picker.d.ts.map +1 -0
  463. package/dist/{fusion → tui/renderers/fusion}/model-picker.js +1 -0
  464. package/dist/tui/renderers/fusion/model-picker.js.map +1 -0
  465. package/dist/tui/renderers/fusion.d.ts +7 -0
  466. package/dist/tui/renderers/fusion.d.ts.map +1 -0
  467. package/dist/tui/renderers/fusion.js +266 -0
  468. package/dist/tui/renderers/fusion.js.map +1 -0
  469. package/dist/tui/renderers/insights/charts.d.ts +14 -0
  470. package/dist/tui/renderers/insights/charts.d.ts.map +1 -0
  471. package/dist/tui/renderers/insights/charts.js +77 -0
  472. package/dist/tui/renderers/insights/charts.js.map +1 -0
  473. package/dist/tui/renderers/insights/panel.d.ts +55 -0
  474. package/dist/tui/renderers/insights/panel.d.ts.map +1 -0
  475. package/dist/tui/renderers/insights/panel.js +310 -0
  476. package/dist/tui/renderers/insights/panel.js.map +1 -0
  477. package/dist/tui/renderers/insights.d.ts +4 -0
  478. package/dist/tui/renderers/insights.d.ts.map +1 -0
  479. package/dist/tui/renderers/insights.js +51 -0
  480. package/dist/tui/renderers/insights.js.map +1 -0
  481. package/dist/tui/renderers/memory.d.ts +5 -0
  482. package/dist/tui/renderers/memory.d.ts.map +1 -0
  483. package/dist/tui/renderers/memory.js +99 -0
  484. package/dist/tui/renderers/memory.js.map +1 -0
  485. package/dist/tui/renderers/navigation.d.ts +7 -0
  486. package/dist/tui/renderers/navigation.d.ts.map +1 -0
  487. package/dist/tui/renderers/navigation.js +14 -0
  488. package/dist/tui/renderers/navigation.js.map +1 -0
  489. package/dist/tui/renderers/powerline/colors.d.ts +18 -0
  490. package/dist/tui/renderers/powerline/colors.d.ts.map +1 -0
  491. package/dist/tui/renderers/powerline/colors.js +42 -0
  492. package/dist/tui/renderers/powerline/colors.js.map +1 -0
  493. package/dist/tui/renderers/powerline/config.d.ts +44 -0
  494. package/dist/tui/renderers/powerline/config.d.ts.map +1 -0
  495. package/dist/tui/renderers/powerline/config.js +123 -0
  496. package/dist/tui/renderers/powerline/config.js.map +1 -0
  497. package/dist/tui/renderers/powerline/footer-renderer.d.ts +7 -0
  498. package/dist/tui/renderers/powerline/footer-renderer.d.ts.map +1 -0
  499. package/dist/tui/renderers/powerline/footer-renderer.js +74 -0
  500. package/dist/tui/renderers/powerline/footer-renderer.js.map +1 -0
  501. package/dist/tui/renderers/powerline/projected-footer.d.ts +24 -0
  502. package/dist/tui/renderers/powerline/projected-footer.d.ts.map +1 -0
  503. package/dist/tui/renderers/powerline/projected-footer.js +33 -0
  504. package/dist/tui/renderers/powerline/projected-footer.js.map +1 -0
  505. package/dist/tui/renderers/powerline/segments.d.ts +18 -0
  506. package/dist/tui/renderers/powerline/segments.d.ts.map +1 -0
  507. package/dist/tui/renderers/powerline/segments.js +331 -0
  508. package/dist/tui/renderers/powerline/segments.js.map +1 -0
  509. package/dist/tui/renderers/powerline/symbols.d.ts +27 -0
  510. package/dist/tui/renderers/powerline/symbols.d.ts.map +1 -0
  511. package/dist/tui/renderers/powerline/symbols.js +17 -0
  512. package/dist/tui/renderers/powerline/symbols.js.map +1 -0
  513. package/dist/tui/renderers/powerline.d.ts +4 -0
  514. package/dist/tui/renderers/powerline.d.ts.map +1 -0
  515. package/dist/tui/renderers/powerline.js +4 -0
  516. package/dist/tui/renderers/powerline.js.map +1 -0
  517. package/dist/tui/renderers/prewalk/plan-review.d.ts +28 -0
  518. package/dist/tui/renderers/prewalk/plan-review.d.ts.map +1 -0
  519. package/dist/tui/renderers/prewalk/plan-review.js +414 -0
  520. package/dist/tui/renderers/prewalk/plan-review.js.map +1 -0
  521. package/dist/tui/renderers/prewalk.d.ts +5 -0
  522. package/dist/tui/renderers/prewalk.d.ts.map +1 -0
  523. package/dist/tui/renderers/prewalk.js +43 -0
  524. package/dist/tui/renderers/prewalk.js.map +1 -0
  525. package/dist/tui/renderers/processes/background-bash-view.d.ts +45 -0
  526. package/dist/tui/renderers/processes/background-bash-view.d.ts.map +1 -0
  527. package/dist/tui/renderers/processes/background-bash-view.js +405 -0
  528. package/dist/tui/renderers/processes/background-bash-view.js.map +1 -0
  529. package/dist/tui/renderers/processes/completion-message.d.ts +26 -0
  530. package/dist/tui/renderers/processes/completion-message.d.ts.map +1 -0
  531. package/dist/tui/renderers/processes/completion-message.js +97 -0
  532. package/dist/tui/renderers/processes/completion-message.js.map +1 -0
  533. package/dist/tui/renderers/processes/process-view.d.ts +40 -0
  534. package/dist/tui/renderers/processes/process-view.d.ts.map +1 -0
  535. package/dist/tui/renderers/processes/process-view.js +250 -0
  536. package/dist/tui/renderers/processes/process-view.js.map +1 -0
  537. package/dist/tui/renderers/processes.d.ts +12 -0
  538. package/dist/tui/renderers/processes.d.ts.map +1 -0
  539. package/dist/tui/renderers/processes.js +80 -0
  540. package/dist/tui/renderers/processes.js.map +1 -0
  541. package/dist/tui/renderers/prompt-history/picker.d.ts +64 -0
  542. package/dist/tui/renderers/prompt-history/picker.d.ts.map +1 -0
  543. package/dist/tui/renderers/prompt-history/picker.js +430 -0
  544. package/dist/tui/renderers/prompt-history/picker.js.map +1 -0
  545. package/dist/tui/renderers/prompt-history.d.ts +16 -0
  546. package/dist/tui/renderers/prompt-history.d.ts.map +1 -0
  547. package/dist/tui/renderers/prompt-history.js +113 -0
  548. package/dist/tui/renderers/prompt-history.js.map +1 -0
  549. package/dist/tui/renderers/tasks/tasks-overlay.d.ts +37 -0
  550. package/dist/tui/renderers/tasks/tasks-overlay.d.ts.map +1 -0
  551. package/dist/tui/renderers/tasks/tasks-overlay.js +461 -0
  552. package/dist/tui/renderers/tasks/tasks-overlay.js.map +1 -0
  553. package/dist/tui/renderers/tasks.d.ts +18 -0
  554. package/dist/tui/renderers/tasks.d.ts.map +1 -0
  555. package/dist/tui/renderers/tasks.js +97 -0
  556. package/dist/tui/renderers/tasks.js.map +1 -0
  557. package/dist/tui/run.d.ts +22 -0
  558. package/dist/tui/run.d.ts.map +1 -0
  559. package/dist/tui/run.js +249 -0
  560. package/dist/tui/run.js.map +1 -0
  561. package/dist/tui/screen.d.ts +73 -0
  562. package/dist/tui/screen.d.ts.map +1 -0
  563. package/dist/tui/screen.js +371 -0
  564. package/dist/tui/screen.js.map +1 -0
  565. package/dist/tui/session-navigator.d.ts +53 -0
  566. package/dist/tui/session-navigator.d.ts.map +1 -0
  567. package/dist/tui/session-navigator.js +256 -0
  568. package/dist/tui/session-navigator.js.map +1 -0
  569. package/dist/tui/settings-menu.d.ts +31 -0
  570. package/dist/tui/settings-menu.d.ts.map +1 -0
  571. package/dist/tui/settings-menu.js +78 -0
  572. package/dist/tui/settings-menu.js.map +1 -0
  573. package/dist/tui/setup-ui.d.ts +14 -0
  574. package/dist/tui/setup-ui.d.ts.map +1 -0
  575. package/dist/tui/setup-ui.js +122 -0
  576. package/dist/tui/setup-ui.js.map +1 -0
  577. package/dist/tui/setup.d.ts +29 -0
  578. package/dist/tui/setup.d.ts.map +1 -0
  579. package/dist/tui/setup.js +414 -0
  580. package/dist/tui/setup.js.map +1 -0
  581. package/dist/tui/shell-execution.d.ts +20 -0
  582. package/dist/tui/shell-execution.d.ts.map +1 -0
  583. package/dist/tui/shell-execution.js +64 -0
  584. package/dist/tui/shell-execution.js.map +1 -0
  585. package/dist/tui/startup-header.d.ts +4 -0
  586. package/dist/tui/startup-header.d.ts.map +1 -0
  587. package/dist/tui/startup-header.js +19 -0
  588. package/dist/tui/startup-header.js.map +1 -0
  589. package/dist/tui/streaming-markdown.d.ts +21 -0
  590. package/dist/tui/streaming-markdown.d.ts.map +1 -0
  591. package/dist/tui/streaming-markdown.js +118 -0
  592. package/dist/tui/streaming-markdown.js.map +1 -0
  593. package/dist/tui/theme-config.d.ts +26 -0
  594. package/dist/tui/theme-config.d.ts.map +1 -0
  595. package/dist/tui/theme-config.js +87 -0
  596. package/dist/tui/theme-config.js.map +1 -0
  597. package/dist/tui/theme-picker.d.ts +23 -0
  598. package/dist/tui/theme-picker.d.ts.map +1 -0
  599. package/dist/tui/theme-picker.js +91 -0
  600. package/dist/tui/theme-picker.js.map +1 -0
  601. package/dist/tui/theme.d.ts +15 -0
  602. package/dist/tui/theme.d.ts.map +1 -0
  603. package/dist/tui/theme.js +216 -0
  604. package/dist/tui/theme.js.map +1 -0
  605. package/dist/tui/tool-inspector.d.ts +24 -0
  606. package/dist/tui/tool-inspector.d.ts.map +1 -0
  607. package/dist/tui/tool-inspector.js +81 -0
  608. package/dist/tui/tool-inspector.js.map +1 -0
  609. package/dist/tui/tool-presentation.d.ts +3 -0
  610. package/dist/tui/tool-presentation.d.ts.map +1 -0
  611. package/dist/tui/tool-presentation.js +22 -0
  612. package/dist/tui/tool-presentation.js.map +1 -0
  613. package/dist/tui/transcript.d.ts +6 -0
  614. package/dist/tui/transcript.d.ts.map +1 -0
  615. package/dist/tui/transcript.js +78 -0
  616. package/dist/tui/transcript.js.map +1 -0
  617. package/dist/tui/tree-navigator.d.ts +71 -0
  618. package/dist/tui/tree-navigator.d.ts.map +1 -0
  619. package/dist/tui/tree-navigator.js +522 -0
  620. package/dist/tui/tree-navigator.js.map +1 -0
  621. package/npm-shrinkwrap.json +3637 -0
  622. package/package.json +79 -30
  623. package/dist/acp/interactions.d.ts +0 -22
  624. package/dist/acp/interactions.d.ts.map +0 -1
  625. package/dist/acp/interactions.js +0 -353
  626. package/dist/acp/interactions.js.map +0 -1
  627. package/dist/application.d.ts +0 -23
  628. package/dist/application.d.ts.map +0 -1
  629. package/dist/application.js +0 -267
  630. package/dist/application.js.map +0 -1
  631. package/dist/browser/authorization-host.d.ts.map +0 -1
  632. package/dist/browser/authorization-host.js.map +0 -1
  633. package/dist/browser/chrome-devtools.d.ts.map +0 -1
  634. package/dist/browser/chrome-devtools.js.map +0 -1
  635. package/dist/browser/connection-lease.d.ts.map +0 -1
  636. package/dist/browser/connection-lease.js.map +0 -1
  637. package/dist/classifier-settings.d.ts +0 -10
  638. package/dist/classifier-settings.d.ts.map +0 -1
  639. package/dist/classifier-settings.js +0 -98
  640. package/dist/classifier-settings.js.map +0 -1
  641. package/dist/classifier.d.ts.map +0 -1
  642. package/dist/classifier.js.map +0 -1
  643. package/dist/codemode.d.ts.map +0 -1
  644. package/dist/codemode.js.map +0 -1
  645. package/dist/codex.d.ts +0 -3
  646. package/dist/codex.d.ts.map +0 -1
  647. package/dist/codex.js +0 -8
  648. package/dist/codex.js.map +0 -1
  649. package/dist/command-autocomplete.d.ts +0 -3
  650. package/dist/command-autocomplete.d.ts.map +0 -1
  651. package/dist/command-autocomplete.js +0 -10
  652. package/dist/command-autocomplete.js.map +0 -1
  653. package/dist/cwd-command.d.ts +0 -13
  654. package/dist/cwd-command.d.ts.map +0 -1
  655. package/dist/cwd-command.js +0 -176
  656. package/dist/cwd-command.js.map +0 -1
  657. package/dist/dependencies.d.ts +0 -37
  658. package/dist/dependencies.d.ts.map +0 -1
  659. package/dist/dependencies.js +0 -372
  660. package/dist/dependencies.js.map +0 -1
  661. package/dist/extension-settings.d.ts +0 -12
  662. package/dist/extension-settings.d.ts.map +0 -1
  663. package/dist/extension-settings.js +0 -241
  664. package/dist/extension-settings.js.map +0 -1
  665. package/dist/extensions.d.ts +0 -62
  666. package/dist/extensions.d.ts.map +0 -1
  667. package/dist/extensions.js +0 -265
  668. package/dist/extensions.js.map +0 -1
  669. package/dist/fusion/host.d.ts +0 -3
  670. package/dist/fusion/host.d.ts.map +0 -1
  671. package/dist/fusion/host.js +0 -333
  672. package/dist/fusion/host.js.map +0 -1
  673. package/dist/fusion/model-picker.d.ts.map +0 -1
  674. package/dist/fusion/model-picker.js.map +0 -1
  675. package/dist/herdr.d.ts +0 -29
  676. package/dist/herdr.d.ts.map +0 -1
  677. package/dist/herdr.js +0 -247
  678. package/dist/herdr.js.map +0 -1
  679. package/dist/insights.d.ts +0 -5
  680. package/dist/insights.d.ts.map +0 -1
  681. package/dist/insights.js +0 -140
  682. package/dist/insights.js.map +0 -1
  683. package/dist/lock.d.ts +0 -27
  684. package/dist/lock.d.ts.map +0 -1
  685. package/dist/lock.js +0 -432
  686. package/dist/lock.js.map +0 -1
  687. package/dist/logger.d.ts +0 -7
  688. package/dist/logger.d.ts.map +0 -1
  689. package/dist/logger.js +0 -48
  690. package/dist/logger.js.map +0 -1
  691. package/dist/mcp/callback-server.d.ts +0 -11
  692. package/dist/mcp/callback-server.d.ts.map +0 -1
  693. package/dist/mcp/callback-server.js.map +0 -1
  694. package/dist/mcp/config.d.ts +0 -20
  695. package/dist/mcp/config.d.ts.map +0 -1
  696. package/dist/mcp/config.js +0 -352
  697. package/dist/mcp/config.js.map +0 -1
  698. package/dist/mcp/index.d.ts +0 -3
  699. package/dist/mcp/index.d.ts.map +0 -1
  700. package/dist/mcp/index.js +0 -25
  701. package/dist/mcp/index.js.map +0 -1
  702. package/dist/mcp/oauth-host.d.ts +0 -42
  703. package/dist/mcp/oauth-host.d.ts.map +0 -1
  704. package/dist/mcp/oauth-host.js +0 -524
  705. package/dist/mcp/oauth-host.js.map +0 -1
  706. package/dist/mcp/oauth-store.d.ts +0 -27
  707. package/dist/mcp/oauth-store.d.ts.map +0 -1
  708. package/dist/mcp/oauth-store.js +0 -138
  709. package/dist/mcp/oauth-store.js.map +0 -1
  710. package/dist/memory/control.d.ts +0 -8
  711. package/dist/memory/control.d.ts.map +0 -1
  712. package/dist/memory/control.js +0 -167
  713. package/dist/memory/control.js.map +0 -1
  714. package/dist/memory/coordinator.d.ts +0 -53
  715. package/dist/memory/coordinator.d.ts.map +0 -1
  716. package/dist/memory/coordinator.js +0 -807
  717. package/dist/memory/coordinator.js.map +0 -1
  718. package/dist/memory/dreamer.d.ts +0 -50
  719. package/dist/memory/dreamer.d.ts.map +0 -1
  720. package/dist/memory/dreamer.js +0 -527
  721. package/dist/memory/dreamer.js.map +0 -1
  722. package/dist/memory/history-view.d.ts.map +0 -1
  723. package/dist/memory/history-view.js.map +0 -1
  724. package/dist/memory/lease.d.ts +0 -13
  725. package/dist/memory/lease.d.ts.map +0 -1
  726. package/dist/memory/lease.js +0 -188
  727. package/dist/memory/lease.js.map +0 -1
  728. package/dist/memory/project.d.ts +0 -7
  729. package/dist/memory/project.d.ts.map +0 -1
  730. package/dist/memory/project.js +0 -41
  731. package/dist/memory/project.js.map +0 -1
  732. package/dist/memory/run-retention.d.ts +0 -12
  733. package/dist/memory/run-retention.d.ts.map +0 -1
  734. package/dist/memory/run-retention.js +0 -294
  735. package/dist/memory/run-retention.js.map +0 -1
  736. package/dist/memory/run.d.ts +0 -79
  737. package/dist/memory/run.d.ts.map +0 -1
  738. package/dist/memory/run.js +0 -417
  739. package/dist/memory/run.js.map +0 -1
  740. package/dist/memory/store.d.ts +0 -116
  741. package/dist/memory/store.d.ts.map +0 -1
  742. package/dist/memory/store.js +0 -751
  743. package/dist/memory/store.js.map +0 -1
  744. package/dist/model-defaults.d.ts.map +0 -1
  745. package/dist/model-defaults.js.map +0 -1
  746. package/dist/model-selector.d.ts +0 -5
  747. package/dist/model-selector.d.ts.map +0 -1
  748. package/dist/model-selector.js +0 -87
  749. package/dist/model-selector.js.map +0 -1
  750. package/dist/output-style-instructions.d.ts +0 -6
  751. package/dist/output-style-instructions.d.ts.map +0 -1
  752. package/dist/output-style-instructions.js +0 -53
  753. package/dist/output-style-instructions.js.map +0 -1
  754. package/dist/overlay-images.d.ts +0 -9
  755. package/dist/overlay-images.d.ts.map +0 -1
  756. package/dist/overlay-images.js +0 -99
  757. package/dist/overlay-images.js.map +0 -1
  758. package/dist/pi-extensions.d.ts +0 -28
  759. package/dist/pi-extensions.d.ts.map +0 -1
  760. package/dist/pi-extensions.js +0 -141
  761. package/dist/pi-extensions.js.map +0 -1
  762. package/dist/pi-llama.d.ts +0 -2
  763. package/dist/pi-llama.d.ts.map +0 -1
  764. package/dist/pi-llama.js +0 -15
  765. package/dist/pi-llama.js.map +0 -1
  766. package/dist/pi-lock.d.ts.map +0 -1
  767. package/dist/pi-lock.js.map +0 -1
  768. package/dist/powerline.d.ts +0 -12
  769. package/dist/powerline.d.ts.map +0 -1
  770. package/dist/powerline.js.map +0 -1
  771. package/dist/project-trust-prompt.d.ts +0 -30
  772. package/dist/project-trust-prompt.d.ts.map +0 -1
  773. package/dist/project-trust-prompt.js +0 -122
  774. package/dist/project-trust-prompt.js.map +0 -1
  775. package/dist/project-trust.d.ts +0 -8
  776. package/dist/project-trust.d.ts.map +0 -1
  777. package/dist/project-trust.js +0 -36
  778. package/dist/project-trust.js.map +0 -1
  779. package/dist/prompt-history.d.ts +0 -11
  780. package/dist/prompt-history.d.ts.map +0 -1
  781. package/dist/prompt-history.js +0 -96
  782. package/dist/prompt-history.js.map +0 -1
  783. package/dist/restart-command.d.ts +0 -9
  784. package/dist/restart-command.d.ts.map +0 -1
  785. package/dist/restart-command.js +0 -94
  786. package/dist/restart-command.js.map +0 -1
  787. package/dist/resume.d.ts +0 -5
  788. package/dist/resume.d.ts.map +0 -1
  789. package/dist/resume.js +0 -46
  790. package/dist/resume.js.map +0 -1
  791. package/dist/runtime-factory.d.ts +0 -12
  792. package/dist/runtime-factory.d.ts.map +0 -1
  793. package/dist/runtime-factory.js +0 -12
  794. package/dist/runtime-factory.js.map +0 -1
  795. package/dist/runtime.d.ts +0 -59
  796. package/dist/runtime.d.ts.map +0 -1
  797. package/dist/runtime.js +0 -534
  798. package/dist/runtime.js.map +0 -1
  799. package/dist/savings.d.ts.map +0 -1
  800. package/dist/savings.js.map +0 -1
  801. package/dist/settings.d.ts.map +0 -1
  802. package/dist/settings.js +0 -359
  803. package/dist/settings.js.map +0 -1
  804. package/dist/startup-header.d.ts +0 -9
  805. package/dist/startup-header.d.ts.map +0 -1
  806. package/dist/startup-header.js +0 -151
  807. package/dist/startup-header.js.map +0 -1
  808. package/dist/subagents/catalog.d.ts +0 -8
  809. package/dist/subagents/catalog.d.ts.map +0 -1
  810. package/dist/subagents/catalog.js +0 -136
  811. package/dist/subagents/catalog.js.map +0 -1
  812. package/dist/subagents/host.d.ts +0 -133
  813. package/dist/subagents/host.d.ts.map +0 -1
  814. package/dist/subagents/host.js +0 -1420
  815. package/dist/subagents/host.js.map +0 -1
  816. package/dist/subagents/store.d.ts +0 -25
  817. package/dist/subagents/store.d.ts.map +0 -1
  818. package/dist/subagents/store.js +0 -35
  819. package/dist/subagents/store.js.map +0 -1
  820. package/dist/system-prompt.d.ts.map +0 -1
  821. package/dist/system-prompt.js.map +0 -1
  822. package/dist/tui-compatibility.d.ts +0 -4
  823. package/dist/tui-compatibility.d.ts.map +0 -1
  824. package/dist/tui-compatibility.js +0 -244
  825. package/dist/tui-compatibility.js.map +0 -1
  826. package/dist/update-notification.d.ts +0 -3
  827. package/dist/update-notification.d.ts.map +0 -1
  828. package/dist/update-notification.js +0 -50
  829. package/dist/update-notification.js.map +0 -1
  830. /package/dist/{browser → providers/browser}/chrome-devtools.d.ts +0 -0
  831. /package/dist/{browser → providers/browser}/chrome-devtools.js +0 -0
  832. /package/dist/{browser → providers/browser}/connection-lease.d.ts +0 -0
  833. /package/dist/{browser → providers/browser}/connection-lease.js +0 -0
  834. /package/dist/{classifier.d.ts → providers/classifier.d.ts} +0 -0
  835. /package/dist/{classifier.js → providers/classifier.js} +0 -0
  836. /package/dist/{codemode.d.ts → providers/codemode.d.ts} +0 -0
  837. /package/dist/{codemode.js → providers/codemode.js} +0 -0
  838. /package/dist/{model-defaults.d.ts → providers/model-defaults.d.ts} +0 -0
  839. /package/dist/{model-defaults.js → providers/model-defaults.js} +0 -0
  840. /package/dist/{pi-lock.d.ts → providers/pi-lock.d.ts} +0 -0
  841. /package/dist/{system-prompt.d.ts → providers/system-prompt.d.ts} +0 -0
  842. /package/dist/{system-prompt.js → providers/system-prompt.js} +0 -0
@@ -0,0 +1,1348 @@
1
+ import { decodeUiMarkdown } from '../../client/ui.js';
2
+ import { createRequire } from 'node:module';
3
+ import { Container, decodeKittyPrintable, Editor, fuzzyFilter, Key, matchesKey, Spacer, Text, truncateToWidth, wrapTextWithAnsi, } from '@earendil-works/pi-tui';
4
+ import { normalizeAskUserOption } from '@felan-ai/ext-ask-user/data';
5
+ import { renderSingleSelectRows } from './ask-user/single-select-layout.js';
6
+ import { DEFAULT_ASK_USER_CONFIG, normalizeAskUserShortcut } from '../ask-user-preferences.js';
7
+ export { ASK_USER_FORM_HINT } from '@felan-ai/ext-ask-user/data';
8
+ const VERSION = createRequire(import.meta.url)('../../../package.json').version;
9
+ const BOX_LEFT = '│ ';
10
+ const BOX_RIGHT = ' │';
11
+ const BOX_OVERHEAD = BOX_LEFT.length + BOX_RIGHT.length;
12
+ const OVERLAY_MAX_HEIGHT_RATIO = 0.85;
13
+ const OVERLAY_MIN_RENDER_LINES = 8;
14
+ const OVERLAY_WIDTH = '92%';
15
+ const OVERLAY_MAX_HEIGHT = '85%';
16
+ const OVERLAY_MIN_WIDTH = 40;
17
+ const SPLIT_PANE_MIN_WIDTH = 84;
18
+ const SPLIT_LEFT_MIN_WIDTH = 32;
19
+ const SPLIT_RIGHT_MIN_WIDTH = 28;
20
+ const SPLIT_SEPARATOR = ' │ ';
21
+ const COMMENT_LABEL = 'Add extra context after selection';
22
+ const DEFAULT_OVERLAY_TOGGLE = 'alt+o';
23
+ const DEFAULT_COMMENT_TOGGLE = 'ctrl+g';
24
+ const CONTEXT_TOGGLE_KEY = Key.ctrl('e');
25
+ const INLINE_CONTEXT_MAX_ROWS = 3;
26
+ const FREEFORM_SENTINEL = 'Type custom response...';
27
+ const DISABLED_SHORTCUT = {
28
+ disabled: true,
29
+ spec: null,
30
+ matches: (_data) => false,
31
+ };
32
+ export function createTuiAskUserPresenter(config = {}) {
33
+ const defaults = { ...DEFAULT_ASK_USER_CONFIG, ...config };
34
+ return { present: (request, context) => presentAskUser(request, {
35
+ ...context, mode: 'tui', hasUI: true, reportProgress: context.reportProgress ?? (() => { }),
36
+ }, defaults) };
37
+ }
38
+ export async function presentAskUserForm(form, context, config = {}) {
39
+ const ids = [...new Set(form.input.fields.map(field => field.id.replace(/\.(mode|selection|text|comment)$/u, '')))];
40
+ const sections = form.markdown?.split(/^## Question \d+: /mu).slice(1) ?? [];
41
+ const questions = ids.map((id, index) => {
42
+ const selection = form.input.fields.find(field => field.id === `${id}.selection`);
43
+ const section = sections[index] ?? '';
44
+ const newline = section.indexOf('\n');
45
+ const header = newline < 0 ? `Q${index + 1}` : section.slice(0, newline);
46
+ const body = section.slice(newline + 1).trim();
47
+ const choicesAt = body.indexOf('\n\n- ');
48
+ const skipAt = body.lastIndexOf('\n\nChoose an answer type.');
49
+ const content = choicesAt >= 0 ? body.slice(0, choicesAt) : skipAt >= 0 ? body.slice(0, skipAt) : body;
50
+ const [question, ...context] = content.split('\n\n');
51
+ const choices = choicesAt < 0 ? [] : body.slice(choicesAt + 4, body.lastIndexOf('\n\nSelect ')).split('\n- ').map(formLiteral);
52
+ const options = selection?.kind === 'enum' || selection?.kind === 'multi_select' ? selection.options : [];
53
+ const numbered = new Set(options.map(option => option.label)).size !== options.length;
54
+ return {
55
+ id, header: formLiteral(header), question: formLiteral(question || form.title),
56
+ ...(context.length ? { context: formLiteral(context.join('\n\n')) } : {}),
57
+ options: options.map((option, index) => {
58
+ const title = option.label.replace(/[\u0000-\u001f\u007f-\u009f]/gu, '');
59
+ const choice = choices[index];
60
+ const description = choice?.startsWith(`${option.label}: `) ? choice.slice(option.label.length + 2) : undefined;
61
+ return { title: numbered ? `${index + 1}. ${title}` : title, ...(description === undefined ? {} : { description }) };
62
+ }),
63
+ allowMultiple: selection?.kind === 'multi_select',
64
+ allowFreeform: form.input.fields.some(field => field.id === `${id}.text` && field.kind === 'string'),
65
+ allowComment: form.input.fields.some(field => field.id === `${id}.comment` && field.kind === 'string'),
66
+ };
67
+ });
68
+ const result = await createTuiAskUserPresenter(config).present({ questions }, context);
69
+ if (context.signal.aborted)
70
+ return undefined;
71
+ const action = form.actions.find(action => action.id === (result.status === 'answered' ? 'submit' : 'cancel'));
72
+ if (!action)
73
+ throw new Error('Ask-user form is missing its response action.');
74
+ const values = {};
75
+ if (result.status === 'answered')
76
+ for (const question of questions) {
77
+ const response = result.answers.find(answer => answer.questionId === question.id)?.response;
78
+ const mode = response?.kind ?? 'skip';
79
+ if (form.input.fields.some(field => field.id === `${question.id}.mode`))
80
+ values[`${question.id}.mode`] = mode;
81
+ if (response?.kind === 'freeform')
82
+ values[`${question.id}.text`] = response.text;
83
+ if (response?.kind === 'selection') {
84
+ const field = form.input.fields.find(field => field.id === `${question.id}.selection`);
85
+ if (field?.kind !== 'enum' && field?.kind !== 'multi_select')
86
+ throw new Error('Ask-user selection field is missing.');
87
+ const selected = response.selections.map(title => {
88
+ const option = field.options[question.options.findIndex(option => option.title === title)];
89
+ if (!option)
90
+ throw new Error('Ask-user returned an undeclared selection.');
91
+ return option.id;
92
+ });
93
+ values[field.id] = field.kind === 'multi_select' ? selected : selected[0];
94
+ if (response.comment !== undefined)
95
+ values[`${question.id}.comment`] = response.comment;
96
+ }
97
+ }
98
+ return { kind: 'form', actionId: action.id, outcome: action.outcome, values };
99
+ }
100
+ function formLiteral(value) {
101
+ return decodeUiMarkdown(value, { plainText: true }).replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/gu, '');
102
+ }
103
+ async function presentAskUser(request, execution, config) {
104
+ if (execution.signal.aborted)
105
+ return { status: 'cancelled', reason: 'abort' };
106
+ const ctx = execution;
107
+ if (!ctx.hasUI || (ctx.mode !== 'tui' && ctx.mode !== 'rpc')) {
108
+ return {
109
+ status: 'cancelled',
110
+ reason: 'unavailable',
111
+ message: `ask_user requires TUI or RPC dialog mode; current mode is ${ctx.mode}`,
112
+ };
113
+ }
114
+ const displayMode = request.displayMode ?? config.displayMode;
115
+ const singleSelectLayout = request.singleSelectLayout ?? config.singleSelectLayout;
116
+ const shortcuts = {
117
+ overlayToggle: resolveShortcut(request.overlayToggleKey, config.overlayToggleKey, DEFAULT_OVERLAY_TOGGLE),
118
+ commentToggle: resolveShortcut(request.commentToggleKey, config.commentToggleKey, DEFAULT_COMMENT_TOGGLE),
119
+ };
120
+ let timedOut = false;
121
+ let aborted = false;
122
+ if (ctx.mode === 'rpc') {
123
+ const dialogResult = await askQuestionsViaDialogs(ctx.ui, request.questions, request.timeout, execution.signal);
124
+ if (dialogResult.cancelled)
125
+ return { status: 'cancelled', reason: dialogResult.cancelled };
126
+ return dialogResult.answers.some((answer) => answer.response !== null)
127
+ ? { status: 'answered', answers: dialogResult.answers }
128
+ : { status: 'cancelled', reason: 'user' };
129
+ }
130
+ let overlayHandle;
131
+ let removeOverlayListener;
132
+ let removeAbortListener;
133
+ let timeoutHandle;
134
+ let announcedHidden = false;
135
+ try {
136
+ const overlayToggle = shortcuts.overlayToggle;
137
+ if (displayMode === 'overlay' && !overlayToggle.disabled && typeof ctx.ui.onTerminalInput === 'function') {
138
+ removeOverlayListener = ctx.ui.onTerminalInput((data) => {
139
+ if (!overlayHandle || !overlayToggle.matches(data))
140
+ return undefined;
141
+ const hidden = !overlayHandle.isHidden();
142
+ overlayHandle.setHidden(hidden);
143
+ if (hidden && !announcedHidden) {
144
+ announcedHidden = true;
145
+ ctx.ui.notify?.(`ask_user hidden — press ${overlayToggle.spec} to reopen`, 'info');
146
+ }
147
+ return { consume: true };
148
+ });
149
+ }
150
+ const result = await ctx.ui.custom((tui, theme, keybindings, done) => {
151
+ let settled = false;
152
+ const finish = (value) => {
153
+ if (settled)
154
+ return;
155
+ settled = true;
156
+ done(value);
157
+ };
158
+ const onAbort = () => {
159
+ aborted = true;
160
+ finish(null);
161
+ };
162
+ execution.signal.addEventListener('abort', onAbort, { once: true });
163
+ removeAbortListener = () => execution.signal.removeEventListener('abort', onAbort);
164
+ if (request.timeout !== undefined) {
165
+ timeoutHandle = setTimeout(() => {
166
+ timedOut = true;
167
+ finish(null);
168
+ }, request.timeout);
169
+ }
170
+ if (request.questions.length === 1) {
171
+ const question = request.questions[0];
172
+ return new AskPrompt(question, displayMode, singleSelectLayout, tui, theme, keybindings, shortcuts, (response) => finish(response === null ? null : [{ questionId: question.id, response }]));
173
+ }
174
+ return new AskWizard(request.questions, displayMode, singleSelectLayout, tui, theme, keybindings, shortcuts, execution.reportProgress, finish);
175
+ }, customUIOptions(displayMode, (handle) => {
176
+ overlayHandle = handle;
177
+ }));
178
+ if (result === undefined) {
179
+ const dialogResult = await askQuestionsViaDialogs(ctx.ui, request.questions, request.timeout, execution.signal);
180
+ if (dialogResult.cancelled)
181
+ return { status: 'cancelled', reason: dialogResult.cancelled };
182
+ return dialogResult.answers.some((answer) => answer.response !== null)
183
+ ? { status: 'answered', answers: dialogResult.answers }
184
+ : { status: 'cancelled', reason: 'user' };
185
+ }
186
+ if (result === null) {
187
+ return {
188
+ status: 'cancelled',
189
+ reason: timedOut ? 'timeout' : aborted || execution.signal.aborted ? 'abort' : 'user',
190
+ };
191
+ }
192
+ return { status: 'answered', answers: result };
193
+ }
194
+ finally {
195
+ if (timeoutHandle !== undefined)
196
+ clearTimeout(timeoutHandle);
197
+ removeAbortListener?.();
198
+ removeOverlayListener?.();
199
+ }
200
+ }
201
+ function resolveShortcut(parameter, configuredDefault, fallback) {
202
+ for (const value of [parameter, configuredDefault, fallback]) {
203
+ if (value === undefined)
204
+ continue;
205
+ if (value === null)
206
+ return DISABLED_SHORTCUT;
207
+ const normalized = normalizeAskUserShortcut(value);
208
+ if (normalized === undefined)
209
+ continue;
210
+ if (normalized === null)
211
+ return DISABLED_SHORTCUT;
212
+ return { disabled: false, spec: normalized, matches: (data) => matchesKey(data, normalized) };
213
+ }
214
+ return DISABLED_SHORTCUT;
215
+ }
216
+ function customUIOptions(displayMode, onHandle) {
217
+ if (displayMode === 'inline')
218
+ return undefined;
219
+ return {
220
+ overlay: true,
221
+ overlayOptions: {
222
+ anchor: 'center',
223
+ width: OVERLAY_WIDTH,
224
+ minWidth: OVERLAY_MIN_WIDTH,
225
+ maxHeight: OVERLAY_MAX_HEIGHT,
226
+ margin: 1,
227
+ },
228
+ onHandle,
229
+ };
230
+ }
231
+ function overlayMaxRenderLines(terminalRows) {
232
+ const rows = Number.isFinite(terminalRows) ? Math.max(1, Math.floor(terminalRows)) : 24;
233
+ const availableRows = Math.max(1, rows - 2);
234
+ const ratioRows = Math.max(1, Math.floor(rows * OVERLAY_MAX_HEIGHT_RATIO));
235
+ const minimumRows = Math.min(OVERLAY_MIN_RENDER_LINES, availableRows);
236
+ return Math.min(availableRows, Math.max(minimumRows, ratioRows));
237
+ }
238
+ class BorderTop {
239
+ color;
240
+ title;
241
+ titleColor;
242
+ constructor(color, title, titleColor) {
243
+ this.color = color;
244
+ this.title = title;
245
+ this.titleColor = titleColor;
246
+ }
247
+ invalidate() { }
248
+ render(width) {
249
+ const inner = Math.max(0, width - 2);
250
+ if (inner < this.title.length + 4)
251
+ return [this.color(`╭${'─'.repeat(inner)}╮`)];
252
+ const label = ` ${this.title} `;
253
+ return [
254
+ this.color('╭─')
255
+ + this.titleColor(label)
256
+ + this.color(`${'─'.repeat(Math.max(0, inner - label.length - 1))}╮`),
257
+ ];
258
+ }
259
+ }
260
+ class BorderBottom {
261
+ color;
262
+ label;
263
+ labelColor;
264
+ constructor(color, label, labelColor) {
265
+ this.color = color;
266
+ this.label = label;
267
+ this.labelColor = labelColor;
268
+ }
269
+ invalidate() { }
270
+ render(width) {
271
+ const inner = Math.max(0, width - 2);
272
+ if (inner < this.label.length + 4)
273
+ return [this.color(`╰${'─'.repeat(inner)}╯`)];
274
+ const tag = ` ${this.label} `;
275
+ return [
276
+ this.color(`╰${'─'.repeat(Math.max(0, inner - tag.length - 1))}`)
277
+ + this.labelColor(tag)
278
+ + this.color('─╯'),
279
+ ];
280
+ }
281
+ }
282
+ function createEditorTheme(theme) {
283
+ return {
284
+ borderColor: (text) => theme.fg('accent', text),
285
+ selectList: {
286
+ selectedPrefix: (text) => theme.fg('accent', text),
287
+ selectedText: (text) => theme.fg('accent', text),
288
+ description: (text) => theme.fg('muted', text),
289
+ scrollInfo: (text) => theme.fg('dim', text),
290
+ noMatch: (text) => theme.fg('warning', text),
291
+ },
292
+ };
293
+ }
294
+ function keyHint(theme, keybindings, binding, description) {
295
+ return `${theme.fg('dim', keybindings.getKeys(binding).join('/'))}${theme.fg('muted', ` ${description}`)}`;
296
+ }
297
+ function literalHint(theme, key, description) {
298
+ return `${theme.fg('dim', key)}${theme.fg('muted', ` ${description}`)}`;
299
+ }
300
+ function matchesUp(data, keybindings) {
301
+ return keybindings.matches(data, 'tui.select.up')
302
+ || matchesKey(data, Key.shift('tab'))
303
+ || matchesKey(data, Key.ctrl('k'));
304
+ }
305
+ function matchesDown(data, keybindings) {
306
+ return keybindings.matches(data, 'tui.select.down')
307
+ || matchesKey(data, Key.tab)
308
+ || matchesKey(data, Key.ctrl('j'));
309
+ }
310
+ function matchesSubmit(data, keybindings) {
311
+ return keybindings.matches(data, 'tui.select.confirm')
312
+ || keybindings.matches(data, 'tui.input.submit')
313
+ || matchesKey(data, Key.enter)
314
+ || matchesKey(data, Key.return);
315
+ }
316
+ class MultiSelectList {
317
+ options;
318
+ allowFreeform;
319
+ allowComment;
320
+ theme;
321
+ keybindings;
322
+ commentToggle;
323
+ selectedIndex = 0;
324
+ checked = new Set();
325
+ commentEnabled = false;
326
+ maxVisibleRows = 10;
327
+ cachedWidth;
328
+ cachedLines;
329
+ onCancel;
330
+ onSubmit;
331
+ onEnterFreeform;
332
+ constructor(options, allowFreeform, allowComment, theme, keybindings, commentToggle) {
333
+ this.options = options;
334
+ this.allowFreeform = allowFreeform;
335
+ this.allowComment = allowComment;
336
+ this.theme = theme;
337
+ this.keybindings = keybindings;
338
+ this.commentToggle = commentToggle;
339
+ }
340
+ setMaxVisibleRows(rows) {
341
+ const normalized = Math.max(1, Math.floor(rows));
342
+ if (normalized !== this.maxVisibleRows) {
343
+ this.maxVisibleRows = normalized;
344
+ this.invalidate();
345
+ }
346
+ }
347
+ invalidate() {
348
+ this.cachedWidth = undefined;
349
+ this.cachedLines = undefined;
350
+ }
351
+ handleInput(data) {
352
+ if (this.keybindings.matches(data, 'tui.select.cancel'))
353
+ return this.onCancel?.();
354
+ const count = this.itemCount();
355
+ if (count === 0)
356
+ return this.onCancel?.();
357
+ if (this.allowComment && !this.commentToggle.disabled && this.commentToggle.matches(data)) {
358
+ this.toggleComment();
359
+ return;
360
+ }
361
+ if (matchesUp(data, this.keybindings)) {
362
+ this.selectedIndex = this.selectedIndex === 0 ? count - 1 : this.selectedIndex - 1;
363
+ this.invalidate();
364
+ return;
365
+ }
366
+ if (matchesDown(data, this.keybindings)) {
367
+ this.selectedIndex = this.selectedIndex === count - 1 ? 0 : this.selectedIndex + 1;
368
+ this.invalidate();
369
+ return;
370
+ }
371
+ const number = data.match(/^[1-9]$/);
372
+ if (number) {
373
+ const index = Number(number[0]) - 1;
374
+ if (index < this.options.length) {
375
+ this.toggle(index);
376
+ this.selectedIndex = index;
377
+ this.invalidate();
378
+ }
379
+ return;
380
+ }
381
+ if (matchesKey(data, Key.space)) {
382
+ if (this.isCommentRow(this.selectedIndex))
383
+ return this.toggleComment();
384
+ if (this.isFreeformRow(this.selectedIndex))
385
+ return this.onEnterFreeform?.();
386
+ this.toggle(this.selectedIndex);
387
+ this.invalidate();
388
+ return;
389
+ }
390
+ if (!matchesSubmit(data, this.keybindings))
391
+ return;
392
+ if (this.isCommentRow(this.selectedIndex))
393
+ return this.toggleComment();
394
+ if (this.isFreeformRow(this.selectedIndex))
395
+ return this.onEnterFreeform?.();
396
+ const selections = [...this.checked]
397
+ .sort((left, right) => left - right)
398
+ .map((index) => this.options[index]?.title)
399
+ .filter((title) => title !== undefined);
400
+ const fallback = this.options[this.selectedIndex]?.title;
401
+ const result = selections.length > 0 ? selections : fallback ? [fallback] : [];
402
+ if (result.length > 0)
403
+ this.onSubmit?.(result, this.commentEnabled);
404
+ else
405
+ this.onCancel?.();
406
+ }
407
+ render(width) {
408
+ if (this.cachedLines && this.cachedWidth === width)
409
+ return this.cachedLines;
410
+ const count = this.itemCount();
411
+ if (count === 0)
412
+ return [this.theme.fg('warning', 'No options')];
413
+ const blocks = [];
414
+ for (let index = 0; index < count; index += 1) {
415
+ const active = index === this.selectedIndex;
416
+ const pointer = active ? this.theme.fg('accent', '→') : ' ';
417
+ const block = [];
418
+ if (this.isCommentRow(index)) {
419
+ const check = this.commentEnabled ? this.theme.fg('success', '[✓]') : this.theme.fg('dim', '[ ]');
420
+ block.push(truncateToWidth(`${pointer} ${check} ${this.theme.fg(active ? 'accent' : 'text', COMMENT_LABEL)}`, width, ''));
421
+ blocks.push(block);
422
+ continue;
423
+ }
424
+ if (this.isFreeformRow(index)) {
425
+ block.push(truncateToWidth(`${pointer} ${this.theme.fg(active ? 'accent' : 'text', 'Type something.')} ${this.theme.fg('muted', '— Enter a custom response')}`, width, ''));
426
+ blocks.push(block);
427
+ continue;
428
+ }
429
+ const option = this.options[index];
430
+ const check = this.checked.has(index) ? this.theme.fg('success', '[✓]') : this.theme.fg('dim', '[ ]');
431
+ block.push(truncateToWidth(`${pointer} ${this.theme.fg('dim', `${index + 1}.`)} ${check} ${this.theme.fg(active ? 'accent' : 'text', this.theme.bold(option.title))}`, width, ''));
432
+ if (option.description) {
433
+ for (const line of wrapTextWithAnsi(option.description, Math.max(10, width - 6))) {
434
+ block.push(truncateToWidth(` ${this.theme.fg('muted', line)}`, width, ''));
435
+ }
436
+ }
437
+ blocks.push(block);
438
+ }
439
+ const totalRows = blocks.reduce((sum, block) => sum + block.length, 0);
440
+ let lines;
441
+ if (totalRows <= this.maxVisibleRows) {
442
+ lines = blocks.flat();
443
+ }
444
+ else {
445
+ const availableRows = this.maxVisibleRows > 1 ? this.maxVisibleRows - 1 : 1;
446
+ const selectedBlock = blocks[this.selectedIndex] ?? blocks[0] ?? [];
447
+ if (selectedBlock.length >= availableRows) {
448
+ lines = selectedBlock.slice(0, availableRows);
449
+ }
450
+ else {
451
+ let start = this.selectedIndex;
452
+ let end = this.selectedIndex + 1;
453
+ let usedRows = selectedBlock.length;
454
+ while (true) {
455
+ const next = blocks[end];
456
+ if (next && usedRows + next.length <= availableRows) {
457
+ usedRows += next.length;
458
+ end += 1;
459
+ continue;
460
+ }
461
+ const previous = blocks[start - 1];
462
+ if (previous && usedRows + previous.length <= availableRows) {
463
+ start -= 1;
464
+ usedRows += previous.length;
465
+ continue;
466
+ }
467
+ break;
468
+ }
469
+ lines = blocks.slice(start, end).flat();
470
+ }
471
+ if (this.maxVisibleRows > 1) {
472
+ lines.push(this.theme.fg('dim', truncateToWidth(` (${this.selectedIndex + 1}/${count})`, width, '')));
473
+ }
474
+ }
475
+ this.cachedWidth = width;
476
+ this.cachedLines = lines;
477
+ return lines;
478
+ }
479
+ itemCount() {
480
+ return this.options.length + (this.allowComment ? 1 : 0) + (this.allowFreeform ? 1 : 0);
481
+ }
482
+ isCommentRow(index) {
483
+ return this.allowComment && index === this.options.length;
484
+ }
485
+ isFreeformRow(index) {
486
+ return this.allowFreeform && index === this.options.length + (this.allowComment ? 1 : 0);
487
+ }
488
+ toggle(index) {
489
+ if (index < 0 || index >= this.options.length)
490
+ return;
491
+ if (this.checked.has(index))
492
+ this.checked.delete(index);
493
+ else
494
+ this.checked.add(index);
495
+ }
496
+ toggleComment() {
497
+ if (!this.allowComment)
498
+ return;
499
+ this.commentEnabled = !this.commentEnabled;
500
+ this.invalidate();
501
+ }
502
+ }
503
+ class SearchableSingleSelect {
504
+ options;
505
+ allowFreeform;
506
+ allowComment;
507
+ theme;
508
+ singleSelectLayout;
509
+ keybindings;
510
+ commentToggle;
511
+ selectedIndex = 0;
512
+ searchQuery = '';
513
+ commentEnabled = false;
514
+ maxVisibleRows = 12;
515
+ cachedWidth;
516
+ cachedLines;
517
+ onCancel;
518
+ onSubmit;
519
+ onEnterFreeform;
520
+ constructor(options, allowFreeform, allowComment, theme, singleSelectLayout, keybindings, commentToggle) {
521
+ this.options = options;
522
+ this.allowFreeform = allowFreeform;
523
+ this.allowComment = allowComment;
524
+ this.theme = theme;
525
+ this.singleSelectLayout = singleSelectLayout;
526
+ this.keybindings = keybindings;
527
+ this.commentToggle = commentToggle;
528
+ }
529
+ setMaxVisibleRows(rows) {
530
+ const normalized = Math.max(1, Math.floor(rows));
531
+ if (normalized !== this.maxVisibleRows) {
532
+ this.maxVisibleRows = normalized;
533
+ this.invalidate();
534
+ }
535
+ }
536
+ invalidate() {
537
+ this.cachedWidth = undefined;
538
+ this.cachedLines = undefined;
539
+ }
540
+ handleInput(data) {
541
+ if (this.searchQuery && matchesKey(data, Key.escape)) {
542
+ this.setSearch('');
543
+ return;
544
+ }
545
+ if (this.keybindings.matches(data, 'tui.select.cancel'))
546
+ return this.onCancel?.();
547
+ if (this.allowComment && !this.commentToggle.disabled && this.commentToggle.matches(data)) {
548
+ this.toggleComment();
549
+ return;
550
+ }
551
+ const filtered = this.filtered();
552
+ const count = this.itemCount(filtered);
553
+ if (matchesUp(data, this.keybindings) && count > 0) {
554
+ this.selectedIndex = this.selectedIndex === 0 ? count - 1 : this.selectedIndex - 1;
555
+ this.invalidate();
556
+ return;
557
+ }
558
+ if (matchesDown(data, this.keybindings) && count > 0) {
559
+ this.selectedIndex = this.selectedIndex === count - 1 ? 0 : this.selectedIndex + 1;
560
+ this.invalidate();
561
+ return;
562
+ }
563
+ const number = data.match(/^[1-9]$/);
564
+ if (number && Number(number[0]) <= filtered.length) {
565
+ this.selectedIndex = Number(number[0]) - 1;
566
+ this.invalidate();
567
+ return;
568
+ }
569
+ if (matchesKey(data, Key.space) && this.isCommentRow(this.selectedIndex, filtered)) {
570
+ this.toggleComment();
571
+ return;
572
+ }
573
+ if (matchesSubmit(data, this.keybindings) && count > 0) {
574
+ if (this.isCommentRow(this.selectedIndex, filtered))
575
+ return this.toggleComment();
576
+ if (this.isFreeformRow(this.selectedIndex, filtered))
577
+ return this.onEnterFreeform?.();
578
+ const selected = filtered[this.selectedIndex]?.title;
579
+ if (selected)
580
+ this.onSubmit?.(selected, this.commentEnabled);
581
+ else
582
+ this.onCancel?.();
583
+ return;
584
+ }
585
+ if (this.keybindings.matches(data, 'tui.editor.deleteCharBackward') || matchesKey(data, Key.backspace)) {
586
+ const characters = [...this.searchQuery];
587
+ characters.pop();
588
+ this.setSearch(characters.join(''));
589
+ return;
590
+ }
591
+ const printable = printableInput(data);
592
+ if (printable)
593
+ this.setSearch(this.searchQuery + printable);
594
+ }
595
+ render(width) {
596
+ if (this.cachedLines && this.cachedWidth === width)
597
+ return this.cachedLines;
598
+ const filtered = this.filtered();
599
+ const count = this.itemCount(filtered);
600
+ this.selectedIndex = count > 0 ? Math.min(this.selectedIndex, count - 1) : 0;
601
+ const split = this.singleSelectLayout === 'list' ? null : splitPaneWidths(width);
602
+ const lines = split
603
+ ? this.renderSplit(split.left, split.right, filtered)
604
+ : this.renderList(width, filtered, false);
605
+ this.cachedWidth = width;
606
+ this.cachedLines = lines;
607
+ return lines;
608
+ }
609
+ renderList(width, filtered, hideDescriptions) {
610
+ const query = this.searchQuery ? this.theme.fg('text', this.searchQuery) : this.theme.fg('dim', 'type to filter');
611
+ const header = [truncateToWidth(`${this.theme.fg('accent', 'Filter:')} ${query}`, width, '')];
612
+ if (this.searchQuery && filtered.length === 0)
613
+ header.push(this.theme.fg('warning', 'No matching options'));
614
+ const rows = renderSingleSelectRows({
615
+ options: filtered,
616
+ selectedIndex: this.selectedIndex,
617
+ width,
618
+ allowFreeform: this.allowFreeform,
619
+ allowComment: this.allowComment,
620
+ commentEnabled: this.commentEnabled,
621
+ maxRows: Math.max(1, this.maxVisibleRows - header.length),
622
+ hideDescriptions,
623
+ });
624
+ const renderedRows = rows.map((row) => this.styleLine(row.line, width, row.selected));
625
+ if (this.maxVisibleRows === 1)
626
+ return renderedRows.length > 0 ? [renderedRows[0]] : header.slice(-1);
627
+ return [...header, ...renderedRows].slice(0, this.maxVisibleRows);
628
+ }
629
+ renderSplit(leftWidth, rightWidth, filtered) {
630
+ const left = this.renderList(leftWidth, filtered, true);
631
+ const right = this.preview(rightWidth, filtered);
632
+ const rows = Math.min(this.maxVisibleRows, Math.max(left.length, right.length));
633
+ return Array.from({ length: rows }, (_, index) => (`${truncateToWidth(left[index] ?? '', leftWidth, '', true)}${this.theme.fg('dim', SPLIT_SEPARATOR)}${truncateToWidth(right[index] ?? '', rightWidth, '')}`));
634
+ }
635
+ preview(width, filtered) {
636
+ let title;
637
+ let description;
638
+ if (this.isCommentRow(this.selectedIndex, filtered)) {
639
+ title = 'Additional context';
640
+ description = `Currently ${this.commentEnabled ? 'enabled' : 'disabled'}. Add an explanation after selecting.`;
641
+ }
642
+ else if (this.isFreeformRow(this.selectedIndex, filtered)) {
643
+ title = 'Custom response';
644
+ description = 'Open the editor to write an answer when none of the listed options fit.';
645
+ }
646
+ else {
647
+ const selected = filtered[this.selectedIndex];
648
+ title = selected?.title ?? 'No option selected';
649
+ description = selected?.description ?? 'No additional details provided for this option.';
650
+ }
651
+ const lines = [this.theme.fg('accent', this.theme.bold(title)), ''];
652
+ lines.push(...wrapTextWithAnsi(description, Math.max(10, width)).map((line) => this.theme.fg('muted', line)));
653
+ return lines.slice(0, this.maxVisibleRows);
654
+ }
655
+ styleLine(line, width, selected) {
656
+ if (selected)
657
+ return truncateToWidth(this.theme.fg('accent', this.theme.bold(line)), width, '');
658
+ if (line.startsWith(' '))
659
+ return truncateToWidth(this.theme.fg('muted', line), width, '');
660
+ if (line.trim().startsWith('('))
661
+ return truncateToWidth(this.theme.fg('dim', line), width, '');
662
+ return truncateToWidth(this.theme.fg('text', line), width, '');
663
+ }
664
+ filtered() {
665
+ return fuzzyFilter([...this.options], this.searchQuery, (option) => `${option.title} ${option.description ?? ''}`);
666
+ }
667
+ itemCount(filtered) {
668
+ return filtered.length + (this.allowComment ? 1 : 0) + (this.allowFreeform ? 1 : 0);
669
+ }
670
+ isCommentRow(index, filtered) {
671
+ return this.allowComment && index === filtered.length;
672
+ }
673
+ isFreeformRow(index, filtered) {
674
+ return this.allowFreeform && index === filtered.length + (this.allowComment ? 1 : 0);
675
+ }
676
+ setSearch(value) {
677
+ this.searchQuery = value;
678
+ this.selectedIndex = 0;
679
+ this.invalidate();
680
+ }
681
+ toggleComment() {
682
+ this.commentEnabled = !this.commentEnabled;
683
+ this.invalidate();
684
+ }
685
+ }
686
+ function printableInput(data) {
687
+ const kitty = decodeKittyPrintable(data);
688
+ if (kitty !== undefined)
689
+ return kitty;
690
+ const characters = [...data];
691
+ if (characters.length !== 1)
692
+ return null;
693
+ const character = characters[0];
694
+ const code = character.charCodeAt(0);
695
+ return code < 32 || code === 0x7f || (code >= 0x80 && code <= 0x9f) ? null : character;
696
+ }
697
+ function splitPaneWidths(width) {
698
+ if (width < SPLIT_PANE_MIN_WIDTH)
699
+ return null;
700
+ const available = width - SPLIT_SEPARATOR.length;
701
+ if (available < SPLIT_LEFT_MIN_WIDTH + SPLIT_RIGHT_MIN_WIDTH)
702
+ return null;
703
+ const left = Math.max(SPLIT_LEFT_MIN_WIDTH, Math.min(Math.floor(available * 0.42), available - SPLIT_RIGHT_MIN_WIDTH));
704
+ const right = available - left;
705
+ return right < SPLIT_RIGHT_MIN_WIDTH ? null : { left, right };
706
+ }
707
+ class AskPrompt extends Container {
708
+ question;
709
+ displayMode;
710
+ singleSelectLayout;
711
+ tui;
712
+ theme;
713
+ keybindings;
714
+ shortcuts;
715
+ onDone;
716
+ mode = 'select';
717
+ pendingSelections = [];
718
+ freeformDraft = '';
719
+ commentDraft = '';
720
+ modeContainer = new Container();
721
+ titleText = new Text('', 1, 0);
722
+ helpText = new Text('', 1, 0);
723
+ contextText;
724
+ contextIsCollapsible = false;
725
+ contextExpanded = false;
726
+ singleSelect;
727
+ multiSelect;
728
+ editor;
729
+ _focused = false;
730
+ get focused() {
731
+ return this._focused;
732
+ }
733
+ set focused(value) {
734
+ this._focused = value;
735
+ if (this.editor && this.mode !== 'select')
736
+ this.editor.focused = value;
737
+ }
738
+ constructor(question, displayMode, singleSelectLayout, tui, theme, keybindings, shortcuts, onDone) {
739
+ super();
740
+ this.question = question;
741
+ this.displayMode = displayMode;
742
+ this.singleSelectLayout = singleSelectLayout;
743
+ this.tui = tui;
744
+ this.theme = theme;
745
+ this.keybindings = keybindings;
746
+ this.shortcuts = shortcuts;
747
+ this.onDone = onDone;
748
+ this.addChild(new BorderTop((text) => theme.fg('accent', text), 'ask_user', (text) => theme.fg('dim', theme.bold(text))));
749
+ this.addChild(new Spacer(1));
750
+ this.addChild(this.titleText);
751
+ this.addChild(new Spacer(1));
752
+ this.addChild(new Text(theme.fg('text', theme.bold(question.question)), 1, 0));
753
+ if (question.context) {
754
+ this.addChild(new Spacer(1));
755
+ this.contextText = new Text('', 1, 0);
756
+ this.addChild(this.contextText);
757
+ }
758
+ this.addChild(new Spacer(1));
759
+ this.addChild(this.modeContainer);
760
+ this.addChild(new Spacer(1));
761
+ this.addChild(this.helpText);
762
+ this.addChild(new Spacer(1));
763
+ this.addChild(new BorderBottom((text) => theme.fg('accent', text), `v${VERSION}`, (text) => theme.fg('dim', text)));
764
+ this.showSelect();
765
+ }
766
+ invalidate() {
767
+ super.invalidate();
768
+ this.updateText();
769
+ }
770
+ render(width) {
771
+ const innerWidth = Math.max(1, width - (this.displayMode === 'overlay' ? BOX_OVERHEAD : 0));
772
+ const maxHeight = this.displayMode === 'overlay'
773
+ ? overlayMaxRenderLines(this.tui.terminal.rows)
774
+ : undefined;
775
+ this.updateContext(innerWidth, maxHeight);
776
+ if (this.mode === 'select') {
777
+ const questionRows = wrapTextWithAnsi(this.question.question, Math.max(10, innerWidth - 2)).length;
778
+ const contextRows = this.contextText?.render(innerWidth).length ?? 0;
779
+ const staticLines = 10 + questionRows + (contextRows > 0 ? contextRows + 1 : 0);
780
+ const visibleRows = maxHeight === undefined
781
+ ? (this.question.allowMultiple ? 10 : 12)
782
+ : Math.max(1, maxHeight - staticLines);
783
+ if (this.question.allowMultiple)
784
+ this.ensureMulti().setMaxVisibleRows(visibleRows);
785
+ else
786
+ this.ensureSingle().setMaxVisibleRows(visibleRows);
787
+ }
788
+ const lines = super.render(innerWidth);
789
+ if (maxHeight !== undefined && lines.length > maxHeight) {
790
+ if (maxHeight <= 1)
791
+ return [this.renderTopBorder(width)];
792
+ if (maxHeight === 2)
793
+ return [this.renderTopBorder(width), this.renderBottomBorder(width)];
794
+ const bodyCapacity = maxHeight - 2;
795
+ const renderedModeLines = this.modeContainer.render(innerWidth);
796
+ let prioritizedModeLines = renderedModeLines;
797
+ if (this.mode !== 'select' && renderedModeLines.length > 1) {
798
+ prioritizedModeLines = renderedModeLines.slice(0, -1);
799
+ }
800
+ else if (!this.question.allowMultiple && renderedModeLines.length > 1) {
801
+ prioritizedModeLines = renderedModeLines.slice(1);
802
+ }
803
+ const modeLines = prioritizedModeLines.slice(-bodyCapacity);
804
+ const promptBudget = Math.max(0, bodyCapacity - modeLines.length);
805
+ const promptLines = [
806
+ ...new Text(this.theme.fg('text', this.theme.bold(this.question.question)), 1, 0).render(innerWidth),
807
+ ...(this.contextText?.render(innerWidth) ?? []),
808
+ ].slice(0, promptBudget);
809
+ return this.frameBody([...promptLines, ...modeLines], width, innerWidth);
810
+ }
811
+ return lines.map((line, index) => {
812
+ if (index === 0)
813
+ return this.renderTopBorder(width);
814
+ if (index === lines.length - 1)
815
+ return this.renderBottomBorder(width);
816
+ return this.displayMode === 'overlay'
817
+ ? this.boxLine(line, innerWidth)
818
+ : truncateToWidth(line, width, '', true);
819
+ });
820
+ }
821
+ handleInput(data) {
822
+ if (this.contextIsCollapsible && matchesKey(data, CONTEXT_TOGGLE_KEY)) {
823
+ this.contextExpanded = !this.contextExpanded;
824
+ this.invalidate();
825
+ this.tui.requestRender();
826
+ return;
827
+ }
828
+ if (this.mode !== 'select') {
829
+ if (matchesKey(data, Key.escape)) {
830
+ this.showSelect();
831
+ return;
832
+ }
833
+ if (this.keybindings.matches(data, 'tui.select.cancel')) {
834
+ this.onDone(null);
835
+ return;
836
+ }
837
+ this.ensureEditor().handleInput(data);
838
+ this.tui.requestRender();
839
+ return;
840
+ }
841
+ if (this.question.allowMultiple)
842
+ this.ensureMulti().handleInput(data);
843
+ else
844
+ this.ensureSingle().handleInput(data);
845
+ this.tui.requestRender();
846
+ }
847
+ isTextInputMode() {
848
+ return this.mode !== 'select';
849
+ }
850
+ ensureSingle() {
851
+ if (this.singleSelect)
852
+ return this.singleSelect;
853
+ const list = new SearchableSingleSelect(this.question.options, this.question.allowFreeform, this.question.allowComment, this.theme, this.singleSelectLayout, this.keybindings, this.shortcuts.commentToggle);
854
+ list.onCancel = () => this.onDone(null);
855
+ list.onEnterFreeform = () => this.showFreeform();
856
+ list.onSubmit = (selection, comment) => this.handleSelection([selection], comment);
857
+ this.singleSelect = list;
858
+ return list;
859
+ }
860
+ ensureMulti() {
861
+ if (this.multiSelect)
862
+ return this.multiSelect;
863
+ const list = new MultiSelectList(this.question.options, this.question.allowFreeform, this.question.allowComment, this.theme, this.keybindings, this.shortcuts.commentToggle);
864
+ list.onCancel = () => this.onDone(null);
865
+ list.onEnterFreeform = () => this.showFreeform();
866
+ list.onSubmit = (selections, comment) => this.handleSelection(selections, comment);
867
+ this.multiSelect = list;
868
+ return list;
869
+ }
870
+ ensureEditor() {
871
+ if (this.editor)
872
+ return this.editor;
873
+ const editor = new Editor(this.tui, createEditorTheme(this.theme));
874
+ editor.disableSubmit = false;
875
+ editor.onSubmit = (text) => {
876
+ if (this.mode === 'freeform')
877
+ this.onDone(freeformResponse(text));
878
+ else
879
+ this.onDone(selectionResponse(this.pendingSelections, text));
880
+ };
881
+ editor.focused = this._focused;
882
+ this.editor = editor;
883
+ return editor;
884
+ }
885
+ handleSelection(selections, wantsComment) {
886
+ if (this.question.allowComment && wantsComment) {
887
+ this.pendingSelections = selections;
888
+ this.commentDraft = '';
889
+ this.showComment();
890
+ return;
891
+ }
892
+ this.onDone(selectionResponse(selections));
893
+ }
894
+ showSelect() {
895
+ this.saveDraft();
896
+ this.mode = 'select';
897
+ this.pendingSelections = [];
898
+ this.modeContainer.clear();
899
+ this.modeContainer.addChild(this.question.allowMultiple ? this.ensureMulti() : this.ensureSingle());
900
+ this.updateText();
901
+ this.invalidate();
902
+ this.tui.requestRender();
903
+ }
904
+ showFreeform() {
905
+ this.saveDraft();
906
+ this.mode = 'freeform';
907
+ this.modeContainer.clear();
908
+ this.setEditorText(this.freeformDraft);
909
+ this.modeContainer.addChild(new Text(this.theme.fg('accent', this.theme.bold('Custom response')), 1, 0));
910
+ this.modeContainer.addChild(new Spacer(1));
911
+ this.modeContainer.addChild(this.ensureEditor());
912
+ this.updateText();
913
+ this.invalidate();
914
+ this.tui.requestRender();
915
+ }
916
+ showComment() {
917
+ this.saveDraft();
918
+ this.mode = 'comment';
919
+ this.modeContainer.clear();
920
+ this.setEditorText(this.commentDraft);
921
+ this.modeContainer.addChild(new Text(this.theme.fg('accent', this.theme.bold('Selected:')), 1, 0));
922
+ this.modeContainer.addChild(new Text(this.pendingSelections.join(', '), 1, 0));
923
+ this.modeContainer.addChild(new Spacer(1));
924
+ this.modeContainer.addChild(this.ensureEditor());
925
+ this.updateText();
926
+ this.invalidate();
927
+ this.tui.requestRender();
928
+ }
929
+ saveDraft() {
930
+ if (!this.editor || this.mode === 'select')
931
+ return;
932
+ const text = this.editor.getText();
933
+ if (this.mode === 'freeform')
934
+ this.freeformDraft = text;
935
+ else
936
+ this.commentDraft = text;
937
+ }
938
+ setEditorText(text) {
939
+ this.ensureEditor().setText(text);
940
+ }
941
+ updateText() {
942
+ this.titleText.setText(this.theme.fg('accent', this.theme.bold(this.mode === 'comment' ? 'Optional comment' : 'Question')));
943
+ const overlay = this.displayMode === 'overlay' && !this.shortcuts.overlayToggle.disabled
944
+ ? literalHint(this.theme, this.shortcuts.overlayToggle.spec, 'hide')
945
+ : undefined;
946
+ const context = this.contextIsCollapsible
947
+ ? literalHint(this.theme, CONTEXT_TOGGLE_KEY, this.contextExpanded ? 'collapse context' : 'expand context')
948
+ : undefined;
949
+ if (this.mode !== 'select') {
950
+ this.helpText.setText(this.theme.fg('dim', [
951
+ keyHint(this.theme, this.keybindings, 'tui.input.submit', this.mode === 'comment' ? 'submit/skip' : 'submit'),
952
+ literalHint(this.theme, 'esc', 'back'),
953
+ context,
954
+ overlay,
955
+ ].filter(Boolean).join(' • ')));
956
+ return;
957
+ }
958
+ const comment = this.question.allowComment && !this.shortcuts.commentToggle.disabled
959
+ ? literalHint(this.theme, this.shortcuts.commentToggle.spec, 'toggle context')
960
+ : undefined;
961
+ this.helpText.setText(this.theme.fg('dim', [
962
+ this.question.allowMultiple ? literalHint(this.theme, 'space', 'toggle') : literalHint(this.theme, 'type', 'filter'),
963
+ literalHint(this.theme, '↑↓', 'navigate'),
964
+ comment,
965
+ context,
966
+ overlay,
967
+ keyHint(this.theme, this.keybindings, 'tui.select.confirm', this.question.allowMultiple ? 'submit' : 'select'),
968
+ keyHint(this.theme, this.keybindings, 'tui.select.cancel', 'cancel'),
969
+ ].filter(Boolean).join(' • ')));
970
+ }
971
+ updateContext(width, maxHeight) {
972
+ if (!this.contextText || !this.question.context)
973
+ return;
974
+ const contentWidth = Math.max(10, width - 2);
975
+ const contextRows = wrapTextWithAnsi(this.question.context, contentWidth).length;
976
+ const questionRows = wrapTextWithAnsi(this.question.question, contentWidth).length;
977
+ const wouldCrowdChoices = maxHeight !== undefined && 11 + questionRows + contextRows + 1 > maxHeight;
978
+ const collapsible = contextRows > INLINE_CONTEXT_MAX_ROWS || wouldCrowdChoices;
979
+ if (this.contextIsCollapsible !== collapsible) {
980
+ this.contextIsCollapsible = collapsible;
981
+ if (!collapsible)
982
+ this.contextExpanded = false;
983
+ this.updateText();
984
+ }
985
+ if (this.contextIsCollapsible && !this.contextExpanded) {
986
+ this.contextText.setText(this.theme.fg('dim', `Context (${contextRows} lines) — ${CONTEXT_TOGGLE_KEY} expand`));
987
+ return;
988
+ }
989
+ this.contextText.setText(`${this.theme.fg('accent', this.theme.bold('Context:'))}\n${this.theme.fg('dim', this.question.context)}`);
990
+ }
991
+ frameBody(body, width, innerWidth) {
992
+ if (this.displayMode === 'inline') {
993
+ return [this.renderTopBorder(width), ...body.map((line) => truncateToWidth(line, width, '', true)), this.renderBottomBorder(width)];
994
+ }
995
+ return [
996
+ this.renderTopBorder(width),
997
+ ...body.map((line) => this.boxLine(line, innerWidth)),
998
+ this.renderBottomBorder(width),
999
+ ];
1000
+ }
1001
+ boxLine(line, innerWidth) {
1002
+ const border = (text) => this.theme.fg('accent', text);
1003
+ return `${border(BOX_LEFT)}${truncateToWidth(line, innerWidth, '', true)}${border(BOX_RIGHT)}`;
1004
+ }
1005
+ renderTopBorder(width) {
1006
+ if (this.displayMode === 'inline')
1007
+ return this.theme.fg('accent', '─'.repeat(Math.max(1, width)));
1008
+ return new BorderTop((text) => this.theme.fg('accent', text), 'ask_user', (text) => this.theme.fg('dim', this.theme.bold(text))).render(width)[0];
1009
+ }
1010
+ renderBottomBorder(width) {
1011
+ if (this.displayMode === 'inline')
1012
+ return this.theme.fg('accent', '─'.repeat(Math.max(1, width)));
1013
+ return new BorderBottom((text) => this.theme.fg('accent', text), `v${VERSION}`, (text) => this.theme.fg('dim', text)).render(width)[0];
1014
+ }
1015
+ }
1016
+ class AskWizard {
1017
+ questions;
1018
+ displayMode;
1019
+ singleSelectLayout;
1020
+ tui;
1021
+ theme;
1022
+ keybindings;
1023
+ shortcuts;
1024
+ reportProgress;
1025
+ onDone;
1026
+ index = 0;
1027
+ responses = new Map();
1028
+ prompt;
1029
+ _focused = false;
1030
+ get focused() {
1031
+ return this._focused;
1032
+ }
1033
+ set focused(value) {
1034
+ this._focused = value;
1035
+ if (this.prompt)
1036
+ this.prompt.focused = value;
1037
+ }
1038
+ constructor(questions, displayMode, singleSelectLayout, tui, theme, keybindings, shortcuts, reportProgress, onDone) {
1039
+ this.questions = questions;
1040
+ this.displayMode = displayMode;
1041
+ this.singleSelectLayout = singleSelectLayout;
1042
+ this.tui = tui;
1043
+ this.theme = theme;
1044
+ this.keybindings = keybindings;
1045
+ this.shortcuts = shortcuts;
1046
+ this.reportProgress = reportProgress;
1047
+ this.onDone = onDone;
1048
+ }
1049
+ invalidate() {
1050
+ this.prompt?.invalidate();
1051
+ }
1052
+ handleInput(data) {
1053
+ if (this.index === this.questions.length) {
1054
+ if (this.navigate(data))
1055
+ return;
1056
+ if (matchesSubmit(data, this.keybindings)) {
1057
+ const answers = this.answers();
1058
+ this.onDone(answers.some((answer) => answer.response !== null) ? answers : null);
1059
+ }
1060
+ else if (this.keybindings.matches(data, 'tui.select.cancel')) {
1061
+ this.onDone(null);
1062
+ }
1063
+ return;
1064
+ }
1065
+ const prompt = this.ensurePrompt();
1066
+ if (!prompt.isTextInputMode() && this.navigate(data))
1067
+ return;
1068
+ prompt.handleInput(data);
1069
+ }
1070
+ render(width) {
1071
+ const body = this.index === this.questions.length ? this.renderReview(width) : this.ensurePrompt().render(width);
1072
+ if (body.length < 2)
1073
+ return body;
1074
+ const border = (text) => this.theme.fg('accent', text);
1075
+ const inner = Math.max(1, width - (this.displayMode === 'overlay' ? BOX_OVERHEAD : 0));
1076
+ const navigation = this.displayMode === 'overlay'
1077
+ ? `${border(BOX_LEFT)}${truncateToWidth(this.navigation(), inner, '', true)}${border(BOX_RIGHT)}`
1078
+ : truncateToWidth(this.navigation(), width, '', true);
1079
+ const spacer = this.displayMode === 'overlay'
1080
+ ? `${border(BOX_LEFT)}${truncateToWidth('', inner, '', true)}${border(BOX_RIGHT)}`
1081
+ : ' '.repeat(width);
1082
+ const decorated = [body[0], navigation, spacer, ...body.slice(1)];
1083
+ if (this.displayMode !== 'overlay')
1084
+ return decorated;
1085
+ const maxHeight = overlayMaxRenderLines(this.tui.terminal.rows);
1086
+ if (decorated.length <= maxHeight)
1087
+ return decorated;
1088
+ if (maxHeight <= 1)
1089
+ return [body[0]];
1090
+ if (maxHeight === 2)
1091
+ return [body[0], body.at(-1)];
1092
+ const contentCapacity = maxHeight - 2;
1093
+ const promptContent = body.slice(1, -1);
1094
+ const content = contentCapacity === 1
1095
+ ? promptContent.slice(-1)
1096
+ : [navigation, ...promptContent.slice(-(contentCapacity - 1))];
1097
+ return [body[0], ...content, body.at(-1)];
1098
+ }
1099
+ ensurePrompt() {
1100
+ if (this.prompt)
1101
+ return this.prompt;
1102
+ const question = this.questions[this.index];
1103
+ this.prompt = new AskPrompt(question, this.displayMode, this.singleSelectLayout, this.tui, this.theme, this.keybindings, this.shortcuts, (response) => {
1104
+ if (response === null) {
1105
+ this.onDone(null);
1106
+ return;
1107
+ }
1108
+ this.responses.set(question.id, response);
1109
+ const answers = this.answers();
1110
+ this.reportProgress(answers);
1111
+ this.index = this.index < this.questions.length - 1 ? this.index + 1 : this.questions.length;
1112
+ this.prompt = undefined;
1113
+ this.invalidate();
1114
+ this.tui.requestRender();
1115
+ });
1116
+ this.prompt.focused = this._focused;
1117
+ return this.prompt;
1118
+ }
1119
+ navigate(data) {
1120
+ if (matchesKey(data, Key.tab) || matchesKey(data, Key.right)) {
1121
+ this.goTo((this.index + 1) % (this.questions.length + 1));
1122
+ return true;
1123
+ }
1124
+ if (matchesKey(data, Key.shift('tab')) || matchesKey(data, Key.left)) {
1125
+ this.goTo((this.index - 1 + this.questions.length + 1) % (this.questions.length + 1));
1126
+ return true;
1127
+ }
1128
+ return false;
1129
+ }
1130
+ goTo(index) {
1131
+ this.index = index;
1132
+ this.prompt = undefined;
1133
+ this.invalidate();
1134
+ this.tui.requestRender();
1135
+ }
1136
+ answers() {
1137
+ return this.questions.map((question) => ({
1138
+ questionId: question.id,
1139
+ response: this.responses.get(question.id) ?? null,
1140
+ }));
1141
+ }
1142
+ navigation() {
1143
+ const parts = [this.theme.fg('dim', '←')];
1144
+ for (let index = 0; index < this.questions.length; index += 1) {
1145
+ const question = this.questions[index];
1146
+ const answered = this.responses.has(question.id);
1147
+ const label = `${answered ? '✓' : '□'} ${question.header}`;
1148
+ parts.push(index === this.index
1149
+ ? this.theme.fg('accent', `[${label}]`)
1150
+ : this.theme.fg(answered ? 'success' : 'muted', label));
1151
+ }
1152
+ const submit = `${this.responses.size > 0 ? '✓' : '□'} Submit`;
1153
+ parts.push(this.index === this.questions.length
1154
+ ? this.theme.fg('accent', `[${submit}]`)
1155
+ : this.theme.fg(this.responses.size > 0 ? 'success' : 'muted', submit));
1156
+ parts.push(this.theme.fg('dim', '→'));
1157
+ return parts.join(' ');
1158
+ }
1159
+ renderReview(width) {
1160
+ const border = (text) => this.theme.fg('accent', text);
1161
+ const inner = Math.max(1, width - (this.displayMode === 'overlay' ? BOX_OVERHEAD : 0));
1162
+ const body = [this.theme.fg('accent', this.theme.bold('Review answers')), ''];
1163
+ for (const question of this.questions) {
1164
+ body.push(`${this.theme.fg('muted', `${question.header}:`)} ${this.theme.fg('text', question.question)}`);
1165
+ body.push(` ${this.responses.has(question.id) ? formatResponse(this.responses.get(question.id)) : this.theme.fg('muted', 'Skipped')}`);
1166
+ }
1167
+ body.push('', this.theme.fg('dim', 'Enter submit • unanswered questions are skipped • Tab/←→ navigate • Esc cancel'));
1168
+ const bodyLines = body.map((line) => this.displayMode === 'overlay'
1169
+ ? this.boxLine(line, inner)
1170
+ : truncateToWidth(line, width, '', true));
1171
+ return [
1172
+ this.displayMode === 'overlay'
1173
+ ? new BorderTop(border, 'ask_user', (text) => this.theme.fg('dim', this.theme.bold(text))).render(width)[0]
1174
+ : border('─'.repeat(Math.max(1, width))),
1175
+ ...bodyLines,
1176
+ this.displayMode === 'overlay'
1177
+ ? new BorderBottom(border, `v${VERSION}`, (text) => this.theme.fg('dim', text)).render(width)[0]
1178
+ : border('─'.repeat(Math.max(1, width))),
1179
+ ];
1180
+ }
1181
+ boxLine(line, innerWidth) {
1182
+ const border = (text) => this.theme.fg('accent', text);
1183
+ return `${border(BOX_LEFT)}${truncateToWidth(line, innerWidth, '', true)}${border(BOX_RIGHT)}`;
1184
+ }
1185
+ }
1186
+ async function askQuestionsViaDialogs(ui, questions, timeout, signal) {
1187
+ const answers = [];
1188
+ const deadline = timeout === undefined ? undefined : Date.now() + timeout;
1189
+ for (const question of questions) {
1190
+ if (signal?.aborted)
1191
+ return { answers, cancelled: 'abort' };
1192
+ const remaining = deadline === undefined ? undefined : deadline - Date.now();
1193
+ if (remaining !== undefined && remaining <= 0)
1194
+ return { answers, cancelled: 'timeout' };
1195
+ const response = await raceDialogAbort(askViaDialogs(ui, question, remaining), signal);
1196
+ if (response.aborted)
1197
+ return { answers, cancelled: 'abort' };
1198
+ if (response.value === null && deadline !== undefined && Date.now() >= deadline) {
1199
+ return { answers, cancelled: 'timeout' };
1200
+ }
1201
+ answers.push({
1202
+ questionId: question.id,
1203
+ response: response.value,
1204
+ });
1205
+ }
1206
+ return { answers };
1207
+ }
1208
+ async function raceDialogAbort(operation, signal) {
1209
+ if (!signal)
1210
+ return { aborted: false, value: await operation };
1211
+ if (signal.aborted)
1212
+ return { aborted: true };
1213
+ // Pi dialogs have no abort option, so stop this host flow even if the RPC
1214
+ // client dismisses its outstanding prompt later.
1215
+ let removeListener = () => { };
1216
+ const aborted = new Promise((resolve) => {
1217
+ const onAbort = () => resolve({ aborted: true });
1218
+ signal.addEventListener('abort', onAbort, { once: true });
1219
+ removeListener = () => signal.removeEventListener('abort', onAbort);
1220
+ });
1221
+ try {
1222
+ return await Promise.race([
1223
+ operation.then((value) => ({ aborted: false, value })),
1224
+ aborted,
1225
+ ]);
1226
+ }
1227
+ finally {
1228
+ removeListener();
1229
+ }
1230
+ }
1231
+ async function askViaDialogs(ui, question, timeout) {
1232
+ const dialogOptions = timeout === undefined ? undefined : { timeout };
1233
+ const prompt = question.context
1234
+ ? `${question.question}\n\nContext:\n${question.context}`
1235
+ : question.question;
1236
+ if (question.options.length === 0) {
1237
+ const answer = await ui.input(prompt, 'Type your answer...', dialogOptions);
1238
+ return answer === undefined ? null : freeformResponse(answer);
1239
+ }
1240
+ if (question.allowMultiple) {
1241
+ const options = formatOptions(question.options);
1242
+ const raw = await ui.input(`${prompt}\n\nOptions (select one or more):\n${options}`, 'Type option titles separated by commas...', dialogOptions);
1243
+ if (raw === undefined)
1244
+ return null;
1245
+ const selections = raw.split(',').map((selection) => selection.trim()).filter(Boolean);
1246
+ if (selections.length === 0)
1247
+ return null;
1248
+ if (!question.allowComment)
1249
+ return selectionResponse(selections);
1250
+ const comment = await ui.input(`${prompt}\n\nSelected:\n${selections.map((selection) => `- ${selection}`).join('\n')}`, 'Optional comment (press Enter to skip)...', dialogOptions);
1251
+ return selectionResponse(selections, comment);
1252
+ }
1253
+ const options = question.options.map((option) => option.title);
1254
+ if (question.allowFreeform)
1255
+ options.push(FREEFORM_SENTINEL);
1256
+ const selected = await ui.select(prompt, options, dialogOptions);
1257
+ if (selected === undefined)
1258
+ return null;
1259
+ if (selected === FREEFORM_SENTINEL) {
1260
+ const answer = await ui.input(prompt, 'Type your answer...', dialogOptions);
1261
+ return answer === undefined ? null : freeformResponse(answer);
1262
+ }
1263
+ if (!question.allowComment)
1264
+ return selectionResponse([selected]);
1265
+ const comment = await ui.input(`${prompt}\n\nSelected option:\n- ${selected}`, 'Optional comment (press Enter to skip)...', dialogOptions);
1266
+ return selectionResponse([selected], comment);
1267
+ }
1268
+ function selectionResponse(selections, comment) {
1269
+ const normalizedSelections = selections.map((selection) => selection.trim()).filter(Boolean);
1270
+ if (normalizedSelections.length === 0)
1271
+ return null;
1272
+ const normalizedComment = comment?.trim();
1273
+ return {
1274
+ kind: 'selection',
1275
+ selections: normalizedSelections,
1276
+ ...(normalizedComment ? { comment: normalizedComment } : {}),
1277
+ };
1278
+ }
1279
+ function freeformResponse(text) {
1280
+ const normalized = text.trim();
1281
+ return normalized ? { kind: 'freeform', text: normalized } : null;
1282
+ }
1283
+ function formatOptions(options) {
1284
+ return options.map((option, index) => (`${index + 1}. ${option.title}${option.description ? ` — ${option.description}` : ''}`)).join('\n');
1285
+ }
1286
+ function formatResponse(response) {
1287
+ if (response.kind === 'freeform')
1288
+ return response.text;
1289
+ const selections = response.selections.join(', ');
1290
+ return response.comment ? `${selections} — ${response.comment}` : selections;
1291
+ }
1292
+ export const askUserToolPresentation = {
1293
+ renderCall(args, theme) {
1294
+ const values = args;
1295
+ if (Array.isArray(values.questions) && values.questions.length > 0) {
1296
+ const labels = values.questions.map((question, index) => (question.header || question.question || `Q${index + 1}`));
1297
+ return new Text(`${theme.fg('toolTitle', theme.bold('ask_user '))}${theme.fg('muted', `${values.questions.length} questions`)}\n${theme.fg('dim', ` ${truncateToWidth(labels.join(', '), 80)}`)}`, 0, 0);
1298
+ }
1299
+ const options = Array.isArray(values.options) ? values.options : [];
1300
+ const labels = options.map((option) => normalizeAskUserOption(option)?.title ?? '<invalid>');
1301
+ const optionLine = labels.length > 0
1302
+ ? `\n${theme.fg('dim', ` ${labels.length} option(s): ${labels.join(', ')}`)}`
1303
+ : '';
1304
+ const modes = `${values.allowMultiple ? ' [multi-select]' : ''}${values.allowComment ? ' [optional comment]' : ''}`;
1305
+ return new Text(`${theme.fg('toolTitle', theme.bold('ask_user '))}${theme.fg('muted', String(values.question ?? ''))}${optionLine}${theme.fg('dim', modes)}`, 0, 0);
1306
+ },
1307
+ renderResult(result, options, theme) {
1308
+ const details = result.details;
1309
+ if (details && 'error' in details)
1310
+ return new Text(theme.fg('error', `✗ ${details.error}`), 0, 0);
1311
+ if (options.isPartial) {
1312
+ const waiting = result.content
1313
+ .filter((part) => part.type === 'text')
1314
+ .map((part) => part.text)
1315
+ .join('\n') || 'Waiting for user input...';
1316
+ return new Text(theme.fg('muted', waiting), 0, 0);
1317
+ }
1318
+ if (!details)
1319
+ return new Text(theme.fg('warning', 'No result'), 0, 0);
1320
+ if (details.status === 'cancelled')
1321
+ return new Text(theme.fg('warning', details.message ?? 'Cancelled'), 0, 0);
1322
+ if (details.status === 'deferred') {
1323
+ const interaction = details.interactionId ? ` (interaction: ${details.interactionId})` : '';
1324
+ return new Text(theme.fg('muted', `${details.message ?? 'Question sent'}${interaction}`), 0, 0);
1325
+ }
1326
+ if (details.status === 'pending')
1327
+ return new Text(theme.fg('muted', 'Waiting for user input...'), 0, 0);
1328
+ if (details.kind === 'single') {
1329
+ if (!details.response)
1330
+ return new Text(theme.fg('warning', 'Skipped'), 0, 0);
1331
+ let text = `${theme.fg('success', '✓ ')}${theme.fg('accent', formatResponse(details.response))}`;
1332
+ if (options.expanded) {
1333
+ text += `\n${theme.fg('dim', `Q: ${details.question.question}`)}`;
1334
+ if (details.question.context)
1335
+ text += `\n${theme.fg('dim', details.question.context)}`;
1336
+ }
1337
+ return new Text(text, 0, 0);
1338
+ }
1339
+ const lines = details.questions.map((question) => {
1340
+ const response = details.responses[question.id];
1341
+ return response
1342
+ ? `${theme.fg('success', '✓ ')}${theme.fg('accent', question.header)}: ${formatResponse(response)}`
1343
+ : `${theme.fg('muted', '○ ')}${theme.fg('muted', question.header)}: skipped`;
1344
+ });
1345
+ return new Text(lines.join('\n'), 0, 0);
1346
+ },
1347
+ };
1348
+ //# sourceMappingURL=ask-user.js.map