@bastani/atomic 0.9.9-alpha.1 → 0.9.9-alpha.3

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 (576) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/builtin/cursor/CHANGELOG.md +12 -0
  3. package/dist/builtin/cursor/package.json +3 -3
  4. package/dist/builtin/intercom/CHANGELOG.md +14 -0
  5. package/dist/builtin/intercom/README.md +10 -3
  6. package/dist/builtin/intercom/broker/client.ts +2 -0
  7. package/dist/builtin/intercom/broker/send-handler.ts +22 -20
  8. package/dist/builtin/intercom/foreground-detach-handoff.ts +3 -1
  9. package/dist/builtin/intercom/inbound-idle-queue.ts +82 -0
  10. package/dist/builtin/intercom/index-heavy.ts +47 -37
  11. package/dist/builtin/intercom/intercom-tool.ts +6 -4
  12. package/dist/builtin/intercom/intercom-utils.ts +30 -0
  13. package/dist/builtin/intercom/lifecycle.ts +8 -5
  14. package/dist/builtin/intercom/package.json +3 -3
  15. package/dist/builtin/intercom/reply-tracker.ts +19 -19
  16. package/dist/builtin/intercom/session-target.ts +68 -0
  17. package/dist/builtin/intercom/skills/intercom/SKILL.md +7 -4
  18. package/dist/builtin/intercom/source-ownership.ts +34 -0
  19. package/dist/builtin/intercom/subagent-relay.ts +45 -20
  20. package/dist/builtin/intercom/terminal-ordering-barrier.ts +111 -0
  21. package/dist/builtin/intercom/types.ts +5 -0
  22. package/dist/builtin/mcp/CHANGELOG.md +13 -0
  23. package/dist/builtin/mcp/package.json +4 -4
  24. package/dist/builtin/subagents/CHANGELOG.md +13 -0
  25. package/dist/builtin/subagents/package.json +5 -5
  26. package/dist/builtin/subagents/src/runs/background/notify.ts +53 -9
  27. package/dist/builtin/subagents/src/shared/types-config.ts +1 -0
  28. package/dist/builtin/web-access/CHANGELOG.md +13 -0
  29. package/dist/builtin/web-access/package.json +3 -3
  30. package/dist/builtin/web-access/web-search-tool.ts +1 -2
  31. package/dist/builtin/workflows/CHANGELOG.md +13 -0
  32. package/dist/builtin/workflows/package.json +3 -3
  33. package/dist/builtin/workflows/src/extension/workflow-tool.ts +18 -2
  34. package/dist/builtin/workflows/src/shared/serializable.ts +1 -1
  35. package/dist/bun/cli.d.ts.map +1 -1
  36. package/dist/bun/internal-intercom-broker.d.ts.map +1 -1
  37. package/dist/bun/register-bedrock.d.ts.map +1 -1
  38. package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
  39. package/dist/bun/split-loader.d.ts.map +1 -1
  40. package/dist/cli/args.d.ts.map +1 -1
  41. package/dist/cli/config-selector.d.ts.map +1 -1
  42. package/dist/cli/file-processor.d.ts.map +1 -1
  43. package/dist/cli/initial-message.d.ts.map +1 -1
  44. package/dist/cli/list-models.d.ts.map +1 -1
  45. package/dist/cli/project-trust.d.ts.map +1 -1
  46. package/dist/cli/session-picker.d.ts.map +1 -1
  47. package/dist/cli/startup-ui.d.ts.map +1 -1
  48. package/dist/cli.d.ts.map +1 -1
  49. package/dist/config-self-update.d.ts.map +1 -1
  50. package/dist/config.d.ts.map +1 -1
  51. package/dist/core/agent-session-accessors.d.ts.map +1 -1
  52. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  53. package/dist/core/agent-session-bash.d.ts.map +1 -1
  54. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  55. package/dist/core/agent-session-events.d.ts.map +1 -1
  56. package/dist/core/agent-session-export.d.ts.map +1 -1
  57. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  58. package/dist/core/agent-session-extension-bindings.js +9 -0
  59. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  60. package/dist/core/agent-session-message-queue.d.ts +4 -1
  61. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  62. package/dist/core/agent-session-message-queue.js +35 -0
  63. package/dist/core/agent-session-message-queue.js.map +1 -1
  64. package/dist/core/agent-session-methods.d.ts +2 -1
  65. package/dist/core/agent-session-methods.d.ts.map +1 -1
  66. package/dist/core/agent-session-methods.js.map +1 -1
  67. package/dist/core/agent-session-models.d.ts.map +1 -1
  68. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  69. package/dist/core/agent-session-retry.d.ts.map +1 -1
  70. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  71. package/dist/core/agent-session-services.d.ts.map +1 -1
  72. package/dist/core/agent-session-skill-block.d.ts.map +1 -1
  73. package/dist/core/agent-session-state.d.ts.map +1 -1
  74. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  75. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  76. package/dist/core/agent-session-tree.d.ts.map +1 -1
  77. package/dist/core/agent-session-types.d.ts.map +1 -1
  78. package/dist/core/agent-session.d.ts.map +1 -1
  79. package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
  80. package/dist/core/async/format.d.ts.map +1 -1
  81. package/dist/core/async/job-manager.d.ts.map +1 -1
  82. package/dist/core/async/session-manager.d.ts.map +1 -1
  83. package/dist/core/async/types.d.ts.map +1 -1
  84. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  85. package/dist/core/auth-guidance.d.ts.map +1 -1
  86. package/dist/core/auth-storage-backends.d.ts.map +1 -1
  87. package/dist/core/auth-storage.d.ts +4 -0
  88. package/dist/core/auth-storage.d.ts.map +1 -1
  89. package/dist/core/bash-executor.d.ts.map +1 -1
  90. package/dist/core/builtin-packages.d.ts.map +1 -1
  91. package/dist/core/codex-fast-mode.d.ts.map +1 -1
  92. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  93. package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
  94. package/dist/core/compaction/compaction-parameters.d.ts.map +1 -1
  95. package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
  96. package/dist/core/compaction/compaction-types.d.ts.map +1 -1
  97. package/dist/core/compaction/compaction.d.ts.map +1 -1
  98. package/dist/core/compaction/deleted-ranges.d.ts.map +1 -1
  99. package/dist/core/compaction/index.d.ts.map +1 -1
  100. package/dist/core/compaction/range-planner.d.ts.map +1 -1
  101. package/dist/core/compaction/transcript-serialization.d.ts.map +1 -1
  102. package/dist/core/compaction/utils.d.ts.map +1 -1
  103. package/dist/core/context-window.d.ts.map +1 -1
  104. package/dist/core/copilot-anthropic-sse-repair.d.ts.map +1 -1
  105. package/dist/core/copilot-errors.d.ts.map +1 -1
  106. package/dist/core/copilot-gemini-payload-sanitizer.d.ts.map +1 -1
  107. package/dist/core/copilot-gemini-reasoning.d.ts.map +1 -1
  108. package/dist/core/copilot-gemini-tool-arguments.d.ts.map +1 -1
  109. package/dist/core/copilot-hosts.d.ts.map +1 -1
  110. package/dist/core/copilot-model-catalog.d.ts.map +1 -1
  111. package/dist/core/copilot-model-static-fallbacks.d.ts.map +1 -1
  112. package/dist/core/copilot-model-synthesis.d.ts.map +1 -1
  113. package/dist/core/defaults.d.ts.map +1 -1
  114. package/dist/core/diagnostics.d.ts.map +1 -1
  115. package/dist/core/event-bus.d.ts.map +1 -1
  116. package/dist/core/exec.d.ts.map +1 -1
  117. package/dist/core/experimental.d.ts.map +1 -1
  118. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  119. package/dist/core/export-html/index.d.ts.map +1 -1
  120. package/dist/core/export-html/template-script.d.ts.map +1 -1
  121. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  122. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  123. package/dist/core/extensions/api-types.d.ts +3 -1
  124. package/dist/core/extensions/api-types.d.ts.map +1 -1
  125. package/dist/core/extensions/api-types.js.map +1 -1
  126. package/dist/core/extensions/command-types.d.ts.map +1 -1
  127. package/dist/core/extensions/context-types.d.ts.map +1 -1
  128. package/dist/core/extensions/event-results.d.ts.map +1 -1
  129. package/dist/core/extensions/event-types.d.ts.map +1 -1
  130. package/dist/core/extensions/index.d.ts +1 -1
  131. package/dist/core/extensions/index.d.ts.map +1 -1
  132. package/dist/core/extensions/index.js.map +1 -1
  133. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  134. package/dist/core/extensions/loader-api.js +4 -0
  135. package/dist/core/extensions/loader-api.js.map +1 -1
  136. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  137. package/dist/core/extensions/loader-discovery.d.ts.map +1 -1
  138. package/dist/core/extensions/loader-resources.d.ts.map +1 -1
  139. package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
  140. package/dist/core/extensions/loader-runtime.js +1 -0
  141. package/dist/core/extensions/loader-runtime.js.map +1 -1
  142. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  143. package/dist/core/extensions/loader.d.ts.map +1 -1
  144. package/dist/core/extensions/message-types.d.ts +3 -0
  145. package/dist/core/extensions/message-types.d.ts.map +1 -1
  146. package/dist/core/extensions/message-types.js.map +1 -1
  147. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  148. package/dist/core/extensions/reactive-widget.d.ts.map +1 -1
  149. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  150. package/dist/core/extensions/runner-events.d.ts.map +1 -1
  151. package/dist/core/extensions/runner-handlers.d.ts.map +1 -1
  152. package/dist/core/extensions/runner-project-trust.d.ts.map +1 -1
  153. package/dist/core/extensions/runner-registries.d.ts.map +1 -1
  154. package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -1
  155. package/dist/core/extensions/runner-ui.d.ts.map +1 -1
  156. package/dist/core/extensions/runner.d.ts.map +1 -1
  157. package/dist/core/extensions/runner.js +1 -0
  158. package/dist/core/extensions/runner.js.map +1 -1
  159. package/dist/core/extensions/runtime-types.d.ts +3 -1
  160. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  161. package/dist/core/extensions/runtime-types.js.map +1 -1
  162. package/dist/core/extensions/session-events.d.ts.map +1 -1
  163. package/dist/core/extensions/tool-events.d.ts.map +1 -1
  164. package/dist/core/extensions/tool-types.d.ts.map +1 -1
  165. package/dist/core/extensions/types.d.ts.map +1 -1
  166. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  167. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  168. package/dist/core/flattened-tool-arguments.d.ts.map +1 -1
  169. package/dist/core/footer-data-provider.d.ts.map +1 -1
  170. package/dist/core/http-dispatcher.d.ts.map +1 -1
  171. package/dist/core/index.d.ts.map +1 -1
  172. package/dist/core/keybindings.d.ts.map +1 -1
  173. package/dist/core/messages.d.ts.map +1 -1
  174. package/dist/core/model-registry-auth.d.ts.map +1 -1
  175. package/dist/core/model-registry-builtins.d.ts.map +1 -1
  176. package/dist/core/model-registry-builtins.js.map +1 -1
  177. package/dist/core/model-registry-custom-loader.d.ts.map +1 -1
  178. package/dist/core/model-registry-custom-loader.js.map +1 -1
  179. package/dist/core/model-registry-dynamic.d.ts.map +1 -1
  180. package/dist/core/model-registry-loader.d.ts.map +1 -1
  181. package/dist/core/model-registry-schemas.d.ts +65 -13
  182. package/dist/core/model-registry-schemas.d.ts.map +1 -1
  183. package/dist/core/model-registry-schemas.js +5 -1
  184. package/dist/core/model-registry-schemas.js.map +1 -1
  185. package/dist/core/model-registry-types.d.ts.map +1 -1
  186. package/dist/core/model-registry.d.ts.map +1 -1
  187. package/dist/core/model-resolver-cli.d.ts.map +1 -1
  188. package/dist/core/model-resolver-defaults.d.ts.map +1 -1
  189. package/dist/core/model-resolver-initial.d.ts.map +1 -1
  190. package/dist/core/model-resolver-patterns.d.ts.map +1 -1
  191. package/dist/core/model-resolver-scope.d.ts.map +1 -1
  192. package/dist/core/model-resolver-types.d.ts.map +1 -1
  193. package/dist/core/model-resolver.d.ts.map +1 -1
  194. package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -1
  195. package/dist/core/output-guard.d.ts.map +1 -1
  196. package/dist/core/package-manager-auto-resources.d.ts.map +1 -1
  197. package/dist/core/package-manager-command.d.ts.map +1 -1
  198. package/dist/core/package-manager-constants.d.ts.map +1 -1
  199. package/dist/core/package-manager-env.d.ts.map +1 -1
  200. package/dist/core/package-manager-git.d.ts.map +1 -1
  201. package/dist/core/package-manager-manifest.d.ts.map +1 -1
  202. package/dist/core/package-manager-npm.d.ts.map +1 -1
  203. package/dist/core/package-manager-operations.d.ts.map +1 -1
  204. package/dist/core/package-manager-paths.d.ts.map +1 -1
  205. package/dist/core/package-manager-progress.d.ts.map +1 -1
  206. package/dist/core/package-manager-resolver.d.ts.map +1 -1
  207. package/dist/core/package-manager-resource-accumulator.d.ts.map +1 -1
  208. package/dist/core/package-manager-resource-collector.d.ts.map +1 -1
  209. package/dist/core/package-manager-resource-files.d.ts.map +1 -1
  210. package/dist/core/package-manager-resource-patterns.d.ts.map +1 -1
  211. package/dist/core/package-manager-settings.d.ts.map +1 -1
  212. package/dist/core/package-manager-source.d.ts.map +1 -1
  213. package/dist/core/package-manager-types.d.ts.map +1 -1
  214. package/dist/core/package-manager.d.ts.map +1 -1
  215. package/dist/core/project-trust.d.ts.map +1 -1
  216. package/dist/core/prompt-templates-async.d.ts.map +1 -1
  217. package/dist/core/prompt-templates.d.ts.map +1 -1
  218. package/dist/core/provider-attribution.d.ts.map +1 -1
  219. package/dist/core/provider-context-usage.d.ts.map +1 -1
  220. package/dist/core/provider-display-names.d.ts.map +1 -1
  221. package/dist/core/resolve-config-value.d.ts.map +1 -1
  222. package/dist/core/resource-loader-assets.d.ts.map +1 -1
  223. package/dist/core/resource-loader-context-files.d.ts.map +1 -1
  224. package/dist/core/resource-loader-core.d.ts.map +1 -1
  225. package/dist/core/resource-loader-discovery.d.ts.map +1 -1
  226. package/dist/core/resource-loader-extensions.d.ts.map +1 -1
  227. package/dist/core/resource-loader-helpers.d.ts.map +1 -1
  228. package/dist/core/resource-loader-internals.d.ts.map +1 -1
  229. package/dist/core/resource-loader-package-resources.d.ts.map +1 -1
  230. package/dist/core/resource-loader-paths.d.ts.map +1 -1
  231. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  232. package/dist/core/resource-loader-source-info.d.ts.map +1 -1
  233. package/dist/core/resource-loader-types.d.ts.map +1 -1
  234. package/dist/core/resource-loader.d.ts.map +1 -1
  235. package/dist/core/sdk-exports.d.ts.map +1 -1
  236. package/dist/core/sdk-types.d.ts.map +1 -1
  237. package/dist/core/sdk.d.ts.map +1 -1
  238. package/dist/core/session-cwd.d.ts.map +1 -1
  239. package/dist/core/session-entry-normalization.d.ts.map +1 -1
  240. package/dist/core/session-manager-archive.d.ts.map +1 -1
  241. package/dist/core/session-manager-classification.d.ts.map +1 -1
  242. package/dist/core/session-manager-core.d.ts.map +1 -1
  243. package/dist/core/session-manager-entries.d.ts.map +1 -1
  244. package/dist/core/session-manager-history.d.ts.map +1 -1
  245. package/dist/core/session-manager-list.d.ts.map +1 -1
  246. package/dist/core/session-manager-migrations.d.ts.map +1 -1
  247. package/dist/core/session-manager-paths.d.ts.map +1 -1
  248. package/dist/core/session-manager-storage.d.ts.map +1 -1
  249. package/dist/core/session-manager-types.d.ts.map +1 -1
  250. package/dist/core/session-manager-validation.d.ts.map +1 -1
  251. package/dist/core/session-manager.d.ts.map +1 -1
  252. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  253. package/dist/core/settings-manager-core.d.ts.map +1 -1
  254. package/dist/core/settings-manager-internals.d.ts.map +1 -1
  255. package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
  256. package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
  257. package/dist/core/settings-manager.d.ts.map +1 -1
  258. package/dist/core/settings-merge.d.ts.map +1 -1
  259. package/dist/core/settings-storage.d.ts.map +1 -1
  260. package/dist/core/settings-types.d.ts.map +1 -1
  261. package/dist/core/skills-async.d.ts.map +1 -1
  262. package/dist/core/skills.d.ts.map +1 -1
  263. package/dist/core/slash-commands.d.ts.map +1 -1
  264. package/dist/core/source-info.d.ts.map +1 -1
  265. package/dist/core/system-prompt.d.ts.map +1 -1
  266. package/dist/core/telemetry.d.ts.map +1 -1
  267. package/dist/core/thinking-blocks.d.ts.map +1 -1
  268. package/dist/core/timings.d.ts.map +1 -1
  269. package/dist/core/tools/artifact-protocol.d.ts.map +1 -1
  270. package/dist/core/tools/artifacts.d.ts.map +1 -1
  271. package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
  272. package/dist/core/tools/ask-user-question/config.d.ts.map +1 -1
  273. package/dist/core/tools/ask-user-question/index.d.ts.map +1 -1
  274. package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts.map +1 -1
  275. package/dist/core/tools/ask-user-question/state/inline-input.d.ts.map +1 -1
  276. package/dist/core/tools/ask-user-question/state/key-router.d.ts.map +1 -1
  277. package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
  278. package/dist/core/tools/ask-user-question/state/row-intent.d.ts.map +1 -1
  279. package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts.map +1 -1
  280. package/dist/core/tools/ask-user-question/state/selectors/derivations.d.ts.map +1 -1
  281. package/dist/core/tools/ask-user-question/state/selectors/focus.d.ts.map +1 -1
  282. package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts.map +1 -1
  283. package/dist/core/tools/ask-user-question/state/state-reducer.d.ts.map +1 -1
  284. package/dist/core/tools/ask-user-question/state/state.d.ts.map +1 -1
  285. package/dist/core/tools/ask-user-question/tool/format-answer.d.ts.map +1 -1
  286. package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts.map +1 -1
  287. package/dist/core/tools/ask-user-question/tool/types.d.ts.map +1 -1
  288. package/dist/core/tools/ask-user-question/tool/validate-questionnaire.d.ts.map +1 -1
  289. package/dist/core/tools/ask-user-question/view/body-residual-spacer.d.ts.map +1 -1
  290. package/dist/core/tools/ask-user-question/view/component-binding.d.ts.map +1 -1
  291. package/dist/core/tools/ask-user-question/view/components/chat-row-view.d.ts.map +1 -1
  292. package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
  293. package/dist/core/tools/ask-user-question/view/components/option-list-view.d.ts.map +1 -1
  294. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts.map +1 -1
  295. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts.map +1 -1
  296. package/dist/core/tools/ask-user-question/view/components/preview/preview-box-renderer.d.ts.map +1 -1
  297. package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.d.ts.map +1 -1
  298. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts.map +1 -1
  299. package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts.map +1 -1
  300. package/dist/core/tools/ask-user-question/view/components/tab-bar.d.ts.map +1 -1
  301. package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
  302. package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts.map +1 -1
  303. package/dist/core/tools/ask-user-question/view/props-adapter.d.ts.map +1 -1
  304. package/dist/core/tools/ask-user-question/view/stateful-view.d.ts.map +1 -1
  305. package/dist/core/tools/ask-user-question/view/tab-components.d.ts.map +1 -1
  306. package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts.map +1 -1
  307. package/dist/core/tools/bash-async-execution.d.ts.map +1 -1
  308. package/dist/core/tools/bash-async-jobs.d.ts.map +1 -1
  309. package/dist/core/tools/bash-async-output.d.ts.map +1 -1
  310. package/dist/core/tools/bash-interceptor.d.ts.map +1 -1
  311. package/dist/core/tools/bash-leading-cd.d.ts.map +1 -1
  312. package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
  313. package/dist/core/tools/bash.d.ts.map +1 -1
  314. package/dist/core/tools/block-resolver.d.ts.map +1 -1
  315. package/dist/core/tools/conflict-registry.d.ts.map +1 -1
  316. package/dist/core/tools/directory-tree.d.ts.map +1 -1
  317. package/dist/core/tools/edit-diff-preserve.d.ts.map +1 -1
  318. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  319. package/dist/core/tools/edit.d.ts.map +1 -1
  320. package/dist/core/tools/fetch-url.d.ts.map +1 -1
  321. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  322. package/dist/core/tools/find.d.ts.map +1 -1
  323. package/dist/core/tools/glob-path-utils.d.ts.map +1 -1
  324. package/dist/core/tools/grep.d.ts.map +1 -1
  325. package/dist/core/tools/hashline-engine/apply.d.ts.map +1 -1
  326. package/dist/core/tools/hashline-engine/block.d.ts.map +1 -1
  327. package/dist/core/tools/hashline-engine/diff-preview.d.ts.map +1 -1
  328. package/dist/core/tools/hashline-engine/format.d.ts.map +1 -1
  329. package/dist/core/tools/hashline-engine/fs.d.ts.map +1 -1
  330. package/dist/core/tools/hashline-engine/index.d.ts.map +1 -1
  331. package/dist/core/tools/hashline-engine/input.d.ts.map +1 -1
  332. package/dist/core/tools/hashline-engine/messages.d.ts.map +1 -1
  333. package/dist/core/tools/hashline-engine/mismatch.d.ts.map +1 -1
  334. package/dist/core/tools/hashline-engine/normalize.d.ts.map +1 -1
  335. package/dist/core/tools/hashline-engine/parser.d.ts.map +1 -1
  336. package/dist/core/tools/hashline-engine/patcher.d.ts.map +1 -1
  337. package/dist/core/tools/hashline-engine/prefixes.d.ts.map +1 -1
  338. package/dist/core/tools/hashline-engine/recovery.d.ts.map +1 -1
  339. package/dist/core/tools/hashline-engine/snapshots.d.ts.map +1 -1
  340. package/dist/core/tools/hashline-engine/stream.d.ts.map +1 -1
  341. package/dist/core/tools/hashline-engine/tokenizer.d.ts.map +1 -1
  342. package/dist/core/tools/hashline-engine/types.d.ts.map +1 -1
  343. package/dist/core/tools/hashline.d.ts.map +1 -1
  344. package/dist/core/tools/index.d.ts.map +1 -1
  345. package/dist/core/tools/ls.d.ts.map +1 -1
  346. package/dist/core/tools/notebook.d.ts.map +1 -1
  347. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  348. package/dist/core/tools/oversized-tool-result.d.ts.map +1 -1
  349. package/dist/core/tools/path-utils.d.ts.map +1 -1
  350. package/dist/core/tools/read-document-extract.d.ts.map +1 -1
  351. package/dist/core/tools/read-selectors.d.ts.map +1 -1
  352. package/dist/core/tools/read-url.d.ts.map +1 -1
  353. package/dist/core/tools/read.d.ts.map +1 -1
  354. package/dist/core/tools/render-utils.d.ts.map +1 -1
  355. package/dist/core/tools/resource-selectors.d.ts.map +1 -1
  356. package/dist/core/tools/search-details.d.ts.map +1 -1
  357. package/dist/core/tools/search-line-ranges.d.ts.map +1 -1
  358. package/dist/core/tools/search-native.d.ts.map +1 -1
  359. package/dist/core/tools/search.d.ts.map +1 -1
  360. package/dist/core/tools/structured-output.d.ts.map +1 -1
  361. package/dist/core/tools/todos-execute.d.ts.map +1 -1
  362. package/dist/core/tools/todos-locks.d.ts.map +1 -1
  363. package/dist/core/tools/todos-model.d.ts.map +1 -1
  364. package/dist/core/tools/todos-mutations.d.ts.map +1 -1
  365. package/dist/core/tools/todos-paths.d.ts.map +1 -1
  366. package/dist/core/tools/todos-render.d.ts.map +1 -1
  367. package/dist/core/tools/todos-storage.d.ts.map +1 -1
  368. package/dist/core/tools/todos-types.d.ts.map +1 -1
  369. package/dist/core/tools/todos-types.js +1 -1
  370. package/dist/core/tools/todos-types.js.map +1 -1
  371. package/dist/core/tools/todos.d.ts.map +1 -1
  372. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  373. package/dist/core/tools/tool-definition-wrapper.js +6 -2
  374. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  375. package/dist/core/tools/tool-limits.d.ts.map +1 -1
  376. package/dist/core/tools/truncate.d.ts.map +1 -1
  377. package/dist/core/tools/url-ip-guards.d.ts.map +1 -1
  378. package/dist/core/tools/write.d.ts.map +1 -1
  379. package/dist/core/trust-manager.d.ts.map +1 -1
  380. package/dist/core/typebox-compat.d.ts +12 -0
  381. package/dist/core/typebox-compat.d.ts.map +1 -0
  382. package/dist/core/typebox-compat.js +10 -0
  383. package/dist/core/typebox-compat.js.map +1 -0
  384. package/dist/index-extensions.d.ts.map +1 -1
  385. package/dist/index.d.ts +1 -0
  386. package/dist/index.d.ts.map +1 -1
  387. package/dist/index.js +1 -0
  388. package/dist/index.js.map +1 -1
  389. package/dist/main-app-mode.d.ts.map +1 -1
  390. package/dist/main-deferred-startup.d.ts.map +1 -1
  391. package/dist/main-early-input.d.ts.map +1 -1
  392. package/dist/main-session-options.d.ts.map +1 -1
  393. package/dist/main-session.d.ts.map +1 -1
  394. package/dist/main-stdio.d.ts.map +1 -1
  395. package/dist/main.d.ts.map +1 -1
  396. package/dist/migrations-config-values.d.ts.map +1 -1
  397. package/dist/migrations.d.ts.map +1 -1
  398. package/dist/modes/index.d.ts.map +1 -1
  399. package/dist/modes/interactive/chat-input-actions.d.ts.map +1 -1
  400. package/dist/modes/interactive/components/armin.d.ts.map +1 -1
  401. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  402. package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
  403. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  404. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  405. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  406. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  407. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  408. package/dist/modes/interactive/components/chat-session-host-editor.d.ts.map +1 -1
  409. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  410. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  411. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
  412. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  413. package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts.map +1 -1
  414. package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
  415. package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -1
  416. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  417. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  418. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  419. package/dist/modes/interactive/components/config-selector-list.d.ts.map +1 -1
  420. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  421. package/dist/modes/interactive/components/context-window-selector.d.ts.map +1 -1
  422. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  423. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  424. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  425. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  426. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  427. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  428. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  429. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  430. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  431. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  432. package/dist/modes/interactive/components/fast-mode-selector.d.ts.map +1 -1
  433. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  434. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  435. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  436. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  437. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  438. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  439. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  440. package/dist/modes/interactive/components/session-selector-delete.d.ts.map +1 -1
  441. package/dist/modes/interactive/components/session-selector-header.d.ts.map +1 -1
  442. package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
  443. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  444. package/dist/modes/interactive/components/session-selector-tree.d.ts.map +1 -1
  445. package/dist/modes/interactive/components/session-selector-types.d.ts.map +1 -1
  446. package/dist/modes/interactive/components/session-selector-utils.d.ts.map +1 -1
  447. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  448. package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
  449. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  450. package/dist/modes/interactive/components/settings-selector-options.d.ts.map +1 -1
  451. package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
  452. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  453. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  454. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  455. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  456. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  457. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  458. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  459. package/dist/modes/interactive/components/tree-selector-component.d.ts.map +1 -1
  460. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  461. package/dist/modes/interactive/components/tree-selector-help.d.ts.map +1 -1
  462. package/dist/modes/interactive/components/tree-selector-label-input.d.ts.map +1 -1
  463. package/dist/modes/interactive/components/tree-selector-list.d.ts.map +1 -1
  464. package/dist/modes/interactive/components/tree-selector-model.d.ts.map +1 -1
  465. package/dist/modes/interactive/components/tree-selector-types.d.ts.map +1 -1
  466. package/dist/modes/interactive/components/tree-selector-viewport.d.ts.map +1 -1
  467. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  468. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
  469. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  470. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  471. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  472. package/dist/modes/interactive/components/working-status.d.ts.map +1 -1
  473. package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
  474. package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -1
  475. package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
  476. package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
  477. package/dist/modes/interactive/interactive-bash-compact.d.ts.map +1 -1
  478. package/dist/modes/interactive/interactive-child-ordering.d.ts.map +1 -1
  479. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  480. package/dist/modes/interactive/interactive-editor-actions.d.ts.map +1 -1
  481. package/dist/modes/interactive/interactive-extension-context.d.ts.map +1 -1
  482. package/dist/modes/interactive/interactive-extension-custom-ui.d.ts.map +1 -1
  483. package/dist/modes/interactive/interactive-extension-dialogs.d.ts.map +1 -1
  484. package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
  485. package/dist/modes/interactive/interactive-extension-widgets.d.ts.map +1 -1
  486. package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
  487. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  488. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  489. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  490. package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
  491. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  492. package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
  493. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  494. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  495. package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -1
  496. package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -1
  497. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  498. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  499. package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -1
  500. package/dist/modes/interactive/interactive-resource-paths.d.ts.map +1 -1
  501. package/dist/modes/interactive/interactive-resource-rendering.d.ts.map +1 -1
  502. package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
  503. package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
  504. package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
  505. package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -1
  506. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  507. package/dist/modes/interactive/model-search.d.ts.map +1 -1
  508. package/dist/modes/interactive/theme/color-utils.d.ts.map +1 -1
  509. package/dist/modes/interactive/theme/export-colors.d.ts.map +1 -1
  510. package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
  511. package/dist/modes/interactive/theme/terminal-detection.d.ts.map +1 -1
  512. package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
  513. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  514. package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
  515. package/dist/modes/interactive/theme/theme-parse.d.ts.map +1 -1
  516. package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
  517. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  518. package/dist/modes/interactive/theme/tui-theme.d.ts.map +1 -1
  519. package/dist/modes/interactive/whimsical-messages.d.ts.map +1 -1
  520. package/dist/modes/print-mode.d.ts.map +1 -1
  521. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  522. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  523. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  524. package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
  525. package/dist/modes/rpc/rpc-input.d.ts.map +1 -1
  526. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  527. package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
  528. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  529. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  530. package/dist/package-manager-cli-parser.d.ts.map +1 -1
  531. package/dist/package-manager-cli.d.ts.map +1 -1
  532. package/dist/rpc-entry.d.ts.map +1 -1
  533. package/dist/utils/ansi.d.ts.map +1 -1
  534. package/dist/utils/changelog.d.ts.map +1 -1
  535. package/dist/utils/child-process.d.ts.map +1 -1
  536. package/dist/utils/clipboard-image.d.ts.map +1 -1
  537. package/dist/utils/clipboard-native.d.ts.map +1 -1
  538. package/dist/utils/clipboard.d.ts.map +1 -1
  539. package/dist/utils/deprecation.d.ts.map +1 -1
  540. package/dist/utils/event-loop.d.ts.map +1 -1
  541. package/dist/utils/exif-orientation.d.ts.map +1 -1
  542. package/dist/utils/frontmatter.d.ts.map +1 -1
  543. package/dist/utils/fs-watch.d.ts.map +1 -1
  544. package/dist/utils/git-env.d.ts.map +1 -1
  545. package/dist/utils/git.d.ts.map +1 -1
  546. package/dist/utils/html.d.ts.map +1 -1
  547. package/dist/utils/image-convert.d.ts.map +1 -1
  548. package/dist/utils/image-process.d.ts.map +1 -1
  549. package/dist/utils/image-resize-core.d.ts.map +1 -1
  550. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  551. package/dist/utils/image-resize.d.ts.map +1 -1
  552. package/dist/utils/json.d.ts.map +1 -1
  553. package/dist/utils/markit.d.ts.map +1 -1
  554. package/dist/utils/mime.d.ts.map +1 -1
  555. package/dist/utils/module-require.d.ts.map +1 -1
  556. package/dist/utils/open-browser.d.ts.map +1 -1
  557. package/dist/utils/paths.d.ts.map +1 -1
  558. package/dist/utils/photon.d.ts.map +1 -1
  559. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  560. package/dist/utils/shell.d.ts.map +1 -1
  561. package/dist/utils/sleep.d.ts.map +1 -1
  562. package/dist/utils/split-launcher.d.ts.map +1 -1
  563. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  564. package/dist/utils/tools-manager.d.ts.map +1 -1
  565. package/dist/utils/version-check.d.ts.map +1 -1
  566. package/dist/utils/windows-self-update.d.ts.map +1 -1
  567. package/docs/custom-provider.md +7 -1
  568. package/docs/extensions.md +19 -4
  569. package/docs/subagents.md +2 -0
  570. package/docs/workflows.md +2 -2
  571. package/examples/extensions/README.md +3 -1
  572. package/examples/extensions/subagent/schemas.ts +1 -1
  573. package/examples/extensions/tic-tac-toe.ts +1 -2
  574. package/examples/extensions/todo.ts +1 -2
  575. package/npm-shrinkwrap.json +214 -98
  576. package/package.json +12 -12
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-slash-commands.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-slash-commands.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type Component, fs, os, path, Container, Markdown, Spacer, Text, spawn, spawnSync, getShareViewerUrl, SessionImportFileNotFoundError, MissingSessionCwdError, getChangelogPath, normalizeChangelogLinks, parseChangelog, copyToClipboard, BorderedLoader, DynamicBorder, setRegisteredThemes, theme } from \"./interactive-mode-deps.ts\";\nimport { isExpandable } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.handleReloadCommand = async function(this: InteractiveModeBase): Promise<void> {\n if (this.session.isStreaming) {\n this.showWarning(\n \"Wait for the current response to finish before reloading.\",\n );\n return;\n }\n if (this.session.isCompacting) {\n this.showWarning(\"Wait for compaction to finish before reloading.\");\n return;\n }\n\n this.resetExtensionUI();\n\n const reloadBox = new Container();\n const borderColor = (s: string) => theme.fg(\"border\", s);\n reloadBox.addChild(new DynamicBorder(borderColor));\n reloadBox.addChild(new Spacer(1));\n reloadBox.addChild(\n new Text(\n theme.fg(\n \"muted\",\n \"Reloading keybindings, extensions, skills, prompts, themes...\",\n ),\n 1,\n 0,\n ),\n );\n reloadBox.addChild(new Spacer(1));\n reloadBox.addChild(new DynamicBorder(borderColor));\n\n const previousEditor = this.editor;\n this.editorContainer.clear();\n this.editorContainer.addChild(reloadBox);\n this.ui.setFocus(reloadBox);\n this.ui.requestRender(true);\n await new Promise((resolve) => process.nextTick(resolve));\n\n const dismissReloadBox = (editor: Component) => {\n this.editorContainer.clear();\n this.editorContainer.addChild(editor);\n this.ui.setFocus(editor);\n this.ui.requestRender();\n };\n\n try {\n await this.session.reload();\n this.keybindings.reload();\n const activeHeader = this.customHeader ?? this.builtInHeader;\n if (isExpandable(activeHeader)) {\n activeHeader.setExpanded(this.toolOutputExpanded);\n }\n setRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();\n await this.themeController.applyFromSettings();\n const editorPaddingX = this.settingsManager.getEditorPaddingX();\n const autocompleteMaxVisible =\n this.settingsManager.getAutocompleteMaxVisible();\n this.defaultEditor.setPaddingX(editorPaddingX);\n this.defaultEditor.setAutocompleteMaxVisible(autocompleteMaxVisible);\n if (this.editor !== this.defaultEditor) {\n this.editor.setPaddingX?.(editorPaddingX);\n this.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);\n }\n this.ui.setShowHardwareCursor(\n this.settingsManager.getShowHardwareCursor(),\n );\n this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());\n this.setupAutocompleteProvider();\n const runner = this.session.extensionRunner;\n this.setupExtensionShortcuts(runner);\n this.rebuildChatFromMessages();\n dismissReloadBox(this.editor as Component);\n const savedImplicitProjectTrust = this.maybeSaveImplicitProjectTrustAfterReload();\n this.showLoadedResources({\n force: false,\n showDiagnosticsWhenQuiet: true,\n });\n if (savedImplicitProjectTrust) {\n this.showStatus(\"Saved project trust for future sessions\");\n }\n const modelsJsonError = this.session.modelRegistry.getError();\n if (modelsJsonError) {\n this.showError(`models.json error: ${modelsJsonError}`);\n }\n this.showStatus(\n \"Reloaded keybindings, extensions, skills, prompts, themes\",\n );\n } catch (error) {\n dismissReloadBox(previousEditor as Component);\n this.showError(\n `Reload failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n };\n\nInteractiveModeBase.prototype.handleExportCommand = async function(this: InteractiveModeBase, text: string): Promise<void> {\n const outputPath = this.getPathCommandArgument(text, \"/export\");\n\n try {\n if (outputPath?.endsWith(\".jsonl\")) {\n const filePath = this.session.exportToJsonl(outputPath);\n this.showStatus(`Session exported to: ${filePath}`);\n } else {\n const filePath = await this.session.exportToHtml(outputPath);\n this.showStatus(`Session exported to: ${filePath}`);\n }\n } catch (error: unknown) {\n this.showError(\n `Failed to export session: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n );\n }\n };\n\nInteractiveModeBase.prototype.getPathCommandArgument = function(this: InteractiveModeBase, text: string, command: \"/export\" | \"/import\"): string | undefined {\n if (text === command) {\n return undefined;\n }\n if (!text.startsWith(`${command} `)) {\n return undefined;\n }\n\n const argsString = text.slice(command.length + 1).trimStart();\n if (!argsString) {\n return undefined;\n }\n\n const firstChar = argsString[0];\n if (firstChar === '\"' || firstChar === \"'\") {\n const closingQuoteIndex = argsString.indexOf(firstChar, 1);\n if (closingQuoteIndex < 0) {\n return undefined;\n }\n return argsString.slice(1, closingQuoteIndex);\n }\n\n const firstWhitespaceIndex = argsString.search(/\\s/);\n if (firstWhitespaceIndex < 0) {\n return argsString;\n }\n return argsString.slice(0, firstWhitespaceIndex);\n };\n\nInteractiveModeBase.prototype.handleImportCommand = async function(this: InteractiveModeBase, text: string): Promise<void> {\n const inputPath = this.getPathCommandArgument(text, \"/import\");\n if (!inputPath) {\n this.showError(\"Usage: /import <path.jsonl>\");\n return;\n }\n\n const confirmed = await this.showExtensionConfirm(\n \"Import session\",\n `Replace current session with ${inputPath}?`,\n );\n if (!confirmed) {\n this.showStatus(\"Import cancelled\");\n return;\n }\n\n const finishSuccessfulImport = () => {\n this.renderCurrentSessionState();\n if (this.firstRunNoticeVisible) {\n this.clearFirstRunOnboardingUi();\n }\n this.showStatus(`Session imported from: ${inputPath}`);\n };\n\n try {\n if (this.loadingAnimation) {\n this.loadingAnimation.stop();\n this.loadingAnimation = undefined;\n }\n this.statusContainer.clear();\n const result = await this.runtimeHost.importFromJsonl(inputPath);\n if (result.cancelled) {\n this.showStatus(\"Import cancelled\");\n return;\n }\n finishSuccessfulImport();\n } catch (error: unknown) {\n if (error instanceof MissingSessionCwdError) {\n const selectedCwd = await this.promptForMissingSessionCwd(error);\n if (!selectedCwd) {\n this.showStatus(\"Import cancelled\");\n return;\n }\n const result = await this.runtimeHost.importFromJsonl(\n inputPath,\n selectedCwd,\n );\n if (result.cancelled) {\n this.showStatus(\"Import cancelled\");\n return;\n }\n finishSuccessfulImport();\n return;\n }\n if (error instanceof SessionImportFileNotFoundError) {\n this.showError(`Failed to import session: ${error.message}`);\n return;\n }\n await this.handleFatalRuntimeError(\"Failed to import session\", error);\n }\n };\n\nInteractiveModeBase.prototype.handleShareCommand = async function(this: InteractiveModeBase): Promise<void> {\n // Check if gh is available and logged in\n try {\n const authResult = spawnSync(\"gh\", [\"auth\", \"status\"], {\n encoding: \"utf-8\",\n });\n if (authResult.status !== 0) {\n this.showError(\n \"GitHub CLI is not logged in. Run 'gh auth login' first.\",\n );\n return;\n }\n } catch {\n this.showError(\n \"GitHub CLI (gh) is not installed. Install it from https://cli.github.com/\",\n );\n return;\n }\n\n // Export to a temp file\n const tmpFile = path.join(os.tmpdir(), \"session.html\");\n try {\n await this.session.exportToHtml(tmpFile);\n } catch (error: unknown) {\n this.showError(\n `Failed to export session: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n );\n return;\n }\n\n // Show cancellable loader, replacing the editor\n const loader = new BorderedLoader(this.ui, theme, \"Creating gist...\");\n this.editorContainer.clear();\n this.editorContainer.addChild(loader);\n this.ui.setFocus(loader);\n this.ui.requestRender();\n\n const restoreEditor = () => {\n loader.dispose();\n this.editorContainer.clear();\n this.editorContainer.addChild(this.editor);\n this.ui.setFocus(this.editor);\n try {\n fs.unlinkSync(tmpFile);\n } catch {\n // Ignore cleanup errors\n }\n };\n\n // Create a secret gist asynchronously\n let proc: ReturnType<typeof spawn> | null = null;\n\n loader.onAbort = () => {\n proc?.kill();\n restoreEditor();\n this.showStatus(\"Share cancelled\");\n };\n\n try {\n const result = await new Promise<{\n stdout: string;\n stderr: string;\n code: number | null;\n }>((resolve) => {\n proc = spawn(\"gh\", [\"gist\", \"create\", \"--public=false\", tmpFile]);\n let stdout = \"\";\n let stderr = \"\";\n proc.stdout?.on(\"data\", (data) => {\n stdout += data.toString();\n });\n proc.stderr?.on(\"data\", (data) => {\n stderr += data.toString();\n });\n proc.on(\"close\", (code) => resolve({ stdout, stderr, code }));\n });\n\n if (loader.signal.aborted) return;\n\n restoreEditor();\n\n if (result.code !== 0) {\n const errorMsg = result.stderr?.trim() || \"Unknown error\";\n this.showError(`Failed to create gist: ${errorMsg}`);\n return;\n }\n\n // Extract gist ID from the URL returned by gh\n // gh returns something like: https://gist.github.com/username/GIST_ID\n const gistUrl = result.stdout?.trim();\n const gistId = gistUrl?.split(\"/\").pop();\n if (!gistId) {\n this.showError(\"Failed to parse gist ID from gh output\");\n return;\n }\n\n // Create the preview URL\n const previewUrl = getShareViewerUrl(gistId);\n this.showStatus(`Share URL: ${previewUrl}\\nGist: ${gistUrl}`);\n } catch (error: unknown) {\n if (!loader.signal.aborted) {\n restoreEditor();\n this.showError(\n `Failed to create gist: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n );\n }\n }\n };\n\nInteractiveModeBase.prototype.handleCopyCommand = async function(this: InteractiveModeBase): Promise<void> {\n const text = this.session.getLastAssistantText();\n if (!text) {\n this.showError(\"No agent messages to copy yet.\");\n return;\n }\n\n try {\n await copyToClipboard(text);\n this.showStatus(\"Copied last agent message to clipboard\");\n } catch (error) {\n this.showError(error instanceof Error ? error.message : String(error));\n }\n };\n\nInteractiveModeBase.prototype.handleNameCommand = function(this: InteractiveModeBase, text: string): void {\n const name = text.replace(/^\\/name\\s*/, \"\").trim();\n if (!name) {\n const currentName = this.sessionManager.getSessionName();\n if (currentName) {\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(\n new Text(theme.fg(\"dim\", `Session name: ${currentName}`), 1, 0),\n );\n } else {\n this.showWarning(\"Usage: /name <name>\");\n }\n this.ui.requestRender();\n return;\n }\n\n this.session.setSessionName(name);\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(\n new Text(theme.fg(\"dim\", `Session name set: ${name}`), 1, 0),\n );\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.handleSessionCommand = function(this: InteractiveModeBase): void {\n const stats = this.session.getSessionStats();\n const sessionName = this.sessionManager.getSessionName();\n\n let info = `${theme.bold(\"Session Info\")}\\n\\n`;\n if (sessionName) {\n info += `${theme.fg(\"dim\", \"Name:\")} ${sessionName}\\n`;\n }\n info += `${theme.fg(\"dim\", \"File:\")} ${stats.sessionFile ?? \"In-memory\"}\\n`;\n info += `${theme.fg(\"dim\", \"ID:\")} ${stats.sessionId}\\n\\n`;\n info += `${theme.bold(\"Messages\")}\\n`;\n info += `${theme.fg(\"dim\", \"User:\")} ${stats.userMessages}\\n`;\n info += `${theme.fg(\"dim\", \"Assistant:\")} ${stats.assistantMessages}\\n`;\n info += `${theme.fg(\"dim\", \"Tool Calls:\")} ${stats.toolCalls}\\n`;\n info += `${theme.fg(\"dim\", \"Tool Results:\")} ${stats.toolResults}\\n`;\n info += `${theme.fg(\"dim\", \"Total:\")} ${stats.totalMessages}\\n\\n`;\n info += `${theme.bold(\"Tokens\")}\\n`;\n info += `${theme.fg(\"dim\", \"Input:\")} ${stats.tokens.input.toLocaleString()}\\n`;\n info += `${theme.fg(\"dim\", \"Output:\")} ${stats.tokens.output.toLocaleString()}\\n`;\n if (stats.tokens.cacheRead > 0) {\n info += `${theme.fg(\"dim\", \"Cache Read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n }\n if (stats.tokens.cacheWrite > 0) {\n info += `${theme.fg(\"dim\", \"Cache Write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n }\n info += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n`;\n\n if (stats.cost > 0) {\n info += `\\n${theme.bold(\"Cost\")}\\n`;\n info += `${theme.fg(\"dim\", \"Total:\")} ${stats.cost.toFixed(4)}`;\n }\n\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(new Text(info, 1, 0));\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.handleChangelogCommand = function(this: InteractiveModeBase): void {\n const changelogPath = getChangelogPath();\n const allEntries = parseChangelog(changelogPath);\n\n const changelogMarkdown =\n allEntries.length > 0\n ? allEntries\n .reverse()\n .map((e) => normalizeChangelogLinks(e.content, e))\n .join(\"\\n\\n\")\n : \"No changelog entries found.\";\n\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(new DynamicBorder());\n this.chatContainer.addChild(\n new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0),\n );\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(\n new Markdown(\n changelogMarkdown,\n 1,\n 1,\n this.getMarkdownThemeWithSettings(),\n ),\n );\n this.chatContainer.addChild(new DynamicBorder());\n this.ui.requestRender();\n };\n"]}
1
+ {"version":3,"file":"interactive-slash-commands.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-slash-commands.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-startup.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-startup.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase, seedStartupInput } from \"./interactive-mode-base.ts\";\nimport { type Container, type MarkdownTheme, os, path, Markdown, Spacer, Text, spawn, APP_NAME, APP_TITLE, ENV_OFFLINE, getEnvValue, getAgentDir, VERSION, formatCodexFastModeModelLabel, shouldApplyCodexFastMode, DefaultPackageManager, isInstallTelemetryEnabled, getChangelogPath, getEntriesForVersion, getNewEntries, normalizeChangelogLinks, parseChangelog, getCwdRelativePath, getPiUserAgent, recordTimeSinceReset, ensureTool, checkForNewPiVersion, renderAtomicAnsiBanner, DynamicBorder, getMarkdownTheme, onThemeChange, theme } from \"./interactive-mode-deps.ts\";\nimport { ExpandableText } from \"./interactive-mode-helpers.ts\";\nimport { ONBOARDING_COPY } from \"./interactive-onboarding.ts\";\n\nfunction prepareStartupNotices(mode: InteractiveModeBase): void {\n if (mode.startupNoticesPrepared) return;\n mode.startupNoticesPrepared = true;\n mode.hadLastChangelogVersionAtStartup = Boolean(mode.settingsManager.getLastChangelogVersion?.());\n if (mode.changelogMarkdown === undefined) {\n mode.changelogMarkdown = mode.getChangelogForDisplay?.();\n }\n mode.initializeFirstRunOnboardingMarkers?.();\n if (!mode.firstRunNoticeVisible) {\n mode.firstRunNoticeVisible = mode.isFirstRunOnboardingEligible?.() ?? false;\n }\n }\n\nInteractiveModeBase.prototype.showStartupNoticesIfNeeded = function(this: InteractiveModeBase, targetContainer: Container = this.chatContainer): void {\n if (this.startupNoticesShown) {\n return;\n }\n prepareStartupNotices(this);\n this.startupNoticesShown = true;\n\n const changelogMarkdown = this.changelogMarkdown;\n if (!changelogMarkdown && !this.firstRunNoticeVisible) {\n return;\n }\n\n if (changelogMarkdown) {\n if (targetContainer.children.length > 0) {\n targetContainer.addChild(new Spacer(1));\n }\n targetContainer.addChild(new DynamicBorder());\n if (this.settingsManager.getCollapseChangelog()) {\n const versionMatch = changelogMarkdown.match(\n /##\\s+\\[?((?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-(?:alpha\\.)?(?:0|[1-9]\\d*))?)\\]?/,\n );\n const latestVersion = versionMatch ? versionMatch[1] : this.version;\n const condensedText = `Updated to v${latestVersion}. Use ${theme.bold(\"/changelog\")} to view full changelog.`;\n targetContainer.addChild(new Text(condensedText, 1, 0));\n } else {\n targetContainer.addChild(\n new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0),\n );\n targetContainer.addChild(new Spacer(1));\n targetContainer.addChild(\n new Markdown(\n changelogMarkdown.trim(),\n 1,\n 0,\n this.getMarkdownThemeWithSettings(),\n ),\n );\n targetContainer.addChild(new Spacer(1));\n }\n targetContainer.addChild(new DynamicBorder());\n }\n\n if (this.firstRunNoticeVisible) {\n this.firstRunOnboardingNoticeComponents = [];\n if (targetContainer.children.length > 0) {\n this.firstRunOnboardingNoticeComponents.push(new Spacer(1));\n }\n this.firstRunOnboardingNoticeComponents.push(\n new DynamicBorder(),\n new Text(ONBOARDING_COPY, 1, 0),\n new DynamicBorder(),\n new Spacer(1),\n );\n for (const component of this.firstRunOnboardingNoticeComponents) {\n targetContainer.addChild(component);\n }\n // Mark completion only after queueing the notice in the chat canvas so\n // launches that skip rendering retry the first-run notice next time.\n this.settingsManager.setOnboardedVersion(this.version);\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.init = async function(this: InteractiveModeBase): Promise<void> {\n if (this.isInitialized) return;\n\n this.registerSignalHandlers();\n\n // Changelog and first-run onboarding are prepared lazily after first paint.\n\n // Add header container as first child. Populate it after theme initialization.\n this.ui.addChild(this.headerContainer);\n\n this.ui.addChild(this.chatContainer);\n this.ui.addChild(this.pendingMessagesContainer);\n this.ui.addChild(this.statusContainer);\n this.renderWidgets(); // Initialize with default spacer\n this.ui.addChild(this.widgetContainerAbove);\n this.ui.addChild(this.usageMeter);\n this.ui.addChild(this.editorContainer);\n // Footer (persistent model + cwd identity) stays pinned directly under the\n // editor; below-editor widgets render after it, at the very bottom. This\n // keeps the session identity line attached to the input and places\n // transient run status (e.g. the workflow companion counter) beneath it.\n // Rendering below-editor widgets last also keeps a live widget at the\n // absolute bottom of the buffer (always within the viewport), so its\n // per-tick updates never sit above the fold — preserving the #1109\n // resize-flicker fix.\n this.ui.addChild(this.footer);\n this.ui.addChild(this.widgetContainerBelow);\n this.ui.setFocus(this.editor);\n\n this.setupKeyHandlers();\n this.setupEditorSubmitHandler();\n\n seedStartupInput(\n this.pendingUserInputs,\n this.defaultEditor,\n this.options.startupInputCapture?.consume(),\n this.startupReplayInputs,\n (text) => {\n this.startupDraftText = text;\n },\n (text) => {\n this.startupReplayActiveInput = text;\n },\n );\n\n // Start UI before extension/session work; fd/rg readiness and git watching move after first paint.\n this.ui.start();\n recordTimeSinceReset(\"time-to-first-frame\");\n this.footerDataProvider.onBranchChange(() => {\n this.ui.requestRender();\n });\n this.isInitialized = true;\n\n await this.themeController.applyFromSettings();\n\n // Add the quiet startup identity unless silenced.\n if (this.options.verbose || !this.settingsManager.getQuietStartup()) {\n this.builtInHeader = new ExpandableText(\n () => this.getStartupIdentityText(),\n () => this.getStartupIdentityText(),\n this.getStartupExpansionState(),\n 1,\n 0,\n );\n\n this.headerContainer.addChild(new Spacer(1));\n this.headerContainer.addChild(this.builtInHeader);\n this.headerContainer.addChild(new Spacer(1));\n } else {\n // Minimal header when silenced\n this.builtInHeader = new Text(\"\", 0, 0);\n this.headerContainer.addChild(this.builtInHeader);\n }\n this.ui.requestRender();\n\n void Promise.all([ensureTool(\"fd\"), ensureTool(\"rg\")])\n .then(([fdPath]) => {\n this.fdPath = fdPath;\n this.setupAutocompleteProvider();\n })\n .catch((error) => {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`Tool readiness check failed: ${message}`);\n });\n\n // When startup resources are deferred, keep the already-painted editor responsive.\n // Extension UI bindings are installed at the deferred reload boundary, not here,\n // so no post-paint resource work can block visible typing.\n if (this.deferredStartupPending) {\n this.applyRuntimeSettings();\n this.subscribeToAgent();\n this.updateEditorBorderColor();\n this.updateTerminalTitle();\n } else {\n await this.rebindCurrentSession();\n }\n\n this.attachStartupNoticesContainer();\n // Render initial messages AFTER the initial session binding is in place.\n this.renderInitialMessages();\n // Set up theme file watcher\n onThemeChange(() => {\n this.ui.invalidate();\n this.updateEditorBorderColor();\n this.ui.requestRender();\n });\n\n // Initialize available provider count for footer display without delaying first-frame startup.\n void this.updateAvailableProviderCount().catch((error) => {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`Failed to update provider count: ${message}`);\n });\n };\n\nInteractiveModeBase.prototype.updateTerminalTitle = function(this: InteractiveModeBase): void {\n const cwdBasename = path.basename(this.sessionManager.getCwd());\n const sessionName = this.sessionManager.getSessionName();\n if (sessionName) {\n this.ui.terminal.setTitle(\n `${APP_TITLE} - ${sessionName} - ${cwdBasename}`,\n );\n } else {\n this.ui.terminal.setTitle(`${APP_TITLE} - ${cwdBasename}`);\n }\n };\n\nInteractiveModeBase.prototype.run = async function(this: InteractiveModeBase): Promise<void> {\n await this.init();\n\n\tsetTimeout(() => {\n\t\tvoid this.refreshCopilotModelCatalog();\n const startupNoticesContainer = this.startupNoticesContainer;\n\t\tcheckForNewPiVersion(this.version).then((newVersion) => {\n\t\t\tif (newVersion) this.showNewVersionNotification(newVersion, startupNoticesContainer);\n\t\t});\n\t\tthis.checkForPackageUpdates().then((updates) => {\n\t\t\tif (updates.length > 0) this.showPackageUpdateNotification(updates, startupNoticesContainer);\n\t\t});\n\t\tthis.checkTmuxKeyboardSetup().then((warning) => {\n\t\t\tif (warning) this.showWarning(warning, startupNoticesContainer);\n\t\t});\n\t\t// When startup is deferred, the RESOURCES disclosure renders after the\n\t\t// deferred extension load; hold the subscription warning until then so\n\t\t// the disclosure always appears first.\n\t\tif (!this.deferredStartupPending && !this.deferredStartupPromise && !this.pendingLoadedResourcesDisclosure) {\n\t\t\tvoid this.maybeWarnAboutAnthropicSubscriptionAuth(undefined, startupNoticesContainer);\n\t\t}\n\t}, 500);\n\n // Show startup warnings\n const {\n migratedProviders,\n modelFallbackMessage,\n initialMessage,\n initialImages,\n initialMessages,\n } = this.options;\n\n if (migratedProviders && migratedProviders.length > 0) {\n this.showWarning(\n `Migrated credentials to auth.json: ${migratedProviders.join(\", \")}`,\n );\n }\n\n const modelsJsonError = this.session.modelRegistry.getError();\n if (modelsJsonError) {\n this.showError(`models.json error: ${modelsJsonError}`);\n }\n\n if (modelFallbackMessage && !this.deferredStartupPending) {\n this.showWarning(modelFallbackMessage, this.startupNoticesContainer);\n }\n\n // CLI-provided startup prompts need extension tools/resources; wait before sending them,\n // but do not block the normal no-prompt input loop from becoming ready.\n if (this.deferredStartupPending && (initialMessage || (initialMessages && initialMessages.length > 0))) {\n await this.ensureDeferredStartupComplete();\n }\n\n // Process initial messages\n if (initialMessage) {\n try {\n await this.session.prompt(initialMessage, { images: initialImages });\n } catch (error: unknown) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error occurred\";\n this.showError(errorMessage);\n }\n }\n\n if (initialMessages) {\n for (const message of initialMessages) {\n try {\n await this.session.prompt(message);\n } catch (error: unknown) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error occurred\";\n this.showError(errorMessage);\n }\n }\n }\n\n // Main interactive loop\n while (true) {\n const userInput = await this.getUserInput();\n await this.runUserPromptTurn(userInput);\n }\n };\n\nInteractiveModeBase.prototype.checkForPackageUpdates = async function(this: InteractiveModeBase): Promise<string[]> {\n if (getEnvValue(ENV_OFFLINE)) {\n return [];\n }\n\n try {\n const packageManager = new DefaultPackageManager({\n cwd: this.sessionManager.getCwd(),\n agentDir: getAgentDir(),\n settingsManager: this.settingsManager,\n });\n const updates = await packageManager.checkForAvailableUpdates();\n return updates.map((update) => update.displayName);\n } catch {\n return [];\n }\n };\n\nInteractiveModeBase.prototype.checkTmuxKeyboardSetup = async function(this: InteractiveModeBase): Promise<string | undefined> {\n if (!process.env.TMUX) return undefined;\n\n const runTmuxShow = (option: string): Promise<string | undefined> => {\n return new Promise((resolve) => {\n const proc = spawn(\"tmux\", [\"show\", \"-gv\", option], {\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n });\n let stdout = \"\";\n const timer = setTimeout(() => {\n proc.kill();\n resolve(undefined);\n }, 2000);\n\n proc.stdout?.on(\"data\", (data) => {\n stdout += data.toString();\n });\n proc.on(\"error\", () => {\n clearTimeout(timer);\n resolve(undefined);\n });\n proc.on(\"close\", (code) => {\n clearTimeout(timer);\n resolve(code === 0 ? stdout.trim() : undefined);\n });\n });\n };\n\n const [extendedKeys, extendedKeysFormat] = await Promise.all([\n runTmuxShow(\"extended-keys\"),\n runTmuxShow(\"extended-keys-format\"),\n ]);\n\n // If we couldn't query tmux (timeout, sandbox, etc.), don't warn\n if (extendedKeys === undefined) return undefined;\n\n if (extendedKeys !== \"on\" && extendedKeys !== \"always\") {\n return \"tmux extended-keys is off. Modified enter keys may not work. Add `set -g extended-keys on` to ~/.tmux.conf and restart tmux.\";\n }\n\n if (extendedKeysFormat === \"xterm\") {\n return \"tmux extended-keys-format is xterm. Pi works best with csi-u. Add `set -g extended-keys-format csi-u` to ~/.tmux.conf and restart tmux.\";\n }\n\n return undefined;\n };\n\nInteractiveModeBase.prototype.getChangelogForDisplay = function(this: InteractiveModeBase): string | undefined {\n // Skip changelog for resumed/continued sessions (already have messages)\n if (this.session.state.messages.length > 0) {\n return undefined;\n }\n\n const lastVersion = this.settingsManager.getLastChangelogVersion();\n const changelogPath = getChangelogPath();\n const entries = parseChangelog(changelogPath);\n\n if (!lastVersion) {\n // Fresh install - record the version, send telemetry, don't show changelog\n this.settingsManager.setLastChangelogVersion(VERSION);\n this.reportInstallTelemetry(VERSION);\n return undefined;\n }\n\n const newEntries = getNewEntries(entries, lastVersion, VERSION);\n const currentEntries = getEntriesForVersion(newEntries, VERSION);\n if (currentEntries.length > 0) {\n this.settingsManager.setLastChangelogVersion(VERSION);\n this.reportInstallTelemetry(VERSION);\n return currentEntries.map((e) => normalizeChangelogLinks(e.content, e)).join(\"\\n\\n\");\n }\n\n return undefined;\n };\n\nInteractiveModeBase.prototype.reportInstallTelemetry = function(this: InteractiveModeBase, version: string): void {\n if (getEnvValue(ENV_OFFLINE)) {\n return;\n }\n\n if (!isInstallTelemetryEnabled(this.settingsManager)) {\n return;\n }\n\n void fetch(\n `https://pi.dev/api/report-install?version=${encodeURIComponent(version)}`,\n {\n headers: {\n \"User-Agent\": getPiUserAgent(version),\n },\n signal: AbortSignal.timeout(5000),\n },\n )\n .then(() => undefined)\n .catch(() => undefined);\n };\n\nInteractiveModeBase.prototype.getMarkdownThemeWithSettings = function(this: InteractiveModeBase): MarkdownTheme {\n return {\n ...getMarkdownTheme(),\n codeBlockIndent: this.settingsManager.getCodeBlockIndent(),\n };\n };\n\nInteractiveModeBase.prototype.formatDisplayPath = function(this: InteractiveModeBase, p: string): string {\n const home = os.homedir();\n let result = p;\n\n // Replace home directory with ~\n if (result.startsWith(home)) {\n result = `~${result.slice(home.length)}`;\n }\n\n return result;\n };\n\nInteractiveModeBase.prototype.formatExtensionDisplayPath = function(this: InteractiveModeBase, path: string): string {\n let result = this.formatDisplayPath(path);\n result = result.replace(/\\/index\\.ts$/, \"\").replace(/\\/index\\.js$/, \"\");\n return result;\n };\n\nInteractiveModeBase.prototype.formatContextPath = function(this: InteractiveModeBase, p: string): string {\n const cwd = path.resolve(this.sessionManager.getCwd());\n const absolutePath = path.isAbsolute(p)\n ? path.resolve(p)\n : path.resolve(cwd, p);\n const relativePath = getCwdRelativePath(absolutePath, cwd);\n if (relativePath !== undefined) {\n return relativePath;\n }\n\n return this.formatDisplayPath(absolutePath);\n };\n\nInteractiveModeBase.prototype.getStartupModelLabel = function(this: InteractiveModeBase): string {\n const model = this.session.state.model;\n let modelLabel = model?.id ?? \"no-model\";\n\n if (model?.reasoning) {\n modelLabel = `${modelLabel} ${this.session.thinkingLevel || \"off\"}`;\n }\n\n if (!model) {\n return modelLabel;\n }\n\n const fastModeEnabled = shouldApplyCodexFastMode(\n model,\n this.session.settingsManager.getCodexFastModeSettings(),\n this.session.orchestrationContext,\n );\n return formatCodexFastModeModelLabel(modelLabel, fastModeEnabled);\n };\n\nInteractiveModeBase.prototype.getStartupIdentityText = function(this: InteractiveModeBase): string {\n const appLabel = APP_NAME.length > 0\n ? `${APP_NAME[0]!.toUpperCase()}${APP_NAME.slice(1)}`\n : \"Atomic\";\n const title = `${theme.bold(theme.fg(\"text\", appLabel))} ${theme.fg(\"muted\", `v${this.version}`)}`;\n const model = this.session.state.model;\n const provider = model ? theme.fg(\"dim\", `(${model.provider})`) : theme.fg(\"dim\", \"(no-provider)\");\n const modelLine = `${provider} ${theme.fg(\"muted\", this.getStartupModelLabel())}`;\n const cwd = theme.fg(\"muted\", this.formatDisplayPath(this.sessionManager.getCwd()));\n const metaLines = [title, modelLine, cwd];\n const markLines = this.getAtomicAnsiMarkLines();\n\n return markLines\n .map((line, index) => `${line} ${metaLines[index] ?? \"\"}`.trimEnd())\n .join(\"\\n\");\n };\n\nInteractiveModeBase.prototype.getAtomicAnsiMarkLines = function(this: InteractiveModeBase): string[] {\n return renderAtomicAnsiBanner(theme, this.session.thinkingLevel || \"off\");\n };\n\nInteractiveModeBase.prototype.getStartupExpansionState = function(this: InteractiveModeBase): boolean {\n return this.options.verbose || this.toolOutputExpanded;\n };\n"]}
1
+ {"version":3,"file":"interactive-startup.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-startup.ts"],"names":[],"mappings":""}
@@ -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":"color-utils.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/color-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;AAEjD,wBAAgB,eAAe,IAAI,SAAS,CAyB3C;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAYzE;AAgFD,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAatE;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAatE;AAED,wBAAgB,cAAc,CAC7B,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAChC,OAAO,cAAoB,GACzB,MAAM,GAAG,MAAM,CAYjB;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACtE,MAAM,EAAE,CAAC,EACT,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAM,GACnC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAMlC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAsClD","sourcesContent":["import type { ColorValue } from \"./theme-schema.ts\";\n\nexport type ColorMode = \"truecolor\" | \"256color\";\n\nexport function detectColorMode(): ColorMode {\n\tconst colorterm = process.env.COLORTERM;\n\tif (colorterm === \"truecolor\" || colorterm === \"24bit\") {\n\t\treturn \"truecolor\";\n\t}\n\t// Windows Terminal supports truecolor\n\tif (process.env.WT_SESSION) {\n\t\treturn \"truecolor\";\n\t}\n\tconst term = process.env.TERM || \"\";\n\t// Fall back to 256color for truly limited terminals\n\tif (term === \"dumb\" || term === \"\" || term === \"linux\") {\n\t\treturn \"256color\";\n\t}\n\t// Terminal.app also doesn't support truecolor\n\tif (process.env.TERM_PROGRAM === \"Apple_Terminal\") {\n\t\treturn \"256color\";\n\t}\n\t// GNU screen doesn't support truecolor unless explicitly opted in via COLORTERM=truecolor.\n\t// TERM under screen is typically \"screen\", \"screen-256color\", or \"screen.xterm-256color\".\n\tif (term === \"screen\" || term.startsWith(\"screen-\") || term.startsWith(\"screen.\")) {\n\t\treturn \"256color\";\n\t}\n\t// Assume truecolor for everything else - virtually all modern terminals support it\n\treturn \"truecolor\";\n}\n\nexport function 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\nexport function 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\nexport function 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\nexport function 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\nexport function 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\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 */\nexport function 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"]}
1
+ {"version":3,"file":"color-utils.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/color-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;AAEjD,wBAAgB,eAAe,IAAI,SAAS,CAyB3C;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAYzE;AAgFD,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAatE;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAatE;AAED,wBAAgB,cAAc,CAC7B,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAChC,OAAO,cAAoB,GACzB,MAAM,GAAG,MAAM,CAYjB;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACtE,MAAM,EAAE,CAAC,EACT,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAM,GACnC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAMlC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAsClD"}
@@ -1 +1 @@
1
- {"version":3,"file":"export-colors.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/export-colors.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBjF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAExD;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","sourcesContent":["import { ansi256ToHex, resolveThemeColors, resolveVarRefs } from \"./color-utils.ts\";\nimport { getCurrentThemeName } from \"./global-theme.ts\";\nimport { getDefaultTheme } from \"./terminal-detection.ts\";\nimport { loadThemeJson } from \"./theme-loading.ts\";\nimport type { ColorValue } from \"./theme-schema.ts\";\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 ?? getCurrentThemeName() ?? getDefaultTheme();\n\tconst isLight = isLightTheme(name);\n\tconst themeJson = loadThemeJson(name);\n\tconst resolved = resolveThemeColors(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\treturn themeName === \"light\" || themeName === \"catppuccin-latte\";\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 ?? getCurrentThemeName() ?? 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"]}
1
+ {"version":3,"file":"export-colors.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/export-colors.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBjF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAExD;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"}
@@ -1 +1 @@
1
- {"version":3,"file":"global-theme.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/global-theme.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAUzC,eAAO,MAAM,KAAK,EAAE,KAMlB,CAAC;AAcH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAExD;AAED,wBAAgB,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,aAAa,GAAE,OAAe,GAAG,IAAI,CAclF;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,GAAE,OAAe,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAqB3G;AAED,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,KAAK,GAAG,IAAI,CAO3D;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAExD;AA+FD,wBAAgB,gBAAgB,IAAI,IAAI,CAYvC","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { getCustomThemesDir } from \"../../../config.ts\";\nimport { closeWatcher, isSafeFsWatchPathError, watchWithErrorHandler } from \"../../../utils/fs-watch.ts\";\nimport { Theme } from \"./theme-class.ts\";\nimport { getDefaultTheme } from \"./terminal-detection.ts\";\nimport { getBuiltinThemes, loadTheme, loadThemeFromPath, setRegisteredTheme } from \"./theme-loading.ts\";\n\n// Use globalThis to share theme across module loaders (tsx + jiti in dev mode)\nconst THEME_KEY = Symbol.for(\"@bastani/atomic:theme\");\nconst THEME_KEY_OLD = Symbol.for(\"@bastani/atomic: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_OLD] = t;\n}\n\nlet currentThemeName: string | undefined;\nlet themeWatcher: fs.FSWatcher | undefined;\nlet themeReloadTimer: NodeJS.Timeout | undefined;\nlet themeWatchFilePath: string | undefined;\nlet themeWatchFileListener: ((current: fs.Stats, previous: fs.Stats) => void) | undefined;\nlet onThemeChangeCallback: (() => void) | undefined;\n\nexport function getCurrentThemeName(): string | undefined {\n\treturn currentThemeName;\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 in getBuiltinThemes()) {\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\tsetRegisteredTheme(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\tconst startPollingFallback = () => {\n\t\tif (themeWatchFilePath && themeWatchFileListener) {\n\t\t\treturn;\n\t\t}\n\t\tthemeWatchFilePath = themeFile;\n\t\tthemeWatchFileListener = (current, previous) => {\n\t\t\tif (\n\t\t\t\tcurrent.mtimeMs !== previous.mtimeMs ||\n\t\t\t\tcurrent.ctimeMs !== previous.ctimeMs ||\n\t\t\t\tcurrent.size !== previous.size\n\t\t\t) {\n\t\t\t\tscheduleReload();\n\t\t\t}\n\t\t};\n\t\tfs.watchFile(themeFile, { interval: 1000 }, themeWatchFileListener);\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(error) => {\n\t\t\t\tcloseWatcher(themeWatcher);\n\t\t\t\tthemeWatcher = undefined;\n\t\t\t\tif (isSafeFsWatchPathError(error)) {\n\t\t\t\t\tstartPollingFallback();\n\t\t\t\t}\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\tif (themeWatchFilePath && themeWatchFileListener) {\n\t\tfs.unwatchFile(themeWatchFilePath, themeWatchFileListener);\n\t}\n\tthemeWatchFilePath = undefined;\n\tthemeWatchFileListener = undefined;\n}\n"]}
1
+ {"version":3,"file":"global-theme.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/global-theme.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAUzC,eAAO,MAAM,KAAK,EAAE,KAMlB,CAAC;AAcH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAExD;AAED,wBAAgB,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,aAAa,GAAE,OAAe,GAAG,IAAI,CAclF;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,GAAE,OAAe,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAqB3G;AAED,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,KAAK,GAAG,IAAI,CAO3D;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAExD;AA+FD,wBAAgB,gBAAgB,IAAI,IAAI,CAYvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"terminal-detection.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/terminal-detection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGvD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC;AAE7C,wBAAgB,qBAAqB,CACpC,YAAY,EAAE,MAAM,GAAG,SAAS,GAC9B;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAavD;AAED,wBAAgB,mBAAmB,CAClC,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,aAAa,EAAE,aAAa,GAC1B,MAAM,GAAG,SAAS,CAQpB;AAED,MAAM,WAAW,sBAAsB;IACtC,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,qBAAqB,GAAG,WAAW,GAAG,UAAU,CAAC;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC;CAC3B;AAED,MAAM,WAAW,6BAA6B;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,+BAA+B;IAC/C,4BAA4B,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;CAClG;AAED,MAAM,WAAW,uCAAwC,SAAQ,6BAA6B;IAC7F,EAAE,EAAE,+BAA+B,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;CAClB;AAyBD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,QAAQ,GAAG,aAAa,CAEhE;AAED,wBAAgB,+BAA+B,CAAC,OAAO,GAAE,6BAAkC,GAAG,sBAAsB,CAmBnH;AAED,wBAAsB,6BAA6B,CAAC,EACnD,EAAE,EACF,SAAS,EACT,GAAG,GACH,EAAE,uCAAuC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAgB3E;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC","sourcesContent":["import type { RgbColor } from \"@earendil-works/pi-tui\";\nimport { ansi256ToHex, hexToRgb } from \"./color-utils.ts\";\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 TerminalBackgroundThemeDetectionOptions extends TerminalThemeDetectionOptions {\n\tui: TerminalBackgroundThemeDetector;\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 function getDefaultTheme(): string {\n\treturn detectTerminalBackgroundFromEnv().theme;\n}\n"]}
1
+ {"version":3,"file":"terminal-detection.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/terminal-detection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGvD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC;AAE7C,wBAAgB,qBAAqB,CACpC,YAAY,EAAE,MAAM,GAAG,SAAS,GAC9B;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAavD;AAED,wBAAgB,mBAAmB,CAClC,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,aAAa,EAAE,aAAa,GAC1B,MAAM,GAAG,SAAS,CAQpB;AAED,MAAM,WAAW,sBAAsB;IACtC,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,qBAAqB,GAAG,WAAW,GAAG,UAAU,CAAC;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC;CAC3B;AAED,MAAM,WAAW,6BAA6B;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,+BAA+B;IAC/C,4BAA4B,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;CAClG;AAED,MAAM,WAAW,uCAAwC,SAAQ,6BAA6B;IAC7F,EAAE,EAAE,+BAA+B,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;CAClB;AAyBD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,QAAQ,GAAG,aAAa,CAEhE;AAED,wBAAgB,+BAA+B,CAAC,OAAO,GAAE,6BAAkC,GAAG,sBAAsB,CAmBnH;AAED,wBAAsB,6BAA6B,CAAC,EACnD,EAAE,EACF,SAAS,EACT,GAAG,GACH,EAAE,uCAAuC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAgB3E;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC"}
@@ -1 +1 @@
1
- {"version":3,"file":"theme-class.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-class.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAU,KAAK,SAAS,EAAU,MAAM,kBAAkB,CAAC;AAElE,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,iBAAiB,GACjB,aAAa,GACb,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,UAAU,CAAC;AAEd,MAAM,MAAM,OAAO,GAChB,YAAY,GACZ,eAAe,GACf,iBAAiB,GACjB,eAAe,GACf,eAAe,GACf,aAAa,CAAC;AAEjB,qBAAa,KAAK;IACjB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,IAAI,CAAY;IAExB,YACC,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,EAC7C,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,EAC1C,IAAI,EAAE,SAAS,EACf,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,UAAU,CAAA;KAAO,EAc7E;IAED,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI1C;IAED,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAIvC;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzB;IAED,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3B;IAED,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9B;IAED,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5B;IAED,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElC;IAED,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAInC;IAED,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAIhC;IAED,YAAY,IAAI,SAAS,CAExB;IAED,sBAAsB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAoBtH;IAED,sBAAsB,IAAI,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAEhD;CACD","sourcesContent":["import chalk from \"chalk\";\nimport type { SourceInfo } from \"../../../core/source-info.ts\";\nimport { bgAnsi, type ColorMode, fgAnsi } from \"./color-utils.ts\";\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| \"bashMode\";\n\nexport type ThemeBg =\n\t| \"selectedBg\"\n\t| \"userMessageBg\"\n\t| \"customMessageBg\"\n\t| \"toolPendingBg\"\n\t| \"toolSuccessBg\"\n\t| \"toolErrorBg\";\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<ThemeBg, 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\tfor (const [key, value] of Object.entries(fgColors) 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\tfor (const [key, value] of Object.entries(bgColors) 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: \"off\" | \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\"): (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(\"thinkingXhigh\", 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"]}
1
+ {"version":3,"file":"theme-class.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-class.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAU,KAAK,SAAS,EAAU,MAAM,kBAAkB,CAAC;AAElE,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,iBAAiB,GACjB,aAAa,GACb,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,UAAU,CAAC;AAEd,MAAM,MAAM,OAAO,GAChB,YAAY,GACZ,eAAe,GACf,iBAAiB,GACjB,eAAe,GACf,eAAe,GACf,aAAa,CAAC;AAEjB,qBAAa,KAAK;IACjB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,IAAI,CAAY;IAExB,YACC,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,EAC7C,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,EAC1C,IAAI,EAAE,SAAS,EACf,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,UAAU,CAAA;KAAO,EAc7E;IAED,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI1C;IAED,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAIvC;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzB;IAED,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3B;IAED,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9B;IAED,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5B;IAED,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElC;IAED,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAInC;IAED,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAIhC;IAED,YAAY,IAAI,SAAS,CAExB;IAED,sBAAsB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAoBtH;IAED,sBAAsB,IAAI,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAEhD;CACD"}
@@ -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,EAQN,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;IAEhC,YAAY,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,IAAI,EAQjH;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;YAML,0BAA0B;IAUxC,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\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\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.ui.onTerminalColorSchemeChange((terminalTheme) => this.applyTerminalTheme(terminalTheme));\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 this.detectTerminalThemeForAuto();\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 async detectTerminalThemeForAuto(): Promise<TerminalTheme> {\n\t\ttry {\n\t\t\tconst colorScheme = await this.ui.queryTerminalColorScheme({ timeoutMs: 100 });\n\t\t\tif (colorScheme) return colorScheme;\n\t\t} catch {\n\t\t\t// Fall back to OSC 11 / COLORFGBG detection when color-scheme DSR is unsupported.\n\t\t}\n\t\treturn (await detectTerminalBackgroundTheme({ ui: this.ui, timeoutMs: 100 })).theme;\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,EAQN,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;IAEhC,YAAY,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,IAAI,EAQjH;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;YAML,0BAA0B;IAUxC,OAAO,CAAC,kBAAkB;CAa1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"theme-loading.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-loading.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,SAAS,EAAsB,MAAM,kBAAkB,CAAC;AAEvF,OAAO,EAAE,KAAK,EAAiC,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnD,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CACzB;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAe5D;AAED,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAE7C;AAED,wBAAgB,2BAA2B,IAAI,SAAS,EAAE,CAyBzD;AA2BD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAoBrD;AA4BD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,CAG5E;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,CAGhG;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,CAO/D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAM9D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAQzD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAEnE","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { getCustomThemesDir, getThemesDir } from \"../../../config.ts\";\nimport { detectColorMode, type ColorMode, resolveThemeColors } from \"./color-utils.ts\";\nimport { assertThemeNameIsValid, parseThemeJsonContent } from \"./theme-parse.ts\";\nimport { Theme, type ThemeBg, type ThemeColor } from \"./theme-class.ts\";\nimport type { ThemeJson } from \"./theme-schema.ts\";\n\nlet BUILTIN_THEMES: Record<string, ThemeJson> | undefined;\nconst registeredThemes = new Map<string, Theme>();\n\nexport interface ThemeInfo {\n\tname: string;\n\tpath: string | undefined;\n}\n\nexport function getBuiltinThemes(): Record<string, ThemeJson> {\n\tif (!BUILTIN_THEMES) {\n\t\tconst themesDir = getThemesDir();\n\t\tconst themes: Record<string, ThemeJson> = {};\n\t\tfor (const file of fs.readdirSync(themesDir).sort()) {\n\t\t\tif (!file.endsWith(\".json\") || file === \"theme-schema.json\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst themePath = path.join(themesDir, file);\n\t\t\tconst themeJson = parseThemeJsonContent(themePath, fs.readFileSync(themePath, \"utf-8\"));\n\t\t\tthemes[themeJson.name] = themeJson;\n\t\t}\n\t\tBUILTIN_THEMES = themes;\n\t}\n\treturn BUILTIN_THEMES;\n}\n\nexport function getAvailableThemes(): string[] {\n\treturn getAvailableThemesWithPaths().map(({ name }) => name);\n}\n\nexport function getAvailableThemesWithPaths(): ThemeInfo[] {\n\tconst themesDir = getThemesDir();\n\tconst result: ThemeInfo[] = [];\n\tconst seen = new Set<string>();\n\tconst addTheme = (info: ThemeInfo) => {\n\t\tif (seen.has(info.name)) return;\n\t\tseen.add(info.name);\n\t\tresult.push(info);\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 info of getCustomThemeInfos()) {\n\t\taddTheme(info);\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\nexport function 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 ?? detectColorMode();\n\tconst resolvedColors = resolveThemeColors(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\"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\treturn loadThemeFromContent(themePath, content, mode);\n}\n\nexport function loadThemeFromContent(themePath: string, content: string, mode?: ColorMode): Theme {\n\tconst themeJson = parseThemeJsonContent(themePath, content);\n\treturn createTheme(themeJson, mode, themePath);\n}\n\nexport function 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 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 setRegisteredTheme(name: string, theme: Theme): void {\n\tregisteredThemes.set(name, theme);\n}\n"]}
1
+ {"version":3,"file":"theme-loading.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-loading.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,SAAS,EAAsB,MAAM,kBAAkB,CAAC;AAEvF,OAAO,EAAE,KAAK,EAAiC,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnD,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CACzB;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAe5D;AAED,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAE7C;AAED,wBAAgB,2BAA2B,IAAI,SAAS,EAAE,CAyBzD;AA2BD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAoBrD;AA4BD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,CAG5E;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,CAGhG;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,CAO/D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAM9D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAQzD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAEnE"}
@@ -1 +1 @@
1
- {"version":3,"file":"theme-parse.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGnD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAMzD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,SAAS,CAuCtE;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAQ/E","sourcesContent":["import type { ThemeJson } from \"./theme-schema.ts\";\nimport { validateThemeJson } from \"./theme-schema.ts\";\n\nexport function 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\nexport function 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\nexport function 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"]}
1
+ {"version":3,"file":"theme-parse.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGnD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAMzD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,SAAS,CAuCtE;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAQ/E"}
@@ -1 +1 @@
1
- {"version":3,"file":"theme-schema.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,eAAO,MAAM,gBAAgB,4CAG3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEzD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuE1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAEvD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA2B,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\n\nexport const 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\nexport type ColorValue = Static<typeof ColorValueSchema>;\n\nexport const 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 colors)\n\t\tselectedBg: 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\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\nexport type ThemeJson = Static<typeof ThemeJsonSchema>;\n\nexport const validateThemeJson = Compile(ThemeJsonSchema);\n"]}
1
+ {"version":3,"file":"theme-schema.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,eAAO,MAAM,gBAAgB,4CAG3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEzD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuE1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAEvD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA2B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChG,OAAO,EACN,SAAS,EACT,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,GACL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,+BAA+B,EAC/B,6BAA6B,EAC7B,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,uCAAuC,EAC5C,KAAK,+BAA+B,EACpC,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,GAClC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EACN,kBAAkB,EAClB,2BAA2B,EAC3B,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,SAAS,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,GACb,MAAM,gBAAgB,CAAC","sourcesContent":["export { getThemeExportColors, getResolvedThemeColors, isLightTheme } from \"./export-colors.ts\";\nexport {\n\tinitTheme,\n\tonThemeChange,\n\tsetTheme,\n\tsetThemeInstance,\n\tstopThemeWatcher,\n\ttheme,\n} from \"./global-theme.ts\";\nexport {\n\tdetectTerminalBackgroundFromEnv,\n\tdetectTerminalBackgroundTheme,\n\tgetDefaultTheme,\n\tgetThemeForRgbColor,\n\tparseAutoThemeSetting,\n\tresolveThemeSetting,\n\ttype TerminalBackgroundThemeDetectionOptions,\n\ttype TerminalBackgroundThemeDetector,\n\ttype TerminalTheme,\n\ttype TerminalThemeDetection,\n\ttype TerminalThemeDetectionOptions,\n} from \"./terminal-detection.ts\";\nexport { Theme, type ThemeBg, type ThemeColor } from \"./theme-class.ts\";\nexport {\n\tgetAvailableThemes,\n\tgetAvailableThemesWithPaths,\n\tgetThemeByName,\n\tloadThemeFromPath,\n\tloadThemeFromContent,\n\tsetRegisteredThemes,\n\ttype ThemeInfo,\n} from \"./theme-loading.ts\";\nexport {\n\tgetEditorTheme,\n\tgetLanguageFromPath,\n\tgetMarkdownTheme,\n\tgetSelectListTheme,\n\tgetSettingsListTheme,\n\thighlightCode,\n} from \"./tui-theme.ts\";\n"]}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChG,OAAO,EACN,SAAS,EACT,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,GACL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,+BAA+B,EAC/B,6BAA6B,EAC7B,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,uCAAuC,EAC5C,KAAK,+BAA+B,EACpC,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,GAClC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EACN,kBAAkB,EAClB,2BAA2B,EAC3B,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,SAAS,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,GACb,MAAM,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"tui-theme.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/tui-theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAiD1F;;;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,OAAO,wBAAwB,EAAE,iBAAiB,CAQzF","sourcesContent":["import type { EditorTheme, MarkdownTheme, SelectListTheme } from \"@earendil-works/pi-tui\";\nimport chalk from \"chalk\";\nimport { highlight, supportsLanguage } from \"../../../utils/syntax-highlight.ts\";\nimport { theme } from \"./global-theme.ts\";\nimport type { Theme } from \"./theme-class.ts\";\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(): import(\"@earendil-works/pi-tui\").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":"tui-theme.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/tui-theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAiD1F;;;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,OAAO,wBAAwB,EAAE,iBAAiB,CAQzF"}
@@ -1 +1 @@
1
- {"version":3,"file":"whimsical-messages.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/whimsical-messages.ts"],"names":[],"mappings":"AAAA;;GAEG;AA6cH,wBAAgB,2BAA2B,IAAI,MAAM,CAEpD","sourcesContent":["/**\n * Whimsical working messages cycled into the interactive loader between turns.\n */\n\nconst messages = [\n // Short\n \"Schlepping...\",\n \"Combobulating...\",\n \"Doing...\",\n \"Channelling...\",\n \"Vibing...\",\n \"Concocting...\",\n \"Spelunking...\",\n \"Transmuting...\",\n \"Imagining...\",\n \"Pontificating...\",\n \"Whirring...\",\n \"Cogitating...\",\n \"Honking...\",\n \"Flibbertigibbeting...\",\n \"Noodling...\",\n \"Percolating...\",\n \"Ruminating...\",\n \"Simmering...\",\n \"Marinating...\",\n \"Fermenting...\",\n \"Gestating...\",\n \"Hatching...\",\n \"Brewing...\",\n \"Steeping...\",\n \"Contemplating...\",\n \"Musing...\",\n \"Pondering...\",\n \"Mulling...\",\n \"Daydreaming...\",\n \"Woolgathering...\",\n \"Dithering...\",\n \"Faffing...\",\n \"Puttering...\",\n \"Tinkering...\",\n \"Fiddling...\",\n \"Noodging...\",\n \"Finagling...\",\n \"Wrangling...\",\n \"Jiggling...\",\n \"Wiggling...\",\n \"Shimmying...\",\n \"Galumphing...\",\n \"Perambulating...\",\n \"Meandering...\",\n \"Traipsing...\",\n \"Moseying...\",\n \"Sauntering...\",\n \"Ambling...\",\n \"Pottering...\",\n \"Bumbling...\",\n \"Futzing...\",\n \"Schmalzing...\",\n \"Kerfuffling...\",\n \"Bamboozling...\",\n \"Discombobulating...\",\n \"Recombobulating...\",\n \"Unbefuddling...\",\n \"Defenestrating...\",\n \"Confabulating...\",\n \"Persnicketing...\",\n \"Flummoxing...\",\n \"Befuddling...\",\n \"Snorkeling...\",\n \"Yodeling...\",\n \"Zigzagging...\",\n \"Ricocheting...\",\n \"Somersaulting...\",\n \"Pirouetting...\",\n \"Canoodling...\",\n \"Schmoozing...\",\n \"Kibbitzing...\",\n \"Skedaddling...\",\n \"Scampering...\",\n \"Skittering...\",\n \"Sashaying...\",\n \"Swashbuckling...\",\n \"Oscillating...\",\n \"Undulating...\",\n \"Pulsating...\",\n \"Effervescing...\",\n \"Fizzing...\",\n \"Bubbling...\",\n \"Perplexing...\",\n \"Mystifying...\",\n \"Enchanting...\",\n \"Bewitching...\",\n \"Beguiling...\",\n \"Mesmerizing...\",\n \"Bedazzling...\",\n \"Sparkling...\",\n \"Glittering...\",\n \"Scintillating...\",\n \"Coruscating...\",\n \"Phosphorescing...\",\n \"Luminescing...\",\n \"Sublimating...\",\n \"Synthesizing...\",\n \"Amalgamating...\",\n \"Procrastinating...\",\n \"Dillydallying...\",\n \"Lollygagging...\",\n \"Dawdling...\",\n \"Malingering...\",\n \"Skulking...\",\n \"Lurking...\",\n \"Sleuthing...\",\n \"Rummaging...\",\n \"Fossicking...\",\n \"Foraging...\",\n \"Scavenging...\",\n \"Absquatulating...\",\n \"Vamoosing...\",\n \"Absconding...\",\n \"Grooving...\",\n \"Jamming...\",\n \"Improvising...\",\n \"Extemporizing...\",\n \"Freestyling...\",\n \"Frolicking...\",\n \"Gamboling...\",\n \"Blorping...\",\n \"Flonking...\",\n \"Snurfling...\",\n \"Whomping...\",\n \"Zorping...\",\n \"Biffing...\",\n \"Splunging...\",\n \"Thwacking...\",\n \"Gonkulating...\",\n \"Splorfing...\",\n \"Wibbling...\",\n \"Wobbling...\",\n \"Squonking...\",\n \"Plonking...\",\n \"Bonking...\",\n \"Zonking...\",\n \"Flumping...\",\n \"Clomping...\",\n \"Squelching...\",\n \"Schlurping...\",\n \"Glurping...\",\n \"Burbling...\",\n \"Gurgling...\",\n \"Splooshing...\",\n \"Whooshing...\",\n \"Swooshing...\",\n \"Kerplunking...\",\n \"Thunking...\",\n \"Clunking...\",\n \"Clanking...\",\n \"Rattling...\",\n \"Jostling...\",\n \"Rustling...\",\n \"Bustling...\",\n \"Hustling...\",\n \"Miffing...\",\n \"Boffing...\",\n \"Snazzifying...\",\n \"Pizzazzing...\",\n \"Razzmatazzing...\",\n \"Bedoodling...\",\n \"Doodling...\",\n \"Scribbling...\",\n \"Squiggling...\",\n \"Wriggling...\",\n \"Niggling...\",\n \"Higgling...\",\n \"Piggling...\",\n \"Figgling...\",\n \"Gibbering...\",\n \"Jabbering...\",\n \"Blathering...\",\n \"Blithering...\",\n \"Withering...\",\n \"Slithering...\",\n \"Tethering...\",\n \"Feathering...\",\n \"Weathering...\",\n \"Leathering...\",\n \"Heathering...\",\n \"Smoldering...\",\n \"Moldering...\",\n \"Shouldering...\",\n \"Bouldering...\",\n \"Tottering...\",\n \"Teetering...\",\n \"Tittering...\",\n \"Flittering...\",\n \"Jittering...\",\n \"Frittering...\",\n \"Twittering...\",\n \"Nattering...\",\n \"Chattering...\",\n \"Clattering...\",\n \"Splattering...\",\n \"Battering...\",\n \"Scattering...\",\n \"Shattering...\",\n \"Flattering...\",\n \"Pattering...\",\n \"Tattering...\",\n \"Mattering...\",\n \"Yammering...\",\n \"Hammering...\",\n \"Stammering...\",\n \"Clamoring...\",\n \"Glamoring...\",\n \"Enamoring...\",\n \"Shimmering...\",\n \"Glimmering...\",\n \"Brimming...\",\n \"Skimming...\",\n \"Trimming...\",\n \"Primming...\",\n \"Whimming...\",\n \"Humming...\",\n \"Strumming...\",\n \"Thrumming...\",\n \"Drumming...\",\n \"Plumbing...\",\n \"Thumbing...\",\n \"Numbing...\",\n \"Fumbling...\",\n \"Grumbling...\",\n \"Mumbling...\",\n \"Rumbling...\",\n \"Stumbling...\",\n \"Tumbling...\",\n \"Crumbling...\",\n \"Jumbling...\",\n \"Humbling...\",\n \"Bungling...\",\n \"Jungling...\",\n \"Mangling...\",\n \"Wangling...\",\n \"Dangling...\",\n \"Tangling...\",\n \"Jangling...\",\n \"Angling...\",\n \"Struggling...\",\n \"Mingling...\",\n \"Tingling...\",\n \"Jingling...\",\n \"Singling...\",\n \"Ringling...\",\n \"Kingling...\",\n\n // Long\n \"Consulting the void...\",\n \"Asking the electrons...\",\n \"Bribing the compiler...\",\n \"Negotiating with entropy...\",\n \"Whispering to the bits...\",\n \"Tickling the stack...\",\n \"Massaging the heap...\",\n \"Appeasing the garbage collector...\",\n \"Summoning semicolons...\",\n \"Herding pointers...\",\n \"Untangling spaghetti...\",\n \"Polishing the algorithms...\",\n \"Waxing philosophical...\",\n \"Consulting ancient scrolls...\",\n \"Reading tea leaves...\",\n \"Shaking the magic 8-ball...\",\n \"Sacrificing to the demo gods...\",\n \"Warming up the hamsters...\",\n \"Spinning up the squirrels...\",\n \"Caffeinating...\",\n \"Existentially questioning...\",\n \"Having a little think...\",\n \"Stroking chin thoughtfully...\",\n \"Squinting at the problem...\",\n \"Staring into the abyss...\",\n \"Abyss staring back...\",\n \"Achieving enlightenment...\",\n \"Transcending mere computation...\",\n \"Ascending to a higher plane...\",\n \"Communing with the machine spirit...\",\n \"Performing arcane rituals...\",\n \"Invoking elder functions...\",\n \"Consulting the oracle...\",\n \"Divining the answer...\",\n \"Scrying the codebase...\",\n \"Dowsing for bugs...\",\n \"Rearranging deck chairs...\",\n \"Shuffling bits around...\",\n \"Aligning the chakras...\",\n \"Reticulating splines...\",\n \"Reversing the polarity...\",\n \"Calibrating the flux capacitor...\",\n \"Charging the crystals...\",\n \"Tuning the vibrations...\",\n \"Adjusting the cosmic frequency...\",\n \"Waiting for a sign...\",\n \"Hoping for the best...\",\n \"Manifesting solutions...\",\n \"Willing it into existence...\",\n \"Believing really hard...\",\n \"Politely asking the CPU...\",\n \"Bribing the runtime...\",\n \"Flirting with the database...\",\n \"Sweet-talking the API...\",\n \"Negotiating with deadlines...\",\n \"Having words with the cache...\",\n \"Reasoning with the memory...\",\n \"Pleading with the logs...\",\n \"Bargaining with fate...\",\n \"Making offerings to the CI...\",\n \"Praying to the uptime gods...\",\n \"Consulting the rubber duck...\",\n \"Interrogating the stack trace...\",\n \"Cross-examining the debugger...\",\n \"Petitioning the kernel...\",\n \"Lobbying the scheduler...\",\n \"Schmoozing the network...\",\n \"Buttering up the firewall...\",\n \"Wining and dining the servers...\",\n \"Taking the bytes out for lunch...\",\n \"Giving the code a pep talk...\",\n \"Reading the room...\",\n \"Checking under the hood...\",\n \"Kicking the tires...\",\n \"Shaking loose the cobwebs...\",\n \"Dusting off the neurons...\",\n \"Greasing the gears...\",\n \"Oiling the cogs...\",\n \"Winding up the clockwork...\",\n \"Stoking the furnace...\",\n \"Feeding the machine...\",\n \"Watering the logic tree...\",\n \"Pruning the decision branches...\",\n \"Harvesting the outputs...\",\n \"Planting computational seeds...\",\n \"Nurturing the algorithm...\",\n \"Raising the exceptions...\",\n \"Taming wild pointers...\",\n \"Herding cats in memory...\",\n \"Teaching old code new tricks...\",\n \"Whispering sweet nothings to the compiler...\",\n \"Serenading the syntax...\",\n \"Dancing with dependencies...\",\n \"Waltzing through the codebase...\",\n \"Tangoing with type errors...\",\n \"Doing the deployment dance...\",\n \"Having a moment of clarity...\",\n \"Experiencing a flash of insight...\",\n \"Channeling the ancient developers...\",\n \"Receiving transmissions from the cloud...\",\n \"Asking the hamsters to run faster...\",\n \"Convincing the pixels to cooperate...\",\n \"Teaching electrons new tricks...\",\n \"Bribing the byte fairies...\",\n \"Whispering passwords to the void...\",\n \"Negotiating with cosmic rays...\",\n \"Flattering the floating points...\",\n \"Seducing the semicolons...\",\n \"Wooing the while loops...\",\n \"Charming the curly braces...\",\n \"Hypnotizing the hash tables...\",\n \"Mesmerizing the memory banks...\",\n \"Enchanting the error handlers...\",\n \"Bewitching the boolean logic...\",\n \"Spellbinding the stack frames...\",\n \"Hexing the hexadecimals...\",\n \"Jinxing the JSON parsers...\",\n \"Cursing the cache misses...\",\n \"Blessing the build process...\",\n \"Anointing the algorithms...\",\n \"Consecrating the callbacks...\",\n \"Sanctifying the source code...\",\n \"Exorcising the exceptions...\",\n \"Purifying the parameters...\",\n \"Cleansing the closures...\",\n \"Baptizing the binary...\",\n \"Absolving the abstractions...\",\n \"Redeeming the recursion...\",\n \"Forgiving the for loops...\",\n \"Pardoning the pointers...\",\n \"Liberating the lambdas...\",\n \"Emancipating the enums...\",\n \"Freeing the functions...\",\n \"Releasing the references...\",\n \"Unbinding the variables...\",\n \"Untying the type knots...\",\n \"Unraveling the regex...\",\n \"Decoding the mysteries...\",\n \"Cracking the conundrums...\",\n \"Solving the riddles of RAM...\",\n \"Unlocking the secrets of silicon...\",\n \"Discovering hidden semicolons...\",\n \"Unearthing buried bugs...\",\n \"Excavating ancient APIs...\",\n \"Archeologically analyzing the architecture...\",\n \"Fossil hunting in the functions...\",\n \"Spelunking through the stack...\",\n \"Scuba diving in the data...\",\n \"Snorkeling through the streams...\",\n \"Parasailing past the parameters...\",\n \"Hang gliding through the heap...\",\n \"Bungee jumping into the backend...\",\n \"Skydiving through the source...\",\n \"Surfing the syntax waves...\",\n \"Skateboarding down the stack trace...\",\n \"Snowboarding through the schemas...\",\n \"Mountain climbing the modules...\",\n \"Hiking through the headers...\",\n \"Trekking through the trees...\",\n \"Backpacking through the binaries...\",\n \"Camping in the codebase...\",\n \"Glamping in the globals...\",\n \"Picnicking with the processes...\",\n \"Barbecuing the bugs...\",\n \"Roasting the race conditions...\",\n \"Grilling the glitches...\",\n \"Sautéing the syntax errors...\",\n \"Flambéing the failures...\",\n \"Caramelizing the callbacks...\",\n \"Braising the breakpoints...\",\n \"Poaching the pointers...\",\n \"Blanching the branches...\",\n \"Searing the segments...\",\n \"Smoking the subroutines...\",\n \"Curing the code smells...\",\n \"Pickling the packages...\",\n \"Preserving the protocols...\",\n \"Canning the constants...\",\n \"Bottling the buffers...\",\n \"Jarring the JavaScript...\",\n \"Decanting the data structures...\",\n \"Aerating the arrays...\",\n \"Letting the logic breathe...\",\n \"Aging the algorithms gracefully...\",\n \"Maturing the methods...\",\n \"Ripening the results...\",\n \"Seasoning the solutions...\",\n \"Spicing up the specs...\",\n \"Garnishing the getters...\",\n \"Plating the output nicely...\",\n \"Presenting with pizzazz...\",\n \"Adding a dash of elegance...\",\n \"Sprinkling some magic dust...\",\n \"Drizzling debug sauce...\",\n \"Folding in the features...\",\n \"Whisking the widgets...\",\n \"Kneading the namespaces...\",\n \"Rolling out the runtime...\",\n \"Proofing the promises...\",\n \"Letting the dough rise...\",\n \"Baking at 350 kilobytes...\",\n \"Frosting the functions...\",\n \"Decorating the deployment...\",\n \"Icing the interfaces...\",\n \"Glazing the graphics...\",\n \"Topping with tests...\",\n \"Cherry-picking the commits...\",\n];\n\nexport function pickWhimsicalWorkingMessage(): string {\n return messages[Math.floor(Math.random() * messages.length)];\n}\n"]}
1
+ {"version":3,"file":"whimsical-messages.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/whimsical-messages.ts"],"names":[],"mappings":"AAAA;;GAEG;AA6cH,wBAAgB,2BAA2B,IAAI,MAAM,CAEpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"print-mode.d.ts","sourceRoot":"","sources":["../../src/modes/print-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAoB,YAAY,EAAqB,MAAM,8BAA8B,CAAC;AAEtG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAO5E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,yEAAyE;IACzE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8CAA8C;IAC9C,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAC/B;AAiED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,WAAW,EAAE,mBAAmB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAuK/G","sourcesContent":["/**\n * Print mode (single-shot): Send prompts, output result, exit.\n *\n * Used for:\n * - `pi -p \"prompt\"` - text output\n * - `pi --mode json \"prompt\"` - JSON event stream\n */\n\nimport type { AssistantMessage, ImageContent, ToolResultMessage } from \"@earendil-works/pi-ai/compat\";\nimport type { AgentSessionEvent } from \"../core/agent-session.ts\";\nimport type { AgentSessionRuntime } from \"../core/agent-session-runtime.ts\";\nimport type { ExtensionError } from \"../core/extensions/index.ts\";\nimport type { ToolDefinition } from \"../core/extensions/types.ts\";\nimport type { CustomMessage } from \"../core/messages.ts\";\nimport { flushRawStdout, writeRawStdout } from \"../core/output-guard.ts\";\nimport { killTrackedDetachedChildren } from \"../utils/shell.ts\";\n\n/**\n * Options for print mode.\n */\nexport interface PrintModeOptions {\n\t/** Output mode: \"text\" for final response only, \"json\" for all events */\n\tmode: \"text\" | \"json\";\n\t/** Array of additional prompts to send after initialMessage */\n\tmessages?: string[];\n\t/** First message to send (may contain @file content) */\n\tinitialMessage?: string;\n\t/** Images to attach to the initial message */\n\tinitialImages?: ImageContent[];\n}\n\nfunction isCommandExtensionError(error: ExtensionError): boolean {\n\treturn error.event === \"command\" || error.extensionPath.startsWith(\"command:\");\n}\n\nfunction displayableCustomText(message: CustomMessage): string | undefined {\n\tif (message.display !== true) return undefined;\n\tif (typeof message.content === \"string\") return message.content;\n\n\tlet text = \"\";\n\tlet hasTextPart = false;\n\tfor (const part of message.content) {\n\t\tif (part.type === \"text\") {\n\t\t\thasTextPart = true;\n\t\t\ttext += part.text;\n\t\t}\n\t}\n\n\treturn hasTextPart ? text : undefined;\n}\n\ntype MaybeTerminatingToolResult = {\n\tterminate?: boolean;\n};\n\ntype ToolExecutionEndSessionEvent = Extract<AgentSessionEvent, { type: \"tool_execution_end\" }>;\n\ntype GetToolDefinition = (name: string) => ToolDefinition | undefined;\n\nfunction isStructuredOutputTool(getToolDefinition: GetToolDefinition, name: string): boolean {\n\treturn getToolDefinition(name)?.structuredOutput === true;\n}\n\nfunction isTerminatingStructuredOutputEvent(\n\tevent: AgentSessionEvent,\n\tgetToolDefinition: GetToolDefinition,\n): event is ToolExecutionEndSessionEvent {\n\tif (event.type !== \"tool_execution_end\") return false;\n\tif (!isStructuredOutputTool(getToolDefinition, event.toolName)) return false;\n\tif (event.isError) return false;\n\tconst result = event.result as MaybeTerminatingToolResult | undefined;\n\treturn result?.terminate === true;\n}\n\nfunction textFromToolResult(message: ToolResultMessage): string | undefined {\n\tlet text = \"\";\n\tlet hasTextPart = false;\n\tfor (const part of message.content) {\n\t\tif (part.type === \"text\") {\n\t\t\thasTextPart = true;\n\t\t\ttext += part.text;\n\t\t}\n\t}\n\treturn hasTextPart ? text : undefined;\n}\n\nfunction terminatingStructuredOutputText(\n\tmessage: ToolResultMessage,\n\tterminatingStructuredOutputCallIds: ReadonlySet<string>,\n): string | undefined {\n\tif (!terminatingStructuredOutputCallIds.has(message.toolCallId)) return undefined;\n\treturn textFromToolResult(message);\n}\n\n/**\n * Run in print (single-shot) mode.\n * Sends prompts to the agent and outputs the result.\n */\nexport async function runPrintMode(runtimeHost: AgentSessionRuntime, options: PrintModeOptions): Promise<number> {\n\tconst { mode, messages = [], initialMessage, initialImages } = options;\n\tlet exitCode = 0;\n\tlet suppressFinalOutput = false;\n\tlet activePromptHadCommandError = false;\n\tlet session = runtimeHost.session;\n\tlet unsubscribe: (() => void) | undefined;\n\tconst terminatingStructuredOutputCallIds = new Set<string>();\n\tlet disposed = false;\n\tconst signalCleanupHandlers: Array<() => void> = [];\n\n\tconst disposeRuntime = async (): Promise<void> => {\n\t\tif (disposed) return;\n\t\tdisposed = true;\n\t\tunsubscribe?.();\n\t\tawait runtimeHost.dispose();\n\t};\n\n\tconst registerSignalHandlers = (): void => {\n\t\tconst signals: NodeJS.Signals[] = [\"SIGTERM\"];\n\t\tif (process.platform !== \"win32\") {\n\t\t\tsignals.push(\"SIGHUP\");\n\t\t}\n\n\t\tfor (const signal of signals) {\n\t\t\tconst handler = () => {\n\t\t\t\tkillTrackedDetachedChildren();\n\t\t\t\tvoid disposeRuntime().finally(() => {\n\t\t\t\t\tprocess.exit(signal === \"SIGHUP\" ? 129 : 143);\n\t\t\t\t});\n\t\t\t};\n\t\t\tprocess.on(signal, handler);\n\t\t\tsignalCleanupHandlers.push(() => process.off(signal, handler));\n\t\t}\n\t};\n\n\tregisterSignalHandlers();\n\n\tconst promptWithScopedCommandSuppression = async (\n\t\ttext: string,\n\t\tpromptOptions?: { images?: ImageContent[] },\n\t): Promise<void> => {\n\t\tactivePromptHadCommandError = false;\n\t\ttry {\n\t\t\tif (promptOptions === undefined) {\n\t\t\t\tawait session.prompt(text);\n\t\t\t} else {\n\t\t\t\tawait session.prompt(text, promptOptions);\n\t\t\t}\n\t\t} finally {\n\t\t\t// Final-output suppression is scoped to the most recent prompt so a\n\t\t\t// later successful prompt in the same invocation can still print its\n\t\t\t// result. The non-zero exit code remains sticky across prompts.\n\t\t\tsuppressFinalOutput = activePromptHadCommandError;\n\t\t}\n\t};\n\n\tconst rebindSession = async (): Promise<void> => {\n\t\tsession = runtimeHost.session;\n\t\tawait session.bindExtensions({\n\t\t\tmode: mode === \"json\" ? \"json\" : \"print\",\n\t\t\tcommandContextActions: {\n\t\t\t\twaitForIdle: () => session.agent.waitForIdle(),\n\t\t\t\tnewSession: async (newSessionOptions) => runtimeHost.newSession(newSessionOptions),\n\t\t\t\tfork: async (entryId, forkOptions) => {\n\t\t\t\t\tconst result = await runtimeHost.fork(entryId, forkOptions);\n\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t},\n\t\t\t\tnavigateTree: async (targetId, navigateOptions) => {\n\t\t\t\t\tconst result = await session.navigateTree(targetId, {\n\t\t\t\t\t\tsummarize: navigateOptions?.summarize,\n\t\t\t\t\t\tcustomInstructions: navigateOptions?.customInstructions,\n\t\t\t\t\t\treplaceInstructions: navigateOptions?.replaceInstructions,\n\t\t\t\t\t\tlabel: navigateOptions?.label,\n\t\t\t\t\t});\n\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t},\n\t\t\t\tswitchSession: async (sessionPath, switchOptions) => {\n\t\t\t\t\treturn runtimeHost.switchSession(sessionPath, switchOptions);\n\t\t\t\t},\n\t\t\t\treload: async () => {\n\t\t\t\t\tawait session.reload();\n\t\t\t\t},\n\t\t\t},\n\t\t\tonError: (err) => {\n\t\t\t\tconst isCommandError = isCommandExtensionError(err);\n\t\t\t\tif (isCommandError) exitCode = 1;\n\t\t\t\tactivePromptHadCommandError = activePromptHadCommandError || isCommandError;\n\t\t\t\tconsole.error(`Extension error (${err.extensionPath}): ${err.error}`);\n\t\t\t},\n\t\t});\n\n\t\tunsubscribe?.();\n\t\tunsubscribe = session.subscribe((event) => {\n\t\t\tif (isTerminatingStructuredOutputEvent(event, (name) => session.getToolDefinition(name))) {\n\t\t\t\tterminatingStructuredOutputCallIds.add(event.toolCallId);\n\t\t\t}\n\t\t\tif (mode === \"json\") {\n\t\t\t\twriteRawStdout(`${JSON.stringify(event)}\\n`);\n\t\t\t}\n\t\t});\n\t};\n\n\truntimeHost.setRebindSession(async () => {\n\t\tawait rebindSession();\n\t});\n\n\ttry {\n\t\tif (mode === \"json\") {\n\t\t\tconst header = session.sessionManager.getHeader();\n\t\t\tif (header) {\n\t\t\t\twriteRawStdout(`${JSON.stringify(header)}\\n`);\n\t\t\t}\n\t\t}\n\n\t\tawait rebindSession();\n\n\t\tif (initialMessage) {\n\t\t\tawait promptWithScopedCommandSuppression(initialMessage, { images: initialImages });\n\t\t}\n\n\t\tfor (const message of messages) {\n\t\t\tawait promptWithScopedCommandSuppression(message);\n\t\t}\n\n\t\tconst state = session.state;\n\t\tconst lastMessage = state.messages[state.messages.length - 1];\n\n\t\tif (lastMessage?.role === \"assistant\") {\n\t\t\tconst assistantMsg = lastMessage as AssistantMessage;\n\t\t\tif (assistantMsg.stopReason === \"error\" || assistantMsg.stopReason === \"aborted\") {\n\t\t\t\tif (mode === \"text\" && !suppressFinalOutput) {\n\t\t\t\t\tconsole.error(assistantMsg.errorMessage || `Request ${assistantMsg.stopReason}`);\n\t\t\t\t}\n\t\t\t\texitCode = 1;\n\t\t\t} else if (mode === \"text\" && !suppressFinalOutput) {\n\t\t\t\tfor (const content of assistantMsg.content) {\n\t\t\t\t\tif (content.type === \"text\") {\n\t\t\t\t\t\twriteRawStdout(`${content.text}\\n`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (mode === \"text\" && !suppressFinalOutput) {\n\t\t\tif (lastMessage?.role === \"custom\") {\n\t\t\t\tconst text = displayableCustomText(lastMessage as CustomMessage);\n\t\t\t\tif (text !== undefined) {\n\t\t\t\t\twriteRawStdout(`${text}\\n`);\n\t\t\t\t}\n\t\t\t} else if (lastMessage?.role === \"toolResult\") {\n\t\t\t\tconst text = terminatingStructuredOutputText(lastMessage as ToolResultMessage, terminatingStructuredOutputCallIds);\n\t\t\t\tif (text !== undefined) {\n\t\t\t\t\twriteRawStdout(`${text}\\n`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn exitCode;\n\t} catch (error: unknown) {\n\t\tconsole.error(error instanceof Error ? error.message : String(error));\n\t\treturn 1;\n\t} finally {\n\t\tfor (const cleanup of signalCleanupHandlers) {\n\t\t\tcleanup();\n\t\t}\n\t\tawait disposeRuntime();\n\t\tawait flushRawStdout();\n\t}\n}\n"]}
1
+ {"version":3,"file":"print-mode.d.ts","sourceRoot":"","sources":["../../src/modes/print-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAoB,YAAY,EAAqB,MAAM,8BAA8B,CAAC;AAEtG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAO5E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,yEAAyE;IACzE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8CAA8C;IAC9C,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAC/B;AAiED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,WAAW,EAAE,mBAAmB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAuK/G"}
@@ -1 +1 @@
1
- {"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/jsonl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAExD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAqClG","sourcesContent":["import type { Readable } from \"node:stream\";\nimport { StringDecoder } from \"node:string_decoder\";\n\n/**\n * Serialize a single strict JSONL record.\n *\n * Framing is LF-only. Payload strings may contain other Unicode separators such as\n * U+2028 and U+2029. Clients must split records on `\\n` only.\n */\nexport function serializeJsonLine(value: unknown): string {\n\treturn `${JSON.stringify(value)}\\n`;\n}\n\n/**\n * Attach an LF-only JSONL reader to a stream.\n *\n * This intentionally does not use Node readline. Readline splits on additional\n * Unicode separators that are valid inside JSON strings and therefore does not\n * implement strict JSONL framing.\n */\nexport function attachJsonlLineReader(stream: Readable, onLine: (line: string) => void): () => void {\n\tconst decoder = new StringDecoder(\"utf8\");\n\tlet buffer = \"\";\n\n\tconst emitLine = (line: string) => {\n\t\tonLine(line.endsWith(\"\\r\") ? line.slice(0, -1) : line);\n\t};\n\n\tconst onData = (chunk: string | Buffer) => {\n\t\tbuffer += typeof chunk === \"string\" ? chunk : decoder.write(chunk);\n\n\t\twhile (true) {\n\t\t\tconst newlineIndex = buffer.indexOf(\"\\n\");\n\t\t\tif (newlineIndex === -1) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\temitLine(buffer.slice(0, newlineIndex));\n\t\t\tbuffer = buffer.slice(newlineIndex + 1);\n\t\t}\n\t};\n\n\tconst onEnd = () => {\n\t\tbuffer += decoder.end();\n\t\tif (buffer.length > 0) {\n\t\t\temitLine(buffer);\n\t\t\tbuffer = \"\";\n\t\t}\n\t};\n\n\tstream.on(\"data\", onData);\n\tstream.on(\"end\", onEnd);\n\n\treturn () => {\n\t\tstream.off(\"data\", onData);\n\t\tstream.off(\"end\", onEnd);\n\t};\n}\n"]}
1
+ {"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/jsonl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAExD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAqClG"}
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEnF,OAAO,KAAK,EAEX,oBAAoB,EACpB,QAAQ,EAER,eAAe,EACf,eAAe,EACf,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAYrE,MAAM,WAAW,gBAAgB;IAChC,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uFAAuF;IACvF,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;AAMzD,qBAAa,SAAS;IACrB,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,eAAe,CACZ;IACX,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,SAAS,CAAsB;IAEvC,QAAgB,OAAO,CAAmB;IAE1C,YAAY,OAAO,GAAE,gBAAqB,EAEzC;IAED,mCAAmC;IAC7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CA4D3B;IAED,kCAAkC;IAC5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAsB1B;IAED,iCAAiC;IACjC,OAAO,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,IAAI,CAQ9C;IAED,0DAA0D;IAC1D,SAAS,IAAI,MAAM,CAElB;IAMD;;;;OAIG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE;IAED,+DAA+D;IACzD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnE;IAED,0EAA0E;IACpE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtE;IAED,+BAA+B;IACzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED;;;;OAIG;IACG,UAAU,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAGxE;IAED,iCAAiC;IAC3B,QAAQ,IAAI,OAAO,CAAC,eAAe,CAAC,CAGzC;IAED,oCAAoC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAG3F;IAED,2BAA2B;IACrB,UAAU,IAAI,OAAO,CAAC;QAC3B,KAAK,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;QACxC,aAAa,EAAE,aAAa,CAAC;QAC7B,QAAQ,EAAE,OAAO,CAAC;KAClB,GAAG,IAAI,CAAC,CAGR;IAED,oCAAoC;IAC9B,kBAAkB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAG/C;IAED,0BAA0B;IACpB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D;IAED,4BAA4B;IACtB,kBAAkB,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,aAAa,CAAA;KAAE,GAAG,IAAI,CAAC,CAGnE;IAED;;;OAGG;IACG,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGpE;IAED,yEAAyE;IACnE,0BAA0B,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAGhE;IAED,yBAAyB;IACnB,eAAe,CAAC,IAAI,EAAE,KAAK,GAAG,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAElE;IAED,0BAA0B;IACpB,eAAe,CAAC,IAAI,EAAE,KAAK,GAAG,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAElE;IAED,mEAAmE;IAC7D,OAAO,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAGjD;IAEK,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvD;IACK,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAElD;IACK,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAEhC;IACK,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAG/C;IACK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAE/B;IACK,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC,CAG7C;IACK,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAG/D;IACK,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAGxE;IACK,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAGzE;IACK,KAAK,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAG7C;IACK,eAAe,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAGzE;IAED,yFAAyF;IACnF,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAG5F;IAED,8BAA8B;IACxB,OAAO,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,eAAe,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAG3E;IACK,oBAAoB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGnD;IACK,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhD;IACK,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAG3C;IACK,WAAW,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAG9C;IACD,WAAW,CAAC,OAAO,SAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAc1C;IACD,aAAa,CAAC,OAAO,SAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAgBlD;IACK,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,EAAE,OAAO,SAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAIlG;IACD,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,sBAAsB;IAG9B,OAAO,CAAC,qBAAqB;YAMf,IAAI;IA2ClB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,OAAO;CAKf","sourcesContent":["/**\n * RPC Client for programmatic access to the coding agent.\n *\n * Spawns the agent in RPC mode and provides a typed API for all operations.\n */\n\nimport { type ChildProcess, spawn } from \"node:child_process\";\nimport type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent } from \"@earendil-works/pi-ai/compat\";\nimport type { SessionStats } from \"../../core/agent-session.ts\";\nimport type { BashResult } from \"../../core/bash-executor.ts\";\nimport type { VerbatimCompactionResult } from \"../../core/compaction/index.ts\";\nimport type { SessionEntry, SessionTreeNode } from \"../../core/session-manager.ts\";\nimport { attachJsonlLineReader, serializeJsonLine } from \"./jsonl.ts\";\nimport type {\n\tRpcCommand,\n\tRpcContextWindowInfo,\n\tRpcEvent,\n\tRpcResponse,\n\tRpcSessionState,\n\tRpcSlashCommand,\n} from \"./rpc-types.ts\";\nexport type { RpcContextWindowInfo, RpcEvent } from \"./rpc-types.ts\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/** Distributive Omit that works with union types */\ntype DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;\n\n/** RpcCommand without the id field (for internal send) */\ntype RpcCommandBody = DistributiveOmit<RpcCommand, \"id\">;\n\nexport interface RpcClientOptions {\n\t/** Path to the CLI entry point (default: searches for dist/cli.js) */\n\tcliPath?: string;\n\t/** Working directory for the agent */\n\tcwd?: string;\n\t/** Environment variables */\n\tenv?: Record<string, string>;\n\t/** Provider to use */\n\tprovider?: string;\n\t/** Model ID to use */\n\tmodel?: string;\n\t/** Startup context-window selection, as raw tokens or compact form like \"400k\"/\"1m\" */\n\tcontextWindow?: number | string;\n\t/** Additional CLI arguments */\n\targs?: string[];\n}\n\nexport interface ModelInfo {\n\tprovider: string;\n\tid: string;\n\tcontextWindow: number;\n\treasoning: boolean;\n}\n\nexport type RpcEventListener = (event: RpcEvent) => void;\n\n// ============================================================================\n// RPC Client\n// ============================================================================\n\nexport class RpcClient {\n\tprivate process: ChildProcess | null = null;\n\tprivate stopReadingStdout: (() => void) | null = null;\n\tprivate eventListeners: RpcEventListener[] = [];\n\tprivate pendingRequests: Map<string, { resolve: (response: RpcResponse) => void; reject: (error: Error) => void }> =\n\t\tnew Map();\n\tprivate requestId = 0;\n\tprivate stderr = \"\";\n\tprivate exitError: Error | null = null;\n\n\tdeclare private options: RpcClientOptions;\n\n\tconstructor(options: RpcClientOptions = {}) {\n\t\tthis.options = options;\n\t}\n\n\t/** Start the RPC agent process. */\n\tasync start(): Promise<void> {\n\t\tif (this.process) {\n\t\t\tthrow new Error(\"Client already started\");\n\t\t}\n\n\t\tconst cliPath = this.options.cliPath ?? \"dist/cli.js\";\n\t\tconst args = [\"--mode\", \"rpc\"];\n\n\t\tif (this.options.provider) {\n\t\t\targs.push(\"--provider\", this.options.provider);\n\t\t}\n\t\tif (this.options.model) {\n\t\t\targs.push(\"--model\", this.options.model);\n\t\t}\n\t\tif (this.options.contextWindow !== undefined) {\n\t\t\targs.push(\"--context-window\", String(this.options.contextWindow));\n\t\t}\n\t\tif (this.options.args) {\n\t\t\targs.push(...this.options.args);\n\t\t}\n\n\t\tthis.exitError = null;\n\t\tconst childProcess = spawn(\"node\", [cliPath, ...args], {\n\t\t\tcwd: this.options.cwd,\n\t\t\tenv: { ...process.env, ...this.options.env },\n\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t});\n\t\tthis.process = childProcess;\n\n\t\tchildProcess.once(\"exit\", (code, signal) => {\n\t\t\tconst error = this.createProcessExitError(code, signal);\n\t\t\tthis.exitError = error;\n\t\t\tthis.rejectPendingRequests(error);\n\t\t});\n\t\tchildProcess.once(\"error\", (error) => {\n\t\t\tthis.exitError = error;\n\t\t\tthis.rejectPendingRequests(error);\n\t\t});\n\t\tchildProcess.stdin?.on(\"error\", (error) => {\n\t\t\tthis.exitError = error;\n\t\t\tthis.rejectPendingRequests(error);\n\t\t});\n\n\t\t// Collect stderr for debugging\n\t\tchildProcess.stderr?.on(\"data\", (data) => {\n\t\t\tthis.stderr += data.toString();\n\t\t\tprocess.stderr.write(data);\n\t\t});\n\n\t\t// Set up strict JSONL reader for stdout.\n\t\tthis.stopReadingStdout = attachJsonlLineReader(childProcess.stdout!, (line) => {\n\t\t\tthis.handleLine(line);\n\t\t});\n\n\t\t// Wait a moment for process to initialize\n\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\n\t\tif (this.process.exitCode !== null) {\n\t\t\tthrow new Error(`Agent process exited immediately with code ${this.process.exitCode}. Stderr: ${this.stderr}`);\n\t\t}\n\t}\n\n\t/** Stop the RPC agent process. */\n\tasync stop(): Promise<void> {\n\t\tif (!this.process) return;\n\n\t\tthis.stopReadingStdout?.();\n\t\tthis.stopReadingStdout = null;\n\t\tthis.process.kill(\"SIGTERM\");\n\n\t\t// Wait for process to exit\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tthis.process?.kill(\"SIGKILL\");\n\t\t\t\tresolve();\n\t\t\t}, 1000);\n\n\t\t\tthis.process?.on(\"exit\", () => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\n\t\tthis.process = null;\n\t\tthis.pendingRequests.clear();\n\t}\n\n\t/** Subscribe to agent events. */\n\tonEvent(listener: RpcEventListener): () => void {\n\t\tthis.eventListeners.push(listener);\n\t\treturn () => {\n\t\t\tconst index = this.eventListeners.indexOf(listener);\n\t\t\tif (index !== -1) {\n\t\t\t\tthis.eventListeners.splice(index, 1);\n\t\t\t}\n\t\t};\n\t}\n\n\t/** Get collected stderr output (useful for debugging). */\n\tgetStderr(): string {\n\t\treturn this.stderr;\n\t}\n\n\t// =========================================================================\n\t// Command Methods\n\t// =========================================================================\n\n\t/**\n\t * Send a prompt to the agent.\n\t * Returns immediately after sending; use onEvent() to receive streaming events.\n\t * Use waitForIdle() to wait for completion.\n\t */\n\tasync prompt(message: string, images?: ImageContent[]): Promise<void> {\n\t\tawait this.send({ type: \"prompt\", message, images });\n\t}\n\n\t/** Queue a steering message to interrupt the agent mid-run. */\n\tasync steer(message: string, images?: ImageContent[]): Promise<void> {\n\t\tawait this.send({ type: \"steer\", message, images });\n\t}\n\n\t/** Queue a follow-up message to be processed after the agent finishes. */\n\tasync followUp(message: string, images?: ImageContent[]): Promise<void> {\n\t\tawait this.send({ type: \"follow_up\", message, images });\n\t}\n\n\t/** Abort current operation. */\n\tasync abort(): Promise<void> {\n\t\tawait this.send({ type: \"abort\" });\n\t}\n\n\t/**\n\t * Start a new session, optionally with parent tracking.\n\t * @param parentSession - Optional parent session path for lineage tracking\n\t * @returns Object with `cancelled: true` if an extension cancelled the new session\n\t */\n\tasync newSession(parentSession?: string): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"new_session\", parentSession });\n\t\treturn this.getData(response);\n\t}\n\n\t/** Get current session state. */\n\tasync getState(): Promise<RpcSessionState> {\n\t\tconst response = await this.send({ type: \"get_state\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/** Set model by provider and ID. */\n\tasync setModel(provider: string, modelId: string): Promise<{ provider: string; id: string }> {\n\t\tconst response = await this.send({ type: \"set_model\", provider, modelId });\n\t\treturn this.getData(response);\n\t}\n\n\t/** Cycle to next model. */\n\tasync cycleModel(): Promise<{\n\t\tmodel: { provider: string; id: string };\n\t\tthinkingLevel: ThinkingLevel;\n\t\tisScoped: boolean;\n\t} | null> {\n\t\tconst response = await this.send({ type: \"cycle_model\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/** Get list of available models. */\n\tasync getAvailableModels(): Promise<ModelInfo[]> {\n\t\tconst response = await this.send({ type: \"get_available_models\" });\n\t\treturn this.getData<{ models: ModelInfo[] }>(response).models;\n\t}\n\n\t/** Set thinking level. */\n\tasync setThinkingLevel(level: ThinkingLevel): Promise<void> {\n\t\tawait this.send({ type: \"set_thinking_level\", level });\n\t}\n\n\t/** Cycle thinking level. */\n\tasync cycleThinkingLevel(): Promise<{ level: ThinkingLevel } | null> {\n\t\tconst response = await this.send({ type: \"cycle_thinking_level\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Set the active context-window token budget for the current model.\n\t * This is a runtime selection and does not persist context-window defaults.\n\t */\n\tasync setContextWindow(contextWindow: number | string): Promise<void> {\n\t\tconst response = await this.send({ type: \"set_context_window\", contextWindow });\n\t\tthis.assertSuccess(response);\n\t}\n\n\t/** Get selectable context-window token budgets for the current model. */\n\tasync getAvailableContextWindows(): Promise<RpcContextWindowInfo> {\n\t\tconst response = await this.send({ type: \"get_available_context_windows\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/** Set steering mode. */\n\tasync setSteeringMode(mode: \"all\" | \"one-at-a-time\"): Promise<void> {\n\t\tawait this.send({ type: \"set_steering_mode\", mode });\n\t}\n\n\t/** Set follow-up mode. */\n\tasync setFollowUpMode(mode: \"all\" | \"one-at-a-time\"): Promise<void> {\n\t\tawait this.send({ type: \"set_follow_up_mode\", mode });\n\t}\n\n\t/** Compact session context with verbatim line-range compaction. */\n\tasync compact(): Promise<VerbatimCompactionResult> {\n\t\tconst response = await this.send({ type: \"compact\" });\n\t\treturn this.getData(response);\n\t}\n\n\tasync setAutoCompaction(enabled: boolean): Promise<void> {\n\t\tawait this.send({ type: \"set_auto_compaction\", enabled });\n\t}\n\tasync setAutoRetry(enabled: boolean): Promise<void> {\n\t\tawait this.send({ type: \"set_auto_retry\", enabled });\n\t}\n\tasync abortRetry(): Promise<void> {\n\t\tawait this.send({ type: \"abort_retry\" });\n\t}\n\tasync bash(command: string): Promise<BashResult> {\n\t\tconst response = await this.send({ type: \"bash\", command });\n\t\treturn this.getData(response);\n\t}\n\tasync abortBash(): Promise<void> {\n\t\tawait this.send({ type: \"abort_bash\" });\n\t}\n\tasync getSessionStats(): Promise<SessionStats> {\n\t\tconst response = await this.send({ type: \"get_session_stats\" });\n\t\treturn this.getData(response);\n\t}\n\tasync exportHtml(outputPath?: string): Promise<{ path: string }> {\n\t\tconst response = await this.send({ type: \"export_html\", outputPath });\n\t\treturn this.getData(response);\n\t}\n\tasync switchSession(sessionPath: string): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"switch_session\", sessionPath });\n\t\treturn this.getData(response);\n\t}\n\tasync fork(entryId: string): Promise<{ text: string; cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"fork\", entryId });\n\t\treturn this.getData(response);\n\t}\n\tasync clone(): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"clone\" });\n\t\treturn this.getData(response);\n\t}\n\tasync getForkMessages(): Promise<Array<{ entryId: string; text: string }>> {\n\t\tconst response = await this.send({ type: \"get_fork_messages\" });\n\t\treturn this.getData<{ messages: Array<{ entryId: string; text: string }> }>(response).messages;\n\t}\n\n\t/** Session entries in append order, optionally only those after the `since` entry id. */\n\tasync getEntries(since?: string): Promise<{ entries: SessionEntry[]; leafId: string | null }> {\n\t\tconst response = await this.send({ type: \"get_entries\", since });\n\t\treturn this.getData<{ entries: SessionEntry[]; leafId: string | null }>(response);\n\t}\n\n\t/** The session entry tree. */\n\tasync getTree(): Promise<{ tree: SessionTreeNode[]; leafId: string | null }> {\n\t\tconst response = await this.send({ type: \"get_tree\" });\n\t\treturn this.getData<{ tree: SessionTreeNode[]; leafId: string | null }>(response);\n\t}\n\tasync getLastAssistantText(): Promise<string | null> {\n\t\tconst response = await this.send({ type: \"get_last_assistant_text\" });\n\t\treturn this.getData<{ text: string | null }>(response).text;\n\t}\n\tasync setSessionName(name: string): Promise<void> {\n\t\tawait this.send({ type: \"set_session_name\", name });\n\t}\n\tasync getMessages(): Promise<AgentMessage[]> {\n\t\tconst response = await this.send({ type: \"get_messages\" });\n\t\treturn this.getData<{ messages: AgentMessage[] }>(response).messages;\n\t}\n\tasync getCommands(): Promise<RpcSlashCommand[]> {\n\t\tconst response = await this.send({ type: \"get_commands\" });\n\t\treturn this.getData<{ commands: RpcSlashCommand[] }>(response).commands;\n\t}\n\twaitForIdle(timeout = 60000): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tunsubscribe();\n\t\t\t\treject(new Error(`Timeout waiting for agent to become idle. Stderr: ${this.stderr}`));\n\t\t\t}, timeout);\n\t\t\tconst unsubscribe = this.onEvent((event) => {\n\t\t\t\tif (event.type === \"agent_end\") {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tunsubscribe();\n\t\t\t\t\tresolve();\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\tcollectEvents(timeout = 60000): Promise<RpcEvent[]> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst events: RpcEvent[] = [];\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tunsubscribe();\n\t\t\t\treject(new Error(`Timeout collecting events. Stderr: ${this.stderr}`));\n\t\t\t}, timeout);\n\t\t\tconst unsubscribe = this.onEvent((event) => {\n\t\t\t\tevents.push(event);\n\t\t\t\tif (event.type === \"agent_end\") {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tunsubscribe();\n\t\t\t\t\tresolve(events);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\tasync promptAndWait(message: string, images?: ImageContent[], timeout = 60000): Promise<RpcEvent[]> {\n\t\tconst eventsPromise = this.collectEvents(timeout);\n\t\tawait this.prompt(message, images);\n\t\treturn eventsPromise;\n\t}\n\tprivate handleLine(line: string): void {\n\t\ttry {\n\t\t\tconst data = JSON.parse(line);\n\t\t\tif (data.type === \"response\" && data.id && this.pendingRequests.has(data.id)) {\n\t\t\t\tconst pending = this.pendingRequests.get(data.id)!;\n\t\t\t\tthis.pendingRequests.delete(data.id);\n\t\t\t\tpending.resolve(data as RpcResponse);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (const listener of this.eventListeners) {\n\t\t\t\tlistener(data as RpcEvent);\n\t\t\t}\n\t\t} catch {\n\t\t}\n\t}\n\tprivate createProcessExitError(code: number | null, signal: NodeJS.Signals | null): Error {\n\t\treturn new Error(`Agent process exited (code=${code} signal=${signal}). Stderr: ${this.stderr}`);\n\t}\n\tprivate rejectPendingRequests(error: Error): void {\n\t\tfor (const { reject } of this.pendingRequests.values()) {\n\t\t\treject(error);\n\t\t}\n\t\tthis.pendingRequests.clear();\n\t}\n\tprivate async send(command: RpcCommandBody): Promise<RpcResponse> {\n\t\tconst childProcess = this.process;\n\t\tconst stdin = childProcess?.stdin;\n\t\tif (!childProcess || !stdin) {\n\t\t\tthrow new Error(\"Client not started\");\n\t\t}\n\t\tif (this.exitError) {\n\t\t\tthrow this.exitError;\n\t\t}\n\t\tif (childProcess.exitCode !== null) {\n\t\t\tconst error = this.createProcessExitError(childProcess.exitCode, childProcess.signalCode);\n\t\t\tthis.exitError = error;\n\t\t\tthrow error;\n\t\t}\n\t\tif (stdin.destroyed || !stdin.writable) {\n\t\t\tthrow new Error(\"Agent process stdin is not writable\");\n\t\t}\n\t\tconst id = `req_${++this.requestId}`;\n\t\tconst fullCommand = { ...command, id } as RpcCommand;\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tthis.pendingRequests.delete(id);\n\t\t\t\treject(new Error(`Timeout waiting for response to ${command.type}. Stderr: ${this.stderr}`));\n\t\t\t}, 30000);\n\t\t\tthis.pendingRequests.set(id, {\n\t\t\t\tresolve: (response) => {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tresolve(response);\n\t\t\t\t},\n\t\t\t\treject: (error) => {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\treject(error);\n\t\t\t\t},\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tstdin.write(serializeJsonLine(fullCommand));\n\t\t\t} catch (error) {\n\t\t\t\tthis.pendingRequests.delete(id);\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\treject(error instanceof Error ? error : new Error(String(error)));\n\t\t\t}\n\t\t});\n\t}\n\tprivate assertSuccess(response: RpcResponse): void {\n\t\tif (!response.success) {\n\t\t\tthrow new Error(response.error);\n\t\t}\n\t}\n\tprivate getData<T>(response: RpcResponse): T {\n\t\tthis.assertSuccess(response);\n\t\tconst successResponse = response as Extract<RpcResponse, { success: true; data: unknown }>;\n\t\treturn successResponse.data as T;\n\t}\n}\n"]}
1
+ {"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEnF,OAAO,KAAK,EAEX,oBAAoB,EACpB,QAAQ,EAER,eAAe,EACf,eAAe,EACf,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAYrE,MAAM,WAAW,gBAAgB;IAChC,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uFAAuF;IACvF,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;AAMzD,qBAAa,SAAS;IACrB,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,eAAe,CACZ;IACX,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,SAAS,CAAsB;IAEvC,QAAgB,OAAO,CAAmB;IAE1C,YAAY,OAAO,GAAE,gBAAqB,EAEzC;IAED,mCAAmC;IAC7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CA4D3B;IAED,kCAAkC;IAC5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAsB1B;IAED,iCAAiC;IACjC,OAAO,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,IAAI,CAQ9C;IAED,0DAA0D;IAC1D,SAAS,IAAI,MAAM,CAElB;IAMD;;;;OAIG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE;IAED,+DAA+D;IACzD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnE;IAED,0EAA0E;IACpE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtE;IAED,+BAA+B;IACzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED;;;;OAIG;IACG,UAAU,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAGxE;IAED,iCAAiC;IAC3B,QAAQ,IAAI,OAAO,CAAC,eAAe,CAAC,CAGzC;IAED,oCAAoC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAG3F;IAED,2BAA2B;IACrB,UAAU,IAAI,OAAO,CAAC;QAC3B,KAAK,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;QACxC,aAAa,EAAE,aAAa,CAAC;QAC7B,QAAQ,EAAE,OAAO,CAAC;KAClB,GAAG,IAAI,CAAC,CAGR;IAED,oCAAoC;IAC9B,kBAAkB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAG/C;IAED,0BAA0B;IACpB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D;IAED,4BAA4B;IACtB,kBAAkB,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,aAAa,CAAA;KAAE,GAAG,IAAI,CAAC,CAGnE;IAED;;;OAGG;IACG,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGpE;IAED,yEAAyE;IACnE,0BAA0B,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAGhE;IAED,yBAAyB;IACnB,eAAe,CAAC,IAAI,EAAE,KAAK,GAAG,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAElE;IAED,0BAA0B;IACpB,eAAe,CAAC,IAAI,EAAE,KAAK,GAAG,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAElE;IAED,mEAAmE;IAC7D,OAAO,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAGjD;IAEK,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvD;IACK,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAElD;IACK,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAEhC;IACK,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAG/C;IACK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAE/B;IACK,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC,CAG7C;IACK,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAG/D;IACK,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAGxE;IACK,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAGzE;IACK,KAAK,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAG7C;IACK,eAAe,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAGzE;IAED,yFAAyF;IACnF,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAG5F;IAED,8BAA8B;IACxB,OAAO,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,eAAe,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAG3E;IACK,oBAAoB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGnD;IACK,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhD;IACK,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAG3C;IACK,WAAW,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAG9C;IACD,WAAW,CAAC,OAAO,SAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAc1C;IACD,aAAa,CAAC,OAAO,SAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAgBlD;IACK,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,EAAE,OAAO,SAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAIlG;IACD,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,sBAAsB;IAG9B,OAAO,CAAC,qBAAqB;YAMf,IAAI;IA2ClB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,OAAO;CAKf"}
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-command-handler.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-command-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAKN,KAAK,SAAS,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAoC,MAAM,gBAAgB,CAAC;AAEhG,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;AAE1F,UAAU,wBAAwB;IACjC,WAAW,EAAE,mBAAmB,CAAC;IACjC,UAAU,EAAE,MAAM,YAAY,CAAC;IAC/B,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,EAAE,SAAS,CAAC;CAClB;AAED,wBAAgB,uBAAuB,CAAC,EACvC,WAAW,EACX,UAAU,EACV,aAAa,EACb,MAAM,GACN,EAAE,wBAAwB,GAAG,iBAAiB,CAqR9C","sourcesContent":["import type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport {\n\tcreateRpcErrorResponse,\n\tcreateRpcSuccessResponse,\n\tformatRpcErrorMessage,\n\tparseRpcContextWindow,\n\ttype RpcOutput,\n} from \"./rpc-responses.ts\";\nimport type { RpcCommand, RpcResponse, RpcSessionState, RpcSlashCommand } from \"./rpc-types.ts\";\n\nexport type RpcCommandHandler = (command: RpcCommand) => Promise<RpcResponse | undefined>;\n\ninterface RpcCommandHandlerOptions {\n\truntimeHost: AgentSessionRuntime;\n\tgetSession: () => AgentSession;\n\trebindSession: () => Promise<void>;\n\toutput: RpcOutput;\n}\n\nexport function createRpcCommandHandler({\n\truntimeHost,\n\tgetSession,\n\trebindSession,\n\toutput,\n}: RpcCommandHandlerOptions): RpcCommandHandler {\n\treturn async (command: RpcCommand): Promise<RpcResponse | undefined> => {\n\t\tconst id = command.id;\n\t\tconst session = getSession();\n\n\t\tswitch (command.type) {\n\t\t\tcase \"prompt\": {\n\t\t\t\tlet preflightSucceeded = false;\n\t\t\t\tvoid session\n\t\t\t\t\t.prompt(command.message, {\n\t\t\t\t\t\timages: command.images,\n\t\t\t\t\t\tstreamingBehavior: command.streamingBehavior,\n\t\t\t\t\t\tsource: \"rpc\",\n\t\t\t\t\t\tpreflightResult: (didSucceed) => {\n\t\t\t\t\t\t\tif (didSucceed) {\n\t\t\t\t\t\t\t\tpreflightSucceeded = true;\n\t\t\t\t\t\t\t\toutput(createRpcSuccessResponse(id, \"prompt\"));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t\t.catch((promptError: unknown) => {\n\t\t\t\t\t\tif (!preflightSucceeded) {\n\t\t\t\t\t\t\toutput(createRpcErrorResponse(id, \"prompt\", formatRpcErrorMessage(promptError)));\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tcase \"steer\": {\n\t\t\t\tawait session.steer(command.message, command.images);\n\t\t\t\treturn createRpcSuccessResponse(id, \"steer\");\n\t\t\t}\n\n\t\t\tcase \"follow_up\": {\n\t\t\t\tawait session.followUp(command.message, command.images);\n\t\t\t\treturn createRpcSuccessResponse(id, \"follow_up\");\n\t\t\t}\n\n\t\t\tcase \"abort\": {\n\t\t\t\tawait session.abort();\n\t\t\t\treturn createRpcSuccessResponse(id, \"abort\");\n\t\t\t}\n\n\t\t\tcase \"new_session\": {\n\t\t\t\tconst options = command.parentSession ? { parentSession: command.parentSession } : undefined;\n\t\t\t\tconst result = await runtimeHost.newSession(options);\n\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\tawait rebindSession();\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"new_session\", result);\n\t\t\t}\n\n\t\t\tcase \"get_state\": {\n\t\t\t\tconst state: RpcSessionState = {\n\t\t\t\t\tmodel: session.model,\n\t\t\t\t\tthinkingLevel: session.thinkingLevel,\n\t\t\t\t\tisStreaming: session.isStreaming,\n\t\t\t\t\tisCompacting: session.isCompacting,\n\t\t\t\t\tsteeringMode: session.steeringMode,\n\t\t\t\t\tfollowUpMode: session.followUpMode,\n\t\t\t\t\tsessionFile: session.sessionFile,\n\t\t\t\t\tsessionId: session.sessionId,\n\t\t\t\t\tsessionName: session.sessionName,\n\t\t\t\t\tautoCompactionEnabled: session.autoCompactionEnabled,\n\t\t\t\t\tmessageCount: session.messages.length,\n\t\t\t\t\tpendingMessageCount: session.pendingMessageCount,\n\t\t\t\t};\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_state\", state);\n\t\t\t}\n\n\t\t\tcase \"set_model\": {\n\t\t\t\tconst models = await session.modelRegistry.getAvailable();\n\t\t\t\tconst model = models.find((candidate) => candidate.provider === command.provider && candidate.id === command.modelId);\n\t\t\t\tif (!model) {\n\t\t\t\t\treturn createRpcErrorResponse(id, \"set_model\", `Model not found: ${command.provider}/${command.modelId}`);\n\t\t\t\t}\n\t\t\t\tawait session.setModel(model);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_model\", session.model ?? model);\n\t\t\t}\n\n\t\t\tcase \"cycle_model\": {\n\t\t\t\tconst result = await session.cycleModel();\n\t\t\t\treturn createRpcSuccessResponse(id, \"cycle_model\", result ?? null);\n\t\t\t}\n\n\t\t\tcase \"get_available_models\": {\n\t\t\t\tconst models = await session.modelRegistry.getAvailable();\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_available_models\", { models });\n\t\t\t}\n\n\t\t\tcase \"set_thinking_level\": {\n\t\t\t\tsession.setThinkingLevel(command.level);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_thinking_level\");\n\t\t\t}\n\n\t\t\tcase \"cycle_thinking_level\": {\n\t\t\t\tconst level = session.cycleThinkingLevel();\n\t\t\t\treturn createRpcSuccessResponse(id, \"cycle_thinking_level\", level ? { level } : null);\n\t\t\t}\n\n\t\t\tcase \"set_context_window\": {\n\t\t\t\tconst contextWindow = parseRpcContextWindow(command.contextWindow);\n\t\t\t\tsession.setContextWindow(contextWindow);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_context_window\");\n\t\t\t}\n\n\t\t\tcase \"get_available_context_windows\": {\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_available_context_windows\", {\n\t\t\t\t\tcontextWindows: session.getAvailableContextWindows(),\n\t\t\t\t\tcurrentContextWindow: session.model?.contextWindow,\n\t\t\t\t\tsupportsSelection: session.supportsContextWindowSelection(),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"set_steering_mode\": {\n\t\t\t\tsession.setSteeringMode(command.mode);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_steering_mode\");\n\t\t\t}\n\n\t\t\tcase \"set_follow_up_mode\": {\n\t\t\t\tsession.setFollowUpMode(command.mode);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_follow_up_mode\");\n\t\t\t}\n\n\t\t\tcase \"compact\": {\n\t\t\t\tconst result = await session.compact();\n\t\t\t\treturn createRpcSuccessResponse(id, \"compact\", result);\n\t\t\t}\n\n\n\t\t\tcase \"set_auto_compaction\": {\n\t\t\t\tsession.setAutoCompactionEnabled(command.enabled);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_auto_compaction\");\n\t\t\t}\n\n\t\t\tcase \"set_auto_retry\": {\n\t\t\t\tsession.setAutoRetryEnabled(command.enabled);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_auto_retry\");\n\t\t\t}\n\n\t\t\tcase \"abort_retry\": {\n\t\t\t\tsession.abortRetry();\n\t\t\t\treturn createRpcSuccessResponse(id, \"abort_retry\");\n\t\t\t}\n\n\t\t\tcase \"bash\": {\n\t\t\t\tconst result = await session.executeBash(command.command, undefined, {\n\t\t\t\t\texcludeFromContext: command.excludeFromContext,\n\t\t\t\t});\n\t\t\t\treturn createRpcSuccessResponse(id, \"bash\", result);\n\t\t\t}\n\n\t\t\tcase \"abort_bash\": {\n\t\t\t\tsession.abortBash();\n\t\t\t\treturn createRpcSuccessResponse(id, \"abort_bash\");\n\t\t\t}\n\n\t\t\tcase \"get_session_stats\": {\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_session_stats\", session.getSessionStats());\n\t\t\t}\n\n\t\t\tcase \"export_html\": {\n\t\t\t\tconst path = await session.exportToHtml(command.outputPath);\n\t\t\t\treturn createRpcSuccessResponse(id, \"export_html\", { path });\n\t\t\t}\n\n\t\t\tcase \"switch_session\": {\n\t\t\t\tconst result = await runtimeHost.switchSession(command.sessionPath);\n\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\tawait rebindSession();\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"switch_session\", result);\n\t\t\t}\n\n\t\t\tcase \"fork\": {\n\t\t\t\tconst result = await runtimeHost.fork(command.entryId);\n\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\tawait rebindSession();\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"fork\", { text: result.selectedText, cancelled: result.cancelled });\n\t\t\t}\n\n\t\t\tcase \"clone\": {\n\t\t\t\tconst leafId = session.sessionManager.getLeafId();\n\t\t\t\tif (!leafId) {\n\t\t\t\t\treturn createRpcErrorResponse(id, \"clone\", \"Cannot clone session: no current entry selected\");\n\t\t\t\t}\n\t\t\t\tconst result = await runtimeHost.fork(leafId, { position: \"at\" });\n\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\tawait rebindSession();\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"clone\", { cancelled: result.cancelled });\n\t\t\t}\n\n\t\t\tcase \"get_fork_messages\": {\n\t\t\t\tconst messages = session.getUserMessagesForForking();\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_fork_messages\", { messages });\n\t\t\t}\n\n\t\t\tcase \"get_entries\": {\n\t\t\t\tconst sessionManager = session.sessionManager;\n\t\t\t\tlet entries = sessionManager.getEntries();\n\t\t\t\tif (command.since !== undefined) {\n\t\t\t\t\tconst sinceIndex = entries.findIndex((e) => e.id === command.since);\n\t\t\t\t\tif (sinceIndex === -1) {\n\t\t\t\t\t\treturn createRpcErrorResponse(id, \"get_entries\", `Entry not found: ${command.since}`);\n\t\t\t\t\t}\n\t\t\t\t\tentries = entries.slice(sinceIndex + 1);\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_entries\", { entries, leafId: sessionManager.getLeafId() });\n\t\t\t}\n\n\t\t\tcase \"get_tree\": {\n\t\t\t\tconst sessionManager = session.sessionManager;\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_tree\", {\n\t\t\t\t\ttree: sessionManager.getTree(),\n\t\t\t\t\tleafId: sessionManager.getLeafId(),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"get_last_assistant_text\": {\n\t\t\t\tconst text = session.getLastAssistantText();\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_last_assistant_text\", { text });\n\t\t\t}\n\n\t\t\tcase \"set_session_name\": {\n\t\t\t\tconst name = command.name.trim();\n\t\t\t\tif (!name) {\n\t\t\t\t\treturn createRpcErrorResponse(id, \"set_session_name\", \"Session name cannot be empty\");\n\t\t\t\t}\n\t\t\t\tsession.setSessionName(name);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_session_name\");\n\t\t\t}\n\n\t\t\tcase \"get_messages\": {\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_messages\", { messages: session.messages });\n\t\t\t}\n\n\t\t\tcase \"get_commands\": {\n\t\t\t\tconst commands: RpcSlashCommand[] = [];\n\n\t\t\t\tfor (const registeredCommand of session.extensionRunner.getRegisteredCommands()) {\n\t\t\t\t\tcommands.push({\n\t\t\t\t\t\tname: registeredCommand.invocationName,\n\t\t\t\t\t\tdescription: registeredCommand.description,\n\t\t\t\t\t\tsource: \"extension\",\n\t\t\t\t\t\tsourceInfo: registeredCommand.sourceInfo,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfor (const template of session.promptTemplates) {\n\t\t\t\t\tcommands.push({\n\t\t\t\t\t\tname: template.name,\n\t\t\t\t\t\tdescription: template.description,\n\t\t\t\t\t\tsource: \"prompt\",\n\t\t\t\t\t\tsourceInfo: template.sourceInfo,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfor (const skill of session.resourceLoader.getSkills().skills) {\n\t\t\t\t\tcommands.push({\n\t\t\t\t\t\tname: `skill:${skill.name}`,\n\t\t\t\t\t\tdescription: skill.description,\n\t\t\t\t\t\tsource: \"skill\",\n\t\t\t\t\t\tsourceInfo: skill.sourceInfo,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_commands\", { commands });\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tconst unknownCommand = command as { type: string };\n\t\t\t\treturn createRpcErrorResponse(id, unknownCommand.type, `Unknown command: ${unknownCommand.type}`);\n\t\t\t}\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"file":"rpc-command-handler.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-command-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAKN,KAAK,SAAS,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAoC,MAAM,gBAAgB,CAAC;AAEhG,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;AAE1F,UAAU,wBAAwB;IACjC,WAAW,EAAE,mBAAmB,CAAC;IACjC,UAAU,EAAE,MAAM,YAAY,CAAC;IAC/B,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,EAAE,SAAS,CAAC;CAClB;AAED,wBAAgB,uBAAuB,CAAC,EACvC,WAAW,EACX,UAAU,EACV,aAAa,EACb,MAAM,GACN,EAAE,wBAAwB,GAAG,iBAAiB,CAqR9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-extension-ui.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-extension-ui.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,kBAAkB,EAIlB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAyB,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACjD,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/B;AAED,MAAM,MAAM,2BAA2B,GAAG,GAAG,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;AAElF,UAAU,kCAAkC;IAC3C,MAAM,EAAE,SAAS,CAAC;IAClB,wBAAwB,EAAE,2BAA2B,CAAC;CACtD;AAyDD,wBAAgB,2BAA2B,CAAC,EAC3C,MAAM,EACN,wBAAwB,GACxB,EAAE,kCAAkC,GAAG,kBAAkB,CA8LzD","sourcesContent":["import * as crypto from \"node:crypto\";\nimport type {\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tWorkingIndicatorOptions,\n} from \"../../core/extensions/index.ts\";\nimport { type Theme, theme } from \"../interactive/theme/theme.ts\";\nimport type { RpcExtensionUIRequest, RpcExtensionUIResponse } from \"./rpc-types.ts\";\nimport type { RpcOutput } from \"./rpc-responses.ts\";\n\nexport interface RpcPendingExtensionRequest {\n\tresolve: (value: RpcExtensionUIResponse) => void;\n\treject: (error: Error) => void;\n}\n\nexport type RpcPendingExtensionRequests = Map<string, RpcPendingExtensionRequest>;\n\ninterface CreateRpcExtensionUIContextOptions {\n\toutput: RpcOutput;\n\tpendingExtensionRequests: RpcPendingExtensionRequests;\n}\n\ninterface DialogPromiseOptions<T> extends CreateRpcExtensionUIContextOptions {\n\tdialogOptions: ExtensionUIDialogOptions | undefined;\n\tdefaultValue: T;\n\trequest: Record<string, unknown>;\n\tparseResponse: (response: RpcExtensionUIResponse) => T;\n}\n\nfunction createDialogPromise<T>({\n\toutput,\n\tpendingExtensionRequests,\n\tdialogOptions,\n\tdefaultValue,\n\trequest,\n\tparseResponse,\n}: DialogPromiseOptions<T>): Promise<T> {\n\tif (dialogOptions?.signal?.aborted) return Promise.resolve(defaultValue);\n\n\tconst id = crypto.randomUUID();\n\treturn new Promise((resolve, reject) => {\n\t\tlet timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n\t\tconst cleanup = () => {\n\t\t\tif (timeoutId) clearTimeout(timeoutId);\n\t\t\tdialogOptions?.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\tpendingExtensionRequests.delete(id);\n\t\t};\n\n\t\tconst onAbort = () => {\n\t\t\tcleanup();\n\t\t\tresolve(defaultValue);\n\t\t};\n\t\tdialogOptions?.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\tif (dialogOptions?.timeout) {\n\t\t\ttimeoutId = setTimeout(() => {\n\t\t\t\tcleanup();\n\t\t\t\tresolve(defaultValue);\n\t\t\t}, dialogOptions.timeout);\n\t\t}\n\n\t\tpendingExtensionRequests.set(id, {\n\t\t\tresolve: (response: RpcExtensionUIResponse) => {\n\t\t\t\tcleanup();\n\t\t\t\tresolve(parseResponse(response));\n\t\t\t},\n\t\t\treject,\n\t\t});\n\t\toutput({ type: \"extension_ui_request\", id, ...request } as RpcExtensionUIRequest);\n\t});\n}\n\nfunction emitExtensionUIRequest(output: RpcOutput, request: Record<string, unknown>): void {\n\toutput({ type: \"extension_ui_request\", id: crypto.randomUUID(), ...request } as RpcExtensionUIRequest);\n}\n\nexport function createRpcExtensionUIContext({\n\toutput,\n\tpendingExtensionRequests,\n}: CreateRpcExtensionUIContextOptions): ExtensionUIContext {\n\treturn {\n\t\tselect: (title, options, opts) =>\n\t\t\tcreateDialogPromise({\n\t\t\t\toutput,\n\t\t\t\tpendingExtensionRequests,\n\t\t\t\tdialogOptions: opts,\n\t\t\t\tdefaultValue: undefined,\n\t\t\t\trequest: { method: \"select\", title, options, timeout: opts?.timeout },\n\t\t\t\tparseResponse: (response) =>\n\t\t\t\t\t\"cancelled\" in response && response.cancelled ? undefined : \"value\" in response ? response.value : undefined,\n\t\t\t}),\n\n\t\tconfirm: (title, message, opts) =>\n\t\t\tcreateDialogPromise({\n\t\t\t\toutput,\n\t\t\t\tpendingExtensionRequests,\n\t\t\t\tdialogOptions: opts,\n\t\t\t\tdefaultValue: false,\n\t\t\t\trequest: { method: \"confirm\", title, message, timeout: opts?.timeout },\n\t\t\t\tparseResponse: (response) =>\n\t\t\t\t\t\"cancelled\" in response && response.cancelled ? false : \"confirmed\" in response ? response.confirmed : false,\n\t\t\t}),\n\n\t\tinput: (title, placeholder, opts) =>\n\t\t\tcreateDialogPromise({\n\t\t\t\toutput,\n\t\t\t\tpendingExtensionRequests,\n\t\t\t\tdialogOptions: opts,\n\t\t\t\tdefaultValue: undefined,\n\t\t\t\trequest: { method: \"input\", title, placeholder, timeout: opts?.timeout },\n\t\t\t\tparseResponse: (response) =>\n\t\t\t\t\t\"cancelled\" in response && response.cancelled ? undefined : \"value\" in response ? response.value : undefined,\n\t\t\t}),\n\n\t\tnotify(message: string, type?: \"info\" | \"warning\" | \"error\"): void {\n\t\t\temitExtensionUIRequest(output, { method: \"notify\", message, notifyType: type });\n\t\t},\n\n\t\trequestRender(): void {\n\t\t\t// RPC mode does not own a local TUI renderer.\n\t\t},\n\n\t\tonTerminalInput(): () => void {\n\t\t\t// Raw terminal input not supported in RPC mode\n\t\t\treturn () => {};\n\t\t},\n\n\t\tsetStatus(key: string, text: string | undefined): void {\n\t\t\temitExtensionUIRequest(output, { method: \"setStatus\", statusKey: key, statusText: text });\n\t\t},\n\n\t\tsetWorkingMessage(_message?: string): void {\n\t\t\t// Working message not supported in RPC mode - requires TUI loader access\n\t\t},\n\n\t\tsetWorkingVisible(_visible: boolean): void {\n\t\t\t// Working visibility not supported in RPC mode - requires TUI loader access\n\t\t},\n\n\t\tsetWorkingIndicator(_options?: WorkingIndicatorOptions): void {\n\t\t\t// Working indicator customization not supported in RPC mode - requires TUI loader access\n\t\t},\n\n\t\tsetHiddenThinkingLabel(_label?: string): void {\n\t\t\t// Hidden thinking label not supported in RPC mode - requires TUI message rendering access\n\t\t},\n\n\t\tsetWidget(key: string, content: unknown, options?: ExtensionWidgetOptions): void {\n\t\t\t// Only support string arrays in RPC mode - factory functions are ignored\n\t\t\tif (content === undefined || Array.isArray(content)) {\n\t\t\t\temitExtensionUIRequest(output, {\n\t\t\t\t\tmethod: \"setWidget\",\n\t\t\t\t\twidgetKey: key,\n\t\t\t\t\twidgetLines: content as string[] | undefined,\n\t\t\t\t\twidgetPlacement: options?.placement,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\n\t\tsetFooter(_factory: unknown): void {\n\t\t\t// Custom footer not supported in RPC mode - requires TUI access\n\t\t},\n\n\t\tsetHeader(_factory: unknown): void {\n\t\t\t// Custom header not supported in RPC mode - requires TUI access\n\t\t},\n\n\t\tsetTitle(title: string): void {\n\t\t\temitExtensionUIRequest(output, { method: \"setTitle\", title });\n\t\t},\n\n\t\tasync custom() {\n\t\t\t// Custom UI not supported in RPC mode\n\t\t\treturn undefined as never;\n\t\t},\n\n\t\tpasteToEditor(text: string): void {\n\t\t\t// Paste handling not supported in RPC mode - falls back to setEditorText\n\t\t\tthis.setEditorText(text);\n\t\t},\n\n\t\tsetEditorText(text: string): void {\n\t\t\temitExtensionUIRequest(output, { method: \"set_editor_text\", text });\n\t\t},\n\n\t\tgetEditorText(): string {\n\t\t\t// Synchronous method can't wait for RPC response; host should track editor state locally if needed.\n\t\t\treturn \"\";\n\t\t},\n\n\t\tasync editor(title: string, prefill?: string): Promise<string | undefined> {\n\t\t\tconst id = crypto.randomUUID();\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tpendingExtensionRequests.set(id, {\n\t\t\t\t\tresolve: (response: RpcExtensionUIResponse) => {\n\t\t\t\t\t\tif (\"cancelled\" in response && response.cancelled) {\n\t\t\t\t\t\t\tresolve(undefined);\n\t\t\t\t\t\t} else if (\"value\" in response) {\n\t\t\t\t\t\t\tresolve(response.value);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresolve(undefined);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\treject,\n\t\t\t\t});\n\t\t\t\toutput({ type: \"extension_ui_request\", id, method: \"editor\", title, prefill } as RpcExtensionUIRequest);\n\t\t\t});\n\t\t},\n\n\t\taddAutocompleteProvider(): void {\n\t\t\t// Autocomplete provider composition is not supported in RPC mode\n\t\t},\n\n\t\tsetEditorComponent(): void {\n\t\t\t// Custom editor components not supported in RPC mode\n\t\t},\n\n\t\tgetEditorComponent() {\n\t\t\t// Custom editor components not supported in RPC mode\n\t\t\treturn undefined;\n\t\t},\n\n\t\tgetFooterDataProvider() {\n\t\t\treturn {\n\t\t\t\tgetGitBranch: () => null,\n\t\t\t\tgetExtensionStatuses: () => new Map(),\n\t\t\t\tgetAvailableProviderCount: () => 1,\n\t\t\t\tonBranchChange: () => () => {},\n\t\t\t};\n\t\t},\n\n\t\tget theme() {\n\t\t\treturn theme;\n\t\t},\n\n\t\tgetAllThemes() {\n\t\t\treturn [];\n\t\t},\n\n\t\tgetTheme(_name: string) {\n\t\t\treturn undefined;\n\t\t},\n\n\t\tsetTheme(_theme: string | Theme) {\n\t\t\t// Theme switching not supported in RPC mode\n\t\t\treturn { success: false, error: \"Theme switching not supported in RPC mode\" };\n\t\t},\n\n\t\tgetToolsExpanded() {\n\t\t\t// Tool expansion not supported in RPC mode - no TUI\n\t\t\treturn false;\n\t\t},\n\n\t\tsetToolsExpanded(_expanded: boolean) {\n\t\t\t// Tool expansion not supported in RPC mode - no TUI\n\t\t},\n\n\t\tgetChatRenderSettings() {\n\t\t\treturn {\n\t\t\t\thideThinkingBlock: false,\n\t\t\t\thiddenThinkingLabel: \"Thinking...\",\n\t\t\t\ttoolOutputExpanded: false,\n\t\t\t\tshowImages: false,\n\t\t\t\timageWidthCells: 60,\n\t\t\t\tgetToolDefinition: () => undefined,\n\t\t\t\tgetCustomMessageRenderer: () => undefined,\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"rpc-extension-ui.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-extension-ui.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,kBAAkB,EAIlB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAyB,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACjD,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/B;AAED,MAAM,MAAM,2BAA2B,GAAG,GAAG,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;AAElF,UAAU,kCAAkC;IAC3C,MAAM,EAAE,SAAS,CAAC;IAClB,wBAAwB,EAAE,2BAA2B,CAAC;CACtD;AAyDD,wBAAgB,2BAA2B,CAAC,EAC3C,MAAM,EACN,wBAAwB,GACxB,EAAE,kCAAkC,GAAG,kBAAkB,CA8LzD"}
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-input.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-input.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAiD,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGnG,UAAU,0BAA0B;IACnC,MAAM,EAAE,SAAS,CAAC;IAClB,wBAAwB,EAAE,2BAA2B,CAAC;IACtD,aAAa,EAAE,iBAAiB,CAAC;IACjC,sBAAsB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AA2BD,wBAAgB,yBAAyB,CAAC,EACzC,MAAM,EACN,wBAAwB,EACxB,aAAa,EACb,sBAAsB,GACtB,EAAE,0BAA0B,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAkC9D","sourcesContent":["import { waitForRawStdoutBackpressure } from \"../../core/output-guard.ts\";\nimport type { RpcCommandHandler } from \"./rpc-command-handler.ts\";\nimport type { RpcPendingExtensionRequests } from \"./rpc-extension-ui.ts\";\nimport { createRpcErrorResponse, formatRpcErrorMessage, type RpcOutput } from \"./rpc-responses.ts\";\nimport type { RpcCommand, RpcExtensionUIResponse } from \"./rpc-types.ts\";\n\ninterface RpcInputLineHandlerOptions {\n\toutput: RpcOutput;\n\tpendingExtensionRequests: RpcPendingExtensionRequests;\n\thandleCommand: RpcCommandHandler;\n\tcheckShutdownRequested: () => Promise<void>;\n}\n\ninterface CommandIdentity {\n\tid: string | undefined;\n\ttype: string;\n}\n\nfunction isRpcExtensionUIResponse(value: unknown): value is RpcExtensionUIResponse {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"type\" in value &&\n\t\tvalue.type === \"extension_ui_response\" &&\n\t\t\"id\" in value &&\n\t\ttypeof value.id === \"string\"\n\t);\n}\n\nfunction getCommandIdentity(command: unknown): CommandIdentity {\n\tif (typeof command !== \"object\" || command === null) {\n\t\treturn { id: undefined, type: \"unknown\" };\n\t}\n\tconst id = \"id\" in command && typeof command.id === \"string\" ? command.id : undefined;\n\tconst type = \"type\" in command && typeof command.type === \"string\" ? command.type : \"unknown\";\n\treturn { id, type };\n}\n\nexport function createRpcInputLineHandler({\n\toutput,\n\tpendingExtensionRequests,\n\thandleCommand,\n\tcheckShutdownRequested,\n}: RpcInputLineHandlerOptions): (line: string) => Promise<void> {\n\treturn async (line: string): Promise<void> => {\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(line);\n\t\t} catch (parseError: unknown) {\n\t\t\toutput(createRpcErrorResponse(undefined, \"parse\", `Failed to parse command: ${formatRpcErrorMessage(parseError)}`));\n\t\t\tawait waitForRawStdoutBackpressure();\n\t\t\treturn;\n\t\t}\n\n\t\tif (isRpcExtensionUIResponse(parsed)) {\n\t\t\tconst pending = pendingExtensionRequests.get(parsed.id);\n\t\t\tif (pending) {\n\t\t\t\tpendingExtensionRequests.delete(parsed.id);\n\t\t\t\tpending.resolve(parsed);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst command = parsed as RpcCommand;\n\t\ttry {\n\t\t\tconst response = await handleCommand(command);\n\t\t\tif (response) {\n\t\t\t\toutput(response);\n\t\t\t\tawait waitForRawStdoutBackpressure();\n\t\t\t}\n\t\t\tawait checkShutdownRequested();\n\t\t} catch (commandError: unknown) {\n\t\t\tconst identity = getCommandIdentity(command);\n\t\t\toutput(createRpcErrorResponse(identity.id, identity.type, formatRpcErrorMessage(commandError)));\n\t\t\tawait waitForRawStdoutBackpressure();\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"file":"rpc-input.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-input.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAiD,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGnG,UAAU,0BAA0B;IACnC,MAAM,EAAE,SAAS,CAAC;IAClB,wBAAwB,EAAE,2BAA2B,CAAC;IACtD,aAAa,EAAE,iBAAiB,CAAC;IACjC,sBAAsB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AA2BD,wBAAgB,yBAAyB,CAAC,EACzC,MAAM,EACN,wBAAwB,EACxB,aAAa,EACb,sBAAsB,GACtB,EAAE,0BAA0B,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAkC9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-mode.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAW/E,YAAY,EACX,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,eAAe,GACf,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,KAAK,CAAC,CAqGjF","sourcesContent":["/**\n * RPC mode: Headless operation with JSON stdin/stdout protocol.\n *\n * Used for embedding the agent in other applications.\n * Receives commands as JSON on stdin, outputs events and responses as JSON on stdout.\n *\n * Protocol:\n * - Commands: JSON objects with `type` field, optional `id` for correlation\n * - Responses: JSON objects with `type: \"response\"`, `command`, `success`, and optional `data`/`error`\n * - Events: AgentSessionEvent objects streamed as they occur\n * - Extension UI: Extension UI requests are emitted, client responds with extension_ui_response\n */\n\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport { flushRawStdout, takeOverStdout, writeRawStdout } from \"../../core/output-guard.ts\";\nimport { killTrackedDetachedChildren } from \"../../utils/shell.ts\";\nimport { attachJsonlLineReader, serializeJsonLine } from \"./jsonl.ts\";\nimport { createRpcCommandHandler } from \"./rpc-command-handler.ts\";\nimport { createRpcInputLineHandler } from \"./rpc-input.ts\";\nimport type { RpcPendingExtensionRequests } from \"./rpc-extension-ui.ts\";\nimport type { RpcOutput } from \"./rpc-responses.ts\";\nimport { RpcSessionBinding } from \"./rpc-session-binding.ts\";\n\n// Re-export types for consumers\nexport type {\n\tRpcCommand,\n\tRpcContextWindowInfo,\n\tRpcExtensionUIRequest,\n\tRpcExtensionUIResponse,\n\tRpcResponse,\n\tRpcSessionState,\n} from \"./rpc-types.ts\";\n\n/**\n * Run in RPC mode.\n * Listens for JSON commands on stdin, outputs events and responses on stdout.\n */\nexport async function runRpcMode(runtimeHost: AgentSessionRuntime): Promise<never> {\n\ttakeOverStdout();\n\n\tconst output: RpcOutput = (obj) => {\n\t\twriteRawStdout(serializeJsonLine(obj));\n\t};\n\tconst pendingExtensionRequests: RpcPendingExtensionRequests = new Map();\n\tconst signalCleanupHandlers: Array<() => void> = [];\n\n\tlet shutdownRequested = false;\n\tlet shuttingDown = false;\n\tlet detachInput = () => {};\n\n\tconst requestShutdown = () => {\n\t\tshutdownRequested = true;\n\t};\n\n\tconst sessionBinding = new RpcSessionBinding({\n\t\truntimeHost,\n\t\toutput,\n\t\tpendingExtensionRequests,\n\t\trequestShutdown,\n\t});\n\n\truntimeHost.setRebindSession(async () => {\n\t\tawait sessionBinding.rebindSession();\n\t});\n\n\tconst handleCommand = createRpcCommandHandler({\n\t\truntimeHost,\n\t\tgetSession: () => sessionBinding.currentSession,\n\t\trebindSession: () => sessionBinding.rebindSession(),\n\t\toutput,\n\t});\n\n\tasync function shutdown(exitCode = 0, signal?: NodeJS.Signals): Promise<never> {\n\t\tif (shuttingDown) {\n\t\t\tprocess.exit(exitCode);\n\t\t}\n\t\tshuttingDown = true;\n\t\tfor (const cleanup of signalCleanupHandlers) {\n\t\t\tcleanup();\n\t\t}\n\t\tsessionBinding.disposeSubscriptions();\n\t\tawait runtimeHost.dispose();\n\t\tdetachInput();\n\t\tprocess.stdin.pause();\n\t\tif (signal !== \"SIGTERM\") {\n\t\t\tawait flushRawStdout();\n\t\t}\n\t\tprocess.exit(exitCode);\n\t}\n\n\tconst checkShutdownRequested = async (): Promise<void> => {\n\t\tif (!shutdownRequested) return;\n\t\tawait shutdown();\n\t};\n\n\tconst registerSignalHandlers = (): void => {\n\t\tconst signals: NodeJS.Signals[] = [\"SIGTERM\"];\n\t\tif (process.platform !== \"win32\") {\n\t\t\tsignals.push(\"SIGHUP\");\n\t\t}\n\n\t\tfor (const signal of signals) {\n\t\t\tconst handler = () => {\n\t\t\t\tkillTrackedDetachedChildren();\n\t\t\t\tvoid shutdown(signal === \"SIGHUP\" ? 129 : 143, signal);\n\t\t\t};\n\t\t\tprocess.on(signal, handler);\n\t\t\tsignalCleanupHandlers.push(() => process.off(signal, handler));\n\t\t}\n\t};\n\n\tawait sessionBinding.rebindSession();\n\tregisterSignalHandlers();\n\n\tconst handleInputLine = createRpcInputLineHandler({\n\t\toutput,\n\t\tpendingExtensionRequests,\n\t\thandleCommand,\n\t\tcheckShutdownRequested,\n\t});\n\n\tconst onInputEnd = () => {\n\t\tvoid shutdown();\n\t};\n\tprocess.stdin.on(\"end\", onInputEnd);\n\n\tdetachInput = (() => {\n\t\tconst detachJsonl = attachJsonlLineReader(process.stdin, (line) => {\n\t\t\tvoid handleInputLine(line);\n\t\t});\n\t\treturn () => {\n\t\t\tdetachJsonl();\n\t\t\tprocess.stdin.off(\"end\", onInputEnd);\n\t\t};\n\t})();\n\n\t// Keep process alive forever\n\treturn new Promise(() => {});\n}\n"]}
1
+ {"version":3,"file":"rpc-mode.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAW/E,YAAY,EACX,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,eAAe,GACf,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,KAAK,CAAC,CAqGjF"}
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-responses.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-responses.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErF,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,qBAAqB,GAAG,MAAM,CAAC;AAC3E,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;AAEvD,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,EACpE,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,OAAO,EAAE,CAAC,EACV,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAClB,WAAW,CAKb;AAED,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,CAE5G;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE5D;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAYpE","sourcesContent":["import { parseContextWindowValue } from \"../../core/context-window.ts\";\nimport type { RpcCommand, RpcExtensionUIRequest, RpcResponse } from \"./rpc-types.ts\";\n\nexport type RpcOutputRecord = RpcResponse | RpcExtensionUIRequest | object;\nexport type RpcOutput = (obj: RpcOutputRecord) => void;\n\nexport function createRpcSuccessResponse<T extends RpcCommand[\"type\"]>(\n\tid: string | undefined,\n\tcommand: T,\n\tdata?: object | null,\n): RpcResponse {\n\tif (data === undefined) {\n\t\treturn { id, type: \"response\", command, success: true } as RpcResponse;\n\t}\n\treturn { id, type: \"response\", command, success: true, data } as RpcResponse;\n}\n\nexport function createRpcErrorResponse(id: string | undefined, command: string, message: string): RpcResponse {\n\treturn { id, type: \"response\", command, success: false, error: message };\n}\n\nexport function formatRpcErrorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nexport function parseRpcContextWindow(value: number | string): number {\n\tif (typeof value === \"number\") {\n\t\treturn value;\n\t}\n\tif (typeof value === \"string\") {\n\t\tconst parsed = parseContextWindowValue(value);\n\t\tif (parsed.value !== undefined) {\n\t\t\treturn parsed.value;\n\t\t}\n\t\tthrow new Error(parsed.error ?? \"Invalid context window\");\n\t}\n\tthrow new Error(\"Context window must be a number of tokens or a compact value like 400k or 1m\");\n}\n"]}
1
+ {"version":3,"file":"rpc-responses.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-responses.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErF,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,qBAAqB,GAAG,MAAM,CAAC;AAC3E,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;AAEvD,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,EACpE,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,OAAO,EAAE,CAAC,EACV,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAClB,WAAW,CAKb;AAED,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,CAE5G;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE5D;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAYpE"}