commandmate 0.3.1 → 0.3.3

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 (151) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +11 -11
  3. package/.next/app-path-routes-manifest.json +1 -1
  4. package/.next/build-manifest.json +4 -4
  5. package/.next/cache/.tsbuildinfo +1 -1
  6. package/.next/cache/config.json +3 -3
  7. package/.next/cache/webpack/client-production/0.pack +0 -0
  8. package/.next/cache/webpack/client-production/1.pack +0 -0
  9. package/.next/cache/webpack/client-production/2.pack +0 -0
  10. package/.next/cache/webpack/client-production/index.pack +0 -0
  11. package/.next/cache/webpack/client-production/index.pack.old +0 -0
  12. package/.next/cache/webpack/edge-server-production/0.pack +0 -0
  13. package/.next/cache/webpack/edge-server-production/index.pack +0 -0
  14. package/.next/cache/webpack/server-production/0.pack +0 -0
  15. package/.next/cache/webpack/server-production/index.pack +0 -0
  16. package/.next/next-server.js.nft.json +1 -1
  17. package/.next/prerender-manifest.json +1 -1
  18. package/.next/required-server-files.json +1 -1
  19. package/.next/routes-manifest.json +1 -1
  20. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  21. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  22. package/.next/server/app/api/app/update-check/route.js +1 -1
  23. package/.next/server/app/api/external-apps/[id]/health/route.js +1 -1
  24. package/.next/server/app/api/external-apps/[id]/route.js +1 -1
  25. package/.next/server/app/api/external-apps/route.js +1 -1
  26. package/.next/server/app/api/hooks/claude-done/route.js +1 -1
  27. package/.next/server/app/api/ollama/models/route.js +1 -0
  28. package/.next/server/app/api/ollama/models/route.js.nft.json +1 -0
  29. package/.next/server/app/api/ollama/models.body +1 -0
  30. package/.next/server/app/api/ollama/models.meta +1 -0
  31. package/.next/server/app/api/repositories/clone/[jobId]/route.js +1 -1
  32. package/.next/server/app/api/repositories/clone/route.js +1 -1
  33. package/.next/server/app/api/repositories/excluded/route.js +7 -7
  34. package/.next/server/app/api/repositories/restore/route.js +3 -3
  35. package/.next/server/app/api/repositories/route.js +13 -11
  36. package/.next/server/app/api/repositories/route.js.nft.json +1 -1
  37. package/.next/server/app/api/repositories/scan/route.js +1 -1
  38. package/.next/server/app/api/repositories/sync/route.js +3 -3
  39. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js +1 -1
  40. package/.next/server/app/api/worktrees/[id]/auto-yes/route.js.nft.json +1 -1
  41. package/.next/server/app/api/worktrees/[id]/cli-tool/route.js +1 -1
  42. package/.next/server/app/api/worktrees/[id]/current-output/route.js +1 -1
  43. package/.next/server/app/api/worktrees/[id]/current-output/route.js.nft.json +1 -1
  44. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route.js +1 -0
  45. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route.js.nft.json +1 -0
  46. package/.next/server/app/api/worktrees/[id]/execution-logs/route.js +9 -0
  47. package/.next/server/app/api/worktrees/[id]/execution-logs/route.js.nft.json +1 -0
  48. package/.next/server/app/api/worktrees/[id]/files/[...path]/route.js +1 -1
  49. package/.next/server/app/api/worktrees/[id]/interrupt/route.js +1 -1
  50. package/.next/server/app/api/worktrees/[id]/interrupt/route.js.nft.json +1 -1
  51. package/.next/server/app/api/worktrees/[id]/kill-session/route.js +1 -1
  52. package/.next/server/app/api/worktrees/[id]/kill-session/route.js.nft.json +1 -1
  53. package/.next/server/app/api/worktrees/[id]/logs/[filename]/route.js +1 -1
  54. package/.next/server/app/api/worktrees/[id]/logs/route.js +2 -2
  55. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route.js +1 -1
  56. package/.next/server/app/api/worktrees/[id]/memos/route.js +1 -1
  57. package/.next/server/app/api/worktrees/[id]/messages/route.js +1 -1
  58. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js +1 -1
  59. package/.next/server/app/api/worktrees/[id]/prompt-response/route.js.nft.json +1 -1
  60. package/.next/server/app/api/worktrees/[id]/respond/route.js +1 -1
  61. package/.next/server/app/api/worktrees/[id]/respond/route.js.nft.json +1 -1
  62. package/.next/server/app/api/worktrees/[id]/route.js +1 -1
  63. package/.next/server/app/api/worktrees/[id]/route.js.nft.json +1 -1
  64. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js +1 -0
  65. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js.nft.json +1 -0
  66. package/.next/server/app/api/worktrees/[id]/schedules/route.js +4 -0
  67. package/.next/server/app/api/worktrees/[id]/schedules/route.js.nft.json +1 -0
  68. package/.next/server/app/api/worktrees/[id]/search/route.js +1 -1
  69. package/.next/server/app/api/worktrees/[id]/send/route.js +1 -1
  70. package/.next/server/app/api/worktrees/[id]/send/route.js.nft.json +1 -1
  71. package/.next/server/app/api/worktrees/[id]/slash-commands/route.js +1 -1
  72. package/.next/server/app/api/worktrees/[id]/start-polling/route.js +1 -1
  73. package/.next/server/app/api/worktrees/[id]/start-polling/route.js.nft.json +1 -1
  74. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route.js +1 -1
  75. package/.next/server/app/api/worktrees/[id]/tree/route.js +1 -1
  76. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route.js +1 -1
  77. package/.next/server/app/api/worktrees/[id]/viewed/route.js +1 -1
  78. package/.next/server/app/api/worktrees/route.js +1 -1
  79. package/.next/server/app/api/worktrees/route.js.nft.json +1 -1
  80. package/.next/server/app/login/page.js.nft.json +1 -1
  81. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  82. package/.next/server/app/page.js +1 -1
  83. package/.next/server/app/page.js.nft.json +1 -1
  84. package/.next/server/app/page_client-reference-manifest.js +1 -1
  85. package/.next/server/app/proxy/[...path]/route.js +1 -1
  86. package/.next/server/app/worktrees/[id]/files/[...path]/page.js.nft.json +1 -1
  87. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
  88. package/.next/server/app/worktrees/[id]/page.js +8 -3
  89. package/.next/server/app/worktrees/[id]/page.js.nft.json +1 -1
  90. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
  91. package/.next/server/app/worktrees/[id]/terminal/page.js.nft.json +1 -1
  92. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
  93. package/.next/server/app-paths-manifest.json +10 -5
  94. package/.next/server/chunks/2314.js +1 -0
  95. package/.next/server/chunks/3860.js +1 -1
  96. package/.next/server/chunks/4559.js +1 -1
  97. package/.next/server/chunks/539.js +10 -10
  98. package/.next/server/chunks/5853.js +1 -1
  99. package/.next/server/chunks/6228.js +1 -0
  100. package/.next/server/chunks/7425.js +112 -37
  101. package/.next/server/chunks/7566.js +1 -1
  102. package/.next/server/chunks/8693.js +1 -1
  103. package/.next/server/chunks/9446.js +1 -0
  104. package/.next/server/functions-config-manifest.json +1 -1
  105. package/.next/server/middleware-build-manifest.js +1 -1
  106. package/.next/server/middleware-manifest.json +5 -5
  107. package/.next/server/pages/500.html +1 -1
  108. package/.next/server/server-reference-manifest.json +1 -1
  109. package/.next/static/chunks/8091-274bc0716106e7fc.js +1 -0
  110. package/.next/static/chunks/app/page-060057e02b841125.js +1 -0
  111. package/.next/static/chunks/app/worktrees/[id]/page-78580947c201d698.js +1 -0
  112. package/.next/static/chunks/{main-db79434ee4a6c931.js → main-2feda12a4d321111.js} +1 -1
  113. package/.next/static/css/e85de230ef5ddc40.css +3 -0
  114. package/.next/trace +5 -5
  115. package/.next/types/app/api/ollama/models/route.ts +343 -0
  116. package/.next/types/app/api/worktrees/[id]/execution-logs/[logId]/route.ts +343 -0
  117. package/.next/types/app/api/worktrees/[id]/execution-logs/route.ts +343 -0
  118. package/.next/types/app/api/worktrees/[id]/schedules/[scheduleId]/route.ts +343 -0
  119. package/.next/types/app/api/worktrees/[id]/schedules/route.ts +343 -0
  120. package/README.md +74 -76
  121. package/dist/cli/utils/docs-reader.d.ts.map +1 -1
  122. package/dist/cli/utils/docs-reader.js +1 -0
  123. package/dist/server/server.js +5 -0
  124. package/dist/server/src/config/cmate-constants.js +79 -0
  125. package/dist/server/src/config/schedule-config.js +60 -0
  126. package/dist/server/src/lib/auto-yes-manager.js +2 -2
  127. package/dist/server/src/lib/claude-executor.js +158 -0
  128. package/dist/server/src/lib/cli-patterns.js +73 -9
  129. package/dist/server/src/lib/cli-tools/gemini.js +81 -22
  130. package/dist/server/src/lib/cli-tools/manager.js +4 -2
  131. package/dist/server/src/lib/cli-tools/types.js +64 -2
  132. package/dist/server/src/lib/cli-tools/vibe-local.js +163 -0
  133. package/dist/server/src/lib/cmate-parser.js +262 -0
  134. package/dist/server/src/lib/db-instance.js +3 -0
  135. package/dist/server/src/lib/db-migrations.js +145 -2
  136. package/dist/server/src/lib/db.js +51 -1
  137. package/dist/server/src/lib/env-sanitizer.js +57 -0
  138. package/dist/server/src/lib/prompt-detector.js +4 -3
  139. package/dist/server/src/lib/response-poller.js +22 -11
  140. package/dist/server/src/lib/schedule-manager.js +401 -0
  141. package/dist/server/src/lib/selected-agents-validator.js +99 -0
  142. package/dist/server/src/types/cmate.js +6 -0
  143. package/dist/server/src/types/sidebar.js +9 -4
  144. package/package.json +2 -1
  145. package/.next/server/chunks/7536.js +0 -1
  146. package/.next/static/chunks/8091-925542bdfc843dce.js +0 -1
  147. package/.next/static/chunks/app/page-238b5a70d8c101e9.js +0 -1
  148. package/.next/static/chunks/app/worktrees/[id]/page-a556551ce5c69dec.js +0 -1
  149. package/.next/static/css/b9ea6a4fad17dc32.css +0 -3
  150. /package/.next/static/{hmAjbCPjxX_C0Os7rphI1 → O7EDFfAYQNe_HRbORxQAC}/_buildManifest.js +0 -0
  151. /package/.next/static/{hmAjbCPjxX_C0Os7rphI1 → O7EDFfAYQNe_HRbORxQAC}/_ssgManifest.js +0 -0
@@ -11,4 +11,4 @@ This repository will be added to the exclusion list.
11
11
  It will NOT be re-registered when you run "Sync All".
12
12
  You can restore it from the excluded repositories list.
13
13
 
