orquesta-cli 0.1.12

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 (851) hide show
  1. package/.eslintrc.json +26 -0
  2. package/.prettierrc.json +10 -0
  3. package/CLAUDE.md +199 -0
  4. package/LICENSE +21 -0
  5. package/README.md +280 -0
  6. package/SECURITY.md +290 -0
  7. package/TEST_LOCAL.md +245 -0
  8. package/dist/agents/base/base-agent.d.ts +38 -0
  9. package/dist/agents/base/base-agent.d.ts.map +1 -0
  10. package/dist/agents/base/base-agent.js +69 -0
  11. package/dist/agents/base/base-agent.js.map +1 -0
  12. package/dist/agents/docs-search/index.d.ts +33 -0
  13. package/dist/agents/docs-search/index.d.ts.map +1 -0
  14. package/dist/agents/docs-search/index.js +244 -0
  15. package/dist/agents/docs-search/index.js.map +1 -0
  16. package/dist/agents/index.d.ts +4 -0
  17. package/dist/agents/index.d.ts.map +1 -0
  18. package/dist/agents/index.js +4 -0
  19. package/dist/agents/index.js.map +1 -0
  20. package/dist/agents/planner/index.d.ts +17 -0
  21. package/dist/agents/planner/index.d.ts.map +1 -0
  22. package/dist/agents/planner/index.js +250 -0
  23. package/dist/agents/planner/index.js.map +1 -0
  24. package/dist/cli.d.ts +3 -0
  25. package/dist/cli.d.ts.map +1 -0
  26. package/dist/cli.js +144 -0
  27. package/dist/cli.js.map +1 -0
  28. package/dist/constants.d.ts +8 -0
  29. package/dist/constants.d.ts.map +1 -0
  30. package/dist/constants.js +10 -0
  31. package/dist/constants.js.map +1 -0
  32. package/dist/core/compact/compact-manager.d.ts +22 -0
  33. package/dist/core/compact/compact-manager.d.ts.map +1 -0
  34. package/dist/core/compact/compact-manager.js +75 -0
  35. package/dist/core/compact/compact-manager.js.map +1 -0
  36. package/dist/core/compact/compact-prompts.d.ts +11 -0
  37. package/dist/core/compact/compact-prompts.d.ts.map +1 -0
  38. package/dist/core/compact/compact-prompts.js +90 -0
  39. package/dist/core/compact/compact-prompts.js.map +1 -0
  40. package/dist/core/compact/context-tracker.d.ts +28 -0
  41. package/dist/core/compact/context-tracker.d.ts.map +1 -0
  42. package/dist/core/compact/context-tracker.js +71 -0
  43. package/dist/core/compact/context-tracker.js.map +1 -0
  44. package/dist/core/compact/index.d.ts +4 -0
  45. package/dist/core/compact/index.d.ts.map +1 -0
  46. package/dist/core/compact/index.js +4 -0
  47. package/dist/core/compact/index.js.map +1 -0
  48. package/dist/core/config/config-manager.d.ts +44 -0
  49. package/dist/core/config/config-manager.d.ts.map +1 -0
  50. package/dist/core/config/config-manager.js +259 -0
  51. package/dist/core/config/config-manager.js.map +1 -0
  52. package/dist/core/config/index.d.ts +2 -0
  53. package/dist/core/config/index.d.ts.map +1 -0
  54. package/dist/core/config/index.js +2 -0
  55. package/dist/core/config/index.js.map +1 -0
  56. package/dist/core/docs-manager.d.ts +46 -0
  57. package/dist/core/docs-manager.d.ts.map +1 -0
  58. package/dist/core/docs-manager.js +475 -0
  59. package/dist/core/docs-manager.js.map +1 -0
  60. package/dist/core/git-auto-updater.d.ts +58 -0
  61. package/dist/core/git-auto-updater.d.ts.map +1 -0
  62. package/dist/core/git-auto-updater.js +374 -0
  63. package/dist/core/git-auto-updater.js.map +1 -0
  64. package/dist/core/llm/index.d.ts +2 -0
  65. package/dist/core/llm/index.d.ts.map +1 -0
  66. package/dist/core/llm/index.js +2 -0
  67. package/dist/core/llm/index.js.map +1 -0
  68. package/dist/core/llm/llm-client.d.ts +97 -0
  69. package/dist/core/llm/llm-client.d.ts.map +1 -0
  70. package/dist/core/llm/llm-client.js +1000 -0
  71. package/dist/core/llm/llm-client.js.map +1 -0
  72. package/dist/core/session/index.d.ts +2 -0
  73. package/dist/core/session/index.d.ts.map +1 -0
  74. package/dist/core/session/index.js +2 -0
  75. package/dist/core/session/index.js.map +1 -0
  76. package/dist/core/session/session-manager.d.ts +71 -0
  77. package/dist/core/session/session-manager.d.ts.map +1 -0
  78. package/dist/core/session/session-manager.js +250 -0
  79. package/dist/core/session/session-manager.js.map +1 -0
  80. package/dist/core/slash-command-handler.d.ts +31 -0
  81. package/dist/core/slash-command-handler.d.ts.map +1 -0
  82. package/dist/core/slash-command-handler.js +302 -0
  83. package/dist/core/slash-command-handler.js.map +1 -0
  84. package/dist/core/usage-tracker.d.ts +70 -0
  85. package/dist/core/usage-tracker.d.ts.map +1 -0
  86. package/dist/core/usage-tracker.js +251 -0
  87. package/dist/core/usage-tracker.js.map +1 -0
  88. package/dist/errors/base.d.ts +22 -0
  89. package/dist/errors/base.d.ts.map +1 -0
  90. package/dist/errors/base.js +43 -0
  91. package/dist/errors/base.js.map +1 -0
  92. package/dist/errors/file.d.ts +31 -0
  93. package/dist/errors/file.d.ts.map +1 -0
  94. package/dist/errors/file.js +110 -0
  95. package/dist/errors/file.js.map +1 -0
  96. package/dist/errors/index.d.ts +10 -0
  97. package/dist/errors/index.d.ts.map +1 -0
  98. package/dist/errors/index.js +41 -0
  99. package/dist/errors/index.js.map +1 -0
  100. package/dist/errors/llm.d.ts +26 -0
  101. package/dist/errors/llm.d.ts.map +1 -0
  102. package/dist/errors/llm.js +86 -0
  103. package/dist/errors/llm.js.map +1 -0
  104. package/dist/errors/network.d.ts +19 -0
  105. package/dist/errors/network.d.ts.map +1 -0
  106. package/dist/errors/network.js +82 -0
  107. package/dist/errors/network.js.map +1 -0
  108. package/dist/errors/validation.d.ts +19 -0
  109. package/dist/errors/validation.d.ts.map +1 -0
  110. package/dist/errors/validation.js +62 -0
  111. package/dist/errors/validation.js.map +1 -0
  112. package/dist/eval/eval-runner.d.ts +24 -0
  113. package/dist/eval/eval-runner.d.ts.map +1 -0
  114. package/dist/eval/eval-runner.js +309 -0
  115. package/dist/eval/eval-runner.js.map +1 -0
  116. package/dist/eval/index.d.ts +3 -0
  117. package/dist/eval/index.d.ts.map +1 -0
  118. package/dist/eval/index.js +3 -0
  119. package/dist/eval/index.js.map +1 -0
  120. package/dist/eval/types.d.ts +77 -0
  121. package/dist/eval/types.d.ts.map +1 -0
  122. package/dist/eval/types.js +2 -0
  123. package/dist/eval/types.js.map +1 -0
  124. package/dist/index.d.ts +4 -0
  125. package/dist/index.d.ts.map +1 -0
  126. package/dist/index.js +6 -0
  127. package/dist/index.js.map +1 -0
  128. package/dist/orchestration/index.d.ts +4 -0
  129. package/dist/orchestration/index.d.ts.map +1 -0
  130. package/dist/orchestration/index.js +3 -0
  131. package/dist/orchestration/index.js.map +1 -0
  132. package/dist/orchestration/plan-executor.d.ts +28 -0
  133. package/dist/orchestration/plan-executor.d.ts.map +1 -0
  134. package/dist/orchestration/plan-executor.js +382 -0
  135. package/dist/orchestration/plan-executor.js.map +1 -0
  136. package/dist/orchestration/types.d.ts +66 -0
  137. package/dist/orchestration/types.d.ts.map +1 -0
  138. package/dist/orchestration/types.js +2 -0
  139. package/dist/orchestration/types.js.map +1 -0
  140. package/dist/orchestration/utils.d.ts +13 -0
  141. package/dist/orchestration/utils.d.ts.map +1 -0
  142. package/dist/orchestration/utils.js +78 -0
  143. package/dist/orchestration/utils.js.map +1 -0
  144. package/dist/orquesta/connection.d.ts +35 -0
  145. package/dist/orquesta/connection.d.ts.map +1 -0
  146. package/dist/orquesta/connection.js +189 -0
  147. package/dist/orquesta/connection.js.map +1 -0
  148. package/dist/prompts/agents/docs-search-decision.d.ts +6 -0
  149. package/dist/prompts/agents/docs-search-decision.d.ts.map +1 -0
  150. package/dist/prompts/agents/docs-search-decision.js +46 -0
  151. package/dist/prompts/agents/docs-search-decision.js.map +1 -0
  152. package/dist/prompts/agents/docs-search.d.ts +4 -0
  153. package/dist/prompts/agents/docs-search.d.ts.map +1 -0
  154. package/dist/prompts/agents/docs-search.js +70 -0
  155. package/dist/prompts/agents/docs-search.js.map +1 -0
  156. package/dist/prompts/agents/planning.d.ts +4 -0
  157. package/dist/prompts/agents/planning.d.ts.map +1 -0
  158. package/dist/prompts/agents/planning.js +119 -0
  159. package/dist/prompts/agents/planning.js.map +1 -0
  160. package/dist/prompts/index.d.ts +10 -0
  161. package/dist/prompts/index.d.ts.map +1 -0
  162. package/dist/prompts/index.js +10 -0
  163. package/dist/prompts/index.js.map +1 -0
  164. package/dist/prompts/shared/codebase-rules.d.ts +4 -0
  165. package/dist/prompts/shared/codebase-rules.d.ts.map +1 -0
  166. package/dist/prompts/shared/codebase-rules.js +16 -0
  167. package/dist/prompts/shared/codebase-rules.js.map +1 -0
  168. package/dist/prompts/shared/git-rules.d.ts +2 -0
  169. package/dist/prompts/shared/git-rules.d.ts.map +1 -0
  170. package/dist/prompts/shared/git-rules.js +87 -0
  171. package/dist/prompts/shared/git-rules.js.map +1 -0
  172. package/dist/prompts/shared/language-rules.d.ts +4 -0
  173. package/dist/prompts/shared/language-rules.d.ts.map +1 -0
  174. package/dist/prompts/shared/language-rules.js +22 -0
  175. package/dist/prompts/shared/language-rules.js.map +1 -0
  176. package/dist/prompts/shared/tool-usage.d.ts +12 -0
  177. package/dist/prompts/shared/tool-usage.d.ts.map +1 -0
  178. package/dist/prompts/shared/tool-usage.js +51 -0
  179. package/dist/prompts/shared/tool-usage.js.map +1 -0
  180. package/dist/prompts/system/compact.d.ts +3 -0
  181. package/dist/prompts/system/compact.d.ts.map +1 -0
  182. package/dist/prompts/system/compact.js +73 -0
  183. package/dist/prompts/system/compact.js.map +1 -0
  184. package/dist/prompts/system/plan-execute.d.ts +3 -0
  185. package/dist/prompts/system/plan-execute.d.ts.map +1 -0
  186. package/dist/prompts/system/plan-execute.js +83 -0
  187. package/dist/prompts/system/plan-execute.js.map +1 -0
  188. package/dist/tools/browser/browser-client.d.ts +107 -0
  189. package/dist/tools/browser/browser-client.d.ts.map +1 -0
  190. package/dist/tools/browser/browser-client.js +958 -0
  191. package/dist/tools/browser/browser-client.js.map +1 -0
  192. package/dist/tools/browser/browser-tools.d.ts +17 -0
  193. package/dist/tools/browser/browser-tools.d.ts.map +1 -0
  194. package/dist/tools/browser/browser-tools.js +972 -0
  195. package/dist/tools/browser/browser-tools.js.map +1 -0
  196. package/dist/tools/browser/index.d.ts +7 -0
  197. package/dist/tools/browser/index.d.ts.map +1 -0
  198. package/dist/tools/browser/index.js +17 -0
  199. package/dist/tools/browser/index.js.map +1 -0
  200. package/dist/tools/index.d.ts +4 -0
  201. package/dist/tools/index.d.ts.map +1 -0
  202. package/dist/tools/index.js +4 -0
  203. package/dist/tools/index.js.map +1 -0
  204. package/dist/tools/llm/agents/docs-search-tools.d.ts +17 -0
  205. package/dist/tools/llm/agents/docs-search-tools.d.ts.map +1 -0
  206. package/dist/tools/llm/agents/docs-search-tools.js +265 -0
  207. package/dist/tools/llm/agents/docs-search-tools.js.map +1 -0
  208. package/dist/tools/llm/agents/index.d.ts +4 -0
  209. package/dist/tools/llm/agents/index.d.ts.map +1 -0
  210. package/dist/tools/llm/agents/index.js +3 -0
  211. package/dist/tools/llm/agents/index.js.map +1 -0
  212. package/dist/tools/llm/index.d.ts +3 -0
  213. package/dist/tools/llm/index.d.ts.map +1 -0
  214. package/dist/tools/llm/index.js +3 -0
  215. package/dist/tools/llm/index.js.map +1 -0
  216. package/dist/tools/llm/simple/ask-user-tool.d.ts +5 -0
  217. package/dist/tools/llm/simple/ask-user-tool.d.ts.map +1 -0
  218. package/dist/tools/llm/simple/ask-user-tool.js +7 -0
  219. package/dist/tools/llm/simple/ask-user-tool.js.map +1 -0
  220. package/dist/tools/llm/simple/background-bash-tool.d.ts +30 -0
  221. package/dist/tools/llm/simple/background-bash-tool.d.ts.map +1 -0
  222. package/dist/tools/llm/simple/background-bash-tool.js +323 -0
  223. package/dist/tools/llm/simple/background-bash-tool.js.map +1 -0
  224. package/dist/tools/llm/simple/background-powershell-tool.d.ts +30 -0
  225. package/dist/tools/llm/simple/background-powershell-tool.d.ts.map +1 -0
  226. package/dist/tools/llm/simple/background-powershell-tool.js +305 -0
  227. package/dist/tools/llm/simple/background-powershell-tool.js.map +1 -0
  228. package/dist/tools/llm/simple/bash-tool.d.ts +4 -0
  229. package/dist/tools/llm/simple/bash-tool.d.ts.map +1 -0
  230. package/dist/tools/llm/simple/bash-tool.js +178 -0
  231. package/dist/tools/llm/simple/bash-tool.js.map +1 -0
  232. package/dist/tools/llm/simple/docs-search-agent-tool.d.ts +6 -0
  233. package/dist/tools/llm/simple/docs-search-agent-tool.d.ts.map +1 -0
  234. package/dist/tools/llm/simple/docs-search-agent-tool.js +104 -0
  235. package/dist/tools/llm/simple/docs-search-agent-tool.js.map +1 -0
  236. package/dist/tools/llm/simple/file-tools.d.ts +13 -0
  237. package/dist/tools/llm/simple/file-tools.d.ts.map +1 -0
  238. package/dist/tools/llm/simple/file-tools.js +785 -0
  239. package/dist/tools/llm/simple/file-tools.js.map +1 -0
  240. package/dist/tools/llm/simple/final-response-tool.d.ts +12 -0
  241. package/dist/tools/llm/simple/final-response-tool.d.ts.map +1 -0
  242. package/dist/tools/llm/simple/final-response-tool.js +107 -0
  243. package/dist/tools/llm/simple/final-response-tool.js.map +1 -0
  244. package/dist/tools/llm/simple/index.d.ts +11 -0
  245. package/dist/tools/llm/simple/index.d.ts.map +1 -0
  246. package/dist/tools/llm/simple/index.js +20 -0
  247. package/dist/tools/llm/simple/index.js.map +1 -0
  248. package/dist/tools/llm/simple/planning-tools.d.ts +5 -0
  249. package/dist/tools/llm/simple/planning-tools.d.ts.map +1 -0
  250. package/dist/tools/llm/simple/planning-tools.js +117 -0
  251. package/dist/tools/llm/simple/planning-tools.js.map +1 -0
  252. package/dist/tools/llm/simple/powershell-tool.d.ts +4 -0
  253. package/dist/tools/llm/simple/powershell-tool.d.ts.map +1 -0
  254. package/dist/tools/llm/simple/powershell-tool.js +178 -0
  255. package/dist/tools/llm/simple/powershell-tool.js.map +1 -0
  256. package/dist/tools/llm/simple/simple-tool-executor.d.ts +38 -0
  257. package/dist/tools/llm/simple/simple-tool-executor.d.ts.map +1 -0
  258. package/dist/tools/llm/simple/simple-tool-executor.js +134 -0
  259. package/dist/tools/llm/simple/simple-tool-executor.js.map +1 -0
  260. package/dist/tools/llm/simple/todo-tools.d.ts +15 -0
  261. package/dist/tools/llm/simple/todo-tools.d.ts.map +1 -0
  262. package/dist/tools/llm/simple/todo-tools.js +145 -0
  263. package/dist/tools/llm/simple/todo-tools.js.map +1 -0
  264. package/dist/tools/llm/simple/user-interaction-tools.d.ts +22 -0
  265. package/dist/tools/llm/simple/user-interaction-tools.d.ts.map +1 -0
  266. package/dist/tools/llm/simple/user-interaction-tools.js +168 -0
  267. package/dist/tools/llm/simple/user-interaction-tools.js.map +1 -0
  268. package/dist/tools/office/common/constants.d.ts +194 -0
  269. package/dist/tools/office/common/constants.d.ts.map +1 -0
  270. package/dist/tools/office/common/constants.js +169 -0
  271. package/dist/tools/office/common/constants.js.map +1 -0
  272. package/dist/tools/office/common/index.d.ts +4 -0
  273. package/dist/tools/office/common/index.d.ts.map +1 -0
  274. package/dist/tools/office/common/index.js +3 -0
  275. package/dist/tools/office/common/index.js.map +1 -0
  276. package/dist/tools/office/common/types.d.ts +82 -0
  277. package/dist/tools/office/common/types.d.ts.map +1 -0
  278. package/dist/tools/office/common/types.js +2 -0
  279. package/dist/tools/office/common/types.js.map +1 -0
  280. package/dist/tools/office/common/utils.d.ts +14 -0
  281. package/dist/tools/office/common/utils.d.ts.map +1 -0
  282. package/dist/tools/office/common/utils.js +58 -0
  283. package/dist/tools/office/common/utils.js.map +1 -0
  284. package/dist/tools/office/excel-client.d.ts +123 -0
  285. package/dist/tools/office/excel-client.d.ts.map +1 -0
  286. package/dist/tools/office/excel-client.js +1037 -0
  287. package/dist/tools/office/excel-client.js.map +1 -0
  288. package/dist/tools/office/excel-tools/cells.d.ts +10 -0
  289. package/dist/tools/office/excel-tools/cells.d.ts.map +1 -0
  290. package/dist/tools/office/excel-tools/cells.js +279 -0
  291. package/dist/tools/office/excel-tools/cells.js.map +1 -0
  292. package/dist/tools/office/excel-tools/charts.d.ts +6 -0
  293. package/dist/tools/office/excel-tools/charts.d.ts.map +1 -0
  294. package/dist/tools/office/excel-tools/charts.js +124 -0
  295. package/dist/tools/office/excel-tools/charts.js.map +1 -0
  296. package/dist/tools/office/excel-tools/comments.d.ts +6 -0
  297. package/dist/tools/office/excel-tools/comments.d.ts.map +1 -0
  298. package/dist/tools/office/excel-tools/comments.js +114 -0
  299. package/dist/tools/office/excel-tools/comments.js.map +1 -0
  300. package/dist/tools/office/excel-tools/data-ops.d.ts +10 -0
  301. package/dist/tools/office/excel-tools/data-ops.d.ts.map +1 -0
  302. package/dist/tools/office/excel-tools/data-ops.js +266 -0
  303. package/dist/tools/office/excel-tools/data-ops.js.map +1 -0
  304. package/dist/tools/office/excel-tools/export.d.ts +5 -0
  305. package/dist/tools/office/excel-tools/export.d.ts.map +1 -0
  306. package/dist/tools/office/excel-tools/export.js +75 -0
  307. package/dist/tools/office/excel-tools/export.js.map +1 -0
  308. package/dist/tools/office/excel-tools/formatting.d.ts +10 -0
  309. package/dist/tools/office/excel-tools/formatting.d.ts.map +1 -0
  310. package/dist/tools/office/excel-tools/formatting.js +276 -0
  311. package/dist/tools/office/excel-tools/formatting.js.map +1 -0
  312. package/dist/tools/office/excel-tools/index.d.ts +16 -0
  313. package/dist/tools/office/excel-tools/index.d.ts.map +1 -0
  314. package/dist/tools/office/excel-tools/index.js +42 -0
  315. package/dist/tools/office/excel-tools/index.js.map +1 -0
  316. package/dist/tools/office/excel-tools/launch.d.ts +10 -0
  317. package/dist/tools/office/excel-tools/launch.d.ts.map +1 -0
  318. package/dist/tools/office/excel-tools/launch.js +248 -0
  319. package/dist/tools/office/excel-tools/launch.js.map +1 -0
  320. package/dist/tools/office/excel-tools/media.d.ts +5 -0
  321. package/dist/tools/office/excel-tools/media.d.ts.map +1 -0
  322. package/dist/tools/office/excel-tools/media.js +84 -0
  323. package/dist/tools/office/excel-tools/media.js.map +1 -0
  324. package/dist/tools/office/excel-tools/named-ranges.d.ts +6 -0
  325. package/dist/tools/office/excel-tools/named-ranges.d.ts.map +1 -0
  326. package/dist/tools/office/excel-tools/named-ranges.js +113 -0
  327. package/dist/tools/office/excel-tools/named-ranges.js.map +1 -0
  328. package/dist/tools/office/excel-tools/protection.d.ts +5 -0
  329. package/dist/tools/office/excel-tools/protection.d.ts.map +1 -0
  330. package/dist/tools/office/excel-tools/protection.js +75 -0
  331. package/dist/tools/office/excel-tools/protection.js.map +1 -0
  332. package/dist/tools/office/excel-tools/rows-columns.d.ts +11 -0
  333. package/dist/tools/office/excel-tools/rows-columns.d.ts.map +1 -0
  334. package/dist/tools/office/excel-tools/rows-columns.js +293 -0
  335. package/dist/tools/office/excel-tools/rows-columns.js.map +1 -0
  336. package/dist/tools/office/excel-tools/sheets.d.ts +8 -0
  337. package/dist/tools/office/excel-tools/sheets.d.ts.map +1 -0
  338. package/dist/tools/office/excel-tools/sheets.js +177 -0
  339. package/dist/tools/office/excel-tools/sheets.js.map +1 -0
  340. package/dist/tools/office/excel-tools/validation.d.ts +7 -0
  341. package/dist/tools/office/excel-tools/validation.d.ts.map +1 -0
  342. package/dist/tools/office/excel-tools/validation.js +175 -0
  343. package/dist/tools/office/excel-tools/validation.js.map +1 -0
  344. package/dist/tools/office/excel-tools.d.ts +3 -0
  345. package/dist/tools/office/excel-tools.d.ts.map +1 -0
  346. package/dist/tools/office/excel-tools.js +3 -0
  347. package/dist/tools/office/excel-tools.js.map +1 -0
  348. package/dist/tools/office/index.d.ts +6 -0
  349. package/dist/tools/office/index.d.ts.map +1 -0
  350. package/dist/tools/office/index.js +9 -0
  351. package/dist/tools/office/index.js.map +1 -0
  352. package/dist/tools/office/office-client-base.d.ts +31 -0
  353. package/dist/tools/office/office-client-base.d.ts.map +1 -0
  354. package/dist/tools/office/office-client-base.js +154 -0
  355. package/dist/tools/office/office-client-base.js.map +1 -0
  356. package/dist/tools/office/office-client.d.ts +196 -0
  357. package/dist/tools/office/office-client.d.ts.map +1 -0
  358. package/dist/tools/office/office-client.js +200 -0
  359. package/dist/tools/office/office-client.js.map +1 -0
  360. package/dist/tools/office/powerpoint-client.d.ts +135 -0
  361. package/dist/tools/office/powerpoint-client.d.ts.map +1 -0
  362. package/dist/tools/office/powerpoint-client.js +1136 -0
  363. package/dist/tools/office/powerpoint-client.js.map +1 -0
  364. package/dist/tools/office/powerpoint-tools/effects.d.ts +9 -0
  365. package/dist/tools/office/powerpoint-tools/effects.d.ts.map +1 -0
  366. package/dist/tools/office/powerpoint-tools/effects.js +246 -0
  367. package/dist/tools/office/powerpoint-tools/effects.js.map +1 -0
  368. package/dist/tools/office/powerpoint-tools/export.d.ts +6 -0
  369. package/dist/tools/office/powerpoint-tools/export.d.ts.map +1 -0
  370. package/dist/tools/office/powerpoint-tools/export.js +108 -0
  371. package/dist/tools/office/powerpoint-tools/export.js.map +1 -0
  372. package/dist/tools/office/powerpoint-tools/index.d.ts +13 -0
  373. package/dist/tools/office/powerpoint-tools/index.d.ts.map +1 -0
  374. package/dist/tools/office/powerpoint-tools/index.js +33 -0
  375. package/dist/tools/office/powerpoint-tools/index.js.map +1 -0
  376. package/dist/tools/office/powerpoint-tools/launch.d.ts +9 -0
  377. package/dist/tools/office/powerpoint-tools/launch.d.ts.map +1 -0
  378. package/dist/tools/office/powerpoint-tools/launch.js +214 -0
  379. package/dist/tools/office/powerpoint-tools/launch.js.map +1 -0
  380. package/dist/tools/office/powerpoint-tools/media.d.ts +8 -0
  381. package/dist/tools/office/powerpoint-tools/media.d.ts.map +1 -0
  382. package/dist/tools/office/powerpoint-tools/media.js +211 -0
  383. package/dist/tools/office/powerpoint-tools/media.js.map +1 -0
  384. package/dist/tools/office/powerpoint-tools/notes.d.ts +8 -0
  385. package/dist/tools/office/powerpoint-tools/notes.d.ts.map +1 -0
  386. package/dist/tools/office/powerpoint-tools/notes.js +171 -0
  387. package/dist/tools/office/powerpoint-tools/notes.js.map +1 -0
  388. package/dist/tools/office/powerpoint-tools/sections.d.ts +6 -0
  389. package/dist/tools/office/powerpoint-tools/sections.d.ts.map +1 -0
  390. package/dist/tools/office/powerpoint-tools/sections.js +104 -0
  391. package/dist/tools/office/powerpoint-tools/sections.js.map +1 -0
  392. package/dist/tools/office/powerpoint-tools/shapes.d.ts +22 -0
  393. package/dist/tools/office/powerpoint-tools/shapes.d.ts.map +1 -0
  394. package/dist/tools/office/powerpoint-tools/shapes.js +681 -0
  395. package/dist/tools/office/powerpoint-tools/shapes.js.map +1 -0
  396. package/dist/tools/office/powerpoint-tools/slides.d.ts +11 -0
  397. package/dist/tools/office/powerpoint-tools/slides.d.ts.map +1 -0
  398. package/dist/tools/office/powerpoint-tools/slides.js +283 -0
  399. package/dist/tools/office/powerpoint-tools/slides.js.map +1 -0
  400. package/dist/tools/office/powerpoint-tools/tables.d.ts +6 -0
  401. package/dist/tools/office/powerpoint-tools/tables.d.ts.map +1 -0
  402. package/dist/tools/office/powerpoint-tools/tables.js +132 -0
  403. package/dist/tools/office/powerpoint-tools/tables.js.map +1 -0
  404. package/dist/tools/office/powerpoint-tools/text.d.ts +12 -0
  405. package/dist/tools/office/powerpoint-tools/text.d.ts.map +1 -0
  406. package/dist/tools/office/powerpoint-tools/text.js +366 -0
  407. package/dist/tools/office/powerpoint-tools/text.js.map +1 -0
  408. package/dist/tools/office/powerpoint-tools.d.ts +3 -0
  409. package/dist/tools/office/powerpoint-tools.d.ts.map +1 -0
  410. package/dist/tools/office/powerpoint-tools.js +3 -0
  411. package/dist/tools/office/powerpoint-tools.js.map +1 -0
  412. package/dist/tools/office/word-client.d.ts +147 -0
  413. package/dist/tools/office/word-client.d.ts.map +1 -0
  414. package/dist/tools/office/word-client.js +1341 -0
  415. package/dist/tools/office/word-client.js.map +1 -0
  416. package/dist/tools/office/word-tools/bookmarks.d.ts +7 -0
  417. package/dist/tools/office/word-tools/bookmarks.d.ts.map +1 -0
  418. package/dist/tools/office/word-tools/bookmarks.js +146 -0
  419. package/dist/tools/office/word-tools/bookmarks.js.map +1 -0
  420. package/dist/tools/office/word-tools/comments.d.ts +7 -0
  421. package/dist/tools/office/word-tools/comments.d.ts.map +1 -0
  422. package/dist/tools/office/word-tools/comments.js +146 -0
  423. package/dist/tools/office/word-tools/comments.js.map +1 -0
  424. package/dist/tools/office/word-tools/content.d.ts +7 -0
  425. package/dist/tools/office/word-tools/content.d.ts.map +1 -0
  426. package/dist/tools/office/word-tools/content.js +168 -0
  427. package/dist/tools/office/word-tools/content.js.map +1 -0
  428. package/dist/tools/office/word-tools/export.d.ts +5 -0
  429. package/dist/tools/office/word-tools/export.d.ts.map +1 -0
  430. package/dist/tools/office/word-tools/export.js +73 -0
  431. package/dist/tools/office/word-tools/export.js.map +1 -0
  432. package/dist/tools/office/word-tools/formatting.d.ts +6 -0
  433. package/dist/tools/office/word-tools/formatting.d.ts.map +1 -0
  434. package/dist/tools/office/word-tools/formatting.js +129 -0
  435. package/dist/tools/office/word-tools/formatting.js.map +1 -0
  436. package/dist/tools/office/word-tools/headers-footers.d.ts +6 -0
  437. package/dist/tools/office/word-tools/headers-footers.d.ts.map +1 -0
  438. package/dist/tools/office/word-tools/headers-footers.js +117 -0
  439. package/dist/tools/office/word-tools/headers-footers.js.map +1 -0
  440. package/dist/tools/office/word-tools/index.d.ts +16 -0
  441. package/dist/tools/office/word-tools/index.d.ts.map +1 -0
  442. package/dist/tools/office/word-tools/index.js +45 -0
  443. package/dist/tools/office/word-tools/index.js.map +1 -0
  444. package/dist/tools/office/word-tools/launch.d.ts +10 -0
  445. package/dist/tools/office/word-tools/launch.d.ts.map +1 -0
  446. package/dist/tools/office/word-tools/launch.js +255 -0
  447. package/dist/tools/office/word-tools/launch.js.map +1 -0
  448. package/dist/tools/office/word-tools/lists.d.ts +5 -0
  449. package/dist/tools/office/word-tools/lists.d.ts.map +1 -0
  450. package/dist/tools/office/word-tools/lists.js +73 -0
  451. package/dist/tools/office/word-tools/lists.js.map +1 -0
  452. package/dist/tools/office/word-tools/navigation.d.ts +5 -0
  453. package/dist/tools/office/word-tools/navigation.d.ts.map +1 -0
  454. package/dist/tools/office/word-tools/navigation.js +85 -0
  455. package/dist/tools/office/word-tools/navigation.js.map +1 -0
  456. package/dist/tools/office/word-tools/page-setup.d.ts +7 -0
  457. package/dist/tools/office/word-tools/page-setup.d.ts.map +1 -0
  458. package/dist/tools/office/word-tools/page-setup.js +152 -0
  459. package/dist/tools/office/word-tools/page-setup.js.map +1 -0
  460. package/dist/tools/office/word-tools/tables.d.ts +8 -0
  461. package/dist/tools/office/word-tools/tables.d.ts.map +1 -0
  462. package/dist/tools/office/word-tools/tables.js +197 -0
  463. package/dist/tools/office/word-tools/tables.js.map +1 -0
  464. package/dist/tools/office/word-tools/text.d.ts +9 -0
  465. package/dist/tools/office/word-tools/text.d.ts.map +1 -0
  466. package/dist/tools/office/word-tools/text.js +235 -0
  467. package/dist/tools/office/word-tools/text.js.map +1 -0
  468. package/dist/tools/office/word-tools/undo-redo.d.ts +5 -0
  469. package/dist/tools/office/word-tools/undo-redo.d.ts.map +1 -0
  470. package/dist/tools/office/word-tools/undo-redo.js +73 -0
  471. package/dist/tools/office/word-tools/undo-redo.js.map +1 -0
  472. package/dist/tools/office/word-tools/watermarks.d.ts +5 -0
  473. package/dist/tools/office/word-tools/watermarks.d.ts.map +1 -0
  474. package/dist/tools/office/word-tools/watermarks.js +81 -0
  475. package/dist/tools/office/word-tools/watermarks.js.map +1 -0
  476. package/dist/tools/office/word-tools.d.ts +3 -0
  477. package/dist/tools/office/word-tools.d.ts.map +1 -0
  478. package/dist/tools/office/word-tools.js +3 -0
  479. package/dist/tools/office/word-tools.js.map +1 -0
  480. package/dist/tools/registry.d.ts +53 -0
  481. package/dist/tools/registry.d.ts.map +1 -0
  482. package/dist/tools/registry.js +278 -0
  483. package/dist/tools/registry.js.map +1 -0
  484. package/dist/tools/types.d.ts +88 -0
  485. package/dist/tools/types.d.ts.map +1 -0
  486. package/dist/tools/types.js +19 -0
  487. package/dist/tools/types.js.map +1 -0
  488. package/dist/types/index.d.ts +126 -0
  489. package/dist/types/index.d.ts.map +1 -0
  490. package/dist/types/index.js +2 -0
  491. package/dist/types/index.js.map +1 -0
  492. package/dist/ui/PlanExecuteView.d.ts +11 -0
  493. package/dist/ui/PlanExecuteView.d.ts.map +1 -0
  494. package/dist/ui/PlanExecuteView.js +29 -0
  495. package/dist/ui/PlanExecuteView.js.map +1 -0
  496. package/dist/ui/TodoPanel.d.ts +13 -0
  497. package/dist/ui/TodoPanel.d.ts.map +1 -0
  498. package/dist/ui/TodoPanel.js +135 -0
  499. package/dist/ui/TodoPanel.js.map +1 -0
  500. package/dist/ui/UpdateNotification.d.ts +13 -0
  501. package/dist/ui/UpdateNotification.d.ts.map +1 -0
  502. package/dist/ui/UpdateNotification.js +42 -0
  503. package/dist/ui/UpdateNotification.js.map +1 -0
  504. package/dist/ui/components/ActivityIndicator.d.ts +25 -0
  505. package/dist/ui/components/ActivityIndicator.d.ts.map +1 -0
  506. package/dist/ui/components/ActivityIndicator.js +115 -0
  507. package/dist/ui/components/ActivityIndicator.js.map +1 -0
  508. package/dist/ui/components/CommandBrowser.d.ts +10 -0
  509. package/dist/ui/components/CommandBrowser.d.ts.map +1 -0
  510. package/dist/ui/components/CommandBrowser.js +53 -0
  511. package/dist/ui/components/CommandBrowser.js.map +1 -0
  512. package/dist/ui/components/CustomTextInput.d.ts +13 -0
  513. package/dist/ui/components/CustomTextInput.d.ts.map +1 -0
  514. package/dist/ui/components/CustomTextInput.js +245 -0
  515. package/dist/ui/components/CustomTextInput.js.map +1 -0
  516. package/dist/ui/components/DocsSearchProgress.d.ts +13 -0
  517. package/dist/ui/components/DocsSearchProgress.d.ts.map +1 -0
  518. package/dist/ui/components/DocsSearchProgress.js +37 -0
  519. package/dist/ui/components/DocsSearchProgress.js.map +1 -0
  520. package/dist/ui/components/FileBrowser.d.ts +11 -0
  521. package/dist/ui/components/FileBrowser.d.ts.map +1 -0
  522. package/dist/ui/components/FileBrowser.js +45 -0
  523. package/dist/ui/components/FileBrowser.js.map +1 -0
  524. package/dist/ui/components/LLMSetupWizard.d.ts +8 -0
  525. package/dist/ui/components/LLMSetupWizard.d.ts.map +1 -0
  526. package/dist/ui/components/LLMSetupWizard.js +192 -0
  527. package/dist/ui/components/LLMSetupWizard.js.map +1 -0
  528. package/dist/ui/components/Logo.d.ts +19 -0
  529. package/dist/ui/components/Logo.d.ts.map +1 -0
  530. package/dist/ui/components/Logo.js +55 -0
  531. package/dist/ui/components/Logo.js.map +1 -0
  532. package/dist/ui/components/MarkdownRenderer.d.ts +9 -0
  533. package/dist/ui/components/MarkdownRenderer.d.ts.map +1 -0
  534. package/dist/ui/components/MarkdownRenderer.js +198 -0
  535. package/dist/ui/components/MarkdownRenderer.js.map +1 -0
  536. package/dist/ui/components/ModelSelector.d.ts +8 -0
  537. package/dist/ui/components/ModelSelector.d.ts.map +1 -0
  538. package/dist/ui/components/ModelSelector.js +111 -0
  539. package/dist/ui/components/ModelSelector.js.map +1 -0
  540. package/dist/ui/components/PlanExecuteApp.d.ts +23 -0
  541. package/dist/ui/components/PlanExecuteApp.d.ts.map +1 -0
  542. package/dist/ui/components/PlanExecuteApp.js +1324 -0
  543. package/dist/ui/components/PlanExecuteApp.js.map +1 -0
  544. package/dist/ui/components/ProgressBar.d.ts +10 -0
  545. package/dist/ui/components/ProgressBar.d.ts.map +1 -0
  546. package/dist/ui/components/ProgressBar.js +26 -0
  547. package/dist/ui/components/ProgressBar.js.map +1 -0
  548. package/dist/ui/components/StatusBar.d.ts +23 -0
  549. package/dist/ui/components/StatusBar.d.ts.map +1 -0
  550. package/dist/ui/components/StatusBar.js +162 -0
  551. package/dist/ui/components/StatusBar.js.map +1 -0
  552. package/dist/ui/components/ThinkingIndicator.d.ts +14 -0
  553. package/dist/ui/components/ThinkingIndicator.d.ts.map +1 -0
  554. package/dist/ui/components/ThinkingIndicator.js +63 -0
  555. package/dist/ui/components/ThinkingIndicator.js.map +1 -0
  556. package/dist/ui/components/TodoListView.d.ts +11 -0
  557. package/dist/ui/components/TodoListView.d.ts.map +1 -0
  558. package/dist/ui/components/TodoListView.js +69 -0
  559. package/dist/ui/components/TodoListView.js.map +1 -0
  560. package/dist/ui/components/ToolSelector.d.ts +7 -0
  561. package/dist/ui/components/ToolSelector.d.ts.map +1 -0
  562. package/dist/ui/components/ToolSelector.js +111 -0
  563. package/dist/ui/components/ToolSelector.js.map +1 -0
  564. package/dist/ui/components/dialogs/ApprovalDialog.d.ts +13 -0
  565. package/dist/ui/components/dialogs/ApprovalDialog.d.ts.map +1 -0
  566. package/dist/ui/components/dialogs/ApprovalDialog.js +173 -0
  567. package/dist/ui/components/dialogs/ApprovalDialog.js.map +1 -0
  568. package/dist/ui/components/dialogs/AskUserDialog.d.ts +9 -0
  569. package/dist/ui/components/dialogs/AskUserDialog.d.ts.map +1 -0
  570. package/dist/ui/components/dialogs/AskUserDialog.js +111 -0
  571. package/dist/ui/components/dialogs/AskUserDialog.js.map +1 -0
  572. package/dist/ui/components/dialogs/DocsBrowser.d.ts +8 -0
  573. package/dist/ui/components/dialogs/DocsBrowser.d.ts.map +1 -0
  574. package/dist/ui/components/dialogs/DocsBrowser.js +127 -0
  575. package/dist/ui/components/dialogs/DocsBrowser.js.map +1 -0
  576. package/dist/ui/components/dialogs/SettingsDialog.d.ts +10 -0
  577. package/dist/ui/components/dialogs/SettingsDialog.d.ts.map +1 -0
  578. package/dist/ui/components/dialogs/SettingsDialog.js +563 -0
  579. package/dist/ui/components/dialogs/SettingsDialog.js.map +1 -0
  580. package/dist/ui/components/dialogs/index.d.ts +4 -0
  581. package/dist/ui/components/dialogs/index.d.ts.map +1 -0
  582. package/dist/ui/components/dialogs/index.js +4 -0
  583. package/dist/ui/components/dialogs/index.js.map +1 -0
  584. package/dist/ui/components/index.d.ts +12 -0
  585. package/dist/ui/components/index.d.ts.map +1 -0
  586. package/dist/ui/components/index.js +9 -0
  587. package/dist/ui/components/index.js.map +1 -0
  588. package/dist/ui/components/panels/LogPanel.d.ts +7 -0
  589. package/dist/ui/components/panels/LogPanel.d.ts.map +1 -0
  590. package/dist/ui/components/panels/LogPanel.js +280 -0
  591. package/dist/ui/components/panels/LogPanel.js.map +1 -0
  592. package/dist/ui/components/panels/SessionPanel.d.ts +8 -0
  593. package/dist/ui/components/panels/SessionPanel.d.ts.map +1 -0
  594. package/dist/ui/components/panels/SessionPanel.js +81 -0
  595. package/dist/ui/components/panels/SessionPanel.js.map +1 -0
  596. package/dist/ui/components/panels/index.d.ts +4 -0
  597. package/dist/ui/components/panels/index.d.ts.map +1 -0
  598. package/dist/ui/components/panels/index.js +4 -0
  599. package/dist/ui/components/panels/index.js.map +1 -0
  600. package/dist/ui/components/views/ChatView.d.ts +12 -0
  601. package/dist/ui/components/views/ChatView.d.ts.map +1 -0
  602. package/dist/ui/components/views/ChatView.js +289 -0
  603. package/dist/ui/components/views/ChatView.js.map +1 -0
  604. package/dist/ui/components/views/index.d.ts +2 -0
  605. package/dist/ui/components/views/index.d.ts.map +1 -0
  606. package/dist/ui/components/views/index.js +2 -0
  607. package/dist/ui/components/views/index.js.map +1 -0
  608. package/dist/ui/contexts/TokenContext.d.ts +29 -0
  609. package/dist/ui/contexts/TokenContext.d.ts.map +1 -0
  610. package/dist/ui/contexts/TokenContext.js +79 -0
  611. package/dist/ui/contexts/TokenContext.js.map +1 -0
  612. package/dist/ui/hooks/atFileProcessor.d.ts +15 -0
  613. package/dist/ui/hooks/atFileProcessor.d.ts.map +1 -0
  614. package/dist/ui/hooks/atFileProcessor.js +88 -0
  615. package/dist/ui/hooks/atFileProcessor.js.map +1 -0
  616. package/dist/ui/hooks/index.d.ts +8 -0
  617. package/dist/ui/hooks/index.d.ts.map +1 -0
  618. package/dist/ui/hooks/index.js +8 -0
  619. package/dist/ui/hooks/index.js.map +1 -0
  620. package/dist/ui/hooks/slashCommandProcessor.d.ts +21 -0
  621. package/dist/ui/hooks/slashCommandProcessor.d.ts.map +1 -0
  622. package/dist/ui/hooks/slashCommandProcessor.js +100 -0
  623. package/dist/ui/hooks/slashCommandProcessor.js.map +1 -0
  624. package/dist/ui/hooks/useCommandBrowserState.d.ts +12 -0
  625. package/dist/ui/hooks/useCommandBrowserState.d.ts.map +1 -0
  626. package/dist/ui/hooks/useCommandBrowserState.js +66 -0
  627. package/dist/ui/hooks/useCommandBrowserState.js.map +1 -0
  628. package/dist/ui/hooks/useFileBrowserState.d.ts +15 -0
  629. package/dist/ui/hooks/useFileBrowserState.d.ts.map +1 -0
  630. package/dist/ui/hooks/useFileBrowserState.js +80 -0
  631. package/dist/ui/hooks/useFileBrowserState.js.map +1 -0
  632. package/dist/ui/hooks/useFileList.d.ts +20 -0
  633. package/dist/ui/hooks/useFileList.d.ts.map +1 -0
  634. package/dist/ui/hooks/useFileList.js +57 -0
  635. package/dist/ui/hooks/useFileList.js.map +1 -0
  636. package/dist/ui/hooks/useInputHistory.d.ts +9 -0
  637. package/dist/ui/hooks/useInputHistory.d.ts.map +1 -0
  638. package/dist/ui/hooks/useInputHistory.js +68 -0
  639. package/dist/ui/hooks/useInputHistory.js.map +1 -0
  640. package/dist/ui/hooks/usePlanExecution.d.ts +8 -0
  641. package/dist/ui/hooks/usePlanExecution.d.ts.map +1 -0
  642. package/dist/ui/hooks/usePlanExecution.js +214 -0
  643. package/dist/ui/hooks/usePlanExecution.js.map +1 -0
  644. package/dist/ui/index.d.ts +7 -0
  645. package/dist/ui/index.d.ts.map +1 -0
  646. package/dist/ui/index.js +7 -0
  647. package/dist/ui/index.js.map +1 -0
  648. package/dist/ui/ink-entry.d.ts +3 -0
  649. package/dist/ui/ink-entry.d.ts.map +1 -0
  650. package/dist/ui/ink-entry.js +22 -0
  651. package/dist/ui/ink-entry.js.map +1 -0
  652. package/dist/utils/env-filter.d.ts +4 -0
  653. package/dist/utils/env-filter.d.ts.map +1 -0
  654. package/dist/utils/env-filter.js +101 -0
  655. package/dist/utils/env-filter.js.map +1 -0
  656. package/dist/utils/file-system.d.ts +9 -0
  657. package/dist/utils/file-system.d.ts.map +1 -0
  658. package/dist/utils/file-system.js +99 -0
  659. package/dist/utils/file-system.js.map +1 -0
  660. package/dist/utils/git-utils.d.ts +2 -0
  661. package/dist/utils/git-utils.d.ts.map +1 -0
  662. package/dist/utils/git-utils.js +16 -0
  663. package/dist/utils/git-utils.js.map +1 -0
  664. package/dist/utils/json-stream-logger.d.ts +74 -0
  665. package/dist/utils/json-stream-logger.d.ts.map +1 -0
  666. package/dist/utils/json-stream-logger.js +808 -0
  667. package/dist/utils/json-stream-logger.js.map +1 -0
  668. package/dist/utils/logger.d.ts +152 -0
  669. package/dist/utils/logger.d.ts.map +1 -0
  670. package/dist/utils/logger.js +1672 -0
  671. package/dist/utils/logger.js.map +1 -0
  672. package/dist/utils/platform-utils.d.ts +19 -0
  673. package/dist/utils/platform-utils.d.ts.map +1 -0
  674. package/dist/utils/platform-utils.js +134 -0
  675. package/dist/utils/platform-utils.js.map +1 -0
  676. package/dist/utils/wsl-utils.d.ts +4 -0
  677. package/dist/utils/wsl-utils.d.ts.map +1 -0
  678. package/dist/utils/wsl-utils.js +72 -0
  679. package/dist/utils/wsl-utils.js.map +1 -0
  680. package/electron.vite.config.ts +63 -0
  681. package/google374b9eba0c52b043.html +1 -0
  682. package/package.json +122 -0
  683. package/src/agents/base/base-agent.ts +159 -0
  684. package/src/agents/docs-search/index.ts +365 -0
  685. package/src/agents/index.ts +34 -0
  686. package/src/agents/planner/index.ts +544 -0
  687. package/src/cli.ts +201 -0
  688. package/src/constants.ts +47 -0
  689. package/src/core/compact/compact-manager.ts +160 -0
  690. package/src/core/compact/compact-prompts.ts +150 -0
  691. package/src/core/compact/context-tracker.ts +164 -0
  692. package/src/core/compact/index.ts +25 -0
  693. package/src/core/config/config-manager.ts +460 -0
  694. package/src/core/config/index.ts +5 -0
  695. package/src/core/docs-manager.ts +678 -0
  696. package/src/core/llm/index.ts +7 -0
  697. package/src/core/llm/llm-client.ts +1550 -0
  698. package/src/core/session/index.ts +5 -0
  699. package/src/core/session/session-manager.ts +464 -0
  700. package/src/core/slash-command-handler.ts +410 -0
  701. package/src/core/usage-tracker.ts +438 -0
  702. package/src/errors/base.ts +81 -0
  703. package/src/errors/file.ts +183 -0
  704. package/src/errors/index.ts +95 -0
  705. package/src/errors/llm.ts +151 -0
  706. package/src/errors/network.ts +124 -0
  707. package/src/errors/validation.ts +111 -0
  708. package/src/eval/eval-runner.ts +456 -0
  709. package/src/eval/index.ts +8 -0
  710. package/src/eval/types.ts +139 -0
  711. package/src/index.ts +22 -0
  712. package/src/orchestration/index.ts +30 -0
  713. package/src/orchestration/plan-executor.ts +652 -0
  714. package/src/orchestration/types.ts +127 -0
  715. package/src/orchestration/utils.ts +119 -0
  716. package/src/orquesta/connection.ts +291 -0
  717. package/src/prompts/agents/docs-search-decision.ts +74 -0
  718. package/src/prompts/agents/docs-search.ts +84 -0
  719. package/src/prompts/agents/planning.ts +143 -0
  720. package/src/prompts/index.ts +31 -0
  721. package/src/prompts/shared/codebase-rules.ts +29 -0
  722. package/src/prompts/shared/git-rules.ts +94 -0
  723. package/src/prompts/shared/language-rules.ts +36 -0
  724. package/src/prompts/shared/tool-usage.ts +72 -0
  725. package/src/prompts/system/compact.ts +80 -0
  726. package/src/prompts/system/plan-execute.ts +89 -0
  727. package/src/tools/browser/browser-client.ts +1363 -0
  728. package/src/tools/browser/browser-tools.ts +1139 -0
  729. package/src/tools/browser/index.ts +65 -0
  730. package/src/tools/index.ts +23 -0
  731. package/src/tools/llm/agents/docs-search-tools.ts +368 -0
  732. package/src/tools/llm/agents/index.ts +22 -0
  733. package/src/tools/llm/index.ts +11 -0
  734. package/src/tools/llm/simple/ask-user-tool.ts +25 -0
  735. package/src/tools/llm/simple/background-bash-tool.ts +443 -0
  736. package/src/tools/llm/simple/background-powershell-tool.ts +421 -0
  737. package/src/tools/llm/simple/bash-tool.ts +238 -0
  738. package/src/tools/llm/simple/docs-search-agent-tool.ts +146 -0
  739. package/src/tools/llm/simple/file-tools.ts +1051 -0
  740. package/src/tools/llm/simple/final-response-tool.ts +180 -0
  741. package/src/tools/llm/simple/index.ts +42 -0
  742. package/src/tools/llm/simple/planning-tools.ts +143 -0
  743. package/src/tools/llm/simple/powershell-tool.ts +241 -0
  744. package/src/tools/llm/simple/simple-tool-executor.ts +279 -0
  745. package/src/tools/llm/simple/todo-tools.ts +207 -0
  746. package/src/tools/llm/simple/user-interaction-tools.ts +277 -0
  747. package/src/tools/office/common/constants.ts +335 -0
  748. package/src/tools/office/common/index.ts +133 -0
  749. package/src/tools/office/common/types.ts +286 -0
  750. package/src/tools/office/common/utils.ts +116 -0
  751. package/src/tools/office/excel-client.ts +1336 -0
  752. package/src/tools/office/excel-tools/cells.ts +359 -0
  753. package/src/tools/office/excel-tools/charts.ts +166 -0
  754. package/src/tools/office/excel-tools/comments.ts +155 -0
  755. package/src/tools/office/excel-tools/data-ops.ts +349 -0
  756. package/src/tools/office/excel-tools/export.ts +105 -0
  757. package/src/tools/office/excel-tools/formatting.ts +357 -0
  758. package/src/tools/office/excel-tools/index.ts +55 -0
  759. package/src/tools/office/excel-tools/launch.ts +303 -0
  760. package/src/tools/office/excel-tools/media.ts +117 -0
  761. package/src/tools/office/excel-tools/named-ranges.ts +148 -0
  762. package/src/tools/office/excel-tools/protection.ts +105 -0
  763. package/src/tools/office/excel-tools/rows-columns.ts +386 -0
  764. package/src/tools/office/excel-tools/sheets.ts +228 -0
  765. package/src/tools/office/excel-tools/validation.ts +226 -0
  766. package/src/tools/office/excel-tools.ts +9 -0
  767. package/src/tools/office/index.ts +259 -0
  768. package/src/tools/office/office-client-base.ts +242 -0
  769. package/src/tools/office/office-client.ts +377 -0
  770. package/src/tools/office/powerpoint-client.ts +1498 -0
  771. package/src/tools/office/powerpoint-tools/effects.ts +315 -0
  772. package/src/tools/office/powerpoint-tools/export.ts +138 -0
  773. package/src/tools/office/powerpoint-tools/index.ts +45 -0
  774. package/src/tools/office/powerpoint-tools/launch.ts +263 -0
  775. package/src/tools/office/powerpoint-tools/media.ts +291 -0
  776. package/src/tools/office/powerpoint-tools/notes.ts +220 -0
  777. package/src/tools/office/powerpoint-tools/sections.ts +140 -0
  778. package/src/tools/office/powerpoint-tools/shapes.ts +870 -0
  779. package/src/tools/office/powerpoint-tools/slides.ts +350 -0
  780. package/src/tools/office/powerpoint-tools/tables.ts +182 -0
  781. package/src/tools/office/powerpoint-tools/text.ts +473 -0
  782. package/src/tools/office/powerpoint-tools.ts +9 -0
  783. package/src/tools/office/word-client.ts +1697 -0
  784. package/src/tools/office/word-tools/bookmarks.ts +186 -0
  785. package/src/tools/office/word-tools/comments.ts +185 -0
  786. package/src/tools/office/word-tools/content.ts +229 -0
  787. package/src/tools/office/word-tools/export.ts +97 -0
  788. package/src/tools/office/word-tools/formatting.ts +161 -0
  789. package/src/tools/office/word-tools/headers-footers.ts +155 -0
  790. package/src/tools/office/word-tools/index.ts +57 -0
  791. package/src/tools/office/word-tools/launch.ts +312 -0
  792. package/src/tools/office/word-tools/lists.ts +97 -0
  793. package/src/tools/office/word-tools/navigation.ts +114 -0
  794. package/src/tools/office/word-tools/page-setup.ts +195 -0
  795. package/src/tools/office/word-tools/tables.ts +262 -0
  796. package/src/tools/office/word-tools/text.ts +294 -0
  797. package/src/tools/office/word-tools/undo-redo.ts +97 -0
  798. package/src/tools/office/word-tools/watermarks.ts +105 -0
  799. package/src/tools/office/word-tools.ts +9 -0
  800. package/src/tools/registry.ts +527 -0
  801. package/src/tools/types.ts +231 -0
  802. package/src/types/index.ts +181 -0
  803. package/src/ui/PlanExecuteView.tsx +119 -0
  804. package/src/ui/TodoPanel.tsx +240 -0
  805. package/src/ui/UpdateNotification.tsx +105 -0
  806. package/src/ui/components/ActivityIndicator.tsx +234 -0
  807. package/src/ui/components/CommandBrowser.tsx +114 -0
  808. package/src/ui/components/CustomTextInput.tsx +389 -0
  809. package/src/ui/components/DocsSearchProgress.tsx +85 -0
  810. package/src/ui/components/FileBrowser.tsx +93 -0
  811. package/src/ui/components/LLMSetupWizard.tsx +333 -0
  812. package/src/ui/components/Logo.tsx +125 -0
  813. package/src/ui/components/MarkdownRenderer.tsx +358 -0
  814. package/src/ui/components/ModelSelector.tsx +203 -0
  815. package/src/ui/components/PlanExecuteApp.tsx +2007 -0
  816. package/src/ui/components/ProgressBar.tsx +51 -0
  817. package/src/ui/components/StatusBar.tsx +302 -0
  818. package/src/ui/components/ThinkingIndicator.tsx +120 -0
  819. package/src/ui/components/TodoListView.tsx +140 -0
  820. package/src/ui/components/ToolSelector.tsx +215 -0
  821. package/src/ui/components/dialogs/ApprovalDialog.tsx +259 -0
  822. package/src/ui/components/dialogs/AskUserDialog.tsx +159 -0
  823. package/src/ui/components/dialogs/DocsBrowser.tsx +222 -0
  824. package/src/ui/components/dialogs/SettingsDialog.tsx +939 -0
  825. package/src/ui/components/dialogs/index.ts +13 -0
  826. package/src/ui/components/index.ts +27 -0
  827. package/src/ui/components/panels/LogPanel.tsx +385 -0
  828. package/src/ui/components/panels/SessionPanel.tsx +146 -0
  829. package/src/ui/components/panels/index.ts +13 -0
  830. package/src/ui/components/views/ChatView.tsx +447 -0
  831. package/src/ui/components/views/index.ts +5 -0
  832. package/src/ui/contexts/TokenContext.tsx +139 -0
  833. package/src/ui/hooks/atFileProcessor.ts +167 -0
  834. package/src/ui/hooks/index.ts +11 -0
  835. package/src/ui/hooks/slashCommandProcessor.ts +174 -0
  836. package/src/ui/hooks/useCommandBrowserState.ts +97 -0
  837. package/src/ui/hooks/useFileBrowserState.ts +116 -0
  838. package/src/ui/hooks/useFileList.ts +132 -0
  839. package/src/ui/hooks/useInputHistory.ts +89 -0
  840. package/src/ui/hooks/usePlanExecution.ts +339 -0
  841. package/src/ui/index.ts +10 -0
  842. package/src/ui/ink-entry.tsx +36 -0
  843. package/src/utils/env-filter.ts +164 -0
  844. package/src/utils/file-system.ts +133 -0
  845. package/src/utils/git-utils.ts +30 -0
  846. package/src/utils/json-stream-logger.ts +1259 -0
  847. package/src/utils/logger.ts +2767 -0
  848. package/src/utils/platform-utils.ts +256 -0
  849. package/src/utils/wsl-utils.ts +113 -0
  850. package/tsconfig.electron.json +39 -0
  851. package/tsconfig.json +64 -0
