repoburg 1.3.320 → 1.3.322
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-pane/backend/dist/index.js +356 -61
- package/agent-pane/backend/dist/server.js +356 -61
- package/agent-pane/frontend/dist/assets/{TerminalView-D5Hg3Fzf.js → TerminalView-Z7ZJ436H.js} +1 -1
- package/agent-pane/frontend/dist/assets/{index-Cckb2tlY.js → index-CjwvHfxy.js} +12 -2
- package/agent-pane/frontend/dist/index.html +1 -1
- package/package.json +1 -1
- package/tabtape/extension/dist/build-info.json +3 -3
- package/tabtape/extension/dist/manifest.json +1 -1
- package/tabtape/ui/dist/build-info.json +3 -3
package/agent-pane/frontend/dist/assets/{TerminalView-D5Hg3Fzf.js → TerminalView-Z7ZJ436H.js}
RENAMED
|
@@ -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-
|
|
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-CjwvHfxy.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-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-Z7ZJ436H.js","assets/TerminalView-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
var V0=Object.defineProperty;var K0=(e,n,r)=>n in e?V0(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var mt=(e,n,r)=>K0(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 nv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Fu={exports:{}},gi={},Uu={exports:{}},Ge={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react.production.min.js
|
|
@@ -781,6 +781,9 @@ ${A}
|
|
|
781
781
|
}
|
|
782
782
|
});
|
|
783
783
|
}
|
|
784
|
+
function headlessOnly(api) {
|
|
785
|
+
return Promise.reject(new Error(api + ' is only available in the headless runtime: reach it from the tab with callTool'));
|
|
786
|
+
}
|
|
784
787
|
window.AgentPane = {
|
|
785
788
|
getApp: function () { return call('getApp'); },
|
|
786
789
|
getState: function () { return call('getState'); },
|
|
@@ -814,6 +817,13 @@ ${A}
|
|
|
814
817
|
onToolCall: function (cb) { listeners.push(function (event, payload) { if (event === 'tool_call' && payload) cb(payload); }); },
|
|
815
818
|
onStateChanged: function (cb) { listeners.push(function (event, payload) { if (event === 'state_changed') cb(payload || {}); }); },
|
|
816
819
|
onBackgroundTasks: function (cb) { listeners.push(function (event, payload) { if (event === 'background_tasks' && payload) cb(payload); }); },
|
|
820
|
+
// Headless only: session activity and alarms reach the app's headless
|
|
821
|
+
// runtime, never a tab (see the apps-root AGENTS.md).
|
|
822
|
+
onSessionActivity: function () {},
|
|
823
|
+
onAlarm: function () {},
|
|
824
|
+
setAlarm: function () { return headlessOnly('setAlarm'); },
|
|
825
|
+
clearAlarm: function () { return headlessOnly('clearAlarm'); },
|
|
826
|
+
listAlarms: function () { return headlessOnly('listAlarms'); },
|
|
817
827
|
resolveToolCall: function (callId, result) { return call('resolveToolCall', { callId: callId, result: result }); },
|
|
818
828
|
openSession: function (sessionId) { return call('openSession', { sessionId: sessionId }); },
|
|
819
829
|
openUrl: function (url) {
|
|
@@ -844,7 +854,7 @@ ${A}
|
|
|
844
854
|
stack: (r && r.stack) || '', line: 0, col: 0
|
|
845
855
|
}, '*');
|
|
846
856
|
});
|
|
847
|
-
}`;function rj(e){return`(${sj})(${JSON.stringify(e)});`}function qg(e){return e.replace(/<\/script/gi,"<\\/script")}function oj(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 Xg(e,n,r){const o=oj(e,n);return o===-1?e+r:e.slice(0,o)+r+e.slice(o)}function ij(e,n,r){let o=e;const l=`<script>${qg(n)}<\/script>`;if(/<\/head>/i.test(o)?o=Xg(o,"</head>",l):/<html[^>]*>/i.test(o)?o=o.replace(/(<html[^>]*>)/i,`$1<head>${l}</head>`):o=`${l}${o}`,r){const c=`<script>${qg(r)}<\/script>`;o=Xg(o,"</body>",c)}return o}function aj(){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 lj(e){var r;if(!(e instanceof Io)||e.status!==409)return null;const n=(r=e.body)==null?void 0:r.state;return n&&typeof n=="object"?n:null}function cj({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 j=aj(),N=b=>{const A=o.current.version;typeof b.version=="number"&&typeof A=="number"&&b.version<A||(o.current=b)};Kw(e,b=>{var A,L;return(L=(A=r.current)==null?void 0:A.contentWindow)==null?void 0:L.postMessage(b,"*")},n);const C=async b=>{var F,O,Z,J,ee,ge,Se,Oe,xe,ie,te,X,oe,K,E,M,ce,U,ue,Y,we,ve,Ie,je;if(b.source!==((F=r.current)==null?void 0:F.contentWindow))return;const A=b.data;if(!A||A.source!=="agentpane-app")return;if(A.report==="error"){const pe={message:String(A.message??"Unknown error"),stack:String(A.stack??"")};m(he=>{const Ye=he[he.length-1];return Ye&&Ye.message===pe.message?he:[...he,pe].slice(-20)});return}if(typeof A.method!="string")return;let L=!0,$,z,q=null;try{switch(A.method){case"getApp":$={id:e,workspace:n};break;case"getState":try{const pe=await jm(e,n);N(pe),$=pe}catch{$=o.current}break;case"setState":{const pe=((O=A.params)==null?void 0:O.data)??null,he=(Z=A.params)==null?void 0:Z.ifVersion,Ye={data:pe,writer:j};typeof he=="number"&&(Ye.ifVersion=he);try{const Ce=await jv(e,Ye,n);N(Ce),$=Ce}catch(Ce){if(q=lj(Ce),!q)throw Ce;N(q);const ct=Ce.body;throw new Error(typeof(ct==null?void 0:ct.error)=="string"?ct.error:"App state changed since that version")}break}case"createSession":{const pe=A.params??{},he=await Kd({title:typeof pe.title=="string"?pe.title:void 0,runtime_type:typeof pe.runtime_type=="string"?pe.runtime_type:void 0,model:typeof pe.model=="string"?pe.model:void 0,model_reasoning_effort:typeof pe.model_reasoning_effort=="string"?pe.model_reasoning_effort:void 0,cwd:typeof pe.cwd=="string"?pe.cwd:void 0,origin_app_id:e,origin_app_workspace:n});pl(he.id,e),R.getState().addSession(he),$=he;break}case"submitTurn":{const pe=String(((J=A.params)==null?void 0:J.sessionId)??"");if(!await _m(e,pe))throw new Error(`submitTurn: ${pe} is not a session of this app`);const he=String(((ee=A.params)==null?void 0:ee.prompt)??""),Ye=await nj(e,(ge=A.params)==null?void 0:ge.attachments,ct=>n1(e,ct)),Ce=await pv(pe,he,Ye.length?Ye:void 0,{originAppId:e});pl(pe,e),$=Ce;break}case"getSession":{$=await _m(e,String(((Se=A.params)==null?void 0:Se.sessionId)??""));break}case"listSessions":{const pe=(Oe=A.params)==null?void 0:Oe.lifecycle,he=(xe=A.params)==null?void 0:xe.running;$=await Bk(e,n,{lifecycle:pe==="working"||pe==="finished"?pe:void 0,running:typeof he=="boolean"?he:void 0});break}case"getSessionInfo":{$=await Wk(e,n,String(((ie=A.params)==null?void 0:ie.sessionId)??""));break}case"cancelTurn":{$=await Hk(e,String(((te=A.params)==null?void 0:te.sessionId)??""));break}case"setSessionLifecycle":{$=await Vk(e,String(((X=A.params)==null?void 0:X.sessionId)??""),String(((oe=A.params)==null?void 0:oe.lifecycle)??""));break}case"callTool":{const pe=(K=A.params)==null?void 0:K.args;$=await Kk(e,n,String(((E=A.params)==null?void 0:E.tool)??""),pe&&typeof pe=="object"?pe:{});break}case"listProviders":{$=await Jy();break}case"listModels":{const pe=typeof((M=A.params)==null?void 0:M.runtime)=="string"?A.params.runtime.trim():"";if(!pe)throw new Error("listModels: runtime is required");const he=(ce=A.params)==null?void 0:ce.cwd;$=await Cv(pe,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");$=await mv();break}case"resolveToolCall":{const pe=String(((U=A.params)==null?void 0:U.callId)??""),he=(ue=A.params)==null?void 0:ue.result;await Zk(pe,he),$={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 pe=typeof((Y=A.params)==null?void 0:Y.sessionId)=="string"?A.params.sessionId.trim():"";if(!pe)throw new Error("openSession: sessionId is required");try{await R.getState().revealSession(pe)}catch(he){throw new Error(`openSession: ${he instanceof Error?he.message:String(he)}`)}$={ok:!0};break}case"uploadFile":{const pe=await tj((we=A.params)==null?void 0:we.file);try{$=Gg(await e1(e,pe))}catch(he){throw new Error(`uploadFile: ${he instanceof Error?he.message:String(he)}`)}break}case"getFile":{const pe=lx(e,(ve=A.params)==null?void 0:ve.ref),he=pe?await t1(e,pe):null;$=he?Gg(he):null;break}default:throw new Error(`Unknown bridge method: ${A.method}`)}}catch(pe){L=!1,z=pe instanceof Error?pe.message:String(pe)}(je=(Ie=r.current)==null?void 0:Ie.contentWindow)==null||je.postMessage(q?{source:"agentpane-host",id:A.id,ok:L,error:z,code:"conflict",state:q}:{source:"agentpane-host",id:A.id,ok:L,result:$,error:z},"*")};return window.addEventListener("message",C),Jw(e,b=>{var A,L;typeof b.workspace=="string"&&b.workspace!==n||b.writer!==j&&((L=(A=r.current)==null?void 0:A.contentWindow)==null||L.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,A,L]=await Promise.all([Em(e),jm(e,n),Uk(e).catch(()=>[])]);if(!S)return;o.current=A,L.forEach($=>pl($.id,e)),c(b)}catch(b){S&&f(b instanceof Error?b.message:String(b))}})(),()=>{S=!1,Gw(e),Zw(e),ek(e),window.removeEventListener("message",C)}},[e,n]),x.useEffect(()=>{l&&qw(e,l.manifest.headlessSessions===!0)},[e,l]);const v=x.useMemo(()=>l?ij(l.html,rj({appId:e,apiOrigin:ax()}),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,j)=>a.jsxs("div",{className:"miniapp-diag",children:[S.file,":",S.line,":",S.column," — ",S.message]},j))]}),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,j)=>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})]},j))})]})}function uj({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(Mo,{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(Q1,{size:13}),"Edit"]}),a.jsx("button",{className:"miniapp-header-close",title:"Close app",onClick:()=>d(null),children:a.jsx(Cn,{size:14})})]}),a.jsx("div",{className:"miniapp-body",children:a.jsx(cj,{appId:e,workspace:m},`${e}:${m}`)})]})}function dj({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,j=e==="left"?h.current+S:h.current-S,N=Math.min(r,Math.max(n,j));l(N)},[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,j;y.preventDefault(),y.stopPropagation();try{(j=(S=y.currentTarget)==null?void 0:S.setPointerCapture)==null||j.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 Yg({side:e,minWidth:n,maxWidth:r,getWidth:o,setWidth:l}){const{onPointerDown:c,dragging:d}=dj({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 fj=x.lazy(()=>x1(()=>import("./TerminalView-D5Hg3Fzf.js"),__vite__mapDeps([0,1])));function pj(){Ut.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 j=Cl(),{rightPanelWidth:N,setRightPanelWidth:C}=R.getState();N>j&&C(j)};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const y=l?`${e}px 6px 1fr ${Mk}px`:`${e}px 6px 1fr 6px ${n}px`;return a.jsxs("div",{className:"ide-root",children:[a.jsx(YE,{}),a.jsxs("div",{className:`ide-layout ${c||d||f?"ide-hidden":""}`,style:{gridTemplateColumns:y},children:[a.jsx(aN,{}),a.jsx(Yg,{side:"left",minWidth:kd,maxWidth:Sd,getWidth:()=>R.getState().sidebarWidth,setWidth:r}),a.jsxs("div",{className:"ide-center",children:[a.jsx(uN,{}),a.jsxs("div",{className:"ide-render",children:[k.map(S=>a.jsx(uj,{appId:S,active:v===S},S)),v==null&&a.jsx(bC,{})]}),a.jsx(MC,{})]}),!l&&a.jsx(Yg,{side:"right",minWidth:Tl,maxWidth:Cl(),getWidth:()=>R.getState().rightPanelWidth,setWidth:o}),a.jsx(nE,{})]}),c&&a.jsx(NE,{}),d&&a.jsx(XE,{}),h&&a.jsx(x.Suspense,{fallback:null,children:a.jsx(fj,{visible:f})}),a.jsx(xE,{})]})}function hj(){var z,q,F;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,j]=x.useState(""),{models:N}=rx(e?l:null);if(!e)return null;const C=O=>N.find(Z=>Z.slug===O),b=m?((z=C(m))==null?void 0:z.reasoningLevels)??[]:[];function A(){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(""),j("")}function L(O){O.key==="Escape"&&n(!1)}function $(O){var ee,ge,Se;v(O);const Z=((ee=C(O))==null?void 0:ee.reasoningLevels)??[];Z.some(Oe=>Oe.effort===k)||y(((ge=C(O))==null?void 0:ge.defaultReasoning)??((Se=Z[0])==null?void 0:Se.effort)??"")}return a.jsx("div",{className:"dialog-overlay",onClick:()=>n(!1),children:a.jsxs("div",{className:"dialog",onClick:O=>O.stopPropagation(),onKeyDown:L,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(Cn,{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:O=>h(O.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:O=>$(O.target.value),children:[a.jsx("option",{value:"",children:"Default (Codex picks)"}),N.map(O=>a.jsxs("option",{value:O.slug,children:[O.displayName," — ",O.description]},O.slug))]})]}),b.length>0&&a.jsxs("label",{className:"dialog-label",children:["Thinking Level",a.jsxs("select",{className:"dialog-input dialog-select",value:k,onChange:O=>y(O.target.value),children:[a.jsxs("option",{value:"",children:["Default",(q=C(m))!=null&&q.defaultReasoning?` (${(F=C(m))==null?void 0:F.defaultReasoning})`:""]}),b.map(O=>a.jsx("option",{value:O.effort,children:O.label},O.effort))]})]}),a.jsxs("label",{className:"dialog-label",children:["Working Directory (optional)",a.jsx("input",{className:"dialog-input",type:"text",value:S,onChange:O=>j(O.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:A,children:"Create"})]})]})})}function mj(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 gj(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 vj(){return R(n=>n.showAddWorkspaceDialog)?a.jsx(yj,{}):null}function yj(){var F;const e=R(O=>O.setShowAddWorkspaceDialog),n=R(O=>O.workspaces),r=R(O=>O.createWorkspaceAt),o=R(O=>O.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(()=>gj(R.getState().workspaces)),j=x.useRef(null),N=x.useCallback(()=>{v||e(!1)},[v,e]);Do(N);const C=x.useCallback(async(O,Z=!1)=>{const J=++y.current;f(!0);let ee=null,ge=null;try{ee=await cm(O)}catch(Se){if(ge=Hn(Se),Z&&O)try{ee=await cm(),ge=null}catch(Oe){ge=Hn(Oe)}}J===y.current&&(ee&&c(ee),m(ge),f(!1))},[]);x.useEffect(()=>{C(S,!0)},[C,S]);const b=l==null?void 0:l.path;x.useEffect(()=>{j.current&&(j.current.scrollTop=0)},[b]);const A=new Set(n.filter(O=>O.deleted===0).map(O=>gr(O.path)));async function L(O){if(!v){k(!0),m(null);try{const Z=await r(O);e(!1),o("success",`Workspace added — ${Z.path}`)}catch(Z){m(Hn(Z)),k(!1)}}}const $=l?mj(l.path,l.home):[],z=((F=$.at(-1))==null?void 0:F.label)??"",q=l!==null&&A.has(gr(l.path));return a.jsx("div",{className:"dialog-overlay",onClick:N,children:a.jsxs("div",{className:"dialog folder-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"folder-dialog-title",onClick:O=>O.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:N,"aria-label":"Close",disabled:v,children:a.jsx(Cn,{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($v,{size:14})}),a.jsx("nav",{className:"folder-crumbs","aria-label":"Folder path",children:$.map((O,Z)=>a.jsxs(x.Fragment,{children:[Z>0&&a.jsx($i,{size:12,className:"folder-crumb-sep","aria-hidden":"true"}),Z===$.length-1?a.jsx("span",{className:"folder-crumb current","aria-current":"location",title:O.path,children:O.label}):a.jsx("button",{className:"folder-crumb",onClick:()=>void C(O.path),title:O.path,children:O.label})]},O.path))}),d&&l&&a.jsx(rn,{size:14,className:"spin folder-spinner","aria-label":"Loading"})]}),a.jsx("ul",{ref:j,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(O=>a.jsxs("li",{className:"folder-item",children:[a.jsxs("button",{className:"folder-row",onClick:()=>void C(O.path),title:O.path,"aria-label":O.git?`${O.name} (git repository)`:O.name,children:[O.git?a.jsx(L1,{size:15,className:"folder-icon git","aria-hidden":"true"}):a.jsx(Il,{size:15,className:"folder-icon","aria-hidden":"true"}),a.jsx("span",{className:"folder-name",children:O.name}),a.jsx($i,{size:13,className:"folder-chevron","aria-hidden":"true"})]}),A.has(gr(O.path))?a.jsx("span",{className:"folder-tag",children:"Added"}):a.jsx("button",{className:"folder-add",onClick:()=>void L(O.path),disabled:v,"aria-label":`Add ${O.name}`,children:"Add"})]},O.path)):d&&a.jsxs("li",{className:"folder-empty",role:"status",children:[a.jsx(rn,{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:N,disabled:v,children:"Cancel"}),a.jsx("button",{className:"dialog-btn-create",onClick:()=>l&&void L(l.path),disabled:!l||d||v||q,children:v?"Adding…":q?"Already added":`Add “${z}”`})]})]})})}const Ud=6e4,Bd=60*Ud,fl=24*Bd;function xj(e,n=Date.now()){const r=Date.parse(e);if(Number.isNaN(r))return"";const o=Math.max(0,n-r);return o<Ud?"just now":o<Bd?`${Math.floor(o/Ud)} min ago`:o<fl?`${Math.floor(o/Bd)} h ago`:o<2*fl?"yesterday":o<7*fl?`${Math.floor(o/fl)} days ago`:new Date(r).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function wj(){const e=R(n=>n.importSessionsWorkspace);return e?a.jsx(kj,{workspace:e},e):null}function kj({workspace:e}){const n=R(F=>F.setImportSessionsWorkspace),r=R(F=>F.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,j]=x.useState(new Map),N=x.useCallback(()=>{k||n(null)},[k,n]);Do(N),x.useEffect(()=>{let F=!1;return Tv(e).then(({sessions:O,errors:Z})=>{if(F)return;const J=Object.values(Z);if(J.length===wd.length){d([...new Set(J)].join("; "));return}l(O),h(Z)}).catch(O=>{F||d(Hn(O))}),()=>{F=!0}},[e]);function C(F){v(O=>{const Z=new Set(O);return Z.has(F)?Z.delete(F):Z.add(F),Z})}const b=o??[],A=F=>Qu({runtime:F.runtime,id:F.session_id}),L=b.length>0&&b.every(F=>m.has(A(F)));async function $(){const F=b.filter(J=>m.has(A(J))).map(J=>({runtime:J.runtime,id:J.session_id}));if(F.length===0)return;y(!0);const{failed:O}=await r(e,F);if(y(!1),O.length===0){n(null);return}const Z=new Set(O.map(Qu));l(J=>(J??[]).filter(ee=>!m.has(A(ee))||Z.has(A(ee)))),v(Z),j(new Map(O.map(J=>[Qu(J),J.error])))}const z=e.split("/").pop()||e,q=m.size;return a.jsx("div",{className:"dialog-overlay",onClick:N,children:a.jsxs("div",{className:"dialog import-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"import-dialog-title",onClick:F=>F.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:N,"aria-label":"Close",disabled:k,children:a.jsx(Cn,{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:z}),", 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(rn,{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(Qg,{errors:f})]}):a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"import-select-all",children:[a.jsx("input",{type:"checkbox",checked:L,disabled:k,onChange:()=>v(L?new Set:new Set(b.map(A)))}),"Select all (",o.length,")"]}),a.jsx("ul",{className:"import-list",children:o.map(F=>{const O=A(F),Z=S.get(O);return a.jsx("li",{children:a.jsxs("label",{className:`import-row${m.has(O)?" selected":""}`,children:[a.jsx("input",{type:"checkbox",checked:m.has(O),disabled:k,onChange:()=>C(O)}),a.jsxs("span",{className:"import-row-main",children:[a.jsx("span",{className:"import-row-title",title:F.title,children:F.title}),a.jsxs("span",{className:"import-row-meta",children:[a.jsx("span",{className:`import-row-runtime ${F.runtime}`,children:Zl[F.runtime]}),a.jsx("span",{title:new Date(F.last_modified).toLocaleString(),children:xj(F.last_modified)}),F.git_branch&&a.jsxs("span",{className:"import-row-branch",title:"Git branch",children:[a.jsx(Uv,{size:10})," ",F.git_branch]})]}),F.recently_active&&a.jsxs("span",{className:"import-row-warn",children:[a.jsx(nc,{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."]}),Z&&a.jsx("span",{className:"import-row-error",role:"alert",children:Z})]})]})},O)})}),a.jsx(Qg,{errors:f})]})]}),a.jsxs("div",{className:"dialog-footer",children:[a.jsx("button",{className:"dialog-btn-cancel",onClick:N,disabled:k,children:"Cancel"}),a.jsx("button",{className:"dialog-btn-create",onClick:()=>void $(),disabled:q===0||k,children:k?a.jsxs(a.Fragment,{children:[a.jsx(rn,{size:12,className:"spin"})," Importing…"]}):q>1?`Import ${q} sessions`:"Import"})]})]})})}function Qg({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 ",Zl[r]," sessions — ",o]},r))})}const Sj=50*1024*1024;function bj(e){const n=e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"");return/^[a-z0-9]/.test(n)?n:""}function Nj(e){return bj(e.replace(/\.zip$/i,"").replace(/\s*\(\d+\)$/,""))}const Tj=new TextEncoder().encode(".agentpane-data/data.json");async function Cj(e){const n=new Uint8Array(await e.arrayBuffer()),r=Tj;e:for(let o=0;o<=n.length-r.length;o++){for(let l=0;l<r.length;l++)if(n[o+l]!==r[l])continue e;return!0}return!1}function Ej(){const{appCatalogOpen:e,closeAppCatalog:n,apps:r,installExampleApp:o,createSkeletonApp:l,importAppZip:c}=R(),[d,f]=x.useState("examples"),[h,m]=x.useState(null),[v,k]=x.useState(null),[y,S]=x.useState(!1),[j,N]=x.useState(""),[C,b]=x.useState(""),[A,L]=x.useState(""),[$,z]=x.useState(""),[q,F]=x.useState(null),[O,Z]=x.useState(null),[J,ee]=x.useState(""),[ge,Se]=x.useState(null);if(x.useEffect(()=>{e&&(m(null),Gk().then(m).catch(()=>m([])))},[e]),!e)return null;const Oe=new Set(r.map(E=>E.id));async function xe(E){k(E);try{await o(E)&&n()}finally{k(null)}}async function ie(){if(y)return;const E=j.trim(),M=C.trim();if(!(!E||!M)){S(!0);try{await l({id:E,title:M,description:A.trim()||void 0,icon:$.trim()||void 0})&&(N(""),b(""),L(""),z(""),n())}finally{S(!1)}}}async function te(E){var ce;const M=((ce=E.target.files)==null?void 0:ce[0])??null;if(Z(null),F(null),Se(null),!!M){if(!/\.zip$/i.test(M.name)){Z("Choose a .zip file.");return}if(M.size>Sj){Z("The archive is larger than 50 MB.");return}ee(Nj(M.name)),Se(await Cj(M).catch(()=>!1)?!0:null),F(M)}}async function X(){if(!(y||!q||!J.trim())){S(!0);try{await c(J.trim(),q,{data:ge===!0})&&(F(null),ee(""),n())}finally{S(!1)}}}function oe(E){E.key==="Escape"&&n()}const K=[{key:"examples",label:"Examples"},{key:"new",label:"New App"},{key:"import",label:"Import"}];return a.jsx("div",{className:"dialog-overlay",onClick:n,children:a.jsxs("div",{className:"dialog app-catalog",onClick:E=>E.stopPropagation(),onKeyDown:oe,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:K.map(E=>a.jsx("button",{className:`catalog-tab${d===E.key?" active":""}`,onClick:()=>f(E.key),children:E.label},E.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(E=>{const M=Oe.has(E.id);return a.jsxs("div",{className:"example-row",children:[a.jsx(Mo,{iconNode:E.iconNode,size:14,className:"sidebar-app-icon"}),a.jsxs("div",{className:"example-info",children:[a.jsx("span",{className:"example-title",children:E.title}),E.description&&a.jsx("span",{className:"example-desc",children:E.description})]}),a.jsx("button",{className:"example-install",disabled:M||v===E.id,onClick:()=>xe(E.id),title:M?"Already installed":"Install this example",children:M?"Installed":v===E.id?"Installing…":"Install"})]},E.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:j,onChange:E=>N(E.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:E=>b(E.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:A,onChange:E=>L(E.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:$,onChange:E=>z(E.target.value),placeholder:"e.g. notebook-pen",spellCheck:!1,autoCapitalize:"off"})]}),a.jsxs("button",{className:"dialog-btn-create catalog-action-btn",disabled:y||!j.trim()||!C.trim(),onClick:ie,children:[a.jsx(hr,{size:13})," Create App"]})]}),d==="import"&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"catalog-upload-hint",children:"Choose a mini app archive (.zip), as Export downloads it. A missing manifest.json is generated from the app id."}),a.jsx("input",{type:"file",accept:".zip,application/zip","aria-label":"App archive",onChange:E=>void te(E)}),O&&a.jsx("div",{className:"catalog-upload-error",children:O}),q&&a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"dialog-label",children:["App id",a.jsx("input",{className:"dialog-input",type:"text",value:J,onChange:E=>ee(E.target.value)})]}),a.jsxs("div",{className:"catalog-upload-summary",children:[q.name," (",Math.max(1,Math.round(q.size/1024))," KB)"]}),ge!==null&&a.jsxs("label",{className:"app-export-option",children:[a.jsx("input",{type:"checkbox",checked:ge,onChange:E=>Se(E.target.checked)}),a.jsxs("span",{children:["Import data",a.jsx("span",{className:"app-export-option-hint",children:"The archive carries the app’s saved state and stored files."})]})]})]}),a.jsxs("button",{className:"dialog-btn-create catalog-action-btn",disabled:y||!q||!J.trim(),onClick:X,children:[a.jsx(rS,{size:13})," ",y?"Importing…":"Import App"]})]})]}),a.jsx("div",{className:"dialog-footer",children:a.jsx("button",{className:"dialog-btn-cancel",onClick:n,children:"Close"})})]})})}function jj(){var k;const e=R(y=>y.appExportId),n=R(y=>y.apps),r=R(y=>y.closeAppExport),o=R(y=>y.exportApp),[l,c]=x.useState(!1),[d,f]=x.useState(!1);if(x.useEffect(()=>{c(!1)},[e]),!e)return null;const h=e,m=((k=n.find(y=>y.id===h))==null?void 0:k.title)??h;async function v(){if(!d){f(!0);try{await o(h,{data:l})&&r()}finally{f(!1)}}}return a.jsx("div",{className:"dialog-overlay",onClick:r,children:a.jsxs("div",{className:"dialog app-export",role:"dialog","aria-label":"Export Mini App",onClick:y=>y.stopPropagation(),onKeyDown:y=>{y.key==="Escape"&&r()},children:[a.jsxs("div",{className:"dialog-header",children:[a.jsxs("span",{className:"dialog-title",children:["Export ",m]}),a.jsx("button",{className:"dialog-close",onClick:r,children:"✕"})]}),a.jsxs("div",{className:"dialog-body catalog-body",children:[a.jsxs("div",{className:"catalog-upload-hint",children:["Downloads the app’s files as ",a.jsxs("code",{children:[h,".zip"]}),". Import it from Add Mini App → Import."]}),a.jsxs("label",{className:"app-export-option",children:[a.jsx("input",{type:"checkbox",checked:l,onChange:y=>c(y.target.checked),autoFocus:!0}),a.jsxs("span",{children:["Include data",a.jsx("span",{className:"app-export-option-hint",children:"The app’s saved state (global and per workspace) and the files it stored. It may hold private content."})]})]}),a.jsxs("button",{className:"dialog-btn-create catalog-action-btn",disabled:d,onClick:v,children:[a.jsx(of,{size:13})," ",d?"Exporting…":l?"Export with data":"Export"]})]}),a.jsx("div",{className:"dialog-footer",children:a.jsx("button",{className:"dialog-btn-cancel",onClick:r,children:"Cancel"})})]})})}function _j(){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=Xl(k);return[{id:"new-session",label:"New Session",hint:"Create a new Codex session",icon:hr,action:()=>r.setShowNewSessionDialog(!0),available:!0},{id:"delete-session",label:"Delete Session",hint:"Delete the active session",icon:fs,action:()=>{r.activeSessionId&&r.deleteSession(r.activeSessionId)},available:!!r.activeSessionId},{id:"send-message",label:"Send Message",hint:"Focus the message input",icon:Ki,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:B1,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:X1,action:()=>r.toggleRightPanel(),available:!0},{id:"close-tab",label:"Close Tab",hint:"Close the active session tab",icon:Cn,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(D1,{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 Zg=/^[a-z][a-z0-9-]{1,30}$/,Rj=2e3,Aj=2e3;function Ij(){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,j]=x.useState(!1),[N,C]=x.useState("main"),[b,A]=x.useState(null),[L,$]=x.useState(null),[z,q]=x.useState(!1),[F,O]=x.useState(null),[Z,J]=x.useState({kind:"setup"}),[ee,ge]=x.useState(""),[Se,Oe]=x.useState(!1),[xe,ie]=x.useState(null),te=x.useRef(null);Vi(te,()=>j(!1),S);const X=m||k,oe=x.useCallback(async()=>{h(!0),d(null);try{const be=await fetch(`${jt()}/remote/status`,{headers:{Accept:"application/json"}});if(!be.ok)throw new Error(`status ${be.status}`);l(await be.json())}catch{l(null),d("Machine management is only available from this machine's local pane.")}finally{h(!1)}},[]),K=x.useCallback(async()=>{try{const be=await fetch(`${jt()}/auth/status`,{headers:{Accept:"application/json"}});if(!be.ok)throw new Error(`auth status ${be.status}`);const Be=await be.json();return A(Be),Be}catch{return null}},[]);x.useEffect(()=>{e&&(C("main"),ie(null),$(null),O(null),oe(),K())},[e,oe,K]);const E=xe!==null&&xe.state==="running";x.useEffect(()=>{if(!E)return;const be=setInterval(async()=>{try{const Be=await fetch(`${jt()}/remote/enable`,{headers:{Accept:"application/json"}});Be.ok&&ie(await Be.json())}catch{}},Rj);return()=>clearInterval(be)},[E]);const M=N==="login"&&(L==null?void 0:L.state)==="pending";if(x.useEffect(()=>{if(!M)return;const be=setInterval(async()=>{const Be=await K();Be&&(Be.status==="authorized"?(clearInterval(be),$(null),Y()):Be.login&&Be.login.state!=="pending"&&$(Be.login))},Aj);return()=>clearInterval(be)},[M,K,Z]),x.useEffect(()=>{(xe==null?void 0:xe.state)==="needs_login"&&(J({kind:"enable",mahlas:xe.mahlas??ee}),ie(null),C("login"))},[xe,ee]),!e)return null;const ce=!!(o!=null&&o.tunnel.provisioned)&&!!(o!=null&&o.service.running)&&!!(o!=null&&o.connection.ok);function U(be){be.key==="Escape"&&n(!1)}async function ue(){const be=b??await K();(be==null?void 0:be.status)==="authorized"?C("setup"):(J({kind:"setup"}),C("login"))}function Y(){const be=Z;J({kind:"setup"}),be.kind==="enable"?je(be.mahlas):be.kind==="remove"?(C("main"),Ce()):C("setup")}async function we(){q(!0),O(null);const be=window.open("about:blank","_blank");try{const Be=await fetch(`${jt()}/auth/initiate`,{method:"POST"}),qe=await Be.json().catch(()=>({}));if(!Be.ok)throw new Error(qe.error??`initiate ${Be.status}`);$(qe),be&&(be.opener=null,be.location.href=qe.loginUrl)}catch(Be){be==null||be.close(),O(Be.message||"Could not start the sign-in.")}finally{q(!1)}}function ve(){(L==null?void 0:L.state)==="pending"&&fetch(`${jt()}/auth/cancel`,{method:"POST"}).catch(()=>{}),$(null),O(null),C("main")}async function Ie(){await fetch(`${jt()}/auth/logout`,{method:"POST"}).catch(()=>{}),A(null),J({kind:"setup"}),$(null),C("login")}async function je(be){if(Zg.test(be)){Oe(!0);try{const Be=await fetch(`${jt()}/remote/enable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mahlas:be})});if(!Be.ok)throw new Error(`enable ${Be.status}`);ie(await Be.json()),C("setup")}catch{d("Could not start the setup — check the daemon logs.")}finally{Oe(!1)}}}function pe(){xe!=null&&xe.troubleshootingSessionId&&(r(xe.troubleshootingSessionId),n(!1))}async function he(){v(!0);try{await fetch(`${jt()}/remote/disable`,{method:"POST"}),await oe()}catch{d("Could not stop the tunnel service — check the service logs.")}finally{v(!1)}}async function Ye(){j(!1),window.confirm(`Remove the tunnel completely?
|
|
857
|
+
}`;function rj(e){return`(${sj})(${JSON.stringify(e)});`}function qg(e){return e.replace(/<\/script/gi,"<\\/script")}function oj(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 Xg(e,n,r){const o=oj(e,n);return o===-1?e+r:e.slice(0,o)+r+e.slice(o)}function ij(e,n,r){let o=e;const l=`<script>${qg(n)}<\/script>`;if(/<\/head>/i.test(o)?o=Xg(o,"</head>",l):/<html[^>]*>/i.test(o)?o=o.replace(/(<html[^>]*>)/i,`$1<head>${l}</head>`):o=`${l}${o}`,r){const c=`<script>${qg(r)}<\/script>`;o=Xg(o,"</body>",c)}return o}function aj(){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 lj(e){var r;if(!(e instanceof Io)||e.status!==409)return null;const n=(r=e.body)==null?void 0:r.state;return n&&typeof n=="object"?n:null}function cj({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 j=aj(),N=b=>{const A=o.current.version;typeof b.version=="number"&&typeof A=="number"&&b.version<A||(o.current=b)};Kw(e,b=>{var A,L;return(L=(A=r.current)==null?void 0:A.contentWindow)==null?void 0:L.postMessage(b,"*")},n);const C=async b=>{var F,O,Z,J,ee,ge,Se,Oe,xe,ie,te,X,oe,K,E,M,ce,U,ue,Y,we,ve,Ie,je;if(b.source!==((F=r.current)==null?void 0:F.contentWindow))return;const A=b.data;if(!A||A.source!=="agentpane-app")return;if(A.report==="error"){const pe={message:String(A.message??"Unknown error"),stack:String(A.stack??"")};m(he=>{const Ye=he[he.length-1];return Ye&&Ye.message===pe.message?he:[...he,pe].slice(-20)});return}if(typeof A.method!="string")return;let L=!0,$,z,q=null;try{switch(A.method){case"getApp":$={id:e,workspace:n};break;case"getState":try{const pe=await jm(e,n);N(pe),$=pe}catch{$=o.current}break;case"setState":{const pe=((O=A.params)==null?void 0:O.data)??null,he=(Z=A.params)==null?void 0:Z.ifVersion,Ye={data:pe,writer:j};typeof he=="number"&&(Ye.ifVersion=he);try{const Ce=await jv(e,Ye,n);N(Ce),$=Ce}catch(Ce){if(q=lj(Ce),!q)throw Ce;N(q);const ct=Ce.body;throw new Error(typeof(ct==null?void 0:ct.error)=="string"?ct.error:"App state changed since that version")}break}case"createSession":{const pe=A.params??{},he=await Kd({title:typeof pe.title=="string"?pe.title:void 0,runtime_type:typeof pe.runtime_type=="string"?pe.runtime_type:void 0,model:typeof pe.model=="string"?pe.model:void 0,model_reasoning_effort:typeof pe.model_reasoning_effort=="string"?pe.model_reasoning_effort:void 0,cwd:typeof pe.cwd=="string"?pe.cwd:void 0,origin_app_id:e,origin_app_workspace:n});pl(he.id,e),R.getState().addSession(he),$=he;break}case"submitTurn":{const pe=String(((J=A.params)==null?void 0:J.sessionId)??"");if(!await _m(e,pe))throw new Error(`submitTurn: ${pe} is not a session of this app`);const he=String(((ee=A.params)==null?void 0:ee.prompt)??""),Ye=await nj(e,(ge=A.params)==null?void 0:ge.attachments,ct=>n1(e,ct)),Ce=await pv(pe,he,Ye.length?Ye:void 0,{originAppId:e});pl(pe,e),$=Ce;break}case"getSession":{$=await _m(e,String(((Se=A.params)==null?void 0:Se.sessionId)??""));break}case"listSessions":{const pe=(Oe=A.params)==null?void 0:Oe.lifecycle,he=(xe=A.params)==null?void 0:xe.running;$=await Bk(e,n,{lifecycle:pe==="working"||pe==="finished"?pe:void 0,running:typeof he=="boolean"?he:void 0});break}case"getSessionInfo":{$=await Wk(e,n,String(((ie=A.params)==null?void 0:ie.sessionId)??""));break}case"cancelTurn":{$=await Hk(e,String(((te=A.params)==null?void 0:te.sessionId)??""));break}case"setSessionLifecycle":{$=await Vk(e,String(((X=A.params)==null?void 0:X.sessionId)??""),String(((oe=A.params)==null?void 0:oe.lifecycle)??""));break}case"callTool":{const pe=(K=A.params)==null?void 0:K.args;$=await Kk(e,n,String(((E=A.params)==null?void 0:E.tool)??""),pe&&typeof pe=="object"?pe:{});break}case"listProviders":{$=await Jy();break}case"listModels":{const pe=typeof((M=A.params)==null?void 0:M.runtime)=="string"?A.params.runtime.trim():"";if(!pe)throw new Error("listModels: runtime is required");const he=(ce=A.params)==null?void 0:ce.cwd;$=await Cv(pe,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");$=await mv();break}case"resolveToolCall":{const pe=String(((U=A.params)==null?void 0:U.callId)??""),he=(ue=A.params)==null?void 0:ue.result;await Zk(pe,he),$={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 pe=typeof((Y=A.params)==null?void 0:Y.sessionId)=="string"?A.params.sessionId.trim():"";if(!pe)throw new Error("openSession: sessionId is required");try{await R.getState().revealSession(pe)}catch(he){throw new Error(`openSession: ${he instanceof Error?he.message:String(he)}`)}$={ok:!0};break}case"uploadFile":{const pe=await tj((we=A.params)==null?void 0:we.file);try{$=Gg(await e1(e,pe))}catch(he){throw new Error(`uploadFile: ${he instanceof Error?he.message:String(he)}`)}break}case"getFile":{const pe=lx(e,(ve=A.params)==null?void 0:ve.ref),he=pe?await t1(e,pe):null;$=he?Gg(he):null;break}default:throw new Error(`Unknown bridge method: ${A.method}`)}}catch(pe){L=!1,z=pe instanceof Error?pe.message:String(pe)}(je=(Ie=r.current)==null?void 0:Ie.contentWindow)==null||je.postMessage(q?{source:"agentpane-host",id:A.id,ok:L,error:z,code:"conflict",state:q}:{source:"agentpane-host",id:A.id,ok:L,result:$,error:z},"*")};return window.addEventListener("message",C),Jw(e,b=>{var A,L;typeof b.workspace=="string"&&b.workspace!==n||b.writer!==j&&((L=(A=r.current)==null?void 0:A.contentWindow)==null||L.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,A,L]=await Promise.all([Em(e),jm(e,n),Uk(e).catch(()=>[])]);if(!S)return;o.current=A,L.forEach($=>pl($.id,e)),c(b)}catch(b){S&&f(b instanceof Error?b.message:String(b))}})(),()=>{S=!1,Gw(e),Zw(e),ek(e),window.removeEventListener("message",C)}},[e,n]),x.useEffect(()=>{l&&qw(e,l.manifest.headlessSessions===!0)},[e,l]);const v=x.useMemo(()=>l?ij(l.html,rj({appId:e,apiOrigin:ax()}),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,j)=>a.jsxs("div",{className:"miniapp-diag",children:[S.file,":",S.line,":",S.column," — ",S.message]},j))]}),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,j)=>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})]},j))})]})}function uj({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(Mo,{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(Q1,{size:13}),"Edit"]}),a.jsx("button",{className:"miniapp-header-close",title:"Close app",onClick:()=>d(null),children:a.jsx(Cn,{size:14})})]}),a.jsx("div",{className:"miniapp-body",children:a.jsx(cj,{appId:e,workspace:m},`${e}:${m}`)})]})}function dj({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,j=e==="left"?h.current+S:h.current-S,N=Math.min(r,Math.max(n,j));l(N)},[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,j;y.preventDefault(),y.stopPropagation();try{(j=(S=y.currentTarget)==null?void 0:S.setPointerCapture)==null||j.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 Yg({side:e,minWidth:n,maxWidth:r,getWidth:o,setWidth:l}){const{onPointerDown:c,dragging:d}=dj({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 fj=x.lazy(()=>x1(()=>import("./TerminalView-Z7ZJ436H.js"),__vite__mapDeps([0,1])));function pj(){Ut.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 j=Cl(),{rightPanelWidth:N,setRightPanelWidth:C}=R.getState();N>j&&C(j)};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const y=l?`${e}px 6px 1fr ${Mk}px`:`${e}px 6px 1fr 6px ${n}px`;return a.jsxs("div",{className:"ide-root",children:[a.jsx(YE,{}),a.jsxs("div",{className:`ide-layout ${c||d||f?"ide-hidden":""}`,style:{gridTemplateColumns:y},children:[a.jsx(aN,{}),a.jsx(Yg,{side:"left",minWidth:kd,maxWidth:Sd,getWidth:()=>R.getState().sidebarWidth,setWidth:r}),a.jsxs("div",{className:"ide-center",children:[a.jsx(uN,{}),a.jsxs("div",{className:"ide-render",children:[k.map(S=>a.jsx(uj,{appId:S,active:v===S},S)),v==null&&a.jsx(bC,{})]}),a.jsx(MC,{})]}),!l&&a.jsx(Yg,{side:"right",minWidth:Tl,maxWidth:Cl(),getWidth:()=>R.getState().rightPanelWidth,setWidth:o}),a.jsx(nE,{})]}),c&&a.jsx(NE,{}),d&&a.jsx(XE,{}),h&&a.jsx(x.Suspense,{fallback:null,children:a.jsx(fj,{visible:f})}),a.jsx(xE,{})]})}function hj(){var z,q,F;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,j]=x.useState(""),{models:N}=rx(e?l:null);if(!e)return null;const C=O=>N.find(Z=>Z.slug===O),b=m?((z=C(m))==null?void 0:z.reasoningLevels)??[]:[];function A(){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(""),j("")}function L(O){O.key==="Escape"&&n(!1)}function $(O){var ee,ge,Se;v(O);const Z=((ee=C(O))==null?void 0:ee.reasoningLevels)??[];Z.some(Oe=>Oe.effort===k)||y(((ge=C(O))==null?void 0:ge.defaultReasoning)??((Se=Z[0])==null?void 0:Se.effort)??"")}return a.jsx("div",{className:"dialog-overlay",onClick:()=>n(!1),children:a.jsxs("div",{className:"dialog",onClick:O=>O.stopPropagation(),onKeyDown:L,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(Cn,{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:O=>h(O.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:O=>$(O.target.value),children:[a.jsx("option",{value:"",children:"Default (Codex picks)"}),N.map(O=>a.jsxs("option",{value:O.slug,children:[O.displayName," — ",O.description]},O.slug))]})]}),b.length>0&&a.jsxs("label",{className:"dialog-label",children:["Thinking Level",a.jsxs("select",{className:"dialog-input dialog-select",value:k,onChange:O=>y(O.target.value),children:[a.jsxs("option",{value:"",children:["Default",(q=C(m))!=null&&q.defaultReasoning?` (${(F=C(m))==null?void 0:F.defaultReasoning})`:""]}),b.map(O=>a.jsx("option",{value:O.effort,children:O.label},O.effort))]})]}),a.jsxs("label",{className:"dialog-label",children:["Working Directory (optional)",a.jsx("input",{className:"dialog-input",type:"text",value:S,onChange:O=>j(O.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:A,children:"Create"})]})]})})}function mj(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 gj(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 vj(){return R(n=>n.showAddWorkspaceDialog)?a.jsx(yj,{}):null}function yj(){var F;const e=R(O=>O.setShowAddWorkspaceDialog),n=R(O=>O.workspaces),r=R(O=>O.createWorkspaceAt),o=R(O=>O.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(()=>gj(R.getState().workspaces)),j=x.useRef(null),N=x.useCallback(()=>{v||e(!1)},[v,e]);Do(N);const C=x.useCallback(async(O,Z=!1)=>{const J=++y.current;f(!0);let ee=null,ge=null;try{ee=await cm(O)}catch(Se){if(ge=Hn(Se),Z&&O)try{ee=await cm(),ge=null}catch(Oe){ge=Hn(Oe)}}J===y.current&&(ee&&c(ee),m(ge),f(!1))},[]);x.useEffect(()=>{C(S,!0)},[C,S]);const b=l==null?void 0:l.path;x.useEffect(()=>{j.current&&(j.current.scrollTop=0)},[b]);const A=new Set(n.filter(O=>O.deleted===0).map(O=>gr(O.path)));async function L(O){if(!v){k(!0),m(null);try{const Z=await r(O);e(!1),o("success",`Workspace added — ${Z.path}`)}catch(Z){m(Hn(Z)),k(!1)}}}const $=l?mj(l.path,l.home):[],z=((F=$.at(-1))==null?void 0:F.label)??"",q=l!==null&&A.has(gr(l.path));return a.jsx("div",{className:"dialog-overlay",onClick:N,children:a.jsxs("div",{className:"dialog folder-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"folder-dialog-title",onClick:O=>O.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:N,"aria-label":"Close",disabled:v,children:a.jsx(Cn,{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($v,{size:14})}),a.jsx("nav",{className:"folder-crumbs","aria-label":"Folder path",children:$.map((O,Z)=>a.jsxs(x.Fragment,{children:[Z>0&&a.jsx($i,{size:12,className:"folder-crumb-sep","aria-hidden":"true"}),Z===$.length-1?a.jsx("span",{className:"folder-crumb current","aria-current":"location",title:O.path,children:O.label}):a.jsx("button",{className:"folder-crumb",onClick:()=>void C(O.path),title:O.path,children:O.label})]},O.path))}),d&&l&&a.jsx(rn,{size:14,className:"spin folder-spinner","aria-label":"Loading"})]}),a.jsx("ul",{ref:j,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(O=>a.jsxs("li",{className:"folder-item",children:[a.jsxs("button",{className:"folder-row",onClick:()=>void C(O.path),title:O.path,"aria-label":O.git?`${O.name} (git repository)`:O.name,children:[O.git?a.jsx(L1,{size:15,className:"folder-icon git","aria-hidden":"true"}):a.jsx(Il,{size:15,className:"folder-icon","aria-hidden":"true"}),a.jsx("span",{className:"folder-name",children:O.name}),a.jsx($i,{size:13,className:"folder-chevron","aria-hidden":"true"})]}),A.has(gr(O.path))?a.jsx("span",{className:"folder-tag",children:"Added"}):a.jsx("button",{className:"folder-add",onClick:()=>void L(O.path),disabled:v,"aria-label":`Add ${O.name}`,children:"Add"})]},O.path)):d&&a.jsxs("li",{className:"folder-empty",role:"status",children:[a.jsx(rn,{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:N,disabled:v,children:"Cancel"}),a.jsx("button",{className:"dialog-btn-create",onClick:()=>l&&void L(l.path),disabled:!l||d||v||q,children:v?"Adding…":q?"Already added":`Add “${z}”`})]})]})})}const Ud=6e4,Bd=60*Ud,fl=24*Bd;function xj(e,n=Date.now()){const r=Date.parse(e);if(Number.isNaN(r))return"";const o=Math.max(0,n-r);return o<Ud?"just now":o<Bd?`${Math.floor(o/Ud)} min ago`:o<fl?`${Math.floor(o/Bd)} h ago`:o<2*fl?"yesterday":o<7*fl?`${Math.floor(o/fl)} days ago`:new Date(r).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function wj(){const e=R(n=>n.importSessionsWorkspace);return e?a.jsx(kj,{workspace:e},e):null}function kj({workspace:e}){const n=R(F=>F.setImportSessionsWorkspace),r=R(F=>F.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,j]=x.useState(new Map),N=x.useCallback(()=>{k||n(null)},[k,n]);Do(N),x.useEffect(()=>{let F=!1;return Tv(e).then(({sessions:O,errors:Z})=>{if(F)return;const J=Object.values(Z);if(J.length===wd.length){d([...new Set(J)].join("; "));return}l(O),h(Z)}).catch(O=>{F||d(Hn(O))}),()=>{F=!0}},[e]);function C(F){v(O=>{const Z=new Set(O);return Z.has(F)?Z.delete(F):Z.add(F),Z})}const b=o??[],A=F=>Qu({runtime:F.runtime,id:F.session_id}),L=b.length>0&&b.every(F=>m.has(A(F)));async function $(){const F=b.filter(J=>m.has(A(J))).map(J=>({runtime:J.runtime,id:J.session_id}));if(F.length===0)return;y(!0);const{failed:O}=await r(e,F);if(y(!1),O.length===0){n(null);return}const Z=new Set(O.map(Qu));l(J=>(J??[]).filter(ee=>!m.has(A(ee))||Z.has(A(ee)))),v(Z),j(new Map(O.map(J=>[Qu(J),J.error])))}const z=e.split("/").pop()||e,q=m.size;return a.jsx("div",{className:"dialog-overlay",onClick:N,children:a.jsxs("div",{className:"dialog import-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"import-dialog-title",onClick:F=>F.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:N,"aria-label":"Close",disabled:k,children:a.jsx(Cn,{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:z}),", 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(rn,{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(Qg,{errors:f})]}):a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"import-select-all",children:[a.jsx("input",{type:"checkbox",checked:L,disabled:k,onChange:()=>v(L?new Set:new Set(b.map(A)))}),"Select all (",o.length,")"]}),a.jsx("ul",{className:"import-list",children:o.map(F=>{const O=A(F),Z=S.get(O);return a.jsx("li",{children:a.jsxs("label",{className:`import-row${m.has(O)?" selected":""}`,children:[a.jsx("input",{type:"checkbox",checked:m.has(O),disabled:k,onChange:()=>C(O)}),a.jsxs("span",{className:"import-row-main",children:[a.jsx("span",{className:"import-row-title",title:F.title,children:F.title}),a.jsxs("span",{className:"import-row-meta",children:[a.jsx("span",{className:`import-row-runtime ${F.runtime}`,children:Zl[F.runtime]}),a.jsx("span",{title:new Date(F.last_modified).toLocaleString(),children:xj(F.last_modified)}),F.git_branch&&a.jsxs("span",{className:"import-row-branch",title:"Git branch",children:[a.jsx(Uv,{size:10})," ",F.git_branch]})]}),F.recently_active&&a.jsxs("span",{className:"import-row-warn",children:[a.jsx(nc,{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."]}),Z&&a.jsx("span",{className:"import-row-error",role:"alert",children:Z})]})]})},O)})}),a.jsx(Qg,{errors:f})]})]}),a.jsxs("div",{className:"dialog-footer",children:[a.jsx("button",{className:"dialog-btn-cancel",onClick:N,disabled:k,children:"Cancel"}),a.jsx("button",{className:"dialog-btn-create",onClick:()=>void $(),disabled:q===0||k,children:k?a.jsxs(a.Fragment,{children:[a.jsx(rn,{size:12,className:"spin"})," Importing…"]}):q>1?`Import ${q} sessions`:"Import"})]})]})})}function Qg({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 ",Zl[r]," sessions — ",o]},r))})}const Sj=50*1024*1024;function bj(e){const n=e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"");return/^[a-z0-9]/.test(n)?n:""}function Nj(e){return bj(e.replace(/\.zip$/i,"").replace(/\s*\(\d+\)$/,""))}const Tj=new TextEncoder().encode(".agentpane-data/data.json");async function Cj(e){const n=new Uint8Array(await e.arrayBuffer()),r=Tj;e:for(let o=0;o<=n.length-r.length;o++){for(let l=0;l<r.length;l++)if(n[o+l]!==r[l])continue e;return!0}return!1}function Ej(){const{appCatalogOpen:e,closeAppCatalog:n,apps:r,installExampleApp:o,createSkeletonApp:l,importAppZip:c}=R(),[d,f]=x.useState("examples"),[h,m]=x.useState(null),[v,k]=x.useState(null),[y,S]=x.useState(!1),[j,N]=x.useState(""),[C,b]=x.useState(""),[A,L]=x.useState(""),[$,z]=x.useState(""),[q,F]=x.useState(null),[O,Z]=x.useState(null),[J,ee]=x.useState(""),[ge,Se]=x.useState(null);if(x.useEffect(()=>{e&&(m(null),Gk().then(m).catch(()=>m([])))},[e]),!e)return null;const Oe=new Set(r.map(E=>E.id));async function xe(E){k(E);try{await o(E)&&n()}finally{k(null)}}async function ie(){if(y)return;const E=j.trim(),M=C.trim();if(!(!E||!M)){S(!0);try{await l({id:E,title:M,description:A.trim()||void 0,icon:$.trim()||void 0})&&(N(""),b(""),L(""),z(""),n())}finally{S(!1)}}}async function te(E){var ce;const M=((ce=E.target.files)==null?void 0:ce[0])??null;if(Z(null),F(null),Se(null),!!M){if(!/\.zip$/i.test(M.name)){Z("Choose a .zip file.");return}if(M.size>Sj){Z("The archive is larger than 50 MB.");return}ee(Nj(M.name)),Se(await Cj(M).catch(()=>!1)?!0:null),F(M)}}async function X(){if(!(y||!q||!J.trim())){S(!0);try{await c(J.trim(),q,{data:ge===!0})&&(F(null),ee(""),n())}finally{S(!1)}}}function oe(E){E.key==="Escape"&&n()}const K=[{key:"examples",label:"Examples"},{key:"new",label:"New App"},{key:"import",label:"Import"}];return a.jsx("div",{className:"dialog-overlay",onClick:n,children:a.jsxs("div",{className:"dialog app-catalog",onClick:E=>E.stopPropagation(),onKeyDown:oe,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:K.map(E=>a.jsx("button",{className:`catalog-tab${d===E.key?" active":""}`,onClick:()=>f(E.key),children:E.label},E.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(E=>{const M=Oe.has(E.id);return a.jsxs("div",{className:"example-row",children:[a.jsx(Mo,{iconNode:E.iconNode,size:14,className:"sidebar-app-icon"}),a.jsxs("div",{className:"example-info",children:[a.jsx("span",{className:"example-title",children:E.title}),E.description&&a.jsx("span",{className:"example-desc",children:E.description})]}),a.jsx("button",{className:"example-install",disabled:M||v===E.id,onClick:()=>xe(E.id),title:M?"Already installed":"Install this example",children:M?"Installed":v===E.id?"Installing…":"Install"})]},E.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:j,onChange:E=>N(E.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:E=>b(E.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:A,onChange:E=>L(E.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:$,onChange:E=>z(E.target.value),placeholder:"e.g. notebook-pen",spellCheck:!1,autoCapitalize:"off"})]}),a.jsxs("button",{className:"dialog-btn-create catalog-action-btn",disabled:y||!j.trim()||!C.trim(),onClick:ie,children:[a.jsx(hr,{size:13})," Create App"]})]}),d==="import"&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"catalog-upload-hint",children:"Choose a mini app archive (.zip), as Export downloads it. A missing manifest.json is generated from the app id."}),a.jsx("input",{type:"file",accept:".zip,application/zip","aria-label":"App archive",onChange:E=>void te(E)}),O&&a.jsx("div",{className:"catalog-upload-error",children:O}),q&&a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"dialog-label",children:["App id",a.jsx("input",{className:"dialog-input",type:"text",value:J,onChange:E=>ee(E.target.value)})]}),a.jsxs("div",{className:"catalog-upload-summary",children:[q.name," (",Math.max(1,Math.round(q.size/1024))," KB)"]}),ge!==null&&a.jsxs("label",{className:"app-export-option",children:[a.jsx("input",{type:"checkbox",checked:ge,onChange:E=>Se(E.target.checked)}),a.jsxs("span",{children:["Import data",a.jsx("span",{className:"app-export-option-hint",children:"The archive carries the app’s saved state and stored files."})]})]})]}),a.jsxs("button",{className:"dialog-btn-create catalog-action-btn",disabled:y||!q||!J.trim(),onClick:X,children:[a.jsx(rS,{size:13})," ",y?"Importing…":"Import App"]})]})]}),a.jsx("div",{className:"dialog-footer",children:a.jsx("button",{className:"dialog-btn-cancel",onClick:n,children:"Close"})})]})})}function jj(){var k;const e=R(y=>y.appExportId),n=R(y=>y.apps),r=R(y=>y.closeAppExport),o=R(y=>y.exportApp),[l,c]=x.useState(!1),[d,f]=x.useState(!1);if(x.useEffect(()=>{c(!1)},[e]),!e)return null;const h=e,m=((k=n.find(y=>y.id===h))==null?void 0:k.title)??h;async function v(){if(!d){f(!0);try{await o(h,{data:l})&&r()}finally{f(!1)}}}return a.jsx("div",{className:"dialog-overlay",onClick:r,children:a.jsxs("div",{className:"dialog app-export",role:"dialog","aria-label":"Export Mini App",onClick:y=>y.stopPropagation(),onKeyDown:y=>{y.key==="Escape"&&r()},children:[a.jsxs("div",{className:"dialog-header",children:[a.jsxs("span",{className:"dialog-title",children:["Export ",m]}),a.jsx("button",{className:"dialog-close",onClick:r,children:"✕"})]}),a.jsxs("div",{className:"dialog-body catalog-body",children:[a.jsxs("div",{className:"catalog-upload-hint",children:["Downloads the app’s files as ",a.jsxs("code",{children:[h,".zip"]}),". Import it from Add Mini App → Import."]}),a.jsxs("label",{className:"app-export-option",children:[a.jsx("input",{type:"checkbox",checked:l,onChange:y=>c(y.target.checked),autoFocus:!0}),a.jsxs("span",{children:["Include data",a.jsx("span",{className:"app-export-option-hint",children:"The app’s saved state (global and per workspace) and the files it stored. It may hold private content."})]})]}),a.jsxs("button",{className:"dialog-btn-create catalog-action-btn",disabled:d,onClick:v,children:[a.jsx(of,{size:13})," ",d?"Exporting…":l?"Export with data":"Export"]})]}),a.jsx("div",{className:"dialog-footer",children:a.jsx("button",{className:"dialog-btn-cancel",onClick:r,children:"Cancel"})})]})})}function _j(){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=Xl(k);return[{id:"new-session",label:"New Session",hint:"Create a new Codex session",icon:hr,action:()=>r.setShowNewSessionDialog(!0),available:!0},{id:"delete-session",label:"Delete Session",hint:"Delete the active session",icon:fs,action:()=>{r.activeSessionId&&r.deleteSession(r.activeSessionId)},available:!!r.activeSessionId},{id:"send-message",label:"Send Message",hint:"Focus the message input",icon:Ki,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:B1,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:X1,action:()=>r.toggleRightPanel(),available:!0},{id:"close-tab",label:"Close Tab",hint:"Close the active session tab",icon:Cn,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(D1,{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 Zg=/^[a-z][a-z0-9-]{1,30}$/,Rj=2e3,Aj=2e3;function Ij(){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,j]=x.useState(!1),[N,C]=x.useState("main"),[b,A]=x.useState(null),[L,$]=x.useState(null),[z,q]=x.useState(!1),[F,O]=x.useState(null),[Z,J]=x.useState({kind:"setup"}),[ee,ge]=x.useState(""),[Se,Oe]=x.useState(!1),[xe,ie]=x.useState(null),te=x.useRef(null);Vi(te,()=>j(!1),S);const X=m||k,oe=x.useCallback(async()=>{h(!0),d(null);try{const be=await fetch(`${jt()}/remote/status`,{headers:{Accept:"application/json"}});if(!be.ok)throw new Error(`status ${be.status}`);l(await be.json())}catch{l(null),d("Machine management is only available from this machine's local pane.")}finally{h(!1)}},[]),K=x.useCallback(async()=>{try{const be=await fetch(`${jt()}/auth/status`,{headers:{Accept:"application/json"}});if(!be.ok)throw new Error(`auth status ${be.status}`);const Be=await be.json();return A(Be),Be}catch{return null}},[]);x.useEffect(()=>{e&&(C("main"),ie(null),$(null),O(null),oe(),K())},[e,oe,K]);const E=xe!==null&&xe.state==="running";x.useEffect(()=>{if(!E)return;const be=setInterval(async()=>{try{const Be=await fetch(`${jt()}/remote/enable`,{headers:{Accept:"application/json"}});Be.ok&&ie(await Be.json())}catch{}},Rj);return()=>clearInterval(be)},[E]);const M=N==="login"&&(L==null?void 0:L.state)==="pending";if(x.useEffect(()=>{if(!M)return;const be=setInterval(async()=>{const Be=await K();Be&&(Be.status==="authorized"?(clearInterval(be),$(null),Y()):Be.login&&Be.login.state!=="pending"&&$(Be.login))},Aj);return()=>clearInterval(be)},[M,K,Z]),x.useEffect(()=>{(xe==null?void 0:xe.state)==="needs_login"&&(J({kind:"enable",mahlas:xe.mahlas??ee}),ie(null),C("login"))},[xe,ee]),!e)return null;const ce=!!(o!=null&&o.tunnel.provisioned)&&!!(o!=null&&o.service.running)&&!!(o!=null&&o.connection.ok);function U(be){be.key==="Escape"&&n(!1)}async function ue(){const be=b??await K();(be==null?void 0:be.status)==="authorized"?C("setup"):(J({kind:"setup"}),C("login"))}function Y(){const be=Z;J({kind:"setup"}),be.kind==="enable"?je(be.mahlas):be.kind==="remove"?(C("main"),Ce()):C("setup")}async function we(){q(!0),O(null);const be=window.open("about:blank","_blank");try{const Be=await fetch(`${jt()}/auth/initiate`,{method:"POST"}),qe=await Be.json().catch(()=>({}));if(!Be.ok)throw new Error(qe.error??`initiate ${Be.status}`);$(qe),be&&(be.opener=null,be.location.href=qe.loginUrl)}catch(Be){be==null||be.close(),O(Be.message||"Could not start the sign-in.")}finally{q(!1)}}function ve(){(L==null?void 0:L.state)==="pending"&&fetch(`${jt()}/auth/cancel`,{method:"POST"}).catch(()=>{}),$(null),O(null),C("main")}async function Ie(){await fetch(`${jt()}/auth/logout`,{method:"POST"}).catch(()=>{}),A(null),J({kind:"setup"}),$(null),C("login")}async function je(be){if(Zg.test(be)){Oe(!0);try{const Be=await fetch(`${jt()}/remote/enable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mahlas:be})});if(!Be.ok)throw new Error(`enable ${Be.status}`);ie(await Be.json()),C("setup")}catch{d("Could not start the setup — check the daemon logs.")}finally{Oe(!1)}}}function pe(){xe!=null&&xe.troubleshootingSessionId&&(r(xe.troubleshootingSessionId),n(!1))}async function he(){v(!0);try{await fetch(`${jt()}/remote/disable`,{method:"POST"}),await oe()}catch{d("Could not stop the tunnel service — check the service logs.")}finally{v(!1)}}async function Ye(){j(!1),window.confirm(`Remove the tunnel completely?
|
|
848
858
|
|
|
849
859
|
This deletes the Cloudflare tunnel, its DNS record and sign-in sessions, and this machine's remote state. The mahlas is released.
|
|
850
860
|
|
|
@@ -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-
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-CjwvHfxy.js"></script>
|
|
14
14
|
<link rel="stylesheet" crossorigin href="/assets/index-C1m0abtH.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"tree": "3f01773d2dfcfcfee7b73a8c7d7497c15ad692bc",
|
|
3
|
-
"commit": "
|
|
3
|
+
"commit": "b5f34e1b25a75186f3b4f98f3d187816f4649086",
|
|
4
4
|
"dirty": false,
|
|
5
|
-
"repoburgVersion": "1.3.
|
|
6
|
-
"builtAt": "2026-11-
|
|
5
|
+
"repoburgVersion": "1.3.322",
|
|
6
|
+
"builtAt": "2026-11-18T00:48:19.237Z"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"tree": "3f01773d2dfcfcfee7b73a8c7d7497c15ad692bc",
|
|
3
|
-
"commit": "
|
|
3
|
+
"commit": "b5f34e1b25a75186f3b4f98f3d187816f4649086",
|
|
4
4
|
"dirty": false,
|
|
5
|
-
"repoburgVersion": "1.3.
|
|
6
|
-
"builtAt": "2026-11-
|
|
5
|
+
"repoburgVersion": "1.3.322",
|
|
6
|
+
"builtAt": "2026-11-18T00:48:19.237Z"
|
|
7
7
|
}
|