@bitkyc08/opencodex 2.14.2 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gui/dist/assets/{index-DUyQeU1j.js → index-B5T5ADgY.js} +1 -1
- package/gui/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/adapters/cursor/effort-map.ts +4 -5
- package/src/adapters/cursor/request-builder.ts +1 -1
- package/src/generated/compatibility-version.json +10 -10
- package/src/generated/model-metadata.ts +1 -1
- package/src/oauth/index.ts +3 -0
- package/src/providers/antigravity-models.ts +93 -28
- package/src/providers/model-rename-migration.ts +54 -1
- package/src/providers/registry.ts +1 -1
- package/src/usage/expected-prices.ts +13 -0
|
@@ -73,4 +73,4 @@ default_mode_request_user_input = true`})]}),(0,z.jsxs)(`div`,{className:`codex-
|
|
|
73
73
|
}'`;return(0,z.jsxs)(`section`,{className:`panel api-panel awi-usage-panel`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:n(`api.workspace.usageExamples`)}),(0,z.jsxs)(`div`,{className:`awi-usage-panel-body`,children:[(0,z.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,z.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageChatTitle`)}),(0,z.jsx)(om,{text:i})]}),(0,z.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,z.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageResponsesTitle`)}),(0,z.jsx)(om,{text:a})]}),t&&(0,z.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,z.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageMessagesTitle`)}),(0,z.jsx)(om,{text:o})]})]})]})}var fm=[`opencode`,`pi`,`omp`,`hermes`,`openclaw`,`kimi`,`gajae`],pm={opencode:`api.clientConfig.clientOpencode`,pi:`api.clientConfig.clientPi`,omp:`api.clientConfig.clientOmp`,hermes:`api.clientConfig.clientHermes`,openclaw:`api.clientConfig.clientOpenclaw`,kimi:`api.clientConfig.clientKimi`,gajae:`api.clientConfig.clientGajae`},mm={opencode:`/provider-icons/opencode.svg`,pi:`/provider-icons/pi.svg`};function hm({client:e,apiBase:t,onOpenDetails:n,onCopy:r,onDownload:i}){let a=Z(),[o,s]=(0,_.useState)(0),c=[t,e,String(o)].join(`|`),[l,u]=(0,_.useState)(null);(0,_.useEffect)(()=>{let n=new AbortController,r=!1;return(async()=>{try{let i=await fetch(`${t}/api/client-config?client=${encodeURIComponent(e)}`,{signal:n.signal});if(!i.ok)throw Error(String(i.status));let a=await i.json();if(r)return;u({key:c,data:a,failed:!1})}catch{if(r)return;u({key:c,data:null,failed:!0})}})(),()=>{r=!0,n.abort()}},[t,e,c]);let d=l!==null&&l.key===c?l:null,f=d?.data??null,p=d?.failed??!1,m=d===null,h=a(pm[e]),g=mm[e],v=f?.text??``,y=(0,_.useCallback)(t=>{f&&n(e,f,v,t.currentTarget)},[e,f,v,n]);return(0,z.jsxs)(`li`,{className:`awi-clientconfig-row`,children:[(0,z.jsx)(`span`,{className:`awi-clientconfig-mark`,"aria-hidden":`true`,children:g?(0,z.jsx)(`img`,{src:g,alt:``,width:20,height:20}):(0,z.jsx)(`span`,{className:`awi-clientconfig-monogram`,children:h.slice(0,1)})}),(0,z.jsxs)(`span`,{className:`awi-clientconfig-identity`,children:[(0,z.jsx)(`span`,{className:`awi-clientconfig-name`,children:h}),(0,z.jsx)(`span`,{className:`muted text-label awi-clientconfig-meta`,children:m?a(`api.clientConfig.loading`):p||!f?(0,z.jsx)(`span`,{role:`alert`,children:a(`api.clientConfig.rowError`,{client:h})}):a(`api.clientConfig.rowMeta`,{destination:f.destination,count:f.modelCount})})]}),(0,z.jsx)(`span`,{className:`awi-clientconfig-row-actions`,children:p&&!m?(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>s(e=>e+1),children:a(`common.retry`)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":a(`api.clientConfig.copyAria`,{client:h}),disabled:!f,onClick:()=>{f&&r(e,v)},children:a(`api.clientConfig.copy`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,"aria-label":a(`api.clientConfig.downloadAria`,{client:h}),disabled:!f,onClick:()=>{f&&i(e,f,v)},children:a(`api.clientConfig.download`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"aria-label":a(`api.clientConfig.detailsAria`,{client:h}),disabled:!f,onClick:y,children:a(`api.clientConfig.details`)})]})})]})}function gm({client:e,envelope:t,json:n,hasKeys:r,onClose:i,onCopy:a,onDownload:o}){let s=Z(),c=(0,_.useRef)(null),l=`awi-clientconfig-dialog-${e}`;(0,_.useEffect)(()=>{let e=c.current;return e&&!e.open&&e.showModal(),()=>{e?.open&&e.close()}},[]);let u=(0,_.useCallback)(e=>{e.preventDefault(),i()},[i]);return(0,z.jsxs)(`dialog`,{ref:c,className:`modal-overlay`,"aria-labelledby":l,onCancel:u,children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":s(`common.close`),tabIndex:-1,onClick:i}),(0,z.jsxs)(`div`,{className:`modal-card awi-clientconfig-dialog`,onClick:e=>e.stopPropagation(),role:`document`,children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{id:l,children:s(pm[e])}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:i,children:s(`common.close`)})]}),(0,z.jsx)(`pre`,{className:`api-code api-example-pre awi-clientconfig-json`,tabIndex:0,role:`group`,"aria-label":s(`api.clientConfig.jsonLabel`,{client:s(pm[e])}),children:n}),(0,z.jsx)(`p`,{className:`muted small awi-clientconfig-count`,children:s(`api.clientConfig.modelCount`,{count:t.modelCount})}),t.modelsWithoutLimits>0&&(0,z.jsx)(`p`,{className:`muted small awi-clientconfig-degraded`,children:s(`api.clientConfig.missingLimits`,{count:t.modelsWithoutLimits,total:t.modelCount})}),!r&&(0,z.jsx)(`p`,{className:`muted small awi-clientconfig-nokey`,children:s(`api.clientConfig.noKeyYet`,{env:t.apiKeyEnv})}),(0,z.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,z.jsx)(`span`,{className:`muted text-label`,children:s(`api.clientConfig.destination`)}),(0,z.jsx)(om,{text:t.destination})]}),(0,z.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,z.jsx)(`span`,{className:`muted text-label`,children:s(`api.clientConfig.envHint`)}),(0,z.jsx)(om,{text:t.exportHint})]}),(0,z.jsx)(`p`,{className:`muted small awi-clientconfig-merge`,children:s(`api.clientConfig.mergeWarning`)}),(0,z.jsx)(`p`,{className:`muted text-label awi-clientconfig-where-title`,children:s(`api.clientConfig.whereDisclosure`)}),(0,z.jsx)(`p`,{className:`muted small`,children:s(`api.clientConfig.whereBody`)}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:a,children:s(`api.clientConfig.copy`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:o,children:s(`api.clientConfig.download`)})]})]})]})}function _m({apiBase:e,baseUrl:t,hasKeys:n}){let r=Z(),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(``),c=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(i!==null)return;let e=c.current;e&&(c.current=null,e.isConnected&&e.focus())},[i]);let l=(0,_.useCallback)(async(e,t,n)=>{try{await navigator.clipboard.writeText(t),s(n?r(`api.clientConfig.copiedAnnounceClient`,{client:r(pm[e])}):r(`api.clientConfig.copiedAnnounce`))}catch{s(r(`api.clientConfig.copyFailed`))}},[r]),u=(0,_.useCallback)((e,t,n)=>{let i=URL.createObjectURL(new Blob([n],{type:t.mediaType})),a=document.createElement(`a`);a.href=i,a.download=t.filename,a.click(),URL.revokeObjectURL(i),s(r(`api.clientConfig.downloadedAnnounce`,{filename:t.filename,destination:t.destination}))},[r]),d=(0,_.useCallback)(()=>a(null),[]),f=(0,_.useCallback)((e,t,n,r)=>{c.current=r,a({client:e,envelope:t,json:n})},[]);return(0,z.jsxs)(`section`,{className:`panel api-panel awi-clientconfig-panel`,children:[(0,z.jsx)(`div`,{className:`api-panel-head awi-clientconfig-head`,children:(0,z.jsx)(`h3`,{className:`panel-title`,children:r(`api.clientConfig.title`)})}),(0,z.jsx)(`ul`,{className:`awi-clientconfig-rows`,"aria-label":r(`api.clientConfig.rowsLabel`),children:fm.map(t=>(0,z.jsx)(hm,{client:t,apiBase:e,onOpenDetails:f,onCopy:(e,t)=>{l(e,t,!0)},onDownload:u},t))}),(0,z.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,z.jsx)(`span`,{className:`muted text-label`,children:r(`api.baseUrl`)}),(0,z.jsx)(om,{text:t})]}),(0,z.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:o}),i&&(0,z.jsx)(gm,{client:i.client,envelope:i.envelope,json:i.json,hasKeys:n,onClose:d,onCopy:()=>{l(i.client,i.json,!1)},onDownload:()=>u(i.client,i.envelope,i.json)})]})}function vm({keys:e,keysLoading:t,keysLoadFailed:n,attributionSince:r,localeTag:i,busy:a,onSelect:o}){let s=Z();return(0,z.jsxs)(`div`,{className:`panel api-panel awi-keylist-panel`,"aria-busy":t,children:[(0,z.jsx)(`div`,{className:`api-panel-head`,children:(0,z.jsx)(`h3`,{className:`panel-title`,children:t?s(`api.activeKeysLoading`):s(`api.activeKeys`,{count:e.length})})}),t?(0,z.jsx)(`div`,{className:`api-active-keys-skeleton`,role:`status`,"aria-label":s(`common.loading`)}):e.length===0?(0,z.jsx)(`p`,{className:`muted small`,children:s(n?`api.keysLoadFailed`:`api.noKeys`)}):(0,z.jsx)(`div`,{className:`tbl-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl awi-keylist-table`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:s(`api.colName`)}),(0,z.jsx)(`th`,{children:s(`api.colKey`)}),(0,z.jsx)(`th`,{children:s(`api.attribution.requests7d`)}),(0,z.jsx)(`th`,{children:s(`api.attribution.lastUsed`)})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{children:(0,z.jsx)(`button`,{type:`button`,className:`awi-keylist-name`,disabled:a,onClick:()=>o(e.id),children:e.name})}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`code`,{children:e.prefix})}),(0,z.jsx)(`td`,{children:r?e.usage.ambiguous?s(`api.attribution.railAmbiguous`):e.usage.requests7d.toLocaleString(i):s(`api.attribution.unavailable`)}),(0,z.jsx)(`td`,{children:!r||e.usage.ambiguous?`—`:e.usage.lastUsedAt?rm(e.usage.lastUsedAt,i):s(`api.attribution.neverUsed`)})]},e.id))})]})})]})}function ym({keys:e,apiBase:t,attributionSince:n,historyTruncated:r,authMatrix:i,keysLoading:a,keysLoadFailed:o,endpoints:s,claudeCodeEnabled:c,localeTag:l,newName:u,creating:d,newKey:f,copied:p,filteredModels:m,modelsLoading:h,modelsRefreshing:g=!1,modelsLoadFailed:v,modelCount:y,hasModelData:b,modelQuery:x,copiedModelId:S,modelTests:C,canTestModels:w,onNewNameChange:T,onCreate:E,onDismissNewKey:D,onCopyKey:O,onDelete:k,onRename:A,onModelQueryChange:j,onCopyModelId:M,onTestModel:N,onRetryModels:P,sourceLabel:F,protocolLabel:I}){let L=Z(),[R,B]=(0,_.useState)(null),[V,H]=(0,_.useState)(!1),[U,W]=(0,_.useState)(!1),[G,ee]=(0,_.useState)(!1),[te,ne]=(0,_.useState)(!1),[K,q]=(0,_.useState)(``),[J,re]=(0,_.useState)(!1),[Y,ie]=(0,_.useState)(!1),[ae,se]=(0,_.useState)(!1),ce=R?e.find(e=>e.id===R)??null:null,le=G||J,ue=(0,_.useMemo)(()=>[{id:`keys`,label:L(`api.section.keys`),meta:a?void 0:String(e.length)},{id:`connect`,label:L(`api.section.connect`)},{id:`endpoints`,label:L(`api.section.endpoints`)},{id:`models`,label:L(`api.section.models`),meta:String(y)},{id:`examples`,label:L(`api.section.examples`)}],[L,e.length,a,y]),de=()=>{H(!1),W(!1)},fe=()=>{B(null),de(),ne(!1),ie(!1),se(!1)};(0,_.useEffect)(()=>{if(!V)return;let e=window.setTimeout(()=>W(!0),300);return()=>window.clearTimeout(e)},[V]);let me=()=>{ce&&H(!0)},X=async()=>{if(!(!ce||!U||G)){ee(!0),se(!1);try{await k(ce.id)?(de(),B(null)):se(!0)}finally{ee(!1)}}},he=()=>{ce&&(q(ce.name),ie(!1),ne(!0))},ge=async()=>{if(!ce||J)return;let e=K.trim();if(!e||e===ce.name){ne(!1);return}re(!0),ie(!1);try{await A(ce.id,e)?ne(!1):ie(!0)}finally{re(!1)}};return(0,z.jsxs)(`div`,{className:`apikeys-workspace-shell`,children:[!ce&&(0,z.jsx)(Cd,{scope:`api`,items:ue,ariaLabel:L(`api.workspace.sections`)}),(0,z.jsx)(`div`,{className:`apikeys-workspace-root`,children:(0,z.jsx)(`section`,{className:`apikeys-workspace-main`,"aria-label":L(`api.workspace.details`),children:ce?(0,z.jsxs)(`div`,{className:`awi-detail`,children:[(0,z.jsx)(`div`,{className:`awi-detail-toolbar`,children:(0,z.jsxs)(`button`,{type:`button`,className:`awi-back`,onClick:fe,disabled:le,children:[(0,z.jsx)(pe,{className:`awi-back-chevron`,"aria-hidden":`true`}),L(`modal.back`)]})}),(0,z.jsxs)(`div`,{className:`awi-detail-body`,children:[(0,z.jsxs)(`div`,{className:`awi-detail-head`,children:[(0,z.jsx)(`h2`,{className:`awi-detail-title`,children:ce.name}),(0,z.jsx)(`span`,{className:`awi-detail-actions`,children:V?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm awi-confirm-delete`,onClick:()=>{X()},disabled:!U||G,children:[(0,z.jsx)(oe,{}),` `,L(G?`api.key.deleting`:`api.confirm`)]},`confirm-delete`),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:de,disabled:G,children:L(`common.cancel`)})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:he,disabled:te,children:L(`api.key.rename`)},`rename`),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,onClick:me,"aria-label":L(`api.deleteAria`),children:[(0,z.jsx)(oe,{}),` `,L(`api.workspace.deleteKey`)]},`request-delete`)]})})]}),V&&(0,z.jsx)(`p`,{className:`muted awi-delete-hint`,children:L(`api.workspace.deleteConfirm`)}),ae&&(0,z.jsx)(`p`,{className:`awi-delete-error`,role:`alert`,children:L(`api.deleteFailed`)}),te&&(0,z.jsxs)(`div`,{className:`awi-rename`,children:[(0,z.jsx)(`label`,{className:`awi-rename-label`,htmlFor:`awi-key-name`,children:L(`api.key.name`)}),(0,z.jsx)(`input`,{id:`awi-key-name`,className:`input`,type:`text`,value:K,maxLength:64,disabled:J,onChange:e=>q(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ge())}}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>{ge()},disabled:J,children:L(J?`api.key.renaming`:`api.key.saveName`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>ne(!1),disabled:J,children:L(`common.cancel`)}),Y&&(0,z.jsx)(`p`,{className:`awi-rename-error`,role:`alert`,children:L(`api.key.renameFailed`)})]}),(0,z.jsxs)(`div`,{className:`awi-section`,children:[(0,z.jsx)(`h3`,{className:`awi-section-title`,children:L(`api.workspace.keyDetails`)}),(0,z.jsxs)(`dl`,{className:`awi-kv`,children:[(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(`api.workspace.keyPrefix`)}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:ce.prefix})})]}),(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(`api.colCreated`)}),(0,z.jsx)(`dd`,{children:rm(ce.createdAt,l)})]})]})]}),(0,z.jsxs)(`div`,{className:`awi-section`,children:[(0,z.jsx)(`h3`,{className:`awi-section-title`,children:L(`api.attribution.title`)}),n?ce.usage.ambiguous?(0,z.jsx)(`p`,{className:`muted`,children:L(`api.attribution.ambiguous`)}):(0,z.jsxs)(`dl`,{className:`awi-kv`,children:[(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(`api.attribution.requests7d`)}),(0,z.jsx)(`dd`,{children:ce.usage.requests7d.toLocaleString(l)})]}),(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(r?`api.attribution.totalRequestsAvailable`:`api.attribution.totalRequests`)}),(0,z.jsx)(`dd`,{children:ce.usage.totalRequests.toLocaleString(l)})]}),(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(`api.attribution.lastUsed`)}),(0,z.jsx)(`dd`,{children:ce.usage.lastUsedAt?rm(ce.usage.lastUsedAt,l):L(`api.attribution.neverUsed`)})]}),(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(r?`api.attribution.sinceAvailable`:`api.attribution.since`)}),(0,z.jsx)(`dd`,{children:rm(n,l)})]})]}):(0,z.jsx)(`p`,{className:`muted`,children:L(`api.attribution.unavailableDetail`)})]})]})]}):(0,z.jsx)(`div`,{className:`awi-overview`,children:(0,z.jsxs)(`div`,{className:`awi-overview-section`,children:[(0,z.jsxs)(`div`,{id:bd(`api`,`keys`),className:`awi-section-anchor`,children:[(0,z.jsx)(lm,{keys:e,keysLoading:a,keysLoadFailed:o,newName:u,creating:d,newKey:f,copied:p,confirmDelete:null,localeTag:l,showKeyList:!1,onNewNameChange:T,onCreate:E,onDismissNewKey:D,onCopyKey:O,onConfirmDelete:()=>{},onCancelDelete:()=>{},onDelete:()=>{}}),(0,z.jsx)(vm,{keys:e,keysLoading:a,keysLoadFailed:o,attributionSince:n,localeTag:l,busy:le,onSelect:e=>{B(e),de(),ne(!1),ie(!1),se(!1)}})]}),(0,z.jsx)(`div`,{id:bd(`api`,`connect`),className:`awi-section-anchor`,children:(0,z.jsx)(_m,{apiBase:t,baseUrl:s.baseUrl,hasKeys:e.length>0})}),(0,z.jsx)(`div`,{id:bd(`api`,`endpoints`),className:`awi-section-anchor`,children:(0,z.jsx)(cm,{endpoints:s,claudeCodeEnabled:c,authMatrix:i})}),(0,z.jsx)(`div`,{id:bd(`api`,`models`),className:`awi-section-anchor`,children:(0,z.jsx)(um,{filteredModels:m,modelsLoading:h,modelsRefreshing:g,modelsLoadFailed:v,modelCount:y,hasModelData:b,modelQuery:x,copiedModelId:S,modelTests:C,claudeCodeEnabled:c,onModelQueryChange:j,onCopyModelId:M,onTestModel:N,onRetryModels:P,canTestModels:w,sourceLabel:F,protocolLabel:I})}),(0,z.jsx)(`div`,{id:bd(`api`,`examples`),className:`awi-section-anchor`,children:(0,z.jsx)(dm,{endpoints:s,claudeCodeEnabled:c})})]})})})})]})}var bm=[],xm=15e3;function Sm(e){let t=e.replace(/\/$/,``);if(!t)return tm;try{return new URL(t).host?nm(`${t}/v1/responses`):tm}catch{return tm}}function Cm(e){return!e||!em(e.authMatrix)||!Array.isArray(e.keys)||e.keys.some(e=>!e||!Qp(e.usage))?null:e}function wm({apiBase:e,active:t=!0}){let{t:n,locale:r}=Ze(),i=Ue.find(e=>e.code===r)?.htmlLang,a=`ocx.apikeys.list.v2:${e}`,o=`ocx.apikeys.models.v1:${e}`,s=`api-keys:${e}`,c=`api-models:${e}`,l=Cm(Jn(a)),u=Jn(o),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)({}),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(!1),O=(0,_.useRef)(!1),k=(0,_.useCallback)(async t=>{let r=await wt(await fetch(`${e}/api/keys`,{signal:t}));if(!r||!em(r.authMatrix))throw Error(n(`api.keysLoadFailed`));let i=r.keys??[];if(i.some(e=>!Qp(e.usage)))throw Error(n(`api.keysLoadFailed`));let o=i,s=nm(r.endpoint??``),c={keys:o,endpoints:{baseUrl:r.baseUrl??s.baseUrl,responses:r.responsesEndpoint??r.endpoint??tm.responses,chatCompletions:r.chatCompletionsEndpoint??s.chatCompletions,messages:r.messagesEndpoint??s.messages,models:r.modelsEndpoint??s.models},claudeCodeEnabled:r.claudeCodeEnabled!==!1,...r.attributionSince?{attributionSince:r.attributionSince}:{},...r.historyTruncated===!0?{historyTruncated:!0}:{},authMatrix:r.authMatrix};return Yn(a,c),c},[e,a,n]),A=(0,_.useCallback)(async t=>{let r=await fetch(`${e}/v1/models`,{signal:t});if(!r.ok)throw Error(n(`api.modelsLoadFailed`));let i=await r.json(),a=Array.isArray(i)?i:typeof i==`object`&&i&&Array.isArray(i.data)?i.data:null;if(!a)throw Error(n(`api.modelsLoadFailed`));let s=a.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`).map(e=>Xp(e)).sort((e,t)=>Zp(e).localeCompare(Zp(t)));return Yn(o,s),s},[e,o,n]),j=Zs(s,[e],k,{isEmpty:e=>e.keys.length===0,initialData:l??void 0,enabled:t}),M=Zs(c,[e],A,{isEmpty:e=>e.length===0,initialData:u??void 0,enabled:t}),N=j.state,P=M.state,F=N.data??l,I=P.data??u??bm,L=F?.keys??[],R=F?.endpoints??Sm(e),B=F?.claudeCodeEnabled??!0,V=F?.attributionSince,H=F?.historyTruncated===!0,U=F?.authMatrix??[],W=j.refresh,G=M.refresh,ee=(0,_.useMemo)(()=>{let e=p.trim().toLowerCase();return e?I.filter(t=>Zp(t).toLowerCase().includes(e)||t.displayName.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)):I},[p,I]),te=async t=>{if(O.current)return!1;O.current=!0,C(!0),f(null);try{let r=t??b,i=await Ct(await fetch(`${e}/api/keys`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:r||`default`})}),n(`api.createFailed`));return typeof i?.key!=`string`||i.key.length===0?(f(n(`api.createFailed`)),!1):(T(i.key),x(``),W(),!0)}catch{return f(n(`api.createFailed`)),!1}finally{O.current=!1,C(!1)}},ne=async t=>{f(null);let n=wn(xm);try{return(await fetch(`${e}/api/keys`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t}),signal:n.signal})).ok?(W(),!0):!1}catch{return!1}finally{n.clear()}},K=async(t,n)=>{f(null);let r=wn(xm);try{return(await fetch(`${e}/api/keys`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t,name:n}),signal:r.signal})).ok?(W(),!0):!1}catch{return!1}finally{r.clear()}},q=async()=>{if(w){f(null);try{await navigator.clipboard.writeText(w),D(!0),window.setTimeout(()=>D(!1),2e3)}catch{D(!1),f(n(`api.key.copyFailed`))}}},J=async e=>{try{await navigator.clipboard.writeText(e),g(e),window.setTimeout(()=>g(t=>t===e?null:t),2e3)}catch{}},re=e=>e.native?n(`api.sourceNative`):e.provider===`combo`?n(`api.sourceCombo`):e.custom?n(`api.sourceCustom`):mn(e.provider,n),Y=e=>n(e===`responses`?`api.protocolResponses`:e===`messages`?`api.protocolMessages`:`api.protocolChatCompletions`),ie=(e,t)=>e===`responses`?{url:R.responses,body:{model:t,input:`ping`,max_output_tokens:1,stream:!1}}:e===`messages`?{url:R.messages,body:{model:t,max_tokens:1,messages:[{role:`user`,content:`ping`}]}}:{url:R.chatCompletions,body:{model:t,messages:[{role:`user`,content:`ping`}],max_tokens:1,stream:!1}},ae=(e,t,n)=>y(r=>({...r,[e]:{...r[e],[t]:n}})),oe=async(e,t)=>{if(!w)return;let r=Zp(e),i=ie(t,r);ae(r,t,{state:`testing`});try{let e=await fetch(i.url,{method:`POST`,headers:{"Content-Type":`application/json`,"x-opencodex-api-key":w},body:JSON.stringify(i.body)});if(!e.ok){let n=await e.text();ae(r,t,{state:`error`,detail:n.slice(0,160)||String(e.status)});return}ae(r,t,{state:`ok`})}catch(e){ae(r,t,{state:`error`,detail:e instanceof Error?e.message:n(`api.testFailed`)})}},se=n(`api.subtitle`).split(`{authHeader}`);return(0,z.jsxs)(`section`,{className:`api-page`,"aria-busy":N.refreshing||P.refreshing||void 0,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:n(`api.title`)})}),(0,z.jsxs)(`p`,{className:`page-sub`,children:[se[0],(0,z.jsx)(`code`,{children:`x-opencodex-api-key`}),se[1]]}),d&&(0,z.jsx)(Q,{tone:`err`,children:d}),N.showError&&F&&(0,z.jsx)(Q,{tone:`err`,children:n(`api.keysLoadFailed`)}),N.showSkeleton&&!F?(0,z.jsx)($s,{label:n(`api.activeKeysLoading`),rows:4}):N.kind===`failed-cold`&&!F?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Q,{tone:`err`,children:N.error instanceof Error?N.error.message:n(`api.keysLoadFailed`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>W(),children:n(`common.retry`)})]}):(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(ym,{keys:L,apiBase:e,attributionSince:V,historyTruncated:H,authMatrix:U,keysLoading:!1,keysLoadFailed:N.showError,endpoints:R,claudeCodeEnabled:B,localeTag:i,newName:b,creating:S,newKey:w,copied:E,filteredModels:ee,modelsLoading:P.showSkeleton&&!P.data&&!u,modelsRefreshing:P.refreshing&&P.showError&&(P.data!==void 0||u!==null),modelsLoadFailed:P.showError,modelCount:I.length,hasModelData:P.data!==void 0||u!==null,modelQuery:p,copiedModelId:h,modelTests:v,onNewNameChange:x,onCreate:()=>{te()},onDismissNewKey:()=>T(null),onCopyKey:()=>{q()},onDelete:ne,onRename:K,onModelQueryChange:m,onCopyModelId:e=>{J(e)},onTestModel:(e,t)=>{oe(e,t)},onRetryModels:()=>{G({forceLoading:!0})},canTestModels:w!==null,sourceLabel:re,protocolLabel:Y})})]})}function Tm(e,t){let n=(e??[]).map(e=>({value:e,label:Ys(e)}));return[{value:``,label:t},...n]}function Em(e){let t=e.autoConnectSupported===!0;return{autoConnectSupported:t,systemEnv:t&&e.systemEnv===!0}}var Dm=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`];function Om(e){let t=`http://127.0.0.1:${e.port}`,n=e.authMode===`auto`?e.markerMode??`subscription`:e.authMode,r=e.autoContext&&e.maxContextTokens===null,i=Dm.filter(t=>e.effectiveModelEnv[t]).map(t=>`export ${t}=${e.effectiveModelEnv[t]}`);return[`export ANTHROPIC_BASE_URL=${t}`,...n===`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`,...n===`proxy`?['[ -z "${CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST+x}" ] && export CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1']:[],...r?[`export CLAUDE_CODE_AUTO_COMPACT_WINDOW=${e.autoCompactWindow??35e4}`]:[],...i,`claude`].join(`
|
|
74
74
|
`)}function km(e){return e?e.backend??`auto`:`inherit`}function Am(e,t){if(t!==`inherit`)return t===`auto`?{...e,backend:void 0}:{...e,backend:t}}function jm(e,t){return{...e,model:t}}function Mm(e){if(!e)return null;let t=(e.model??``).trim();return e.backend?{backend:e.backend,model:t}:t?{backend:null,model:t}:null}function Nm({label:e,checked:t,onChange:n,disabled:r=!1,describedBy:i}){return(0,z.jsxs)(`label`,{className:`toggle`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:t,disabled:r,"aria-label":e,"aria-describedby":i,onChange:e=>n(e.target.checked)}),(0,z.jsx)(`span`,{className:`slider`,"aria-hidden":`true`})]})}function Pm({supported:e,checked:t,onChange:n}){let r=Z(),i=e?void 0:`claude-system-env-unsupported`;return(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:r(`claude.systemEnv`)}),e?(0,z.jsx)(`span`,{className:`desc`,children:r(`claude.systemEnvDesc`)}):(0,z.jsx)(`span`,{className:`desc`,id:i,children:(0,z.jsx)($e,{k:`claude.systemEnvUnsupported`,cmd:`ocx claude`})}),e&&t&&(0,z.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:r(`claude.systemEnvWarn`)})]}),(0,z.jsx)(Nm,{label:r(`claude.systemEnv`),checked:e&&t,disabled:!e,describedBy:i,onChange:n})]})}function Fm({value:e,tierHaikuModel:t,options:n,onChange:r}){let i=Z(),a=t??e;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:i(`claude.smallFastModelAccurateHint`)}),(0,z.jsx)(gt,{value:e,options:n,onChange:r,label:i(`claude.smallFastModel`),style:{maxWidth:420}}),a===``&&(0,z.jsx)(`p`,{className:`notice-warn`,role:`status`,style:{marginTop:8},children:i(`claude.smallFastModelNativeWarning`)})]})}function Im(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)try{return crypto.randomUUID()}catch{}let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Lm(e,t=`en`){if(e>=1e6){let n=e/1e6,r=n.toFixed(1).replace(/\.0$/,``);return Number.isInteger(n)||Number(r)*1e6===e?new Intl.NumberFormat(t,{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:+!Number.isInteger(n)}).format(e):`${Math.round(e/1e3)}k`}return`${Math.round(e/1e3)}k`}function Rm(e,t){return e&&[`claude-json-oauth`,`claude-credentials-file`,`macos-keychain`,`exported-env`].includes(e)?t(`claude.authSource.${e}`):t(`claude.authSource.unknown`)}function zm({state:e,autoCompactOptions:t,availableModels:n,onStateChange:r}){let i=Z();return(0,z.jsxs)(`div`,{className:`card`,style:{overflow:`hidden`},children:[(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.authMode`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.authModeHint`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(gt,{value:e.authMode,options:[{value:`auto`,label:i(`claude.authModeAuto`)},{value:`subscription`,label:i(`claude.authModeSubscription`)},{value:`proxy`,label:i(`claude.authModeProxy`)}],onChange:t=>r({...e,authMode:t}),label:i(`claude.authMode`),style:{minWidth:220},align:`right`,portal:!0})})]}),e.authModeOrigin&&(0,z.jsxs)(`div`,{className:`claude-effective-auth${e.authModeOrigin===`auto-unknown`?` warn`:``}`,role:`status`,children:[(0,z.jsx)(`span`,{className:`claude-effective-auth-label`,children:i(`claude.effectiveMode.label`)}),(0,z.jsxs)(`span`,{children:[e.authModeOrigin===`manual`?i(`claude.effectiveMode.manual`,{mode:e.markerMode===`proxy`?i(`claude.authModeProxy`):i(`claude.authModeSubscription`)}):e.authModeOrigin===`auto-present`?i(`claude.effectiveMode.autoPresent`,{source:Rm(e.authFoundBy,i)}):e.authModeOrigin===`auto-absent`?i(`claude.effectiveMode.autoAbsent`):i(`claude.effectiveMode.autoUnknown`),e.admissionKeyActive===!0?` ${i(`claude.effectiveMode.admissionKey`)}`:``]})]}),(0,z.jsx)(Pm,{supported:e.autoConnectSupported,checked:e.systemEnv,onChange:t=>r({...e,systemEnv:t})}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.fastMode`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.fastModeDesc`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(gt,{value:e.fastMode===null?`auto`:e.fastMode?`on`:`off`,options:[{value:`auto`,label:i(`claude.fastAuto`)},{value:`on`,label:i(`claude.fastOn`)},{value:`off`,label:i(`claude.fastOff`)}],onChange:t=>r({...e,fastMode:t===`auto`?null:t===`on`}),label:i(`claude.fastMode`),style:{minWidth:140},align:`right`,portal:!0})})]}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.autoContext`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.autoContextDesc`)}),e.maxContextTokens!==null&&(0,z.jsx)(`span`,{className:`desc`,style:{color:`var(--muted)`},children:i(`claude.autoContextInert`)})]}),(0,z.jsx)(Nm,{label:i(`claude.autoContext`),checked:e.autoContext,onChange:t=>r({...e,autoContext:t})})]}),e.autoContext&&(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.autoCompactWindow`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.autoCompactWindowDesc`)}),e.autoCompactWindow!==null&&(0,z.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:i(`claude.autoCompactWindowWarn`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(gt,{value:e.autoCompactWindow===null?``:String(e.autoCompactWindow),options:t,onChange:t=>r({...e,autoCompactWindow:t===``?null:Number(t)}),label:i(`claude.autoCompactWindow`),style:{minWidth:130},align:`right`,portal:!0})})]}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.injectAgents`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.injectAgentsDesc`)})]}),(0,z.jsx)(Nm,{label:i(`claude.injectAgents`),checked:e.injectAgents,onChange:t=>r({...e,injectAgents:t})})]}),[`webSearchSidecar`,`visionSidecar`].map(t=>{let a=e[t],o=t===`webSearchSidecar`?`claude.webSearchSidecar`:`claude.visionSidecar`,s=t===`webSearchSidecar`?`claude.webSearchSidecarHint`:`claude.visionSidecarHint`,c=`claude-sidecar-models-${t}`;return(0,z.jsxs)(`div`,{className:`setting-row`,style:{alignItems:`flex-start`},children:[(0,z.jsxs)(`div`,{className:`setting-label setting-copy`,style:{flex:1},children:[(0,z.jsx)(`span`,{className:`title`,children:i(o)}),(0,z.jsx)(`span`,{className:`desc`,children:i(s)})]}),(0,z.jsxs)(`div`,{className:`setting-controls`,style:{display:`flex`,gap:8},children:[(0,z.jsx)(gt,{value:km(a),options:[{value:`inherit`,label:i(`claude.useMainSetting`)},{value:`auto`,label:i(`dash.backendAuto`)},{value:`openai`,label:i(`dash.backendOpenAI`)},{value:`anthropic`,label:i(`dash.backendAnthropic`)}],onChange:n=>{r({...e,[t]:Am(a,n)})},label:i(`dash.sidecarBackend`),portal:!0}),(0,z.jsx)(`input`,{className:`input mono`,value:a?.model??``,onChange:n=>{r({...e,[t]:jm(a,n.target.value)})},placeholder:i(`claude.sidecarModelPlaceholder`),disabled:!a,list:a?c:void 0,"aria-label":i(`dash.sidecarModel`),style:{minWidth:210},autoComplete:`off`}),a&&(0,z.jsx)(`datalist`,{id:c,children:n.map(e=>(0,z.jsx)(`option`,{value:e},e))})]})]},t)})]})}function Bm({manualEnv:e}){let t=Z();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:(0,z.jsx)($e,{k:`claude.quickstartHint`,cmd:`ocx claude`})}),(0,z.jsx)(`pre`,{className:`mono card`,style:{padding:`10px 14px`,overflowX:`auto`,margin:0},children:`ocx claude`}),(0,z.jsxs)(`details`,{style:{margin:`10px 0 0`},children:[(0,z.jsx)(`summary`,{className:`muted text-label`,style:{cursor:`pointer`,padding:`2px 2px`},children:t(`claude.manualEnv`)}),(0,z.jsx)(`pre`,{className:`mono card text-label`,style:{padding:`10px 14px`,overflowX:`auto`,margin:`6px 0 0`},children:e})]})]})}function Vm({rows:e,onRowsChange:t}){let n=Z();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:n(`claude.modelMapHint`)}),(0,z.jsx)(`div`,{className:`stack`,style:{gap:8},children:e.map((r,i)=>(0,z.jsxs)(`div`,{className:`row`,style:{gap:8},children:[(0,z.jsx)(`input`,{className:`input mono`,value:r.from,placeholder:n(`claude.mapFrom`),"aria-label":n(`claude.mapFrom`),onChange:n=>t(e.map((e,t)=>t===i?{...e,from:n.target.value}:e)),style:{flex:1}}),(0,z.jsx)(`span`,{className:`muted`,"aria-hidden":!0,children:`→`}),(0,z.jsx)(`input`,{className:`input mono`,value:r.to,placeholder:n(`claude.mapTo`),"aria-label":n(`claude.mapTo`),onChange:n=>t(e.map((e,t)=>t===i?{...e,to:n.target.value}:e)),style:{flex:1}}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>t(e.filter((e,t)=>t!==i)),"aria-label":n(`claude.removeMapping`),style:{color:`var(--red)`},children:(0,z.jsx)(J,{})})]},r.id))}),(0,z.jsx)(`div`,{style:{marginTop:8},children:(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>t([...e,{id:Im(),from:``,to:``}]),children:[(0,z.jsx)(re,{}),` `,n(`claude.addMapping`)]})})]})}var Hm=`etc`;function Um(e){let t=new Map;for(let n of e){let e=/\(([^)]+)\)\s*$/.exec(n.display_name),r=e?e[1]:Hm,i=t.get(r);i?i.push(n):t.set(r,[n])}return Array.from(t)}function Wm({aliases:e}){let t=Z();return(0,z.jsxs)(`div`,{className:`claude-aliases`,children:[(0,z.jsx)(`p`,{className:`muted text-label claude-aliases-hint`,children:t(`claude.aliasesHint`)}),e.length===0?(0,z.jsx)(`div`,{className:`muted text-label`,children:t(`claude.none`)}):(0,z.jsx)(`div`,{className:`claude-aliases-scroll`,children:Um(e).map(([e,n])=>(0,z.jsxs)(`div`,{className:`claude-aliases-group`,children:[(0,z.jsxs)(`div`,{className:`claude-aliases-group-label`,children:[e===Hm?t(`claude.aliasProviderOther`):e,(0,z.jsx)(`span`,{className:`claude-aliases-group-count`,children:n.length})]}),(0,z.jsx)(`div`,{className:`claude-aliases-chips`,children:n.map(e=>(0,z.jsxs)(`span`,{className:`claude-aliases-chip`,children:[(0,z.jsx)(`code`,{className:`claude-aliases-chip-id`,children:e.id}),e.display_name?(0,z.jsx)(`span`,{className:`claude-aliases-chip-name`,children:e.display_name}):null]},e.id))})]},e))})]})}function Gm({apiBase:e,active:t=!0}){let n=Z(),{locale:r}=Ze(),i=Ue.find(e=>e.code===r)?.htmlLang??`en`,a=`ocx.claude-code.v1:${e}`,o=`claude-code:${e}`,s=(0,_.useMemo)(()=>Jn(a),[a]),[c,l]=(0,_.useState)(()=>s?.state??null),[u,d]=(0,_.useState)(()=>s?.rows??[]),[f,p]=(0,_.useState)(!!s),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(`settings`),[x,S]=(0,_.useState)(!1),C=(0,_.useRef)(!1),w=(0,_.useCallback)(async t=>{let r=await Ct(await fetch(`${e}/api/claude-code`,{signal:t}),n(`claude.loadFail`));if(!r)throw Error(n(`claude.loadFail`));let i={...r,authMode:r.authMode===`proxy`||r.authMode===`subscription`?r.authMode:`auto`,...Em(r),fastMode:r.fastMode??null,maxContextTokens:r.maxContextTokens??null,autoContext:r.autoContext!==!1,autoCompactWindow:r.autoCompactWindow??null,injectAgents:r.injectAgents!==!1,effectiveModelEnv:r.effectiveModelEnv??{}},o=Object.entries(r.modelMap??{}).map(([e,t])=>({id:Im(),from:e,to:String(t)})),s={state:i,rows:o};if(t.aborted)throw Error(`Claude Code request aborted`);return l(i),d(o),p(!0),Yn(a,s),s},[e,a,n]),T=Zs(o,[e],w,{isEmpty:()=>!1,enabled:t,initialData:s??void 0}),E=T.state,D=E.data??s,O=c??D?.state??null,k=f?u:D?.rows??u,A=(0,_.useMemo)(()=>Tm(O?.available,n(`claude.smallFastModelUnsetOption`)),[O?.available,n]),j=(0,_.useMemo)(()=>{let e=[1e5,2e5,25e4,3e5,35e4,4e5,5e5,6e5,75e4,9e5,1e6],t=O?.autoCompactWindow??null,r=t!==null&&!e.includes(t)?[...e,t].sort((e,t)=>e-t):e;return[{value:``,label:n(`claude.autoCompactDefault`)},...r.map(e=>({value:String(e),label:Lm(e,i)}))]},[O?.autoCompactWindow,n,i]),M=async()=>{if(!O||C.current)return;C.current=!0,S(!0),h(``);let t=!O.enabled;try{await Ct(await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})}),n(`claude.saveFailed`)),l({...O,enabled:t}),T.refresh()}catch(e){v(!1),h(e instanceof Error&&e.message?e.message:n(`claude.networkError`))}finally{C.current=!1,S(!1)}},N=async()=>{if(!O)return;h(``);let t={};for(let e of k)e.from.trim()&&e.to.trim()&&(t[e.from.trim()]=e.to.trim());try{await Ct(await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:O.enabled,authMode:O.authMode,systemEnv:O.systemEnv,fastMode:O.fastMode,autoContext:O.autoContext,autoCompactWindow:O.autoCompactWindow,injectAgents:O.injectAgents,smallFastModel:O.smallFastModel,modelMap:t,webSearchSidecar:Mm(O.webSearchSidecar),visionSidecar:Mm(O.visionSidecar)})}),n(`claude.saveFailed`)),v(!0),h(n(`claude.saved`)),T.refresh()}catch(e){v(!1),h(e instanceof Error&&e.message?e.message:n(`claude.networkError`))}};if(E.kind===`disabled`&&!D)return null;if(E.showSkeleton&&!D)return(0,z.jsx)($s,{label:n(`claude.loading`),rows:3});if(E.kind===`failed-cold`){let e=E.error instanceof Error?E.error.message:n(`claude.loadFail`);return(0,z.jsxs)(`div`,{className:`claudecode-workspace-shell`,children:[(0,z.jsx)(Q,{tone:`err`,children:e}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>T.refresh(),children:n(`common.retry`)})]})}if(!O)return null;let P=[{id:`settings`,label:n(`claude.workspace.settings`),body:(0,z.jsx)(zm,{state:O,autoCompactOptions:j,availableModels:O.available??[],onStateChange:l})},{id:`quickstart`,label:n(`claude.quickstart`),body:(0,z.jsx)(Bm,{manualEnv:Om(O)})},{id:`smallFast`,label:n(`claude.smallFastModel`),body:(0,z.jsx)(Fm,{value:O.smallFastModel,tierHaikuModel:O.tierModels?.haiku,options:A,onChange:e=>l({...O,smallFastModel:e})})},{id:`modelMap`,label:n(`claude.modelMap`),meta:String(k.length),body:(0,z.jsx)(Vm,{rows:k,onRowsChange:e=>{p(!0),d(e)}})},{id:`aliases`,label:n(`claude.aliases`),meta:String(O.aliases.length),body:(0,z.jsx)(Wm,{aliases:O.aliases})}],F=P.find(e=>e.id===y)??P[0],I=y===`settings`||y===`smallFast`||y===`modelMap`;return(0,z.jsxs)(`div`,{className:`claudecode-workspace-shell`,children:[m&&(0,z.jsx)(Q,{tone:g?`ok`:`err`,children:m}),E.showError&&(0,z.jsx)(Q,{tone:`err`,children:n(`claude.loadFail`)}),O&&(0,z.jsxs)(`div`,{className:`claudecode-connection-head`,children:[(0,z.jsx)(`span`,{id:`claudecode-connection-label`,children:n(`claude.enabledLabel`)}),(0,z.jsx)(mt,{on:O.enabled,onClick:()=>void M(),disabled:x,label:n(`claude.toggleAria`)})]}),(0,z.jsxs)(`div`,{className:`claudecode-workspace-root`,children:[(0,z.jsx)(`aside`,{className:`claudecode-workspace-rail`,"aria-label":n(`claude.pageTitle`),children:(0,z.jsx)(`div`,{className:`claudecode-workspace-rail-list`,children:P.map(e=>(0,z.jsx)(`button`,{type:`button`,className:`claudecode-workspace-rail-row${y===e.id?` claudecode-workspace-rail-row--selected`:``}`,onClick:()=>b(e.id),"aria-current":y===e.id?`true`:void 0,children:(0,z.jsx)(`span`,{className:`claudecode-workspace-rail-name`,children:e.label})},e.id))})}),(0,z.jsxs)(`section`,{className:`claudecode-workspace-main`,"aria-label":F.label,children:[(0,z.jsxs)(`div`,{className:`ccw-main-head`,children:[(0,z.jsxs)(`h3`,{className:`ccw-main-title`,children:[F.label,F.meta==null?null:(0,z.jsx)(`span`,{className:`count`,children:F.meta})]}),(0,z.jsx)(`div`,{className:`claudecode-workspace-save`,"data-visible":I?`true`:`false`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:!I,tabIndex:I?0:-1,"aria-hidden":!I,onClick:()=>{N()},children:n(`common.save`)})})]}),(0,z.jsx)(`div`,{className:`ccw-body`,children:F.body})]})]})]})}function Km(e,t,n){let r=t.trim().toLowerCase(),i=(r?e.filter(e=>e.label.toLowerCase().includes(r)||e.route.toLowerCase().includes(r)):e).toSorted((e,t)=>Number(!e.available)-Number(!t.available)),a=i.slice(0,n);return{total:e.length,showSearch:e.length>4,shown:a,hidden:i.length-a.length,noMatch:e.length>0&&i.length===0}}function qm(e){return new Set(Object.keys(e))}function Jm(e,t){return t!==null&&e===t}function Ym(e){return e||(typeof localStorage>`u`?void 0:localStorage)}function Xm(e){return{read(t){let n=Ym(t);if(!n)return null;try{let t=n.getItem(e);if(t===null)return null;let r=JSON.parse(t);return Array.isArray(r)?new Set(r.filter(e=>typeof e==`string`)):null}catch{return null}},write(t,n){let r=Ym(n);if(r)try{r.setItem(e,JSON.stringify([...t]))}catch{}}}}function Zm(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}var Qm=[`opus`,`fable`,`sonnet`,`haiku`],$m=Xm(`ocx.claudeDesktop.collapsedFamilies.v2`),eh={opus:`claudeDesktop.family.opus`,fable:`claudeDesktop.family.fable`,sonnet:`claudeDesktop.family.sonnet`,haiku:`claudeDesktop.family.haiku`};function th(e){return{version:1,assignments:Object.fromEntries(Object.entries(e.assignments).map(([e,t])=>[e,{...t}])),defaults:{...e.defaults},...e.appliedFingerprint===void 0?{}:{appliedFingerprint:e.appliedFingerprint},...e.appliedAt===void 0?{}:{appliedAt:e.appliedAt}}}function nh(e){let t={...e.profile.assignments};for(let n of e.models){let e=t[n.route]??n.assignment;t[n.route]={family:Qm.includes(e?.family)?e.family:`opus`,alias:typeof e?.alias==`string`?e.alias:``}}return{version:1,assignments:t,defaults:{opus:e.profile.defaults.opus??null,fable:e.profile.defaults.fable??null,sonnet:e.profile.defaults.sonnet??null,haiku:e.profile.defaults.haiku??null}}}function rh(e,t){return e&&typeof e==`object`&&`error`in e&&typeof e.error==`string`?e.error:t}function ih(e,t){return e?e>=1048576?t(`claudeDesktop.contextM`,{n:Math.round(e/1048576)}):e>=1e6?t(`claudeDesktop.contextM`,{n:e/1e6}):t(`claudeDesktop.contextK`,{n:Math.round(e/1e3)}):null}function ah(e){return Jn(e)}function oh(e){let t=ah(e);return{held:t,data:t?.data??null,profile:t?.profile??null,savedProfile:t?.profile?th(t.profile):null,destinations:t?.data?Object.fromEntries(t.data.models.map(e=>[e.route,t.profile.assignments[e.route]?.family??`opus`])):{}}}function sh({apiBase:e,active:t=!0,onPortChange:n}){let{t:r,locale:i}=Ze(),a=Ue.find(e=>e.code===i)?.htmlLang,o=`ocx.claude-desktop.v1:${e}`,s=`claude-desktop:${e}`,c=(0,_.useMemo)(()=>oh(o),[o]),[l,u]=(0,_.useState)(()=>c.profile),[d,f]=(0,_.useState)(()=>c.savedProfile),[p,m]=(0,_.useState)(()=>c.destinations),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)({}),[w,T]=(0,_.useState)({}),[E,D]=(0,_.useState)(()=>$m.read()??new Set(Qm)),[O,k]=(0,_.useState)({}),A=(0,_.useRef)(null),j=(0,_.useCallback)(async t=>{let n=await Ct(await fetch(`${e}/api/claude-desktop`,{signal:t}),r(`claudeDesktop.loadFail`));if(!n||!(`profile`in n)||!(`models`in n))throw Error(rh(n,r(`claudeDesktop.loadFail`)));let i=nh(n),a={data:n,profile:i};if(t.aborted)throw Error(`Claude Desktop request aborted`);if(u(i),f(th(i)),m(Object.fromEntries(n.models.map(e=>[e.route,i.assignments[e.route]?.family??`opus`]))),$m.read()===null){let e=Object.fromEntries(Qm.map(e=>[e,0]));for(let t of n.models)e[i.assignments[t.route]?.family??`opus`]+=1;D(qm(e))}return Yn(o,a),a},[e,o,r,m,u,f]),M=Zs(s,[e],j,{isEmpty:()=>!1,enabled:t,initialData:c.held??void 0}),N=M.state,P=N.data??(c.data&&c.profile?{data:c.data,profile:c.profile}:null),F=P?.data??null,I=l??P?.profile??null,L=d??P?.profile??null,R=P?Object.fromEntries(P.data.models.map(e=>[e.route,P.profile.assignments[e.route]?.family??`opus`])):{},B=Object.keys(p).length>0?p:R;(0,_.useEffect)(()=>{if(n){if(typeof F?.port==`number`){n(F.port);return}N.kind===`failed-cold`&&n(null)}},[F?.port,N.kind,n]);let V=(0,_.useMemo)(()=>I!==null&&L!==null&&JSON.stringify(I)!==JSON.stringify(L),[I,L]),H=(0,_.useMemo)(()=>{let e=Object.fromEntries(Qm.map(e=>[e,[]]));if(!F||!I)return e;for(let t of F.models)e[I.assignments[t.route]?.family??`opus`].push(t);return e},[F,I]),U=(0,_.useMemo)(()=>{let e={};for(let t of Qm){let n=H[t].filter(e=>e.available).map(e=>e.route).sort(),r=I?.defaults[t]??null;e[t]=r&&n.includes(r)?r:n[0]??null}return e},[H,I]),W=`ocx.claude-desktop.status.v1:${e}`,G=`claude-desktop-status:${e}`,ee=Jn(W),te=Zs(G,[e],async t=>{let n=await wt(await fetch(`${e}/api/claude-desktop/status`,{signal:t}));if(!n)throw Error(`Claude Desktop status unavailable`);return Yn(W,n),n},{isEmpty:()=>!1,pollMs:5e3,enabled:t,initialData:ee??void 0}),ne=te.state,K=ne.data??ee??null,q=ne.showError,J=(e,t)=>{!I||I.assignments[e]?.family===t||(u(n=>{if(!n)return n;let r=n.assignments[e];if(!r||r.family===t)return n;let i={...n.assignments,[e]:{...r,family:t}},a={...n.defaults};return a[r.family]===e&&(a[r.family]=Object.keys(i).filter(t=>t!==e&&i[t].family===r.family).sort()[0]??null),a[t]===null&&(a[t]=e),{...n,assignments:i,defaults:a}}),m(n=>({...n,[e]:t})),y(r(`claudeDesktop.moved`,{route:e,family:r(eh[t])})))},re=e=>{let t=Zm(E,e);$m.write(t),D(t)},Y=async t=>{if(!(!I||b)){x(`save`),g(null);try{await Ct(await fetch(`${e}/api/claude-desktop`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profile:I})}),r(`claudeDesktop.saveFailed`)),f(th(I)),t?(x(`apply`),(await Ct(await fetch(`${e}/api/claude-desktop/apply`,{method:`POST`}),r(`claudeDesktop.applyFailed`)))?.saved===!1?(g({tone:`warn`,text:r(`claudeDesktop.appliedMarkerUnsaved`)}),y(r(`claudeDesktop.appliedMarkerUnsaved`))):(g({tone:`ok`,text:r(`claudeDesktop.savedApplied`)}),y(r(`claudeDesktop.savedAppliedAnnounce`)))):(g({tone:`ok`,text:r(`claudeDesktop.saved`)}),y(r(`claudeDesktop.savedAnnounce`))),te.refresh()}catch(e){let t=e instanceof Error?e.message:r(`claudeDesktop.updateFailed`);g({tone:`err`,text:t}),y(t)}finally{x(null)}}},ie=()=>{if(!I)return;let e=URL.createObjectURL(new Blob([`${JSON.stringify(I,null,2)}\n`],{type:`application/json`})),t=document.createElement(`a`);t.href=e,t.download=`claude-desktop-profile.json`,t.click(),URL.revokeObjectURL(e),y(r(`claudeDesktop.exported`))},ae=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t)try{let e=JSON.parse(await t.text());if(e.version!==1||!e.assignments||!e.defaults)throw Error(r(`claudeDesktop.importExpected`));let n=nh({...F,profile:e});u(n),g({tone:`ok`,text:r(`claudeDesktop.importReady`)}),y(r(`claudeDesktop.importedAnnounce`))}catch(e){let t=e instanceof Error?e.message:r(`claudeDesktop.importInvalid`);g({tone:`err`,text:t}),y(r(`claudeDesktop.importFailed`,{error:t}))}},oe=(e,t)=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);n&&J(n,t)};if(N.kind===`disabled`&&!P)return null;if(N.showSkeleton&&!P)return(0,z.jsx)($s,{label:r(`claudeDesktop.loading`),rows:4});if(N.kind===`failed-cold`){let e=N.error instanceof Error?N.error.message:r(`claudeDesktop.loadFail`);return(0,z.jsxs)(`div`,{className:`claude-desktop-error`,children:[(0,z.jsx)(Q,{tone:`err`,children:e}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>M.refresh(),children:r(`claudeDesktop.retry`)})]})}return!F||!I?null:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`claude-desktop-toolbar`,children:(0,z.jsxs)(`div`,{className:`claude-profile-tools`,children:[(0,z.jsx)(`input`,{ref:A,type:`file`,accept:`application/json,.json`,hidden:!0,onChange:e=>void ae(e)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A.current?.click(),children:r(`claudeDesktop.importJson`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:ie,children:r(`claudeDesktop.exportJson`)})]})}),(0,z.jsxs)(`div`,{className:`claude-status-bar ${q&&!K?`not-applied`:K?K.desiredEnabled?K.activeProfile===!1?`not-applied`:K.stale?`stale`:K.applied?`applied`:`not-applied`:`not-applied`:`pending`}`,"aria-busy":!K&&!q||void 0,children:[(0,z.jsx)(`span`,{className:`claude-status-dot`}),(0,z.jsx)(`span`,{children:q&&!K?r(`claudeDesktop.loadFail`):K?K.desiredEnabled?K.activeProfile===!1?r(`claudeDesktop.status.notActiveProfile`):K.stale?r(`claudeDesktop.status.stale`):K.applied?r(`claudeDesktop.status.applied`):r(`claudeDesktop.status.notApplied`):r(`claudeDesktop.status.disabled`):r(`claudeDesktop.loading`)}),K?.health.lastRequestAt&&(0,z.jsxs)(`span`,{className:`claude-status-health`,children:[r(`claudeDesktop.health.lastRequest`),`:`,` `,new Date(K.health.lastRequestAt).toLocaleTimeString(a)]}),K&&K.health.requestCount>0&&(0,z.jsx)(`span`,{className:`claude-status-health`,children:r(`claudeDesktop.health.stats`,{count:K.health.requestCount,errors:K.health.errorCount})})]}),(0,z.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:v}),h&&(0,z.jsx)(Q,{tone:h.tone,children:h.text}),N.showError&&(0,z.jsx)(Q,{tone:`err`,children:r(`claudeDesktop.loadFail`)}),q&&K&&(0,z.jsx)(Q,{tone:`err`,children:r(`claudeDesktop.loadFail`)}),(0,z.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,z.jsx)(`span`,{className:`claude-dirty${V?` active`:``}`,children:r(V?`claudeDesktop.unsaved`:`claudeDesktop.upToDate`)}),(0,z.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!V||b!==null,onClick:()=>void Y(!1),children:r(b===`save`?`claudeDesktop.saving`:`common.save`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:b!==null,onClick:()=>void Y(!0),children:b===`apply`?r(`claudeDesktop.applying`):b===`save`?r(`claudeDesktop.saving`):K?.desiredEnabled===!1?r(`claudeDesktop.enableApply`):r(`claudeDesktop.saveApply`)})]})]}),F.models.length===0&&(0,z.jsx)(_t,{title:r(`claudeDesktop.emptyTitle`),children:r(`claudeDesktop.emptyHint`)}),(0,z.jsx)(`div`,{className:`ocx-group-stack`,"aria-label":r(`claudeDesktop.assignmentsLabel`),children:Qm.map(e=>{let t=H[e],n=Km(t,S[e]??``,w[e]??6),i=E.has(e),a=U[e];return(0,z.jsxs)(`section`,{className:`ocx-group${i?` collapsed`:``}`,"aria-labelledby":`claude-lane-${e}`,onDragOver:e=>e.preventDefault(),onDrop:t=>oe(t,e),children:[(0,z.jsxs)(`header`,{className:`ocx-group-head${i?``:` open`}`,children:[(0,z.jsx)(`h3`,{id:`claude-lane-${e}`,className:`ocx-group-heading`,children:(0,z.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!i,"aria-controls":`claude-lane-body-${e}`,onClick:()=>re(e),children:[(0,z.jsx)(pe,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:i?`none`:`rotate(90deg)`}}),(0,z.jsx)(`span`,{className:`ocx-group-name`,children:r(eh[e])}),(0,z.jsx)(`span`,{className:`ocx-group-count`,children:r(t.length===1?`claudeDesktop.modelCountOne`:`claudeDesktop.modelCountMany`,{count:t.length})}),a&&(0,z.jsx)(`code`,{className:`claude-lane-default`,title:a,children:a})]})}),t.length>0&&I.defaults[e]===null&&(0,z.jsx)(`span`,{className:`claude-default-needed`,children:r(`claudeDesktop.chooseDefault`)}),a&&a!==I.defaults[e]&&(0,z.jsx)(`span`,{className:`claude-default-needed`,title:a,children:r(`claudeDesktop.temporaryDefault`)})]}),!i&&(0,z.jsxs)(`div`,{id:`claude-lane-body-${e}`,children:[n.showSearch&&(0,z.jsx)(`input`,{className:`input claude-lane-search`,type:`search`,placeholder:r(`models.search`),"aria-label":r(`models.search`),value:S[e]??``,onChange:t=>{let n=t.target.value;C(t=>({...t,[e]:n})),T(t=>({...t,[e]:6}))}}),(0,z.jsxs)(`div`,{className:`claude-lane-models`,children:[t.length===0?(0,z.jsx)(`div`,{className:`claude-lane-empty`,children:r(`claudeDesktop.laneEmpty`)}):n.noMatch?(0,z.jsx)(`div`,{className:`claude-lane-empty`,children:r(`claudeDesktop.laneNoMatch`)}):n.shown.map(t=>{let n=I.assignments[t.route],i=ih(t.contextWindow,r),a=B[t.route]??`opus`,o=O[t.route]??Jm(t.route,U[e]);return(0,z.jsxs)(`article`,{className:`claude-model-card${o?` open`:``}`,draggable:t.available,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.route)},children:[(0,z.jsxs)(`button`,{type:`button`,className:`claude-model-summary`,"aria-expanded":o,"aria-controls":`claude-model-body-${t.route}`,onClick:()=>k(e=>({...e,[t.route]:!o})),children:[(0,z.jsx)(pe,{className:`ocx-chevron`,width:12,height:12,"aria-hidden":`true`,style:{transform:o?`rotate(90deg)`:`none`}}),(0,z.jsxs)(`span`,{className:`claude-model-names`,children:[(0,z.jsx)(`strong`,{title:t.label,children:t.label}),(0,z.jsx)(`code`,{title:t.route,children:t.route})]}),i&&(0,z.jsx)(`span`,{className:`claude-model-context`,children:i}),!i&&(0,z.jsx)(`span`,{className:`claude-model-context claude-model-context-unknown`,children:r(`claudeDesktop.contextUnknown`)}),t.supports1m===!0&&(0,z.jsx)(`span`,{className:`claude-1m-chip`,children:r(`claudeDesktop.supports1m`)}),t.effortSupported===!1&&(0,z.jsx)(`span`,{className:`claude-effort-badge off`,children:r(`claudeDesktop.effort.displayOnly`)}),t.effortSupported===!0&&(0,z.jsx)(`span`,{className:`claude-effort-badge on`,children:r(`claudeDesktop.effort.supported`)}),I.defaults[e]===t.route&&(0,z.jsx)(`span`,{className:`claude-row-default`,children:r(`claudeDesktop.defaultBadge`)}),(0,z.jsx)(`span`,{className:`badge ${t.available?`badge-green`:`badge-muted`}`,children:t.available?r(`claudeDesktop.available`):r(`claudeDesktop.unavailable`)})]}),o&&(0,z.jsxs)(`div`,{className:`claude-model-body`,id:`claude-model-body-${t.route}`,children:[U[e]===t.route&&I.defaults[e]!==t.route&&(0,z.jsx)(`span`,{className:`claude-effective-default`,children:r(`claudeDesktop.temporaryDefault`)}),(0,z.jsxs)(`div`,{className:`claude-field`,children:[(0,z.jsx)(`span`,{children:r(`claudeDesktop.alias`)}),(0,z.jsx)(`code`,{className:`claude-alias`,title:n.alias,children:n.alias})]}),(0,z.jsxs)(`label`,{className:`claude-default-radio`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`default-${e}`,checked:I.defaults[e]===t.route,disabled:!t.available,onChange:()=>u(n=>n&&{...n,defaults:{...n.defaults,[e]:t.route}})}),r(`claudeDesktop.useAsDefault`,{family:r(eh[e])})]}),(0,z.jsxs)(`div`,{className:`claude-move-row`,children:[(0,z.jsx)(`label`,{htmlFor:`move-${t.route}`,children:r(`claudeDesktop.moveTo`)}),(0,z.jsx)(`select`,{id:`move-${t.route}`,className:`input`,value:a,disabled:!t.available,onChange:e=>m(n=>({...n,[t.route]:e.target.value})),children:Qm.map(e=>(0,z.jsx)(`option`,{value:e,children:r(eh[e])},e))}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:!t.available||a===e,onClick:()=>J(t.route,a),children:r(`claudeDesktop.move`)})]})]})]},t.route)}),n.hidden>0&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm claude-lane-more`,onClick:()=>T(t=>({...t,[e]:(t[e]??6)+6})),children:r(`models.showMore`,{n:n.hidden})})]})]})]},e)})})]})}var ch=`integrations/claude`,lh=`integrations/claude/desktop`;function uh(e=typeof window<`u`?window.location.hash:``){return et(e)===lh?`desktop`:`code`}function dh(e){let t=Jn(`ocx.claude-desktop.v1:${e}`);return typeof t?.data?.port==`number`?t.data.port:null}function fh({apiBase:e,active:t=!0}){let[n,r]=(0,_.useState)(uh),i=Z(),a=(0,_.useRef)(null),o=(0,_.useRef)(null),s=dh(e),[c,l]=(0,_.useState)(null),u=c?.base===e?c.port:s,d=c?.base===e,f=(0,_.useCallback)(t=>{l(n=>n?.base===e&&n.port===t?n:{base:e,port:t})},[e]);(0,_.useEffect)(()=>{let e=()=>r(uh());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let p=e=>{nt(e===`desktop`?lh:ch),r(e),window.requestAnimationFrame(()=>{(e===`code`?a:o).current?.focus({preventScroll:!0})})},m=e=>{e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),p(n===`code`?`desktop`:`code`)):e.key===`Home`?(e.preventDefault(),p(`code`)):e.key===`End`&&(e.preventDefault(),p(`desktop`))};return(0,z.jsxs)(`section`,{className:`claude-page`,children:[(0,z.jsxs)(`div`,{className:`claude-page-intro`,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:i(n===`code`?`claude.pageTitle`:`claudeDesktop.title`)})}),n===`code`?(0,z.jsx)(`p`,{className:`page-sub`,children:i(`claude.subtitle`)}):(0,z.jsx)(`p`,{className:`page-sub`,children:u==null?i(d?`claudeDesktop.loadFail`:`claudeDesktop.loading`):i(`claudeDesktop.subtitle`,{port:u})})]}),(0,z.jsxs)(`div`,{className:`claude-tabs`,role:`tablist`,"aria-label":i(`claude.tabsLabel`),children:[(0,z.jsx)(`button`,{type:`button`,role:`tab`,ref:a,"aria-selected":n===`code`,"aria-controls":`claude-code-panel`,id:`claude-code-tab`,className:n===`code`?`active`:``,tabIndex:n===`code`?0:-1,onKeyDown:m,onClick:()=>p(`code`),children:i(`claude.tabCode`)}),(0,z.jsx)(`button`,{type:`button`,role:`tab`,ref:o,"aria-selected":n===`desktop`,"aria-controls":`claude-desktop-panel`,id:`claude-desktop-tab`,className:n===`desktop`?`active`:``,tabIndex:n===`desktop`?0:-1,onKeyDown:m,onClick:()=>p(`desktop`),children:i(`claude.tabDesktop`)})]}),(0,z.jsx)(`div`,{id:`claude-code-panel`,role:`tabpanel`,"aria-labelledby":`claude-code-tab`,hidden:n!==`code`,children:(0,z.jsx)(Gm,{apiBase:e,active:t&&n===`code`},e)}),(0,z.jsx)(`div`,{id:`claude-desktop-panel`,role:`tabpanel`,"aria-labelledby":`claude-desktop-tab`,hidden:n!==`desktop`,children:(0,z.jsx)(sh,{apiBase:e,active:t&&n===`desktop`,onPortChange:f},e)})]})}function ph(e,t,n,r){let i=e.filter(e=>r===`native`===e.native).map(e=>({...e,alias:t.get(e.id)??null,enabled:!n.has(e.id)})).toSorted((e,t)=>Number(!e.enabled)-Number(!t.enabled));return{rows:i,total:i.length,enabled:i.filter(e=>e.enabled).length}}var mh=Xm(`ocx.grok.collapsedGroups.v2`),hh=[{id:`native`,tkey:`grok.groupNative`},{id:`routed`,tkey:`grok.groupRouted`}],gh=new Set(hh.map(e=>e.id));function _h(e,t){return e?e>=1048576?t(`claudeDesktop.contextM`,{n:Math.round(e/1048576)}):e>=1e6?t(`claudeDesktop.contextM`,{n:e/1e6}):t(`claudeDesktop.contextK`,{n:Math.round(e/1e3)}):`—`}function vh({apiBase:e,active:t=!0}){let n=Z(),r=`ocx.grok.status.v1:${e}`,i=Jn(r),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(()=>mh.read()??new Set(gh)),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(``),h=(0,_.useCallback)(async t=>{let i=await Ct(await fetch(`${e}/api/grok`,{signal:t}),n(`grok.loadFail`));if(!i)throw Error(n(`grok.loadFail`));let a={...i,candidates:i.candidates??[],excluded:i.excluded??[]};return Yn(r,a),a},[e,r,n]),g=`grok-status:${e}`,v=Zs(g,[e],h,{isEmpty:()=>!1,initialData:i??void 0,enabled:t}),{state:y}=v,b=v.refresh,x=y.data??i,S=(0,_.useMemo)(()=>new Set(x?.excluded??[]),[x]),C=a??S,w=(0,_.useMemo)(()=>a!==null&&(a.size!==S.size||[...a].some(e=>!S.has(e))),[a,S]),T=(0,_.useMemo)(()=>new Map((x?.models??[]).map(e=>[e.id,e.alias])),[x]),E=e=>{let t=Zm(s,e);mh.write(t),c(t)},D=e=>{let t=e?new Set(hh.map(e=>e.id)):new Set;mh.write(t),c(t)},O=(e,t)=>{o(n=>{let r=new Set(n??S);return t?r.delete(e):r.add(e),r})},k=async t=>{if(!l){u(`save`),f(null);try{await Ct(await fetch(`${e}/api/grok/selection`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({excluded:[...C]})}),n(`grok.saveFailed`));let i=[...C];if(x&&L(g,{...x,excluded:i}),o(null),t){u(`apply`);let t=await fetch(`${e}/api/grok/apply`,{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??e.error??n(`grok.applyFailed`))}let r=await t.json().catch(()=>({}));r.skippedReason?(f({tone:`err`,text:r.message??n(`grok.applySkipped`)}),m(r.message??n(`grok.applySkipped`))):(f({tone:`ok`,text:n(`grok.savedApplied`)}),m(n(`grok.savedApplied`))),await b()}else f({tone:`ok`,text:n(`grok.saved`)}),m(n(`grok.saved`)),x&&Yn(r,{...x,excluded:i})}catch(e){let t=e instanceof Error?e.message:n(`grok.saveFailed`);f({tone:`err`,text:t}),m(t)}finally{u(null)}}};if(y.showSkeleton&&!x)return(0,z.jsx)(`section`,{className:`grok-page`,children:(0,z.jsx)($s,{label:n(`grok.loading`),rows:4})});if(y.kind===`failed-cold`){let e=y.error instanceof Error?y.error.message:n(`grok.loadFail`);return(0,z.jsxs)(`section`,{className:`grok-page`,children:[(0,z.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:e}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>b(),children:n(`common.retry`)})]})}return(0,z.jsxs)(`section`,{className:`grok-page`,"aria-busy":y.refreshing||void 0,children:[(0,z.jsx)(`h2`,{className:`page-title`,children:n(`grok.title`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:n(`grok.subtitle`)}),(0,z.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:p}),d&&(0,z.jsx)(Q,{tone:d.tone,children:d.text}),y.showError&&(0,z.jsx)(Q,{tone:`err`,children:n(`grok.loadFail`)}),x&&x.candidates.length>0&&(0,z.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,z.jsx)(`span`,{className:`claude-dirty${w?` active`:``}`,children:n(w?`grok.unsaved`:`grok.upToDate`)}),(0,z.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!w||l!==null,onClick:()=>void k(!1),children:n(l===`save`?`grok.saving`:`common.save`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!w||l!==null,onClick:()=>void k(!0),children:n(l===`apply`?`grok.applying`:l===`save`?`grok.saving`:`grok.saveApply`)})]})]}),x?.present?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grok-endpoint`,children:[(0,z.jsx)(`span`,{children:n(`grok.endpoint`)}),(0,z.jsx)(`code`,{children:x.baseUrl??`—`})]}),(0,z.jsx)(`p`,{className:`page-sub`,children:(0,z.jsx)(`code`,{children:x.configPath})})]}):(0,z.jsxs)(_t,{title:n(`grok.notConfiguredTitle`),children:[n(`grok.notConfiguredHint`),(0,z.jsx)(`br`,{}),(0,z.jsx)(`code`,{children:x?.configPath})]}),x&&x.candidates.length>0&&(0,z.jsxs)(`div`,{className:`ocx-group-stack`,children:[(0,z.jsxs)(`div`,{className:`row`,style:{gap:6,margin:`2px 0 10px`},children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>D(!0),disabled:l!==null,children:[(0,z.jsx)(pe,{width:12,height:12,"aria-hidden":`true`}),` `,n(`models.collapseAll`)]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>D(!1),disabled:l!==null,children:[(0,z.jsx)(pe,{width:12,height:12,"aria-hidden":`true`,style:{transform:`rotate(90deg)`}}),` `,n(`models.expandAll`)]})]}),hh.map(e=>{let t=ph(x.candidates,T,C,e.id);if(t.total===0)return null;let r=s.has(e.id);return(0,z.jsxs)(`section`,{className:`ocx-group${r?` collapsed`:``}`,"aria-labelledby":`grok-group-${e.id}`,children:[(0,z.jsx)(`header`,{className:`ocx-group-head${r?``:` open`}`,children:(0,z.jsx)(`h3`,{id:`grok-group-${e.id}`,className:`ocx-group-heading`,children:(0,z.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!r,"aria-controls":`grok-group-body-${e.id}`,onClick:()=>E(e.id),children:[(0,z.jsx)(pe,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:r?`none`:`rotate(90deg)`}}),(0,z.jsx)(`span`,{className:`ocx-group-name`,children:n(e.tkey)}),(0,z.jsx)(`span`,{className:`ocx-group-count`,children:n(`grok.enabledCount`,{on:t.enabled,total:t.total})})]})})}),!r&&(0,z.jsx)(`div`,{id:`grok-group-body-${e.id}`,className:`grok-model-list`,children:t.rows.map(e=>(0,z.jsxs)(`div`,{className:`grok-model-row`,children:[(0,z.jsx)(mt,{on:e.enabled,onClick:()=>O(e.id,!e.enabled),disabled:l!==null,label:n(`grok.toggleModel`,{id:e.id})}),(0,z.jsxs)(`span`,{className:`grok-model-names`,children:[(0,z.jsx)(`strong`,{title:e.id,children:e.id}),(0,z.jsx)(`code`,{title:e.alias??void 0,children:e.alias??`—`})]}),(0,z.jsx)(`span`,{className:`claude-model-context`,children:_h(e.contextWindow,n)})]},e.id))})]},e.id)})]})]})}var yh={"not-installed":`integrations.state.notInstalled`,unknown:`integrations.state.unknown`,absent:`integrations.state.absent`,current:`integrations.state.current`,stale:`integrations.state.stale`,conflict:`integrations.state.conflict`,unsafe:`integrations.state.unsafe`},bh={"not-installed":`badge badge-muted`,unknown:`badge badge-muted`,absent:`badge badge-muted`,current:`badge badge-green`,stale:`badge badge-amber`,conflict:`badge integration-badge--danger`,unsafe:`badge integration-badge--danger-outline`};function xh({state:e,installed:t,id:n}){let r=Z(),i=e===`unknown`||e===`not-installed`||t?e:`not-installed`;return(0,z.jsx)(`span`,{id:n,className:bh[i],"data-integration-state":i,children:r(yh[i])})}function Sh({copyKey:e,vars:t}){let n=Z()(e,t),r=t?.path;if(!r||!n.includes(r))return(0,z.jsx)(`p`,{children:n});let[i,...a]=n.split(r);return(0,z.jsxs)(`p`,{children:[i,(0,z.jsx)(`code`,{children:r}),a.join(r)]})}function Ch({copy:e,onConfirm:t,onClose:n}){let r=Z(),i=(0,_.useRef)(null),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(null),l=`integration-consequence-dialog-title`;(0,_.useEffect)(()=>{let e=i.current;return e&&!e.open&&e.showModal(),()=>{e?.open&&e.close()}},[]);let u=(0,_.useCallback)(e=>{e.preventDefault(),a||n()},[n,a]),d=(0,_.useCallback)(async()=>{if(!a){o(!0),c(null);try{await t()}catch(e){c(e instanceof Error?e.message:r(`integrations.error.generic`)),o(!1)}}},[t,a,r]),f=[(0,z.jsx)(Sh,{copyKey:e.changesKey,vars:e.vars},`changes`),(0,z.jsx)(Sh,{copyKey:e.breakageKey,vars:e.vars},`breakage`),(0,z.jsx)(Sh,{copyKey:e.undoKey,vars:e.vars},`undo`)];return e.sideEffectKey&&f.push((0,z.jsx)(Sh,{copyKey:e.sideEffectKey,vars:e.vars},`side-effect`)),(0,z.jsxs)(`dialog`,{ref:i,className:`modal-overlay`,"aria-labelledby":l,onCancel:u,children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":r(`common.close`),tabIndex:-1,onClick:()=>{a||n()}}),(0,z.jsxs)(`div`,{className:`modal-card integration-consequence-dialog`,role:`document`,children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{id:l,children:r(e.titleKey,e.vars)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:n,disabled:a,children:r(`common.close`)})]}),(0,z.jsx)(`div`,{className:`integration-consequence-body`,children:f}),s&&(0,z.jsx)(Q,{tone:`err`,children:s}),(0,z.jsx)(`div`,{className:`modal-actions`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>void d(),disabled:a,children:r(e.confirmKey)})})]})]})}var wh=[`opencode`,`pi`,`omp`,`hermes`,`openclaw`,`kimi`,`gajae`],Th=new Set([`not_installed`,`conflict`,`unsafe`,`non_loopback`,`drift_requires_confirm`,`snapshot_expired`,`write_failed`]),Eh=new Set([`integration_unsafe`,`integration_conflict`,`integration_drift_confirmation_required`,`integration_snapshot_expired`,`integration_mutation_failed`]),Dh=new Set([`absent`,`current`,`stale`,`conflict`,`unsafe`]);function Oh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kh(e){return!Oh(e)||!Th.has(String(e.reason))?!1:typeof e.error==`string`&&Eh.has(String(e.code))&&wh.includes(e.clientId)&&Dh.has(String(e.state))&&typeof e.message==`string`}var Ah=class extends Error{refusal;status;body;constructor(e,t){let n=kh(t)?t:null;super(n?.message??t.error??t.message??String(e)),this.name=`IntegrationApiError`,this.status=e,this.body=t,this.refusal=n}};async function jh(e){try{let t=await e.json();return Oh(t)?t:{}}catch{return{}}}async function Mh(e){if(!e.ok)throw new Ah(e.status,await jh(e));let t=await wt(e);if(t==null)throw new Ah(e.status,{});return t}async function Nh(e,t){return Mh(await fetch(`${e}/api/client-integrations`,{signal:t}))}async function Ph(e,t,n){return Mh(await fetch(`${e}/api/client-integrations/${encodeURIComponent(t)}`,{signal:n}))}async function Fh(e,t,n){let r=t?`?client=${encodeURIComponent(t)}`:``;return Mh(await fetch(`${e}/api/client-integrations/journal${r}`,{signal:n}))}async function Ih(e,t,n,r){return Mh(await fetch(`${e}/api/client-integrations/${encodeURIComponent(t)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n}),signal:r}))}async function Lh(e,t,n=!1,r){return Mh(await fetch(`${e}/api/client-integrations/restore`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({opId:t,confirmDrift:n}),signal:r}))}async function Rh(e){try{let t=await e;return t.ok?await wt(t)??null:null}catch{return null}}async function zh(e,t){let n=await Rh(fetch(`${e}/api/startup-health`,{signal:t}));return n?{routingInjected:n.routingInjected===!0,status:typeof n.status==`string`?n.status:void 0,recommendedCommand:typeof n.recommendedCommand==`string`?n.recommendedCommand:null}:null}async function Bh(e,t){let n=await fetch(`${e}/api/keys`,{signal:t});if(!n.ok)throw Error(`/api/keys responded ${n.status}`);let r=await wt(n);if(!r||!Array.isArray(r.keys))throw Error(`/api/keys returned an unexpected body`);return r.keys.length}async function Vh(e,t){let n=await Rh(fetch(`${e}/api/claude-code`,{signal:t}));return n?{enabled:n.enabled===!0,authMode:typeof n.authMode==`string`?n.authMode:void 0}:null}async function Hh(e,t){let n=await Rh(fetch(`${e}/api/claude-desktop/status`,{signal:t}));return!n||typeof n.desiredEnabled!=`boolean`||typeof n.installed!=`boolean`||typeof n.observedKind!=`string`?null:{desiredEnabled:n.desiredEnabled,installed:n.installed,observedKind:n.observedKind,applied:n.applied===!0,stale:n.stale===!0,activeProfile:typeof n.activeProfile==`boolean`?n.activeProfile:null,appliedAt:typeof n.appliedAt==`string`?n.appliedAt:null}}async function Uh(e,t){let n=await Rh(fetch(`${e}/api/grok`,{signal:t}));return n?{present:n.present===!0,models:Array.isArray(n.models)?n.models:[]}:null}var Wh=new Set([`claude`,`grok`,`codex`,`claude-desktop`]),Gh=new Set([`native_integration_refused`,`native_integration_failed`]),Kh=new Set([`not_installed`,`orphaned_marker`,`home_mismatch`,`config_busy`,`write_failed`,`metadata_unreadable`,`cleanup_incomplete`,`desired_state_changed`]);function qh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Jh(e){return qh(e)?typeof e.error==`string`&&Gh.has(String(e.code))&&Wh.has(String(e.clientId))&&Kh.has(String(e.reason))&&typeof e.message==`string`:!1}var Yh=class extends Error{refusal;status;body;constructor(e,t){let n=Jh(t)?t:null;super(n?.message??t.error??t.message??String(e)),this.name=`NativeApiError`,this.status=e,this.body=t,this.refusal=n}};async function Xh(e){try{let t=await e;return t.ok?await wt(t)??null:null}catch{return null}}async function Zh(e){try{let t=await e.json();return qh(t)?t:{}}catch{return{}}}async function Qh(e){if(!e.ok)throw new Yh(e.status,await Zh(e));let t=await wt(e);if(t==null)throw new Yh(e.status,{});return t}function $h(e,t){return Xh(fetch(`${e}/api/native-integrations`,{signal:t}))}async function eg(e,t,n,r){return Qh(await fetch(`${e}/api/native-integrations/${encodeURIComponent(t)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n}),signal:r}))}var tg={integration_mutation_busy:`integrations.error.busy`};function ng(e){return e instanceof Ah?e.refusal:null}function rg(e){return e instanceof Yh?e.refusal:null}function ig(e){return e===`conflict`?`integrations.error.conflict`:e===`unsafe`?`integrations.error.unsafe`:e===`non_loopback`?`integrations.error.nonLoopback`:`integrations.error.generic`}var ag=new Set([`non_loopback`]);function og(e,t,n){return t.reason===`orphaned_marker`?e(`integrations.native.error.orphanedMarker`,{path:n??``}):t.reason===`home_mismatch`?`${e(`integrations.native.error.homeMismatch`)} ${t.message}`:t.reason===`not_installed`?e(`integrations.native.error.notInstalled`):t.reason===`config_busy`?e(`integrations.native.error.configBusy`):t.reason===`metadata_unreadable`?e(`integrations.native.error.desktopUnsafeMetadata`,{path:n??``}):t.reason===`cleanup_incomplete`?e(`integrations.native.error.desktopCleanupIncomplete`,{paths:(t.residualPaths??[]).join(`, `)}):t.message||e(`integrations.error.generic`)}function sg(e,t,n,r){let i=rg(t);if(i)return og(e,i,r);let a=ng(t);if(!a){let r=tg[t instanceof Ah?String(t.body.code??``):``];return r?e(r):t instanceof Error&&t.message?t.message:n??e(`integrations.error.generic`)}let o=ag.has(a.reason)?e(ig(a.reason),{client:a.clientId}):a.message||e(ig(a.reason));return a.snapshotPath?e(a.residual?`integrations.error.residual`:`integrations.error.recover`,{message:o,path:a.snapshotPath}):a.reason===`conflict`||a.reason===`unsafe`?`${e(ig(a.reason))} ${o}`:o}function cg({apiBase:e,row:t,onClose:n,onRestored:r}){let i=Z(),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null),d=async()=>{if(!s){c(!0),u(null);try{await Lh(e,t.opId,a),r(),n()}catch(e){if(ng(e)?.reason===`drift_requires_confirm`){o(!0),c(!1);return}u(sg(i,e)),c(!1)}}};return(0,z.jsx)(`dialog`,{className:`modal-overlay`,open:!0,style:{display:`flex`,border:`none`,margin:0,maxWidth:`none`,maxHeight:`none`,width:`100%`,height:`100%`},"aria-labelledby":`integration-restore-title`,onCancel:e=>{e.preventDefault(),n()},children:(0,z.jsxs)(`div`,{className:`modal-card integration-restore-dialog`,children:[(0,z.jsx)(`div`,{className:`modal-head`,children:(0,z.jsx)(`h3`,{id:`integration-restore-title`,children:i(a?`integrations.restore.driftTitle`:`integrations.restore.title`)})}),(0,z.jsx)(`div`,{className:`modal-desc`,children:i(a?`integrations.restore.driftBody`:`integrations.restore.body`)}),(0,z.jsx)(`p`,{className:`integration-path`,children:t.configPath}),l&&(0,z.jsx)(Q,{tone:`err`,children:l}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:n,disabled:s,children:i(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>void d(),disabled:s,children:i(s?`integrations.restore.pending`:a?`integrations.restore.confirmDrift`:`integrations.restore.confirm`)})]})]})})}var lg={opencode:`integrations.tab.opencode`,pi:`integrations.tab.pi`,omp:`integrations.tab.omp`,hermes:`integrations.tab.hermes`,openclaw:`integrations.tab.openclaw`,kimi:`integrations.tab.kimi`,gajae:`integrations.tab.gajae`};function ug(e){return e===`current`||e===`stale`}function dg(e){let t={id:`codex`,hash:`integrations/codex`,labelKey:`integrations.tab.codex`,toggle:`codex`,toggleBlocked:null,togglePath:null,status:null,detail:null,detailVars:null};return e?e.routingInjected===!0?{...t,state:e.status===`error`?`stale`:`current`,installed:!0,applied:!0,detailKey:`integrations.detail.codexRouted`}:{...t,state:`absent`,installed:!0,applied:!1,detail:e.recommendedCommand??null,detailKey:e.recommendedCommand?null:`integrations.detail.codexAbsent`}:{...t,state:`unknown`,installed:!1,applied:!1,detailKey:null}}function fg(e,t){let n={hash:`integrations/keys`,labelKey:`integrations.tab.keys`};return e===`checking`?{...n,state:`checking`,detailKey:`integrations.detail.keyChecking`,detailVars:null}:e===`unavailable`||t===null?{...n,state:`unavailable`,detailKey:`integrations.detail.keyUnavailable`,detailVars:null}:{...n,state:t>0?`issued`:`none-issued`,detailKey:t>0?`integrations.detail.keyCount`:`integrations.detail.keyNone`,detailVars:t>0?{count:String(t)}:null}}function pg(e){return e?e.enabled===!0?e.authMode===`subscription`?`claude.authModeSubscription`:e.authMode===`proxy`?`claude.authModeProxy`:e.authMode===`auto`?`claude.authModeAuto`:null:`integrations.detail.claudeOff`:null}function mg(e,t,n){let r={id:`claude`,hash:`integrations/claude`,labelKey:`integrations.tab.claude`,toggle:`claude`,toggleBlocked:t?.disableBlocked??null,togglePath:t?.configPath??null,status:null,detail:null,detailVars:null},i=pg(e);if(n===void 0){if(!e)return{...r,state:`unknown`,installed:!1,applied:!1,detailKey:i};let t=e.enabled===!0;return{...r,state:t?`current`:`absent`,installed:!0,applied:t,detailKey:i}}return n?t?{...r,state:t.state,installed:t.installed,applied:t.state===`current`,detailKey:i}:{...r,toggle:null,state:`unknown`,installed:!1,applied:!1,detailKey:i}:{...r,state:`unknown`,installed:!1,applied:!1,detailKey:i}}function hg(e,t,n){let r={id:`claudeDesktop`,hash:`integrations/claude/desktop`,labelKey:`claudeDesktop.title`,toggle:`claude-desktop`,toggleBlocked:t?.disableBlocked??null,togglePath:t?.configPath??null,status:null,detail:null,detailVars:null};if(!e||!n||!t||typeof e.desiredEnabled!=`boolean`)return{...r,toggle:null,state:`unknown`,installed:!1,applied:!1,detailKey:null};let i=e.desiredEnabled;if(e.applied!==!0)return{...r,state:`absent`,installed:e.installed===!0,applied:!1,toggleOn:i,detailKey:i?`integrations.detail.desktopDesiredOnNotApplied`:`integrations.detail.desktopDesiredOff`};let a=e.stale===!0||e.activeProfile===!1;return{...r,state:a?`stale`:`current`,installed:!0,applied:!0,toggleOn:i,detailKey:e.activeProfile===!1?`integrations.detail.desktopNotServed`:a?`integrations.detail.desktopStale`:`integrations.detail.desktopCurrent`}}function gg(e){if(!e)return{detailKey:null,detailVars:null};let t=e.present===!0;return{detailKey:t?`integrations.detail.grokModels`:`integrations.detail.grokAbsent`,detailVars:t?{count:String(e.models?.length??0)}:null}}function _g(e,t,n){let r={id:`grok`,hash:`integrations/grok`,labelKey:`integrations.tab.grok`,toggle:`grok`,toggleBlocked:t?.disableBlocked??null,togglePath:t?.configPath??null,status:null,detail:null},i=gg(e);if(n===void 0){if(!e)return{...r,state:`unknown`,installed:!1,applied:!1,...i};let t=e.present===!0;return{...r,state:t?`current`:`absent`,installed:t,applied:t,...i}}return n?t?{...r,state:t.state,installed:t.installed,applied:t.state===`current`,...i}:{...r,toggle:null,state:`unknown`,installed:!1,applied:!1,...i}:{...r,state:`unknown`,installed:!1,applied:!1,...i}}function vg(e){return{id:e.clientId,hash:`integrations/${e.clientId}`,labelKey:lg[e.clientId],state:e.installed?e.state:`not-installed`,installed:e.installed,applied:e.installed&&ug(e.state),detail:e.configPath,detailKey:null,detailVars:null,toggle:e.clientId,toggleBlocked:null,togglePath:e.configPath,status:e}}function yg(e){let t=e.native?.find(e=>e.clientId===`claude`),n=e.native?.find(e=>e.clientId===`grok`),r=new Map(e.clients.map(e=>[e.clientId,e])),i=[dg(e.codex),mg(e.claude,t,e.nativeSettled),hg(e.claudeDesktop,e.native?.find(e=>e.clientId===`claude-desktop`),e.nativeSettled),_g(e.grok,n,e.nativeSettled)];for(let t of wh){let n=r.get(t);if(n){i.push(vg(n));continue}e.clientsSettled||i.push({id:t,hash:`integrations/${t}`,labelKey:lg[t],state:`unknown`,installed:!1,applied:!1,detail:null,detailKey:null,detailVars:null,toggle:null,toggleBlocked:null,togglePath:null,status:null})}return{keysRow:fg(e.keyPhase,e.keyCount),rows:i}}function bg(e){return{detected:e.filter(e=>e.installed).length,applied:e.filter(e=>e.applied).length,stale:e.filter(e=>e.state===`stale`).length,unknown:e.filter(e=>e.state===`unknown`).length}}var xg={titleKey:`integrations.dialog.grok.title`,changesKey:`integrations.dialog.grok.changes`,breakageKey:`integrations.dialog.grok.breakage`,undoKey:`integrations.dialog.grok.undo`,confirmKey:`integrations.dialog.grok.confirm`},Sg={titleKey:`integrations.dialog.desktop.title`,changesKey:`integrations.dialog.desktop.changes`,breakageKey:`integrations.dialog.desktop.breakage`,undoKey:`integrations.dialog.desktop.undo`,sideEffectKey:`integrations.dialog.desktop.restart`,confirmKey:`integrations.dialog.desktop.confirm`},Cg={apply:`integrations.kind.apply`,disable:`integrations.kind.disable`,refresh:`integrations.kind.refresh`,restore:`integrations.kind.restore`};function wg(e){return e.state===`current`||e.state===`stale`}function Tg({row:e,pending:t,result:n,onOpen:r,onToggle:i}){let a=Z(),o=e.detail??(e.detailKey?a(e.detailKey,e.detailVars??void 0):null),s=e.toggleBlocked!==null&&(e.applied||e.toggleBlocked.reason===`orphaned_marker`),c=s&&e.toggleBlocked&&(e.toggle===`claude`||e.toggle===`grok`)?sg(a,new Yh(409,{error:`native integration change refused`,code:`native_integration_refused`,clientId:e.toggle,reason:e.toggleBlocked.reason,message:e.toggleBlocked.message}),void 0,e.togglePath??void 0):null;return(0,z.jsxs)(`li`,{className:`integration-card`,"data-client":e.id,children:[(0,z.jsxs)(`div`,{className:`integration-card-head`,children:[(0,z.jsx)(`h4`,{children:(0,z.jsx)(`button`,{type:`button`,className:`integration-card-link`,onClick:r,children:a(e.labelKey)})}),(0,z.jsx)(xh,{state:e.state,installed:e.installed})]}),o&&(0,z.jsx)(`p`,{className:e.detail?`integration-path`:`integration-meta`,children:o}),n?.tone===`err`&&(0,z.jsx)(Q,{tone:`err`,children:n.text}),n?.tone===`ok`&&(0,z.jsx)(Q,{tone:`ok`,children:n.text}),(0,z.jsxs)(`div`,{className:`integration-card-actions`,children:[e.toggle&&i&&(0,z.jsxs)(`div`,{className:`integration-toggle-control`,children:[(0,z.jsx)(mt,{on:e.toggleOn??e.applied,onClick:i,disabled:e.state===`unknown`||!e.installed||e.state===`conflict`||e.state===`unsafe`||s||t,label:e.applied?a(`integrations.action.disable`):a(`integrations.action.apply`)}),c&&(0,z.jsx)(`p`,{className:`integration-toggle-blocked`,children:c})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:r,tabIndex:-1,children:a(`integrations.action.settings`)})]})]})}function Eg({apiBase:e,active:t=!0}){let n=Z(),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)({}),[d,f]=(0,_.useState)(null),p=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(d!==null)return;let e=p.current;e&&(p.current=null,e.isConnected&&e.focus())},[d]);let m=(0,_.useCallback)(async t=>(await Nh(e,t)).clients,[e]),h=(0,_.useCallback)(async t=>(await Fh(e,void 0,t)).operations,[e]),g=(0,_.useCallback)(t=>zh(e,t),[e]),v=(0,_.useCallback)(t=>Bh(e,t),[e]),y=(0,_.useCallback)(t=>Vh(e,t),[e]),b=(0,_.useCallback)(t=>Hh(e,t),[e]),x=(0,_.useCallback)(t=>Uh(e,t),[e]),S=(0,_.useCallback)(async t=>(await $h(e,t))?.clients??null,[e]),C=Zs(`integration-states:${e}`,[e],m,{isEmpty:e=>e.length===0,enabled:t}),w=Zs(`integration-journal-all:${e}`,[e],h,{isEmpty:e=>e.length===0,enabled:t}),T=Zs(`integration-codex:${e}`,[e],g,{isEmpty:e=>e===null,enabled:t}),E=Zs(`integration-keys:${e}`,[e],v,{isEmpty:()=>!1,enabled:t}),D=Zs(`integration-claude:${e}`,[e],y,{isEmpty:e=>e===null,enabled:t}),O=Zs(`integration-claude-desktop:${e}`,[e],b,{isEmpty:e=>e===null,enabled:t}),k=Zs(`integration-grok:${e}`,[e],x,{isEmpty:e=>e===null,enabled:t}),A=Zs(`integration-native:${e}`,[e],S,{isEmpty:e=>e===null,enabled:t}),j=C.state.data??[],M=w.state.data??[],N=j.filter(wg),P=j.filter(e=>e.installed),F=C.state.kind!==`cold`&&C.state.kind!==`retrying-cold`,I=A.state.data??null,L=I!==null,R=E.state.kind===`cold`||E.state.kind===`retrying-cold`?`checking`:E.state.kind===`failed-cold`||E.state.kind===`failed-with-stale`?`unavailable`:`settled`,{keysRow:B,rows:V}=yg({clients:j,clientsSettled:F,codex:T.state.data??null,keyCount:E.state.data??null,keyPhase:R,claude:D.state.data??null,claudeDesktop:O.state.data??null,grok:k.state.data??null,native:I,nativeSettled:L}),H=bg(V),U=()=>{C.refresh(),w.refresh(),T.refresh(),E.refresh(),D.refresh(),O.refresh(),k.refresh(),A.refresh()},W=async()=>{if(r||N.length===0)return;let t=[n(`integrations.bulk.title`),n(`integrations.bulk.body`)].join(`
|
|
75
75
|
|
|
76
|
-
`);if(!confirm(t))return;i(!0),o(null);let a=[];for(let t of N)try{await Ih(e,t.clientId,!1)}catch(e){a.push(`${t.clientId}: ${sg(n,e)}`)}let s=!1;try{s=(await Nh(e)).clients.some(wg)}catch{a.push(n(`integrations.error.stale`))}s&&a.length===0&&a.push(n(`integrations.error.stale`)),U(),i(!1),o(a.length===0?{tone:`ok`,text:n(`integrations.bulk.success`)}:{tone:`err`,text:n(`integrations.bulk.partial`,{clients:a.join(`; `)})})},G=M[0]?.at,[ee,te]=(0,_.useState)(null),ne=()=>{A.refresh(),D.refresh(),k.refresh()},K=(e,t)=>{u(n=>{let r={...n};return t?r[e]=t:delete r[e],r})},q=async(t,r)=>{if(!ee&&t.toggle){te(t.id),K(t.id,null);try{if(t.status)await Ih(e,t.status.clientId,r),U();else if(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`){let i=await eg(e,t.toggle,r);i.reason===`non_loopback_removed`?K(t.id,{tone:`ok`,text:n(i.changed?`integrations.native.msg.nonLoopbackRemoved`:`integrations.native.msg.nonLoopbackRemovedNoop`)}):i.reason===`non_loopback_superseded`&&K(t.id,{tone:`ok`,text:n(`integrations.native.msg.nonLoopbackSuperseded`)}),ne()}}catch(e){K(t.id,{tone:`err`,text:sg(n,e,void 0,t.togglePath??void 0)}),(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`)&&ne()}finally{te(null)}}},J=(e,t)=>{if(e.status||t||e.id===`claude`||e.toggle===null){q(e,t);return}let n=document.activeElement;p.current=n?.tagName===`BUTTON`?n:null,f(e)};return(0,z.jsxs)(`section`,{className:`integrations-overview`,children:[(0,z.jsxs)(`div`,{className:`integration-summary`,children:[(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.detected`)}),(0,z.jsx)(`strong`,{children:H.detected})]}),(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.applied`)}),(0,z.jsx)(`strong`,{children:H.applied})]}),(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.stale`)}),(0,z.jsx)(`strong`,{children:H.stale})]}),H.unknown>0&&(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.state.unknown`)}),(0,z.jsx)(`strong`,{children:H.unknown})]}),(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.lastChange`)}),(0,z.jsx)(`strong`,{children:G?new Date(G).toLocaleString():n(`integrations.status.unknown`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void W(),disabled:r||N.length===0,children:n(`integrations.summary.disableAll`)})]}),(0,z.jsx)(Dg,{row:B}),(0,z.jsx)(`p`,{className:`page-sub`,children:n(`integrations.onboarding`)}),C.state.kind===`failed-cold`&&(0,z.jsx)(Q,{tone:`err`,children:n(`integrations.error.load`)}),C.state.kind===`failed-with-stale`&&(0,z.jsx)(Q,{tone:`err`,children:n(`integrations.error.stale`)}),a&&(0,z.jsx)(Q,{tone:a.tone,children:a.text}),V.length===0?C.state.kind===`failed-cold`?null:(0,z.jsx)(`p`,{className:`page-sub`,children:n(`common.loading`)}):(0,z.jsx)(`ul`,{className:`integration-cards`,children:V.map(e=>(0,z.jsx)(Tg,{row:e,pending:ee!==null,result:l[e.id]??null,onOpen:()=>nt(e.hash),onToggle:e.toggle?()=>J(e,!(e.toggleOn??e.applied)):null},e.id))}),F&&P.length===0&&(0,z.jsxs)(`div`,{className:`integration-empty`,children:[(0,z.jsx)(`h4`,{children:n(`integrations.empty.title`)}),(0,z.jsx)(`p`,{children:n(`integrations.empty.body`)})]}),(0,z.jsx)(`h4`,{children:n(`integrations.rollback.title`)}),M.length===0?(0,z.jsxs)(`div`,{className:`integration-empty`,children:[(0,z.jsx)(`p`,{children:n(`integrations.rollback.empty`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:n(`integrations.rollback.emptyBody`)})]}):(0,z.jsx)(`ul`,{className:`integration-history`,children:M.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`span`,{className:`integration-history-kind`,children:n(Cg[e.kind])}),(0,z.jsx)(`span`,{className:`integration-history-client`,children:e.clientId}),(0,z.jsx)(`span`,{className:`integration-history-at`,children:new Date(e.at).toLocaleString()}),e.snapshot===`expired`?(0,z.jsx)(`span`,{className:`badge badge-muted`,children:n(`integrations.action.snapshotExpired`)}):(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>c(e),children:e.undoable?n(`integrations.action.undo`):n(`integrations.action.restorePoint`)})]},e.opId))}),s&&(0,z.jsx)(cg,{apiBase:e,row:s,onClose:()=>c(null),onRestored:U}),d&&(0,z.jsx)(Ch,{copy:{...d.toggle===`claude-desktop`?Sg:xg,vars:{path:d.togglePath??``}},onClose:()=>f(null),onConfirm:async()=>{await q(d,!1),f(null)}})]})}function Dg({row:e}){let t=Z(),n=e.detailKey?t(e.detailKey,e.detailVars??void 0):null;return(0,z.jsxs)(`div`,{className:`integration-api-keys-row`,"data-client":`keys`,"data-key-state":e.state,children:[(0,z.jsxs)(`div`,{className:`integration-api-keys-copy`,children:[(0,z.jsx)(`h4`,{children:t(e.labelKey)}),n&&(0,z.jsx)(`p`,{className:`integration-meta`,children:n})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>nt(e.hash),children:t(`integrations.action.manageKeys`)})]})}var Og={opencode:`integrations.semantics.opencode`,pi:`integrations.semantics.pi`,omp:`integrations.semantics.omp`,hermes:`integrations.semantics.hermes`,openclaw:`integrations.semantics.openclaw`,kimi:`integrations.semantics.kimi`,gajae:`integrations.semantics.gajae`},kg={opencode:`integrations.tab.opencode`,pi:`integrations.tab.pi`,omp:`integrations.tab.omp`,hermes:`integrations.tab.hermes`,openclaw:`integrations.tab.openclaw`,kimi:`integrations.tab.kimi`,gajae:`integrations.tab.gajae`},Ag={apply:`integrations.kind.apply`,disable:`integrations.kind.disable`,refresh:`integrations.kind.refresh`,restore:`integrations.kind.restore`};function jg({apiBase:e,client:t,active:n=!0}){let r=Z(),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),u=(0,_.useCallback)(n=>Ph(e,t,n),[e,t]),d=(0,_.useCallback)(async n=>(await Fh(e,t,n)).operations,[e,t]),f=Zs(`integration-state:${e}:${t}`,[e,t],u,{isEmpty:()=>!1,enabled:n}),p=Zs(`integration-journal:${e}:${t}`,[e,t],d,{isEmpty:e=>e.length===0,enabled:n}),m=f.state.data??null,h=p.state.data??[],g=()=>{f.refresh(),p.refresh()},v=async n=>{if(!(!m||i)){a(!0),s(null);try{await Ih(e,t,n),g()}catch(e){s(sg(r,e))}finally{a(!1)}}},y=()=>void v(!(m&&(m.state===`current`||m.state===`stale`)));if(!m)return(0,z.jsx)(`section`,{className:`integration-client-page`,children:f.state.kind===`failed-cold`?(0,z.jsx)(Q,{tone:`err`,children:r(`integrations.error.load`)}):(0,z.jsx)(`p`,{className:`page-sub`,children:r(`common.loading`)})});let b=m.state===`current`||m.state===`stale`,x=!m.installed||m.state===`conflict`||m.state===`unsafe`;return(0,z.jsxs)(`section`,{className:`integration-client-page`,children:[(0,z.jsxs)(`div`,{className:`integration-client-head`,children:[(0,z.jsx)(`h3`,{children:r(kg[t])}),(0,z.jsx)(xh,{state:m.state,installed:m.installed,id:`integration-state-${t}`}),(0,z.jsx)(mt,{on:b,onClick:y,disabled:x||i,label:r(b?`integrations.action.disable`:`integrations.action.apply`)})]}),m.state===`stale`&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void v(!0),disabled:i,children:r(`integrations.action.refresh`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:r(Og[t])}),(0,z.jsx)(`p`,{className:`integration-path`,children:m.configPath}),m.appliedAt&&(0,z.jsxs)(`p`,{className:`integration-meta`,children:[r(`integrations.status.appliedAt`),`: `,new Date(m.appliedAt).toLocaleString()]}),m.retentionDegraded&&(0,z.jsx)(Q,{tone:`err`,children:r(`integrations.retention.degraded`)}),o&&(0,z.jsx)(Q,{tone:`err`,children:o}),(0,z.jsx)(`h4`,{children:r(`integrations.rollback.title`)}),h.length===0?(0,z.jsx)(`p`,{className:`page-sub`,children:r(`integrations.rollback.empty`)}):(0,z.jsx)(`ul`,{className:`integration-history`,children:h.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`span`,{className:`integration-history-kind`,children:r(Ag[e.kind])}),(0,z.jsx)(`span`,{className:`integration-history-at`,children:new Date(e.at).toLocaleString()}),e.snapshot===`expired`?(0,z.jsx)(`span`,{className:`badge badge-muted`,children:r(`integrations.action.snapshotExpired`)}):(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>l(e),children:e.undoable?r(`integrations.action.undo`):r(`integrations.action.restorePoint`)})]},e.opId))}),c&&(0,z.jsx)(cg,{apiBase:e,row:c,onClose:()=>l(null),onRestored:g})]})}var Mg=[{id:`overview`,hash:`integrations`,labelKey:`integrations.tab.overview`},{id:`keys`,hash:`integrations/keys`,labelKey:`integrations.tab.keys`},{id:`codex`,hash:`integrations/codex`,labelKey:`integrations.tab.codex`},{id:`claude`,hash:`integrations/claude`,labelKey:`integrations.tab.claude`},{id:`grok`,hash:`integrations/grok`,labelKey:`integrations.tab.grok`},{id:`opencode`,hash:`integrations/opencode`,labelKey:`integrations.tab.opencode`},{id:`pi`,hash:`integrations/pi`,labelKey:`integrations.tab.pi`},{id:`omp`,hash:`integrations/omp`,labelKey:`integrations.tab.omp`},{id:`hermes`,hash:`integrations/hermes`,labelKey:`integrations.tab.hermes`},{id:`openclaw`,hash:`integrations/openclaw`,labelKey:`integrations.tab.openclaw`},{id:`kimi`,hash:`integrations/kimi`,labelKey:`integrations.tab.kimi`},{id:`gajae`,hash:`integrations/gajae`,labelKey:`integrations.tab.gajae`}],Ng=new Set([`opencode`,`pi`,`omp`,`hermes`,`openclaw`,`kimi`,`gajae`]);function Pg(e=window.location.hash){let t=et(e);return t===`integrations/claude/desktop`?`claude`:Mg.find(e=>e.hash===t)?.id??`overview`}function Fg(e){return`integrations-tab-${e}`}function Ig(e){return`integrations-panel-${e}`}function Lg({apiBase:e}){let t=Z(),[n,r]=(0,_.useState)(Pg),[i,a]=(0,_.useState)(()=>new Set([Pg()])),o=(0,_.useRef)(null);o.current===null&&(o.current=new Map);let s=e=>{r(e),a(t=>t.has(e)?t:new Set([...t,e]))};(0,_.useEffect)(()=>{let e=()=>s(Pg());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let c=(e,t)=>{let n=Mg.find(t=>t.id===e);n&&(nt(n.hash),s(e),t&&window.requestAnimationFrame(()=>{o.current.get(e)?.focus({preventScroll:!0})}))},l=e=>{let t=Mg.findIndex(e=>e.id===n),r=null;e.key===`ArrowLeft`?r=(t-1+Mg.length)%Mg.length:e.key===`ArrowRight`?r=(t+1)%Mg.length:e.key===`Home`?r=0:e.key===`End`&&(r=Mg.length-1),r!==null&&(e.preventDefault(),c(Mg[r].id,!0))};return(0,z.jsxs)(`section`,{className:`integrations-page`,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:t(`nav.integrations`)})}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`integrations.subtitle`)}),(0,z.jsx)(`div`,{className:`page-tabs`,role:`tablist`,"aria-label":t(`integrations.tabsLabel`),children:Mg.map(e=>(0,z.jsx)(`button`,{ref:t=>{t?o.current.set(e.id,t):o.current.delete(e.id)},type:`button`,role:`tab`,id:Fg(e.id),"aria-selected":n===e.id,"aria-controls":Ig(e.id),tabIndex:n===e.id?0:-1,className:`page-tab${n===e.id?` page-tab--active`:``}`,onClick:()=>c(e.id,!0),onKeyDown:l,children:t(e.labelKey)},e.id))}),Mg.map(r=>{if(!i.has(r.id))return null;let a=n===r.id;return(0,z.jsxs)(`div`,{role:`tabpanel`,id:Ig(r.id),"aria-labelledby":Fg(r.id),hidden:!a,children:[r.id===`overview`&&(0,z.jsx)(Eg,{apiBase:e,active:a}),r.id===`keys`&&(0,z.jsx)(wm,{apiBase:e,active:a}),r.id===`codex`&&(0,z.jsxs)(`section`,{className:`integration-native-page`,"aria-labelledby":`codex-integration-title`,children:[(0,z.jsx)(`h3`,{id:`codex-integration-title`,children:t(`integrations.codex.title`)}),(0,z.jsx)(`p`,{children:t(`integrations.codex.body`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>nt(`startup`),children:t(`integrations.codex.openService`)})]}),r.id===`claude`&&(0,z.jsx)(fh,{apiBase:e,active:a}),r.id===`grok`&&(0,z.jsx)(vh,{apiBase:e,active:a}),Ng.has(r.id)&&(0,z.jsx)(jg,{apiBase:e,client:r.id,active:a})]},r.id)})]})}function Rg(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 zg={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},Bg={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},Vg={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function Hg({ok:e,yes:t,no:n}){return(0,z.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function Ug({failed:e,data:t}){let{t:n}=Ze(),r=e?`startup-hero--risk`:t.status===`protected`?`startup-hero--safe`:t.status===`at-risk`?`startup-hero--risk`:`startup-hero--native`,i=e||t.status===`at-risk`?se:q,a=t.routingKind===`opencodex-local`?`startup.routing.proxy`:t.routingKind===`custom-local`?`startup.routing.customLocal`:t.routingKind===`custom-remote`?`startup.routing.customRemote`:t.routingKind===`unknown`?`startup.routing.unknown`:`startup.routing.native`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`section`,{className:`panel startup-hero ${r}`,"aria-live":`polite`,children:[(0,z.jsx)(`div`,{className:`startup-hero-icon`,children:(0,z.jsx)(i,{})}),(0,z.jsxs)(`div`,{className:`startup-hero-copy`,children:[(0,z.jsx)(`span`,{className:`badge ${e||t.status===`at-risk`?`badge-amber`:`badge-green`}`,children:n(e?`startup.status.atRisk`:zg[t.status])}),(0,z.jsx)(`h3`,{children:n(e?`startup.error`:Bg[t.status])}),(0,z.jsx)(`p`,{children:e?n(`startup.staleData`):t.status===`at-risk`?n(Xn(t)):n(`startup.safeDetail`)})]})]}),(0,z.jsxs)(`div`,{className:`startup-state-grid`,children:[(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.routing`)}),(0,z.jsx)(`div`,{className:`value`,children:n(a)})]}),(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.restartProtection`)}),(0,z.jsx)(`div`,{className:`value`,children:n(Vg[t.protection])})]}),(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.preference`)}),(0,z.jsx)(`div`,{className:`value`,children:n(t.autostartEnabled?`startup.enabled`:`startup.disabled`)})]})]})]})}function Wg({data:e,failed:t,loading:n=!1,installBusy:r,installResult:i,onInstall:a}){let{t:o}=Ze(),s=e.serviceSupported&&e.serviceInstalled&&e.serviceStale&&!e.serviceConflict,c=e.shimInstalled&&!e.shimHealthy,l=r!==null||t||n;return(0,z.jsxs)(`section`,{className:`panel startup-details`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:o(`startup.details`)}),(0,z.jsx)(`span`,{className:`muted mono`,children:e.platform})]}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(`startup.service`)}),(0,z.jsx)(`span`,{children:o(`startup.serviceHint`)})]}),(0,z.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,z.jsx)(Hg,{ok:e.serviceViable,yes:o(`startup.viable`),no:o(e.serviceConflict?`startup.conflict`:e.serviceStale?`startup.stale`:e.serviceInstalled?`startup.unhealthy`:e.serviceSupported?`startup.notInstalled`:`startup.unsupported`)}),e.serviceSupported&&!e.serviceInstalled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-service`),children:o(r===`install-service`?`startup.installing`:`startup.install`)}),s&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-service`,{repair:!0}),children:o(r===`install-service`?`startup.repairing`:`startup.repair`)})]})]}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(`startup.shim`)}),(0,z.jsx)(`span`,{children:o(`startup.shimHint`)})]}),(0,z.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,z.jsx)(Hg,{ok:e.shimHealthy&&e.autostartEnabled,yes:o(e.shimCoverage===`cli-only`?`startup.cliOnly`:`startup.healthy`),no:o(e.shimInstalled?e.shimHealthy&&!e.autostartEnabled?`startup.installedDisabled`:`startup.stale`:`startup.notInstalled`)}),!e.shimInstalled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-shim`),children:o(r===`install-shim`?`startup.installing`:`startup.install`)}),c&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-shim`,{repair:!0}),children:o(r===`install-shim`?`startup.repairing`:`startup.repair`)})]})]}),i&&(0,z.jsx)(`div`,{className:`notice ${i.kind===`success`?`notice-ok`:`notice-warn`} startup-action-notice`,role:`status`,"aria-live":`polite`,children:i.kind===`success`?i.action===`install-service`?o(i.repair?`startup.serviceRepaired`:`startup.serviceInstalled`):o(i.repair?`startup.shimRepaired`:`startup.shimInstalled`):`${o(`startup.installFailed`)} ${i.detail??``}`})]})}function Gg({tray:e,trayLoading:t,trayError:n,trayBusy:r,onTrayAction:i}){let{t:a}=Ze();return(0,z.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:a(`startup.tray.title`)}),(0,z.jsx)(X,{})]}),(0,z.jsx)(`p`,{className:`muted`,children:a(`startup.tray.hint`)}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:a(`startup.tray.login`)}),(0,z.jsx)(`span`,{children:a(`startup.tray.notProtection`)})]}),t||n||!e?(0,z.jsx)(`span`,{className:`badge badge-amber`,children:a(t?`startup.tray.loading`:`startup.tray.unavailable`)}):(0,z.jsx)(Hg,{ok:e.running&&!e.stale,yes:a(`startup.tray.running`),no:a(e.stale?`startup.tray.stale`:e.installed?`startup.tray.stopped`:`startup.tray.notInstalled`)})]}),(0,z.jsxs)(`div`,{className:`startup-tray-buttons`,children:[!t&&!n&&e&&!e.installed&&!e.stale&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`install`),children:a(`startup.tray.install`)}),!t&&!n&&e?.installed&&!e.stale&&!e.running&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`start`),children:a(`startup.tray.start`)}),!t&&!n&&e?.running&&!e.stale&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:r,onClick:()=>i(`stop`),children:a(`startup.tray.stop`)}),!t&&!n&&e&&(e.installed||e.stale)&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-danger`,disabled:r,onClick:()=>{window.confirm(a(`startup.tray.uninstall`))&&i(`uninstall`)},children:a(`startup.tray.uninstall`)})]}),(n||e?.stale)&&(0,z.jsx)(`div`,{className:`notice notice-warn startup-tray-error`,role:`alert`,children:a(`startup.tray.error`)})]})}function Kg({data:e,copied:t,onCopy:n}){let{t:r}=Ze(),i=e.serviceInstalled&&!e.serviceConflict?e.commands.repairService:e.commands.installService;return(0,z.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:r(`startup.recovery`)}),(0,z.jsx)(te,{})]}),(0,z.jsx)(`p`,{className:`muted`,children:r(`startup.recoveryHint`)}),(0,z.jsxs)(`div`,{className:`startup-command-list`,children:[e.serviceSupported&&(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.service`)}),(0,z.jsx)(`code`,{children:i})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(i),children:r(t===i?`startup.copied`:`startup.copy`)})]}),(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.shim`)}),(0,z.jsx)(`code`,{children:e.commands.installShim})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.installShim),children:t===e.commands.installShim?r(`startup.copied`):r(`startup.copy`)})]}),(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.native`)}),(0,z.jsx)(`code`,{children:e.commands.restoreNative})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.restoreNative),children:t===e.commands.restoreNative?r(`startup.copied`):r(`startup.copy`)})]})]}),e.status===`at-risk`&&(0,z.jsxs)(`div`,{className:`notice notice-warn startup-action-notice`,role:`alert`,children:[(0,z.jsx)(X,{}),` `,r(`startup.recommended`,{cmd:e.recommendedCommand??e.commands.installService})]})]})}var qg=`ocx.startup.page.v1:`;function Jg(e,t){let n=t===`win32`?`; `:` && `;return e.join(n)}function Yg(e,t,n){if(!e)return{warning:null,fix:null};let r=!!e.catalogClamp?.active,i=!!e.newerAvailable,a=(r?e.catalogClamp?.runtimeVersion:e.version)??e.version??`unknown`,o=(e.catalogClamp?.removedEfforts??[]).join(`, `),s=Jg([`ocx doctor --fix-codex-runtime`,`ocx sync`],n);return r?{warning:o?t(`startup.codexRuntime.clampHiddenWithEfforts`,{version:a,efforts:o}):t(`startup.codexRuntime.clampHidden`,{version:a}),fix:i?s:`ocx sync`}:i?{warning:t(`startup.codexRuntime.olderBinary`,{version:a}),fix:s}:{warning:null,fix:null}}function Xg({apiBase:e}){let{t}=Ze(),n=`${qg}${e}`,r=(0,_.useMemo)(()=>Jn(n),[n]),i=`startup-page:${e}`,[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(()=>r?.tray??null),[l,u]=(0,_.useState)(()=>!r?.data),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(()=>r?.warning??null),[S,C]=(0,_.useState)(()=>r?.fix??null),[w,T]=(0,_.useState)(()=>!r?.data),E=(0,_.useRef)(!!r?.data),D=(0,_.useCallback)(async r=>{let i=E.current;i||(u(!0),T(!0));try{let i=fetch(`${e}/api/settings`,{signal:r}).then(async e=>e.ok?await e.json():null).catch(()=>null),a=await fetch(`${e}/api/startup-health`,{signal:r});if(!a.ok)throw Error(`fetch failed`);let o=await a.json();y(e=>e?.kind===`error`&&(o.status===`native`&&e.forLocalRouting===!0||(e.action===`install-service`?o.serviceViable:o.shimInstalled&&o.shimHealthy))?null:e),E.current=!0;let s=Jn(n);Yn(n,{data:o,warning:s?.warning??null,fix:s?.fix??null,tray:s?.tray??null});let l=o.platform===`win32`?fetch(`${e}/api/windows-tray`,{signal:r}).then(async e=>{if(!e.ok)throw Error(`tray status failed`);let t=await e.json();if(!Rg(t))throw Error(`invalid tray status`);return{tray:t,error:!1}}).catch(()=>({tray:null,error:!0})):Promise.resolve({tray:null,error:!1});return Promise.all([i,l]).then(([e,i])=>{if(r.aborted)return;let a=o.platform===`win32`?i.tray:null;if(o.platform===`win32`?(c(a),m(i.error)):(c(null),m(!1)),u(!1),T(!1),e){let r=Yg(e.codexRuntime,t,o.platform);x(r.warning),C(r.fix),Yn(n,{data:o,warning:r.warning,fix:r.fix,tray:a});return}let s=Jn(n);Yn(n,{data:o,warning:s?.warning??null,fix:s?.fix??null,tray:a})}),o}catch(e){throw r.aborted?e:(i||(c(null),m(!0),x(null),C(null)),T(!1),u(!1),e)}},[e,n,t]),O=Zs(i,[e],D,{isEmpty:()=>!1,initialData:r?.data??void 0}),k=O.state,A=O.refresh,j=k.data??r?.data??null,M=k.refreshing,N=!!j?.diagnosticStale||k.showError;(0,_.useEffect)(()=>{if(!j?.diagnosticStale)return;let e=window.setTimeout(A,2e3);return()=>window.clearTimeout(e)},[j,A]);let P=async e=>{try{await navigator.clipboard.writeText(e),o(e),window.setTimeout(()=>o(t=>t===e?null:t),1600)}catch{o(null)}},F=async t=>{f(!0),m(!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(!Rg(r.status))throw Error(`invalid tray action status`);c(r.status),m(!1)}catch{c(null),m(!0)}finally{f(!1)}},I=async(t,n)=>{g(t),y(null);try{let r=await fetch(`${e}/api/startup-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t,repair:n?.repair===!0})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(typeof e?.error==`string`?e.error:`installation failed`)}y({kind:`success`,action:t,repair:n?.repair===!0}),A()}catch(e){y({kind:`error`,action:t,repair:n?.repair===!0,detail:e instanceof Error?e.message:String(e),forLocalRouting:j?.localRoutingDependency===!0})}finally{g(null)}};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{children:t(`startup.title`)}),(0,z.jsx)(`p`,{className:`page-sub startup-page-sub`,children:t(`startup.subtitle`)})]}),(0,z.jsxs)(`div`,{className:`startup-page-head-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>nt(`dashboard`),children:t(`startup.backToDashboard`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A(),disabled:M,children:[(0,z.jsx)(Y,{}),` `,t(`startup.refresh`)]})]})]}),k.showSkeleton&&!j?(0,z.jsx)($s,{label:t(`startup.loading`),rows:5}):k.kind===`failed-cold`?(0,z.jsxs)(`div`,{className:`startup-page-notice`,children:[(0,z.jsx)(Q,{tone:`err`,children:k.error instanceof Error?k.error.message:t(`startup.error`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A(),children:t(`common.retry`)})]}):j?(0,z.jsxs)(z.Fragment,{children:[k.showError&&(0,z.jsx)(Q,{tone:`err`,children:t(`startup.error`)}),N&&(0,z.jsx)(`div`,{className:`notice notice-warn startup-page-notice`,role:`alert`,children:t(`startup.staleData`)}),(w||b)&&(0,z.jsx)(`div`,{className:`startup-runtime-notice-slot${w&&!b?` startup-runtime-notice-slot--pending`:``}`,"aria-hidden":w&&!b?!0:void 0,children:b&&(0,z.jsxs)(`div`,{className:`notice notice-warn startup-page-notice startup-runtime-notice`,role:`status`,children:[(0,z.jsx)(`p`,{className:`startup-runtime-notice__text`,children:b}),S&&(0,z.jsxs)(`div`,{className:`startup-runtime-notice__fix`,children:[(0,z.jsx)(`code`,{children:S}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void P(S),children:t(a===S?`startup.copied`:`startup.copy`)})]})]})}),(0,z.jsx)(Ug,{failed:N,data:j}),(0,z.jsx)(Wg,{data:j,failed:N,loading:M,installBusy:h,installResult:v,onInstall:(e,t)=>{I(e,t)}}),j.platform===`win32`&&(0,z.jsx)(Gg,{tray:s,trayLoading:l,trayError:p,trayBusy:d,onTrayAction:e=>{F(e)}}),(0,z.jsx)(Kg,{data:j,copied:a,onCopy:e=>{P(e)}})]}):null]})}var Zg=3e5,Qg=6e5,$g=`https://github.com/lidge-jun/opencodex`;async function e_(e,t){let n=await fetch(e,{signal:t});return n.ok?await n.json():null}function t_({apiBase:e,onOpenUpdate:t}){let n=Z(),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),s=I(`sidebar-star:${e}`,[e],t=>e_(`${e}/api/github/star`,t),{pollMs:Zg}),c=I(`sidebar-update-badge:${e}`,[e],t=>e_(`${e}/api/update/badge`,t),{pollMs:Qg}),l=s.data?.state??null,u=a!==null&&a.basedOn===l?a.state:l??`not-starred`,d=s.data?.url??$g,f=u===`starred`,p=c.data,m=p?.updateAvailable===!0,h=p?.latestVersion??null,g=()=>window.open(d,`_blank`,`noopener,noreferrer`),v=async()=>{if(!(f||r)){if(u===`unauthenticated`){g();return}i(!0);try{let t=await fetch(`${e}/api/github/star`,{method:`POST`}),n=t.ok?await t.json():null;if(n?.ok===!0){o({state:`starred`,basedOn:l});return}n?.state&&o({state:n.state,basedOn:l}),g()}catch{g()}finally{i(!1),s.refresh()}}},y=n(f?`sidebar.starred`:u===`unauthenticated`?`sidebar.starUnauthenticated`:`sidebar.star`),b=m&&h?n(`sidebar.updateAvailable`,{version:h}):n(`sidebar.checkUpdate`);return(0,z.jsxs)(`div`,{className:`sidebar-github-row`,children:[(0,z.jsxs)(`a`,{className:`sidebar-link sidebar-github-link`,href:d,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(me,{}),` `,n(`common.github`)]}),(0,z.jsxs)(`div`,{className:`sidebar-github-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`sidebar-orb${f?` sidebar-orb--starred`:``}`,onClick:()=>{v()},disabled:r||f,"aria-label":y,"aria-pressed":f,title:y,children:(0,z.jsx)(Ee,{"aria-hidden":`true`,...f?{fill:`currentColor`}:{}})}),(0,z.jsxs)(`button`,{type:`button`,className:`sidebar-orb${m?` sidebar-orb--update`:``}`,onClick:t,"aria-label":b,title:b,children:[(0,z.jsx)(fe,{"aria-hidden":`true`}),m&&(0,z.jsx)(`span`,{className:`sidebar-orb-dot`,"aria-hidden":`true`})]})]})]})}var n_=`opencodex-admin-token-dialog`,r_=`OpenCodex`;function i_(e,t=qe()){let n=Be[t],r=n[`auth.adminTokenTitle`];return new Promise(t=>{let i=document.activeElement instanceof HTMLElement?document.activeElement:null,a=!1,o=document.createElement(`dialog`);o.id=n_,o.className=`modal-overlay`,o.setAttribute(`aria-labelledby`,`${n_}-title`);let s=document.createElement(`form`);s.className=`modal-card`,s.method=`post`,s.action=window.location.href,s.autocomplete=`on`;let c=document.createElement(`div`);c.className=`modal-head`;let l=document.createElement(`h3`);l.id=`${n_}-title`,l.textContent=r,c.append(l);let u=document.createElement(`div`),d=document.createElement(`label`);d.className=`field-label`,d.htmlFor=`${n_}-username`,d.textContent=n[`auth.adminAccountLabel`];let f=document.createElement(`input`);f.id=d.htmlFor,f.className=`input`,f.type=`text`,f.name=`username`,f.autocomplete=`username`,f.value=r_,f.readOnly=!0,u.append(d,f);let p=document.createElement(`div`);p.style.marginTop=`var(--space-4)`;let m=document.createElement(`label`);m.className=`field-label`,m.htmlFor=`${n_}-password`,m.textContent=n[`auth.adminTokenFieldLabel`];let h=document.createElement(`input`);h.id=m.htmlFor,h.className=`input`,h.type=`password`,h.name=`password`,h.autocomplete=`current-password`,h.required=!0,h.spellcheck=!1,h.autocapitalize=`none`,p.append(m,h);let g=document.createElement(`div`);g.className=`notice notice-err`,g.setAttribute(`role`,`alert`),g.hidden=!0;let _=document.createElement(`div`);_.className=`modal-actions`;let v=document.createElement(`button`);v.type=`button`,v.className=`btn btn-ghost`,v.textContent=n[`common.cancel`];let y=document.createElement(`button`);y.type=`submit`,y.className=`btn btn-primary`,y.textContent=n[`common.ok`],_.append(v,y),s.append(c,u,p,g,_),o.append(s);let b=e=>{a||(a=!0,o.open&&o.close(),o.remove(),i?.focus(),t(e))};s.addEventListener(`submit`,t=>{t.preventDefault();let r=h.value.trim();if(!r){h.value=``,h.reportValidity();return}h.disabled=!0,y.disabled=!0,g.hidden=!0,e(r).then(e=>{if(!a){if(e===`accepted`){b(r);return}h.value=``,h.disabled=!1,y.disabled=!1,g.textContent=e===`rejected`?n[`auth.adminTokenRejected`]:n[`auth.adminTokenUnavailable`],g.hidden=!1,h.focus()}}).catch(()=>{a||(h.value=``,h.disabled=!1,y.disabled=!1,g.textContent=n[`auth.adminTokenUnavailable`],g.hidden=!1,h.focus())})}),v.addEventListener(`click`,()=>b(null)),o.addEventListener(`cancel`,e=>{e.preventDefault(),b(null)}),document.body.append(o),typeof o.showModal==`function`?o.showModal():o.setAttribute(`open`,``),queueMicrotask(()=>h.focus())})}var a_=!1,o_=null,s_=null,c_=!1,l_=i_,u_=`/opencodex-session`,d_=`/api/settings`;function f_(e){try{let t=e instanceof Request?e.url:String(e),n=new URL(t,window.location.href);return n.origin===window.location.origin&&n.pathname.startsWith(`/api/`)}catch{return!1}}var p_=`opencodex-api-token`,m_=null,h_=null,g_=null;function __(){return m_}function v_(e){m_=e}function y_(){m_=null,h_=null,g_=null}function b_(e){let t=document.querySelector(`meta[name="${e}"]`),n=t?.content.trim()||null;return t?.remove(),n}function x_(){C_(b_(`opencodex-session-token`),b_(`opencodex-session-csrf`),b_(`opencodex-session-origin`))}function S_(e){e!=null&&__()===e&&y_()}function C_(e,t,n){return!e?.startsWith(`ocx_session_`)||!t||n!==window.location.origin?!1:(m_=e,h_=t,g_=n,!0)}function w_(e,t){for(let n of e.match(/<meta\b[^>]*>/gi)??[])if(n.match(/\bname="([^"]+)"/i)?.[1]===t)return n.match(/\bcontent="([^"]*)"/i)?.[1]?.trim()||null;return null}async function T_(){if(!s_)return null;try{let e=await s_(u_,{cache:`no-store`});if(!e.ok)return null;let t=await e.text();return C_(w_(t,`opencodex-session-token`),w_(t,`opencodex-session-csrf`),w_(t,`opencodex-session-origin`))?__():null}catch{return null}}async function E_(e){if(!s_)return`unavailable`;try{let[t,n]=O_(d_,{cache:`no-store`},e),r=await s_(t,n);return r.status===401?`rejected`:r.ok?`accepted`:`unavailable`}catch{return`unavailable`}}function D_(){try{sessionStorage.removeItem(p_)}catch{}}function O_(e,t,n){let r=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));if(r.set(`X-OpenCodex-API-Key`,n),g_&&h_&&n.startsWith(`ocx_session_`)){r.set(`X-OpenCodex-GUI-Origin`,g_);let n=(t?.method??(e instanceof Request?e.method:`GET`)).toUpperCase();n!==`GET`&&n!==`HEAD`&&r.set(`X-OpenCodex-CSRF-Token`,h_)}return e instanceof Request?[new Request(e,{headers:r}),t?{...t,headers:r}:void 0]:[e,{...t,headers:r}]}async function k_(e){return c_?null:o_||(o_=(async()=>{if(c_)return null;let t=__();if(t&&t!==e)return t;let n=await T_();if(n)return n;let r=await l_(E_);return r?(v_(r),r):(c_=!0,null)})().finally(()=>{o_=null}),o_)}function A_(){if(a_)return;a_=!0,D_(),x_();let e=window.fetch.bind(window);s_=e,window.fetch=async(t,n)=>{if(!f_(t))return e(t,n);let r=__(),[i,a]=r?O_(t,n,r):[t,n],o=await e(i,a);if(o.status!==401)return o;let s=__();if(s&&s!==r){let[r,i]=O_(t,n,s),a=await e(r,i);if(a.status!==401)return a;S_(s)}else S_(r);let c=await k_(r);if(!c)return o;let[l,u]=O_(t,n,c),d=await e(l,u);return d.status===401&&S_(c),d}}var j_=new Set([`dashboard`,`startup`,`providers`,`models`,`subagents`,`logs`,`usage`,`storage`,`codex-auth`,`integrations`]);function M_(e){let t=et(e??(typeof window<`u`?window.location.hash:``)).split(`/`)[0];return t===`debug`?`logs`:t===`combos`||t===`routing`||t===`lab`?`models`:t===`api`||t===`claude`||t===`grok`?`integrations`:j_.has(t)?t:`dashboard`}var N_=[`dashboard/providers`,`dashboard/models`],P_=[`models/combos`,`models/routing`,`models/compatibility`],F_=[`integrations/keys`,`integrations/codex`,`integrations/claude`,`integrations/claude/desktop`,`integrations/grok`,`integrations/opencode`,`integrations/pi`,`integrations/omp`,`integrations/hermes`,`integrations/openclaw`,`integrations/kimi`,`integrations/gajae`];function I_(e,t){return e===t||t===`logs`&&e===`logs/debug`||t===`models`&&P_.includes(e)||t===`dashboard`&&(e===`dashboard/update`||N_.includes(e))||t===`integrations`&&F_.includes(e)}function L_(e){let t=M_(e);return e===`debug`||e.startsWith(`debug/`)?{page:`logs`,replaceTo:`logs/debug`}:e===`combos`||e.startsWith(`combos/`)?{page:`models`,replaceTo:`models/combos`}:e===`routing`||e.startsWith(`routing/`)?{page:`models`,replaceTo:`models/routing`}:e===`lab`||e.startsWith(`lab/`)?{page:`models`,replaceTo:`models/compatibility`}:e===`api`?{page:`integrations`,replaceTo:`integrations/keys`}:e===`claude`?{page:`integrations`,replaceTo:`integrations/claude`}:e===`grok`?{page:`integrations`,replaceTo:`integrations/grok`}:e===`providers/workspace`?{page:`providers`,replaceTo:`providers`}:I_(e,t)?{page:t,replaceTo:null}:{page:t,replaceTo:t}}var R_=[`ocx-global-view`,`ocx-view`,`ocx-providers-view`,`ocx-subagents-view`,`ocx-storage-view`,`ocx-codexauth-view`,`ocx-apikeys-view`,`ocx-claudecode-view`,`ocx-usage-view`,`ocx-logs-view`,`ocx-models-view`,`ocx-dashboard-view`];function z_(){try{for(let e of R_)localStorage.removeItem(e)}catch{}}function B_(){let[e,t]=(0,_.useState)(M_);(0,_.useEffect)(()=>{z_()},[]);let n=(0,_.useCallback)(e=>{let n=L_(e);n.replaceTo&&tt(n.replaceTo),t(n.page)},[]);return(0,_.useEffect)(()=>{let e=()=>{n(et(window.location.hash))};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[n]),(0,_.useEffect)(()=>{let n=L_(et(window.location.hash));n.replaceTo&&tt(n.replaceTo),n.page!==e&&t(n.page)},[e]),{page:e,setPageState:t,navigateToPage:(e,n)=>{nt(n?`${e}/${n}`:e),t(e)}}}var V_=15e3;function H_(e,t,n){return typeof e?.message==`string`&&e.message.trim()?e.message:typeof e?.error==`string`&&e.error.trim()?e.error:n(t)}function U_(e){return(e instanceof DOMException||e instanceof Error)&&e.name===`AbortError`}async function W_(e,t={}){let{fetchFn:n=fetch,timeoutMs:r=V_,formatFailure:i=e=>`Failed to stop proxy (HTTP ${e}).`}=t,a;try{a=await n(`${e}/api/stop`,{method:`POST`,signal:AbortSignal.timeout(r)})}catch(e){return U_(e),{accepted:!0}}let o=await a.json().catch(()=>null);return!a.ok||o?.success===!1?{accepted:!1,message:H_(o,a.status,i)}:{accepted:!0}}A_();var G_={dashboard:`nav.dashboard`,startup:`nav.startup`,providers:`nav.providers`,models:`nav.models`,subagents:`nav.subagents`,logs:`nav.logs`,usage:`nav.usage`,storage:`nav.storage`,"codex-auth":`nav.codexAuth`,integrations:`nav.integrations`},K_=``,q_=`ocx-theme`,J_=[{id:`dashboard`,tkey:`nav.dashboard`,Icon:V},{id:`codex-auth`,tkey:`nav.codexAuth`,Icon:ge},{id:`providers`,tkey:`nav.providers`,Icon:H},{id:`models`,tkey:`nav.models`,Icon:U},{id:`subagents`,tkey:`nav.subagents`,Icon:W},{id:`logs`,tkey:`nav.logs`,Icon:G},{id:`usage`,tkey:`nav.usage`,Icon:ne},{id:`storage`,tkey:`nav.storage`,Icon:K},{id:`integrations`,tkey:`nav.integrations`,Icon:Ce}],Y_={light:be,dark:xe,system:Se},X_={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function Z_(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 Q_(){let e=localStorage.getItem(q_);return e===`light`||e===`dark`?e:`system`}function $_(){let{page:e,navigateToPage:t}=B_(),[n,r]=(0,_.useState)(Hu);(0,_.useEffect)(()=>{let e=()=>r(Hu());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let[i,a]=(0,_.useState)(Q_),{locale:o,setLocale:s}=Ze(),c=Z(),[l,u]=(0,_.useState)(!1),d=(0,_.useRef)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(!1);(0,_.useEffect)(()=>{let e=()=>u(!1);return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]),(0,_.useEffect)(()=>{let e=document.documentElement;i===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(q_)):(e.setAttribute(`data-theme`,i),localStorage.setItem(q_,i))},[i]);let m=I(`app-healthz:${K_}`,[],async e=>{let t=await fetch(`${K_}/healthz`,{signal:e});return t.ok?Z_(await t.json()):null},{pollMs:3e4}),h=()=>a(e=>e===`light`?`dark`:e===`dark`?`system`:`light`),g=Y_[i],v=m.data??`2.14.2`,[y,b]=(0,_.useState)(!1);(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)},[]);let x=async()=>{if(!confirm(c(`dash.stopConfirm`)))return;b(!0);let e=await W_(K_,{formatFailure:e=>c(`dash.stopFailed`,{status:String(e)})});e.accepted||(b(!1),alert(e.message))},S=(0,z.jsxs)(`div`,{className:`brand`,children:[(0,z.jsx)(`span`,{className:`brand-logo`,role:`img`,"aria-label":c(`app.logoAria`)}),(0,z.jsx)(`span`,{className:`name`,children:`opencodex`}),(0,z.jsxs)(`span`,{className:`ver`,children:[`v`,v]})]});return(0,z.jsxs)(`div`,{className:`app`,children:[(0,z.jsxs)(`header`,{className:`mobile-topbar`,inert:l,children:[(0,z.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,z.jsx)(ee,{})}),S,(0,z.jsx)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:x,disabled:y,"aria-label":c(`dash.stop`),title:c(`dash.stop`),children:(0,z.jsx)(X,{})})]}),l&&(0,z.jsx)(`div`,{className:`drawer-scrim`,onClick:()=>u(!1),"aria-hidden":`true`}),(0,z.jsxs)(`aside`,{id:`app-sidebar`,className:`sidebar${l?` open`:``}`,ref:f,tabIndex:-1,children:[(0,z.jsxs)(`div`,{className:`drawer-head`,children:[S,(0,z.jsx)(`button`,{type:`button`,className:`menu-toggle drawer-close`,onClick:()=>u(!1),"aria-label":c(`nav.closeMenu`),title:c(`nav.closeMenu`),children:(0,z.jsx)(J,{})})]}),(0,z.jsx)(`nav`,{children:J_.map(n=>{let{id:r,tkey:i,Icon:a}=n,o=r===e;return(0,z.jsx)(`div`,{className:`nav-entry`,children:(0,z.jsxs)(`button`,{type:`button`,className:`nav-item${o?` active`:``}`,"data-page":r,onClick:()=>{t(r),u(!1)},"aria-current":o?`page`:void 0,children:[(0,z.jsx)(a,{}),` `,c(i)]})},r)})}),(0,z.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,z.jsxs)(`div`,{className:`lang-toggle`,children:[(0,z.jsx)(Ce,{"aria-hidden":!0}),(0,z.jsx)(gt,{value:o,options:Ue.map(e=>({value:e.code,label:Ve(e.code)})),onChange:e=>s(e),label:c(`lang.label`),placement:`right`,portal:!1,style:{flex:1,minWidth:0,width:`100%`}})]}),(0,z.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:h,"aria-label":`${c(`theme.label`)}: ${c(X_[i])}`,title:`${c(`theme.label`)}: ${c(X_[i])}`,children:[(0,z.jsx)(g,{}),` `,(0,z.jsx)(`span`,{className:`mode`,children:c(X_[i])})]}),(0,z.jsxs)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:x,disabled:y,"aria-label":c(`dash.stop`),title:c(`dash.stop`),children:[(0,z.jsx)(X,{}),` `,(0,z.jsx)(`span`,{className:`mode`,children:c(y?`dash.stopping`:`dash.stop`)})]}),(0,z.jsx)(t_,{apiBase:K_,onOpenUpdate:()=>{u(!1),t(`dashboard`,`update`)}})]})]}),(0,z.jsx)(`main`,{className:`main`,inert:l,children:(0,z.jsx)(`div`,{className:`main-inner${e===`models`&&n===`combos`?` main-inner--combos`:``}`,children:(0,z.jsxs)(tc,{pageName:c(G_[e]),title:c(`errorBoundary.title`),message:c(`errorBoundary.message`),detailsLabel:c(`errorBoundary.details`),reloadLabel:c(`errorBoundary.reload`),children:[e===`dashboard`&&(0,z.jsx)(Tr,{apiBase:K_}),e===`startup`&&(0,z.jsx)(Xg,{apiBase:K_}),e===`providers`&&(0,z.jsx)(Ws,{apiBase:K_}),e===`models`&&(0,z.jsx)(vd,{apiBase:K_},K_),e===`subagents`&&(0,z.jsx)(Ad,{apiBase:K_},K_),e===`logs`&&(0,z.jsx)(tp,{apiBase:K_}),e===`usage`&&(0,z.jsx)(Cp,{apiBase:K_}),e===`storage`&&(0,z.jsx)(Vp,{apiBase:K_}),e===`codex-auth`&&(0,z.jsx)(Jp,{apiBase:K_}),e===`integrations`&&(0,z.jsx)(Lg,{apiBase:K_})]},e)})})]})}g.createRoot(document.getElementById(`root`)).render((0,z.jsx)(_.StrictMode,{children:(0,z.jsx)(Qe,{children:(0,z.jsx)($_,{})})}));
|
|
76
|
+
`);if(!confirm(t))return;i(!0),o(null);let a=[];for(let t of N)try{await Ih(e,t.clientId,!1)}catch(e){a.push(`${t.clientId}: ${sg(n,e)}`)}let s=!1;try{s=(await Nh(e)).clients.some(wg)}catch{a.push(n(`integrations.error.stale`))}s&&a.length===0&&a.push(n(`integrations.error.stale`)),U(),i(!1),o(a.length===0?{tone:`ok`,text:n(`integrations.bulk.success`)}:{tone:`err`,text:n(`integrations.bulk.partial`,{clients:a.join(`; `)})})},G=M[0]?.at,[ee,te]=(0,_.useState)(null),ne=()=>{A.refresh(),D.refresh(),k.refresh()},K=(e,t)=>{u(n=>{let r={...n};return t?r[e]=t:delete r[e],r})},q=async(t,r)=>{if(!ee&&t.toggle){te(t.id),K(t.id,null);try{if(t.status)await Ih(e,t.status.clientId,r),U();else if(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`){let i=await eg(e,t.toggle,r);i.reason===`non_loopback_removed`?K(t.id,{tone:`ok`,text:n(i.changed?`integrations.native.msg.nonLoopbackRemoved`:`integrations.native.msg.nonLoopbackRemovedNoop`)}):i.reason===`non_loopback_superseded`&&K(t.id,{tone:`ok`,text:n(`integrations.native.msg.nonLoopbackSuperseded`)}),ne()}}catch(e){K(t.id,{tone:`err`,text:sg(n,e,void 0,t.togglePath??void 0)}),(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`)&&ne()}finally{te(null)}}},J=(e,t)=>{if(e.status||t||e.id===`claude`||e.toggle===null){q(e,t);return}let n=document.activeElement;p.current=n?.tagName===`BUTTON`?n:null,f(e)};return(0,z.jsxs)(`section`,{className:`integrations-overview`,children:[(0,z.jsxs)(`div`,{className:`integration-summary`,children:[(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.detected`)}),(0,z.jsx)(`strong`,{children:H.detected})]}),(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.applied`)}),(0,z.jsx)(`strong`,{children:H.applied})]}),(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.stale`)}),(0,z.jsx)(`strong`,{children:H.stale})]}),H.unknown>0&&(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.state.unknown`)}),(0,z.jsx)(`strong`,{children:H.unknown})]}),(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.lastChange`)}),(0,z.jsx)(`strong`,{children:G?new Date(G).toLocaleString():n(`integrations.status.unknown`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void W(),disabled:r||N.length===0,children:n(`integrations.summary.disableAll`)})]}),(0,z.jsx)(Dg,{row:B}),(0,z.jsx)(`p`,{className:`page-sub`,children:n(`integrations.onboarding`)}),C.state.kind===`failed-cold`&&(0,z.jsx)(Q,{tone:`err`,children:n(`integrations.error.load`)}),C.state.kind===`failed-with-stale`&&(0,z.jsx)(Q,{tone:`err`,children:n(`integrations.error.stale`)}),a&&(0,z.jsx)(Q,{tone:a.tone,children:a.text}),V.length===0?C.state.kind===`failed-cold`?null:(0,z.jsx)(`p`,{className:`page-sub`,children:n(`common.loading`)}):(0,z.jsx)(`ul`,{className:`integration-cards`,children:V.map(e=>(0,z.jsx)(Tg,{row:e,pending:ee!==null,result:l[e.id]??null,onOpen:()=>nt(e.hash),onToggle:e.toggle?()=>J(e,!(e.toggleOn??e.applied)):null},e.id))}),F&&P.length===0&&(0,z.jsxs)(`div`,{className:`integration-empty`,children:[(0,z.jsx)(`h4`,{children:n(`integrations.empty.title`)}),(0,z.jsx)(`p`,{children:n(`integrations.empty.body`)})]}),(0,z.jsx)(`h4`,{children:n(`integrations.rollback.title`)}),M.length===0?(0,z.jsxs)(`div`,{className:`integration-empty`,children:[(0,z.jsx)(`p`,{children:n(`integrations.rollback.empty`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:n(`integrations.rollback.emptyBody`)})]}):(0,z.jsx)(`ul`,{className:`integration-history`,children:M.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`span`,{className:`integration-history-kind`,children:n(Cg[e.kind])}),(0,z.jsx)(`span`,{className:`integration-history-client`,children:e.clientId}),(0,z.jsx)(`span`,{className:`integration-history-at`,children:new Date(e.at).toLocaleString()}),e.snapshot===`expired`?(0,z.jsx)(`span`,{className:`badge badge-muted`,children:n(`integrations.action.snapshotExpired`)}):(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>c(e),children:e.undoable?n(`integrations.action.undo`):n(`integrations.action.restorePoint`)})]},e.opId))}),s&&(0,z.jsx)(cg,{apiBase:e,row:s,onClose:()=>c(null),onRestored:U}),d&&(0,z.jsx)(Ch,{copy:{...d.toggle===`claude-desktop`?Sg:xg,vars:{path:d.togglePath??``}},onClose:()=>f(null),onConfirm:async()=>{await q(d,!1),f(null)}})]})}function Dg({row:e}){let t=Z(),n=e.detailKey?t(e.detailKey,e.detailVars??void 0):null;return(0,z.jsxs)(`div`,{className:`integration-api-keys-row`,"data-client":`keys`,"data-key-state":e.state,children:[(0,z.jsxs)(`div`,{className:`integration-api-keys-copy`,children:[(0,z.jsx)(`h4`,{children:t(e.labelKey)}),n&&(0,z.jsx)(`p`,{className:`integration-meta`,children:n})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>nt(e.hash),children:t(`integrations.action.manageKeys`)})]})}var Og={opencode:`integrations.semantics.opencode`,pi:`integrations.semantics.pi`,omp:`integrations.semantics.omp`,hermes:`integrations.semantics.hermes`,openclaw:`integrations.semantics.openclaw`,kimi:`integrations.semantics.kimi`,gajae:`integrations.semantics.gajae`},kg={opencode:`integrations.tab.opencode`,pi:`integrations.tab.pi`,omp:`integrations.tab.omp`,hermes:`integrations.tab.hermes`,openclaw:`integrations.tab.openclaw`,kimi:`integrations.tab.kimi`,gajae:`integrations.tab.gajae`},Ag={apply:`integrations.kind.apply`,disable:`integrations.kind.disable`,refresh:`integrations.kind.refresh`,restore:`integrations.kind.restore`};function jg({apiBase:e,client:t,active:n=!0}){let r=Z(),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),u=(0,_.useCallback)(n=>Ph(e,t,n),[e,t]),d=(0,_.useCallback)(async n=>(await Fh(e,t,n)).operations,[e,t]),f=Zs(`integration-state:${e}:${t}`,[e,t],u,{isEmpty:()=>!1,enabled:n}),p=Zs(`integration-journal:${e}:${t}`,[e,t],d,{isEmpty:e=>e.length===0,enabled:n}),m=f.state.data??null,h=p.state.data??[],g=()=>{f.refresh(),p.refresh()},v=async n=>{if(!(!m||i)){a(!0),s(null);try{await Ih(e,t,n),g()}catch(e){s(sg(r,e))}finally{a(!1)}}},y=()=>void v(!(m&&(m.state===`current`||m.state===`stale`)));if(!m)return(0,z.jsx)(`section`,{className:`integration-client-page`,children:f.state.kind===`failed-cold`?(0,z.jsx)(Q,{tone:`err`,children:r(`integrations.error.load`)}):(0,z.jsx)(`p`,{className:`page-sub`,children:r(`common.loading`)})});let b=m.state===`current`||m.state===`stale`,x=!m.installed||m.state===`conflict`||m.state===`unsafe`;return(0,z.jsxs)(`section`,{className:`integration-client-page`,children:[(0,z.jsxs)(`div`,{className:`integration-client-head`,children:[(0,z.jsx)(`h3`,{children:r(kg[t])}),(0,z.jsx)(xh,{state:m.state,installed:m.installed,id:`integration-state-${t}`}),(0,z.jsx)(mt,{on:b,onClick:y,disabled:x||i,label:r(b?`integrations.action.disable`:`integrations.action.apply`)})]}),m.state===`stale`&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void v(!0),disabled:i,children:r(`integrations.action.refresh`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:r(Og[t])}),(0,z.jsx)(`p`,{className:`integration-path`,children:m.configPath}),m.appliedAt&&(0,z.jsxs)(`p`,{className:`integration-meta`,children:[r(`integrations.status.appliedAt`),`: `,new Date(m.appliedAt).toLocaleString()]}),m.retentionDegraded&&(0,z.jsx)(Q,{tone:`err`,children:r(`integrations.retention.degraded`)}),o&&(0,z.jsx)(Q,{tone:`err`,children:o}),(0,z.jsx)(`h4`,{children:r(`integrations.rollback.title`)}),h.length===0?(0,z.jsx)(`p`,{className:`page-sub`,children:r(`integrations.rollback.empty`)}):(0,z.jsx)(`ul`,{className:`integration-history`,children:h.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`span`,{className:`integration-history-kind`,children:r(Ag[e.kind])}),(0,z.jsx)(`span`,{className:`integration-history-at`,children:new Date(e.at).toLocaleString()}),e.snapshot===`expired`?(0,z.jsx)(`span`,{className:`badge badge-muted`,children:r(`integrations.action.snapshotExpired`)}):(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>l(e),children:e.undoable?r(`integrations.action.undo`):r(`integrations.action.restorePoint`)})]},e.opId))}),c&&(0,z.jsx)(cg,{apiBase:e,row:c,onClose:()=>l(null),onRestored:g})]})}var Mg=[{id:`overview`,hash:`integrations`,labelKey:`integrations.tab.overview`},{id:`keys`,hash:`integrations/keys`,labelKey:`integrations.tab.keys`},{id:`codex`,hash:`integrations/codex`,labelKey:`integrations.tab.codex`},{id:`claude`,hash:`integrations/claude`,labelKey:`integrations.tab.claude`},{id:`grok`,hash:`integrations/grok`,labelKey:`integrations.tab.grok`},{id:`opencode`,hash:`integrations/opencode`,labelKey:`integrations.tab.opencode`},{id:`pi`,hash:`integrations/pi`,labelKey:`integrations.tab.pi`},{id:`omp`,hash:`integrations/omp`,labelKey:`integrations.tab.omp`},{id:`hermes`,hash:`integrations/hermes`,labelKey:`integrations.tab.hermes`},{id:`openclaw`,hash:`integrations/openclaw`,labelKey:`integrations.tab.openclaw`},{id:`kimi`,hash:`integrations/kimi`,labelKey:`integrations.tab.kimi`},{id:`gajae`,hash:`integrations/gajae`,labelKey:`integrations.tab.gajae`}],Ng=new Set([`opencode`,`pi`,`omp`,`hermes`,`openclaw`,`kimi`,`gajae`]);function Pg(e=window.location.hash){let t=et(e);return t===`integrations/claude/desktop`?`claude`:Mg.find(e=>e.hash===t)?.id??`overview`}function Fg(e){return`integrations-tab-${e}`}function Ig(e){return`integrations-panel-${e}`}function Lg({apiBase:e}){let t=Z(),[n,r]=(0,_.useState)(Pg),[i,a]=(0,_.useState)(()=>new Set([Pg()])),o=(0,_.useRef)(null);o.current===null&&(o.current=new Map);let s=e=>{r(e),a(t=>t.has(e)?t:new Set([...t,e]))};(0,_.useEffect)(()=>{let e=()=>s(Pg());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let c=(e,t)=>{let n=Mg.find(t=>t.id===e);n&&(nt(n.hash),s(e),t&&window.requestAnimationFrame(()=>{o.current.get(e)?.focus({preventScroll:!0})}))},l=e=>{let t=Mg.findIndex(e=>e.id===n),r=null;e.key===`ArrowLeft`?r=(t-1+Mg.length)%Mg.length:e.key===`ArrowRight`?r=(t+1)%Mg.length:e.key===`Home`?r=0:e.key===`End`&&(r=Mg.length-1),r!==null&&(e.preventDefault(),c(Mg[r].id,!0))};return(0,z.jsxs)(`section`,{className:`integrations-page`,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:t(`nav.integrations`)})}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`integrations.subtitle`)}),(0,z.jsx)(`div`,{className:`page-tabs`,role:`tablist`,"aria-label":t(`integrations.tabsLabel`),children:Mg.map(e=>(0,z.jsx)(`button`,{ref:t=>{t?o.current.set(e.id,t):o.current.delete(e.id)},type:`button`,role:`tab`,id:Fg(e.id),"aria-selected":n===e.id,"aria-controls":Ig(e.id),tabIndex:n===e.id?0:-1,className:`page-tab${n===e.id?` page-tab--active`:``}`,onClick:()=>c(e.id,!0),onKeyDown:l,children:t(e.labelKey)},e.id))}),Mg.map(r=>{if(!i.has(r.id))return null;let a=n===r.id;return(0,z.jsxs)(`div`,{role:`tabpanel`,id:Ig(r.id),"aria-labelledby":Fg(r.id),hidden:!a,children:[r.id===`overview`&&(0,z.jsx)(Eg,{apiBase:e,active:a}),r.id===`keys`&&(0,z.jsx)(wm,{apiBase:e,active:a}),r.id===`codex`&&(0,z.jsxs)(`section`,{className:`integration-native-page`,"aria-labelledby":`codex-integration-title`,children:[(0,z.jsx)(`h3`,{id:`codex-integration-title`,children:t(`integrations.codex.title`)}),(0,z.jsx)(`p`,{children:t(`integrations.codex.body`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>nt(`startup`),children:t(`integrations.codex.openService`)})]}),r.id===`claude`&&(0,z.jsx)(fh,{apiBase:e,active:a}),r.id===`grok`&&(0,z.jsx)(vh,{apiBase:e,active:a}),Ng.has(r.id)&&(0,z.jsx)(jg,{apiBase:e,client:r.id,active:a})]},r.id)})]})}function Rg(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 zg={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},Bg={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},Vg={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function Hg({ok:e,yes:t,no:n}){return(0,z.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function Ug({failed:e,data:t}){let{t:n}=Ze(),r=e?`startup-hero--risk`:t.status===`protected`?`startup-hero--safe`:t.status===`at-risk`?`startup-hero--risk`:`startup-hero--native`,i=e||t.status===`at-risk`?se:q,a=t.routingKind===`opencodex-local`?`startup.routing.proxy`:t.routingKind===`custom-local`?`startup.routing.customLocal`:t.routingKind===`custom-remote`?`startup.routing.customRemote`:t.routingKind===`unknown`?`startup.routing.unknown`:`startup.routing.native`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`section`,{className:`panel startup-hero ${r}`,"aria-live":`polite`,children:[(0,z.jsx)(`div`,{className:`startup-hero-icon`,children:(0,z.jsx)(i,{})}),(0,z.jsxs)(`div`,{className:`startup-hero-copy`,children:[(0,z.jsx)(`span`,{className:`badge ${e||t.status===`at-risk`?`badge-amber`:`badge-green`}`,children:n(e?`startup.status.atRisk`:zg[t.status])}),(0,z.jsx)(`h3`,{children:n(e?`startup.error`:Bg[t.status])}),(0,z.jsx)(`p`,{children:e?n(`startup.staleData`):t.status===`at-risk`?n(Xn(t)):n(`startup.safeDetail`)})]})]}),(0,z.jsxs)(`div`,{className:`startup-state-grid`,children:[(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.routing`)}),(0,z.jsx)(`div`,{className:`value`,children:n(a)})]}),(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.restartProtection`)}),(0,z.jsx)(`div`,{className:`value`,children:n(Vg[t.protection])})]}),(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.preference`)}),(0,z.jsx)(`div`,{className:`value`,children:n(t.autostartEnabled?`startup.enabled`:`startup.disabled`)})]})]})]})}function Wg({data:e,failed:t,loading:n=!1,installBusy:r,installResult:i,onInstall:a}){let{t:o}=Ze(),s=e.serviceSupported&&e.serviceInstalled&&e.serviceStale&&!e.serviceConflict,c=e.shimInstalled&&!e.shimHealthy,l=r!==null||t||n;return(0,z.jsxs)(`section`,{className:`panel startup-details`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:o(`startup.details`)}),(0,z.jsx)(`span`,{className:`muted mono`,children:e.platform})]}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(`startup.service`)}),(0,z.jsx)(`span`,{children:o(`startup.serviceHint`)})]}),(0,z.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,z.jsx)(Hg,{ok:e.serviceViable,yes:o(`startup.viable`),no:o(e.serviceConflict?`startup.conflict`:e.serviceStale?`startup.stale`:e.serviceInstalled?`startup.unhealthy`:e.serviceSupported?`startup.notInstalled`:`startup.unsupported`)}),e.serviceSupported&&!e.serviceInstalled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-service`),children:o(r===`install-service`?`startup.installing`:`startup.install`)}),s&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-service`,{repair:!0}),children:o(r===`install-service`?`startup.repairing`:`startup.repair`)})]})]}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(`startup.shim`)}),(0,z.jsx)(`span`,{children:o(`startup.shimHint`)})]}),(0,z.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,z.jsx)(Hg,{ok:e.shimHealthy&&e.autostartEnabled,yes:o(e.shimCoverage===`cli-only`?`startup.cliOnly`:`startup.healthy`),no:o(e.shimInstalled?e.shimHealthy&&!e.autostartEnabled?`startup.installedDisabled`:`startup.stale`:`startup.notInstalled`)}),!e.shimInstalled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-shim`),children:o(r===`install-shim`?`startup.installing`:`startup.install`)}),c&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-shim`,{repair:!0}),children:o(r===`install-shim`?`startup.repairing`:`startup.repair`)})]})]}),i&&(0,z.jsx)(`div`,{className:`notice ${i.kind===`success`?`notice-ok`:`notice-warn`} startup-action-notice`,role:`status`,"aria-live":`polite`,children:i.kind===`success`?i.action===`install-service`?o(i.repair?`startup.serviceRepaired`:`startup.serviceInstalled`):o(i.repair?`startup.shimRepaired`:`startup.shimInstalled`):`${o(`startup.installFailed`)} ${i.detail??``}`})]})}function Gg({tray:e,trayLoading:t,trayError:n,trayBusy:r,onTrayAction:i}){let{t:a}=Ze();return(0,z.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:a(`startup.tray.title`)}),(0,z.jsx)(X,{})]}),(0,z.jsx)(`p`,{className:`muted`,children:a(`startup.tray.hint`)}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:a(`startup.tray.login`)}),(0,z.jsx)(`span`,{children:a(`startup.tray.notProtection`)})]}),t||n||!e?(0,z.jsx)(`span`,{className:`badge badge-amber`,children:a(t?`startup.tray.loading`:`startup.tray.unavailable`)}):(0,z.jsx)(Hg,{ok:e.running&&!e.stale,yes:a(`startup.tray.running`),no:a(e.stale?`startup.tray.stale`:e.installed?`startup.tray.stopped`:`startup.tray.notInstalled`)})]}),(0,z.jsxs)(`div`,{className:`startup-tray-buttons`,children:[!t&&!n&&e&&!e.installed&&!e.stale&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`install`),children:a(`startup.tray.install`)}),!t&&!n&&e?.installed&&!e.stale&&!e.running&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`start`),children:a(`startup.tray.start`)}),!t&&!n&&e?.running&&!e.stale&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:r,onClick:()=>i(`stop`),children:a(`startup.tray.stop`)}),!t&&!n&&e&&(e.installed||e.stale)&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-danger`,disabled:r,onClick:()=>{window.confirm(a(`startup.tray.uninstall`))&&i(`uninstall`)},children:a(`startup.tray.uninstall`)})]}),(n||e?.stale)&&(0,z.jsx)(`div`,{className:`notice notice-warn startup-tray-error`,role:`alert`,children:a(`startup.tray.error`)})]})}function Kg({data:e,copied:t,onCopy:n}){let{t:r}=Ze(),i=e.serviceInstalled&&!e.serviceConflict?e.commands.repairService:e.commands.installService;return(0,z.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:r(`startup.recovery`)}),(0,z.jsx)(te,{})]}),(0,z.jsx)(`p`,{className:`muted`,children:r(`startup.recoveryHint`)}),(0,z.jsxs)(`div`,{className:`startup-command-list`,children:[e.serviceSupported&&(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.service`)}),(0,z.jsx)(`code`,{children:i})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(i),children:r(t===i?`startup.copied`:`startup.copy`)})]}),(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.shim`)}),(0,z.jsx)(`code`,{children:e.commands.installShim})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.installShim),children:t===e.commands.installShim?r(`startup.copied`):r(`startup.copy`)})]}),(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.native`)}),(0,z.jsx)(`code`,{children:e.commands.restoreNative})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(e.commands.restoreNative),children:t===e.commands.restoreNative?r(`startup.copied`):r(`startup.copy`)})]})]}),e.status===`at-risk`&&(0,z.jsxs)(`div`,{className:`notice notice-warn startup-action-notice`,role:`alert`,children:[(0,z.jsx)(X,{}),` `,r(`startup.recommended`,{cmd:e.recommendedCommand??e.commands.installService})]})]})}var qg=`ocx.startup.page.v1:`;function Jg(e,t){let n=t===`win32`?`; `:` && `;return e.join(n)}function Yg(e,t,n){if(!e)return{warning:null,fix:null};let r=!!e.catalogClamp?.active,i=!!e.newerAvailable,a=(r?e.catalogClamp?.runtimeVersion:e.version)??e.version??`unknown`,o=(e.catalogClamp?.removedEfforts??[]).join(`, `),s=Jg([`ocx doctor --fix-codex-runtime`,`ocx sync`],n);return r?{warning:o?t(`startup.codexRuntime.clampHiddenWithEfforts`,{version:a,efforts:o}):t(`startup.codexRuntime.clampHidden`,{version:a}),fix:i?s:`ocx sync`}:i?{warning:t(`startup.codexRuntime.olderBinary`,{version:a}),fix:s}:{warning:null,fix:null}}function Xg({apiBase:e}){let{t}=Ze(),n=`${qg}${e}`,r=(0,_.useMemo)(()=>Jn(n),[n]),i=`startup-page:${e}`,[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(()=>r?.tray??null),[l,u]=(0,_.useState)(()=>!r?.data),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(()=>r?.warning??null),[S,C]=(0,_.useState)(()=>r?.fix??null),[w,T]=(0,_.useState)(()=>!r?.data),E=(0,_.useRef)(!!r?.data),D=(0,_.useCallback)(async r=>{let i=E.current;i||(u(!0),T(!0));try{let i=fetch(`${e}/api/settings`,{signal:r}).then(async e=>e.ok?await e.json():null).catch(()=>null),a=await fetch(`${e}/api/startup-health`,{signal:r});if(!a.ok)throw Error(`fetch failed`);let o=await a.json();y(e=>e?.kind===`error`&&(o.status===`native`&&e.forLocalRouting===!0||(e.action===`install-service`?o.serviceViable:o.shimInstalled&&o.shimHealthy))?null:e),E.current=!0;let s=Jn(n);Yn(n,{data:o,warning:s?.warning??null,fix:s?.fix??null,tray:s?.tray??null});let l=o.platform===`win32`?fetch(`${e}/api/windows-tray`,{signal:r}).then(async e=>{if(!e.ok)throw Error(`tray status failed`);let t=await e.json();if(!Rg(t))throw Error(`invalid tray status`);return{tray:t,error:!1}}).catch(()=>({tray:null,error:!0})):Promise.resolve({tray:null,error:!1});return Promise.all([i,l]).then(([e,i])=>{if(r.aborted)return;let a=o.platform===`win32`?i.tray:null;if(o.platform===`win32`?(c(a),m(i.error)):(c(null),m(!1)),u(!1),T(!1),e){let r=Yg(e.codexRuntime,t,o.platform);x(r.warning),C(r.fix),Yn(n,{data:o,warning:r.warning,fix:r.fix,tray:a});return}let s=Jn(n);Yn(n,{data:o,warning:s?.warning??null,fix:s?.fix??null,tray:a})}),o}catch(e){throw r.aborted?e:(i||(c(null),m(!0),x(null),C(null)),T(!1),u(!1),e)}},[e,n,t]),O=Zs(i,[e],D,{isEmpty:()=>!1,initialData:r?.data??void 0}),k=O.state,A=O.refresh,j=k.data??r?.data??null,M=k.refreshing,N=!!j?.diagnosticStale||k.showError;(0,_.useEffect)(()=>{if(!j?.diagnosticStale)return;let e=window.setTimeout(A,2e3);return()=>window.clearTimeout(e)},[j,A]);let P=async e=>{try{await navigator.clipboard.writeText(e),o(e),window.setTimeout(()=>o(t=>t===e?null:t),1600)}catch{o(null)}},F=async t=>{f(!0),m(!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(!Rg(r.status))throw Error(`invalid tray action status`);c(r.status),m(!1)}catch{c(null),m(!0)}finally{f(!1)}},I=async(t,n)=>{g(t),y(null);try{let r=await fetch(`${e}/api/startup-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t,repair:n?.repair===!0})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(typeof e?.error==`string`?e.error:`installation failed`)}y({kind:`success`,action:t,repair:n?.repair===!0}),A()}catch(e){y({kind:`error`,action:t,repair:n?.repair===!0,detail:e instanceof Error?e.message:String(e),forLocalRouting:j?.localRoutingDependency===!0})}finally{g(null)}};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{children:t(`startup.title`)}),(0,z.jsx)(`p`,{className:`page-sub startup-page-sub`,children:t(`startup.subtitle`)})]}),(0,z.jsxs)(`div`,{className:`startup-page-head-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>nt(`dashboard`),children:t(`startup.backToDashboard`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A(),disabled:M,children:[(0,z.jsx)(Y,{}),` `,t(`startup.refresh`)]})]})]}),k.showSkeleton&&!j?(0,z.jsx)($s,{label:t(`startup.loading`),rows:5}):k.kind===`failed-cold`?(0,z.jsxs)(`div`,{className:`startup-page-notice`,children:[(0,z.jsx)(Q,{tone:`err`,children:k.error instanceof Error?k.error.message:t(`startup.error`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A(),children:t(`common.retry`)})]}):j?(0,z.jsxs)(z.Fragment,{children:[k.showError&&(0,z.jsx)(Q,{tone:`err`,children:t(`startup.error`)}),N&&(0,z.jsx)(`div`,{className:`notice notice-warn startup-page-notice`,role:`alert`,children:t(`startup.staleData`)}),(w||b)&&(0,z.jsx)(`div`,{className:`startup-runtime-notice-slot${w&&!b?` startup-runtime-notice-slot--pending`:``}`,"aria-hidden":w&&!b?!0:void 0,children:b&&(0,z.jsxs)(`div`,{className:`notice notice-warn startup-page-notice startup-runtime-notice`,role:`status`,children:[(0,z.jsx)(`p`,{className:`startup-runtime-notice__text`,children:b}),S&&(0,z.jsxs)(`div`,{className:`startup-runtime-notice__fix`,children:[(0,z.jsx)(`code`,{children:S}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void P(S),children:t(a===S?`startup.copied`:`startup.copy`)})]})]})}),(0,z.jsx)(Ug,{failed:N,data:j}),(0,z.jsx)(Wg,{data:j,failed:N,loading:M,installBusy:h,installResult:v,onInstall:(e,t)=>{I(e,t)}}),j.platform===`win32`&&(0,z.jsx)(Gg,{tray:s,trayLoading:l,trayError:p,trayBusy:d,onTrayAction:e=>{F(e)}}),(0,z.jsx)(Kg,{data:j,copied:a,onCopy:e=>{P(e)}})]}):null]})}var Zg=3e5,Qg=6e5,$g=`https://github.com/lidge-jun/opencodex`;async function e_(e,t){let n=await fetch(e,{signal:t});return n.ok?await n.json():null}function t_({apiBase:e,onOpenUpdate:t}){let n=Z(),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),s=I(`sidebar-star:${e}`,[e],t=>e_(`${e}/api/github/star`,t),{pollMs:Zg}),c=I(`sidebar-update-badge:${e}`,[e],t=>e_(`${e}/api/update/badge`,t),{pollMs:Qg}),l=s.data?.state??null,u=a!==null&&a.basedOn===l?a.state:l??`not-starred`,d=s.data?.url??$g,f=u===`starred`,p=c.data,m=p?.updateAvailable===!0,h=p?.latestVersion??null,g=()=>window.open(d,`_blank`,`noopener,noreferrer`),v=async()=>{if(!(f||r)){if(u===`unauthenticated`){g();return}i(!0);try{let t=await fetch(`${e}/api/github/star`,{method:`POST`}),n=t.ok?await t.json():null;if(n?.ok===!0){o({state:`starred`,basedOn:l});return}n?.state&&o({state:n.state,basedOn:l}),g()}catch{g()}finally{i(!1),s.refresh()}}},y=n(f?`sidebar.starred`:u===`unauthenticated`?`sidebar.starUnauthenticated`:`sidebar.star`),b=m&&h?n(`sidebar.updateAvailable`,{version:h}):n(`sidebar.checkUpdate`);return(0,z.jsxs)(`div`,{className:`sidebar-github-row`,children:[(0,z.jsxs)(`a`,{className:`sidebar-link sidebar-github-link`,href:d,target:`_blank`,rel:`noreferrer`,children:[(0,z.jsx)(me,{}),` `,n(`common.github`)]}),(0,z.jsxs)(`div`,{className:`sidebar-github-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`sidebar-orb${f?` sidebar-orb--starred`:``}`,onClick:()=>{v()},disabled:r||f,"aria-label":y,"aria-pressed":f,title:y,children:(0,z.jsx)(Ee,{"aria-hidden":`true`,...f?{fill:`currentColor`}:{}})}),(0,z.jsxs)(`button`,{type:`button`,className:`sidebar-orb${m?` sidebar-orb--update`:``}`,onClick:t,"aria-label":b,title:b,children:[(0,z.jsx)(fe,{"aria-hidden":`true`}),m&&(0,z.jsx)(`span`,{className:`sidebar-orb-dot`,"aria-hidden":`true`})]})]})]})}var n_=`opencodex-admin-token-dialog`,r_=`OpenCodex`;function i_(e,t=qe()){let n=Be[t],r=n[`auth.adminTokenTitle`];return new Promise(t=>{let i=document.activeElement instanceof HTMLElement?document.activeElement:null,a=!1,o=document.createElement(`dialog`);o.id=n_,o.className=`modal-overlay`,o.setAttribute(`aria-labelledby`,`${n_}-title`);let s=document.createElement(`form`);s.className=`modal-card`,s.method=`post`,s.action=window.location.href,s.autocomplete=`on`;let c=document.createElement(`div`);c.className=`modal-head`;let l=document.createElement(`h3`);l.id=`${n_}-title`,l.textContent=r,c.append(l);let u=document.createElement(`div`),d=document.createElement(`label`);d.className=`field-label`,d.htmlFor=`${n_}-username`,d.textContent=n[`auth.adminAccountLabel`];let f=document.createElement(`input`);f.id=d.htmlFor,f.className=`input`,f.type=`text`,f.name=`username`,f.autocomplete=`username`,f.value=r_,f.readOnly=!0,u.append(d,f);let p=document.createElement(`div`);p.style.marginTop=`var(--space-4)`;let m=document.createElement(`label`);m.className=`field-label`,m.htmlFor=`${n_}-password`,m.textContent=n[`auth.adminTokenFieldLabel`];let h=document.createElement(`input`);h.id=m.htmlFor,h.className=`input`,h.type=`password`,h.name=`password`,h.autocomplete=`current-password`,h.required=!0,h.spellcheck=!1,h.autocapitalize=`none`,p.append(m,h);let g=document.createElement(`div`);g.className=`notice notice-err`,g.setAttribute(`role`,`alert`),g.hidden=!0;let _=document.createElement(`div`);_.className=`modal-actions`;let v=document.createElement(`button`);v.type=`button`,v.className=`btn btn-ghost`,v.textContent=n[`common.cancel`];let y=document.createElement(`button`);y.type=`submit`,y.className=`btn btn-primary`,y.textContent=n[`common.ok`],_.append(v,y),s.append(c,u,p,g,_),o.append(s);let b=e=>{a||(a=!0,o.open&&o.close(),o.remove(),i?.focus(),t(e))};s.addEventListener(`submit`,t=>{t.preventDefault();let r=h.value.trim();if(!r){h.value=``,h.reportValidity();return}h.disabled=!0,y.disabled=!0,g.hidden=!0,e(r).then(e=>{if(!a){if(e===`accepted`){b(r);return}h.value=``,h.disabled=!1,y.disabled=!1,g.textContent=e===`rejected`?n[`auth.adminTokenRejected`]:n[`auth.adminTokenUnavailable`],g.hidden=!1,h.focus()}}).catch(()=>{a||(h.value=``,h.disabled=!1,y.disabled=!1,g.textContent=n[`auth.adminTokenUnavailable`],g.hidden=!1,h.focus())})}),v.addEventListener(`click`,()=>b(null)),o.addEventListener(`cancel`,e=>{e.preventDefault(),b(null)}),document.body.append(o),typeof o.showModal==`function`?o.showModal():o.setAttribute(`open`,``),queueMicrotask(()=>h.focus())})}var a_=!1,o_=null,s_=null,c_=!1,l_=i_,u_=`/opencodex-session`,d_=`/api/settings`;function f_(e){try{let t=e instanceof Request?e.url:String(e),n=new URL(t,window.location.href);return n.origin===window.location.origin&&n.pathname.startsWith(`/api/`)}catch{return!1}}var p_=`opencodex-api-token`,m_=null,h_=null,g_=null;function __(){return m_}function v_(e){m_=e}function y_(){m_=null,h_=null,g_=null}function b_(e){let t=document.querySelector(`meta[name="${e}"]`),n=t?.content.trim()||null;return t?.remove(),n}function x_(){C_(b_(`opencodex-session-token`),b_(`opencodex-session-csrf`),b_(`opencodex-session-origin`))}function S_(e){e!=null&&__()===e&&y_()}function C_(e,t,n){return!e?.startsWith(`ocx_session_`)||!t||n!==window.location.origin?!1:(m_=e,h_=t,g_=n,!0)}function w_(e,t){for(let n of e.match(/<meta\b[^>]*>/gi)??[])if(n.match(/\bname="([^"]+)"/i)?.[1]===t)return n.match(/\bcontent="([^"]*)"/i)?.[1]?.trim()||null;return null}async function T_(){if(!s_)return null;try{let e=await s_(u_,{cache:`no-store`});if(!e.ok)return null;let t=await e.text();return C_(w_(t,`opencodex-session-token`),w_(t,`opencodex-session-csrf`),w_(t,`opencodex-session-origin`))?__():null}catch{return null}}async function E_(e){if(!s_)return`unavailable`;try{let[t,n]=O_(d_,{cache:`no-store`},e),r=await s_(t,n);return r.status===401?`rejected`:r.ok?`accepted`:`unavailable`}catch{return`unavailable`}}function D_(){try{sessionStorage.removeItem(p_)}catch{}}function O_(e,t,n){let r=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));if(r.set(`X-OpenCodex-API-Key`,n),g_&&h_&&n.startsWith(`ocx_session_`)){r.set(`X-OpenCodex-GUI-Origin`,g_);let n=(t?.method??(e instanceof Request?e.method:`GET`)).toUpperCase();n!==`GET`&&n!==`HEAD`&&r.set(`X-OpenCodex-CSRF-Token`,h_)}return e instanceof Request?[new Request(e,{headers:r}),t?{...t,headers:r}:void 0]:[e,{...t,headers:r}]}async function k_(e){return c_?null:o_||(o_=(async()=>{if(c_)return null;let t=__();if(t&&t!==e)return t;let n=await T_();if(n)return n;let r=await l_(E_);return r?(v_(r),r):(c_=!0,null)})().finally(()=>{o_=null}),o_)}function A_(){if(a_)return;a_=!0,D_(),x_();let e=window.fetch.bind(window);s_=e,window.fetch=async(t,n)=>{if(!f_(t))return e(t,n);let r=__(),[i,a]=r?O_(t,n,r):[t,n],o=await e(i,a);if(o.status!==401)return o;let s=__();if(s&&s!==r){let[r,i]=O_(t,n,s),a=await e(r,i);if(a.status!==401)return a;S_(s)}else S_(r);let c=await k_(r);if(!c)return o;let[l,u]=O_(t,n,c),d=await e(l,u);return d.status===401&&S_(c),d}}var j_=new Set([`dashboard`,`startup`,`providers`,`models`,`subagents`,`logs`,`usage`,`storage`,`codex-auth`,`integrations`]);function M_(e){let t=et(e??(typeof window<`u`?window.location.hash:``)).split(`/`)[0];return t===`debug`?`logs`:t===`combos`||t===`routing`||t===`lab`?`models`:t===`api`||t===`claude`||t===`grok`?`integrations`:j_.has(t)?t:`dashboard`}var N_=[`dashboard/providers`,`dashboard/models`],P_=[`models/combos`,`models/routing`,`models/compatibility`],F_=[`integrations/keys`,`integrations/codex`,`integrations/claude`,`integrations/claude/desktop`,`integrations/grok`,`integrations/opencode`,`integrations/pi`,`integrations/omp`,`integrations/hermes`,`integrations/openclaw`,`integrations/kimi`,`integrations/gajae`];function I_(e,t){return e===t||t===`logs`&&e===`logs/debug`||t===`models`&&P_.includes(e)||t===`dashboard`&&(e===`dashboard/update`||N_.includes(e))||t===`integrations`&&F_.includes(e)}function L_(e){let t=M_(e);return e===`debug`||e.startsWith(`debug/`)?{page:`logs`,replaceTo:`logs/debug`}:e===`combos`||e.startsWith(`combos/`)?{page:`models`,replaceTo:`models/combos`}:e===`routing`||e.startsWith(`routing/`)?{page:`models`,replaceTo:`models/routing`}:e===`lab`||e.startsWith(`lab/`)?{page:`models`,replaceTo:`models/compatibility`}:e===`api`?{page:`integrations`,replaceTo:`integrations/keys`}:e===`claude`?{page:`integrations`,replaceTo:`integrations/claude`}:e===`grok`?{page:`integrations`,replaceTo:`integrations/grok`}:e===`providers/workspace`?{page:`providers`,replaceTo:`providers`}:I_(e,t)?{page:t,replaceTo:null}:{page:t,replaceTo:t}}var R_=[`ocx-global-view`,`ocx-view`,`ocx-providers-view`,`ocx-subagents-view`,`ocx-storage-view`,`ocx-codexauth-view`,`ocx-apikeys-view`,`ocx-claudecode-view`,`ocx-usage-view`,`ocx-logs-view`,`ocx-models-view`,`ocx-dashboard-view`];function z_(){try{for(let e of R_)localStorage.removeItem(e)}catch{}}function B_(){let[e,t]=(0,_.useState)(M_);(0,_.useEffect)(()=>{z_()},[]);let n=(0,_.useCallback)(e=>{let n=L_(e);n.replaceTo&&tt(n.replaceTo),t(n.page)},[]);return(0,_.useEffect)(()=>{let e=()=>{n(et(window.location.hash))};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[n]),(0,_.useEffect)(()=>{let n=L_(et(window.location.hash));n.replaceTo&&tt(n.replaceTo),n.page!==e&&t(n.page)},[e]),{page:e,setPageState:t,navigateToPage:(e,n)=>{nt(n?`${e}/${n}`:e),t(e)}}}var V_=15e3;function H_(e,t,n){return typeof e?.message==`string`&&e.message.trim()?e.message:typeof e?.error==`string`&&e.error.trim()?e.error:n(t)}function U_(e){return(e instanceof DOMException||e instanceof Error)&&e.name===`AbortError`}async function W_(e,t={}){let{fetchFn:n=fetch,timeoutMs:r=V_,formatFailure:i=e=>`Failed to stop proxy (HTTP ${e}).`}=t,a;try{a=await n(`${e}/api/stop`,{method:`POST`,signal:AbortSignal.timeout(r)})}catch(e){return U_(e),{accepted:!0}}let o=await a.json().catch(()=>null);return!a.ok||o?.success===!1?{accepted:!1,message:H_(o,a.status,i)}:{accepted:!0}}A_();var G_={dashboard:`nav.dashboard`,startup:`nav.startup`,providers:`nav.providers`,models:`nav.models`,subagents:`nav.subagents`,logs:`nav.logs`,usage:`nav.usage`,storage:`nav.storage`,"codex-auth":`nav.codexAuth`,integrations:`nav.integrations`},K_=``,q_=`ocx-theme`,J_=[{id:`dashboard`,tkey:`nav.dashboard`,Icon:V},{id:`codex-auth`,tkey:`nav.codexAuth`,Icon:ge},{id:`providers`,tkey:`nav.providers`,Icon:H},{id:`models`,tkey:`nav.models`,Icon:U},{id:`subagents`,tkey:`nav.subagents`,Icon:W},{id:`logs`,tkey:`nav.logs`,Icon:G},{id:`usage`,tkey:`nav.usage`,Icon:ne},{id:`storage`,tkey:`nav.storage`,Icon:K},{id:`integrations`,tkey:`nav.integrations`,Icon:Ce}],Y_={light:be,dark:xe,system:Se},X_={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function Z_(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 Q_(){let e=localStorage.getItem(q_);return e===`light`||e===`dark`?e:`system`}function $_(){let{page:e,navigateToPage:t}=B_(),[n,r]=(0,_.useState)(Hu);(0,_.useEffect)(()=>{let e=()=>r(Hu());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let[i,a]=(0,_.useState)(Q_),{locale:o,setLocale:s}=Ze(),c=Z(),[l,u]=(0,_.useState)(!1),d=(0,_.useRef)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(!1);(0,_.useEffect)(()=>{let e=()=>u(!1);return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]),(0,_.useEffect)(()=>{let e=document.documentElement;i===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(q_)):(e.setAttribute(`data-theme`,i),localStorage.setItem(q_,i))},[i]);let m=I(`app-healthz:${K_}`,[],async e=>{let t=await fetch(`${K_}/healthz`,{signal:e});return t.ok?Z_(await t.json()):null},{pollMs:3e4}),h=()=>a(e=>e===`light`?`dark`:e===`dark`?`system`:`light`),g=Y_[i],v=m.data??`2.15.0`,[y,b]=(0,_.useState)(!1);(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)},[]);let x=async()=>{if(!confirm(c(`dash.stopConfirm`)))return;b(!0);let e=await W_(K_,{formatFailure:e=>c(`dash.stopFailed`,{status:String(e)})});e.accepted||(b(!1),alert(e.message))},S=(0,z.jsxs)(`div`,{className:`brand`,children:[(0,z.jsx)(`span`,{className:`brand-logo`,role:`img`,"aria-label":c(`app.logoAria`)}),(0,z.jsx)(`span`,{className:`name`,children:`opencodex`}),(0,z.jsxs)(`span`,{className:`ver`,children:[`v`,v]})]});return(0,z.jsxs)(`div`,{className:`app`,children:[(0,z.jsxs)(`header`,{className:`mobile-topbar`,inert:l,children:[(0,z.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,z.jsx)(ee,{})}),S,(0,z.jsx)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:x,disabled:y,"aria-label":c(`dash.stop`),title:c(`dash.stop`),children:(0,z.jsx)(X,{})})]}),l&&(0,z.jsx)(`div`,{className:`drawer-scrim`,onClick:()=>u(!1),"aria-hidden":`true`}),(0,z.jsxs)(`aside`,{id:`app-sidebar`,className:`sidebar${l?` open`:``}`,ref:f,tabIndex:-1,children:[(0,z.jsxs)(`div`,{className:`drawer-head`,children:[S,(0,z.jsx)(`button`,{type:`button`,className:`menu-toggle drawer-close`,onClick:()=>u(!1),"aria-label":c(`nav.closeMenu`),title:c(`nav.closeMenu`),children:(0,z.jsx)(J,{})})]}),(0,z.jsx)(`nav`,{children:J_.map(n=>{let{id:r,tkey:i,Icon:a}=n,o=r===e;return(0,z.jsx)(`div`,{className:`nav-entry`,children:(0,z.jsxs)(`button`,{type:`button`,className:`nav-item${o?` active`:``}`,"data-page":r,onClick:()=>{t(r),u(!1)},"aria-current":o?`page`:void 0,children:[(0,z.jsx)(a,{}),` `,c(i)]})},r)})}),(0,z.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,z.jsxs)(`div`,{className:`lang-toggle`,children:[(0,z.jsx)(Ce,{"aria-hidden":!0}),(0,z.jsx)(gt,{value:o,options:Ue.map(e=>({value:e.code,label:Ve(e.code)})),onChange:e=>s(e),label:c(`lang.label`),placement:`right`,portal:!1,style:{flex:1,minWidth:0,width:`100%`}})]}),(0,z.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:h,"aria-label":`${c(`theme.label`)}: ${c(X_[i])}`,title:`${c(`theme.label`)}: ${c(X_[i])}`,children:[(0,z.jsx)(g,{}),` `,(0,z.jsx)(`span`,{className:`mode`,children:c(X_[i])})]}),(0,z.jsxs)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:x,disabled:y,"aria-label":c(`dash.stop`),title:c(`dash.stop`),children:[(0,z.jsx)(X,{}),` `,(0,z.jsx)(`span`,{className:`mode`,children:c(y?`dash.stopping`:`dash.stop`)})]}),(0,z.jsx)(t_,{apiBase:K_,onOpenUpdate:()=>{u(!1),t(`dashboard`,`update`)}})]})]}),(0,z.jsx)(`main`,{className:`main`,inert:l,children:(0,z.jsx)(`div`,{className:`main-inner${e===`models`&&n===`combos`?` main-inner--combos`:``}`,children:(0,z.jsxs)(tc,{pageName:c(G_[e]),title:c(`errorBoundary.title`),message:c(`errorBoundary.message`),detailsLabel:c(`errorBoundary.details`),reloadLabel:c(`errorBoundary.reload`),children:[e===`dashboard`&&(0,z.jsx)(Tr,{apiBase:K_}),e===`startup`&&(0,z.jsx)(Xg,{apiBase:K_}),e===`providers`&&(0,z.jsx)(Ws,{apiBase:K_}),e===`models`&&(0,z.jsx)(vd,{apiBase:K_},K_),e===`subagents`&&(0,z.jsx)(Ad,{apiBase:K_},K_),e===`logs`&&(0,z.jsx)(tp,{apiBase:K_}),e===`usage`&&(0,z.jsx)(Cp,{apiBase:K_}),e===`storage`&&(0,z.jsx)(Vp,{apiBase:K_}),e===`codex-auth`&&(0,z.jsx)(Jp,{apiBase:K_}),e===`integrations`&&(0,z.jsx)(Lg,{apiBase:K_})]},e)})})]})}g.createRoot(document.getElementById(`root`)).render((0,z.jsx)(_.StrictMode,{children:(0,z.jsx)(Qe,{children:(0,z.jsx)($_,{})})}));
|
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-B5T5ADgY.js"></script>
|
|
20
20
|
<link rel="stylesheet" crossorigin href="/assets/index-DUCH59lJ.css">
|
|
21
21
|
</head>
|
|
22
22
|
<body>
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Cursor model ids encode the reasoning effort as a suffix (`claude-4.6-opus-high`), and the available
|
|
5
5
|
* tiers differ per model — `claude-4.6-opus` tops out at `-max`, `claude-opus-4-8` at `-xhigh`,
|
|
6
6
|
* `claude-4.6-sonnet` only has `-medium`, and most `composer`/`gemini` models take no suffix at all.
|
|
7
|
-
* Grok Fast puts its mode marker after the effort (`grok-4.
|
|
7
|
+
* Grok Fast puts its mode marker after the effort (`grok-4.6-xhigh-fast`). A bare id for a model that
|
|
8
8
|
* requires a suffix is rejected `ERROR_BAD_MODEL_NAME` (devlog 350.105).
|
|
9
9
|
*
|
|
10
10
|
* Canonical effort order is always low < medium < high < xhigh < max (max is the top tier, confirmed
|
|
@@ -35,10 +35,9 @@ const CURSOR_MODEL_EFFORT_TIERS: Record<string, readonly string[]> = {
|
|
|
35
35
|
// cursor-grok-4.5-{low,medium,high}-fast. The bare Fast id returns not_found.
|
|
36
36
|
"grok-4.5": ["low", "medium", "high"],
|
|
37
37
|
"grok-4.5-fast": ["low", "medium", "high"],
|
|
38
|
-
// 260813
|
|
39
|
-
|
|
40
|
-
"grok-4.6": ["low", "medium", "high"],
|
|
41
|
-
"grok-4.6-fast": ["low", "medium", "high"],
|
|
38
|
+
// Cursor's 260813 lineup exposes Grok 4.6 Extra High in both regular and Fast forms.
|
|
39
|
+
"grok-4.6": ["low", "medium", "high", "xhigh"],
|
|
40
|
+
"grok-4.6-fast": ["low", "medium", "high", "xhigh"],
|
|
42
41
|
"gpt-5.1": ["low", "high"],
|
|
43
42
|
"gpt-5.1-codex-max": ["low", "medium", "high", "xhigh"],
|
|
44
43
|
"gpt-5.1-codex-mini": ["low", "high"],
|
|
@@ -174,7 +174,7 @@ function catalogLimitNote(kept: readonly OcxTool[], omitted: readonly OcxTool[])
|
|
|
174
174
|
/**
|
|
175
175
|
* Resolve a `cursor/<model>` selection + Codex reasoning effort to Cursor's requested model shape.
|
|
176
176
|
* Most models encode effort in a flat id (`claude-4.6-opus-high`). Grok Fast is parameterized
|
|
177
|
-
* instead: current Cursor clients send the
|
|
177
|
+
* instead: current Cursor clients send the matching Grok base id plus `effort` and `fast` parameters.
|
|
178
178
|
* A fully-qualified id (one that is not a known effort base) passes through unchanged.
|
|
179
179
|
*/
|
|
180
180
|
function normalizeCursorModelId(modelId: string, reasoning?: string): {
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
"path": "package.json",
|
|
13
|
-
"sha256": "
|
|
13
|
+
"sha256": "c3251067cb20065a4a5f341341349fdad0824e27b6918874a9f2ea626566c564"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"path": "scripts/model-metadata.source.json",
|
|
17
|
-
"sha256": "
|
|
17
|
+
"sha256": "6e5301171f8003cfa241d5fc0d03c4a71df872d0888b8f182a1bfa081fe2e55f"
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"path": "src/AGENTS.md",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
"path": "src/adapters/cursor/effort-map.ts",
|
|
77
|
-
"sha256": "
|
|
77
|
+
"sha256": "0bd99fed73779c1b49eac385a350d2825fcab9cb2996845f61ce9b76d47ac1bd"
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
"path": "src/adapters/cursor/exec-policy.ts",
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
},
|
|
159
159
|
{
|
|
160
160
|
"path": "src/adapters/cursor/request-builder.ts",
|
|
161
|
-
"sha256": "
|
|
161
|
+
"sha256": "ec30a9988cf25a8bc51b2bb286ce25033b6a86591e5036d8d24b74e79b824704"
|
|
162
162
|
},
|
|
163
163
|
{
|
|
164
164
|
"path": "src/adapters/cursor/thread-continuity.ts",
|
|
@@ -970,7 +970,7 @@
|
|
|
970
970
|
},
|
|
971
971
|
{
|
|
972
972
|
"path": "src/generated/model-metadata.ts",
|
|
973
|
-
"sha256": "
|
|
973
|
+
"sha256": "a21e063f1e968ea715080b732b1066867183873ca0cffce04f0c0cb4ce99e1b8"
|
|
974
974
|
},
|
|
975
975
|
{
|
|
976
976
|
"path": "src/github/star-state.ts",
|
|
@@ -1754,7 +1754,7 @@
|
|
|
1754
1754
|
},
|
|
1755
1755
|
{
|
|
1756
1756
|
"path": "src/oauth/index.ts",
|
|
1757
|
-
"sha256": "
|
|
1757
|
+
"sha256": "cbe370cd31412914b4cd2f565fd519eb45897ebd4ec7284503f68926017e127d"
|
|
1758
1758
|
},
|
|
1759
1759
|
{
|
|
1760
1760
|
"path": "src/oauth/key-providers.ts",
|
|
@@ -1822,7 +1822,7 @@
|
|
|
1822
1822
|
},
|
|
1823
1823
|
{
|
|
1824
1824
|
"path": "src/providers/antigravity-models.ts",
|
|
1825
|
-
"sha256": "
|
|
1825
|
+
"sha256": "e7a2b7352997cfdc4268c733def555dae8632ba58a3f889dfc78d812b885d072"
|
|
1826
1826
|
},
|
|
1827
1827
|
{
|
|
1828
1828
|
"path": "src/providers/api-keys.ts",
|
|
@@ -1882,7 +1882,7 @@
|
|
|
1882
1882
|
},
|
|
1883
1883
|
{
|
|
1884
1884
|
"path": "src/providers/model-rename-migration.ts",
|
|
1885
|
-
"sha256": "
|
|
1885
|
+
"sha256": "3a321e04e7b73a969536befb115caf3d50994c058b8c365e1213114da3414490"
|
|
1886
1886
|
},
|
|
1887
1887
|
{
|
|
1888
1888
|
"path": "src/providers/model-rename-startup.ts",
|
|
@@ -1922,7 +1922,7 @@
|
|
|
1922
1922
|
},
|
|
1923
1923
|
{
|
|
1924
1924
|
"path": "src/providers/registry.ts",
|
|
1925
|
-
"sha256": "
|
|
1925
|
+
"sha256": "f02400134cf6e4ed1d8ba5e4381abbc4b4e091dd26b4958b8e28bc40cf18d8dc"
|
|
1926
1926
|
},
|
|
1927
1927
|
{
|
|
1928
1928
|
"path": "src/providers/slug-codec.ts",
|
|
@@ -2534,7 +2534,7 @@
|
|
|
2534
2534
|
},
|
|
2535
2535
|
{
|
|
2536
2536
|
"path": "src/usage/expected-prices.ts",
|
|
2537
|
-
"sha256": "
|
|
2537
|
+
"sha256": "3b2874f24e7d53979fee5829f6b710b21cfefe06fb96f5cc887247aab5606acc"
|
|
2538
2538
|
},
|
|
2539
2539
|
{
|
|
2540
2540
|
"path": "src/usage/log.ts",
|
|
@@ -42,7 +42,7 @@ const DATA: Record<string, readonly Row[]> = {
|
|
|
42
42
|
"azure-openai": [["gpt-4.1",1047576,32768,"text,image",0,null,2,8,0.5,0],["gpt-4o",128000,16384,"text,image",0,null,2.5,10,1.25,0],["gpt-4o-mini",128000,16384,"text,image",0,null,0.15,0.6,0.075,0],["o3",200000,100000,"text,image",1,null,2,8,0.5,0],["o3-mini",200000,100000,"text",1,null,1.1,4.4,0.55,0]],
|
|
43
43
|
"cerebras": [["gemma-4-31b",131072,40960,"text,image",1,null,0.99,1.49,0,0],["gpt-oss-120b",131072,40960,"text",1,null,0.35,0.75,0,0],["llama3.1-8b",32000,8000,"text",0,null,0.1,0.1,0,0],["qwen-3-235b-a22b-instruct-2507",131000,32000,"text",0,null,0.6,1.2,0,0],["qwen-3-coder-480b",131072,32768,"text",0,null,0,0,0,0],["zai-glm-4.6",131072,32768,"text",0,null,0,0,0,0],["zai-glm-4.7",131072,40960,"text",1,null,2.25,2.75,2.25,0]],
|
|
44
44
|
"deepseek": [["deepseek-v4-flash",1048576,384000,"text",1,null,0.14,0.28,0.0028,0],["deepseek-v4-pro",1048576,384000,"text",1,null,0.435,0.87,0.003625,0]],
|
|
45
|
-
"google": [["deep-research-max-preview-04-2026",131072,65536,"text,image",1,null,2,12,0.2,0],["deep-research-preview-04-2026",131072,65536,"text,image",1,null,2,12,0.2,0],["gemini-1.5-flash",1000000,8192,"text,image",0,null,0.075,0.3,0.01875,0],["gemini-1.5-flash-8b",1000000,8192,"text,image",0,null,0.0375,0.15,0.01,0],["gemini-1.5-pro",1000000,8192,"text,image",0,null,1.25,5,0.3125,0],["gemini-2.0-flash",1048576,8192,"text,image",0,null,0.1,0.4,0.025,0],["gemini-2.0-flash-lite",1048576,8192,"text,image",0,null,0.075,0.3,0,0],["gemini-2.5-computer-use-preview-10-2025",131072,65536,"text,image",1,null,1.25,10,0,0],["gemini-2.5-flash",1048576,65536,"text,image",1,null,0.3,2.5,0.03,0],["gemini-2.5-flash-lite",1048576,65536,"text,image",1,null,0.1,0.4,0.01,0],["gemini-2.5-flash-lite-preview-06-17",1048576,65536,"text,image",1,null,0.1,0.4,0.025,0],["gemini-2.5-flash-lite-preview-09-2025",1048576,65536,"text,image",1,null,0.1,0.4,0.025,0],["gemini-2.5-flash-preview-04-17",1048576,65536,"text,image",1,null,0.15,0.6,0.0375,0],["gemini-2.5-flash-preview-05-20",1048576,65536,"text,image",1,null,0.15,0.6,0.0375,0],["gemini-2.5-flash-preview-09-2025",1048576,65536,"text,image",1,null,0.3,2.5,0.075,0],["gemini-2.5-pro",1048576,65536,"text,image",1,null,1.25,10,0.125,0],["gemini-2.5-pro-preview-05-06",1048576,65536,"text,image",1,null,1.25,10,0.31,0],["gemini-2.5-pro-preview-06-05",1048576,65536,"text,image",1,null,1.25,10,0.31,0],["gemini-3-flash-preview",1048576,65536,"text,image",1,null,0.5,3,0.05,0],["gemini-3-pro-preview",1048576,65536,"text,image",1,null,2,12,0.2,0],["gemini-3.1-flash-lite",1048576,65536,"text,image",1,null,0.25,1.5,0.025,0],["gemini-3.1-flash-lite-image",65536,65536,"text,image",1,null,0.25,30,0,0],["gemini-3.1-flash-lite-preview",1048576,65536,"text,image",1,null,0.25,1.5,0.025,0],["gemini-3.1-flash-live-preview",131072,65536,"text,image",1,null,0.75,4.5,0,0],["gemini-3.1-pro-preview",1048576,65536,"text,image",1,null,2,12,0.2,0],["gemini-3.1-pro-preview-customtools",1048576,65536,"text,image",1,null,2,12,0.2,0],["gemini-3.5-flash",1048576,65536,"text,image",1,null,1.5,9,0.15,0],["gemini-3.5-flash-lite",1048576,65536,"text,image",1,null,0.3,2.5,0.03,0],["gemini-3.6-flash",1048576,65536,"text,image",1,null,1.5,7.5,0.15,0],["gemini-flash-latest",1048576,65536,"text,image",1,null,1.5,9,0.15,0],["gemini-flash-lite-latest",1048576,65536,"text,image",1,null,0.25,1.5,0.025,0],["gemini-live-2.5-flash",128000,8000,"text,image",1,null,0.5,2,0,0],["gemini-live-2.5-flash-preview-native-audio",131072,65536,"text",1,null,0.5,2,0,0],["gemini-robotics-er-1.6-preview",131072,65536,"text,image",1,null,1,5,0,0],["gemma-3-27b-it",131072,8192,"text,image",0,null,0,0,0,0],["gemma-4-26b",256000,8192,"text,image",1,null,0,0,0,0],["gemma-4-26b-a4b-it",262144,32768,"text,image",1,null,0,0,0,0],["gemma-4-26b-it",256000,8192,"text,image",1,null,0,0,0,0],["gemma-4-31b",256000,8192,"text,image",1,null,0,0,0,0],["gemma-4-31b-it",262144,32768,"text,image",1,null,0,0,0,0],["gemma-4-E2B-it",131072,8192,"text,image",1,null,0,0,0,0],["gemma-4-E4B-it",131072,8192,"text,image",1,null,0,0,0,0]],
|
|
45
|
+
"google": [["deep-research-max-preview-04-2026",131072,65536,"text,image",1,null,2,12,0.2,0],["deep-research-preview-04-2026",131072,65536,"text,image",1,null,2,12,0.2,0],["gemini-1.5-flash",1000000,8192,"text,image",0,null,0.075,0.3,0.01875,0],["gemini-1.5-flash-8b",1000000,8192,"text,image",0,null,0.0375,0.15,0.01,0],["gemini-1.5-pro",1000000,8192,"text,image",0,null,1.25,5,0.3125,0],["gemini-2.0-flash",1048576,8192,"text,image",0,null,0.1,0.4,0.025,0],["gemini-2.0-flash-lite",1048576,8192,"text,image",0,null,0.075,0.3,0,0],["gemini-2.5-computer-use-preview-10-2025",131072,65536,"text,image",1,null,1.25,10,0,0],["gemini-2.5-flash",1048576,65536,"text,image",1,null,0.3,2.5,0.03,0],["gemini-2.5-flash-lite",1048576,65536,"text,image",1,null,0.1,0.4,0.01,0],["gemini-2.5-flash-lite-preview-06-17",1048576,65536,"text,image",1,null,0.1,0.4,0.025,0],["gemini-2.5-flash-lite-preview-09-2025",1048576,65536,"text,image",1,null,0.1,0.4,0.025,0],["gemini-2.5-flash-preview-04-17",1048576,65536,"text,image",1,null,0.15,0.6,0.0375,0],["gemini-2.5-flash-preview-05-20",1048576,65536,"text,image",1,null,0.15,0.6,0.0375,0],["gemini-2.5-flash-preview-09-2025",1048576,65536,"text,image",1,null,0.3,2.5,0.075,0],["gemini-2.5-pro",1048576,65536,"text,image",1,null,1.25,10,0.125,0],["gemini-2.5-pro-preview-05-06",1048576,65536,"text,image",1,null,1.25,10,0.31,0],["gemini-2.5-pro-preview-06-05",1048576,65536,"text,image",1,null,1.25,10,0.31,0],["gemini-3-flash-preview",1048576,65536,"text,image",1,null,0.5,3,0.05,0],["gemini-3-pro-preview",1048576,65536,"text,image",1,null,2,12,0.2,0],["gemini-3.1-flash-lite",1048576,65536,"text,image",1,null,0.25,1.5,0.025,0],["gemini-3.1-flash-lite-image",65536,65536,"text,image",1,null,0.25,30,0,0],["gemini-3.1-flash-lite-preview",1048576,65536,"text,image",1,null,0.25,1.5,0.025,0],["gemini-3.1-flash-live-preview",131072,65536,"text,image",1,null,0.75,4.5,0,0],["gemini-3.1-pro-preview",1048576,65536,"text,image",1,null,2,12,0.2,0],["gemini-3.1-pro-preview-customtools",1048576,65536,"text,image",1,null,2,12,0.2,0],["gemini-3.5-flash",1048576,65536,"text,image",1,null,1.5,9,0.15,0],["gemini-3.5-flash-lite",1048576,65536,"text,image",1,null,0.3,2.5,0.03,0],["gemini-3.6-flash",1048576,65536,"text,image",1,null,1.5,7.5,0.15,0],["gemini-3.7-flash",1048576,65536,"text,image",1],["gemini-flash-latest",1048576,65536,"text,image",1,null,1.5,9,0.15,0],["gemini-flash-lite-latest",1048576,65536,"text,image",1,null,0.25,1.5,0.025,0],["gemini-live-2.5-flash",128000,8000,"text,image",1,null,0.5,2,0,0],["gemini-live-2.5-flash-preview-native-audio",131072,65536,"text",1,null,0.5,2,0,0],["gemini-robotics-er-1.6-preview",131072,65536,"text,image",1,null,1,5,0,0],["gemma-3-27b-it",131072,8192,"text,image",0,null,0,0,0,0],["gemma-4-26b",256000,8192,"text,image",1,null,0,0,0,0],["gemma-4-26b-a4b-it",262144,32768,"text,image",1,null,0,0,0,0],["gemma-4-26b-it",256000,8192,"text,image",1,null,0,0,0,0],["gemma-4-31b",256000,8192,"text,image",1,null,0,0,0,0],["gemma-4-31b-it",262144,32768,"text,image",1,null,0,0,0,0],["gemma-4-E2B-it",131072,8192,"text,image",1,null,0,0,0,0],["gemma-4-E4B-it",131072,8192,"text,image",1,null,0,0,0,0]],
|
|
46
46
|
"minimax": [["MiniMax-M2",196608,128000,"text",1,null,0.3,1.2,0,0],["MiniMax-M2.1",204800,131072,"text",1,null,0.3,1.2,0,0],["MiniMax-M2.5",204800,131072,"text",1,null,0.3,1.2,0.03,0.375],["MiniMax-M2.5-highspeed",204800,131072,"text",1,null,0.6,2.4,0.06,0.375],["MiniMax-M2.5-lightning",204800,32000,"text",1,null,0.3,2.4,0,0],["MiniMax-M2.7",204800,131072,"text",1,null,0.3,1.2,0.06,0.375],["MiniMax-M2.7-highspeed",204800,131072,"text",1,null,0.6,2.4,0.06,0.375],["minimax-m3",512000,128000,"text,image",1,null,0.6,2.4,0.12,0],["MiniMax-M3",1000000,128000,"text,image,video",1,null,0.3,1.2,0.06,0]],
|
|
47
47
|
"mistral": [["codestral-latest",256000,4096,"text",0,null,0.3,0.9,0,0],["devstral-2512",262144,262144,"text",0,null,0.4,2,0,0],["devstral-latest",262144,262144,"text",0,null,0.4,2,0,0],["devstral-medium-2507",128000,128000,"text",0,null,0.4,2,0,0],["devstral-medium-latest",262144,262144,"text",0,null,0.4,2,0,0],["devstral-small-2505",128000,128000,"text",0,null,0.1,0.3,0,0],["devstral-small-2507",128000,128000,"text",0,null,0.1,0.3,0,0],["labs-devstral-small-2512",256000,256000,"text,image",0,null,0,0,0,0],["magistral-medium-latest",128000,16384,"text",1,null,2,5,0,0],["magistral-small",128000,128000,"text",1,null,0.5,1.5,0,0],["ministral-3b-latest",128000,128000,"text",0,null,0.04,0.04,0,0],["ministral-8b-latest",128000,128000,"text",0,null,0.1,0.1,0,0],["mistral-large-2411",131072,16384,"text",0,null,2,6,0,0],["mistral-large-2512",262144,262144,"text,image",0,null,0.5,1.5,0,0],["mistral-large-latest",262144,262144,"text,image",0,null,0.5,1.5,0,0],["mistral-medium-2505",131072,131072,"text,image",0,null,0.4,2,0,0],["mistral-medium-2508",262144,262144,"text,image",0,null,0.4,2,0,0],["mistral-medium-2604",262144,262144,"text,image",1,null,1.5,7.5,0,0],["mistral-medium-latest",262144,262144,"text,image",1,null,1.5,7.5,0,0],["mistral-nemo",128000,128000,"text",0,null,0.15,0.15,0,0],["mistral-small-2506",128000,16384,"text,image",0,null,0.1,0.3,0,0],["mistral-small-2603",256000,256000,"text,image",1,null,0.15,0.6,0,0],["mistral-small-latest",256000,256000,"text,image",1,null,0.15,0.6,0,0],["open-mistral-7b",8000,8000,"text",0,null,0.25,0.25,0,0],["open-mistral-nemo",128000,128000,"text",0,null,0.15,0.15,0,0],["open-mixtral-8x22b",64000,64000,"text",0,null,2,6,0,0],["open-mixtral-8x7b",32000,32000,"text",0,null,0.7,0.7,0,0],["pixtral-12b",128000,128000,"text,image",0,null,0.15,0.15,0,0],["pixtral-large-latest",128000,128000,"text,image",0,null,2,6,0,0]],
|
|
48
48
|
"moonshot": [["kimi-k2.5",262144,65536,"text,image",1,null,0,0,0,0]],
|
package/src/oauth/index.ts
CHANGED
|
@@ -879,6 +879,9 @@ function isLegacyCommandCodeStaticCatalog(provider: OcxProviderConfig): boolean
|
|
|
879
879
|
}
|
|
880
880
|
|
|
881
881
|
function isLegacyAntigravityStaticCatalog(provider: OcxProviderConfig): boolean {
|
|
882
|
+
// A fingerprint of the shape version 1 actually shipped, NOT of the current registry.
|
|
883
|
+
// These literals must stay frozen as the model list moves on: matching them is how we
|
|
884
|
+
// know the row is the untouched v1 seed rather than a user's own selection.
|
|
882
885
|
return provider.liveModels === false
|
|
883
886
|
&& provider.adapter === "google"
|
|
884
887
|
&& provider.baseUrl === "https://daily-cloudcode-pa.googleapis.com"
|
|
@@ -10,10 +10,39 @@ import { isValidModelDiscoveryModelId, MODEL_DISCOVERY_MAX_MODELS } from "./mode
|
|
|
10
10
|
// returned wire id remains visible so an unavailable tier cannot be selected.
|
|
11
11
|
|
|
12
12
|
// ── Wire IDs (what CCA :fetchAvailableModels returns) ──
|
|
13
|
+
|
|
14
|
+
/** Current Antigravity Flash generation. */
|
|
15
|
+
const GEMINI_FLASH_CURRENT = "gemini-3.7-flash";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Retired Flash ids → the reasoning tier they used to encode.
|
|
19
|
+
*
|
|
20
|
+
* Google pulls the previous Flash model from CCA almost immediately when the next
|
|
21
|
+
* one ships, so a saved selection cannot keep pointing at it. A flat alias would
|
|
22
|
+
* strand the user's tier: `resolveAntigravityEffortWireModel` rule 1 treats any
|
|
23
|
+
* alias as "the suffix IS the effort" and deliberately sends no thinkingConfig, so
|
|
24
|
+
* `gemini-3.6-flash-high` would silently become an untiered 3.7 call. Carrying the
|
|
25
|
+
* level here preserves what the user actually chose.
|
|
26
|
+
*
|
|
27
|
+
* 3.7 exposes tiers through `thinkingLevel` on ONE wire id rather than through
|
|
28
|
+
* suffixed wire ids, which is why the mapping is id → level and not id → id.
|
|
29
|
+
*/
|
|
30
|
+
const RETIRED_FLASH_TIERS: Record<string, string> = {
|
|
31
|
+
// 3.6 generation.
|
|
32
|
+
"gemini-3.6-flash": "medium", // bare base carried a medium default
|
|
33
|
+
"gemini-3.6-flash-low": "low",
|
|
34
|
+
"gemini-3.6-flash-medium": "medium",
|
|
35
|
+
"gemini-3.6-flash-high": "high",
|
|
36
|
+
// 3.5 generation — these already pointed at 3.6 wire ids, which are now dead too.
|
|
37
|
+
"gemini-3.5-flash-extra-low": "low",
|
|
38
|
+
"gemini-3.5-flash-low": "medium",
|
|
39
|
+
"gemini-3.5-flash-mid": "medium",
|
|
40
|
+
"gemini-3.5-flash-high": "high",
|
|
41
|
+
"gemini-3-flash-agent": "high",
|
|
42
|
+
};
|
|
43
|
+
|
|
13
44
|
const ANTIGRAVITY_WIRE_MODELS = [
|
|
14
|
-
"gemini-3.
|
|
15
|
-
"gemini-3.6-flash-medium",
|
|
16
|
-
"gemini-3.6-flash-high",
|
|
45
|
+
"gemini-3.7-flash",
|
|
17
46
|
"gemini-3.1-pro-low",
|
|
18
47
|
"gemini-pro-agent",
|
|
19
48
|
"gemini-3.1-flash-image",
|
|
@@ -23,9 +52,6 @@ const ANTIGRAVITY_WIRE_MODELS = [
|
|
|
23
52
|
];
|
|
24
53
|
|
|
25
54
|
const ANTIGRAVITY_PICKER_MODEL_BY_WIRE_ID: Record<string, string> = {
|
|
26
|
-
"gemini-3.6-flash-low": "gemini-3.6-flash",
|
|
27
|
-
"gemini-3.6-flash-medium": "gemini-3.6-flash",
|
|
28
|
-
"gemini-3.6-flash-high": "gemini-3.6-flash",
|
|
29
55
|
"gemini-3.1-pro-low": "gemini-3.1-pro",
|
|
30
56
|
"gemini-pro-agent": "gemini-3.1-pro",
|
|
31
57
|
};
|
|
@@ -41,7 +67,7 @@ const ANTIGRAVITY_WIRE_IDS_BY_PICKER_MODEL: Record<string, string[]> = Object.en
|
|
|
41
67
|
// Gemini models: effort → wire model suffix (official agy UI pattern).
|
|
42
68
|
// Claude Opus: effort → thinkingConfig.thinkingLevel (CLIProxyAPI proven pattern).
|
|
43
69
|
export const ANTIGRAVITY_MODEL_EFFORTS: Record<string, string[]> = {
|
|
44
|
-
"gemini-3.
|
|
70
|
+
"gemini-3.7-flash": ["low", "medium", "high"],
|
|
45
71
|
"gemini-3.1-pro": ["low", "high"],
|
|
46
72
|
"claude-sonnet-4-6": ["low", "medium", "high", "max"],
|
|
47
73
|
"claude-opus-4-6-thinking": ["low", "medium", "high", "max"],
|
|
@@ -49,11 +75,6 @@ export const ANTIGRAVITY_MODEL_EFFORTS: Record<string, string[]> = {
|
|
|
49
75
|
|
|
50
76
|
// ── Effort → wire model map for Gemini base models ──
|
|
51
77
|
const ANTIGRAVITY_EFFORT_WIRE_MAP: Record<string, Record<string, string>> = {
|
|
52
|
-
"gemini-3.6-flash": {
|
|
53
|
-
low: "gemini-3.6-flash-low",
|
|
54
|
-
medium: "gemini-3.6-flash-medium",
|
|
55
|
-
high: "gemini-3.6-flash-high",
|
|
56
|
-
},
|
|
57
78
|
"gemini-3.1-pro": {
|
|
58
79
|
low: "gemini-3.1-pro-low",
|
|
59
80
|
high: "gemini-pro-agent",
|
|
@@ -62,11 +83,20 @@ const ANTIGRAVITY_EFFORT_WIRE_MAP: Record<string, Record<string, string>> = {
|
|
|
62
83
|
|
|
63
84
|
// ── Default effort per Gemini base model ──
|
|
64
85
|
const ANTIGRAVITY_DEFAULT_EFFORT: Record<string, string> = {
|
|
65
|
-
"gemini-3.6-flash": "medium",
|
|
66
86
|
"gemini-3.1-pro": "high",
|
|
67
87
|
};
|
|
68
88
|
|
|
69
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Gemini base models whose efforts ride on `thinkingLevel` against a single wire id
|
|
91
|
+
* instead of suffixed wire ids, with the level applied when the caller names none.
|
|
92
|
+
*/
|
|
93
|
+
const ANTIGRAVITY_THINKING_LEVEL_MODELS: Record<string, string> = {
|
|
94
|
+
"gemini-3.7-flash": "medium",
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// `minimal` is deliberately absent: Google documents it as unsupported for the current
|
|
98
|
+
// Flash generation, where it is an error rather than a quieter tier.
|
|
99
|
+
const ANTIGRAVITY_THINKING_LEVELS = new Set(["low", "medium", "high"]);
|
|
70
100
|
|
|
71
101
|
function resolveAntigravityThinkingLevel(effort: string): string | undefined {
|
|
72
102
|
if (effort === "xhigh" || effort === "max" || effort === "ultra") return "high";
|
|
@@ -83,16 +113,17 @@ const ANTIGRAVITY_VISIBLE_MODEL_ALIASES: Record<string, string> = {
|
|
|
83
113
|
// Wire suffix IDs are identity aliases — they resolve to themselves so saved configs
|
|
84
114
|
// with explicit suffixes (e.g. gemini-3.6-flash-low) continue to work.
|
|
85
115
|
const ANTIGRAVITY_COMPATIBILITY_MODEL_ALIASES: Record<string, string> = {
|
|
86
|
-
"gemini-3.6-flash-low": "gemini-3.6-flash-low",
|
|
87
|
-
"gemini-3.6-flash-medium": "gemini-3.6-flash-medium",
|
|
88
|
-
"gemini-3.6-flash-high": "gemini-3.6-flash-high",
|
|
89
116
|
"gemini-3.1-pro-low": "gemini-3.1-pro-low",
|
|
90
117
|
"gemini-pro-agent": "gemini-pro-agent",
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
118
|
+
// ── Retired Flash generations ──
|
|
119
|
+
// Google takes the previous Antigravity Flash model offline almost immediately
|
|
120
|
+
// once its successor ships, so 3.6 (and the 3.5 ids that used to land on it)
|
|
121
|
+
// route to 3.7. These stay in the alias map — not only in the tier map below —
|
|
122
|
+
// because `parseAntigravityAvailableModels` uses THIS map to keep a stale CCA
|
|
123
|
+
// payload from republishing a dead wire id as a picker row.
|
|
124
|
+
...Object.fromEntries(
|
|
125
|
+
Object.keys(RETIRED_FLASH_TIERS).map(retired => [retired, GEMINI_FLASH_CURRENT]),
|
|
126
|
+
),
|
|
96
127
|
};
|
|
97
128
|
|
|
98
129
|
export const ANTIGRAVITY_MODEL_ALIASES: Record<string, string> = {
|
|
@@ -102,7 +133,7 @@ export const ANTIGRAVITY_MODEL_ALIASES: Record<string, string> = {
|
|
|
102
133
|
|
|
103
134
|
// Picker-visible: collapsed base models only.
|
|
104
135
|
export const ANTIGRAVITY_MODELS = [
|
|
105
|
-
|
|
136
|
+
GEMINI_FLASH_CURRENT,
|
|
106
137
|
"gemini-3.1-pro",
|
|
107
138
|
"gemini-3.1-flash-image",
|
|
108
139
|
"claude-sonnet-4-6",
|
|
@@ -112,9 +143,7 @@ export const ANTIGRAVITY_MODELS = [
|
|
|
112
143
|
|
|
113
144
|
// Context windows from the upstream `:fetchAvailableModels` maxTokens per model.
|
|
114
145
|
const ANTIGRAVITY_WIRE_MODEL_CONTEXT_WINDOWS: Record<string, number> = {
|
|
115
|
-
"gemini-3.
|
|
116
|
-
"gemini-3.6-flash-medium": 1_048_576,
|
|
117
|
-
"gemini-3.6-flash-high": 1_048_576,
|
|
146
|
+
"gemini-3.7-flash": 1_048_576,
|
|
118
147
|
"gemini-3.1-pro-low": 1_048_576,
|
|
119
148
|
"gemini-pro-agent": 1_048_576,
|
|
120
149
|
"gemini-3.1-flash-image": 1_048_576,
|
|
@@ -125,7 +154,7 @@ const ANTIGRAVITY_WIRE_MODEL_CONTEXT_WINDOWS: Record<string, number> = {
|
|
|
125
154
|
|
|
126
155
|
export const ANTIGRAVITY_MODEL_CONTEXT_WINDOWS: Record<string, number> = {
|
|
127
156
|
// Collapsed base IDs — explicit entries for the picker.
|
|
128
|
-
"gemini-3.
|
|
157
|
+
"gemini-3.7-flash": 1_048_576,
|
|
129
158
|
"gemini-3.1-pro": 1_048_576,
|
|
130
159
|
// Wire IDs and aliases via derivation.
|
|
131
160
|
...ANTIGRAVITY_WIRE_MODEL_CONTEXT_WINDOWS,
|
|
@@ -138,7 +167,11 @@ export const ANTIGRAVITY_MODEL_CONTEXT_WINDOWS: Record<string, number> = {
|
|
|
138
167
|
};
|
|
139
168
|
|
|
140
169
|
export const ANTIGRAVITY_MODEL_INPUT_MODALITIES: Record<string, string[]> = {
|
|
141
|
-
|
|
170
|
+
// Google documents 3.7 Flash as also accepting video, audio and PDF, but this proxy
|
|
171
|
+
// carries only text and image parts (`OcxImageContent`, src/types.ts) and the Codex
|
|
172
|
+
// catalog normalizes `input_modalities` against a closed enum. Advertising a modality
|
|
173
|
+
// the wire cannot carry would be a promise we break at request time.
|
|
174
|
+
"gemini-3.7-flash": ["text", "image"],
|
|
142
175
|
"gemini-3.1-pro": ["text", "image"],
|
|
143
176
|
"gemini-3.1-flash-image": ["text", "image"],
|
|
144
177
|
"claude-sonnet-4-6": ["text", "image"],
|
|
@@ -244,6 +277,11 @@ export function isAntigravitySuffixModelId(modelId: string): boolean {
|
|
|
244
277
|
return !(ANTIGRAVITY_MODELS as string[]).includes(modelId);
|
|
245
278
|
}
|
|
246
279
|
|
|
280
|
+
/** The reasoning tier a retired Flash id used to encode, if it is one. */
|
|
281
|
+
export function retiredAntigravityFlashTier(modelId: string): string | undefined {
|
|
282
|
+
return RETIRED_FLASH_TIERS[modelId];
|
|
283
|
+
}
|
|
284
|
+
|
|
247
285
|
/**
|
|
248
286
|
* Resolve a picker-visible base model + optional reasoning effort to the CCA wire model ID.
|
|
249
287
|
*
|
|
@@ -258,11 +296,32 @@ export function resolveAntigravityEffortWireModel(
|
|
|
258
296
|
modelId: string,
|
|
259
297
|
effort?: string,
|
|
260
298
|
): { wireModelId: string; thinkingLevel?: string } {
|
|
299
|
+
// Rule 0: retired Flash id — Google has taken the wire id offline, so route to the
|
|
300
|
+
// current generation and carry the tier the retired id encoded. This runs BEFORE the
|
|
301
|
+
// suffix check because those ids are aliases, and rule 1 would drop the tier.
|
|
302
|
+
const retiredTier = RETIRED_FLASH_TIERS[modelId];
|
|
303
|
+
if (retiredTier) {
|
|
304
|
+
return {
|
|
305
|
+
wireModelId: GEMINI_FLASH_CURRENT,
|
|
306
|
+
thinkingLevel: effort ? resolveAntigravityThinkingLevel(effort) ?? retiredTier : retiredTier,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
261
310
|
// Rule 1: suffix/compat alias — suffix IS the effort.
|
|
262
311
|
if (isAntigravitySuffixModelId(modelId)) {
|
|
263
312
|
return { wireModelId: resolveAntigravityWireModelId(modelId) };
|
|
264
313
|
}
|
|
265
314
|
|
|
315
|
+
// Rule 1b: single-wire-id Gemini model whose tiers ride on thinkingLevel. Without
|
|
316
|
+
// this the model falls to rule 5 and silently loses reasoning control entirely.
|
|
317
|
+
const defaultLevel = ANTIGRAVITY_THINKING_LEVEL_MODELS[modelId];
|
|
318
|
+
if (defaultLevel) {
|
|
319
|
+
return {
|
|
320
|
+
wireModelId: modelId,
|
|
321
|
+
thinkingLevel: effort ? resolveAntigravityThinkingLevel(effort) ?? defaultLevel : defaultLevel,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
266
325
|
// Rule 2/3: mapped Gemini base model.
|
|
267
326
|
const effortMap = ANTIGRAVITY_EFFORT_WIRE_MAP[modelId];
|
|
268
327
|
if (effortMap) {
|
|
@@ -301,6 +360,12 @@ const ANTIGRAVITY_USAGE_BASE_BY_ID: Record<string, string> = (() => {
|
|
|
301
360
|
// If alias is itself a base/wire already mapped, keep that mapping.
|
|
302
361
|
else if (rev[wire]) rev[alias] = rev[wire]!;
|
|
303
362
|
}
|
|
363
|
+
// Retired ids keep their OWN identity for usage aggregation, overriding the alias
|
|
364
|
+
// pass above. Routing sends new 3.6 calls to 3.7, but a usage row written months ago
|
|
365
|
+
// records a model the user actually called: relabelling it would move historical spend
|
|
366
|
+
// onto a model that did not exist then, and away from the 3.6 price row that still
|
|
367
|
+
// prices it correctly. Retirement changes what we CALL, not what we RECORD.
|
|
368
|
+
for (const retired of Object.keys(RETIRED_FLASH_TIERS)) rev[retired] = retired;
|
|
304
369
|
// Visible aliases that only appear in ANTIGRAVITY_VISIBLE_MODEL_ALIASES are already
|
|
305
370
|
// included via ANTIGRAVITY_MODEL_ALIASES. Identity bases without effort maps remain.
|
|
306
371
|
return rev;
|
|
@@ -26,6 +26,22 @@ export interface ModelRename {
|
|
|
26
26
|
to: string;
|
|
27
27
|
/** Why the vendor retired it, for the startup warning and future readers. */
|
|
28
28
|
reason: string;
|
|
29
|
+
/**
|
|
30
|
+
* Drop the retired key from `modelReasoningEffortMap` instead of renaming it.
|
|
31
|
+
*
|
|
32
|
+
* Renaming preserves the VALUE, which is right for records whose values describe the
|
|
33
|
+
* model — a context window or an effort ladder survives a rename — and wrong for the
|
|
34
|
+
* one record whose values are themselves wire ids. An effort map saved as
|
|
35
|
+
* `high -> gemini-3.6-flash-high` would keep naming a dead wire id under the new key,
|
|
36
|
+
* and the adapter maps effort BEFORE resolving CCA routing, so that value arrives as
|
|
37
|
+
* an unrecognised effort and silently degrades to the default tier.
|
|
38
|
+
*
|
|
39
|
+
* Only that one record is dropped. Emptying the others would be worse than the bug:
|
|
40
|
+
* catalog enrichment treats an existing `{}` as "already populated" and will not
|
|
41
|
+
* restore the registry's records, so the migrated user would keep routing correctly
|
|
42
|
+
* but lose the reasoning picker entirely.
|
|
43
|
+
*/
|
|
44
|
+
dropReasoningEffortMap?: boolean;
|
|
29
45
|
}
|
|
30
46
|
|
|
31
47
|
/**
|
|
@@ -46,6 +62,22 @@ export const MODEL_RENAMES: readonly ModelRename[] = [
|
|
|
46
62
|
to: "qwen3.8-max",
|
|
47
63
|
reason: "Alibaba shipped Qwen3.8-Max as stable and documents the preview endpoint as liable to be taken offline once preview concludes",
|
|
48
64
|
},
|
|
65
|
+
// Antigravity Flash generations. Google takes the previous Flash model off Cloud Code
|
|
66
|
+
// Assist almost immediately when the next ships, so a saved 3.6 (or older 3.5) id is a
|
|
67
|
+
// dead selection rather than a merely outdated one. Routing already redirects these ids
|
|
68
|
+
// at request time; this migration repairs the saved config so the picker, the allowlist
|
|
69
|
+
// and the capability maps stop naming a model the backend no longer serves.
|
|
70
|
+
...(["gemini-3.6-flash", "gemini-3.6-flash-low", "gemini-3.6-flash-medium", "gemini-3.6-flash-high",
|
|
71
|
+
"gemini-3.5-flash-extra-low", "gemini-3.5-flash-low", "gemini-3.5-flash-mid", "gemini-3.5-flash-high",
|
|
72
|
+
"gemini-3-flash-agent"] as const).map(from => ({
|
|
73
|
+
provider: "google-antigravity",
|
|
74
|
+
from,
|
|
75
|
+
to: "gemini-3.7-flash",
|
|
76
|
+
reason: "Google retires the previous Antigravity Flash generation from Cloud Code Assist when its successor ships, so the saved id no longer resolves to a live model",
|
|
77
|
+
// The retired Flash tiers were wire ids, so any saved per-model record keyed by one
|
|
78
|
+
// may also hold one as a value. 3.7 expresses tiers as thinkingLevel names instead.
|
|
79
|
+
dropReasoningEffortMap: true,
|
|
80
|
+
})),
|
|
49
81
|
];
|
|
50
82
|
|
|
51
83
|
/** Provider fields that key metadata by model id. */
|
|
@@ -61,6 +93,12 @@ const MODEL_KEYED_RECORDS = [
|
|
|
61
93
|
/** Provider fields that are flat lists of model ids. */
|
|
62
94
|
const MODEL_ID_LISTS = [
|
|
63
95
|
"models",
|
|
96
|
+
// A retired id left here is worse than a stale label: `filterCatalogModels` treats
|
|
97
|
+
// `selectedModels` as an exact-match allowlist, so a user who allowlisted only the
|
|
98
|
+
// retired model gets NO replacement row at all — the model silently vanishes from
|
|
99
|
+
// their catalog instead of being renamed. OAuth reconciliation does not cover this
|
|
100
|
+
// field, so the rename has to.
|
|
101
|
+
"selectedModels",
|
|
64
102
|
"noVisionModels",
|
|
65
103
|
"noReasoningModels",
|
|
66
104
|
"noTemperatureModels",
|
|
@@ -102,6 +140,19 @@ function renameInRecord(value: unknown, from: string, to: string): Record<string
|
|
|
102
140
|
return next;
|
|
103
141
|
}
|
|
104
142
|
|
|
143
|
+
/** Drop the retired key entirely, leaving any entry already saved under the new id. */
|
|
144
|
+
function dropFromRecord(value: unknown, from: string): Record<string, unknown> | null {
|
|
145
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
146
|
+
const record = value as Record<string, unknown>;
|
|
147
|
+
if (!(from in record)) return null;
|
|
148
|
+
const next: Record<string, unknown> = {};
|
|
149
|
+
for (const [key, entry] of Object.entries(record)) {
|
|
150
|
+
if (key === from) continue;
|
|
151
|
+
next[key] = entry;
|
|
152
|
+
}
|
|
153
|
+
return next;
|
|
154
|
+
}
|
|
155
|
+
|
|
105
156
|
/**
|
|
106
157
|
* `provider/model` rows in the top-level `disabledModels` list.
|
|
107
158
|
*
|
|
@@ -179,7 +230,9 @@ export function projectModelRenames(
|
|
|
179
230
|
touched = true;
|
|
180
231
|
}
|
|
181
232
|
for (const field of MODEL_KEYED_RECORDS) {
|
|
182
|
-
const next =
|
|
233
|
+
const next = rename.dropReasoningEffortMap && field === "modelReasoningEffortMap"
|
|
234
|
+
? dropFromRecord(row[field], rename.from)
|
|
235
|
+
: renameInRecord(row[field], rename.from, rename.to);
|
|
183
236
|
if (!next) continue;
|
|
184
237
|
row[field] = next;
|
|
185
238
|
touched = true;
|
|
@@ -1397,7 +1397,7 @@ export const PROVIDER_REGISTRY: readonly ProviderRegistryEntry[] = [
|
|
|
1397
1397
|
// 2026-07-10: defaultModel is frozen pending Vertex-specific Tier-2 evidence; Gemini API
|
|
1398
1398
|
// evidence from ai.google.dev does not establish Vertex publisher availability.
|
|
1399
1399
|
{ id: "google-vertex", label: "Google Vertex AI", adapter: "google", baseUrl: "https://aiplatform.googleapis.com", authKind: "key", dashboardUrl: "https://console.cloud.google.com/vertex-ai", defaultModel: "gemini-3-pro", googleMode: "vertex", jawcodeBundle: "google", extraMetadataAliases: ["gemini-vertex"] },
|
|
1400
|
-
{ id: "google-antigravity", label: "Google Antigravity", adapter: "google", baseUrl: "https://daily-cloudcode-pa.googleapis.com", authKind: "oauth", dashboardUrl: "https://antigravity.google", models: ANTIGRAVITY_MODELS, liveModels: true, defaultModel: "gemini-3.
|
|
1400
|
+
{ id: "google-antigravity", label: "Google Antigravity", adapter: "google", baseUrl: "https://daily-cloudcode-pa.googleapis.com", authKind: "oauth", dashboardUrl: "https://antigravity.google", models: ANTIGRAVITY_MODELS, liveModels: true, defaultModel: "gemini-3.7-flash", modelContextWindows: ANTIGRAVITY_MODEL_CONTEXT_WINDOWS, modelInputModalities: ANTIGRAVITY_MODEL_INPUT_MODALITIES, modelReasoningEfforts: ANTIGRAVITY_MODEL_EFFORTS, googleMode: "cloud-code-assist", jawcodeBundle: "google", extraMetadataAliases: ["antigravity", "gemini-antigravity"] },
|
|
1401
1401
|
{ id: "azure-openai", label: "Azure OpenAI", adapter: "azure-openai", baseUrl: "https://{resource}.openai.azure.com/openai", authKind: "key", featured: true, dashboardUrl: "https://portal.azure.com" },
|
|
1402
1402
|
{ id: "ollama", label: "Ollama (local)", adapter: "openai-chat", baseUrl: "http://localhost:11434/v1", authKind: "local", allowPrivateNetworkByDefault: true, allowBaseUrlOverride: true, featured: true, note: "Local — key usually blank" },
|
|
1403
1403
|
{ id: "vllm", label: "vLLM (local)", adapter: "openai-chat", baseUrl: "http://localhost:8000/v1", authKind: "local", allowPrivateNetworkByDefault: true, allowBaseUrlOverride: true, featured: true, note: "Local — key usually blank" },
|
|
@@ -52,6 +52,10 @@ const DAYBREAK_RED: Cost4 = { input: 12.5, output: 75, cacheRead: 1.25, cacheWri
|
|
|
52
52
|
const GPT56_TERRA: Cost4 = { input: 2, output: 12, cacheRead: 0.2, cacheWrite: 2.5 };
|
|
53
53
|
const GPT56_LUNA: Cost4 = { input: 0.2, output: 1.2, cacheRead: 0.02, cacheWrite: 0.25 };
|
|
54
54
|
const GEMINI_36_FLASH: Cost4 = { input: 1.5, output: 7.5, cacheRead: 0.15, cacheWrite: 0 };
|
|
55
|
+
// Gemini 3.7 Flash launch promotion: Google publishes $0.75 in / $3.75 out per 1M
|
|
56
|
+
// through 2026-12-31, stepping up to $1.50 / $7.50 on 2027-01-01. Revisit this row
|
|
57
|
+
// then — the promotional rate is dated on the pricing page, not open-ended.
|
|
58
|
+
const GEMINI_37_FLASH: Cost4 = { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0 };
|
|
55
59
|
const MINIMAX_M21_HIGHSPEED: Cost4 = { input: 0.6, output: 2.4, cacheRead: 0.03, cacheWrite: 0.375 };
|
|
56
60
|
const KIMI_K3: Cost4 = { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3 };
|
|
57
61
|
const KIMI_K27_CODE: Cost4 = { input: 0.95, output: 4, cacheRead: 0.19, cacheWrite: 0.95 };
|
|
@@ -70,6 +74,7 @@ const CLAUDE_OPUS_5_DERIVED_SOURCE =
|
|
|
70
74
|
const ANTHROPIC_PRICING = "https://platform.claude.com/docs/en/about-claude/pricing (official; 5m cache-write tier)";
|
|
71
75
|
|
|
72
76
|
const GEMINI_PRICING = "https://ai.google.dev/gemini-api/docs/pricing (2026-07-22); cacheWrite=0: storage is billed per-hour, not per-token";
|
|
77
|
+
const GEMINI_37_PRICING = "https://ai.google.dev/gemini-api/docs/pricing (2026-08-14); promotional rate through 2026-12-31, rises to 1.50/7.50 on 2027-01-01; cacheWrite=0: storage is billed per-hour, not per-token";
|
|
73
78
|
const MINIMAX_PRICING = "https://platform.minimax.io/docs/guides/pricing-paygo";
|
|
74
79
|
const OPENAI_GPT56_PRICING = "https://developers.openai.com/api/docs/pricing";
|
|
75
80
|
const DEEPSEEK_PRICING = "https://api-docs.deepseek.com/quick_start/pricing-details-usd; V4 Flash alias transition scheduled 2026-07-24 — re-verify after";
|
|
@@ -102,6 +107,12 @@ export const EXPECTED_PRICE_OVERLAYS: readonly ExpectedPriceOverlay[] = [
|
|
|
102
107
|
// Google Antigravity effort-suffix variants — derived from the verified base-model
|
|
103
108
|
// price (Google does not publish per-suffix prices; Agent inference bills at the
|
|
104
109
|
// base model's standard rate per the official Billing FAQ).
|
|
110
|
+
// 3.7 Flash rides CCA, whose billing equivalence to the Developer API list price is
|
|
111
|
+
// not published, so this is `verified-derived` rather than `verified`: the number is
|
|
112
|
+
// proven, the claim that Antigravity charges it is inferred.
|
|
113
|
+
{ provider: "google-antigravity", modelId: "gemini-3.7-flash", cost4: GEMINI_37_FLASH, source: `derived: Gemini 3.7 Flash promotional rate through 2026-12-31 ${GEMINI_37_PRICING}`, verifiedAt: "2026-08-14", status: "verified-derived" },
|
|
114
|
+
// Retained after the 3.6 retirement: historical usage.jsonl rows still carry these
|
|
115
|
+
// ids, and dropping the row would silently zero the cost of requests already made.
|
|
105
116
|
{ provider: "google-antigravity", modelId: "gemini-3.6-flash", cost4: GEMINI_36_FLASH, source: `collapsed base ID ${GEMINI_PRICING}`, verifiedAt: "2026-07-22", status: "verified" },
|
|
106
117
|
{ provider: "google-antigravity", modelId: "gemini-3.1-pro", cost4: GEMINI_31_PRO, source: `collapsed base ID ${GEMINI_PRICING}`, verifiedAt: "2026-07-22", status: "verified" },
|
|
107
118
|
// OpenAI GPT-5.6 `-pro` virtual selections. The virtual resolver keeps the SELECTED id in
|
|
@@ -130,6 +141,8 @@ export const EXPECTED_PRICE_OVERLAYS: readonly ExpectedPriceOverlay[] = [
|
|
|
130
141
|
{ provider: "google-antigravity", modelId: "gemini-3-flash-agent", cost4: GEMINI_36_FLASH, source: `compat alias -> gemini-3.6-flash-high ${GEMINI_PRICING}`, verifiedAt: "2026-07-22", status: "verified-derived" },
|
|
131
142
|
// Direct Google Gemini API current model (verified — published table).
|
|
132
143
|
{ provider: "google", modelId: "gemini-3.6-flash", cost4: GEMINI_36_FLASH, source: GEMINI_PRICING, verifiedAt: "2026-07-22", status: "verified" },
|
|
144
|
+
// Developer API row: the price IS published for this surface, so `verified`.
|
|
145
|
+
{ provider: "google", modelId: "gemini-3.7-flash", cost4: GEMINI_37_FLASH, source: GEMINI_37_PRICING, verifiedAt: "2026-08-14", status: "verified" },
|
|
133
146
|
{ provider: "google-antigravity", modelId: "gemini-3.1-pro-preview", cost4: GEMINI_31_PRO, source: GEMINI_PRICING, verifiedAt: "2026-07-20", status: "verified" },
|
|
134
147
|
// Antigravity-bundled third-party models — derived from the underlying vendor's
|
|
135
148
|
// official API price (Antigravity itself bills via subscription quota).
|