upfynai-code 3.0.4 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/README.md +66 -91
  2. package/bin/cli.js +191 -0
  3. package/{client/dist/assets/AppContent-CwrTP6TW.js → dist/client/assets/AppContent-BofJquUs.js} +4 -4
  4. package/{client/dist/assets/BrowserPanel-0TLEl-IC.js → dist/client/assets/BrowserPanel-CSvD4jOX.js} +2 -2
  5. package/dist/client/assets/CanvasFullScreen-onRfarpc.js +1 -0
  6. package/dist/client/assets/CanvasWorkspace-DvGKdL-k.js +259 -0
  7. package/dist/client/assets/DashboardPanel-DqAHbXDO.js +1 -0
  8. package/dist/client/assets/FileTree-BE0h-9M9.js +1 -0
  9. package/{client/dist/assets/GitPanel-C_xFM-N2.js → dist/client/assets/GitPanel-DdeJ0bp5.js} +2 -2
  10. package/{client/dist/assets/LoginModal-CImJHRjX.js → dist/client/assets/LoginModal-BP0pCTrH.js} +3 -3
  11. package/dist/client/assets/MermaidBlock-D0rfEhrT.js +2 -0
  12. package/dist/client/assets/Onboarding-B2zQy-_6.js +1 -0
  13. package/dist/client/assets/SetupForm-Be7-WBe-.js +1 -0
  14. package/dist/client/assets/WorkflowsPanel-CusLbVJ6.js +1 -0
  15. package/{client/dist/assets/index-HaY-3pK1.js → dist/client/assets/index-BQy15irW.js} +24 -24
  16. package/dist/client/assets/index-CS0fDqEC.js +1 -0
  17. package/dist/client/assets/index-DYLSCCCp.css +1 -0
  18. package/dist/client/assets/vendor-canvas-QWTduIvM.js +23 -0
  19. package/{client/dist/assets/vendor-icons-GyYE35HP.js → dist/client/assets/vendor-icons-kix3Gb31.js} +1 -1
  20. package/{client/dist/assets/vendor-mermaid-DucWyDEe.js → dist/client/assets/vendor-mermaid-CS3J4_Bz.js} +329 -326
  21. package/dist/client/favicon.png +0 -0
  22. package/dist/client/favicon.svg +15 -0
  23. package/{client/dist → dist/client}/index.html +3 -3
  24. package/{client/dist → dist/client}/manifest.json +12 -12
  25. package/package.json +55 -104
  26. package/scripts/postinstall.js +9 -0
  27. package/scripts/prepublish.js +77 -0
  28. package/src/animation.js +228 -0
  29. package/src/auth.js +142 -0
  30. package/src/config.js +40 -0
  31. package/src/connect.js +416 -0
  32. package/src/launch.js +81 -0
  33. package/src/mcp.js +57 -0
  34. package/src/permissions.js +140 -0
  35. package/src/persistent-shell.js +261 -0
  36. package/src/server.js +54 -0
  37. package/client/dist/assets/CanvasFullScreen-D1GWQsGL.js +0 -1
  38. package/client/dist/assets/CanvasWorkspace-D7ORj358.js +0 -163
  39. package/client/dist/assets/DashboardPanel-BV7ybUDe.js +0 -1
  40. package/client/dist/assets/FileTree-5qfhBqdE.js +0 -1
  41. package/client/dist/assets/MermaidBlock-BFM21cwe.js +0 -2
  42. package/client/dist/assets/Onboarding-B3cteLu2.js +0 -1
  43. package/client/dist/assets/SetupForm-P6dsYgHO.js +0 -1
  44. package/client/dist/assets/WorkflowsPanel-CBoN80kc.js +0 -1
  45. package/client/dist/assets/index-46kkVu2i.css +0 -1
  46. package/client/dist/assets/vendor-canvas-DvHJ_Pn2.js +0 -49
  47. package/client/dist/favicon.png +0 -0
  48. package/client/dist/favicon.svg +0 -5
  49. package/commands/upfynai-connect.md +0 -59
  50. package/commands/upfynai-disconnect.md +0 -31
  51. package/commands/upfynai-doctor.md +0 -99
  52. package/commands/upfynai-export.md +0 -49
  53. package/commands/upfynai-local.md +0 -82
  54. package/commands/upfynai-status.md +0 -75
  55. package/commands/upfynai-stop.md +0 -49
  56. package/commands/upfynai-uninstall.md +0 -58
  57. package/commands/upfynai.md +0 -69
  58. package/scripts/build-client.js +0 -17
  59. package/scripts/fix-node-pty.js +0 -67
  60. package/scripts/install-commands.js +0 -78
  61. package/server/agent-loop.js +0 -242
  62. package/server/auto-compact.js +0 -99
  63. package/server/browser.js +0 -131
  64. package/server/claude-sdk.js +0 -797
  65. package/server/cli-ui.js +0 -798
  66. package/server/cli.js +0 -751
  67. package/server/constants/config.js +0 -31
  68. package/server/cursor-cli.js +0 -270
  69. package/server/database/auth.db +0 -0
  70. package/server/database/db.js +0 -1547
  71. package/server/database/init.sql +0 -70
  72. package/server/index.js +0 -3813
  73. package/server/load-env.js +0 -26
  74. package/server/mcp-server.js +0 -621
  75. package/server/middleware/auth.js +0 -184
  76. package/server/middleware/relayHelpers.js +0 -44
  77. package/server/middleware/sandboxRouter.js +0 -174
  78. package/server/openai-codex.js +0 -403
  79. package/server/openrouter.js +0 -137
  80. package/server/projects.js +0 -1807
  81. package/server/provider-factory.js +0 -174
  82. package/server/relay-client.js +0 -390
  83. package/server/routes/agent.js +0 -1234
  84. package/server/routes/auth.js +0 -559
  85. package/server/routes/browser.js +0 -419
  86. package/server/routes/canvas.js +0 -53
  87. package/server/routes/cli-auth.js +0 -263
  88. package/server/routes/codex.js +0 -396
  89. package/server/routes/commands.js +0 -707
  90. package/server/routes/composio.js +0 -176
  91. package/server/routes/cursor.js +0 -770
  92. package/server/routes/dashboard.js +0 -295
  93. package/server/routes/git.js +0 -1208
  94. package/server/routes/keys.js +0 -34
  95. package/server/routes/mcp-utils.js +0 -48
  96. package/server/routes/mcp.js +0 -661
  97. package/server/routes/payments.js +0 -227
  98. package/server/routes/projects.js +0 -754
  99. package/server/routes/sessions.js +0 -146
  100. package/server/routes/settings.js +0 -261
  101. package/server/routes/taskmaster.js +0 -1928
  102. package/server/routes/user.js +0 -106
  103. package/server/routes/vapi-chat.js +0 -624
  104. package/server/routes/voice.js +0 -235
  105. package/server/routes/webhooks.js +0 -166
  106. package/server/routes/workflows.js +0 -312
  107. package/server/sandbox.js +0 -120
  108. package/server/services/browser-ai.js +0 -154
  109. package/server/services/composio.js +0 -204
  110. package/server/services/sessionRegistry.js +0 -139
  111. package/server/services/whisperService.js +0 -84
  112. package/server/services/workflowScheduler.js +0 -211
  113. package/server/tests/relay-flow.test.js +0 -570
  114. package/server/tests/sessions.test.js +0 -259
  115. package/server/utils/commandParser.js +0 -303
  116. package/server/utils/email.js +0 -66
  117. package/server/utils/gitConfig.js +0 -24
  118. package/server/utils/mcp-detector.js +0 -198
  119. package/server/utils/taskmaster-websocket.js +0 -129
  120. package/shared/integrationCatalog.d.ts +0 -12
  121. package/shared/integrationCatalog.js +0 -172
  122. package/shared/modelConstants.js +0 -96
  123. /package/{shared → dist}/agents/claude.js +0 -0
  124. /package/{shared → dist}/agents/codex.js +0 -0
  125. /package/{shared → dist}/agents/cursor.js +0 -0
  126. /package/{shared → dist}/agents/detect.js +0 -0
  127. /package/{shared → dist}/agents/exec.js +0 -0
  128. /package/{shared → dist}/agents/files.js +0 -0
  129. /package/{shared → dist}/agents/git.js +0 -0
  130. /package/{shared → dist}/agents/gitagent.js +0 -0
  131. /package/{shared → dist}/agents/index.js +0 -0
  132. /package/{shared → dist}/agents/shell.js +0 -0
  133. /package/{shared → dist}/agents/utils.js +0 -0
  134. /package/{client/dist → dist/client}/api-docs.html +0 -0
  135. /package/{client/dist → dist/client}/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  136. /package/{client/dist → dist/client}/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  137. /package/{client/dist → dist/client}/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  138. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  139. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  140. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  141. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  142. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  143. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  144. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  145. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  146. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  147. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  148. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  149. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  150. /package/{client/dist → dist/client}/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  151. /package/{client/dist → dist/client}/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  152. /package/{client/dist → dist/client}/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  153. /package/{client/dist → dist/client}/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  154. /package/{client/dist → dist/client}/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  155. /package/{client/dist → dist/client}/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  156. /package/{client/dist → dist/client}/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  157. /package/{client/dist → dist/client}/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  158. /package/{client/dist → dist/client}/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  159. /package/{client/dist → dist/client}/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  160. /package/{client/dist → dist/client}/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  161. /package/{client/dist → dist/client}/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  162. /package/{client/dist → dist/client}/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  163. /package/{client/dist → dist/client}/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  164. /package/{client/dist → dist/client}/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  165. /package/{client/dist → dist/client}/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  166. /package/{client/dist → dist/client}/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  167. /package/{client/dist → dist/client}/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  168. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  169. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  170. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  171. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  172. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  173. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  174. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  175. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  176. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  177. /package/{client/dist → dist/client}/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  178. /package/{client/dist → dist/client}/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  179. /package/{client/dist → dist/client}/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  180. /package/{client/dist → dist/client}/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  181. /package/{client/dist → dist/client}/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  182. /package/{client/dist → dist/client}/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  183. /package/{client/dist → dist/client}/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  184. /package/{client/dist → dist/client}/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  185. /package/{client/dist → dist/client}/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  186. /package/{client/dist → dist/client}/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  187. /package/{client/dist → dist/client}/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  188. /package/{client/dist → dist/client}/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  189. /package/{client/dist → dist/client}/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  190. /package/{client/dist → dist/client}/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  191. /package/{client/dist → dist/client}/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  192. /package/{client/dist → dist/client}/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  193. /package/{client/dist → dist/client}/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  194. /package/{client/dist → dist/client}/assets/MarkdownPreview-CESjI261.js +0 -0
  195. /package/{client/dist → dist/client}/assets/PreviewPanel-CqCa92Tf.js +0 -0
  196. /package/{client/dist → dist/client}/assets/pdf-CE_K4jFx.js +0 -0
  197. /package/{client/dist → dist/client}/assets/vendor-canvas-BZV40eAE.css +0 -0
  198. /package/{client/dist → dist/client}/assets/vendor-codemirror-D2ALgpaX.js +0 -0
  199. /package/{client/dist → dist/client}/assets/vendor-diff-DNQpbhrT.js +0 -0
  200. /package/{client/dist → dist/client}/assets/vendor-i18n-DCFGyhQR.js +0 -0
  201. /package/{client/dist → dist/client}/assets/vendor-markdown-CimbIo6Y.js +0 -0
  202. /package/{client/dist → dist/client}/assets/vendor-react-96lCPsRK.js +0 -0
  203. /package/{client/dist → dist/client}/assets/vendor-syntax-LS_Nt30I.js +0 -0
  204. /package/{client/dist → dist/client}/assets/vendor-xterm-CZq1hqo1.js +0 -0
  205. /package/{client/dist → dist/client}/assets/vendor-xterm-qxJ8_QYu.css +0 -0
  206. /package/{client/dist → dist/client}/clear-cache.html +0 -0
  207. /package/{client/dist → dist/client}/convert-icons.md +0 -0
  208. /package/{client/dist → dist/client}/generate-icons.js +0 -0
  209. /package/{client/dist → dist/client}/icons/claude-ai-icon.svg +0 -0
  210. /package/{client/dist → dist/client}/icons/codex-white.svg +0 -0
  211. /package/{client/dist → dist/client}/icons/codex.svg +0 -0
  212. /package/{client/dist → dist/client}/icons/cursor-white.svg +0 -0
  213. /package/{client/dist → dist/client}/icons/cursor.svg +0 -0
  214. /package/{client/dist → dist/client}/icons/icon-128x128.png +0 -0
  215. /package/{client/dist → dist/client}/icons/icon-128x128.svg +0 -0
  216. /package/{client/dist → dist/client}/icons/icon-144x144.png +0 -0
  217. /package/{client/dist → dist/client}/icons/icon-144x144.svg +0 -0
  218. /package/{client/dist → dist/client}/icons/icon-152x152.png +0 -0
  219. /package/{client/dist → dist/client}/icons/icon-152x152.svg +0 -0
  220. /package/{client/dist → dist/client}/icons/icon-192x192.png +0 -0
  221. /package/{client/dist → dist/client}/icons/icon-192x192.svg +0 -0
  222. /package/{client/dist → dist/client}/icons/icon-384x384.png +0 -0
  223. /package/{client/dist → dist/client}/icons/icon-384x384.svg +0 -0
  224. /package/{client/dist → dist/client}/icons/icon-512x512.png +0 -0
  225. /package/{client/dist → dist/client}/icons/icon-512x512.svg +0 -0
  226. /package/{client/dist → dist/client}/icons/icon-72x72.png +0 -0
  227. /package/{client/dist → dist/client}/icons/icon-72x72.svg +0 -0
  228. /package/{client/dist → dist/client}/icons/icon-96x96.png +0 -0
  229. /package/{client/dist → dist/client}/icons/icon-96x96.svg +0 -0
  230. /package/{client/dist → dist/client}/icons/icon-template.svg +0 -0
  231. /package/{client/dist → dist/client}/logo-128.png +0 -0
  232. /package/{client/dist → dist/client}/logo-256.png +0 -0
  233. /package/{client/dist → dist/client}/logo-32.png +0 -0
  234. /package/{client/dist → dist/client}/logo-512.png +0 -0
  235. /package/{client/dist → dist/client}/logo-64.png +0 -0
  236. /package/{client/dist → dist/client}/logo.svg +0 -0
  237. /package/{client/dist → dist/client}/mcp-docs.html +0 -0
  238. /package/{client/dist → dist/client}/offline.html +0 -0
  239. /package/{client/dist → dist/client}/screenshots/cli-selection.png +0 -0
  240. /package/{client/dist → dist/client}/screenshots/desktop-main.png +0 -0
  241. /package/{client/dist → dist/client}/screenshots/mobile-chat.png +0 -0
  242. /package/{client/dist → dist/client}/screenshots/tools-modal.png +0 -0
  243. /package/{client/dist → dist/client}/sw.js +0 -0
  244. /package/{shared → dist}/gitagent/index.js +0 -0
  245. /package/{shared → dist}/gitagent/parser.js +0 -0
  246. /package/{shared → dist}/gitagent/prompt-builder.js +0 -0
