@adhdev/daemon-standalone 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -183,4 +183,4 @@ ${fe}`,_localId:`sys_approval_${Date.now()}`};W(Se=>{for(const we of Object.keys
|
|
|
183
183
|
to { opacity: 1; transform: translateX(0); }
|
|
184
184
|
}
|
|
185
185
|
`})]})}function M3(e){return e.split(":")[0]||""}function A3({renderHeaderActions:e}={}){var b,ge,ve;const{id:t}=dy(),n=cs(),r=wf(),i=r.ides||[],s=r.connectionStates||r.p2pStates||{},{sendCommand:o}=xi(),l=w.useMemo(()=>M3(t||""),[t]),a=w.useMemo(()=>i.find(X=>X.id===t),[i,t]),c=(a==null?void 0:a.type)||void 0,h=c?c.charAt(0).toUpperCase()+c.slice(1):"IDE",u=(a==null?void 0:a.activeChat)||null,d=(a==null?void 0:a.agentStreams)||[],f=s[l]||"new",g=w.useMemo(()=>i.find(X=>X.id===l||X.daemonId===l),[i,l]),m=(g==null?void 0:g.machineNickname)||((b=g==null?void 0:g.machine)==null?void 0:b.hostname)||"",S=((ve=(ge=a==null?void 0:a.workspaceFolders)==null?void 0:ge[0])==null?void 0:ve.name)||"",[_]=Vw(),v=typeof window<"u"&&window.innerWidth<=768,y=_.get("view")||(v?"chat":"split"),[E,I]=w.useState(y),[C,B]=w.useState("ide"),[F,Z]=w.useState(""),[T,L]=w.useState(!1),[N,D]=w.useState(null),[W,M]=w.useState(null),[O,H]=w.useState([]),P=w.useMemo(()=>{var X,he;return{ideId:t||"",daemonId:l,agentName:Yh(c||""),agentType:c||"",status:(u==null?void 0:u.status)||"idle",title:(u==null?void 0:u.title)||"",messages:(u==null?void 0:u.messages)||[],ideType:c||"",workspaceName:(a==null?void 0:a.workspaceName)||"",displayPrimary:h,displaySecondary:(a==null?void 0:a.workspaceName)||"",cdpConnected:!0,modalButtons:(X=u==null?void 0:u.activeModal)==null?void 0:X.buttons,modalMessage:(he=u==null?void 0:u.activeModal)==null?void 0:he.message,streamSource:"native",tabKey:`ide-${t}`}},[t,l,c,u,a,h]);w.useEffect(()=>l?ti.onScreenshot("ide-page",(he,K)=>{if(he!==l)return;const G=new FileReader;G.onload=()=>D(G.result),G.readAsDataURL(K)}):void 0,[l]),w.useEffect(()=>l?ti.onStatusEvent((he,K)=>{if(he!==l)return;let G="",ie="info";if(K.event==="agent:generating_completed"?(G=`✅ Task completed${K.duration?` (${K.duration}s)`:""}`,ie="success"):(K.event==="agent:waiting_approval"||K.event==="agent:approval_requested")&&(G="⚡ Approval needed",ie="warning"),G){const A=Date.now();H(me=>[...me.slice(-4),{id:A,message:G,type:ie}]),setTimeout(()=>H(me=>me.filter(Ke=>Ke.id!==A)),ie==="warning"?1e4:5e3)}}):void 0,[l]),w.useEffect(()=>{const X=l?ti.get(l):null;!X||!(f==="connected")||(E!=="chat"?X.startScreenshots(c):X.stopScreenshots(c))},[E,f,c,l]);const $=w.useCallback(async(X,he={})=>{if(!t)throw new Error("No IDE ID");const K={...he};if(!K._targetInstance&&t){const ie=t.split(":");ie.length>=3&&(ie[1]==="ide"||ie[1]==="cli")&&(K._targetInstance=ie.slice(2).join(":"),K._targetType=ie[1])}const G=l?ti.get(l):null;return G!=null&&G.hasCommandChannel?await G.sendCommand(X,K):G&&G.connectionState!=="failed"&&G.connectionState!=="closed"&&await new Promise(A=>{const Me=Date.now(),me=()=>{if(G.hasCommandChannel)return A(!0);if(Date.now()-Me>3e3)return A(!1);setTimeout(me,200)};me()})&&G.hasCommandChannel?await G.sendCommand(X,K):await o(t,X,K)},[t,l]),x=async()=>{const X=F.trim();if(!(!X||!t||T)){Z(""),L(!0);try{await $("send_chat",{message:X,waitForResponse:!0})}catch(he){console.error("[IDE] Send failed:",he)}finally{L(!1)}}},re=async X=>{if(t)try{const he=await o(t,"screenshot",{width:X?Math.min(X,1280):1280});he!=null&&he.success&&(he!=null&&he.base64)&&M(`data:image/jpeg;base64,${he.base64}`)}catch(he){console.error("[IDE] Screenshot failed:",he)}},ce=d.length>0;return t?p.jsxs("div",{className:"ide-page",children:[p.jsxs("header",{className:"ide-header",children:[p.jsxs("div",{className:"ide-header-left",children:[p.jsxs("div",{className:"ide-title",children:[p.jsx("span",{className:"ide-name",children:h}),S&&p.jsx("span",{className:"ide-workspace",children:S}),p.jsx("span",{className:"ide-badge",children:"REMOTE"})]}),p.jsxs("div",{className:"ide-status-pill",children:[p.jsx("span",{className:`ide-dot ${f==="connected"?"online":"connecting"}`}),p.jsx("span",{className:"ide-status-text",children:f==="connected"?"Connected":f==="connecting"?"Connecting":"WS"})]}),m&&p.jsx("span",{className:"ide-machine-label",children:m})]}),p.jsxs("div",{className:"ide-header-right",children:[["chat","split","remote"].map(X=>p.jsx("button",{className:"btn btn-secondary btn-sm",style:{border:E===X?"1px solid var(--accent-primary)":"none",background:E===X?"rgba(99,102,241,0.12)":"var(--bg-secondary)",padding:"6px 10px",color:E===X?"var(--accent-primary)":void 0},onClick:()=>I(X),children:X==="chat"?"💬":X==="split"?"⊞":"🖥"},X)),e&&e({daemonId:l,ideInstanceId:t||""}),p.jsx("button",{className:"btn btn-primary btn-sm",style:{border:"none",padding:"6px 12px",fontSize:12},onClick:()=>n("/dashboard"),children:"← Back"})]})]}),p.jsxs("div",{className:"ide-content",children:[p.jsxs("div",{className:`ide-chat-panel ${E==="chat"?"full":""} ${E==="remote"?"hidden":""}`,children:[ce&&p.jsxs("div",{className:"ide-chat-tabs",children:[p.jsx("button",{className:`ide-chat-tab ${C==="ide"?"active":""}`,onClick:()=>B("ide"),children:h}),p.jsxs("button",{className:`ide-chat-tab ext ${C==="extensions"?"active":""}`,onClick:()=>B("extensions"),children:["Extensions ",p.jsx("span",{className:"ide-ext-badge",children:d.length})]})]}),C==="extensions"&&ce?p.jsx(X4,{ideId:t,agentStreams:d,sendCommand:async(X,he)=>{try{const K=l?ti.get(l):null;if(K&&f==="connected"){await Promise.race([K.sendCommand(X,he),new Promise((G,ie)=>setTimeout(()=>ie(new Error("connection timeout")),3e3))]);return}}catch{}await o(t,X,he)}}):p.jsx(y1,{activeConv:P,ides:i,agentInput:F,setAgentInput:Z,handleSendChat:x,handleFocusAgent:()=>{},isFocusingAgent:!1,messageReceivedAt:{},actionLogs:[]})]}),p.jsx("div",{className:`ide-remote-panel ${E==="remote"?"full":""} ${E==="chat"?"hidden":""}`,children:p.jsx(p3,{screenshot:W,isCapturing:!1,onRefresh:re,addLog:()=>{},connState:f,connScreenshot:N,onAction:async(X,he)=>{const K=l?ti.get(l):null;if(K&&f==="connected")try{return await K.sendInput(X,he)}catch(G){console.error("[Connection Input] Failed:",G)}return await o(t,"cdp_remote_action",{action:X,params:he})}})})]}),O.length>0&&p.jsx("div",{className:"ide-toasts",children:O.map(X=>p.jsx("div",{className:`ide-toast ${X.type}`,onClick:()=>H(he=>he.filter(K=>K.id!==X.id)),children:X.message},X.id))})]}):p.jsx("div",{className:"ide-empty",children:"No IDE selected"})}function B3(){var Ze,rt,Xt,Ot,$o,Wo,Ho,Uo,Vr;const{id:e}=dy(),t=cs(),{sendCommand:n}=xi(),r=n,i=wf(),s=i.ides||[],o=i.initialLoaded??!0,[l,a]=w.useState([]),[c,h]=w.useState([]),[u,d]=w.useState(0),[f,g]=w.useState(!0),[m,S]=w.useState("debug"),[_,v]=w.useState(null),[y,E]=w.useState([]),[I,C]=w.useState(!1),[B,F]=w.useState(""),[Z,T]=w.useState(""),[L,N]=w.useState(""),[D,W]=w.useState(""),[M,O]=w.useState("overview"),[H,P]=w.useState([]),[$,x]=w.useState(!1),[re,ce]=w.useState(!1),[b,ge]=w.useState(""),[ve,X]=w.useState([]),[he,K]=w.useState(!1),[G,ie]=w.useState(null),[A,Me]=w.useState("all"),me=w.useRef(null),Ke=w.useRef(!1);w.useEffect(()=>{if(!e||M!=="logs"||!f)return;const k=async()=>{try{const ye=await n(e,"get_logs",{count:200,minLevel:m,since:u}),ke=(ye==null?void 0:ye.result)||ye;if(ye!=null&&ye.success&&Array.isArray(ke==null?void 0:ke.logs)&&ke.logs.length>0){h(Je=>[...Je,...ke.logs.map(ki=>({timestamp:ki.ts,level:ki.level,message:`[${ki.category}] ${ki.message}`}))].slice(-300));const je=Math.max(...ke.logs.map(Je=>Je.ts));d(je)}}catch{}};k();const Q=setInterval(k,3e3);return()=>clearInterval(Q)},[e,M,f,u,m]),w.useEffect(()=>{if(f&&c.length>0){const k=Ke.current?"smooth":"instant";setTimeout(()=>{var Q;(Q=me.current)==null||Q.scrollIntoView({behavior:k}),Ke.current=!0},50)}},[c.length,l.length,f]),w.useEffect(()=>{M!=="logs"&&(Ke.current=!1)},[M]);const zt=async()=>{var k;if(e){K(!0);try{const Q=await n(e,"get_provider_settings",{}),ye=(Q==null?void 0:Q.result)||Q;if(Q!=null&&Q.success&&(ye!=null&&ye.settings)){const ke=[];for(const[je,Je]of Object.entries(ye.settings)){const mt=On.find(ki=>ki.type===je);ke.push({type:je,displayName:(mt==null?void 0:mt.displayName)||je,icon:(mt==null?void 0:mt.icon)||"🔧",category:(mt==null?void 0:mt.category)||"unknown",schema:Je,values:((k=ye.values)==null?void 0:k[je])||{}})}ke.sort((je,Je)=>je.category.localeCompare(Je.category)||je.displayName.localeCompare(Je.displayName)),X(ke)}}catch{}K(!1)}};w.useEffect(()=>{M==="providers"&&ve.length===0&&zt()},[M]);const qt=async(k,Q,ye)=>{ie(`${k}.${Q}`),X(ke=>ke.map(je=>je.type===k?{...je,values:{...je.values,[Q]:ye}}:je));try{const ke=await n(e,"set_provider_setting",{providerType:k,key:Q,value:ye});ke!=null&&ke.success||zt()}catch{zt()}ie(null)},De=s.find(k=>k.id===e&&k.daemonMode),Ce=De?{id:De.id,hostname:((Ze=De.machine)==null?void 0:Ze.hostname)||De.id,platform:((rt=De.machine)==null?void 0:rt.platform)||"unknown",arch:((Xt=De.machine)==null?void 0:Xt.arch)||"",cpus:((Ot=De.machine)==null?void 0:Ot.cpus)||0,totalMem:(($o=De.machine)==null?void 0:$o.totalMem)||0,freeMem:((Wo=De.machine)==null?void 0:Wo.freeMem)||0,loadavg:((Ho=De.machine)==null?void 0:Ho.loadavg)||[],uptime:((Uo=De.machine)==null?void 0:Uo.uptime)||0,release:((Vr=De.machine)==null?void 0:Vr.release)||"",cdpconnected:De.cdpconnected||!1,machineNickname:De.machineNickname||null,p2p:De.p2p||{available:!1,state:"unavailable",peers:0},detectedIdes:De.detectedIdes||[],managedIdeIds:De.managedIdeIds||[],managedCliIds:De.managedCliIds||[]}:null,On=(De==null?void 0:De.availableProviders)||[],Jn={};for(const k of On)Jn[k.type]=k.icon;const It=k=>Jn[k]||"💻",Yt=On.filter(k=>k.category==="cli"||k.category==="acp");w.useEffect(()=>{!L&&Yt.length>0&&N(Yt[0].type)},[L,Yt.length]);const Qe=s.filter(k=>k.daemonId===e&&!k.daemonMode).filter(k=>!Nm(k)).map(k=>({id:k.id,type:k.type,version:k.version||"",instanceId:k.instanceId||"",status:k.status,workspaceFolders:k.workspaceFolders||[],activeFile:k.activeFile||null,terminals:k.terminals||0,aiAgents:x3(k.aiAgents||k.agents||[]),activeChat:k.activeChat||null,chats:k.chats||[],agentStreams:k.agentStreams||[],cdpconnected:k.cdpconnected||!1,daemonId:e})),J=s.filter(k=>k.daemonId===e&&Nm(k)).map(k=>{var Q,ye;return{id:k.id,type:k.type,cliName:k.cliName||k.type,status:k.status,workingDir:k.workingDir||((ye=(Q=k.workspaceFolders)==null?void 0:Q[0])==null?void 0:ye.path)||"",activeChat:k.activeChat||null,daemonId:e}}),pe=((Ce==null?void 0:Ce.detectedIdes)||[]).filter(k=>!k.running&&!Qe.some(Q=>(Q.type||"").toLowerCase()===(k.type||"").toLowerCase())),R=(k,Q)=>{a(ye=>[...ye.slice(-100),{timestamp:Date.now(),level:k,message:Q}]),setTimeout(()=>{var ye;return(ye=me.current)==null?void 0:ye.scrollIntoView({behavior:"smooth"})},100)},Y=async k=>{if(!(!e||_)){v(k),R("info",`Launching ${Kn(k)}...`);try{const Q=await n(e,"launch_ide",{ideType:k,enableCdp:!0});R(Q!=null&&Q.success?"info":"error",Q!=null&&Q.success?`${Kn(k)} launched`:`Failed: ${Q==null?void 0:Q.error}`)}catch(Q){R("error",`Launch error: ${Q.message}`)}finally{v(null)}}},z=async(k,Q,ye,ke)=>{if(e){R("info",`Launching ${k}${Q?` in ${Q}`:""}${ke?` (model: ${ke})`:""}...`);try{const je=ye?ye.split(/\s+/).filter(Boolean):void 0,Je=await n(e,"launch_cli",{cliType:k,dir:Q||void 0,cliArgs:je,initialModel:ke||void 0}),mt=(Je==null?void 0:Je.result)||Je;Je!=null&&Je.success?(R("info",`${k} launched`),mt!=null&&mt.defaultedToHome&&R("info",`📂 No directory specified — running in home directory (${mt.dir||"~"})`)):R("error",`Failed: ${(Je==null?void 0:Je.error)||(mt==null?void 0:mt.error)}`)}catch(je){R("error",`Launch error: ${je.message}`)}}},j=async(k,Q)=>{if(e&&window.confirm(`Stop ${k}?
|
|
186
|
-
This will terminate the CLI process.`))try{await n(e,"stop_cli",{cliType:k,dir:Q}),R("info",`${k} stopped`)}catch(ye){R("error",`Stop failed: ${ye.message}`)}},U=async k=>{try{await n(k.id,"restart_session",{ideType:k.type}),R("info",`${Kn(k.type)} restart initiated`)}catch(Q){R("error",`Restart failed: ${Q.message}`)}},q=async()=>{if(e)try{const k=await n(e,"detect_ides",{});R("info",`Found ${((k==null?void 0:k.result)||[]).length} IDE(s)`)}catch(k){R("error",`Detection failed: ${k.message}`)}},ee=async()=>{if(e){C(!0);try{const k=await n(e,"get_recent_workspaces",{});k!=null&&k.success&&Array.isArray(k==null?void 0:k.result)&&E(k.result)}catch(k){R("error",`Failed: ${k.message}`)}finally{C(!1)}}},oe=async()=>{var k;if(e){x(!0);try{const Q=await r(e,"get_cli_history");Q.success&&((k=Q.result)!=null&&k.history)&&P(Q.result.history)}catch{}x(!1)}},le=async()=>{if(e)try{await r(e,"set_machine_nickname",{nickname:b}),R("info",`Nickname set to "${b||"(cleared)"}"`),ce(!1)}catch(k){R("error",`Failed: ${k.message}`)}};if(!Ce)return o?p.jsxs("div",{style:{padding:40,textAlign:"center",color:"#64748b"},children:[p.jsx("h2",{style:{color:"#f1f5f9"},children:"Machine not found"}),p.jsx("p",{style:{marginTop:12},children:"The machine may be offline or not yet connected."}),p.jsx("button",{onClick:()=>t("/machines"),className:"machine-btn-back",children:"← Back to Burrows"})]}):p.jsx("div",{style:{padding:40,textAlign:"center",color:"#64748b"},children:p.jsx("p",{children:"⏳ Loading machine..."})});const fe=Ce.totalMem>0?Math.round((Ce.totalMem-Ce.freeMem)/Ce.totalMem*100):0,ae=Ce.loadavg[0]||0,Se=Ce.machineNickname||Ce.hostname,we=[{id:"overview",label:"📊 Overview"},{id:"ides",label:"💻 IDEs",count:Qe.length},{id:"clis",label:"🔌 CLIs",count:J.length},{id:"providers",label:"⚙️ Providers",count:ve.length>0?ve.length:void 0},{id:"logs",label:"📋 Logs",count:l.length>0?l.length:void 0}];return p.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[p.jsxs("div",{style:{padding:"16px 24px",borderBottom:"1px solid rgba(255,255,255,0.06)",background:"var(--surface-primary)"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14},children:[p.jsx("button",{onClick:()=>t("/machines"),className:"machine-btn-back",children:"←"}),p.jsxs("div",{children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[re?p.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[p.jsx("input",{autoFocus:!0,value:b,onChange:k=>ge(k.target.value),onKeyDown:k=>{k.key==="Enter"&&le(),k.key==="Escape"&&ce(!1)},placeholder:"Machine nickname...",style:{padding:"4px 10px",borderRadius:6,border:"1px solid rgba(139,92,246,0.3)",background:"rgba(15,23,42,0.8)",color:"#f1f5f9",fontSize:14,fontWeight:600,width:200}}),p.jsx("button",{onClick:le,className:"machine-btn",style:{color:"#22c55e",borderColor:"rgba(34,197,94,0.3)"},children:"✓"}),p.jsx("button",{onClick:()=>ce(!1),className:"machine-btn",children:"✕"})]}):p.jsx("h1",{style:{fontSize:18,fontWeight:700,color:"#f1f5f9",margin:0,cursor:"pointer"},onClick:()=>{ce(!0),ge(Ce.machineNickname||"")},title:"Click to set nickname",children:Se}),p.jsx("span",{className:"status-dot-md online"})]}),p.jsxs("div",{style:{fontSize:11,color:"#64748b",marginTop:2,display:"flex",gap:8,alignItems:"center"},children:[p.jsxs("span",{children:[Ce.platform," · ",Ce.arch," · ",Ce.cpus," cores"]}),Ce.p2p.available&&p.jsxs("span",{style:{padding:"1px 6px",borderRadius:4,fontSize:9,fontWeight:600,background:Ce.p2p.state==="connected"?"rgba(34,197,94,0.08)":"rgba(234,179,8,0.08)",color:Ce.p2p.state==="connected"?"#22c55e":"#eab308"},children:["P2P ",Ce.p2p.state==="connected"?`● ${Ce.p2p.peers}`:"○"]}),Ce.cdpconnected&&p.jsx("span",{style:{padding:"1px 6px",borderRadius:4,fontSize:9,fontWeight:600,background:"rgba(34,197,94,0.08)",color:"#22c55e"},children:"CDP ●"}),Ce.machineNickname&&p.jsxs("span",{style:{color:"#475569"},children:["(",Ce.hostname,")"]})]})]})]}),p.jsx("button",{onClick:q,className:"machine-btn-primary",title:"Re-detect installed IDEs",children:"🔍 Scan IDEs"})]}),p.jsx("div",{className:"machine-tabs",children:we.map(k=>p.jsxs("button",{onClick:()=>O(k.id),className:`machine-tab${M===k.id?" active":""}`,children:[k.label,k.count!==void 0&&p.jsx("span",{className:"tab-count",children:k.count})]},k.id))})]}),p.jsxs("div",{className:"page-content",children:[M==="overview"&&p.jsxs("div",{children:[p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:10,marginBottom:20},children:[p.jsx(Mm,{icon:"⏱",label:"Uptime",value:S3(Ce.uptime)}),p.jsx(Mm,{icon:"💻",label:"IDEs",value:`${Qe.length}`,sub:`${J.length} CLIs`})]}),p.jsxs("div",{style:{padding:"16px 20px",borderRadius:12,marginBottom:20,background:"rgba(15, 23, 42, 0.5)",border:"1px solid rgba(255,255,255,0.06)"},children:[p.jsx("div",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:12},children:"Resource Usage"}),p.jsxs("div",{style:{display:"flex",gap:24},children:[p.jsx(Am,{value:Math.min(Math.round(ae/Ce.cpus*100),100),max:100,label:"CPU Load",color:"#8b5cf6",detail:`${ae.toFixed(2)} avg / ${Ce.cpus} cores`}),p.jsx(Am,{value:fe,max:100,label:"Memory",color:"#3b82f6",detail:`${Bm(Ce.totalMem-Ce.freeMem)} / ${Bm(Ce.totalMem)}`})]})]}),p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:12},children:[p.jsxs("div",{style:{padding:"16px 20px",borderRadius:12,background:"rgba(15, 23, 42, 0.5)",border:"1px solid rgba(255,255,255,0.06)"},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[p.jsx("span",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},children:"IDEs"}),p.jsx("button",{onClick:()=>O("ides"),className:"machine-btn",style:{fontSize:10},children:"View All →"})]}),Qe.length===0?p.jsx("div",{style:{fontSize:12,color:"#475569",fontStyle:"italic"},children:"No IDEs running"}):p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:Qe.map(k=>{var ye,ke,je;const Q=(k.agentStreams||[]).some(Je=>Je.status==="generating"||Je.status==="streaming")||((ye=k.activeChat)==null?void 0:ye.status)==="generating";return p.jsxs("div",{onClick:()=>t(`/ide/${k.id}`),style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",borderRadius:8,cursor:"pointer",transition:"background 0.15s",background:Q?"rgba(249,115,22,0.04)":"rgba(255,255,255,0.02)",border:Q?"1px solid rgba(249,115,22,0.1)":"1px solid transparent"},children:[p.jsx("span",{children:It(k.type)}),p.jsx("span",{style:{fontSize:12,color:"#e2e8f0",fontWeight:500},children:Kn(k.type)}),p.jsx("span",{style:{fontSize:10,color:"#475569",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((je=(ke=k.workspaceFolders)==null?void 0:ke[0])==null?void 0:je.name)||""}),Q&&p.jsx("span",{style:{fontSize:10,color:"#fb923c",fontWeight:600,marginLeft:"auto"},children:"⚡ Working"}),p.jsx("span",{style:{marginLeft:Q?6:"auto",width:6,height:6,borderRadius:"50%",background:Q?"#fb923c":"#22c55e",boxShadow:Q?"0 0 8px rgba(249,115,22,0.4)":"none",animation:Q?"pulse-dot 1.5s infinite":"none"}})]},k.id)})})]}),p.jsxs("div",{style:{padding:"16px 20px",borderRadius:12,background:"rgba(15, 23, 42, 0.5)",border:"1px solid rgba(255,255,255,0.06)"},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[p.jsx("span",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},children:"CLIs"}),p.jsx("button",{onClick:()=>O("clis"),className:"machine-btn",style:{fontSize:10},children:"View All →"})]}),J.length===0?p.jsx("div",{style:{fontSize:12,color:"#475569",fontStyle:"italic"},children:"No CLIs running"}):p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:J.map(k=>p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",borderRadius:8,background:"rgba(255,255,255,0.02)"},children:[p.jsx("span",{children:It(k.type)}),p.jsx("span",{style:{fontSize:12,color:"#e2e8f0",fontWeight:500},children:k.cliName}),p.jsx("span",{style:{fontSize:10,color:"#475569",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.workingDir.split("/").pop()}),p.jsx("span",{style:{marginLeft:"auto",width:6,height:6,borderRadius:"50%",background:k.status==="stopped"?"#ef4444":"#22c55e"}})]},k.id))})]})]}),Ce.detectedIdes.length>0&&p.jsxs("div",{style:{marginTop:16,padding:"14px 18px",borderRadius:12,background:"rgba(15,23,42,0.5)",border:"1px solid rgba(255,255,255,0.06)"},children:[p.jsx("div",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:8},children:"Detected on this machine"}),p.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:Ce.detectedIdes.map(k=>p.jsxs("div",{style:{padding:"4px 10px",borderRadius:6,fontSize:11,background:k.running?"rgba(34,197,94,0.06)":"rgba(255,255,255,0.02)",border:`1px solid ${k.running?"rgba(34,197,94,0.12)":"rgba(255,255,255,0.04)"}`,color:k.running?"#86efac":"#64748b",display:"flex",alignItems:"center",gap:4},children:[p.jsx("span",{children:It(k.type)}),k.name||k.type,p.jsx("span",{style:{width:4,height:4,borderRadius:"50%",background:k.running?"#22c55e":"#475569"}})]},k.type))})]})]}),M==="ides"&&p.jsxs("div",{children:[p.jsxs("div",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:10},children:["Running (",Qe.length,")"]}),Qe.length===0?p.jsx("div",{style:{padding:"40px 20px",textAlign:"center",borderRadius:12,background:"rgba(15,23,42,0.4)",border:"1px dashed rgba(255,255,255,0.06)",color:"#475569",fontSize:13,marginBottom:20},children:"No IDEs currently running. Launch one below."}):p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:20},children:Qe.map(k=>{var Q,ye;return p.jsxs("div",{style:{padding:"14px 18px",borderRadius:12,background:"rgba(15,23,42,0.5)",border:"1px solid rgba(255,255,255,0.06)"},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[p.jsx("span",{style:{fontSize:18},children:It(k.type)}),p.jsx("span",{style:{fontWeight:600,fontSize:14,color:"#f1f5f9"},children:Kn(k.type)}),k.version&&p.jsxs("span",{style:{fontSize:10,color:"#475569"},children:["v",k.version]}),p.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#22c55e",boxShadow:"0 0 6px rgba(34,197,94,0.3)"}})]}),p.jsxs("div",{style:{display:"flex",gap:6},children:[p.jsx("button",{onClick:()=>t(`/ide/${k.id}`),className:"machine-btn",children:"🖥 Control"}),p.jsx("button",{onClick:()=>U(k),className:"machine-btn",style:{color:"#f59e0b",borderColor:"rgba(245,158,11,0.3)"},children:"↻ Restart"})]})]}),p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(130px, 1fr))",gap:6,fontSize:12,color:"#94a3b8"},children:[p.jsxs("div",{children:[p.jsx("span",{style:{color:"#64748b"},children:"Workspace:"})," ",((Q=k.workspaceFolders)==null?void 0:Q.map(ke=>ke.name).join(", "))||"—"]}),p.jsxs("div",{children:[p.jsx("span",{style:{color:"#64748b"},children:"File:"})," ",((ye=k.activeFile)==null?void 0:ye.split("/").pop())||"—"]}),p.jsxs("div",{children:[p.jsx("span",{style:{color:"#64748b"},children:"Terminals:"})," ",k.terminals]}),p.jsxs("div",{children:[p.jsx("span",{style:{color:"#64748b"},children:"CDP:"})," ",k.cdpconnected?"● connected":"○ Off"]})]}),k.aiAgents.length>0&&p.jsx("div",{style:{display:"flex",gap:4,marginTop:8,flexWrap:"wrap"},children:k.aiAgents.map(ke=>p.jsxs("span",{style:{padding:"2px 8px",borderRadius:6,fontSize:10,background:ke.status==="generating"||ke.status==="streaming"?"rgba(249,115,22,0.08)":"rgba(99,102,241,0.06)",color:ke.status==="generating"||ke.status==="streaming"?"#fb923c":"#818cf8"},children:[ke.name," · ",ke.status]},ke.id))})]},k.id)})}),p.jsxs("div",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:10},children:["Available to Launch (",pe.length,")"]}),p.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:[pe.map(k=>p.jsxs("button",{onClick:()=>Y(k.type||k.id||""),disabled:!!_,className:"machine-btn-primary",style:{opacity:_&&_!==k.type?.4:1,display:"flex",alignItems:"center",gap:6},children:[p.jsx("span",{children:It(k.type)}),_===k.type?"⏳ Launching...":`▶ ${k.name||Kn(k.type)}`]},k.type)),pe.length===0&&p.jsxs("div",{style:{fontSize:12,color:"#475569",fontStyle:"italic"},children:["All detected IDEs are running, or none detected.",p.jsx("button",{onClick:q,className:"machine-btn",style:{marginLeft:8},children:"🔍 Scan"})]})]})]}),M==="clis"&&p.jsxs("div",{children:[p.jsxs("div",{style:{padding:"16px 20px",borderRadius:12,marginBottom:20,background:"rgba(15,23,42,0.5)",border:"1px solid rgba(139,92,246,0.12)"},children:[p.jsx("div",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:10},children:"Launch New CLI"}),p.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[p.jsx("select",{value:L,onChange:k=>N(k.target.value),className:"machine-input",children:Yt.length>0?Yt.map(k=>p.jsxs("option",{value:k.type,children:[k.icon," ",k.displayName]},k.type)):p.jsx("option",{value:"",disabled:!0,children:"No providers available"})}),p.jsx("input",{type:"text",placeholder:"Working directory...",value:B,onChange:k=>F(k.target.value),className:"machine-input",style:{flex:1,minWidth:200}}),p.jsx("input",{type:"text",placeholder:"Args (optional)",value:Z,onChange:k=>T(k.target.value),className:"machine-input",style:{minWidth:150}}),(()=>{const k=Yt.find(Q=>Q.type===L);return(k==null?void 0:k.category)==="acp"?p.jsx("input",{type:"text",placeholder:"Model (default)",value:D,onChange:Q=>W(Q.target.value),className:"machine-input",style:{minWidth:120}}):null})(),p.jsx("button",{onClick:()=>z(L,B,Z||void 0,D||void 0),className:"machine-btn-primary",children:"▶ Launch"})]})]}),p.jsxs("div",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:10},children:["Running (",J.length,")"]}),J.length===0?p.jsx("div",{style:{padding:"30px 20px",textAlign:"center",borderRadius:12,background:"rgba(15,23,42,0.4)",border:"1px dashed rgba(255,255,255,0.06)",color:"#475569",fontSize:13,marginBottom:20},children:"No CLIs running"}):p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:20},children:J.map(k=>p.jsxs("div",{style:{padding:"12px 16px",borderRadius:10,background:"rgba(15,23,42,0.5)",border:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsx("span",{style:{fontSize:18},children:It(k.type)}),p.jsxs("div",{children:[p.jsx("div",{style:{fontWeight:600,fontSize:13,color:"#f1f5f9"},children:k.cliName}),p.jsx("div",{style:{fontSize:11,color:"#64748b"},children:k.workingDir})]})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[p.jsx("span",{style:{padding:"2px 8px",borderRadius:6,fontSize:10,fontWeight:600,background:k.status==="stopped"?"rgba(239,68,68,0.08)":"rgba(34,197,94,0.08)",color:k.status==="stopped"?"#ef4444":"#22c55e"},children:k.status}),k.status==="stopped"?p.jsx("button",{onClick:()=>z(k.type,k.workingDir),className:"machine-btn",style:{color:"#22c55e",borderColor:"rgba(34,197,94,0.3)"},children:"▶"}):p.jsx("button",{onClick:()=>j(k.type,k.workingDir),className:"machine-btn",style:{color:"#ef4444",borderColor:"rgba(239,68,68,0.3)"},children:"■"})]})]},k.id))}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[p.jsx("span",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},children:"History"}),p.jsx("button",{onClick:oe,disabled:$,className:"machine-btn",children:$?"⏳":"↻ Load"})]}),H.length>0&&p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,maxHeight:200,overflowY:"auto"},children:H.map((k,Q)=>{var ye,ke;return p.jsxs("div",{onClick:()=>{N(k.cliType),F(k.dir),T((k.cliArgs||[]).join(" "))},style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 10px",borderRadius:6,cursor:"pointer",background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.04)",fontSize:12,transition:"background 0.15s"},onMouseEnter:je=>je.currentTarget.style.background="rgba(255,255,255,0.06)",onMouseLeave:je=>je.currentTarget.style.background="rgba(255,255,255,0.02)",children:[p.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",color:"#94a3b8"},children:[p.jsx("span",{children:It(k.cliType)}),p.jsx("span",{children:((ye=k.dir)==null?void 0:ye.split("/").filter(Boolean).pop())||"root"}),((ke=k.cliArgs)==null?void 0:ke.length)>0&&p.jsx("span",{style:{color:"#475569",fontSize:10},children:k.cliArgs.join(" ")})]}),p.jsx("span",{style:{color:"#475569",fontSize:10},children:k.timestamp?new Date(k.timestamp).toLocaleDateString():""})]},Q)})}),p.jsxs("div",{style:{marginTop:20},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[p.jsx("span",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},children:"Recent Workspaces"}),p.jsx("button",{onClick:ee,disabled:I,className:"machine-btn",children:I?"⏳":"↻ Load"})]}),y.length>0&&p.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:y.map((k,Q)=>p.jsxs("button",{onClick:()=>F(k),className:"machine-btn",style:{maxWidth:200,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:k,children:["📂 ",k.split("/").filter(Boolean).pop()||k]},Q))})]})]}),M==="providers"&&p.jsxs("div",{children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[p.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[p.jsx("span",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginRight:8},children:"Filter"}),["all","acp","cli","ide","extension"].map(k=>p.jsx("button",{onClick:()=>Me(k),className:"machine-btn",style:{fontSize:10,padding:"2px 8px",background:A===k?"rgba(139,92,246,0.15)":void 0,borderColor:A===k?"rgba(139,92,246,0.4)":void 0,color:A===k?"#a78bfa":void 0},children:k.toUpperCase()},k))]}),p.jsx("button",{onClick:zt,disabled:he,className:"machine-btn",children:he?"⏳ Loading...":"↻ Refresh"})]}),he&&ve.length===0?p.jsx("div",{style:{padding:40,textAlign:"center",color:"#475569"},children:"Loading provider settings..."}):p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:ve.filter(k=>A==="all"||k.category===A).map(k=>p.jsxs("div",{style:{padding:"14px 18px",borderRadius:12,background:"rgba(15,23,42,0.5)",border:"1px solid rgba(255,255,255,0.06)"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[p.jsx("span",{style:{fontSize:18},children:k.icon}),p.jsx("span",{style:{fontWeight:600,fontSize:13,color:"#f1f5f9"},children:k.displayName}),p.jsx("span",{style:{padding:"1px 6px",borderRadius:4,fontSize:9,fontWeight:600,background:k.category==="acp"?"rgba(139,92,246,0.08)":k.category==="cli"?"rgba(59,130,246,0.08)":k.category==="ide"?"rgba(34,197,94,0.08)":"rgba(245,158,11,0.08)",color:k.category==="acp"?"#a78bfa":k.category==="cli"?"#60a5fa":k.category==="ide"?"#86efac":"#fbbf24"},children:k.category})]}),p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:k.schema.map(Q=>p.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[p.jsxs("div",{style:{flex:1,minWidth:0},children:[p.jsxs("div",{style:{fontSize:12,fontWeight:500,color:"#e2e8f0"},children:[Q.label||Q.key,G===`${k.type}.${Q.key}`&&p.jsx("span",{style:{marginLeft:6,fontSize:9,color:"#8b5cf6"},children:"saving..."})]}),Q.description&&p.jsx("div",{style:{fontSize:10,color:"#64748b",marginTop:1},children:Q.description})]}),p.jsx("div",{style:{flexShrink:0},children:Q.type==="boolean"?p.jsx("button",{onClick:()=>qt(k.type,Q.key,!(k.values[Q.key]??Q.default)),style:{width:40,height:22,borderRadius:11,border:"none",background:k.values[Q.key]??Q.default?"#8b5cf6":"rgba(255,255,255,0.08)",position:"relative",cursor:"pointer",transition:"background 0.2s"},children:p.jsx("div",{style:{width:16,height:16,borderRadius:"50%",background:"white",position:"absolute",top:3,left:k.values[Q.key]??Q.default?21:3,transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})}):Q.type==="number"?p.jsx("input",{type:"number",value:k.values[Q.key]??Q.default??0,min:Q.min,max:Q.max,onChange:ye=>{const ke=parseInt(ye.target.value)||0;Q.min!==void 0&&ke<Q.min||Q.max!==void 0&&ke>Q.max||qt(k.type,Q.key,ke)},className:"machine-input",style:{width:80,textAlign:"center",fontSize:11}}):Q.type==="select"&&Q.options?p.jsx("select",{value:k.values[Q.key]??Q.default??"",onChange:ye=>qt(k.type,Q.key,ye.target.value),className:"machine-input",style:{fontSize:11},children:Q.options.map(ye=>p.jsx("option",{value:ye,children:ye},ye))}):p.jsx("input",{type:"text",value:k.values[Q.key]??Q.default??"",onBlur:ye=>qt(k.type,Q.key,ye.target.value),className:"machine-input",style:{width:120,fontSize:11}})})]},Q.key))})]},k.type))})]}),M==="logs"&&p.jsxs("div",{children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[p.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[p.jsx("span",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginRight:8},children:"Level"}),["debug","info","warn","error"].map(k=>p.jsx("button",{onClick:()=>{S(k),h([]),d(0)},className:"machine-btn",style:{fontSize:10,padding:"2px 8px",background:m===k?"rgba(139,92,246,0.15)":void 0,borderColor:m===k?"rgba(139,92,246,0.4)":void 0,color:m===k?"#a78bfa":void 0},children:k.toUpperCase()},k))]}),p.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[p.jsxs("span",{style:{fontSize:10,color:"#475569"},children:[c.length," entries"]}),p.jsx("button",{onClick:()=>g(!f),className:"machine-btn",style:{color:f?"#22c55e":"#64748b",borderColor:f?"rgba(34,197,94,0.3)":void 0},children:f?"⏸ Pause":"▶ Resume"}),p.jsx("button",{onClick:()=>{h([]),d(0)},className:"machine-btn",children:"Clear"})]})]}),p.jsxs("div",{style:{background:"rgba(15, 23, 42, 0.6)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:12,padding:12,minHeight:200,maxHeight:500,overflowY:"auto",fontFamily:"'JetBrains Mono', monospace",fontSize:11,lineHeight:1.6},children:[c.length===0&&p.jsx("div",{style:{padding:40,textAlign:"center",color:"#475569"},children:"Loading daemon logs..."}),c.map((k,Q)=>p.jsxs("div",{style:{display:"flex",gap:8,padding:"2px 0",color:k.level==="error"?"#ef4444":k.level==="warn"?"#f59e0b":k.level==="debug"?"#64748b":"#94a3b8"},children:[p.jsx("span",{style:{color:"#475569",minWidth:75,flexShrink:0},children:new Date(k.timestamp).toLocaleTimeString()}),p.jsx("span",{style:{fontWeight:600,minWidth:32,flexShrink:0,fontSize:9,color:k.level==="error"?"#ef4444":k.level==="warn"?"#f59e0b":k.level==="debug"?"#475569":"#8b5cf6"},children:k.level==="error"?"ERR":k.level==="warn"?"WRN":k.level==="debug"?"DBG":"INF"}),p.jsx("span",{children:k.message})]},Q)),p.jsx("div",{ref:me})]})]})]})]})}function N3(){if(typeof window>"u")return"ws://localhost:3847/ws";const t=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,r=new URLSearchParams(window.location.search).get("token");return r?`${t}?token=${encodeURIComponent(r)}`:t}const Om=N3(),jm=3e3,z3=3e4;let rr=null,O3=0;const wa=new Map,Xh=new Set;let Ds=null;async function Fl(e,t,n){const r=rr;if(r&&r.readyState===WebSocket.OPEN){const s=`req_${++O3}_${Date.now()}`;return new Promise((o,l)=>{const a=setTimeout(()=>{wa.delete(s),l(new Error(`WS command timeout: ${t}`))},3e4);wa.set(s,{resolve:c=>{clearTimeout(a),o(c)},reject:c=>{clearTimeout(a),l(c)}}),r.send(JSON.stringify({type:"command",requestId:s,data:{type:t,payload:n||{},target:e}}))})}const i=await fetch("/api/v1/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:t,payload:n||{},target:e})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()}class j3{constructor(t){ps(this,"daemonId");ps(this,"screenshotIdeType",null);this.daemonId=t}get hasCommandChannel(){return(rr==null?void 0:rr.readyState)===WebSocket.OPEN}get connectionState(){return(rr==null?void 0:rr.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(t,n){return Fl(this.daemonId,t,n)}async sendInput(t,n){return Fl(this.daemonId,"cdp_remote_action",{action:t,params:n})}startScreenshots(t){if(this.screenshotIdeType=t||null,Ds)return;const n=async()=>{if(this.hasCommandChannel)try{const r=await Fl(this.daemonId,"screenshot",{width:1280});if(r!=null&&r.success&&(r!=null&&r.base64)){const i=await fetch(`data:image/jpeg;base64,${r.base64}`).then(s=>s.blob());Xh.forEach(s=>s(this.daemonId,i))}}catch{}};n(),Ds=setInterval(n,2e3)}stopScreenshots(t){Ds&&(clearInterval(Ds),Ds=null)}}let Xr=null;function F3(e){(!Xr||Xr.daemonId!==e)&&(Xr=new j3(e));try{const{connectionManager:t}=require("@adhdev/web-core"),n=t.get.bind(t);t.get=r=>r===e?Xr:n(r),t.getState=r=>r===e&&(Xr==null?void 0:Xr.connectionState)||"disconnected",t.onScreenshot=r=>(Xh.add(r),()=>{Xh.delete(r)})}catch{}}function $3({children:e}){const t=w.useRef($p()),n=$p();t.current=n;const[,r]=w.useState("disconnected"),i=w.useRef(null),s=w.useRef(),o=w.useRef(jm),l=w.useRef(!0);return w.useEffect(()=>{l.current=!0;function a(){var u,d;if(!l.current||((u=i.current)==null?void 0:u.readyState)===WebSocket.OPEN||((d=i.current)==null?void 0:d.readyState)===WebSocket.CONNECTING)return;r("connecting"),console.log(`[Standalone WS] Connecting to ${Om}...`);let h;try{h=new WebSocket(Om)}catch(f){console.error("[Standalone WS] Failed to create WebSocket:",f),c();return}i.current=h,h.onopen=()=>{if(!l.current){h.close();return}r("connected"),o.current=jm,console.log("[Standalone WS] Connected")},rr=h,h.onmessage=f=>{var g;try{const m=JSON.parse(f.data);if((m.type==="command_result"||m.type==="error")&&m.requestId){const S=wa.get(m.requestId);S&&(wa.delete(m.requestId),m.type==="error"?S.reject(new Error(((g=m.data)==null?void 0:g.message)||"Command failed")):S.resolve(m.data));return}if(m.type==="status"||m.type==="initial_state"){const S=m.data;if(!S)return;const{injectEntries:_,markLoaded:v}=t.current,y=[],E=S.id||"standalone";F3(E),y.push({id:E,type:"adhdev-daemon",status:"online",daemonMode:!0,machine:{hostname:S.hostname,platform:S.platform,...S.system||{}},system:S.system||null,timestamp:S.timestamp,cdpConnected:S.cdpConnected,detectedIdes:S.detectedIdes||[],availableProviders:S.availableProviders||[],managedIdeIds:(S.ides||[]).map(I=>I.id),managedCliIds:(S.clis||[]).map(I=>I.id)});for(const I of S.ides||[])y.push({...I,daemonId:S.id||"standalone",status:I.cdpConnected?"online":"detected"});for(const I of S.clis||[])y.push({...I,daemonId:S.id||"standalone",status:I.isRunning?"running":"stopped"});y.length>0&&_(y),v()}}catch(m){console.error("[Standalone WS] Parse error:",m)}},h.onclose=()=>{l.current&&(r("disconnected"),i.current=null,c())},h.onerror=f=>{console.warn("[Standalone WS] Error, will reconnect:",f)}}function c(){if(!l.current)return;clearTimeout(s.current);const h=o.current;console.log(`[Standalone WS] Reconnecting in ${h}ms...`),s.current=setTimeout(()=>{o.current=Math.min(o.current*1.5,z3),a()},h)}return a(),()=>{l.current=!1,clearTimeout(s.current),i.current&&(i.current.onclose=null,i.current.close(),i.current=null,rr=null)}},[]),p.jsx(p.Fragment,{children:e})}function W3({children:e}){return p.jsx(Yw,{children:p.jsx($3,{children:e})})}const H3=[{id:"dashboard",path:"/dashboard",icon:"🌊",label:"Dashboard"},{id:"machine",path:"/machine",icon:"🐇",label:"Burrow"}];function U3({children:e}){const t=cs(),n=Mo(),[r,i]=w.useState(!1),[s,o]=w.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="1"}catch{return!1}}),l=c=>{t(c),i(!1)},a=()=>{o(c=>{const h=!c;try{localStorage.setItem("sidebar-collapsed",h?"1":"0")}catch{}return h})};return p.jsxs("div",{className:`app-layout${r?" mobile-menu-open":""}${s?" sidebar-collapsed":""}`,children:[p.jsxs("button",{type:"button",className:"mobile-menu-btn","aria-label":"Open menu",onClick:()=>i(!0),children:[p.jsx("span",{className:"mobile-menu-icon"}),p.jsx("span",{className:"mobile-menu-icon"}),p.jsx("span",{className:"mobile-menu-icon"})]}),r&&p.jsx("div",{className:"sidebar-overlay",role:"button",tabIndex:0,"aria-label":"Close menu",onClick:()=>i(!1),onKeyDown:c=>c.key==="Escape"&&i(!1)}),p.jsxs("aside",{className:`sidebar ${r?"sidebar-open":""}`,children:[p.jsxs("div",{className:"sidebar-header",children:[p.jsxs("div",{className:"sidebar-logo",style:{justifyContent:s?"center":void 0,gap:s?0:void 0},children:[p.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",style:{width:28,height:28}}),!s&&p.jsx("span",{children:"ADHDev"})]}),p.jsx("button",{type:"button",className:"sidebar-close-btn","aria-label":"Close menu",onClick:()=>i(!1),children:"✕"})]}),p.jsx("nav",{className:"sidebar-nav",children:H3.map(c=>p.jsxs("div",{className:`nav-item${n.pathname===c.path?" active":""}`,id:`nav-${c.id}`,onClick:()=>l(c.path),title:s?c.label:void 0,style:{cursor:"pointer",justifyContent:s?"center":void 0,padding:s?"10px 0":void 0},children:[p.jsx("span",{className:"nav-icon",children:c.icon}),!s&&c.label]},c.id))}),p.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:16,marginTop:"auto"},children:[!s&&p.jsxs("div",{style:{padding:"8px 12px",fontSize:12,color:"var(--text-muted)"},children:["Selfhost v","0.5.0"]}),p.jsxs("div",{className:"nav-item",onClick:a,title:s?"Expand sidebar":"Collapse sidebar",style:{cursor:"pointer",justifyContent:s?"center":void 0,padding:s?"10px 0":void 0},children:[p.jsx("span",{className:"nav-icon",style:{fontSize:16},children:s?"›":"‹"}),!s&&p.jsx("span",{style:{fontSize:12},children:"Collapse"})]})]})]}),p.jsx("main",{className:"main-content",style:{position:"relative"},children:p.jsx("div",{className:"main-content-inner",children:e})})]})}function Fm(){const{ides:e}=vy(),t=e.find(n=>{var r;return n.daemonMode||((r=n.id)==null?void 0:r.startsWith("standalone"))});return t?p.jsx(Ll,{to:`/machines/${t.id}`,replace:!0}):e.length>0?p.jsx(Ll,{to:`/machines/${e[0].id}`,replace:!0}):p.jsx(Ll,{to:"/dashboard",replace:!0})}function K3(){return p.jsx(Kw,{children:p.jsx(W3,{children:p.jsx(Zw,{value:{sendCommand:Fl,sendData:()=>!1},children:p.jsx(U3,{children:p.jsxs($w,{children:[p.jsx(Zr,{path:"/dashboard",element:p.jsx(D3,{})}),p.jsx(Zr,{path:"/ide/:id",element:p.jsx(A3,{})}),p.jsx(Zr,{path:"/machine",element:p.jsx(Fm,{})}),p.jsx(Zr,{path:"/machines/:id",element:p.jsx(B3,{})}),p.jsx(Zr,{path:"/machines",element:p.jsx(Fm,{})}),p.jsx(Zr,{path:"*",element:p.jsx(Ll,{to:"/dashboard",replace:!0})})]})})})})})}ny(document.getElementById("root")).render(p.jsx(w.StrictMode,{children:p.jsx(K3,{})}));
|
|
186
|
+
This will terminate the CLI process.`))try{await n(e,"stop_cli",{cliType:k,dir:Q}),R("info",`${k} stopped`)}catch(ye){R("error",`Stop failed: ${ye.message}`)}},U=async k=>{try{await n(k.id,"restart_session",{ideType:k.type}),R("info",`${Kn(k.type)} restart initiated`)}catch(Q){R("error",`Restart failed: ${Q.message}`)}},q=async()=>{if(e)try{const k=await n(e,"detect_ides",{});R("info",`Found ${((k==null?void 0:k.result)||[]).length} IDE(s)`)}catch(k){R("error",`Detection failed: ${k.message}`)}},ee=async()=>{if(e){C(!0);try{const k=await n(e,"get_recent_workspaces",{});k!=null&&k.success&&Array.isArray(k==null?void 0:k.result)&&E(k.result)}catch(k){R("error",`Failed: ${k.message}`)}finally{C(!1)}}},oe=async()=>{var k;if(e){x(!0);try{const Q=await r(e,"get_cli_history");Q.success&&((k=Q.result)!=null&&k.history)&&P(Q.result.history)}catch{}x(!1)}},le=async()=>{if(e)try{await r(e,"set_machine_nickname",{nickname:b}),R("info",`Nickname set to "${b||"(cleared)"}"`),ce(!1)}catch(k){R("error",`Failed: ${k.message}`)}};if(!Ce)return o?p.jsxs("div",{style:{padding:40,textAlign:"center",color:"#64748b"},children:[p.jsx("h2",{style:{color:"#f1f5f9"},children:"Machine not found"}),p.jsx("p",{style:{marginTop:12},children:"The machine may be offline or not yet connected."}),p.jsx("button",{onClick:()=>t("/machines"),className:"machine-btn-back",children:"← Back to Burrows"})]}):p.jsx("div",{style:{padding:40,textAlign:"center",color:"#64748b"},children:p.jsx("p",{children:"⏳ Loading machine..."})});const fe=Ce.totalMem>0?Math.round((Ce.totalMem-Ce.freeMem)/Ce.totalMem*100):0,ae=Ce.loadavg[0]||0,Se=Ce.machineNickname||Ce.hostname,we=[{id:"overview",label:"📊 Overview"},{id:"ides",label:"💻 IDEs",count:Qe.length},{id:"clis",label:"🔌 CLIs",count:J.length},{id:"providers",label:"⚙️ Providers",count:ve.length>0?ve.length:void 0},{id:"logs",label:"📋 Logs",count:l.length>0?l.length:void 0}];return p.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[p.jsxs("div",{style:{padding:"16px 24px",borderBottom:"1px solid rgba(255,255,255,0.06)",background:"var(--surface-primary)"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14},children:[p.jsx("button",{onClick:()=>t("/machines"),className:"machine-btn-back",children:"←"}),p.jsxs("div",{children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[re?p.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[p.jsx("input",{autoFocus:!0,value:b,onChange:k=>ge(k.target.value),onKeyDown:k=>{k.key==="Enter"&&le(),k.key==="Escape"&&ce(!1)},placeholder:"Machine nickname...",style:{padding:"4px 10px",borderRadius:6,border:"1px solid rgba(139,92,246,0.3)",background:"rgba(15,23,42,0.8)",color:"#f1f5f9",fontSize:14,fontWeight:600,width:200}}),p.jsx("button",{onClick:le,className:"machine-btn",style:{color:"#22c55e",borderColor:"rgba(34,197,94,0.3)"},children:"✓"}),p.jsx("button",{onClick:()=>ce(!1),className:"machine-btn",children:"✕"})]}):p.jsx("h1",{style:{fontSize:18,fontWeight:700,color:"#f1f5f9",margin:0,cursor:"pointer"},onClick:()=>{ce(!0),ge(Ce.machineNickname||"")},title:"Click to set nickname",children:Se}),p.jsx("span",{className:"status-dot-md online"})]}),p.jsxs("div",{style:{fontSize:11,color:"#64748b",marginTop:2,display:"flex",gap:8,alignItems:"center"},children:[p.jsxs("span",{children:[Ce.platform," · ",Ce.arch," · ",Ce.cpus," cores"]}),Ce.p2p.available&&p.jsxs("span",{style:{padding:"1px 6px",borderRadius:4,fontSize:9,fontWeight:600,background:Ce.p2p.state==="connected"?"rgba(34,197,94,0.08)":"rgba(234,179,8,0.08)",color:Ce.p2p.state==="connected"?"#22c55e":"#eab308"},children:["P2P ",Ce.p2p.state==="connected"?`● ${Ce.p2p.peers}`:"○"]}),Ce.cdpconnected&&p.jsx("span",{style:{padding:"1px 6px",borderRadius:4,fontSize:9,fontWeight:600,background:"rgba(34,197,94,0.08)",color:"#22c55e"},children:"CDP ●"}),Ce.machineNickname&&p.jsxs("span",{style:{color:"#475569"},children:["(",Ce.hostname,")"]})]})]})]}),p.jsx("button",{onClick:q,className:"machine-btn-primary",title:"Re-detect installed IDEs",children:"🔍 Scan IDEs"})]}),p.jsx("div",{className:"machine-tabs",children:we.map(k=>p.jsxs("button",{onClick:()=>O(k.id),className:`machine-tab${M===k.id?" active":""}`,children:[k.label,k.count!==void 0&&p.jsx("span",{className:"tab-count",children:k.count})]},k.id))})]}),p.jsxs("div",{className:"page-content",children:[M==="overview"&&p.jsxs("div",{children:[p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:10,marginBottom:20},children:[p.jsx(Mm,{icon:"⏱",label:"Uptime",value:S3(Ce.uptime)}),p.jsx(Mm,{icon:"💻",label:"IDEs",value:`${Qe.length}`,sub:`${J.length} CLIs`})]}),p.jsxs("div",{style:{padding:"16px 20px",borderRadius:12,marginBottom:20,background:"rgba(15, 23, 42, 0.5)",border:"1px solid rgba(255,255,255,0.06)"},children:[p.jsx("div",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:12},children:"Resource Usage"}),p.jsxs("div",{style:{display:"flex",gap:24},children:[p.jsx(Am,{value:Math.min(Math.round(ae/Ce.cpus*100),100),max:100,label:"CPU Load",color:"#8b5cf6",detail:`${ae.toFixed(2)} avg / ${Ce.cpus} cores`}),p.jsx(Am,{value:fe,max:100,label:"Memory",color:"#3b82f6",detail:`${Bm(Ce.totalMem-Ce.freeMem)} / ${Bm(Ce.totalMem)}`})]})]}),p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:12},children:[p.jsxs("div",{style:{padding:"16px 20px",borderRadius:12,background:"rgba(15, 23, 42, 0.5)",border:"1px solid rgba(255,255,255,0.06)"},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[p.jsx("span",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},children:"IDEs"}),p.jsx("button",{onClick:()=>O("ides"),className:"machine-btn",style:{fontSize:10},children:"View All →"})]}),Qe.length===0?p.jsx("div",{style:{fontSize:12,color:"#475569",fontStyle:"italic"},children:"No IDEs running"}):p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:Qe.map(k=>{var ye,ke,je;const Q=(k.agentStreams||[]).some(Je=>Je.status==="generating"||Je.status==="streaming")||((ye=k.activeChat)==null?void 0:ye.status)==="generating";return p.jsxs("div",{onClick:()=>t(`/ide/${k.id}`),style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",borderRadius:8,cursor:"pointer",transition:"background 0.15s",background:Q?"rgba(249,115,22,0.04)":"rgba(255,255,255,0.02)",border:Q?"1px solid rgba(249,115,22,0.1)":"1px solid transparent"},children:[p.jsx("span",{children:It(k.type)}),p.jsx("span",{style:{fontSize:12,color:"#e2e8f0",fontWeight:500},children:Kn(k.type)}),p.jsx("span",{style:{fontSize:10,color:"#475569",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((je=(ke=k.workspaceFolders)==null?void 0:ke[0])==null?void 0:je.name)||""}),Q&&p.jsx("span",{style:{fontSize:10,color:"#fb923c",fontWeight:600,marginLeft:"auto"},children:"⚡ Working"}),p.jsx("span",{style:{marginLeft:Q?6:"auto",width:6,height:6,borderRadius:"50%",background:Q?"#fb923c":"#22c55e",boxShadow:Q?"0 0 8px rgba(249,115,22,0.4)":"none",animation:Q?"pulse-dot 1.5s infinite":"none"}})]},k.id)})})]}),p.jsxs("div",{style:{padding:"16px 20px",borderRadius:12,background:"rgba(15, 23, 42, 0.5)",border:"1px solid rgba(255,255,255,0.06)"},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[p.jsx("span",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},children:"CLIs"}),p.jsx("button",{onClick:()=>O("clis"),className:"machine-btn",style:{fontSize:10},children:"View All →"})]}),J.length===0?p.jsx("div",{style:{fontSize:12,color:"#475569",fontStyle:"italic"},children:"No CLIs running"}):p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:J.map(k=>p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",borderRadius:8,background:"rgba(255,255,255,0.02)"},children:[p.jsx("span",{children:It(k.type)}),p.jsx("span",{style:{fontSize:12,color:"#e2e8f0",fontWeight:500},children:k.cliName}),p.jsx("span",{style:{fontSize:10,color:"#475569",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.workingDir.split("/").pop()}),p.jsx("span",{style:{marginLeft:"auto",width:6,height:6,borderRadius:"50%",background:k.status==="stopped"?"#ef4444":"#22c55e"}})]},k.id))})]})]}),Ce.detectedIdes.length>0&&p.jsxs("div",{style:{marginTop:16,padding:"14px 18px",borderRadius:12,background:"rgba(15,23,42,0.5)",border:"1px solid rgba(255,255,255,0.06)"},children:[p.jsx("div",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:8},children:"Detected on this machine"}),p.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:Ce.detectedIdes.map(k=>p.jsxs("div",{style:{padding:"4px 10px",borderRadius:6,fontSize:11,background:k.running?"rgba(34,197,94,0.06)":"rgba(255,255,255,0.02)",border:`1px solid ${k.running?"rgba(34,197,94,0.12)":"rgba(255,255,255,0.04)"}`,color:k.running?"#86efac":"#64748b",display:"flex",alignItems:"center",gap:4},children:[p.jsx("span",{children:It(k.type)}),k.name||k.type,p.jsx("span",{style:{width:4,height:4,borderRadius:"50%",background:k.running?"#22c55e":"#475569"}})]},k.type))})]})]}),M==="ides"&&p.jsxs("div",{children:[p.jsxs("div",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:10},children:["Running (",Qe.length,")"]}),Qe.length===0?p.jsx("div",{style:{padding:"40px 20px",textAlign:"center",borderRadius:12,background:"rgba(15,23,42,0.4)",border:"1px dashed rgba(255,255,255,0.06)",color:"#475569",fontSize:13,marginBottom:20},children:"No IDEs currently running. Launch one below."}):p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:20},children:Qe.map(k=>{var Q,ye;return p.jsxs("div",{style:{padding:"14px 18px",borderRadius:12,background:"rgba(15,23,42,0.5)",border:"1px solid rgba(255,255,255,0.06)"},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[p.jsx("span",{style:{fontSize:18},children:It(k.type)}),p.jsx("span",{style:{fontWeight:600,fontSize:14,color:"#f1f5f9"},children:Kn(k.type)}),k.version&&p.jsxs("span",{style:{fontSize:10,color:"#475569"},children:["v",k.version]}),p.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#22c55e",boxShadow:"0 0 6px rgba(34,197,94,0.3)"}})]}),p.jsxs("div",{style:{display:"flex",gap:6},children:[p.jsx("button",{onClick:()=>t(`/ide/${k.id}`),className:"machine-btn",children:"🖥 Control"}),p.jsx("button",{onClick:()=>U(k),className:"machine-btn",style:{color:"#f59e0b",borderColor:"rgba(245,158,11,0.3)"},children:"↻ Restart"})]})]}),p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(130px, 1fr))",gap:6,fontSize:12,color:"#94a3b8"},children:[p.jsxs("div",{children:[p.jsx("span",{style:{color:"#64748b"},children:"Workspace:"})," ",((Q=k.workspaceFolders)==null?void 0:Q.map(ke=>ke.name).join(", "))||"—"]}),p.jsxs("div",{children:[p.jsx("span",{style:{color:"#64748b"},children:"File:"})," ",((ye=k.activeFile)==null?void 0:ye.split("/").pop())||"—"]}),p.jsxs("div",{children:[p.jsx("span",{style:{color:"#64748b"},children:"Terminals:"})," ",k.terminals]}),p.jsxs("div",{children:[p.jsx("span",{style:{color:"#64748b"},children:"CDP:"})," ",k.cdpconnected?"● connected":"○ Off"]})]}),k.aiAgents.length>0&&p.jsx("div",{style:{display:"flex",gap:4,marginTop:8,flexWrap:"wrap"},children:k.aiAgents.map(ke=>p.jsxs("span",{style:{padding:"2px 8px",borderRadius:6,fontSize:10,background:ke.status==="generating"||ke.status==="streaming"?"rgba(249,115,22,0.08)":"rgba(99,102,241,0.06)",color:ke.status==="generating"||ke.status==="streaming"?"#fb923c":"#818cf8"},children:[ke.name," · ",ke.status]},ke.id))})]},k.id)})}),p.jsxs("div",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:10},children:["Available to Launch (",pe.length,")"]}),p.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:[pe.map(k=>p.jsxs("button",{onClick:()=>Y(k.type||k.id||""),disabled:!!_,className:"machine-btn-primary",style:{opacity:_&&_!==k.type?.4:1,display:"flex",alignItems:"center",gap:6},children:[p.jsx("span",{children:It(k.type)}),_===k.type?"⏳ Launching...":`▶ ${k.name||Kn(k.type)}`]},k.type)),pe.length===0&&p.jsxs("div",{style:{fontSize:12,color:"#475569",fontStyle:"italic"},children:["All detected IDEs are running, or none detected.",p.jsx("button",{onClick:q,className:"machine-btn",style:{marginLeft:8},children:"🔍 Scan"})]})]})]}),M==="clis"&&p.jsxs("div",{children:[p.jsxs("div",{style:{padding:"16px 20px",borderRadius:12,marginBottom:20,background:"rgba(15,23,42,0.5)",border:"1px solid rgba(139,92,246,0.12)"},children:[p.jsx("div",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:10},children:"Launch New CLI"}),p.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[p.jsx("select",{value:L,onChange:k=>N(k.target.value),className:"machine-input",children:Yt.length>0?Yt.map(k=>p.jsxs("option",{value:k.type,children:[k.icon," ",k.displayName]},k.type)):p.jsx("option",{value:"",disabled:!0,children:"No providers available"})}),p.jsx("input",{type:"text",placeholder:"Working directory...",value:B,onChange:k=>F(k.target.value),className:"machine-input",style:{flex:1,minWidth:200}}),p.jsx("input",{type:"text",placeholder:"Args (optional)",value:Z,onChange:k=>T(k.target.value),className:"machine-input",style:{minWidth:150}}),(()=>{const k=Yt.find(Q=>Q.type===L);return(k==null?void 0:k.category)==="acp"?p.jsx("input",{type:"text",placeholder:"Model (default)",value:D,onChange:Q=>W(Q.target.value),className:"machine-input",style:{minWidth:120}}):null})(),p.jsx("button",{onClick:()=>z(L,B,Z||void 0,D||void 0),className:"machine-btn-primary",children:"▶ Launch"})]})]}),p.jsxs("div",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:10},children:["Running (",J.length,")"]}),J.length===0?p.jsx("div",{style:{padding:"30px 20px",textAlign:"center",borderRadius:12,background:"rgba(15,23,42,0.4)",border:"1px dashed rgba(255,255,255,0.06)",color:"#475569",fontSize:13,marginBottom:20},children:"No CLIs running"}):p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:20},children:J.map(k=>p.jsxs("div",{style:{padding:"12px 16px",borderRadius:10,background:"rgba(15,23,42,0.5)",border:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsx("span",{style:{fontSize:18},children:It(k.type)}),p.jsxs("div",{children:[p.jsx("div",{style:{fontWeight:600,fontSize:13,color:"#f1f5f9"},children:k.cliName}),p.jsx("div",{style:{fontSize:11,color:"#64748b"},children:k.workingDir})]})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[p.jsx("span",{style:{padding:"2px 8px",borderRadius:6,fontSize:10,fontWeight:600,background:k.status==="stopped"?"rgba(239,68,68,0.08)":"rgba(34,197,94,0.08)",color:k.status==="stopped"?"#ef4444":"#22c55e"},children:k.status}),k.status==="stopped"?p.jsx("button",{onClick:()=>z(k.type,k.workingDir),className:"machine-btn",style:{color:"#22c55e",borderColor:"rgba(34,197,94,0.3)"},children:"▶"}):p.jsx("button",{onClick:()=>j(k.type,k.workingDir),className:"machine-btn",style:{color:"#ef4444",borderColor:"rgba(239,68,68,0.3)"},children:"■"})]})]},k.id))}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[p.jsx("span",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},children:"History"}),p.jsx("button",{onClick:oe,disabled:$,className:"machine-btn",children:$?"⏳":"↻ Load"})]}),H.length>0&&p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,maxHeight:200,overflowY:"auto"},children:H.map((k,Q)=>{var ye,ke;return p.jsxs("div",{onClick:()=>{N(k.cliType),F(k.dir),T((k.cliArgs||[]).join(" "))},style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 10px",borderRadius:6,cursor:"pointer",background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.04)",fontSize:12,transition:"background 0.15s"},onMouseEnter:je=>je.currentTarget.style.background="rgba(255,255,255,0.06)",onMouseLeave:je=>je.currentTarget.style.background="rgba(255,255,255,0.02)",children:[p.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",color:"#94a3b8"},children:[p.jsx("span",{children:It(k.cliType)}),p.jsx("span",{children:((ye=k.dir)==null?void 0:ye.split("/").filter(Boolean).pop())||"root"}),((ke=k.cliArgs)==null?void 0:ke.length)>0&&p.jsx("span",{style:{color:"#475569",fontSize:10},children:k.cliArgs.join(" ")})]}),p.jsx("span",{style:{color:"#475569",fontSize:10},children:k.timestamp?new Date(k.timestamp).toLocaleDateString():""})]},Q)})}),p.jsxs("div",{style:{marginTop:20},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[p.jsx("span",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},children:"Recent Workspaces"}),p.jsx("button",{onClick:ee,disabled:I,className:"machine-btn",children:I?"⏳":"↻ Load"})]}),y.length>0&&p.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:y.map((k,Q)=>p.jsxs("button",{onClick:()=>F(k),className:"machine-btn",style:{maxWidth:200,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:k,children:["📂 ",k.split("/").filter(Boolean).pop()||k]},Q))})]})]}),M==="providers"&&p.jsxs("div",{children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[p.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[p.jsx("span",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginRight:8},children:"Filter"}),["all","acp","cli","ide","extension"].map(k=>p.jsx("button",{onClick:()=>Me(k),className:"machine-btn",style:{fontSize:10,padding:"2px 8px",background:A===k?"rgba(139,92,246,0.15)":void 0,borderColor:A===k?"rgba(139,92,246,0.4)":void 0,color:A===k?"#a78bfa":void 0},children:k.toUpperCase()},k))]}),p.jsx("button",{onClick:zt,disabled:he,className:"machine-btn",children:he?"⏳ Loading...":"↻ Refresh"})]}),he&&ve.length===0?p.jsx("div",{style:{padding:40,textAlign:"center",color:"#475569"},children:"Loading provider settings..."}):p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:ve.filter(k=>A==="all"||k.category===A).map(k=>p.jsxs("div",{style:{padding:"14px 18px",borderRadius:12,background:"rgba(15,23,42,0.5)",border:"1px solid rgba(255,255,255,0.06)"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[p.jsx("span",{style:{fontSize:18},children:k.icon}),p.jsx("span",{style:{fontWeight:600,fontSize:13,color:"#f1f5f9"},children:k.displayName}),p.jsx("span",{style:{padding:"1px 6px",borderRadius:4,fontSize:9,fontWeight:600,background:k.category==="acp"?"rgba(139,92,246,0.08)":k.category==="cli"?"rgba(59,130,246,0.08)":k.category==="ide"?"rgba(34,197,94,0.08)":"rgba(245,158,11,0.08)",color:k.category==="acp"?"#a78bfa":k.category==="cli"?"#60a5fa":k.category==="ide"?"#86efac":"#fbbf24"},children:k.category})]}),p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:k.schema.map(Q=>p.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[p.jsxs("div",{style:{flex:1,minWidth:0},children:[p.jsxs("div",{style:{fontSize:12,fontWeight:500,color:"#e2e8f0"},children:[Q.label||Q.key,G===`${k.type}.${Q.key}`&&p.jsx("span",{style:{marginLeft:6,fontSize:9,color:"#8b5cf6"},children:"saving..."})]}),Q.description&&p.jsx("div",{style:{fontSize:10,color:"#64748b",marginTop:1},children:Q.description})]}),p.jsx("div",{style:{flexShrink:0},children:Q.type==="boolean"?p.jsx("button",{onClick:()=>qt(k.type,Q.key,!(k.values[Q.key]??Q.default)),style:{width:40,height:22,borderRadius:11,border:"none",background:k.values[Q.key]??Q.default?"#8b5cf6":"rgba(255,255,255,0.08)",position:"relative",cursor:"pointer",transition:"background 0.2s"},children:p.jsx("div",{style:{width:16,height:16,borderRadius:"50%",background:"white",position:"absolute",top:3,left:k.values[Q.key]??Q.default?21:3,transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})}):Q.type==="number"?p.jsx("input",{type:"number",value:k.values[Q.key]??Q.default??0,min:Q.min,max:Q.max,onChange:ye=>{const ke=parseInt(ye.target.value)||0;Q.min!==void 0&&ke<Q.min||Q.max!==void 0&&ke>Q.max||qt(k.type,Q.key,ke)},className:"machine-input",style:{width:80,textAlign:"center",fontSize:11}}):Q.type==="select"&&Q.options?p.jsx("select",{value:k.values[Q.key]??Q.default??"",onChange:ye=>qt(k.type,Q.key,ye.target.value),className:"machine-input",style:{fontSize:11},children:Q.options.map(ye=>p.jsx("option",{value:ye,children:ye},ye))}):p.jsx("input",{type:"text",value:k.values[Q.key]??Q.default??"",onBlur:ye=>qt(k.type,Q.key,ye.target.value),className:"machine-input",style:{width:120,fontSize:11}})})]},Q.key))})]},k.type))})]}),M==="logs"&&p.jsxs("div",{children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[p.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[p.jsx("span",{style:{fontSize:11,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",marginRight:8},children:"Level"}),["debug","info","warn","error"].map(k=>p.jsx("button",{onClick:()=>{S(k),h([]),d(0)},className:"machine-btn",style:{fontSize:10,padding:"2px 8px",background:m===k?"rgba(139,92,246,0.15)":void 0,borderColor:m===k?"rgba(139,92,246,0.4)":void 0,color:m===k?"#a78bfa":void 0},children:k.toUpperCase()},k))]}),p.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[p.jsxs("span",{style:{fontSize:10,color:"#475569"},children:[c.length," entries"]}),p.jsx("button",{onClick:()=>g(!f),className:"machine-btn",style:{color:f?"#22c55e":"#64748b",borderColor:f?"rgba(34,197,94,0.3)":void 0},children:f?"⏸ Pause":"▶ Resume"}),p.jsx("button",{onClick:()=>{h([]),d(0)},className:"machine-btn",children:"Clear"})]})]}),p.jsxs("div",{style:{background:"rgba(15, 23, 42, 0.6)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:12,padding:12,minHeight:200,maxHeight:500,overflowY:"auto",fontFamily:"'JetBrains Mono', monospace",fontSize:11,lineHeight:1.6},children:[c.length===0&&p.jsx("div",{style:{padding:40,textAlign:"center",color:"#475569"},children:"Loading daemon logs..."}),c.map((k,Q)=>p.jsxs("div",{style:{display:"flex",gap:8,padding:"2px 0",color:k.level==="error"?"#ef4444":k.level==="warn"?"#f59e0b":k.level==="debug"?"#64748b":"#94a3b8"},children:[p.jsx("span",{style:{color:"#475569",minWidth:75,flexShrink:0},children:new Date(k.timestamp).toLocaleTimeString()}),p.jsx("span",{style:{fontWeight:600,minWidth:32,flexShrink:0,fontSize:9,color:k.level==="error"?"#ef4444":k.level==="warn"?"#f59e0b":k.level==="debug"?"#475569":"#8b5cf6"},children:k.level==="error"?"ERR":k.level==="warn"?"WRN":k.level==="debug"?"DBG":"INF"}),p.jsx("span",{children:k.message})]},Q)),p.jsx("div",{ref:me})]})]})]})]})}function N3(){if(typeof window>"u")return"ws://localhost:3847/ws";const t=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,r=new URLSearchParams(window.location.search).get("token");return r?`${t}?token=${encodeURIComponent(r)}`:t}const Om=N3(),jm=3e3,z3=3e4;let rr=null,O3=0;const wa=new Map,Xh=new Set;let Ds=null;async function Fl(e,t,n){const r=rr;if(r&&r.readyState===WebSocket.OPEN){const s=`req_${++O3}_${Date.now()}`;return new Promise((o,l)=>{const a=setTimeout(()=>{wa.delete(s),l(new Error(`WS command timeout: ${t}`))},3e4);wa.set(s,{resolve:c=>{clearTimeout(a),o(c)},reject:c=>{clearTimeout(a),l(c)}}),r.send(JSON.stringify({type:"command",requestId:s,data:{type:t,payload:n||{},target:e}}))})}const i=await fetch("/api/v1/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:t,payload:n||{},target:e})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()}class j3{constructor(t){ps(this,"daemonId");ps(this,"screenshotIdeType",null);this.daemonId=t}get hasCommandChannel(){return(rr==null?void 0:rr.readyState)===WebSocket.OPEN}get connectionState(){return(rr==null?void 0:rr.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(t,n){return Fl(this.daemonId,t,n)}async sendInput(t,n){return Fl(this.daemonId,"cdp_remote_action",{action:t,params:n})}startScreenshots(t){if(this.screenshotIdeType=t||null,Ds)return;const n=async()=>{if(this.hasCommandChannel)try{const r=await Fl(this.daemonId,"screenshot",{width:1280});if(r!=null&&r.success&&(r!=null&&r.base64)){const i=await fetch(`data:image/jpeg;base64,${r.base64}`).then(s=>s.blob());Xh.forEach(s=>s(this.daemonId,i))}}catch{}};n(),Ds=setInterval(n,2e3)}stopScreenshots(t){Ds&&(clearInterval(Ds),Ds=null)}}let Xr=null;function F3(e){(!Xr||Xr.daemonId!==e)&&(Xr=new j3(e));try{const{connectionManager:t}=require("@adhdev/web-core"),n=t.get.bind(t);t.get=r=>r===e?Xr:n(r),t.getState=r=>r===e&&(Xr==null?void 0:Xr.connectionState)||"disconnected",t.onScreenshot=r=>(Xh.add(r),()=>{Xh.delete(r)})}catch{}}function $3({children:e}){const t=w.useRef($p()),n=$p();t.current=n;const[,r]=w.useState("disconnected"),i=w.useRef(null),s=w.useRef(),o=w.useRef(jm),l=w.useRef(!0);return w.useEffect(()=>{l.current=!0;function a(){var u,d;if(!l.current||((u=i.current)==null?void 0:u.readyState)===WebSocket.OPEN||((d=i.current)==null?void 0:d.readyState)===WebSocket.CONNECTING)return;r("connecting"),console.log(`[Standalone WS] Connecting to ${Om}...`);let h;try{h=new WebSocket(Om)}catch(f){console.error("[Standalone WS] Failed to create WebSocket:",f),c();return}i.current=h,h.onopen=()=>{if(!l.current){h.close();return}r("connected"),o.current=jm,console.log("[Standalone WS] Connected")},rr=h,h.onmessage=f=>{var g;try{const m=JSON.parse(f.data);if((m.type==="command_result"||m.type==="error")&&m.requestId){const S=wa.get(m.requestId);S&&(wa.delete(m.requestId),m.type==="error"?S.reject(new Error(((g=m.data)==null?void 0:g.message)||"Command failed")):S.resolve(m.data));return}if(m.type==="status"||m.type==="initial_state"){const S=m.data;if(!S)return;const{injectEntries:_,markLoaded:v}=t.current,y=[],E=S.id||"standalone";F3(E),y.push({id:E,type:"adhdev-daemon",status:"online",daemonMode:!0,machine:{hostname:S.hostname,platform:S.platform,...S.system||{}},system:S.system||null,timestamp:S.timestamp,cdpConnected:S.cdpConnected,detectedIdes:S.detectedIdes||[],availableProviders:S.availableProviders||[],managedIdeIds:(S.ides||[]).map(I=>I.id),managedCliIds:(S.clis||[]).map(I=>I.id)});for(const I of S.ides||[])y.push({...I,daemonId:S.id||"standalone",status:I.cdpConnected?"online":"detected"});for(const I of S.clis||[])y.push({...I,daemonId:S.id||"standalone",status:I.isRunning?"running":"stopped"});y.length>0&&_(y),v()}}catch(m){console.error("[Standalone WS] Parse error:",m)}},h.onclose=()=>{l.current&&(r("disconnected"),i.current=null,c())},h.onerror=f=>{console.warn("[Standalone WS] Error, will reconnect:",f)}}function c(){if(!l.current)return;clearTimeout(s.current);const h=o.current;console.log(`[Standalone WS] Reconnecting in ${h}ms...`),s.current=setTimeout(()=>{o.current=Math.min(o.current*1.5,z3),a()},h)}return a(),()=>{l.current=!1,clearTimeout(s.current),i.current&&(i.current.onclose=null,i.current.close(),i.current=null,rr=null)}},[]),p.jsx(p.Fragment,{children:e})}function W3({children:e}){return p.jsx(Yw,{children:p.jsx($3,{children:e})})}const H3=[{id:"dashboard",path:"/dashboard",icon:"🌊",label:"Dashboard"},{id:"machine",path:"/machine",icon:"🐇",label:"Burrow"}];function U3({children:e}){const t=cs(),n=Mo(),[r,i]=w.useState(!1),[s,o]=w.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="1"}catch{return!1}}),l=c=>{t(c),i(!1)},a=()=>{o(c=>{const h=!c;try{localStorage.setItem("sidebar-collapsed",h?"1":"0")}catch{}return h})};return p.jsxs("div",{className:`app-layout${r?" mobile-menu-open":""}${s?" sidebar-collapsed":""}`,children:[p.jsxs("button",{type:"button",className:"mobile-menu-btn","aria-label":"Open menu",onClick:()=>i(!0),children:[p.jsx("span",{className:"mobile-menu-icon"}),p.jsx("span",{className:"mobile-menu-icon"}),p.jsx("span",{className:"mobile-menu-icon"})]}),r&&p.jsx("div",{className:"sidebar-overlay",role:"button",tabIndex:0,"aria-label":"Close menu",onClick:()=>i(!1),onKeyDown:c=>c.key==="Escape"&&i(!1)}),p.jsxs("aside",{className:`sidebar ${r?"sidebar-open":""}`,children:[p.jsxs("div",{className:"sidebar-header",children:[p.jsxs("div",{className:"sidebar-logo",style:{justifyContent:s?"center":void 0,gap:s?0:void 0},children:[p.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",style:{width:28,height:28}}),!s&&p.jsx("span",{children:"ADHDev"})]}),p.jsx("button",{type:"button",className:"sidebar-close-btn","aria-label":"Close menu",onClick:()=>i(!1),children:"✕"})]}),p.jsx("nav",{className:"sidebar-nav",children:H3.map(c=>p.jsxs("div",{className:`nav-item${n.pathname===c.path?" active":""}`,id:`nav-${c.id}`,onClick:()=>l(c.path),title:s?c.label:void 0,style:{cursor:"pointer",justifyContent:s?"center":void 0,padding:s?"10px 0":void 0},children:[p.jsx("span",{className:"nav-icon",children:c.icon}),!s&&c.label]},c.id))}),p.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:16,marginTop:"auto"},children:[!s&&p.jsxs("div",{style:{padding:"8px 12px",fontSize:12,color:"var(--text-muted)"},children:["Selfhost v","0.5.1"]}),p.jsxs("div",{className:"nav-item",onClick:a,title:s?"Expand sidebar":"Collapse sidebar",style:{cursor:"pointer",justifyContent:s?"center":void 0,padding:s?"10px 0":void 0},children:[p.jsx("span",{className:"nav-icon",style:{fontSize:16},children:s?"›":"‹"}),!s&&p.jsx("span",{style:{fontSize:12},children:"Collapse"})]})]})]}),p.jsx("main",{className:"main-content",style:{position:"relative"},children:p.jsx("div",{className:"main-content-inner",children:e})})]})}function Fm(){const{ides:e}=vy(),t=e.find(n=>{var r;return n.daemonMode||((r=n.id)==null?void 0:r.startsWith("standalone"))});return t?p.jsx(Ll,{to:`/machines/${t.id}`,replace:!0}):e.length>0?p.jsx(Ll,{to:`/machines/${e[0].id}`,replace:!0}):p.jsx(Ll,{to:"/dashboard",replace:!0})}function K3(){return p.jsx(Kw,{children:p.jsx(W3,{children:p.jsx(Zw,{value:{sendCommand:Fl,sendData:()=>!1},children:p.jsx(U3,{children:p.jsxs($w,{children:[p.jsx(Zr,{path:"/dashboard",element:p.jsx(D3,{})}),p.jsx(Zr,{path:"/ide/:id",element:p.jsx(A3,{})}),p.jsx(Zr,{path:"/machine",element:p.jsx(Fm,{})}),p.jsx(Zr,{path:"/machines/:id",element:p.jsx(B3,{})}),p.jsx(Zr,{path:"/machines",element:p.jsx(Fm,{})}),p.jsx(Zr,{path:"*",element:p.jsx(Ll,{to:"/dashboard",replace:!0})})]})})})})})}ny(document.getElementById("root")).render(p.jsx(w.StrictMode,{children:p.jsx(K3,{})}));
|
package/public/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="description" content="ADHDev self-hosted dashboard for controlling AI agents" />
|
|
8
8
|
<link rel="icon" href="/otter-logo.png" />
|
|
9
9
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet" />
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-Ct8fHBOw.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/index-DaTd7tHO.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|