cartethyia 2.4.1 → 2.4.3

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.
Files changed (22) hide show
  1. package/dist/dashboard/assets/{BannedPage-hGt6sYfC.js → BannedPage-CFWM4WEi.js} +1 -1
  2. package/dist/dashboard/assets/{CliToolDetailPage-C-v5GoF-.js → CliToolDetailPage-DSGFhzfL.js} +1 -1
  3. package/dist/dashboard/assets/{CliToolsPage-Da2XCM9A.js → CliToolsPage-tsIxtVpX.js} +1 -1
  4. package/dist/dashboard/assets/{ConsoleLogPage-xT-LP8xZ.js → ConsoleLogPage-BY7Y_0z8.js} +1 -1
  5. package/dist/dashboard/assets/{CustomizationPage-D0PQsW3f.js → CustomizationPage-DlyXzyIf.js} +1 -1
  6. package/dist/dashboard/assets/{HealthEventsModal-DTiQ4ulO.js → HealthEventsModal-KG3K2C5M.js} +1 -1
  7. package/dist/dashboard/assets/{LoginPage-jMx71m_m.js → LoginPage-B4T7XQcx.js} +1 -1
  8. package/dist/dashboard/assets/{OverviewPage-BQpanEmj.js → OverviewPage-BeVW5HiF.js} +1 -1
  9. package/dist/dashboard/assets/{ProviderDetailPage-DMh9bfu0.js → ProviderDetailPage-D8CTrTMh.js} +1 -1
  10. package/dist/dashboard/assets/{ProvidersPage-Bfg0qSLE.js → ProvidersPage-DSSnMPdU.js} +1 -1
  11. package/dist/dashboard/assets/{ProxyPage-CSSN-6vg.js → ProxyPage-DjXFNVqh.js} +1 -1
  12. package/dist/dashboard/assets/{QuotaPage-BPksahOs.js → QuotaPage-ZRiPzRxI.js} +1 -1
  13. package/dist/dashboard/assets/{SetupPage-DxKaH8LS.js → SetupPage-4v0f70wB.js} +1 -1
  14. package/dist/dashboard/assets/{StudioPage-B9WEa99R.js → StudioPage-DQ3V_uhU.js} +1 -1
  15. package/dist/dashboard/assets/{UsagePage-BOSJhVq0.js → UsagePage-DA2RUnXI.js} +1 -1
  16. package/dist/dashboard/assets/{entry-C1Dn2nQu.js → entry-8jVcj7OO.js} +3 -3
  17. package/dist/dashboard/assets/{index-TZNbg9dv.js → index-gJaMvav9.js} +2 -2
  18. package/dist/dashboard/index.html +1 -1
  19. package/package.json +1 -1
  20. package/scripts/cli/cli.ts +97 -305
  21. package/scripts/cli/tray.ps1 +98 -0
  22. package/scripts/cli/tray.ts +213 -0
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-CXUMngI_.js";import{$ as t}from"./entry-C1Dn2nQu.js";var n=e();function r(){return(0,n.jsx)(`main`,{className:`auth-viewport`,children:(0,n.jsxs)(`div`,{className:`card-solid auth-window border border-red-soft`,children:[(0,n.jsxs)(`div`,{className:`auth-header`,children:[(0,n.jsx)(`div`,{"aria-hidden":`true`,className:`auth-logo bg-red bg-none`,children:(0,n.jsx)(t,{size:24})}),(0,n.jsx)(`h1`,{className:`auth-title`,children:`Access Restricted`}),(0,n.jsx)(`p`,{className:`auth-desc`,children:`Security policy lockout or untrusted origin address`})]}),(0,n.jsxs)(`div`,{className:`rounded-panel border border-inner-border bg-surface-2 p-7 text-caption leading-relaxed text-text-secondary`,children:[(0,n.jsx)(`strong`,{className:`block text-text-primary mb-2`,children:`HTTP 403 Forbidden`}),`This client IP has been temporarily locked out due to repeated invalid credential attempts or untrusted proxy headers.`]})]})})}export{r as default};
1
+ import{t as e}from"./jsx-runtime-CXUMngI_.js";import{$ as t}from"./entry-8jVcj7OO.js";var n=e();function r(){return(0,n.jsx)(`main`,{className:`auth-viewport`,children:(0,n.jsxs)(`div`,{className:`card-solid auth-window border border-red-soft`,children:[(0,n.jsxs)(`div`,{className:`auth-header`,children:[(0,n.jsx)(`div`,{"aria-hidden":`true`,className:`auth-logo bg-red bg-none`,children:(0,n.jsx)(t,{size:24})}),(0,n.jsx)(`h1`,{className:`auth-title`,children:`Access Restricted`}),(0,n.jsx)(`p`,{className:`auth-desc`,children:`Security policy lockout or untrusted origin address`})]}),(0,n.jsxs)(`div`,{className:`rounded-panel border border-inner-border bg-surface-2 p-7 text-caption leading-relaxed text-text-secondary`,children:[(0,n.jsx)(`strong`,{className:`block text-text-primary mb-2`,children:`HTTP 403 Forbidden`}),`This client IP has been temporarily locked out due to repeated invalid credential attempts or untrusted proxy headers.`]})]})})}export{r as default};
@@ -1 +1 @@
1
- import{n as e,o as t,r as n,t as r}from"./jsx-runtime-CXUMngI_.js";import{t as i}from"./arrow-left-CpBxkoxI.js";import{t as a}from"./select-CGUuTQmj.js";import{t as o}from"./circle-check-BU3v_mFW.js";import{n as s,t as c}from"./toast-DKAdP2mo.js";import{t as ee}from"./download-A0SW9OCW.js";import{n as l,r as u}from"./state-DHKdg-pm.js";import{t as d}from"./route-CNSNj9Zm.js";import{t as f}from"./search-JOKus9rb.js";import{c as p}from"./query-keys-ROf-g1Wi.js";import{J as m,X as h}from"./entry-C1Dn2nQu.js";import{n as g,r as _,t as v}from"./card-BTdbRFFg.js";import{n as y}from"./download-dRFo5_Wu.js";import{t as b}from"./badge-BwmwEOgA.js";import{n as x}from"./input-Bn4_kNav.js";import{t as te}from"./ModelPicker-CAiPR5Vd.js";import{t as ne}from"./switch-DIDeAiz9.js";import{t as S}from"./stack-C1kTcOmP.js";import{n as C}from"./inline-DCejSLlA.js";import{f as re,t as w}from"./api-keys-CjIGQhe7.js";import{a as T,i as ie,n as ae,o as E,r as oe,t as D}from"./cli-tools-DccaOfhX.js";import{t as se}from"./ToolIcon-K1ckcDKg.js";var ce=e(`book-open`,[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]),le=e(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),ue=e(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),de=e(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),O=t(n(),1);function k(e,t){return e==null?!1:e instanceof Set?e.has(t):e.includes(t)}function A(e){return e==null?0:e instanceof Set?e.size:e.length}function j(e){let t=e.lastIndexOf(`/`);return t<0?e:e.slice(t+1)}function M(e,t,n,r){let i=n?`${n}/${j(t)}`:void 0,a=[t,j(t),...i?[i]:[]];r&&r!==t&&a.push(r);let o=e.model_list;return e.model_access_mode===`blacklist`?a.some(e=>k(o,e))?`model-denied`:null:o==null||A(o)===0||a.some(e=>k(o,e))?null:`model-not-allowed`}function N(e,t,n,r){return M(e,t,n,r)===null}var P=r();function F(){let{toolId:e}=h(),t=T(),n=E(),r=w(),i=(0,O.useMemo)(()=>t.data?.find(t=>t.id===e)??null,[t.data,e]),a=(0,O.useMemo)(()=>{let t=n.data;if(t)return Array.isArray(t)?t.find(t=>t.toolId===e):t[e]},[n.data,e]);return t.isLoading?(0,P.jsx)(u,{label:`Loading tool details…`}):t.isError?(0,P.jsx)(l,{title:`Unable to load tool`,message:t.error?.message??`Could not load the CLI tool registry.`,onRetry:()=>void t.refetch()}):i?(0,P.jsx)(I,{tool:i,status:a,apiKeys:r.data??[]}):(0,P.jsxs)(S,{gap:`12px`,children:[(0,P.jsx)(m,{to:`/cli-tools`,className:`text-caption text-accent`,children:`← Back to CLI Tools`}),(0,P.jsx)(l,{title:`Tool not found`,message:`Unknown CLI tool id.`})]})}function I({tool:e,status:t,apiKeys:n}){let[r,l]=(0,O.useState)(``),[u,h]=(0,O.useState)(()=>typeof window>`u`?`http://localhost:12800`:window.location.origin),[w,T]=(0,O.useState)({}),[E,k]=(0,O.useState)(!1),[A,j]=(0,O.useState)({}),[M,F]=(0,O.useState)(null),[I,L]=(0,O.useState)(`slot`),R=(0,O.useRef)(null),z=(0,O.useMemo)(()=>n.filter(e=>e.keyMode===`personal`||e.keyMode===`share`&&e.parentKeyId===void 0),[n]),B=ie(e.id,r),V=oe(),H=ae(),U=re(),W=D(),G=z.find(e=>e.id===r),K=G?.scopes?.includes(`routing:cli_mapping`)===!0,q=G?.keyMode===`personal`,J=G?.modelAccessMode??`whitelist`,Y=G?.modelList,X=e=>N({model_access_mode:J,model_list:Y},e),fe=(0,O.useMemo)(()=>{let t=new Set;if(!e.mappingSupported)return t;for(let n of e.defaultModels){let e=A[n.alias]??``;if(e.length===0)continue;let r=w[n.alias]??n.defaultValue??n.id;!X(e)&&!X(r)&&t.add(n.alias)}return t},[e.defaultModels,e.mappingSupported,A,w,G]),pe=e=>{if(!G)return;let t=Y??[],n=J===`blacklist`?t.filter(t=>t!==e):[...new Set([...t,e])];U.mutate({keyId:G.id,request:{modelAccessMode:J,modelList:n}},{onSuccess:()=>c.success(J===`blacklist`?`Model unblocked for this key`:`Model allowed for this key`),onError:e=>c.error(p(e,`Could not update the API key.`))})};(0,O.useEffect)(()=>{let t=Object.fromEntries(e.defaultModels.map(e=>[e.alias,e.defaultValue??e.id]));T(t),j({}),R.current=null},[e,r]),(0,O.useEffect)(()=>{let t=B.data;if(t&&t.apiKeyId===r){if(k(t.enabled),t.mappings.length>0)T(e=>({...e,...Object.fromEntries(t.mappings.map(e=>[e.slotKey,e.sourceModel]))})),j(e=>({...e,...Object.fromEntries(t.mappings.map(e=>[e.slotKey,e.targetModel]))}));else{let t=Object.fromEntries(e.defaultModels.map(e=>[e.alias,e.defaultValue??e.id]));T(t),j({})}R.current=JSON.stringify({enabled:t.enabled,mappings:t.mappings})}},[r,B.data,e.defaultModels]);let me=t?.installed??!1,Z=t?.configured??!1,he=e.configType===`guide`,Q=(0,O.useMemo)(()=>e.defaultModels.map(e=>w[e.alias]??e.defaultValue??e.id),[w,e.defaultModels]),$=(0,O.useCallback)(()=>{if(e.mappingSupported)return{enabled:E,mappings:e.defaultModels.filter(e=>(A[e.alias]??``).length>0).map(e=>({slotKey:e.alias,sourceModel:w[e.alias]??e.defaultValue??e.id,targetModel:A[e.alias]??``,enabled:!0})).filter(e=>e.targetModel.length>0)}},[E,A,w,e.defaultModels,e.mappingSupported]);(0,O.useEffect)(()=>{if(!e.mappingSupported||r.length===0)return;let t=B.data;if(!t||t.apiKeyId!==r)return;let n=$();if(!n)return;let i=JSON.stringify({enabled:n.enabled,mappings:n.mappings});if(i===R.current)return;let a=setTimeout(()=>{V.mutate({toolId:e.id,keyId:r,input:n},{onSuccess:()=>{R.current=i},onError:e=>c.error(p(e,`Could not save mappings.`))})},600);return()=>clearTimeout(a)},[$,r,B.data,V,e.id,e.mappingSupported]);let ge=(0,O.useCallback)(()=>{let t=Object.fromEntries(e.defaultModels.map(e=>[e.alias,w[e.alias]??e.defaultValue??e.id])),n=e.defaultModels.find(e=>e.roleKind===`subagent`);return{endpoint:u,apiKey:``,modelIds:e.id===`claude`?[]:Q,modelSlots:t,...Q[0]?{activeModel:Q[0]}:{},...n?{subagentModel:w[n.alias]??n.defaultValue??n.id}:{},mappingOwnerId:r,...e.mappingSupported?{mapping:$()}:{}}},[Q,$,r,u,w,e]);return(0,P.jsxs)(S,{gap:`16px`,children:[(0,P.jsxs)(m,{to:`/cli-tools`,className:`inline-flex items-center gap-3 text-caption text-accent`,children:[(0,P.jsx)(i,{size:14}),`Back to CLI Tools`]}),(0,P.jsx)(v,{children:(0,P.jsxs)(g,{className:`flex flex-col gap-5`,children:[(0,P.jsxs)(C,{gap:`14px`,align:`flex-start`,className:`flex-wrap`,children:[(0,P.jsx)(se,{toolId:e.id,name:e.name,color:e.color,size:46}),(0,P.jsxs)(C,{gap:`8px`,className:`flex-wrap`,children:[(0,P.jsx)(`h1`,{className:`text-title font-bold m-0`,children:e.name}),me?(0,P.jsx)(b,{tone:`ok`,children:`Installed`}):(0,P.jsx)(b,{tone:`disabled`,children:`Not installed`}),Z?(0,P.jsx)(b,{tone:`accent`,children:`Configured`}):null,e.configType===`guide`?(0,P.jsx)(b,{tone:`info`,children:`Guide`}):null]})]}),(0,P.jsx)(`p`,{className:`m-0 text-caption text-text-secondary`,children:e.description}),e.docsUrl?(0,P.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noreferrer`,className:`inline-block text-caption text-accent`,children:`Official documentation →`}):null,t?.settingsPath?(0,P.jsxs)(`div`,{className:`font-mono tabular-nums px-6 py-4 rounded-inset bg-surface-2 border border-inner-border text-badge text-text-secondary break-all`,children:[`Config file: `,t.settingsPath]}):null,t?.message?(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-badge ${Z?`text-green`:`text-orange`}`,children:[Z?(0,P.jsx)(o,{size:13}):(0,P.jsx)(le,{size:13}),t.message]}):null]})}),(0,P.jsxs)(v,{children:[(0,P.jsx)(_,{title:`Setup`,subtitle:`Pick the Apikey Name and endpoint, set the models, then download. The key's secret is read server-side — you never paste it.`,icon:(0,P.jsx)(de,{size:16})}),(0,P.jsx)(g,{children:(0,P.jsx)(S,{gap:`12px`,children:(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 items-start min-w-0 max-medium:grid-cols-1`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 min-w-0`,children:[(0,P.jsx)(a,{label:`Apikey Name`,id:`api-key-select`,value:r,onValueChange:l,options:[{value:``,label:`Select…`},...z.map(e=>({value:e.id,label:`${e.label} — ${e.keyMode===`personal`?`Personal`:`Share template`}`}))]}),(0,P.jsx)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:G===void 0?(0,P.jsx)(`span`,{className:`mt-1 text-badge text-text-tertiary`,children:`Choose the Apikey Name whose routes this CLI session should use.`}):K?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(b,{tone:`ok`,children:`routing:cli_mapping`}),(0,P.jsx)(`span`,{className:`mt-1 text-badge text-text-tertiary`,children:`Remote routes work with this key.`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(b,{tone:`warn`,title:`This key cannot resolve persisted CLI mappings on /v1/*. Turn on Remote Routing below to enable it.`,children:`no CLI scope`}),(0,P.jsx)(`span`,{className:`mt-1 text-badge text-text-tertiary`,children:`Remote routes stay inert on this key — turning on Remote Routing below will activate it.`})]})}),G?.keyMode===`share`?(0,P.jsx)(`span`,{className:`mt-1 text-badge text-text-tertiary`,children:`Share template: its child keys inherit these routes automatically.`}):null]}),(0,P.jsx)(`div`,{className:`min-w-0`,children:(0,P.jsx)(x,{label:`Endpoint`,value:u,onChange:e=>h(e.target.value)})})]})})})]}),(0,P.jsxs)(v,{children:[(0,P.jsx)(_,{title:`Model routing`,icon:(0,P.jsx)(d,{size:16}),subtitle:e.mappingSupported?`Left is the model name the CLI asks for. Right is the route Cartethyia sends it to. Leave a target empty to send that slot straight to the provider.`:`The model names written into this tool's config.`,action:e.mappingSupported?(0,P.jsxs)(`div`,{className:`flex items-center gap-5`,children:[(0,P.jsx)(ne,{checked:E,disabled:!r,onChange:t=>{if(k(t),!r){c.error(`Select an API key first to configure its Remote Routing.`);return}if(t&&G&&!K){let e=[...new Set([...G.scopes??[],`routing:cli_mapping`])];U.mutate({keyId:G.id,request:{scopes:e}},{onSuccess:()=>{c.success(`Activated routing:cli_mapping on "${G.label}".`)},onError:e=>{c.error(p(e,`Could not update key scope.`))}})}let n=$();n&&V.mutate({toolId:e.id,keyId:r,input:{...n,enabled:t}},{onError:e=>c.error(p(e,`Could not save mappings.`))})},label:E?`Remote Routing on`:`Remote Routing off`}),(0,P.jsx)(s,{variant:`secondary`,size:`sm`,disabled:!r||H.isPending,onClick:()=>{if(!r){c.error(`Select an API key first.`);return}H.mutate({toolId:e.id,keyId:r},{onSuccess:()=>{k(!1),j({}),c.success(`Remote routes cleared and Remote Routing turned off.`)},onError:e=>c.error(p(e,`Could not reset remote routes.`))})},children:H.isPending?`Resetting…`:`Reset`})]}):void 0}),(0,P.jsxs)(g,{children:[r?null:(0,P.jsx)(`p`,{className:`text-badge text-text-tertiary mb-5`,children:`Select an API key above to load and save remote routes for that key. You can still set models below to download a config file.`}),e.mappingSupported?(0,P.jsxs)(`div`,{className:`mb-5 flex items-center gap-4 rounded-inset border border-inner-border bg-surface-2 px-5 py-3 text-micro text-text-tertiary`,children:[(0,P.jsx)(`span`,{className:`flex-1`,children:`CLI asks for`}),(0,P.jsx)(`span`,{className:`w-9 text-center`,children:`→`}),(0,P.jsx)(`span`,{className:`flex-1`,children:`Cartethyia routes to`})]}):null,(0,P.jsx)(S,{gap:`6px`,children:e.defaultModels.map(t=>{let n=w[t.alias]??t.defaultValue??t.id,r=A[t.alias]??``,i=r===n;return(0,P.jsxs)(`div`,{className:`grid items-center gap-4 ${e.mappingSupported?`grid-cols-2`:`grid-cols-1`}`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>{F(t.alias),L(`slot`)},className:`font-mono tabular-nums flex w-full min-w-0 cursor-pointer items-center justify-between gap-4 rounded-inset border border-inner-border bg-surface-2 px-5 py-3.5 text-left text-badge text-text-primary`,children:[(0,P.jsx)(`span`,{className:`overflow-hidden truncate whitespace-nowrap`,children:n}),(0,P.jsx)(f,{size:12,className:`text-text-tertiary shrink-0`})]}),(0,P.jsx)(`span`,{className:`text-micro text-text-tertiary pl-1`,children:t.roleLabel??t.name})]}),e.mappingSupported?(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>{F(t.alias),L(`target`)},className:`font-mono tabular-nums flex w-full min-w-0 cursor-pointer items-center justify-between gap-4 rounded-inset border px-5 py-3.5 text-left text-badge ${i?`border-inner-border bg-surface-2 text-text-tertiary`:`border-accent bg-accent-soft text-text-primary`}`,children:[(0,P.jsx)(`span`,{className:`overflow-hidden truncate whitespace-nowrap`,children:r.length>0?r:`Not routed`}),(0,P.jsx)(f,{size:12,className:`text-text-tertiary shrink-0`})]}),(0,P.jsxs)(`span`,{className:`pl-1 text-micro ${r.length===0?`text-text-tertiary`:`text-accent`}`,children:[r.length===0?`not routed`:`rerouted`,r.length>0?(0,P.jsx)(`button`,{type:`button`,onClick:()=>j(e=>({...e,[t.alias]:``})),className:`ml-3 border-none bg-none p-0 text-micro text-text-tertiary cursor-pointer underline`,children:`clear`}):null]}),fe.has(t.alias)?(0,P.jsxs)(`span`,{className:`mt-1 flex items-center gap-3 text-micro text-orange`,children:[(0,P.jsx)(`span`,{children:J===`blacklist`?`This key blocks the target model.`:`This key does not allow the target model.`}),(0,P.jsx)(`button`,{type:`button`,disabled:U.isPending,onClick:()=>pe(r),className:`border-none bg-none p-0 text-micro font-semibold text-accent underline ${U.isPending?`cursor-not-allowed`:`cursor-pointer`}`,children:J===`blacklist`?`Unblock`:`Allow this model`})]}):null]}):null]},t.alias)})})]})]}),he&&e.guideSteps?(0,P.jsxs)(v,{children:[(0,P.jsx)(_,{title:`Guide`,subtitle:`Manual setup steps for tools that do not support file injection.`,icon:(0,P.jsx)(ce,{size:16})}),(0,P.jsx)(g,{children:(0,P.jsx)(`ol`,{className:`flex flex-col gap-6 pl-9`,children:e.guideSteps.map(e=>(0,P.jsxs)(`li`,{children:[(0,P.jsx)(`strong`,{className:`text-body`,children:e.title}),e.desc?(0,P.jsx)(`p`,{className:`text-caption text-text-secondary mt-2`,children:e.desc}):null,e.value?(0,P.jsx)(`pre`,{className:`mt-3 overflow-x-auto rounded-control border border-inner-border bg-surface-2 p-5 font-mono text-badge`,children:e.value.replace(/\{\{baseUrl\}\}/g,u)}):null]},e.step))})})]}):null,(0,P.jsxs)(v,{children:[(0,P.jsx)(_,{title:`Config file`,subtitle:`Download the config file for this CLI tool. The selected API key secret is decrypted automatically into the download.`,icon:(0,P.jsx)(ue,{size:16})}),(0,P.jsxs)(g,{className:`flex flex-col gap-6`,children:[(0,P.jsx)(`div`,{className:`flex gap-4 flex-wrap justify-end`,children:(0,P.jsx)(s,{variant:`primary`,icon:(0,P.jsx)(ee,{size:14}),onClick:()=>{if(!r){c.error(`Select an API key first.`);return}W.mutate({toolId:e.id,keyId:r,input:ge()},{onSuccess:e=>{y(e.filename,e.content,e.mimeType),c.success(`Downloaded ${e.filename}.`)},onError:e=>c.error(p(e,`Could not download config.`))})},disabled:W.isPending||!q,children:W.isPending?`Downloading…`:`Download config`})}),q?null:(0,P.jsx)(`p`,{className:`text-badge text-text-tertiary text-right`,children:G?.keyMode===`share`?`A share template has no secret to write into a config. Select a personal key to download the config file.`:`Select an Apikey Name above to enable downloading the config file.`})]})]}),(0,P.jsx)(te,{open:M!==null,onClose:()=>F(null),selected:M?[I===`target`?A[M]??w[M]??``:w[M]??``]:[],onToggle:()=>{},onSelectOne:e=>{M&&(I===`target`?j(t=>({...t,[M]:e})):T(t=>({...t,[M]:e}))),F(null)},title:M?`Select ${M} model`:`Select model`,multi:!1})]})}export{F as default};
1
+ import{n as e,o as t,r as n,t as r}from"./jsx-runtime-CXUMngI_.js";import{t as i}from"./arrow-left-CpBxkoxI.js";import{t as a}from"./select-CGUuTQmj.js";import{t as o}from"./circle-check-BU3v_mFW.js";import{n as s,t as c}from"./toast-DKAdP2mo.js";import{t as ee}from"./download-A0SW9OCW.js";import{n as l,r as u}from"./state-DHKdg-pm.js";import{t as d}from"./route-CNSNj9Zm.js";import{t as f}from"./search-JOKus9rb.js";import{c as p}from"./query-keys-ROf-g1Wi.js";import{J as m,X as h}from"./entry-8jVcj7OO.js";import{n as g,r as _,t as v}from"./card-BTdbRFFg.js";import{n as y}from"./download-dRFo5_Wu.js";import{t as b}from"./badge-BwmwEOgA.js";import{n as x}from"./input-Bn4_kNav.js";import{t as te}from"./ModelPicker-CAiPR5Vd.js";import{t as ne}from"./switch-DIDeAiz9.js";import{t as S}from"./stack-C1kTcOmP.js";import{n as C}from"./inline-DCejSLlA.js";import{f as re,t as w}from"./api-keys-CjIGQhe7.js";import{a as T,i as ie,n as ae,o as E,r as oe,t as D}from"./cli-tools-DccaOfhX.js";import{t as se}from"./ToolIcon-K1ckcDKg.js";var ce=e(`book-open`,[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]),le=e(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),ue=e(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),de=e(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),O=t(n(),1);function k(e,t){return e==null?!1:e instanceof Set?e.has(t):e.includes(t)}function A(e){return e==null?0:e instanceof Set?e.size:e.length}function j(e){let t=e.lastIndexOf(`/`);return t<0?e:e.slice(t+1)}function M(e,t,n,r){let i=n?`${n}/${j(t)}`:void 0,a=[t,j(t),...i?[i]:[]];r&&r!==t&&a.push(r);let o=e.model_list;return e.model_access_mode===`blacklist`?a.some(e=>k(o,e))?`model-denied`:null:o==null||A(o)===0||a.some(e=>k(o,e))?null:`model-not-allowed`}function N(e,t,n,r){return M(e,t,n,r)===null}var P=r();function F(){let{toolId:e}=h(),t=T(),n=E(),r=w(),i=(0,O.useMemo)(()=>t.data?.find(t=>t.id===e)??null,[t.data,e]),a=(0,O.useMemo)(()=>{let t=n.data;if(t)return Array.isArray(t)?t.find(t=>t.toolId===e):t[e]},[n.data,e]);return t.isLoading?(0,P.jsx)(u,{label:`Loading tool details…`}):t.isError?(0,P.jsx)(l,{title:`Unable to load tool`,message:t.error?.message??`Could not load the CLI tool registry.`,onRetry:()=>void t.refetch()}):i?(0,P.jsx)(I,{tool:i,status:a,apiKeys:r.data??[]}):(0,P.jsxs)(S,{gap:`12px`,children:[(0,P.jsx)(m,{to:`/cli-tools`,className:`text-caption text-accent`,children:`← Back to CLI Tools`}),(0,P.jsx)(l,{title:`Tool not found`,message:`Unknown CLI tool id.`})]})}function I({tool:e,status:t,apiKeys:n}){let[r,l]=(0,O.useState)(``),[u,h]=(0,O.useState)(()=>typeof window>`u`?`http://localhost:12800`:window.location.origin),[w,T]=(0,O.useState)({}),[E,k]=(0,O.useState)(!1),[A,j]=(0,O.useState)({}),[M,F]=(0,O.useState)(null),[I,L]=(0,O.useState)(`slot`),R=(0,O.useRef)(null),z=(0,O.useMemo)(()=>n.filter(e=>e.keyMode===`personal`||e.keyMode===`share`&&e.parentKeyId===void 0),[n]),B=ie(e.id,r),V=oe(),H=ae(),U=re(),W=D(),G=z.find(e=>e.id===r),K=G?.scopes?.includes(`routing:cli_mapping`)===!0,q=G?.keyMode===`personal`,J=G?.modelAccessMode??`whitelist`,Y=G?.modelList,X=e=>N({model_access_mode:J,model_list:Y},e),fe=(0,O.useMemo)(()=>{let t=new Set;if(!e.mappingSupported)return t;for(let n of e.defaultModels){let e=A[n.alias]??``;if(e.length===0)continue;let r=w[n.alias]??n.defaultValue??n.id;!X(e)&&!X(r)&&t.add(n.alias)}return t},[e.defaultModels,e.mappingSupported,A,w,G]),pe=e=>{if(!G)return;let t=Y??[],n=J===`blacklist`?t.filter(t=>t!==e):[...new Set([...t,e])];U.mutate({keyId:G.id,request:{modelAccessMode:J,modelList:n}},{onSuccess:()=>c.success(J===`blacklist`?`Model unblocked for this key`:`Model allowed for this key`),onError:e=>c.error(p(e,`Could not update the API key.`))})};(0,O.useEffect)(()=>{let t=Object.fromEntries(e.defaultModels.map(e=>[e.alias,e.defaultValue??e.id]));T(t),j({}),R.current=null},[e,r]),(0,O.useEffect)(()=>{let t=B.data;if(t&&t.apiKeyId===r){if(k(t.enabled),t.mappings.length>0)T(e=>({...e,...Object.fromEntries(t.mappings.map(e=>[e.slotKey,e.sourceModel]))})),j(e=>({...e,...Object.fromEntries(t.mappings.map(e=>[e.slotKey,e.targetModel]))}));else{let t=Object.fromEntries(e.defaultModels.map(e=>[e.alias,e.defaultValue??e.id]));T(t),j({})}R.current=JSON.stringify({enabled:t.enabled,mappings:t.mappings})}},[r,B.data,e.defaultModels]);let me=t?.installed??!1,Z=t?.configured??!1,he=e.configType===`guide`,Q=(0,O.useMemo)(()=>e.defaultModels.map(e=>w[e.alias]??e.defaultValue??e.id),[w,e.defaultModels]),$=(0,O.useCallback)(()=>{if(e.mappingSupported)return{enabled:E,mappings:e.defaultModels.filter(e=>(A[e.alias]??``).length>0).map(e=>({slotKey:e.alias,sourceModel:w[e.alias]??e.defaultValue??e.id,targetModel:A[e.alias]??``,enabled:!0})).filter(e=>e.targetModel.length>0)}},[E,A,w,e.defaultModels,e.mappingSupported]);(0,O.useEffect)(()=>{if(!e.mappingSupported||r.length===0)return;let t=B.data;if(!t||t.apiKeyId!==r)return;let n=$();if(!n)return;let i=JSON.stringify({enabled:n.enabled,mappings:n.mappings});if(i===R.current)return;let a=setTimeout(()=>{V.mutate({toolId:e.id,keyId:r,input:n},{onSuccess:()=>{R.current=i},onError:e=>c.error(p(e,`Could not save mappings.`))})},600);return()=>clearTimeout(a)},[$,r,B.data,V,e.id,e.mappingSupported]);let ge=(0,O.useCallback)(()=>{let t=Object.fromEntries(e.defaultModels.map(e=>[e.alias,w[e.alias]??e.defaultValue??e.id])),n=e.defaultModels.find(e=>e.roleKind===`subagent`);return{endpoint:u,apiKey:``,modelIds:e.id===`claude`?[]:Q,modelSlots:t,...Q[0]?{activeModel:Q[0]}:{},...n?{subagentModel:w[n.alias]??n.defaultValue??n.id}:{},mappingOwnerId:r,...e.mappingSupported?{mapping:$()}:{}}},[Q,$,r,u,w,e]);return(0,P.jsxs)(S,{gap:`16px`,children:[(0,P.jsxs)(m,{to:`/cli-tools`,className:`inline-flex items-center gap-3 text-caption text-accent`,children:[(0,P.jsx)(i,{size:14}),`Back to CLI Tools`]}),(0,P.jsx)(v,{children:(0,P.jsxs)(g,{className:`flex flex-col gap-5`,children:[(0,P.jsxs)(C,{gap:`14px`,align:`flex-start`,className:`flex-wrap`,children:[(0,P.jsx)(se,{toolId:e.id,name:e.name,color:e.color,size:46}),(0,P.jsxs)(C,{gap:`8px`,className:`flex-wrap`,children:[(0,P.jsx)(`h1`,{className:`text-title font-bold m-0`,children:e.name}),me?(0,P.jsx)(b,{tone:`ok`,children:`Installed`}):(0,P.jsx)(b,{tone:`disabled`,children:`Not installed`}),Z?(0,P.jsx)(b,{tone:`accent`,children:`Configured`}):null,e.configType===`guide`?(0,P.jsx)(b,{tone:`info`,children:`Guide`}):null]})]}),(0,P.jsx)(`p`,{className:`m-0 text-caption text-text-secondary`,children:e.description}),e.docsUrl?(0,P.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noreferrer`,className:`inline-block text-caption text-accent`,children:`Official documentation →`}):null,t?.settingsPath?(0,P.jsxs)(`div`,{className:`font-mono tabular-nums px-6 py-4 rounded-inset bg-surface-2 border border-inner-border text-badge text-text-secondary break-all`,children:[`Config file: `,t.settingsPath]}):null,t?.message?(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-badge ${Z?`text-green`:`text-orange`}`,children:[Z?(0,P.jsx)(o,{size:13}):(0,P.jsx)(le,{size:13}),t.message]}):null]})}),(0,P.jsxs)(v,{children:[(0,P.jsx)(_,{title:`Setup`,subtitle:`Pick the Apikey Name and endpoint, set the models, then download. The key's secret is read server-side — you never paste it.`,icon:(0,P.jsx)(de,{size:16})}),(0,P.jsx)(g,{children:(0,P.jsx)(S,{gap:`12px`,children:(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 items-start min-w-0 max-medium:grid-cols-1`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 min-w-0`,children:[(0,P.jsx)(a,{label:`Apikey Name`,id:`api-key-select`,value:r,onValueChange:l,options:[{value:``,label:`Select…`},...z.map(e=>({value:e.id,label:`${e.label} — ${e.keyMode===`personal`?`Personal`:`Share template`}`}))]}),(0,P.jsx)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:G===void 0?(0,P.jsx)(`span`,{className:`mt-1 text-badge text-text-tertiary`,children:`Choose the Apikey Name whose routes this CLI session should use.`}):K?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(b,{tone:`ok`,children:`routing:cli_mapping`}),(0,P.jsx)(`span`,{className:`mt-1 text-badge text-text-tertiary`,children:`Remote routes work with this key.`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(b,{tone:`warn`,title:`This key cannot resolve persisted CLI mappings on /v1/*. Turn on Remote Routing below to enable it.`,children:`no CLI scope`}),(0,P.jsx)(`span`,{className:`mt-1 text-badge text-text-tertiary`,children:`Remote routes stay inert on this key — turning on Remote Routing below will activate it.`})]})}),G?.keyMode===`share`?(0,P.jsx)(`span`,{className:`mt-1 text-badge text-text-tertiary`,children:`Share template: its child keys inherit these routes automatically.`}):null]}),(0,P.jsx)(`div`,{className:`min-w-0`,children:(0,P.jsx)(x,{label:`Endpoint`,value:u,onChange:e=>h(e.target.value)})})]})})})]}),(0,P.jsxs)(v,{children:[(0,P.jsx)(_,{title:`Model routing`,icon:(0,P.jsx)(d,{size:16}),subtitle:e.mappingSupported?`Left is the model name the CLI asks for. Right is the route Cartethyia sends it to. Leave a target empty to send that slot straight to the provider.`:`The model names written into this tool's config.`,action:e.mappingSupported?(0,P.jsxs)(`div`,{className:`flex items-center gap-5`,children:[(0,P.jsx)(ne,{checked:E,disabled:!r,onChange:t=>{if(k(t),!r){c.error(`Select an API key first to configure its Remote Routing.`);return}if(t&&G&&!K){let e=[...new Set([...G.scopes??[],`routing:cli_mapping`])];U.mutate({keyId:G.id,request:{scopes:e}},{onSuccess:()=>{c.success(`Activated routing:cli_mapping on "${G.label}".`)},onError:e=>{c.error(p(e,`Could not update key scope.`))}})}let n=$();n&&V.mutate({toolId:e.id,keyId:r,input:{...n,enabled:t}},{onError:e=>c.error(p(e,`Could not save mappings.`))})},label:E?`Remote Routing on`:`Remote Routing off`}),(0,P.jsx)(s,{variant:`secondary`,size:`sm`,disabled:!r||H.isPending,onClick:()=>{if(!r){c.error(`Select an API key first.`);return}H.mutate({toolId:e.id,keyId:r},{onSuccess:()=>{k(!1),j({}),c.success(`Remote routes cleared and Remote Routing turned off.`)},onError:e=>c.error(p(e,`Could not reset remote routes.`))})},children:H.isPending?`Resetting…`:`Reset`})]}):void 0}),(0,P.jsxs)(g,{children:[r?null:(0,P.jsx)(`p`,{className:`text-badge text-text-tertiary mb-5`,children:`Select an API key above to load and save remote routes for that key. You can still set models below to download a config file.`}),e.mappingSupported?(0,P.jsxs)(`div`,{className:`mb-5 flex items-center gap-4 rounded-inset border border-inner-border bg-surface-2 px-5 py-3 text-micro text-text-tertiary`,children:[(0,P.jsx)(`span`,{className:`flex-1`,children:`CLI asks for`}),(0,P.jsx)(`span`,{className:`w-9 text-center`,children:`→`}),(0,P.jsx)(`span`,{className:`flex-1`,children:`Cartethyia routes to`})]}):null,(0,P.jsx)(S,{gap:`6px`,children:e.defaultModels.map(t=>{let n=w[t.alias]??t.defaultValue??t.id,r=A[t.alias]??``,i=r===n;return(0,P.jsxs)(`div`,{className:`grid items-center gap-4 ${e.mappingSupported?`grid-cols-2`:`grid-cols-1`}`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>{F(t.alias),L(`slot`)},className:`font-mono tabular-nums flex w-full min-w-0 cursor-pointer items-center justify-between gap-4 rounded-inset border border-inner-border bg-surface-2 px-5 py-3.5 text-left text-badge text-text-primary`,children:[(0,P.jsx)(`span`,{className:`overflow-hidden truncate whitespace-nowrap`,children:n}),(0,P.jsx)(f,{size:12,className:`text-text-tertiary shrink-0`})]}),(0,P.jsx)(`span`,{className:`text-micro text-text-tertiary pl-1`,children:t.roleLabel??t.name})]}),e.mappingSupported?(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>{F(t.alias),L(`target`)},className:`font-mono tabular-nums flex w-full min-w-0 cursor-pointer items-center justify-between gap-4 rounded-inset border px-5 py-3.5 text-left text-badge ${i?`border-inner-border bg-surface-2 text-text-tertiary`:`border-accent bg-accent-soft text-text-primary`}`,children:[(0,P.jsx)(`span`,{className:`overflow-hidden truncate whitespace-nowrap`,children:r.length>0?r:`Not routed`}),(0,P.jsx)(f,{size:12,className:`text-text-tertiary shrink-0`})]}),(0,P.jsxs)(`span`,{className:`pl-1 text-micro ${r.length===0?`text-text-tertiary`:`text-accent`}`,children:[r.length===0?`not routed`:`rerouted`,r.length>0?(0,P.jsx)(`button`,{type:`button`,onClick:()=>j(e=>({...e,[t.alias]:``})),className:`ml-3 border-none bg-none p-0 text-micro text-text-tertiary cursor-pointer underline`,children:`clear`}):null]}),fe.has(t.alias)?(0,P.jsxs)(`span`,{className:`mt-1 flex items-center gap-3 text-micro text-orange`,children:[(0,P.jsx)(`span`,{children:J===`blacklist`?`This key blocks the target model.`:`This key does not allow the target model.`}),(0,P.jsx)(`button`,{type:`button`,disabled:U.isPending,onClick:()=>pe(r),className:`border-none bg-none p-0 text-micro font-semibold text-accent underline ${U.isPending?`cursor-not-allowed`:`cursor-pointer`}`,children:J===`blacklist`?`Unblock`:`Allow this model`})]}):null]}):null]},t.alias)})})]})]}),he&&e.guideSteps?(0,P.jsxs)(v,{children:[(0,P.jsx)(_,{title:`Guide`,subtitle:`Manual setup steps for tools that do not support file injection.`,icon:(0,P.jsx)(ce,{size:16})}),(0,P.jsx)(g,{children:(0,P.jsx)(`ol`,{className:`flex flex-col gap-6 pl-9`,children:e.guideSteps.map(e=>(0,P.jsxs)(`li`,{children:[(0,P.jsx)(`strong`,{className:`text-body`,children:e.title}),e.desc?(0,P.jsx)(`p`,{className:`text-caption text-text-secondary mt-2`,children:e.desc}):null,e.value?(0,P.jsx)(`pre`,{className:`mt-3 overflow-x-auto rounded-control border border-inner-border bg-surface-2 p-5 font-mono text-badge`,children:e.value.replace(/\{\{baseUrl\}\}/g,u)}):null]},e.step))})})]}):null,(0,P.jsxs)(v,{children:[(0,P.jsx)(_,{title:`Config file`,subtitle:`Download the config file for this CLI tool. The selected API key secret is decrypted automatically into the download.`,icon:(0,P.jsx)(ue,{size:16})}),(0,P.jsxs)(g,{className:`flex flex-col gap-6`,children:[(0,P.jsx)(`div`,{className:`flex gap-4 flex-wrap justify-end`,children:(0,P.jsx)(s,{variant:`primary`,icon:(0,P.jsx)(ee,{size:14}),onClick:()=>{if(!r){c.error(`Select an API key first.`);return}W.mutate({toolId:e.id,keyId:r,input:ge()},{onSuccess:e=>{y(e.filename,e.content,e.mimeType),c.success(`Downloaded ${e.filename}.`)},onError:e=>c.error(p(e,`Could not download config.`))})},disabled:W.isPending||!q,children:W.isPending?`Downloading…`:`Download config`})}),q?null:(0,P.jsx)(`p`,{className:`text-badge text-text-tertiary text-right`,children:G?.keyMode===`share`?`A share template has no secret to write into a config. Select a personal key to download the config file.`:`Select an Apikey Name above to enable downloading the config file.`})]})]}),(0,P.jsx)(te,{open:M!==null,onClose:()=>F(null),selected:M?[I===`target`?A[M]??w[M]??``:w[M]??``]:[],onToggle:()=>{},onSelectOne:e=>{M&&(I===`target`?j(t=>({...t,[M]:e})):T(t=>({...t,[M]:e}))),F(null)},title:M?`Select ${M} model`:`Select model`,multi:!1})]})}export{F as default};
@@ -1 +1 @@
1
- import{o as e,r as t,t as n}from"./jsx-runtime-CXUMngI_.js";import{t as r}from"./terminal-C9mZ4Ugm.js";import{n as i,r as a,t as o}from"./state-DHKdg-pm.js";import{J as s}from"./entry-C1Dn2nQu.js";import{n as c,r as l,t as u}from"./card-BTdbRFFg.js";import{t as d}from"./badge-BwmwEOgA.js";import{t as f}from"./stack-C1kTcOmP.js";import{n as p}from"./inline-DCejSLlA.js";import{a as m,o as h}from"./cli-tools-DccaOfhX.js";import{t as g}from"./ToolIcon-K1ckcDKg.js";import{n as _}from"./layout-Bv-NxqZ5.js";var v=e(t(),1),y=n();function b(){let e=m(),t=h(),n=(0,v.useMemo)(()=>{let e=new Map,n=t.data;if(!n)return e;if(Array.isArray(n))for(let t of n)t?.toolId&&e.set(t.toolId,t);else if(typeof n==`object`)for(let[t,r]of Object.entries(n))r&&e.set(r.toolId||t,r);return e},[t.data]);if(e.isLoading)return(0,y.jsx)(a,{label:`Loading CLI tools…`});if(e.isError||!e.data)return(0,y.jsx)(i,{title:`Unable to load CLI tools`,message:e.error?.message??`Could not load the CLI tools registry.`,onRetry:()=>void e.refetch()});let b=e.data,x=b.filter(e=>e.configType!==`guide`),S=b.filter(e=>e.configType===`guide`),C=x.filter(e=>n.get(e.id)?.configured).length;return b.length===0?(0,y.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-12 border border-dashed border-transparent rounded-card bg-transparent text-center`,children:(0,y.jsx)(o,{title:`No CLI tools registered`,message:`The registry is empty, so there is nothing to configure yet.`})}):(0,y.jsx)(f,{gap:`16px`,children:(0,y.jsxs)(u,{children:[(0,y.jsx)(l,{title:`CLI Tools`,subtitle:`${C}/${x.length} file-injected tools configured`,icon:(0,y.jsx)(r,{size:16}),action:(0,y.jsx)(d,{tone:`accent`,children:`${b.length} tools`})}),(0,y.jsxs)(c,{className:`flex flex-col gap-8`,children:[(0,y.jsxs)(`section`,{className:`flex flex-col gap-6`,children:[(0,y.jsx)(_,{title:`File-injected tools (${x.length})`,description:`Direct config file writing and preset model mappings`}),(0,y.jsx)(`div`,{className:`provider-grid grid gap-6 w-full min-w-0`,children:x.map(e=>{let t=n.get(e.id);return(0,y.jsx)(u,{interactive:!0,className:`relative overflow-hidden rounded-panel`,children:(0,y.jsx)(s,{to:`/cli-tools/${e.id}`,className:`no-underline text-inherit block p-6`,children:(0,y.jsxs)(p,{gap:`10px`,children:[(0,y.jsx)(g,{toolId:e.id,name:e.name,color:e.color,size:32}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`div`,{className:`text-body font-semibold overflow-hidden truncate whitespace-nowrap`,children:e.name}),(0,y.jsx)(`div`,{className:`mt-1.5`,children:t?.configured?(0,y.jsx)(d,{tone:`ok`,dot:!0,children:`Configured`}):t?.installed?(0,y.jsx)(d,{tone:`warn`,dot:!0,children:`Installed`}):(0,y.jsx)(d,{children:`Not installed`})})]}),(0,y.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5 shrink-0`,children:[(0,y.jsx)(`span`,{className:`font-mono tabular-nums text-micro font-semibold bg-kbd-bg py-0.5 px-2.5 rounded-tiny text-text-secondary`,children:e.id}),e.surface?(0,y.jsx)(d,{tone:`default`,children:e.surface}):null]})]})})},e.id)})})]}),(0,y.jsxs)(`section`,{className:`flex flex-col gap-6`,children:[(0,y.jsx)(_,{title:`Guide-only tools (${S.length})`,description:`Manual setup steps and exportable config templates`}),(0,y.jsx)(`div`,{className:`provider-grid grid gap-6 w-full min-w-0`,children:S.map(e=>(0,y.jsx)(u,{interactive:!0,className:`relative overflow-hidden rounded-panel`,children:(0,y.jsx)(s,{to:`/cli-tools/${e.id}`,className:`no-underline text-inherit block p-6`,children:(0,y.jsxs)(p,{gap:`10px`,children:[(0,y.jsx)(g,{toolId:e.id,name:e.name,color:e.color,size:32}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`div`,{className:`text-body font-semibold overflow-hidden truncate whitespace-nowrap`,children:e.name}),(0,y.jsx)(`div`,{className:`mt-1.5`,children:(0,y.jsx)(d,{tone:`info`,children:`Guide`})})]}),(0,y.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5 shrink-0`,children:[(0,y.jsx)(`span`,{className:`font-mono tabular-nums text-micro font-semibold bg-kbd-bg py-0.5 px-2.5 rounded-tiny text-text-secondary`,children:e.id}),e.surface?(0,y.jsx)(d,{tone:`default`,children:e.surface}):null]})]})})},e.id))})]})]})]})})}export{b as default};
1
+ import{o as e,r as t,t as n}from"./jsx-runtime-CXUMngI_.js";import{t as r}from"./terminal-C9mZ4Ugm.js";import{n as i,r as a,t as o}from"./state-DHKdg-pm.js";import{J as s}from"./entry-8jVcj7OO.js";import{n as c,r as l,t as u}from"./card-BTdbRFFg.js";import{t as d}from"./badge-BwmwEOgA.js";import{t as f}from"./stack-C1kTcOmP.js";import{n as p}from"./inline-DCejSLlA.js";import{a as m,o as h}from"./cli-tools-DccaOfhX.js";import{t as g}from"./ToolIcon-K1ckcDKg.js";import{n as _}from"./layout-Bv-NxqZ5.js";var v=e(t(),1),y=n();function b(){let e=m(),t=h(),n=(0,v.useMemo)(()=>{let e=new Map,n=t.data;if(!n)return e;if(Array.isArray(n))for(let t of n)t?.toolId&&e.set(t.toolId,t);else if(typeof n==`object`)for(let[t,r]of Object.entries(n))r&&e.set(r.toolId||t,r);return e},[t.data]);if(e.isLoading)return(0,y.jsx)(a,{label:`Loading CLI tools…`});if(e.isError||!e.data)return(0,y.jsx)(i,{title:`Unable to load CLI tools`,message:e.error?.message??`Could not load the CLI tools registry.`,onRetry:()=>void e.refetch()});let b=e.data,x=b.filter(e=>e.configType!==`guide`),S=b.filter(e=>e.configType===`guide`),C=x.filter(e=>n.get(e.id)?.configured).length;return b.length===0?(0,y.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-12 border border-dashed border-transparent rounded-card bg-transparent text-center`,children:(0,y.jsx)(o,{title:`No CLI tools registered`,message:`The registry is empty, so there is nothing to configure yet.`})}):(0,y.jsx)(f,{gap:`16px`,children:(0,y.jsxs)(u,{children:[(0,y.jsx)(l,{title:`CLI Tools`,subtitle:`${C}/${x.length} file-injected tools configured`,icon:(0,y.jsx)(r,{size:16}),action:(0,y.jsx)(d,{tone:`accent`,children:`${b.length} tools`})}),(0,y.jsxs)(c,{className:`flex flex-col gap-8`,children:[(0,y.jsxs)(`section`,{className:`flex flex-col gap-6`,children:[(0,y.jsx)(_,{title:`File-injected tools (${x.length})`,description:`Direct config file writing and preset model mappings`}),(0,y.jsx)(`div`,{className:`provider-grid grid gap-6 w-full min-w-0`,children:x.map(e=>{let t=n.get(e.id);return(0,y.jsx)(u,{interactive:!0,className:`relative overflow-hidden rounded-panel`,children:(0,y.jsx)(s,{to:`/cli-tools/${e.id}`,className:`no-underline text-inherit block p-6`,children:(0,y.jsxs)(p,{gap:`10px`,children:[(0,y.jsx)(g,{toolId:e.id,name:e.name,color:e.color,size:32}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`div`,{className:`text-body font-semibold overflow-hidden truncate whitespace-nowrap`,children:e.name}),(0,y.jsx)(`div`,{className:`mt-1.5`,children:t?.configured?(0,y.jsx)(d,{tone:`ok`,dot:!0,children:`Configured`}):t?.installed?(0,y.jsx)(d,{tone:`warn`,dot:!0,children:`Installed`}):(0,y.jsx)(d,{children:`Not installed`})})]}),(0,y.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5 shrink-0`,children:[(0,y.jsx)(`span`,{className:`font-mono tabular-nums text-micro font-semibold bg-kbd-bg py-0.5 px-2.5 rounded-tiny text-text-secondary`,children:e.id}),e.surface?(0,y.jsx)(d,{tone:`default`,children:e.surface}):null]})]})})},e.id)})})]}),(0,y.jsxs)(`section`,{className:`flex flex-col gap-6`,children:[(0,y.jsx)(_,{title:`Guide-only tools (${S.length})`,description:`Manual setup steps and exportable config templates`}),(0,y.jsx)(`div`,{className:`provider-grid grid gap-6 w-full min-w-0`,children:S.map(e=>(0,y.jsx)(u,{interactive:!0,className:`relative overflow-hidden rounded-panel`,children:(0,y.jsx)(s,{to:`/cli-tools/${e.id}`,className:`no-underline text-inherit block p-6`,children:(0,y.jsxs)(p,{gap:`10px`,children:[(0,y.jsx)(g,{toolId:e.id,name:e.name,color:e.color,size:32}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`div`,{className:`text-body font-semibold overflow-hidden truncate whitespace-nowrap`,children:e.name}),(0,y.jsx)(`div`,{className:`mt-1.5`,children:(0,y.jsx)(d,{tone:`info`,children:`Guide`})})]}),(0,y.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5 shrink-0`,children:[(0,y.jsx)(`span`,{className:`font-mono tabular-nums text-micro font-semibold bg-kbd-bg py-0.5 px-2.5 rounded-tiny text-text-secondary`,children:e.id}),e.surface?(0,y.jsx)(d,{tone:`default`,children:e.surface}):null]})]})})},e.id))})]})]})]})})}export{b as default};
@@ -1 +1 @@
1
- import{o as e,r as t,t as n}from"./jsx-runtime-CXUMngI_.js";import{n as r,t as i}from"./toast-DKAdP2mo.js";import{n as a,r as o,t as s}from"./state-DHKdg-pm.js";import{t as c}from"./refresh-cw-BqJFk4sU.js";import{t as l}from"./search-JOKus9rb.js";import{t as u}from"./shield-check-DVS0Foqh.js";import{t as d}from"./trash-Cppn5c3R.js";import{a as f,c as p,l as m}from"./query-keys-ROf-g1Wi.js";import{D as h,F as g,O as _,tt as v}from"./entry-C1Dn2nQu.js";import{n as y,r as b,t as x}from"./card-BTdbRFFg.js";import{r as S}from"./numbers-CFL4_Dqc.js";import{t as C}from"./stream-retry-5QnVuSSo.js";import{t as w}from"./badge-BwmwEOgA.js";import{n as T}from"./input-Bn4_kNav.js";import{t as E}from"./layout-Bv-NxqZ5.js";var D=e(t(),1),O=500,k=1500;function A(e){return m(e)&&typeof e.ts==`string`&&(e.level===`debug`||e.level===`info`||e.level===`warn`||e.level===`error`)&&typeof e.msg==`string`}function j(e){return!m(e)||!Array.isArray(e.lines)?[]:e.lines.filter(A)}function M(){let[e,t]=(0,D.useState)([]),[n,r]=(0,D.useState)(new Set),[i,a]=(0,D.useState)(`idle`),o=(0,D.useRef)(0),s=(0,D.useRef)(0),c=(0,D.useRef)(new Set),l=e=>({...e,id:`l${s.current+=1}`});return(0,D.useEffect)(()=>{let e=!1,n,i=o.current+=1,s=(e,t)=>{let n=window.setTimeout(()=>{c.current.delete(n),e()},t);c.current.add(n)},u=e=>{let n=l(e);r(e=>{let t=new Set(e);return t.add(n.id),t}),s(()=>{r(e=>{if(!e.has(n.id))return e;let t=new Set(e);return t.delete(n.id),t})},k),t(e=>{let t=[...e,n];return t.length>O?t.slice(t.length-O):t})},d=()=>{n=new EventSource(`/console/api/logs/stream`),n.addEventListener(`init`,n=>{if(!e)try{let e=JSON.parse(n.data);m(e)&&(t(j(e).slice(-500).map(l)),r(new Set)),a(`live`)}catch{}}),n.addEventListener(`line`,t=>{if(!e)try{let e=JSON.parse(t.data);A(e)&&(u(e),a(`live`))}catch{}}),n.addEventListener(`clear`,()=>{e||(t([]),r(new Set))}),n.onerror=()=>{n?.close(),!e&&(a(`reconnecting`),s(()=>{!e&&i===o.current&&p()},C))}},p=async()=>{try{let n=await f(`/logs?limit=200`);if(e||i!==o.current)return;t(j(n).slice(-500).map(l)),r(new Set),d()}catch{}};return p(),()=>{e=!0;for(let e of c.current)window.clearTimeout(e);c.current.clear(),n?.close()}},[]),{lines:e,newLineIds:n,status:i,clear:(0,D.useCallback)(async()=>{await f(`/logs`,{method:`DELETE`}),t([]),r(new Set)},[])}}var N={"api_key.created":`API key created`,"api_key.updated":`API key updated`,"api_key.revoked":`API key revoked`,"api_key.regenerated":`API key regenerated`,"api_key.shared":`API key shared`,"api_key.share_regenerated":`API key share link regenerated`,"api_key.share_revoked":`API key unshared`,"provider.created":`Provider created`,"provider.updated":`Provider updated`,"provider.deleted":`Provider deleted`,"provider.global.updated":`Global provider updated`,"provider.global.deleted":`Global provider deleted`,"provider.routing.updated":`Provider routing updated`,"provider.models.registered":`Provider models registered`,"provider.models.bulk_deleted":`Provider models bulk-deleted`,"provider.model.deleted":`Provider model deleted`,"provider.model.enabled":`Provider model enabled`,"provider.model.disabled":`Provider model disabled`,"provider_account.created":`Provider account connected`,"provider_account.updated":`Provider account updated`,"provider_account.recovered":`Provider account recovered`,"provider_account.revoked":`Provider account revoked`,"provider_account.circuit_force_closed":`Provider account circuit force-closed`,"provider_account.deleted":`Provider account deleted`,"provider_account.exported":`Provider accounts exported (plaintext)`,"provider_account.global.updated":`Global provider account updated`,"provider_account.global.refreshed":`Global provider account refreshed`,"provider_account.global.deleted":`Global provider account deleted`,"model_alias.created":`Model alias created`,"model_alias.updated":`Model alias updated`,"model_alias.deleted":`Model alias deleted`,"model_combo.created":`Model combo created`,"model_combo.updated":`Model combo updated`,"model_combo.cloned":`Model combo cloned`,"model_combo.deleted":`Model combo deleted`,"network_pool.created":`Network pool created`,"network_pool.updated":`Network pool updated`,"network_pool.deleted":`Network pool deleted`,"network_pool.recovered":`Network pool recovered`,"network_pool.strategy_updated":`Network pool strategy updated`,"network_pool.relay_deployed":`Network pool relay deployed`,"filter_rule.created":`Filter rule created`,"filter_rule.updated":`Filter rule updated`,"filter_rule.deleted":`Filter rule deleted`,"filter_rule.reordered":`Filter rules reordered`,"filter_rule.master_toggle":`Filter master switch toggled`,"settings.runtime.updated":`Runtime settings updated`,"cli_tool.mappings_saved":`CLI tool mappings saved`,"cli_tool.mappings_reset":`CLI tool mappings reset`,"cli_tool.applied":`CLI tool applied`,"console.password_changed":`Console password changed`,"console_logs.cleared":`Console logs cleared`,"security.ip_banned":`IP banned`,"backup.reset":`Backup reset`,"backup.delete_all":`Delete all configuration`},P={api:`API`,ip:`IP`,cli:`CLI`,oauth:`OAuth`};function F(e){return e.split(`.`).map(e=>e.split(/[_-]+/).filter(Boolean).map(e=>P[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)).join(` `)).join(` · `)}function I(e){return N[e]??F(e)}var L=n(),R=50,z=[{id:`all`,label:`All`},{id:`debug`,label:`Debug`},{id:`info`,label:`Info`},{id:`warn`,label:`Warn`},{id:`error`,label:`Error`}],B={debug:`var(--text-tertiary)`,info:`var(--accent)`,warn:`var(--orange)`,error:`var(--red)`},V={debug:`DBG`,info:`INF`,warn:`WRN`,error:`ERR`};function H(e){return e>=500?`err`:e>=400?`warn`:`ok`}function U(e,t,n){let r=n.trim().toLowerCase();return e.filter(e=>t!==`all`&&e.level!==t?!1:!r||`${e.msg} ${e.endpoint??``} ${e.model??``} ${e.routedModel??``} ${e.providerId??``} ${e.errorCode??``} ${e.userAgent??``} ${e.clientIp??``} ${e.accountLabel??``}`.toLowerCase().includes(r))}function W(){let[e,t]=(0,D.useState)(`logs`),n=_().data?.isPlatformAdmin??!1,i=e===`audit`&&!n?`logs`:e,a=(0,L.jsxs)(`div`,{className:`flex gap-4`,children:[(0,L.jsx)(r,{variant:i===`logs`?`primary`:`secondary`,size:`sm`,onClick:()=>t(`logs`),icon:(0,L.jsx)(v,{size:13}),"aria-pressed":i===`logs`,children:`Console Log`}),n?(0,L.jsx)(r,{variant:i===`audit`?`primary`:`secondary`,size:`sm`,onClick:()=>t(`audit`),icon:(0,L.jsx)(u,{size:13}),"aria-pressed":i===`audit`,children:`Admin Audit`}):null]});return(0,L.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:i===`logs`?(0,L.jsx)(Q,{tabAction:a}):(0,L.jsx)($,{tabAction:a})})}function G(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour12:!1})}function K(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function q(e){let t=e.details;if(!t)return null;let n=typeof t.inputTokens==`number`?t.inputTokens:void 0,r=typeof t.outputTokens==`number`?t.outputTokens:void 0,i=typeof t.cachedInputTokens==`number`?t.cachedInputTokens:void 0,a=typeof t.reasoningTokens==`number`?t.reasoningTokens:void 0;if(n===void 0&&r===void 0&&i===void 0&&a===void 0)return null;let o=[];return n!==void 0&&o.push(`${K(n)} in`),r!==void 0&&o.push(`${K(r)} out`),i!==void 0&&o.push(`${K(i)} cached`),a!==void 0&&a>0&&o.push(`${K(a)} reason`),o.join(` / `)}function J(e){let t=e.model,n=e.routedModel,r=e.providerId,i=n??t;if(!i&&!r)return null;let a=r&&i?`${r}/${i}`:i??r??``;return n&&t&&n!==t?`${a} ← ${t}`:a}var Y=(0,D.memo)(function({line:e,isNew:t}){let n=e.event!==void 0,r=e.level;return(0,L.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-4 px-8 py-1.5 font-mono text-caption leading-normal max-medium:gap-3 max-medium:px-5 max-medium:text-badge${r===`warn`?` bg-orange-soft`:r===`error`?` bg-red-soft`:``}${t?` bg-surface-muted`:``} hover:bg-surface-hover`,"data-log-tone":r,children:[(0,L.jsx)(`span`,{className:`max-medium:flex-none flex-none tabular-nums text-text-tertiary`,children:G(e.ts)}),(0,L.jsx)(`span`,{className:`flex-none w-13 text-left text-micro font-bold tracking-label`,style:{color:B[e.level]},title:e.level.toUpperCase(),children:V[e.level]}),n?(0,L.jsx)(X,{line:e}):(0,L.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere break-words text-text-secondary`,children:e.msg})]})});function X({line:e}){let t=J(e),n=q(e),r=Z(e);return(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[(0,L.jsxs)(`span`,{className:`font-bold tracking-label ${r.tone}`,"data-log-field":`badge`,children:[`[`,r.label,`]`]}),` `,(0,L.jsx)(`span`,{className:`text-text-tertiary`,children:e.method??`POST`}),` `,(0,L.jsx)(`span`,{className:`text-text-primary`,children:e.endpoint??``}),e.status===void 0?null:(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`tabular-nums ${H(e.status)===`ok`?`text-text-tertiary`:H(e.status)===`warn`?`text-orange font-semibold`:`text-red font-semibold`}`,children:e.status})]}),e.durationMs===void 0?null:(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`tabular-nums text-text-secondary`,children:S(e.durationMs)})]}),t?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`text-status-info`,"data-log-field":`route`,children:t})]}):null,e.accountLabel?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`text-purple`,"data-log-field":`account`,title:e.accountId??void 0,children:e.accountLabel})]}):null,e.clientIp?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`tabular-nums text-text-secondary`,"data-log-field":`ip`,children:e.clientIp})]}):null,n?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`tabular-nums text-orange`,"data-log-field":`tokens`,children:n})]}):null,e.errorCode?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsxs)(`span`,{className:`text-red`,title:e.msg,children:[e.msg,` (`,e.errorCode,`)`]})]}):null,e.requestId?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`text-micro text-text-tertiary`,"data-log-field":`id`,children:e.requestId.slice(0,8)})]}):null]})}function Z(e){return e.event===`request_start`||e.status===void 0?{label:`REQUEST`,tone:`text-text-tertiary`}:e.event===`request_error`||e.status>=400?{label:`FAILED`,tone:`text-red`}:{label:`SUCCESS`,tone:`text-status-info`}}function Q({tabAction:e}){let{lines:t,newLineIds:n,clear:r}=M(),[a,o]=(0,D.useState)(`all`),[c,u]=(0,D.useState)(``),[f,p]=(0,D.useState)(!1),[m,h]=(0,D.useState)(null),_=c.trim().toLowerCase(),S=(0,D.useMemo)(()=>U(t,a,_).slice().reverse(),[t,a,_]),C=(0,D.useMemo)(()=>{let e=new Map([[`all`,t.length]]);for(let n of t)e.set(n.level,(e.get(n.level)??0)+1);return e},[t]);return(0,L.jsxs)(x,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(b,{title:`Console Log`,subtitle:`${S.length} of ${t.length} lines`,icon:(0,L.jsx)(v,{size:16}),action:e}),(0,L.jsxs)(y,{className:`flex flex-row items-center justify-between gap-8 flex-none min-h-0 px-7 py-4 border-b border-inner-border max-medium:flex-col max-medium:items-start max-medium:gap-4`,children:[(0,L.jsx)(`div`,{className:`inline-flex items-center gap-1.5 flex-none max-medium:w-full max-medium:overflow-x-auto`,role:`group`,"aria-label":`Log level`,children:z.map(e=>{let t=C.get(e.id)??0;return(0,L.jsxs)(`button`,{className:`inline-flex items-center appearance-none border-0 rounded-tiny px-5 py-3.5 bg-transparent font-sans text-badge font-semibold leading-none cursor-pointer ${a===e.id?`bg-surface-muted text-text-primary`:`text-text-tertiary hover:bg-surface-muted hover:text-text-primary`}`,type:`button`,onClick:()=>o(e.id),"aria-pressed":a===e.id,children:[(0,L.jsx)(`span`,{children:e.label}),(0,L.jsx)(`span`,{className:`ml-2.5 text-inherit opacity-65 tabular-nums`,children:t})]},e.id)})}),(0,L.jsxs)(`div`,{className:`flex items-center gap-4 ml-auto max-medium:w-full max-medium:ml-0 max-medium:min-w-0`,children:[(0,L.jsxs)(`div`,{className:`relative w-140 min-w-0 max-w-full max-medium:flex-auto max-medium:w-auto`,children:[(0,L.jsx)(l,{size:13,"aria-hidden":`true`,className:`absolute left-5 top-1/2 -translate-y-1/2 text-text-tertiary pointer-events-none`}),(0,L.jsx)(T,{"aria-label":`Search console logs`,value:c,onChange:e=>u(e.target.value),placeholder:`Search logs...`,className:`pl-15 w-full min-w-0`})]}),(0,L.jsx)(`button`,{className:`inline-grid place-items-center w-16 h-16 border border-border-subtle rounded-control bg-transparent text-text-secondary cursor-pointer hover:border-red hover:text-red hover:bg-red-soft`,type:`button`,onClick:()=>p(!0),"aria-label":`Clear console logs`,title:`Clear logs`,children:(0,L.jsx)(d,{size:15,"aria-hidden":`true`})})]})]}),(0,L.jsxs)(y,{className:`p-0 flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(`div`,{className:`scroll-region flex-1 min-h-0 flex flex-col p-0 bg-code-surface text-text-primary`,children:S.length===0?(0,L.jsx)(s,{title:t.length===0?`No log lines yet`:_?`No lines match your search`:`No lines match this level`,message:t.length===0?`Server log output will stream here as the gateway runs.`:`Adjust the search or pick another level to widen the view.`,icon:(0,L.jsx)(v,{size:20})}):S.map(e=>(0,L.jsx)(Y,{line:e,isNew:n.has(e.id)},e.id))}),(0,L.jsx)(`div`,{className:`flex items-center justify-between gap-5 shrink-0 px-8 py-4 border-t border-inner-border bg-surface-2 text-micro text-text-tertiary`,"aria-live":`polite`,children:(0,L.jsxs)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:[S.length,` of `,t.length,` lines`,a===`all`?``:` · ${a}`,_?` · search: "${c.trim()}"`:``]})})]}),(0,L.jsx)(g,{open:f,onClose:()=>p(!1),onConfirm:async()=>{h(null);try{await r(),p(!1),i.success(`Console logs cleared`)}catch{h(`Failed to clear server logs.`)}},title:`Clear console logs`,message:`Clear the in-memory server log tail? New lines keep streaming afterwards.`,confirmLabel:`Clear`,danger:!0}),m?(0,L.jsx)(`span`,{className:`text-badge text-red pt-0 px-8 pb-4`,children:m}):null]})}function $({tabAction:e}){let[t,n]=(0,D.useState)(``),[i,l]=(0,D.useState)(``),[d,f]=(0,D.useState)(``),[m,g]=(0,D.useState)(``),[_,v]=(0,D.useState)(void 0),[S,C]=(0,D.useState)([]);(0,D.useEffect)(()=>{let e=setTimeout(()=>f(t),300);return()=>clearTimeout(e)},[t]),(0,D.useEffect)(()=>{let e=setTimeout(()=>g(i),300);return()=>clearTimeout(e)},[i]);let w=h({limit:R,...d?{action:d}:{},...m?{actor:m}:{},..._?{cursor:_}:{}}),O=w.data,k=O?.entries??[],A=O?.nextCursor,j=()=>{A&&(C(e=>[...e,_??``]),v(A))},M=()=>{C(e=>{let t=e[e.length-1];return v(t||void 0),e.slice(0,-1)})},N=()=>{v(void 0),C([])};return(0,L.jsxs)(x,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(b,{title:`Admin Audit Trail`,subtitle:`Every privileged console mutation, retained on its own lifecycle`,icon:(0,L.jsx)(u,{size:16}),action:(0,L.jsxs)(`div`,{className:`flex gap-4 items-center`,children:[e,(0,L.jsx)(r,{variant:`secondary`,size:`sm`,onClick:()=>void w.refetch(),disabled:w.isFetching,icon:(0,L.jsx)(c,{size:13,className:w.isFetching?`animate-spin`:``}),children:`Refresh`})]})}),(0,L.jsxs)(y,{className:`flex flex-row items-center justify-between gap-6 flex-none min-h-0 px-8 py-5 border-b border-inner-border items-end`,children:[(0,L.jsx)(T,{label:`Action`,placeholder:`e.g. provider updated`,value:t,onChange:e=>{n(e.target.value),N()}}),(0,L.jsx)(T,{label:`Actor`,placeholder:`e.g. alice or a user id`,value:i,onChange:e=>{l(e.target.value),N()}}),(0,L.jsxs)(`div`,{className:`ml-auto flex gap-4`,children:[(0,L.jsx)(r,{size:`sm`,variant:`secondary`,onClick:M,disabled:S.length===0,children:`← Newer`}),(0,L.jsx)(r,{size:`sm`,variant:`secondary`,onClick:j,disabled:!A,children:`Older →`})]})]}),(0,L.jsx)(y,{className:`p-0 flex-1 min-h-0 flex flex-col`,children:(0,L.jsx)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-y-auto p-0 bg-transparent text-inherit`,children:w.isPending&&k.length===0?(0,L.jsx)(o,{label:`Loading audit trail…`}):w.isError&&k.length===0?(0,L.jsx)(a,{message:p(w.error,`Unable to load audit trail.`),onRetry:()=>void w.refetch()}):k.length===0?(0,L.jsx)(s,{title:`No audit entries yet`,message:`Privileged mutations (provider changes, key rotations, backups, bans) will appear here.`,icon:(0,L.jsx)(u,{size:20})}):(0,L.jsx)(E,{headers:[`Timestamp`,`Actor`,`Action`,`Target`,`Detail`],children:k.map(e=>(0,L.jsx)(ee,{entry:e},e.id))})})})]})}function ee({entry:e}){return(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{className:`text-badge text-text-tertiary whitespace-nowrap`,children:new Date(e.createdAt).toLocaleString()}),(0,L.jsxs)(`td`,{className:`max-w-100`,children:[(0,L.jsx)(`div`,{className:`text-caption font-semibold`,children:e.actorName??e.actor}),e.actorName?(0,L.jsx)(`div`,{title:e.actor,className:`truncate font-mono tabular-nums text-micro text-text-tertiary`,children:e.actor}):null]}),(0,L.jsx)(`td`,{children:(0,L.jsx)(w,{tone:e.action.includes(`delete`)||e.action.includes(`revoked`)?`err`:`ok`,title:e.action,children:I(e.action)})}),(0,L.jsx)(`td`,{title:e.target,className:`truncate font-mono tabular-nums text-badge max-w-110`,children:e.target}),(0,L.jsx)(`td`,{className:`font-mono tabular-nums text-badge max-w-160 overflow-hidden truncate`,children:e.detail?JSON.stringify(e.detail):`—`})]})}export{W as default,U as filterLogLines,H as statusTone};
1
+ import{o as e,r as t,t as n}from"./jsx-runtime-CXUMngI_.js";import{n as r,t as i}from"./toast-DKAdP2mo.js";import{n as a,r as o,t as s}from"./state-DHKdg-pm.js";import{t as c}from"./refresh-cw-BqJFk4sU.js";import{t as l}from"./search-JOKus9rb.js";import{t as u}from"./shield-check-DVS0Foqh.js";import{t as d}from"./trash-Cppn5c3R.js";import{a as f,c as p,l as m}from"./query-keys-ROf-g1Wi.js";import{D as h,F as g,O as _,tt as v}from"./entry-8jVcj7OO.js";import{n as y,r as b,t as x}from"./card-BTdbRFFg.js";import{r as S}from"./numbers-CFL4_Dqc.js";import{t as C}from"./stream-retry-5QnVuSSo.js";import{t as w}from"./badge-BwmwEOgA.js";import{n as T}from"./input-Bn4_kNav.js";import{t as E}from"./layout-Bv-NxqZ5.js";var D=e(t(),1),O=500,k=1500;function A(e){return m(e)&&typeof e.ts==`string`&&(e.level===`debug`||e.level===`info`||e.level===`warn`||e.level===`error`)&&typeof e.msg==`string`}function j(e){return!m(e)||!Array.isArray(e.lines)?[]:e.lines.filter(A)}function M(){let[e,t]=(0,D.useState)([]),[n,r]=(0,D.useState)(new Set),[i,a]=(0,D.useState)(`idle`),o=(0,D.useRef)(0),s=(0,D.useRef)(0),c=(0,D.useRef)(new Set),l=e=>({...e,id:`l${s.current+=1}`});return(0,D.useEffect)(()=>{let e=!1,n,i=o.current+=1,s=(e,t)=>{let n=window.setTimeout(()=>{c.current.delete(n),e()},t);c.current.add(n)},u=e=>{let n=l(e);r(e=>{let t=new Set(e);return t.add(n.id),t}),s(()=>{r(e=>{if(!e.has(n.id))return e;let t=new Set(e);return t.delete(n.id),t})},k),t(e=>{let t=[...e,n];return t.length>O?t.slice(t.length-O):t})},d=()=>{n=new EventSource(`/console/api/logs/stream`),n.addEventListener(`init`,n=>{if(!e)try{let e=JSON.parse(n.data);m(e)&&(t(j(e).slice(-500).map(l)),r(new Set)),a(`live`)}catch{}}),n.addEventListener(`line`,t=>{if(!e)try{let e=JSON.parse(t.data);A(e)&&(u(e),a(`live`))}catch{}}),n.addEventListener(`clear`,()=>{e||(t([]),r(new Set))}),n.onerror=()=>{n?.close(),!e&&(a(`reconnecting`),s(()=>{!e&&i===o.current&&p()},C))}},p=async()=>{try{let n=await f(`/logs?limit=200`);if(e||i!==o.current)return;t(j(n).slice(-500).map(l)),r(new Set),d()}catch{}};return p(),()=>{e=!0;for(let e of c.current)window.clearTimeout(e);c.current.clear(),n?.close()}},[]),{lines:e,newLineIds:n,status:i,clear:(0,D.useCallback)(async()=>{await f(`/logs`,{method:`DELETE`}),t([]),r(new Set)},[])}}var N={"api_key.created":`API key created`,"api_key.updated":`API key updated`,"api_key.revoked":`API key revoked`,"api_key.regenerated":`API key regenerated`,"api_key.shared":`API key shared`,"api_key.share_regenerated":`API key share link regenerated`,"api_key.share_revoked":`API key unshared`,"provider.created":`Provider created`,"provider.updated":`Provider updated`,"provider.deleted":`Provider deleted`,"provider.global.updated":`Global provider updated`,"provider.global.deleted":`Global provider deleted`,"provider.routing.updated":`Provider routing updated`,"provider.models.registered":`Provider models registered`,"provider.models.bulk_deleted":`Provider models bulk-deleted`,"provider.model.deleted":`Provider model deleted`,"provider.model.enabled":`Provider model enabled`,"provider.model.disabled":`Provider model disabled`,"provider_account.created":`Provider account connected`,"provider_account.updated":`Provider account updated`,"provider_account.recovered":`Provider account recovered`,"provider_account.revoked":`Provider account revoked`,"provider_account.circuit_force_closed":`Provider account circuit force-closed`,"provider_account.deleted":`Provider account deleted`,"provider_account.exported":`Provider accounts exported (plaintext)`,"provider_account.global.updated":`Global provider account updated`,"provider_account.global.refreshed":`Global provider account refreshed`,"provider_account.global.deleted":`Global provider account deleted`,"model_alias.created":`Model alias created`,"model_alias.updated":`Model alias updated`,"model_alias.deleted":`Model alias deleted`,"model_combo.created":`Model combo created`,"model_combo.updated":`Model combo updated`,"model_combo.cloned":`Model combo cloned`,"model_combo.deleted":`Model combo deleted`,"network_pool.created":`Network pool created`,"network_pool.updated":`Network pool updated`,"network_pool.deleted":`Network pool deleted`,"network_pool.recovered":`Network pool recovered`,"network_pool.strategy_updated":`Network pool strategy updated`,"network_pool.relay_deployed":`Network pool relay deployed`,"filter_rule.created":`Filter rule created`,"filter_rule.updated":`Filter rule updated`,"filter_rule.deleted":`Filter rule deleted`,"filter_rule.reordered":`Filter rules reordered`,"filter_rule.master_toggle":`Filter master switch toggled`,"settings.runtime.updated":`Runtime settings updated`,"cli_tool.mappings_saved":`CLI tool mappings saved`,"cli_tool.mappings_reset":`CLI tool mappings reset`,"cli_tool.applied":`CLI tool applied`,"console.password_changed":`Console password changed`,"console_logs.cleared":`Console logs cleared`,"security.ip_banned":`IP banned`,"backup.reset":`Backup reset`,"backup.delete_all":`Delete all configuration`},P={api:`API`,ip:`IP`,cli:`CLI`,oauth:`OAuth`};function F(e){return e.split(`.`).map(e=>e.split(/[_-]+/).filter(Boolean).map(e=>P[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)).join(` `)).join(` · `)}function I(e){return N[e]??F(e)}var L=n(),R=50,z=[{id:`all`,label:`All`},{id:`debug`,label:`Debug`},{id:`info`,label:`Info`},{id:`warn`,label:`Warn`},{id:`error`,label:`Error`}],B={debug:`var(--text-tertiary)`,info:`var(--accent)`,warn:`var(--orange)`,error:`var(--red)`},V={debug:`DBG`,info:`INF`,warn:`WRN`,error:`ERR`};function H(e){return e>=500?`err`:e>=400?`warn`:`ok`}function U(e,t,n){let r=n.trim().toLowerCase();return e.filter(e=>t!==`all`&&e.level!==t?!1:!r||`${e.msg} ${e.endpoint??``} ${e.model??``} ${e.routedModel??``} ${e.providerId??``} ${e.errorCode??``} ${e.userAgent??``} ${e.clientIp??``} ${e.accountLabel??``}`.toLowerCase().includes(r))}function W(){let[e,t]=(0,D.useState)(`logs`),n=_().data?.isPlatformAdmin??!1,i=e===`audit`&&!n?`logs`:e,a=(0,L.jsxs)(`div`,{className:`flex gap-4`,children:[(0,L.jsx)(r,{variant:i===`logs`?`primary`:`secondary`,size:`sm`,onClick:()=>t(`logs`),icon:(0,L.jsx)(v,{size:13}),"aria-pressed":i===`logs`,children:`Console Log`}),n?(0,L.jsx)(r,{variant:i===`audit`?`primary`:`secondary`,size:`sm`,onClick:()=>t(`audit`),icon:(0,L.jsx)(u,{size:13}),"aria-pressed":i===`audit`,children:`Admin Audit`}):null]});return(0,L.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:i===`logs`?(0,L.jsx)(Q,{tabAction:a}):(0,L.jsx)($,{tabAction:a})})}function G(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour12:!1})}function K(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function q(e){let t=e.details;if(!t)return null;let n=typeof t.inputTokens==`number`?t.inputTokens:void 0,r=typeof t.outputTokens==`number`?t.outputTokens:void 0,i=typeof t.cachedInputTokens==`number`?t.cachedInputTokens:void 0,a=typeof t.reasoningTokens==`number`?t.reasoningTokens:void 0;if(n===void 0&&r===void 0&&i===void 0&&a===void 0)return null;let o=[];return n!==void 0&&o.push(`${K(n)} in`),r!==void 0&&o.push(`${K(r)} out`),i!==void 0&&o.push(`${K(i)} cached`),a!==void 0&&a>0&&o.push(`${K(a)} reason`),o.join(` / `)}function J(e){let t=e.model,n=e.routedModel,r=e.providerId,i=n??t;if(!i&&!r)return null;let a=r&&i?`${r}/${i}`:i??r??``;return n&&t&&n!==t?`${a} ← ${t}`:a}var Y=(0,D.memo)(function({line:e,isNew:t}){let n=e.event!==void 0,r=e.level;return(0,L.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-4 px-8 py-1.5 font-mono text-caption leading-normal max-medium:gap-3 max-medium:px-5 max-medium:text-badge${r===`warn`?` bg-orange-soft`:r===`error`?` bg-red-soft`:``}${t?` bg-surface-muted`:``} hover:bg-surface-hover`,"data-log-tone":r,children:[(0,L.jsx)(`span`,{className:`max-medium:flex-none flex-none tabular-nums text-text-tertiary`,children:G(e.ts)}),(0,L.jsx)(`span`,{className:`flex-none w-13 text-left text-micro font-bold tracking-label`,style:{color:B[e.level]},title:e.level.toUpperCase(),children:V[e.level]}),n?(0,L.jsx)(X,{line:e}):(0,L.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere break-words text-text-secondary`,children:e.msg})]})});function X({line:e}){let t=J(e),n=q(e),r=Z(e);return(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[(0,L.jsxs)(`span`,{className:`font-bold tracking-label ${r.tone}`,"data-log-field":`badge`,children:[`[`,r.label,`]`]}),` `,(0,L.jsx)(`span`,{className:`text-text-tertiary`,children:e.method??`POST`}),` `,(0,L.jsx)(`span`,{className:`text-text-primary`,children:e.endpoint??``}),e.status===void 0?null:(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`tabular-nums ${H(e.status)===`ok`?`text-text-tertiary`:H(e.status)===`warn`?`text-orange font-semibold`:`text-red font-semibold`}`,children:e.status})]}),e.durationMs===void 0?null:(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`tabular-nums text-text-secondary`,children:S(e.durationMs)})]}),t?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`text-status-info`,"data-log-field":`route`,children:t})]}):null,e.accountLabel?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`text-purple`,"data-log-field":`account`,title:e.accountId??void 0,children:e.accountLabel})]}):null,e.clientIp?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`tabular-nums text-text-secondary`,"data-log-field":`ip`,children:e.clientIp})]}):null,n?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`tabular-nums text-orange`,"data-log-field":`tokens`,children:n})]}):null,e.errorCode?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsxs)(`span`,{className:`text-red`,title:e.msg,children:[e.msg,` (`,e.errorCode,`)`]})]}):null,e.requestId?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(`span`,{className:`text-micro text-text-tertiary`,"data-log-field":`id`,children:e.requestId.slice(0,8)})]}):null]})}function Z(e){return e.event===`request_start`||e.status===void 0?{label:`REQUEST`,tone:`text-text-tertiary`}:e.event===`request_error`||e.status>=400?{label:`FAILED`,tone:`text-red`}:{label:`SUCCESS`,tone:`text-status-info`}}function Q({tabAction:e}){let{lines:t,newLineIds:n,clear:r}=M(),[a,o]=(0,D.useState)(`all`),[c,u]=(0,D.useState)(``),[f,p]=(0,D.useState)(!1),[m,h]=(0,D.useState)(null),_=c.trim().toLowerCase(),S=(0,D.useMemo)(()=>U(t,a,_).slice().reverse(),[t,a,_]),C=(0,D.useMemo)(()=>{let e=new Map([[`all`,t.length]]);for(let n of t)e.set(n.level,(e.get(n.level)??0)+1);return e},[t]);return(0,L.jsxs)(x,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(b,{title:`Console Log`,subtitle:`${S.length} of ${t.length} lines`,icon:(0,L.jsx)(v,{size:16}),action:e}),(0,L.jsxs)(y,{className:`flex flex-row items-center justify-between gap-8 flex-none min-h-0 px-7 py-4 border-b border-inner-border max-medium:flex-col max-medium:items-start max-medium:gap-4`,children:[(0,L.jsx)(`div`,{className:`inline-flex items-center gap-1.5 flex-none max-medium:w-full max-medium:overflow-x-auto`,role:`group`,"aria-label":`Log level`,children:z.map(e=>{let t=C.get(e.id)??0;return(0,L.jsxs)(`button`,{className:`inline-flex items-center appearance-none border-0 rounded-tiny px-5 py-3.5 bg-transparent font-sans text-badge font-semibold leading-none cursor-pointer ${a===e.id?`bg-surface-muted text-text-primary`:`text-text-tertiary hover:bg-surface-muted hover:text-text-primary`}`,type:`button`,onClick:()=>o(e.id),"aria-pressed":a===e.id,children:[(0,L.jsx)(`span`,{children:e.label}),(0,L.jsx)(`span`,{className:`ml-2.5 text-inherit opacity-65 tabular-nums`,children:t})]},e.id)})}),(0,L.jsxs)(`div`,{className:`flex items-center gap-4 ml-auto max-medium:w-full max-medium:ml-0 max-medium:min-w-0`,children:[(0,L.jsxs)(`div`,{className:`relative w-140 min-w-0 max-w-full max-medium:flex-auto max-medium:w-auto`,children:[(0,L.jsx)(l,{size:13,"aria-hidden":`true`,className:`absolute left-5 top-1/2 -translate-y-1/2 text-text-tertiary pointer-events-none`}),(0,L.jsx)(T,{"aria-label":`Search console logs`,value:c,onChange:e=>u(e.target.value),placeholder:`Search logs...`,className:`pl-15 w-full min-w-0`})]}),(0,L.jsx)(`button`,{className:`inline-grid place-items-center w-16 h-16 border border-border-subtle rounded-control bg-transparent text-text-secondary cursor-pointer hover:border-red hover:text-red hover:bg-red-soft`,type:`button`,onClick:()=>p(!0),"aria-label":`Clear console logs`,title:`Clear logs`,children:(0,L.jsx)(d,{size:15,"aria-hidden":`true`})})]})]}),(0,L.jsxs)(y,{className:`p-0 flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(`div`,{className:`scroll-region flex-1 min-h-0 flex flex-col p-0 bg-code-surface text-text-primary`,children:S.length===0?(0,L.jsx)(s,{title:t.length===0?`No log lines yet`:_?`No lines match your search`:`No lines match this level`,message:t.length===0?`Server log output will stream here as the gateway runs.`:`Adjust the search or pick another level to widen the view.`,icon:(0,L.jsx)(v,{size:20})}):S.map(e=>(0,L.jsx)(Y,{line:e,isNew:n.has(e.id)},e.id))}),(0,L.jsx)(`div`,{className:`flex items-center justify-between gap-5 shrink-0 px-8 py-4 border-t border-inner-border bg-surface-2 text-micro text-text-tertiary`,"aria-live":`polite`,children:(0,L.jsxs)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:[S.length,` of `,t.length,` lines`,a===`all`?``:` · ${a}`,_?` · search: "${c.trim()}"`:``]})})]}),(0,L.jsx)(g,{open:f,onClose:()=>p(!1),onConfirm:async()=>{h(null);try{await r(),p(!1),i.success(`Console logs cleared`)}catch{h(`Failed to clear server logs.`)}},title:`Clear console logs`,message:`Clear the in-memory server log tail? New lines keep streaming afterwards.`,confirmLabel:`Clear`,danger:!0}),m?(0,L.jsx)(`span`,{className:`text-badge text-red pt-0 px-8 pb-4`,children:m}):null]})}function $({tabAction:e}){let[t,n]=(0,D.useState)(``),[i,l]=(0,D.useState)(``),[d,f]=(0,D.useState)(``),[m,g]=(0,D.useState)(``),[_,v]=(0,D.useState)(void 0),[S,C]=(0,D.useState)([]);(0,D.useEffect)(()=>{let e=setTimeout(()=>f(t),300);return()=>clearTimeout(e)},[t]),(0,D.useEffect)(()=>{let e=setTimeout(()=>g(i),300);return()=>clearTimeout(e)},[i]);let w=h({limit:R,...d?{action:d}:{},...m?{actor:m}:{},..._?{cursor:_}:{}}),O=w.data,k=O?.entries??[],A=O?.nextCursor,j=()=>{A&&(C(e=>[...e,_??``]),v(A))},M=()=>{C(e=>{let t=e[e.length-1];return v(t||void 0),e.slice(0,-1)})},N=()=>{v(void 0),C([])};return(0,L.jsxs)(x,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(b,{title:`Admin Audit Trail`,subtitle:`Every privileged console mutation, retained on its own lifecycle`,icon:(0,L.jsx)(u,{size:16}),action:(0,L.jsxs)(`div`,{className:`flex gap-4 items-center`,children:[e,(0,L.jsx)(r,{variant:`secondary`,size:`sm`,onClick:()=>void w.refetch(),disabled:w.isFetching,icon:(0,L.jsx)(c,{size:13,className:w.isFetching?`animate-spin`:``}),children:`Refresh`})]})}),(0,L.jsxs)(y,{className:`flex flex-row items-center justify-between gap-6 flex-none min-h-0 px-8 py-5 border-b border-inner-border items-end`,children:[(0,L.jsx)(T,{label:`Action`,placeholder:`e.g. provider updated`,value:t,onChange:e=>{n(e.target.value),N()}}),(0,L.jsx)(T,{label:`Actor`,placeholder:`e.g. alice or a user id`,value:i,onChange:e=>{l(e.target.value),N()}}),(0,L.jsxs)(`div`,{className:`ml-auto flex gap-4`,children:[(0,L.jsx)(r,{size:`sm`,variant:`secondary`,onClick:M,disabled:S.length===0,children:`← Newer`}),(0,L.jsx)(r,{size:`sm`,variant:`secondary`,onClick:j,disabled:!A,children:`Older →`})]})]}),(0,L.jsx)(y,{className:`p-0 flex-1 min-h-0 flex flex-col`,children:(0,L.jsx)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-y-auto p-0 bg-transparent text-inherit`,children:w.isPending&&k.length===0?(0,L.jsx)(o,{label:`Loading audit trail…`}):w.isError&&k.length===0?(0,L.jsx)(a,{message:p(w.error,`Unable to load audit trail.`),onRetry:()=>void w.refetch()}):k.length===0?(0,L.jsx)(s,{title:`No audit entries yet`,message:`Privileged mutations (provider changes, key rotations, backups, bans) will appear here.`,icon:(0,L.jsx)(u,{size:20})}):(0,L.jsx)(E,{headers:[`Timestamp`,`Actor`,`Action`,`Target`,`Detail`],children:k.map(e=>(0,L.jsx)(ee,{entry:e},e.id))})})})]})}function ee({entry:e}){return(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{className:`text-badge text-text-tertiary whitespace-nowrap`,children:new Date(e.createdAt).toLocaleString()}),(0,L.jsxs)(`td`,{className:`max-w-100`,children:[(0,L.jsx)(`div`,{className:`text-caption font-semibold`,children:e.actorName??e.actor}),e.actorName?(0,L.jsx)(`div`,{title:e.actor,className:`truncate font-mono tabular-nums text-micro text-text-tertiary`,children:e.actor}):null]}),(0,L.jsx)(`td`,{children:(0,L.jsx)(w,{tone:e.action.includes(`delete`)||e.action.includes(`revoked`)?`err`:`ok`,title:e.action,children:I(e.action)})}),(0,L.jsx)(`td`,{title:e.target,className:`truncate font-mono tabular-nums text-badge max-w-110`,children:e.target}),(0,L.jsx)(`td`,{className:`font-mono tabular-nums text-badge max-w-160 overflow-hidden truncate`,children:e.detail?JSON.stringify(e.detail):`—`})]})}export{W as default,U as filterLogLines,H as statusTone};
@@ -1 +1 @@
1
- import{n as e,o as t,r as n,t as r}from"./jsx-runtime-CXUMngI_.js";import{d as i,n as a}from"./toast-DKAdP2mo.js";import{t as o}from"./image-BPaouViG.js";import{t as s}from"./layers-2-glBbjl.js";import{t as c}from"./rotate-ccw-CufcqITi.js";import{G as l,H as u,I as d,K as f,L as p,R as m,U as h,V as g,W as _,q as v,z as y}from"./entry-C1Dn2nQu.js";import{n as b,r as x,t as S}from"./card-BTdbRFFg.js";import{t as C}from"./switch-DIDeAiz9.js";import{t as w}from"./stack-C1kTcOmP.js";import{t as T}from"./inline-DCejSLlA.js";var E=e(`frame`,[[`line`,{x1:`22`,x2:`2`,y1:`6`,y2:`6`,key:`15w7dq`}],[`line`,{x1:`22`,x2:`2`,y1:`18`,y2:`18`,key:`1ip48p`}],[`line`,{x1:`6`,x2:`6`,y1:`2`,y2:`22`,key:`a2lnyx`}],[`line`,{x1:`18`,x2:`18`,y1:`2`,y2:`22`,key:`8vb6jd`}]]),D=e(`panel-top`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),O=e(`rectangle-horizontal`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`2`,key:`9lu3g6`}]]),k=t(n(),1),A=r(),j={cards:{label:`Cards`,description:`The card body on every page`,icon:(0,A.jsx)(O,{size:15})},chrome:{label:`Sidebar & topbar`,description:`The shell around the page`,icon:(0,A.jsx)(D,{size:15})}};function M(e){return e<1048576?`${Math.max(1,Math.round(e/1024))} KB`:`${(e/1048576).toFixed(1)} MB`}function N(){let[e,t]=y(),[n,r]=(0,k.useState)(!1),[l,u]=(0,k.useState)(null),C=async n=>{let a=n.target.files?.[0];if(n.target.value=``,!a)return;let o=_(a);if(!o){i.error(`Choose an image or a video.`);return}if(a.size>4294967296){i.error(`File too big. 4 GB is the limit.`);return}let s=a.size>g;r(!0);try{let n=o===`image`?await f(a):a;await v(n,o),u(n.size),t({backgroundSet:!0,backgroundEnabled:!0,backgroundRevision:e.backgroundRevision+1}),i.success(o===`video`?`Video background saved in this browser.`:`Background saved in this browser.`),s&&i.warning(`File too big. Your web performance and experience may be degraded.`)}catch{i.error(`Could not store that file. The browser may be out of space.`)}finally{r(!1)}},D=async()=>{r(!0);try{await h(),u(null),t({backgroundSet:!1,backgroundEnabled:!1})}catch{i.error(`Could not remove the background.`)}finally{r(!1)}};return(0,A.jsxs)(w,{gap:`16px`,children:[(0,A.jsxs)(S,{children:[(0,A.jsx)(x,{title:`Background`,subtitle:`Stored in this browser only. It never leaves the machine.`,icon:(0,A.jsx)(o,{size:16}),action:(0,A.jsx)(T,{children:(0,A.jsx)(a,{variant:`ghost`,size:`sm`,icon:(0,A.jsx)(c,{size:13}),onClick:()=>{m({backgroundOpacity:p.backgroundOpacity,backgroundScale:p.backgroundScale,backgroundX:p.backgroundX,backgroundY:p.backgroundY,backgroundBlur:p.backgroundBlur,backgroundEnabled:e.backgroundSet}),i.success(`Background reset to defaults.`)},children:`Reset`})})}),(0,A.jsx)(b,{children:(0,A.jsxs)(w,{gap:`14px`,children:[(0,A.jsx)(P,{settings:e,onBytes:u,bytes:l}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,A.jsxs)(`label`,{className:`btn btn-primary inline-flex items-center justify-center gap-3.5 rounded-control font-semibold text-caption px-7 py-2 cursor-pointer bg-accent text-accent-foreground`,children:[n?`Working…`:e.backgroundSet?`Replace`:`Upload image or video`,(0,A.jsx)(`input`,{type:`file`,accept:`image/*,video/*`,className:`sr-only`,onChange:e=>void C(e),disabled:n})]}),e.backgroundSet?(0,A.jsx)(a,{variant:`danger`,size:`sm`,onClick:()=>void D(),disabled:n,children:`Remove`}):null,(0,A.jsx)(`span`,{className:`text-badge text-text-tertiary`,children:`Images are resized to 2560px. Videos play on desktop and show their first frame on mobile.`})]}),(0,A.jsx)(F,{settings:e,setSettings:t})]})})]}),(0,A.jsxs)(S,{children:[(0,A.jsx)(x,{title:`Blur`,subtitle:`Each surface keeps its own style. Dialogs are never blurred, so they stay readable.`,icon:(0,A.jsx)(s,{size:16}),action:(0,A.jsx)(T,{children:(0,A.jsx)(a,{variant:`ghost`,size:`sm`,icon:(0,A.jsx)(c,{size:13}),onClick:()=>{m({blurCardsAmount:p.blurCardsAmount,blurChromeAmount:p.blurChromeAmount,blurCardsEnabled:p.blurCardsEnabled,blurChromeEnabled:p.blurChromeEnabled,blurCardsDepth:p.blurCardsDepth,blurChromeDepth:p.blurChromeDepth}),i.success(`Blur reset to defaults.`)},children:`Reset`})})}),(0,A.jsx)(b,{children:(0,A.jsx)(`div`,{className:`grid gap-10 lg:grid-cols-2`,children:d.map(n=>{let r=n===`chrome`;return(0,A.jsx)(L,{target:n,enabled:r?e.blurChromeEnabled:e.blurCardsEnabled,onToggle:()=>t(r?{blurChromeEnabled:!e.blurChromeEnabled}:{blurCardsEnabled:!e.blurCardsEnabled}),clarity:r?e.blurChromeAmount:e.blurCardsAmount,onClarity:e=>t(r?{blurChromeAmount:e}:{blurCardsAmount:e}),depth:r?e.blurChromeDepth:e.blurCardsDepth,onDepth:e=>t(r?{blurChromeDepth:e}:{blurCardsDepth:e})},n)})})})]}),(0,A.jsxs)(S,{children:[(0,A.jsx)(x,{title:`Empty panels`,subtitle:`A dashed frame around a page that has nothing to show yet.`,icon:(0,A.jsx)(E,{size:16})}),(0,A.jsx)(b,{children:(0,A.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":e.emptyOutline,onClick:()=>t({emptyOutline:!e.emptyOutline}),className:`flex w-full items-center justify-between gap-6 rounded-card border border-inner-border bg-surface-2 px-7 py-6 text-left`,children:[(0,A.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,A.jsx)(`span`,{className:`text-caption font-semibold text-text-primary`,children:`Dashed border`}),(0,A.jsx)(`span`,{className:`text-badge text-text-tertiary`,children:`Off leaves the empty state sitting on the card.`})]}),(0,A.jsx)(`span`,{"aria-hidden":`true`,className:e.emptyOutline?`h-10 w-18 shrink-0 rounded-pill bg-accent p-1`:`h-10 w-18 shrink-0 rounded-pill bg-surface-active p-1`,children:(0,A.jsx)(`span`,{className:e.emptyOutline?`block size-8 translate-x-8 rounded-full bg-accent-foreground transition-transform`:`block size-8 rounded-full bg-text-secondary transition-transform`})})]})})]})]})}function P({settings:e,bytes:t,onBytes:n}){let[r,i]=(0,k.useState)(null),[a,o]=(0,k.useState)(null);if((0,k.useEffect)(()=>{if(!e.backgroundSet){i(u),o(`image`);return}let t=!0,r=null;return l().then(e=>{if(e){if(!t){URL.revokeObjectURL(e.url);return}r=e.url,i(e.url),o(e.kind),n(e.blob.size)}}).catch(()=>{}),()=>{t=!1,r&&URL.revokeObjectURL(r)}},[e.backgroundSet,n]),!r)return(0,A.jsx)(`div`,{className:`flex h-60 items-center justify-center rounded-card border border-dashed border-inner-border bg-surface-2 text-caption text-text-tertiary`,children:`No background yet. The console uses its plain surface.`});let s={objectFit:`cover`,objectPosition:`${50+e.backgroundX/2}% ${50+e.backgroundY/2}%`,transform:`scale(${e.backgroundScale/100})`,opacity:e.backgroundOpacity/100};return(0,A.jsxs)(`div`,{className:`relative h-75 overflow-hidden rounded-card border border-inner-border bg-surface-2`,children:[a===`video`?(0,A.jsx)(`video`,{src:r,muted:!0,playsInline:!0,preload:`metadata`,className:`size-full`,style:s}):(0,A.jsx)(`img`,{src:r,alt:``,className:`size-full`,style:s}),(0,A.jsxs)(`span`,{className:`absolute bottom-4 left-5 rounded-control bg-surface-1 px-4 py-1 text-micro text-text-secondary`,children:[a===`video`?`Video`:`Image`,t===null?``:` · ${M(t)}`,e.backgroundEnabled?``:` · hidden`]})]})}function F({settings:e,setSettings:t}){return(0,A.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,A.jsxs)(`label`,{className:`flex min-h-18 items-center justify-between gap-6 text-body font-semibold text-text-primary`,children:[(0,A.jsx)(`span`,{children:`Show background`}),(0,A.jsx)(C,{checked:e.backgroundEnabled,onChange:e=>t({backgroundEnabled:e}),"aria-label":`Show background`})]}),(0,A.jsxs)(`div`,{className:`grid gap-7 sm:grid-cols-2`,children:[(0,A.jsx)(I,{label:`Visibility`,value:e.backgroundOpacity,defaultValue:p.backgroundOpacity,min:0,max:100,unit:`%`,onChange:e=>t({backgroundOpacity:e})}),(0,A.jsx)(I,{label:`Blur`,value:e.backgroundBlur,defaultValue:p.backgroundBlur,min:0,max:100,unit:`%`,onChange:e=>t({backgroundBlur:e})}),(0,A.jsx)(I,{label:`Zoom`,value:e.backgroundScale,defaultValue:p.backgroundScale,min:100,max:180,unit:`%`,onChange:e=>t({backgroundScale:e})}),(0,A.jsx)(I,{label:`Shift horizontal`,value:e.backgroundX,defaultValue:p.backgroundX,min:-100,max:100,onChange:e=>t({backgroundX:e})}),(0,A.jsx)(I,{label:`Shift vertical`,value:e.backgroundY,defaultValue:p.backgroundY,min:-100,max:100,onChange:e=>t({backgroundY:e})})]})]})}function I({label:e,value:t,defaultValue:n,min:r,max:i,unit:a,onChange:o}){return(0,A.jsxs)(`label`,{className:`flex flex-col gap-2 text-caption text-text-secondary`,children:[(0,A.jsxs)(`span`,{className:`flex items-center justify-between`,children:[e,(0,A.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,A.jsxs)(`span`,{className:`font-mono tabular-nums text-badge text-text-tertiary`,children:[t,a??``]}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(n),disabled:t===n,"aria-label":`Reset ${e}`,title:`Reset ${e} to ${n}${a??``}`,className:`flex size-9 items-center justify-center rounded-control text-text-tertiary hover:bg-hover hover:text-text-primary disabled:pointer-events-none disabled:opacity-30`,children:(0,A.jsx)(c,{size:11})})]})]}),(0,A.jsx)(`input`,{type:`range`,min:r,max:i,value:t,onChange:e=>o(Number(e.target.value)),"aria-label":e,className:`blur-slider w-full h-11 m-0 border-0 rounded-pill cursor-pointer`,style:{"--fill":`${(t-r)/(i-r)*100}%`}})]})}function L({target:e,enabled:t,onToggle:n,clarity:r,onClarity:i,depth:a,onDepth:o}){let s=j[e]??j.cards;return(0,A.jsxs)(`div`,{className:`flex flex-col gap-8 rounded-card border border-inner-border bg-surface-2 p-8`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-5`,children:[(0,A.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-control bg-surface-1 text-text-secondary`,children:s.icon}),(0,A.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,A.jsx)(`span`,{className:`text-body font-semibold text-text-primary`,children:s.label}),(0,A.jsx)(`span`,{className:`text-micro text-text-tertiary`,children:s.description})]}),(0,A.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":`Toggle ${s.label} blur`,onClick:n,className:t?`h-10 w-18 shrink-0 rounded-pill bg-accent p-1`:`h-10 w-18 shrink-0 rounded-pill bg-surface-active p-1`,children:(0,A.jsx)(`span`,{className:t?`block size-8 translate-x-8 rounded-full bg-accent-foreground`:`block size-8 rounded-full bg-text-secondary`})})]}),(0,A.jsxs)(`div`,{className:t?`flex flex-col gap-6`:`flex flex-col gap-6 opacity-40`,children:[(0,A.jsxs)(`label`,{className:`flex flex-col gap-3 text-caption text-text-secondary`,children:[(0,A.jsxs)(`span`,{className:`flex items-center justify-between`,children:[`Clarity`,(0,A.jsxs)(`span`,{className:`font-mono text-badge tabular-nums text-text-tertiary`,children:[r,`%`]})]}),(0,A.jsx)(`input`,{type:`range`,min:0,max:100,value:r,disabled:!t,onChange:e=>i(Number(e.target.value)),"aria-label":`${s.label} clarity. How see-through the surface is.`,className:`blur-slider w-full h-11 m-0 border-0 rounded-pill cursor-pointer`,style:{"--fill":`${r}%`}}),(0,A.jsxs)(`span`,{className:`flex justify-between text-badge text-text-tertiary`,children:[(0,A.jsx)(`span`,{children:`See-through`}),(0,A.jsx)(`span`,{children:`Solid`})]})]}),(0,A.jsxs)(`label`,{className:`flex flex-col gap-3 text-caption text-text-secondary`,children:[(0,A.jsxs)(`span`,{className:`flex items-center justify-between`,children:[`Blur`,(0,A.jsxs)(`span`,{className:`font-mono text-badge tabular-nums text-text-tertiary`,children:[a,`%`]})]}),(0,A.jsx)(`input`,{type:`range`,min:0,max:100,value:a,disabled:!t,onChange:e=>o(Number(e.target.value)),"aria-label":`${s.label} blur. How blurred whatever is behind it looks.`,className:`blur-slider w-full h-11 m-0 border-0 rounded-pill cursor-pointer`,style:{"--fill":`${a}%`}}),(0,A.jsxs)(`span`,{className:`flex justify-between text-badge text-text-tertiary`,children:[(0,A.jsx)(`span`,{children:`Sharp`}),(0,A.jsx)(`span`,{children:`Blurred`})]})]})]})]})}export{N as default};
1
+ import{n as e,o as t,r as n,t as r}from"./jsx-runtime-CXUMngI_.js";import{d as i,n as a}from"./toast-DKAdP2mo.js";import{t as o}from"./image-BPaouViG.js";import{t as s}from"./layers-2-glBbjl.js";import{t as c}from"./rotate-ccw-CufcqITi.js";import{G as l,H as u,I as d,K as f,L as p,R as m,U as h,V as g,W as _,q as v,z as y}from"./entry-8jVcj7OO.js";import{n as b,r as x,t as S}from"./card-BTdbRFFg.js";import{t as C}from"./switch-DIDeAiz9.js";import{t as w}from"./stack-C1kTcOmP.js";import{t as T}from"./inline-DCejSLlA.js";var E=e(`frame`,[[`line`,{x1:`22`,x2:`2`,y1:`6`,y2:`6`,key:`15w7dq`}],[`line`,{x1:`22`,x2:`2`,y1:`18`,y2:`18`,key:`1ip48p`}],[`line`,{x1:`6`,x2:`6`,y1:`2`,y2:`22`,key:`a2lnyx`}],[`line`,{x1:`18`,x2:`18`,y1:`2`,y2:`22`,key:`8vb6jd`}]]),D=e(`panel-top`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),O=e(`rectangle-horizontal`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`2`,key:`9lu3g6`}]]),k=t(n(),1),A=r(),j={cards:{label:`Cards`,description:`The card body on every page`,icon:(0,A.jsx)(O,{size:15})},chrome:{label:`Sidebar & topbar`,description:`The shell around the page`,icon:(0,A.jsx)(D,{size:15})}};function M(e){return e<1048576?`${Math.max(1,Math.round(e/1024))} KB`:`${(e/1048576).toFixed(1)} MB`}function N(){let[e,t]=y(),[n,r]=(0,k.useState)(!1),[l,u]=(0,k.useState)(null),C=async n=>{let a=n.target.files?.[0];if(n.target.value=``,!a)return;let o=_(a);if(!o){i.error(`Choose an image or a video.`);return}if(a.size>4294967296){i.error(`File too big. 4 GB is the limit.`);return}let s=a.size>g;r(!0);try{let n=o===`image`?await f(a):a;await v(n,o),u(n.size),t({backgroundSet:!0,backgroundEnabled:!0,backgroundRevision:e.backgroundRevision+1}),i.success(o===`video`?`Video background saved in this browser.`:`Background saved in this browser.`),s&&i.warning(`File too big. Your web performance and experience may be degraded.`)}catch{i.error(`Could not store that file. The browser may be out of space.`)}finally{r(!1)}},D=async()=>{r(!0);try{await h(),u(null),t({backgroundSet:!1,backgroundEnabled:!1})}catch{i.error(`Could not remove the background.`)}finally{r(!1)}};return(0,A.jsxs)(w,{gap:`16px`,children:[(0,A.jsxs)(S,{children:[(0,A.jsx)(x,{title:`Background`,subtitle:`Stored in this browser only. It never leaves the machine.`,icon:(0,A.jsx)(o,{size:16}),action:(0,A.jsx)(T,{children:(0,A.jsx)(a,{variant:`ghost`,size:`sm`,icon:(0,A.jsx)(c,{size:13}),onClick:()=>{m({backgroundOpacity:p.backgroundOpacity,backgroundScale:p.backgroundScale,backgroundX:p.backgroundX,backgroundY:p.backgroundY,backgroundBlur:p.backgroundBlur,backgroundEnabled:e.backgroundSet}),i.success(`Background reset to defaults.`)},children:`Reset`})})}),(0,A.jsx)(b,{children:(0,A.jsxs)(w,{gap:`14px`,children:[(0,A.jsx)(P,{settings:e,onBytes:u,bytes:l}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,A.jsxs)(`label`,{className:`btn btn-primary inline-flex items-center justify-center gap-3.5 rounded-control font-semibold text-caption px-7 py-2 cursor-pointer bg-accent text-accent-foreground`,children:[n?`Working…`:e.backgroundSet?`Replace`:`Upload image or video`,(0,A.jsx)(`input`,{type:`file`,accept:`image/*,video/*`,className:`sr-only`,onChange:e=>void C(e),disabled:n})]}),e.backgroundSet?(0,A.jsx)(a,{variant:`danger`,size:`sm`,onClick:()=>void D(),disabled:n,children:`Remove`}):null,(0,A.jsx)(`span`,{className:`text-badge text-text-tertiary`,children:`Images are resized to 2560px. Videos play on desktop and show their first frame on mobile.`})]}),(0,A.jsx)(F,{settings:e,setSettings:t})]})})]}),(0,A.jsxs)(S,{children:[(0,A.jsx)(x,{title:`Blur`,subtitle:`Each surface keeps its own style. Dialogs are never blurred, so they stay readable.`,icon:(0,A.jsx)(s,{size:16}),action:(0,A.jsx)(T,{children:(0,A.jsx)(a,{variant:`ghost`,size:`sm`,icon:(0,A.jsx)(c,{size:13}),onClick:()=>{m({blurCardsAmount:p.blurCardsAmount,blurChromeAmount:p.blurChromeAmount,blurCardsEnabled:p.blurCardsEnabled,blurChromeEnabled:p.blurChromeEnabled,blurCardsDepth:p.blurCardsDepth,blurChromeDepth:p.blurChromeDepth}),i.success(`Blur reset to defaults.`)},children:`Reset`})})}),(0,A.jsx)(b,{children:(0,A.jsx)(`div`,{className:`grid gap-10 lg:grid-cols-2`,children:d.map(n=>{let r=n===`chrome`;return(0,A.jsx)(L,{target:n,enabled:r?e.blurChromeEnabled:e.blurCardsEnabled,onToggle:()=>t(r?{blurChromeEnabled:!e.blurChromeEnabled}:{blurCardsEnabled:!e.blurCardsEnabled}),clarity:r?e.blurChromeAmount:e.blurCardsAmount,onClarity:e=>t(r?{blurChromeAmount:e}:{blurCardsAmount:e}),depth:r?e.blurChromeDepth:e.blurCardsDepth,onDepth:e=>t(r?{blurChromeDepth:e}:{blurCardsDepth:e})},n)})})})]}),(0,A.jsxs)(S,{children:[(0,A.jsx)(x,{title:`Empty panels`,subtitle:`A dashed frame around a page that has nothing to show yet.`,icon:(0,A.jsx)(E,{size:16})}),(0,A.jsx)(b,{children:(0,A.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":e.emptyOutline,onClick:()=>t({emptyOutline:!e.emptyOutline}),className:`flex w-full items-center justify-between gap-6 rounded-card border border-inner-border bg-surface-2 px-7 py-6 text-left`,children:[(0,A.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,A.jsx)(`span`,{className:`text-caption font-semibold text-text-primary`,children:`Dashed border`}),(0,A.jsx)(`span`,{className:`text-badge text-text-tertiary`,children:`Off leaves the empty state sitting on the card.`})]}),(0,A.jsx)(`span`,{"aria-hidden":`true`,className:e.emptyOutline?`h-10 w-18 shrink-0 rounded-pill bg-accent p-1`:`h-10 w-18 shrink-0 rounded-pill bg-surface-active p-1`,children:(0,A.jsx)(`span`,{className:e.emptyOutline?`block size-8 translate-x-8 rounded-full bg-accent-foreground transition-transform`:`block size-8 rounded-full bg-text-secondary transition-transform`})})]})})]})]})}function P({settings:e,bytes:t,onBytes:n}){let[r,i]=(0,k.useState)(null),[a,o]=(0,k.useState)(null);if((0,k.useEffect)(()=>{if(!e.backgroundSet){i(u),o(`image`);return}let t=!0,r=null;return l().then(e=>{if(e){if(!t){URL.revokeObjectURL(e.url);return}r=e.url,i(e.url),o(e.kind),n(e.blob.size)}}).catch(()=>{}),()=>{t=!1,r&&URL.revokeObjectURL(r)}},[e.backgroundSet,n]),!r)return(0,A.jsx)(`div`,{className:`flex h-60 items-center justify-center rounded-card border border-dashed border-inner-border bg-surface-2 text-caption text-text-tertiary`,children:`No background yet. The console uses its plain surface.`});let s={objectFit:`cover`,objectPosition:`${50+e.backgroundX/2}% ${50+e.backgroundY/2}%`,transform:`scale(${e.backgroundScale/100})`,opacity:e.backgroundOpacity/100};return(0,A.jsxs)(`div`,{className:`relative h-75 overflow-hidden rounded-card border border-inner-border bg-surface-2`,children:[a===`video`?(0,A.jsx)(`video`,{src:r,muted:!0,playsInline:!0,preload:`metadata`,className:`size-full`,style:s}):(0,A.jsx)(`img`,{src:r,alt:``,className:`size-full`,style:s}),(0,A.jsxs)(`span`,{className:`absolute bottom-4 left-5 rounded-control bg-surface-1 px-4 py-1 text-micro text-text-secondary`,children:[a===`video`?`Video`:`Image`,t===null?``:` · ${M(t)}`,e.backgroundEnabled?``:` · hidden`]})]})}function F({settings:e,setSettings:t}){return(0,A.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,A.jsxs)(`label`,{className:`flex min-h-18 items-center justify-between gap-6 text-body font-semibold text-text-primary`,children:[(0,A.jsx)(`span`,{children:`Show background`}),(0,A.jsx)(C,{checked:e.backgroundEnabled,onChange:e=>t({backgroundEnabled:e}),"aria-label":`Show background`})]}),(0,A.jsxs)(`div`,{className:`grid gap-7 sm:grid-cols-2`,children:[(0,A.jsx)(I,{label:`Visibility`,value:e.backgroundOpacity,defaultValue:p.backgroundOpacity,min:0,max:100,unit:`%`,onChange:e=>t({backgroundOpacity:e})}),(0,A.jsx)(I,{label:`Blur`,value:e.backgroundBlur,defaultValue:p.backgroundBlur,min:0,max:100,unit:`%`,onChange:e=>t({backgroundBlur:e})}),(0,A.jsx)(I,{label:`Zoom`,value:e.backgroundScale,defaultValue:p.backgroundScale,min:100,max:180,unit:`%`,onChange:e=>t({backgroundScale:e})}),(0,A.jsx)(I,{label:`Shift horizontal`,value:e.backgroundX,defaultValue:p.backgroundX,min:-100,max:100,onChange:e=>t({backgroundX:e})}),(0,A.jsx)(I,{label:`Shift vertical`,value:e.backgroundY,defaultValue:p.backgroundY,min:-100,max:100,onChange:e=>t({backgroundY:e})})]})]})}function I({label:e,value:t,defaultValue:n,min:r,max:i,unit:a,onChange:o}){return(0,A.jsxs)(`label`,{className:`flex flex-col gap-2 text-caption text-text-secondary`,children:[(0,A.jsxs)(`span`,{className:`flex items-center justify-between`,children:[e,(0,A.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,A.jsxs)(`span`,{className:`font-mono tabular-nums text-badge text-text-tertiary`,children:[t,a??``]}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(n),disabled:t===n,"aria-label":`Reset ${e}`,title:`Reset ${e} to ${n}${a??``}`,className:`flex size-9 items-center justify-center rounded-control text-text-tertiary hover:bg-hover hover:text-text-primary disabled:pointer-events-none disabled:opacity-30`,children:(0,A.jsx)(c,{size:11})})]})]}),(0,A.jsx)(`input`,{type:`range`,min:r,max:i,value:t,onChange:e=>o(Number(e.target.value)),"aria-label":e,className:`blur-slider w-full h-11 m-0 border-0 rounded-pill cursor-pointer`,style:{"--fill":`${(t-r)/(i-r)*100}%`}})]})}function L({target:e,enabled:t,onToggle:n,clarity:r,onClarity:i,depth:a,onDepth:o}){let s=j[e]??j.cards;return(0,A.jsxs)(`div`,{className:`flex flex-col gap-8 rounded-card border border-inner-border bg-surface-2 p-8`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-5`,children:[(0,A.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-control bg-surface-1 text-text-secondary`,children:s.icon}),(0,A.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,A.jsx)(`span`,{className:`text-body font-semibold text-text-primary`,children:s.label}),(0,A.jsx)(`span`,{className:`text-micro text-text-tertiary`,children:s.description})]}),(0,A.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":`Toggle ${s.label} blur`,onClick:n,className:t?`h-10 w-18 shrink-0 rounded-pill bg-accent p-1`:`h-10 w-18 shrink-0 rounded-pill bg-surface-active p-1`,children:(0,A.jsx)(`span`,{className:t?`block size-8 translate-x-8 rounded-full bg-accent-foreground`:`block size-8 rounded-full bg-text-secondary`})})]}),(0,A.jsxs)(`div`,{className:t?`flex flex-col gap-6`:`flex flex-col gap-6 opacity-40`,children:[(0,A.jsxs)(`label`,{className:`flex flex-col gap-3 text-caption text-text-secondary`,children:[(0,A.jsxs)(`span`,{className:`flex items-center justify-between`,children:[`Clarity`,(0,A.jsxs)(`span`,{className:`font-mono text-badge tabular-nums text-text-tertiary`,children:[r,`%`]})]}),(0,A.jsx)(`input`,{type:`range`,min:0,max:100,value:r,disabled:!t,onChange:e=>i(Number(e.target.value)),"aria-label":`${s.label} clarity. How see-through the surface is.`,className:`blur-slider w-full h-11 m-0 border-0 rounded-pill cursor-pointer`,style:{"--fill":`${r}%`}}),(0,A.jsxs)(`span`,{className:`flex justify-between text-badge text-text-tertiary`,children:[(0,A.jsx)(`span`,{children:`See-through`}),(0,A.jsx)(`span`,{children:`Solid`})]})]}),(0,A.jsxs)(`label`,{className:`flex flex-col gap-3 text-caption text-text-secondary`,children:[(0,A.jsxs)(`span`,{className:`flex items-center justify-between`,children:[`Blur`,(0,A.jsxs)(`span`,{className:`font-mono text-badge tabular-nums text-text-tertiary`,children:[a,`%`]})]}),(0,A.jsx)(`input`,{type:`range`,min:0,max:100,value:a,disabled:!t,onChange:e=>o(Number(e.target.value)),"aria-label":`${s.label} blur. How blurred whatever is behind it looks.`,className:`blur-slider w-full h-11 m-0 border-0 rounded-pill cursor-pointer`,style:{"--fill":`${a}%`}}),(0,A.jsxs)(`span`,{className:`flex justify-between text-badge text-text-tertiary`,children:[(0,A.jsx)(`span`,{children:`Sharp`}),(0,A.jsx)(`span`,{children:`Blurred`})]})]})]})]})}export{N as default};
@@ -1 +1 @@
1
- import{o as e,r as t,t as n}from"./jsx-runtime-CXUMngI_.js";import{i as r}from"./terminal-C9mZ4Ugm.js";import{n as i,t as a}from"./toast-DKAdP2mo.js";import{n as o,r as s,t as c}from"./state-DHKdg-pm.js";import{t as l}from"./dialog-iocKA3jr.js";import{t as u}from"./rotate-ccw-CufcqITi.js";import{S as d,_ as f,w as p}from"./assert-Bwh6DJTK.js";import{a as m,t as h}from"./query-keys-ROf-g1Wi.js";import{t as g}from"./useMutation-DVmwOKU-.js";import{E as _,F as v,_ as y,n as b}from"./entry-C1Dn2nQu.js";import{t as x}from"./badge-BwmwEOgA.js";import{n as S}from"./inline-DCejSLlA.js";import{t as C}from"./layout-Bv-NxqZ5.js";async function w(e){return m(`/quota/overview`,e?{signal:e}:void 0)}function T(){return d({queryKey:h.quota.all,queryFn:e=>w(f(e)),staleTime:1/0,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnMount:!1,refetchOnWindowFocus:!1,placeholderData:e=>e})}function E(e){let t=p(),n=h.quota.account(e);return g({mutationFn:async()=>m(`/accounts/${encodeURIComponent(e)}/quota/refresh`,{method:`POST`}),onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:n,exact:!0}),t.invalidateQueries({queryKey:h.quota.all}),t.invalidateQueries({queryKey:h.providers.all})])}})}var D=100;function O(){let e=p();return g({mutationFn:async e=>{let t=[];for(let n=0;n<e.length;n+=D)t.push(e.slice(n,n+D));let n=await Promise.all(t.map(e=>m(`/quota/refresh`,{method:`POST`,body:JSON.stringify({accountIds:e})}))),r=n.flatMap(e=>e.failures);return{ok:r.length===0,queued:n.reduce((e,t)=>e+t.queued,0),succeeded:n.reduce((e,t)=>e+t.succeeded,0),failed:n.reduce((e,t)=>e+t.failed,0),failures:r}},onSuccess:async(t,n)=>{let r=new Set(t.failures.map(e=>e.accountId)),i=n.filter(e=>!r.has(e));await Promise.all([...i.map(t=>e.invalidateQueries({queryKey:h.quota.account(t),exact:!0})),e.invalidateQueries({queryKey:h.quota.all})])}})}function k(){let e=p();return g({mutationFn:({id:e,active:t})=>m(`/accounts/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify({active:t})}),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:h.quota.all}),e.invalidateQueries({queryKey:h.providers.all})])}})}function A(){let e=p();return g({mutationFn:async({ids:e,active:t})=>{e.length!==0&&await m(`/accounts/batch`,{method:`PATCH`,body:JSON.stringify({ids:e,active:t})})},onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:h.quota.all}),e.invalidateQueries({queryKey:h.providers.all})])}})}function j(){let e=p();return g({mutationFn:async e=>{await m(`/accounts/${encodeURIComponent(e)}`,{method:`DELETE`})},onSuccess:async(t,n)=>{e.removeQueries({queryKey:h.quota.account(n),exact:!0}),await Promise.all([e.invalidateQueries({queryKey:h.quota.all}),e.invalidateQueries({queryKey:h.providers.all})])}})}var M=new Set([`workbuddy`,`workbuddycn`,`cb`,`cbcn`]);function N(e){return M.has(e.trim().toLowerCase())}function P(e){let t=p();return g({mutationFn:async()=>{if(e.length===0)throw Error(`Select a provider first`);return m(`/quota/daily-growth`,{method:`POST`,body:JSON.stringify({providerId:e})})},onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:h.quota.all}),t.invalidateQueries({queryKey:h.providers.all})])}})}function F(e){let t=p();return g({mutationFn:async()=>{let t=await m(`/accounts/${encodeURIComponent(e)}/activity-report`,{method:`POST`}),n=t.message??`Activity reported`,r=await m(`/accounts/${encodeURIComponent(e)}/checkin`,{method:`POST`}),i=r.message??`Daily check-in done`;return{ok:t.ok,message:t.ok?`Report success · Check-in ${i}`:`Report failed: ${n} · Check-in ${i}`,checkin:r,report:t}},onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:h.quota.all}),t.invalidateQueries({queryKey:h.providers.all})])}})}var I=new Set([`codex`,`claude`,`anthropic`]);function L(e){return I.has(e.trim().toLowerCase())}function R(e,t){return d({queryKey:h.quota.resets(e),queryFn:({signal:t})=>m(`/accounts/${encodeURIComponent(e)}/resets`,t?{signal:t}:void 0),enabled:t,staleTime:3e4})}function z(e){let t=p();return g({mutationFn:async t=>m(`/accounts/${encodeURIComponent(e)}/reset`,{method:`POST`,body:JSON.stringify(t??{})}),onSettled:async()=>{await Promise.all([t.invalidateQueries({queryKey:h.quota.all}),t.invalidateQueries({queryKey:h.providers.all})])}})}var B=e(t(),1),V=n();function H(e){return e===`cooldown`}function U(e){return e===`active`?`ok`:e===`disabled`?`disabled`:`warn`}function W(e,t){return e?{title:`Enable static-token mode?`,message:`${t} will be used exactly as issued and will not be refreshed. Re-enable refresh before this token expires.`,confirmLabel:`Enable static mode`}:{title:`Re-enable credential refresh?`,message:`${t} will return to the OAuth refresh sweep. Use this only when a refresh token is available.`,confirmLabel:`Re-enable refresh`}}function G({summary:e,onClose:t}){let{providerId:n,accountId:d,title:f,status:p,errorCategory:m,errorMessage:h}=e,g=b(n,d),w=y(),T=g.data??[],E=_(),D=e.credentialKind===`oauth`||e.credentialMode===`jwt`||e.staticToken===!0,[O,k]=(0,B.useState)(e.staticToken===!0),[A,j]=(0,B.useState)(null);return(0,B.useEffect)(()=>k(e.staticToken===!0),[e.staticToken]),(0,V.jsx)(l,{open:!0,onClose:t,title:`Health & Error Log — ${f}`,size:`lg`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-7 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-5 rounded-control border border-inner-border bg-surface-2 py-5 px-7`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(S,{gap:`8px`,className:`flex-wrap`,children:[(0,V.jsx)(`span`,{className:`text-body font-semibold`,children:`Account status:`}),(0,V.jsx)(x,{tone:U(p),dot:!0,children:p.toUpperCase()}),m?(0,V.jsx)(x,{tone:`warn`,title:h??void 0,children:m}):null]}),h?(0,V.jsx)(`p`,{className:`text-badge text-red mt-2 wrap-anywhere`,children:h}):null]}),H(p)?(0,V.jsx)(i,{size:`sm`,variant:`secondary`,icon:(0,V.jsx)(u,{size:12,className:w.isPending?`animate-spin`:``}),disabled:w.isPending,onClick:()=>w.mutate({providerId:n,accountId:d},{onSuccess:()=>void g.refetch()}),children:w.isPending?`Recovering...`:`Recover Now`}):null]}),D?(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-6 rounded-control border border-inner-border bg-surface-2 py-5 px-7`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-caption font-semibold`,children:`Credential management`}),(0,V.jsx)(`div`,{className:`text-badge text-text-tertiary`,children:O?`Static mode: no refresh request will be sent.`:`OAuth refresh is enabled for this account.`})]}),(0,V.jsx)(i,{size:`sm`,variant:O?`primary`:`secondary`,disabled:E.isPending,onClick:()=>j(!O),children:O?`Static · no refresh`:`Enable static mode`})]}):null,(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`h4`,{className:`text-caption font-semibold text-text-secondary mb-4`,children:[`Transition Events & Audit (`,T.length,`)`]}),g.isPending?(0,V.jsx)(s,{label:`Loading health events...`}):g.isError?(0,V.jsx)(o,{message:`Failed to load health events`,onRetry:()=>void g.refetch()}):T.length===0?(0,V.jsx)(c,{title:`No health events recorded`,message:e.emptyMessage,icon:(0,V.jsx)(r,{size:20})}):(0,V.jsx)(`div`,{className:`rounded-inset border border-inner-border`,children:(0,V.jsx)(C,{maxHeight:480,scrollRegion:!0,headers:[`Timestamp`,`From → To`,`Model`,`Category`,`Reason / Details`],children:T.map(e=>(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`td`,{className:`text-badge text-text-tertiary whitespace-nowrap`,children:new Date(e.createdAt).toLocaleString()}),(0,V.jsxs)(`td`,{className:`whitespace-nowrap`,children:[(0,V.jsxs)(`span`,{className:`text-badge text-text-secondary`,children:[e.fromStatus??`new`,` →`,` `]}),(0,V.jsx)(x,{tone:U(e.toStatus),children:e.toStatus})]}),(0,V.jsx)(`td`,{className:`font-mono tabular-nums text-badge text-text-secondary wrap-anywhere`,children:e.modelId??`—`}),(0,V.jsx)(`td`,{className:`font-mono tabular-nums text-badge text-text-secondary`,children:e.errorCategory??`—`}),(0,V.jsx)(`td`,{className:`text-badge text-text-primary min-w-110 max-w-260 wrap-anywhere`,children:e.reason??`—`})]},e.id))})})]}),(0,V.jsx)(v,{open:A!==null,onClose:()=>j(null),onConfirm:()=>{let e=A===!0;E.mutate({providerId:n,accountId:d,request:{staticToken:e}},{onSuccess:()=>{k(e),j(null),a.success(e?`Static mode enabled`:`Credential refresh re-enabled`,f),g.refetch()},onError:e=>a.error(`Credential update failed`,e instanceof Error?e.message:`Unable to update credential mode`)})},title:W(A===!0,f).title,message:W(A===!0,f).message,confirmLabel:W(A===!0,f).confirmLabel,cancelLabel:`Cancel`}),(0,V.jsx)(S,{justify:`flex-end`,gap:`0px`,children:(0,V.jsx)(i,{variant:`secondary`,size:`sm`,onClick:t,children:`Close`})})]})})}export{j as a,O as c,F as d,P as f,R as i,A as l,N as n,T as o,k as p,L as r,E as s,G as t,z as u};
1
+ import{o as e,r as t,t as n}from"./jsx-runtime-CXUMngI_.js";import{i as r}from"./terminal-C9mZ4Ugm.js";import{n as i,t as a}from"./toast-DKAdP2mo.js";import{n as o,r as s,t as c}from"./state-DHKdg-pm.js";import{t as l}from"./dialog-iocKA3jr.js";import{t as u}from"./rotate-ccw-CufcqITi.js";import{S as d,_ as f,w as p}from"./assert-Bwh6DJTK.js";import{a as m,t as h}from"./query-keys-ROf-g1Wi.js";import{t as g}from"./useMutation-DVmwOKU-.js";import{E as _,F as v,_ as y,n as b}from"./entry-8jVcj7OO.js";import{t as x}from"./badge-BwmwEOgA.js";import{n as S}from"./inline-DCejSLlA.js";import{t as C}from"./layout-Bv-NxqZ5.js";async function w(e){return m(`/quota/overview`,e?{signal:e}:void 0)}function T(){return d({queryKey:h.quota.all,queryFn:e=>w(f(e)),staleTime:1/0,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnMount:!1,refetchOnWindowFocus:!1,placeholderData:e=>e})}function E(e){let t=p(),n=h.quota.account(e);return g({mutationFn:async()=>m(`/accounts/${encodeURIComponent(e)}/quota/refresh`,{method:`POST`}),onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:n,exact:!0}),t.invalidateQueries({queryKey:h.quota.all}),t.invalidateQueries({queryKey:h.providers.all})])}})}var D=100;function O(){let e=p();return g({mutationFn:async e=>{let t=[];for(let n=0;n<e.length;n+=D)t.push(e.slice(n,n+D));let n=await Promise.all(t.map(e=>m(`/quota/refresh`,{method:`POST`,body:JSON.stringify({accountIds:e})}))),r=n.flatMap(e=>e.failures);return{ok:r.length===0,queued:n.reduce((e,t)=>e+t.queued,0),succeeded:n.reduce((e,t)=>e+t.succeeded,0),failed:n.reduce((e,t)=>e+t.failed,0),failures:r}},onSuccess:async(t,n)=>{let r=new Set(t.failures.map(e=>e.accountId)),i=n.filter(e=>!r.has(e));await Promise.all([...i.map(t=>e.invalidateQueries({queryKey:h.quota.account(t),exact:!0})),e.invalidateQueries({queryKey:h.quota.all})])}})}function k(){let e=p();return g({mutationFn:({id:e,active:t})=>m(`/accounts/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify({active:t})}),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:h.quota.all}),e.invalidateQueries({queryKey:h.providers.all})])}})}function A(){let e=p();return g({mutationFn:async({ids:e,active:t})=>{e.length!==0&&await m(`/accounts/batch`,{method:`PATCH`,body:JSON.stringify({ids:e,active:t})})},onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:h.quota.all}),e.invalidateQueries({queryKey:h.providers.all})])}})}function j(){let e=p();return g({mutationFn:async e=>{await m(`/accounts/${encodeURIComponent(e)}`,{method:`DELETE`})},onSuccess:async(t,n)=>{e.removeQueries({queryKey:h.quota.account(n),exact:!0}),await Promise.all([e.invalidateQueries({queryKey:h.quota.all}),e.invalidateQueries({queryKey:h.providers.all})])}})}var M=new Set([`workbuddy`,`workbuddycn`,`cb`,`cbcn`]);function N(e){return M.has(e.trim().toLowerCase())}function P(e){let t=p();return g({mutationFn:async()=>{if(e.length===0)throw Error(`Select a provider first`);return m(`/quota/daily-growth`,{method:`POST`,body:JSON.stringify({providerId:e})})},onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:h.quota.all}),t.invalidateQueries({queryKey:h.providers.all})])}})}function F(e){let t=p();return g({mutationFn:async()=>{let t=await m(`/accounts/${encodeURIComponent(e)}/activity-report`,{method:`POST`}),n=t.message??`Activity reported`,r=await m(`/accounts/${encodeURIComponent(e)}/checkin`,{method:`POST`}),i=r.message??`Daily check-in done`;return{ok:t.ok,message:t.ok?`Report success · Check-in ${i}`:`Report failed: ${n} · Check-in ${i}`,checkin:r,report:t}},onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:h.quota.all}),t.invalidateQueries({queryKey:h.providers.all})])}})}var I=new Set([`codex`,`claude`,`anthropic`]);function L(e){return I.has(e.trim().toLowerCase())}function R(e,t){return d({queryKey:h.quota.resets(e),queryFn:({signal:t})=>m(`/accounts/${encodeURIComponent(e)}/resets`,t?{signal:t}:void 0),enabled:t,staleTime:3e4})}function z(e){let t=p();return g({mutationFn:async t=>m(`/accounts/${encodeURIComponent(e)}/reset`,{method:`POST`,body:JSON.stringify(t??{})}),onSettled:async()=>{await Promise.all([t.invalidateQueries({queryKey:h.quota.all}),t.invalidateQueries({queryKey:h.providers.all})])}})}var B=e(t(),1),V=n();function H(e){return e===`cooldown`}function U(e){return e===`active`?`ok`:e===`disabled`?`disabled`:`warn`}function W(e,t){return e?{title:`Enable static-token mode?`,message:`${t} will be used exactly as issued and will not be refreshed. Re-enable refresh before this token expires.`,confirmLabel:`Enable static mode`}:{title:`Re-enable credential refresh?`,message:`${t} will return to the OAuth refresh sweep. Use this only when a refresh token is available.`,confirmLabel:`Re-enable refresh`}}function G({summary:e,onClose:t}){let{providerId:n,accountId:d,title:f,status:p,errorCategory:m,errorMessage:h}=e,g=b(n,d),w=y(),T=g.data??[],E=_(),D=e.credentialKind===`oauth`||e.credentialMode===`jwt`||e.staticToken===!0,[O,k]=(0,B.useState)(e.staticToken===!0),[A,j]=(0,B.useState)(null);return(0,B.useEffect)(()=>k(e.staticToken===!0),[e.staticToken]),(0,V.jsx)(l,{open:!0,onClose:t,title:`Health & Error Log — ${f}`,size:`lg`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-7 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-5 rounded-control border border-inner-border bg-surface-2 py-5 px-7`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(S,{gap:`8px`,className:`flex-wrap`,children:[(0,V.jsx)(`span`,{className:`text-body font-semibold`,children:`Account status:`}),(0,V.jsx)(x,{tone:U(p),dot:!0,children:p.toUpperCase()}),m?(0,V.jsx)(x,{tone:`warn`,title:h??void 0,children:m}):null]}),h?(0,V.jsx)(`p`,{className:`text-badge text-red mt-2 wrap-anywhere`,children:h}):null]}),H(p)?(0,V.jsx)(i,{size:`sm`,variant:`secondary`,icon:(0,V.jsx)(u,{size:12,className:w.isPending?`animate-spin`:``}),disabled:w.isPending,onClick:()=>w.mutate({providerId:n,accountId:d},{onSuccess:()=>void g.refetch()}),children:w.isPending?`Recovering...`:`Recover Now`}):null]}),D?(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-6 rounded-control border border-inner-border bg-surface-2 py-5 px-7`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-caption font-semibold`,children:`Credential management`}),(0,V.jsx)(`div`,{className:`text-badge text-text-tertiary`,children:O?`Static mode: no refresh request will be sent.`:`OAuth refresh is enabled for this account.`})]}),(0,V.jsx)(i,{size:`sm`,variant:O?`primary`:`secondary`,disabled:E.isPending,onClick:()=>j(!O),children:O?`Static · no refresh`:`Enable static mode`})]}):null,(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`h4`,{className:`text-caption font-semibold text-text-secondary mb-4`,children:[`Transition Events & Audit (`,T.length,`)`]}),g.isPending?(0,V.jsx)(s,{label:`Loading health events...`}):g.isError?(0,V.jsx)(o,{message:`Failed to load health events`,onRetry:()=>void g.refetch()}):T.length===0?(0,V.jsx)(c,{title:`No health events recorded`,message:e.emptyMessage,icon:(0,V.jsx)(r,{size:20})}):(0,V.jsx)(`div`,{className:`rounded-inset border border-inner-border`,children:(0,V.jsx)(C,{maxHeight:480,scrollRegion:!0,headers:[`Timestamp`,`From → To`,`Model`,`Category`,`Reason / Details`],children:T.map(e=>(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`td`,{className:`text-badge text-text-tertiary whitespace-nowrap`,children:new Date(e.createdAt).toLocaleString()}),(0,V.jsxs)(`td`,{className:`whitespace-nowrap`,children:[(0,V.jsxs)(`span`,{className:`text-badge text-text-secondary`,children:[e.fromStatus??`new`,` →`,` `]}),(0,V.jsx)(x,{tone:U(e.toStatus),children:e.toStatus})]}),(0,V.jsx)(`td`,{className:`font-mono tabular-nums text-badge text-text-secondary wrap-anywhere`,children:e.modelId??`—`}),(0,V.jsx)(`td`,{className:`font-mono tabular-nums text-badge text-text-secondary`,children:e.errorCategory??`—`}),(0,V.jsx)(`td`,{className:`text-badge text-text-primary min-w-110 max-w-260 wrap-anywhere`,children:e.reason??`—`})]},e.id))})})]}),(0,V.jsx)(v,{open:A!==null,onClose:()=>j(null),onConfirm:()=>{let e=A===!0;E.mutate({providerId:n,accountId:d,request:{staticToken:e}},{onSuccess:()=>{k(e),j(null),a.success(e?`Static mode enabled`:`Credential refresh re-enabled`,f),g.refetch()},onError:e=>a.error(`Credential update failed`,e instanceof Error?e.message:`Unable to update credential mode`)})},title:W(A===!0,f).title,message:W(A===!0,f).message,confirmLabel:W(A===!0,f).confirmLabel,cancelLabel:`Cancel`}),(0,V.jsx)(S,{justify:`flex-end`,gap:`0px`,children:(0,V.jsx)(i,{variant:`secondary`,size:`sm`,onClick:t,children:`Close`})})]})})}export{j as a,O as c,F as d,P as f,R as i,A as l,N as n,T as o,k as p,L as r,E as s,G as t,z as u};
@@ -1 +1 @@
1
- import{o as e,r as t,t as n}from"./jsx-runtime-CXUMngI_.js";import{n as r}from"./toast-DKAdP2mo.js";import{t as i}from"./log-in-BmRjy60c.js";import{a,t as o}from"./query-keys-ROf-g1Wi.js";import{P as s,Y as c,Z as l}from"./entry-C1Dn2nQu.js";import{n as u}from"./input-Bn4_kNav.js";var d=e(t(),1),f=n();function p(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/`}function m(){let e=c(),[t]=l(),[n,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(``),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(!1),[x,S]=(0,d.useState)(!0);return(0,d.useEffect)(()=>{let t=!0;return a(`/auth/first-boot`).then(n=>{if(t){if(n.requires_setup){e(`/setup`,{replace:!0});return}S(!1)}}).catch(()=>{t&&S(!1)}),()=>{t=!1}},[e]),x?(0,f.jsx)(`main`,{className:`auth-viewport`,children:(0,f.jsx)(`div`,{className:`card-solid auth-window`,children:(0,f.jsxs)(`div`,{className:`auth-header`,children:[(0,f.jsx)(`div`,{className:`auth-logo`,"aria-hidden":`true`}),(0,f.jsx)(`h1`,{className:`auth-title`,children:`Cartethyia Console`}),(0,f.jsx)(`p`,{className:`auth-desc`,children:`Checking console setup...`})]})})}):(0,f.jsx)(`main`,{className:`auth-viewport`,children:(0,f.jsxs)(`div`,{className:`card-solid auth-window`,children:[(0,f.jsxs)(`div`,{className:`auth-header`,children:[(0,f.jsx)(`div`,{className:`auth-logo`,"aria-hidden":`true`}),(0,f.jsx)(`h1`,{className:`auth-title`,children:`Cartethyia Console`}),(0,f.jsx)(`p`,{className:`auth-desc`,children:`Sign in to manage AI Gateway routing and providers`})]}),(0,f.jsxs)(`form`,{onSubmit:async r=>{r.preventDefault(),b(!0),v(null);try{let r=await a(`/auth/login`,{method:`POST`,body:JSON.stringify({username:n.trim(),password:h})});if(r.status!==`success`){if(r.requires_setup){e(`/setup`,{replace:!0});return}g(``),v(r.message??`Authentication failed. Please check your credentials.`);return}s.removeQueries({queryKey:o.session.current}),e(r.requires_setup?`/setup`:p(t.get(`returnTo`)),{replace:!0})}catch(e){if(e&&typeof e==`object`&&`message`in e){let t=e.message;if(typeof t==`string`){g(``),v(t);return}}v(`An unexpected network error occurred.`)}finally{b(!1)}},className:`flex flex-col gap-7`,children:[(0,f.jsx)(u,{label:`Username`,id:`login-username`,value:n,onChange:e=>m(e.target.value),required:!0,autoComplete:`username`,placeholder:`admin`}),(0,f.jsx)(u,{label:`Password`,id:`login-password`,type:`password`,value:h,onChange:e=>g(e.target.value),required:!0,autoComplete:`current-password`}),_?(0,f.jsx)(`div`,{className:`py-5 px-7 rounded-control bg-red-soft text-red text-caption font-medium`,role:`alert`,children:_}):null,(0,f.jsx)(r,{variant:`primary`,type:`submit`,disabled:y,className:`w-full mt-3 h-20`,icon:(0,f.jsx)(i,{size:15}),children:y?`Authenticating…`:`Sign In`})]})]})})}export{m as default};
1
+ import{o as e,r as t,t as n}from"./jsx-runtime-CXUMngI_.js";import{n as r}from"./toast-DKAdP2mo.js";import{t as i}from"./log-in-BmRjy60c.js";import{a,t as o}from"./query-keys-ROf-g1Wi.js";import{P as s,Y as c,Z as l}from"./entry-8jVcj7OO.js";import{n as u}from"./input-Bn4_kNav.js";var d=e(t(),1),f=n();function p(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/`}function m(){let e=c(),[t]=l(),[n,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(``),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(!1),[x,S]=(0,d.useState)(!0);return(0,d.useEffect)(()=>{let t=!0;return a(`/auth/first-boot`).then(n=>{if(t){if(n.requires_setup){e(`/setup`,{replace:!0});return}S(!1)}}).catch(()=>{t&&S(!1)}),()=>{t=!1}},[e]),x?(0,f.jsx)(`main`,{className:`auth-viewport`,children:(0,f.jsx)(`div`,{className:`card-solid auth-window`,children:(0,f.jsxs)(`div`,{className:`auth-header`,children:[(0,f.jsx)(`div`,{className:`auth-logo`,"aria-hidden":`true`}),(0,f.jsx)(`h1`,{className:`auth-title`,children:`Cartethyia Console`}),(0,f.jsx)(`p`,{className:`auth-desc`,children:`Checking console setup...`})]})})}):(0,f.jsx)(`main`,{className:`auth-viewport`,children:(0,f.jsxs)(`div`,{className:`card-solid auth-window`,children:[(0,f.jsxs)(`div`,{className:`auth-header`,children:[(0,f.jsx)(`div`,{className:`auth-logo`,"aria-hidden":`true`}),(0,f.jsx)(`h1`,{className:`auth-title`,children:`Cartethyia Console`}),(0,f.jsx)(`p`,{className:`auth-desc`,children:`Sign in to manage AI Gateway routing and providers`})]}),(0,f.jsxs)(`form`,{onSubmit:async r=>{r.preventDefault(),b(!0),v(null);try{let r=await a(`/auth/login`,{method:`POST`,body:JSON.stringify({username:n.trim(),password:h})});if(r.status!==`success`){if(r.requires_setup){e(`/setup`,{replace:!0});return}g(``),v(r.message??`Authentication failed. Please check your credentials.`);return}s.removeQueries({queryKey:o.session.current}),e(r.requires_setup?`/setup`:p(t.get(`returnTo`)),{replace:!0})}catch(e){if(e&&typeof e==`object`&&`message`in e){let t=e.message;if(typeof t==`string`){g(``),v(t);return}}v(`An unexpected network error occurred.`)}finally{b(!1)}},className:`flex flex-col gap-7`,children:[(0,f.jsx)(u,{label:`Username`,id:`login-username`,value:n,onChange:e=>m(e.target.value),required:!0,autoComplete:`username`,placeholder:`admin`}),(0,f.jsx)(u,{label:`Password`,id:`login-password`,type:`password`,value:h,onChange:e=>g(e.target.value),required:!0,autoComplete:`current-password`}),_?(0,f.jsx)(`div`,{className:`py-5 px-7 rounded-control bg-red-soft text-red text-caption font-medium`,role:`alert`,children:_}):null,(0,f.jsx)(r,{variant:`primary`,type:`submit`,disabled:y,className:`w-full mt-3 h-20`,icon:(0,f.jsx)(i,{size:15}),children:y?`Authenticating…`:`Sign In`})]})]})})}export{m as default};