nextclaw 0.9.15 → 0.9.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +131 -6
- package/package.json +1 -1
- package/ui-dist/assets/{ChannelsList-DACqpUYZ.js → ChannelsList-DRqUf_f1.js} +1 -1
- package/ui-dist/assets/{ChatPage-iji0RkTR.js → ChatPage-XNOO4MdH.js} +1 -1
- package/ui-dist/assets/{DocBrowser-D7mjKkGe.js → DocBrowser-B_7djIEq.js} +1 -1
- package/ui-dist/assets/{LogoBadge-BlDT-g9R.js → LogoBadge-CEQerLPb.js} +1 -1
- package/ui-dist/assets/{MarketplacePage-CZq3jVgg.js → MarketplacePage-DBzY0jNC.js} +1 -1
- package/ui-dist/assets/{ModelConfig-DwRU5qrw.js → ModelConfig-BIcnKQ9L.js} +1 -1
- package/ui-dist/assets/{ProvidersList-DFxN3pjx.js → ProvidersList-K0TZvjGO.js} +1 -1
- package/ui-dist/assets/{RuntimeConfig-C7BRLGSC.js → RuntimeConfig-DlOB3OyD.js} +1 -1
- package/ui-dist/assets/{SecretsConfig-D5xZh7VF.js → SecretsConfig-Dl7ISZSg.js} +1 -1
- package/ui-dist/assets/{SessionsConfig-ovpj_otA.js → SessionsConfig-BQrPKyRq.js} +1 -1
- package/ui-dist/assets/{card-Bf4CtrW8.js → card-B-c2OgfM.js} +1 -1
- package/ui-dist/assets/{index-dKTqKCJo.js → index-gXBW3ns8.js} +5 -5
- package/ui-dist/assets/{input-CaKJyoWZ.js → input-vcZIRBEV.js} +1 -1
- package/ui-dist/assets/{label-BaXSWTKI.js → label-DZa1Y6BS.js} +1 -1
- package/ui-dist/assets/{page-layout-DA6PFRtQ.js → page-layout-DVoD2FFE.js} +1 -1
- package/ui-dist/assets/{session-run-status-CllIZxNf.js → session-run-status-C0z5CFQq.js} +1 -1
- package/ui-dist/assets/{switch-Cvd5wZs-.js → switch-DNEnGqWo.js} +1 -1
- package/ui-dist/assets/{tabs-custom-0PybLkXs.js → tabs-custom-B7PsWX6R.js} +1 -1
- package/ui-dist/assets/{useConfirmDialog-DdtpSju1.js → useConfirmDialog-PNI-ofd5.js} +1 -1
- package/ui-dist/index.html +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e,aH as Ge,aI as Qe,aB as $e,a0 as ye,a as Ue,d as B,ax as Ie,aJ as Ve,C as Ye,aK as Je,a1 as Xe,K as Ze}from"./vendor-C--HHaLf.js";import{c as te,t,u as Le,a as Te,b as Be,z as es,A as ss,C as ts,E as as,F as rs,G as ns,H as is,S as ls,e as os,f as cs,g as ds,h as us,I as ms}from"./index-dKTqKCJo.js";import{B as k,P as xs,a as hs}from"./page-layout-DA6PFRtQ.js";import{I as R}from"./input-CaKJyoWZ.js";import{L as O}from"./label-BaXSWTKI.js";import{C as ps,a as fs,S as Ke,b as ys,c as gs,L as js}from"./LogoBadge-BlDT-g9R.js";import{h as ee}from"./config-hints-CApS3K_7.js";import{T as bs}from"./tabs-custom-0PybLkXs.js";function vs({maskedValue:s,isSet:r,className:i,value:l,onChange:y,placeholder:w,...g}){const[u,f]=c.useState(!1),[j,b]=c.useState(!1),E=typeof l=="string"&&l.length>0,D=r&&!E&&!j;return e.jsxs("div",{className:"relative",children:[D?e.jsx("div",{onClick:()=>b(!0),className:te("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",i),children:"••••••••••••"}):e.jsx(R,{type:u?"text":"password",className:te("pr-12",i),value:l,onChange:y,onBlur:()=>{E||b(!1)},placeholder:w,autoFocus:j,...g}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(r||E)&&e.jsx(k,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>f(!u),children:u?e.jsx(Ge,{className:"h-4 w-4"}):e.jsx(Qe,{className:"h-4 w-4"})})})]})}function ws({value:s,onChange:r,className:i}){const l=s?Object.entries(s):[],y=(u,f,j)=>{const b=[...l];b[u]=[f,j],r(Object.fromEntries(b))},w=()=>{r({...s,"":""})},g=u=>{const f=l.filter((j,b)=>b!==u);r(Object.fromEntries(f))};return e.jsxs("div",{className:te("space-y-2",i),children:[l.map(([u,f],j)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(R,{type:"text",value:u,onChange:b=>y(j,b.target.value,f),placeholder:t("headerName"),className:"flex-1"}),e.jsx(R,{type:"text",value:f,onChange:b=>y(j,u,b.target.value),placeholder:t("headerValue"),className:"flex-1"}),e.jsx(k,{type:"button",variant:"ghost",size:"icon",onClick:()=>g(j),children:e.jsx($e,{className:"h-4 w-4 text-red-500"})})]},j)),e.jsxs(k,{type:"button",variant:"outline",size:"sm",onClick:w,children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),t("add")]})]})}const Ns={displayName:"",apiKeySet:!1,apiBase:null,extraHeaders:null,wireApi:null,models:[]};function se(s){if(!s)return null;const r=Object.entries(s).map(([i,l])=>[i.trim(),l]).filter(([i])=>i.length>0);return r.length===0?null:Object.fromEntries(r)}function ke(s,r){const i=se(s),l=se(r);if(i===null&&l===null)return!0;if(!i||!l)return!1;const y=Object.entries(i).sort(([g],[u])=>g.localeCompare(u)),w=Object.entries(l).sort(([g],[u])=>g.localeCompare(u));return y.length!==w.length?!1:y.every(([g,u],f)=>g===w[f][0]&&u===w[f][1])}function pe(s){if(!s||s.length===0)return[];const r=new Set;for(const i of s){const l=i.trim();l&&r.add(l)}return[...r]}function Cs(s,r){const i=s.trim();if(!i||!r.trim())return i;const l=`${r.trim()}/`;return i.startsWith(l)?i.slice(l.length):i}function oe(s,r){let i=s.trim();if(!i)return"";for(const l of r){const y=l.trim();y&&(i=Cs(i,y))}return i.trim()}function fe(s,r){return s.length!==r.length?!1:s.every((i,l)=>i===r[l])}function As(s,r){const i=[...s];for(const l of r)i.includes(l)||i.push(l);return i}function Ps(s,r){return r.length===0?s:r.every(l=>!s.includes(l))?As(s,r):r}function Ss(s,r){return fe(s,r)?[]:s}function Es({providerName:s,onProviderDeleted:r}){var Se,Ee,De,Me;const i=Ue(),{data:l}=Le(),{data:y}=Te(),{data:w}=Be(),g=es(),u=ss(),f=ts(),j=as(),b=rs(),E=ns(),[D,Q]=c.useState(""),[z,M]=c.useState(""),[K,U]=c.useState(null),[o,h]=c.useState("auto"),[v,N]=c.useState([]),[$,C]=c.useState(""),[I,_]=c.useState(""),[V,ae]=c.useState(!1),[ce,re]=c.useState(!1),[ne,F]=c.useState(null),[ge,P]=c.useState(""),ie=c.useRef(null),n=y==null?void 0:y.providers.find(a=>a.name===s),S=(s?l==null?void 0:l.providers[s]:null)??Ns,le=w==null?void 0:w.uiHints,H=!!(n!=null&&n.isCustom),W=s?ee(`providers.${s}.apiKey`,le):void 0,L=s?ee(`providers.${s}.apiBase`,le):void 0,de=s?ee(`providers.${s}.extraHeaders`,le):void 0,ue=s?ee(`providers.${s}.wireApi`,le):void 0,je=(n==null?void 0:n.displayName)||s||"",q=(S.displayName||"").trim()||je,Fe=I.trim()||q||s||t("providersSelectPlaceholder"),be=(n==null?void 0:n.modelPrefix)||s||"",G=c.useMemo(()=>pe([be,s||""]),[be,s]),me=(n==null?void 0:n.defaultApiBase)||"",Y=S.apiBase||me,xe=se(S.extraHeaders||null),J=S.wireApi||(n==null?void 0:n.defaultWireApi)||"auto",he=c.useMemo(()=>pe(((n==null?void 0:n.defaultModels)??[]).map(a=>oe(a,G))),[n==null?void 0:n.defaultModels,G]),ve=c.useMemo(()=>pe((S.models??[]).map(a=>oe(a,G))),[S.models,G]),X=c.useMemo(()=>Ps(he,ve),[he,ve]),we=is(),ze=((Se=n==null?void 0:n.apiBaseHelp)==null?void 0:Se[we])||((Ee=n==null?void 0:n.apiBaseHelp)==null?void 0:Ee.en)||(L==null?void 0:L.help)||t("providerApiBaseHelp"),p=n==null?void 0:n.auth,Ne=((De=p==null?void 0:p.note)==null?void 0:De[we])||((Me=p==null?void 0:p.note)==null?void 0:Me.en)||(p==null?void 0:p.displayName)||"",A=c.useCallback(()=>{ie.current!==null&&(window.clearTimeout(ie.current),ie.current=null)},[]),Ce=c.useCallback((a,d)=>{A(),ie.current=window.setTimeout(()=>{(async()=>{if(s)try{const x=await b.mutateAsync({provider:s,data:{sessionId:a}});if(x.status==="pending"){P(t("providerAuthWaitingBrowser")),Ce(a,x.nextPollMs??d);return}if(x.status==="authorized"){F(null),A(),P(t("providerAuthCompleted")),B.success(t("providerAuthCompleted")),i.invalidateQueries({queryKey:["config"]}),i.invalidateQueries({queryKey:["config-meta"]});return}F(null),A(),P(x.message||`Authorization ${x.status}.`),B.error(x.message||`Authorization ${x.status}.`)}catch(x){F(null),A();const m=x instanceof Error?x.message:String(x);P(m),B.error(`Authorization failed: ${m}`)}})()},Math.max(1e3,d))},[A,b,s,i]);c.useEffect(()=>{if(!s){Q(""),M(""),U(null),h("auto"),N([]),C(""),_(""),F(null),P(""),A();return}Q(""),M(Y),U(S.extraHeaders||null),h(J),N(X),C(""),_(q),F(null),P(""),A()},[s,Y,S.extraHeaders,J,X,q,A]),c.useEffect(()=>()=>A(),[A]);const Ae=c.useMemo(()=>{if(!s)return!1;const a=D.trim().length>0,d=z.trim()!==Y.trim(),x=!ke(K,xe),m=n!=null&&n.supportsWireApi?o!==J:!1,T=!fe(v,X),Z=H?I.trim()!==q:!1;return a||d||x||m||T||Z},[s,H,I,q,D,z,Y,K,xe,n==null?void 0:n.supportsWireApi,o,J,v,X]),Pe=()=>{const a=oe($,G);if(a){if(v.includes(a)){C("");return}N(d=>[...d,a]),C("")}},_e=a=>{if(a.preventDefault(),!s)return;const d={},x=D.trim(),m=z.trim(),T=se(K),Z=I.trim();H&&Z!==q&&(d.displayName=Z.length>0?Z:null),x.length>0&&(d.apiKey=x),m!==Y.trim()&&(d.apiBase=m.length>0&&m!==me?m:null),ke(T,xe)||(d.extraHeaders=T),n!=null&&n.supportsWireApi&&o!==J&&(d.wireApi=o),fe(v,X)||(d.models=Ss(v,he)),g.mutate({provider:s,data:d})},Oe=async()=>{if(!s)return;const a=v.find(m=>m.trim().length>0)??"",d=oe(a,G),x={apiBase:z.trim(),extraHeaders:se(K),model:d||null};D.trim().length>0&&(x.apiKey=D.trim()),n!=null&&n.supportsWireApi&&(x.wireApi=o);try{const m=await f.mutateAsync({provider:s,data:x});if(m.success){B.success(`${t("providerTestConnectionSuccess")} (${m.latencyMs}ms)`);return}const T=[`provider=${m.provider}`,`latency=${m.latencyMs}ms`];m.model&&T.push(`model=${m.model}`),B.error(`${t("providerTestConnectionFailed")}: ${m.message} | ${T.join(" | ")}`)}catch(m){const T=m instanceof Error?m.message:String(m);B.error(`${t("providerTestConnectionFailed")}: ${T}`)}},Re=async()=>{if(!(!s||!H||!window.confirm(t("providerDeleteConfirm"))))try{await u.mutateAsync({provider:s}),r==null||r(s)}catch{}},He=async()=>{if(!(!s||(p==null?void 0:p.kind)!=="device_code"))try{P("");const a=await j.mutateAsync({provider:s});if(!a.sessionId||!a.verificationUri)throw new Error(t("providerAuthStartFailed"));F(a.sessionId),P(`${t("providerAuthOpenPrompt")}${a.userCode}${t("providerAuthOpenPromptSuffix")}`),window.open(a.verificationUri,"_blank","noopener,noreferrer"),Ce(a.sessionId,a.intervalMs)}catch(a){const d=a instanceof Error?a.message:String(a);F(null),A(),P(d),B.error(`${t("providerAuthStartFailed")}: ${d}`)}},We=async()=>{if(!(!s||(p==null?void 0:p.kind)!=="device_code"))try{A(),F(null);const a=await E.mutateAsync({provider:s}),d=a.expiresAt?` (expires: ${a.expiresAt})`:"";P(`${t("providerAuthImportStatusPrefix")}${d}`),B.success(t("providerAuthImportSuccess")),i.invalidateQueries({queryKey:["config"]}),i.invalidateQueries({queryKey:["config-meta"]})}catch(a){const d=a instanceof Error?a.message:String(a);P(d),B.error(`${t("providerAuthImportFailed")}: ${d}`)}};if(!s||!n)return e.jsx("div",{className:ps,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 qe=S.apiKeySet?t("statusReady"):t("statusSetup");return e.jsxs("div",{className:fs,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:Fe}),e.jsxs("div",{className:"flex items-center gap-3",children:[H&&e.jsx("button",{type:"button",onClick:Re,disabled:u.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:t("providerDelete"),children:e.jsx($e,{className:"h-4 w-4"})}),e.jsx(Ke,{status:S.apiKeySet?"ready":"setup",label:qe})]})]})}),e.jsxs("form",{onSubmit:_e,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:[H&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:t("providerDisplayName")}),e.jsx(R,{id:"providerDisplayName",type:"text",value:I,onChange:a=>_(a.target.value),placeholder:je||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(O,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(W==null?void 0:W.label)??t("apiKey")}),e.jsx(vs,{id:"apiKey",value:D,isSet:S.apiKeySet,onChange:a=>Q(a.target.value),placeholder:(W==null?void 0:W.placeholder)??t("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("leaveBlankToKeepUnchanged")})]}),(p==null?void 0:p.kind)==="device_code"&&e.jsxs("div",{className:"space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:p.displayName||t("providerAuthSectionTitle")}),Ne?e.jsx("p",{className:"text-xs text-gray-600",children:Ne}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{type:"button",variant:"outline",size:"sm",onClick:He,disabled:j.isPending||!!ne,children:j.isPending?t("providerAuthStarting"):ne?t("providerAuthAuthorizing"):t("providerAuthAuthorizeInBrowser")}),p.supportsCliImport?e.jsx(k,{type:"button",variant:"outline",size:"sm",onClick:We,disabled:E.isPending,children:E.isPending?t("providerAuthImporting"):t("providerAuthImportFromCli")}):null,ne?e.jsxs("span",{className:"text-xs text-gray-500",children:[t("providerAuthSessionLabel"),": ",ne.slice(0,8),"…"]}):null]}),ge?e.jsx("p",{className:"text-xs text-gray-600",children:ge}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(L==null?void 0:L.label)??t("apiBase")}),e.jsx(R,{id:"apiBase",type:"text",value:z,onChange:a=>M(a.target.value),placeholder:me||(L==null?void 0:L.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:ze})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:t("providerModelsTitle")}),!ce&&e.jsxs("button",{type:"button",onClick:()=>re(!0),className:"text-xs text-primary hover:text-primary/80 font-medium flex items-center gap-1",children:[e.jsx(ye,{className:"h-3 w-3"}),t("providerAddModel")]})]}),ce&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{value:$,onChange:a=>C(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),Pe()),a.key==="Escape"&&(re(!1),C(""))},placeholder:t("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(k,{type:"button",size:"sm",onClick:Pe,disabled:$.trim().length===0,children:t("add")}),e.jsx(k,{type:"button",size:"sm",variant:"ghost",onClick:()=>{re(!1),C("")},children:e.jsx(Ie,{className:"h-4 w-4"})})]}),v.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")}),!ce&&e.jsx("button",{type:"button",onClick:()=>re(!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:v.map(a=>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:a}),e.jsx("button",{type:"button",onClick:()=>N(d=>d.filter(x=>x!==a)),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(Ie,{className:"h-3 w-3"})})]},a))})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>ae(!V),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(Ve,{className:"h-3.5 w-3.5"}),t("providerAdvancedSettings")]}),e.jsx(Ye,{className:`h-4 w-4 transition-transform ${V?"rotate-180":""}`})]}),V&&e.jsxs("div",{className:"mt-4 space-y-5",children:[n.supportsWireApi&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:(ue==null?void 0:ue.label)??t("wireApi")}),e.jsxs(ls,{value:o,onValueChange:a=>h(a),children:[e.jsx(os,{className:"rounded-xl",children:e.jsx(cs,{})}),e.jsx(ds,{children:(n.wireApiOptions||["auto","chat","responses"]).map(a=>e.jsx(us,{value:a,children:a==="chat"?t("wireApiChat"):a==="responses"?t("wireApiResponses"):t("wireApiAuto")},a))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:(de==null?void 0:de.label)??t("extraHeaders")}),e.jsx(ws,{value:K,onChange:U}),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(k,{type:"button",variant:"outline",size:"sm",onClick:Oe,disabled:f.isPending,children:[e.jsx(Je,{className:"mr-1.5 h-4 w-4"}),f.isPending?t("providerTestingConnection"):t("providerTestConnection")]}),e.jsx(k,{type:"submit",disabled:g.isPending||!Ae,children:g.isPending?t("saving"):Ae?t("save"):t("unchanged")})]})]})]})}function Ds(s){if(!s)return null;try{const r=new URL(s),i=r.pathname&&r.pathname!=="/"?r.pathname:"";return`${r.host}${i}`}catch{return s.replace(/^https?:\/\//,"")}}function _s(){const{data:s}=Le(),{data:r}=Te(),{data:i}=Be(),l=ms(),[y,w]=c.useState("installed"),[g,u]=c.useState(),[f,j]=c.useState(""),b=i==null?void 0:i.uiHints,E=(r==null?void 0:r.providers)??[],D=(s==null?void 0:s.providers)??{},Q=E.filter(o=>{var h;return(h=D[o.name])==null?void 0:h.apiKeySet}).length,z=[{id:"installed",label:t("providersTabConfigured"),count:Q},{id:"all",label:t("providersTabAll"),count:E.length}],M=c.useMemo(()=>{const o=(r==null?void 0:r.providers)??[],h=(s==null?void 0:s.providers)??{},v=f.trim().toLowerCase();return o.filter(N=>{var $;return y==="installed"?!!(($=h[N.name])!=null&&$.apiKeySet):!0}).filter(N=>{var I,_;return v?(((_=(I=h[N.name])==null?void 0:I.displayName)==null?void 0:_.trim())||N.displayName||N.name).toLowerCase().includes(v)||N.name.toLowerCase().includes(v):!0})},[r,s,y,f]);c.useEffect(()=>{if(M.length===0){u(void 0);return}M.some(h=>h.name===g)||u(M[0].name)},[M,g]);const K=g,U=async()=>{try{const o=await l.mutateAsync({data:{}});w("all"),j(""),u(o.name)}catch{}};return!s||!r?e.jsx("div",{className:"p-8",children:t("providersLoading")}):e.jsxs(xs,{children:[e.jsx(hs,{title:t("providersPageTitle"),description:t("providersPageDescription")}),e.jsxs("div",{className:ys,children:[e.jsxs("section",{className:gs,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(bs,{tabs:z,activeTab:y,onChange:w,className:"mb-0"}),e.jsxs(k,{type:"button",variant:"outline",className:"w-full justify-center",onClick:U,disabled:l.isPending,children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),l.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(Xe,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(R,{value:f,onChange:o=>j(o.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:[M.map(o=>{var ae;const h=s.providers[o.name],v=!!(h!=null&&h.apiKeySet),N=K===o.name,$=((ae=h==null?void 0:h.displayName)==null?void 0:ae.trim())||o.displayName||o.name,C=ee(`providers.${o.name}`,b),I=(h==null?void 0:h.apiBase)||o.defaultApiBase||"",V=Ds(I)||(C==null?void 0:C.help)||t("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>u(o.name),className:te("w-full rounded-xl border p-2.5 text-left transition-all",N?"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(js,{name:o.name,src:o.logo?`/logos/${o.logo}`:null,className:te("h-10 w-10 rounded-lg border",v?"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:o.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:$}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:V})]})]}),e.jsx(Ke,{status:v?"ready":"setup",label:v?t("statusReady"):t("statusSetup"),className:"min-w-[56px] justify-center"})]})},o.name)}),M.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(Ze,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:t("providersNoMatch")})]})]})]}),e.jsx(Es,{providerName:K,onProviderDeleted:o=>{o===g&&u(void 0)}})]})]})}export{_s as ProvidersList};
|
|
1
|
+
import{r as c,j as e,aH as Ge,aI as Qe,aB as $e,a0 as ye,a as Ue,d as B,ax as Ie,aJ as Ve,C as Ye,aK as Je,a1 as Xe,K as Ze}from"./vendor-C--HHaLf.js";import{c as te,t,u as Le,a as Te,b as Be,z as es,A as ss,C as ts,E as as,F as rs,G as ns,H as is,S as ls,e as os,f as cs,g as ds,h as us,I as ms}from"./index-gXBW3ns8.js";import{B as k,P as xs,a as hs}from"./page-layout-DVoD2FFE.js";import{I as R}from"./input-vcZIRBEV.js";import{L as O}from"./label-DZa1Y6BS.js";import{C as ps,a as fs,S as Ke,b as ys,c as gs,L as js}from"./LogoBadge-CEQerLPb.js";import{h as ee}from"./config-hints-CApS3K_7.js";import{T as bs}from"./tabs-custom-B7PsWX6R.js";function vs({maskedValue:s,isSet:r,className:i,value:l,onChange:y,placeholder:w,...g}){const[u,f]=c.useState(!1),[j,b]=c.useState(!1),E=typeof l=="string"&&l.length>0,D=r&&!E&&!j;return e.jsxs("div",{className:"relative",children:[D?e.jsx("div",{onClick:()=>b(!0),className:te("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",i),children:"••••••••••••"}):e.jsx(R,{type:u?"text":"password",className:te("pr-12",i),value:l,onChange:y,onBlur:()=>{E||b(!1)},placeholder:w,autoFocus:j,...g}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(r||E)&&e.jsx(k,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>f(!u),children:u?e.jsx(Ge,{className:"h-4 w-4"}):e.jsx(Qe,{className:"h-4 w-4"})})})]})}function ws({value:s,onChange:r,className:i}){const l=s?Object.entries(s):[],y=(u,f,j)=>{const b=[...l];b[u]=[f,j],r(Object.fromEntries(b))},w=()=>{r({...s,"":""})},g=u=>{const f=l.filter((j,b)=>b!==u);r(Object.fromEntries(f))};return e.jsxs("div",{className:te("space-y-2",i),children:[l.map(([u,f],j)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(R,{type:"text",value:u,onChange:b=>y(j,b.target.value,f),placeholder:t("headerName"),className:"flex-1"}),e.jsx(R,{type:"text",value:f,onChange:b=>y(j,u,b.target.value),placeholder:t("headerValue"),className:"flex-1"}),e.jsx(k,{type:"button",variant:"ghost",size:"icon",onClick:()=>g(j),children:e.jsx($e,{className:"h-4 w-4 text-red-500"})})]},j)),e.jsxs(k,{type:"button",variant:"outline",size:"sm",onClick:w,children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),t("add")]})]})}const Ns={displayName:"",apiKeySet:!1,apiBase:null,extraHeaders:null,wireApi:null,models:[]};function se(s){if(!s)return null;const r=Object.entries(s).map(([i,l])=>[i.trim(),l]).filter(([i])=>i.length>0);return r.length===0?null:Object.fromEntries(r)}function ke(s,r){const i=se(s),l=se(r);if(i===null&&l===null)return!0;if(!i||!l)return!1;const y=Object.entries(i).sort(([g],[u])=>g.localeCompare(u)),w=Object.entries(l).sort(([g],[u])=>g.localeCompare(u));return y.length!==w.length?!1:y.every(([g,u],f)=>g===w[f][0]&&u===w[f][1])}function pe(s){if(!s||s.length===0)return[];const r=new Set;for(const i of s){const l=i.trim();l&&r.add(l)}return[...r]}function Cs(s,r){const i=s.trim();if(!i||!r.trim())return i;const l=`${r.trim()}/`;return i.startsWith(l)?i.slice(l.length):i}function oe(s,r){let i=s.trim();if(!i)return"";for(const l of r){const y=l.trim();y&&(i=Cs(i,y))}return i.trim()}function fe(s,r){return s.length!==r.length?!1:s.every((i,l)=>i===r[l])}function As(s,r){const i=[...s];for(const l of r)i.includes(l)||i.push(l);return i}function Ps(s,r){return r.length===0?s:r.every(l=>!s.includes(l))?As(s,r):r}function Ss(s,r){return fe(s,r)?[]:s}function Es({providerName:s,onProviderDeleted:r}){var Se,Ee,De,Me;const i=Ue(),{data:l}=Le(),{data:y}=Te(),{data:w}=Be(),g=es(),u=ss(),f=ts(),j=as(),b=rs(),E=ns(),[D,Q]=c.useState(""),[z,M]=c.useState(""),[K,U]=c.useState(null),[o,h]=c.useState("auto"),[v,N]=c.useState([]),[$,C]=c.useState(""),[I,_]=c.useState(""),[V,ae]=c.useState(!1),[ce,re]=c.useState(!1),[ne,F]=c.useState(null),[ge,P]=c.useState(""),ie=c.useRef(null),n=y==null?void 0:y.providers.find(a=>a.name===s),S=(s?l==null?void 0:l.providers[s]:null)??Ns,le=w==null?void 0:w.uiHints,H=!!(n!=null&&n.isCustom),W=s?ee(`providers.${s}.apiKey`,le):void 0,L=s?ee(`providers.${s}.apiBase`,le):void 0,de=s?ee(`providers.${s}.extraHeaders`,le):void 0,ue=s?ee(`providers.${s}.wireApi`,le):void 0,je=(n==null?void 0:n.displayName)||s||"",q=(S.displayName||"").trim()||je,Fe=I.trim()||q||s||t("providersSelectPlaceholder"),be=(n==null?void 0:n.modelPrefix)||s||"",G=c.useMemo(()=>pe([be,s||""]),[be,s]),me=(n==null?void 0:n.defaultApiBase)||"",Y=S.apiBase||me,xe=se(S.extraHeaders||null),J=S.wireApi||(n==null?void 0:n.defaultWireApi)||"auto",he=c.useMemo(()=>pe(((n==null?void 0:n.defaultModels)??[]).map(a=>oe(a,G))),[n==null?void 0:n.defaultModels,G]),ve=c.useMemo(()=>pe((S.models??[]).map(a=>oe(a,G))),[S.models,G]),X=c.useMemo(()=>Ps(he,ve),[he,ve]),we=is(),ze=((Se=n==null?void 0:n.apiBaseHelp)==null?void 0:Se[we])||((Ee=n==null?void 0:n.apiBaseHelp)==null?void 0:Ee.en)||(L==null?void 0:L.help)||t("providerApiBaseHelp"),p=n==null?void 0:n.auth,Ne=((De=p==null?void 0:p.note)==null?void 0:De[we])||((Me=p==null?void 0:p.note)==null?void 0:Me.en)||(p==null?void 0:p.displayName)||"",A=c.useCallback(()=>{ie.current!==null&&(window.clearTimeout(ie.current),ie.current=null)},[]),Ce=c.useCallback((a,d)=>{A(),ie.current=window.setTimeout(()=>{(async()=>{if(s)try{const x=await b.mutateAsync({provider:s,data:{sessionId:a}});if(x.status==="pending"){P(t("providerAuthWaitingBrowser")),Ce(a,x.nextPollMs??d);return}if(x.status==="authorized"){F(null),A(),P(t("providerAuthCompleted")),B.success(t("providerAuthCompleted")),i.invalidateQueries({queryKey:["config"]}),i.invalidateQueries({queryKey:["config-meta"]});return}F(null),A(),P(x.message||`Authorization ${x.status}.`),B.error(x.message||`Authorization ${x.status}.`)}catch(x){F(null),A();const m=x instanceof Error?x.message:String(x);P(m),B.error(`Authorization failed: ${m}`)}})()},Math.max(1e3,d))},[A,b,s,i]);c.useEffect(()=>{if(!s){Q(""),M(""),U(null),h("auto"),N([]),C(""),_(""),F(null),P(""),A();return}Q(""),M(Y),U(S.extraHeaders||null),h(J),N(X),C(""),_(q),F(null),P(""),A()},[s,Y,S.extraHeaders,J,X,q,A]),c.useEffect(()=>()=>A(),[A]);const Ae=c.useMemo(()=>{if(!s)return!1;const a=D.trim().length>0,d=z.trim()!==Y.trim(),x=!ke(K,xe),m=n!=null&&n.supportsWireApi?o!==J:!1,T=!fe(v,X),Z=H?I.trim()!==q:!1;return a||d||x||m||T||Z},[s,H,I,q,D,z,Y,K,xe,n==null?void 0:n.supportsWireApi,o,J,v,X]),Pe=()=>{const a=oe($,G);if(a){if(v.includes(a)){C("");return}N(d=>[...d,a]),C("")}},_e=a=>{if(a.preventDefault(),!s)return;const d={},x=D.trim(),m=z.trim(),T=se(K),Z=I.trim();H&&Z!==q&&(d.displayName=Z.length>0?Z:null),x.length>0&&(d.apiKey=x),m!==Y.trim()&&(d.apiBase=m.length>0&&m!==me?m:null),ke(T,xe)||(d.extraHeaders=T),n!=null&&n.supportsWireApi&&o!==J&&(d.wireApi=o),fe(v,X)||(d.models=Ss(v,he)),g.mutate({provider:s,data:d})},Oe=async()=>{if(!s)return;const a=v.find(m=>m.trim().length>0)??"",d=oe(a,G),x={apiBase:z.trim(),extraHeaders:se(K),model:d||null};D.trim().length>0&&(x.apiKey=D.trim()),n!=null&&n.supportsWireApi&&(x.wireApi=o);try{const m=await f.mutateAsync({provider:s,data:x});if(m.success){B.success(`${t("providerTestConnectionSuccess")} (${m.latencyMs}ms)`);return}const T=[`provider=${m.provider}`,`latency=${m.latencyMs}ms`];m.model&&T.push(`model=${m.model}`),B.error(`${t("providerTestConnectionFailed")}: ${m.message} | ${T.join(" | ")}`)}catch(m){const T=m instanceof Error?m.message:String(m);B.error(`${t("providerTestConnectionFailed")}: ${T}`)}},Re=async()=>{if(!(!s||!H||!window.confirm(t("providerDeleteConfirm"))))try{await u.mutateAsync({provider:s}),r==null||r(s)}catch{}},He=async()=>{if(!(!s||(p==null?void 0:p.kind)!=="device_code"))try{P("");const a=await j.mutateAsync({provider:s});if(!a.sessionId||!a.verificationUri)throw new Error(t("providerAuthStartFailed"));F(a.sessionId),P(`${t("providerAuthOpenPrompt")}${a.userCode}${t("providerAuthOpenPromptSuffix")}`),window.open(a.verificationUri,"_blank","noopener,noreferrer"),Ce(a.sessionId,a.intervalMs)}catch(a){const d=a instanceof Error?a.message:String(a);F(null),A(),P(d),B.error(`${t("providerAuthStartFailed")}: ${d}`)}},We=async()=>{if(!(!s||(p==null?void 0:p.kind)!=="device_code"))try{A(),F(null);const a=await E.mutateAsync({provider:s}),d=a.expiresAt?` (expires: ${a.expiresAt})`:"";P(`${t("providerAuthImportStatusPrefix")}${d}`),B.success(t("providerAuthImportSuccess")),i.invalidateQueries({queryKey:["config"]}),i.invalidateQueries({queryKey:["config-meta"]})}catch(a){const d=a instanceof Error?a.message:String(a);P(d),B.error(`${t("providerAuthImportFailed")}: ${d}`)}};if(!s||!n)return e.jsx("div",{className:ps,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 qe=S.apiKeySet?t("statusReady"):t("statusSetup");return e.jsxs("div",{className:fs,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:Fe}),e.jsxs("div",{className:"flex items-center gap-3",children:[H&&e.jsx("button",{type:"button",onClick:Re,disabled:u.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:t("providerDelete"),children:e.jsx($e,{className:"h-4 w-4"})}),e.jsx(Ke,{status:S.apiKeySet?"ready":"setup",label:qe})]})]})}),e.jsxs("form",{onSubmit:_e,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:[H&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:t("providerDisplayName")}),e.jsx(R,{id:"providerDisplayName",type:"text",value:I,onChange:a=>_(a.target.value),placeholder:je||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(O,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(W==null?void 0:W.label)??t("apiKey")}),e.jsx(vs,{id:"apiKey",value:D,isSet:S.apiKeySet,onChange:a=>Q(a.target.value),placeholder:(W==null?void 0:W.placeholder)??t("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:t("leaveBlankToKeepUnchanged")})]}),(p==null?void 0:p.kind)==="device_code"&&e.jsxs("div",{className:"space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:p.displayName||t("providerAuthSectionTitle")}),Ne?e.jsx("p",{className:"text-xs text-gray-600",children:Ne}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{type:"button",variant:"outline",size:"sm",onClick:He,disabled:j.isPending||!!ne,children:j.isPending?t("providerAuthStarting"):ne?t("providerAuthAuthorizing"):t("providerAuthAuthorizeInBrowser")}),p.supportsCliImport?e.jsx(k,{type:"button",variant:"outline",size:"sm",onClick:We,disabled:E.isPending,children:E.isPending?t("providerAuthImporting"):t("providerAuthImportFromCli")}):null,ne?e.jsxs("span",{className:"text-xs text-gray-500",children:[t("providerAuthSessionLabel"),": ",ne.slice(0,8),"…"]}):null]}),ge?e.jsx("p",{className:"text-xs text-gray-600",children:ge}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(L==null?void 0:L.label)??t("apiBase")}),e.jsx(R,{id:"apiBase",type:"text",value:z,onChange:a=>M(a.target.value),placeholder:me||(L==null?void 0:L.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:ze})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:t("providerModelsTitle")}),!ce&&e.jsxs("button",{type:"button",onClick:()=>re(!0),className:"text-xs text-primary hover:text-primary/80 font-medium flex items-center gap-1",children:[e.jsx(ye,{className:"h-3 w-3"}),t("providerAddModel")]})]}),ce&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{value:$,onChange:a=>C(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),Pe()),a.key==="Escape"&&(re(!1),C(""))},placeholder:t("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(k,{type:"button",size:"sm",onClick:Pe,disabled:$.trim().length===0,children:t("add")}),e.jsx(k,{type:"button",size:"sm",variant:"ghost",onClick:()=>{re(!1),C("")},children:e.jsx(Ie,{className:"h-4 w-4"})})]}),v.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")}),!ce&&e.jsx("button",{type:"button",onClick:()=>re(!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:v.map(a=>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:a}),e.jsx("button",{type:"button",onClick:()=>N(d=>d.filter(x=>x!==a)),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(Ie,{className:"h-3 w-3"})})]},a))})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>ae(!V),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(Ve,{className:"h-3.5 w-3.5"}),t("providerAdvancedSettings")]}),e.jsx(Ye,{className:`h-4 w-4 transition-transform ${V?"rotate-180":""}`})]}),V&&e.jsxs("div",{className:"mt-4 space-y-5",children:[n.supportsWireApi&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:(ue==null?void 0:ue.label)??t("wireApi")}),e.jsxs(ls,{value:o,onValueChange:a=>h(a),children:[e.jsx(os,{className:"rounded-xl",children:e.jsx(cs,{})}),e.jsx(ds,{children:(n.wireApiOptions||["auto","chat","responses"]).map(a=>e.jsx(us,{value:a,children:a==="chat"?t("wireApiChat"):a==="responses"?t("wireApiResponses"):t("wireApiAuto")},a))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:(de==null?void 0:de.label)??t("extraHeaders")}),e.jsx(ws,{value:K,onChange:U}),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(k,{type:"button",variant:"outline",size:"sm",onClick:Oe,disabled:f.isPending,children:[e.jsx(Je,{className:"mr-1.5 h-4 w-4"}),f.isPending?t("providerTestingConnection"):t("providerTestConnection")]}),e.jsx(k,{type:"submit",disabled:g.isPending||!Ae,children:g.isPending?t("saving"):Ae?t("save"):t("unchanged")})]})]})]})}function Ds(s){if(!s)return null;try{const r=new URL(s),i=r.pathname&&r.pathname!=="/"?r.pathname:"";return`${r.host}${i}`}catch{return s.replace(/^https?:\/\//,"")}}function _s(){const{data:s}=Le(),{data:r}=Te(),{data:i}=Be(),l=ms(),[y,w]=c.useState("installed"),[g,u]=c.useState(),[f,j]=c.useState(""),b=i==null?void 0:i.uiHints,E=(r==null?void 0:r.providers)??[],D=(s==null?void 0:s.providers)??{},Q=E.filter(o=>{var h;return(h=D[o.name])==null?void 0:h.apiKeySet}).length,z=[{id:"installed",label:t("providersTabConfigured"),count:Q},{id:"all",label:t("providersTabAll"),count:E.length}],M=c.useMemo(()=>{const o=(r==null?void 0:r.providers)??[],h=(s==null?void 0:s.providers)??{},v=f.trim().toLowerCase();return o.filter(N=>{var $;return y==="installed"?!!(($=h[N.name])!=null&&$.apiKeySet):!0}).filter(N=>{var I,_;return v?(((_=(I=h[N.name])==null?void 0:I.displayName)==null?void 0:_.trim())||N.displayName||N.name).toLowerCase().includes(v)||N.name.toLowerCase().includes(v):!0})},[r,s,y,f]);c.useEffect(()=>{if(M.length===0){u(void 0);return}M.some(h=>h.name===g)||u(M[0].name)},[M,g]);const K=g,U=async()=>{try{const o=await l.mutateAsync({data:{}});w("all"),j(""),u(o.name)}catch{}};return!s||!r?e.jsx("div",{className:"p-8",children:t("providersLoading")}):e.jsxs(xs,{children:[e.jsx(hs,{title:t("providersPageTitle"),description:t("providersPageDescription")}),e.jsxs("div",{className:ys,children:[e.jsxs("section",{className:gs,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(bs,{tabs:z,activeTab:y,onChange:w,className:"mb-0"}),e.jsxs(k,{type:"button",variant:"outline",className:"w-full justify-center",onClick:U,disabled:l.isPending,children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),l.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(Xe,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(R,{value:f,onChange:o=>j(o.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:[M.map(o=>{var ae;const h=s.providers[o.name],v=!!(h!=null&&h.apiKeySet),N=K===o.name,$=((ae=h==null?void 0:h.displayName)==null?void 0:ae.trim())||o.displayName||o.name,C=ee(`providers.${o.name}`,b),I=(h==null?void 0:h.apiBase)||o.defaultApiBase||"",V=Ds(I)||(C==null?void 0:C.help)||t("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>u(o.name),className:te("w-full rounded-xl border p-2.5 text-left transition-all",N?"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(js,{name:o.name,src:o.logo?`/logos/${o.logo}`:null,className:te("h-10 w-10 rounded-lg border",v?"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:o.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:$}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:V})]})]}),e.jsx(Ke,{status:v?"ready":"setup",label:v?t("statusReady"):t("statusSetup"),className:"min-w-[56px] justify-center"})]})},o.name)}),M.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(Ze,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:t("providersNoMatch")})]})]})]}),e.jsx(Es,{providerName:K,onProviderDeleted:o=>{o===g&&u(void 0)}})]})]})}export{_s as ProvidersList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as e,aB as ee,a0 as ae,aO as de,d as se}from"./vendor-C--HHaLf.js";import{u as me,b as he,M as ue,t,S as te,e as re,f as ne,g as le,h as S}from"./index-
|
|
1
|
+
import{r as p,j as e,aB as ee,a0 as ae,aO as de,d as se}from"./vendor-C--HHaLf.js";import{u as me,b as he,M as ue,t,S as te,e as re,f as ne,g as le,h as S}from"./index-gXBW3ns8.js";import{P as pe,a as xe,B as w}from"./page-layout-DVoD2FFE.js";import{C as R,b as $,c as z,d as D,a as L}from"./card-B-c2OgfM.js";import{I as i}from"./input-vcZIRBEV.js";import{S as ge}from"./switch-DNEnGqWo.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 Se(){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),[G,J]=p.useState(2e5),[Q,W]=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),J(d.agents.defaults.contextTokens??2e5),W(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 X,Y,Z,H;const l=s.agentId.trim(),o=s.match.channel.trim(),m=((X=s.match.accountId)==null?void 0:X.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,G),engine:Q.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:G,onChange:a=>J(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:Q,onChange:a=>W(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{Se as RuntimeConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as u,j as e,aB as H,a0 as L,aO as G,d as J}from"./vendor-C--HHaLf.js";import{u as K,P as Q,t as a,S as x,e as m,f as p,g as j,h as o}from"./index-
|
|
1
|
+
import{r as u,j as e,aB as H,a0 as L,aO as G,d as J}from"./vendor-C--HHaLf.js";import{u as K,P as Q,t as a,S as x,e as m,f as p,g as j,h as o}from"./index-gXBW3ns8.js";import{P as W,a as X,B as _}from"./page-layout-DVoD2FFE.js";import{C as R,b as T,c as M,d as O,a as A}from"./card-B-c2OgfM.js";import{I as h}from"./input-vcZIRBEV.js";import{L as k}from"./label-DZa1Y6BS.js";import{S as Y}from"./switch-DNEnGqWo.js";const U=["env","file","exec"];function b(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"?{...b(n),source:"env",prefix:l.prefix??""}:l.source==="file"?{...b(n),source:"file",path:l.path}:{...b(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}=K(),N=Q(),[D,y]=u.useState(!0),[I,E]=u.useState(""),[V,S]=u.useState(""),[B,$]=u.useState(""),[C,f]=u.useState([]),[F,v]=u.useState([]);u.useEffect(()=>{const s=n==null?void 0:n.secrets;if(!s){y(!0),E(""),S(""),$(""),f([]),v([]);return}y(!!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))},P=(s,t)=>{v(r=>r.map((c,i)=>i===s?{...c,...t}:c))},z=()=>{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 F.entries()){const i=c.path.trim(),q=c.id.trim();if(!i)throw new Error(`${a("secretConfigPath")} #${r+1} ${a("isRequired")}`);if(!q)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:q}}N.mutate({data:{enabled:D,defaults:{env:I.trim()||null,file:V.trim()||null,exec:B.trim()||null},providers:s,refs:t}})}catch(s){const t=s instanceof Error?s.message:String(s);J.error(t)}};return l?e.jsx("div",{className:"p-8 text-gray-400",children:a("loading")}):e.jsxs(W,{className:"space-y-6",children:[e.jsx(X,{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:y})]}),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:B||"__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,b()]),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:[F.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=>P(t,{path:r.target.value}),placeholder:a("secretConfigPath")}),e.jsx(h,{value:s.id,onChange:r=>P(t,{id:r.target.value}),placeholder:a("secretId")}),e.jsxs(x,{value:s.source,onValueChange:r=>P(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=>P(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:z,disabled:N.isPending,children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),N.isPending?a("saving"):a("save")]})})]})}export{oe as SecretsConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r,j as e,aC as I,a1 as J,aP as T,aM as X,w as Z,M as U,aQ as ee,a4 as se,a5 as te}from"./vendor-C--HHaLf.js";import{u as ae}from"./useConfirmDialog-
|
|
1
|
+
import{r,j as e,aC as I,a1 as J,aP as T,aM as X,w as Z,M as U,aQ as ee,a4 as se,a5 as te}from"./vendor-C--HHaLf.js";import{u as ae}from"./useConfirmDialog-PNI-ofd5.js";import{r as re,y as ne,w as le,N as ie,x as oe,t,c as i,S as de,e as ce,f as xe,g as me,h as Q,O as ue,k as he}from"./index-gXBW3ns8.js";import{P as ge,a as fe,B as f}from"./page-layout-DVoD2FFE.js";import{I as k}from"./input-vcZIRBEV.js";import{d as ye,f as pe,S as be,e as je}from"./session-run-status-C0z5CFQq.js";const y="__unknown_channel__";function ve(a){return he(a)}function j(a){const l=a.indexOf(":");return l<=0?y:a.slice(0,l).trim()||y}function C(a){return a===y?t("sessionsUnknownChannel"):a}function Ne({session:a,channel:l,runStatus:d,isSelected:x,onSelect:n}){const p=C(l),m=a.label||a.key.split(":").pop()||a.key;return e.jsxs("button",{onClick:n,className:i("w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group",x?"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:i("font-semibold truncate pr-2 flex-1 text-sm",x?"text-brand-800":"text-gray-900"),children:m}),e.jsx("div",{className:i("text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize",x?"bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]":"bg-gray-100 text-gray-500"),children:p})]}),e.jsxs("div",{className:i("flex items-center text-xs justify-between mt-2 font-medium",x?"text-brand-600/80":"text-gray-400"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:d?e.jsx(be,{status:d}):null}),e.jsx(ee,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{className:"truncate max-w-[100px]",children:ue(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 we({message:a}){const l=a.role.toLowerCase()==="user",d=je(a.content).trim();return e.jsx("div",{className:i("flex w-full mb-6",l?"justify-end":"justify-start"),children:e.jsxs("div",{className:i("max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm",l?"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:l?e.jsx(se,{className:"w-4 h-4 text-primary-100"}):e.jsx(te,{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:i("font-semibold text-xs",l?"text-primary-50":"text-gray-900 capitalize"),children:a.role}),e.jsx("span",{className:i("text-[10px]",l?"text-primary-200":"text-gray-400"),children:ve(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[15px]",children:d||"-"})]})]})})}function _e(){var B,E,K,R;const[a,l]=r.useState(""),[d]=r.useState(100),[x]=r.useState(0),[n,p]=r.useState(null),[m,q]=r.useState("all"),[M,v]=r.useState(""),[L,N]=r.useState(""),[w,S]=r.useState(!1),F=r.useMemo(()=>({q:a.trim()||void 0,limit:d,activeMinutes:x}),[a,d,x]),g=re(F),D=ne({states:["queued","running"],limit:200}),u=le(n,200),b=ie(),_=oe(),{confirm:P,ConfirmDialog:O}=ae(),c=r.useMemo(()=>{var s;return((s=g.data)==null?void 0:s.sessions)??[]},[(B=g.data)==null?void 0:B.sessions]),z=r.useMemo(()=>{var s;return ye(((s=D.data)==null?void 0:s.runs)??[])},[(E=D.data)==null?void 0:E.runs]),V=r.useMemo(()=>pe(z),[z]),o=r.useMemo(()=>c.find(s=>s.key===n),[c,n]),$=r.useMemo(()=>{const s=new Set;for(const h of c)s.add(j(h.key));return Array.from(s).sort((h,A)=>h===y?1:A===y?-1:h.localeCompare(A))},[c]),H=r.useMemo(()=>m==="all"?c:c.filter(s=>j(s.key)===m),[c,m]);r.useEffect(()=>{o?(v(o.label||""),N(o.preferredModel||"")):(v(""),N("")),S(!1)},[o]);const W=()=>{n&&(b.mutate({key:n,data:{label:M.trim()||null,preferredModel:L.trim()||null}}),S(!1))},Y=async()=>{if(!n)return;await P({title:t("sessionsClearHistory")+"?",variant:"destructive",confirmLabel:t("sessionsClearHistory")})&&b.mutate({key:n,data:{clearHistory:!0}})},G=async()=>{if(!n)return;await P({title:t("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:t("sessionsDeleteConfirm")})&&_.mutate({key:n},{onSuccess:()=>p(null)})};return e.jsxs(ge,{fullHeight:!0,children:[e.jsx(fe,{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(f,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>g.refetch(),children:e.jsx(I,{className:i("h-3.5 w-3.5",g.isFetching&&"animate-spin")})})]}),e.jsxs(de,{value:m,onValueChange:q,children:[e.jsx(ce,{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(xe,{placeholder:t("sessionsAllChannels")})}),e.jsxs(me,{className:"rounded-xl shadow-lg border-gray-100 max-w-[280px]",children:[e.jsx(Q,{value:"all",className:"rounded-lg text-xs",children:t("sessionsAllChannels")}),$.map(s=>e.jsx(Q,{value:s,className:"rounded-lg text-xs truncate pr-6",children:C(s)},s))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(J,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),e.jsx(k,{value:a,onChange:s=>l(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:g.isLoading?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("sessionsLoading")}):H.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(T,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t("sessionsEmpty")]}):H.map(s=>e.jsx(Ne,{session:s,channel:j(s.key),runStatus:V.get(s.key),isSelected:n===s.key,onSelect:()=>p(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||_.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"})}),n&&o?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(X,{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:o.label||o.key.split(":").pop()||o.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(o.key))})]}),e.jsx("div",{className:"text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70",title:n,children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>S(!w),className:i("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(Z,{className:"w-3.5 h-3.5 mr-1.5"}),t("sessionsMetadata")]}),e.jsx(f,{variant:"outline",size:"sm",onClick:Y,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(f,{variant:"outline",size:"sm",onClick:G,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(k,{placeholder:t("sessionsLabelPlaceholder"),value:M,onChange:s=>v(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(k,{placeholder:t("sessionsModelPlaceholder"),value:L,onChange:s=>N(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(f,{size:"sm",onClick:W,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:[u.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(I,{className:"w-6 h-6 text-primary animate-spin"}),e.jsx("span",{className:"text-sm font-medium text-gray-500",children:t("sessionsHistoryLoading")})]})}),u.error&&e.jsx("div",{className:"text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm",children:u.error.message}),!u.isLoading&&((K=u.data)==null?void 0:K.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:(((R=u.data)==null?void 0:R.messages)??[]).map((s,h)=>e.jsx(we,{message:s},`${s.timestamp}-${h}`))})]})]}):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(T,{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(O,{})]})}export{_e as SessionsConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as t}from"./vendor-C--HHaLf.js";import{c as d}from"./index-
|
|
1
|
+
import{r as s,j as t}from"./vendor-C--HHaLf.js";import{c as d}from"./index-gXBW3ns8.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};
|