@kaitranntt/ccs 7.65.2-dev.1 → 7.65.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.
- package/dist/ui/assets/{accounts-Dh95PibK.js → accounts-BHEYnq6b.js} +1 -1
- package/dist/ui/assets/{alert-dialog-C5RdUHi9.js → alert-dialog-D0EFRcfB.js} +1 -1
- package/dist/ui/assets/{api-C0ROFLme.js → api-DhM3BYXr.js} +1 -1
- package/dist/ui/assets/{auth-section-M2azTP3G.js → auth-section-DVp8FQGm.js} +1 -1
- package/dist/ui/assets/{backups-section-DIDUVa0t.js → backups-section-CRo0NZkA.js} +1 -1
- package/dist/ui/assets/{channels-D_5uerEp.js → channels-uZ_9CBqO.js} +1 -1
- package/dist/ui/assets/{checkbox-CgMg7fDH.js → checkbox-32DNqW_Q.js} +1 -1
- package/dist/ui/assets/{claude-extension-DA9wMzPz.js → claude-extension-BfXlz5gV.js} +1 -1
- package/dist/ui/assets/{cliproxy-4yUL1fQw.js → cliproxy-DjNY9H-U.js} +1 -1
- package/dist/ui/assets/{cliproxy-ai-providers-DedMcdcc.js → cliproxy-ai-providers-5SHLMHiy.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-B0kwxgNi.js → cliproxy-control-panel-Zax_m1AC.js} +1 -1
- package/dist/ui/assets/{codex-CAWw4ZNl.js → codex-CRUSpjsu.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-Ds0PYz2R.js → confirm-dialog-DVf5ZmCZ.js} +1 -1
- package/dist/ui/assets/{copilot-m6i00mFy.js → copilot-BZrihl_Z.js} +1 -1
- package/dist/ui/assets/{cursor-COeD0Dgq.js → cursor-BP4nbEk_.js} +1 -1
- package/dist/ui/assets/{droid-CznUyiRx.js → droid-BG92rdM2.js} +1 -1
- package/dist/ui/assets/{globalenv-section-FgK1eGWk.js → globalenv-section-Cf6dKgSf.js} +1 -1
- package/dist/ui/assets/{health-Cpu6bD6K.js → health-BTy1UZs3.js} +1 -1
- package/dist/ui/assets/{index-DgnxlKNk.js → index-BVeN0dIB.js} +1 -1
- package/dist/ui/assets/index-Corv1lSo.js +69 -0
- package/dist/ui/assets/{index-rTSyskt3.js → index-DHrTq-0n.js} +1 -1
- package/dist/ui/assets/{index-Bhz6T039.js → index-DuRYaONg.js} +1 -1
- package/dist/ui/assets/{index-C7sG68Mi.js → index-N2ZSJurX.js} +1 -1
- package/dist/ui/assets/{index-DampXntj.js → index-wg7UtkFv.js} +1 -1
- package/dist/ui/assets/{masked-input-B_l4FMkE.js → masked-input-DX9bedLy.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-C7wSbfPC.js → proxy-status-widget-DVDMuZK5.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-CViWFt6t.js → raw-json-settings-editor-panel-Dkt5E6Z_.js} +1 -1
- package/dist/ui/assets/{searchable-select-7-yJbbw2.js → searchable-select-BP3Q1-Yn.js} +1 -1
- package/dist/ui/assets/{separator-DApM4Wa5.js → separator-BLGGUlh9.js} +1 -1
- package/dist/ui/assets/{shared-Blmm7sMd.js → shared-G0XRyLig.js} +1 -1
- package/dist/ui/assets/{table-BwM4zncv.js → table-B4lRrWC-.js} +1 -1
- package/dist/ui/assets/{updates-DJ0ofB67.js → updates--A2Sdo7N.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/scripts/github/normalize-ai-review-output.mjs +95 -33
- package/dist/ui/assets/index-CcKb4PL_.js +0 -69
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-C98W0NRG.js";import{r as Q}from"./react-vendor-CNOkPC89.js";import{t as j}from"./notifications-B2HqRBj7.js";import{b2 as X,b3 as ye,C as b,j as v,k as y,B as P,b as N,r as H,s as q,t as W,v as Y,w as k,I as oe,a as Ne,b9 as we,ba as ne,bb as ke,Q as Se,R as Pe,U,V,n as T,b4 as Ee,c as Ce}from"./index-CcKb4PL_.js";import{a as Te,u as ae,b as Ae}from"./tanstack-CfKik0yL.js";import{a as Re}from"./raw-json-settings-editor-panel-CViWFt6t.js";import{aS as _e,ar as De,J as Oe,L as Me,S as Be,aR as Fe,w as Le,D as Ie,T as Ke,aa as Ue,aG as Ve,o as ie}from"./icons-CeH5899d.js";import{S as A}from"./separator-DApM4Wa5.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function $e(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{settings:null,parseError:"JSON root must be an object."}:{settings:r,parseError:null}}catch(r){return{settings:null,parseError:r.message}}}async function ze(){const s=await fetch(X("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function Je(){const s=await fetch(X("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Qe(s){const r=await fetch(X("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new ye("Droid raw settings changed externally");if(!r.ok){const n=await r.json().catch(()=>null);throw new Error(n?.error||"Failed to save Droid raw settings")}return r.json()}function He(){const s=Te(),r=ae({queryKey:["droid-diagnostics"],queryFn:ze,refetchInterval:1e4}),n=ae({queryKey:["droid-raw-settings"],queryFn:Je}),o=Ae({mutationFn:Qe,onSuccess:(d,l)=>{s.setQueryData(["droid-raw-settings"],t=>{const a=t?.path??"~/.factory/settings.json",u=t?.resolvedPath??a,x=$e(l.rawText);return{path:a,resolvedPath:u,exists:!0,mtime:d.mtime,rawText:l.rawText,settings:x.settings,parseError:x.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return Q.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawSettings:n.data,rawSettingsLoading:n.isLoading,rawSettingsError:n.error,refetchRawSettings:n.refetch,saveRawSettings:o.mutate,saveRawSettingsAsync:o.mutateAsync,isSavingRawSettings:o.isPending}),[r.data,r.isLoading,r.error,r.refetch,n.data,n.isLoading,n.error,n.refetch,o.mutate,o.mutateAsync,o.isPending])}const qe=["customModels","custom_models"],We={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},Ye=["low","medium","high","max","xhigh"];function h(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function p(s){return typeof s=="string"&&s.trim()?s.trim():null}function _(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function G(s){if(!s)return"unknown";const r=s.toLowerCase();return r==="anthropic"?"anthropic":r==="openai"?"openai":r==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function Ge(s,r,n){return`${s}:${r}:${encodeURIComponent(String(n))}`}function Xe(s){const r=s.indexOf(":"),n=s.indexOf(":",r+1);if(r<=0||n<=r+1)return null;const o=s.slice(0,r),d=s.slice(r+1,n),l=s.slice(n+1);if(o!=="customModels"&&o!=="custom_models"||d!=="array"&&d!=="object")return null;const t=decodeURIComponent(l);if(d==="array"){const a=Number.parseInt(t,10);return!Number.isInteger(a)||a<0?null:{rootKey:o,locationType:d,locationKey:a}}return{rootKey:o,locationType:d,locationKey:t}}function Ze(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function es(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function le(s){return JSON.parse(JSON.stringify(s))}function ss(s){const r=[];for(const n of qe){const o=s[n];if(Array.isArray(o)){o.forEach((d,l)=>{h(d)&&r.push({rootKey:n,locationType:"array",locationKey:l,entry:d})});continue}if(h(o))for(const[d,l]of Object.entries(o))h(l)&&r.push({rootKey:n,locationType:"object",locationKey:d,entry:l})}return r}function de(s,r){const n=Xe(r);if(!n)return null;const o=s[n.rootKey];if(n.locationType==="array"){if(!Array.isArray(o))return null;const t=o[n.locationKey];if(!h(t))return null;const a=p(t.provider);return{entry:t,providerKind:G(a)}}if(!h(o))return null;const d=o[n.locationKey];if(!h(d))return null;const l=p(d.provider);return{entry:d,providerKind:G(l)}}function rs(s,r){const n=r.extraArgs??r.extra_args,o=h(n)?n:null;if(!o)return{effort:null,anthropicBudgetTokens:null};const d=p(o.reasoning_effort)??p(o.reasoningEffort),l=h(o.reasoning)?o.reasoning:null,t=l?p(l.effort):null,a=h(o.thinking)?o.thinking:null,u=a?p(a.type):null,x=a?_(a.budget_tokens)??_(a.budgetTokens):null;return s==="openai"?{effort:t??d,anthropicBudgetTokens:null}:s==="anthropic"?u==="enabled"?{effort:Ze(x)??"high",anthropicBudgetTokens:x}:{effort:t??d,anthropicBudgetTokens:x}:{effort:d??t,anthropicBudgetTokens:null}}function ts(s){if(!s)return null;const r=s.trim().toLowerCase();return!r||r==="default"||r==="unset"||r==="off"||r==="none"||r==="disabled"?null:r}function ce(s){const r=es(s),n=s[r],o=h(n)?{...n}:{};return{extraArgsKey:r,extraArgs:o}}function ue(s,r,n){if(Object.keys(n).length===0){delete s[r];return}s[r]=n}function ns(s){return ss(s).map(({rootKey:r,locationType:n,locationKey:o,entry:d})=>{const l=p(d.displayName)??p(d.model_display_name)??"Unnamed model",t=p(d.model)??"",a=p(d.provider)??"unknown",u=G(a),x=rs(u,d);return{id:Ge(r,n,o),rootKey:r,locationType:n,locationKey:o,displayName:l,model:t,provider:a,providerKind:u,effort:x.effort,anthropicBudgetTokens:x.anthropicBudgetTokens}})}function as(s,r,n){const o=le(s),d=de(o,r);if(!d)return null;const l=ts(n),{extraArgsKey:t,extraArgs:a}=ce(d.entry);if(d.providerKind==="openai")if(delete a.reasoning_effort,delete a.reasoningEffort,!l)delete a.reasoning;else{const u=h(a.reasoning)?a.reasoning:{};a.reasoning={...u,effort:l}}else if(d.providerKind==="anthropic")if(delete a.reasoning_effort,delete a.reasoningEffort,delete a.reasoning,!l)delete a.thinking;else{const u=h(a.thinking)?{...a.thinking}:{},x=_(u.budget_tokens)??_(u.budgetTokens);delete u.budgetTokens,a.thinking={...u,type:"enabled",budget_tokens:x??We[l]??3e4}}else delete a.reasoning,delete a.reasoningEffort,l?a.reasoning_effort=l:delete a.reasoning_effort;return ue(d.entry,t,a),o}function is(s,r,n){const o=le(s),d=de(o,r);if(!d||d.providerKind!=="anthropic")return null;const{extraArgsKey:l,extraArgs:t}=ce(d.entry),a=h(t.thinking)?{...t.thinking}:{};if(a.type="enabled",n===null)delete a.budget_tokens,delete a.budgetTokens;else{const u=Math.max(1024,Math.floor(n));a.budget_tokens=u,delete a.budgetTokens}return t.thinking=a,ue(d.entry,l,t),o}const $="__unset__";function os(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function ls({models:s,disabled:r,disabledReason:n,onEffortChange:o,onAnthropicBudgetChange:d}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"BYOK Reasoning / Thinking",e.jsx(P,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(l=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:l.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:l.model||"(missing model id)"})]}),e.jsx(P,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:l.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Reasoning Effort"}),e.jsxs(H,{value:l.effort??$,onValueChange:t=>o(l.id,t===$?null:t),disabled:r,children:[e.jsx(q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:$,children:"Use provider default"}),Ye.map(t=>e.jsx(k,{value:t,children:t},t))]})]})]}),l.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Thinking Budget Tokens"}),e.jsx(oe,{type:"number",min:1024,step:1024,value:l.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:r,onChange:t=>{const a=t.target.value.trim();if(!a){d(l.id,null);return}const u=Number.parseInt(a,10);Number.isFinite(u)&&d(l.id,Math.max(1024,u))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:os(l)})]},l.id))})]})]})}const C="__unset__",ds=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],cs=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],us=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function ms(s){return s===!0?"true":s===!1?"false":C}function xs(s){return s==="true"?!0:s==="false"?!1:null}function gs({values:s,disabled:r,disabledReason:n,onEnumSettingChange:o,onBooleanSettingChange:d,onNumberSettingChange:l}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),"Quick Settings",e.jsx(P,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[ds.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(H,{value:s[t.key]??C,onValueChange:a=>o(t.key,a===C?null:a),disabled:r,children:[e.jsx(q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:C,children:"Use default"}),t.options.map(a=>e.jsx(k,{value:a.value,children:a.label},a.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.description})]},t.key)),us.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsx(oe,{type:"number",min:t.min,step:t.step,value:s[t.key]??"",onChange:a=>{const u=a.target.value.trim();if(!u){l(t.key,null);return}const x=Number.parseInt(u,10);Number.isFinite(x)&&l(t.key,Math.max(t.min,x))},className:"h-8 text-xs",disabled:r})]},t.key)),cs.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(H,{value:ms(s[t.key]),onValueChange:a=>d(t.key,xs(a)),disabled:r,children:[e.jsx(q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:C,children:"Use default"}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},t.key))]})]})]})}const fs=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],hs=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function ps(s){const r=/https?:\/\/[^\s)]+/g,n=[];let o=0,d;for(;(d=r.exec(s))!==null;){const[l]=d,t=d.index;t>o&&n.push(s.slice(o,t)),n.push(e.jsx("a",{href:l,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:l},`${l}-${t}`)),o=t+l.length}return o<s.length&&n.push(s.slice(o)),n.length>0?n:[s]}function js(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function bs(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function vs(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:r}}catch(r){return{valid:!1,error:r.message}}}function z(s){return typeof s=="string"?s:null}function J(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function R(s){return typeof s=="boolean"?s:null}function g({label:s,value:r,mono:n=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:Ce("text-right break-all",n&&"font-mono text-xs"),children:r})]})}function _s(){const{t:s}=Ne(),{diagnostics:r,diagnosticsLoading:n,diagnosticsError:o,refetchDiagnostics:d,rawSettings:l,rawSettingsLoading:t,refetchRawSettings:a,saveRawSettingsAsync:u,isSavingRawSettings:x}=He(),[D,O]=Q.useState(null),M=l?.rawText??"{}",B=D??M,Z=D!==null&&D!==M,c=vs(B),F=c.valid?{valid:!0}:{valid:!1,error:c.error},ee=m=>{if(m===M){O(null);return}O(m)},L=m=>{ee(JSON.stringify(m,null,2)+`
|
|
1
|
+
import{j as e}from"./radix-ui-C98W0NRG.js";import{r as Q}from"./react-vendor-CNOkPC89.js";import{t as j}from"./notifications-B2HqRBj7.js";import{b2 as X,b3 as ye,C as b,j as v,k as y,B as P,b as N,r as H,s as q,t as W,v as Y,w as k,I as oe,a as Ne,b9 as we,ba as ne,bb as ke,Q as Se,R as Pe,U,V,n as T,b4 as Ee,c as Ce}from"./index-Corv1lSo.js";import{a as Te,u as ae,b as Ae}from"./tanstack-CfKik0yL.js";import{a as Re}from"./raw-json-settings-editor-panel-Dkt5E6Z_.js";import{aS as _e,ar as De,J as Oe,L as Me,S as Be,aR as Fe,w as Le,D as Ie,T as Ke,aa as Ue,aG as Ve,o as ie}from"./icons-CeH5899d.js";import{S as A}from"./separator-BLGGUlh9.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function $e(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{settings:null,parseError:"JSON root must be an object."}:{settings:r,parseError:null}}catch(r){return{settings:null,parseError:r.message}}}async function ze(){const s=await fetch(X("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function Je(){const s=await fetch(X("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Qe(s){const r=await fetch(X("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new ye("Droid raw settings changed externally");if(!r.ok){const n=await r.json().catch(()=>null);throw new Error(n?.error||"Failed to save Droid raw settings")}return r.json()}function He(){const s=Te(),r=ae({queryKey:["droid-diagnostics"],queryFn:ze,refetchInterval:1e4}),n=ae({queryKey:["droid-raw-settings"],queryFn:Je}),o=Ae({mutationFn:Qe,onSuccess:(d,l)=>{s.setQueryData(["droid-raw-settings"],t=>{const a=t?.path??"~/.factory/settings.json",u=t?.resolvedPath??a,x=$e(l.rawText);return{path:a,resolvedPath:u,exists:!0,mtime:d.mtime,rawText:l.rawText,settings:x.settings,parseError:x.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return Q.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawSettings:n.data,rawSettingsLoading:n.isLoading,rawSettingsError:n.error,refetchRawSettings:n.refetch,saveRawSettings:o.mutate,saveRawSettingsAsync:o.mutateAsync,isSavingRawSettings:o.isPending}),[r.data,r.isLoading,r.error,r.refetch,n.data,n.isLoading,n.error,n.refetch,o.mutate,o.mutateAsync,o.isPending])}const qe=["customModels","custom_models"],We={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},Ye=["low","medium","high","max","xhigh"];function h(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function p(s){return typeof s=="string"&&s.trim()?s.trim():null}function _(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function G(s){if(!s)return"unknown";const r=s.toLowerCase();return r==="anthropic"?"anthropic":r==="openai"?"openai":r==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function Ge(s,r,n){return`${s}:${r}:${encodeURIComponent(String(n))}`}function Xe(s){const r=s.indexOf(":"),n=s.indexOf(":",r+1);if(r<=0||n<=r+1)return null;const o=s.slice(0,r),d=s.slice(r+1,n),l=s.slice(n+1);if(o!=="customModels"&&o!=="custom_models"||d!=="array"&&d!=="object")return null;const t=decodeURIComponent(l);if(d==="array"){const a=Number.parseInt(t,10);return!Number.isInteger(a)||a<0?null:{rootKey:o,locationType:d,locationKey:a}}return{rootKey:o,locationType:d,locationKey:t}}function Ze(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function es(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function le(s){return JSON.parse(JSON.stringify(s))}function ss(s){const r=[];for(const n of qe){const o=s[n];if(Array.isArray(o)){o.forEach((d,l)=>{h(d)&&r.push({rootKey:n,locationType:"array",locationKey:l,entry:d})});continue}if(h(o))for(const[d,l]of Object.entries(o))h(l)&&r.push({rootKey:n,locationType:"object",locationKey:d,entry:l})}return r}function de(s,r){const n=Xe(r);if(!n)return null;const o=s[n.rootKey];if(n.locationType==="array"){if(!Array.isArray(o))return null;const t=o[n.locationKey];if(!h(t))return null;const a=p(t.provider);return{entry:t,providerKind:G(a)}}if(!h(o))return null;const d=o[n.locationKey];if(!h(d))return null;const l=p(d.provider);return{entry:d,providerKind:G(l)}}function rs(s,r){const n=r.extraArgs??r.extra_args,o=h(n)?n:null;if(!o)return{effort:null,anthropicBudgetTokens:null};const d=p(o.reasoning_effort)??p(o.reasoningEffort),l=h(o.reasoning)?o.reasoning:null,t=l?p(l.effort):null,a=h(o.thinking)?o.thinking:null,u=a?p(a.type):null,x=a?_(a.budget_tokens)??_(a.budgetTokens):null;return s==="openai"?{effort:t??d,anthropicBudgetTokens:null}:s==="anthropic"?u==="enabled"?{effort:Ze(x)??"high",anthropicBudgetTokens:x}:{effort:t??d,anthropicBudgetTokens:x}:{effort:d??t,anthropicBudgetTokens:null}}function ts(s){if(!s)return null;const r=s.trim().toLowerCase();return!r||r==="default"||r==="unset"||r==="off"||r==="none"||r==="disabled"?null:r}function ce(s){const r=es(s),n=s[r],o=h(n)?{...n}:{};return{extraArgsKey:r,extraArgs:o}}function ue(s,r,n){if(Object.keys(n).length===0){delete s[r];return}s[r]=n}function ns(s){return ss(s).map(({rootKey:r,locationType:n,locationKey:o,entry:d})=>{const l=p(d.displayName)??p(d.model_display_name)??"Unnamed model",t=p(d.model)??"",a=p(d.provider)??"unknown",u=G(a),x=rs(u,d);return{id:Ge(r,n,o),rootKey:r,locationType:n,locationKey:o,displayName:l,model:t,provider:a,providerKind:u,effort:x.effort,anthropicBudgetTokens:x.anthropicBudgetTokens}})}function as(s,r,n){const o=le(s),d=de(o,r);if(!d)return null;const l=ts(n),{extraArgsKey:t,extraArgs:a}=ce(d.entry);if(d.providerKind==="openai")if(delete a.reasoning_effort,delete a.reasoningEffort,!l)delete a.reasoning;else{const u=h(a.reasoning)?a.reasoning:{};a.reasoning={...u,effort:l}}else if(d.providerKind==="anthropic")if(delete a.reasoning_effort,delete a.reasoningEffort,delete a.reasoning,!l)delete a.thinking;else{const u=h(a.thinking)?{...a.thinking}:{},x=_(u.budget_tokens)??_(u.budgetTokens);delete u.budgetTokens,a.thinking={...u,type:"enabled",budget_tokens:x??We[l]??3e4}}else delete a.reasoning,delete a.reasoningEffort,l?a.reasoning_effort=l:delete a.reasoning_effort;return ue(d.entry,t,a),o}function is(s,r,n){const o=le(s),d=de(o,r);if(!d||d.providerKind!=="anthropic")return null;const{extraArgsKey:l,extraArgs:t}=ce(d.entry),a=h(t.thinking)?{...t.thinking}:{};if(a.type="enabled",n===null)delete a.budget_tokens,delete a.budgetTokens;else{const u=Math.max(1024,Math.floor(n));a.budget_tokens=u,delete a.budgetTokens}return t.thinking=a,ue(d.entry,l,t),o}const $="__unset__";function os(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function ls({models:s,disabled:r,disabledReason:n,onEffortChange:o,onAnthropicBudgetChange:d}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"BYOK Reasoning / Thinking",e.jsx(P,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(l=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:l.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:l.model||"(missing model id)"})]}),e.jsx(P,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:l.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Reasoning Effort"}),e.jsxs(H,{value:l.effort??$,onValueChange:t=>o(l.id,t===$?null:t),disabled:r,children:[e.jsx(q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:$,children:"Use provider default"}),Ye.map(t=>e.jsx(k,{value:t,children:t},t))]})]})]}),l.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Thinking Budget Tokens"}),e.jsx(oe,{type:"number",min:1024,step:1024,value:l.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:r,onChange:t=>{const a=t.target.value.trim();if(!a){d(l.id,null);return}const u=Number.parseInt(a,10);Number.isFinite(u)&&d(l.id,Math.max(1024,u))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:os(l)})]},l.id))})]})]})}const C="__unset__",ds=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],cs=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],us=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function ms(s){return s===!0?"true":s===!1?"false":C}function xs(s){return s==="true"?!0:s==="false"?!1:null}function gs({values:s,disabled:r,disabledReason:n,onEnumSettingChange:o,onBooleanSettingChange:d,onNumberSettingChange:l}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),"Quick Settings",e.jsx(P,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[ds.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(H,{value:s[t.key]??C,onValueChange:a=>o(t.key,a===C?null:a),disabled:r,children:[e.jsx(q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:C,children:"Use default"}),t.options.map(a=>e.jsx(k,{value:a.value,children:a.label},a.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.description})]},t.key)),us.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsx(oe,{type:"number",min:t.min,step:t.step,value:s[t.key]??"",onChange:a=>{const u=a.target.value.trim();if(!u){l(t.key,null);return}const x=Number.parseInt(u,10);Number.isFinite(x)&&l(t.key,Math.max(t.min,x))},className:"h-8 text-xs",disabled:r})]},t.key)),cs.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(H,{value:ms(s[t.key]),onValueChange:a=>d(t.key,xs(a)),disabled:r,children:[e.jsx(q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:C,children:"Use default"}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},t.key))]})]})]})}const fs=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],hs=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function ps(s){const r=/https?:\/\/[^\s)]+/g,n=[];let o=0,d;for(;(d=r.exec(s))!==null;){const[l]=d,t=d.index;t>o&&n.push(s.slice(o,t)),n.push(e.jsx("a",{href:l,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:l},`${l}-${t}`)),o=t+l.length}return o<s.length&&n.push(s.slice(o)),n.length>0?n:[s]}function js(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function bs(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function vs(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:r}}catch(r){return{valid:!1,error:r.message}}}function z(s){return typeof s=="string"?s:null}function J(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function R(s){return typeof s=="boolean"?s:null}function g({label:s,value:r,mono:n=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:Ce("text-right break-all",n&&"font-mono text-xs"),children:r})]})}function _s(){const{t:s}=Ne(),{diagnostics:r,diagnosticsLoading:n,diagnosticsError:o,refetchDiagnostics:d,rawSettings:l,rawSettingsLoading:t,refetchRawSettings:a,saveRawSettingsAsync:u,isSavingRawSettings:x}=He(),[D,O]=Q.useState(null),M=l?.rawText??"{}",B=D??M,Z=D!==null&&D!==M,c=vs(B),F=c.valid?{valid:!0}:{valid:!1,error:c.error},ee=m=>{if(m===M){O(null);return}O(m)},L=m=>{ee(JSON.stringify(m,null,2)+`
|
|
2
2
|
`)},I=(m,w)=>{if(!c.valid){j.error(s("droidPage.fixJsonBeforeQuickSettings"));return}const S={...c.value};w==null?delete S[m]:S[m]=w,L(S)},me=c.valid?{reasoningEffort:z(c.value.reasoningEffort),autonomyLevel:z(c.value.autonomyLevel),diffMode:z(c.value.diffMode),maxTurns:J(c.value.maxTurns),maxToolCalls:J(c.value.maxToolCalls),autoCompactThreshold:J(c.value.autoCompactThreshold),todoEnabled:R(c.value.todoEnabled),todoAutoRefresh:R(c.value.todoAutoRefresh),autoCompactEnabled:R(c.value.autoCompactEnabled),soundEnabled:R(c.value.soundEnabled)}:{reasoningEffort:null,autonomyLevel:null,diffMode:null,maxTurns:null,maxToolCalls:null,autoCompactThreshold:null,todoEnabled:null,todoAutoRefresh:null,autoCompactEnabled:null,soundEnabled:null},xe=c.valid?ns(c.value):[],ge=async()=>{await Promise.all([d(),a()])},fe=async()=>{if(!F.valid){j.error(s("droidPage.invalidJson",{value:F.error}));return}try{await u({rawText:B,expectedMtime:l?.exists?l.mtime:void 0}),O(null),j.success(s("droidPage.saved"))}catch(m){Ee(m)?j.error(s("droidPage.changedExternally")):j.error(m.message||s("droidPage.failedSave"))}},se=r?.byok.customModels??[],re=Q.useMemo(()=>Object.entries(r?.byok.providerBreakdown??{}).sort((m,w)=>w[1]-m[1]),[r?.byok.providerBreakdown]),he=()=>{if(n)return e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(Me,{className:"h-5 w-5 animate-spin mr-2"}),s("droidPage.loadingDiagnostics")]});if(o||!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-destructive px-6 text-center",children:s("droidPage.failedDiagnostics")});const m=r.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},w=m.notes??[],S=m.links??[],te=m.providerDocs??[],pe=S.length>0?S:fs,je=te.length>0?te:hs,be=m.providerValues??[],ve=m.settingsHierarchy??[],K="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden";return e.jsxs(Se,{defaultValue:"byok",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Pe,{className:"grid w-full grid-cols-3",children:[e.jsx(U,{value:"overview",children:s("droidPage.overview")}),e.jsx(U,{value:"byok",children:s("droidPage.byok")}),e.jsx(U,{value:"docs",children:s("droidPage.docs")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx(V,{value:"overview",className:K,children:e.jsx(T,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4"}),s("droidPage.runtimeInstall")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("droidPage.status")}),e.jsx(P,{variant:r.binary.installed?"default":"secondary",children:r.binary.installed?s("droidPage.detected"):s("droidPage.notFound")})]}),e.jsx(g,{label:s("droidPage.detectionSource"),value:r.binary.source,mono:!0}),e.jsx(g,{label:s("droidPage.binaryPath"),value:r.binary.path||s("droidPage.notFound"),mono:!0}),e.jsx(g,{label:s("droidPage.installDirectory"),value:r.binary.installDir||"N/A",mono:!0}),e.jsx(g,{label:s("droidPage.version"),value:r.binary.version||"Unknown",mono:!0}),e.jsx(g,{label:s("droidPage.overridePath"),value:r.binary.overridePath||"Not set",mono:!0})]})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Fe,{className:"h-4 w-4"}),s("droidPage.configFiles")]})}),e.jsx(N,{className:"space-y-3",children:[r.files.settings,r.files.legacyConfig].map(i=>e.jsxs("div",{className:"rounded-md border p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:i.label}),i.exists?e.jsx(Le,{className:"h-4 w-4 text-green-600"}):e.jsx(Ie,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(g,{label:s("droidPage.path"),value:i.path,mono:!0}),e.jsx(g,{label:s("droidPage.resolved"),value:i.resolvedPath,mono:!0}),e.jsx(g,{label:s("droidPage.size"),value:bs(i.sizeBytes)}),e.jsx(g,{label:s("droidPage.lastModified"),value:js(i.mtimeMs)}),i.parseError&&e.jsx("p",{className:"text-xs text-amber-600",children:s("droidPage.parseWarning",{value:i.parseError})}),i.readError&&e.jsx("p",{className:"text-xs text-destructive",children:s("droidPage.readWarning",{value:i.readError})})]},i.label))})]}),r.warnings.length>0&&e.jsxs(b,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4 text-amber-600"}),s("droidPage.warnings")]})}),e.jsx(N,{className:"space-y-1.5",children:r.warnings.map(i=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",i]},i))})]})]})})}),e.jsx(V,{value:"byok",className:K,children:e.jsx(T,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsx(gs,{values:me,disabled:t||!c.valid,disabledReason:c.valid?null:`Quick settings disabled: ${c.error}`,onEnumSettingChange:(i,f)=>{I(i,f)},onBooleanSettingChange:(i,f)=>{I(i,f)},onNumberSettingChange:(i,f)=>{I(i,f)}}),e.jsx(ls,{models:xe,disabled:t||!c.valid,disabledReason:c.valid?null:`${s("droidPage.byok")}: ${c.error}`,onEffortChange:(i,f)=>{if(!c.valid){j.error(s("droidPage.fixJsonBeforeReasoning"));return}const E=as(c.value,i,f);if(!E){j.error(s("droidPage.unableUpdateReasoning"));return}L(E)},onAnthropicBudgetChange:(i,f)=>{if(!c.valid){j.error(s("droidPage.fixJsonBeforeBudget"));return}const E=is(c.value,i,f);if(!E){j.error(s("droidPage.anthropicOnlyBudget"));return}L(E)}}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ue,{className:"h-4 w-4"}),s("droidPage.byokSummary")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsx(g,{label:s("droidPage.activeModelSelector"),value:r.byok.activeModelSelector||"Not set",mono:!0}),e.jsx(g,{label:s("droidPage.customModels"),value:String(r.byok.customModelCount)}),e.jsx(g,{label:s("droidPage.ccsManaged"),value:String(r.byok.ccsManagedCount)}),e.jsx(g,{label:s("droidPage.userManaged"),value:String(r.byok.userManagedCount)}),e.jsx(g,{label:s("droidPage.malformedEntries"),value:String(r.byok.invalidModelEntryCount)}),e.jsx(A,{}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providers")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[re.length===0&&e.jsx(P,{variant:"secondary",className:"font-mono",children:s("droidPage.none")}),re.map(([i,f])=>e.jsxs(P,{variant:"outline",className:"font-mono text-xs",children:[i,": ",f]},i))]})]})]})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsx(y,{className:"text-base",children:s("droidPage.customModelsTitle")})}),e.jsx(N,{children:e.jsxs("div",{className:"rounded-md border overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] bg-muted/40 px-3 py-2 text-xs font-medium",children:[e.jsx("span",{children:s("droidPage.modelName")}),e.jsx("span",{children:s("droidPage.provider")}),e.jsx("span",{children:s("droidPage.baseUrl")})]}),e.jsx(T,{className:"h-52",children:e.jsxs("div",{className:"divide-y",children:[se.length===0&&e.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground",children:s("droidPage.noCustomModels")}),se.map(i=>e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] gap-2 px-3 py-2 text-xs",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:i.displayName}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:i.model})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",children:i.provider}),e.jsx("p",{className:"text-muted-foreground",children:i.apiKeyPreview||"no-key"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",title:i.baseUrl,children:i.host||i.baseUrl}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:i.baseUrl})]})]},`${i.displayName}-${i.model}-${i.baseUrl}`))]})})]})})]})]})})}),e.jsx(V,{value:"docs",className:K,children:e.jsx(T,{className:"h-full",children:e.jsx("div",{className:"space-y-4 pr-1",children:e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),s("droidPage.docsAlignedNotes")]})}),e.jsxs(N,{className:"space-y-2 text-sm",children:[w.map((i,f)=>e.jsxs("p",{className:"text-muted-foreground",children:["- ",ps(i)]},`${f}-${i}`)),e.jsx(A,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.factoryDocs")}),e.jsx("div",{className:"space-y-1.5",children:pe.map(i=>e.jsxs("a",{href:i.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:i.label}),e.jsx(ie,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:i.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:i.url})]},i.id))})]}),e.jsx(A,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.providerFactCheckDocs")}),e.jsx("div",{className:"space-y-1.5",children:je.map(i=>e.jsxs("a",{href:i.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:i.label}),e.jsx(ie,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",i.provider," | format: ",i.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:i.url})]},`${i.provider}-${i.url}`))})]}),e.jsx(A,{}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providerValues",{value:be.join(", ")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.settingsHierarchy",{value:ve.join(" -> ")})})]})]})})})})]})]})};return e.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:e.jsxs(we,{direction:"horizontal",className:"h-full",children:[e.jsx(ne,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:he()})}),e.jsx(ke,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:e.jsx(Oe,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(ne,{defaultSize:55,minSize:35,children:e.jsx(Re,{title:s("droidPage.settingsTitle"),pathLabel:l?.path||"~/.factory/settings.json",loading:t,parseWarning:l?.parseError,value:B,dirty:Z,saving:x,saveDisabled:!Z||x||t||!F.valid,onChange:m=>{ee(m)},onSave:fe,onRefresh:ge})})]})})}export{_s as DroidPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-C98W0NRG.js";import{r as m}from"./react-vendor-CNOkPC89.js";import{bj as C,bk as w,a as G,bl as y,b5 as k,b7 as S,n as R,aA as A,d as f,I as j}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-C98W0NRG.js";import{r as m}from"./react-vendor-CNOkPC89.js";import{bj as C,bk as w,a as G,bl as y,b5 as k,b7 as S,n as R,aA as A,d as f,I as j}from"./index-Corv1lSo.js";import{R as N,v as D,w as L,am as T,a6 as I}from"./icons-CeH5899d.js";import"./tanstack-CfKik0yL.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function _(){const{state:s}=C(),n=w(),[o,r]=m.useState(""),[c,g]=m.useState(""),b=m.useCallback(async()=>{try{n.setGlobalEnvLoading(!0),n.setGlobalEnvError(null);const a=await fetch("/api/global-env");if(!a.ok)throw new Error("Failed to load Global Env config");const l=await a.json();n.setGlobalEnvConfig(l)}catch(a){n.setGlobalEnvError(a.message)}finally{n.setGlobalEnvLoading(!1)}},[n]),i=m.useCallback(async a=>{const l=s.globalEnvConfig;if(!l)return;const x={...l,...a};n.setGlobalEnvConfig(x);try{n.setGlobalEnvSaving(!0),n.setGlobalEnvError(null);const d=await fetch("/api/global-env",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!d.ok){const h=await d.json();throw new Error(h.error||"Failed to save")}const v=await d.json();n.setGlobalEnvConfig(v.config),n.setGlobalEnvSuccess(!0),setTimeout(()=>n.setGlobalEnvSuccess(!1),1500)}catch(d){n.setGlobalEnvConfig(l),n.setGlobalEnvError(d.message)}finally{n.setGlobalEnvSaving(!1)}},[s.globalEnvConfig,n]),E=m.useCallback(()=>{if(!o.trim()||!s.globalEnvConfig)return;const a={...s.globalEnvConfig.env,[o.trim()]:c};i({env:a}),r(""),g("")},[o,c,s.globalEnvConfig,i]),u=m.useCallback(a=>{if(!s.globalEnvConfig)return;const l={...s.globalEnvConfig.env};delete l[a],i({env:l})},[s.globalEnvConfig,i]);return{config:s.globalEnvConfig,loading:s.globalEnvLoading,saving:s.globalEnvSaving,error:s.globalEnvError,success:s.globalEnvSuccess,newEnvKey:o,setNewEnvKey:r,newEnvValue:c,setNewEnvValue:g,fetchConfig:b,saveConfig:i,addEnvVar:E,removeEnvVar:u}}function Y(){const{t:s}=G(),{config:n,loading:o,saving:r,error:c,success:g,newEnvKey:b,setNewEnvKey:i,newEnvValue:E,setNewEnvValue:u,fetchConfig:a,saveConfig:l,addEnvVar:x,removeEnvVar:d}=_(),{fetchRawConfig:v}=y();m.useEffect(()=>{a(),v()},[a,v]);const h=()=>{l({enabled:!n?.enabled})};return o?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(N,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${c||g?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[c&&e.jsxs(k,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx(S,{children:c})]}),g&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(L,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(R,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.description")}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:n?.enabled?s("settingsGlobalEnv.enabled"):s("settingsGlobalEnv.disabled")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n?.enabled?s("settingsGlobalEnv.enabledDesc"):s("settingsGlobalEnv.disabledDesc")})]}),e.jsx(A,{checked:n?.enabled??!0,onCheckedChange:h})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsGlobalEnv.envVars")}),n?.env&&Object.keys(n.env).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(n.env).map(([t,p])=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border bg-background",children:[e.jsx("code",{className:"flex-1 font-mono text-sm truncate",children:t}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"font-mono text-sm px-2 py-1 bg-muted rounded",children:p}),e.jsx(f,{variant:"ghost",size:"sm",onClick:()=>d(t),disabled:r,className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(T,{className:"w-4 h-4"})})]},t))}):e.jsx("div",{className:"p-4 rounded-lg border border-dashed text-center text-muted-foreground",children:e.jsx("p",{children:s("settingsGlobalEnv.noneConfigured")})}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.addNew")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{value:b,onChange:t=>i(t.target.value.toUpperCase()),placeholder:s("settingsGlobalEnv.keyName"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:"="}),e.jsx(j,{value:E,onChange:t=>u(t.target.value),placeholder:s("settingsGlobalEnv.value"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsxs(f,{size:"sm",onClick:x,disabled:r||!b.trim(),className:"h-9",children:[e.jsx(I,{className:"w-4 h-4 mr-1"}),s("settingsGlobalEnv.add")]})]})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.quickAdd")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[[{key:"DISABLE_BUG_COMMAND",value:"1"},{key:"DISABLE_ERROR_REPORTING",value:"1"},{key:"DISABLE_TELEMETRY",value:"1"}].map(({key:t,value:p})=>!n?.env?.[t]&&e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{i(t),u(p)},className:"text-xs font-mono",children:["+ ",t]},t)),n?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(t=>n.env[t])&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.allConfigured")})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{a(),v()},disabled:o||r,className:"w-full",children:[e.jsx(N,{className:`w-4 h-4 mr-2 ${o?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-C98W0NRG.js";import{a as N,c as l,d as p,M as k,N as C,O as S,B as R,S as h}from"./index-CcKb4PL_.js";import{u as W,a as E,b as O}from"./tanstack-CfKik0yL.js";import{t as g}from"./notifications-B2HqRBj7.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{aZ as y,C as P,Y as I,n as M,Z as T,h as H,U as $,d as A,a_ as z,r as F,Q as B,R as D}from"./icons-CeH5899d.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const q={sm:{dimension:80,strokeWidth:6,fontSize:"text-lg",labelSize:"text-[10px]"},md:{dimension:120,strokeWidth:8,fontSize:"text-3xl",labelSize:"text-xs"},lg:{dimension:160,strokeWidth:10,fontSize:"text-4xl",labelSize:"text-sm"}},G={ok:{stroke:"#22C55E",glow:"rgba(34, 197, 94, 0.4)"},warning:{stroke:"#EAB308",glow:"rgba(234, 179, 8, 0.4)"},error:{stroke:"#EF4444",glow:"rgba(239, 68, 68, 0.4)"}};function K({passed:s,total:t,status:a,size:r="md"}){const{t:i}=N(),o=q[r],c=G[a],n=t>0?Math.round(s/t*100):0,d=(o.dimension-o.strokeWidth)/2,u=2*Math.PI*d,f=u-n/100*u,x=o.dimension/2;return e.jsxs("div",{className:"relative inline-flex items-center justify-center",children:[e.jsxs("svg",{width:o.dimension,height:o.dimension,className:"transform -rotate-90",style:{filter:`drop-shadow(0 0 8px ${c.glow})`},children:[e.jsx("circle",{cx:x,cy:x,r:d,fill:"none",stroke:"currentColor",strokeWidth:o.strokeWidth,className:"text-muted/30"}),e.jsx("circle",{cx:x,cy:x,r:d,fill:"none",stroke:c.stroke,strokeWidth:o.strokeWidth,strokeLinecap:"round",strokeDasharray:u,strokeDashoffset:f,className:"transition-all duration-1000 ease-out"}),n>0&&e.jsx("circle",{cx:x+d*Math.cos(n/100*2*Math.PI-Math.PI/2),cy:x+d*Math.sin(n/100*2*Math.PI-Math.PI/2),r:o.strokeWidth/2,fill:c.stroke,className:"animate-pulse",style:{filter:`drop-shadow(0 0 4px ${c.glow})`}})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("span",{className:l("font-mono font-bold tracking-tight",o.fontSize),children:n}),e.jsx("span",{className:l("font-mono uppercase tracking-widest text-muted-foreground",o.labelSize),children:i("health.healthLabel")})]})]})}function b({label:s,value:t,color:a,bgColor:r}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full animate-pulse",r)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:s}),e.jsx("span",{className:l("font-mono font-bold text-sm",a),children:t})]})}function L({total:s,passed:t,warnings:a,errors:r,info:i}){const{t:o}=N(),c=t/s*100,n=a/s*100,d=r/s*100,u=i/s*100;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"h-2 rounded-full overflow-hidden bg-muted/50 flex",children:[d>0&&e.jsx("div",{className:"h-full bg-red-500 transition-all duration-500",style:{width:`${d}%`}}),n>0&&e.jsx("div",{className:"h-full bg-yellow-500 transition-all duration-500",style:{width:`${n}%`}}),u>0&&e.jsx("div",{className:"h-full bg-blue-500 transition-all duration-500",style:{width:`${u}%`}}),c>0&&e.jsx("div",{className:"h-full bg-green-500 transition-all duration-500",style:{width:`${c}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("health.checks")}),e.jsx("span",{className:"font-mono font-bold text-lg",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx(b,{label:"OK",value:t,color:"text-green-500",bgColor:"bg-green-500"}),e.jsx(b,{label:"WARN",value:a,color:"text-yellow-500",bgColor:"bg-yellow-500"}),e.jsx(b,{label:"ERR",value:r,color:"text-red-500",bgColor:"bg-red-500"}),e.jsx(b,{label:"INFO",value:i,color:"text-blue-500",bgColor:"bg-blue-500"})]})]})]})}function Q(){return W({queryKey:["health"],queryFn:async()=>(await fetch("/api/health")).json(),refetchInterval:3e4})}function U(){const s=E();return O({mutationFn:async t=>{const a=await fetch(`/api/health/fix/${t}`,{method:"POST"}),r=await a.json();if(!a.ok)throw new Error(r.message);return r},onSuccess:t=>{s.invalidateQueries({queryKey:["health"]}),g.success(t.message)},onError:t=>{g.error(t.message)}})}const Z={ok:{dot:"bg-green-500",label:"OK",labelColor:"text-green-500"},warning:{dot:"bg-yellow-500",label:"WARN",labelColor:"text-yellow-500"},error:{dot:"bg-red-500",label:"ERR",labelColor:"text-red-500"},info:{dot:"bg-blue-500",label:"INFO",labelColor:"text-blue-500"}};function Y({check:s}){const{t}=N(),a=U(),r=Z[s.status],[i,o]=j.useState(!1),c=s.details||s.fix,n=d=>{navigator.clipboard.writeText(d),g.success(t("health.copied"))};return c?e.jsx(k,{open:i,onOpenChange:o,children:e.jsxs("div",{className:l("group rounded-lg border transition-all duration-150",i?"border-border bg-muted/30":"border-transparent hover:border-border/50 hover:bg-muted/50"),children:[e.jsx(C,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left",children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),e.jsx(P,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",i&&"rotate-90")})]})}),e.jsx(S,{children:e.jsxs("div",{className:"px-3 pb-3 pt-1 space-y-2 ml-7",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.message}),s.details&&e.jsx("pre",{className:"text-xs font-mono text-muted-foreground bg-background/50 rounded p-2 overflow-x-auto border border-border/50",children:s.details}),s.fix&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 bg-background/50 rounded px-2 py-1.5 border border-border/50",children:[e.jsx(I,{className:"w-3 h-3 text-muted-foreground shrink-0"}),e.jsx("code",{className:"text-xs font-mono flex-1 truncate",children:s.fix}),e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>s.fix&&n(s.fix),className:"h-5 w-5 p-0",children:e.jsx(M,{className:"w-3 h-3"})})]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",onClick:()=>a.mutate(s.id),disabled:a.isPending,className:"h-7 px-3 text-xs",children:[e.jsx(y,{className:"w-3 h-3 mr-1"}),t("health.applyFix")]})]})]})})]})}):e.jsxs("div",{className:l("group flex items-center gap-3 px-3 py-2 rounded-lg","hover:bg-muted/50 transition-colors duration-150","border border-transparent hover:border-border/50"),children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",variant:"ghost",onClick:()=>a.mutate(s.id),disabled:a.isPending,className:"h-6 px-2 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(y,{className:"w-3 h-3 mr-1"}),t("health.fix")]})]})}const _={Monitor:z,Settings:A,Users:$,Shield:H,Zap:T};function J({group:s,defaultOpen:t=!0}){const[a,r]=j.useState(t),i=_[s.icon]||z,o=s.checks.filter(m=>m.status==="ok").length,c=s.checks.length,n=s.checks.some(m=>m.status==="error"),d=s.checks.some(m=>m.status==="warning"),u=Math.round(o/c*100),f=n?"text-red-500":d?"text-yellow-500":"text-green-500",x=n?"bg-red-500":d?"bg-yellow-500":"bg-green-500";return e.jsx(k,{open:a,onOpenChange:r,children:e.jsxs("div",{className:l("rounded-lg border transition-all duration-200",n?"border-red-500/30":d?"border-yellow-500/30":"border-border"),children:[e.jsx(C,{asChild:!0,children:e.jsxs("button",{className:l("w-full flex items-center gap-3 p-3 text-left rounded-lg","hover:bg-muted/50 transition-colors duration-150",a&&"rounded-b-none border-b border-border/50"),children:[e.jsx("div",{className:l("p-1.5 rounded-md",n?"bg-red-500/10 text-red-500":d?"bg-yellow-500/10 text-yellow-500":"bg-muted text-muted-foreground"),children:e.jsx(i,{className:"w-4 h-4"})}),e.jsx("span",{className:"flex-1 text-sm font-semibold",children:s.name}),!a&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"w-16 h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:l("h-full transition-all duration-500",x),style:{width:`${u}%`}})})}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",f),children:[o,"/",c]}),e.jsx(F,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",a&&"rotate-180")})]})}),e.jsx(S,{children:e.jsx("div",{className:"p-2 space-y-0.5",children:s.checks.map(m=>e.jsx(Y,{check:m},m.id))})})]})})}function V(s){return s.errors>0?"error":s.warnings>0?"warning":"ok"}function X(s,t){const a=Math.floor((Date.now()-s)/1e3);if(a<5)return t("health.justNow");if(a<60)return t("health.secondsAgo",{count:a});const r=Math.floor(a/60);if(r<60)return t("health.minutesAgo",{count:r});const i=Math.floor(r/60);return t("health.hoursAgo",{count:i})}function ee(s){return[...s].sort((t,a)=>{const r=t.checks.filter(n=>n.status==="error").length,i=a.checks.filter(n=>n.status==="error").length,o=t.checks.filter(n=>n.status==="warning").length,c=a.checks.filter(n=>n.status==="warning").length;return r!==i?i-r:c-o})}function se(){return e.jsxs("div",{className:"font-mono text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{className:"text-green-500",children:"$"}),e.jsx("span",{children:"ccs doctor"})]})}function te(){return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsx("div",{className:"rounded-xl border bg-gradient-to-br from-background to-muted/20 p-6",children:e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx(h,{className:"w-[120px] h-[120px] rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(h,{className:"h-5 w-48"}),e.jsx(h,{className:"h-8 w-64"}),e.jsx(h,{className:"h-4 w-32"})]})]})}),e.jsx(h,{className:"h-16 w-full rounded-lg"}),e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(s=>e.jsx(h,{className:"h-20 rounded-lg"},s))})]})}function xe(){const{t:s}=N(),{data:t,isLoading:a,refetch:r,dataUpdatedAt:i}=Q(),o=i,[c,n]=j.useState(0);j.useEffect(()=>{const m=setInterval(()=>n(v=>v+1),1e3);return()=>clearInterval(m)},[]);const d=()=>{navigator.clipboard.writeText("ccs doctor"),g.success(s("health.copied"))},u=()=>{r(),g.info(s("health.refreshing"))};if(a&&!t)return e.jsx(te,{});const f=t?V(t.summary):"ok",x=t?.groups?ee(t.groups):[];return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:l("relative overflow-hidden rounded-xl border p-6","bg-gradient-to-br from-background via-background to-muted/30"),children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),e.jsxs("div",{className:"relative flex flex-col md:flex-row items-start md:items-center gap-6",children:[t&&e.jsx("div",{className:"shrink-0",children:e.jsx(K,{passed:t.summary.passed,total:t.summary.total-t.summary.info,status:f,size:"md"})}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(se,{}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"text-2xl font-bold font-mono tracking-tight",children:s("health.systemHealth")}),t?.version&&e.jsx(R,{variant:"outline",className:"font-mono text-xs bg-muted/50",children:s("health.build",{version:t.version})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(B,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:s("health.lastScan")}),e.jsx("span",{className:"font-mono",children:o?X(o,s):"--"}),e.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsx("span",{className:"text-muted-foreground",children:s("health.autoRefresh")}),e.jsx("span",{className:"font-mono text-green-500",children:"30s"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(p,{variant:"outline",size:"sm",onClick:d,className:"gap-2 font-mono text-xs",children:[e.jsx(I,{className:"w-3 h-3"}),"ccs doctor",e.jsx(M,{className:"w-3 h-3 opacity-50"})]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:u,disabled:a,className:"gap-2",children:[e.jsx(D,{className:l("w-4 h-4",a&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:s("health.refresh")}),e.jsx("kbd",{className:"hidden md:inline-flex h-5 items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:"R"})]})]})]})]}),t&&e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsx(L,{total:t.summary.total,passed:t.summary.passed,warnings:t.summary.warnings,errors:t.summary.errors,info:t.summary.info})}),x.length>0&&e.jsx("div",{className:"space-y-3",children:x.map((m,v)=>e.jsx(J,{group:m,defaultOpen:v<2||m.checks.some(w=>w.status==="error"||w.status==="warning")},m.id))}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{children:[s("health.version")," ",e.jsx("span",{className:"font-mono",children:t?.version??"--"})]}),e.jsxs("span",{children:[s("health.platform")," ",e.jsx("span",{className:"font-mono",children:typeof navigator<"u"?navigator.platform:"linux"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),e.jsx("span",{children:s("health.liveMonitoring")})]})]})]})}export{xe as HealthPage};
|
|
1
|
+
import{j as e}from"./radix-ui-C98W0NRG.js";import{a as N,c as l,d as p,M as k,N as C,O as S,B as R,S as h}from"./index-Corv1lSo.js";import{u as W,a as E,b as O}from"./tanstack-CfKik0yL.js";import{t as g}from"./notifications-B2HqRBj7.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{aZ as y,C as P,Y as I,n as M,Z as T,h as H,U as $,d as A,a_ as z,r as F,Q as B,R as D}from"./icons-CeH5899d.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const q={sm:{dimension:80,strokeWidth:6,fontSize:"text-lg",labelSize:"text-[10px]"},md:{dimension:120,strokeWidth:8,fontSize:"text-3xl",labelSize:"text-xs"},lg:{dimension:160,strokeWidth:10,fontSize:"text-4xl",labelSize:"text-sm"}},G={ok:{stroke:"#22C55E",glow:"rgba(34, 197, 94, 0.4)"},warning:{stroke:"#EAB308",glow:"rgba(234, 179, 8, 0.4)"},error:{stroke:"#EF4444",glow:"rgba(239, 68, 68, 0.4)"}};function K({passed:s,total:t,status:a,size:r="md"}){const{t:i}=N(),o=q[r],c=G[a],n=t>0?Math.round(s/t*100):0,d=(o.dimension-o.strokeWidth)/2,u=2*Math.PI*d,f=u-n/100*u,x=o.dimension/2;return e.jsxs("div",{className:"relative inline-flex items-center justify-center",children:[e.jsxs("svg",{width:o.dimension,height:o.dimension,className:"transform -rotate-90",style:{filter:`drop-shadow(0 0 8px ${c.glow})`},children:[e.jsx("circle",{cx:x,cy:x,r:d,fill:"none",stroke:"currentColor",strokeWidth:o.strokeWidth,className:"text-muted/30"}),e.jsx("circle",{cx:x,cy:x,r:d,fill:"none",stroke:c.stroke,strokeWidth:o.strokeWidth,strokeLinecap:"round",strokeDasharray:u,strokeDashoffset:f,className:"transition-all duration-1000 ease-out"}),n>0&&e.jsx("circle",{cx:x+d*Math.cos(n/100*2*Math.PI-Math.PI/2),cy:x+d*Math.sin(n/100*2*Math.PI-Math.PI/2),r:o.strokeWidth/2,fill:c.stroke,className:"animate-pulse",style:{filter:`drop-shadow(0 0 4px ${c.glow})`}})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("span",{className:l("font-mono font-bold tracking-tight",o.fontSize),children:n}),e.jsx("span",{className:l("font-mono uppercase tracking-widest text-muted-foreground",o.labelSize),children:i("health.healthLabel")})]})]})}function b({label:s,value:t,color:a,bgColor:r}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full animate-pulse",r)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:s}),e.jsx("span",{className:l("font-mono font-bold text-sm",a),children:t})]})}function L({total:s,passed:t,warnings:a,errors:r,info:i}){const{t:o}=N(),c=t/s*100,n=a/s*100,d=r/s*100,u=i/s*100;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"h-2 rounded-full overflow-hidden bg-muted/50 flex",children:[d>0&&e.jsx("div",{className:"h-full bg-red-500 transition-all duration-500",style:{width:`${d}%`}}),n>0&&e.jsx("div",{className:"h-full bg-yellow-500 transition-all duration-500",style:{width:`${n}%`}}),u>0&&e.jsx("div",{className:"h-full bg-blue-500 transition-all duration-500",style:{width:`${u}%`}}),c>0&&e.jsx("div",{className:"h-full bg-green-500 transition-all duration-500",style:{width:`${c}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("health.checks")}),e.jsx("span",{className:"font-mono font-bold text-lg",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx(b,{label:"OK",value:t,color:"text-green-500",bgColor:"bg-green-500"}),e.jsx(b,{label:"WARN",value:a,color:"text-yellow-500",bgColor:"bg-yellow-500"}),e.jsx(b,{label:"ERR",value:r,color:"text-red-500",bgColor:"bg-red-500"}),e.jsx(b,{label:"INFO",value:i,color:"text-blue-500",bgColor:"bg-blue-500"})]})]})]})}function Q(){return W({queryKey:["health"],queryFn:async()=>(await fetch("/api/health")).json(),refetchInterval:3e4})}function U(){const s=E();return O({mutationFn:async t=>{const a=await fetch(`/api/health/fix/${t}`,{method:"POST"}),r=await a.json();if(!a.ok)throw new Error(r.message);return r},onSuccess:t=>{s.invalidateQueries({queryKey:["health"]}),g.success(t.message)},onError:t=>{g.error(t.message)}})}const Z={ok:{dot:"bg-green-500",label:"OK",labelColor:"text-green-500"},warning:{dot:"bg-yellow-500",label:"WARN",labelColor:"text-yellow-500"},error:{dot:"bg-red-500",label:"ERR",labelColor:"text-red-500"},info:{dot:"bg-blue-500",label:"INFO",labelColor:"text-blue-500"}};function Y({check:s}){const{t}=N(),a=U(),r=Z[s.status],[i,o]=j.useState(!1),c=s.details||s.fix,n=d=>{navigator.clipboard.writeText(d),g.success(t("health.copied"))};return c?e.jsx(k,{open:i,onOpenChange:o,children:e.jsxs("div",{className:l("group rounded-lg border transition-all duration-150",i?"border-border bg-muted/30":"border-transparent hover:border-border/50 hover:bg-muted/50"),children:[e.jsx(C,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left",children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),e.jsx(P,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",i&&"rotate-90")})]})}),e.jsx(S,{children:e.jsxs("div",{className:"px-3 pb-3 pt-1 space-y-2 ml-7",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.message}),s.details&&e.jsx("pre",{className:"text-xs font-mono text-muted-foreground bg-background/50 rounded p-2 overflow-x-auto border border-border/50",children:s.details}),s.fix&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 bg-background/50 rounded px-2 py-1.5 border border-border/50",children:[e.jsx(I,{className:"w-3 h-3 text-muted-foreground shrink-0"}),e.jsx("code",{className:"text-xs font-mono flex-1 truncate",children:s.fix}),e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>s.fix&&n(s.fix),className:"h-5 w-5 p-0",children:e.jsx(M,{className:"w-3 h-3"})})]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",onClick:()=>a.mutate(s.id),disabled:a.isPending,className:"h-7 px-3 text-xs",children:[e.jsx(y,{className:"w-3 h-3 mr-1"}),t("health.applyFix")]})]})]})})]})}):e.jsxs("div",{className:l("group flex items-center gap-3 px-3 py-2 rounded-lg","hover:bg-muted/50 transition-colors duration-150","border border-transparent hover:border-border/50"),children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",variant:"ghost",onClick:()=>a.mutate(s.id),disabled:a.isPending,className:"h-6 px-2 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(y,{className:"w-3 h-3 mr-1"}),t("health.fix")]})]})}const _={Monitor:z,Settings:A,Users:$,Shield:H,Zap:T};function J({group:s,defaultOpen:t=!0}){const[a,r]=j.useState(t),i=_[s.icon]||z,o=s.checks.filter(m=>m.status==="ok").length,c=s.checks.length,n=s.checks.some(m=>m.status==="error"),d=s.checks.some(m=>m.status==="warning"),u=Math.round(o/c*100),f=n?"text-red-500":d?"text-yellow-500":"text-green-500",x=n?"bg-red-500":d?"bg-yellow-500":"bg-green-500";return e.jsx(k,{open:a,onOpenChange:r,children:e.jsxs("div",{className:l("rounded-lg border transition-all duration-200",n?"border-red-500/30":d?"border-yellow-500/30":"border-border"),children:[e.jsx(C,{asChild:!0,children:e.jsxs("button",{className:l("w-full flex items-center gap-3 p-3 text-left rounded-lg","hover:bg-muted/50 transition-colors duration-150",a&&"rounded-b-none border-b border-border/50"),children:[e.jsx("div",{className:l("p-1.5 rounded-md",n?"bg-red-500/10 text-red-500":d?"bg-yellow-500/10 text-yellow-500":"bg-muted text-muted-foreground"),children:e.jsx(i,{className:"w-4 h-4"})}),e.jsx("span",{className:"flex-1 text-sm font-semibold",children:s.name}),!a&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"w-16 h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:l("h-full transition-all duration-500",x),style:{width:`${u}%`}})})}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",f),children:[o,"/",c]}),e.jsx(F,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",a&&"rotate-180")})]})}),e.jsx(S,{children:e.jsx("div",{className:"p-2 space-y-0.5",children:s.checks.map(m=>e.jsx(Y,{check:m},m.id))})})]})})}function V(s){return s.errors>0?"error":s.warnings>0?"warning":"ok"}function X(s,t){const a=Math.floor((Date.now()-s)/1e3);if(a<5)return t("health.justNow");if(a<60)return t("health.secondsAgo",{count:a});const r=Math.floor(a/60);if(r<60)return t("health.minutesAgo",{count:r});const i=Math.floor(r/60);return t("health.hoursAgo",{count:i})}function ee(s){return[...s].sort((t,a)=>{const r=t.checks.filter(n=>n.status==="error").length,i=a.checks.filter(n=>n.status==="error").length,o=t.checks.filter(n=>n.status==="warning").length,c=a.checks.filter(n=>n.status==="warning").length;return r!==i?i-r:c-o})}function se(){return e.jsxs("div",{className:"font-mono text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{className:"text-green-500",children:"$"}),e.jsx("span",{children:"ccs doctor"})]})}function te(){return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsx("div",{className:"rounded-xl border bg-gradient-to-br from-background to-muted/20 p-6",children:e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx(h,{className:"w-[120px] h-[120px] rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(h,{className:"h-5 w-48"}),e.jsx(h,{className:"h-8 w-64"}),e.jsx(h,{className:"h-4 w-32"})]})]})}),e.jsx(h,{className:"h-16 w-full rounded-lg"}),e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(s=>e.jsx(h,{className:"h-20 rounded-lg"},s))})]})}function xe(){const{t:s}=N(),{data:t,isLoading:a,refetch:r,dataUpdatedAt:i}=Q(),o=i,[c,n]=j.useState(0);j.useEffect(()=>{const m=setInterval(()=>n(v=>v+1),1e3);return()=>clearInterval(m)},[]);const d=()=>{navigator.clipboard.writeText("ccs doctor"),g.success(s("health.copied"))},u=()=>{r(),g.info(s("health.refreshing"))};if(a&&!t)return e.jsx(te,{});const f=t?V(t.summary):"ok",x=t?.groups?ee(t.groups):[];return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:l("relative overflow-hidden rounded-xl border p-6","bg-gradient-to-br from-background via-background to-muted/30"),children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),e.jsxs("div",{className:"relative flex flex-col md:flex-row items-start md:items-center gap-6",children:[t&&e.jsx("div",{className:"shrink-0",children:e.jsx(K,{passed:t.summary.passed,total:t.summary.total-t.summary.info,status:f,size:"md"})}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(se,{}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"text-2xl font-bold font-mono tracking-tight",children:s("health.systemHealth")}),t?.version&&e.jsx(R,{variant:"outline",className:"font-mono text-xs bg-muted/50",children:s("health.build",{version:t.version})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(B,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:s("health.lastScan")}),e.jsx("span",{className:"font-mono",children:o?X(o,s):"--"}),e.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsx("span",{className:"text-muted-foreground",children:s("health.autoRefresh")}),e.jsx("span",{className:"font-mono text-green-500",children:"30s"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(p,{variant:"outline",size:"sm",onClick:d,className:"gap-2 font-mono text-xs",children:[e.jsx(I,{className:"w-3 h-3"}),"ccs doctor",e.jsx(M,{className:"w-3 h-3 opacity-50"})]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:u,disabled:a,className:"gap-2",children:[e.jsx(D,{className:l("w-4 h-4",a&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:s("health.refresh")}),e.jsx("kbd",{className:"hidden md:inline-flex h-5 items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:"R"})]})]})]})]}),t&&e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsx(L,{total:t.summary.total,passed:t.summary.passed,warnings:t.summary.warnings,errors:t.summary.errors,info:t.summary.info})}),x.length>0&&e.jsx("div",{className:"space-y-3",children:x.map((m,v)=>e.jsx(J,{group:m,defaultOpen:v<2||m.checks.some(w=>w.status==="error"||w.status==="warning")},m.id))}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{children:[s("health.version")," ",e.jsx("span",{className:"font-mono",children:t?.version??"--"})]}),e.jsxs("span",{children:[s("health.platform")," ",e.jsx("span",{className:"font-mono",children:typeof navigator<"u"?navigator.platform:"linux"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),e.jsx("span",{children:s("health.liveMonitoring")})]})]})]})}export{xe as HealthPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-C98W0NRG.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{bl as je,Y as re,b5 as ae,b7 as te,d as B,n as Ne,B as c,c as u,aA as ye,I as G,r as se,s as ne,t as ie,v as de,w as F}from"./index-CcKb4PL_.js";import{R as J,v as le,w as ke,a5 as oe,ar as we,A as Ce,a7 as Be,am as Me,s as Se,r as _e,a6 as Pe,aC as Ae}from"./icons-CeH5899d.js";import"./tanstack-CfKik0yL.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const M="__no_backend__";function ce(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(a=>typeof a=="string")}function Re(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const a=t;return!!a.config&&typeof a.config.enabled=="boolean"&&typeof a.config.timeout=="number"&&ce(a.config.providerModels)&&(a.config.fallbackBackend===null||typeof a.config.fallbackBackend=="string")&&ce(a.config.profileBackends)&&!!a.summary&&typeof a.summary.state=="string"&&typeof a.summary.title=="string"&&typeof a.summary.detail=="string"&&Array.isArray(a.backends)&&Array.isArray(a.profiles)&&!!a.catalog&&Array.isArray(a.catalog.knownBackends)&&Array.isArray(a.catalog.profileNames)&&typeof a.summary.nativeProfileCount=="number"}function Te(t){return Object.entries(t).sort(([a],[l])=>a.localeCompare(l)).map(([a,l],g)=>({id:`${a}-${l}-${g}`,profileName:a,backendId:l}))}function De(t){switch(t){case"ready":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-900 dark:text-emerald-200";case"partial":return"border-amber-500/25 bg-amber-500/10 text-amber-900 dark:text-amber-200";case"needs_setup":return"border-rose-500/25 bg-rose-500/10 text-rose-900 dark:text-rose-200";case"disabled":return"border-border/80 bg-background/85 text-muted-foreground"}}function Ie(t){switch(t){case"ready":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"starts_on_launch":return"border-sky-500/25 bg-sky-500/10 text-sky-800 dark:text-sky-200";case"needs_auth":return"border-rose-500/25 bg-rose-500/10 text-rose-800 dark:text-rose-200";case"needs_proxy":return"border-amber-500/25 bg-amber-500/10 text-amber-800 dark:text-amber-200";case"review":return"border-border/80 bg-background/85 text-muted-foreground"}}function me(t){switch(t){case"active":return"Active";case"bypassed":return"Bypassed";case"fallback":return"Native fallback";case"setup":return"Needs setup";case"disabled":return"Disabled";case"native":return"Native";case"unresolved":return"Native only"}}function ue(t){switch(t){case"active":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"bypassed":return"border-sky-500/25 bg-sky-500/10 text-sky-800 dark:text-sky-200";case"fallback":case"setup":return"border-amber-500/25 bg-amber-500/10 text-amber-800 dark:text-amber-200";case"native":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"disabled":case"unresolved":return"border-border/80 bg-background/85 text-muted-foreground"}}function Ee(t){switch(t){case"starts_on_launch":return"Starts on launch";case"needs_auth":return"Needs auth";case"needs_proxy":return"Needs proxy";case"review":return"Review";case"ready":return"Ready"}}function $e(t){if(!t)return"No model configured.";switch(t.state){case"needs_auth":return t.authReason||"Authenticate to route here.";case"needs_proxy":return t.proxyReason||"Proxy unavailable.";case"starts_on_launch":return"Auth ready. Launches locally on demand.";case"review":return"Needs manual review.";case"ready":return null}}function ze(t){switch(t){case"profile-backend":return"Explicit mapping";case"fallback-backend":return"Fallback backend";case"cliproxy-provider":return"Provider match";case"cliproxy-bridge":return"Bridge match";case"native-compatible":return"Native path";case"copilot-alias":return"Copilot alias";default:return t.replace(/-/g," ")}}function y(t){return"border-border/50 bg-background/40"}function Oe(t){switch(t){case"ready":return"bg-[linear-gradient(90deg,rgba(16,185,129,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(16,185,129,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"starts_on_launch":return"bg-[linear-gradient(90deg,rgba(14,165,233,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(14,165,233,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"needs_auth":return"bg-[linear-gradient(90deg,rgba(244,63,94,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(244,63,94,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"needs_proxy":return"bg-[linear-gradient(90deg,rgba(245,158,11,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(245,158,11,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"review":default:return"bg-[linear-gradient(180deg,rgba(255,255,255,0.74),rgba(255,255,255,0.5))] dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.8),rgba(15,23,42,0.58))]"}}function Fe(t){switch(t){case"ready":return"from-emerald-500 to-emerald-400/30";case"starts_on_launch":return"from-sky-500 to-sky-400/30";case"needs_auth":return"from-rose-500 to-rose-400/30";case"needs_proxy":return"from-amber-500 to-amber-400/30";case"review":default:return"from-slate-400 to-slate-300/20"}}function Ke(t,a){return a.nativeReadPreference?t%2===0?"bg-emerald-500/[0.06]":"bg-emerald-500/[0.08]":t%2===0?"bg-background/75":"bg-muted/18"}function Le(t){const a=[`${t.activeProfileCount} routed`,`${t.nativeProfileCount} native`];return t.mappedProfileCount>0&&a.push(`${t.mappedProfileCount} override${t.mappedProfileCount===1?"":"s"}`),a.join(" · ")}function Ve(t){return Object.entries(t).reduce((a,[l,g])=>{const j=g.trim();return a[l]=j||null,a},{})}function q(t){return Object.entries(t).filter(([,a])=>a.trim().length>0).map(([a])=>a)}function Ue(t){return t.reduce((a,l)=>{const g=l.profileName.trim();return!g||!l.backendId||(a[g]=l.backendId),a},{})}function ge(t,a){const l=Number.parseInt(t.trim(),10);return Number.isInteger(l)?String(Math.min(600,Math.max(10,l))):a}function T({title:t,description:a,icon:l,meta:g,action:j,children:o,className:D}){return e.jsxs("div",{className:u("relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/25 p-4 shadow-sm",D),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-primary/40 via-primary/10 to-transparent"}),e.jsxs("div",{className:"relative space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-primary/20 bg-primary/10 text-primary",children:l}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold tracking-tight",children:t}),g]}),e.jsx("p",{className:"mt-0.5 text-sm leading-5 text-muted-foreground",children:a})]})]}),j&&e.jsx("div",{className:"shrink-0",children:j})]}),e.jsx("div",{className:"space-y-3",children:o})]})]})}function er(){const{fetchRawConfig:t}=je(),[a,l]=d.useState(null),[g,j]=d.useState(!0),[o,D]=d.useState(!1),[I,N]=d.useState(null),[S,K]=d.useState(null),[E,Y]=d.useState(!1),[_,Q]=d.useState(!0),[L,V]=d.useState("60"),[f,P]=d.useState(""),[k,$]=d.useState({}),[x,z]=d.useState([]),w=d.useCallback(r=>{Q(r.config.enabled),V(String(r.config.timeout)),P(r.config.fallbackBackend??""),$(r.catalog.knownBackends.reduce((s,n)=>(s[n]=r.config.providerModels[n]??"",s),{})),z(Te(r.config.profileBackends))},[]),U=d.useCallback(async()=>{try{j(!0),N(null);const r=await re.imageAnalysis.get();if(!Re(r))throw new Error("Image settings returned an unexpected response. Restart the dashboard server so the new API route is available.");l(r),w(r)}catch(r){N(r instanceof Error?r.message:"Failed to load image settings.")}finally{j(!1)}},[w]);d.useEffect(()=>{U(),t()},[U,t]),d.useEffect(()=>{if(!S)return;const r=window.setTimeout(()=>K(null),2500);return()=>window.clearTimeout(r)},[S]),d.useEffect(()=>{a&&Object.keys(a.config.profileBackends).length>0&&Y(!0)},[a]);const m=d.useMemo(()=>q(k),[k]),W=d.useMemo(()=>{if(!a)return[];const r=a.catalog.knownBackends.filter(n=>m.includes(n)),s=a.catalog.knownBackends.filter(n=>!m.includes(n));return[...r,...s]},[m,a]),O=d.useMemo(()=>a?.profiles.filter(r=>r.nativeReadPreference)??[],[a]);d.useEffect(()=>{if(m.length===0){P("");return}m.includes(f)||P(m[0])},[m,f]);const A=d.useCallback(async r=>{if(!a)return!1;const s=r?.enabled??_,n=r?.providerModels??k,i=q(n),b=ge(r?.timeout??L,String(a.config.timeout)),h=r?.fallbackBackend??f,C=i.length===0?"":i.includes(h)?h:i[0],p=r?.mappingDrafts??x,R={enabled:s,timeout:b,fallbackBackend:C,providerModels:Ve(n),profileBackends:Ue(p)},ve={enabled:a.config.enabled,timeout:String(a.config.timeout),fallbackBackend:a.config.fallbackBackend??"",providerModels:a.catalog.knownBackends.reduce((v,ee)=>(v[ee]=a.config.providerModels[ee]??null,v),{}),profileBackends:a.config.profileBackends};if(JSON.stringify(R)===JSON.stringify(ve))return!0;if(s&&i.length===0)return N("Keep at least one provider model configured, or disable Image globally."),w(a),!1;try{D(!0),N(null);const v=await re.imageAnalysis.update({enabled:s,timeout:Number.parseInt(b,10),fallbackBackend:C||null,providerModels:R.providerModels,profileBackends:R.profileBackends});return l(v),w(v),K("Image settings saved."),await t(),!0}catch(v){return N(v instanceof Error?v.message:"Failed to save image settings."),w(a),!1}finally{D(!1)}},[a,_,f,t,w,x,k,L]),X=async()=>{g||o||(K(null),await Promise.all([U(),t()]))},xe=async r=>{if(!o){if(r&&m.length===0){N("Keep at least one provider model configured, or disable Image globally.");return}Q(r),await A({enabled:r})}},be=async r=>{if(!a||o)return;const s=ge(r,String(a.config.timeout));V(s),await A({timeout:s})},pe=async r=>{o||(P(r),await A({fallbackBackend:r}))},Z=async(r,s)=>{if(!a||o)return;const n=s.trim(),i={...k,[r]:n},b=q(i);if(_&&b.length===0){N("Disable Image first or keep one backend configured."),$(C=>({...C,[r]:a.config.providerModels[r]??""}));return}const h=b.length===0?"":b.includes(f)?f:b[0];$(i),P(h),await A({providerModels:i,fallbackBackend:h})},fe=(r,s)=>{z(n=>n.map(i=>i.id===r?{...i,...s}:i))},H=async r=>{o||(z(r),await A({mappingDrafts:r}))},he=x.filter(r=>r.profileName.trim()&&r.backendId).length;return g?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(J,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading image settings..."})]})}):a?e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${I||S?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[I&&e.jsxs(ae,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(le,{className:"h-4 w-4"}),e.jsx(te,{children:I})]}),S&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ke,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:S})]})]}),e.jsx(Ne,{className:"min-h-0 flex-1",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/30 p-4 shadow-sm",children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-primary/70 via-primary/20 to-transparent"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-[0.035]",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"inline-flex h-8 w-8 items-center justify-center rounded-xl border border-primary/20 bg-primary/8 text-primary",children:e.jsx(oe,{className:"h-4 w-4"})}),e.jsx("p",{className:"text-sm font-semibold tracking-tight",children:"Image"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(c,{className:u("border",De(a.summary.state)),children:a.summary.title}),e.jsx("span",{children:Le(a.summary)})]})]}),e.jsx(B,{variant:"ghost",size:"sm",onClick:X,disabled:g||o,"aria-label":"Refresh",title:"Refresh",children:e.jsx(J,{className:`h-4 w-4 ${g?"animate-spin":""}`})})]}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] border bg-background/72 px-3 py-2.5 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Active routes"}),e.jsx("div",{className:"mt-1.5 text-xl font-semibold text-foreground",children:a.summary.activeProfileCount}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Current target path"})]}),e.jsxs("div",{className:"rounded-[18px] border bg-background/72 px-3 py-2.5 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Native path"}),e.jsx("div",{className:"mt-1.5 text-xl font-semibold text-foreground",children:a.summary.nativeProfileCount}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Skip transformer"})]})]})]})]}),e.jsxs(T,{tone:"amber",eyebrow:"Control deck",title:"Core setup",description:"Global toggle, timeout, and fallback.",icon:e.jsx(we,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px]",children:[m.length," configured"]}),children:[e.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[e.jsxs("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Enabled"}),e.jsxs("div",{className:"mt-2.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:_?"Transformer on":"Transformer off"}),e.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Profile flags stay untouched."})]}),e.jsx(ye,{checked:_,onCheckedChange:r=>{xe(r)},disabled:o})]})]}),e.jsxs("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Timeout"}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-2",children:[e.jsx(G,{value:L,onChange:r=>V(r.target.value),inputMode:"numeric",className:"h-10 border-amber-500/15 bg-background/90 text-base",disabled:o,onBlur:r=>{be(r.currentTarget.value)},onKeyDown:r=>{r.key==="Enter"&&r.currentTarget.blur()}}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"sec"})]}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Keeps large reads from hanging."})]}),e.jsxs("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Fallback backend"}),e.jsx("div",{className:"mt-2.5",children:e.jsxs(se,{value:f||M,onValueChange:r=>{pe(r===M?"":r)},disabled:o,children:[e.jsx(ne,{className:"h-10 border-amber-500/15 bg-background/90",children:e.jsx(ie,{placeholder:"Choose backend"})}),e.jsx(de,{children:m.length===0?e.jsx(F,{value:M,children:"Configure a model first"}):m.map(r=>e.jsx(F,{value:r,children:r},r))})]})}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Used when no direct route exists."})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[he," overrides"]}),e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[O.length," native"]}),e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[f||"No fallback"," fallback"]})]})]}),e.jsx(T,{tone:"cyan",eyebrow:"Route inventory",title:"Backend routes",description:"Model entry plus route health.",icon:e.jsx(Ce,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",className:"border-cyan-500/25 bg-cyan-500/10 text-[10px]",children:[W.length," backends"]}),children:e.jsx("div",{className:"overflow-hidden rounded-[20px] border border-cyan-500/12 bg-background/65 shadow-sm backdrop-blur-sm",children:W.map((r,s)=>{const n=a.backends.find(p=>p.backendId===r),i=n?.displayName||r,b=k[r]??"",h=$e(n),C=b?[`${n?.profilesUsing??0} active`,n?.authReadiness==="missing"?"auth missing":n?.proxyReadiness==="stopped"?"starts on launch":null].filter(Boolean).join(" · "):"No model configured.";return e.jsxs("div",{className:u("relative px-3 py-3 md:px-4",s>0&&"border-t border-cyan-500/10",Oe(n?.state)),children:[e.jsx("div",{className:u("absolute bottom-3 left-0 top-3 w-1 rounded-r-full bg-gradient-to-b",Fe(n?.state))}),e.jsxs("div",{className:"pl-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground",children:i}),e.jsx(c,{variant:"outline",className:"font-mono text-[10px]",children:r}),n?.profilesUsing?e.jsxs(c,{variant:"outline",className:"border-cyan-500/20 bg-cyan-500/10 text-[10px]",children:[n.profilesUsing," active"]}):null]}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:C})]}),e.jsx(c,{className:u("border",n?Ie(n.state):"border-border/80 bg-background/85 text-muted-foreground"),children:n?Ee(n.state):"Inactive"})]}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx(G,{className:"h-10 flex-1 border-cyan-500/15 bg-background/88 text-base",placeholder:"Set model",value:b,disabled:o,onChange:p=>$(R=>({...R,[r]:p.target.value})),onBlur:p=>{Z(r,p.currentTarget.value)},onKeyDown:p=>{p.key==="Enter"&&p.currentTarget.blur()}}),b.trim().length>0&&e.jsx(B,{type:"button",variant:"outline",size:"sm",className:"h-10 sm:self-stretch",disabled:o,onClick:()=>{Z(r,"")},children:"Clear"})]}),h&&e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:h})]})]},r)})})}),e.jsx(T,{tone:"emerald",eyebrow:"Native path",title:"Native reading",description:"Profiles that skip the transformer.",icon:e.jsx(Be,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",children:[O.length," profiles"]}),children:O.length===0?e.jsx("div",{className:u("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",y()),children:"No profiles prefer native reading yet."}):e.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:O.map(r=>e.jsx("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:r.name}),e.jsx(c,{variant:"outline",className:"text-[10px]",children:r.kind==="variant"?"Variant":"Profile"}),e.jsx(c,{variant:"outline",className:"text-[10px]",children:r.nativeImageCapable?"Verified":"Review"})]}),e.jsxs("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:[r.profileModel||"Model not detected"," ·"," ",r.nativeImageReason||"Native read preferred."]})]}),e.jsx(c,{className:u("border",ue(r.currentTargetMode)),children:me(r.currentTargetMode)})]})},`native-${r.kind}-${r.name}`))})}),e.jsxs(T,{tone:"slate",eyebrow:"Override lab",title:"Profile routing",description:"Only for explicit route overrides.",icon:e.jsx(Ae,{className:"h-4 w-4"}),meta:e.jsx(c,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px] text-amber-800 dark:text-amber-200",children:"Advanced"}),action:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(B,{type:"button",variant:"outline",size:"sm",onClick:()=>Y(r=>!r),children:[E?e.jsx(Se,{className:"mr-1 h-4 w-4"}):e.jsx(_e,{className:"mr-1 h-4 w-4"}),E?"Hide":"Show"]}),E&&e.jsxs(B,{type:"button",variant:"outline",size:"sm",onClick:()=>z(r=>[...r,{id:`mapping-${Date.now()}`,profileName:"",backendId:m[0]??""}]),disabled:m.length===0||o,children:[e.jsx(Pe,{className:"mr-1 h-4 w-4"}),"Add mapping"]})]}),className:"border-dashed",children:[e.jsx("datalist",{id:"image-profile-suggestions",children:a.catalog.profileNames.map(r=>e.jsx("option",{value:r},r))}),E?e.jsx("div",{className:"space-y-2",children:x.length===0?e.jsx("div",{className:u("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",y()),children:"No explicit overrides saved."}):e.jsx("div",{className:"space-y-2",children:x.map(r=>e.jsxs("div",{className:"rounded-[18px] border border-slate-400/20 bg-[linear-gradient(180deg,rgba(255,255,255,0.72),rgba(248,250,252,0.52))] p-3 shadow-sm dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.84),rgba(15,23,42,0.56))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] leading-4 text-muted-foreground",children:[e.jsx("span",{children:"Direct override"}),!(r.profileName.trim()&&r.backendId)&&e.jsx(c,{variant:"outline",className:"text-[10px]",children:"Draft"})]}),e.jsxs(B,{type:"button",variant:"ghost",size:"sm",disabled:o,onClick:()=>{const s=x.filter(n=>n.id!==r.id);H(s)},children:[e.jsx(Me,{className:"mr-1 h-4 w-4"}),"Remove"]})]}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(G,{value:r.profileName,list:"image-profile-suggestions",disabled:o,placeholder:"Profile or variant name",className:"h-10 border-slate-400/15 bg-background/88 text-base",onChange:s=>{fe(r.id,{profileName:s.target.value})},onBlur:s=>{const n=x.map(i=>i.id===r.id?{...i,profileName:s.currentTarget.value.trim()}:i);H(n)},onKeyDown:s=>{s.key==="Enter"&&s.currentTarget.blur()}}),e.jsxs(se,{value:r.backendId||M,disabled:o,onValueChange:s=>{const n=x.map(i=>i.id===r.id?{...i,backendId:s===M?"":s}:i);H(n)},children:[e.jsx(ne,{className:"h-10 border-slate-400/15 bg-background/88",children:e.jsx(ie,{placeholder:"Choose backend"})}),e.jsx(de,{children:m.length===0?e.jsx(F,{value:M,children:"Configure a model first"}):m.map(s=>e.jsx(F,{value:s,children:s},s))})]})]})]},r.id))})}):e.jsxs("div",{className:u("rounded-[18px] border border-dashed px-3.5 py-3 text-sm text-muted-foreground",y()),children:["Hidden by default.",x.length>0?` ${x.length} override${x.length===1?"":"s"} saved.`:" No overrides saved."]})]}),e.jsx(T,{tone:"slate",eyebrow:"Audit view",title:"Coverage",description:"Read-only routing ledger for the current path.",icon:e.jsx(oe,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",children:[a.profiles.length," profiles"]}),children:e.jsx("div",{className:"overflow-hidden rounded-[20px] border border-slate-400/15 bg-background/75 shadow-sm backdrop-blur-sm",children:a.profiles.map((r,s)=>e.jsxs("div",{className:u("grid gap-2 px-3.5 py-2.5 md:grid-cols-[minmax(0,1fr)_auto] md:items-center",s>0&&"border-t border-slate-400/12",Ke(s,r)),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:r.name}),e.jsx(c,{variant:"outline",className:"text-[10px]",children:r.kind==="variant"?"Variant":"Profile"}),e.jsx(c,{variant:"outline",className:"font-mono text-[10px] uppercase",children:r.target}),r.nativeReadPreference&&e.jsx(c,{variant:"outline",className:"border-emerald-500/20 bg-emerald-500/10 text-[10px]",children:"Native"})]}),e.jsxs("div",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:[r.backendDisplayName||r.profileModel||"Native file access"," ·"," ",ze(r.resolutionSource)]})]}),e.jsxs("div",{className:"flex items-center gap-2 md:justify-end",children:[r.profileModel&&e.jsx(c,{variant:"outline",className:"font-mono text-[10px]",children:r.profileModel}),e.jsx(c,{className:u("border",ue(r.currentTargetMode)),children:me(r.currentTargetMode)})]})]},`${r.kind}-${r.name}`))})})]})})]}):e.jsxs("div",{className:"p-5",children:[e.jsxs(ae,{variant:"destructive",children:[e.jsx(le,{className:"h-4 w-4"}),e.jsx(te,{children:I??"Failed to load image settings."})]}),e.jsx("div",{className:"mt-4",children:e.jsxs(B,{variant:"outline",size:"sm",onClick:X,children:[e.jsx(J,{className:"mr-1 h-4 w-4"}),"Retry"]})})]})}export{er as default};
|
|
1
|
+
import{j as e}from"./radix-ui-C98W0NRG.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{bl as je,Y as re,b5 as ae,b7 as te,d as B,n as Ne,B as c,c as u,aA as ye,I as G,r as se,s as ne,t as ie,v as de,w as F}from"./index-Corv1lSo.js";import{R as J,v as le,w as ke,a5 as oe,ar as we,A as Ce,a7 as Be,am as Me,s as Se,r as _e,a6 as Pe,aC as Ae}from"./icons-CeH5899d.js";import"./tanstack-CfKik0yL.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const M="__no_backend__";function ce(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(a=>typeof a=="string")}function Re(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const a=t;return!!a.config&&typeof a.config.enabled=="boolean"&&typeof a.config.timeout=="number"&&ce(a.config.providerModels)&&(a.config.fallbackBackend===null||typeof a.config.fallbackBackend=="string")&&ce(a.config.profileBackends)&&!!a.summary&&typeof a.summary.state=="string"&&typeof a.summary.title=="string"&&typeof a.summary.detail=="string"&&Array.isArray(a.backends)&&Array.isArray(a.profiles)&&!!a.catalog&&Array.isArray(a.catalog.knownBackends)&&Array.isArray(a.catalog.profileNames)&&typeof a.summary.nativeProfileCount=="number"}function Te(t){return Object.entries(t).sort(([a],[l])=>a.localeCompare(l)).map(([a,l],g)=>({id:`${a}-${l}-${g}`,profileName:a,backendId:l}))}function De(t){switch(t){case"ready":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-900 dark:text-emerald-200";case"partial":return"border-amber-500/25 bg-amber-500/10 text-amber-900 dark:text-amber-200";case"needs_setup":return"border-rose-500/25 bg-rose-500/10 text-rose-900 dark:text-rose-200";case"disabled":return"border-border/80 bg-background/85 text-muted-foreground"}}function Ie(t){switch(t){case"ready":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"starts_on_launch":return"border-sky-500/25 bg-sky-500/10 text-sky-800 dark:text-sky-200";case"needs_auth":return"border-rose-500/25 bg-rose-500/10 text-rose-800 dark:text-rose-200";case"needs_proxy":return"border-amber-500/25 bg-amber-500/10 text-amber-800 dark:text-amber-200";case"review":return"border-border/80 bg-background/85 text-muted-foreground"}}function me(t){switch(t){case"active":return"Active";case"bypassed":return"Bypassed";case"fallback":return"Native fallback";case"setup":return"Needs setup";case"disabled":return"Disabled";case"native":return"Native";case"unresolved":return"Native only"}}function ue(t){switch(t){case"active":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"bypassed":return"border-sky-500/25 bg-sky-500/10 text-sky-800 dark:text-sky-200";case"fallback":case"setup":return"border-amber-500/25 bg-amber-500/10 text-amber-800 dark:text-amber-200";case"native":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"disabled":case"unresolved":return"border-border/80 bg-background/85 text-muted-foreground"}}function Ee(t){switch(t){case"starts_on_launch":return"Starts on launch";case"needs_auth":return"Needs auth";case"needs_proxy":return"Needs proxy";case"review":return"Review";case"ready":return"Ready"}}function $e(t){if(!t)return"No model configured.";switch(t.state){case"needs_auth":return t.authReason||"Authenticate to route here.";case"needs_proxy":return t.proxyReason||"Proxy unavailable.";case"starts_on_launch":return"Auth ready. Launches locally on demand.";case"review":return"Needs manual review.";case"ready":return null}}function ze(t){switch(t){case"profile-backend":return"Explicit mapping";case"fallback-backend":return"Fallback backend";case"cliproxy-provider":return"Provider match";case"cliproxy-bridge":return"Bridge match";case"native-compatible":return"Native path";case"copilot-alias":return"Copilot alias";default:return t.replace(/-/g," ")}}function y(t){return"border-border/50 bg-background/40"}function Oe(t){switch(t){case"ready":return"bg-[linear-gradient(90deg,rgba(16,185,129,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(16,185,129,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"starts_on_launch":return"bg-[linear-gradient(90deg,rgba(14,165,233,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(14,165,233,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"needs_auth":return"bg-[linear-gradient(90deg,rgba(244,63,94,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(244,63,94,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"needs_proxy":return"bg-[linear-gradient(90deg,rgba(245,158,11,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(245,158,11,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"review":default:return"bg-[linear-gradient(180deg,rgba(255,255,255,0.74),rgba(255,255,255,0.5))] dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.8),rgba(15,23,42,0.58))]"}}function Fe(t){switch(t){case"ready":return"from-emerald-500 to-emerald-400/30";case"starts_on_launch":return"from-sky-500 to-sky-400/30";case"needs_auth":return"from-rose-500 to-rose-400/30";case"needs_proxy":return"from-amber-500 to-amber-400/30";case"review":default:return"from-slate-400 to-slate-300/20"}}function Ke(t,a){return a.nativeReadPreference?t%2===0?"bg-emerald-500/[0.06]":"bg-emerald-500/[0.08]":t%2===0?"bg-background/75":"bg-muted/18"}function Le(t){const a=[`${t.activeProfileCount} routed`,`${t.nativeProfileCount} native`];return t.mappedProfileCount>0&&a.push(`${t.mappedProfileCount} override${t.mappedProfileCount===1?"":"s"}`),a.join(" · ")}function Ve(t){return Object.entries(t).reduce((a,[l,g])=>{const j=g.trim();return a[l]=j||null,a},{})}function q(t){return Object.entries(t).filter(([,a])=>a.trim().length>0).map(([a])=>a)}function Ue(t){return t.reduce((a,l)=>{const g=l.profileName.trim();return!g||!l.backendId||(a[g]=l.backendId),a},{})}function ge(t,a){const l=Number.parseInt(t.trim(),10);return Number.isInteger(l)?String(Math.min(600,Math.max(10,l))):a}function T({title:t,description:a,icon:l,meta:g,action:j,children:o,className:D}){return e.jsxs("div",{className:u("relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/25 p-4 shadow-sm",D),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-primary/40 via-primary/10 to-transparent"}),e.jsxs("div",{className:"relative space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-primary/20 bg-primary/10 text-primary",children:l}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold tracking-tight",children:t}),g]}),e.jsx("p",{className:"mt-0.5 text-sm leading-5 text-muted-foreground",children:a})]})]}),j&&e.jsx("div",{className:"shrink-0",children:j})]}),e.jsx("div",{className:"space-y-3",children:o})]})]})}function er(){const{fetchRawConfig:t}=je(),[a,l]=d.useState(null),[g,j]=d.useState(!0),[o,D]=d.useState(!1),[I,N]=d.useState(null),[S,K]=d.useState(null),[E,Y]=d.useState(!1),[_,Q]=d.useState(!0),[L,V]=d.useState("60"),[f,P]=d.useState(""),[k,$]=d.useState({}),[x,z]=d.useState([]),w=d.useCallback(r=>{Q(r.config.enabled),V(String(r.config.timeout)),P(r.config.fallbackBackend??""),$(r.catalog.knownBackends.reduce((s,n)=>(s[n]=r.config.providerModels[n]??"",s),{})),z(Te(r.config.profileBackends))},[]),U=d.useCallback(async()=>{try{j(!0),N(null);const r=await re.imageAnalysis.get();if(!Re(r))throw new Error("Image settings returned an unexpected response. Restart the dashboard server so the new API route is available.");l(r),w(r)}catch(r){N(r instanceof Error?r.message:"Failed to load image settings.")}finally{j(!1)}},[w]);d.useEffect(()=>{U(),t()},[U,t]),d.useEffect(()=>{if(!S)return;const r=window.setTimeout(()=>K(null),2500);return()=>window.clearTimeout(r)},[S]),d.useEffect(()=>{a&&Object.keys(a.config.profileBackends).length>0&&Y(!0)},[a]);const m=d.useMemo(()=>q(k),[k]),W=d.useMemo(()=>{if(!a)return[];const r=a.catalog.knownBackends.filter(n=>m.includes(n)),s=a.catalog.knownBackends.filter(n=>!m.includes(n));return[...r,...s]},[m,a]),O=d.useMemo(()=>a?.profiles.filter(r=>r.nativeReadPreference)??[],[a]);d.useEffect(()=>{if(m.length===0){P("");return}m.includes(f)||P(m[0])},[m,f]);const A=d.useCallback(async r=>{if(!a)return!1;const s=r?.enabled??_,n=r?.providerModels??k,i=q(n),b=ge(r?.timeout??L,String(a.config.timeout)),h=r?.fallbackBackend??f,C=i.length===0?"":i.includes(h)?h:i[0],p=r?.mappingDrafts??x,R={enabled:s,timeout:b,fallbackBackend:C,providerModels:Ve(n),profileBackends:Ue(p)},ve={enabled:a.config.enabled,timeout:String(a.config.timeout),fallbackBackend:a.config.fallbackBackend??"",providerModels:a.catalog.knownBackends.reduce((v,ee)=>(v[ee]=a.config.providerModels[ee]??null,v),{}),profileBackends:a.config.profileBackends};if(JSON.stringify(R)===JSON.stringify(ve))return!0;if(s&&i.length===0)return N("Keep at least one provider model configured, or disable Image globally."),w(a),!1;try{D(!0),N(null);const v=await re.imageAnalysis.update({enabled:s,timeout:Number.parseInt(b,10),fallbackBackend:C||null,providerModels:R.providerModels,profileBackends:R.profileBackends});return l(v),w(v),K("Image settings saved."),await t(),!0}catch(v){return N(v instanceof Error?v.message:"Failed to save image settings."),w(a),!1}finally{D(!1)}},[a,_,f,t,w,x,k,L]),X=async()=>{g||o||(K(null),await Promise.all([U(),t()]))},xe=async r=>{if(!o){if(r&&m.length===0){N("Keep at least one provider model configured, or disable Image globally.");return}Q(r),await A({enabled:r})}},be=async r=>{if(!a||o)return;const s=ge(r,String(a.config.timeout));V(s),await A({timeout:s})},pe=async r=>{o||(P(r),await A({fallbackBackend:r}))},Z=async(r,s)=>{if(!a||o)return;const n=s.trim(),i={...k,[r]:n},b=q(i);if(_&&b.length===0){N("Disable Image first or keep one backend configured."),$(C=>({...C,[r]:a.config.providerModels[r]??""}));return}const h=b.length===0?"":b.includes(f)?f:b[0];$(i),P(h),await A({providerModels:i,fallbackBackend:h})},fe=(r,s)=>{z(n=>n.map(i=>i.id===r?{...i,...s}:i))},H=async r=>{o||(z(r),await A({mappingDrafts:r}))},he=x.filter(r=>r.profileName.trim()&&r.backendId).length;return g?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(J,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading image settings..."})]})}):a?e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${I||S?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[I&&e.jsxs(ae,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(le,{className:"h-4 w-4"}),e.jsx(te,{children:I})]}),S&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ke,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:S})]})]}),e.jsx(Ne,{className:"min-h-0 flex-1",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/30 p-4 shadow-sm",children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-primary/70 via-primary/20 to-transparent"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-[0.035]",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"inline-flex h-8 w-8 items-center justify-center rounded-xl border border-primary/20 bg-primary/8 text-primary",children:e.jsx(oe,{className:"h-4 w-4"})}),e.jsx("p",{className:"text-sm font-semibold tracking-tight",children:"Image"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(c,{className:u("border",De(a.summary.state)),children:a.summary.title}),e.jsx("span",{children:Le(a.summary)})]})]}),e.jsx(B,{variant:"ghost",size:"sm",onClick:X,disabled:g||o,"aria-label":"Refresh",title:"Refresh",children:e.jsx(J,{className:`h-4 w-4 ${g?"animate-spin":""}`})})]}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] border bg-background/72 px-3 py-2.5 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Active routes"}),e.jsx("div",{className:"mt-1.5 text-xl font-semibold text-foreground",children:a.summary.activeProfileCount}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Current target path"})]}),e.jsxs("div",{className:"rounded-[18px] border bg-background/72 px-3 py-2.5 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Native path"}),e.jsx("div",{className:"mt-1.5 text-xl font-semibold text-foreground",children:a.summary.nativeProfileCount}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Skip transformer"})]})]})]})]}),e.jsxs(T,{tone:"amber",eyebrow:"Control deck",title:"Core setup",description:"Global toggle, timeout, and fallback.",icon:e.jsx(we,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px]",children:[m.length," configured"]}),children:[e.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[e.jsxs("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Enabled"}),e.jsxs("div",{className:"mt-2.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:_?"Transformer on":"Transformer off"}),e.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Profile flags stay untouched."})]}),e.jsx(ye,{checked:_,onCheckedChange:r=>{xe(r)},disabled:o})]})]}),e.jsxs("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Timeout"}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-2",children:[e.jsx(G,{value:L,onChange:r=>V(r.target.value),inputMode:"numeric",className:"h-10 border-amber-500/15 bg-background/90 text-base",disabled:o,onBlur:r=>{be(r.currentTarget.value)},onKeyDown:r=>{r.key==="Enter"&&r.currentTarget.blur()}}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"sec"})]}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Keeps large reads from hanging."})]}),e.jsxs("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Fallback backend"}),e.jsx("div",{className:"mt-2.5",children:e.jsxs(se,{value:f||M,onValueChange:r=>{pe(r===M?"":r)},disabled:o,children:[e.jsx(ne,{className:"h-10 border-amber-500/15 bg-background/90",children:e.jsx(ie,{placeholder:"Choose backend"})}),e.jsx(de,{children:m.length===0?e.jsx(F,{value:M,children:"Configure a model first"}):m.map(r=>e.jsx(F,{value:r,children:r},r))})]})}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Used when no direct route exists."})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[he," overrides"]}),e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[O.length," native"]}),e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[f||"No fallback"," fallback"]})]})]}),e.jsx(T,{tone:"cyan",eyebrow:"Route inventory",title:"Backend routes",description:"Model entry plus route health.",icon:e.jsx(Ce,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",className:"border-cyan-500/25 bg-cyan-500/10 text-[10px]",children:[W.length," backends"]}),children:e.jsx("div",{className:"overflow-hidden rounded-[20px] border border-cyan-500/12 bg-background/65 shadow-sm backdrop-blur-sm",children:W.map((r,s)=>{const n=a.backends.find(p=>p.backendId===r),i=n?.displayName||r,b=k[r]??"",h=$e(n),C=b?[`${n?.profilesUsing??0} active`,n?.authReadiness==="missing"?"auth missing":n?.proxyReadiness==="stopped"?"starts on launch":null].filter(Boolean).join(" · "):"No model configured.";return e.jsxs("div",{className:u("relative px-3 py-3 md:px-4",s>0&&"border-t border-cyan-500/10",Oe(n?.state)),children:[e.jsx("div",{className:u("absolute bottom-3 left-0 top-3 w-1 rounded-r-full bg-gradient-to-b",Fe(n?.state))}),e.jsxs("div",{className:"pl-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground",children:i}),e.jsx(c,{variant:"outline",className:"font-mono text-[10px]",children:r}),n?.profilesUsing?e.jsxs(c,{variant:"outline",className:"border-cyan-500/20 bg-cyan-500/10 text-[10px]",children:[n.profilesUsing," active"]}):null]}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:C})]}),e.jsx(c,{className:u("border",n?Ie(n.state):"border-border/80 bg-background/85 text-muted-foreground"),children:n?Ee(n.state):"Inactive"})]}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx(G,{className:"h-10 flex-1 border-cyan-500/15 bg-background/88 text-base",placeholder:"Set model",value:b,disabled:o,onChange:p=>$(R=>({...R,[r]:p.target.value})),onBlur:p=>{Z(r,p.currentTarget.value)},onKeyDown:p=>{p.key==="Enter"&&p.currentTarget.blur()}}),b.trim().length>0&&e.jsx(B,{type:"button",variant:"outline",size:"sm",className:"h-10 sm:self-stretch",disabled:o,onClick:()=>{Z(r,"")},children:"Clear"})]}),h&&e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:h})]})]},r)})})}),e.jsx(T,{tone:"emerald",eyebrow:"Native path",title:"Native reading",description:"Profiles that skip the transformer.",icon:e.jsx(Be,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",children:[O.length," profiles"]}),children:O.length===0?e.jsx("div",{className:u("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",y()),children:"No profiles prefer native reading yet."}):e.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:O.map(r=>e.jsx("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:r.name}),e.jsx(c,{variant:"outline",className:"text-[10px]",children:r.kind==="variant"?"Variant":"Profile"}),e.jsx(c,{variant:"outline",className:"text-[10px]",children:r.nativeImageCapable?"Verified":"Review"})]}),e.jsxs("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:[r.profileModel||"Model not detected"," ·"," ",r.nativeImageReason||"Native read preferred."]})]}),e.jsx(c,{className:u("border",ue(r.currentTargetMode)),children:me(r.currentTargetMode)})]})},`native-${r.kind}-${r.name}`))})}),e.jsxs(T,{tone:"slate",eyebrow:"Override lab",title:"Profile routing",description:"Only for explicit route overrides.",icon:e.jsx(Ae,{className:"h-4 w-4"}),meta:e.jsx(c,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px] text-amber-800 dark:text-amber-200",children:"Advanced"}),action:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(B,{type:"button",variant:"outline",size:"sm",onClick:()=>Y(r=>!r),children:[E?e.jsx(Se,{className:"mr-1 h-4 w-4"}):e.jsx(_e,{className:"mr-1 h-4 w-4"}),E?"Hide":"Show"]}),E&&e.jsxs(B,{type:"button",variant:"outline",size:"sm",onClick:()=>z(r=>[...r,{id:`mapping-${Date.now()}`,profileName:"",backendId:m[0]??""}]),disabled:m.length===0||o,children:[e.jsx(Pe,{className:"mr-1 h-4 w-4"}),"Add mapping"]})]}),className:"border-dashed",children:[e.jsx("datalist",{id:"image-profile-suggestions",children:a.catalog.profileNames.map(r=>e.jsx("option",{value:r},r))}),E?e.jsx("div",{className:"space-y-2",children:x.length===0?e.jsx("div",{className:u("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",y()),children:"No explicit overrides saved."}):e.jsx("div",{className:"space-y-2",children:x.map(r=>e.jsxs("div",{className:"rounded-[18px] border border-slate-400/20 bg-[linear-gradient(180deg,rgba(255,255,255,0.72),rgba(248,250,252,0.52))] p-3 shadow-sm dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.84),rgba(15,23,42,0.56))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] leading-4 text-muted-foreground",children:[e.jsx("span",{children:"Direct override"}),!(r.profileName.trim()&&r.backendId)&&e.jsx(c,{variant:"outline",className:"text-[10px]",children:"Draft"})]}),e.jsxs(B,{type:"button",variant:"ghost",size:"sm",disabled:o,onClick:()=>{const s=x.filter(n=>n.id!==r.id);H(s)},children:[e.jsx(Me,{className:"mr-1 h-4 w-4"}),"Remove"]})]}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(G,{value:r.profileName,list:"image-profile-suggestions",disabled:o,placeholder:"Profile or variant name",className:"h-10 border-slate-400/15 bg-background/88 text-base",onChange:s=>{fe(r.id,{profileName:s.target.value})},onBlur:s=>{const n=x.map(i=>i.id===r.id?{...i,profileName:s.currentTarget.value.trim()}:i);H(n)},onKeyDown:s=>{s.key==="Enter"&&s.currentTarget.blur()}}),e.jsxs(se,{value:r.backendId||M,disabled:o,onValueChange:s=>{const n=x.map(i=>i.id===r.id?{...i,backendId:s===M?"":s}:i);H(n)},children:[e.jsx(ne,{className:"h-10 border-slate-400/15 bg-background/88",children:e.jsx(ie,{placeholder:"Choose backend"})}),e.jsx(de,{children:m.length===0?e.jsx(F,{value:M,children:"Configure a model first"}):m.map(s=>e.jsx(F,{value:s,children:s},s))})]})]})]},r.id))})}):e.jsxs("div",{className:u("rounded-[18px] border border-dashed px-3.5 py-3 text-sm text-muted-foreground",y()),children:["Hidden by default.",x.length>0?` ${x.length} override${x.length===1?"":"s"} saved.`:" No overrides saved."]})]}),e.jsx(T,{tone:"slate",eyebrow:"Audit view",title:"Coverage",description:"Read-only routing ledger for the current path.",icon:e.jsx(oe,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",children:[a.profiles.length," profiles"]}),children:e.jsx("div",{className:"overflow-hidden rounded-[20px] border border-slate-400/15 bg-background/75 shadow-sm backdrop-blur-sm",children:a.profiles.map((r,s)=>e.jsxs("div",{className:u("grid gap-2 px-3.5 py-2.5 md:grid-cols-[minmax(0,1fr)_auto] md:items-center",s>0&&"border-t border-slate-400/12",Ke(s,r)),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:r.name}),e.jsx(c,{variant:"outline",className:"text-[10px]",children:r.kind==="variant"?"Variant":"Profile"}),e.jsx(c,{variant:"outline",className:"font-mono text-[10px] uppercase",children:r.target}),r.nativeReadPreference&&e.jsx(c,{variant:"outline",className:"border-emerald-500/20 bg-emerald-500/10 text-[10px]",children:"Native"})]}),e.jsxs("div",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:[r.backendDisplayName||r.profileModel||"Native file access"," ·"," ",ze(r.resolutionSource)]})]}),e.jsxs("div",{className:"flex items-center gap-2 md:justify-end",children:[r.profileModel&&e.jsx(c,{variant:"outline",className:"font-mono text-[10px]",children:r.profileModel}),e.jsx(c,{className:u("border",ue(r.currentTargetMode)),children:me(r.currentTargetMode)})]})]},`${r.kind}-${r.name}`))})})]})})]}):e.jsxs("div",{className:"p-5",children:[e.jsxs(ae,{variant:"destructive",children:[e.jsx(le,{className:"h-4 w-4"}),e.jsx(te,{children:I??"Failed to load image settings."})]}),e.jsx("div",{className:"mt-4",children:e.jsxs(B,{variant:"outline",size:"sm",onClick:X,children:[e.jsx(J,{className:"mr-1 h-4 w-4"}),"Retry"]})})]})}export{er as default};
|