zerg-ztc 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (411) hide show
  1. package/README.md +361 -0
  2. package/dist/App.d.ts +4 -0
  3. package/dist/App.d.ts.map +1 -0
  4. package/dist/App.js +499 -0
  5. package/dist/App.js.map +1 -0
  6. package/dist/agent/agent.d.ts +54 -0
  7. package/dist/agent/agent.d.ts.map +1 -0
  8. package/dist/agent/agent.js +347 -0
  9. package/dist/agent/agent.js.map +1 -0
  10. package/dist/agent/backends/anthropic.d.ts +13 -0
  11. package/dist/agent/backends/anthropic.d.ts.map +1 -0
  12. package/dist/agent/backends/anthropic.js +54 -0
  13. package/dist/agent/backends/anthropic.js.map +1 -0
  14. package/dist/agent/backends/gemini.d.ts +13 -0
  15. package/dist/agent/backends/gemini.d.ts.map +1 -0
  16. package/dist/agent/backends/gemini.js +71 -0
  17. package/dist/agent/backends/gemini.js.map +1 -0
  18. package/dist/agent/backends/inception.d.ts +12 -0
  19. package/dist/agent/backends/inception.d.ts.map +1 -0
  20. package/dist/agent/backends/inception.js +15 -0
  21. package/dist/agent/backends/inception.js.map +1 -0
  22. package/dist/agent/backends/index.d.ts +7 -0
  23. package/dist/agent/backends/index.d.ts.map +1 -0
  24. package/dist/agent/backends/index.js +6 -0
  25. package/dist/agent/backends/index.js.map +1 -0
  26. package/dist/agent/backends/openai.d.ts +12 -0
  27. package/dist/agent/backends/openai.d.ts.map +1 -0
  28. package/dist/agent/backends/openai.js +15 -0
  29. package/dist/agent/backends/openai.js.map +1 -0
  30. package/dist/agent/backends/openai_compatible.d.ts +17 -0
  31. package/dist/agent/backends/openai_compatible.d.ts.map +1 -0
  32. package/dist/agent/backends/openai_compatible.js +95 -0
  33. package/dist/agent/backends/openai_compatible.js.map +1 -0
  34. package/dist/agent/backends/types.d.ts +49 -0
  35. package/dist/agent/backends/types.d.ts.map +1 -0
  36. package/dist/agent/backends/types.js +2 -0
  37. package/dist/agent/backends/types.js.map +1 -0
  38. package/dist/agent/commands/clipboard.d.ts +3 -0
  39. package/dist/agent/commands/clipboard.d.ts.map +1 -0
  40. package/dist/agent/commands/clipboard.js +72 -0
  41. package/dist/agent/commands/clipboard.js.map +1 -0
  42. package/dist/agent/commands/config.d.ts +3 -0
  43. package/dist/agent/commands/config.d.ts.map +1 -0
  44. package/dist/agent/commands/config.js +120 -0
  45. package/dist/agent/commands/config.js.map +1 -0
  46. package/dist/agent/commands/debug.d.ts +3 -0
  47. package/dist/agent/commands/debug.d.ts.map +1 -0
  48. package/dist/agent/commands/debug.js +23 -0
  49. package/dist/agent/commands/debug.js.map +1 -0
  50. package/dist/agent/commands/emulation.d.ts +3 -0
  51. package/dist/agent/commands/emulation.d.ts.map +1 -0
  52. package/dist/agent/commands/emulation.js +78 -0
  53. package/dist/agent/commands/emulation.js.map +1 -0
  54. package/dist/agent/commands/execution.d.ts +3 -0
  55. package/dist/agent/commands/execution.d.ts.map +1 -0
  56. package/dist/agent/commands/execution.js +8 -0
  57. package/dist/agent/commands/execution.js.map +1 -0
  58. package/dist/agent/commands/help.d.ts +3 -0
  59. package/dist/agent/commands/help.d.ts.map +1 -0
  60. package/dist/agent/commands/help.js +19 -0
  61. package/dist/agent/commands/help.js.map +1 -0
  62. package/dist/agent/commands/history.d.ts +3 -0
  63. package/dist/agent/commands/history.d.ts.map +1 -0
  64. package/dist/agent/commands/history.js +12 -0
  65. package/dist/agent/commands/history.js.map +1 -0
  66. package/dist/agent/commands/index.d.ts +4 -0
  67. package/dist/agent/commands/index.d.ts.map +1 -0
  68. package/dist/agent/commands/index.js +19 -0
  69. package/dist/agent/commands/index.js.map +1 -0
  70. package/dist/agent/commands/model.d.ts +3 -0
  71. package/dist/agent/commands/model.d.ts.map +1 -0
  72. package/dist/agent/commands/model.js +10 -0
  73. package/dist/agent/commands/model.js.map +1 -0
  74. package/dist/agent/commands/models.d.ts +3 -0
  75. package/dist/agent/commands/models.d.ts.map +1 -0
  76. package/dist/agent/commands/models.js +110 -0
  77. package/dist/agent/commands/models.js.map +1 -0
  78. package/dist/agent/commands/permissions.d.ts +3 -0
  79. package/dist/agent/commands/permissions.d.ts.map +1 -0
  80. package/dist/agent/commands/permissions.js +58 -0
  81. package/dist/agent/commands/permissions.js.map +1 -0
  82. package/dist/agent/commands/retry.d.ts +3 -0
  83. package/dist/agent/commands/retry.d.ts.map +1 -0
  84. package/dist/agent/commands/retry.js +8 -0
  85. package/dist/agent/commands/retry.js.map +1 -0
  86. package/dist/agent/commands/shell.d.ts +4 -0
  87. package/dist/agent/commands/shell.d.ts.map +1 -0
  88. package/dist/agent/commands/shell.js +66 -0
  89. package/dist/agent/commands/shell.js.map +1 -0
  90. package/dist/agent/commands/skills.d.ts +3 -0
  91. package/dist/agent/commands/skills.d.ts.map +1 -0
  92. package/dist/agent/commands/skills.js +50 -0
  93. package/dist/agent/commands/skills.js.map +1 -0
  94. package/dist/agent/commands/status.d.ts +3 -0
  95. package/dist/agent/commands/status.d.ts.map +1 -0
  96. package/dist/agent/commands/status.js +18 -0
  97. package/dist/agent/commands/status.js.map +1 -0
  98. package/dist/agent/commands/types.d.ts +70 -0
  99. package/dist/agent/commands/types.d.ts.map +1 -0
  100. package/dist/agent/commands/types.js +2 -0
  101. package/dist/agent/commands/types.js.map +1 -0
  102. package/dist/agent/factory.d.ts +13 -0
  103. package/dist/agent/factory.d.ts.map +1 -0
  104. package/dist/agent/factory.js +46 -0
  105. package/dist/agent/factory.js.map +1 -0
  106. package/dist/agent/index.d.ts +14 -0
  107. package/dist/agent/index.d.ts.map +1 -0
  108. package/dist/agent/index.js +10 -0
  109. package/dist/agent/index.js.map +1 -0
  110. package/dist/agent/runtime/capabilities.d.ts +7 -0
  111. package/dist/agent/runtime/capabilities.d.ts.map +1 -0
  112. package/dist/agent/runtime/capabilities.js +8 -0
  113. package/dist/agent/runtime/capabilities.js.map +1 -0
  114. package/dist/agent/runtime/memory.d.ts +13 -0
  115. package/dist/agent/runtime/memory.d.ts.map +1 -0
  116. package/dist/agent/runtime/memory.js +13 -0
  117. package/dist/agent/runtime/memory.js.map +1 -0
  118. package/dist/agent/runtime/policy.d.ts +22 -0
  119. package/dist/agent/runtime/policy.d.ts.map +1 -0
  120. package/dist/agent/runtime/policy.js +29 -0
  121. package/dist/agent/runtime/policy.js.map +1 -0
  122. package/dist/agent/runtime/session.d.ts +11 -0
  123. package/dist/agent/runtime/session.d.ts.map +1 -0
  124. package/dist/agent/runtime/session.js +10 -0
  125. package/dist/agent/runtime/session.js.map +1 -0
  126. package/dist/agent/runtime/tracing.d.ts +13 -0
  127. package/dist/agent/runtime/tracing.d.ts.map +1 -0
  128. package/dist/agent/runtime/tracing.js +6 -0
  129. package/dist/agent/runtime/tracing.js.map +1 -0
  130. package/dist/agent/tools/file.d.ts +5 -0
  131. package/dist/agent/tools/file.d.ts.map +1 -0
  132. package/dist/agent/tools/file.js +162 -0
  133. package/dist/agent/tools/file.js.map +1 -0
  134. package/dist/agent/tools/index.d.ts +13 -0
  135. package/dist/agent/tools/index.d.ts.map +1 -0
  136. package/dist/agent/tools/index.js +34 -0
  137. package/dist/agent/tools/index.js.map +1 -0
  138. package/dist/agent/tools/search.d.ts +3 -0
  139. package/dist/agent/tools/search.d.ts.map +1 -0
  140. package/dist/agent/tools/search.js +124 -0
  141. package/dist/agent/tools/search.js.map +1 -0
  142. package/dist/agent/tools/shell.d.ts +3 -0
  143. package/dist/agent/tools/shell.d.ts.map +1 -0
  144. package/dist/agent/tools/shell.js +60 -0
  145. package/dist/agent/tools/shell.js.map +1 -0
  146. package/dist/agent/tools/skills.d.ts +3 -0
  147. package/dist/agent/tools/skills.d.ts.map +1 -0
  148. package/dist/agent/tools/skills.js +27 -0
  149. package/dist/agent/tools/skills.js.map +1 -0
  150. package/dist/agent/tools/types.d.ts +8 -0
  151. package/dist/agent/tools/types.d.ts.map +1 -0
  152. package/dist/agent/tools/types.js +2 -0
  153. package/dist/agent/tools/types.js.map +1 -0
  154. package/dist/agent/tools/zerg.d.ts +3 -0
  155. package/dist/agent/tools/zerg.d.ts.map +1 -0
  156. package/dist/agent/tools/zerg.js +47 -0
  157. package/dist/agent/tools/zerg.js.map +1 -0
  158. package/dist/cli.d.ts +3 -0
  159. package/dist/cli.d.ts.map +1 -0
  160. package/dist/cli.js +75 -0
  161. package/dist/cli.js.map +1 -0
  162. package/dist/components/FullScreen.d.ts +28 -0
  163. package/dist/components/FullScreen.d.ts.map +1 -0
  164. package/dist/components/FullScreen.js +40 -0
  165. package/dist/components/FullScreen.js.map +1 -0
  166. package/dist/components/Header.d.ts +10 -0
  167. package/dist/components/Header.d.ts.map +1 -0
  168. package/dist/components/Header.js +14 -0
  169. package/dist/components/Header.js.map +1 -0
  170. package/dist/components/InputArea.d.ts +24 -0
  171. package/dist/components/InputArea.d.ts.map +1 -0
  172. package/dist/components/InputArea.js +476 -0
  173. package/dist/components/InputArea.js.map +1 -0
  174. package/dist/components/MessageList.d.ts +12 -0
  175. package/dist/components/MessageList.d.ts.map +1 -0
  176. package/dist/components/MessageList.js +9 -0
  177. package/dist/components/MessageList.js.map +1 -0
  178. package/dist/components/StatusBar.d.ts +18 -0
  179. package/dist/components/StatusBar.d.ts.map +1 -0
  180. package/dist/components/StatusBar.js +21 -0
  181. package/dist/components/StatusBar.js.map +1 -0
  182. package/dist/components/index.d.ts +6 -0
  183. package/dist/components/index.d.ts.map +1 -0
  184. package/dist/components/index.js +7 -0
  185. package/dist/components/index.js.map +1 -0
  186. package/dist/config/types.d.ts +12 -0
  187. package/dist/config/types.d.ts.map +1 -0
  188. package/dist/config/types.js +2 -0
  189. package/dist/config/types.js.map +1 -0
  190. package/dist/config.d.ts +28 -0
  191. package/dist/config.d.ts.map +1 -0
  192. package/dist/config.js +155 -0
  193. package/dist/config.js.map +1 -0
  194. package/dist/debug/logger.d.ts +2 -0
  195. package/dist/debug/logger.d.ts.map +1 -0
  196. package/dist/debug/logger.js +15 -0
  197. package/dist/debug/logger.js.map +1 -0
  198. package/dist/emulation/catalog.d.ts +4 -0
  199. package/dist/emulation/catalog.d.ts.map +1 -0
  200. package/dist/emulation/catalog.js +68 -0
  201. package/dist/emulation/catalog.js.map +1 -0
  202. package/dist/emulation/trace_style.d.ts +3 -0
  203. package/dist/emulation/trace_style.d.ts.map +1 -0
  204. package/dist/emulation/trace_style.js +10 -0
  205. package/dist/emulation/trace_style.js.map +1 -0
  206. package/dist/emulation/types.d.ts +8 -0
  207. package/dist/emulation/types.d.ts.map +1 -0
  208. package/dist/emulation/types.js +2 -0
  209. package/dist/emulation/types.js.map +1 -0
  210. package/dist/skills/index.d.ts +5 -0
  211. package/dist/skills/index.d.ts.map +1 -0
  212. package/dist/skills/index.js +36 -0
  213. package/dist/skills/index.js.map +1 -0
  214. package/dist/skills/loader.d.ts +3 -0
  215. package/dist/skills/loader.d.ts.map +1 -0
  216. package/dist/skills/loader.js +137 -0
  217. package/dist/skills/loader.js.map +1 -0
  218. package/dist/skills/registry.d.ts +3 -0
  219. package/dist/skills/registry.d.ts.map +1 -0
  220. package/dist/skills/registry.js +5 -0
  221. package/dist/skills/registry.js.map +1 -0
  222. package/dist/skills/types.d.ts +11 -0
  223. package/dist/skills/types.d.ts.map +1 -0
  224. package/dist/skills/types.js +2 -0
  225. package/dist/skills/types.js.map +1 -0
  226. package/dist/types.d.ts +93 -0
  227. package/dist/types.d.ts.map +1 -0
  228. package/dist/types.js +5 -0
  229. package/dist/types.js.map +1 -0
  230. package/dist/ui/core/factory.d.ts +4 -0
  231. package/dist/ui/core/factory.d.ts.map +1 -0
  232. package/dist/ui/core/factory.js +7 -0
  233. package/dist/ui/core/factory.js.map +1 -0
  234. package/dist/ui/core/index.d.ts +5 -0
  235. package/dist/ui/core/index.d.ts.map +1 -0
  236. package/dist/ui/core/index.js +4 -0
  237. package/dist/ui/core/index.js.map +1 -0
  238. package/dist/ui/core/input.d.ts +22 -0
  239. package/dist/ui/core/input.d.ts.map +1 -0
  240. package/dist/ui/core/input.js +15 -0
  241. package/dist/ui/core/input.js.map +1 -0
  242. package/dist/ui/core/input_segments.d.ts +19 -0
  243. package/dist/ui/core/input_segments.d.ts.map +1 -0
  244. package/dist/ui/core/input_segments.js +367 -0
  245. package/dist/ui/core/input_segments.js.map +1 -0
  246. package/dist/ui/core/input_state.d.ts +24 -0
  247. package/dist/ui/core/input_state.d.ts.map +1 -0
  248. package/dist/ui/core/input_state.js +2 -0
  249. package/dist/ui/core/input_state.js.map +1 -0
  250. package/dist/ui/core/layout_yoga.d.ts +11 -0
  251. package/dist/ui/core/layout_yoga.d.ts.map +1 -0
  252. package/dist/ui/core/layout_yoga.js +102 -0
  253. package/dist/ui/core/layout_yoga.js.map +1 -0
  254. package/dist/ui/core/style.d.ts +3 -0
  255. package/dist/ui/core/style.d.ts.map +1 -0
  256. package/dist/ui/core/style.js +37 -0
  257. package/dist/ui/core/style.js.map +1 -0
  258. package/dist/ui/core/types.d.ts +50 -0
  259. package/dist/ui/core/types.d.ts.map +1 -0
  260. package/dist/ui/core/types.js +2 -0
  261. package/dist/ui/core/types.js.map +1 -0
  262. package/dist/ui/ink/index.d.ts +2 -0
  263. package/dist/ui/ink/index.d.ts.map +1 -0
  264. package/dist/ui/ink/index.js +2 -0
  265. package/dist/ui/ink/index.js.map +1 -0
  266. package/dist/ui/ink/render.d.ts +6 -0
  267. package/dist/ui/ink/render.d.ts.map +1 -0
  268. package/dist/ui/ink/render.js +14 -0
  269. package/dist/ui/ink/render.js.map +1 -0
  270. package/dist/ui/views/app.d.ts +28 -0
  271. package/dist/ui/views/app.d.ts.map +1 -0
  272. package/dist/ui/views/app.js +59 -0
  273. package/dist/ui/views/app.js.map +1 -0
  274. package/dist/ui/views/header.d.ts +11 -0
  275. package/dist/ui/views/header.d.ts.map +1 -0
  276. package/dist/ui/views/header.js +28 -0
  277. package/dist/ui/views/header.js.map +1 -0
  278. package/dist/ui/views/input_area.d.ts +45 -0
  279. package/dist/ui/views/input_area.d.ts.map +1 -0
  280. package/dist/ui/views/input_area.js +183 -0
  281. package/dist/ui/views/input_area.js.map +1 -0
  282. package/dist/ui/views/message_list.d.ts +12 -0
  283. package/dist/ui/views/message_list.d.ts.map +1 -0
  284. package/dist/ui/views/message_list.js +381 -0
  285. package/dist/ui/views/message_list.js.map +1 -0
  286. package/dist/ui/views/status_bar.d.ts +18 -0
  287. package/dist/ui/views/status_bar.d.ts.map +1 -0
  288. package/dist/ui/views/status_bar.js +72 -0
  289. package/dist/ui/views/status_bar.js.map +1 -0
  290. package/dist/ui/vue/index.d.ts +5 -0
  291. package/dist/ui/vue/index.d.ts.map +1 -0
  292. package/dist/ui/vue/index.js +50 -0
  293. package/dist/ui/vue/index.js.map +1 -0
  294. package/dist/utils/clipboard.d.ts +2 -0
  295. package/dist/utils/clipboard.d.ts.map +1 -0
  296. package/dist/utils/clipboard.js +39 -0
  297. package/dist/utils/clipboard.js.map +1 -0
  298. package/dist/utils/clipboard_image.d.ts +2 -0
  299. package/dist/utils/clipboard_image.d.ts.map +1 -0
  300. package/dist/utils/clipboard_image.js +37 -0
  301. package/dist/utils/clipboard_image.js.map +1 -0
  302. package/dist/utils/diff.d.ts +2 -0
  303. package/dist/utils/diff.d.ts.map +1 -0
  304. package/dist/utils/diff.js +49 -0
  305. package/dist/utils/diff.js.map +1 -0
  306. package/dist/utils/image_preview.d.ts +2 -0
  307. package/dist/utils/image_preview.d.ts.map +1 -0
  308. package/dist/utils/image_preview.js +37 -0
  309. package/dist/utils/image_preview.js.map +1 -0
  310. package/dist/utils/models.d.ts +8 -0
  311. package/dist/utils/models.d.ts.map +1 -0
  312. package/dist/utils/models.js +85 -0
  313. package/dist/utils/models.js.map +1 -0
  314. package/dist/utils/shell.d.ts +4 -0
  315. package/dist/utils/shell.d.ts.map +1 -0
  316. package/dist/utils/shell.js +57 -0
  317. package/dist/utils/shell.js.map +1 -0
  318. package/dist/utils/tool_summary.d.ts +3 -0
  319. package/dist/utils/tool_summary.d.ts.map +1 -0
  320. package/dist/utils/tool_summary.js +54 -0
  321. package/dist/utils/tool_summary.js.map +1 -0
  322. package/dist/utils/tool_trace.d.ts +9 -0
  323. package/dist/utils/tool_trace.d.ts.map +1 -0
  324. package/dist/utils/tool_trace.js +183 -0
  325. package/dist/utils/tool_trace.js.map +1 -0
  326. package/package.json +41 -0
  327. package/src/App.tsx +576 -0
  328. package/src/agent/agent.ts +407 -0
  329. package/src/agent/backends/anthropic.ts +76 -0
  330. package/src/agent/backends/gemini.ts +107 -0
  331. package/src/agent/backends/inception.ts +23 -0
  332. package/src/agent/backends/index.ts +16 -0
  333. package/src/agent/backends/openai.ts +23 -0
  334. package/src/agent/backends/openai_compatible.ts +131 -0
  335. package/src/agent/backends/types.ts +59 -0
  336. package/src/agent/commands/clipboard.ts +77 -0
  337. package/src/agent/commands/config.ts +130 -0
  338. package/src/agent/commands/debug.ts +23 -0
  339. package/src/agent/commands/emulation.ts +80 -0
  340. package/src/agent/commands/execution.ts +9 -0
  341. package/src/agent/commands/help.ts +20 -0
  342. package/src/agent/commands/history.ts +13 -0
  343. package/src/agent/commands/index.ts +40 -0
  344. package/src/agent/commands/model.ts +11 -0
  345. package/src/agent/commands/models.ts +116 -0
  346. package/src/agent/commands/permissions.ts +64 -0
  347. package/src/agent/commands/retry.ts +9 -0
  348. package/src/agent/commands/shell.ts +68 -0
  349. package/src/agent/commands/skills.ts +54 -0
  350. package/src/agent/commands/status.ts +19 -0
  351. package/src/agent/commands/types.ts +78 -0
  352. package/src/agent/factory.ts +60 -0
  353. package/src/agent/index.ts +20 -0
  354. package/src/agent/runtime/capabilities.ts +6 -0
  355. package/src/agent/runtime/memory.ts +23 -0
  356. package/src/agent/runtime/policy.ts +48 -0
  357. package/src/agent/runtime/session.ts +18 -0
  358. package/src/agent/runtime/tracing.ts +23 -0
  359. package/src/agent/tools/file.ts +173 -0
  360. package/src/agent/tools/index.ts +46 -0
  361. package/src/agent/tools/search.ts +137 -0
  362. package/src/agent/tools/shell.ts +65 -0
  363. package/src/agent/tools/skills.ts +28 -0
  364. package/src/agent/tools/types.ts +10 -0
  365. package/src/agent/tools/zerg.ts +50 -0
  366. package/src/cli.tsx +80 -0
  367. package/src/components/FullScreen.tsx +73 -0
  368. package/src/components/Header.tsx +27 -0
  369. package/src/components/InputArea.tsx +551 -0
  370. package/src/components/MessageList.tsx +25 -0
  371. package/src/components/StatusBar.tsx +49 -0
  372. package/src/components/index.tsx +6 -0
  373. package/src/config/types.ts +11 -0
  374. package/src/config.ts +178 -0
  375. package/src/debug/logger.ts +14 -0
  376. package/src/emulation/README.md +24 -0
  377. package/src/emulation/catalog.ts +82 -0
  378. package/src/emulation/trace_style.ts +8 -0
  379. package/src/emulation/types.ts +7 -0
  380. package/src/skills/index.ts +36 -0
  381. package/src/skills/loader.ts +135 -0
  382. package/src/skills/registry.ts +6 -0
  383. package/src/skills/types.ts +10 -0
  384. package/src/types.ts +83 -0
  385. package/src/ui/README.md +44 -0
  386. package/src/ui/core/factory.ts +9 -0
  387. package/src/ui/core/index.ts +4 -0
  388. package/src/ui/core/input.ts +38 -0
  389. package/src/ui/core/input_segments.ts +375 -0
  390. package/src/ui/core/input_state.ts +17 -0
  391. package/src/ui/core/layout_yoga.ts +122 -0
  392. package/src/ui/core/style.ts +38 -0
  393. package/src/ui/core/types.ts +53 -0
  394. package/src/ui/ink/index.tsx +1 -0
  395. package/src/ui/ink/render.tsx +49 -0
  396. package/src/ui/views/app.ts +99 -0
  397. package/src/ui/views/header.ts +42 -0
  398. package/src/ui/views/input_area.ts +244 -0
  399. package/src/ui/views/message_list.ts +427 -0
  400. package/src/ui/views/status_bar.ts +104 -0
  401. package/src/ui/vue/index.ts +53 -0
  402. package/src/utils/clipboard.ts +39 -0
  403. package/src/utils/clipboard_image.ts +40 -0
  404. package/src/utils/diff.ts +52 -0
  405. package/src/utils/image_preview.ts +36 -0
  406. package/src/utils/models.ts +98 -0
  407. package/src/utils/shell.ts +63 -0
  408. package/src/utils/tool_summary.ts +56 -0
  409. package/src/utils/tool_trace.ts +206 -0
  410. package/tsconfig.json +22 -0
  411. package/vite.config.ts +363 -0
