@bitkyc08/opencodex 2.7.36-preview.20260723 → 2.7.36
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 ba(e){let t=e.autoConnectSupported===!0;return{autoConnectSupported:t,systemEnv:t&&e.systemEnv===!0}}var xa=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`];function Sa(e){let t=`http://127.0.0.1:${e.port}`,n=e.autoContext&&e.maxContextTokens===null,r=xa.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 Ca(e){return e>=1e6?`1M`:`${Math.round(e/1e3)}k`}function wa({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 Ta({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)(wa,{label:r(`claude.systemEnv`),checked:e&&t,disabled:!e,describedBy:i,onChange:n})]})}function Ea({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`,...ba(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.slotUnset`)},...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:Ca(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=Sa(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)(wa,{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)(Ta,{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)(wa,{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)(wa,{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)(`div`,{className:`h-section`,children:t(`claude.smallFastModel`)}),(0,S.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:t(`claude.smallFastModelHint`)}),(0,S.jsx)(De,{value:n.smallFastModel,options:p,onChange:e=>r({...n,smallFastModel:e}),label:t(`claude.smallFastModel`),style:{maxWidth:420}}),(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 Da(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 Oa={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},ka={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},Aa={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function ja({ok:e,yes:t,no:n}){return(0,S.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function Ma({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=(0,_.useCallback)(async t=>{a(!0),p(!0);try{let n=await fetch(`${e}/api/startup-health`,{signal:t});if(!n.ok)throw Error(`fetch failed`);let i=await n.json();if(t?.aborted)return;if(r(i),s(i.diagnosticStale),i.platform===`win32`){v(!1);try{let n=await fetch(`${e}/api/windows-tray`,{signal:t});if(!n.ok)throw Error(`tray status failed`);let r=await n.json();if(!Da(r))throw Error(`invalid tray status`);t?.aborted||(d(r),v(!1))}catch{t?.aborted||(d(null),v(!0))}finally{t?.aborted||p(!1)}}else p(!1)}catch{if(t?.aborted)return;s(!0),d(null),v(!0),p(!1)}finally{t?.aborted||a(!1)}},[e]);(0,_.useEffect)(()=>{let e=new AbortController,t=window.setTimeout(()=>{w(e.signal)},0);return()=>{window.clearTimeout(t),e.abort()}},[w]),(0,_.useEffect)(()=>{if(!n?.diagnosticStale)return;let e=window.setTimeout(()=>{w()},2e3);return()=>window.clearTimeout(e)},[n,w]);let T=async e=>{try{await navigator.clipboard.writeText(e),l(e),window.setTimeout(()=>l(t=>t===e?null:t),1600)}catch{l(null)}},E=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(!Da(r.status))throw Error(`invalid tray action status`);d(r.status),v(!1)}catch{d(null),v(!0)}finally{h(!1)}},D=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 w()}catch(e){C({kind:`error`,action:t,detail:e instanceof Error?e.message:String(e)})}finally{b(null)}},O=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`,k=o?`startup-hero--risk`:n?.status===`protected`?`startup-hero--safe`:n?.status===`at-risk`?`startup-hero--risk`:`startup-hero--native`,j=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 w(),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`)}),(0,S.jsxs)(`section`,{className:`panel startup-hero ${k}`,"aria-live":`polite`,children:[(0,S.jsx)(`div`,{className:`startup-hero-icon`,children:(0,S.jsx)(j,{})}),(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`:Oa[n.status])}),(0,S.jsx)(`h3`,{children:t(o?`startup.error`:ka[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(O)})]}),(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(Aa[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)(ja,{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 D(`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)(ja,{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 D(`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)(ja,{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 E(`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 E(`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 E(`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`))&&E(`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 T(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 T(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 T(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 Na=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}},Pa=`opencodex-api-token`,Fa=!1,Ia=null;function La(e){try{let t=e instanceof Request?e.url:String(e);return new URL(t,window.location.href).pathname}catch{return null}}function Ra(e){let t=La(e);return!!t&&(t.startsWith(`/api/`)||t.startsWith(`/v1/`))}function za(){try{return sessionStorage.getItem(Pa)?.trim()||null}catch{return null}}function Ba(e){try{sessionStorage.setItem(Pa,e)}catch{}}function Va(){try{sessionStorage.removeItem(Pa)}catch{}}function Ha(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 Ua(){return Ia||(Ia=Promise.resolve().then(()=>window.prompt(`OpenCodex API token`)?.trim()||null).finally(()=>{Ia=null}),Ia)}function Wa(){if(Fa)return;Fa=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{if(!Ra(t))return e(t,n);let r=za(),[i,a]=r?Ha(t,n,r):[t,n],o=await e(i,a);if(o.status!==401)return o;r&&Va();let s=await Ua();if(!s)return o;Ba(s);let[c,l]=Ha(t,n,s),u=await e(c,l);return u.status===401&&Va(),u}}Wa();var Ga=new Set([`dashboard`,`startup`,`providers`,`models`,`combos`,`subagents`,`logs`,`usage`,`storage`,`codex-auth`,`api`,`claude`]),Ka={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 qa(){let e=location.hash.replace(/^#\/?/,``).split(`/`)[0];return e===`debug`?`logs`:Ga.has(e)?e:`dashboard`}function Ja(e,t){return e===t||t===`providers`&&e===`providers/workspace`||t===`logs`&&e===`logs/debug`}var Ya=``,Xa=`ocx-theme`,Za=`ocx-providers-view`;function Qa(){try{return localStorage.getItem(Za)===`workspace`?`workspace`:`classic`}catch{return`classic`}}function $a(e){try{localStorage.setItem(Za,e)}catch{}}function eo(){return Qa()===`workspace`?`providers/workspace`:`providers`}var to=[{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}],Z={light:G,dark:oe,system:se},no={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function ro(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 io(){let e=localStorage.getItem(Xa);return e===`light`||e===`dark`?e:`system`}function ao(){let[e,t]=(0,_.useState)(qa),[n,r]=(0,_.useState)(io),[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=qa(),n=window.location.hash.replace(/^#\/?/,``);if(u(!1),n===`debug`||n.startsWith(`debug/`)){window.location.hash=`logs/debug`;return}if(!Ja(n,e)){window.location.hash=e===`providers`?eo():e;return}if(e===`providers`){let e=Qa();if(n===`providers/workspace`)$a(`workspace`);else if(n===`providers`&&e===`workspace`){window.location.hash=`providers/workspace`;return}else n===`providers`&&$a(`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`){$a(`workspace`);return}let e=eo();t!==e&&(window.location.hash=e);return}Ja(t,e)||(window.location.hash=e)},[e]),(0,_.useEffect)(()=>{let e=document.documentElement;n===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(Xa)):(e.setAttribute(`data-theme`,n),localStorage.setItem(Xa,n))},[n]),(0,_.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await fetch(`${Ya}/healthz`);if(!t.ok)return;let n=ro(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=Z[n],g=i??`2.7.36-preview.20260723`,[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(`${Ya}/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(`${Ya}/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(`${Ya}/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:to.map(({id:n,tkey:r,Icon:i})=>(0,S.jsxs)(`button`,{className:`nav-item${e===n?` active`:``}`,"data-page":n,onClick:()=>{window.location.hash=n===`providers`?eo():n,t(n),u(!1)},"aria-current":e===n?`page`:void 0,children:[(0,S.jsx)(i,{}),` `,c(r)]},n))}),(0,S.jsxs)(`div`,{className:`sidebar-foot`,children:[b!==null&&(0,S.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:C,"aria-pressed":b,"aria-label":c(`claude.toggleAria`),title:c(`claude.toggleAria`),style:b?{color:`var(--accent)`}:void 0,children:[(0,S.jsx)(q,{}),` `,(0,S.jsx)(`span`,{className:`mode`,children:c(b?`app.claudeOn`:`app.claudeOff`)})]}),(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(no[n])}`,title:`${c(`theme.label`)}: ${c(no[n])}`,children:[(0,S.jsx)(h,{}),` `,(0,S.jsx)(`span`,{className:`mode`,children:c(no[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)(Na,{pageName:c(Ka[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:Ya}),e===`startup`&&(0,S.jsx)(Ma,{apiBase:Ya}),e===`providers`&&(0,S.jsx)(Kn,{apiBase:Ya}),e===`models`&&(0,S.jsx)(Or,{apiBase:Ya}),e===`combos`&&(0,S.jsx)(Wr,{apiBase:Ya}),e===`subagents`&&(0,S.jsx)(Gr,{apiBase:Ya}),e===`logs`&&(0,S.jsx)(Gi,{apiBase:Ya}),e===`usage`&&(0,S.jsx)(ca,{apiBase:Ya}),e===`storage`&&(0,S.jsx)(ha,{apiBase:Ya}),e===`codex-auth`&&(0,S.jsx)(_a,{apiBase:Ya}),e===`api`&&(0,S.jsx)(ya,{apiBase:Ya}),e===`claude`&&(0,S.jsx)(Ea,{apiBase:Ya})]},e)})})]})}v.createRoot(document.getElementById(`root`)).render((0,S.jsx)(_.StrictMode,{children:(0,S.jsx)(ye,{children:(0,S.jsx)(ao,{})})}));
|
|
52
|
+
`)}function Ca(e){return e>=1e6?`1M`:`${Math.round(e/1e3)}k`}function wa({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 Ta({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)(wa,{label:r(`claude.systemEnv`),checked:e&&t,disabled:!e,describedBy:i,onChange:n})]})}function Ea({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`,...ba(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.slotUnset`)},...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:Ca(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=Sa(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)(wa,{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)(Ta,{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)(wa,{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)(wa,{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)(`div`,{className:`h-section`,children:t(`claude.smallFastModel`)}),(0,S.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:t(`claude.smallFastModelHint`)}),(0,S.jsx)(De,{value:n.smallFastModel,options:p,onChange:e=>r({...n,smallFastModel:e}),label:t(`claude.smallFastModel`),style:{maxWidth:420}}),(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 Da(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 Oa={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},ka={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},Aa={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function ja({ok:e,yes:t,no:n}){return(0,S.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function Ma({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=(0,_.useCallback)(async t=>{a(!0),p(!0);try{let n=await fetch(`${e}/api/startup-health`,{signal:t});if(!n.ok)throw Error(`fetch failed`);let i=await n.json();if(t?.aborted)return;if(r(i),s(i.diagnosticStale),i.platform===`win32`){v(!1);try{let n=await fetch(`${e}/api/windows-tray`,{signal:t});if(!n.ok)throw Error(`tray status failed`);let r=await n.json();if(!Da(r))throw Error(`invalid tray status`);t?.aborted||(d(r),v(!1))}catch{t?.aborted||(d(null),v(!0))}finally{t?.aborted||p(!1)}}else p(!1)}catch{if(t?.aborted)return;s(!0),d(null),v(!0),p(!1)}finally{t?.aborted||a(!1)}},[e]);(0,_.useEffect)(()=>{let e=new AbortController,t=window.setTimeout(()=>{w(e.signal)},0);return()=>{window.clearTimeout(t),e.abort()}},[w]),(0,_.useEffect)(()=>{if(!n?.diagnosticStale)return;let e=window.setTimeout(()=>{w()},2e3);return()=>window.clearTimeout(e)},[n,w]);let T=async e=>{try{await navigator.clipboard.writeText(e),l(e),window.setTimeout(()=>l(t=>t===e?null:t),1600)}catch{l(null)}},E=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(!Da(r.status))throw Error(`invalid tray action status`);d(r.status),v(!1)}catch{d(null),v(!0)}finally{h(!1)}},D=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 w()}catch(e){C({kind:`error`,action:t,detail:e instanceof Error?e.message:String(e)})}finally{b(null)}},O=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`,k=o?`startup-hero--risk`:n?.status===`protected`?`startup-hero--safe`:n?.status===`at-risk`?`startup-hero--risk`:`startup-hero--native`,j=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 w(),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`)}),(0,S.jsxs)(`section`,{className:`panel startup-hero ${k}`,"aria-live":`polite`,children:[(0,S.jsx)(`div`,{className:`startup-hero-icon`,children:(0,S.jsx)(j,{})}),(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`:Oa[n.status])}),(0,S.jsx)(`h3`,{children:t(o?`startup.error`:ka[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(O)})]}),(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(Aa[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)(ja,{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 D(`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)(ja,{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 D(`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)(ja,{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 E(`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 E(`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 E(`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`))&&E(`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 T(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 T(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 T(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 Na=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}},Pa=`opencodex-api-token`,Fa=!1,Ia=null;function La(e){try{let t=e instanceof Request?e.url:String(e);return new URL(t,window.location.href).pathname}catch{return null}}function Ra(e){let t=La(e);return!!t&&(t.startsWith(`/api/`)||t.startsWith(`/v1/`))}function za(){try{return sessionStorage.getItem(Pa)?.trim()||null}catch{return null}}function Ba(e){try{sessionStorage.setItem(Pa,e)}catch{}}function Va(){try{sessionStorage.removeItem(Pa)}catch{}}function Ha(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 Ua(){return Ia||(Ia=Promise.resolve().then(()=>window.prompt(`OpenCodex API token`)?.trim()||null).finally(()=>{Ia=null}),Ia)}function Wa(){if(Fa)return;Fa=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{if(!Ra(t))return e(t,n);let r=za(),[i,a]=r?Ha(t,n,r):[t,n],o=await e(i,a);if(o.status!==401)return o;r&&Va();let s=await Ua();if(!s)return o;Ba(s);let[c,l]=Ha(t,n,s),u=await e(c,l);return u.status===401&&Va(),u}}Wa();var Ga=new Set([`dashboard`,`startup`,`providers`,`models`,`combos`,`subagents`,`logs`,`usage`,`storage`,`codex-auth`,`api`,`claude`]),Ka={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 qa(){let e=location.hash.replace(/^#\/?/,``).split(`/`)[0];return e===`debug`?`logs`:Ga.has(e)?e:`dashboard`}function Ja(e,t){return e===t||t===`providers`&&e===`providers/workspace`||t===`logs`&&e===`logs/debug`}var Ya=``,Xa=`ocx-theme`,Za=`ocx-providers-view`;function Qa(){try{return localStorage.getItem(Za)===`workspace`?`workspace`:`classic`}catch{return`classic`}}function $a(e){try{localStorage.setItem(Za,e)}catch{}}function eo(){return Qa()===`workspace`?`providers/workspace`:`providers`}var to=[{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}],Z={light:G,dark:oe,system:se},no={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function ro(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 io(){let e=localStorage.getItem(Xa);return e===`light`||e===`dark`?e:`system`}function ao(){let[e,t]=(0,_.useState)(qa),[n,r]=(0,_.useState)(io),[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=qa(),n=window.location.hash.replace(/^#\/?/,``);if(u(!1),n===`debug`||n.startsWith(`debug/`)){window.location.hash=`logs/debug`;return}if(!Ja(n,e)){window.location.hash=e===`providers`?eo():e;return}if(e===`providers`){let e=Qa();if(n===`providers/workspace`)$a(`workspace`);else if(n===`providers`&&e===`workspace`){window.location.hash=`providers/workspace`;return}else n===`providers`&&$a(`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`){$a(`workspace`);return}let e=eo();t!==e&&(window.location.hash=e);return}Ja(t,e)||(window.location.hash=e)},[e]),(0,_.useEffect)(()=>{let e=document.documentElement;n===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(Xa)):(e.setAttribute(`data-theme`,n),localStorage.setItem(Xa,n))},[n]),(0,_.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await fetch(`${Ya}/healthz`);if(!t.ok)return;let n=ro(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=Z[n],g=i??`2.7.36`,[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(`${Ya}/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(`${Ya}/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(`${Ya}/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:to.map(({id:n,tkey:r,Icon:i})=>(0,S.jsxs)(`button`,{className:`nav-item${e===n?` active`:``}`,"data-page":n,onClick:()=>{window.location.hash=n===`providers`?eo():n,t(n),u(!1)},"aria-current":e===n?`page`:void 0,children:[(0,S.jsx)(i,{}),` `,c(r)]},n))}),(0,S.jsxs)(`div`,{className:`sidebar-foot`,children:[b!==null&&(0,S.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:C,"aria-pressed":b,"aria-label":c(`claude.toggleAria`),title:c(`claude.toggleAria`),style:b?{color:`var(--accent)`}:void 0,children:[(0,S.jsx)(q,{}),` `,(0,S.jsx)(`span`,{className:`mode`,children:c(b?`app.claudeOn`:`app.claudeOff`)})]}),(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(no[n])}`,title:`${c(`theme.label`)}: ${c(no[n])}`,children:[(0,S.jsx)(h,{}),` `,(0,S.jsx)(`span`,{className:`mode`,children:c(no[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)(Na,{pageName:c(Ka[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:Ya}),e===`startup`&&(0,S.jsx)(Ma,{apiBase:Ya}),e===`providers`&&(0,S.jsx)(Kn,{apiBase:Ya}),e===`models`&&(0,S.jsx)(Or,{apiBase:Ya}),e===`combos`&&(0,S.jsx)(Wr,{apiBase:Ya}),e===`subagents`&&(0,S.jsx)(Gr,{apiBase:Ya}),e===`logs`&&(0,S.jsx)(Gi,{apiBase:Ya}),e===`usage`&&(0,S.jsx)(ca,{apiBase:Ya}),e===`storage`&&(0,S.jsx)(ha,{apiBase:Ya}),e===`codex-auth`&&(0,S.jsx)(_a,{apiBase:Ya}),e===`api`&&(0,S.jsx)(ya,{apiBase:Ya}),e===`claude`&&(0,S.jsx)(Ea,{apiBase:Ya})]},e)})})]})}v.createRoot(document.getElementById(`root`)).render((0,S.jsx)(_.StrictMode,{children:(0,S.jsx)(ye,{children:(0,S.jsx)(ao,{})})}));
|
package/gui/dist/index.html
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
} catch (e) {}
|
|
17
17
|
})();
|
|
18
18
|
</script>
|
|
19
|
-
<script type="module" crossorigin src="/assets/index-
|
|
19
|
+
<script type="module" crossorigin src="/assets/index-ZmFopEYw.js"></script>
|
|
20
20
|
<link rel="stylesheet" crossorigin href="/assets/index-BpX-hoSd.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.36
|
|
3
|
+
"version": "2.7.36",
|
|
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",
|