repoburg 1.3.311 → 1.3.312

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.
@@ -1,4 +1,4 @@
1
- var en=Object.defineProperty;var tn=(e,t,i)=>t in e?en(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Ye=(e,t,i)=>tn(e,typeof t!="symbol"?t+"":t,i);import{c as sn,b as rn,u as gi,r as lt,j as Ee,R as nn,X as on}from"./index-NpywVkQl.js";/**
1
+ var en=Object.defineProperty;var tn=(e,t,i)=>t in e?en(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Ye=(e,t,i)=>tn(e,typeof t!="symbol"?t+"":t,i);import{c as sn,b as rn,u as gi,r as lt,j as Ee,R as nn,X as on}from"./index-7ikRAI4J.js";/**
2
2
  * @license lucide-react v0.469.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-CdL80e84.js","assets/TerminalView-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-BF35pnWS.js","assets/TerminalView-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
2
  var U0=Object.defineProperty;var B0=(e,n,r)=>n in e?U0(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var at=(e,n,r)=>B0(e,typeof n!="symbol"?n+"":n,r);(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))o(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function r(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function o(l){if(l.ep)return;l.ep=!0;const c=r(l);fetch(l.href,c)}})();function tv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Fu={exports:{}},mi={},Uu={exports:{}},He={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -833,9 +833,9 @@ ${_}
833
833
  stack: (r && r.stack) || '', line: 0, col: 0
834
834
  }, '*');
835
835
  });
836
- }`;function HE(e){return`(${WE})(${JSON.stringify(e)});`}function Gg(e){return e.replace(/<\/script/gi,"<\\/script")}function VE(e,n){const r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(r,"gi");let l=-1,c;for(;(c=o.exec(e))!==null;)l=c.index;return l}function qg(e,n,r){const o=VE(e,n);return o===-1?e+r:e.slice(0,o)+r+e.slice(o)}function KE(e,n,r){let o=e;const l=`<script>${Gg(n)}<\/script>`;if(/<\/head>/i.test(o)?o=qg(o,"</head>",l):/<html[^>]*>/i.test(o)?o=o.replace(/(<html[^>]*>)/i,`$1<head>${l}</head>`):o=`${l}${o}`,r){const c=`<script>${Gg(r)}<\/script>`;o=qg(o,"</body>",c)}return o}function GE(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`tab-${e.randomUUID()}`:`tab-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function qE(e){var r;if(!(e instanceof Ui)||e.status!==409)return null;const n=(r=e.body)==null?void 0:r.state;return n&&typeof n=="object"?n:null}function XE({appId:e,workspace:n=""}){const r=x.useRef(null),o=x.useRef({pinned:!1,data:null}),[l,c]=x.useState(null),[d,f]=x.useState(null),[h,m]=x.useState([]);x.useEffect(()=>{let S=!0;const E=GE(),T=b=>{const _=o.current.version;typeof b.version=="number"&&typeof _=="number"&&b.version<_||(o.current=b)};Ww(e,b=>{var _,z;return(z=(_=r.current)==null?void 0:_.contentWindow)==null?void 0:z.postMessage(b,"*")},n);const C=async b=>{var P,U,Q,J,oe,me,Se,Me,ee,ie,te,F,Z,q,I,$,ue,B,X,ce,be,_e,Ae,je;if(b.source!==((P=r.current)==null?void 0:P.contentWindow))return;const _=b.data;if(!_||_.source!=="agentpane-app")return;if(_.report==="error"){const ge={message:String(_.message??"Unknown error"),stack:String(_.stack??"")};m(he=>{const Ve=he[he.length-1];return Ve&&Ve.message===ge.message?he:[...he,ge].slice(-20)});return}if(typeof _.method!="string")return;let z=!0,M,L,G=null;try{switch(_.method){case"getApp":M={id:e,workspace:n};break;case"getState":try{const ge=await jm(e,n);T(ge),M=ge}catch{M=o.current}break;case"setState":{const ge=((U=_.params)==null?void 0:U.data)??null,he=(Q=_.params)==null?void 0:Q.ifVersion,Ve={data:ge,writer:E};typeof he=="number"&&(Ve.ifVersion=he);try{const Ie=await Cv(e,Ve,n);T(Ie),M=Ie}catch(Ie){if(G=qE(Ie),!G)throw Ie;T(G);const mt=Ie.body;throw new Error(typeof(mt==null?void 0:mt.error)=="string"?mt.error:"App state changed since that version")}break}case"createSession":{const ge=_.params??{},he=await qd({title:typeof ge.title=="string"?ge.title:void 0,runtime_type:typeof ge.runtime_type=="string"?ge.runtime_type:void 0,model:typeof ge.model=="string"?ge.model:void 0,model_reasoning_effort:typeof ge.model_reasoning_effort=="string"?ge.model_reasoning_effort:void 0,cwd:typeof ge.cwd=="string"?ge.cwd:void 0,origin_app_id:e,origin_app_workspace:n});dl(he.id,e),R.getState().addSession(he),M=he;break}case"submitTurn":{const ge=String(((J=_.params)==null?void 0:J.sessionId)??"");if(!await _m(e,ge))throw new Error(`submitTurn: ${ge} is not a session of this app`);const he=String(((oe=_.params)==null?void 0:oe.prompt)??""),Ve=await BE(e,(me=_.params)==null?void 0:me.attachments,mt=>Xk(e,mt)),Ie=await dv(ge,he,Ve.length?Ve:void 0,{originAppId:e});dl(ge,e),M=Ie;break}case"getSession":{M=await _m(e,String(((Se=_.params)==null?void 0:Se.sessionId)??""));break}case"listSessions":{const ge=(Me=_.params)==null?void 0:Me.lifecycle,he=(ee=_.params)==null?void 0:ee.running;M=await Ok(e,n,{lifecycle:ge==="working"||ge==="finished"?ge:void 0,running:typeof he=="boolean"?he:void 0});break}case"getSessionInfo":{M=await $k(e,n,String(((ie=_.params)==null?void 0:ie.sessionId)??""));break}case"cancelTurn":{M=await Pk(e,String(((te=_.params)==null?void 0:te.sessionId)??""));break}case"setSessionLifecycle":{M=await zk(e,String(((F=_.params)==null?void 0:F.sessionId)??""),String(((Z=_.params)==null?void 0:Z.lifecycle)??""));break}case"callTool":{const ge=(q=_.params)==null?void 0:q.args;M=await Fk(e,n,String(((I=_.params)==null?void 0:I.tool)??""),ge&&typeof ge=="object"?ge:{});break}case"listProviders":{M=await Xy();break}case"listModels":{const ge=typeof(($=_.params)==null?void 0:$.runtime)=="string"?_.params.runtime.trim():"";if(!ge)throw new Error("listModels: runtime is required");const he=(ue=_.params)==null?void 0:ue.cwd;M=await Nv(ge,typeof he=="string"&&he?he:void 0);break}case"pickDirectory":{if(R.getState().activeAppTabId!==e)throw new Error("pickDirectory: the app is not on screen — call it from a click in the app");M=await pv();break}case"resolveToolCall":{const ge=String(((B=_.params)==null?void 0:B.callId)??""),he=(X=_.params)==null?void 0:X.result;await Vk(ge,he),M={ok:!0};break}case"openSession":{if(R.getState().activeAppTabId!==e)throw new Error("openSession: the app is not on screen — call it from a click in the app");const ge=typeof((ce=_.params)==null?void 0:ce.sessionId)=="string"?_.params.sessionId.trim():"";if(!ge)throw new Error("openSession: sessionId is required");try{await R.getState().revealSession(ge)}catch(he){throw new Error(`openSession: ${he instanceof Error?he.message:String(he)}`)}M={ok:!0};break}case"uploadFile":{const ge=await UE((be=_.params)==null?void 0:be.file);try{M=Kg(await Gk(e,ge))}catch(he){throw new Error(`uploadFile: ${he instanceof Error?he.message:String(he)}`)}break}case"getFile":{const ge=rx(e,(_e=_.params)==null?void 0:_e.ref),he=ge?await qk(e,ge):null;M=he?Kg(he):null;break}default:throw new Error(`Unknown bridge method: ${_.method}`)}}catch(ge){z=!1,L=ge instanceof Error?ge.message:String(ge)}(je=(Ae=r.current)==null?void 0:Ae.contentWindow)==null||je.postMessage(G?{source:"agentpane-host",id:_.id,ok:z,error:L,code:"conflict",state:G}:{source:"agentpane-host",id:_.id,ok:z,result:M,error:L},"*")};return window.addEventListener("message",C),Yw(e,b=>{var _,z;typeof b.workspace=="string"&&b.workspace!==n||b.writer!==E&&((z=(_=r.current)==null?void 0:_.contentWindow)==null||z.postMessage({source:"agentpane-host",event:"state_changed",payload:typeof b.version=="number"?{version:b.version}:{}},"*"))}),qw(e,()=>{Em(e).then(b=>{S&&(c(b),m([]))}).catch(()=>{})}),(async()=>{try{const[b,_,z]=await Promise.all([Em(e),jm(e,n),Lk(e).catch(()=>[])]);if(!S)return;o.current=_,z.forEach(M=>dl(M.id,e)),c(b)}catch(b){S&&f(b instanceof Error?b.message:String(b))}})(),()=>{S=!1,Hw(e),Xw(e),Qw(e),window.removeEventListener("message",C)}},[e,n]),x.useEffect(()=>{l&&Vw(e,l.manifest.headlessSessions===!0)},[e,l]);const v=x.useMemo(()=>l?KE(l.html,HE({appId:e,apiOrigin:sx()}),l.js):"",[l,e]);if(d)return a.jsxs("div",{className:"empty-state",style:{padding:"24px"},children:["Mini app failed to load: ",d]});if(!v)return a.jsx("div",{className:"empty-state",style:{padding:"24px"},children:"Loading mini app…"});const k=(l==null?void 0:l.diagnostics)??[],y=k.some(S=>S.severity==="error");return a.jsxs("div",{className:"miniapp-runtime",children:[k.length>0&&a.jsxs("div",{className:`miniapp-diagnostics${y?"":" miniapp-diagnostics-warn"}`,"data-testid":"miniapp-diagnostics",children:[a.jsx("div",{className:"miniapp-diagnostics-title",children:y?`Compile errors in ${(l==null?void 0:l.sourceFile)??"the app logic"} — the pane serves the last code that parsed:`:"Warnings — the app runs, but fix these:"}),k.map((S,E)=>a.jsxs("div",{className:"miniapp-diag",children:[S.file,":",S.line,":",S.column," — ",S.message]},E))]}),a.jsx("iframe",{ref:r,className:"miniapp-frame",sandbox:"allow-scripts allow-popups allow-popups-to-escape-sandbox",allow:"loopback-network; local-network; local-network-access",title:`Mini app: ${e}`,srcDoc:v}),h.length>0&&a.jsx("div",{className:"miniapp-rt-errors","data-testid":"miniapp-rt-errors",children:h.map((S,E)=>a.jsxs("div",{className:"miniapp-rt-error",children:[a.jsx("div",{className:"miniapp-rt-error-message",children:S.message}),S.stack&&a.jsx("pre",{className:"miniapp-rt-error-stack",children:S.stack})]},E))})]})}function YE({appId:e,active:n}){const r=R(y=>y.apps),o=R(y=>y.workspaces),l=R(y=>y.appWorkspaces),c=R(y=>y.setAppWorkspace),d=R(y=>y.setActiveAppTab),f=R(y=>y.startAppEdit),h=r.find(y=>y.id===e),m=l[e]??"",v=o.filter(y=>y.deleted!==1),k=m!==""&&!v.some(y=>y.path===m)?m:null;return a.jsxs("div",{className:`miniapp-view ${n?"":"miniapp-view-hidden"}`,children:[a.jsxs("div",{className:"miniapp-header",children:[a.jsx(Do,{iconNode:h==null?void 0:h.iconNode,size:14,className:"miniapp-header-icon"}),a.jsx("span",{className:"miniapp-header-title",children:(h==null?void 0:h.title)??e}),a.jsxs("select",{className:"miniapp-workspace-select",title:"Workspace this app instance is bound to (state and pinning are scoped per workspace)",value:m,onChange:y=>c(e,y.target.value),children:[a.jsx("option",{value:"",children:"All workspaces (global)"}),v.map(y=>a.jsx("option",{value:y.path,children:y.label||y.path.split("/").pop()||y.path},y.path)),k&&a.jsx("option",{value:k,children:`${k} (unknown workspace)`})]}),a.jsxs("button",{className:"miniapp-header-btn",title:"Edit this app with the agent (opens an edit session on the app folder)",onClick:()=>void f(e),children:[a.jsx(V1,{size:13}),"Edit"]}),a.jsx("button",{className:"miniapp-header-close",title:"Close app",onClick:()=>d(null),children:a.jsx(Tn,{size:14})})]}),a.jsx("div",{className:"miniapp-body",children:a.jsx(XE,{appId:e,workspace:m},`${e}:${m}`)})]})}function QE({side:e,minWidth:n,maxWidth:r,getWidth:o,setWidth:l}){const[c,d]=x.useState(!1),f=x.useRef(0),h=x.useRef(0),m=x.useCallback(y=>{const S=y.clientX-f.current,E=e==="left"?h.current+S:h.current-S,T=Math.min(r,Math.max(n,E));l(T)},[e,n,r,l]),v=x.useCallback(()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",v),document.body.classList.remove("is-resizing"),d(!1)},[m]);return{onPointerDown:x.useCallback(y=>{var S,E;y.preventDefault(),y.stopPropagation();try{(E=(S=y.currentTarget)==null?void 0:S.setPointerCapture)==null||E.call(S,y.pointerId)}catch{}f.current=y.clientX,h.current=o(),d(!0),document.body.classList.add("is-resizing"),window.addEventListener("pointermove",m),window.addEventListener("pointerup",v)},[o,m,v]),dragging:c}}function Xg({side:e,minWidth:n,maxWidth:r,getWidth:o,setWidth:l}){const{onPointerDown:c,dragging:d}=QE({side:e,minWidth:n,maxWidth:r,getWidth:o,setWidth:l});return a.jsx("div",{className:`resize-handle ${e}${d?" dragging":""}`,onPointerDown:c,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e} panel`,"data-resizing":d?"":void 0})}const ZE=x.lazy(()=>f1(()=>import("./TerminalView-CdL80e84.js"),__vite__mapDeps([0,1])));function JE(){Lt.trackRender("IdeWorkspace");const e=R(S=>S.sidebarWidth),n=R(S=>S.rightPanelWidth),r=R(S=>S.setSidebarWidth),o=R(S=>S.setRightPanelWidth),l=R(S=>S.rightPanelCollapsed),c=R(S=>S.vscodeViewOpen),d=R(S=>S.usageViewOpen),f=R(S=>S.terminalViewOpen),[h,m]=x.useState(!1);f&&!h&&m(!0);const v=R(S=>S.activeAppTabId),k=R(S=>S.openAppTabs);x.useEffect(()=>{const S=()=>{const E=Nl(),{rightPanelWidth:T,setRightPanelWidth:C}=R.getState();T>E&&C(E)};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const y=l?`${e}px 6px 1fr ${jk}px`:`${e}px 6px 1fr 6px ${n}px`;return a.jsxs("div",{className:"ide-root",children:[a.jsx(OE,{}),a.jsxs("div",{className:`ide-layout ${c||d||f?"ide-hidden":""}`,style:{gridTemplateColumns:y},children:[a.jsx(tN,{}),a.jsx(Xg,{side:"left",minWidth:kd,maxWidth:Sd,getWidth:()=>R.getState().sidebarWidth,setWidth:r}),a.jsxs("div",{className:"ide-center",children:[a.jsx(rN,{}),a.jsxs("div",{className:"ide-render",children:[k.map(S=>a.jsx(YE,{appId:S,active:v===S},S)),v==null&&a.jsx(vC,{})]}),a.jsx(jC,{})]}),!l&&a.jsx(Xg,{side:"right",minWidth:bl,maxWidth:Nl(),getWidth:()=>R.getState().rightPanelWidth,setWidth:o}),a.jsx(YC,{})]}),c&&a.jsx(uE,{}),d&&a.jsx(LE,{}),h&&a.jsx(x.Suspense,{fallback:null,children:a.jsx(ZE,{visible:f})}),a.jsx(oE,{})]})}function ej(){const{showNewSessionDialog:e,setShowNewSessionDialog:n,createSession:r,lastModelConfig:o}=R(),l=(o==null?void 0:o.provider)??"codex",c=(o==null?void 0:o.model)??"",d=(o==null?void 0:o.reasoning)??"",[f,h]=x.useState(""),[m,v]=x.useState(c),[k,y]=x.useState(d),[S,E]=x.useState("");if(!e)return null;const T=jf(l),C=m?Fd(l,m):[];function b(){r({title:f.trim()||void 0,model:m||void 0,model_reasoning_effort:k||void 0,cwd:S.trim()||void 0,runtime_type:l}),h(""),E("")}function _(M){M.key==="Escape"&&n(!1)}function z(M){var P;v(M);const L=Fd(l,M);L.some(U=>U.effort===k)||y(Ud(l,M)??((P=L[0])==null?void 0:P.effort)??"")}return a.jsx("div",{className:"dialog-overlay",onClick:()=>n(!1),children:a.jsxs("div",{className:"dialog",onClick:M=>M.stopPropagation(),onKeyDown:_,children:[a.jsxs("div",{className:"dialog-header",children:[a.jsx("span",{className:"dialog-title",children:"New Session"}),a.jsx("button",{className:"dialog-close",onClick:()=>n(!1),children:a.jsx(Tn,{size:16})})]}),a.jsxs("div",{className:"dialog-body",children:[a.jsxs("label",{className:"dialog-label",children:["Title (optional)",a.jsx("input",{className:"dialog-input",type:"text",value:f,onChange:M=>h(M.target.value),placeholder:"e.g. refactor auth module",autoFocus:!0})]}),a.jsxs("label",{className:"dialog-label",children:["Model",a.jsxs("select",{className:"dialog-input dialog-select",value:m,onChange:M=>z(M.target.value),children:[a.jsx("option",{value:"",children:"Default (Codex picks)"}),T.map(M=>a.jsxs("option",{value:M.slug,children:[M.displayName," — ",M.description]},M.slug))]})]}),C.length>0&&a.jsxs("label",{className:"dialog-label",children:["Thinking Level",a.jsxs("select",{className:"dialog-input dialog-select",value:k,onChange:M=>y(M.target.value),children:[a.jsxs("option",{value:"",children:["Default (",Ud(l,m),")"]}),C.map(M=>a.jsx("option",{value:M.effort,children:M.label},M.effort))]})]}),a.jsxs("label",{className:"dialog-label",children:["Working Directory (optional)",a.jsx("input",{className:"dialog-input",type:"text",value:S,onChange:M=>E(M.target.value),placeholder:"e.g. /Users/me/projects/my-app"})]})]}),a.jsxs("div",{className:"dialog-footer",children:[a.jsx("button",{className:"dialog-btn-cancel",onClick:()=>n(!1),children:"Cancel"}),a.jsx("button",{className:"dialog-btn-create",onClick:b,children:"Create"})]})]})})}function tj(e,n){const r=n!==""&&(e===n||e.startsWith(`${n}/`)),o=[r?{label:"~",path:n}:{label:"/",path:"/"}],l=e.slice(r?n.length:0);let c=o[0].path;for(const d of l.split("/").filter(Boolean))c=c==="/"?`/${d}`:`${c}/${d}`,o.push({label:d,path:c});return o}function nj(e){const n=e.filter(l=>l.deleted===0).at(-1);if(!n)return;const r=gr(n.path),o=r.lastIndexOf("/");return o>0?r.slice(0,o):void 0}function sj(){return R(n=>n.showAddWorkspaceDialog)?a.jsx(rj,{}):null}function rj(){var P;const e=R(U=>U.setShowAddWorkspaceDialog),n=R(U=>U.workspaces),r=R(U=>U.createWorkspaceAt),o=R(U=>U.addToast),[l,c]=x.useState(null),[d,f]=x.useState(!0),[h,m]=x.useState(null),[v,k]=x.useState(!1),y=x.useRef(0),[S]=x.useState(()=>nj(R.getState().workspaces)),E=x.useRef(null),T=x.useCallback(()=>{v||e(!1)},[v,e]);Io(T);const C=x.useCallback(async(U,Q=!1)=>{const J=++y.current;f(!0);let oe=null,me=null;try{oe=await cm(U)}catch(Se){if(me=hr(Se),Q&&U)try{oe=await cm(),me=null}catch(Me){me=hr(Me)}}J===y.current&&(oe&&c(oe),m(me),f(!1))},[]);x.useEffect(()=>{C(S,!0)},[C,S]);const b=l==null?void 0:l.path;x.useEffect(()=>{E.current&&(E.current.scrollTop=0)},[b]);const _=new Set(n.filter(U=>U.deleted===0).map(U=>gr(U.path)));async function z(U){if(!v){k(!0),m(null);try{const Q=await r(U);e(!1),o("success",`Workspace added — ${Q.path}`)}catch(Q){m(hr(Q)),k(!1)}}}const M=l?tj(l.path,l.home):[],L=((P=M.at(-1))==null?void 0:P.label)??"",G=l!==null&&_.has(gr(l.path));return a.jsx("div",{className:"dialog-overlay",onClick:T,children:a.jsxs("div",{className:"dialog folder-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"folder-dialog-title",onClick:U=>U.stopPropagation(),children:[a.jsxs("div",{className:"dialog-header",children:[a.jsx("span",{className:"dialog-title",id:"folder-dialog-title",children:"Add workspace"}),a.jsx("button",{className:"dialog-close",onClick:T,"aria-label":"Close",disabled:v,children:a.jsx(Tn,{size:16})})]}),a.jsxs("div",{className:"dialog-body",children:[a.jsxs("p",{className:"dialog-hint",children:["Choose a project folder",l&&a.jsxs(a.Fragment,{children:[" ","on ",a.jsx("strong",{children:l.hostname})]}),"."]}),a.jsxs("div",{className:"folder-nav",children:[a.jsx("button",{className:"folder-up",onClick:()=>(l==null?void 0:l.parent)&&void C(l.parent),disabled:!(l!=null&&l.parent),"aria-label":"Parent folder",title:"Parent folder",children:a.jsx(Mv,{size:14})}),a.jsx("nav",{className:"folder-crumbs","aria-label":"Folder path",children:M.map((U,Q)=>a.jsxs(x.Fragment,{children:[Q>0&&a.jsx(Li,{size:12,className:"folder-crumb-sep","aria-hidden":"true"}),Q===M.length-1?a.jsx("span",{className:"folder-crumb current","aria-current":"location",title:U.path,children:U.label}):a.jsx("button",{className:"folder-crumb",onClick:()=>void C(U.path),title:U.path,children:U.label})]},U.path))}),d&&l&&a.jsx(mn,{size:14,className:"spin folder-spinner","aria-label":"Loading"})]}),a.jsx("ul",{ref:E,className:`folder-list${d&&l?" loading":""}`,"aria-label":"Folders",children:l?l.folders.length===0?a.jsx("li",{className:"folder-empty",children:"No folders here."}):l.folders.map(U=>a.jsxs("li",{className:"folder-item",children:[a.jsxs("button",{className:"folder-row",onClick:()=>void C(U.path),title:U.path,"aria-label":U.git?`${U.name} (git repository)`:U.name,children:[U.git?a.jsx(j1,{size:15,className:"folder-icon git","aria-hidden":"true"}):a.jsx(Rl,{size:15,className:"folder-icon","aria-hidden":"true"}),a.jsx("span",{className:"folder-name",children:U.name}),a.jsx(Li,{size:13,className:"folder-chevron","aria-hidden":"true"})]}),_.has(gr(U.path))?a.jsx("span",{className:"folder-tag",children:"Added"}):a.jsx("button",{className:"folder-add",onClick:()=>void z(U.path),disabled:v,"aria-label":`Add ${U.name}`,children:"Add"})]},U.path)):d&&a.jsxs("li",{className:"folder-empty",role:"status",children:[a.jsx(mn,{size:14,className:"spin"})," Loading folders…"]})}),(l==null?void 0:l.truncated)&&a.jsxs("p",{className:"folder-note",children:["Showing the first ",l.folders.length," folders."]}),h&&a.jsx("p",{className:"folder-error",role:"alert",children:h})]}),a.jsxs("div",{className:"dialog-footer",children:[a.jsx("button",{className:"dialog-btn-cancel",onClick:T,disabled:v,children:"Cancel"}),a.jsx("button",{className:"dialog-btn-create",onClick:()=>l&&void z(l.path),disabled:!l||d||v||G,children:v?"Adding…":G?"Already added":`Add “${L}”`})]})]})})}const Wd=6e4,Hd=60*Wd,ul=24*Hd;function oj(e,n=Date.now()){const r=Date.parse(e);if(Number.isNaN(r))return"";const o=Math.max(0,n-r);return o<Wd?"just now":o<Hd?`${Math.floor(o/Wd)} min ago`:o<ul?`${Math.floor(o/Hd)} h ago`:o<2*ul?"yesterday":o<7*ul?`${Math.floor(o/ul)} days ago`:new Date(r).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function ij(){const e=R(n=>n.importSessionsWorkspace);return e?a.jsx(aj,{workspace:e},e):null}function aj({workspace:e}){const n=R(P=>P.setImportSessionsWorkspace),r=R(P=>P.importSessions),[o,l]=x.useState(null),[c,d]=x.useState(null),[f,h]=x.useState({}),[m,v]=x.useState(new Set),[k,y]=x.useState(!1),[S,E]=x.useState(new Map),T=x.useCallback(()=>{k||n(null)},[k,n]);Io(T),x.useEffect(()=>{let P=!1;return bv(e).then(({sessions:U,errors:Q})=>{if(P)return;const J=Object.values(Q);if(J.length===wd.length){d([...new Set(J)].join("; "));return}l(U),h(Q)}).catch(U=>{P||d(hr(U))}),()=>{P=!0}},[e]);function C(P){v(U=>{const Q=new Set(U);return Q.has(P)?Q.delete(P):Q.add(P),Q})}const b=o??[],_=P=>Qu({runtime:P.runtime,id:P.session_id}),z=b.length>0&&b.every(P=>m.has(_(P)));async function M(){const P=b.filter(J=>m.has(_(J))).map(J=>({runtime:J.runtime,id:J.session_id}));if(P.length===0)return;y(!0);const{failed:U}=await r(e,P);if(y(!1),U.length===0){n(null);return}const Q=new Set(U.map(Qu));l(J=>(J??[]).filter(oe=>!m.has(_(oe))||Q.has(_(oe)))),v(Q),E(new Map(U.map(J=>[Qu(J),J.error])))}const L=e.split("/").pop()||e,G=m.size;return a.jsx("div",{className:"dialog-overlay",onClick:T,children:a.jsxs("div",{className:"dialog import-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"import-dialog-title",onClick:P=>P.stopPropagation(),children:[a.jsxs("div",{className:"dialog-header",children:[a.jsx("span",{className:"dialog-title",id:"import-dialog-title",children:"Import sessions"}),a.jsx("button",{className:"dialog-close",onClick:T,"aria-label":"Close",disabled:k,children:a.jsx(Tn,{size:16})})]}),a.jsxs("div",{className:"dialog-body",children:[a.jsxs("p",{className:"dialog-hint",children:["Sessions you started with ",a.jsx("code",{children:"claude"})," or ",a.jsx("code",{children:"codex"})," in"," ",a.jsx("strong",{title:e,children:L}),", in a terminal or an IDE. An imported session keeps its history and continues the same conversation."]}),c?a.jsxs("p",{className:"import-error",role:"alert",children:["Could not list the sessions — ",c]}):o===null?a.jsxs("div",{className:"import-loading",role:"status",children:[a.jsx(mn,{size:14,className:"spin"})," Looking for sessions…"]}):o.length===0?a.jsxs("div",{className:"import-empty",children:["No Claude Code or Codex sessions to import here. Sessions you start with ",a.jsx("code",{children:"claude"})," or"," ",a.jsx("code",{children:"codex"})," in this folder will show up here.",a.jsx(Yg,{errors:f})]}):a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"import-select-all",children:[a.jsx("input",{type:"checkbox",checked:z,disabled:k,onChange:()=>v(z?new Set:new Set(b.map(_)))}),"Select all (",o.length,")"]}),a.jsx("ul",{className:"import-list",children:o.map(P=>{const U=_(P),Q=S.get(U);return a.jsx("li",{children:a.jsxs("label",{className:`import-row${m.has(U)?" selected":""}`,children:[a.jsx("input",{type:"checkbox",checked:m.has(U),disabled:k,onChange:()=>C(U)}),a.jsxs("span",{className:"import-row-main",children:[a.jsx("span",{className:"import-row-title",title:P.title,children:P.title}),a.jsxs("span",{className:"import-row-meta",children:[a.jsx("span",{className:`import-row-runtime ${P.runtime}`,children:Ql[P.runtime]}),a.jsx("span",{title:new Date(P.last_modified).toLocaleString(),children:oj(P.last_modified)}),P.git_branch&&a.jsxs("span",{className:"import-row-branch",title:"Git branch",children:[a.jsx(Pv,{size:10})," ",P.git_branch]})]}),P.recently_active&&a.jsxs("span",{className:"import-row-warn",children:[a.jsx(tc,{size:11})," Active in the last few minutes. If it is still open in a terminal, close it there first: both would write to the same session."]}),Q&&a.jsx("span",{className:"import-row-error",role:"alert",children:Q})]})]})},U)})}),a.jsx(Yg,{errors:f})]})]}),a.jsxs("div",{className:"dialog-footer",children:[a.jsx("button",{className:"dialog-btn-cancel",onClick:T,disabled:k,children:"Cancel"}),a.jsx("button",{className:"dialog-btn-create",onClick:()=>void M(),disabled:G===0||k,children:k?a.jsxs(a.Fragment,{children:[a.jsx(mn,{size:12,className:"spin"})," Importing…"]}):G>1?`Import ${G} sessions`:"Import"})]})]})})}function Yg({errors:e}){const n=Object.entries(e);return n.length===0?null:a.jsx(a.Fragment,{children:n.map(([r,o])=>a.jsxs("p",{className:"import-note",children:["Could not list the ",Ql[r]," sessions — ",o]},r))})}const lj=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,cj=512*1024;function uj(e){const n=e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"");return/^[a-z0-9]/.test(n)?n:""}function dj(){const{appCatalogOpen:e,closeAppCatalog:n,apps:r,installExampleApp:o,createSkeletonApp:l,importAppFolder:c}=R(),[d,f]=x.useState("examples"),[h,m]=x.useState(null),[v,k]=x.useState(null),[y,S]=x.useState(!1),[E,T]=x.useState(""),[C,b]=x.useState(""),[_,z]=x.useState(""),[M,L]=x.useState(""),[G,P]=x.useState(null),[U,Q]=x.useState(""),J=x.useRef(null);if(x.useEffect(()=>{e&&(m(null),Uk().then(m).catch(()=>m([])))},[e]),x.useEffect(()=>{J.current&&(J.current.webkitdirectory=!0)},[d]),!e)return null;const oe=new Set(r.map(F=>F.id));async function me(F){k(F);try{await o(F)&&n()}finally{k(null)}}async function Se(){if(y)return;const F=E.trim(),Z=C.trim();if(!(!F||!Z)){S(!0);try{await l({id:F,title:Z,description:_.trim()||void 0,icon:M.trim()||void 0})&&(T(""),b(""),z(""),L(""),n())}finally{S(!1)}}}async function Me(F){const Z=Array.from(F.target.files??[]),q={};let I="";for(const $ of Z){const B=($.webkitRelativePath??"").split("/");!I&&B.length>1&&(I=B[0]);const X=B[B.length-1];if(!(!X||!lj.test(X))&&!($.size>cj))try{q[X]=await $.text()}catch{}}P(Object.keys(q).length>0?q:null),Q(uj(I))}async function ee(){if(!(y||!G||!U.trim())){S(!0);try{await c(U.trim(),G)&&(P(null),Q(""),n())}finally{S(!1)}}}function ie(F){F.key==="Escape"&&n()}const te=[{key:"examples",label:"Examples"},{key:"new",label:"New App"},{key:"upload",label:"Upload"}];return a.jsx("div",{className:"dialog-overlay",onClick:n,children:a.jsxs("div",{className:"dialog app-catalog",onClick:F=>F.stopPropagation(),onKeyDown:ie,children:[a.jsxs("div",{className:"dialog-header",children:[a.jsx("span",{className:"dialog-title",children:"Add Mini App"}),a.jsx("button",{className:"dialog-close",onClick:n,children:"✕"})]}),a.jsx("div",{className:"catalog-tabs",children:te.map(F=>a.jsx("button",{className:`catalog-tab${d===F.key?" active":""}`,onClick:()=>f(F.key),children:F.label},F.key))}),a.jsxs("div",{className:"dialog-body catalog-body",children:[d==="examples"&&a.jsx("div",{className:"catalog-examples",children:h===null?a.jsx("div",{className:"empty-state",style:{padding:"12px"},children:"Loading examples…"}):h.length===0?a.jsx("div",{className:"empty-state",style:{padding:"12px"},children:"No example apps available."}):h.map(F=>{const Z=oe.has(F.id);return a.jsxs("div",{className:"example-row",children:[a.jsx(Do,{iconNode:F.iconNode,size:14,className:"sidebar-app-icon"}),a.jsxs("div",{className:"example-info",children:[a.jsx("span",{className:"example-title",children:F.title}),F.description&&a.jsx("span",{className:"example-desc",children:F.description})]}),a.jsx("button",{className:"example-install",disabled:Z||v===F.id,onClick:()=>me(F.id),title:Z?"Already installed":"Install this example",children:Z?"Installed":v===F.id?"Installing…":"Install"})]},F.id)})}),d==="new"&&a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"dialog-label",children:["App id (folder name)",a.jsx("input",{className:"dialog-input",type:"text",value:E,onChange:F=>T(F.target.value),placeholder:"e.g. todo-list",autoFocus:!0})]}),a.jsxs("label",{className:"dialog-label",children:["Title",a.jsx("input",{className:"dialog-input",type:"text",value:C,onChange:F=>b(F.target.value),placeholder:"e.g. Todo List"})]}),a.jsxs("label",{className:"dialog-label",children:["Description (optional)",a.jsx("input",{className:"dialog-input",type:"text",value:_,onChange:F=>z(F.target.value),placeholder:"What does this app do?"})]}),a.jsxs("label",{className:"dialog-label",children:[a.jsxs("span",{children:["Icon (optional, a"," ",a.jsx("a",{href:"https://lucide.dev/icons",target:"_blank",rel:"noreferrer",children:"Lucide icon"})," ","name)"]}),a.jsx("input",{className:"dialog-input",type:"text",value:M,onChange:F=>L(F.target.value),placeholder:"e.g. notebook-pen",spellCheck:!1,autoCapitalize:"off"})]}),a.jsxs("button",{className:"dialog-btn-create catalog-action-btn",disabled:y||!E.trim()||!C.trim(),onClick:Se,children:[a.jsx(pr,{size:13})," Create App"]})]}),d==="upload"&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"catalog-upload-hint",children:"Select an app folder from disk. Text files only (manifest.json, index.html, app.ts (or legacy app.js), …). A missing manifest.json is generated from the folder name."}),a.jsx("input",{ref:J,type:"file",multiple:!0,onChange:Me}),G&&a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"dialog-label",children:["App id",a.jsx("input",{className:"dialog-input",type:"text",value:U,onChange:F=>Q(F.target.value)})]}),a.jsxs("div",{className:"catalog-upload-summary",children:[Object.keys(G).length," file(s):"," ",Object.keys(G).slice(0,6).join(", "),Object.keys(G).length>6?", …":""]})]}),a.jsxs("button",{className:"dialog-btn-create catalog-action-btn",disabled:y||!G||!U.trim(),onClick:ee,children:[a.jsx(Z1,{size:13})," Import App"]})]})]}),a.jsx("div",{className:"dialog-footer",children:a.jsx("button",{className:"dialog-btn-cancel",onClick:n,children:"Close"})})]})})}function fj(){const e=R(k=>k.showCommandPalette),n=R(k=>k.setShowCommandPalette),r=R(),[o,l]=x.useState(""),[c,d]=x.useState(0),f=x.useRef(null),h=x.useMemo(()=>{const k=r.activeSessionId?r.sessionDetails[r.activeSessionId]:null,y=ql(k);return[{id:"new-session",label:"New Session",hint:"Create a new Codex session",icon:pr,action:()=>r.setShowNewSessionDialog(!0),available:!0},{id:"delete-session",label:"Delete Session",hint:"Delete the active session",icon:us,action:()=>{r.activeSessionId&&r.deleteSession(r.activeSessionId)},available:!!r.activeSessionId},{id:"send-message",label:"Send Message",hint:"Focus the message input",icon:Hi,action:()=>{const S=document.querySelector(".cmd-input");S==null||S.focus()},available:!!r.activeSessionId&&!y},{id:"cancel-turn",label:"Cancel Turn",hint:"Cancel the running turn",icon:yr,action:()=>r.cancelTurn(),available:y},{id:"tab-turns",label:"Switch to Turns Tab",hint:"View conversation timeline",icon:O1,action:()=>r.switchRightTab("turns"),available:!!r.activeSessionId},{id:"tab-sidecar",label:"Ask Sidecar",hint:"Ask about this session — status, blockers, what is left",icon:vr,action:()=>r.switchRightTab("sidecar"),available:!!r.activeSessionId},{id:"toggle-right-panel",label:"Toggle Right Panel",hint:r.rightPanelCollapsed?"Expand the right panel":"Collapse the right panel to its icon rail",icon:W1,action:()=>r.toggleRightPanel(),available:!0},{id:"close-tab",label:"Close Tab",hint:"Close the active session tab",icon:Tn,action:()=>{r.activeSessionId&&r.closeTab(r.activeSessionId)},available:!!r.activeSessionId}]},[r]),m=x.useMemo(()=>{const k=o.toLowerCase().trim(),y=h.filter(S=>S.available);return k?y.filter(S=>S.label.toLowerCase().includes(k)||S.hint.toLowerCase().includes(k)):y},[h,o]);x.useEffect(()=>{e&&(l(""),d(0),setTimeout(()=>{var k;return(k=f.current)==null?void 0:k.focus()},50))},[e]);function v(k){if(k.key==="ArrowDown")k.preventDefault(),d(y=>Math.min(y+1,m.length-1));else if(k.key==="ArrowUp")k.preventDefault(),d(y=>Math.max(y-1,0));else if(k.key==="Enter"){k.preventDefault();const y=m[c];y&&(y.action(),n(!1))}else k.key==="Escape"&&n(!1)}return e?a.jsx("div",{className:"palette-overlay",onClick:()=>n(!1),children:a.jsxs("div",{className:"palette",onClick:k=>k.stopPropagation(),children:[a.jsxs("div",{className:"palette-search",children:[a.jsx("input",{ref:f,type:"text",placeholder:"Type a command…",value:o,onChange:k=>{l(k.target.value),d(0)},onKeyDown:v}),a.jsx("span",{className:"palette-esc",children:"ESC"})]}),m.length===0?a.jsx("div",{className:"palette-empty",children:"No matching commands"}):a.jsx("div",{className:"palette-list",children:m.map((k,y)=>{const S=k.icon;return a.jsxs("div",{className:`palette-item ${y===c?"selected":""}`,onClick:()=>{k.action(),n(!1)},onMouseEnter:()=>d(y),children:[a.jsx("span",{className:"palette-item-icon",children:a.jsx(S,{size:16})}),a.jsx("span",{className:"palette-item-label",children:k.label}),a.jsx("span",{className:"palette-item-hint",children:k.hint}),y===c&&a.jsx(T1,{size:12,className:"palette-item-enter"})]},k.id)})}),a.jsxs("div",{className:"palette-footer",children:[a.jsxs("span",{className:"palette-footer-hint",children:[a.jsx("span",{className:"kbd",children:"↑"}),a.jsx("span",{className:"kbd",children:"↓"})," Navigate"]}),a.jsxs("span",{className:"palette-footer-hint",children:[a.jsx("span",{className:"kbd",children:"↵"})," Select"]}),a.jsxs("span",{className:"palette-footer-hint",children:[a.jsx("span",{className:"kbd",children:"Esc"})," Close"]})]})]})}):null}const Qg=/^[a-z][a-z0-9-]{1,30}$/,pj=2e3;function hj(){const{showRemoteModal:e,setShowRemoteModal:n,selectSession:r}=R(),[o,l]=x.useState(null),[c,d]=x.useState(null),[f,h]=x.useState(!1),[m,v]=x.useState(!1),[k,y]=x.useState(!1),[S,E]=x.useState(!1),[T,C]=x.useState("main"),[b,_]=x.useState(""),[z,M]=x.useState(!1),[L,G]=x.useState(null),P=x.useRef(null);Wi(P,()=>E(!1),S);const U=m||k,Q=x.useCallback(async()=>{h(!0),d(null);try{const F=await fetch(`${rn()}/remote/status`,{headers:{Accept:"application/json"}});if(!F.ok)throw new Error(`status ${F.status}`);l(await F.json())}catch{l(null),d("Machine management is only available from this machine's local pane.")}finally{h(!1)}},[]);x.useEffect(()=>{e&&(C("main"),G(null),Q())},[e,Q]);const J=L!==null&&L.state==="running";if(x.useEffect(()=>{if(!J)return;const F=setInterval(async()=>{try{const Z=await fetch(`${rn()}/remote/enable`,{headers:{Accept:"application/json"}});Z.ok&&G(await Z.json())}catch{}},pj);return()=>clearInterval(F)},[J]),!e)return null;const oe=!!(o!=null&&o.tunnel.provisioned)&&!!(o!=null&&o.service.running)&&!!(o!=null&&o.connection.ok);function me(F){F.key==="Escape"&&n(!1)}async function Se(F){if(Qg.test(F)){M(!0);try{const Z=await fetch(`${rn()}/remote/enable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mahlas:F})});if(!Z.ok)throw new Error(`enable ${Z.status}`);G(await Z.json()),C("setup")}catch{d("Could not start the setup — check the daemon logs.")}finally{M(!1)}}}function Me(){L!=null&&L.troubleshootingSessionId&&(r(L.troubleshootingSessionId),n(!1))}async function ee(){v(!0);try{await fetch(`${rn()}/remote/disable`,{method:"POST"}),await Q()}catch{d("Could not stop the tunnel service — check the service logs.")}finally{v(!1)}}async function ie(){if(E(!1),!!window.confirm(`Remove the tunnel completely?
836
+ }`;function HE(e){return`(${WE})(${JSON.stringify(e)});`}function Gg(e){return e.replace(/<\/script/gi,"<\\/script")}function VE(e,n){const r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(r,"gi");let l=-1,c;for(;(c=o.exec(e))!==null;)l=c.index;return l}function qg(e,n,r){const o=VE(e,n);return o===-1?e+r:e.slice(0,o)+r+e.slice(o)}function KE(e,n,r){let o=e;const l=`<script>${Gg(n)}<\/script>`;if(/<\/head>/i.test(o)?o=qg(o,"</head>",l):/<html[^>]*>/i.test(o)?o=o.replace(/(<html[^>]*>)/i,`$1<head>${l}</head>`):o=`${l}${o}`,r){const c=`<script>${Gg(r)}<\/script>`;o=qg(o,"</body>",c)}return o}function GE(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`tab-${e.randomUUID()}`:`tab-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function qE(e){var r;if(!(e instanceof Ui)||e.status!==409)return null;const n=(r=e.body)==null?void 0:r.state;return n&&typeof n=="object"?n:null}function XE({appId:e,workspace:n=""}){const r=x.useRef(null),o=x.useRef({pinned:!1,data:null}),[l,c]=x.useState(null),[d,f]=x.useState(null),[h,m]=x.useState([]);x.useEffect(()=>{let S=!0;const E=GE(),T=b=>{const _=o.current.version;typeof b.version=="number"&&typeof _=="number"&&b.version<_||(o.current=b)};Ww(e,b=>{var _,z;return(z=(_=r.current)==null?void 0:_.contentWindow)==null?void 0:z.postMessage(b,"*")},n);const C=async b=>{var P,U,Q,J,oe,me,Se,Me,ee,ie,te,F,Z,q,I,$,ue,B,X,ce,be,_e,Ae,je;if(b.source!==((P=r.current)==null?void 0:P.contentWindow))return;const _=b.data;if(!_||_.source!=="agentpane-app")return;if(_.report==="error"){const ge={message:String(_.message??"Unknown error"),stack:String(_.stack??"")};m(he=>{const Ve=he[he.length-1];return Ve&&Ve.message===ge.message?he:[...he,ge].slice(-20)});return}if(typeof _.method!="string")return;let z=!0,M,L,G=null;try{switch(_.method){case"getApp":M={id:e,workspace:n};break;case"getState":try{const ge=await jm(e,n);T(ge),M=ge}catch{M=o.current}break;case"setState":{const ge=((U=_.params)==null?void 0:U.data)??null,he=(Q=_.params)==null?void 0:Q.ifVersion,Ve={data:ge,writer:E};typeof he=="number"&&(Ve.ifVersion=he);try{const Ie=await Cv(e,Ve,n);T(Ie),M=Ie}catch(Ie){if(G=qE(Ie),!G)throw Ie;T(G);const mt=Ie.body;throw new Error(typeof(mt==null?void 0:mt.error)=="string"?mt.error:"App state changed since that version")}break}case"createSession":{const ge=_.params??{},he=await qd({title:typeof ge.title=="string"?ge.title:void 0,runtime_type:typeof ge.runtime_type=="string"?ge.runtime_type:void 0,model:typeof ge.model=="string"?ge.model:void 0,model_reasoning_effort:typeof ge.model_reasoning_effort=="string"?ge.model_reasoning_effort:void 0,cwd:typeof ge.cwd=="string"?ge.cwd:void 0,origin_app_id:e,origin_app_workspace:n});dl(he.id,e),R.getState().addSession(he),M=he;break}case"submitTurn":{const ge=String(((J=_.params)==null?void 0:J.sessionId)??"");if(!await _m(e,ge))throw new Error(`submitTurn: ${ge} is not a session of this app`);const he=String(((oe=_.params)==null?void 0:oe.prompt)??""),Ve=await BE(e,(me=_.params)==null?void 0:me.attachments,mt=>Xk(e,mt)),Ie=await dv(ge,he,Ve.length?Ve:void 0,{originAppId:e});dl(ge,e),M=Ie;break}case"getSession":{M=await _m(e,String(((Se=_.params)==null?void 0:Se.sessionId)??""));break}case"listSessions":{const ge=(Me=_.params)==null?void 0:Me.lifecycle,he=(ee=_.params)==null?void 0:ee.running;M=await Ok(e,n,{lifecycle:ge==="working"||ge==="finished"?ge:void 0,running:typeof he=="boolean"?he:void 0});break}case"getSessionInfo":{M=await $k(e,n,String(((ie=_.params)==null?void 0:ie.sessionId)??""));break}case"cancelTurn":{M=await Pk(e,String(((te=_.params)==null?void 0:te.sessionId)??""));break}case"setSessionLifecycle":{M=await zk(e,String(((F=_.params)==null?void 0:F.sessionId)??""),String(((Z=_.params)==null?void 0:Z.lifecycle)??""));break}case"callTool":{const ge=(q=_.params)==null?void 0:q.args;M=await Fk(e,n,String(((I=_.params)==null?void 0:I.tool)??""),ge&&typeof ge=="object"?ge:{});break}case"listProviders":{M=await Xy();break}case"listModels":{const ge=typeof(($=_.params)==null?void 0:$.runtime)=="string"?_.params.runtime.trim():"";if(!ge)throw new Error("listModels: runtime is required");const he=(ue=_.params)==null?void 0:ue.cwd;M=await Nv(ge,typeof he=="string"&&he?he:void 0);break}case"pickDirectory":{if(R.getState().activeAppTabId!==e)throw new Error("pickDirectory: the app is not on screen — call it from a click in the app");M=await pv();break}case"resolveToolCall":{const ge=String(((B=_.params)==null?void 0:B.callId)??""),he=(X=_.params)==null?void 0:X.result;await Vk(ge,he),M={ok:!0};break}case"openSession":{if(R.getState().activeAppTabId!==e)throw new Error("openSession: the app is not on screen — call it from a click in the app");const ge=typeof((ce=_.params)==null?void 0:ce.sessionId)=="string"?_.params.sessionId.trim():"";if(!ge)throw new Error("openSession: sessionId is required");try{await R.getState().revealSession(ge)}catch(he){throw new Error(`openSession: ${he instanceof Error?he.message:String(he)}`)}M={ok:!0};break}case"uploadFile":{const ge=await UE((be=_.params)==null?void 0:be.file);try{M=Kg(await Gk(e,ge))}catch(he){throw new Error(`uploadFile: ${he instanceof Error?he.message:String(he)}`)}break}case"getFile":{const ge=rx(e,(_e=_.params)==null?void 0:_e.ref),he=ge?await qk(e,ge):null;M=he?Kg(he):null;break}default:throw new Error(`Unknown bridge method: ${_.method}`)}}catch(ge){z=!1,L=ge instanceof Error?ge.message:String(ge)}(je=(Ae=r.current)==null?void 0:Ae.contentWindow)==null||je.postMessage(G?{source:"agentpane-host",id:_.id,ok:z,error:L,code:"conflict",state:G}:{source:"agentpane-host",id:_.id,ok:z,result:M,error:L},"*")};return window.addEventListener("message",C),Yw(e,b=>{var _,z;typeof b.workspace=="string"&&b.workspace!==n||b.writer!==E&&((z=(_=r.current)==null?void 0:_.contentWindow)==null||z.postMessage({source:"agentpane-host",event:"state_changed",payload:typeof b.version=="number"?{version:b.version}:{}},"*"))}),qw(e,()=>{Em(e).then(b=>{S&&(c(b),m([]))}).catch(()=>{})}),(async()=>{try{const[b,_,z]=await Promise.all([Em(e),jm(e,n),Lk(e).catch(()=>[])]);if(!S)return;o.current=_,z.forEach(M=>dl(M.id,e)),c(b)}catch(b){S&&f(b instanceof Error?b.message:String(b))}})(),()=>{S=!1,Hw(e),Xw(e),Qw(e),window.removeEventListener("message",C)}},[e,n]),x.useEffect(()=>{l&&Vw(e,l.manifest.headlessSessions===!0)},[e,l]);const v=x.useMemo(()=>l?KE(l.html,HE({appId:e,apiOrigin:sx()}),l.js):"",[l,e]);if(d)return a.jsxs("div",{className:"empty-state",style:{padding:"24px"},children:["Mini app failed to load: ",d]});if(!v)return a.jsx("div",{className:"empty-state",style:{padding:"24px"},children:"Loading mini app…"});const k=(l==null?void 0:l.diagnostics)??[],y=k.some(S=>S.severity==="error");return a.jsxs("div",{className:"miniapp-runtime",children:[k.length>0&&a.jsxs("div",{className:`miniapp-diagnostics${y?"":" miniapp-diagnostics-warn"}`,"data-testid":"miniapp-diagnostics",children:[a.jsx("div",{className:"miniapp-diagnostics-title",children:y?`Compile errors in ${(l==null?void 0:l.sourceFile)??"the app logic"} — the pane serves the last code that parsed:`:"Warnings — the app runs, but fix these:"}),k.map((S,E)=>a.jsxs("div",{className:"miniapp-diag",children:[S.file,":",S.line,":",S.column," — ",S.message]},E))]}),a.jsx("iframe",{ref:r,className:"miniapp-frame",sandbox:"allow-scripts allow-popups allow-popups-to-escape-sandbox",allow:"loopback-network; local-network; local-network-access",title:`Mini app: ${e}`,srcDoc:v}),h.length>0&&a.jsx("div",{className:"miniapp-rt-errors","data-testid":"miniapp-rt-errors",children:h.map((S,E)=>a.jsxs("div",{className:"miniapp-rt-error",children:[a.jsx("div",{className:"miniapp-rt-error-message",children:S.message}),S.stack&&a.jsx("pre",{className:"miniapp-rt-error-stack",children:S.stack})]},E))})]})}function YE({appId:e,active:n}){const r=R(y=>y.apps),o=R(y=>y.workspaces),l=R(y=>y.appWorkspaces),c=R(y=>y.setAppWorkspace),d=R(y=>y.setActiveAppTab),f=R(y=>y.startAppEdit),h=r.find(y=>y.id===e),m=l[e]??"",v=o.filter(y=>y.deleted!==1),k=m!==""&&!v.some(y=>y.path===m)?m:null;return a.jsxs("div",{className:`miniapp-view ${n?"":"miniapp-view-hidden"}`,children:[a.jsxs("div",{className:"miniapp-header",children:[a.jsx(Do,{iconNode:h==null?void 0:h.iconNode,size:14,className:"miniapp-header-icon"}),a.jsx("span",{className:"miniapp-header-title",children:(h==null?void 0:h.title)??e}),a.jsxs("select",{className:"miniapp-workspace-select",title:"Workspace this app instance is bound to (state and pinning are scoped per workspace)",value:m,onChange:y=>c(e,y.target.value),children:[a.jsx("option",{value:"",children:"All workspaces (global)"}),v.map(y=>a.jsx("option",{value:y.path,children:y.label||y.path.split("/").pop()||y.path},y.path)),k&&a.jsx("option",{value:k,children:`${k} (unknown workspace)`})]}),a.jsxs("button",{className:"miniapp-header-btn",title:"Edit this app with the agent (opens an edit session on the app folder)",onClick:()=>void f(e),children:[a.jsx(V1,{size:13}),"Edit"]}),a.jsx("button",{className:"miniapp-header-close",title:"Close app",onClick:()=>d(null),children:a.jsx(Tn,{size:14})})]}),a.jsx("div",{className:"miniapp-body",children:a.jsx(XE,{appId:e,workspace:m},`${e}:${m}`)})]})}function QE({side:e,minWidth:n,maxWidth:r,getWidth:o,setWidth:l}){const[c,d]=x.useState(!1),f=x.useRef(0),h=x.useRef(0),m=x.useCallback(y=>{const S=y.clientX-f.current,E=e==="left"?h.current+S:h.current-S,T=Math.min(r,Math.max(n,E));l(T)},[e,n,r,l]),v=x.useCallback(()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",v),document.body.classList.remove("is-resizing"),d(!1)},[m]);return{onPointerDown:x.useCallback(y=>{var S,E;y.preventDefault(),y.stopPropagation();try{(E=(S=y.currentTarget)==null?void 0:S.setPointerCapture)==null||E.call(S,y.pointerId)}catch{}f.current=y.clientX,h.current=o(),d(!0),document.body.classList.add("is-resizing"),window.addEventListener("pointermove",m),window.addEventListener("pointerup",v)},[o,m,v]),dragging:c}}function Xg({side:e,minWidth:n,maxWidth:r,getWidth:o,setWidth:l}){const{onPointerDown:c,dragging:d}=QE({side:e,minWidth:n,maxWidth:r,getWidth:o,setWidth:l});return a.jsx("div",{className:`resize-handle ${e}${d?" dragging":""}`,onPointerDown:c,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e} panel`,"data-resizing":d?"":void 0})}const ZE=x.lazy(()=>f1(()=>import("./TerminalView-BF35pnWS.js"),__vite__mapDeps([0,1])));function JE(){Lt.trackRender("IdeWorkspace");const e=R(S=>S.sidebarWidth),n=R(S=>S.rightPanelWidth),r=R(S=>S.setSidebarWidth),o=R(S=>S.setRightPanelWidth),l=R(S=>S.rightPanelCollapsed),c=R(S=>S.vscodeViewOpen),d=R(S=>S.usageViewOpen),f=R(S=>S.terminalViewOpen),[h,m]=x.useState(!1);f&&!h&&m(!0);const v=R(S=>S.activeAppTabId),k=R(S=>S.openAppTabs);x.useEffect(()=>{const S=()=>{const E=Nl(),{rightPanelWidth:T,setRightPanelWidth:C}=R.getState();T>E&&C(E)};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const y=l?`${e}px 6px 1fr ${jk}px`:`${e}px 6px 1fr 6px ${n}px`;return a.jsxs("div",{className:"ide-root",children:[a.jsx(OE,{}),a.jsxs("div",{className:`ide-layout ${c||d||f?"ide-hidden":""}`,style:{gridTemplateColumns:y},children:[a.jsx(tN,{}),a.jsx(Xg,{side:"left",minWidth:kd,maxWidth:Sd,getWidth:()=>R.getState().sidebarWidth,setWidth:r}),a.jsxs("div",{className:"ide-center",children:[a.jsx(rN,{}),a.jsxs("div",{className:"ide-render",children:[k.map(S=>a.jsx(YE,{appId:S,active:v===S},S)),v==null&&a.jsx(vC,{})]}),a.jsx(jC,{})]}),!l&&a.jsx(Xg,{side:"right",minWidth:bl,maxWidth:Nl(),getWidth:()=>R.getState().rightPanelWidth,setWidth:o}),a.jsx(YC,{})]}),c&&a.jsx(uE,{}),d&&a.jsx(LE,{}),h&&a.jsx(x.Suspense,{fallback:null,children:a.jsx(ZE,{visible:f})}),a.jsx(oE,{})]})}function ej(){const{showNewSessionDialog:e,setShowNewSessionDialog:n,createSession:r,lastModelConfig:o}=R(),l=(o==null?void 0:o.provider)??"codex",c=(o==null?void 0:o.model)??"",d=(o==null?void 0:o.reasoning)??"",[f,h]=x.useState(""),[m,v]=x.useState(c),[k,y]=x.useState(d),[S,E]=x.useState("");if(!e)return null;const T=jf(l),C=m?Fd(l,m):[];function b(){r({title:f.trim()||void 0,model:m||void 0,model_reasoning_effort:k||void 0,cwd:S.trim()||void 0,runtime_type:l}),h(""),E("")}function _(M){M.key==="Escape"&&n(!1)}function z(M){var P;v(M);const L=Fd(l,M);L.some(U=>U.effort===k)||y(Ud(l,M)??((P=L[0])==null?void 0:P.effort)??"")}return a.jsx("div",{className:"dialog-overlay",onClick:()=>n(!1),children:a.jsxs("div",{className:"dialog",onClick:M=>M.stopPropagation(),onKeyDown:_,children:[a.jsxs("div",{className:"dialog-header",children:[a.jsx("span",{className:"dialog-title",children:"New Session"}),a.jsx("button",{className:"dialog-close",onClick:()=>n(!1),children:a.jsx(Tn,{size:16})})]}),a.jsxs("div",{className:"dialog-body",children:[a.jsxs("label",{className:"dialog-label",children:["Title (optional)",a.jsx("input",{className:"dialog-input",type:"text",value:f,onChange:M=>h(M.target.value),placeholder:"e.g. refactor auth module",autoFocus:!0})]}),a.jsxs("label",{className:"dialog-label",children:["Model",a.jsxs("select",{className:"dialog-input dialog-select",value:m,onChange:M=>z(M.target.value),children:[a.jsx("option",{value:"",children:"Default (Codex picks)"}),T.map(M=>a.jsxs("option",{value:M.slug,children:[M.displayName," — ",M.description]},M.slug))]})]}),C.length>0&&a.jsxs("label",{className:"dialog-label",children:["Thinking Level",a.jsxs("select",{className:"dialog-input dialog-select",value:k,onChange:M=>y(M.target.value),children:[a.jsxs("option",{value:"",children:["Default (",Ud(l,m),")"]}),C.map(M=>a.jsx("option",{value:M.effort,children:M.label},M.effort))]})]}),a.jsxs("label",{className:"dialog-label",children:["Working Directory (optional)",a.jsx("input",{className:"dialog-input",type:"text",value:S,onChange:M=>E(M.target.value),placeholder:"e.g. /Users/me/projects/my-app"})]})]}),a.jsxs("div",{className:"dialog-footer",children:[a.jsx("button",{className:"dialog-btn-cancel",onClick:()=>n(!1),children:"Cancel"}),a.jsx("button",{className:"dialog-btn-create",onClick:b,children:"Create"})]})]})})}function tj(e,n){const r=n!==""&&(e===n||e.startsWith(`${n}/`)),o=[r?{label:"~",path:n}:{label:"/",path:"/"}],l=e.slice(r?n.length:0);let c=o[0].path;for(const d of l.split("/").filter(Boolean))c=c==="/"?`/${d}`:`${c}/${d}`,o.push({label:d,path:c});return o}function nj(e){const n=e.filter(l=>l.deleted===0).at(-1);if(!n)return;const r=gr(n.path),o=r.lastIndexOf("/");return o>0?r.slice(0,o):void 0}function sj(){return R(n=>n.showAddWorkspaceDialog)?a.jsx(rj,{}):null}function rj(){var P;const e=R(U=>U.setShowAddWorkspaceDialog),n=R(U=>U.workspaces),r=R(U=>U.createWorkspaceAt),o=R(U=>U.addToast),[l,c]=x.useState(null),[d,f]=x.useState(!0),[h,m]=x.useState(null),[v,k]=x.useState(!1),y=x.useRef(0),[S]=x.useState(()=>nj(R.getState().workspaces)),E=x.useRef(null),T=x.useCallback(()=>{v||e(!1)},[v,e]);Io(T);const C=x.useCallback(async(U,Q=!1)=>{const J=++y.current;f(!0);let oe=null,me=null;try{oe=await cm(U)}catch(Se){if(me=hr(Se),Q&&U)try{oe=await cm(),me=null}catch(Me){me=hr(Me)}}J===y.current&&(oe&&c(oe),m(me),f(!1))},[]);x.useEffect(()=>{C(S,!0)},[C,S]);const b=l==null?void 0:l.path;x.useEffect(()=>{E.current&&(E.current.scrollTop=0)},[b]);const _=new Set(n.filter(U=>U.deleted===0).map(U=>gr(U.path)));async function z(U){if(!v){k(!0),m(null);try{const Q=await r(U);e(!1),o("success",`Workspace added — ${Q.path}`)}catch(Q){m(hr(Q)),k(!1)}}}const M=l?tj(l.path,l.home):[],L=((P=M.at(-1))==null?void 0:P.label)??"",G=l!==null&&_.has(gr(l.path));return a.jsx("div",{className:"dialog-overlay",onClick:T,children:a.jsxs("div",{className:"dialog folder-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"folder-dialog-title",onClick:U=>U.stopPropagation(),children:[a.jsxs("div",{className:"dialog-header",children:[a.jsx("span",{className:"dialog-title",id:"folder-dialog-title",children:"Add workspace"}),a.jsx("button",{className:"dialog-close",onClick:T,"aria-label":"Close",disabled:v,children:a.jsx(Tn,{size:16})})]}),a.jsxs("div",{className:"dialog-body",children:[a.jsxs("p",{className:"dialog-hint",children:["Choose a project folder",l&&a.jsxs(a.Fragment,{children:[" ","on ",a.jsx("strong",{children:l.hostname})]}),"."]}),a.jsxs("div",{className:"folder-nav",children:[a.jsx("button",{className:"folder-up",onClick:()=>(l==null?void 0:l.parent)&&void C(l.parent),disabled:!(l!=null&&l.parent),"aria-label":"Parent folder",title:"Parent folder",children:a.jsx(Mv,{size:14})}),a.jsx("nav",{className:"folder-crumbs","aria-label":"Folder path",children:M.map((U,Q)=>a.jsxs(x.Fragment,{children:[Q>0&&a.jsx(Li,{size:12,className:"folder-crumb-sep","aria-hidden":"true"}),Q===M.length-1?a.jsx("span",{className:"folder-crumb current","aria-current":"location",title:U.path,children:U.label}):a.jsx("button",{className:"folder-crumb",onClick:()=>void C(U.path),title:U.path,children:U.label})]},U.path))}),d&&l&&a.jsx(mn,{size:14,className:"spin folder-spinner","aria-label":"Loading"})]}),a.jsx("ul",{ref:E,className:`folder-list${d&&l?" loading":""}`,"aria-label":"Folders",children:l?l.folders.length===0?a.jsx("li",{className:"folder-empty",children:"No folders here."}):l.folders.map(U=>a.jsxs("li",{className:"folder-item",children:[a.jsxs("button",{className:"folder-row",onClick:()=>void C(U.path),title:U.path,"aria-label":U.git?`${U.name} (git repository)`:U.name,children:[U.git?a.jsx(j1,{size:15,className:"folder-icon git","aria-hidden":"true"}):a.jsx(Rl,{size:15,className:"folder-icon","aria-hidden":"true"}),a.jsx("span",{className:"folder-name",children:U.name}),a.jsx(Li,{size:13,className:"folder-chevron","aria-hidden":"true"})]}),_.has(gr(U.path))?a.jsx("span",{className:"folder-tag",children:"Added"}):a.jsx("button",{className:"folder-add",onClick:()=>void z(U.path),disabled:v,"aria-label":`Add ${U.name}`,children:"Add"})]},U.path)):d&&a.jsxs("li",{className:"folder-empty",role:"status",children:[a.jsx(mn,{size:14,className:"spin"})," Loading folders…"]})}),(l==null?void 0:l.truncated)&&a.jsxs("p",{className:"folder-note",children:["Showing the first ",l.folders.length," folders."]}),h&&a.jsx("p",{className:"folder-error",role:"alert",children:h})]}),a.jsxs("div",{className:"dialog-footer",children:[a.jsx("button",{className:"dialog-btn-cancel",onClick:T,disabled:v,children:"Cancel"}),a.jsx("button",{className:"dialog-btn-create",onClick:()=>l&&void z(l.path),disabled:!l||d||v||G,children:v?"Adding…":G?"Already added":`Add “${L}”`})]})]})})}const Wd=6e4,Hd=60*Wd,ul=24*Hd;function oj(e,n=Date.now()){const r=Date.parse(e);if(Number.isNaN(r))return"";const o=Math.max(0,n-r);return o<Wd?"just now":o<Hd?`${Math.floor(o/Wd)} min ago`:o<ul?`${Math.floor(o/Hd)} h ago`:o<2*ul?"yesterday":o<7*ul?`${Math.floor(o/ul)} days ago`:new Date(r).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function ij(){const e=R(n=>n.importSessionsWorkspace);return e?a.jsx(aj,{workspace:e},e):null}function aj({workspace:e}){const n=R(P=>P.setImportSessionsWorkspace),r=R(P=>P.importSessions),[o,l]=x.useState(null),[c,d]=x.useState(null),[f,h]=x.useState({}),[m,v]=x.useState(new Set),[k,y]=x.useState(!1),[S,E]=x.useState(new Map),T=x.useCallback(()=>{k||n(null)},[k,n]);Io(T),x.useEffect(()=>{let P=!1;return bv(e).then(({sessions:U,errors:Q})=>{if(P)return;const J=Object.values(Q);if(J.length===wd.length){d([...new Set(J)].join("; "));return}l(U),h(Q)}).catch(U=>{P||d(hr(U))}),()=>{P=!0}},[e]);function C(P){v(U=>{const Q=new Set(U);return Q.has(P)?Q.delete(P):Q.add(P),Q})}const b=o??[],_=P=>Qu({runtime:P.runtime,id:P.session_id}),z=b.length>0&&b.every(P=>m.has(_(P)));async function M(){const P=b.filter(J=>m.has(_(J))).map(J=>({runtime:J.runtime,id:J.session_id}));if(P.length===0)return;y(!0);const{failed:U}=await r(e,P);if(y(!1),U.length===0){n(null);return}const Q=new Set(U.map(Qu));l(J=>(J??[]).filter(oe=>!m.has(_(oe))||Q.has(_(oe)))),v(Q),E(new Map(U.map(J=>[Qu(J),J.error])))}const L=e.split("/").pop()||e,G=m.size;return a.jsx("div",{className:"dialog-overlay",onClick:T,children:a.jsxs("div",{className:"dialog import-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"import-dialog-title",onClick:P=>P.stopPropagation(),children:[a.jsxs("div",{className:"dialog-header",children:[a.jsx("span",{className:"dialog-title",id:"import-dialog-title",children:"Import sessions"}),a.jsx("button",{className:"dialog-close",onClick:T,"aria-label":"Close",disabled:k,children:a.jsx(Tn,{size:16})})]}),a.jsxs("div",{className:"dialog-body",children:[a.jsxs("p",{className:"dialog-hint",children:["Sessions you started with ",a.jsx("code",{children:"claude"})," or ",a.jsx("code",{children:"codex"})," in"," ",a.jsx("strong",{title:e,children:L}),", in a terminal or an IDE. An imported session keeps its history and continues the same conversation."]}),c?a.jsxs("p",{className:"import-error",role:"alert",children:["Could not list the sessions — ",c]}):o===null?a.jsxs("div",{className:"import-loading",role:"status",children:[a.jsx(mn,{size:14,className:"spin"})," Looking for sessions…"]}):o.length===0?a.jsxs("div",{className:"import-empty",children:["No Claude Code or Codex sessions to import here. Sessions you start with ",a.jsx("code",{children:"claude"})," or"," ",a.jsx("code",{children:"codex"})," in this folder will show up here.",a.jsx(Yg,{errors:f})]}):a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"import-select-all",children:[a.jsx("input",{type:"checkbox",checked:z,disabled:k,onChange:()=>v(z?new Set:new Set(b.map(_)))}),"Select all (",o.length,")"]}),a.jsx("ul",{className:"import-list",children:o.map(P=>{const U=_(P),Q=S.get(U);return a.jsx("li",{children:a.jsxs("label",{className:`import-row${m.has(U)?" selected":""}`,children:[a.jsx("input",{type:"checkbox",checked:m.has(U),disabled:k,onChange:()=>C(U)}),a.jsxs("span",{className:"import-row-main",children:[a.jsx("span",{className:"import-row-title",title:P.title,children:P.title}),a.jsxs("span",{className:"import-row-meta",children:[a.jsx("span",{className:`import-row-runtime ${P.runtime}`,children:Ql[P.runtime]}),a.jsx("span",{title:new Date(P.last_modified).toLocaleString(),children:oj(P.last_modified)}),P.git_branch&&a.jsxs("span",{className:"import-row-branch",title:"Git branch",children:[a.jsx(Pv,{size:10})," ",P.git_branch]})]}),P.recently_active&&a.jsxs("span",{className:"import-row-warn",children:[a.jsx(tc,{size:11})," Active in the last few minutes. If it is still open in a terminal, close it there first: both would write to the same session."]}),Q&&a.jsx("span",{className:"import-row-error",role:"alert",children:Q})]})]})},U)})}),a.jsx(Yg,{errors:f})]})]}),a.jsxs("div",{className:"dialog-footer",children:[a.jsx("button",{className:"dialog-btn-cancel",onClick:T,disabled:k,children:"Cancel"}),a.jsx("button",{className:"dialog-btn-create",onClick:()=>void M(),disabled:G===0||k,children:k?a.jsxs(a.Fragment,{children:[a.jsx(mn,{size:12,className:"spin"})," Importing…"]}):G>1?`Import ${G} sessions`:"Import"})]})]})})}function Yg({errors:e}){const n=Object.entries(e);return n.length===0?null:a.jsx(a.Fragment,{children:n.map(([r,o])=>a.jsxs("p",{className:"import-note",children:["Could not list the ",Ql[r]," sessions — ",o]},r))})}const lj=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,cj=512*1024;function uj(e){const n=e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"");return/^[a-z0-9]/.test(n)?n:""}function dj(){const{appCatalogOpen:e,closeAppCatalog:n,apps:r,installExampleApp:o,createSkeletonApp:l,importAppFolder:c}=R(),[d,f]=x.useState("examples"),[h,m]=x.useState(null),[v,k]=x.useState(null),[y,S]=x.useState(!1),[E,T]=x.useState(""),[C,b]=x.useState(""),[_,z]=x.useState(""),[M,L]=x.useState(""),[G,P]=x.useState(null),[U,Q]=x.useState(""),J=x.useRef(null);if(x.useEffect(()=>{e&&(m(null),Uk().then(m).catch(()=>m([])))},[e]),x.useEffect(()=>{J.current&&(J.current.webkitdirectory=!0)},[d]),!e)return null;const oe=new Set(r.map(F=>F.id));async function me(F){k(F);try{await o(F)&&n()}finally{k(null)}}async function Se(){if(y)return;const F=E.trim(),Z=C.trim();if(!(!F||!Z)){S(!0);try{await l({id:F,title:Z,description:_.trim()||void 0,icon:M.trim()||void 0})&&(T(""),b(""),z(""),L(""),n())}finally{S(!1)}}}async function Me(F){const Z=Array.from(F.target.files??[]),q={};let I="";for(const $ of Z){const B=($.webkitRelativePath??"").split("/");!I&&B.length>1&&(I=B[0]);const X=B[B.length-1];if(!(!X||!lj.test(X))&&!($.size>cj))try{q[X]=await $.text()}catch{}}P(Object.keys(q).length>0?q:null),Q(uj(I))}async function ee(){if(!(y||!G||!U.trim())){S(!0);try{await c(U.trim(),G)&&(P(null),Q(""),n())}finally{S(!1)}}}function ie(F){F.key==="Escape"&&n()}const te=[{key:"examples",label:"Examples"},{key:"new",label:"New App"},{key:"upload",label:"Upload"}];return a.jsx("div",{className:"dialog-overlay",onClick:n,children:a.jsxs("div",{className:"dialog app-catalog",onClick:F=>F.stopPropagation(),onKeyDown:ie,children:[a.jsxs("div",{className:"dialog-header",children:[a.jsx("span",{className:"dialog-title",children:"Add Mini App"}),a.jsx("button",{className:"dialog-close",onClick:n,children:"✕"})]}),a.jsx("div",{className:"catalog-tabs",children:te.map(F=>a.jsx("button",{className:`catalog-tab${d===F.key?" active":""}`,onClick:()=>f(F.key),children:F.label},F.key))}),a.jsxs("div",{className:"dialog-body catalog-body",children:[d==="examples"&&a.jsx("div",{className:"catalog-examples",children:h===null?a.jsx("div",{className:"empty-state",style:{padding:"12px"},children:"Loading examples…"}):h.length===0?a.jsx("div",{className:"empty-state",style:{padding:"12px"},children:"No example apps available."}):h.map(F=>{const Z=oe.has(F.id);return a.jsxs("div",{className:"example-row",children:[a.jsx(Do,{iconNode:F.iconNode,size:14,className:"sidebar-app-icon"}),a.jsxs("div",{className:"example-info",children:[a.jsx("span",{className:"example-title",children:F.title}),F.description&&a.jsx("span",{className:"example-desc",children:F.description})]}),a.jsx("button",{className:"example-install",disabled:Z||v===F.id,onClick:()=>me(F.id),title:Z?"Already installed":"Install this example",children:Z?"Installed":v===F.id?"Installing…":"Install"})]},F.id)})}),d==="new"&&a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"dialog-label",children:["App id (folder name)",a.jsx("input",{className:"dialog-input",type:"text",value:E,onChange:F=>T(F.target.value),placeholder:"e.g. todo-list",autoFocus:!0})]}),a.jsxs("label",{className:"dialog-label",children:["Title",a.jsx("input",{className:"dialog-input",type:"text",value:C,onChange:F=>b(F.target.value),placeholder:"e.g. Todo List"})]}),a.jsxs("label",{className:"dialog-label",children:["Description (optional)",a.jsx("input",{className:"dialog-input",type:"text",value:_,onChange:F=>z(F.target.value),placeholder:"What does this app do?"})]}),a.jsxs("label",{className:"dialog-label",children:[a.jsxs("span",{children:["Icon (optional, a"," ",a.jsx("a",{href:"https://lucide.dev/icons",target:"_blank",rel:"noreferrer",children:"Lucide icon"})," ","name)"]}),a.jsx("input",{className:"dialog-input",type:"text",value:M,onChange:F=>L(F.target.value),placeholder:"e.g. notebook-pen",spellCheck:!1,autoCapitalize:"off"})]}),a.jsxs("button",{className:"dialog-btn-create catalog-action-btn",disabled:y||!E.trim()||!C.trim(),onClick:Se,children:[a.jsx(pr,{size:13})," Create App"]})]}),d==="upload"&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"catalog-upload-hint",children:"Select an app folder from disk. Text files only (manifest.json, index.html, app.ts (or legacy app.js), …). A missing manifest.json is generated from the folder name."}),a.jsx("input",{ref:J,type:"file",multiple:!0,onChange:Me}),G&&a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"dialog-label",children:["App id",a.jsx("input",{className:"dialog-input",type:"text",value:U,onChange:F=>Q(F.target.value)})]}),a.jsxs("div",{className:"catalog-upload-summary",children:[Object.keys(G).length," file(s):"," ",Object.keys(G).slice(0,6).join(", "),Object.keys(G).length>6?", …":""]})]}),a.jsxs("button",{className:"dialog-btn-create catalog-action-btn",disabled:y||!G||!U.trim(),onClick:ee,children:[a.jsx(Z1,{size:13})," Import App"]})]})]}),a.jsx("div",{className:"dialog-footer",children:a.jsx("button",{className:"dialog-btn-cancel",onClick:n,children:"Close"})})]})})}function fj(){const e=R(k=>k.showCommandPalette),n=R(k=>k.setShowCommandPalette),r=R(),[o,l]=x.useState(""),[c,d]=x.useState(0),f=x.useRef(null),h=x.useMemo(()=>{const k=r.activeSessionId?r.sessionDetails[r.activeSessionId]:null,y=ql(k);return[{id:"new-session",label:"New Session",hint:"Create a new Codex session",icon:pr,action:()=>r.setShowNewSessionDialog(!0),available:!0},{id:"delete-session",label:"Delete Session",hint:"Delete the active session",icon:us,action:()=>{r.activeSessionId&&r.deleteSession(r.activeSessionId)},available:!!r.activeSessionId},{id:"send-message",label:"Send Message",hint:"Focus the message input",icon:Hi,action:()=>{const S=document.querySelector(".cmd-input");S==null||S.focus()},available:!!r.activeSessionId&&!y},{id:"cancel-turn",label:"Cancel Turn",hint:"Cancel the running turn",icon:yr,action:()=>r.cancelTurn(),available:y},{id:"tab-turns",label:"Switch to Turns Tab",hint:"View conversation timeline",icon:O1,action:()=>r.switchRightTab("turns"),available:!!r.activeSessionId},{id:"tab-sidecar",label:"Ask Sidecar",hint:"Ask about this session — status, blockers, what is left",icon:vr,action:()=>r.switchRightTab("sidecar"),available:!!r.activeSessionId},{id:"toggle-right-panel",label:"Toggle Right Panel",hint:r.rightPanelCollapsed?"Expand the right panel":"Collapse the right panel to its icon rail",icon:W1,action:()=>r.toggleRightPanel(),available:!0},{id:"close-tab",label:"Close Tab",hint:"Close the active session tab",icon:Tn,action:()=>{r.activeSessionId&&r.closeTab(r.activeSessionId)},available:!!r.activeSessionId}]},[r]),m=x.useMemo(()=>{const k=o.toLowerCase().trim(),y=h.filter(S=>S.available);return k?y.filter(S=>S.label.toLowerCase().includes(k)||S.hint.toLowerCase().includes(k)):y},[h,o]);x.useEffect(()=>{e&&(l(""),d(0),setTimeout(()=>{var k;return(k=f.current)==null?void 0:k.focus()},50))},[e]);function v(k){if(k.key==="ArrowDown")k.preventDefault(),d(y=>Math.min(y+1,m.length-1));else if(k.key==="ArrowUp")k.preventDefault(),d(y=>Math.max(y-1,0));else if(k.key==="Enter"){k.preventDefault();const y=m[c];y&&(y.action(),n(!1))}else k.key==="Escape"&&n(!1)}return e?a.jsx("div",{className:"palette-overlay",onClick:()=>n(!1),children:a.jsxs("div",{className:"palette",onClick:k=>k.stopPropagation(),children:[a.jsxs("div",{className:"palette-search",children:[a.jsx("input",{ref:f,type:"text",placeholder:"Type a command…",value:o,onChange:k=>{l(k.target.value),d(0)},onKeyDown:v}),a.jsx("span",{className:"palette-esc",children:"ESC"})]}),m.length===0?a.jsx("div",{className:"palette-empty",children:"No matching commands"}):a.jsx("div",{className:"palette-list",children:m.map((k,y)=>{const S=k.icon;return a.jsxs("div",{className:`palette-item ${y===c?"selected":""}`,onClick:()=>{k.action(),n(!1)},onMouseEnter:()=>d(y),children:[a.jsx("span",{className:"palette-item-icon",children:a.jsx(S,{size:16})}),a.jsx("span",{className:"palette-item-label",children:k.label}),a.jsx("span",{className:"palette-item-hint",children:k.hint}),y===c&&a.jsx(T1,{size:12,className:"palette-item-enter"})]},k.id)})}),a.jsxs("div",{className:"palette-footer",children:[a.jsxs("span",{className:"palette-footer-hint",children:[a.jsx("span",{className:"kbd",children:"↑"}),a.jsx("span",{className:"kbd",children:"↓"})," Navigate"]}),a.jsxs("span",{className:"palette-footer-hint",children:[a.jsx("span",{className:"kbd",children:"↵"})," Select"]}),a.jsxs("span",{className:"palette-footer-hint",children:[a.jsx("span",{className:"kbd",children:"Esc"})," Close"]})]})]})}):null}const Qg=/^[a-z][a-z0-9-]{1,30}$/,pj=2e3;function hj(){const{showRemoteModal:e,setShowRemoteModal:n,selectSession:r}=R(),[o,l]=x.useState(null),[c,d]=x.useState(null),[f,h]=x.useState(!1),[m,v]=x.useState(!1),[k,y]=x.useState(!1),[S,E]=x.useState(!1),[T,C]=x.useState("main"),[b,_]=x.useState(""),[z,M]=x.useState(!1),[L,G]=x.useState(null),P=x.useRef(null);Wi(P,()=>E(!1),S);const U=m||k,Q=x.useCallback(async()=>{h(!0),d(null);try{const F=await fetch(`${rn()}/remote/status`,{headers:{Accept:"application/json"}});if(!F.ok)throw new Error(`status ${F.status}`);l(await F.json())}catch{l(null),d("Machine management is only available from this machine's local pane.")}finally{h(!1)}},[]);x.useEffect(()=>{e&&(C("main"),G(null),Q())},[e,Q]);const J=L!==null&&L.state==="running";if(x.useEffect(()=>{if(!J)return;const F=setInterval(async()=>{try{const Z=await fetch(`${rn()}/remote/enable`,{headers:{Accept:"application/json"}});Z.ok&&G(await Z.json())}catch{}},pj);return()=>clearInterval(F)},[J]),!e)return null;const oe=!!(o!=null&&o.tunnel.provisioned)&&!!(o!=null&&o.service.running)&&!!(o!=null&&o.connection.ok);function me(F){F.key==="Escape"&&n(!1)}async function Se(F){if(Qg.test(F)){M(!0);try{const Z=await fetch(`${rn()}/remote/enable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mahlas:F})});if(!Z.ok)throw new Error(`enable ${Z.status}`);G(await Z.json()),C("setup")}catch{d("Could not start the setup — check the daemon logs.")}finally{M(!1)}}}function Me(){L!=null&&L.troubleshootingSessionId&&(r(L.troubleshootingSessionId),n(!1))}async function ee(){v(!0);try{await fetch(`${rn()}/remote/disable`,{method:"POST"}),await Q()}catch{d("Could not stop the tunnel service — check the service logs.")}finally{v(!1)}}async function ie(){if(E(!1),!!window.confirm(`Remove the tunnel completely?
837
837
 
838
- This deletes the Cloudflare tunnel, its DNS record and Access app, and this machine's remote state. The mahlas is released.
838
+ This deletes the Cloudflare tunnel, its DNS record and sign-in sessions, and this machine's remote state. The mahlas is released.
839
839
 
840
840
  This cannot be undone.`)){y(!0);try{const Z=await fetch(`${rn()}/remote/uninstall`,{method:"DELETE"});if(!Z.ok)throw new Error(`uninstall ${Z.status}`);await Q()}catch{d("Could not remove the tunnel — check the daemon logs.")}finally{y(!1)}}}function te(){if(!L)return a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"dialog-label",children:["Machine name (mahlas)",a.jsx("input",{className:"dialog-input",value:b,onChange:I=>_(I.target.value.toLowerCase()),placeholder:"my-macbook",autoFocus:!0})]}),a.jsx("div",{className:"dialog-label",style:{opacity:.7,marginTop:-4},children:"The machine will be reachable at https://<name>.repoburg.com"}),a.jsxs("div",{className:"dialog-footer",children:[a.jsx("button",{className:"dialog-btn-cancel",onClick:()=>C("main"),children:"Back"}),a.jsxs("button",{className:"dialog-btn-create",disabled:!Qg.test(b)||z,onClick:()=>void Se(b),children:[z?a.jsx(mn,{size:14,className:"spin",style:{verticalAlign:"middle",marginRight:6}}):null,"Start setup"]})]})]});const F=["detect","provision","install","verify","ready"],Z=F.indexOf(L.step),q=L.state==="ready";return a.jsxs(a.Fragment,{children:[L.state==="running"&&a.jsxs("div",{className:"dialog-label",style:{display:"flex",alignItems:"center",gap:6},children:[a.jsx(mn,{size:14,className:"spin"})," Setting up the remote tunnel…"]}),L.state==="ready"&&a.jsxs("div",{className:"dialog-label",style:{color:"var(--green)",display:"flex",alignItems:"center",gap:6},children:[a.jsx(Cs,{size:14})," Setup complete — you can close this window."]}),L.state==="ready"&&L.hostname&&a.jsxs("div",{className:"dialog-label",children:["This machine is accessible at"," ",a.jsx("a",{href:`https://${L.hostname}`,target:"_blank",rel:"noreferrer",children:L.hostname})]}),a.jsx("ol",{className:"dialog-label",style:{margin:"4px 0",paddingLeft:0,listStyle:"none"},children:F.map((I,$)=>{const ue=q||Z>-1&&$<Z,B=!q&&$===Z&&L.state==="running";return a.jsxs("li",{style:{display:"flex",alignItems:"center",gap:6,opacity:ue||B?1:.4,color:ue?"var(--green)":void 0},children:[ue?a.jsx(Cs,{size:13}):B?a.jsx(mn,{size:13,className:"spin"}):a.jsx(b1,{size:9,style:{marginLeft:2,marginRight:2}}),I]},I)})}),L.logs.length>0&&a.jsx("div",{className:"dialog-label",style:{opacity:.7,fontSize:12,whiteSpace:"pre-wrap"},children:L.logs.slice(-3).map(I=>I.message).join(`
841
841
  `)}),L.state==="troubleshooting"&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"dialog-label",style:{color:"var(--red)"},children:"Setup failed — a troubleshooting session is open and the agent is working on the fix in the background."}),a.jsx("div",{className:"dialog-footer",children:a.jsx("button",{className:"dialog-btn-create",onClick:Me,children:"Open troubleshooting session"})})]}),L.state==="failed"&&a.jsxs("div",{className:"dialog-label",style:{color:"var(--red)"},children:["Setup failed: ",L.error]}),a.jsx("div",{className:"dialog-footer",children:a.jsx("button",{className:"dialog-btn-cancel",onClick:()=>void Q(),children:"Refresh status"})})]})}return a.jsx("div",{className:"dialog-overlay",onClick:()=>n(!1),children:a.jsxs("div",{className:"dialog",onClick:F=>F.stopPropagation(),onKeyDown:me,children:[a.jsxs("div",{className:"dialog-header",children:[a.jsx("span",{className:"dialog-title",children:"Remote Access"}),a.jsx("button",{className:"dialog-close",onClick:()=>n(!1),children:a.jsx(Tn,{size:16})})]}),a.jsxs("div",{className:"dialog-body",children:[f&&a.jsxs("div",{className:"dialog-label",style:{display:"flex",alignItems:"center",gap:6},children:[a.jsx(mn,{size:14,className:"spin"})," Loading machine status…"]}),c&&a.jsx("div",{className:"dialog-label",style:{color:"var(--red)"},children:c}),T==="setup"?te():a.jsxs(a.Fragment,{children:[oe&&(o==null?void 0:o.tunnel.hostname)&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"dialog-label",children:["This machine is reachable at"," ",a.jsx("a",{href:`https://${o.tunnel.hostname}`,target:"_blank",rel:"noreferrer",children:o.tunnel.hostname})]}),a.jsxs("div",{style:{position:"relative",display:"flex",marginTop:8},children:[a.jsxs("button",{className:"dialog-btn-cancel",style:{flex:1,borderTopRightRadius:0,borderBottomRightRadius:0},onClick:()=>void ee(),disabled:U,children:[m?a.jsx(mn,{size:14,className:"spin",style:{verticalAlign:"middle",marginRight:6}}):null,"Stop tunnel connection"]}),a.jsx("button",{className:"dialog-btn-cancel",style:{width:30,borderLeft:"none",borderTopLeftRadius:0,borderBottomLeftRadius:0,display:"inline-flex",alignItems:"center",justifyContent:"center"},onClick:()=>E(F=>!F),disabled:U,"aria-label":"More tunnel actions","aria-haspopup":"menu","aria-expanded":S,children:k?a.jsx(mn,{size:14,className:"spin"}):a.jsx(_o,{size:14})}),S&&a.jsx("div",{ref:P,className:"ctx-menu",role:"menu",style:{position:"absolute",right:0,top:"calc(100% + 4px)",zIndex:10},children:a.jsxs("div",{className:"ctx-menu-item ctx-danger",role:"menuitem",onClick:()=>void ie(),children:[a.jsx(us,{size:12})," Remove tunnel"]})})]})]}),!oe&&a.jsx(a.Fragment,{children:o!=null&&o.tunnel.provisioned&&o.tunnel.mahlas&&o.tunnel.hostname?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"dialog-label",children:["Tunnel exists as"," ",a.jsx("a",{href:`https://${o.tunnel.hostname}`,target:"_blank",rel:"noreferrer",children:o.tunnel.hostname})," ","but the connection is stopped."]}),a.jsxs("button",{className:"dialog-btn-create",style:{width:"100%"},onClick:()=>void Se(o.tunnel.mahlas),disabled:z,children:[z?a.jsx(mn,{size:14,className:"spin",style:{verticalAlign:"middle",marginRight:6}}):a.jsx(Lm,{size:16,style:{verticalAlign:"middle",marginRight:6}}),"Resume tunnel connection"]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("button",{className:"dialog-btn-create",style:{width:"100%"},onClick:()=>C("setup"),children:[a.jsx(Lm,{size:16,style:{verticalAlign:"middle",marginRight:6}}),"Make this machine remote"]}),a.jsx("div",{className:"dialog-label",style:{opacity:.7,marginTop:-4},children:"The daemon sets everything up and shows the progress here."})]})})]})]})]})})}const mj={success:k1,error:Jl,info:R1,warn:tc},gj=4e3;function vj({toast:e}){const n=R(d=>d.removeToast),r=mj[e.type],o=x.useRef(null);x.useEffect(()=>{function d(){o.current=setTimeout(()=>n(e.id),gj)}return d(),()=>{o.current&&clearTimeout(o.current)}},[e.id,n]);function l(){o.current&&(clearTimeout(o.current),o.current=null)}function c(){o.current=setTimeout(()=>n(e.id),2e3)}return a.jsxs("div",{className:`toast toast-${e.type}`,onMouseEnter:l,onMouseLeave:c,children:[a.jsx(r,{size:16}),a.jsx("span",{className:"toast-message",children:e.message}),e.undoAction&&a.jsxs("button",{className:"toast-undo",onClick:()=>{var d;(d=e.undoAction)==null||d.call(e),n(e.id)},children:[a.jsx(Q1,{size:12})," ",e.undoLabel||"Undo"]}),a.jsx("button",{className:"toast-close",onClick:()=>n(e.id),children:a.jsx(Tn,{size:14})})]})}function yj(){const e=R(n=>n.toasts);return e.length===0?null:a.jsx("div",{className:"toast-container",children:e.map(n=>a.jsx(vj,{toast:n},n.id))})}function xj(){const[e]=x.useState(Sk),[n,r]=x.useState(!1),[o,l]=x.useState(!1),c=x.useRef(void 0);x.useEffect(()=>()=>clearTimeout(c.current),[]);async function d(){await Fi(wm)&&(r(!0),l(!0),clearTimeout(c.current),c.current=setTimeout(()=>r(!1),1500))}return a.jsxs("main",{className:"daemon-download",children:[a.jsx("h1",{className:"daemon-download-title",children:"Repoburg"}),e&&a.jsx("p",{className:"daemon-download-text",children:"Open the Repoburg app to continue."}),a.jsxs("div",{className:"daemon-download-install",children:[e&&a.jsx("p",{className:"daemon-download-label",children:"Not installed? Run this in Terminal:"}),a.jsxs("div",{className:"daemon-download-cmd",onCopy:()=>l(!0),children:[a.jsx("span",{className:"daemon-download-prompt","aria-hidden":"true",children:"$"}),a.jsx("code",{children:wm}),a.jsx("button",{type:"button",className:`daemon-download-copy${n?" copied":""}`,onClick:()=>void d(),"aria-label":"Copy the install command",title:n?"Copied":"Copy",children:n?a.jsx(Cs,{size:15}):a.jsx(Oi,{size:15})})]}),!e&&a.jsx("p",{className:"daemon-download-meta",children:"Apple Silicon · macOS 13+"})]}),o&&a.jsx("p",{className:"daemon-download-hint",children:"Paste it into Terminal and press Return. Repoburg installs and opens in your menu bar."}),(e||o)&&a.jsxs("p",{className:"daemon-download-waiting",role:"status",children:[a.jsx(mn,{size:13,className:"spin"}),"Waiting for Repoburg to start…"]})]})}let Jn=null,Ao=null,Ai=1e3;const wj=1e4;function Vd(){Jn&&(Jn.readyState===WebSocket.OPEN||Jn.readyState===WebSocket.CONNECTING)||(Jn=new WebSocket(uw("/ws")),Jn.onopen=()=>{const e=Ai>1e3;if(Ai=1e3,R.getState().setWsConnected(!0),R.getState().addLogEntry("INFO","WebSocket connected"),e){Zw();const n=R.getState();n.activeSessionId&&(n.refreshActiveSession(),n.addToast("info","WebSocket reconnected — session state reconciled"))}},Jn.onclose=()=>{R.getState().setWsConnected(!1),R.getState().addLogEntry("WARN","WebSocket disconnected"),R.getState().addToast("warn","WebSocket disconnected — reconnecting…"),Sj()},Jn.onerror=()=>{},Jn.onmessage=e=>{try{const n=JSON.parse(e.data);Lt.trackWsEvent(typeof n.event=="string"?n.event:"unknown",typeof e.data=="string"?e.data.length:0);const r=bj[n.event];r&&r(n.data)}catch{}})}function kj(){Ao&&(clearTimeout(Ao),Ao=null),Jn&&(Jn.onclose=null,Jn.close(),Jn=null),R.getState().setWsConnected(!1)}function Sj(){Ao||(Ao=window.setTimeout(()=>{Ao=null,Vd()},Ai),Ai=Math.min(Ai*2,wj))}const bj={"turn:created":e=>{const n=e;R.getState().onTurnCreated(n.sessionId,n.turn)},"turn:started":e=>{const n=e;Lt.note(`turn:started — ${n.turnId.slice(0,8)}`),R.getState().onTurnStarted(n.sessionId,n.turnId)},"item:started":e=>{const n=e;Vu(n.sessionId,n.turnId,n.item),R.getState().onItemStarted(n.sessionId,n.turnId,n.item)},"item:updated":e=>{const n=e;Vu(n.sessionId,n.turnId,n.item),R.getState().onItemUpdated(n.sessionId,n.turnId,n.item)},"item:completed":e=>{const n=e;Vu(n.sessionId,n.turnId,n.item),R.getState().onItemCompleted(n.sessionId,n.turnId,n.item)},"item:delta":e=>{const n=e,r=hw(n.sessionId,n.turnId,n.itemId,n.delta);R.getState().onItemDelta(n.sessionId,n.turnId,n.itemId,n.delta,r)},"streams:snapshot":e=>{const n=e,r=R.getState();for(const o of mw(n.sessionId??null,Array.isArray(n.streams)?n.streams:[]))r.onItemText(o.sessionId,o.turnId,o.itemId,o.text)},"widget:delta":e=>{const n=e;typeof n.itemId!="string"||typeof n.html!="string"||R.getState().onWidgetDelta(n.sessionId,n.turnId,n.itemId,typeof n.title=="string"?n.title:"",n.html)},"turn:completed":e=>{const n=e;Lt.note(`turn:completed — ${n.turnId.slice(0,8)}`),gi(n.sessionId,n.turnId),R.getState().onTurnCompleted(n.sessionId,n.turnId,n.usage,n.hasUnreviewed,n.response??void 0)},"turn:tokenUsage":e=>{const n=e;R.getState().onTokenUsageUpdated(n.sessionId,n.turnId,n.usage)},"turn:contextUsage":e=>{const n=e,r={totalTokens:n.totalTokens,contextWindow:n.contextWindow,percentage:n.percentage,...n.autoCompactThreshold?{autoCompactThreshold:n.autoCompactThreshold}:{}};R.getState().onContextUsageUpdated(n.sessionId,r)},"turn:failed":e=>{const n=e;gi(n.sessionId,n.turnId),R.getState().onTurnFailed(n.sessionId,n.turnId,n.error,n.resumeState)},"turn:interrupted":e=>{const n=e;Lt.note(`turn:interrupted — ${n.turnId.slice(0,8)} (${n.reason})`),gi(n.sessionId,n.turnId),R.getState().onTurnInterrupted(n.sessionId,n.turnId,{reason:n.reason,interruptedAt:n.interruptedAt,attempts:n.attempts,detail:n.detail??null,resumeAt:n.resumeAt??null})},"turn:resuming":e=>{const n=e;gi(n.sessionId,n.turnId),R.getState().onTurnResuming(n.sessionId,n.turnId,n.attempt)},"turn:resumed":e=>{const n=e;R.getState().onTurnResumed(n.sessionId,n.turnId)},"turn:retrying":e=>{const n=e;R.getState().onTurnRetrying(n.sessionId,n.turnId,{attempt:n.attempt,maxRetries:n.maxRetries,retryDelayMs:n.retryDelayMs,errorStatus:n.errorStatus??null,error:n.error??null})},"turn:cancelled":e=>{const n=e;gi(n.sessionId,n.turnId),R.getState().onTurnCancelled(n.sessionId,n.turnId)},"session:title":e=>{const n=e;R.getState().onSessionTitle(n.sessionId,n.title)},"session:touched":e=>{const n=e;R.getState().onSessionTouched(n.sessionId)},"session:created":e=>{const{session:n}=e;n.origin_app_id&&dl(n.id,n.origin_app_id),R.getState().addSession(n)},"session:resync":e=>{const n=e,r=R.getState();r.activeSessionId===n.sessionId&&r.refreshActiveSession()},"session:updated":e=>{const n=e;R.getState().onSessionUpdated(n.session)},background_tasks:e=>{const n=e;Lt.note(`background_tasks — ${n.tasks.length} live (${n.tasks.map(r=>r.task_type).join(", ")||"none"})`),R.getState().onBackgroundTasksChanged(n.sessionId,n.tasks)},"background_tasks:snapshot":e=>{const n=e;R.getState().onBackgroundTasksSnapshot(n.sessions??{})},"signed_out_turns:snapshot":e=>{const n=e;R.getState().onSignedOutTurnsSnapshot(n.turns??[])},"thread:created":e=>{const n=e;R.getState().onThreadCreated(n.sessionId,n.thread,n.turn)},"thread:followup":e=>{const n=e;R.getState().onThreadFollowup(n.sessionId,n.threadId,n.turn)},"thread:resolved":e=>{const n=e;R.getState().onThreadResolved(n.sessionId,n.threadId,n.status)},"thread:deleted":e=>{const n=e;R.getState().onThreadDeleted(n.sessionId,n.threadId)},"app:tool_call":e=>{const n=e;Kw(n.appId,n.callId,n.tool,n.args??{},n.workspace,n.caller)},"app:source:updated":e=>{Jw(e.appId),R.getState().refreshApps()},"app:state_changed":e=>{const{appId:n,...r}=e;kv(n,r)}};function Nj(){const e=R(n=>n.init);return x.useEffect(()=>{lw();function n(){e(),Vd()}const{daemonStatus:r,setDaemonStatus:o}=R.getState();let l=null;r==="ready"?n():l=Nk({onMissing:()=>o("missing"),onReady:()=>{o("ready"),n()}});function c(){if(document.visibilityState!=="visible")return;const d=R.getState(),f=d.activeSessionId;if(!f)return;const h=d.sessionDetails[f];d.wsConnected||Vd(),h&&h.is_running===1&&(d.refreshActiveSession(),d.addLogEntry("INFO","Tab returned — reconciling session state"))}return document.addEventListener("visibilitychange",c),()=>{l==null||l(),kj(),document.removeEventListener("visibilitychange",c)}},[e]),null}const ax="agentpaneView";function Kd(e){return{tab:Xd(e),vscode:e.vscodeViewOpen,usage:e.usageViewOpen,terminal:e.terminalViewOpen}}function lx(e,n){return e.tab===n.tab&&e.vscode===n.vscode&&e.usage===n.usage&&e.terminal===n.terminal}function Zg(e){return e.tab===null&&!e.vscode&&!e.usage&&!e.terminal}function Jg(e,n){return n.tab!==null&&!e.tabOrder.includes(n.tab)?!1:!lx(n,Kd(e))}function ev(e){const n=e==null?void 0:e[ax];return typeof(n==null?void 0:n.index)!="number"?null:{...n,view:{...n.view,terminal:!!n.view.terminal}}}function Tj(e,n){e.getState().vscodeViewOpen!==n.vscode&&e.getState().toggleVscodeView(),e.getState().usageViewOpen!==n.usage&&e.getState().toggleUsageView(),e.getState().terminalViewOpen!==n.terminal&&e.getState().toggleTerminalView();const r=e.getState();if(n.tab===null)return;const{kind:o,id:l}=mr(n.tab);o==="app"?r.openAppTab(l):r.activeSessionId===l?r.setActiveAppTab(null):r.selectSession(l)}function Cj(e){let n=ev(window.history.state)??{index:0,newest:0,view:Kd(e.getState())},r=n.newest,o=!1;const l=new Map([[n.index,n.view]]),c=y=>{const S=e.getState();for(let E=n.index+y;E>=0&&E<=r;E+=y){const T=l.get(E);if(!T||Jg(S,T))return!0}return!1},d=()=>{const y=c(-1),S=c(1),E=e.getState();(E.canGoBack!==y||E.canGoForward!==S)&&e.setState({canGoBack:y,canGoForward:S})},f=()=>({[ax]:{...n,newest:r}}),h=()=>{window.history.replaceState({...window.history.state,...f()},"")},m=y=>{if(l.set(n.index,n.view),Zg(n.view))n={...n,view:y},h();else{n={index:n.index+1,newest:n.index+1,view:y},r=n.index;for(const S of l.keys())S>r&&l.delete(S);window.history.pushState(f(),"")}l.set(n.index,y)},v=y=>{const S=ev(y.state);if(!S)return;l.set(S.index,S.view),r=Math.max(r,S.index);const E=e.getState(),T=Math.sign(S.index-n.index);if(T!==0&&!Jg(E,S.view)){const C=S.index+T;window.history.go(C<0||C>r?n.index-S.index:T);return}n=S,h(),o=!0;try{Tj(e,S.view)}finally{o=!1}d()};h(),d(),window.addEventListener("popstate",v);const k=e.subscribe((y,S)=>{const E=y.activeSessionId!==S.activeSessionId||y.activeAppTabId!==S.activeAppTabId||y.vscodeViewOpen!==S.vscodeViewOpen||y.usageViewOpen!==S.usageViewOpen||y.terminalViewOpen!==S.terminalViewOpen;if(!(!E&&y.tabOrder===S.tabOrder)){if(E&&!o){const T=Kd(y);!Zg(T)&&!lx(T,n.view)&&m(T)}d()}});return()=>{k(),window.removeEventListener("popstate",v)}}function Ej(){const e=R(c=>c.loading),n=R(c=>c.error),r=R(c=>c.sessions),o=R(c=>c.daemonStatus),l=R(c=>c.setShowCommandPalette);return x.useEffect(()=>Lt.start(),[]),x.useEffect(()=>Cj(R),[]),x.useEffect(()=>{function c(d){(d.metaKey||d.ctrlKey)&&d.key==="k"&&(d.preventDefault(),l(!0))}return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[l]),a.jsxs(a.Fragment,{children:[a.jsx(Nj,{}),o==="missing"?a.jsx(xj,{}):o==="checking"||e&&r.length===0?a.jsx("div",{className:"empty-state",children:"Loading sessions…"}):n&&r.length===0?a.jsxs("div",{className:"empty-state",children:["Error: ",n]}):a.jsxs(a.Fragment,{children:[a.jsx(JE,{}),a.jsx(ej,{}),a.jsx(sj,{}),a.jsx(ij,{}),a.jsx(dj,{}),a.jsx(hj,{}),a.jsx(fj,{}),a.jsx(yj,{})]})]})}Q0.createRoot(document.getElementById("root")).render(a.jsx(ct.StrictMode,{children:a.jsx(Ej,{})}));export{$i as R,Tn as X,uw as b,ye as c,a as j,x as r,R as u};
@@ -10,7 +10,7 @@
10
10
  href="https://fonts.googleapis.com/css2?family=Inter:wght@400;450;510;590;600&family=JetBrains+Mono:wght@400;500&display=swap"
11
11
  rel="stylesheet"
12
12
  />
13
- <script type="module" crossorigin src="/assets/index-NpywVkQl.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-7ikRAI4J.js"></script>
14
14
  <link rel="stylesheet" crossorigin href="/assets/index-wFHgyM6i.css">
15
15
  </head>
16
16
  <body>
@@ -18,7 +18,6 @@ const mcp_gateway_1 = require("./mcp-gateway");
18
18
  const agentPane_1 = require("./agentPane");
19
19
  const routes_1 = require("./remote/routes");
20
20
  const checkRemoteAuth_1 = require("./middleware/checkRemoteAuth");
21
- const edge_gate_move_1 = require("./remote/edge-gate-move");
22
21
  const staticServing_1 = require("./staticServing");
23
22
  const router_1 = require("./recorder/router");
24
23
  const tabtape_1 = require("./tabtape");
@@ -168,8 +167,6 @@ async function main() {
168
167
  console.log(`Repoburg Platform Daemon listening on http://127.0.0.1:${PORT}`);
169
168
  console.log(`MCP Gateway available at http://localhost:${PORT}/mcp`);
170
169
  tabtape = loadTabtape();
171
- // A tunnel still behind Cloudflare Access moves to the edge gate.
172
- (0, edge_gate_move_1.scheduleEdgeGateMove)();
173
170
  // Adopt the agents the previous daemon left running in session hosts and
174
171
  // resume the turns it left interrupted (restart, crash, power loss) —
175
172
  // only now that the port is ours.
@@ -4,7 +4,6 @@ exports.remoteAuthFailure = remoteAuthFailure;
4
4
  exports.checkRemoteAuth = checkRemoteAuth;
5
5
  exports.checkRemoteWsAuth = checkRemoteWsAuth;
6
6
  const tunnel_state_1 = require("../remote/tunnel-state");
7
- const access_jwt_1 = require("../remote/access-jwt");
8
7
  const edge_jwt_1 = require("../remote/edge-jwt");
9
8
  const originGuard_1 = require("./originGuard");
10
9
  /**
@@ -20,12 +19,9 @@ const originGuard_1 = require("./originGuard");
20
19
  * - a host of REPOBURG_ALLOWED_ORIGINS (the owner's own proxy): no;
21
20
  * - anything else: yes (it cannot be this machine's tunnel, so it fails).
22
21
  *
23
- * Accepted credentials, either one (fail closed: without one, 401):
24
- * - an edge token (X-Repoburg-Edge-Auth) from the account server's edge
25
- * gate, for this hostname and the pinned owner email (MUH-108);
26
- * - a Cloudflare Access JWT (Cf-Access-Jwt-Assertion), while this tunnel
27
- * still has its Access app (remote.json has accessTeamDomain + accessAud),
28
- * also pinned to the owner email.
22
+ * The credential (fail closed: without it, 401) is an edge token
23
+ * (X-Repoburg-Edge-Auth) from the account server's edge gate, for this
24
+ * hostname and the pinned owner email (MUH-108).
29
25
  */
30
26
  function needsCredential(host) {
31
27
  if (!host)
@@ -51,26 +47,15 @@ async function remoteAuthFailure(headers, state = (0, tunnel_state_1.loadTunnelS
51
47
  if (!state.ownerEmail)
52
48
  return 'Tunnel owner email is missing — re-provision this machine.';
53
49
  const edgeToken = header(headers, edge_jwt_1.EDGE_AUTH_HEADER);
54
- if (edgeToken) {
55
- try {
56
- await (0, edge_jwt_1.verifyEdgeJwt)(edgeToken, { hostname: state.hostname, ownerEmail: state.ownerEmail });
57
- return null;
58
- }
59
- catch {
60
- return 'Invalid or expired sign-in token.';
61
- }
50
+ if (!edgeToken)
51
+ return 'Sign in to this machine first.';
52
+ try {
53
+ await (0, edge_jwt_1.verifyEdgeJwt)(edgeToken, { hostname: state.hostname, ownerEmail: state.ownerEmail });
54
+ return null;
62
55
  }
63
- const assertion = header(headers, 'cf-access-jwt-assertion');
64
- if (assertion && state.accessTeamDomain && state.accessAud) {
65
- try {
66
- await (0, access_jwt_1.verifyAccessJwt)(assertion, { teamDomain: state.accessTeamDomain, aud: state.accessAud }, { ownerEmail: state.ownerEmail });
67
- return null;
68
- }
69
- catch {
70
- return 'Invalid or expired Cloudflare Access token.';
71
- }
56
+ catch {
57
+ return 'Invalid or expired sign-in token.';
72
58
  }
73
- return 'Sign in to this machine first.';
74
59
  }
75
60
  /** Express middleware for every route. */
76
61
  async function checkRemoteAuth(req, res, next) {
@@ -37,16 +37,13 @@ const jose = __importStar(require("jose"));
37
37
  const checkRemoteAuth_1 = require("./checkRemoteAuth");
38
38
  const originGuard_1 = require("./originGuard");
39
39
  const tunnel_state_1 = require("../remote/tunnel-state");
40
- const access_jwt_1 = require("../remote/access-jwt");
41
40
  jest.mock('../remote/tunnel-state');
42
- jest.mock('../remote/access-jwt');
43
41
  const mockedLoad = tunnel_state_1.loadTunnelState;
44
- const mockedVerifyAccess = access_jwt_1.verifyAccessJwt;
45
42
  /** Requests THROUGH THE TUNNEL carry the machine hostname as Host. */
46
43
  const HOSTNAME = 'zztest.repoburg.com';
47
44
  const TUNNEL_HOST = `${HOSTNAME}:443`;
48
45
  const OWNER = 'owner@repoburg.com';
49
- /** A tunnel behind the edge gate (provisioned with edgeAuth, or moved). */
46
+ /** A tunnel behind the edge gate. */
50
47
  const GATE_STATE = {
51
48
  mahlas: 'zztest',
52
49
  hostname: HOSTNAME,
@@ -54,7 +51,7 @@ const GATE_STATE = {
54
51
  tunnelToken: 'connector',
55
52
  ownerEmail: OWNER,
56
53
  };
57
- /** A tunnel still behind Cloudflare Access. */
54
+ /** remote.json of a tunnel from before the gate: its Access fields mean nothing now. */
58
55
  const ACCESS_STATE = {
59
56
  ...GATE_STATE,
60
57
  accessTeamDomain: 'team.cloudflareaccess.com',
@@ -83,7 +80,6 @@ afterAll(() => {
83
80
  });
84
81
  beforeEach(() => {
85
82
  mockedLoad.mockReset().mockReturnValue(null);
86
- mockedVerifyAccess.mockReset().mockResolvedValue(undefined);
87
83
  (0, originGuard_1.setExtraOriginsForTest)([]);
88
84
  });
89
85
  describe('remoteAuthFailure: who needs a credential', () => {
@@ -93,7 +89,6 @@ describe('remoteAuthFailure: who needs a credential', () => {
93
89
  expect(await (0, checkRemoteAuth_1.remoteAuthFailure)({ host }, state)).toBeNull();
94
90
  }
95
91
  }
96
- expect(mockedVerifyAccess).not.toHaveBeenCalled();
97
92
  });
98
93
  it('does not take a lookalike Host for a local one', async () => {
99
94
  for (const host of ['localhost.evil.com', '127.0.0.1.evil.com:9998', '0.0.0.0.evil.com']) {
@@ -122,7 +117,7 @@ describe('remoteAuthFailure: edge tokens', () => {
122
117
  expect(await withToken(await edgeToken())).toBeNull();
123
118
  expect(await withToken(await edgeToken({ email: 'Owner@Repoburg.com' }))).toBeNull();
124
119
  });
125
- it('accepts it on a tunnel still behind Access too (the move is under way)', async () => {
120
+ it('accepts it with a remote.json from before the gate too', async () => {
126
121
  expect(await withToken(await edgeToken(), ACCESS_STATE)).toBeNull();
127
122
  });
128
123
  it('refuses a token without credentials, of another machine, owner, issuer or key, or expired', async () => {
@@ -148,21 +143,10 @@ describe('remoteAuthFailure: edge tokens', () => {
148
143
  it('asks to sign in when there is no credential at all', async () => {
149
144
  expect(await (0, checkRemoteAuth_1.remoteAuthFailure)({ host: TUNNEL_HOST }, GATE_STATE)).toBe('Sign in to this machine first.');
150
145
  });
151
- it('does not take an Access JWT on a tunnel that moved to the gate', async () => {
146
+ it('takes no Cloudflare Access JWT, whatever remote.json says', async () => {
152
147
  const headers = { host: TUNNEL_HOST, 'cf-access-jwt-assertion': 'jwt' };
153
148
  expect(await (0, checkRemoteAuth_1.remoteAuthFailure)(headers, GATE_STATE)).toBe('Sign in to this machine first.');
154
- expect(mockedVerifyAccess).not.toHaveBeenCalled();
155
- });
156
- });
157
- describe('remoteAuthFailure: Cloudflare Access (tunnels from before the gate)', () => {
158
- const headers = { host: TUNNEL_HOST, 'cf-access-jwt-assertion': 'jwt' };
159
- it('accepts a valid Access JWT and pins the owner email', async () => {
160
- expect(await (0, checkRemoteAuth_1.remoteAuthFailure)(headers, ACCESS_STATE)).toBeNull();
161
- expect(mockedVerifyAccess).toHaveBeenCalledWith('jwt', { teamDomain: 'team.cloudflareaccess.com', aud: 'aud-tag' }, { ownerEmail: OWNER });
162
- });
163
- it('rejects an invalid one, or one for the wrong email (email pinning)', async () => {
164
- mockedVerifyAccess.mockRejectedValue(new Error('Access token email does not match the machine owner'));
165
- expect(await (0, checkRemoteAuth_1.remoteAuthFailure)(headers, ACCESS_STATE)).toBe('Invalid or expired Cloudflare Access token.');
149
+ expect(await (0, checkRemoteAuth_1.remoteAuthFailure)(headers, ACCESS_STATE)).toBe('Sign in to this machine first.');
166
150
  });
167
151
  });
168
152
  describe('checkRemoteAuth (HTTP, every route)', () => {
@@ -20,8 +20,6 @@ const STATE = {
20
20
  hostname: 'zz.repoburg.com',
21
21
  accountTunnelId: 'acc-1',
22
22
  tunnelToken: 'TUNNELSECRET',
23
- accessTeamDomain: 'team.cloudflareaccess.com',
24
- accessAud: 'aud',
25
23
  ownerEmail: 'o@x.com',
26
24
  installedAt: '2026-01-01T00:00:00Z',
27
25
  };
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProvisioningError = void 0;
4
4
  exports.accountServerUrl = accountServerUrl;
5
5
  exports.provisionTunnel = provisionTunnel;
6
- exports.moveTunnelToEdgeGate = moveTunnelToEdgeGate;
7
6
  exports.listTunnels = listTunnels;
8
7
  exports.uninstallTunnel = uninstallTunnel;
9
8
  /**
@@ -51,9 +50,8 @@ async function provisionTunnel(mahlas) {
51
50
  if (!token) {
52
51
  throw new ProvisioningError('Not logged in. Run `repoburg login` first.', 401);
53
52
  }
54
- // `edgeAuth`: this daemon checks the edge gate's tokens, so the tunnel
55
- // needs no Cloudflare Access app (MUH-108). An account server from before
56
- // the gate ignores it and answers with Access fields, which are kept.
53
+ // `edgeAuth`: this daemon checks the edge gate's tokens (MUH-108). The
54
+ // account server refuses daemons that do not say so (426).
57
55
  const result = await callAccountServer('POST', '/device/tunnels', token, { mahlas, edgeAuth: true });
58
56
  // The owner email arrives in the same response: the tunnel is gated from
59
57
  // birth, and checkRemoteAuth can pin the owner's email.
@@ -62,34 +60,12 @@ async function provisionTunnel(mahlas) {
62
60
  hostname: result.hostname,
63
61
  accountTunnelId: result.id,
64
62
  tunnelToken: result.tunnel_token,
65
- ...(result.accessTeamDomain && result.accessAud
66
- ? { accessTeamDomain: result.accessTeamDomain, accessAud: result.accessAud }
67
- : {}),
68
63
  ownerEmail: result.ownerEmail,
69
64
  installedAt: new Date().toISOString(),
70
65
  };
71
66
  (0, tunnel_state_1.saveTunnelState)(state);
72
67
  return state;
73
68
  }
74
- /**
75
- * Moves a tunnel provisioned behind Cloudflare Access to the edge gate: the
76
- * account server deletes the Access app, and remote.json drops the Access
77
- * fields (Access JWTs are no longer accepted). Nothing to do for a tunnel
78
- * without them. Returns whether it moved; throws when it could not (try again).
79
- */
80
- async function moveTunnelToEdgeGate(home) {
81
- const state = (0, tunnel_state_1.loadTunnelState)(home);
82
- if (!state?.accessAud && !state?.accessTeamDomain)
83
- return false;
84
- const token = await authManager_1.authManager.readToken();
85
- if (!token)
86
- throw new ProvisioningError('Not logged in. Run `repoburg login` first.', 401);
87
- const result = await callAccountServer('POST', `/device/tunnels/${state.accountTunnelId}/edge-auth`, token);
88
- const { accessTeamDomain: _domain, accessAud: _aud, ...rest } = state;
89
- // The pinned email stays as it was; a state from before pinning gets one.
90
- (0, tunnel_state_1.saveTunnelState)({ ...rest, ownerEmail: state.ownerEmail ?? result.ownerEmail }, home);
91
- return true;
92
- }
93
69
  /** List this user's machines (used by the pane machine list when local). */
94
70
  async function listTunnels() {
95
71
  const token = await authManager_1.authManager.readToken();
@@ -30,9 +30,8 @@ describe('provisioner', () => {
30
30
  mahlas: 'workstation',
31
31
  hostname: 'workstation.repoburg.com',
32
32
  tunnel_token: 'connector-token',
33
- accessTeamDomain: 'team.cloudflareaccess.com',
34
- accessAud: 'aud-tag',
35
33
  ownerEmail: 'owner@repoburg.com',
34
+ gate: 'repoburg',
36
35
  }),
37
36
  }));
38
37
  global.fetch = fetchMock;
@@ -40,58 +39,29 @@ describe('provisioner', () => {
40
39
  os_1.default.homedir = () => tmpHome;
41
40
  try {
42
41
  const state = await (0, provisioner_1.provisionTunnel)('workstation');
43
- expect(state).toMatchObject({
42
+ expect(state).toEqual({
44
43
  mahlas: 'workstation',
45
44
  hostname: 'workstation.repoburg.com',
46
45
  accountTunnelId: 'tunnel-uuid',
47
46
  tunnelToken: 'connector-token',
48
- accessTeamDomain: 'team.cloudflareaccess.com',
49
- accessAud: 'aud-tag',
50
47
  ownerEmail: 'owner@repoburg.com',
48
+ installedAt: expect.any(String),
51
49
  });
52
50
  expect((0, tunnel_state_1.loadTunnelState)(tmpHome)).toMatchObject({
53
51
  accountTunnelId: 'tunnel-uuid',
54
- // The Access config arrives with the tunnel — email-gated from birth.
55
- accessAud: 'aud-tag',
52
+ // The owner email arrives with the tunnel — email-pinned from birth.
56
53
  ownerEmail: 'owner@repoburg.com',
57
54
  });
58
55
  const [url, init] = fetchMock.mock.calls[0];
59
56
  expect(url).toBe('http://account-server.test/device/tunnels');
60
57
  expect(init.headers.Authorization).toBe('Bearer device-jwt');
61
- // This daemon checks edge-gate tokens: no Access app needed.
58
+ // This daemon checks edge-gate tokens.
62
59
  expect(JSON.parse(init.body)).toEqual({ mahlas: 'workstation', edgeAuth: true });
63
60
  }
64
61
  finally {
65
62
  os_1.default.homedir = origHomedir;
66
63
  }
67
64
  });
68
- it('keeps no Access fields for a tunnel behind the edge gate', async () => {
69
- mockedReadToken.mockResolvedValue('device-jwt');
70
- global.fetch = jest.fn(async () => ({
71
- ok: true,
72
- status: 201,
73
- json: async () => ({
74
- id: 'tunnel-uuid',
75
- mahlas: 'workstation',
76
- hostname: 'workstation.repoburg.com',
77
- tunnel_token: 'connector-token',
78
- ownerEmail: 'owner@repoburg.com',
79
- gate: 'repoburg',
80
- }),
81
- }));
82
- const origHomedir = os_1.default.homedir;
83
- os_1.default.homedir = () => tmpHome;
84
- try {
85
- await (0, provisioner_1.provisionTunnel)('workstation');
86
- const state = (0, tunnel_state_1.loadTunnelState)(tmpHome);
87
- expect(state).toMatchObject({ hostname: 'workstation.repoburg.com', ownerEmail: 'owner@repoburg.com' });
88
- expect(state).not.toHaveProperty('accessAud');
89
- expect(state).not.toHaveProperty('accessTeamDomain');
90
- }
91
- finally {
92
- os_1.default.homedir = origHomedir;
93
- }
94
- });
95
65
  it('refuses to provision when not logged in', async () => {
96
66
  mockedReadToken.mockResolvedValue(null);
97
67
  await expect((0, provisioner_1.provisionTunnel)('workstation')).rejects.toBeInstanceOf(provisioner_1.ProvisioningError);
@@ -131,54 +101,3 @@ describe('provisioner', () => {
131
101
  await expect((0, provisioner_1.listTunnels)()).resolves.toEqual([]);
132
102
  });
133
103
  });
134
- describe('moveTunnelToEdgeGate', () => {
135
- const ACCESS_STATE = {
136
- mahlas: 'workstation',
137
- hostname: 'workstation.repoburg.com',
138
- accountTunnelId: 'tunnel-uuid',
139
- tunnelToken: 'connector-token',
140
- accessTeamDomain: 'team.cloudflareaccess.com',
141
- accessAud: 'aud-tag',
142
- ownerEmail: 'owner@repoburg.com',
143
- installedAt: '2026-01-01T00:00:00.000Z',
144
- };
145
- const reply = (status, body) => jest.fn(async () => ({ ok: status < 400, status, json: async () => body }));
146
- it('asks the account server, then drops the Access fields and keeps the pinned email', async () => {
147
- (0, tunnel_state_1.saveTunnelState)(ACCESS_STATE, tmpHome);
148
- mockedReadToken.mockResolvedValue('device-jwt');
149
- const fetchMock = reply(200, { ownerEmail: 'changed@repoburg.com', gate: 'repoburg' });
150
- global.fetch = fetchMock;
151
- await expect((0, provisioner_1.moveTunnelToEdgeGate)(tmpHome)).resolves.toBe(true);
152
- const [url, init] = fetchMock.mock.calls[0];
153
- expect(url).toBe('http://account-server.test/device/tunnels/tunnel-uuid/edge-auth');
154
- expect(init.method).toBe('POST');
155
- expect(init.headers.Authorization).toBe('Bearer device-jwt');
156
- const { accessTeamDomain: _domain, accessAud: _aud, ...rest } = ACCESS_STATE;
157
- expect((0, tunnel_state_1.loadTunnelState)(tmpHome)).toEqual(rest);
158
- });
159
- it('pins the account server’s email on a state from before pinning', async () => {
160
- (0, tunnel_state_1.saveTunnelState)({ ...ACCESS_STATE, ownerEmail: undefined }, tmpHome);
161
- mockedReadToken.mockResolvedValue('device-jwt');
162
- global.fetch = reply(200, { ownerEmail: 'owner@repoburg.com' });
163
- await (0, provisioner_1.moveTunnelToEdgeGate)(tmpHome);
164
- expect((0, tunnel_state_1.loadTunnelState)(tmpHome)?.ownerEmail).toBe('owner@repoburg.com');
165
- });
166
- it('has nothing to do without Access fields or without a tunnel', async () => {
167
- const fetchMock = jest.fn();
168
- global.fetch = fetchMock;
169
- await expect((0, provisioner_1.moveTunnelToEdgeGate)(tmpHome)).resolves.toBe(false);
170
- const { accessTeamDomain: _domain, accessAud: _aud, ...gateState } = ACCESS_STATE;
171
- (0, tunnel_state_1.saveTunnelState)(gateState, tmpHome);
172
- await expect((0, provisioner_1.moveTunnelToEdgeGate)(tmpHome)).resolves.toBe(false);
173
- expect(fetchMock).not.toHaveBeenCalled();
174
- });
175
- it('keeps the Access fields when it cannot move (not logged in, server error)', async () => {
176
- (0, tunnel_state_1.saveTunnelState)(ACCESS_STATE, tmpHome);
177
- mockedReadToken.mockResolvedValue(null);
178
- await expect((0, provisioner_1.moveTunnelToEdgeGate)(tmpHome)).rejects.toBeInstanceOf(provisioner_1.ProvisioningError);
179
- mockedReadToken.mockResolvedValue('device-jwt');
180
- global.fetch = reply(503, { message: 'Cloudflare API error: denied' });
181
- await expect((0, provisioner_1.moveTunnelToEdgeGate)(tmpHome)).rejects.toThrow(/denied/);
182
- expect((0, tunnel_state_1.loadTunnelState)(tmpHome)).toEqual(ACCESS_STATE);
183
- });
184
- });
@@ -45,12 +45,9 @@ function createRemoteRouter() {
45
45
  service: { running: await (0, cloudflared_1.isServiceRunning)().catch(() => false) },
46
46
  connection: { ok: await (0, probes_1.probeTunnelConnected)() },
47
47
  access: {
48
- // Who signs visitors in: the account server's edge gate, or
49
- // Cloudflare Access on a tunnel from before it (MUH-108).
50
- gate: state ? (state.accessAud ? 'cloudflare-access' : 'repoburg') : null,
51
- configured: Boolean(state?.accessTeamDomain && state?.accessAud),
48
+ // Who signs visitors in: the account server's edge gate (MUH-108).
49
+ gate: state ? 'repoburg' : null,
52
50
  ownerEmail: state?.ownerEmail ?? null,
53
- teamDomain: state?.accessTeamDomain ?? null,
54
51
  },
55
52
  publicHealth: { ok: await (0, probes_1.probePublicHealth)() },
56
53
  });
@@ -104,8 +104,6 @@ describe('remote routes', () => {
104
104
  it('GET /status aggregates tunnel, cloudflared, service, connection, and access', async () => {
105
105
  mocked.loadTunnelState.mockReturnValue({
106
106
  ...STATE,
107
- accessTeamDomain: 'team.cloudflareaccess.com',
108
- accessAud: 'aud-tag',
109
107
  ownerEmail: 'owner@repoburg.com',
110
108
  });
111
109
  mocked.isInstalled.mockReturnValue(true);
@@ -117,12 +115,7 @@ describe('remote routes', () => {
117
115
  expect(res.json.cloudflared).toEqual({ installed: true });
118
116
  expect(res.json.service).toEqual({ running: true });
119
117
  expect(res.json.connection).toEqual({ ok: true });
120
- expect(res.json.access).toEqual({
121
- gate: 'cloudflare-access',
122
- configured: true,
123
- ownerEmail: 'owner@repoburg.com',
124
- teamDomain: 'team.cloudflareaccess.com',
125
- });
118
+ expect(res.json.access).toEqual({ gate: 'repoburg', ownerEmail: 'owner@repoburg.com' });
126
119
  expect(res.json.publicHealth).toEqual({ ok: true });
127
120
  });
128
121
  it('GET /status reports connection false when cloudflared metrics show 0 ha connections', async () => {
@@ -15,8 +15,6 @@ describe('tunnel state', () => {
15
15
  hostname: 'workstation.repoburg.com',
16
16
  accountTunnelId: 'tunnel-uuid',
17
17
  tunnelToken: 'connector-token',
18
- accessTeamDomain: 'team.cloudflareaccess.com',
19
- accessAud: 'aud-tag',
20
18
  ownerEmail: 'owner@repoburg.com',
21
19
  };
22
20
  it('round-trips the state to ~/.repoburg/remote.json', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repoburg",
3
- "version": "1.3.311",
3
+ "version": "1.3.312",
4
4
  "description": "A local AI-powered software developer assistant that runs on your own machine.",
5
5
  "author": "Celal Ertug",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "tree": "3f01773d2dfcfcfee7b73a8c7d7497c15ad692bc",
3
- "commit": "c8a8bf96995548760fca8d881f2f2017d816d5dd",
3
+ "commit": "98373b2b5d9e1ece8cbc7ffe6a38862f0a9a1695",
4
4
  "dirty": false,
5
- "repoburgVersion": "1.3.311",
6
- "builtAt": "2026-11-09T02:56:59.735Z"
5
+ "repoburgVersion": "1.3.312",
6
+ "builtAt": "2026-11-09T03:36:41.034Z"
7
7
  }
@@ -58,5 +58,5 @@
58
58
  ]
59
59
  }
60
60
  ],
61
- "version_name": "0.6.0 (repoburg 1.3.311, c8a8bf9)"
61
+ "version_name": "0.6.0 (repoburg 1.3.312, 98373b2)"
62
62
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "tree": "3f01773d2dfcfcfee7b73a8c7d7497c15ad692bc",
3
- "commit": "c8a8bf96995548760fca8d881f2f2017d816d5dd",
3
+ "commit": "98373b2b5d9e1ece8cbc7ffe6a38862f0a9a1695",
4
4
  "dirty": false,
5
- "repoburgVersion": "1.3.311",
6
- "builtAt": "2026-11-09T02:56:59.735Z"
5
+ "repoburgVersion": "1.3.312",
6
+ "builtAt": "2026-11-09T03:36:41.034Z"
7
7
  }