@adhdev/daemon-standalone 0.7.7 → 0.7.9

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.7.7",
3
+ "version": "0.7.9",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -10,14 +10,16 @@
10
10
  "scripts": {
11
11
  "build": "tsup",
12
12
  "bundle:web": "node -e \"const{cpSync,mkdirSync}=require('fs');mkdirSync('public',{recursive:true});cpSync('../web-standalone/dist','public',{recursive:true});console.log('bundled web-standalone → public/')\"",
13
+ "bundle:vendor": "node ./scripts/vendor-runtime-deps.mjs",
13
14
  "dev": "tsx src/index.ts",
14
15
  "start": "node dist/index.js",
15
16
  "typecheck": "tsc --noEmit -p tsconfig.json",
16
- "prepublishOnly": "cd ../.. && npm run build -w packages/daemon-core && npm run build -w packages/web-standalone && cd packages/daemon-standalone && npm run bundle:web && npm run build"
17
+ "prepublishOnly": "cd ../.. && npm run build -w packages/session-host-daemon && npm run build -w packages/daemon-core && npm run build -w packages/web-standalone && cd packages/daemon-standalone && npm run bundle:web && npm run bundle:vendor && npm run build"
17
18
  },
18
19
  "files": [
19
20
  "dist",
20
21
  "public",
22
+ "vendor",
21
23
  "README.md"
22
24
  ],
