upfynai-code 2.5.1 → 2.6.1

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 (293) hide show
  1. package/README.md +123 -88
  2. package/bin/cli.js +63 -0
  3. package/package.json +48 -112
  4. package/src/auth.js +115 -0
  5. package/src/config.js +33 -0
  6. package/src/connect.js +314 -0
  7. package/src/launch.js +54 -0
  8. package/src/mcp.js +57 -0
  9. package/src/server.js +54 -0
  10. package/client/dist/api-docs.html +0 -879
  11. package/client/dist/assets/AppContent-C0CyP3g5.js +0 -513
  12. package/client/dist/assets/CanvasPanel-0u9QR7U-.js +0 -34
  13. package/client/dist/assets/CanvasPanel-WhZulBJw.css +0 -1
  14. package/client/dist/assets/DashboardPanel-Dgqw1yZk.js +0 -1
  15. package/client/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  16. package/client/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  17. package/client/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  18. package/client/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  19. package/client/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  20. package/client/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  21. package/client/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  22. package/client/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  23. package/client/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  24. package/client/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  25. package/client/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  26. package/client/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  27. package/client/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  28. package/client/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  29. package/client/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  30. package/client/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  31. package/client/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  32. package/client/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  33. package/client/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  34. package/client/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  35. package/client/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  36. package/client/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  37. package/client/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  38. package/client/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  39. package/client/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  40. package/client/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  41. package/client/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  42. package/client/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  43. package/client/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  44. package/client/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  45. package/client/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  46. package/client/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  47. package/client/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  48. package/client/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  49. package/client/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  50. package/client/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  51. package/client/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  52. package/client/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  53. package/client/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  54. package/client/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  55. package/client/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  56. package/client/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  57. package/client/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  58. package/client/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  59. package/client/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  60. package/client/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  61. package/client/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  62. package/client/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  63. package/client/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  64. package/client/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  65. package/client/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  66. package/client/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  67. package/client/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  68. package/client/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  69. package/client/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  70. package/client/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  71. package/client/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  72. package/client/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  73. package/client/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  74. package/client/dist/assets/LoginModal-CZDEzqjK.js +0 -19
  75. package/client/dist/assets/MarkdownPreview-CYdvwJaV.js +0 -1
  76. package/client/dist/assets/Onboarding-DR6NZ4Vz.js +0 -1
  77. package/client/dist/assets/SetupForm-D49gtWY4.js +0 -1
  78. package/client/dist/assets/Tableau10-B-NsZVaP.js +0 -1
  79. package/client/dist/assets/WorkflowsPanel-CqlbEJA_.js +0 -1
  80. package/client/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js +0 -1
  81. package/client/dist/assets/ar-SA-G6X2FPQ2-BWqa1yBH.js +0 -10
  82. package/client/dist/assets/arc-BegSKqEW.js +0 -1
  83. package/client/dist/assets/array-BKyUJesY.js +0 -1
  84. package/client/dist/assets/az-AZ-76LH7QW2-DrVlbZDP.js +0 -1
  85. package/client/dist/assets/bg-BG-XCXSNQG7-DdunjBgT.js +0 -5
  86. package/client/dist/assets/blockDiagram-38ab4fdb-BKMbwGHu.js +0 -118
  87. package/client/dist/assets/bn-BD-2XOGV67Q-_7DtmvwO.js +0 -5
  88. package/client/dist/assets/c4Diagram-3d4e48cf-hJuiHhSn.js +0 -10
  89. package/client/dist/assets/ca-ES-6MX7JW3Y-BFIrmojG.js +0 -8
  90. package/client/dist/assets/channel-Bur-rRTp.js +0 -1
  91. package/client/dist/assets/classDiagram-70f12bd4-BjiAf9cM.js +0 -2
  92. package/client/dist/assets/classDiagram-v2-f2320105-pwBewejc.js +0 -2
  93. package/client/dist/assets/clone-BtqXeoBJ.js +0 -1
  94. package/client/dist/assets/createText-2e5e7dd3-Dq_acOWe.js +0 -5
  95. package/client/dist/assets/cs-CZ-2BRQDIVT-B-x4F6TJ.js +0 -11
  96. package/client/dist/assets/da-DK-5WZEPLOC-Btlc8Dgn.js +0 -5
  97. package/client/dist/assets/de-DE-XR44H4JA-BVu3ZIoD.js +0 -8
  98. package/client/dist/assets/directory-open-01563666-DWU9wJ6I.js +0 -1
  99. package/client/dist/assets/directory-open-4ed118d0-CunoC1EB.js +0 -1
  100. package/client/dist/assets/edges-e0da2a9e-DH0wVTXR.js +0 -4
  101. package/client/dist/assets/el-GR-BZB4AONW-h2ll8_ZC.js +0 -10
  102. package/client/dist/assets/erDiagram-9861fffd-BYezLIR7.js +0 -51
  103. package/client/dist/assets/es-ES-U4NZUMDT-Cveiulwt.js +0 -9
  104. package/client/dist/assets/eu-ES-A7QVB2H4-DQluL2PY.js +0 -11
  105. package/client/dist/assets/fa-IR-HGAKTJCU-BJtcMBSv.js +0 -8
  106. package/client/dist/assets/fi-FI-Z5N7JZ37-D8NfbVXV.js +0 -6
  107. package/client/dist/assets/file-open-002ab408-DIuFHtCF.js +0 -1
  108. package/client/dist/assets/file-open-7c801643-684qeFg4.js +0 -1
  109. package/client/dist/assets/file-save-3189631c-C1wFhQhH.js +0 -1
  110. package/client/dist/assets/file-save-745eba88-Bb9F9Kg7.js +0 -1
  111. package/client/dist/assets/flowDb-956e92f1-scnUykhM.js +0 -10
  112. package/client/dist/assets/flowDiagram-66a62f08-jVyWsfyU.js +0 -4
  113. package/client/dist/assets/flowDiagram-v2-96b9c2cf-N6xgi25h.js +0 -1
  114. package/client/dist/assets/flowchart-elk-definition-4a651766-gKGX3HqR.js +0 -139
  115. package/client/dist/assets/fr-FR-RHASNOE6-vdj42kC6.js +0 -9
  116. package/client/dist/assets/ganttDiagram-c361ad54-C2CiWFUP.js +0 -257
  117. package/client/dist/assets/gitGraphDiagram-72cf32ee-C59Yz2LK.js +0 -70
  118. package/client/dist/assets/gl-ES-HMX3MZ6V-DQo0TzoP.js +0 -10
  119. package/client/dist/assets/graph-Dx_H43Kv.js +0 -1
  120. package/client/dist/assets/he-IL-6SHJWFNN-DKXK5e33.js +0 -10
  121. package/client/dist/assets/hi-IN-IWLTKZ5I-C2Qgqc0R.js +0 -4
  122. package/client/dist/assets/hu-HU-A5ZG7DT2-Ss-6vX0m.js +0 -7
  123. package/client/dist/assets/id-ID-SAP4L64H-D7Wsg1S2.js +0 -10
  124. package/client/dist/assets/image-blob-reduce.esm-D6s-rqMO.js +0 -7
  125. package/client/dist/assets/index-3862675e-u8Nv7hHC.js +0 -1
  126. package/client/dist/assets/index-BVowJdZF.js +0 -97
  127. package/client/dist/assets/index-ce18TYkg.js +0 -27
  128. package/client/dist/assets/index-kQoJx-bc.css +0 -1
  129. package/client/dist/assets/infoDiagram-f8f76790-LmoJYsxo.js +0 -7
  130. package/client/dist/assets/init-Gi6I4Gst.js +0 -1
  131. package/client/dist/assets/it-IT-JPQ66NNP-CAPTVl7M.js +0 -11
  132. package/client/dist/assets/ja-JP-DBVTYXUO-eNVPawR2.js +0 -8
  133. package/client/dist/assets/journeyDiagram-49397b02-BaJqehpR.js +0 -139
  134. package/client/dist/assets/kaa-6HZHGXH3-tpuNkKhS.js +0 -1
  135. package/client/dist/assets/kab-KAB-ZGHBKWFO-Dp83kx4x.js +0 -8
  136. package/client/dist/assets/kk-KZ-P5N5QNE5-B9IlC6YN.js +0 -1
  137. package/client/dist/assets/km-KH-HSX4SM5Z-B_KMYaMj.js +0 -11
  138. package/client/dist/assets/ko-KR-MTYHY66A-yebnUNdb.js +0 -9
  139. package/client/dist/assets/ku-TR-6OUDTVRD-BR6fh6-5.js +0 -9
  140. package/client/dist/assets/layout-DLl5Jwcl.js +0 -1
  141. package/client/dist/assets/line-FpB7omSK.js +0 -1
  142. package/client/dist/assets/linear-CkXqUFJ8.js +0 -1
  143. package/client/dist/assets/lt-LT-XHIRWOB4-SutZSWtR.js +0 -3
  144. package/client/dist/assets/lv-LV-5QDEKY6T-DuAxdcZL.js +0 -7
  145. package/client/dist/assets/mindmap-definition-fc14e90a-DyxXOExh.js +0 -425
  146. package/client/dist/assets/mr-IN-CRQNXWMA-DqDUWM_8.js +0 -13
  147. package/client/dist/assets/my-MM-5M5IBNSE-C40kMFMR.js +0 -1
  148. package/client/dist/assets/nb-NO-T6EIAALU-DVij32Ju.js +0 -10
  149. package/client/dist/assets/nl-NL-IS3SIHDZ-rT84mDYq.js +0 -8
  150. package/client/dist/assets/nn-NO-6E72VCQL-BBZXBW8V.js +0 -8
  151. package/client/dist/assets/oc-FR-POXYY2M6-DzjOugOf.js +0 -8
  152. package/client/dist/assets/ordinal-Cboi1Yqb.js +0 -1
  153. package/client/dist/assets/pa-IN-N4M65BXN-DD1iU8_F.js +0 -4
  154. package/client/dist/assets/path-CbwjOpE9.js +0 -1
  155. package/client/dist/assets/pdf-CE_K4jFx.js +0 -12
  156. package/client/dist/assets/pdf.worker-BA9kU3Pw.mjs +0 -61080
  157. package/client/dist/assets/percentages-BXMCSKIN-WVlHS4wx.js +0 -207
  158. package/client/dist/assets/pica-CQIY57Tf.js +0 -7
  159. package/client/dist/assets/pieDiagram-8a3498a8-Dd_85qBH.js +0 -35
  160. package/client/dist/assets/pl-PL-T2D74RX3-ukVXa48G.js +0 -9
  161. package/client/dist/assets/pt-BR-5N22H2LF-BibawarT.js +0 -9
  162. package/client/dist/assets/pt-PT-UZXXM6DQ-So3i9l9w.js +0 -9
  163. package/client/dist/assets/quadrantDiagram-120e2f19-C4dFVDEx.js +0 -7
  164. package/client/dist/assets/requirementDiagram-deff3bca-DrTO7yFl.js +0 -52
  165. package/client/dist/assets/ro-RO-JPDTUUEW-DY0Xq_Hd.js +0 -11
  166. package/client/dist/assets/roundRect-0PYZxl1G.js +0 -1
  167. package/client/dist/assets/ru-RU-B4JR7IUQ-B7u_Zvkd.js +0 -9
  168. package/client/dist/assets/sankeyDiagram-04a897e0-D24gfzuS.js +0 -8
  169. package/client/dist/assets/sequenceDiagram-704730f1-Dgji2XLQ.js +0 -122
  170. package/client/dist/assets/si-LK-N5RQ5JYF-OejsLzQ_.js +0 -1
  171. package/client/dist/assets/sk-SK-C5VTKIMK-_vy2Bt-M.js +0 -6
  172. package/client/dist/assets/sl-SI-NN7IZMDC-DKOl_u2M.js +0 -6
  173. package/client/dist/assets/stateDiagram-587899a1-CJ8eBaiU.js +0 -1
  174. package/client/dist/assets/stateDiagram-v2-d93cdb3a-C5K3l-Nt.js +0 -1
  175. package/client/dist/assets/styles-6aaf32cf-DAKE0jbx.js +0 -207
  176. package/client/dist/assets/styles-9a916d00-LFAJCgEy.js +0 -160
  177. package/client/dist/assets/styles-c10674c1-CllKO8NG.js +0 -116
  178. package/client/dist/assets/subset-shared.chunk-Uy-J87FQ.js +0 -84
  179. package/client/dist/assets/subset-worker.chunk-dvgDvqt9.js +0 -1
  180. package/client/dist/assets/sv-SE-XGPEYMSR-CDCB2ZV5.js +0 -10
  181. package/client/dist/assets/svgDrawCommon-08f97a94-CObOzbFQ.js +0 -1
  182. package/client/dist/assets/ta-IN-2NMHFXQM-DHUNdO69.js +0 -9
  183. package/client/dist/assets/th-TH-HPSO5L25-zI2hnBq3.js +0 -2
  184. package/client/dist/assets/timeline-definition-85554ec2-C2XHRmxK.js +0 -61
  185. package/client/dist/assets/tr-TR-DEFEU3FU-l-6Hu4-D.js +0 -7
  186. package/client/dist/assets/uk-UA-QMV73CPH-CqSOwrl7.js +0 -6
  187. package/client/dist/assets/vendor-codemirror-D_s0aGBu.js +0 -35
  188. package/client/dist/assets/vendor-i18n-DCFGyhQR.js +0 -1
  189. package/client/dist/assets/vendor-icons-Lb69KSFJ.js +0 -646
  190. package/client/dist/assets/vendor-markdown-BXEi_H3G.js +0 -298
  191. package/client/dist/assets/vendor-react-9mUTKBHH.js +0 -67
  192. package/client/dist/assets/vendor-syntax-DnmwQQJF.js +0 -16
  193. package/client/dist/assets/vendor-xterm-CZq1hqo1.js +0 -66
  194. package/client/dist/assets/vendor-xterm-qxJ8_QYu.css +0 -32
  195. package/client/dist/assets/vi-VN-M7AON7JQ-CUL8-mBZ.js +0 -5
  196. package/client/dist/assets/xychartDiagram-e933f94c-1fmf6slj.js +0 -7
  197. package/client/dist/assets/zh-CN-LNUGB5OW-CB5y5VVU.js +0 -10
  198. package/client/dist/assets/zh-HK-E62DVLB3-BHcrrEeJ.js +0 -1
  199. package/client/dist/assets/zh-TW-RAJ6MFWO-DoDUdkaJ.js +0 -9
  200. package/client/dist/clear-cache.html +0 -85
  201. package/client/dist/convert-icons.md +0 -53
  202. package/client/dist/favicon.png +0 -0
  203. package/client/dist/favicon.svg +0 -9
  204. package/client/dist/generate-icons.js +0 -49
  205. package/client/dist/icons/claude-ai-icon.svg +0 -1
  206. package/client/dist/icons/codex-white.svg +0 -3
  207. package/client/dist/icons/codex.svg +0 -3
  208. package/client/dist/icons/cursor-white.svg +0 -12
  209. package/client/dist/icons/cursor.svg +0 -1
  210. package/client/dist/icons/icon-128x128.png +0 -0
  211. package/client/dist/icons/icon-128x128.svg +0 -12
  212. package/client/dist/icons/icon-144x144.png +0 -0
  213. package/client/dist/icons/icon-144x144.svg +0 -12
  214. package/client/dist/icons/icon-152x152.png +0 -0
  215. package/client/dist/icons/icon-152x152.svg +0 -12
  216. package/client/dist/icons/icon-192x192.png +0 -0
  217. package/client/dist/icons/icon-192x192.svg +0 -12
  218. package/client/dist/icons/icon-384x384.png +0 -0
  219. package/client/dist/icons/icon-384x384.svg +0 -12
  220. package/client/dist/icons/icon-512x512.png +0 -0
  221. package/client/dist/icons/icon-512x512.svg +0 -12
  222. package/client/dist/icons/icon-72x72.png +0 -0
  223. package/client/dist/icons/icon-72x72.svg +0 -12
  224. package/client/dist/icons/icon-96x96.png +0 -0
  225. package/client/dist/icons/icon-96x96.svg +0 -12
  226. package/client/dist/icons/icon-template.svg +0 -12
  227. package/client/dist/index.html +0 -128
  228. package/client/dist/logo-128.png +0 -0
  229. package/client/dist/logo-256.png +0 -0
  230. package/client/dist/logo-32.png +0 -0
  231. package/client/dist/logo-512.png +0 -0
  232. package/client/dist/logo-64.png +0 -0
  233. package/client/dist/logo.svg +0 -17
  234. package/client/dist/manifest.json +0 -61
  235. package/client/dist/mcp-docs.html +0 -119
  236. package/client/dist/screenshots/cli-selection.png +0 -0
  237. package/client/dist/screenshots/desktop-main.png +0 -0
  238. package/client/dist/screenshots/mobile-chat.png +0 -0
  239. package/client/dist/screenshots/tools-modal.png +0 -0
  240. package/client/dist/sw.js +0 -19
  241. package/commands/upfynai-connect.md +0 -59
  242. package/commands/upfynai-disconnect.md +0 -31
  243. package/commands/upfynai-doctor.md +0 -99
  244. package/commands/upfynai-export.md +0 -49
  245. package/commands/upfynai-local.md +0 -82
  246. package/commands/upfynai-status.md +0 -75
  247. package/commands/upfynai-stop.md +0 -49
  248. package/commands/upfynai-uninstall.md +0 -58
  249. package/commands/upfynai.md +0 -69
  250. package/scripts/build-client.js +0 -17
  251. package/scripts/fix-node-pty.js +0 -67
  252. package/scripts/install-commands.js +0 -78
  253. package/server/claude-sdk.js +0 -714
  254. package/server/cli-ui.js +0 -785
  255. package/server/cli.js +0 -596
  256. package/server/constants/config.js +0 -31
  257. package/server/cursor-cli.js +0 -270
  258. package/server/database/auth.db +0 -0
  259. package/server/database/db.js +0 -808
  260. package/server/database/init.sql +0 -70
  261. package/server/index.js +0 -2621
  262. package/server/load-env.js +0 -26
  263. package/server/mcp-server.js +0 -621
  264. package/server/middleware/auth.js +0 -173
  265. package/server/openai-codex.js +0 -403
  266. package/server/openrouter.js +0 -137
  267. package/server/projects.js +0 -1742
  268. package/server/relay-client.js +0 -619
  269. package/server/routes/agent.js +0 -1266
  270. package/server/routes/auth.js +0 -263
  271. package/server/routes/cli-auth.js +0 -263
  272. package/server/routes/codex.js +0 -344
  273. package/server/routes/commands.js +0 -601
  274. package/server/routes/cursor.js +0 -808
  275. package/server/routes/dashboard.js +0 -52
  276. package/server/routes/git.js +0 -1165
  277. package/server/routes/mcp-utils.js +0 -48
  278. package/server/routes/mcp.js +0 -552
  279. package/server/routes/payments.js +0 -172
  280. package/server/routes/projects.js +0 -552
  281. package/server/routes/settings.js +0 -269
  282. package/server/routes/taskmaster.js +0 -1964
  283. package/server/routes/user.js +0 -106
  284. package/server/routes/voice.js +0 -198
  285. package/server/routes/webhooks.js +0 -166
  286. package/server/routes/workflows.js +0 -118
  287. package/server/services/whisperService.js +0 -84
  288. package/server/services/workflowScheduler.js +0 -186
  289. package/server/utils/commandParser.js +0 -303
  290. package/server/utils/gitConfig.js +0 -24
  291. package/server/utils/mcp-detector.js +0 -198
  292. package/server/utils/taskmaster-websocket.js +0 -129
  293. package/shared/modelConstants.js +0 -96
