@truefoundry/trueforge 0.1.3 → 0.1.4
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/_frontend/assets/{ConnectorSettings-EYOQ72OS-DdSqeM08.js → ConnectorSettings-ODC3LVHN-CAU9MgGN.js} +1 -1
- package/dist/_frontend/assets/ConnectorSettings-ODC3LVHN-CAU9MgGN.js.br +0 -0
- package/dist/_frontend/assets/ConnectorSettings-ODC3LVHN-CAU9MgGN.js.gz +0 -0
- package/dist/_frontend/assets/{DockLayout-XIOJZ2YM-htVfvSLo.js → DockLayout-2RWDSUKE-eKoTN8R3.js} +1 -1
- package/dist/_frontend/assets/{DrawerLayout-CNKNNVI7-CQ7wZgB6.js → DrawerLayout-CZLJYMIN-DWPAdLZz.js} +2 -2
- package/dist/_frontend/assets/DrawerLayout-CZLJYMIN-DWPAdLZz.js.br +0 -0
- package/dist/_frontend/assets/DrawerLayout-CZLJYMIN-DWPAdLZz.js.gz +0 -0
- package/dist/_frontend/assets/{ModelSettings-WBDPLI6O-CYfqXYXo.js → ModelSettings-CKQ5CVAC-UBz_ch6T.js} +1 -1
- package/dist/_frontend/assets/ModelSettings-CKQ5CVAC-UBz_ch6T.js.br +0 -0
- package/dist/_frontend/assets/ModelSettings-CKQ5CVAC-UBz_ch6T.js.gz +0 -0
- package/dist/_frontend/assets/{SandboxSettings-4GHBXULN-BPT3vPku.js → SandboxSettings-HSCPYUOC-Csl-nC9h.js} +1 -1
- package/dist/_frontend/assets/SandboxSettings-HSCPYUOC-Csl-nC9h.js.br +0 -0
- package/dist/_frontend/assets/SandboxSettings-HSCPYUOC-Csl-nC9h.js.gz +0 -0
- package/dist/_frontend/assets/SettingsBuilder-MYWRFXRI-Ce3OWfa1.js +2 -0
- package/dist/_frontend/assets/SettingsBuilder-MYWRFXRI-Ce3OWfa1.js.br +0 -0
- package/dist/_frontend/assets/SettingsBuilder-MYWRFXRI-Ce3OWfa1.js.gz +0 -0
- package/dist/_frontend/assets/{ShellRouteSync-T4WLY57Q-BKbLAZEv.js → ShellRouteSync-T4WLY57Q-B5lyCu4o.js} +1 -1
- package/dist/_frontend/assets/ShellRouteSync-T4WLY57Q-B5lyCu4o.js.br +0 -0
- package/dist/_frontend/assets/ShellRouteSync-T4WLY57Q-B5lyCu4o.js.gz +0 -0
- package/dist/_frontend/assets/{SidebarLayout-JGLTENB3-BiZz45he.js → SidebarLayout-WVY54TGZ-CIx5jQIC.js} +2 -2
- package/dist/_frontend/assets/SidebarLayout-WVY54TGZ-CIx5jQIC.js.br +0 -0
- package/dist/_frontend/assets/SidebarLayout-WVY54TGZ-CIx5jQIC.js.gz +0 -0
- package/dist/_frontend/assets/{SkillSettings-UG6USX4N-DhQTOueg.js → SkillSettings-ECH6SHZ7-CKWEzdO_.js} +1 -1
- package/dist/_frontend/assets/SkillSettings-ECH6SHZ7-CKWEzdO_.js.br +0 -0
- package/dist/_frontend/assets/SkillSettings-ECH6SHZ7-CKWEzdO_.js.gz +0 -0
- package/dist/_frontend/assets/{TrueForgeUIWithRouter-CTC5XRSY-BnWelV-R.js → TrueForgeUIWithRouter-RKZ2E7PV-CoVbEgto.js} +1 -1
- package/dist/_frontend/assets/{WidgetLayout-6P6OUUTG-B1G5uZ4_.js → WidgetLayout-NWWB2SXI-cUmY1p2v.js} +1 -1
- package/dist/_frontend/assets/WidgetLayout-NWWB2SXI-cUmY1p2v.js.br +0 -0
- package/dist/_frontend/assets/WidgetLayout-NWWB2SXI-cUmY1p2v.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-62JRHF6Z-yJ2twjOf.js → chunk-62JRHF6Z-BftTGWZl.js} +1 -1
- package/dist/_frontend/assets/chunk-62JRHF6Z-BftTGWZl.js.br +0 -0
- package/dist/_frontend/assets/chunk-62JRHF6Z-BftTGWZl.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-27MKI3HF-CVw53aeu.js → chunk-OZTNBS6V-CLmmFX7d.js} +1 -1
- package/dist/_frontend/assets/chunk-OZTNBS6V-CLmmFX7d.js.br +0 -0
- package/dist/_frontend/assets/chunk-OZTNBS6V-CLmmFX7d.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-H75C5ETA-CX-fQN0e.js → chunk-TCAVLWYL-DVhtkE3q.js} +2 -2
- package/dist/_frontend/assets/chunk-TCAVLWYL-DVhtkE3q.js.br +0 -0
- package/dist/_frontend/assets/chunk-TCAVLWYL-DVhtkE3q.js.gz +0 -0
- package/dist/_frontend/assets/{cssMode-CEpMXY8Z.js → cssMode-CvKwYh_L.js} +1 -1
- package/dist/_frontend/assets/cssMode-CvKwYh_L.js.br +0 -0
- package/dist/_frontend/assets/cssMode-CvKwYh_L.js.gz +0 -0
- package/dist/_frontend/assets/{freemarker2-cQSgojlC.js → freemarker2-Bb2yOpT3.js} +1 -1
- package/dist/_frontend/assets/freemarker2-Bb2yOpT3.js.br +0 -0
- package/dist/_frontend/assets/freemarker2-Bb2yOpT3.js.gz +0 -0
- package/dist/_frontend/assets/{handlebars-BQ-clQ7_.js → handlebars-FL3wsxe0.js} +1 -1
- package/dist/_frontend/assets/handlebars-FL3wsxe0.js.br +0 -0
- package/dist/_frontend/assets/handlebars-FL3wsxe0.js.gz +0 -0
- package/dist/_frontend/assets/{html-ChfWgJt-.js → html-Cb3v_ZRD.js} +1 -1
- package/dist/_frontend/assets/html-Cb3v_ZRD.js.br +0 -0
- package/dist/_frontend/assets/html-Cb3v_ZRD.js.gz +0 -0
- package/dist/_frontend/assets/{htmlMode-D1PmpoAx.js → htmlMode-JQDvK0Qf.js} +1 -1
- package/dist/_frontend/assets/htmlMode-JQDvK0Qf.js.br +0 -0
- package/dist/_frontend/assets/htmlMode-JQDvK0Qf.js.gz +0 -0
- package/dist/_frontend/assets/{index-BRS0kvLQ.js → index-DJ1uWGdt.js} +122 -122
- package/dist/_frontend/assets/index-DJ1uWGdt.js.br +0 -0
- package/dist/_frontend/assets/index-DJ1uWGdt.js.gz +0 -0
- package/dist/_frontend/assets/{index-aEojVaVa.js → index-DRjgykCE.js} +3 -3
- package/dist/_frontend/assets/index-DRjgykCE.js.br +0 -0
- package/dist/_frontend/assets/index-DRjgykCE.js.gz +0 -0
- package/dist/_frontend/assets/{javascript-DFHGvkjD.js → javascript-2WsgEpYV.js} +1 -1
- package/dist/_frontend/assets/{jsonMode-DWo0prLv.js → jsonMode-DnbseMlM.js} +1 -1
- package/dist/_frontend/assets/jsonMode-DnbseMlM.js.br +0 -0
- package/dist/_frontend/assets/jsonMode-DnbseMlM.js.gz +0 -0
- package/dist/_frontend/assets/{liquid-Bs2__P9v.js → liquid-DeE37I1e.js} +1 -1
- package/dist/_frontend/assets/liquid-DeE37I1e.js.br +0 -0
- package/dist/_frontend/assets/liquid-DeE37I1e.js.gz +0 -0
- package/dist/_frontend/assets/{lspLanguageFeatures-zZ0stYf4.js → lspLanguageFeatures-Bty8j9di.js} +1 -1
- package/dist/_frontend/assets/lspLanguageFeatures-Bty8j9di.js.br +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-Bty8j9di.js.gz +0 -0
- package/dist/_frontend/assets/{mdx-C7c8MDI_.js → mdx-DfKPZX1Z.js} +1 -1
- package/dist/_frontend/assets/mdx-DfKPZX1Z.js.br +0 -0
- package/dist/_frontend/assets/mdx-DfKPZX1Z.js.gz +0 -0
- package/dist/_frontend/assets/{python-CLO39XAV.js → python-2i3Kiv75.js} +1 -1
- package/dist/_frontend/assets/python-2i3Kiv75.js.br +0 -0
- package/dist/_frontend/assets/python-2i3Kiv75.js.gz +0 -0
- package/dist/_frontend/assets/{razor-efddsYhk.js → razor-B0N4vZnc.js} +1 -1
- package/dist/_frontend/assets/razor-B0N4vZnc.js.br +0 -0
- package/dist/_frontend/assets/razor-B0N4vZnc.js.gz +0 -0
- package/dist/_frontend/assets/{tsMode-xfchPgTX.js → tsMode-D1Y8xh-o.js} +1 -1
- package/dist/_frontend/assets/tsMode-D1Y8xh-o.js.br +0 -0
- package/dist/_frontend/assets/tsMode-D1Y8xh-o.js.gz +0 -0
- package/dist/_frontend/assets/{typescript-BFzaCQP8.js → typescript-2nhip0PT.js} +1 -1
- package/dist/_frontend/assets/typescript-2nhip0PT.js.br +0 -0
- package/dist/_frontend/assets/typescript-2nhip0PT.js.gz +0 -0
- package/dist/_frontend/assets/{workers-DKwMBzKS.js → workers-DSmTvA39.js} +1 -1
- package/dist/_frontend/assets/workers-DSmTvA39.js.br +0 -0
- package/dist/_frontend/assets/workers-DSmTvA39.js.gz +0 -0
- package/dist/_frontend/assets/{xml-Cx6gHwq3.js → xml-CA4M6Pks.js} +1 -1
- package/dist/_frontend/assets/xml-CA4M6Pks.js.br +0 -0
- package/dist/_frontend/assets/xml-CA4M6Pks.js.gz +0 -0
- package/dist/_frontend/assets/{yaml-DyrfMWlf.js → yaml-D5KNk7Ji.js} +1 -1
- package/dist/_frontend/assets/yaml-D5KNk7Ji.js.br +0 -0
- package/dist/_frontend/assets/yaml-D5KNk7Ji.js.gz +0 -0
- package/dist/_frontend/index.html +1 -1
- package/dist/_frontend/index.html.br +0 -0
- package/dist/_frontend/index.html.gz +0 -0
- package/dist/main.js +2152 -468
- package/dist/main.js.map +1 -1
- package/package.json +10 -4
- package/dist/_frontend/assets/ConnectorSettings-EYOQ72OS-DdSqeM08.js.br +0 -0
- package/dist/_frontend/assets/ConnectorSettings-EYOQ72OS-DdSqeM08.js.gz +0 -0
- package/dist/_frontend/assets/DrawerLayout-CNKNNVI7-CQ7wZgB6.js.br +0 -0
- package/dist/_frontend/assets/DrawerLayout-CNKNNVI7-CQ7wZgB6.js.gz +0 -0
- package/dist/_frontend/assets/ModelSettings-WBDPLI6O-CYfqXYXo.js.br +0 -0
- package/dist/_frontend/assets/ModelSettings-WBDPLI6O-CYfqXYXo.js.gz +0 -0
- package/dist/_frontend/assets/SandboxSettings-4GHBXULN-BPT3vPku.js.br +0 -0
- package/dist/_frontend/assets/SandboxSettings-4GHBXULN-BPT3vPku.js.gz +0 -0
- package/dist/_frontend/assets/SettingsBuilder-TD42LCIU-COZb69Wb.js +0 -2
- package/dist/_frontend/assets/SettingsBuilder-TD42LCIU-COZb69Wb.js.br +0 -0
- package/dist/_frontend/assets/SettingsBuilder-TD42LCIU-COZb69Wb.js.gz +0 -0
- package/dist/_frontend/assets/ShellRouteSync-T4WLY57Q-BKbLAZEv.js.br +0 -0
- package/dist/_frontend/assets/ShellRouteSync-T4WLY57Q-BKbLAZEv.js.gz +0 -0
- package/dist/_frontend/assets/SidebarLayout-JGLTENB3-BiZz45he.js.br +0 -0
- package/dist/_frontend/assets/SidebarLayout-JGLTENB3-BiZz45he.js.gz +0 -0
- package/dist/_frontend/assets/SkillSettings-UG6USX4N-DhQTOueg.js.br +0 -0
- package/dist/_frontend/assets/SkillSettings-UG6USX4N-DhQTOueg.js.gz +0 -0
- package/dist/_frontend/assets/WidgetLayout-6P6OUUTG-B1G5uZ4_.js.br +0 -0
- package/dist/_frontend/assets/WidgetLayout-6P6OUUTG-B1G5uZ4_.js.gz +0 -0
- package/dist/_frontend/assets/chunk-27MKI3HF-CVw53aeu.js.br +0 -0
- package/dist/_frontend/assets/chunk-27MKI3HF-CVw53aeu.js.gz +0 -0
- package/dist/_frontend/assets/chunk-62JRHF6Z-yJ2twjOf.js.br +0 -0
- package/dist/_frontend/assets/chunk-62JRHF6Z-yJ2twjOf.js.gz +0 -0
- package/dist/_frontend/assets/chunk-H75C5ETA-CX-fQN0e.js.br +0 -0
- package/dist/_frontend/assets/chunk-H75C5ETA-CX-fQN0e.js.gz +0 -0
- package/dist/_frontend/assets/cssMode-CEpMXY8Z.js.br +0 -0
- package/dist/_frontend/assets/cssMode-CEpMXY8Z.js.gz +0 -0
- package/dist/_frontend/assets/freemarker2-cQSgojlC.js.br +0 -0
- package/dist/_frontend/assets/freemarker2-cQSgojlC.js.gz +0 -0
- package/dist/_frontend/assets/handlebars-BQ-clQ7_.js.br +0 -0
- package/dist/_frontend/assets/handlebars-BQ-clQ7_.js.gz +0 -0
- package/dist/_frontend/assets/html-ChfWgJt-.js.br +0 -0
- package/dist/_frontend/assets/html-ChfWgJt-.js.gz +0 -0
- package/dist/_frontend/assets/htmlMode-D1PmpoAx.js.br +0 -0
- package/dist/_frontend/assets/htmlMode-D1PmpoAx.js.gz +0 -0
- package/dist/_frontend/assets/index-BRS0kvLQ.js.br +0 -0
- package/dist/_frontend/assets/index-BRS0kvLQ.js.gz +0 -0
- package/dist/_frontend/assets/index-aEojVaVa.js.br +0 -0
- package/dist/_frontend/assets/index-aEojVaVa.js.gz +0 -0
- package/dist/_frontend/assets/jsonMode-DWo0prLv.js.br +0 -0
- package/dist/_frontend/assets/jsonMode-DWo0prLv.js.gz +0 -0
- package/dist/_frontend/assets/liquid-Bs2__P9v.js.br +0 -0
- package/dist/_frontend/assets/liquid-Bs2__P9v.js.gz +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-zZ0stYf4.js.br +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-zZ0stYf4.js.gz +0 -0
- package/dist/_frontend/assets/mdx-C7c8MDI_.js.br +0 -0
- package/dist/_frontend/assets/mdx-C7c8MDI_.js.gz +0 -0
- package/dist/_frontend/assets/python-CLO39XAV.js.br +0 -0
- package/dist/_frontend/assets/python-CLO39XAV.js.gz +0 -0
- package/dist/_frontend/assets/razor-efddsYhk.js.br +0 -0
- package/dist/_frontend/assets/razor-efddsYhk.js.gz +0 -0
- package/dist/_frontend/assets/tsMode-xfchPgTX.js.br +0 -0
- package/dist/_frontend/assets/tsMode-xfchPgTX.js.gz +0 -0
- package/dist/_frontend/assets/typescript-BFzaCQP8.js.br +0 -0
- package/dist/_frontend/assets/typescript-BFzaCQP8.js.gz +0 -0
- package/dist/_frontend/assets/workers-DKwMBzKS.js.br +0 -0
- package/dist/_frontend/assets/workers-DKwMBzKS.js.gz +0 -0
- package/dist/_frontend/assets/xml-Cx6gHwq3.js.br +0 -0
- package/dist/_frontend/assets/xml-Cx6gHwq3.js.gz +0 -0
- package/dist/_frontend/assets/yaml-DyrfMWlf.js.br +0 -0
- package/dist/_frontend/assets/yaml-DyrfMWlf.js.gz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as J,o as de,r,p as H,j as e,q as oe,B as z,I as w,t as X,x as Q,y as ce,e as P,s as G}from"./index-BRS0kvLQ.js";var me=[{value:"dcr",label:"OAuth"},{value:"none",label:"None"},{value:"header",label:"API Key"}],$=Q("h-11 shadow-sm"),L=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),ue=({open:n,onOpenChange:u,onAdd:m,busy:j=!1,error:o})=>{const[f,y]=r.useState(""),[h,x]=r.useState(""),[p,S]=r.useState(""),[i,b]=r.useState("dcr"),[v,M]=r.useState(""),[k,F]=r.useState(""),A=()=>{y(""),x(""),S(""),b("dcr"),M(""),F("")},a=l=>{l||A(),u(l)},N=!!f.trim()&&!!p.trim()&&!!h.trim()&&(i!=="header"||!!v.trim()),E=async l=>{if(l.preventDefault(),!N||j)return;const I=i==="header"?{type:"header",apiKey:v.trim(),...k.trim()?{headerName:k.trim()}:{}}:{type:i};try{await m({name:f.trim(),url:h.trim(),description:p.trim(),auth:I}),A(),u(!1)}catch{}};return e.jsx(X,{open:n,onOpenChange:a,title:"Add MCP server",description:"Point at a remote MCP endpoint. It then behaves like any other connector.",contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:l=>void E(l),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(L,{})]}),e.jsx("input",{id:"mcp-server-name",type:"text",required:!0,value:f,onChange:l=>{y(l.target.value)},placeholder:"analytics-postgres-mcp",autoFocus:!0,className:$})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-description",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Description",e.jsx(L,{})]}),e.jsx("textarea",{id:"mcp-server-description",value:p,onChange:l=>{S(l.target.value)},placeholder:"Query analytics from Postgres",required:!0,rows:3,className:Q("resize-y py-2.5 shadow-sm")})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["URL",e.jsx(L,{})]}),e.jsx("input",{id:"mcp-server-url",type:"url",required:!0,value:h,onChange:l=>{x(l.target.value)},placeholder:"https://mcp.example.com/mcp",className:$})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"mb-1.5 text-sm font-medium text-text-primary",children:["Auth type",e.jsx(L,{})]}),e.jsx("div",{className:"flex w-full flex-row rounded-md border border-border bg-secondary-bg/40 p-1",children:me.map(l=>e.jsxs("label",{className:`flex h-8 flex-1 cursor-pointer items-center justify-center rounded-sm text-sm font-medium transition-colors ${i===l.value?"bg-dropdown-selected-item-bg text-dropdown-selected-item-text shadow-sm":"text-text-secondary hover:text-text-primary"}`,children:[e.jsx("input",{type:"radio",name:"mcp-auth-type",value:l.value,checked:i===l.value,onChange:()=>{b(l.value)},className:"sr-only"}),l.label]},l.value))})]}),i==="dcr"?e.jsxs("div",{className:"flex gap-1.5 bg-secondary-bg/40 p-2 rounded-md",children:[e.jsx(w,{name:"info",className:"size-3.5 mt-1 text-text-secondary"}),e.jsx("div",{className:"text-xs text-text-secondary leading-5.5",children:"Sign-in only — the server must support dynamic client registration. Manual OAuth (client ID / secret) isn't supported yet."})]}):null,i==="header"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",e.jsx(L,{})]}),e.jsx("input",{id:"mcp-server-api-key",type:"password",required:!0,value:v,onChange:l=>{M(l.target.value)},placeholder:"Paste the server token",className:$})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-header-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Header name ",e.jsx("span",{className:"font-normal text-text-secondary",children:"(optional)"})]}),e.jsx("input",{id:"mcp-server-header-name",type:"text",value:k,onChange:l=>{F(l.target.value)},placeholder:"Authorization",className:$})]})]}):null]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[o?e.jsx("p",{className:"text-failure-bg text-sm",children:o}):null,e.jsx(z,{type:"submit",size:"lg",disabled:!N||j,className:"w-full shrink-0",children:"Add"})]})]})})},xe=ue,_={dcr:"OAuth2",header:"API Key",none:"No Auth"};function he({text:n}){const u=r.useRef(null),[m,j]=r.useState(!1),[o,f]=r.useState(!1),[y,h]=r.useState(16);return r.useLayoutEffect(()=>{j(!1),h(16)},[n]),r.useLayoutEffect(()=>{const x=u.current;if(!x)return;if(!m){h(16),f(x.scrollWidth>x.clientWidth+1);return}h(16);const p=requestAnimationFrame(()=>{h(x.scrollHeight)});return()=>cancelAnimationFrame(p)},[n,m]),n?e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("p",{ref:u,style:{maxHeight:y},className:P("mt-0.5 overflow-hidden font-mono text-xs leading-4 text-text-secondary transition-[max-height] duration-300 ease-in-out",!m&&"whitespace-nowrap",!m&&o&&"pr-[5.75rem]"),children:[n,m&&o?e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"cursor-pointer font-mono text-xs font-medium text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!0,onClick:()=>j(!1),children:"Show less"})]}):null]}),!m&&o?e.jsxs("button",{type:"button",className:"absolute top-0.5 right-0 cursor-pointer bg-card-bg pl-1.5 font-mono text-xs font-medium leading-4 text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!1,onClick:()=>j(!0),children:[e.jsx("span",{"aria-hidden":!0,className:"text-text-secondary",children:"…"}),e.jsx("span",{className:"ml-1",children:"Read more"})]}):null]}):null}var pe=({connector:n,onBack:u,onConnectorRefreshed:m,onDisconnect:j,busy:o=!1})=>{const{connectorCatalog:f}=J(),{handleAuthorize:y,isOAuthLoading:h}=ce(),[x,p]=r.useState([]),[S,i]=r.useState(!0),[b,v]=r.useState(null),[M,k]=r.useState(!1);r.useEffect(()=>{let a=!1;return p([]),v(null),i(!0),f.getToolsByConnectorId({id:n.id}).then(N=>{a||p(N)}).catch(N=>{a||v(H(N,"Failed to load connector tools"))}).finally(()=>{a||i(!1)}),()=>{a=!0}},[n.authenticated,n.id,f]);const F=async()=>{k(!0),v(null);try{const a=await f.getConnector({id:n.id});m(a)}catch(a){v(H(a,"Failed to refresh connector details"))}finally{k(!1)}},A=h||M;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:u,className:"mb-3 inline-flex w-fit items-center gap-1 rounded-md py-1 pr-2 text-sm text-text-secondary hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",children:[e.jsx(w,{name:"chevron-left",className:"size-3.5"}),"Connectors"]}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-y-auto pb-1",children:[e.jsxs("header",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"text-lg font-semibold text-text-primary",children:n.name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:[e.jsxs("span",{className:P("flex items-center gap-1.5 text-xs font-medium",n.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:P("h-1.5 w-1.5 rounded-full",n.authenticated?"bg-success-bg":"bg-primary-button-bg")}),n.authenticated?"Connected":"Not authenticated"]}),e.jsxs("span",{className:"text-text-secondary",children:["· ",n.description]})]}),e.jsx("span",{className:"mt-2 inline-flex items-center rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-text-secondary",children:_[n.auth.type]??_.none})]}),n.auth.type==="dcr"&&!n.authenticated?e.jsx(z,{variant:"outline",size:"sm",type:"button",disabled:o||A,onClick:()=>{y(n.id,a=>{a&&F()})},children:A?"Connecting…":"Connect"}):n.auth.type==="dcr"&&!n.requiresAuth?e.jsx(z,{variant:"outline",size:"sm",type:"button",disabled:o,onClick:j,children:"Disconnect"}):null]}),e.jsx("section",{className:"mt-6","aria-labelledby":"connector-tools-heading",children:S?e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"Loading tools…"}):b?e.jsxs("div",{className:"rounded-xl border border-failure-bg/30 bg-failure-bg/10 p-6 text-center text-sm text-failure-bg",children:[b,n.auth.type==="dcr"&&!n.authenticated&&e.jsx("div",{className:"font-bold mt-1",children:"Click Connect and authenticate successfully to view tools."})]}):x.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("h5",{id:"connector-tools-heading",className:"mb-2 text-[0.8125rem] font-semibold text-text-primary",children:["Tools ",e.jsxs("span",{className:"font-normal text-text-secondary",children:["· ",x.length]})]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:x.map(a=>e.jsx("article",{className:"flex min-h-12 items-start gap-3 border-b border-border px-3 py-2 last:border-b-0",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h6",{className:"text-sm font-medium text-text-primary",children:a.name}),e.jsx(he,{text:a.description})]})},a.id))})]}):e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"No tools reported for this connector."})})]})]})},fe=pe,be=()=>{const{connectorCatalog:n}=J(),u=de(),[m,j]=r.useState(""),[o,f]=r.useState({ordered:[],authStatusById:new Map}),[y,h]=r.useState(!0),[x,p]=r.useState(null),[S,i]=r.useState(null),[b,v]=r.useState(!1),[M,k]=r.useState([]),[F,A]=r.useState(!1),[a,N]=r.useState(null),[E,l]=r.useState(null),[I,R]=r.useState(""),W=r.useMemo(()=>(M??[]).reduce((t,s)=>(t[s.name]=s.logo??"",t),{}),[M]),K=r.useCallback(async()=>{h(!0),p(null);try{const[t,s]=await Promise.all([n.listConnectors(),n.getConnectorCatalog()]);k(s);const d=t??[],g=new Set(d.map(c=>c.id)),C=[...d.map(c=>({connector:c,isConfigured:!0})),...s.filter(c=>!g.has(c.id)).map(c=>({connector:c,isConfigured:!1}))];f({ordered:C,authStatusById:new Map(C.map(c=>[c.connector.id,c.isConfigured?c.connector.authenticated:!1]))}),l(c=>c?t.find(ie=>ie.id===c.id)??null:null)}catch(t){p(H(t,"Failed to load connectors"))}finally{h(!1)}},[n]);r.useEffect(()=>{K()},[K]);const B=m.trim().toLowerCase(),T=r.useMemo(()=>B?o.ordered.filter(({connector:t})=>{var s;return t.name.toLowerCase().includes(B)||(((s=t.description)==null?void 0:s.toLowerCase().includes(B))??!1)||t.url.toLowerCase().includes(B)}):o.ordered,[o.ordered,B]),D=r.useMemo(()=>{const t=[];for(const s of T)if(s.isConfigured){const d=o.authStatusById.get(s.connector.id)??s.connector.authenticated;t.push(d===s.connector.authenticated?s.connector:{...s.connector,authenticated:d})}return t},[o.authStatusById,T]),q=r.useMemo(()=>{const t=[];for(const s of T)s.isConfigured||t.push(s.connector);return t},[T]),O=async(t,s=p)=>{v(!0),p(null);try{await t(),await K()}catch(d){throw s(H(d,"Request failed")),d}finally{v(!1)}},U=()=>{N(null),R(""),i(null)},V=async(t,s)=>{const d=s??(t.auth.type==="header"?{type:"header",...t.auth.headerName?{headerName:t.auth.headerName}:{}}:t.auth.type==="dcr"?{type:"dcr"}:{type:"none"});await n.createConnector({name:t.name,description:t.description??t.url,url:t.url,auth:d})},Z=t=>{if(t.auth.type==="header"){R(""),i(null),N(t);return}O(async()=>{await V(t)}).catch(()=>{})},ee=t=>{if(t.preventDefault(),!a||!I.trim())return;const s=a;i(null),O(async()=>{const d={type:"header",apiKey:I.trim(),...s.auth.type==="header"&&s.auth.headerName?{headerName:s.auth.headerName}:{}},g=o.ordered.find(({connector:c})=>c.id===s.id),C=g!=null&&g.isConfigured?g.connector:void 0;C?await n.updateConnector({id:C.id,name:C.name,description:C.description,url:C.url,auth:d}):await V(s,d),U(),setTimeout(()=>{u==null||u.showSuccess({title:`${s.name} ${C?"updated":"connected"}`})},100)},i).catch(()=>{})},te=async t=>{i(null),await O(async()=>{await n.createConnector({...t})},i),setTimeout(()=>{u==null||u.showSuccess({title:`${t.name} added`})},0)},se=t=>{O(async()=>{await n.disconnectConnector({id:t.id}),l(null)}).catch(()=>{})},ae=t=>{l(s=>(s==null?void 0:s.id)===t.id?t:s),f(s=>{const d=new Map(s.authStatusById);return d.set(t.id,t.authenticated),{ordered:s.ordered.map(g=>g.isConfigured&&g.connector.id===t.id?{connector:t,isConfigured:!0}:g),authStatusById:d}})},re=(t,s)=>{const d=W[t.name],g=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:d?e.jsx(G,{src:d,alt:t.name,className:"size-4.5"}):e.jsx(w,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description})]})]});return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0 cursor-pointer transition-colors hover:bg-ghost-button-hover/60",onClick:()=>{l(t)},children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:g}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:P("flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium",t.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:P("h-1.5 w-1.5 rounded-full",t.authenticated?"bg-success-bg":"bg-primary-button-bg")}),t.authenticated?"Connected":"Added"]})}),t.auth.type==="header"?e.jsxs(z,{variant:"secondary",size:"sm",type:"button",disabled:b,onClick:c=>{c.stopPropagation(),R(""),N(t)},children:[e.jsx(w,{name:"wrench",className:"size-3"}),"Replace Key"]}):null,e.jsx(w,{name:"chevron-right",className:"size-4"})]})]},t.id)},ne=t=>{const s=W[t.name];return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:s?e.jsx(G,{src:s,alt:t.name,className:"size-4.5"}):e.jsx(w,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description??t.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("span",{className:"hidden text-xs text-text-secondary sm:inline",children:_[t.auth.type]??_.none}),e.jsx(z,{variant:"secondary",size:"sm",type:"button",disabled:b,onClick:()=>{Z(t)},children:t.auth.type==="dcr"?"Add":"Connect"})]})]},t.id)},Y=r.useMemo(()=>a!==null&&o.ordered.some(t=>t.isConfigured&&t.connector.id===a.id),[a,o.ordered]);if(E)return e.jsx(fe,{connector:E,busy:b,onBack:()=>{l(null)},onConnectorRefreshed:ae,onDisconnect:()=>{se(E)}});const le=D.length>0||q.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Connectors"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect tools your agents can use."}),x?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:x}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(oe,{query:m,setQuery:j,placeholder:"Search connectors"})}),e.jsxs(z,{variant:"secondary",type:"button",onClick:()=>{i(null),A(!0)},children:[e.jsx(w,{name:"plus",size:"1rem",className:"mr-1"}),"Add MCP Server"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[y?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!y&&D.length>0?e.jsxs("section",{"aria-labelledby":"connected-connectors-heading",children:[e.jsxs("h4",{id:"connected-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Configured · ",D.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:D.map(t=>re(t))})]}):null,!y&&q.length>0?e.jsxs("section",{"aria-labelledby":"available-connectors-heading",children:[e.jsxs("h4",{id:"available-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",q.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:q.map(t=>ne(t))})]}):null,!y&&!le?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:m.trim()?`No connectors match “${m.trim()}”.`:"No connectors yet."}):null]}),e.jsx(X,{open:a!==null,onOpenChange:t=>{t||U()},title:`${Y?"Replace key for":"Connect"} ${(a==null?void 0:a.name)??"connector"}`,description:a==null?void 0:a.url,contentSized:!0,className:"md:max-w-xl",children:e.jsxs("form",{onSubmit:ee,children:[e.jsxs("div",{className:"space-y-5 px-5 py-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-xl border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-6 text-text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-text-primary",children:a==null?void 0:a.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:a==null?void 0:a.description})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"connector-api-key",className:"mb-2 block text-xs font-semibold uppercase tracking-wide text-text-secondary",children:"API key / token"}),e.jsx("input",{id:"connector-api-key",type:"password",value:I,onChange:t=>{R(t.target.value)},placeholder:`Paste the token from ${(a==null?void 0:a.name)??"the provider"}`,autoFocus:!0,required:!0,className:Q("h-11")})]}),S?e.jsx("p",{className:"text-failure-bg text-sm",children:S}):null]}),e.jsxs("footer",{className:"flex justify-end gap-2 border-t border-border px-5 py-4",children:[e.jsx(z,{variant:"ghost",type:"button",onClick:U,disabled:b,children:"Cancel"}),e.jsx(z,{type:"submit",disabled:!I.trim()||b,children:Y?"Replace Key":"Connect"})]})]})}),e.jsx(xe,{open:F,onOpenChange:t=>{A(t),t||i(null)},onAdd:te,busy:b,error:S})]})})]})},ye=be;export{ye as default};
|
|
1
|
+
import{n as J,o as de,r,p as H,j as e,q as oe,B as z,I as w,t as X,x as Q,y as ce,e as P,s as G}from"./index-DJ1uWGdt.js";var me=[{value:"dcr",label:"OAuth"},{value:"none",label:"None"},{value:"header",label:"API Key"}],$=Q("h-11 shadow-sm"),L=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),ue=({open:n,onOpenChange:u,onAdd:m,busy:j=!1,error:o})=>{const[f,y]=r.useState(""),[h,x]=r.useState(""),[p,S]=r.useState(""),[i,b]=r.useState("dcr"),[v,M]=r.useState(""),[k,F]=r.useState(""),A=()=>{y(""),x(""),S(""),b("dcr"),M(""),F("")},a=l=>{l||A(),u(l)},N=!!f.trim()&&!!p.trim()&&!!h.trim()&&(i!=="header"||!!v.trim()),E=async l=>{if(l.preventDefault(),!N||j)return;const I=i==="header"?{type:"header",apiKey:v.trim(),...k.trim()?{headerName:k.trim()}:{}}:{type:i};try{await m({name:f.trim(),url:h.trim(),description:p.trim(),auth:I}),A(),u(!1)}catch{}};return e.jsx(X,{open:n,onOpenChange:a,title:"Add MCP server",description:"Point at a remote MCP endpoint. It then behaves like any other connector.",contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:l=>void E(l),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(L,{})]}),e.jsx("input",{id:"mcp-server-name",type:"text",required:!0,value:f,onChange:l=>{y(l.target.value)},placeholder:"analytics-postgres-mcp",autoFocus:!0,className:$})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-description",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Description",e.jsx(L,{})]}),e.jsx("textarea",{id:"mcp-server-description",value:p,onChange:l=>{S(l.target.value)},placeholder:"Query analytics from Postgres",required:!0,rows:3,className:Q("resize-y py-2.5 shadow-sm")})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["URL",e.jsx(L,{})]}),e.jsx("input",{id:"mcp-server-url",type:"url",required:!0,value:h,onChange:l=>{x(l.target.value)},placeholder:"https://mcp.example.com/mcp",className:$})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"mb-1.5 text-sm font-medium text-text-primary",children:["Auth type",e.jsx(L,{})]}),e.jsx("div",{className:"flex w-full flex-row rounded-md border border-border bg-secondary-bg/40 p-1",children:me.map(l=>e.jsxs("label",{className:`flex h-8 flex-1 cursor-pointer items-center justify-center rounded-sm text-sm font-medium transition-colors ${i===l.value?"bg-dropdown-selected-item-bg text-dropdown-selected-item-text shadow-sm":"text-text-secondary hover:text-text-primary"}`,children:[e.jsx("input",{type:"radio",name:"mcp-auth-type",value:l.value,checked:i===l.value,onChange:()=>{b(l.value)},className:"sr-only"}),l.label]},l.value))})]}),i==="dcr"?e.jsxs("div",{className:"flex gap-1.5 bg-secondary-bg/40 p-2 rounded-md",children:[e.jsx(w,{name:"info",className:"size-3.5 mt-1 text-text-secondary"}),e.jsx("div",{className:"text-xs text-text-secondary leading-5.5",children:"Sign-in only — the server must support dynamic client registration. Manual OAuth (client ID / secret) isn't supported yet."})]}):null,i==="header"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",e.jsx(L,{})]}),e.jsx("input",{id:"mcp-server-api-key",type:"password",required:!0,value:v,onChange:l=>{M(l.target.value)},placeholder:"Paste the server token",className:$})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-header-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Header name ",e.jsx("span",{className:"font-normal text-text-secondary",children:"(optional)"})]}),e.jsx("input",{id:"mcp-server-header-name",type:"text",value:k,onChange:l=>{F(l.target.value)},placeholder:"Authorization",className:$})]})]}):null]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[o?e.jsx("p",{className:"text-failure-bg text-sm",children:o}):null,e.jsx(z,{type:"submit",size:"lg",disabled:!N||j,className:"w-full shrink-0",children:"Add"})]})]})})},xe=ue,_={dcr:"OAuth2",header:"API Key",none:"No Auth"};function he({text:n}){const u=r.useRef(null),[m,j]=r.useState(!1),[o,f]=r.useState(!1),[y,h]=r.useState(16);return r.useLayoutEffect(()=>{j(!1),h(16)},[n]),r.useLayoutEffect(()=>{const x=u.current;if(!x)return;if(!m){h(16),f(x.scrollWidth>x.clientWidth+1);return}h(16);const p=requestAnimationFrame(()=>{h(x.scrollHeight)});return()=>cancelAnimationFrame(p)},[n,m]),n?e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("p",{ref:u,style:{maxHeight:y},className:P("mt-0.5 overflow-hidden font-mono text-xs leading-4 text-text-secondary transition-[max-height] duration-300 ease-in-out",!m&&"whitespace-nowrap",!m&&o&&"pr-[5.75rem]"),children:[n,m&&o?e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"cursor-pointer font-mono text-xs font-medium text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!0,onClick:()=>j(!1),children:"Show less"})]}):null]}),!m&&o?e.jsxs("button",{type:"button",className:"absolute top-0.5 right-0 cursor-pointer bg-card-bg pl-1.5 font-mono text-xs font-medium leading-4 text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!1,onClick:()=>j(!0),children:[e.jsx("span",{"aria-hidden":!0,className:"text-text-secondary",children:"…"}),e.jsx("span",{className:"ml-1",children:"Read more"})]}):null]}):null}var pe=({connector:n,onBack:u,onConnectorRefreshed:m,onDisconnect:j,busy:o=!1})=>{const{connectorCatalog:f}=J(),{handleAuthorize:y,isOAuthLoading:h}=ce(),[x,p]=r.useState([]),[S,i]=r.useState(!0),[b,v]=r.useState(null),[M,k]=r.useState(!1);r.useEffect(()=>{let a=!1;return p([]),v(null),i(!0),f.getToolsByConnectorId({id:n.id}).then(N=>{a||p(N)}).catch(N=>{a||v(H(N,"Failed to load connector tools"))}).finally(()=>{a||i(!1)}),()=>{a=!0}},[n.authenticated,n.id,f]);const F=async()=>{k(!0),v(null);try{const a=await f.getConnector({id:n.id});m(a)}catch(a){v(H(a,"Failed to refresh connector details"))}finally{k(!1)}},A=h||M;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:u,className:"mb-3 inline-flex w-fit items-center gap-1 rounded-md py-1 pr-2 text-sm text-text-secondary hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",children:[e.jsx(w,{name:"chevron-left",className:"size-3.5"}),"Connectors"]}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-y-auto pb-1",children:[e.jsxs("header",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"text-lg font-semibold text-text-primary",children:n.name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:[e.jsxs("span",{className:P("flex items-center gap-1.5 text-xs font-medium",n.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:P("h-1.5 w-1.5 rounded-full",n.authenticated?"bg-success-bg":"bg-primary-button-bg")}),n.authenticated?"Connected":"Not authenticated"]}),e.jsxs("span",{className:"text-text-secondary",children:["· ",n.description]})]}),e.jsx("span",{className:"mt-2 inline-flex items-center rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-text-secondary",children:_[n.auth.type]??_.none})]}),n.auth.type==="dcr"&&!n.authenticated?e.jsx(z,{variant:"outline",size:"sm",type:"button",disabled:o||A,onClick:()=>{y(n.id,a=>{a&&F()})},children:A?"Connecting…":"Connect"}):n.auth.type==="dcr"&&!n.requiresAuth?e.jsx(z,{variant:"outline",size:"sm",type:"button",disabled:o,onClick:j,children:"Disconnect"}):null]}),e.jsx("section",{className:"mt-6","aria-labelledby":"connector-tools-heading",children:S?e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"Loading tools…"}):b?e.jsxs("div",{className:"rounded-xl border border-failure-bg/30 bg-failure-bg/10 p-6 text-center text-sm text-failure-bg",children:[b,n.auth.type==="dcr"&&!n.authenticated&&e.jsx("div",{className:"font-bold mt-1",children:"Click Connect and authenticate successfully to view tools."})]}):x.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("h5",{id:"connector-tools-heading",className:"mb-2 text-[0.8125rem] font-semibold text-text-primary",children:["Tools ",e.jsxs("span",{className:"font-normal text-text-secondary",children:["· ",x.length]})]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:x.map(a=>e.jsx("article",{className:"flex min-h-12 items-start gap-3 border-b border-border px-3 py-2 last:border-b-0",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h6",{className:"text-sm font-medium text-text-primary",children:a.name}),e.jsx(he,{text:a.description})]})},a.id))})]}):e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"No tools reported for this connector."})})]})]})},fe=pe,be=()=>{const{connectorCatalog:n}=J(),u=de(),[m,j]=r.useState(""),[o,f]=r.useState({ordered:[],authStatusById:new Map}),[y,h]=r.useState(!0),[x,p]=r.useState(null),[S,i]=r.useState(null),[b,v]=r.useState(!1),[M,k]=r.useState([]),[F,A]=r.useState(!1),[a,N]=r.useState(null),[E,l]=r.useState(null),[I,R]=r.useState(""),W=r.useMemo(()=>(M??[]).reduce((t,s)=>(t[s.name]=s.logo??"",t),{}),[M]),K=r.useCallback(async()=>{h(!0),p(null);try{const[t,s]=await Promise.all([n.listConnectors(),n.getConnectorCatalog()]);k(s);const d=t??[],g=new Set(d.map(c=>c.id)),C=[...d.map(c=>({connector:c,isConfigured:!0})),...s.filter(c=>!g.has(c.id)).map(c=>({connector:c,isConfigured:!1}))];f({ordered:C,authStatusById:new Map(C.map(c=>[c.connector.id,c.isConfigured?c.connector.authenticated:!1]))}),l(c=>c?t.find(ie=>ie.id===c.id)??null:null)}catch(t){p(H(t,"Failed to load connectors"))}finally{h(!1)}},[n]);r.useEffect(()=>{K()},[K]);const B=m.trim().toLowerCase(),T=r.useMemo(()=>B?o.ordered.filter(({connector:t})=>{var s;return t.name.toLowerCase().includes(B)||(((s=t.description)==null?void 0:s.toLowerCase().includes(B))??!1)||t.url.toLowerCase().includes(B)}):o.ordered,[o.ordered,B]),D=r.useMemo(()=>{const t=[];for(const s of T)if(s.isConfigured){const d=o.authStatusById.get(s.connector.id)??s.connector.authenticated;t.push(d===s.connector.authenticated?s.connector:{...s.connector,authenticated:d})}return t},[o.authStatusById,T]),q=r.useMemo(()=>{const t=[];for(const s of T)s.isConfigured||t.push(s.connector);return t},[T]),O=async(t,s=p)=>{v(!0),p(null);try{await t(),await K()}catch(d){throw s(H(d,"Request failed")),d}finally{v(!1)}},U=()=>{N(null),R(""),i(null)},V=async(t,s)=>{const d=s??(t.auth.type==="header"?{type:"header",...t.auth.headerName?{headerName:t.auth.headerName}:{}}:t.auth.type==="dcr"?{type:"dcr"}:{type:"none"});await n.createConnector({name:t.name,description:t.description??t.url,url:t.url,auth:d})},Z=t=>{if(t.auth.type==="header"){R(""),i(null),N(t);return}O(async()=>{await V(t)}).catch(()=>{})},ee=t=>{if(t.preventDefault(),!a||!I.trim())return;const s=a;i(null),O(async()=>{const d={type:"header",apiKey:I.trim(),...s.auth.type==="header"&&s.auth.headerName?{headerName:s.auth.headerName}:{}},g=o.ordered.find(({connector:c})=>c.id===s.id),C=g!=null&&g.isConfigured?g.connector:void 0;C?await n.updateConnector({id:C.id,name:C.name,description:C.description,url:C.url,auth:d}):await V(s,d),U(),setTimeout(()=>{u==null||u.showSuccess({title:`${s.name} ${C?"updated":"connected"}`})},100)},i).catch(()=>{})},te=async t=>{i(null),await O(async()=>{await n.createConnector({...t})},i),setTimeout(()=>{u==null||u.showSuccess({title:`${t.name} added`})},0)},se=t=>{O(async()=>{await n.disconnectConnector({id:t.id}),l(null)}).catch(()=>{})},ae=t=>{l(s=>(s==null?void 0:s.id)===t.id?t:s),f(s=>{const d=new Map(s.authStatusById);return d.set(t.id,t.authenticated),{ordered:s.ordered.map(g=>g.isConfigured&&g.connector.id===t.id?{connector:t,isConfigured:!0}:g),authStatusById:d}})},re=(t,s)=>{const d=W[t.name],g=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:d?e.jsx(G,{src:d,alt:t.name,className:"size-4.5"}):e.jsx(w,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description})]})]});return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0 cursor-pointer transition-colors hover:bg-ghost-button-hover/60",onClick:()=>{l(t)},children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:g}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:P("flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium",t.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:P("h-1.5 w-1.5 rounded-full",t.authenticated?"bg-success-bg":"bg-primary-button-bg")}),t.authenticated?"Connected":"Added"]})}),t.auth.type==="header"?e.jsxs(z,{variant:"secondary",size:"sm",type:"button",disabled:b,onClick:c=>{c.stopPropagation(),R(""),N(t)},children:[e.jsx(w,{name:"wrench",className:"size-3"}),"Replace Key"]}):null,e.jsx(w,{name:"chevron-right",className:"size-4"})]})]},t.id)},ne=t=>{const s=W[t.name];return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:s?e.jsx(G,{src:s,alt:t.name,className:"size-4.5"}):e.jsx(w,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description??t.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("span",{className:"hidden text-xs text-text-secondary sm:inline",children:_[t.auth.type]??_.none}),e.jsx(z,{variant:"secondary",size:"sm",type:"button",disabled:b,onClick:()=>{Z(t)},children:t.auth.type==="dcr"?"Add":"Connect"})]})]},t.id)},Y=r.useMemo(()=>a!==null&&o.ordered.some(t=>t.isConfigured&&t.connector.id===a.id),[a,o.ordered]);if(E)return e.jsx(fe,{connector:E,busy:b,onBack:()=>{l(null)},onConnectorRefreshed:ae,onDisconnect:()=>{se(E)}});const le=D.length>0||q.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Connectors"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect tools your agents can use."}),x?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:x}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(oe,{query:m,setQuery:j,placeholder:"Search connectors"})}),e.jsxs(z,{variant:"secondary",type:"button",onClick:()=>{i(null),A(!0)},children:[e.jsx(w,{name:"plus",size:"1rem",className:"mr-1"}),"Add MCP Server"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[y?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!y&&D.length>0?e.jsxs("section",{"aria-labelledby":"connected-connectors-heading",children:[e.jsxs("h4",{id:"connected-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Configured · ",D.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:D.map(t=>re(t))})]}):null,!y&&q.length>0?e.jsxs("section",{"aria-labelledby":"available-connectors-heading",children:[e.jsxs("h4",{id:"available-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",q.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:q.map(t=>ne(t))})]}):null,!y&&!le?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:m.trim()?`No connectors match “${m.trim()}”.`:"No connectors yet."}):null]}),e.jsx(X,{open:a!==null,onOpenChange:t=>{t||U()},title:`${Y?"Replace key for":"Connect"} ${(a==null?void 0:a.name)??"connector"}`,description:a==null?void 0:a.url,contentSized:!0,className:"md:max-w-xl",children:e.jsxs("form",{onSubmit:ee,children:[e.jsxs("div",{className:"space-y-5 px-5 py-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-xl border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(w,{name:"mcp-server",className:"size-6 text-text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-text-primary",children:a==null?void 0:a.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:a==null?void 0:a.description})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"connector-api-key",className:"mb-2 block text-xs font-semibold uppercase tracking-wide text-text-secondary",children:"API key / token"}),e.jsx("input",{id:"connector-api-key",type:"password",value:I,onChange:t=>{R(t.target.value)},placeholder:`Paste the token from ${(a==null?void 0:a.name)??"the provider"}`,autoFocus:!0,required:!0,className:Q("h-11")})]}),S?e.jsx("p",{className:"text-failure-bg text-sm",children:S}):null]}),e.jsxs("footer",{className:"flex justify-end gap-2 border-t border-border px-5 py-4",children:[e.jsx(z,{variant:"ghost",type:"button",onClick:U,disabled:b,children:"Cancel"}),e.jsx(z,{type:"submit",disabled:!I.trim()||b,children:Y?"Replace Key":"Connect"})]})]})}),e.jsx(xe,{open:F,onOpenChange:t=>{A(t),t||i(null)},onAdd:te,busy:b,error:S})]})})]})},ye=be;export{ye as default};
|
|
Binary file
|
|
Binary file
|
package/dist/_frontend/assets/{DockLayout-XIOJZ2YM-htVfvSLo.js → DockLayout-2RWDSUKE-eKoTN8R3.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as a}from"./chunk-
|
|
1
|
+
import{S as a}from"./chunk-TCAVLWYL-DVhtkE3q.js";import{j as o,C as t,e as l}from"./index-DJ1uWGdt.js";import"./chunk-OZTNBS6V-CLmmFX7d.js";function n({className:r}){return o.jsx(t,{children:o.jsx("div",{"data-aui-compact-layout":!0,className:l("ml-auto flex h-full w-full max-w-[min(400px,100%)] min-h-0 min-w-0 flex-col border-l border-border bg-primary-bg shadow-[-4px_0_24px_color-mix(in_oklab,var(--shadow-color)_6%,transparent)]",r),children:o.jsx(a,{})})})}export{n as DockLayout};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SettingsBuilder-
|
|
2
|
-
import{u as N,a as v,c,r as a,j as e,I as m,f as S,S as C,e as E,_ as k}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SettingsBuilder-MYWRFXRI-Ce3OWfa1.js","assets/index-DJ1uWGdt.js","assets/index-DEKCw40W.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as N,a as v,c,r as a,j as e,I as m,f as S,S as C,e as E,_ as k}from"./index-DJ1uWGdt.js";import{N as O,S as R,a as T,T as A}from"./chunk-OZTNBS6V-CLmmFX7d.js";var _=a.lazy(()=>k(()=>import("./SettingsBuilder-MYWRFXRI-Ce3OWfa1.js"),__vite__mapDeps([0,1,2])));function z({className:p}){const b=N(),s=v(),h=c("ClearChatButton"),j=c("SaveAgentButton"),g=c("SelectAgentEmptyState"),[n,r]=a.useState(!1),u=a.useRef(null),d=a.useRef(null),f=a.useRef(null),l=a.useRef(!1),y=(s==null?void 0:s.mode.status)==="idle",o=(s==null?void 0:s.settingsOpen)===!0;a.useEffect(()=>{if(!n)return;const t=i=>{i.key==="Escape"&&r(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[n]),a.useEffect(()=>{var i,x;const t=f.current;if(n){l.current=!0,t&&(t.inert=!0),(i=d.current)==null||i.focus();return}l.current&&(t&&(t.inert=!1),(x=u.current)==null||x.focus(),l.current=!1)},[n]);const w=()=>{s!=null&&s.isComposerEnabled?s.openDraft():(s==null||s.setSettingsOpen(!1),b.threads().switchToNewThread()),r(!1)};return e.jsxs("div",{className:E("relative flex h-full min-h-0 w-full flex-col bg-primary-bg",p),children:[e.jsxs("header",{className:"flex shrink-0 items-center gap-1 border-b border-border bg-topbar-bg px-2 py-1.5",children:[o?e.jsx("span",{className:"min-w-0 flex-1"}):e.jsxs(e.Fragment,{children:[e.jsx(O,{}),e.jsx("span",{className:"min-w-0 flex-1"}),e.jsx(h,{}),e.jsx(j,{})]}),e.jsx(R,{},"shell-actions"),o?null:e.jsxs(e.Fragment,{children:[(s==null?void 0:s.isNewChatEnabled)!==!1?e.jsx("button",{type:"button","aria-label":"New chat",title:"New chat",className:S({variant:"ghost",size:"icon"}),onClick:w,children:e.jsx(m,{name:"plus"})}):null,e.jsx("button",{ref:u,type:"button","aria-label":"Sessions","aria-expanded":n,className:"text-text-secondary hover:text-text-primary inline-flex size-8 cursor-pointer items-center justify-center rounded-md",onClick:()=>r(t=>!t),children:e.jsx(m,{name:"clock-rotate-left"})})]})]}),e.jsx("div",{ref:f,className:"min-h-0 min-w-0 flex-1",children:o?e.jsx(a.Suspense,{fallback:e.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[e.jsx(C,{size:28,className:"text-text-primary"}),e.jsx("span",{className:"sr-only",children:"Loading"})]}),children:e.jsx(_,{})}):y?e.jsx(g,{}):e.jsx(T,{})}),n?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close sessions",className:"absolute inset-0 z-[9] cursor-pointer bg-[var(--overlay)]",onClick:()=>r(!1)}),e.jsx("div",{ref:d,className:"absolute inset-y-0 right-0 z-10 flex w-full max-w-80 flex-col border-l border-border bg-sidebar-bg shadow-lg outline-none",role:"dialog","aria-label":"Sessions",tabIndex:-1,children:e.jsx(A,{onThreadOpen:()=>r(!1)})})]}):null]})}export{z as DrawerLayout};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as be,o as fe,r as o,p as Y,j as e,q as ge,B,I as P,s as ie,t as xe,A as ye,v as ve,e as L,w as je,x as Ne}from"./index-BRS0kvLQ.js";var me=Ne("h-11 shadow-sm"),we=({open:n,onOpenChange:l,onSave:b,title:k,description:p,initialBaseUrl:E="",baseUrlPlaceholder:d="https://api.openai.com/v1",requireApiKey:c=!0,submitLabel:S="Save",busy:O=!1,error:F})=>{const[M,$]=o.useState(""),[y,x]=o.useState(""),[w,A]=o.useState(!1),U=()=>{$(""),x(""),A(!1)};o.useEffect(()=>{n&&($(""),x(E),A(!1))},[n,E]);const X=i=>{i||U(),l(i)},T=M.trim(),G=!c||!!T,v=async i=>{if(i.preventDefault(),!(!G||O))try{await b({apiKey:T,baseUrl:y.trim()}),U(),l(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:X,title:k,description:p,contentSized:!0,children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:v,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"model-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",c?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"model-provider-api-key",type:"password",required:c,value:M,onChange:i=>{$(i.target.value)},placeholder:c?"Enter API key":"Enter a new key",autoFocus:!0,className:me}),c?null:e.jsx("p",{className:"mt-1.5 text-xs text-text-secondary",children:"Leave blank to keep the current key; enter a new one to replace it."})]}),e.jsxs(ye,{expanded:w,onChange:(i,K)=>A(K),className:"rounded-md border border-border",children:[e.jsx(ve,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced · custom endpoint",e.jsx(P,{name:"chevron-down",className:L("size-4 shrink-0 text-text-secondary transition-transform duration-200",w?"rotate-0":"-rotate-90")})]})}),e.jsxs(je,{className:"space-y-1.5 border-t border-border px-3 pb-3 pt-4",children:[e.jsx("label",{htmlFor:"model-provider-base-url",className:"block text-sm font-medium text-text-primary",children:"Base URL"}),e.jsx("input",{id:"model-provider-base-url",type:"url",value:y,onChange:i=>{x(i.target.value)},placeholder:d,className:me}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Leave blank unless you use a regional or proxy endpoint."})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[F?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsx(B,{type:"submit",size:"lg",disabled:!G||O,className:"w-full shrink-0",children:S})]})]})})},Ce=we,ke="128000",Ee="4096",pe=()=>({id:"",name:"",advancedExpanded:!0,contextLength:"",maxOutputTokens:""}),ue=n=>(n==null?void 0:n.models.map(l=>{var b,k,p,E,d;return{id:l.id,name:l.name,advancedExpanded:!0,reasoningEfforts:(b=l.properties)==null?void 0:b.reasoningEfforts,contextLength:((p=(k=l.properties)==null?void 0:k.contextLength)==null?void 0:p.toString())??"",maxOutputTokens:((d=(E=l.properties)==null?void 0:E.maxOutputTokens)==null?void 0:d.toString())??"",nameDirty:!0}}))??[pe()],Q="h-11 w-full rounded-md border border-border/70 bg-secondary-bg px-3 text-sm text-text-primary outline-none transition-colors placeholder:text-text-secondary/70 focus-visible:border-focus-ring focus-visible:ring-2 focus-visible:ring-focus-ring/50",V="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function ce(n){const l=n.trim();if(l==="")return null;const b=Number(l);return Number.isInteger(b)&&b>0?b:null}function Se(n){return n.replace(/([a-zA-Z])(\d)/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").slice(0,64).replace(/-+$/g,"")}var re=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),ee=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-failure-bg",children:n}),ne=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:n}),Me=({open:n,onOpenChange:l,onSubmit:b,reasoningEffortOptions:k,busy:p=!1,error:E,isEditMode:d=!1,initialValues:c})=>{const[S,O]=o.useState((c==null?void 0:c.name)??""),[F,M]=o.useState((c==null?void 0:c.baseUrl)??""),[$,y]=o.useState(""),[x,w]=o.useState(()=>ue(c)),[A,U]=o.useState(!1),[X,T]=o.useState(!1),G=()=>{O((c==null?void 0:c.name)??""),M((c==null?void 0:c.baseUrl)??""),y(""),w(ue(c)),U(!1),T(!1)},v=s=>{s||G(),l(s)},i=(s,r)=>{w(g=>g.map((u,j)=>j===s?{...u,...r}:u))},K=()=>{U(!0),T(!0),w(s=>s.map(r=>({...r,idTouched:!0,contextTouched:!0,maxTouched:!0})))},f=S.trim(),D=f?null:"Name is required.",_=F.trim();let h=null;if(!_)h="Base URL is required.";else try{new URL(_)}catch{h="Enter a valid URL."}const W=s=>s.id.trim()?null:"Model ID is required.",te=s=>s.name.trim()?null:"Model name is required.",q=s=>ce(s.contextLength)==null?"Set the model's context window.":null,Z=s=>ce(s.maxOutputTokens)==null?"Set the max output tokens.":null,oe=!D&&!h&&x.every(s=>!W(s)&&!te(s)),se=A&&D,H=X&&h,I=async()=>{if(K(),!oe||p)return;const s=x.findIndex(r=>q(r)||Z(r));if(s!==-1){i(s,{advancedExpanded:!0});const r=x[s],g=r&&q(r)?"context-length":"max-output-tokens";setTimeout(()=>{var j;const u=document.getElementById(`custom-provider-model-${s}-${g}`);(j=u==null?void 0:u.scrollIntoView)==null||j.call(u,{block:"center",behavior:"smooth"}),u==null||u.focus()},0);return}try{await b({name:f,baseUrl:_,apiKey:$.trim(),models:x.map(r=>{var R;const g={};(R=r.reasoningEfforts)!=null&&R.length&&(g.reasoningEfforts=r.reasoningEfforts);const u=ce(r.contextLength);u!=null&&(g.contextLength=u);const j=ce(r.maxOutputTokens);return j!=null&&(g.maxOutputTokens=j),{id:r.id.trim(),name:r.name.trim(),...Object.keys(g).length>0?{properties:g}:{}}})}),v(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:v,title:d?`Edit ${(c==null?void 0:c.name)??S}`:"Add custom provider",description:d?"Update the endpoint, credentials, and models for this provider.":"Connect any OpenAI-compatible endpoint, whether it's a local model, a proxy, or your own hosted service.",contentSized:!0,children:e.jsxs("form",{className:"flex min-h-0 flex-1 flex-col",onSubmit:s=>{s.preventDefault(),I()},children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto px-5 pt-4 pb-8",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:S,onChange:s=>O(s.target.value),onBlur:()=>U(!0),placeholder:"local-llama",autoFocus:!d,readOnly:d,"aria-readonly":d,"aria-invalid":se?!0:void 0,className:L(Q,d&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",se&&V)}),d?e.jsx(ne,{children:"Provider names cannot be changed after creation."}):null,se?e.jsx(ee,{children:D}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-base-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Base URL",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-base-url",type:"text",value:F,onChange:s=>M(s.target.value),onBlur:()=>T(!0),placeholder:"http://localhost:11434/v1",autoFocus:d,"aria-invalid":H?!0:void 0,className:L(Q,H&&V)}),H?e.jsx(ee,{children:h}):_?null:e.jsx(ne,{children:"OpenAI-compatible endpoint, usually ending in /v1."})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"custom-provider-api-key",type:"password",value:$,onChange:s=>y(s.target.value),placeholder:"sk-…",className:Q}),e.jsx(ne,{children:d?"Leave blank to keep the saved key, or enter a new key to replace it.":"Leave blank if your endpoint needs no key (e.g. a local model)."})]}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0",children:[e.jsxs("legend",{className:"float-left mb-2 w-full p-0 text-sm font-medium text-text-primary",children:["Models",e.jsx(re,{})]}),e.jsx("div",{className:"clear-both",children:x.map((s,r)=>{const g=W(s),u=s.idTouched&&g,j=te(s),R=!!j&&s.nameDirty,le=q(s),C=Z(s),z=s.contextTouched&&le,ae=s.maxTouched&&C;return e.jsxs("div",{className:L("pb-6",r>0?"border-t border-border pt-6":"pt-1"),style:r>0?{borderTopWidth:"0.5px"}:void 0,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_2rem] items-end gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-id`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model ID"}),e.jsx("input",{id:`custom-provider-model-${r}-id`,type:"text",value:s.id,onChange:t=>{const a=t.target.value;i(r,{id:a,...s.nameDirty?{}:{name:Se(a)}})},onBlur:()=>i(r,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":u?!0:void 0,className:L(Q,"font-mono",u&&V)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-name`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model name"}),e.jsx("input",{id:`custom-provider-model-${r}-name`,type:"text",value:s.name,onChange:t=>i(r,{name:t.target.value,nameDirty:!0}),placeholder:"llama-3-1-70b","aria-invalid":R?!0:void 0,className:L(Q,R&&V)})]}),e.jsx("button",{type:"button","aria-label":`Remove model ${r+1}`,disabled:x.length===1||p,className:"mb-0.5 flex size-9 items-center justify-center rounded-md text-text-secondary transition-colors hover:text-text-primary disabled:opacity-40",onClick:()=>w(t=>t.filter((a,m)=>m!==r)),children:e.jsx(P,{name:"trash",className:"size-4"})})]}),u?e.jsx(ee,{children:g}):null,R?e.jsx(ee,{children:j}):null,e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button","aria-expanded":s.advancedExpanded,"aria-controls":`custom-provider-model-${r}-advanced`,className:"flex cursor-pointer items-center gap-1.5 text-sm font-medium text-text-primary",onClick:()=>i(r,{advancedExpanded:!s.advancedExpanded}),children:[e.jsx(P,{name:"chevron-down",className:L("size-4 text-text-secondary transition-transform",s.advancedExpanded?"":"-rotate-90")}),"Advanced"]}),s.advancedExpanded?e.jsxs("div",{id:`custom-provider-model-${r}-advanced`,className:"mt-3 space-y-4 pl-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-context-length`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Context length",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-context-length`,type:"number",min:1,inputMode:"numeric",value:s.contextLength,onChange:t=>i(r,{contextLength:t.target.value}),onBlur:()=>i(r,{contextTouched:!0}),placeholder:ke,"aria-invalid":z?!0:void 0,className:L(Q,z&&V)}),z?e.jsx(ee,{children:le}):s.contextLength.trim()===""?e.jsx(ne,{children:"Model's total token window."}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-max-output-tokens`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Max output tokens",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-max-output-tokens`,type:"number",min:1,inputMode:"numeric",value:s.maxOutputTokens,onChange:t=>i(r,{maxOutputTokens:t.target.value}),onBlur:()=>i(r,{maxTouched:!0}),placeholder:Ee,"aria-invalid":ae?!0:void 0,className:L(Q,ae&&V)}),ae?e.jsx(ee,{children:C}):s.maxOutputTokens.trim()===""?e.jsx(ne,{children:"Longest reply the model allows — use its real limit."}):null]}),k&&k.length>0?e.jsxs("div",{children:[e.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 select-none",children:[e.jsx("input",{type:"checkbox",className:"size-4 shrink-0 cursor-pointer accent-primary-button-bg disabled:cursor-not-allowed disabled:opacity-50",checked:s.reasoningEfforts!==void 0,"aria-label":`Enable reasoning effort for model ${r+1}`,disabled:p,onChange:t=>i(r,{reasoningEfforts:t.target.checked?[]:void 0})}),e.jsx("span",{className:"text-text-secondary text-xs font-medium",children:"Reasoning effort"})]}),s.reasoningEfforts!==void 0?e.jsx("div",{role:"group","aria-label":`Supported reasoning efforts for model ${r+1}`,className:"mt-2 flex flex-wrap gap-2",children:k.map(t=>{var m;const a=((m=s.reasoningEfforts)==null?void 0:m.includes(t))??!1;return e.jsx("button",{type:"button","aria-pressed":a,disabled:p,className:L("rounded-full border px-3 py-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/40 disabled:opacity-50",a?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-border text-text-secondary hover:bg-ghost-button-hover"),onClick:()=>{var J;return i(r,{reasoningEfforts:a?(J=s.reasoningEfforts)==null?void 0:J.filter(de=>de!==t):[...s.reasoningEfforts??[],t]})},children:t},t)})}):null]}):null]}):null]})]},r)})}),e.jsxs(B,{variant:"secondary",size:"sm",type:"button",className:"mt-4 w-fit",onClick:()=>w(s=>[...s,pe()]),children:[e.jsx(P,{name:"plus",className:"size-3.5"}),"Add model"]})]})]}),e.jsxs("div",{className:"shrink-0 space-y-3 border-t border-border px-5 py-4",children:[E?e.jsx("p",{className:"text-failure-bg text-sm",children:E}):null,e.jsx(B,{type:"submit",size:"lg",disabled:!oe||p,className:"w-full",children:d?"Save changes":"Add provider"})]})]})})},Ue=Me;function Te(n){return"baseUrl"in n&&typeof n.baseUrl=="string"?n.baseUrl:""}var Le=()=>{const{modelCatalog:n}=be(),l=fe(),[b,k]=o.useState(""),[p,E]=o.useState([]),[d,c]=o.useState([]),[S,O]=o.useState(!0),[F,M]=o.useState(null),[$,y]=o.useState(null),[x,w]=o.useState(!1),[A,U]=o.useState(null),[X,T]=o.useState(null),[G,v]=o.useState(null),[i,K]=o.useState(!1),[f,D]=o.useState(null),_=o.useMemo(()=>(d??[]).reduce((t,a)=>(t[a.name]=a.logo??"",t),{}),[d]),h=b.trim().toLowerCase(),W=o.useCallback(async()=>{O(!0),M(null);try{const[t,a]=await Promise.all([n.listModelProviders(),n.getModelProviderCatalog()]);E(t),c(a)}catch(t){M(Y(t,"Failed to load model providers"))}finally{O(!1)}},[n]);o.useEffect(()=>{W()},[W]);const te=o.useMemo(()=>new Set(p.map(t=>t.type)),[p]),q=o.useMemo(()=>p.filter(t=>{var a;return((a=t.name)==null?void 0:a.toLowerCase().includes(h))||t.models.some(m=>m.name.toLowerCase().includes(h)||m.id.toLowerCase().includes(h))}),[p,h]),Z=o.useMemo(()=>d.filter(t=>t.type!=="custom"&&!te.has(t.type)&&(t.name.toLowerCase().includes(h)||t.models.some(a=>a.name.toLowerCase().includes(h)||a.id.toLowerCase().includes(h)))),[d,te,h]),oe=o.useMemo(()=>{var t;return(t=d.find(a=>a.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[d]),se=o.useMemo(()=>{const t=new Map;for(const a of d)t.set(a.type,a.models);return t},[d]),H=()=>{U(null),T(null),v(null)},I=async(t,a)=>{w(!0),M(null);try{await t(),await W(),H()}catch(m){throw a?a(m):l==null?M(Y(m,"Request failed")):l.showError(m),m}finally{w(!1)}},s=async(t,a)=>{v(null),await I(async()=>{await n.createModelProvider({type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed")))},r=async(t,a)=>{v(null),await I(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed"))),l==null||l.showSuccess({title:`${t.name} updated`})},g=t=>{n.deleteModelProvider&&I(async()=>{await n.deleteModelProvider({id:t.id})}).catch(()=>{})},u=(t,a)=>{I(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...t.baseUrl?{baseUrl:t.baseUrl}:{},apiKey:"",models:a})}).catch(()=>{})},j=async t=>{y(null),await I(async()=>{await n.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},a=>y(Y(a,"Request failed"))),setTimeout(()=>{l==null||l.showSuccess({title:`${t.name} added`})},0)},R=async t=>{if(!f)return;const a=f;y(null),await I(async()=>{await n.updateModelProvider({id:a.id,type:a.type,name:a.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},m=>y(Y(m,"Request failed"))),setTimeout(()=>{l==null||l.showSuccess({title:"Model provider updated",description:`${a.name} was updated successfully.`})},0)},le=f?{name:f.name,baseUrl:f.baseUrl??"",models:f.models}:void 0,C=A!=null?p.find(t=>t.id===A)??null:null,z=X!=null?d.find(t=>t.type===X)??null:null,ae=C!=null||z!=null;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Models"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect providers and choose which models are available."}),F?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:F}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(ge,{query:b,setQuery:k,placeholder:"Search providers and models"})}),e.jsxs(B,{variant:"secondary",type:"button",onClick:()=>{y(null),D(null),K(!0)},children:[e.jsx(P,{name:"plus",size:"1rem",className:"mr-1"}),"Add Custom Provider"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto",children:[S?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!S&&q.length>0?e.jsxs("section",{"aria-labelledby":"configured-providers-heading",children:[e.jsx("div",{id:"configured-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Configured"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:q.map(t=>{const a=se.get(t.type)??[],m=new Set(t.models.map(N=>N.id)),J=a.filter(N=>!m.has(N.id)),de=_[t.name];return e.jsxs("article",{className:"border-b border-border p-3 last:border-b-0",children:[e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:de?e.jsx(ie,{src:de,alt:t.name,className:"size-4.5"}):e.jsx(P,{name:"cpu",className:"size-4.5"})}),e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-success-bg",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success-bg"}),"Connected"]}),e.jsxs(B,{variant:"secondary",size:"sm",className:"text-[0.8125rem]",type:"button","aria-label":`Edit ${t.name}`,title:`Edit ${t.name}`,disabled:x,onClick:()=>{t.type==="custom"?(H(),y(null),D(t),K(!0)):(v(null),T(null),U(t.id))},children:[e.jsx(P,{name:"wrench",className:"size-3.5"}),"Edit"]}),n.deleteModelProvider?e.jsx(B,{variant:"outline",size:"sm",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:x,onClick:()=>{g(t)},children:"Remove"}):null]})]}),e.jsxs("div",{className:"mt-3 overflow-hidden rounded-lg border border-border bg-secondary-bg/30",children:[t.models.map(N=>e.jsxs("div",{className:"flex min-h-10 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx("button",{type:"button","aria-label":`Remove ${N.name}`,disabled:x,className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring disabled:opacity-50",onClick:()=>{u(t,t.models.filter(he=>he.id!==N.id))},children:e.jsx(P,{name:"trash",className:"size-3.5"})})]},N.id)),J.length>0?e.jsxs("section",{children:[e.jsxs("div",{className:"border-b border-border bg-secondary-bg/40 px-3 py-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available to add · ",J.length]}),J.map(N=>e.jsxs("div",{className:"flex min-h-12 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx(B,{variant:"outline",size:"sm",type:"button",disabled:x,onClick:()=>{u(t,[...t.models,N])},children:"Add"})]},N.id))]}):null]})]},t.id)})})]}):null,!S&&Z.length>0?e.jsxs("section",{"aria-labelledby":"available-providers-heading",className:"mt-2",children:[e.jsx("div",{id:"available-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Available"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:Z.map(t=>{const a=_[t.name];return e.jsx("article",{className:"border-b border-border p-3 last:border-b-0",children:e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:a?e.jsx(ie,{src:a,alt:t.name,className:"size-4.5"}):e.jsx(P,{name:"cpu",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:t.models.map(m=>m.name).join(" · ")})]})]}),e.jsxs(B,{variant:"secondary",type:"button",disabled:x,onClick:()=>{v(null),U(null),T(t.type)},children:[e.jsx(P,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!S&&q.length===0&&Z.length===0?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:h?`No providers match “${b.trim()}”.`:"No model providers yet."}):null]}),e.jsx(Ce,{open:ae,onOpenChange:t=>{t||H()},onSave:t=>{if(C)return r(C,t);if(z)return s(z,t)},title:C?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:C?C.baseUrl??"":z?Te(z):"",requireApiKey:C==null,submitLabel:C?"Save":"Create",busy:x,error:G}),e.jsx(Ue,{open:i,onOpenChange:t=>{K(t),t||(y(null),D(null))},isEditMode:f!==null,initialValues:le,onSubmit:f?R:j,reasoningEffortOptions:oe,busy:x,error:$},(f==null?void 0:f.id)??"add-custom-provider")]})})]})},ze=Le;export{ze as default};
|
|
1
|
+
import{n as be,o as fe,r as o,p as Y,j as e,q as ge,B,I as P,s as ie,t as xe,A as ye,v as ve,e as L,w as je,x as Ne}from"./index-DJ1uWGdt.js";var me=Ne("h-11 shadow-sm"),we=({open:n,onOpenChange:l,onSave:b,title:k,description:p,initialBaseUrl:E="",baseUrlPlaceholder:d="https://api.openai.com/v1",requireApiKey:c=!0,submitLabel:S="Save",busy:O=!1,error:F})=>{const[M,$]=o.useState(""),[y,x]=o.useState(""),[w,A]=o.useState(!1),U=()=>{$(""),x(""),A(!1)};o.useEffect(()=>{n&&($(""),x(E),A(!1))},[n,E]);const X=i=>{i||U(),l(i)},T=M.trim(),G=!c||!!T,v=async i=>{if(i.preventDefault(),!(!G||O))try{await b({apiKey:T,baseUrl:y.trim()}),U(),l(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:X,title:k,description:p,contentSized:!0,children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:v,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"model-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",c?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"model-provider-api-key",type:"password",required:c,value:M,onChange:i=>{$(i.target.value)},placeholder:c?"Enter API key":"Enter a new key",autoFocus:!0,className:me}),c?null:e.jsx("p",{className:"mt-1.5 text-xs text-text-secondary",children:"Leave blank to keep the current key; enter a new one to replace it."})]}),e.jsxs(ye,{expanded:w,onChange:(i,K)=>A(K),className:"rounded-md border border-border",children:[e.jsx(ve,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced · custom endpoint",e.jsx(P,{name:"chevron-down",className:L("size-4 shrink-0 text-text-secondary transition-transform duration-200",w?"rotate-0":"-rotate-90")})]})}),e.jsxs(je,{className:"space-y-1.5 border-t border-border px-3 pb-3 pt-4",children:[e.jsx("label",{htmlFor:"model-provider-base-url",className:"block text-sm font-medium text-text-primary",children:"Base URL"}),e.jsx("input",{id:"model-provider-base-url",type:"url",value:y,onChange:i=>{x(i.target.value)},placeholder:d,className:me}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Leave blank unless you use a regional or proxy endpoint."})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[F?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsx(B,{type:"submit",size:"lg",disabled:!G||O,className:"w-full shrink-0",children:S})]})]})})},Ce=we,ke="128000",Ee="4096",pe=()=>({id:"",name:"",advancedExpanded:!0,contextLength:"",maxOutputTokens:""}),ue=n=>(n==null?void 0:n.models.map(l=>{var b,k,p,E,d;return{id:l.id,name:l.name,advancedExpanded:!0,reasoningEfforts:(b=l.properties)==null?void 0:b.reasoningEfforts,contextLength:((p=(k=l.properties)==null?void 0:k.contextLength)==null?void 0:p.toString())??"",maxOutputTokens:((d=(E=l.properties)==null?void 0:E.maxOutputTokens)==null?void 0:d.toString())??"",nameDirty:!0}}))??[pe()],Q="h-11 w-full rounded-md border border-border/70 bg-secondary-bg px-3 text-sm text-text-primary outline-none transition-colors placeholder:text-text-secondary/70 focus-visible:border-focus-ring focus-visible:ring-2 focus-visible:ring-focus-ring/50",V="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function ce(n){const l=n.trim();if(l==="")return null;const b=Number(l);return Number.isInteger(b)&&b>0?b:null}function Se(n){return n.replace(/([a-zA-Z])(\d)/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").slice(0,64).replace(/-+$/g,"")}var re=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),ee=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-failure-bg",children:n}),ne=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:n}),Me=({open:n,onOpenChange:l,onSubmit:b,reasoningEffortOptions:k,busy:p=!1,error:E,isEditMode:d=!1,initialValues:c})=>{const[S,O]=o.useState((c==null?void 0:c.name)??""),[F,M]=o.useState((c==null?void 0:c.baseUrl)??""),[$,y]=o.useState(""),[x,w]=o.useState(()=>ue(c)),[A,U]=o.useState(!1),[X,T]=o.useState(!1),G=()=>{O((c==null?void 0:c.name)??""),M((c==null?void 0:c.baseUrl)??""),y(""),w(ue(c)),U(!1),T(!1)},v=s=>{s||G(),l(s)},i=(s,r)=>{w(g=>g.map((u,j)=>j===s?{...u,...r}:u))},K=()=>{U(!0),T(!0),w(s=>s.map(r=>({...r,idTouched:!0,contextTouched:!0,maxTouched:!0})))},f=S.trim(),D=f?null:"Name is required.",_=F.trim();let h=null;if(!_)h="Base URL is required.";else try{new URL(_)}catch{h="Enter a valid URL."}const W=s=>s.id.trim()?null:"Model ID is required.",te=s=>s.name.trim()?null:"Model name is required.",q=s=>ce(s.contextLength)==null?"Set the model's context window.":null,Z=s=>ce(s.maxOutputTokens)==null?"Set the max output tokens.":null,oe=!D&&!h&&x.every(s=>!W(s)&&!te(s)),se=A&&D,H=X&&h,I=async()=>{if(K(),!oe||p)return;const s=x.findIndex(r=>q(r)||Z(r));if(s!==-1){i(s,{advancedExpanded:!0});const r=x[s],g=r&&q(r)?"context-length":"max-output-tokens";setTimeout(()=>{var j;const u=document.getElementById(`custom-provider-model-${s}-${g}`);(j=u==null?void 0:u.scrollIntoView)==null||j.call(u,{block:"center",behavior:"smooth"}),u==null||u.focus()},0);return}try{await b({name:f,baseUrl:_,apiKey:$.trim(),models:x.map(r=>{var R;const g={};(R=r.reasoningEfforts)!=null&&R.length&&(g.reasoningEfforts=r.reasoningEfforts);const u=ce(r.contextLength);u!=null&&(g.contextLength=u);const j=ce(r.maxOutputTokens);return j!=null&&(g.maxOutputTokens=j),{id:r.id.trim(),name:r.name.trim(),...Object.keys(g).length>0?{properties:g}:{}}})}),v(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:v,title:d?`Edit ${(c==null?void 0:c.name)??S}`:"Add custom provider",description:d?"Update the endpoint, credentials, and models for this provider.":"Connect any OpenAI-compatible endpoint, whether it's a local model, a proxy, or your own hosted service.",contentSized:!0,children:e.jsxs("form",{className:"flex min-h-0 flex-1 flex-col",onSubmit:s=>{s.preventDefault(),I()},children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto px-5 pt-4 pb-8",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:S,onChange:s=>O(s.target.value),onBlur:()=>U(!0),placeholder:"local-llama",autoFocus:!d,readOnly:d,"aria-readonly":d,"aria-invalid":se?!0:void 0,className:L(Q,d&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",se&&V)}),d?e.jsx(ne,{children:"Provider names cannot be changed after creation."}):null,se?e.jsx(ee,{children:D}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-base-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Base URL",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-base-url",type:"text",value:F,onChange:s=>M(s.target.value),onBlur:()=>T(!0),placeholder:"http://localhost:11434/v1",autoFocus:d,"aria-invalid":H?!0:void 0,className:L(Q,H&&V)}),H?e.jsx(ee,{children:h}):_?null:e.jsx(ne,{children:"OpenAI-compatible endpoint, usually ending in /v1."})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"custom-provider-api-key",type:"password",value:$,onChange:s=>y(s.target.value),placeholder:"sk-…",className:Q}),e.jsx(ne,{children:d?"Leave blank to keep the saved key, or enter a new key to replace it.":"Leave blank if your endpoint needs no key (e.g. a local model)."})]}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0",children:[e.jsxs("legend",{className:"float-left mb-2 w-full p-0 text-sm font-medium text-text-primary",children:["Models",e.jsx(re,{})]}),e.jsx("div",{className:"clear-both",children:x.map((s,r)=>{const g=W(s),u=s.idTouched&&g,j=te(s),R=!!j&&s.nameDirty,le=q(s),C=Z(s),z=s.contextTouched&&le,ae=s.maxTouched&&C;return e.jsxs("div",{className:L("pb-6",r>0?"border-t border-border pt-6":"pt-1"),style:r>0?{borderTopWidth:"0.5px"}:void 0,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_2rem] items-end gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-id`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model ID"}),e.jsx("input",{id:`custom-provider-model-${r}-id`,type:"text",value:s.id,onChange:t=>{const a=t.target.value;i(r,{id:a,...s.nameDirty?{}:{name:Se(a)}})},onBlur:()=>i(r,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":u?!0:void 0,className:L(Q,"font-mono",u&&V)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-name`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model name"}),e.jsx("input",{id:`custom-provider-model-${r}-name`,type:"text",value:s.name,onChange:t=>i(r,{name:t.target.value,nameDirty:!0}),placeholder:"llama-3-1-70b","aria-invalid":R?!0:void 0,className:L(Q,R&&V)})]}),e.jsx("button",{type:"button","aria-label":`Remove model ${r+1}`,disabled:x.length===1||p,className:"mb-0.5 flex size-9 items-center justify-center rounded-md text-text-secondary transition-colors hover:text-text-primary disabled:opacity-40",onClick:()=>w(t=>t.filter((a,m)=>m!==r)),children:e.jsx(P,{name:"trash",className:"size-4"})})]}),u?e.jsx(ee,{children:g}):null,R?e.jsx(ee,{children:j}):null,e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button","aria-expanded":s.advancedExpanded,"aria-controls":`custom-provider-model-${r}-advanced`,className:"flex cursor-pointer items-center gap-1.5 text-sm font-medium text-text-primary",onClick:()=>i(r,{advancedExpanded:!s.advancedExpanded}),children:[e.jsx(P,{name:"chevron-down",className:L("size-4 text-text-secondary transition-transform",s.advancedExpanded?"":"-rotate-90")}),"Advanced"]}),s.advancedExpanded?e.jsxs("div",{id:`custom-provider-model-${r}-advanced`,className:"mt-3 space-y-4 pl-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-context-length`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Context length",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-context-length`,type:"number",min:1,inputMode:"numeric",value:s.contextLength,onChange:t=>i(r,{contextLength:t.target.value}),onBlur:()=>i(r,{contextTouched:!0}),placeholder:ke,"aria-invalid":z?!0:void 0,className:L(Q,z&&V)}),z?e.jsx(ee,{children:le}):s.contextLength.trim()===""?e.jsx(ne,{children:"Model's total token window."}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-max-output-tokens`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Max output tokens",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-max-output-tokens`,type:"number",min:1,inputMode:"numeric",value:s.maxOutputTokens,onChange:t=>i(r,{maxOutputTokens:t.target.value}),onBlur:()=>i(r,{maxTouched:!0}),placeholder:Ee,"aria-invalid":ae?!0:void 0,className:L(Q,ae&&V)}),ae?e.jsx(ee,{children:C}):s.maxOutputTokens.trim()===""?e.jsx(ne,{children:"Longest reply the model allows — use its real limit."}):null]}),k&&k.length>0?e.jsxs("div",{children:[e.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 select-none",children:[e.jsx("input",{type:"checkbox",className:"size-4 shrink-0 cursor-pointer accent-primary-button-bg disabled:cursor-not-allowed disabled:opacity-50",checked:s.reasoningEfforts!==void 0,"aria-label":`Enable reasoning effort for model ${r+1}`,disabled:p,onChange:t=>i(r,{reasoningEfforts:t.target.checked?[]:void 0})}),e.jsx("span",{className:"text-text-secondary text-xs font-medium",children:"Reasoning effort"})]}),s.reasoningEfforts!==void 0?e.jsx("div",{role:"group","aria-label":`Supported reasoning efforts for model ${r+1}`,className:"mt-2 flex flex-wrap gap-2",children:k.map(t=>{var m;const a=((m=s.reasoningEfforts)==null?void 0:m.includes(t))??!1;return e.jsx("button",{type:"button","aria-pressed":a,disabled:p,className:L("rounded-full border px-3 py-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/40 disabled:opacity-50",a?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-border text-text-secondary hover:bg-ghost-button-hover"),onClick:()=>{var J;return i(r,{reasoningEfforts:a?(J=s.reasoningEfforts)==null?void 0:J.filter(de=>de!==t):[...s.reasoningEfforts??[],t]})},children:t},t)})}):null]}):null]}):null]})]},r)})}),e.jsxs(B,{variant:"secondary",size:"sm",type:"button",className:"mt-4 w-fit",onClick:()=>w(s=>[...s,pe()]),children:[e.jsx(P,{name:"plus",className:"size-3.5"}),"Add model"]})]})]}),e.jsxs("div",{className:"shrink-0 space-y-3 border-t border-border px-5 py-4",children:[E?e.jsx("p",{className:"text-failure-bg text-sm",children:E}):null,e.jsx(B,{type:"submit",size:"lg",disabled:!oe||p,className:"w-full",children:d?"Save changes":"Add provider"})]})]})})},Ue=Me;function Te(n){return"baseUrl"in n&&typeof n.baseUrl=="string"?n.baseUrl:""}var Le=()=>{const{modelCatalog:n}=be(),l=fe(),[b,k]=o.useState(""),[p,E]=o.useState([]),[d,c]=o.useState([]),[S,O]=o.useState(!0),[F,M]=o.useState(null),[$,y]=o.useState(null),[x,w]=o.useState(!1),[A,U]=o.useState(null),[X,T]=o.useState(null),[G,v]=o.useState(null),[i,K]=o.useState(!1),[f,D]=o.useState(null),_=o.useMemo(()=>(d??[]).reduce((t,a)=>(t[a.name]=a.logo??"",t),{}),[d]),h=b.trim().toLowerCase(),W=o.useCallback(async()=>{O(!0),M(null);try{const[t,a]=await Promise.all([n.listModelProviders(),n.getModelProviderCatalog()]);E(t),c(a)}catch(t){M(Y(t,"Failed to load model providers"))}finally{O(!1)}},[n]);o.useEffect(()=>{W()},[W]);const te=o.useMemo(()=>new Set(p.map(t=>t.type)),[p]),q=o.useMemo(()=>p.filter(t=>{var a;return((a=t.name)==null?void 0:a.toLowerCase().includes(h))||t.models.some(m=>m.name.toLowerCase().includes(h)||m.id.toLowerCase().includes(h))}),[p,h]),Z=o.useMemo(()=>d.filter(t=>t.type!=="custom"&&!te.has(t.type)&&(t.name.toLowerCase().includes(h)||t.models.some(a=>a.name.toLowerCase().includes(h)||a.id.toLowerCase().includes(h)))),[d,te,h]),oe=o.useMemo(()=>{var t;return(t=d.find(a=>a.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[d]),se=o.useMemo(()=>{const t=new Map;for(const a of d)t.set(a.type,a.models);return t},[d]),H=()=>{U(null),T(null),v(null)},I=async(t,a)=>{w(!0),M(null);try{await t(),await W(),H()}catch(m){throw a?a(m):l==null?M(Y(m,"Request failed")):l.showError(m),m}finally{w(!1)}},s=async(t,a)=>{v(null),await I(async()=>{await n.createModelProvider({type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed")))},r=async(t,a)=>{v(null),await I(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed"))),l==null||l.showSuccess({title:`${t.name} updated`})},g=t=>{n.deleteModelProvider&&I(async()=>{await n.deleteModelProvider({id:t.id})}).catch(()=>{})},u=(t,a)=>{I(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...t.baseUrl?{baseUrl:t.baseUrl}:{},apiKey:"",models:a})}).catch(()=>{})},j=async t=>{y(null),await I(async()=>{await n.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},a=>y(Y(a,"Request failed"))),setTimeout(()=>{l==null||l.showSuccess({title:`${t.name} added`})},0)},R=async t=>{if(!f)return;const a=f;y(null),await I(async()=>{await n.updateModelProvider({id:a.id,type:a.type,name:a.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},m=>y(Y(m,"Request failed"))),setTimeout(()=>{l==null||l.showSuccess({title:"Model provider updated",description:`${a.name} was updated successfully.`})},0)},le=f?{name:f.name,baseUrl:f.baseUrl??"",models:f.models}:void 0,C=A!=null?p.find(t=>t.id===A)??null:null,z=X!=null?d.find(t=>t.type===X)??null:null,ae=C!=null||z!=null;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Models"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect providers and choose which models are available."}),F?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:F}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(ge,{query:b,setQuery:k,placeholder:"Search providers and models"})}),e.jsxs(B,{variant:"secondary",type:"button",onClick:()=>{y(null),D(null),K(!0)},children:[e.jsx(P,{name:"plus",size:"1rem",className:"mr-1"}),"Add Custom Provider"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto",children:[S?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!S&&q.length>0?e.jsxs("section",{"aria-labelledby":"configured-providers-heading",children:[e.jsx("div",{id:"configured-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Configured"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:q.map(t=>{const a=se.get(t.type)??[],m=new Set(t.models.map(N=>N.id)),J=a.filter(N=>!m.has(N.id)),de=_[t.name];return e.jsxs("article",{className:"border-b border-border p-3 last:border-b-0",children:[e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:de?e.jsx(ie,{src:de,alt:t.name,className:"size-4.5"}):e.jsx(P,{name:"cpu",className:"size-4.5"})}),e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-success-bg",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success-bg"}),"Connected"]}),e.jsxs(B,{variant:"secondary",size:"sm",className:"text-[0.8125rem]",type:"button","aria-label":`Edit ${t.name}`,title:`Edit ${t.name}`,disabled:x,onClick:()=>{t.type==="custom"?(H(),y(null),D(t),K(!0)):(v(null),T(null),U(t.id))},children:[e.jsx(P,{name:"wrench",className:"size-3.5"}),"Edit"]}),n.deleteModelProvider?e.jsx(B,{variant:"outline",size:"sm",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:x,onClick:()=>{g(t)},children:"Remove"}):null]})]}),e.jsxs("div",{className:"mt-3 overflow-hidden rounded-lg border border-border bg-secondary-bg/30",children:[t.models.map(N=>e.jsxs("div",{className:"flex min-h-10 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx("button",{type:"button","aria-label":`Remove ${N.name}`,disabled:x,className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring disabled:opacity-50",onClick:()=>{u(t,t.models.filter(he=>he.id!==N.id))},children:e.jsx(P,{name:"trash",className:"size-3.5"})})]},N.id)),J.length>0?e.jsxs("section",{children:[e.jsxs("div",{className:"border-b border-border bg-secondary-bg/40 px-3 py-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available to add · ",J.length]}),J.map(N=>e.jsxs("div",{className:"flex min-h-12 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx(B,{variant:"outline",size:"sm",type:"button",disabled:x,onClick:()=>{u(t,[...t.models,N])},children:"Add"})]},N.id))]}):null]})]},t.id)})})]}):null,!S&&Z.length>0?e.jsxs("section",{"aria-labelledby":"available-providers-heading",className:"mt-2",children:[e.jsx("div",{id:"available-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Available"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:Z.map(t=>{const a=_[t.name];return e.jsx("article",{className:"border-b border-border p-3 last:border-b-0",children:e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:a?e.jsx(ie,{src:a,alt:t.name,className:"size-4.5"}):e.jsx(P,{name:"cpu",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:t.models.map(m=>m.name).join(" · ")})]})]}),e.jsxs(B,{variant:"secondary",type:"button",disabled:x,onClick:()=>{v(null),U(null),T(t.type)},children:[e.jsx(P,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!S&&q.length===0&&Z.length===0?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:h?`No providers match “${b.trim()}”.`:"No model providers yet."}):null]}),e.jsx(Ce,{open:ae,onOpenChange:t=>{t||H()},onSave:t=>{if(C)return r(C,t);if(z)return s(z,t)},title:C?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:C?C.baseUrl??"":z?Te(z):"",requireApiKey:C==null,submitLabel:C?"Save":"Create",busy:x,error:G}),e.jsx(Ue,{open:i,onOpenChange:t=>{K(t),t||(y(null),D(null))},isEditMode:f!==null,initialValues:le,onSubmit:f?R:j,reasoningEffortOptions:oe,busy:x,error:$},(f==null?void 0:f.id)??"add-custom-provider")]})})]})},ze=Le;export{ze as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as G,o as H,r,p as q,j as e,S as Y,I as N,z as J,B as R,t as Q,A as W,v as X,e as Z,w as ee,x as te}from"./index-BRS0kvLQ.js";var se={execTimeoutMs:3e5,autoStopIntervalInMinutes:15,autoArchiveIntervalInMinutes:10080,autoDeleteIntervalInMinutes:43200},F=te("h-11 shadow-sm");function U(s){if(s.trim()==="")return null;const l=Number(s);return!Number.isFinite(l)||l<0?null:l}var ae=({open:s,onOpenChange:l,onSave:d,title:g,description:I,initialConfig:_=null,requireApiKey:y=!0,busy:w=!1,error:C})=>{const[m,k]=r.useState(""),[u,x]=r.useState(""),[M,i]=r.useState(""),[h,o]=r.useState(""),[b,f]=r.useState(""),[A,v]=r.useState(!1),S=()=>{k(""),x(""),i(""),o(""),f(""),v(!1)};r.useEffect(()=>{if(!s)return;const a=_??se;k(String(a.execTimeoutMs)),x(String(a.autoStopIntervalInMinutes)),i(String(a.autoArchiveIntervalInMinutes)),o(String(a.autoDeleteIntervalInMinutes)),f(""),v(!1)},[s,_]);const B=a=>{a||S(),l(a)},p=U(m),P=U(u),T=U(M),z=U(h),D=b.trim(),K=(!y||!!D)&&p!=null&&P!=null&&T!=null&&z!=null,E=async a=>{if(a.preventDefault(),!(!K||w||p==null||P==null||T==null||z==null))try{await d({execTimeoutMs:p,autoStopIntervalInMinutes:P,autoArchiveIntervalInMinutes:T,autoDeleteIntervalInMinutes:z,apiKey:D}),S(),l(!1)}catch{}};return e.jsx(Q,{open:s,onOpenChange:B,title:g,description:I,contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(N,{name:"cube",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:E,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"sandbox-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",y?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"sandbox-api-key",type:"password",required:y,value:b,onChange:a=>{f(a.target.value)},placeholder:y?"dtn_...":"Leave blank to keep existing",autoFocus:!0,className:F})]}),e.jsxs(W,{expanded:A,onChange:(a,t)=>v(t),className:"rounded-md border border-border",children:[e.jsx(X,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced settings",e.jsx(N,{name:"chevron-down",className:Z("size-4 shrink-0 text-text-secondary transition-transform duration-200",A?"rotate-0":"-rotate-90")})]})}),e.jsxs(ee,{className:"space-y-4 border-t border-border px-3 pb-3 pt-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-exec-timeout",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Exec timeout (ms)"}),e.jsx("input",{id:"sandbox-exec-timeout",type:"number",min:0,required:!0,value:m,onChange:a=>{k(a.target.value)},placeholder:"300000",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-stop",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-stop interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-stop",type:"number",min:0,required:!0,value:u,onChange:a=>{x(a.target.value)},placeholder:"15",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-archive",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-archive interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-archive",type:"number",min:0,required:!0,value:M,onChange:a=>{i(a.target.value)},placeholder:"10080",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-delete",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-delete interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-delete",type:"number",min:0,required:!0,value:h,onChange:a=>{o(a.target.value)},placeholder:"43200",className:F})]})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[C?e.jsx("p",{className:"text-failure-bg text-sm",children:C}):null,e.jsx(R,{type:"submit",size:"lg",disabled:!K||w,className:"w-full shrink-0",children:"Save"})]})]})})},ne=ae,re=1e4,O=({execTimeoutMs:s,autoStopIntervalInMinutes:l,autoArchiveIntervalInMinutes:d,autoDeleteIntervalInMinutes:g})=>({execTimeoutMs:s,autoStopIntervalInMinutes:l,autoArchiveIntervalInMinutes:d,autoDeleteIntervalInMinutes:g}),le=s=>{switch(s){case"pending":return{label:"Syncing image...",className:"text-warning-bg"};case"ready":return{label:"Connected",className:"text-success-bg"};case"failed":return{label:"Sync failed",className:"text-failure-bg"};default:return{label:s,className:"text-text-secondary"}}},ie=()=>{const{sandboxCatalog:s}=G(),l=H(),[d,g]=r.useState([]),[I,_]=r.useState([]),[y,w]=r.useState(!0),[C,m]=r.useState(null),[k,u]=r.useState(null),[x,M]=r.useState(!1),[i,h]=r.useState(null),[o,b]=r.useState(null),f=r.useCallback(async({quiet:t=!1}={})=>{if(s){t||w(!0),m(null);try{const[n,c]=await Promise.all([s.listSandboxProviders(),s.getSandboxProviderCatalog()]);g(n),_(c)}catch(n){m(q(n,"Failed to load sandbox providers"))}finally{t||w(!1)}}},[s]);r.useEffect(()=>{f()},[f]);const A=d.some(t=>t.snapshotSyncStatus.status==="pending");r.useEffect(()=>{if(!s||!A)return;const t=s;let n=!1,c;function j(){c=window.setTimeout(()=>{$()},re)}async function $(){try{const L=await t.listSandboxProviders();if(n)return;g(L),m(null),L.some(V=>V.snapshotSyncStatus.status==="pending")&&j()}catch(L){if(n)return;m(q(L,"Failed to refresh sandbox providers")),j()}}return j(),()=>{n=!0,c!==void 0&&window.clearTimeout(c)}},[s,A]);const v=d.length>0,S=r.useMemo(()=>{if(v)return[];const t=new Set(d.map(n=>n.data.catalogId));return I.filter(n=>!t.has(n.id))},[I,d,v]),B=r.useMemo(()=>o?O(o):i?O(i):null,[o,i]);if(!s)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Sandbox provider catalog is not available."});const p=async(t,n=m)=>{M(!0),m(null);try{await t(),await f({quiet:!0})}catch(c){throw n(q(c,"Request failed")),c}finally{M(!1)}},P=async t=>{i&&(u(null),await p(async()=>{await s.createSandboxProvider({catalogId:i.id,name:i.name,type:i.type,...O(t),apiKey:t.apiKey})},u),h(null),setTimeout(()=>{l==null||l.showSuccess({title:`${i.name} configured`})},0))},T=async t=>{o&&(u(null),await p(async()=>{await s.updateSandboxProvider({id:o.id,...O(t),...t.apiKey?{apiKey:t.apiKey}:{}})},u),b(null),setTimeout(()=>{l==null||l.showSuccess({title:`${o.name} updated`})},0))},z=t=>{p(async()=>{await s.updateSandboxProvider({id:t.id,...O(t)})}).catch(()=>{})},D=t=>{const n=s.deleteSandboxProvider;n&&p(async()=>{await n({id:t.id})}).catch(()=>{})},K=i!=null||o!=null,E=o!=null,a=o?`Update ${o.name}`:i?`Configure ${i.name}`:"Configure sandbox provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Sandbox providers"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Choose a provider that runs sandboxes for code, files and shell commands. Only one can be active at a time."}),C?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:C}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:y?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading sandbox providers…"}):e.jsxs("div",{className:"space-y-6",children:[d.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",d.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:d.map(t=>{const n=t.data,c=le(t.snapshotSyncStatus.status),j=t.snapshotSyncStatus.statusReason,$=e.jsxs("span",{className:`inline-flex items-center gap-1.5 text-sm font-medium ${c.className}`,children:[t.snapshotSyncStatus.status==="pending"?e.jsx(Y,{size:16,"aria-label":"Syncing snapshot image"}):t.snapshotSyncStatus.status==="ready"?e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}):t.snapshotSyncStatus.status==="failed"?e.jsx(N,{name:"triangle-exclamation",className:"size-4"}):null,c.label]});return e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(N,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:n.name})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[$,j?e.jsx(J,{content:j,children:e.jsx("button",{type:"button","aria-label":"Snapshot sync status details",className:"inline-flex text-text-secondary transition-colors hover:text-text-primary",children:e.jsx(N,{name:"info",className:"size-4"})})}):null,t.snapshotSyncStatus.status==="failed"?e.jsx(R,{variant:"ghost",size:"sm",type:"button",disabled:x,onClick:()=>{z(n)},children:"Retry"}):null,e.jsx(R,{variant:"secondary",size:"sm",type:"button",disabled:x,onClick:()=>{u(null),h(null),b(n)},children:"Update"}),s.deleteSandboxProvider?e.jsx(R,{variant:"ghost",size:"sm",className:"text-text-secondary",type:"button",disabled:x,onClick:()=>{D(n)},children:"Remove"}):null]})]},n.id)})})]}):null,v?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",S.length]}),S.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:I.length>0?"All catalog providers are configured.":"No sandbox providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:S.map(t=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(N,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name})})]}),e.jsx(R,{variant:"secondary",type:"button",disabled:x,onClick:()=>{u(null),b(null),h(t)},children:"Configure"})]},t.id))})]})]})}),e.jsx(ne,{open:K,onOpenChange:t=>{t||(u(null),h(null),b(null))},onSave:E?T:P,title:a,description:E?"Update this sandbox provider. Leave API key blank to keep the existing key.":"Configure this sandbox provider. API key is never stored in the catalog.",initialConfig:B,requireApiKey:!E,busy:x,error:k})]})},de=ie;export{de as default};
|
|
1
|
+
import{n as G,o as H,r,p as q,j as e,S as Y,I as N,z as J,B as R,t as Q,A as W,v as X,e as Z,w as ee,x as te}from"./index-DJ1uWGdt.js";var se={execTimeoutMs:3e5,autoStopIntervalInMinutes:15,autoArchiveIntervalInMinutes:10080,autoDeleteIntervalInMinutes:43200},F=te("h-11 shadow-sm");function U(s){if(s.trim()==="")return null;const l=Number(s);return!Number.isFinite(l)||l<0?null:l}var ae=({open:s,onOpenChange:l,onSave:d,title:g,description:I,initialConfig:_=null,requireApiKey:y=!0,busy:w=!1,error:C})=>{const[m,k]=r.useState(""),[u,x]=r.useState(""),[M,i]=r.useState(""),[h,o]=r.useState(""),[b,f]=r.useState(""),[A,v]=r.useState(!1),S=()=>{k(""),x(""),i(""),o(""),f(""),v(!1)};r.useEffect(()=>{if(!s)return;const a=_??se;k(String(a.execTimeoutMs)),x(String(a.autoStopIntervalInMinutes)),i(String(a.autoArchiveIntervalInMinutes)),o(String(a.autoDeleteIntervalInMinutes)),f(""),v(!1)},[s,_]);const B=a=>{a||S(),l(a)},p=U(m),P=U(u),T=U(M),z=U(h),D=b.trim(),K=(!y||!!D)&&p!=null&&P!=null&&T!=null&&z!=null,E=async a=>{if(a.preventDefault(),!(!K||w||p==null||P==null||T==null||z==null))try{await d({execTimeoutMs:p,autoStopIntervalInMinutes:P,autoArchiveIntervalInMinutes:T,autoDeleteIntervalInMinutes:z,apiKey:D}),S(),l(!1)}catch{}};return e.jsx(Q,{open:s,onOpenChange:B,title:g,description:I,contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(N,{name:"cube",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:E,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"sandbox-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",y?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"sandbox-api-key",type:"password",required:y,value:b,onChange:a=>{f(a.target.value)},placeholder:y?"dtn_...":"Leave blank to keep existing",autoFocus:!0,className:F})]}),e.jsxs(W,{expanded:A,onChange:(a,t)=>v(t),className:"rounded-md border border-border",children:[e.jsx(X,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced settings",e.jsx(N,{name:"chevron-down",className:Z("size-4 shrink-0 text-text-secondary transition-transform duration-200",A?"rotate-0":"-rotate-90")})]})}),e.jsxs(ee,{className:"space-y-4 border-t border-border px-3 pb-3 pt-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-exec-timeout",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Exec timeout (ms)"}),e.jsx("input",{id:"sandbox-exec-timeout",type:"number",min:0,required:!0,value:m,onChange:a=>{k(a.target.value)},placeholder:"300000",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-stop",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-stop interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-stop",type:"number",min:0,required:!0,value:u,onChange:a=>{x(a.target.value)},placeholder:"15",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-archive",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-archive interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-archive",type:"number",min:0,required:!0,value:M,onChange:a=>{i(a.target.value)},placeholder:"10080",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-delete",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-delete interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-delete",type:"number",min:0,required:!0,value:h,onChange:a=>{o(a.target.value)},placeholder:"43200",className:F})]})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[C?e.jsx("p",{className:"text-failure-bg text-sm",children:C}):null,e.jsx(R,{type:"submit",size:"lg",disabled:!K||w,className:"w-full shrink-0",children:"Save"})]})]})})},ne=ae,re=1e4,O=({execTimeoutMs:s,autoStopIntervalInMinutes:l,autoArchiveIntervalInMinutes:d,autoDeleteIntervalInMinutes:g})=>({execTimeoutMs:s,autoStopIntervalInMinutes:l,autoArchiveIntervalInMinutes:d,autoDeleteIntervalInMinutes:g}),le=s=>{switch(s){case"pending":return{label:"Syncing image...",className:"text-warning-bg"};case"ready":return{label:"Connected",className:"text-success-bg"};case"failed":return{label:"Sync failed",className:"text-failure-bg"};default:return{label:s,className:"text-text-secondary"}}},ie=()=>{const{sandboxCatalog:s}=G(),l=H(),[d,g]=r.useState([]),[I,_]=r.useState([]),[y,w]=r.useState(!0),[C,m]=r.useState(null),[k,u]=r.useState(null),[x,M]=r.useState(!1),[i,h]=r.useState(null),[o,b]=r.useState(null),f=r.useCallback(async({quiet:t=!1}={})=>{if(s){t||w(!0),m(null);try{const[n,c]=await Promise.all([s.listSandboxProviders(),s.getSandboxProviderCatalog()]);g(n),_(c)}catch(n){m(q(n,"Failed to load sandbox providers"))}finally{t||w(!1)}}},[s]);r.useEffect(()=>{f()},[f]);const A=d.some(t=>t.snapshotSyncStatus.status==="pending");r.useEffect(()=>{if(!s||!A)return;const t=s;let n=!1,c;function j(){c=window.setTimeout(()=>{$()},re)}async function $(){try{const L=await t.listSandboxProviders();if(n)return;g(L),m(null),L.some(V=>V.snapshotSyncStatus.status==="pending")&&j()}catch(L){if(n)return;m(q(L,"Failed to refresh sandbox providers")),j()}}return j(),()=>{n=!0,c!==void 0&&window.clearTimeout(c)}},[s,A]);const v=d.length>0,S=r.useMemo(()=>{if(v)return[];const t=new Set(d.map(n=>n.data.catalogId));return I.filter(n=>!t.has(n.id))},[I,d,v]),B=r.useMemo(()=>o?O(o):i?O(i):null,[o,i]);if(!s)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Sandbox provider catalog is not available."});const p=async(t,n=m)=>{M(!0),m(null);try{await t(),await f({quiet:!0})}catch(c){throw n(q(c,"Request failed")),c}finally{M(!1)}},P=async t=>{i&&(u(null),await p(async()=>{await s.createSandboxProvider({catalogId:i.id,name:i.name,type:i.type,...O(t),apiKey:t.apiKey})},u),h(null),setTimeout(()=>{l==null||l.showSuccess({title:`${i.name} configured`})},0))},T=async t=>{o&&(u(null),await p(async()=>{await s.updateSandboxProvider({id:o.id,...O(t),...t.apiKey?{apiKey:t.apiKey}:{}})},u),b(null),setTimeout(()=>{l==null||l.showSuccess({title:`${o.name} updated`})},0))},z=t=>{p(async()=>{await s.updateSandboxProvider({id:t.id,...O(t)})}).catch(()=>{})},D=t=>{const n=s.deleteSandboxProvider;n&&p(async()=>{await n({id:t.id})}).catch(()=>{})},K=i!=null||o!=null,E=o!=null,a=o?`Update ${o.name}`:i?`Configure ${i.name}`:"Configure sandbox provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Sandbox providers"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Choose a provider that runs sandboxes for code, files and shell commands. Only one can be active at a time."}),C?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:C}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:y?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading sandbox providers…"}):e.jsxs("div",{className:"space-y-6",children:[d.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",d.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:d.map(t=>{const n=t.data,c=le(t.snapshotSyncStatus.status),j=t.snapshotSyncStatus.statusReason,$=e.jsxs("span",{className:`inline-flex items-center gap-1.5 text-sm font-medium ${c.className}`,children:[t.snapshotSyncStatus.status==="pending"?e.jsx(Y,{size:16,"aria-label":"Syncing snapshot image"}):t.snapshotSyncStatus.status==="ready"?e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}):t.snapshotSyncStatus.status==="failed"?e.jsx(N,{name:"triangle-exclamation",className:"size-4"}):null,c.label]});return e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(N,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:n.name})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[$,j?e.jsx(J,{content:j,children:e.jsx("button",{type:"button","aria-label":"Snapshot sync status details",className:"inline-flex text-text-secondary transition-colors hover:text-text-primary",children:e.jsx(N,{name:"info",className:"size-4"})})}):null,t.snapshotSyncStatus.status==="failed"?e.jsx(R,{variant:"ghost",size:"sm",type:"button",disabled:x,onClick:()=>{z(n)},children:"Retry"}):null,e.jsx(R,{variant:"secondary",size:"sm",type:"button",disabled:x,onClick:()=>{u(null),h(null),b(n)},children:"Update"}),s.deleteSandboxProvider?e.jsx(R,{variant:"ghost",size:"sm",className:"text-text-secondary",type:"button",disabled:x,onClick:()=>{D(n)},children:"Remove"}):null]})]},n.id)})})]}):null,v?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",S.length]}),S.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:I.length>0?"All catalog providers are configured.":"No sandbox providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:S.map(t=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(N,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name})})]}),e.jsx(R,{variant:"secondary",type:"button",disabled:x,onClick:()=>{u(null),b(null),h(t)},children:"Configure"})]},t.id))})]})]})}),e.jsx(ne,{open:K,onOpenChange:t=>{t||(u(null),h(null),b(null))},onSave:E?T:P,title:a,description:E?"Update this sandbox provider. Leave API key blank to keep the existing key.":"Configure this sandbox provider. API key is never stored in the catalog.",initialConfig:B,requireApiKey:!E,busy:x,error:k})]})},de=ie;export{de as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelSettings-CKQ5CVAC-UBz_ch6T.js","assets/index-DJ1uWGdt.js","assets/index-DEKCw40W.css","assets/ConnectorSettings-ODC3LVHN-CAU9MgGN.js","assets/SkillSettings-ECH6SHZ7-CKWEzdO_.js","assets/SandboxSettings-HSCPYUOC-Csl-nC9h.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{g,i as v,k as y,l as j,m as S,r as t,j as e,I as p,f as _,e as f,_ as u,S as k}from"./index-DJ1uWGdt.js";var w=t.lazy(()=>u(()=>import("./ModelSettings-CKQ5CVAC-UBz_ch6T.js"),__vite__mapDeps([0,1,2]))),E=t.lazy(()=>u(()=>import("./ConnectorSettings-ODC3LVHN-CAU9MgGN.js"),__vite__mapDeps([3,1,2]))),N=t.lazy(()=>u(()=>import("./SkillSettings-ECH6SHZ7-CKWEzdO_.js"),__vite__mapDeps([4,1,2]))),C=t.lazy(()=>u(()=>import("./SandboxSettings-HSCPYUOC-Csl-nC9h.js"),__vite__mapDeps([5,1,2])));function L(){return e.jsxs("div",{className:"flex flex-1 items-center justify-center py-8",role:"status","aria-live":"polite","aria-busy":"true",children:[e.jsx(k,{size:20,className:"text-text-secondary"}),e.jsx("span",{className:"sr-only",children:"Loading"})]})}var O=()=>{const{settingsOpen:n,settingsSection:l,setSettingsOpen:a}=g(),r=v(),d=y(),{refresh:m}=j(),i=S(),o=(r==null?void 0:r.skillCatalog)!=null,c=(r==null?void 0:r.sandboxCatalog)!=null,x=t.useCallback(()=>{a(!1)},[a]);t.useEffect(()=>{if(n)return()=>{m(),d==null||d()}},[n,m,d]),t.useEffect(()=>{!o&&l==="skills"&&a(n,"models"),!c&&l==="sandbox"&&a(n,"models")},[o,c,l,n,a]),t.useEffect(()=>{if(!n)return;const s=b=>{b.key==="Escape"&&(b.stopImmediatePropagation(),x())};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[x,n]);const h=t.useMemo(()=>{const s=[{id:"models",label:"Models",icon:"cpu"},{id:"connectors",label:"Connectors",icon:"plug"}];return o&&s.push({id:"skills",label:"Skills",icon:"lightbulb"}),c&&s.push({id:"sandbox",label:"Sandbox providers",icon:"cube"}),s},[o,c]);return!n||!r?null:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col bg-primary-bg",children:[e.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b border-border px-2 py-1.5",children:[e.jsx("button",{type:"button","aria-label":"Back",title:"Back",className:_({variant:"ghost",size:"icon"}),onClick:x,children:e.jsx(p,{name:"arrow-left"})}),e.jsx("h1",{className:"text-lg font-semibold tracking-tight text-text-primary",children:"Settings"})]}),e.jsxs("div",{className:f("flex min-h-0 flex-1 flex-col",!i&&"md:flex-row"),children:[e.jsx("nav",{"aria-label":"Settings sections",className:f("flex w-full gap-1 border-b border-border bg-secondary-bg/40 p-2",i?"min-w-0":"justify-center md:w-48 md:flex-col md:justify-start md:border-b-0 md:border-r"),children:h.map(s=>e.jsxs("button",{type:"button","aria-current":l===s.id?"page":void 0,...i?{title:s.label}:{},className:f("flex min-h-9 items-center gap-2 rounded-md px-3 text-sm font-medium transition-colors","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",i?"min-w-0 flex-1 justify-center gap-1.5 px-1.5":"shrink-0",l===s.id?"bg-primary-button-bg text-primary-button-text":"text-text-secondary hover:bg-ghost-button-hover/60 hover:text-text-primary"),onClick:()=>{a(!0,s.id)},children:[e.jsx(p,{name:s.icon,className:"h-4 w-4 shrink-0"}),i?e.jsx("span",{className:"truncate",children:s.label}):s.label]},s.id))}),e.jsx("section",{className:"flex flex-col h-full flex-1 overflow-y-hidden px-6 py-4",children:e.jsx("div",{className:"w-full max-w-210 h-full min-h-0 flex flex-col mx-auto",children:e.jsxs(t.Suspense,{fallback:e.jsx(L,{}),children:[l==="models"?e.jsx(w,{}):null,l==="connectors"?e.jsx(E,{}):null,l==="skills"&&o?e.jsx(N,{}):null,l==="sandbox"&&c?e.jsx(C,{}):null]})})})]})]})},I=O;export{I as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as A,a as E,m as O,p as L,b as v}from"./chunk-62JRHF6Z-
|
|
1
|
+
import{u as A,a as E,m as O,p as L,b as v}from"./chunk-62JRHF6Z-BftTGWZl.js";import{g as H,h as I,r as a}from"./index-DJ1uWGdt.js";function C(n){const u=n.activeRemoteId??n.pendingSessionId;if(u!=null)return{type:"session",sessionId:u};const{mode:c,agentConfigMode:t}=n;if(c.status==="active"&&!c.isMutable&&t!=="SingleAgent"){const o=c.agentName??c.agentId;if(o!=null)return{type:"agent",agentName:o}}return{type:"root"}}function k(n){return n.settingsOpen?{type:"settings"}:C(n)}function x({routes:n,activeRemoteId:u,initialSettingsOpen:c}){const t=H(),o=I(),h=A(),s=E(),S={settingsOpen:t.settingsOpen,pendingSessionId:t.pendingSessionId,activeRemoteId:u,mode:t.mode,agentConfigMode:t.agentConfigMode},l=k(S),N=JSON.stringify(l),i=a.useRef(null),d=a.useRef(null),f=a.useRef(!1),m=a.useRef(null),b=a.useRef(!1),P=a.useRef(!1),R=a.useCallback(e=>{if(m.current=e,o==null){t.openHistorySession({sessionId:e});return}o.getSession({sessionId:e}).then(r=>{m.current===e&&t.openHistorySession({sessionId:e,isMutable:r.isMutable,...r.agentName!=null?{agentName:r.agentName}:{}})}).catch(()=>{m.current===e&&t.openHistorySession({sessionId:e})})},[o,t]),y=a.useCallback(e=>{switch(e.type){case"settings":t.setSettingsOpen(!0);return;case"session":if(t.pendingSessionId===e.sessionId||u===e.sessionId)return;R(e.sessionId);return;case"agent":t.selectLibraryAgent({isMutable:!1,agentName:e.agentName});return;case"root":switch(t.setSettingsOpen(!1),t.agentConfigMode){case"AgentLibrary":t.openLibraryHome();return;case"AgentComposer":case"AgentLibraryWithComposer":t.openDraft();return;case"SingleAgent":t.clearChat();return}}},[t,u,R]);return a.useEffect(()=>{if(f.current)return;f.current=!0;const e=O(s.pathname,n)??{type:"root"},r=c||e.type==="settings";if(e.type==="settings")t.setSettingsOpen(!0);else{const M=C(S);L(M,e)||y(e),c&&t.setSettingsOpen(!0)}const p=r?{type:"settings"}:e,g=v(p,n);d.current=p,g!=null&&g!==s.pathname&&(i.current=g,h({pathname:g,search:s.search,hash:s.hash},{replace:!0}))},[]),a.useEffect(()=>{if(!f.current)return;if(!b.current){b.current=!0;return}const e=v(l,n);if(e==null)return;const r=d.current;if(d.current=l,e===s.pathname)return;const p=l.type==="session"&&t.pendingSessionId==null&&r!=null&&r.type!=="session";i.current=e,h({pathname:e,search:s.search,hash:s.hash},{replace:p})},[N]),a.useEffect(()=>{if(!f.current)return;if(!P.current){P.current=!0;return}if(i.current===s.pathname){i.current=null;return}const e=O(s.pathname,n);if(e==null){const r=n.root;i.current=r,h({pathname:r,search:s.search,hash:s.hash},{replace:!0}),y({type:"root"});return}e.type!=="settings"&&t.settingsOpen&&t.setSettingsOpen(!1),y(e)},[s.pathname]),null}export{x as ShellRouteSync};
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SettingsBuilder-
|
|
2
|
-
import{u as T,a as _,b as I,c,r as n,d as D,j as e,e as r,I as u,f,S as H,_ as P}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SettingsBuilder-MYWRFXRI-Ce3OWfa1.js","assets/index-DJ1uWGdt.js","assets/index-DEKCw40W.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as T,a as _,b as I,c,r as n,d as D,j as e,e as r,I as u,f,S as H,_ as P}from"./index-DJ1uWGdt.js";import{T as v,S as y,N as F,a as M}from"./chunk-OZTNBS6V-CLmmFX7d.js";var V=n.lazy(()=>P(()=>import("./SettingsBuilder-MYWRFXRI-Ce3OWfa1.js"),__vite__mapDeps([0,1,2]))),w=!1;function G({className:C}){const S=T(),s=_(),p=I(),b=c("BrandLogo"),k=c("AgentsLibraryButton"),E=c("ClearChatButton"),B=c("SaveAgentButton"),L=c("SelectAgentEmptyState"),[a,A]=n.useState(w),z=t=>{A(l=>{const o=typeof t=="function"?t(l):t;return w=o,o})},[i,d]=n.useState(!1),h=n.useRef(null),j=n.useRef(null),g=n.useRef(null),x=n.useRef(!1),N=(s==null?void 0:s.mode.status)==="idle",m=(s==null?void 0:s.settingsOpen)===!0,O=D();n.useEffect(()=>{if(!i)return;const t=l=>{l.key==="Escape"&&d(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[i]),n.useEffect(()=>{var l,o;const t=g.current;if(i){x.current=!0,t&&(t.inert=!0),(l=j.current)==null||l.focus();return}x.current&&(t&&(t.inert=!1),(o=h.current)==null||o.focus(),x.current=!1)},[i]);const R=()=>{if(s!=null&&s.isComposerEnabled){s.openDraft();return}s==null||s.setSettingsOpen(!1),Promise.resolve(S.threads().switchToNewThread()).catch(()=>{})};return e.jsxs("div",{className:r("relative flex h-full min-h-0 w-full min-w-0",C),children:[e.jsxs("aside",{className:r("hidden min-h-0 shrink-0 flex-col border-r border-border bg-sidebar-bg transition-[width] duration-300 ease-in-out md:flex",a?"w-16":"w-64"),children:[e.jsxs("div",{className:r("flex shrink-0 items-center px-3 py-3",a?"flex-col gap-3":"justify-between gap-2"),children:[e.jsxs("div",{className:r("flex min-w-0 items-center text-text-primary",a?"justify-center":"gap-2"),children:[e.jsx(b,{className:"size-5 shrink-0 object-contain"}),a?null:e.jsx("span",{className:"truncate text-lg font-semibold tracking-tight",children:p})]}),e.jsx("button",{type:"button","aria-label":a?"Expand sidebar":"Collapse sidebar",title:a?"Expand sidebar":"Collapse sidebar","aria-expanded":!a,className:f({variant:"ghost",size:"icon"}),onClick:()=>z(t=>!t),children:e.jsx(u,{name:a?"panel-left-open":"panel-left-close"})})]}),e.jsxs("nav",{className:"flex min-h-0 flex-1 flex-col items-center gap-2 px-3",hidden:!a,"aria-label":"Sidebar",children:[(s==null?void 0:s.isNewChatEnabled)!==!1?e.jsx("button",{type:"button","aria-label":"Start new chat",title:"New chat",className:f({variant:"ghost",size:"icon"}),onClick:R,children:e.jsx(u,{name:"square-pen"})}):null,e.jsx(k,{compact:!0})]}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",hidden:a,children:e.jsx(v,{})}),e.jsx("footer",{className:r("flex shrink-0 border-t border-border px-3 py-2",a?"flex-col items-center gap-2":"items-center gap-1"),children:e.jsx(y,{className:a?"flex-col":void 0})})]}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-primary-bg",children:[e.jsxs("header",{className:r("flex shrink-0 items-center gap-1 border-b border-border bg-topbar-bg px-2 py-1.5",(m||N||!O)&&"md:hidden"),children:[m?e.jsx("span",{className:"min-w-0 flex-1"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:h,type:"button","aria-label":"Sessions","aria-expanded":i,className:r(f({variant:"ghost",size:"icon"}),"md:hidden"),onClick:()=>d(!0),children:e.jsx(u,{name:"bars"})}),e.jsx(F,{}),e.jsx("span",{className:"min-w-0 flex-1"}),e.jsx(E,{}),e.jsx(B,{})]}),e.jsx("div",{className:"md:hidden",children:e.jsx(y,{})},"mobile-shell-actions")]}),e.jsx("div",{ref:g,className:"min-h-0 min-w-0 flex-1",children:m?e.jsx(n.Suspense,{fallback:e.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[e.jsx(H,{size:28,className:"text-text-primary"}),e.jsx("span",{className:"sr-only",children:"Loading"})]}),children:e.jsx(V,{})}):N?e.jsx(L,{}):e.jsx(M,{})})]}),i?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close sessions",className:"absolute inset-0 z-[9] cursor-pointer bg-[var(--overlay)] md:hidden",onClick:()=>d(!1)}),e.jsxs("div",{ref:j,className:"absolute inset-y-0 left-0 z-10 flex w-full max-w-80 flex-col border-r border-border bg-sidebar-bg shadow-lg outline-none md:hidden",role:"dialog","aria-label":"Sessions",tabIndex:-1,children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-3 text-text-primary",children:[e.jsx(b,{className:"size-5 shrink-0 object-contain"}),e.jsx("span",{className:"truncate text-lg font-semibold tracking-tight",children:p})]}),e.jsx(v,{onThreadOpen:()=>d(!1)})]})]}):null]})}export{G as SidebarLayout};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as D,o as H,r as a,p as E,j as e,q as $,B as R,I as F,t as Q,x as v}from"./index-
|
|
1
|
+
import{n as D,o as H,r as a,p as E,j as e,q as $,B as R,I as F,t as Q,x as v}from"./index-DJ1uWGdt.js";var _=({open:l,onOpenChange:o,onImport:c,busy:k=!1,error:d})=>{const[h,b]=a.useState(""),[p,m]=a.useState(""),[u,f]=a.useState(""),[i,y]=a.useState(""),[n,x]=a.useState(""),N=()=>{b(""),m(""),f(""),y(""),x("")},S=()=>{N(),o(!1)},w=async s=>{if(s.preventDefault(),!(!h.trim()||!p.trim()||!u.trim()||!i.trim()||!n.trim()||k))try{await c({name:h.trim(),description:p.trim(),repoURL:u.trim(),path:i.trim(),ref:n.trim()}),S()}catch{}},g=!!(h.trim()&&p.trim()&&u.trim()&&i.trim()&&n.trim())&&!k;return e.jsx(Q,{open:l,onOpenChange:s=>{s||S()},title:"Import from GitHub",description:"Import a skill from a SKILL.md file in a GitHub repository.",headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary",children:e.jsx(F,{name:"github",className:"size-5"})}),contentSized:!0,className:"md:max-w-2xl",children:e.jsx("form",{onSubmit:s=>void w(s),children:e.jsxs("div",{className:"space-y-5 px-5 py-5 md:px-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-name",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Name"}),e.jsx("input",{id:"skill-name",value:h,onChange:s=>{b(s.target.value)},placeholder:"release-notes",autoFocus:!0,required:!0,className:v("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-description",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Description"}),e.jsx("textarea",{id:"skill-description",value:p,onChange:s=>{m(s.target.value)},placeholder:"Generate release notes from merged pull requests",required:!0,rows:3,className:v("resize-y py-2.5")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-repo-url",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Repository URL"}),e.jsx("input",{id:"skill-repo-url",type:"url",value:u,onChange:s=>{f(s.target.value)},placeholder:"https://github.com/org/repo",required:!0,className:v("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-path",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Folder containing the SKILL.md"}),e.jsx("input",{id:"skill-path",value:i,onChange:s=>{y(s.target.value)},placeholder:"skills/release-notes",required:!0,className:v("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-ref",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Branch"}),e.jsx("input",{id:"skill-ref",value:n,onChange:s=>{x(s.target.value)},placeholder:"main",required:!0,className:v("h-11")})]}),e.jsxs("div",{className:"space-y-3",children:[d?e.jsx("p",{className:"text-failure-bg text-sm",children:d}):null,e.jsx(R,{type:"submit",disabled:!g,className:"w-full",children:"Import"})]})]})})})},K=_,q=(l,o,c)=>!l||o.toLowerCase().includes(l)||c.toLowerCase().includes(l),P=l=>"catalogId"in l,T=()=>{const{skillCatalog:l}=D(),o=H(),[c,k]=a.useState(""),[d,h]=a.useState([]),[b,p]=a.useState([]),[m,u]=a.useState(!0),[f,i]=a.useState(null),[y,n]=a.useState(null),[x,N]=a.useState(!1),[S,w]=a.useState(!1),g=a.useCallback(async()=>{if(l){u(!0),i(null);try{const[t,r]=await Promise.all([l.listSkills(),l.getSkillCatalog()]);h(t),p(r)}catch(t){i(E(t,"Failed to load skills"))}finally{u(!1)}}},[l]);a.useEffect(()=>{g()},[g]);const s=c.trim().toLowerCase(),C=a.useMemo(()=>d.filter(t=>q(s,t.name,t.description)),[d,s]),I=a.useMemo(()=>{const t=new Set(d.flatMap(r=>P(r)?[r.catalogId]:[]));return b.filter(r=>!t.has(r.id)&&q(s,r.name,r.description))},[b,d,s]),L=async(t,r=i)=>{N(!0),i(null);try{await t(),await g()}catch(j){throw r(E(j,"Request failed")),j}finally{N(!1)}};if(!l)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Skills catalog is not available."});const B=t=>{L(async()=>{await l.createSkill({catalogId:t.id,name:t.name,description:t.description,repoURL:t.repoURL,path:t.path,ref:t.ref})}).catch(()=>{})},G=t=>{const r=l.deleteSkill;r&&L(async()=>{await r({id:t.id})}).catch(()=>{})},M=async t=>{n(null),await L(async()=>{await l.createSkill(t)},n),setTimeout(()=>{o==null||o.showSuccess({title:`${t.name} imported`})},0)},z=({key:t,name:r,description:j,action:O})=>e.jsxs("article",{className:"flex min-h-16 items-center gap-3 border-b border-border p-3 last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(F,{name:"lightbulb",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:r}),j?e.jsx("p",{className:"mt-0.5 truncate text-sm text-text-secondary",children:j}):null]}),O]},t),U=C.length>0||I.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Skills"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Use built-in skills or import custom skills from GitHub."}),f?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:f}):null,e.jsxs("div",{className:"mt-4 flex min-h-0 flex-1 flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx($,{query:c,setQuery:k,placeholder:"Search skills"})}),e.jsxs(R,{variant:"secondary",type:"button",className:"shrink-0",disabled:x,onClick:()=>{n(null),w(!0)},children:[e.jsx(F,{name:"github",className:"size-4"}),"Import from GitHub"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[m?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!m&&C.length>0?e.jsxs("section",{"aria-labelledby":"enabled-skills-heading",children:[e.jsxs("h4",{id:"enabled-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Enabled · ",C.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:C.map(t=>z({key:t.id,name:t.name,description:t.description,action:l.deleteSkill?e.jsx(R,{variant:"outline",size:"sm",type:"button",disabled:x,"aria-label":`Remove ${t.name}`,onClick:()=>{G(t)},children:"Remove"}):null}))})]}):null,!m&&I.length>0?e.jsxs("section",{"aria-labelledby":"available-skills-heading",children:[e.jsxs("h4",{id:"available-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",I.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:I.map(t=>z({key:t.id,name:t.name,description:t.description,action:e.jsx(R,{variant:"outline",size:"sm",type:"button",disabled:x,"aria-label":`Enable ${t.name}`,onClick:()=>{B(t)},children:"Enable"})}))})]}):null,!m&&!U?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:s?`No skills match “${c.trim()}”.`:"No skills yet."}):null]})]}),e.jsx(K,{open:S,onOpenChange:t=>{w(t),t||n(null)},onImport:M,busy:x,error:y})]})},J=T;export{J as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,B as a}from"./chunk-62JRHF6Z-
|
|
1
|
+
import{r as t,B as a}from"./chunk-62JRHF6Z-BftTGWZl.js";import{r as n,j as o,T as u}from"./index-DJ1uWGdt.js";function l({routes:e,...s}){const r=n.useMemo(()=>t(e),[e]);return o.jsx(a,{basename:r.basename||void 0,children:o.jsx(u,{...s,resolvedRoutes:r})})}export{l as TrueForgeUIWithRouter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as d}from"./chunk-
|
|
1
|
+
import{S as d}from"./chunk-TCAVLWYL-DVhtkE3q.js";import{c as x,r,j as e,C as f,I as p,f as b,e as h}from"./index-DJ1uWGdt.js";import"./chunk-OZTNBS6V-CLmmFX7d.js";function w({className:u}){const m=x("BrandLogo"),[a,o]=r.useState(!1),i=r.useRef(null),s=r.useRef(null),l=r.useRef(!1);return r.useEffect(()=>{if(!a)return;const t=n=>{var c;n.key==="Escape"&&!((c=s.current)!=null&&c.querySelector("dialog[open]"))&&o(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[a]),r.useEffect(()=>{var t,n;if(a){l.current=!0,(t=s.current)==null||t.focus();return}l.current&&((n=i.current)==null||n.focus(),l.current=!1)},[a]),e.jsxs("div",{className:h("pointer-events-none relative h-full min-h-0 w-full",u),children:[a?e.jsx("div",{ref:s,"data-aui-compact-layout":!0,className:"pointer-events-auto absolute right-[max(1.25rem,env(safe-area-inset-right,0px))] bottom-[calc(5.25rem+env(safe-area-inset-bottom,0px))] z-[19] flex h-[min(560px,calc(100%-6.5rem-env(safe-area-inset-bottom,0px)))] max-h-[calc(100%-6.5rem)] w-[min(380px,calc(100%-2.5rem))] flex-col overflow-hidden rounded-xl border border-border bg-primary-bg shadow-[0_16px_48px_color-mix(in_oklab,var(--shadow-color)_14%,transparent)] outline-none",role:"dialog","aria-modal":!0,"aria-label":"Chat",tabIndex:-1,children:e.jsx(f,{children:e.jsx(d,{threadHeaderEnd:e.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:b({variant:"ghost",size:"icon"}),onClick:()=>o(!1),children:e.jsx(p,{name:"xmark"})})})})}):null,e.jsx("button",{ref:i,type:"button",className:"pointer-events-auto absolute right-[max(1.25rem,env(safe-area-inset-right,0px))] bottom-[max(1.25rem,env(safe-area-inset-bottom,0px))] z-20 flex size-14 cursor-pointer items-center justify-center rounded-full text-sm font-medium shadow-[0_8px_24px_color-mix(in_oklab,var(--primary-button-bg)_45%,transparent)]",style:{backgroundColor:"var(--primary-button-bg)",color:"var(--primary-button-text)"},"aria-expanded":a,"aria-label":a?"Close chat":"Open chat",onClick:()=>o(t=>!t),children:a?e.jsx("span",{"aria-hidden":!0,className:"text-xl leading-none",children:"×"}):e.jsx(m,{className:"size-6"})})]})}export{w as WidgetLayout};
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as i}from"./index-
|
|
1
|
+
import{r as i}from"./index-DJ1uWGdt.js";var W={root:"/",settings:"/settings",agent:"/agents/:agentName",session:"/sessions/:sessionId"};function re(e){const t=e.trim(),n=t.startsWith("/")?t:`/${t}`;return n.length>1&&n.endsWith("/")?n.slice(0,-1):n}function Q(e,t){return e===!1?null:re(e??t)}function Ln(e){const t=e==null?void 0:e.paths;return{basename:(e==null?void 0:e.basename)??"",root:re((t==null?void 0:t.root)??W.root),settings:Q(t==null?void 0:t.settings,W.settings),agent:Q(t==null?void 0:t.agent,W.agent),session:Q(t==null?void 0:t.session,W.session)}}function ae(e){return e.split("/").filter(t=>t.length>0)}function pe(e,t){return"/"+ae(e).map(n=>n.startsWith(":")?encodeURIComponent(t):n).join("/")}function kn(e,t){switch(e.type){case"root":return t.root;case"settings":return t.settings;case"agent":return t.agent==null?null:pe(t.agent,e.agentName);case"session":return t.session==null?null:pe(t.session,e.sessionId)}}function Ke(e){try{return decodeURIComponent(e)}catch{return null}}function ge(e,t){const n=ae(e);if(n.length!==t.length)return null;let a=null;for(const[r,o]of n.entries()){const l=t[r];if(l===void 0)return null;if(o.startsWith(":")){const s=Ke(l);if(s==null)return null;a=s}else if(o!==l)return null}return a}function $n(e,t){const n=re(e),a=ae(n);if(t.settings!=null&&n===t.settings)return{type:"settings"};if(t.agent!=null){const r=ge(t.agent,a);if(r!=null)return{type:"agent",agentName:r}}if(t.session!=null){const r=ge(t.session,a);if(r!=null)return{type:"session",sessionId:r}}return n===t.root?{type:"root"}:null}function Tn(e,t){return e.type!==t.type?!1:e.type==="agent"&&t.type==="agent"?e.agentName===t.agentName:e.type==="session"&&t.type==="session"?e.sessionId===t.sessionId:!0}/**
|
|
2
2
|
* react-router v7.18.2
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
Binary file
|
|
Binary file
|