upfynai-code 2.6.0 → 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 (295) hide show
  1. package/README.md +123 -88
  2. package/bin/cli.js +63 -0
  3. package/package.json +48 -106
  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 -822
  260. package/server/database/init.sql +0 -70
  261. package/server/index.js +0 -2738
  262. package/server/load-env.js +0 -26
  263. package/server/mcp-server.js +0 -621
  264. package/server/middleware/auth.js +0 -181
  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 -672
  269. package/server/routes/agent.js +0 -1226
  270. package/server/routes/auth.js +0 -266
  271. package/server/routes/cli-auth.js +0 -263
  272. package/server/routes/codex.js +0 -344
  273. package/server/routes/commands.js +0 -598
  274. package/server/routes/cursor.js +0 -807
  275. package/server/routes/dashboard.js +0 -205
  276. package/server/routes/git.js +0 -1151
  277. package/server/routes/mcp-utils.js +0 -48
  278. package/server/routes/mcp.js +0 -535
  279. package/server/routes/payments.js +0 -172
  280. package/server/routes/projects.js +0 -552
  281. package/server/routes/settings.js +0 -261
  282. package/server/routes/taskmaster.js +0 -1928
  283. package/server/routes/user.js +0 -106
  284. package/server/routes/vapi-chat.js +0 -94
  285. package/server/routes/voice.js +0 -194
  286. package/server/routes/webhooks.js +0 -166
  287. package/server/routes/workflows.js +0 -118
  288. package/server/sandbox.js +0 -120
  289. package/server/services/whisperService.js +0 -84
  290. package/server/services/workflowScheduler.js +0 -186
  291. package/server/utils/commandParser.js +0 -303
  292. package/server/utils/gitConfig.js +0 -24
  293. package/server/utils/mcp-detector.js +0 -198
  294. package/server/utils/taskmaster-websocket.js +0 -129
  295. package/shared/modelConstants.js +0 -96
