indusagi-coding-agent 0.1.46 → 0.1.48

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 (452) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/command-line/args.js +1 -1
  3. package/dist/command-line/args.js.map +1 -1
  4. package/dist/command-line/login-handler.d.ts.map +1 -1
  5. package/dist/command-line/login-handler.js +3 -1
  6. package/dist/command-line/login-handler.js.map +1 -1
  7. package/dist/command-line/session-picker.d.ts.map +1 -1
  8. package/dist/command-line/session-picker.js +26 -48
  9. package/dist/command-line/session-picker.js.map +1 -1
  10. package/dist/config.js +1 -1
  11. package/dist/config.js.map +1 -1
  12. package/dist/helpers/open-auth-url.d.ts +2 -0
  13. package/dist/helpers/open-auth-url.d.ts.map +1 -0
  14. package/dist/helpers/open-auth-url.js +54 -0
  15. package/dist/helpers/open-auth-url.js.map +1 -0
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +2 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/interfaces/index.d.ts +1 -1
  21. package/dist/interfaces/index.d.ts.map +1 -1
  22. package/dist/interfaces/index.js +1 -1
  23. package/dist/interfaces/index.js.map +1 -1
  24. package/dist/interfaces/react-ink/adapters/command-router.d.ts +19 -0
  25. package/dist/interfaces/react-ink/adapters/command-router.d.ts.map +1 -0
  26. package/dist/interfaces/react-ink/adapters/command-router.js +674 -0
  27. package/dist/interfaces/react-ink/adapters/command-router.js.map +1 -0
  28. package/dist/interfaces/react-ink/adapters/session-events.d.ts +5 -0
  29. package/dist/interfaces/react-ink/adapters/session-events.d.ts.map +1 -0
  30. package/dist/interfaces/react-ink/adapters/session-events.js +76 -0
  31. package/dist/interfaces/react-ink/adapters/session-events.js.map +1 -0
  32. package/dist/interfaces/react-ink/adapters/session-history.d.ts +14 -0
  33. package/dist/interfaces/react-ink/adapters/session-history.d.ts.map +1 -0
  34. package/dist/interfaces/react-ink/adapters/session-history.js +83 -0
  35. package/dist/interfaces/react-ink/adapters/session-history.js.map +1 -0
  36. package/dist/interfaces/react-ink/adapters/tool-state.d.ts +4 -0
  37. package/dist/interfaces/react-ink/adapters/tool-state.d.ts.map +1 -0
  38. package/dist/interfaces/react-ink/adapters/tool-state.js +67 -0
  39. package/dist/interfaces/react-ink/adapters/tool-state.js.map +1 -0
  40. package/dist/interfaces/react-ink/components/AppShell.d.ts +17 -0
  41. package/dist/interfaces/react-ink/components/AppShell.d.ts.map +1 -0
  42. package/dist/interfaces/react-ink/components/AppShell.js +1465 -0
  43. package/dist/interfaces/react-ink/components/AppShell.js.map +1 -0
  44. package/dist/interfaces/react-ink/components/ChangelogBlock.d.ts +9 -0
  45. package/dist/interfaces/react-ink/components/ChangelogBlock.d.ts.map +1 -0
  46. package/dist/interfaces/react-ink/components/ChangelogBlock.js +58 -0
  47. package/dist/interfaces/react-ink/components/ChangelogBlock.js.map +1 -0
  48. package/dist/interfaces/react-ink/components/DisplayBlockView.d.ts +9 -0
  49. package/dist/interfaces/react-ink/components/DisplayBlockView.d.ts.map +1 -0
  50. package/dist/interfaces/react-ink/components/DisplayBlockView.js +11 -0
  51. package/dist/interfaces/react-ink/components/DisplayBlockView.js.map +1 -0
  52. package/dist/interfaces/react-ink/components/Footer.d.ts +11 -0
  53. package/dist/interfaces/react-ink/components/Footer.d.ts.map +1 -0
  54. package/dist/interfaces/react-ink/components/Footer.js +18 -0
  55. package/dist/interfaces/react-ink/components/Footer.js.map +1 -0
  56. package/dist/interfaces/react-ink/components/Header.d.ts +14 -0
  57. package/dist/interfaces/react-ink/components/Header.d.ts.map +1 -0
  58. package/dist/interfaces/react-ink/components/Header.js +24 -0
  59. package/dist/interfaces/react-ink/components/Header.js.map +1 -0
  60. package/dist/interfaces/react-ink/components/MessageList.d.ts +14 -0
  61. package/dist/interfaces/react-ink/components/MessageList.d.ts.map +1 -0
  62. package/dist/interfaces/react-ink/components/MessageList.js +43 -0
  63. package/dist/interfaces/react-ink/components/MessageList.js.map +1 -0
  64. package/dist/interfaces/react-ink/components/MessageRow.d.ts +13 -0
  65. package/dist/interfaces/react-ink/components/MessageRow.d.ts.map +1 -0
  66. package/dist/interfaces/react-ink/components/MessageRow.js +35 -0
  67. package/dist/interfaces/react-ink/components/MessageRow.js.map +1 -0
  68. package/dist/interfaces/react-ink/components/PromptInput.d.ts +35 -0
  69. package/dist/interfaces/react-ink/components/PromptInput.d.ts.map +1 -0
  70. package/dist/interfaces/react-ink/components/PromptInput.js +319 -0
  71. package/dist/interfaces/react-ink/components/PromptInput.js.map +1 -0
  72. package/dist/interfaces/react-ink/components/StartupDiagnosticsBlock.d.ts +9 -0
  73. package/dist/interfaces/react-ink/components/StartupDiagnosticsBlock.d.ts.map +1 -0
  74. package/dist/interfaces/react-ink/components/StartupDiagnosticsBlock.js +14 -0
  75. package/dist/interfaces/react-ink/components/StartupDiagnosticsBlock.js.map +1 -0
  76. package/dist/interfaces/react-ink/components/StatusLine.d.ts +10 -0
  77. package/dist/interfaces/react-ink/components/StatusLine.d.ts.map +1 -0
  78. package/dist/interfaces/react-ink/components/StatusLine.js +39 -0
  79. package/dist/interfaces/react-ink/components/StatusLine.js.map +1 -0
  80. package/dist/interfaces/react-ink/components/TaskPanel.d.ts +10 -0
  81. package/dist/interfaces/react-ink/components/TaskPanel.d.ts.map +1 -0
  82. package/dist/interfaces/react-ink/components/TaskPanel.js +23 -0
  83. package/dist/interfaces/react-ink/components/TaskPanel.js.map +1 -0
  84. package/dist/interfaces/react-ink/components/ToolEventBlock.d.ts +18 -0
  85. package/dist/interfaces/react-ink/components/ToolEventBlock.d.ts.map +1 -0
  86. package/dist/interfaces/react-ink/components/ToolEventBlock.js +61 -0
  87. package/dist/interfaces/react-ink/components/ToolEventBlock.js.map +1 -0
  88. package/dist/interfaces/react-ink/components/dialogs/DialogFrame.d.ts +9 -0
  89. package/dist/interfaces/react-ink/components/dialogs/DialogFrame.d.ts.map +1 -0
  90. package/dist/interfaces/react-ink/components/dialogs/DialogFrame.js +6 -0
  91. package/dist/interfaces/react-ink/components/dialogs/DialogFrame.js.map +1 -0
  92. package/dist/interfaces/react-ink/components/dialogs/LoginDialog.d.ts +15 -0
  93. package/dist/interfaces/react-ink/components/dialogs/LoginDialog.d.ts.map +1 -0
  94. package/dist/interfaces/react-ink/components/dialogs/LoginDialog.js +10 -0
  95. package/dist/interfaces/react-ink/components/dialogs/LoginDialog.js.map +1 -0
  96. package/dist/interfaces/react-ink/components/dialogs/ModelDialog.d.ts +10 -0
  97. package/dist/interfaces/react-ink/components/dialogs/ModelDialog.d.ts.map +1 -0
  98. package/dist/interfaces/react-ink/components/dialogs/ModelDialog.js +64 -0
  99. package/dist/interfaces/react-ink/components/dialogs/ModelDialog.js.map +1 -0
  100. package/dist/interfaces/react-ink/components/dialogs/OAuthDialog.d.ts +10 -0
  101. package/dist/interfaces/react-ink/components/dialogs/OAuthDialog.d.ts.map +1 -0
  102. package/dist/interfaces/react-ink/components/dialogs/OAuthDialog.js +24 -0
  103. package/dist/interfaces/react-ink/components/dialogs/OAuthDialog.js.map +1 -0
  104. package/dist/interfaces/react-ink/components/dialogs/ScopedModelsDialog.d.ts +10 -0
  105. package/dist/interfaces/react-ink/components/dialogs/ScopedModelsDialog.d.ts.map +1 -0
  106. package/dist/interfaces/react-ink/components/dialogs/ScopedModelsDialog.js +95 -0
  107. package/dist/interfaces/react-ink/components/dialogs/ScopedModelsDialog.js.map +1 -0
  108. package/dist/interfaces/react-ink/components/dialogs/SelectableDialog.d.ts +17 -0
  109. package/dist/interfaces/react-ink/components/dialogs/SelectableDialog.d.ts.map +1 -0
  110. package/dist/interfaces/react-ink/components/dialogs/SelectableDialog.js +66 -0
  111. package/dist/interfaces/react-ink/components/dialogs/SelectableDialog.js.map +1 -0
  112. package/dist/interfaces/react-ink/components/dialogs/SessionDialog.d.ts +11 -0
  113. package/dist/interfaces/react-ink/components/dialogs/SessionDialog.d.ts.map +1 -0
  114. package/dist/interfaces/react-ink/components/dialogs/SessionDialog.js +10 -0
  115. package/dist/interfaces/react-ink/components/dialogs/SessionDialog.js.map +1 -0
  116. package/dist/interfaces/react-ink/components/dialogs/SettingsDialog.d.ts +15 -0
  117. package/dist/interfaces/react-ink/components/dialogs/SettingsDialog.d.ts.map +1 -0
  118. package/dist/interfaces/react-ink/components/dialogs/SettingsDialog.js +79 -0
  119. package/dist/interfaces/react-ink/components/dialogs/SettingsDialog.js.map +1 -0
  120. package/dist/interfaces/react-ink/components/dialogs/StartupSessionPicker.d.ts +10 -0
  121. package/dist/interfaces/react-ink/components/dialogs/StartupSessionPicker.d.ts.map +1 -0
  122. package/dist/interfaces/react-ink/components/dialogs/StartupSessionPicker.js +99 -0
  123. package/dist/interfaces/react-ink/components/dialogs/StartupSessionPicker.js.map +1 -0
  124. package/dist/interfaces/react-ink/components/dialogs/ThemeDialog.d.ts +8 -0
  125. package/dist/interfaces/react-ink/components/dialogs/ThemeDialog.d.ts.map +1 -0
  126. package/dist/interfaces/react-ink/components/dialogs/ThemeDialog.js +7 -0
  127. package/dist/interfaces/react-ink/components/dialogs/ThemeDialog.js.map +1 -0
  128. package/dist/interfaces/react-ink/components/dialogs/TreeDialog.d.ts +9 -0
  129. package/dist/interfaces/react-ink/components/dialogs/TreeDialog.d.ts.map +1 -0
  130. package/dist/interfaces/react-ink/components/dialogs/TreeDialog.js +7 -0
  131. package/dist/interfaces/react-ink/components/dialogs/TreeDialog.js.map +1 -0
  132. package/dist/interfaces/react-ink/components/dialogs/UserMessageDialog.d.ts +9 -0
  133. package/dist/interfaces/react-ink/components/dialogs/UserMessageDialog.d.ts.map +1 -0
  134. package/dist/interfaces/react-ink/components/dialogs/UserMessageDialog.js +7 -0
  135. package/dist/interfaces/react-ink/components/dialogs/UserMessageDialog.js.map +1 -0
  136. package/dist/interfaces/react-ink/components/extensions/ExtensionComponentHost.d.ts +30 -0
  137. package/dist/interfaces/react-ink/components/extensions/ExtensionComponentHost.d.ts.map +1 -0
  138. package/dist/interfaces/react-ink/components/extensions/ExtensionComponentHost.js +106 -0
  139. package/dist/interfaces/react-ink/components/extensions/ExtensionComponentHost.js.map +1 -0
  140. package/dist/interfaces/react-ink/components/extensions/ExtensionDialogs.d.ts +20 -0
  141. package/dist/interfaces/react-ink/components/extensions/ExtensionDialogs.d.ts.map +1 -0
  142. package/dist/interfaces/react-ink/components/extensions/ExtensionDialogs.js +144 -0
  143. package/dist/interfaces/react-ink/components/extensions/ExtensionDialogs.js.map +1 -0
  144. package/dist/interfaces/react-ink/components/messages/AssistantMessage.d.ts +12 -0
  145. package/dist/interfaces/react-ink/components/messages/AssistantMessage.d.ts.map +1 -0
  146. package/dist/interfaces/react-ink/components/messages/AssistantMessage.js +20 -0
  147. package/dist/interfaces/react-ink/components/messages/AssistantMessage.js.map +1 -0
  148. package/dist/interfaces/react-ink/components/messages/BashMessage.d.ts +9 -0
  149. package/dist/interfaces/react-ink/components/messages/BashMessage.d.ts.map +1 -0
  150. package/dist/interfaces/react-ink/components/messages/BashMessage.js +11 -0
  151. package/dist/interfaces/react-ink/components/messages/BashMessage.js.map +1 -0
  152. package/dist/interfaces/react-ink/components/messages/BranchSummaryMessage.d.ts +9 -0
  153. package/dist/interfaces/react-ink/components/messages/BranchSummaryMessage.d.ts.map +1 -0
  154. package/dist/interfaces/react-ink/components/messages/BranchSummaryMessage.js +6 -0
  155. package/dist/interfaces/react-ink/components/messages/BranchSummaryMessage.js.map +1 -0
  156. package/dist/interfaces/react-ink/components/messages/CompactionMessage.d.ts +9 -0
  157. package/dist/interfaces/react-ink/components/messages/CompactionMessage.d.ts.map +1 -0
  158. package/dist/interfaces/react-ink/components/messages/CompactionMessage.js +6 -0
  159. package/dist/interfaces/react-ink/components/messages/CompactionMessage.js.map +1 -0
  160. package/dist/interfaces/react-ink/components/messages/CustomMessage.d.ts +10 -0
  161. package/dist/interfaces/react-ink/components/messages/CustomMessage.d.ts.map +1 -0
  162. package/dist/interfaces/react-ink/components/messages/CustomMessage.js +9 -0
  163. package/dist/interfaces/react-ink/components/messages/CustomMessage.js.map +1 -0
  164. package/dist/interfaces/react-ink/components/messages/SkillInvocationMessage.d.ts +8 -0
  165. package/dist/interfaces/react-ink/components/messages/SkillInvocationMessage.d.ts.map +1 -0
  166. package/dist/interfaces/react-ink/components/messages/SkillInvocationMessage.js +10 -0
  167. package/dist/interfaces/react-ink/components/messages/SkillInvocationMessage.js.map +1 -0
  168. package/dist/interfaces/react-ink/components/messages/ToolCallMessage.d.ts +9 -0
  169. package/dist/interfaces/react-ink/components/messages/ToolCallMessage.d.ts.map +1 -0
  170. package/dist/interfaces/react-ink/components/messages/ToolCallMessage.js +8 -0
  171. package/dist/interfaces/react-ink/components/messages/ToolCallMessage.js.map +1 -0
  172. package/dist/interfaces/react-ink/components/messages/ToolResultBlock.d.ts +12 -0
  173. package/dist/interfaces/react-ink/components/messages/ToolResultBlock.d.ts.map +1 -0
  174. package/dist/interfaces/react-ink/components/messages/ToolResultBlock.js +8 -0
  175. package/dist/interfaces/react-ink/components/messages/ToolResultBlock.js.map +1 -0
  176. package/dist/interfaces/react-ink/components/messages/UserMessage.d.ts +10 -0
  177. package/dist/interfaces/react-ink/components/messages/UserMessage.d.ts.map +1 -0
  178. package/dist/interfaces/react-ink/components/messages/UserMessage.js +7 -0
  179. package/dist/interfaces/react-ink/components/messages/UserMessage.js.map +1 -0
  180. package/dist/interfaces/react-ink/hooks/use-agent-session.d.ts +8 -0
  181. package/dist/interfaces/react-ink/hooks/use-agent-session.d.ts.map +1 -0
  182. package/dist/interfaces/react-ink/hooks/use-agent-session.js +34 -0
  183. package/dist/interfaces/react-ink/hooks/use-agent-session.js.map +1 -0
  184. package/dist/interfaces/react-ink/hooks/use-app-keybindings.d.ts +12 -0
  185. package/dist/interfaces/react-ink/hooks/use-app-keybindings.d.ts.map +1 -0
  186. package/dist/interfaces/react-ink/hooks/use-app-keybindings.js +17 -0
  187. package/dist/interfaces/react-ink/hooks/use-app-keybindings.js.map +1 -0
  188. package/dist/interfaces/react-ink/hooks/use-footer-data.d.ts +7 -0
  189. package/dist/interfaces/react-ink/hooks/use-footer-data.d.ts.map +1 -0
  190. package/dist/interfaces/react-ink/hooks/use-footer-data.js +17 -0
  191. package/dist/interfaces/react-ink/hooks/use-footer-data.js.map +1 -0
  192. package/dist/interfaces/react-ink/hooks/use-prompt-submit.d.ts +17 -0
  193. package/dist/interfaces/react-ink/hooks/use-prompt-submit.d.ts.map +1 -0
  194. package/dist/interfaces/react-ink/hooks/use-prompt-submit.js +66 -0
  195. package/dist/interfaces/react-ink/hooks/use-prompt-submit.js.map +1 -0
  196. package/dist/interfaces/react-ink/hooks/use-session-history.d.ts +8 -0
  197. package/dist/interfaces/react-ink/hooks/use-session-history.d.ts.map +1 -0
  198. package/dist/interfaces/react-ink/hooks/use-session-history.js +8 -0
  199. package/dist/interfaces/react-ink/hooks/use-session-history.js.map +1 -0
  200. package/dist/interfaces/react-ink/index.d.ts +8 -0
  201. package/dist/interfaces/react-ink/index.d.ts.map +1 -0
  202. package/dist/interfaces/react-ink/index.js +8 -0
  203. package/dist/interfaces/react-ink/index.js.map +1 -0
  204. package/dist/interfaces/react-ink/interactive-mode.d.ts +24 -0
  205. package/dist/interfaces/react-ink/interactive-mode.d.ts.map +1 -0
  206. package/dist/interfaces/react-ink/interactive-mode.js +57 -0
  207. package/dist/interfaces/react-ink/interactive-mode.js.map +1 -0
  208. package/dist/interfaces/react-ink/render-root.d.ts +19 -0
  209. package/dist/interfaces/react-ink/render-root.d.ts.map +1 -0
  210. package/dist/interfaces/react-ink/render-root.js +6 -0
  211. package/dist/interfaces/react-ink/render-root.js.map +1 -0
  212. package/dist/interfaces/react-ink/state/reducer.d.ts +51 -0
  213. package/dist/interfaces/react-ink/state/reducer.d.ts.map +1 -0
  214. package/dist/interfaces/react-ink/state/reducer.js +122 -0
  215. package/dist/interfaces/react-ink/state/reducer.js.map +1 -0
  216. package/dist/interfaces/react-ink/state/store.d.ts +4 -0
  217. package/dist/interfaces/react-ink/state/store.d.ts.map +1 -0
  218. package/dist/interfaces/react-ink/state/store.js +5 -0
  219. package/dist/interfaces/react-ink/state/store.js.map +1 -0
  220. package/dist/interfaces/react-ink/state/ui-state.d.ts +5 -0
  221. package/dist/interfaces/react-ink/state/ui-state.d.ts.map +1 -0
  222. package/dist/interfaces/react-ink/state/ui-state.js +20 -0
  223. package/dist/interfaces/react-ink/state/ui-state.js.map +1 -0
  224. package/dist/interfaces/react-ink/theme-adapter.d.ts +4 -0
  225. package/dist/interfaces/react-ink/theme-adapter.d.ts.map +1 -0
  226. package/dist/interfaces/react-ink/theme-adapter.js +15 -0
  227. package/dist/interfaces/react-ink/theme-adapter.js.map +1 -0
  228. package/dist/interfaces/react-ink/types.d.ts +51 -0
  229. package/dist/interfaces/react-ink/types.d.ts.map +1 -0
  230. package/dist/interfaces/react-ink/types.js +2 -0
  231. package/dist/interfaces/react-ink/types.js.map +1 -0
  232. package/dist/interfaces/react-ink/utils/changelog.d.ts +7 -0
  233. package/dist/interfaces/react-ink/utils/changelog.d.ts.map +1 -0
  234. package/dist/interfaces/react-ink/utils/changelog.js +40 -0
  235. package/dist/interfaces/react-ink/utils/changelog.js.map +1 -0
  236. package/dist/interfaces/react-ink/utils/key-data.d.ts +22 -0
  237. package/dist/interfaces/react-ink/utils/key-data.d.ts.map +1 -0
  238. package/dist/interfaces/react-ink/utils/key-data.js +123 -0
  239. package/dist/interfaces/react-ink/utils/key-data.js.map +1 -0
  240. package/dist/interfaces/react-ink/utils/message-groups.d.ts +26 -0
  241. package/dist/interfaces/react-ink/utils/message-groups.d.ts.map +1 -0
  242. package/dist/interfaces/react-ink/utils/message-groups.js +230 -0
  243. package/dist/interfaces/react-ink/utils/message-groups.js.map +1 -0
  244. package/dist/interfaces/react-ink/utils/prompt-autocomplete.d.ts +20 -0
  245. package/dist/interfaces/react-ink/utils/prompt-autocomplete.d.ts.map +1 -0
  246. package/dist/interfaces/react-ink/utils/prompt-autocomplete.js +46 -0
  247. package/dist/interfaces/react-ink/utils/prompt-autocomplete.js.map +1 -0
  248. package/dist/interfaces/react-ink/utils/selection-dialog.d.ts +3 -0
  249. package/dist/interfaces/react-ink/utils/selection-dialog.d.ts.map +1 -0
  250. package/dist/interfaces/react-ink/utils/selection-dialog.js +18 -0
  251. package/dist/interfaces/react-ink/utils/selection-dialog.js.map +1 -0
  252. package/dist/interfaces/react-ink/utils/session-actions.d.ts +10 -0
  253. package/dist/interfaces/react-ink/utils/session-actions.d.ts.map +1 -0
  254. package/dist/interfaces/react-ink/utils/session-actions.js +66 -0
  255. package/dist/interfaces/react-ink/utils/session-actions.js.map +1 -0
  256. package/dist/interfaces/react-ink/utils/slash-commands.d.ts +10 -0
  257. package/dist/interfaces/react-ink/utils/slash-commands.d.ts.map +1 -0
  258. package/dist/interfaces/react-ink/utils/slash-commands.js +111 -0
  259. package/dist/interfaces/react-ink/utils/slash-commands.js.map +1 -0
  260. package/dist/interfaces/react-ink/utils/startup-diagnostics.d.ts +7 -0
  261. package/dist/interfaces/react-ink/utils/startup-diagnostics.d.ts.map +1 -0
  262. package/dist/interfaces/react-ink/utils/startup-diagnostics.js +111 -0
  263. package/dist/interfaces/react-ink/utils/startup-diagnostics.js.map +1 -0
  264. package/dist/interfaces/react-ink/utils/tool-display.d.ts +22 -0
  265. package/dist/interfaces/react-ink/utils/tool-display.d.ts.map +1 -0
  266. package/dist/interfaces/react-ink/utils/tool-display.js +349 -0
  267. package/dist/interfaces/react-ink/utils/tool-display.js.map +1 -0
  268. package/dist/interfaces/service-api/rpc-mode.js +1 -1
  269. package/dist/interfaces/service-api/rpc-mode.js.map +1 -1
  270. package/dist/interfaces/{terminal-ui/theme → theme}/dark.json +1 -1
  271. package/dist/interfaces/{terminal-ui/theme → theme}/light.json +1 -1
  272. package/dist/interfaces/theme/theme.d.ts.map +1 -0
  273. package/dist/interfaces/{terminal-ui/theme → theme}/theme.js +1 -1
  274. package/dist/interfaces/theme/theme.js.map +1 -0
  275. package/dist/main.js +1 -1
  276. package/dist/main.js.map +1 -1
  277. package/dist/runtime/agent-session.js +1 -1
  278. package/dist/runtime/agent-session.js.map +1 -1
  279. package/dist/runtime/html-export/index.js +1 -1
  280. package/dist/runtime/html-export/index.js.map +1 -1
  281. package/dist/runtime/html-export/index.ts +1 -2
  282. package/dist/runtime/html-export/tool-renderer.d.ts +1 -1
  283. package/dist/runtime/html-export/tool-renderer.d.ts.map +1 -1
  284. package/dist/runtime/html-export/tool-renderer.ts +1 -1
  285. package/dist/runtime/plugins/runner.js +1 -1
  286. package/dist/runtime/plugins/runner.js.map +1 -1
  287. package/dist/runtime/plugins/types.d.ts +1 -1
  288. package/dist/runtime/plugins/types.d.ts.map +1 -1
  289. package/dist/runtime/resource-loader.d.ts +1 -1
  290. package/dist/runtime/resource-loader.d.ts.map +1 -1
  291. package/dist/runtime/resource-loader.js +1 -1
  292. package/dist/runtime/resource-loader.js.map +1 -1
  293. package/dist/runtime/system-prompt.js +1 -1
  294. package/dist/runtime/system-prompt.js.map +1 -1
  295. package/dist/runtime/tooling/composio-compat.d.ts +169 -0
  296. package/dist/runtime/tooling/composio-compat.d.ts.map +1 -0
  297. package/dist/runtime/tooling/composio-compat.js +163 -0
  298. package/dist/runtime/tooling/composio-compat.js.map +1 -0
  299. package/dist/runtime/tooling/index.d.ts +12 -25
  300. package/dist/runtime/tooling/index.d.ts.map +1 -1
  301. package/dist/runtime/tooling/index.js +3 -3
  302. package/dist/runtime/tooling/index.js.map +1 -1
  303. package/guides/INDUSVX_OBSERVE_FULL_INTEGRATION_REPORT.md +2 -2
  304. package/package.json +9 -5
  305. package/dist/interfaces/induscode-ui-delegate.d.ts +0 -3
  306. package/dist/interfaces/induscode-ui-delegate.d.ts.map +0 -1
  307. package/dist/interfaces/induscode-ui-delegate.js +0 -148
  308. package/dist/interfaces/induscode-ui-delegate.js.map +0 -1
  309. package/dist/interfaces/terminal-ui/components/armin.d.ts +0 -19
  310. package/dist/interfaces/terminal-ui/components/armin.d.ts.map +0 -1
  311. package/dist/interfaces/terminal-ui/components/armin.js +0 -280
  312. package/dist/interfaces/terminal-ui/components/armin.js.map +0 -1
  313. package/dist/interfaces/terminal-ui/components/assistant-message.d.ts +0 -13
  314. package/dist/interfaces/terminal-ui/components/assistant-message.d.ts.map +0 -1
  315. package/dist/interfaces/terminal-ui/components/assistant-message.js +0 -95
  316. package/dist/interfaces/terminal-ui/components/assistant-message.js.map +0 -1
  317. package/dist/interfaces/terminal-ui/components/bash-execution.d.ts +0 -24
  318. package/dist/interfaces/terminal-ui/components/bash-execution.d.ts.map +0 -1
  319. package/dist/interfaces/terminal-ui/components/bash-execution.js +0 -135
  320. package/dist/interfaces/terminal-ui/components/bash-execution.js.map +0 -1
  321. package/dist/interfaces/terminal-ui/components/bordered-loader.d.ts +0 -14
  322. package/dist/interfaces/terminal-ui/components/bordered-loader.d.ts.map +0 -1
  323. package/dist/interfaces/terminal-ui/components/bordered-loader.js +0 -78
  324. package/dist/interfaces/terminal-ui/components/bordered-loader.js.map +0 -1
  325. package/dist/interfaces/terminal-ui/components/branch-summary-message.d.ts +0 -16
  326. package/dist/interfaces/terminal-ui/components/branch-summary-message.d.ts.map +0 -1
  327. package/dist/interfaces/terminal-ui/components/branch-summary-message.js +0 -55
  328. package/dist/interfaces/terminal-ui/components/branch-summary-message.js.map +0 -1
  329. package/dist/interfaces/terminal-ui/components/compaction-summary-message.d.ts +0 -16
  330. package/dist/interfaces/terminal-ui/components/compaction-summary-message.d.ts.map +0 -1
  331. package/dist/interfaces/terminal-ui/components/compaction-summary-message.js +0 -60
  332. package/dist/interfaces/terminal-ui/components/compaction-summary-message.js.map +0 -1
  333. package/dist/interfaces/terminal-ui/components/config-selector.d.ts +0 -71
  334. package/dist/interfaces/terminal-ui/components/config-selector.d.ts.map +0 -1
  335. package/dist/interfaces/terminal-ui/components/config-selector.js +0 -459
  336. package/dist/interfaces/terminal-ui/components/config-selector.js.map +0 -1
  337. package/dist/interfaces/terminal-ui/components/countdown-timer.d.ts +0 -10
  338. package/dist/interfaces/terminal-ui/components/countdown-timer.d.ts.map +0 -1
  339. package/dist/interfaces/terminal-ui/components/countdown-timer.js +0 -42
  340. package/dist/interfaces/terminal-ui/components/countdown-timer.js.map +0 -1
  341. package/dist/interfaces/terminal-ui/components/custom-editor.d.ts +0 -17
  342. package/dist/interfaces/terminal-ui/components/custom-editor.d.ts.map +0 -1
  343. package/dist/interfaces/terminal-ui/components/custom-editor.js +0 -72
  344. package/dist/interfaces/terminal-ui/components/custom-editor.js.map +0 -1
  345. package/dist/interfaces/terminal-ui/components/custom-message.d.ts +0 -19
  346. package/dist/interfaces/terminal-ui/components/custom-message.d.ts.map +0 -1
  347. package/dist/interfaces/terminal-ui/components/custom-message.js +0 -71
  348. package/dist/interfaces/terminal-ui/components/custom-message.js.map +0 -1
  349. package/dist/interfaces/terminal-ui/components/diff.d.ts +0 -9
  350. package/dist/interfaces/terminal-ui/components/diff.d.ts.map +0 -1
  351. package/dist/interfaces/terminal-ui/components/diff.js +0 -126
  352. package/dist/interfaces/terminal-ui/components/diff.js.map +0 -1
  353. package/dist/interfaces/terminal-ui/components/dynamic-border.d.ts +0 -20
  354. package/dist/interfaces/terminal-ui/components/dynamic-border.d.ts.map +0 -1
  355. package/dist/interfaces/terminal-ui/components/dynamic-border.js +0 -40
  356. package/dist/interfaces/terminal-ui/components/dynamic-border.js.map +0 -1
  357. package/dist/interfaces/terminal-ui/components/extension-editor.d.ts +0 -13
  358. package/dist/interfaces/terminal-ui/components/extension-editor.d.ts.map +0 -1
  359. package/dist/interfaces/terminal-ui/components/extension-editor.js +0 -94
  360. package/dist/interfaces/terminal-ui/components/extension-editor.js.map +0 -1
  361. package/dist/interfaces/terminal-ui/components/extension-input.d.ts +0 -18
  362. package/dist/interfaces/terminal-ui/components/extension-input.d.ts.map +0 -1
  363. package/dist/interfaces/terminal-ui/components/extension-input.js +0 -72
  364. package/dist/interfaces/terminal-ui/components/extension-input.js.map +0 -1
  365. package/dist/interfaces/terminal-ui/components/extension-selector.d.ts +0 -19
  366. package/dist/interfaces/terminal-ui/components/extension-selector.d.ts.map +0 -1
  367. package/dist/interfaces/terminal-ui/components/extension-selector.js +0 -93
  368. package/dist/interfaces/terminal-ui/components/extension-selector.js.map +0 -1
  369. package/dist/interfaces/terminal-ui/components/footer.d.ts +0 -17
  370. package/dist/interfaces/terminal-ui/components/footer.d.ts.map +0 -1
  371. package/dist/interfaces/terminal-ui/components/footer.js +0 -160
  372. package/dist/interfaces/terminal-ui/components/footer.js.map +0 -1
  373. package/dist/interfaces/terminal-ui/components/index.d.ts +0 -80
  374. package/dist/interfaces/terminal-ui/components/index.d.ts.map +0 -1
  375. package/dist/interfaces/terminal-ui/components/index.js +0 -74
  376. package/dist/interfaces/terminal-ui/components/index.js.map +0 -1
  377. package/dist/interfaces/terminal-ui/components/keybinding-hints.d.ts +0 -23
  378. package/dist/interfaces/terminal-ui/components/keybinding-hints.d.ts.map +0 -1
  379. package/dist/interfaces/terminal-ui/components/keybinding-hints.js +0 -54
  380. package/dist/interfaces/terminal-ui/components/keybinding-hints.js.map +0 -1
  381. package/dist/interfaces/terminal-ui/components/login-dialog.d.ts +0 -29
  382. package/dist/interfaces/terminal-ui/components/login-dialog.d.ts.map +0 -1
  383. package/dist/interfaces/terminal-ui/components/login-dialog.js +0 -143
  384. package/dist/interfaces/terminal-ui/components/login-dialog.js.map +0 -1
  385. package/dist/interfaces/terminal-ui/components/model-selector.d.ts +0 -43
  386. package/dist/interfaces/terminal-ui/components/model-selector.d.ts.map +0 -1
  387. package/dist/interfaces/terminal-ui/components/model-selector.js +0 -201
  388. package/dist/interfaces/terminal-ui/components/model-selector.js.map +0 -1
  389. package/dist/interfaces/terminal-ui/components/oauth-selector.d.ts +0 -75
  390. package/dist/interfaces/terminal-ui/components/oauth-selector.d.ts.map +0 -1
  391. package/dist/interfaces/terminal-ui/components/oauth-selector.js +0 -374
  392. package/dist/interfaces/terminal-ui/components/oauth-selector.js.map +0 -1
  393. package/dist/interfaces/terminal-ui/components/scoped-models-selector.d.ts +0 -39
  394. package/dist/interfaces/terminal-ui/components/scoped-models-selector.d.ts.map +0 -1
  395. package/dist/interfaces/terminal-ui/components/scoped-models-selector.js +0 -242
  396. package/dist/interfaces/terminal-ui/components/scoped-models-selector.js.map +0 -1
  397. package/dist/interfaces/terminal-ui/components/session-selector-search.d.ts +0 -21
  398. package/dist/interfaces/terminal-ui/components/session-selector-search.d.ts.map +0 -1
  399. package/dist/interfaces/terminal-ui/components/session-selector-search.js +0 -135
  400. package/dist/interfaces/terminal-ui/components/session-selector-search.js.map +0 -1
  401. package/dist/interfaces/terminal-ui/components/session-selector.d.ts +0 -85
  402. package/dist/interfaces/terminal-ui/components/session-selector.d.ts.map +0 -1
  403. package/dist/interfaces/terminal-ui/components/session-selector.js +0 -688
  404. package/dist/interfaces/terminal-ui/components/session-selector.js.map +0 -1
  405. package/dist/interfaces/terminal-ui/components/settings-selector.d.ts +0 -49
  406. package/dist/interfaces/terminal-ui/components/settings-selector.d.ts.map +0 -1
  407. package/dist/interfaces/terminal-ui/components/settings-selector.js +0 -159
  408. package/dist/interfaces/terminal-ui/components/settings-selector.js.map +0 -1
  409. package/dist/interfaces/terminal-ui/components/show-images-selector.d.ts +0 -10
  410. package/dist/interfaces/terminal-ui/components/show-images-selector.d.ts.map +0 -1
  411. package/dist/interfaces/terminal-ui/components/show-images-selector.js +0 -32
  412. package/dist/interfaces/terminal-ui/components/show-images-selector.js.map +0 -1
  413. package/dist/interfaces/terminal-ui/components/skill-invocation-message.d.ts +0 -17
  414. package/dist/interfaces/terminal-ui/components/skill-invocation-message.d.ts.map +0 -1
  415. package/dist/interfaces/terminal-ui/components/skill-invocation-message.js +0 -55
  416. package/dist/interfaces/terminal-ui/components/skill-invocation-message.js.map +0 -1
  417. package/dist/interfaces/terminal-ui/components/theme-selector.d.ts +0 -11
  418. package/dist/interfaces/terminal-ui/components/theme-selector.d.ts.map +0 -1
  419. package/dist/interfaces/terminal-ui/components/theme-selector.js +0 -39
  420. package/dist/interfaces/terminal-ui/components/theme-selector.js.map +0 -1
  421. package/dist/interfaces/terminal-ui/components/thinking-selector.d.ts +0 -11
  422. package/dist/interfaces/terminal-ui/components/thinking-selector.d.ts.map +0 -1
  423. package/dist/interfaces/terminal-ui/components/thinking-selector.js +0 -45
  424. package/dist/interfaces/terminal-ui/components/thinking-selector.js.map +0 -1
  425. package/dist/interfaces/terminal-ui/components/tool-execution.d.ts +0 -72
  426. package/dist/interfaces/terminal-ui/components/tool-execution.d.ts.map +0 -1
  427. package/dist/interfaces/terminal-ui/components/tool-execution.js +0 -1162
  428. package/dist/interfaces/terminal-ui/components/tool-execution.js.map +0 -1
  429. package/dist/interfaces/terminal-ui/components/tree-selector.d.ts +0 -62
  430. package/dist/interfaces/terminal-ui/components/tree-selector.d.ts.map +0 -1
  431. package/dist/interfaces/terminal-ui/components/tree-selector.js +0 -886
  432. package/dist/interfaces/terminal-ui/components/tree-selector.js.map +0 -1
  433. package/dist/interfaces/terminal-ui/components/user-message-selector.d.ts +0 -24
  434. package/dist/interfaces/terminal-ui/components/user-message-selector.d.ts.map +0 -1
  435. package/dist/interfaces/terminal-ui/components/user-message-selector.js +0 -99
  436. package/dist/interfaces/terminal-ui/components/user-message-selector.js.map +0 -1
  437. package/dist/interfaces/terminal-ui/components/user-message.d.ts +0 -193
  438. package/dist/interfaces/terminal-ui/components/user-message.d.ts.map +0 -1
  439. package/dist/interfaces/terminal-ui/components/user-message.js +0 -201
  440. package/dist/interfaces/terminal-ui/components/user-message.js.map +0 -1
  441. package/dist/interfaces/terminal-ui/components/visual-truncate.d.ts +0 -12
  442. package/dist/interfaces/terminal-ui/components/visual-truncate.d.ts.map +0 -1
  443. package/dist/interfaces/terminal-ui/components/visual-truncate.js +0 -25
  444. package/dist/interfaces/terminal-ui/components/visual-truncate.js.map +0 -1
  445. package/dist/interfaces/terminal-ui/interactive-mode.d.ts +0 -1941
  446. package/dist/interfaces/terminal-ui/interactive-mode.d.ts.map +0 -1
  447. package/dist/interfaces/terminal-ui/interactive-mode.js +0 -5940
  448. package/dist/interfaces/terminal-ui/interactive-mode.js.map +0 -1
  449. package/dist/interfaces/terminal-ui/theme/theme.d.ts.map +0 -1
  450. package/dist/interfaces/terminal-ui/theme/theme.js.map +0 -1
  451. /package/dist/interfaces/{terminal-ui/theme → theme}/theme-schema.json +0 -0
  452. /package/dist/interfaces/{terminal-ui/theme → theme}/theme.d.ts +0 -0
