@odysx/codemind 0.0.0-stage → 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 (331) hide show
  1. package/README.md +293 -2
  2. package/dist/commands/agents.d.ts +2 -0
  3. package/dist/commands/agents.d.ts.map +1 -0
  4. package/dist/commands/agents.js +91 -0
  5. package/dist/commands/agents.js.map +1 -0
  6. package/dist/commands/auth.d.ts +2 -0
  7. package/dist/commands/auth.d.ts.map +1 -0
  8. package/dist/commands/auth.js +35 -0
  9. package/dist/commands/auth.js.map +1 -0
  10. package/dist/commands/chat.d.ts +2 -0
  11. package/dist/commands/chat.d.ts.map +1 -0
  12. package/dist/commands/chat.js +180 -0
  13. package/dist/commands/chat.js.map +1 -0
  14. package/dist/commands/keys.d.ts +2 -0
  15. package/dist/commands/keys.d.ts.map +1 -0
  16. package/dist/commands/keys.js +81 -0
  17. package/dist/commands/keys.js.map +1 -0
  18. package/dist/commands/local.d.ts +2 -0
  19. package/dist/commands/local.d.ts.map +1 -0
  20. package/dist/commands/local.js +325 -0
  21. package/dist/commands/local.js.map +1 -0
  22. package/dist/commands/mcp.d.ts +2 -0
  23. package/dist/commands/mcp.d.ts.map +1 -0
  24. package/dist/commands/mcp.js +73 -0
  25. package/dist/commands/mcp.js.map +1 -0
  26. package/dist/commands/prompts.d.ts +2 -0
  27. package/dist/commands/prompts.d.ts.map +1 -0
  28. package/dist/commands/prompts.js +59 -0
  29. package/dist/commands/prompts.js.map +1 -0
  30. package/dist/commands/skills.d.ts +2 -0
  31. package/dist/commands/skills.d.ts.map +1 -0
  32. package/dist/commands/skills.js +41 -0
  33. package/dist/commands/skills.js.map +1 -0
  34. package/dist/core/auth/index.d.ts +10 -0
  35. package/dist/core/auth/index.d.ts.map +1 -0
  36. package/dist/core/auth/index.js +82 -0
  37. package/dist/core/auth/index.js.map +1 -0
  38. package/dist/core/config/index.d.ts +47 -0
  39. package/dist/core/config/index.d.ts.map +1 -0
  40. package/dist/core/config/index.js +118 -0
  41. package/dist/core/config/index.js.map +1 -0
  42. package/dist/core/history.d.ts +14 -0
  43. package/dist/core/history.d.ts.map +1 -0
  44. package/dist/core/history.js +80 -0
  45. package/dist/core/history.js.map +1 -0
  46. package/dist/core/markdown-renderer.d.ts +47 -0
  47. package/dist/core/markdown-renderer.d.ts.map +1 -0
  48. package/dist/core/markdown-renderer.js +385 -0
  49. package/dist/core/markdown-renderer.js.map +1 -0
  50. package/dist/core/permissions/index.d.ts +31 -0
  51. package/dist/core/permissions/index.d.ts.map +1 -0
  52. package/dist/core/permissions/index.js +64 -0
  53. package/dist/core/permissions/index.js.map +1 -0
  54. package/dist/core/provider/external.d.ts +28 -0
  55. package/dist/core/provider/external.d.ts.map +1 -0
  56. package/dist/core/provider/external.js +248 -0
  57. package/dist/core/provider/external.js.map +1 -0
  58. package/dist/core/provider/index.d.ts +96 -0
  59. package/dist/core/provider/index.d.ts.map +1 -0
  60. package/dist/core/provider/index.js +423 -0
  61. package/dist/core/provider/index.js.map +1 -0
  62. package/dist/core/registry/index.d.ts +25 -0
  63. package/dist/core/registry/index.d.ts.map +1 -0
  64. package/dist/core/registry/index.js +216 -0
  65. package/dist/core/registry/index.js.map +1 -0
  66. package/dist/core/schema/types.d.ts +93 -0
  67. package/dist/core/schema/types.d.ts.map +1 -0
  68. package/dist/core/schema/types.js +12 -0
  69. package/dist/core/schema/types.js.map +1 -0
  70. package/dist/core/terminal.d.ts +40 -0
  71. package/dist/core/terminal.d.ts.map +1 -0
  72. package/dist/core/terminal.js +134 -0
  73. package/dist/core/terminal.js.map +1 -0
  74. package/dist/core/workspace/index.d.ts +35 -0
  75. package/dist/core/workspace/index.d.ts.map +1 -0
  76. package/dist/core/workspace/index.js +194 -0
  77. package/dist/core/workspace/index.js.map +1 -0
  78. package/dist/index.d.ts +10 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +393 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/ui/app.d.ts +3 -0
  83. package/dist/ui/app.d.ts.map +1 -0
  84. package/dist/ui/app.js +554 -0
  85. package/dist/ui/app.js.map +1 -0
  86. package/dist/ui/commands/cases/catalog.d.ts +11 -0
  87. package/dist/ui/commands/cases/catalog.d.ts.map +1 -0
  88. package/dist/ui/commands/cases/catalog.js +62 -0
  89. package/dist/ui/commands/cases/catalog.js.map +1 -0
  90. package/dist/ui/commands/cases/misc.d.ts +35 -0
  91. package/dist/ui/commands/cases/misc.d.ts.map +1 -0
  92. package/dist/ui/commands/cases/misc.js +245 -0
  93. package/dist/ui/commands/cases/misc.js.map +1 -0
  94. package/dist/ui/commands/cases/tasks.d.ts +13 -0
  95. package/dist/ui/commands/cases/tasks.d.ts.map +1 -0
  96. package/dist/ui/commands/cases/tasks.js +91 -0
  97. package/dist/ui/commands/cases/tasks.js.map +1 -0
  98. package/dist/ui/commands/runCommand.d.ts +22 -0
  99. package/dist/ui/commands/runCommand.d.ts.map +1 -0
  100. package/dist/ui/commands/runCommand.js +136 -0
  101. package/dist/ui/commands/runCommand.js.map +1 -0
  102. package/dist/ui/components/AgentPicker.d.ts +11 -0
  103. package/dist/ui/components/AgentPicker.d.ts.map +1 -0
  104. package/dist/ui/components/AgentPicker.js +7 -0
  105. package/dist/ui/components/AgentPicker.js.map +1 -0
  106. package/dist/ui/components/AuthPicker.d.ts +14 -0
  107. package/dist/ui/components/AuthPicker.d.ts.map +1 -0
  108. package/dist/ui/components/AuthPicker.js +7 -0
  109. package/dist/ui/components/AuthPicker.js.map +1 -0
  110. package/dist/ui/components/Banner.d.ts +8 -0
  111. package/dist/ui/components/Banner.d.ts.map +1 -0
  112. package/dist/ui/components/Banner.js +24 -0
  113. package/dist/ui/components/Banner.js.map +1 -0
  114. package/dist/ui/components/CommandMenu.d.ts +17 -0
  115. package/dist/ui/components/CommandMenu.d.ts.map +1 -0
  116. package/dist/ui/components/CommandMenu.js +21 -0
  117. package/dist/ui/components/CommandMenu.js.map +1 -0
  118. package/dist/ui/components/ErrorBoundary.d.ts +24 -0
  119. package/dist/ui/components/ErrorBoundary.d.ts.map +1 -0
  120. package/dist/ui/components/ErrorBoundary.js +51 -0
  121. package/dist/ui/components/ErrorBoundary.js.map +1 -0
  122. package/dist/ui/components/InputBar.d.ts +28 -0
  123. package/dist/ui/components/InputBar.d.ts.map +1 -0
  124. package/dist/ui/components/InputBar.js +108 -0
  125. package/dist/ui/components/InputBar.js.map +1 -0
  126. package/dist/ui/components/KeysPanel.d.ts +12 -0
  127. package/dist/ui/components/KeysPanel.d.ts.map +1 -0
  128. package/dist/ui/components/KeysPanel.js +25 -0
  129. package/dist/ui/components/KeysPanel.js.map +1 -0
  130. package/dist/ui/components/MessageView.d.ts +29 -0
  131. package/dist/ui/components/MessageView.d.ts.map +1 -0
  132. package/dist/ui/components/MessageView.js +107 -0
  133. package/dist/ui/components/MessageView.js.map +1 -0
  134. package/dist/ui/components/PermissionPrompt.d.ts +10 -0
  135. package/dist/ui/components/PermissionPrompt.d.ts.map +1 -0
  136. package/dist/ui/components/PermissionPrompt.js +4 -0
  137. package/dist/ui/components/PermissionPrompt.js.map +1 -0
  138. package/dist/ui/components/Pickers.d.ts +43 -0
  139. package/dist/ui/components/Pickers.d.ts.map +1 -0
  140. package/dist/ui/components/Pickers.js +33 -0
  141. package/dist/ui/components/Pickers.js.map +1 -0
  142. package/dist/ui/components/SearchOverlay.d.ts +21 -0
  143. package/dist/ui/components/SearchOverlay.d.ts.map +1 -0
  144. package/dist/ui/components/SearchOverlay.js +14 -0
  145. package/dist/ui/components/SearchOverlay.js.map +1 -0
  146. package/dist/ui/components/SessionPicker.d.ts +12 -0
  147. package/dist/ui/components/SessionPicker.d.ts.map +1 -0
  148. package/dist/ui/components/SessionPicker.js +8 -0
  149. package/dist/ui/components/SessionPicker.js.map +1 -0
  150. package/dist/ui/components/WorkingIndicator.d.ts +10 -0
  151. package/dist/ui/components/WorkingIndicator.d.ts.map +1 -0
  152. package/dist/ui/components/WorkingIndicator.js +23 -0
  153. package/dist/ui/components/WorkingIndicator.js.map +1 -0
  154. package/dist/ui/controls/ApiKeyEntry.d.ts +8 -0
  155. package/dist/ui/controls/ApiKeyEntry.d.ts.map +1 -0
  156. package/dist/ui/controls/ApiKeyEntry.js +5 -0
  157. package/dist/ui/controls/ApiKeyEntry.js.map +1 -0
  158. package/dist/ui/controls/MultiSelect.d.ts +18 -0
  159. package/dist/ui/controls/MultiSelect.d.ts.map +1 -0
  160. package/dist/ui/controls/MultiSelect.js +9 -0
  161. package/dist/ui/controls/MultiSelect.js.map +1 -0
  162. package/dist/ui/hooks/useAgentPicker.d.ts +14 -0
  163. package/dist/ui/hooks/useAgentPicker.d.ts.map +1 -0
  164. package/dist/ui/hooks/useAgentPicker.js +53 -0
  165. package/dist/ui/hooks/useAgentPicker.js.map +1 -0
  166. package/dist/ui/hooks/useAuthFlow.d.ts +14 -0
  167. package/dist/ui/hooks/useAuthFlow.d.ts.map +1 -0
  168. package/dist/ui/hooks/useAuthFlow.js +31 -0
  169. package/dist/ui/hooks/useAuthFlow.js.map +1 -0
  170. package/dist/ui/hooks/useKeysFlow.d.ts +17 -0
  171. package/dist/ui/hooks/useKeysFlow.d.ts.map +1 -0
  172. package/dist/ui/hooks/useKeysFlow.js +130 -0
  173. package/dist/ui/hooks/useKeysFlow.js.map +1 -0
  174. package/dist/ui/hooks/useSessionPicker.d.ts +29 -0
  175. package/dist/ui/hooks/useSessionPicker.d.ts.map +1 -0
  176. package/dist/ui/hooks/useSessionPicker.js +58 -0
  177. package/dist/ui/hooks/useSessionPicker.js.map +1 -0
  178. package/dist/ui/hooks/useTerminalSize.d.ts +6 -0
  179. package/dist/ui/hooks/useTerminalSize.d.ts.map +1 -0
  180. package/dist/ui/hooks/useTerminalSize.js +29 -0
  181. package/dist/ui/hooks/useTerminalSize.js.map +1 -0
  182. package/dist/ui/input/keyRouter.d.ts +125 -0
  183. package/dist/ui/input/keyRouter.d.ts.map +1 -0
  184. package/dist/ui/input/keyRouter.js +574 -0
  185. package/dist/ui/input/keyRouter.js.map +1 -0
  186. package/dist/ui/layouts/ScreenLayout.d.ts +98 -0
  187. package/dist/ui/layouts/ScreenLayout.d.ts.map +1 -0
  188. package/dist/ui/layouts/ScreenLayout.js +56 -0
  189. package/dist/ui/layouts/ScreenLayout.js.map +1 -0
  190. package/dist/ui/shared/types.d.ts +143 -0
  191. package/dist/ui/shared/types.d.ts.map +1 -0
  192. package/dist/ui/shared/types.js +38 -0
  193. package/dist/ui/shared/types.js.map +1 -0
  194. package/dist/ui/theme.d.ts +29 -0
  195. package/dist/ui/theme.d.ts.map +1 -0
  196. package/dist/ui/theme.js +54 -0
  197. package/dist/ui/theme.js.map +1 -0
  198. package/dist/ui/utils/markdown.d.ts +74 -0
  199. package/dist/ui/utils/markdown.d.ts.map +1 -0
  200. package/dist/ui/utils/markdown.js +187 -0
  201. package/dist/ui/utils/markdown.js.map +1 -0
  202. package/dist/ui/utils/mentions.d.ts +12 -0
  203. package/dist/ui/utils/mentions.d.ts.map +1 -0
  204. package/dist/ui/utils/mentions.js +28 -0
  205. package/dist/ui/utils/mentions.js.map +1 -0
  206. package/dist/ui/utils/terminal-text.d.ts +33 -0
  207. package/dist/ui/utils/terminal-text.d.ts.map +1 -0
  208. package/dist/ui/utils/terminal-text.js +123 -0
  209. package/dist/ui/utils/terminal-text.js.map +1 -0
  210. package/dist/ui/utils/text.d.ts +72 -0
  211. package/dist/ui/utils/text.d.ts.map +1 -0
  212. package/dist/ui/utils/text.js +171 -0
  213. package/dist/ui/utils/text.js.map +1 -0
  214. package/eslint.config.js +40 -0
  215. package/graphify-out/GRAPH_REPORT.md +140 -0
  216. package/graphify-out/cache/1236b1806943f8eb5c64fece9fb448149370f4a1b52b32f0977ad528d7911291.json +1 -0
  217. package/graphify-out/cache/15cbf641dcc0fd641c18da872214918203a1f64baa7ac8430e4702ef32d18b02.json +1 -0
  218. package/graphify-out/cache/1abc52745bb46f6cc5a528530e2bc1f368c26e348dff85cdde5cad6f275d7177.json +1 -0
  219. package/graphify-out/cache/1c7815c37c13177e98895e272285f6151a8d0807478fc843ec452634b3e9912d.json +1 -0
  220. package/graphify-out/cache/1ec38c39f044f329c78642b61d6394fb8e15d0014335f32947d1f5c7b88c02bc.json +1 -0
  221. package/graphify-out/cache/20c9b57ff76dbb9d57cbd00659b0a42d2b28dd2abacf1ef4143cc67a5b6fe7f4.json +1 -0
  222. package/graphify-out/cache/285e11876884eb619e779d540cd957b33e70f14c67ecc26c9b9755aa9cedd717.json +1 -0
  223. package/graphify-out/cache/2c0a9c49ab51f4e0f07543b4e941bf802b7db31fa607c4cee8e595575be68fe7.json +1 -0
  224. package/graphify-out/cache/3025e6c2756c79ccaadd51d611f25a8b6630a6a11ce1b4e6e261b3e033dc194f.json +1 -0
  225. package/graphify-out/cache/4801a686ddfa0a52824a4fc3d65443cbb0ab9f0b030af67d02fccb520c584a08.json +1 -0
  226. package/graphify-out/cache/4f8fd96f38aa7d0293b4fab60c4581c4f3e68f4533c664c9cd78d1c53bea1cba.json +1 -0
  227. package/graphify-out/cache/5928e562b0f5700184b810e2403f4aa685e2b93c3c584c10460562b514c40fdd.json +1 -0
  228. package/graphify-out/cache/66132486efb0a4cfaeea766448f1f15bb33635808714052e7e24e5b00fbc984f.json +1 -0
  229. package/graphify-out/cache/66ab27669e7ec685130063662af9f30018c267f7639b4af4b0504a98282c383a.json +1 -0
  230. package/graphify-out/cache/6ff6b3dd433b5ffe96e166263a203dd622397e419dc00bb676824988b7defeab.json +1 -0
  231. package/graphify-out/cache/7a00a49932177a6215e2590b1ddfd6f1d8494792f693068e9d427d16b165d370.json +1 -0
  232. package/graphify-out/cache/7b681bc5182f40f707f1c0b16b78af38efffa62a1df315d10878f4de888408ef.json +1 -0
  233. package/graphify-out/cache/81196d44e50ac0b276d826a531ed10c425a528b298e3fe18e8d5a3eec996e9d5.json +1 -0
  234. package/graphify-out/cache/8934e9b32dea6e66fdc34fa1681b287ff1335c389917e0fc6ee2fc573e23e87b.json +1 -0
  235. package/graphify-out/cache/975f6c99807f86b79c80ca40c783618e2080a927eaebe6ea3db37b869f048851.json +1 -0
  236. package/graphify-out/cache/9ab98f08626fd8190462595e38de828293ad184db8df5e1177b05a8fe290faa1.json +1 -0
  237. package/graphify-out/cache/9c434a6796d7932b6e87a908c155c09cb2b8d097fc55f141f0302b6600f94749.json +1 -0
  238. package/graphify-out/cache/ac5cf4c489dc417c1f6ea728d0b6ba12ac7087bc6c2e736697ff3024b4d4e534.json +1 -0
  239. package/graphify-out/cache/ae5083b5c1dca3e5c6af485e7f6eb8a08ff8b382cdecf92ab5e0902053442afe.json +1 -0
  240. package/graphify-out/cache/b274057fc2e0118cf2746d1d8060841122bb2a2b0305566fc3f32d3a51e08bcc.json +1 -0
  241. package/graphify-out/cache/b39beef31da682387f030c0d149f6cd5b3e66effbf936cc8430db15360759dda.json +1 -0
  242. package/graphify-out/cache/bf3c6a36bb72820bc11cbf4a5c49067d1f62013d4686c019a4dbd9951b1e980e.json +1 -0
  243. package/graphify-out/cache/c034e156028d1a58b89bce659726e9a4065ddc4d2b560d6bce7a206fdff8dad3.json +1 -0
  244. package/graphify-out/cache/c619b5bbe8d1f427fbd7816d1e9fcfaf90d7201b020ae6b578166aeb9cb20683.json +1 -0
  245. package/graphify-out/cache/c8db77a9da0b0f601acfa50a620f31155cdda0d0cc0f2285adcea19e77194ee6.json +1 -0
  246. package/graphify-out/cache/ca664791ec7741a2077d9e7c10384142d30e7a3b77b388df719c315da608d57d.json +1 -0
  247. package/graphify-out/cache/cba43a116186bd55c8a63368dea4eee4a8123b2bec0a42df6efb3254f89f9a7a.json +1 -0
  248. package/graphify-out/cache/cd51cbb3dad1cf34417b9761fe2eb184a9f57d23dc86e45630e63bfa2ecafddc.json +1 -0
  249. package/graphify-out/cache/d06738cde193b34a136b94104220c17e0212b814b3e4d7ff399105635cae1a03.json +1 -0
  250. package/graphify-out/cache/d093c19f0169c0398eeb1360895b1c16ecc50abc59f4be8eec3f6fd27c89a6e5.json +1 -0
  251. package/graphify-out/cache/da8f75c438531d232fe114d5cbf2374576ce842a5fb87c7e5a88b78fdb334e5e.json +1 -0
  252. package/graphify-out/cache/e35798fa04ddede548a6953bdea506bd7d0788dfed4e8a8ea6ae77b1b60ef5e0.json +1 -0
  253. package/graphify-out/cache/e5a38c254719000487098782125e15e2e982c07d66b99d359ed1781f30f9fc8c.json +1 -0
  254. package/graphify-out/cache/e6e4c4a5a7200ee0154585b5d6538f699b0a746dbded3164f8391f06ce7cb212.json +1 -0
  255. package/graphify-out/cache/ea8d0838df6309b673b031f616b253af957898ee7289d25a541fa6183b732e4e.json +1 -0
  256. package/graphify-out/cache/ebaee92b0e881efd7a08f3143e2c1803310396b4651d4f77532003c699cc6836.json +1 -0
  257. package/graphify-out/cache/edf8543318a9e60d56d04704078da6c37202ddd6fdfc83144fe2b94fe19b80ef.json +1 -0
  258. package/graphify-out/cache/efca19d3668035f11126fc9eccbeab290abfa94babf3f9a8706de81d17aba263.json +1 -0
  259. package/graphify-out/cache/f1480bb642025ebd6d99986cdd8a7d5726897ec038300e4b095c9c938435dfad.json +1 -0
  260. package/graphify-out/cache/f459f21277f03865f732affb175b1b092954dae5967f27b3cd1864466e3e24f4.json +1 -0
  261. package/graphify-out/cache/f899e37e864010b30f4c196e86082d7bd022a0df032005e0407883ebcec36514.json +1 -0
  262. package/graphify-out/cache/fb3cbe07fbcd97c536cff9c6bc343c35f22d49613f05c53ad30ef67a75c5d93e.json +1 -0
  263. package/graphify-out/cache/fd3dc682b1ca2f5ae03b50d6b0e045ae50f5701c0a21c5a388d77ef482939d3a.json +1 -0
  264. package/graphify-out/graph.html +257 -0
  265. package/graphify-out/graph.json +4396 -0
  266. package/package.json +45 -6
  267. package/scripts/e2e-external.mjs +65 -0
  268. package/scripts/live-agents.mjs +6 -0
  269. package/scripts/live-stream.mjs +51 -0
  270. package/src/commands/agents.ts +91 -0
  271. package/src/commands/auth.ts +39 -0
  272. package/src/commands/chat.ts +198 -0
  273. package/src/commands/keys.ts +83 -0
  274. package/src/commands/local.ts +302 -0
  275. package/src/commands/mcp.ts +74 -0
  276. package/src/commands/prompts.ts +58 -0
  277. package/src/commands/skills.ts +43 -0
  278. package/src/core/auth/index.ts +101 -0
  279. package/src/core/config/index.ts +152 -0
  280. package/src/core/history.ts +79 -0
  281. package/src/core/markdown-renderer.ts +420 -0
  282. package/src/core/permissions/index.ts +99 -0
  283. package/src/core/provider/external.ts +312 -0
  284. package/src/core/provider/index.ts +517 -0
  285. package/src/core/registry/index.ts +250 -0
  286. package/src/core/schema/types.ts +106 -0
  287. package/src/core/terminal.ts +124 -0
  288. package/src/core/workspace/index.ts +216 -0
  289. package/src/index.ts +401 -0
  290. package/src/ui/app.tsx +644 -0
  291. package/src/ui/commands/cases/catalog.ts +76 -0
  292. package/src/ui/commands/cases/misc.ts +293 -0
  293. package/src/ui/commands/cases/tasks.ts +115 -0
  294. package/src/ui/commands/runCommand.ts +178 -0
  295. package/src/ui/components/Banner.tsx +63 -0
  296. package/src/ui/components/CommandMenu.tsx +63 -0
  297. package/src/ui/components/ErrorBoundary.tsx +75 -0
  298. package/src/ui/components/InputBar.tsx +227 -0
  299. package/src/ui/components/KeysPanel.tsx +115 -0
  300. package/src/ui/components/MessageView.tsx +226 -0
  301. package/src/ui/components/Pickers.tsx +234 -0
  302. package/src/ui/components/SearchOverlay.tsx +65 -0
  303. package/src/ui/components/WorkingIndicator.tsx +35 -0
  304. package/src/ui/controls/ApiKeyEntry.tsx +29 -0
  305. package/src/ui/controls/MultiSelect.tsx +55 -0
  306. package/src/ui/hooks/useAgentPicker.ts +64 -0
  307. package/src/ui/hooks/useAuthFlow.ts +47 -0
  308. package/src/ui/hooks/useKeysFlow.ts +157 -0
  309. package/src/ui/hooks/useSessionPicker.ts +84 -0
  310. package/src/ui/hooks/useTerminalSize.ts +36 -0
  311. package/src/ui/input/keyRouter.ts +627 -0
  312. package/src/ui/layouts/ScreenLayout.tsx +202 -0
  313. package/src/ui/shared/types.ts +160 -0
  314. package/src/ui/theme.ts +53 -0
  315. package/src/ui/utils/markdown.ts +255 -0
  316. package/src/ui/utils/mentions.ts +40 -0
  317. package/src/ui/utils/terminal-text.ts +130 -0
  318. package/src/ui/utils/text.ts +174 -0
  319. package/test/commands.test.mjs +127 -0
  320. package/test/config.test.mjs +123 -0
  321. package/test/history.test.mjs +42 -0
  322. package/test/keyrouter.test.mjs +324 -0
  323. package/test/layout.test.mjs +271 -0
  324. package/test/markdown.test.mjs +92 -0
  325. package/test/mentions.test.mjs +51 -0
  326. package/test/permissions.test.mjs +130 -0
  327. package/test/provider.test.mjs +287 -0
  328. package/test/terminal-text.test.mjs +116 -0
  329. package/test/text.test.mjs +134 -0
  330. package/test/workspace.test.mjs +101 -0
  331. package/tsconfig.json +32 -0
