remote-codex 0.11.34 → 0.11.35

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
- import{j as e,r as n,L as Le,u as Ye,d as Dt,b as Qr,e as Zs,f as Do,N as os,B as Uo,h as en,i as Ne,O as $o,k as Mo,c as Ho}from"./react-vendor-Dfg_6BLf.js";import{u as Ut,a as tn,t as _o,f as fr,T as Bo,C as Xs,b as Wo,c as Fo,d as qo,e as Vo,g as zo,L as Go,P as Jo,A as Ko}from"./thread-ui-DoKAPILv.js";import{l as q}from"./ui-vendor-CuR8GHb0.js";import"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import"./markdown-vendor-RZk8L7-L.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const i of l.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function a(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=a(o);fetch(o.href,l)}})();var Yo=["codex","claude","opencode"],Je="codex",pr={codex:{displayName:"Codex",description:"Local Codex app-server runtime.",defaultTransport:"stdio",homeEnvVar:"CODEX_HOME",commandEnvVar:"CODEX_COMMAND",defaultHomeDir:".codex",defaultCommand:"codex"},claude:{displayName:"Claude Code",description:"Local Claude Code Agent SDK runtime.",defaultTransport:"sdk",homeEnvVar:"CLAUDE_HOME",commandEnvVar:"CLAUDE_COMMAND",defaultHomeDir:".claude",defaultCommand:"claude"},opencode:{displayName:"OpenCode",description:"Local OpenCode runtime.",defaultTransport:"sdk",homeEnvVar:"OPENCODE_HOME",commandEnvVar:"OPENCODE_COMMAND",defaultHomeDir:".opencode",defaultCommand:"opencode"}};function Zo(t){return typeof t=="string"&&Yo.includes(t)}function Xo(t){return Zo(t)?t:null}var xr=15;function Qo(t){return t.replace(/\s+/g," ").trim()}function el(t){const s=Qo(t);if(!s)return"";const a=Array.from(s);return a.length<=xr?s:`${a.slice(0,xr).join("")}...`}const tl=["codex","claude","opencode"],sn="codex",an={codex:{displayName:"Codex",description:"Local Codex app-server runtime.",defaultTransport:"stdio",homeEnvVar:"CODEX_HOME",commandEnvVar:"CODEX_COMMAND",defaultHomeDir:".codex",defaultCommand:"codex"},claude:{displayName:"Claude Code",description:"Local Claude Code Agent SDK runtime.",defaultTransport:"sdk",homeEnvVar:"CLAUDE_HOME",commandEnvVar:"CLAUDE_COMMAND",defaultHomeDir:".claude",defaultCommand:"claude"},opencode:{displayName:"OpenCode",description:"Local OpenCode runtime.",defaultTransport:"sdk",homeEnvVar:"OPENCODE_HOME",commandEnvVar:"OPENCODE_COMMAND",defaultHomeDir:".opencode",defaultCommand:"opencode"}},gr=15;function sl(t){return t.replace(/\s+/g," ").trim()}function al(t){const s=sl(t);if(!s)return"";const a=Array.from(s);return a.length<=gr?s:`${a.slice(0,gr).join("")}...`}function Ts(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:e.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})}const rl=[{value:"light",label:"Light",description:"Always use the bright theme."},{value:"dark",label:"Dark",description:"Always use the dark theme."},{value:"system",label:"System",description:"Follow the operating system appearance."}],rn={hostConfigFiles:[],toolboxItems:[],hookCommandTemplates:[],providerConfigFormat:"none",mcpConfigFormat:"none",configArchives:!1,buildRestart:!1},nl={codex:{packageName:"@openai/codex",installCommand:null,updateCommand:"npm install -g @openai/codex@latest"},claude:{packageName:"@anthropic-ai/claude-agent-sdk",installCommand:"npm install -g @anthropic-ai/claude-code @anthropic-ai/claude-agent-sdk",updateCommand:"npm install -g @anthropic-ai/claude-code@latest @anthropic-ai/claude-agent-sdk@latest"},opencode:{packageName:"opencode-ai",installCommand:"npm install -g opencode-ai @opencode-ai/sdk",updateCommand:"npm install -g opencode-ai@latest @opencode-ai/sdk@latest"}};function Bs(t){const s=nl[t];return{packageName:s.packageName,installed:t==="codex",installedVersion:null,latestVersion:null,installCommand:s.installCommand,updateCommand:s.updateCommand,busy:!1,lastError:null}}function ol(t,s){return{provider:t,displayName:s,description:`${s} backend descriptor is not available.`,enabled:!1,isDefault:t===sn,status:{state:"stopped",transport:an[t].defaultTransport,lastStartedAt:null,lastError:"Backend descriptor is not available.",restartCount:0},capabilities:{sessions:{list:!1,read:!1,resume:!1,importLocal:!1},turns:{start:!1,streamInput:!1,steer:!1,interrupt:!1,compact:!1},branching:{fork:!1,hardRollback:!1,resumeAt:!1,rewindFiles:!1},controls:{planMode:!1,permissionRequests:!1,sandboxMode:!1,performanceMode:!1,goals:!1},management:{models:!1,mcpStatus:!1,skills:!1,hooks:!1,hookTrust:!1,hostConfigFiles:!1,providerSettings:!1},usage:{contextWindow:!1,tokenUsage:!1,costUsd:!1}},managementSchema:rn,installation:Bs(t)}}function Es(t){const s=t.installation??Bs(t.provider);return{...t,installation:{...Bs(t.provider),...s}}}const vt=[...tl.map(t=>ol(t,an[t].displayName))];function ll(t){var s;return((s=vt.find(a=>a.provider===t))==null?void 0:s.managementSchema)??rn}function il(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function dl(t){const s=t.payload.details,a=typeof(s==null?void 0:s.stderr)=="string"&&s.stderr.trim()?s.stderr.trim():typeof(s==null?void 0:s.stdout)=="string"&&s.stdout.trim()?s.stdout.trim():null;return a?`${t.message}
1
+ import{j as e,r as n,L as Le,u as Ye,d as Dt,b as Qr,e as Zs,f as Do,N as os,B as Uo,h as en,i as Ne,O as $o,k as Mo,c as Ho}from"./react-vendor-Dfg_6BLf.js";import{u as Ut,a as tn,t as _o,f as fr,T as Bo,C as Xs,b as Wo,c as Fo,d as qo,e as Vo,g as zo,L as Go,P as Jo,A as Ko}from"./thread-ui-CK1xSLOW.js";import{l as q}from"./ui-vendor-CuR8GHb0.js";import"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import"./markdown-vendor-RZk8L7-L.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const i of l.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function a(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=a(o);fetch(o.href,l)}})();var Yo=["codex","claude","opencode"],Je="codex",pr={codex:{displayName:"Codex",description:"Local Codex app-server runtime.",defaultTransport:"stdio",homeEnvVar:"CODEX_HOME",commandEnvVar:"CODEX_COMMAND",defaultHomeDir:".codex",defaultCommand:"codex"},claude:{displayName:"Claude Code",description:"Local Claude Code Agent SDK runtime.",defaultTransport:"sdk",homeEnvVar:"CLAUDE_HOME",commandEnvVar:"CLAUDE_COMMAND",defaultHomeDir:".claude",defaultCommand:"claude"},opencode:{displayName:"OpenCode",description:"Local OpenCode runtime.",defaultTransport:"sdk",homeEnvVar:"OPENCODE_HOME",commandEnvVar:"OPENCODE_COMMAND",defaultHomeDir:".opencode",defaultCommand:"opencode"}};function Zo(t){return typeof t=="string"&&Yo.includes(t)}function Xo(t){return Zo(t)?t:null}var xr=15;function Qo(t){return t.replace(/\s+/g," ").trim()}function el(t){const s=Qo(t);if(!s)return"";const a=Array.from(s);return a.length<=xr?s:`${a.slice(0,xr).join("")}...`}const tl=["codex","claude","opencode"],sn="codex",an={codex:{displayName:"Codex",description:"Local Codex app-server runtime.",defaultTransport:"stdio",homeEnvVar:"CODEX_HOME",commandEnvVar:"CODEX_COMMAND",defaultHomeDir:".codex",defaultCommand:"codex"},claude:{displayName:"Claude Code",description:"Local Claude Code Agent SDK runtime.",defaultTransport:"sdk",homeEnvVar:"CLAUDE_HOME",commandEnvVar:"CLAUDE_COMMAND",defaultHomeDir:".claude",defaultCommand:"claude"},opencode:{displayName:"OpenCode",description:"Local OpenCode runtime.",defaultTransport:"sdk",homeEnvVar:"OPENCODE_HOME",commandEnvVar:"OPENCODE_COMMAND",defaultHomeDir:".opencode",defaultCommand:"opencode"}},gr=15;function sl(t){return t.replace(/\s+/g," ").trim()}function al(t){const s=sl(t);if(!s)return"";const a=Array.from(s);return a.length<=gr?s:`${a.slice(0,gr).join("")}...`}function Ts(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:e.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})}const rl=[{value:"light",label:"Light",description:"Always use the bright theme."},{value:"dark",label:"Dark",description:"Always use the dark theme."},{value:"system",label:"System",description:"Follow the operating system appearance."}],rn={hostConfigFiles:[],toolboxItems:[],hookCommandTemplates:[],providerConfigFormat:"none",mcpConfigFormat:"none",configArchives:!1,buildRestart:!1},nl={codex:{packageName:"@openai/codex",installCommand:null,updateCommand:"npm install -g @openai/codex@latest"},claude:{packageName:"@anthropic-ai/claude-agent-sdk",installCommand:"npm install -g @anthropic-ai/claude-code @anthropic-ai/claude-agent-sdk",updateCommand:"npm install -g @anthropic-ai/claude-code@latest @anthropic-ai/claude-agent-sdk@latest"},opencode:{packageName:"opencode-ai",installCommand:"npm install -g opencode-ai @opencode-ai/sdk",updateCommand:"npm install -g opencode-ai@latest @opencode-ai/sdk@latest"}};function Bs(t){const s=nl[t];return{packageName:s.packageName,installed:t==="codex",installedVersion:null,latestVersion:null,installCommand:s.installCommand,updateCommand:s.updateCommand,busy:!1,lastError:null}}function ol(t,s){return{provider:t,displayName:s,description:`${s} backend descriptor is not available.`,enabled:!1,isDefault:t===sn,status:{state:"stopped",transport:an[t].defaultTransport,lastStartedAt:null,lastError:"Backend descriptor is not available.",restartCount:0},capabilities:{sessions:{list:!1,read:!1,resume:!1,importLocal:!1},turns:{start:!1,streamInput:!1,steer:!1,interrupt:!1,compact:!1},branching:{fork:!1,hardRollback:!1,resumeAt:!1,rewindFiles:!1},controls:{planMode:!1,permissionRequests:!1,sandboxMode:!1,performanceMode:!1,goals:!1},management:{models:!1,mcpStatus:!1,skills:!1,hooks:!1,hookTrust:!1,hostConfigFiles:!1,providerSettings:!1},usage:{contextWindow:!1,tokenUsage:!1,costUsd:!1}},managementSchema:rn,installation:Bs(t)}}function Es(t){const s=t.installation??Bs(t.provider);return{...t,installation:{...Bs(t.provider),...s}}}const vt=[...tl.map(t=>ol(t,an[t].displayName))];function ll(t){var s;return((s=vt.find(a=>a.provider===t))==null?void 0:s.managementSchema)??rn}function il(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function dl(t){const s=t.payload.details,a=typeof(s==null?void 0:s.stderr)=="string"&&s.stderr.trim()?s.stderr.trim():typeof(s==null?void 0:s.stdout)=="string"&&s.stdout.trim()?s.stdout.trim():null;return a?`${t.message}
2
2
  ${a}`:t.message}function Tt(t){return{path:t,exists:!1,originalContent:"",draftContent:"",loading:!1,saving:!1,error:null,saveMessage:null}}const cl=/^\/devices\/([^/]+)(?:\/|$)/,ul=/^(?:\/devices\/[^/]+)?\/threads\/([^/?#]+)(?:[/?#]|$)/;function nn(t){const s=cl.exec(t);return s?decodeURIComponent(s[1]??""):null}function Ke(){return typeof window>"u"?null:nn(window.location.pathname)}function ml(t){const s=ul.exec(t);return s?decodeURIComponent(s[1]??""):null}function hl(){return typeof window>"u"?null:ml(window.location.pathname)}function $t(t,s){if(!s)return t;const a=t.startsWith("/")?t:`/${t}`;return`/devices/${encodeURIComponent(s)}${a}`}function vr(t){return $t(t,Ke())}function Ws(t,s){return $t(`/threads/${encodeURIComponent(t)}`,s)}function $e(t){return Ws(t,Ke())}function fl(t,s){const a=t?`?workspaceId=${encodeURIComponent(t)}`:"";return $t(`/threads${a}`,s)}function Ot(t){return fl(t,Ke())}function pl(t,s){const a=t?`?workspaceId=${encodeURIComponent(t)}`:"";return $t(`/threads/new${a}`,s)}function ls(t){return pl(t,Ke())}function Fs(t){return $t("/workspaces",t)}function fs(){return Fs(Ke())}class se extends Error{constructor(s,a){super(a.message),this.statusCode=s,this.payload=a}}const qs="remote-codex-auth-token",Vs="remote-codex-relay-token",zs="remote-codex-relay-admin-token",on="remote-codex-relay-mode",Gs="remote-codex-relay-device-id",Js="remote-codex-relay-thread-id",Ks="remote-codex:hosted-vm-wake";function br(t){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Ks,{detail:t}))}function xl(t,s){return new Promise((a,r)=>{const o=window.setTimeout(a,t);s==null||s.addEventListener("abort",()=>{window.clearTimeout(o),r(s.reason??new DOMException("Request aborted.","AbortError"))},{once:!0})})}function ln(){return typeof window>"u"?null:window.localStorage.getItem(qs)}function gl(t){if(!(typeof window>"u")){if(t){window.localStorage.setItem(qs,t);return}window.localStorage.removeItem(qs)}}function dn(){return typeof window>"u"?null:window.localStorage.getItem(Vs)}function vl(){return typeof window>"u"?null:window.localStorage.getItem(zs)}function Qs(t){if(!(typeof window>"u")){if(t){window.localStorage.setItem(Vs,t);return}window.localStorage.removeItem(Vs)}}function cn(t){if(!(typeof window>"u")){if(t){window.localStorage.setItem(zs,t);return}window.localStorage.removeItem(zs)}}function bt(){var t;return typeof window>"u"?!1:((t=window.__REMOTE_CODEX_BOOTSTRAP__)==null?void 0:t.mode)==="relay"||window.location.pathname.startsWith("/relay-portal")||window.location.pathname.startsWith("/relay-admin")||window.location.pathname.startsWith("/relay-account")||window.location.pathname.startsWith("/relay-devices")||window.location.pathname.startsWith("/relay-guide")||window.location.search.includes("relay=1")||window.localStorage.getItem(on)==="true"}function qe(){typeof window>"u"||window.localStorage.setItem(on,"true")}function rt(){return bt()}function un(){return typeof window>"u"?null:Ke()??window.localStorage.getItem(Gs)}function ss(t){if(!(typeof window>"u")){if(t){window.localStorage.setItem(Gs,t);return}window.localStorage.removeItem(Gs)}}function bl(){return typeof window>"u"?null:hl()??window.localStorage.getItem(Js)}function as(t){if(!(typeof window>"u")){if(t){window.localStorage.setItem(Js,t);return}window.localStorage.removeItem(Js)}}function ea(t){if(!bt())return t;if(t.startsWith("/api/")){const s=un();return s?`/relay/devices/${encodeURIComponent(s)}${t}`:`/relay${t}`}return t}function mn(t){return ea(t)}function yl(t){return t===400?"bad_request":t===401?"unauthorized":t===403?"forbidden":t===404?"not_found":t===409?"conflict":t===429||t===503?"service_unavailable":"internal_error"}function wl(t,s){const a=s==null?void 0:s.trim(),r=a?`${t} ${a}`:`${t}`;return t===429?`Too many requests (${r}).`:t===503?`Upstream service unavailable (${r}).`:`Request failed (${r}).`}function pt(t,s,a){const r=typeof(s==null?void 0:s.message)=="string"&&s.message.trim()?s.message.trim():a,o=s!=null&&s.details&&typeof s.details=="object"?s.details:void 0;return{code:(s==null?void 0:s.code)??yl(t.status),message:r,...o?{details:o}:{}}}async function hn(t){var o,l;const s=wl(t.status,t.statusText),a=((l=(o=t.headers)==null?void 0:o.get)==null?void 0:l.call(o,"content-type"))??"",r=async()=>pt(t,await t.json(),s);if(a.includes("application/json"))try{return await r()}catch{return pt(t,null,s)}try{if(typeof t.text!="function")try{return await r()}catch{return pt(t,null,s)}const i=(await t.text()).trim();if(i.startsWith("{"))try{return pt(t,JSON.parse(i),s)}catch{}return pt(t,i?{message:`${s}
3
3
  ${i}`}:null,s)}catch{try{return await r()}catch{return pt(t,null,s)}}}async function R(t,s,a={}){var i;const r=new Headers(s==null?void 0:s.headers);(s==null?void 0:s.body)!==void 0&&!(s.body instanceof FormData)&&!r.has("Content-Type")&&r.set("Content-Type","application/json");const o=pn({...s,headers:r},a.auth);let l=0;for(;;){const c=await fetch(ea(String(t)),o);if(c.ok)return l>0&&br({state:"connected",attempt:l}),await c.json();const f=await hn(c);if(!(c.status===503&&((i=f.details)==null?void 0:i.reason)==="hosted_sandbox_starting")||l>=60)throw new se(c.status,f);l+=1,br({state:"starting",attempt:l}),await xl(1500,o.signal)}}function jl(t){const s=String(t);return s.includes("/exports/pdf")?s.includes("format=html")?"remote-codex-transcript.html":"remote-codex-transcript.pdf":"download"}function Nl(t){var o;if(!t)return null;const s=t.match(/filename\*=UTF-8''([^;]+)/i);if(s!=null&&s[1])try{return decodeURIComponent(s[1].trim())}catch{return s[1].trim()}const a=t.match(/filename="([^"]+)"/i);if(a!=null&&a[1])return a[1].trim();const r=t.match(/filename=([^;]+)/i);return((o=r==null?void 0:r[1])==null?void 0:o.trim())??null}async function fn(t,s){const a=await fetch(ea(String(t)),pn(s));if(!a.ok){const o=await hn(a);throw new se(a.status,o)}const r=Nl(a.headers.get("content-disposition"))??jl(t);return{blob:await a.blob(),filename:r}}function pn(t={},s="default"){const a=new Headers(t.headers),r=bt();if(s!=="none"&&!a.has("Authorization"))if(s==="relay-admin"){const o=vl();o&&a.set("Authorization",`Bearer ${o}`)}else{const o=dn(),l=ln();r&&o?a.set("Authorization",`Bearer ${o}`):!r&&l&&a.set("Authorization",`Bearer ${l}`)}return{...t,credentials:t.credentials??"same-origin",headers:a}}function yr(t,s){const a=t.originalName.trim();if(a)return a;const r=t.file.name.trim();return r||(t.kind==="photo"?`photo-${s+1}.jpg`:`file-${s+1}`)}function kl(){return R("/api/config/runtime")}function Sl(){return R("/api/auth/session",{cache:"no-store"})}async function Cl(t){const s=await R("/api/auth/login",{method:"POST",body:JSON.stringify(t)});return gl(s.token??null),s}function yt(){return R("/relay/auth/session",{cache:"no-store"})}async function Tl(t){qe();const s=await R("/relay/auth/login",{method:"POST",body:JSON.stringify(t)},{auth:"none"});return Qs(s.token),s}function xn(){return qe(),R("/relay/auth/session",{cache:"no-store"},{auth:"relay-admin"})}async function El(t){qe();const s=await R("/relay/auth/login",{method:"POST",body:JSON.stringify({identifier:t.username,password:t.password})},{auth:"none"});return cn(s.token),s}async function Il(){return cn(null),xn()}async function Rl(t){qe();const s=await R("/relay/auth/register",{method:"POST",body:JSON.stringify(t)},{auth:"none"});return Qs(s.token??null),s}async function Al(){const t=await R("/relay/auth/logout",{method:"POST"});return Qs(null),ss(null),as(null),t}function gn(){return R("/relay/portal")}function Pl(t){const s=new URLSearchParams({deviceId:t.deviceId});return t.threadId&&s.set("threadId",t.threadId),t.workspaceId&&s.set("workspaceId",t.workspaceId),R(`/relay/access?${s.toString()}`)}function Ol(t){return R("/relay/devices",{method:"POST",body:JSON.stringify(t)})}function Ll(t){return R(`/relay/devices/${encodeURIComponent(t)}`,{method:"DELETE"})}function Dl(t){return R("/relay/account",{method:"PATCH",body:JSON.stringify(t)})}function Ul(t){return R("/relay/account/password",{method:"PATCH",body:JSON.stringify(t)})}function $l(t){return R("/relay/shares",{method:"POST",body:JSON.stringify(t)})}function Ml(t,s){return R(`/relay/shares/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(s)})}function vn(t){return R(`/relay/shares/${encodeURIComponent(t)}`,{method:"DELETE"})}function Hl(t){return R("/relay/grants",{method:"POST",body:JSON.stringify(t)})}function _l(t,s){return R(`/relay/grants/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(s)})}function Bl(t){return R(`/relay/grants/${encodeURIComponent(t)}`,{method:"DELETE"})}function Wl(t){const s=t?`?days=${encodeURIComponent(String(t))}`:"";return R(`/relay/admin${s}`,void 0,{auth:"relay-admin"})}function Fl(){return R("/relay/admin/hosted-sandboxes/capability",void 0,{auth:"relay-admin"})}function ql(){return R("/relay/admin/hosted-sandboxes",void 0,{auth:"relay-admin"})}function Vl(){return R("/relay/admin/hosted-sandboxes/reconciliation",void 0,{auth:"relay-admin"})}function zl(){return R("/relay/admin/hosted-sandboxes/reconciliation/run",{method:"POST"},{auth:"relay-admin"})}function Gl(t){return R(`/relay/admin/hosted-sandboxes/reconciliation/orphan-instances/${encodeURIComponent(t)}`,{method:"DELETE"},{auth:"relay-admin"})}function Jl(t){return R(`/relay/admin/hosted-sandboxes/reconciliation/orphan-credentials/${encodeURIComponent(t)}`,{method:"DELETE"},{auth:"relay-admin"})}function Kl(t){return R("/relay/admin/hosted-sandboxes",{method:"POST",body:JSON.stringify(t)},{auth:"relay-admin"})}function wr(t,s){return R(`/relay/admin/hosted-sandboxes/${encodeURIComponent(t)}/members`,{method:"PUT",body:JSON.stringify({assignedUserIds:s})},{auth:"relay-admin"})}function Yl(t,s){return R(`/relay/admin/hosted-sandboxes/${encodeURIComponent(t)}/settings`,{method:"PATCH",body:JSON.stringify(s)},{auth:"relay-admin"})}function jr(t,s){return R(`/relay/admin/hosted-sandboxes/${encodeURIComponent(t)}/${s}`,{method:"POST"},{auth:"relay-admin"})}function Zl(t,s){return R(`/relay/admin/hosted-sandboxes/${encodeURIComponent(t)}/snapshots`,{method:"POST",body:JSON.stringify({name:s})},{auth:"relay-admin"})}function Xl(t){return R(`/relay/admin/hosted-sandboxes/${encodeURIComponent(t)}/backends/codex/files`,void 0,{auth:"relay-admin"})}function Ql(t,s){return R(`/relay/admin/hosted-sandboxes/${encodeURIComponent(t)}/backends/codex/files`,{method:"PUT",body:JSON.stringify(s)},{auth:"relay-admin"})}function ei(t){return R(`/relay/admin/hosted-sandboxes/${encodeURIComponent(t)}`,{method:"DELETE"},{auth:"relay-admin"})}function ti(t){return R("/relay/admin/settings/registration",{method:"PATCH",body:JSON.stringify(t)},{auth:"relay-admin"})}function si(t,s){return R(`/relay/admin/users/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({enabled:s})},{auth:"relay-admin"})}function ai(t){return R(`/relay/admin/users/${encodeURIComponent(t)}`,{method:"DELETE"},{auth:"relay-admin"})}function ri(t,s){return R(`/relay/admin/users/${encodeURIComponent(t)}/reset-password`,{method:"POST",body:JSON.stringify({password:s})},{auth:"relay-admin"})}function ni(t){return R(`/relay/admin/registrations/${encodeURIComponent(t)}/approve`,{method:"POST"},{auth:"relay-admin"})}function oi(t){return R(`/relay/admin/registrations/${encodeURIComponent(t)}/reject`,{method:"POST"},{auth:"relay-admin"})}function bn(){return R("/api/config/workspace-settings",{cache:"no-store"})}function li(t){return R("/api/config/workspace-settings",{method:"PATCH",body:JSON.stringify(t)})}function is(){return R("/api/agent-runtimes",{cache:"no-store"})}function yn(t){return R(`/api/agent-runtimes/${encodeURIComponent(t)}/status`,{cache:"no-store"})}function ii(t){return R(`/api/agent-runtimes/${encodeURIComponent(t)}/subscription-usage`,{cache:"no-store"})}function di(t){return R(`/api/agent-runtimes/${encodeURIComponent(t)}/restart`,{method:"POST"})}function wn(t,s){return R(`/api/agent-runtimes/${encodeURIComponent(t)}/install`,{method:"POST",body:JSON.stringify({action:s})})}function rs(t){return R(`/api/agent-runtimes/${encodeURIComponent(t)}/models`,{cache:"no-store"})}function jn(t,s){return R(`/api/config/providers/${encodeURIComponent(t)}/files/${encodeURIComponent(s)}`,{cache:"no-store"})}function Nn(t,s,a){return R(`/api/config/providers/${encodeURIComponent(t)}/files/${encodeURIComponent(s)}`,{method:"PATCH",body:JSON.stringify(a)})}function ci(t){return R(`/api/config/providers/${encodeURIComponent(t)}/archives`,{cache:"no-store"})}function ui(t,s={}){return R(`/api/config/providers/${encodeURIComponent(t)}/archives`,{method:"POST",body:JSON.stringify(s)})}function mi(t,s,a){return R(`/api/config/providers/${encodeURIComponent(t)}/archives/${encodeURIComponent(s)}`,{method:"PATCH",body:JSON.stringify(a)})}function hi(t,s){return R(`/api/config/providers/${encodeURIComponent(t)}/archives/${encodeURIComponent(s)}/apply`,{method:"POST"})}function fi(){return R("/api/service/build-restart",{method:"POST"})}function pi(){return R("/healthz",{cache:"no-store"})}function ta(){return R("/api/workspaces")}function xi(t,s={}){const a=new URLSearchParams;s.path&&a.set("path",s.path);const r=a.size>0?`?${a.toString()}`:"";return R(`/api/workspaces/${encodeURIComponent(t)}/files/tree${r}`,{cache:"no-store"})}function gi(t,s){const a=new URLSearchParams({path:s.path});return s.offset!==void 0&&a.set("offset",String(s.offset)),s.limit!==void 0&&a.set("limit",String(s.limit)),R(`/api/workspaces/${encodeURIComponent(t)}/files/preview?${a.toString()}`,{cache:"no-store"})}function vi(t,s){const a=new URLSearchParams({path:s.path});return mn(`/api/workspaces/${encodeURIComponent(t)}/files/raw?${a.toString()}`)}function bi(t,s){const a=new URLSearchParams({path:s.path});return mn(`/api/threads/${encodeURIComponent(t)}/assets/image?${a.toString()}`)}function yi(t,s){const a=new URLSearchParams({path:s.path});return fn(`/api/workspaces/${encodeURIComponent(t)}/files/download?${a.toString()}`,{cache:"no-store"})}function wi(t,s){const a=new FormData;return a.append("file",s.file,s.file.name),R(`/api/workspaces/${encodeURIComponent(t)}/files/upload`,{method:"POST",body:a})}function ji(t,s){return R(`/api/workspaces/${encodeURIComponent(t)}/files`,{method:"PUT",body:JSON.stringify(s)})}function sa(){return R("/api/threads")}function Nr(t,s={}){const a=new URLSearchParams;return s.limit!==void 0&&a.set("limit",String(s.limit)),s.beforeTurnId&&a.set("beforeTurnId",s.beforeTurnId),R(`/api/threads/${t}${a.size>0?`?${a.toString()}`:""}`)}function Ni(t,s){return R(`/api/threads/${t}/items/${encodeURIComponent(s)}/detail`)}function ki(){return R("/api/plugins",{cache:"no-store"})}function Si(t){return R("/api/plugins/import",{method:"POST",body:JSON.stringify(t)})}function Ci(t,s){return R(`/api/plugins/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(s)})}function Ti(t){return R(`/api/plugins/${encodeURIComponent(t)}`,{method:"DELETE"})}function Ei(t){return R(`/api/threads/${t}/export-turns`,{cache:"no-store"})}function Ii(t,s){var r,o,l;const a=new URLSearchParams;return s.format!==void 0&&a.set("format",s.format),a.set("mode",s.mode),s.limit!==void 0&&a.set("limit",String(s.limit)),s.turnIds!==void 0&&a.set("turnIds",s.turnIds.join(",")),s.profile!==void 0&&a.set("profile",s.profile),((r=s.options)==null?void 0:r.includeTokenAndPrice)!==void 0&&a.set("includeTokenAndPrice",String(s.options.includeTokenAndPrice)),((o=s.options)==null?void 0:o.includeCommandOutput)!==void 0&&a.set("includeCommandOutput",String(s.options.includeCommandOutput)),((l=s.options)==null?void 0:l.includeAbsolutePaths)!==void 0&&a.set("includeAbsolutePaths",String(s.options.includeAbsolutePaths)),`/api/threads/${encodeURIComponent(t)}/exports/pdf?${a.toString()}`}function Ri(t,s){return fn(Ii(t,s),{cache:"no-store"})}function Ai(t){return R(`/api/threads/${t}/shell`)}function Pi(t){return R("/api/threads/start",{method:"POST",body:JSON.stringify(t)})}function Oi(t){return R("/api/threads/import",{method:"POST",body:JSON.stringify(typeof t=="string"?{sessionId:t}:t)})}function Li(t,s={}){return R(`/api/threads/${t}/shell`,{method:"POST",...Object.keys(s).length>0?{body:JSON.stringify(s)}:{}})}function Di(t){return R(`/api/shells/${t}/terminate`,{method:"POST"})}function Ui(t,s){return R(`/api/shells/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function Is(t,s={}){return R(`/api/threads/${t}/resume`,{method:"POST",...Object.keys(s).length>0?{body:JSON.stringify(s)}:{}})}function $i(t){return R(`/api/threads/${t}/disconnect`,{method:"POST"})}function Mi(t,s){const a=s.attachments??[];if(a.length===0)return R(`/api/threads/${t}/prompt`,{method:"POST",body:JSON.stringify(s)});const r=new FormData;r.append("prompt",s.prompt),s.clientRequestId!==void 0&&r.append("clientRequestId",s.clientRequestId),s.model!==void 0&&r.append("model",s.model),s.reasoningEffort!==void 0&&s.reasoningEffort!==null&&r.append("reasoningEffort",s.reasoningEffort),s.collaborationMode!==void 0&&r.append("collaborationMode",s.collaborationMode);const o=a.map((l,i)=>({clientId:l.clientId,kind:l.kind,originalName:yr(l,i),placeholder:l.placeholder}));r.append("attachmentManifest",JSON.stringify(o));for(const[l,i]of a.entries())r.append("attachments",i.file,yr(i,l));return R(`/api/threads/${t}/prompt`,{method:"POST",body:r})}function kr(t,s={}){return R(`/api/threads/${t}/interrupt`,{method:"POST",body:JSON.stringify(s)})}function kn(t,s){return R(`/api/threads/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function Sn(t){return R(`/api/threads/${t}`,{method:"DELETE"})}function Hi(t,s){return R(`/api/threads/${t}/pending-steers/${encodeURIComponent(s)}`,{method:"DELETE"})}function _i(t,s){return R(`/api/threads/${t}/settings`,{method:"PATCH",body:JSON.stringify(s)})}function Bi(t){return R(`/api/threads/${t}/compact`,{method:"POST"})}function Wi(t){return R(`/api/threads/${t}/goal`,{cache:"no-store"})}function Fi(t,s){return R(`/api/threads/${t}/goal`,{method:"PATCH",body:JSON.stringify(s)})}function qi(t){return R(`/api/threads/${t}/goal`,{method:"DELETE"})}function Vi(t){return R(`/api/threads/${t}/fork-turns`,{cache:"no-store"})}function Sr(t,s){return R(`/api/threads/${t}/fork`,{method:"POST",body:JSON.stringify(s)})}function zi(t){return R(`/api/threads/${t}/skills`,{cache:"no-store"})}function Gi(t){return R(`/api/threads/${t}/mcp-servers`,{cache:"no-store"})}function Ji(t){return R(`/api/threads/${t}/hooks`,{cache:"no-store"})}function Ki(t,s){return R(`/api/threads/${t}/hooks`,{method:"POST",body:JSON.stringify(s)})}function Yi(t,s){return R(`/api/threads/${t}/hooks`,{method:"PUT",body:JSON.stringify(s)})}function Zi(t,s){return R(`/api/threads/${t}/hooks/trust`,{method:"POST",body:JSON.stringify(s)})}function Xi(t,s){return R(`/api/threads/${t}/hooks/untrust`,{method:"POST",body:JSON.stringify(s)})}function Qi(t,s,a){return R(`/api/threads/${t}/requests/${encodeURIComponent(s)}/respond`,{method:"POST",body:JSON.stringify(a)})}function ed(t){return R("/api/workspaces",{method:"POST",body:JSON.stringify(t)})}function td(t,s){return R(`/api/workspaces/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function sd(t,s){return R(`/api/workspaces/${t}`,{method:"DELETE",body:JSON.stringify(s)})}function ad(t,s){return R(`/api/workspaces/${t}/favorite`,{method:"POST",body:JSON.stringify(s)})}function Cn(t){const s=window.location.protocol==="https:"?"wss:":"ws:",a=new WebSocket(Tn(s));return a.addEventListener("message",r=>{try{const o=JSON.parse(r.data);nd(o)&&t(o)}catch{}}),a}function rd(t={}){const s=window.location.protocol==="https:"?"wss:":"ws:",a=new WebSocket(Tn(s));return a.addEventListener("message",r=>{var o,l;try{const i=JSON.parse(r.data);if(i.type==="supervisor.connected"){(o=t.onConnected)==null||o.call(t,i);return}od(i)&&((l=t.onShellEvent)==null||l.call(t,i))}catch{}}),{socket:a,send(r){a.send(JSON.stringify(r))}}}function Tn(t){const s=new URL(`${t}//${window.location.host}/ws`);if(bt()){const l=un();s.pathname=l?`/relay/devices/${encodeURIComponent(l)}/ws`:"/relay/ws"}const a=ln(),r=dn(),o=bl();return bt()&&r&&s.searchParams.set("relaySession",r),bt()&&o&&s.searchParams.set("threadId",o),a&&s.searchParams.set("token",a),s.toString()}function nd(t){return"threadId"in t&&t.type.startsWith("thread.")&&typeof t.payload=="object"&&t.payload!==null}function od(t){return"shellId"in t&&t.type.startsWith("shell.")&&typeof t.payload=="object"&&t.payload!==null}function aa({embedded:t=!1}={}){const s=Ut(),a=tn(),[r,o]=n.useState(""),[l,i]=n.useState({busy:!1,message:null,error:null}),[c,f]=n.useState(!1),[g,b]=n.useState(null),[x,S]=n.useState({}),y=g?x[g]:null,[m,p]=n.useState({busy:!1,message:null,error:null}),[O,M]=n.useState([]),[D,I]=n.useState(vt),[A,K]=n.useState({loading:!1,saving:!1,error:null,operatingProvider:null,operatingAction:null,message:null}),[Y,X]=n.useState(null),[d,W]=n.useState({devHomeDraft:"",loading:!1,saving:!1,message:null,error:null}),[Q,B]=n.useState({loading:!1,creating:!1,applyingId:null,renamingId:null,renameDraft:"",message:null,error:null}),ae=(s==null?void 0:s.themeMode)??"system",oe=t||!!(s!=null&&s.settingsOpen);async function ge(){const w=r.trim();if(!(!w||l.busy)){i({busy:!0,message:null,error:null});try{await a.importPluginManifest({manifestJson:w,enabled:!0}),o(""),i({busy:!1,message:"Plugin manifest imported.",error:null})}catch(E){i({busy:!1,message:null,error:E instanceof Error?E.message:"Unable to import plugin manifest."})}}}const ce=(s==null?void 0:s.effectiveTheme)??"dark",ke=(s==null?void 0:s.autoCollapseCompletedTurns)??!0,be=(s==null?void 0:s.defaultBackend)??sn,Se=a.plugins.filter(w=>w.enabled).length,P=a.loading?"Loading...":`${Se}/${a.plugins.length} enabled`,L=D.find(w=>w.provider===be)??vt.find(w=>w.provider===be)??vt[0],te=L.managementSchema??ll(L.provider),H=te.hostConfigFiles;n.useEffect(()=>{if(!oe||t||!s||!te.configArchives)return;const w=s;function E(_){_.key==="Escape"&&w.closeSettings()}return window.addEventListener("keydown",E),()=>{window.removeEventListener("keydown",E)}},[te.configArchives,t,oe,s]),n.useEffect(()=>{if(!oe)return;let w=!1;return K(E=>({...E,loading:!0,error:null})),is().then(E=>{if(w)return;const _=[...E.map(Es),...vt.filter(ee=>!E.some(xe=>xe.provider===ee.provider))];I(_),K(ee=>({...ee,loading:!1}))}).catch(E=>{w||(I(vt),K(_=>({..._,loading:!1,error:E instanceof se?E.message:"Unable to load backend settings."})))}),()=>{w=!0}},[oe]),n.useEffect(()=>{if(!oe)return;let w=!1;return W(E=>({...E,loading:!0,message:null,error:null})),bn().then(E=>{w||(X(E),W(_=>({..._,devHomeDraft:E.devHome,loading:!1})))}).catch(E=>{w||W(_=>({..._,loading:!1,error:E instanceof se?E.message:"Unable to load workspace settings."}))}),()=>{w=!0}},[oe]),n.useEffect(()=>{if(!oe||!L.capabilities.management.hostConfigFiles)return;let w=!1;async function E(){S(ee=>{const xe={...ee};for(const Pe of H)xe[Pe.name]={...Tt(Pe.name),...ee[Pe.name],loading:!0,saving:!1,error:null,saveMessage:null};return xe});const _=await Promise.allSettled(H.map(async ee=>({name:ee.name,result:await jn(L.provider,ee.name)})));w||S(ee=>{var Pe,nt;const xe={...ee};for(const ot of _){if(ot.status==="fulfilled"){const{name:ut,result:Qe}=ot.value;xe[ut]={path:Qe.path,exists:Qe.exists,originalContent:Qe.content,draftContent:Qe.content,loading:!1,saving:!1,error:null,saveMessage:null};continue}const Mt=ot.reason instanceof se?ot.reason.message:"Unable to load the file.",Xe=((Pe=H[_.indexOf(ot)])==null?void 0:Pe.name)??((nt=H[0])==null?void 0:nt.name);Xe&&(xe[Xe]={...Tt(Xe),...xe[Xe],loading:!1,saving:!1,error:Mt,saveMessage:null})}return xe})}return E(),()=>{w=!0}},[L.capabilities.management.hostConfigFiles,L.provider,H,oe]),n.useEffect(()=>{if(!oe)return;let w=!1;async function E(){B(_=>({..._,loading:!0,error:null,message:null}));try{const _=await ci(L.provider);if(w)return;M(_),B(ee=>({...ee,loading:!1}))}catch(_){if(w)return;B(ee=>({...ee,loading:!1,error:_ instanceof se?_.message:"Unable to load config archives."}))}}return E(),()=>{w=!0}},[L.provider,te.configArchives,oe]);async function V(){if(!(m.busy||A.saving)){p({busy:!0,message:null,error:null});try{const w=await di(L.provider),E=Es(w);p({busy:!1,message:E.status.state==="ready"?`${E.displayName} backend restarted.`:`${E.displayName} backend state: ${E.status.state}`,error:null}),I(_=>_.map(ee=>ee.provider===E.provider?E:ee))}catch(w){p({busy:!1,message:null,error:w instanceof se?w.message:"Unable to restart the app server."})}}}async function N(w,E){if(m.busy||A.saving)return;const _=D.find(ee=>ee.provider===w);K(ee=>({...ee,saving:!0,operatingProvider:w,operatingAction:E,message:null,error:null}));try{const ee=await wn(w,E),xe=Es(ee);I(Pe=>Pe.map(nt=>nt.provider===xe.provider?xe:nt)),K(Pe=>({...Pe,saving:!1,operatingProvider:null,operatingAction:null,message:xe.installation.lastError?`${xe.displayName} ${E==="install"?"installed":"updated"}, but requires attention:
4
4
  ${xe.installation.lastError}`:`${xe.displayName} ${E==="install"?"installed":"updated"}.`,error:null}))}catch(ee){K(xe=>({...xe,saving:!1,operatingProvider:null,operatingAction:null,message:null,error:ee instanceof se?dl(ee):`Unable to ${E} ${(_==null?void 0:_.displayName)??w}.`}))}}async function J(){if(!(m.busy||A.saving)){p({busy:!0,message:null,error:null});try{await fi(),p({busy:!1,message:"Build and restart launched. The page may disconnect briefly.",error:null})}catch(w){p({busy:!1,message:null,error:w instanceof se?w.message:"Unable to launch build and restart."})}}}async function ue(){const w=d.devHomeDraft.trim();if(!(!w||d.saving)){W(E=>({...E,saving:!0,message:null,error:null}));try{const E=await li({devHome:w});X(E),W(_=>({..._,devHomeDraft:E.devHome,saving:!1,message:"Workspace defaults saved."}))}catch(E){W(_=>({..._,saving:!1,error:E instanceof se?E.message:"Unable to save workspace settings."}))}}}async function fe(w){const E=x[w];if(!(!E||E.saving)){S(_=>({..._,[w]:{...Tt(w),..._[w],saving:!0,error:null,saveMessage:null}}));try{const _=await Nn(L.provider,w,{content:E.draftContent});S(ee=>({...ee,[w]:{path:_.path,exists:_.exists,originalContent:_.content,draftContent:_.content,loading:!1,saving:!1,error:null,saveMessage:"Saved"}}))}catch(_){S(ee=>({...ee,[w]:{...Tt(w),...ee[w],saving:!1,error:_ instanceof se?_.message:"Unable to save the file.",saveMessage:null}}))}}}async function ve(){if(!Q.creating){B(w=>({...w,creating:!0,message:null,error:null}));try{const w=await ui(L.provider);M(E=>[w,...E]),B(E=>({...E,creating:!1,message:"Backup created."}))}catch(w){B(E=>({...E,creating:!1,error:w instanceof se?w.message:"Unable to create a config backup."}))}}}async function u(w){if(!Q.applyingId){B(E=>({...E,applyingId:w.id,message:null,error:null}));try{const E=await hi(L.provider,w.id);B(_=>({..._,applyingId:null,message:E.status.state==="ready"?`Applied "${E.archive.label}" and restarted ${L.displayName}.`:`Applied "${E.archive.label}". ${L.displayName} state: ${E.status.state}.`}))}catch(E){B(_=>({..._,applyingId:null,error:E instanceof se?E.message:"Unable to apply the config archive."}))}}}async function k(w){const E=Q.renameDraft.trim();if(!(!E||Q.renamingId!==w.id)){B(_=>({..._,message:null,error:null}));try{const _=await mi(L.provider,w.id,{label:E});M(ee=>ee.map(xe=>xe.id===w.id?_:xe)),B(ee=>({...ee,renamingId:null,renameDraft:"",message:"Backup renamed."}))}catch(_){B(ee=>({...ee,error:_ instanceof se?_.message:"Unable to rename the config backup."}))}}}if(!oe)return null;const Z=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-3 grid gap-2",children:[a.plugins.map(w=>e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2.5",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium text-[var(--theme-fg)]",children:w.name}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-[var(--theme-fg-muted)]",children:w.description}),e.jsx("span",{className:"mt-2 block text-[10px] uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:[...w.capabilities.artifactTypes.map(E=>E.type),...w.capabilities.threadPanels.map(E=>E.kind??E.id)].join(", ")||"utility"}),e.jsx("span",{className:"mt-1 block text-[10px] uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:w.source==="imported"?"Imported manifest":"Built-in module"})]}),e.jsx("input",{type:"checkbox",checked:w.enabled,onChange:E=>void a.setPluginEnabled(w.id,E.currentTarget.checked),className:"mt-1 h-4 w-4 shrink-0 accent-[var(--theme-accent-solid)]"})]},w.id)),a.plugins.length===0&&e.jsx("p",{className:"rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No plugins are registered."})]}),e.jsxs("div",{className:"mt-3 border-t border-[var(--theme-border)] pt-3",children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--theme-fg)]",children:"Import manifest JSON"}),e.jsx("textarea",{value:r,onChange:w=>{o(w.currentTarget.value),(l.message||l.error)&&i({busy:!1,message:null,error:null})},placeholder:'{"id":"example.viewer","name":"Example Viewer","version":"0.1.0",...}',rows:4,className:"mt-2 min-h-28 w-full resize-y rounded-[0.9rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2 font-mono text-xs leading-5 text-[var(--theme-fg)] outline-none transition placeholder:text-[var(--theme-fg-muted)] focus:border-[var(--theme-accent-border)]"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsx("p",{className:"max-w-[42rem] text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Imports register manifest-declared artifact types. Rendering code still needs a trusted built-in frontend module."}),e.jsx("button",{type:"button",onClick:()=>void ge(),disabled:!r.trim()||l.busy,className:"rounded-full border border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] px-3 py-1.5 text-xs font-medium text-[var(--theme-accent-strong)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:l.busy?"Importing...":"Import"})]}),l.error&&e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:l.error}),l.message&&e.jsx("p",{className:"mt-2 text-xs text-emerald-300",children:l.message})]}),a.error&&e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:a.error})]}),we=e.jsxs(e.Fragment,{children:[t?null:e.jsx("div",{className:"shrink-0 p-5 pb-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Settings"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold text-[var(--theme-fg)]",children:"Settings"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--theme-fg-soft)]",children:"Choose the default backend and manage host-side runtime files."})]}),e.jsx("button",{type:"button","aria-label":"Close Settings",onClick:s==null?void 0:s.closeSettings,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-surface-strong)] text-[var(--theme-fg)] transition hover:border-[var(--theme-border-contrast)] hover:bg-[var(--theme-hover)]",children:e.jsx(Ts,{})})]})}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${t?"p-0":"p-5 pt-5"}`,children:e.jsxs("div",{className:"space-y-2",children:[t?null:e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Appearance"}),e.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:["Choose light, dark, or follow the system setting. Active:"," ",ce,"."]})]})}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-3",children:rl.map(w=>{const E=ae===w.value;return e.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s.setThemeMode(w.value),className:`block rounded-[1rem] border px-3 py-2.5 text-left transition ${E?"border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)]":"border-[var(--theme-border)] bg-[var(--theme-surface-strong)] hover:bg-[var(--theme-hover)]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--theme-fg)]",children:w.label}),E?e.jsx("span",{className:"rounded-full border border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-[var(--theme-accent-strong)]",children:"Active"}):null]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:w.description})]},w.value)})})]}),s!=null&&s.setAutoCollapseCompletedTurns?e.jsx("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Thread timeline"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Collapse completed turns into prompt, elapsed work, and final reply."})]}),e.jsxs("label",{className:"inline-flex min-h-10 shrink-0 items-center gap-2 text-xs font-medium text-[var(--theme-fg-soft)]",children:[e.jsx("input",{type:"checkbox",checked:ke,onChange:w=>{var E;return(E=s.setAutoCollapseCompletedTurns)==null?void 0:E.call(s,w.currentTarget.checked)},className:"h-4 w-4 accent-[var(--theme-accent-solid)]"}),e.jsx("span",{children:"Auto collapse"})]})]})}):null,e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Plugins"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Enable renderers and thread extensions loaded by this supervisor."})]}),e.jsx("button",{type:"button",onClick:()=>void a.refresh(),disabled:a.loading,className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:text-[var(--theme-fg-muted)]",children:a.loading?"Loading...":"Refresh"})]}),t?e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 rounded-[0.95rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2",children:[e.jsx("span",{className:"text-xs text-[var(--theme-fg-muted)]",children:P}),e.jsx("button",{type:"button",onClick:()=>f(!0),className:"rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-panel)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)]",children:"Manage"})]}):Z]}),e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Workspace defaults"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Git projects clone into dev home. New workspace directories can create one missing child under this path."})]})}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--theme-fg-muted)]",children:"Workspace root"}),e.jsx("p",{title:(Y==null?void 0:Y.workspaceRoot)??"Loading workspace root",className:"mt-1 truncate rounded-[0.9rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2 font-mono text-xs text-[var(--theme-fg-soft)]",children:d.loading&&!Y?"Loading...":(Y==null?void 0:Y.workspaceRoot)??"Unavailable"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-dev-home",className:"text-[11px] uppercase tracking-[0.18em] text-[var(--theme-fg-muted)]",children:"Dev home"}),e.jsxs("div",{className:"mt-1 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{id:"settings-dev-home",value:d.devHomeDraft,onChange:w=>W(E=>({...E,devHomeDraft:w.target.value,message:null,error:null})),placeholder:"/Users/name/dev",className:"min-w-0 flex-1 rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-2 text-sm text-[var(--theme-fg)] outline-none focus:border-[var(--theme-accent-border)]"}),e.jsx("button",{type:"button","aria-label":"Save workspace defaults",onClick:()=>void ue(),disabled:d.loading||d.saving||!d.devHomeDraft.trim(),className:"rounded-full bg-[var(--theme-accent-solid)] px-4 py-2 text-xs font-medium text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)] disabled:cursor-not-allowed disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:d.saving?"Saving...":"Save"})]})]})]}),d.error?e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:d.error}):d.message?e.jsx("p",{className:"mt-2 text-xs text-emerald-300",children:d.message}):null]}),e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Runtime controls"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Inspect installed backend versions, install optional runtimes, or restart the selected backend."})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void V(),disabled:m.busy||A.saving,className:"rounded-full border border-sky-400/35 bg-sky-400/10 px-3 py-1.5 text-xs font-medium text-sky-500 transition hover:bg-sky-400/16 disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:m.busy?"Restarting...":"Restart"}),e.jsx("button",{type:"button",onClick:()=>void J(),disabled:m.busy||A.saving,className:"rounded-full border border-[var(--status-warning-border)] bg-[var(--status-warning-bg)] px-3 py-1.5 text-xs font-medium text-[var(--status-warning-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:m.busy?"Working...":"Build and restart"})]})]}),e.jsx("div",{className:"mt-3 grid gap-2",children:D.map(w=>{const E=w.installation,_=!E.installed&&!!E.installCommand,ee=E.installed&&!!E.updateCommand,xe=A.saving&&A.operatingProvider===w.provider,Pe=_?"Install":"Update";return e.jsxs("div",{className:"flex flex-col gap-2 rounded-[0.95rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--theme-fg)]",children:w.displayName}),e.jsx("span",{className:`rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.16em] ${w.enabled?"border-emerald-400/35 bg-emerald-400/10 text-emerald-400":"border-[var(--theme-border)] bg-[var(--theme-muted)] text-[var(--theme-fg-muted)]"}`,children:w.enabled?"Ready":E.installed?w.status.state:"Not installed"})]}),e.jsxs("p",{className:"mt-1 truncate text-xs text-[var(--theme-fg-muted)]",children:["Version:"," ",E.installedVersion??(E.installed?"Installed":"Unavailable"),E.latestVersion?` · Latest: ${E.latestVersion}`:""]}),E.lastError?e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-rose-300",children:E.lastError}):null]}),_||ee?e.jsx("button",{type:"button","aria-label":`${_?"Install":"Update"} ${w.displayName}`,onClick:()=>void N(w.provider,_?"install":"update"),disabled:m.busy||A.saving||!_&&!ee,className:"shrink-0 rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-panel)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:xe?A.operatingAction==="install"?"Installing...":"Updating...":Pe}):null]},w.provider)})}),m.error?e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:m.error}):m.message?e.jsx("p",{className:"mt-2 text-xs text-emerald-300",children:m.message}):A.message?e.jsx("p",{className:`mt-2 whitespace-pre-line text-xs ${A.message.includes("requires attention")?"text-[var(--status-warning-fg)]":"text-emerald-300"}`,children:A.message}):A.error?e.jsx("p",{className:"mt-2 whitespace-pre-line text-xs text-rose-300",children:A.error}):null]}),e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Provider host files"}),e.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:[L.displayName," exposes these editable files through its backend schema."]})]})}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[H.map(w=>{const E=x[w.name]??{path:w.name,exists:!1,originalContent:"",draftContent:"",loading:!1},_=E.draftContent!==E.originalContent;return e.jsx("button",{type:"button",onClick:()=>b(w.name),className:"block rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-left transition hover:bg-[var(--theme-hover)]",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:w.label}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:w.description})]}),e.jsx("div",{className:"shrink-0",children:E.loading?e.jsx("span",{className:"text-[11px] uppercase tracking-[0.2em] text-[var(--theme-fg-muted)]",children:"Loading"}):_?e.jsx("span",{className:"rounded-full border border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-[var(--theme-accent-strong)]",children:"Unsaved"}):E.exists?e.jsx("span",{className:"rounded-full border border-emerald-400/25 bg-emerald-400/10 px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-emerald-600 dark:text-emerald-100",children:"Ready"}):e.jsx("span",{className:"rounded-full border border-sky-300/25 bg-sky-300/10 px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-sky-600 dark:text-sky-100",children:"New"})})]})},w.name)}),H.length===0?e.jsx("p",{className:"rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-xs text-[var(--theme-fg-muted)]",children:"This backend does not expose editable host files."}):null]})]}),te.configArchives?e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Config archives"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Backup the selected backend host files, then apply a saved archive with a backend restart."})]}),e.jsx("button",{type:"button",onClick:()=>void ve(),disabled:Q.creating,className:"shrink-0 rounded-full border border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] px-3 py-1.5 text-xs font-medium text-[var(--theme-accent-strong)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:Q.creating?"Creating...":"Create backup"})]}),Q.error?e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:Q.error}):Q.message?e.jsx("p",{className:"mt-2 text-xs text-emerald-300",children:Q.message}):null,e.jsx("div",{className:"mt-3 space-y-2",children:Q.loading?e.jsx("p",{className:"rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-xs text-[var(--theme-fg-muted)]",children:"Loading backups..."}):O.length===0?e.jsx("p",{className:"rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No config backups yet."}):O.map(w=>{const E=Q.renamingId===w.id;return e.jsx("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[E?e.jsxs("div",{className:"flex max-w-xl gap-2",children:[e.jsx("input",{"aria-label":`Rename ${w.label}`,value:Q.renameDraft,onChange:_=>B(ee=>({...ee,renameDraft:_.target.value,error:null,message:null})),className:"min-w-0 flex-1 rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-1.5 text-sm text-[var(--theme-fg)] outline-none focus:border-[var(--theme-accent-border)]"}),e.jsx("button",{type:"button","aria-label":`Save archive name ${w.label}`,onClick:()=>void k(w),className:"rounded-full bg-[var(--theme-accent-solid)] px-3 py-1.5 text-xs font-medium text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)]",children:"Save"}),e.jsx("button",{type:"button",onClick:()=>B(_=>({..._,renamingId:null,renameDraft:""})),className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)]",children:"Cancel"})]}):e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:w.label}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-[11px] text-[var(--theme-fg-muted)]",children:[e.jsxs("span",{children:["Created ",il(w.createdAt)]}),H.map(_=>{var ee;return e.jsxs("span",{className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-2 py-0.5 font-mono",children:[_.name,":"," ",(ee=w.files[_.name])!=null&&ee.exists?"saved":"missing"]},_.name)})]})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>B(_=>({..._,renamingId:w.id,renameDraft:w.label,message:null,error:null})),disabled:E,className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:text-[var(--theme-fg-muted)]",children:"Rename"}),e.jsx("button",{type:"button",onClick:()=>void u(w),disabled:Q.applyingId!==null,className:"rounded-full border border-emerald-400/35 bg-emerald-400/10 px-3 py-1.5 text-xs font-medium text-emerald-600 transition hover:bg-emerald-400/16 disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)] dark:text-emerald-100",children:Q.applyingId===w.id?"Applying...":"Apply"})]})]})},w.id)})})]}):null]})})]});return t?e.jsxs("div",{className:"flex min-h-0 flex-col overflow-hidden",children:[we,c?e.jsxs("div",{className:"fixed inset-0 z-[90] flex items-start justify-center p-4 pt-[max(env(safe-area-inset-top),4rem)] sm:items-center sm:pt-4",children:[e.jsx("button",{type:"button","aria-label":"Close plugins panel",onClick:()=>f(!1),className:"ui-overlay-scrim absolute inset-0 backdrop-blur-[2px]"}),e.jsxs("section",{className:"relative z-10 flex max-h-[min(82vh,42rem)] w-full max-w-2xl flex-col overflow-hidden rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] shadow-[var(--theme-shadow)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--theme-border)] px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Plugins"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--theme-fg-muted)]",children:P})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void a.refresh(),disabled:a.loading,className:"rounded-md border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:text-[var(--theme-fg-muted)]",children:a.loading?"Loading...":"Refresh"}),e.jsx("button",{type:"button","aria-label":"Close plugins panel",onClick:()=>f(!1),className:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-surface-strong)] text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)]",children:e.jsx(Ts,{})})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:Z})]})]}):null]}):e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-start justify-center p-4 pt-[max(env(safe-area-inset-top),1rem)] sm:items-center",children:[e.jsx("button",{type:"button","aria-label":"Close Settings",onClick:s==null?void 0:s.closeSettings,className:"ui-overlay-scrim absolute inset-0 backdrop-blur-sm"}),e.jsx("section",{role:"dialog","aria-modal":"true","aria-label":"Settings",className:"relative z-10 flex max-h-[calc(100vh-2rem)] w-full max-w-4xl flex-col overflow-hidden rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] shadow-[var(--theme-shadow)]",children:we}),g&&y?e.jsx("div",{className:"pointer-events-none fixed inset-0 z-[71] flex items-center justify-center p-4",children:e.jsxs("div",{className:"pointer-events-auto relative z-10 flex max-h-[min(88vh,56rem)] w-full max-w-3xl flex-col overflow-hidden rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] shadow-[var(--theme-shadow)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-[var(--theme-border)] px-4 py-3 sm:px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:g}),e.jsx("p",{className:"mt-1 break-all font-mono text-xs text-[var(--theme-fg-muted)]",children:y.path})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[y.error?e.jsx("span",{className:"text-xs text-rose-300",children:y.error}):y.saveMessage?e.jsx("span",{className:"text-xs text-emerald-300",children:y.saveMessage}):null,e.jsx("button",{type:"button","aria-label":`Save ${g}`,onClick:()=>void fe(g),disabled:y.loading||y.saving||y.draftContent===y.originalContent,className:"rounded-full bg-[var(--theme-accent-solid)] px-4 py-2 text-sm font-medium text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)] disabled:cursor-not-allowed disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:y.saving?"Saving...":"Save"}),e.jsx("button",{type:"button","aria-label":"Close File Editor",onClick:()=>b(null),className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-surface-strong)] text-[var(--theme-fg)] transition hover:border-[var(--theme-border-contrast)] hover:bg-[var(--theme-hover)]",children:e.jsx(Ts,{})})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-5",children:e.jsx("textarea",{"aria-label":`Edit ${g}`,value:y.draftContent,onChange:w=>S(E=>({...E,[g]:{...Tt(g),...E[g],draftContent:w.target.value,error:null,saveMessage:null}})),spellCheck:!1,className:"min-h-[28rem] w-full rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 font-mono text-[13px] leading-6 text-[var(--theme-fg)] outline-none transition focus:border-[var(--theme-accent-border)]",placeholder:y.loading?"Loading...":`Edit ${g} here`})})]})}):null]})}function En({eyebrow:t="Supervisor Access",description:s="Use the admin credentials configured on this Remote Codex server.",onLogin:a}){const[r,o]=n.useState(""),[l,i]=n.useState(""),[c,f]=n.useState(null),[g,b]=n.useState(!1);async function x(S){S.preventDefault(),f(null),b(!0);try{await a({username:r,password:l})}catch(y){y instanceof se?f(y.payload.message):f("Unable to sign in.")}finally{b(!1)}}return e.jsx("main",{className:"flex min-h-screen items-center justify-center bg-[var(--app-bg)] px-4 py-8 text-[var(--app-fg)]",children:e.jsxs("section",{className:"w-full max-w-sm rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-5 shadow-[var(--theme-shadow)] sm:p-6",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-fg-muted)]",children:t}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold tracking-normal text-[var(--theme-fg)]",children:"Sign in"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--theme-fg-muted)]",children:s})]}),e.jsxs("form",{onSubmit:x,className:"space-y-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--theme-fg-soft)]",children:"Username"}),e.jsx("input",{autoComplete:"username",autoFocus:!0,className:"mt-2 h-11 w-full rounded-lg border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 text-sm text-[var(--theme-fg)] outline-none transition focus:border-[var(--theme-accent-solid)] focus:ring-2 focus:ring-[var(--theme-accent-border)]",disabled:g,name:"username",onChange:S=>o(S.target.value),value:r})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--theme-fg-soft)]",children:"Password"}),e.jsx("input",{autoComplete:"current-password",className:"mt-2 h-11 w-full rounded-lg border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 text-sm text-[var(--theme-fg)] outline-none transition focus:border-[var(--theme-accent-solid)] focus:ring-2 focus:ring-[var(--theme-accent-border)]",disabled:g,name:"password",onChange:S=>i(S.target.value),type:"password",value:l})]}),c&&e.jsx("p",{className:"rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-sm text-[var(--status-danger-fg)]",children:c}),e.jsx("button",{className:"h-11 w-full rounded-lg bg-[var(--theme-accent-solid)] px-4 text-sm font-semibold text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-60",disabled:g||!r.trim()||!l,type:"submit",children:g?"Signing in...":"Sign in"})]})]})})}function Rs(t,s){return t instanceof se?t.payload.message:t instanceof Error?t.message:s}function In({className:t=""}){var Q;const[s,a]=n.useState(null),[r,o]=n.useState(""),[l,i]=n.useState(""),[c,f]=n.useState(""),[g,b]=n.useState(""),[x,S]=n.useState(!0),[y,m]=n.useState(!1),[p,O]=n.useState(!1),[M,D]=n.useState(null),[I,A]=n.useState(null),[K,Y]=n.useState(!1);async function X(){var B;S(!0),A(null);try{qe();const ae=await yt();a(ae),o(((B=ae.user)==null?void 0:B.username)??"")}catch(ae){A(Rs(ae,"Unable to load account."))}finally{S(!1)}}n.useEffect(()=>{X()},[]);async function d(B){B.preventDefault(),m(!0),A(null),D(null);try{const ae=await Dl({username:r});a(oe=>oe!=null&&oe.authenticated?{...oe,user:ae}:oe),o(ae.username),D("Account updated.")}catch(ae){A(Rs(ae,"Unable to update account."))}finally{m(!1)}}async function W(B){B.preventDefault(),O(!0),A(null),D(null);try{if(c!==g){A("New passwords do not match.");return}await Ul({currentPassword:l,newPassword:c}),i(""),f(""),b(""),D("Password changed.")}catch(ae){A(Rs(ae,"Unable to change password."))}finally{O(!1)}}return e.jsx("div",{className:`space-y-5 ${t}`.trim(),children:x?e.jsx("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4 text-sm text-[var(--theme-fg-muted)]",children:"Loading account..."}):s!=null&&s.authenticated?e.jsxs(e.Fragment,{children:[I?e.jsx(Cr,{tone:"danger",children:I}):null,M?e.jsx(Cr,{tone:"success",children:M}):null,e.jsxs("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Profile"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:"Username changes apply to future shares and login."})]}),e.jsxs("form",{className:"space-y-4",onSubmit:d,children:[e.jsxs("label",{className:"block text-sm text-[var(--theme-fg-soft)]",children:["Email",e.jsx("input",{className:"relay-input mt-2 w-full",disabled:!0,readOnly:!0,value:((Q=s.user)==null?void 0:Q.email)??""})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[e.jsxs("label",{className:"block flex-1 text-sm text-[var(--theme-fg-soft)]",children:["Username",e.jsx("input",{className:"relay-input mt-2 w-full",onChange:B=>o(B.target.value),value:r})]}),e.jsxs("button",{className:"relay-button-primary inline-flex h-10 items-center justify-center gap-2",disabled:y||!r.trim(),type:"submit",children:[e.jsx(q.Save,{className:"h-4 w-4"}),"Save"]})]}),e.jsxs("button",{className:"relay-button-secondary inline-flex items-center gap-2",onClick:()=>Y(!0),type:"button",children:[K?e.jsx(q.CheckCircle2,{className:"h-4 w-4"}):e.jsx(q.MailCheck,{className:"h-4 w-4"}),K?"Verification queued":"Verify email"]})]})]}),e.jsxs("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Password"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:"Use at least 8 characters."})]}),e.jsxs("form",{className:"grid gap-4 sm:grid-cols-3",onSubmit:W,children:[e.jsx(As,{label:"Current password",value:l,onChange:i}),e.jsx(As,{label:"New password",value:c,onChange:f}),e.jsx(As,{label:"Confirm password",value:g,onChange:b}),e.jsxs("button",{className:"relay-button-primary inline-flex h-10 items-center justify-center gap-2 sm:col-span-3 sm:w-fit",disabled:p||!l||c.length<8||!g,type:"submit",children:[e.jsx(q.Save,{className:"h-4 w-4"}),"Change password"]})]})]})]}):e.jsx("section",{className:"rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] p-4 text-sm text-[var(--status-danger-fg)]",children:"Relay login is required."})})}function ld(){return e.jsx("main",{className:"min-h-screen bg-[var(--app-bg)] px-4 py-6 text-[var(--app-fg)] sm:px-6",children:e.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-5 pr-12 sm:pr-0",children:[e.jsxs("header",{className:"border-b border-[var(--theme-border)] pb-5",children:[e.jsx(Le,{className:"text-sm text-[var(--theme-accent-strong)]",to:"/relay-devices",children:"Back to relay portal"}),e.jsx("p",{className:"mt-4 text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-fg-muted)]",children:"Relay Account"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold text-[var(--theme-fg)]",children:"Account settings"})]}),e.jsx(In,{})]})})}function As({label:t,value:s,onChange:a}){return e.jsxs("label",{className:"block text-sm text-[var(--theme-fg-soft)]",children:[t,e.jsx("input",{autoComplete:"new-password",className:"relay-input mt-2 w-full",onChange:r=>a(r.target.value),type:"password",value:s})]})}function Cr({tone:t,children:s}){return e.jsx("div",{className:`rounded-lg border px-3 py-2 text-sm ${t==="danger"?"border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] text-[var(--status-danger-fg)]":"border-[var(--status-success-border)] bg-[var(--status-success-bg)] text-[var(--status-success-fg)]"}`,children:s})}function We(t){return t instanceof se?t.payload.message:t instanceof Error?t.message:"Unable to update relay admin state."}function id(){const[t,s]=n.useState(null),[a,r]=n.useState(!0),[o,l]=n.useState(null),[i,c]=n.useState(!1),[f,g]=n.useState(null),[b,x]=n.useState("overview"),[S,y]=n.useState(7),[m,p]=n.useState(null),[O,M]=n.useState(null),[D,I]=n.useState([]),[A,K]=n.useState(null),[Y,X]=n.useState(!1),[d,W]=n.useState(null),[Q,B]=n.useState(null);async function ae(H=S,V={}){V.showLoading!==!1&&r(!0),l(null);try{qe();const N=await Wl(H);s(N),p(N.settings),y(N.conversationWindowDays),c(!1)}catch(N){N instanceof se&&(N.statusCode===401||N.statusCode===403)?(s(null),c(!0),l(null)):l(We(N))}finally{r(!1)}}n.useEffect(()=>{ae()},[]);async function oe(H={}){H.showLoading!==!1&&X(!0),W(null);const[V,N,J]=await Promise.allSettled([Fl(),ql(),Vl()]);V.status==="fulfilled"?M(V.value):(M(null),W(We(V.reason))),N.status==="fulfilled"?I(N.value.sandboxes):W(ue=>ue??We(N.reason)),J.status==="fulfilled"?K(J.value):(K(null),W(ue=>ue??We(J.reason))),H.showLoading!==!1&&X(!1)}n.useEffect(()=>{b==="hosted"&&oe()},[b]),n.useEffect(()=>{if(b!=="hosted")return;const H=D.some(N=>["requested","creating","starting","provisioning","stopping","deleting"].includes(N.status)),V=window.setInterval(()=>void oe({showLoading:!1}),H?2e3:15e3);return()=>window.clearInterval(V)},[b,D]);async function ge(H,V){B(H),W(null);try{await V(),await oe(),window.setTimeout(()=>void oe(),750)}catch(N){W(We(N))}finally{B(null)}}const ce=n.useMemo(()=>{const H=(t==null?void 0:t.users)??[],V=(t==null?void 0:t.devices)??[];return{users:H.length,enabledUsers:H.filter(N=>N.enabled).length,devices:V.length,onlineDevices:V.filter(N=>N.connected).length,conversations:H.reduce((N,J)=>N+J.conversationCount,0),shares:(t==null?void 0:t.shares.filter(N=>!N.revokedAt).length)??0}},[t]);async function ke(H,V){g(H),l(null);try{const N=await si(H,V);s(J=>Er(J,N))}catch(N){l(We(N))}finally{g(null)}}async function be(H){g(`delete:${H}`),l(null);try{await ai(H),await ae(S,{showLoading:!1})}catch(V){l(We(V))}finally{g(null)}}async function Se(H,V){g(`reset:${H}`),l(null);try{const N=await ri(H,V);s(J=>Er(J,N))}catch(N){l(We(N))}finally{g(null)}}async function P(H){if(H.preventDefault(),!!m){g("settings"),l(null);try{const V=await ti(m);s(N=>N&&{...N,registrationEnabled:V.registrationEnabled,settings:V.settings}),p(V.settings)}catch(V){l(We(V))}finally{g(null)}}}async function L(H,V){g(`${V}:${H}`),l(null);try{V==="approve"?await ni(H):await oi(H),await ae(S,{showLoading:!1})}catch(N){l(We(N))}finally{g(null)}}async function te(H){await El(H),await ae(S)}return i?e.jsx(En,{description:"Use the relay admin credentials for this server. This does not replace your normal relay account.",eyebrow:"Relay Admin",onLogin:te}):e.jsxs("main",{className:"min-h-screen bg-[var(--app-bg)] px-4 py-6 text-[var(--app-fg)] sm:px-6",children:[e.jsx(xd,{onLogout:()=>{s(null),c(!0)}}),e.jsxs("div",{className:"mx-auto flex w-full max-w-7xl flex-col gap-5",children:[e.jsxs("header",{className:"flex flex-col gap-4 border-b border-[var(--theme-border)] pb-5 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-fg-muted)]",children:"Relay Admin"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold text-[var(--theme-fg)]",children:"Operations panel"}),e.jsx("p",{className:"mt-1 max-w-2xl text-sm text-[var(--theme-fg-muted)]",children:"Accounts, devices, usage, registration policy, and shared thread access."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--theme-fg-muted)]",children:["Usage window",e.jsxs("select",{className:"relay-input h-10 w-24",onChange:H=>void ae(Number(H.target.value)),value:S,children:[e.jsx("option",{value:1,children:"1 day"}),e.jsx("option",{value:7,children:"7 days"}),e.jsx("option",{value:30,children:"30 days"}),e.jsx("option",{value:90,children:"90 days"})]})]}),e.jsx(Le,{className:"relay-button-secondary",to:"/",children:"Relay home"}),e.jsxs("button",{className:"relay-button-secondary inline-flex items-center gap-2",onClick:()=>void ae(S),type:"button",children:[e.jsx(q.RefreshCw,{className:"h-4 w-4"}),"Refresh"]})]})]}),o?e.jsx("section",{className:"rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] p-4 text-sm text-[var(--status-danger-fg)]",children:o}):null,a?e.jsx("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4 text-sm text-[var(--theme-fg-muted)]",children:"Loading relay admin..."}):t?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(Zt,{icon:e.jsx(q.Users,{className:"h-5 w-5"}),label:"Users",value:ce.users,detail:`${ce.enabledUsers} enabled`}),e.jsx(Zt,{icon:e.jsx(q.Database,{className:"h-5 w-5"}),label:"Devices",value:ce.devices,detail:`${ce.onlineDevices} online`}),e.jsx(Zt,{icon:e.jsx(q.Clock3,{className:"h-5 w-5"}),label:`Conversations, ${t.conversationWindowDays}d`,value:ce.conversations,detail:"Relay prompt/start events"}),e.jsx(Zt,{icon:e.jsx(q.Share2,{className:"h-5 w-5"}),label:"Active shares",value:ce.shares,detail:`${t.pendingRegistrations.length} pending registrations`})]}),e.jsx("nav",{className:"flex gap-2 overflow-x-auto border-b border-[var(--theme-border)] pb-2",children:["overview","users","devices","hosted","shares","settings"].map(H=>e.jsx("button",{className:`rounded-md px-3 py-2 text-sm font-medium ${b===H?"bg-[var(--theme-accent-soft)] text-[var(--theme-fg)]":"text-[var(--theme-fg-muted)] hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]"}`,onClick:()=>x(H),type:"button",children:Ed(H)},H))}),b==="overview"?e.jsx(gd,{summary:t}):null,b==="users"?e.jsx(vd,{busyKey:f,onDeleteUser:be,onResetPassword:Se,onUpdateUser:ke,users:t.users}):null,b==="devices"?e.jsx(bd,{devices:t.devices,users:t.users}):null,b==="hosted"?e.jsx(dd,{busyKey:Q,capability:O,error:d,loading:Y,onAction:ge,onRefresh:oe,sandboxes:D,reconciliation:A,users:t.users}):null,b==="shares"?e.jsx(yd,{shares:t.shares}):null,b==="settings"&&m?e.jsx(wd,{busy:f==="settings",draft:m,onChange:p,onReviewRegistration:L,onSave:P,pending:t.pendingRegistrations,reviewBusyKey:f}):null]}):null]})]})}function dd({busyKey:t,capability:s,error:a,loading:r,onAction:o,onRefresh:l,reconciliation:i,sandboxes:c,users:f}){var X;const g=f.filter(d=>d.role==="user"&&d.enabled),[b,x]=n.useState([]),[S,y]=n.useState("Hosted Codex"),[m,p]=n.useState("standard"),[O,M]=n.useState(`model_provider = "OpenAI"