@bitkyc08/opencodex 2.7.37 → 2.7.39-preview.20260724

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.
@@ -49,4 +49,4 @@ v2: spawn_agent を備えたマルチスレッドエージェント。すべて
49
49
  "model": "gpt-5.4",
50
50
  "input": "Hello, world!"
51
51
  }'`})]})]})}function xa(e){let t=e.autoConnectSupported===!0;return{autoConnectSupported:t,systemEnv:t&&e.systemEnv===!0}}var Sa=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`];function Ca(e){let t=`http://127.0.0.1:${e.port}`,n=e.autoContext&&e.maxContextTokens===null,r=Sa.filter(t=>e.effectiveModelEnv[t]).map(t=>`export ${t}=${e.effectiveModelEnv[t]}`);return[`export ANTHROPIC_BASE_URL=${t}`,...e.authMode===`proxy`?[`export ANTHROPIC_AUTH_TOKEN=opencodex-proxy`]:[`# no ANTHROPIC_AUTH_TOKEN: your claude.ai login (and connectors) stay active`],`export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1`,...e.authMode===`proxy`?['[ -z "${CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST+x}" ] && export CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1']:[],...n?[`export CLAUDE_CODE_AUTO_COMPACT_WINDOW=${e.autoCompactWindow??35e4}`]:[],...r,`claude`].join(`