14
- Type "delete" to confirm:`)){C(e);try{await m.J1.delete(e),f===e&&v(null),await R(),await L()}catch(e){x((0,m.zG)(e))}finally{C(null)}}};return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsxs)(i.Ct,{variant:"gray",children:[t.length," branches"]}),l.length>0&&(0,a.jsxs)(i.Ct,{variant:"info",children:[l.length," ",1===l.length?"repository":"repositories"]}),"connected"===M&&a.jsx(i.Ct,{variant:"success",dot:!0,children:"Live"})]}),a.jsx("div",{className:"flex gap-2 w-full sm:w-auto",children:a.jsx(i.zx,{variant:"secondary",size:"sm",onClick:()=>R(),disabled:o,children:o?"Loading...":"Refresh"})})]}),a.jsx("div",{className:"flex flex-col sm:flex-row gap-3",children:a.jsx("input",{type:"text",placeholder:"Search worktrees...",value:u,onChange:e=>h(e.target.value),className:"input flex-1"})}),l.length>0&&(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap items-center",children:[(0,a.jsxs)(i.zx,{variant:null===f?"primary":"ghost",size:"sm",onClick:()=>v(null),children:["All (",t.length,")"]}),l.map(e=>(0,a.jsxs)("div",{className:"relative group inline-flex items-center",children:[(0,a.jsxs)(i.zx,{variant:f===e.path?"primary":"ghost",size:"sm",onClick:()=>v(e.path),className:"pr-6",children:[e.name," (",e.worktreeCount,")"]}),a.jsx("button",{className:"absolute right-1 opacity-0 group-hover:opacity-100 text-gray-400 hover:text-red-500 transition-opacity px-1",onClick:t=>{t.stopPropagation(),F(e.path,e.name)},disabled:k===e.path,title:"Delete repository",children:k===e.path?"...":"x"})]},e.path))]}),(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap items-center",children:[a.jsx(i.zx,{variant:null===N?"primary":"ghost",size:"sm",onClick:()=>w(null),children:"All"}),a.jsx(i.zx,{variant:"todo"===N?"primary":"ghost",size:"sm",onClick:()=>w("todo"),children:"\uD83D\uDCDD ToDo"}),a.jsx(i.zx,{variant:"doing"===N?"primary":"ghost",size:"sm",onClick:()=>w("doing"),children:"\uD83D\uDEA7 Doing"}),a.jsx(i.zx,{variant:"done"===N?"primary":"ghost",size:"sm",onClick:()=>w("done"),children:"✅ Done"}),a.jsx(i.zx,{variant:"unset"===N?"primary":"ghost",size:"sm",onClick:()=>w("unset"),children:"Not set"})]}),(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[a.jsx("span",{className:"text-sm text-gray-600 self-center",children:"Sort by:"}),(0,a.jsxs)(i.zx,{variant:"favorite"===g?"primary":"ghost",size:"sm",onClick:()=>_("favorite"),children:["⭐ Favorite ","favorite"===g&&("asc"===b?"↑":"↓")]}),(0,a.jsxs)(i.zx,{variant:"name"===g?"primary":"ghost",size:"sm",onClick:()=>_("name"),children:["Name ","name"===g&&("asc"===b?"↑":"↓")]}),(0,a.jsxs)(i.zx,{variant:"updated"===g?"primary":"ghost",size:"sm",onClick:()=>_("updated"),children:["Updated ","updated"===g&&("asc"===b?"↑":"↓")]})]}),c&&a.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:a.jsx("p",{className:"text-sm text-red-800",children:c})}),o&&!t.length&&(0,a.jsxs)("div",{className:"text-center py-12",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"}),a.jsx("p",{className:"mt-4 text-gray-600",children:"Loading worktrees..."})]}),!o&&!c&&0===E.length&&(0,a.jsxs)("div",{className:"text-center py-12",children:[a.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),a.jsx("p",{className:"mt-4 text-gray-600",children:u?"No worktrees found matching your search":"No worktrees found"})]}),!o&&E.length>0&&a.jsx("div",{className:"space-y-8",children:Array.from(I.entries()).map(([e,t])=>{let s=l.find(t=>t.path===e),r=s?.name||"Unknown Repository";return(0,a.jsxs)("div",{className:"space-y-4",children:[(l.length>1||!f)&&(0,a.jsxs)("div",{className:"flex items-center gap-3 pb-2 border-b border-gray-200",children:[a.jsx("h3",{className:"text-xl font-semibold text-gray-900",children:r}),a.jsx(i.Ct,{variant:"gray",children:t.length})]}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:t.map(e=>a.jsx(p,{worktree:e,onSessionKilled:R,onStatusChanged:R},e.id))})]},e)})}),S.length>0&&(0,a.jsxs)("div",{className:"border border-gray-200 rounded-lg",children:[(0,a.jsxs)("button",{className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 transition-colors",onClick:()=>A(!z),children:[(0,a.jsxs)("span",{className:"text-sm font-medium text-gray-700",children:["Excluded Repositories (",S.length,")"]}),a.jsx("span",{className:"text-gray-400 text-sm",children:z?"Hide":"Show"})]}),z&&a.jsx("div",{className:"border-t border-gray-200 divide-y divide-gray-100",children:S.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,a.jsxs)("div",{children:[a.jsx("span",{className:"text-sm font-medium text-gray-700",children:e.name}),a.jsx("span",{className:"text-xs text-gray-500 ml-2",children:e.path})]}),a.jsx(i.zx,{variant:"secondary",size:"sm",onClick:()=>O(e.path),disabled:$===e.path,children:$===e.path?"Restoring...":"Restore"})]},e.id))})]})]})}s(35047),s(43053),s(15470),s(11867);class h{constructor(){}static getInstance(){return h.instance||(h.instance=new h),h.instance}normalize(e){let t=e.match(/^ssh:\/\/git@([^:\/]+)(:\d+)?\/(.+?)(\.git)?$/);if(t)return`https://${t[1]}/${t[3]}`.toLowerCase().replace(/\/$/,"");let s=e.match(/^git@([^:]+):(.+?)(\.git)?$/);return s?`https://${s[1]}/${s[2]}`.toLowerCase().replace(/\/$/,""):e.replace(/\.git\/?$/,"").replace(/\/$/,"").toLowerCase()}isSameRepository(e,t){return this.normalize(e)===this.normalize(t)}extractRepoName(e){let t=e.match(/^ssh:\/\/git@[^\/]+\/(.+?)(\.git)?$/);if(t){let e=t[1].split("/");return e[e.length-1]}let s=e.match(/:(.+?)(\.git)?$/);if(s&&e.startsWith("git@")){let e=s[1].split("/");return e[e.length-1]}let a=e.match(/\/([^\/]+?)(\.git)?$/);return a?a[1]:""}getUrlType(e){return e.startsWith("https://")?"https":e.startsWith("git@")||e.startsWith("ssh://")?"ssh":null}validate(e){if(!e||"string"!=typeof e||""===e.trim())return{valid:!1,error:"EMPTY_URL"};let t=e.trim();return t.startsWith("https://")?/^https:\/\/[^\/]+\/[^\/]+\/[^\/]+(\.git)?$/.test(t)?{valid:!0}:{valid:!1,error:"INVALID_URL_FORMAT"}:t.startsWith("git@")?/^git@[^:]+:.+\/.+(\.git)?$/.test(t)?{valid:!0}:{valid:!1,error:"INVALID_URL_FORMAT"}:t.startsWith("ssh://")&&/^ssh:\/\/git@[^\/]+(:\d+)?\/[^\/]+\/.+(\.git)?$/.test(t)?{valid:!0}:{valid:!1,error:"INVALID_URL_FORMAT"}}}function g({onRepositoryAdded:e}){let[t,s]=(0,r.useState)(!1),[l,n]=(0,r.useState)("local"),[o,d]=(0,r.useState)(""),[c,x]=(0,r.useState)(""),[p,u]=(0,r.useState)(!1),[g,y]=(0,r.useState)(!1),[b,j]=(0,r.useState)(!1),[f,v]=(0,r.useState)(null),[N,w]=(0,r.useState)(null),[k,C]=(0,r.useState)(null),S=h.getInstance(),P=(0,r.useCallback)(async t=>{try{let a=await m.J1.getCloneStatus(t);"completed"===a.status?(C("Repository cloned successfully"),j(!1),v(null),x(""),s(!1),e&&e()):"failed"===a.status?(w(a.error?.message||"Clone failed"),j(!1),v(null)):("running"===a.status||"pending"===a.status)&&setTimeout(()=>P(t),2e3)}catch(e){w((0,m.zG)(e)),j(!1),v(null)}},[e]),z=async t=>{if(t.preventDefault(),!o.trim()){w("Repository path is required");return}w(null),C(null),u(!0);try{let t=await m.J1.scan(o);C(t.message),d(""),s(!1),e&&e()}catch(e){w((0,m.zG)(e))}finally{u(!1)}},A=async e=>{if(e.preventDefault(),!c.trim()){w("Clone URL is required");return}let t=S.validate(c.trim());if(!t.valid){"EMPTY_URL"===t.error?w("Clone URL is required"):w("Invalid URL format");return}w(null),C(null),j(!0);try{let e=await m.J1.clone(c.trim());v(e.jobId)}catch(e){w((0,m.zG)(e)),j(!1)}},$=async()=>{w(null),C(null),y(!0);try{let t=await m.J1.sync();C(t.message),e&&e()}catch(e){w((0,m.zG)(e))}finally{y(!1)}},T=()=>{s(!1),d(""),x(""),w(null),n("local")};return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[!t&&a.jsx(i.zx,{variant:"primary",size:"sm",onClick:()=>s(!0),children:"+ Add Repository"}),a.jsx(i.zx,{variant:"secondary",size:"sm",onClick:$,disabled:g,children:g?"Syncing...":"Sync All"})]}),t&&a.jsx(i.Zb,{padding:"lg",children:(0,a.jsxs)("div",{className:"space-y-4",children:[a.jsx("div",{children:a.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Add New Repository"})}),(0,a.jsxs)("div",{className:"flex border-b border-gray-200",role:"tablist",children:[a.jsx("button",{role:"tab","aria-selected":"local"===l,onClick:()=>n("local"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${"local"===l?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"Local Path"}),a.jsx("button",{role:"tab","aria-selected":"url"===l,onClick:()=>n("url"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${"url"===l?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"Clone URL"})]}),"local"===l&&(0,a.jsxs)("form",{onSubmit:z,className:"space-y-4",children:[(0,a.jsxs)("div",{children:[a.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Enter the absolute path to a git repository containing worktrees."}),a.jsx("label",{htmlFor:"repositoryPath",className:"block text-sm font-medium text-gray-700 mb-2",children:"Repository Path"}),a.jsx("input",{id:"repositoryPath",type:"text",value:o,onChange:e=>d(e.target.value),placeholder:"/absolute/path/to/repository",className:"input w-full font-mono text-sm",disabled:p}),a.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Example: /Users/username/projects/my-repo"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx(i.zx,{type:"submit",variant:"primary",disabled:p||!o.trim(),children:p?"Scanning...":"Scan & Add"}),a.jsx(i.zx,{type:"button",variant:"ghost",onClick:T,disabled:p,children:"Cancel"})]})]}),"url"===l&&(0,a.jsxs)("form",{onSubmit:A,className:"space-y-4",children:[(0,a.jsxs)("div",{children:[a.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Enter a git clone URL to clone a remote repository."}),a.jsx("label",{htmlFor:"cloneUrl",className:"block text-sm font-medium text-gray-700 mb-2",children:"Clone URL"}),a.jsx("input",{id:"cloneUrl",type:"text",value:c,onChange:e=>x(e.target.value),placeholder:"https://github.com/user/repo.git",className:"input w-full font-mono text-sm",disabled:b}),a.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Supports HTTPS and SSH URLs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx(i.zx,{type:"submit",variant:"primary",disabled:b||!c.trim(),children:b?"Cloning...":"Clone"}),a.jsx(i.zx,{type:"button",variant:"ghost",onClick:T,disabled:b,children:"Cancel"})]})]})]})}),k&&a.jsx("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:a.jsx("p",{className:"text-sm text-green-800",children:k})}),N&&a.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:a.jsx("p",{className:"text-sm text-red-800",children:N})})]})}function y({appId:e,pollInterval:t=3e4,showResponseTime:s=!1,compact:l=!1}){let[n,i]=(0,r.useState)(null),[o,d]=(0,r.useState)(!0);if((0,r.useCallback)(async()=>{try{let t=await fetch(`/api/external-apps/${e}/health`);if(t.ok){let e=await t.json();i(e)}else i({id:e,healthy:!1,lastChecked:Date.now(),error:"Failed to check health"})}catch{i({id:e,healthy:!1,lastChecked:Date.now(),error:"Network error"})}finally{d(!1)}},[e]),o)return(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full bg-gray-300 animate-pulse"}),!l&&a.jsx("span",{className:"text-xs text-gray-400",children:"Checking..."})]});let c=n?.healthy??!1,x=c?"bg-green-500":"bg-gray-400",m=c?"Running":"Stopped";return l?a.jsx("span",{className:`inline-block h-2.5 w-2.5 rounded-full ${x}`,title:m}):(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:`inline-block h-2.5 w-2.5 rounded-full ${x}`}),a.jsx("span",{className:`text-xs ${c?"text-green-600":"text-gray-500"}`,children:m}),s&&n?.responseTime!==void 0&&(0,a.jsxs)("span",{className:"text-xs text-gray-400",children:["(",n.responseTime,"ms)"]})]})}function b({app:e,onEdit:t,onDelete:s}){var l;let[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(!1),x=async()=>{c(!0);try{await s(e.id)}finally{c(!1),o(!1)}},m=`/proxy/${e.pathPrefix}/`;return(0,a.jsxs)(i.Zb,{padding:"md",className:"relative",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[a.jsx("h4",{className:"text-base font-semibold text-gray-900 truncate",children:e.displayName}),a.jsx("p",{className:"text-xs text-gray-500 mt-0.5 font-mono truncate",children:e.name})]}),a.jsx(i.Ct,{variant:{sveltekit:"warning",streamlit:"error",nextjs:"info",other:"gray"}[e.appType]||"gray",children:{sveltekit:"SvelteKit",streamlit:"Streamlit",nextjs:"Next.js",other:"Other"}[l=e.appType]||l})]}),(0,a.jsxs)("div",{className:"space-y-2 mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-600",children:"Status"}),a.jsx(y,{appId:e.id,pollInterval:3e4})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-600",children:"Port"}),(0,a.jsxs)("span",{className:"text-sm font-mono text-gray-900",children:[":",e.targetPort]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-600",children:"Path"}),(0,a.jsxs)("span",{className:"text-sm font-mono text-gray-900 truncate max-w-[150px]",children:["/proxy/",e.pathPrefix,"/"]})]}),e.websocketEnabled&&(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-600",children:"WebSocket"}),a.jsx(i.Ct,{variant:"info",children:"Enabled"})]}),!e.enabled&&a.jsx("div",{className:"mt-2 py-1 px-2 bg-yellow-50 border border-yellow-200 rounded text-xs text-yellow-700",children:"This app is disabled"})]}),n?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("p",{className:"text-sm text-gray-600",children:['Delete "',e.displayName,'"?']}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx(i.zx,{variant:"danger",size:"sm",onClick:x,disabled:d,loading:d,children:"Delete"}),a.jsx(i.zx,{variant:"ghost",size:"sm",onClick:()=>o(!1),disabled:d,children:"Cancel"})]})]}):(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[a.jsx(i.zx,{variant:"primary",size:"sm",onClick:()=>window.open(m,"_blank"),disabled:!e.enabled,children:"Open"}),a.jsx(i.zx,{variant:"secondary",size:"sm",onClick:()=>t(e),children:"Settings"}),a.jsx(i.zx,{variant:"ghost",size:"sm",onClick:()=>o(!0),className:"text-red-600 hover:bg-red-50",children:"Delete"})]})]})}let j={MIN:1024,MAX:65535},f=/^[a-zA-Z0-9-]+$/,v={sveltekit:"SvelteKit",streamlit:"Streamlit",nextjs:"Next.js",other:"Other"},N=["sveltekit","streamlit","nextjs","other"].map(e=>({value:e,label:v[e]}));function w({isOpen:e,onClose:t,editApp:s,onSave:l}){let n=!!s,[o,d]=(0,r.useState)(""),[c,x]=(0,r.useState)(""),[m,p]=(0,r.useState)(""),[u,h]=(0,r.useState)(""),[g,y]=(0,r.useState)(""),[b,v]=(0,r.useState)(!1),[w,k]=(0,r.useState)(""),[C,S]=(0,r.useState)(!0),[P,z]=(0,r.useState)({}),[A,$]=(0,r.useState)(!1),[T,L]=(0,r.useState)(null),R=async e=>{e.preventDefault(),L(null);let a=function(e,t){var s;let a={};return e.displayName?.trim()||(a.displayName="Display name is required"),t||(e.name?.trim()?f.test(e.name)||(a.name="Only alphanumeric characters and hyphens are allowed"):a.name="Identifier name is required",e.pathPrefix?.trim()?f.test(e.pathPrefix)||(a.pathPrefix="Only alphanumeric characters and hyphens are allowed"):a.pathPrefix="Path prefix is required"),e.targetPort?"number"!=typeof e.targetPort||Number.isInteger(s=e.targetPort)&&s>=j.MIN&&s<=j.MAX||(a.targetPort=`Port must be between ${j.MIN} and ${j.MAX}`):a.targetPort="Port number is required",t||e.appType||(a.appType="App type is required"),a}({displayName:o,name:c,pathPrefix:m,targetPort:u,appType:g},n);if(Object.keys(a).length>0){z(a);return}z({}),$(!0);try{if(n&&s){let e=await fetch(`/api/external-apps/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:o,description:w||void 0,targetPort:u||void 0,websocketEnabled:b,enabled:C})});if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to update app")}}else{let e=await fetch("/api/external-apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:o,name:c,pathPrefix:m,targetPort:u,appType:g,websocketEnabled:b,description:w||void 0})});if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to create app")}}l(),t()}catch(e){L(e instanceof Error?e.message:"An error occurred")}finally{$(!1)}};return a.jsx(i.u_,{isOpen:e,onClose:t,title:n?"Edit External App":"Add External App",size:"md",children:(0,a.jsxs)("form",{onSubmit:R,className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{htmlFor:"displayName",className:"block text-sm font-medium text-gray-700 mb-1",children:["Display Name ",a.jsx("span",{className:"text-red-500",children:"*"})]}),a.jsx("input",{id:"displayName",type:"text",value:o,onChange:e=>d(e.target.value),className:`input w-full ${P.displayName?"border-red-500":""}`,placeholder:"My App",disabled:A}),P.displayName&&a.jsx("p",{className:"mt-1 text-xs text-red-500",children:P.displayName})]}),!n&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-700 mb-1",children:["Identifier Name ",a.jsx("span",{className:"text-red-500",children:"*"})]}),a.jsx("input",{id:"name",type:"text",value:c,onChange:e=>x(e.target.value),className:`input w-full font-mono ${P.name?"border-red-500":""}`,placeholder:"my-app",disabled:A}),a.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Alphanumeric and hyphens only. Cannot be changed later."}),P.name&&a.jsx("p",{className:"mt-1 text-xs text-red-500",children:P.name})]}),!n&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{htmlFor:"pathPrefix",className:"block text-sm font-medium text-gray-700 mb-1",children:["Path Prefix ",a.jsx("span",{className:"text-red-500",children:"*"})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[a.jsx("span",{className:"text-sm text-gray-500 mr-1",children:"/proxy/"}),a.jsx("input",{id:"pathPrefix",type:"text",value:m,onChange:e=>p(e.target.value),className:`input flex-1 font-mono ${P.pathPrefix?"border-red-500":""}`,placeholder:"app-name",disabled:A}),a.jsx("span",{className:"text-sm text-gray-500 ml-1",children:"/"})]}),a.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"URL path for accessing this app. Cannot be changed later."}),P.pathPrefix&&a.jsx("p",{className:"mt-1 text-xs text-red-500",children:P.pathPrefix})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{htmlFor:"targetPort",className:"block text-sm font-medium text-gray-700 mb-1",children:["Port Number ",a.jsx("span",{className:"text-red-500",children:"*"})]}),a.jsx("input",{id:"targetPort",type:"number",value:u,onChange:e=>h(e.target.value?parseInt(e.target.value,10):""),className:`input w-full font-mono ${P.targetPort?"border-red-500":""}`,placeholder:"5173",min:j.MIN,max:j.MAX,disabled:A}),(0,a.jsxs)("p",{className:"mt-1 text-xs text-gray-500",children:["Target port (",j.MIN,"-",j.MAX,")"]}),P.targetPort&&a.jsx("p",{className:"mt-1 text-xs text-red-500",children:P.targetPort})]}),!n&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{htmlFor:"appType",className:"block text-sm font-medium text-gray-700 mb-1",children:["App Type ",a.jsx("span",{className:"text-red-500",children:"*"})]}),(0,a.jsxs)("select",{id:"appType",value:g,onChange:e=>y(e.target.value),className:`input w-full ${P.appType?"border-red-500":""}`,disabled:A,children:[a.jsx("option",{value:"",children:"Select app type..."}),N.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))]}),P.appType&&a.jsx("p",{className:"mt-1 text-xs text-red-500",children:P.appType})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-gray-700 mb-1",children:"Description"}),a.jsx("textarea",{id:"description",value:w,onChange:e=>k(e.target.value),className:"input w-full",placeholder:"Optional description...",rows:2,disabled:A})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[a.jsx("input",{id:"websocketEnabled",type:"checkbox",checked:b,onChange:e=>v(e.target.checked),className:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500",disabled:A}),a.jsx("label",{htmlFor:"websocketEnabled",className:"ml-2 text-sm text-gray-700",children:"Enable WebSocket support"})]}),n&&(0,a.jsxs)("div",{className:"flex items-center",children:[a.jsx("input",{id:"enabled",type:"checkbox",checked:C,onChange:e=>S(e.target.checked),className:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500",disabled:A}),a.jsx("label",{htmlFor:"enabled",className:"ml-2 text-sm text-gray-700",children:"App is enabled"})]}),T&&a.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded text-sm text-red-700",children:T}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 pt-4 border-t border-gray-200",children:[a.jsx(i.zx,{type:"button",variant:"ghost",onClick:t,disabled:A,children:"Cancel"}),a.jsx(i.zx,{type:"submit",variant:"primary",loading:A,children:n?"Save Changes":"Add App"})]})]})})}function k(){let[e,t]=(0,r.useState)([]),[s,l]=(0,r.useState)(!0),[n,o]=(0,r.useState)(null),[d,c]=(0,r.useState)(!1),[x,m]=(0,r.useState)(null),p=(0,r.useCallback)(async()=>{try{o(null);let e=await fetch("/api/external-apps");if(!e.ok)throw Error("Failed to fetch external apps");let s=await e.json();t(s.apps||[])}catch(e){o(e instanceof Error?e.message:"An error occurred")}finally{l(!1)}},[]),u=(0,r.useCallback)(e=>{m(e),c(!0)},[]),h=(0,r.useCallback)(()=>{m(null),c(!0)},[]),g=(0,r.useCallback)(async e=>{try{let t=await fetch(`/api/external-apps/${e}`,{method:"DELETE"});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to delete app")}p()}catch(e){console.error("Failed to delete app:",e)}},[p]),y=(0,r.useCallback)(()=>{p()},[p]),j=(0,r.useCallback)(()=>{c(!1),m(null)},[]);return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"External Apps"}),a.jsx(i.zx,{variant:"primary",size:"sm",onClick:h,children:"+ Add App"})]}),s?a.jsx(i.Zb,{padding:"lg",children:(0,a.jsxs)("div",{className:"flex items-center justify-center py-8",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),a.jsx("span",{className:"ml-3 text-gray-600",children:"Loading apps..."})]})}):n?a.jsx(i.Zb,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-8",children:[a.jsx("p",{className:"text-red-600 mb-4",children:"Failed to load external apps"}),a.jsx(i.zx,{variant:"secondary",size:"sm",onClick:p,children:"Retry"})]})}):0===e.length?a.jsx(i.Zb,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-8",children:[a.jsx("p",{className:"text-gray-500 mb-4",children:"No external apps registered yet."}),a.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Add an external app to proxy requests to other frontend applications."}),a.jsx(i.zx,{variant:"primary",size:"sm",onClick:h,children:"Add Your First App"})]})}):a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:e.map(e=>a.jsx(b,{app:e,onEdit:u,onDelete:g},e.id))}),a.jsx(w,{isOpen:d,onClose:j,editApp:x,onSave:y})]})}function C(){let[e,t]=(0,r.useState)(0),s=(0,r.useCallback)(()=>{t(e=>e+1)},[]);return a.jsx(l.Vw,{children:(0,a.jsxs)("div",{className:"container-custom py-8 overflow-auto h-full",children:[(0,a.jsxs)("div",{className:"mb-8",children:[a.jsx("h1",{className:"mb-2",children:"CommandMate"}),a.jsx("p",{className:"text-lg text-gray-600",children:"Git worktree management with Claude CLI and tmux sessions"})]}),a.jsx("div",{className:"mb-8",children:a.jsx(g,{onRepositoryAdded:s})}),a.jsx(u,{},e),a.jsx("div",{className:"mt-8",children:a.jsx(k,{})})]})})}},35480:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>a});let a=(0,s(68570).createProxy)(String.raw`/home/runner/work/CommandMate/CommandMate/src/app/page.tsx#default`)},6162:(e,t,s)=>{"use strict";s.d(t,{T:()=>l});var a=s(34643);function r(e,t){return(...e)=>{try{return t(...e)}catch{throw Error(void 0)}}}let l=r(0,a.T_);r(0,a.Gb)}};var t=require("../webpack-runtime.js");t.C(e);var s=e=>t(t.s=e),a=t.X(0,[8948,3294,6621,8705,7808,3860,539],()=>s(37906));module.exports=a})();
14
+ Type "delete" to confirm:`)){C(e);try{await m.J1.delete(e),f===e&&v(null),await R(),await L()}catch(e){x((0,m.zG)(e))}finally{C(null)}}};return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsxs)(i.Ct,{variant:"gray",children:[t.length," branches"]}),l.length>0&&(0,a.jsxs)(i.Ct,{variant:"info",children:[l.length," ",1===l.length?"repository":"repositories"]}),"connected"===M&&a.jsx(i.Ct,{variant:"success",dot:!0,children:"Live"})]}),a.jsx("div",{className:"flex gap-2 w-full sm:w-auto",children:a.jsx(i.zx,{variant:"secondary",size:"sm",onClick:()=>R(),disabled:o,children:o?"Loading...":"Refresh"})})]}),a.jsx("div",{className:"flex flex-col sm:flex-row gap-3",children:a.jsx("input",{type:"text",placeholder:"Search worktrees...",value:u,onChange:e=>h(e.target.value),className:"input flex-1"})}),l.length>0&&(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap items-center",children:[(0,a.jsxs)(i.zx,{variant:null===f?"primary":"ghost",size:"sm",onClick:()=>v(null),children:["All (",t.length,")"]}),l.map(e=>(0,a.jsxs)("div",{className:"relative group inline-flex items-center",children:[(0,a.jsxs)(i.zx,{variant:f===e.path?"primary":"ghost",size:"sm",onClick:()=>v(e.path),className:"pr-6",children:[e.name," (",e.worktreeCount,")"]}),a.jsx("button",{className:"absolute right-1 opacity-0 group-hover:opacity-100 text-gray-400 hover:text-red-500 transition-opacity px-1",onClick:t=>{t.stopPropagation(),F(e.path,e.name)},disabled:k===e.path,title:"Delete repository",children:k===e.path?"...":"x"})]},e.path))]}),(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap items-center",children:[a.jsx(i.zx,{variant:null===N?"primary":"ghost",size:"sm",onClick:()=>w(null),children:"All"}),a.jsx(i.zx,{variant:"todo"===N?"primary":"ghost",size:"sm",onClick:()=>w("todo"),children:"\uD83D\uDCDD ToDo"}),a.jsx(i.zx,{variant:"doing"===N?"primary":"ghost",size:"sm",onClick:()=>w("doing"),children:"\uD83D\uDEA7 Doing"}),a.jsx(i.zx,{variant:"done"===N?"primary":"ghost",size:"sm",onClick:()=>w("done"),children:"✅ Done"}),a.jsx(i.zx,{variant:"unset"===N?"primary":"ghost",size:"sm",onClick:()=>w("unset"),children:"Not set"})]}),(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[a.jsx("span",{className:"text-sm text-gray-600 self-center",children:"Sort by:"}),(0,a.jsxs)(i.zx,{variant:"favorite"===g?"primary":"ghost",size:"sm",onClick:()=>_("favorite"),children:["⭐ Favorite ","favorite"===g&&("asc"===b?"↑":"↓")]}),(0,a.jsxs)(i.zx,{variant:"name"===g?"primary":"ghost",size:"sm",onClick:()=>_("name"),children:["Name ","name"===g&&("asc"===b?"↑":"↓")]}),(0,a.jsxs)(i.zx,{variant:"updated"===g?"primary":"ghost",size:"sm",onClick:()=>_("updated"),children:["Updated ","updated"===g&&("asc"===b?"↑":"↓")]})]}),c&&a.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:a.jsx("p",{className:"text-sm text-red-800",children:c})}),o&&!t.length&&(0,a.jsxs)("div",{className:"text-center py-12",children:[a.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-gray-300 border-t-blue-600"}),a.jsx("p",{className:"mt-4 text-gray-600",children:"Loading worktrees..."})]}),!o&&!c&&0===E.length&&(0,a.jsxs)("div",{className:"text-center py-12",children:[a.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),a.jsx("p",{className:"mt-4 text-gray-600",children:u?"No worktrees found matching your search":"No worktrees found"})]}),!o&&E.length>0&&a.jsx("div",{className:"space-y-8",children:Array.from(I.entries()).map(([e,t])=>{let s=l.find(t=>t.path===e),r=s?.name||"Unknown Repository";return(0,a.jsxs)("div",{className:"space-y-4",children:[(l.length>1||!f)&&(0,a.jsxs)("div",{className:"flex items-center gap-3 pb-2 border-b border-gray-200",children:[a.jsx("h3",{className:"text-xl font-semibold text-gray-900",children:r}),a.jsx(i.Ct,{variant:"gray",children:t.length})]}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:t.map(e=>a.jsx(p,{worktree:e,onSessionKilled:R,onStatusChanged:R},e.id))})]},e)})}),S.length>0&&(0,a.jsxs)("div",{className:"border border-gray-200 rounded-lg",children:[(0,a.jsxs)("button",{className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 transition-colors",onClick:()=>A(!z),children:[(0,a.jsxs)("span",{className:"text-sm font-medium text-gray-700",children:["Excluded Repositories (",S.length,")"]}),a.jsx("span",{className:"text-gray-400 text-sm",children:z?"Hide":"Show"})]}),z&&a.jsx("div",{className:"border-t border-gray-200 divide-y divide-gray-100",children:S.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,a.jsxs)("div",{children:[a.jsx("span",{className:"text-sm font-medium text-gray-700",children:e.name}),a.jsx("span",{className:"text-xs text-gray-500 ml-2",children:e.path})]}),a.jsx(i.zx,{variant:"secondary",size:"sm",onClick:()=>O(e.path),disabled:$===e.path,children:$===e.path?"Restoring...":"Restore"})]},e.id))})]})]})}s(35047),s(2491),s(43053),s(15470),s(11867);class h{constructor(){}static getInstance(){return h.instance||(h.instance=new h),h.instance}normalize(e){let t=e.match(/^ssh:\/\/git@([^:\/]+)(:\d+)?\/(.+?)(\.git)?$/);if(t)return`https://${t[1]}/${t[3]}`.toLowerCase().replace(/\/$/,"");let s=e.match(/^git@([^:]+):(.+?)(\.git)?$/);return s?`https://${s[1]}/${s[2]}`.toLowerCase().replace(/\/$/,""):e.replace(/\.git\/?$/,"").replace(/\/$/,"").toLowerCase()}isSameRepository(e,t){return this.normalize(e)===this.normalize(t)}extractRepoName(e){let t=e.match(/^ssh:\/\/git@[^\/]+\/(.+?)(\.git)?$/);if(t){let e=t[1].split("/");return e[e.length-1]}let s=e.match(/:(.+?)(\.git)?$/);if(s&&e.startsWith("git@")){let e=s[1].split("/");return e[e.length-1]}let a=e.match(/\/([^\/]+?)(\.git)?$/);return a?a[1]:""}getUrlType(e){return e.startsWith("https://")?"https":e.startsWith("git@")||e.startsWith("ssh://")?"ssh":null}validate(e){if(!e||"string"!=typeof e||""===e.trim())return{valid:!1,error:"EMPTY_URL"};let t=e.trim();return t.startsWith("https://")?/^https:\/\/[^\/]+\/[^\/]+\/[^\/]+(\.git)?$/.test(t)?{valid:!0}:{valid:!1,error:"INVALID_URL_FORMAT"}:t.startsWith("git@")?/^git@[^:]+:.+\/.+(\.git)?$/.test(t)?{valid:!0}:{valid:!1,error:"INVALID_URL_FORMAT"}:t.startsWith("ssh://")&&/^ssh:\/\/git@[^\/]+(:\d+)?\/[^\/]+\/.+(\.git)?$/.test(t)?{valid:!0}:{valid:!1,error:"INVALID_URL_FORMAT"}}}function g({onRepositoryAdded:e}){let[t,s]=(0,r.useState)(!1),[l,n]=(0,r.useState)("local"),[o,d]=(0,r.useState)(""),[c,x]=(0,r.useState)(""),[p,u]=(0,r.useState)(!1),[g,y]=(0,r.useState)(!1),[b,j]=(0,r.useState)(!1),[f,v]=(0,r.useState)(null),[N,w]=(0,r.useState)(null),[k,C]=(0,r.useState)(null),S=h.getInstance(),P=(0,r.useCallback)(async t=>{try{let a=await m.J1.getCloneStatus(t);"completed"===a.status?(C("Repository cloned successfully"),j(!1),v(null),x(""),s(!1),e&&e()):"failed"===a.status?(w(a.error?.message||"Clone failed"),j(!1),v(null)):("running"===a.status||"pending"===a.status)&&setTimeout(()=>P(t),2e3)}catch(e){w((0,m.zG)(e)),j(!1),v(null)}},[e]),z=async t=>{if(t.preventDefault(),!o.trim()){w("Repository path is required");return}w(null),C(null),u(!0);try{let t=await m.J1.scan(o);C(t.message),d(""),s(!1),e&&e()}catch(e){w((0,m.zG)(e))}finally{u(!1)}},A=async e=>{if(e.preventDefault(),!c.trim()){w("Clone URL is required");return}let t=S.validate(c.trim());if(!t.valid){"EMPTY_URL"===t.error?w("Clone URL is required"):w("Invalid URL format");return}w(null),C(null),j(!0);try{let e=await m.J1.clone(c.trim());v(e.jobId)}catch(e){w((0,m.zG)(e)),j(!1)}},$=async()=>{w(null),C(null),y(!0);try{let t=await m.J1.sync();C(t.message),e&&e()}catch(e){w((0,m.zG)(e))}finally{y(!1)}},T=()=>{s(!1),d(""),x(""),w(null),n("local")};return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[!t&&a.jsx(i.zx,{variant:"primary",size:"sm",onClick:()=>s(!0),children:"+ Add Repository"}),a.jsx(i.zx,{variant:"secondary",size:"sm",onClick:$,disabled:g,children:g?"Syncing...":"Sync All"})]}),t&&a.jsx(i.Zb,{padding:"lg",children:(0,a.jsxs)("div",{className:"space-y-4",children:[a.jsx("div",{children:a.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Add New Repository"})}),(0,a.jsxs)("div",{className:"flex border-b border-gray-200",role:"tablist",children:[a.jsx("button",{role:"tab","aria-selected":"local"===l,onClick:()=>n("local"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${"local"===l?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"Local Path"}),a.jsx("button",{role:"tab","aria-selected":"url"===l,onClick:()=>n("url"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${"url"===l?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"Clone URL"})]}),"local"===l&&(0,a.jsxs)("form",{onSubmit:z,className:"space-y-4",children:[(0,a.jsxs)("div",{children:[a.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Enter the absolute path to a git repository containing worktrees."}),a.jsx("label",{htmlFor:"repositoryPath",className:"block text-sm font-medium text-gray-700 mb-2",children:"Repository Path"}),a.jsx("input",{id:"repositoryPath",type:"text",value:o,onChange:e=>d(e.target.value),placeholder:"/absolute/path/to/repository",className:"input w-full font-mono text-sm",disabled:p}),a.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Example: /Users/username/projects/my-repo"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx(i.zx,{type:"submit",variant:"primary",disabled:p||!o.trim(),children:p?"Scanning...":"Scan & Add"}),a.jsx(i.zx,{type:"button",variant:"ghost",onClick:T,disabled:p,children:"Cancel"})]})]}),"url"===l&&(0,a.jsxs)("form",{onSubmit:A,className:"space-y-4",children:[(0,a.jsxs)("div",{children:[a.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Enter a git clone URL to clone a remote repository."}),a.jsx("label",{htmlFor:"cloneUrl",className:"block text-sm font-medium text-gray-700 mb-2",children:"Clone URL"}),a.jsx("input",{id:"cloneUrl",type:"text",value:c,onChange:e=>x(e.target.value),placeholder:"https://github.com/user/repo.git",className:"input w-full font-mono text-sm",disabled:b}),a.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Supports HTTPS and SSH URLs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx(i.zx,{type:"submit",variant:"primary",disabled:b||!c.trim(),children:b?"Cloning...":"Clone"}),a.jsx(i.zx,{type:"button",variant:"ghost",onClick:T,disabled:b,children:"Cancel"})]})]})]})}),k&&a.jsx("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:a.jsx("p",{className:"text-sm text-green-800",children:k})}),N&&a.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:a.jsx("p",{className:"text-sm text-red-800",children:N})})]})}function y({appId:e,pollInterval:t=3e4,showResponseTime:s=!1,compact:l=!1}){let[n,i]=(0,r.useState)(null),[o,d]=(0,r.useState)(!0);if((0,r.useCallback)(async()=>{try{let t=await fetch(`/api/external-apps/${e}/health`);if(t.ok){let e=await t.json();i(e)}else i({id:e,healthy:!1,lastChecked:Date.now(),error:"Failed to check health"})}catch{i({id:e,healthy:!1,lastChecked:Date.now(),error:"Network error"})}finally{d(!1)}},[e]),o)return(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full bg-gray-300 animate-pulse"}),!l&&a.jsx("span",{className:"text-xs text-gray-400",children:"Checking..."})]});let c=n?.healthy??!1,x=c?"bg-green-500":"bg-gray-400",m=c?"Running":"Stopped";return l?a.jsx("span",{className:`inline-block h-2.5 w-2.5 rounded-full ${x}`,title:m}):(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:`inline-block h-2.5 w-2.5 rounded-full ${x}`}),a.jsx("span",{className:`text-xs ${c?"text-green-600":"text-gray-500"}`,children:m}),s&&n?.responseTime!==void 0&&(0,a.jsxs)("span",{className:"text-xs text-gray-400",children:["(",n.responseTime,"ms)"]})]})}function b({app:e,onEdit:t,onDelete:s}){var l;let[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(!1),x=async()=>{c(!0);try{await s(e.id)}finally{c(!1),o(!1)}},m=`/proxy/${e.pathPrefix}/`;return(0,a.jsxs)(i.Zb,{padding:"md",className:"relative",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[a.jsx("h4",{className:"text-base font-semibold text-gray-900 truncate",children:e.displayName}),a.jsx("p",{className:"text-xs text-gray-500 mt-0.5 font-mono truncate",children:e.name})]}),a.jsx(i.Ct,{variant:{sveltekit:"warning",streamlit:"error",nextjs:"info",other:"gray"}[e.appType]||"gray",children:{sveltekit:"SvelteKit",streamlit:"Streamlit",nextjs:"Next.js",other:"Other"}[l=e.appType]||l})]}),(0,a.jsxs)("div",{className:"space-y-2 mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-600",children:"Status"}),a.jsx(y,{appId:e.id,pollInterval:3e4})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-600",children:"Port"}),(0,a.jsxs)("span",{className:"text-sm font-mono text-gray-900",children:[":",e.targetPort]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-600",children:"Path"}),(0,a.jsxs)("span",{className:"text-sm font-mono text-gray-900 truncate max-w-[150px]",children:["/proxy/",e.pathPrefix,"/"]})]}),e.websocketEnabled&&(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-600",children:"WebSocket"}),a.jsx(i.Ct,{variant:"info",children:"Enabled"})]}),!e.enabled&&a.jsx("div",{className:"mt-2 py-1 px-2 bg-yellow-50 border border-yellow-200 rounded text-xs text-yellow-700",children:"This app is disabled"})]}),n?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("p",{className:"text-sm text-gray-600",children:['Delete "',e.displayName,'"?']}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx(i.zx,{variant:"danger",size:"sm",onClick:x,disabled:d,loading:d,children:"Delete"}),a.jsx(i.zx,{variant:"ghost",size:"sm",onClick:()=>o(!1),disabled:d,children:"Cancel"})]})]}):(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[a.jsx(i.zx,{variant:"primary",size:"sm",onClick:()=>window.open(m,"_blank"),disabled:!e.enabled,children:"Open"}),a.jsx(i.zx,{variant:"secondary",size:"sm",onClick:()=>t(e),children:"Settings"}),a.jsx(i.zx,{variant:"ghost",size:"sm",onClick:()=>o(!0),className:"text-red-600 hover:bg-red-50",children:"Delete"})]})]})}let j={MIN:1024,MAX:65535},f=/^[a-zA-Z0-9-]+$/,v={sveltekit:"SvelteKit",streamlit:"Streamlit",nextjs:"Next.js",other:"Other"},N=["sveltekit","streamlit","nextjs","other"].map(e=>({value:e,label:v[e]}));function w({isOpen:e,onClose:t,editApp:s,onSave:l}){let n=!!s,[o,d]=(0,r.useState)(""),[c,x]=(0,r.useState)(""),[m,p]=(0,r.useState)(""),[u,h]=(0,r.useState)(""),[g,y]=(0,r.useState)(""),[b,v]=(0,r.useState)(!1),[w,k]=(0,r.useState)(""),[C,S]=(0,r.useState)(!0),[P,z]=(0,r.useState)({}),[A,$]=(0,r.useState)(!1),[T,L]=(0,r.useState)(null),R=async e=>{e.preventDefault(),L(null);let a=function(e,t){var s;let a={};return e.displayName?.trim()||(a.displayName="Display name is required"),t||(e.name?.trim()?f.test(e.name)||(a.name="Only alphanumeric characters and hyphens are allowed"):a.name="Identifier name is required",e.pathPrefix?.trim()?f.test(e.pathPrefix)||(a.pathPrefix="Only alphanumeric characters and hyphens are allowed"):a.pathPrefix="Path prefix is required"),e.targetPort?"number"!=typeof e.targetPort||Number.isInteger(s=e.targetPort)&&s>=j.MIN&&s<=j.MAX||(a.targetPort=`Port must be between ${j.MIN} and ${j.MAX}`):a.targetPort="Port number is required",t||e.appType||(a.appType="App type is required"),a}({displayName:o,name:c,pathPrefix:m,targetPort:u,appType:g},n);if(Object.keys(a).length>0){z(a);return}z({}),$(!0);try{if(n&&s){let e=await fetch(`/api/external-apps/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:o,description:w||void 0,targetPort:u||void 0,websocketEnabled:b,enabled:C})});if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to update app")}}else{let e=await fetch("/api/external-apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:o,name:c,pathPrefix:m,targetPort:u,appType:g,websocketEnabled:b,description:w||void 0})});if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to create app")}}l(),t()}catch(e){L(e instanceof Error?e.message:"An error occurred")}finally{$(!1)}};return a.jsx(i.u_,{isOpen:e,onClose:t,title:n?"Edit External App":"Add External App",size:"md",children:(0,a.jsxs)("form",{onSubmit:R,className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{htmlFor:"displayName",className:"block text-sm font-medium text-gray-700 mb-1",children:["Display Name ",a.jsx("span",{className:"text-red-500",children:"*"})]}),a.jsx("input",{id:"displayName",type:"text",value:o,onChange:e=>d(e.target.value),className:`input w-full ${P.displayName?"border-red-500":""}`,placeholder:"My App",disabled:A}),P.displayName&&a.jsx("p",{className:"mt-1 text-xs text-red-500",children:P.displayName})]}),!n&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-700 mb-1",children:["Identifier Name ",a.jsx("span",{className:"text-red-500",children:"*"})]}),a.jsx("input",{id:"name",type:"text",value:c,onChange:e=>x(e.target.value),className:`input w-full font-mono ${P.name?"border-red-500":""}`,placeholder:"my-app",disabled:A}),a.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Alphanumeric and hyphens only. Cannot be changed later."}),P.name&&a.jsx("p",{className:"mt-1 text-xs text-red-500",children:P.name})]}),!n&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{htmlFor:"pathPrefix",className:"block text-sm font-medium text-gray-700 mb-1",children:["Path Prefix ",a.jsx("span",{className:"text-red-500",children:"*"})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[a.jsx("span",{className:"text-sm text-gray-500 mr-1",children:"/proxy/"}),a.jsx("input",{id:"pathPrefix",type:"text",value:m,onChange:e=>p(e.target.value),className:`input flex-1 font-mono ${P.pathPrefix?"border-red-500":""}`,placeholder:"app-name",disabled:A}),a.jsx("span",{className:"text-sm text-gray-500 ml-1",children:"/"})]}),a.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"URL path for accessing this app. Cannot be changed later."}),P.pathPrefix&&a.jsx("p",{className:"mt-1 text-xs text-red-500",children:P.pathPrefix})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{htmlFor:"targetPort",className:"block text-sm font-medium text-gray-700 mb-1",children:["Port Number ",a.jsx("span",{className:"text-red-500",children:"*"})]}),a.jsx("input",{id:"targetPort",type:"number",value:u,onChange:e=>h(e.target.value?parseInt(e.target.value,10):""),className:`input w-full font-mono ${P.targetPort?"border-red-500":""}`,placeholder:"5173",min:j.MIN,max:j.MAX,disabled:A}),(0,a.jsxs)("p",{className:"mt-1 text-xs text-gray-500",children:["Target port (",j.MIN,"-",j.MAX,")"]}),P.targetPort&&a.jsx("p",{className:"mt-1 text-xs text-red-500",children:P.targetPort})]}),!n&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{htmlFor:"appType",className:"block text-sm font-medium text-gray-700 mb-1",children:["App Type ",a.jsx("span",{className:"text-red-500",children:"*"})]}),(0,a.jsxs)("select",{id:"appType",value:g,onChange:e=>y(e.target.value),className:`input w-full ${P.appType?"border-red-500":""}`,disabled:A,children:[a.jsx("option",{value:"",children:"Select app type..."}),N.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))]}),P.appType&&a.jsx("p",{className:"mt-1 text-xs text-red-500",children:P.appType})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-gray-700 mb-1",children:"Description"}),a.jsx("textarea",{id:"description",value:w,onChange:e=>k(e.target.value),className:"input w-full",placeholder:"Optional description...",rows:2,disabled:A})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[a.jsx("input",{id:"websocketEnabled",type:"checkbox",checked:b,onChange:e=>v(e.target.checked),className:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500",disabled:A}),a.jsx("label",{htmlFor:"websocketEnabled",className:"ml-2 text-sm text-gray-700",children:"Enable WebSocket support"})]}),n&&(0,a.jsxs)("div",{className:"flex items-center",children:[a.jsx("input",{id:"enabled",type:"checkbox",checked:C,onChange:e=>S(e.target.checked),className:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500",disabled:A}),a.jsx("label",{htmlFor:"enabled",className:"ml-2 text-sm text-gray-700",children:"App is enabled"})]}),T&&a.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded text-sm text-red-700",children:T}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 pt-4 border-t border-gray-200",children:[a.jsx(i.zx,{type:"button",variant:"ghost",onClick:t,disabled:A,children:"Cancel"}),a.jsx(i.zx,{type:"submit",variant:"primary",loading:A,children:n?"Save Changes":"Add App"})]})]})})}function k(){let[e,t]=(0,r.useState)([]),[s,l]=(0,r.useState)(!0),[n,o]=(0,r.useState)(null),[d,c]=(0,r.useState)(!1),[x,m]=(0,r.useState)(null),p=(0,r.useCallback)(async()=>{try{o(null);let e=await fetch("/api/external-apps");if(!e.ok)throw Error("Failed to fetch external apps");let s=await e.json();t(s.apps||[])}catch(e){o(e instanceof Error?e.message:"An error occurred")}finally{l(!1)}},[]),u=(0,r.useCallback)(e=>{m(e),c(!0)},[]),h=(0,r.useCallback)(()=>{m(null),c(!0)},[]),g=(0,r.useCallback)(async e=>{try{let t=await fetch(`/api/external-apps/${e}`,{method:"DELETE"});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to delete app")}p()}catch(e){console.error("Failed to delete app:",e)}},[p]),y=(0,r.useCallback)(()=>{p()},[p]),j=(0,r.useCallback)(()=>{c(!1),m(null)},[]);return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"External Apps"}),a.jsx(i.zx,{variant:"primary",size:"sm",onClick:h,children:"+ Add App"})]}),s?a.jsx(i.Zb,{padding:"lg",children:(0,a.jsxs)("div",{className:"flex items-center justify-center py-8",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),a.jsx("span",{className:"ml-3 text-gray-600",children:"Loading apps..."})]})}):n?a.jsx(i.Zb,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-8",children:[a.jsx("p",{className:"text-red-600 mb-4",children:"Failed to load external apps"}),a.jsx(i.zx,{variant:"secondary",size:"sm",onClick:p,children:"Retry"})]})}):0===e.length?a.jsx(i.Zb,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-8",children:[a.jsx("p",{className:"text-gray-500 mb-4",children:"No external apps registered yet."}),a.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Add an external app to proxy requests to other frontend applications."}),a.jsx(i.zx,{variant:"primary",size:"sm",onClick:h,children:"Add Your First App"})]})}):a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:e.map(e=>a.jsx(b,{app:e,onEdit:u,onDelete:g},e.id))}),a.jsx(w,{isOpen:d,onClose:j,editApp:x,onSave:y})]})}function C(){let[e,t]=(0,r.useState)(0),s=(0,r.useCallback)(()=>{t(e=>e+1)},[]);return a.jsx(l.Vw,{children:(0,a.jsxs)("div",{className:"container-custom py-8 overflow-auto h-full",children:[(0,a.jsxs)("div",{className:"mb-8",children:[a.jsx("h1",{className:"mb-2",children:"CommandMate"}),a.jsx("p",{className:"text-lg text-gray-600",children:"Git worktree management with Claude CLI and tmux sessions"})]}),a.jsx("div",{className:"mb-8",children:a.jsx(g,{onRepositoryAdded:s})}),a.jsx(u,{},e),a.jsx("div",{className:"mt-8",children:a.jsx(k,{})})]})})}},35480:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>a});let a=(0,s(68570).createProxy)(String.raw`/home/runner/work/CommandMate/CommandMate/src/app/page.tsx#default`)},6162:(e,t,s)=>{"use strict";s.d(t,{T:()=>l});var a=s(34643);function r(e,t){return(...e)=>{try{return t(...e)}catch{throw Error(void 0)}}}let l=r(0,a.T_);r(0,a.Gb)}};var t=require("../webpack-runtime.js");t.C(e);var s=e=>t(t.s=e),a=t.X(0,[8948,3294,6621,8705,7808,3860,539],()=>s(37906));module.exports=a})();
@@ -1 +1 @@
1
- {"version":1,"files":["../../../node_modules/next/dist/client/components/action-async-storage-instance.js","../../../node_modules/next/dist/client/components/action-async-storage.external.js","../../../node_modules/next/dist/client/components/async-local-storage.js","../../../node_modules/next/dist/client/components/request-async-storage-instance.js","../../../node_modules/next/dist/client/components/request-async-storage.external.js","../../../node_modules/next/dist/client/components/static-generation-async-storage-instance.js","../../../node_modules/next/dist/client/components/static-generation-async-storage.external.js","../../../node_modules/next/dist/compiled/@opentelemetry/api/index.js","../../../node_modules/next/dist/compiled/@opentelemetry/api/package.json","../../../node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js","../../../node_modules/next/dist/server/lib/trace/constants.js","../../../node_modules/next/dist/server/lib/trace/tracer.js","../../../node_modules/next/package.json","../../../package.json","../../package.json","../chunks/2683.js","../chunks/3074.js","../chunks/3294.js","../chunks/3348.js","../chunks/369.js","../chunks/3860.js","../chunks/4559.js","../chunks/539.js","../chunks/5795.js","../chunks/5823.js","../chunks/5853.js","../chunks/6621.js","../chunks/6837.js","../chunks/7266.js","../chunks/7808.js","../chunks/8705.js","../chunks/8744.js","../chunks/8948.js","../chunks/9582.js","../webpack-runtime.js","page_client-reference-manifest.js"]}
1
+ {"version":1,"files":["../../../node_modules/next/dist/client/components/action-async-storage-instance.js","../../../node_modules/next/dist/client/components/action-async-storage.external.js","../../../node_modules/next/dist/client/components/async-local-storage.js","../../../node_modules/next/dist/client/components/request-async-storage-instance.js","../../../node_modules/next/dist/client/components/request-async-storage.external.js","../../../node_modules/next/dist/client/components/static-generation-async-storage-instance.js","../../../node_modules/next/dist/client/components/static-generation-async-storage.external.js","../../../node_modules/next/dist/compiled/@opentelemetry/api/index.js","../../../node_modules/next/dist/compiled/@opentelemetry/api/package.json","../../../node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js","../../../node_modules/next/dist/server/lib/trace/constants.js","../../../node_modules/next/dist/server/lib/trace/tracer.js","../../../node_modules/next/package.json","../../../package.json","../../package.json","../chunks/2314.js","../chunks/2683.js","../chunks/3074.js","../chunks/3294.js","../chunks/3348.js","../chunks/369.js","../chunks/3860.js","../chunks/4559.js","../chunks/539.js","../chunks/5795.js","../chunks/5823.js","../chunks/5853.js","../chunks/6228.js","../chunks/6621.js","../chunks/6837.js","../chunks/7266.js","../chunks/7808.js","../chunks/8705.js","../chunks/8744.js","../chunks/8948.js","../chunks/9582.js","../webpack-runtime.js","page_client-reference-manifest.js"]}
@@ -1 +1 @@
1
- globalThis.__RSC_MANIFEST=(globalThis.__RSC_MANIFEST||{});globalThis.__RSC_MANIFEST["/page"]={"moduleLoading":{"prefix":"/_next/","crossOrigin":null},"ssrModuleMapping":{"80":{"*":{"id":"41868","name":"*","chunks":[],"async":false}},"4707":{"*":{"id":"79671","name":"*","chunks":[],"async":false}},"12846":{"*":{"id":"12994","name":"*","chunks":[],"async":false}},"18390":{"*":{"id":"74810","name":"*","chunks":[],"async":false}},"18828":{"*":{"id":"2108","name":"*","chunks":[],"async":false}},"19107":{"*":{"id":"96114","name":"*","chunks":[],"async":false}},"36423":{"*":{"id":"84759","name":"*","chunks":[],"async":false}},"38991":{"*":{"id":"24146","name":"*","chunks":[],"async":false}},"41845":{"*":{"id":"37398","name":"*","chunks":[],"async":false}},"50653":{"*":{"id":"84442","name":"*","chunks":[],"async":false}},"61060":{"*":{"id":"9727","name":"*","chunks":[],"async":false}},"66677":{"*":{"id":"42106","name":"*","chunks":[],"async":false}}},"edgeSSRModuleMapping":{},"clientModules":{"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/app-router.js":{"id":12846,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/app-router.js":{"id":12846,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/client-page.js":{"id":19107,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/client-page.js":{"id":19107,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/error-boundary.js":{"id":61060,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/error-boundary.js":{"id":61060,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/layout-router.js":{"id":4707,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/layout-router.js":{"id":4707,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/not-found-boundary.js":{"id":80,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/not-found-boundary.js":{"id":80,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/render-from-template-context.js":{"id":36423,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/render-from-template-context.js":{"id":36423,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/globals.css":{"id":2778,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","3185","static/chunks/app/layout-9110f9a5e41c6bf4.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/components/providers/AppProviders.tsx":{"id":18828,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","3185","static/chunks/app/layout-9110f9a5e41c6bf4.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/page.tsx":{"id":66677,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","216","static/chunks/216-f18f4a9d8b04a91e.js","2335","static/chunks/2335-98a211e00b94c7ac.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","8091","static/chunks/8091-925542bdfc843dce.js","1931","static/chunks/app/page-238b5a70d8c101e9.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/login/page.tsx":{"id":38991,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/files/[...path]/page.tsx":{"id":50653,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx":{"id":18390,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/terminal/page.tsx":{"id":41845,"name":"*","chunks":[],"async":false}},"entryCSSFiles":{"/home/runner/work/CommandMate/CommandMate/src/":[],"/home/runner/work/CommandMate/CommandMate/src/app/layout":["static/css/b9ea6a4fad17dc32.css"],"/home/runner/work/CommandMate/CommandMate/src/app/page":[]}}
1
+ globalThis.__RSC_MANIFEST=(globalThis.__RSC_MANIFEST||{});globalThis.__RSC_MANIFEST["/page"]={"moduleLoading":{"prefix":"/_next/","crossOrigin":null},"ssrModuleMapping":{"80":{"*":{"id":"41868","name":"*","chunks":[],"async":false}},"4707":{"*":{"id":"79671","name":"*","chunks":[],"async":false}},"12846":{"*":{"id":"12994","name":"*","chunks":[],"async":false}},"18828":{"*":{"id":"2108","name":"*","chunks":[],"async":false}},"19107":{"*":{"id":"96114","name":"*","chunks":[],"async":false}},"36423":{"*":{"id":"84759","name":"*","chunks":[],"async":false}},"38991":{"*":{"id":"24146","name":"*","chunks":[],"async":false}},"40991":{"*":{"id":"27247","name":"*","chunks":[],"async":false}},"41845":{"*":{"id":"37398","name":"*","chunks":[],"async":false}},"50653":{"*":{"id":"84442","name":"*","chunks":[],"async":false}},"61060":{"*":{"id":"9727","name":"*","chunks":[],"async":false}},"66677":{"*":{"id":"42106","name":"*","chunks":[],"async":false}}},"edgeSSRModuleMapping":{},"clientModules":{"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/app-router.js":{"id":12846,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/app-router.js":{"id":12846,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/client-page.js":{"id":19107,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/client-page.js":{"id":19107,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/error-boundary.js":{"id":61060,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/error-boundary.js":{"id":61060,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/layout-router.js":{"id":4707,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/layout-router.js":{"id":4707,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/not-found-boundary.js":{"id":80,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/not-found-boundary.js":{"id":80,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/render-from-template-context.js":{"id":36423,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/render-from-template-context.js":{"id":36423,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/globals.css":{"id":2778,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","3185","static/chunks/app/layout-9110f9a5e41c6bf4.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/components/providers/AppProviders.tsx":{"id":18828,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","3185","static/chunks/app/layout-9110f9a5e41c6bf4.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/login/page.tsx":{"id":38991,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/page.tsx":{"id":66677,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","216","static/chunks/216-f18f4a9d8b04a91e.js","2335","static/chunks/2335-98a211e00b94c7ac.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","8091","static/chunks/8091-274bc0716106e7fc.js","1931","static/chunks/app/page-060057e02b841125.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/files/[...path]/page.tsx":{"id":50653,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx":{"id":40991,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/terminal/page.tsx":{"id":41845,"name":"*","chunks":[],"async":false}},"entryCSSFiles":{"/home/runner/work/CommandMate/CommandMate/src/":[],"/home/runner/work/CommandMate/CommandMate/src/app/layout":["static/css/e85de230ef5ddc40.css"],"/home/runner/work/CommandMate/CommandMate/src/app/page":[]}}
@@ -1,4 +1,4 @@
1
- "use strict";(()=>{var e={};e.id=4650,e.ids=[4650],e.modules={85890:e=>{e.exports=require("better-sqlite3")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},84770:e=>{e.exports=require("crypto")},92048:e=>{e.exports=require("fs")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},6490:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>U,patchFetch:()=>v,requestAsyncStorage:()=>k,routeModule:()=>D,serverHooks:()=>$,staticGenerationAsyncStorage:()=>P});var a={};r.r(a),r.d(a,{DELETE:()=>A,GET:()=>g,PATCH:()=>T,POST:()=>b,PUT:()=>R,dynamic:()=>m});var n=r(49303),o=r(88716),s=r(60670),i=r(87070),p=r(97425),l=r(73068);let c={DEFAULT_MS:3e4},d=["host","connection","keep-alive","transfer-encoding","te","trailer","upgrade"],u=["transfer-encoding","connection","keep-alive"],h={BAD_GATEWAY:502,GATEWAY_TIMEOUT:504,UPGRADE_REQUIRED:426},f={GATEWAY_TIMEOUT:"The upstream server did not respond in time",BAD_GATEWAY:"Unable to connect to upstream server",UPGRADE_REQUIRED:"WebSocket connections are not supported through the proxy Route Handler"};async function _(e,t,r){let a=`http://${t.targetHost}:${t.targetPort}${r}`,n=new Headers;e.headers.forEach((e,t)=>{let r=t.toLowerCase();d.includes(r)||n.set(t,e)});try{let t=new AbortController,r=setTimeout(()=>t.abort(),c.DEFAULT_MS),o=await fetch(a,{method:e.method,headers:n,body:"GET"!==e.method&&"HEAD"!==e.method?e.body:void 0,signal:t.signal,duplex:"half"});clearTimeout(r);let s=new Headers;return o.headers.forEach((e,t)=>{let r=t.toLowerCase();u.includes(r)||s.set(t,e)}),new Response(o.body,{status:o.status,statusText:o.statusText,headers:s})}catch(e){if(e instanceof Error&&("AbortError"===e.name||"TimeoutError"===e.name))return new Response(JSON.stringify({error:"Gateway Timeout",message:f.GATEWAY_TIMEOUT}),{status:h.GATEWAY_TIMEOUT,headers:{"Content-Type":"application/json"}});return new Response(JSON.stringify({error:"Bad Gateway",message:f.BAD_GATEWAY}),{status:h.BAD_GATEWAY,headers:{"Content-Type":"application/json"}})}}async function E(e,t,r){let a=`ws://${t.targetHost}:${t.targetPort}${r}`;return new Response(JSON.stringify({error:"Upgrade Required",message:`${f.UPGRADE_REQUIRED}. Configure your WebSocket client to connect directly to ${a}`,directUrl:a}),{status:h.UPGRADE_REQUIRED,headers:{"Content-Type":"application/json",Upgrade:"websocket"}})}let w=(0,r(43895).h)("proxy");function x(e){let t=`[Proxy] ${e.method} /proxy/${e.pathPrefix}${e.path} -> ${e.statusCode} (${e.responseTime}ms)`;e.error?w.warn(t,{...e}):w.info(t,{...e})}let m="force-dynamic";async function y(e,t){let r=Date.now(),a=e.method,[n,...o]=t,s="/"+o.join("/");if(!n)return i.NextResponse.json({error:"Path prefix is required"},{status:400});try{let t=(0,p.n)(),o=(0,l.V_)(t),c=await o.getByPathPrefix(n);if(!c)return i.NextResponse.json({error:`No external app found for path prefix: ${n}`},{status:404});if(!c.enabled)return i.NextResponse.json({error:`External app "${c.displayName}" is currently disabled`},{status:503});if(function(e){let t=e.headers.get("upgrade");return t?.toLowerCase()==="websocket"}(e)){let t=await E(e,c,s),o={timestamp:Date.now(),pathPrefix:n,method:a,path:s,statusCode:t.status,responseTime:Date.now()-r,isWebSocket:!0};return x(o),t}let d=await _(e,c,s),u={timestamp:Date.now(),pathPrefix:n,method:a,path:s,statusCode:d.status,responseTime:Date.now()-r,isWebSocket:!1};return d.status>=400&&(u.error=`HTTP ${d.status}`),x(u),d}catch(e){return w.error(`[Proxy] ${a} /proxy/${n}${s} failed: ${e.message}`,{pathPrefix:n,method:a,path:s,error:e.message,stack:e.stack}),i.NextResponse.json({error:"Proxy error",message:e.message},{status:502})}}async function g(e,{params:t}){let{path:r}=await t;return y(e,r)}async function b(e,{params:t}){let{path:r}=await t;return y(e,r)}async function R(e,{params:t}){let{path:r}=await t;return y(e,r)}async function T(e,{params:t}){let{path:r}=await t;return y(e,r)}async function A(e,{params:t}){let{path:r}=await t;return y(e,r)}let D=new n.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/proxy/[...path]/route",pathname:"/proxy/[...path]",filename:"route",bundlePath:"app/proxy/[...path]/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/proxy/[...path]/route.ts",nextConfigOutput:"",userland:a}),{requestAsyncStorage:k,staticGenerationAsyncStorage:P,serverHooks:$}=D,U="/proxy/[...path]/route";function v(){return(0,s.patchFetch)({serverHooks:$,staticGenerationAsyncStorage:P})}},73068:(e,t,r)=>{r.d(t,{V_:()=>s});var a=r(51172);class n{constructor(e,t=3e4){this.cache=new Map,this.allAppsCache=null,this.lastRefresh=0,this.db=e,this.ttl=t}getTTL(){return this.ttl}isStale(){return Date.now()-this.lastRefresh>this.ttl}async refresh(){let e=(0,a.J6)(this.db);for(let t of(this.cache.clear(),e))this.cache.set(t.pathPrefix,t);this.allAppsCache=e,this.lastRefresh=Date.now()}async getByPathPrefix(e){return this.isStale()&&await this.refresh(),this.cache.get(e)??null}async getAll(){return this.isStale()&&await this.refresh(),this.allAppsCache??[]}invalidate(){this.cache.clear(),this.allAppsCache=null,this.lastRefresh=0}invalidateByIssueNo(e){this.invalidate()}}let o=null;function s(e){if(!o){if(!e)throw Error("Database instance required to initialize cache");o=new n(e)}return o}},51172:(e,t,r)=>{r.d(t,{F1:()=>p,J6:()=>u,JF:()=>i,j6:()=>s,ke:()=>l,uz:()=>c,vV:()=>d});var a=r(84770);class n extends Error{constructor(e,t,r){super(e),this.code=t,this.cause=r,this.name="ExternalAppDbError"}}function o(e){return{id:e.id,name:e.name,displayName:e.display_name,description:e.description??void 0,pathPrefix:e.path_prefix,targetPort:e.target_port,targetHost:e.target_host,appType:e.app_type,websocketEnabled:1===e.websocket_enabled,websocketPathPattern:e.websocket_path_pattern??void 0,enabled:1===e.enabled,createdAt:e.created_at,updatedAt:e.updated_at}}function s(e,t){let r=(0,a.randomUUID)(),o=Date.now(),s={name:t.name,display_name:t.displayName,description:t.description??null,path_prefix:t.pathPrefix,target_port:t.targetPort,target_host:t.targetHost??"localhost",app_type:t.appType,websocket_enabled:t.websocketEnabled?1:0,websocket_path_pattern:t.websocketPathPattern??null};try{return e.prepare(`
1
+ "use strict";(()=>{var e={};e.id=4650,e.ids=[4650],e.modules={85890:e=>{e.exports=require("better-sqlite3")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},84770:e=>{e.exports=require("crypto")},92048:e=>{e.exports=require("fs")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},6490:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>U,patchFetch:()=>v,requestAsyncStorage:()=>k,routeModule:()=>D,serverHooks:()=>$,staticGenerationAsyncStorage:()=>P});var a={};r.r(a),r.d(a,{DELETE:()=>A,GET:()=>g,PATCH:()=>T,POST:()=>b,PUT:()=>R,dynamic:()=>m});var n=r(49303),o=r(88716),s=r(60670),i=r(87070),p=r(97425),l=r(73068);let c={DEFAULT_MS:3e4},d=["host","connection","keep-alive","transfer-encoding","te","trailer","upgrade"],u=["transfer-encoding","connection","keep-alive"],h={BAD_GATEWAY:502,GATEWAY_TIMEOUT:504,UPGRADE_REQUIRED:426},f={GATEWAY_TIMEOUT:"The upstream server did not respond in time",BAD_GATEWAY:"Unable to connect to upstream server",UPGRADE_REQUIRED:"WebSocket connections are not supported through the proxy Route Handler"};async function _(e,t,r){let a=`http://${t.targetHost}:${t.targetPort}${r}`,n=new Headers;e.headers.forEach((e,t)=>{let r=t.toLowerCase();d.includes(r)||n.set(t,e)});try{let t=new AbortController,r=setTimeout(()=>t.abort(),c.DEFAULT_MS),o=await fetch(a,{method:e.method,headers:n,body:"GET"!==e.method&&"HEAD"!==e.method?e.body:void 0,signal:t.signal,duplex:"half"});clearTimeout(r);let s=new Headers;return o.headers.forEach((e,t)=>{let r=t.toLowerCase();u.includes(r)||s.set(t,e)}),new Response(o.body,{status:o.status,statusText:o.statusText,headers:s})}catch(e){if(e instanceof Error&&("AbortError"===e.name||"TimeoutError"===e.name))return new Response(JSON.stringify({error:"Gateway Timeout",message:f.GATEWAY_TIMEOUT}),{status:h.GATEWAY_TIMEOUT,headers:{"Content-Type":"application/json"}});return new Response(JSON.stringify({error:"Bad Gateway",message:f.BAD_GATEWAY}),{status:h.BAD_GATEWAY,headers:{"Content-Type":"application/json"}})}}async function E(e,t,r){let a=`ws://${t.targetHost}:${t.targetPort}${r}`;return new Response(JSON.stringify({error:"Upgrade Required",message:`${f.UPGRADE_REQUIRED}. Configure your WebSocket client to connect directly to ${a}`,directUrl:a}),{status:h.UPGRADE_REQUIRED,headers:{"Content-Type":"application/json",Upgrade:"websocket"}})}let w=(0,r(43895).h)("proxy");function x(e){let t=`[Proxy] ${e.method} /proxy/${e.pathPrefix}${e.path} -> ${e.statusCode} (${e.responseTime}ms)`;e.error?w.warn(t,{...e}):w.info(t,{...e})}let m="force-dynamic";async function y(e,t){let r=Date.now(),a=e.method,[n,...o]=t,s="/"+o.join("/");if(!n)return i.NextResponse.json({error:"Path prefix is required"},{status:400});try{let t=(0,p.getDbInstance)(),o=(0,l.V_)(t),c=await o.getByPathPrefix(n);if(!c)return i.NextResponse.json({error:`No external app found for path prefix: ${n}`},{status:404});if(!c.enabled)return i.NextResponse.json({error:`External app "${c.displayName}" is currently disabled`},{status:503});if(function(e){let t=e.headers.get("upgrade");return t?.toLowerCase()==="websocket"}(e)){let t=await E(e,c,s),o={timestamp:Date.now(),pathPrefix:n,method:a,path:s,statusCode:t.status,responseTime:Date.now()-r,isWebSocket:!0};return x(o),t}let d=await _(e,c,s),u={timestamp:Date.now(),pathPrefix:n,method:a,path:s,statusCode:d.status,responseTime:Date.now()-r,isWebSocket:!1};return d.status>=400&&(u.error=`HTTP ${d.status}`),x(u),d}catch(e){return w.error(`[Proxy] ${a} /proxy/${n}${s} failed: ${e.message}`,{pathPrefix:n,method:a,path:s,error:e.message,stack:e.stack}),i.NextResponse.json({error:"Proxy error",message:e.message},{status:502})}}async function g(e,{params:t}){let{path:r}=await t;return y(e,r)}async function b(e,{params:t}){let{path:r}=await t;return y(e,r)}async function R(e,{params:t}){let{path:r}=await t;return y(e,r)}async function T(e,{params:t}){let{path:r}=await t;return y(e,r)}async function A(e,{params:t}){let{path:r}=await t;return y(e,r)}let D=new n.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/proxy/[...path]/route",pathname:"/proxy/[...path]",filename:"route",bundlePath:"app/proxy/[...path]/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/proxy/[...path]/route.ts",nextConfigOutput:"",userland:a}),{requestAsyncStorage:k,staticGenerationAsyncStorage:P,serverHooks:$}=D,U="/proxy/[...path]/route";function v(){return(0,s.patchFetch)({serverHooks:$,staticGenerationAsyncStorage:P})}},73068:(e,t,r)=>{r.d(t,{V_:()=>s});var a=r(51172);class n{constructor(e,t=3e4){this.cache=new Map,this.allAppsCache=null,this.lastRefresh=0,this.db=e,this.ttl=t}getTTL(){return this.ttl}isStale(){return Date.now()-this.lastRefresh>this.ttl}async refresh(){let e=(0,a.J6)(this.db);for(let t of(this.cache.clear(),e))this.cache.set(t.pathPrefix,t);this.allAppsCache=e,this.lastRefresh=Date.now()}async getByPathPrefix(e){return this.isStale()&&await this.refresh(),this.cache.get(e)??null}async getAll(){return this.isStale()&&await this.refresh(),this.allAppsCache??[]}invalidate(){this.cache.clear(),this.allAppsCache=null,this.lastRefresh=0}invalidateByIssueNo(e){this.invalidate()}}let o=null;function s(e){if(!o){if(!e)throw Error("Database instance required to initialize cache");o=new n(e)}return o}},51172:(e,t,r)=>{r.d(t,{F1:()=>p,J6:()=>u,JF:()=>i,j6:()=>s,ke:()=>l,uz:()=>c,vV:()=>d});var a=r(84770);class n extends Error{constructor(e,t,r){super(e),this.code=t,this.cause=r,this.name="ExternalAppDbError"}}function o(e){return{id:e.id,name:e.name,displayName:e.display_name,description:e.description??void 0,pathPrefix:e.path_prefix,targetPort:e.target_port,targetHost:e.target_host,appType:e.app_type,websocketEnabled:1===e.websocket_enabled,websocketPathPattern:e.websocket_path_pattern??void 0,enabled:1===e.enabled,createdAt:e.created_at,updatedAt:e.updated_at}}function s(e,t){let r=(0,a.randomUUID)(),o=Date.now(),s={name:t.name,display_name:t.displayName,description:t.description??null,path_prefix:t.pathPrefix,target_port:t.targetPort,target_host:t.targetHost??"localhost",app_type:t.appType,websocket_enabled:t.websocketEnabled?1:0,websocket_path_pattern:t.websocketPathPattern??null};try{return e.prepare(`
2
2
  INSERT INTO external_apps (
3
3
  id, name, display_name, description, path_prefix,
4
4
  target_port, target_host, app_type,
@@ -1 +1 @@
1
- {"version":1,"files":["../../../../../../../node_modules/next/dist/client/components/action-async-storage-instance.js","../../../../../../../node_modules/next/dist/client/components/action-async-storage.external.js","../../../../../../../node_modules/next/dist/client/components/async-local-storage.js","../../../../../../../node_modules/next/dist/client/components/request-async-storage-instance.js","../../../../../../../node_modules/next/dist/client/components/request-async-storage.external.js","../../../../../../../node_modules/next/dist/client/components/static-generation-async-storage-instance.js","../../../../../../../node_modules/next/dist/client/components/static-generation-async-storage.external.js","../../../../../../../node_modules/next/dist/compiled/@opentelemetry/api/index.js","../../../../../../../node_modules/next/dist/compiled/@opentelemetry/api/package.json","../../../../../../../node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js","../../../../../../../node_modules/next/dist/server/lib/trace/constants.js","../../../../../../../node_modules/next/dist/server/lib/trace/tracer.js","../../../../../../../node_modules/next/package.json","../../../../../../../package.json","../../../../../../package.json","../../../../../chunks/2683.js","../../../../../chunks/3074.js","../../../../../chunks/3294.js","../../../../../chunks/3348.js","../../../../../chunks/369.js","../../../../../chunks/3860.js","../../../../../chunks/4559.js","../../../../../chunks/5795.js","../../../../../chunks/5823.js","../../../../../chunks/5853.js","../../../../../chunks/6621.js","../../../../../chunks/6837.js","../../../../../chunks/7266.js","../../../../../chunks/7458.js","../../../../../chunks/8744.js","../../../../../chunks/8948.js","../../../../../chunks/9582.js","../../../../../webpack-runtime.js","page_client-reference-manifest.js"]}
1
+ {"version":1,"files":["../../../../../../../node_modules/next/dist/client/components/action-async-storage-instance.js","../../../../../../../node_modules/next/dist/client/components/action-async-storage.external.js","../../../../../../../node_modules/next/dist/client/components/async-local-storage.js","../../../../../../../node_modules/next/dist/client/components/request-async-storage-instance.js","../../../../../../../node_modules/next/dist/client/components/request-async-storage.external.js","../../../../../../../node_modules/next/dist/client/components/static-generation-async-storage-instance.js","../../../../../../../node_modules/next/dist/client/components/static-generation-async-storage.external.js","../../../../../../../node_modules/next/dist/compiled/@opentelemetry/api/index.js","../../../../../../../node_modules/next/dist/compiled/@opentelemetry/api/package.json","../../../../../../../node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js","../../../../../../../node_modules/next/dist/server/lib/trace/constants.js","../../../../../../../node_modules/next/dist/server/lib/trace/tracer.js","../../../../../../../node_modules/next/package.json","../../../../../../../package.json","../../../../../../package.json","../../../../../chunks/2314.js","../../../../../chunks/2683.js","../../../../../chunks/3074.js","../../../../../chunks/3294.js","../../../../../chunks/3348.js","../../../../../chunks/369.js","../../../../../chunks/3860.js","../../../../../chunks/4559.js","../../../../../chunks/5795.js","../../../../../chunks/5823.js","../../../../../chunks/5853.js","../../../../../chunks/6228.js","../../../../../chunks/6621.js","../../../../../chunks/6837.js","../../../../../chunks/7266.js","../../../../../chunks/7458.js","../../../../../chunks/8744.js","../../../../../chunks/8948.js","../../../../../chunks/9582.js","../../../../../webpack-runtime.js","page_client-reference-manifest.js"]}
@@ -1 +1 @@
1
- globalThis.__RSC_MANIFEST=(globalThis.__RSC_MANIFEST||{});globalThis.__RSC_MANIFEST["/worktrees/[id]/files/[...path]/page"]={"moduleLoading":{"prefix":"/_next/","crossOrigin":null},"ssrModuleMapping":{"80":{"*":{"id":"41868","name":"*","chunks":[],"async":false}},"4707":{"*":{"id":"79671","name":"*","chunks":[],"async":false}},"12846":{"*":{"id":"12994","name":"*","chunks":[],"async":false}},"18390":{"*":{"id":"74810","name":"*","chunks":[],"async":false}},"18828":{"*":{"id":"2108","name":"*","chunks":[],"async":false}},"19107":{"*":{"id":"96114","name":"*","chunks":[],"async":false}},"36423":{"*":{"id":"84759","name":"*","chunks":[],"async":false}},"38991":{"*":{"id":"24146","name":"*","chunks":[],"async":false}},"41845":{"*":{"id":"37398","name":"*","chunks":[],"async":false}},"50653":{"*":{"id":"84442","name":"*","chunks":[],"async":false}},"61060":{"*":{"id":"9727","name":"*","chunks":[],"async":false}},"66677":{"*":{"id":"42106","name":"*","chunks":[],"async":false}}},"edgeSSRModuleMapping":{},"clientModules":{"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/app-router.js":{"id":12846,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/app-router.js":{"id":12846,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/client-page.js":{"id":19107,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/client-page.js":{"id":19107,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/error-boundary.js":{"id":61060,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/error-boundary.js":{"id":61060,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/layout-router.js":{"id":4707,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/layout-router.js":{"id":4707,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/not-found-boundary.js":{"id":80,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/not-found-boundary.js":{"id":80,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/render-from-template-context.js":{"id":36423,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/render-from-template-context.js":{"id":36423,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/globals.css":{"id":2778,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","3185","static/chunks/app/layout-9110f9a5e41c6bf4.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/components/providers/AppProviders.tsx":{"id":18828,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","3185","static/chunks/app/layout-9110f9a5e41c6bf4.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/page.tsx":{"id":66677,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","216","static/chunks/216-f18f4a9d8b04a91e.js","2335","static/chunks/2335-98a211e00b94c7ac.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","8091","static/chunks/8091-925542bdfc843dce.js","1931","static/chunks/app/page-238b5a70d8c101e9.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/login/page.tsx":{"id":38991,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/files/[...path]/page.tsx":{"id":50653,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","1038","static/chunks/1038-3509435b68c0967e.js","5441","static/chunks/app/worktrees/%5Bid%5D/files/%5B...path%5D/page-4a3c0861367e0391.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx":{"id":18390,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","216","static/chunks/216-f18f4a9d8b04a91e.js","1038","static/chunks/1038-3509435b68c0967e.js","2335","static/chunks/2335-98a211e00b94c7ac.js","9178","static/chunks/9178-88850a7c48deea07.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","8091","static/chunks/8091-925542bdfc843dce.js","130","static/chunks/app/worktrees/%5Bid%5D/page-a556551ce5c69dec.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/terminal/page.tsx":{"id":41845,"name":"*","chunks":[],"async":false}},"entryCSSFiles":{"/home/runner/work/CommandMate/CommandMate/src/":[],"/home/runner/work/CommandMate/CommandMate/src/app/layout":["static/css/b9ea6a4fad17dc32.css"],"/home/runner/work/CommandMate/CommandMate/src/app/page":[],"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page":["static/css/5eacd01f773eed7f.css"],"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/files/[...path]/page":[]}}
1
+ globalThis.__RSC_MANIFEST=(globalThis.__RSC_MANIFEST||{});globalThis.__RSC_MANIFEST["/worktrees/[id]/files/[...path]/page"]={"moduleLoading":{"prefix":"/_next/","crossOrigin":null},"ssrModuleMapping":{"80":{"*":{"id":"41868","name":"*","chunks":[],"async":false}},"4707":{"*":{"id":"79671","name":"*","chunks":[],"async":false}},"12846":{"*":{"id":"12994","name":"*","chunks":[],"async":false}},"18828":{"*":{"id":"2108","name":"*","chunks":[],"async":false}},"19107":{"*":{"id":"96114","name":"*","chunks":[],"async":false}},"36423":{"*":{"id":"84759","name":"*","chunks":[],"async":false}},"38991":{"*":{"id":"24146","name":"*","chunks":[],"async":false}},"40991":{"*":{"id":"27247","name":"*","chunks":[],"async":false}},"41845":{"*":{"id":"37398","name":"*","chunks":[],"async":false}},"50653":{"*":{"id":"84442","name":"*","chunks":[],"async":false}},"61060":{"*":{"id":"9727","name":"*","chunks":[],"async":false}},"66677":{"*":{"id":"42106","name":"*","chunks":[],"async":false}}},"edgeSSRModuleMapping":{},"clientModules":{"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/app-router.js":{"id":12846,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/app-router.js":{"id":12846,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/client-page.js":{"id":19107,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/client-page.js":{"id":19107,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/error-boundary.js":{"id":61060,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/error-boundary.js":{"id":61060,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/layout-router.js":{"id":4707,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/layout-router.js":{"id":4707,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/not-found-boundary.js":{"id":80,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/not-found-boundary.js":{"id":80,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/client/components/render-from-template-context.js":{"id":36423,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/node_modules/next/dist/esm/client/components/render-from-template-context.js":{"id":36423,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/globals.css":{"id":2778,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","3185","static/chunks/app/layout-9110f9a5e41c6bf4.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/components/providers/AppProviders.tsx":{"id":18828,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","3185","static/chunks/app/layout-9110f9a5e41c6bf4.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/login/page.tsx":{"id":38991,"name":"*","chunks":[],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/page.tsx":{"id":66677,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","216","static/chunks/216-f18f4a9d8b04a91e.js","2335","static/chunks/2335-98a211e00b94c7ac.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","8091","static/chunks/8091-274bc0716106e7fc.js","1931","static/chunks/app/page-060057e02b841125.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/files/[...path]/page.tsx":{"id":50653,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","1038","static/chunks/1038-3509435b68c0967e.js","5441","static/chunks/app/worktrees/%5Bid%5D/files/%5B...path%5D/page-4a3c0861367e0391.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page.tsx":{"id":40991,"name":"*","chunks":["9234","static/chunks/9234-b0304101384ca079.js","216","static/chunks/216-f18f4a9d8b04a91e.js","1038","static/chunks/1038-3509435b68c0967e.js","2335","static/chunks/2335-98a211e00b94c7ac.js","9178","static/chunks/9178-88850a7c48deea07.js","8528","static/chunks/8528-4d554d3b94d4cf9b.js","8091","static/chunks/8091-274bc0716106e7fc.js","130","static/chunks/app/worktrees/%5Bid%5D/page-78580947c201d698.js"],"async":false},"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/terminal/page.tsx":{"id":41845,"name":"*","chunks":[],"async":false}},"entryCSSFiles":{"/home/runner/work/CommandMate/CommandMate/src/":[],"/home/runner/work/CommandMate/CommandMate/src/app/layout":["static/css/e85de230ef5ddc40.css"],"/home/runner/work/CommandMate/CommandMate/src/app/page":[],"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/page":["static/css/5eacd01f773eed7f.css"],"/home/runner/work/CommandMate/CommandMate/src/app/worktrees/[id]/files/[...path]/page":[]}}