@kaitranntt/ccs 7.66.1-dev.4 → 7.66.1-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/ccs.js +10 -0
  2. package/dist/ccs.js.map +1 -1
  3. package/dist/cliproxy/proxy-detector.d.ts.map +1 -1
  4. package/dist/cliproxy/proxy-detector.js +6 -2
  5. package/dist/cliproxy/proxy-detector.js.map +1 -1
  6. package/dist/cliproxy/startup-lock.d.ts.map +1 -1
  7. package/dist/cliproxy/startup-lock.js +5 -1
  8. package/dist/cliproxy/startup-lock.js.map +1 -1
  9. package/dist/cliproxy/tool-sanitization-proxy.d.ts +1 -0
  10. package/dist/cliproxy/tool-sanitization-proxy.d.ts.map +1 -1
  11. package/dist/cliproxy/tool-sanitization-proxy.js +6 -0
  12. package/dist/cliproxy/tool-sanitization-proxy.js.map +1 -1
  13. package/dist/commands/cleanup-command.d.ts +1 -1
  14. package/dist/commands/cleanup-command.d.ts.map +1 -1
  15. package/dist/commands/cleanup-command.js +57 -34
  16. package/dist/commands/cleanup-command.js.map +1 -1
  17. package/dist/commands/command-catalog.js +1 -1
  18. package/dist/commands/command-catalog.js.map +1 -1
  19. package/dist/commands/config-command.d.ts.map +1 -1
  20. package/dist/commands/config-command.js +23 -0
  21. package/dist/commands/config-command.js.map +1 -1
  22. package/dist/config/unified-config-loader.d.ts +2 -1
  23. package/dist/config/unified-config-loader.d.ts.map +1 -1
  24. package/dist/config/unified-config-loader.js +31 -1
  25. package/dist/config/unified-config-loader.js.map +1 -1
  26. package/dist/config/unified-config-types.d.ts +22 -0
  27. package/dist/config/unified-config-types.d.ts.map +1 -1
  28. package/dist/config/unified-config-types.js +10 -1
  29. package/dist/config/unified-config-types.js.map +1 -1
  30. package/dist/errors/error-handler.d.ts.map +1 -1
  31. package/dist/errors/error-handler.js +13 -0
  32. package/dist/errors/error-handler.js.map +1 -1
  33. package/dist/glmt/glmt-transformer.d.ts +1 -0
  34. package/dist/glmt/glmt-transformer.d.ts.map +1 -1
  35. package/dist/glmt/glmt-transformer.js +9 -0
  36. package/dist/glmt/glmt-transformer.js.map +1 -1
  37. package/dist/services/logging/index.d.ts +7 -0
  38. package/dist/services/logging/index.d.ts.map +1 -0
  39. package/dist/services/logging/index.js +22 -0
  40. package/dist/services/logging/index.js.map +1 -0
  41. package/dist/services/logging/log-buffer.d.ts +5 -0
  42. package/dist/services/logging/log-buffer.d.ts.map +1 -0
  43. package/dist/services/logging/log-buffer.js +20 -0
  44. package/dist/services/logging/log-buffer.js.map +1 -0
  45. package/dist/services/logging/log-config.d.ts +4 -0
  46. package/dist/services/logging/log-config.d.ts.map +1 -0
  47. package/dist/services/logging/log-config.js +68 -0
  48. package/dist/services/logging/log-config.js.map +1 -0
  49. package/dist/services/logging/log-paths.d.ts +8 -0
  50. package/dist/services/logging/log-paths.d.ts.map +1 -0
  51. package/dist/services/logging/log-paths.js +66 -0
  52. package/dist/services/logging/log-paths.js.map +1 -0
  53. package/dist/services/logging/log-reader.d.ts +5 -0
  54. package/dist/services/logging/log-reader.d.ts.map +1 -0
  55. package/dist/services/logging/log-reader.js +124 -0
  56. package/dist/services/logging/log-reader.js.map +1 -0
  57. package/dist/services/logging/log-redaction.d.ts +2 -0
  58. package/dist/services/logging/log-redaction.d.ts.map +1 -0
  59. package/dist/services/logging/log-redaction.js +53 -0
  60. package/dist/services/logging/log-redaction.js.map +1 -0
  61. package/dist/services/logging/log-storage.d.ts +4 -0
  62. package/dist/services/logging/log-storage.d.ts.map +1 -0
  63. package/dist/services/logging/log-storage.js +109 -0
  64. package/dist/services/logging/log-storage.js.map +1 -0
  65. package/dist/services/logging/log-types.d.ts +30 -0
  66. package/dist/services/logging/log-types.d.ts.map +1 -0
  67. package/dist/services/logging/log-types.js +19 -0
  68. package/dist/services/logging/log-types.js.map +1 -0
  69. package/dist/services/logging/logger.d.ts +9 -0
  70. package/dist/services/logging/logger.d.ts.map +1 -0
  71. package/dist/services/logging/logger.js +46 -0
  72. package/dist/services/logging/logger.js.map +1 -0
  73. package/dist/ui/assets/{accounts-DUWrYt3x.js → accounts-CoxemH1E.js} +1 -1
  74. package/dist/ui/assets/{alert-dialog-D_Yz_iZc.js → alert-dialog-CIVd-ody.js} +1 -1
  75. package/dist/ui/assets/{api-CBTgaJzF.js → api-BVfXHYxj.js} +2 -2
  76. package/dist/ui/assets/{auth-section-BoDZqbPJ.js → auth-section-DDd9GEBK.js} +1 -1
  77. package/dist/ui/assets/{backups-section-D4-FbvV4.js → backups-section-BWbdSnXt.js} +1 -1
  78. package/dist/ui/assets/{channels-BFBl4r-j.js → channels-BPxlzEif.js} +1 -1
  79. package/dist/ui/assets/{checkbox-DjeKLLRq.js → checkbox-BKFUU2sG.js} +1 -1
  80. package/dist/ui/assets/{claude-extension-C1FsOq-7.js → claude-extension-C-6KUHA0.js} +1 -1
  81. package/dist/ui/assets/{cliproxy-C2sZh-5V.js → cliproxy-C2_5ie4n.js} +2 -2
  82. package/dist/ui/assets/{cliproxy-ai-providers-DcCbeAbO.js → cliproxy-ai-providers-D1-ZGJt9.js} +5 -5
  83. package/dist/ui/assets/{cliproxy-control-panel-v4kA_2hy.js → cliproxy-control-panel-CTjW6xf_.js} +1 -1
  84. package/dist/ui/assets/{codex-Cj_wPgw5.js → codex-xU8SQWhS.js} +1 -1
  85. package/dist/ui/assets/{confirm-dialog-B273dyaD.js → confirm-dialog-B9mG4XrE.js} +1 -1
  86. package/dist/ui/assets/{copilot-DvgELRFw.js → copilot-B_cDTXu9.js} +2 -2
  87. package/dist/ui/assets/{cursor-8gcvd36W.js → cursor-B0aHykdX.js} +1 -1
  88. package/dist/ui/assets/{droid-DZDVCJBf.js → droid-Cou-phPn.js} +1 -1
  89. package/dist/ui/assets/{globalenv-section-CKv4BfT4.js → globalenv-section-B7fDhbOR.js} +1 -1
  90. package/dist/ui/assets/{health-DmZLL4IN.js → health-Cux4-fWS.js} +1 -1
  91. package/dist/ui/assets/icons-C4EMu2PL.js +1 -0
  92. package/dist/ui/assets/index-7qTHMz5v.css +1 -0
  93. package/dist/ui/assets/index-B-YlctHj.js +69 -0
  94. package/dist/ui/assets/index-CHWn7pks.js +1 -0
  95. package/dist/ui/assets/{index-DUM_z9jT.js → index-Cp8KcNTJ.js} +1 -1
  96. package/dist/ui/assets/{index-l8yS9gLo.js → index-CvqYFZA_.js} +1 -1
  97. package/dist/ui/assets/{index-DESEUD89.js → index-DOFoLunG.js} +1 -1
  98. package/dist/ui/assets/{index-B185OZF2.js → index-WuuQNt8F.js} +1 -1
  99. package/dist/ui/assets/logs-C2LvO27n.js +1 -0
  100. package/dist/ui/assets/{masked-input-C-vLCUuQ.js → masked-input-DyN9mmaP.js} +1 -1
  101. package/dist/ui/assets/{proxy-status-widget-190bjsgV.js → proxy-status-widget-EgraEYSp.js} +1 -1
  102. package/dist/ui/assets/{raw-json-settings-editor-panel-DcwxTJM2.js → raw-json-settings-editor-panel-T7HrEBqp.js} +1 -1
  103. package/dist/ui/assets/{searchable-select-CCNEAmMs.js → searchable-select-Bfwi19-3.js} +1 -1
  104. package/dist/ui/assets/{separator-DdqwGZjf.js → separator-Cia83j78.js} +1 -1
  105. package/dist/ui/assets/{shared-CiXoJI0N.js → shared-BRUYjDc4.js} +1 -1
  106. package/dist/ui/assets/{table-BbSidPe4.js → table-DVwKEwq6.js} +1 -1
  107. package/dist/ui/assets/{tanstack-DWm6aJ-G.js → tanstack-CrmUhA7Z.js} +2 -2
  108. package/dist/ui/assets/updates-CfwrNAck.js +1 -0
  109. package/dist/ui/index.html +4 -4
  110. package/dist/utils/websearch/trace.d.ts.map +1 -1
  111. package/dist/utils/websearch/trace.js +7 -0
  112. package/dist/utils/websearch/trace.js.map +1 -1
  113. package/dist/web-server/index.d.ts.map +1 -1
  114. package/dist/web-server/index.js +15 -0
  115. package/dist/web-server/index.js.map +1 -1
  116. package/dist/web-server/middleware/request-logging-middleware.d.ts +3 -0
  117. package/dist/web-server/middleware/request-logging-middleware.d.ts.map +1 -0
  118. package/dist/web-server/middleware/request-logging-middleware.js +30 -0
  119. package/dist/web-server/middleware/request-logging-middleware.js.map +1 -0
  120. package/dist/web-server/routes/index.d.ts.map +1 -1
  121. package/dist/web-server/routes/index.js +2 -0
  122. package/dist/web-server/routes/index.js.map +1 -1
  123. package/dist/web-server/routes/logs-routes.d.ts +3 -0
  124. package/dist/web-server/routes/logs-routes.d.ts.map +1 -0
  125. package/dist/web-server/routes/logs-routes.js +75 -0
  126. package/dist/web-server/routes/logs-routes.js.map +1 -0
  127. package/dist/web-server/services/logs-dashboard-service.d.ts +7 -0
  128. package/dist/web-server/services/logs-dashboard-service.d.ts.map +1 -0
  129. package/dist/web-server/services/logs-dashboard-service.js +33 -0
  130. package/dist/web-server/services/logs-dashboard-service.js.map +1 -0
  131. package/dist/web-server/websocket.d.ts.map +1 -1
  132. package/dist/web-server/websocket.js +23 -14
  133. package/dist/web-server/websocket.js.map +1 -1
  134. package/package.json +1 -1
  135. package/dist/ui/assets/icons-HPncf80J.js +0 -1
  136. package/dist/ui/assets/index-CObGkcxo.js +0 -1
  137. package/dist/ui/assets/index-D8NlA5zN.js +0 -69
  138. package/dist/ui/assets/index-DY4gWzEw.css +0 -1
  139. package/dist/ui/assets/updates-DqccLz_y.js +0 -1
