upfynai-code 0.1.0 → 2.2.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 (340) hide show
  1. package/client/dist/api-docs.html +879 -0
  2. package/client/dist/assets/AppContent-CTSHQdyq.js +513 -0
  3. package/client/dist/assets/CanvasPanel-Cig0Mo9s.js +6 -0
  4. package/client/dist/assets/CanvasPanel-q4HEqNtV.css +1 -0
  5. package/client/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  6. package/client/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  7. package/client/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  8. package/client/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  9. package/client/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  10. package/client/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  11. package/client/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  12. package/client/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  13. package/client/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  14. package/client/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  15. package/client/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  16. package/client/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  17. package/client/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  18. package/client/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  19. package/client/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  20. package/client/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  21. package/client/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  22. package/client/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  23. package/client/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  24. package/client/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  25. package/client/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  26. package/client/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  27. package/client/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  28. package/client/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  29. package/client/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  30. package/client/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  31. package/client/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  32. package/client/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  33. package/client/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  34. package/client/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  35. package/client/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  36. package/client/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  37. package/client/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  38. package/client/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  39. package/client/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  40. package/client/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  41. package/client/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  42. package/client/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  43. package/client/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  44. package/client/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  45. package/client/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  46. package/client/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  47. package/client/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  48. package/client/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  49. package/client/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  50. package/client/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  51. package/client/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  52. package/client/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  53. package/client/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  54. package/client/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  55. package/client/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  56. package/client/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  57. package/client/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  58. package/client/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  59. package/client/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  60. package/client/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  61. package/client/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  62. package/client/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  63. package/client/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  64. package/client/dist/assets/LoginModal-silya-zP.js +11 -0
  65. package/client/dist/assets/MarkdownPreview-B3c7OEj6.js +1 -0
  66. package/client/dist/assets/Onboarding-Coxo6mFA.js +1 -0
  67. package/client/dist/assets/SetupForm-BzYOsbji.js +1 -0
  68. package/client/dist/assets/Tableau10-B-NsZVaP.js +1 -0
  69. package/client/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
  70. package/client/dist/assets/ar-SA-G6X2FPQ2-Bmw2-hDt.js +10 -0
  71. package/client/dist/assets/arc-BMqY7_Ci.js +1 -0
  72. package/client/dist/assets/array-BKyUJesY.js +1 -0
  73. package/client/dist/assets/az-AZ-76LH7QW2-Dh1le_qs.js +1 -0
  74. package/client/dist/assets/bg-BG-XCXSNQG7-Cbav8Z9z.js +5 -0
  75. package/client/dist/assets/blockDiagram-38ab4fdb-ChHJxsXw.js +118 -0
  76. package/client/dist/assets/bn-BD-2XOGV67Q-DCNjOaWz.js +5 -0
  77. package/client/dist/assets/c4Diagram-3d4e48cf-b8Xue4Z6.js +10 -0
  78. package/client/dist/assets/ca-ES-6MX7JW3Y-Dl_vM7NS.js +8 -0
  79. package/client/dist/assets/channel-CSnvHe_M.js +1 -0
  80. package/client/dist/assets/classDiagram-70f12bd4-BheP7Ggo.js +2 -0
  81. package/client/dist/assets/classDiagram-v2-f2320105-xtym7GEZ.js +2 -0
  82. package/client/dist/assets/clone-B75abXxS.js +1 -0
  83. package/client/dist/assets/createText-2e5e7dd3-_n4jI_fO.js +5 -0
  84. package/client/dist/assets/cs-CZ-2BRQDIVT-ftsKDdz4.js +11 -0
  85. package/client/dist/assets/da-DK-5WZEPLOC-DAjdwGRO.js +5 -0
  86. package/client/dist/assets/de-DE-XR44H4JA-BJXczHGT.js +8 -0
  87. package/client/dist/assets/directory-open-01563666-DWU9wJ6I.js +1 -0
  88. package/client/dist/assets/directory-open-4ed118d0-CunoC1EB.js +1 -0
  89. package/client/dist/assets/edges-e0da2a9e-CfPZr4YM.js +4 -0
  90. package/client/dist/assets/el-GR-BZB4AONW-DW2p_uy7.js +10 -0
  91. package/client/dist/assets/erDiagram-9861fffd-CF33V-Of.js +51 -0
  92. package/client/dist/assets/es-ES-U4NZUMDT-DLOIGnrl.js +9 -0
  93. package/client/dist/assets/eu-ES-A7QVB2H4-LJXbf89m.js +11 -0
  94. package/client/dist/assets/fa-IR-HGAKTJCU-Dvx65fgW.js +8 -0
  95. package/client/dist/assets/fi-FI-Z5N7JZ37-EoL65BQh.js +6 -0
  96. package/client/dist/assets/file-open-002ab408-DIuFHtCF.js +1 -0
  97. package/client/dist/assets/file-open-7c801643-684qeFg4.js +1 -0
  98. package/client/dist/assets/file-save-3189631c-C1wFhQhH.js +1 -0
  99. package/client/dist/assets/file-save-745eba88-Bb9F9Kg7.js +1 -0
  100. package/client/dist/assets/flowDb-956e92f1-HgoXVy2H.js +10 -0
  101. package/client/dist/assets/flowDiagram-66a62f08-tffoET0H.js +4 -0
  102. package/client/dist/assets/flowDiagram-v2-96b9c2cf-Byc3JCHh.js +1 -0
  103. package/client/dist/assets/flowchart-elk-definition-4a651766-DJbI2dpv.js +139 -0
  104. package/client/dist/assets/fr-FR-RHASNOE6-DNk_jdDs.js +9 -0
  105. package/client/dist/assets/ganttDiagram-c361ad54-2XX670FU.js +257 -0
  106. package/client/dist/assets/gitGraphDiagram-72cf32ee-CcUfruAo.js +70 -0
  107. package/client/dist/assets/gl-ES-HMX3MZ6V-dxzFjZlG.js +10 -0
  108. package/client/dist/assets/graph-BSbiMSBC.js +1 -0
  109. package/client/dist/assets/he-IL-6SHJWFNN-Cogsfdt1.js +10 -0
  110. package/client/dist/assets/hi-IN-IWLTKZ5I-L6wbgi4F.js +4 -0
  111. package/client/dist/assets/hu-HU-A5ZG7DT2-DSA6ZDsH.js +7 -0
  112. package/client/dist/assets/id-ID-SAP4L64H-BK_vGGS6.js +10 -0
  113. package/client/dist/assets/image-blob-reduce.esm-BLtmMM_J.js +2 -0
  114. package/client/dist/assets/index-3862675e-Bv32HUgT.js +1 -0
  115. package/client/dist/assets/index-B8wwD_Xo.css +1 -0
  116. package/client/dist/assets/index-BPwf8Fw3.js +27 -0
  117. package/client/dist/assets/index-D1urGMYu.js +95 -0
  118. package/client/dist/assets/infoDiagram-f8f76790-w4mR4pxn.js +7 -0
  119. package/client/dist/assets/init-Gi6I4Gst.js +1 -0
  120. package/client/dist/assets/it-IT-JPQ66NNP-BLdHYMhn.js +11 -0
  121. package/client/dist/assets/ja-JP-DBVTYXUO-B_vmexl_.js +8 -0
  122. package/client/dist/assets/journeyDiagram-49397b02-D9nmO17e.js +139 -0
  123. package/client/dist/assets/kaa-6HZHGXH3-5s-3jl6F.js +1 -0
  124. package/client/dist/assets/kab-KAB-ZGHBKWFO-2QaVDuSf.js +8 -0
  125. package/client/dist/assets/kk-KZ-P5N5QNE5-CTC52Vbi.js +1 -0
  126. package/client/dist/assets/km-KH-HSX4SM5Z-DxawH8UZ.js +11 -0
  127. package/client/dist/assets/ko-KR-MTYHY66A-CmosEM8_.js +9 -0
  128. package/client/dist/assets/ku-TR-6OUDTVRD-DbiLen4y.js +9 -0
  129. package/client/dist/assets/layout-jmt3H9tA.js +1 -0
  130. package/client/dist/assets/line-JTlRayUJ.js +1 -0
  131. package/client/dist/assets/linear-DJeB5p7x.js +1 -0
  132. package/client/dist/assets/lt-LT-XHIRWOB4-CH15wrjA.js +3 -0
  133. package/client/dist/assets/lv-LV-5QDEKY6T-dhgfPuCQ.js +7 -0
  134. package/client/dist/assets/mindmap-definition-fc14e90a-BOOrexmz.js +415 -0
  135. package/client/dist/assets/mr-IN-CRQNXWMA-3Gi6iq7A.js +13 -0
  136. package/client/dist/assets/my-MM-5M5IBNSE-CpH4rdJj.js +1 -0
  137. package/client/dist/assets/nb-NO-T6EIAALU-Du6iiGql.js +10 -0
  138. package/client/dist/assets/nl-NL-IS3SIHDZ-BGvsd1MT.js +8 -0
  139. package/client/dist/assets/nn-NO-6E72VCQL-B-odvJZW.js +8 -0
  140. package/client/dist/assets/oc-FR-POXYY2M6-COC8xNjo.js +8 -0
  141. package/client/dist/assets/ordinal-Cboi1Yqb.js +1 -0
  142. package/client/dist/assets/pa-IN-N4M65BXN-CE21PUQH.js +4 -0
  143. package/client/dist/assets/path-CbwjOpE9.js +1 -0
  144. package/client/dist/assets/pdf-TYrZqVzP.js +12 -0
  145. package/client/dist/assets/pdf.worker-BA9kU3Pw.mjs +61080 -0
  146. package/client/dist/assets/percentages-BXMCSKIN-C9GT0OD3.js +199 -0
  147. package/client/dist/assets/pica-VkdyTzi8.js +2 -0
  148. package/client/dist/assets/pieDiagram-8a3498a8-Cvfh7Qr5.js +35 -0
  149. package/client/dist/assets/pl-PL-T2D74RX3-D4xFVSoT.js +9 -0
  150. package/client/dist/assets/pt-BR-5N22H2LF-CCq257gA.js +9 -0
  151. package/client/dist/assets/pt-PT-UZXXM6DQ-1l8gt5vA.js +9 -0
  152. package/client/dist/assets/quadrantDiagram-120e2f19-BA0js1aD.js +7 -0
  153. package/client/dist/assets/requirementDiagram-deff3bca-B0QNFfIn.js +52 -0
  154. package/client/dist/assets/ro-RO-JPDTUUEW-yosBW01E.js +11 -0
  155. package/client/dist/assets/roundRect-mAH3dD0p.js +1 -0
  156. package/client/dist/assets/ru-RU-B4JR7IUQ-8LkEJUix.js +9 -0
  157. package/client/dist/assets/sankeyDiagram-04a897e0-D4T9eCXn.js +8 -0
  158. package/client/dist/assets/sequenceDiagram-704730f1-CfBUTCrO.js +122 -0
  159. package/client/dist/assets/si-LK-N5RQ5JYF-D8rjbqtd.js +1 -0
  160. package/client/dist/assets/sk-SK-C5VTKIMK-Bg14sAzN.js +6 -0
  161. package/client/dist/assets/sl-SI-NN7IZMDC-CMTib6Zs.js +6 -0
  162. package/client/dist/assets/stateDiagram-587899a1-BGgvmVSZ.js +1 -0
  163. package/client/dist/assets/stateDiagram-v2-d93cdb3a-Qn3DpYuO.js +1 -0
  164. package/client/dist/assets/styles-6aaf32cf-IdVZLPrD.js +207 -0
  165. package/client/dist/assets/styles-9a916d00-BAC3L45X.js +160 -0
  166. package/client/dist/assets/styles-c10674c1-COhXxX8c.js +116 -0
  167. package/client/dist/assets/subset-shared.chunk-BWHnFai4.js +22 -0
  168. package/client/dist/assets/subset-worker.chunk-C8QUSruZ.js +1 -0
  169. package/client/dist/assets/sv-SE-XGPEYMSR-C1425rOF.js +10 -0
  170. package/client/dist/assets/svgDrawCommon-08f97a94-Cfk-fgnN.js +1 -0
  171. package/client/dist/assets/ta-IN-2NMHFXQM-BHHo1zpF.js +9 -0
  172. package/client/dist/assets/th-TH-HPSO5L25-CZVzm_WT.js +2 -0
  173. package/client/dist/assets/timeline-definition-85554ec2-VAvuJith.js +61 -0
  174. package/client/dist/assets/tr-TR-DEFEU3FU-DE1lclCq.js +7 -0
  175. package/client/dist/assets/uk-UA-QMV73CPH-D4lJZ85O.js +6 -0
  176. package/client/dist/assets/vendor-codemirror-BARtJV1V.js +16 -0
  177. package/client/dist/assets/vendor-codemirror-langs-52_y1wip.js +20 -0
  178. package/client/dist/assets/vendor-i18n-ByAl-gdx.js +1 -0
  179. package/client/dist/assets/vendor-icons-D33IkSIf.js +1 -0
  180. package/client/dist/assets/vendor-markdown-CIVH08vJ.js +298 -0
  181. package/client/dist/assets/vendor-react-CHoMc7ka.js +8 -0
  182. package/client/dist/assets/vendor-syntax-Djb62v3a.js +9 -0
  183. package/client/dist/assets/vendor-xterm-DBb3RXlu.js +66 -0
  184. package/client/dist/assets/vendor-xterm-DrlLKa8f.css +1 -0
  185. package/client/dist/assets/vi-VN-M7AON7JQ-Dgc_SShk.js +5 -0
  186. package/client/dist/assets/xychartDiagram-e933f94c-BeyVBJhb.js +7 -0
  187. package/client/dist/assets/zh-CN-LNUGB5OW-MH4Yh8in.js +10 -0
  188. package/client/dist/assets/zh-HK-E62DVLB3-D4XHehjx.js +1 -0
  189. package/client/dist/assets/zh-TW-RAJ6MFWO--efj3evj.js +9 -0
  190. package/client/dist/clear-cache.html +85 -0
  191. package/client/dist/convert-icons.md +53 -0
  192. package/client/dist/favicon.png +0 -0
  193. package/client/dist/favicon.svg +9 -0
  194. package/client/dist/generate-icons.js +49 -0
  195. package/client/dist/icons/claude-ai-icon.svg +1 -0
  196. package/client/dist/icons/codex-white.svg +3 -0
  197. package/client/dist/icons/codex.svg +3 -0
  198. package/client/dist/icons/cursor-white.svg +12 -0
  199. package/client/dist/icons/cursor.svg +1 -0
  200. package/client/dist/icons/icon-128x128.png +0 -0
  201. package/client/dist/icons/icon-128x128.svg +12 -0
  202. package/client/dist/icons/icon-144x144.png +0 -0
  203. package/client/dist/icons/icon-144x144.svg +12 -0
  204. package/client/dist/icons/icon-152x152.png +0 -0
  205. package/client/dist/icons/icon-152x152.svg +12 -0
  206. package/client/dist/icons/icon-192x192.png +0 -0
  207. package/client/dist/icons/icon-192x192.svg +12 -0
  208. package/client/dist/icons/icon-384x384.png +0 -0
  209. package/client/dist/icons/icon-384x384.svg +12 -0
  210. package/client/dist/icons/icon-512x512.png +0 -0
  211. package/client/dist/icons/icon-512x512.svg +12 -0
  212. package/client/dist/icons/icon-72x72.png +0 -0
  213. package/client/dist/icons/icon-72x72.svg +12 -0
  214. package/client/dist/icons/icon-96x96.png +0 -0
  215. package/client/dist/icons/icon-96x96.svg +12 -0
  216. package/client/dist/icons/icon-template.svg +12 -0
  217. package/client/dist/index.html +128 -0
  218. package/client/dist/logo-128.png +0 -0
  219. package/client/dist/logo-256.png +0 -0
  220. package/client/dist/logo-32.png +0 -0
  221. package/client/dist/logo-512.png +0 -0
  222. package/client/dist/logo-64.png +0 -0
  223. package/client/dist/logo.svg +17 -0
  224. package/client/dist/manifest.json +61 -0
  225. package/client/dist/mcp-docs.html +119 -0
  226. package/client/dist/screenshots/cli-selection.png +0 -0
  227. package/client/dist/screenshots/desktop-main.png +0 -0
  228. package/client/dist/screenshots/mobile-chat.png +0 -0
  229. package/client/dist/screenshots/tools-modal.png +0 -0
  230. package/client/dist/sw.js +19 -0
  231. package/commands/upfynai-connect.md +46 -0
  232. package/commands/upfynai-disconnect.md +31 -0
  233. package/commands/upfynai-doctor.md +99 -0
  234. package/commands/upfynai-export.md +49 -0
  235. package/commands/upfynai-local.md +82 -0
  236. package/commands/upfynai-status.md +75 -0
  237. package/commands/upfynai-stop.md +49 -0
  238. package/commands/upfynai-uninstall.md +58 -0
  239. package/commands/upfynai.md +50 -0
  240. package/package.json +106 -47
  241. package/scripts/build-client.js +17 -0
  242. package/scripts/fix-node-pty.js +67 -0
  243. package/scripts/install-commands.js +78 -0
  244. package/server/claude-sdk.js +714 -0
  245. package/server/cli.js +419 -0
  246. package/server/constants/config.js +5 -0
  247. package/server/cursor-cli.js +270 -0
  248. package/server/database/auth.db +0 -0
  249. package/server/database/db.js +606 -0
  250. package/server/database/init.sql +70 -0
  251. package/server/index.js +2269 -0
  252. package/server/load-env.js +26 -0
  253. package/server/mcp-server.js +620 -0
  254. package/server/middleware/auth.js +158 -0
  255. package/server/openai-codex.js +403 -0
  256. package/server/projects.js +1849 -0
  257. package/server/relay-client.js +314 -0
  258. package/server/routes/agent.js +1231 -0
  259. package/server/routes/auth.js +220 -0
  260. package/server/routes/cli-auth.js +263 -0
  261. package/server/routes/codex.js +344 -0
  262. package/server/routes/commands.js +601 -0
  263. package/server/routes/cursor.js +808 -0
  264. package/server/routes/git.js +1165 -0
  265. package/server/routes/mcp-utils.js +48 -0
  266. package/server/routes/mcp.js +552 -0
  267. package/server/routes/payments.js +172 -0
  268. package/server/routes/projects.js +549 -0
  269. package/server/routes/settings.js +178 -0
  270. package/server/routes/taskmaster.js +1964 -0
  271. package/server/routes/user.js +106 -0
  272. package/server/utils/commandParser.js +303 -0
  273. package/server/utils/gitConfig.js +24 -0
  274. package/server/utils/mcp-detector.js +198 -0
  275. package/server/utils/taskmaster-websocket.js +129 -0
  276. package/shared/modelConstants.js +67 -0
  277. package/LICENSE +0 -22
  278. package/bin/cli.js +0 -86
  279. package/dist/assets/CanvasPanel-B48gAKVY.js +0 -538
  280. package/dist/assets/CanvasPanel-B48gAKVY.js.map +0 -1
  281. package/dist/assets/CanvasPanel-BsOG3EVs.css +0 -1
  282. package/dist/assets/index-CEhTwG68.css +0 -1
  283. package/dist/assets/index-GqAGWpJI.js +0 -70
  284. package/dist/assets/index-GqAGWpJI.js.map +0 -1
  285. package/dist/index.html +0 -18
  286. package/index.html +0 -17
  287. package/src/App.tsx +0 -226
  288. package/src/components/canvas/CanvasPanel.tsx +0 -62
  289. package/src/components/canvas/layout/graph-builder.ts +0 -136
  290. package/src/components/canvas/shapes/CompactionNodeShape.tsx +0 -76
  291. package/src/components/canvas/shapes/SessionNodeShape.tsx +0 -93
  292. package/src/components/canvas/shapes/StatuslineWidgetShape.tsx +0 -125
  293. package/src/components/canvas/shapes/TextResponseNodeShape.tsx +0 -86
  294. package/src/components/canvas/shapes/ToolCallNodeShape.tsx +0 -107
  295. package/src/components/canvas/shapes/ToolResultNodeShape.tsx +0 -87
  296. package/src/components/canvas/shapes/shared-styles.ts +0 -35
  297. package/src/components/chat/ChatPanel.tsx +0 -96
  298. package/src/components/chat/InputBar.tsx +0 -81
  299. package/src/components/chat/MessageList.tsx +0 -130
  300. package/src/components/chat/PermissionDialog.tsx +0 -70
  301. package/src/components/layout/FolderSelector.tsx +0 -152
  302. package/src/components/layout/ModelSelector.tsx +0 -65
  303. package/src/components/layout/SessionManager.tsx +0 -115
  304. package/src/components/statusline/StatuslineBar.tsx +0 -114
  305. package/src/main.tsx +0 -10
  306. package/src/server/claude-session.ts +0 -156
  307. package/src/server/index.ts +0 -149
  308. package/src/services/stream-consumer.ts +0 -330
  309. package/src/statusline-core/bin/statusline.sh +0 -121
  310. package/src/statusline-core/commands/sls-config.md +0 -42
  311. package/src/statusline-core/commands/sls-doctor.md +0 -35
  312. package/src/statusline-core/commands/sls-help.md +0 -48
  313. package/src/statusline-core/commands/sls-layout.md +0 -38
  314. package/src/statusline-core/commands/sls-preview.md +0 -34
  315. package/src/statusline-core/commands/sls-theme.md +0 -40
  316. package/src/statusline-core/installer.js +0 -228
  317. package/src/statusline-core/layouts/compact.sh +0 -21
  318. package/src/statusline-core/layouts/full.sh +0 -62
  319. package/src/statusline-core/layouts/standard.sh +0 -39
  320. package/src/statusline-core/lib/core.sh +0 -389
  321. package/src/statusline-core/lib/helpers.sh +0 -81
  322. package/src/statusline-core/lib/json-parser.sh +0 -71
  323. package/src/statusline-core/themes/catppuccin.sh +0 -32
  324. package/src/statusline-core/themes/default.sh +0 -37
  325. package/src/statusline-core/themes/gruvbox.sh +0 -32
  326. package/src/statusline-core/themes/nord.sh +0 -32
  327. package/src/statusline-core/themes/tokyo-night.sh +0 -32
  328. package/src/store/canvas-store.ts +0 -50
  329. package/src/store/chat-store.ts +0 -60
  330. package/src/store/permission-store.ts +0 -29
  331. package/src/store/session-store.ts +0 -52
  332. package/src/store/statusline-store.ts +0 -160
  333. package/src/styles/global.css +0 -117
  334. package/src/themes/index.ts +0 -149
  335. package/src/types/canvas-graph.ts +0 -24
  336. package/src/types/sdk-messages.ts +0 -156
  337. package/src/types/statusline-fields.ts +0 -67
  338. package/src/vite-env.d.ts +0 -1
  339. package/tsconfig.json +0 -26
  340. package/vite.config.ts +0 -24