@@ -0,0 +1,1336 @@
1
+ /**
2
+ * Excel Client
3
+ *
4
+ * Microsoft Excel automation via PowerShell COM.
5
+ * Extends OfficeClientBase with Excel-specific operations.
6
+ */
7
+
8
+ import { OfficeClientBase, OfficeResponse, ScreenshotResponse } from './office-client-base.js';
9
+
10
+ /**
11
+ * Convert column letter (A, B, ..., Z, AA, AB, ...) to number (1, 2, ..., 26, 27, 28, ...)
12
+ */
13
+ function columnLetterToNumber(column: string): number {
14
+ let result = 0;
15
+ for (let i = 0; i < column.length; i++) {
16
+ result = result * 26 + (column.charCodeAt(i) - 'A'.charCodeAt(0) + 1);
17
+ }
18
+ return result;
19
+ }
20
+
21
+ /**
22
+ * Convert column number (1, 2, ..., 26, 27, 28, ...) to letter (A, B, ..., Z, AA, AB, ...)
23
+ */
24
+ function columnNumberToLetter(num: number): string {
25
+ let result = '';
26
+ while (num > 0) {
27
+ num--;
28
+ result = String.fromCharCode('A'.charCodeAt(0) + (num % 26)) + result;
29
+ num = Math.floor(num / 26);
30
+ }
31
+ return result;
32
+ }
33
+
34
+ export class ExcelClient extends OfficeClientBase {
35
+ async excelLaunch(): Promise<OfficeResponse> {
36
+ return this.executePowerShell(`
37
+ try {
38
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
39
+ $excel.Visible = $true
40
+ @{ success = $true; message = "Connected to existing Excel instance" } | ConvertTo-Json -Compress
41
+ } catch {
42
+ $excel = New-Object -ComObject Excel.Application
43
+ $excel.Visible = $true
44
+ @{ success = $true; message = "Launched new Excel instance" } | ConvertTo-Json -Compress
45
+ }
46
+ `);
47
+ }
48
+
49
+ async excelCreate(): Promise<OfficeResponse> {
50
+ return this.executePowerShell(`
51
+ try {
52
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
53
+ } catch {
54
+ $excel = New-Object -ComObject Excel.Application
55
+ $excel.Visible = $true
56
+ }
57
+ $workbook = $excel.Workbooks.Add()
58
+ @{ success = $true; message = "Created new workbook"; workbook_name = $workbook.Name } | ConvertTo-Json -Compress
59
+ `);
60
+ }
61
+
62
+ async excelOpen(filePath: string): Promise<OfficeResponse> {
63
+ const windowsPath = this.toWindowsPath(filePath).replace(/'/g, "''");
64
+ return this.executePowerShell(`
65
+ try {
66
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
67
+ } catch {
68
+ $excel = New-Object -ComObject Excel.Application
69
+ $excel.Visible = $true
70
+ }
71
+ $workbook = $excel.Workbooks.Open('${windowsPath}')
72
+ @{ success = $true; message = "Workbook opened"; workbook_name = $workbook.Name; path = $workbook.FullName } | ConvertTo-Json -Compress
73
+ `);
74
+ }
75
+
76
+ async excelWriteCell(
77
+ cell: string,
78
+ value: unknown,
79
+ sheet?: string,
80
+ options?: { fontName?: string; fontSize?: number; bold?: boolean; asText?: boolean }
81
+ ): Promise<OfficeResponse> {
82
+ const strValue = String(value);
83
+ const escapedValue = strValue.replace(/'/g, "''");
84
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
85
+
86
+ // Auto-detect Korean and set font
87
+ const hasKorean = /[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(strValue);
88
+ const fontName = options?.fontName || (hasKorean ? 'Malgun Gothic' : '');
89
+
90
+ // TEXT FIRST, FONT AFTER pattern (Microsoft recommended for Korean)
91
+ const fontScript: string[] = [];
92
+ if (fontName) fontScript.push(`$range.Font.Name = '${fontName.replace(/'/g, "''")}'`);
93
+ if (options?.fontSize) fontScript.push(`$range.Font.Size = ${options.fontSize}`);
94
+ if (options?.bold !== undefined) fontScript.push(`$range.Font.Bold = ${options.bold ? '$true' : '$false'}`);
95
+
96
+ // Determine how to set the value:
97
+ // - Numbers: set without quotes so Excel recognizes them
98
+ // - Dates (YYYY-MM-DD, MM/DD/YYYY): use DateValue or let Excel parse
99
+ // - asText option: force text format
100
+ // - Otherwise: let Excel auto-detect (without forcing string)
101
+ let valueScript: string;
102
+
103
+ if (options?.asText) {
104
+ // Force text format
105
+ valueScript = `$range.NumberFormat = '@'; $range.Value = '${escapedValue}'`;
106
+ } else if (typeof value === 'number' || (strValue !== '' && !isNaN(Number(strValue)) && strValue.trim() !== '')) {
107
+ // Numeric value - don't quote
108
+ valueScript = `$range.Value = ${strValue}`;
109
+ } else if (/^\d{4}-\d{2}-\d{2}$/.test(strValue)) {
110
+ // ISO date format (YYYY-MM-DD) - convert to Excel date
111
+ const [year, month, day] = strValue.split('-');
112
+ valueScript = `$range.Value = (Get-Date -Year ${year} -Month ${month} -Day ${day}).ToOADate()`;
113
+ } else if (/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(strValue)) {
114
+ // US date format (MM/DD/YYYY) - let Excel parse
115
+ valueScript = `$range.Value = '${escapedValue}'`;
116
+ } else {
117
+ // Default: set as-is and let Excel auto-detect
118
+ valueScript = `$range.Value = '${escapedValue}'`;
119
+ }
120
+
121
+ return this.executePowerShell(`
122
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
123
+ $workbook = $excel.ActiveWorkbook
124
+ ${sheetScript}
125
+ $range = $sheet.Range('${cell}')
126
+ ${valueScript}
127
+ ${fontScript.join('\n')}
128
+ @{ success = $true; message = "Value written to ${cell}" } | ConvertTo-Json -Compress
129
+ `);
130
+ }
131
+
132
+ async excelReadCell(cell: string, sheet?: string): Promise<OfficeResponse> {
133
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
134
+ return this.executePowerShell(`
135
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
136
+ $workbook = $excel.ActiveWorkbook
137
+ ${sheetScript}
138
+ $value = $sheet.Range('${cell}').Value2
139
+ @{ success = $true; cell = '${cell}'; value = $value } | ConvertTo-Json -Compress
140
+ `);
141
+ }
142
+
143
+ async excelWriteRange(startCell: string, values: unknown[][], sheet?: string): Promise<OfficeResponse> {
144
+ const rows = values.length;
145
+ const cols = values[0]?.length || 0;
146
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
147
+
148
+ // Check for Korean text in any cell
149
+ let hasKorean = false;
150
+
151
+ // Helper to convert value to PowerShell format
152
+ const toPsValue = (v: unknown): string => {
153
+ const str = String(v);
154
+ if (/[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(str)) hasKorean = true;
155
+
156
+ // Numbers: output without quotes
157
+ if (typeof v === 'number' || (str !== '' && !isNaN(Number(str)) && str.trim() !== '')) {
158
+ return str;
159
+ }
160
+ // ISO date (YYYY-MM-DD): convert to OADate expression
161
+ if (/^\d{4}-\d{2}-\d{2}$/.test(str)) {
162
+ const [year, month, day] = str.split('-');
163
+ return `([DateTime]::new(${year},${month},${day})).ToOADate()`;
164
+ }
165
+ // Default: string with escaped quotes
166
+ return `'${str.replace(/'/g, "''")}'`;
167
+ };
168
+
169
+ // Build PowerShell 2D array
170
+ const arrayLines: string[] = [];
171
+ for (let i = 0; i < values.length; i++) {
172
+ const row = values[i];
173
+ if (!row) continue;
174
+ const rowValues = row.map(v => toPsValue(v)).join(',');
175
+ arrayLines.push(`@(${rowValues})`);
176
+ }
177
+ const arrayScript = `@(${arrayLines.join(',')})`;
178
+
179
+ // TEXT FIRST, FONT AFTER pattern (Microsoft recommended for Korean)
180
+ const fontScript = hasKorean ? "$range.Font.Name = 'Malgun Gothic'" : '';
181
+
182
+ return this.executePowerShell(`
183
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
184
+ $workbook = $excel.ActiveWorkbook
185
+ ${sheetScript}
186
+ $startRange = $sheet.Range('${startCell}')
187
+ $endCell = $sheet.Cells($startRange.Row + ${rows - 1}, $startRange.Column + ${cols - 1})
188
+ $range = $sheet.Range($startRange, $endCell)
189
+ $data = ${arrayScript}
190
+ $range.Value = $data
191
+ ${fontScript}
192
+ @{ success = $true; message = "Range written from ${startCell} (${rows}x${cols})" } | ConvertTo-Json -Compress
193
+ `);
194
+ }
195
+
196
+ async excelReadRange(range: string, sheet?: string): Promise<OfficeResponse> {
197
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
198
+ return this.executePowerShell(`
199
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
200
+ $workbook = $excel.ActiveWorkbook
201
+ ${sheetScript}
202
+ $range = $sheet.Range('${range}')
203
+ $values = $range.Value2
204
+ $rows = $range.Rows.Count
205
+ $cols = $range.Columns.Count
206
+ @{ success = $true; range = '${range}'; values = $values; rows = $rows; columns = $cols } | ConvertTo-Json -Compress -Depth 10
207
+ `);
208
+ }
209
+
210
+ async excelSave(filePath?: string): Promise<OfficeResponse> {
211
+ const windowsPath = filePath ? this.toWindowsPath(filePath).replace(/'/g, "''") : '';
212
+ return this.executePowerShell(`
213
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
214
+ $workbook = $excel.ActiveWorkbook
215
+ ${windowsPath ? `$workbook.SaveAs('${windowsPath}')` : '$workbook.Save()'}
216
+ @{ success = $true; message = "Workbook saved"; path = $workbook.FullName } | ConvertTo-Json -Compress
217
+ `);
218
+ }
219
+
220
+ async excelClose(save: boolean = false): Promise<OfficeResponse> {
221
+ return this.executePowerShell(`
222
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
223
+ $workbook = $excel.ActiveWorkbook
224
+ $workbook.Close(${save ? '$true' : '$false'})
225
+ @{ success = $true; message = "Workbook closed" } | ConvertTo-Json -Compress
226
+ `);
227
+ }
228
+
229
+ async excelQuit(save: boolean = false): Promise<OfficeResponse> {
230
+ return this.executePowerShell(`
231
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
232
+ if (${save ? '$true' : '$false'}) {
233
+ foreach ($wb in $excel.Workbooks) { $wb.Save() }
234
+ }
235
+ $excel.Quit()
236
+ @{ success = $true; message = "Excel closed" } | ConvertTo-Json -Compress
237
+ `);
238
+ }
239
+
240
+ async excelSetFormula(cell: string, formula: string, sheet?: string): Promise<OfficeResponse> {
241
+ const escapedFormula = formula.replace(/'/g, "''");
242
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
243
+ return this.executePowerShell(`
244
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
245
+ $workbook = $excel.ActiveWorkbook
246
+ ${sheetScript}
247
+ $sheet.Range('${cell}').Formula = '${escapedFormula}'
248
+ @{ success = $true; message = "Formula set in ${cell}" } | ConvertTo-Json -Compress
249
+ `);
250
+ }
251
+
252
+ async excelSetFont(
253
+ range: string,
254
+ options: {
255
+ fontName?: string;
256
+ fontSize?: number;
257
+ bold?: boolean;
258
+ italic?: boolean;
259
+ underline?: boolean;
260
+ color?: string;
261
+ },
262
+ sheet?: string
263
+ ): Promise<OfficeResponse> {
264
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
265
+ const commands: string[] = [];
266
+ if (options.fontName) commands.push(`$range.Font.Name = '${options.fontName.replace(/'/g, "''")}'`);
267
+ if (options.fontSize) commands.push(`$range.Font.Size = ${options.fontSize}`);
268
+ if (options.bold !== undefined) commands.push(`$range.Font.Bold = ${options.bold ? '$true' : '$false'}`);
269
+ if (options.italic !== undefined) commands.push(`$range.Font.Italic = ${options.italic ? '$true' : '$false'}`);
270
+ if (options.underline !== undefined) commands.push(`$range.Font.Underline = ${options.underline ? '2' : '0'}`);
271
+ if (options.color) {
272
+ const rgb = this.hexToRgb(options.color);
273
+ if (rgb) commands.push(`$range.Font.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`);
274
+ }
275
+
276
+ return this.executePowerShell(`
277
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
278
+ $workbook = $excel.ActiveWorkbook
279
+ ${sheetScript}
280
+ $range = $sheet.Range('${range}')
281
+ ${commands.join('\n')}
282
+ @{ success = $true; message = "Font properties set for ${range}" } | ConvertTo-Json -Compress
283
+ `);
284
+ }
285
+
286
+ async excelSetAlignment(
287
+ range: string,
288
+ options: {
289
+ horizontal?: 'left' | 'center' | 'right';
290
+ vertical?: 'top' | 'center' | 'bottom';
291
+ wrapText?: boolean;
292
+ orientation?: number;
293
+ },
294
+ sheet?: string
295
+ ): Promise<OfficeResponse> {
296
+ const hAlignMap: Record<string, number> = { left: -4131, center: -4108, right: -4152 };
297
+ const vAlignMap: Record<string, number> = { top: -4160, center: -4108, bottom: -4107 };
298
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
299
+ const commands: string[] = [];
300
+ if (options.horizontal) commands.push(`$range.HorizontalAlignment = ${hAlignMap[options.horizontal]}`);
301
+ if (options.vertical) commands.push(`$range.VerticalAlignment = ${vAlignMap[options.vertical]}`);
302
+ if (options.wrapText !== undefined) commands.push(`$range.WrapText = ${options.wrapText ? '$true' : '$false'}`);
303
+ if (options.orientation !== undefined) commands.push(`$range.Orientation = ${options.orientation}`);
304
+
305
+ return this.executePowerShell(`
306
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
307
+ $workbook = $excel.ActiveWorkbook
308
+ ${sheetScript}
309
+ $range = $sheet.Range('${range}')
310
+ ${commands.join('\n')}
311
+ @{ success = $true; message = "Alignment set for ${range}" } | ConvertTo-Json -Compress
312
+ `);
313
+ }
314
+
315
+ async excelSetColumnWidth(column: string, width?: number, autoFit?: boolean, sheet?: string): Promise<OfficeResponse> {
316
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
317
+ return this.executePowerShell(`
318
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
319
+ $workbook = $excel.ActiveWorkbook
320
+ ${sheetScript}
321
+ $col = $sheet.Columns('${column}')
322
+ ${autoFit ? '$col.AutoFit()' : `$col.ColumnWidth = ${width || 10}`}
323
+ @{ success = $true; message = "Column ${column} width set" } | ConvertTo-Json -Compress
324
+ `);
325
+ }
326
+
327
+ async excelSetRowHeight(row: number, height?: number, autoFit?: boolean, sheet?: string): Promise<OfficeResponse> {
328
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
329
+ return this.executePowerShell(`
330
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
331
+ $workbook = $excel.ActiveWorkbook
332
+ ${sheetScript}
333
+ $row = $sheet.Rows(${row})
334
+ ${autoFit ? '$row.AutoFit()' : `$row.RowHeight = ${height || 15}`}
335
+ @{ success = $true; message = "Row ${row} height set" } | ConvertTo-Json -Compress
336
+ `);
337
+ }
338
+
339
+ async excelMergeCells(range: string, sheet?: string): Promise<OfficeResponse> {
340
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
341
+ return this.executePowerShell(`
342
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
343
+ $workbook = $excel.ActiveWorkbook
344
+ ${sheetScript}
345
+ $sheet.Range('${range}').Merge()
346
+ @{ success = $true; message = "Cells merged: ${range}" } | ConvertTo-Json -Compress
347
+ `);
348
+ }
349
+
350
+ async excelSetBorder(
351
+ range: string,
352
+ options: {
353
+ style?: 'thin' | 'medium' | 'thick' | 'double' | 'dotted' | 'dashed';
354
+ color?: string;
355
+ edges?: ('left' | 'right' | 'top' | 'bottom' | 'all')[];
356
+ },
357
+ sheet?: string
358
+ ): Promise<OfficeResponse> {
359
+ // xlContinuous=1, xlDash=-4115, xlDot=-4118, xlDouble=-4119
360
+ // For weight: xlThin=2, xlMedium=-4138, xlThick=4
361
+ const styleMap: Record<string, number> = { thin: 1, medium: 1, thick: 1, double: -4119, dotted: -4118, dashed: -4115 };
362
+ const weightMap: Record<string, number> = { thin: 2, medium: -4138, thick: 4, double: 2, dotted: 2, dashed: 2 };
363
+ const edgeMap: Record<string, number> = { left: 7, right: 10, top: 8, bottom: 9, all: -1 };
364
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
365
+ const edges = options.edges || ['all'];
366
+ const borderStyle = options.style ? styleMap[options.style] : 1;
367
+ const borderWeight = options.style ? weightMap[options.style] : 2;
368
+
369
+ let borderScript = '';
370
+ if (edges.includes('all')) {
371
+ borderScript = `
372
+ $range.Borders.LineStyle = ${borderStyle}
373
+ $range.Borders.Weight = ${borderWeight}`;
374
+ } else {
375
+ borderScript = edges.map(e => `$range.Borders(${edgeMap[e]}).LineStyle = ${borderStyle}
376
+ $range.Borders(${edgeMap[e]}).Weight = ${borderWeight}`).join('\n');
377
+ }
378
+
379
+ return this.executePowerShell(`
380
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
381
+ $workbook = $excel.ActiveWorkbook
382
+ ${sheetScript}
383
+ $range = $sheet.Range('${range}')
384
+ ${borderScript}
385
+ @{ success = $true; message = "Border set for ${range}" } | ConvertTo-Json -Compress
386
+ `);
387
+ }
388
+
389
+ async excelSetFill(range: string, color: string, sheet?: string): Promise<OfficeResponse> {
390
+ const rgb = this.hexToRgb(color);
391
+ const colorValue = rgb ? rgb.r + rgb.g * 256 + rgb.b * 65536 : 0;
392
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
393
+ return this.executePowerShell(`
394
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
395
+ $workbook = $excel.ActiveWorkbook
396
+ ${sheetScript}
397
+ $sheet.Range('${range}').Interior.Color = ${colorValue}
398
+ @{ success = $true; message = "Fill color set for ${range}" } | ConvertTo-Json -Compress
399
+ `);
400
+ }
401
+
402
+ async excelSetNumberFormat(range: string, format: string, sheet?: string): Promise<OfficeResponse> {
403
+ const escapedFormat = format.replace(/'/g, "''");
404
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
405
+ return this.executePowerShell(`
406
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
407
+ $workbook = $excel.ActiveWorkbook
408
+ ${sheetScript}
409
+ $sheet.Range('${range}').NumberFormat = '${escapedFormat}'
410
+ @{ success = $true; message = "Number format set for ${range}" } | ConvertTo-Json -Compress
411
+ `);
412
+ }
413
+
414
+ async excelAddSheet(name?: string, position?: 'start' | 'end' | string): Promise<OfficeResponse> {
415
+ const escapedName = name?.replace(/'/g, "''") || '';
416
+ let positionScript = '';
417
+ if (position === 'start') {
418
+ positionScript = ', [ref]$workbook.Sheets(1)';
419
+ } else if (position === 'end') {
420
+ positionScript = ', , [ref]$workbook.Sheets($workbook.Sheets.Count)';
421
+ } else if (position) {
422
+ positionScript = `, , [ref]$workbook.Sheets('${position.replace(/'/g, "''")}')`;
423
+ }
424
+
425
+ return this.executePowerShell(`
426
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
427
+ $workbook = $excel.ActiveWorkbook
428
+ $newSheet = $workbook.Sheets.Add(${positionScript})
429
+ ${escapedName ? `$newSheet.Name = '${escapedName}'` : ''}
430
+ @{ success = $true; message = "Sheet added"; sheet_name = $newSheet.Name } | ConvertTo-Json -Compress
431
+ `);
432
+ }
433
+
434
+ async excelDeleteSheet(name: string): Promise<OfficeResponse> {
435
+ const escapedName = name.replace(/'/g, "''");
436
+ return this.executePowerShell(`
437
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
438
+ $workbook = $excel.ActiveWorkbook
439
+ $excel.DisplayAlerts = $false
440
+ $workbook.Sheets('${escapedName}').Delete()
441
+ $excel.DisplayAlerts = $true
442
+ @{ success = $true; message = "Sheet '${escapedName}' deleted" } | ConvertTo-Json -Compress
443
+ `);
444
+ }
445
+
446
+ async excelRenameSheet(oldName: string, newName: string): Promise<OfficeResponse> {
447
+ const escapedOld = oldName.replace(/'/g, "''");
448
+ const escapedNew = newName.replace(/'/g, "''");
449
+ return this.executePowerShell(`
450
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
451
+ $workbook = $excel.ActiveWorkbook
452
+ $workbook.Sheets('${escapedOld}').Name = '${escapedNew}'
453
+ @{ success = $true; message = "Sheet renamed from '${escapedOld}' to '${escapedNew}'" } | ConvertTo-Json -Compress
454
+ `);
455
+ }
456
+
457
+ async excelGetSheets(): Promise<OfficeResponse> {
458
+ return this.executePowerShell(`
459
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
460
+ $workbook = $excel.ActiveWorkbook
461
+ $sheets = @()
462
+ foreach ($sheet in $workbook.Sheets) {
463
+ $sheets += $sheet.Name
464
+ }
465
+ @{ success = $true; sheets = $sheets; count = $sheets.Count } | ConvertTo-Json -Compress
466
+ `);
467
+ }
468
+
469
+ async excelSortRange(
470
+ range: string,
471
+ sortColumn: string,
472
+ ascending: boolean = true,
473
+ hasHeader: boolean = true,
474
+ sheet?: string
475
+ ): Promise<OfficeResponse> {
476
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
477
+ const order = ascending ? 1 : 2; // xlAscending = 1, xlDescending = 2
478
+ const header = hasHeader ? 1 : 2; // xlYes = 1, xlNo = 2
479
+
480
+ return this.executePowerShell(`
481
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
482
+ $workbook = $excel.ActiveWorkbook
483
+ ${sheetScript}
484
+ $range = $sheet.Range('${range}')
485
+ $sortKey = $sheet.Range('${sortColumn}1')
486
+
487
+ # Use Sort object for better compatibility
488
+ $sheet.Sort.SortFields.Clear()
489
+ $sheet.Sort.SortFields.Add($sortKey, 0, ${order})
490
+ $sheet.Sort.SetRange($range)
491
+ $sheet.Sort.Header = ${header}
492
+ $sheet.Sort.Apply()
493
+
494
+ @{ success = $true; message = "Range sorted by column ${sortColumn}" } | ConvertTo-Json -Compress
495
+ `);
496
+ }
497
+
498
+ async excelInsertRow(row: number, count: number = 1, sheet?: string): Promise<OfficeResponse> {
499
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
500
+ return this.executePowerShell(`
501
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
502
+ $workbook = $excel.ActiveWorkbook
503
+ ${sheetScript}
504
+ for ($i = 0; $i -lt ${count}; $i++) {
505
+ $sheet.Rows(${row}).Insert()
506
+ }
507
+ @{ success = $true; message = "${count} row(s) inserted at row ${row}" } | ConvertTo-Json -Compress
508
+ `);
509
+ }
510
+
511
+ async excelDeleteRow(row: number, count: number = 1, sheet?: string): Promise<OfficeResponse> {
512
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
513
+ return this.executePowerShell(`
514
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
515
+ $workbook = $excel.ActiveWorkbook
516
+ ${sheetScript}
517
+ $sheet.Rows("${row}:${row + count - 1}").Delete()
518
+ @{ success = $true; message = "${count} row(s) deleted starting at row ${row}" } | ConvertTo-Json -Compress
519
+ `);
520
+ }
521
+
522
+ async excelInsertColumn(column: string, count: number = 1, sheet?: string): Promise<OfficeResponse> {
523
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
524
+ return this.executePowerShell(`
525
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
526
+ $workbook = $excel.ActiveWorkbook
527
+ ${sheetScript}
528
+ for ($i = 0; $i -lt ${count}; $i++) {
529
+ $sheet.Columns('${column}').Insert()
530
+ }
531
+ @{ success = $true; message = "${count} column(s) inserted at column ${column}" } | ConvertTo-Json -Compress
532
+ `);
533
+ }
534
+
535
+ async excelDeleteColumn(column: string, count: number = 1, sheet?: string): Promise<OfficeResponse> {
536
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
537
+ const startColNum = columnLetterToNumber(column.toUpperCase());
538
+ const endCol = columnNumberToLetter(startColNum + count - 1);
539
+ return this.executePowerShell(`
540
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
541
+ $workbook = $excel.ActiveWorkbook
542
+ ${sheetScript}
543
+ $sheet.Columns("${column}:${endCol}").Delete()
544
+ @{ success = $true; message = "${count} column(s) deleted starting at column ${column}" } | ConvertTo-Json -Compress
545
+ `);
546
+ }
547
+
548
+ async excelFreezePanes(row?: number, column?: string, sheet?: string): Promise<OfficeResponse> {
549
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
550
+ const cellRef = `${column || 'A'}${row || 1}`;
551
+ return this.executePowerShell(`
552
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
553
+ $workbook = $excel.ActiveWorkbook
554
+ ${sheetScript}
555
+ $sheet.Activate()
556
+ $sheet.Range('${cellRef}').Select()
557
+ $excel.ActiveWindow.FreezePanes = $true
558
+ @{ success = $true; message = "Panes frozen at ${cellRef}" } | ConvertTo-Json -Compress
559
+ `);
560
+ }
561
+
562
+ async excelAutoFilter(range: string, sheet?: string): Promise<OfficeResponse> {
563
+ const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
564
+ return this.executePowerShell(`
565
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
566
+ $workbook = $excel.ActiveWorkbook
567
+ ${sheetScript}
568
+ $sheet.Range('${range}').AutoFilter()
569
+ @{ success = $true; message = "AutoFilter applied to ${range}" } | ConvertTo-Json -Compress
570
+ `);
571
+ }
572
+
573
+ async excelScreenshot(): Promise<ScreenshotResponse> {
574
+ const result = await this.executePowerShell(`
575
+ Add-Type -AssemblyName System.Windows.Forms
576
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
577
+ $sheet = $excel.ActiveWorkbook.ActiveSheet
578
+
579
+ # Get used range and copy as picture
580
+ $usedRange = $sheet.UsedRange
581
+ $usedRange.CopyPicture(1, 2) # xlScreen=1, xlBitmap=2
582
+
583
+ # Get image from clipboard
584
+ Start-Sleep -Milliseconds 500
585
+ $img = [System.Windows.Forms.Clipboard]::GetImage()
586
+ if ($img -eq $null) {
587
+ @{ success = $false; error = "Failed to capture screenshot" } | ConvertTo-Json -Compress
588
+ return
589
+ }
590
+
591
+ # Convert to base64
592
+ $ms = New-Object System.IO.MemoryStream
593
+ $img.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
594
+ $bytes = $ms.ToArray()
595
+ $base64 = [Convert]::ToBase64String($bytes)
596
+ $ms.Dispose()
597
+ $img.Dispose()
598
+
599
+ @{
600
+ success = $true
601
+ image = $base64
602
+ format = "png"
603
+ encoding = "base64"
604
+ } | ConvertTo-Json -Compress
605
+ `);
606
+ return result as ScreenshotResponse;
607
+ }
608
+
609
+ // -------------------------------------------------------------------------
610
+ // Excel Charts
611
+ // -------------------------------------------------------------------------
612
+
613
+ async excelAddChart(
614
+ dataRange: string,
615
+ chartType: 'column' | 'bar' | 'line' | 'pie' | 'area' | 'scatter' | 'doughnut',
616
+ options?: {
617
+ title?: string;
618
+ left?: number;
619
+ top?: number;
620
+ width?: number;
621
+ height?: number;
622
+ sheet?: string;
623
+ }
624
+ ): Promise<OfficeResponse> {
625
+ // Excel chart types
626
+ const chartTypeMap: Record<string, number> = {
627
+ column: 51, // xlColumnClustered
628
+ bar: 57, // xlBarClustered
629
+ line: 4, // xlLine
630
+ pie: 5, // xlPie
631
+ area: 1, // xlArea
632
+ scatter: -4169, // xlXYScatter
633
+ doughnut: -4120, // xlDoughnut
634
+ };
635
+ const xlChartType = chartTypeMap[chartType] ?? 51;
636
+ const escapedTitle = options?.title?.replace(/'/g, "''") || '';
637
+ const hasKorean = options?.title ? /[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(options.title) : false;
638
+
639
+ const sheetScript = options?.sheet ?
640
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
641
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
642
+
643
+ const left = options?.left ?? 100;
644
+ const top = options?.top ?? 100;
645
+ const width = options?.width ?? 400;
646
+ const height = options?.height ?? 300;
647
+
648
+ // TEXT FIRST, FONT AFTER pattern (Microsoft recommended for Korean)
649
+ const titleScript = escapedTitle ? `
650
+ $chart.HasTitle = $true
651
+ $chart.ChartTitle.Text = '${escapedTitle}'
652
+ ${hasKorean ? "$chart.ChartTitle.Font.Name = 'Malgun Gothic'" : ''}` : '';
653
+
654
+ return this.executePowerShell(`
655
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
656
+ ${sheetScript}
657
+ $range = $sheet.Range('${dataRange}')
658
+ $chartObj = $sheet.ChartObjects().Add(${left}, ${top}, ${width}, ${height})
659
+ $chart = $chartObj.Chart
660
+ $chart.SetSourceData($range)
661
+ $chart.ChartType = ${xlChartType}
662
+ ${titleScript}
663
+ @{ success = $true; message = "Chart added"; chart_name = $chartObj.Name } | ConvertTo-Json -Compress
664
+ `);
665
+ }
666
+
667
+ async excelSetChartTitle(chartIndex: number, title: string, sheet?: string): Promise<OfficeResponse> {
668
+ const escapedTitle = title.replace(/'/g, "''");
669
+ const hasKorean = /[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(title);
670
+ const sheetScript = sheet ?
671
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
672
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
673
+
674
+ // TEXT FIRST, FONT AFTER pattern (Microsoft recommended for Korean)
675
+ return this.executePowerShell(`
676
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
677
+ ${sheetScript}
678
+ $chartObj = $sheet.ChartObjects(${chartIndex})
679
+ $chart = $chartObj.Chart
680
+ $chart.HasTitle = $true
681
+ $chart.ChartTitle.Text = '${escapedTitle}'
682
+ ${hasKorean ? "$chart.ChartTitle.Font.Name = 'Malgun Gothic'" : ''}
683
+ @{ success = $true; message = "Chart title set" } | ConvertTo-Json -Compress
684
+ `);
685
+ }
686
+
687
+ async excelDeleteChart(chartIndex: number, sheet?: string): Promise<OfficeResponse> {
688
+ const sheetScript = sheet ?
689
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
690
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
691
+
692
+ return this.executePowerShell(`
693
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
694
+ ${sheetScript}
695
+ $sheet.ChartObjects(${chartIndex}).Delete()
696
+ @{ success = $true; message = "Chart deleted" } | ConvertTo-Json -Compress
697
+ `);
698
+ }
699
+
700
+ // -------------------------------------------------------------------------
701
+ // Excel Conditional Formatting
702
+ // -------------------------------------------------------------------------
703
+
704
+ async excelAddConditionalFormat(
705
+ range: string,
706
+ formatType: 'cellValue' | 'colorScale' | 'dataBar' | 'iconSet' | 'duplicates' | 'top10',
707
+ options?: {
708
+ operator?: 'greater' | 'less' | 'equal' | 'between' | 'notBetween';
709
+ value1?: string | number;
710
+ value2?: string | number;
711
+ fillColor?: string;
712
+ fontColor?: string;
713
+ sheet?: string;
714
+ }
715
+ ): Promise<OfficeResponse> {
716
+ const sheetScript = options?.sheet ?
717
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
718
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
719
+
720
+ // xlFormatConditionType: xlCellValue=1, xlColorScale=3, xlDataBar=4, xlIconSet=6, xlUniqueValues=8, xlTop10=5
721
+ const typeMap: Record<string, number> = {
722
+ cellValue: 1,
723
+ colorScale: 3,
724
+ dataBar: 4,
725
+ iconSet: 6,
726
+ duplicates: 8,
727
+ top10: 5,
728
+ };
729
+ const conditionType = typeMap[formatType] ?? 1;
730
+
731
+ // xlOperator: xlGreater=5, xlLess=6, xlEqual=3, xlBetween=1, xlNotBetween=2
732
+ const operatorMap: Record<string, number> = {
733
+ greater: 5,
734
+ less: 6,
735
+ equal: 3,
736
+ between: 1,
737
+ notBetween: 2,
738
+ };
739
+ const xlOperator = options?.operator ? operatorMap[options.operator] : 5;
740
+
741
+ let formatScript = '';
742
+ if (formatType === 'cellValue') {
743
+ const formula1 = typeof options?.value1 === 'string' ? `"${options.value1}"` : options?.value1 ?? 0;
744
+ const formula2 = options?.value2 !== undefined ?
745
+ (typeof options.value2 === 'string' ? `"${options.value2}"` : options.value2) : '';
746
+
747
+ formatScript = `
748
+ $fc = $range.FormatConditions.Add(${conditionType}, ${xlOperator}, ${formula1}${formula2 ? `, ${formula2}` : ''})`;
749
+
750
+ if (options?.fillColor) {
751
+ const rgb = this.hexToRgb(options.fillColor);
752
+ if (rgb) {
753
+ formatScript += `\n$fc.Interior.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`;
754
+ }
755
+ }
756
+ if (options?.fontColor) {
757
+ const rgb = this.hexToRgb(options.fontColor);
758
+ if (rgb) {
759
+ formatScript += `\n$fc.Font.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`;
760
+ }
761
+ }
762
+ } else if (formatType === 'colorScale') {
763
+ formatScript = '$range.FormatConditions.AddColorScale(3)';
764
+ } else if (formatType === 'dataBar') {
765
+ formatScript = '$range.FormatConditions.AddDataBar()';
766
+ } else if (formatType === 'iconSet') {
767
+ formatScript = '$range.FormatConditions.AddIconSetCondition()';
768
+ } else if (formatType === 'duplicates') {
769
+ formatScript = `$fc = $range.FormatConditions.AddUniqueValues()
770
+ $fc.DupeUnique = 1`; // xlDuplicate
771
+ if (options?.fillColor) {
772
+ const rgb = this.hexToRgb(options.fillColor);
773
+ if (rgb) {
774
+ formatScript += `\n$fc.Interior.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`;
775
+ }
776
+ }
777
+ } else if (formatType === 'top10') {
778
+ formatScript = `$fc = $range.FormatConditions.AddTop10()
779
+ $fc.TopBottom = 1
780
+ $fc.Rank = 10`;
781
+ if (options?.fillColor) {
782
+ const rgb = this.hexToRgb(options.fillColor);
783
+ if (rgb) {
784
+ formatScript += `\n$fc.Interior.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`;
785
+ }
786
+ }
787
+ }
788
+
789
+ return this.executePowerShell(`
790
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
791
+ ${sheetScript}
792
+ $range = $sheet.Range('${range}')
793
+ ${formatScript}
794
+ @{ success = $true; message = "Conditional format added to ${range}" } | ConvertTo-Json -Compress
795
+ `);
796
+ }
797
+
798
+ async excelClearConditionalFormat(range: string, sheet?: string): Promise<OfficeResponse> {
799
+ const sheetScript = sheet ?
800
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
801
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
802
+
803
+ return this.executePowerShell(`
804
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
805
+ ${sheetScript}
806
+ $sheet.Range('${range}').FormatConditions.Delete()
807
+ @{ success = $true; message = "Conditional formatting cleared from ${range}" } | ConvertTo-Json -Compress
808
+ `);
809
+ }
810
+
811
+ // -------------------------------------------------------------------------
812
+ // Excel Data Validation
813
+ // -------------------------------------------------------------------------
814
+
815
+ async excelSetDataValidation(
816
+ range: string,
817
+ validationType: 'list' | 'whole' | 'decimal' | 'date' | 'textLength' | 'custom',
818
+ options: {
819
+ formula1?: string;
820
+ formula2?: string;
821
+ operator?: 'between' | 'notBetween' | 'equal' | 'notEqual' | 'greater' | 'less' | 'greaterEqual' | 'lessEqual';
822
+ showInputMessage?: boolean;
823
+ inputTitle?: string;
824
+ inputMessage?: string;
825
+ showErrorMessage?: boolean;
826
+ errorTitle?: string;
827
+ errorMessage?: string;
828
+ sheet?: string;
829
+ }
830
+ ): Promise<OfficeResponse> {
831
+ const sheetScript = options?.sheet ?
832
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
833
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
834
+
835
+ // xlDVType: xlValidateList=3, xlValidateWholeNumber=1, xlValidateDecimal=2, xlValidateDate=4, xlValidateTextLength=6, xlValidateCustom=7
836
+ const typeMap: Record<string, number> = {
837
+ list: 3,
838
+ whole: 1,
839
+ decimal: 2,
840
+ date: 4,
841
+ textLength: 6,
842
+ custom: 7,
843
+ };
844
+ const dvType = typeMap[validationType] ?? 3;
845
+
846
+ // xlDVAlertStyle: xlValidAlertStop=1
847
+ // xlOperator
848
+ const operatorMap: Record<string, number> = {
849
+ between: 1,
850
+ notBetween: 2,
851
+ equal: 3,
852
+ notEqual: 4,
853
+ greater: 5,
854
+ less: 6,
855
+ greaterEqual: 7,
856
+ lessEqual: 8,
857
+ };
858
+ const xlOperator = options.operator ? operatorMap[options.operator] : 1;
859
+
860
+ const formula1 = options.formula1?.replace(/'/g, "''") || '';
861
+ const formula2 = options.formula2?.replace(/'/g, "''") || '';
862
+
863
+ const additionalSettings: string[] = [];
864
+ if (options.showInputMessage !== false && (options.inputTitle || options.inputMessage)) {
865
+ additionalSettings.push('$validation.ShowInput = $true');
866
+ if (options.inputTitle) additionalSettings.push(`$validation.InputTitle = '${options.inputTitle.replace(/'/g, "''")}'`);
867
+ if (options.inputMessage) additionalSettings.push(`$validation.InputMessage = '${options.inputMessage.replace(/'/g, "''")}'`);
868
+ }
869
+ if (options.showErrorMessage !== false && (options.errorTitle || options.errorMessage)) {
870
+ additionalSettings.push('$validation.ShowError = $true');
871
+ if (options.errorTitle) additionalSettings.push(`$validation.ErrorTitle = '${options.errorTitle.replace(/'/g, "''")}'`);
872
+ if (options.errorMessage) additionalSettings.push(`$validation.ErrorMessage = '${options.errorMessage.replace(/'/g, "''")}'`);
873
+ }
874
+
875
+ // For list validation, operator parameter is not used
876
+ const validationParams = validationType === 'list'
877
+ ? `${dvType}, 1, 1, '${formula1}'` // List: Type, AlertStyle, Operator (ignored), Formula1
878
+ : `${dvType}, 1, ${xlOperator}, '${formula1}'${formula2 ? `, '${formula2}'` : ''}`;
879
+
880
+ return this.executePowerShell(`
881
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
882
+ ${sheetScript}
883
+ $range = $sheet.Range('${range}')
884
+ $range.Validation.Delete()
885
+ $range.Validation.Add(${validationParams})
886
+ $validation = $range.Validation
887
+ ${additionalSettings.join('\n')}
888
+ @{ success = $true; message = "Data validation set on ${range}" } | ConvertTo-Json -Compress
889
+ `);
890
+ }
891
+
892
+ async excelClearDataValidation(range: string, sheet?: string): Promise<OfficeResponse> {
893
+ const sheetScript = sheet ?
894
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
895
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
896
+
897
+ return this.executePowerShell(`
898
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
899
+ ${sheetScript}
900
+ $sheet.Range('${range}').Validation.Delete()
901
+ @{ success = $true; message = "Data validation cleared from ${range}" } | ConvertTo-Json -Compress
902
+ `);
903
+ }
904
+
905
+ // -------------------------------------------------------------------------
906
+ // Excel Named Ranges
907
+ // -------------------------------------------------------------------------
908
+
909
+ async excelCreateNamedRange(name: string, range: string, sheet?: string): Promise<OfficeResponse> {
910
+ const escapedName = name.replace(/'/g, "''");
911
+ const sheetScript = sheet ?
912
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
913
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
914
+
915
+ return this.executePowerShell(`
916
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
917
+ $workbook = $excel.ActiveWorkbook
918
+ ${sheetScript}
919
+ $range = $sheet.Range('${range}')
920
+ $workbook.Names.Add('${escapedName}', $range)
921
+ @{ success = $true; message = "Named range '${escapedName}' created" } | ConvertTo-Json -Compress
922
+ `);
923
+ }
924
+
925
+ async excelGetNamedRanges(): Promise<OfficeResponse> {
926
+ return this.executePowerShell(`
927
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
928
+ $workbook = $excel.ActiveWorkbook
929
+ $names = @()
930
+ foreach ($n in $workbook.Names) {
931
+ $names += @{
932
+ name = $n.Name
933
+ refersTo = $n.RefersTo
934
+ value = $n.Value
935
+ }
936
+ }
937
+ @{ success = $true; named_ranges = $names } | ConvertTo-Json -Compress -Depth 5
938
+ `);
939
+ }
940
+
941
+ async excelDeleteNamedRange(name: string): Promise<OfficeResponse> {
942
+ const escapedName = name.replace(/'/g, "''");
943
+ return this.executePowerShell(`
944
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
945
+ $workbook = $excel.ActiveWorkbook
946
+ $workbook.Names('${escapedName}').Delete()
947
+ @{ success = $true; message = "Named range '${escapedName}' deleted" } | ConvertTo-Json -Compress
948
+ `);
949
+ }
950
+
951
+ // -------------------------------------------------------------------------
952
+ // Excel Copy/Paste/Clear
953
+ // -------------------------------------------------------------------------
954
+
955
+ async excelCopyRange(range: string, sheet?: string): Promise<OfficeResponse> {
956
+ const sheetScript = sheet ?
957
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
958
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
959
+
960
+ return this.executePowerShell(`
961
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
962
+ ${sheetScript}
963
+ $sheet.Range('${range}').Copy()
964
+ @{ success = $true; message = "Range ${range} copied to clipboard" } | ConvertTo-Json -Compress
965
+ `);
966
+ }
967
+
968
+ async excelPasteRange(destination: string, sheet?: string): Promise<OfficeResponse> {
969
+ const sheetScript = sheet ?
970
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
971
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
972
+
973
+ return this.executePowerShell(`
974
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
975
+ ${sheetScript}
976
+ $sheet.Range('${destination}').Select()
977
+ $sheet.Paste()
978
+ @{ success = $true; message = "Pasted to ${destination}" } | ConvertTo-Json -Compress
979
+ `);
980
+ }
981
+
982
+ async excelClearRange(
983
+ range: string,
984
+ clearType: 'all' | 'contents' | 'formats' | 'comments' = 'all',
985
+ sheet?: string
986
+ ): Promise<OfficeResponse> {
987
+ const sheetScript = sheet ?
988
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
989
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
990
+
991
+ const clearMethod = {
992
+ all: 'Clear()',
993
+ contents: 'ClearContents()',
994
+ formats: 'ClearFormats()',
995
+ comments: 'ClearComments()',
996
+ }[clearType];
997
+
998
+ return this.executePowerShell(`
999
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1000
+ ${sheetScript}
1001
+ $sheet.Range('${range}').${clearMethod}
1002
+ @{ success = $true; message = "Range ${range} cleared (${clearType})" } | ConvertTo-Json -Compress
1003
+ `);
1004
+ }
1005
+
1006
+ // -------------------------------------------------------------------------
1007
+ // Excel Hide/Show Rows & Columns
1008
+ // -------------------------------------------------------------------------
1009
+
1010
+ async excelHideColumn(column: string, sheet?: string): Promise<OfficeResponse> {
1011
+ const sheetScript = sheet ?
1012
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1013
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1014
+
1015
+ return this.executePowerShell(`
1016
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1017
+ ${sheetScript}
1018
+ $sheet.Columns('${column}').Hidden = $true
1019
+ @{ success = $true; message = "Column ${column} hidden" } | ConvertTo-Json -Compress
1020
+ `);
1021
+ }
1022
+
1023
+ async excelShowColumn(column: string, sheet?: string): Promise<OfficeResponse> {
1024
+ const sheetScript = sheet ?
1025
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1026
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1027
+
1028
+ return this.executePowerShell(`
1029
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1030
+ ${sheetScript}
1031
+ $sheet.Columns('${column}').Hidden = $false
1032
+ @{ success = $true; message = "Column ${column} shown" } | ConvertTo-Json -Compress
1033
+ `);
1034
+ }
1035
+
1036
+ async excelHideRow(row: number, sheet?: string): Promise<OfficeResponse> {
1037
+ const sheetScript = sheet ?
1038
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1039
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1040
+
1041
+ return this.executePowerShell(`
1042
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1043
+ ${sheetScript}
1044
+ $sheet.Rows(${row}).Hidden = $true
1045
+ @{ success = $true; message = "Row ${row} hidden" } | ConvertTo-Json -Compress
1046
+ `);
1047
+ }
1048
+
1049
+ async excelShowRow(row: number, sheet?: string): Promise<OfficeResponse> {
1050
+ const sheetScript = sheet ?
1051
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1052
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1053
+
1054
+ return this.executePowerShell(`
1055
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1056
+ ${sheetScript}
1057
+ $sheet.Rows(${row}).Hidden = $false
1058
+ @{ success = $true; message = "Row ${row} shown" } | ConvertTo-Json -Compress
1059
+ `);
1060
+ }
1061
+
1062
+ // -------------------------------------------------------------------------
1063
+ // Excel Image & Hyperlink
1064
+ // -------------------------------------------------------------------------
1065
+
1066
+ async excelAddImage(
1067
+ imagePath: string,
1068
+ cell: string,
1069
+ options?: { width?: number; height?: number; sheet?: string }
1070
+ ): Promise<OfficeResponse> {
1071
+ const windowsPath = this.toWindowsPath(imagePath).replace(/'/g, "''");
1072
+ const sheetScript = options?.sheet ?
1073
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
1074
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1075
+
1076
+ const sizeScript = [];
1077
+ if (options?.width) sizeScript.push(`$pic.Width = ${options.width}`);
1078
+ if (options?.height) sizeScript.push(`$pic.Height = ${options.height}`);
1079
+
1080
+ return this.executePowerShell(`
1081
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1082
+ ${sheetScript}
1083
+ $cell = $sheet.Range('${cell}')
1084
+ $pic = $sheet.Shapes.AddPicture('${windowsPath}', 0, -1, $cell.Left, $cell.Top, -1, -1)
1085
+ ${sizeScript.join('\n')}
1086
+ @{ success = $true; message = "Image added at ${cell}" } | ConvertTo-Json -Compress
1087
+ `);
1088
+ }
1089
+
1090
+ async excelAddHyperlink(
1091
+ cell: string,
1092
+ url: string,
1093
+ displayText?: string,
1094
+ sheet?: string
1095
+ ): Promise<OfficeResponse> {
1096
+ const escapedUrl = url.replace(/'/g, "''");
1097
+ const escapedText = displayText?.replace(/'/g, "''") || url;
1098
+ const sheetScript = sheet ?
1099
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1100
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1101
+
1102
+ return this.executePowerShell(`
1103
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1104
+ ${sheetScript}
1105
+ $range = $sheet.Range('${cell}')
1106
+ $sheet.Hyperlinks.Add($range, '${escapedUrl}', '', '', '${escapedText}')
1107
+ @{ success = $true; message = "Hyperlink added to ${cell}" } | ConvertTo-Json -Compress
1108
+ `);
1109
+ }
1110
+
1111
+ // -------------------------------------------------------------------------
1112
+ // Excel Export & Print
1113
+ // -------------------------------------------------------------------------
1114
+
1115
+ async excelExportPDF(outputPath: string, sheet?: string): Promise<OfficeResponse> {
1116
+ const windowsPath = this.toWindowsPath(outputPath).replace(/'/g, "''");
1117
+ const sheetScript = sheet ?
1118
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')
1119
+ $sheet.ExportAsFixedFormat(0, '${windowsPath}')` :
1120
+ `$excel.ActiveWorkbook.ExportAsFixedFormat(0, '${windowsPath}')`;
1121
+
1122
+ return this.executePowerShell(`
1123
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1124
+ ${sheetScript}
1125
+ @{ success = $true; message = "Exported to PDF"; path = '${windowsPath}' } | ConvertTo-Json -Compress
1126
+ `);
1127
+ }
1128
+
1129
+ async excelPrint(copies: number = 1, sheet?: string): Promise<OfficeResponse> {
1130
+ const sheetScript = sheet ?
1131
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')
1132
+ $sheet.PrintOut(1, 9999, ${copies})` :
1133
+ `$excel.ActiveWorkbook.PrintOut(1, 9999, ${copies})`;
1134
+
1135
+ return this.executePowerShell(`
1136
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1137
+ ${sheetScript}
1138
+ @{ success = $true; message = "Print job sent (${copies} copies)" } | ConvertTo-Json -Compress
1139
+ `);
1140
+ }
1141
+
1142
+ // -------------------------------------------------------------------------
1143
+ // Excel Comments
1144
+ // -------------------------------------------------------------------------
1145
+
1146
+ async excelAddComment(cell: string, text: string, _author?: string, sheet?: string): Promise<OfficeResponse> {
1147
+ const escapedText = text.replace(/'/g, "''");
1148
+ const sheetScript = sheet ?
1149
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1150
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1151
+
1152
+ return this.executePowerShell(`
1153
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1154
+ ${sheetScript}
1155
+ $cell = $sheet.Range('${cell}')
1156
+ if ($cell.Comment -ne $null) { $cell.Comment.Delete() }
1157
+ $comment = $cell.AddComment('${escapedText}')
1158
+ $comment.Visible = $false
1159
+ @{ success = $true; message = "Comment added to ${cell}" } | ConvertTo-Json -Compress
1160
+ `);
1161
+ }
1162
+
1163
+ async excelGetComment(cell: string, sheet?: string): Promise<OfficeResponse> {
1164
+ const sheetScript = sheet ?
1165
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1166
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1167
+
1168
+ return this.executePowerShell(`
1169
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1170
+ ${sheetScript}
1171
+ $cell = $sheet.Range('${cell}')
1172
+ if ($cell.Comment -ne $null) {
1173
+ @{ success = $true; has_comment = $true; text = $cell.Comment.Text() } | ConvertTo-Json -Compress
1174
+ } else {
1175
+ @{ success = $true; has_comment = $false } | ConvertTo-Json -Compress
1176
+ }
1177
+ `);
1178
+ }
1179
+
1180
+ async excelDeleteComment(cell: string, sheet?: string): Promise<OfficeResponse> {
1181
+ const sheetScript = sheet ?
1182
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1183
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1184
+
1185
+ return this.executePowerShell(`
1186
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1187
+ ${sheetScript}
1188
+ $cell = $sheet.Range('${cell}')
1189
+ if ($cell.Comment -ne $null) {
1190
+ $cell.Comment.Delete()
1191
+ @{ success = $true; message = "Comment deleted from ${cell}" } | ConvertTo-Json -Compress
1192
+ } else {
1193
+ @{ success = $false; error = "No comment found at ${cell}" } | ConvertTo-Json -Compress
1194
+ }
1195
+ `);
1196
+ }
1197
+
1198
+ // -------------------------------------------------------------------------
1199
+ // Excel Sheet Protection
1200
+ // -------------------------------------------------------------------------
1201
+
1202
+ async excelProtectSheet(password?: string, sheet?: string): Promise<OfficeResponse> {
1203
+ const escapedPassword = password?.replace(/'/g, "''") || '';
1204
+ const sheetScript = sheet ?
1205
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1206
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1207
+
1208
+ return this.executePowerShell(`
1209
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1210
+ ${sheetScript}
1211
+ $sheet.Protect('${escapedPassword}')
1212
+ @{ success = $true; message = "Sheet protected" } | ConvertTo-Json -Compress
1213
+ `);
1214
+ }
1215
+
1216
+ async excelUnprotectSheet(password?: string, sheet?: string): Promise<OfficeResponse> {
1217
+ const escapedPassword = password?.replace(/'/g, "''") || '';
1218
+ const sheetScript = sheet ?
1219
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1220
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1221
+
1222
+ return this.executePowerShell(`
1223
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1224
+ ${sheetScript}
1225
+ $sheet.Unprotect('${escapedPassword}')
1226
+ @{ success = $true; message = "Sheet unprotected" } | ConvertTo-Json -Compress
1227
+ `);
1228
+ }
1229
+
1230
+ // -------------------------------------------------------------------------
1231
+ // Excel Unmerge Cells
1232
+ // -------------------------------------------------------------------------
1233
+
1234
+ async excelUnmergeCells(range: string, sheet?: string): Promise<OfficeResponse> {
1235
+ const sheetScript = sheet ?
1236
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1237
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1238
+
1239
+ return this.executePowerShell(`
1240
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1241
+ ${sheetScript}
1242
+ $sheet.Range('${range}').UnMerge()
1243
+ @{ success = $true; message = "Cells unmerged: ${range}" } | ConvertTo-Json -Compress
1244
+ `);
1245
+ }
1246
+
1247
+ // -------------------------------------------------------------------------
1248
+ // Excel Select/Activate Sheet
1249
+ // -------------------------------------------------------------------------
1250
+
1251
+ async excelSelectSheet(name: string): Promise<OfficeResponse> {
1252
+ const escapedName = name.replace(/'/g, "''");
1253
+ return this.executePowerShell(`
1254
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1255
+ $excel.ActiveWorkbook.Worksheets('${escapedName}').Activate()
1256
+ @{ success = $true; message = "Sheet '${escapedName}' activated" } | ConvertTo-Json -Compress
1257
+ `);
1258
+ }
1259
+
1260
+ // -------------------------------------------------------------------------
1261
+ // Excel Find & Replace
1262
+ // -------------------------------------------------------------------------
1263
+
1264
+ async excelFindReplace(
1265
+ find: string,
1266
+ replace: string,
1267
+ options?: {
1268
+ matchCase?: boolean;
1269
+ matchEntireCell?: boolean;
1270
+ range?: string;
1271
+ sheet?: string;
1272
+ }
1273
+ ): Promise<OfficeResponse> {
1274
+ const escapedFind = find.replace(/'/g, "''");
1275
+ const escapedReplace = replace.replace(/'/g, "''");
1276
+ const sheetScript = options?.sheet ?
1277
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
1278
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1279
+
1280
+ const rangeScript = options?.range ?
1281
+ `$range = $sheet.Range('${options.range}')` :
1282
+ '$range = $sheet.UsedRange';
1283
+
1284
+ const matchCase = options?.matchCase ? '$true' : '$false';
1285
+ const lookAt = options?.matchEntireCell ? '1' : '2'; // xlWhole=1, xlPart=2
1286
+
1287
+ return this.executePowerShell(`
1288
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1289
+ ${sheetScript}
1290
+ ${rangeScript}
1291
+ $replaced = $range.Replace('${escapedFind}', '${escapedReplace}', ${lookAt}, 1, ${matchCase})
1292
+ @{ success = $true; message = "Find and replace completed" } | ConvertTo-Json -Compress
1293
+ `);
1294
+ }
1295
+
1296
+ // -------------------------------------------------------------------------
1297
+ // Excel Group Rows
1298
+ // -------------------------------------------------------------------------
1299
+
1300
+ async excelGroupRows(startRow: number, endRow: number, sheet?: string): Promise<OfficeResponse> {
1301
+ const sheetScript = sheet ?
1302
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1303
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1304
+
1305
+ return this.executePowerShell(`
1306
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1307
+ ${sheetScript}
1308
+ $sheet.Rows("${startRow}:${endRow}").Group()
1309
+ @{ success = $true; message = "Rows ${startRow}-${endRow} grouped" } | ConvertTo-Json -Compress
1310
+ `);
1311
+ }
1312
+
1313
+ async excelUngroupRows(startRow: number, endRow: number, sheet?: string): Promise<OfficeResponse> {
1314
+ const sheetScript = sheet ?
1315
+ `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1316
+ '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1317
+
1318
+ return this.executePowerShell(`
1319
+ $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1320
+ ${sheetScript}
1321
+ $sheet.Rows("${startRow}:${endRow}").Ungroup()
1322
+ @{ success = $true; message = "Rows ${startRow}-${endRow} ungrouped" } | ConvertTo-Json -Compress
1323
+ `);
1324
+ }
1325
+
1326
+ // ===========================================================================
1327
+ // Microsoft PowerPoint Operations
1328
+ // ===========================================================================
1329
+
1330
+
1331
+ }
1332
+
1333
+ // Export singleton instance
1334
+ export const excelClient = new ExcelClient();
1335
+ export type { OfficeResponse, ScreenshotResponse };
1336
+