@humain/terminal 0.0.4-beta.1 → 0.0.5

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 (675) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +1 -0
  3. package/dist/bun/cli.d.ts.map +1 -1
  4. package/dist/bun/cli.js.map +1 -1
  5. package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
  6. package/dist/bun/restore-sandbox-env.js.map +1 -1
  7. package/dist/cli/args.d.ts +1 -0
  8. package/dist/cli/args.d.ts.map +1 -1
  9. package/dist/cli/args.js +11 -0
  10. package/dist/cli/args.js.map +1 -1
  11. package/dist/cli/auth-check.d.ts.map +1 -1
  12. package/dist/cli/auth-check.js.map +1 -1
  13. package/dist/cli/auth-command.d.ts.map +1 -1
  14. package/dist/cli/auth-command.js.map +1 -1
  15. package/dist/cli/config-selector.d.ts.map +1 -1
  16. package/dist/cli/config-selector.js.map +1 -1
  17. package/dist/cli/credential-print.d.ts.map +1 -1
  18. package/dist/cli/credential-print.js.map +1 -1
  19. package/dist/cli/experimental/auth.d.ts.map +1 -1
  20. package/dist/cli/experimental/auth.js.map +1 -1
  21. package/dist/cli/experimental/cli.d.ts.map +1 -1
  22. package/dist/cli/experimental/command-options.d.ts.map +1 -1
  23. package/dist/cli/experimental/command-options.js.map +1 -1
  24. package/dist/cli/experimental/command.d.ts.map +1 -1
  25. package/dist/cli/experimental/command.js +2 -5
  26. package/dist/cli/experimental/command.js.map +1 -1
  27. package/dist/cli/experimental/commands/client.d.ts.map +1 -1
  28. package/dist/cli/experimental/commands/client.js.map +1 -1
  29. package/dist/cli/experimental/commands/pi.d.ts.map +1 -1
  30. package/dist/cli/experimental/commands/pi.js.map +1 -1
  31. package/dist/cli/experimental/commands/server.d.ts.map +1 -1
  32. package/dist/cli/experimental/commands/server.js.map +1 -1
  33. package/dist/cli/experimental/transport-address.d.ts.map +1 -1
  34. package/dist/cli/experimental/transport-address.js.map +1 -1
  35. package/dist/cli/file-processor.d.ts.map +1 -1
  36. package/dist/cli/file-processor.js.map +1 -1
  37. package/dist/cli/initial-message.d.ts +1 -1
  38. package/dist/cli/initial-message.d.ts.map +1 -1
  39. package/dist/cli/initial-message.js.map +1 -1
  40. package/dist/cli/list-models.d.ts.map +1 -1
  41. package/dist/cli/list-models.js.map +1 -1
  42. package/dist/cli/project-trust.d.ts.map +1 -1
  43. package/dist/cli/project-trust.js.map +1 -1
  44. package/dist/cli/session-picker.d.ts.map +1 -1
  45. package/dist/cli/session-picker.js.map +1 -1
  46. package/dist/cli/startup-ui.d.ts.map +1 -1
  47. package/dist/cli/startup-ui.js.map +1 -1
  48. package/dist/cli.d.ts.map +1 -1
  49. package/dist/cli.js.map +1 -1
  50. package/dist/client/index.d.ts.map +1 -1
  51. package/dist/client/remote-session.d.ts.map +1 -1
  52. package/dist/client/remote-session.js.map +1 -1
  53. package/dist/client/transcript.d.ts.map +1 -1
  54. package/dist/client/transcript.js +1 -1
  55. package/dist/client/transcript.js.map +1 -1
  56. package/dist/config.d.ts.map +1 -1
  57. package/dist/config.js.map +1 -1
  58. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  59. package/dist/core/agent-session-runtime.js +0 -8
  60. package/dist/core/agent-session-runtime.js.map +1 -1
  61. package/dist/core/agent-session-services.d.ts.map +1 -1
  62. package/dist/core/agent-session-services.js.map +1 -1
  63. package/dist/core/agent-session.d.ts +36 -2
  64. package/dist/core/agent-session.d.ts.map +1 -1
  65. package/dist/core/agent-session.js +100 -128
  66. package/dist/core/agent-session.js.map +1 -1
  67. package/dist/core/auth-guidance.d.ts.map +1 -1
  68. package/dist/core/auth-guidance.js.map +1 -1
  69. package/dist/core/auth-storage.d.ts.map +1 -1
  70. package/dist/core/auth-storage.js +3 -8
  71. package/dist/core/auth-storage.js.map +1 -1
  72. package/dist/core/bash-executor.d.ts.map +1 -1
  73. package/dist/core/bash-executor.js.map +1 -1
  74. package/dist/core/cache-stats.d.ts.map +1 -1
  75. package/dist/core/cache-stats.js.map +1 -1
  76. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  77. package/dist/core/compaction/branch-summarization.js.map +1 -1
  78. package/dist/core/compaction/compaction.d.ts.map +1 -1
  79. package/dist/core/compaction/compaction.js.map +1 -1
  80. package/dist/core/compaction/index.d.ts.map +1 -1
  81. package/dist/core/compaction/utils.d.ts.map +1 -1
  82. package/dist/core/compaction/utils.js.map +1 -1
  83. package/dist/core/defaults.d.ts.map +1 -1
  84. package/dist/core/diagnostics.d.ts.map +1 -1
  85. package/dist/core/event-bus.d.ts.map +1 -1
  86. package/dist/core/event-bus.js.map +1 -1
  87. package/dist/core/exec.d.ts.map +1 -1
  88. package/dist/core/exec.js.map +1 -1
  89. package/dist/core/experimental.d.ts +4 -0
  90. package/dist/core/experimental.d.ts.map +1 -1
  91. package/dist/core/experimental.js +4 -0
  92. package/dist/core/experimental.js.map +1 -1
  93. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  94. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  95. package/dist/core/export-html/index.d.ts.map +1 -1
  96. package/dist/core/export-html/index.js.map +1 -1
  97. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  98. package/dist/core/export-html/tool-renderer.js.map +1 -1
  99. package/dist/core/extensions/index.d.ts.map +1 -1
  100. package/dist/core/extensions/loader.d.ts.map +1 -1
  101. package/dist/core/extensions/loader.js.map +1 -1
  102. package/dist/core/extensions/runner.d.ts.map +1 -1
  103. package/dist/core/extensions/runner.js +22 -30
  104. package/dist/core/extensions/runner.js.map +1 -1
  105. package/dist/core/extensions/types.d.ts +4 -0
  106. package/dist/core/extensions/types.d.ts.map +1 -1
  107. package/dist/core/extensions/types.js.map +1 -1
  108. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  109. package/dist/core/extensions/wrapper.js.map +1 -1
  110. package/dist/core/footer-data-provider.d.ts.map +1 -1
  111. package/dist/core/footer-data-provider.js +17 -18
  112. package/dist/core/footer-data-provider.js.map +1 -1
  113. package/dist/core/http-dispatcher.d.ts.map +1 -1
  114. package/dist/core/http-dispatcher.js.map +1 -1
  115. package/dist/core/index.d.ts.map +1 -1
  116. package/dist/core/keybindings.d.ts +24 -0
  117. package/dist/core/keybindings.d.ts.map +1 -1
  118. package/dist/core/keybindings.js +0 -1
  119. package/dist/core/keybindings.js.map +1 -1
  120. package/dist/core/messages.d.ts.map +1 -1
  121. package/dist/core/messages.js.map +1 -1
  122. package/dist/core/model-config.d.ts +5 -0
  123. package/dist/core/model-config.d.ts.map +1 -1
  124. package/dist/core/model-config.js +1 -2
  125. package/dist/core/model-config.js.map +1 -1
  126. package/dist/core/model-registry.d.ts.map +1 -1
  127. package/dist/core/model-registry.js +0 -1
  128. package/dist/core/model-registry.js.map +1 -1
  129. package/dist/core/model-resolver.d.ts.map +1 -1
  130. package/dist/core/model-resolver.js.map +1 -1
  131. package/dist/core/model-runtime.d.ts.map +1 -1
  132. package/dist/core/model-runtime.js +15 -25
  133. package/dist/core/model-runtime.js.map +1 -1
  134. package/dist/core/models-store.d.ts.map +1 -1
  135. package/dist/core/models-store.js +3 -4
  136. package/dist/core/models-store.js.map +1 -1
  137. package/dist/core/output-guard.d.ts.map +1 -1
  138. package/dist/core/output-guard.js.map +1 -1
  139. package/dist/core/package-manager.d.ts.map +1 -1
  140. package/dist/core/package-manager.js +0 -7
  141. package/dist/core/package-manager.js.map +1 -1
  142. package/dist/core/pi-manifest.d.ts.map +1 -1
  143. package/dist/core/pi-manifest.js.map +1 -1
  144. package/dist/core/project-trust.d.ts.map +1 -1
  145. package/dist/core/project-trust.js.map +1 -1
  146. package/dist/core/prompt-templates.d.ts.map +1 -1
  147. package/dist/core/prompt-templates.js.map +1 -1
  148. package/dist/core/provider-attribution.d.ts.map +1 -1
  149. package/dist/core/provider-attribution.js.map +1 -1
  150. package/dist/core/provider-composer.d.ts.map +1 -1
  151. package/dist/core/provider-composer.js.map +1 -1
  152. package/dist/core/radius.d.ts.map +1 -1
  153. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  154. package/dist/core/remote-catalog-provider.js.map +1 -1
  155. package/dist/core/resolve-config-value.d.ts.map +1 -1
  156. package/dist/core/resolve-config-value.js.map +1 -1
  157. package/dist/core/resource-loader.d.ts.map +1 -1
  158. package/dist/core/resource-loader.js +0 -44
  159. package/dist/core/resource-loader.js.map +1 -1
  160. package/dist/core/runtime-credentials.d.ts.map +1 -1
  161. package/dist/core/runtime-credentials.js +1 -2
  162. package/dist/core/runtime-credentials.js.map +1 -1
  163. package/dist/core/sdk.d.ts +5 -3
  164. package/dist/core/sdk.d.ts.map +1 -1
  165. package/dist/core/sdk.js +2 -1
  166. package/dist/core/sdk.js.map +1 -1
  167. package/dist/core/session-cwd.d.ts.map +1 -1
  168. package/dist/core/session-cwd.js +0 -1
  169. package/dist/core/session-cwd.js.map +1 -1
  170. package/dist/core/session-manager.d.ts.map +1 -1
  171. package/dist/core/session-manager.js +9 -13
  172. package/dist/core/session-manager.js.map +1 -1
  173. package/dist/core/settings-manager.d.ts +6 -0
  174. package/dist/core/settings-manager.d.ts.map +1 -1
  175. package/dist/core/settings-manager.js +19 -17
  176. package/dist/core/settings-manager.js.map +1 -1
  177. package/dist/core/skills.d.ts.map +1 -1
  178. package/dist/core/skills.js.map +1 -1
  179. package/dist/core/slash-commands.d.ts.map +1 -1
  180. package/dist/core/source-info.d.ts.map +1 -1
  181. package/dist/core/source-info.js.map +1 -1
  182. package/dist/core/system-prompt.d.ts.map +1 -1
  183. package/dist/core/system-prompt.js +1 -1
  184. package/dist/core/system-prompt.js.map +1 -1
  185. package/dist/core/telemetry.d.ts.map +1 -1
  186. package/dist/core/telemetry.js.map +1 -1
  187. package/dist/core/timings.d.ts.map +1 -1
  188. package/dist/core/timings.js.map +1 -1
  189. package/dist/core/tools/bash.d.ts.map +1 -1
  190. package/dist/core/tools/bash.js +10 -5
  191. package/dist/core/tools/bash.js.map +1 -1
  192. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  193. package/dist/core/tools/edit-diff.js.map +1 -1
  194. package/dist/core/tools/edit.d.ts.map +1 -1
  195. package/dist/core/tools/edit.js +2 -0
  196. package/dist/core/tools/edit.js.map +1 -1
  197. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  198. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  199. package/dist/core/tools/find.d.ts +1 -1
  200. package/dist/core/tools/find.d.ts.map +1 -1
  201. package/dist/core/tools/find.js +1 -1
  202. package/dist/core/tools/find.js.map +1 -1
  203. package/dist/core/tools/grep.d.ts.map +1 -1
  204. package/dist/core/tools/grep.js +1 -1
  205. package/dist/core/tools/grep.js.map +1 -1
  206. package/dist/core/tools/index.d.ts.map +1 -1
  207. package/dist/core/tools/index.js.map +1 -1
  208. package/dist/core/tools/ls.d.ts.map +1 -1
  209. package/dist/core/tools/ls.js.map +1 -1
  210. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  211. package/dist/core/tools/output-accumulator.js +12 -18
  212. package/dist/core/tools/output-accumulator.js.map +1 -1
  213. package/dist/core/tools/path-utils.d.ts.map +1 -1
  214. package/dist/core/tools/path-utils.js.map +1 -1
  215. package/dist/core/tools/read.d.ts.map +1 -1
  216. package/dist/core/tools/read.js +2 -0
  217. package/dist/core/tools/read.js.map +1 -1
  218. package/dist/core/tools/render-utils.d.ts.map +1 -1
  219. package/dist/core/tools/render-utils.js.map +1 -1
  220. package/dist/core/tools/subagent.d.ts +3 -0
  221. package/dist/core/tools/subagent.d.ts.map +1 -1
  222. package/dist/core/tools/subagent.js +30 -9
  223. package/dist/core/tools/subagent.js.map +1 -1
  224. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  225. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  226. package/dist/core/tools/truncate.d.ts.map +1 -1
  227. package/dist/core/tools/truncate.js.map +1 -1
  228. package/dist/core/tools/write.d.ts.map +1 -1
  229. package/dist/core/tools/write.js +2 -1
  230. package/dist/core/tools/write.js.map +1 -1
  231. package/dist/core/trust-manager.d.ts.map +1 -1
  232. package/dist/core/trust-manager.js +0 -1
  233. package/dist/core/trust-manager.js.map +1 -1
  234. package/dist/core/usage-totals.d.ts.map +1 -1
  235. package/dist/core/usage-totals.js.map +1 -1
  236. package/dist/extensions/index.d.ts.map +1 -1
  237. package/dist/extensions/llama/client.d.ts.map +1 -1
  238. package/dist/extensions/llama/client.js +0 -2
  239. package/dist/extensions/llama/client.js.map +1 -1
  240. package/dist/extensions/llama/huggingface.d.ts.map +1 -1
  241. package/dist/extensions/llama/huggingface.js +0 -2
  242. package/dist/extensions/llama/huggingface.js.map +1 -1
  243. package/dist/extensions/llama/index.d.ts.map +1 -1
  244. package/dist/extensions/llama/index.js.map +1 -1
  245. package/dist/extensions/llama/provider.d.ts.map +1 -1
  246. package/dist/extensions/llama/provider.js.map +1 -1
  247. package/dist/extensions/llama/ui.d.ts.map +1 -1
  248. package/dist/extensions/llama/ui.js +12 -28
  249. package/dist/extensions/llama/ui.js.map +1 -1
  250. package/dist/humain/agent-execution-protocol.d.ts.map +1 -1
  251. package/dist/humain/agent-execution-protocol.js.map +1 -1
  252. package/dist/humain/agent-execution-runtime.d.ts.map +1 -1
  253. package/dist/humain/agent-execution-runtime.js.map +1 -1
  254. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +127 -7
  255. package/dist/humain/brand-logo.d.ts.map +1 -1
  256. package/dist/humain/index.d.ts.map +1 -1
  257. package/dist/humain/index.js.map +1 -1
  258. package/dist/humain/legacy-workflow-tiers.d.ts.map +1 -1
  259. package/dist/humain/legacy-workflow-tiers.js.map +1 -1
  260. package/dist/humain/mcp-adapter/vendor/package.json +3 -3
  261. package/dist/humain/mcp-adapter.d.ts.map +1 -1
  262. package/dist/humain/mcp-adapter.js.map +1 -1
  263. package/dist/humain/pi-agent-execution-host.d.ts.map +1 -1
  264. package/dist/humain/pi-agent-execution-host.js.map +1 -1
  265. package/dist/humain/web-access/host.d.ts.map +1 -1
  266. package/dist/humain/web-access/index.d.ts.map +1 -1
  267. package/dist/humain/web-access/index.js.map +1 -1
  268. package/dist/humain/web-access/vendor/activity.d.ts.map +1 -1
  269. package/dist/humain/web-access/vendor/activity.js +7 -5
  270. package/dist/humain/web-access/vendor/activity.js.map +1 -1
  271. package/dist/humain/web-access/vendor/anysearch.d.ts.map +1 -1
  272. package/dist/humain/web-access/vendor/anysearch.js.map +1 -1
  273. package/dist/humain/web-access/vendor/auth-fetch.d.ts.map +1 -1
  274. package/dist/humain/web-access/vendor/auth-fetch.js.map +1 -1
  275. package/dist/humain/web-access/vendor/bocha.d.ts.map +1 -1
  276. package/dist/humain/web-access/vendor/bocha.js.map +1 -1
  277. package/dist/humain/web-access/vendor/brave.d.ts.map +1 -1
  278. package/dist/humain/web-access/vendor/brave.js.map +1 -1
  279. package/dist/humain/web-access/vendor/brightdata-unlocker.d.ts.map +1 -1
  280. package/dist/humain/web-access/vendor/brightdata-unlocker.js.map +1 -1
  281. package/dist/humain/web-access/vendor/brightdata.d.ts.map +1 -1
  282. package/dist/humain/web-access/vendor/brightdata.js.map +1 -1
  283. package/dist/humain/web-access/vendor/chrome-cookies.d.ts.map +1 -1
  284. package/dist/humain/web-access/vendor/chrome-cookies.js +101 -19
  285. package/dist/humain/web-access/vendor/chrome-cookies.js.map +1 -1
  286. package/dist/humain/web-access/vendor/content-find.d.ts.map +1 -1
  287. package/dist/humain/web-access/vendor/content-find.js.map +1 -1
  288. package/dist/humain/web-access/vendor/credential-source.d.ts.map +1 -1
  289. package/dist/humain/web-access/vendor/credential-source.js +0 -2
  290. package/dist/humain/web-access/vendor/credential-source.js.map +1 -1
  291. package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
  292. package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
  293. package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
  294. package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
  295. package/dist/humain/web-access/vendor/data-uri-sanitize.d.ts +21 -0
  296. package/dist/humain/web-access/vendor/data-uri-sanitize.d.ts.map +1 -0
  297. package/dist/humain/web-access/vendor/data-uri-sanitize.js +373 -0
  298. package/dist/humain/web-access/vendor/data-uri-sanitize.js.map +1 -0
  299. package/dist/humain/web-access/vendor/datalab-pdf-extract.d.ts.map +1 -1
  300. package/dist/humain/web-access/vendor/datalab-pdf-extract.js.map +1 -1
  301. package/dist/humain/web-access/vendor/declared-web-links.d.ts.map +1 -1
  302. package/dist/humain/web-access/vendor/declared-web-links.js.map +1 -1
  303. package/dist/humain/web-access/vendor/duckduckgo.d.ts.map +1 -1
  304. package/dist/humain/web-access/vendor/duckduckgo.js.map +1 -1
  305. package/dist/humain/web-access/vendor/exa.d.ts.map +1 -1
  306. package/dist/humain/web-access/vendor/exa.js.map +1 -1
  307. package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
  308. package/dist/humain/web-access/vendor/extract.js +14 -2
  309. package/dist/humain/web-access/vendor/extract.js.map +1 -1
  310. package/dist/humain/web-access/vendor/feature-config.d.ts.map +1 -1
  311. package/dist/humain/web-access/vendor/feature-config.js.map +1 -1
  312. package/dist/humain/web-access/vendor/fetch-params.d.ts.map +1 -1
  313. package/dist/humain/web-access/vendor/fetch-params.js.map +1 -1
  314. package/dist/humain/web-access/vendor/firecrawl.d.ts.map +1 -1
  315. package/dist/humain/web-access/vendor/firecrawl.js +15 -2
  316. package/dist/humain/web-access/vendor/firecrawl.js.map +1 -1
  317. package/dist/humain/web-access/vendor/gemini-api.d.ts.map +1 -1
  318. package/dist/humain/web-access/vendor/gemini-api.js.map +1 -1
  319. package/dist/humain/web-access/vendor/gemini-pdf-extract.d.ts.map +1 -1
  320. package/dist/humain/web-access/vendor/gemini-pdf-extract.js.map +1 -1
  321. package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
  322. package/dist/humain/web-access/vendor/gemini-search.js +30 -16
  323. package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
  324. package/dist/humain/web-access/vendor/gemini-url-context.d.ts.map +1 -1
  325. package/dist/humain/web-access/vendor/gemini-url-context.js.map +1 -1
  326. package/dist/humain/web-access/vendor/gemini-web-config.d.ts.map +1 -1
  327. package/dist/humain/web-access/vendor/gemini-web-config.js.map +1 -1
  328. package/dist/humain/web-access/vendor/gemini-web.d.ts.map +1 -1
  329. package/dist/humain/web-access/vendor/gemini-web.js.map +1 -1
  330. package/dist/humain/web-access/vendor/github-api.d.ts.map +1 -1
  331. package/dist/humain/web-access/vendor/github-api.js.map +1 -1
  332. package/dist/humain/web-access/vendor/github-extract.d.ts.map +1 -1
  333. package/dist/humain/web-access/vendor/github-extract.js +69 -35
  334. package/dist/humain/web-access/vendor/github-extract.js.map +1 -1
  335. package/dist/humain/web-access/vendor/index.d.ts +74 -1
  336. package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
  337. package/dist/humain/web-access/vendor/index.js +38 -15
  338. package/dist/humain/web-access/vendor/index.js.map +1 -1
  339. package/dist/humain/web-access/vendor/jina-search.d.ts.map +1 -1
  340. package/dist/humain/web-access/vendor/jina-search.js.map +1 -1
  341. package/dist/humain/web-access/vendor/kagi.d.ts.map +1 -1
  342. package/dist/humain/web-access/vendor/kagi.js.map +1 -1
  343. package/dist/humain/web-access/vendor/ollama.d.ts.map +1 -1
  344. package/dist/humain/web-access/vendor/ollama.js.map +1 -1
  345. package/dist/humain/web-access/vendor/openai-search.d.ts +1 -1
  346. package/dist/humain/web-access/vendor/openai-search.d.ts.map +1 -1
  347. package/dist/humain/web-access/vendor/openai-search.js +15 -5
  348. package/dist/humain/web-access/vendor/openai-search.js.map +1 -1
  349. package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
  350. package/dist/humain/web-access/vendor/page-query.js.map +1 -1
  351. package/dist/humain/web-access/vendor/parallel-mcp.d.ts.map +1 -1
  352. package/dist/humain/web-access/vendor/parallel-mcp.js.map +1 -1
  353. package/dist/humain/web-access/vendor/parallel.d.ts.map +1 -1
  354. package/dist/humain/web-access/vendor/parallel.js.map +1 -1
  355. package/dist/humain/web-access/vendor/pdf-extract.d.ts +1 -0
  356. package/dist/humain/web-access/vendor/pdf-extract.d.ts.map +1 -1
  357. package/dist/humain/web-access/vendor/pdf-extract.js +15 -5
  358. package/dist/humain/web-access/vendor/pdf-extract.js.map +1 -1
  359. package/dist/humain/web-access/vendor/perplexity.d.ts.map +1 -1
  360. package/dist/humain/web-access/vendor/perplexity.js.map +1 -1
  361. package/dist/humain/web-access/vendor/querit.d.ts.map +1 -1
  362. package/dist/humain/web-access/vendor/querit.js.map +1 -1
  363. package/dist/humain/web-access/vendor/query-rewrite.d.ts.map +1 -1
  364. package/dist/humain/web-access/vendor/query-rewrite.js.map +1 -1
  365. package/dist/humain/web-access/vendor/render-search-error.d.ts.map +1 -1
  366. package/dist/humain/web-access/vendor/render-search-error.js.map +1 -1
  367. package/dist/humain/web-access/vendor/rsc-extract.d.ts.map +1 -1
  368. package/dist/humain/web-access/vendor/rsc-extract.js.map +1 -1
  369. package/dist/humain/web-access/vendor/search1api.d.ts.map +1 -1
  370. package/dist/humain/web-access/vendor/search1api.js.map +1 -1
  371. package/dist/humain/web-access/vendor/searchinfinity.d.ts.map +1 -1
  372. package/dist/humain/web-access/vendor/searchinfinity.js.map +1 -1
  373. package/dist/humain/web-access/vendor/searxng.d.ts.map +1 -1
  374. package/dist/humain/web-access/vendor/searxng.js.map +1 -1
  375. package/dist/humain/web-access/vendor/serpbase.d.ts.map +1 -1
  376. package/dist/humain/web-access/vendor/serpbase.js.map +1 -1
  377. package/dist/humain/web-access/vendor/serpdive.d.ts.map +1 -1
  378. package/dist/humain/web-access/vendor/serpdive.js.map +1 -1
  379. package/dist/humain/web-access/vendor/serper.d.ts.map +1 -1
  380. package/dist/humain/web-access/vendor/serper.js.map +1 -1
  381. package/dist/humain/web-access/vendor/source-check.d.ts.map +1 -1
  382. package/dist/humain/web-access/vendor/source-check.js.map +1 -1
  383. package/dist/humain/web-access/vendor/ssrf-protection.d.ts +2 -0
  384. package/dist/humain/web-access/vendor/ssrf-protection.d.ts.map +1 -1
  385. package/dist/humain/web-access/vendor/ssrf-protection.js +11 -2
  386. package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -1
  387. package/dist/humain/web-access/vendor/storage.d.ts.map +1 -1
  388. package/dist/humain/web-access/vendor/storage.js.map +1 -1
  389. package/dist/humain/web-access/vendor/summary-model-scope.d.ts.map +1 -1
  390. package/dist/humain/web-access/vendor/summary-model-scope.js.map +1 -1
  391. package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -1
  392. package/dist/humain/web-access/vendor/summary-review.js.map +1 -1
  393. package/dist/humain/web-access/vendor/tavily.d.ts.map +1 -1
  394. package/dist/humain/web-access/vendor/tavily.js.map +1 -1
  395. package/dist/humain/web-access/vendor/tinyfish.d.ts.map +1 -1
  396. package/dist/humain/web-access/vendor/tinyfish.js.map +1 -1
  397. package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
  398. package/dist/humain/web-access/vendor/utils.js.map +1 -1
  399. package/dist/humain/web-access/vendor/valyu.d.ts.map +1 -1
  400. package/dist/humain/web-access/vendor/valyu.js.map +1 -1
  401. package/dist/humain/web-access/vendor/video-extract.d.ts.map +1 -1
  402. package/dist/humain/web-access/vendor/video-extract.js.map +1 -1
  403. package/dist/humain/web-access/vendor/xai-search.d.ts.map +1 -1
  404. package/dist/humain/web-access/vendor/xai-search.js.map +1 -1
  405. package/dist/humain/web-access/vendor/youtube-extract.d.ts.map +1 -1
  406. package/dist/humain/web-access/vendor/youtube-extract.js.map +1 -1
  407. package/dist/index.d.ts +1 -1
  408. package/dist/index.d.ts.map +1 -1
  409. package/dist/index.js.map +1 -1
  410. package/dist/main.d.ts.map +1 -1
  411. package/dist/main.js +4 -0
  412. package/dist/main.js.map +1 -1
  413. package/dist/migrations.d.ts.map +1 -1
  414. package/dist/migrations.js.map +1 -1
  415. package/dist/modes/agent-exec-mode.d.ts.map +1 -1
  416. package/dist/modes/agent-exec-mode.js.map +1 -1
  417. package/dist/modes/index.d.ts.map +1 -1
  418. package/dist/modes/interactive/components/armin.d.ts.map +1 -1
  419. package/dist/modes/interactive/components/armin.js +6 -10
  420. package/dist/modes/interactive/components/armin.js.map +1 -1
  421. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  422. package/dist/modes/interactive/components/assistant-message.js +2 -9
  423. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  424. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  425. package/dist/modes/interactive/components/bash-execution.js +4 -9
  426. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  427. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  428. package/dist/modes/interactive/components/bordered-loader.js +0 -3
  429. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  430. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  431. package/dist/modes/interactive/components/branch-summary-message.js +1 -3
  432. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  433. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  434. package/dist/modes/interactive/components/compaction-summary-message.js +1 -3
  435. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  436. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  437. package/dist/modes/interactive/components/config-selector.js +5 -22
  438. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  439. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  440. package/dist/modes/interactive/components/countdown-timer.js +0 -5
  441. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  442. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  443. package/dist/modes/interactive/components/custom-editor.js +1 -8
  444. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  445. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  446. package/dist/modes/interactive/components/custom-entry.js +1 -4
  447. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  448. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  449. package/dist/modes/interactive/components/custom-message.js +1 -7
  450. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  451. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  452. package/dist/modes/interactive/components/daxnuts.js +6 -8
  453. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  454. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  455. package/dist/modes/interactive/components/diff.js +2 -2
  456. package/dist/modes/interactive/components/diff.js.map +1 -1
  457. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  458. package/dist/modes/interactive/components/dynamic-border.js +0 -1
  459. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  460. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  461. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  462. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  463. package/dist/modes/interactive/components/extension-editor.js +1 -7
  464. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  465. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  466. package/dist/modes/interactive/components/extension-input.js +2 -8
  467. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  468. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  469. package/dist/modes/interactive/components/extension-selector.js +1 -9
  470. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  471. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  472. package/dist/modes/interactive/components/first-time-setup.js +2 -4
  473. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  474. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  475. package/dist/modes/interactive/components/footer.js +1 -3
  476. package/dist/modes/interactive/components/footer.js.map +1 -1
  477. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  478. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  479. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  480. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  481. package/dist/modes/interactive/components/login-dialog.js +3 -9
  482. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  483. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
  484. package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
  485. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  486. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  487. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  488. package/dist/modes/interactive/components/model-selector.js +14 -26
  489. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  490. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  491. package/dist/modes/interactive/components/oauth-selector.js +3 -11
  492. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  493. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  494. package/dist/modes/interactive/components/scoped-models-selector.js +9 -14
  495. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  496. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  497. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  498. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  499. package/dist/modes/interactive/components/session-selector.js +33 -57
  500. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  501. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  502. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  503. package/dist/modes/interactive/components/settings-selector.js +10 -14
  504. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  505. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  506. package/dist/modes/interactive/components/show-images-selector.js +0 -1
  507. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  508. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  509. package/dist/modes/interactive/components/skill-invocation-message.js +1 -3
  510. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  511. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  512. package/dist/modes/interactive/components/status-indicator.js +0 -2
  513. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  514. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  515. package/dist/modes/interactive/components/theme-selector.js +0 -2
  516. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  517. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  518. package/dist/modes/interactive/components/thinking-selector.js +0 -1
  519. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  520. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  521. package/dist/modes/interactive/components/tool-execution.js +19 -25
  522. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  523. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  524. package/dist/modes/interactive/components/tree-selector.js +18 -34
  525. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  526. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
  527. package/dist/modes/interactive/components/trust-selector.js +0 -6
  528. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  529. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  530. package/dist/modes/interactive/components/user-message-selector.js +3 -6
  531. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  532. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  533. package/dist/modes/interactive/components/user-message.js +0 -4
  534. package/dist/modes/interactive/components/user-message.js.map +1 -1
  535. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  536. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  537. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  538. package/dist/modes/interactive/external-editor.js.map +1 -1
  539. package/dist/modes/interactive/interactive-mode.d.ts +18 -2
  540. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  541. package/dist/modes/interactive/interactive-mode.js +147 -137
  542. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  543. package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
  544. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
  545. package/dist/modes/interactive/model-catalog-refresh.js +36 -0
  546. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
  547. package/dist/modes/interactive/model-search.d.ts.map +1 -1
  548. package/dist/modes/interactive/model-search.js.map +1 -1
  549. package/dist/modes/interactive/theme/dark.json +2 -0
  550. package/dist/modes/interactive/theme/light.json +2 -0
  551. package/dist/modes/interactive/theme/theme-controller.d.ts +10 -2
  552. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  553. package/dist/modes/interactive/theme/theme-controller.js +25 -18
  554. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  555. package/dist/modes/interactive/theme/theme-schema.json +9 -1
  556. package/dist/modes/interactive/theme/theme.d.ts +7 -5
  557. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  558. package/dist/modes/interactive/theme/theme.js +12 -8
  559. package/dist/modes/interactive/theme/theme.js.map +1 -1
  560. package/dist/modes/json-event.d.ts +4 -1
  561. package/dist/modes/json-event.d.ts.map +1 -1
  562. package/dist/modes/json-event.js +5 -2
  563. package/dist/modes/json-event.js.map +1 -1
  564. package/dist/modes/print-mode.d.ts.map +1 -1
  565. package/dist/modes/print-mode.js.map +1 -1
  566. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  567. package/dist/modes/rpc/jsonl.js.map +1 -1
  568. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  569. package/dist/modes/rpc/rpc-client.js +9 -10
  570. package/dist/modes/rpc/rpc-client.js.map +1 -1
  571. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  572. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  573. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  574. package/dist/package-manager-cli.d.ts.map +1 -1
  575. package/dist/package-manager-cli.js.map +1 -1
  576. package/dist/rpc-entry.d.ts.map +1 -1
  577. package/dist/rpc-entry.js.map +1 -1
  578. package/dist/server/create-harness.d.ts.map +1 -1
  579. package/dist/server/create-harness.js +2 -0
  580. package/dist/server/create-harness.js.map +1 -1
  581. package/dist/utils/abort.d.ts.map +1 -1
  582. package/dist/utils/abort.js.map +1 -1
  583. package/dist/utils/ansi.d.ts.map +1 -1
  584. package/dist/utils/ansi.js.map +1 -1
  585. package/dist/utils/changelog.d.ts.map +1 -1
  586. package/dist/utils/changelog.js.map +1 -1
  587. package/dist/utils/child-process.d.ts.map +1 -1
  588. package/dist/utils/child-process.js.map +1 -1
  589. package/dist/utils/clipboard-image.d.ts.map +1 -1
  590. package/dist/utils/clipboard-image.js +1 -1
  591. package/dist/utils/clipboard-image.js.map +1 -1
  592. package/dist/utils/clipboard-native.d.ts.map +1 -1
  593. package/dist/utils/clipboard-native.js.map +1 -1
  594. package/dist/utils/clipboard.d.ts.map +1 -1
  595. package/dist/utils/clipboard.js.map +1 -1
  596. package/dist/utils/deprecation.d.ts.map +1 -1
  597. package/dist/utils/deprecation.js.map +1 -1
  598. package/dist/utils/exif-orientation.d.ts.map +1 -1
  599. package/dist/utils/exif-orientation.js.map +1 -1
  600. package/dist/utils/frontmatter.d.ts.map +1 -1
  601. package/dist/utils/frontmatter.js.map +1 -1
  602. package/dist/utils/fs-watch.d.ts.map +1 -1
  603. package/dist/utils/fs-watch.js.map +1 -1
  604. package/dist/utils/git.d.ts.map +1 -1
  605. package/dist/utils/git.js.map +1 -1
  606. package/dist/utils/html.d.ts.map +1 -1
  607. package/dist/utils/html.js.map +1 -1
  608. package/dist/utils/image-convert.d.ts.map +1 -1
  609. package/dist/utils/image-convert.js.map +1 -1
  610. package/dist/utils/image-process.d.ts.map +1 -1
  611. package/dist/utils/image-process.js.map +1 -1
  612. package/dist/utils/image-resize-core.d.ts.map +1 -1
  613. package/dist/utils/image-resize-core.js.map +1 -1
  614. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  615. package/dist/utils/image-resize-worker.js.map +1 -1
  616. package/dist/utils/image-resize.d.ts.map +1 -1
  617. package/dist/utils/image-resize.js.map +1 -1
  618. package/dist/utils/json.d.ts.map +1 -1
  619. package/dist/utils/json.js.map +1 -1
  620. package/dist/utils/management-http.d.ts.map +1 -1
  621. package/dist/utils/management-http.js.map +1 -1
  622. package/dist/utils/mime.d.ts.map +1 -1
  623. package/dist/utils/mime.js.map +1 -1
  624. package/dist/utils/open-browser.d.ts.map +1 -1
  625. package/dist/utils/open-browser.js.map +1 -1
  626. package/dist/utils/paths.d.ts.map +1 -1
  627. package/dist/utils/paths.js.map +1 -1
  628. package/dist/utils/photon.d.ts.map +1 -1
  629. package/dist/utils/photon.js.map +1 -1
  630. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  631. package/dist/utils/pi-user-agent.js.map +1 -1
  632. package/dist/utils/shell.d.ts.map +1 -1
  633. package/dist/utils/shell.js.map +1 -1
  634. package/dist/utils/sleep.d.ts.map +1 -1
  635. package/dist/utils/sleep.js.map +1 -1
  636. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  637. package/dist/utils/syntax-highlight.js +1 -1
  638. package/dist/utils/syntax-highlight.js.map +1 -1
  639. package/dist/utils/tool-result-images.d.ts.map +1 -1
  640. package/dist/utils/tool-result-images.js.map +1 -1
  641. package/dist/utils/tools-manager.d.ts +10 -1
  642. package/dist/utils/tools-manager.d.ts.map +1 -1
  643. package/dist/utils/tools-manager.js +14 -19
  644. package/dist/utils/tools-manager.js.map +1 -1
  645. package/dist/utils/version-check.d.ts.map +1 -1
  646. package/dist/utils/version-check.js.map +1 -1
  647. package/dist/utils/windows-self-update.d.ts.map +1 -1
  648. package/dist/utils/windows-self-update.js.map +1 -1
  649. package/docs/compaction.md +3 -3
  650. package/docs/custom-provider.md +1 -1
  651. package/docs/environment-variables.md +1 -0
  652. package/docs/extensions.md +4 -0
  653. package/docs/json.md +6 -4
  654. package/docs/keybindings.md +8 -2
  655. package/docs/rpc.md +15 -4
  656. package/docs/sdk.md +9 -0
  657. package/docs/settings.md +31 -0
  658. package/docs/terminal-setup.md +23 -2
  659. package/docs/themes.md +23 -3
  660. package/docs/tui.md +2 -2
  661. package/docs/usage.md +3 -2
  662. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  663. package/examples/extensions/custom-provider-anthropic/package.json +2 -2
  664. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  665. package/examples/extensions/gondolin/package-lock.json +2 -2
  666. package/examples/extensions/gondolin/package.json +1 -1
  667. package/examples/extensions/minimal-mode.ts +6 -6
  668. package/examples/extensions/sandbox/package-lock.json +2 -2
  669. package/examples/extensions/sandbox/package.json +2 -2
  670. package/examples/extensions/with-deps/package-lock.json +2 -2
  671. package/examples/extensions/with-deps/package.json +1 -1
  672. package/npm-shrinkwrap.json +853 -661
  673. package/package.json +33 -33
  674. package/src/humain/web-access/UPSTREAM.md +1 -1
  675. package/src/humain/web-access/upstream.json +4 -4