@@ -1,11 +1,11 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as m,u as qe,h as $e}from"./react-vendor-CNOkPC89.js";import{c as H,aC as me,b3 as ue,B as h,af as He,ag as Ke,ah as Be,ai as De,aj as Fe,L as A,I as k,M as Ge,N as Ve,O as Je,aB as ze,d as f,Y as ae,S as fe,n as ee,Q as ve,R as ye,U as W,V as X,b4 as be,b5 as _e}from"./index-D8NlA5zN.js";import{P as Qe}from"./proxy-status-widget-190bjsgV.js";import{C as We}from"./confirm-dialog-B273dyaD.js";import{k as Xe,v as Pe,l as Ae,m as pe,au as se,r as Ye,R as le,Z as Ze,a6 as Se,o as Ie,aG as es,N as ss,ap as ts,aq as rs,V as je,aH as Ue,aI as Le,ae as Me,at as as,aJ as ns}from"./icons-HPncf80J.js";import{u as is,a as xe,b as he}from"./tanstack-DWm6aJ-G.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-D_Yz_iZc.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:r}){return e.jsx("div",{className:"space-y-1",children:t.map(a=>{const i=a.id===s,o=ls(a.status),d=o.icon;return e.jsx("button",{type:"button",onClick:()=>r(a.id),className:H("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(a.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:a.displayName}),a.entries.length>0&&e.jsx(h,{variant:"secondary",className:"h-4 px-1 text-[10px]",children:a.entries.length})]}),e.jsxs("div",{className:H("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:a.authMode})]})},a.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(`
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as m,u as qe,h as Ke}from"./react-vendor-CNOkPC89.js";import{c as $,aC as me,b3 as ue,B as h,af as $e,ag as He,ah as Be,ai as De,aj as Fe,L as A,I as k,M as Ge,N as Ve,O as Je,aB as ze,d as f,Y as ae,S as fe,n as ee,Q as ve,R as ye,U as W,V as X,b4 as be,b5 as _e}from"./index-B-YlctHj.js";import{P as Qe}from"./proxy-status-widget-EgraEYSp.js";import{C as We}from"./confirm-dialog-B9mG4XrE.js";import{l as Xe,w as Pe,m as Ae,n as pe,aw as se,s as Ye,R as le,Z as Ze,a8 as Se,p as Ie,aH as es,O as ss,ar as ts,as as rs,Y as je,aI as Ue,aJ as Le,ag as Me,av as as,aK as ns}from"./icons-C4EMu2PL.js";import{u as is,a as xe,b as he}from"./tanstack-CrmUhA7Z.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-CIVd-ody.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:r}){return e.jsx("div",{className:"space-y-1",children:t.map(a=>{const i=a.id===s,o=ls(a.status),d=o.icon;return e.jsx("button",{type:"button",onClick:()=>r(a.id),className:$("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(a.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:a.displayName}),a.entries.length>0&&e.jsx(h,{variant:"secondary",className:"h-4 px-1 text-[10px]",children:a.entries.length})]}),e.jsxs("div",{className:$("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:a.authMode})]})},a.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 r=s.includes(":")?":":"=",[a,...i]=s.split(r);return{key:a.trim(),value:i.join(r).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 r=s.indexOf("=");return r===-1?{name:s.trim(),alias:""}:{name:s.slice(0,r).trim(),alias:s.slice(r+1).trim()}}).filter(s=>s.name.length>0||s.alias.length>0)}function Y({value:t,onChange:s,placeholder:r,rows:a=4}){return e.jsx("textarea",{rows:a,value:t,onChange:i=>s(i.target.value),placeholder:r,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
- `)}function we({title:t,items:s,icon:r}){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:[r,t]}),e.jsx("div",{className:"mt-3 space-y-3",children:s.map((a,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:a})]},`${t}:${a}`))})]})}function hs({family:t,entry:s,open:r,onOpenChange:a,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,z]=m.useState(()=>s?.prefix||""),[N,U]=m.useState(""),[y,p]=m.useState(""),[L,w]=m.useState(()=>us(s)),[q,K]=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(He,{open:r,onOpenChange:a,children:e.jsx(Ke,{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:H("h-4 w-4 text-muted-foreground transition-transform",R&&"rotate-180")})]})}),e.jsx(Je,{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=>z(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:K,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(ze,{className:"border-t bg-muted/10 px-6 py-4",children:[e.jsx(f,{type:"button",variant:"outline",onClick:()=>a(!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:()=>ae.cliproxy.aiProviders.list()})}function fs(){const t=xe();return he({mutationFn:({family:s,data:r})=>ae.cliproxy.aiProviders.create(s,r),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:r,data:a})=>ae.cliproxy.aiProviders.update(s,r,a),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:r})=>ae.cliproxy.aiProviders.delete(s,r),onSuccess:()=>{t.invalidateQueries({queryKey:ne}),G.success("Provider entry removed")},onError:s=>{G.error(s.message)}})}function _({label:t,value:s,hint:r}){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}),r?e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r}):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),r=Re(t),a=[];return s>0&&a.push(`${s} mapped`),r>0&&a.push(`${r} direct`),a.length>0?a.join(" + "):"No model rules"}function ce({configured:t}){return e.jsx(h,{variant:"secondary",className:H("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 J(t){return t.split(`
7
+ `)}function we({title:t,items:s,icon:r}){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:[r,t]}),e.jsx("div",{className:"mt-3 space-y-3",children:s.map((a,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:a})]},`${t}:${a}`))})]})}function hs({family:t,entry:s,open:r,onOpenChange:a,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,z]=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(),K=Ne(y),C=l&&s?.secretConfigured&&!n.length&&K.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?K.length>0?{apiKeys:K}:{}:n.length>0?{apiKey:n}:{}};await i(ie)};return e.jsx($e,{open:r,onOpenChange:a,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:$("h-4 w-4 text-muted-foreground transition-transform",R&&"rotate-180")})]})}),e.jsx(Je,{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=>z(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(ze,{className:"border-t bg-muted/10 px-6 py-4",children:[e.jsx(f,{type:"button",variant:"outline",onClick:()=>a(!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:()=>ae.cliproxy.aiProviders.list()})}function fs(){const t=xe();return he({mutationFn:({family:s,data:r})=>ae.cliproxy.aiProviders.create(s,r),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:r,data:a})=>ae.cliproxy.aiProviders.update(s,r,a),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:r})=>ae.cliproxy.aiProviders.delete(s,r),onSuccess:()=>{t.invalidateQueries({queryKey:ne}),G.success("Provider entry removed")},onError:s=>{G.error(s.message)}})}function _({label:t,value:s,hint:r}){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}),r?e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r}):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),r=Re(t),a=[];return s>0&&a.push(`${s} mapped`),r>0&&a.push(`${r} direct`),a.length>0?a.join(" + "):"No model rules"}function ce({configured:t}){return e.jsx(h,{variant:"secondary",className:$("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 J(t){return t.split(`
9
9
  `).map(s=>s.trim()).filter(s=>s.length>0)}function re(t){return t.split(`
10
10
  `).map(s=>s.trim()).filter(s=>s.length>0).map(s=>{const r=s.includes(":")?":":"=",[a,...i]=s.split(r);return{key:a.trim(),value:i.join(r).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 r=s.indexOf("=");return r===-1?{name:s.trim(),alias:""}:{name:s.slice(0,r).trim(),alias:s.slice(r+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(`
@@ -17,5 +17,5 @@ ${d.keyPlaceholder}`}),e.jsx("p",{className:"text-xs text-muted-foreground",chil
17
17
  `)}}const i=a;return{name:"",baseUrl:typeof i["base-url"]=="string"?i["base-url"]:"",proxyUrl:typeof i["proxy-url"]=="string"?i["proxy-url"]:"",prefix:typeof i.prefix=="string"?i.prefix:"",headersText:i.headers&&typeof i.headers=="object"&&!Array.isArray(i.headers)?Object.entries(i.headers).map(([o,d])=>`${o}: ${d}`).join(`
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
- `):"",apiKey:typeof i["api-key"]=="string"&&i["api-key"]!==V?i["api-key"]:"",apiKeysText:""}}function Ss(t,s,r){if(t.id==="openai-compatibility"){const o=J(r.apiKeysText),d=s.secretConfigured&&o.length===0;return{name:r.name.trim(),baseUrl:r.baseUrl.trim(),headers:re(r.headersText),models:Q(r.modelAliasesText),preserveSecrets:d,...o.length>0?{apiKeys:o}:{}}}const a=r.apiKey.trim(),i=s.secretConfigured&&a.length===0;return{baseUrl:r.baseUrl.trim(),proxyUrl:r.proxyUrl.trim(),prefix:r.prefix.trim(),headers:re(r.headersText),excludedModels:J(r.excludedModelsText),models:Q(r.modelAliasesText),preserveSecrets:i,...a.length>0?{apiKey:a}:{}}}function Is(t,s,r){const a={ANTHROPIC_BASE_URL:`${r.target}${t.routePath}`,ANTHROPIC_AUTH_TOKEN:"ccs-internal-managed"},i=Q(s.modelAliasesText).find(o=>o.name.trim());return i?.name&&(a.ANTHROPIC_MODEL=i.name),{env:a}}function ke({badge:t,title:s,items:r}){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:r.map((a,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:a})]},`${s}:${a}`))})]})}function M({label:t,helper:s,children:r}){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}),r,s?e.jsx("div",{className:"text-xs leading-5 text-muted-foreground",children:s}):null]})}function Z({value:t,onChange:s,placeholder:r,rows:a=4}){return e.jsx("textarea",{rows:a,value:t,onChange:i=>s(i.target.value),placeholder:r,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:r,isSaving:a,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"),[z,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,r),[l,t,r]),w=m.useMemo(()=>Q(l.modelAliasesText),[l.modelAliasesText]),q=m.useMemo(()=>re(l.headersText),[l.headersText]),K=m.useMemo(()=>J(l.excludedModelsText),[l.excludedModelsText]),B=m.useMemo(()=>JSON.stringify(L,null,2),[L]),g=Te(w),R=Re(w),P=q.length+K.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&&J(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:r.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:!$||a,children:[e.jsx(rs,{className:"mr-1 h-3.5 w-3.5"}),a?"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:z,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:r.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(as,{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%",heightMode:"fill-parent"})})})]})}),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%",heightMode:"fill-parent"})})}),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:r,onOpenProfiles:a}){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:r,children:"Control Panel"}),e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:a,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:r,error:a,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,z]=m.useState(null),N=m.useMemo(()=>r?.families??[],[r?.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-full min-h-0 overflow-hidden",children:[e.jsx(fe,{className:"h-full w-80 rounded-none"}),e.jsx(fe,{className:"h-full flex-1 rounded-none"})]});if(a||!r||!p){const n=a instanceof Error?a.message:"Failed to load CLIProxy AI providers. Check the local server and try again.";return e.jsx("div",{className:"flex h-full 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 K=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:`${K.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-full min-h-0 overflow-hidden",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:H("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:H("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:[K.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:()=>z(n.id),className:H("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:r.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};
20
+ `):"",apiKey:typeof i["api-key"]=="string"&&i["api-key"]!==V?i["api-key"]:"",apiKeysText:""}}function Ss(t,s,r){if(t.id==="openai-compatibility"){const o=J(r.apiKeysText),d=s.secretConfigured&&o.length===0;return{name:r.name.trim(),baseUrl:r.baseUrl.trim(),headers:re(r.headersText),models:Q(r.modelAliasesText),preserveSecrets:d,...o.length>0?{apiKeys:o}:{}}}const a=r.apiKey.trim(),i=s.secretConfigured&&a.length===0;return{baseUrl:r.baseUrl.trim(),proxyUrl:r.proxyUrl.trim(),prefix:r.prefix.trim(),headers:re(r.headersText),excludedModels:J(r.excludedModelsText),models:Q(r.modelAliasesText),preserveSecrets:i,...a.length>0?{apiKey:a}:{}}}function Is(t,s,r){const a={ANTHROPIC_BASE_URL:`${r.target}${t.routePath}`,ANTHROPIC_AUTH_TOKEN:"ccs-internal-managed"},i=Q(s.modelAliasesText).find(o=>o.name.trim());return i?.name&&(a.ANTHROPIC_MODEL=i.name),{env:a}}function ke({badge:t,title:s,items:r}){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:r.map((a,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:a})]},`${s}:${a}`))})]})}function M({label:t,helper:s,children:r}){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}),r,s?e.jsx("div",{className:"text-xs leading-5 text-muted-foreground",children:s}):null]})}function Z({value:t,onChange:s,placeholder:r,rows:a=4}){return e.jsx("textarea",{rows:a,value:t,onChange:i=>s(i.target.value),placeholder:r,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:r,isSaving:a,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"),[z,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,r),[l,t,r]),w=m.useMemo(()=>Q(l.modelAliasesText),[l.modelAliasesText]),q=m.useMemo(()=>re(l.headersText),[l.headersText]),H=m.useMemo(()=>J(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&&J(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]),K=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:r.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:!K||a,children:[e.jsx(rs,{className:"mr-1 h-3.5 w-3.5"}),a?"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:z,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:r.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(as,{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%",heightMode:"fill-parent"})})})]})}),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%",heightMode:"fill-parent"})})}),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:r,onOpenProfiles:a}){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:r,children:"Control Panel"}),e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:a,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=Ke(),{data:r,error:a,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,z]=m.useState(null),N=m.useMemo(()=>r?.families??[],[r?.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(K=>K.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-full min-h-0 overflow-hidden",children:[e.jsx(fe,{className:"h-full w-80 rounded-none"}),e.jsx(fe,{className:"h-full flex-1 rounded-none"})]});if(a||!r||!p){const n=a instanceof Error?a.message:"Failed to load CLIProxy AI providers. Check the local server and try again.";return e.jsx("div",{className:"flex h-full 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-full min-h-0 overflow-hidden",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:$("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:$("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:()=>z(n.id),className:$("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:r.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};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as R}from"./tanstack-DWm6aJ-G.js";import{b6 as g,Y as I}from"./index-D8NlA5zN.js";import{C as S}from"./default-ports-1QQSffYX.js";import{G as z,R as _,v as D}from"./icons-HPncf80J.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const k="cli-proxy-auth",T="isLoggedIn",O="apiBase",U="apiUrl",K="managementKey";function $(a){return a.startsWith("/")?new URL(a.replace(/\/$/,""),window.location.origin).href:a.replace(/\/$/,"")}function Q(a,c){window.localStorage.removeItem(k),window.localStorage.setItem(O,a),window.localStorage.setItem(U,a),window.localStorage.setItem(K,c),window.localStorage.setItem(T,"true")}function A(){window.localStorage.removeItem(k),window.localStorage.removeItem(O),window.localStorage.removeItem(U),window.localStorage.removeItem(K),window.localStorage.removeItem(T)}function X({port:a=S}){const c=s.useRef(null),[F,C]=s.useState(null),[M,B]=s.useState(0),[L,N]=s.useState(null),[Y,v]=s.useState(!1),{data:l,error:p}=R({queryKey:["cliproxy-server-config"],queryFn:()=>I.cliproxyServer.get(),staleTime:3e4});s.useEffect(()=>{p&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",p)},[p]);const E=!!(l?.remote?.enabled&&l?.remote?.host),{data:w,error:f}=R({queryKey:["auth-tokens-raw",E?"remote":"local"],enabled:l!==void 0&&!E,queryFn:async()=>{try{const t=await fetch(g("/settings/auth/tokens/raw"));if(!t.ok)throw new Error("Failed to fetch auth tokens");const n=await t.json(),o=n.managementSecret.value.trim();if(!o)throw new Error("Management secret missing");return Q($(g("/cliproxy-local/")),o),n}catch(t){throw A(),t}},staleTime:3e4}),{managementUrl:P,checkUrl:x,authToken:y,isRemote:i,displayHost:m}=s.useMemo(()=>{const t=l?.remote,n=l?.local?.port??a;if(t?.enabled&&t?.host){const o=t.protocol||"http",d=t.port||(o==="https"?443:S),h=o==="https"&&d===443||o==="http"&&d===80?"":`:${d}`,r=`${o}://${t.host}${h}`;return{managementUrl:`${r}/management.html`,checkUrl:`${r}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${h}`}}return{managementUrl:g("/cliproxy-local/management.html"),checkUrl:g("/cliproxy-local/"),authToken:w?.managementSecret?.value||void 0,isRemote:!1,displayHost:`localhost:${n}`}},[l,w,a]),b=`${P}:${i?"remote":"local"}:${x}:${y??"missing"}:${M}`,j=l!==void 0&&(i||!!w||!!f);s.useEffect(()=>{f&&console.warn("[ControlPanelEmbed] Failed to preload local control panel session, falling back to manual login:",f)},[f]),s.useEffect(()=>{if(!i)return()=>{A()}},[i]);const G=!j||!(F===b),q=()=>{if(!(!i||!c.current?.contentWindow||!y))try{const t=$(x),n=new URL(`${t}/`).origin;if(new URL(c.current.src,window.location.origin).origin!==n){console.warn("[ControlPanelEmbed] Remote iframe origin mismatch, skipping postMessage");return}c.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:y},n)}catch(t){console.debug("[ControlPanelEmbed] Remote postMessage bootstrap failed:",t)}};s.useEffect(()=>{const t=new AbortController;let n=!1;const o=(r,u)=>{n||(v(r),N(u))},d=async()=>{try{if(i){const r=l?.remote,u=await I.cliproxyServer.test({host:r?.host??"",port:r?.port,protocol:r?.protocol??"http",authToken:r?.auth_token});u?.reachable?o(!0,null):o(!1,u?.error?`Remote CLIProxy at ${m}: ${u.error}`:`Remote CLIProxy at ${m} returned an error`)}else(await fetch(x,{signal:t.signal})).ok?o(!0,null):o(!1,"CLIProxy returned an error")}catch(r){if(r instanceof Error&&r.name==="AbortError")return;o(!1,i?`Remote CLIProxy at ${m} is not reachable`:"CLIProxy is not running")}},h=setTimeout(()=>t.abort(),2e3);return d().finally(()=>clearTimeout(h)),()=>{n=!0,t.abort()}},[x,i,m,l]);const H=()=>{C(b),q()},W=()=>{C(null),B(t=>t+1),N(null),v(!1)};return!Y&&L?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(z,{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:W,children:[e.jsx(_,{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(D,{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:L}),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:[G&&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(_,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?`Loading Control Panel from ${m}...`:"Loading Control Panel..."})]})}),j?e.jsx("iframe",{ref:c,src:P,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:H},b):null]})})}function ie(){return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(X,{})})}export{ie as CliproxyControlPanelPage};
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as R}from"./tanstack-CrmUhA7Z.js";import{b6 as g,Y as I}from"./index-B-YlctHj.js";import{C as S}from"./default-ports-1QQSffYX.js";import{G as z,R as _,w as D}from"./icons-C4EMu2PL.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const k="cli-proxy-auth",T="isLoggedIn",O="apiBase",U="apiUrl",K="managementKey";function $(a){return a.startsWith("/")?new URL(a.replace(/\/$/,""),window.location.origin).href:a.replace(/\/$/,"")}function Q(a,c){window.localStorage.removeItem(k),window.localStorage.setItem(O,a),window.localStorage.setItem(U,a),window.localStorage.setItem(K,c),window.localStorage.setItem(T,"true")}function A(){window.localStorage.removeItem(k),window.localStorage.removeItem(O),window.localStorage.removeItem(U),window.localStorage.removeItem(K),window.localStorage.removeItem(T)}function X({port:a=S}){const c=s.useRef(null),[F,C]=s.useState(null),[M,B]=s.useState(0),[L,N]=s.useState(null),[Y,v]=s.useState(!1),{data:l,error:p}=R({queryKey:["cliproxy-server-config"],queryFn:()=>I.cliproxyServer.get(),staleTime:3e4});s.useEffect(()=>{p&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",p)},[p]);const E=!!(l?.remote?.enabled&&l?.remote?.host),{data:w,error:f}=R({queryKey:["auth-tokens-raw",E?"remote":"local"],enabled:l!==void 0&&!E,queryFn:async()=>{try{const t=await fetch(g("/settings/auth/tokens/raw"));if(!t.ok)throw new Error("Failed to fetch auth tokens");const n=await t.json(),o=n.managementSecret.value.trim();if(!o)throw new Error("Management secret missing");return Q($(g("/cliproxy-local/")),o),n}catch(t){throw A(),t}},staleTime:3e4}),{managementUrl:P,checkUrl:x,authToken:y,isRemote:i,displayHost:m}=s.useMemo(()=>{const t=l?.remote,n=l?.local?.port??a;if(t?.enabled&&t?.host){const o=t.protocol||"http",d=t.port||(o==="https"?443:S),h=o==="https"&&d===443||o==="http"&&d===80?"":`:${d}`,r=`${o}://${t.host}${h}`;return{managementUrl:`${r}/management.html`,checkUrl:`${r}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${h}`}}return{managementUrl:g("/cliproxy-local/management.html"),checkUrl:g("/cliproxy-local/"),authToken:w?.managementSecret?.value||void 0,isRemote:!1,displayHost:`localhost:${n}`}},[l,w,a]),b=`${P}:${i?"remote":"local"}:${x}:${y??"missing"}:${M}`,j=l!==void 0&&(i||!!w||!!f);s.useEffect(()=>{f&&console.warn("[ControlPanelEmbed] Failed to preload local control panel session, falling back to manual login:",f)},[f]),s.useEffect(()=>{if(!i)return()=>{A()}},[i]);const G=!j||!(F===b),q=()=>{if(!(!i||!c.current?.contentWindow||!y))try{const t=$(x),n=new URL(`${t}/`).origin;if(new URL(c.current.src,window.location.origin).origin!==n){console.warn("[ControlPanelEmbed] Remote iframe origin mismatch, skipping postMessage");return}c.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:y},n)}catch(t){console.debug("[ControlPanelEmbed] Remote postMessage bootstrap failed:",t)}};s.useEffect(()=>{const t=new AbortController;let n=!1;const o=(r,u)=>{n||(v(r),N(u))},d=async()=>{try{if(i){const r=l?.remote,u=await I.cliproxyServer.test({host:r?.host??"",port:r?.port,protocol:r?.protocol??"http",authToken:r?.auth_token});u?.reachable?o(!0,null):o(!1,u?.error?`Remote CLIProxy at ${m}: ${u.error}`:`Remote CLIProxy at ${m} returned an error`)}else(await fetch(x,{signal:t.signal})).ok?o(!0,null):o(!1,"CLIProxy returned an error")}catch(r){if(r instanceof Error&&r.name==="AbortError")return;o(!1,i?`Remote CLIProxy at ${m} is not reachable`:"CLIProxy is not running")}},h=setTimeout(()=>t.abort(),2e3);return d().finally(()=>clearTimeout(h)),()=>{n=!0,t.abort()}},[x,i,m,l]);const H=()=>{C(b),q()},W=()=>{C(null),B(t=>t+1),N(null),v(!1)};return!Y&&L?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(z,{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:W,children:[e.jsx(_,{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(D,{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:L}),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:[G&&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(_,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?`Loading Control Panel from ${m}...`:"Loading Control Panel..."})]})}),j?e.jsx("iframe",{ref:c,src:P,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:H},b):null]})})}function ie(){return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(X,{})})}export{ie as CliproxyControlPanelPage};
@@ -1,4 +1,4 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as b}from"./react-vendor-CNOkPC89.js";import{t as K}from"./notifications-B2HqRBj7.js";import{C as D,j as M,k as I,B as y,b as F,d as w,aE as B,r as _,s as E,t as P,v as O,w as v,I as C,n as xe,b6 as J,b7 as Te,c as _e,bd as $e,be as fe,bf as Ye,Q as Be,R as He,U as re,V as te,b8 as je}from"./index-D8NlA5zN.js";import{a7 as Qe,aN as Je,ap as Z,L as z,m as Ze,aO as es,aP as ss,au as rs,v as ts,a4 as ns,aQ as as,aR as ls,aS as os,ae as de,o as ge,Y as is,l as cs,n as ds,V as us,S as ms,aI as ve,aT as xs,w as hs,D as ps,T as fs,J as js}from"./icons-HPncf80J.js";import{S as Q}from"./separator-DdqwGZjf.js";import{a as gs,u as be,b as we}from"./tanstack-DWm6aJ-G.js";import"./code-highlight-BRUf_pqB.js";import{T as vs,a as bs,b as Ne,c as ne,d as ws,e as ae}from"./table-BbSidPe4.js";import{R as Ns}from"./raw-json-settings-editor-panel-DcwxTJM2.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";function H({title:s,icon:r,badge:t,description:a,disabledReason:n,children:l}){return e.jsxs(D,{children:[e.jsxs(M,{className:"pb-2",children:[e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[r,s,t?e.jsx(y,{variant:"outline",className:"text-[10px] font-normal",children:t}):null]}),a?e.jsx("p",{className:"text-xs text-muted-foreground",children:a}):null]}),e.jsxs(F,{className:"space-y-3",children:[n?e.jsx("p",{className:"text-xs text-amber-600",children:n}):null,l]})]})}function Cs({catalog:s,state:r,disabled:t=!1,disabledReason:a,onToggle:n}){const l=new Set(s.map(o=>o.name)),i=Object.entries(r).filter(([o])=>!l.has(o)).sort(([o],[d])=>o.localeCompare(d));return e.jsxs(H,{title:"Features",badge:"features",icon:e.jsx(Qe,{className:"h-4 w-4"}),description:"Toggle the supported Codex feature flags CCS can safely manage.",disabledReason:a,children:[e.jsx("div",{className:"space-y-2",children:s.map(o=>{const d=r[o.name]??null;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:o.label}),e.jsx(y,{variant:"outline",className:"font-mono text-[10px]",children:o.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d!==null?e.jsx(w,{variant:"outline",size:"sm",onClick:()=>n(o.name,null),disabled:t,children:"Use default"}):null,e.jsx(B,{checked:d===!0,onCheckedChange:c=>n(o.name,c),disabled:t})]})]},o.name)})}),i.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Existing config-only flags"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These feature keys already exist in your `config.toml`, so CCS can surface them without claiming full catalog coverage."})]}),i.map(([o,d])=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-dashed px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:o}),e.jsx(y,{variant:"secondary",className:"text-[10px]",children:"existing"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d===null?"Stored in a non-boolean form. Use raw TOML if you need to edit it.":"Discovered from the current file instead of CCS's built-in catalog."})]}),d===null?e.jsx(y,{variant:"outline",children:"Raw only"}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"sm",onClick:()=>n(o,null),disabled:t,children:"Use default"}),e.jsx(B,{checked:d===!0,onCheckedChange:c=>n(o,c),disabled:t})]})]},o))]}):null]})}const ys={name:"",transport:"stdio",command:null,args:[],url:null,enabled:!0,required:!1,startupTimeoutSec:null,toolTimeoutSec:null,enabledTools:[],disabledTools:[]};function le(s){return s.join(", ")}function oe(s){return s.split(",").map(r=>r.trim()).filter(Boolean)}function Ss({initialDraft:s,isNew:r,disabled:t,saving:a,canDelete:n,onSave:l,onDelete:i}){const[o,d]=b.useState(s);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:o.name,onChange:c=>d(u=>({...u,name:c.target.value})),placeholder:"playwright",disabled:t||!r}),e.jsxs(_,{value:o.transport,onValueChange:c=>d(u=>({...u,transport:c})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsxs(O,{children:[e.jsx(v,{value:"stdio",children:"stdio"}),e.jsx(v,{value:"streamable-http",children:"streamable-http"})]})]}),o.transport==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(C,{value:o.command??"",onChange:c=>d(u=>({...u,command:c.target.value||null})),placeholder:"npx",disabled:t}),e.jsx(C,{value:le(o.args),onChange:c=>d(u=>({...u,args:oe(c.target.value)})),placeholder:"@playwright/mcp@latest, --flag",disabled:t})]}):e.jsx(C,{className:"sm:col-span-2",value:o.url??"",onChange:c=>d(u=>({...u,url:c.target.value||null})),placeholder:"https://example.test/mcp",disabled:t}),e.jsx(C,{type:"number",min:1,value:o.startupTimeoutSec??"",onChange:c=>d(u=>({...u,startupTimeoutSec:c.target.value?Number(c.target.value):null})),placeholder:"Startup timeout (sec)",disabled:t}),e.jsx(C,{type:"number",min:1,value:o.toolTimeoutSec??"",onChange:c=>d(u=>({...u,toolTimeoutSec:c.target.value?Number(c.target.value):null})),placeholder:"Tool timeout (sec)",disabled:t}),e.jsx(C,{value:le(o.enabledTools),onChange:c=>d(u=>({...u,enabledTools:oe(c.target.value)})),placeholder:"enabled_tools",disabled:t}),e.jsx(C,{value:le(o.disabledTools),onChange:c=>d(u=>({...u,disabledTools:oe(c.target.value)})),placeholder:"disabled_tools",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Enabled",e.jsx(B,{checked:o.enabled,onCheckedChange:c=>d(u=>({...u,enabled:c})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Required",e.jsx(B,{checked:o.required,onCheckedChange:c=>d(u=>({...u,required:c})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(w,{variant:"outline",onClick:i,disabled:t||a||!n,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(w,{onClick:()=>l(o.name,{transport:o.transport,command:o.command,args:o.args,url:o.url,enabled:o.enabled,required:o.required,startupTimeoutSec:o.startupTimeoutSec,toolTimeoutSec:o.toolTimeoutSec,enabledTools:o.enabledTools,disabledTools:o.disabledTools}),disabled:t||a||o.name.trim().length===0,children:[a?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save MCP server"]})]})]})}function ks({entries:s,disabled:r=!1,disabledReason:t,saving:a=!1,onSave:n,onDelete:l}){const[i,o]=b.useState("new"),d=b.useMemo(()=>s.find(h=>h.name===i)??null,[s,i]),c=d??ys,u=JSON.stringify(c);return e.jsxs(H,{title:"MCP servers",badge:"mcp_servers",icon:e.jsx(Je,{className:"h-4 w-4"}),description:"Manage the safe MCP transport fields. Keep auth headers and bearer tokens in raw TOML.",disabledReason:t,children:[e.jsxs(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select MCP server"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new MCP server"}),s.map(h=>e.jsx(v,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Ss,{initialDraft:c,isNew:i==="new",disabled:r,saving:a,canDelete:d!==null,onDelete:async()=>{d&&(await l(d.name),o("new"))},onSave:async(h,j)=>{await n(h,j),o(h)}},u)]})}const Ts={name:"",displayName:null,baseUrl:null,envKey:null,wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1},_s={name:"cliproxy",displayName:"CLIProxy Codex",baseUrl:"http://127.0.0.1:8317/api/provider/codex",envKey:"CLIPROXY_API_KEY",wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1};function Es({initialDraft:s,isNew:r,disabled:t,saving:a,canDelete:n,onSave:l,onDelete:i}){const[o,d]=b.useState(s);return e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground",children:[e.jsxs("p",{children:["Quick start: apply the CLIProxy Codex preset here, then set"," ",e.jsx("strong",{children:"Default provider"})," to ",e.jsx("code",{children:"cliproxy"})," in Top-level settings."]}),e.jsx(w,{variant:"outline",size:"sm",onClick:()=>d(_s),disabled:t,children:"Use CLIProxy Codex preset"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:o.name,onChange:c=>d(u=>({...u,name:c.target.value})),placeholder:"Provider id",disabled:t||!r}),e.jsx(C,{value:o.displayName??"",onChange:c=>d(u=>({...u,displayName:c.target.value||null})),placeholder:"Display name",disabled:t}),e.jsx(C,{value:o.baseUrl??"",onChange:c=>d(u=>({...u,baseUrl:c.target.value||null})),placeholder:"http://127.0.0.1:8317/api/provider/codex",disabled:t}),e.jsx(C,{value:o.envKey??"",onChange:c=>d(u=>({...u,envKey:c.target.value||null})),placeholder:"CLIPROXY_API_KEY",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs(_,{value:o.wireApi??"responses",onValueChange:c=>d(u=>({...u,wireApi:c})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsx(O,{children:e.jsx(v,{value:"responses",children:"responses"})})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Requires OpenAI auth",e.jsx(B,{checked:o.requiresOpenaiAuth,onCheckedChange:c=>d(u=>({...u,requiresOpenaiAuth:c})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Supports websockets",e.jsx(B,{checked:o.supportsWebsockets,onCheckedChange:c=>d(u=>({...u,supportsWebsockets:c})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(w,{variant:"outline",onClick:i,disabled:t||a||!n,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(w,{onClick:()=>l(o.name,{displayName:o.displayName,baseUrl:o.baseUrl,envKey:o.envKey,wireApi:o.wireApi,requiresOpenaiAuth:o.requiresOpenaiAuth,supportsWebsockets:o.supportsWebsockets}),disabled:t||a||o.name.trim().length===0,children:[a?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save provider"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["If you want plain native ",e.jsx("code",{children:"codex"})," to default to CLIProxy, save a provider named"," ",e.jsx("code",{children:"cliproxy"})," with ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," here, then pick"," ",e.jsx("code",{children:"cliproxy"})," in the ",e.jsx("strong",{children:"Default provider"})," control above."]})]})}function Ps({entries:s,disabled:r=!1,disabledReason:t,saving:a=!1,onSave:n,onDelete:l}){const[i,o]=b.useState("new"),d=b.useMemo(()=>s.find(h=>h.name===i)??null,[s,i]),c=d??Ts,u=JSON.stringify(c);return e.jsxs(H,{title:"Model providers",badge:"model_providers",icon:e.jsx(Ze,{className:"h-4 w-4"}),description:"Edit the common provider fields CCS can support safely. Keep secret migration and inline bearer tokens in raw TOML.",disabledReason:t,children:[e.jsxs(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select provider"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new provider"}),s.map(h=>e.jsx(v,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Es,{initialDraft:c,isNew:i==="new",disabled:r,saving:a,canDelete:d!==null,onDelete:async()=>{d&&(await l(d.name),o("new"))},onSave:async(h,j)=>{await n(h,j),o(h)}},u)]})}function Os({initialName:s,initialModel:r,initialProvider:t,initialEffort:a,providerNames:n,activeProfile:l,selectedEntryName:i,disabled:o,saving:d,onSave:c,onDelete:u,onSetActive:h}){const[j,x]=b.useState(s),[g,A]=b.useState(r),[U,m]=b.useState(t),[f,T]=b.useState(a);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:j,onChange:N=>x(N.target.value),placeholder:"deep-review",disabled:o||i!==null}),e.jsx(C,{value:g??"",onChange:N=>A(N.target.value||null),placeholder:"gpt-5.4",disabled:o}),e.jsxs(_,{value:U??"__unset__",onValueChange:N=>m(N==="__unset__"?null:N),disabled:o,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use global provider"})}),e.jsxs(O,{children:[e.jsx(v,{value:"__unset__",children:"Use global provider"}),n.map(N=>e.jsx(v,{value:N,children:N},N))]})]}),e.jsxs(_,{value:f??"__unset__",onValueChange:N=>T(N==="__unset__"?null:N),disabled:o,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use global effort"})}),e.jsxs(O,{children:[e.jsx(v,{value:"__unset__",children:"Use global effort"}),["minimal","low","medium","high","xhigh"].map(N=>e.jsx(v,{value:N,children:N},N))]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",onClick:u,disabled:o||d||!i,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsx(w,{variant:"outline",onClick:h,disabled:o||d||!i||i===l,children:"Set active"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",onClick:()=>c(j,{model:g,modelProvider:U,modelReasoningEffort:f},!1),disabled:o||d||j.trim().length===0,children:[d?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save profile"]}),e.jsxs(w,{onClick:()=>c(j,{model:g,modelProvider:U,modelReasoningEffort:f},!0),disabled:o||d||j.trim().length===0,children:[d?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save + activate"]})]})]})]})}function Ls({activeProfile:s,entries:r,providerNames:t,disabled:a=!1,disabledReason:n,saving:l=!1,onSave:i,onDelete:o,onSetActive:d}){const[c,u]=b.useState("new"),h=b.useMemo(()=>r.find(x=>x.name===c)??null,[r,c]),j=JSON.stringify(h??{name:"",values:{}});return e.jsxs(H,{title:"Profiles",badge:"profiles",icon:e.jsx(es,{className:"h-4 w-4"}),description:"Create reusable Codex overlays and set the active default profile.",disabledReason:n,children:[e.jsxs(_,{value:c,onValueChange:u,disabled:a,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select profile"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new profile"}),r.map(x=>e.jsxs(v,{value:x.name,children:[x.name,x.name===s?" (active)":""]},x.name))]})]}),e.jsx(Os,{initialName:h?.name??"",initialModel:h?.values.model??null,initialProvider:h?.values.modelProvider??null,initialEffort:h?.values.modelReasoningEffort??null,providerNames:t,activeProfile:s,selectedEntryName:h?.name??null,disabled:a,saving:l,onDelete:async()=>{h&&(await o(h.name),u("new"))},onSetActive:async()=>{h&&await d(h.name)},onSave:async(x,g,A)=>{await i(x,g,A),u(x)}},j)]})}function As({workspacePath:s,disabled:r,saving:t,onSave:a}){const[n,l]=b.useState(s),[i,o]=b.useState("trusted");return e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_160px_auto]",children:[e.jsx(C,{value:n,onChange:d=>l(d.target.value),placeholder:"~/repo or /absolute/path",disabled:r}),e.jsxs(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsxs(O,{children:[e.jsx(v,{value:"trusted",children:"trusted"}),e.jsx(v,{value:"untrusted",children:"untrusted"})]})]}),e.jsxs(w,{onClick:()=>a(n,i),disabled:r||t,children:[t?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save trust"]})]})}function Rs({workspacePath:s,entries:r,disabled:t=!1,disabledReason:a,saving:n=!1,onSave:l}){return e.jsxs(H,{title:"Project trust",badge:"projects",icon:e.jsx(ss,{className:"h-4 w-4"}),description:"Trust current workspaces or remove stale trust entries without opening raw TOML.",disabledReason:a,children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paths must be absolute or start with ",e.jsx("code",{children:"~/"}),". Relative paths are rejected so CCS does not trust the wrong folder."]}),e.jsx(As,{workspacePath:s,disabled:t,saving:n,onSave:l},s),e.jsx(w,{variant:"outline",className:"w-full justify-start",onClick:()=>l(s,"trusted"),disabled:t||n,children:"Trust current workspace"}),e.jsx("div",{className:"space-y-2",children:r.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No explicit project trust entries saved."}):r.map(i=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:i.path}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["trust_level = ",i.trustLevel]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>l(i.path,i.trustLevel==="trusted"?"untrusted":"trusted"),disabled:t||n,children:"Toggle"}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>l(i.path,null),disabled:t||n,children:e.jsx(Z,{className:"h-4 w-4"})})]})]},i.path))})]})}const L="__unset__",Ds=105e4,Ms=272e3,Ce=8e5,ye=7e5,Is=new Intl.NumberFormat("en-US");function X(s){return s??L}function G(s,r){return r&&!s.includes(r)?[r,...s]:s}function ie(s){return Is.format(s)}function Fs(s){return s?.trim().toLowerCase().startsWith("gpt-5.4")??!1}function Us(s,r){const t={};return r.model!==s.model&&(t.model=r.model),r.modelReasoningEffort!==s.modelReasoningEffort&&(t.modelReasoningEffort=r.modelReasoningEffort),r.modelContextWindow!==s.modelContextWindow&&(t.modelContextWindow=r.modelContextWindow),r.modelAutoCompactTokenLimit!==s.modelAutoCompactTokenLimit&&(t.modelAutoCompactTokenLimit=r.modelAutoCompactTokenLimit),r.modelProvider!==s.modelProvider&&(t.modelProvider=r.modelProvider),r.approvalPolicy!==s.approvalPolicy&&(t.approvalPolicy=r.approvalPolicy),r.sandboxMode!==s.sandboxMode&&(t.sandboxMode=r.sandboxMode),r.webSearch!==s.webSearch&&(t.webSearch=r.webSearch),r.toolOutputTokenLimit!==s.toolOutputTokenLimit&&(t.toolOutputTokenLimit=r.toolOutputTokenLimit),r.personality!==s.personality&&(t.personality=r.personality),t}function Ks({initialValues:s,providerNames:r,disabled:t,saving:a,onSave:n}){const[l,i]=b.useState(s),o=G(["minimal","low","medium","high","xhigh"],l.modelReasoningEffort),d=G(r,l.modelProvider),c=G(["on-request","never","untrusted"],l.approvalPolicy),u=G(["read-only","workspace-write","danger-full-access"],l.sandboxMode),h=G(["cached","live","disabled"],l.webSearch),j=G(["none","friendly","pragmatic"],l.personality),x=Us(s,l),g=Object.keys(x).length>0,A=Fs(l.model),U=m=>{const f=m.trim();return f.length>0?Number(f):null};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Model"}),e.jsx(C,{value:l.model??"",onChange:m=>i(f=>({...f,model:m.target.value||null})),placeholder:"gpt-5.4",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Reasoning effort"}),e.jsxs(_,{value:X(l.modelReasoningEffort),onValueChange:m=>i(f=>({...f,modelReasoningEffort:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),o.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Default provider"}),e.jsxs(_,{value:X(l.modelProvider),onValueChange:m=>i(f=>({...f,modelProvider:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use Codex default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use Codex default"}),d.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Approval policy"}),e.jsxs(_,{value:X(l.approvalPolicy),onValueChange:m=>i(f=>({...f,approvalPolicy:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),c.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Sandbox mode"}),e.jsxs(_,{value:X(l.sandboxMode),onValueChange:m=>i(f=>({...f,sandboxMode:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),u.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Web search"}),e.jsxs(_,{value:X(l.webSearch),onValueChange:m=>i(f=>({...f,webSearch:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),h.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Tool output token limit"}),e.jsx(C,{type:"number",min:1,value:l.toolOutputTokenLimit??"",onChange:m=>i(f=>({...f,toolOutputTokenLimit:m.target.value?Number(m.target.value):null})),placeholder:"25000",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Personality"}),e.jsxs(_,{value:X(l.personality),onValueChange:m=>i(f=>({...f,personality:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),j.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]})]}),e.jsxs("div",{className:"space-y-4 rounded-xl border border-amber-500/30 bg-amber-500/5 p-4 shadow-sm dark:bg-amber-400/5",children:[e.jsxs("div",{className:"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(ts,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}),e.jsx("p",{className:"text-sm font-semibold",children:"Long context override"}),e.jsx(y,{variant:"outline",className:"border-amber-500/40 bg-background/80 text-[10px] uppercase tracking-[0.16em] text-amber-700 dark:text-amber-300",children:"Manual opt-in only"}),e.jsx(y,{variant:"secondary",className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:A?"GPT-5.4 selected":"GPT-5.4 reference"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Draft values only. Nothing applies until Save."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(w,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:Ce,modelAutoCompactTokenLimit:ye})),children:"Fill cautious pair"}),e.jsx(w,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:Ds})),children:"Set official max window"}),e.jsx(w,{type:"button",variant:"ghost",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:null,modelAutoCompactTokenLimit:null})),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Official max"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"1.05M / 1M"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"GPT-5.4 context cap"})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Standard window"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:ie(Ms)}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Normal usage window"})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Above 272K"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"Counts 2x"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Usage-limit cost above 272K"})]})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border bg-background/75 px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"One cautious pair"}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Context ",ie(Ce)]}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Auto-compact ",ie(ye)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(y,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Not official"}),e.jsx(y,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Draft only"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:"Quick-fill only. Review before saving."}),!A&&l.model?e.jsxs("span",{children:[e.jsx("code",{children:l.model})," should be checked separately."]}):null]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Model context window"}),e.jsx(C,{"aria-label":"Model context window",type:"number",min:1,value:l.modelContextWindow??"",onChange:m=>i(f=>({...f,modelContextWindow:U(m.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_context_window"}),". Leave unset to keep Codex defaults."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Auto-compact token limit"}),e.jsx(C,{"aria-label":"Auto-compact token limit",type:"number",min:1,value:l.modelAutoCompactTokenLimit??"",onChange:m=>i(f=>({...f,modelAutoCompactTokenLimit:U(m.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_auto_compact_token_limit"}),". Leave unset to keep model defaults."]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em]",children:"Docs"}),e.jsx("a",{href:"https://developers.openai.com/api/docs/models/gpt-5.4",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"GPT-5.4 model page"}),e.jsx("a",{href:"https://openai.com/index/introducing-gpt-5-4/",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Release notes"}),e.jsx("a",{href:"https://developers.openai.com/codex/config-reference",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Config reference"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{onClick:()=>n(x),disabled:t||a||!g,children:[a?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save top-level settings"]})})]})}function Ws({values:s,providerNames:r,disabled:t=!1,disabledReason:a,saving:n=!1,onSave:l}){return e.jsx(H,{title:"Top-level controls",badge:"config.toml",icon:e.jsx(rs,{className:"h-4 w-4"}),description:"Structured controls for the stable top-level Codex settings users touch most often. Unsupported upstream shapes stay untouched and should be edited in raw TOML.",disabledReason:a,children:e.jsx(Ks,{initialValues:s,providerNames:r,disabled:t,saving:n,onSave:l},JSON.stringify(s))})}function qs({workspacePath:s,activeProfile:r,topLevelSettings:t,projectTrustEntries:a,profileEntries:n,modelProviderEntries:l,mcpServerEntries:i,featureCatalog:o,featureState:d,disabled:c,disabledReason:u,saving:h,onPatch:j}){return e.jsx(xe,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 pr-1 pb-6",children:[e.jsxs("div",{className:"group relative overflow-hidden rounded-xl border border-border/80 bg-background/50 p-5 shadow-sm transition-all hover:bg-background hover:shadow-md dark:border-border/60",children:[e.jsx("div",{className:"absolute inset-x-0 -top-px h-px bg-gradient-to-r from-transparent via-foreground/15 to-transparent transition-opacity group-hover:via-foreground/30"}),e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary transition-colors group-hover:border-primary/30",children:e.jsx(ns,{className:"h-4 w-4"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-base font-semibold tracking-tight text-foreground",children:"Structured controls boundary"})})]}),e.jsxs("ul",{className:"grid gap-3 sm:grid-cols-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(as,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsxs("span",{className:"leading-relaxed",children:["Writes exclusively to user-layer"," ",e.jsx("code",{className:"text-[11px] bg-muted/70 px-1.5 py-0.5 rounded border border-border/50",children:"config.toml"})]})]}),e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(ls,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsx("span",{className:"leading-relaxed",children:"Does not reflect repo trust layers or CLI overrides"})]})]})]}),e.jsx("div",{className:"shrink-0 lg:w-[280px]",children:e.jsx("div",{className:"relative overflow-hidden rounded-lg border border-amber-500/20 bg-amber-500/5 p-4 transition-colors group-hover:border-amber-500/30 group-hover:bg-amber-500/10 dark:border-amber-400/10 dark:bg-amber-400/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(os,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold text-amber-700 dark:text-amber-300 uppercase tracking-wider",children:"Formatting Note"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-amber-800/80 dark:text-amber-200/70",children:"Saves normalize TOML formatting and strip comments. Switch to the raw editor if exact layout matters."})]})]})})})]})]}),e.jsx(Ws,{values:t,providerNames:l.map(x=>x.name),disabled:c,disabledReason:u,saving:h,onSave:x=>j({kind:"top-level",values:x},"Saved top-level Codex settings.")}),e.jsx(Rs,{workspacePath:s,entries:a,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"project-trust",path:x,trustLevel:g},g?"Saved project trust entry.":"Removed project trust entry.")}),e.jsx(Ls,{activeProfile:r,entries:n,providerNames:l.map(x=>x.name),disabled:c,disabledReason:u,saving:h,onSave:(x,g,A)=>j({kind:"profile",action:"upsert",name:x,values:g,setAsActive:A},"Saved profile."),onDelete:x=>j({kind:"profile",action:"delete",name:x},"Deleted profile."),onSetActive:x=>j({kind:"profile",action:"set-active",name:x},"Set active profile.")}),e.jsx(Ps,{entries:l,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"model-provider",action:"upsert",name:x,values:g},"Saved model provider."),onDelete:x=>j({kind:"model-provider",action:"delete",name:x},"Deleted model provider.")}),e.jsx(ks,{entries:i,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"mcp-server",action:"upsert",name:x,values:g},"Saved MCP server."),onDelete:x=>j({kind:"mcp-server",action:"delete",name:x},"Deleted MCP server.")}),e.jsx(Cs,{catalog:o,state:d,disabled:c,disabledReason:u,onToggle:(x,g)=>j({kind:"feature",feature:x,enabled:g},"Saved feature toggle.")})]})})}const Ee=`model_provider = "cliproxy"
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as b}from"./react-vendor-CNOkPC89.js";import{t as K}from"./notifications-B2HqRBj7.js";import{C as D,j as M,k as I,B as y,b as F,d as w,aE as B,r as _,s as E,t as P,v as O,w as v,I as C,n as xe,b6 as J,b7 as Te,c as _e,bd as $e,be as fe,bf as Ye,Q as Be,R as He,U as re,V as te,b8 as je}from"./index-B-YlctHj.js";import{a9 as Qe,aO as Je,ar as Z,L as z,n as Ze,aP as es,aQ as ss,aw as rs,w as ts,a6 as ns,aR as as,aS as ls,aT as os,ag as de,p as ge,_ as is,m as cs,o as ds,Y as us,S as ms,aJ as ve,aU as xs,x as hs,I as ps,T as fs,N as js}from"./icons-C4EMu2PL.js";import{S as Q}from"./separator-Cia83j78.js";import{a as gs,u as be,b as we}from"./tanstack-CrmUhA7Z.js";import"./code-highlight-BRUf_pqB.js";import{T as vs,a as bs,b as Ne,c as ne,d as ws,e as ae}from"./table-DVwKEwq6.js";import{R as Ns}from"./raw-json-settings-editor-panel-T7HrEBqp.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";function H({title:s,icon:r,badge:t,description:a,disabledReason:n,children:l}){return e.jsxs(D,{children:[e.jsxs(M,{className:"pb-2",children:[e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[r,s,t?e.jsx(y,{variant:"outline",className:"text-[10px] font-normal",children:t}):null]}),a?e.jsx("p",{className:"text-xs text-muted-foreground",children:a}):null]}),e.jsxs(F,{className:"space-y-3",children:[n?e.jsx("p",{className:"text-xs text-amber-600",children:n}):null,l]})]})}function Cs({catalog:s,state:r,disabled:t=!1,disabledReason:a,onToggle:n}){const l=new Set(s.map(o=>o.name)),i=Object.entries(r).filter(([o])=>!l.has(o)).sort(([o],[d])=>o.localeCompare(d));return e.jsxs(H,{title:"Features",badge:"features",icon:e.jsx(Qe,{className:"h-4 w-4"}),description:"Toggle the supported Codex feature flags CCS can safely manage.",disabledReason:a,children:[e.jsx("div",{className:"space-y-2",children:s.map(o=>{const d=r[o.name]??null;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:o.label}),e.jsx(y,{variant:"outline",className:"font-mono text-[10px]",children:o.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d!==null?e.jsx(w,{variant:"outline",size:"sm",onClick:()=>n(o.name,null),disabled:t,children:"Use default"}):null,e.jsx(B,{checked:d===!0,onCheckedChange:c=>n(o.name,c),disabled:t})]})]},o.name)})}),i.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Existing config-only flags"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These feature keys already exist in your `config.toml`, so CCS can surface them without claiming full catalog coverage."})]}),i.map(([o,d])=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-dashed px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:o}),e.jsx(y,{variant:"secondary",className:"text-[10px]",children:"existing"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d===null?"Stored in a non-boolean form. Use raw TOML if you need to edit it.":"Discovered from the current file instead of CCS's built-in catalog."})]}),d===null?e.jsx(y,{variant:"outline",children:"Raw only"}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"sm",onClick:()=>n(o,null),disabled:t,children:"Use default"}),e.jsx(B,{checked:d===!0,onCheckedChange:c=>n(o,c),disabled:t})]})]},o))]}):null]})}const ys={name:"",transport:"stdio",command:null,args:[],url:null,enabled:!0,required:!1,startupTimeoutSec:null,toolTimeoutSec:null,enabledTools:[],disabledTools:[]};function le(s){return s.join(", ")}function oe(s){return s.split(",").map(r=>r.trim()).filter(Boolean)}function Ss({initialDraft:s,isNew:r,disabled:t,saving:a,canDelete:n,onSave:l,onDelete:i}){const[o,d]=b.useState(s);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:o.name,onChange:c=>d(u=>({...u,name:c.target.value})),placeholder:"playwright",disabled:t||!r}),e.jsxs(_,{value:o.transport,onValueChange:c=>d(u=>({...u,transport:c})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsxs(O,{children:[e.jsx(v,{value:"stdio",children:"stdio"}),e.jsx(v,{value:"streamable-http",children:"streamable-http"})]})]}),o.transport==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(C,{value:o.command??"",onChange:c=>d(u=>({...u,command:c.target.value||null})),placeholder:"npx",disabled:t}),e.jsx(C,{value:le(o.args),onChange:c=>d(u=>({...u,args:oe(c.target.value)})),placeholder:"@playwright/mcp@latest, --flag",disabled:t})]}):e.jsx(C,{className:"sm:col-span-2",value:o.url??"",onChange:c=>d(u=>({...u,url:c.target.value||null})),placeholder:"https://example.test/mcp",disabled:t}),e.jsx(C,{type:"number",min:1,value:o.startupTimeoutSec??"",onChange:c=>d(u=>({...u,startupTimeoutSec:c.target.value?Number(c.target.value):null})),placeholder:"Startup timeout (sec)",disabled:t}),e.jsx(C,{type:"number",min:1,value:o.toolTimeoutSec??"",onChange:c=>d(u=>({...u,toolTimeoutSec:c.target.value?Number(c.target.value):null})),placeholder:"Tool timeout (sec)",disabled:t}),e.jsx(C,{value:le(o.enabledTools),onChange:c=>d(u=>({...u,enabledTools:oe(c.target.value)})),placeholder:"enabled_tools",disabled:t}),e.jsx(C,{value:le(o.disabledTools),onChange:c=>d(u=>({...u,disabledTools:oe(c.target.value)})),placeholder:"disabled_tools",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Enabled",e.jsx(B,{checked:o.enabled,onCheckedChange:c=>d(u=>({...u,enabled:c})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Required",e.jsx(B,{checked:o.required,onCheckedChange:c=>d(u=>({...u,required:c})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(w,{variant:"outline",onClick:i,disabled:t||a||!n,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(w,{onClick:()=>l(o.name,{transport:o.transport,command:o.command,args:o.args,url:o.url,enabled:o.enabled,required:o.required,startupTimeoutSec:o.startupTimeoutSec,toolTimeoutSec:o.toolTimeoutSec,enabledTools:o.enabledTools,disabledTools:o.disabledTools}),disabled:t||a||o.name.trim().length===0,children:[a?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save MCP server"]})]})]})}function ks({entries:s,disabled:r=!1,disabledReason:t,saving:a=!1,onSave:n,onDelete:l}){const[i,o]=b.useState("new"),d=b.useMemo(()=>s.find(h=>h.name===i)??null,[s,i]),c=d??ys,u=JSON.stringify(c);return e.jsxs(H,{title:"MCP servers",badge:"mcp_servers",icon:e.jsx(Je,{className:"h-4 w-4"}),description:"Manage the safe MCP transport fields. Keep auth headers and bearer tokens in raw TOML.",disabledReason:t,children:[e.jsxs(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select MCP server"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new MCP server"}),s.map(h=>e.jsx(v,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Ss,{initialDraft:c,isNew:i==="new",disabled:r,saving:a,canDelete:d!==null,onDelete:async()=>{d&&(await l(d.name),o("new"))},onSave:async(h,j)=>{await n(h,j),o(h)}},u)]})}const Ts={name:"",displayName:null,baseUrl:null,envKey:null,wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1},_s={name:"cliproxy",displayName:"CLIProxy Codex",baseUrl:"http://127.0.0.1:8317/api/provider/codex",envKey:"CLIPROXY_API_KEY",wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1};function Es({initialDraft:s,isNew:r,disabled:t,saving:a,canDelete:n,onSave:l,onDelete:i}){const[o,d]=b.useState(s);return e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground",children:[e.jsxs("p",{children:["Quick start: apply the CLIProxy Codex preset here, then set"," ",e.jsx("strong",{children:"Default provider"})," to ",e.jsx("code",{children:"cliproxy"})," in Top-level settings."]}),e.jsx(w,{variant:"outline",size:"sm",onClick:()=>d(_s),disabled:t,children:"Use CLIProxy Codex preset"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:o.name,onChange:c=>d(u=>({...u,name:c.target.value})),placeholder:"Provider id",disabled:t||!r}),e.jsx(C,{value:o.displayName??"",onChange:c=>d(u=>({...u,displayName:c.target.value||null})),placeholder:"Display name",disabled:t}),e.jsx(C,{value:o.baseUrl??"",onChange:c=>d(u=>({...u,baseUrl:c.target.value||null})),placeholder:"http://127.0.0.1:8317/api/provider/codex",disabled:t}),e.jsx(C,{value:o.envKey??"",onChange:c=>d(u=>({...u,envKey:c.target.value||null})),placeholder:"CLIPROXY_API_KEY",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs(_,{value:o.wireApi??"responses",onValueChange:c=>d(u=>({...u,wireApi:c})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsx(O,{children:e.jsx(v,{value:"responses",children:"responses"})})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Requires OpenAI auth",e.jsx(B,{checked:o.requiresOpenaiAuth,onCheckedChange:c=>d(u=>({...u,requiresOpenaiAuth:c})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Supports websockets",e.jsx(B,{checked:o.supportsWebsockets,onCheckedChange:c=>d(u=>({...u,supportsWebsockets:c})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(w,{variant:"outline",onClick:i,disabled:t||a||!n,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(w,{onClick:()=>l(o.name,{displayName:o.displayName,baseUrl:o.baseUrl,envKey:o.envKey,wireApi:o.wireApi,requiresOpenaiAuth:o.requiresOpenaiAuth,supportsWebsockets:o.supportsWebsockets}),disabled:t||a||o.name.trim().length===0,children:[a?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save provider"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["If you want plain native ",e.jsx("code",{children:"codex"})," to default to CLIProxy, save a provider named"," ",e.jsx("code",{children:"cliproxy"})," with ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," here, then pick"," ",e.jsx("code",{children:"cliproxy"})," in the ",e.jsx("strong",{children:"Default provider"})," control above."]})]})}function Ps({entries:s,disabled:r=!1,disabledReason:t,saving:a=!1,onSave:n,onDelete:l}){const[i,o]=b.useState("new"),d=b.useMemo(()=>s.find(h=>h.name===i)??null,[s,i]),c=d??Ts,u=JSON.stringify(c);return e.jsxs(H,{title:"Model providers",badge:"model_providers",icon:e.jsx(Ze,{className:"h-4 w-4"}),description:"Edit the common provider fields CCS can support safely. Keep secret migration and inline bearer tokens in raw TOML.",disabledReason:t,children:[e.jsxs(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select provider"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new provider"}),s.map(h=>e.jsx(v,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Es,{initialDraft:c,isNew:i==="new",disabled:r,saving:a,canDelete:d!==null,onDelete:async()=>{d&&(await l(d.name),o("new"))},onSave:async(h,j)=>{await n(h,j),o(h)}},u)]})}function Os({initialName:s,initialModel:r,initialProvider:t,initialEffort:a,providerNames:n,activeProfile:l,selectedEntryName:i,disabled:o,saving:d,onSave:c,onDelete:u,onSetActive:h}){const[j,x]=b.useState(s),[g,A]=b.useState(r),[U,m]=b.useState(t),[f,T]=b.useState(a);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:j,onChange:N=>x(N.target.value),placeholder:"deep-review",disabled:o||i!==null}),e.jsx(C,{value:g??"",onChange:N=>A(N.target.value||null),placeholder:"gpt-5.4",disabled:o}),e.jsxs(_,{value:U??"__unset__",onValueChange:N=>m(N==="__unset__"?null:N),disabled:o,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use global provider"})}),e.jsxs(O,{children:[e.jsx(v,{value:"__unset__",children:"Use global provider"}),n.map(N=>e.jsx(v,{value:N,children:N},N))]})]}),e.jsxs(_,{value:f??"__unset__",onValueChange:N=>T(N==="__unset__"?null:N),disabled:o,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use global effort"})}),e.jsxs(O,{children:[e.jsx(v,{value:"__unset__",children:"Use global effort"}),["minimal","low","medium","high","xhigh"].map(N=>e.jsx(v,{value:N,children:N},N))]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",onClick:u,disabled:o||d||!i,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsx(w,{variant:"outline",onClick:h,disabled:o||d||!i||i===l,children:"Set active"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",onClick:()=>c(j,{model:g,modelProvider:U,modelReasoningEffort:f},!1),disabled:o||d||j.trim().length===0,children:[d?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save profile"]}),e.jsxs(w,{onClick:()=>c(j,{model:g,modelProvider:U,modelReasoningEffort:f},!0),disabled:o||d||j.trim().length===0,children:[d?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save + activate"]})]})]})]})}function Ls({activeProfile:s,entries:r,providerNames:t,disabled:a=!1,disabledReason:n,saving:l=!1,onSave:i,onDelete:o,onSetActive:d}){const[c,u]=b.useState("new"),h=b.useMemo(()=>r.find(x=>x.name===c)??null,[r,c]),j=JSON.stringify(h??{name:"",values:{}});return e.jsxs(H,{title:"Profiles",badge:"profiles",icon:e.jsx(es,{className:"h-4 w-4"}),description:"Create reusable Codex overlays and set the active default profile.",disabledReason:n,children:[e.jsxs(_,{value:c,onValueChange:u,disabled:a,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select profile"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new profile"}),r.map(x=>e.jsxs(v,{value:x.name,children:[x.name,x.name===s?" (active)":""]},x.name))]})]}),e.jsx(Os,{initialName:h?.name??"",initialModel:h?.values.model??null,initialProvider:h?.values.modelProvider??null,initialEffort:h?.values.modelReasoningEffort??null,providerNames:t,activeProfile:s,selectedEntryName:h?.name??null,disabled:a,saving:l,onDelete:async()=>{h&&(await o(h.name),u("new"))},onSetActive:async()=>{h&&await d(h.name)},onSave:async(x,g,A)=>{await i(x,g,A),u(x)}},j)]})}function As({workspacePath:s,disabled:r,saving:t,onSave:a}){const[n,l]=b.useState(s),[i,o]=b.useState("trusted");return e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_160px_auto]",children:[e.jsx(C,{value:n,onChange:d=>l(d.target.value),placeholder:"~/repo or /absolute/path",disabled:r}),e.jsxs(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsxs(O,{children:[e.jsx(v,{value:"trusted",children:"trusted"}),e.jsx(v,{value:"untrusted",children:"untrusted"})]})]}),e.jsxs(w,{onClick:()=>a(n,i),disabled:r||t,children:[t?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save trust"]})]})}function Rs({workspacePath:s,entries:r,disabled:t=!1,disabledReason:a,saving:n=!1,onSave:l}){return e.jsxs(H,{title:"Project trust",badge:"projects",icon:e.jsx(ss,{className:"h-4 w-4"}),description:"Trust current workspaces or remove stale trust entries without opening raw TOML.",disabledReason:a,children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paths must be absolute or start with ",e.jsx("code",{children:"~/"}),". Relative paths are rejected so CCS does not trust the wrong folder."]}),e.jsx(As,{workspacePath:s,disabled:t,saving:n,onSave:l},s),e.jsx(w,{variant:"outline",className:"w-full justify-start",onClick:()=>l(s,"trusted"),disabled:t||n,children:"Trust current workspace"}),e.jsx("div",{className:"space-y-2",children:r.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No explicit project trust entries saved."}):r.map(i=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:i.path}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["trust_level = ",i.trustLevel]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>l(i.path,i.trustLevel==="trusted"?"untrusted":"trusted"),disabled:t||n,children:"Toggle"}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>l(i.path,null),disabled:t||n,children:e.jsx(Z,{className:"h-4 w-4"})})]})]},i.path))})]})}const L="__unset__",Ds=105e4,Ms=272e3,Ce=8e5,ye=7e5,Is=new Intl.NumberFormat("en-US");function X(s){return s??L}function G(s,r){return r&&!s.includes(r)?[r,...s]:s}function ie(s){return Is.format(s)}function Fs(s){return s?.trim().toLowerCase().startsWith("gpt-5.4")??!1}function Us(s,r){const t={};return r.model!==s.model&&(t.model=r.model),r.modelReasoningEffort!==s.modelReasoningEffort&&(t.modelReasoningEffort=r.modelReasoningEffort),r.modelContextWindow!==s.modelContextWindow&&(t.modelContextWindow=r.modelContextWindow),r.modelAutoCompactTokenLimit!==s.modelAutoCompactTokenLimit&&(t.modelAutoCompactTokenLimit=r.modelAutoCompactTokenLimit),r.modelProvider!==s.modelProvider&&(t.modelProvider=r.modelProvider),r.approvalPolicy!==s.approvalPolicy&&(t.approvalPolicy=r.approvalPolicy),r.sandboxMode!==s.sandboxMode&&(t.sandboxMode=r.sandboxMode),r.webSearch!==s.webSearch&&(t.webSearch=r.webSearch),r.toolOutputTokenLimit!==s.toolOutputTokenLimit&&(t.toolOutputTokenLimit=r.toolOutputTokenLimit),r.personality!==s.personality&&(t.personality=r.personality),t}function Ks({initialValues:s,providerNames:r,disabled:t,saving:a,onSave:n}){const[l,i]=b.useState(s),o=G(["minimal","low","medium","high","xhigh"],l.modelReasoningEffort),d=G(r,l.modelProvider),c=G(["on-request","never","untrusted"],l.approvalPolicy),u=G(["read-only","workspace-write","danger-full-access"],l.sandboxMode),h=G(["cached","live","disabled"],l.webSearch),j=G(["none","friendly","pragmatic"],l.personality),x=Us(s,l),g=Object.keys(x).length>0,A=Fs(l.model),U=m=>{const f=m.trim();return f.length>0?Number(f):null};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Model"}),e.jsx(C,{value:l.model??"",onChange:m=>i(f=>({...f,model:m.target.value||null})),placeholder:"gpt-5.4",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Reasoning effort"}),e.jsxs(_,{value:X(l.modelReasoningEffort),onValueChange:m=>i(f=>({...f,modelReasoningEffort:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),o.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Default provider"}),e.jsxs(_,{value:X(l.modelProvider),onValueChange:m=>i(f=>({...f,modelProvider:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use Codex default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use Codex default"}),d.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Approval policy"}),e.jsxs(_,{value:X(l.approvalPolicy),onValueChange:m=>i(f=>({...f,approvalPolicy:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),c.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Sandbox mode"}),e.jsxs(_,{value:X(l.sandboxMode),onValueChange:m=>i(f=>({...f,sandboxMode:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),u.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Web search"}),e.jsxs(_,{value:X(l.webSearch),onValueChange:m=>i(f=>({...f,webSearch:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),h.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Tool output token limit"}),e.jsx(C,{type:"number",min:1,value:l.toolOutputTokenLimit??"",onChange:m=>i(f=>({...f,toolOutputTokenLimit:m.target.value?Number(m.target.value):null})),placeholder:"25000",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Personality"}),e.jsxs(_,{value:X(l.personality),onValueChange:m=>i(f=>({...f,personality:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),j.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]})]}),e.jsxs("div",{className:"space-y-4 rounded-xl border border-amber-500/30 bg-amber-500/5 p-4 shadow-sm dark:bg-amber-400/5",children:[e.jsxs("div",{className:"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(ts,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}),e.jsx("p",{className:"text-sm font-semibold",children:"Long context override"}),e.jsx(y,{variant:"outline",className:"border-amber-500/40 bg-background/80 text-[10px] uppercase tracking-[0.16em] text-amber-700 dark:text-amber-300",children:"Manual opt-in only"}),e.jsx(y,{variant:"secondary",className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:A?"GPT-5.4 selected":"GPT-5.4 reference"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Draft values only. Nothing applies until Save."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(w,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:Ce,modelAutoCompactTokenLimit:ye})),children:"Fill cautious pair"}),e.jsx(w,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:Ds})),children:"Set official max window"}),e.jsx(w,{type:"button",variant:"ghost",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:null,modelAutoCompactTokenLimit:null})),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Official max"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"1.05M / 1M"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"GPT-5.4 context cap"})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Standard window"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:ie(Ms)}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Normal usage window"})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Above 272K"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"Counts 2x"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Usage-limit cost above 272K"})]})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border bg-background/75 px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"One cautious pair"}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Context ",ie(Ce)]}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Auto-compact ",ie(ye)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(y,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Not official"}),e.jsx(y,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Draft only"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:"Quick-fill only. Review before saving."}),!A&&l.model?e.jsxs("span",{children:[e.jsx("code",{children:l.model})," should be checked separately."]}):null]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Model context window"}),e.jsx(C,{"aria-label":"Model context window",type:"number",min:1,value:l.modelContextWindow??"",onChange:m=>i(f=>({...f,modelContextWindow:U(m.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_context_window"}),". Leave unset to keep Codex defaults."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Auto-compact token limit"}),e.jsx(C,{"aria-label":"Auto-compact token limit",type:"number",min:1,value:l.modelAutoCompactTokenLimit??"",onChange:m=>i(f=>({...f,modelAutoCompactTokenLimit:U(m.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_auto_compact_token_limit"}),". Leave unset to keep model defaults."]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em]",children:"Docs"}),e.jsx("a",{href:"https://developers.openai.com/api/docs/models/gpt-5.4",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"GPT-5.4 model page"}),e.jsx("a",{href:"https://openai.com/index/introducing-gpt-5-4/",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Release notes"}),e.jsx("a",{href:"https://developers.openai.com/codex/config-reference",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Config reference"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{onClick:()=>n(x),disabled:t||a||!g,children:[a?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save top-level settings"]})})]})}function Ws({values:s,providerNames:r,disabled:t=!1,disabledReason:a,saving:n=!1,onSave:l}){return e.jsx(H,{title:"Top-level controls",badge:"config.toml",icon:e.jsx(rs,{className:"h-4 w-4"}),description:"Structured controls for the stable top-level Codex settings users touch most often. Unsupported upstream shapes stay untouched and should be edited in raw TOML.",disabledReason:a,children:e.jsx(Ks,{initialValues:s,providerNames:r,disabled:t,saving:n,onSave:l},JSON.stringify(s))})}function qs({workspacePath:s,activeProfile:r,topLevelSettings:t,projectTrustEntries:a,profileEntries:n,modelProviderEntries:l,mcpServerEntries:i,featureCatalog:o,featureState:d,disabled:c,disabledReason:u,saving:h,onPatch:j}){return e.jsx(xe,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 pr-1 pb-6",children:[e.jsxs("div",{className:"group relative overflow-hidden rounded-xl border border-border/80 bg-background/50 p-5 shadow-sm transition-all hover:bg-background hover:shadow-md dark:border-border/60",children:[e.jsx("div",{className:"absolute inset-x-0 -top-px h-px bg-gradient-to-r from-transparent via-foreground/15 to-transparent transition-opacity group-hover:via-foreground/30"}),e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary transition-colors group-hover:border-primary/30",children:e.jsx(ns,{className:"h-4 w-4"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-base font-semibold tracking-tight text-foreground",children:"Structured controls boundary"})})]}),e.jsxs("ul",{className:"grid gap-3 sm:grid-cols-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(as,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsxs("span",{className:"leading-relaxed",children:["Writes exclusively to user-layer"," ",e.jsx("code",{className:"text-[11px] bg-muted/70 px-1.5 py-0.5 rounded border border-border/50",children:"config.toml"})]})]}),e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(ls,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsx("span",{className:"leading-relaxed",children:"Does not reflect repo trust layers or CLI overrides"})]})]})]}),e.jsx("div",{className:"shrink-0 lg:w-[280px]",children:e.jsx("div",{className:"relative overflow-hidden rounded-lg border border-amber-500/20 bg-amber-500/5 p-4 transition-colors group-hover:border-amber-500/30 group-hover:bg-amber-500/10 dark:border-amber-400/10 dark:bg-amber-400/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(os,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold text-amber-700 dark:text-amber-300 uppercase tracking-wider",children:"Formatting Note"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-amber-800/80 dark:text-amber-200/70",children:"Saves normalize TOML formatting and strip comments. Switch to the raw editor if exact layout matters."})]})]})})})]})]}),e.jsx(Ws,{values:t,providerNames:l.map(x=>x.name),disabled:c,disabledReason:u,saving:h,onSave:x=>j({kind:"top-level",values:x},"Saved top-level Codex settings.")}),e.jsx(Rs,{workspacePath:s,entries:a,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"project-trust",path:x,trustLevel:g},g?"Saved project trust entry.":"Removed project trust entry.")}),e.jsx(Ls,{activeProfile:r,entries:n,providerNames:l.map(x=>x.name),disabled:c,disabledReason:u,saving:h,onSave:(x,g,A)=>j({kind:"profile",action:"upsert",name:x,values:g,setAsActive:A},"Saved profile."),onDelete:x=>j({kind:"profile",action:"delete",name:x},"Deleted profile."),onSetActive:x=>j({kind:"profile",action:"set-active",name:x},"Set active profile.")}),e.jsx(Ps,{entries:l,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"model-provider",action:"upsert",name:x,values:g},"Saved model provider."),onDelete:x=>j({kind:"model-provider",action:"delete",name:x},"Deleted model provider.")}),e.jsx(ks,{entries:i,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"mcp-server",action:"upsert",name:x,values:g},"Saved MCP server."),onDelete:x=>j({kind:"mcp-server",action:"delete",name:x},"Deleted MCP server.")}),e.jsx(Cs,{catalog:o,state:d,disabled:c,disabledReason:u,onToggle:(x,g)=>j({kind:"feature",feature:x,enabled:g},"Saved feature toggle.")})]})})}const Ee=`model_provider = "cliproxy"
2
2
 
3
3
  [model_providers.cliproxy]
4
4
  base_url = "http://127.0.0.1:8317/api/provider/codex"
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.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-D_Yz_iZc.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
+ import{j as e}from"./radix-ui-Zb8sVEtn.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-CIVd-ody.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};