@@ -0,0 +1,52 @@
1
+ interface DiffLine {
2
+ type: 'context' | 'add' | 'remove';
3
+ text: string;
4
+ }
5
+
6
+ export function buildSimpleDiff(before: string, after: string, maxLines = 120, context = 2): string {
7
+ const beforeLines = before.split('\n');
8
+ const afterLines = after.split('\n');
9
+ const maxLen = Math.max(beforeLines.length, afterLines.length);
10
+
11
+ const changes = new Set<number>();
12
+ for (let i = 0; i < maxLen; i += 1) {
13
+ const b = beforeLines[i];
14
+ const a = afterLines[i];
15
+ if (b !== a) {
16
+ changes.add(i);
17
+ }
18
+ }
19
+
20
+ const include = new Set<number>();
21
+ for (const idx of changes) {
22
+ for (let i = Math.max(0, idx - context); i <= idx + context; i += 1) {
23
+ include.add(i);
24
+ }
25
+ }
26
+
27
+ const lines: DiffLine[] = [];
28
+ for (let i = 0; i < maxLen; i += 1) {
29
+ if (!include.has(i)) continue;
30
+ const b = beforeLines[i];
31
+ const a = afterLines[i];
32
+ if (b === a) {
33
+ lines.push({ type: 'context', text: b || '' });
34
+ } else {
35
+ if (b !== undefined) lines.push({ type: 'remove', text: b || '' });
36
+ if (a !== undefined) lines.push({ type: 'add', text: a || '' });
37
+ }
38
+ }
39
+
40
+ const clipped = lines.slice(0, maxLines);
41
+ if (lines.length > maxLines) {
42
+ clipped.push({ type: 'context', text: '... diff truncated ...' });
43
+ }
44
+
45
+ return clipped
46
+ .map(line => {
47
+ if (line.type === 'add') return `+ ${line.text}`;
48
+ if (line.type === 'remove') return `- ${line.text}`;
49
+ return ` ${line.text}`;
50
+ })
51
+ .join('\n');
52
+ }
@@ -0,0 +1,36 @@
1
+ import { execFile } from 'child_process';
2
+ import { promisify } from 'util';
3
+
4
+ const execFileAsync = promisify(execFile);
5
+ const cache = new Map<string, string[]>();
6
+
7
+ async function hasCommand(command: string): Promise<boolean> {
8
+ try {
9
+ await execFileAsync('which', [command]);
10
+ return true;
11
+ } catch {
12
+ return false;
13
+ }
14
+ }
15
+
16
+ export async function renderImagePreview(path: string, width = 40, height = 20): Promise<string[] | null> {
17
+ const key = `${path}:${width}x${height}`;
18
+ const cached = cache.get(key);
19
+ if (cached) return cached;
20
+ if (!(await hasCommand('chafa'))) {
21
+ return null;
22
+ }
23
+ try {
24
+ const { stdout } = await execFileAsync('chafa', [
25
+ '--colors=none',
26
+ '--symbols=block',
27
+ `--size=${width}x${height}`,
28
+ path
29
+ ]);
30
+ const lines = stdout.split('\n').filter(line => line.length > 0);
31
+ cache.set(key, lines);
32
+ return lines;
33
+ } catch {
34
+ return null;
35
+ }
36
+ }
@@ -0,0 +1,98 @@
1
+ interface ListModelsOptions {
2
+ provider: string;
3
+ apiKey?: string;
4
+ baseUrl?: string;
5
+ }
6
+
7
+ async function parseList(response: Response): Promise<string[]> {
8
+ const data = await response.json() as Record<string, unknown>;
9
+ const array =
10
+ (Array.isArray(data.data) && data.data) ||
11
+ (Array.isArray(data.models) && data.models) ||
12
+ (Array.isArray(data.items) && data.items) ||
13
+ [];
14
+
15
+ const models = array
16
+ .map(item => {
17
+ if (typeof item === 'string') return item;
18
+ if (item && typeof item === 'object') {
19
+ const obj = item as Record<string, unknown>;
20
+ if (typeof obj.id === 'string') return obj.id;
21
+ if (typeof obj.name === 'string') return obj.name;
22
+ }
23
+ return null;
24
+ })
25
+ .filter((value): value is string => typeof value === 'string');
26
+
27
+ return models;
28
+ }
29
+
30
+ export async function listModels(options: ListModelsOptions): Promise<string[]> {
31
+ const provider = options.provider;
32
+ const apiKey = options.apiKey || '';
33
+
34
+ if (!apiKey) {
35
+ throw new Error(`No API key configured for ${provider}`);
36
+ }
37
+
38
+ if (provider === 'anthropic') {
39
+ const res = await fetch('https://api.anthropic.com/v1/models', {
40
+ headers: {
41
+ 'x-api-key': apiKey,
42
+ 'anthropic-version': '2023-06-01'
43
+ }
44
+ });
45
+ if (!res.ok) {
46
+ throw new Error(`Anthropic error (${res.status})`);
47
+ }
48
+ return parseList(res);
49
+ }
50
+
51
+ if (provider === 'openai') {
52
+ const res = await fetch('https://api.openai.com/v1/models', {
53
+ headers: {
54
+ Authorization: `Bearer ${apiKey}`
55
+ }
56
+ });
57
+ if (!res.ok) {
58
+ throw new Error(`OpenAI error (${res.status})`);
59
+ }
60
+ return parseList(res);
61
+ }
62
+
63
+ if (provider === 'openai_compatible') {
64
+ const baseUrl = options.baseUrl || 'https://api.openai.com/v1';
65
+ const res = await fetch(`${baseUrl.replace(/\/$/, '')}/models`, {
66
+ headers: {
67
+ Authorization: `Bearer ${apiKey}`
68
+ }
69
+ });
70
+ if (!res.ok) {
71
+ throw new Error(`OpenAI-compatible error (${res.status})`);
72
+ }
73
+ return parseList(res);
74
+ }
75
+
76
+ if (provider === 'gemini') {
77
+ const res = await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${apiKey}`);
78
+ if (!res.ok) {
79
+ throw new Error(`Gemini error (${res.status})`);
80
+ }
81
+ return parseList(res);
82
+ }
83
+
84
+ if (provider === 'inception') {
85
+ const baseUrl = options.baseUrl || 'https://api.inception.ai/v1';
86
+ const res = await fetch(`${baseUrl.replace(/\/$/, '')}/models`, {
87
+ headers: {
88
+ Authorization: `Bearer ${apiKey}`
89
+ }
90
+ });
91
+ if (!res.ok) {
92
+ throw new Error(`Inception error (${res.status})`);
93
+ }
94
+ return parseList(res);
95
+ }
96
+
97
+ throw new Error(`Unknown provider: ${provider}`);
98
+ }
@@ -0,0 +1,63 @@
1
+ import { exec, ExecException } from 'child_process';
2
+ import { promisify } from 'util';
3
+ import { resolve } from 'path';
4
+ import { stat } from 'fs/promises';
5
+
6
+ import type { ShellResult } from '../agent/commands/types.js';
7
+
8
+ const execAsync = promisify(exec);
9
+
10
+ const MAX_BUFFER = 1024 * 1024;
11
+ const MAX_OUTPUT = 10000;
12
+ const DEFAULT_TIMEOUT_MS = 30000;
13
+ const DANGEROUS = ['rm -rf /', 'mkfs', ':(){:|:&};:'];
14
+
15
+ export async function runShellCommand(command: string, cwd: string): Promise<ShellResult> {
16
+ if (DANGEROUS.some(entry => command.includes(entry))) {
17
+ throw new Error('Command rejected for safety reasons');
18
+ }
19
+
20
+ const resolvedCwd = resolve(cwd);
21
+
22
+ try {
23
+ const { stdout, stderr } = await execAsync(command, {
24
+ cwd: resolvedCwd,
25
+ timeout: DEFAULT_TIMEOUT_MS,
26
+ maxBuffer: MAX_BUFFER
27
+ });
28
+ const clippedStdout = stdout.slice(0, MAX_OUTPUT);
29
+ const clippedStderr = stderr.slice(0, MAX_OUTPUT);
30
+ return {
31
+ command,
32
+ cwd: resolvedCwd,
33
+ stdout: clippedStdout,
34
+ stderr: clippedStderr,
35
+ exitCode: 0,
36
+ truncated: stdout.length > MAX_OUTPUT || stderr.length > MAX_OUTPUT
37
+ };
38
+ } catch (err) {
39
+ const error = err as ExecException & { stdout?: string; stderr?: string; code?: number };
40
+ const stdout = String(error.stdout || '');
41
+ const stderr = String(error.stderr || error.message || '');
42
+ const clippedStdout = stdout.slice(0, MAX_OUTPUT);
43
+ const clippedStderr = stderr.slice(0, MAX_OUTPUT);
44
+ return {
45
+ command,
46
+ cwd: resolvedCwd,
47
+ stdout: clippedStdout,
48
+ stderr: clippedStderr,
49
+ exitCode: typeof error.code === 'number' ? error.code : 1,
50
+ truncated: stdout.length > MAX_OUTPUT || stderr.length > MAX_OUTPUT
51
+ };
52
+ }
53
+ }
54
+
55
+ export async function resolveWorkingDir(current: string, target?: string): Promise<string> {
56
+ const base = current || process.cwd();
57
+ const next = target && target.trim().length > 0 ? resolve(base, target) : base;
58
+ const info = await stat(next);
59
+ if (!info.isDirectory()) {
60
+ throw new Error('Not a directory');
61
+ }
62
+ return next;
63
+ }
@@ -0,0 +1,56 @@
1
+ type ParsedResult = Record<string, unknown>;
2
+
3
+ function parseResult(raw: string): ParsedResult | null {
4
+ try {
5
+ const data = JSON.parse(raw) as ParsedResult;
6
+ if (data && typeof data === 'object') return data;
7
+ } catch {
8
+ return null;
9
+ }
10
+ return null;
11
+ }
12
+
13
+ export function summarizeToolResult(tool: string, raw: string): string {
14
+ const parsed = parseResult(raw);
15
+ if (!parsed) {
16
+ const trimmed = raw.trim();
17
+ return trimmed.length > 140 ? `${trimmed.slice(0, 140)}...` : trimmed || 'Done';
18
+ }
19
+
20
+ if (tool === 'read_file') {
21
+ const path = String(parsed.path || '');
22
+ const size = parsed.size ? ` (${parsed.size} bytes)` : '';
23
+ return `Read ${path}${size}`;
24
+ }
25
+ if (tool === 'write_file') {
26
+ const path = String(parsed.path || '');
27
+ const action = String(parsed.action || 'written');
28
+ return `Wrote ${path} (${action})`;
29
+ }
30
+ if (tool === 'list_directory') {
31
+ const path = String(parsed.path || '');
32
+ const entries = Array.isArray(parsed.entries) ? parsed.entries.length : 0;
33
+ return `Listed ${path} (${entries} items)`;
34
+ }
35
+ if (tool === 'run_command') {
36
+ const cwd = String(parsed.cwd || '');
37
+ const cmd = String(parsed.command || '');
38
+ return `Ran ${cmd}${cwd ? ` (cwd ${cwd})` : ''}`;
39
+ }
40
+ if (tool === 'search') {
41
+ const count = parsed.count ? String(parsed.count) : '0';
42
+ const path = String(parsed.path || '');
43
+ return `Found ${count} matches${path ? ` in ${path}` : ''}`;
44
+ }
45
+
46
+ const fallback = raw.trim();
47
+ return fallback.length > 140 ? `${fallback.slice(0, 140)}...` : fallback || 'Done';
48
+ }
49
+
50
+ export function summarizeToolArgs(args: Record<string, unknown>): string {
51
+ const entries = Object.entries(args)
52
+ .map(([key, value]) => `${key}=${String(value)}`)
53
+ .slice(0, 3);
54
+ if (entries.length === 0) return '';
55
+ return `(${entries.join(', ')}${Object.keys(args).length > 3 ? ', ...' : ''})`;
56
+ }
@@ -0,0 +1,206 @@
1
+ import { getTraceStyle, TraceStyle } from '../emulation/trace_style.js';
2
+
3
+ const toolLabels: Record<string, string> = {
4
+ run_command: 'Bash',
5
+ read_file: 'Read',
6
+ write_file: 'Update',
7
+ list_directory: 'List',
8
+ search: 'Search'
9
+ };
10
+
11
+ function formatValue(value: unknown): string {
12
+ if (typeof value === 'string') {
13
+ const escaped = value.replace(/\n/g, '\\n');
14
+ return `"${escaped}"`;
15
+ }
16
+ if (typeof value === 'number' || typeof value === 'boolean') {
17
+ return String(value);
18
+ }
19
+ return JSON.stringify(value);
20
+ }
21
+
22
+ function formatArgs(tool: string, args: Record<string, unknown>): string {
23
+ if (tool === 'run_command') {
24
+ const command = args.command ? String(args.command) : '';
25
+ const cwd = args.cwd ? `, cwd: ${formatValue(args.cwd)}` : '';
26
+ const timeout = args.timeout ? `, timeout: ${formatValue(args.timeout)}` : '';
27
+ return `(${command}${cwd}${timeout})`;
28
+ }
29
+ if (tool === 'search') {
30
+ const pattern = args.pattern ? `pattern: ${formatValue(args.pattern)}` : '';
31
+ const path = args.path ? `path: ${formatValue(args.path)}` : '';
32
+ const output = args.output_mode ? `output_mode: ${formatValue(args.output_mode)}` : '';
33
+ const parts = [pattern, path, output].filter(Boolean);
34
+ return parts.length ? `(${parts.join(', ')})` : '';
35
+ }
36
+ if (tool === 'read_file' || tool === 'write_file' || tool === 'list_directory') {
37
+ const path = args.path ? formatValue(args.path) : '""';
38
+ return `(${path})`;
39
+ }
40
+
41
+ const entries = Object.entries(args).map(([key, value]) => `${key}: ${formatValue(value)}`);
42
+ return entries.length ? `(${entries.join(', ')})` : '';
43
+ }
44
+
45
+ function parseResult(raw: string): Record<string, unknown> | null {
46
+ try {
47
+ const data = JSON.parse(raw) as Record<string, unknown>;
48
+ if (data && typeof data === 'object') return data;
49
+ } catch {
50
+ return null;
51
+ }
52
+ return null;
53
+ }
54
+
55
+ function formatOutcome(tool: string, result: string, durationMs?: number): string {
56
+ const parsed = parseResult(result);
57
+ const duration = typeof durationMs === 'number' ? ` in ${(durationMs / 1000).toFixed(1)}s` : '';
58
+
59
+ if (parsed && tool === 'search') {
60
+ const count = typeof parsed.count === 'number' ? parsed.count : 0;
61
+ const label = count === 1 ? 'match' : 'matches';
62
+ return `Found ${count} ${label}${duration}`;
63
+ }
64
+ if (parsed && tool === 'run_command') {
65
+ const stdout = String(parsed.stdout || '');
66
+ const stderr = String(parsed.stderr || '');
67
+ const lines = (stdout || stderr).trim().split('\n').filter(Boolean).length;
68
+ const label = lines === 1 ? 'line' : 'lines';
69
+ return lines > 0 ? `Output ${lines} ${label}${duration}` : `Command finished${duration}`;
70
+ }
71
+ if (parsed && tool === 'read_file') {
72
+ const path = String(parsed.path || '');
73
+ const size = parsed.size ? `${parsed.size} bytes` : 'unknown size';
74
+ const truncated = parsed.truncated ? ' (truncated)' : '';
75
+ return `Read ${path} (${size})${duration}${truncated}`;
76
+ }
77
+ if (parsed && tool === 'write_file') {
78
+ const path = String(parsed.path || '');
79
+ const action = String(parsed.action || 'written');
80
+ return `Updated ${path} (${action})${duration}`;
81
+ }
82
+ if (parsed && tool === 'list_directory') {
83
+ const path = String(parsed.path || '');
84
+ const entries = Array.isArray(parsed.entries) ? parsed.entries.length : 0;
85
+ return `Listed ${path} (${entries} items)${duration}`;
86
+ }
87
+
88
+ return `Done${duration}`;
89
+ }
90
+
91
+ function buildOutputLines(tool: string, result: string): { lines: string[]; truncated: boolean } {
92
+ const parsed = parseResult(result);
93
+ if (!parsed) {
94
+ return { lines: [], truncated: false };
95
+ }
96
+
97
+ if (tool === 'run_command') {
98
+ const stdout = String(parsed.stdout || '');
99
+ const stderr = String(parsed.stderr || '');
100
+ const combined = [stdout, stderr].filter(Boolean).join('\n');
101
+ const lines = combined.split('\n').filter(Boolean);
102
+ return { lines, truncated: Boolean(parsed.truncated) };
103
+ }
104
+
105
+ if (tool === 'search') {
106
+ const matches = Array.isArray(parsed.matches) ? parsed.matches : [];
107
+ const lines = matches.map((entry: unknown) => {
108
+ if (!entry || typeof entry !== 'object') return '';
109
+ const row = entry as Record<string, unknown>;
110
+ const file = String(row.path || '');
111
+ const line = row.line ? `:${row.line}` : '';
112
+ const text = String(row.text || '');
113
+ return `${file}${line} ${text}`.trim();
114
+ }).filter(Boolean);
115
+ return { lines, truncated: Boolean(parsed.truncated) };
116
+ }
117
+
118
+ if (tool === 'read_file') {
119
+ const content = String(parsed.content || '');
120
+ const lines = content.split('\n');
121
+ return { lines, truncated: Boolean(parsed.truncated) };
122
+ }
123
+
124
+ if (tool === 'write_file') {
125
+ const diff = typeof parsed.diff === 'string' ? parsed.diff : '';
126
+ const lines = diff ? diff.split('\n') : [];
127
+ return { lines, truncated: Boolean(parsed.truncated) };
128
+ }
129
+
130
+ return { lines: [], truncated: false };
131
+ }
132
+
133
+ export function formatToolStart(tool: string, args: Record<string, unknown>, emulationId?: string): string {
134
+ const style = getTraceStyle(emulationId);
135
+ const label = toolLabels[tool] || tool;
136
+ const argsText = formatArgs(tool, args);
137
+ if (style === 'claude_code') {
138
+ return `⏺ ${label}${argsText}`;
139
+ }
140
+ if (style === 'codex') {
141
+ return `• ${label}${argsText}`;
142
+ }
143
+ return `> ${label}${argsText}`;
144
+ }
145
+
146
+ export function formatToolEnd(tool: string, result: string, durationMs?: number, emulationId?: string): string {
147
+ const style = getTraceStyle(emulationId);
148
+ const summary = formatOutcome(tool, result, durationMs);
149
+ if (style === 'claude_code') {
150
+ return `⎿ ${summary}`;
151
+ }
152
+ if (style === 'codex') {
153
+ return ` ${summary}`;
154
+ }
155
+ return `< ${summary}`;
156
+ }
157
+
158
+ export function formatToolError(tool: string, error: string, emulationId?: string): string {
159
+ const style = getTraceStyle(emulationId);
160
+ if (style === 'claude_code') {
161
+ return `⎿ ${tool} failed: ${error}`;
162
+ }
163
+ if (style === 'codex') {
164
+ return ` ${tool} failed: ${error}`;
165
+ }
166
+ return `< ${tool} failed: ${error}`;
167
+ }
168
+
169
+ export function buildToolOutputMessage(
170
+ tool: string,
171
+ result: string,
172
+ durationMs?: number,
173
+ emulationId?: string
174
+ ): { preview: string; full: string; truncated: boolean } {
175
+ const { lines, truncated } = buildOutputLines(tool, result);
176
+ if (lines.length === 0) {
177
+ const summary = formatToolEnd(tool, result, durationMs, emulationId);
178
+ return { preview: summary, full: summary, truncated: false };
179
+ }
180
+
181
+ const maxLines = 8;
182
+ const previewLines = lines.slice(0, maxLines);
183
+ const remaining = lines.length - previewLines.length;
184
+ const expandHint = truncated || remaining > 0 ? ' (ctrl+o to expand)' : '';
185
+
186
+ const summary = formatToolEnd(tool, result, durationMs, emulationId);
187
+ const previewBlock = [
188
+ summary,
189
+ ...previewLines.map(line => ` ${line}`)
190
+ ];
191
+ if (expandHint) {
192
+ const extraLabel = remaining > 0 ? `… +${remaining} lines` : '…';
193
+ previewBlock.push(` ${extraLabel}${expandHint}`);
194
+ }
195
+
196
+ const fullBlock = [
197
+ summary,
198
+ ...lines.map(line => ` ${line}`)
199
+ ];
200
+
201
+ return {
202
+ preview: previewBlock.join('\n'),
203
+ full: fullBlock.join('\n'),
204
+ truncated: Boolean(expandHint)
205
+ };
206
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "lib": ["ES2022"],
7
+ "outDir": "./dist",
8
+ "rootDir": "./src",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "resolveJsonModule": true,
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "sourceMap": true,
17
+ "jsx": "react-jsx",
18
+ "jsxImportSource": "react"
19
+ },
20
+ "include": ["src/**/*"],
21
+ "exclude": ["node_modules", "dist"]
22
+ }