@kaitranntt/ccs 7.56.0-dev.1 → 7.56.0-dev.2
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/README.md +2 -0
- package/dist/api/services/profile-lifecycle-service.d.ts.map +1 -1
- package/dist/api/services/profile-lifecycle-service.js +10 -10
- package/dist/api/services/profile-lifecycle-service.js.map +1 -1
- package/dist/api/services/profile-writer.d.ts.map +1 -1
- package/dist/api/services/profile-writer.js +33 -36
- package/dist/api/services/profile-writer.js.map +1 -1
- package/dist/auth/profile-registry.d.ts.map +1 -1
- package/dist/auth/profile-registry.js +46 -48
- package/dist/auth/profile-registry.js.map +1 -1
- package/dist/cliproxy/account-manager.d.ts +1 -1
- package/dist/cliproxy/account-manager.d.ts.map +1 -1
- package/dist/cliproxy/account-manager.js +4 -1
- package/dist/cliproxy/account-manager.js.map +1 -1
- package/dist/cliproxy/accounts/index.d.ts +1 -1
- package/dist/cliproxy/accounts/index.d.ts.map +1 -1
- package/dist/cliproxy/accounts/index.js +4 -1
- package/dist/cliproxy/accounts/index.js.map +1 -1
- package/dist/cliproxy/accounts/query.d.ts.map +1 -1
- package/dist/cliproxy/accounts/query.js +4 -6
- package/dist/cliproxy/accounts/query.js.map +1 -1
- package/dist/cliproxy/accounts/registry.d.ts +2 -2
- package/dist/cliproxy/accounts/registry.d.ts.map +1 -1
- package/dist/cliproxy/accounts/registry.js +292 -320
- package/dist/cliproxy/accounts/registry.js.map +1 -1
- package/dist/cliproxy/accounts/token-file-ops.d.ts +16 -1
- package/dist/cliproxy/accounts/token-file-ops.d.ts.map +1 -1
- package/dist/cliproxy/accounts/token-file-ops.js +55 -3
- package/dist/cliproxy/accounts/token-file-ops.js.map +1 -1
- package/dist/cliproxy/ai-providers/config-store.d.ts.map +1 -1
- package/dist/cliproxy/ai-providers/config-store.js +37 -4
- package/dist/cliproxy/ai-providers/config-store.js.map +1 -1
- package/dist/cliproxy/ai-providers/service.d.ts +2 -2
- package/dist/cliproxy/ai-providers/service.d.ts.map +1 -1
- package/dist/cliproxy/ai-providers/service.js +39 -10
- package/dist/cliproxy/ai-providers/service.js.map +1 -1
- package/dist/cliproxy/ai-providers/types.d.ts +2 -0
- package/dist/cliproxy/ai-providers/types.d.ts.map +1 -1
- package/dist/cliproxy/ai-providers/types.js.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.d.ts +1 -0
- package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.js +31 -69
- package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
- package/dist/cliproxy/auth/oauth-process.d.ts +1 -0
- package/dist/cliproxy/auth/oauth-process.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-process.js +5 -5
- package/dist/cliproxy/auth/oauth-process.js.map +1 -1
- package/dist/cliproxy/auth/token-manager.d.ts +1 -1
- package/dist/cliproxy/auth/token-manager.d.ts.map +1 -1
- package/dist/cliproxy/auth/token-manager.js +53 -20
- package/dist/cliproxy/auth/token-manager.js.map +1 -1
- package/dist/cliproxy/auth-token-manager.d.ts.map +1 -1
- package/dist/cliproxy/auth-token-manager.js +47 -50
- package/dist/cliproxy/auth-token-manager.js.map +1 -1
- package/dist/cliproxy/executor/index.js +1 -1
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/services/variant-config-adapter.d.ts.map +1 -1
- package/dist/cliproxy/services/variant-config-adapter.js +43 -39
- package/dist/cliproxy/services/variant-config-adapter.js.map +1 -1
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.d.ts +0 -5
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js +6 -16
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/resolve-lifecycle-port.d.ts +6 -0
- package/dist/commands/cliproxy/resolve-lifecycle-port.d.ts.map +1 -0
- package/dist/commands/cliproxy/resolve-lifecycle-port.js +15 -0
- package/dist/commands/cliproxy/resolve-lifecycle-port.js.map +1 -0
- package/dist/commands/config-auth/disable-command.d.ts.map +1 -1
- package/dist/commands/config-auth/disable-command.js +8 -8
- package/dist/commands/config-auth/disable-command.js.map +1 -1
- package/dist/commands/config-auth/setup-command.d.ts.map +1 -1
- package/dist/commands/config-auth/setup-command.js +9 -11
- package/dist/commands/config-auth/setup-command.js.map +1 -1
- package/dist/commands/copilot-command.js +11 -11
- package/dist/commands/copilot-command.js.map +1 -1
- package/dist/commands/cursor-command.d.ts.map +1 -1
- package/dist/commands/cursor-command.js +11 -11
- package/dist/commands/cursor-command.js.map +1 -1
- package/dist/commands/help-command.js +1 -1
- package/dist/commands/help-command.js.map +1 -1
- package/dist/commands/setup-command.d.ts.map +1 -1
- package/dist/commands/setup-command.js +4 -3
- package/dist/commands/setup-command.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts +1 -1
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +39 -32
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/ui/assets/{accounts-CccaoV-N.js → accounts-BikRyqcT.js} +1 -1
- package/dist/ui/assets/{alert-dialog-D838sIju.js → alert-dialog-CwEJfEUX.js} +1 -1
- package/dist/ui/assets/api-BYSEdQYh.js +4 -0
- package/dist/ui/assets/{auth-section-BGCaHAcN.js → auth-section-CrFrby6w.js} +1 -1
- package/dist/ui/assets/{backups-section-CqZN-2Qq.js → backups-section-CdMvSnSm.js} +1 -1
- package/dist/ui/assets/{checkbox-BgLi38k2.js → checkbox-CC0rU-9-.js} +1 -1
- package/dist/ui/assets/{claude-extension-ClHnH_4i.js → claude-extension-CzGeZYz8.js} +1 -1
- package/dist/ui/assets/cliproxy-BSNSGNOv.js +3 -0
- package/dist/ui/assets/{cliproxy-ai-providers-EhHqrkRr.js → cliproxy-ai-providers-D-U6NKfV.js} +3 -3
- package/dist/ui/assets/{cliproxy-control-panel-lRQBQhPS.js → cliproxy-control-panel-BCexyz40.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-t6i94F2B.js → confirm-dialog-Bee0kh6i.js} +1 -1
- package/dist/ui/assets/{copilot-DlSkTZ2q.js → copilot-BZRAvPLD.js} +1 -1
- package/dist/ui/assets/{cursor-DJvTEVHh.js → cursor-CO2rCNKC.js} +1 -1
- package/dist/ui/assets/{droid-wevxXBVG.js → droid-CcKqoQtO.js} +2 -2
- package/dist/ui/assets/{globalenv-section-De072K_j.js → globalenv-section-CBRvmZbS.js} +1 -1
- package/dist/ui/assets/{health-Wv80MRCF.js → health-DgrTQESI.js} +1 -1
- package/dist/ui/assets/{icons-DMeZET56.js → icons-DR-ORtNe.js} +1 -1
- package/dist/ui/assets/{index-CxPqnEpn.js → index-BOhcsuQK.js} +1 -1
- package/dist/ui/assets/{index-BqdBnk5l.js → index-CursmDny.js} +1 -1
- package/dist/ui/assets/{index-C9TiCNLM.js → index-D90gSn57.js} +1 -1
- package/dist/ui/assets/{index-BmB4ckDm.js → index-DJCPwAoe.js} +1 -1
- package/dist/ui/assets/index-kGiBvBM-.css +1 -0
- package/dist/ui/assets/index-sCtK1kDn.js +47 -0
- package/dist/ui/assets/{proxy-status-widget-DMe8konR.js → proxy-status-widget-C8cOlsqE.js} +1 -1
- package/dist/ui/assets/{searchable-select-C-dUgzQ_.js → searchable-select-CF22qEzz.js} +1 -1
- package/dist/ui/assets/{separator-TnQMGoEt.js → separator-CAoIlNuN.js} +1 -1
- package/dist/ui/assets/{shared-Cbcz8ZIu.js → shared-zeFjETE6.js} +1 -1
- package/dist/ui/assets/{switch-Df15Gmz9.js → switch-BeqpDfK5.js} +1 -1
- package/dist/ui/assets/{updates-WOEYNHTJ.js → updates-By9S46EJ.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/web-server/health-service.d.ts.map +1 -1
- package/dist/web-server/health-service.js +2 -3
- package/dist/web-server/health-service.js.map +1 -1
- package/dist/web-server/middleware/auth-middleware.d.ts +2 -0
- package/dist/web-server/middleware/auth-middleware.d.ts.map +1 -1
- package/dist/web-server/middleware/auth-middleware.js +23 -1
- package/dist/web-server/middleware/auth-middleware.js.map +1 -1
- package/dist/web-server/routes/ai-provider-routes.d.ts.map +1 -1
- package/dist/web-server/routes/ai-provider-routes.js +19 -13
- package/dist/web-server/routes/ai-provider-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts +7 -0
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js +119 -32
- package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.js +6 -0
- package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-sync-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-sync-routes.js +6 -11
- package/dist/web-server/routes/cliproxy-sync-routes.js.map +1 -1
- package/dist/web-server/routes/cursor-settings-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cursor-settings-routes.js +36 -33
- package/dist/web-server/routes/cursor-settings-routes.js.map +1 -1
- package/dist/web-server/routes/misc-routes.d.ts.map +1 -1
- package/dist/web-server/routes/misc-routes.js +26 -19
- package/dist/web-server/routes/misc-routes.js.map +1 -1
- package/dist/web-server/routes/proxy-routes.d.ts.map +1 -1
- package/dist/web-server/routes/proxy-routes.js +6 -0
- package/dist/web-server/routes/proxy-routes.js.map +1 -1
- package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
- package/dist/web-server/routes/settings-routes.js +143 -109
- package/dist/web-server/routes/settings-routes.js.map +1 -1
- package/dist/web-server/routes/websearch-routes.d.ts.map +1 -1
- package/dist/web-server/routes/websearch-routes.js +31 -43
- package/dist/web-server/routes/websearch-routes.js.map +1 -1
- package/dist/web-server/shared-routes.d.ts.map +1 -1
- package/dist/web-server/shared-routes.js +6 -0
- package/dist/web-server/shared-routes.js.map +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/api-IXigV-A_.js +0 -4
- package/dist/ui/assets/cliproxy-qX23viWV.js +0 -3
- package/dist/ui/assets/index-DRmZP4OP.css +0 -1
- package/dist/ui/assets/index-N_jd9sKU.js +0 -47
package/dist/ui/assets/{cliproxy-ai-providers-EhHqrkRr.js → cliproxy-ai-providers-D-U6NKfV.js}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as m,u as qe,h as $e}from"./react-vendor-CNOkPC89.js";import{c as K,
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as m,u as qe,h as $e}from"./react-vendor-CNOkPC89.js";import{c as K,at as me,aZ as ue,B as h,ad as Ke,ae as He,af as Be,ag as De,ah as Fe,L as A,I as k,M as Ge,N as Ve,O as ze,as as Je,d as f,Y as re,S as fe,n as ee,Q as ve,R as ye,U as W,V as X,a_ as be,a$ as _e}from"./index-sCtK1kDn.js";import{P as Qe}from"./proxy-status-widget-C8cOlsqE.js";import{C as We}from"./confirm-dialog-Bee0kh6i.js";import{k as Xe,x as Pe,l as Ae,m as pe,an as se,r as Ye,R as le,Z as Ze,a3 as Se,o as Ie,aB as es,I as ss,ai as ts,aj as as,O as je,aC as Ue,aD as Le,aE as Me,am as rs,aF as ns}from"./icons-DR-ORtNe.js";import{u as is,a as xe,b as he}from"./tanstack-B8i0evp-.js";import{t as G}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CwEJfEUX.js";function ls(t){switch(t){case"ready":return{icon:Ae,text:"Ready",className:"text-green-600"};case"partial":return{icon:Pe,text:"Needs attention",className:"text-amber-600"};default:return{icon:Xe,text:"Not configured",className:"text-muted-foreground"}}}function os({families:t,selectedFamily:s,onSelect:a}){return e.jsx("div",{className:"space-y-1",children:t.map(r=>{const i=r.id===s,o=ls(r.status),d=o.icon;return e.jsx("button",{type:"button",onClick:()=>a(r.id),className:K("w-full cursor-pointer rounded-lg border px-3 py-2.5 text-left transition-colors",i?"border-primary/20 bg-primary/10":"border-transparent hover:bg-muted/70"),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(me,{provider:ue(r.id),size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:r.displayName}),r.entries.length>0&&e.jsx(h,{variant:"secondary",className:"h-4 px-1 text-[10px]",children:r.entries.length})]}),e.jsxs("div",{className:K("mt-0.5 flex items-center gap-1.5 text-xs",o.className),children:[e.jsx(d,{className:"h-3 w-3"}),e.jsx("span",{children:o.text})]})]}),e.jsx(h,{variant:"outline",className:"h-5 px-1.5 text-[9px] uppercase tracking-wide",children:r.authMode})]})},r.id)})})}function ds(t){switch(t){case"gemini-api-key":return{familyName:"Gemini",description:"Store the Gemini key here so CLIProxy can route Gemini requests without creating a separate CCS API Profile.",requiredNow:["Paste the Gemini API key.","Leave Base URL empty unless you use a custom Gemini host."],optionalLater:["Model mappings only when requested names and Gemini names differ.","Headers only when your provider setup requires them."],keyLabel:"Gemini API Key",keyPlaceholder:"AIza...",keyHelper:"This is the only field most Gemini setups need.",baseUrlPlaceholder:"https://generativelanguage.googleapis.com",baseUrlHelper:"Optional. Leave blank to keep the default Gemini endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gemini-2.5-pro",aliasesHelper:"Format: requested=upstream. Leave this blank unless the upstream Gemini model name differs.",headersPlaceholder:"X-Goog-User-Project: your-project"};case"codex-api-key":return{familyName:"Codex",description:"Store the Codex or OpenAI key here so CLIProxy can route Codex requests without duplicating the setup in API Profiles.",requiredNow:["Paste the Codex or OpenAI API key.","Leave Base URL empty unless this route should target another OpenAI-style endpoint."],optionalLater:["Model mappings only when the upstream model ID differs.","Headers only when org or project routing needs them."],keyLabel:"Codex API Key",keyPlaceholder:"sk-...",keyHelper:"This is the only field most Codex setups need.",baseUrlPlaceholder:"https://api.openai.com/v1",baseUrlHelper:"Optional. Leave blank to keep the default Codex endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gpt-5",aliasesHelper:"Format: requested=upstream. Add a mapping only when the upstream model name differs.",headersPlaceholder:"OpenAI-Organization: org_..."};case"claude-api-key":return{familyName:"Claude",description:"Store the Anthropic or compatible key here for CLIProxy-managed Claude routing. Save the key first, then add rewrites only if this route needs them.",requiredNow:["Paste the Claude or Anthropic-compatible API key.","Leave Base URL empty unless this route should target another compatible endpoint."],optionalLater:["Model mappings only when the requested and upstream Claude model IDs differ.","Proxy, prefix, exclusions, and headers only for advanced routing cases."],keyLabel:"Claude API Key",keyPlaceholder:"sk-ant-...",keyHelper:"Most Claude routes can start with the key only.",baseUrlPlaceholder:"https://api.anthropic.com",baseUrlHelper:"Optional. Leave blank to keep the default Claude-compatible endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=claude-3-7-sonnet-latest",aliasesHelper:"Format: requested=upstream. Add a mapping only when the upstream model ID should differ.",headersPlaceholder:"X-Project: internal-routing"};case"vertex-api-key":return{familyName:"Vertex",description:"Store the Vertex key here so CLIProxy can route Vertex traffic without creating a separate CCS API Profile.",requiredNow:["Paste the Vertex API key.","Leave Base URL empty unless a regional or gateway endpoint is required."],optionalLater:["Model mappings only when the upstream name differs.","Headers only when the provider expects extra routing context."],keyLabel:"Vertex API Key",keyPlaceholder:"AIza...",keyHelper:"Most Vertex routes only need the key.",baseUrlPlaceholder:"https://vertex.googleapis.com",baseUrlHelper:"Optional. Leave blank to keep the default Vertex endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gemini-2.5-pro",aliasesHelper:"Format: requested=upstream. Leave blank unless the upstream model name differs.",headersPlaceholder:"X-Goog-User-Project: your-project"};case"openai-compatibility":return{familyName:"OpenAI-Compatible Connector",description:"Create a named connector for OpenRouter, Together, or any OpenAI-style endpoint. This page owns the connector setup directly inside CLIProxy.",requiredNow:["Pick a connector name such as openrouter or together.","Set the connector Base URL.","Add at least one API key before saving."],optionalLater:["Model mappings only when requested and upstream model names differ.","Headers only when the connector requires provider-specific auth or routing."],keyLabel:"API Keys",keyPlaceholder:"sk-...",keyHelper:"Add one key per line. Most connectors start with a single key.",connectorPlaceholder:"openrouter",connectorHelper:"This becomes the connector label in the saved entries list.",baseUrlPlaceholder:"https://openrouter.ai/api/v1",baseUrlHelper:"Required for connectors. This is the upstream OpenAI-style endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gpt-4.1",aliasesHelper:"Format: requested=upstream. Leave blank unless the connector expects a different model ID.",headersPlaceholder:"HTTP-Referer: https://your-app.example"}}}function Ne(t){return t.split(`
|
|
2
2
|
`).map(s=>s.trim()).filter(s=>s.length>0)}function cs(t){return t.split(`
|
|
3
3
|
`).map(s=>s.trim()).filter(s=>s.length>0).map(s=>{const a=s.includes(":")?":":"=",[r,...i]=s.split(a);return{key:r.trim(),value:i.join(a).trim()}}).filter(s=>s.key.length>0)}function ms(t){return t.split(`
|
|
4
4
|
`).map(s=>s.trim()).filter(s=>s.length>0).map(s=>{const a=s.indexOf("=");return a===-1?{name:s.trim(),alias:""}:{name:s.slice(0,a).trim(),alias:s.slice(a+1).trim()}}).filter(s=>s.name.length>0||s.alias.length>0)}function Y({value:t,onChange:s,placeholder:a,rows:r=4}){return e.jsx("textarea",{rows:r,value:t,onChange:i=>s(i.target.value),placeholder:a,className:"flex min-h-24 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-xs outline-none transition-[color,box-shadow] placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50"})}function us(t){return(t?.headers||[]).map(s=>`${s.key}: ${s.value}`).join(`
|
|
5
5
|
`)}function ps(t){return(t?.excludedModels||[]).join(`
|
|
6
6
|
`)}function xs(t){return(t?.models||[]).map(s=>s.alias.trim()?`${s.name}=${s.alias}`:s.name).join(`
|
|
7
7
|
`)}function we({title:t,items:s,icon:a}){return e.jsxs("div",{className:"rounded-xl border bg-background/80 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[a,t]}),e.jsx("div",{className:"mt-3 space-y-3",children:s.map((r,i)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border bg-muted/40 text-[11px] font-semibold text-muted-foreground",children:i+1}),e.jsx("div",{className:"text-sm leading-6 text-muted-foreground",children:r})]},`${t}:${r}`))})]})}function hs({family:t,entry:s,open:a,onOpenChange:r,onSubmit:i,isSaving:o}){const d=m.useMemo(()=>ds(t),[t]),l=!!s,c=t==="openai-compatibility",v=t==="claude-api-key",[S,E]=m.useState(()=>s?.name||""),[b,T]=m.useState(()=>s?.baseUrl||""),[j,O]=m.useState(()=>s?.proxyUrl||""),[I,J]=m.useState(()=>s?.prefix||""),[N,U]=m.useState(""),[y,p]=m.useState(""),[L,w]=m.useState(()=>us(s)),[q,H]=m.useState(()=>ps(s)),[B,g]=m.useState(()=>xs(s)),[R,P]=m.useState(()=>!!(s?.headers.length||s?.excludedModels.length||s?.proxyUrl||s?.prefix)),D=m.useMemo(()=>!l||!s?.secretConfigured?null:c?"Leave API keys blank to keep the stored connector secrets.":"Leave the API key blank to keep the stored secret.",[s?.secretConfigured,l,c]),F=async()=>{const n=N.trim(),$=Ne(y),C=l&&s?.secretConfigured&&!n.length&&$.length===0,ie={name:c?S:void 0,baseUrl:b,proxyUrl:v?j:void 0,prefix:v?I:void 0,headers:cs(L),excludedModels:v?Ne(q):void 0,models:ms(B),preserveSecrets:C,...c?$.length>0?{apiKeys:$}:{}:n.length>0?{apiKey:n}:{}};await i(ie)};return e.jsx(Ke,{open:a,onOpenChange:r,children:e.jsx(He,{className:"overflow-hidden p-0 sm:max-w-3xl",children:e.jsxs("div",{className:"max-h-[85vh] overflow-y-auto",children:[e.jsx("div",{className:"border-b bg-muted/20 px-6 py-5",children:e.jsxs(Be,{className:"gap-4 text-left",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl border bg-background",children:e.jsx(me,{provider:ue(t),size:"md"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(De,{children:l?`Edit ${d.familyName}`:`Set up ${d.familyName}`}),e.jsx(h,{variant:"outline",className:"uppercase text-[11px]",children:c?"connector":"api-key"})]}),e.jsx(Fe,{className:"mt-1 max-w-2xl leading-6",children:d.description})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(we,{title:"Required now",items:d.requiredNow,icon:e.jsx(pe,{className:"h-4 w-4 text-primary"})}),e.jsx(we,{title:"Optional later",items:d.optionalLater,icon:e.jsx(se,{className:"h-4 w-4 text-primary"})})]}),D?e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-800",children:D}):null]})}),e.jsxs("div",{className:"space-y-6 px-6 py-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:"Required setup"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Save the smallest working configuration first."})]}),c?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"connector-name",children:"Connector Name"}),e.jsx(k,{id:"connector-name",value:S,onChange:n=>E(n.target.value),placeholder:d.connectorPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.connectorHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"base-url",children:"Base URL"}),e.jsx(k,{id:"base-url",value:b,onChange:n=>T(n.target.value),placeholder:d.baseUrlPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.baseUrlHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{children:"API Keys"}),e.jsx(Y,{value:y,onChange:p,rows:4,placeholder:`${d.keyPlaceholder}
|
|
8
|
-
${d.keyPlaceholder}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.keyHelper})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"api-key",children:d.keyLabel}),e.jsx(k,{id:"api-key",type:"password",value:N,onChange:n=>U(n.target.value),placeholder:d.keyPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.keyHelper})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:"Optional routing"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Only fill these when the route needs more than the default behavior."})]}),c?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"base-url",children:"Base URL"}),e.jsx(k,{id:"base-url",value:b,onChange:n=>T(n.target.value),placeholder:d.baseUrlPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.baseUrlHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{children:"Model Mappings"}),e.jsx(Y,{value:B,onChange:g,rows:4,placeholder:d.aliasesPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.aliasesHelper})]})]}),e.jsx(Ge,{open:R,onOpenChange:P,children:e.jsxs("div",{className:"rounded-xl border",children:[e.jsx(Ve,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-4 px-4 py-4 text-left",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(se,{className:"h-4 w-4 text-primary"}),"Advanced routing"]}),e.jsxs("div",{className:"mt-1 text-sm text-muted-foreground",children:["Headers",v?", proxy, prefix, and exclusions.":" and provider-specific overrides."]})]}),e.jsx(Ye,{className:K("h-4 w-4 text-muted-foreground transition-transform",R&&"rotate-180")})]})}),e.jsx(ze,{className:"border-t px-4 py-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{children:"Headers"}),e.jsx(Y,{value:L,onChange:w,rows:3,placeholder:d.headersPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use headers only when the provider requires extra routing or auth context."})]}),v?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"prefix",children:"Prefix"}),e.jsx(k,{id:"prefix",value:I,onChange:n=>J(n.target.value),placeholder:"glm-"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Prepends model names before routing."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"proxy-url",children:"Proxy URL"}),e.jsx(k,{id:"proxy-url",value:j,onChange:n=>O(n.target.value),placeholder:"http://127.0.0.1:8080"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Sends requests through an intermediate proxy."})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{children:"Excluded Models"}),e.jsx(Y,{value:q,onChange:H,rows:3,placeholder:"claude-opus-4-1\\nclaude-sonnet-4-5"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. One model ID per line when this route should reject specific upstream models."})]})]}):null]})})]})})]}),e.jsxs(Je,{className:"border-t bg-muted/10 px-6 py-4",children:[e.jsx(f,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(f,{type:"button",onClick:()=>void F(),disabled:o,children:o?"Saving...":c?l?"Save Connector":"Create Connector":"Save Entry"})]})]})})})}const ne=["cliproxy-ai-providers"];function gs(){return is({queryKey:ne,queryFn:()=>re.cliproxy.aiProviders.list()})}function fs(){const t=xe();return he({mutationFn:({family:s,data:a})=>re.cliproxy.aiProviders.create(s,a),onSuccess:()=>{t.invalidateQueries({queryKey:ne}),G.success("Provider entry created")},onError:s=>{G.error(s.message)}})}function vs(){const t=xe();return he({mutationFn:({family:s,index:a,data:r})=>re.cliproxy.aiProviders.update(s,a,r),onSuccess:()=>{t.invalidateQueries({queryKey:ne}),G.success("Provider entry updated")},onError:s=>{G.error(s.message)}})}function ys(){const t=xe();return he({mutationFn:({family:s,index:a})=>re.cliproxy.aiProviders.delete(s,a),onSuccess:()=>{t.invalidateQueries({queryKey:ne}),G.success("Provider entry removed")},onError:s=>{G.error(s.message)}})}function _({label:t,value:s,hint:a}){return e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t}),e.jsx("div",{className:"mt-1 break-all text-sm font-medium leading-5",children:s}),a?e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:a}):null]})}function bs(t){switch(t){case"ready":return{label:"Ready",className:"bg-emerald-50 text-emerald-700 hover:bg-emerald-50"};case"partial":return{label:"Needs attention",className:"bg-amber-50 text-amber-700 hover:bg-amber-50"};default:return{label:"Empty",className:"bg-muted text-muted-foreground hover:bg-muted"}}}function de(t){return t.proxyUrl?"Proxy override":t.prefix?"Prefixed route":t.baseUrl?"Direct upstream":"Default runtime"}function Te(t){return t.filter(s=>s.alias.trim().length>0).length}function Re(t){return t.filter(s=>s.name.trim().length>0&&s.alias.trim().length===0).length}function te(t){const s=Te(t),a=Re(t),r=[];return s>0&&r.push(`${s} mapped`),a>0&&r.push(`${a} direct`),r.length>0?r.join(" + "):"No model rules"}function ce({configured:t}){return e.jsx(h,{variant:"secondary",className:K("border-transparent text-[10px]",t?"bg-emerald-50 text-emerald-700 hover:bg-emerald-50":"bg-muted text-muted-foreground hover:bg-muted"),children:t?"Configured":"Missing secret"})}const V="<stored in CLIProxy>";function Ee(t){switch(t.id){case"gemini-api-key":return{requiredNow:["Save the Gemini API key.","Leave Base URL blank unless you use a custom Gemini gateway.","Add model mappings only when Gemini model names differ from the requested ones."],optionalLater:["Headers for provider-specific project routing.","Base URL override for a proxy or regional endpoint.","Mappings such as claude-sonnet-4-5 -> gemini-2.5-pro."],emptyStateSummary:[`Requests to ${t.routePath} use CLIProxy-managed Gemini credentials.`,"The default upstream is enough for most Gemini setups.","Model mappings and headers are optional, not step one."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile instead of this CLIProxy-managed Gemini route.",editPrompts:[{label:"Base URL",hint:"Change it only for a custom Gemini gateway or regional endpoint."},{label:"Model mappings",hint:"Add them only when requested names and Gemini names differ."},{label:"Headers",hint:"Keep them empty unless the provider requires project or org routing."}]};case"codex-api-key":return{requiredNow:["Save the Codex or OpenAI API key.","Leave Base URL blank unless this route should hit a different OpenAI-style host.","Add mappings only when the upstream model name differs from what CCS requests."],optionalLater:["Base URL override for a gateway, proxy, or self-hosted endpoint.","Headers for org or project routing.","Mappings such as claude-sonnet-4-5 -> gpt-5."],emptyStateSummary:[`Requests to ${t.routePath} use CLIProxy-managed Codex credentials.`,"Most setups can keep the default upstream and skip extra routing.","Mappings are only needed when the upstream model naming does not match the requested one."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile rather than this CLIProxy-managed Codex route.",editPrompts:[{label:"Base URL",hint:"Change it only when Codex should resolve through another OpenAI-style endpoint."},{label:"Model mappings",hint:"Map requested model names to the exact upstream model ID only when needed."},{label:"Headers",hint:"Use headers sparingly for project routing or extra auth."}]};case"claude-api-key":return{requiredNow:["Save the Anthropic or compatible API key.","Leave Base URL blank unless this route should point at a custom Claude-compatible endpoint.","Add mappings only when the upstream model ID differs from the requested Claude model name."],optionalLater:["Prefix or proxy overrides for advanced route rewriting.","Excluded models when a route should block specific model IDs.","Headers for project-scoped routing."],emptyStateSummary:[`Requests to ${t.routePath} use a CLIProxy-managed Claude-compatible key.`,"Base URL, proxy, and prefix rewrites are advanced options, not the minimum setup.","Most users can start with a key only, then add mappings or filters if routing needs it."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile or preset instead of this CLIProxy-managed Claude route.",editPrompts:[{label:"Base URL",hint:"Change it only when Claude traffic should target another compatible endpoint."},{label:"Mappings",hint:"Add them only when the requested Claude model name should route to a different upstream ID."},{label:"Advanced routing",hint:"Proxy, prefix, headers, and exclusions are for edge cases. Leave them blank when unsure."}]};case"vertex-api-key":return{requiredNow:["Save the Vertex API key.","Leave Base URL blank unless a regional or gateway endpoint is required.","Add mappings only when the upstream model name differs from the requested name."],optionalLater:["Base URL override for a regional gateway.","Headers for provider-specific routing.","Mappings for translating requested names to Vertex model IDs."],emptyStateSummary:[`Requests to ${t.routePath} use CLIProxy-managed Vertex credentials.`,"Most setups start with the key only and keep the default endpoint.","Mappings and headers are optional follow-up steps."],profileBoundary:"Use API Profiles when you need a CCS-native Anthropic-compatible profile rather than this CLIProxy-managed Vertex route.",editPrompts:[{label:"Base URL",hint:"Use it only for a regional gateway or managed Vertex endpoint."},{label:"Model mappings",hint:"Add them only when the requested names need translating upstream."},{label:"Headers",hint:"Keep them empty unless the provider requires extra routing context."}]};case"openai-compatibility":return{requiredNow:["Name the connector, for example openrouter or together.","Set the connector Base URL.","Add at least one API key before saving."],optionalLater:["Headers for provider-specific auth or project routing.","Model mappings such as claude-sonnet-4-5 -> gpt-4.1.","Additional API keys for the same connector."],emptyStateSummary:[`Requests to ${t.routePath} resolve through a named OpenAI-compatible connector.`,"This flow needs a connector name, a Base URL, and one or more API keys.","Headers and mappings come after the connector is already working."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile, preset, or provider outside the CLIProxy connector flow.",editPrompts:[{label:"Connector identity",hint:"Keep the connector name and Base URL stable once clients depend on it."},{label:"Model mappings",hint:"Only add them when the connector expects a different upstream model ID."},{label:"Headers",hint:"Use them for provider-specific auth or project routing, not as a default."}]}}}function z(t){return t.split(`
|
|
8
|
+
${d.keyPlaceholder}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.keyHelper})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"api-key",children:d.keyLabel}),e.jsx(k,{id:"api-key",type:"password",value:N,onChange:n=>U(n.target.value),placeholder:d.keyPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.keyHelper})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:"Optional routing"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Only fill these when the route needs more than the default behavior."})]}),c?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"base-url",children:"Base URL"}),e.jsx(k,{id:"base-url",value:b,onChange:n=>T(n.target.value),placeholder:d.baseUrlPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.baseUrlHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{children:"Model Mappings"}),e.jsx(Y,{value:B,onChange:g,rows:4,placeholder:d.aliasesPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.aliasesHelper})]})]}),e.jsx(Ge,{open:R,onOpenChange:P,children:e.jsxs("div",{className:"rounded-xl border",children:[e.jsx(Ve,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-4 px-4 py-4 text-left",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(se,{className:"h-4 w-4 text-primary"}),"Advanced routing"]}),e.jsxs("div",{className:"mt-1 text-sm text-muted-foreground",children:["Headers",v?", proxy, prefix, and exclusions.":" and provider-specific overrides."]})]}),e.jsx(Ye,{className:K("h-4 w-4 text-muted-foreground transition-transform",R&&"rotate-180")})]})}),e.jsx(ze,{className:"border-t px-4 py-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{children:"Headers"}),e.jsx(Y,{value:L,onChange:w,rows:3,placeholder:d.headersPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use headers only when the provider requires extra routing or auth context."})]}),v?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"prefix",children:"Prefix"}),e.jsx(k,{id:"prefix",value:I,onChange:n=>J(n.target.value),placeholder:"glm-"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Prepends model names before routing."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"proxy-url",children:"Proxy URL"}),e.jsx(k,{id:"proxy-url",value:j,onChange:n=>O(n.target.value),placeholder:"http://127.0.0.1:8080"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Sends requests through an intermediate proxy."})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{children:"Excluded Models"}),e.jsx(Y,{value:q,onChange:H,rows:3,placeholder:"claude-opus-4-1\\nclaude-sonnet-4-5"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. One model ID per line when this route should reject specific upstream models."})]})]}):null]})})]})})]}),e.jsxs(Je,{className:"border-t bg-muted/10 px-6 py-4",children:[e.jsx(f,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(f,{type:"button",onClick:()=>void F(),disabled:o,children:o?"Saving...":c?l?"Save Connector":"Create Connector":"Save Entry"})]})]})})})}const ne=["cliproxy-ai-providers"];function gs(){return is({queryKey:ne,queryFn:()=>re.cliproxy.aiProviders.list()})}function fs(){const t=xe();return he({mutationFn:({family:s,data:a})=>re.cliproxy.aiProviders.create(s,a),onSuccess:()=>{t.invalidateQueries({queryKey:ne}),G.success("Provider entry created")},onError:s=>{G.error(s.message)}})}function vs(){const t=xe();return he({mutationFn:({family:s,entryId:a,data:r})=>re.cliproxy.aiProviders.update(s,a,r),onSuccess:()=>{t.invalidateQueries({queryKey:ne}),G.success("Provider entry updated")},onError:s=>{G.error(s.message)}})}function ys(){const t=xe();return he({mutationFn:({family:s,entryId:a})=>re.cliproxy.aiProviders.delete(s,a),onSuccess:()=>{t.invalidateQueries({queryKey:ne}),G.success("Provider entry removed")},onError:s=>{G.error(s.message)}})}function _({label:t,value:s,hint:a}){return e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t}),e.jsx("div",{className:"mt-1 break-all text-sm font-medium leading-5",children:s}),a?e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:a}):null]})}function bs(t){switch(t){case"ready":return{label:"Ready",className:"bg-emerald-50 text-emerald-700 hover:bg-emerald-50"};case"partial":return{label:"Needs attention",className:"bg-amber-50 text-amber-700 hover:bg-amber-50"};default:return{label:"Empty",className:"bg-muted text-muted-foreground hover:bg-muted"}}}function de(t){return t.proxyUrl?"Proxy override":t.prefix?"Prefixed route":t.baseUrl?"Direct upstream":"Default runtime"}function Te(t){return t.filter(s=>s.alias.trim().length>0).length}function Re(t){return t.filter(s=>s.name.trim().length>0&&s.alias.trim().length===0).length}function te(t){const s=Te(t),a=Re(t),r=[];return s>0&&r.push(`${s} mapped`),a>0&&r.push(`${a} direct`),r.length>0?r.join(" + "):"No model rules"}function ce({configured:t}){return e.jsx(h,{variant:"secondary",className:K("border-transparent text-[10px]",t?"bg-emerald-50 text-emerald-700 hover:bg-emerald-50":"bg-muted text-muted-foreground hover:bg-muted"),children:t?"Configured":"Missing secret"})}const V="<stored in CLIProxy>";function Ee(t){switch(t.id){case"gemini-api-key":return{requiredNow:["Save the Gemini API key.","Leave Base URL blank unless you use a custom Gemini gateway.","Add model mappings only when Gemini model names differ from the requested ones."],optionalLater:["Headers for provider-specific project routing.","Base URL override for a proxy or regional endpoint.","Mappings such as claude-sonnet-4-5 -> gemini-2.5-pro."],emptyStateSummary:[`Requests to ${t.routePath} use CLIProxy-managed Gemini credentials.`,"The default upstream is enough for most Gemini setups.","Model mappings and headers are optional, not step one."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile instead of this CLIProxy-managed Gemini route.",editPrompts:[{label:"Base URL",hint:"Change it only for a custom Gemini gateway or regional endpoint."},{label:"Model mappings",hint:"Add them only when requested names and Gemini names differ."},{label:"Headers",hint:"Keep them empty unless the provider requires project or org routing."}]};case"codex-api-key":return{requiredNow:["Save the Codex or OpenAI API key.","Leave Base URL blank unless this route should hit a different OpenAI-style host.","Add mappings only when the upstream model name differs from what CCS requests."],optionalLater:["Base URL override for a gateway, proxy, or self-hosted endpoint.","Headers for org or project routing.","Mappings such as claude-sonnet-4-5 -> gpt-5."],emptyStateSummary:[`Requests to ${t.routePath} use CLIProxy-managed Codex credentials.`,"Most setups can keep the default upstream and skip extra routing.","Mappings are only needed when the upstream model naming does not match the requested one."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile rather than this CLIProxy-managed Codex route.",editPrompts:[{label:"Base URL",hint:"Change it only when Codex should resolve through another OpenAI-style endpoint."},{label:"Model mappings",hint:"Map requested model names to the exact upstream model ID only when needed."},{label:"Headers",hint:"Use headers sparingly for project routing or extra auth."}]};case"claude-api-key":return{requiredNow:["Save the Anthropic or compatible API key.","Leave Base URL blank unless this route should point at a custom Claude-compatible endpoint.","Add mappings only when the upstream model ID differs from the requested Claude model name."],optionalLater:["Prefix or proxy overrides for advanced route rewriting.","Excluded models when a route should block specific model IDs.","Headers for project-scoped routing."],emptyStateSummary:[`Requests to ${t.routePath} use a CLIProxy-managed Claude-compatible key.`,"Base URL, proxy, and prefix rewrites are advanced options, not the minimum setup.","Most users can start with a key only, then add mappings or filters if routing needs it."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile or preset instead of this CLIProxy-managed Claude route.",editPrompts:[{label:"Base URL",hint:"Change it only when Claude traffic should target another compatible endpoint."},{label:"Mappings",hint:"Add them only when the requested Claude model name should route to a different upstream ID."},{label:"Advanced routing",hint:"Proxy, prefix, headers, and exclusions are for edge cases. Leave them blank when unsure."}]};case"vertex-api-key":return{requiredNow:["Save the Vertex API key.","Leave Base URL blank unless a regional or gateway endpoint is required.","Add mappings only when the upstream model name differs from the requested name."],optionalLater:["Base URL override for a regional gateway.","Headers for provider-specific routing.","Mappings for translating requested names to Vertex model IDs."],emptyStateSummary:[`Requests to ${t.routePath} use CLIProxy-managed Vertex credentials.`,"Most setups start with the key only and keep the default endpoint.","Mappings and headers are optional follow-up steps."],profileBoundary:"Use API Profiles when you need a CCS-native Anthropic-compatible profile rather than this CLIProxy-managed Vertex route.",editPrompts:[{label:"Base URL",hint:"Use it only for a regional gateway or managed Vertex endpoint."},{label:"Model mappings",hint:"Add them only when the requested names need translating upstream."},{label:"Headers",hint:"Keep them empty unless the provider requires extra routing context."}]};case"openai-compatibility":return{requiredNow:["Name the connector, for example openrouter or together.","Set the connector Base URL.","Add at least one API key before saving."],optionalLater:["Headers for provider-specific auth or project routing.","Model mappings such as claude-sonnet-4-5 -> gpt-4.1.","Additional API keys for the same connector."],emptyStateSummary:[`Requests to ${t.routePath} resolve through a named OpenAI-compatible connector.`,"This flow needs a connector name, a Base URL, and one or more API keys.","Headers and mappings come after the connector is already working."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile, preset, or provider outside the CLIProxy connector flow.",editPrompts:[{label:"Connector identity",hint:"Keep the connector name and Base URL stable once clients depend on it."},{label:"Model mappings",hint:"Only add them when the connector expects a different upstream model ID."},{label:"Headers",hint:"Use them for provider-specific auth or project routing, not as a default."}]}}}function z(t){return t.split(`
|
|
9
9
|
`).map(s=>s.trim()).filter(s=>s.length>0)}function ae(t){return t.split(`
|
|
10
10
|
`).map(s=>s.trim()).filter(s=>s.length>0).map(s=>{const a=s.includes(":")?":":"=",[r,...i]=s.split(a);return{key:r.trim(),value:i.join(a).trim()}}).filter(s=>s.key.length>0)}function Q(t){return t.split(`
|
|
11
11
|
`).map(s=>s.trim()).filter(s=>s.length>0).map(s=>{const a=s.indexOf("=");return a===-1?{name:s.trim(),alias:""}:{name:s.slice(0,a).trim(),alias:s.slice(a+1).trim()}}).filter(s=>s.name.length>0||s.alias.length>0)}function js(t){return(t?.headers||[]).map(s=>`${s.key}: ${s.value}`).join(`
|
|
@@ -18,4 +18,4 @@ ${d.keyPlaceholder}`}),e.jsx("p",{className:"text-xs text-muted-foreground",chil
|
|
|
18
18
|
`):"",excludedModelsText:Array.isArray(i["excluded-models"])?i["excluded-models"].join(`
|
|
19
19
|
`):"",modelAliasesText:Array.isArray(i.models)?i.models.map(o=>o.alias?.trim()?`${o.name?.trim()||""}=${o.alias.trim()}`:o.name?.trim()||"").filter(Boolean).join(`
|
|
20
20
|
`):"",apiKey:typeof i["api-key"]=="string"&&i["api-key"]!==V?i["api-key"]:"",apiKeysText:""}}function Ss(t,s,a){if(t.id==="openai-compatibility"){const o=z(a.apiKeysText),d=s.secretConfigured&&o.length===0;return{name:a.name.trim(),baseUrl:a.baseUrl.trim(),headers:ae(a.headersText),models:Q(a.modelAliasesText),preserveSecrets:d,...o.length>0?{apiKeys:o}:{}}}const r=a.apiKey.trim(),i=s.secretConfigured&&r.length===0;return{baseUrl:a.baseUrl.trim(),proxyUrl:a.proxyUrl.trim(),prefix:a.prefix.trim(),headers:ae(a.headersText),excludedModels:z(a.excludedModelsText),models:Q(a.modelAliasesText),preserveSecrets:i,...r.length>0?{apiKey:r}:{}}}function Is(t,s,a){const r={ANTHROPIC_BASE_URL:`${a.target}${t.routePath}`,ANTHROPIC_AUTH_TOKEN:"ccs-internal-managed"},i=Q(s.modelAliasesText).find(o=>o.name.trim());return i?.name&&(r.ANTHROPIC_MODEL=i.name),{env:r}}function ke({badge:t,title:s,items:a}){return e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(h,{variant:"secondary",className:"text-[11px]",children:t}),e.jsx("div",{className:"text-sm font-medium",children:s})]}),e.jsx("div",{className:"mt-4 space-y-3",children:a.map((r,i)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/10 px-3 py-3",children:[e.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border bg-background text-[11px] font-semibold text-muted-foreground",children:i+1}),e.jsx("div",{className:"text-sm leading-6 text-muted-foreground",children:r})]},`${s}:${r}`))})]})}function M({label:t,helper:s,children:a}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:t}),a,s?e.jsx("div",{className:"text-xs leading-5 text-muted-foreground",children:s}):null]})}function Z({value:t,onChange:s,placeholder:a,rows:r=4}){return e.jsx("textarea",{rows:r,value:t,onChange:i=>s(i.target.value),placeholder:a,className:"flex min-h-24 w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-xs outline-none transition-[color,box-shadow] placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50"})}function Us({family:t,entry:s,source:a,isSaving:r,onSave:i,onDelete:o}){const d=Ee(t),[l,c]=m.useState(()=>oe(s)),[v,S]=m.useState(null),[E,b]=m.useState(!0),[T,j]=m.useState(null),[O,I]=m.useState("config"),[J,N]=m.useState("raw"),U=m.useMemo(()=>JSON.stringify(Ce(t,s,oe(s)),null,2),[s,t]),y=m.useMemo(()=>JSON.stringify(Ce(t,s,l),null,2),[l,s,t]),p=v??y,L=m.useMemo(()=>Is(t,l,a),[l,t,a]),w=m.useMemo(()=>Q(l.modelAliasesText),[l.modelAliasesText]),q=m.useMemo(()=>ae(l.headersText),[l.headersText]),H=m.useMemo(()=>z(l.excludedModelsText),[l.excludedModelsText]),B=m.useMemo(()=>JSON.stringify(L,null,2),[L]),g=Te(w),R=Re(w),P=q.length+H.length+(l.proxyUrl.trim()?1:0)+(l.prefix.trim()?1:0),D=t.id==="openai-compatibility"?l.headersText.trim().length>0:!!(l.proxyUrl.trim()||l.prefix.trim()||l.headersText.trim()||l.excludedModelsText.trim()),F=v!==null?v!==U:y!==U,n=m.useMemo(()=>{if(t.id==="openai-compatibility"){const u=[];return l.name.trim()||u.push("name"),l.baseUrl.trim()||u.push("base-url"),!s.secretConfigured&&z(l.apiKeysText).length===0&&u.push("api-key-entries"),u}return!s.secretConfigured&&!l.apiKey.trim()?["api-key"]:[]},[l.apiKey,l.apiKeysText,l.baseUrl,l.name,s.secretConfigured,t.id]),$=E&&n.length===0&&F,C=u=>{c(x=>u(x)),S(null),b(!0),j(null)},ie=u=>{S(u);try{const x=As(t,s,u);c(x),b(!0),j(null)}catch(x){b(!1),j(x instanceof Error?x.message:"Invalid JSON")}},Oe=()=>{c(oe(s)),S(null),b(!0),j(null)},ge=u=>{C(x=>u==="minimal"?t.id==="openai-compatibility"?{...x,headersText:"",modelAliasesText:""}:{...x,baseUrl:"",proxyUrl:"",prefix:"",headersText:"",excludedModelsText:"",modelAliasesText:""}:{...x,proxyUrl:"",prefix:"",headersText:"",excludedModelsText:t.id==="openai-compatibility"?x.excludedModelsText:""})};return e.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[minmax(360px,0.44fr)_minmax(0,0.56fr)] divide-x overflow-hidden rounded-b-xl border-x border-b bg-card",children:[e.jsx("div",{className:"min-h-0 overflow-hidden bg-muted/5",children:e.jsxs(ve,{value:O,onValueChange:I,className:"flex h-full flex-col",children:[e.jsxs("div",{className:"border-b bg-background px-4 pt-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"truncate text-lg font-semibold",children:s.label}),e.jsx(ce,{configured:s.secretConfigured}),e.jsx(h,{variant:"outline",className:"uppercase",children:t.authMode})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(h,{variant:"outline",className:"font-mono text-[11px]",children:t.routePath}),e.jsx(h,{variant:"outline",className:"text-[11px]",children:de(s)}),e.jsx(h,{variant:"outline",className:"text-[11px]",children:a.label})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:Oe,disabled:!F,children:[e.jsx(ss,{className:"mr-1 h-3.5 w-3.5"}),"Reset"]}),e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:o,children:[e.jsx(ts,{className:"mr-1 h-3.5 w-3.5"}),"Remove"]}),e.jsxs(f,{type:"button",size:"sm",onClick:()=>void i(Ss(t,s,l)),disabled:!$||r,children:[e.jsx(as,{className:"mr-1 h-3.5 w-3.5"}),r?"Saving...":"Save"]})]})]}),e.jsxs(ye,{className:"grid w-full grid-cols-2",children:[e.jsxs(W,{value:"config",className:"gap-2 text-xs",children:[e.jsx(se,{className:"h-3.5 w-3.5"}),"Config"]}),e.jsxs(W,{value:"usage",className:"gap-2 text-xs",children:[e.jsx(je,{className:"h-3.5 w-3.5"}),"Info & Usage"]})]})]}),e.jsx(X,{value:"config",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsx(ee,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"Workspace presets"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Keep the route lean by default, then layer routing only when this entry actually needs it."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(f,{type:"button",size:"sm",variant:"outline",onClick:()=>ge("minimal"),children:"Minimal setup"}),e.jsx(f,{type:"button",size:"sm",variant:"outline",onClick:()=>ge("clean-routing"),children:"Clear routing noise"})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 2xl:grid-cols-3",children:[e.jsx(_,{label:"Secret",value:s.secretConfigured?"Stored in CLIProxy":"Missing",hint:s.secretConfigured?"Rotate only when needed":"Required to save"}),e.jsx(_,{label:"Model Rules",value:w.length>0?te(w):"No model rules",hint:"Requested model names stay direct unless remapped"}),e.jsx(_,{label:"Advanced",value:P>0?`${P} active`:"Optional",hint:"Proxy, prefix, headers, and exclusions"})]})]}),n.length>0?e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50/80 p-4 text-sm text-amber-900",children:["Missing required fields:"," ",e.jsx("span",{className:"font-mono",children:n.join(", ")})]}):null,e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-2 text-sm font-medium",children:[e.jsx(pe,{className:"h-4 w-4 text-primary"}),"Connection"]}),e.jsxs("div",{className:"grid gap-4 2xl:grid-cols-2",children:[t.id==="openai-compatibility"?e.jsx(M,{label:"Connector Name",helper:"This is the saved connector label shown in the entry switcher.",children:e.jsx(k,{value:l.name,onChange:u=>C(x=>({...x,name:u.target.value})),placeholder:"openrouter"})}):e.jsx(M,{label:`${t.displayName} API Key`,helper:s.secretConfigured?"Leave blank to keep the stored secret. Enter a new value only to rotate it.":"Required before this route can authenticate.",children:e.jsx(k,{type:"password",value:l.apiKey,onChange:u=>C(x=>({...x,apiKey:u.target.value})),placeholder:s.secretConfigured?s.apiKeyMasked||V:"Paste provider API key"})}),t.id==="openai-compatibility"?e.jsx(M,{label:"API Keys",helper:s.secretConfigured?"One key per line. Leave empty to preserve the stored connector keys.":"Add one key per line. A connector needs at least one key.",children:e.jsx(Z,{value:l.apiKeysText,onChange:u=>C(x=>({...x,apiKeysText:u})),placeholder:"sk-...",rows:4})}):null,e.jsx(M,{label:"Base URL",helper:t.id==="openai-compatibility"?"Required for connectors. This is the upstream OpenAI-style endpoint.":"Leave blank unless this route should target another upstream host.",children:e.jsx(k,{value:l.baseUrl,onChange:u=>C(x=>({...x,baseUrl:u.target.value})),placeholder:t.id==="codex-api-key"?"https://api.openai.com/v1":t.id==="claude-api-key"?"https://api.anthropic.com":t.id==="openai-compatibility"?"https://openrouter.ai/api/v1":"https://provider.example.com"})}),t.id!=="openai-compatibility"?e.jsx(M,{label:"Proxy URL",helper:"Optional intermediary endpoint. Leave blank for direct routing.",children:e.jsx(k,{value:l.proxyUrl,onChange:u=>C(x=>({...x,proxyUrl:u.target.value})),placeholder:"https://proxy.example.com/v1"})}):null,t.id!=="openai-compatibility"?e.jsx(M,{label:"Prefix",helper:"Optional model prefix rewrite for advanced routing only.",children:e.jsx(k,{value:l.prefix,onChange:u=>C(x=>({...x,prefix:u.target.value})),placeholder:"provider/"})}):null]})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ue,{className:"h-4 w-4 text-primary"}),"Model rules"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[g>0?e.jsxs(h,{variant:"outline",children:[g," mapped"]}):null,R>0?e.jsxs(h,{variant:"outline",children:[R," direct"]}):null,w.length===0?e.jsx(h,{variant:"outline",children:"Optional"}):null]})]}),e.jsx(M,{label:"Requested [= Upstream]",helper:"Use requested=upstream for remaps. Use a plain model name when you want the route to expose that model directly.",children:e.jsx(Z,{value:l.modelAliasesText,onChange:u=>C(x=>({...x,modelAliasesText:u})),placeholder:`claude-sonnet-4-5=gpt-5
|
|
21
|
-
glm-5`,rows:6})})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(se,{className:"h-4 w-4 text-primary"}),"Advanced routing"]}),e.jsx(h,{variant:"outline",children:D?`${P} active`:"Optional"})]}),e.jsxs("div",{className:"grid gap-4 2xl:grid-cols-2",children:[e.jsx(M,{label:"Headers",helper:"One header per line. Use only when the upstream expects org, project, or secondary auth headers.",children:e.jsx(Z,{value:l.headersText,onChange:u=>C(x=>({...x,headersText:u})),placeholder:"OpenAI-Organization: org_...",rows:5})}),t.id!=="openai-compatibility"?e.jsx(M,{label:"Excluded Models",helper:"One model ID per line. These models will be blocked for this entry.",children:e.jsx(Z,{value:l.excludedModelsText,onChange:u=>C(x=>({...x,excludedModelsText:u})),placeholder:"claude-opus-4-1",rows:5})}):e.jsx("div",{className:"rounded-xl border border-dashed bg-muted/10 p-4 text-sm text-muted-foreground",children:"OpenAI-compatible connectors keep advanced routing lean. Add headers or model mappings first before introducing extra route layers elsewhere."})]})]})]})})}),e.jsx(X,{value:"usage",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsx(ee,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Le,{className:"h-4 w-4 text-primary"}),"How this route behaves"]}),e.jsxs("div",{className:"mt-3 space-y-3 text-sm leading-6 text-muted-foreground",children:[e.jsxs("div",{className:"rounded-lg border bg-muted/10 p-4",children:["Calls to ",e.jsx("span",{className:"font-mono",children:t.routePath})," use this saved entry inside CLIProxy."]}),e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4",children:l.baseUrl.trim()?`Traffic resolves to ${l.baseUrl.trim()} unless you layer another proxy in front.`:"Traffic keeps the family default upstream unless you add a custom base URL."}),e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4",children:w.length>0?`${te(w)} rule${w.length===1?"":"s"} active for this entry.`:"Requested model names pass through unchanged until you add explicit model rules."})]})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(je,{className:"h-4 w-4 text-primary"}),"When API Profiles fits better"]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:d.profileBoundary})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Me,{className:"h-4 w-4 text-primary"}),"Editing rule of thumb"]}),e.jsx("div",{className:"mt-3 space-y-3",children:d.editPrompts.map(u=>e.jsxs("div",{className:"rounded-lg border bg-muted/10 p-4",children:[e.jsx("div",{className:"text-sm font-medium",children:u.label}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:u.hint})]},u.label))})]})]})})})]})}),e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsxs(ve,{value:J,onValueChange:N,className:"flex h-full flex-col",children:[e.jsxs("div",{className:"border-b bg-background px-4 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Raw configuration"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Target ",e.jsx("span",{className:"font-mono",children:a.target})]})]}),e.jsxs(ye,{className:"grid w-full grid-cols-2",children:[e.jsxs(W,{value:"raw",className:"gap-2 text-xs",children:[e.jsx(rs,{className:"h-3.5 w-3.5"}),"Raw Entry Config"]}),e.jsxs(W,{value:"preview",className:"gap-2 text-xs",children:[e.jsx(ns,{className:"h-3.5 w-3.5"}),"settings.json Preview"]})]})]}),e.jsx(X,{value:"raw",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"border-b bg-muted/10 px-6 py-3 text-sm text-muted-foreground",children:s.secretConfigured?`Stored secrets are shown as ${V}. Replace the placeholder only when you want to rotate the secret.`:"Add secrets directly in the JSON or use the form on the left."}),T?e.jsx("div",{className:"mx-6 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:T}):null,e.jsx("div",{className:"min-h-0 flex-1 px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full overflow-hidden rounded-md border bg-background",children:e.jsx(be,{value:p,onChange:ie,language:"json",minHeight:"100%"})})})]})}),e.jsx(X,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"border-b bg-muted/10 px-6 py-3 text-sm text-muted-foreground",children:"Derived preview for a CCS profile that points to this CLIProxy route. The route stays local; the upstream key remains managed here."}),e.jsx("div",{className:"min-h-0 flex-1 px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full overflow-hidden rounded-md border bg-background",children:e.jsx(be,{value:B,onChange:()=>{},language:"json",readonly:!0,minHeight:"100%"})})}),e.jsx("div",{className:"mx-6 mb-4 overflow-hidden rounded-md border",children:e.jsx(_e,{profileEnv:L.env})})]})})]})})]})}function Ls({family:t,onAddEntry:s,onOpenControlPanel:a,onOpenProfiles:r}){const i=Ee(t),o=t.supportsNamedEntries?"Create connector":`Add ${t.displayName} entry`;return e.jsx("div",{className:"space-y-5",children:e.jsxs("div",{className:"grid gap-5 2xl:grid-cols-[minmax(0,1fr)_320px]",children:[e.jsxs("div",{className:"rounded-xl border bg-card",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b px-5 py-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-muted",children:e.jsx(pe,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold",children:["Set up ",t.displayName]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Start with the smallest working setup. Add routing rules only after the route is already working."})]})]}),e.jsxs(f,{type:"button",onClick:s,children:[e.jsx(Se,{className:"mr-1 h-4 w-4"}),o]})]}),e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-muted/10 p-4",children:[e.jsx("div",{className:"text-sm font-medium",children:"Recommended setup flow"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Finish the left section first. Treat the right section as optional follow-up."}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx(ke,{badge:"Do this first",title:"Minimum working setup",items:i.requiredNow}),e.jsx(ke,{badge:"Only if needed",title:"Optional later",items:i.optionalLater})]})]}),e.jsxs("div",{className:"rounded-xl border bg-muted/15 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Me,{className:"h-4 w-4 text-emerald-600"}),"Need the other pages?"]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Use Overview or Control Panel for OAuth sign-ins. Use API Profiles only for CCS-native Anthropic-compatible profiles and presets."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(f,{type:"button",size:"sm",variant:"outline",onClick:a,children:"Control Panel"}),e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:r,children:["API Profiles",e.jsx(Ie,{className:"ml-1 h-3.5 w-3.5"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Le,{className:"h-4 w-4 text-primary"}),"What this route does"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(h,{variant:"outline",className:"font-mono text-[11px]",children:t.routePath}),e.jsx(h,{variant:"outline",className:"uppercase text-[11px]",children:t.authMode})]}),e.jsx("div",{className:"mt-4 space-y-3",children:i.emptyStateSummary.map(d=>e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4 text-sm leading-6 text-muted-foreground",children:d},d))})]}),e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ue,{className:"h-4 w-4 text-primary"}),"When API Profiles is the better fit"]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:i.profileBoundary})]})]})]})})}function Gs(){const t=qe(),s=$e(),{data:a,error:r,isLoading:i,isFetching:o,refetch:d}=gs(),l=fs(),c=vs(),v=ys(),[S,E]=m.useState(!1),[b,T]=m.useState(null),[j,O]=m.useState(null),[I,J]=m.useState(null),N=m.useMemo(()=>a?.families??[],[a?.families]),U=m.useMemo(()=>new URLSearchParams(t.search).get("family")||null,[t.search]),y=m.useMemo(()=>U&&N.some(n=>n.id===U)?U:N[0]?.id??"gemini-api-key",[N,U]),p=m.useMemo(()=>N.find(n=>n.id===y)||null,[N,y]),L=m.useMemo(()=>{const n=p?.entries??[];return n.length===0?null:I&&n.some($=>$.id===I)?I:n[0]?.id??null},[I,p?.entries]),w=n=>{s({pathname:t.pathname,search:`?family=${n}`},{replace:!0})},q=()=>{T(null),E(!0)};if(i)return e.jsxs("div",{className:"flex h-[calc(100vh-100px)] min-h-0",children:[e.jsx(fe,{className:"h-full w-80 rounded-none"}),e.jsx(fe,{className:"h-full flex-1 rounded-none"})]});if(r||!a||!p){const n=r instanceof Error?r.message:"Failed to load CLIProxy AI providers. Check the local server and try again.";return e.jsx("div",{className:"flex h-[calc(100vh-100px)] min-h-0 items-center justify-center bg-muted/10 p-6",children:e.jsx("div",{className:"w-full max-w-2xl rounded-xl border bg-card p-6 shadow-sm",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-lg bg-destructive/10",children:e.jsx(Pe,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-lg font-semibold",children:"Unable to load AI Providers"}),e.jsx("div",{className:"mt-2 text-sm text-muted-foreground",children:n}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(f,{type:"button",onClick:()=>void d(),children:[e.jsx(le,{className:"mr-2 h-4 w-4"}),"Retry"]}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>s("/cliproxy/control-panel"),children:"Control Panel"}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>s("/providers"),children:"API Profiles"})]})]})]})})})}const H=p.entries.filter(n=>n.secretConfigured),B=N.filter(n=>n.status==="ready").length,g=p.entries.find(n=>n.id===L)??null,R=p.entries.length>1,P=bs(p.status),D=p.entries.length>0,F=e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Setup status"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:p.routePath})]}),e.jsx(h,{variant:"secondary",className:P.className,children:P.label})]}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[e.jsx(_,{label:"Entries",value:`${p.entries.length}`,hint:"configured rows"}),e.jsx(_,{label:"Secrets",value:`${H.length}/${p.entries.length||0}`,hint:"stored in CLIProxy"})]}),e.jsx("div",{className:"mt-3 rounded-lg border bg-muted/15 p-3 text-xs leading-5 text-muted-foreground",children:"Overview handles OAuth sign-ins. This page stores CLIProxy-managed keys and connectors. API Profiles remains for CCS-native Anthropic-compatible profiles."})]});return e.jsxs("div",{className:"flex h-[calc(100vh-100px)] min-h-0",children:[e.jsxs("div",{className:"flex w-80 flex-col border-r bg-muted/30",children:[e.jsxs("div",{className:"border-b bg-background p-4",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ze,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"CLIProxy Plus"})]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",type:"button",onClick:()=>void d(),disabled:o,children:e.jsx(le,{className:K("h-4 w-4",o&&"animate-spin")})})]}),e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"AI Providers"}),e.jsxs(f,{variant:"default",size:"sm",className:"w-full gap-2",type:"button",onClick:q,children:[e.jsx(Se,{className:"h-4 w-4"}),p.supportsNamedEntries?"Create Connector":`Add ${p.displayName} Entry`]})]}),e.jsx(ee,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Provider Families"}),e.jsx(os,{families:N,selectedFamily:y,onSelect:w})]})}),e.jsx("div",{className:"border-t p-3",children:e.jsx(Qe,{})}),e.jsx("div",{className:"border-t bg-background p-3 text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[N.length," families"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ae,{className:"h-3 w-3 text-emerald-600"}),B," ready"]})]})})]}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col bg-background",children:[e.jsx("div",{className:"shrink-0 border-b bg-background px-6 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(me,{provider:ue(p.id),size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:p.displayName}),e.jsx(h,{variant:"secondary",className:P.className,children:P.label}),e.jsx(h,{variant:"outline",className:"uppercase",children:p.authMode}),e.jsx(h,{variant:"outline",className:"font-mono text-[11px]",children:p.routePath})]}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:p.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(f,{type:"button",variant:"ghost",size:"sm",onClick:()=>void d(),disabled:o,children:e.jsx(le,{className:K("h-4 w-4",o&&"animate-spin")})}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>s("/cliproxy/control-panel"),children:"Control Panel"}),e.jsxs(f,{type:"button",variant:"outline",onClick:()=>s("/providers"),children:["API Profiles",e.jsx(Ie,{className:"ml-1 h-3.5 w-3.5"})]})]})]})}),D?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 border-b bg-muted/5 px-6 py-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:[e.jsx(es,{className:"h-3 w-3"}),R?"Saved entries":"Saved entry"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(h,{variant:"outline",className:"text-[11px]",children:[p.entries.length," entries"]}),e.jsxs(h,{variant:"outline",className:"text-[11px]",children:[H.length,"/",p.entries.length," secrets stored"]})]})]}),R?e.jsx("div",{className:"flex flex-wrap gap-3",children:p.entries.map(n=>e.jsxs("button",{type:"button",onClick:()=>J(n.id),className:K("min-w-[220px] max-w-[280px] flex-1 rounded-xl border bg-background px-4 py-3 text-left transition-colors",n.id===L?"border-primary/30 bg-primary/5 shadow-sm":"border-border/60 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:n.label}),e.jsx(ce,{configured:n.secretConfigured})]}),e.jsx("div",{className:"mt-2 truncate text-xs text-muted-foreground",children:n.baseUrl||p.routePath}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(h,{variant:"outline",className:"text-[10px]",children:de(n)}),n.models.length>0?e.jsx(h,{variant:"outline",className:"text-[10px]",children:te(n.models)}):null,e.jsxs(h,{variant:"outline",className:"text-[10px]",children:[n.headers.length," hdr"]})]})]},n.id))}):g?e.jsx("div",{className:"rounded-xl border bg-background px-4 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center 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-medium",children:g.label}),e.jsx(ce,{configured:g.secretConfigured})]}),e.jsx("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:g.baseUrl||p.routePath})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(h,{variant:"outline",className:"text-[10px]",children:de(g)}),g.models.length>0?e.jsx(h,{variant:"outline",className:"text-[10px]",children:te(g.models)}):null,e.jsxs(h,{variant:"outline",className:"text-[10px]",children:[g.headers.length," hdr"]})]})]})}):null]}),g?e.jsx(Us,{family:p,entry:g,source:a.source,isSaving:c.isPending,onSave:async n=>{await c.mutateAsync({family:y,index:g.index,data:n}),d()},onDelete:()=>O(g)},g.id):null]}):e.jsx(ee,{className:"flex-1",children:e.jsxs("div",{className:"space-y-6 p-6",children:[F,e.jsx(Ls,{family:p,onAddEntry:q,onOpenControlPanel:()=>s("/cliproxy/control-panel"),onOpenProfiles:()=>s("/providers")})]})})]}),e.jsx(hs,{family:y,entry:b,open:S,onOpenChange:E,onSubmit:async n=>{b?await c.mutateAsync({family:y,index:b.index,data:n}):await l.mutateAsync({family:y,data:n}),E(!1),T(null),d()},isSaving:l.isPending||c.isPending},`${y}:${b?.id??"new"}:${S?"open":"closed"}`),e.jsx(We,{open:j!==null,title:"Remove provider entry?",description:j?`This removes ${j.label} from ${p.displayName}.`:"",confirmText:"Remove",variant:"destructive",onConfirm:async()=>{j&&(await v.mutateAsync({family:y,index:j.index}),O(null))},onCancel:()=>O(null)})]})}export{Gs as CliproxyAiProvidersPage};
|
|
21
|
+
glm-5`,rows:6})})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(se,{className:"h-4 w-4 text-primary"}),"Advanced routing"]}),e.jsx(h,{variant:"outline",children:D?`${P} active`:"Optional"})]}),e.jsxs("div",{className:"grid gap-4 2xl:grid-cols-2",children:[e.jsx(M,{label:"Headers",helper:"One header per line. Use only when the upstream expects org, project, or secondary auth headers.",children:e.jsx(Z,{value:l.headersText,onChange:u=>C(x=>({...x,headersText:u})),placeholder:"OpenAI-Organization: org_...",rows:5})}),t.id!=="openai-compatibility"?e.jsx(M,{label:"Excluded Models",helper:"One model ID per line. These models will be blocked for this entry.",children:e.jsx(Z,{value:l.excludedModelsText,onChange:u=>C(x=>({...x,excludedModelsText:u})),placeholder:"claude-opus-4-1",rows:5})}):e.jsx("div",{className:"rounded-xl border border-dashed bg-muted/10 p-4 text-sm text-muted-foreground",children:"OpenAI-compatible connectors keep advanced routing lean. Add headers or model mappings first before introducing extra route layers elsewhere."})]})]})]})})}),e.jsx(X,{value:"usage",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsx(ee,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Le,{className:"h-4 w-4 text-primary"}),"How this route behaves"]}),e.jsxs("div",{className:"mt-3 space-y-3 text-sm leading-6 text-muted-foreground",children:[e.jsxs("div",{className:"rounded-lg border bg-muted/10 p-4",children:["Calls to ",e.jsx("span",{className:"font-mono",children:t.routePath})," use this saved entry inside CLIProxy."]}),e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4",children:l.baseUrl.trim()?`Traffic resolves to ${l.baseUrl.trim()} unless you layer another proxy in front.`:"Traffic keeps the family default upstream unless you add a custom base URL."}),e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4",children:w.length>0?`${te(w)} rule${w.length===1?"":"s"} active for this entry.`:"Requested model names pass through unchanged until you add explicit model rules."})]})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(je,{className:"h-4 w-4 text-primary"}),"When API Profiles fits better"]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:d.profileBoundary})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Me,{className:"h-4 w-4 text-primary"}),"Editing rule of thumb"]}),e.jsx("div",{className:"mt-3 space-y-3",children:d.editPrompts.map(u=>e.jsxs("div",{className:"rounded-lg border bg-muted/10 p-4",children:[e.jsx("div",{className:"text-sm font-medium",children:u.label}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:u.hint})]},u.label))})]})]})})})]})}),e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsxs(ve,{value:J,onValueChange:N,className:"flex h-full flex-col",children:[e.jsxs("div",{className:"border-b bg-background px-4 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Raw configuration"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Target ",e.jsx("span",{className:"font-mono",children:a.target})]})]}),e.jsxs(ye,{className:"grid w-full grid-cols-2",children:[e.jsxs(W,{value:"raw",className:"gap-2 text-xs",children:[e.jsx(rs,{className:"h-3.5 w-3.5"}),"Raw Entry Config"]}),e.jsxs(W,{value:"preview",className:"gap-2 text-xs",children:[e.jsx(ns,{className:"h-3.5 w-3.5"}),"settings.json Preview"]})]})]}),e.jsx(X,{value:"raw",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"border-b bg-muted/10 px-6 py-3 text-sm text-muted-foreground",children:s.secretConfigured?`Stored secrets are shown as ${V}. Replace the placeholder only when you want to rotate the secret.`:"Add secrets directly in the JSON or use the form on the left."}),T?e.jsx("div",{className:"mx-6 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:T}):null,e.jsx("div",{className:"min-h-0 flex-1 px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full overflow-hidden rounded-md border bg-background",children:e.jsx(be,{value:p,onChange:ie,language:"json",minHeight:"100%"})})})]})}),e.jsx(X,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"border-b bg-muted/10 px-6 py-3 text-sm text-muted-foreground",children:"Derived preview for a CCS profile that points to this CLIProxy route. The route stays local; the upstream key remains managed here."}),e.jsx("div",{className:"min-h-0 flex-1 px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full overflow-hidden rounded-md border bg-background",children:e.jsx(be,{value:B,onChange:()=>{},language:"json",readonly:!0,minHeight:"100%"})})}),e.jsx("div",{className:"mx-6 mb-4 overflow-hidden rounded-md border",children:e.jsx(_e,{profileEnv:L.env})})]})})]})})]})}function Ls({family:t,onAddEntry:s,onOpenControlPanel:a,onOpenProfiles:r}){const i=Ee(t),o=t.supportsNamedEntries?"Create connector":`Add ${t.displayName} entry`;return e.jsx("div",{className:"space-y-5",children:e.jsxs("div",{className:"grid gap-5 2xl:grid-cols-[minmax(0,1fr)_320px]",children:[e.jsxs("div",{className:"rounded-xl border bg-card",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b px-5 py-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-muted",children:e.jsx(pe,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold",children:["Set up ",t.displayName]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Start with the smallest working setup. Add routing rules only after the route is already working."})]})]}),e.jsxs(f,{type:"button",onClick:s,children:[e.jsx(Se,{className:"mr-1 h-4 w-4"}),o]})]}),e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-muted/10 p-4",children:[e.jsx("div",{className:"text-sm font-medium",children:"Recommended setup flow"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Finish the left section first. Treat the right section as optional follow-up."}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx(ke,{badge:"Do this first",title:"Minimum working setup",items:i.requiredNow}),e.jsx(ke,{badge:"Only if needed",title:"Optional later",items:i.optionalLater})]})]}),e.jsxs("div",{className:"rounded-xl border bg-muted/15 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Me,{className:"h-4 w-4 text-emerald-600"}),"Need the other pages?"]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Use Overview or Control Panel for OAuth sign-ins. Use API Profiles only for CCS-native Anthropic-compatible profiles and presets."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(f,{type:"button",size:"sm",variant:"outline",onClick:a,children:"Control Panel"}),e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:r,children:["API Profiles",e.jsx(Ie,{className:"ml-1 h-3.5 w-3.5"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Le,{className:"h-4 w-4 text-primary"}),"What this route does"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(h,{variant:"outline",className:"font-mono text-[11px]",children:t.routePath}),e.jsx(h,{variant:"outline",className:"uppercase text-[11px]",children:t.authMode})]}),e.jsx("div",{className:"mt-4 space-y-3",children:i.emptyStateSummary.map(d=>e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4 text-sm leading-6 text-muted-foreground",children:d},d))})]}),e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ue,{className:"h-4 w-4 text-primary"}),"When API Profiles is the better fit"]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:i.profileBoundary})]})]})]})})}function Gs(){const t=qe(),s=$e(),{data:a,error:r,isLoading:i,isFetching:o,refetch:d}=gs(),l=fs(),c=vs(),v=ys(),[S,E]=m.useState(!1),[b,T]=m.useState(null),[j,O]=m.useState(null),[I,J]=m.useState(null),N=m.useMemo(()=>a?.families??[],[a?.families]),U=m.useMemo(()=>new URLSearchParams(t.search).get("family")||null,[t.search]),y=m.useMemo(()=>U&&N.some(n=>n.id===U)?U:N[0]?.id??"gemini-api-key",[N,U]),p=m.useMemo(()=>N.find(n=>n.id===y)||null,[N,y]),L=m.useMemo(()=>{const n=p?.entries??[];return n.length===0?null:I&&n.some($=>$.id===I)?I:n[0]?.id??null},[I,p?.entries]),w=n=>{s({pathname:t.pathname,search:`?family=${n}`},{replace:!0})},q=()=>{T(null),E(!0)};if(i)return e.jsxs("div",{className:"flex h-[calc(100vh-100px)] min-h-0",children:[e.jsx(fe,{className:"h-full w-80 rounded-none"}),e.jsx(fe,{className:"h-full flex-1 rounded-none"})]});if(r||!a||!p){const n=r instanceof Error?r.message:"Failed to load CLIProxy AI providers. Check the local server and try again.";return e.jsx("div",{className:"flex h-[calc(100vh-100px)] min-h-0 items-center justify-center bg-muted/10 p-6",children:e.jsx("div",{className:"w-full max-w-2xl rounded-xl border bg-card p-6 shadow-sm",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-lg bg-destructive/10",children:e.jsx(Pe,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-lg font-semibold",children:"Unable to load AI Providers"}),e.jsx("div",{className:"mt-2 text-sm text-muted-foreground",children:n}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(f,{type:"button",onClick:()=>void d(),children:[e.jsx(le,{className:"mr-2 h-4 w-4"}),"Retry"]}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>s("/cliproxy/control-panel"),children:"Control Panel"}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>s("/providers"),children:"API Profiles"})]})]})]})})})}const H=p.entries.filter(n=>n.secretConfigured),B=N.filter(n=>n.status==="ready").length,g=p.entries.find(n=>n.id===L)??null,R=p.entries.length>1,P=bs(p.status),D=p.entries.length>0,F=e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Setup status"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:p.routePath})]}),e.jsx(h,{variant:"secondary",className:P.className,children:P.label})]}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[e.jsx(_,{label:"Entries",value:`${p.entries.length}`,hint:"configured rows"}),e.jsx(_,{label:"Secrets",value:`${H.length}/${p.entries.length||0}`,hint:"stored in CLIProxy"})]}),e.jsx("div",{className:"mt-3 rounded-lg border bg-muted/15 p-3 text-xs leading-5 text-muted-foreground",children:"Overview handles OAuth sign-ins. This page stores CLIProxy-managed keys and connectors. API Profiles remains for CCS-native Anthropic-compatible profiles."})]});return e.jsxs("div",{className:"flex h-[calc(100vh-100px)] min-h-0",children:[e.jsxs("div",{className:"flex w-80 flex-col border-r bg-muted/30",children:[e.jsxs("div",{className:"border-b bg-background p-4",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ze,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"CLIProxy Plus"})]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",type:"button",onClick:()=>void d(),disabled:o,children:e.jsx(le,{className:K("h-4 w-4",o&&"animate-spin")})})]}),e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"AI Providers"}),e.jsxs(f,{variant:"default",size:"sm",className:"w-full gap-2",type:"button",onClick:q,children:[e.jsx(Se,{className:"h-4 w-4"}),p.supportsNamedEntries?"Create Connector":`Add ${p.displayName} Entry`]})]}),e.jsx(ee,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Provider Families"}),e.jsx(os,{families:N,selectedFamily:y,onSelect:w})]})}),e.jsx("div",{className:"border-t p-3",children:e.jsx(Qe,{})}),e.jsx("div",{className:"border-t bg-background p-3 text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[N.length," families"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ae,{className:"h-3 w-3 text-emerald-600"}),B," ready"]})]})})]}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col bg-background",children:[e.jsx("div",{className:"shrink-0 border-b bg-background px-6 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(me,{provider:ue(p.id),size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:p.displayName}),e.jsx(h,{variant:"secondary",className:P.className,children:P.label}),e.jsx(h,{variant:"outline",className:"uppercase",children:p.authMode}),e.jsx(h,{variant:"outline",className:"font-mono text-[11px]",children:p.routePath})]}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:p.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(f,{type:"button",variant:"ghost",size:"sm",onClick:()=>void d(),disabled:o,children:e.jsx(le,{className:K("h-4 w-4",o&&"animate-spin")})}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>s("/cliproxy/control-panel"),children:"Control Panel"}),e.jsxs(f,{type:"button",variant:"outline",onClick:()=>s("/providers"),children:["API Profiles",e.jsx(Ie,{className:"ml-1 h-3.5 w-3.5"})]})]})]})}),D?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 border-b bg-muted/5 px-6 py-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:[e.jsx(es,{className:"h-3 w-3"}),R?"Saved entries":"Saved entry"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(h,{variant:"outline",className:"text-[11px]",children:[p.entries.length," entries"]}),e.jsxs(h,{variant:"outline",className:"text-[11px]",children:[H.length,"/",p.entries.length," secrets stored"]})]})]}),R?e.jsx("div",{className:"flex flex-wrap gap-3",children:p.entries.map(n=>e.jsxs("button",{type:"button",onClick:()=>J(n.id),className:K("min-w-[220px] max-w-[280px] flex-1 rounded-xl border bg-background px-4 py-3 text-left transition-colors",n.id===L?"border-primary/30 bg-primary/5 shadow-sm":"border-border/60 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:n.label}),e.jsx(ce,{configured:n.secretConfigured})]}),e.jsx("div",{className:"mt-2 truncate text-xs text-muted-foreground",children:n.baseUrl||p.routePath}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(h,{variant:"outline",className:"text-[10px]",children:de(n)}),n.models.length>0?e.jsx(h,{variant:"outline",className:"text-[10px]",children:te(n.models)}):null,e.jsxs(h,{variant:"outline",className:"text-[10px]",children:[n.headers.length," hdr"]})]})]},n.id))}):g?e.jsx("div",{className:"rounded-xl border bg-background px-4 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center 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-medium",children:g.label}),e.jsx(ce,{configured:g.secretConfigured})]}),e.jsx("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:g.baseUrl||p.routePath})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(h,{variant:"outline",className:"text-[10px]",children:de(g)}),g.models.length>0?e.jsx(h,{variant:"outline",className:"text-[10px]",children:te(g.models)}):null,e.jsxs(h,{variant:"outline",className:"text-[10px]",children:[g.headers.length," hdr"]})]})]})}):null]}),g?e.jsx(Us,{family:p,entry:g,source:a.source,isSaving:c.isPending,onSave:async n=>{await c.mutateAsync({family:y,entryId:g.id,data:n}),d()},onDelete:()=>O(g)},g.id):null]}):e.jsx(ee,{className:"flex-1",children:e.jsxs("div",{className:"space-y-6 p-6",children:[F,e.jsx(Ls,{family:p,onAddEntry:q,onOpenControlPanel:()=>s("/cliproxy/control-panel"),onOpenProfiles:()=>s("/providers")})]})})]}),e.jsx(hs,{family:y,entry:b,open:S,onOpenChange:E,onSubmit:async n=>{b?await c.mutateAsync({family:y,entryId:b.id,data:n}):await l.mutateAsync({family:y,data:n}),E(!1),T(null),d()},isSaving:l.isPending||c.isPending},`${y}:${b?.id??"new"}:${S?"open":"closed"}`),e.jsx(We,{open:j!==null,title:"Remove provider entry?",description:j?`This removes ${j.label} from ${p.displayName}.`:"",confirmText:"Remove",variant:"destructive",onConfirm:async()=>{j&&(await v.mutateAsync({family:y,entryId:j.id}),O(null))},onCancel:()=>O(null)})]})}export{Gs as CliproxyAiProvidersPage};
|
package/dist/ui/assets/{cliproxy-control-panel-lRQBQhPS.js → cliproxy-control-panel-BCexyz40.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as w}from"./tanstack-B8i0evp-.js";import{Y as U,
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as w}from"./tanstack-B8i0evp-.js";import{Y as U,b0 as A}from"./index-sCtK1kDn.js";import{C as P}from"./default-ports-1QQSffYX.js";import{G as M,R as k,x as q}from"./icons-DR-ORtNe.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function F({port:a=P}){const l=s.useRef(null),[L,g]=s.useState(null),[$,R]=s.useState(0),[y,c]=s.useState(null),[E,i]=s.useState(!1),{data:b,error:x}=w({queryKey:["cliproxy-server-config"],queryFn:()=>U.cliproxyServer.get(),staleTime:3e4}),{data:j}=w({queryKey:["auth-tokens-raw"],queryFn:async()=>{const t=await fetch(A("/settings/auth/tokens/raw"));if(!t.ok)throw new Error("Failed to fetch auth tokens");return t.json()},staleTime:3e4});s.useEffect(()=>{x&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",x)},[x]);const{managementUrl:n,checkUrl:m,authToken:h,isRemote:d,displayHost:u}=s.useMemo(()=>{const t=b?.remote;if(t?.enabled&&t?.host){const o=t.protocol||"http",r=t.port||(o==="https"?443:P),N=o==="https"&&r===443||o==="http"&&r===80?"":`:${r}`,v=`${o}://${t.host}${N}`;return{managementUrl:`${v}/management.html`,checkUrl:`${v}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${N}`}}const f=j?.managementSecret?.value||"ccs";return{managementUrl:`http://localhost:${a}/management.html`,checkUrl:`http://localhost:${a}/`,authToken:f,isRemote:!1,displayHost:`localhost:${a}`}},[b,j,a]),p=L===n,I=!p;s.useEffect(()=>{const t=new AbortController,f=async()=>{try{(await fetch(m,{signal:t.signal})).ok?(i(!0),c(null)):(i(!1),c(d?`Remote CLIProxy at ${u} returned an error`:"CLIProxy returned an error"))}catch(r){if(r instanceof Error&&r.name==="AbortError")return;i(!1),c(d?`Remote CLIProxy at ${u} is not reachable`:"CLIProxy is not running")}},o=setTimeout(()=>t.abort(),2e3);return f().finally(()=>clearTimeout(o)),()=>t.abort()},[m,d,u]);const C=s.useCallback(()=>{if(!(!p||!l.current?.contentWindow||!h))try{const t=m.replace(/\/$/,"");if(!l.current.src.startsWith(t)){console.warn("[ControlPanelEmbed] Iframe origin mismatch, skipping postMessage");return}l.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:h},t)}catch(t){console.debug("[ControlPanelEmbed] postMessage failed - cross-origin:",t)}},[h,m,p]);s.useEffect(()=>{C()},[C]);const S=s.useCallback(()=>{g(n)},[n]),T=()=>{g(null),R(t=>t+1),c(null),i(!1)};return!E&&y?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"CLIProxy Control Panel"})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:T,children:[e.jsx(k,{className:"w-4 h-4"}),"Retry"]})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(q,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"CLIProxy Not Available"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:y}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsx("div",{className:"flex-1 flex flex-col",children:e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[I&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(k,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d?`Loading Control Panel from ${u}...`:"Loading Control Panel..."})]})}),e.jsx("iframe",{ref:l,src:n,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:S},`${n}:${$}`)]})})}function Q(){return e.jsx("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:e.jsx(F,{})})}export{Q as CliproxyControlPanelPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{A as c,a as d,b as g,c as x,d as h,e as j,f as A,g as D}from"./alert-dialog-
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{A as c,a as d,b as g,c as x,d as h,e as j,f as A,g as D}from"./alert-dialog-CwEJfEUX.js";function f({open:i,onConfirm:l,onCancel:r,title:s,description:t,confirmText:a="Confirm",variant:o="default"}){return e.jsx(c,{open:i,onOpenChange:n=>!n&&r(),children:e.jsxs(d,{children:[e.jsxs(g,{children:[e.jsx(x,{children:s}),e.jsx(h,{children:t})]}),e.jsxs(j,{children:[e.jsx(A,{onClick:r,children:"Cancel"}),e.jsx(D,{onClick:l,className:o==="destructive"?"bg-red-600 hover:bg-red-700 text-white":"",children:a})]})]})})}export{f as C};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{b1 as w,b2 as Pe,B as S,d as N,a as ie,V as ne,n as H,L as T,I as ce,r as ke,s as Fe,t as Te,v as Me,w as X,x as he,b3 as Le,S as b,b4 as Re,b5 as Ae,b6 as Oe,Q as Ee,R as _e,U as Y,b7 as qe,c as se}from"./index-N_jd9sKU.js";import{r as v}from"./react-vendor-CNOkPC89.js";import{a as De,u as _,b as M}from"./tanstack-B8i0evp-.js";import{C as Ie}from"./confirm-dialog-t6i94F2B.js";import{R as ge,L as fe,aj as Ke,a4 as Ue,Z as de,O as Qe,T as je,am as $e,b as Je,a6 as ze,as as Be,aG as me,K as Ge,N as He,aH as Ve,v as ve,w as we}from"./icons-DMeZET56.js";import{S as ae}from"./separator-TnQMGoEt.js";import{S as We}from"./searchable-select-C-dUgzQ_.js";import{S as Z}from"./switch-Df15Gmz9.js";import{t as q}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-D838sIju.js";async function Xe(){const t=await fetch(w("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Ye(){const t=await fetch(w("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function Ze(){const t=await fetch(w("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function et(){const t=await fetch(w("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function tt(t){const s=await fetch(w("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function st(t){const s=await fetch(w("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new Pe("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function at(){const t=await fetch(w("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function it(){const t=await fetch(w("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function nt(){const t=await fetch(w("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function ot(){const t=await fetch(w("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function lt(t){const s=await fetch(w("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function Ne(){const t=De(),s=_({queryKey:["copilot-status"],queryFn:Xe,refetchInterval:5e3}),l=_({queryKey:["copilot-config"],queryFn:Ye}),c=_({queryKey:["copilot-models"],queryFn:Ze}),i=_({queryKey:["copilot-raw-settings"],queryFn:et}),d=_({queryKey:["copilot-info"],queryFn:ot}),r=M({mutationFn:tt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),n=M({mutationFn:st,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=M({mutationFn:at,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),p=M({mutationFn:it,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),g=M({mutationFn:nt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),o=M({mutationFn:lt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return v.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:l.data,configLoading:l.isLoading,models:c.data?.models??[],currentModel:c.data?.current,modelsLoading:c.isLoading,rawSettings:i.data,rawSettingsLoading:i.isLoading,refetchRawSettings:i.refetch,updateConfig:r.mutate,updateConfigAsync:r.mutateAsync,isUpdating:r.isPending,saveRawSettings:n.mutate,saveRawSettingsAsync:n.mutateAsync,isSavingRawSettings:n.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:p.mutate,isStartingDaemon:p.isPending,stopDaemon:g.mutate,isStoppingDaemon:g.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:o.mutate,installAsync:o.mutateAsync,isInstalling:o.isPending}),[s.data,s.isLoading,s.error,s.refetch,l.data,l.isLoading,c.data,c.isLoading,i.data,i.isLoading,i.refetch,r.mutate,r.mutateAsync,r.isPending,n.mutate,n.mutateAsync,n.isPending,x.mutate,x.mutateAsync,x.isPending,x.data,p.mutate,p.isPending,g.mutate,g.isPending,d.data,d.isLoading,d.refetch,o.mutate,o.mutateAsync,o.isPending])}function rt({rawSettings:t,rawSettingsLoading:s,isUpdating:l,isSavingRawSettings:c,hasChanges:i,isRawJsonValid:d,onRefresh:r,onSave:n}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Copilot Configuration"}),t&&e.jsx(S,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:r,disabled:s,children:e.jsx(ge,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(N,{size:"sm",onClick:n,disabled:l||c||!i||!d,children:l||c?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const ct=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}],dt=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function ue(t){switch(t){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function mt(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function z({label:t,description:s,value:l,onChange:c,models:i,disabled:d}){const{t:r}=ie();return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),s&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsx(We,{value:l||void 0,onChange:c,disabled:d,placeholder:r("componentModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:r("componentModelSelector.availableModelsCount",{count:i.length})}],options:i.map(n=>({value:n.id,groupKey:"models",searchText:`${n.name||n.id} ${n.id}`,keywords:[n.minPlan??"",n.preview?"preview":""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.name||n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan}),n.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:mt(n.multiplier)}),n.preview&&e.jsx(S,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:r("componentModelSelector.preview")})]})}))})]})}function ee(t){if(t>=1e6){const s=t/1e6;return s%1===0?`${s}M`:`${s.toFixed(1)}M`}if(t>=1e3){const s=t/1e3;return s%1===0?`${s}K`:`${s.toFixed(1)}K`}return`${t}`}function ut(t){if(!t?.limits)return null;const s=[];return t.limits.maxPromptTokens&&s.push(`prompt ${ee(t.limits.maxPromptTokens)}`),t.limits.maxContextWindowTokens&&s.push(`context ${ee(t.limits.maxContextWindowTokens)}`),t.limits.maxOutputTokens&&s.push(`output ${ee(t.limits.maxOutputTokens)}`),s.length>0?s.join(" | "):null}function xt({currentModel:t,opusModel:s,sonnetModel:l,haikuModel:c,models:i,modelsLoading:d,onApplyPreset:r,onUpdateModel:n,onUpdateOpusModel:x,onUpdateSonnetModel:p,onUpdateHaikuModel:g}){const o=[{label:"Default",id:t},{label:"Opus",id:s||t},{label:"Sonnet",id:l||t},{label:"Haiku",id:c||t}].map(({label:a,id:u})=>{const y=i.find(P=>P.id===u),C=ut(y);return C?{label:a,id:u,limits:C}:null}).filter(a=>a!==null);return e.jsx(ne,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(H,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ue,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ct.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3 text-green-600"}),a.name]},a.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:dt.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3"}),a.name]},a.name))})]})]}),e.jsx(ae,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"mb-4 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-900 dark:text-amber-200",children:[e.jsx("p",{className:"font-medium",children:"GitHub Copilot controls prompt/context limits upstream."}),e.jsx("p",{className:"mt-1",children:"CCS can switch Copilot models, but it cannot increase the provider's max prompt or context window."}),o.length>0?e.jsx("div",{className:"mt-2 space-y-1 text-[11px] font-mono",children:o.map(a=>e.jsxs("p",{children:[a.label,": ",a.id," (",a.limits,")"]},`${a.label}-${a.id}`))}):e.jsx("p",{className:"mt-2 text-[11px] font-mono",children:"Start the daemon to inspect live model limits from GitHub Copilot metadata."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(z,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:n,models:i,disabled:d}),e.jsx(z,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:x,models:i,disabled:d}),e.jsx(z,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:l||t,onChange:p,models:i,disabled:d}),e.jsx(z,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c||t,onChange:g,models:i,disabled:d})]})]})]})})})}function pt({enabled:t,autoStart:s,port:l,accountType:c,rateLimit:i,waitOnLimit:d,onUpdateEnabled:r,onUpdateAutoStart:n,onUpdatePort:x,onUpdateAccountType:p,onUpdateRateLimit:g,onUpdateWaitOnLimit:o}){const{t:a}=ie();return e.jsx(ne,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(H,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"enabled",className:"text-sm font-medium",children:a("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("copilotSettings.enableCopilotDesc")})]}),e.jsx(Z,{id:"enabled",checked:t,onCheckedChange:r})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"port",className:"text-xs",children:a("copilotPage.port")}),e.jsx(ce,{id:"port",type:"number",value:l,onChange:u=>x(parseInt(u.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"account-type",className:"text-xs",children:a("copilotSettings.accountType")}),e.jsxs(ke,{value:c,onValueChange:p,children:[e.jsx(Fe,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(Te,{})}),e.jsxs(Me,{children:[e.jsx(X,{value:"individual",children:a("copilotSettings.accountTypeIndividual")}),e.jsx(X,{value:"business",children:a("copilotSettings.accountTypeBusiness")}),e.jsx(X,{value:"enterprise",children:a("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"rate-limit",className:"text-xs",children:a("copilotSettings.rateLimitSeconds")}),e.jsx(ce,{id:"rate-limit",type:"number",value:i,onChange:u=>g(u.target.value),placeholder:a("copilotSettings.noLimit"),min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"wait-on-limit",className:"text-xs",children:a("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx(Z,{id:"wait-on-limit",checked:d,onCheckedChange:o})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.daemonSettings")}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"auto-start",className:"text-xs",children:a("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.autoStartDaemonDesc")})]}),e.jsx(Z,{id:"auto-start",checked:s,onCheckedChange:n})]})]})]})})})}function B({label:t,command:s}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:s}),e.jsx(he,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function ht({rawSettings:t}){return e.jsx(ne,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(H,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(Qe,{className:"w-4 h-4"}),"Configuration Info"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:"GitHub Copilot"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:t.path}),e.jsx(he,{value:t.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),e.jsx(S,{variant:"outline",className:t.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:t.exists?"File exists":"Using defaults"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(B,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(B,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(B,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(B,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const gt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function xe(t){const s=t?.env||{};return gt.filter(l=>!s[l]?.trim())}function pe(t){if(!t||t.length===0)return[];const s=new Map;return t.forEach(l=>{s.set(l.message,l)}),[...s.values()]}function ft(){const{config:t,configLoading:s,models:l,modelsLoading:c,rawSettings:i,rawSettingsLoading:d,updateConfigAsync:r,isUpdating:n,saveRawSettingsAsync:x,isSavingRawSettings:p,refetchRawSettings:g}=Ne(),[o,a]=v.useState({}),[u,y]=v.useState(null),[C,P]=v.useState(!1),D=o.enabled??t?.enabled??!1,I=o.autoStart??t?.auto_start??!1,L=o.port??t?.port??4141,K=o.accountType??t?.account_type??"individual",R=o.model??t?.model??"claude-sonnet-4-6",A=o.rateLimit??t?.rate_limit?.toString()??"",f=o.waitOnLimit??t?.wait_on_limit??!0,U=o.opusModel??t?.opus_model??"",Q=o.sonnetModel??t?.sonnet_model??"",$=o.haikuModel??t?.haiku_model??"",J=(h,j)=>{a(O=>({...O,[h]:j}))},V=h=>{a(j=>({...j,model:h.default,opusModel:h.opus,sonnetModel:h.sonnet,haikuModel:h.haiku})),q.success(`Applied "${h.name}" preset`)},k=v.useMemo(()=>u!==null?u:i?.settings?JSON.stringify(i.settings,null,2):`{
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{b0 as w,b1 as Pe,B as S,d as N,a as ie,V as ne,n as H,L as T,I as ce,r as ke,s as Fe,t as Te,v as Me,w as X,x as he,b2 as Le,S as b,b3 as Re,b4 as Ae,b5 as Oe,Q as Ee,R as _e,U as Y,b6 as qe,c as se}from"./index-sCtK1kDn.js";import{r as v}from"./react-vendor-CNOkPC89.js";import{a as De,u as _,b as M}from"./tanstack-B8i0evp-.js";import{C as Ie}from"./confirm-dialog-Bee0kh6i.js";import{R as ge,L as fe,aj as Ke,a4 as Ue,Z as de,O as Qe,T as je,am as $e,b as Je,a6 as ze,as as Be,aG as me,K as Ge,N as He,aH as Ve,v as ve,w as we}from"./icons-DR-ORtNe.js";import{S as ae}from"./separator-CAoIlNuN.js";import{S as We}from"./searchable-select-CF22qEzz.js";import{S as Z}from"./switch-BeqpDfK5.js";import{t as q}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CwEJfEUX.js";async function Xe(){const t=await fetch(w("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Ye(){const t=await fetch(w("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function Ze(){const t=await fetch(w("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function et(){const t=await fetch(w("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function tt(t){const s=await fetch(w("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function st(t){const s=await fetch(w("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new Pe("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function at(){const t=await fetch(w("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function it(){const t=await fetch(w("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function nt(){const t=await fetch(w("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function ot(){const t=await fetch(w("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function lt(t){const s=await fetch(w("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function Ne(){const t=De(),s=_({queryKey:["copilot-status"],queryFn:Xe,refetchInterval:5e3}),l=_({queryKey:["copilot-config"],queryFn:Ye}),c=_({queryKey:["copilot-models"],queryFn:Ze}),i=_({queryKey:["copilot-raw-settings"],queryFn:et}),d=_({queryKey:["copilot-info"],queryFn:ot}),r=M({mutationFn:tt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),n=M({mutationFn:st,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=M({mutationFn:at,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),p=M({mutationFn:it,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),g=M({mutationFn:nt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),o=M({mutationFn:lt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return v.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:l.data,configLoading:l.isLoading,models:c.data?.models??[],currentModel:c.data?.current,modelsLoading:c.isLoading,rawSettings:i.data,rawSettingsLoading:i.isLoading,refetchRawSettings:i.refetch,updateConfig:r.mutate,updateConfigAsync:r.mutateAsync,isUpdating:r.isPending,saveRawSettings:n.mutate,saveRawSettingsAsync:n.mutateAsync,isSavingRawSettings:n.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:p.mutate,isStartingDaemon:p.isPending,stopDaemon:g.mutate,isStoppingDaemon:g.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:o.mutate,installAsync:o.mutateAsync,isInstalling:o.isPending}),[s.data,s.isLoading,s.error,s.refetch,l.data,l.isLoading,c.data,c.isLoading,i.data,i.isLoading,i.refetch,r.mutate,r.mutateAsync,r.isPending,n.mutate,n.mutateAsync,n.isPending,x.mutate,x.mutateAsync,x.isPending,x.data,p.mutate,p.isPending,g.mutate,g.isPending,d.data,d.isLoading,d.refetch,o.mutate,o.mutateAsync,o.isPending])}function rt({rawSettings:t,rawSettingsLoading:s,isUpdating:l,isSavingRawSettings:c,hasChanges:i,isRawJsonValid:d,onRefresh:r,onSave:n}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Copilot Configuration"}),t&&e.jsx(S,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:r,disabled:s,children:e.jsx(ge,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(N,{size:"sm",onClick:n,disabled:l||c||!i||!d,children:l||c?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const ct=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}],dt=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function ue(t){switch(t){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function mt(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function z({label:t,description:s,value:l,onChange:c,models:i,disabled:d}){const{t:r}=ie();return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),s&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsx(We,{value:l||void 0,onChange:c,disabled:d,placeholder:r("componentModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:r("componentModelSelector.availableModelsCount",{count:i.length})}],options:i.map(n=>({value:n.id,groupKey:"models",searchText:`${n.name||n.id} ${n.id}`,keywords:[n.minPlan??"",n.preview?"preview":""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.name||n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan}),n.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:mt(n.multiplier)}),n.preview&&e.jsx(S,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:r("componentModelSelector.preview")})]})}))})]})}function ee(t){if(t>=1e6){const s=t/1e6;return s%1===0?`${s}M`:`${s.toFixed(1)}M`}if(t>=1e3){const s=t/1e3;return s%1===0?`${s}K`:`${s.toFixed(1)}K`}return`${t}`}function ut(t){if(!t?.limits)return null;const s=[];return t.limits.maxPromptTokens&&s.push(`prompt ${ee(t.limits.maxPromptTokens)}`),t.limits.maxContextWindowTokens&&s.push(`context ${ee(t.limits.maxContextWindowTokens)}`),t.limits.maxOutputTokens&&s.push(`output ${ee(t.limits.maxOutputTokens)}`),s.length>0?s.join(" | "):null}function xt({currentModel:t,opusModel:s,sonnetModel:l,haikuModel:c,models:i,modelsLoading:d,onApplyPreset:r,onUpdateModel:n,onUpdateOpusModel:x,onUpdateSonnetModel:p,onUpdateHaikuModel:g}){const o=[{label:"Default",id:t},{label:"Opus",id:s||t},{label:"Sonnet",id:l||t},{label:"Haiku",id:c||t}].map(({label:a,id:u})=>{const y=i.find(P=>P.id===u),C=ut(y);return C?{label:a,id:u,limits:C}:null}).filter(a=>a!==null);return e.jsx(ne,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(H,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ue,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ct.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3 text-green-600"}),a.name]},a.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:dt.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3"}),a.name]},a.name))})]})]}),e.jsx(ae,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"mb-4 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-900 dark:text-amber-200",children:[e.jsx("p",{className:"font-medium",children:"GitHub Copilot controls prompt/context limits upstream."}),e.jsx("p",{className:"mt-1",children:"CCS can switch Copilot models, but it cannot increase the provider's max prompt or context window."}),o.length>0?e.jsx("div",{className:"mt-2 space-y-1 text-[11px] font-mono",children:o.map(a=>e.jsxs("p",{children:[a.label,": ",a.id," (",a.limits,")"]},`${a.label}-${a.id}`))}):e.jsx("p",{className:"mt-2 text-[11px] font-mono",children:"Start the daemon to inspect live model limits from GitHub Copilot metadata."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(z,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:n,models:i,disabled:d}),e.jsx(z,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:x,models:i,disabled:d}),e.jsx(z,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:l||t,onChange:p,models:i,disabled:d}),e.jsx(z,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c||t,onChange:g,models:i,disabled:d})]})]})]})})})}function pt({enabled:t,autoStart:s,port:l,accountType:c,rateLimit:i,waitOnLimit:d,onUpdateEnabled:r,onUpdateAutoStart:n,onUpdatePort:x,onUpdateAccountType:p,onUpdateRateLimit:g,onUpdateWaitOnLimit:o}){const{t:a}=ie();return e.jsx(ne,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(H,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"enabled",className:"text-sm font-medium",children:a("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("copilotSettings.enableCopilotDesc")})]}),e.jsx(Z,{id:"enabled",checked:t,onCheckedChange:r})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"port",className:"text-xs",children:a("copilotPage.port")}),e.jsx(ce,{id:"port",type:"number",value:l,onChange:u=>x(parseInt(u.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"account-type",className:"text-xs",children:a("copilotSettings.accountType")}),e.jsxs(ke,{value:c,onValueChange:p,children:[e.jsx(Fe,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(Te,{})}),e.jsxs(Me,{children:[e.jsx(X,{value:"individual",children:a("copilotSettings.accountTypeIndividual")}),e.jsx(X,{value:"business",children:a("copilotSettings.accountTypeBusiness")}),e.jsx(X,{value:"enterprise",children:a("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"rate-limit",className:"text-xs",children:a("copilotSettings.rateLimitSeconds")}),e.jsx(ce,{id:"rate-limit",type:"number",value:i,onChange:u=>g(u.target.value),placeholder:a("copilotSettings.noLimit"),min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"wait-on-limit",className:"text-xs",children:a("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx(Z,{id:"wait-on-limit",checked:d,onCheckedChange:o})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.daemonSettings")}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"auto-start",className:"text-xs",children:a("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.autoStartDaemonDesc")})]}),e.jsx(Z,{id:"auto-start",checked:s,onCheckedChange:n})]})]})]})})})}function B({label:t,command:s}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:s}),e.jsx(he,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function ht({rawSettings:t}){return e.jsx(ne,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(H,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(Qe,{className:"w-4 h-4"}),"Configuration Info"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:"GitHub Copilot"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:t.path}),e.jsx(he,{value:t.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),e.jsx(S,{variant:"outline",className:t.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:t.exists?"File exists":"Using defaults"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(B,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(B,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(B,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(B,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const gt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function xe(t){const s=t?.env||{};return gt.filter(l=>!s[l]?.trim())}function pe(t){if(!t||t.length===0)return[];const s=new Map;return t.forEach(l=>{s.set(l.message,l)}),[...s.values()]}function ft(){const{config:t,configLoading:s,models:l,modelsLoading:c,rawSettings:i,rawSettingsLoading:d,updateConfigAsync:r,isUpdating:n,saveRawSettingsAsync:x,isSavingRawSettings:p,refetchRawSettings:g}=Ne(),[o,a]=v.useState({}),[u,y]=v.useState(null),[C,P]=v.useState(!1),D=o.enabled??t?.enabled??!1,I=o.autoStart??t?.auto_start??!1,L=o.port??t?.port??4141,K=o.accountType??t?.account_type??"individual",R=o.model??t?.model??"claude-sonnet-4-6",A=o.rateLimit??t?.rate_limit?.toString()??"",f=o.waitOnLimit??t?.wait_on_limit??!0,U=o.opusModel??t?.opus_model??"",Q=o.sonnetModel??t?.sonnet_model??"",$=o.haikuModel??t?.haiku_model??"",J=(h,j)=>{a(O=>({...O,[h]:j}))},V=h=>{a(j=>({...j,model:h.default,opusModel:h.opus,sonnetModel:h.sonnet,haikuModel:h.haiku})),q.success(`Applied "${h.name}" preset`)},k=v.useMemo(()=>u!==null?u:i?.settings?JSON.stringify(i.settings,null,2):`{
|
|
2
2
|
"env": {}
|
|
3
3
|
}`,[u,i]),m=v.useCallback(h=>{y(h)},[]),oe=v.useMemo(()=>{try{return JSON.parse(k),!0}catch{return!1}},[k]),be=v.useMemo(()=>{const h=Object.keys(o).length>0,j=u!==null&&u!==JSON.stringify(i?.settings,null,2);return h||j},[o,u,i]),le=v.useMemo(()=>{if(u!==null)try{return JSON.parse(u)}catch{return i?.settings}return i?.settings},[u,i?.settings]),ye=v.useMemo(()=>xe(le),[le]),Se=v.useMemo(()=>pe([...t?.warnings??[],...i?.warnings??[]]),[t?.warnings,i?.warnings]),re=async({overwriteRawSettings:h=!1}={})=>{try{const j=[];if(Object.keys(o).length>0){const F=await r({enabled:D,auto_start:I,port:L,account_type:K,model:R,rate_limit:A?parseInt(A,10):null,wait_on_limit:f,opus_model:U||void 0,sonnet_model:Q||void 0,haiku_model:$||void 0});j.push(...F.warnings??[])}let O=[];if(u!==null&&oe){const F=JSON.parse(k);O=xe(F);const Ce=await x({settings:F,expectedMtime:h?void 0:i?.mtime});j.push(...Ce.warnings??[])}const W=pe(j),E=[];W.length>0&&E.push(W.map(F=>F.message).join(" ")),O.length>0&&E.push(`Missing fields will use defaults: ${O.join(", ")}`),W.length>0?q.warning("Copilot configuration saved with model adjustments",{description:E.join(" ")}):E.length>0?q.success("Copilot configuration saved",{description:E.join(" ")}):q.success("Copilot configuration saved"),a({}),y(null)}catch(j){Le(j)?P(!0):q.error("Failed to save settings")}};return{configLoading:s,rawSettingsLoading:d,modelsLoading:c,isUpdating:n,isSavingRawSettings:p,models:l,rawSettings:i,rawJsonContent:k,rawJsonEdits:u,enabled:D,autoStart:I,port:L,accountType:K,currentModel:R,rateLimit:A,waitOnLimit:f,opusModel:U,sonnetModel:Q,haikuModel:$,isRawJsonValid:oe,hasChanges:be,normalizationWarnings:Se,conflictDialog:C,updateField:J,applyPreset:V,handleRawJsonChange:m,handleSave:re,handleConflictResolve:async h=>{P(!1),h?await re({overwriteRawSettings:!0}):y(null)},refetchRawSettings:g,missingRequiredFields:ye}}function jt(){const{configLoading:t,rawSettingsLoading:s,modelsLoading:l,isUpdating:c,isSavingRawSettings:i,models:d,rawSettings:r,rawJsonContent:n,rawJsonEdits:x,enabled:p,autoStart:g,port:o,accountType:a,currentModel:u,rateLimit:y,waitOnLimit:C,opusModel:P,sonnetModel:D,haikuModel:I,isRawJsonValid:L,hasChanges:K,normalizationWarnings:R,conflictDialog:A,updateField:f,applyPreset:U,handleRawJsonChange:Q,handleSave:$,handleConflictResolve:J,refetchRawSettings:V,missingRequiredFields:k}=ft();return t||s?e.jsxs("div",{className:"space-y-6",children:[e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(rt,{rawSettings:r,rawSettingsLoading:s,isUpdating:c,isSavingRawSettings:i,hasChanges:K,isRawJsonValid:L,onRefresh:()=>V(),onSave:$}),R.length>0&&e.jsx("div",{className:"px-6 pt-4 shrink-0",children:e.jsxs(Re,{variant:"warning",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(Ae,{children:"Deprecated Copilot models detected"}),e.jsxs(Oe,{className:"space-y-2",children:[e.jsx("p",{children:"Loading this page did not rewrite your files. Save the Copilot configuration to persist these replacements."}),e.jsx("div",{className:"space-y-1",children:R.map(m=>e.jsx("p",{children:m.message},m.message))})]})]})}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(Ee,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(_e,{className:"w-full",children:[e.jsx(Y,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Y,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(Y,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(xt,{currentModel:u,opusModel:P,sonnetModel:D,haikuModel:I,models:d,modelsLoading:l,onApplyPreset:U,onUpdateModel:m=>f("model",m),onUpdateOpusModel:m=>f("opusModel",m),onUpdateSonnetModel:m=>f("sonnetModel",m),onUpdateHaikuModel:m=>f("haikuModel",m)}),e.jsx(pt,{enabled:p,autoStart:g,port:o,accountType:a,rateLimit:y,waitOnLimit:C,onUpdateEnabled:m=>f("enabled",m),onUpdateAutoStart:m=>f("autoStart",m),onUpdatePort:m=>f("port",m),onUpdateAccountType:m=>f("accountType",m),onUpdateRateLimit:m=>f("rateLimit",m),onUpdateWaitOnLimit:m=>f("waitOnLimit",m)}),e.jsx(ht,{rawSettings:r})]})]})})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx($e,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(qe,{rawJsonContent:n,isRawJsonValid:L,rawJsonEdits:x,rawSettingsEnv:r?.settings?.env,onChange:Q,missingRequiredFields:k})]})]}),e.jsx(Ie,{open:A,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>J(!0),onCancel:()=>J(!1)})]})}function te({title:t,children:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:t}),e.jsx("div",{className:"space-y-1",children:s})]})}function G({icon:t,label:s,status:l,statusText:c,variant:i="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(t,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:s})}),e.jsx("div",{className:"flex items-center gap-1.5",children:l?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:se("w-4 h-4",i==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:se("text-xs",i==="warning"?"text-yellow-500":"text-green-500"),children:c||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:c||"No"})]})})]})}function vt(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(b,{className:"h-8 w-full"}),e.jsx(b,{className:"h-12 w-full"}),e.jsx(b,{className:"h-12 w-full"}),e.jsx(b,{className:"h-12 w-full"})]})}function Et(){const{t}=ie(),{status:s,statusLoading:l,refetchStatus:c,startAuth:i,isAuthenticating:d,startDaemon:r,isStartingDaemon:n,stopDaemon:x,isStoppingDaemon:p,install:g,isInstalling:o}=Ne();return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Je,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:t("copilotPage.title")})]}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>c(),disabled:l,children:e.jsx(ge,{className:se("w-4 h-4",l&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("copilotPage.subtitle")})]}),e.jsx(H,{className:"flex-1",children:l?e.jsx(vt,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:t("copilotPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:t("copilotPage.unofficialItem1")}),e.jsx("li",{children:t("copilotPage.unofficialItem2")}),e.jsx("li",{children:t("copilotPage.unofficialItem3")})]})]}),e.jsxs(te,{title:t("copilotPage.setup"),children:[e.jsx(G,{icon:ze,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:t("copilotPage.installed"):t("copilotPage.missing")}),!s?.installed&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>g(void 0),disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),t("copilotPage.installing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-3.5 h-3.5 mr-1.5"}),t("copilotPage.installCopilotApi")]})}),s?.installed&&e.jsx(G,{icon:me,label:t("copilotPage.integration"),status:s?.enabled??!1,statusText:s?.enabled?t("copilotPage.enabled"):t("copilotPage.disabled")})]}),s?.installed&&e.jsxs(te,{title:t("copilotPage.auth"),children:[e.jsx(G,{icon:Ge,label:t("copilotPage.github"),status:s?.authenticated??!1,statusText:s?.authenticated?t("copilotPage.connected"):t("copilotPage.notConnected")}),!s?.authenticated&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>i(),disabled:d,children:t(d?"copilotPage.authenticating":"copilotPage.authenticate")})]}),s?.authenticated&&e.jsxs(te,{title:t("copilotPage.daemon"),children:[e.jsx(G,{icon:He,label:t("copilotPage.status"),status:s?.daemon_running??!1,statusText:s?.daemon_running?t("copilotPage.running"):t("copilotPage.stopped")}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:[t("copilotPage.port"),": ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>x(),disabled:p,children:[e.jsx(Ve,{className:"w-3.5 h-3.5 mr-1.5"}),t(p?"copilotPage.stopping":"copilotPage.stop")]}):e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>r(),disabled:n,children:[e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),t(n?"copilotPage.starting":"copilotPage.start")]})})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:t("copilotPage.proxy")}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ve,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{className:"w-3 h-3 text-muted-foreground"}),t("copilotPage.inactive")]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(jt,{})})]})}export{Et as CopilotPage};
|