23
25
  "publishConfig": {
@@ -31,11 +33,9 @@
31
33
  "author": "vilmire",
32
34
  "license": "AGPL-3.0-or-later",
33
35
  "dependencies": {
34
- "@adhdev/daemon-core": "*",
35
- "@adhdev/session-host-core": "*",
36
- "@adhdev/session-host-daemon": "*",
37
- "@adhdev/terminal-mux-cli": "*",
38
- "@adhdev/terminal-mux-control": "*",
36
+ "chalk": "^5.3.0",
37
+ "conf": "^13.0.0",
38
+ "node-pty": "^1.1.0",
39
39
  "open": "^10.1.0",
40
40
  "ws": "^8.19.0"
41
41
  },
@@ -39,7 +39,7 @@ var xn=Object.defineProperty;var pn=(t,s,n)=>s in t?xn(t,s,{enumerable:!0,config
39
39
  }
40
40
  `})]})}function Ps({activeConv:t,onModalButton:s}){const[n,r]=o.useState(null);if(o.useEffect(()=>{r(null)},[t.modalMessage,t.status]),t.status!=="waiting_approval"||!t.modalButtons)return null;const a=i=>{n||(r(i),s(i))},c=i=>i.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim();return e.jsxs("div",{className:"bg-gradient-to-br from-amber-600 to-amber-700 text-white py-2.5 px-4 shrink-0 z-[5]",children:[t.modalMessage&&e.jsx("div",{className:"text-[11px] opacity-85 mb-1.5 whitespace-nowrap overflow-hidden text-ellipsis max-w-full",children:t.modalMessage.replace(/[\n\r]+/g," ").slice(0,120)}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"font-black text-xs flex items-center gap-2",children:[e.jsx(Ut,{size:14})," ",n?"PROCESSING...":"ACTION REQUIRED"]}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:t.modalButtons.map((i,u)=>{const l=c(i).toLowerCase(),p=/^(run|approve|accept|yes|allow|always)/.test(l),d=/^(reject|deny|delete|remove|abort)/.test(l),m=n===i,f=n!==null;return e.jsx("button",{onClick:()=>a(i),disabled:f,className:`btn btn-sm border-none rounded-md text-xs px-3 py-1 ${p?"bg-white text-amber-700 font-extrabold":d?"bg-red-500/30 text-white font-semibold":"bg-white/15 text-white font-semibold"} ${f&&!m?"opacity-40":"opacity-100"} ${f?"cursor-not-allowed":"cursor-pointer"}`,children:m?"⏳ ...":c(i)},u)})})]})]})}const ve=new Map;function rr({ideId:t,sessionId:s,ideType:n,providerType:r,displayLabel:a,serverModel:c,serverMode:i,acpConfigOptions:u,acpModes:l}){var oe;const{sendCommand:p}=Pe(),d=!!(u||l),m=`${t}:${s||r}`,f=ve.get(m),[g,y]=o.useState(!1),[k,I]=o.useState(!1),[h,b]=o.useState((f==null?void 0:f.models)||[]),[N,T]=o.useState((f==null?void 0:f.modes)||[]),x=O=>O?typeof O=="string"?O:typeof O=="object"?O.name||O.id||JSON.stringify(O):String(O):"",[j,v]=o.useState(x(c)),[w,R]=o.useState(x(i)),[_,W]=o.useState(!1),[A,C]=o.useState(!1),P=o.useRef(0),K=O=>O.map($=>typeof $=="string"?$:($==null?void 0:$.name)||($==null?void 0:$.id)||String($));o.useEffect(()=>{if(u){const O=u.find($=>$.category==="model");if(O){const $=K(O.options.map(L=>L.value));b($),O.currentValue&&v(x(O.currentValue));const E=ve.get(m)||{models:[],modes:[]};ve.set(m,{...E,models:$})}}if(l&&l.length>0){const O=K(l.map(E=>E.id));T(O);const $=ve.get(m)||{models:[],modes:[]};ve.set(m,{...$,modes:O})}else if(u){const O=u.find($=>$.category!=="model");if(O){const $=K(O.options.map(L=>L.value));T($),O.currentValue&&R(x(O.currentValue));const E=ve.get(m)||{models:[],modes:[]};ve.set(m,{...E,modes:$})}}},[u,l,m]),o.useEffect(()=>{y(!1),I(!1),v(x(c)),R(x(i));const O=ve.get(m);O?(b(O.models),T(O.modes)):(b([]),T([]))},[t,r,s]),o.useEffect(()=>{c&&Date.now()>P.current&&v(x(c))},[c]),o.useEffect(()=>{i&&Date.now()>P.current&&R(x(i))},[i]);const S=o.useCallback(async(O,$={})=>{const E={...$,...s&&{targetSessionId:s}};return await p(t,O,E)},[t,s,p]),U=async()=>{var O,$;if(h.length>0){y(!g);return}if(d){y(!0);return}W(!0);try{const E=await S("list_extension_models",{agentType:r,ideType:n}),L=(E==null?void 0:E.models)||((O=E==null?void 0:E.result)==null?void 0:O.models)||[],D=K(L);b(D),E!=null&&E.current&&v(x(E.current)),($=E==null?void 0:E.result)!=null&&$.current&&v(x(E.result.current));const F=ve.get(m)||{models:[],modes:[]};ve.set(m,{...F,models:D}),y(!0)}catch{}finally{W(!1)}},Q=async()=>{var O,$;if(N.length>0){I(!k);return}if(d){I(!0);return}C(!0);try{const E=await S("list_extension_modes",{agentType:r,ideType:n}),L=(E==null?void 0:E.modes)||((O=E==null?void 0:E.result)==null?void 0:O.modes)||[],D=K(L);T(D),E!=null&&E.current&&R(x(E.current)),($=E==null?void 0:E.result)!=null&&$.current&&R(x(E.result.current));const F=ve.get(m)||{models:[],modes:[]};ve.set(m,{...F,modes:D}),I(!0)}catch{}finally{C(!1)}},J=async O=>{y(!1),v(O),P.current=Date.now()+5e3;try{d?await S("change_model",{agentType:r,ideType:n,model:O}):await S("set_extension_model",{agentType:r,ideType:n,model:O})}catch{}},G=d&&!(l&&l.length>0)&&(u==null?void 0:u.some(O=>O.category!=="model")),se=G?(oe=u==null?void 0:u.find(O=>O.category!=="model"))==null?void 0:oe.configId:void 0,X=async O=>{I(!1),R(O),P.current=Date.now()+5e3;try{d&&G&&se?await S("set_thought_level",{agentType:r,ideType:n,configId:se,value:O}):d?await S("set_mode",{agentType:r,ideType:n,mode:O}):await S("set_extension_mode",{agentType:r,ideType:n,mode:O})}catch{}},ee={cline:"#22d3ee","roo-code":"#a78bfa",cursor:"#60a5fa",antigravity:"#f97316",windsurf:"#34d399"}[r]||"#94a3b8";return e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 flex-wrap text-[10px] border-t border-border-subtle bg-[var(--surface-primary)]",children:[e.jsx("span",{className:"text-[9px] font-bold tracking-wide opacity-70",style:{color:ee},children:a}),e.jsx("span",{className:"text-border-subtle text-[10px]",children:"│"}),e.jsxs("div",{className:"relative",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-xl text-[10px] font-medium cursor-pointer transition-all bg-[var(--surface-tertiary)] whitespace-nowrap max-w-40 overflow-hidden text-ellipsis",style:{borderColor:g?`${ee}55`:"transparent",border:"1px solid",color:j?"var(--text-primary)":"var(--text-muted)"},onClick:U,children:[e.jsx("span",{className:"text-[9px] opacity-60",children:"🤖"}),_?"...":j||"Model",e.jsx("span",{className:"text-[7px] opacity-50",children:"▼"})]}),g&&h.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[59]",onClick:()=>y(!1)}),e.jsxs("div",{className:"absolute bottom-full left-0 z-[60] bg-[var(--surface-primary)] border border-border-subtle rounded-lg mb-1 max-h-[220px] overflow-y-auto min-w-40 shadow-[0_-4px_16px_rgba(0,0,0,0.3)]",children:[e.jsx("div",{className:"px-3 py-1.5 text-[9px] font-bold text-text-muted tracking-wider border-b border-border-subtle",children:"SELECT MODEL"}),h.map(O=>e.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:O===j?`${ee}18`:"transparent",color:O===j?ee:"var(--text-secondary)",fontWeight:O===j?600:400,borderLeft:O===j?`2px solid ${ee}`:"2px solid transparent"},onMouseEnter:$=>{$.currentTarget.style.background=`${ee}12`},onMouseLeave:$=>{$.currentTarget.style.background=O===j?`${ee}18`:"transparent"},onClick:()=>J(O),children:O},O))]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-xl text-[10px] font-medium cursor-pointer transition-all bg-[var(--surface-tertiary)] whitespace-nowrap max-w-40 overflow-hidden text-ellipsis",style:{borderColor:k?`${ee}55`:"transparent",border:"1px solid",color:w?"var(--text-primary)":"var(--text-muted)"},onClick:Q,children:[e.jsx("span",{className:"text-[9px] opacity-60",children:G?"🧠":"⚡"}),A?"...":w||(G?"Thinking":"Mode"),e.jsx("span",{className:"text-[7px] opacity-50",children:"▼"})]}),k&&N.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[59]",onClick:()=>I(!1)}),e.jsxs("div",{className:"absolute bottom-full left-0 z-[60] bg-[var(--surface-primary)] border border-border-subtle rounded-lg mb-1 max-h-[220px] overflow-y-auto min-w-40 shadow-[0_-4px_16px_rgba(0,0,0,0.3)]",children:[e.jsx("div",{className:"px-3 py-1.5 text-[9px] font-bold text-text-muted tracking-wider border-b border-border-subtle",children:G?"SELECT THINKING LEVEL":"SELECT MODE"}),N.map(O=>e.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:O===w?`${ee}18`:"transparent",color:O===w?ee:"var(--text-secondary)",fontWeight:O===w?600:400,borderLeft:O===w?`2px solid ${ee}`:"2px solid transparent"},onMouseEnter:$=>{$.currentTarget.style.background=`${ee}12`},onMouseLeave:$=>{$.currentTarget.style.background=O===w?`${ee}18`:"transparent"},onClick:()=>X(O),children:O},O))]})]})]})]})}const ar=o.memo(function({contextKey:s,panelLabel:n,isSending:r,onSend:a}){const c=o.useRef(null),[i,u]=o.useState("");o.useEffect(()=>{u("")},[s]);const l=()=>{const p=i.trim();!p||r||(u(""),a(p))};return e.jsx("div",{className:"dashboard-input-area px-3 py-2.5 bg-[var(--surface-primary)] border-t border-border-subtle shrink-0",children:e.jsxs("div",{className:"flex gap-2.5 items-center",children:[e.jsx("div",{className:"flex-1 relative",children:e.jsx("input",{ref:c,type:"text",placeholder:`Send message to ${n}...`,value:i,onChange:p=>u(p.target.value),onPaste:p=>{const d=p.clipboardData.getData("text");d&&u(m=>m+d),p.preventDefault()},onKeyDown:p=>{if(p.key==="Enter"){if(p.nativeEvent.isComposing){p.preventDefault();return}p.preventDefault(),l()}},onBlur:p=>{if(window.innerWidth<768){const d=p.relatedTarget;if((d==null?void 0:d.tagName)==="BUTTON")return;setTimeout(()=>{document.documentElement.scrollTop=0},300)}},className:"w-full h-10 rounded-[20px] px-4 bg-bg-secondary text-sm text-text-primary",style:{border:"1px solid var(--chat-input-border, var(--border-subtle))"}})}),e.jsx("button",{onClick:l,disabled:!i.trim()||r,className:`w-10 h-10 rounded-full flex items-center justify-center border-none shrink-0 transition-all duration-300 ${i.trim()&&!r?"cursor-pointer":"bg-bg-secondary cursor-default"}`,style:i.trim()&&!r?{background:"var(--chat-send-bg, var(--accent-primary))"}:void 0,children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:i.trim()?"text-white":"text-text-muted",children:e.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})})}),be=t=>t.transport==="pty",fe=t=>t.transport==="acp";var or=new Set(["generating","streaming","loading","loading_reference","thinking","active"]);function ir(t){var s;return(((s=t==null?void 0:t.buttons)==null?void 0:s.length)??0)>0}function he(t,s){if(ir(s==null?void 0:s.activeModal))return"waiting_approval";const n=String(t||"idle").trim().toLowerCase();return n==="waiting_approval"?"waiting_approval":or.has(n)?"generating":n==="error"?"error":n==="stopped"?"stopped":n==="starting"?"starting":n==="panel_hidden"?"panel_hidden":n==="not_monitored"?"not_monitored":n==="disconnected"?"disconnected":"idle"}function Ds(t){return he(t)==="generating"}function xe(t){return t?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():"IDE"}function cr(t){if(t<60)return`${Math.round(t)}s`;const s=Math.floor(t/60);if(s<60)return`${s}m`;const n=Math.floor(s/60),r=s%60;if(n<24)return r>0?`${n}h ${r}m`:`${n}h`;const a=Math.floor(n/24),c=n%24;return`${a}d ${c}h`}function Qt(t){return t<1024*1024*1024?`${(t/(1024*1024)).toFixed(0)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function Bt(t,s){const n=typeof s=="string"?s.trim():"";if(n)return n;const r=typeof t=="string"?t.trim():"";if(!r)return"";const a=r.replace(/[\\/]+$/,""),c=a.split(/[\\/]/).filter(Boolean);return c[c.length-1]||a}function lr(t){if(t.length>16&&/^[a-f0-9]+$/i.test(t))return`Machine-${t.substring(0,8)}`;if(t.includes("_")){const s=t.split("_"),n=s[s.length-1];return n.length>12?`Machine-${n.substring(0,8)}`:n}return t}function dr(t){return lr(t.trim().replace(/\.local$/i,""))}function ur(t){const s=t.machineNickname??t.nickname;return typeof s!="string"?null:s.trim()||null}function Bs(t,s={}){var a,c;const n=[t.hostname,(a=t.machine)==null?void 0:a.hostname,(c=t.system)==null?void 0:c.hostname].find(i=>typeof i=="string"&&i.trim().length>0);if(n&&n!=="Unknown")return dr(n);const r=s.fallbackId||t.id;return r?`Machine-${r.substring(0,8)}`:s.fallbackLabel||"Machine"}function Xe(t,s={}){return ur(t)||Bs(t,s)}function es(t){return t.transport==="pty"}function ts(t){return t.transport==="acp"}function ss(t,s){return xe(t)}function xr(t,s,n){const r=(t||"").trim().toLowerCase();if(!r)return!0;const a=(s||"").trim().toLowerCase(),c=(n||"").trim().toLowerCase(),i=xe(n||"").trim().toLowerCase();return r===a||r===c||r===i}function pr(t){return he(t==null?void 0:t.status,{activeModal:t==null?void 0:t.activeModal})}function hr(t){if(!Array.isArray(t)||t.length<=1)return t;const s=new Map,n=["generating","waiting_approval","connected","idle","panel_hidden"];for(const r of t){const a=(r.name||r.id||"").toLowerCase().replace(/\s+/g,"-"),c=s.get(a),i=he(r.status);if(!c){s.set(a,{...r,status:i});continue}const u=n.indexOf(c.status||"idle"),l=n.indexOf(i||"idle");l>=0&&(u<0||l<u)&&s.set(a,{...r,status:i})}return Array.from(s.values())}const mr=60,fr=60;function Ws({activeConv:t,ideEntry:s,handleSendChat:n,isSendingChat:r=!1,handleFocusAgent:a,isFocusingAgent:c,actionLogs:i,userName:u}){const l=o.useRef(new Map),{sendCommand:p}=Pe();ct("ChatPane",{tabKey:t.tabKey,messageCount:t.messages.length,actionLogCount:i.length,isSendingChat:r});const d=o.useRef(new Map),m=o.useCallback(A=>(d.current.has(A)||d.current.set(A,{messages:[],offset:0,hasMore:!0,error:null,visibleLiveCount:mr}),d.current.get(A)),[]),f=o.useCallback((A,C)=>{const P=m(A);d.current.set(A,{...P,...C}),g(K=>K+1)},[m]),[,g]=o.useState(0),y=t.tabKey,k=m(y),I=k.messages,h=k.hasMore,b=k.error,N=Math.max(0,t.messages.length-k.visibleLiveCount),[T,x]=o.useState(!1),j=o.useCallback(async()=>{var P,K;if(T)return;const A=t.tabKey,C=m(A);if(t.messages.length>C.visibleLiveCount){f(A,{visibleLiveCount:Math.min(t.messages.length,C.visibleLiveCount+fr),error:null});return}x(!0),f(A,{error:null});try{const S=(s==null?void 0:s.daemonId)||((P=t.ideId)==null?void 0:P.split(":")[0])||"";if(!S){f(A,{hasMore:!1});return}const U=t.ideType||t.agentType||"",Q=await p(S,"chat_history",{agentType:U,offset:C.offset,limit:30,targetSessionId:t.sessionId}),J=(Q==null?void 0:Q.result)??Q;if(((K=J.messages)==null?void 0:K.length)>0){const G=m(A);f(A,{messages:[...J.messages,...G.messages],offset:G.offset+J.messages.length,hasMore:!!J.hasMore})}else f(A,{hasMore:!!J.hasMore})}catch(S){const U=(S==null?void 0:S.message)||"";U.includes("P2P not available")||U.includes("channel not open")||U.includes("P2P not connected")||U.includes("timeout")?f(A,{error:"Connection not ready — tap to retry"}):f(A,{hasMore:!1,error:"Failed to load history"})}finally{x(!1)}},[T,s,t,p,m,f]),{allMessages:v,receivedAtMap:w}=o.useMemo(()=>{const A=N>0?t.messages.slice(-k.visibleLiveCount):t.messages;if(I.length===0){const U={};return A.forEach((Q,J)=>{const G=`${t.tabKey}:${Ve(Q,J)}`;let se=Q.receivedAt||l.current.get(G)||0;se||(se=Date.now(),l.current.set(G,se)),U[Ve(Q,J)]=se}),{allMessages:A,receivedAtMap:U}}const C=new Set(A.map(U=>`${U.role}:${(U.content||"").slice(0,100)}`)),K=[...I.filter(U=>!C.has(`${U.role}:${(U.content||"").slice(0,100)}`)),...A],S={};return K.forEach((U,Q)=>{const J=`${t.tabKey}:${Ve(U,Q)}`;let G=U.receivedAt||l.current.get(J)||0;G||(G=Date.now(),l.current.set(J,G)),S[Ve(U,Q)]=G}),{allMessages:K,receivedAtMap:S}},[t.messages,t.tabKey,N,I,k.visibleLiveCount]),R=o.useMemo(()=>i.filter(A=>A.ideId===t.tabKey).sort((A,C)=>A.timestamp-C.timestamp),[i,t.tabKey]),_=t.displayPrimary||t.agentName||"Agent",W=o.useMemo(()=>{if(t.messages.length===0){if(t.connectionState==="connecting"||t.connectionState==="new")return e.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-4",children:[e.jsx("div",{className:"connecting-logo-float",children:e.jsx("div",{style:{width:64,height:64,borderRadius:"50%",background:"radial-gradient(circle, rgba(96,165,250,0.12), transparent 70%)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 0 40px rgba(96,165,250,0.08)"},children:e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",style:{width:40,height:40,borderRadius:"50%",opacity:.85}})})}),e.jsxs("div",{className:"flex flex-col items-center gap-1.5",children:[e.jsxs("div",{className:"text-[13px] text-blue-400 font-medium",children:["Connecting to your machine",e.jsx("span",{className:"connecting-dots"})]}),e.jsx("div",{className:"text-[11px] opacity-35",children:"Establishing P2P connection"})]})]});if(t.status==="not_monitored")return e.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[e.jsx("div",{className:"text-3xl opacity-60",children:e.jsx(qe,{size:28})}),e.jsx("div",{className:"text-[13px] opacity-50",children:"Agent not monitored"}),e.jsx("button",{onClick:a,disabled:c,className:"btn btn-primary",children:c?"⌛ Switching...":e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Pt,{size:14})," Open ",_," Panel"]})}),e.jsx("div",{className:"text-[11px] opacity-35 max-w-[280px]",children:"Click to switch monitoring to this agent"})]});if(t.status==="panel_hidden")return e.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[e.jsx("div",{className:"text-3xl opacity-60",children:e.jsx(Es,{size:28})}),e.jsx("div",{className:"text-[13px] opacity-50",children:"Agent panel is not visible yet"}),e.jsx("button",{onClick:a,disabled:c,className:"btn btn-primary",children:c?"⌛ Opening...":e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Pt,{size:14})," Open ",_," Panel"]})}),e.jsx("div",{className:"text-[11px] opacity-35 max-w-[280px]",children:"Open the agent panel or chat view in the app you are using to start viewing messages"})]});if(t.status==="idle"&&!T)return e.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[e.jsx("div",{className:"text-2xl opacity-40 animate-pulse",children:"💬"}),e.jsx("div",{className:"text-[13px] opacity-40",children:"Loading chat..."})]})}},[t.messages.length,t.connectionState,t.status,a,c,T,_]);return e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[e.jsx(Gn,{messages:v,actionLogs:R,agentName:t.agentName||t.displayPrimary||"Agent",userName:u,isCliMode:be(t)||fe(t),isWorking:t.status==="generating",contextKey:t.tabKey,receivedAtMap:w,onLoadMore:j,isLoadingMore:T,hasMoreHistory:h,hiddenLiveCount:N,loadError:b??void 0,emptyState:W}),!be(t)&&(()=>{const A=t.streamSource!=="agent-stream",C=A?t.ideType:t.agentType,P=A?s!=null&&s.type?xe(s.type):xe(t.ideType||""):t.agentName||xe(t.agentType||"");return e.jsx(rr,{ideId:t.ideId,sessionId:t.sessionId,ideType:t.ideType,providerType:C,displayLabel:P,serverModel:(s==null?void 0:s.currentModel)||void 0,serverMode:(s==null?void 0:s.currentPlan)||void 0,acpConfigOptions:fe(t)?s==null?void 0:s.acpConfigOptions:void 0,acpModes:fe(t)?s==null?void 0:s.acpModes:void 0})})(),e.jsx(ar,{contextKey:t.tabKey,panelLabel:_,isSending:r,onSend:n})]})}function gr({activeConv:t,clearToken:s=0,ptyBuffers:n,terminalRef:r,handleSendChat:a,isSendingChat:c=!1}){const i=o.useRef(null),{sendCommand:u,sendData:l}=Pe(),p=En(),[d,m]=o.useState(""),[f,g]=o.useState(!1),y=o.useRef(0),k=o.useRef(!1),I=t.tabKey,h=t.sessionId||"",b=()=>{var x;y.current=0,k.current=!1,g(!1),(x=r.current)==null||x.clear()},N=()=>{var x;y.current=0,k.current=!1,g(!0),(x=r.current)==null||x.clear()},T=(x,j=0)=>{var v,w;k.current||y.current>=j&&y.current!==0||(y.current=j,g(!0),(v=r.current)==null||v.clear(),x&&((w=r.current)==null||w.write(x)))};return o.useEffect(()=>{b()},[h]),o.useEffect(()=>{if(!h)return;const x=new EventSource(p.getRuntimeEventsUrl(h)),j=R=>{try{const _=JSON.parse(R.data);if(_.sessionId!==h)return;T(_.text||"",_.seq||0)}catch{}},v=R=>{var _;try{const W=JSON.parse(R.data);if(W.sessionId!==h)return;k.current=!0,typeof W.seq=="number"&&(y.current=Math.max(y.current,W.seq)),g(!0),typeof W.data=="string"&&((_=r.current)==null||_.write(W.data))}catch{}},w=R=>{try{if(JSON.parse(R.data).sessionId!==h)return;N()}catch{}};return x.addEventListener("runtime_snapshot",j),x.addEventListener("session_output",v),x.addEventListener("session_cleared",w),x.onerror=()=>{},()=>{x.removeEventListener("runtime_snapshot",j),x.removeEventListener("session_output",v),x.removeEventListener("session_cleared",w),x.close()}},[p,h]),o.useEffect(()=>{s&&(n.current.delete(I),b())},[s,I,n,r]),o.useEffect(()=>{m("")},[t.tabKey]),o.useEffect(()=>{const x=j=>{var w;const v=j.detail;v!=null&&v.sessionId&&v.sessionId!==h||f&&((w=r.current)==null||w.fit())};return window.addEventListener("adhdev:fit-cli-terminal",x),()=>{window.removeEventListener("adhdev:fit-cli-terminal",x)}},[f,h,r]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 min-h-0 p-2 bg-[#0f1117]",children:[e.jsx($s,{ref:r,readOnly:!f,onInput:x=>{if(!f)return;const j=t.ideId||t.daemonId||"";l!=null&&l(j,{type:"pty_input",targetSessionId:h,data:x})||u(j,"pty_input",{targetSessionId:h,data:x}).catch(console.error)},onResize:(x,j)=>{if(!f)return;const v=t.ideId||t.daemonId||"";l!=null&&l(v,{type:"pty_resize",targetSessionId:h,cols:x,rows:j})||u(v,"pty_resize",{targetSessionId:h,cols:x,rows:j,force:!0}).catch(()=>{})}},t.tabKey),!f&&e.jsx("div",{className:"absolute inset-x-2 top-2 rounded-md border border-red-500/30 bg-red-500/10 px-3 py-2 text-[11px] text-red-300 pointer-events-none",children:"Runtime terminal unavailable"})]}),e.jsx("div",{className:"px-3 py-2 bg-[var(--surface-primary)] border-t border-border-subtle shrink-0",children:e.jsxs("div",{className:"flex gap-2.5 items-center",children:[e.jsx("div",{className:"flex-1 relative",children:e.jsx("input",{ref:i,type:"text",placeholder:`Send message to ${t.displayPrimary}...`,value:d,onChange:x=>m(x.target.value),onPaste:x=>{const j=x.clipboardData.getData("text");j&&m(v=>v+j),x.preventDefault()},onKeyDown:x=>{if(x.key!=="Enter")return;if(x.nativeEvent.isComposing){x.preventDefault();return}x.preventDefault();const j=d.trim();!f||!j||c||(m(""),a(j))},className:"w-full h-9 rounded-[18px] px-4 bg-bg-secondary text-[13px] text-text-primary",style:{border:"1px solid var(--chat-input-border, var(--border-subtle))"}})}),e.jsx("button",{onClick:()=>{const x=d.trim();!f||!x||c||(m(""),a(x))},disabled:!f||!d.trim()||c,className:`w-9 h-9 rounded-full flex items-center justify-center border-none shrink-0 transition-all duration-300 ${d.trim()&&!c?"cursor-pointer":"bg-bg-secondary cursor-default"}`,style:d.trim()&&!c?{background:"var(--chat-send-bg, var(--accent-primary))"}:void 0,children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:d.trim()?"text-white":"text-text-muted",children:e.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})})]})}function br({wsStatus:t,showReconnected:s,loginUrl:n}){const r=t==="disconnected"||t==="reconnecting"||t==="offline"||t==="auth_failed",a=t==="auth_failed"?"red":t==="offline"?"orange":"violet",c={red:"linear-gradient(90deg, rgba(239,68,68,0.12), rgba(239,68,68,0.04))",orange:"linear-gradient(90deg, rgba(255,107,53,0.12), rgba(255,107,53,0.04))",violet:"linear-gradient(90deg, rgba(139,92,246,0.12), rgba(139,92,246,0.04))"},i={red:"1px solid rgba(239,68,68,0.2)",orange:"1px solid rgba(255,107,53,0.2)",violet:"1px solid rgba(139,92,246,0.2)"},u={red:"#ef4444",orange:"#ff6b35",violet:"#a78bfa"};return e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"py-2.5 px-5 text-[13px] font-semibold flex items-center gap-2.5 justify-center",style:{background:c[a],borderBottom:i[a],color:u[a]},children:[e.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-5 h-5",style:{opacity:t==="auth_failed"?.6:1,animation:t==="auth_failed"?void 0:"pulse 2s ease-in-out infinite",filter:t==="auth_failed"?"grayscale(1)":void 0}}),t==="offline"&&"Network offline — waiting for connection...",t==="disconnected"&&"Reconnecting to server...",t==="reconnecting"&&"Reconnecting to server...",t==="auth_failed"&&(n?e.jsxs(e.Fragment,{children:["Session expired."," ",e.jsx("a",{href:n,className:"text-inherit underline",children:"Log in again"})]}):"Connection failed — please restart the server.")]}),s&&t==="connected"&&e.jsxs("div",{className:"py-2 px-4 text-xs font-semibold flex items-center gap-2 justify-center bg-gradient-to-r from-green-500/[0.12] to-green-500/[0.04] text-green-400 border-b border-green-500/15 animate-[fadeIn_0.3s_ease]",children:[e.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-4 h-4"}),"Connected"]})]})}let Os=ot;function It(){return Os()}class yr{constructor(){ue(this,"listeners",new Map)}send(s){}isConnected(){return!1}on(s,n){return this.listeners.has(s)||this.listeners.set(s,new Set),this.listeners.get(s).add(n),()=>{var r;(r=this.listeners.get(s))==null||r.delete(n)}}emit(s,...n){var r;(r=this.listeners.get(s))==null||r.forEach(a=>a(...n))}}let Ks=new yr;class jr{constructor(){ue(this,"ptyCallbacks",new Set)}sendPtyInput(s,n,r){return!1}sendPtyResize(s,n,r,a){return!1}retryConnection(s){}getState(s){return"disconnected"}sendData(s,n){return!1}get(s){}onScreenshot(s,n){return()=>{}}onPtyOutput(s){return this.ptyCallbacks.add(s),()=>{this.ptyCallbacks.delete(s)}}emitPtyOutput(s,n){this.ptyCallbacks.forEach(r=>r(s,n))}}let Re=new jr;function vr(t){t.dashboardWS&&(Ks=t.dashboardWS),t.connectionManager&&(Re=t.connectionManager),t.useDaemonsHook&&(Os=t.useDaemonsHook)}function wr({activeConv:t,agentCount:s,wsStatus:n,isConnected:r,onOpenHistory:a,onStopCli:c,onFitCli:i}){const u=it(),l=It(),p=l.p2pStates||{},d=l.ides||[],m=!!t&&be(t)&&!fe(t),f=r?"#22c55e":n==="connected"?"#eab308":"#ef4444",g=r?"0 0 4px #22c55e80":n==="connected"?"0 0 4px #eab30880":"0 0 4px #ef444480",y=d.filter(T=>T.type==="adhdev-daemon"),k=Object.values(p),I=k.filter(T=>T==="connected").length,h=k.filter(T=>T==="connecting"||T==="new"||T==="checking").length,N=n!=="connected"||y.length===0?null:h>0&&I===0?"P2P connecting...":I>0&&s===0?"Waiting for IDE...":null;return e.jsxs("div",{className:"dashboard-header",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"leading-tight",children:[e.jsxs("h1",{className:"header-title m-0 flex items-center gap-1.5",children:[e.jsx(Ye,{size:18}),e.jsx("span",{className:"header-title-desktop",children:"Dashboard"}),e.jsx("span",{className:"header-title-mobile",children:(t==null?void 0:t.displayPrimary)||"Dashboard"}),e.jsx("span",{className:"header-count-mobile text-[10px] font-semibold opacity-60 ml-2 tracking-wide",children:e.jsx("span",{className:"inline-block w-[6px] h-[6px] rounded-full align-middle",style:{background:f,boxShadow:g}})})]}),e.jsxs("div",{className:"header-subtitle text-xs items-center gap-1",children:[s," agent",s!==1?"s":""," active",e.jsx("span",{title:r?"Connected":n==="connected"?"Partial":"Disconnected",className:"inline-block w-1.5 h-1.5 rounded-full shrink-0",style:{background:f,boxShadow:g}}),N&&e.jsxs("span",{className:"text-[10px] text-text-muted animate-pulse ml-1",children:["· ",N]})]})]})}),e.jsxs("div",{className:"flex gap-2 items-center",children:[m&&c&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:i,className:"btn btn-secondary btn-sm",title:"Fit terminal to current view",children:"Fit"}),e.jsx("button",{onClick:c,className:"btn btn-secondary btn-sm text-red-400 border-red-500/25 hover:bg-red-500/10",title:"Stop CLI process",children:"Stop"})]}),t&&!m&&!fe(t)&&e.jsxs("button",{onClick:()=>u(`/ide/${t.ideId}`),className:"btn btn-primary btn-sm",title:"IDE View",children:[e.jsx(Ft,{size:14})," IDE"]}),t&&!m&&!fe(t)&&e.jsx("button",{onClick:a,className:"btn btn-secondary btn-sm",title:"Chat History",children:e.jsx(Ms,{size:16})}),t&&!m&&!fe(t)&&e.jsx("button",{onClick:()=>u(`/ide/${t.ideId}?view=remote`),className:"btn btn-secondary btn-sm",title:"Remote Control",children:e.jsx(Le,{size:16})})]})]})}function zs({activeConv:t,ides:s,isCreatingChat:n,isRefreshingHistory:r,onClose:a,onNewChat:c,onSwitchSession:i,onRefreshHistory:u}){var m;const l=s.find(f=>f.id===t.ideId),p=(l==null?void 0:l.chats)||[],d=(m=l==null?void 0:l.activeChat)==null?void 0:m.id;return e.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center",children:[e.jsx("div",{onClick:a,className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),e.jsxs("div",{className:"card fade-in relative w-[90%] max-w-[500px] max-h-[80vh] flex flex-col p-0 overflow-hidden shadow-[0_20px_40px_rgba(0,0,0,0.4)] rounded-[20px]",children:[e.jsxs("div",{className:"px-6 py-5 border-b border-border-subtle flex justify-between items-center bg-[var(--surface-primary)]",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"m-0 text-lg font-extrabold",children:"Chat History"}),e.jsxs("div",{className:"text-xs text-text-muted mt-0.5",children:[t.displayPrimary," — ",xe(t.ideType)]})]}),e.jsx("button",{onClick:a,className:"bg-transparent border-none text-xl text-text-muted cursor-pointer",children:"✕"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 bg-bg-primary",children:[e.jsx("button",{onClick:c,disabled:n,className:"w-full p-3.5 rounded-xl mb-3 bg-indigo-500/10 border border-dashed border-accent text-accent font-bold text-sm cursor-pointer",children:n?"⌛ Creating...":"+ Start New Chat Session"}),p.map(f=>e.jsxs("div",{onClick:()=>{i(t.ideId,f.id),a()},className:`p-4 rounded-xl mb-2 cursor-pointer border transition-all ${d===f.id?"bg-[var(--bg-glass-hover)] border-accent":"bg-[var(--surface-secondary)] border-border-subtle"}`,children:[e.jsx("div",{className:`font-bold text-sm mb-1 ${d===f.id?"text-[var(--accent-primary-light)]":"text-text-primary"}`,children:f.title||"Untitled Session"}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"text-[11px] text-text-muted font-mono",children:[f.id.substring(0,12),"..."]}),d===f.id&&e.jsx("span",{className:"text-[10px] bg-accent text-white px-2 py-0.5 rounded-[10px] font-extrabold",children:"ACTIVE"})]})]},f.id)),p.length===0&&e.jsxs("div",{className:"py-10 px-5 text-center text-text-muted",children:[e.jsx("div",{className:"text-3xl mb-3 opacity-60",children:e.jsx(On,{size:32})}),e.jsx("div",{className:"text-[13px]",children:"No recent chat sessions found."})]})]}),e.jsx("div",{className:"px-5 py-4 bg-[var(--surface-tertiary)] border-t border-border-subtle text-right",children:e.jsx("button",{onClick:u,disabled:r,className:"btn btn-secondary btn-sm rounded-[10px]",children:r?"⌛ Refreshing...":e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ts,{size:13})," Refresh History"]})})})]})]})}const ns={success:"rgba(16, 185, 129, 0.95)",warning:"rgba(245, 158, 11, 0.95)",info:"rgba(99, 102, 241, 0.95)"};function Hs({toasts:t,onDismiss:s,onClickToast:n}){return e.jsx("div",{className:"fixed right-4 z-[9999] flex flex-col gap-2 pointer-events-none",style:{top:"calc(env(safe-area-inset-top, 0px) + 16px)"},children:t.map(r=>e.jsxs("div",{className:"fade-in text-white px-5 py-3 rounded-xl text-[13px] font-semibold shadow-[0_8px_32px_rgba(0,0,0,0.3)] backdrop-blur-lg pointer-events-auto cursor-pointer animate-[toast-in_0.3s_ease-out] max-w-[360px] relative group",style:{background:ns[r.type]||ns.info},onClick:()=>{var a;(a=r.actions)!=null&&a.length||(n&&n(r),s(r.id))},children:[e.jsx("button",{className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full flex items-center justify-center text-white/50 hover:text-white hover:bg-white/20 transition-all text-[11px] leading-none opacity-0 group-hover:opacity-100 cursor-pointer",onClick:a=>{a.stopPropagation(),s(r.id)},"aria-label":"Dismiss",children:"×"}),e.jsx("div",{className:"pr-4",children:r.message}),r.actions&&r.actions.length>0&&e.jsx("div",{className:"flex gap-2 mt-2",children:r.actions.map((a,c)=>e.jsx("button",{className:`text-xs px-3 py-1 rounded-md font-bold transition-all cursor-pointer ${a.variant==="primary"?"bg-white text-amber-700 hover:bg-gray-100":a.variant==="danger"?"bg-red-500/30 text-white hover:bg-red-500/50":"bg-white/20 text-white hover:bg-white/30"}`,onClick:i=>{i.stopPropagation(),a.onClick(),s(r.id)},children:a.label},c))})]},r.id))})}const Nr=t=>t.transport==="pty"||t.transport==="acp"||t.transport==="cdp-page"?!0:t.daemonId!==t.id;function kr(t){const s=t.workspace||"";if(!s)return"";const n=s.split(/[/\\]/).filter(Boolean);return n.length>0?n[n.length-1]:s}function Sr(t){return t.sessionId||t.instanceId||t.agentType}function xt(t){return typeof t=="string"?t.replace(/\s+/g," ").trim():Array.isArray(t)?t.map(s=>typeof s=="string"?s:s&&typeof s=="object"&&"text"in s?String(s.text||""):"").join(`
41
41
  `).replace(/\s+/g," ").trim():t&&typeof t=="object"&&"text"in t?String(t.text||"").replace(/\s+/g," ").trim():String(t||"").replace(/\s+/g," ").trim()}function rs(t,s){const n=new Set,r=[];for(const a of s)if(a)for(const c of t[a]||[]){const i=c._localId||`${c.role}:${c.timestamp}:${c.content}`;n.has(i)||(n.add(i),r.push(c))}return r.sort((a,c)=>a.timestamp-c.timestamp)}function Us(t=[]){const s={};for(const n of t){const r=n;(r.type==="adhdev-daemon"||r.daemonMode)&&(s[r.id]=Xe(r,{fallbackId:r.id}))}return s}function Fs(t,s,n={}){var g,y,k,I,h,b;const r=[],a=n.machineName,c=n.connectionState,i=kr(t),u=xe(t.type),l=t.agentStreams,p=Array.isArray(l)?l.map(N=>({...N,activeModal:N.activeModal??void 0})):[],d=Nr(t),m=t.activeChat||{title:""},f=m.title&&String(m.title).trim()?String(m.title).trim():"";if(d){const N=t.sessionId||t.instanceId,T=ss(t.type),x=(g=t.activeChat)==null?void 0:g.activeModal,j=x&&Array.isArray(x.buttons)&&x.buttons.length>0,v=he((y=t.activeChat)==null?void 0:y.status,{activeModal:(k=t.activeChat)==null?void 0:k.activeModal})||he((h=(I=t.agents)==null?void 0:I[0])==null?void 0:h.status)||"idle",w=t.activeChat||{title:"",messages:[]};let R=w.title&&String(w.title).trim()?String(w.title).trim():"";const _=(b=t.activeChat)==null?void 0:b.id,W=t.chats;if(_&&Array.isArray(W)&&W.length>0){const S=W.find(U=>U.id===_||U.id&&String(U.id)===String(_));S!=null&&S.title&&String(S.title).trim()&&(R=String(S.title).trim())}const A=w.messages||[],C=rs(s,[t.id,N]),P=new Map;A.filter(S=>S.role==="user").forEach(S=>{const U=xt(S.content);U&&P.set(U,(P.get(U)||0)+1)});const K=C.filter(S=>{const U=xt(S.content),Q=P.get(U)||0;return Q>0?(P.set(U,Q-1),!1):!0});r.push({ideId:t.id,sessionId:N,transport:t.transport,daemonId:t.daemonId||void 0,mode:be(t)?t.mode||"terminal":"chat",agentName:T,agentType:(be(t)||fe(t))&&(t.cliType||t.acpType)||t.type,status:v,title:R,messages:[...A,...K],terminalHistory:typeof w.terminalHistory=="string"?w.terminalHistory:"",resume:t.resume,ideType:t.cliType||t.acpType||t.type,workspaceName:i,displayPrimary:R||i||(be(t)||fe(t)?"Terminal":T),displaySecondary:u,cdpConnected:t.cdpConnected,modalButtons:j?x.buttons:void 0,modalMessage:j?x.message:void 0,streamSource:"native",tabKey:t.id,machineName:a,connectionState:c})}if(d&&(be(t)||fe(t)))return r;for(const N of p){const T=N.activeModal&&Array.isArray(N.activeModal.buttons)&&N.activeModal.buttons.length>0,x=pr(N),j=Sr(N),v=`${t.id}:${j}`,w=N.title&&String(N.title).trim()||"",R=xr(w,N.agentName,N.agentType)?"":w,_=N.messages||[],W=rs(s,[v,N.sessionId,N.instanceId]),A=new Map;_.filter(P=>P.role==="user").forEach(P=>{const K=xt(P.content);K&&A.set(K,(A.get(K)||0)+1)});const C=W.filter(P=>{const K=xt(P.content),S=A.get(K)||0;return S>0?(A.set(K,S-1),!1):!0});r.push({ideId:t.id,sessionId:N.sessionId||N.instanceId,transport:N.transport||"cdp-webview",daemonId:t.daemonId||void 0,mode:"chat",agentName:N.agentName,agentType:N.agentType,status:x,title:R,messages:[..._,...C],ideType:N.agentType,workspaceName:i,displayPrimary:R||f||i||u,displaySecondary:`${u}·${N.agentName}`,cdpConnected:t.cdpConnected,modalButtons:T?N.activeModal.buttons:void 0,modalMessage:T?N.activeModal.message:void 0,streamSource:"agent-stream",tabKey:v,machineName:a,connectionState:c})}return r.length===0&&r.push({ideId:t.id,sessionId:t.sessionId||t.instanceId,transport:t.transport,daemonId:t.daemonId||void 0,mode:"chat",agentName:ss(t.type),agentType:"ide-native",status:"idle",title:"",messages:[],ideType:t.type,workspaceName:i,displayPrimary:i||u,displaySecondary:u,cdpConnected:t.cdpConnected,streamSource:"native",tabKey:t.id,connectionState:c}),r}function Cr(t){const s=[],n=new Map;for(const r of t)if(r.parentId){const a=n.get(r.parentId)||[];a.push(r),n.set(r.parentId,a)}else s.push(r);return{topLevel:s,childrenByParent:n}}function Ir(t,s){var g,y,k,I,h,b,N,T;const n=[],{daemonId:r,existingDaemon:a,timestamp:c}=s,i=c||t.timestamp||Date.now(),u=t.sessions||[],{topLevel:l,childrenByParent:p}=Cr(u),d=l.filter(x=>x.kind==="workspace"&&x.transport==="cdp-page"),m=l.filter(x=>x.kind==="agent"&&x.transport==="pty"),f=l.filter(x=>x.kind==="agent"&&x.transport==="acp");n.push({...a||{},id:r,type:"adhdev-daemon",status:"online",daemonMode:!0,timestamp:i,...t.version&&{version:t.version},...t.machine&&{machine:t.machine,platform:t.machine.platform},...t.instanceId&&{instanceId:t.instanceId},...t.machineNickname!==void 0&&{machineNickname:t.machineNickname},...t.p2p&&{p2p:t.p2p},...t.workspaces&&{workspaces:t.workspaces},...t.defaultWorkspaceId!==void 0&&{defaultWorkspaceId:t.defaultWorkspaceId},...t.defaultWorkspacePath!==void 0&&{defaultWorkspacePath:t.defaultWorkspacePath},...t.workspaceActivity&&{workspaceActivity:t.workspaceActivity},...t.detectedIdes&&{detectedIdes:t.detectedIdes},..."availableProviders"in t&&{availableProviders:t.availableProviders},cdpConnected:d.some(x=>!!x.cdpConnected)});for(const x of d){const j=p.get(x.id)||[];n.push({id:`${r}:ide:${x.id}`,sessionId:x.id,parentSessionId:x.parentId,sessionKind:x.kind,transport:x.transport,sessionCapabilities:x.capabilities,type:x.providerType,ideType:x.providerType,status:x.cdpConnected?"online":"detected",daemonId:r,instanceId:x.id,workspace:x.workspace,terminals:0,agents:j.map(v=>({id:v.id,name:v.providerName,type:v.providerType,status:v.status})),activeChat:x.activeChat,chats:[],agentStreams:j.map(v=>{var w,R,_,W;return{sessionId:v.id,instanceId:v.id,parentSessionId:v.parentId,agentType:v.providerType,agentName:v.providerName,extensionId:v.providerType,transport:v.transport,status:he(v.status,{activeModal:(w=v.activeChat)==null?void 0:w.activeModal}),title:v.title,messages:((R=v.activeChat)==null?void 0:R.messages)||[],inputContent:((_=v.activeChat)==null?void 0:_.inputContent)||"",activeModal:((W=v.activeChat)==null?void 0:W.activeModal)||null,model:v.currentModel}}),cdpConnected:x.cdpConnected,currentModel:x.currentModel,currentPlan:x.currentPlan,currentAutoApprove:x.currentAutoApprove,timestamp:i})}for(const x of m){const j=x.runtime;n.push({id:`${r}:cli:${x.id}`,sessionId:x.id,parentSessionId:x.parentId,sessionKind:x.kind,transport:x.transport,sessionCapabilities:x.capabilities,type:x.providerType,ideType:x.providerType,agentType:x.providerType,status:x.status||"running",daemonId:r,instanceId:x.id,cliName:x.providerName,mode:"terminal",workspace:x.workspace||"",activeChat:x.activeChat,resume:x.resume,runtimeKey:x.runtimeKey??(j==null?void 0:j.runtimeKey),runtimeDisplayName:x.runtimeDisplayName??(j==null?void 0:j.displayName),runtimeWorkspaceLabel:x.runtimeWorkspaceLabel??(j==null?void 0:j.workspaceLabel),runtimeWriteOwner:x.runtimeWriteOwner??(j==null?void 0:j.writeOwner)??null,runtimeAttachedClients:x.runtimeAttachedClients??(j==null?void 0:j.attachedClients)??[],agentStreams:[{sessionId:x.id,instanceId:x.id,parentSessionId:x.parentId,agentType:x.providerType,agentName:x.providerName,extensionId:"cli-agent",transport:x.transport,status:he(x.status,{activeModal:(g=x.activeChat)==null?void 0:g.activeModal}),title:x.title,messages:((y=x.activeChat)==null?void 0:y.messages)||[],inputContent:((k=x.activeChat)==null?void 0:k.inputContent)||"",activeModal:(I=x.activeChat)==null?void 0:I.activeModal}],timestamp:i,_isCli:!0})}for(const x of f){const j=x.runtime;n.push({id:`${r}:acp:${x.id}`,sessionId:x.id,parentSessionId:x.parentId,sessionKind:x.kind,transport:x.transport,sessionCapabilities:x.capabilities,type:x.providerType,ideType:x.providerType,agentType:x.providerType,status:x.status||"running",daemonId:r,instanceId:x.id,cliName:x.providerName,mode:"chat",workspace:x.workspace||"",activeChat:x.activeChat,runtimeKey:x.runtimeKey??(j==null?void 0:j.runtimeKey),runtimeDisplayName:x.runtimeDisplayName??(j==null?void 0:j.displayName),runtimeWorkspaceLabel:x.runtimeWorkspaceLabel??(j==null?void 0:j.workspaceLabel),runtimeWriteOwner:x.runtimeWriteOwner??(j==null?void 0:j.writeOwner)??null,runtimeAttachedClients:x.runtimeAttachedClients??(j==null?void 0:j.attachedClients)??[],currentModel:x.currentModel,currentPlan:x.currentPlan,acpConfigOptions:x.acpConfigOptions,acpModes:x.acpModes,agentStreams:[{sessionId:x.id,instanceId:x.id,parentSessionId:x.parentId,agentType:x.providerType,agentName:x.providerName,extensionId:"acp-agent",transport:x.transport,status:he(x.status,{activeModal:(h=x.activeChat)==null?void 0:h.activeModal}),title:x.title,messages:((b=x.activeChat)==null?void 0:b.messages)||[],inputContent:((N=x.activeChat)==null?void 0:N.inputContent)||"",activeModal:(T=x.activeChat)==null?void 0:T.activeModal}],timestamp:i,_isAcp:!0})}return n}function Vs(t){const s=t.split(":");return s.length>=3&&(s[1]==="ide"||s[1]==="cli"||s[1]==="acp")?{daemonId:s[0],targetSessionId:s.slice(2).join(":")||void 0}:{daemonId:t}}function Mr(t,s){const n=Vs(t);return{daemonId:n.daemonId,payload:{...s,...n.targetSessionId&&!s.targetSessionId?{targetSessionId:n.targetSessionId}:{}}}}const Ys=[{id:"vscode",name:"VS Code",icon:"💙"},{id:"cursor",name:"Cursor",icon:"⚡"},{id:"windsurf",name:"Windsurf",icon:"🏄"},{id:"antigravity",name:"Antigravity",icon:"🌀"},{id:"trae",name:"Trae",icon:"🔮"},{id:"kiro",name:"Kiro",icon:"🎯"},{id:"pearai",name:"PearAI",icon:"🍐"},{id:"vscodium",name:"VSCodium",icon:"💚"}],qs=[{id:"claude-cli",name:"Claude Code",icon:"🟠"},{id:"gemini-cli",name:"Gemini CLI",icon:"✨"},{id:"codex-cli",name:"Codex CLI",icon:"📦"},{id:"aider-cli",name:"Aider",icon:"🛠️"},{id:"cursor-cli",name:"Cursor CLI",icon:"⚡"},{id:"github-copilot-cli",name:"GitHub Copilot CLI",icon:"🤖"},{id:"goose-cli",name:"Goose CLI",icon:"🪿"},{id:"opencode-cli",name:"OpenCode CLI",icon:"🧩"}],Xs=[{id:"copilot",name:"GitHub Copilot",icon:"🤖"},{id:"cline",name:"Cline",icon:"🧠"},{id:"roo-code",name:"Roo Code",icon:"🦘"},{id:"continue",name:"Continue",icon:"▶️"}],Gs="adhdev_notification_prefs",as={globalEnabled:!0,disconnectAlert:!0,browserNotifications:!0,completionAlert:!0,approvalAlert:!0,chatTaskCompletionBubble:!1};function Tr(){try{const t=localStorage.getItem(Gs);if(t){const s=JSON.parse(t);return{...as,...s}}}catch{}return{...as}}function Er(t){try{localStorage.setItem(Gs,JSON.stringify(t))}catch{}}let Me=Tr(),bt=[];function Ar(){bt.forEach(t=>t())}function Lr(){return{...Me}}function Rr(t){Me={...Me,...t},Er(Me),Ar()}function _r(){const[,t]=o.useState(0);o.useEffect(()=>{const n=()=>t(r=>r+1);return bt.push(n),()=>{bt=bt.filter(r=>r!==n)}},[]);const s=o.useCallback(n=>{Rr(n)},[]);return[{...Me},s]}function nt(t){if(!Me.globalEnabled)return!1;switch(t){case"disconnect":return Me.disconnectAlert;case"completion":return Me.completionAlert;case"approval":return Me.approvalAlert;case"browser":return Me.browserNotifications;default:return!0}}const $r={enabled:!0,onApproval:!0,onComplete:!0,onError:!0,throttleMs:5e3};async function Pr(){return"Notification"in window?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"}function Js(){return"Notification"in window&&Notification.permission==="granted"}let De=null;async function Dr(){if(De!==null)return De;try{if(!("serviceWorker"in navigator)||!("PushManager"in window))return De=!1,!1;const t=await navigator.serviceWorker.getRegistration();return t?(De=!!await t.pushManager.getSubscription(),De):(De=!1,!1)}catch{return De=!1,!1}}function Wt(t,s,n){if(Js())try{const r=new Notification(t,{body:s,icon:"/otter-logo.png",tag:n||`adhdev-${Date.now()}`,silent:!1});setTimeout(()=>r.close(),8e3),r.onclick=()=>{window.focus(),r.close()}}catch{}}function Br(t,s={}){const n={...$r,...s},r=o.useRef(new Map),a=o.useRef(0),c=o.useRef(null);o.useEffect(()=>{Dr().then(u=>{c.current=u})},[]);const i=o.useCallback((u,l,p)=>{const d=Date.now();d-a.current<n.throttleMs||(a.current=d,Wt(u,l,p))},[n.throttleMs]);o.useEffect(()=>{var u;if(!(!n.enabled||!Js())&&nt("browser")&&c.current!==!0){if(document.hasFocus()){for(const l of t)r.current.set(l.id,he(l.status,{activeModal:l.activeModal}));return}for(const l of t){const p=r.current.get(l.id),d=he(l.status,{activeModal:l.activeModal}),m=l.name||l.id;if(n.onApproval&&nt("approval")&&d==="waiting_approval"&&p!=="waiting_approval"){const f=((u=l.activeModal)==null?void 0:u.message)||"Action requires your approval";i(`🔔 ${m} — Approval needed`,f.slice(0,120),`approval-${l.id}`)}n.onComplete&&nt("completion")&&Ds(p)&&d==="idle"&&i(`✅ ${m} — Task complete`,"Agent has finished generating",`complete-${l.id}`),n.onError&&d==="error"&&p!=="error"&&i(`⚠️ ${m} — Error`,"Agent encountered an error",`error-${l.id}`),r.current.set(l.id,d)}}},[t,n.enabled,n.onApproval,n.onComplete,n.onError,i])}class Wr{constructor(){ue(this,"dedupMap",new Map);ue(this,"DEDUP_WINDOW_MS",5e3);ue(this,"DEDUP_MAX_SIZE",50);ue(this,"DEDUP_CLEANUP_AGE_MS",1e4);ue(this,"toastCallbacks",[]);ue(this,"systemMessageCallbacks",[]);ue(this,"clearSystemMessageCallbacks",[]);ue(this,"resolveActionFn",null);ue(this,"viewRequestRespondFn",null);ue(this,"ides",[])}onToast(s){return this.toastCallbacks.push(s),()=>{this.toastCallbacks=this.toastCallbacks.filter(n=>n!==s)}}onSystemMessage(s){return this.systemMessageCallbacks.push(s),()=>{this.systemMessageCallbacks=this.systemMessageCallbacks.filter(n=>n!==s)}}onClearSystemMessage(s){return this.clearSystemMessageCallbacks.push(s),()=>{this.clearSystemMessageCallbacks=this.clearSystemMessageCallbacks.filter(n=>n!==s)}}setResolveAction(s){this.resolveActionFn=s}setIdes(s){this.ides=s}setViewRequestRespond(s){this.viewRequestRespondFn=s}emitToast(s){for(const n of this.toastCallbacks)n(s)}showToast(s,n="info",r){const a=(r==null?void 0:r.id)||Date.now();this.emitToast({id:a,message:s,type:n,timestamp:a,duration:5e3,...r})}emitSystemMessage(s,n){for(const r of this.systemMessageCallbacks)r(s,n)}emitClearSystemMessage(s,n){for(const r of this.clearSystemMessageCallbacks)r(s,n)}isDuplicate(s){const n=Date.now(),r=this.dedupMap.get(s)||0;if(n-r<this.DEDUP_WINDOW_MS)return!0;if(this.dedupMap.set(s,n),this.dedupMap.size>this.DEDUP_MAX_SIZE)for(const[a,c]of this.dedupMap)n-c>this.DEDUP_CLEANUP_AGE_MS&&this.dedupMap.delete(a);return!1}resolveOwningDaemon(s){if(s.ideType==="adhdev-daemon"&&s.ideId){const a=this.ides.find(c=>c.id===s.ideId&&c.type==="adhdev-daemon");if(a)return a}let n;if(s.targetSessionId&&(n=this.findOwningSession(s.targetSessionId)||void 0),s.ideId&&(n=n||this.ides.find(a=>a.id===s.ideId)),!n&&s.instanceId&&(n=this.ides.find(a=>a.id.endsWith(`:ide:${s.instanceId}`)||a.id.endsWith(`:cli:${s.instanceId}`))),n){const a=n.daemonId;if(a){const c=this.ides.find(i=>i.id===a&&i.type==="adhdev-daemon");if(c)return c}}const r=this.ides.filter(a=>a.type==="adhdev-daemon");return r.length===1?r[0]:null}resolveRouteId(s,n){for(const r of this.ides)if(r.id.startsWith(s)&&(!n||n===r.type))return r.id;return s}findOwningSession(s){for(const n of this.ides)if(n.id===s||n.sessionId===s||(Array.isArray(n.agentStreams)?n.agentStreams:[]).some(a=>(a==null?void 0:a.sessionId)===s))return n;return null}resolveActionRouteTarget(s){if(s.ideId){const n=s.agentType||s.ideType||"";return this.resolveRouteId(s.ideId,n)}if(s.targetSessionId){const n=this.findOwningSession(s.targetSessionId);return(n==null?void 0:n.id)||(n==null?void 0:n.daemonId)||null}return null}resolveConversationKey(s){return s.targetSessionId?s.targetSessionId:s.ideId?s.ideId:null}handleRawEvent(s,n){var d,m;if(!s.ideId&&s.instanceId){for(const f of this.ides)if(f.id.endsWith(`:ide:${s.instanceId}`)||f.id.endsWith(`:cli:${s.instanceId}`)){s.ideId=f.id;break}}const r=this.resolveConversationKey(s),c=`${r||s.instanceId||s.ideType||s.providerType||""}:${s.event}:${s.chatTitle||""}`;if(this.isDuplicate(c))return;let i=xe(s.ideType||"");const u=this.resolveOwningDaemon(s);if(u){const f=Xe(u,{fallbackId:u.id});f&&(i=s.ideType==="adhdev-daemon"?f:`${f}/${i}`)}let l="",p="info";if(s.event==="agent:generating_completed"){const f=s.duration?` (${s.duration}s)`:"";l=`✅ ${i} agent task completed${f}`,p="success";try{new Audio("data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQQAAAB/f39/").play().catch(()=>{})}catch{}r&&Lr().chatTaskCompletionBubble&&this.emitSystemMessage(r,{role:"system",timestamp:Date.now(),content:`✅ Task completed${f}`,_localId:`sys_complete_${Date.now()}`})}else if(s.event==="agent:generating_started")r&&this.emitClearSystemMessage(r,"sys_complete_");else if(s.event==="agent:waiting_approval"){if(l=`⚡ ${i} approval needed`,p="warning",r){const f=s.modalMessage||"Approval requested",g=(d=s.modalButtons)!=null&&d.length?s.modalButtons.map(y=>`[${y}]`).join(" "):"[Approve] [Reject]";this.emitSystemMessage(r,{role:"system",timestamp:Date.now(),content:`⚡ Approval requested: ${f}
42
- ${g}`,_localId:`sys_approval_${Date.now()}`})}if((m=s.modalButtons)!=null&&m.length&&this.resolveActionFn){const f=this.resolveActionRouteTarget(s);if(!f)return;const g=s.agentType||s.ideType||"",y=s.ideType||"",k=s.modalButtons,I=x=>x.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim(),h=this.resolveActionFn,b=k.map((x,j)=>{const v=I(x).toLowerCase(),w=/^(run|approve|accept|yes|allow|always)/.test(v),R=/^(reject|deny|delete|remove|abort|cancel|no)/.test(v);return{label:I(x),variant:w?"primary":R?"danger":"default",onClick:()=>{const _=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(v);h(f,"resolve_action",{action:_?"approve":"reject",button:x,buttonIndex:j,agentType:g,ideType:y,...s.targetSessionId&&{targetSessionId:s.targetSessionId}})}}}),N=s.modalMessage?`⚡ ${i}: ${s.modalMessage.replace(/[\n\r]+/g," ").slice(0,80)}`:l,T=Date.now();this.emitToast({id:T,message:N,type:p,timestamp:T,targetKey:r||f,actions:b,duration:15e3}),l=""}}else if(s.event==="monitor:long_generating"){const f=s.elapsedSec?` (${Math.round(s.elapsedSec/60)}m)`:"";l=`⚠️ ${i} agent is taking a long time${f}`,p="warning",nt("browser")&&!document.hasFocus()&&Wt(`⚠️ ${i} — Long Running`,`Agent has been generating for over ${f.replace(/[()]/g,"")}`,`long-${s.ideId||s.agentType}`)}else if(s.event==="team:view_request"){const f=s.requesterName||"A team member",g=s.requestId,y=s.orgId;if(l=`👁️ ${f} wants to view your session`,p="warning",g&&y&&this.viewRequestRespondFn){const k=this.viewRequestRespondFn,I=Date.now(),h=[{label:"Approve",variant:"primary",onClick:()=>{k(y,g,"approve").catch(b=>console.error("[EventManager] approve view request failed:",b))}},{label:"Decline",variant:"danger",onClick:()=>{k(y,g,"reject").catch(b=>console.error("[EventManager] reject view request failed:",b))}}];this.emitToast({id:I,message:l,type:p,timestamp:I,actions:h,duration:3e4}),l=""}nt("browser")&&!document.hasFocus()&&Wt("👁️ View Request",`${f} wants to view your session`,`view-request-${g}`)}else s.event==="team:view_request_approved"?(l="✅ View request approved",p="success"):s.event==="team:view_request_rejected"&&(l=`❌ ${s.targetName||"Team member"} declined your view request`,p="warning");if(l){const f=Date.now();this.emitToast({id:f,message:l,type:p,timestamp:f,targetKey:r||s.ideId,duration:5e3})}}}const _e=new Wr;function ze(...t){return fn(gn(t))}function Or({icon:t,title:s,subtitle:n,badge:r,actions:a,className:c}){return e.jsxs("div",{className:ze("dashboard-header",c),children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"header-title flex items-center gap-2",children:[e.jsx("span",{className:"flex items-center text-lg",children:t})," ",s,r&&e.jsxs("span",{className:"text-[10px] font-semibold px-1.5 py-px rounded-full bg-accent/10 text-accent-light",children:[r.count!==void 0?r.count:""," ",r.text]})]}),n&&e.jsx("div",{className:"header-subtitle mt-1 text-xs text-text-muted",children:n})]}),a&&e.jsx("div",{className:"flex gap-2",children:a})]})}function Nt({icon:t,title:s,subtitle:n,badge:r,actions:a,widthClassName:c="max-w-6xl",contentClassName:i,children:u}){return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(Or,{icon:t,title:s,subtitle:n,badge:r,actions:a}),e.jsx("div",{className:"page-content",children:e.jsx("div",{className:ze("mx-auto flex w-full flex-col gap-4",c,i),children:u})})]})}function me({title:t,icon:s,description:n,accentColor:r,className:a,children:c}){return e.jsxs("div",{className:ze("bg-bg-card border border-border-subtle rounded-2xl p-5 backdrop-blur-xl transition-all","hover:border-border-default hover:shadow-glow",r&&"border-l-[3px]",a),style:r?{borderLeftColor:r}:void 0,children:[(t||n)&&e.jsxs("div",{className:"mb-4",children:[t&&e.jsxs("h3",{className:"text-base font-semibold text-text-primary",children:[s&&e.jsx("span",{className:"mr-1.5",children:s}),t]}),n&&e.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:n})]}),c]})}function Vt({icon:t,title:s,description:n,action:r,className:a}){return e.jsxs("div",{className:ze("py-16 px-5 text-center bg-bg-glass border-2 border-dashed border-border-subtle rounded-2xl",a),children:[e.jsx("div",{className:"text-5xl mb-4 opacity-50",children:t}),e.jsx("h3",{className:"text-lg font-bold text-text-secondary mb-2",children:s}),e.jsx("p",{className:"text-sm text-text-muted max-w-sm mx-auto mb-5 leading-relaxed",children:n}),r]})}const Kr={error:"bg-red-500/10 border-red-500/30 text-red-400",warning:"bg-yellow-500/10 border-yellow-500/30 text-yellow-400",success:"bg-green-500/10 border-green-500/30 text-green-400",info:"bg-indigo-500/10 border-indigo-500/30 text-indigo-400"},zr={error:"⚠️",warning:"🧪",success:"✅",info:"💡"};function Hr({variant:t,children:s,onDismiss:n,className:r}){return e.jsxs("div",{className:ze("flex items-center justify-between gap-3 px-4 py-3 rounded-xl border text-[13px]",Kr[t],r),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:zr[t]}),e.jsx("span",{children:s})]}),n&&e.jsx("button",{onClick:n,className:"cursor-pointer border-none bg-transparent text-current text-base opacity-70 hover:opacity-100 transition-opacity",children:"✕"})]})}const Ur={online:"bg-green-500/10 text-green-400 border-green-500/30",idle:"bg-yellow-500/10 text-yellow-400 border-yellow-500/30",busy:"bg-orange-500/10 text-orange-400 border-orange-500/30",error:"bg-red-500/10 text-red-400 border-red-500/30",offline:"bg-gray-500/10 text-text-secondary border-gray-500/30"},Fr={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function Vr({status:t,label:s,className:n}){const r=s||t;return e.jsxs("span",{className:ze("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",Ur[t],n),children:[e.jsx("span",{className:ze("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",Fr[t])}),r]})}function Yr(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function Ot(){try{const t=localStorage.getItem("theme");if(t==="dark"||t==="light"||t==="system")return t}catch{}return"dark"}function yt(t){return t==="system"?Yr():t}function qr(){typeof document>"u"||document.documentElement.setAttribute("data-theme",yt(Ot()))}function Xr(){const[t,s]=o.useState(Ot),[n,r]=o.useState(()=>yt(Ot()));o.useEffect(()=>{document.documentElement.setAttribute("data-theme",n)},[n]),o.useEffect(()=>{const i=window.matchMedia("(prefers-color-scheme: light)"),u=l=>{t==="system"&&r(l.matches?"light":"dark")};return i.addEventListener("change",u),()=>i.removeEventListener("change",u)},[t]);const a=o.useCallback(i=>{s(i),r(yt(i));try{localStorage.setItem("theme",i)}catch{}},[]),c=o.useCallback(()=>{s(i=>{const u=i==="dark"?"light":i==="light"?"system":"dark";r(yt(u));try{localStorage.setItem("theme",u)}catch{}return u})},[]);return{theme:n,preference:t,setPreference:a,cycleTheme:c,isDark:n==="dark"}}function We({label:t,description:s,checked:n,disabled:r,onChange:a,extra:c}){return e.jsxs("label",{className:"flex justify-between items-center cursor-pointer",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:t}),e.jsx("div",{className:"text-[11px] text-text-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[c,e.jsx("input",{type:"checkbox",checked:n,disabled:r,onChange:i=>a(i.target.checked),className:"w-5 h-5 accent-accent"})]})]})}function Gr({onPrefChange:t}){const[s,n]=_r(),r=(a,c)=>{n({[a]:c}),t==null||t(a,c)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(_s,{size:15})," Notifications"]}),description:"Master toggle for all alerts",checked:s.globalEnabled,onChange:a=>r("globalEnabled",a)}),s.globalEnabled&&e.jsx("div",{className:"border-t border-border-subtle my-0.5"}),s.globalEnabled&&e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Le,{size:15})," Browser Notifications"]}),description:"Desktop alerts when tab is inactive",checked:s.browserNotifications,onChange:a=>r("browserNotifications",a)}),s.globalEnabled&&s.browserNotifications&&e.jsxs("div",{className:"ml-5 pl-3 border-l-2 border-border-subtle flex flex-col gap-2",children:[e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Kn,{size:15})," Completion Alerts"]}),description:"Notify when agent finishes a task",checked:s.completionAlert,onChange:a=>r("completionAlert",a)}),e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(zn,{size:15})," Approval Alerts"]}),description:"Notify when agent needs approval",checked:s.approvalAlert,onChange:a=>r("approvalAlert",a)}),e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(qe,{size:15})," Connection Alerts"]}),description:"Alert when a daemon disconnects",checked:s.disconnectAlert,onChange:a=>r("disconnectAlert",a)})]}),s.globalEnabled&&e.jsx("div",{className:"border-t border-border-subtle my-2"}),s.globalEnabled&&e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ye,{size:15})," Task Completion Bubble"]}),description:"Show a system message bubble in chat when an agent finishes a task",checked:s.chatTaskCompletionBubble,onChange:a=>r("chatTaskCompletionBubble",a)}),!s.globalEnabled&&e.jsx("p",{className:"text-[11px] text-text-muted italic",children:"All notifications are disabled. Enable the master toggle to configure individual alerts."})]})}function Jr({ides:t,emptyMessage:s,sendDaemonCommand:n,onDisconnect:r,onRevokeToken:a}){const c=t.filter(i=>i.type==="adhdev-daemon");return c.length===0?e.jsx(Vt,{icon:e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-12 h-12 object-contain mx-auto opacity-90"}),title:"No machines connected",description:s||"Run 'adhdev-standalone' to connect a local daemon instance."}):e.jsx("div",{className:"flex flex-col gap-2",children:c.map(i=>e.jsx(Qr,{ide:i,allIdes:t,sendDaemonCommand:n,onDisconnect:r,onRevokeToken:a},i.id))})}function os({title:t,message:s,confirmLabel:n,confirmColor:r,onConfirm:a,onCancel:c}){const i=r==="red"?"bg-red-500/20 text-red-400 border-red-500/30 hover:bg-red-500/30":"bg-amber-500/20 text-amber-400 border-amber-500/30 hover:bg-amber-500/30";return bn.createPortal(e.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/60 backdrop-blur-sm",style:{zIndex:9999},onClick:c,children:e.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl p-5 max-w-sm w-full mx-4 shadow-2xl",onClick:u=>u.stopPropagation(),children:[e.jsx("div",{className:"font-semibold text-sm mb-3",children:t}),e.jsx("div",{className:"text-xs text-text-muted leading-relaxed mb-5 whitespace-pre-line",children:s}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:c,className:"text-xs px-3 py-1.5 rounded-lg font-medium bg-bg-secondary text-text-secondary border border-border-subtle hover:bg-bg-glass transition-colors",children:"Cancel"}),e.jsx("button",{onClick:a,className:`text-xs px-3 py-1.5 rounded-lg font-medium border transition-colors ${i}`,children:n})]})]})}),document.body)}function Zr(t){const s=t.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase(),r=[...Ys,...qs,...Xs].find(a=>a.id===s||s.includes(a.id)||a.id.includes(s));return r?{icon:r.icon,name:r.name}:{icon:"📝",name:t}}function Qr({ide:t,allIdes:s,sendDaemonCommand:n,onDisconnect:r,onRevokeToken:a}){var P,K;const[c,i]=o.useState("idle"),[u,l]=o.useState(""),[p,d]=o.useState(null),[m,f]=o.useState("idle"),[g,y]=o.useState(""),k=t,I=k.version||k.daemonVersion||null,h=((P=k.machine)==null?void 0:P.platform)||((K=k.system)==null?void 0:K.platform)||"",b=Xe(k,{fallbackId:t.id}),N=h==="win32"?"🪟":h==="darwin"?"🍎":"🐧",T=s.filter(S=>S.daemonId===t.id&&S.transport==="cdp-page"),x=s.filter(S=>S.daemonId===t.id&&S.transport==="pty"),j=s.filter(S=>S.daemonId===t.id&&S.transport==="acp"),v=k.p2p,w=async()=>{var S,U,Q;if(n){i("upgrading"),l("Installing latest version...");try{const J=await n(t.id,"daemon_upgrade",{});(S=J==null?void 0:J.result)!=null&&S.upgraded||(U=J==null?void 0:J.result)!=null&&U.success?(i("done"),l(`Upgraded to v${J.result.version||"latest"}. Daemon is restarting...`)):(i("error"),l(((Q=J==null?void 0:J.result)==null?void 0:Q.error)||"Upgrade failed"))}catch(J){i("error"),l((J==null?void 0:J.message)||"Connection lost during upgrade")}}},R=async()=>{if(d(null),!!r){f("loading");try{await r(t.id),f("done"),y("Machine disconnected.")}catch(S){f("error"),y((S==null?void 0:S.message)||"Failed to disconnect")}}},_=async()=>{if(d(null),!!a){f("loading");try{await a(t.id),f("done"),y('Token revoked. Machine must restart "adhdev-standalone" to reconnect.')}catch(S){f("error"),y((S==null?void 0:S.message)||"Failed to revoke token")}}},W="0.7.7",A=!I||I!==W,C=T.length+x.length+j.length;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-bg-glass rounded-lg px-4 py-3 border border-border-subtle",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xl",children:N}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:b}),e.jsxs("div",{className:"text-xs text-text-muted font-mono flex items-center gap-2",children:[e.jsxs("span",{children:[t.id.substring(0,12),"…"]}),I&&e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${A?"bg-amber-500/15 text-amber-400":"bg-bg-secondary"}`,children:["v",I,!A&&" ✓"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&A&&e.jsx("button",{onClick:w,disabled:c==="upgrading"||c==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${W}`,children:c==="upgrading"?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"animate-spin",children:"⟳"})," Upgrading..."]}):c==="done"?"✓ Updated":`↑ Update${` to v${W}`}`}),r&&e.jsx("button",{onClick:()=>d("disconnect"),disabled:m==="loading",className:"btn btn-sm btn-warning disabled:opacity-50 disabled:cursor-not-allowed",title:"Disconnect this machine",children:"Disconnect"}),a&&e.jsx("button",{onClick:()=>d("revoke"),disabled:m==="loading",className:"btn btn-sm btn-danger disabled:opacity-50 disabled:cursor-not-allowed",title:"Remove machine (requires re-setup)",children:"Remove"}),e.jsx(Vr,{status:t.status==="online"?"online":"error"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2.5 pt-2.5 border-t border-border-subtle/50",children:[v&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${v.state==="connected"?"bg-green-400":v.state==="connecting"||v.state==="new"?"bg-amber-400 animate-pulse":"bg-text-muted/30"}`}),e.jsxs("span",{className:"text-text-muted",children:["P2P ",v.state==="connected"?"connected":v.state==="connecting"||v.state==="new"?"connecting...":v.state||"off"]}),v.peers!==void 0&&v.peers>0&&e.jsxs("span",{className:"text-text-muted/60",children:["(",v.peers," peer",v.peers!==1?"s":"",")"]})]}),v&&C>0&&e.jsx("span",{className:"text-border-subtle",children:"·"}),C>0?e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[T.map(S=>{const U=Zr(S.type),Q=S.cdpConnected;return e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:U.icon}),e.jsx("span",{children:U.name}),Q!==void 0&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Q?"bg-green-400":"bg-amber-400 animate-pulse"}`,title:Q?"CDP connected":"CDP connecting..."})]},S.id)}),x.map(S=>e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:"⌨️"}),e.jsx("span",{children:S.cliName||"CLI"})]},S.id)),j.map(S=>e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:"🔗"}),e.jsx("span",{children:S.cliName||"ACP"})]},S.id))]}):e.jsx("span",{className:"text-[11px] text-text-muted/60 italic",children:"No IDEs connected"})]}),(u||g)&&e.jsx("div",{className:`text-xs mt-2 px-1 ${c==="error"||m==="error"?"text-red-400":c==="done"||m==="done"?"text-green-400":"text-text-muted"}`,children:g||u})]}),p==="disconnect"&&e.jsx(os,{title:"🔌 Disconnect Machine",message:`Disconnect "${b}" from ADHDev?
42
+ ${g}`,_localId:`sys_approval_${Date.now()}`})}if((m=s.modalButtons)!=null&&m.length&&this.resolveActionFn){const f=this.resolveActionRouteTarget(s);if(!f)return;const g=s.agentType||s.ideType||"",y=s.ideType||"",k=s.modalButtons,I=x=>x.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim(),h=this.resolveActionFn,b=k.map((x,j)=>{const v=I(x).toLowerCase(),w=/^(run|approve|accept|yes|allow|always)/.test(v),R=/^(reject|deny|delete|remove|abort|cancel|no)/.test(v);return{label:I(x),variant:w?"primary":R?"danger":"default",onClick:()=>{const _=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(v);h(f,"resolve_action",{action:_?"approve":"reject",button:x,buttonIndex:j,agentType:g,ideType:y,...s.targetSessionId&&{targetSessionId:s.targetSessionId}})}}}),N=s.modalMessage?`⚡ ${i}: ${s.modalMessage.replace(/[\n\r]+/g," ").slice(0,80)}`:l,T=Date.now();this.emitToast({id:T,message:N,type:p,timestamp:T,targetKey:r||f,actions:b,duration:15e3}),l=""}}else if(s.event==="monitor:long_generating"){const f=s.elapsedSec?` (${Math.round(s.elapsedSec/60)}m)`:"";l=`⚠️ ${i} agent is taking a long time${f}`,p="warning",nt("browser")&&!document.hasFocus()&&Wt(`⚠️ ${i} — Long Running`,`Agent has been generating for over ${f.replace(/[()]/g,"")}`,`long-${s.ideId||s.agentType}`)}else if(s.event==="team:view_request"){const f=s.requesterName||"A team member",g=s.requestId,y=s.orgId;if(l=`👁️ ${f} wants to view your session`,p="warning",g&&y&&this.viewRequestRespondFn){const k=this.viewRequestRespondFn,I=Date.now(),h=[{label:"Approve",variant:"primary",onClick:()=>{k(y,g,"approve").catch(b=>console.error("[EventManager] approve view request failed:",b))}},{label:"Decline",variant:"danger",onClick:()=>{k(y,g,"reject").catch(b=>console.error("[EventManager] reject view request failed:",b))}}];this.emitToast({id:I,message:l,type:p,timestamp:I,actions:h,duration:3e4}),l=""}nt("browser")&&!document.hasFocus()&&Wt("👁️ View Request",`${f} wants to view your session`,`view-request-${g}`)}else s.event==="team:view_request_approved"?(l="✅ View request approved",p="success"):s.event==="team:view_request_rejected"&&(l=`❌ ${s.targetName||"Team member"} declined your view request`,p="warning");if(l){const f=Date.now();this.emitToast({id:f,message:l,type:p,timestamp:f,targetKey:r||s.ideId,duration:5e3})}}}const _e=new Wr;function ze(...t){return fn(gn(t))}function Or({icon:t,title:s,subtitle:n,badge:r,actions:a,className:c}){return e.jsxs("div",{className:ze("dashboard-header",c),children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"header-title flex items-center gap-2",children:[e.jsx("span",{className:"flex items-center text-lg",children:t})," ",s,r&&e.jsxs("span",{className:"text-[10px] font-semibold px-1.5 py-px rounded-full bg-accent/10 text-accent-light",children:[r.count!==void 0?r.count:""," ",r.text]})]}),n&&e.jsx("div",{className:"header-subtitle mt-1 text-xs text-text-muted",children:n})]}),a&&e.jsx("div",{className:"flex gap-2",children:a})]})}function Nt({icon:t,title:s,subtitle:n,badge:r,actions:a,widthClassName:c="max-w-6xl",contentClassName:i,children:u}){return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(Or,{icon:t,title:s,subtitle:n,badge:r,actions:a}),e.jsx("div",{className:"page-content",children:e.jsx("div",{className:ze("mx-auto flex w-full flex-col gap-4",c,i),children:u})})]})}function me({title:t,icon:s,description:n,accentColor:r,className:a,children:c}){return e.jsxs("div",{className:ze("bg-bg-card border border-border-subtle rounded-2xl p-5 backdrop-blur-xl transition-all","hover:border-border-default hover:shadow-glow",r&&"border-l-[3px]",a),style:r?{borderLeftColor:r}:void 0,children:[(t||n)&&e.jsxs("div",{className:"mb-4",children:[t&&e.jsxs("h3",{className:"text-base font-semibold text-text-primary",children:[s&&e.jsx("span",{className:"mr-1.5",children:s}),t]}),n&&e.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:n})]}),c]})}function Vt({icon:t,title:s,description:n,action:r,className:a}){return e.jsxs("div",{className:ze("py-16 px-5 text-center bg-bg-glass border-2 border-dashed border-border-subtle rounded-2xl",a),children:[e.jsx("div",{className:"text-5xl mb-4 opacity-50",children:t}),e.jsx("h3",{className:"text-lg font-bold text-text-secondary mb-2",children:s}),e.jsx("p",{className:"text-sm text-text-muted max-w-sm mx-auto mb-5 leading-relaxed",children:n}),r]})}const Kr={error:"bg-red-500/10 border-red-500/30 text-red-400",warning:"bg-yellow-500/10 border-yellow-500/30 text-yellow-400",success:"bg-green-500/10 border-green-500/30 text-green-400",info:"bg-indigo-500/10 border-indigo-500/30 text-indigo-400"},zr={error:"⚠️",warning:"🧪",success:"✅",info:"💡"};function Hr({variant:t,children:s,onDismiss:n,className:r}){return e.jsxs("div",{className:ze("flex items-center justify-between gap-3 px-4 py-3 rounded-xl border text-[13px]",Kr[t],r),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:zr[t]}),e.jsx("span",{children:s})]}),n&&e.jsx("button",{onClick:n,className:"cursor-pointer border-none bg-transparent text-current text-base opacity-70 hover:opacity-100 transition-opacity",children:"✕"})]})}const Ur={online:"bg-green-500/10 text-green-400 border-green-500/30",idle:"bg-yellow-500/10 text-yellow-400 border-yellow-500/30",busy:"bg-orange-500/10 text-orange-400 border-orange-500/30",error:"bg-red-500/10 text-red-400 border-red-500/30",offline:"bg-gray-500/10 text-text-secondary border-gray-500/30"},Fr={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function Vr({status:t,label:s,className:n}){const r=s||t;return e.jsxs("span",{className:ze("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",Ur[t],n),children:[e.jsx("span",{className:ze("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",Fr[t])}),r]})}function Yr(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function Ot(){try{const t=localStorage.getItem("theme");if(t==="dark"||t==="light"||t==="system")return t}catch{}return"dark"}function yt(t){return t==="system"?Yr():t}function qr(){typeof document>"u"||document.documentElement.setAttribute("data-theme",yt(Ot()))}function Xr(){const[t,s]=o.useState(Ot),[n,r]=o.useState(()=>yt(Ot()));o.useEffect(()=>{document.documentElement.setAttribute("data-theme",n)},[n]),o.useEffect(()=>{const i=window.matchMedia("(prefers-color-scheme: light)"),u=l=>{t==="system"&&r(l.matches?"light":"dark")};return i.addEventListener("change",u),()=>i.removeEventListener("change",u)},[t]);const a=o.useCallback(i=>{s(i),r(yt(i));try{localStorage.setItem("theme",i)}catch{}},[]),c=o.useCallback(()=>{s(i=>{const u=i==="dark"?"light":i==="light"?"system":"dark";r(yt(u));try{localStorage.setItem("theme",u)}catch{}return u})},[]);return{theme:n,preference:t,setPreference:a,cycleTheme:c,isDark:n==="dark"}}function We({label:t,description:s,checked:n,disabled:r,onChange:a,extra:c}){return e.jsxs("label",{className:"flex justify-between items-center cursor-pointer",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:t}),e.jsx("div",{className:"text-[11px] text-text-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[c,e.jsx("input",{type:"checkbox",checked:n,disabled:r,onChange:i=>a(i.target.checked),className:"w-5 h-5 accent-accent"})]})]})}function Gr({onPrefChange:t}){const[s,n]=_r(),r=(a,c)=>{n({[a]:c}),t==null||t(a,c)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(_s,{size:15})," Notifications"]}),description:"Master toggle for all alerts",checked:s.globalEnabled,onChange:a=>r("globalEnabled",a)}),s.globalEnabled&&e.jsx("div",{className:"border-t border-border-subtle my-0.5"}),s.globalEnabled&&e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Le,{size:15})," Browser Notifications"]}),description:"Desktop alerts when tab is inactive",checked:s.browserNotifications,onChange:a=>r("browserNotifications",a)}),s.globalEnabled&&s.browserNotifications&&e.jsxs("div",{className:"ml-5 pl-3 border-l-2 border-border-subtle flex flex-col gap-2",children:[e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Kn,{size:15})," Completion Alerts"]}),description:"Notify when agent finishes a task",checked:s.completionAlert,onChange:a=>r("completionAlert",a)}),e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(zn,{size:15})," Approval Alerts"]}),description:"Notify when agent needs approval",checked:s.approvalAlert,onChange:a=>r("approvalAlert",a)}),e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(qe,{size:15})," Connection Alerts"]}),description:"Alert when a daemon disconnects",checked:s.disconnectAlert,onChange:a=>r("disconnectAlert",a)})]}),s.globalEnabled&&e.jsx("div",{className:"border-t border-border-subtle my-2"}),s.globalEnabled&&e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ye,{size:15})," Task Completion Bubble"]}),description:"Show a system message bubble in chat when an agent finishes a task",checked:s.chatTaskCompletionBubble,onChange:a=>r("chatTaskCompletionBubble",a)}),!s.globalEnabled&&e.jsx("p",{className:"text-[11px] text-text-muted italic",children:"All notifications are disabled. Enable the master toggle to configure individual alerts."})]})}function Jr({ides:t,emptyMessage:s,sendDaemonCommand:n,onDisconnect:r,onRevokeToken:a}){const c=t.filter(i=>i.type==="adhdev-daemon");return c.length===0?e.jsx(Vt,{icon:e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-12 h-12 object-contain mx-auto opacity-90"}),title:"No machines connected",description:s||"Run 'adhdev-standalone' to connect a local daemon instance."}):e.jsx("div",{className:"flex flex-col gap-2",children:c.map(i=>e.jsx(Qr,{ide:i,allIdes:t,sendDaemonCommand:n,onDisconnect:r,onRevokeToken:a},i.id))})}function os({title:t,message:s,confirmLabel:n,confirmColor:r,onConfirm:a,onCancel:c}){const i=r==="red"?"bg-red-500/20 text-red-400 border-red-500/30 hover:bg-red-500/30":"bg-amber-500/20 text-amber-400 border-amber-500/30 hover:bg-amber-500/30";return bn.createPortal(e.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/60 backdrop-blur-sm",style:{zIndex:9999},onClick:c,children:e.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl p-5 max-w-sm w-full mx-4 shadow-2xl",onClick:u=>u.stopPropagation(),children:[e.jsx("div",{className:"font-semibold text-sm mb-3",children:t}),e.jsx("div",{className:"text-xs text-text-muted leading-relaxed mb-5 whitespace-pre-line",children:s}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:c,className:"text-xs px-3 py-1.5 rounded-lg font-medium bg-bg-secondary text-text-secondary border border-border-subtle hover:bg-bg-glass transition-colors",children:"Cancel"}),e.jsx("button",{onClick:a,className:`text-xs px-3 py-1.5 rounded-lg font-medium border transition-colors ${i}`,children:n})]})]})}),document.body)}function Zr(t){const s=t.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase(),r=[...Ys,...qs,...Xs].find(a=>a.id===s||s.includes(a.id)||a.id.includes(s));return r?{icon:r.icon,name:r.name}:{icon:"📝",name:t}}function Qr({ide:t,allIdes:s,sendDaemonCommand:n,onDisconnect:r,onRevokeToken:a}){var P,K;const[c,i]=o.useState("idle"),[u,l]=o.useState(""),[p,d]=o.useState(null),[m,f]=o.useState("idle"),[g,y]=o.useState(""),k=t,I=k.version||k.daemonVersion||null,h=((P=k.machine)==null?void 0:P.platform)||((K=k.system)==null?void 0:K.platform)||"",b=Xe(k,{fallbackId:t.id}),N=h==="win32"?"🪟":h==="darwin"?"🍎":"🐧",T=s.filter(S=>S.daemonId===t.id&&S.transport==="cdp-page"),x=s.filter(S=>S.daemonId===t.id&&S.transport==="pty"),j=s.filter(S=>S.daemonId===t.id&&S.transport==="acp"),v=k.p2p,w=async()=>{var S,U,Q;if(n){i("upgrading"),l("Installing latest version...");try{const J=await n(t.id,"daemon_upgrade",{});(S=J==null?void 0:J.result)!=null&&S.upgraded||(U=J==null?void 0:J.result)!=null&&U.success?(i("done"),l(`Upgraded to v${J.result.version||"latest"}. Daemon is restarting...`)):(i("error"),l(((Q=J==null?void 0:J.result)==null?void 0:Q.error)||"Upgrade failed"))}catch(J){i("error"),l((J==null?void 0:J.message)||"Connection lost during upgrade")}}},R=async()=>{if(d(null),!!r){f("loading");try{await r(t.id),f("done"),y("Machine disconnected.")}catch(S){f("error"),y((S==null?void 0:S.message)||"Failed to disconnect")}}},_=async()=>{if(d(null),!!a){f("loading");try{await a(t.id),f("done"),y('Token revoked. Machine must restart "adhdev-standalone" to reconnect.')}catch(S){f("error"),y((S==null?void 0:S.message)||"Failed to revoke token")}}},W="0.7.9",A=!I||I!==W,C=T.length+x.length+j.length;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-bg-glass rounded-lg px-4 py-3 border border-border-subtle",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xl",children:N}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:b}),e.jsxs("div",{className:"text-xs text-text-muted font-mono flex items-center gap-2",children:[e.jsxs("span",{children:[t.id.substring(0,12),"…"]}),I&&e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${A?"bg-amber-500/15 text-amber-400":"bg-bg-secondary"}`,children:["v",I,!A&&" ✓"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&A&&e.jsx("button",{onClick:w,disabled:c==="upgrading"||c==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${W}`,children:c==="upgrading"?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"animate-spin",children:"⟳"})," Upgrading..."]}):c==="done"?"✓ Updated":`↑ Update${` to v${W}`}`}),r&&e.jsx("button",{onClick:()=>d("disconnect"),disabled:m==="loading",className:"btn btn-sm btn-warning disabled:opacity-50 disabled:cursor-not-allowed",title:"Disconnect this machine",children:"Disconnect"}),a&&e.jsx("button",{onClick:()=>d("revoke"),disabled:m==="loading",className:"btn btn-sm btn-danger disabled:opacity-50 disabled:cursor-not-allowed",title:"Remove machine (requires re-setup)",children:"Remove"}),e.jsx(Vr,{status:t.status==="online"?"online":"error"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2.5 pt-2.5 border-t border-border-subtle/50",children:[v&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${v.state==="connected"?"bg-green-400":v.state==="connecting"||v.state==="new"?"bg-amber-400 animate-pulse":"bg-text-muted/30"}`}),e.jsxs("span",{className:"text-text-muted",children:["P2P ",v.state==="connected"?"connected":v.state==="connecting"||v.state==="new"?"connecting...":v.state||"off"]}),v.peers!==void 0&&v.peers>0&&e.jsxs("span",{className:"text-text-muted/60",children:["(",v.peers," peer",v.peers!==1?"s":"",")"]})]}),v&&C>0&&e.jsx("span",{className:"text-border-subtle",children:"·"}),C>0?e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[T.map(S=>{const U=Zr(S.type),Q=S.cdpConnected;return e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:U.icon}),e.jsx("span",{children:U.name}),Q!==void 0&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Q?"bg-green-400":"bg-amber-400 animate-pulse"}`,title:Q?"CDP connected":"CDP connecting..."})]},S.id)}),x.map(S=>e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:"⌨️"}),e.jsx("span",{children:S.cliName||"CLI"})]},S.id)),j.map(S=>e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:"🔗"}),e.jsx("span",{children:S.cliName||"ACP"})]},S.id))]}):e.jsx("span",{className:"text-[11px] text-text-muted/60 italic",children:"No IDEs connected"})]}),(u||g)&&e.jsx("div",{className:`text-xs mt-2 px-1 ${c==="error"||m==="error"?"text-red-400":c==="done"||m==="done"?"text-green-400":"text-text-muted"}`,children:g||u})]}),p==="disconnect"&&e.jsx(os,{title:"🔌 Disconnect Machine",message:`Disconnect "${b}" from ADHDev?
43
43
 