@@ -1,2 +1,2 @@
1
- import{j as e,r as n}from"./vendor-react-96lCPsRK.js";import{b as N}from"./index-HaY-3pK1.js";import{bm as te,A as se,Z,X as z,bn as re,H as oe,V as ae,bo as ne,q as B,T as K,E as ie,a3 as le,bp as ce,L as de,a as ue,bq as me,br as xe}from"./vendor-icons-GyYE35HP.js";import"./vendor-syntax-LS_Nt30I.js";import"./vendor-markdown-CimbIo6Y.js";import"./vendor-i18n-DCFGyhQR.js";function pe({url:u,onUrlChange:t,onNavigate:c,onRefresh:m,mode:f,onModeChange:r,hasSession:i,onNewSession:h,onCloseSession:x,isLoading:C}){const $=k=>{if(k.key==="Enter"){let p=u.trim();p&&!p.startsWith("http://")&&!p.startsWith("https://")&&(p=`https://${p}`),c(p)}};return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-muted/30 border-b border-border/40",children:[e.jsx("div",{className:"flex items-center gap-0.5",children:e.jsx("button",{onClick:m,disabled:!i||C,className:"p-1.5 rounded-md hover:bg-muted/60 text-muted-foreground hover:text-foreground disabled:opacity-30 transition-colors",title:"Refresh",children:e.jsx(te,{className:`w-3.5 h-3.5 ${C?"animate-spin":""}`})})}),e.jsxs("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 bg-background rounded-lg border border-border/40 focus-within:border-primary/40 transition-colors",children:[e.jsx(se,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("input",{type:"text",value:u,onChange:k=>t(k.target.value),onKeyDown:$,placeholder:i?"Enter URL or search...":"Launch a browser session first",disabled:!i,className:"flex-1 text-sm bg-transparent outline-none text-foreground placeholder:text-muted-foreground/50"})]}),e.jsxs("div",{className:"flex items-center bg-muted/40 rounded-lg p-0.5",children:[e.jsx("button",{onClick:()=>r("chat"),className:`px-2.5 py-1 text-[11px] font-medium rounded-md transition-colors ${f==="chat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Chat"}),e.jsxs("button",{onClick:()=>r("autonomous"),className:`px-2.5 py-1 text-[11px] font-medium rounded-md transition-colors flex items-center gap-1 ${f==="autonomous"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Z,{className:"w-3 h-3"}),"Auto"]})]}),i?e.jsx("button",{onClick:x,className:"p-1.5 rounded-md hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors",title:"Close browser session",children:e.jsx(z,{className:"w-3.5 h-3.5"})}):e.jsxs("button",{onClick:h,disabled:C,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 disabled:opacity-50 transition-opacity",children:[e.jsx(re,{className:"w-3.5 h-3.5"}),"Launch"]})]})}function fe({viewerUrl:u,hasSession:t,isLoading:c,onNewSession:m}){return t?u?e.jsx("div",{className:"flex-1 relative bg-black",children:e.jsx("iframe",{src:u,title:"Browser Session",className:"absolute inset-0 w-full h-full border-0",sandbox:"allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox",allow:"clipboard-read; clipboard-write"})}):e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/10",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-muted-foreground/30 border-t-muted-foreground rounded-full animate-spin"}),"Connecting to browser session..."]})}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 bg-muted/10 text-muted-foreground",children:[e.jsx(oe,{className:"w-12 h-12 opacity-30"}),e.jsxs("div",{className:"text-center space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"No browser session active"}),e.jsx("p",{className:"text-xs opacity-70",children:"Launch a session to start browsing or preview your sandbox apps"})]}),e.jsx("button",{onClick:m,disabled:c,className:"px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 disabled:opacity-50 transition-opacity",children:c?"Launching...":"Launch Browser"})]})}function he({value:u,onChange:t,onSubmit:c,onStop:m,mode:f,isRunning:r,hasSession:i}){const h=x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),u.trim()&&!r&&c())};return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-muted/30 border-t border-border/40",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 px-3 py-2 bg-background rounded-lg border border-border/40 focus-within:border-primary/40 transition-colors",children:[f==="autonomous"&&e.jsx(Z,{className:"w-3.5 h-3.5 text-amber-500 flex-shrink-0"}),e.jsx("input",{type:"text",value:u,onChange:x=>t(x.target.value),onKeyDown:h,placeholder:i?f==="chat"?'Tell the AI what to do... (e.g., "Click the login button")':'Set a goal... (e.g., "Fill out the registration form")':"Launch a session first",disabled:!i||r,className:"flex-1 text-sm bg-transparent outline-none text-foreground placeholder:text-muted-foreground/50"})]}),r?e.jsx("button",{onClick:m,className:"p-2 rounded-lg bg-destructive/10 text-destructive hover:bg-destructive/20 transition-colors",title:"Stop",children:e.jsx(ae,{className:"w-4 h-4"})}):e.jsx("button",{onClick:c,disabled:!i||!u.trim(),className:"p-2 rounded-lg bg-primary text-primary-foreground hover:opacity-90 disabled:opacity-30 transition-opacity",title:"Send",children:e.jsx(ne,{className:"w-4 h-4"})})]})}const be={act:ce,extract:le,observe:ie,navigate:B,error:K,info:B};function ge({actions:u,consoleErrors:t,isVisible:c,onClose:m,onFixError:f}){return c?e.jsxs("div",{className:"w-64 flex-shrink-0 border-l border-border/40 bg-muted/10 flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/40",children:[e.jsx("span",{className:"text-xs font-medium text-foreground",children:"Action Log"}),e.jsx("button",{onClick:m,className:"p-1 rounded hover:bg-muted/60 text-muted-foreground",children:e.jsx(z,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[u.length===0&&t.length===0&&e.jsx("div",{className:"p-3 text-xs text-muted-foreground/60 text-center",children:"AI actions and console errors will appear here"}),u.map(r=>{const i=be[r.type]||B;return e.jsx("div",{className:"px-3 py-2 border-b border-border/20 hover:bg-muted/20 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:r.status==="running"?e.jsx(de,{className:"w-3 h-3 text-primary animate-spin"}):r.status==="error"?e.jsx(K,{className:"w-3 h-3 text-destructive"}):e.jsx(i,{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-1",children:[e.jsxs("span",{className:"text-[10px] text-muted-foreground/60 font-mono",children:["#",r.step]}),e.jsx("span",{className:"text-[10px] uppercase text-muted-foreground/60 font-medium",children:r.type})]}),e.jsx("p",{className:"text-xs text-foreground truncate",children:r.instruction}),r.result&&e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5 line-clamp-2",children:r.result})]}),r.status==="done"&&e.jsx(ue,{className:"w-3 h-3 text-emerald-500 flex-shrink-0 mt-0.5"})]})},r.id)}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-1.5 bg-destructive/5 border-y border-destructive/10",children:e.jsxs("span",{className:"text-[10px] font-medium text-destructive uppercase tracking-wide",children:["Console Errors (",t.length,")"]})}),t.map((r,i)=>e.jsxs("div",{className:"px-3 py-2 border-b border-border/20 hover:bg-destructive/5 transition-colors",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(K,{className:"w-3 h-3 text-destructive flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-foreground line-clamp-3 font-mono",children:r.message}),r.source&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[r.source,r.line?`:${r.line}`:""]})]})]}),e.jsxs("button",{onClick:()=>f(r),className:"mt-1.5 flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-primary bg-primary/10 rounded hover:bg-primary/20 transition-colors",children:[e.jsx(me,{className:"w-2.5 h-2.5"}),"Fix this error"]})]},`err-${i}`))]})]})]}):null}function ke({selectedProject:u}){const[t,c]=n.useState(null),[m,f]=n.useState(""),[r,i]=n.useState("chat"),[h,x]=n.useState(""),[C,$]=n.useState(!1),[k,p]=n.useState(!1),[G,D]=n.useState([]),[S,M]=n.useState([]),[P,R]=n.useState(!1),[V,v]=n.useState(null),E=n.useRef(0),F=n.useRef(null);n.useEffect(()=>{let s=!1;return(async()=>{var o;try{const a=await N.browser.listSessions();if(s)return;if(a.ok){const l=(o=(await a.json()).sessions)==null?void 0:o[0];l&&c({sessionId:l.steel_session_id||l.id,viewerUrl:l.viewer_url||l.viewerUrl||null,status:"active"})}}catch{}})(),()=>{s=!0}},[]);const W=n.useCallback(async()=>{$(!0),v(null);try{const s=await N.browser.createSession();if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error(a.error||"Failed to create session")}const o=await s.json();c({sessionId:o.sessionId||o.id,viewerUrl:o.viewerUrl||o.sessionViewerUrl||null,status:"active"})}catch(s){v(s.message||"Failed to launch browser")}finally{$(!1)}},[]),H=n.useCallback(async()=>{if(t){c(s=>s?{...s,status:"closing"}:null);try{await N.browser.closeSession(t.sessionId)}catch{}c(null),f(""),D([]),M([]),E.current=0}},[t]),J=n.useCallback(async s=>{if(!(!t||!s)){f(s);try{const o=await N.browser.navigate(t.sessionId,s);if(!o.ok){const a=await o.json().catch(()=>({}));v(a.error||"Navigation failed")}}catch{v("Navigation failed")}}},[t]),X=n.useCallback(async()=>{if(!(!t||!m))try{await N.browser.navigate(t.sessionId,m)}catch{}},[t,m]),I=n.useCallback(s=>{E.current+=1;const o={...s,id:`action-${Date.now()}-${E.current}`,step:E.current};return D(a=>[...a,o]),R(!0),o.id},[]),w=n.useCallback((s,o)=>{D(a=>a.map(d=>d.id===s?{...d,...o}:d))},[]),q=n.useCallback(async()=>{if(!t||!h.trim())return;const s=h.trim();x(""),p(!0),v(null);const o=I({type:"act",instruction:s,timestamp:Date.now(),status:"running"});try{const a=await N.browser.aiAct(t.sessionId,s);if(a.ok){const d=await a.json();w(o,{status:"done",result:d.result||"Done"})}else{const d=await a.json().catch(()=>({}));w(o,{status:"error",result:d.error||"Action failed"})}}catch(a){w(o,{status:"error",result:a.message||"Action failed"})}finally{p(!1)}},[t,h,I,w]),_=n.useCallback(async()=>{var d;if(!t||!h.trim())return;const s=h.trim();x(""),p(!0),v(null);const o=new AbortController;F.current=o;const a=I({type:"info",instruction:`Goal: ${s}`,timestamp:Date.now(),status:"running"});try{const l=await fetch(`/api/browser/sessions/${t.sessionId}/ai/autonomous?goal=${encodeURIComponent(s)}&maxSteps=20`,{credentials:"include",signal:o.signal});if(!l.ok){const y=await l.json().catch(()=>({}));w(a,{status:"error",result:y.error||"Failed"});return}const A=(d=l.body)==null?void 0:d.getReader(),b=new TextDecoder;let T="";if(A)for(;;){const{done:y,value:L}=await A.read();if(y)break;T+=b.decode(L,{stream:!0});const j=T.split(`
2
- `);T=j.pop()||"";for(const O of j){if(!O.startsWith("data: "))continue;const U=O.slice(6).trim();if(!(!U||U==="[DONE]"))try{const g=JSON.parse(U);g.type==="step"?I({type:g.actionType||"act",instruction:g.instruction||g.description||"",result:g.result,timestamp:Date.now(),status:g.status==="error"?"error":"done"}):g.type==="complete"?w(a,{status:"done",result:g.message||"Goal completed"}):g.type==="error"&&w(a,{status:"error",result:g.error||"Autonomous run failed"})}catch{}}}D(y=>{const L=y.find(j=>j.id===a);return L&&L.status==="running"?y.map(j=>j.id===a?{...j,status:"done",result:"Completed"}:j):y})}catch(l){l.name!=="AbortError"&&w(a,{status:"error",result:l.message||"Autonomous run failed"})}finally{p(!1),F.current=null}},[t,h,I,w]),Q=n.useCallback(()=>{r==="chat"?q():_()},[r,q,_]),Y=n.useCallback(()=>{var s;(s=F.current)==null||s.abort(),p(!1)},[]),ee=n.useCallback(s=>{const o=`Fix this console error: ${s.message}${s.source?` (source: ${s.source}:${s.line})`:""}`;x(o),i("chat")},[]);return n.useEffect(()=>{if(!t||t.status!=="active")return;let s=!1;const o=async()=>{var d;try{const l=await N.browser.consoleErrors(t.sessionId);if(s||!l.ok)return;const A=await l.json();(d=A.errors)!=null&&d.length&&M(A.errors.map(b=>({message:b.message||b.text||String(b),source:b.source||b.url,line:b.line||b.lineNumber,timestamp:b.timestamp||Date.now()})))}catch{}},a=setInterval(o,1e4);return o(),()=>{s=!0,clearInterval(a)}},[t]),e.jsxs("div",{className:"h-full flex flex-col bg-background",children:[e.jsx(pe,{url:m,onUrlChange:f,onNavigate:J,onRefresh:X,mode:r,onModeChange:i,hasSession:(t==null?void 0:t.status)==="active",onNewSession:W,onCloseSession:H,isLoading:C}),V&&e.jsxs("div",{className:"px-3 py-1.5 bg-destructive/10 border-b border-destructive/20 text-xs text-destructive flex items-center justify-between",children:[e.jsx("span",{children:V}),e.jsx("button",{onClick:()=>v(null),className:"text-destructive/70 hover:text-destructive",children:"Dismiss"})]}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsx(fe,{viewerUrl:(t==null?void 0:t.viewerUrl)||null,hasSession:!!t,isLoading:C,onNewSession:W}),!P&&(G.length>0||S.length>0)&&e.jsxs("button",{onClick:()=>R(!0),className:"absolute right-2 top-14 z-10 p-1.5 rounded-md bg-muted/80 border border-border/40 text-muted-foreground hover:text-foreground transition-colors",title:"Show action log",children:[e.jsx(xe,{className:"w-3.5 h-3.5"}),S.length>0&&e.jsx("span",{className:"absolute -top-1 -right-1 w-3 h-3 bg-destructive rounded-full text-[8px] text-white flex items-center justify-center",children:S.length>9?"!":S.length})]}),e.jsx(ge,{actions:G,consoleErrors:S,isVisible:P,onClose:()=>R(!1),onFixError:ee})]}),e.jsx(he,{value:h,onChange:x,onSubmit:Q,onStop:Y,mode:r,isRunning:k,hasSession:(t==null?void 0:t.status)==="active"})]})}export{ke as default};
1
+ import{j as e,r as n}from"./vendor-react-96lCPsRK.js";import{b as N}from"./index-BQy15irW.js";import{bm as te,A as se,Z,X as z,bn as re,M as oe,U as ae,bo as ne,q as B,T as K,E as ie,a2 as le,bp as ce,L as de,a as ue,bq as me,br as xe}from"./vendor-icons-kix3Gb31.js";import"./vendor-syntax-LS_Nt30I.js";import"./vendor-markdown-CimbIo6Y.js";import"./vendor-i18n-DCFGyhQR.js";function pe({url:u,onUrlChange:t,onNavigate:c,onRefresh:m,mode:f,onModeChange:r,hasSession:i,onNewSession:h,onCloseSession:x,isLoading:C}){const $=k=>{if(k.key==="Enter"){let p=u.trim();p&&!p.startsWith("http://")&&!p.startsWith("https://")&&(p=`https://${p}`),c(p)}};return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-muted/30 border-b border-border/40",children:[e.jsx("div",{className:"flex items-center gap-0.5",children:e.jsx("button",{onClick:m,disabled:!i||C,className:"p-1.5 rounded-md hover:bg-muted/60 text-muted-foreground hover:text-foreground disabled:opacity-30 transition-colors",title:"Refresh",children:e.jsx(te,{className:`w-3.5 h-3.5 ${C?"animate-spin":""}`})})}),e.jsxs("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 bg-background rounded-lg border border-border/40 focus-within:border-primary/40 transition-colors",children:[e.jsx(se,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("input",{type:"text",value:u,onChange:k=>t(k.target.value),onKeyDown:$,placeholder:i?"Enter URL or search...":"Launch a browser session first",disabled:!i,className:"flex-1 text-sm bg-transparent outline-none text-foreground placeholder:text-muted-foreground/50"})]}),e.jsxs("div",{className:"flex items-center bg-muted/40 rounded-lg p-0.5",children:[e.jsx("button",{onClick:()=>r("chat"),className:`px-2.5 py-1 text-[11px] font-medium rounded-md transition-colors ${f==="chat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Chat"}),e.jsxs("button",{onClick:()=>r("autonomous"),className:`px-2.5 py-1 text-[11px] font-medium rounded-md transition-colors flex items-center gap-1 ${f==="autonomous"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Z,{className:"w-3 h-3"}),"Auto"]})]}),i?e.jsx("button",{onClick:x,className:"p-1.5 rounded-md hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors",title:"Close browser session",children:e.jsx(z,{className:"w-3.5 h-3.5"})}):e.jsxs("button",{onClick:h,disabled:C,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 disabled:opacity-50 transition-opacity",children:[e.jsx(re,{className:"w-3.5 h-3.5"}),"Launch"]})]})}function fe({viewerUrl:u,hasSession:t,isLoading:c,onNewSession:m}){return t?u?e.jsx("div",{className:"flex-1 relative bg-black",children:e.jsx("iframe",{src:u,title:"Browser Session",className:"absolute inset-0 w-full h-full border-0",sandbox:"allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox",allow:"clipboard-read; clipboard-write"})}):e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/10",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-muted-foreground/30 border-t-muted-foreground rounded-full animate-spin"}),"Connecting to browser session..."]})}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 bg-muted/10 text-muted-foreground",children:[e.jsx(oe,{className:"w-12 h-12 opacity-30"}),e.jsxs("div",{className:"text-center space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"No browser session active"}),e.jsx("p",{className:"text-xs opacity-70",children:"Launch a session to start browsing or preview your sandbox apps"})]}),e.jsx("button",{onClick:m,disabled:c,className:"px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 disabled:opacity-50 transition-opacity",children:c?"Launching...":"Launch Browser"})]})}function he({value:u,onChange:t,onSubmit:c,onStop:m,mode:f,isRunning:r,hasSession:i}){const h=x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),u.trim()&&!r&&c())};return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-muted/30 border-t border-border/40",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 px-3 py-2 bg-background rounded-lg border border-border/40 focus-within:border-primary/40 transition-colors",children:[f==="autonomous"&&e.jsx(Z,{className:"w-3.5 h-3.5 text-amber-500 flex-shrink-0"}),e.jsx("input",{type:"text",value:u,onChange:x=>t(x.target.value),onKeyDown:h,placeholder:i?f==="chat"?'Tell the AI what to do... (e.g., "Click the login button")':'Set a goal... (e.g., "Fill out the registration form")':"Launch a session first",disabled:!i||r,className:"flex-1 text-sm bg-transparent outline-none text-foreground placeholder:text-muted-foreground/50"})]}),r?e.jsx("button",{onClick:m,className:"p-2 rounded-lg bg-destructive/10 text-destructive hover:bg-destructive/20 transition-colors",title:"Stop",children:e.jsx(ae,{className:"w-4 h-4"})}):e.jsx("button",{onClick:c,disabled:!i||!u.trim(),className:"p-2 rounded-lg bg-primary text-primary-foreground hover:opacity-90 disabled:opacity-30 transition-opacity",title:"Send",children:e.jsx(ne,{className:"w-4 h-4"})})]})}const be={act:ce,extract:le,observe:ie,navigate:B,error:K,info:B};function ge({actions:u,consoleErrors:t,isVisible:c,onClose:m,onFixError:f}){return c?e.jsxs("div",{className:"w-64 flex-shrink-0 border-l border-border/40 bg-muted/10 flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/40",children:[e.jsx("span",{className:"text-xs font-medium text-foreground",children:"Action Log"}),e.jsx("button",{onClick:m,className:"p-1 rounded hover:bg-muted/60 text-muted-foreground",children:e.jsx(z,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[u.length===0&&t.length===0&&e.jsx("div",{className:"p-3 text-xs text-muted-foreground/60 text-center",children:"AI actions and console errors will appear here"}),u.map(r=>{const i=be[r.type]||B;return e.jsx("div",{className:"px-3 py-2 border-b border-border/20 hover:bg-muted/20 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:r.status==="running"?e.jsx(de,{className:"w-3 h-3 text-primary animate-spin"}):r.status==="error"?e.jsx(K,{className:"w-3 h-3 text-destructive"}):e.jsx(i,{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-1",children:[e.jsxs("span",{className:"text-[10px] text-muted-foreground/60 font-mono",children:["#",r.step]}),e.jsx("span",{className:"text-[10px] uppercase text-muted-foreground/60 font-medium",children:r.type})]}),e.jsx("p",{className:"text-xs text-foreground truncate",children:r.instruction}),r.result&&e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5 line-clamp-2",children:r.result})]}),r.status==="done"&&e.jsx(ue,{className:"w-3 h-3 text-emerald-500 flex-shrink-0 mt-0.5"})]})},r.id)}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-1.5 bg-destructive/5 border-y border-destructive/10",children:e.jsxs("span",{className:"text-[10px] font-medium text-destructive uppercase tracking-wide",children:["Console Errors (",t.length,")"]})}),t.map((r,i)=>e.jsxs("div",{className:"px-3 py-2 border-b border-border/20 hover:bg-destructive/5 transition-colors",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(K,{className:"w-3 h-3 text-destructive flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-foreground line-clamp-3 font-mono",children:r.message}),r.source&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[r.source,r.line?`:${r.line}`:""]})]})]}),e.jsxs("button",{onClick:()=>f(r),className:"mt-1.5 flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-primary bg-primary/10 rounded hover:bg-primary/20 transition-colors",children:[e.jsx(me,{className:"w-2.5 h-2.5"}),"Fix this error"]})]},`err-${i}`))]})]})]}):null}function ke({selectedProject:u}){const[t,c]=n.useState(null),[m,f]=n.useState(""),[r,i]=n.useState("chat"),[h,x]=n.useState(""),[C,$]=n.useState(!1),[k,p]=n.useState(!1),[M,D]=n.useState([]),[S,G]=n.useState([]),[P,R]=n.useState(!1),[W,v]=n.useState(null),E=n.useRef(0),F=n.useRef(null);n.useEffect(()=>{let s=!1;return(async()=>{var o;try{const a=await N.browser.listSessions();if(s)return;if(a.ok){const l=(o=(await a.json()).sessions)==null?void 0:o[0];l&&c({sessionId:l.steel_session_id||l.id,viewerUrl:l.viewer_url||l.viewerUrl||null,status:"active"})}}catch{}})(),()=>{s=!0}},[]);const q=n.useCallback(async()=>{$(!0),v(null);try{const s=await N.browser.createSession();if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error(a.error||"Failed to create session")}const o=await s.json();c({sessionId:o.sessionId||o.id,viewerUrl:o.viewerUrl||o.sessionViewerUrl||null,status:"active"})}catch(s){v(s.message||"Failed to launch browser")}finally{$(!1)}},[]),J=n.useCallback(async()=>{if(t){c(s=>s?{...s,status:"closing"}:null);try{await N.browser.closeSession(t.sessionId)}catch{}c(null),f(""),D([]),G([]),E.current=0}},[t]),X=n.useCallback(async s=>{if(!(!t||!s)){f(s);try{const o=await N.browser.navigate(t.sessionId,s);if(!o.ok){const a=await o.json().catch(()=>({}));v(a.error||"Navigation failed")}}catch{v("Navigation failed")}}},[t]),H=n.useCallback(async()=>{if(!(!t||!m))try{await N.browser.navigate(t.sessionId,m)}catch{}},[t,m]),I=n.useCallback(s=>{E.current+=1;const o={...s,id:`action-${Date.now()}-${E.current}`,step:E.current};return D(a=>[...a,o]),R(!0),o.id},[]),w=n.useCallback((s,o)=>{D(a=>a.map(d=>d.id===s?{...d,...o}:d))},[]),V=n.useCallback(async()=>{if(!t||!h.trim())return;const s=h.trim();x(""),p(!0),v(null);const o=I({type:"act",instruction:s,timestamp:Date.now(),status:"running"});try{const a=await N.browser.aiAct(t.sessionId,s);if(a.ok){const d=await a.json();w(o,{status:"done",result:d.result||"Done"})}else{const d=await a.json().catch(()=>({}));w(o,{status:"error",result:d.error||"Action failed"})}}catch(a){w(o,{status:"error",result:a.message||"Action failed"})}finally{p(!1)}},[t,h,I,w]),_=n.useCallback(async()=>{var d;if(!t||!h.trim())return;const s=h.trim();x(""),p(!0),v(null);const o=new AbortController;F.current=o;const a=I({type:"info",instruction:`Goal: ${s}`,timestamp:Date.now(),status:"running"});try{const l=await fetch(`/api/browser/sessions/${t.sessionId}/ai/autonomous?goal=${encodeURIComponent(s)}&maxSteps=20`,{credentials:"include",signal:o.signal});if(!l.ok){const y=await l.json().catch(()=>({}));w(a,{status:"error",result:y.error||"Failed"});return}const A=(d=l.body)==null?void 0:d.getReader(),b=new TextDecoder;let U="";if(A)for(;;){const{done:y,value:L}=await A.read();if(y)break;U+=b.decode(L,{stream:!0});const j=U.split(`
2
+ `);U=j.pop()||"";for(const O of j){if(!O.startsWith("data: "))continue;const T=O.slice(6).trim();if(!(!T||T==="[DONE]"))try{const g=JSON.parse(T);g.type==="step"?I({type:g.actionType||"act",instruction:g.instruction||g.description||"",result:g.result,timestamp:Date.now(),status:g.status==="error"?"error":"done"}):g.type==="complete"?w(a,{status:"done",result:g.message||"Goal completed"}):g.type==="error"&&w(a,{status:"error",result:g.error||"Autonomous run failed"})}catch{}}}D(y=>{const L=y.find(j=>j.id===a);return L&&L.status==="running"?y.map(j=>j.id===a?{...j,status:"done",result:"Completed"}:j):y})}catch(l){l.name!=="AbortError"&&w(a,{status:"error",result:l.message||"Autonomous run failed"})}finally{p(!1),F.current=null}},[t,h,I,w]),Q=n.useCallback(()=>{r==="chat"?V():_()},[r,V,_]),Y=n.useCallback(()=>{var s;(s=F.current)==null||s.abort(),p(!1)},[]),ee=n.useCallback(s=>{const o=`Fix this console error: ${s.message}${s.source?` (source: ${s.source}:${s.line})`:""}`;x(o),i("chat")},[]);return n.useEffect(()=>{if(!t||t.status!=="active")return;let s=!1;const o=async()=>{var d;try{const l=await N.browser.consoleErrors(t.sessionId);if(s||!l.ok)return;const A=await l.json();(d=A.errors)!=null&&d.length&&G(A.errors.map(b=>({message:b.message||b.text||String(b),source:b.source||b.url,line:b.line||b.lineNumber,timestamp:b.timestamp||Date.now()})))}catch{}},a=setInterval(o,1e4);return o(),()=>{s=!0,clearInterval(a)}},[t]),e.jsxs("div",{className:"h-full flex flex-col bg-background",children:[e.jsx(pe,{url:m,onUrlChange:f,onNavigate:X,onRefresh:H,mode:r,onModeChange:i,hasSession:(t==null?void 0:t.status)==="active",onNewSession:q,onCloseSession:J,isLoading:C}),W&&e.jsxs("div",{className:"px-3 py-1.5 bg-destructive/10 border-b border-destructive/20 text-xs text-destructive flex items-center justify-between",children:[e.jsx("span",{children:W}),e.jsx("button",{onClick:()=>v(null),className:"text-destructive/70 hover:text-destructive",children:"Dismiss"})]}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsx(fe,{viewerUrl:(t==null?void 0:t.viewerUrl)||null,hasSession:!!t,isLoading:C,onNewSession:q}),!P&&(M.length>0||S.length>0)&&e.jsxs("button",{onClick:()=>R(!0),className:"absolute right-2 top-14 z-10 p-1.5 rounded-md bg-muted/80 border border-border/40 text-muted-foreground hover:text-foreground transition-colors",title:"Show action log",children:[e.jsx(xe,{className:"w-3.5 h-3.5"}),S.length>0&&e.jsx("span",{className:"absolute -top-1 -right-1 w-3 h-3 bg-destructive rounded-full text-[8px] text-white flex items-center justify-center",children:S.length>9?"!":S.length})]}),e.jsx(ge,{actions:M,consoleErrors:S,isVisible:P,onClose:()=>R(!1),onFixError:ee})]}),e.jsx(he,{value:h,onChange:x,onSubmit:Q,onStop:Y,mode:r,isRunning:k,hasSession:(t==null?void 0:t.status)==="active"})]})}export{ke as default};
@@ -0,0 +1 @@
1
+ import{u as x,h as p,r as u,j as e}from"./vendor-react-96lCPsRK.js";import{u as f}from"./index-BQy15irW.js";import h from"./CanvasWorkspace-DvGKdL-k.js";import"./vendor-syntax-LS_Nt30I.js";import"./vendor-markdown-CimbIo6Y.js";import"./vendor-icons-kix3Gb31.js";import"./vendor-i18n-DCFGyhQR.js";import"./vendor-canvas-QWTduIvM.js";function C(){const{projectName:s}=x(),r=p(),{sendMessage:l,latestMessage:m,connectionState:t}=f();if(u.useEffect(()=>{const n=o=>{var c,d;const i=(d=(c=o.target)==null?void 0:c.tagName)==null?void 0:d.toLowerCase();o.key==="Escape"&&i!=="input"&&i!=="textarea"&&r("/")};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[r]),!s)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-background text-muted-foreground",children:"No project selected"});const a=decodeURIComponent(s);return e.jsxs("div",{className:"fixed inset-0 bg-background flex flex-col z-50",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border/50 bg-card/50 backdrop-blur-sm shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>r("/"),className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back"]}),e.jsx("div",{className:"h-4 w-px bg-border/50"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z"})}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:a}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary border border-primary/20 font-medium",children:"Canvas"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t!=="connected"&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] px-2 py-0.5 rounded-full border border-amber-500/20 bg-amber-500/5 text-amber-400",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-amber-400 rounded-full animate-pulse"}),t==="reconnecting"?"Reconnecting...":"Offline"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Press Esc to exit"})]})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(h,{projectName:a,sendMessage:l,latestMessage:m,isFullScreen:!0})})]})}export{C as default};