@@ -0,0 +1,7 @@
1
+ import type { ModelsRefreshResult } from "@earendil-works/pi-ai";
2
+ import type { ModelRuntime } from "../../core/model-runtime.ts";
3
+ type ModelCatalogRuntime = Pick<ModelRuntime, "refresh">;
4
+ /** Share concurrent interactive all-catalog refreshes while keeping each caller's cancellation independent. */
5
+ export declare function refreshModelCatalogs(modelRuntime: ModelCatalogRuntime, signal: AbortSignal): Promise<ModelsRefreshResult>;
6
+ export {};
7
+ //# sourceMappingURL=model-catalog-refresh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-catalog-refresh.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/model-catalog-refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,KAAK,mBAAmB,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAwCzD,+GAA+G;AAC/G,wBAAgB,oBAAoB,CACnC,YAAY,EAAE,mBAAmB,EACjC,MAAM,EAAE,WAAW,GACjB,OAAO,CAAC,mBAAmB,CAAC,CAE9B"}
@@ -0,0 +1,36 @@
1
+ import { raceWithAbortSignal } from "../../utils/abort.js";
2
+ class ModelCatalogRefreshCoordinator {
3
+ constructor() {
4
+ this.activeByRuntime = new WeakMap();
5
+ }
6
+ refresh(modelRuntime, signal) {
7
+ signal.throwIfAborted();
8
+ let active = this.activeByRuntime.get(modelRuntime);
9
+ if (!active) {
10
+ const controller = new AbortController();
11
+ let created;
12
+ const operation = modelRuntime.refresh({ signal: controller.signal });
13
+ const promise = raceWithAbortSignal(operation, controller.signal).finally(() => {
14
+ if (this.activeByRuntime.get(modelRuntime) === created) {
15
+ this.activeByRuntime.delete(modelRuntime);
16
+ }
17
+ });
18
+ created = { controller, promise, waiters: 0 };
19
+ active = created;
20
+ this.activeByRuntime.set(modelRuntime, active);
21
+ }
22
+ active.waiters++;
23
+ return raceWithAbortSignal(active.promise, signal).finally(() => {
24
+ active.waiters--;
25
+ if (active.waiters === 0 && this.activeByRuntime.get(modelRuntime) === active) {
26
+ active.controller.abort();
27
+ }
28
+ });
29
+ }
30
+ }
31
+ const modelCatalogRefreshCoordinator = new ModelCatalogRefreshCoordinator();
32
+ /** Share concurrent interactive all-catalog refreshes while keeping each caller's cancellation independent. */
33
+ export function refreshModelCatalogs(modelRuntime, signal) {
34
+ return modelCatalogRefreshCoordinator.refresh(modelRuntime, signal);
35
+ }
36
+ //# sourceMappingURL=model-catalog-refresh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-catalog-refresh.js","sourceRoot":"","sources":["../../../src/modes/interactive/model-catalog-refresh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAU3D,MAAM,8BAA8B;IAApC;QACkB,oBAAe,GAAG,IAAI,OAAO,EAAkD,CAAC;IA2BlG,CAAC;IAzBA,OAAO,CAAC,YAAiC,EAAE,MAAmB;QAC7D,MAAM,CAAC,cAAc,EAAE,CA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AC/G,MAAM,UAAU,oBAAoB,CACnC,YAAiC,EACjC,MAAmB;IAEnB,OAAO,8BAA8B,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import type { ModelsRefreshResult } from \"@earendil-works/pi-ai\";\nimport type { ModelRuntime } from \"../../core/model-runtime.ts\";\nimport { raceWithAbortSignal } from \"../../utils/abort.ts\";\n\ntype ModelCatalogRuntime = Pick<ModelRuntime, \"refresh\">;\n\ninterface ActiveModelCatalogRefresh {\n\tcontroller: AbortController;\n\tpromise: Promise<ModelsRefreshResult>;\n\twaiters: number;\n}\n\nclass ModelCatalogRefreshCoordinator {\n\tprivate readonly activeByRuntime = new WeakMap<ModelCatalogRuntime, ActiveModelCatalogRefresh>();\n\n\trefresh(modelRuntime: ModelCatalogRuntime, signal: AbortSignal): Promise<ModelsRefreshResult> {\n\t\tsignal.throwIfAborted();\n\t\tlet active = this.activeByRuntime.get(modelRuntime);\n\t\tif (!active) {\n\t\t\tconst controller = new AbortController();\n\t\t\tlet created!: ActiveModelCatalogRefresh;\n\t\t\tconst operation = modelRuntime.refresh({ signal: controller.signal });\n\t\t\tconst promise = raceWithAbortSignal(operation, controller.signal).finally(() => {\n\t\t\t\tif (this.activeByRuntime.get(modelRuntime) === created) {\n\t\t\t\t\tthis.activeByRuntime.delete(modelRuntime);\n\t\t\t\t}\n\t\t\t});\n\t\t\tcreated = { controller, promise, waiters: 0 };\n\t\t\tactive = created;\n\t\t\tthis.activeByRuntime.set(modelRuntime, active);\n\t\t}\n\n\t\tactive.waiters++;\n\t\treturn raceWithAbortSignal(active.promise, signal).finally(() => {\n\t\t\tactive.waiters--;\n\t\t\tif (active.waiters === 0 && this.activeByRuntime.get(modelRuntime) === active) {\n\t\t\t\tactive.controller.abort();\n\t\t\t}\n\t\t});\n\t}\n}\n\nconst modelCatalogRefreshCoordinator = new ModelCatalogRefreshCoordinator();\n\n/** Share concurrent interactive all-catalog refreshes while keeping each caller's cancellation independent. */\nexport function refreshModelCatalogs(\n\tmodelRuntime: ModelCatalogRuntime,\n\tsignal: AbortSignal,\n): Promise<ModelsRefreshResult> {\n\treturn modelCatalogRefreshCoordinator.refresh(modelRuntime, signal);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"model-search.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/model-search.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAIhE;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAIxE","sourcesContent":["export interface ModelSearchItem {\n\tid: string;\n\tprovider: string;\n\tname?: string;\n}\n\nexport function getModelSearchText(item: ModelSearchItem): string {\n\tconst { id, provider } = item;\n\tconst name = item.name ? ` ${item.name}` : \"\";\n\treturn `${id} ${provider} ${provider}/${id} ${provider} ${id}${name}`;\n}\n\n/**\n * The /model selector search should rank exact provider-prefixed queries before proxy-provider IDs\n * like openrouter/openai/gpt-5, so keep the bare model ID out of the leading position.\n */\nexport function getModelSelectorSearchText(item: ModelSearchItem): string {\n\tconst { id, provider } = item;\n\tconst name = item.name ? ` ${item.name}` : \"\";\n\treturn `${provider} ${provider}/${id} ${provider} ${id}${name}`;\n}\n"]}
1
+ {"version":3,"file":"model-search.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/model-search.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAIhE;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAIxE"}
@@ -1 +1 @@
1
- {"version":3,"file":"model-search.js","sourceRoot":"","sources":["../../../src/modes/interactive/model-search.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,kBAAkB,CAAC,IAAqB,EAAU;IACjE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,OAAO,GAAG,EAAE,IAAI,QAAQ,IAAI,QAAQ,IAAI,EAAE,IAAI,QAAQ,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;AAAA,CACtE;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAAqB,EAAU;IACzE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,OAAO,GAAG,QAAQ,IAAI,QAAQ,IAAI,EAAE,IAAI,QAAQ,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;AAAA,CAChE","sourcesContent":["export interface ModelSearchItem {\n\tid: string;\n\tprovider: string;\n\tname?: string;\n}\n\nexport function getModelSearchText(item: ModelSearchItem): string {\n\tconst { id, provider } = item;\n\tconst name = item.name ? ` ${item.name}` : \"\";\n\treturn `${id} ${provider} ${provider}/${id} ${provider} ${id}${name}`;\n}\n\n/**\n * The /model selector search should rank exact provider-prefixed queries before proxy-provider IDs\n * like openrouter/openai/gpt-5, so keep the bare model ID out of the leading position.\n */\nexport function getModelSelectorSearchText(item: ModelSearchItem): string {\n\tconst { id, provider } = item;\n\tconst name = item.name ? ` ${item.name}` : \"\";\n\treturn `${provider} ${provider}/${id} ${provider} ${id}${name}`;\n}\n"]}
1
+ {"version":3,"file":"model-search.js","sourceRoot":"","sources":["../../../src/modes/interactive/model-search.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,kBAAkB,CAAC,IAAqB;IACvD,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,OAAO,GAAG,EAAE,IAAI,QAAQ,IAAI,QAAQ,IAAI,EAAE,IAAI,QAAQ,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;AACvE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAAqB;IAC/D,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,OAAO,GAAG,QAAQ,IAAI,QAAQ,IAAI,EAAE,IAAI,QAAQ,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;AACjE,CAAC","sourcesContent":["export interface ModelSearchItem {\n\tid: string;\n\tprovider: string;\n\tname?: string;\n}\n\nexport function getModelSearchText(item: ModelSearchItem): string {\n\tconst { id, provider } = item;\n\tconst name = item.name ? ` ${item.name}` : \"\";\n\treturn `${id} ${provider} ${provider}/${id} ${provider} ${id}${name}`;\n}\n\n/**\n * The /model selector search should rank exact provider-prefixed queries before proxy-provider IDs\n * like openrouter/openai/gpt-5, so keep the bare model ID out of the leading position.\n */\nexport function getModelSelectorSearchText(item: ModelSearchItem): string {\n\tconst { id, provider } = item;\n\tconst name = item.name ? ` ${item.name}` : \"\";\n\treturn `${provider} ${provider}/${id} ${provider} ${id}${name}`;\n}\n"]}
@@ -34,6 +34,8 @@
34
34
 
35
35
  "selectedBg": "selectedBg",
36
36
  "scrollbarThumb": "selectedBg",
37
+ "searchMatchBg": "selectedBg",
38
+ "searchMatchText": "text",
37
39
  "userMessageBg": "userMsgBg",
38
40
  "userMessageText": "text",
39
41
  "customMessageBg": "customMsgBg",
@@ -33,6 +33,8 @@
33
33
 
34
34
  "selectedBg": "selectedBg",
35
35
  "scrollbarThumb": "selectedBg",
36
+ "searchMatchBg": "selectedBg",
37
+ "searchMatchText": "text",
36
38
  "userMessageBg": "userMsgBg",
37
39
  "userMessageText": "text",
38
40
  "customMessageBg": "customMsgBg",
@@ -7,17 +7,25 @@ type ThemeResult = {
7
7
  };
8
8
  export declare class InteractiveThemeController {
9
9
  private readonly ui;
10
- private readonly settingsManager;
10
+ private readonly getSettingsManager;
11
11
  private readonly showError;
12
12
  private readonly onChanged;
13
+ private currentThemeSetting;
13
14
  private terminalTheme;
14
15
  private activeThemeName;
15
16
  private autoSyncEnabled;
16
17
  private terminalColorSchemeUnsubscribe;
17
- constructor(ui: TUI, settingsManager: SettingsManager, showError: (message: string) => void, onChanged: () => void);
18
+ constructor(ui: TUI, options: {
19
+ getSettingsManager: () => SettingsManager;
20
+ showError: (message: string) => void;
21
+ onChanged: () => void;
22
+ initialThemeSetting?: string;
23
+ });
18
24
  rebindTui(): void;
19
25
  applyFromSettings(): Promise<void>;
26
+ getThemeSelection(): string | undefined;
20
27
  setThemeName(themeName: string, showError?: boolean): ThemeResult;
28
+ setThemeSetting(themeSetting: string): Promise<void>;
21
29
  setThemeInstance(themeInstance: Theme): ThemeResult;
22
30
  preview(themeSettingOrName: string): void;
23
31
  disableAutoSync(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"theme-controller.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EASN,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,MAAM,YAAY,CAAC;AAEpB,KAAK,WAAW,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,qBAAa,0BAA0B;IACtC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAM;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;IAClD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4B;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IACvC,OAAO,CAAC,aAAa,CAA0D;IAC/E,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,8BAA8B,CAA2B;IAEjE,YAAY,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,IAAI,EAQjH;IAED,SAAS,IAAI,IAAI,CAIhB;IAEK,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAuBvC;IAED,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,WAAW,CAG9D;IAED,gBAAgB,CAAC,aAAa,EAAE,KAAK,GAAG,WAAW,CAMlD;IAED,OAAO,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAOxC;IAED,eAAe,IAAI,IAAI,CAEtB;IAED,gBAAgB,IAAI,aAAa,CAEhC;IAED,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,+BAA+B;IAMvC,OAAO,CAAC,kBAAkB;CAa1B","sourcesContent":["import type { TUI } from \"@earendil-works/pi-tui\";\nimport type { SettingsManager } from \"../../../core/settings-manager.ts\";\nimport {\n\tdetectTerminalBackgroundFromEnv,\n\tdetectTerminalBackgroundTheme,\n\tdetectTerminalThemeForAuto,\n\tinitTheme,\n\tparseAutoThemeSetting,\n\tresolveThemeSetting,\n\tsetTheme,\n\tsetThemeInstance,\n\ttype TerminalTheme,\n\ttype Theme,\n} from \"./theme.ts\";\n\ntype ThemeResult = { success: boolean; error?: string };\n\nexport class InteractiveThemeController {\n\tprivate readonly ui: TUI;\n\tprivate readonly settingsManager: SettingsManager;\n\tprivate readonly showError: (message: string) => void;\n\tprivate readonly onChanged: () => void;\n\tprivate terminalTheme: TerminalTheme = detectTerminalBackgroundFromEnv().theme;\n\tprivate activeThemeName: string | undefined;\n\tprivate autoSyncEnabled = false;\n\tprivate terminalColorSchemeUnsubscribe: (() => void) | undefined;\n\n\tconstructor(ui: TUI, settingsManager: SettingsManager, showError: (message: string) => void, onChanged: () => void) {\n\t\tthis.ui = ui;\n\t\tthis.settingsManager = settingsManager;\n\t\tthis.showError = showError;\n\t\tthis.onChanged = onChanged;\n\t\tthis.activeThemeName = resolveThemeSetting(this.settingsManager.getThemeSetting(), this.terminalTheme);\n\t\tinitTheme(this.activeThemeName, true);\n\t\tthis.bindTerminalColorSchemeListener();\n\t}\n\n\trebindTui(): void {\n\t\tthis.terminalColorSchemeUnsubscribe?.();\n\t\tthis.bindTerminalColorSchemeListener();\n\t\tthis.ui.setTerminalColorSchemeNotifications(this.autoSyncEnabled);\n\t}\n\n\tasync applyFromSettings(): Promise<void> {\n\t\tconst themeSetting = this.settingsManager.getThemeSetting();\n\t\tconst autoTheme = parseAutoThemeSetting(themeSetting);\n\t\tif (autoTheme) {\n\t\t\tthis.terminalTheme = await detectTerminalThemeForAuto({ ui: this.ui, timeoutMs: 100 });\n\t\t\tthis.setAutoSync(true);\n\t\t\tthis.applyThemeName(this.terminalTheme === \"light\" ? autoTheme.lightTheme : autoTheme.darkTheme, true);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.setAutoSync(false);\n\t\tif (themeSetting !== undefined) {\n\t\t\tthis.applyThemeName(themeSetting, true);\n\t\t\treturn;\n\t\t}\n\n\t\tconst detection = await detectTerminalBackgroundTheme({ ui: this.ui, timeoutMs: 100 });\n\t\tthis.terminalTheme = detection.theme;\n\t\tif (!this.applyThemeName(detection.theme).success) return;\n\t\tif (detection.confidence === \"high\") {\n\t\t\tthis.settingsManager.setTheme(detection.theme);\n\t\t\tawait this.settingsManager.flush();\n\t\t}\n\t}\n\n\tsetThemeName(themeName: string, showError = false): ThemeResult {\n\t\tthis.setAutoSync(false);\n\t\treturn this.applyThemeName(themeName, showError);\n\t}\n\n\tsetThemeInstance(themeInstance: Theme): ThemeResult {\n\t\tthis.setAutoSync(false);\n\t\tsetThemeInstance(themeInstance);\n\t\tthis.activeThemeName = \"<in-memory>\";\n\t\tthis.notifyChanged();\n\t\treturn { success: true };\n\t}\n\n\tpreview(themeSettingOrName: string): void {\n\t\tconst themeName = resolveThemeSetting(themeSettingOrName, this.terminalTheme) ?? this.activeThemeName;\n\t\tif (!themeName) return;\n\t\tif (setTheme(themeName, true).success) {\n\t\t\tthis.ui.invalidate();\n\t\t\tthis.ui.requestRender();\n\t\t}\n\t}\n\n\tdisableAutoSync(): void {\n\t\tthis.setAutoSync(false);\n\t}\n\n\tgetTerminalTheme(): TerminalTheme {\n\t\treturn this.terminalTheme;\n\t}\n\n\tprivate applyThemeName(themeName: string, showError = false): ThemeResult {\n\t\tconst result = setTheme(themeName, true);\n\t\tthis.activeThemeName = result.success ? themeName : \"dark\";\n\t\tthis.notifyChanged();\n\t\tif (!result.success && showError) {\n\t\t\tthis.showError(`Failed to load theme \"${themeName}\": ${result.error}\\nFell back to dark theme.`);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate notifyChanged(): void {\n\t\tthis.ui.invalidate();\n\t\tthis.onChanged();\n\t}\n\n\tprivate setAutoSync(enabled: boolean): void {\n\t\tif (this.autoSyncEnabled === enabled) return;\n\t\tthis.autoSyncEnabled = enabled;\n\t\tthis.ui.setTerminalColorSchemeNotifications(enabled);\n\t}\n\n\tprivate bindTerminalColorSchemeListener(): void {\n\t\tthis.terminalColorSchemeUnsubscribe = this.ui.onTerminalColorSchemeChange((terminalTheme) =>\n\t\t\tthis.applyTerminalTheme(terminalTheme),\n\t\t);\n\t}\n\n\tprivate applyTerminalTheme(terminalTheme: TerminalTheme): void {\n\t\tif (!this.autoSyncEnabled) return;\n\t\tthis.terminalTheme = terminalTheme;\n\t\tconst autoTheme = parseAutoThemeSetting(this.settingsManager.getThemeSetting());\n\t\tif (!autoTheme) {\n\t\t\tthis.setAutoSync(false);\n\t\t\treturn;\n\t\t}\n\t\tconst themeName = terminalTheme === \"light\" ? autoTheme.lightTheme : autoTheme.darkTheme;\n\t\tif (themeName !== this.activeThemeName) {\n\t\t\tthis.applyThemeName(themeName);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"theme-controller.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EASN,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,MAAM,YAAY,CAAC;AAEpB,KAAK,WAAW,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,qBAAa,0BAA0B;IACtC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAM;IACzB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAwB;IAC3D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4B;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IACvC,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,aAAa,CAA0D;IAC/E,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,8BAA8B,CAA2B;IAEjE,YACC,EAAE,EAAE,GAAG,EACP,OAAO,EAAE;QACR,kBAAkB,EAAE,MAAM,eAAe,CAAC;QAC1C,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;QACrC,SAAS,EAAE,MAAM,IAAI,CAAC;QACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC7B,EAaD;IAED,SAAS,IAAI,IAAI,CAIhB;IAEK,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAwBvC;IAED,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAEtC;IAED,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,WAAW,CAO9D;IAEK,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzD;IAED,gBAAgB,CAAC,aAAa,EAAE,KAAK,GAAG,WAAW,CAMlD;IAED,OAAO,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAOxC;IAED,eAAe,IAAI,IAAI,CAEtB;IAED,gBAAgB,IAAI,aAAa,CAEhC;IAED,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,+BAA+B;IAMvC,OAAO,CAAC,kBAAkB;CAa1B"}
@@ -1,19 +1,14 @@
1
1
  import { detectTerminalBackgroundFromEnv, detectTerminalBackgroundTheme, detectTerminalThemeForAuto, initTheme, parseAutoThemeSetting, resolveThemeSetting, setTheme, setThemeInstance, } from "./theme.js";
2
2
  export class InteractiveThemeController {
3
- ui;
4
- settingsManager;
5
- showError;
6
- onChanged;
7
- terminalTheme = detectTerminalBackgroundFromEnv().theme;
8
- activeThemeName;
9
- autoSyncEnabled = false;
10
- terminalColorSchemeUnsubscribe;
11
- constructor(ui, settingsManager, showError, onChanged) {
3
+ constructor(ui, options) {
4
+ this.terminalTheme = detectTerminalBackgroundFromEnv().theme;
5
+ this.autoSyncEnabled = false;
12
6
  this.ui = ui;
13
- this.settingsManager = settingsManager;
14
- this.showError = showError;
15
- this.onChanged = onChanged;
16
- this.activeThemeName = resolveThemeSetting(this.settingsManager.getThemeSetting(), this.terminalTheme);
7
+ this.getSettingsManager = options.getSettingsManager;
8
+ this.showError = options.showError;
9
+ this.onChanged = options.onChanged;
10
+ this.currentThemeSetting = options.initialThemeSetting;
11
+ this.activeThemeName = resolveThemeSetting(this.currentThemeSetting ?? this.getSettingsManager().getThemeSetting(), this.terminalTheme);
17
12
  initTheme(this.activeThemeName, true);
18
13
  this.bindTerminalColorSchemeListener();
19
14
  }
@@ -23,7 +18,8 @@ export class InteractiveThemeController {
23
18
  this.ui.setTerminalColorSchemeNotifications(this.autoSyncEnabled);
24
19
  }
25
20
  async applyFromSettings() {
26
- const themeSetting = this.settingsManager.getThemeSetting();
21
+ const settingsManager = this.getSettingsManager();
22
+ const themeSetting = this.currentThemeSetting ?? settingsManager.getThemeSetting();
27
23
  const autoTheme = parseAutoThemeSetting(themeSetting);
28
24
  if (autoTheme) {
29
25
  this.terminalTheme = await detectTerminalThemeForAuto({ ui: this.ui, timeoutMs: 100 });
@@ -41,13 +37,24 @@ export class InteractiveThemeController {
41
37
  if (!this.applyThemeName(detection.theme).success)
42
38
  return;
43
39
  if (detection.confidence === "high") {
44
- this.settingsManager.setTheme(detection.theme);
45
- await this.settingsManager.flush();
40
+ settingsManager.setTheme(detection.theme);
41
+ await settingsManager.flush();
46
42
  }
47
43
  }
44
+ getThemeSelection() {
45
+ return this.currentThemeSetting ?? this.getSettingsManager().getThemeSetting() ?? this.activeThemeName;
46
+ }
48
47
  setThemeName(themeName, showError = false) {
49
48
  this.setAutoSync(false);
50
- return this.applyThemeName(themeName, showError);
49
+ const result = this.applyThemeName(themeName, showError);
50
+ if (result.success) {
51
+ this.currentThemeSetting = themeName;
52
+ }
53
+ return result;
54
+ }
55
+ async setThemeSetting(themeSetting) {
56
+ this.currentThemeSetting = themeSetting;
57
+ await this.applyFromSettings();
51
58
  }
52
59
  setThemeInstance(themeInstance) {
53
60
  this.setAutoSync(false);
@@ -97,7 +104,7 @@ export class InteractiveThemeController {
97
104
  if (!this.autoSyncEnabled)
98
105
  return;
99
106
  this.terminalTheme = terminalTheme;
100
- const autoTheme = parseAutoThemeSetting(this.settingsManager.getThemeSetting());
107
+ const autoTheme = parseAutoThemeSetting(this.currentThemeSetting ?? this.getSettingsManager().getThemeSetting());
101
108
  if (!autoTheme) {
102
109
  this.setAutoSync(false);
103
110
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"theme-controller.js","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-controller.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,+BAA+B,EAC/B,6BAA6B,EAC7B,0BAA0B,EAC1B,SAAS,EACT,qBAAqB,EACrB,mBAAmB,EACnB,QAAQ,EACR,gBAAgB,GAGhB,MAAM,YAAY,CAAC;AAIpB,MAAM,OAAO,0BAA0B;IACrB,EAAE,CAAM;IACR,eAAe,CAAkB;IACjC,SAAS,CAA4B;IACrC,SAAS,CAAa;IAC/B,aAAa,GAAkB,+BAA+B,EAAE,CAAC,KAAK,CAAC;IACvE,eAAe,CAAqB;IACpC,eAAe,GAAG,KAAK,CAAC;IACxB,8BAA8B,CAA2B;IAEjE,YAAY,EAAO,EAAE,eAAgC,EAAE,SAAoC,EAAE,SAAqB,EAAE;QACnH,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,IAAI,CAAC,eAAe,CAAC,eAAe,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACvG,SAAS,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC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K,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC;QACzF,IAAI,SAAS,KAAK,IAAI,CAAC,eAAe,EAAE,CAAC;YACxC,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAChC,CAAC;IAAA,CACD;CACD","sourcesContent":["import type { TUI } from \"@earendil-works/pi-tui\";\nimport type { SettingsManager } from \"../../../core/settings-manager.ts\";\nimport {\n\tdetectTerminalBackgroundFromEnv,\n\tdetectTerminalBackgroundTheme,\n\tdetectTerminalThemeForAuto,\n\tinitTheme,\n\tparseAutoThemeSetting,\n\tresolveThemeSetting,\n\tsetTheme,\n\tsetThemeInstance,\n\ttype TerminalTheme,\n\ttype Theme,\n} from \"./theme.ts\";\n\ntype ThemeResult = { success: boolean; error?: string };\n\nexport class InteractiveThemeController {\n\tprivate readonly ui: TUI;\n\tprivate readonly settingsManager: SettingsManager;\n\tprivate readonly showError: (message: string) => void;\n\tprivate readonly onChanged: () => void;\n\tprivate terminalTheme: TerminalTheme = detectTerminalBackgroundFromEnv().theme;\n\tprivate activeThemeName: string | undefined;\n\tprivate autoSyncEnabled = false;\n\tprivate terminalColorSchemeUnsubscribe: (() => void) | undefined;\n\n\tconstructor(ui: TUI, settingsManager: SettingsManager, showError: (message: string) => void, onChanged: () => void) {\n\t\tthis.ui = ui;\n\t\tthis.settingsManager = settingsManager;\n\t\tthis.showError = showError;\n\t\tthis.onChanged = onChanged;\n\t\tthis.activeThemeName = resolveThemeSetting(this.settingsManager.getThemeSetting(), this.terminalTheme);\n\t\tinitTheme(this.activeThemeName, true);\n\t\tthis.bindTerminalColorSchemeListener();\n\t}\n\n\trebindTui(): void {\n\t\tthis.terminalColorSchemeUnsubscribe?.();\n\t\tthis.bindTerminalColorSchemeListener();\n\t\tthis.ui.setTerminalColorSchemeNotifications(this.autoSyncEnabled);\n\t}\n\n\tasync applyFromSettings(): Promise<void> {\n\t\tconst themeSetting = this.settingsManager.getThemeSetting();\n\t\tconst autoTheme = parseAutoThemeSetting(themeSetting);\n\t\tif (autoTheme) {\n\t\t\tthis.terminalTheme = await detectTerminalThemeForAuto({ ui: this.ui, timeoutMs: 100 });\n\t\t\tthis.setAutoSync(true);\n\t\t\tthis.applyThemeName(this.terminalTheme === \"light\" ? autoTheme.lightTheme : autoTheme.darkTheme, true);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.setAutoSync(false);\n\t\tif (themeSetting !== undefined) {\n\t\t\tthis.applyThemeName(themeSetting, true);\n\t\t\treturn;\n\t\t}\n\n\t\tconst detection = await detectTerminalBackgroundTheme({ ui: this.ui, timeoutMs: 100 });\n\t\tthis.terminalTheme = detection.theme;\n\t\tif (!this.applyThemeName(detection.theme).success) return;\n\t\tif (detection.confidence === \"high\") {\n\t\t\tthis.settingsManager.setTheme(detection.theme);\n\t\t\tawait this.settingsManager.flush();\n\t\t}\n\t}\n\n\tsetThemeName(themeName: string, showError = false): ThemeResult {\n\t\tthis.setAutoSync(false);\n\t\treturn this.applyThemeName(themeName, showError);\n\t}\n\n\tsetThemeInstance(themeInstance: Theme): ThemeResult {\n\t\tthis.setAutoSync(false);\n\t\tsetThemeInstance(themeInstance);\n\t\tthis.activeThemeName = \"<in-memory>\";\n\t\tthis.notifyChanged();\n\t\treturn { success: true };\n\t}\n\n\tpreview(themeSettingOrName: string): void {\n\t\tconst themeName = resolveThemeSetting(themeSettingOrName, this.terminalTheme) ?? this.activeThemeName;\n\t\tif (!themeName) return;\n\t\tif (setTheme(themeName, true).success) {\n\t\t\tthis.ui.invalidate();\n\t\t\tthis.ui.requestRender();\n\t\t}\n\t}\n\n\tdisableAutoSync(): void {\n\t\tthis.setAutoSync(false);\n\t}\n\n\tgetTerminalTheme(): TerminalTheme {\n\t\treturn this.terminalTheme;\n\t}\n\n\tprivate applyThemeName(themeName: string, showError = false): ThemeResult {\n\t\tconst result = setTheme(themeName, true);\n\t\tthis.activeThemeName = result.success ? themeName : \"dark\";\n\t\tthis.notifyChanged();\n\t\tif (!result.success && showError) {\n\t\t\tthis.showError(`Failed to load theme \"${themeName}\": ${result.error}\\nFell back to dark theme.`);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate notifyChanged(): void {\n\t\tthis.ui.invalidate();\n\t\tthis.onChanged();\n\t}\n\n\tprivate setAutoSync(enabled: boolean): void {\n\t\tif (this.autoSyncEnabled === enabled) return;\n\t\tthis.autoSyncEnabled = enabled;\n\t\tthis.ui.setTerminalColorSchemeNotifications(enabled);\n\t}\n\n\tprivate bindTerminalColorSchemeListener(): void {\n\t\tthis.terminalColorSchemeUnsubscribe = this.ui.onTerminalColorSchemeChange((terminalTheme) =>\n\t\t\tthis.applyTerminalTheme(terminalTheme),\n\t\t);\n\t}\n\n\tprivate applyTerminalTheme(terminalTheme: TerminalTheme): void {\n\t\tif (!this.autoSyncEnabled) return;\n\t\tthis.terminalTheme = terminalTheme;\n\t\tconst autoTheme = parseAutoThemeSetting(this.settingsManager.getThemeSetting());\n\t\tif (!autoTheme) {\n\t\t\tthis.setAutoSync(false);\n\t\t\treturn;\n\t\t}\n\t\tconst themeName = terminalTheme === \"light\" ? autoTheme.lightTheme : autoTheme.darkTheme;\n\t\tif (themeName !== this.activeThemeName) {\n\t\t\tthis.applyThemeName(themeName);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"theme-controller.js","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-controller.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,+BAA+B,EAC/B,6BAA6B,EAC7B,0BAA0B,EAC1B,SAAS,EACT,qBAAqB,EACrB,mBAAmB,EACnB,QAAQ,EACR,gBAAgB,GAGhB,MAAM,YAAY,CAAC;AAIpB,MAAM,OAAO,0BAA0B;IAWtC,YACC,EAAO,EACP,OAKC;QAZM,kBAAa,GAAkB,+BAA+B,EAAE,CAAC,KAAK,CAAC;QAEvE,oBAAe,GAAG,KAAK,CAAC;QAY/B,IAAI,CAAC,EAAE,GAA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;QACpB,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;QACrB,IAAI,CAAC,SAAS,EAAE,CAAC;IAClB,CAAC;IAEO,WAAW,CAAC,OAAgB;QACnC,IAAI,IAAI,CAAC,eAAe,KAAK,OAAO;YAAE,OAAO;QAC7C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;QAC/B,IAAI,CAAC,EAAE,CAAC,mCAAmC,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAEO,+BAA+B;QACtC,IAAI,CAAC,8BAA8B,GAAG,IAAI,CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC,aAAa,EAAE,EAAE,CAC3F,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,CACtC,CAAC;IACH,CAAC;IAEO,kBAAkB,CAAC,aAA4B;QACtD,IAAI,CAAC,IAAI,CAAC,eAAe;YAAE,OAAO;QAClC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,MAAM,SAAS,GAAG,qBAAqB,CAAC,IAAI,CAAC,mBAAmB,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QACjH,IAAI,CAAC,SAAS,EAAE,CAAC;YAChB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACxB,OAAO;QACR,CAAC;QACD,MAAM,SAAS,GAAG,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC;QACzF,IAAI,SAAS,KAAK,IAAI,CAAC,eAAe,EAAE,CAAC;YACxC,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;CACD","sourcesContent":["import type { TUI } from \"@earendil-works/pi-tui\";\nimport type { SettingsManager } from \"../../../core/settings-manager.ts\";\nimport {\n\tdetectTerminalBackgroundFromEnv,\n\tdetectTerminalBackgroundTheme,\n\tdetectTerminalThemeForAuto,\n\tinitTheme,\n\tparseAutoThemeSetting,\n\tresolveThemeSetting,\n\tsetTheme,\n\tsetThemeInstance,\n\ttype TerminalTheme,\n\ttype Theme,\n} from \"./theme.ts\";\n\ntype ThemeResult = { success: boolean; error?: string };\n\nexport class InteractiveThemeController {\n\tprivate readonly ui: TUI;\n\tprivate readonly getSettingsManager: () => SettingsManager;\n\tprivate readonly showError: (message: string) => void;\n\tprivate readonly onChanged: () => void;\n\tprivate currentThemeSetting: string | undefined;\n\tprivate terminalTheme: TerminalTheme = detectTerminalBackgroundFromEnv().theme;\n\tprivate activeThemeName: string | undefined;\n\tprivate autoSyncEnabled = false;\n\tprivate terminalColorSchemeUnsubscribe: (() => void) | undefined;\n\n\tconstructor(\n\t\tui: TUI,\n\t\toptions: {\n\t\t\tgetSettingsManager: () => SettingsManager;\n\t\t\tshowError: (message: string) => void;\n\t\t\tonChanged: () => void;\n\t\t\tinitialThemeSetting?: string;\n\t\t},\n\t) {\n\t\tthis.ui = ui;\n\t\tthis.getSettingsManager = options.getSettingsManager;\n\t\tthis.showError = options.showError;\n\t\tthis.onChanged = options.onChanged;\n\t\tthis.currentThemeSetting = options.initialThemeSetting;\n\t\tthis.activeThemeName = resolveThemeSetting(\n\t\t\tthis.currentThemeSetting ?? this.getSettingsManager().getThemeSetting(),\n\t\t\tthis.terminalTheme,\n\t\t);\n\t\tinitTheme(this.activeThemeName, true);\n\t\tthis.bindTerminalColorSchemeListener();\n\t}\n\n\trebindTui(): void {\n\t\tthis.terminalColorSchemeUnsubscribe?.();\n\t\tthis.bindTerminalColorSchemeListener();\n\t\tthis.ui.setTerminalColorSchemeNotifications(this.autoSyncEnabled);\n\t}\n\n\tasync applyFromSettings(): Promise<void> {\n\t\tconst settingsManager = this.getSettingsManager();\n\t\tconst themeSetting = this.currentThemeSetting ?? settingsManager.getThemeSetting();\n\t\tconst autoTheme = parseAutoThemeSetting(themeSetting);\n\t\tif (autoTheme) {\n\t\t\tthis.terminalTheme = await detectTerminalThemeForAuto({ ui: this.ui, timeoutMs: 100 });\n\t\t\tthis.setAutoSync(true);\n\t\t\tthis.applyThemeName(this.terminalTheme === \"light\" ? autoTheme.lightTheme : autoTheme.darkTheme, true);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.setAutoSync(false);\n\t\tif (themeSetting !== undefined) {\n\t\t\tthis.applyThemeName(themeSetting, true);\n\t\t\treturn;\n\t\t}\n\n\t\tconst detection = await detectTerminalBackgroundTheme({ ui: this.ui, timeoutMs: 100 });\n\t\tthis.terminalTheme = detection.theme;\n\t\tif (!this.applyThemeName(detection.theme).success) return;\n\t\tif (detection.confidence === \"high\") {\n\t\t\tsettingsManager.setTheme(detection.theme);\n\t\t\tawait settingsManager.flush();\n\t\t}\n\t}\n\n\tgetThemeSelection(): string | undefined {\n\t\treturn this.currentThemeSetting ?? this.getSettingsManager().getThemeSetting() ?? this.activeThemeName;\n\t}\n\n\tsetThemeName(themeName: string, showError = false): ThemeResult {\n\t\tthis.setAutoSync(false);\n\t\tconst result = this.applyThemeName(themeName, showError);\n\t\tif (result.success) {\n\t\t\tthis.currentThemeSetting = themeName;\n\t\t}\n\t\treturn result;\n\t}\n\n\tasync setThemeSetting(themeSetting: string): Promise<void> {\n\t\tthis.currentThemeSetting = themeSetting;\n\t\tawait this.applyFromSettings();\n\t}\n\n\tsetThemeInstance(themeInstance: Theme): ThemeResult {\n\t\tthis.setAutoSync(false);\n\t\tsetThemeInstance(themeInstance);\n\t\tthis.activeThemeName = \"<in-memory>\";\n\t\tthis.notifyChanged();\n\t\treturn { success: true };\n\t}\n\n\tpreview(themeSettingOrName: string): void {\n\t\tconst themeName = resolveThemeSetting(themeSettingOrName, this.terminalTheme) ?? this.activeThemeName;\n\t\tif (!themeName) return;\n\t\tif (setTheme(themeName, true).success) {\n\t\t\tthis.ui.invalidate();\n\t\t\tthis.ui.requestRender();\n\t\t}\n\t}\n\n\tdisableAutoSync(): void {\n\t\tthis.setAutoSync(false);\n\t}\n\n\tgetTerminalTheme(): TerminalTheme {\n\t\treturn this.terminalTheme;\n\t}\n\n\tprivate applyThemeName(themeName: string, showError = false): ThemeResult {\n\t\tconst result = setTheme(themeName, true);\n\t\tthis.activeThemeName = result.success ? themeName : \"dark\";\n\t\tthis.notifyChanged();\n\t\tif (!result.success && showError) {\n\t\t\tthis.showError(`Failed to load theme \"${themeName}\": ${result.error}\\nFell back to dark theme.`);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate notifyChanged(): void {\n\t\tthis.ui.invalidate();\n\t\tthis.onChanged();\n\t}\n\n\tprivate setAutoSync(enabled: boolean): void {\n\t\tif (this.autoSyncEnabled === enabled) return;\n\t\tthis.autoSyncEnabled = enabled;\n\t\tthis.ui.setTerminalColorSchemeNotifications(enabled);\n\t}\n\n\tprivate bindTerminalColorSchemeListener(): void {\n\t\tthis.terminalColorSchemeUnsubscribe = this.ui.onTerminalColorSchemeChange((terminalTheme) =>\n\t\t\tthis.applyTerminalTheme(terminalTheme),\n\t\t);\n\t}\n\n\tprivate applyTerminalTheme(terminalTheme: TerminalTheme): void {\n\t\tif (!this.autoSyncEnabled) return;\n\t\tthis.terminalTheme = terminalTheme;\n\t\tconst autoTheme = parseAutoThemeSetting(this.currentThemeSetting ?? this.getSettingsManager().getThemeSetting());\n\t\tif (!autoTheme) {\n\t\t\tthis.setAutoSync(false);\n\t\t\treturn;\n\t\t}\n\t\tconst themeName = terminalTheme === \"light\" ? autoTheme.lightTheme : autoTheme.darkTheme;\n\t\tif (themeName !== this.activeThemeName) {\n\t\t\tthis.applyThemeName(themeName);\n\t\t}\n\t}\n}\n"]}
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "colors": {
36
36
  "type": "object",
37
- "description": "Theme color definitions (thinkingMax and scrollbarThumb are optional and use compatible fallbacks)",
37
+ "description": "Theme color definitions (thinkingMax, scrollbarThumb, and search highlight colors are optional and use compatible fallbacks)",
38
38
  "required": [
39
39
  "accent",
40
40
  "border",
@@ -141,6 +141,14 @@
141
141
  "$ref": "#/$defs/colorValue",
142
142
  "description": "Fullscreen scrollbar thumb background (falls back to selectedBg when omitted)"
143
143
  },
144
+ "searchMatchBg": {
145
+ "$ref": "#/$defs/colorValue",
146
+ "description": "Transcript search match background and current-match text (falls back to selectedBg when omitted)"
147
+ },
148
+ "searchMatchText": {
149
+ "$ref": "#/$defs/colorValue",
150
+ "description": "Transcript search match text and current-match background (falls back to text when omitted)"
151
+ },
144
152
  "userMessageBg": {
145
153
  "$ref": "#/$defs/colorValue",
146
154
  "description": "User message background"
@@ -1,8 +1,10 @@
1
1
  import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
2
2
  import { type EditorTheme, type MarkdownTheme, type RgbColor, type SelectListTheme, type SettingsListTheme } from "@earendil-works/pi-tui";
3
3
  import type { SourceInfo } from "../../../core/source-info.ts";
4
- export type ThemeColor = "accent" | "border" | "borderAccent" | "borderMuted" | "success" | "error" | "warning" | "muted" | "dim" | "text" | "thinkingText" | "userMessageText" | "customMessageText" | "customMessageLabel" | "toolTitle" | "toolOutput" | "mdHeading" | "mdLink" | "mdLinkUrl" | "mdCode" | "mdCodeBlock" | "mdCodeBlockBorder" | "mdQuote" | "mdQuoteBorder" | "mdHr" | "mdListBullet" | "toolDiffAdded" | "toolDiffRemoved" | "toolDiffContext" | "syntaxComment" | "syntaxKeyword" | "syntaxFunction" | "syntaxVariable" | "syntaxString" | "syntaxNumber" | "syntaxType" | "syntaxOperator" | "syntaxPunctuation" | "thinkingOff" | "thinkingMinimal" | "thinkingLow" | "thinkingMedium" | "thinkingHigh" | "thinkingXhigh" | "thinkingMax" | "bashMode";
5
- export type ThemeBg = "selectedBg" | "scrollbarThumb" | "userMessageBg" | "customMessageBg" | "toolPendingBg" | "toolSuccessBg" | "toolErrorBg";
4
+ export type ThemeColor = "accent" | "border" | "borderAccent" | "borderMuted" | "success" | "error" | "warning" | "muted" | "dim" | "text" | "thinkingText" | "searchMatchText" | "userMessageText" | "customMessageText" | "customMessageLabel" | "toolTitle" | "toolOutput" | "mdHeading" | "mdLink" | "mdLinkUrl" | "mdCode" | "mdCodeBlock" | "mdCodeBlockBorder" | "mdQuote" | "mdQuoteBorder" | "mdHr" | "mdListBullet" | "toolDiffAdded" | "toolDiffRemoved" | "toolDiffContext" | "syntaxComment" | "syntaxKeyword" | "syntaxFunction" | "syntaxVariable" | "syntaxString" | "syntaxNumber" | "syntaxType" | "syntaxOperator" | "syntaxPunctuation" | "thinkingOff" | "thinkingMinimal" | "thinkingLow" | "thinkingMedium" | "thinkingHigh" | "thinkingXhigh" | "thinkingMax" | "bashMode";
5
+ export type ThemeBg = "selectedBg" | "scrollbarThumb" | "searchMatchBg" | "userMessageBg" | "customMessageBg" | "toolPendingBg" | "toolSuccessBg" | "toolErrorBg";
6
+ type OptionalThemeColor = "thinkingMax" | "searchMatchText";
7
+ type OptionalThemeBg = "scrollbarThumb" | "searchMatchBg";
6
8
  type ColorMode = "truecolor" | "256color";
7
9
  export declare class Theme {
8
10
  readonly name?: string;
@@ -11,7 +13,7 @@ export declare class Theme {
11
13
  private fgColors;
12
14
  private bgColors;
13
15
  private mode;
14
- constructor(fgColors: Record<ThemeColor, string | number>, bgColors: Record<Exclude<ThemeBg, "scrollbarThumb">, string | number> & Partial<Record<"scrollbarThumb", string | number>>, mode: ColorMode, options?: {
16
+ constructor(fgColors: Record<Exclude<ThemeColor, OptionalThemeColor>, string | number> & Partial<Record<OptionalThemeColor, string | number>>, bgColors: Record<Exclude<ThemeBg, OptionalThemeBg>, string | number> & Partial<Record<OptionalThemeBg, string | number>>, mode: ColorMode, options?: {
15
17
  name?: string;
16
18
  sourcePath?: string;
17
19
  sourceInfo?: SourceInfo;
@@ -72,8 +74,8 @@ export interface TerminalAutoThemeDetectionOptions extends TerminalThemeDetectio
72
74
  }
73
75
  export declare function getThemeForRgbColor(rgb: RgbColor): TerminalTheme;
74
76
  export declare function detectTerminalBackgroundFromEnv(options?: TerminalThemeDetectionOptions): TerminalThemeDetection;
75
- export declare function detectTerminalBackgroundTheme({ ui, timeoutMs, env }: TerminalBackgroundThemeDetectionOptions): Promise<TerminalThemeDetection>;
76
- export declare function detectTerminalThemeForAuto({ ui, timeoutMs, env }: TerminalAutoThemeDetectionOptions): Promise<TerminalTheme>;
77
+ export declare function detectTerminalBackgroundTheme({ ui, timeoutMs, env, }: TerminalBackgroundThemeDetectionOptions): Promise<TerminalThemeDetection>;
78
+ export declare function detectTerminalThemeForAuto({ ui, timeoutMs, env, }: TerminalAutoThemeDetectionOptions): Promise<TerminalTheme>;
77
79
  export declare function getDefaultTheme(): string;
78
80
  export declare const theme: Theme;
79
81
  export declare function setRegisteredThemes(themes: Theme[]): void;
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EACN,KAAK,WAAW,EAEhB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AA8F/D,MAAM,MAAM,UAAU,GACnB,QAAQ,GACR,QAAQ,GACR,cAAc,GACd,aAAa,GACb,SAAS,GACT,OAAO,GACP,SAAS,GACT,OAAO,GACP,KAAK,GACL,MAAM,GACN,cAAc,GACd,iBAAiB,GACjB,mBAAmB,GACnB,oBAAoB,GACpB,WAAW,GACX,YAAY,GACZ,WAAW,GACX,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,aAAa,GACb,mBAAmB,GACnB,SAAS,GACT,eAAe,GACf,MAAM,GACN,cAAc,GACd,eAAe,GACf,iBAAiB,GACjB,iBAAiB,GACjB,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,cAAc,GACd,YAAY,GACZ,gBAAgB,GAChB,mBAAmB,GACnB,aAAa,GACb,iBAA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el } from \"@earendil-works/pi-agent-core\";\nimport {\n\ttype EditorTheme,\n\tgetCapabilities,\n\ttype MarkdownTheme,\n\ttype RgbColor,\n\ttype SelectListTheme,\n\ttype SettingsListTheme,\n} from \"@earendil-works/pi-tui\";\nimport chalk from \"chalk\";\nimport { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\nimport { getCustomThemesDir, getThemesDir } from \"../../../config.ts\";\nimport type { SourceInfo } from \"../../../core/source-info.ts\";\nimport { closeWatcher, watchWithErrorHandler } from \"../../../utils/fs-watch.ts\";\nimport { highlight, supportsLanguage } from \"../../../utils/syntax-highlight.ts\";\n\n// ============================================================================\n// Types & Schema\n// ============================================================================\n\nconst ColorValueSchema = Type.Union([\n\tType.String(), // hex \"#ff0000\", var ref \"primary\", or empty \"\"\n\tType.Integer({ minimum: 0, maximum: 255 }), // 256-color index\n]);\n\ntype ColorValue = Static<typeof ColorValueSchema>;\n\nconst ThemeJsonSchema = Type.Object({\n\t$schema: Type.Optional(Type.String()),\n\tname: Type.String(),\n\tvars: Type.Optional(Type.Record(Type.String(), ColorValueSchema)),\n\tcolors: Type.Object({\n\t\t// Core UI (10 colors)\n\t\taccent: ColorValueSchema,\n\t\tborder: ColorValueSchema,\n\t\tborderAccent: ColorValueSchema,\n\t\tborderMuted: ColorValueSchema,\n\t\tsuccess: ColorValueSchema,\n\t\terror: ColorValueSchema,\n\t\twarning: ColorValueSchema,\n\t\tmuted: ColorValueSchema,\n\t\tdim: ColorValueSchema,\n\t\ttext: ColorValueSchema,\n\t\tthinkingText: ColorValueSchema,\n\t\t// Backgrounds & Content Text (11 required, 1 optional)\n\t\tselectedBg: ColorValueSchema,\n\t\tscrollbarThumb: Type.Optional(ColorValueSchema),\n\t\tuserMessageBg: ColorValueSchema,\n\t\tuserMessageText: ColorValueSchema,\n\t\tcustomMessageBg: ColorValueSchema,\n\t\tcustomMessageText: ColorValueSchema,\n\t\tcustomMessageLabel: ColorValueSchema,\n\t\ttoolPendingBg: ColorValueSchema,\n\t\ttoolSuccessBg: ColorValueSchema,\n\t\ttoolErrorBg: ColorValueSchema,\n\t\ttoolTitle: ColorValueSchema,\n\t\ttoolOutput: ColorValueSchema,\n\t\t// Markdown (10 colors)\n\t\tmdHeading: ColorValueSchema,\n\t\tmdLink: ColorValueSchema,\n\t\tmdLinkUrl: ColorValueSchema,\n\t\tmdCode: ColorValueSchema,\n\t\tmdCodeBlock: ColorValueSchema,\n\t\tmdCodeBlockBorder: ColorValueSchema,\n\t\tmdQuote: ColorValueSchema,\n\t\tmdQuoteBorder: ColorValueSchema,\n\t\tmdHr: ColorValueSchema,\n\t\tmdListBullet: ColorValueSchema,\n\t\t// Tool Diffs (3 colors)\n\t\ttoolDiffAdded: ColorValueSchema,\n\t\ttoolDiffRemoved: ColorValueSchema,\n\t\ttoolDiffContext: ColorValueSchema,\n\t\t// Syntax Highlighting (9 colors)\n\t\tsyntaxComment: ColorValueSchema,\n\t\tsyntaxKeyword: ColorValueSchema,\n\t\tsyntaxFunction: ColorValueSchema,\n\t\tsyntaxVariable: ColorValueSchema,\n\t\tsyntaxString: ColorValueSchema,\n\t\tsyntaxNumber: ColorValueSchema,\n\t\tsyntaxType: ColorValueSchema,\n\t\tsyntaxOperator: ColorValueSchema,\n\t\tsyntaxPunctuation: ColorValueSchema,\n\t\t// Thinking Level Borders (6 colors)\n\t\tthinkingOff: ColorValueSchema,\n\t\tthinkingMinimal: ColorValueSchema,\n\t\tthinkingLow: ColorValueSchema,\n\t\tthinkingMedium: ColorValueSchema,\n\t\tthinkingHigh: ColorValueSchema,\n\t\tthinkingXhigh: ColorValueSchema,\n\t\tthinkingMax: Type.Optional(ColorValueSchema),\n\t\t// Bash Mode (1 color)\n\t\tbashMode: ColorValueSchema,\n\t}),\n\texport: Type.Optional(\n\t\tType.Object({\n\t\t\tpageBg: Type.Optional(ColorValueSchema),\n\t\t\tcardBg: Type.Optional(ColorValueSchema),\n\t\t\tinfoBg: Type.Optional(ColorValueSchema),\n\t\t}),\n\t),\n});\n\ntype ThemeJson = Static<typeof ThemeJsonSchema>;\n\nconst validateThemeJson = Compile(ThemeJsonSchema);\n\nexport type ThemeColor =\n\t| \"accent\"\n\t| \"border\"\n\t| \"borderAccent\"\n\t| \"borderMuted\"\n\t| \"success\"\n\t| \"error\"\n\t| \"warning\"\n\t| \"muted\"\n\t| \"dim\"\n\t| \"text\"\n\t| \"thinkingText\"\n\t| \"userMessageText\"\n\t| \"customMessageText\"\n\t| \"customMessageLabel\"\n\t| \"toolTitle\"\n\t| \"toolOutput\"\n\t| \"mdHeading\"\n\t| \"mdLink\"\n\t| \"mdLinkUrl\"\n\t| \"mdCode\"\n\t| \"mdCodeBlock\"\n\t| \"mdCodeBlockBorder\"\n\t| \"mdQuote\"\n\t| \"mdQuoteBorder\"\n\t| \"mdHr\"\n\t| \"mdListBullet\"\n\t| \"toolDiffAdded\"\n\t| \"toolDiffRemoved\"\n\t| \"toolDiffContext\"\n\t| \"syntaxComment\"\n\t| \"syntaxKeyword\"\n\t| \"syntaxFunction\"\n\t| \"syntaxVariable\"\n\t| \"syntaxString\"\n\t| \"syntaxNumber\"\n\t| \"syntaxType\"\n\t| \"syntaxOperator\"\n\t| \"syntaxPunctuation\"\n\t| \"thinkingOff\"\n\t| \"thinkingMinimal\"\n\t| \"thinkingLow\"\n\t| \"thinkingMedium\"\n\t| \"thinkingHigh\"\n\t| \"thinkingXhigh\"\n\t| \"thinkingMax\"\n\t| \"bashMode\";\n\nexport type ThemeBg =\n\t| \"selectedBg\"\n\t| \"scrollbarThumb\"\n\t| \"userMessageBg\"\n\t| \"customMessageBg\"\n\t| \"toolPendingBg\"\n\t| \"toolSuccessBg\"\n\t| \"toolErrorBg\";\n\ntype ColorMode = \"truecolor\" | \"256color\";\n\n// ============================================================================\n// Color Utilities\n// ============================================================================\n\nfunction hexToRgb(hex: string): { r: number; g: number; b: number } {\n\tconst cleaned = hex.replace(\"#\", \"\");\n\tif (cleaned.length !== 6) {\n\t\tthrow new Error(`Invalid hex color: ${hex}`);\n\t}\n\tconst r = parseInt(cleaned.substring(0, 2), 16);\n\tconst g = parseInt(cleaned.substring(2, 4), 16);\n\tconst b = parseInt(cleaned.substring(4, 6), 16);\n\tif (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {\n\t\tthrow new Error(`Invalid hex color: ${hex}`);\n\t}\n\treturn { r, g, b };\n}\n\n// The 6x6x6 color cube channel values (indices 0-5)\nconst CUBE_VALUES = [0, 95, 135, 175, 215, 255];\n\n// Grayscale ramp values (indices 232-255, 24 grays from 8 to 238)\nconst GRAY_VALUES = Array.from({ length: 24 }, (_, i) => 8 + i * 10);\n\nfunction findClosestCubeIndex(value: number): number {\n\tlet minDist = Infinity;\n\tlet minIdx = 0;\n\tfor (let i = 0; i < CUBE_VALUES.length; i++) {\n\t\tconst dist = Math.abs(value - CUBE_VALUES[i]);\n\t\tif (dist < minDist) {\n\t\t\tminDist = dist;\n\t\t\tminIdx = i;\n\t\t}\n\t}\n\treturn minIdx;\n}\n\nfunction findClosestGrayIndex(gray: number): number {\n\tlet minDist = Infinity;\n\tlet minIdx = 0;\n\tfor (let i = 0; i < GRAY_VALUES.length; i++) {\n\t\tconst dist = Math.abs(gray - GRAY_VALUES[i]);\n\t\tif (dist < minDist) {\n\t\t\tminDist = dist;\n\t\t\tminIdx = i;\n\t\t}\n\t}\n\treturn minIdx;\n}\n\nfunction colorDistance(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number): number {\n\t// Weighted Euclidean distance (human eye is more sensitive to green)\n\tconst dr = r1 - r2;\n\tconst dg = g1 - g2;\n\tconst db = b1 - b2;\n\treturn dr * dr * 0.299 + dg * dg * 0.587 + db * db * 0.114;\n}\n\nfunction rgbTo256(r: number, g: number, b: number): number {\n\t// Find closest color in the 6x6x6 cube\n\tconst rIdx = findClosestCubeIndex(r);\n\tconst gIdx = findClosestCubeIndex(g);\n\tconst bIdx = findClosestCubeIndex(b);\n\tconst cubeR = CUBE_VALUES[rIdx];\n\tconst cubeG = CUBE_VALUES[gIdx];\n\tconst cubeB = CUBE_VALUES[bIdx];\n\tconst cubeIndex = 16 + 36 * rIdx + 6 * gIdx + bIdx;\n\tconst cubeDist = colorDistance(r, g, b, cubeR, cubeG, cubeB);\n\n\t// Find closest grayscale\n\tconst gray = Math.round(0.299 * r + 0.587 * g + 0.114 * b);\n\tconst grayIdx = findClosestGrayIndex(gray);\n\tconst grayValue = GRAY_VALUES[grayIdx];\n\tconst grayIndex = 232 + grayIdx;\n\tconst grayDist = colorDistance(r, g, b, grayValue, grayValue, grayValue);\n\n\t// Check if color has noticeable saturation (hue matters)\n\t// If max-min spread is significant, prefer cube to preserve tint\n\tconst maxC = Math.max(r, g, b);\n\tconst minC = Math.min(r, g, b);\n\tconst spread = maxC - minC;\n\n\t// Only consider grayscale if color is nearly neutral (spread < 10)\n\t// AND grayscale is actually closer\n\tif (spread < 10 && grayDist < cubeDist) {\n\t\treturn grayIndex;\n\t}\n\n\treturn cubeIndex;\n}\n\nfunction hexTo256(hex: string): number {\n\tconst { r, g, b } = hexToRgb(hex);\n\treturn rgbTo256(r, g, b);\n}\n\nfunction fgAnsi(color: string | number, mode: ColorMode): string {\n\tif (color === \"\") return \"\\x1b[39m\";\n\tif (typeof color === \"number\") return `\\x1b[38;5;${color}m`;\n\tif (color.startsWith(\"#\")) {\n\t\tif (mode === \"truecolor\") {\n\t\t\tconst { r, g, b } = hexToRgb(color);\n\t\t\treturn `\\x1b[38;2;${r};${g};${b}m`;\n\t\t} else {\n\t\t\tconst index = hexTo256(color);\n\t\t\treturn `\\x1b[38;5;${index}m`;\n\t\t}\n\t}\n\tthrow new Error(`Invalid color value: ${color}`);\n}\n\nfunction bgAnsi(color: string | number, mode: ColorMode): string {\n\tif (color === \"\") return \"\\x1b[49m\";\n\tif (typeof color === \"number\") return `\\x1b[48;5;${color}m`;\n\tif (color.startsWith(\"#\")) {\n\t\tif (mode === \"truecolor\") {\n\t\t\tconst { r, g, b } = hexToRgb(color);\n\t\t\treturn `\\x1b[48;2;${r};${g};${b}m`;\n\t\t} else {\n\t\t\tconst index = hexTo256(color);\n\t\t\treturn `\\x1b[48;5;${index}m`;\n\t\t}\n\t}\n\tthrow new Error(`Invalid color value: ${color}`);\n}\n\nfunction resolveVarRefs(\n\tvalue: ColorValue,\n\tvars: Record<string, ColorValue>,\n\tvisited = new Set<string>(),\n): string | number {\n\tif (typeof value === \"number\" || value === \"\" || value.startsWith(\"#\")) {\n\t\treturn value;\n\t}\n\tif (visited.has(value)) {\n\t\tthrow new Error(`Circular variable reference detected: ${value}`);\n\t}\n\tif (!(value in vars)) {\n\t\tthrow new Error(`Variable reference not found: ${value}`);\n\t}\n\tvisited.add(value);\n\treturn resolveVarRefs(vars[value], vars, visited);\n}\n\nfunction resolveThemeColors<T extends Record<string, ColorValue>>(\n\tcolors: T,\n\tvars: Record<string, ColorValue> = {},\n): Record<keyof T, string | number> {\n\tconst resolved: Record<string, string | number> = {};\n\tfor (const [key, value] of Object.entries(colors)) {\n\t\tresolved[key] = resolveVarRefs(value, vars);\n\t}\n\treturn resolved as Record<keyof T, string | number>;\n}\n\nfunction withThemeColorFallbacks(\n\tcolors: ThemeJson[\"colors\"],\n): ThemeJson[\"colors\"] & { thinkingMax: ColorValue; scrollbarThumb: ColorValue } {\n\treturn {\n\t\t...colors,\n\t\tthinkingMax: colors.thinkingMax ?? colors.thinkingXhigh,\n\t\tscrollbarThumb: colors.scrollbarThumb ?? colors.selectedBg,\n\t};\n}\n\n// ============================================================================\n// Theme Class\n// ============================================================================\n\nexport class Theme {\n\treadonly name?: string;\n\treadonly sourcePath?: string;\n\tsourceInfo?: SourceInfo;\n\tprivate fgColors: Map<ThemeColor, string>;\n\tprivate bgColors: Map<ThemeBg, string>;\n\tprivate mode: ColorMode;\n\n\tconstructor(\n\t\tfgColors: Record<ThemeColor, string | number>,\n\t\tbgColors: Record<Exclude<ThemeBg, \"scrollbarThumb\">, string | number> &\n\t\t\tPartial<Record<\"scrollbarThumb\", string | number>>,\n\t\tmode: ColorMode,\n\t\toptions: { name?: string; sourcePath?: string; sourceInfo?: SourceInfo } = {},\n\t) {\n\t\tthis.name = options.name;\n\t\tthis.sourcePath = options.sourcePath;\n\t\tthis.sourceInfo = options.sourceInfo;\n\t\tthis.mode = mode;\n\t\tthis.fgColors = new Map();\n\t\tconst colors = { ...fgColors, thinkingMax: fgColors.thinkingMax ?? fgColors.thinkingXhigh };\n\t\tfor (const [key, value] of Object.entries(colors) as [ThemeColor, string | number][]) {\n\t\t\tthis.fgColors.set(key, fgAnsi(value, mode));\n\t\t}\n\t\tthis.bgColors = new Map();\n\t\tconst backgrounds = {\n\t\t\t...bgColors,\n\t\t\tscrollbarThumb: bgColors.scrollbarThumb ?? bgColors.selectedBg,\n\t\t};\n\t\tfor (const [key, value] of Object.entries(backgrounds) as [ThemeBg, string | number][]) {\n\t\t\tthis.bgColors.set(key, bgAnsi(value, mode));\n\t\t}\n\t}\n\n\tfg(color: ThemeColor, text: string): string {\n\t\tconst ansi = this.fgColors.get(color);\n\t\tif (!ansi) throw new Error(`Unknown theme color: ${color}`);\n\t\treturn `${ansi}${text}\\x1b[39m`; // Reset only foreground color\n\t}\n\n\tbg(color: ThemeBg, text: string): string {\n\t\tconst ansi = this.bgColors.get(color);\n\t\tif (!ansi) throw new Error(`Unknown theme background color: ${color}`);\n\t\treturn `${ansi}${text}\\x1b[49m`; // Reset only background color\n\t}\n\n\tbold(text: string): string {\n\t\treturn chalk.bold(text);\n\t}\n\n\titalic(text: string): string {\n\t\treturn chalk.italic(text);\n\t}\n\n\tunderline(text: string): string {\n\t\treturn chalk.underline(text);\n\t}\n\n\tinverse(text: string): string {\n\t\treturn chalk.inverse(text);\n\t}\n\n\tstrikethrough(text: string): string {\n\t\treturn chalk.strikethrough(text);\n\t}\n\n\tgetFgAnsi(color: ThemeColor): string {\n\t\tconst ansi = this.fgColors.get(color);\n\t\tif (!ansi) throw new Error(`Unknown theme color: ${color}`);\n\t\treturn ansi;\n\t}\n\n\tgetBgAnsi(color: ThemeBg): string {\n\t\tconst ansi = this.bgColors.get(color);\n\t\tif (!ansi) throw new Error(`Unknown theme background color: ${color}`);\n\t\treturn ansi;\n\t}\n\n\tgetColorMode(): ColorMode {\n\t\treturn this.mode;\n\t}\n\n\tgetThinkingBorderColor(level: ThinkingLevel): (str: string) => string {\n\t\t// Map thinking levels to dedicated theme colors\n\t\tswitch (level) {\n\t\t\tcase \"off\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingOff\", str);\n\t\t\tcase \"minimal\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingMinimal\", str);\n\t\t\tcase \"low\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingLow\", str);\n\t\t\tcase \"medium\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingMedium\", str);\n\t\t\tcase \"high\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingHigh\", str);\n\t\t\tcase \"xhigh\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingXhigh\", str);\n\t\t\tcase \"max\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingMax\", str);\n\t\t\tdefault:\n\t\t\t\treturn (str: string) => this.fg(\"thinkingOff\", str);\n\t\t}\n\t}\n\n\tgetBashModeBorderColor(): (str: string) => string {\n\t\treturn (str: string) => this.fg(\"bashMode\", str);\n\t}\n}\n\n// ============================================================================\n// Theme Loading\n// ============================================================================\n\nlet BUILTIN_THEMES: Record<string, ThemeJson> | undefined;\n\nfunction getBuiltinThemes(): Record<string, ThemeJson> {\n\tif (!BUILTIN_THEMES) {\n\t\tconst themesDir = getThemesDir();\n\t\tconst darkPath = path.join(themesDir, \"dark.json\");\n\t\tconst lightPath = path.join(themesDir, \"light.json\");\n\t\tconst humainDarkPath = path.join(themesDir, \"humain-dark.json\");\n\t\tconst humainLightPath = path.join(themesDir, \"humain-light.json\");\n\t\tBUILTIN_THEMES = {\n\t\t\tdark: JSON.parse(fs.readFileSync(darkPath, \"utf-8\")) as ThemeJson,\n\t\t\tlight: JSON.parse(fs.readFileSync(lightPath, \"utf-8\")) as ThemeJson,\n\t\t\t\"humain-dark\": JSON.parse(fs.readFileSync(humainDarkPath, \"utf-8\")) as ThemeJson,\n\t\t\t\"humain-light\": JSON.parse(fs.readFileSync(humainLightPath, \"utf-8\")) as ThemeJson,\n\t\t};\n\t}\n\treturn BUILTIN_THEMES;\n}\n\nexport function getAvailableThemes(): string[] {\n\treturn getAvailableThemesWithPaths().map(({ name }) => name);\n}\n\nexport interface ThemeInfo {\n\tname: string;\n\tpath: string | undefined;\n}\n\nexport function getAvailableThemesWithPaths(): ThemeInfo[] {\n\tconst themesDir = getThemesDir();\n\tconst result: ThemeInfo[] = [];\n\tconst seen = new Set<string>();\n\tconst addTheme = (themeInfo: ThemeInfo) => {\n\t\tif (seen.has(themeInfo.name)) {\n\t\t\treturn;\n\t\t}\n\t\tseen.add(themeInfo.name);\n\t\tresult.push(themeInfo);\n\t};\n\n\t// Built-in themes\n\tfor (const name of Object.keys(getBuiltinThemes())) {\n\t\taddTheme({ name, path: path.join(themesDir, `${name}.json`) });\n\t}\n\n\t// Custom themes\n\tfor (const themeInfo of getCustomThemeInfos()) {\n\t\taddTheme(themeInfo);\n\t}\n\n\tfor (const [name, theme] of registeredThemes.entries()) {\n\t\taddTheme({ name, path: theme.sourcePath });\n\t}\n\n\treturn result.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nfunction getCustomThemeInfos(): ThemeInfo[] {\n\tconst customThemesDir = getCustomThemesDir();\n\tconst result: ThemeInfo[] = [];\n\tif (!fs.existsSync(customThemesDir)) {\n\t\treturn result;\n\t}\n\n\tfor (const file of fs.readdirSync(customThemesDir)) {\n\t\tif (!file.endsWith(\".json\")) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst themePath = path.join(customThemesDir, file);\n\t\ttry {\n\t\t\tconst customTheme = loadThemeFromPath(themePath);\n\t\t\tif (customTheme.name) {\n\t\t\t\tresult.push({ name: customTheme.name, path: themePath });\n\t\t\t}\n\t\t} catch {\n\t\t\t// Invalid themes are ignored here; the resource loader reports them\n\t\t\t// during normal startup/reload.\n\t\t}\n\t}\n\treturn result;\n}\n\nfunction assertThemeNameIsValid(name: string): void {\n\tif (name.includes(\"/\")) {\n\t\tthrow new Error(\n\t\t\t`Invalid theme name \"${name}\": theme names cannot contain \"/\" because it is reserved for automatic light/dark theme settings.`,\n\t\t);\n\t}\n}\n\nfunction parseThemeJson(label: string, json: unknown): ThemeJson {\n\tif (!validateThemeJson.Check(json)) {\n\t\tconst errors = Array.from(validateThemeJson.Errors(json));\n\t\tconst missingColors = new Set<string>();\n\t\tconst otherErrors: string[] = [];\n\n\t\tfor (const error of errors) {\n\t\t\tif (error.keyword === \"required\" && error.instancePath === \"/colors\") {\n\t\t\t\tconst requiredProperties = (error.params as { requiredProperties?: string[] }).requiredProperties;\n\t\t\t\tfor (const requiredProperty of requiredProperties ?? []) {\n\t\t\t\t\tmissingColors.add(requiredProperty);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst path = error.instancePath || \"/\";\n\t\t\totherErrors.push(` - ${path}: ${error.message}`);\n\t\t}\n\n\t\tlet errorMessage = `Invalid theme \"${label}\":\\n`;\n\t\tif (missingColors.size > 0) {\n\t\t\terrorMessage += \"\\nMissing required color tokens:\\n\";\n\t\t\terrorMessage += Array.from(missingColors)\n\t\t\t\t.sort()\n\t\t\t\t.map((color) => ` - ${color}`)\n\t\t\t\t.join(\"\\n\");\n\t\t\terrorMessage += '\\n\\nPlease add these colors to your theme\\'s \"colors\" object.';\n\t\t\terrorMessage += \"\\nSee the built-in themes (dark.json, light.json) for reference values.\";\n\t\t}\n\t\tif (otherErrors.length > 0) {\n\t\t\terrorMessage += `\\n\\nOther errors:\\n${otherErrors.join(\"\\n\")}`;\n\t\t}\n\n\t\tthrow new Error(errorMessage);\n\t}\n\n\tconst themeJson = json as ThemeJson;\n\tassertThemeNameIsValid(themeJson.name);\n\treturn themeJson;\n}\n\nfunction parseThemeJsonContent(label: string, content: string): ThemeJson {\n\tlet json: unknown;\n\ttry {\n\t\tjson = JSON.parse(content);\n\t} catch (error) {\n\t\tthrow new Error(`Failed to parse theme ${label}: ${error}`);\n\t}\n\treturn parseThemeJson(label, json);\n}\n\nfunction loadThemeJson(name: string): ThemeJson {\n\tconst builtinThemes = getBuiltinThemes();\n\tif (name in builtinThemes) {\n\t\treturn builtinThemes[name];\n\t}\n\tconst registeredTheme = registeredThemes.get(name);\n\tif (registeredTheme?.sourcePath) {\n\t\tconst content = fs.readFileSync(registeredTheme.sourcePath, \"utf-8\");\n\t\treturn parseThemeJsonContent(registeredTheme.sourcePath, content);\n\t}\n\tif (registeredTheme) {\n\t\tthrow new Error(`Theme \"${name}\" does not have a source path for export`);\n\t}\n\tconst customThemesDir = getCustomThemesDir();\n\tconst themePath = path.join(customThemesDir, `${name}.json`);\n\tif (!fs.existsSync(themePath)) {\n\t\tthrow new Error(`Theme not found: ${name}`);\n\t}\n\tconst content = fs.readFileSync(themePath, \"utf-8\");\n\treturn parseThemeJsonContent(name, content);\n}\n\nfunction createTheme(themeJson: ThemeJson, mode?: ColorMode, sourcePath?: string): Theme {\n\tconst colorMode = mode ?? (getCapabilities().trueColor ? \"truecolor\" : \"256color\");\n\tconst resolvedColors = resolveThemeColors(withThemeColorFallbacks(themeJson.colors), themeJson.vars);\n\tconst fgColors: Record<ThemeColor, string | number> = {} as Record<ThemeColor, string | number>;\n\tconst bgColors: Record<ThemeBg, string | number> = {} as Record<ThemeBg, string | number>;\n\tconst bgColorKeys: Set<string> = new Set([\n\t\t\"selectedBg\",\n\t\t\"scrollbarThumb\",\n\t\t\"userMessageBg\",\n\t\t\"customMessageBg\",\n\t\t\"toolPendingBg\",\n\t\t\"toolSuccessBg\",\n\t\t\"toolErrorBg\",\n\t]);\n\tfor (const [key, value] of Object.entries(resolvedColors)) {\n\t\tif (bgColorKeys.has(key)) {\n\t\t\tbgColors[key as ThemeBg] = value;\n\t\t} else {\n\t\t\tfgColors[key as ThemeColor] = value;\n\t\t}\n\t}\n\treturn new Theme(fgColors, bgColors, colorMode, {\n\t\tname: themeJson.name,\n\t\tsourcePath,\n\t});\n}\n\nexport function loadThemeFromPath(themePath: string, mode?: ColorMode): Theme {\n\tconst content = fs.readFileSync(themePath, \"utf-8\");\n\tconst themeJson = parseThemeJsonContent(themePath, content);\n\treturn createTheme(themeJson, mode, themePath);\n}\n\nfunction loadTheme(name: string, mode?: ColorMode): Theme {\n\tconst registeredTheme = registeredThemes.get(name);\n\tif (registeredTheme) {\n\t\treturn registeredTheme;\n\t}\n\tconst themeJson = loadThemeJson(name);\n\treturn createTheme(themeJson, mode);\n}\n\nexport function getThemeByName(name: string): Theme | undefined {\n\ttry {\n\t\treturn loadTheme(name);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport type TerminalTheme = \"dark\" | \"light\";\n\nexport function parseAutoThemeSetting(\n\tthemeSetting: string | undefined,\n): { lightTheme: string; darkTheme: string } | undefined {\n\tif (!themeSetting) return undefined;\n\tconst slashIndex = themeSetting.indexOf(\"/\");\n\tif (slashIndex === -1 || themeSetting.indexOf(\"/\", slashIndex + 1) !== -1) {\n\t\treturn undefined;\n\t}\n\n\tconst lightTheme = themeSetting.slice(0, slashIndex).trim();\n\tconst darkTheme = themeSetting.slice(slashIndex + 1).trim();\n\tif (!lightTheme || !darkTheme) {\n\t\treturn undefined;\n\t}\n\treturn { lightTheme, darkTheme };\n}\n\nexport function resolveThemeSetting(\n\tthemeSetting: string | undefined,\n\tterminalTheme: TerminalTheme,\n): string | undefined {\n\tconst autoTheme = parseAutoThemeSetting(themeSetting);\n\tif (autoTheme) {\n\t\treturn terminalTheme === \"light\" ? autoTheme.lightTheme : autoTheme.darkTheme;\n\t}\n\tif (themeSetting?.includes(\"/\")) return undefined;\n\tif (typeof themeSetting === \"string\") return themeSetting;\n\treturn undefined;\n}\n\nexport interface TerminalThemeDetection {\n\ttheme: TerminalTheme;\n\tsource: \"terminal background\" | \"COLORFGBG\" | \"fallback\";\n\tdetail: string;\n\tconfidence: \"high\" | \"low\";\n}\n\nexport interface TerminalThemeDetectionOptions {\n\tenv?: NodeJS.ProcessEnv;\n}\n\nexport interface TerminalBackgroundThemeDetector {\n\tqueryTerminalBackgroundColor({ timeoutMs }: { timeoutMs: number }): Promise<RgbColor | undefined>;\n}\n\nexport interface TerminalAutoThemeDetector extends TerminalBackgroundThemeDetector {\n\tqueryTerminalColorScheme?({ timeoutMs }: { timeoutMs: number }): Promise<TerminalTheme | undefined>;\n}\n\nexport interface TerminalBackgroundThemeDetectionOptions extends TerminalThemeDetectionOptions {\n\tui: TerminalBackgroundThemeDetector;\n\ttimeoutMs: number;\n}\n\nexport interface TerminalAutoThemeDetectionOptions extends TerminalThemeDetectionOptions {\n\tui: TerminalAutoThemeDetector;\n\ttimeoutMs: number;\n}\n\nfunction getColorFgBgBackgroundIndex(colorfgbg: string): number | undefined {\n\tconst parts = colorfgbg.split(\";\");\n\tfor (let i = parts.length - 1; i >= 0; i--) {\n\t\tconst bg = parseInt(parts[i].trim(), 10);\n\t\tif (Number.isInteger(bg) && bg >= 0 && bg <= 255) {\n\t\t\treturn bg;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction getRgbColorLuminance({ r, g, b }: RgbColor): number {\n\tconst toLinear = (channel: number) => {\n\t\tconst value = channel / 255;\n\t\treturn value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;\n\t};\n\treturn 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);\n}\n\nfunction getAnsiColorLuminance(index: number): number {\n\treturn getRgbColorLuminance(hexToRgb(ansi256ToHex(index)));\n}\n\nexport function getThemeForRgbColor(rgb: RgbColor): TerminalTheme {\n\treturn getRgbColorLuminance(rgb) >= 0.5 ? \"light\" : \"dark\";\n}\n\nexport function detectTerminalBackgroundFromEnv(options: TerminalThemeDetectionOptions = {}): TerminalThemeDetection {\n\tconst env = options.env ?? process.env;\n\tconst colorfgbg = env.COLORFGBG || \"\";\n\tconst bg = getColorFgBgBackgroundIndex(colorfgbg);\n\tif (bg !== undefined) {\n\t\treturn {\n\t\t\ttheme: getAnsiColorLuminance(bg) >= 0.5 ? \"light\" : \"dark\",\n\t\t\tsource: \"COLORFGBG\",\n\t\t\tdetail: `background color index ${bg}`,\n\t\t\tconfidence: \"high\",\n\t\t};\n\t}\n\n\treturn {\n\t\ttheme: \"dark\",\n\t\tsource: \"fallback\",\n\t\tdetail: \"no terminal background hint found\",\n\t\tconfidence: \"low\",\n\t};\n}\n\nexport async function detectTerminalBackgroundTheme({\n\tui,\n\ttimeoutMs,\n\tenv,\n}: TerminalBackgroundThemeDetectionOptions): Promise<TerminalThemeDetection> {\n\ttry {\n\t\tconst rgb = await ui.queryTerminalBackgroundColor({ timeoutMs });\n\t\tif (rgb) {\n\t\t\treturn {\n\t\t\t\ttheme: getThemeForRgbColor(rgb),\n\t\t\t\tsource: \"terminal background\",\n\t\t\t\tdetail: `OSC 11 background rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`,\n\t\t\t\tconfidence: \"high\",\n\t\t\t};\n\t\t}\n\t} catch {\n\t\t// Fall back to environment-based detection when the terminal query fails.\n\t}\n\n\treturn detectTerminalBackgroundFromEnv({ env });\n}\n\nexport async function detectTerminalThemeForAuto({\n\tui,\n\ttimeoutMs,\n\tenv,\n}: TerminalAutoThemeDetectionOptions): Promise<TerminalTheme> {\n\tlet colorSchemePromise: Promise<TerminalTheme | undefined> | undefined;\n\ttry {\n\t\tcolorSchemePromise = ui.queryTerminalColorScheme?.({ timeoutMs });\n\t} catch {\n\t\t// Fall back to OSC 11 / COLORFGBG detection when starting the color-scheme query fails.\n\t}\n\tconst backgroundThemePromise = detectTerminalBackgroundTheme({ ui, timeoutMs, env });\n\n\ttry {\n\t\tconst colorScheme = await colorSchemePromise;\n\t\tif (colorScheme) return colorScheme;\n\t} catch {\n\t\t// Fall back to the concurrently queried OSC 11 / COLORFGBG detection.\n\t}\n\treturn (await backgroundThemePromise).theme;\n}\n\nexport function getDefaultTheme(): string {\n\treturn detectTerminalBackgroundFromEnv().theme;\n}\n\n// ============================================================================\n// Global Theme Instance\n// ============================================================================\n\n// Use globalThis to share theme across module loaders (tsx + jiti in dev mode)\nconst THEME_KEY = Symbol.for(\"humain-terminal:theme\");\nconst THEME_KEY_LEGACY_EARENDIL = Symbol.for(\"@earendil-works/pi-coding-agent:theme\");\nconst THEME_KEY_LEGACY_MARIO = Symbol.for(\"@mariozechner/pi-coding-agent:theme\");\n\n// Export theme as a getter that reads from globalThis\n// This ensures all module instances (tsx, jiti) see the same theme\nexport const theme: Theme = new Proxy({} as Theme, {\n\tget(_target, prop) {\n\t\tconst t = (globalThis as Record<symbol, Theme>)[THEME_KEY];\n\t\tif (!t) throw new Error(\"Theme not initialized. Call initTheme() first.\");\n\t\treturn (t as unknown as Record<string | symbol, unknown>)[prop];\n\t},\n});\n\nfunction setGlobalTheme(t: Theme): void {\n\t(globalThis as Record<symbol, Theme>)[THEME_KEY] = t;\n\t(globalThis as Record<symbol, Theme>)[THEME_KEY_LEGACY_EARENDIL] = t;\n\t(globalThis as Record<symbol, Theme>)[THEME_KEY_LEGACY_MARIO] = t;\n}\n\nlet currentThemeName: string | undefined;\nlet themeWatcher: fs.FSWatcher | undefined;\nlet themeReloadTimer: NodeJS.Timeout | undefined;\nlet onThemeChangeCallback: (() => void) | undefined;\nconst registeredThemes = new Map<string, Theme>();\n\nexport function setRegisteredThemes(themes: Theme[]): void {\n\tregisteredThemes.clear();\n\tfor (const theme of themes) {\n\t\tif (theme.name) {\n\t\t\tassertThemeNameIsValid(theme.name);\n\t\t\tregisteredThemes.set(theme.name, theme);\n\t\t}\n\t}\n}\n\nexport function initTheme(themeName?: string, enableWatcher: boolean = false): void {\n\tconst name = themeName ?? getDefaultTheme();\n\tcurrentThemeName = name;\n\ttry {\n\t\tsetGlobalTheme(loadTheme(name));\n\t\tif (enableWatcher) {\n\t\t\tstartThemeWatcher();\n\t\t}\n\t} catch (_error) {\n\t\t// Theme is invalid - fall back to dark theme silently\n\t\tcurrentThemeName = \"dark\";\n\t\tsetGlobalTheme(loadTheme(\"dark\"));\n\t\t// Don't start watcher for fallback theme\n\t}\n}\n\nexport function setTheme(name: string, enableWatcher: boolean = false): { success: boolean; error?: string } {\n\tcurrentThemeName = name;\n\ttry {\n\t\tsetGlobalTheme(loadTheme(name));\n\t\tif (enableWatcher) {\n\t\t\tstartThemeWatcher();\n\t\t}\n\t\tif (onThemeChangeCallback) {\n\t\t\tonThemeChangeCallback();\n\t\t}\n\t\treturn { success: true };\n\t} catch (error) {\n\t\t// Theme is invalid - fall back to dark theme\n\t\tcurrentThemeName = \"dark\";\n\t\tsetGlobalTheme(loadTheme(\"dark\"));\n\t\t// Don't start watcher for fallback theme\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t};\n\t}\n}\n\nexport function setThemeInstance(themeInstance: Theme): void {\n\tsetGlobalTheme(themeInstance);\n\tcurrentThemeName = \"<in-memory>\";\n\tstopThemeWatcher(); // Can't watch a direct instance\n\tif (onThemeChangeCallback) {\n\t\tonThemeChangeCallback();\n\t}\n}\n\nexport function onThemeChange(callback: () => void): void {\n\tonThemeChangeCallback = callback;\n}\n\nfunction startThemeWatcher(): void {\n\tstopThemeWatcher();\n\n\t// Only watch if it's a custom theme (not built-in)\n\tif (!currentThemeName || currentThemeName === \"dark\" || currentThemeName === \"light\") {\n\t\treturn;\n\t}\n\n\tconst customThemesDir = getCustomThemesDir();\n\tconst watchedThemeName = currentThemeName;\n\tconst watchedFileName = `${watchedThemeName}.json`;\n\tconst themeFile = path.join(customThemesDir, watchedFileName);\n\n\t// Only watch if the file exists\n\tif (!fs.existsSync(themeFile)) {\n\t\treturn;\n\t}\n\n\tconst scheduleReload = () => {\n\t\tif (themeReloadTimer) {\n\t\t\tclearTimeout(themeReloadTimer);\n\t\t}\n\t\tthemeReloadTimer = setTimeout(() => {\n\t\t\tthemeReloadTimer = undefined;\n\n\t\t\t// Ignore stale timers after switching themes or stopping the watcher\n\t\t\tif (currentThemeName !== watchedThemeName) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Keep the last successfully loaded theme active if the file is temporarily missing\n\t\t\tif (!fs.existsSync(themeFile)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\t// Reload the theme from disk and refresh the registry cache\n\t\t\t\tconst reloadedTheme = loadThemeFromPath(themeFile);\n\t\t\t\tregisteredThemes.set(watchedThemeName, reloadedTheme);\n\t\t\t\tsetGlobalTheme(reloadedTheme);\n\t\t\t\t// Notify callback (to invalidate UI)\n\t\t\t\tif (onThemeChangeCallback) {\n\t\t\t\t\tonThemeChangeCallback();\n\t\t\t\t}\n\t\t\t} catch (_error) {\n\t\t\t\t// Ignore errors (file might be in invalid state while being edited)\n\t\t\t}\n\t\t}, 100);\n\t};\n\n\tthemeWatcher =\n\t\twatchWithErrorHandler(\n\t\t\tcustomThemesDir,\n\t\t\t(_eventType, filename) => {\n\t\t\t\tif (currentThemeName !== watchedThemeName) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!filename) {\n\t\t\t\t\tscheduleReload();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (filename !== watchedFileName) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tscheduleReload();\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tcloseWatcher(themeWatcher);\n\t\t\t\tthemeWatcher = undefined;\n\t\t\t},\n\t\t) ?? undefined;\n}\n\nexport function stopThemeWatcher(): void {\n\tif (themeReloadTimer) {\n\t\tclearTimeout(themeReloadTimer);\n\t\tthemeReloadTimer = undefined;\n\t}\n\tcloseWatcher(themeWatcher);\n\tthemeWatcher = undefined;\n}\n\n// ============================================================================\n// HTML Export Helpers\n// ============================================================================\n\n/**\n * Convert a 256-color index to hex string.\n * Indices 0-15: basic colors (approximate)\n * Indices 16-231: 6x6x6 color cube\n * Indices 232-255: grayscale ramp\n */\nfunction ansi256ToHex(index: number): string {\n\t// Basic colors (0-15) - approximate common terminal values\n\tconst basicColors = [\n\t\t\"#000000\",\n\t\t\"#800000\",\n\t\t\"#008000\",\n\t\t\"#808000\",\n\t\t\"#000080\",\n\t\t\"#800080\",\n\t\t\"#008080\",\n\t\t\"#c0c0c0\",\n\t\t\"#808080\",\n\t\t\"#ff0000\",\n\t\t\"#00ff00\",\n\t\t\"#ffff00\",\n\t\t\"#0000ff\",\n\t\t\"#ff00ff\",\n\t\t\"#00ffff\",\n\t\t\"#ffffff\",\n\t];\n\tif (index < 16) {\n\t\treturn basicColors[index];\n\t}\n\n\t// Color cube (16-231): 6x6x6 = 216 colors\n\tif (index < 232) {\n\t\tconst cubeIndex = index - 16;\n\t\tconst r = Math.floor(cubeIndex / 36);\n\t\tconst g = Math.floor((cubeIndex % 36) / 6);\n\t\tconst b = cubeIndex % 6;\n\t\tconst toHex = (n: number) => (n === 0 ? 0 : 55 + n * 40).toString(16).padStart(2, \"0\");\n\t\treturn `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n\t}\n\n\t// Grayscale (232-255): 24 shades\n\tconst gray = 8 + (index - 232) * 10;\n\tconst grayHex = gray.toString(16).padStart(2, \"0\");\n\treturn `#${grayHex}${grayHex}${grayHex}`;\n}\n\n/**\n * Get resolved theme colors as CSS-compatible hex strings.\n * Used by HTML export to generate CSS custom properties.\n */\nexport function getResolvedThemeColors(themeName?: string): Record<string, string> {\n\tconst name = themeName ?? currentThemeName ?? getDefaultTheme();\n\tconst isLight = name === \"light\";\n\tconst themeJson = loadThemeJson(name);\n\tconst resolved = resolveThemeColors(withThemeColorFallbacks(themeJson.colors), themeJson.vars);\n\n\t// Default text color for empty values (terminal uses default fg color)\n\tconst defaultText = isLight ? \"#000000\" : \"#e5e5e7\";\n\n\tconst cssColors: Record<string, string> = {};\n\tfor (const [key, value] of Object.entries(resolved)) {\n\t\tif (typeof value === \"number\") {\n\t\t\tcssColors[key] = ansi256ToHex(value);\n\t\t} else if (value === \"\") {\n\t\t\t// Empty means default terminal color - use sensible fallback for HTML\n\t\t\tcssColors[key] = defaultText;\n\t\t} else {\n\t\t\tcssColors[key] = value;\n\t\t}\n\t}\n\treturn cssColors;\n}\n\n/**\n * Check if a theme is a \"light\" theme (for CSS that needs light/dark variants).\n */\nexport function isLightTheme(themeName?: string): boolean {\n\t// Currently just check the name - could be extended to analyze colors\n\treturn themeName === \"light\";\n}\n\n/**\n * Get explicit export colors from theme JSON, if specified.\n * Returns undefined for each color that isn't explicitly set.\n */\nexport function getThemeExportColors(themeName?: string): {\n\tpageBg?: string;\n\tcardBg?: string;\n\tinfoBg?: string;\n} {\n\tconst name = themeName ?? currentThemeName ?? getDefaultTheme();\n\ttry {\n\t\tconst themeJson = loadThemeJson(name);\n\t\tconst exportSection = themeJson.export;\n\t\tif (!exportSection) return {};\n\n\t\tconst vars = themeJson.vars ?? {};\n\t\tconst resolve = (value: ColorValue | undefined): string | undefined => {\n\t\t\tif (value === undefined) return undefined;\n\t\t\tconst resolved = resolveVarRefs(value, vars);\n\t\t\tif (typeof resolved === \"number\") return ansi256ToHex(resolved);\n\t\t\tif (resolved === \"\") return undefined;\n\t\t\treturn resolved;\n\t\t};\n\n\t\treturn {\n\t\t\tpageBg: resolve(exportSection.pageBg),\n\t\t\tcardBg: resolve(exportSection.cardBg),\n\t\t\tinfoBg: resolve(exportSection.infoBg),\n\t\t};\n\t} catch {\n\t\treturn {};\n\t}\n}\n\n// ============================================================================\n// TUI Helpers\n// ============================================================================\n\ntype CliHighlightTheme = Record<string, (s: string) => string>;\n\nlet cachedHighlightThemeFor: Theme | undefined;\nlet cachedCliHighlightTheme: CliHighlightTheme | undefined;\n\nfunction buildCliHighlightTheme(t: Theme): CliHighlightTheme {\n\treturn {\n\t\tkeyword: (s: string) => t.fg(\"syntaxKeyword\", s),\n\t\tbuilt_in: (s: string) => t.fg(\"syntaxType\", s),\n\t\tliteral: (s: string) => t.fg(\"syntaxNumber\", s),\n\t\tnumber: (s: string) => t.fg(\"syntaxNumber\", s),\n\t\tregexp: (s: string) => t.fg(\"syntaxString\", s),\n\t\tstring: (s: string) => t.fg(\"syntaxString\", s),\n\t\tcomment: (s: string) => t.fg(\"syntaxComment\", s),\n\t\tdoctag: (s: string) => t.fg(\"syntaxComment\", s),\n\t\tmeta: (s: string) => t.fg(\"muted\", s),\n\t\tfunction: (s: string) => t.fg(\"syntaxFunction\", s),\n\t\ttitle: (s: string) => t.fg(\"syntaxFunction\", s),\n\t\tclass: (s: string) => t.fg(\"syntaxType\", s),\n\t\ttype: (s: string) => t.fg(\"syntaxType\", s),\n\t\ttag: (s: string) => t.fg(\"syntaxPunctuation\", s),\n\t\tname: (s: string) => t.fg(\"syntaxKeyword\", s),\n\t\tattr: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\tvariable: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\tparams: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\toperator: (s: string) => t.fg(\"syntaxOperator\", s),\n\t\tpunctuation: (s: string) => t.fg(\"syntaxPunctuation\", s),\n\t\temphasis: (s: string) => t.italic(s),\n\t\tstrong: (s: string) => t.bold(s),\n\t\tlink: (s: string) => t.underline(s),\n\t\taddition: (s: string) => t.fg(\"toolDiffAdded\", s),\n\t\tdeletion: (s: string) => t.fg(\"toolDiffRemoved\", s),\n\t};\n}\n\nfunction getCliHighlightTheme(t: Theme): CliHighlightTheme {\n\tif (cachedHighlightThemeFor !== t || !cachedCliHighlightTheme) {\n\t\tcachedHighlightThemeFor = t;\n\t\tcachedCliHighlightTheme = buildCliHighlightTheme(t);\n\t}\n\treturn cachedCliHighlightTheme;\n}\n\n/**\n * Highlight code with syntax coloring based on file extension or language.\n * Returns array of highlighted lines.\n */\nexport function highlightCode(code: string, lang?: string): string[] {\n\t// Validate language before highlighting to avoid stderr spam from cli-highlight\n\tconst validLang = lang && supportsLanguage(lang) ? lang : undefined;\n\t// Skip highlighting when no valid language is specified. cli-highlight's\n\t// auto-detection is unreliable and can misidentify prose as AppleScript,\n\t// LiveCodeServer, etc., coloring random English words as keywords.\n\tif (!validLang) {\n\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t}\n\tconst opts = {\n\t\tlanguage: validLang,\n\t\tignoreIllegals: true,\n\t\ttheme: getCliHighlightTheme(theme),\n\t};\n\ttry {\n\t\treturn highlight(code, opts).split(\"\\n\");\n\t} catch {\n\t\treturn code.split(\"\\n\");\n\t}\n}\n\n/**\n * Get language identifier from file path extension.\n */\nexport function getLanguageFromPath(filePath: string): string | undefined {\n\tconst ext = filePath.split(\".\").pop()?.toLowerCase();\n\tif (!ext) return undefined;\n\n\tconst extToLang: Record<string, string> = {\n\t\tts: \"typescript\",\n\t\ttsx: \"typescript\",\n\t\tjs: \"javascript\",\n\t\tjsx: \"javascript\",\n\t\tmjs: \"javascript\",\n\t\tcjs: \"javascript\",\n\t\tpy: \"python\",\n\t\trb: \"ruby\",\n\t\trs: \"rust\",\n\t\tgo: \"go\",\n\t\tjava: \"java\",\n\t\tkt: \"kotlin\",\n\t\tswift: \"swift\",\n\t\tc: \"c\",\n\t\th: \"c\",\n\t\tcpp: \"cpp\",\n\t\tcc: \"cpp\",\n\t\tcxx: \"cpp\",\n\t\thpp: \"cpp\",\n\t\tcs: \"csharp\",\n\t\tphp: \"php\",\n\t\tsh: \"bash\",\n\t\tbash: \"bash\",\n\t\tzsh: \"bash\",\n\t\tfish: \"fish\",\n\t\tps1: \"powershell\",\n\t\tsql: \"sql\",\n\t\thtml: \"html\",\n\t\thtm: \"html\",\n\t\tcss: \"css\",\n\t\tscss: \"scss\",\n\t\tsass: \"sass\",\n\t\tless: \"less\",\n\t\tjson: \"json\",\n\t\tyaml: \"yaml\",\n\t\tyml: \"yaml\",\n\t\ttoml: \"toml\",\n\t\txml: \"xml\",\n\t\tmd: \"markdown\",\n\t\tmarkdown: \"markdown\",\n\t\tdockerfile: \"dockerfile\",\n\t\tmakefile: \"makefile\",\n\t\tcmake: \"cmake\",\n\t\tlua: \"lua\",\n\t\tperl: \"perl\",\n\t\tr: \"r\",\n\t\tscala: \"scala\",\n\t\tclj: \"clojure\",\n\t\tex: \"elixir\",\n\t\texs: \"elixir\",\n\t\terl: \"erlang\",\n\t\ths: \"haskell\",\n\t\tml: \"ocaml\",\n\t\tvim: \"vim\",\n\t\tgraphql: \"graphql\",\n\t\tproto: \"protobuf\",\n\t\ttf: \"hcl\",\n\t\thcl: \"hcl\",\n\t};\n\n\treturn extToLang[ext];\n}\n\nexport function getMarkdownTheme(): MarkdownTheme {\n\treturn {\n\t\theading: (text: string) => theme.fg(\"mdHeading\", text),\n\t\tlink: (text: string) => theme.fg(\"mdLink\", text),\n\t\tlinkUrl: (text: string) => theme.fg(\"mdLinkUrl\", text),\n\t\tcode: (text: string) => theme.fg(\"mdCode\", text),\n\t\tcodeBlock: (text: string) => theme.fg(\"mdCodeBlock\", text),\n\t\tcodeBlockBorder: (text: string) => theme.fg(\"mdCodeBlockBorder\", text),\n\t\tquote: (text: string) => theme.fg(\"mdQuote\", text),\n\t\tquoteBorder: (text: string) => theme.fg(\"mdQuoteBorder\", text),\n\t\thr: (text: string) => theme.fg(\"mdHr\", text),\n\t\tlistBullet: (text: string) => theme.fg(\"mdListBullet\", text),\n\t\tbold: (text: string) => theme.bold(text),\n\t\titalic: (text: string) => theme.italic(text),\n\t\tunderline: (text: string) => theme.underline(text),\n\t\tstrikethrough: (text: string) => chalk.strikethrough(text),\n\t\thighlightCode: (code: string, lang?: string): string[] => {\n\t\t\t// Validate language before highlighting to avoid stderr spam from cli-highlight\n\t\t\tconst validLang = lang && supportsLanguage(lang) ? lang : undefined;\n\t\t\t// Skip highlighting when no valid language is specified. cli-highlight's\n\t\t\t// auto-detection is unreliable and can misidentify prose as AppleScript,\n\t\t\t// LiveCodeServer, etc., coloring random English words as keywords.\n\t\t\tif (!validLang) {\n\t\t\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t\t\t}\n\t\t\tconst opts = {\n\t\t\t\tlanguage: validLang,\n\t\t\t\tignoreIllegals: true,\n\t\t\t\ttheme: getCliHighlightTheme(theme),\n\t\t\t};\n\t\t\ttry {\n\t\t\t\treturn highlight(code, opts).split(\"\\n\");\n\t\t\t} catch {\n\t\t\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t\t\t}\n\t\t},\n\t};\n}\n\nexport function getSelectListTheme(): SelectListTheme {\n\treturn {\n\t\tselectedPrefix: (text: string) => theme.fg(\"accent\", text),\n\t\tselectedText: (text: string) => theme.fg(\"accent\", text),\n\t\tdescription: (text: string) => theme.fg(\"muted\", text),\n\t\tscrollInfo: (text: string) => theme.fg(\"muted\", text),\n\t\tnoMatch: (text: string) => theme.fg(\"muted\", text),\n\t};\n}\n\nexport function getEditorTheme(): EditorTheme {\n\treturn {\n\t\tborderColor: (text: string) => theme.fg(\"borderMuted\", text),\n\t\tselectList: getSelectListTheme(),\n\t};\n}\n\nexport function getSettingsListTheme(): SettingsListTheme {\n\treturn {\n\t\tlabel: (text: string, selected: boolean) => (selected ? theme.fg(\"accent\", text) : text),\n\t\tvalue: (text: string, selected: boolean) => (selected ? theme.fg(\"accent\", text) : theme.fg(\"muted\", text)),\n\t\tdescription: (text: string) => theme.fg(\"dim\", text),\n\t\tcursor: theme.fg(\"accent\", \"→ \"),\n\t\thint: (text: string) => theme.fg(\"dim\", text),\n\t};\n}\n"]}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EACN,KAAK,WAAW,EAEhB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EAA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AAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBjF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAGxD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,CAwBA;AAiDD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBnE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkExE;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAqChD;AAED,wBAAgB,kBAAkB,IAAI,eAAe,CAQpD;AAED,wBAAgB,cAAc,IAAI,WAAW,CAK5C;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,CAQxD"}
@@ -31,9 +31,11 @@ const ThemeJsonSchema = Type.Object({
31
31
  dim: ColorValueSchema,
32
32
  text: ColorValueSchema,
33
33
  thinkingText: ColorValueSchema,
34
- // Backgrounds & Content Text (11 required, 1 optional)
34
+ // Backgrounds & Content Text (11 required, 3 optional)
35
35
  selectedBg: ColorValueSchema,
36
36
  scrollbarThumb: Type.Optional(ColorValueSchema),
37
+ searchMatchBg: Type.Optional(ColorValueSchema),
38
+ searchMatchText: Type.Optional(ColorValueSchema),
37
39
  userMessageBg: ColorValueSchema,
38
40
  userMessageText: ColorValueSchema,
39
41
  customMessageBg: ColorValueSchema,
@@ -229,25 +231,25 @@ function withThemeColorFallbacks(colors) {
229
231
  ...colors,
230
232
  thinkingMax: colors.thinkingMax ?? colors.thinkingXhigh,
231
233
  scrollbarThumb: colors.scrollbarThumb ?? colors.selectedBg,
234
+ searchMatchBg: colors.searchMatchBg ?? colors.selectedBg,
235
+ searchMatchText: colors.searchMatchText ?? colors.text,
232
236
  };
233
237
  }
234
238
  // ============================================================================
235
239
  // Theme Class
236
240
  // ============================================================================
237
241
  export class Theme {
238
- name;
239
- sourcePath;
240
- sourceInfo;
241
- fgColors;
242
- bgColors;
243
- mode;
244
242
  constructor(fgColors, bgColors, mode, options = {}) {
245
243
  this.name = options.name;
246
244
  this.sourcePath = options.sourcePath;
247
245
  this.sourceInfo = options.sourceInfo;
248
246
  this.mode = mode;
249
247
  this.fgColors = new Map();
250
- const colors = { ...fgColors, thinkingMax: fgColors.thinkingMax ?? fgColors.thinkingXhigh };
248
+ const colors = {
249
+ ...fgColors,
250
+ thinkingMax: fgColors.thinkingMax ?? fgColors.thinkingXhigh,
251
+ searchMatchText: fgColors.searchMatchText ?? fgColors.text,
252
+ };
251
253
  for (const [key, value] of Object.entries(colors)) {
252
254
  this.fgColors.set(key, fgAnsi(value, mode));
253
255
  }
@@ -255,6 +257,7 @@ export class Theme {
255
257
  const backgrounds = {
256
258
  ...bgColors,
257
259
  scrollbarThumb: bgColors.scrollbarThumb ?? bgColors.selectedBg,
260
+ searchMatchBg: bgColors.searchMatchBg ?? bgColors.selectedBg,
258
261
  };
259
262
  for (const [key, value] of Object.entries(backgrounds)) {
260
263
  this.bgColors.set(key, bgAnsi(value, mode));
@@ -477,6 +480,7 @@ function createTheme(themeJson, mode, sourcePath) {
477
480
  const bgColorKeys = new Set([
478
481
  "selectedBg",
479
482
  "scrollbarThumb",
483
+ "searchMatchBg",
480
484
  "userMessageBg",
481
485
  "customMessageBg",
482
486
  "toolPendingBg",