44
44
  This will close the server connection. The daemon process will continue running on the machine and will automatically reconnect.
45
45
 
@@ -65,4 +65,4 @@ This will disconnect CDP and optionally kill the process.`))try{const L=await n(
65
65
  from { opacity: 0; transform: translateX(40px); }
66
66
  to { opacity: 1; transform: translateX(0); }
67
67
  }
68
- `})]})}function fo(){const[t,s]=o.useState({ide:[],cli:[],ext:[],acp:[]}),[n,r]=o.useState(!0);o.useEffect(()=>{fetch("https://raw.githubusercontent.com/vilmire/adhdev-providers/main/registry.json").then(i=>i.json()).then(i=>{const u=[],l=[],p=[],d=[];Object.values(i.providers||{}).forEach(f=>{const g={name:f.name||"Unknown",status:f.status||"Stable",details:f.details||"Community Provider"};f.category==="ide"?u.push(g):f.category==="cli"?l.push(g):f.category==="extension"?p.push(g):f.category==="acp"&&d.push(g)});const m=(f,g)=>{const y={Stable:1,Beta:2,WIP:3},k=y[f.status]||99,I=y[g.status]||99;return k!==I?k-I:f.name.localeCompare(g.name)};s({ide:u.sort(m),cli:l.sort(m),ext:p.sort(m),acp:d.sort(m)})}).catch(i=>console.error("Failed to load capabilities:",i)).finally(()=>r(!1))},[]);const a=i=>i==="Stable"?e.jsxs("div",{className:"flex items-center gap-1.5 text-success",children:[e.jsx(Is,{className:"w-4 h-4"})," ",e.jsx("span",{children:"Stable"})]}):i==="Beta"?e.jsxs("div",{className:"flex items-center gap-1.5 text-warning",children:[e.jsx(Ut,{className:"w-4 h-4"})," ",e.jsx("span",{children:"Beta"})]}):e.jsxs("div",{className:"flex items-center gap-1.5 text-text-muted",children:[e.jsx(As,{className:"w-4 h-4"})," ",e.jsx("span",{children:i})]}),c=i=>e.jsx("div",{className:"bg-bg-card border border-border-subtle rounded-xl overflow-hidden",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-bg-secondary border-b border-border-subtle text-xs uppercase text-text-muted font-medium tracking-wider",children:[e.jsx("th",{className:"py-3 px-4 w-1/3",children:"Target"}),e.jsx("th",{className:"py-3 px-4 w-1/4",children:"Status"}),e.jsx("th",{className:"py-3 px-4",children:"Details"})]})}),e.jsx("tbody",{className:"divide-y divide-border-subtle text-sm",children:i.map((u,l)=>e.jsxs("tr",{className:"hover:bg-bg-subtle/50 transition-colors",children:[e.jsx("td",{className:"py-3 px-4 font-medium text-text-main",children:u.name}),e.jsx("td",{className:"py-3 px-4",children:a(u.status)}),e.jsx("td",{className:"py-3 px-4 text-text-muted",children:u.details})]},l))})]})});return n?e.jsx(Nt,{title:"Capabilities",subtitle:"Provider registry coverage for IDEs, CLI agents, extensions, and ACPs",icon:e.jsx(wt,{}),widthClassName:"max-w-5xl",children:e.jsx(Vt,{icon:e.jsx("div",{className:"w-8 h-8 border-4 border-accent border-t-transparent rounded-full animate-spin mx-auto"}),title:"Loading provider registry",description:"Fetching the latest support matrix from the shared provider registry."})}):e.jsxs(Nt,{title:"Capabilities",subtitle:"Provider registry coverage for IDEs, CLI agents, extensions, and ACPs",icon:e.jsx(wt,{}),widthClassName:"max-w-5xl",contentClassName:"animate-fade-in",children:[e.jsx(me,{title:"Registry overview",description:"Support status is loaded from the shared provider registry used across OSS and cloud surfaces.",children:e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"IDEs"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.ide.length})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"CLI"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.cli.length})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"Extensions"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.ext.length})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"ACP"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.acp.length})]})]})}),e.jsx(me,{title:"IDE support",icon:e.jsx(Le,{className:"w-4 h-4"}),description:"Desktop editors and IDE surfaces with registry-backed providers.",children:c(t.ide)}),e.jsx(me,{title:"Standalone CLI agents",icon:e.jsx(Ft,{className:"w-4 h-4"}),description:"CLI-first agents that can participate in the standalone dashboard.",children:c(t.cli)}),e.jsx(me,{title:"AI extensions",icon:e.jsx(qe,{className:"w-4 h-4"}),description:"IDE extensions and companion integrations available in the registry.",children:c(t.ext)}),e.jsx(me,{title:`ACP agents (${t.acp.length} loaded)`,icon:e.jsx(qe,{className:"w-4 h-4"}),description:"ACP-backed providers discovered through the same shared registry.",children:c(t.acp)})]})}class go{constructor(){ue(this,"adapters",new Map);ue(this,"states",new Map);ue(this,"ptyCallbacks",new Set);ue(this,"screenshotCallbacks",new Map);ue(this,"statusCallbacks",new Set)}resolveDaemonId(s){if(this.adapters.has(s))return s;if(s.startsWith("standalone")){for(const n of this.adapters.keys())if(n.startsWith("standalone"))return n}return null}register(s,n){this.adapters.set(s,n),this.states.set(s,n.connectionState)}unregister(s){this.adapters.delete(s),this.states.delete(s)}setState(s,n){this.states.set(s,n)}retryConnection(s){}get(s){const n=this.resolveDaemonId(s);return n?this.adapters.get(n):void 0}getState(s){const n=this.resolveDaemonId(s);return n&&this.states.get(n)||"disconnected"}sendData(s,n){return!1}sendPtyInput(s,n,r){return!1}sendPtyResize(s,n,r,a){return!1}onScreenshot(s,n){return this.screenshotCallbacks.set(s,n),()=>{this.screenshotCallbacks.delete(s)}}emitScreenshot(s,n){this.screenshotCallbacks.forEach(r=>r(s,n))}onStatus(s){return this.statusCallbacks.add(s),()=>{this.statusCallbacks.delete(s)}}emitStatus(s,n){this.statusCallbacks.forEach(r=>r(s,n))}onPtyOutput(s){return this.ptyCallbacks.add(s),()=>{this.ptyCallbacks.delete(s)}}emitPtyOutput(s,n){this.ptyCallbacks.forEach(r=>r(s,n))}}const $e=new go;function bo(){if(typeof window>"u")return"ws://localhost:3847/ws";const s=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,r=new URLSearchParams(window.location.search).get("token");return r?`${s}?token=${encodeURIComponent(r)}`:s}const xs=bo(),ps=3e3,yo=3e4;let Ee=null,jo=0;const Ct=new Map;let Be=null,at=null;function vo(t){return t==="connected"?"connected":t}async function vt(t,s,n){const r=Mr(t,n||{}),a=Ee;if(a&&a.readyState===WebSocket.OPEN){const i=`req_${++jo}_${Date.now()}`;return new Promise((u,l)=>{const p=setTimeout(()=>{Ct.delete(i),l(new Error(`WS command timeout: ${s}`))},3e4);Ct.set(i,{resolve:d=>{clearTimeout(p),u(d)},reject:d=>{clearTimeout(p),l(d)}}),a.send(JSON.stringify({type:"command",requestId:i,data:{type:s,payload:r.payload}}))})}const c=await fetch("/api/v1/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:s,payload:r.payload})});if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}class wo{constructor(s){ue(this,"daemonId");ue(this,"screenshotIdeType",null);this.daemonId=s}get hasCommandChannel(){return(Ee==null?void 0:Ee.readyState)===WebSocket.OPEN}get connectionState(){return(Ee==null?void 0:Ee.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(s,n){return vt(this.daemonId,s,n)}async sendInput(s,n){return vt(this.daemonId,"cdp_remote_action",{action:s,params:n,...this.screenshotIdeType&&{targetSessionId:this.screenshotIdeType}})}startScreenshots(s){this.screenshotIdeType=s||null,Be&&(clearInterval(Be),Be=null);const n=async()=>{if(this.hasCommandChannel)try{const r=await vt(this.daemonId,"screenshot",{width:1280,...this.screenshotIdeType&&{targetSessionId:this.screenshotIdeType}});if(r!=null&&r.success&&(r!=null&&r.base64)){const a=await fetch(`data:image/jpeg;base64,${r.base64}`).then(c=>c.blob());$e.emitScreenshot(this.daemonId,a)}}catch{}};n(),Be=setInterval(n,2e3)}stopScreenshots(s){Be&&(clearInterval(Be),Be=null)}}let Ne=null;function No(t){return(!Ne||Ne.daemonId!==t)&&(Ne=new wo(t)),Ne}function ko({children:t}){const s=o.useRef(Xt()),n=Xt();s.current=n;const{setUserName:r}=ot(),a=o.useRef(r);a.current=r;const[,c]=o.useState("disconnected"),i=o.useCallback((f,g)=>{c(f),at==null||at(f,g)},[]),u=o.useRef(null),l=o.useRef(),p=o.useRef(ps),d=o.useRef(!0),m=o.useRef(!1);return o.useEffect(()=>{d.current=!0,m.current=!1;function f(){var k,I;if(!d.current||((k=u.current)==null?void 0:k.readyState)===WebSocket.OPEN||((I=u.current)==null?void 0:I.readyState)===WebSocket.CONNECTING)return;i("connecting"),console.log(`[Standalone WS] Connecting to ${xs}...`);let y;try{y=new WebSocket(xs)}catch(h){console.error("[Standalone WS] Failed to create WebSocket:",h),g();return}u.current=y,y.onopen=()=>{if(!d.current){y.close();return}i("connected"),p.current=ps,console.log("[Standalone WS] Connected")},Ee=y,y.onmessage=h=>{var b;try{const N=JSON.parse(h.data);if((N.type==="command_result"||N.type==="error")&&N.requestId){const T=Ct.get(N.requestId);T&&(Ct.delete(N.requestId),N.type==="error"?T.reject(new Error(((b=N.data)==null?void 0:b.message)||"Command failed")):T.resolve(N.data));return}if(N.type==="pty_output"){$e.emitPtyOutput(N.cliId,N.data);return}if(N.type==="status"||N.type==="initial_state"){const T=N.data;if(!T)return;const{injectEntries:x,markLoaded:j}=s.current,v=T.id||"standalone",w=No(v);$e.register(v,w),$e.setState(v,"connected"),i("connected",v),$e.emitStatus(v,T);const R=Ir(T,{daemonId:v});R.length>0&&x(R),j(),T.userName&&a.current&&a.current(T.userName)}}catch(N){console.error("[Standalone WS] Parse error:",N)}},y.onclose=()=>{d.current&&(Ne==null||Ne.stopScreenshots(),Ne&&$e.setState(Ne.daemonId,"disconnected"),i("disconnected"),u.current=null,g())},y.onerror=h=>{m.current||!d.current||console.warn("[Standalone WS] Error, will reconnect:",h)}}function g(){if(!d.current)return;clearTimeout(l.current);const y=p.current;console.log(`[Standalone WS] Reconnecting in ${y}ms...`),l.current=setTimeout(()=>{p.current=Math.min(p.current*1.5,yo),f()},y)}return f(),()=>{d.current=!1,m.current=!0,clearTimeout(l.current),u.current&&(u.current.onerror=null,u.current.onclose=null,u.current.close(),u.current=null,Ee=null),Ne&&(Ne.stopScreenshots(),$e.unregister(Ne.daemonId))}},[]),e.jsx(e.Fragment,{children:t})}function So({children:t}){const[s,n]=o.useState("disconnected"),[r,a]=o.useState(null);o.useEffect(()=>(at=(i,u)=>{n(i),u&&a(u)},()=>{at=null}),[]);const c=o.useMemo(()=>{const i=s==="connected",u=vo(s),l={};return r&&(l[r]=u),l.standalone=u,{wsStatus:s,isConnected:i,connectionStates:l}},[s,r]);return e.jsx(In,{connectionOverrides:c,children:e.jsx(ko,{children:t})})}const Co=[{id:"dashboard",path:"/dashboard",icon:e.jsx(ks,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:e.jsx(Ss,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:e.jsx(Ht,{}),label:"Settings"}];function Io({children:t}){const s=it(),n=jn(),[r,a]=o.useState(!1),[c,i]=o.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="1"}catch{return!1}}),u=d=>{s(d),a(!1)},l=()=>{i(d=>{const m=!d;try{localStorage.setItem("sidebar-collapsed",m?"1":"0")}catch{}return m})},p=d=>`nav-item${n.pathname.startsWith(d)?" active":""} cursor-pointer ${c?"justify-center py-2.5 px-0":""}`;return e.jsxs("div",{className:`app-layout${r?" mobile-menu-open":""}${c?" sidebar-collapsed":""}`,children:[e.jsxs("button",{type:"button",className:"mobile-menu-btn","aria-label":"Open menu",onClick:()=>a(!0),children:[e.jsx("span",{className:"mobile-menu-icon"}),e.jsx("span",{className:"mobile-menu-icon"}),e.jsx("span",{className:"mobile-menu-icon"})]}),r&&e.jsx("div",{className:"sidebar-overlay",role:"button",tabIndex:0,"aria-label":"Close menu",onClick:()=>a(!1),onKeyDown:d=>d.key==="Escape"&&a(!1)}),e.jsxs("aside",{className:`sidebar ${r?"sidebar-open":""}`,children:[e.jsxs("div",{className:"sidebar-header",children:[e.jsxs("div",{className:`sidebar-logo ${c?"justify-center gap-0":""}`,children:[e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-7 h-7"}),!c&&e.jsx("span",{children:"ADHDev"})]}),e.jsx("button",{type:"button",className:"sidebar-close-btn","aria-label":"Close menu",onClick:()=>a(!1),children:"✕"})]}),e.jsx("nav",{className:"sidebar-nav",children:Co.map(d=>e.jsxs("div",{className:p(d.path),id:`nav-${d.id}`,onClick:()=>u(d.path),title:c?d.label:void 0,children:[e.jsx("span",{className:"nav-icon",children:d.icon}),!c&&d.label]},d.id))}),e.jsxs("div",{className:"border-t border-border-subtle pt-4 mt-2",children:[e.jsxs("div",{className:`nav-item cursor-pointer ${c?"justify-center py-2.5 px-0":""}`,id:"nav-docs",onClick:()=>window.open("https://docs.adhf.dev","_blank"),title:c?"Docs":void 0,children:[e.jsx("span",{className:"nav-icon",children:e.jsx(wt,{})}),!c&&e.jsxs(e.Fragment,{children:["Docs",e.jsx("span",{className:"ml-auto text-[9px] text-text-muted",children:"↗"})]})]}),e.jsxs("div",{className:`nav-item cursor-pointer${n.pathname==="/about"?" active":""} ${c?"justify-center py-2.5 px-0":""}`,id:"nav-about",onClick:()=>s("/about"),title:c?"About":void 0,children:[e.jsx("span",{className:"nav-icon",children:e.jsx(Cs,{})}),!c&&"About"]}),!c&&e.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.7.7"]}),e.jsxs("div",{className:`nav-item cursor-pointer ${c?"justify-center py-2.5 px-0":"mt-1"}`,onClick:l,title:c?"Expand sidebar":"Collapse sidebar",children:[e.jsx("span",{className:"nav-icon text-base",children:c?"›":"‹"}),!c&&e.jsx("span",{className:"text-xs",children:"Collapse"})]})]})]}),e.jsx("main",{className:"main-content relative",children:e.jsx("div",{className:"main-content-inner",children:t})})]})}const Mo=[{icon:e.jsx(Ss,{size:16}),title:"Local-first runtime",desc:"Everything stays on your machine and the browser only connects over localhost."},{icon:e.jsx(Ye,{size:16}),title:"Agent chat relay",desc:"Read and respond to AI conversations in real time across connected IDEs."},{icon:e.jsx(Es,{size:16}),title:"Live screenshots",desc:"View your IDE directly in the browser through the local screenshot stream."},{icon:e.jsx(Le,{size:16}),title:"Remote control",desc:"Click, type, and steer your IDE sessions without switching windows."},{icon:e.jsx(qe,{size:16}),title:"Multi-IDE support",desc:"Monitor VS Code, Cursor, Windsurf, and extension-based agents in one place."},{icon:e.jsx(wt,{size:16}),title:"CLI and ACP coverage",desc:"Track standalone CLI agents and ACP-backed workflows alongside IDE sessions."}],To=[{icon:e.jsx(Ls,{size:16}),title:"Access from anywhere",desc:"Reach your burrows from another laptop or phone without opening local ports."},{icon:e.jsx(ks,{size:16}),title:"Low-latency P2P stream",desc:"Cloud adds the WebRTC path for faster screenshots and remote control."},{icon:e.jsx(_s,{size:16}),title:"Mobile notifications",desc:"Get approval prompts and activity updates when you are away from your desk."},{icon:e.jsx($n,{size:16}),title:"REST API access",desc:"Integrate with Slack, CI, or internal tools using API keys and service routes."},{icon:e.jsx(Rn,{size:16}),title:"Team workspace",desc:"Share burrows, activity views, and policies across a team workspace."},{icon:e.jsx(Is,{size:16}),title:"Enterprise controls",desc:"SSO, RBAC, audit logs, and managed policy features for production teams."}],Eo=[{feature:"Agent chat relay",selfhost:!0,cloud:!0},{feature:"Live IDE screenshots",selfhost:!0,cloud:!0},{feature:"Remote IDE control",selfhost:!0,cloud:!0},{feature:"Multi-IDE monitoring",selfhost:!0,cloud:!0},{feature:"Extension and CLI agents",selfhost:!0,cloud:!0},{feature:"Access from any network",selfhost:!1,cloud:!0},{feature:"WebRTC P2P streaming",selfhost:!1,cloud:!0},{feature:"Mobile push notifications",selfhost:!1,cloud:!0},{feature:"REST API and webhooks",selfhost:!1,cloud:!0},{feature:"Team collaboration",selfhost:!1,cloud:!0},{feature:"Multi-machine burrows",selfhost:!1,cloud:!0},{feature:"SSO, RBAC, audit logs",selfhost:!1,cloud:!0}];function Ao(){return e.jsxs(Nt,{icon:e.jsx(Cs,{className:"text-text-primary"}),title:"About",subtitle:"Self-hosted ADHDev overview, supported surfaces, and what changes in Cloud",widthClassName:"max-w-5xl",actions:e.jsxs("div",{className:"px-3 py-1 text-[11px] font-semibold tracking-wide rounded-full bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:["SELFHOST v","0.7.7"]}),children:[e.jsx(me,{children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("div",{className:"text-[11px] font-semibold tracking-[0.18em] uppercase text-emerald-400 mb-2",children:"Self-hosted edition"}),e.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-text-primary mb-2",children:"Keep the same dashboard experience, with the runtime fully on-device."}),e.jsx("p",{className:"text-sm text-text-muted leading-relaxed",children:"Standalone keeps the browser, daemon, screenshots, and control path on your own machine. It is the same core product shape as cloud, just without the remote networking and team layers."})]}),e.jsxs("div",{className:"grid gap-2 min-w-[220px]",children:[e.jsx("a",{href:"https://docs.adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex justify-center no-underline",children:"Docs ↗"}),e.jsx("a",{href:"https://github.com/vilmire/adhdev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex justify-center no-underline",children:"GitHub ↗"}),e.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm inline-flex justify-center no-underline",children:"Try Cloud ↗"})]})]})}),e.jsx(me,{title:"Included in standalone",description:"The local-first feature set available without the cloud control plane.",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Mo.map(t=>e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-4 transition-colors hover:border-border-default",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-text-primary mb-2",children:[e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-accent/10 text-accent-light",children:t.icon}),t.title]}),e.jsx("p",{className:"text-[13px] leading-relaxed text-text-muted",children:t.desc})]},t.title))})}),e.jsx(me,{title:"Compatible with",description:"Supported editors and agent surfaces exposed in the standalone dashboard.",children:e.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:[{label:"IDEs",items:Ys.map(t=>`${t.icon} ${t.name}`)},{label:"Extensions",items:Xs.map(t=>`${t.icon} ${t.name}`)},{label:"CLI agents",items:qs.map(t=>`${t.icon} ${t.name}`)}].map(t=>e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-4",children:[e.jsx("div",{className:"text-[10px] font-bold tracking-wider text-text-muted mb-3 uppercase",children:t.label}),e.jsx("div",{className:"flex flex-col gap-1.5",children:t.items.map(s=>e.jsx("div",{className:"rounded-md border border-border-subtle bg-bg-card px-2.5 py-1.5 text-[12px] text-text-secondary",children:s},s))})]},t.label))})}),e.jsx(me,{title:"Cloud-only extras",description:"Capabilities that need the hosted control plane or team infrastructure.",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:To.map(t=>e.jsxs("div",{className:"rounded-xl border border-violet-500/20 bg-violet-500/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-text-primary mb-2",children:[e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-violet-500/10 text-violet-400",children:t.icon}),t.title]}),e.jsx("p",{className:"text-[13px] leading-relaxed text-text-muted",children:t.desc})]},t.title))})}),e.jsx(me,{title:"Self-hosted vs Cloud",description:"The product split at a glance.",children:e.jsx("div",{className:"overflow-x-auto rounded-xl border border-border-subtle",children:e.jsxs("table",{className:"w-full text-[13px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-bg-secondary",children:[e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-text-muted text-[11px] uppercase tracking-wider",children:"Feature"}),e.jsx("th",{className:"text-center px-4 py-3 font-semibold text-text-muted text-[11px] uppercase tracking-wider w-[110px]",children:"Selfhost"}),e.jsx("th",{className:"text-center px-4 py-3 font-semibold text-violet-400 text-[11px] uppercase tracking-wider w-[110px]",children:"Cloud"})]})}),e.jsx("tbody",{children:Eo.map((t,s)=>e.jsxs("tr",{className:s%2===0?"bg-bg-glass":"bg-transparent",children:[e.jsx("td",{className:"px-4 py-2.5 text-text-secondary",children:t.feature}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:t.selfhost?e.jsx("span",{className:"text-emerald-500",children:"✓"}):e.jsx("span",{className:"text-text-muted opacity-40",children:"—"})}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:e.jsx("span",{className:"text-emerald-500",children:"✓"})})]},t.feature))})]})})}),e.jsx(Vt,{icon:e.jsx("img",{src:"/otter-logo.png",alt:"",className:"mx-auto h-12 w-12 opacity-80"}),title:"Cloud is optional, not required",description:"You can stay fully local in standalone, and move to cloud later without changing how you use the dashboard.",action:e.jsxs("div",{className:"flex flex-wrap justify-center gap-3",children:[e.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm no-underline",children:"Compare Cloud ↗"}),e.jsxs("a",{href:"https://discord.gg/WJD3tCfBzk",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm no-underline",children:[e.jsx(Un,{size:14,className:"mr-1"}),"Discord ↗"]})]})})]})}function Lo(){const{ides:t}=ot(),s=t.find(m=>m.type==="adhdev-daemon"),n=(s==null?void 0:s.detectedIdes)||[],{sendCommand:r}=Pe(),{userName:a}=ot(),[c,i]=o.useState(a||"");o.useEffect(()=>{a!==void 0&&i(a)},[a]);const u=m=>{const f=m.target.value.trim();s!=null&&s.id&&f!==a&&r(s.id,"set_user_name",{userName:f}).catch(console.error)},[l,p]=o.useState(()=>{try{return localStorage.getItem("adhdev_sound")!=="0"}catch{return!0}}),d=m=>{p(m);try{localStorage.setItem("adhdev_sound",m?"1":"0")}catch{}};return e.jsxs(Nt,{icon:e.jsx(Ht,{className:"text-text-primary"}),title:"Settings",subtitle:"Local daemon configuration, appearance, and on-device preferences",widthClassName:"max-w-5xl",children:[e.jsx(Hr,{variant:"info",children:"Standalone settings stay on this machine. The browser only talks to your local daemon over localhost."}),e.jsx(me,{title:"Daemon",description:"Connection health and local endpoints for the self-hosted runtime.",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-x-4 gap-y-2.5 text-sm",children:[e.jsx("span",{className:"text-text-muted",children:"Version"}),e.jsxs("span",{className:"font-mono text-xs",children:["v","0.7.7"]}),e.jsx("span",{className:"text-text-muted",children:"Status"}),e.jsx("span",{className:s?"text-green-400":"text-yellow-400",children:s?"● Running":"○ Not connected"}),e.jsx("span",{className:"text-text-muted",children:"WebSocket"}),e.jsx("span",{className:"font-mono text-xs",children:"ws://localhost:19222"}),e.jsx("span",{className:"text-text-muted",children:"HTTP"}),e.jsx("span",{className:"font-mono text-xs",children:"http://localhost:19280"})]})}),e.jsx(me,{title:"Detected IDEs",description:"Editors discovered by the local daemon on this machine.",children:n.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:"No IDEs detected. Start an IDE to see it here."}):e.jsx("div",{className:"flex flex-col gap-1.5",children:n.map(m=>e.jsxs("div",{className:"flex justify-between items-center bg-bg-glass rounded-lg px-3.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${m.running?"bg-green-400":"bg-text-muted/30"}`}),e.jsx("span",{className:"text-sm font-medium",children:m.name})]}),e.jsx("span",{className:"text-[11px] text-text-muted font-mono",children:m.type})]},m.type))})}),e.jsx(me,{title:"Machine",description:"The local burrow exposed by your standalone daemon.",children:e.jsx(Jr,{ides:t,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),e.jsx(me,{title:"Appearance",description:"Match the rest of the dashboard with a single place for mode and theme.",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Mode"}),e.jsx(ta,{})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[e.jsx("div",{className:"text-xs text-text-muted mb-1 font-medium",children:"Theme"}),e.jsx("p",{className:"text-[11px] text-text-muted mb-3",children:"Choose a preset or create a custom surface, accent, and chat palette for the standalone UI."}),e.jsx(ia,{})]})]})}),e.jsx(me,{title:"Notifications",description:"Browser prompts and local sound cues for agent activity.",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Gr,{}),e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Hn,{size:15})," Sound Effects"]}),description:"Play a sound when agent completes or needs approval",checked:l,onChange:d})]})}),e.jsx(me,{title:"Profile",description:"How your name appears in local chat threads and dashboard views.",children:e.jsx("div",{className:"flex flex-col gap-3",children:e.jsxs("div",{className:"flex items-center justify-between px-3.5 py-4 bg-bg-glass rounded-xl border border-border-subtle hover:border-border-default transition-colors",children:[e.jsxs("div",{className:"flex flex-col gap-1 pr-4 max-w-[500px]",children:[e.jsxs("span",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(_n,{size:16,className:"text-text-secondary"})," Display Name"]}),e.jsx("span",{className:"text-[12px] text-text-muted leading-relaxed",children:"Your name shown in chat threads and on the team dashboard."})]}),e.jsx("input",{type:"text",className:"bg-bg-primary border border-border-strong rounded-lg px-3 py-1.5 text-sm w-48 text-right focus:border-accent focus:outline-none transition-colors",placeholder:"Anonymous",value:c,onChange:m=>i(m.target.value),onBlur:u,onKeyDown:m=>{m.key==="Enter"&&m.currentTarget.blur()}})]})})})]})}qr();aa();const Ro=vs({baseUrl:""});function hs(){const{ides:t}=ot(),s=t.find(n=>{var r;return n.daemonMode||((r=n.id)==null?void 0:r.startsWith("standalone"))});return s?e.jsx(gt,{to:`/machines/${s.id}`,replace:!0}):t.length>0?e.jsx(gt,{to:`/machines/${t[0].id}`,replace:!0}):e.jsx(gt,{to:"/dashboard",replace:!0})}function _o(){return e.jsx(vn,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:e.jsx(Tn,{client:Ro,children:e.jsx(So,{children:e.jsx(Ln,{value:{sendCommand:vt,sendData:()=>!1},children:e.jsx(Io,{children:e.jsxs(wn,{children:[e.jsx(Te,{path:"/dashboard",element:e.jsx(qa,{})}),e.jsx(Te,{path:"/ide/:id",element:e.jsx(so,{})}),e.jsx(Te,{path:"/machine",element:e.jsx(hs,{})}),e.jsx(Te,{path:"/machines/:id",element:e.jsx(mo,{})}),e.jsx(Te,{path:"/machines",element:e.jsx(hs,{})}),e.jsx(Te,{path:"/capabilities",element:e.jsx(fo,{})}),e.jsx(Te,{path:"/about",element:e.jsx(Ao,{})}),e.jsx(Te,{path:"/settings",element:e.jsx(Lo,{})}),e.jsx(Te,{path:"*",element:e.jsx(gt,{to:"/dashboard",replace:!0})})]})})})})})})}vr({connectionManager:$e});Nn(document.getElementById("root")).render(e.jsx(o.StrictMode,{children:e.jsx(_o,{})}));
68
+ `})]})}function fo(){const[t,s]=o.useState({ide:[],cli:[],ext:[],acp:[]}),[n,r]=o.useState(!0);o.useEffect(()=>{fetch("https://raw.githubusercontent.com/vilmire/adhdev-providers/main/registry.json").then(i=>i.json()).then(i=>{const u=[],l=[],p=[],d=[];Object.values(i.providers||{}).forEach(f=>{const g={name:f.name||"Unknown",status:f.status||"Stable",details:f.details||"Community Provider"};f.category==="ide"?u.push(g):f.category==="cli"?l.push(g):f.category==="extension"?p.push(g):f.category==="acp"&&d.push(g)});const m=(f,g)=>{const y={Stable:1,Beta:2,WIP:3},k=y[f.status]||99,I=y[g.status]||99;return k!==I?k-I:f.name.localeCompare(g.name)};s({ide:u.sort(m),cli:l.sort(m),ext:p.sort(m),acp:d.sort(m)})}).catch(i=>console.error("Failed to load capabilities:",i)).finally(()=>r(!1))},[]);const a=i=>i==="Stable"?e.jsxs("div",{className:"flex items-center gap-1.5 text-success",children:[e.jsx(Is,{className:"w-4 h-4"})," ",e.jsx("span",{children:"Stable"})]}):i==="Beta"?e.jsxs("div",{className:"flex items-center gap-1.5 text-warning",children:[e.jsx(Ut,{className:"w-4 h-4"})," ",e.jsx("span",{children:"Beta"})]}):e.jsxs("div",{className:"flex items-center gap-1.5 text-text-muted",children:[e.jsx(As,{className:"w-4 h-4"})," ",e.jsx("span",{children:i})]}),c=i=>e.jsx("div",{className:"bg-bg-card border border-border-subtle rounded-xl overflow-hidden",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-bg-secondary border-b border-border-subtle text-xs uppercase text-text-muted font-medium tracking-wider",children:[e.jsx("th",{className:"py-3 px-4 w-1/3",children:"Target"}),e.jsx("th",{className:"py-3 px-4 w-1/4",children:"Status"}),e.jsx("th",{className:"py-3 px-4",children:"Details"})]})}),e.jsx("tbody",{className:"divide-y divide-border-subtle text-sm",children:i.map((u,l)=>e.jsxs("tr",{className:"hover:bg-bg-subtle/50 transition-colors",children:[e.jsx("td",{className:"py-3 px-4 font-medium text-text-main",children:u.name}),e.jsx("td",{className:"py-3 px-4",children:a(u.status)}),e.jsx("td",{className:"py-3 px-4 text-text-muted",children:u.details})]},l))})]})});return n?e.jsx(Nt,{title:"Capabilities",subtitle:"Provider registry coverage for IDEs, CLI agents, extensions, and ACPs",icon:e.jsx(wt,{}),widthClassName:"max-w-5xl",children:e.jsx(Vt,{icon:e.jsx("div",{className:"w-8 h-8 border-4 border-accent border-t-transparent rounded-full animate-spin mx-auto"}),title:"Loading provider registry",description:"Fetching the latest support matrix from the shared provider registry."})}):e.jsxs(Nt,{title:"Capabilities",subtitle:"Provider registry coverage for IDEs, CLI agents, extensions, and ACPs",icon:e.jsx(wt,{}),widthClassName:"max-w-5xl",contentClassName:"animate-fade-in",children:[e.jsx(me,{title:"Registry overview",description:"Support status is loaded from the shared provider registry used across OSS and cloud surfaces.",children:e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"IDEs"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.ide.length})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"CLI"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.cli.length})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"Extensions"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.ext.length})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-muted mb-1",children:"ACP"}),e.jsx("div",{className:"text-2xl font-semibold text-text-primary",children:t.acp.length})]})]})}),e.jsx(me,{title:"IDE support",icon:e.jsx(Le,{className:"w-4 h-4"}),description:"Desktop editors and IDE surfaces with registry-backed providers.",children:c(t.ide)}),e.jsx(me,{title:"Standalone CLI agents",icon:e.jsx(Ft,{className:"w-4 h-4"}),description:"CLI-first agents that can participate in the standalone dashboard.",children:c(t.cli)}),e.jsx(me,{title:"AI extensions",icon:e.jsx(qe,{className:"w-4 h-4"}),description:"IDE extensions and companion integrations available in the registry.",children:c(t.ext)}),e.jsx(me,{title:`ACP agents (${t.acp.length} loaded)`,icon:e.jsx(qe,{className:"w-4 h-4"}),description:"ACP-backed providers discovered through the same shared registry.",children:c(t.acp)})]})}class go{constructor(){ue(this,"adapters",new Map);ue(this,"states",new Map);ue(this,"ptyCallbacks",new Set);ue(this,"screenshotCallbacks",new Map);ue(this,"statusCallbacks",new Set)}resolveDaemonId(s){if(this.adapters.has(s))return s;if(s.startsWith("standalone")){for(const n of this.adapters.keys())if(n.startsWith("standalone"))return n}return null}register(s,n){this.adapters.set(s,n),this.states.set(s,n.connectionState)}unregister(s){this.adapters.delete(s),this.states.delete(s)}setState(s,n){this.states.set(s,n)}retryConnection(s){}get(s){const n=this.resolveDaemonId(s);return n?this.adapters.get(n):void 0}getState(s){const n=this.resolveDaemonId(s);return n&&this.states.get(n)||"disconnected"}sendData(s,n){return!1}sendPtyInput(s,n,r){return!1}sendPtyResize(s,n,r,a){return!1}onScreenshot(s,n){return this.screenshotCallbacks.set(s,n),()=>{this.screenshotCallbacks.delete(s)}}emitScreenshot(s,n){this.screenshotCallbacks.forEach(r=>r(s,n))}onStatus(s){return this.statusCallbacks.add(s),()=>{this.statusCallbacks.delete(s)}}emitStatus(s,n){this.statusCallbacks.forEach(r=>r(s,n))}onPtyOutput(s){return this.ptyCallbacks.add(s),()=>{this.ptyCallbacks.delete(s)}}emitPtyOutput(s,n){this.ptyCallbacks.forEach(r=>r(s,n))}}const $e=new go;function bo(){if(typeof window>"u")return"ws://localhost:3847/ws";const s=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,r=new URLSearchParams(window.location.search).get("token");return r?`${s}?token=${encodeURIComponent(r)}`:s}const xs=bo(),ps=3e3,yo=3e4;let Ee=null,jo=0;const Ct=new Map;let Be=null,at=null;function vo(t){return t==="connected"?"connected":t}async function vt(t,s,n){const r=Mr(t,n||{}),a=Ee;if(a&&a.readyState===WebSocket.OPEN){const i=`req_${++jo}_${Date.now()}`;return new Promise((u,l)=>{const p=setTimeout(()=>{Ct.delete(i),l(new Error(`WS command timeout: ${s}`))},3e4);Ct.set(i,{resolve:d=>{clearTimeout(p),u(d)},reject:d=>{clearTimeout(p),l(d)}}),a.send(JSON.stringify({type:"command",requestId:i,data:{type:s,payload:r.payload}}))})}const c=await fetch("/api/v1/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:s,payload:r.payload})});if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}class wo{constructor(s){ue(this,"daemonId");ue(this,"screenshotIdeType",null);this.daemonId=s}get hasCommandChannel(){return(Ee==null?void 0:Ee.readyState)===WebSocket.OPEN}get connectionState(){return(Ee==null?void 0:Ee.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(s,n){return vt(this.daemonId,s,n)}async sendInput(s,n){return vt(this.daemonId,"cdp_remote_action",{action:s,params:n,...this.screenshotIdeType&&{targetSessionId:this.screenshotIdeType}})}startScreenshots(s){this.screenshotIdeType=s||null,Be&&(clearInterval(Be),Be=null);const n=async()=>{if(this.hasCommandChannel)try{const r=await vt(this.daemonId,"screenshot",{width:1280,...this.screenshotIdeType&&{targetSessionId:this.screenshotIdeType}});if(r!=null&&r.success&&(r!=null&&r.base64)){const a=await fetch(`data:image/jpeg;base64,${r.base64}`).then(c=>c.blob());$e.emitScreenshot(this.daemonId,a)}}catch{}};n(),Be=setInterval(n,2e3)}stopScreenshots(s){Be&&(clearInterval(Be),Be=null)}}let Ne=null;function No(t){return(!Ne||Ne.daemonId!==t)&&(Ne=new wo(t)),Ne}function ko({children:t}){const s=o.useRef(Xt()),n=Xt();s.current=n;const{setUserName:r}=ot(),a=o.useRef(r);a.current=r;const[,c]=o.useState("disconnected"),i=o.useCallback((f,g)=>{c(f),at==null||at(f,g)},[]),u=o.useRef(null),l=o.useRef(),p=o.useRef(ps),d=o.useRef(!0),m=o.useRef(!1);return o.useEffect(()=>{d.current=!0,m.current=!1;function f(){var k,I;if(!d.current||((k=u.current)==null?void 0:k.readyState)===WebSocket.OPEN||((I=u.current)==null?void 0:I.readyState)===WebSocket.CONNECTING)return;i("connecting"),console.log(`[Standalone WS] Connecting to ${xs}...`);let y;try{y=new WebSocket(xs)}catch(h){console.error("[Standalone WS] Failed to create WebSocket:",h),g();return}u.current=y,y.onopen=()=>{if(!d.current){y.close();return}i("connected"),p.current=ps,console.log("[Standalone WS] Connected")},Ee=y,y.onmessage=h=>{var b;try{const N=JSON.parse(h.data);if((N.type==="command_result"||N.type==="error")&&N.requestId){const T=Ct.get(N.requestId);T&&(Ct.delete(N.requestId),N.type==="error"?T.reject(new Error(((b=N.data)==null?void 0:b.message)||"Command failed")):T.resolve(N.data));return}if(N.type==="pty_output"){$e.emitPtyOutput(N.cliId,N.data);return}if(N.type==="status"||N.type==="initial_state"){const T=N.data;if(!T)return;const{injectEntries:x,markLoaded:j}=s.current,v=T.id||"standalone",w=No(v);$e.register(v,w),$e.setState(v,"connected"),i("connected",v),$e.emitStatus(v,T);const R=Ir(T,{daemonId:v});R.length>0&&x(R),j(),T.userName&&a.current&&a.current(T.userName)}}catch(N){console.error("[Standalone WS] Parse error:",N)}},y.onclose=()=>{d.current&&(Ne==null||Ne.stopScreenshots(),Ne&&$e.setState(Ne.daemonId,"disconnected"),i("disconnected"),u.current=null,g())},y.onerror=h=>{m.current||!d.current||console.warn("[Standalone WS] Error, will reconnect:",h)}}function g(){if(!d.current)return;clearTimeout(l.current);const y=p.current;console.log(`[Standalone WS] Reconnecting in ${y}ms...`),l.current=setTimeout(()=>{p.current=Math.min(p.current*1.5,yo),f()},y)}return f(),()=>{d.current=!1,m.current=!0,clearTimeout(l.current),u.current&&(u.current.onerror=null,u.current.onclose=null,u.current.close(),u.current=null,Ee=null),Ne&&(Ne.stopScreenshots(),$e.unregister(Ne.daemonId))}},[]),e.jsx(e.Fragment,{children:t})}function So({children:t}){const[s,n]=o.useState("disconnected"),[r,a]=o.useState(null);o.useEffect(()=>(at=(i,u)=>{n(i),u&&a(u)},()=>{at=null}),[]);const c=o.useMemo(()=>{const i=s==="connected",u=vo(s),l={};return r&&(l[r]=u),l.standalone=u,{wsStatus:s,isConnected:i,connectionStates:l}},[s,r]);return e.jsx(In,{connectionOverrides:c,children:e.jsx(ko,{children:t})})}const Co=[{id:"dashboard",path:"/dashboard",icon:e.jsx(ks,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:e.jsx(Ss,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:e.jsx(Ht,{}),label:"Settings"}];function Io({children:t}){const s=it(),n=jn(),[r,a]=o.useState(!1),[c,i]=o.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="1"}catch{return!1}}),u=d=>{s(d),a(!1)},l=()=>{i(d=>{const m=!d;try{localStorage.setItem("sidebar-collapsed",m?"1":"0")}catch{}return m})},p=d=>`nav-item${n.pathname.startsWith(d)?" active":""} cursor-pointer ${c?"justify-center py-2.5 px-0":""}`;return e.jsxs("div",{className:`app-layout${r?" mobile-menu-open":""}${c?" sidebar-collapsed":""}`,children:[e.jsxs("button",{type:"button",className:"mobile-menu-btn","aria-label":"Open menu",onClick:()=>a(!0),children:[e.jsx("span",{className:"mobile-menu-icon"}),e.jsx("span",{className:"mobile-menu-icon"}),e.jsx("span",{className:"mobile-menu-icon"})]}),r&&e.jsx("div",{className:"sidebar-overlay",role:"button",tabIndex:0,"aria-label":"Close menu",onClick:()=>a(!1),onKeyDown:d=>d.key==="Escape"&&a(!1)}),e.jsxs("aside",{className:`sidebar ${r?"sidebar-open":""}`,children:[e.jsxs("div",{className:"sidebar-header",children:[e.jsxs("div",{className:`sidebar-logo ${c?"justify-center gap-0":""}`,children:[e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-7 h-7"}),!c&&e.jsx("span",{children:"ADHDev"})]}),e.jsx("button",{type:"button",className:"sidebar-close-btn","aria-label":"Close menu",onClick:()=>a(!1),children:"✕"})]}),e.jsx("nav",{className:"sidebar-nav",children:Co.map(d=>e.jsxs("div",{className:p(d.path),id:`nav-${d.id}`,onClick:()=>u(d.path),title:c?d.label:void 0,children:[e.jsx("span",{className:"nav-icon",children:d.icon}),!c&&d.label]},d.id))}),e.jsxs("div",{className:"border-t border-border-subtle pt-4 mt-2",children:[e.jsxs("div",{className:`nav-item cursor-pointer ${c?"justify-center py-2.5 px-0":""}`,id:"nav-docs",onClick:()=>window.open("https://docs.adhf.dev","_blank"),title:c?"Docs":void 0,children:[e.jsx("span",{className:"nav-icon",children:e.jsx(wt,{})}),!c&&e.jsxs(e.Fragment,{children:["Docs",e.jsx("span",{className:"ml-auto text-[9px] text-text-muted",children:"↗"})]})]}),e.jsxs("div",{className:`nav-item cursor-pointer${n.pathname==="/about"?" active":""} ${c?"justify-center py-2.5 px-0":""}`,id:"nav-about",onClick:()=>s("/about"),title:c?"About":void 0,children:[e.jsx("span",{className:"nav-icon",children:e.jsx(Cs,{})}),!c&&"About"]}),!c&&e.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.7.9"]}),e.jsxs("div",{className:`nav-item cursor-pointer ${c?"justify-center py-2.5 px-0":"mt-1"}`,onClick:l,title:c?"Expand sidebar":"Collapse sidebar",children:[e.jsx("span",{className:"nav-icon text-base",children:c?"›":"‹"}),!c&&e.jsx("span",{className:"text-xs",children:"Collapse"})]})]})]}),e.jsx("main",{className:"main-content relative",children:e.jsx("div",{className:"main-content-inner",children:t})})]})}const Mo=[{icon:e.jsx(Ss,{size:16}),title:"Local-first runtime",desc:"Everything stays on your machine and the browser only connects over localhost."},{icon:e.jsx(Ye,{size:16}),title:"Agent chat relay",desc:"Read and respond to AI conversations in real time across connected IDEs."},{icon:e.jsx(Es,{size:16}),title:"Live screenshots",desc:"View your IDE directly in the browser through the local screenshot stream."},{icon:e.jsx(Le,{size:16}),title:"Remote control",desc:"Click, type, and steer your IDE sessions without switching windows."},{icon:e.jsx(qe,{size:16}),title:"Multi-IDE support",desc:"Monitor VS Code, Cursor, Windsurf, and extension-based agents in one place."},{icon:e.jsx(wt,{size:16}),title:"CLI and ACP coverage",desc:"Track standalone CLI agents and ACP-backed workflows alongside IDE sessions."}],To=[{icon:e.jsx(Ls,{size:16}),title:"Access from anywhere",desc:"Reach your burrows from another laptop or phone without opening local ports."},{icon:e.jsx(ks,{size:16}),title:"Low-latency P2P stream",desc:"Cloud adds the WebRTC path for faster screenshots and remote control."},{icon:e.jsx(_s,{size:16}),title:"Mobile notifications",desc:"Get approval prompts and activity updates when you are away from your desk."},{icon:e.jsx($n,{size:16}),title:"REST API access",desc:"Integrate with Slack, CI, or internal tools using API keys and service routes."},{icon:e.jsx(Rn,{size:16}),title:"Team workspace",desc:"Share burrows, activity views, and policies across a team workspace."},{icon:e.jsx(Is,{size:16}),title:"Enterprise controls",desc:"SSO, RBAC, audit logs, and managed policy features for production teams."}],Eo=[{feature:"Agent chat relay",selfhost:!0,cloud:!0},{feature:"Live IDE screenshots",selfhost:!0,cloud:!0},{feature:"Remote IDE control",selfhost:!0,cloud:!0},{feature:"Multi-IDE monitoring",selfhost:!0,cloud:!0},{feature:"Extension and CLI agents",selfhost:!0,cloud:!0},{feature:"Access from any network",selfhost:!1,cloud:!0},{feature:"WebRTC P2P streaming",selfhost:!1,cloud:!0},{feature:"Mobile push notifications",selfhost:!1,cloud:!0},{feature:"REST API and webhooks",selfhost:!1,cloud:!0},{feature:"Team collaboration",selfhost:!1,cloud:!0},{feature:"Multi-machine burrows",selfhost:!1,cloud:!0},{feature:"SSO, RBAC, audit logs",selfhost:!1,cloud:!0}];function Ao(){return e.jsxs(Nt,{icon:e.jsx(Cs,{className:"text-text-primary"}),title:"About",subtitle:"Self-hosted ADHDev overview, supported surfaces, and what changes in Cloud",widthClassName:"max-w-5xl",actions:e.jsxs("div",{className:"px-3 py-1 text-[11px] font-semibold tracking-wide rounded-full bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:["SELFHOST v","0.7.9"]}),children:[e.jsx(me,{children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("div",{className:"text-[11px] font-semibold tracking-[0.18em] uppercase text-emerald-400 mb-2",children:"Self-hosted edition"}),e.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-text-primary mb-2",children:"Keep the same dashboard experience, with the runtime fully on-device."}),e.jsx("p",{className:"text-sm text-text-muted leading-relaxed",children:"Standalone keeps the browser, daemon, screenshots, and control path on your own machine. It is the same core product shape as cloud, just without the remote networking and team layers."})]}),e.jsxs("div",{className:"grid gap-2 min-w-[220px]",children:[e.jsx("a",{href:"https://docs.adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex justify-center no-underline",children:"Docs ↗"}),e.jsx("a",{href:"https://github.com/vilmire/adhdev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex justify-center no-underline",children:"GitHub ↗"}),e.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm inline-flex justify-center no-underline",children:"Try Cloud ↗"})]})]})}),e.jsx(me,{title:"Included in standalone",description:"The local-first feature set available without the cloud control plane.",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Mo.map(t=>e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-4 transition-colors hover:border-border-default",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-text-primary mb-2",children:[e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-accent/10 text-accent-light",children:t.icon}),t.title]}),e.jsx("p",{className:"text-[13px] leading-relaxed text-text-muted",children:t.desc})]},t.title))})}),e.jsx(me,{title:"Compatible with",description:"Supported editors and agent surfaces exposed in the standalone dashboard.",children:e.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:[{label:"IDEs",items:Ys.map(t=>`${t.icon} ${t.name}`)},{label:"Extensions",items:Xs.map(t=>`${t.icon} ${t.name}`)},{label:"CLI agents",items:qs.map(t=>`${t.icon} ${t.name}`)}].map(t=>e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-bg-glass px-4 py-4",children:[e.jsx("div",{className:"text-[10px] font-bold tracking-wider text-text-muted mb-3 uppercase",children:t.label}),e.jsx("div",{className:"flex flex-col gap-1.5",children:t.items.map(s=>e.jsx("div",{className:"rounded-md border border-border-subtle bg-bg-card px-2.5 py-1.5 text-[12px] text-text-secondary",children:s},s))})]},t.label))})}),e.jsx(me,{title:"Cloud-only extras",description:"Capabilities that need the hosted control plane or team infrastructure.",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:To.map(t=>e.jsxs("div",{className:"rounded-xl border border-violet-500/20 bg-violet-500/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-text-primary mb-2",children:[e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-violet-500/10 text-violet-400",children:t.icon}),t.title]}),e.jsx("p",{className:"text-[13px] leading-relaxed text-text-muted",children:t.desc})]},t.title))})}),e.jsx(me,{title:"Self-hosted vs Cloud",description:"The product split at a glance.",children:e.jsx("div",{className:"overflow-x-auto rounded-xl border border-border-subtle",children:e.jsxs("table",{className:"w-full text-[13px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-bg-secondary",children:[e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-text-muted text-[11px] uppercase tracking-wider",children:"Feature"}),e.jsx("th",{className:"text-center px-4 py-3 font-semibold text-text-muted text-[11px] uppercase tracking-wider w-[110px]",children:"Selfhost"}),e.jsx("th",{className:"text-center px-4 py-3 font-semibold text-violet-400 text-[11px] uppercase tracking-wider w-[110px]",children:"Cloud"})]})}),e.jsx("tbody",{children:Eo.map((t,s)=>e.jsxs("tr",{className:s%2===0?"bg-bg-glass":"bg-transparent",children:[e.jsx("td",{className:"px-4 py-2.5 text-text-secondary",children:t.feature}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:t.selfhost?e.jsx("span",{className:"text-emerald-500",children:"✓"}):e.jsx("span",{className:"text-text-muted opacity-40",children:"—"})}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:e.jsx("span",{className:"text-emerald-500",children:"✓"})})]},t.feature))})]})})}),e.jsx(Vt,{icon:e.jsx("img",{src:"/otter-logo.png",alt:"",className:"mx-auto h-12 w-12 opacity-80"}),title:"Cloud is optional, not required",description:"You can stay fully local in standalone, and move to cloud later without changing how you use the dashboard.",action:e.jsxs("div",{className:"flex flex-wrap justify-center gap-3",children:[e.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm no-underline",children:"Compare Cloud ↗"}),e.jsxs("a",{href:"https://discord.gg/WJD3tCfBzk",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm no-underline",children:[e.jsx(Un,{size:14,className:"mr-1"}),"Discord ↗"]})]})})]})}function Lo(){const{ides:t}=ot(),s=t.find(m=>m.type==="adhdev-daemon"),n=(s==null?void 0:s.detectedIdes)||[],{sendCommand:r}=Pe(),{userName:a}=ot(),[c,i]=o.useState(a||"");o.useEffect(()=>{a!==void 0&&i(a)},[a]);const u=m=>{const f=m.target.value.trim();s!=null&&s.id&&f!==a&&r(s.id,"set_user_name",{userName:f}).catch(console.error)},[l,p]=o.useState(()=>{try{return localStorage.getItem("adhdev_sound")!=="0"}catch{return!0}}),d=m=>{p(m);try{localStorage.setItem("adhdev_sound",m?"1":"0")}catch{}};return e.jsxs(Nt,{icon:e.jsx(Ht,{className:"text-text-primary"}),title:"Settings",subtitle:"Local daemon configuration, appearance, and on-device preferences",widthClassName:"max-w-5xl",children:[e.jsx(Hr,{variant:"info",children:"Standalone settings stay on this machine. The browser only talks to your local daemon over localhost."}),e.jsx(me,{title:"Daemon",description:"Connection health and local endpoints for the self-hosted runtime.",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-x-4 gap-y-2.5 text-sm",children:[e.jsx("span",{className:"text-text-muted",children:"Version"}),e.jsxs("span",{className:"font-mono text-xs",children:["v","0.7.9"]}),e.jsx("span",{className:"text-text-muted",children:"Status"}),e.jsx("span",{className:s?"text-green-400":"text-yellow-400",children:s?"● Running":"○ Not connected"}),e.jsx("span",{className:"text-text-muted",children:"WebSocket"}),e.jsx("span",{className:"font-mono text-xs",children:"ws://localhost:19222"}),e.jsx("span",{className:"text-text-muted",children:"HTTP"}),e.jsx("span",{className:"font-mono text-xs",children:"http://localhost:19280"})]})}),e.jsx(me,{title:"Detected IDEs",description:"Editors discovered by the local daemon on this machine.",children:n.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:"No IDEs detected. Start an IDE to see it here."}):e.jsx("div",{className:"flex flex-col gap-1.5",children:n.map(m=>e.jsxs("div",{className:"flex justify-between items-center bg-bg-glass rounded-lg px-3.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${m.running?"bg-green-400":"bg-text-muted/30"}`}),e.jsx("span",{className:"text-sm font-medium",children:m.name})]}),e.jsx("span",{className:"text-[11px] text-text-muted font-mono",children:m.type})]},m.type))})}),e.jsx(me,{title:"Machine",description:"The local burrow exposed by your standalone daemon.",children:e.jsx(Jr,{ides:t,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),e.jsx(me,{title:"Appearance",description:"Match the rest of the dashboard with a single place for mode and theme.",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Mode"}),e.jsx(ta,{})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[e.jsx("div",{className:"text-xs text-text-muted mb-1 font-medium",children:"Theme"}),e.jsx("p",{className:"text-[11px] text-text-muted mb-3",children:"Choose a preset or create a custom surface, accent, and chat palette for the standalone UI."}),e.jsx(ia,{})]})]})}),e.jsx(me,{title:"Notifications",description:"Browser prompts and local sound cues for agent activity.",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Gr,{}),e.jsx(We,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Hn,{size:15})," Sound Effects"]}),description:"Play a sound when agent completes or needs approval",checked:l,onChange:d})]})}),e.jsx(me,{title:"Profile",description:"How your name appears in local chat threads and dashboard views.",children:e.jsx("div",{className:"flex flex-col gap-3",children:e.jsxs("div",{className:"flex items-center justify-between px-3.5 py-4 bg-bg-glass rounded-xl border border-border-subtle hover:border-border-default transition-colors",children:[e.jsxs("div",{className:"flex flex-col gap-1 pr-4 max-w-[500px]",children:[e.jsxs("span",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(_n,{size:16,className:"text-text-secondary"})," Display Name"]}),e.jsx("span",{className:"text-[12px] text-text-muted leading-relaxed",children:"Your name shown in chat threads and on the team dashboard."})]}),e.jsx("input",{type:"text",className:"bg-bg-primary border border-border-strong rounded-lg px-3 py-1.5 text-sm w-48 text-right focus:border-accent focus:outline-none transition-colors",placeholder:"Anonymous",value:c,onChange:m=>i(m.target.value),onBlur:u,onKeyDown:m=>{m.key==="Enter"&&m.currentTarget.blur()}})]})})})]})}qr();aa();const Ro=vs({baseUrl:""});function hs(){const{ides:t}=ot(),s=t.find(n=>{var r;return n.daemonMode||((r=n.id)==null?void 0:r.startsWith("standalone"))});return s?e.jsx(gt,{to:`/machines/${s.id}`,replace:!0}):t.length>0?e.jsx(gt,{to:`/machines/${t[0].id}`,replace:!0}):e.jsx(gt,{to:"/dashboard",replace:!0})}function _o(){return e.jsx(vn,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:e.jsx(Tn,{client:Ro,children:e.jsx(So,{children:e.jsx(Ln,{value:{sendCommand:vt,sendData:()=>!1},children:e.jsx(Io,{children:e.jsxs(wn,{children:[e.jsx(Te,{path:"/dashboard",element:e.jsx(qa,{})}),e.jsx(Te,{path:"/ide/:id",element:e.jsx(so,{})}),e.jsx(Te,{path:"/machine",element:e.jsx(hs,{})}),e.jsx(Te,{path:"/machines/:id",element:e.jsx(mo,{})}),e.jsx(Te,{path:"/machines",element:e.jsx(hs,{})}),e.jsx(Te,{path:"/capabilities",element:e.jsx(fo,{})}),e.jsx(Te,{path:"/about",element:e.jsx(Ao,{})}),e.jsx(Te,{path:"/settings",element:e.jsx(Lo,{})}),e.jsx(Te,{path:"*",element:e.jsx(gt,{to:"/dashboard",replace:!0})})]})})})})})})}vr({connectionManager:$e});Nn(document.getElementById("root")).render(e.jsx(o.StrictMode,{children:e.jsx(_o,{})}));
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-BNE24U2u.js"></script>
10
+ <script type="module" crossorigin src="/assets/index-ClygVU_6.js"></script>
11
11
  <link rel="modulepreload" crossorigin href="/assets/vendor-tc3018Wt.js">
12
12
  <link rel="modulepreload" crossorigin href="/assets/terminal-SgUt8Azj.js">
13
13
  <link rel="stylesheet" crossorigin href="/assets/index-Cc7KAykU.css">
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ import { EventEmitter } from 'events';
3
+ import { SessionHostEndpoint, SessionHostRegistry, SessionHostRequest, SessionHostResponse } from '@adhdev/session-host-core';
4
+
5
+ interface SessionHostServerOptions {
6
+ endpoint?: SessionHostEndpoint;
7
+ appName?: string;
8
+ }
9
+ declare class SessionHostServer extends EventEmitter {
10
+ readonly endpoint: SessionHostEndpoint;
11
+ readonly registry: SessionHostRegistry;
12
+ private runtimes;
13
+ private readonly storage;
14
+ private ipcServer;
15
+ private sockets;
16
+ private persistTimers;
17
+ constructor(options?: SessionHostServerOptions);
18
+ start(): Promise<void>;
19
+ stop(): Promise<void>;
20
+ handleRequest(request: SessionHostRequest): Promise<SessionHostResponse>;
21
+ private requireRuntime;
22
+ private getAttachedClient;
23
+ private emitEvent;
24
+ private handleIncomingRequest;
25
+ private schedulePersist;
26
+ private persistNow;
27
+ private flushAllPersistence;
28
+ private restorePersistedRuntimes;
29
+ private buildPayloadFromRecord;
30
+ private startRuntime;
31
+ }
32
+
33
+ export { SessionHostServer, type SessionHostServerOptions };
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ import { EventEmitter } from 'events';
3
+ import { SessionHostEndpoint, SessionHostRegistry, SessionHostRequest, SessionHostResponse } from '@adhdev/session-host-core';
4
+
5
+ interface SessionHostServerOptions {
6
+ endpoint?: SessionHostEndpoint;
7
+ appName?: string;
8
+ }
9
+ declare class SessionHostServer extends EventEmitter {
10
+ readonly endpoint: SessionHostEndpoint;
11
+ readonly registry: SessionHostRegistry;
12
+ private runtimes;
13
+ private readonly storage;
14
+ private ipcServer;
15
+ private sockets;
16
+ private persistTimers;
17
+ constructor(options?: SessionHostServerOptions);
18
+ start(): Promise<void>;
19
+ stop(): Promise<void>;
20
+ handleRequest(request: SessionHostRequest): Promise<SessionHostResponse>;
21
+ private requireRuntime;
22
+ private getAttachedClient;
23
+ private emitEvent;
24
+ private handleIncomingRequest;
25
+ private schedulePersist;
26
+ private persistNow;
27
+ private flushAllPersistence;
28
+ private restorePersistedRuntimes;
29
+ private buildPayloadFromRecord;
30
+ private startRuntime;
31
+ }
32
+
33
+ export { SessionHostServer, type SessionHostServerOptions };