52
- `)}function wa(e){return e>=1e6?`1M`:`${Math.round(e/1e3)}k`}function Ta({label:e,checked:t,onChange:n,disabled:r=!1,describedBy:i}){return(0,S.jsxs)(`label`,{className:`toggle`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t,disabled:r,"aria-label":e,"aria-describedby":i,onChange:e=>n(e.target.checked)}),(0,S.jsx)(`span`,{className:`slider`,"aria-hidden":`true`})]})}function Ea({supported:e,checked:t,onChange:n}){let r=Y(),i=e?void 0:`claude-system-env-unsupported`;return(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:r(`claude.systemEnv`)}),e?(0,S.jsx)(`span`,{className:`desc`,children:r(`claude.systemEnvDesc`)}):(0,S.jsx)(`span`,{className:`desc`,id:i,children:(0,S.jsx)(be,{k:`claude.systemEnvUnsupported`,cmd:`ocx claude`})}),e&&t&&(0,S.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:r(`claude.systemEnvWarn`)})]}),(0,S.jsx)(Ta,{label:r(`claude.systemEnv`),checked:e&&t,disabled:!e,describedBy:i,onChange:n})]})}function Da({value:e,tierHaikuModel:t,options:n,onChange:r}){let i=Y(),a=t??e;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`h-section`,children:i(`claude.smallFastModel`)}),(0,S.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:i(`claude.smallFastModelAccurateHint`)}),(0,S.jsx)(De,{value:e,options:n,onChange:r,label:i(`claude.smallFastModel`),style:{maxWidth:420}}),a===``&&(0,S.jsx)(`p`,{className:`notice-warn`,role:`status`,style:{marginTop:8},children:i(`claude.smallFastModelNativeWarning`)})]})}function Oa({apiBase:e}){let t=Y(),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),f=(0,_.useCallback)(async()=>{try{let t=await fetch(`${e}/api/claude-code`).then(e=>e.json());r({...t,authMode:t.authMode===`proxy`?`proxy`:`subscription`,...xa(t),fastMode:t.fastMode??null,maxContextTokens:t.maxContextTokens??null,autoContext:t.autoContext!==!1,autoCompactWindow:t.autoCompactWindow??null,injectAgents:t.injectAgents!==!1,effectiveModelEnv:t.effectiveModelEnv??{}}),a(Object.entries(t.modelMap??{}).map(([e,t])=>({from:e,to:String(t)})))}catch{l(!1),s(t(`claude.loadFail`))}finally{d(!1)}},[e,t]);(0,_.useEffect)(()=>{let e=window.setTimeout(()=>{f()},0);return()=>window.clearTimeout(e)},[f]);let p=(0,_.useMemo)(()=>{let e=(n?.available??[]).map(e=>({value:e,label:String(Zn(e))}));return[{value:``,label:t(`claude.smallFastModelUnsetOption`)},...e]},[n?.available,t]),m=(0,_.useMemo)(()=>{let e=[1e5,2e5,25e4,3e5,35e4,4e5,5e5,6e5,75e4,9e5,1e6],r=n?.autoCompactWindow??null,i=r!==null&&!e.includes(r)?[...e,r].sort((e,t)=>e-t):e;return[{value:``,label:t(`claude.autoCompactDefault`)},...i.map(e=>({value:String(e),label:wa(e)}))]},[n?.autoCompactWindow,t]),h=async()=>{if(!n)return;s(``);let r={};for(let e of i)e.from.trim()&&e.to.trim()&&(r[e.from.trim()]=e.to.trim());try{let i=await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n.enabled,authMode:n.authMode,systemEnv:n.systemEnv,fastMode:n.fastMode,autoContext:n.autoContext,autoCompactWindow:n.autoCompactWindow,injectAgents:n.injectAgents,smallFastModel:n.smallFastModel,modelMap:r,webSearchSidecar:n.webSearchSidecar?{backend:n.webSearchSidecar.backend??null,model:n.webSearchSidecar.model??``}:null,visionSidecar:n.visionSidecar?{backend:n.visionSidecar.backend??null,model:n.visionSidecar.model??``}:null})}),a=await i.json();l(i.ok),s(i.ok?t(`claude.saved`):a.error||t(`claude.saveFailed`)),i.ok&&await f()}catch{l(!1),s(t(`claude.networkError`))}};if(u)return(0,S.jsx)(`div`,{className:`muted`,style:{padding:8},children:t(`claude.loading`)});if(!n)return(0,S.jsx)(Ee,{tone:`err`,children:o||t(`claude.loadFail`)});let g=Ca(n);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`page-head`,children:(0,S.jsx)(`h2`,{children:t(`claude.pageTitle`)})}),(0,S.jsx)(`p`,{className:`page-sub`,children:t(`claude.subtitle`)}),o&&(0,S.jsx)(Ee,{tone:c?`ok`:`err`,children:o}),(0,S.jsxs)(`div`,{className:`card`,style:{overflow:`hidden`},children:[(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:t(`claude.enabledLabel`)}),(0,S.jsx)(`span`,{className:`desc`,children:t(`claude.enabledHint`)})]}),(0,S.jsx)(Ta,{label:t(`claude.enabledLabel`),checked:n.enabled,onChange:e=>r({...n,enabled:e})})]}),(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:t(`claude.authMode`)}),(0,S.jsx)(`span`,{className:`desc`,children:t(`claude.authModeHint`)})]}),(0,S.jsx)(De,{value:n.authMode,options:[{value:`subscription`,label:t(`claude.authModeSubscription`)},{value:`proxy`,label:t(`claude.authModeProxy`)}],onChange:e=>r({...n,authMode:e}),label:t(`claude.authMode`),style:{minWidth:220}})]}),(0,S.jsx)(Ea,{supported:n.autoConnectSupported,checked:n.systemEnv,onChange:e=>r({...n,systemEnv:e})}),(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:t(`claude.fastMode`)}),(0,S.jsx)(`span`,{className:`desc`,children:t(`claude.fastModeDesc`)})]}),(0,S.jsxs)(`select`,{value:n.fastMode===null?`auto`:n.fastMode?`on`:`off`,onChange:e=>{let t=e.target.value;r({...n,fastMode:t===`auto`?null:t===`on`})},className:`text-label font-medium`,"aria-label":t(`claude.fastMode`),style:{padding:`5px 10px`,borderRadius:`var(--radius-xs)`,border:`1px solid var(--border)`,background:`var(--surface)`,color:`var(--text)`},children:[(0,S.jsx)(`option`,{value:`auto`,children:t(`claude.fastAuto`)}),(0,S.jsx)(`option`,{value:`on`,children:t(`claude.fastOn`)}),(0,S.jsx)(`option`,{value:`off`,children:t(`claude.fastOff`)})]})]}),(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:t(`claude.autoContext`)}),(0,S.jsx)(`span`,{className:`desc`,children:t(`claude.autoContextDesc`)}),n.maxContextTokens!==null&&(0,S.jsx)(`span`,{className:`desc`,style:{color:`var(--muted)`},children:t(`claude.autoContextInert`)})]}),(0,S.jsx)(Ta,{label:t(`claude.autoContext`),checked:n.autoContext,onChange:e=>r({...n,autoContext:e})})]}),n.autoContext&&(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:t(`claude.autoCompactWindow`)}),(0,S.jsx)(`span`,{className:`desc`,children:t(`claude.autoCompactWindowDesc`)}),n.autoCompactWindow!==null&&(0,S.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:t(`claude.autoCompactWindowWarn`)})]}),(0,S.jsx)(De,{value:n.autoCompactWindow===null?``:String(n.autoCompactWindow),options:m,onChange:e=>r({...n,autoCompactWindow:e===``?null:Number(e)}),label:t(`claude.autoCompactWindow`),style:{minWidth:130}})]}),(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:t(`claude.injectAgents`)}),(0,S.jsx)(`span`,{className:`desc`,children:t(`claude.injectAgentsDesc`)})]}),(0,S.jsx)(Ta,{label:t(`claude.injectAgents`),checked:n.injectAgents,onChange:e=>r({...n,injectAgents:e})})]}),[`webSearchSidecar`,`visionSidecar`].map(e=>{let i=n[e],a=e===`webSearchSidecar`?`claude.webSearchSidecar`:`claude.visionSidecar`,o=e===`webSearchSidecar`?`claude.webSearchSidecarHint`:`claude.visionSidecarHint`;return(0,S.jsxs)(`div`,{className:`setting-row`,style:{alignItems:`flex-start`},children:[(0,S.jsxs)(`div`,{className:`setting-label setting-copy`,style:{flex:1},children:[(0,S.jsx)(`span`,{className:`title`,children:t(a)}),(0,S.jsx)(`span`,{className:`desc`,children:t(o)})]}),(0,S.jsxs)(`div`,{className:`setting-controls`,style:{display:`flex`,gap:8},children:[(0,S.jsx)(De,{value:i?i.backend??`auto`:`inherit`,options:[{value:`inherit`,label:t(`claude.useMainSetting`)},{value:`auto`,label:t(`dash.backendAuto`)},{value:`openai`,label:t(`dash.backendOpenAI`)},{value:`anthropic`,label:t(`dash.backendAnthropic`)}],onChange:t=>r({...n,[e]:t===`inherit`?void 0:{...i,backend:t===`auto`?void 0:t}}),label:t(`dash.sidecarBackend`)}),(0,S.jsx)(`input`,{className:`input mono`,value:i?.model??``,onChange:t=>r({...n,[e]:{...i,model:t.target.value}}),placeholder:t(`claude.sidecarModelPlaceholder`),disabled:!i,"aria-label":t(`dash.sidecarModel`),style:{minWidth:210}})]})]},e)})]}),(0,S.jsx)(`div`,{className:`h-section`,children:t(`claude.quickstart`)}),(0,S.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:(0,S.jsx)(be,{k:`claude.quickstartHint`,cmd:`ocx claude`})}),(0,S.jsx)(`pre`,{className:`mono card`,style:{padding:`10px 14px`,overflowX:`auto`,margin:0},children:`ocx claude`}),(0,S.jsxs)(`details`,{style:{margin:`10px 0 0`},children:[(0,S.jsx)(`summary`,{className:`muted text-label`,style:{cursor:`pointer`,padding:`2px 2px`},children:t(`claude.manualEnv`)}),(0,S.jsx)(`pre`,{className:`mono card text-label`,style:{padding:`10px 14px`,overflowX:`auto`,margin:`6px 0 0`},children:g})]}),(0,S.jsx)(Da,{value:n.smallFastModel,tierHaikuModel:n.tierModels?.haiku,options:p,onChange:e=>r({...n,smallFastModel:e})}),(0,S.jsxs)(`div`,{className:`h-section`,children:[t(`claude.modelMap`),` `,(0,S.jsx)(`span`,{className:`count`,children:i.length})]}),(0,S.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:t(`claude.modelMapHint`)}),(0,S.jsx)(`div`,{className:`stack`,style:{gap:8},children:i.map((e,n)=>(0,S.jsxs)(`div`,{className:`row`,style:{gap:8},children:[(0,S.jsx)(`input`,{className:`input mono`,value:e.from,placeholder:t(`claude.mapFrom`),"aria-label":t(`claude.mapFrom`),onChange:e=>a(t=>t.map((t,r)=>r===n?{...t,from:e.target.value}:t)),style:{flex:1}}),(0,S.jsx)(`span`,{className:`muted`,"aria-hidden":!0,children:`→`}),(0,S.jsx)(`input`,{className:`input mono`,value:e.to,placeholder:t(`claude.mapTo`),"aria-label":t(`claude.mapTo`),onChange:e=>a(t=>t.map((t,r)=>r===n?{...t,to:e.target.value}:t)),style:{flex:1}}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>a(e=>e.filter((e,t)=>t!==n)),"aria-label":t(`claude.removeMapping`),style:{color:`var(--red)`},children:(0,S.jsx)(P,{})})]},n))}),(0,S.jsx)(`div`,{style:{marginTop:8},children:(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>a(e=>[...e,{from:``,to:``}]),children:[(0,S.jsx)(F,{}),` `,t(`claude.addMapping`)]})}),(0,S.jsx)(`div`,{style:{marginTop:14},children:(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:h,children:t(`common.save`)})}),(0,S.jsxs)(`div`,{className:`h-section`,children:[t(`claude.aliases`),` `,(0,S.jsx)(`span`,{className:`count`,children:n.aliases.length})]}),(0,S.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:t(`claude.aliasesHint`)}),n.aliases.length===0?(0,S.jsx)(`div`,{className:`muted text-label`,children:t(`claude.none`)}):(0,S.jsx)(`div`,{className:`stack`,style:{gap:6,maxHeight:320,overflowY:`auto`},children:Array.from(n.aliases.reduce((e,t)=>{let n=/\(([^)]+)\)\s*$/.exec(t.display_name),r=n?n[1]:`etc`;return(e.get(r)??e.set(r,[]).get(r)).push(t),e},new Map)).map(([e,t])=>(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`muted text-caption font-semibold`,style:{textTransform:`uppercase`,letterSpacing:`var(--tracking-wide)`,margin:`6px 2px 4px`},children:[e,` · `,t.length]}),(0,S.jsx)(`div`,{className:`stack`,style:{gap:4},children:t.map(e=>(0,S.jsxs)(`div`,{className:`card row`,style:{padding:`6px 12px`,gap:10},children:[(0,S.jsx)(`code`,{className:`mono text-label`,style:{flex:1},children:e.id}),(0,S.jsx)(`span`,{className:`muted text-label`,children:e.display_name})]},e.id))})]},e))})]})}function ka(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.supported==`boolean`&&typeof t.installed==`boolean`&&typeof t.running==`boolean`&&typeof t.stale==`boolean`&&typeof t.summary==`string`}var Aa={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},ja={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},Ma={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function Na({ok:e,yes:t,no:n}){return(0,S.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function Pa({apiBase:e}){let{t}=ve(),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!0),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(null),[x,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(null),O=(0,_.useCallback)(async n=>{a(!0),p(!0);try{let i=await fetch(`${e}/api/startup-health`,{signal:n});if(!i.ok)throw Error(`fetch failed`);let a=await i.json();if(n?.aborted)return;r(a),s(a.diagnosticStale);try{let r=await fetch(`${e}/api/settings`,{signal:n});if(r.ok){let e=await r.json();if(!n?.aborted){let n=e.codexRuntime,r=!!n?.catalogClamp?.active,i=!!n?.newerAvailable,a=(r?n?.catalogClamp?.runtimeVersion:n?.version)??n?.version??`unknown`,o=(n?.catalogClamp?.removedEfforts??[]).join(`, `);T(r?o?t(`startup.codexRuntime.clampHiddenWithEfforts`,{version:a,efforts:o}):t(`startup.codexRuntime.clampHidden`,{version:a}):i?t(`startup.codexRuntime.olderBinary`,{version:a}):null),D(i?`ocx doctor --fix-codex-runtime && ocx sync`:r?`ocx sync`:null)}}else n?.aborted||(T(null),D(null))}catch{n?.aborted||(T(null),D(null))}if(a.platform===`win32`){v(!1);try{let t=await fetch(`${e}/api/windows-tray`,{signal:n});if(!t.ok)throw Error(`tray status failed`);let r=await t.json();if(!ka(r))throw Error(`invalid tray status`);n?.aborted||(d(r),v(!1))}catch{n?.aborted||(d(null),v(!0))}finally{n?.aborted||p(!1)}}else p(!1)}catch{if(n?.aborted)return;s(!0),d(null),v(!0),p(!1)}finally{n?.aborted||a(!1)}},[e,t]);(0,_.useEffect)(()=>{let e=new AbortController,t=window.setTimeout(()=>{O(e.signal)},0);return()=>{window.clearTimeout(t),e.abort()}},[O]),(0,_.useEffect)(()=>{if(!n?.diagnosticStale)return;let e=window.setTimeout(()=>{O()},2e3);return()=>window.clearTimeout(e)},[n,O]);let k=async e=>{try{await navigator.clipboard.writeText(e),l(e),window.setTimeout(()=>l(t=>t===e?null:t),1600)}catch{l(null)}},j=async t=>{h(!0),v(!1);try{let n=await fetch(`${e}/api/windows-tray`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t})});if(!n.ok)throw Error(`tray action failed`);let r=await n.json();if(!ka(r.status))throw Error(`invalid tray action status`);d(r.status),v(!1)}catch{d(null),v(!0)}finally{h(!1)}},M=async t=>{b(t),C(null);try{let n=await fetch(`${e}/api/startup-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t})}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(typeof r?.error==`string`?r.error:`installation failed`);C({kind:`success`,action:t}),await O()}catch(e){C({kind:`error`,action:t,detail:e instanceof Error?e.message:String(e)})}finally{b(null)}},P=n?.routingKind===`opencodex-local`?`startup.routing.proxy`:n?.routingKind===`custom-local`?`startup.routing.customLocal`:n?.routingKind===`custom-remote`?`startup.routing.customRemote`:n?.routingKind===`unknown`?`startup.routing.unknown`:`startup.routing.native`,F=o?`startup-hero--risk`:n?.status===`protected`?`startup-hero--safe`:n?.status===`at-risk`?`startup-hero--risk`:`startup-hero--native`,L=o||n?.status===`at-risk`?R:N;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`page-head`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{children:t(`startup.title`)}),(0,S.jsx)(`p`,{className:`page-sub startup-page-sub`,children:t(`startup.subtitle`)})]}),(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void O(),disabled:i,children:[(0,S.jsx)(I,{}),` `,t(`startup.refresh`)]})]}),i&&!n?(0,S.jsx)(Oe,{title:t(`startup.loading`)}):o&&!n?(0,S.jsx)(Oe,{title:t(`startup.error`)}):n?(0,S.jsxs)(S.Fragment,{children:[o&&(0,S.jsx)(`div`,{className:`notice notice-warn`,role:`alert`,children:t(`startup.staleData`)}),w&&(0,S.jsxs)(`div`,{className:`notice notice-warn`,role:`status`,children:[(0,S.jsx)(`p`,{children:w}),E&&(0,S.jsxs)(`p`,{children:[(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void k(E),children:t(c===E?`startup.copied`:`startup.copy`)}),(0,S.jsx)(`code`,{style:{marginLeft:`0.5rem`},children:E})]})]}),(0,S.jsxs)(`section`,{className:`panel startup-hero ${F}`,"aria-live":`polite`,children:[(0,S.jsx)(`div`,{className:`startup-hero-icon`,children:(0,S.jsx)(L,{})}),(0,S.jsxs)(`div`,{className:`startup-hero-copy`,children:[(0,S.jsx)(`span`,{className:`badge ${o||n.status===`at-risk`?`badge-amber`:`badge-green`}`,children:t(o?`startup.status.atRisk`:Aa[n.status])}),(0,S.jsx)(`h3`,{children:t(o?`startup.error`:ja[n.status])}),(0,S.jsx)(`p`,{children:o?t(`startup.staleData`):n.status===`at-risk`?t(xe(n)):t(`startup.safeDetail`)})]})]}),(0,S.jsxs)(`div`,{className:`startup-state-grid`,children:[(0,S.jsxs)(`section`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`label`,children:t(`startup.routing`)}),(0,S.jsx)(`div`,{className:`value`,children:t(P)})]}),(0,S.jsxs)(`section`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`label`,children:t(`startup.restartProtection`)}),(0,S.jsx)(`div`,{className:`value`,children:t(Ma[n.protection])})]}),(0,S.jsxs)(`section`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`label`,children:t(`startup.preference`)}),(0,S.jsx)(`div`,{className:`value`,children:t(n.autostartEnabled?`startup.enabled`:`startup.disabled`)})]})]}),(0,S.jsxs)(`section`,{className:`panel startup-details`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`h3`,{className:`panel-title`,children:t(`startup.details`)}),(0,S.jsx)(`span`,{className:`muted mono`,children:n.platform})]}),(0,S.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`strong`,{children:t(`startup.service`)}),(0,S.jsx)(`span`,{children:t(`startup.serviceHint`)})]}),(0,S.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,S.jsx)(Na,{ok:n.serviceViable,yes:t(`startup.viable`),no:t(n.serviceConflict?`startup.conflict`:n.serviceStale?`startup.stale`:n.serviceInstalled?`startup.unhealthy`:n.serviceSupported?`startup.notInstalled`:`startup.unsupported`)}),n.serviceSupported&&!n.serviceInstalled&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${t(`startup.service`)} - ${t(`startup.install`)}`,disabled:y!==null||o,onClick:()=>void M(`install-service`),children:t(y===`install-service`?`startup.installing`:`startup.install`)})]})]}),(0,S.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`strong`,{children:t(`startup.shim`)}),(0,S.jsx)(`span`,{children:t(`startup.shimHint`)})]}),(0,S.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,S.jsx)(Na,{ok:n.shimHealthy&&n.autostartEnabled,yes:t(n.shimCoverage===`cli-only`?`startup.cliOnly`:`startup.healthy`),no:t(n.shimInstalled?n.shimHealthy&&!n.autostartEnabled?`startup.installedDisabled`:`startup.stale`:`startup.notInstalled`)}),!n.shimInstalled&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${t(`startup.shim`)} - ${t(`startup.install`)}`,disabled:y!==null||o,onClick:()=>void M(`install-shim`),children:t(y===`install-shim`?`startup.installing`:`startup.install`)})]})]}),x&&(0,S.jsx)(`div`,{className:`notice ${x.kind===`success`?`notice-ok`:`notice-warn`} startup-action-notice`,role:`status`,"aria-live":`polite`,children:x.kind===`success`?t(x.action===`install-service`?`startup.serviceInstalled`:`startup.shimInstalled`):`${t(`startup.installFailed`)} ${x.detail??``}`})]}),n.platform===`win32`&&(0,S.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`h3`,{className:`panel-title`,children:t(`startup.tray.title`)}),(0,S.jsx)(W,{})]}),(0,S.jsx)(`p`,{className:`muted`,children:t(`startup.tray.hint`)}),(0,S.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`strong`,{children:t(`startup.tray.login`)}),(0,S.jsx)(`span`,{children:t(`startup.tray.notProtection`)})]}),f||g||!u?(0,S.jsx)(`span`,{className:`badge badge-amber`,children:t(f?`startup.tray.loading`:`startup.tray.unavailable`)}):(0,S.jsx)(Na,{ok:u.running&&!u.stale,yes:t(`startup.tray.running`),no:t(u.stale?`startup.tray.stale`:u.installed?`startup.tray.stopped`:`startup.tray.notInstalled`)})]}),(0,S.jsxs)(`div`,{className:`startup-tray-buttons`,children:[!f&&!g&&u&&!u.installed&&!u.stale&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:m,onClick:()=>void j(`install`),children:t(`startup.tray.install`)}),!f&&!g&&u?.installed&&!u.stale&&!u.running&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:m,onClick:()=>void j(`start`),children:t(`startup.tray.start`)}),!f&&!g&&u?.running&&!u.stale&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:m,onClick:()=>void j(`stop`),children:t(`startup.tray.stop`)}),!f&&!g&&u&&(u.installed||u.stale)&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-danger`,disabled:m,onClick:()=>{window.confirm(t(`startup.tray.uninstall`))&&j(`uninstall`)},children:t(`startup.tray.uninstall`)})]}),(g||u?.stale)&&(0,S.jsx)(`div`,{className:`notice notice-warn`,role:`alert`,children:t(`startup.tray.error`)})]}),(0,S.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`h3`,{className:`panel-title`,children:t(`startup.recovery`)}),(0,S.jsx)(A,{})]}),(0,S.jsx)(`p`,{className:`muted`,children:t(`startup.recoveryHint`)}),(0,S.jsxs)(`div`,{className:`startup-command-list`,children:[n.serviceSupported&&(0,S.jsxs)(`div`,{className:`startup-command-row`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`strong`,{children:t(`startup.command.service`)}),(0,S.jsx)(`code`,{children:n.commands.installService})]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void k(n.commands.installService),children:c===n.commands.installService?t(`startup.copied`):t(`startup.copy`)})]}),(0,S.jsxs)(`div`,{className:`startup-command-row`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`strong`,{children:t(`startup.command.shim`)}),(0,S.jsx)(`code`,{children:n.commands.installShim})]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void k(n.commands.installShim),children:c===n.commands.installShim?t(`startup.copied`):t(`startup.copy`)})]}),(0,S.jsxs)(`div`,{className:`startup-command-row`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`strong`,{children:t(`startup.command.native`)}),(0,S.jsx)(`code`,{children:n.commands.restoreNative})]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void k(n.commands.restoreNative),children:c===n.commands.restoreNative?t(`startup.copied`):t(`startup.copy`)})]})]}),n.status===`at-risk`&&(0,S.jsxs)(`div`,{className:`notice notice-warn startup-action-notice`,role:`alert`,children:[(0,S.jsx)(W,{}),` `,t(`startup.recommended`,{cmd:n.recommendedCommand??n.commands.installService})]})]})]}):null]})}var Fa=class extends _.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}reload=()=>{this.setState({error:null})};render(){return this.state.error?(0,S.jsxs)(`section`,{className:`card`,role:`alert`,style:{maxWidth:720,padding:`var(--space-6)`},children:[(0,S.jsxs)(`h2`,{style:{margin:`0 0 var(--space-2)`,fontSize:`var(--text-title)`},children:[this.props.pageName,`: `,this.props.title]}),(0,S.jsx)(`p`,{className:`muted`,style:{margin:`0 0 var(--space-4)`},children:this.props.message}),(0,S.jsxs)(`p`,{style:{margin:`0 0 var(--space-5)`,overflowWrap:`anywhere`},children:[(0,S.jsxs)(`strong`,{children:[this.props.detailsLabel,`:`]}),` `,this.state.error.message]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:this.reload,children:this.props.reloadLabel})]}):this.props.children}},Ia=`opencodex-api-token`,La=!1,Ra=null;function za(e){try{let t=e instanceof Request?e.url:String(e);return new URL(t,window.location.href).pathname}catch{return null}}function Ba(e){let t=za(e);return!!t&&(t.startsWith(`/api/`)||t.startsWith(`/v1/`))}function Va(){try{return sessionStorage.getItem(Ia)?.trim()||null}catch{return null}}function Ha(e){try{sessionStorage.setItem(Ia,e)}catch{}}function Ua(){try{sessionStorage.removeItem(Ia)}catch{}}function Wa(e,t,n){let r=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));return r.set(`X-OpenCodex-API-Key`,n),e instanceof Request?[new Request(e,{headers:r}),t?{...t,headers:r}:void 0]:[e,{...t,headers:r}]}async function Ga(){return Ra||(Ra=Promise.resolve().then(()=>window.prompt(`OpenCodex API token`)?.trim()||null).finally(()=>{Ra=null}),Ra)}function Ka(){if(La)return;La=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{if(!Ba(t))return e(t,n);let r=Va(),[i,a]=r?Wa(t,n,r):[t,n],o=await e(i,a);if(o.status!==401)return o;r&&Ua();let s=await Ga();if(!s)return o;Ha(s);let[c,l]=Wa(t,n,s),u=await e(c,l);return u.status===401&&Ua(),u}}Ka();var qa=new Set([`dashboard`,`startup`,`providers`,`models`,`combos`,`subagents`,`logs`,`usage`,`storage`,`codex-auth`,`api`,`claude`]),Ja={dashboard:`nav.dashboard`,startup:`nav.startup`,providers:`nav.providers`,models:`nav.models`,combos:`nav.combos`,subagents:`nav.subagents`,logs:`nav.logs`,usage:`nav.usage`,storage:`nav.storage`,"codex-auth":`nav.codexAuth`,api:`nav.api`,claude:`nav.claude`};function Ya(){let e=location.hash.replace(/^#\/?/,``).split(`/`)[0];return e===`debug`?`logs`:qa.has(e)?e:`dashboard`}function Xa(e,t){return e===t||t===`providers`&&e===`providers/workspace`||t===`logs`&&e===`logs/debug`}var Za=``,Qa=`ocx-theme`,$a=`ocx-providers-view`;function eo(){try{return localStorage.getItem($a)===`workspace`?`workspace`:`classic`}catch{return`classic`}}function to(e){try{localStorage.setItem($a,e)}catch{}}function Z(){return eo()===`workspace`?`providers/workspace`:`providers`}var no=[{id:`dashboard`,tkey:`nav.dashboard`,Icon:w},{id:`providers`,tkey:`nav.providers`,Icon:T},{id:`models`,tkey:`nav.models`,Icon:E},{id:`subagents`,tkey:`nav.subagents`,Icon:D},{id:`logs`,tkey:`nav.logs`,Icon:O},{id:`usage`,tkey:`nav.usage`,Icon:j},{id:`storage`,tkey:`nav.storage`,Icon:M},{id:`codex-auth`,tkey:`nav.codexAuth`,Icon:ne},{id:`api`,tkey:`nav.api`,Icon:K},{id:`claude`,tkey:`nav.claude`,Icon:q}],ro={light:G,dark:oe,system:se},io={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function ao(e){if(!e||typeof e!=`object`||!(`version`in e))return null;let t=e.version;return typeof t==`string`&&t.length>0?t:null}function oo(){let e=localStorage.getItem(Qa);return e===`light`||e===`dark`?e:`system`}function so(){let[e,t]=(0,_.useState)(Ya),[n,r]=(0,_.useState)(oo),[i,a]=(0,_.useState)(null),{locale:o,setLocale:s}=ve(),c=Y(),[l,u]=(0,_.useState)(!1),d=(0,_.useRef)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(!1);(0,_.useEffect)(()=>{let e=()=>{let e=Ya(),n=window.location.hash.replace(/^#\/?/,``);if(u(!1),n===`debug`||n.startsWith(`debug/`)){window.location.hash=`logs/debug`;return}if(!Xa(n,e)){window.location.hash=e===`providers`?Z():e;return}if(e===`providers`){let e=eo();if(n===`providers/workspace`)to(`workspace`);else if(n===`providers`&&e===`workspace`){window.location.hash=`providers/workspace`;return}else n===`providers`&&to(`classic`)}t(e)};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,_.useEffect)(()=>{let t=window.location.hash.replace(/^#\/?/,``);if(t===`debug`||t.startsWith(`debug/`)){window.location.hash=`logs/debug`;return}if(e===`providers`){if(t===`providers/workspace`){to(`workspace`);return}let e=Z();t!==e&&(window.location.hash=e);return}Xa(t,e)||(window.location.hash=e)},[e]),(0,_.useEffect)(()=>{let e=document.documentElement;n===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(Qa)):(e.setAttribute(`data-theme`,n),localStorage.setItem(Qa,n))},[n]),(0,_.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await fetch(`${Za}/healthz`);if(!t.ok)return;let n=ao(await t.json());!e&&n&&a(n)}catch{}};t();let n=setInterval(t,3e4);return()=>{e=!0,clearInterval(n)}},[]);let m=()=>r(e=>e===`light`?`dark`:e===`dark`?`system`:`light`),h=ro[n],g=i??`2.7.37`,[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(null);(0,_.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};window.addEventListener(`keydown`,e);let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{window.removeEventListener(`keydown`,e),document.body.style.overflow=t}},[l]),(0,_.useEffect)(()=>{if(l){p.current=!0;let e=setTimeout(()=>f.current?.focus(),200);return()=>clearTimeout(e)}p.current&&(p.current=!1,d.current?.focus())},[l]),(0,_.useEffect)(()=>{let e=window.matchMedia(`(min-width: 761px)`),t=()=>{e.matches&&u(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,_.useEffect)(()=>{let e=!1;return fetch(`${Za}/api/claude-code`).then(e=>e.json()).then(t=>{!e&&typeof t.enabled==`boolean`&&x(t.enabled)}).catch(()=>{}),()=>{e=!0}},[]);let C=async()=>{if(b===null)return;let e=!b;x(e);try{(await fetch(`${Za}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})})).ok||x(!e)}catch{x(!e)}},w=async()=>{if(confirm(c(`dash.stopConfirm`))){y(!0);try{await fetch(`${Za}/api/stop`,{method:`POST`})}catch{}}},T=(0,S.jsxs)(`div`,{className:`brand`,children:[(0,S.jsx)(`span`,{className:`brand-logo`,role:`img`,"aria-label":c(`app.logoAria`)}),(0,S.jsx)(`span`,{className:`name`,children:`opencodex`}),(0,S.jsxs)(`span`,{className:`ver`,children:[`v`,g]})]});return(0,S.jsxs)(`div`,{className:`app`,children:[(0,S.jsxs)(`header`,{className:`mobile-topbar`,inert:l,children:[(0,S.jsx)(`button`,{ref:d,type:`button`,className:`menu-toggle`,onClick:()=>u(e=>!e),"aria-expanded":l,"aria-controls":`app-sidebar`,"aria-label":c(l?`nav.closeMenu`:`nav.openMenu`),title:c(l?`nav.closeMenu`:`nav.openMenu`),children:(0,S.jsx)(k,{})}),T,(0,S.jsx)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:w,disabled:v,"aria-label":c(`dash.stop`),title:c(`dash.stop`),children:(0,S.jsx)(W,{})})]}),l&&(0,S.jsx)(`div`,{className:`drawer-scrim`,onClick:()=>u(!1),"aria-hidden":`true`}),(0,S.jsxs)(`aside`,{id:`app-sidebar`,className:`sidebar${l?` open`:``}`,ref:f,tabIndex:-1,children:[(0,S.jsxs)(`div`,{className:`drawer-head`,children:[T,(0,S.jsx)(`button`,{type:`button`,className:`menu-toggle drawer-close`,onClick:()=>u(!1),"aria-label":c(`nav.closeMenu`),title:c(`nav.closeMenu`),children:(0,S.jsx)(P,{})})]}),(0,S.jsx)(`nav`,{children:no.map(({id:n,tkey:r,Icon:i})=>(0,S.jsxs)(`div`,{className:`nav-entry${n===`claude`?` nav-entry-claude${e===n?` active`:``}`:``}`,children:[(0,S.jsxs)(`button`,{className:`nav-item${e===n?` active`:``}`,"data-page":n,onClick:()=>{window.location.hash=n===`providers`?Z():n,t(n),u(!1)},"aria-current":e===n?`page`:void 0,children:[(0,S.jsx)(i,{}),` `,c(r)]}),n===`claude`&&b!==null&&(0,S.jsx)(Te,{on:b,onClick:()=>void C(),label:c(`claude.toggleAria`)})]},n))}),(0,S.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,S.jsxs)(`div`,{className:`lang-toggle`,children:[(0,S.jsx)(K,{"aria-hidden":!0}),(0,S.jsx)(De,{value:o,options:pe.map(e=>({value:e.code,label:e.name})),onChange:e=>s(e),label:c(`lang.label`),placement:`right`,style:{flex:1,minWidth:0,width:`100%`}})]}),(0,S.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:m,"aria-label":`${c(`theme.label`)}: ${c(io[n])}`,title:`${c(`theme.label`)}: ${c(io[n])}`,children:[(0,S.jsx)(h,{}),` `,(0,S.jsx)(`span`,{className:`mode`,children:c(io[n])})]}),(0,S.jsxs)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:w,disabled:v,"aria-label":c(`dash.stop`),title:c(`dash.stop`),children:[(0,S.jsx)(W,{}),` `,(0,S.jsx)(`span`,{className:`mode`,children:c(v?`dash.stopping`:`dash.stop`)})]}),(0,S.jsxs)(`a`,{className:`sidebar-link`,href:`https://github.com/lidge-jun/opencodex`,target:`_blank`,rel:`noreferrer`,children:[(0,S.jsx)(U,{}),` `,c(`common.github`)]})]})]}),(0,S.jsx)(`main`,{className:`main`,inert:l,children:(0,S.jsx)(`div`,{className:`main-inner${e===`combos`?` main-inner--combos`:``}`,children:(0,S.jsxs)(Fa,{pageName:c(Ja[e]),title:c(`errorBoundary.title`),message:c(`errorBoundary.message`),detailsLabel:c(`errorBoundary.details`),reloadLabel:c(`errorBoundary.reload`),children:[e===`dashboard`&&(0,S.jsx)(Ve,{apiBase:Za}),e===`startup`&&(0,S.jsx)(Pa,{apiBase:Za}),e===`providers`&&(0,S.jsx)(Kn,{apiBase:Za}),e===`models`&&(0,S.jsx)(Or,{apiBase:Za}),e===`combos`&&(0,S.jsx)(Gr,{apiBase:Za}),e===`subagents`&&(0,S.jsx)(Kr,{apiBase:Za}),e===`logs`&&(0,S.jsx)(Ki,{apiBase:Za}),e===`usage`&&(0,S.jsx)(la,{apiBase:Za}),e===`storage`&&(0,S.jsx)(ga,{apiBase:Za}),e===`codex-auth`&&(0,S.jsx)(va,{apiBase:Za}),e===`api`&&(0,S.jsx)(ba,{apiBase:Za}),e===`claude`&&(0,S.jsx)(Oa,{apiBase:Za})]},e)})})]})}v.createRoot(document.getElementById(`root`)).render((0,S.jsx)(_.StrictMode,{children:(0,S.jsx)(ye,{children:(0,S.jsx)(so,{})})}));
52
+ `)}function wa(e){return e>=1e6?`1M`:`${Math.round(e/1e3)}k`}function Ta({label:e,checked:t,onChange:n,disabled:r=!1,describedBy:i}){return(0,S.jsxs)(`label`,{className:`toggle`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t,disabled:r,"aria-label":e,"aria-describedby":i,onChange:e=>n(e.target.checked)}),(0,S.jsx)(`span`,{className:`slider`,"aria-hidden":`true`})]})}function Ea({supported:e,checked:t,onChange:n}){let r=Y(),i=e?void 0:`claude-system-env-unsupported`;return(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:r(`claude.systemEnv`)}),e?(0,S.jsx)(`span`,{className:`desc`,children:r(`claude.systemEnvDesc`)}):(0,S.jsx)(`span`,{className:`desc`,id:i,children:(0,S.jsx)(be,{k:`claude.systemEnvUnsupported`,cmd:`ocx claude`})}),e&&t&&(0,S.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:r(`claude.systemEnvWarn`)})]}),(0,S.jsx)(Ta,{label:r(`claude.systemEnv`),checked:e&&t,disabled:!e,describedBy:i,onChange:n})]})}function Da({value:e,tierHaikuModel:t,options:n,onChange:r}){let i=Y(),a=t??e;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`h-section`,children:i(`claude.smallFastModel`)}),(0,S.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:i(`claude.smallFastModelAccurateHint`)}),(0,S.jsx)(De,{value:e,options:n,onChange:r,label:i(`claude.smallFastModel`),style:{maxWidth:420}}),a===``&&(0,S.jsx)(`p`,{className:`notice-warn`,role:`status`,style:{marginTop:8},children:i(`claude.smallFastModelNativeWarning`)})]})}function Oa({apiBase:e}){let t=Y(),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),f=(0,_.useCallback)(async()=>{try{let t=await fetch(`${e}/api/claude-code`).then(e=>e.json());r({...t,authMode:t.authMode===`proxy`?`proxy`:`subscription`,...xa(t),fastMode:t.fastMode??null,maxContextTokens:t.maxContextTokens??null,autoContext:t.autoContext!==!1,autoCompactWindow:t.autoCompactWindow??null,injectAgents:t.injectAgents!==!1,effectiveModelEnv:t.effectiveModelEnv??{}}),a(Object.entries(t.modelMap??{}).map(([e,t])=>({from:e,to:String(t)})))}catch{l(!1),s(t(`claude.loadFail`))}finally{d(!1)}},[e,t]);(0,_.useEffect)(()=>{let e=window.setTimeout(()=>{f()},0);return()=>window.clearTimeout(e)},[f]);let p=(0,_.useMemo)(()=>{let e=(n?.available??[]).map(e=>({value:e,label:String(Zn(e))}));return[{value:``,label:t(`claude.smallFastModelUnsetOption`)},...e]},[n?.available,t]),m=(0,_.useMemo)(()=>{let e=[1e5,2e5,25e4,3e5,35e4,4e5,5e5,6e5,75e4,9e5,1e6],r=n?.autoCompactWindow??null,i=r!==null&&!e.includes(r)?[...e,r].sort((e,t)=>e-t):e;return[{value:``,label:t(`claude.autoCompactDefault`)},...i.map(e=>({value:String(e),label:wa(e)}))]},[n?.autoCompactWindow,t]),h=async()=>{if(!n)return;s(``);let r={};for(let e of i)e.from.trim()&&e.to.trim()&&(r[e.from.trim()]=e.to.trim());try{let i=await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n.enabled,authMode:n.authMode,systemEnv:n.systemEnv,fastMode:n.fastMode,autoContext:n.autoContext,autoCompactWindow:n.autoCompactWindow,injectAgents:n.injectAgents,smallFastModel:n.smallFastModel,modelMap:r,webSearchSidecar:n.webSearchSidecar?{backend:n.webSearchSidecar.backend??null,model:n.webSearchSidecar.model??``}:null,visionSidecar:n.visionSidecar?{backend:n.visionSidecar.backend??null,model:n.visionSidecar.model??``}:null})}),a=await i.json();l(i.ok),s(i.ok?t(`claude.saved`):a.error||t(`claude.saveFailed`)),i.ok&&await f()}catch{l(!1),s(t(`claude.networkError`))}};if(u)return(0,S.jsx)(`div`,{className:`muted`,style:{padding:8},children:t(`claude.loading`)});if(!n)return(0,S.jsx)(Ee,{tone:`err`,children:o||t(`claude.loadFail`)});let g=Ca(n);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`page-head`,children:(0,S.jsx)(`h2`,{children:t(`claude.pageTitle`)})}),(0,S.jsx)(`p`,{className:`page-sub`,children:t(`claude.subtitle`)}),o&&(0,S.jsx)(Ee,{tone:c?`ok`:`err`,children:o}),(0,S.jsxs)(`div`,{className:`card`,style:{overflow:`hidden`},children:[(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:t(`claude.enabledLabel`)}),(0,S.jsx)(`span`,{className:`desc`,children:t(`claude.enabledHint`)})]}),(0,S.jsx)(Ta,{label:t(`claude.enabledLabel`),checked:n.enabled,onChange:e=>r({...n,enabled:e})})]}),(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:t(`claude.authMode`)}),(0,S.jsx)(`span`,{className:`desc`,children:t(`claude.authModeHint`)})]}),(0,S.jsx)(De,{value:n.authMode,options:[{value:`subscription`,label:t(`claude.authModeSubscription`)},{value:`proxy`,label:t(`claude.authModeProxy`)}],onChange:e=>r({...n,authMode:e}),label:t(`claude.authMode`),style:{minWidth:220}})]}),(0,S.jsx)(Ea,{supported:n.autoConnectSupported,checked:n.systemEnv,onChange:e=>r({...n,systemEnv:e})}),(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:t(`claude.fastMode`)}),(0,S.jsx)(`span`,{className:`desc`,children:t(`claude.fastModeDesc`)})]}),(0,S.jsxs)(`select`,{value:n.fastMode===null?`auto`:n.fastMode?`on`:`off`,onChange:e=>{let t=e.target.value;r({...n,fastMode:t===`auto`?null:t===`on`})},className:`text-label font-medium`,"aria-label":t(`claude.fastMode`),style:{padding:`5px 10px`,borderRadius:`var(--radius-xs)`,border:`1px solid var(--border)`,background:`var(--surface)`,color:`var(--text)`},children:[(0,S.jsx)(`option`,{value:`auto`,children:t(`claude.fastAuto`)}),(0,S.jsx)(`option`,{value:`on`,children:t(`claude.fastOn`)}),(0,S.jsx)(`option`,{value:`off`,children:t(`claude.fastOff`)})]})]}),(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:t(`claude.autoContext`)}),(0,S.jsx)(`span`,{className:`desc`,children:t(`claude.autoContextDesc`)}),n.maxContextTokens!==null&&(0,S.jsx)(`span`,{className:`desc`,style:{color:`var(--muted)`},children:t(`claude.autoContextInert`)})]}),(0,S.jsx)(Ta,{label:t(`claude.autoContext`),checked:n.autoContext,onChange:e=>r({...n,autoContext:e})})]}),n.autoContext&&(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:t(`claude.autoCompactWindow`)}),(0,S.jsx)(`span`,{className:`desc`,children:t(`claude.autoCompactWindowDesc`)}),n.autoCompactWindow!==null&&(0,S.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:t(`claude.autoCompactWindowWarn`)})]}),(0,S.jsx)(De,{value:n.autoCompactWindow===null?``:String(n.autoCompactWindow),options:m,onChange:e=>r({...n,autoCompactWindow:e===``?null:Number(e)}),label:t(`claude.autoCompactWindow`),style:{minWidth:130}})]}),(0,S.jsxs)(`div`,{className:`setting-row`,children:[(0,S.jsxs)(`div`,{className:`setting-label`,children:[(0,S.jsx)(`span`,{className:`title`,children:t(`claude.injectAgents`)}),(0,S.jsx)(`span`,{className:`desc`,children:t(`claude.injectAgentsDesc`)})]}),(0,S.jsx)(Ta,{label:t(`claude.injectAgents`),checked:n.injectAgents,onChange:e=>r({...n,injectAgents:e})})]}),[`webSearchSidecar`,`visionSidecar`].map(e=>{let i=n[e],a=e===`webSearchSidecar`?`claude.webSearchSidecar`:`claude.visionSidecar`,o=e===`webSearchSidecar`?`claude.webSearchSidecarHint`:`claude.visionSidecarHint`;return(0,S.jsxs)(`div`,{className:`setting-row`,style:{alignItems:`flex-start`},children:[(0,S.jsxs)(`div`,{className:`setting-label setting-copy`,style:{flex:1},children:[(0,S.jsx)(`span`,{className:`title`,children:t(a)}),(0,S.jsx)(`span`,{className:`desc`,children:t(o)})]}),(0,S.jsxs)(`div`,{className:`setting-controls`,style:{display:`flex`,gap:8},children:[(0,S.jsx)(De,{value:i?i.backend??`auto`:`inherit`,options:[{value:`inherit`,label:t(`claude.useMainSetting`)},{value:`auto`,label:t(`dash.backendAuto`)},{value:`openai`,label:t(`dash.backendOpenAI`)},{value:`anthropic`,label:t(`dash.backendAnthropic`)}],onChange:t=>r({...n,[e]:t===`inherit`?void 0:{...i,backend:t===`auto`?void 0:t}}),label:t(`dash.sidecarBackend`)}),(0,S.jsx)(`input`,{className:`input mono`,value:i?.model??``,onChange:t=>r({...n,[e]:{...i,model:t.target.value}}),placeholder:t(`claude.sidecarModelPlaceholder`),disabled:!i,"aria-label":t(`dash.sidecarModel`),style:{minWidth:210}})]})]},e)})]}),(0,S.jsx)(`div`,{className:`h-section`,children:t(`claude.quickstart`)}),(0,S.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:(0,S.jsx)(be,{k:`claude.quickstartHint`,cmd:`ocx claude`})}),(0,S.jsx)(`pre`,{className:`mono card`,style:{padding:`10px 14px`,overflowX:`auto`,margin:0},children:`ocx claude`}),(0,S.jsxs)(`details`,{style:{margin:`10px 0 0`},children:[(0,S.jsx)(`summary`,{className:`muted text-label`,style:{cursor:`pointer`,padding:`2px 2px`},children:t(`claude.manualEnv`)}),(0,S.jsx)(`pre`,{className:`mono card text-label`,style:{padding:`10px 14px`,overflowX:`auto`,margin:`6px 0 0`},children:g})]}),(0,S.jsx)(Da,{value:n.smallFastModel,tierHaikuModel:n.tierModels?.haiku,options:p,onChange:e=>r({...n,smallFastModel:e})}),(0,S.jsxs)(`div`,{className:`h-section`,children:[t(`claude.modelMap`),` `,(0,S.jsx)(`span`,{className:`count`,children:i.length})]}),(0,S.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:t(`claude.modelMapHint`)}),(0,S.jsx)(`div`,{className:`stack`,style:{gap:8},children:i.map((e,n)=>(0,S.jsxs)(`div`,{className:`row`,style:{gap:8},children:[(0,S.jsx)(`input`,{className:`input mono`,value:e.from,placeholder:t(`claude.mapFrom`),"aria-label":t(`claude.mapFrom`),onChange:e=>a(t=>t.map((t,r)=>r===n?{...t,from:e.target.value}:t)),style:{flex:1}}),(0,S.jsx)(`span`,{className:`muted`,"aria-hidden":!0,children:`→`}),(0,S.jsx)(`input`,{className:`input mono`,value:e.to,placeholder:t(`claude.mapTo`),"aria-label":t(`claude.mapTo`),onChange:e=>a(t=>t.map((t,r)=>r===n?{...t,to:e.target.value}:t)),style:{flex:1}}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>a(e=>e.filter((e,t)=>t!==n)),"aria-label":t(`claude.removeMapping`),style:{color:`var(--red)`},children:(0,S.jsx)(P,{})})]},n))}),(0,S.jsx)(`div`,{style:{marginTop:8},children:(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>a(e=>[...e,{from:``,to:``}]),children:[(0,S.jsx)(F,{}),` `,t(`claude.addMapping`)]})}),(0,S.jsx)(`div`,{style:{marginTop:14},children:(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:h,children:t(`common.save`)})}),(0,S.jsxs)(`div`,{className:`h-section`,children:[t(`claude.aliases`),` `,(0,S.jsx)(`span`,{className:`count`,children:n.aliases.length})]}),(0,S.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:t(`claude.aliasesHint`)}),n.aliases.length===0?(0,S.jsx)(`div`,{className:`muted text-label`,children:t(`claude.none`)}):(0,S.jsx)(`div`,{className:`stack`,style:{gap:6,maxHeight:320,overflowY:`auto`},children:Array.from(n.aliases.reduce((e,t)=>{let n=/\(([^)]+)\)\s*$/.exec(t.display_name),r=n?n[1]:`etc`;return(e.get(r)??e.set(r,[]).get(r)).push(t),e},new Map)).map(([e,t])=>(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`muted text-caption font-semibold`,style:{textTransform:`uppercase`,letterSpacing:`var(--tracking-wide)`,margin:`6px 2px 4px`},children:[e,` · `,t.length]}),(0,S.jsx)(`div`,{className:`stack`,style:{gap:4},children:t.map(e=>(0,S.jsxs)(`div`,{className:`card row`,style:{padding:`6px 12px`,gap:10},children:[(0,S.jsx)(`code`,{className:`mono text-label`,style:{flex:1},children:e.id}),(0,S.jsx)(`span`,{className:`muted text-label`,children:e.display_name})]},e.id))})]},e))})]})}function ka(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.supported==`boolean`&&typeof t.installed==`boolean`&&typeof t.running==`boolean`&&typeof t.stale==`boolean`&&typeof t.summary==`string`}var Aa={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},ja={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},Ma={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function Na({ok:e,yes:t,no:n}){return(0,S.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function Pa({apiBase:e}){let{t}=ve(),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!0),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(null),[x,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(null),O=(0,_.useCallback)(async n=>{a(!0),p(!0);try{let i=await fetch(`${e}/api/startup-health`,{signal:n});if(!i.ok)throw Error(`fetch failed`);let a=await i.json();if(n?.aborted)return;r(a),s(a.diagnosticStale);try{let r=await fetch(`${e}/api/settings`,{signal:n});if(r.ok){let e=await r.json();if(!n?.aborted){let n=e.codexRuntime,r=!!n?.catalogClamp?.active,i=!!n?.newerAvailable,a=(r?n?.catalogClamp?.runtimeVersion:n?.version)??n?.version??`unknown`,o=(n?.catalogClamp?.removedEfforts??[]).join(`, `);T(r?o?t(`startup.codexRuntime.clampHiddenWithEfforts`,{version:a,efforts:o}):t(`startup.codexRuntime.clampHidden`,{version:a}):i?t(`startup.codexRuntime.olderBinary`,{version:a}):null),D(i?`ocx doctor --fix-codex-runtime && ocx sync`:r?`ocx sync`:null)}}else n?.aborted||(T(null),D(null))}catch{n?.aborted||(T(null),D(null))}if(a.platform===`win32`){v(!1);try{let t=await fetch(`${e}/api/windows-tray`,{signal:n});if(!t.ok)throw Error(`tray status failed`);let r=await t.json();if(!ka(r))throw Error(`invalid tray status`);n?.aborted||(d(r),v(!1))}catch{n?.aborted||(d(null),v(!0))}finally{n?.aborted||p(!1)}}else p(!1)}catch{if(n?.aborted)return;s(!0),d(null),v(!0),p(!1)}finally{n?.aborted||a(!1)}},[e,t]);(0,_.useEffect)(()=>{let e=new AbortController,t=window.setTimeout(()=>{O(e.signal)},0);return()=>{window.clearTimeout(t),e.abort()}},[O]),(0,_.useEffect)(()=>{if(!n?.diagnosticStale)return;let e=window.setTimeout(()=>{O()},2e3);return()=>window.clearTimeout(e)},[n,O]);let k=async e=>{try{await navigator.clipboard.writeText(e),l(e),window.setTimeout(()=>l(t=>t===e?null:t),1600)}catch{l(null)}},j=async t=>{h(!0),v(!1);try{let n=await fetch(`${e}/api/windows-tray`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t})});if(!n.ok)throw Error(`tray action failed`);let r=await n.json();if(!ka(r.status))throw Error(`invalid tray action status`);d(r.status),v(!1)}catch{d(null),v(!0)}finally{h(!1)}},M=async t=>{b(t),C(null);try{let n=await fetch(`${e}/api/startup-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t})}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(typeof r?.error==`string`?r.error:`installation failed`);C({kind:`success`,action:t}),await O()}catch(e){C({kind:`error`,action:t,detail:e instanceof Error?e.message:String(e)})}finally{b(null)}},P=n?.routingKind===`opencodex-local`?`startup.routing.proxy`:n?.routingKind===`custom-local`?`startup.routing.customLocal`:n?.routingKind===`custom-remote`?`startup.routing.customRemote`:n?.routingKind===`unknown`?`startup.routing.unknown`:`startup.routing.native`,F=o?`startup-hero--risk`:n?.status===`protected`?`startup-hero--safe`:n?.status===`at-risk`?`startup-hero--risk`:`startup-hero--native`,L=o||n?.status===`at-risk`?R:N;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`page-head`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{children:t(`startup.title`)}),(0,S.jsx)(`p`,{className:`page-sub startup-page-sub`,children:t(`startup.subtitle`)})]}),(0,S.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void O(),disabled:i,children:[(0,S.jsx)(I,{}),` `,t(`startup.refresh`)]})]}),i&&!n?(0,S.jsx)(Oe,{title:t(`startup.loading`)}):o&&!n?(0,S.jsx)(Oe,{title:t(`startup.error`)}):n?(0,S.jsxs)(S.Fragment,{children:[o&&(0,S.jsx)(`div`,{className:`notice notice-warn`,role:`alert`,children:t(`startup.staleData`)}),w&&(0,S.jsxs)(`div`,{className:`notice notice-warn`,role:`status`,children:[(0,S.jsx)(`p`,{children:w}),E&&(0,S.jsxs)(`p`,{children:[(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void k(E),children:t(c===E?`startup.copied`:`startup.copy`)}),(0,S.jsx)(`code`,{style:{marginLeft:`0.5rem`},children:E})]})]}),(0,S.jsxs)(`section`,{className:`panel startup-hero ${F}`,"aria-live":`polite`,children:[(0,S.jsx)(`div`,{className:`startup-hero-icon`,children:(0,S.jsx)(L,{})}),(0,S.jsxs)(`div`,{className:`startup-hero-copy`,children:[(0,S.jsx)(`span`,{className:`badge ${o||n.status===`at-risk`?`badge-amber`:`badge-green`}`,children:t(o?`startup.status.atRisk`:Aa[n.status])}),(0,S.jsx)(`h3`,{children:t(o?`startup.error`:ja[n.status])}),(0,S.jsx)(`p`,{children:o?t(`startup.staleData`):n.status===`at-risk`?t(xe(n)):t(`startup.safeDetail`)})]})]}),(0,S.jsxs)(`div`,{className:`startup-state-grid`,children:[(0,S.jsxs)(`section`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`label`,children:t(`startup.routing`)}),(0,S.jsx)(`div`,{className:`value`,children:t(P)})]}),(0,S.jsxs)(`section`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`label`,children:t(`startup.restartProtection`)}),(0,S.jsx)(`div`,{className:`value`,children:t(Ma[n.protection])})]}),(0,S.jsxs)(`section`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`label`,children:t(`startup.preference`)}),(0,S.jsx)(`div`,{className:`value`,children:t(n.autostartEnabled?`startup.enabled`:`startup.disabled`)})]})]}),(0,S.jsxs)(`section`,{className:`panel startup-details`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`h3`,{className:`panel-title`,children:t(`startup.details`)}),(0,S.jsx)(`span`,{className:`muted mono`,children:n.platform})]}),(0,S.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`strong`,{children:t(`startup.service`)}),(0,S.jsx)(`span`,{children:t(`startup.serviceHint`)})]}),(0,S.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,S.jsx)(Na,{ok:n.serviceViable,yes:t(`startup.viable`),no:t(n.serviceConflict?`startup.conflict`:n.serviceStale?`startup.stale`:n.serviceInstalled?`startup.unhealthy`:n.serviceSupported?`startup.notInstalled`:`startup.unsupported`)}),n.serviceSupported&&!n.serviceInstalled&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${t(`startup.service`)} - ${t(`startup.install`)}`,disabled:y!==null||o,onClick:()=>void M(`install-service`),children:t(y===`install-service`?`startup.installing`:`startup.install`)})]})]}),(0,S.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`strong`,{children:t(`startup.shim`)}),(0,S.jsx)(`span`,{children:t(`startup.shimHint`)})]}),(0,S.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,S.jsx)(Na,{ok:n.shimHealthy&&n.autostartEnabled,yes:t(n.shimCoverage===`cli-only`?`startup.cliOnly`:`startup.healthy`),no:t(n.shimInstalled?n.shimHealthy&&!n.autostartEnabled?`startup.installedDisabled`:`startup.stale`:`startup.notInstalled`)}),!n.shimInstalled&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${t(`startup.shim`)} - ${t(`startup.install`)}`,disabled:y!==null||o,onClick:()=>void M(`install-shim`),children:t(y===`install-shim`?`startup.installing`:`startup.install`)})]})]}),x&&(0,S.jsx)(`div`,{className:`notice ${x.kind===`success`?`notice-ok`:`notice-warn`} startup-action-notice`,role:`status`,"aria-live":`polite`,children:x.kind===`success`?t(x.action===`install-service`?`startup.serviceInstalled`:`startup.shimInstalled`):`${t(`startup.installFailed`)} ${x.detail??``}`})]}),n.platform===`win32`&&(0,S.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`h3`,{className:`panel-title`,children:t(`startup.tray.title`)}),(0,S.jsx)(W,{})]}),(0,S.jsx)(`p`,{className:`muted`,children:t(`startup.tray.hint`)}),(0,S.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`strong`,{children:t(`startup.tray.login`)}),(0,S.jsx)(`span`,{children:t(`startup.tray.notProtection`)})]}),f||g||!u?(0,S.jsx)(`span`,{className:`badge badge-amber`,children:t(f?`startup.tray.loading`:`startup.tray.unavailable`)}):(0,S.jsx)(Na,{ok:u.running&&!u.stale,yes:t(`startup.tray.running`),no:t(u.stale?`startup.tray.stale`:u.installed?`startup.tray.stopped`:`startup.tray.notInstalled`)})]}),(0,S.jsxs)(`div`,{className:`startup-tray-buttons`,children:[!f&&!g&&u&&!u.installed&&!u.stale&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:m,onClick:()=>void j(`install`),children:t(`startup.tray.install`)}),!f&&!g&&u?.installed&&!u.stale&&!u.running&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:m,onClick:()=>void j(`start`),children:t(`startup.tray.start`)}),!f&&!g&&u?.running&&!u.stale&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:m,onClick:()=>void j(`stop`),children:t(`startup.tray.stop`)}),!f&&!g&&u&&(u.installed||u.stale)&&(0,S.jsx)(`button`,{type:`button`,className:`btn btn-danger`,disabled:m,onClick:()=>{window.confirm(t(`startup.tray.uninstall`))&&j(`uninstall`)},children:t(`startup.tray.uninstall`)})]}),(g||u?.stale)&&(0,S.jsx)(`div`,{className:`notice notice-warn`,role:`alert`,children:t(`startup.tray.error`)})]}),(0,S.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`h3`,{className:`panel-title`,children:t(`startup.recovery`)}),(0,S.jsx)(A,{})]}),(0,S.jsx)(`p`,{className:`muted`,children:t(`startup.recoveryHint`)}),(0,S.jsxs)(`div`,{className:`startup-command-list`,children:[n.serviceSupported&&(0,S.jsxs)(`div`,{className:`startup-command-row`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`strong`,{children:t(`startup.command.service`)}),(0,S.jsx)(`code`,{children:n.commands.installService})]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void k(n.commands.installService),children:c===n.commands.installService?t(`startup.copied`):t(`startup.copy`)})]}),(0,S.jsxs)(`div`,{className:`startup-command-row`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`strong`,{children:t(`startup.command.shim`)}),(0,S.jsx)(`code`,{children:n.commands.installShim})]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void k(n.commands.installShim),children:c===n.commands.installShim?t(`startup.copied`):t(`startup.copy`)})]}),(0,S.jsxs)(`div`,{className:`startup-command-row`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`strong`,{children:t(`startup.command.native`)}),(0,S.jsx)(`code`,{children:n.commands.restoreNative})]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void k(n.commands.restoreNative),children:c===n.commands.restoreNative?t(`startup.copied`):t(`startup.copy`)})]})]}),n.status===`at-risk`&&(0,S.jsxs)(`div`,{className:`notice notice-warn startup-action-notice`,role:`alert`,children:[(0,S.jsx)(W,{}),` `,t(`startup.recommended`,{cmd:n.recommendedCommand??n.commands.installService})]})]})]}):null]})}var Fa=class extends _.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}reload=()=>{this.setState({error:null})};render(){return this.state.error?(0,S.jsxs)(`section`,{className:`card`,role:`alert`,style:{maxWidth:720,padding:`var(--space-6)`},children:[(0,S.jsxs)(`h2`,{style:{margin:`0 0 var(--space-2)`,fontSize:`var(--text-title)`},children:[this.props.pageName,`: `,this.props.title]}),(0,S.jsx)(`p`,{className:`muted`,style:{margin:`0 0 var(--space-4)`},children:this.props.message}),(0,S.jsxs)(`p`,{style:{margin:`0 0 var(--space-5)`,overflowWrap:`anywhere`},children:[(0,S.jsxs)(`strong`,{children:[this.props.detailsLabel,`:`]}),` `,this.state.error.message]}),(0,S.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:this.reload,children:this.props.reloadLabel})]}):this.props.children}},Ia=`opencodex-api-token`,La=!1,Ra=null;function za(e){try{let t=e instanceof Request?e.url:String(e);return new URL(t,window.location.href).pathname}catch{return null}}function Ba(e){let t=za(e);return!!t&&(t.startsWith(`/api/`)||t.startsWith(`/v1/`))}function Va(){try{return sessionStorage.getItem(Ia)?.trim()||null}catch{return null}}function Ha(e){try{sessionStorage.setItem(Ia,e)}catch{}}function Ua(){try{sessionStorage.removeItem(Ia)}catch{}}function Wa(e,t,n){let r=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));return r.set(`X-OpenCodex-API-Key`,n),e instanceof Request?[new Request(e,{headers:r}),t?{...t,headers:r}:void 0]:[e,{...t,headers:r}]}async function Ga(){return Ra||(Ra=Promise.resolve().then(()=>window.prompt(`OpenCodex API token`)?.trim()||null).finally(()=>{Ra=null}),Ra)}function Ka(){if(La)return;La=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{if(!Ba(t))return e(t,n);let r=Va(),[i,a]=r?Wa(t,n,r):[t,n],o=await e(i,a);if(o.status!==401)return o;r&&Ua();let s=await Ga();if(!s)return o;Ha(s);let[c,l]=Wa(t,n,s),u=await e(c,l);return u.status===401&&Ua(),u}}Ka();var qa=new Set([`dashboard`,`startup`,`providers`,`models`,`combos`,`subagents`,`logs`,`usage`,`storage`,`codex-auth`,`api`,`claude`]),Ja={dashboard:`nav.dashboard`,startup:`nav.startup`,providers:`nav.providers`,models:`nav.models`,combos:`nav.combos`,subagents:`nav.subagents`,logs:`nav.logs`,usage:`nav.usage`,storage:`nav.storage`,"codex-auth":`nav.codexAuth`,api:`nav.api`,claude:`nav.claude`};function Ya(){let e=location.hash.replace(/^#\/?/,``).split(`/`)[0];return e===`debug`?`logs`:qa.has(e)?e:`dashboard`}function Xa(e,t){return e===t||t===`providers`&&e===`providers/workspace`||t===`logs`&&e===`logs/debug`}var Za=``,Qa=`ocx-theme`,$a=`ocx-providers-view`;function eo(){try{return localStorage.getItem($a)===`workspace`?`workspace`:`classic`}catch{return`classic`}}function to(e){try{localStorage.setItem($a,e)}catch{}}function Z(){return eo()===`workspace`?`providers/workspace`:`providers`}var no=[{id:`dashboard`,tkey:`nav.dashboard`,Icon:w},{id:`providers`,tkey:`nav.providers`,Icon:T},{id:`models`,tkey:`nav.models`,Icon:E},{id:`subagents`,tkey:`nav.subagents`,Icon:D},{id:`logs`,tkey:`nav.logs`,Icon:O},{id:`usage`,tkey:`nav.usage`,Icon:j},{id:`storage`,tkey:`nav.storage`,Icon:M},{id:`codex-auth`,tkey:`nav.codexAuth`,Icon:ne},{id:`api`,tkey:`nav.api`,Icon:K},{id:`claude`,tkey:`nav.claude`,Icon:q}],ro={light:G,dark:oe,system:se},io={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function ao(e){if(!e||typeof e!=`object`||!(`version`in e))return null;let t=e.version;return typeof t==`string`&&t.length>0?t:null}function oo(){let e=localStorage.getItem(Qa);return e===`light`||e===`dark`?e:`system`}function so(){let[e,t]=(0,_.useState)(Ya),[n,r]=(0,_.useState)(oo),[i,a]=(0,_.useState)(null),{locale:o,setLocale:s}=ve(),c=Y(),[l,u]=(0,_.useState)(!1),d=(0,_.useRef)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(!1);(0,_.useEffect)(()=>{let e=()=>{let e=Ya(),n=window.location.hash.replace(/^#\/?/,``);if(u(!1),n===`debug`||n.startsWith(`debug/`)){window.location.hash=`logs/debug`;return}if(!Xa(n,e)){window.location.hash=e===`providers`?Z():e;return}if(e===`providers`){let e=eo();if(n===`providers/workspace`)to(`workspace`);else if(n===`providers`&&e===`workspace`){window.location.hash=`providers/workspace`;return}else n===`providers`&&to(`classic`)}t(e)};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,_.useEffect)(()=>{let t=window.location.hash.replace(/^#\/?/,``);if(t===`debug`||t.startsWith(`debug/`)){window.location.hash=`logs/debug`;return}if(e===`providers`){if(t===`providers/workspace`){to(`workspace`);return}let e=Z();t!==e&&(window.location.hash=e);return}Xa(t,e)||(window.location.hash=e)},[e]),(0,_.useEffect)(()=>{let e=document.documentElement;n===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(Qa)):(e.setAttribute(`data-theme`,n),localStorage.setItem(Qa,n))},[n]),(0,_.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await fetch(`${Za}/healthz`);if(!t.ok)return;let n=ao(await t.json());!e&&n&&a(n)}catch{}};t();let n=setInterval(t,3e4);return()=>{e=!0,clearInterval(n)}},[]);let m=()=>r(e=>e===`light`?`dark`:e===`dark`?`system`:`light`),h=ro[n],g=i??`2.7.39-preview.20260724`,[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(null);(0,_.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};window.addEventListener(`keydown`,e);let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{window.removeEventListener(`keydown`,e),document.body.style.overflow=t}},[l]),(0,_.useEffect)(()=>{if(l){p.current=!0;let e=setTimeout(()=>f.current?.focus(),200);return()=>clearTimeout(e)}p.current&&(p.current=!1,d.current?.focus())},[l]),(0,_.useEffect)(()=>{let e=window.matchMedia(`(min-width: 761px)`),t=()=>{e.matches&&u(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,_.useEffect)(()=>{let e=!1;return fetch(`${Za}/api/claude-code`).then(e=>e.json()).then(t=>{!e&&typeof t.enabled==`boolean`&&x(t.enabled)}).catch(()=>{}),()=>{e=!0}},[]);let C=async()=>{if(b===null)return;let e=!b;x(e);try{(await fetch(`${Za}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})})).ok||x(!e)}catch{x(!e)}},w=async()=>{if(confirm(c(`dash.stopConfirm`))){y(!0);try{await fetch(`${Za}/api/stop`,{method:`POST`})}catch{}}},T=(0,S.jsxs)(`div`,{className:`brand`,children:[(0,S.jsx)(`span`,{className:`brand-logo`,role:`img`,"aria-label":c(`app.logoAria`)}),(0,S.jsx)(`span`,{className:`name`,children:`opencodex`}),(0,S.jsxs)(`span`,{className:`ver`,children:[`v`,g]})]});return(0,S.jsxs)(`div`,{className:`app`,children:[(0,S.jsxs)(`header`,{className:`mobile-topbar`,inert:l,children:[(0,S.jsx)(`button`,{ref:d,type:`button`,className:`menu-toggle`,onClick:()=>u(e=>!e),"aria-expanded":l,"aria-controls":`app-sidebar`,"aria-label":c(l?`nav.closeMenu`:`nav.openMenu`),title:c(l?`nav.closeMenu`:`nav.openMenu`),children:(0,S.jsx)(k,{})}),T,(0,S.jsx)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:w,disabled:v,"aria-label":c(`dash.stop`),title:c(`dash.stop`),children:(0,S.jsx)(W,{})})]}),l&&(0,S.jsx)(`div`,{className:`drawer-scrim`,onClick:()=>u(!1),"aria-hidden":`true`}),(0,S.jsxs)(`aside`,{id:`app-sidebar`,className:`sidebar${l?` open`:``}`,ref:f,tabIndex:-1,children:[(0,S.jsxs)(`div`,{className:`drawer-head`,children:[T,(0,S.jsx)(`button`,{type:`button`,className:`menu-toggle drawer-close`,onClick:()=>u(!1),"aria-label":c(`nav.closeMenu`),title:c(`nav.closeMenu`),children:(0,S.jsx)(P,{})})]}),(0,S.jsx)(`nav`,{children:no.map(({id:n,tkey:r,Icon:i})=>(0,S.jsxs)(`div`,{className:`nav-entry${n===`claude`?` nav-entry-claude${e===n?` active`:``}`:``}`,children:[(0,S.jsxs)(`button`,{className:`nav-item${e===n?` active`:``}`,"data-page":n,onClick:()=>{window.location.hash=n===`providers`?Z():n,t(n),u(!1)},"aria-current":e===n?`page`:void 0,children:[(0,S.jsx)(i,{}),` `,c(r)]}),n===`claude`&&b!==null&&(0,S.jsx)(Te,{on:b,onClick:()=>void C(),label:c(`claude.toggleAria`)})]},n))}),(0,S.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,S.jsxs)(`div`,{className:`lang-toggle`,children:[(0,S.jsx)(K,{"aria-hidden":!0}),(0,S.jsx)(De,{value:o,options:pe.map(e=>({value:e.code,label:e.name})),onChange:e=>s(e),label:c(`lang.label`),placement:`right`,style:{flex:1,minWidth:0,width:`100%`}})]}),(0,S.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:m,"aria-label":`${c(`theme.label`)}: ${c(io[n])}`,title:`${c(`theme.label`)}: ${c(io[n])}`,children:[(0,S.jsx)(h,{}),` `,(0,S.jsx)(`span`,{className:`mode`,children:c(io[n])})]}),(0,S.jsxs)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:w,disabled:v,"aria-label":c(`dash.stop`),title:c(`dash.stop`),children:[(0,S.jsx)(W,{}),` `,(0,S.jsx)(`span`,{className:`mode`,children:c(v?`dash.stopping`:`dash.stop`)})]}),(0,S.jsxs)(`a`,{className:`sidebar-link`,href:`https://github.com/lidge-jun/opencodex`,target:`_blank`,rel:`noreferrer`,children:[(0,S.jsx)(U,{}),` `,c(`common.github`)]})]})]}),(0,S.jsx)(`main`,{className:`main`,inert:l,children:(0,S.jsx)(`div`,{className:`main-inner${e===`combos`?` main-inner--combos`:``}`,children:(0,S.jsxs)(Fa,{pageName:c(Ja[e]),title:c(`errorBoundary.title`),message:c(`errorBoundary.message`),detailsLabel:c(`errorBoundary.details`),reloadLabel:c(`errorBoundary.reload`),children:[e===`dashboard`&&(0,S.jsx)(Ve,{apiBase:Za}),e===`startup`&&(0,S.jsx)(Pa,{apiBase:Za}),e===`providers`&&(0,S.jsx)(Kn,{apiBase:Za}),e===`models`&&(0,S.jsx)(Or,{apiBase:Za}),e===`combos`&&(0,S.jsx)(Gr,{apiBase:Za}),e===`subagents`&&(0,S.jsx)(Kr,{apiBase:Za}),e===`logs`&&(0,S.jsx)(Ki,{apiBase:Za}),e===`usage`&&(0,S.jsx)(la,{apiBase:Za}),e===`storage`&&(0,S.jsx)(ga,{apiBase:Za}),e===`codex-auth`&&(0,S.jsx)(va,{apiBase:Za}),e===`api`&&(0,S.jsx)(ba,{apiBase:Za}),e===`claude`&&(0,S.jsx)(Oa,{apiBase:Za})]},e)})})]})}v.createRoot(document.getElementById(`root`)).render((0,S.jsx)(_.StrictMode,{children:(0,S.jsx)(ye,{children:(0,S.jsx)(so,{})})}));
@@ -16,7 +16,7 @@
16
16
  } catch (e) {}
17
17
  })();
18
18
  </script>
19
- <script type="module" crossorigin src="/assets/index-BhUTxmCy.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-dfIJJHvq.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-oOZcqVmj.css">
21
21
  </head>
22
22
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitkyc08/opencodex",
3
- "version": "2.7.37",
3
+ "version": "2.7.39-preview.20260724",
4
4
  "description": "Universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code",
5
5
  "type": "module",
6
6
  "main": "./bin/package-main.mjs",