package/server/cli.js ADDED
@@ -0,0 +1,419 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Upfyn-Code CLI
4
+ * by Thinqmesh Technologies
5
+ *
6
+ * Visual AI coding interface with Upfyn-Canvas for AI coding assistants
7
+ *
8
+ * Commands:
9
+ * (no args) - Start the server (default)
10
+ * start - Start the server
11
+ * status - Show configuration and data locations
12
+ * help - Show help information
13
+ * version - Show version information
14
+ */
15
+
16
+ import fs from 'fs';
17
+ import path from 'path';
18
+ import os from 'os';
19
+ import { fileURLToPath } from 'url';
20
+ import { dirname } from 'path';
21
+
22
+ const __filename = fileURLToPath(import.meta.url);
23
+ const __dirname = dirname(__filename);
24
+
25
+ // ANSI color codes for terminal output
26
+ const colors = {
27
+ reset: '\x1b[0m',
28
+ bright: '\x1b[1m',
29
+ dim: '\x1b[2m',
30
+
31
+ // Foreground colors
32
+ cyan: '\x1b[36m',
33
+ green: '\x1b[32m',
34
+ yellow: '\x1b[33m',
35
+ blue: '\x1b[34m',
36
+ magenta: '\x1b[35m',
37
+ white: '\x1b[37m',
38
+ gray: '\x1b[90m',
39
+ };
40
+
41
+ // Helper to colorize text
42
+ const c = {
43
+ info: (text) => `${colors.cyan}${text}${colors.reset}`,
44
+ ok: (text) => `${colors.green}${text}${colors.reset}`,
45
+ warn: (text) => `${colors.yellow}${text}${colors.reset}`,
46
+ error: (text) => `${colors.yellow}${text}${colors.reset}`,
47
+ tip: (text) => `${colors.blue}${text}${colors.reset}`,
48
+ bright: (text) => `${colors.bright}${text}${colors.reset}`,
49
+ dim: (text) => `${colors.dim}${text}${colors.reset}`,
50
+ };
51
+
52
+ // Load package.json for version info
53
+ const packageJsonPath = path.join(__dirname, '../package.json');
54
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
55
+
56
+ // Load environment variables from .env file if it exists
57
+ function loadEnvFile() {
58
+ try {
59
+ const envPath = path.join(__dirname, '../.env');
60
+ const envFile = fs.readFileSync(envPath, 'utf8');
61
+ envFile.split('\n').forEach(line => {
62
+ const trimmedLine = line.trim();
63
+ if (trimmedLine && !trimmedLine.startsWith('#')) {
64
+ const [key, ...valueParts] = trimmedLine.split('=');
65
+ if (key && valueParts.length > 0 && !process.env[key]) {
66
+ process.env[key] = valueParts.join('=').trim();
67
+ }
68
+ }
69
+ });
70
+ } catch (e) {
71
+ // .env file is optional
72
+ }
73
+ }
74
+
75
+ // Get the database path (same logic as db.js)
76
+ function getDatabasePath() {
77
+ loadEnvFile();
78
+ return process.env.DATABASE_PATH || path.join(__dirname, 'database', 'auth.db');
79
+ }
80
+
81
+ // Get the installation directory
82
+ function getInstallDir() {
83
+ return path.join(__dirname, '..');
84
+ }
85
+
86
+ // Show status command
87
+ function showStatus() {
88
+ console.log(`\n${c.bright('Upfyn-Code - Status')}\n`);
89
+ console.log(c.dim('═'.repeat(60)));
90
+
91
+ // Version info
92
+ console.log(`\n${c.info('[INFO]')} Version: ${c.bright(packageJson.version)}`);
93
+
94
+ // Installation location
95
+ const installDir = getInstallDir();
96
+ console.log(`\n${c.info('[INFO]')} Installation Directory:`);
97
+ console.log(` ${c.dim(installDir)}`);
98
+
99
+ // Database location
100
+ const dbPath = getDatabasePath();
101
+ const dbExists = fs.existsSync(dbPath);
102
+ console.log(`\n${c.info('[INFO]')} Database Location:`);
103
+ console.log(` ${c.dim(dbPath)}`);
104
+ console.log(` Status: ${dbExists ? c.ok('[OK] Exists') : c.warn('[WARN] Not created yet (will be created on first run)')}`);
105
+
106
+ if (dbExists) {
107
+ const stats = fs.statSync(dbPath);
108
+ console.log(` Size: ${c.dim((stats.size / 1024).toFixed(2) + ' KB')}`);
109
+ console.log(` Modified: ${c.dim(stats.mtime.toLocaleString())}`);
110
+ }
111
+
112
+ // Environment variables
113
+ console.log(`\n${c.info('[INFO]')} Configuration:`);
114
+ console.log(` PORT: ${c.bright(process.env.PORT || '3001')} ${c.dim(process.env.PORT ? '' : '(default)')}`);
115
+ console.log(` DATABASE_PATH: ${c.dim(process.env.DATABASE_PATH || '(using default location)')}`);
116
+ console.log(` CLAUDE_CLI_PATH: ${c.dim(process.env.CLAUDE_CLI_PATH || 'claude (default)')}`);
117
+ console.log(` CONTEXT_WINDOW: ${c.dim(process.env.CONTEXT_WINDOW || '160000 (default)')}`);
118
+
119
+ // Claude projects folder
120
+ const claudeProjectsPath = path.join(os.homedir(), '.claude', 'projects');
121
+ const projectsExists = fs.existsSync(claudeProjectsPath);
122
+ console.log(`\n${c.info('[INFO]')} Claude Projects Folder:`);
123
+ console.log(` ${c.dim(claudeProjectsPath)}`);
124
+ console.log(` Status: ${projectsExists ? c.ok('[OK] Exists') : c.warn('[WARN] Not found')}`);
125
+
126
+ // Config file location
127
+ const envFilePath = path.join(__dirname, '../.env');
128
+ const envExists = fs.existsSync(envFilePath);
129
+ console.log(`\n${c.info('[INFO]')} Configuration File:`);
130
+ console.log(` ${c.dim(envFilePath)}`);
131
+ console.log(` Status: ${envExists ? c.ok('[OK] Exists') : c.warn('[WARN] Not found (using defaults)')}`);
132
+
133
+ console.log('\n' + c.dim('═'.repeat(60)));
134
+ console.log(`\n${c.tip('[TIP]')} Hints:`);
135
+ console.log(` ${c.dim('>')} Use ${c.bright('uc --port 8080')} to run on a custom port`);
136
+ console.log(` ${c.dim('>')} Use ${c.bright('uc --database-path /path/to/db')} for custom database`);
137
+ console.log(` ${c.dim('>')} Run ${c.bright('uc help')} for all options`);
138
+ console.log(` ${c.dim('>')} Access the UI at http://localhost:${process.env.PORT || '3001'}\n`);
139
+ }
140
+
141
+ // Show help
142
+ function showHelp() {
143
+ console.log(`
144
+ ╔═══════════════════════════════════════════════════════════════╗
145
+ ║ Upfyn-Code — by Thinqmesh Technologies ║
146
+ ║ Visual AI Coding Interface with tldraw Canvas ║
147
+ ╚═══════════════════════════════════════════════════════════════╝
148
+
149
+ Usage:
150
+ upfynai-code [command] [options]
151
+ uc [command] [options]
152
+
153
+ Commands:
154
+ start Start the server (default)
155
+ connect Connect local machine to hosted server (relay bridge)
156
+ status Show configuration and data locations
157
+ install-commands Install /upfynai-* slash commands to ~/.claude/commands/
158
+ uninstall-commands Remove /upfynai-* slash commands
159
+ update Update to the latest version
160
+ help Show this help information
161
+ version Show version information
162
+
163
+ Slash Commands (inside your AI CLI):
164
+ /upfynai Start the web UI server
165
+ /upfynai-connect Connect CLI session to web UI
166
+ /upfynai-disconnect Disconnect from web UI
167
+ /upfynai-status Show connection status
168
+ /upfynai-doctor Run diagnostics
169
+ /upfynai-export Export session/canvas data
170
+ /upfynai-stop Stop the web UI server
171
+ /upfynai-local Full local installation setup
172
+ /upfynai-uninstall Remove Upfyn-Code
173
+
174
+ Options:
175
+ -p, --port <port> Set server port (default: 3001)
176
+ --database-path <path> Set custom database location
177
+ -h, --help Show this help information
178
+ -v, --version Show version information
179
+
180
+ Options:
181
+ --server <url> Server URL for connect (default: https://upfynai.thinqmesh.com)
182
+ --key <token> Relay token for connect (get from Settings > Relay Tokens)
183
+
184
+ Examples:
185
+ $ uc # Start with defaults
186
+ $ uc --port 8080 # Start on port 8080
187
+ $ uc connect --key upfyn_xxx # Bridge to hosted server
188
+ $ uc start --port 4000 # Explicit start command
189
+ $ uc status # Show configuration
190
+
191
+ Environment Variables:
192
+ PORT Set server port (default: 3001)
193
+ DATABASE_PATH Set custom database location
194
+ CLAUDE_CLI_PATH Set custom Claude CLI path
195
+ CONTEXT_WINDOW Set context window size (default: 160000)
196
+
197
+ Documentation:
198
+ ${packageJson.homepage || 'https://github.com/AnitChaudhry/UpfynAI-Code'}
199
+
200
+ Report Issues:
201
+ ${packageJson.bugs?.url || 'https://github.com/AnitChaudhry/UpfynAI-Code/issues'}
202
+ `);
203
+ }
204
+
205
+ // Show version
206
+ function showVersion() {
207
+ console.log(`${packageJson.version}`);
208
+ }
209
+
210
+ // Compare semver versions, returns true if v1 > v2
211
+ function isNewerVersion(v1, v2) {
212
+ const parts1 = v1.split('.').map(Number);
213
+ const parts2 = v2.split('.').map(Number);
214
+ for (let i = 0; i < 3; i++) {
215
+ if (parts1[i] > parts2[i]) return true;
216
+ if (parts1[i] < parts2[i]) return false;
217
+ }
218
+ return false;
219
+ }
220
+
221
+ // Check for updates
222
+ async function checkForUpdates(silent = false) {
223
+ try {
224
+ const { execSync } = await import('child_process');
225
+ const latestVersion = execSync('npm show upfynai-code version', { encoding: 'utf8' }).trim();
226
+ const currentVersion = packageJson.version;
227
+
228
+ if (isNewerVersion(latestVersion, currentVersion)) {
229
+ console.log(`\n${c.warn('[UPDATE]')} New version available: ${c.bright(latestVersion)} (current: ${currentVersion})`);
230
+ console.log(` Run ${c.bright('uc update')} to update\n`);
231
+ return { hasUpdate: true, latestVersion, currentVersion };
232
+ } else if (!silent) {
233
+ console.log(`${c.ok('[OK]')} You are on the latest version (${currentVersion})`);
234
+ }
235
+ return { hasUpdate: false, latestVersion, currentVersion };
236
+ } catch (e) {
237
+ if (!silent) {
238
+ console.log(`${c.warn('[WARN]')} Could not check for updates`);
239
+ }
240
+ return { hasUpdate: false, error: e.message };
241
+ }
242
+ }
243
+
244
+ // Update the package
245
+ async function updatePackage() {
246
+ try {
247
+ const { execSync } = await import('child_process');
248
+ console.log(`${c.info('[INFO]')} Checking for updates...`);
249
+
250
+ const { hasUpdate, latestVersion, currentVersion } = await checkForUpdates(true);
251
+
252
+ if (!hasUpdate) {
253
+ console.log(`${c.ok('[OK]')} Already on the latest version (${currentVersion})`);
254
+ return;
255
+ }
256
+
257
+ console.log(`${c.info('[INFO]')} Updating from ${currentVersion} to ${latestVersion}...`);
258
+ execSync('npm update -g upfynai-code', { stdio: 'inherit' });
259
+ console.log(`${c.ok('[OK]')} Update complete! Restart uc to use the new version.`);
260
+ } catch (e) {
261
+ console.error(`${c.error('[ERROR]')} Update failed: ${e.message}`);
262
+ console.log(`${c.tip('[TIP]')} Try running manually: npm update -g upfynai-code`);
263
+ }
264
+ }
265
+
266
+ // Install slash commands to ~/.claude/commands/
267
+ async function installCommands() {
268
+ const commandsSource = path.join(__dirname, '..', 'commands');
269
+ const commandsDest = path.join(os.homedir(), '.claude', 'commands');
270
+
271
+ if (!fs.existsSync(commandsDest)) {
272
+ fs.mkdirSync(commandsDest, { recursive: true });
273
+ }
274
+
275
+ if (!fs.existsSync(commandsSource)) {
276
+ console.error(`${c.error('[ERROR]')} Commands directory not found`);
277
+ process.exit(1);
278
+ }
279
+
280
+ const files = fs.readdirSync(commandsSource).filter(f => f.endsWith('.md'));
281
+ let count = 0;
282
+
283
+ for (const file of files) {
284
+ fs.copyFileSync(
285
+ path.join(commandsSource, file),
286
+ path.join(commandsDest, file)
287
+ );
288
+ console.log(`${c.ok('[OK]')} Installed /${file.replace('.md', '')}`);
289
+ count++;
290
+ }
291
+
292
+ console.log(`\n${c.bright(`${count} slash commands installed!`)}`);
293
+ console.log(`${c.dim('Available in your AI CLI as /upfynai-*')}\n`);
294
+ }
295
+
296
+ // Remove slash commands from ~/.claude/commands/
297
+ async function uninstallCommands() {
298
+ const commandsDest = path.join(os.homedir(), '.claude', 'commands');
299
+ const files = fs.existsSync(commandsDest)
300
+ ? fs.readdirSync(commandsDest).filter(f => f.startsWith('upfynai'))
301
+ : [];
302
+
303
+ if (files.length === 0) {
304
+ console.log(`${c.warn('[WARN]')} No Upfyn-Code commands found to remove`);
305
+ return;
306
+ }
307
+
308
+ for (const file of files) {
309
+ fs.unlinkSync(path.join(commandsDest, file));
310
+ console.log(`${c.ok('[OK]')} Removed /${file.replace('.md', '')}`);
311
+ }
312
+
313
+ console.log(`\n${c.bright(`${files.length} slash commands removed.`)}\n`);
314
+ }
315
+
316
+ // Start the server
317
+ async function startServer() {
318
+ // Check for updates silently on startup
319
+ checkForUpdates(true);
320
+
321
+ // Import and run the server
322
+ await import('./index.js');
323
+ }
324
+
325
+ // Parse CLI arguments
326
+ function parseArgs(args) {
327
+ const parsed = { command: 'start', options: {} };
328
+
329
+ for (let i = 0; i < args.length; i++) {
330
+ const arg = args[i];
331
+
332
+ if (arg === '--port' || arg === '-p') {
333
+ parsed.options.port = args[++i];
334
+ } else if (arg.startsWith('--port=')) {
335
+ parsed.options.port = arg.split('=')[1];
336
+ } else if (arg === '--database-path') {
337
+ parsed.options.databasePath = args[++i];
338
+ } else if (arg.startsWith('--database-path=')) {
339
+ parsed.options.databasePath = arg.split('=')[1];
340
+ } else if (arg === '--server') {
341
+ parsed.options.server = args[++i];
342
+ } else if (arg.startsWith('--server=')) {
343
+ parsed.options.server = arg.split('=')[1];
344
+ } else if (arg === '--key') {
345
+ parsed.options.key = args[++i];
346
+ } else if (arg.startsWith('--key=')) {
347
+ parsed.options.key = arg.split('=')[1];
348
+ } else if (arg === '--help' || arg === '-h') {
349
+ parsed.command = 'help';
350
+ } else if (arg === '--version' || arg === '-v') {
351
+ parsed.command = 'version';
352
+ } else if (!arg.startsWith('-')) {
353
+ parsed.command = arg;
354
+ }
355
+ }
356
+
357
+ return parsed;
358
+ }
359
+
360
+ // Main CLI handler
361
+ async function main() {
362
+ const args = process.argv.slice(2);
363
+ const { command, options } = parseArgs(args);
364
+
365
+ // Apply CLI options to environment variables
366
+ if (options.port) {
367
+ process.env.PORT = options.port;
368
+ }
369
+ if (options.databasePath) {
370
+ process.env.DATABASE_PATH = options.databasePath;
371
+ }
372
+
373
+ switch (command) {
374
+ case 'start':
375
+ await startServer();
376
+ break;
377
+ case 'status':
378
+ case 'info':
379
+ showStatus();
380
+ break;
381
+ case 'help':
382
+ case '-h':
383
+ case '--help':
384
+ showHelp();
385
+ break;
386
+ case 'version':
387
+ case '-v':
388
+ case '--version':
389
+ showVersion();
390
+ break;
391
+ case 'update':
392
+ await updatePackage();
393
+ break;
394
+ case 'install-commands':
395
+ await installCommands();
396
+ break;
397
+ case 'uninstall-commands':
398
+ await uninstallCommands();
399
+ break;
400
+ case 'connect': {
401
+ const { connectToServer } = await import('./relay-client.js');
402
+ await connectToServer({
403
+ server: options.server || args[1],
404
+ key: options.key || args[2],
405
+ });
406
+ break;
407
+ }
408
+ default:
409
+ console.error(`\n❌ Unknown command: ${command}`);
410
+ console.log(' Run "uc help" for usage information.\n');
411
+ process.exit(1);
412
+ }
413
+ }
414
+
415
+ // Run the CLI
416
+ main().catch(error => {
417
+ console.error('\n❌ Error:', error.message);
418
+ process.exit(1);
419
+ });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Environment Flag: Is Platform
3
+ * Indicates if the app is running in Platform mode (hosted) or OSS mode (self-hosted)
4
+ */
5
+ export const IS_PLATFORM = process.env.VITE_IS_PLATFORM === 'true';
@@ -0,0 +1,270 @@
1
+ import { spawn } from 'child_process';
2
+ import crossSpawn from 'cross-spawn';
3
+ import { promises as fs } from 'fs';
4
+ import path from 'path';
5
+ import os from 'os';
6
+
7
+ // Use cross-spawn on Windows for better command execution
8
+ const spawnFunction = process.platform === 'win32' ? crossSpawn : spawn;
9
+
10
+ let activeCursorProcesses = new Map(); // Track active processes by session ID
11
+
12
+ async function spawnCursor(command, options = {}, ws) {
13
+ return new Promise(async (resolve, reject) => {
14
+ const { sessionId, projectPath, cwd, resume, toolsSettings, skipPermissions, model, images } = options;
15
+ let capturedSessionId = sessionId; // Track session ID throughout the process
16
+ let sessionCreatedSent = false; // Track if we've already sent session-created event
17
+ let messageBuffer = ''; // Buffer for accumulating assistant messages
18
+
19
+ // Use tools settings passed from frontend, or defaults
20
+ const settings = toolsSettings || {
21
+ allowedShellCommands: [],
22
+ skipPermissions: false
23
+ };
24
+
25
+ // Build Cursor CLI command
26
+ const args = [];
27
+
28
+ // Build flags allowing both resume and prompt together (reply in existing session)
29
+ // Treat presence of sessionId as intention to resume, regardless of resume flag
30
+ if (sessionId) {
31
+ args.push('--resume=' + sessionId);
32
+ }
33
+
34
+ if (command && command.trim()) {
35
+ // Provide a prompt (works for both new and resumed sessions)
36
+ args.push('-p', command);
37
+
38
+ // Add model flag if specified (only meaningful for new sessions; harmless on resume)
39
+ if (!sessionId && model) {
40
+ args.push('--model', model);
41
+ }
42
+
43
+ // Request streaming JSON when we are providing a prompt
44
+ args.push('--output-format', 'stream-json');
45
+ }
46
+
47
+ // Add skip permissions flag if enabled
48
+ if (skipPermissions || settings.skipPermissions) {
49
+ args.push('-f');
50
+ }
51
+
52
+ // Use cwd (actual project directory) instead of projectPath
53
+ const workingDir = cwd || projectPath || process.cwd();
54
+
55
+ const cursorProcess = spawnFunction('cursor-agent', args, {
56
+ cwd: workingDir,
57
+ stdio: ['pipe', 'pipe', 'pipe'],
58
+ env: { ...process.env } // Inherit all environment variables
59
+ });
60
+
61
+ // Store process reference for potential abort
62
+ const processKey = capturedSessionId || Date.now().toString();
63
+ activeCursorProcesses.set(processKey, cursorProcess);
64
+
65
+ // Handle stdout (streaming JSON responses)
66
+ cursorProcess.stdout.on('data', (data) => {
67
+ const rawOutput = data.toString();
68
+ // stdout received
69
+
70
+ const lines = rawOutput.split('\n').filter(line => line.trim());
71
+
72
+ for (const line of lines) {
73
+ try {
74
+ const response = JSON.parse(line);
75
+ // parsed response
76
+
77
+ // Handle different message types
78
+ switch (response.type) {
79
+ case 'system':
80
+ if (response.subtype === 'init') {
81
+ // Capture session ID
82
+ if (response.session_id && !capturedSessionId) {
83
+ capturedSessionId = response.session_id;
84
+ // session ID captured
85
+
86
+ // Update process key with captured session ID
87
+ if (processKey !== capturedSessionId) {
88
+ activeCursorProcesses.delete(processKey);
89
+ activeCursorProcesses.set(capturedSessionId, cursorProcess);
90
+ }
91
+
92
+ // Set session ID on writer (for API endpoint compatibility)
93
+ if (ws.setSessionId && typeof ws.setSessionId === 'function') {
94
+ ws.setSessionId(capturedSessionId);
95
+ }
96
+
97
+ // Send session-created event only once for new sessions
98
+ if (!sessionId && !sessionCreatedSent) {
99
+ sessionCreatedSent = true;
100
+ ws.send({
101
+ type: 'session-created',
102
+ sessionId: capturedSessionId,
103
+ model: response.model,
104
+ cwd: response.cwd
105
+ });
106
+ }
107
+ }
108
+
109
+ // Send system info to frontend
110
+ ws.send({
111
+ type: 'cursor-system',
112
+ data: response,
113
+ sessionId: capturedSessionId || sessionId || null
114
+ });
115
+ }
116
+ break;
117
+
118
+ case 'user':
119
+ // Forward user message
120
+ ws.send({
121
+ type: 'cursor-user',
122
+ data: response,
123
+ sessionId: capturedSessionId || sessionId || null
124
+ });
125
+ break;
126
+
127
+ case 'assistant':
128
+ // Accumulate assistant message chunks
129
+ if (response.message && response.message.content && response.message.content.length > 0) {
130
+ const textContent = response.message.content[0].text;
131
+ messageBuffer += textContent;
132
+
133
+ // Send as Claude-compatible format for frontend
134
+ ws.send({
135
+ type: 'claude-response',
136
+ data: {
137
+ type: 'content_block_delta',
138
+ delta: {
139
+ type: 'text_delta',
140
+ text: textContent
141
+ }
142
+ },
143
+ sessionId: capturedSessionId || sessionId || null
144
+ });
145
+ }
146
+ break;
147
+
148
+ case 'result':
149
+ // Session complete
150
+ // session result received
151
+
152
+ // Send final message if we have buffered content
153
+ if (messageBuffer) {
154
+ ws.send({
155
+ type: 'claude-response',
156
+ data: {
157
+ type: 'content_block_stop'
158
+ },
159
+ sessionId: capturedSessionId || sessionId || null
160
+ });
161
+ }
162
+
163
+ // Send completion event
164
+ ws.send({
165
+ type: 'cursor-result',
166
+ sessionId: capturedSessionId || sessionId,
167
+ data: response,
168
+ success: response.subtype === 'success'
169
+ });
170
+ break;
171
+
172
+ default:
173
+ // Forward any other message types
174
+ ws.send({
175
+ type: 'cursor-response',
176
+ data: response,
177
+ sessionId: capturedSessionId || sessionId || null
178
+ });
179
+ }
180
+ } catch (parseError) {
181
+ // non-JSON response skipped
182
+ // If not JSON, send as raw text
183
+ ws.send({
184
+ type: 'cursor-output',
185
+ data: line,
186
+ sessionId: capturedSessionId || sessionId || null
187
+ });
188
+ }
189
+ }
190
+ });
191
+
192
+ // Handle stderr
193
+ cursorProcess.stderr.on('data', (data) => {
194
+ // stderr output received
195
+ ws.send({
196
+ type: 'cursor-error',
197
+ error: data.toString(),
198
+ sessionId: capturedSessionId || sessionId || null
199
+ });
200
+ });
201
+
202
+ // Handle process completion
203
+ cursorProcess.on('close', async (code) => {
204
+ // process exited
205
+
206
+ // Clean up process reference
207
+ const finalSessionId = capturedSessionId || sessionId || processKey;
208
+ activeCursorProcesses.delete(finalSessionId);
209
+
210
+ ws.send({
211
+ type: 'claude-complete',
212
+ sessionId: finalSessionId,
213
+ exitCode: code,
214
+ isNewSession: !sessionId && !!command // Flag to indicate this was a new session
215
+ });
216
+
217
+ if (code === 0) {
218
+ resolve();
219
+ } else {
220
+ reject(new Error(`Cursor CLI exited with code ${code}`));
221
+ }
222
+ });
223
+
224
+ // Handle process errors
225
+ cursorProcess.on('error', (error) => {
226
+ // process error occurred
227
+
228
+ // Clean up process reference on error
229
+ const finalSessionId = capturedSessionId || sessionId || processKey;
230
+ activeCursorProcesses.delete(finalSessionId);
231
+
232
+ ws.send({
233
+ type: 'cursor-error',
234
+ error: error.message,
235
+ sessionId: capturedSessionId || sessionId || null
236
+ });
237
+
238
+ reject(error);
239
+ });
240
+
241
+ // Close stdin since Cursor doesn't need interactive input
242
+ cursorProcess.stdin.end();
243
+ });
244
+ }
245
+
246
+ function abortCursorSession(sessionId) {
247
+ const process = activeCursorProcesses.get(sessionId);
248
+ if (process) {
249
+ // aborting session
250
+ process.kill('SIGTERM');
251
+ activeCursorProcesses.delete(sessionId);
252
+ return true;
253
+ }
254
+ return false;
255
+ }
256
+
257
+ function isCursorSessionActive(sessionId) {
258
+ return activeCursorProcesses.has(sessionId);
259
+ }
260
+
261
+ function getActiveCursorSessions() {
262
+ return Array.from(activeCursorProcesses.keys());
263
+ }
264
+
265
+ export {
266
+ spawnCursor,
267
+ abortCursorSession,
268
+ isCursorSessionActive,
269
+ getActiveCursorSessions
270
+ };
Binary file