@@ -1,808 +0,0 @@
1
- import express from 'express';
2
- import { promises as fs } from 'fs';
3
- import path from 'path';
4
- import os from 'os';
5
- import { spawn } from 'child_process';
6
- // sqlite3 is a native module — conditionally imported (not available on Vercel)
7
- let sqlite3 = null;
8
- let sqliteOpen = null;
9
- try {
10
- sqlite3 = (await import('sqlite3')).default;
11
- sqliteOpen = (await import('sqlite')).open;
12
- } catch (e) {
13
- console.warn('[WARN] sqlite3/sqlite not available in cursor routes.');
14
- }
15
- import crypto from 'crypto';
16
- import { CURSOR_MODELS } from '../../shared/modelConstants.js';
17
-
18
- const router = express.Router();
19
-
20
- // GET /api/cursor/config - Read Cursor CLI configuration
21
- router.get('/config', async (req, res) => {
22
- try {
23
- const configPath = path.join(os.homedir(), '.cursor', 'cli-config.json');
24
-
25
- try {
26
- const configContent = await fs.readFile(configPath, 'utf8');
27
- const config = JSON.parse(configContent);
28
-
29
- res.json({
30
- success: true,
31
- config: config,
32
- path: configPath
33
- });
34
- } catch (error) {
35
- // Config doesn't exist or is invalid
36
- // cursor config not found
37
-
38
- // Return default config
39
- res.json({
40
- success: true,
41
- config: {
42
- version: 1,
43
- model: {
44
- modelId: CURSOR_MODELS.DEFAULT,
45
- displayName: "GPT-5"
46
- },
47
- permissions: {
48
- allow: [],
49
- deny: []
50
- }
51
- },
52
- isDefault: true
53
- });
54
- }
55
- } catch (error) {
56
- // config read error
57
- res.status(500).json({
58
- error: 'Failed to read Cursor configuration',
59
- details: 'An error occurred'
60
- });
61
- }
62
- });
63
-
64
- // POST /api/cursor/config - Update Cursor CLI configuration
65
- router.post('/config', async (req, res) => {
66
- try {
67
- const { permissions, model } = req.body;
68
- const configPath = path.join(os.homedir(), '.cursor', 'cli-config.json');
69
-
70
- // Read existing config or create default
71
- let config = {
72
- version: 1,
73
- editor: {
74
- vimMode: false
75
- },
76
- hasChangedDefaultModel: false,
77
- privacyCache: {
78
- ghostMode: false,
79
- privacyMode: 3,
80
- updatedAt: Date.now()
81
- }
82
- };
83
-
84
- try {
85
- const existing = await fs.readFile(configPath, 'utf8');
86
- config = JSON.parse(existing);
87
- } catch (error) {
88
- // Config doesn't exist, use defaults
89
- // creating new config
90
- }
91
-
92
- // Update permissions if provided
93
- if (permissions) {
94
- config.permissions = {
95
- allow: permissions.allow || [],
96
- deny: permissions.deny || []
97
- };
98
- }
99
-
100
- // Update model if provided
101
- if (model) {
102
- config.model = model;
103
- config.hasChangedDefaultModel = true;
104
- }
105
-
106
- // Ensure directory exists
107
- const configDir = path.dirname(configPath);
108
- await fs.mkdir(configDir, { recursive: true });
109
-
110
- // Write updated config
111
- await fs.writeFile(configPath, JSON.stringify(config, null, 2));
112
-
113
- res.json({
114
- success: true,
115
- config: config,
116
- message: 'Cursor configuration updated successfully'
117
- });
118
- } catch (error) {
119
- // config update error
120
- res.status(500).json({
121
- error: 'Failed to update Cursor configuration',
122
- details: 'An error occurred'
123
- });
124
- }
125
- });
126
-
127
- // GET /api/cursor/mcp - Read Cursor MCP servers configuration
128
- router.get('/mcp', async (req, res) => {
129
- try {
130
- const mcpPath = path.join(os.homedir(), '.cursor', 'mcp.json');
131
-
132
- try {
133
- const mcpContent = await fs.readFile(mcpPath, 'utf8');
134
- const mcpConfig = JSON.parse(mcpContent);
135
-
136
- // Convert to UI-friendly format
137
- const servers = [];
138
- if (mcpConfig.mcpServers && typeof mcpConfig.mcpServers === 'object') {
139
- for (const [name, config] of Object.entries(mcpConfig.mcpServers)) {
140
- const server = {
141
- id: name,
142
- name: name,
143
- type: 'stdio',
144
- scope: 'cursor',
145
- config: {},
146
- raw: config
147
- };
148
-
149
- // Determine transport type and extract config
150
- if (config.command) {
151
- server.type = 'stdio';
152
- server.config.command = config.command;
153
- server.config.args = config.args || [];
154
- server.config.env = config.env || {};
155
- } else if (config.url) {
156
- server.type = config.transport || 'http';
157
- server.config.url = config.url;
158
- server.config.headers = config.headers || {};
159
- }
160
-
161
- servers.push(server);
162
- }
163
- }
164
-
165
- res.json({
166
- success: true,
167
- servers: servers,
168
- path: mcpPath
169
- });
170
- } catch (error) {
171
- // MCP config doesn't exist
172
- // MCP config not found
173
- res.json({
174
- success: true,
175
- servers: [],
176
- isDefault: true
177
- });
178
- }
179
- } catch (error) {
180
- // MCP config read error
181
- res.status(500).json({
182
- error: 'Failed to read Cursor MCP configuration',
183
- details: 'An error occurred'
184
- });
185
- }
186
- });
187
-
188
- // POST /api/cursor/mcp/add - Add MCP server to Cursor configuration
189
- router.post('/mcp/add', async (req, res) => {
190
- try {
191
- const { name, type = 'stdio', command, args = [], url, headers = {}, env = {} } = req.body;
192
- const mcpPath = path.join(os.homedir(), '.cursor', 'mcp.json');
193
-
194
- // adding MCP server
195
-
196
- // Read existing config or create new
197
- let mcpConfig = { mcpServers: {} };
198
-
199
- try {
200
- const existing = await fs.readFile(mcpPath, 'utf8');
201
- mcpConfig = JSON.parse(existing);
202
- if (!mcpConfig.mcpServers) {
203
- mcpConfig.mcpServers = {};
204
- }
205
- } catch (error) {
206
- // creating new MCP config
207
- }
208
-
209
- // Build server config based on type
210
- let serverConfig = {};
211
-
212
- if (type === 'stdio') {
213
- serverConfig = {
214
- command: command,
215
- args: args,
216
- env: env
217
- };
218
- } else if (type === 'http' || type === 'sse') {
219
- serverConfig = {
220
- url: url,
221
- transport: type,
222
- headers: headers
223
- };
224
- }
225
-
226
- // Add server to config
227
- mcpConfig.mcpServers[name] = serverConfig;
228
-
229
- // Ensure directory exists
230
- const mcpDir = path.dirname(mcpPath);
231
- await fs.mkdir(mcpDir, { recursive: true });
232
-
233
- // Write updated config
234
- await fs.writeFile(mcpPath, JSON.stringify(mcpConfig, null, 2));
235
-
236
- res.json({
237
- success: true,
238
- message: `MCP server "${name}" added to Cursor configuration`,
239
- config: mcpConfig
240
- });
241
- } catch (error) {
242
- // MCP server add error
243
- res.status(500).json({
244
- error: 'Failed to add MCP server',
245
- details: 'An error occurred'
246
- });
247
- }
248
- });
249
-
250
- // DELETE /api/cursor/mcp/:name - Remove MCP server from Cursor configuration
251
- router.delete('/mcp/:name', async (req, res) => {
252
- try {
253
- const { name } = req.params;
254
- const mcpPath = path.join(os.homedir(), '.cursor', 'mcp.json');
255
-
256
- // removing MCP server
257
-
258
- // Read existing config
259
- let mcpConfig = { mcpServers: {} };
260
-
261
- try {
262
- const existing = await fs.readFile(mcpPath, 'utf8');
263
- mcpConfig = JSON.parse(existing);
264
- } catch (error) {
265
- return res.status(404).json({
266
- error: 'Cursor MCP configuration not found'
267
- });
268
- }
269
-
270
- // Check if server exists
271
- if (!mcpConfig.mcpServers || !mcpConfig.mcpServers[name]) {
272
- return res.status(404).json({
273
- error: `MCP server "${name}" not found in Cursor configuration`
274
- });
275
- }
276
-
277
- // Remove server from config
278
- delete mcpConfig.mcpServers[name];
279
-
280
- // Write updated config
281
- await fs.writeFile(mcpPath, JSON.stringify(mcpConfig, null, 2));
282
-
283
- res.json({
284
- success: true,
285
- message: `MCP server "${name}" removed from Cursor configuration`,
286
- config: mcpConfig
287
- });
288
- } catch (error) {
289
- // MCP server remove error
290
- res.status(500).json({
291
- error: 'Failed to remove MCP server',
292
- details: 'An error occurred'
293
- });
294
- }
295
- });
296
-
297
- // POST /api/cursor/mcp/add-json - Add MCP server using JSON format
298
- router.post('/mcp/add-json', async (req, res) => {
299
- try {
300
- const { name, jsonConfig } = req.body;
301
- const mcpPath = path.join(os.homedir(), '.cursor', 'mcp.json');
302
-
303
- // adding MCP server via JSON
304
-
305
- // Validate and parse JSON config
306
- let parsedConfig;
307
- try {
308
- parsedConfig = typeof jsonConfig === 'string' ? JSON.parse(jsonConfig) : jsonConfig;
309
- } catch (parseError) {
310
- return res.status(400).json({
311
- error: 'Invalid JSON configuration',
312
- details: parseError.message
313
- });
314
- }
315
-
316
- // Read existing config or create new
317
- let mcpConfig = { mcpServers: {} };
318
-
319
- try {
320
- const existing = await fs.readFile(mcpPath, 'utf8');
321
- mcpConfig = JSON.parse(existing);
322
- if (!mcpConfig.mcpServers) {
323
- mcpConfig.mcpServers = {};
324
- }
325
- } catch (error) {
326
- // creating new MCP config
327
- }
328
-
329
- // Add server to config
330
- mcpConfig.mcpServers[name] = parsedConfig;
331
-
332
- // Ensure directory exists
333
- const mcpDir = path.dirname(mcpPath);
334
- await fs.mkdir(mcpDir, { recursive: true });
335
-
336
- // Write updated config
337
- await fs.writeFile(mcpPath, JSON.stringify(mcpConfig, null, 2));
338
-
339
- res.json({
340
- success: true,
341
- message: `MCP server "${name}" added to Cursor configuration via JSON`,
342
- config: mcpConfig
343
- });
344
- } catch (error) {
345
- // MCP server JSON add error
346
- res.status(500).json({
347
- error: 'Failed to add MCP server',
348
- details: 'An error occurred'
349
- });
350
- }
351
- });
352
-
353
- // GET /api/cursor/sessions - Get Cursor sessions from SQLite database
354
- router.get('/sessions', async (req, res) => {
355
- try {
356
- const { projectPath } = req.query;
357
-
358
- // Calculate cwdID hash for the project path (Cursor uses MD5 hash)
359
- const cwdId = crypto.createHash('md5').update(projectPath || process.cwd()).digest('hex');
360
- const cursorChatsPath = path.join(os.homedir(), '.cursor', 'chats', cwdId);
361
-
362
-
363
- // Check if the directory exists
364
- try {
365
- await fs.access(cursorChatsPath);
366
- } catch (error) {
367
- // No sessions for this project
368
- return res.json({
369
- success: true,
370
- sessions: [],
371
- cwdId: cwdId,
372
- path: cursorChatsPath
373
- });
374
- }
375
-
376
- // List all session directories
377
- const sessionDirs = await fs.readdir(cursorChatsPath);
378
- const sessions = [];
379
-
380
- for (const sessionId of sessionDirs) {
381
- const sessionPath = path.join(cursorChatsPath, sessionId);
382
- const storeDbPath = path.join(sessionPath, 'store.db');
383
- let dbStatMtimeMs = null;
384
-
385
- try {
386
- // Check if store.db exists
387
- await fs.access(storeDbPath);
388
-
389
- // Capture store.db mtime as a reliable fallback timestamp (last activity)
390
- try {
391
- const stat = await fs.stat(storeDbPath);
392
- dbStatMtimeMs = stat.mtimeMs;
393
- } catch (_) {}
394
-
395
- // Open SQLite database
396
- if (!sqliteOpen || !sqlite3) {
397
- continue; // Skip on Vercel where native modules aren't available
398
- }
399
- const db = await sqliteOpen({
400
- filename: storeDbPath,
401
- driver: sqlite3.Database,
402
- mode: sqlite3.OPEN_READONLY
403
- });
404
-
405
- // Get metadata from meta table
406
- const metaRows = await db.all(`
407
- SELECT key, value FROM meta
408
- `);
409
-
410
- let sessionData = {
411
- id: sessionId,
412
- name: 'Untitled Session',
413
- createdAt: null,
414
- mode: null,
415
- projectPath: projectPath,
416
- lastMessage: null,
417
- messageCount: 0
418
- };
419
-
420
- // Parse meta table entries
421
- for (const row of metaRows) {
422
- if (row.value) {
423
- try {
424
- // Try to decode as hex-encoded JSON
425
- const hexMatch = row.value.toString().match(/^[0-9a-fA-F]+$/);
426
- if (hexMatch) {
427
- const jsonStr = Buffer.from(row.value, 'hex').toString('utf8');
428
- const data = JSON.parse(jsonStr);
429
-
430
- if (row.key === 'agent') {
431
- sessionData.name = data.name || sessionData.name;
432
- // Normalize createdAt to ISO string in milliseconds
433
- let createdAt = data.createdAt;
434
- if (typeof createdAt === 'number') {
435
- if (createdAt < 1e12) {
436
- createdAt = createdAt * 1000; // seconds -> ms
437
- }
438
- sessionData.createdAt = new Date(createdAt).toISOString();
439
- } else if (typeof createdAt === 'string') {
440
- const n = Number(createdAt);
441
- if (!Number.isNaN(n)) {
442
- const ms = n < 1e12 ? n * 1000 : n;
443
- sessionData.createdAt = new Date(ms).toISOString();
444
- } else {
445
- // Assume it's already an ISO/date string
446
- const d = new Date(createdAt);
447
- sessionData.createdAt = isNaN(d.getTime()) ? null : d.toISOString();
448
- }
449
- } else {
450
- sessionData.createdAt = sessionData.createdAt || null;
451
- }
452
- sessionData.mode = data.mode;
453
- sessionData.agentId = data.agentId;
454
- sessionData.latestRootBlobId = data.latestRootBlobId;
455
- }
456
- } else {
457
- // If not hex, use raw value for simple keys
458
- if (row.key === 'name') {
459
- sessionData.name = row.value.toString();
460
- }
461
- }
462
- } catch (e) {
463
- // meta parse error
464
- }
465
- }
466
- }
467
-
468
- // Get message count from JSON blobs only (actual messages, not DAG structure)
469
- try {
470
- const blobCount = await db.get(`
471
- SELECT COUNT(*) as count
472
- FROM blobs
473
- WHERE substr(data, 1, 1) = X'7B'
474
- `);
475
- sessionData.messageCount = blobCount.count;
476
-
477
- // Get the most recent JSON blob for preview (actual message, not DAG structure)
478
- const lastBlob = await db.get(`
479
- SELECT data FROM blobs
480
- WHERE substr(data, 1, 1) = X'7B'
481
- ORDER BY rowid DESC
482
- LIMIT 1
483
- `);
484
-
485
- if (lastBlob && lastBlob.data) {
486
- try {
487
- // Try to extract readable preview from blob (may contain binary with embedded JSON)
488
- const raw = lastBlob.data.toString('utf8');
489
- let preview = '';
490
- // Attempt direct JSON parse
491
- try {
492
- const parsed = JSON.parse(raw);
493
- if (parsed?.content) {
494
- if (Array.isArray(parsed.content)) {
495
- const firstText = parsed.content.find(p => p?.type === 'text' && p.text)?.text || '';
496
- preview = firstText;
497
- } else if (typeof parsed.content === 'string') {
498
- preview = parsed.content;
499
- }
500
- }
501
- } catch (_) {}
502
- if (!preview) {
503
- // Strip non-printable and try to find JSON chunk
504
- const cleaned = raw.replace(/[^\x09\x0A\x0D\x20-\x7E]/g, '');
505
- const s = cleaned;
506
- const start = s.indexOf('{');
507
- const end = s.lastIndexOf('}');
508
- if (start !== -1 && end > start) {
509
- const jsonStr = s.slice(start, end + 1);
510
- try {
511
- const parsed = JSON.parse(jsonStr);
512
- if (parsed?.content) {
513
- if (Array.isArray(parsed.content)) {
514
- const firstText = parsed.content.find(p => p?.type === 'text' && p.text)?.text || '';
515
- preview = firstText;
516
- } else if (typeof parsed.content === 'string') {
517
- preview = parsed.content;
518
- }
519
- }
520
- } catch (_) {
521
- preview = s;
522
- }
523
- } else {
524
- preview = s;
525
- }
526
- }
527
- if (preview && preview.length > 0) {
528
- sessionData.lastMessage = preview.substring(0, 100) + (preview.length > 100 ? '...' : '');
529
- }
530
- } catch (e) {
531
- // blob parse error
532
- }
533
- }
534
- } catch (e) {
535
- // blobs read error
536
- }
537
-
538
- await db.close();
539
-
540
- // Finalize createdAt: use parsed meta value when valid, else fall back to store.db mtime
541
- if (!sessionData.createdAt) {
542
- if (dbStatMtimeMs && Number.isFinite(dbStatMtimeMs)) {
543
- sessionData.createdAt = new Date(dbStatMtimeMs).toISOString();
544
- }
545
- }
546
-
547
- sessions.push(sessionData);
548
-
549
- } catch (error) {
550
- // session read error
551
- }
552
- }
553
-
554
- // Fallback: ensure createdAt is a valid ISO string (use session directory mtime as last resort)
555
- for (const s of sessions) {
556
- if (!s.createdAt) {
557
- try {
558
- const sessionDir = path.join(cursorChatsPath, s.id);
559
- const st = await fs.stat(sessionDir);
560
- s.createdAt = new Date(st.mtimeMs).toISOString();
561
- } catch {
562
- s.createdAt = new Date().toISOString();
563
- }
564
- }
565
- }
566
- // Sort sessions by creation date (newest first)
567
- sessions.sort((a, b) => {
568
- if (!a.createdAt) return 1;
569
- if (!b.createdAt) return -1;
570
- return new Date(b.createdAt) - new Date(a.createdAt);
571
- });
572
-
573
- res.json({
574
- success: true,
575
- sessions: sessions,
576
- cwdId: cwdId,
577
- path: cursorChatsPath
578
- });
579
-
580
- } catch (error) {
581
- // sessions read error
582
- res.status(500).json({
583
- error: 'Failed to read Cursor sessions',
584
- details: 'An error occurred'
585
- });
586
- }
587
- });
588
-
589
- // GET /api/cursor/sessions/:sessionId - Get specific Cursor session from SQLite
590
- router.get('/sessions/:sessionId', async (req, res) => {
591
- try {
592
- const { sessionId } = req.params;
593
- const { projectPath } = req.query;
594
-
595
- // Calculate cwdID hash for the project path
596
- const cwdId = crypto.createHash('md5').update(projectPath || process.cwd()).digest('hex');
597
- const storeDbPath = path.join(os.homedir(), '.cursor', 'chats', cwdId, sessionId, 'store.db');
598
-
599
-
600
- // Open SQLite database (requires native sqlite3 module)
601
- if (!sqliteOpen || !sqlite3) {
602
- return res.status(503).json({ error: 'SQLite not available on this deployment' });
603
- }
604
- const db = await sqliteOpen({
605
- filename: storeDbPath,
606
- driver: sqlite3.Database,
607
- mode: sqlite3.OPEN_READONLY
608
- });
609
-
610
- // Get all blobs to build the DAG structure
611
- const allBlobs = await db.all(`
612
- SELECT rowid, id, data FROM blobs
613
- `);
614
-
615
- // Build the DAG structure from parent-child relationships
616
- const blobMap = new Map(); // id -> blob data
617
- const parentRefs = new Map(); // blob id -> [parent blob ids]
618
- const childRefs = new Map(); // blob id -> [child blob ids]
619
- const jsonBlobs = []; // Clean JSON messages
620
-
621
- for (const blob of allBlobs) {
622
- blobMap.set(blob.id, blob);
623
-
624
- // Check if this is a JSON blob (actual message) or protobuf (DAG structure)
625
- if (blob.data && blob.data[0] === 0x7B) { // Starts with '{' - JSON blob
626
- try {
627
- const parsed = JSON.parse(blob.data.toString('utf8'));
628
- jsonBlobs.push({ ...blob, parsed });
629
- } catch (e) {
630
- // JSON blob parse failed
631
- }
632
- } else if (blob.data) { // Protobuf blob - extract parent references
633
- const parents = [];
634
- let i = 0;
635
-
636
- // Scan for parent references (0x0A 0x20 followed by 32-byte hash)
637
- while (i < blob.data.length - 33) {
638
- if (blob.data[i] === 0x0A && blob.data[i+1] === 0x20) {
639
- const parentHash = blob.data.slice(i+2, i+34).toString('hex');
640
- if (blobMap.has(parentHash)) {
641
- parents.push(parentHash);
642
- }
643
- i += 34;
644
- } else {
645
- i++;
646
- }
647
- }
648
-
649
- if (parents.length > 0) {
650
- parentRefs.set(blob.id, parents);
651
- // Update child references
652
- for (const parentId of parents) {
653
- if (!childRefs.has(parentId)) {
654
- childRefs.set(parentId, []);
655
- }
656
- childRefs.get(parentId).push(blob.id);
657
- }
658
- }
659
- }
660
- }
661
-
662
- // Perform topological sort to get chronological order
663
- const visited = new Set();
664
- const sorted = [];
665
-
666
- // DFS-based topological sort
667
- function visit(nodeId) {
668
- if (visited.has(nodeId)) return;
669
- visited.add(nodeId);
670
-
671
- // Visit all parents first (dependencies)
672
- const parents = parentRefs.get(nodeId) || [];
673
- for (const parentId of parents) {
674
- visit(parentId);
675
- }
676
-
677
- // Add this node after all its parents
678
- const blob = blobMap.get(nodeId);
679
- if (blob) {
680
- sorted.push(blob);
681
- }
682
- }
683
-
684
- // Start with nodes that have no parents (roots)
685
- for (const blob of allBlobs) {
686
- if (!parentRefs.has(blob.id)) {
687
- visit(blob.id);
688
- }
689
- }
690
-
691
- // Visit any remaining nodes (disconnected components)
692
- for (const blob of allBlobs) {
693
- visit(blob.id);
694
- }
695
-
696
- // Now extract JSON messages in the order they appear in the sorted DAG
697
- const messageOrder = new Map(); // JSON blob id -> order index
698
- let orderIndex = 0;
699
-
700
- for (const blob of sorted) {
701
- // Check if this blob references any JSON messages
702
- if (blob.data && blob.data[0] !== 0x7B) { // Protobuf blob
703
- // Look for JSON blob references
704
- for (const jsonBlob of jsonBlobs) {
705
- try {
706
- const jsonIdBytes = Buffer.from(jsonBlob.id, 'hex');
707
- if (blob.data.includes(jsonIdBytes)) {
708
- if (!messageOrder.has(jsonBlob.id)) {
709
- messageOrder.set(jsonBlob.id, orderIndex++);
710
- }
711
- }
712
- } catch (e) {
713
- // Skip if can't convert ID
714
- }
715
- }
716
- }
717
- }
718
-
719
- // Sort JSON blobs by their appearance order in the DAG
720
- const sortedJsonBlobs = jsonBlobs.sort((a, b) => {
721
- const orderA = messageOrder.get(a.id) ?? Number.MAX_SAFE_INTEGER;
722
- const orderB = messageOrder.get(b.id) ?? Number.MAX_SAFE_INTEGER;
723
- if (orderA !== orderB) return orderA - orderB;
724
- // Fallback to rowid if not in order map
725
- return a.rowid - b.rowid;
726
- });
727
-
728
- // Use sorted JSON blobs
729
- const blobs = sortedJsonBlobs.map((blob, idx) => ({
730
- ...blob,
731
- sequence_num: idx + 1,
732
- original_rowid: blob.rowid
733
- }));
734
-
735
- // Get metadata from meta table
736
- const metaRows = await db.all(`
737
- SELECT key, value FROM meta
738
- `);
739
-
740
- // Parse metadata
741
- let metadata = {};
742
- for (const row of metaRows) {
743
- if (row.value) {
744
- try {
745
- // Try to decode as hex-encoded JSON
746
- const hexMatch = row.value.toString().match(/^[0-9a-fA-F]+$/);
747
- if (hexMatch) {
748
- const jsonStr = Buffer.from(row.value, 'hex').toString('utf8');
749
- metadata[row.key] = JSON.parse(jsonStr);
750
- } else {
751
- metadata[row.key] = row.value.toString();
752
- }
753
- } catch (e) {
754
- metadata[row.key] = row.value.toString();
755
- }
756
- }
757
- }
758
-
759
- // Extract messages from sorted JSON blobs
760
- const messages = [];
761
- for (const blob of blobs) {
762
- try {
763
- // We already parsed JSON blobs earlier
764
- const parsed = blob.parsed;
765
-
766
- if (parsed) {
767
- // Filter out ONLY system messages at the server level
768
- // Check both direct role and nested message.role
769
- const role = parsed?.role || parsed?.message?.role;
770
- if (role === 'system') {
771
- continue; // Skip only system messages
772
- }
773
- messages.push({
774
- id: blob.id,
775
- sequence: blob.sequence_num,
776
- rowid: blob.original_rowid,
777
- content: parsed
778
- });
779
- }
780
- } catch (e) {
781
- // Skip blobs that cause errors
782
- // blob skipped
783
- }
784
- }
785
-
786
- await db.close();
787
-
788
- res.json({
789
- success: true,
790
- session: {
791
- id: sessionId,
792
- projectPath: projectPath,
793
- messages: messages,
794
- metadata: metadata,
795
- cwdId: cwdId
796
- }
797
- });
798
-
799
- } catch (error) {
800
- // session read error
801
- res.status(500).json({
802
- error: 'Failed to read Cursor session',
803
- details: 'An error occurred'
804
- });
805
- }
806
- });
807
-
808
- export default router;