@adhdev/daemon-standalone 0.9.82-rc.153 → 0.9.82-rc.155

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-standalone",
3
- "version": "0.9.82-rc.153",
3
+ "version": "0.9.82-rc.155",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -73,7 +73,7 @@ Use this if you want to permanently remove a machine.`,confirmLabel:"Remove Mach
73
73
  body { overflow: hidden; overscroll-behavior: none; }
74
74
  `}),s.jsx(Mw,{historyModal:{open:_e,targetConv:kt,ides:b,isCreatingChat:js,isRefreshingHistory:St?!1:ss,savedSessions:Er,savedHistoryFilters:$r,missingWorkspaceResumePath:Or||null,onSavedHistoryFiltersChange:Br,isSavedSessionsLoading:Fr,isResumingSavedSessionId:Hr,onClose:Le,onNewChat:Pr,onSwitchSession:rs,onRefreshHistory:St?Wr:Dr,onResumeSavedSession:Kr},remoteDialog:{conversation:Oe,ideEntry:Ie,ides:b,connectionStates:g,actionLogs:ve,sendDaemonCommand:e,setActionLogs:Y,isStandalone:fe,userName:h.userName,onOpenHistory:We=>{We&&Xe(We),ae()},onConversationChange:Xe,onClose:gt},cliStopDialog:{open:ct,targetConv:dt,onCancel:qt,onStopNow:async()=>{await ee("hard")},onSaveAndStop:async()=>{await ee("save")}},connectionBanner:{wsStatus:j,showReconnected:S,loginUrl:h.connectionLoginUrl,onReconnect:h.retryServerConnection},toastOverlay:{toasts:p,onDismiss:We=>f(_t=>_t.filter(zs=>zs.id!==We)),onClick:We=>{if(We.targetKey){const _t=Ye(We.targetKey);_t&&(Q(_t.tabKey,et),ji(_t),ie(_t.tabKey,"toast-open"))}}},onboarding:{open:k,onClose:()=>{try{localStorage.setItem("adhdev_onboarding_v1","done")}catch{}y(!1)}}})]})}function Rw({machineId:e,registeredMachineId:t,sendDaemonCommand:r,onNicknameSynced:n,logsEndRef:a}){const[o,l]=i.useState([]),[c,d]=i.useState(null),[m,u]=i.useState(null),[h,b]=i.useState(!1),[v,x]=i.useState(null),[f,k]=i.useState(!1),[y,p]=i.useState(""),j=i.useRef(null),w=i.useCallback(D=>{j.current=D},[]),g=i.useCallback((D,L,K=!1)=>{l(F=>[...F.slice(-100),{timestamp:Date.now(),level:D,message:L}]),setTimeout(()=>{var F;return(F=a.current)==null?void 0:F.scrollIntoView({behavior:"smooth"})},100),K&&Qe.showToast(L,D==="error"||D==="warn"?"warning":"success")},[a]),S=i.useCallback(D=>{const L=D instanceof Error?D.message:String(D||"");return L.includes("P2P command timeout")||L.includes("P2P not connected")||L.includes("P2P not available")},[]),M=i.useCallback(async(D,L)=>{var K;if(!e||c)return!1;d(D),g("info",`Launching ${ft(D)}${L!=null&&L.workspace?` in ${L.workspace}`:""}...`);try{const F={ideType:D,enableCdp:!0};(K=L==null?void 0:L.workspace)!=null&&K.trim()?F.workspace=L.workspace.trim():L!=null&&L.useDefaultWorkspace&&(F.useDefaultWorkspace=!0);const z=await r(e,"launch_ide",F);return g(z!=null&&z.success?"info":"error",z!=null&&z.success?`${ft(D)} launched`:`Failed: ${z==null?void 0:z.error}`,!0),!!(z!=null&&z.success)}catch(F){return g("error",`Launch error: ${F.message}`,!0),!1}finally{d(null)}},[e,c,g,r]),C=i.useCallback(async D=>{if(!e)return{success:!1};const{cliType:L,dir:K,workspaceId:F,useDefaultWorkspace:z,useHome:Q,argsStr:X,model:oe,resumeSessionId:me}=D;if(!L)return g("warn","Select a CLI or ACP provider first",!0),{success:!1};const ve=X?X.split(/\s+/).filter(Boolean):void 0,Y=(K==null?void 0:K.trim())||(F?"(saved id)":z?"(default workspace)":Q?"(home)":"");g("info",`Launching ${L}${Y?` in ${Y}`:""}${oe?` (model: ${oe})`:""}...`),u(L);try{const xe={cliType:L,cliArgs:ve,initialModel:oe||void 0};K!=null&&K.trim()?xe.dir=K.trim():F?xe.workspaceId=F:z?xe.useDefaultWorkspace=!0:Q&&(xe.useHome=!0),me&&(xe.resumeSessionId=me);const he=await r(e,"launch_cli",xe),ge=(he==null?void 0:he.result)||he;return he!=null&&he.success?(g("info",`${L} launched`,!0),(ge==null?void 0:ge.launchSource)==="home"?g("info","📂 Running in home directory (explicit choice)"):(ge==null?void 0:ge.launchSource)==="defaultWorkspace"&&g("info","📂 Using default workspace (explicit choice)"),{success:!0,sessionId:ge==null?void 0:ge.sessionId}):(g("error",`Failed: ${(he==null?void 0:he.error)||(ge==null?void 0:ge.error)}`,!0),(he==null?void 0:he.code)==="WORKSPACE_LAUNCH_CONTEXT_REQUIRED"&&x({cliType:L,argsStr:X,model:oe}),{success:!1,sessionId:ge==null?void 0:ge.sessionId})}catch(xe){return S(xe)?(g("warn",`${L} launch requested — waiting for session to appear...`,!0),{success:!1,pending:!0}):(g("error",`Launch error: ${xe.message}`,!0),{success:!1})}finally{u(null)}},[e,g,S,r]),N=i.useCallback(async(D,L,K,F)=>e?D?L.trim()?C({cliType:D,dir:L,argsStr:K,model:F}):(x({cliType:D,argsStr:K,model:F}),{success:!1}):(g("warn","Select a provider",!0),{success:!1}):{success:!1},[e,g,C]),B=i.useCallback(async(D,L,K)=>{if(e&&window.confirm(`Stop ${D}?
75
75
  This will terminate the process.`))try{const F=await r(e,"stop_cli",{cliType:D,dir:L,targetSessionId:K});F!=null&&F.success?g("info",`${D} stopped`,!0):g("error",`Stop failed: ${(F==null?void 0:F.error)||"Unknown error"}`,!0)}catch(F){g("error",`Stop failed: ${F.message}`,!0)}},[e,g,r]),_=i.useCallback(async D=>{try{await r(D.daemonId,"restart_ide",{ideType:D.type}),g("info",`${ft(D.type)} restart initiated`,!0)}catch(L){g("error",`Restart failed: ${L.message}`,!0)}},[g,r]),T=i.useCallback(async D=>{if(window.confirm(`Stop ${ft(D.type)}?
76
- This will disconnect CDP and optionally kill the process.`))try{const L=await r(D.daemonId,"stop_ide",{ideType:D.type,killProcess:!0});L!=null&&L.success?g("info",`${ft(D.type)} stopped`,!0):g("error",`Stop failed: ${(L==null?void 0:L.error)||"Unknown error"}`,!0)}catch(L){g("error",`Stop failed: ${L.message}`,!0)}},[g,r]),H=i.useCallback(async()=>{if(e)try{const D=await r(e,"detect_ides",{});g("info",`Found ${((D==null?void 0:D.result)||[]).length} IDE(s)`,!0)}catch(D){g("error",`Detection failed: ${D.message}`,!0)}},[e,g,r]),P=i.useCallback(async D=>{if(!e||!D.trim())return!1;b(!0);try{const L=await r(e,"workspace_add",{path:D.trim()});return L!=null&&L.success?(g("info",`Workspace added: ${D.trim()}`),!0):(g("error",(L==null?void 0:L.error)||"workspace_add failed"),!1)}catch(L){return g("error",L.message),!1}finally{b(!1)}},[e,g,r]),O=i.useCallback(async D=>{if(!(!e||!window.confirm("Remove this workspace from the list?"))){b(!0);try{const L=await r(e,"workspace_remove",{id:D});L!=null&&L.success?g("info","Workspace removed",!0):g("error",(L==null?void 0:L.error)||"workspace_remove failed",!0)}catch(L){g("error",L.message,!0)}finally{b(!1)}}},[e,g,r]),A=i.useCallback(async D=>{var L;if(e){b(!0);try{const K=await r(e,"workspace_set_default",D===null?{clear:!0}:{id:D});if(K!=null&&K.success){g("info",D?"Default workspace updated":"Default workspace cleared",!0);const F=typeof K.defaultWorkspacePath=="string"?K.defaultWorkspacePath:"";F&&((L=j.current)==null||L.call(j,F))}else g("error",(K==null?void 0:K.error)||"workspace_set_default failed",!0)}catch(K){g("error",K.message,!0)}finally{b(!1)}}},[e,g,r]),I=i.useCallback(async D=>{var K;if(!e||!D.trim())return;const L=D.trim();b(!0);try{const F=await r(e,"workspace_set_default",{path:L});F!=null&&F.success?(g("info","Default workspace set from history"),(K=j.current)==null||K.call(j,L)):g("error",(F==null?void 0:F.error)||"Could not set default (path missing on disk?)")}catch(F){g("error",F.message)}finally{b(!1)}},[e,g,r]),E=i.useCallback(async()=>{if(e)try{if(await r(e,"set_machine_nickname",{nickname:y}),n)try{await n({machineRuntimeId:e,registeredMachineId:t,nickname:y})}catch(D){g("warn",`Live nickname updated, but account sync failed: ${D.message}`)}g("info",`Nickname set to "${y||"(cleared)"}"`),k(!1)}catch(D){g("error",`Failed: ${D.message}`)}},[e,y,t,g,n,r]);return{logs:o,launchingIde:c,launchingAgentType:m,workspaceBusy:h,launchPick:v,setLaunchPick:x,editingNickname:f,setEditingNickname:k,nicknameInput:y,setNicknameInput:p,addLog:g,handleLaunchIde:M,runLaunchCliCore:C,handleLaunchCli:N,handleStopCli:B,handleRestartIde:_,handleStopIde:T,handleDetectIdes:H,handleWorkspaceAdd:P,handleWorkspaceRemove:O,handleWorkspaceSetDefault:A,handleWorkspaceResumePath:I,handleSaveNickname:E,setOnDefaultWorkspaceChanged:w}}function Pw({machine:e,ideSessions:t,cliSessions:r,acpSessions:n}){var d;const a=typeof e.uptime=="number"||typeof e.freeMem=="number"||typeof e.availableMem=="number"||Array.isArray(e.loadavg)&&e.loadavg.length>0,o=e.availableMem??e.freeMem??e.totalMem,l=a&&e.totalMem>0?Math.min(100,Math.max(0,Math.round((e.totalMem-o)/e.totalMem*100))):0,c=((d=e.loadavg)==null?void 0:d[0])||0;return s.jsxs("div",{children:[s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5 mb-5",children:[s.jsx(qr,{icon:s.jsx(bc,{size:16}),label:"Uptime",value:typeof e.uptime=="number"?dp(e.uptime):"Waiting…"}),s.jsx(qr,{icon:s.jsx($t,{size:16}),label:"IDEs",value:`${t.length}`}),s.jsx(qr,{icon:s.jsx(Po,{size:16}),label:"CLIs",value:`${r.length}`}),s.jsx(qr,{icon:s.jsx(dh,{size:16}),label:"ACPs",value:`${n.length}`})]}),s.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[s.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-3",children:"Resource Usage"}),s.jsxs("div",{className:"flex gap-6",children:[s.jsx(Fi,{value:a?Math.min(Math.round(c/e.cpus*100),100):0,max:100,label:"CPU Load",color:"#8b5cf6",detail:a?`${c.toFixed(2)} avg / ${e.cpus} cores`:"Polled from machine page"}),s.jsx(Fi,{value:l,max:100,label:"Memory",color:"#3b82f6",detail:a?`${ha(e.totalMem-o)} / ${ha(e.totalMem)}${e.platform==="darwin"?" (approx.)":""}`:`Polled from machine page · ${ha(e.totalMem)} total`})]})]})]})}function Dw(e){if(!e||typeof e!="object")return null;const t=e,r=t.result&&typeof t.result=="object"?t.result:t;return!r.settings||typeof r.settings!="object"?null:{settings:r.settings,values:r.values&&typeof r.values=="object"?r.values:{}}}function Ew(e,t,r){const n=[];for(const[a,o]of Object.entries(e.settings)){const l=r!=null&&r.filterSchema?r.filterSchema(o):o;if(l.length===0)continue;const c=t.find(d=>d.type===a);n.push({type:a,displayName:(c==null?void 0:c.displayName)||a,icon:(c==null?void 0:c.icon)||"",category:(c==null?void 0:c.category)||"unknown",schema:l,values:e.values[a]||{}})}return n}function Ka(e){if(!e||typeof e!="object")return!1;const t=e;return(t.sourceMode==="normal"||t.sourceMode==="no-upstream")&&typeof t.disableUpstream=="boolean"&&(t.explicitProviderDir===null||typeof t.explicitProviderDir=="string")&&typeof t.userDir=="string"&&typeof t.upstreamDir=="string"&&Array.isArray(t.providerRoots)}function Gl(e){if(!e||typeof e!="object")return null;if(Ka(e))return e;const t=e,r=t.result;return Ka(r)?r:Ka(t.sourceConfig)?t.sourceConfig:null}function $w(e){const t=e.trim();return t||null}function Bw({machineId:e,providers:t,sendDaemonCommand:r,onClose:n,onCreated:a}){var g;const o=t.filter(S=>S.category==="ide"),[l,c]=i.useState(((g=o[0])==null?void 0:g.type)||""),[d,m]=i.useState(""),[u,h]=i.useState(""),[b,v]=i.useState(!1),[x,f]=i.useState(""),[k,y]=i.useState(!1),p=S=>{const M=S.toLowerCase().replace(/[^a-z0-9-]/g,"");m(M),(!u||u===j(d))&&h(j(M))},j=S=>S.split("-").map(M=>M.charAt(0).toUpperCase()+M.slice(1)).join(" "),w=async()=>{if(!(!d||!u||!l)){v(!0),f("");try{const S=await r(e,"provider_clone",{type:d,name:u,category:"ide",location:"user",cloneFrom:l});S!=null&&S.success||S!=null&&S.created?(y(!0),a==null||a(d)):f((S==null?void 0:S.error)||"Failed to create provider")}catch(S){f((S==null?void 0:S.message)||"Connection failed")}v(!1)}};return s.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center overflow-y-auto bg-black/60 backdrop-blur-sm px-2 pt-[calc(8px+env(safe-area-inset-top,0px))] pb-[calc(8px+env(safe-area-inset-bottom,0px))] sm:items-center sm:p-4",onClick:n,children:s.jsxs("div",{className:"w-full max-w-[480px] max-h-[calc(100dvh-env(safe-area-inset-top,0px)-env(safe-area-inset-bottom,0px)-16px)] rounded-[24px] sm:rounded-2xl bg-bg-primary border border-border-subtle shadow-2xl flex flex-col overflow-hidden",onClick:S=>S.stopPropagation(),children:[s.jsxs("div",{className:"px-5 py-4 border-b border-border-subtle",children:[s.jsx("h2",{className:"text-[15px] font-semibold text-text-primary",children:"✨ Create User Provider"}),s.jsx("p",{className:"text-[11px] text-text-muted mt-0.5",children:"Clone an upstream IDE provider to customize"})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3 sm:px-5 sm:py-4 flex flex-col gap-4",children:k?s.jsxs("div",{className:"text-center py-6",children:[s.jsx("div",{className:"text-3xl mb-2",children:"🎉"}),s.jsx("h3",{className:"text-[14px] font-semibold text-text-primary",children:"Provider Created!"}),s.jsxs("p",{className:"text-[11px] text-text-muted mt-1",children:[s.jsx("code",{className:"text-violet-400",children:d})," has been created at ",s.jsxs("code",{className:"text-green-400",children:["~/.adhdev/providers/",d,"/"]})]}),s.jsxs("p",{className:"text-[11px] text-text-muted mt-2",children:["Run ",s.jsxs("code",{className:"text-violet-400",children:["adhdev provider fix ",d]})," or use Auto-Fix to implement scripts."]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Base Provider"}),s.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:o.map(S=>s.jsxs("button",{onClick:()=>c(S.type),className:"px-2.5 py-2 rounded-lg border text-center transition-all",style:{borderColor:l===S.type?"color-mix(in srgb, var(--accent-primary) 40%, transparent)":"var(--border-subtle)",background:l===S.type?"color-mix(in srgb, var(--accent-primary) 8%, transparent)":"transparent"},children:[s.jsx("div",{className:"text-lg",children:S.icon}),s.jsx("div",{className:"text-[10px] font-medium mt-0.5",style:{color:l===S.type?"#a78bfa":"var(--text-secondary)"},children:S.displayName})]},S.type))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Provider Type (ID)"}),s.jsx("input",{value:d,onChange:S=>p(S.target.value),placeholder:"my-cursor, custom-windsurf...",className:"w-full px-3 py-2 rounded-lg border border-border-subtle bg-bg-secondary text-text-primary text-[12px] placeholder:text-text-muted/50 focus:outline-none focus:border-violet-500/40"}),s.jsxs("p",{className:"text-[10px] text-text-muted mt-1",children:["Lowercase, alphanumeric + hyphens only. Will be created at ",s.jsxs("code",{className:"text-violet-400",children:["~/.adhdev/providers/",d||"...","/"]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Display Name"}),s.jsx("input",{value:u,onChange:S=>h(S.target.value),placeholder:"My Custom IDE",className:"w-full px-3 py-2 rounded-lg border border-border-subtle bg-bg-secondary text-text-primary text-[12px] placeholder:text-text-muted/50 focus:outline-none focus:border-violet-500/40"})]}),x&&s.jsx("div",{className:"px-3 py-2 rounded-lg bg-red-500/[0.06] border border-red-500/20 text-red-400 text-[11px]",children:x})]})}),s.jsx("div",{className:"px-4 py-[calc(12px+env(safe-area-inset-bottom,0px))] sm:px-5 sm:py-3.5 border-t border-border-subtle flex justify-end gap-2 shrink-0",children:k?s.jsx("button",{onClick:n,className:"machine-btn",children:"Close"}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:n,className:"machine-btn",children:"Cancel"}),s.jsx("button",{onClick:w,disabled:!d||!u||b,className:"machine-btn",style:{background:d&&u?"rgba(34,197,94,0.12)":void 0,borderColor:d&&u?"rgba(34,197,94,0.3)":void 0,color:d&&u?"#86efac":void 0,opacity:!d||!u||b?.4:1},children:b?"⏳ Creating...":"✨ Create Provider"})]})})]})})}const Ua=24,Ow={verified:"Verified","declarative-only":"Declarative",extended:"Extended","extended-legacy":"Legacy"},Fw={cli:"CLI",ide:"IDE",extension:"EXT",acp:"ACP"};function Hw(){return typeof window<"u"&&window.location.hostname==="localhost"?"/registry":"https://api.adhf.dev/api/v1/registry"}function Ww({machineId:e,sendDaemonCommand:t,installedTypes:r,onInstalled:n}){const[a,o]=i.useState(!1),[l,c]=i.useState([]),[d,m]=i.useState(0),[u,h]=i.useState(!1),[b,v]=i.useState(!1),[x,f]=i.useState(null),[k,y]=i.useState("all"),[p,j]=i.useState(""),[w,g]=i.useState(""),[S,M]=i.useState("popular"),[C,N]=i.useState(0),[B,_]=i.useState(new Set),[T,H]=i.useState(null),P=i.useRef(null);i.useEffect(()=>{const L=setTimeout(()=>g(p),250);return()=>clearTimeout(L)},[p]),i.useEffect(()=>{N(0)},[k,S,w]);const O=i.useCallback(L=>{const K=Hw(),F=new URL(`${K}/providers`,window.location.origin);return k!=="all"&&F.searchParams.set("category",k),w&&F.searchParams.set("search",w),F.searchParams.set("sort",S),F.searchParams.set("limit",String(Ua)),F.searchParams.set("offset",String(L)),F.toString()},[k,w,S]);i.useEffect(()=>{if(!a)return;h(!0),f(null);let L=!1;return fetch(O(0)).then(K=>{if(!K.ok)throw new Error(`HTTP ${K.status}`);return K.json()}).then(K=>{var F;L||(c(K.providers??[]),m(K.total??((F=K.providers)==null?void 0:F.length)??0),N(Ua))}).catch(K=>{L||f(K instanceof Error?K.message:String(K))}).finally(()=>{L||h(!1)}),()=>{L=!0}},[O,a]),i.useEffect(()=>{if(!a)return;const L=P.current;if(!L)return;const K=new IntersectionObserver(async F=>{var z;if((z=F[0])!=null&&z.isIntersecting&&!(u||b)&&!(l.length>=d)){v(!0);try{const Q=await fetch(O(C));if(!Q.ok)throw new Error(`HTTP ${Q.status}`);const X=await Q.json();c(oe=>[...oe,...X.providers??[]]),m(X.total??d),N(oe=>oe+Ua)}catch{}finally{v(!1)}}},{rootMargin:"200px"});return K.observe(L),()=>K.disconnect()},[a,O,C,l.length,d,u,b]);const A=i.useCallback(async L=>{var K,F;if(!B.has(L.type)){H(null),_(z=>new Set(z).add(L.type));try{const z=await t(e,"install_provider_manifest",{type:L.type});if(!((z==null?void 0:z.success)??((K=z==null?void 0:z.result)==null?void 0:K.success))){const X=(z==null?void 0:z.error)??((F=z==null?void 0:z.result)==null?void 0:F.error)??"install failed";throw new Error(X)}n==null||n()}catch(z){H({type:L.type,message:z instanceof Error?z.message:String(z)})}finally{_(z=>{const Q=new Set(z);return Q.delete(L.type),Q})}}},[B,e,t,n]),I=[{key:"all",label:"All"},{key:"cli",label:"CLI"},{key:"ide",label:"IDE"},{key:"extension",label:"Extension"},{key:"acp",label:"ACP"}],E=[{key:"popular",label:"Popular"},{key:"newest",label:"Newest"},{key:"name",label:"Name"}],D=i.useMemo(()=>l,[l]);return s.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle mb-4",children:[s.jsxs("button",{onClick:()=>o(L=>!L),className:"flex items-center justify-between w-full text-left gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-violet-400",children:"Add provider"}),s.jsx("div",{className:"text-[11px] text-text-muted mt-1",children:"Browse the registry and install provider manifests on this daemon."})]}),s.jsx("span",{className:"text-text-muted text-xs",children:a?"▾":"▸"})]}),a&&s.jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[s.jsx("div",{className:"flex gap-1 flex-wrap",children:I.map(L=>s.jsx("button",{onClick:()=>y(L.key),className:`machine-btn text-[10px] px-2 py-0.5 ${k===L.key?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:L.label},L.key))}),s.jsxs("div",{className:"flex gap-1.5 sm:ml-auto items-center",children:[s.jsx("select",{value:S,onChange:L=>M(L.target.value),className:"machine-input text-[11px]",children:E.map(L=>s.jsx("option",{value:L.key,children:L.label},L.key))}),s.jsx("input",{type:"text",placeholder:"Search…",value:p,onChange:L=>j(L.target.value),className:"machine-input text-[11px] min-w-[140px]"})]})]}),u&&s.jsx("div",{className:"text-text-muted text-[11px] py-6 text-center",children:"Loading registry…"}),!u&&x&&s.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/5 px-3 py-2 text-[11px] text-red-400",children:["Failed to load registry: ",x]}),!u&&!x&&D.length===0&&s.jsx("div",{className:"text-text-muted text-[11px] py-6 text-center",children:w?`No providers matching "${w}".`:"No providers found."}),!u&&!x&&D.length>0&&s.jsx("div",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-3",children:D.map(L=>{const K=r.has(L.type),F=B.has(L.type),z=L.manifest,Q=typeof z.icon=="string"?z.icon:"📦",X=typeof z.details=="string"?z.details:"",oe=z.links??{},me=oe.docs||oe.homepage||oe.repo;return s.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-3 py-2.5 flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-base shrink-0",children:Q}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-[12px] font-semibold text-text-primary truncate",children:L.displayName}),X&&s.jsx("div",{className:"text-[10px] text-text-muted truncate",children:X})]}),s.jsx("div",{className:"shrink-0",children:K?s.jsx("span",{className:"text-[9px] px-1.5 py-px rounded border bg-green-500/10 border-green-500/25 text-green-400 font-semibold",children:"Installed"}):s.jsx("button",{onClick:()=>void A(L),disabled:F,className:"machine-btn text-[10px] px-2 py-0.5 bg-violet-500/[0.08] border-violet-500/30 text-violet-300 hover:bg-violet-500/[0.16]",children:F?"…":"Install"})})]}),s.jsxs("div",{className:"flex flex-wrap gap-1 items-center text-[9px]",children:[s.jsx("span",{className:"px-1.5 py-px rounded border border-border-subtle text-text-muted",children:Fw[L.category]??L.category}),s.jsx("span",{className:"px-1.5 py-px rounded border border-border-subtle text-text-muted",children:Ow[L.tier]??L.tier}),s.jsxs("span",{className:"text-text-muted",children:["v",L.version]}),s.jsxs("span",{className:"text-text-muted ml-auto",children:["⬇ ",(L.downloadCount??0).toLocaleString()]}),me&&s.jsx("a",{href:me,target:"_blank",rel:"noopener noreferrer",className:"text-violet-400 hover:text-violet-300 ml-1",onClick:ve=>ve.stopPropagation(),children:"↗"})]}),(T==null?void 0:T.type)===L.type&&s.jsx("div",{className:"text-[10px] text-red-400 break-all",children:T.message})]},L.id)})}),!u&&!x&&s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:P,className:"h-1"}),s.jsx("div",{className:"text-[10px] text-text-muted text-center",children:b?"Loading more…":`${D.length} of ${d} provider${d!==1?"s":""}`})]})]})]})}const Kw={detected:"Detected",not_detected:"Not detected",enabled_unchecked:"Enabled (unchecked)",disabled:"Disabled"},Vl={detected:"bg-green-500/[0.10] border-green-500/25 text-green-400",not_detected:"bg-red-500/[0.10] border-red-500/25 text-red-400",enabled_unchecked:"bg-yellow-500/[0.10] border-yellow-500/25 text-yellow-400",disabled:"bg-white/[0.04] border-white/[0.10] text-text-muted"},Uw={acp:"bg-violet-500/10 text-violet-300 border-violet-500/20",cli:"bg-blue-500/10 text-blue-300 border-blue-500/20",ide:"bg-green-500/10 text-green-300 border-green-500/20",extension:"bg-yellow-500/10 text-yellow-300 border-yellow-500/20"};function ql(e){if(!e)return"—";const t=e.ok?"OK":"Failed",r=e.message||e.path||e.command||"";return r?`${t} — ${r}`:t}function zw(e){return e==="cli"||e==="acp"}function Gw({prov:e,providerInfo:t,savingKey:r,onSetSetting:n,onEnableToggle:a,onDetect:o,onResetCommand:l,onUninstall:c}){const[d,m]=i.useState(!1),u=(t==null?void 0:t.enabled)===!0||e.values.enabled===!0,h=t==null?void 0:t.machineStatus,b=u&&h==="disabled"?"enabled_unchecked":h||(u?"enabled_unchecked":"disabled"),v=zw(e.category);return s.jsxs("div",{className:"rounded-xl bg-bg-secondary border border-border-subtle",children:[s.jsxs("button",{onClick:()=>m(x=>!x),className:"w-full px-4 py-2.5 flex items-center gap-3 text-left",children:[s.jsx("span",{className:"text-base shrink-0",children:e.icon}),s.jsx("span",{className:"text-[13px] font-semibold text-text-primary truncate",children:e.displayName}),s.jsx("span",{className:`text-[9px] font-semibold px-1.5 py-px rounded border ${Uw[e.category]??"border-border-subtle text-text-muted"}`,children:e.category.toUpperCase()}),v&&s.jsx("span",{className:`text-[9px] font-semibold px-1.5 py-px rounded border ${Vl[b]??Vl.disabled}`,children:Kw[b]??b}),s.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[v&&s.jsx("button",{onClick:x=>{x.stopPropagation(),a(e.type,!u)},disabled:r===`${e.type}.enabled`,className:`machine-btn text-[10px] px-2 py-0.5 ${u?"text-red-400 border-red-500/25":"text-green-400 border-green-500/25"}`,children:u?"Disable":"Enable"}),s.jsx("span",{className:"text-text-muted text-xs",children:d?"▾":"▸"})]})]}),d&&s.jsxs("div",{className:"border-t border-border-subtle px-4 py-3 flex flex-col gap-3",children:[v&&s.jsxs("div",{className:"grid gap-1 text-[10px] text-text-muted",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-text-secondary font-medium",children:"Detection:"})," ",ql(t==null?void 0:t.lastDetection)]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-text-secondary font-medium",children:"Verification:"})," ",ql(t==null?void 0:t.lastVerification)]})]}),e.schema.length>0&&s.jsx("div",{className:"flex flex-col gap-1.5",children:e.schema.map(x=>s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"text-[11px] font-medium text-text-primary",children:[x.label||x.key,r===`${e.type}.${x.key}`&&s.jsx("span",{className:"ml-1.5 text-[9px] text-violet-500",children:"saving…"})]}),x.description&&s.jsx("div",{className:"text-[10px] text-text-muted mt-px",children:x.description})]}),s.jsx("div",{className:"shrink-0",children:x.type==="boolean"?s.jsx("button",{onClick:()=>void n(e.type,x.key,!(e.values[x.key]??x.default)),className:"w-10 h-[22px] rounded-[11px] border-none relative cursor-pointer transition-colors duration-200",style:{background:e.values[x.key]??x.default?"#8b5cf6":"var(--border-subtle)"},children:s.jsx("div",{className:"w-4 h-4 rounded-full bg-white absolute top-[3px] transition-[left] duration-200 shadow-[0_1px_3px_rgba(0,0,0,0.3)]",style:{left:e.values[x.key]??x.default?21:3}})}):x.type==="number"?s.jsx("input",{type:"number",value:Number(e.values[x.key]??x.default??0)||0,min:x.min,max:x.max,onChange:f=>{const k=parseInt(f.target.value)||0;x.min!==void 0&&k<x.min||x.max!==void 0&&k>x.max||n(e.type,x.key,k)},className:"machine-input w-20 text-center text-[11px]"}):x.type==="select"&&x.options?s.jsx("select",{value:String(e.values[x.key]??x.default??""),onChange:f=>void n(e.type,x.key,f.target.value),className:"machine-input text-[11px]",children:x.options.map(f=>s.jsx("option",{value:f,children:f},f))}):s.jsx("input",{type:"text",defaultValue:String(e.values[x.key]??x.default??""),onBlur:f=>void n(e.type,x.key,f.target.value),className:"machine-input w-[180px] text-[11px]"})})]},x.key))}),s.jsxs("div",{className:"flex gap-1.5 flex-wrap pt-1 border-t border-border-subtle",children:[v&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>void o(e.type),disabled:!u||r===`${e.type}.detect`,className:`machine-btn text-[10px] px-2 py-0.5 text-blue-400 border-blue-500/25 ${u?"":"opacity-40 cursor-not-allowed"}`,title:u?"Run detection for the configured executable":"Enable provider before detection",children:"Detect"}),s.jsx("button",{onClick:()=>void l(e.type),className:"machine-btn text-[10px] px-2 py-0.5",children:"Reset command"})]}),s.jsx("button",{onClick:()=>void c(e.type,e.category),className:"machine-btn text-[10px] px-2 py-0.5 text-red-400 border-red-500/25 ml-auto",title:"Remove manifest from ~/.adhdev/marketplace/",children:"Uninstall"})]})]})]})}function Vw({machineId:e,providers:t,sendDaemonCommand:r}){var A;const[n,a]=i.useState([]),[o,l]=i.useState(!1),[c,d]=i.useState(null),[m,u]=i.useState("all"),[h,b]=i.useState(!1),[v,x]=i.useState(!1),[f,k]=i.useState(null),[y,p]=i.useState("normal"),[j,w]=i.useState(""),[g,S]=i.useState(!1),M=i.useCallback(async()=>{if(e)try{const I=await r(e,"get_provider_source_config",{}),E=Gl(I);E&&(k(E),p(E.sourceMode),w(E.explicitProviderDir||""))}catch{}},[e,r]),C=i.useCallback(async()=>{if(e){l(!0);try{const I=await r(e,"get_provider_settings",{}),E=Dw(I);if(E){const D=Ew(E,t,{filterSchema:L=>L.filter(K=>K.key!=="enabled")});D.sort((L,K)=>L.category.localeCompare(K.category)||L.displayName.localeCompare(K.displayName)),a(D)}}catch{}l(!1)}},[e,t,r]);i.useEffect(()=>{n.length===0&&C(),f||M()},[]);const N=async(I,E,D)=>{d(`${I}.${E}`),a(L=>L.map(K=>K.type===I?{...K,values:{...K.values,[E]:D}}:K));try{const L=await r(e,"set_provider_setting",{providerType:I,key:E,value:D});L!=null&&L.success||C()}catch{C()}d(null)},B=async(I,E)=>{await N(I,"enabled",E),await C()},_=async I=>{d(`${I}.detect`);try{await r(e,"detect_provider",{providerType:I})}finally{await C(),d(null)}},T=async I=>{await N(I,"executablePath",""),await N(I,"executableArgs",""),await C()},H=async(I,E)=>{if(confirm(`Uninstall ${I}? This removes the manifest from ~/.adhdev/marketplace/.`))try{await r(e,"uninstall_provider_manifest",{type:I,category:E})}finally{await C()}},P=async()=>{S(!0);try{const I=await r(e,"set_provider_source_config",{providerSourceMode:y,providerDir:$w(j)}),E=Gl(I);E?(k(E),p(E.sourceMode),w(E.explicitProviderDir||"")):await M(),await C()}catch{await M()}S(!1)},O=n.filter(I=>m==="all"||I.category===m);return s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx(Ww,{machineId:e,sendDaemonCommand:r,installedTypes:new Set(n.map(I=>I.type)),onInstalled:()=>{C()}}),s.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[s.jsxs("div",{className:"flex gap-1 items-center",children:[s.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Filter"}),["all","acp","cli","ide","extension"].map(I=>s.jsx("button",{onClick:()=>u(I),className:`machine-btn text-[10px] px-2 py-0.5 ${m===I?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:I.toUpperCase()},I))]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx("button",{onClick:()=>b(!0),className:"machine-btn text-[10px]",title:"Create a new provider from an existing one",children:"✨ Create"}),s.jsxs("button",{onClick:C,disabled:o,className:"machine-btn text-[10px]",children:[o?"⏳":"↻"," Refresh"]}),s.jsx("button",{onClick:()=>x(I=>!I),className:"machine-btn text-[10px]",title:"Show source configuration (advanced)",children:"⚙ Advanced"})]})]}),v&&s.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-violet-400",children:"Provider source config"}),s.jsx("div",{className:"text-[11px] text-text-muted mt-1",children:"Where the daemon looks for provider manifests. Affects resolution and reloads."})]}),s.jsx("button",{onClick:M,className:"machine-btn text-[10px]",children:"↻ Refresh"})]}),s.jsxs("div",{className:"grid md:grid-cols-[180px_1fr_auto] gap-3 items-end",children:[s.jsxs("label",{className:"flex flex-col gap-1 text-[11px] text-text-secondary",children:[s.jsx("span",{className:"font-medium text-text-primary",children:"Source mode"}),s.jsxs("select",{value:y,onChange:I=>p(I.target.value),className:"machine-input text-[11px]",children:[s.jsx("option",{value:"normal",children:"normal"}),s.jsx("option",{value:"no-upstream",children:"no-upstream"})]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-[11px] text-text-secondary",children:[s.jsx("span",{className:"font-medium text-text-primary",children:"Explicit providerDir"}),s.jsx("input",{type:"text",value:j,onChange:I=>w(I.target.value),placeholder:"Leave blank to use ~/.adhdev/providers",className:"machine-input text-[11px]"})]}),s.jsx("button",{onClick:()=>void P(),disabled:g,className:"machine-btn text-[10px] bg-violet-500/[0.08] border-violet-500/20 text-violet-300 hover:bg-violet-500/[0.14]",children:g?"Applying…":"Apply + Reload"})]}),s.jsxs("div",{className:"mt-3 grid gap-1 text-[10px] text-text-muted",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-text-secondary font-medium",children:"User root:"})," ",(f==null?void 0:f.userDir)||"—"]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-text-secondary font-medium",children:"Upstream root:"})," ",(f==null?void 0:f.upstreamDir)||"—"]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-text-secondary font-medium",children:"Provider roots:"})," ",((A=f==null?void 0:f.providerRoots)==null?void 0:A.join(" → "))||"—"]})]})]}),o&&n.length===0?s.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading provider settings…"}):O.length===0?s.jsx("div",{className:"px-4.5 py-8 rounded-xl border border-border-subtle bg-bg-secondary text-center",children:s.jsx("div",{className:"text-[12px] text-text-muted",children:m==="all"?'No providers installed yet. Open "Add provider" above to install one.':`No ${m.toUpperCase()} providers installed.`})}):s.jsx("div",{className:"flex flex-col gap-1.5",children:O.map(I=>s.jsx(Gw,{prov:I,providerInfo:t.find(E=>E.type===I.type),savingKey:c,onSetSetting:N,onEnableToggle:B,onDetect:_,onResetCommand:T,onUninstall:H},I.type))}),h&&s.jsx(Bw,{machineId:e,providers:t,sendDaemonCommand:r,onClose:()=>b(!1),onCreated:()=>{b(!1),C()}})]})}const qw=[{value:"all",label:"All trace"},{value:"session_host",label:"Session host"}];function Yw({count:e,since:t,category:r}){return{count:e,since:t,...r==="all"?{}:{category:r}}}function Xw(e,t){return t==="all"?e:e.filter(r=>r.category===t)}function Jw(e){return e.trim().toLowerCase()}function aa(e,t){const r=Jw(t);return r?e.some(n=>String(n??"").toLowerCase().includes(r)):!0}function bi(e){if(!e||Object.keys(e).length===0)return"";try{return JSON.stringify(e)}catch{return"[unserializable payload]"}}function Fs(e,t=220){const r=bi(e);return r?r.length>t?`${r.slice(0,t)}…`:r:""}function Qw(e){const t=e&&typeof e=="object"&&"logs"in e?e.logs:e;if(Array.isArray(t))return{kind:t.length>0?"structured":"empty",entries:t.map(r=>{const n=r;return{timestamp:Number(n.ts)||0,level:n.level||"info",message:`[${String(n.category||"daemon")}] ${String(n.message||"")}`.trim()}}),rawText:""};if(typeof t=="string"){const r=t.trim();return{kind:r?"text":"empty",entries:[],rawText:r}}return{kind:"empty",entries:[],rawText:""}}function Zw(e,t){return e.filter(r=>aa([r.level,r.message],t))}function Yl(e){return`${e.timestamp}:${e.level}:${e.message}`}function ej(e,t,r=300){if(t.entries.length>0){const n=new Map;for(const l of e.entries)n.set(Yl(l),l);for(const l of t.entries)n.set(Yl(l),l);const a=Array.from(n.values()).sort((l,c)=>l.timestamp-c.timestamp).slice(-r),o=a.reduce((l,c)=>Math.max(l,Number(c.timestamp||0)),e.lastTs);return{entries:a,kind:"structured",rawText:"",lastTs:o}}return t.kind==="text"?e.entries.length>0?e:{entries:[],kind:"text",rawText:t.rawText,lastTs:e.lastTs}:e.entries.length>0||e.rawText?e:{entries:[],kind:"empty",rawText:"",lastTs:e.lastTs}}function tj(e,t,r=120){if(t.length===0)return e;const n=new Map;for(const a of e)n.set(a.id,a);for(const a of t)n.set(a.id,a);return Array.from(n.values()).sort((a,o)=>a.ts-o.ts).slice(-r)}function sj(e,t){return e.split(`
76
+ This will disconnect CDP and optionally kill the process.`))try{const L=await r(D.daemonId,"stop_ide",{ideType:D.type,killProcess:!0});L!=null&&L.success?g("info",`${ft(D.type)} stopped`,!0):g("error",`Stop failed: ${(L==null?void 0:L.error)||"Unknown error"}`,!0)}catch(L){g("error",`Stop failed: ${L.message}`,!0)}},[g,r]),H=i.useCallback(async()=>{if(e)try{const D=await r(e,"detect_ides",{});g("info",`Found ${((D==null?void 0:D.result)||[]).length} IDE(s)`,!0)}catch(D){g("error",`Detection failed: ${D.message}`,!0)}},[e,g,r]),P=i.useCallback(async D=>{if(!e||!D.trim())return!1;b(!0);try{const L=await r(e,"workspace_add",{path:D.trim()});return L!=null&&L.success?(g("info",`Workspace added: ${D.trim()}`),!0):(g("error",(L==null?void 0:L.error)||"workspace_add failed"),!1)}catch(L){return g("error",L.message),!1}finally{b(!1)}},[e,g,r]),O=i.useCallback(async D=>{if(!(!e||!window.confirm("Remove this workspace from the list?"))){b(!0);try{const L=await r(e,"workspace_remove",{id:D});L!=null&&L.success?g("info","Workspace removed",!0):g("error",(L==null?void 0:L.error)||"workspace_remove failed",!0)}catch(L){g("error",L.message,!0)}finally{b(!1)}}},[e,g,r]),A=i.useCallback(async D=>{var L;if(e){b(!0);try{const K=await r(e,"workspace_set_default",D===null?{clear:!0}:{id:D});if(K!=null&&K.success){g("info",D?"Default workspace updated":"Default workspace cleared",!0);const F=typeof K.defaultWorkspacePath=="string"?K.defaultWorkspacePath:"";F&&((L=j.current)==null||L.call(j,F))}else g("error",(K==null?void 0:K.error)||"workspace_set_default failed",!0)}catch(K){g("error",K.message,!0)}finally{b(!1)}}},[e,g,r]),I=i.useCallback(async D=>{var K;if(!e||!D.trim())return;const L=D.trim();b(!0);try{const F=await r(e,"workspace_set_default",{path:L});F!=null&&F.success?(g("info","Default workspace set from history"),(K=j.current)==null||K.call(j,L)):g("error",(F==null?void 0:F.error)||"Could not set default (path missing on disk?)")}catch(F){g("error",F.message)}finally{b(!1)}},[e,g,r]),E=i.useCallback(async()=>{if(e)try{if(await r(e,"set_machine_nickname",{nickname:y}),n)try{await n({machineRuntimeId:e,registeredMachineId:t,nickname:y})}catch(D){g("warn",`Live nickname updated, but account sync failed: ${D.message}`)}g("info",`Nickname set to "${y||"(cleared)"}"`),k(!1)}catch(D){g("error",`Failed: ${D.message}`)}},[e,y,t,g,n,r]);return{logs:o,launchingIde:c,launchingAgentType:m,workspaceBusy:h,launchPick:v,setLaunchPick:x,editingNickname:f,setEditingNickname:k,nicknameInput:y,setNicknameInput:p,addLog:g,handleLaunchIde:M,runLaunchCliCore:C,handleLaunchCli:N,handleStopCli:B,handleRestartIde:_,handleStopIde:T,handleDetectIdes:H,handleWorkspaceAdd:P,handleWorkspaceRemove:O,handleWorkspaceSetDefault:A,handleWorkspaceResumePath:I,handleSaveNickname:E,setOnDefaultWorkspaceChanged:w}}function Pw({machine:e,ideSessions:t,cliSessions:r,acpSessions:n}){var d;const a=typeof e.uptime=="number"||typeof e.freeMem=="number"||typeof e.availableMem=="number"||Array.isArray(e.loadavg)&&e.loadavg.length>0,o=e.availableMem??e.freeMem??e.totalMem,l=a&&e.totalMem>0?Math.min(100,Math.max(0,Math.round((e.totalMem-o)/e.totalMem*100))):0,c=((d=e.loadavg)==null?void 0:d[0])||0;return s.jsxs("div",{children:[s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5 mb-5",children:[s.jsx(qr,{icon:s.jsx(bc,{size:16}),label:"Uptime",value:typeof e.uptime=="number"?dp(e.uptime):"Waiting…"}),s.jsx(qr,{icon:s.jsx($t,{size:16}),label:"IDEs",value:`${t.length}`}),s.jsx(qr,{icon:s.jsx(Po,{size:16}),label:"CLIs",value:`${r.length}`}),s.jsx(qr,{icon:s.jsx(dh,{size:16}),label:"ACPs",value:`${n.length}`})]}),s.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[s.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-3",children:"Resource Usage"}),s.jsxs("div",{className:"flex gap-6",children:[s.jsx(Fi,{value:a?Math.min(Math.round(c/e.cpus*100),100):0,max:100,label:"CPU Load",color:"#8b5cf6",detail:a?`${c.toFixed(2)} avg / ${e.cpus} cores`:"Polled from machine page"}),s.jsx(Fi,{value:l,max:100,label:"Memory",color:"#3b82f6",detail:a?`${ha(e.totalMem-o)} / ${ha(e.totalMem)}${e.platform==="darwin"?" (approx.)":""}`:`Polled from machine page · ${ha(e.totalMem)} total`})]})]})]})}function Dw(e){if(!e||typeof e!="object")return null;const t=e,r=t.result&&typeof t.result=="object"?t.result:t;return!r.settings||typeof r.settings!="object"?null:{settings:r.settings,values:r.values&&typeof r.values=="object"?r.values:{}}}function Ew(e,t,r){const n=[];for(const[a,o]of Object.entries(e.settings)){const l=r!=null&&r.filterSchema?r.filterSchema(o):o;if(l.length===0)continue;const c=t.find(d=>d.type===a);n.push({type:a,displayName:(c==null?void 0:c.displayName)||a,icon:(c==null?void 0:c.icon)||"",category:(c==null?void 0:c.category)||"unknown",schema:l,values:e.values[a]||{}})}return n}function Ka(e){if(!e||typeof e!="object")return!1;const t=e;return(t.sourceMode==="normal"||t.sourceMode==="no-upstream")&&typeof t.disableUpstream=="boolean"&&(t.explicitProviderDir===null||typeof t.explicitProviderDir=="string")&&typeof t.userDir=="string"&&typeof t.upstreamDir=="string"&&Array.isArray(t.providerRoots)}function Gl(e){if(!e||typeof e!="object")return null;if(Ka(e))return e;const t=e,r=t.result;return Ka(r)?r:Ka(t.sourceConfig)?t.sourceConfig:null}function $w(e){const t=e.trim();return t||null}function Bw({machineId:e,providers:t,sendDaemonCommand:r,onClose:n,onCreated:a}){var g;const o=t.filter(S=>S.category==="ide"),[l,c]=i.useState(((g=o[0])==null?void 0:g.type)||""),[d,m]=i.useState(""),[u,h]=i.useState(""),[b,v]=i.useState(!1),[x,f]=i.useState(""),[k,y]=i.useState(!1),p=S=>{const M=S.toLowerCase().replace(/[^a-z0-9-]/g,"");m(M),(!u||u===j(d))&&h(j(M))},j=S=>S.split("-").map(M=>M.charAt(0).toUpperCase()+M.slice(1)).join(" "),w=async()=>{if(!(!d||!u||!l)){v(!0),f("");try{const S=await r(e,"provider_clone",{type:d,name:u,category:"ide",location:"user",cloneFrom:l});S!=null&&S.success||S!=null&&S.created?(y(!0),a==null||a(d)):f((S==null?void 0:S.error)||"Failed to create provider")}catch(S){f((S==null?void 0:S.message)||"Connection failed")}v(!1)}};return s.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center overflow-y-auto bg-black/60 backdrop-blur-sm px-2 pt-[calc(8px+env(safe-area-inset-top,0px))] pb-[calc(8px+env(safe-area-inset-bottom,0px))] sm:items-center sm:p-4",onClick:n,children:s.jsxs("div",{className:"w-full max-w-[480px] max-h-[calc(100dvh-env(safe-area-inset-top,0px)-env(safe-area-inset-bottom,0px)-16px)] rounded-[24px] sm:rounded-2xl bg-bg-primary border border-border-subtle shadow-2xl flex flex-col overflow-hidden",onClick:S=>S.stopPropagation(),children:[s.jsxs("div",{className:"px-5 py-4 border-b border-border-subtle",children:[s.jsx("h2",{className:"text-[15px] font-semibold text-text-primary",children:"✨ Create User Provider"}),s.jsx("p",{className:"text-[11px] text-text-muted mt-0.5",children:"Clone an upstream IDE provider to customize"})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3 sm:px-5 sm:py-4 flex flex-col gap-4",children:k?s.jsxs("div",{className:"text-center py-6",children:[s.jsx("div",{className:"text-3xl mb-2",children:"🎉"}),s.jsx("h3",{className:"text-[14px] font-semibold text-text-primary",children:"Provider Created!"}),s.jsxs("p",{className:"text-[11px] text-text-muted mt-1",children:[s.jsx("code",{className:"text-violet-400",children:d})," has been created at ",s.jsxs("code",{className:"text-green-400",children:["~/.adhdev/providers/",d,"/"]})]}),s.jsxs("p",{className:"text-[11px] text-text-muted mt-2",children:["Run ",s.jsxs("code",{className:"text-violet-400",children:["adhdev provider fix ",d]})," or use Auto-Fix to implement scripts."]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Base Provider"}),s.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:o.map(S=>s.jsxs("button",{onClick:()=>c(S.type),className:"px-2.5 py-2 rounded-lg border text-center transition-all",style:{borderColor:l===S.type?"color-mix(in srgb, var(--accent-primary) 40%, transparent)":"var(--border-subtle)",background:l===S.type?"color-mix(in srgb, var(--accent-primary) 8%, transparent)":"transparent"},children:[s.jsx("div",{className:"text-lg",children:S.icon}),s.jsx("div",{className:"text-[10px] font-medium mt-0.5",style:{color:l===S.type?"#a78bfa":"var(--text-secondary)"},children:S.displayName})]},S.type))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Provider Type (ID)"}),s.jsx("input",{value:d,onChange:S=>p(S.target.value),placeholder:"my-cursor, custom-windsurf...",className:"w-full px-3 py-2 rounded-lg border border-border-subtle bg-bg-secondary text-text-primary text-[12px] placeholder:text-text-muted/50 focus:outline-none focus:border-violet-500/40"}),s.jsxs("p",{className:"text-[10px] text-text-muted mt-1",children:["Lowercase, alphanumeric + hyphens only. Will be created at ",s.jsxs("code",{className:"text-violet-400",children:["~/.adhdev/providers/",d||"...","/"]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Display Name"}),s.jsx("input",{value:u,onChange:S=>h(S.target.value),placeholder:"My Custom IDE",className:"w-full px-3 py-2 rounded-lg border border-border-subtle bg-bg-secondary text-text-primary text-[12px] placeholder:text-text-muted/50 focus:outline-none focus:border-violet-500/40"})]}),x&&s.jsx("div",{className:"px-3 py-2 rounded-lg bg-red-500/[0.06] border border-red-500/20 text-red-400 text-[11px]",children:x})]})}),s.jsx("div",{className:"px-4 py-[calc(12px+env(safe-area-inset-bottom,0px))] sm:px-5 sm:py-3.5 border-t border-border-subtle flex justify-end gap-2 shrink-0",children:k?s.jsx("button",{onClick:n,className:"machine-btn",children:"Close"}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:n,className:"machine-btn",children:"Cancel"}),s.jsx("button",{onClick:w,disabled:!d||!u||b,className:"machine-btn",style:{background:d&&u?"rgba(34,197,94,0.12)":void 0,borderColor:d&&u?"rgba(34,197,94,0.3)":void 0,color:d&&u?"#86efac":void 0,opacity:!d||!u||b?.4:1},children:b?"⏳ Creating...":"✨ Create Provider"})]})})]})})}const Ua=24,Ow={verified:"Verified","declarative-only":"Declarative",extended:"Extended","extended-legacy":"Legacy"},Fw={cli:"CLI",ide:"IDE",extension:"EXT",acp:"ACP"};function Hw(){if(typeof window>"u")return"https://api.adhf.dev/api/v1/registry";const e=window.location.hostname;return e==="localhost"||e==="127.0.0.1"?"/registry":e==="adhf.dev"||e==="adhdev-web.pages.dev"?"https://api.adhf.dev/api/v1/registry":"https://api-preview.adhf.dev/api/v1/registry"}function Ww({machineId:e,sendDaemonCommand:t,installedTypes:r,onInstalled:n}){const[a,o]=i.useState(!1),[l,c]=i.useState([]),[d,m]=i.useState(0),[u,h]=i.useState(!1),[b,v]=i.useState(!1),[x,f]=i.useState(null),[k,y]=i.useState("all"),[p,j]=i.useState(""),[w,g]=i.useState(""),[S,M]=i.useState("popular"),[C,N]=i.useState(0),[B,_]=i.useState(new Set),[T,H]=i.useState(null),P=i.useRef(null);i.useEffect(()=>{const L=setTimeout(()=>g(p),250);return()=>clearTimeout(L)},[p]),i.useEffect(()=>{N(0)},[k,S,w]);const O=i.useCallback(L=>{const K=Hw(),F=new URL(`${K}/providers`,window.location.origin);return k!=="all"&&F.searchParams.set("category",k),w&&F.searchParams.set("search",w),F.searchParams.set("sort",S),F.searchParams.set("limit",String(Ua)),F.searchParams.set("offset",String(L)),F.toString()},[k,w,S]);i.useEffect(()=>{if(!a)return;h(!0),f(null);let L=!1;return fetch(O(0)).then(K=>{if(!K.ok)throw new Error(`HTTP ${K.status}`);return K.json()}).then(K=>{var F;L||(c(K.providers??[]),m(K.total??((F=K.providers)==null?void 0:F.length)??0),N(Ua))}).catch(K=>{L||f(K instanceof Error?K.message:String(K))}).finally(()=>{L||h(!1)}),()=>{L=!0}},[O,a]),i.useEffect(()=>{if(!a)return;const L=P.current;if(!L)return;const K=new IntersectionObserver(async F=>{var z;if((z=F[0])!=null&&z.isIntersecting&&!(u||b)&&!(l.length>=d)){v(!0);try{const Q=await fetch(O(C));if(!Q.ok)throw new Error(`HTTP ${Q.status}`);const X=await Q.json();c(oe=>[...oe,...X.providers??[]]),m(X.total??d),N(oe=>oe+Ua)}catch{}finally{v(!1)}}},{rootMargin:"200px"});return K.observe(L),()=>K.disconnect()},[a,O,C,l.length,d,u,b]);const A=i.useCallback(async L=>{var K,F;if(!B.has(L.type)){H(null),_(z=>new Set(z).add(L.type));try{const z=await t(e,"install_provider_manifest",{type:L.type});if(!((z==null?void 0:z.success)??((K=z==null?void 0:z.result)==null?void 0:K.success))){const X=(z==null?void 0:z.error)??((F=z==null?void 0:z.result)==null?void 0:F.error)??"install failed";throw new Error(X)}n==null||n()}catch(z){H({type:L.type,message:z instanceof Error?z.message:String(z)})}finally{_(z=>{const Q=new Set(z);return Q.delete(L.type),Q})}}},[B,e,t,n]),I=[{key:"all",label:"All"},{key:"cli",label:"CLI"},{key:"ide",label:"IDE"},{key:"extension",label:"Extension"},{key:"acp",label:"ACP"}],E=[{key:"popular",label:"Popular"},{key:"newest",label:"Newest"},{key:"name",label:"Name"}],D=i.useMemo(()=>l,[l]);return s.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle mb-4",children:[s.jsxs("button",{onClick:()=>o(L=>!L),className:"flex items-center justify-between w-full text-left gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-violet-400",children:"Add provider"}),s.jsx("div",{className:"text-[11px] text-text-muted mt-1",children:"Browse the registry and install provider manifests on this daemon."})]}),s.jsx("span",{className:"text-text-muted text-xs",children:a?"▾":"▸"})]}),a&&s.jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[s.jsx("div",{className:"flex gap-1 flex-wrap",children:I.map(L=>s.jsx("button",{onClick:()=>y(L.key),className:`machine-btn text-[10px] px-2 py-0.5 ${k===L.key?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:L.label},L.key))}),s.jsxs("div",{className:"flex gap-1.5 sm:ml-auto items-center",children:[s.jsx("select",{value:S,onChange:L=>M(L.target.value),className:"machine-input text-[11px]",children:E.map(L=>s.jsx("option",{value:L.key,children:L.label},L.key))}),s.jsx("input",{type:"text",placeholder:"Search…",value:p,onChange:L=>j(L.target.value),className:"machine-input text-[11px] min-w-[140px]"})]})]}),u&&s.jsx("div",{className:"text-text-muted text-[11px] py-6 text-center",children:"Loading registry…"}),!u&&x&&s.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/5 px-3 py-2 text-[11px] text-red-400",children:["Failed to load registry: ",x]}),!u&&!x&&D.length===0&&s.jsx("div",{className:"text-text-muted text-[11px] py-6 text-center",children:w?`No providers matching "${w}".`:"No providers found."}),!u&&!x&&D.length>0&&s.jsx("div",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-3",children:D.map(L=>{const K=r.has(L.type),F=B.has(L.type),z=L.manifest,Q=typeof z.icon=="string"?z.icon:"📦",X=typeof z.details=="string"?z.details:"",oe=z.links??{},me=oe.docs||oe.homepage||oe.repo;return s.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-3 py-2.5 flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-base shrink-0",children:Q}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-[12px] font-semibold text-text-primary truncate",children:L.displayName}),X&&s.jsx("div",{className:"text-[10px] text-text-muted truncate",children:X})]}),s.jsx("div",{className:"shrink-0",children:K?s.jsx("span",{className:"text-[9px] px-1.5 py-px rounded border bg-green-500/10 border-green-500/25 text-green-400 font-semibold",children:"Installed"}):s.jsx("button",{onClick:()=>void A(L),disabled:F,className:"machine-btn text-[10px] px-2 py-0.5 bg-violet-500/[0.08] border-violet-500/30 text-violet-300 hover:bg-violet-500/[0.16]",children:F?"…":"Install"})})]}),s.jsxs("div",{className:"flex flex-wrap gap-1 items-center text-[9px]",children:[s.jsx("span",{className:"px-1.5 py-px rounded border border-border-subtle text-text-muted",children:Fw[L.category]??L.category}),s.jsx("span",{className:"px-1.5 py-px rounded border border-border-subtle text-text-muted",children:Ow[L.tier]??L.tier}),s.jsxs("span",{className:"text-text-muted",children:["v",L.version]}),s.jsxs("span",{className:"text-text-muted ml-auto",children:["⬇ ",(L.downloadCount??0).toLocaleString()]}),me&&s.jsx("a",{href:me,target:"_blank",rel:"noopener noreferrer",className:"text-violet-400 hover:text-violet-300 ml-1",onClick:ve=>ve.stopPropagation(),children:"↗"})]}),(T==null?void 0:T.type)===L.type&&s.jsx("div",{className:"text-[10px] text-red-400 break-all",children:T.message})]},L.id)})}),!u&&!x&&s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:P,className:"h-1"}),s.jsx("div",{className:"text-[10px] text-text-muted text-center",children:b?"Loading more…":`${D.length} of ${d} provider${d!==1?"s":""}`})]})]})]})}const Kw={detected:"Detected",not_detected:"Not detected",enabled_unchecked:"Enabled (unchecked)",disabled:"Disabled"},Vl={detected:"bg-green-500/[0.10] border-green-500/25 text-green-400",not_detected:"bg-red-500/[0.10] border-red-500/25 text-red-400",enabled_unchecked:"bg-yellow-500/[0.10] border-yellow-500/25 text-yellow-400",disabled:"bg-white/[0.04] border-white/[0.10] text-text-muted"},Uw={acp:"bg-violet-500/10 text-violet-300 border-violet-500/20",cli:"bg-blue-500/10 text-blue-300 border-blue-500/20",ide:"bg-green-500/10 text-green-300 border-green-500/20",extension:"bg-yellow-500/10 text-yellow-300 border-yellow-500/20"};function ql(e){if(!e)return"—";const t=e.ok?"OK":"Failed",r=e.message||e.path||e.command||"";return r?`${t} — ${r}`:t}function zw(e){return e==="cli"||e==="acp"}function Gw({prov:e,providerInfo:t,savingKey:r,onSetSetting:n,onEnableToggle:a,onDetect:o,onResetCommand:l,onUninstall:c}){const[d,m]=i.useState(!1),u=(t==null?void 0:t.enabled)===!0||e.values.enabled===!0,h=t==null?void 0:t.machineStatus,b=u&&h==="disabled"?"enabled_unchecked":h||(u?"enabled_unchecked":"disabled"),v=zw(e.category);return s.jsxs("div",{className:"rounded-xl bg-bg-secondary border border-border-subtle",children:[s.jsxs("button",{onClick:()=>m(x=>!x),className:"w-full px-4 py-2.5 flex items-center gap-3 text-left",children:[s.jsx("span",{className:"text-base shrink-0",children:e.icon}),s.jsx("span",{className:"text-[13px] font-semibold text-text-primary truncate",children:e.displayName}),s.jsx("span",{className:`text-[9px] font-semibold px-1.5 py-px rounded border ${Uw[e.category]??"border-border-subtle text-text-muted"}`,children:e.category.toUpperCase()}),v&&s.jsx("span",{className:`text-[9px] font-semibold px-1.5 py-px rounded border ${Vl[b]??Vl.disabled}`,children:Kw[b]??b}),s.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[v&&s.jsx("button",{onClick:x=>{x.stopPropagation(),a(e.type,!u)},disabled:r===`${e.type}.enabled`,className:`machine-btn text-[10px] px-2 py-0.5 ${u?"text-red-400 border-red-500/25":"text-green-400 border-green-500/25"}`,children:u?"Disable":"Enable"}),s.jsx("span",{className:"text-text-muted text-xs",children:d?"▾":"▸"})]})]}),d&&s.jsxs("div",{className:"border-t border-border-subtle px-4 py-3 flex flex-col gap-3",children:[v&&s.jsxs("div",{className:"grid gap-1 text-[10px] text-text-muted",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-text-secondary font-medium",children:"Detection:"})," ",ql(t==null?void 0:t.lastDetection)]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-text-secondary font-medium",children:"Verification:"})," ",ql(t==null?void 0:t.lastVerification)]})]}),e.schema.length>0&&s.jsx("div",{className:"flex flex-col gap-1.5",children:e.schema.map(x=>s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"text-[11px] font-medium text-text-primary",children:[x.label||x.key,r===`${e.type}.${x.key}`&&s.jsx("span",{className:"ml-1.5 text-[9px] text-violet-500",children:"saving…"})]}),x.description&&s.jsx("div",{className:"text-[10px] text-text-muted mt-px",children:x.description})]}),s.jsx("div",{className:"shrink-0",children:x.type==="boolean"?s.jsx("button",{onClick:()=>void n(e.type,x.key,!(e.values[x.key]??x.default)),className:"w-10 h-[22px] rounded-[11px] border-none relative cursor-pointer transition-colors duration-200",style:{background:e.values[x.key]??x.default?"#8b5cf6":"var(--border-subtle)"},children:s.jsx("div",{className:"w-4 h-4 rounded-full bg-white absolute top-[3px] transition-[left] duration-200 shadow-[0_1px_3px_rgba(0,0,0,0.3)]",style:{left:e.values[x.key]??x.default?21:3}})}):x.type==="number"?s.jsx("input",{type:"number",value:Number(e.values[x.key]??x.default??0)||0,min:x.min,max:x.max,onChange:f=>{const k=parseInt(f.target.value)||0;x.min!==void 0&&k<x.min||x.max!==void 0&&k>x.max||n(e.type,x.key,k)},className:"machine-input w-20 text-center text-[11px]"}):x.type==="select"&&x.options?s.jsx("select",{value:String(e.values[x.key]??x.default??""),onChange:f=>void n(e.type,x.key,f.target.value),className:"machine-input text-[11px]",children:x.options.map(f=>s.jsx("option",{value:f,children:f},f))}):s.jsx("input",{type:"text",defaultValue:String(e.values[x.key]??x.default??""),onBlur:f=>void n(e.type,x.key,f.target.value),className:"machine-input w-[180px] text-[11px]"})})]},x.key))}),s.jsxs("div",{className:"flex gap-1.5 flex-wrap pt-1 border-t border-border-subtle",children:[v&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>void o(e.type),disabled:!u||r===`${e.type}.detect`,className:`machine-btn text-[10px] px-2 py-0.5 text-blue-400 border-blue-500/25 ${u?"":"opacity-40 cursor-not-allowed"}`,title:u?"Run detection for the configured executable":"Enable provider before detection",children:"Detect"}),s.jsx("button",{onClick:()=>void l(e.type),className:"machine-btn text-[10px] px-2 py-0.5",children:"Reset command"})]}),s.jsx("button",{onClick:()=>void c(e.type,e.category),className:"machine-btn text-[10px] px-2 py-0.5 text-red-400 border-red-500/25 ml-auto",title:"Remove manifest from ~/.adhdev/marketplace/",children:"Uninstall"})]})]})]})}function Vw({machineId:e,providers:t,sendDaemonCommand:r}){var A;const[n,a]=i.useState([]),[o,l]=i.useState(!1),[c,d]=i.useState(null),[m,u]=i.useState("all"),[h,b]=i.useState(!1),[v,x]=i.useState(!1),[f,k]=i.useState(null),[y,p]=i.useState("normal"),[j,w]=i.useState(""),[g,S]=i.useState(!1),M=i.useCallback(async()=>{if(e)try{const I=await r(e,"get_provider_source_config",{}),E=Gl(I);E&&(k(E),p(E.sourceMode),w(E.explicitProviderDir||""))}catch{}},[e,r]),C=i.useCallback(async()=>{if(e){l(!0);try{const I=await r(e,"get_provider_settings",{}),E=Dw(I);if(E){const D=Ew(E,t,{filterSchema:L=>L.filter(K=>K.key!=="enabled")});D.sort((L,K)=>L.category.localeCompare(K.category)||L.displayName.localeCompare(K.displayName)),a(D)}}catch{}l(!1)}},[e,t,r]);i.useEffect(()=>{n.length===0&&C(),f||M()},[]);const N=async(I,E,D)=>{d(`${I}.${E}`),a(L=>L.map(K=>K.type===I?{...K,values:{...K.values,[E]:D}}:K));try{const L=await r(e,"set_provider_setting",{providerType:I,key:E,value:D});L!=null&&L.success||C()}catch{C()}d(null)},B=async(I,E)=>{await N(I,"enabled",E),await C()},_=async I=>{d(`${I}.detect`);try{await r(e,"detect_provider",{providerType:I})}finally{await C(),d(null)}},T=async I=>{await N(I,"executablePath",""),await N(I,"executableArgs",""),await C()},H=async(I,E)=>{if(confirm(`Uninstall ${I}? This removes the manifest from ~/.adhdev/marketplace/.`))try{await r(e,"uninstall_provider_manifest",{type:I,category:E})}finally{await C()}},P=async()=>{S(!0);try{const I=await r(e,"set_provider_source_config",{providerSourceMode:y,providerDir:$w(j)}),E=Gl(I);E?(k(E),p(E.sourceMode),w(E.explicitProviderDir||"")):await M(),await C()}catch{await M()}S(!1)},O=n.filter(I=>m==="all"||I.category===m);return s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx(Ww,{machineId:e,sendDaemonCommand:r,installedTypes:new Set(n.map(I=>I.type)),onInstalled:()=>{C()}}),s.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[s.jsxs("div",{className:"flex gap-1 items-center",children:[s.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Filter"}),["all","acp","cli","ide","extension"].map(I=>s.jsx("button",{onClick:()=>u(I),className:`machine-btn text-[10px] px-2 py-0.5 ${m===I?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:I.toUpperCase()},I))]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx("button",{onClick:()=>b(!0),className:"machine-btn text-[10px]",title:"Create a new provider from an existing one",children:"✨ Create"}),s.jsxs("button",{onClick:C,disabled:o,className:"machine-btn text-[10px]",children:[o?"⏳":"↻"," Refresh"]}),s.jsx("button",{onClick:()=>x(I=>!I),className:"machine-btn text-[10px]",title:"Show source configuration (advanced)",children:"⚙ Advanced"})]})]}),v&&s.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-violet-400",children:"Provider source config"}),s.jsx("div",{className:"text-[11px] text-text-muted mt-1",children:"Where the daemon looks for provider manifests. Affects resolution and reloads."})]}),s.jsx("button",{onClick:M,className:"machine-btn text-[10px]",children:"↻ Refresh"})]}),s.jsxs("div",{className:"grid md:grid-cols-[180px_1fr_auto] gap-3 items-end",children:[s.jsxs("label",{className:"flex flex-col gap-1 text-[11px] text-text-secondary",children:[s.jsx("span",{className:"font-medium text-text-primary",children:"Source mode"}),s.jsxs("select",{value:y,onChange:I=>p(I.target.value),className:"machine-input text-[11px]",children:[s.jsx("option",{value:"normal",children:"normal"}),s.jsx("option",{value:"no-upstream",children:"no-upstream"})]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-[11px] text-text-secondary",children:[s.jsx("span",{className:"font-medium text-text-primary",children:"Explicit providerDir"}),s.jsx("input",{type:"text",value:j,onChange:I=>w(I.target.value),placeholder:"Leave blank to use ~/.adhdev/providers",className:"machine-input text-[11px]"})]}),s.jsx("button",{onClick:()=>void P(),disabled:g,className:"machine-btn text-[10px] bg-violet-500/[0.08] border-violet-500/20 text-violet-300 hover:bg-violet-500/[0.14]",children:g?"Applying…":"Apply + Reload"})]}),s.jsxs("div",{className:"mt-3 grid gap-1 text-[10px] text-text-muted",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-text-secondary font-medium",children:"User root:"})," ",(f==null?void 0:f.userDir)||"—"]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-text-secondary font-medium",children:"Upstream root:"})," ",(f==null?void 0:f.upstreamDir)||"—"]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-text-secondary font-medium",children:"Provider roots:"})," ",((A=f==null?void 0:f.providerRoots)==null?void 0:A.join(" → "))||"—"]})]})]}),o&&n.length===0?s.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading provider settings…"}):O.length===0?s.jsx("div",{className:"px-4.5 py-8 rounded-xl border border-border-subtle bg-bg-secondary text-center",children:s.jsx("div",{className:"text-[12px] text-text-muted",children:m==="all"?'No providers installed yet. Open "Add provider" above to install one.':`No ${m.toUpperCase()} providers installed.`})}):s.jsx("div",{className:"flex flex-col gap-1.5",children:O.map(I=>s.jsx(Gw,{prov:I,providerInfo:t.find(E=>E.type===I.type),savingKey:c,onSetSetting:N,onEnableToggle:B,onDetect:_,onResetCommand:T,onUninstall:H},I.type))}),h&&s.jsx(Bw,{machineId:e,providers:t,sendDaemonCommand:r,onClose:()=>b(!1),onCreated:()=>{b(!1),C()}})]})}const qw=[{value:"all",label:"All trace"},{value:"session_host",label:"Session host"}];function Yw({count:e,since:t,category:r}){return{count:e,since:t,...r==="all"?{}:{category:r}}}function Xw(e,t){return t==="all"?e:e.filter(r=>r.category===t)}function Jw(e){return e.trim().toLowerCase()}function aa(e,t){const r=Jw(t);return r?e.some(n=>String(n??"").toLowerCase().includes(r)):!0}function bi(e){if(!e||Object.keys(e).length===0)return"";try{return JSON.stringify(e)}catch{return"[unserializable payload]"}}function Fs(e,t=220){const r=bi(e);return r?r.length>t?`${r.slice(0,t)}…`:r:""}function Qw(e){const t=e&&typeof e=="object"&&"logs"in e?e.logs:e;if(Array.isArray(t))return{kind:t.length>0?"structured":"empty",entries:t.map(r=>{const n=r;return{timestamp:Number(n.ts)||0,level:n.level||"info",message:`[${String(n.category||"daemon")}] ${String(n.message||"")}`.trim()}}),rawText:""};if(typeof t=="string"){const r=t.trim();return{kind:r?"text":"empty",entries:[],rawText:r}}return{kind:"empty",entries:[],rawText:""}}function Zw(e,t){return e.filter(r=>aa([r.level,r.message],t))}function Yl(e){return`${e.timestamp}:${e.level}:${e.message}`}function ej(e,t,r=300){if(t.entries.length>0){const n=new Map;for(const l of e.entries)n.set(Yl(l),l);for(const l of t.entries)n.set(Yl(l),l);const a=Array.from(n.values()).sort((l,c)=>l.timestamp-c.timestamp).slice(-r),o=a.reduce((l,c)=>Math.max(l,Number(c.timestamp||0)),e.lastTs);return{entries:a,kind:"structured",rawText:"",lastTs:o}}return t.kind==="text"?e.entries.length>0?e:{entries:[],kind:"text",rawText:t.rawText,lastTs:e.lastTs}:e.entries.length>0||e.rawText?e:{entries:[],kind:"empty",rawText:"",lastTs:e.lastTs}}function tj(e,t,r=120){if(t.length===0)return e;const n=new Map;for(const a of e)n.set(a.id,a);for(const a of t)n.set(a.id,a);return Array.from(n.values()).sort((a,o)=>a.ts-o.ts).slice(-r)}function sj(e,t){return e.split(`
77
77
  `).map(r=>r.trimEnd()).filter(Boolean).filter(r=>aa([r],t))}function rj(e,t){return e.filter(r=>aa([r.level,r.category,r.stage,r.interactionId,bi(r.payload)],t))}function nj(e,t){return e.filter(r=>aa([r.kind,r.topic,r.interactionId,bi(r.payload)],t))}function Xl(e){return e==="warn"||e==="error"}function aj({daemonLogs:e,daemonRawLines:t,trace:r,webEvents:n}){return{all:e.length+t.length+r.length+n.length,info:e.filter(a=>a.level!=="debug").length+r.filter(a=>a.level!=="debug").length+n.length,issues:e.filter(a=>Xl(a.level)).length+r.filter(a=>Xl(a.level)).length}}function oj({daemonLogs:e,daemonRawLines:t,trace:r,webEvents:n}){const a=[];return e.length>0?a.push(["[daemon logs]",...e.map(o=>`${new Date(o.timestamp).toISOString()} ${o.level.toUpperCase()} ${o.message}`)].join(`
78
78
  `)):t.length>0&&a.push(["[daemon logs]",...t].join(`
79
79
  `)),r.length>0&&a.push(["[trace]",...r.map(o=>`${new Date(o.ts).toISOString()} ${o.level.toUpperCase()} ${o.category}.${o.stage} ${Fs(o.payload,500)}`.trim())].join(`
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-Dpa94xrO.js"></script>
10
+ <script type="module" crossorigin src="/assets/index-DVw__4V7.js"></script>
11
11
  <link rel="modulepreload" crossorigin href="/assets/vendor-DNk1FT1R.js">
12
12
  <link rel="stylesheet" crossorigin href="/assets/index-BJ64Ym2t.css">
13
13
  </head>