@@ -1,1941 +0,0 @@
1
- /**
2
- * Interactive Mode - Terminal-based UI for interactive agent use
3
- *
4
- * ============================================================================
5
- * PURPOSE
6
- * ============================================================================
7
- *
8
- * Provides a full-featured terminal UI for interactive use of the coding agent.
9
- * Handles rendering, keyboard input, session management, and real-time updates.
10
- * This is the primary mode for direct user interaction with the agent.
11
- *
12
- * ============================================================================
13
- * ARCHITECTURE
14
- * ============================================================================
15
- *
16
- * Initialization Phase:
17
- * - Create AgentSession with language model and tools
18
- * - Load theme system and keyboard bindings
19
- * - Initialize TUI (terminal user interface) library
20
- * - Set up extension system with UI context
21
- * - Load autocomplete provider with fd tool for file paths
22
- *
23
- * Rendering Phase:
24
- * - Terminal layout: Header (logo/changelog) → Chat → Pending → Status → Widgets → Editor → Footer
25
- * - Live rendering of agent messages with syntax highlighting
26
- * - Real-time tool execution display with collapsible output
27
- * - Thinking block display (can be toggled via settings)
28
- * - Auto-scrolling to latest message
29
- *
30
- * Input Phase:
31
- * - Keyboard event handling via TUI key system
32
- * - Command parsing (/command format)
33
- * - Slash command autocomplete with fuzzy filtering
34
- * - File path completion via fd tool
35
- * - Multi-line editor support with Ctrl+J to continue
36
- *
37
- * State Management:
38
- * - Subscribe to AgentSession events (messages, tools, compaction)
39
- * - Update display on each event
40
- * - Maintain streaming component state for incremental rendering
41
- * - Track tool execution components for expansion control
42
- *
43
- * ============================================================================
44
- * DATA FLOW
45
- * ============================================================================
46
- *
47
- * User Input Flow:
48
- * User Input (keyboard)
49
- * ↓
50
- * TUI Key Handler (in setupKeyHandlers)
51
- * ↓
52
- * Command Parser (parseSlashCommand or plain text)
53
- * ↓
54
- * Command Handler or session.prompt()
55
- * ↓
56
- * AgentSession.prompt() executes agent loop
57
- * ↓
58
- * Agent emits AgentSessionEvent (message, tool, etc.)
59
- * ↓
60
- * Event Subscriber in InteractiveMode (subscribeToAgent)
61
- * ↓
62
- * Display Update (render message, tool, status)
63
- * ↓
64
- * TUI Invalidate → requestRender()
65
- * ↓
66
- * Terminal Output Rendered
67
- *
68
- * Event Processing Flow:
69
- * agent_start → Show loading animation
70
- * message_streamed → Stream text to AssistantMessageComponent
71
- * tool_call → Create ToolExecutionComponent, show in pending area
72
- * tool_output → Update tool component with result
73
- * message_complete → Move message to chat, hide loading
74
- * compaction_start → Show compaction loader
75
- * compaction_complete → Update with summary message
76
- *
77
- * ============================================================================
78
- * KEY COMPONENTS
79
- * ============================================================================
80
- *
81
- * Renderer:
82
- * - TUI: Core terminal rendering library (from indusagi/tui)
83
- * - Components: Markdown, Text, Container, ProcessTerminal, etc.
84
- * - Handles ANSI codes for colors, styles, and terminal control
85
- * - Manages viewport size and automatic text wrapping
86
- *
87
- * InputHandler:
88
- * - CustomEditor: Multi-line editor with autocomplete
89
- * - KeybindingsManager: Keyboard shortcut configuration
90
- * - Autocomplete: Slash commands, file paths, templates
91
- * - Command Parser: Processes /settings, /model, /fork, etc.
92
- *
93
- * DisplayManager:
94
- * - InteractiveMode class: Orchestrates all display updates
95
- * - Container hierarchy: ChatContainer, PendingMessagesContainer, StatusContainer
96
- * - Session display: Shows messages, tools, thinking blocks
97
- * - Component tracking: streamingComponent, pendingTools, etc.
98
- *
99
- * ThemeManager:
100
- * - Theme system: Colors, styles, layout options
101
- * - EditorTheme: Syntax highlighting for code
102
- * - MarkdownTheme: Rendering options for markdown
103
- * - Theme switching: Hot reload on theme file changes
104
- * - Custom themes: Load from .indusagi/themes/*.json
105
- *
106
- * Extension System:
107
- * - ExtensionRunner: Manages registered extensions
108
- * - ExtensionUIContext: TUI-based UI for extensions
109
- * - Extension shortcuts: Keyboard shortcuts from extensions
110
- * - Extension widgets: Custom UI above/below editor
111
- * - Extension commands: Custom slash commands
112
- *
113
- * SessionManager:
114
- * - Session state tracking: Model, messages, tools
115
- * - Session persistence: Save/load from disk
116
- * - Branching: Create branches from previous messages
117
- * - Tree navigation: Switch between branches
118
- *
119
- * ============================================================================
120
- * KEY FEATURES
121
- * ============================================================================
122
- *
123
- * Real-time Streaming:
124
- * - Stream agent responses token-by-token
125
- * - Show tool execution in real-time
126
- * - Display thinking blocks (if enabled)
127
- * - Syntax highlighting for code blocks
128
- *
129
- * Interactive Commands:
130
- * - /settings: Open settings menu
131
- * - /model: Select language model
132
- * - /fork: Create branch from previous message
133
- * - /tree: Navigate session tree
134
- * - /export: Export to HTML
135
- * - /compact: Manually compact session
136
- * - /new: Start new session
137
- *
138
- * Session Management:
139
- * - Save/load sessions from disk
140
- * - Branch creation and navigation
141
- * - Automatic context compaction
142
- * - Session switching
143
- *
144
- * Customization:
145
- * - Custom themes
146
- * - Keyboard bindings
147
- * - Settings (quiet startup, collapse changelog, etc.)
148
- * - Editor options (padding, tab width, etc.)
149
- *
150
- * ============================================================================
151
- * BASED ON INDUSAGI VENDOR
152
- * ============================================================================
153
- *
154
- * This interactive mode implementation is based on indusagi, a terminal UI
155
- * toolkit and agent framework maintained at:
156
- * https://github.com/varunisrani/indusagi-ts
157
- *
158
- * Vendor packages used:
159
- * - indusagi/tui: Terminal UI components and rendering
160
- * - indusagi/ai: AI model interfaces and chat protocol
161
- * - indusagi/agent: Core agent session and event system
162
- *
163
- * Attribution: Builds on proven TUI patterns and architectural decisions
164
- * from the original indusagi implementation.
165
- */
166
- import { type ImageContent } from "indusagi/ai";
167
- import { type AgentSession } from "../../runtime/agent-session.js";
168
- /**
169
- * Options for InteractiveMode initialization.
170
- */
171
- export interface InteractiveModeOptions {
172
- /** Providers that were migrated to auth.json (shows warning) */
173
- migratedProviders?: string[];
174
- /** Warning message if session model couldn't be restored */
175
- modelFallbackMessage?: string;
176
- /** Initial message to send on startup (can include @file content) */
177
- initialMessage?: string;
178
- /** Images to attach to the initial message */
179
- initialImages?: ImageContent[];
180
- /** Additional messages to send after the initial message */
181
- initialMessages?: string[];
182
- /** Force verbose startup (overrides quietStartup setting) */
183
- verbose?: boolean;
184
- }
185
- /**
186
- * ============================================================================
187
- * INTERACTIVE MODE - RENDERING ORCHESTRATION & PIPELINE
188
- * ============================================================================
189
- *
190
- * COMPREHENSIVE RENDERING DOCUMENTATION:
191
- * ============================================================================
192
- *
193
- * This section documents the complete rendering pipeline from session state
194
- * to terminal output. The InteractiveMode class manages the TUI layout,
195
- * message rendering, and real-time updates for the interactive agent interface.
196
- *
197
- * RENDERING PIPELINE OVERVIEW:
198
- * ============================================================================
199
- * End-to-End Flow (from user input to terminal display):
200
- *
201
- * User Input (keyboard event)
202
- * ↓
203
- * TUI key handler → setupKeyHandlers()
204
- * ↓
205
- * Command parser (parseSlashCommand or plaintext)
206
- * ↓
207
- * Handler: session.prompt(text) or special command
208
- * ↓
209
- * AgentSession processes (calls LLM, tools, etc.)
210
- * ↓
211
- * Agent emits events: message_streamed, tool_output, etc.
212
- * ↓
213
- * Event handler: subscribeToAgent() listeners
214
- * ↓
215
- * Display update: addMessageToChat() or component.updateResult()
216
- * ↓
217
- * TUI invalidate() → ui.requestRender()
218
- * ↓
219
- * TUI render() → compute layout (width, height, wrapping)
220
- * ↓
221
- * Terminal output: ANSI codes to terminal device
222
- * ↓
223
- * User sees updated chat with new message
224
- *
225
- * LAYOUT STRUCTURE:
226
- * ============================================================================
227
- * Terminal Layout (top to bottom):
228
- *
229
- * ┌─────────────────────────────────────────────────────┐
230
- * │ [Logo/Changelog] (conditionally shown at startup) │ 1-10 lines
231
- * ├─────────────────────────────────────────────────────┤
232
- * │ │
233
- * │ Chat Messages (scrollable, grows downward) │ N lines
234
- * │ ├─ User message (background colored) │
235
- * │ ├─ Assistant message │
236
- * │ ├─ Tool execution (pending or complete) │
237
- * │ └─ ...more messages... │
238
- * │ │
239
- * ├─────────────────────────────────────────────────────┤
240
- * │ Pending Messages (tools being executed) │ 1-20 lines
241
- * │ ├─ Tool call (pending background) │
242
- * │ └─ ...more pending tools... │
243
- * ├─────────────────────────────────────────────────────┤
244
- * │ Status Line (operation status) │ 1 line
245
- * │ "Thinking..." or "Reading files..." or "Complete" │
246
- * ├─────────────────────────────────────────────────────┤
247
- * │ [Widgets] (optional, from extensions) │ 0-5 lines
248
- * ├─────────────────────────────────────────────────────┤
249
- * │ [Editor] (multi-line input) │ 3-10 lines
250
- * │ > User typing here... │
251
- * │ > Can span multiple lines │
252
- * ├─────────────────────────────────────────────────────┤
253
- * │ [Footer] (status, model, etc.) │ 1 line
254
- * │ Model: GPT-4 | Tokens: 4,251 | Compaction: ... │
255
- * └─────────────────────────────────────────────────────┘
256
- *
257
- * Container Hierarchy:
258
- * - mainContainer: Root container for entire UI
259
- * ├── logoContainer: Logo/changelog (conditional)
260
- * ├── chatContainer: All completed messages
261
- * ├── pendingMessagesContainer: Tools being executed
262
- * ├── statusContainer: Status line
263
- * ├── widgetsContainer: Extension widgets
264
- * ├── editorContainer: Multi-line input
265
- * └── footerComponent: Status bar at bottom
266
- *
267
- * RENDERING MODES:
268
- * ============================================================================
269
- *
270
- * 1. INITIAL LOAD (renderInitialMessages):
271
- * Purpose: Display all messages when session loads
272
- * Process:
273
- * a. Session manager builds aligned message context
274
- * b. Iterate through all messages (oldest to newest)
275
- * c. For each assistant message:
276
- * - Create AssistantMessageComponent
277
- * - For each tool call in message:
278
- * - Create ToolExecutionComponent (no result yet)
279
- * - Render to chatContainer
280
- * d. For each tool result message:
281
- * - Find matching pending tool
282
- * - Call component.updateResult()
283
- * - Remove from pending map
284
- * e. Update footer (token count, context info)
285
- * f. Add user messages to editor history (for Up arrow)
286
- * g. Call ui.requestRender()
287
- *
288
- * 2. STREAMING UPDATES (handleEvent):
289
- * Purpose: Update display as agent processes real-time
290
- * Process:
291
- * a. Agent emits message_streamed event
292
- * b. Extract message from event.message
293
- * c. Create/update component:
294
- * - First event: Create AssistantMessageComponent
295
- * - Subsequent events: Call component.updateContent()
296
- * d. Add to chatContainer if first event
297
- * e. Update footer status (show operation in progress)
298
- * f. TUI invalidate() and requestRender()
299
- * Optimization:
300
- * - Streaming component cached (one per assistant message)
301
- * - Only call updateContent() on new content (not full rebuild)
302
- * - Markdown rendering is lazy-cached by TUI library
303
- *
304
- * 3. TOOL EXECUTION (handleEvent + renderSessionContext):
305
- * Purpose: Show tool calls and their results
306
- * Process:
307
- * a. Agent emits message_update (tool call started)
308
- * b. Render tool call with pending background
309
- * c. Tool executes (could take seconds/minutes)
310
- * d. Agent emits tool_output event
311
- * e. Find tool component in pendingTools map
312
- * f. Call component.updateResult()
313
- * g. Pending background changes to success/error
314
- * h. Remove from pendingTools (completed)
315
- * i. User can expand/collapse output via toolOutputExpanded setting
316
- *
317
- * 4. REAL-TIME BASH (handleBashCommand):
318
- * Purpose: Stream bash output line-by-line
319
- * Process:
320
- * a. User types !! command
321
- * b. Create BashExecutionComponent
322
- * c. Start bash execution (async)
323
- * d. Agent streams stdout chunks
324
- * e. For each chunk:
325
- * - Call component.appendOutput()
326
- * - Component appends to outputLines
327
- * - Call updateDisplay() and requestRender()
328
- * f. When done, call component.setComplete()
329
- * g. Show exit code or cancellation message
330
- *
331
- * 5. REBUILD (rebuildChatFromMessages):
332
- * Purpose: Clear and re-render after settings change or recovery
333
- * Process:
334
- * a. Clear chatContainer
335
- * b. Call renderInitialMessages()
336
- * c. All messages re-created with new settings
337
- * d. Useful for: thinking block toggle, theme change, etc.
338
- *
339
- * STYLING & COLOR SCHEME:
340
- * ============================================================================
341
- * Message Type Colors:
342
- * - User message: userMessageBg + userMessageText (background + text)
343
- * - Assistant: Normal markdown colors (no background)
344
- * - Tool pending: toolPendingBg (neutral during execution)
345
- * - Tool success: toolSuccessBg (green tint after success)
346
- * - Tool error: toolErrorBg (red tint after error)
347
- * - Bash: bashMode color (border + command)
348
- * - Error: theme.fg("error", text) (red)
349
- * - Warning: theme.fg("warning", text) (yellow)
350
- * - Muted: theme.fg("muted", text) (dim/gray)
351
- *
352
- * Code Highlighting:
353
- * - Markdown: Full markdown with syntax-highlighted code blocks
354
- * - Code inline: Monospace with color
355
- * - Code block: Full syntax highlighting via highlight.js
356
- * - Languages detected from file extensions
357
- * - Theme provides editor theme for highlighting
358
- *
359
- * Spacing & Layout:
360
- * - Line height: 1 logical line per message (no double spacing)
361
- * - Margins: Spacer(1) before each message type
362
- * - Padding: 1 char left/right within backgrounds
363
- * - Terminal width: Auto-wrap text to terminal width
364
- * - Viewport: Scrollable (auto-scroll to bottom on new message)
365
- *
366
- * PERFORMANCE CONSIDERATIONS:
367
- * ============================================================================
368
- *
369
- * Streaming Performance:
370
- * - Streaming component cached: Only one active at a time
371
- * - Markdown incremental: TUI library caches rendering
372
- * - Invalidate efficient: Only re-renders changed container
373
- * - Suitable for: 100+ stream updates without lag
374
- *
375
- * Large Conversations:
376
- * - Tool caching: pendingTools map (fast lookup by ID)
377
- * - Lazy rendering: Messages only rendered when visible
378
- * - No 1000+ message overhead with proper viewport management
379
- * - Compaction system: Auto-summarizes old messages to save memory
380
- *
381
- * Image Handling:
382
- * - Async conversion: Non-blocking PNG conversion for Kitty protocol
383
- * - Lazy loading: Images loaded when result arrives
384
- * - Format detection: MIME type checked, converted if needed
385
- * - Display control: showImages setting filters images
386
- *
387
- * Diff Computation:
388
- * - Async preview: Edit diff computed before tool runs
389
- * - Result override: Post-execution diff takes priority
390
- * - Caching: Results cached to avoid re-computation
391
- * - Race handling: File modifications between preview/execution
392
- *
393
- * INTERACTIVE FEATURES:
394
- * ============================================================================
395
- *
396
- * Keyboard Controls:
397
- * - Enter: Send message
398
- * - Ctrl-J: Continue multi-line message
399
- * - Arrow Up: Recall previous message from history
400
- * - /settings: Open settings dialog
401
- * - /model: Select language model
402
- * - Tab: Autocomplete
403
- * - Ctrl-C: Cancel current operation or exit
404
- *
405
- * Expandable Elements:
406
- * - Tool output: Expand to see full output (toolOutputExpanded setting)
407
- * - Code blocks: Expand long code to show all lines
408
- * - Tool list: Expand to show all matching tools
409
- * - Bash output: Expand from preview (20 lines) to full
410
- *
411
- * Real-time Status:
412
- * - Status line: Shows current operation (thinking, reading, writing)
413
- * - Footer: Token count, model name, session info
414
- * - Loader: Animated spinner for long operations
415
- * - Progress: Some operations show progress indicator
416
- *
417
- * Session Management:
418
- * - Fork: Create branch from previous message
419
- * - Tree: Navigate between branches
420
- * - Save: Auto-save to .indusagi/sessions/
421
- * - Resume: Load previous session on startup
422
- *
423
- * EXAMPLE RENDERING SEQUENCES:
424
- * ============================================================================
425
- *
426
- * Sequence 1: User Prompt → Assistant Response
427
- * ─────────────────────────────────────────────
428
- *
429
- * 1. User types "read src/main.ts" and presses Enter
430
- * 2. CustomEditor captures text and clears
431
- * 3. session.prompt(text) called
432
- * 4. Agent starts processing
433
- * 5. Agent emits message_streamed with assistant message (empty)
434
- * → CreateAssistantMessageComponent, add to chatContainer
435
- * → Show status "Thinking..."
436
- * 6. Agent streams text tokens "I'll read the file..."
437
- * → component.updateContent(), add text to message
438
- * → invalidate() and requestRender()
439
- * 7. Agent detects tool call (read)
440
- * → Emit message_update with tool call
441
- * → CreateToolExecutionComponent, add to chatContainer
442
- * → pendingTools["id"] = component
443
- * 8. Tool executes on server
444
- * 9. Agent emits tool_output with result
445
- * → Find component in pendingTools["id"]
446
- * → component.updateResult(result)
447
- * → Remove from pendingTools
448
- * → Background changes from pending to success
449
- * 10. Agent completes
450
- * → Hide status line
451
- * → Show footer with token count
452
- * 11. Entire sequence rendered to terminal
453
- *
454
- * Sequence 2: Real-time Bash Output
455
- * ──────────────────────────────────
456
- *
457
- * 1. User types "!!ls -la /src" and presses Enter
458
- * 2. handleBashCommand() parses and creates BashExecutionComponent
459
- * 3. Component shows header and loader
460
- * 4. Shell command starts (async)
461
- * 5. Shell outputs "total 128\ndrwx..." chunk 1
462
- * → component.appendOutput(chunk)
463
- * → outputLines = ["total 128", "drwx..."]
464
- * → updateDisplay() and requestRender()
465
- * 6. Shell outputs "-rw-r--..." chunk 2
466
- * → component.appendOutput(chunk)
467
- * → outputLines += ["-rw-r--..."]
468
- * → updateDisplay() and requestRender()
469
- * 7. Shell outputs "(exit 0)" and completes
470
- * → component.setComplete(0, false, ...)
471
- * → Loader stops, exit code shown
472
- * → updateDisplay() and requestRender()
473
- * 8. Final output rendered to terminal
474
- *
475
- * TERMINAL DIMENSIONS & WRAPPING:
476
- * ============================================================================
477
- *
478
- * Width Handling:
479
- * - Terminal width from ui.terminal.columns
480
- * - TUI library auto-wraps text at this width
481
- * - Code blocks may overflow (user can scroll horizontally)
482
- * - Table rendering respects width (may abbreviate cells)
483
- *
484
- * Height Handling:
485
- * - Terminal height from ui.terminal.rows
486
- * - mainContainer grows as needed (scrollable)
487
- * - Chat area expands to fill available space
488
- * - Footer always at bottom (fixed)
489
- * - Editor always above footer (fixed)
490
- *
491
- * Dynamic Resizing:
492
- * - TUI detects terminal resize (SIGWINCH)
493
- * - All components re-render with new dimensions
494
- * - invalidate() called on all containers
495
- * - Visual line truncation recached (width-aware)
496
- * - Auto-scroll adjusted to show latest message
497
- *
498
- * Text Truncation:
499
- * - Long lines: Wrapped automatically by TUI
500
- * - Visual truncation: truncateToVisualLines() respects width
501
- * - Ellipsis: "..." used to indicate truncation
502
- * - Hints: Show "(to expand)" for cut-off content
503
- *
504
- * INTEGRATION WITH EXTENSIONS:
505
- * ============================================================================
506
- *
507
- * Custom Renderers:
508
- * - Extension provides renderCall() and renderResult()
509
- * - Called from ToolExecutionComponent.updateDisplay()
510
- * - Custom components rendered within tool box
511
- * - Falls back to built-in rendering if custom fails
512
- *
513
- * Custom Commands:
514
- * - Extension registers slash command handler
515
- * - Command handler called from InteractiveMode.handleCommand()
516
- * - Can show dialogs, update display, etc.
517
- * - Can access session and TUI for rendering
518
- *
519
- * Widgets:
520
- * - Extension provides widget component
521
- * - Rendered in widgetsContainer above editor
522
- * - Can show status, buttons, controls, etc.
523
- * - Multiple widgets stack vertically
524
- *
525
- * SEE ALSO:
526
- * ============================================================================
527
- * - AssistantMessageComponent: Text/thinking rendering
528
- * - UserMessageComponent: User prompt rendering
529
- * - ToolExecutionComponent: Tool call/result rendering
530
- * - BashExecutionComponent: Real-time bash output
531
- * - renderInitialMessages(): Full session rendering
532
- * - renderSessionContext(): Message-by-message rendering
533
- * - handleEvent(): Real-time event processing
534
- * - subscribeToAgent(): Event subscription setup
535
- */
536
- export declare class InteractiveMode {
537
- private options;
538
- private session;
539
- private ui;
540
- private chatContainer;
541
- private pendingMessagesContainer;
542
- private statusContainer;
543
- private defaultEditor;
544
- private editor;
545
- private autocompleteProvider;
546
- private fdPath;
547
- private editorContainer;
548
- private footer;
549
- private footerDataProvider;
550
- private keybindings;
551
- private version;
552
- private isInitialized;
553
- private onInputCallback?;
554
- private loadingAnimation;
555
- private pendingWorkingMessage;
556
- private readonly defaultWorkingMessage;
557
- private lastSigintTime;
558
- private lastEscapeTime;
559
- private changelogMarkdown;
560
- private lastStatusSpacer;
561
- private lastStatusText;
562
- private streamingComponent;
563
- private streamingMessage;
564
- private pendingTools;
565
- private toolOutputExpanded;
566
- private hideThinkingBlock;
567
- private skillCommands;
568
- private unsubscribe?;
569
- private isBashMode;
570
- private bashComponent;
571
- private pendingBashComponents;
572
- private autoCompactionLoader;
573
- private autoCompactionEscapeHandler?;
574
- private retryLoader;
575
- private retryEscapeHandler?;
576
- private compactionQueuedMessages;
577
- private shutdownRequested;
578
- private extensionSelector;
579
- private extensionInput;
580
- private extensionEditor;
581
- private extensionWidgetsAbove;
582
- private extensionWidgetsBelow;
583
- private widgetContainerAbove;
584
- private widgetContainerBelow;
585
- private customFooter;
586
- private builtInHeader;
587
- private customHeader;
588
- private get agent();
589
- private get sessionManager();
590
- private get settingsManager();
591
- constructor(session: AgentSession, options?: InteractiveModeOptions);
592
- private setupAutocomplete;
593
- private rebuildAutocomplete;
594
- private prepareStartupResources;
595
- private buildStartupHeader;
596
- private attachMainLayout;
597
- private activateInteractiveRuntime;
598
- private showStartupWarnings;
599
- private processStartupMessages;
600
- /**
601
- * Initialize the interactive mode UI and extensions.
602
- *
603
- * PURPOSE:
604
- * Sets up the terminal UI, keyboard handlers, event subscriptions, and extension system.
605
- * This prepares the interactive mode for user interaction. Must be called before run().
606
- *
607
- * PROCESS:
608
- * 1. Load changelog entries and check for initial messages
609
- * 2. Ensure fd tool is available for file path autocomplete
610
- * 3. Build autocomplete provider (slash commands, templates, extensions, skills)
611
- * 4. Initialize TUI with header (logo, keybinding hints, changelog)
612
- * 5. Add layout components (chat, pending, status, widgets, editor, footer)
613
- * 6. Set up keyboard handlers (key bindings, editor events)
614
- * 7. Start the TUI (terminal raw mode, enable mouse, etc.)
615
- * 8. Initialize extension system with TUI-based UI context
616
- * 9. Subscribe to agent events (messages, tools, compaction, retry)
617
- * 10. Set up theme file watcher for hot reload
618
- * 11. Set up git branch watcher for footer
619
- * 12. Initialize available provider count for display
620
- *
621
- * PARAMETERS:
622
- * None - uses constructor options for initial messages and warnings
623
- *
624
- * RETURNS:
625
- * Promise<void> - resolves when initialization is complete
626
- *
627
- * STATE CHANGES:
628
- * - Sets isInitialized flag to true
629
- * - Starts TUI (terminal is in raw mode after this)
630
- * - Sets terminal title with session name
631
- * - Subscribes to agent events and theme changes
632
- *
633
- * NOTES:
634
- * - Must be idempotent (calling twice does nothing on second call)
635
- * - Extension system is fully initialized here
636
- * - Changelog is only shown for new sessions, not resumed ones
637
- */
638
- init(): Promise<void>;
639
- /**
640
- * Update terminal title with session name and cwd.
641
- */
642
- private updateTerminalTitle;
643
- /**
644
- * Run the interactive mode main loop.
645
- *
646
- * PURPOSE:
647
- * Main entry point for interactive mode. Initializes UI, displays startup info,
648
- * processes initial messages, and enters the interactive user input loop.
649
- * Never returns under normal operation (runs until user exits with /quit, Ctrl+D, etc.).
650
- *
651
- * PROCESS:
652
- * 1. Call init() to set up UI, keyboard handlers, extensions
653
- * 2. Start version check asynchronously (shows notification if newer version available)
654
- * 3. Render initial session messages from previous session (if resumed)
655
- * 4. Show startup warnings:
656
- * - Migrated provider credentials
657
- * - models.json parsing errors
658
- * - Model fallback message (if model couldn't be restored)
659
- * 5. Process initial messages from options (--message, --initial-message):
660
- * - Send each via session.prompt()
661
- * - Catch and display errors
662
- * 6. Start interactive loop:
663
- * a. Wait for user input (getUserInput waits for editor.onSubmit)
664
- * b. Send input to session.prompt()
665
- * c. Loop continues until shutdown (process.exit)
666
- *
667
- * PARAMETERS:
668
- * None - uses constructor options for initial messages and warnings
669
- *
670
- * RETURNS:
671
- * Promise<void> - never resolves (runs until process.exit is called)
672
- *
673
- * STATE CHANGES:
674
- * - Initializes all UI components
675
- * - Starts the interactive input loop
676
- * - Updates footer/display as agent processes messages
677
- * - May create new sessions, fork, navigate tree, etc. based on commands
678
- *
679
- * NOTES:
680
- * - Must call init() first
681
- * - Handles all errors from session.prompt() and displays them
682
- * - Runs forever - shutdown happens via /quit, Ctrl+D, or extension shutdown signal
683
- */
684
- run(): Promise<void>;
685
- /**
686
- * Check npm registry for a newer version.
687
- */
688
- private checkForNewVersion;
689
- /**
690
- * Get changelog entries to display on startup.
691
- * Only shows new entries since last seen version, skips for resumed sessions.
692
- */
693
- private getChangelogForDisplay;
694
- private getStartupImageComponent;
695
- private getMarkdownThemeWithSettings;
696
- private formatDisplayPath;
697
- /**
698
- * Get a short path relative to the package root for display.
699
- */
700
- private getShortPath;
701
- private getDisplaySourceInfo;
702
- private getScopeGroup;
703
- private isPackageSource;
704
- private buildScopeGroups;
705
- private formatScopeGroups;
706
- /**
707
- * Find metadata for a path, checking parent directories if exact match fails.
708
- * Package manager stores metadata for directories, but we display file paths.
709
- */
710
- private findMetadata;
711
- /**
712
- * Format a path with its source/scope info from metadata.
713
- */
714
- private formatPathWithSource;
715
- /**
716
- * Format resource diagnostics with nice collision display using metadata.
717
- */
718
- private formatDiagnostics;
719
- private showLoadedResources;
720
- /**
721
- * Initialize the extension system with TUI-based UI context.
722
- *
723
- * PURPOSE:
724
- * Set up extensions with UI capabilities. Creates ExtensionUIContext for
725
- * extensions to use for dialogs, widgets, status messages, etc.
726
- * Binds command context actions, error handlers, and shutdown handler.
727
- *
728
- * PROCESS:
729
- * 1. If no extension runner: show loaded resources and return
730
- * 2. Create ExtensionUIContext with:
731
- * a. Dialog methods (select, confirm, input, notify)
732
- * b. Status/title setters
733
- * c. Widget and footer/header setters
734
- * d. Editor interaction methods
735
- * e. Theme access and switching
736
- * 3. Call session.bindExtensions() with:
737
- * a. uiContext - for TUI dialogs
738
- * b. commandContextActions - for /fork, /tree, /new actions
739
- * c. shutdownHandler - called when extension wants to exit
740
- * d. Error handlers - for extension and hook errors
741
- * 4. Set up extension shortcuts (keyboard bindings from extensions)
742
- * 5. Show loaded resources (extensions, skills, prompts, themes)
743
- *
744
- * EXTENSION CAPABILITIES:
745
- * - Show dialogs (selectors, confirmations, inputs)
746
- * - Display persistent widgets above/below editor
747
- * - Set custom footer and header
748
- * - Customize editor component
749
- * - Register keyboard shortcuts
750
- * - Request shutdown
751
- * - Access theme system
752
- *
753
- * COMMAND CONTEXT ACTIONS:
754
- * - waitForIdle(): Wait until agent is idle
755
- * - newSession(): Start a new session
756
- * - fork(): Create branch from previous message
757
- * - navigateTree(): Switch to different point in tree
758
- *
759
- * PARAMETERS:
760
- * None
761
- *
762
- * RETURNS:
763
- * Promise<void> - completes when extensions are initialized
764
- *
765
- * STATE CHANGES:
766
- * - Binds extensions to session
767
- * - Sets up shortcuts on defaultEditor
768
- * - Displays loaded resources in chat
769
- *
770
- * NOTES:
771
- * - Called from init() after TUI is started
772
- * - Extensions can't affect UI until this completes
773
- * - Error/hook errors displayed but don't stop initialization
774
- * - Resources shown only if verbose or not quietStartup
775
- *
776
- * SEE ALSO:
777
- * - createExtensionUIContext() for UI API details
778
- * - setupExtensionShortcuts() for keyboard bindings
779
- */
780
- private initExtensions;
781
- /**
782
- * Get a registered tool definition by name (for custom rendering).
783
- */
784
- private getRegisteredToolDefinition;
785
- /**
786
- * Set up keyboard shortcuts registered by extensions.
787
- */
788
- private setupExtensionShortcuts;
789
- /**
790
- * Set extension status text in the footer.
791
- */
792
- private setExtensionStatus;
793
- /**
794
- * Set an extension widget (string array or custom component).
795
- */
796
- private setExtensionWidget;
797
- private clearExtensionWidgets;
798
- private resetExtensionUI;
799
- private static readonly MAX_WIDGET_LINES;
800
- /**
801
- * Render all extension widgets to the widget container.
802
- */
803
- private renderWidgets;
804
- private renderWidgetContainer;
805
- /**
806
- * Set a custom footer component, or restore the built-in footer.
807
- */
808
- private setExtensionFooter;
809
- /**
810
- * Set a custom header component, or restore the built-in header.
811
- */
812
- private setExtensionHeader;
813
- /**
814
- * Create the ExtensionUIContext for extensions.
815
- */
816
- private createExtensionUIContext;
817
- /**
818
- * Show a selector for extensions.
819
- */
820
- private showExtensionSelector;
821
- /**
822
- * Hide the extension selector.
823
- */
824
- private hideExtensionSelector;
825
- /**
826
- * Show a confirmation dialog for extensions.
827
- */
828
- private showExtensionConfirm;
829
- /**
830
- * Show a text input for extensions.
831
- */
832
- private showExtensionInput;
833
- /**
834
- * Hide the extension input.
835
- */
836
- private hideExtensionInput;
837
- /**
838
- * Show a multi-line editor for extensions (with Ctrl+G support).
839
- */
840
- private showExtensionEditor;
841
- /**
842
- * Hide the extension editor.
843
- */
844
- private hideExtensionEditor;
845
- /**
846
- * Set a custom editor component from an extension.
847
- * Pass undefined to restore the default editor.
848
- */
849
- private setCustomEditorComponent;
850
- /**
851
- * Show a notification for extensions.
852
- */
853
- private showExtensionNotify;
854
- /** Show a custom component with keyboard focus. Overlay mode renders on top of existing content. */
855
- private showExtensionCustom;
856
- /**
857
- * Show an extension error in the UI.
858
- */
859
- private showExtensionError;
860
- /**
861
- * Show a hook error in the UI.
862
- */
863
- private showHookError;
864
- /**
865
- * Set up keyboard event handlers for all key bindings.
866
- *
867
- * PURPOSE:
868
- * Registers all keyboard shortcuts and special key handlers on the editor.
869
- * Handles direct key events (Escape, Ctrl+D, etc.) and action dispatching
870
- * for keybinding-mapped actions (clear, suspend, cycle models, etc.).
871
- *
872
- * KEY BINDINGS CONFIGURED:
873
- *
874
- * **Escape**:
875
- * - If loading: restore queued messages and abort agent
876
- * - Else if bash running: abort bash
877
- * - Else if bash mode (!): clear input and exit bash mode
878
- * - Else if editor has text: clear editor
879
- * - Else double-escape with empty: open tree selector or fork selector
880
- * (based on settings.doubleEscapeAction)
881
- *
882
- * **Ctrl+C** (mapped to "clear" action):
883
- * - First press: clear editor
884
- * - Second press within 500ms: exit application
885
- *
886
- * **Ctrl+D** (mapped via onCtrlD):
887
- * - Only when editor is empty
888
- * - Exit application immediately
889
- *
890
- * **Ctrl+Z** (mapped to "suspend" action):
891
- * - Suspend terminal to background
892
- * - Set up SIGCONT handler to restore TUI on resume
893
- *
894
- * **Ctrl+M** (mapped to "cycleThinkingLevel" action):
895
- * - Cycle thinking level: off → low → medium → high → off
896
- * - Update border color and footer
897
- * - Show status message
898
- *
899
- * **Ctrl+N** (mapped to "cycleModelForward" action):
900
- * - Cycle to next model in scope or registry
901
- * - Update footer and border color
902
- * - Show status with new model name
903
- *
904
- * **Ctrl+P** (mapped to "cycleModelBackward" action):
905
- * - Cycle to previous model
906
- *
907
- * **Ctrl+L** (mapped to "selectModel" action):
908
- * - Open model selector dialog
909
- *
910
- * **Ctrl+E** (mapped to "expandTools" action):
911
- * - Toggle expansion state of all tool output components
912
- * - Affects current and future tool displays
913
- *
914
- * **Ctrl+K** (mapped to "toggleThinking" action):
915
- * - Toggle visibility of thinking blocks in all messages
916
- * - Rebuild chat with updated visibility
917
- *
918
- * **Ctrl+X** (mapped to "externalEditor" action):
919
- * - Open current editor content in $VISUAL or $EDITOR
920
- * - Replace content on save
921
- *
922
- * **Alt+Enter** (mapped to "followUp" action):
923
- * - If streaming: queue message to send after agent finishes
924
- * - If idle: acts like regular Enter (trigger onSubmit)
925
- *
926
- * **Ctrl+J** (mapped to "dequeue" action):
927
- * - Restore all queued messages back to editor
928
- * - Show count of restored messages
929
- *
930
- * **Alt+Debug** (global on TUI, not editor):
931
- * - Write debug log with terminal render state and agent messages
932
- *
933
- * **onChange**:
934
- * - Track if text starts with ! to enter bash mode
935
- * - Update editor border color (blue for bash, accent for thinking)
936
- *
937
- * **onPasteImage**:
938
- * - Handle Ctrl+V clipboard image paste
939
- * - Write to temp file, insert path in editor
940
- *
941
- * PARAMETERS:
942
- * None - configures this.defaultEditor handlers
943
- *
944
- * RETURNS:
945
- * void - side effects only
946
- *
947
- * STATE CHANGES:
948
- * - Sets this.defaultEditor.onEscape, onSubmit, onChange, onCtrlD, onPasteImage
949
- * - Sets this.defaultEditor action handlers (clear, suspend, etc.)
950
- * - Sets this.ui.onDebug for global debug shortcut
951
- *
952
- * NOTES:
953
- * - Handlers use this.editor (which may be custom from extension)
954
- * - All handlers use updateEditorBorderColor() to reflect state
955
- * - Extension shortcuts can override action handlers via registerShortcut()
956
- * - Most handlers call updatePendingMessagesDisplay() to sync UI
957
- */
958
- private setupKeyHandlers;
959
- private handleClipboardImagePaste;
960
- /**
961
- * Set up the editor submit handler for user input.
962
- *
963
- * PURPOSE:
964
- * Configures the editor's onSubmit callback to process user input.
965
- * This is called when the user presses Enter in the editor.
966
- * Handles command parsing, slash commands, bash execution, and message queuing.
967
- *
968
- * INPUT TYPES PROCESSED:
969
- *
970
- * **Slash Commands** (commands starting with /):
971
- * - /settings: Open settings selector menu
972
- * - /scoped-models: Open model scoping selector
973
- * - /model [search]: Open model selector or find exact match
974
- * - /export [path]: Export session to HTML file
975
- * - /share: Share session as secret GitHub gist
976
- * - /copy: Copy last agent message to clipboard
977
- * - /name [name]: Set or display session name
978
- * - /session: Show session info and stats (messages, tokens, cost)
979
- * - /changelog: Show full changelog entries
980
- * - /hotkeys: Show all keyboard shortcuts
981
- * - /fork: Show fork selector (pick message to branch from)
982
- * - /tree: Show tree selector (navigate session DAG)
983
- * - /login: Open OAuth or API key login selector
984
- * - /logout: Open logout selector for saved credentials
985
- * - /new, /clear: Start a new session
986
- * - /compact [instructions]: Manually compact context
987
- * - /reload: Reload extensions, skills, prompts, themes
988
- * - /resume: Show session selector to switch sessions
989
- * - /quit, /exit: Exit the application
990
- *
991
- * **Bash Commands** (text starting with ! or !!):
992
- * - !command: Execute bash command, include output in context
993
- * - !!command: Execute bash command, exclude from context (use !!)
994
- * - Shows BashExecutionComponent with real-time output
995
- * - Can be queued during streaming (moved to chat on next submit)
996
- *
997
- * **Prompt Templates** (custom /name commands):
998
- * - Registered template names become slash commands
999
- * - Can have placeholders and argument completion
1000
- * - Expanded and sent as regular messages
1001
- *
1002
- * **Extension Commands**:
1003
- * - Custom commands registered by extensions
1004
- * - Execute immediately even during streaming
1005
- * - Can provide argument completion
1006
- *
1007
- * **Regular Messages**:
1008
- * - If streaming: queue with streaming behavior (steer/followUp)
1009
- * - "steer": interrupt immediately
1010
- * - "followUp": wait until response finishes
1011
- * - If compacting: queue in compactionQueuedMessages
1012
- * - If idle: send immediately
1013
- * - Can include @file references for context injection
1014
- *
1015
- * COMMAND PARSING:
1016
- * 1. Trim whitespace
1017
- * 2. Check if it's a slash command (/command or /command arg)
1018
- * 3. Check if it's a bash command (!cmd or !!cmd)
1019
- * 4. Otherwise treat as regular message
1020
- *
1021
- * QUEUEING BEHAVIOR:
1022
- * - During streaming: prompt() with streamingBehavior option
1023
- * - During compaction: compactionQueuedMessages array
1024
- * - Queued messages shown in pendingMessagesContainer
1025
- * - Can be dequeued with Ctrl+J and edited
1026
- *
1027
- * PARAMETERS:
1028
- * @param text - The submitted editor text (trimmed)
1029
- *
1030
- * RETURNS:
1031
- * void - async, calls callbacks but doesn't return a value
1032
- *
1033
- * STATE CHANGES:
1034
- * - Clears editor text on submit
1035
- * - Adds to editor history (for Up arrow to recall)
1036
- * - Updates pendingMessagesDisplay when queuing
1037
- * - Moves pendingBashComponents to chat
1038
- * - Calls session.prompt() or command handlers
1039
- *
1040
- * NOTES:
1041
- * - Empty input is ignored
1042
- * - All errors are caught and displayed via showError()
1043
- * - Some commands suppress editor.addToHistory() (reload, etc.)
1044
- * - Bash commands check if bash is already running and warn
1045
- * - Must check isBashMode before allowing bash command execution
1046
- */
1047
- private setupEditorSubmitHandler;
1048
- /**
1049
- * Subscribe to agent session events for UI updates.
1050
- *
1051
- * PURPOSE:
1052
- * Sets up the event subscription to agent session. All agent activity (messages,
1053
- * tool execution, compaction, retry, etc.) flows through here to update the display.
1054
- * This is the bridge between the agent execution layer and the TUI rendering layer.
1055
- *
1056
- * PROCESS:
1057
- * 1. Call session.subscribe() with an async event handler
1058
- * 2. Save unsubscribe function for cleanup on shutdown
1059
- * 3. Handler receives AgentSessionEvent objects and calls handleEvent()
1060
- * 4. handleEvent() dispatches based on event type to update UI components
1061
- *
1062
- * EVENT TYPES HANDLED:
1063
- * - `agent_start`: Show loading animation with working message
1064
- * - `message_start`: Create new message component (user/assistant/custom)
1065
- * - `message_update`: Stream content to message component, add tool calls
1066
- * - `message_end`: Mark message complete, update tool results
1067
- * - `tool_execution_start`: Create tool execution component in chat
1068
- * - `tool_execution_update`: Stream partial tool results
1069
- * - `tool_execution_end`: Mark tool complete with final result
1070
- * - `agent_end`: Hide loading animation, check for shutdown request
1071
- * - `auto_compaction_start`: Show compaction loader, allow escape to abort
1072
- * - `auto_compaction_end`: Hide loader, rebuild chat, flush queued messages
1073
- * - `auto_retry_start`: Show retry countdown loader
1074
- * - `auto_retry_end`: Hide loader, show error only on failure
1075
- *
1076
- * PARAMETERS:
1077
- * None - subscribes to this.session
1078
- *
1079
- * RETURNS:
1080
- * void - side effects only (sets this.unsubscribe)
1081
- *
1082
- * NOTES:
1083
- * - Called from init() after TUI is started
1084
- * - Handles streaming content incrementally
1085
- * - Must save unsubscribe function for cleanup in stop()
1086
- * - Events are processed sequentially (not concurrent)
1087
- */
1088
- private subscribeToAgent;
1089
- /**
1090
- * Handle a single agent session event and update the UI.
1091
- *
1092
- * PURPOSE:
1093
- * Processes agent events and translates them into UI updates. This is the main
1094
- * event dispatcher that receives all agent activity and renders it to the terminal.
1095
- *
1096
- * PROCESS FOR EACH EVENT TYPE:
1097
- *
1098
- * **agent_start**:
1099
- * - Stop any existing loading animation
1100
- * - Create new Loader component in statusContainer
1101
- * - Apply pending working message if queued
1102
- * - Request render
1103
- *
1104
- * **message_start**:
1105
- * - User messages: render to chat immediately
1106
- * - Assistant messages: create streaming component, add to chat
1107
- * - Custom messages: render with extension renderer
1108
- *
1109
- * **message_update**:
1110
- * - Stream new content to streamingComponent
1111
- * - For each tool call: create or update ToolExecutionComponent
1112
- * - Track tool components by ID for later result updates
1113
- *
1114
- * **message_end**:
1115
- * - Mark streaming complete
1116
- * - If aborted/error: set error message, mark all pending tools as error
1117
- * - Otherwise: trigger diff computation for edit tools
1118
- * - Clear streaming component reference
1119
- *
1120
- * **tool_execution_start/update/end**:
1121
- * - Create or update ToolExecutionComponent in chat
1122
- * - Stream partial results incrementally
1123
- * - On completion: mark expanded state and remove from pending
1124
- *
1125
- * **agent_end**:
1126
- * - Stop loading animation
1127
- * - Clear streaming component from chat
1128
- * - Clear pending tools
1129
- * - Check for shutdown request (if extension called shutdown())
1130
- *
1131
- * **auto_compaction_start**:
1132
- * - Show compaction loader with reason (overflow, etc.)
1133
- * - Replace main escape handler to allow abort
1134
- * - Editor stays active for queueing messages
1135
- *
1136
- * **auto_compaction_end**:
1137
- * - Hide loader
1138
- * - Rebuild chat to show compacted state
1139
- * - Add compaction summary component
1140
- * - Flush queued messages
1141
- * - Handle completion, cancellation, or errors
1142
- *
1143
- * **auto_retry_start**:
1144
- * - Show retry countdown (attempt N/M in delay seconds)
1145
- * - Replace main escape handler to allow abort
1146
- *
1147
- * **auto_retry_end**:
1148
- * - Hide loader
1149
- * - Show error only on final failure (success shows normal response)
1150
- *
1151
- * PARAMETERS:
1152
- * @param event - AgentSessionEvent (message, tool, compaction, retry, etc.)
1153
- *
1154
- * RETURNS:
1155
- * Promise<void> - completes when UI update is done
1156
- *
1157
- * STATE CHANGES:
1158
- * - Updates streamingComponent and streamingMessage
1159
- * - Updates pendingTools map
1160
- * - Updates loading animations (loadingAnimation, autoCompactionLoader, retryLoader)
1161
- * - Updates UI via this.ui.requestRender()
1162
- * - May call checkShutdownRequested() on agent_end
1163
- *
1164
- * NOTES:
1165
- * - Initializes if not yet initialized (lazy init)
1166
- * - Handles streaming content incremental rendering
1167
- * - Events are sequential, not concurrent
1168
- * - Tool components maintain expanded state across events
1169
- */
1170
- private handleEvent;
1171
- /** Extract text content from a user message */
1172
- private getUserMessageText;
1173
- /**
1174
- * Show a status message in the chat.
1175
- *
1176
- * If multiple status messages are emitted back-to-back (without anything else being added to the chat),
1177
- * we update the previous status line instead of appending new ones to avoid log spam.
1178
- */
1179
- private showStatus;
1180
- /**
1181
- * Render a single message to the chat display.
1182
- *
1183
- * PURPOSE:
1184
- * Converts an AgentMessage into one or more UI components and adds to chatContainer.
1185
- * Handles all message types with appropriate rendering, tool display, and formatting.
1186
- *
1187
- * MESSAGE TYPES HANDLED:
1188
- *
1189
- * **user**:
1190
- * - Extract text content (ignore images/other content)
1191
- * - Check for skill blocks (```skill block with instructions)
1192
- * - If skill block found:
1193
- * a. Render SkillInvocationMessageComponent (collapsible)
1194
- * b. Render user message separately if non-skill text exists
1195
- * - Otherwise render UserMessageComponent with full text
1196
- * - Optionally add to editor history for Up arrow recall
1197
- *
1198
- * **assistant**:
1199
- * - Create AssistantMessageComponent with streaming content
1200
- * - Respect hideThinkingBlock setting for visibility
1201
- * - Tool calls are handled separately in message_update event
1202
- *
1203
- * **custom**:
1204
- * - Check message.display flag (if false, skip rendering)
1205
- * - Use extension message renderer if available
1206
- * - Render as CustomMessageComponent with markdown theme
1207
- *
1208
- * **toolResult**:
1209
- * - Rendered inline with tool calls (not standalone)
1210
- * - Handled during renderSessionContext() matching with tool calls
1211
- *
1212
- * **bashExecution**:
1213
- * - Create BashExecutionComponent
1214
- * - Show command and real-time output
1215
- * - Mark complete with exit code and optional truncation info
1216
- *
1217
- * **compactionSummary**:
1218
- * - Show how many tokens were saved during compaction
1219
- * - Display summary of what was compacted
1220
- * - Component respects toolOutputExpanded setting
1221
- *
1222
- * **branchSummary**:
1223
- * - Show branch point with label
1224
- * - Display custom instructions for navigation
1225
- * - Component respects toolOutputExpanded setting
1226
- *
1227
- * PARAMETERS:
1228
- * @param message - AgentMessage to render (any role type)
1229
- * @param options.populateHistory - Add user text to editor history (default: false)
1230
- *
1231
- * RETURNS:
1232
- * void - side effects only (adds components to chatContainer)
1233
- *
1234
- * STATE CHANGES:
1235
- * - Adds components to chatContainer
1236
- * - May update editor history
1237
- * - Updates pendingTools map (indirectly in renderSessionContext)
1238
- *
1239
- * NOTES:
1240
- * - Uses getMarkdownThemeWithSettings() for consistent rendering
1241
- * - Respects current display settings (hideThinkingBlock, showImages, etc.)
1242
- * - Tool calls are created separately during message_update event
1243
- * - Skill blocks use parseSkillBlock() to extract instructions
1244
- * - Images in messages are handled by markdown renderer
1245
- * - Does NOT call ui.requestRender() (caller does)
1246
- *
1247
- * SEE ALSO:
1248
- * - renderSessionContext() which calls this for all messages
1249
- * - handleEvent() which creates components during streaming
1250
- */
1251
- private addMessageToChat;
1252
- /**
1253
- * Render a complete session context (all messages) to the chat display.
1254
- *
1255
- * PURPOSE:
1256
- * Renders all aligned messages from a SessionContext to the chat display.
1257
- * Handles message-to-tool-result matching and streaming state management.
1258
- * Used during initial load, after compaction, and during rebuilds.
1259
- *
1260
- * PROCESS:
1261
- * 1. Clear pendingTools map (reset tracking)
1262
- * 2. Iterate through all messages in context:
1263
- * - Assistant messages: render message + create tool components for each tool call
1264
- * - Tool result messages: match to tool component, update result, remove from pending
1265
- * - Other messages: render via addMessageToChat()
1266
- * 3. Final clear of pendingTools (shouldn't have any left)
1267
- * 4. Call ui.requestRender() to display changes
1268
- *
1269
- * TOOL CALL/RESULT MATCHING:
1270
- * Tool calls and results are matched by ID:
1271
- * 1. When rendering assistant message, create ToolExecutionComponent for each tool call
1272
- * 2. Store component in pendingTools[toolCallId]
1273
- * 3. When rendering tool result: look up component, update it, remove from pending
1274
- * 4. If tool errored/aborted: mark component as error, don't add to pending
1275
- *
1276
- * PARAMETERS:
1277
- * @param sessionContext - SessionContext from sessionManager.buildSessionContext()
1278
- * @param options.updateFooter - Call footer.invalidate() and updateEditorBorderColor() (default: false)
1279
- * @param options.populateHistory - Add user message text to editor history (default: false)
1280
- *
1281
- * RETURNS:
1282
- * void - side effects only
1283
- *
1284
- * STATE CHANGES:
1285
- * - Clears and repopulates chatContainer
1286
- * - Updates pendingTools map (should be empty after completion)
1287
- * - May call footer.invalidate() if updateFooter is true
1288
- * - Calls ui.requestRender()
1289
- *
1290
- * NOTES:
1291
- * - Used internally by renderInitialMessages() and rebuildChatFromMessages()
1292
- * - All messages must be aligned (via sessionManager.buildSessionContext())
1293
- * - Tool calls/results must already be matched and in correct order
1294
- * - Error state is preserved from messages (stopReason, errorMessage)
1295
- * - Tool components track expanded state (respects this.toolOutputExpanded)
1296
- *
1297
- * SEE ALSO:
1298
- * - addMessageToChat() for individual message rendering
1299
- * - handleEvent() for streaming message handling
1300
- */
1301
- private renderSessionContext;
1302
- /**
1303
- * Render all session messages to the chat display.
1304
- *
1305
- * PURPOSE:
1306
- * Displays all messages from the current session context in the chat area.
1307
- * Used when initializing the UI, resuming a session, or after compaction.
1308
- * Handles special message types: assistant, user, tool calls/results, compaction, branches.
1309
- *
1310
- * PROCESS:
1311
- * 1. Get aligned session messages from sessionManager.buildSessionContext()
1312
- * 2. Call renderSessionContext() to render all messages
1313
- * 3. Show compaction count if session was compacted (0+ times)
1314
- * 4. Update footer state (model, tokens, etc.)
1315
- * 5. Populate editor history with user messages for Up arrow
1316
- *
1317
- * MESSAGE TYPES RENDERED:
1318
- * - User messages: with text content and optional skill blocks
1319
- * - Assistant messages: with streaming content, thinking blocks, tool calls
1320
- * - Tool calls: inline with ToolExecutionComponent showing args and results
1321
- * - Tool results: rendered within tool components (not standalone)
1322
- * - Bash execution: with command and output
1323
- * - Compaction summary: shows how many tokens were saved
1324
- * - Branch summary: shows custom branch label/instructions
1325
- * - Custom messages: rendered via extension message renderer
1326
- *
1327
- * PARAMETERS:
1328
- * None - uses this.session and this.sessionManager
1329
- *
1330
- * RETURNS:
1331
- * void - side effects only (adds components to chatContainer)
1332
- *
1333
- * STATE CHANGES:
1334
- * - Populates chatContainer with all message components
1335
- * - Populates editor history
1336
- * - Updates footer.invalidate()
1337
- * - Updates pendingTools map for tracking tool components
1338
- * - Clears previous chat display
1339
- *
1340
- * NOTES:
1341
- * - Called from init() after UI setup
1342
- * - Called from run() before entering interactive loop
1343
- * - Called from resume/fork/tree navigation
1344
- * - Rebuilds entire chat, clearing previous messages
1345
- * - Compaction entries show as status messages
1346
- * - Only shows compaction info if compaction was performed
1347
- *
1348
- * SEE ALSO:
1349
- * - renderSessionContext() for detailed rendering logic
1350
- * - addMessageToChat() for rendering individual messages
1351
- */
1352
- renderInitialMessages(): void;
1353
- getUserInput(): Promise<string>;
1354
- /**
1355
- * Rebuild chat display from scratch, clearing and re-rendering all messages.
1356
- *
1357
- * PURPOSE:
1358
- * Clears the entire chat display and re-renders all messages from session context.
1359
- * Used after toggling thinking block visibility, compaction completion, or theme changes.
1360
- * Ensures the display matches the current session state and settings.
1361
- *
1362
- * PROCESS:
1363
- * 1. Clear chatContainer (remove all rendered components)
1364
- * 2. Get fresh session context from sessionManager
1365
- * 3. Call renderSessionContext() to re-render all messages
1366
- * 4. All messages respect current settings (hideThinkingBlock, showImages, etc.)
1367
- *
1368
- * PARAMETERS:
1369
- * None - uses this.session and this.settingsManager
1370
- *
1371
- * RETURNS:
1372
- * void - side effects only
1373
- *
1374
- * STATE CHANGES:
1375
- * - Clears and repopulates chatContainer
1376
- * - Resets pendingTools map
1377
- * - Updates streaming/non-streaming component visibility
1378
- * - Respects current display settings
1379
- *
1380
- * NOTES:
1381
- * - Much faster than renderInitialMessages() (no footer update or history)
1382
- * - Used internally by toggleThinkingBlockVisibility()
1383
- * - Used after compaction to show new state
1384
- * - Does NOT scroll to top (chat scrolls naturally)
1385
- * - Triggers UI render request in renderSessionContext()
1386
- *
1387
- * SEE ALSO:
1388
- * - renderInitialMessages() for full initialization with footer/history
1389
- * - toggleThinkingBlockVisibility() which calls this
1390
- */
1391
- private rebuildChatFromMessages;
1392
- private handleCtrlC;
1393
- private handleCtrlD;
1394
- /**
1395
- * Gracefully shutdown the interactive mode and exit.
1396
- *
1397
- * PURPOSE:
1398
- * Clean shutdown sequence. Gives extensions opportunity to clean up,
1399
- * waits for pending renders, then exits the process.
1400
- *
1401
- * PROCESS:
1402
- * 1. Check if already shutting down (prevent double shutdown)
1403
- * 2. Emit session_shutdown event to extensions
1404
- * - Extensions can clean up resources, save state, etc.
1405
- * - Waits for handlers to complete
1406
- * 3. Wait one tick for pending renders to complete
1407
- * 4. Call stop() to clean up UI resources:
1408
- * a. Stop loading animation
1409
- * b. Dispose footer
1410
- * c. Unsubscribe from agent events
1411
- * d. Stop TUI (restore terminal)
1412
- * 5. Exit process with code 0
1413
- *
1414
- * TRIGGERS:
1415
- * - User presses Ctrl+D (when editor empty)
1416
- * - User presses Ctrl+C twice within 500ms
1417
- * - User enters /quit or /exit
1418
- * - Extension calls shutdown() via context
1419
- *
1420
- * PARAMETERS:
1421
- * None
1422
- *
1423
- * RETURNS:
1424
- * Promise<void> - never resolves (process.exit is called)
1425
- *
1426
- * NOTES:
1427
- * - Sets this.isShuttingDown flag to prevent double-shutdown
1428
- * - Emits session_shutdown event (not awaited if no handlers)
1429
- * - Extensions can catch this event with .on("session_shutdown")
1430
- * - Clean exits prevent terminal corruption
1431
- * - TUI stop() restores cursor and clear screen
1432
- *
1433
- * SEE ALSO:
1434
- * - stop() which does actual cleanup
1435
- * - checkShutdownRequested() which triggers shutdown on agent_end
1436
- */
1437
- private isShuttingDown;
1438
- private shutdown;
1439
- /**
1440
- * Check if shutdown was requested and perform it if so.
1441
- *
1442
- * PURPOSE:
1443
- * Called after agent completes (agent_end event) to check if an extension
1444
- * has requested shutdown. Allows shutdown to be queued and executed cleanly
1445
- * after current operation completes.
1446
- *
1447
- * PROCESS:
1448
- * 1. Check this.shutdownRequested flag
1449
- * 2. If false: return (no shutdown requested)
1450
- * 3. If true: call shutdown()
1451
- *
1452
- * USAGE:
1453
- * - Extensions call context.shutdown() to request shutdown
1454
- * - Set this.shutdownRequested = true
1455
- * - After agent finishes, agent_end event triggers this check
1456
- * - Shutdown happens cleanly after current message completes
1457
- *
1458
- * PARAMETERS:
1459
- * None
1460
- *
1461
- * RETURNS:
1462
- * Promise<void> - never resolves (process.exit is called)
1463
- *
1464
- * NOTES:
1465
- * - Called from handleEvent() on agent_end
1466
- * - Defers shutdown until agent is idle
1467
- * - Allows current streaming/compaction to complete
1468
- * - Much cleaner than immediate exit
1469
- *
1470
- * SEE ALSO:
1471
- * - shutdown() which does the actual cleanup
1472
- * - handleEvent() which calls this on agent_end
1473
- */
1474
- private checkShutdownRequested;
1475
- private handleCtrlZ;
1476
- private handleFollowUp;
1477
- private handleDequeue;
1478
- private updateEditorBorderColor;
1479
- private cycleThinkingLevel;
1480
- private cycleModel;
1481
- private toggleToolOutputExpansion;
1482
- private toggleThinkingBlockVisibility;
1483
- private openExternalEditor;
1484
- /**
1485
- * Clear the editor and request re-render.
1486
- *
1487
- * PURPOSE:
1488
- * Empties the editor text area. Used when user presses Escape with text.
1489
- */
1490
- clearEditor(): void;
1491
- /**
1492
- * Show an error message in the chat.
1493
- *
1494
- * PURPOSE:
1495
- * Display an error message to the user. Used for command failures,
1496
- * parsing errors, and unexpected exceptions.
1497
- *
1498
- * PARAMETERS:
1499
- * @param errorMessage - The error message text (without "Error:" prefix)
1500
- *
1501
- * RETURNS:
1502
- * void - side effects only
1503
- *
1504
- * FORMATTING:
1505
- * - Adds 1-line spacer before message
1506
- * - Prefixes with "Error: "
1507
- * - Uses error color from theme
1508
- * - Adds to bottom of chat
1509
- *
1510
- * NOTES:
1511
- * - Auto-calls ui.requestRender()
1512
- * - Should be used for all errors displayed to user
1513
- * - Does not throw (safe to use in error handlers)
1514
- */
1515
- showError(errorMessage: string): void;
1516
- /**
1517
- * Show a warning message in the chat.
1518
- *
1519
- * PURPOSE:
1520
- * Display a warning message to the user. Used for non-fatal issues,
1521
- * deprecated features, and important notifications.
1522
- *
1523
- * PARAMETERS:
1524
- * @param warningMessage - The warning message text (without "Warning:" prefix)
1525
- *
1526
- * RETURNS:
1527
- * void - side effects only
1528
- *
1529
- * FORMATTING:
1530
- * - Adds 1-line spacer before message
1531
- * - Prefixes with "Warning: "
1532
- * - Uses warning color from theme
1533
- * - Adds to bottom of chat
1534
- *
1535
- * NOTES:
1536
- * - Auto-calls ui.requestRender()
1537
- * - Similar to showError() but with different severity
1538
- * - Used for resource loading issues, model fallbacks, etc.
1539
- *
1540
- * SEE ALSO:
1541
- * - showError() for fatal errors
1542
- * - showStatus() for informational messages
1543
- */
1544
- showWarning(warningMessage: string): void;
1545
- showNewVersionNotification(newVersion: string): void;
1546
- /**
1547
- * Get all queued messages (read-only).
1548
- * Combines session queue and compaction queue.
1549
- */
1550
- private getAllQueuedMessages;
1551
- /**
1552
- * Clear all queued messages and return their contents.
1553
- * Clears both session queue and compaction queue.
1554
- */
1555
- private clearAllQueues;
1556
- private updatePendingMessagesDisplay;
1557
- private restoreQueuedMessagesToEditor;
1558
- private queueCompactionMessage;
1559
- private isExtensionCommand;
1560
- private flushCompactionQueue;
1561
- /** Move pending bash components from pending area to chat */
1562
- private flushPendingBashComponents;
1563
- /**
1564
- * Show a selector component, replacing the editor temporarily.
1565
- *
1566
- * PURPOSE:
1567
- * Generic helper to display selector dialogs (/settings, /model, /tree, etc.).
1568
- * Manages switching between the editor and selector, and restoring the editor.
1569
- *
1570
- * PROCESS:
1571
- * 1. Create done callback that:
1572
- * a. Clears editorContainer
1573
- * b. Restores this.editor as the focused component
1574
- * c. Requests UI render
1575
- * 2. Call factory(done) to create the selector component
1576
- * 3. Factory returns { component, focus } where focus is initial focus target
1577
- * 4. Clear editorContainer and add selector component
1578
- * 5. Set focus to the focus component (usually the selector itself)
1579
- * 6. Request UI render
1580
- * 7. Selector calls done() when user makes selection or presses escape
1581
- *
1582
- * SELECTOR TYPES:
1583
- * - SettingsSelectorComponent: /settings - change settings
1584
- * - ModelSelectorComponent: /model - select a model
1585
- * - UserMessageSelectorComponent: /fork - pick message to branch from
1586
- * - TreeSelectorComponent: /tree - navigate session DAG
1587
- * - SessionSelectorComponent: /resume - switch to different session
1588
- * - OAuthSelectorComponent: /login or /logout - manage credentials
1589
- * - ExtensionSelectorComponent: custom dialogs from extensions
1590
- *
1591
- * PARAMETERS:
1592
- * @param create - Factory function that:
1593
- * - Receives done() callback (selector calls when finished)
1594
- * - Returns { component, focus } where component is the selector UI
1595
- * - focus is the component to set focus to (keyboard input target)
1596
- *
1597
- * RETURNS:
1598
- * void - done callback handles restoration
1599
- *
1600
- * STATE CHANGES:
1601
- * - Temporarily replaces editor with selector in editorContainer
1602
- * - Sets keyboard focus to selector
1603
- * - On done: restores editor and focus
1604
- *
1605
- * NOTES:
1606
- * - Editor content is preserved (not cleared) during selector
1607
- * - Selector can be closed by pressing Escape
1608
- * - Factory receives done callback for flexible completion handling
1609
- * - Used by all major selectors (model, settings, fork, tree, etc.)
1610
- *
1611
- * SEE ALSO:
1612
- * - showModelSelector() for model selection
1613
- * - showSettingsSelector() for settings
1614
- * - showUserMessageSelector() for forking
1615
- * - showTreeSelector() for tree navigation
1616
- */
1617
- private showSelector;
1618
- private showSettingsSelector;
1619
- /**
1620
- * Handle the /model command - select or switch models.
1621
- *
1622
- * PURPOSE:
1623
- * Process /model commands. If search term provided, find exact match.
1624
- * Otherwise show interactive selector. Supports both quick switch and browse.
1625
- *
1626
- * PROCESS:
1627
- * If searchTerm provided:
1628
- * 1. Call findExactModelMatch(searchTerm)
1629
- * 2. If found: switch to model, update footer/border, show status
1630
- * 3. If not found: show selector with search term as initial filter
1631
- *
1632
- * If no searchTerm:
1633
- * 1. Show model selector dialog
1634
- * 2. User picks a model
1635
- * 3. Model is switched
1636
- *
1637
- * SEARCH FORMAT:
1638
- * - "model-id": Match by model ID only
1639
- * - "provider/model-id": Match provider and model ID
1640
- * - Case-insensitive matching
1641
- *
1642
- * PARAMETERS:
1643
- * @param searchTerm - Optional model ID or "provider/model-id" to search for
1644
- *
1645
- * RETURNS:
1646
- * Promise<void> - completes when model is selected
1647
- *
1648
- * STATE CHANGES:
1649
- * - May call session.setModel() to switch
1650
- * - Updates footer.invalidate()
1651
- * - Updates editor border color (thinking level)
1652
- * - Shows status message
1653
- *
1654
- * SEE ALSO:
1655
- * - findExactModelMatch() for model lookup
1656
- * - showModelSelector() for interactive selection
1657
- */
1658
- private handleModelCommand;
1659
- private findExactModelMatch;
1660
- private getModelCandidates;
1661
- /** Update the footer's available provider count from current model candidates */
1662
- private updateAvailableProviderCount;
1663
- private showModelSelector;
1664
- private showModelsSelector;
1665
- private showUserMessageSelector;
1666
- private showTreeSelector;
1667
- private showSessionSelector;
1668
- private handleResumeSession;
1669
- private showOAuthSelector;
1670
- /**
1671
- * Show account selector for providers with multiple accounts
1672
- */
1673
- private showAccountSelector;
1674
- /**
1675
- * Prompt for account name, then proceed with OAuth or API key login
1676
- */
1677
- private showNewAccountNameDialog;
1678
- /**
1679
- * OAuth login with a specific account name
1680
- */
1681
- private showLoginDialogWithAccountName;
1682
- /**
1683
- * API key input with a specific account name
1684
- */
1685
- private showApiKeyInputDialogWithName;
1686
- private showLoginDialog;
1687
- private showApiKeyDialog;
1688
- /**
1689
- * Show API key input dialog for adding a new account
1690
- */
1691
- private showApiKeyInputDialog;
1692
- private handleReloadCommand;
1693
- /**
1694
- * Handle MCP (Model Context Protocol) commands.
1695
- *
1696
- * Subcommands:
1697
- * - "" (empty): Show MCP status
1698
- * - "connect": Connect to MCP servers
1699
- * - "disconnect": Disconnect from MCP servers
1700
- * - "tools": List available MCP tools
1701
- */
1702
- private handleMCPCommand;
1703
- /**
1704
- * Handle /memory commands for memory system management.
1705
- * Sub-commands:
1706
- * - "" / "status": Show memory status
1707
- * - "on": Enable memory for current and future sessions
1708
- * - "off": Disable memory for current and future sessions
1709
- * - "setup <api-key>": Save OpenAI API key and enable memory
1710
- * - "clear": Clear memory for current thread
1711
- * - "working": Show working memory for current thread
1712
- * - "tools": List memory tools
1713
- */
1714
- private handleMemoryCommand;
1715
- /**
1716
- * Handle /composio commands for Composio runtime management.
1717
- * Sub-commands:
1718
- * - "" / "status": Show control-tool and hydrated-tool status
1719
- * - "enable <toolkit[,toolkit]>": Hydrate toolkit tools into the current session
1720
- * - "tools": List hydrated Composio toolkit tools
1721
- * - "accounts [toolkit[,toolkit]]": List connected accounts
1722
- * - "clear": Remove hydrated Composio toolkit tools from the current session
1723
- */
1724
- private handleComposioCommand;
1725
- private handleExportCommand;
1726
- private handleShareCommand;
1727
- private handleCopyCommand;
1728
- private handleNameCommand;
1729
- private handleSessionCommand;
1730
- private handleChangelogCommand;
1731
- /**
1732
- * Capitalize keybinding for display (e.g., "ctrl+c" -> "Ctrl+C").
1733
- */
1734
- private capitalizeKey;
1735
- /**
1736
- * Get capitalized display string for an app keybinding action.
1737
- */
1738
- private getAppKeyDisplay;
1739
- /**
1740
- * Get capitalized display string for an editor keybinding action.
1741
- */
1742
- private getEditorKeyDisplay;
1743
- private handleHotkeysCommand;
1744
- private handleClearCommand;
1745
- /**
1746
- * Handle the /debug command - write diagnostic information to file.
1747
- *
1748
- * PURPOSE:
1749
- * Generates a comprehensive debug log of the current terminal rendering state
1750
- * and agent message history. Used for troubleshooting rendering issues or
1751
- * unusual terminal behavior.
1752
- *
1753
- * PROCESS:
1754
- * 1. Get current terminal dimensions (columns x rows)
1755
- * 2. Call ui.render() to get all rendered lines at that width
1756
- * 3. Calculate visible width of each line (accounting for ANSI codes)
1757
- * 4. Collect all agent messages in JSONL format (one per line)
1758
- * 5. Write everything to debug log file (~/.indusagi/debug.log or similar)
1759
- * 6. Display success message with file path
1760
- *
1761
- * DEBUG LOG CONTENTS:
1762
- * - Timestamp of debug generation
1763
- * - Terminal dimensions (WxH)
1764
- * - Total rendered lines
1765
- * - All rendered lines with visible widths and ANSI-escaped content
1766
- * - All agent messages in JSONL format (one message object per line)
1767
- *
1768
- * PARAMETERS:
1769
- * None
1770
- *
1771
- * RETURNS:
1772
- * void - side effects only (writes file, shows status)
1773
- *
1774
- * STATE CHANGES:
1775
- * - Writes to disk (debug log file)
1776
- * - Adds status message to chat display
1777
- *
1778
- * NOTES:
1779
- * - File path: getDebugLogPath()
1780
- * - Creates parent directories if needed
1781
- * - Useful for reporting rendering bugs
1782
- * - Shows actual ANSI codes (escaped as JSON strings)
1783
- * - One message per line in JSONL section for easy parsing
1784
- */
1785
- private handleDebugCommand;
1786
- private handleArminSaysHi;
1787
- /**
1788
- * Handle bash command execution (! or !! prefix).
1789
- *
1790
- * PURPOSE:
1791
- * Executes a shell command and displays the output in a BashExecutionComponent.
1792
- * Supports including/excluding from context. Can be intercepted by extensions.
1793
- *
1794
- * PROCESS:
1795
- * 1. Emit user_bash event to extensions (if loaded)
1796
- * 2. If extension returns a result, use it (extension may intercept)
1797
- * - Extensions can run custom operations or modify commands
1798
- * 3. Otherwise execute bash command normally:
1799
- * a. Create BashExecutionComponent (shows command)
1800
- * b. If streaming: add to pendingMessagesContainer, queue for chat
1801
- * c. If idle: add directly to chatContainer
1802
- * 4. Stream output chunks to component in real-time
1803
- * 5. Mark complete with exit code and truncation status
1804
- * 6. Record result in session context
1805
- *
1806
- * CONTEXT HANDLING:
1807
- * - excludeFromContext=false (!): Output included in context for agent
1808
- * - excludeFromContext=true (!!): Output excluded from context
1809
- * - Extensions can define custom "operations" to transform output
1810
- *
1811
- * PARAMETERS:
1812
- * @param command - The bash command string (without ! or !! prefix)
1813
- * @param excludeFromContext - If true, mark output as excluded (!! prefix)
1814
- *
1815
- * RETURNS:
1816
- * Promise<void> - completes when command finishes
1817
- *
1818
- * STATE CHANGES:
1819
- * - Creates BashExecutionComponent
1820
- * - Adds to chatContainer or pendingMessagesContainer
1821
- * - Adds to pendingBashComponents if queued
1822
- * - Records bash result in session
1823
- * - Updates ui on each output chunk
1824
- *
1825
- * ERROR HANDLING:
1826
- * - Command failures caught and displayed as error message
1827
- * - Bash execution may be aborted by user (Esc)
1828
- * - Output may be truncated if too large
1829
- * - Truncation info shown with link to full output file
1830
- *
1831
- * NOTES:
1832
- * - User can check if bash is already running before executing
1833
- * - Extension can provide custom operations (e.g., parsing specific formats)
1834
- * - Output is streamed, so large outputs appear incrementally
1835
- * - Bash components moved from pending to chat on next regular message
1836
- * - Session.executeBash() handles actual execution and truncation
1837
- *
1838
- * SEE ALSO:
1839
- * - session.executeBash() for actual command execution
1840
- * - BashExecutionComponent for rendering
1841
- */
1842
- private handleBashCommand;
1843
- /**
1844
- * Handle the /compact command - manually trigger context compaction.
1845
- *
1846
- * PURPOSE:
1847
- * Allows user to manually compact the session context to reduce token usage.
1848
- * Can include custom instructions to guide the compaction process.
1849
- *
1850
- * PROCESS:
1851
- * 1. Count messages in session
1852
- * 2. If less than 2 messages: show warning and return (nothing to compact)
1853
- * 3. Otherwise call executeCompaction() with custom instructions
1854
- *
1855
- * PARAMETERS:
1856
- * @param customInstructions - Optional custom instructions for compaction process
1857
- *
1858
- * RETURNS:
1859
- * Promise<void> - completes when compaction is done
1860
- *
1861
- * NOTES:
1862
- * - User can press Esc during compaction to abort
1863
- * - Compaction may queue incoming messages
1864
- * - Custom instructions merged with default compaction prompt
1865
- *
1866
- * SEE ALSO:
1867
- * - executeCompaction() which does the actual work
1868
- * - auto-compaction (happens automatically based on context size)
1869
- */
1870
- private handleCompactCommand;
1871
- /**
1872
- * Execute context compaction (manual or automatic).
1873
- *
1874
- * PURPOSE:
1875
- * Compacts the session context to reduce token usage by summarizing old messages.
1876
- * Used both for manual /compact commands and automatic overflow-triggered compaction.
1877
- *
1878
- * PROCESS:
1879
- * 1. Stop and clear any existing loading animation
1880
- * 2. Replace escape handler to allow abort (Esc cancels compaction)
1881
- * 3. Show "Compacting context..." loader with estimated time
1882
- * 4. Call session.compact() with optional custom instructions
1883
- * 5. On success:
1884
- * a. Rebuild chat to show compacted state
1885
- * b. Add CompactionSummaryMessageComponent showing tokens saved
1886
- * c. Invalidate footer (update token counts)
1887
- * 6. On abort/error:
1888
- * a. Show error message
1889
- * b. Chat state unchanged (compaction failed)
1890
- * 7. Flush queued messages that arrived during compaction
1891
- * 8. Restore original escape handler
1892
- * 9. Clear loader
1893
- *
1894
- * CUSTOM INSTRUCTIONS:
1895
- * - Optional guidance for compaction algorithm
1896
- * - Examples: "focus on recent messages", "preserve code context", etc.
1897
- * - Merged with default compaction system prompt
1898
- *
1899
- * AUTO vs MANUAL:
1900
- * - isAuto=false (/compact command): shows "Compacting context..." label
1901
- * - isAuto=true (automatic): shows "Auto-compacting..." label
1902
- * - auto-compaction triggered by context overflow (token limit)
1903
- *
1904
- * QUEUED MESSAGES:
1905
- * - Messages sent during compaction are queued in compactionQueuedMessages
1906
- * - After compaction completes, queued messages are flushed
1907
- * - First message becomes next prompt, rest queued as steer/followUp
1908
- *
1909
- * PARAMETERS:
1910
- * @param customInstructions - Optional custom instructions for compaction
1911
- * @param isAuto - If true, shows "Auto-compacting..." (default: false)
1912
- *
1913
- * RETURNS:
1914
- * Promise<CompactionResult | undefined> - returns result or undefined on error/abort
1915
- *
1916
- * STATE CHANGES:
1917
- * - Rebuilds chatContainer
1918
- * - Updates footer
1919
- * - Clears status container
1920
- * - Restores escape handler
1921
- * - Flushes compaction queue
1922
- *
1923
- * ERROR HANDLING:
1924
- * - Compaction cancelled: shows "Compaction cancelled" error
1925
- * - Compaction failed: shows detailed error message
1926
- * - Messages queued during compaction are preserved and flushed
1927
- *
1928
- * NOTES:
1929
- * - User can press Esc to abort
1930
- * - Loader shows "Ctrl+C to cancel" hint
1931
- * - Compaction happens asynchronously, UI stays responsive
1932
- * - Very large contexts may take several seconds
1933
- *
1934
- * SEE ALSO:
1935
- * - handleCompactCommand() for /compact processing
1936
- * - auto-compaction in handleEvent() for automatic triggering
1937
- */
1938
- private executeCompaction;
1939
- stop(): void;
1940
- }
1941
- //# sourceMappingURL=interactive-mode.d.ts.map