@nextclaw/ui 0.6.5 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/assets/{ChannelsList-DiX7ssoj.js → ChannelsList-VqzbAMCc.js} +1 -1
- package/dist/assets/{ChatPage-CEEbtfae.js → ChatPage-CjZqsBmn.js} +1 -1
- package/dist/assets/{DocBrowser-CkDugJv3.js → DocBrowser-DvU-iUeB.js} +1 -1
- package/dist/assets/{MarketplacePage-Cxt223yL.js → MarketplacePage--wFfsNH0.js} +1 -1
- package/dist/assets/{ModelConfig-BRRJU2mk.js → ModelConfig-cY5UsbfA.js} +1 -1
- package/dist/assets/{ProvidersList-Bl-OMAwu.js → ProvidersList-qZwaFoFt.js} +1 -1
- package/dist/assets/{RuntimeConfig-C0wurlgT.js → RuntimeConfig-BY2Axlte.js} +1 -1
- package/dist/assets/{SecretsConfig-C_3yJm1I.js → SecretsConfig-B25P3J7V.js} +1 -1
- package/dist/assets/{SessionsConfig-D13xFf5J.js → SessionsConfig-CxA9gIBw.js} +1 -1
- package/dist/assets/{card-sDEXo_R4.js → card-CCSDsedj.js} +1 -1
- package/dist/assets/{index-DP9xXu9V.js → index-CD8a2KMH.js} +2 -2
- package/dist/assets/{index-6azf0otP.css → index-DKOXGZc8.css} +1 -1
- package/dist/assets/{label-DhIqXnKx.js → label-BxzAKPzU.js} +1 -1
- package/dist/assets/{logos-B9Qiy9wo.js → logos-C3oHQ9kv.js} +1 -1
- package/dist/assets/{page-layout-CC6kzYFp.js → page-layout-DaLNSFKw.js} +1 -1
- package/dist/assets/{switch-DFPJEEVz.js → switch-DHOCEi5L.js} +1 -1
- package/dist/assets/{tabs-custom-C_1pBckQ.js → tabs-custom-zdFy3fnK.js} +1 -1
- package/dist/assets/{useConfig-q7QqH3JB.js → useConfig-CDl9UK5m.js} +1 -1
- package/dist/assets/{useConfirmDialog-BNkeOTcY.js → useConfirmDialog-D3ZVa92J.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/index.css +39 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r as i,O as q,g as U,m as G,v as K,U as Y,W as $}from"./vendor-Dj2ULvht.js";import{P as J,a as Q,B as X}from"./page-layout-
|
|
1
|
+
import{j as e,r as i,O as q,g as U,m as G,v as K,U as Y,W as $}from"./vendor-Dj2ULvht.js";import{P as J,a as Q,B as X}from"./page-layout-DaLNSFKw.js";import{C as z}from"./card-CCSDsedj.js";import{I as _,u as Z,a as H,b as ee,c as se}from"./useConfig-CDl9UK5m.js";import{L as R}from"./label-BxzAKPzU.js";import{c as L,t as c,S as te,a as ae,b as le,d as re,e as ne,D as oe}from"./index-CD8a2KMH.js";import{h as W}from"./config-hints-CApS3K_7.js";import{b as ie,f as ce,t as T,c as de}from"./provider-models-y4mUDcGF.js";function h({className:o,...l}){return e.jsx("div",{className:L("animate-pulse rounded-md bg-slate-200",o),...l})}function me(o){const l=new Set;for(const u of o){const m=u.trim();m.length>0&&l.add(m)}return[...l]}function xe({id:o,value:l,onChange:u,options:m,placeholder:N,className:w,inputClassName:y,emptyText:b,createText:f,maxItems:v=Number.POSITIVE_INFINITY,onEnter:M}){const[C,r]=i.useState(!1),d=i.useMemo(()=>me(m),[m]),a=l.trim().toLowerCase(),g=i.useMemo(()=>{const s=d.map((x,j)=>({option:x,index:j}));a.length>0&&s.sort((x,j)=>{const S=x.option.toLowerCase(),k=j.option.toLowerCase(),D=S===a?0:S.startsWith(a)?1:S.includes(a)?2:3,I=k===a?0:k.startsWith(a)?1:k.includes(a)?2:3;return D!==I?D-I:x.index-j.index});const p=s.map(x=>x.option);return Number.isFinite(v)?p.slice(0,Math.max(1,v)):p},[d,a,v]),n=l.trim().length>0&&d.some(s=>s===l.trim());return e.jsxs("div",{className:L("relative",w),onBlur:()=>{setTimeout(()=>r(!1),120)},children:[e.jsx(_,{id:o,value:l,onFocus:()=>r(!0),onChange:s=>{u(s.target.value),C||r(!0)},onKeyDown:s=>{s.key==="Enter"&&(M&&(s.preventDefault(),M()),r(!1))},placeholder:N,className:L("pr-10",y)}),e.jsx("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>r(s=>!s),className:"absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center text-gray-400 hover:text-gray-600","aria-label":"toggle model options",children:e.jsx(q,{className:"h-4 w-4"})}),C&&e.jsx("div",{className:"absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg",children:e.jsxs("div",{className:"max-h-60 overflow-y-auto py-1",children:[!n&&l.trim().length>0&&e.jsxs("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>{u(l.trim()),r(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(U,{className:"h-4 w-4 text-transparent"}),e.jsx("span",{className:"truncate text-gray-700",children:f?f.replace("{value}",l.trim()):l.trim()})]}),g.map(s=>e.jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>{u(s),r(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(U,{className:L("h-4 w-4",s===l.trim()?"text-primary":"text-transparent")}),e.jsx("span",{className:"truncate text-gray-700",children:s})]},s)),g.length===0&&l.trim().length===0&&e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500",children:b??"No models available"})]})})]})}function ye(){const{data:o,isLoading:l}=Z(),{data:u}=H(),{data:m}=ee(),N=se(),[w,y]=i.useState(""),[b,f]=i.useState(""),[v,M]=i.useState(""),C=m==null?void 0:m.uiHints,r=W("agents.defaults.model",C),d=W("agents.defaults.workspace",C),a=i.useMemo(()=>ie({meta:u,config:o}),[o,u]),g=i.useMemo(()=>new Map(a.map(t=>[t.name,t])),[a]),n=g.get(w)??a[0],s=(n==null?void 0:n.name)??"",p=i.useMemo(()=>(n==null?void 0:n.aliases)??[],[n]),x=i.useMemo(()=>(n==null?void 0:n.models)??[],[n]);i.useEffect(()=>{w||a.length===0||y(a[0].name)},[w,a]),i.useEffect(()=>{var E,F,B;if(!((E=o==null?void 0:o.agents)!=null&&E.defaults))return;const t=(o.agents.defaults.model||"").trim(),P=ce(t,a)??((F=a[0])==null?void 0:F.name)??"",V=((B=g.get(P))==null?void 0:B.aliases)??[];y(P),f(T(t,V)),M(o.agents.defaults.workspace||"")},[o,a,g]);const j=i.useMemo(()=>{const t=new Set;for(const O of x){const P=O.trim();P&&t.add(P)}return[...t]},[x]),S=i.useMemo(()=>{const t=T(b,p);return t?de((n==null?void 0:n.prefix)??"",t):""},[b,n,p]),k=c("modelIdentifierHelp")||(r==null?void 0:r.help)||"",D=t=>{y(t),f("")},I=t=>{f(T(t,p))},A=t=>{t.preventDefault(),N.mutate({model:S})};return l?e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-8 w-32"}),e.jsx(h,{className:"h-4 w-48"})]}),e.jsxs(z,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(h,{className:"h-12 w-12 rounded-xl"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-5 w-24"}),e.jsx(h,{className:"h-3 w-32"})]})]}),e.jsx(h,{className:"h-4 w-20 mb-2"}),e.jsx(h,{className:"h-10 w-full rounded-xl"})]}),e.jsxs(z,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsx(h,{className:"h-5 w-24 mb-2"}),e.jsx(h,{className:"h-10 w-full rounded-xl"})]})]}):e.jsxs(J,{children:[e.jsx(Q,{title:c("modelPageTitle"),description:c("modelPageDescription")}),e.jsxs("form",{onSubmit:A,className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(G,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:c("defaultModel")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"model",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(r==null?void 0:r.label)??"Model Name"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("div",{className:"sm:w-[38%] sm:min-w-[170px]",children:e.jsxs(te,{value:s,onValueChange:D,children:[e.jsx(ae,{className:"h-10 w-full rounded-xl",children:e.jsx(le,{placeholder:c("providersSelectPlaceholder")})}),e.jsx(re,{children:a.map(t=>e.jsx(ne,{value:t.name,children:t.displayName},t.name))})]})}),e.jsx("span",{className:"hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex",children:"/"}),e.jsx(xe,{id:"model",value:b,onChange:I,options:j,placeholder:(r==null?void 0:r.placeholder)??"gpt-5.1",className:"sm:flex-1",inputClassName:"h-10 rounded-xl",emptyText:c("modelPickerNoOptions"),createText:c("modelPickerUseCustom")},s)]}),e.jsx("p",{className:"text-xs text-gray-400",children:k}),e.jsx("p",{className:"text-xs text-gray-500",children:c("modelInputCustomHint")}),e.jsxs("a",{href:`${oe}/guide/model-selection`,className:"inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors",children:[e.jsx(K,{className:"h-3.5 w-3.5"}),c("channelsGuideTitle")]})]})]}),e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(Y,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:c("workspace")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"workspace",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(d==null?void 0:d.label)??"Default Path"}),e.jsx(_,{id:"workspace",value:v,onChange:t=>M(t.target.value),placeholder:(d==null?void 0:d.placeholder)??"/path/to/workspace",className:"rounded-xl"})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(X,{type:"submit",disabled:N.isPending,size:"lg",children:N.isPending?e.jsx($,{className:"h-5 w-5 animate-spin"}):c("saveChanges")})})]})]})}export{ye as ModelConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,j as e,aD as Ce,aE as Pe,ax as pe,X as ie,at as xe,aF as Se,C as De,aG as Ee,aH as re,Y as Me,K as Le}from"./vendor-Dj2ULvht.js";import{I as K,u as ye,a as fe,b as ge,o as ke,p as Be,q as Te,r as Ke}from"./useConfig-q7QqH3JB.js";import{B as T,P as Ie,a as $e}from"./page-layout-CC6kzYFp.js";import{L as R}from"./label-DhIqXnKx.js";import{c as Y,t,S as Fe,a as _e,b as Oe,d as He,e as Re}from"./index-DP9xXu9V.js";import{C as ze,a as We,S as je,b as Ge,c as Ve,L as qe,g as Ue}from"./logos-B9Qiy9wo.js";import{h as U}from"./config-hints-CApS3K_7.js";import{T as Xe}from"./tabs-custom-C_1pBckQ.js";function Ye({maskedValue:s,isSet:a,className:r,value:i,onChange:y,placeholder:b,...f}){const[c,u]=x.useState(!1),[g,p]=x.useState(!1),A=typeof i=="string"&&i.length>0,S=a&&!A&&!g;return e.jsxs("div",{className:"relative",children:[S?e.jsx("div",{onClick:()=>p(!0),className:Y("flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12",r),children:"••••••••••••"}):e.jsx(K,{type:c?"text":"password",className:Y("pr-12",r),value:i,onChange:y,onBlur:()=>{A||p(!1)},placeholder:b,autoFocus:g,...f}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(a||A)&&e.jsx(T,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>u(!c),children:c?e.jsx(Ce,{className:"h-4 w-4"}):e.jsx(Pe,{className:"h-4 w-4"})})})]})}function Qe({value:s,onChange:a,className:r}){const i=s?Object.entries(s):[],y=(c,u,g)=>{const p=[...i];p[c]=[u,g],a(Object.fromEntries(p))},b=()=>{a({...s,"":""})},f=c=>{const u=i.filter((g,p)=>p!==c);a(Object.fromEntries(u))};return e.jsxs("div",{className:Y("space-y-2",r),children:[i.map(([c,u],g)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"text",value:c,onChange:p=>y(g,p.target.value,u),placeholder:t("headerName"),className:"flex-1"}),e.jsx(K,{type:"text",value:u,onChange:p=>y(g,c,p.target.value),placeholder:t("headerValue"),className:"flex-1"}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>f(g),children:e.jsx(pe,{className:"h-4 w-4 text-red-500"})})]},g)),e.jsxs(T,{type:"button",variant:"outline",size:"sm",onClick:b,children:[e.jsx(ie,{className:"h-4 w-4 mr-2"}),t("add")]})]})}function X(s){if(!s)return null;const a=Object.entries(s).map(([r,i])=>[r.trim(),i]).filter(([r])=>r.length>0);return a.length===0?null:Object.fromEntries(a)}function he(s,a){const r=X(s),i=X(a);if(r===null&&i===null)return!0;if(!r||!i)return!1;const y=Object.entries(r).sort(([f],[c])=>f.localeCompare(c)),b=Object.entries(i).sort(([f],[c])=>f.localeCompare(c));return y.length!==b.length?!1:y.every(([f,c],u)=>f===b[u][0]&&c===b[u][1])}function ne(s){if(!s||s.length===0)return[];const a=new Set;for(const r of s){const i=r.trim();i&&a.add(i)}return[...a]}function Je(s,a){const r=s.trim();if(!r||!a.trim())return r;const i=`${a.trim()}/`;return r.startsWith(i)?r.slice(i.length):r}function J(s,a){let r=s.trim();if(!r)return"";for(const i of a){const y=i.trim();y&&(r=Je(r,y))}return r.trim()}function le(s,a){return s.length!==a.length?!1:s.every((r,i)=>r===a[i])}function Ze(s,a){const r=[...s];for(const i of a)r.includes(i)||r.push(i);return r}function es(s,a){return a.length===0?s:a.every(i=>!s.includes(i))?Ze(s,a):a}function ss(s,a){return le(s,a)?[]:s}function ts({providerName:s,onProviderDeleted:a}){const{data:r}=ye(),{data:i}=fe(),{data:y}=ge(),b=ke(),f=Be(),c=Te(),[u,g]=x.useState(""),[p,A]=x.useState(""),[S,z]=x.useState(null),[L,C]=x.useState("auto"),[w,I]=x.useState([]),[d,m]=x.useState(""),[N,v]=x.useState(""),[D,$]=x.useState(!1),[k,B]=x.useState(!1),l=i==null?void 0:i.providers.find(n=>n.name===s),o=s?r==null?void 0:r.providers[s]:null,Q=y==null?void 0:y.uiHints,F=!!(l!=null&&l.isCustom),_=s?U(`providers.${s}.apiKey`,Q):void 0,E=s?U(`providers.${s}.apiBase`,Q):void 0,Z=s?U(`providers.${s}.extraHeaders`,Q):void 0,ee=s?U(`providers.${s}.wireApi`,Q):void 0,oe=(l==null?void 0:l.displayName)||s||"",O=((o==null?void 0:o.displayName)||"").trim()||oe,be=N.trim()||O||s||t("providersSelectPlaceholder"),ce=(l==null?void 0:l.modelPrefix)||s||"",H=x.useMemo(()=>ne([ce,s||""]),[ce,s]),se=(l==null?void 0:l.defaultApiBase)||"",W=(o==null?void 0:o.apiBase)||se,te=X((o==null?void 0:o.extraHeaders)||null),G=(o==null?void 0:o.wireApi)||(l==null?void 0:l.defaultWireApi)||"auto",ae=x.useMemo(()=>ne(((l==null?void 0:l.defaultModels)??[]).map(n=>J(n,H))),[l==null?void 0:l.defaultModels,H]),de=x.useMemo(()=>ne(((o==null?void 0:o.models)??[]).map(n=>J(n,H))),[o==null?void 0:o.models,H]),V=x.useMemo(()=>es(ae,de),[ae,de]);s==="minimax"?t("providerApiBaseHelpMinimax"):E!=null&&E.help||t("providerApiBaseHelp"),x.useEffect(()=>{if(!s){g(""),A(""),z(null),C("auto"),I([]),m(""),v("");return}g(""),A(W),z((o==null?void 0:o.extraHeaders)||null),C(G),I(V),m(""),v(O)},[s,W,o==null?void 0:o.extraHeaders,G,V,O]);const me=x.useMemo(()=>{if(!s)return!1;const n=u.trim().length>0,j=p.trim()!==W.trim(),P=!he(S,te),h=l!=null&&l.supportsWireApi?L!==G:!1,M=!le(w,V),q=F?N.trim()!==O:!1;return n||j||P||h||M||q},[s,F,N,O,u,p,W,S,te,l==null?void 0:l.supportsWireApi,L,G,w,V]),ue=()=>{const n=J(d,H);if(n){if(w.includes(n)){m("");return}I(j=>[...j,n]),m("")}},Ne=n=>{if(n.preventDefault(),!s)return;const j={},P=u.trim(),h=p.trim(),M=X(S),q=N.trim();F&&q!==O&&(j.displayName=q.length>0?q:null),P.length>0&&(j.apiKey=P),h!==W.trim()&&(j.apiBase=h.length>0&&h!==se?h:null),he(M,te)||(j.extraHeaders=M),l!=null&&l.supportsWireApi&&L!==G&&(j.wireApi=L),le(w,V)||(j.models=ss(w,ae)),b.mutate({provider:s,data:j})},ve=async()=>{if(!s)return;const n=w.find(h=>h.trim().length>0)??"",j=J(n,H),P={apiBase:p.trim(),extraHeaders:X(S),model:j||null};u.trim().length>0&&(P.apiKey=u.trim()),l!=null&&l.supportsWireApi&&(P.wireApi=L);try{const h=await c.mutateAsync({provider:s,data:P});if(h.success){re.success(`${t("providerTestConnectionSuccess")} (${h.latencyMs}ms)`);return}const M=[`provider=${h.provider}`,`latency=${h.latencyMs}ms`];h.model&&M.push(`model=${h.model}`),re.error(`${t("providerTestConnectionFailed")}: ${h.message} | ${M.join(" | ")}`)}catch(h){const M=h instanceof Error?h.message:String(h);re.error(`${t("providerTestConnectionFailed")}: ${M}`)}},we=async()=>{if(!(!s||!F||!window.confirm(t("providerDeleteConfirm"))))try{await f.mutateAsync({provider:s}),a==null||a(s)}catch{}};if(!s||!l||!o)return e.jsx("div",{className:ze,children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:t("providersSelectTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:t("providersSelectDescription")})]})});const Ae=o.apiKeySet?t("statusReady"):t("statusSetup");return e.jsxs("div",{className:We,children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"truncate text-lg font-semibold text-gray-900",children:be}),e.jsxs("div",{className:"flex items-center gap-3",children:[F&&e.jsx("button",{type:"button",onClick:we,disabled:f.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:t("providerDelete"),children:e.jsx(pe,{className:"h-4 w-4"})}),e.jsx(je,{status:o.apiKeySet?"ready":"setup",label:Ae})]})]})}),e.jsxs("form",{onSubmit:Ne,className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:[F&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:t("providerDisplayName")}),e.jsx(K,{id:"providerDisplayName",type:"text",value:N,onChange:n=>v(n.target.value),placeholder:oe||t("providerDisplayNamePlaceholder"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("providerDisplayNameHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(_==null?void 0:_.label)??t("apiKey")}),e.jsx(Ye,{id:"apiKey",value:u,isSet:o.apiKeySet,onChange:n=>g(n.target.value),placeholder:(_==null?void 0:_.placeholder)??t("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("leaveBlankToKeepUnchanged")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(E==null?void 0:E.label)??t("apiBase")}),e.jsx(K,{id:"apiBase",type:"text",value:p,onChange:n=>A(n.target.value),placeholder:se||(E==null?void 0:E.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("providerApiBaseHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(R,{className:"text-sm font-medium text-gray-900",children:t("providerModelsTitle")}),!k&&e.jsxs("button",{type:"button",onClick:()=>B(!0),className:"text-xs text-primary hover:text-primary/80 font-medium flex items-center gap-1",children:[e.jsx(ie,{className:"h-3 w-3"}),t("providerAddModel")]})]}),k&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{value:d,onChange:n=>m(n.target.value),onKeyDown:n=>{n.key==="Enter"&&(n.preventDefault(),ue()),n.key==="Escape"&&(B(!1),m(""))},placeholder:t("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(T,{type:"button",size:"sm",onClick:ue,disabled:d.trim().length===0,children:t("add")}),e.jsx(T,{type:"button",size:"sm",variant:"ghost",onClick:()=>{B(!1),m("")},children:e.jsx(xe,{className:"h-4 w-4"})})]}),w.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center",children:[e.jsx("p",{className:"text-sm text-gray-500",children:t("providerModelsEmptyShort")}),!k&&e.jsx("button",{type:"button",onClick:()=>B(!0),className:"mt-2 text-sm text-primary hover:text-primary/80 font-medium",children:t("providerAddFirstModel")})]}):e.jsx("div",{className:"flex flex-wrap gap-2",children:w.map(n=>e.jsxs("div",{className:"group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5",children:[e.jsx("span",{className:"max-w-[180px] truncate text-sm text-gray-800 sm:max-w-[240px]",children:n}),e.jsx("button",{type:"button",onClick:()=>I(j=>j.filter(P=>P!==n)),className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 transition-opacity hover:bg-gray-100 hover:text-gray-600 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":t("remove"),children:e.jsx(xe,{className:"h-3 w-3"})})]},n))})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>$(!D),className:"flex w-full items-center justify-between text-sm text-gray-600 hover:text-gray-900 transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Se,{className:"h-3.5 w-3.5"}),t("providerAdvancedSettings")]}),e.jsx(De,{className:`h-4 w-4 transition-transform ${D?"rotate-180":""}`})]}),D&&e.jsxs("div",{className:"mt-4 space-y-5",children:[l.supportsWireApi&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:(ee==null?void 0:ee.label)??t("wireApi")}),e.jsxs(Fe,{value:L,onValueChange:n=>C(n),children:[e.jsx(_e,{className:"rounded-xl",children:e.jsx(Oe,{})}),e.jsx(He,{children:(l.wireApiOptions||["auto","chat","responses"]).map(n=>e.jsx(Re,{value:n,children:n==="chat"?t("wireApiChat"):n==="responses"?t("wireApiResponses"):t("wireApiAuto")},n))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{className:"text-sm font-medium text-gray-900",children:(Z==null?void 0:Z.label)??t("extraHeaders")}),e.jsx(Qe,{value:S,onChange:z}),e.jsx("p",{className:"text-xs text-gray-500",children:t("providerExtraHeadersHelpShort")})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-4",children:[e.jsxs(T,{type:"button",variant:"outline",size:"sm",onClick:ve,disabled:c.isPending,children:[e.jsx(Ee,{className:"mr-1.5 h-4 w-4"}),c.isPending?t("providerTestingConnection"):t("providerTestConnection")]}),e.jsx(T,{type:"submit",disabled:b.isPending||!me,children:b.isPending?t("saving"):me?t("save"):t("unchanged")})]})]})]})}function as(s){if(!s)return null;try{const a=new URL(s),r=a.pathname&&a.pathname!=="/"?a.pathname:"";return`${a.host}${r}`}catch{return s.replace(/^https?:\/\//,"")}}function xs(){const{data:s}=ye(),{data:a}=fe(),{data:r}=ge(),i=Ke(),[y,b]=x.useState("installed"),[f,c]=x.useState(),[u,g]=x.useState(""),p=r==null?void 0:r.uiHints,A=(a==null?void 0:a.providers)??[],S=(s==null?void 0:s.providers)??{},z=A.filter(d=>{var m;return(m=S[d.name])==null?void 0:m.apiKeySet}).length,L=[{id:"installed",label:t("providersTabConfigured"),count:z},{id:"all",label:t("providersTabAll"),count:A.length}],C=x.useMemo(()=>{const d=(a==null?void 0:a.providers)??[],m=(s==null?void 0:s.providers)??{},N=u.trim().toLowerCase();return d.filter(v=>{var D;return y==="installed"?!!((D=m[v.name])!=null&&D.apiKeySet):!0}).filter(v=>{var k,B;return N?(((B=(k=m[v.name])==null?void 0:k.displayName)==null?void 0:B.trim())||v.displayName||v.name).toLowerCase().includes(N)||v.name.toLowerCase().includes(N):!0})},[a,s,y,u]);x.useEffect(()=>{if(C.length===0){c(void 0);return}C.some(m=>m.name===f)||c(C[0].name)},[C,f]);const w=f,I=async()=>{try{const d=await i.mutateAsync({data:{}});b("all"),g(""),c(d.name)}catch{}};return!s||!a?e.jsx("div",{className:"p-8",children:t("providersLoading")}):e.jsxs(Ie,{children:[e.jsx($e,{title:t("providersPageTitle"),description:t("providersPageDescription")}),e.jsxs("div",{className:Ge,children:[e.jsxs("section",{className:Ve,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(Xe,{tabs:L,activeTab:y,onChange:b,className:"mb-0"}),e.jsxs(T,{type:"button",variant:"outline",className:"w-full justify-center",onClick:I,disabled:i.isPending,children:[e.jsx(ie,{className:"mr-2 h-4 w-4"}),i.isPending?t("saving"):t("providerAddCustom")]})]}),e.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(Me,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(K,{value:u,onChange:d=>g(d.target.value),placeholder:t("providersFilterPlaceholder"),className:"h-10 rounded-xl pl-9"})]})}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:[C.map(d=>{var o;const m=s.providers[d.name],N=!!(m!=null&&m.apiKeySet),v=w===d.name,D=((o=m==null?void 0:m.displayName)==null?void 0:o.trim())||d.displayName||d.name,$=U(`providers.${d.name}`,p),k=(m==null?void 0:m.apiBase)||d.defaultApiBase||"",l=as(k)||($==null?void 0:$.help)||t("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>c(d.name),className:Y("w-full rounded-xl border p-2.5 text-left transition-all",v?"border-primary/30 bg-primary-50/40 shadow-sm":"border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70"),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(qe,{name:d.name,src:Ue(d.name),className:Y("h-10 w-10 rounded-lg border",N?"border-primary/30 bg-white":"border-gray-200/70 bg-white"),imgClassName:"h-5 w-5 object-contain",fallback:e.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500",children:d.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:D}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:l})]})]}),e.jsx(je,{status:N?"ready":"setup",label:N?t("statusReady"):t("statusSetup"),className:"min-w-[56px] justify-center"})]})},d.name)}),C.length===0&&e.jsxs("div",{className:"flex h-full min-h-[220px] flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50/70 py-10 text-center",children:[e.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white",children:e.jsx(Le,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:t("providersNoMatch")})]})]})]}),e.jsx(ts,{providerName:w,onProviderDeleted:d=>{d===f&&c(void 0)}})]})]})}export{xs as ProvidersList};
|
|
1
|
+
import{r as x,j as e,aD as Ce,aE as Pe,ax as pe,X as ie,at as xe,aF as Se,C as De,aG as Ee,aH as re,Y as Me,K as Le}from"./vendor-Dj2ULvht.js";import{I as K,u as ye,a as fe,b as ge,o as ke,p as Be,q as Te,r as Ke}from"./useConfig-CDl9UK5m.js";import{B as T,P as Ie,a as $e}from"./page-layout-DaLNSFKw.js";import{L as R}from"./label-BxzAKPzU.js";import{c as Y,t,S as Fe,a as _e,b as Oe,d as He,e as Re}from"./index-CD8a2KMH.js";import{C as ze,a as We,S as je,b as Ge,c as Ve,L as qe,g as Ue}from"./logos-C3oHQ9kv.js";import{h as U}from"./config-hints-CApS3K_7.js";import{T as Xe}from"./tabs-custom-zdFy3fnK.js";function Ye({maskedValue:s,isSet:a,className:r,value:i,onChange:y,placeholder:b,...f}){const[c,u]=x.useState(!1),[g,p]=x.useState(!1),A=typeof i=="string"&&i.length>0,S=a&&!A&&!g;return e.jsxs("div",{className:"relative",children:[S?e.jsx("div",{onClick:()=>p(!0),className:Y("flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12",r),children:"••••••••••••"}):e.jsx(K,{type:c?"text":"password",className:Y("pr-12",r),value:i,onChange:y,onBlur:()=>{A||p(!1)},placeholder:b,autoFocus:g,...f}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(a||A)&&e.jsx(T,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>u(!c),children:c?e.jsx(Ce,{className:"h-4 w-4"}):e.jsx(Pe,{className:"h-4 w-4"})})})]})}function Qe({value:s,onChange:a,className:r}){const i=s?Object.entries(s):[],y=(c,u,g)=>{const p=[...i];p[c]=[u,g],a(Object.fromEntries(p))},b=()=>{a({...s,"":""})},f=c=>{const u=i.filter((g,p)=>p!==c);a(Object.fromEntries(u))};return e.jsxs("div",{className:Y("space-y-2",r),children:[i.map(([c,u],g)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"text",value:c,onChange:p=>y(g,p.target.value,u),placeholder:t("headerName"),className:"flex-1"}),e.jsx(K,{type:"text",value:u,onChange:p=>y(g,c,p.target.value),placeholder:t("headerValue"),className:"flex-1"}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>f(g),children:e.jsx(pe,{className:"h-4 w-4 text-red-500"})})]},g)),e.jsxs(T,{type:"button",variant:"outline",size:"sm",onClick:b,children:[e.jsx(ie,{className:"h-4 w-4 mr-2"}),t("add")]})]})}function X(s){if(!s)return null;const a=Object.entries(s).map(([r,i])=>[r.trim(),i]).filter(([r])=>r.length>0);return a.length===0?null:Object.fromEntries(a)}function he(s,a){const r=X(s),i=X(a);if(r===null&&i===null)return!0;if(!r||!i)return!1;const y=Object.entries(r).sort(([f],[c])=>f.localeCompare(c)),b=Object.entries(i).sort(([f],[c])=>f.localeCompare(c));return y.length!==b.length?!1:y.every(([f,c],u)=>f===b[u][0]&&c===b[u][1])}function ne(s){if(!s||s.length===0)return[];const a=new Set;for(const r of s){const i=r.trim();i&&a.add(i)}return[...a]}function Je(s,a){const r=s.trim();if(!r||!a.trim())return r;const i=`${a.trim()}/`;return r.startsWith(i)?r.slice(i.length):r}function J(s,a){let r=s.trim();if(!r)return"";for(const i of a){const y=i.trim();y&&(r=Je(r,y))}return r.trim()}function le(s,a){return s.length!==a.length?!1:s.every((r,i)=>r===a[i])}function Ze(s,a){const r=[...s];for(const i of a)r.includes(i)||r.push(i);return r}function es(s,a){return a.length===0?s:a.every(i=>!s.includes(i))?Ze(s,a):a}function ss(s,a){return le(s,a)?[]:s}function ts({providerName:s,onProviderDeleted:a}){const{data:r}=ye(),{data:i}=fe(),{data:y}=ge(),b=ke(),f=Be(),c=Te(),[u,g]=x.useState(""),[p,A]=x.useState(""),[S,z]=x.useState(null),[L,C]=x.useState("auto"),[w,I]=x.useState([]),[d,m]=x.useState(""),[N,v]=x.useState(""),[D,$]=x.useState(!1),[k,B]=x.useState(!1),l=i==null?void 0:i.providers.find(n=>n.name===s),o=s?r==null?void 0:r.providers[s]:null,Q=y==null?void 0:y.uiHints,F=!!(l!=null&&l.isCustom),_=s?U(`providers.${s}.apiKey`,Q):void 0,E=s?U(`providers.${s}.apiBase`,Q):void 0,Z=s?U(`providers.${s}.extraHeaders`,Q):void 0,ee=s?U(`providers.${s}.wireApi`,Q):void 0,oe=(l==null?void 0:l.displayName)||s||"",O=((o==null?void 0:o.displayName)||"").trim()||oe,be=N.trim()||O||s||t("providersSelectPlaceholder"),ce=(l==null?void 0:l.modelPrefix)||s||"",H=x.useMemo(()=>ne([ce,s||""]),[ce,s]),se=(l==null?void 0:l.defaultApiBase)||"",W=(o==null?void 0:o.apiBase)||se,te=X((o==null?void 0:o.extraHeaders)||null),G=(o==null?void 0:o.wireApi)||(l==null?void 0:l.defaultWireApi)||"auto",ae=x.useMemo(()=>ne(((l==null?void 0:l.defaultModels)??[]).map(n=>J(n,H))),[l==null?void 0:l.defaultModels,H]),de=x.useMemo(()=>ne(((o==null?void 0:o.models)??[]).map(n=>J(n,H))),[o==null?void 0:o.models,H]),V=x.useMemo(()=>es(ae,de),[ae,de]);s==="minimax"?t("providerApiBaseHelpMinimax"):E!=null&&E.help||t("providerApiBaseHelp"),x.useEffect(()=>{if(!s){g(""),A(""),z(null),C("auto"),I([]),m(""),v("");return}g(""),A(W),z((o==null?void 0:o.extraHeaders)||null),C(G),I(V),m(""),v(O)},[s,W,o==null?void 0:o.extraHeaders,G,V,O]);const me=x.useMemo(()=>{if(!s)return!1;const n=u.trim().length>0,j=p.trim()!==W.trim(),P=!he(S,te),h=l!=null&&l.supportsWireApi?L!==G:!1,M=!le(w,V),q=F?N.trim()!==O:!1;return n||j||P||h||M||q},[s,F,N,O,u,p,W,S,te,l==null?void 0:l.supportsWireApi,L,G,w,V]),ue=()=>{const n=J(d,H);if(n){if(w.includes(n)){m("");return}I(j=>[...j,n]),m("")}},Ne=n=>{if(n.preventDefault(),!s)return;const j={},P=u.trim(),h=p.trim(),M=X(S),q=N.trim();F&&q!==O&&(j.displayName=q.length>0?q:null),P.length>0&&(j.apiKey=P),h!==W.trim()&&(j.apiBase=h.length>0&&h!==se?h:null),he(M,te)||(j.extraHeaders=M),l!=null&&l.supportsWireApi&&L!==G&&(j.wireApi=L),le(w,V)||(j.models=ss(w,ae)),b.mutate({provider:s,data:j})},ve=async()=>{if(!s)return;const n=w.find(h=>h.trim().length>0)??"",j=J(n,H),P={apiBase:p.trim(),extraHeaders:X(S),model:j||null};u.trim().length>0&&(P.apiKey=u.trim()),l!=null&&l.supportsWireApi&&(P.wireApi=L);try{const h=await c.mutateAsync({provider:s,data:P});if(h.success){re.success(`${t("providerTestConnectionSuccess")} (${h.latencyMs}ms)`);return}const M=[`provider=${h.provider}`,`latency=${h.latencyMs}ms`];h.model&&M.push(`model=${h.model}`),re.error(`${t("providerTestConnectionFailed")}: ${h.message} | ${M.join(" | ")}`)}catch(h){const M=h instanceof Error?h.message:String(h);re.error(`${t("providerTestConnectionFailed")}: ${M}`)}},we=async()=>{if(!(!s||!F||!window.confirm(t("providerDeleteConfirm"))))try{await f.mutateAsync({provider:s}),a==null||a(s)}catch{}};if(!s||!l||!o)return e.jsx("div",{className:ze,children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:t("providersSelectTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:t("providersSelectDescription")})]})});const Ae=o.apiKeySet?t("statusReady"):t("statusSetup");return e.jsxs("div",{className:We,children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"truncate text-lg font-semibold text-gray-900",children:be}),e.jsxs("div",{className:"flex items-center gap-3",children:[F&&e.jsx("button",{type:"button",onClick:we,disabled:f.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:t("providerDelete"),children:e.jsx(pe,{className:"h-4 w-4"})}),e.jsx(je,{status:o.apiKeySet?"ready":"setup",label:Ae})]})]})}),e.jsxs("form",{onSubmit:Ne,className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:[F&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:t("providerDisplayName")}),e.jsx(K,{id:"providerDisplayName",type:"text",value:N,onChange:n=>v(n.target.value),placeholder:oe||t("providerDisplayNamePlaceholder"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("providerDisplayNameHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(_==null?void 0:_.label)??t("apiKey")}),e.jsx(Ye,{id:"apiKey",value:u,isSet:o.apiKeySet,onChange:n=>g(n.target.value),placeholder:(_==null?void 0:_.placeholder)??t("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("leaveBlankToKeepUnchanged")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(E==null?void 0:E.label)??t("apiBase")}),e.jsx(K,{id:"apiBase",type:"text",value:p,onChange:n=>A(n.target.value),placeholder:se||(E==null?void 0:E.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("providerApiBaseHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(R,{className:"text-sm font-medium text-gray-900",children:t("providerModelsTitle")}),!k&&e.jsxs("button",{type:"button",onClick:()=>B(!0),className:"text-xs text-primary hover:text-primary/80 font-medium flex items-center gap-1",children:[e.jsx(ie,{className:"h-3 w-3"}),t("providerAddModel")]})]}),k&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{value:d,onChange:n=>m(n.target.value),onKeyDown:n=>{n.key==="Enter"&&(n.preventDefault(),ue()),n.key==="Escape"&&(B(!1),m(""))},placeholder:t("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(T,{type:"button",size:"sm",onClick:ue,disabled:d.trim().length===0,children:t("add")}),e.jsx(T,{type:"button",size:"sm",variant:"ghost",onClick:()=>{B(!1),m("")},children:e.jsx(xe,{className:"h-4 w-4"})})]}),w.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center",children:[e.jsx("p",{className:"text-sm text-gray-500",children:t("providerModelsEmptyShort")}),!k&&e.jsx("button",{type:"button",onClick:()=>B(!0),className:"mt-2 text-sm text-primary hover:text-primary/80 font-medium",children:t("providerAddFirstModel")})]}):e.jsx("div",{className:"flex flex-wrap gap-2",children:w.map(n=>e.jsxs("div",{className:"group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5",children:[e.jsx("span",{className:"max-w-[180px] truncate text-sm text-gray-800 sm:max-w-[240px]",children:n}),e.jsx("button",{type:"button",onClick:()=>I(j=>j.filter(P=>P!==n)),className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 transition-opacity hover:bg-gray-100 hover:text-gray-600 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":t("remove"),children:e.jsx(xe,{className:"h-3 w-3"})})]},n))})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>$(!D),className:"flex w-full items-center justify-between text-sm text-gray-600 hover:text-gray-900 transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Se,{className:"h-3.5 w-3.5"}),t("providerAdvancedSettings")]}),e.jsx(De,{className:`h-4 w-4 transition-transform ${D?"rotate-180":""}`})]}),D&&e.jsxs("div",{className:"mt-4 space-y-5",children:[l.supportsWireApi&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:(ee==null?void 0:ee.label)??t("wireApi")}),e.jsxs(Fe,{value:L,onValueChange:n=>C(n),children:[e.jsx(_e,{className:"rounded-xl",children:e.jsx(Oe,{})}),e.jsx(He,{children:(l.wireApiOptions||["auto","chat","responses"]).map(n=>e.jsx(Re,{value:n,children:n==="chat"?t("wireApiChat"):n==="responses"?t("wireApiResponses"):t("wireApiAuto")},n))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{className:"text-sm font-medium text-gray-900",children:(Z==null?void 0:Z.label)??t("extraHeaders")}),e.jsx(Qe,{value:S,onChange:z}),e.jsx("p",{className:"text-xs text-gray-500",children:t("providerExtraHeadersHelpShort")})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-4",children:[e.jsxs(T,{type:"button",variant:"outline",size:"sm",onClick:ve,disabled:c.isPending,children:[e.jsx(Ee,{className:"mr-1.5 h-4 w-4"}),c.isPending?t("providerTestingConnection"):t("providerTestConnection")]}),e.jsx(T,{type:"submit",disabled:b.isPending||!me,children:b.isPending?t("saving"):me?t("save"):t("unchanged")})]})]})]})}function as(s){if(!s)return null;try{const a=new URL(s),r=a.pathname&&a.pathname!=="/"?a.pathname:"";return`${a.host}${r}`}catch{return s.replace(/^https?:\/\//,"")}}function xs(){const{data:s}=ye(),{data:a}=fe(),{data:r}=ge(),i=Ke(),[y,b]=x.useState("installed"),[f,c]=x.useState(),[u,g]=x.useState(""),p=r==null?void 0:r.uiHints,A=(a==null?void 0:a.providers)??[],S=(s==null?void 0:s.providers)??{},z=A.filter(d=>{var m;return(m=S[d.name])==null?void 0:m.apiKeySet}).length,L=[{id:"installed",label:t("providersTabConfigured"),count:z},{id:"all",label:t("providersTabAll"),count:A.length}],C=x.useMemo(()=>{const d=(a==null?void 0:a.providers)??[],m=(s==null?void 0:s.providers)??{},N=u.trim().toLowerCase();return d.filter(v=>{var D;return y==="installed"?!!((D=m[v.name])!=null&&D.apiKeySet):!0}).filter(v=>{var k,B;return N?(((B=(k=m[v.name])==null?void 0:k.displayName)==null?void 0:B.trim())||v.displayName||v.name).toLowerCase().includes(N)||v.name.toLowerCase().includes(N):!0})},[a,s,y,u]);x.useEffect(()=>{if(C.length===0){c(void 0);return}C.some(m=>m.name===f)||c(C[0].name)},[C,f]);const w=f,I=async()=>{try{const d=await i.mutateAsync({data:{}});b("all"),g(""),c(d.name)}catch{}};return!s||!a?e.jsx("div",{className:"p-8",children:t("providersLoading")}):e.jsxs(Ie,{children:[e.jsx($e,{title:t("providersPageTitle"),description:t("providersPageDescription")}),e.jsxs("div",{className:Ge,children:[e.jsxs("section",{className:Ve,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(Xe,{tabs:L,activeTab:y,onChange:b,className:"mb-0"}),e.jsxs(T,{type:"button",variant:"outline",className:"w-full justify-center",onClick:I,disabled:i.isPending,children:[e.jsx(ie,{className:"mr-2 h-4 w-4"}),i.isPending?t("saving"):t("providerAddCustom")]})]}),e.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(Me,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(K,{value:u,onChange:d=>g(d.target.value),placeholder:t("providersFilterPlaceholder"),className:"h-10 rounded-xl pl-9"})]})}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:[C.map(d=>{var o;const m=s.providers[d.name],N=!!(m!=null&&m.apiKeySet),v=w===d.name,D=((o=m==null?void 0:m.displayName)==null?void 0:o.trim())||d.displayName||d.name,$=U(`providers.${d.name}`,p),k=(m==null?void 0:m.apiBase)||d.defaultApiBase||"",l=as(k)||($==null?void 0:$.help)||t("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>c(d.name),className:Y("w-full rounded-xl border p-2.5 text-left transition-all",v?"border-primary/30 bg-primary-50/40 shadow-sm":"border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70"),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(qe,{name:d.name,src:Ue(d.name),className:Y("h-10 w-10 rounded-lg border",N?"border-primary/30 bg-white":"border-gray-200/70 bg-white"),imgClassName:"h-5 w-5 object-contain",fallback:e.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500",children:d.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:D}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:l})]})]}),e.jsx(je,{status:N?"ready":"setup",label:N?t("statusReady"):t("statusSetup"),className:"min-w-[56px] justify-center"})]})},d.name)}),C.length===0&&e.jsxs("div",{className:"flex h-full min-h-[220px] flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50/70 py-10 text-center",children:[e.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white",children:e.jsx(Le,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:t("providersNoMatch")})]})]})]}),e.jsx(ts,{providerName:w,onProviderDeleted:d=>{d===f&&c(void 0)}})]})]})}export{xs as ProvidersList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as e,ax as ee,X as ae,aL as de,aH as se}from"./vendor-Dj2ULvht.js";import{u as me,b as he,w as ue,I as i}from"./useConfig-
|
|
1
|
+
import{r as p,j as e,ax as ee,X as ae,aL as de,aH as se}from"./vendor-Dj2ULvht.js";import{u as me,b as he,w as ue,I as i}from"./useConfig-CDl9UK5m.js";import{P as pe,a as xe,B as w}from"./page-layout-DaLNSFKw.js";import{C as R,b as $,c as z,d as D,a as L}from"./card-CCSDsedj.js";import{S as ge}from"./switch-DHOCEi5L.js";import{t,S as te,a as re,b as ne,d as le,e as S}from"./index-CD8a2KMH.js";import{h as x}from"./config-hints-CApS3K_7.js";const je=[{value:"main",label:"main"},{value:"per-peer",label:"per-peer"},{value:"per-channel-peer",label:"per-channel-peer"},{value:"per-account-channel-peer",label:"per-account-channel-peer"}];function fe(){return{id:"",default:!1,workspace:"",model:"",engine:"",contextTokens:void 0,maxToolIterations:void 0}}function ve(){return{agentId:"",match:{channel:"",accountId:""}}}function ce(d){const b=d.trim();if(!b)return;const j=Number.parseInt(b,10);return Number.isFinite(j)?j:void 0}function we(){const{data:d,isLoading:b}=me(),{data:j}=he(),A=ue(),[_,N]=p.useState([]),[q,E]=p.useState([]),[K,F]=p.useState("per-channel-peer"),[V,U]=p.useState(0),[X,G]=p.useState(2e5),[J,Q]=p.useState("native");p.useEffect(()=>{var a,r,n;d&&(N((d.agents.list??[]).map(s=>({id:s.id??"",default:!!s.default,workspace:s.workspace??"",model:s.model??"",engine:s.engine??"",contextTokens:s.contextTokens,maxToolIterations:s.maxToolIterations}))),E((d.bindings??[]).map(s=>{var c,l,o;return{agentId:s.agentId??"",match:{channel:((c=s.match)==null?void 0:c.channel)??"",accountId:((l=s.match)==null?void 0:l.accountId)??"",peer:(o=s.match)!=null&&o.peer?{kind:s.match.peer.kind,id:s.match.peer.id}:void 0}}})),F(((a=d.session)==null?void 0:a.dmScope)??"per-channel-peer"),U(((n=(r=d.session)==null?void 0:r.agentToAgent)==null?void 0:n.maxPingPongTurns)??0),G(d.agents.defaults.contextTokens??2e5),Q(d.agents.defaults.engine??"native"))},[d]);const u=j==null?void 0:j.uiHints,h=x("session.dmScope",u),f=x("session.agentToAgent.maxPingPongTurns",u),v=x("agents.defaults.contextTokens",u),I=x("agents.defaults.engine",u),O=x("agents.list.*.contextTokens",u),B=x("agents.list.*.engine",u),y=x("agents.list",u),k=x("bindings",u),oe=p.useMemo(()=>{const a=new Set(["main"]);return _.forEach(r=>{const n=r.id.trim();n&&a.add(n)}),a},[_]),g=(a,r)=>{N(n=>n.map((s,c)=>c===a?{...s,...r}:s))},T=(a,r)=>{E(n=>n.map((s,c)=>c===a?r:s))},ie=()=>{try{const a=_.map((s,c)=>{var m,C,P;const l=s.id.trim();if(!l)throw new Error(t("agentIdRequiredError").replace("{index}",String(c)));const o={id:l};return s.default&&(o.default=!0),(m=s.workspace)!=null&&m.trim()&&(o.workspace=s.workspace.trim()),(C=s.model)!=null&&C.trim()&&(o.model=s.model.trim()),(P=s.engine)!=null&&P.trim()&&(o.engine=s.engine.trim()),typeof s.contextTokens=="number"&&(o.contextTokens=Math.max(1e3,s.contextTokens)),typeof s.maxToolIterations=="number"&&(o.maxToolIterations=s.maxToolIterations),o}),r=a.map(s=>s.id).filter((s,c,l)=>l.indexOf(s)!==c);if(r.length>0){se.error(`${t("duplicateAgentId")}: ${r[0]}`);return}const n=q.map((s,c)=>{var W,Y,Z,H;const l=s.agentId.trim(),o=s.match.channel.trim(),m=((W=s.match.accountId)==null?void 0:W.trim())??"",C=(Y=s.match.peer)==null?void 0:Y.kind,P=((H=(Z=s.match.peer)==null?void 0:Z.id)==null?void 0:H.trim())??"";if(!l)throw new Error(t("bindingAgentIdRequired").replace("{index}",String(c)));if(!oe.has(l))throw new Error(`${t("bindingAgentIdNotFound").replace("{index}",String(c))}: ${l}`);if(!o)throw new Error(t("bindingChannelRequired").replace("{index}",String(c)));const M={agentId:l,match:{channel:o}};if(m&&(M.match.accountId=m),C){if(!P)throw new Error(t("bindingPeerIdRequired").replace("{index}",String(c)));M.match.peer={kind:C,id:P}}return M});A.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,X),engine:J.trim()||"native"},list:a},bindings:n,session:{dmScope:K,agentToAgent:{maxPingPongTurns:Math.min(5,Math.max(0,V))}}}})}catch(a){const r=a instanceof Error?a.message:String(a);se.error(r)}};return b||!d?e.jsx("div",{className:"p-8 text-gray-400",children:t("runtimeLoading")}):e.jsxs(pe,{className:"space-y-6",children:[e.jsx(xe,{title:t("runtimePageTitle"),description:t("runtimePageDescription")}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(h==null?void 0:h.label)??t("dmScope")}),e.jsx(D,{children:(h==null?void 0:h.help)??t("dmScopeHelp")})]}),e.jsxs(L,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(v==null?void 0:v.label)??t("defaultContextTokens")}),e.jsx(i,{type:"number",min:1e3,step:1e3,value:X,onChange:a=>G(Math.max(1e3,Number.parseInt(a.target.value,10)||1e3))}),e.jsx("p",{className:"text-xs text-gray-500",children:(v==null?void 0:v.help)??t("defaultContextTokensHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(I==null?void 0:I.label)??t("defaultEngine")}),e.jsx(i,{value:J,onChange:a=>Q(a.target.value),placeholder:t("defaultEnginePlaceholder")}),e.jsx("p",{className:"text-xs text-gray-500",children:(I==null?void 0:I.help)??t("defaultEngineHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(h==null?void 0:h.label)??t("dmScope")}),e.jsxs(te,{value:K,onValueChange:a=>F(a),children:[e.jsx(re,{children:e.jsx(ne,{})}),e.jsx(le,{children:je.map(a=>e.jsx(S,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(f==null?void 0:f.label)??t("maxPingPongTurns")}),e.jsx(i,{type:"number",min:0,max:5,value:V,onChange:a=>U(Math.max(0,Number.parseInt(a.target.value,10)||0))}),e.jsx("p",{className:"text-xs text-gray-500",children:(f==null?void 0:f.help)??t("maxPingPongTurnsHelp")})]})]})]}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(y==null?void 0:y.label)??t("agentList")}),e.jsx(D,{children:(y==null?void 0:y.help)??t("agentListHelp")})]}),e.jsxs(L,{className:"space-y-3",children:[_.map((a,r)=>e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(i,{value:a.id,onChange:n=>g(r,{id:n.target.value}),placeholder:t("agentIdPlaceholder")}),e.jsx(i,{value:a.workspace??"",onChange:n=>g(r,{workspace:n.target.value}),placeholder:t("workspaceOverridePlaceholder")}),e.jsx(i,{value:a.model??"",onChange:n=>g(r,{model:n.target.value}),placeholder:t("modelOverridePlaceholder")}),e.jsx(i,{value:a.engine??"",onChange:n=>g(r,{engine:n.target.value}),placeholder:(B==null?void 0:B.label)??t("engineOverridePlaceholder")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(i,{type:"number",min:1e3,step:1e3,value:a.contextTokens??"",onChange:n=>g(r,{contextTokens:ce(n.target.value)}),placeholder:(O==null?void 0:O.label)??t("contextTokensPlaceholder")}),e.jsx(i,{type:"number",min:1,value:a.maxToolIterations??"",onChange:n=>g(r,{maxToolIterations:ce(n.target.value)}),placeholder:t("maxToolsPlaceholder")})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(ge,{checked:!!a.default,onCheckedChange:n=>{if(!n){g(r,{default:!1});return}N(s=>s.map((c,l)=>({...c,default:l===r})))}}),e.jsx("span",{children:t("defaultAgent")})]}),e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:()=>N(n=>n.filter((s,c)=>c!==r)),children:[e.jsx(ee,{className:"h-4 w-4 mr-1"}),t("remove")]})]})]},`${r}-${a.id}`)),e.jsxs(w,{type:"button",variant:"outline",onClick:()=>N(a=>[...a,fe()]),children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("addAgent")]})]})]}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(k==null?void 0:k.label)??t("bindings")}),e.jsx(D,{children:(k==null?void 0:k.help)??t("bindingsHelp")})]}),e.jsxs(L,{className:"space-y-3",children:[q.map((a,r)=>{var s,c;const n=((s=a.match.peer)==null?void 0:s.kind)??"";return e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsx(i,{value:a.agentId,onChange:l=>T(r,{...a,agentId:l.target.value}),placeholder:t("targetAgentIdPlaceholder")}),e.jsx(i,{value:a.match.channel,onChange:l=>T(r,{...a,match:{...a.match,channel:l.target.value}}),placeholder:t("channelPlaceholder")}),e.jsx(i,{value:a.match.accountId??"",onChange:l=>T(r,{...a,match:{...a.match,accountId:l.target.value}}),placeholder:t("accountIdOptionalPlaceholder")}),e.jsxs(te,{value:n||"__none__",onValueChange:l=>{var m;const o=l==="__none__"?"":l;if(!o){T(r,{...a,match:{...a.match,peer:void 0}});return}T(r,{...a,match:{...a.match,peer:{kind:o,id:((m=a.match.peer)==null?void 0:m.id)??""}}})},children:[e.jsx(re,{children:e.jsx(ne,{})}),e.jsxs(le,{children:[e.jsx(S,{value:"__none__",children:t("peerKindOptional")}),e.jsx(S,{value:"direct",children:"direct"}),e.jsx(S,{value:"group",children:"group"}),e.jsx(S,{value:"channel",children:"channel"})]})]}),e.jsx(i,{value:((c=a.match.peer)==null?void 0:c.id)??"",onChange:l=>T(r,{...a,match:{...a.match,peer:n?{kind:n,id:l.target.value}:void 0}}),placeholder:t("peerIdPlaceholder")})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:()=>E(l=>l.filter((o,m)=>m!==r)),children:[e.jsx(ee,{className:"h-4 w-4 mr-1"}),t("remove")]})})]},`${r}-${a.agentId}`)}),e.jsxs(w,{type:"button",variant:"outline",onClick:()=>E(a=>[...a,ve()]),children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("addBinding")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{type:"button",onClick:ie,disabled:A.isPending,children:[e.jsx(de,{className:"h-4 w-4 mr-2"}),A.isPending?t("saving"):t("saveRuntimeSettings")]})})]})}export{we as RuntimeConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as u,j as e,ax as H,X as L,aL as z,aH as G}from"./vendor-Dj2ULvht.js";import{u as J,y as K,I as h}from"./useConfig-
|
|
1
|
+
import{r as u,j as e,ax as H,X as L,aL as z,aH as G}from"./vendor-Dj2ULvht.js";import{u as J,y as K,I as h}from"./useConfig-CDl9UK5m.js";import{P as Q,a as W,B as _}from"./page-layout-DaLNSFKw.js";import{C as R,b as T,c as M,d as O,a as A}from"./card-CCSDsedj.js";import{L as k}from"./label-BxzAKPzU.js";import{t as a,S as x,a as m,b as p,d as j,e as o}from"./index-CD8a2KMH.js";import{S as Y}from"./switch-DHOCEi5L.js";const U=["env","file","exec"];function y(n=""){return{alias:n,source:"env",prefix:"",path:"",command:"",argsText:"",cwd:"",timeoutMs:5e3}}function Z(){return{path:"",source:"env",provider:"",id:""}}function ee(n,l){return l.source==="env"?{...y(n),source:"env",prefix:l.prefix??""}:l.source==="file"?{...y(n),source:"file",path:l.path}:{...y(n),source:"exec",command:l.command,argsText:(l.args??[]).join(`
|
|
2
2
|
`),cwd:l.cwd??"",timeoutMs:l.timeoutMs??5e3}}function se(n){return n.source==="env"?{source:"env",...n.prefix.trim()?{prefix:n.prefix.trim()}:{}}:n.source==="file"?{source:"file",path:n.path.trim(),format:"json"}:{source:"exec",command:n.command.trim(),args:n.argsText.split(`
|
|
3
3
|
`).map(l=>l.trim()).filter(Boolean),...n.cwd.trim()?{cwd:n.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(n.timeoutMs||5e3))}}function oe(){const{data:n,isLoading:l}=J(),N=K(),[D,P]=u.useState(!0),[I,E]=u.useState(""),[V,S]=u.useState(""),[F,$]=u.useState(""),[C,f]=u.useState([]),[q,v]=u.useState([]);u.useEffect(()=>{const s=n==null?void 0:n.secrets;if(!s){P(!0),E(""),S(""),$(""),f([]),v([]);return}P(!!s.enabled),E(s.defaults.env??""),S(s.defaults.file??""),$(s.defaults.exec??"");const t=Object.entries(s.providers).map(([c,i])=>ee(c,i)),r=Object.entries(s.refs).map(([c,i])=>({path:c,source:i.source,provider:i.provider??"",id:i.id}));f(t),v(r)},[n==null?void 0:n.secrets]);const w=u.useMemo(()=>{const s=C.map(t=>t.alias.trim()).filter(Boolean);return Array.from(new Set(s))},[C]),d=(s,t)=>{f(r=>r.map((c,i)=>i===s?{...c,...t}:c))},b=(s,t)=>{v(r=>r.map((c,i)=>i===s?{...c,...t}:c))},X=()=>{try{const s={};for(const[r,c]of C.entries()){const i=c.alias.trim();if(!i)throw new Error(`${a("providerAlias")} #${r+1} ${a("isRequired")}`);if(s[i])throw new Error(`${a("providerAlias")}: ${i} (${a("duplicate")})`);if(c.source==="file"&&!c.path.trim())throw new Error(`${a("secretFilePath")} #${r+1} ${a("isRequired")}`);if(c.source==="exec"&&!c.command.trim())throw new Error(`${a("secretExecCommand")} #${r+1} ${a("isRequired")}`);s[i]=se(c)}const t={};for(const[r,c]of q.entries()){const i=c.path.trim(),B=c.id.trim();if(!i)throw new Error(`${a("secretConfigPath")} #${r+1} ${a("isRequired")}`);if(!B)throw new Error(`${a("secretId")} #${r+1} ${a("isRequired")}`);const g=c.provider.trim();if(g&&!s[g])throw new Error(`${a("secretProviderAlias")}: ${g} ${a("notFound")}`);t[i]={source:c.source,...g?{provider:g}:{},id:B}}N.mutate({data:{enabled:D,defaults:{env:I.trim()||null,file:V.trim()||null,exec:F.trim()||null},providers:s,refs:t}})}catch(s){const t=s instanceof Error?s.message:String(s);G.error(t)}};return l?e.jsx("div",{className:"p-8 text-gray-400",children:a("loading")}):e.jsxs(Q,{className:"space-y-6",children:[e.jsx(W,{title:a("secretsPageTitle"),description:a("secretsPageDescription")}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secrets")}),e.jsx(O,{children:a("secretsEnabledHelp")})]}),e.jsxs(A,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-200 p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-800",children:a("enabled")}),e.jsx("p",{className:"text-xs text-gray-500",children:a("secretsEnabledHelp")})]}),e.jsx(Y,{checked:D,onCheckedChange:P})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultEnvProvider")}),e.jsxs(x,{value:I||"__none__",onValueChange:s=>E(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultFileProvider")}),e.jsxs(x,{value:V||"__none__",onValueChange:s=>S(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultExecProvider")}),e.jsxs(x,{value:F||"__none__",onValueChange:s=>$(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]})]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretProvidersTitle")}),e.jsx(O,{children:a("secretProvidersDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[C.map((s,t)=>e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsx(h,{value:s.alias,onChange:r=>d(t,{alias:r.target.value}),placeholder:a("providerAlias")}),e.jsxs(x,{value:s.source,onValueChange:r=>d(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:U.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(r=>r.filter((c,i)=>i!==t)),children:[e.jsx(H,{className:"h-4 w-4 mr-2"}),a("removeProvider")]})]}),s.source==="env"&&e.jsx(h,{value:s.prefix,onChange:r=>d(t,{prefix:r.target.value}),placeholder:a("envPrefix")}),s.source==="file"&&e.jsx(h,{value:s.path,onChange:r=>d(t,{path:r.target.value}),placeholder:a("secretFilePath")}),s.source==="exec"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{value:s.command,onChange:r=>d(t,{command:r.target.value}),placeholder:a("secretExecCommand")}),e.jsx("textarea",{className:"min-h-[84px] w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono",value:s.argsText,onChange:r=>d(t,{argsText:r.target.value}),placeholder:a("secretExecArgs")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(h,{value:s.cwd,onChange:r=>d(t,{cwd:r.target.value}),placeholder:a("secretExecCwd")}),e.jsx(h,{type:"number",min:1,value:s.timeoutMs,onChange:r=>d(t,{timeoutMs:Number.parseInt(r.target.value,10)||5e3}),placeholder:a("secretExecTimeoutMs")})]})]})]},`provider-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(s=>[...s,y()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretProvider")]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretRefsTitle")}),e.jsx(O,{children:a("secretRefsDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[q.map((s,t)=>e.jsx("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(h,{value:s.path,onChange:r=>b(t,{path:r.target.value}),placeholder:a("secretConfigPath")}),e.jsx(h,{value:s.id,onChange:r=>b(t,{id:r.target.value}),placeholder:a("secretId")}),e.jsxs(x,{value:s.source,onValueChange:r=>b(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:U.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2",children:[e.jsxs(x,{value:s.provider||"__none__",onValueChange:r=>b(t,{provider:r==="__none__"?"":r}),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("secretProviderAlias")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(r=>e.jsx(o,{value:r,children:r},r))]})]}),e.jsx(_,{type:"button",variant:"outline",onClick:()=>v(r=>r.filter((c,i)=>i!==t)),children:e.jsx(H,{className:"h-4 w-4"})})]})]})},`ref-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>v(s=>[...s,Z()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretRef")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(_,{type:"button",onClick:X,disabled:N.isPending,children:[e.jsx(z,{className:"h-4 w-4 mr-2"}),N.isPending?a("saving"):a("save")]})})]})}export{oe as SecretsConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as l,j as e,ay as T,Y,aM as A,aJ as $,q as J,M as U,aN as W,a0 as G,a1 as X}from"./vendor-Dj2ULvht.js";import{u as Z}from"./useConfirmDialog-
|
|
1
|
+
import{r as l,j as e,ay as T,Y,aM as A,aJ as $,q as J,M as U,aN as W,a0 as G,a1 as X}from"./vendor-Dj2ULvht.js";import{u as Z}from"./useConfirmDialog-D3ZVa92J.js";import{j as ee,l as se,x as te,m as ae,I as S}from"./useConfig-CDl9UK5m.js";import{P as re,a as le,B as g}from"./page-layout-DaLNSFKw.js";import{t,c as o,S as ne,a as ie,b as oe,d as de,e as K,i as ce,g as xe}from"./index-CD8a2KMH.js";import{e as me}from"./chat-message-pw9oafI4.js";const u="__unknown_channel__";function he(a){return xe(a)}function j(a){const n=a.indexOf(":");return n<=0?u:a.slice(0,n).trim()||u}function C(a){return a===u?t("sessionsUnknownChannel"):a}function ge({session:a,channel:n,isSelected:i,onSelect:f}){const r=C(n),y=a.label||a.key.split(":").pop()||a.key;return e.jsxs("button",{onClick:f,className:o("w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group",i?"bg-brand-50 border border-brand-100/50":"bg-transparent border border-transparent hover:bg-gray-50/80"),children:[e.jsxs("div",{className:"flex items-start justify-between mb-1.5",children:[e.jsx("div",{className:o("font-semibold truncate pr-2 flex-1 text-sm",i?"text-brand-800":"text-gray-900"),children:y}),e.jsx("div",{className:o("text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize",i?"bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]":"bg-gray-100 text-gray-500"),children:r})]}),e.jsxs("div",{className:o("flex items-center text-xs justify-between mt-2 font-medium",i?"text-brand-600/80":"text-gray-400"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(W,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{className:"truncate max-w-[100px]",children:ce(a.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(U,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{children:a.messageCount})]})]})]})}function ue({message:a}){const n=a.role.toLowerCase()==="user",i=me(a.content).trim();return e.jsx("div",{className:o("flex w-full mb-6",n?"justify-end":"justify-start"),children:e.jsxs("div",{className:o("max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm",n?"bg-primary text-white rounded-tr-sm":"bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50"),children:[e.jsx("div",{className:"shrink-0 pt-0.5",children:n?e.jsx(G,{className:"w-4 h-4 text-primary-100"}):e.jsx(X,{className:"w-4 h-4 text-gray-400"})}),e.jsxs("div",{className:"flex-1 space-y-1 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4 mb-2",children:[e.jsx("span",{className:o("font-semibold text-xs",n?"text-primary-50":"text-gray-900 capitalize"),children:a.role}),e.jsx("span",{className:o("text-[10px]",n?"text-primary-200":"text-gray-400"),children:he(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[15px]",children:i||"-"})]})]})})}function Ne(){var z,H,E;const[a,n]=l.useState(""),[i]=l.useState(100),[f]=l.useState(0),[r,y]=l.useState(null),[p,B]=l.useState("all"),[M,v]=l.useState(""),[L,N]=l.useState(""),[w,k]=l.useState(!1),q=l.useMemo(()=>({q:a.trim()||void 0,limit:i,activeMinutes:f}),[a,i,f]),h=ee(q),x=se(r,200),b=te(),D=ae(),{confirm:_,ConfirmDialog:F}=Z(),c=l.useMemo(()=>{var s;return((s=h.data)==null?void 0:s.sessions)??[]},[(z=h.data)==null?void 0:z.sessions]),d=l.useMemo(()=>c.find(s=>s.key===r),[c,r]),Q=l.useMemo(()=>{const s=new Set;for(const m of c)s.add(j(m.key));return Array.from(s).sort((m,I)=>m===u?1:I===u?-1:m.localeCompare(I))},[c]),P=l.useMemo(()=>p==="all"?c:c.filter(s=>j(s.key)===p),[c,p]);l.useEffect(()=>{d?(v(d.label||""),N(d.preferredModel||"")):(v(""),N("")),k(!1)},[d]);const O=()=>{r&&(b.mutate({key:r,data:{label:M.trim()||null,preferredModel:L.trim()||null}}),k(!1))},R=async()=>{if(!r)return;await _({title:t("sessionsClearHistory")+"?",variant:"destructive",confirmLabel:t("sessionsClearHistory")})&&b.mutate({key:r,data:{clearHistory:!0}})},V=async()=>{if(!r)return;await _({title:t("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:t("sessionsDeleteConfirm")})&&D.mutate({key:r},{onSuccess:()=>y(null)})};return e.jsxs(re,{fullHeight:!0,children:[e.jsx(le,{title:t("sessionsPageTitle"),description:t("sessionsPageDescription")}),e.jsxs("div",{className:"flex-1 flex gap-6 min-h-0 relative",children:[e.jsxs("div",{className:"w-[320px] flex flex-col shrink-0 bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-4 border-b border-gray-100 bg-white z-10 shrink-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:[c.length," ",t("sessionsListTitle")]}),e.jsx(g,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>h.refetch(),children:e.jsx(T,{className:o("h-3.5 w-3.5",h.isFetching&&"animate-spin")})})]}),e.jsxs(ne,{value:p,onValueChange:B,children:[e.jsx(ie,{className:"w-full h-8.5 rounded-lg bg-gray-50/50 hover:bg-gray-100 border-gray-200 focus:ring-0 shadow-none text-xs font-medium text-gray-700",children:e.jsx(oe,{placeholder:t("sessionsAllChannels")})}),e.jsxs(de,{className:"rounded-xl shadow-lg border-gray-100 max-w-[280px]",children:[e.jsx(K,{value:"all",className:"rounded-lg text-xs",children:t("sessionsAllChannels")}),Q.map(s=>e.jsx(K,{value:s,className:"rounded-lg text-xs truncate pr-6",children:C(s)},s))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(Y,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),e.jsx(S,{value:a,onChange:s=>n(s.target.value),placeholder:t("sessionsSearchPlaceholder"),className:"pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-1 pb-10 custom-scrollbar relative",children:h.isLoading?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("sessionsLoading")}):P.length===0?e.jsxs("div",{className:"text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4",children:[e.jsx(A,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t("sessionsEmpty")]}):P.map(s=>e.jsx(ge,{session:s,channel:j(s.key),isSelected:r===s.key,onSelect:()=>y(s.key)},s.key))})]}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden relative bg-white rounded-2xl shadow-sm border border-gray-200",children:[(b.isPending||D.isPending)&&e.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20",children:e.jsx("div",{className:"h-full bg-primary animate-pulse w-1/3 rounded-r-full"})}),r&&d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-gray-100 bg-white px-8 py-5 z-10 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-[14px] bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-400 shrink-0",children:e.jsx($,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 tracking-tight",children:d.label||d.key.split(":").pop()||d.key}),e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest",children:C(j(d.key))})]}),e.jsx("div",{className:"text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70",title:r,children:r})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>k(!w),className:o("h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold",w?"bg-gray-100 text-gray-900":"hover:bg-gray-50 hover:text-gray-900"),children:[e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),t("sessionsMetadata")]}),e.jsx(g,{variant:"outline",size:"sm",onClick:R,className:"h-8.5 rounded-lg shadow-none hover:bg-gray-50 hover:text-gray-900 border-gray-200 text-xs font-semibold text-gray-500",children:t("sessionsClearHistory")}),e.jsx(g,{variant:"outline",size:"sm",onClick:V,className:"h-8.5 rounded-lg shadow-none hover:bg-red-50 hover:text-red-600 hover:border-red-200 border-gray-200 text-xs font-semibold text-red-500",children:t("delete")})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in",children:[e.jsx(S,{placeholder:t("sessionsLabelPlaceholder"),value:M,onChange:s=>v(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(S,{placeholder:t("sessionsModelPlaceholder"),value:L,onChange:s=>N(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(g,{size:"sm",onClick:O,className:"h-8 px-4 shrink-0 shadow-none",disabled:b.isPending,children:t("sessionsSaveMeta")})]})]}),e.jsxs("div",{className:`flex-1 overflow-y-auto p-6 relative
|
|
2
2
|
[&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-gray-300/80 [&::-webkit-scrollbar-thumb]:rounded-full`,children:[x.isLoading&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-50/50 backdrop-blur-sm z-10",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 animate-pulse",children:[e.jsx(T,{className:"w-6 h-6 text-primary animate-spin"}),e.jsx("span",{className:"text-sm font-medium text-gray-500",children:t("sessionsHistoryLoading")})]})}),x.error&&e.jsx("div",{className:"text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm",children:x.error.message}),!x.isLoading&&((H=x.data)==null?void 0:H.messages.length)===0&&e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(U,{className:"w-12 h-12 mb-3 text-gray-300"}),e.jsx("p",{className:"text-sm",children:t("sessionsEmpty")})]}),e.jsx("div",{className:"max-w-3xl mx-auto",children:(((E=x.data)==null?void 0:E.messages)??[]).map((s,m)=>e.jsx(ue,{message:s},`${s.timestamp}-${m}`))})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-gray-400 p-8 h-full bg-white",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-50 rounded-3xl flex items-center justify-center mb-6 border border-gray-100 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.02)] rotate-3",children:e.jsx(A,{className:"h-8 w-8 text-gray-300 -rotate-3"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:t("sessionsNoSelectionTitle")}),e.jsx("p",{className:"text-sm text-center max-w-sm leading-relaxed",children:t("sessionsNoSelectionDescription")})]})]})]}),e.jsx(F,{})]})}export{Ne as SessionsConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as t}from"./vendor-Dj2ULvht.js";import{c as d}from"./index-
|
|
1
|
+
import{r as s,j as t}from"./vendor-Dj2ULvht.js";import{c as d}from"./index-CD8a2KMH.js";const i=s.forwardRef(({className:a,hover:e=!0,...r},o)=>t.jsx("div",{ref:o,className:d("rounded-2xl border border-gray-200/50 bg-white text-card-foreground shadow-card transition-all duration-base",e&&"hover:shadow-card-hover hover:border-gray-200",a),...r}));i.displayName="Card";const c=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex flex-col space-y-1.5 p-6",a),...e}));c.displayName="CardHeader";const l=s.forwardRef(({className:a,...e},r)=>t.jsx("h3",{ref:r,className:d("text-[15px] font-semibold leading-tight tracking-tight text-gray-900",a),...e}));l.displayName="CardTitle";const n=s.forwardRef(({className:a,...e},r)=>t.jsx("p",{ref:r,className:d("text-[13px] text-gray-400 leading-relaxed",a),...e}));n.displayName="CardDescription";const p=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("p-6 pt-0",a),...e}));p.displayName="CardContent";const x=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex items-center justify-between p-6 pt-0",a),...e}));x.displayName="CardFooter";export{i as C,p as a,c as b,l as c,n as d};
|