@@ -0,0 +1,248 @@
1
+ /**
2
+ * External providers — bring-your-own LLM (like Claude Code / Copilot's
3
+ * settings-file model). Codemind stays platform-first; an external provider
4
+ * is an opt-in override configured in ~/.odysx/config.json:
5
+ *
6
+ * "providers": {
7
+ * "openai": { "type": "openai", "baseUrl": "https://api.openai.com/v1", "apiKey": "sk-…", "model": "gpt-4o" },
8
+ * "groq": { "type": "openai", "baseUrl": "https://api.groq.com/openai/v1", "apiKey": "gsk_…", "model": "llama-3.3-70b" },
9
+ * "ollama": { "type": "openai", "baseUrl": "http://localhost:11434/v1", "model": "llama3.2" },
10
+ * "claude": { "type": "anthropic", "apiKey": "sk-ant-…", "model": "claude-sonnet-5" },
11
+ * "gemini": { "type": "gemini", "apiKey": "AIza…", "model": "gemini-2.0-flash" }
12
+ * },
13
+ * "provider": "openai" // active selection; absent/null = OdysX platform
14
+ *
15
+ * Any `type: "openai"` entry with a custom baseUrl covers OpenAI-compatible
16
+ * servers (Groq, Ollama, LM Studio, vLLM, Together, …).
17
+ */
18
+ import { getConfig } from "../config/index.js";
19
+ import { readSSE, idleTimeout, STREAM_IDLE_TIMEOUT_MS } from "./index.js";
20
+ const DEFAULT_BASE_URLS = {
21
+ openai: "https://api.openai.com/v1",
22
+ anthropic: "https://api.anthropic.com/v1",
23
+ gemini: "https://generativelanguage.googleapis.com/v1beta",
24
+ };
25
+ const PROVIDER_TYPES = ["openai", "anthropic", "gemini"];
26
+ const isProviderType = (t) => typeof t === "string" && PROVIDER_TYPES.includes(t);
27
+ export const getActiveProvider = () => {
28
+ const config = getConfig();
29
+ const name = config.provider;
30
+ if (!name || name === "odysx")
31
+ return null;
32
+ const cfg = config.providers?.[name];
33
+ if (!cfg)
34
+ return null;
35
+ // config.json is user-edited and unvalidated. A typo'd `type` used to fall
36
+ // through to `fetch("undefined/chat/completions")`, which surfaced as a
37
+ // baffling URL parse error; refuse cleanly instead.
38
+ if (!isProviderType(cfg.type)) {
39
+ throw new Error(`Provider '${name}' has unknown type '${String(cfg.type)}' — expected openai, anthropic, or gemini.`);
40
+ }
41
+ return {
42
+ name,
43
+ config: { ...cfg, type: cfg.type, baseUrl: cfg.baseUrl ?? DEFAULT_BASE_URLS[cfg.type] },
44
+ };
45
+ };
46
+ /** Stream a chat turn through the active external provider. Throws on HTTP
47
+ * errors with the provider's own message so the REPL can show it directly. */
48
+ export async function streamExternalChat(messages, opts) {
49
+ const active = getActiveProvider();
50
+ if (!active)
51
+ throw new Error("No external provider configured");
52
+ const { type, baseUrl, apiKey, model } = active.config;
53
+ switch (type) {
54
+ case "openai":
55
+ return streamOpenAI(baseUrl, apiKey, model, messages, opts);
56
+ case "anthropic":
57
+ return streamAnthropic(baseUrl, apiKey, model, messages, opts);
58
+ case "gemini":
59
+ return streamGemini(baseUrl, apiKey ?? "", model, messages, opts);
60
+ default:
61
+ throw new Error(`Provider '${active.name}' has unknown type '${String(type)}' — expected openai, anthropic, or gemini.`);
62
+ }
63
+ }
64
+ /* ── OpenAI-compatible (/chat/completions, SSE) ─────────────────────────── */
65
+ async function streamOpenAI(baseUrl, apiKey, model, messages, opts) {
66
+ const res = await postJson(`${baseUrl}/chat/completions`, {
67
+ "Content-Type": "application/json",
68
+ ...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
69
+ }, {
70
+ model,
71
+ stream: true,
72
+ messages: [
73
+ ...(opts.system ? [{ role: "system", content: opts.system }] : []),
74
+ ...messages,
75
+ ],
76
+ }, opts);
77
+ await consume(res, opts, (json) => {
78
+ const token = json?.choices?.[0]?.delta?.content ??
79
+ json?.choices?.[0]?.text ??
80
+ "";
81
+ if (token)
82
+ opts.onToken(token);
83
+ }, (json) => {
84
+ // OpenAI-compatible servers report mid-stream failures as a frame body.
85
+ const err = json?.error;
86
+ if (err)
87
+ return typeof err === "string" ? err : (err.message ?? JSON.stringify(err));
88
+ return null;
89
+ });
90
+ }
91
+ /* ── Anthropic (/messages, SSE) ─────────────────────────────────────────── */
92
+ async function streamAnthropic(baseUrl, apiKey, model, messages, opts) {
93
+ if (!apiKey)
94
+ throw new Error(`Anthropic provider needs an apiKey`);
95
+ const res = await postJson(`${baseUrl}/messages`, {
96
+ "Content-Type": "application/json",
97
+ "x-api-key": apiKey,
98
+ "anthropic-version": "2023-06-01",
99
+ }, {
100
+ model,
101
+ max_tokens: 4096,
102
+ stream: true,
103
+ ...(opts.system ? { system: opts.system } : {}),
104
+ messages,
105
+ }, opts);
106
+ await consume(res, opts, (json) => {
107
+ if (json?.type === "content_block_delta" && json?.delta?.text) {
108
+ opts.onToken(json.delta.text);
109
+ }
110
+ }, (json) => {
111
+ // Anthropic sends `event: error` with an error body mid-stream.
112
+ if (json?.type === "error")
113
+ return json?.error?.message ?? "Provider stream error";
114
+ return null;
115
+ });
116
+ }
117
+ /* ── Google Gemini (streamGenerateContent?alt=sse) ──────────────────────── */
118
+ async function streamGemini(baseUrl, apiKey, model, messages, opts) {
119
+ const contents = messages.map((m) => ({
120
+ role: m.role === "assistant" ? "model" : "user",
121
+ parts: [{ text: m.content }],
122
+ }));
123
+ // The key goes in a header, not the query string: query strings land in
124
+ // provider/proxy access logs and in any error that echoes the URL.
125
+ const url = `${baseUrl}/models/${encodeURIComponent(model)}:streamGenerateContent?alt=sse`;
126
+ const res = await postJson(url, { "Content-Type": "application/json", "x-goog-api-key": apiKey }, {
127
+ contents,
128
+ ...(opts.system
129
+ ? { systemInstruction: { parts: [{ text: opts.system }] } }
130
+ : {}),
131
+ }, opts);
132
+ await consume(res, opts, (json) => {
133
+ const parts = json?.candidates?.[0]?.content?.parts ?? [];
134
+ for (const part of parts)
135
+ if (part.text)
136
+ opts.onToken(part.text);
137
+ }, (json) => {
138
+ const err = json?.error;
139
+ if (err)
140
+ return err.message ?? JSON.stringify(err);
141
+ // A blocked prompt comes back as a finishReason with no text at all.
142
+ const reason = json?.candidates?.[0]?.finishReason;
143
+ if (reason && reason !== "STOP" && reason !== "MAX_TOKENS") {
144
+ return `Gemini stopped the response: ${reason}`;
145
+ }
146
+ const blocked = json?.promptFeedback?.blockReason;
147
+ if (blocked)
148
+ return `Gemini blocked the prompt: ${blocked}`;
149
+ return null;
150
+ });
151
+ }
152
+ /* ── Shared helpers ─────────────────────────────────────────────────────── */
153
+ /** How long a provider may take to accept the connection and send headers. */
154
+ const HEADER_TIMEOUT_MS = 30_000;
155
+ const idleMessage = () => `Provider sent nothing for ${Math.round(STREAM_IDLE_TIMEOUT_MS / 1000)}s — gave up`;
156
+ /**
157
+ * POST JSON and return the response, with a deadline covering connect + the
158
+ * first byte of headers.
159
+ *
160
+ * The idle watchdog only starts *after* `fetch` resolves, so without this a
161
+ * provider that completes the TCP handshake and then never sends headers (a
162
+ * black-holed endpoint, a firewall that accepts) hung the REPL forever with
163
+ * no way out but Ctrl+C.
164
+ */
165
+ async function postJson(url, headers, body, opts) {
166
+ const connect = idleTimeout(HEADER_TIMEOUT_MS, opts.signal);
167
+ let res;
168
+ try {
169
+ res = await fetch(url, {
170
+ method: "POST",
171
+ headers,
172
+ body: JSON.stringify(body),
173
+ signal: connect.signal,
174
+ });
175
+ }
176
+ catch (err) {
177
+ if (connect.timedOut()) {
178
+ throw new Error(`Provider did not respond within ${HEADER_TIMEOUT_MS / 1000}s`);
179
+ }
180
+ throw err;
181
+ }
182
+ finally {
183
+ connect.clear();
184
+ }
185
+ if (!res.ok)
186
+ throw new Error(await readError(res));
187
+ return res;
188
+ }
189
+ /**
190
+ * Drain a provider SSE stream, surfacing two things the old code lost:
191
+ *
192
+ * - A mid-stream error frame (OpenAI `{"error":…}`, Anthropic
193
+ * `{"type":"error"}`, a Gemini safety stop). These used to be swallowed,
194
+ * so a rate-limited turn ended as an empty reply with exit code 0.
195
+ * - The idle timeout itself. The watchdog aborts the reader, so the failure
196
+ * arrives as an AbortError *before* a `timedOut()` check placed after the
197
+ * read could run — the user saw "interrupted" as if they had pressed Esc.
198
+ */
199
+ async function consume(res, opts, onJson, findError) {
200
+ const idle = idleTimeout(STREAM_IDLE_TIMEOUT_MS, opts.signal);
201
+ try {
202
+ await readProviderSSE(res, (json) => {
203
+ const message = findError(json);
204
+ if (message)
205
+ throw new Error(message);
206
+ onJson(json);
207
+ }, idle.signal, idle.touch);
208
+ }
209
+ catch (err) {
210
+ if (idle.timedOut())
211
+ throw new Error(idleMessage());
212
+ throw err;
213
+ }
214
+ finally {
215
+ idle.clear();
216
+ }
217
+ }
218
+ async function readError(res) {
219
+ let detail = "";
220
+ try {
221
+ const text = await res.text();
222
+ try {
223
+ const body = JSON.parse(text);
224
+ detail =
225
+ body?.error?.message ??
226
+ body?.message ??
227
+ (typeof body?.error === "string" ? body.error : JSON.stringify(body).slice(0, 200));
228
+ }
229
+ catch {
230
+ detail = text.slice(0, 200);
231
+ }
232
+ }
233
+ catch { /* ignore unreadable bodies */ }
234
+ return `Provider error HTTP ${res.status}: ${detail || res.statusText}`;
235
+ }
236
+ /** Parse provider SSE frames through the shared, framing-tolerant reader.
237
+ * Malformed JSON frames are skipped rather than killing the turn. */
238
+ async function readProviderSSE(res, onJson, signal, onActivity) {
239
+ await readSSE(res, (data) => {
240
+ if (!data || data === "[DONE]")
241
+ return;
242
+ try {
243
+ onJson(JSON.parse(data));
244
+ }
245
+ catch { /* skip malformed frames */ }
246
+ }, signal, onActivity);
247
+ }
248
+ //# sourceMappingURL=external.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external.js","sourceRoot":"","sources":["../../../src/core/provider/external.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAmB1E,MAAM,iBAAiB,GAAiC;IACtD,MAAM,EAAE,2BAA2B;IACnC,SAAS,EAAE,8BAA8B;IACzC,MAAM,EAAE,kDAAkD;CAC3D,CAAC;AAEF,MAAM,cAAc,GAAsB,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;AAC5E,MAAM,cAAc,GAAG,CAAC,CAAU,EAAqB,EAAE,CACvD,OAAO,CAAC,KAAK,QAAQ,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAGxB,EAAE;IACT,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC7B,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,2EAA2E;IAC3E,wEAAwE;IACxE,oDAAoD;IACpD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,aAAa,IAAI,uBAAuB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,4CAA4C,CACrG,CAAC;IACJ,CAAC;IACD,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,EAAE,GAAG,GAAG,EAAE,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K,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;AAC1E,CAAC;AAED;sEACsE;AACtE,KAAK,UAAU,eAAe,CAC5B,GAAa,EACb,MAA2B,EAC3B,MAAoB,EACpB,UAAuB;IAEvB,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QAC1B,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,QAAQ;YAAE,OAAO;QACvC,IAAI,CAAC;YAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,2BAA2B,CAAC,CAAC;IACzE,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,96 @@
1
+ export interface ApiOptions {
2
+ method?: string;
3
+ body?: unknown;
4
+ headers?: Record<string, string>;
5
+ stream?: boolean;
6
+ signal?: AbortSignal;
7
+ /** Override the default request timeout (ms). */
8
+ timeoutMs?: number;
9
+ }
10
+ export interface ApiResponse<T = unknown> {
11
+ ok: boolean;
12
+ status: number;
13
+ data: T;
14
+ error?: string;
15
+ }
16
+ /** SSE event from streaming endpoint */
17
+ export interface StreamEvent {
18
+ type: "token" | "done" | "error";
19
+ data: string;
20
+ }
21
+ /** Default ceiling for a non-streaming API call. */
22
+ export declare const DEFAULT_TIMEOUT_MS = 30000;
23
+ /** Streaming turns may legitimately run long, but never forever. */
24
+ export declare const STREAM_IDLE_TIMEOUT_MS = 120000;
25
+ /**
26
+ * Keep a stream alive for as long as it keeps producing, but abort if it goes
27
+ * silent for `ms`. This is deliberately *not* `AbortSignal.timeout`, which is a
28
+ * single deadline from the start: a reply that streams for longer than the
29
+ * timeout would be killed mid-sentence even though data was flowing.
30
+ *
31
+ * `touch()` resets the countdown; call it for every chunk received.
32
+ */
33
+ export interface IdleTimeout {
34
+ signal: AbortSignal;
35
+ touch: () => void;
36
+ clear: () => void;
37
+ timedOut: () => boolean;
38
+ }
39
+ export declare function idleTimeout(ms: number, external?: AbortSignal): IdleTimeout;
40
+ /**
41
+ * Encode a value for use as a single URL path segment.
42
+ *
43
+ * Ids come straight from the command line. Interpolated raw, `x/../../y`
44
+ * would be normalised by undici into a *different* endpoint and sent with the
45
+ * user's credentials; `?`/`#` would truncate the path. Always encode.
46
+ */
47
+ export declare const urlSegment: (value: string) => string;
48
+ /** Generic API call */
49
+ export declare function apiCall<T = unknown>(path: string, options?: ApiOptions): Promise<ApiResponse<T>>;
50
+ /**
51
+ * Incremental SSE reader shared by the platform stream and the external
52
+ * providers. It tolerates the framing differences seen in the wild:
53
+ * - `data:` with or without a space
54
+ * - CRLF and LF line endings
55
+ * - a final event with no trailing newline
56
+ * - comments / `event:` lines (ignored)
57
+ * `onData` receives the raw payload string of every `data:` line.
58
+ * `onActivity` fires on every chunk read, so a caller can keep an idle
59
+ * timeout armed only while the stream is genuinely silent.
60
+ */
61
+ export declare function readSSE(res: Response, onData: (data: string) => void, signal?: AbortSignal, onActivity?: () => void): Promise<void>;
62
+ /** Stream SSE from the chat endpoint. Calls `onToken` for each token.
63
+ * `onUsage` (when given) receives approximate token counts computed from
64
+ * the stream (~4 chars ≈ 1 token, matching the server-side accounting). */
65
+ export declare function streamChat(path: string, body: unknown, onToken: (token: string) => void, onDone?: () => void, signal?: AbortSignal, onUsage?: (usage: {
66
+ promptTokens: number;
67
+ completionTokens: number;
68
+ }) => void): Promise<void>;
69
+ /**
70
+ * One chat turn for every CLI front-end.
71
+ *
72
+ * Three chat paths used to disagree: the Ink REPL handled BYOK and fell back
73
+ * from master's unsupported SSE to POST /llm/chat, while `odysx chat` and the
74
+ * piped REPL streamed blindly and failed out of the box. Keeping the choice
75
+ * here means a new front-end cannot forget either behaviour.
76
+ *
77
+ * `history` is only used for external providers (which need the whole
78
+ * conversation); the platform owns session history server-side.
79
+ */
80
+ export declare function streamTurn(message: string, opts: {
81
+ agentId?: string;
82
+ sessionId: string;
83
+ history?: Array<{
84
+ role: "user" | "assistant";
85
+ content: string;
86
+ }>;
87
+ system?: string;
88
+ onToken: (token: string) => void;
89
+ onDone?: () => void;
90
+ onUsage?: (usage: {
91
+ promptTokens: number;
92
+ completionTokens: number;
93
+ }) => void;
94
+ signal?: AbortSignal;
95
+ }): Promise<void>;
96
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/provider/index.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wCAAwC;AACxC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,oDAAoD;AACpD,eAAO,MAAM,kBAAkB,QAAS,CAAC;AACzC,oEAAoE;AACpE,eAAO,MAAM,sBAAsB,SAAU,CAAC;AAmE9C;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,MAAM,OAAO,CAAC;CACzB;AAED,wBAAgB,WAAW,CACzB,EAAE,EAAE,MA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