@@ -1,34 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/percentages-BXMCSKIN-WVlHS4wx.js","assets/vendor-syntax-DnmwQQJF.js","assets/vendor-react-9mUTKBHH.js","assets/vendor-markdown-BXEi_H3G.js","assets/AppContent-C0CyP3g5.js","assets/index-ce18TYkg.js","assets/vendor-icons-Lb69KSFJ.js","assets/vendor-i18n-DCFGyhQR.js","assets/index-kQoJx-bc.css","assets/LoginModal-CZDEzqjK.js","assets/vendor-xterm-CZq1hqo1.js","assets/vendor-xterm-qxJ8_QYu.css","assets/vendor-codemirror-D_s0aGBu.js"])))=>i.map(i=>d[i]);
2
- import{b as ce}from"./vendor-syntax-DnmwQQJF.js";import{r as g,j as i,v as ge}from"./vendor-react-9mUTKBHH.js";import{t as xe,i as be,u as ye,v as ke,F as we,w as ve,x as Ie}from"./vendor-icons-Lb69KSFJ.js";import"./vendor-markdown-BXEi_H3G.js";const X=240,le=120,G=32,Se=12,O={note:{bg:"#f8fafc",border:"#3b82f6",text:"#1e293b",accent:"#2563eb"},pdf:{bg:"#fef2f2",border:"#ef4444",text:"#1e293b",accent:"#dc2626"},summary:{bg:"#f0fdf4",border:"#22c55e",text:"#1e293b",accent:"#16a34a"},prompt:{bg:"#eff6ff",border:"#3b82f6",text:"#1e293b",accent:"#2563eb"},response:{bg:"#f5f3ff",border:"#8b5cf6",text:"#1e293b",accent:"#7c3aed"},research:{bg:"#f0fdfa",border:"#14b8a6",text:"#1e293b",accent:"#0d9488"},suggestion:{bg:"#fffbeb",border:"#f59e0b",text:"#1e293b",accent:"#d97706"}};function R(){return crypto.randomUUID()}function ie(n,e,t,r,a){return{id:a.id,type:"rectangle",x:n,y:e,width:t,height:r,angle:0,strokeColor:a.border,backgroundColor:a.bg,fillStyle:"solid",strokeWidth:2,roughness:0,opacity:100,groupIds:a.groupIds,roundness:{type:3,value:Se},isDeleted:!1,boundElements:null,locked:!1,customData:a.customData,version:1,versionNonce:Math.floor(Math.random()*1e9),seed:Math.floor(Math.random()*1e9)}}function H(n,e,t,r){const a=r.fontSize??14;return{id:r.id,type:"text",x:n,y:e,width:r.width??X-24,height:r.height??a+6,angle:0,strokeColor:r.color,backgroundColor:"transparent",fillStyle:"solid",strokeWidth:1,roughness:0,opacity:100,groupIds:r.groupIds,roundness:null,isDeleted:!1,boundElements:null,locked:!1,text:t,fontSize:a,fontFamily:1,textAlign:"left",verticalAlign:"top",containerId:null,originalText:t,autoResize:!1,lineHeight:1.25,customData:r.customData,version:1,versionNonce:Math.floor(Math.random()*1e9),seed:Math.floor(Math.random()*1e9)}}const Ce={note:"📝 Note",pdf:"📄 PDF",summary:"✨ Summary",prompt:"💬 Prompt",response:"🤖 Response",research:"🔍 Research",suggestion:"💡 Suggestion"};function z(n,e,t,r,a,l){const s=R(),m=R(),d=l??X,p=r.split(`
3
- `),c=Math.max(le-G,p.length*18+16),f=G+c,x=O[n],D=ie(e,t,d,f,{id:m,groupIds:[s],bg:x.bg,border:x.border,customData:{blockType:n,blockId:m,content:r,...a}}),A=H(e+12,t+8,Ce[n],{id:R(),groupIds:[s],color:x.accent,fontSize:13,width:d-24}),w=H(e+12,t+G+4,r,{id:R(),groupIds:[s],color:x.text,fontSize:13,width:d-24,height:c-12});return{elements:[D,A,w],blockId:m,groupId:s,totalHeight:f}}function de(n,e,t="New note..."){return z("note",n,e,t)}function te(n,e,t){return z("prompt",n,e,t)}function je(n,e,t,r){return z("response",n,e,t,void 0,r)}function De(n,e,t,r){return z("research",n,e,t,void 0,r)}function Ee(n,e,t,r){return z("suggestion",n,e,t,void 0,r)}function ue(n,e,t,r,a,l){const s=R(),m=R(),d=t.length>28?t.slice(0,25)+"...":t,p=ie(n,e,X,le,{id:m,groupIds:[s],bg:O.pdf.bg,border:O.pdf.border,customData:{blockType:"pdf",blockId:m,fileName:t,pageCount:r,extractedText:a,thumbnail:l??null}}),c=H(n+12,e+8,`📄 ${d}`,{id:R(),groupIds:[s],color:O.pdf.accent,fontSize:13}),f=H(n+12,e+32,`${r} page${r!==1?"s":""}`,{id:R(),groupIds:[s],color:O.pdf.text,fontSize:12}),x=H(n+12,e+56,a.slice(0,80)+(a.length>80?"...":""),{id:R(),groupIds:[s],color:"#64748b",fontSize:11,height:48});return{elements:[p,c,f,x],blockId:m,groupId:s}}function me(n,e,t,r="Generating summary..."){return z("summary",n,e,r,{sourceIds:t,generatedContent:r})}function Y(n,e){const t=R();return{element:{id:t,type:"arrow",x:0,y:0,width:100,height:0,angle:0,strokeColor:"#6366f1",backgroundColor:"transparent",fillStyle:"solid",strokeWidth:2,roughness:0,opacity:80,groupIds:[],roundness:{type:2},isDeleted:!1,boundElements:null,locked:!1,points:[[0,0],[100,0]],startBinding:{elementId:n,focus:0,gap:4},endBinding:{elementId:e,focus:0,gap:4},startArrowhead:null,endArrowhead:"arrow",customData:{blockType:"context-link",sourceId:n,targetId:e},version:1,versionNonce:Math.floor(Math.random()*1e9),seed:Math.floor(Math.random()*1e9)},linkId:t}}async function Ne(n){try{const e=await ce(()=>import("./pdf-CE_K4jFx.js"),[]);e.GlobalWorkerOptions.workerSrc=new URL("/assets/pdf.worker-BA9kU3Pw.mjs",import.meta.url).toString();const t=await n.arrayBuffer(),r=await e.getDocument({data:t}).promise,a=r.numPages,l=[],s=Math.min(a,10);for(let d=1;d<=s;d++){const f=(await(await r.getPage(d)).getTextContent()).items.map(x=>x.str).join(" ");l.push(f)}let m=null;try{const d=await r.getPage(1),p=d.getViewport({scale:.5}),c=document.createElement("canvas");c.width=p.width,c.height=p.height;const f=c.getContext("2d");f&&(await d.render({canvasContext:f,viewport:p}).promise,m=c.toDataURL("image/png",.6))}catch{}return{text:l.join(`
4
-
5
- `),pageCount:a,thumbnail:m}}catch(e){return console.error("PDF extraction failed:",e),{text:"",pageCount:0,thumbnail:null}}}function K(n){const e=n.getAppState(),t=(-e.scrollX+e.width/2)/e.zoom.value,r=(-e.scrollY+e.height/2)/e.zoom.value;return{x:Math.round(t-120),y:Math.round(r-60)}}function U(n,e){const t=n.getSceneElements();n.updateScene({elements:[...t,...e]})}function Ae({api:n,onRun:e,onStop:t,onClearAi:r,isRunning:a}){const l=g.useRef(null),[s,m]=g.useState(!1),[d,p]=g.useState(!1),c=g.useCallback(()=>{if(!n)return;const{x:o,y:b}=K(n),v=de(o,b);U(n,v.elements)},[n]),f=g.useCallback(()=>{var o;(o=l.current)==null||o.click()},[]),x=g.useCallback(async o=>{var v;const b=(v=o.target.files)==null?void 0:v[0];if(!(!b||!n)){o.target.value="",p(!0);try{const{text:k,pageCount:I,thumbnail:T}=await Ne(b),{x:P,y:M}=K(n),$=ue(P,M,b.name,I,k,T);U(n,$.elements)}finally{p(!1)}}},[n]),D=g.useCallback(()=>{if(!n)return;const o=n.getAppState(),b=Object.keys(o.selectedElementIds||{}),k=n.getSceneElements().filter(M=>{var $;return b.includes(M.id)&&(($=M.customData)==null?void 0:$.blockId)}).map(M=>M.customData.blockId),{x:I,y:T}=K(n),P=me(I+280,T,k,k.length?"Summary of selected blocks":"Select blocks to summarize");U(n,P.elements)},[n]),A=g.useCallback(()=>{if(!n)return;const o=n.getAppState(),b=Object.keys(o.selectedElementIds||{}),k=n.getSceneElements().filter(I=>{var T;return b.includes(I.id)&&((T=I.customData)==null?void 0:T.blockId)});if(k.length===2){const I=Y(k[0].id,k[1].id);U(n,[I.element]),m(!1)}else m(!s)},[n,s]),w="flex items-center justify-center w-9 h-9 rounded-lg transition-colors text-muted-foreground hover:text-foreground hover:bg-black/5";return i.jsxs("div",{className:"canvas-block-toolbar",children:[a?i.jsx("button",{onClick:t,className:`${w} text-red-500 hover:text-red-600 hover:bg-red-50`,title:"Stop AI",children:i.jsx(xe,{className:"w-4 h-4"})}):i.jsx("button",{onClick:e,className:`${w} text-primary hover:text-primary hover:bg-primary/10`,title:"Run: Analyze canvas with AI",children:i.jsx(be,{className:"w-4 h-4"})}),i.jsx("button",{onClick:r,className:w,title:"Clear AI output blocks",children:i.jsx(ye,{className:"w-4 h-4"})}),i.jsx("div",{className:"w-5 border-t border-black/10 mx-auto"}),i.jsx("button",{onClick:c,className:w,title:"Add Note",children:i.jsx(ke,{className:"w-4 h-4"})}),i.jsx("button",{onClick:f,className:w,title:"Add PDF",disabled:d,children:i.jsx(we,{className:`w-4 h-4 ${d?"animate-pulse":""}`})}),i.jsx("button",{onClick:D,className:w,title:"Add Summary",children:i.jsx(ve,{className:"w-4 h-4"})}),i.jsx("div",{className:"w-5 border-t border-black/10 mx-auto"}),i.jsx("button",{onClick:A,className:`${w} ${s?"bg-indigo-500/10 text-indigo-500":""}`,title:"Connect Blocks (select 2)",children:i.jsx(Ie,{className:"w-4 h-4"})}),i.jsx("input",{ref:l,type:"file",accept:".pdf",onChange:x,className:"hidden"}),s&&i.jsx("div",{className:"absolute left-12 top-1/2 -translate-y-1/2 bg-background/90 border border-border rounded-md px-2 py-1 text-xs text-muted-foreground whitespace-nowrap",children:"Select 2 blocks, then click Connect"})]})}function L(){return window.__excalidrawAPI??null}function F(n){const e=L();if(!e)return;const t=e.getSceneElements();e.updateScene({elements:[...t,...n]})}function ne(){const n=L();if(!n)return{x:100,y:100};const e=n.getAppState(),t=(-e.scrollX+e.width/2)/e.zoom.value,r=(-e.scrollY+e.height/2)/e.zoom.value;return{x:Math.round(t-120),y:Math.round(r-60)}}const B={addNote(n,e,t){const r=n!=null&&e!=null?{x:n,y:e}:ne(),a=de(r.x,r.y,t);return F(a.elements),{blockId:a.blockId}},addPdf(n,e,t,r,a=0,l){const s=ue(n,e,t,a,r,l);return F(s.elements),{blockId:s.blockId}},addSummary(n,e,t,r){const a=t!=null&&r!=null?{x:t,y:r}:ne(),l=me(a.x,a.y,n,e);return F(l.elements),{blockId:l.blockId}},connectBlocks(n,e){const t=Y(n,e);return F([t.element]),{linkId:t.linkId}},getBlocks(){const n=L();return n?n.getSceneElements().filter(e=>{var t;return((t=e.customData)==null?void 0:t.blockType)&&e.customData.blockType!=="context-link"}).map(e=>({id:e.id,x:e.x,y:e.y,width:e.width,height:e.height,...e.customData})):[]},getConnections(){const n=L();return n?n.getSceneElements().filter(e=>{var t;return((t=e.customData)==null?void 0:t.blockType)==="context-link"}).map(e=>({id:e.id,sourceId:e.customData.sourceId,targetId:e.customData.targetId})):[]},updateBlockContent(n,e){const t=L();if(!t)return;const r=t.getSceneElements().map(a=>{var l;if(a.id===n&&a.customData)return{...a,customData:{...a.customData,content:e,generatedContent:e}};if(a.type==="text"&&((l=a.groupIds)!=null&&l.length)){const s=t.getSceneElements().find(m=>{var d;return m.id===n&&((d=m.groupIds)==null?void 0:d.some(p=>a.groupIds.includes(p)))});if(s&&a.y>s.y+28)return{...a,text:e,originalText:e}}return a});t.updateScene({elements:r})},removeBlock(n){const e=L();if(!e)return;const t=e.getSceneElements().find(l=>l.id===n);if(!t)return;const r=t.groupIds??[],a=e.getSceneElements().map(l=>{var s,m;return l.id===n||r.length&&((s=l.groupIds)!=null&&s.some(d=>r.includes(d)))?{...l,isDeleted:!0}:((m=l.customData)==null?void 0:m.blockType)==="context-link"&&(l.customData.sourceId===n||l.customData.targetId===n)?{...l,isDeleted:!0}:l});e.updateScene({elements:a})}};function Te(){window.__canvasBlockAPI=B}function Be(){delete window.__canvasBlockAPI}function Re(n){const{action:e,params:t}=n;switch(e){case"addNote":return B.addNote(t.x,t.y,t.content);case"addPdf":return B.addPdf(t.x,t.y,t.fileName,t.text,t.pageCount,t.thumbnail);case"addSummary":return B.addSummary(t.sourceIds,t.content,t.x,t.y);case"connectBlocks":return B.connectBlocks(t.sourceId,t.targetId);case"updateBlockContent":return B.updateBlockContent(t.blockId,t.content);case"removeBlock":return B.removeBlock(t.blockId);case"getBlocks":return B.getBlocks();case"getConnections":return B.getConnections();default:console.warn("Unknown canvas block command:",e)}}function _(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function V(n,e){return`(${Math.round(n)}, ${Math.round(e)})`}function oe(n){var f,x,D,A,w;const e=n.getSceneElements().filter(o=>!o.isDeleted);if(e.length===0)return"Canvas is empty.";const t=[],r=[],a=[],l=[],s=[],m=new Set,d=new Set;for(const o of e)if((f=o.customData)!=null&&f.blockType&&o.customData.blockType!=="context-link"){if(m.add(o.id),o.groupIds)for(const b of o.groupIds)d.add(b);t.push({id:o.id,type:o.customData.blockType,x:o.x,y:o.y,content:o.customData.content||o.customData.extractedText||o.customData.generatedContent||"",label:o.customData.fileName||o.customData.blockType})}const p=new Map;for(const o of t){const b=o.content?_(o.content,40):o.type;p.set(o.id,b)}for(const o of e)if(!m.has(o.id)&&!((x=o.groupIds)!=null&&x.some(b=>d.has(b))))if(((D=o.customData)==null?void 0:D.blockType)==="context-link")l.push({sourceId:o.customData.sourceId,targetId:o.customData.targetId,sourceLabel:p.get(o.customData.sourceId)||"unknown",targetLabel:p.get(o.customData.targetId)||"unknown"});else if(o.type==="arrow"&&(o.startBinding||o.endBinding)){const b=(A=o.startBinding)==null?void 0:A.elementId,v=(w=o.endBinding)==null?void 0:w.elementId;b&&v&&l.push({sourceId:b,targetId:v,sourceLabel:p.get(b)||"element",targetLabel:p.get(v)||"element"})}else o.type==="text"?r.push({text:o.text||o.originalText||"",x:o.x,y:o.y}):o.type==="rectangle"||o.type==="ellipse"||o.type==="diamond"?a.push({type:o.type,x:o.x,y:o.y,width:o.width,height:o.height}):(o.type==="freedraw"||o.type==="line")&&s.push({type:o.type,x:o.x,y:o.y});const c=[`## Canvas Context
6
- `];if(t.length>0){c.push("### Blocks:");for(const o of t){const b=o.content?_(o.content,120):"(empty)";c.push(`- [${o.type} at ${V(o.x,o.y)}]: "${b}"`)}c.push("")}if(r.length>0){c.push("### Free Text:");for(const o of r)c.push(`- Text at ${V(o.x,o.y)}: "${_(o.text,100)}"`);c.push("")}if(a.length>0){c.push("### Shapes:");for(const o of a)c.push(`- ${o.type} at ${V(o.x,o.y)} (${Math.round(o.width)}x${Math.round(o.height)})`);c.push("")}if(s.length>0&&(c.push("### Drawings:"),c.push(`- ${s.length} hand-drawn element(s)`),c.push("")),l.length>0){c.push("### Connections:");for(const o of l)c.push(`- "${o.sourceLabel}" → "${o.targetLabel}"`);c.push("")}if(t.length>1){const o=[...t].sort((k,I)=>k.x-I.x||k.y-I.y),b=o[0],v=o[o.length-1];c.push("### Spatial Layout:"),c.push(`- Leftmost: ${b.type} ("${_(b.content,30)}")`),c.push(`- Rightmost: ${v.type} ("${_(v.content,30)}")`),c.push(`- Total blocks: ${t.length}`),c.push("")}return c.join(`
7
- `)}function Pe(n){var m,d,p;const e=n.getAppState(),t=new Set(Object.keys(e.selectedElementIds||{}));if(t.size===0)return null;const r=n.getSceneElements().filter(c=>!c.isDeleted),a=new Set(t);for(const c of r)if(t.has(c.id)&&c.groupIds)for(const f of c.groupIds)for(const x of r)(m=x.groupIds)!=null&&m.includes(f)&&a.add(x.id);const l=r.filter(c=>a.has(c.id));if(l.length===0)return null;const s=[`## Selected Items Context
8
- `];for(const c of l)if((d=c.customData)!=null&&d.blockType&&c.customData.blockType!=="context-link"){const f=c.customData.content||c.customData.extractedText||c.customData.generatedContent||"";s.push(`- [${c.customData.blockType}]: "${_(f,150)}"`)}else c.type==="text"?s.push(`- Text: "${_(c.text||"",150)}"`):c.type==="rectangle"||c.type==="ellipse"||c.type==="diamond"?s.push(`- Shape: ${c.type} (${Math.round(c.width)}x${Math.round(c.height)})`):((p=c.customData)==null?void 0:p.blockType)==="context-link"&&s.push("- Connection: linked elements");return s.join(`
9
- `)}function se(n){const e=n.getSceneElements().filter(a=>!a.isDeleted);if(e.length===0){const a=n.getAppState(),l=(-a.scrollX+a.width/2)/a.zoom.value,s=(-a.scrollY+a.height/2)/a.zoom.value;return{x:Math.round(l),y:Math.round(s)}}let t=-1/0,r=1/0;for(const a of e){const l=a.x+(a.width||0);l>t&&(t=l),a.y<r&&(r=a.y)}return{x:Math.round(t+60),y:Math.round(r)}}const J=320,re=20;function Me(n){const e=[],t=n.split(`
10
- `);let r="response",a="",l=[],s=!1,m=[];const d=()=>{const p=l.join(`
11
- `).trim();p&&e.push({type:r,heading:a,content:p}),l=[]};for(const p of t){if(p.trim().startsWith("```mermaid")){d(),s=!0,m=[];continue}if(s){if(p.trim()==="```"){s=!1;const c=m.join(`
12
- `).trim();c&&e.push({type:"mermaid",heading:"Flow Diagram",content:c})}else m.push(p);continue}if(p.startsWith("## ")||p.startsWith("### ")){d();const c=p.replace(/^#{2,3}\s+/,"").trim();a=c;const f=c.toLowerCase();f.includes("research")||f.includes("analysis")||f.includes("finding")?r="research":f.includes("suggestion")||f.includes("idea")||f.includes("recommendation")?r="suggestion":r="response";continue}if(p.startsWith("> ")){r!=="suggestion"&&(d(),r="suggestion",a=a||"Suggestion"),l.push(p.slice(2));continue}l.push(p)}return d(),e}function _e(n,e){const t=n.split(`
13
- `),r=[];for(const a of t)if(a.length<=e)r.push(a);else{const l=a.split(" ");let s="";for(const m of l)s.length+m.length+1>e?(s&&r.push(s),s=m):s=s?s+" "+m:m;s&&r.push(s)}return r.join(`
14
- `)}function $e(n,e,t,r){const a=Me(n),l=[],s=[];let m=t;for(const d of a){if(d.type==="mermaid"){s.push({content:d.content,x:e,y:m}),m+=200+re;continue}const p=_e(d.content,42),c=p.length>600?p.slice(0,600)+`
15
- ...`:p;let f;switch(d.type){case"research":f=De(e,m,c,J);break;case"suggestion":f=Ee(e,m,c,J);break;default:f=je(e,m,c,J);break}l.push({blockId:f.blockId,groupId:f.groupId,elements:f.elements,totalHeight:f.totalHeight}),m+=f.totalHeight+re}if(r&&l.length>0){const d=Y(r,l[0].blockId);l[0].elements.push(d.element)}for(let d=0;d<l.length-1;d++){const p=Y(l[d].blockId,l[d+1].blockId);l[d+1].elements.push(p.element)}return{blocks:l,mermaidSections:s}}const q="upfynai-excalidraw-scene",ae=`You are a visual AI assistant working on an infinite canvas. The user has drawn elements on the canvas and is asking you to analyze and respond.
16
-
17
- IMPORTANT: Structure your response using markdown headings so it can be rendered as visual blocks:
18
- - Use ## headings to separate major sections
19
- - Use ### Research: or ### Analysis: for research/analysis sections
20
- - Use ### Suggestions: or ### Ideas: for suggestion sections
21
- - Use > blockquotes for key insights or recommendations
22
- - Use \`\`\`mermaid code blocks for flow diagrams when appropriate
23
- - Keep each section concise (2-4 sentences or bullet points)
24
- - Be visual and structured — your response will appear as blocks on the canvas
25
-
26
- Here is the current canvas context:
27
-
28
- `;function Le({selectedProject:n,ws:e,sendMessage:t,latestMessage:r}){const[a,l]=g.useState(null),[s,m]=g.useState(null),[d,p]=g.useState(!1),[c,f]=g.useState(""),[x,D]=g.useState(!1),[A,w]=g.useState([]),[o,b]=g.useState(0),v=g.useRef(null),k=g.useRef(""),I=g.useRef(null),T=g.useRef({x:0,y:0}),P=g.useRef(null);g.useEffect(()=>{const u="upfynai-canvas-v2-migrated";localStorage.getItem(u)||(localStorage.removeItem(q),localStorage.setItem(u,"1")),ce(()=>import("./percentages-BXMCSKIN-WVlHS4wx.js").then(h=>h.i),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(h=>{l(()=>h.Excalidraw)})},[]);const M=g.useCallback(()=>{try{const u=localStorage.getItem(q);if(u)return{elements:JSON.parse(u).elements||[],appState:{viewModeEnabled:!1,gridModeEnabled:!0}}}catch{}return{elements:[],appState:{viewModeEnabled:!1,gridModeEnabled:!0}}},[]),$=g.useCallback((u,h)=>{try{localStorage.setItem(q,JSON.stringify({elements:u}))}catch{}const E=Object.keys((h==null?void 0:h.selectedElementIds)||{}).length;b(E)},[]);g.useEffect(()=>{if(!s)return;window.__excalidrawAPI=s,Te();const u=E=>{try{const S=JSON.parse(E.data);S.type==="canvas-update"&&S.elements&&s&&s.updateScene({elements:S.elements}),S.type==="canvas-block-command"&&S.action&&Re(S)}catch{}},h=window.__upfynWs;return h&&h.addEventListener("message",u),()=>{delete window.__excalidrawAPI,Be(),h&&h.removeEventListener("message",u)}},[s]),g.useEffect(()=>{if(!(!r||!x)){if(r.type==="claude-response"||r.type==="assistant"){const u=r.content||r.text||r.message||"";u&&(k.current+=u)}if(r.type==="claude-complete"||r.type==="message_stop"){const u=k.current.trim();u&&s&&(pe(u),w(h=>[...h,{role:"ai",text:u.slice(0,200)+(u.length>200?"...":"")}])),D(!1),k.current=""}}},[r,x,s]),g.useEffect(()=>{P.current&&(P.current.scrollTop=P.current.scrollHeight)},[A]);const pe=g.useCallback(u=>{if(!s)return;const h=T.current,E=h.x+300,S=h.y,{blocks:N,mermaidSections:y}=$e(u,E,S,I.current||void 0),C=[];for(const j of N)C.push(...j.elements);if(C.length>0){const j=s.getSceneElements();s.updateScene({elements:[...j,...C]}),s.scrollToContent(C)}for(const j of y)B.addNote(j.x,j.y,`[Flowchart]
29
- ${j.content}`)},[s]),Q=g.useCallback(()=>{if(!s||!t||x)return;const u=oe(s),h=se(s),S=te(h.x,h.y,"Analyzing canvas..."),N=s.getSceneElements();s.updateScene({elements:[...N,...S.elements]}),I.current=S.blockId,T.current={x:h.x,y:h.y};const y=ae+u+`
30
-
31
- Analyze the canvas and provide a structured visual response.`;k.current="",D(!0),w(C=>[...C,{role:"user",text:"Run: Analyze canvas context"}]),t({type:"claude-command",command:y,options:{canvasMode:!0}})},[s,t,x]),Z=g.useCallback(()=>{t&&t({type:"cancel-command"}),D(!1),k.current=""},[t]),ee=g.useCallback(()=>{const u=c.trim();if(!u||!s||!t||x)return;const h=Pe(s),E=h||oe(s),S=h?"Selected items context":"Full canvas context",N=se(s),y=te(N.x,N.y,u),C=s.getSceneElements();s.updateScene({elements:[...C,...y.elements]}),I.current=y.blockId,T.current={x:N.x,y:N.y};const j=ae+`[${S}]
32
- `+E+`
33
-
34
- User message: `+u;k.current="",D(!0),w(W=>[...W,{role:"user",text:u}]),f(""),t({type:"claude-command",command:j,options:{canvasMode:!0}})},[c,s,t,x]),fe=g.useCallback(()=>{var N;if(!s)return;const u=s.getSceneElements(),h=new Set(["response","research","suggestion","prompt"]),E=new Set;for(const y of u)if((N=y.customData)!=null&&N.blockType&&h.has(y.customData.blockType)&&y.groupIds)for(const C of y.groupIds)E.add(C);const S=u.map(y=>{var C,j,W;return(C=y.customData)!=null&&C.blockType&&h.has(y.customData.blockType)?{...y,isDeleted:!0}:(j=y.groupIds)!=null&&j.some(he=>E.has(he))?{...y,isDeleted:!0}:((W=y.customData)==null?void 0:W.blockType)==="context-link"?{...y,isDeleted:!0}:y});s.updateScene({elements:S}),w([])},[s]);return a?i.jsxs("div",{className:"excalidraw-wrapper h-full w-full relative",children:[s&&i.jsx(Ae,{api:s,onRun:Q,onStop:Z,onClearAi:fe,isRunning:x}),i.jsx(a,{excalidrawAPI:u=>m(u),initialData:M(),onChange:$,UIOptions:{welcomeScreen:!1,canvasActions:{export:!1,loadScene:!1,saveToActiveFile:!1,toggleTheme:!1},tools:{image:!1}},viewModeEnabled:!1,gridModeEnabled:!0}),i.jsx("div",{className:"absolute top-4 right-4 z-20 flex items-center gap-2",children:x?i.jsxs("button",{onClick:Z,className:"flex items-center gap-2 px-4 py-2 rounded-xl bg-red-500 text-white shadow-lg hover:bg-red-600 transition-colors text-sm font-medium",children:[i.jsx("div",{className:"w-3 h-3 bg-white rounded-sm"}),"Stop"]}):i.jsxs("button",{onClick:Q,className:"flex items-center gap-2 px-4 py-2 rounded-xl bg-primary text-primary-foreground shadow-lg hover:bg-primary/90 transition-colors text-sm font-medium canvas-run-btn",title:"Read canvas context and ask AI",children:[i.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{d:"M8 5v14l11-7z"})}),"Run"]})}),x&&i.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20",children:i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-primary/10 border border-primary/20 rounded-full text-xs text-primary font-medium",children:[i.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-pulse"}),"AI is analyzing canvas..."]})}),i.jsx("button",{onClick:()=>{p(!d),d||setTimeout(()=>{var u;return(u=v.current)==null?void 0:u.focus()},100)},className:"absolute bottom-4 right-4 z-20 w-10 h-10 rounded-full bg-primary text-primary-foreground shadow-lg flex items-center justify-center hover:bg-primary/90 transition-colors",title:d?"Hide chat":"Chat with canvas",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:d?i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"}):i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),d&&i.jsx("div",{className:"absolute bottom-16 right-4 z-20 w-80 max-h-[50vh] canvas-chat-panel",children:i.jsxs("div",{className:"bg-card/95 backdrop-blur-md border border-border/50 rounded-2xl shadow-xl flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"px-3 py-2 border-b border-border/30 flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-medium text-foreground",children:"Canvas Chat"}),i.jsx("div",{className:"flex items-center gap-1",children:i.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${o>0?"text-primary bg-primary/10":"text-muted-foreground bg-muted/50"}`,children:o>0?`${o} selected`:"full canvas"})})]}),i.jsxs("div",{ref:P,className:"flex-1 overflow-y-auto max-h-48 px-3 py-2 space-y-2",children:[A.length===0&&i.jsx("p",{className:"text-xs text-muted-foreground/60 text-center py-4",children:"Ask AI about your canvas. Context is auto-attached."}),A.map((u,h)=>i.jsxs("div",{className:`text-xs px-2 py-1.5 rounded-lg ${u.role==="user"?"bg-primary/10 text-foreground ml-6":"bg-muted/50 text-foreground mr-6"}`,children:[i.jsx("span",{className:"font-medium text-[10px] text-muted-foreground block mb-0.5",children:u.role==="user"?"You":"AI"}),u.text]},h)),x&&i.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1 px-2",children:[i.jsx("div",{className:"w-1.5 h-1.5 bg-primary rounded-full animate-pulse"}),"Thinking..."]})]}),i.jsx("div",{className:"p-2 border-t border-border/30",children:i.jsxs("div",{className:"flex items-end gap-2",children:[i.jsx("textarea",{ref:v,value:c,onChange:u=>f(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),ee())},placeholder:"Ask about your canvas...",rows:1,className:"flex-1 bg-muted/30 text-foreground text-xs placeholder-muted-foreground/50 resize-none outline-none px-3 py-2 rounded-lg max-h-16 overflow-y-auto border border-border/30 focus:border-primary/30"}),i.jsx("button",{onClick:ee,disabled:!c.trim()||x,className:"shrink-0 w-8 h-8 rounded-lg bg-primary text-primary-foreground flex items-center justify-center disabled:opacity-40 hover:bg-primary/90 transition-colors",children:x?i.jsx("div",{className:"w-3 h-3 border-2 border-primary-foreground/30 border-t-primary-foreground rounded-full animate-spin"}):i.jsx("svg",{className:"w-3.5 h-3.5 rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]})})]})})]}):i.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading whiteboard..."})}const Ue=ge.memo(Le);export{Ue as default};
@@ -1 +0,0 @@
1
- .excalidraw .main-menu-trigger,.excalidraw .welcome-screen-center,.excalidraw a[href*="excalidraw.com"],.excalidraw .encrypted-icon{display:none!important}.excalidraw .collab-button,.excalidraw .CollabButton,.excalidraw [data-testid=collab-button],.excalidraw button[title="Live collaboration"],.excalidraw .share-button,.excalidraw button.collab-button,.excalidraw [class*=collab],.excalidraw [class*=CollabButton],.excalidraw [class*=share-button],.excalidraw .layer-ui__wrapper__top-right [class*=Island]>button:last-child{display:none!important}.excalidraw .HelpButton,.excalidraw button[data-testid=help-icon]{display:none!important}.excalidraw-wrapper{width:100%;height:100%;position:relative}.excalidraw-wrapper .excalidraw{width:100%;height:100%}.excalidraw .App-toolbar-container{z-index:3}.canvas-block-toolbar{position:absolute;top:50%;left:12px;transform:translateY(-50%);z-index:10;display:flex;flex-direction:column;gap:4px;padding:6px;background:#ffffffeb;border:1px solid rgba(0,0,0,.1);border-radius:12px;backdrop-filter:blur(8px);box-shadow:0 2px 8px #00000014}.canvas-block-toolbar button{color:#555}.canvas-block-toolbar button:hover{color:#111;background:#0000000f}.canvas-block-toolbar .w-5{border-color:#0000001a}.canvas-run-btn{box-shadow:0 2px 12px rgba(var(--primary-rgb, 59 130 246) / .3);transition:all .2s}.canvas-run-btn:hover{box-shadow:0 4px 16px rgba(var(--primary-rgb, 59 130 246) / .4);transform:translateY(-1px)}.canvas-chat-panel{animation:slideUp .2s ease-out}@keyframes slideUp{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
@@ -1 +0,0 @@
1
- import{r as n,j as e}from"./vendor-react-9mUTKBHH.js";import{a as f,I as x}from"./index-ce18TYkg.js";import{e as j,f as N,g as v,Z as u,R as w,T as y,d as k,B as C,E as S,A as I}from"./vendor-icons-Lb69KSFJ.js";import"./vendor-syntax-DnmwQQJF.js";import"./vendor-markdown-BXEi_H3G.js";import"./vendor-i18n-DCFGyhQR.js";function B({selectedProject:s}){const[t,o]=n.useState(null),[r,l]=n.useState(null),[a,m]=n.useState(!0),[R,p]=n.useState(null),i=n.useCallback(async()=>{m(!0),p(null);try{const c=await f("/api/dashboard/stats");if(c.ok){const b=await c.json();o(b)}}catch{}m(!1)},[]);return n.useEffect(()=>{i()},[i]),e.jsxs("div",{className:"h-full overflow-y-auto p-4 sm:p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(j,{className:"w-5 h-5 text-blue-500"}),"Dashboard"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:s?`Project: ${s.displayName||s.name}`:"Overview"})]}),e.jsx("button",{onClick:i,disabled:a,className:"p-2 rounded-lg hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors",title:"Refresh stats",children:e.jsx(N,{className:`w-4 h-4 ${a?"animate-spin":""}`})})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsx(g,{icon:v,label:"Sessions",value:(t==null?void 0:t.total)??"—",subtext:t!=null&&t.today?`${t.today} today`:void 0,color:"blue"}),e.jsx(g,{icon:u,label:"AI Providers",value:t!=null&&t.providers?Object.keys(t.providers).length:"—",subtext:t!=null&&t.providers?Object.keys(t.providers).join(", "):void 0,color:"purple"}),x]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3 uppercase tracking-wider",children:"Quick Actions"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:[e.jsx(h,{label:"Install CLI",description:"npm install -g upfynai-code",onClick:()=>navigator.clipboard.writeText("npm install -g upfynai-code")}),e.jsx(h,{label:"Connect Machine",description:"uc connect",onClick:()=>navigator.clipboard.writeText("uc connect")}),x]})]}),x,s&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3 uppercase tracking-wider",children:"Project Info"}),e.jsxs("div",{className:"rounded-lg bg-muted/30 border border-border/50 p-4 space-y-2",children:[e.jsx(d,{label:"Name",value:s.displayName||s.name}),e.jsx(d,{label:"Path",value:s.fullPath||s.path||"—"}),s.sessions&&e.jsx(d,{label:"Claude Sessions",value:String(s.sessions.length)}),s.cursorSessions&&e.jsx(d,{label:"Cursor Sessions",value:String(s.cursorSessions.length)}),s.codexSessions&&e.jsx(d,{label:"Codex Sessions",value:String(s.codexSessions.length)})]})]}),!s&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium text-muted-foreground mb-3 uppercase tracking-wider flex items-center gap-2",children:[e.jsx(w,{className:"w-3.5 h-3.5"}),"Getting Started"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"rounded-lg border border-border/50 bg-card/50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(y,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:"1. Install the CLI"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-2",children:["Install globally, then run ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"uc"})," to launch."]}),e.jsx("code",{className:"text-xs bg-muted/50 px-2 py-1 rounded block text-foreground/80",children:"npm install -g upfynai-code"})]}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-card/50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(u,{className:"w-4 h-4 text-yellow-500"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:"2. Connect Your Machine"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Bridge your local dev environment to this web UI."}),e.jsx("code",{className:"text-xs bg-muted/50 px-2 py-1 rounded block text-foreground/80",children:"uc connect --key your_relay_token"})]}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-card/50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(k,{className:"w-4 h-4 text-indigo-500"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:"3. Use the Canvas"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Switch to the Canvas tab to create visual workspaces with code blocks, diagrams, and notes."})]}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-card/50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(C,{className:"w-4 h-4 text-emerald-500"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:"4. Chat with AI"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use the Chat tab to talk to Claude, Cursor, or Codex. Bring your own API keys in Settings."})]})]})]})]})}function g({icon:s,label:t,value:o,subtext:r,color:l}){const a={blue:"text-blue-500 bg-blue-500/10",purple:"text-purple-500 bg-purple-500/10",amber:"text-amber-500 bg-amber-500/10",emerald:"text-emerald-500 bg-emerald-500/10"};return e.jsxs("div",{className:"rounded-lg border border-border/50 bg-card/50 p-3 sm:p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${a[l]}`,children:e.jsx(s,{className:"w-3.5 h-3.5"})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t})]}),e.jsx("p",{className:"text-xl font-semibold text-foreground",children:o}),r&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:r})]})}function h({label:s,description:t,onClick:o,href:r}){const l=r?"a":"button",a=r?{href:r,target:"_blank",rel:"noopener noreferrer"}:{onClick:o};return e.jsxs(l,{...a,className:"flex items-center justify-between p-3 rounded-lg border border-border/50 bg-card/50 hover:bg-muted/60 transition-colors text-left group",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t})]}),r?e.jsx(S,{className:"w-3.5 h-3.5 text-muted-foreground group-hover:text-foreground"}):e.jsx(I,{className:"w-3.5 h-3.5 text-muted-foreground group-hover:text-foreground"})]})}function d({label:s,value:t}){return e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),e.jsx("span",{className:"text-foreground font-mono text-xs truncate max-w-[60%] text-right",children:t})]})}export{B as default};
@@ -1,19 +0,0 @@
1
- import{a as ye,r as s,j as e}from"./vendor-react-9mUTKBHH.js";import{b as be,R as we,g as ve,c as Ne,d as de}from"./index-ce18TYkg.js";import{x as je,a as ke,b as Ce,c as Se}from"./vendor-xterm-CZq1hqo1.js";import{X as Le}from"./vendor-icons-Lb69KSFJ.js";const Re=(t,r,o,g)=>{var n,w,N,d;const y=[o,{code:r,...g||{}}];if((w=(n=t==null?void 0:t.services)==null?void 0:n.logger)!=null&&w.forward)return t.services.logger.forward(y,"warn","react-i18next::",!0);z(y[0])&&(y[0]=`react-i18next:: ${y[0]}`),(d=(N=t==null?void 0:t.services)==null?void 0:N.logger)!=null&&d.warn?t.services.logger.warn(...y):console!=null&&console.warn&&console.warn(...y)},se={},fe=(t,r,o,g)=>{z(o)&&se[o]||(z(o)&&(se[o]=new Date),Re(t,r,o,g))},xe=(t,r)=>()=>{if(t.isInitialized)r();else{const o=()=>{setTimeout(()=>{t.off("initialized",o)},0),r()};t.on("initialized",o)}},ee=(t,r,o)=>{t.loadNamespaces(r,xe(t,o))},ae=(t,r,o,g)=>{if(z(o)&&(o=[o]),t.options.preload&&t.options.preload.indexOf(r)>-1)return ee(t,o,g);o.forEach(y=>{t.options.ns.indexOf(y)<0&&t.options.ns.push(y)}),t.loadLanguages(r,xe(t,g))},Ee=(t,r,o={})=>!r.languages||!r.languages.length?(fe(r,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:r.languages}),!0):r.hasLoadedNamespace(t,{lng:o.lng,precheck:(g,y)=>{if(o.bindI18n&&o.bindI18n.indexOf("languageChanging")>-1&&g.services.backendConnector.backend&&g.isLanguageChangingTo&&!y(g.isLanguageChangingTo,t))return!1}}),z=t=>typeof t=="string",Te=t=>typeof t=="object"&&t!==null;var Y={exports:{}},Q={};/**
2
- * @license React
3
- * use-sync-external-store-shim.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var le;function Ie(){if(le)return Q;le=1;var t=ye();function r(c,a){return c===a&&(c!==0||1/c===1/a)||c!==c&&a!==a}var o=typeof Object.is=="function"?Object.is:r,g=t.useState,y=t.useEffect,n=t.useLayoutEffect,w=t.useDebugValue;function N(c,a){var b=a(),S=g({inst:{value:b,getSnapshot:a}}),h=S[0].inst,O=S[1];return n(function(){h.value=b,h.getSnapshot=a,d(h)&&O({inst:h})},[c,b,a]),y(function(){return d(h)&&O({inst:h}),c(function(){d(h)&&O({inst:h})})},[c]),w(b),b}function d(c){var a=c.getSnapshot;c=c.value;try{var b=a();return!o(c,b)}catch{return!0}}function j(c,a){return a()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?j:N;return Q.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,Q}var oe;function Oe(){return oe||(oe=1,Y.exports=Ie()),Y.exports}var Ae=Oe();const Me=(t,r)=>z(r)?r:Te(r)&&z(r.defaultValue)?r.defaultValue:Array.isArray(t)?t[t.length-1]:t,_e={t:Me,ready:!1},Pe=()=>()=>{},Ue=(t,r={})=>{var D,i,C;const{i18n:o}=r,{i18n:g,defaultNS:y}=s.useContext(be)||{},n=o||g||Ne();n&&!n.reportNamespaces&&(n.reportNamespaces=new we),n||fe(n,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const w=s.useMemo(()=>{var l;return{...ve(),...(l=n==null?void 0:n.options)==null?void 0:l.react,...r}},[n,r]),{useSuspense:N,keyPrefix:d}=w,j=t||y||((D=n==null?void 0:n.options)==null?void 0:D.defaultNS),u=z(j)?[j]:j||["translation"],c=s.useMemo(()=>u,u);(C=(i=n==null?void 0:n.reportNamespaces)==null?void 0:i.addUsedNamespaces)==null||C.call(i,c);const a=s.useRef(0),b=s.useCallback(l=>{if(!n)return Pe;const{bindI18n:x,bindI18nStore:m}=w,p=()=>{a.current+=1,l()};return x&&n.on(x,p),m&&n.store.on(m,p),()=>{x&&x.split(" ").forEach(I=>n.off(I,p)),m&&m.split(" ").forEach(I=>n.store.off(I,p))}},[n,w]),S=s.useRef(),h=s.useCallback(()=>{if(!n)return _e;const l=!!(n.isInitialized||n.initializedStoreOnce)&&c.every(H=>Ee(H,n,w)),x=r.lng||n.language,m=a.current,p=S.current;if(p&&p.ready===l&&p.lng===x&&p.keyPrefix===d&&p.revision===m)return p;const J={t:n.getFixedT(x,w.nsMode==="fallback"?c:c[0],d),ready:l,lng:x,keyPrefix:d,revision:m};return S.current=J,J},[n,c,d,w,r.lng]),[O,_]=s.useState(0),{t:A,ready:E}=Ae.useSyncExternalStore(b,h,h);s.useEffect(()=>{if(n&&!E&&!N){const l=()=>_(x=>x+1);r.lng?ae(n,r.lng,c,l):ee(n,c,l)}},[n,r.lng,c,E,N,O]);const M=n||{},k=s.useRef(null),T=s.useRef(),B=l=>{const x=Object.getOwnPropertyDescriptors(l);x.__original&&delete x.__original;const m=Object.create(Object.getPrototypeOf(l),x);if(!Object.prototype.hasOwnProperty.call(m,"__original"))try{Object.defineProperty(m,"__original",{value:l,writable:!1,enumerable:!1,configurable:!1})}catch{}return m},P=s.useMemo(()=>{const l=M,x=l==null?void 0:l.language;let m=l;l&&(k.current&&k.current.__original===l?T.current!==x?(m=B(l),k.current=m,T.current=x):m=k.current:(m=B(l),k.current=m,T.current=x));const p=[A,m,E];return p.t=A,p.i18n=m,p.ready=E,p},[A,M,E,M.resolvedLanguage,M.language,M.languages]);if(n&&N&&!E)throw new Promise(l=>{const x=()=>l();r.lng?ae(n,r.lng,c,x):ee(n,c,x)});return P},Je=({className:t="w-5 h-5"})=>e.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:t}),Ke=({className:t="w-5 h-5"})=>{const{isDarkMode:r}=de();return e.jsx("img",{src:r?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:t})},qe=({className:t="w-5 h-5"})=>{const{isDarkMode:r}=de();return e.jsx("img",{src:r?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:t})},We=`
10
- .xterm .xterm-screen {
11
- outline: none !important;
12
- }
13
- .xterm:focus .xterm-screen {
14
- outline: none !important;
15
- }
16
- .xterm-screen:focus {
17
- outline: none !important;
18
- }
19
- `;if(typeof document<"u"){const t=document.createElement("style");t.type="text/css",t.innerText=We,document.head.appendChild(t)}function ze(t){if(!t||typeof document>"u")return!1;const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.focus(),r.select();let o=!1;try{o=document.execCommand("copy")}catch{o=!1}finally{document.body.removeChild(r)}return o}const ce="https://auth.openai.com/codex/device";function ie(t){return typeof t=="string"&&/\bcodex\s+login\b/i.test(t)}function ue({selectedProject:t,selectedSession:r,initialCommand:o,isPlainShell:g=!1,onProcessComplete:y,minimal:n=!1,autoConnect:w=!1,shellType:N=null}){const{t:d}=Ue("chat"),j=s.useRef(null),u=s.useRef(null),c=s.useRef(null),a=s.useRef(null),[b,S]=s.useState(!1),[h,O]=s.useState(!1),[_,A]=s.useState(!1),[E,M]=s.useState(null),[k,T]=s.useState(!1),[B,P]=s.useState(""),[D,i]=s.useState("idle"),[C,l]=s.useState(!1),x=s.useRef(t),m=s.useRef(r),p=s.useRef(o),I=s.useRef(g),J=s.useRef(N),H=s.useRef(y),W=s.useRef("");s.useEffect(()=>{x.current=t,m.current=r,p.current=o,I.current=g,J.current=N,H.current=y});const te=s.useCallback((v=W.current)=>{if(!v)return!1;const R=window.open(v,"_blank","noopener,noreferrer");if(R){try{R.opener=null}catch{}return!0}return!1},[]),G=s.useCallback(async(v=W.current)=>{var L;if(!v)return!1;let R=!1;try{typeof navigator<"u"&&((L=navigator.clipboard)!=null&&L.writeText)&&(await navigator.clipboard.writeText(v),R=!0)}catch{R=!1}return R||(R=ze(v)),R},[]),re=s.useCallback(async()=>{if(!(k||b))try{let v;v=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell`,a.current=new WebSocket(v),a.current.onopen=()=>{S(!0),T(!1),W.current="",P(""),i("idle"),l(!1),setTimeout(()=>{var L,f;c.current&&u.current&&(c.current.fit(),a.current.send(JSON.stringify({type:"init",projectPath:x.current.fullPath||x.current.path,sessionId:I.current?null:(L=m.current)==null?void 0:L.id,hasSession:I.current?!1:!!m.current,provider:I.current?"plain-shell":((f=m.current)==null?void 0:f.__provider)||"claude",cols:u.current.cols,rows:u.current.rows,initialCommand:p.current,isPlainShell:I.current,shellType:J.current})))},100)},a.current.onmessage=L=>{try{const f=JSON.parse(L.data);if(f.type==="output"){let U=f.data;if(I.current&&H.current){const F=U.replace(/\x1b\[[0-9;]*m/g,"");if(F.includes("Process exited with code 0"))H.current(0);else if(F.match(/Process exited with code (\d+)/)){const K=parseInt(F.match(/Process exited with code (\d+)/)[1]);K!==0&&H.current(K)}}u.current&&u.current.write(U)}else(f.type==="auth_url"&&f.url||f.type==="url_open"&&f.url)&&(W.current=f.url,P(f.url),i("idle"),l(!1))}catch(f){console.error("[Shell] Error handling WebSocket message:",f,L.data)}},a.current.onclose=L=>{S(!1),T(!1),i("idle"),l(!1),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H"))},a.current.onerror=L=>{S(!1),T(!1)}}catch{S(!1),T(!1)}},[k,b,te]),V=s.useCallback(()=>{!h||b||k||(T(!0),re())},[h,b,k,re]),X=s.useCallback(()=>{a.current&&(a.current.close(),a.current=null),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H")),S(!1),T(!1),W.current="",P(""),i("idle"),l(!1)},[]),$=s.useMemo(()=>r?r.__provider==="cursor"?r.name||"Untitled Session":r.summary||"New Session":null,[r]),he=s.useMemo(()=>$?$.slice(0,30):null,[$]),me=s.useMemo(()=>$?$.slice(0,50):null,[$]),pe=()=>{A(!0),a.current&&(a.current.close(),a.current=null),u.current&&(u.current.dispose(),u.current=null,c.current=null),S(!1),O(!1),W.current="",P(""),i("idle"),l(!1),setTimeout(()=>{A(!1)},200)};if(s.useEffect(()=>{const v=(r==null?void 0:r.id)||null;E!==null&&E!==v&&h&&X(),M(v)},[r==null?void 0:r.id,h,X]),s.useEffect(()=>{if(!j.current||!t||_||u.current)return;u.current=new je.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),c.current=new ke.FitAddon;const v=new Ce.WebglAddon,R=new Se.WebLinksAddon;u.current.loadAddon(c.current),n||u.current.loadAddon(R);try{u.current.loadAddon(v)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}u.current.open(j.current),u.current.attachCustomKeyEventHandler(f=>{var F,K,ne;const U=ie(p.current)?ce:W.current;return f.type==="keydown"&&n&&I.current&&U&&!f.ctrlKey&&!f.metaKey&&!f.altKey&&((F=f.key)==null?void 0:F.toLowerCase())==="c"&&G(U).catch(()=>{}),f.type==="keydown"&&(f.ctrlKey||f.metaKey)&&((K=f.key)==null?void 0:K.toLowerCase())==="c"&&u.current.hasSelection()?(f.preventDefault(),f.stopPropagation(),document.execCommand("copy"),!1):f.type==="keydown"&&(f.ctrlKey||f.metaKey)&&((ne=f.key)==null?void 0:ne.toLowerCase())==="v"?(f.preventDefault(),f.stopPropagation(),navigator.clipboard.readText().then(ge=>{a.current&&a.current.readyState===WebSocket.OPEN&&a.current.send(JSON.stringify({type:"input",data:ge}))}).catch(()=>{}),!1):!0}),setTimeout(()=>{c.current&&(c.current.fit(),u.current&&a.current&&a.current.readyState===WebSocket.OPEN&&a.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows})))},100),O(!0),u.current.onData(f=>{a.current&&a.current.readyState===WebSocket.OPEN&&a.current.send(JSON.stringify({type:"input",data:f}))});const L=new ResizeObserver(()=>{c.current&&u.current&&setTimeout(()=>{c.current.fit(),a.current&&a.current.readyState===WebSocket.OPEN&&a.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows}))},50)});return j.current&&L.observe(j.current),()=>{L.disconnect(),a.current&&(a.current.readyState===WebSocket.OPEN||a.current.readyState===WebSocket.CONNECTING)&&a.current.close(),a.current=null,u.current&&(u.current.dispose(),u.current=null)}},[(t==null?void 0:t.path)||(t==null?void 0:t.fullPath),_,n,G]),s.useEffect(()=>{!w||!h||k||b||V()},[w,h,k,b,V]),!t)return e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:d("shell.selectProject.title")}),e.jsx("p",{children:d("shell.selectProject.description")})]})});if(n){const v=ie(o)?ce:B,R=!!v,L=R&&!C,f=R&&C;return e.jsxs("div",{className:"h-full w-full bg-gray-900 relative",children:[e.jsx("div",{ref:j,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),L&&e.jsx("div",{className:"absolute inset-x-0 bottom-14 z-20 border-t border-gray-700/80 bg-gray-900/95 p-3 backdrop-blur-sm md:hidden",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs text-gray-300",children:"Open or copy the login URL:"}),e.jsx("button",{type:"button",onClick:()=>l(!0),className:"rounded bg-gray-700 px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-gray-100 hover:bg-gray-600",children:"Hide"})]}),e.jsx("input",{type:"text",value:v,readOnly:!0,onClick:U=>U.currentTarget.select(),className:"w-full rounded border border-gray-600 bg-gray-800 px-2 py-1 text-xs text-gray-100 focus:outline-none focus:ring-1 focus:ring-blue-500","aria-label":"Authentication URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{te(v)},className:"flex-1 rounded bg-blue-600 px-3 py-2 text-xs font-medium text-white hover:bg-blue-700",children:"Open URL"}),e.jsx("button",{type:"button",onClick:async()=>{const U=await G(v);i(U?"copied":"failed")},className:"flex-1 rounded bg-gray-700 px-3 py-2 text-xs font-medium text-white hover:bg-gray-600",children:D==="copied"?"Copied":"Copy URL"})]})]})}),f&&e.jsx("div",{className:"absolute bottom-14 right-3 z-20 md:hidden",children:e.jsx("button",{type:"button",onClick:()=>l(!1),className:"rounded bg-gray-800/95 px-3 py-2 text-xs font-medium text-gray-100 shadow-lg backdrop-blur-sm hover:bg-gray-700",children:"Show login URL"})})]})}return e.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${b?"bg-green-500":"bg-red-500"}`}),r&&e.jsxs("span",{className:"text-xs text-blue-300",children:["(",he,"...)"]}),!r&&e.jsx("span",{className:"text-xs text-gray-400",children:d("shell.status.newSession")}),!h&&e.jsx("span",{className:"text-xs text-yellow-400",children:d("shell.status.initializing")}),_&&e.jsx("span",{className:"text-xs text-blue-400",children:d("shell.status.restarting")})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[b&&e.jsxs("button",{onClick:X,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:d("shell.actions.disconnectTitle"),children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{children:d("shell.actions.disconnect")})]}),e.jsxs("button",{onClick:pe,disabled:_||b,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:d("shell.actions.restartTitle"),children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("span",{children:d("shell.actions.restart")})]})]})]})}),e.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[e.jsx("div",{ref:j,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!h&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:e.jsx("div",{className:"text-white",children:d("shell.loading")})}),h&&!b&&!k&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("button",{onClick:V,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",title:d("shell.actions.connectTitle"),children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("span",{children:d("shell.actions.connect")})]}),e.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:g?d("shell.runCommand",{command:o||d("shell.defaultCommand"),projectName:t.displayName}):r?d("shell.resumeSession",{displayName:me}):d("shell.startSession")})]})}),k&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),e.jsx("span",{className:"text-base font-medium",children:d("shell.connecting")})]}),e.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:g?d("shell.runCommand",{command:o||d("shell.defaultCommand"),projectName:t.displayName}):d("shell.startCli",{projectName:t.displayName})})]})})]})]})}let Z=0;const q=[{value:"powershell",label:"PowerShell",icon:"PS"},{value:"cmd",label:"CMD",icon:">"},{value:"bash",label:"Bash",icon:"$"}];function Be({project:t,session:r=null,command:o=null,isPlainShell:g=null,autoConnect:y=!0,onComplete:n=null,onClose:w=null,title:N=null,className:d="",showHeader:j=!0,compact:u=!1,minimal:c=!1,multiTab:a=!1}){const[b,S]=s.useState(!1),[h,O]=s.useState(()=>[{id:++Z,shellType:"powershell",label:"PowerShell"}]),[_,A]=s.useState(()=>{var i;return(i=h[0])==null?void 0:i.id}),[E,M]=s.useState(!1),k=s.useRef(null),T=g!==null?g:o!==null,B=s.useCallback(i=>{S(!0),n&&n(i)},[n]),P=s.useCallback(i=>{const C=q.find(x=>x.value===i)||q[0],l=++Z;O(x=>[...x,{id:l,shellType:C.value,label:C.label}]),A(l),M(!1)},[]),D=s.useCallback(i=>{O(C=>{const l=C.filter(x=>x.id!==i);return l.length===0?[{id:++Z,shellType:"powershell",label:"PowerShell"}]:l}),A(C=>{if(C===i){const l=h.findIndex(p=>p.id===i),x=h.filter(p=>p.id!==i);if(x.length===0)return null;const m=Math.min(l,x.length-1);return x[m].id}return C})},[h]);return t?a&&!c&&!r&&!o?e.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[e.jsxs("div",{className:"flex-shrink-0 flex items-center bg-[#1e1e1e] border-b border-gray-700 px-1 min-h-[36px]",children:[e.jsx("div",{className:"flex items-center gap-0.5 overflow-x-auto flex-1 min-w-0",children:h.map(i=>{var C;return e.jsxs("button",{onClick:()=>A(i.id),className:`group flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-t transition-colors shrink-0 ${_===i.id?"bg-gray-800 text-gray-100 border-t-2 border-t-blue-500":"text-gray-400 hover:text-gray-200 hover:bg-gray-800/50"}`,children:[e.jsx("span",{className:"text-[10px] font-mono opacity-60",children:((C=q.find(l=>l.value===i.shellType))==null?void 0:C.icon)||">"}),e.jsx("span",{children:i.label}),h.length>1&&e.jsx("span",{onClick:l=>{l.stopPropagation(),D(i.id)},className:"ml-1 opacity-0 group-hover:opacity-100 hover:text-red-400 transition-opacity cursor-pointer",title:"Close tab",children:"×"})]},i.id)})}),e.jsxs("div",{className:"relative ml-1 shrink-0",children:[e.jsx("button",{ref:k,onClick:()=>M(!E),className:"flex items-center justify-center w-7 h-7 text-gray-400 hover:text-gray-100 hover:bg-gray-700 rounded transition-colors text-lg",title:"New terminal",children:"+"}),E&&e.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 bg-gray-800 border border-gray-600 rounded-lg shadow-xl py-1 min-w-[140px]",children:q.map(i=>e.jsxs("button",{onClick:()=>P(i.value),className:"w-full text-left px-3 py-1.5 text-xs text-gray-200 hover:bg-gray-700 flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-[10px] opacity-60 w-4",children:i.icon}),i.label]},i.value))})]})]}),e.jsx("div",{className:"flex-1 w-full min-h-0 relative",children:h.map(i=>e.jsx("div",{className:"absolute inset-0",style:{display:_===i.id?"block":"none"},children:e.jsx(ue,{selectedProject:t,isPlainShell:!0,shellType:i.shellType,autoConnect:!0,minimal:!1})},i.id))})]}):e.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[!c&&j&&N&&e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-200",children:N}),b&&e.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),w&&e.jsx("button",{onClick:w,className:"text-gray-400 hover:text-white",title:"Close",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsx("div",{className:"flex-1 w-full min-h-0",children:e.jsx(ue,{selectedProject:t,selectedSession:r,initialCommand:o,isPlainShell:T,onProcessComplete:B,minimal:c,autoConnect:c?!0:y})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${d}`,children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Project Selected"}),e.jsx("p",{children:"A project is required to open a shell"})]})})}function Ge({isOpen:t,onClose:r,provider:o="claude",project:g,onComplete:y,customCommand:n,isAuthenticated:w=!1,isOnboarding:N=!1}){if(!t)return null;const d=()=>{if(n)return n;switch(o){case"claude":return w?"claude setup-token --dangerously-skip-permissions":N?"claude /exit --dangerously-skip-permissions":"claude /login --dangerously-skip-permissions";case"cursor":return"cursor-agent login";case"codex":return"codex login";default:return w?"claude setup-token --dangerously-skip-permissions":N?"claude /exit --dangerously-skip-permissions":"claude /login --dangerously-skip-permissions"}},j=()=>{switch(o){case"claude":return"Claude CLI Login";case"cursor":return"Cursor CLI Login";case"codex":return"Codex CLI Login";default:return"CLI Login"}},u=c=>{y&&y(c)};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] max-md:items-stretch max-md:justify-stretch",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-3/4 flex flex-col md:max-w-4xl md:h-3/4 md:rounded-lg md:m-4 max-md:max-w-none max-md:h-full max-md:rounded-none max-md:m-0",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:j()}),e.jsx("button",{onClick:r,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:e.jsx(Le,{className:"w-6 h-6"})})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Be,{project:g,command:d(),onComplete:u,minimal:!0})})]})})}export{Je as C,Ge as L,ue as S,Ke as a,qe as b,Be as c,Oe as r,Ue as u};
@@ -1 +0,0 @@
1
- import{r as d,j as r}from"./vendor-react-9mUTKBHH.js";import{a as p,b as x,c as y,d as b,M as u}from"./vendor-markdown-BXEi_H3G.js";import{h,p as k}from"./vendor-syntax-DnmwQQJF.js";function f({inline:e,className:t,children:a,...m}){const[c,n]=d.useState(!1),s=Array.isArray(a)?a.join(""):String(a??""),g=/[\r\n]/.test(s);if(e||!g)return r.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${t||""}`,...m,children:a});const l=/language-(\w+)/.exec(t||""),o=l?l[1]:"text";return r.jsxs("div",{className:"relative group my-2",children:[o&&o!=="text"&&r.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:o}),r.jsx("button",{type:"button",onClick:()=>{var i;(i=navigator.clipboard)==null||i.writeText(s).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},className:"absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity text-xs px-2 py-1 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600",children:c?"Copied!":"Copy"}),r.jsx(h,{language:o,style:k,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:o&&o!=="text"?"2rem 1rem 1rem 1rem":"1rem"},children:s})]})}const j={code:f,blockquote:({children:e})=>r.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:e}),a:({href:e,children:t})=>r.jsx("a",{href:e,className:"text-blue-600 dark:text-blue-400 hover:underline",target:"_blank",rel:"noopener noreferrer",children:t}),table:({children:e})=>r.jsx("div",{className:"overflow-x-auto my-2",children:r.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:e})}),thead:({children:e})=>r.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e}),th:({children:e})=>r.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:e}),td:({children:e})=>r.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:e})};function C({content:e}){const t=d.useMemo(()=>[p,x],[]),a=d.useMemo(()=>[y,b],[]);return r.jsx(u,{remarkPlugins:t,rehypePlugins:a,components:j,children:e})}export{C as default};
@@ -1 +0,0 @@
1
- import{r as a,j as e,v as W}from"./vendor-react-9mUTKBHH.js";import{L as Z,C as _,a as D,b as H}from"./LoginModal-CZDEzqjK.js";import{u as K,a as m}from"./index-ce18TYkg.js";import{R as P,G,L as Q,C as x,a as X,b as R,c as ee,U as te,M as se,T as re,d as ae,Z as ne}from"./vendor-icons-Lb69KSFJ.js";import"./vendor-xterm-CZq1hqo1.js";import"./vendor-syntax-DnmwQQJF.js";import"./vendor-markdown-BXEi_H3G.js";import"./vendor-i18n-DCFGyhQR.js";const ge=({onComplete:y})=>{const[r,g]=a.useState(0),[h,C]=a.useState(""),[u,k]=a.useState(""),[i,f]=a.useState(!1),[S,o]=a.useState(""),[n,b]=a.useState(null),[q]=a.useState({name:"default",fullPath:""}),[l,j]=a.useState({authenticated:!1,email:null,loading:!0,error:null}),[d,N]=a.useState({authenticated:!1,email:null,loading:!0,error:null}),[c,v]=a.useState({authenticated:!1,email:null,loading:!0,error:null}),{user:p}=K(),A=a.useRef(void 0);a.useEffect(()=>{$()},[]);const $=async()=>{try{const t=await m("/api/user/git-config");if(t.ok){const s=await t.json();s.gitName&&C(s.gitName),s.gitEmail&&k(s.gitEmail)}}catch(t){console.error("Error loading git config:",t)}};a.useEffect(()=>{const t=A.current;A.current=n,(t===void 0||t!==null&&n===null)&&(L(),E(),F())},[n]);const L=async()=>{try{const t=await m("/api/cli/claude/status");if(t.ok){const s=await t.json();j({authenticated:s.authenticated,email:s.email,loading:!1,error:s.error||null})}else j({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(t){console.error("Error checking Claude auth status:",t),j({authenticated:!1,email:null,loading:!1,error:t.message})}},E=async()=>{try{const t=await m("/api/cli/cursor/status");if(t.ok){const s=await t.json();N({authenticated:s.authenticated,email:s.email,loading:!1,error:s.error||null})}else N({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(t){console.error("Error checking Cursor auth status:",t),N({authenticated:!1,email:null,loading:!1,error:t.message})}},F=async()=>{try{const t=await m("/api/cli/codex/status");if(t.ok){const s=await t.json();v({authenticated:s.authenticated,email:s.email,loading:!1,error:s.error||null})}else v({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(t){console.error("Error checking Codex auth status:",t),v({authenticated:!1,email:null,loading:!1,error:t.message})}},M=()=>b("claude"),T=()=>b("cursor"),O=()=>b("codex"),U=t=>{t===0&&(n==="claude"?L():n==="cursor"?E():n==="codex"&&F())},B=async()=>{if(o(""),r===0){g(1);return}if(r===1){if(!h.trim()||!u.trim()){o("Both git name and email are required");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u)){o("Please enter a valid email address");return}f(!0);try{const s=await m("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:h,gitEmail:u})});if(!s.ok){const I=await s.json();throw new Error(I.error||"Failed to save git configuration")}g(2)}catch(s){o(s.message)}finally{f(!1)}return}g(r+1)},Y=()=>{o(""),g(r-1)},z=async()=>{f(!0),o("");try{const t=await m("/api/user/complete-onboarding",{method:"POST"});if(!t.ok){const s=await t.json();throw new Error(s.error||"Failed to complete onboarding")}y&&y()}catch(t){o(t.message)}finally{f(!1)}},w=[{title:"Welcome",description:"Get to know Upfyn-Code",icon:P,required:!1},{title:"Git Configuration",description:"Set up your git identity for commits",icon:G,required:!0},{title:"Connect Agents",description:"Connect your AI coding assistants",icon:Q,required:!1}],J=()=>{switch(r){case 0:return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"w-20 h-20 bg-gradient-to-br from-blue-500 to-indigo-600 rounded-2xl flex items-center justify-center mx-auto mb-5 shadow-lg shadow-blue-500/20",children:e.jsx(P,{className:"w-10 h-10 text-white"})}),e.jsxs("h2",{className:"text-2xl font-bold text-foreground mb-2",children:["Welcome to Upfyn-Code",p!=null&&p.first_name?`, ${p.first_name}`:"","!"]}),e.jsx("p",{className:"text-muted-foreground max-w-md mx-auto",children:"Your visual AI coding interface. Let's get you set up in under a minute."})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"border border-border rounded-lg p-4 text-center bg-card",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/30 rounded-lg flex items-center justify-center mx-auto mb-2",children:e.jsx(re,{className:"w-5 h-5 text-blue-500"})}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"AI Agents"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Claude, Cursor, Codex — all in one place"})]}),e.jsxs("div",{className:"border border-border rounded-lg p-4 text-center bg-card",children:[e.jsx("div",{className:"w-10 h-10 bg-indigo-100 dark:bg-indigo-900/30 rounded-lg flex items-center justify-center mx-auto mb-2",children:e.jsx(ae,{className:"w-5 h-5 text-indigo-500"})}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Canvas"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Visual workspace with code, diagrams & notes"})]}),e.jsxs("div",{className:"border border-border rounded-lg p-4 text-center bg-card",children:[e.jsx("div",{className:"w-10 h-10 bg-yellow-100 dark:bg-yellow-900/30 rounded-lg flex items-center justify-center mx-auto mb-2",children:e.jsx(ne,{className:"w-5 h-5 text-yellow-500"})}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Relay"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Bridge your local machine to the web UI"})]})]}),e.jsx("div",{className:"text-center pt-2",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"Two quick steps ahead: git identity + optional agent connections"})})]});case 1:return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"w-16 h-16 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(G,{className:"w-8 h-8 text-blue-600 dark:text-blue-400"})}),e.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Git Configuration"}),e.jsx("p",{className:"text-muted-foreground",children:"Configure your git identity to ensure proper attribution for your commits"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"gitName",className:"flex items-center gap-2 text-sm font-medium text-foreground mb-2",children:[e.jsx(te,{className:"w-4 h-4"}),"Git Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",id:"gitName",value:h,onChange:t=>C(t.target.value),className:"w-full px-4 py-3 border border-border rounded-lg bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"John Doe",required:!0,disabled:i}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This will be used as: git config --global user.name"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"gitEmail",className:"flex items-center gap-2 text-sm font-medium text-foreground mb-2",children:[e.jsx(se,{className:"w-4 h-4"}),"Git Email ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"email",id:"gitEmail",value:u,onChange:t=>k(t.target.value),className:"w-full px-4 py-3 border border-border rounded-lg bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"john@example.com",required:!0,disabled:i}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This will be used as: git config --global user.email"})]})]})]});case 2:return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Connect Your AI Agents"}),e.jsx("p",{className:"text-muted-foreground",children:"Login to one or more AI coding assistants. All are optional."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:`border rounded-lg p-4 transition-colors ${l.authenticated?"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800":"border-border bg-card"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center",children:e.jsx(_,{size:20})}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["Claude Code",l.authenticated&&e.jsx(x,{className:"w-4 h-4 text-green-500"})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l.loading?"Checking...":l.authenticated?l.email||"Connected":"Not connected"})]})]}),!l.authenticated&&!l.loading&&e.jsx("button",{onClick:M,className:"bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium py-2 px-4 rounded-lg transition-colors",children:"Login"})]})}),e.jsx("div",{className:`border rounded-lg p-4 transition-colors ${d.authenticated?"bg-purple-50 dark:bg-purple-900/20 border-purple-200 dark:border-purple-800":"border-border bg-card"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/30 rounded-full flex items-center justify-center",children:e.jsx(D,{size:20})}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["Cursor",d.authenticated&&e.jsx(x,{className:"w-4 h-4 text-green-500"})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:d.loading?"Checking...":d.authenticated?d.email||"Connected":"Not connected"})]})]}),!d.authenticated&&!d.loading&&e.jsx("button",{onClick:T,className:"bg-purple-600 hover:bg-purple-700 text-white text-sm font-medium py-2 px-4 rounded-lg transition-colors",children:"Login"})]})}),e.jsx("div",{className:`border rounded-lg p-4 transition-colors ${c.authenticated?"bg-gray-100 dark:bg-gray-800/50 border-gray-300 dark:border-gray-600":"border-border bg-card"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx(H,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["OpenAI Codex",c.authenticated&&e.jsx(x,{className:"w-4 h-4 text-green-500"})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:c.loading?"Checking...":c.authenticated?c.email||"Connected":"Not connected"})]})]}),!c.authenticated&&!c.loading&&e.jsx("button",{onClick:O,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white text-sm font-medium py-2 px-4 rounded-lg transition-colors",children:"Login"})]})})]}),e.jsx("div",{className:"text-center text-sm text-muted-foreground pt-2",children:e.jsx("p",{children:"You can configure these later in Settings."})})]});default:return null}},V=()=>{switch(r){case 0:return!0;case 1:return h.trim()&&u.trim()&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u);case 2:return!0;default:return!1}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-2xl",children:[e.jsx("div",{className:"mb-8",children:e.jsx("div",{className:"flex items-center justify-between",children:w.map((t,s)=>e.jsxs(W.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center flex-1",children:[e.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center border-2 transition-colors duration-200 ${s<r?"bg-green-500 border-green-500 text-white":s===r?"bg-blue-600 border-blue-600 text-white":"bg-background border-border text-muted-foreground"}`,children:s<r?e.jsx(x,{className:"w-6 h-6"}):typeof t.icon=="function"?e.jsx(t.icon,{}):e.jsx(t.icon,{className:"w-6 h-6"})}),e.jsxs("div",{className:"mt-2 text-center",children:[e.jsx("p",{className:`text-sm font-medium ${s===r?"text-foreground":"text-muted-foreground"}`,children:t.title}),t.required&&e.jsx("span",{className:"text-xs text-red-500",children:"Required"})]})]}),s<w.length-1&&e.jsx("div",{className:`flex-1 h-0.5 mx-2 transition-colors duration-200 ${s<r?"bg-green-500":"bg-border"}`})]},s))})}),e.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8",children:[J(),S&&e.jsx("div",{className:"mt-6 p-4 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-lg",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:S})}),e.jsxs("div",{className:"flex items-center justify-between mt-8 pt-6 border-t border-border",children:[e.jsxs("button",{onClick:Y,disabled:r===0||i,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",children:[e.jsx(X,{className:"w-4 h-4"}),"Previous"]}),e.jsx("div",{className:"flex items-center gap-3",children:r<w.length-1?e.jsx("button",{onClick:B,disabled:!V()||i,className:"flex items-center gap-2 px-6 py-3 bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors duration-200",children:i?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:["Next",e.jsx(ee,{className:"w-4 h-4"})]})}):e.jsx("button",{onClick:z,disabled:i,className:"flex items-center gap-2 px-6 py-3 bg-green-600 hover:bg-green-700 disabled:bg-green-400 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors duration-200",children:i?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 animate-spin"}),"Completing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{className:"w-4 h-4"}),"Complete Setup"]})})})]})]})]})}),n&&e.jsx(Z,{isOpen:!!n,onClose:()=>b(null),provider:n,project:q,onComplete:U,isOnboarding:!0})]})};export{ge as default};
@@ -1 +0,0 @@
1
- import{r as t,j as e}from"./vendor-react-9mUTKBHH.js";import{u as y}from"./index-ce18TYkg.js";import"./vendor-syntax-DnmwQQJF.js";import"./vendor-markdown-BXEi_H3G.js";import"./vendor-icons-Lb69KSFJ.js";import"./vendor-i18n-DCFGyhQR.js";const q=()=>{const[a,f]=t.useState(""),[d,p]=t.useState(""),[l,x]=t.useState(""),[n,g]=t.useState(""),[u,h]=t.useState(""),[s,i]=t.useState(!1),[c,o]=t.useState(""),{register:j}=y(),N=async r=>{if(r.preventDefault(),o(""),n!==u){o("Passwords do not match");return}if(!a.trim()||a.trim().length<2){o("Name must be at least 2 characters");return}if(!d.trim()||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d)){o("Please enter a valid email address");return}if(n.length<6){o("Password must be at least 6 characters");return}i(!0);const m=a.trim().split(" "),w=m[0]||a.trim(),v=m.slice(1).join(" ")||"",b=await j(w,v,n,d.trim(),l.trim()||null);b.success||o(b.error),i(!1)};return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("img",{src:"/logo.svg",alt:"Upfyn-Code",className:"w-16 h-16",onError:r=>{r.target.style.display="none"}})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Create Your Account"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Sign up to start using Upfyn-Code"})]}),e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-foreground mb-1",children:"Full Name"}),e.jsx("input",{type:"text",id:"name",value:a,onChange:r=>f(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Your full name",required:!0,disabled:s})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-foreground mb-1",children:"Email"}),e.jsx("input",{type:"email",id:"email",value:d,onChange:r=>p(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"you@example.com",required:!0,disabled:s})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"phone",className:"block text-sm font-medium text-foreground mb-1",children:"Mobile Number"}),e.jsx("input",{type:"tel",id:"phone",value:l,onChange:r=>x(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"+91 9876543210",disabled:s})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:"Password"}),e.jsx("input",{type:"password",id:"password",value:n,onChange:r=>g(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"At least 6 characters",required:!0,disabled:s})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirmPassword",className:"block text-sm font-medium text-foreground mb-1",children:"Confirm Password"}),e.jsx("input",{type:"password",id:"confirmPassword",value:u,onChange:r=>h(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Confirm your password",required:!0,disabled:s})]}),c&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:c})}),e.jsx("button",{type:"submit",disabled:s,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:s?"Creating account...":"Create Account"})]})]})})})};export{q as default};
@@ -1 +0,0 @@
1
- function o(e){for(var c=e.length/6|0,n=new Array(c),a=0;a<c;)n[a]="#"+e.slice(a*6,++a*6);return n}const r=o("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab");export{r as s};
@@ -1 +0,0 @@
1
- import{r as s,j as e,v as ee}from"./vendor-react-9mUTKBHH.js";import{a as C}from"./index-ce18TYkg.js";import{P as A,Z as M,h as te,b as Z,i as V,H as K,j as X,k as G,l as z,m as J,n as B,g as se,G as re,o as oe,S as ae,p as ne,q as le,r as Y,X as de,C as ce,s as ie}from"./vendor-icons-Lb69KSFJ.js";import"./vendor-syntax-DnmwQQJF.js";import"./vendor-markdown-BXEi_H3G.js";import"./vendor-i18n-DCFGyhQR.js";function ue({onEdit:a,onCreate:E,refreshKey:y}){const[f,T]=s.useState([]),[k,j]=s.useState(!0),[x,b]=s.useState(null),[m,N]=s.useState(null),[d,S]=s.useState(null),[p,L]=s.useState([]),[D,W]=s.useState(!1),w=s.useCallback(async()=>{try{const o=await C("/api/workflows");if(o.ok){const r=await o.json();T(r.workflows||[])}}catch{}j(!1)},[]);s.useEffect(()=>{w()},[w,y]);const P=async o=>{if(d===o){S(null);return}S(o),W(!0);try{const r=await C(`/api/workflows/${o}/runs`);if(r.ok){const g=await r.json();L(g.runs||[])}}catch{L([])}W(!1)},$=async o=>{try{await C(`/api/workflows/${o}`,{method:"DELETE"}),w()}catch{}},v=async o=>{var r;b(o),N(null);try{const u=await(await C(`/api/workflows/${o}/run`,{method:"POST"})).json();N({id:o,success:u.success,message:u.success?`Completed ${((r=u.results)==null?void 0:r.length)||0} steps`:u.error||"Failed",results:u.results}),w()}catch{N({id:o,success:!1,message:"Network error"})}b(null)};return k?e.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"Loading workflows..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Workflows"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Natural language automation with webhook integrations"})]}),e.jsxs("button",{onClick:E,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors",children:[e.jsx(A,{className:"w-3.5 h-3.5"}),"New Workflow"]})]}),f.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-14 h-14 mx-auto mb-4 bg-muted/50 rounded-full flex items-center justify-center",children:e.jsx(M,{className:"w-7 h-7 text-muted-foreground/40"})}),e.jsx("h4",{className:"text-sm font-medium text-foreground mb-1",children:"No workflows yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/60 max-w-xs mx-auto",children:"Create a workflow to automate tasks. Chain AI prompts, webhook calls, and conditions together."}),e.jsxs("button",{onClick:E,className:"mt-4 flex items-center gap-1.5 px-4 py-2 text-xs font-medium bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors mx-auto",children:[e.jsx(A,{className:"w-3.5 h-3.5"}),"Create Your First Workflow"]})]}):e.jsx("div",{className:"space-y-2",children:f.map(o=>e.jsxs("div",{className:"bg-muted/20 border border-border/30 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground",children:o.name}),o.description&&e.jsx("p",{className:"text-xs text-muted-foreground/70 mt-0.5",children:o.description}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 flex-wrap",children:[o.steps.map((r,g)=>e.jsxs(ee.Fragment,{children:[e.jsx("span",{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded ${r.type==="ai-prompt"?"bg-blue-500/10 text-blue-400":r.type==="webhook"?"bg-yellow-500/10 text-yellow-400":r.type==="delay"?"bg-purple-500/10 text-purple-400":"bg-green-500/10 text-green-400"}`,children:r.label}),g<o.steps.length-1&&e.jsx("span",{className:"text-[10px] text-muted-foreground/30",children:"→"})]},r.id||g)),o.steps.length===0&&e.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:"No steps"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px] text-muted-foreground/40 flex-wrap",children:[e.jsxs("span",{children:[o.steps.length," step",o.steps.length!==1?"s":""]}),o.schedule&&o.schedule_enabled?e.jsxs("span",{className:"flex items-center gap-1 text-primary/70",children:[e.jsx(te,{className:"w-2.5 h-2.5"}),o.schedule]}):null,o.last_run&&e.jsxs("span",{children:["Last run: ",new Date(o.last_run).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs("button",{onClick:()=>v(o.id),disabled:x===o.id||o.steps.length===0,className:"flex items-center gap-1 px-2.5 py-1.5 text-xs font-medium bg-green-500/10 text-green-400 hover:bg-green-500/20 rounded-lg transition-colors disabled:opacity-40",title:"Run workflow",children:[x===o.id?e.jsx(Z,{className:"w-3 h-3 animate-spin"}):e.jsx(V,{className:"w-3 h-3"}),"Run"]}),e.jsx("button",{onClick:()=>P(o.id),className:`p-1.5 transition-colors ${d===o.id?"text-primary":"text-muted-foreground hover:text-foreground"}`,title:"Execution history",children:e.jsx(K,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>a(o),className:"p-1.5 text-muted-foreground hover:text-foreground transition-colors",title:"Edit",children:e.jsx(X,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>$(o.id),className:"p-1.5 text-muted-foreground hover:text-red-400 transition-colors",title:"Delete",children:e.jsx(G,{className:"w-3.5 h-3.5"})})]})]}),(m==null?void 0:m.id)===o.id&&e.jsxs("div",{className:`mt-3 p-2.5 rounded-lg text-xs ${m.success?"bg-green-500/5 border border-green-500/20":"bg-red-500/5 border border-red-500/20"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[m.success?e.jsx(z,{className:"w-3.5 h-3.5 text-green-400"}):e.jsx(J,{className:"w-3.5 h-3.5 text-red-400"}),e.jsx("span",{className:m.success?"text-green-400":"text-red-400",children:m.message})]}),m.results&&e.jsx("div",{className:"space-y-1 mt-2",children:m.results.map((r,g)=>{var u;return e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[r.success?e.jsx(z,{className:"w-2.5 h-2.5 text-green-400/60"}):e.jsx(J,{className:"w-2.5 h-2.5 text-red-400/60"}),e.jsx("span",{className:"text-muted-foreground",children:r.label}),((u=r.result)==null?void 0:u.status)&&e.jsxs("span",{className:"text-muted-foreground/40",children:["(",r.result.status,")"]}),r.error&&e.jsx("span",{className:"text-red-400/60",children:r.error})]},g)})})]}),d===o.id&&e.jsxs("div",{className:"mt-3 border-t border-border/20 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(K,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-[11px] font-medium text-foreground",children:"Execution History"})]}),D?e.jsx("div",{className:"text-[10px] text-muted-foreground/50 py-2",children:"Loading..."}):p.length===0?e.jsx("div",{className:"text-[10px] text-muted-foreground/40 py-2",children:"No runs yet"}):e.jsx("div",{className:"space-y-1.5 max-h-48 overflow-y-auto",children:p.map(r=>e.jsxs("div",{className:"flex items-start gap-2 text-[10px] bg-muted/10 rounded-lg p-2",children:[e.jsx("div",{className:"shrink-0 mt-0.5",children:r.status==="completed"?e.jsx(z,{className:"w-3 h-3 text-green-400"}):r.status==="failed"?e.jsx(J,{className:"w-3 h-3 text-red-400"}):r.status==="running"?e.jsx(Z,{className:"w-3 h-3 text-yellow-400 animate-spin"}):e.jsx(B,{className:"w-3 h-3 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium ${r.status==="completed"?"text-green-400":r.status==="failed"?"text-red-400":"text-muted-foreground"}`,children:r.status==="completed"?"Success":r.status==="failed"?"Failed":r.status}),e.jsxs("span",{className:"text-muted-foreground/30",children:[r.steps_completed,"/",r.total_steps," steps"]}),e.jsx("span",{className:"text-muted-foreground/30",children:new Date(r.started_at).toLocaleString()})]}),r.error&&e.jsx("p",{className:"text-red-400/70 mt-0.5 truncate",children:r.error}),r.completed_at&&e.jsxs("span",{className:"text-muted-foreground/20",children:["Duration: ",Math.round((new Date(r.completed_at).getTime()-new Date(r.started_at).getTime())/1e3),"s"]})]})]},r.id))})]})]},o.id))})]})}const q=[{value:"ai-prompt",label:"AI Prompt",icon:se,color:"text-blue-400 bg-blue-500/10"},{value:"webhook",label:"Webhook",icon:M,color:"text-yellow-400 bg-yellow-500/10"},{value:"delay",label:"Delay",icon:B,color:"text-purple-400 bg-purple-500/10"},{value:"condition",label:"Condition",icon:re,color:"text-green-400 bg-green-500/10"}];let xe=0;const me=()=>`step_${Date.now()}_${++xe}`,he=[{label:"Every minute",cron:"* * * * *"},{label:"Every 5 minutes",cron:"*/5 * * * *"},{label:"Every 15 minutes",cron:"*/15 * * * *"},{label:"Every hour",cron:"0 * * * *"},{label:"Every 6 hours",cron:"0 */6 * * *"},{label:"Daily at midnight",cron:"0 0 * * *"},{label:"Daily at 9 AM",cron:"0 9 * * *"},{label:"Weekly (Monday)",cron:"0 9 * * 1"},{label:"Monthly (1st)",cron:"0 0 1 * *"}];function pe({workflow:a,onSave:E,onCancel:y}){const[f,T]=s.useState((a==null?void 0:a.name)||""),[k,j]=s.useState((a==null?void 0:a.description)||""),[x,b]=s.useState((a==null?void 0:a.steps)||[]),[m,N]=s.useState((a==null?void 0:a.schedule)||""),[d,S]=s.useState(!!(a!=null&&a.schedule_enabled)),[p,L]=s.useState((a==null?void 0:a.schedule_timezone)||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"),[D,W]=s.useState([]),[w,P]=s.useState(!1),[$,v]=s.useState(""),[o,r]=s.useState(null),[g,u]=s.useState(!1);s.useEffect(()=>{C("/api/webhooks").then(t=>t.json()).then(t=>{W(t.webhooks||[])}).catch(()=>{})},[]);const F=s.useCallback(t=>{const i=q.find(c=>c.value===t),n={id:me(),type:t,label:(i==null?void 0:i.label)||t,config:t==="delay"?{seconds:5}:{},order:x.length};b(c=>[...c,n]),r(n.id),u(!1)},[x.length]),_=s.useCallback(t=>{b(i=>i.filter(n=>n.id!==t).map((n,c)=>({...n,order:c}))),o===t&&r(null)},[o]),O=s.useCallback((t,i)=>{b(n=>{const c=n.findIndex(H=>H.id===t);if(c<0)return n;const h=i==="up"?c-1:c+1;if(h<0||h>=n.length)return n;const l=[...n];return[l[c],l[h]]=[l[h],l[c]],l.map((H,Q)=>({...H,order:Q}))})},[]),I=s.useCallback((t,i,n)=>{b(c=>c.map(h=>h.id===t?{...h,config:{...h.config,[i]:n}}:h))},[]),R=s.useCallback((t,i)=>{b(n=>n.map(c=>c.id===t?{...c,label:i}:c))},[]),U=async()=>{if(v(""),!f.trim()){v("Workflow name is required");return}if(x.length===0){v("Add at least one step");return}P(!0);try{const t={name:f,description:k,steps:x,schedule:m||null,schedule_enabled:d,schedule_timezone:p},i=a!=null&&a.id?`/api/workflows/${a.id}`:"/api/workflows",n=a!=null&&a.id?"PUT":"POST",c=await C(i,{method:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!c.ok){const h=await c.json();v(h.error||"Failed to save"),P(!1);return}E()}catch{v("Network error")}P(!1)};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/30",children:[e.jsx("button",{onClick:y,className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(oe,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-sm font-semibold text-foreground",children:a!=null&&a.id?"Edit Workflow":"New Workflow"}),e.jsx("div",{className:"flex-1"}),e.jsxs("button",{onClick:U,disabled:w,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors disabled:opacity-50",children:[e.jsx(ae,{className:"w-3.5 h-3.5"}),w?"Saving...":"Save"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-muted-foreground mb-1 block",children:"Workflow Name"}),e.jsx("input",{value:f,onChange:t=>T(t.target.value),placeholder:"My Workflow",className:"w-full px-3 py-2 text-sm bg-background border border-border/50 rounded-lg text-foreground placeholder-muted-foreground/50 focus:outline-none focus:border-primary/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-muted-foreground mb-1 block",children:"Description"}),e.jsx("textarea",{value:k,onChange:t=>j(t.target.value),placeholder:"What does this workflow do?",rows:2,className:"w-full px-3 py-2 text-xs bg-background border border-border/50 rounded-lg text-foreground placeholder-muted-foreground/50 focus:outline-none focus:border-primary/50 resize-none"})]})]}),e.jsxs("div",{className:"bg-muted/20 border border-border/30 rounded-xl p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-semibold text-foreground flex items-center gap-1.5",children:[e.jsx(B,{className:"w-3.5 h-3.5"}),"Schedule (Cron Job)"]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:d?"Enabled":"Disabled"}),e.jsx("div",{onClick:()=>S(!d),className:`relative w-8 h-4 rounded-full transition-colors cursor-pointer ${d?"bg-primary":"bg-muted"}`,children:e.jsx("div",{className:`absolute top-0.5 w-3 h-3 rounded-full bg-white transition-transform ${d?"translate-x-4":"translate-x-0.5"}`})})]})]}),d&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-muted-foreground mb-0.5 block",children:"Cron Expression"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:m,onChange:t=>N(t.target.value),placeholder:"*/15 * * * *",className:"flex-1 px-2 py-1 text-xs bg-background border border-border/50 rounded text-foreground placeholder-muted-foreground/50 focus:outline-none focus:border-primary/50 font-mono"}),e.jsxs("select",{value:m,onChange:t=>N(t.target.value),className:"px-2 py-1 text-xs bg-background border border-border/50 rounded text-foreground focus:outline-none focus:border-primary/50",children:[e.jsx("option",{value:"",children:"Presets..."}),he.map(t=>e.jsx("option",{value:t.cron,children:t.label},t.cron))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-muted-foreground mb-0.5 block",children:"Timezone"}),e.jsx("input",{value:p,onChange:t=>L(t.target.value),placeholder:"UTC",className:"w-48 px-2 py-1 text-xs bg-background border border-border/50 rounded text-foreground placeholder-muted-foreground/50 focus:outline-none focus:border-primary/50"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground/50",children:'Runs automatically when the server is online. Missed runs while offline appear as "missed" in execution history.'})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("span",{className:"text-xs font-semibold text-foreground",children:["Steps (",x.length,")"]})}),x.length===0?e.jsx("div",{className:"text-center py-8 border border-dashed border-border/40 rounded-xl",children:e.jsx("p",{className:"text-xs text-muted-foreground/60",children:"No steps yet. Add your first step below."})}):e.jsx("div",{className:"space-y-2",children:x.map((t,i)=>{const n=q.find(l=>l.value===t.type),c=(n==null?void 0:n.icon)||M,h=o===t.id;return e.jsxs("div",{className:"bg-muted/20 border border-border/30 rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-muted/30 transition-colors",onClick:()=>r(h?null:t.id),children:[e.jsx("span",{className:"text-xs text-muted-foreground/50 w-5 text-center font-mono",children:i+1}),e.jsx("div",{className:`p-1 rounded ${(n==null?void 0:n.color)||"bg-muted text-muted-foreground"}`,children:e.jsx(c,{className:"w-3 h-3"})}),e.jsx("span",{className:"text-xs font-medium text-foreground flex-1 min-w-0 truncate",children:t.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground/50",children:n==null?void 0:n.label}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{onClick:l=>{l.stopPropagation(),O(t.id,"up")},disabled:i===0,className:"p-0.5 text-muted-foreground/40 hover:text-foreground disabled:opacity-20",children:e.jsx(ne,{className:"w-3 h-3"})}),e.jsx("button",{onClick:l=>{l.stopPropagation(),O(t.id,"down")},disabled:i===x.length-1,className:"p-0.5 text-muted-foreground/40 hover:text-foreground disabled:opacity-20",children:e.jsx(le,{className:"w-3 h-3"})}),e.jsx("button",{onClick:l=>{l.stopPropagation(),_(t.id)},className:"p-0.5 text-muted-foreground/40 hover:text-red-400",children:e.jsx(G,{className:"w-3 h-3"})})]})]}),h&&e.jsxs("div",{className:"px-3 pb-3 pt-1 border-t border-border/20 space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-muted-foreground mb-0.5 block",children:"Step Label"}),e.jsx("input",{value:t.label,onChange:l=>R(t.id,l.target.value),className:"w-full px-2 py-1 text-xs bg-background border border-border/50 rounded text-foreground focus:outline-none focus:border-primary/50"})]}),t.type==="ai-prompt"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-muted-foreground mb-0.5 block",children:"Prompt"}),e.jsx("textarea",{value:t.config.prompt||"",onChange:l=>I(t.id,"prompt",l.target.value),placeholder:"Describe what the AI should do...",rows:3,className:"w-full px-2 py-1 text-xs bg-background border border-border/50 rounded text-foreground placeholder-muted-foreground/50 focus:outline-none focus:border-primary/50 resize-none"})]}),t.type==="webhook"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-muted-foreground mb-0.5 block",children:"Webhook"}),e.jsxs("select",{value:t.config.webhookId||"",onChange:l=>I(t.id,"webhookId",l.target.value),className:"w-full px-2 py-1 text-xs bg-background border border-border/50 rounded text-foreground focus:outline-none focus:border-primary/50",children:[e.jsx("option",{value:"",children:"Select a webhook..."}),D.map(l=>e.jsxs("option",{value:l.id,children:[l.name," (",l.method," ",l.url,")"]},l.id))]}),D.length===0&&e.jsx("p",{className:"text-[10px] text-muted-foreground/50 mt-1",children:"No webhooks created yet. Go to the Webhooks tab to create one."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-muted-foreground mb-0.5 block",children:"Payload Template (JSON, optional)"}),e.jsx("textarea",{value:t.config.payloadTemplate||"",onChange:l=>I(t.id,"payloadTemplate",l.target.value),placeholder:'{"key": "value"}',rows:2,className:"w-full px-2 py-1 text-xs bg-background border border-border/50 rounded text-foreground placeholder-muted-foreground/50 focus:outline-none focus:border-primary/50 resize-none font-mono"})]})]}),t.type==="delay"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-muted-foreground mb-0.5 block",children:"Delay (seconds, max 30)"}),e.jsx("input",{type:"number",min:1,max:30,value:t.config.seconds||5,onChange:l=>I(t.id,"seconds",Math.min(30,Math.max(1,parseInt(l.target.value)||1))),className:"w-24 px-2 py-1 text-xs bg-background border border-border/50 rounded text-foreground focus:outline-none focus:border-primary/50"})]}),t.type==="condition"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-muted-foreground mb-0.5 block",children:"Condition Expression"}),e.jsx("input",{value:t.config.expression||"",onChange:l=>I(t.id,"expression",l.target.value),placeholder:"e.g. response.status === 200",className:"w-full px-2 py-1 text-xs bg-background border border-border/50 rounded text-foreground placeholder-muted-foreground/50 focus:outline-none focus:border-primary/50 font-mono"}),e.jsx("p",{className:"text-[10px] text-muted-foreground/40 mt-0.5",children:"Condition evaluation coming soon"})]})]})]},t.id)})}),e.jsxs("div",{className:"relative mt-3",children:[e.jsxs("button",{onClick:()=>u(!g),className:"w-full flex items-center justify-center gap-1.5 py-2 text-xs text-muted-foreground hover:text-foreground border border-dashed border-border/40 hover:border-border/60 rounded-xl transition-colors",children:[e.jsx(A,{className:"w-3.5 h-3.5"}),"Add Step"]}),g&&e.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 bottom-full mb-1 z-10 bg-card border border-border/50 rounded-xl shadow-xl p-1.5 min-w-[180px]",children:q.map(t=>{const i=t.icon;return e.jsxs("button",{onClick:()=>F(t.value),className:"w-full text-left px-3 py-1.5 text-xs text-foreground hover:bg-muted/50 rounded-lg flex items-center gap-2",children:[e.jsx("div",{className:`p-1 rounded ${t.color}`,children:e.jsx(i,{className:"w-3 h-3"})}),t.label]},t.value)})})]})]}),$&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-400",children:[e.jsx(Y,{className:"w-3.5 h-3.5"}),$]})]})]})}const be=["GET","POST","PUT","PATCH","DELETE"];function ge({onWebhooksChange:a}){const[E,y]=s.useState([]),[f,T]=s.useState(!0),[k,j]=s.useState(!1),[x,b]=s.useState(null),[m,N]=s.useState(null),[d,S]=s.useState(null),[p,L]=s.useState(""),[D,W]=s.useState(""),[w,P]=s.useState("POST"),[$,v]=s.useState("{}"),[o,r]=s.useState(""),[g,u]=s.useState(""),F=s.useCallback(async()=>{try{const t=await C("/api/webhooks");if(t.ok){const i=await t.json();y(i.webhooks||[])}}catch{}T(!1)},[]);s.useEffect(()=>{F()},[F]);const _=()=>{L(""),W(""),P("POST"),v("{}"),r(""),u(""),b(null),j(!1)},O=t=>{L(t.name),W(t.url),P(t.method),v(t.headers||"{}"),r(t.description||""),b(t.id),j(!0),u("")},I=async()=>{if(u(""),!p.trim()){u("Name is required");return}if(!D.trim()){u("URL is required");return}try{new URL(D)}catch{u("Invalid URL");return}try{JSON.parse($)}catch{u("Headers must be valid JSON");return}try{const t={name:p,url:D,method:w,headers:$,description:o},i=x?`/api/webhooks/${x}`:"/api/webhooks",c=await C(i,{method:x?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!c.ok){const h=await c.json();u(h.error||"Failed to save");return}_(),F(),a==null||a()}catch{u("Network error")}},R=async t=>{try{await C(`/api/webhooks/${t}`,{method:"DELETE"}),F(),a==null||a()}catch{}},U=async t=>{N(t),S(null);try{const n=await(await C(`/api/webhooks/${t}/test`,{method:"POST"})).json();S({id:t,result:n.result,success:n.success})}catch{S({id:t,result:{error:"Network error"},success:!1})}N(null)};return f?e.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"Loading webhooks..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Webhooks"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Endpoints that workflows can call during execution"})]}),!k&&e.jsxs("button",{onClick:()=>{_(),j(!0)},className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors",children:[e.jsx(A,{className:"w-3.5 h-3.5"}),"Add Webhook"]})]}),k&&e.jsxs("div",{className:"bg-muted/30 border border-border/50 rounded-xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-foreground",children:x?"Edit Webhook":"New Webhook"}),e.jsx("button",{onClick:_,className:"text-muted-foreground hover:text-foreground",children:e.jsx(de,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-muted-foreground mb-1 block",children:"Name"}),e.jsx("input",{value:p,onChange:t=>L(t.target.value),placeholder:"My Webhook",className:"w-full px-3 py-1.5 text-xs bg-background border border-border/50 rounded-lg text-foreground placeholder-muted-foreground/50 focus:outline-none focus:border-primary/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-muted-foreground mb-1 block",children:"Method"}),e.jsx("select",{value:w,onChange:t=>P(t.target.value),className:"w-full px-3 py-1.5 text-xs bg-background border border-border/50 rounded-lg text-foreground focus:outline-none focus:border-primary/50",children:be.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-muted-foreground mb-1 block",children:"URL"}),e.jsx("input",{value:D,onChange:t=>W(t.target.value),placeholder:"https://example.com/webhook",className:"w-full px-3 py-1.5 text-xs bg-background border border-border/50 rounded-lg text-foreground placeholder-muted-foreground/50 focus:outline-none focus:border-primary/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-muted-foreground mb-1 block",children:"Headers (JSON)"}),e.jsx("textarea",{value:$,onChange:t=>v(t.target.value),placeholder:'{"Authorization": "Bearer ..."}',rows:2,className:"w-full px-3 py-1.5 text-xs bg-background border border-border/50 rounded-lg text-foreground placeholder-muted-foreground/50 focus:outline-none focus:border-primary/50 font-mono resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-muted-foreground mb-1 block",children:"Description"}),e.jsx("input",{value:o,onChange:t=>r(t.target.value),placeholder:"Optional description...",className:"w-full px-3 py-1.5 text-xs bg-background border border-border/50 rounded-lg text-foreground placeholder-muted-foreground/50 focus:outline-none focus:border-primary/50"})]}),g&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-400",children:[e.jsx(Y,{className:"w-3.5 h-3.5"}),g]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:_,className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:I,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors",children:[e.jsx(ce,{className:"w-3.5 h-3.5"}),x?"Update":"Create"]})]})]}),E.length===0&&!k?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 bg-muted/50 rounded-full flex items-center justify-center",children:e.jsx(M,{className:"w-6 h-6 text-muted-foreground/50"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No webhooks yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1",children:"Create a webhook to use in your workflows"})]}):e.jsx("div",{className:"space-y-2",children:E.map(t=>e.jsxs("div",{className:"bg-muted/20 border border-border/30 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-foreground",children:t.name}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-mono ${t.method==="GET"?"bg-green-500/10 text-green-400":t.method==="POST"?"bg-blue-500/10 text-blue-400":t.method==="PUT"?"bg-yellow-500/10 text-yellow-400":t.method==="DELETE"?"bg-red-500/10 text-red-400":"bg-muted text-muted-foreground"}`,children:t.method})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground font-mono mt-0.5 truncate",children:t.url}),t.description&&e.jsx("p",{className:"text-[11px] text-muted-foreground/60 mt-0.5",children:t.description}),t.last_triggered&&e.jsxs("p",{className:"text-[10px] text-muted-foreground/40 mt-1",children:["Last triggered: ",new Date(t.last_triggered).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>U(t.id),disabled:m===t.id,className:"p-1.5 text-muted-foreground hover:text-green-400 transition-colors disabled:opacity-50",title:"Test webhook",children:m===t.id?e.jsx("div",{className:"w-3.5 h-3.5 border-2 border-muted-foreground/30 border-t-muted-foreground rounded-full animate-spin"}):e.jsx(V,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>O(t),className:"p-1.5 text-muted-foreground hover:text-foreground transition-colors",title:"Edit",children:e.jsx(X,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>R(t.id),className:"p-1.5 text-muted-foreground hover:text-red-400 transition-colors",title:"Delete",children:e.jsx(G,{className:"w-3.5 h-3.5"})})]})]}),(d==null?void 0:d.id)===t.id&&e.jsx("div",{className:`mt-2 p-2 rounded-lg text-xs ${d.success?"bg-green-500/5 border border-green-500/20":"bg-red-500/5 border border-red-500/20"}`,children:d.result.error?e.jsx("span",{className:"text-red-400",children:d.result.error}):e.jsxs("div",{children:[e.jsxs("span",{className:d.result.status&&d.result.status<400?"text-green-400":"text-red-400",children:[d.result.status," ",d.result.statusText]}),d.result.body&&e.jsx("pre",{className:"mt-1 text-[10px] text-muted-foreground font-mono overflow-x-auto max-h-24 overflow-y-auto",children:typeof d.result.body=="string"?d.result.body:JSON.stringify(d.result.body,null,2)})]})})]},t.id))})]})}function Se({selectedProject:a}){const[E,y]=s.useState("list"),[f,T]=s.useState("workflows"),[k,j]=s.useState(null),[x,b]=s.useState(0),m=s.useCallback(p=>{j(p),y("editor")},[]),N=s.useCallback(()=>{j(null),y("editor")},[]),d=s.useCallback(()=>{y("list"),T("workflows"),j(null),b(p=>p+1)},[]),S=s.useCallback(()=>{y("list"),j(null)},[]);return E==="editor"?e.jsx("div",{className:"h-full",children:e.jsx(pe,{workflow:k,onSave:d,onCancel:S})}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex-shrink-0 px-4 pt-3 pb-0",children:e.jsxs("div",{className:"inline-flex items-center bg-muted/40 rounded-lg p-[3px] gap-[2px]",children:[e.jsxs("button",{onClick:()=>T("workflows"),className:`flex items-center gap-1.5 px-3 py-[5px] text-xs font-medium rounded-md transition-all duration-150 ${f==="workflows"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(M,{className:"w-3 h-3"}),"Workflows"]}),e.jsxs("button",{onClick:()=>T("webhooks"),className:`flex items-center gap-1.5 px-3 py-[5px] text-xs font-medium rounded-md transition-all duration-150 ${f==="webhooks"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ie,{className:"w-3 h-3"}),"Webhooks"]})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:f==="workflows"?e.jsx(ue,{onEdit:m,onCreate:N,refreshKey:x}):e.jsx(ge,{onWebhooksChange:()=>b(p=>p+1)})})]})}export{Se as default};
@@ -1 +0,0 @@
1
- function r(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}export{r as c};