@truefoundry/trueforge 0.2.0 → 0.2.1
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/{AgentCodeSnippets-EK7KMIY2-BSbWDfhX.js → AgentCodeSnippets-DAZWEBJS-BRFLL3U-.js} +1 -1
- package/dist/_frontend/assets/AgentCodeSnippets-DAZWEBJS-BRFLL3U-.js.br +0 -0
- package/dist/_frontend/assets/AgentCodeSnippets-DAZWEBJS-BRFLL3U-.js.gz +0 -0
- package/dist/_frontend/assets/{AgentMetricChart-UZCYOC4M-CoNlyHRt.js → AgentMetricChart-VDIE3S2P-D_xJ9A8R.js} +1 -1
- package/dist/_frontend/assets/AgentMetricChart-VDIE3S2P-D_xJ9A8R.js.br +0 -0
- package/dist/_frontend/assets/AgentMetricChart-VDIE3S2P-D_xJ9A8R.js.gz +0 -0
- package/dist/_frontend/assets/{AgentOverview-5UPMYHT2-WRvNQCHH.js → AgentOverview-5JIVYXPX-C7wS6H9h.js} +1 -1
- package/dist/_frontend/assets/AgentOverview-5JIVYXPX-C7wS6H9h.js.br +0 -0
- package/dist/_frontend/assets/AgentOverview-5JIVYXPX-C7wS6H9h.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessionEventTimeline-V6NPCYMW-D5pZyPP1.js → AgentSessionEventTimeline-WELJSS6O-UXUue7Eb.js} +1 -1
- package/dist/_frontend/assets/AgentSessionEventTimeline-WELJSS6O-UXUue7Eb.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-WELJSS6O-UXUue7Eb.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessionEventTimelineChart-YQWZBQCG-CqBkdMKC.js → AgentSessionEventTimelineChart-ADB3KICM-Ci7-9UDP.js} +1 -1
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-ADB3KICM-Ci7-9UDP.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-ADB3KICM-Ci7-9UDP.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessions-WNYVVB6Q-DIwFNwFg.js → AgentSessions-NSN4LIGJ-ZjsdJ6V6.js} +1 -1
- package/dist/_frontend/assets/AgentSessions-NSN4LIGJ-ZjsdJ6V6.js.br +0 -0
- package/dist/_frontend/assets/AgentSessions-NSN4LIGJ-ZjsdJ6V6.js.gz +0 -0
- package/dist/_frontend/assets/{ConnectorSettings-O4I24244-22M_-mC7.js → ConnectorSettings-C6MFCKYX-BvX0CZ86.js} +1 -1
- package/dist/_frontend/assets/ConnectorSettings-C6MFCKYX-BvX0CZ86.js.br +0 -0
- package/dist/_frontend/assets/ConnectorSettings-C6MFCKYX-BvX0CZ86.js.gz +0 -0
- package/dist/_frontend/assets/{DockLayout-JMBZVMGB-C-VR3Ee2.js → DockLayout-VY7OZ55R-BoHuHGZ4.js} +1 -1
- package/dist/_frontend/assets/{DrawerLayout-E6G3IF6R-D8RZ3D7u.js → DrawerLayout-B2UA3CZO-Bnc8xIc0.js} +2 -2
- package/dist/_frontend/assets/DrawerLayout-B2UA3CZO-Bnc8xIc0.js.br +0 -0
- package/dist/_frontend/assets/DrawerLayout-B2UA3CZO-Bnc8xIc0.js.gz +0 -0
- package/dist/_frontend/assets/ModelSettings-3YAHICJ3-CYXhuUMp.js +1 -0
- package/dist/_frontend/assets/ModelSettings-3YAHICJ3-CYXhuUMp.js.br +0 -0
- package/dist/_frontend/assets/ModelSettings-3YAHICJ3-CYXhuUMp.js.gz +0 -0
- package/dist/_frontend/assets/{SandboxSettings-H6BA2DJQ-ZI6uU_-B.js → SandboxSettings-ALR6F5KU-BhpQsOwg.js} +1 -1
- package/dist/_frontend/assets/SandboxSettings-ALR6F5KU-BhpQsOwg.js.br +0 -0
- package/dist/_frontend/assets/SandboxSettings-ALR6F5KU-BhpQsOwg.js.gz +0 -0
- package/dist/_frontend/assets/SchedulesPage-TIS3BH67-CoDDvRbI.js +1 -0
- package/dist/_frontend/assets/SchedulesPage-TIS3BH67-CoDDvRbI.js.br +0 -0
- package/dist/_frontend/assets/SchedulesPage-TIS3BH67-CoDDvRbI.js.gz +0 -0
- package/dist/_frontend/assets/{SettingsBuilder-VA3VGWZC-DIAqWtHn.js → SettingsBuilder-G5CP5X6Q-XQVNLXzw.js} +2 -2
- package/dist/_frontend/assets/SettingsBuilder-G5CP5X6Q-XQVNLXzw.js.br +0 -0
- package/dist/_frontend/assets/SettingsBuilder-G5CP5X6Q-XQVNLXzw.js.gz +0 -0
- package/dist/_frontend/assets/{ShellRouteSync-ZT4PBE6T-DkGPKx4y.js → ShellRouteSync-G7IJ5VIW-BoBswHkA.js} +1 -1
- package/dist/_frontend/assets/ShellRouteSync-G7IJ5VIW-BoBswHkA.js.br +0 -0
- package/dist/_frontend/assets/ShellRouteSync-G7IJ5VIW-BoBswHkA.js.gz +0 -0
- package/dist/_frontend/assets/SidebarLayout-FKRLGEDB-CqSBeNMU.js +2 -0
- package/dist/_frontend/assets/SidebarLayout-FKRLGEDB-CqSBeNMU.js.br +0 -0
- package/dist/_frontend/assets/SidebarLayout-FKRLGEDB-CqSBeNMU.js.gz +0 -0
- package/dist/_frontend/assets/{SkillSettings-F5JGGFXR-Bz-nW3QX.js → SkillSettings-E5SJ4U3T-hOs4000P.js} +1 -1
- package/dist/_frontend/assets/SkillSettings-E5SJ4U3T-hOs4000P.js.br +0 -0
- package/dist/_frontend/assets/SkillSettings-E5SJ4U3T-hOs4000P.js.gz +0 -0
- package/dist/_frontend/assets/TrueForgeUIWithRouter-WD7O3TWR-rfYDejkx.js +1 -0
- package/dist/_frontend/assets/{WidgetLayout-J7ZRW3V3-DYDWODqy.js → WidgetLayout-KQZTQNE7-CLurTXc-.js} +1 -1
- package/dist/_frontend/assets/WidgetLayout-KQZTQNE7-CLurTXc-.js.br +0 -0
- package/dist/_frontend/assets/WidgetLayout-KQZTQNE7-CLurTXc-.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-62JRHF6Z-CtriJkXR.js → chunk-62JRHF6Z-DVHPxtc3.js} +1 -1
- package/dist/_frontend/assets/chunk-62JRHF6Z-DVHPxtc3.js.br +0 -0
- package/dist/_frontend/assets/chunk-62JRHF6Z-DVHPxtc3.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-JEAULQNF-BD5-zY_K.js → chunk-B76JC5B2-BMXX-7i9.js} +1 -1
- package/dist/_frontend/assets/chunk-B76JC5B2-BMXX-7i9.js.br +0 -0
- package/dist/_frontend/assets/chunk-B76JC5B2-BMXX-7i9.js.gz +0 -0
- package/dist/_frontend/assets/chunk-G7BT4OKG-D-wOOnsv.js +1 -0
- package/dist/_frontend/assets/chunk-G7BT4OKG-D-wOOnsv.js.br +0 -0
- package/dist/_frontend/assets/chunk-G7BT4OKG-D-wOOnsv.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-MB7Z5FPI-CyN2m3rd.js → chunk-IGYCJIU7-COFxTXYC.js} +2 -2
- package/dist/_frontend/assets/chunk-IGYCJIU7-COFxTXYC.js.br +0 -0
- package/dist/_frontend/assets/chunk-IGYCJIU7-COFxTXYC.js.gz +0 -0
- package/dist/_frontend/assets/{cssMode-C-8VzKP7.js → cssMode-BMGYEB3M.js} +1 -1
- package/dist/_frontend/assets/cssMode-BMGYEB3M.js.br +0 -0
- package/dist/_frontend/assets/cssMode-BMGYEB3M.js.gz +0 -0
- package/dist/_frontend/assets/{freemarker2-DDwuEFeX.js → freemarker2-By56tpWC.js} +1 -1
- package/dist/_frontend/assets/freemarker2-By56tpWC.js.br +0 -0
- package/dist/_frontend/assets/freemarker2-By56tpWC.js.gz +0 -0
- package/dist/_frontend/assets/{handlebars-DqPfTAei.js → handlebars-cEjR9Fs2.js} +1 -1
- package/dist/_frontend/assets/handlebars-cEjR9Fs2.js.br +0 -0
- package/dist/_frontend/assets/handlebars-cEjR9Fs2.js.gz +0 -0
- package/dist/_frontend/assets/{html-D0gOfqP6.js → html-tYW1suOW.js} +1 -1
- package/dist/_frontend/assets/html-tYW1suOW.js.br +0 -0
- package/dist/_frontend/assets/html-tYW1suOW.js.gz +0 -0
- package/dist/_frontend/assets/{htmlMode-gx5Bk3tY.js → htmlMode-D8PP1KzI.js} +1 -1
- package/dist/_frontend/assets/htmlMode-D8PP1KzI.js.br +0 -0
- package/dist/_frontend/assets/htmlMode-D8PP1KzI.js.gz +0 -0
- package/dist/_frontend/assets/{index-Djblv9e3.js → index-BS4907Xx.js} +3 -3
- package/dist/_frontend/assets/index-BS4907Xx.js.br +0 -0
- package/dist/_frontend/assets/index-BS4907Xx.js.gz +0 -0
- package/dist/_frontend/assets/{index-BWMZWgYr.js → index-DUFuoecn.js} +1 -1
- package/dist/_frontend/assets/index-DUFuoecn.js.br +0 -0
- package/dist/_frontend/assets/index-DUFuoecn.js.gz +0 -0
- package/dist/_frontend/assets/{index-JWYDBa7W.js → index-G7kdtXvB.js} +222 -222
- package/dist/_frontend/assets/index-G7kdtXvB.js.br +0 -0
- package/dist/_frontend/assets/index-G7kdtXvB.js.gz +0 -0
- package/dist/_frontend/assets/{javascript-DVPzhVD0.js → javascript-osiUQvXx.js} +1 -1
- package/dist/_frontend/assets/{jsonMode-GEdzVuNq.js → jsonMode-CdMHir1V.js} +1 -1
- package/dist/_frontend/assets/jsonMode-CdMHir1V.js.br +0 -0
- package/dist/_frontend/assets/jsonMode-CdMHir1V.js.gz +0 -0
- package/dist/_frontend/assets/{liquid-BItsX3iF.js → liquid-DXwQHd5_.js} +1 -1
- package/dist/_frontend/assets/liquid-DXwQHd5_.js.br +0 -0
- package/dist/_frontend/assets/liquid-DXwQHd5_.js.gz +0 -0
- package/dist/_frontend/assets/{lspLanguageFeatures-Cus-UaLQ.js → lspLanguageFeatures-CEI6BsAF.js} +1 -1
- package/dist/_frontend/assets/lspLanguageFeatures-CEI6BsAF.js.br +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-CEI6BsAF.js.gz +0 -0
- package/dist/_frontend/assets/{mdx-DKtnK9lB.js → mdx-9AQsIt7X.js} +1 -1
- package/dist/_frontend/assets/mdx-9AQsIt7X.js.br +0 -0
- package/dist/_frontend/assets/mdx-9AQsIt7X.js.gz +0 -0
- package/dist/_frontend/assets/{python-BTjir3x0.js → python-OXQa8Ri9.js} +1 -1
- package/dist/_frontend/assets/python-OXQa8Ri9.js.br +0 -0
- package/dist/_frontend/assets/python-OXQa8Ri9.js.gz +0 -0
- package/dist/_frontend/assets/{razor-BW5FLKz0.js → razor-BU90Q8Je.js} +1 -1
- package/dist/_frontend/assets/razor-BU90Q8Je.js.br +0 -0
- package/dist/_frontend/assets/razor-BU90Q8Je.js.gz +0 -0
- package/dist/_frontend/assets/{tsMode-D_fZmsMS.js → tsMode-B3c5Otu4.js} +1 -1
- package/dist/_frontend/assets/tsMode-B3c5Otu4.js.br +0 -0
- package/dist/_frontend/assets/tsMode-B3c5Otu4.js.gz +0 -0
- package/dist/_frontend/assets/{typescript-CGtHZQss.js → typescript-CtOR5Qmc.js} +1 -1
- package/dist/_frontend/assets/typescript-CtOR5Qmc.js.br +0 -0
- package/dist/_frontend/assets/typescript-CtOR5Qmc.js.gz +0 -0
- package/dist/_frontend/assets/{workers-pKgmUfu_.js → workers-Dx3N8uH5.js} +1 -1
- package/dist/_frontend/assets/workers-Dx3N8uH5.js.br +3 -0
- package/dist/_frontend/assets/workers-Dx3N8uH5.js.gz +0 -0
- package/dist/_frontend/assets/{xml-BhrTu8Vy.js → xml-DW3BhbEz.js} +1 -1
- package/dist/_frontend/assets/xml-DW3BhbEz.js.br +0 -0
- package/dist/_frontend/assets/xml-DW3BhbEz.js.gz +0 -0
- package/dist/_frontend/assets/{yaml-G9x_AjyZ.js → yaml-BZ76X4yO.js} +1 -1
- package/dist/_frontend/assets/yaml-BZ76X4yO.js.br +0 -0
- package/dist/_frontend/assets/yaml-BZ76X4yO.js.gz +0 -0
- package/dist/_frontend/index.html +1 -1
- package/dist/controller-main.js +24 -1
- package/dist/controller-main.js.map +1 -1
- package/dist/main.js +131 -30
- package/dist/main.js.map +1 -1
- package/dist/postgres/migrations/20260727_000001_init.js +24 -1
- package/dist/postgres/migrations/20260727_000001_init.js.map +1 -1
- package/package.json +3 -2
- package/dist/_frontend/assets/AgentCodeSnippets-EK7KMIY2-BSbWDfhX.js.br +0 -0
- package/dist/_frontend/assets/AgentCodeSnippets-EK7KMIY2-BSbWDfhX.js.gz +0 -0
- package/dist/_frontend/assets/AgentMetricChart-UZCYOC4M-CoNlyHRt.js.br +0 -0
- package/dist/_frontend/assets/AgentMetricChart-UZCYOC4M-CoNlyHRt.js.gz +0 -0
- package/dist/_frontend/assets/AgentOverview-5UPMYHT2-WRvNQCHH.js.br +0 -0
- package/dist/_frontend/assets/AgentOverview-5UPMYHT2-WRvNQCHH.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-V6NPCYMW-D5pZyPP1.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-V6NPCYMW-D5pZyPP1.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-YQWZBQCG-CqBkdMKC.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-YQWZBQCG-CqBkdMKC.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessions-WNYVVB6Q-DIwFNwFg.js.br +0 -0
- package/dist/_frontend/assets/AgentSessions-WNYVVB6Q-DIwFNwFg.js.gz +0 -0
- package/dist/_frontend/assets/ConnectorSettings-O4I24244-22M_-mC7.js.br +0 -0
- package/dist/_frontend/assets/ConnectorSettings-O4I24244-22M_-mC7.js.gz +0 -0
- package/dist/_frontend/assets/DrawerLayout-E6G3IF6R-D8RZ3D7u.js.br +0 -0
- package/dist/_frontend/assets/DrawerLayout-E6G3IF6R-D8RZ3D7u.js.gz +0 -0
- package/dist/_frontend/assets/ModelSettings-ZVXMXIU4-CTVBWR_b.js +0 -1
- package/dist/_frontend/assets/ModelSettings-ZVXMXIU4-CTVBWR_b.js.br +0 -0
- package/dist/_frontend/assets/ModelSettings-ZVXMXIU4-CTVBWR_b.js.gz +0 -0
- package/dist/_frontend/assets/SandboxSettings-H6BA2DJQ-ZI6uU_-B.js.br +0 -0
- package/dist/_frontend/assets/SandboxSettings-H6BA2DJQ-ZI6uU_-B.js.gz +0 -0
- package/dist/_frontend/assets/SchedulesPage-FS2QZ5KB-rgCfvw8i.js +0 -1
- package/dist/_frontend/assets/SchedulesPage-FS2QZ5KB-rgCfvw8i.js.br +0 -0
- package/dist/_frontend/assets/SchedulesPage-FS2QZ5KB-rgCfvw8i.js.gz +0 -0
- package/dist/_frontend/assets/SettingsBuilder-VA3VGWZC-DIAqWtHn.js.br +0 -0
- package/dist/_frontend/assets/SettingsBuilder-VA3VGWZC-DIAqWtHn.js.gz +0 -0
- package/dist/_frontend/assets/ShellRouteSync-ZT4PBE6T-DkGPKx4y.js.br +0 -0
- package/dist/_frontend/assets/ShellRouteSync-ZT4PBE6T-DkGPKx4y.js.gz +0 -0
- package/dist/_frontend/assets/SidebarLayout-ICXEN7ZL--zbCMgyI.js +0 -2
- package/dist/_frontend/assets/SidebarLayout-ICXEN7ZL--zbCMgyI.js.br +0 -0
- package/dist/_frontend/assets/SidebarLayout-ICXEN7ZL--zbCMgyI.js.gz +0 -0
- package/dist/_frontend/assets/SkillSettings-F5JGGFXR-Bz-nW3QX.js.br +0 -0
- package/dist/_frontend/assets/SkillSettings-F5JGGFXR-Bz-nW3QX.js.gz +0 -0
- package/dist/_frontend/assets/TrueForgeUIWithRouter-MKJ7IEWG-DwIPuROH.js +0 -1
- package/dist/_frontend/assets/WidgetLayout-J7ZRW3V3-DYDWODqy.js.br +0 -0
- package/dist/_frontend/assets/WidgetLayout-J7ZRW3V3-DYDWODqy.js.gz +0 -0
- package/dist/_frontend/assets/chunk-62JRHF6Z-CtriJkXR.js.br +0 -0
- package/dist/_frontend/assets/chunk-62JRHF6Z-CtriJkXR.js.gz +0 -0
- package/dist/_frontend/assets/chunk-7VWUB5OV-DTCqM7Y6.js +0 -1
- package/dist/_frontend/assets/chunk-7VWUB5OV-DTCqM7Y6.js.br +0 -0
- package/dist/_frontend/assets/chunk-7VWUB5OV-DTCqM7Y6.js.gz +0 -0
- package/dist/_frontend/assets/chunk-JEAULQNF-BD5-zY_K.js.br +0 -0
- package/dist/_frontend/assets/chunk-JEAULQNF-BD5-zY_K.js.gz +0 -0
- package/dist/_frontend/assets/chunk-MB7Z5FPI-CyN2m3rd.js.br +0 -0
- package/dist/_frontend/assets/chunk-MB7Z5FPI-CyN2m3rd.js.gz +0 -0
- package/dist/_frontend/assets/cssMode-C-8VzKP7.js.br +0 -0
- package/dist/_frontend/assets/cssMode-C-8VzKP7.js.gz +0 -0
- package/dist/_frontend/assets/freemarker2-DDwuEFeX.js.br +0 -0
- package/dist/_frontend/assets/freemarker2-DDwuEFeX.js.gz +0 -0
- package/dist/_frontend/assets/handlebars-DqPfTAei.js.br +0 -0
- package/dist/_frontend/assets/handlebars-DqPfTAei.js.gz +0 -0
- package/dist/_frontend/assets/html-D0gOfqP6.js.br +0 -0
- package/dist/_frontend/assets/html-D0gOfqP6.js.gz +0 -0
- package/dist/_frontend/assets/htmlMode-gx5Bk3tY.js.br +0 -6
- package/dist/_frontend/assets/htmlMode-gx5Bk3tY.js.gz +0 -0
- package/dist/_frontend/assets/index-BWMZWgYr.js.br +0 -0
- package/dist/_frontend/assets/index-BWMZWgYr.js.gz +0 -0
- package/dist/_frontend/assets/index-Djblv9e3.js.br +0 -0
- package/dist/_frontend/assets/index-Djblv9e3.js.gz +0 -0
- package/dist/_frontend/assets/index-JWYDBa7W.js.br +0 -0
- package/dist/_frontend/assets/index-JWYDBa7W.js.gz +0 -0
- package/dist/_frontend/assets/jsonMode-GEdzVuNq.js.br +0 -0
- package/dist/_frontend/assets/jsonMode-GEdzVuNq.js.gz +0 -0
- package/dist/_frontend/assets/liquid-BItsX3iF.js.br +0 -0
- package/dist/_frontend/assets/liquid-BItsX3iF.js.gz +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-Cus-UaLQ.js.br +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-Cus-UaLQ.js.gz +0 -0
- package/dist/_frontend/assets/mdx-DKtnK9lB.js.br +0 -0
- package/dist/_frontend/assets/mdx-DKtnK9lB.js.gz +0 -0
- package/dist/_frontend/assets/python-BTjir3x0.js.br +0 -0
- package/dist/_frontend/assets/python-BTjir3x0.js.gz +0 -0
- package/dist/_frontend/assets/razor-BW5FLKz0.js.br +0 -0
- package/dist/_frontend/assets/razor-BW5FLKz0.js.gz +0 -0
- package/dist/_frontend/assets/tsMode-D_fZmsMS.js.br +0 -0
- package/dist/_frontend/assets/tsMode-D_fZmsMS.js.gz +0 -0
- package/dist/_frontend/assets/typescript-CGtHZQss.js.br +0 -0
- package/dist/_frontend/assets/typescript-CGtHZQss.js.gz +0 -0
- package/dist/_frontend/assets/workers-pKgmUfu_.js.br +0 -0
- package/dist/_frontend/assets/workers-pKgmUfu_.js.gz +0 -0
- package/dist/_frontend/assets/xml-BhrTu8Vy.js.br +0 -0
- package/dist/_frontend/assets/xml-BhrTu8Vy.js.gz +0 -0
- package/dist/_frontend/assets/yaml-G9x_AjyZ.js.br +0 -0
- package/dist/_frontend/assets/yaml-G9x_AjyZ.js.gz +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aU as be,N as fe,r as o,aV as J,j as e,U as ge,W as B,I as L,aW as ie,aX as xe,aY as ye,aZ as ve,e as P,a_ as je,aq as Ne}from"./index-G7kdtXvB.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[U,$]=o.useState(""),[y,x]=o.useState(""),[w,I]=o.useState(!1),M=()=>{$(""),x(""),I(!1)};o.useEffect(()=>{n&&($(""),x(E),I(!1))},[n,E]);const X=i=>{i||M(),l(i)},T=U.trim(),Q=!c||!!T,v=async i=>{if(i.preventDefault(),!(!Q||O))try{await b({apiKey:T,baseUrl:y.trim()}),M(),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:U,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)=>I(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(L,{name:"chevron-down",className:P("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.Primary,{type:"submit",size:"large",disabled:!Q||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()],W="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}),Ue=({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,U]=o.useState((c==null?void 0:c.baseUrl)??""),[$,y]=o.useState(""),[x,w]=o.useState(()=>ue(c)),[I,M]=o.useState(!1),[X,T]=o.useState(!1),Q=()=>{O((c==null?void 0:c.name)??""),U((c==null?void 0:c.baseUrl)??""),y(""),w(ue(c)),M(!1),T(!1)},v=s=>{s||Q(),l(s)},i=(s,r)=>{w(g=>g.map((u,j)=>j===s?{...u,...r}:u))},K=()=>{M(!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 Z=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,G=s=>ce(s.maxOutputTokens)==null?"Set the max output tokens.":null,oe=!D&&!h&&x.every(s=>!Z(s)&&!te(s)),se=I&&D,H=X&&h,A=async()=>{if(K(),!oe||p)return;const s=x.findIndex(r=>q(r)||G(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-auto flex-col",onSubmit:s=>{s.preventDefault(),A()},children:[e.jsxs("div",{className:"min-h-0 flex-auto 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:()=>M(!0),placeholder:"local-llama",autoFocus:!d,readOnly:d,"aria-readonly":d,"aria-invalid":se?!0:void 0,className:P(W,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=>U(s.target.value),onBlur:()=>T(!0),placeholder:"http://localhost:11434/v1",autoFocus:d,"aria-invalid":H?!0:void 0,className:P(W,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:W}),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=Z(s),u=s.idTouched&&g,j=te(s),R=!!j&&s.nameDirty,le=q(s),C=G(s),z=s.contextTouched&&le,ae=s.maxTouched&&C;return e.jsxs("div",{className:P("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:P(W,"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:P(W,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(L,{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(L,{name:"chevron-down",className:P("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:P(W,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:P(W,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:P("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 Y;return i(r,{reasoningEfforts:a?(Y=s.reasoningEfforts)==null?void 0:Y.filter(de=>de!==t):[...s.reasoningEfforts??[],t]})},children:t},t)})}):null]}):null]}):null]})]},r)})}),e.jsxs(B.Secondary,{size:"small",type:"button",className:"mt-4 w-fit",onClick:()=>w(s=>[...s,pe()]),children:[e.jsx(L,{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.Primary,{type:"submit",size:"large",disabled:!oe||p,className:"w-full",children:d?"Save changes":"Add provider"})]})]})})},Me=Ue;function Te(n){return"baseUrl"in n&&typeof n.baseUrl=="string"?n.baseUrl:""}var Pe=()=>{const{modelCatalog:n}=be(),l=fe(),[b,k]=o.useState(""),[p,E]=o.useState([]),[d,c]=o.useState([]),[S,O]=o.useState(!0),[F,U]=o.useState(null),[$,y]=o.useState(null),[x,w]=o.useState(!1),[I,M]=o.useState(null),[X,T]=o.useState(null),[Q,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(),Z=o.useCallback(async()=>{O(!0),U(null);try{const[t,a]=await Promise.all([n.listModelProviders(),n.getModelProviderCatalog()]);E(t),c(a)}catch(t){U(J(t,"Failed to load model providers"))}finally{O(!1)}},[n]);o.useEffect(()=>{Z()},[Z]);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]),G=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=()=>{M(null),T(null),v(null)},A=async(t,a)=>{w(!0),U(null);try{await t(),await Z(),H()}catch(m){throw a?a(m):l==null?U(J(m,"Request failed")):l.showError(m),m}finally{w(!1)}},s=async(t,a)=>{v(null),await A(async()=>{await n.createModelProvider({type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(J(m,"Request failed")))},r=async(t,a)=>{v(null),await A(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(J(m,"Request failed"))),l==null||l.showSuccess({title:`${t.name} updated`})},g=t=>{n.deleteModelProvider&&A(async()=>{await n.deleteModelProvider({id:t.id})}).catch(()=>{})},u=(t,a)=>{A(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 A(async()=>{await n.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},a=>y(J(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 A(async()=>{await n.updateModelProvider({id:a.id,type:a.type,name:a.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},m=>y(J(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=I!=null?p.find(t=>t.id===I)??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.Secondary,{type:"button",onClick:()=>{y(null),D(null),K(!0)},children:[e.jsx(L,{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)),Y=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(L,{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.Secondary,{size:"small",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),M(t.id))},children:[e.jsx(L,{name:"pencil",className:"size-3.5"}),"Edit"]}),n.deleteModelProvider?e.jsx(B.Secondary,{size:"small",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(L,{name:"trash",className:"size-3.5"})})]},N.id)),Y.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 · ",Y.length]}),Y.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.Secondary,{size:"small",type:"button",disabled:x,onClick:()=>{u(t,[...t.models,N])},children:"Add"})]},N.id))]}):null]})]},t.id)})})]}):null,!S&&G.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:G.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(L,{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.Secondary,{type:"button",disabled:x,onClick:()=>{v(null),M(null),T(t.type)},children:[e.jsx(L,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!S&&q.length===0&&G.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:Q}),e.jsx(Me,{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=Pe;export{ze as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aT as V,N as W,r,aU as B,j as e,S as Y,I as N,E as H,W as R,aW as X,aX as Z,aY as J,e as Q,aZ as ee,ap as te}from"./index-JWYDBa7W.js";var se={execTimeoutMs:3e5,autoStopIntervalInMinutes:15,autoArchiveIntervalInMinutes:10080,autoDeleteIntervalInMinutes:43200},F=te("h-11 shadow-sm");function L(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(""),[P,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 $=a=>{a||S(),l(a)},p=L(m),A=L(u),T=L(M),E=L(h),D=b.trim(),U=(!y||!!D)&&p!=null&&A!=null&&T!=null&&E!=null,z=async a=>{if(a.preventDefault(),!(!U||w||p==null||A==null||T==null||E==null))try{await d({execTimeoutMs:p,autoStopIntervalInMinutes:A,autoArchiveIntervalInMinutes:T,autoDeleteIntervalInMinutes:E,apiKey:D}),S(),l(!1)}catch{}};return e.jsx(X,{open:s,onOpenChange:$,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:z,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(Z,{expanded:P,onChange:(a,t)=>v(t),className:"rounded-md border border-border",children:[e.jsx(J,{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:Q("size-4 shrink-0 text-text-secondary transition-transform duration-200",P?"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.Primary,{type:"submit",size:"large",disabled:!U||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}=V(),l=W(),[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(B(n,"Failed to load sandbox providers"))}finally{t||w(!1)}}},[s]);r.useEffect(()=>{f()},[f]);const P=d.some(t=>t.snapshotSyncStatus.status==="pending");r.useEffect(()=>{if(!s||!P)return;const t=s;let n=!1,c;function j(){c=window.setTimeout(()=>{q()},re)}async function q(){try{const K=await t.listSandboxProviders();if(n)return;g(K),m(null),K.some(G=>G.snapshotSyncStatus.status==="pending")&&j()}catch(K){if(n)return;m(B(K,"Failed to refresh sandbox providers")),j()}}return j(),()=>{n=!0,c!==void 0&&window.clearTimeout(c)}},[s,P]);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]),$=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(B(c,"Request failed")),c}finally{M(!1)}},A=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))},E=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(()=>{})},U=i!=null||o!=null,z=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,q=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:[q,j?e.jsx(H,{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.Ghost,{size:"small",type:"button",disabled:x,onClick:()=>{E(n)},children:"Retry"}):null,e.jsx(R.Secondary,{size:"small",type:"button",disabled:x,onClick:()=>{u(null),h(null),b(n)},children:"Update"}),s.deleteSandboxProvider?e.jsx(R.Ghost,{size:"small",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.Secondary,{type:"button",disabled:x,onClick:()=>{u(null),b(null),h(t)},children:"Configure"})]},t.id))})]})]})}),e.jsx(ne,{open:U,onOpenChange:t=>{t||(u(null),h(null),b(null))},onSave:z?T:A,title:a,description:z?"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:$,requireApiKey:!z,busy:x,error:k})]})},de=ie;export{de as default};
|
|
1
|
+
import{aU as V,N as Y,r,aV as B,j as e,S as H,I as N,E as W,W as O,aX as X,aY as Z,aZ as J,e as Q,a_ as ee,aq as te}from"./index-G7kdtXvB.js";var se={execTimeoutMs:3e5,autoStopIntervalInMinutes:15,autoArchiveIntervalInMinutes:10080,autoDeleteIntervalInMinutes:43200},F=te("h-11 shadow-sm");function L(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:R=null,requireApiKey:y=!0,busy:w=!1,error:C})=>{const[m,k]=r.useState(""),[u,x]=r.useState(""),[M,i]=r.useState(""),[p,o]=r.useState(""),[b,f]=r.useState(""),[P,v]=r.useState(!1),S=()=>{k(""),x(""),i(""),o(""),f(""),v(!1)};r.useEffect(()=>{if(!s)return;const a=R??se;k(String(a.execTimeoutMs)),x(String(a.autoStopIntervalInMinutes)),i(String(a.autoArchiveIntervalInMinutes)),o(String(a.autoDeleteIntervalInMinutes)),f(""),v(!1)},[s,R]);const q=a=>{a||S(),l(a)},h=L(m),A=L(u),T=L(M),E=L(p),D=b.trim(),U=(!y||!!D)&&h!=null&&A!=null&&T!=null&&E!=null,z=async a=>{if(a.preventDefault(),!(!U||w||h==null||A==null||T==null||E==null))try{await d({execTimeoutMs:h,autoStopIntervalInMinutes:A,autoArchiveIntervalInMinutes:T,autoDeleteIntervalInMinutes:E,apiKey:D}),S(),l(!1)}catch{}};return e.jsx(X,{open:s,onOpenChange:q,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:z,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(Z,{expanded:P,onChange:(a,t)=>v(t),className:"rounded-md border border-border",children:[e.jsx(J,{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:Q("size-4 shrink-0 text-text-secondary transition-transform duration-200",P?"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:p,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(O.Primary,{type:"submit",size:"large",disabled:!U||w,className:"w-full shrink-0",children:"Save"})]})]})})},ne=ae,re=1e4,_=({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}=V(),l=Y(),[d,g]=r.useState([]),[I,R]=r.useState([]),[y,w]=r.useState(!0),[C,m]=r.useState(null),[k,u]=r.useState(null),[x,M]=r.useState(!1),[i,p]=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),R(c)}catch(n){m(B(n,"Failed to load sandbox providers"))}finally{t||w(!1)}}},[s]);r.useEffect(()=>{f()},[f]);const P=d.some(t=>t.snapshotSyncStatus.status==="pending");r.useEffect(()=>{if(!s||!P)return;const t=s;let n=!1,c;function j(){c=window.setTimeout(()=>{$()},re)}async function $(){try{const K=await t.listSandboxProviders();if(n)return;g(K),m(null),K.some(G=>G.snapshotSyncStatus.status==="pending")&&j()}catch(K){if(n)return;m(B(K,"Failed to refresh sandbox providers")),j()}}return j(),()=>{n=!0,c!==void 0&&window.clearTimeout(c)}},[s,P]);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]),q=r.useMemo(()=>o?_(o):i?_(i):null,[o,i]);if(!s)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Sandbox provider catalog is not available."});const h=async(t,n=m)=>{M(!0),m(null);try{await t(),await f({quiet:!0})}catch(c){throw n(B(c,"Request failed")),c}finally{M(!1)}},A=async t=>{i&&(u(null),await h(async()=>{await s.createSandboxProvider({catalogId:i.id,name:i.name,type:i.type,..._(t),apiKey:t.apiKey})},u),p(null),setTimeout(()=>{l==null||l.showSuccess({title:`${i.name} configured`})},0))},T=async t=>{o&&(u(null),await h(async()=>{await s.updateSandboxProvider({id:o.id,..._(t),...t.apiKey?{apiKey:t.apiKey}:{}})},u),b(null),setTimeout(()=>{l==null||l.showSuccess({title:`${o.name} updated`})},0))},E=t=>{h(async()=>{await s.updateSandboxProvider({id:t.id,..._(t)})}).catch(()=>{})},D=t=>{const n=s.deleteSandboxProvider;n&&h(async()=>{await n({id:t.id})}).catch(()=>{})},U=i!=null||o!=null,z=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(H,{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(W,{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(O.Ghost,{size:"small",type:"button",disabled:x,onClick:()=>{E(n)},children:"Retry"}):null,e.jsx(O.Secondary,{size:"small",type:"button",disabled:x,onClick:()=>{u(null),p(null),b(n)},children:"Update"}),s.deleteSandboxProvider?e.jsx(O.Ghost,{size:"small",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(O.Secondary,{type:"button",disabled:x,onClick:()=>{u(null),b(null),p(t)},children:"Configure"})]},t.id))})]})]})}),e.jsx(ne,{open:U,onOpenChange:t=>{t||(u(null),p(null),b(null))},onSave:z?T:A,title:a,description:z?"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:q,requireApiKey:!z,busy:x,error:k})]})},de=ie;export{de as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as be,M as Le,N as ge,r as l,O as xe,Q as Se,J as pe,R as Qe,j as e,P as We,U as Ke,V as ce,q as ue,W as q,I as A,X as Ye,Y as ke,Z as Te,$ as Ze,a0 as Je,a1 as Ce,a2 as J,a3 as Xe,a4 as X,a5 as et,a6 as tt,a7 as st,a8 as nt,a9 as at,aa as rt,ab as lt,ac as it,ad as ot,e as $,ae as Ee,af as ct,ag as dt,ah as ut,c as mt,ai as xt,aj as me,d as ht,ak as ft,E as bt,a as gt,al as pt,am as Nt,an as yt,ao as jt,ap as vt,aq as ze,i as wt,ar as St}from"./index-G7kdtXvB.js";function Fe({value:t,selectedLabel:s,onValueChange:i,onAgentPicked:a,disabled:r=!1,onBuildAgent:d,allOption:g,"aria-label":y="Agent",placeholder:m="Search agent",className:f}){const[u,p]=l.useState(!1),[j,o]=l.useState(""),[w,E]=l.useState(null),b=l.useRef(null),k=l.useRef(null),C=l.useRef(null),z=l.useRef(null),H=l.useId(),{agents:R,isInitialLoading:F,isSearching:v,loadingMore:W,hasMore:B,error:D,listRef:I,sentinelRef:G}=it({enabled:u&&!r,query:j});l.useEffect(()=>{u||o("")},[u]),l.useLayoutEffect(()=>{if(!u){E(null);return}const h=()=>{const c=k.current;if(!c)return;const N=c.getBoundingClientRect();E({top:N.bottom+4,left:N.left,width:N.width})};return h(),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[u]),l.useEffect(()=>{if(!u)return;const h=c=>{var N,S;c.target instanceof Node&&((N=b.current)!=null&&N.contains(c.target)||(S=z.current)!=null&&S.contains(c.target)||p(!1))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[u]);const O=()=>{var h;p(!1),o(""),(h=C.current)==null||h.blur()},_=h=>{const c=ue(h);i(c),a==null||a(h),O()},K=()=>{g!=null&&(i(g.value),O())},P=u?j:s,U=j.trim(),V=!F&&D!=null,L=!F&&D==null&&R.length===0&&U==="",Q=!F&&D==null&&R.length===0&&U!=="",ee=u&&w!=null&&!r?ot.createPortal(e.jsxs("div",{ref:z,className:ct("fixed z-[200] flex max-h-64 flex-col overflow-hidden"),style:{top:w.top,left:w.left,width:w.width},onMouseDown:h=>h.stopPropagation(),children:[e.jsxs("div",{ref:I,id:H,role:"listbox","aria-label":y,className:"min-h-0 flex-1 overflow-y-auto p-1",children:[g!=null&&U===""?e.jsxs("button",{type:"button",role:"option","aria-selected":t===g.value,className:Ee(),onClick:K,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.label}),e.jsx(A,{name:"check",className:$("ml-auto size-4 shrink-0",t===g.value?"opacity-100":"opacity-0")})]}):null,F?e.jsx("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",role:"status",children:"Loading…"}):V?e.jsx("p",{className:"text-failure-bg px-3 py-5 text-center text-sm",role:"alert",children:D}):L?e.jsx("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",children:"No Agents created yet"}):Q?e.jsxs("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",role:"status",children:['No agents match "',U,'".']}):e.jsxs(e.Fragment,{children:[v?e.jsx("p",{className:"sr-only",role:"status",children:"Searching…"}):null,R.map(h=>{const c=ue(h),N=t===c;return e.jsxs("button",{type:"button",role:"option","aria-selected":N,className:Ee(),onClick:()=>_(h),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:h.name}),e.jsx(A,{name:"check",className:$("ml-auto size-4 shrink-0",N?"opacity-100":"opacity-0")})]},c)}),B?e.jsx("div",{ref:G,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:W?e.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]}),L&&d!=null?e.jsx("div",{className:"flex justify-end border-t border-border px-2 pt-2",children:e.jsxs(q.Ghost,{type:"button",onClick:d,children:[e.jsx(A,{name:"plus",className:"size-3.5"}),"Build Agent"]})}):null]}),dt(b.current)):null;return e.jsxs("div",{ref:b,className:$("relative",f),children:[e.jsxs("div",{ref:k,className:ut(r?"cursor-not-allowed opacity-50":"cursor-text"),children:[e.jsx("input",{ref:C,type:"text",role:"combobox","aria-label":y,"aria-expanded":u,"aria-controls":u?H:void 0,"aria-autocomplete":"list",disabled:r,placeholder:m,value:P,className:"min-w-0 flex-1 bg-transparent outline-none placeholder:text-text-secondary/70 disabled:cursor-not-allowed",onFocus:()=>{r||p(!0)},onChange:h=>{r||(o(h.target.value),p(!0))},onKeyDown:h=>{var c;if(h.key==="Escape"){h.preventDefault(),p(!1),(c=C.current)==null||c.blur();return}h.key==="ArrowDown"&&!u&&!r&&(h.preventDefault(),p(!0))}}),e.jsx(A,{name:"chevron-down",className:"size-4 shrink-0 text-text-secondary"})]}),ee]})}var Ae=[{value:"America/New_York",label:"America/New_York (ET)"},{value:"America/Chicago",label:"America/Chicago (CT)"},{value:"America/Denver",label:"America/Denver (MT)"},{value:"America/Los_Angeles",label:"America/Los_Angeles (PT)"},{value:"UTC",label:"UTC"},{value:"Europe/London",label:"Europe/London (GMT/BST)"},{value:"Europe/Berlin",label:"Europe/Berlin (CET)"},{value:"Asia/Kolkata",label:"Asia/Kolkata (IST)"},{value:"Asia/Tokyo",label:"Asia/Tokyo (JST)"}];function Ie(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function kt(t){const s=Ie(),i=new Set(Ae.map(r=>r.value));return[...[s,t].flatMap(r=>r==null||r.length===0||i.has(r)?[]:(i.add(r),[{value:r,label:r===s?`${r} (Local)`:r}])),...Ae]}var Me=[{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"},{value:0,label:"Sun"}],Tt={"America/New_York":"ET","America/Chicago":"CT","America/Denver":"MT","America/Los_Angeles":"PT",UTC:"UTC","Europe/London":"GMT","Europe/Berlin":"CET","Asia/Kolkata":"IST","Asia/Tokyo":"JST"};function de(){return{name:"",task:"",recurrence:"daily",hour:9,minute:0,weekdays:[1],customCron:"0 9 * * *",timezone:Ie()}}function Ct(t){return Tt[t]??t.split("/").pop()??t}function $e(t){return t.toString().padStart(2,"0")}function le({hour:t,minute:s}){const i=t>=12?"PM":"AM",a=t%12===0?12:t%12;return`${String(a)}:${$e(s)} ${i}`}function he(t){const s=t.minute,i=t.hour;switch(t.recurrence){case"hourly":return`${String(s)} * * * *`;case"daily":return`${String(s)} ${String(i)} * * *`;case"weekly":{const a=[...t.weekdays].sort((d,g)=>d-g),r=a.length>0?a.join(","):"*";return`${String(s)} ${String(i)} * * ${r}`}case"custom":return t.customCron.trim()}}function ae(t){const s=Ct(t.timezone),i=t.cron.trim().split(/\s+/);if(i.length!==5)return t.cron;const[a,r,d,g,y]=i;if(d!=="*"||g!=="*")return t.cron;const m=Number(a),f=Number(r);if(r==="*"&&y==="*"&&a!==void 0&&!Number.isNaN(m))return`Hourly at :${$e(m)} ${s}`;if(y==="*"&&r!==void 0&&a!==void 0&&!Number.isNaN(f)&&!Number.isNaN(m))return`Daily ${le({hour:f,minute:m})} ${s}`;if(y==="1-5"&&r!==void 0&&a!==void 0&&!Number.isNaN(f)&&!Number.isNaN(m))return`Weekdays ${le({hour:f,minute:m})} ${s}`;if(y!=null&&/^\d(?:,\d)*$/.test(y)&&r!==void 0&&a!==void 0&&!Number.isNaN(f)&&!Number.isNaN(m)){const u=y.split(",").map(p=>{var j;return((j=Me.find(o=>o.value===Number(p)))==null?void 0:j.label)??p});return u.length===1?`Every ${u[0]==="Mon"?"Monday":u[0]} ${le({hour:f,minute:m})} ${s}`:`${u.join(", ")} ${le({hour:f,minute:m})} ${s}`}return t.cron}function Re(t){const s=de(),i=t.cron.trim().split(/\s+/);if(i.length!==5)return{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron};const[a,r,d,g,y]=i,m=Number(a),f=Number(r);return d!=="*"||g!=="*"?{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron}:r==="*"&&y==="*"&&!Number.isNaN(m)?{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"hourly",minute:m,customCron:t.cron}:y==="*"&&!Number.isNaN(f)&&!Number.isNaN(m)?{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"daily",hour:f,minute:m,customCron:t.cron}:y!=null&&/^\d(?:,\d)*$/.test(y)&&!Number.isNaN(f)&&!Number.isNaN(m)?{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"weekly",hour:f,minute:m,weekdays:y.split(",").map(Number),customCron:t.cron}:{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron,hour:Number.isNaN(f)?s.hour:f,minute:Number.isNaN(m)?s.minute:m}}function Et(t,s=Date.now()){if(t==null)return"Never";const i=Date.parse(t);if(Number.isNaN(i))return"Never";const a=Math.round((s-i)/1e3);if(a<60)return"just now";const r=Math.round(a/60);if(r<60)return`${String(r)} min ago`;const d=Math.round(r/60);if(d<48)return`${String(d)} hour${d===1?"":"s"} ago`;const g=Math.round(d/24);return`${String(g)} day${g===1?"":"s"} ago`}var zt=[{value:"hourly",label:"Hourly"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"}],At=Array.from({length:24},(t,s)=>({value:String(s),label:s.toString().padStart(2,"0")})),Rt=[0,15,30,45].map(t=>({value:String(t),label:`:${t.toString().padStart(2,"0")}`}));function Dt({values:t,onChange:s,agentId:i,agentLabel:a,onAgentIdChange:r,onAgentPicked:d,agentPickerDisabled:g=!1,onBuildAgent:y}){const m=he(t),f=ae({cron:m,timezone:t.timezone}),u=kt(t.timezone),p=(o,w)=>{s({...t,[o]:w})},j=o=>{const E=t.weekdays.includes(o)?t.weekdays.filter(b=>b!==o):[...t.weekdays,o];s({...t,weekdays:E.length>0?E:[o]})};return e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("div",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Agent"}),e.jsx(Fe,{"aria-label":"Agent",placeholder:"Search agent",value:i,selectedLabel:a,onValueChange:o=>r==null?void 0:r(o),onAgentPicked:d,disabled:g||r==null,onBuildAgent:y})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Name"}),e.jsx("input",{value:t.name,onChange:o=>p("name",o.target.value),placeholder:"harness-daily-digest",className:ze("h-8"),required:!0})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Task"}),e.jsx("textarea",{value:t.task,onChange:o=>p("task",o.target.value),rows:3,placeholder:"Summarise yesterday's harness runs and post the digest…",className:ze("resize-y py-2"),required:!0})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"mb-1.5 text-sm font-medium",children:"Frequency"}),e.jsx("div",{className:"rounded-t-lg border border-border p-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-1 rounded-lg border border-border bg-primary-bg p-1",children:zt.map(o=>{const w=t.recurrence===o.value;return e.jsx("button",{type:"button",className:$("rounded-md border px-2 py-2 text-sm font-medium transition-colors",w?"border-primary-button-bg/40 bg-primary-button-bg/10 font-semibold text-primary-button-bg":"border-transparent text-text-secondary hover:bg-ghost-button-hover"),"aria-pressed":w,onClick:()=>p("recurrence",o.value),children:o.label},o.value)})}),t.recurrence==="custom"?e.jsxs("div",{className:"rounded-md border border-border bg-secondary-bg/40 px-3 py-2",children:[e.jsx("span",{className:"block text-xs text-text-secondary",children:"Existing custom schedule"}),e.jsx("code",{className:"mt-1 block font-mono text-sm text-text-primary",children:t.customCron}),e.jsx("span",{className:"mt-1 block text-xs text-text-secondary",children:"Select Hourly, Daily, or Weekly to replace this schedule."})]}):null,t.recurrence==="weekly"?e.jsxs("fieldset",{children:[e.jsx("legend",{className:"mb-2 text-sm font-medium",children:"Days"}),e.jsx("div",{className:"flex gap-2",children:Me.map(o=>{const w=t.weekdays.includes(o.value);return e.jsx("button",{type:"button",className:$("min-w-0 flex-1 rounded-md border px-3 py-2 text-[0.8125rem] font-medium",w?"border-primary-button-bg/40 bg-primary-button-bg/10 font-semibold text-primary-button-bg":"border-border text-text-secondary hover:bg-ghost-button-hover"),"aria-pressed":w,onClick:()=>j(o.value),children:o.label},o.value)})})]}):null,e.jsxs("div",{className:"flex gap-4",children:[t.recurrence==="daily"||t.recurrence==="weekly"?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Hour"}),e.jsx(ce,{"aria-label":"Hour",value:String(t.hour),options:At,onValueChange:o=>p("hour",Number(o))})]}):null,t.recurrence!=="custom"?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Minute"}),e.jsx(ce,{"aria-label":"Minute",value:String(t.minute),options:Rt,onValueChange:o=>p("minute",Number(o))})]}):null,e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Timezone"}),e.jsx(ce,{"aria-label":"Timezone",value:t.timezone,options:u,onValueChange:o=>p("timezone",o),menuClassName:"w-full min-w-0"})]})]})]})}),e.jsx("div",{className:"rounded-b-lg border border-t-0 border-border bg-primary-button-bg/10 px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{name:"clock",className:"size-4 shrink-0 text-primary-button-bg"}),e.jsx("span",{className:"shrink-0 text-xs font-medium text-text-secondary",children:"Schedule"}),e.jsx("p",{className:"min-w-0 flex-1 truncate text-sm text-text-primary",children:f||"—"}),e.jsx("code",{className:"shrink-0 whitespace-nowrap font-mono text-[0.8125rem] font-bold text-text-secondary",children:m||"—"})]})})]})]})}function Pt(t){return t.startsWith("manual-")}function Lt(t){return t==="failed"?"failed":"success"}function Be(t){return t==="failed"?"Failed":t==="triggered"?"Triggered":"Scheduled"}function Oe(t){return Pt(t)?"Manual test":"Cron"}function Ft(t,s=5){return t.filter(a=>a.status!=="scheduled").slice(0,s).reverse()}function fe(t){if(t==null)return"—";const s=new Date(t);return Number.isNaN(s.getTime())?"—":jt(s)}function It({run:t}){return e.jsxs("div",{className:"flex flex-col gap-1 text-left text-xs",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Be(t.status)}),e.jsx("p",{className:"text-text-secondary",children:Oe(t.name)}),e.jsxs("p",{className:"text-text-secondary",children:["Scheduled for: ",fe(t.scheduledFor)]}),t.triggeredAt!=null?e.jsxs("p",{className:"text-text-secondary",children:["Triggered at: ",fe(t.triggeredAt)]}):null,e.jsxs("p",{className:"text-text-secondary",children:["Triggered by: ",t.triggeredBy]})]})}var Mt={success:"border-emerald-600/30 bg-emerald-500/10 text-emerald-700 dark:border-emerald-400/35 dark:bg-emerald-500/15 dark:text-emerald-300",failed:"border-red-600/30 bg-red-500/10 text-red-700 dark:border-red-400/35 dark:bg-red-500/15 dark:text-red-300"};function _e({run:t}){const s=Lt(t.status),i=fe(t.triggeredAt??t.scheduledFor);return e.jsx(bt,{content:e.jsx(It,{run:t}),side:"top",children:e.jsx("span",{className:$("inline-flex size-6 shrink-0 items-center justify-center rounded-md border",Mt[s]),"aria-label":`${Be(t.status)} run at ${i}`,children:e.jsx(A,{name:s==="failed"?"triangle-exclamation":"check",className:"size-3.5"})})})}function Ue({status:t}){const s=t==="active";return e.jsxs("span",{className:$("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium",s?"border-emerald-600/30 bg-emerald-500/10 text-emerald-700 dark:border-emerald-400/35 dark:bg-emerald-500/15 dark:text-emerald-300":"border-amber-600/30 bg-amber-500/10 text-amber-800 dark:border-amber-400/35 dark:bg-amber-500/15 dark:text-amber-300"),children:[e.jsx("span",{className:$("size-1.5 shrink-0 rounded-full",s?"bg-emerald-600 dark:bg-emerald-400":"bg-amber-600 dark:bg-amber-400"),"aria-hidden":!0}),s?"Active":"Paused"]})}function $t(t,s){return t.find(i=>i.name===s||i.id===s)??null}function Bt({connector:t,onConnected:s}){return wt()==null?null:e.jsx(St,{connector:t,onConnected:s})}function ne({label:t,children:s}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border px-3 py-2.5 last:border-b-0",children:[e.jsx("span",{className:"text-text-secondary shrink-0 text-[10px] font-semibold tracking-wide uppercase",children:t}),e.jsx("div",{className:"min-w-0 text-right text-sm text-text-primary",children:s})]})}function Ot({schedule:t,agentName:s,mcpMounts:i,onEditConfiguration:a}){const r=be(),d=ge(),{connectors:g,ensureLoaded:y,refreshConnectors:m,loading:f,error:u}=vt(),[p,j]=l.useState(!1),[o,w]=l.useState(null),E=ae({cron:t.cron,timezone:t.timezone}),b=async()=>{j(!0);try{const k=await r.createScheduleRun({scheduleId:t.id});w(k),d==null||d.showSuccess({title:"Test run started"})}catch(k){d==null||d.showError(k)}finally{j(!1)}};return l.useEffect(()=>{y()},[y]),l.useEffect(()=>{u!=null&&(d==null||d.showError(u))},[u,d]),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx(ne,{label:"Agent",children:s}),e.jsx(ne,{label:"Name",children:t.name}),e.jsx(ne,{label:"Status",children:e.jsx(Ue,{status:t.status})}),e.jsx(ne,{label:"Task",children:e.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.task})}),e.jsx(ne,{label:"Frequency",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[e.jsx("span",{children:E}),e.jsx("code",{className:"text-text-secondary font-mono text-xs",children:t.cron})]})}),e.jsx("div",{className:"flex justify-end px-3 py-2.5",children:e.jsxs(q.Secondary,{type:"button",size:"small",onClick:a,children:[e.jsx(A,{name:"pencil",className:"size-3.5"}),"Edit Configuration"]})})]}),e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx("div",{className:"border-b border-border px-3 py-2",children:e.jsx("h3",{className:"text-text-secondary text-[10px] font-semibold tracking-wide uppercase",children:"Tool Authorization"})}),i.length===0?e.jsx("p",{className:"text-text-secondary px-3 py-3 text-sm",children:"No MCP connectors configured for this agent."}):e.jsx("ul",{className:"divide-y divide-border",children:i.map(k=>{const C=$t(g,k.name),z=(C==null?void 0:C.authenticated)===!0,H=C==null&&!f;return e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:$("inline-flex size-4 shrink-0 items-center justify-center rounded-full border",z?"border-emerald-600/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"border-border text-transparent"),"aria-hidden":!0,children:z?e.jsx(A,{name:"check",className:"size-3"}):null}),e.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm",children:k.name}),z?e.jsx("span",{className:"text-success-bg text-xs font-medium",children:"Connected"}):H?e.jsx("span",{className:"text-text-secondary text-xs",children:"Unavailable"}):C!=null&&C.authenticated===!1?e.jsx(Bt,{connector:C,onConnected:m}):f?e.jsx("span",{className:"text-text-secondary text-xs",children:"Loading…"}):null]},k.name)})})]}),e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[e.jsx("h3",{className:"text-text-secondary text-[10px] font-semibold tracking-wide uppercase",children:"Test Run"}),e.jsxs(q.Primary,{type:"button",disabled:p,size:"small",onClick:()=>void b(),children:[e.jsx(A,{name:p?"loader":"play",className:$("size-3.5",p&&"animate-spin")}),"Run Test"]})]}),o==null?e.jsx("p",{className:"text-text-secondary px-3 py-3 text-sm",children:"Run a one-off test using the schedule task. This does not change the cron pending run."}):e.jsxs("div",{className:"flex items-center gap-3 px-3 py-3",children:[e.jsx(_e,{run:o}),e.jsxs("div",{className:"min-w-0 text-sm",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Oe(o.name)}),e.jsx("p",{className:"text-text-secondary",children:Et(o.triggeredAt??o.scheduledFor)})]})]})]})]})}function _t({open:t,onOpenChange:s,mode:i,schedule:a,initialAgentId:r="",onSaved:d}){const g=be(),y=Le(),m=gt(),f=ge(),[u,p]=l.useState(de),[j,o]=l.useState(r),[w,E]=l.useState(null),[b,k]=l.useState({kind:"form"}),[C,z]=l.useState(!1),[H,R]=l.useState(!1),[F,v]=l.useState(null),W=l.useRef(j);W.current=j;const B=b.kind==="form"?b.saved:b.schedule,D=i==="edit"&&b.kind==="form"&&b.saved==null&&a!=null,I=b.kind==="form"&&b.saved!=null,G=i==="create"&&b.kind==="form"&&b.saved==null,{allows:O}=xe({resourceType:"agent",resourceIds:j.length===0?[]:[j]});l.useEffect(()=>{if(!t){p(de()),o(r),E(null),v(null),k({kind:"form"}),R(!1);return}if(i==="edit"&&a!=null){p(Re({name:a.name,task:a.task,cron:a.cron,timezone:a.timezone})),o(a.agentId),E(null),k({kind:"form"});return}p(de()),o(r),E(null),k({kind:"form"})},[t,i,a,r]),l.useEffect(()=>{if(!t||i!=="create"||r.length===0)return;let c=!1;const N=r;return pt({server:y,agentKey:N}).then(S=>{c||S==null||W.current===N&&(E(S),o(ue(S)))}).catch(()=>{}),()=>{c=!0}},[t,i,r,y]);const _=(w==null?void 0:w.name)??(B==null?void 0:B.agentName)??(a==null?void 0:a.agentName)??(j.length>0?j:""),K=l.useMemo(()=>{var N;return(((N=w==null?void 0:w.agentSpec)==null?void 0:N.mcpServers)??[]).map(Nt).filter(S=>S!=null).map(S=>({name:S}))},[w]),P=l.useMemo(()=>{const c=he(u);return u.name.trim().length>0&&u.task.trim().length>0&&c.length>0&&j.length>0&&(!G||O(j,"USE"))},[j,O,u,G]),U=c=>{k({kind:"test",schedule:c}),p(Re({name:c.name,task:c.task,cron:c.cron,timezone:c.timezone})),o(c.agentId)},V=async c=>{if(c.preventDefault(),!P)return;const N=he(u);z(!0),v(null);try{if(D&&a!=null){await g.updateSchedule({id:a.id,name:u.name.trim(),task:u.task.trim(),cron:N,timezone:u.timezone,status:a.status}),d==null||d(),s(!1);return}if(I&&b.kind==="form"&&b.saved!=null){const Y=await g.updateSchedule({id:b.saved.id,name:u.name.trim(),task:u.task.trim(),cron:N,timezone:u.timezone,status:"paused"});d==null||d(),U(Y),f==null||f.showSuccess({title:"Schedule saved as paused",description:ae({cron:Y.cron,timezone:Y.timezone})});return}const S=await g.createSchedule({agentId:j,name:u.name.trim(),task:u.task.trim(),cron:N,timezone:u.timezone,status:"paused"});d==null||d(),U(S),f==null||f.showSuccess({title:"Schedule saved as paused",description:ae({cron:S.cron,timezone:S.timezone})})}catch(S){const Y=S instanceof Error?S.message:"Failed to save schedule";v(Y)}finally{z(!1)}},L=async()=>{if(b.kind==="test"){R(!0),v(null);try{await g.updateSchedule({id:b.schedule.id,name:b.schedule.name,task:b.schedule.task,cron:b.schedule.cron,timezone:b.schedule.timezone,status:"active"}),d==null||d(),f==null||f.showSuccess({title:"Schedule activated"}),s(!1)}catch(c){const N=c instanceof Error?c.message:"Failed to activate schedule";v(N),f==null||f.showError(c)}finally{R(!1)}}},Q=b.kind==="test"?"Test Schedule":D||I?"Edit Schedule":"New Schedule",ee=b.kind==="test"?`Recurring unattended runs of ${_}.`:D||I?"Update cadence and task for this schedule.":"Create a recurring unattended run for an agent.";let h;return b.kind==="test"?h=e.jsxs("div",{className:"flex flex-col gap-2",children:[F!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsx(q.Secondary,{type:"button",className:"w-full",disabled:H,onClick:()=>void L(),children:"Activate Schedule"})]}):h=e.jsxs("div",{className:"flex flex-col gap-2",children:[F!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(q.Secondary,{type:"button",onClick:()=>s(!1),disabled:C,children:"Cancel"}),e.jsx(q.Primary,{type:"submit",form:"schedule-form",disabled:!P||C,children:"Save"})]})]}),e.jsx(yt,{open:t,onOpenChange:s,title:Q,description:ee,anchor:"right",size:"xl",headerIcon:e.jsx("span",{className:"text-primary-button-bg inline-flex size-8 items-center justify-center",children:e.jsx(A,{name:b.kind==="test"||D||I?"calendar":"calendar-plus",className:"size-5"})}),footer:h,children:b.kind==="test"?e.jsx(Ot,{schedule:b.schedule,agentName:_,mcpMounts:K,onEditConfiguration:()=>{v(null),k({kind:"form",saved:b.schedule})}}):e.jsx("form",{id:"schedule-form",onSubmit:c=>void V(c),children:e.jsx(Dt,{values:u,onChange:p,agentId:j,agentLabel:_,onAgentIdChange:D||I?void 0:c=>{o(c),c.length===0&&E(null)},onAgentPicked:E,agentPickerDisabled:D||I,onBuildAgent:i==="create"&&(m==null?void 0:m.isComposerEnabled)===!0?()=>{s(!1),m.openAgentBuilder()}:void 0})})})}function De(t){return e.jsx(ft,{children:e.jsx(_t,{...t})})}function Ut({runs:t}){const s=Ft(t);return s.length===0?e.jsx("span",{className:"text-text-secondary text-sm",children:"—"}):e.jsx("div",{className:"flex items-center gap-1",children:s.map(i=>e.jsx(_e,{run:i},i.id))})}var qt=[{value:"all",label:"All statuses"},{value:"active",label:"Active"},{value:"paused",label:"Paused"}],Pe=[10,25];function ie(t){return Math.min(Math.max(t,1),25)}function oe(t){const s=pe(t);return{nameQuery:s.q??"",statusFilter:s.status??"all",agentFilter:s.agent??"all"}}function Ht(t){const s=pe(window.location.search);if(!s.isNew)return{kind:"closed"};const i=t??s.agent;return{kind:"create",...i==null?{}:{agentId:i}}}function Gt({schedule:t,running:s,canManage:i,canDelete:a,onRunNow:r,onEdit:d,onTogglePause:g,onDelete:y}){const m=mt("PermissionGuard");return e.jsxs("div",{className:"inline-flex items-center justify-end gap-1.5",children:[e.jsx(m,{allowed:i,children:e.jsxs(q.Secondary,{type:"button",disabled:s,"aria-label":`Run now ${t.name}`,size:"large",onClick:r,children:[e.jsx(A,{name:s?"loader":"play",className:$("size-3.5",s&&"animate-spin")}),"Run now"]})}),e.jsxs(xt,{align:"end",trigger:e.jsx("button",{type:"button",className:ht({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(A,{name:"ellipsis"})}),children:[e.jsx(m,{allowed:i,children:e.jsxs(me,{onClick:d,children:[e.jsx(A,{name:"pencil",className:"size-3.5"}),"Edit"]})}),e.jsx(m,{allowed:i,children:e.jsxs(me,{onClick:g,children:[e.jsx(A,{name:t.status==="active"?"pause":"play",className:"size-3.5"}),t.status==="active"?"Pause":"Resume"]})}),e.jsx(m,{allowed:a,children:e.jsxs(me,{className:"text-failure-bg focus:text-failure-bg",onClick:y,children:[e.jsx(A,{name:"trash",className:"size-3.5"}),"Delete"]})})]})]})}function Qt({agentId:t}){const s=be(),i=Le(),a=ge(),[r,d]=l.useState([]),{allows:g}=xe({resourceType:"schedule",resourceIds:r.map(n=>n.id)}),[y,m]=l.useState({}),[f,u]=l.useState(!1),[p,j]=l.useState(()=>new Set),[o,w]=l.useState({}),[E,b]=l.useState(!0),[k,C]=l.useState(null),[z,H]=l.useState(()=>oe(window.location.search).nameQuery),[R,F]=l.useState(()=>oe(window.location.search).statusFilter),[v,W]=l.useState(()=>t??oe(window.location.search).agentFilter),B=t??(v==="all"?null:v),{allows:D}=xe({resourceType:"agent",resourceIds:B==null?[]:[B]}),I=i.permissions==null||B==null||D(B,"USE"),[G,O]=l.useState(()=>Ht(t)),[_,K]=l.useState(null),[P,U]=l.useState(()=>ie(lt)),[V,L]=l.useState(void 0),[Q,ee]=l.useState(void 0),[h,c]=l.useState([]),N=l.useRef(0),S=l.useRef(!1),Y=l.useCallback(async({rows:n,gen:x})=>{if(n.length===0){x===N.current&&m({});return}u(!0);try{const T=await Promise.allSettled(n.map(M=>s.listScheduleRuns({scheduleId:M.id})));if(x!==N.current)return;m(Object.fromEntries(n.map((M,Z)=>{const se=T[Z],Ve=(se==null?void 0:se.status)==="fulfilled"?se.value:[];return[M.id,Ve]})))}finally{x===N.current&&u(!1)}},[s]),te=l.useCallback(async({token:n,size:x,agentId:T})=>{const M=++N.current;b(!0),C(null);try{const Z=await s.listSchedules({limit:ie(x),...n===void 0||n===""?{}:{pageToken:n},...T==="all"?{}:{agentIds:[T]}});if(M!==N.current)return;d(Z.data),ee(Z.nextPageToken),Y({rows:Z.data,gen:M})}catch(Z){if(M!==N.current)return;const se=Z instanceof Error?Z.message:"Failed to load schedules";C(se),d([]),m({}),ee(void 0)}finally{M===N.current&&b(!1)}},[s,Y]),Ne=l.useCallback(n=>{const x=(n==null?void 0:n.size)??P,T=(n==null?void 0:n.agentId)??v;L(void 0),c([]),te({token:void 0,size:x,agentId:T})},[v,te,P]);l.useEffect(()=>{Se({agent:t===void 0&&v!=="all"?v:null,status:R==="all"?null:R,q:z.trim().length===0?null:z})},[v,t,R,z]),l.useEffect(()=>{t!==void 0&&W(n=>n===t?n:(L(void 0),c([]),t))},[t]),l.useEffect(()=>{S.current||!pe(window.location.search).isNew||(S.current=!0,Se({isNew:null}))},[]),l.useEffect(()=>{const n=()=>{const x=oe(window.location.search);H(x.nameQuery),F(x.statusFilter),W(T=>{const M=t??x.agentFilter;return T===M?T:(L(void 0),c([]),M)})};return window.addEventListener("popstate",n),()=>{window.removeEventListener("popstate",n)}},[t]),l.useEffect(()=>{te({token:V,size:P,agentId:v})},[v,P,V,te]);const re=l.useMemo(()=>{const n=z.trim().toLowerCase();return r.filter(x=>!(R!=="all"&&x.status!==R||n.length>0&&!x.name.toLowerCase().includes(n)))},[r,z,R]),ye=Qe(r),je=h.length>0||Q!=null,qe=async n=>{if(!g(n.id,"MANAGE"))return;const x=n.status==="active"?"paused":"active";try{await s.updateSchedule({...n,status:x}),await te({token:V,size:P,agentId:v})}catch(T){a==null||a.showError(T)}},He=async n=>{if(g(n.id,"MANAGE")){j(x=>new Set(x).add(n.id));try{await s.createScheduleRun({scheduleId:n.id}),a==null||a.showSuccess({title:"Run started"});const x=await s.listScheduleRuns({scheduleId:n.id});m(T=>({...T,[n.id]:x}))}catch(x){a==null||a.showError(x)}finally{j(x=>{const T=new Set(x);return T.delete(n.id),T})}}},Ge=async n=>{if(g(n.id,"DELETE")){K(null);try{await s.deleteSchedule({id:n.id}),Ne()}catch(x){a==null||a.showError(x)}}},ve=()=>{Q!=null&&(c(n=>[...n,V??""]),L(Q))},we=()=>{if(h.length===0)return;const n=[...h],x=n.pop();c(n),L(x===""?void 0:x)};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-primary-bg",children:[e.jsx(We,{title:t===void 0?"Scheduled Agents":void 0,end:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full sm:w-60",children:e.jsx(Ke,{query:z,setQuery:H,placeholder:"Search schedules by name"})}),e.jsx(ce,{value:R,onValueChange:F,options:qt,className:"sm:w-40","aria-label":"Filter by status"}),t===void 0?e.jsx(Fe,{value:v,selectedLabel:v==="all"?"All agents":o[v]??v,onValueChange:n=>{W(n),L(void 0),c([])},onAgentPicked:n=>{w(x=>({...x,[ue(n)]:n.name}))},allOption:{value:"all",label:"All agents"},className:"sm:w-48","aria-label":"Filter by agent",placeholder:"Search agent"}):null,e.jsxs(q.Primary,{type:"button",disabled:!I,onClick:()=>I&&O({kind:"create",agentId:v!=="all"?v:void 0}),children:[e.jsx(A,{name:"plus",className:"size-3.5"}),"New Schedule"]})]})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4",children:E?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading schedules",children:Array.from({length:5},(n,x)=>e.jsx(Ye,{className:"h-12 w-full rounded-md"},x))}):k!=null?e.jsx("p",{className:"text-failure-bg px-3 py-8 text-center text-sm",children:k}):r.length===0?e.jsx(ke,{title:"No Schedules Found",description:"Create one to get started.",className:"min-h-full"}):re.length===0?e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx(ke,{title:"No Schedules Found",description:"No schedules match your filters.",className:"flex-1"}),je?e.jsx(Te,{pageSize:P,rowCount:0,canPrev:h.length>0,canNext:Q!=null,onPrev:we,onNext:ve,pageSizeOptions:Pe,onPageSizeChange:n=>{const x=ie(n);U(x),L(void 0),c([])}}):null]}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs(Ze,{className:"min-w-[48rem]",children:[e.jsx(Je,{children:e.jsxs(Ce,{className:"hover:bg-transparent",children:[e.jsx(J,{children:"Name"}),e.jsx(J,{children:"Agent"}),ye?e.jsx(J,{children:"Created by"}):null,e.jsx(J,{children:"Frequency"}),e.jsx(J,{children:"Status"}),e.jsx(J,{children:"Last 5 runs"}),e.jsx(J,{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx(Xe,{children:re.map(n=>{const x=ae({cron:n.cron,timezone:n.timezone}),T=n.agentName??o[n.agentId]??n.agentId;return e.jsxs(Ce,{children:[e.jsx(X,{className:"text-text-primary font-medium",children:e.jsx("span",{className:"text-left !no-underline",children:n.name})}),e.jsx(X,{children:T}),ye?e.jsx(X,{children:e.jsx(et,{subject:n.createdBySubject})}):null,e.jsx(X,{children:x}),e.jsx(X,{children:e.jsx(Ue,{status:n.status})}),e.jsx(X,{children:f?e.jsx("span",{className:"text-text-secondary text-sm",children:"…"}):e.jsx(Ut,{runs:y[n.id]??[]})}),e.jsx(X,{className:"text-right",children:e.jsx(Gt,{schedule:n,running:p.has(n.id),canManage:g(n.id,"MANAGE"),canDelete:g(n.id,"DELETE"),onRunNow:()=>void He(n),onEdit:()=>{g(n.id,"MANAGE")&&O({kind:"edit",schedule:n})},onTogglePause:()=>void qe(n),onDelete:()=>{g(n.id,"DELETE")&&K(n)}})})]},n.id)})})]}),(re.length>0||je)&&e.jsx(Te,{pageSize:P,rowCount:re.length,canPrev:h.length>0,canNext:Q!=null,onPrev:we,onNext:ve,pageSizeOptions:Pe,onPageSizeChange:n=>{const x=ie(n);U(x),L(void 0),c([])}})]})}),G.kind==="create"?e.jsx(De,{open:!0,mode:"create",initialAgentId:G.agentId??"",onOpenChange:n=>{n||O({kind:"closed"})},onSaved:()=>Ne()}):null,G.kind==="edit"?e.jsx(De,{open:!0,mode:"edit",schedule:G.schedule,onOpenChange:n=>{n||O({kind:"closed"})},onSaved:()=>void te({token:V,size:P,agentId:v})}):null,_!=null?e.jsxs(tt,{open:!0,onOpenChange:n=>{n||K(null)},"aria-label":"Delete schedule",className:"max-w-md",children:[e.jsx(st,{children:e.jsxs(nt,{children:[e.jsx(at,{children:"Delete schedule"}),e.jsxs("p",{className:"text-text-secondary text-sm",children:["“",_.name,"” will stop running. This cannot be undone."]})]})}),e.jsxs(rt,{children:[e.jsx(q.Secondary,{type:"button",onClick:()=>K(null),children:"Cancel"}),e.jsx(q.Destructive,{type:"button",disabled:!g(_.id,"DELETE"),onClick:()=>void Ge(_),children:"Delete"})]})]}):null]})}export{Qt as SchedulesPage};
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModelSettings-
|
|
2
|
-
import{g as h,i as v,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModelSettings-3YAHICJ3-CYXhuUMp.js","./index-G7kdtXvB.js","./index-B01pXqvC.css","./ConnectorSettings-C6MFCKYX-BvX0CZ86.js","./SkillSettings-E5SJ4U3T-hOs4000P.js","./SandboxSettings-ALR6F5KU-BhpQsOwg.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{g as h,i as v,aS as y,ap as j,aT as S,r as t,j as e,P as _,I as p,d as k,e as f,_ as d,S as w}from"./index-G7kdtXvB.js";var E=t.lazy(()=>d(()=>import("./ModelSettings-3YAHICJ3-CYXhuUMp.js"),__vite__mapDeps([0,1,2]),import.meta.url)),C=t.lazy(()=>d(()=>import("./ConnectorSettings-C6MFCKYX-BvX0CZ86.js"),__vite__mapDeps([3,1,2]),import.meta.url)),N=t.lazy(()=>d(()=>import("./SkillSettings-E5SJ4U3T-hOs4000P.js"),__vite__mapDeps([4,1,2]),import.meta.url)),L=t.lazy(()=>d(()=>import("./SandboxSettings-ALR6F5KU-BhpQsOwg.js"),__vite__mapDeps([5,1,2]),import.meta.url));function O(){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(w,{size:20,className:"text-text-secondary"}),e.jsx("span",{className:"sr-only",children:"Loading"})]})}var P=()=>{const{settingsOpen:n,settingsSection:l,setSettingsOpen:r}=h(),a=v(),u=y(),{refresh:m}=j(),i=S(),o=(a==null?void 0:a.skillCatalog)!=null,c=(a==null?void 0:a.sandboxCatalog)!=null,x=t.useCallback(()=>{r(!1)},[r]);t.useEffect(()=>{if(n)return()=>{m(),u==null||u()}},[n,m,u]),t.useEffect(()=>{!o&&l==="skills"&&r(n,"models"),!c&&l==="sandbox"&&r(n,"models")},[o,c,l,n,r]),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 g=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||!a?null:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col bg-primary-bg",children:[e.jsx(_,{title:"Settings",start:e.jsx("button",{type:"button","aria-label":"Back",title:"Back",className:k({variant:"ghost",size:"icon"}),onClick:x,children:e.jsx(p,{name:"arrow-left"})})}),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:g.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/10 text-primary-button-bg":"text-text-secondary hover:bg-ghost-button-hover/60 hover:text-text-primary"),onClick:()=>{r(!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(O,{}),children:[l==="models"?e.jsx(E,{}):null,l==="connectors"?e.jsx(C,{}):null,l==="skills"&&o?e.jsx(N,{}):null,l==="sandbox"&&c?e.jsx(L,{}):null]})})})]})]})},I=P;export{I as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as F,p as v,b as J,s as I}from"./chunk-
|
|
1
|
+
import{m as F,p as v,b as J,s as I}from"./chunk-B76JC5B2-BMXX-7i9.js";import{g as ne,h as re,i as se,k as ae,l as ie,m as le,n as ue,r as a,t as oe,o as ce,p as ge,q as pe}from"./index-G7kdtXvB.js";import{u as fe,a as ye}from"./chunk-62JRHF6Z-DVHPxtc3.js";var M="try_agent_name",_="history_agent_name";function V(n){return n!=null&&n.length>0?n:null}function E(n){const i=new URLSearchParams(n.startsWith("?")?n.slice(1):n),l=V(i.get(M));if(l!=null)return{intent:"try-agent",agentName:l};const e=V(i.get(_));return e==null?null:{intent:"history",agentName:e}}function he(n,i){n.delete(M),n.delete(_),i!=null&&n.set(i.intent==="try-agent"?M:_,i.agentName)}function X(n,i){const l=new URLSearchParams(n.startsWith("?")?n.slice(1):n);he(l,i);const e=l.toString();return e.length>0?`?${e}`:""}function Z(n){const i=n.activeRemoteId??n.pendingSessionId;if(i!=null)return{type:"session",sessionId:i};const{mode:l,agentConfigMode:e}=n;if(l.status==="active"&&l.isMutable&&l.isCreateAgent)return{type:"buildAgent"};if(l.status==="active"&&!l.isMutable&&e!=="SingleAgent"){const g=l.agentName??l.agentId;if(g!=null)return{type:"agent",agentName:g}}return{type:"root"}}function de(n){return n.settingsOpen?{type:"settings"}:n.schedulesOpen?{type:"schedules"}:n.sessionsOpen?{type:"sessionsBrowser"}:n.libraryOpen&&n.libraryAgentId!=null?{type:"libraryAgent",agentId:n.libraryAgentId}:n.libraryOpen?{type:"library"}:Z(n)}function b(n){return n.type==="root"||n.type==="agent"||n.type==="session"}function Ae({routes:n,activeRemoteId:i,initialSettingsOpen:l}){var j,z;const e=ne(),g=re(),B=se(),k=ae(),q=ie(),U=le(),$=ue(),C=fe(),s=ye(),o=a.useMemo(()=>oe({routes:n,catalog:B,capabilities:U,sessions:k,schedules:q}),[n,B,U,k,q]),T=o.settings!=null,x=[o.settings,o.sessionsBrowser,o.libraryAgent,o.schedules].join("\0"),W={settingsOpen:e.settingsOpen,libraryOpen:e.libraryOpen,sessionsOpen:e.sessionsOpen,libraryAgentId:e.libraryAgentId,schedulesOpen:e.schedulesOpen,pendingSessionId:e.pendingSessionId,activeRemoteId:i,mode:e.mode,agentConfigMode:e.agentConfigMode},p=de(W),ee=JSON.stringify(p),S=a.useRef(null),H=a.useRef(null),A=a.useRef(null),O=a.useRef(!1),P=a.useRef(null),m=a.useRef(null),w=a.useRef(null),f=a.useRef(null),Y=a.useRef(!1),G=a.useRef(!1),K=a.useCallback(t=>{if(w.current=t,g==null){e.openHistorySession({sessionId:t});return}g.getSession({sessionId:t}).then(r=>{w.current===t&&e.openHistorySession({sessionId:t,isMutable:r.isMutable,isCreateAgent:ce(r),...r.agentName!=null?{agentName:r.agentName}:{}})}).catch(()=>{w.current===t&&e.openHistorySession({sessionId:t})})},[g,e]),h=a.useCallback(t=>{if(t==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}const r=`${t.intent}\0${t.agentName}`,u=e.historyAgentFilter;if((u==null?void 0:u.intent)===t.intent&&u.agentName===t.agentName&&u.agentId!=null){f.current=null;return}f.current=r,e.setHistoryAgentFilter(t),g!=null&&ge({server:g,agentName:t.agentName}).then(c=>{if(f.current===r){if(c==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}f.current=null,e.setHistoryAgentFilter({agentId:pe(c),agentName:c.name,intent:t.intent})}}).catch(()=>{f.current===r&&(f.current=null,m.current=null,e.setHistoryAgentFilter(null))})},[g,e]),Q=a.useCallback(t=>{e.selectLibraryAgent({isMutable:!1,agentName:t}),h({intent:"try-agent",agentName:t})},[h,e]),L=a.useCallback(t=>{switch(t.type){case"settings":e.setSettingsOpen(!0);return;case"library":e.setLibraryOpen(!0);return;case"sessionsBrowser":e.setSessionsOpen(!0);return;case"libraryAgent":e.openLibraryAgent(t.agentId);return;case"schedules":e.setSchedulesOpen(!0);return;case"buildAgent":e.openAgentBuilder();return;case"session":if(e.setLibraryOpen(!1),e.pendingSessionId===t.sessionId||i===t.sessionId)return;K(t.sessionId);return;case"agent":e.setLibraryOpen(!1),Q(t.agentName);return;case"root":switch(e.setSettingsOpen(!1),e.setLibraryOpen(!1),e.setSchedulesOpen(!1),e.agentConfigMode){case"AgentLibrary":e.openLibraryHome();return;case"AgentComposer":case"AgentLibraryWithComposer":e.openDraft();return;case"SingleAgent":e.clearChat();return}}},[e,i,Q,K]);return a.useEffect(()=>{if(O.current)return;const t=F({pathname:s.pathname,search:s.search,routes:n});if(!$&&(t==null?void 0:t.type)==="settings")return;O.current=!0;const r=F({pathname:s.pathname,search:s.search,routes:o})??{type:"root"},u=r.type==="agent"?{intent:"try-agent",agentName:r.agentName}:b(r)?E(s.search):null;m.current=u,A.current=r;const c=T&&(l||r.type==="settings");if(r.type==="settings")T&&e.setSettingsOpen(!0);else if(r.type==="library")e.setLibraryOpen(!0);else if(r.type==="sessionsBrowser")e.setSessionsOpen(!0);else if(r.type==="libraryAgent")e.openLibraryAgent(r.agentId);else if(r.type==="schedules")e.setSchedulesOpen(!0);else{const R=Z(W);v(R,r)||L(r),c&&e.setSettingsOpen(!0)}r.type!=="agent"&&u!=null?h(u):b(r)||h(null);const d=c?{type:"settings"}:r;P.current=v(p,d)?null:d;const y=J(d,o),N=X(I(d,s.search),u);H.current=d,y!=null&&(y!==s.pathname||N!==s.search)&&(S.current=y!==s.pathname?y:null,C({pathname:y,search:N,hash:s.hash},{replace:!0}))},[$]),a.useEffect(()=>{if(!O.current)return;if(!Y.current){Y.current=!0;return}const t=P.current;if(t!=null){if(!v(p,t))return;P.current=null}const r=J(p,o);if(r==null)return;const c=`${o.basename.endsWith("/")?o.basename.slice(0,-1):o.basename}${s.pathname}`||"/",d=window.location.pathname===c?window.location.search:s.search,y=b(p),N=y?e.historyAgentFilter==null?m.current:{intent:e.historyAgentFilter.intent,agentName:e.historyAgentFilter.agentName}:null;!y&&e.historyAgentFilter!=null&&(f.current=null,e.setHistoryAgentFilter(null)),e.historyAgentFilter!=null&&(m.current=null);const R=X(I(p,d),N),D=H.current;if(H.current=p,r===s.pathname&&R===s.search)return;const te=p.type==="session"&&e.pendingSessionId==null&&D!=null&&D.type!=="session";S.current=r!==s.pathname?r:null,C({pathname:r,search:R,hash:s.hash},{replace:te})},[ee,x,(j=e.historyAgentFilter)==null?void 0:j.agentName,(z=e.historyAgentFilter)==null?void 0:z.intent]),a.useEffect(()=>{if(!O.current)return;if(!G.current){G.current=!0;return}if(S.current===s.pathname){S.current=null,A.current=p;return}const t=F({pathname:s.pathname,search:s.search,routes:o});if(t==null){const u=o.root,c=I({type:"root"},s.search);S.current=u,C({pathname:u,search:c,hash:s.hash},{replace:!0}),L({type:"root"}),h(E(c));return}const r=A.current;A.current=t,(r==null||!v(r,t))&&(t.type!=="settings"&&e.settingsOpen&&e.setSettingsOpen(!1),t.type!=="library"&&t.type!=="libraryAgent"&&e.libraryOpen&&e.setLibraryOpen(!1),t.type!=="sessionsBrowser"&&e.sessionsOpen&&e.setSessionsOpen(!1),t.type!=="schedules"&&e.schedulesOpen&&e.setSchedulesOpen(!1),L(t)),t.type!=="agent"&&b(t)?h(E(s.search)):b(t)||h(null)},[s.pathname,s.search]),null}export{Ae as ShellRouteSync};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-G5CP5X6Q-XQVNLXzw.js","./index-G7kdtXvB.js","./index-B01pXqvC.css","./SchedulesPage-TIS3BH67-CoDDvRbI.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{bG as _,bH as Vt,u as G,j as r,bI as Xt,r as d,b1 as P,bJ as He,bK as Wt,bL as Ue,bM as Ve,bN as Xe,bO as We,bP as Ye,bQ as Y,bR as Yt,bS as j,bT as qt,bU as Qt,bV as Zt,bW as Jt,bX as en,bY as tn,bZ as nn,b_ as rn,b$ as be,c0 as sn,c1 as on,c2 as le,c3 as an,c4 as cn,c5 as ln,c6 as qe,c7 as De,c8 as ue,c9 as we,ca as oe,cb as ye,cc as Ie,cd as Me,ce as _e,h as Qe,a as ee,c as N,O as un,cf as dn,e as K,N as mn,cg as fn,ch as hn,ci as pn,b as Ce,aT as Ze,ac as gn,U as xn,aj as Ae,I as z,q as vn,d as se,cj as Je,ad as bn,ag as wn,ck as Oe,aX as yn,aq as In,W as ke,s as et,cl as Mn,P as Cn,S as Fe,cm as Sn,cn as Ln,_ as tt,bz as jn}from"./index-G7kdtXvB.js";import{A as Tn,N as Rn,T as Nn,S as Pn}from"./chunk-G7BT4OKG-D-wOOnsv.js";const Se=n=>{const e=_(8),{index:t,archived:s,children:o}=n;let i;e[0]!==s||e[1]!==t?(i=Vt({source:"threads",query:{type:"index",index:t,archived:s},get:c=>c.threads().item({index:t,archived:s})}),e[0]=s,e[1]=t,e[2]=i):i=e[2];let a;e[3]!==i?(a={threadListItem:i},e[3]=i,e[4]=a):a=e[4];const l=G(a);let u;return e[5]!==l||e[6]!==o?(u=r.jsx(Xt,{value:l,children:o}),e[5]=l,e[6]=o,e[7]=u):u=e[7],u},nt=d.memo(n=>{const e=_(6),{index:t,archived:s,components:o}=n,i=s===void 0?!1:s,a=o.ThreadListItem;let l;e[0]!==a?(l=r.jsx(a,{}),e[0]=a,e[1]=l):l=e[1];let u;return e[2]!==i||e[3]!==t||e[4]!==l?(u=r.jsx(Se,{index:t,archived:i,children:l}),e[2]=i,e[3]=t,e[4]=l,e[5]=u):u=e[5],u},(n,e)=>n.index===e.index&&n.archived===e.archived&&n.components.ThreadListItem===e.components.ThreadListItem);nt.displayName="ThreadListPrimitive.ItemByIndex";const Be=({archived:n,children:e})=>{const t=P(s=>n?s.threads.archivedThreadIds.length:s.threads.threadIds.length);return He(()=>Array.from({length:t},(s,o)=>r.jsx(Se,{index:o,archived:n,children:r.jsx(Wt,{getItemState:i=>i.threads().item({index:o,archived:n}).getState(),children:i=>e({get threadListItem(){return i()}})})},o)),[t,n,e])},rt=n=>{const e=_(8),{archived:t,components:s,children:o}=n,i=t===void 0?!1:t;if(s){const l=s.ThreadListItem;let u;e[0]!==l?(u=()=>r.jsx(l,{}),e[0]=l,e[1]=u):u=e[1];let c;return e[2]!==i||e[3]!==u?(c=r.jsx(Be,{archived:i,children:u}),e[2]=i,e[3]=u,e[4]=c):c=e[4],c}let a;return e[5]!==i||e[6]!==o?(a=r.jsx(Be,{archived:i,children:o}),e[5]=i,e[6]=o,e[7]=a):a=e[7],a};rt.displayName="ThreadListPrimitive.Items";const st=n=>{const e=_(2),{fallback:t}=n,s=P(En)||t;let o;return e[0]!==s?(o=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=o):o=e[1],o};st.displayName="ThreadListItemPrimitive.Title";function En(n){return n.threadListItem.title}const Dn=()=>{const n=_(4),e=G();let t;n[0]!==e?(t=()=>{e.threadListItem().archive()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={archive:s},n[2]=s,n[3]=o):o=n[3],o},_n=()=>{const n=_(4),e=G();let t;n[0]!==e?(t=()=>{e.threadListItem().delete()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={delete:s},n[2]=s,n[3]=o):o=n[3],o},An=()=>{const n=_(4),e=G();let t;n[0]!==e?(t=()=>{e.threadListItem().unarchive()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={unarchive:s},n[2]=s,n[3]=o):o=n[3],o},On=()=>{const n=_(4),e=G();let t;n[0]!==e?(t=()=>{e.threadListItem().switchTo()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={switchTo:s},n[2]=s,n[3]=o):o=n[3],o},kn=()=>{const n=_(4),e=G();let t;n[0]!==e?(t=()=>{e.threads().switchToNewThread()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={switchToNewThread:s},n[2]=s,n[3]=o):o=n[3],o},Fn=()=>{const n=_(5),e=G(),t=P(Bn);let s;n[0]!==e?(s=()=>{e.threads().loadMore()},n[0]=e,n[1]=s):s=n[1];const o=s;let i;return n[2]!==t||n[3]!==o?(i={loadMore:o,disabled:t},n[2]=t,n[3]=o,n[4]=i):i=n[4],i};function Bn(n){return!n.threads.hasMore||n.threads.isLoading||n.threads.isLoadingMore}var Kn=Object.defineProperty,S=(n,e)=>Kn(n,"name",{value:e,configurable:!0}),$n=["Enter"," "],zn=["ArrowDown","PageUp","Home"],ot=["ArrowUp","PageDown","End"],Gn=[...zn,...ot],de="Menu",[ge,Hn,Un]=We(de),[q,at]=Ue(de,[Un,Ve,Xe]),Le=Ve(),it=Xe(),[Vn,ae]=q(de),[Xn,je]=q(de),Wn=S(n=>{const{__scopeMenu:e,open:t=!1,children:s,dir:o,onOpenChange:i,modal:a=!0}=n,l=Le(e),[u,c]=d.useState(null),m=d.useRef(!1),p=on(i),h=le(o);return d.useEffect(()=>{const f=S(()=>{m.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},"handleKeyDown"),x=S(()=>m.current=!1,"handlePointer");return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),d.useEffect(()=>{if(!t)return;const f=S(()=>p(!1),"handleBlur");return window.addEventListener("blur",f),()=>window.removeEventListener("blur",f)},[t,p]),r.jsx(an,{...l,children:r.jsx(Vn,{scope:e,open:t,onOpenChange:p,content:u,onContentChange:c,children:r.jsx(Xn,{scope:e,onClose:d.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:m,dir:h,modal:a,children:s})})})},"Menu"),Yn=d.forwardRef(S(function(e,t){const{__scopeMenu:s,...o}=e,i=Le(s);return r.jsx(cn,{...i,...o,ref:t})},"MenuAnchor")),ct="MenuPortal",[qn,Qn]=q(ct,{forceMount:void 0}),Zn=S(n=>{const{__scopeMenu:e,forceMount:t,children:s,container:o}=n,i=ae(ct,e);return r.jsx(qn,{scope:e,forceMount:t,children:r.jsx(Ye,{present:t||i.open,children:r.jsx(ln,{asChild:!0,container:o,children:s})})})},"MenuPortal"),W="MenuContent",[Jn,lt]=q(W),er=d.forwardRef(S(function(e,t){const s=Qn(W,e.__scopeMenu),{forceMount:o=s.forceMount,...i}=e,a=ae(W,e.__scopeMenu),l=je(W,e.__scopeMenu);return r.jsx(ge.Provider,{scope:e.__scopeMenu,children:r.jsx(Ye,{present:o||a.open,children:r.jsx(ge.Slot,{scope:e.__scopeMenu,children:l.modal?r.jsx(tr,{...i,ref:t}):r.jsx(nr,{...i,ref:t})})})})},"MenuContent")),tr=d.forwardRef(S(function(e,t){const s=ae(W,e.__scopeMenu),o=d.useRef(null),i=Y(t,o);return d.useEffect(()=>{const a=o.current;if(a)return Yt(a)},[]),r.jsx(ut,{...e,ref:i,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:j(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentModal")),nr=d.forwardRef(S(function(e,t){const s=ae(W,e.__scopeMenu);return r.jsx(ut,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentNonModal")),rr=sn("MenuContent.ScrollLock"),ut=d.forwardRef(S(function(e,t){const{__scopeMenu:s,loop:o=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:l,disableOutsidePointerEvents:u,onEntryFocus:c,onEscapeKeyDown:m,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:f,onDismiss:x,disableOutsideScroll:g,...b}=e,y=ae(W,s),M=je(W,s),L=Le(s),R=it(s),O=Hn(s),[F,A]=d.useState(null),E=d.useRef(null),I=Y(t,E,y.onContentChange),T=d.useRef(0),D=d.useRef(""),C=d.useRef(0),k=d.useRef(null),w=d.useRef("right"),Q=d.useRef(0),U=g?Qt:d.Fragment,V=g?{as:rr,allowPinchZoom:!0}:void 0,me=S(v=>{var J,Pe;const B=D.current+v,$=O().filter(H=>!H.disabled),X=document.activeElement,fe=(J=$.find(H=>H.ref.current===X))==null?void 0:J.textValue,he=$.map(H=>H.textValue),Ne=pt(he,B,fe),re=(Pe=$.find(H=>H.textValue===Ne))==null?void 0:Pe.ref.current;S((function H(Ee){D.current=Ee,window.clearTimeout(T.current),Ee!==""&&(T.current=window.setTimeout(()=>H(""),1e3))}),"updateSearch")(B),re&&setTimeout(()=>re.focus())},"handleTypeaheadSearch");d.useEffect(()=>()=>window.clearTimeout(T.current),[]),qt();const Z=d.useCallback(v=>{var $,X;return w.current===(($=k.current)==null?void 0:$.side)&&xt(v,(X=k.current)==null?void 0:X.area)},[]);return r.jsx(Jn,{scope:s,searchRef:D,onItemEnter:d.useCallback(v=>{Z(v)&&v.preventDefault()},[Z]),onItemLeave:d.useCallback(v=>{var B;Z(v)||((B=E.current)==null||B.focus(),A(null))},[Z]),onTriggerLeave:d.useCallback(v=>{Z(v)&&v.preventDefault()},[Z]),pointerGraceTimerRef:C,onPointerGraceIntentChange:d.useCallback(v=>{k.current=v},[]),children:r.jsx(U,{...V,children:r.jsx(Zt,{asChild:!0,trapped:i,onMountAutoFocus:j(a,v=>{var B;v.preventDefault(),(B=E.current)==null||B.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:r.jsx(Jt,{asChild:!0,disableOutsidePointerEvents:u,onEscapeKeyDown:m,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:f,onDismiss:x,children:r.jsx(en,{asChild:!0,...R,dir:M.dir,orientation:"vertical",loop:o,currentTabStopId:F,onCurrentTabStopIdChange:A,onEntryFocus:j(c,v=>{M.isUsingKeyboardRef.current||v.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(tn,{role:"menu","aria-orientation":"vertical","data-state":dt(y.open),"data-radix-menu-content":"",dir:M.dir,...L,...b,ref:I,style:{outline:"none",...b.style},onKeyDown:j(b.onKeyDown,v=>{const $=v.target.closest("[data-radix-menu-content]")===v.currentTarget,X=v.ctrlKey||v.altKey||v.metaKey,fe=v.key.length===1;$&&(v.key==="Tab"&&v.preventDefault(),!X&&fe&&me(v.key));const he=E.current;if(v.target!==he||!Gn.includes(v.key))return;v.preventDefault();const re=O().filter(J=>!J.disabled).map(J=>J.ref.current);ot.includes(v.key)&&re.reverse(),ft(re)}),onBlur:j(e.onBlur,v=>{v.currentTarget.contains(v.target)||(window.clearTimeout(T.current),D.current="")}),onPointerMove:j(e.onPointerMove,ce(v=>{const B=v.target,$=Q.current!==v.clientX;if(v.currentTarget.contains(B)&&$){const X=v.clientX>Q.current?"right":"left";w.current=X,Q.current=v.clientX}}))})})})})})})},"MenuContentImpl")),xe="MenuItem",Ke="menu.itemSelect",sr=d.forwardRef(S(function(e,t){const{disabled:s=!1,onSelect:o,...i}=e,a=d.useRef(null),l=je(xe,e.__scopeMenu),u=lt(xe,e.__scopeMenu),c=Y(t,a),m=d.useRef(!1),p=S(()=>{const h=a.current;if(!s&&h){const f=new CustomEvent(Ke,{bubbles:!0,cancelable:!0});h.addEventListener(Ke,x=>o==null?void 0:o(x),{once:!0}),nn(h,f),f.defaultPrevented?m.current=!1:l.onClose()}},"handleSelect");return r.jsx(or,{...i,ref:c,disabled:s,onClick:j(e.onClick,p),onPointerDown:h=>{var f;(f=e.onPointerDown)==null||f.call(e,h),m.current=!0},onPointerUp:j(e.onPointerUp,h=>{var f;m.current||(f=h.currentTarget)==null||f.click()}),onKeyDown:j(e.onKeyDown,h=>{s||h.target!==h.currentTarget||u.searchRef.current!==""&&h.key===" "||$n.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})},"MenuItem")),or=d.forwardRef(S(function(e,t){const{__scopeMenu:s,disabled:o=!1,textValue:i,...a}=e,l=lt(xe,s),u=it(s),c=d.useRef(null),m=Y(t,c),[p,h]=d.useState(!1),[f,x]=d.useState("");return d.useEffect(()=>{const g=c.current;g&&x((g.textContent??"").trim())},[a.children]),r.jsx(ge.ItemSlot,{scope:s,disabled:o,textValue:i??f,children:r.jsx(rn,{asChild:!0,...u,focusable:!o,children:r.jsx(be.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":o||void 0,"data-disabled":o?"":void 0,...a,ref:m,onPointerMove:j(e.onPointerMove,ce(g=>{o?l.onItemLeave(g):(l.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:j(e.onPointerLeave,ce(g=>l.onItemLeave(g))),onFocus:j(e.onFocus,()=>h(!0)),onBlur:j(e.onBlur,()=>h(!1))})})})},"MenuItemImpl")),ar="MenuRadioGroup",[ls,us]=q(ar,{value:void 0,onValueChange:S(()=>{},"onValueChange")}),ir="MenuItemIndicator",[ds,ms]=q(ir,{checked:!1}),cr=d.forwardRef(S(function(e,t){const{__scopeMenu:s,...o}=e;return r.jsx(be.div,{role:"separator","aria-orientation":"horizontal",...o,ref:t})},"MenuSeparator")),lr="MenuSub",[fs,hs]=q(lr);function dt(n){return n?"open":"closed"}S(dt,"getOpenState");function mt(n){return n==="indeterminate"}S(mt,"isIndeterminate");function ur(n){return mt(n)?"indeterminate":n?"checked":"unchecked"}S(ur,"getCheckedState");function ft(n){const e=document.activeElement;for(const t of n)if(t===e||(t.focus(),document.activeElement!==e))return}S(ft,"focusFirst");function ht(n,e){return n.map((t,s)=>n[(e+s)%n.length])}S(ht,"wrapArray");function pt(n,e,t){const o=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,i=t?n.indexOf(t):-1;let a=ht(n,Math.max(i,0));o.length===1&&(a=a.filter(c=>c!==t));const u=a.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return u!==t?u:void 0}S(pt,"getNextMatch");function gt(n,e){const{x:t,y:s}=n;let o=!1;for(let i=0,a=e.length-1;i<e.length;a=i++){const l=e[i],u=e[a],c=l.x,m=l.y,p=u.x,h=u.y;m>s!=h>s&&t<(p-c)*(s-m)/(h-m)+c&&(o=!o)}return o}S(gt,"isPointInPolygon");function xt(n,e){if(!e)return!1;const t={x:n.clientX,y:n.clientY};return gt(t,e)}S(xt,"isPointerInGraceArea");function ce(n){return e=>e.pointerType==="mouse"?n(e):void 0}S(ce,"whenMouse");var dr=Wn,mr=Yn,fr=Zn,hr=er,pr=sr,gr=cr,xr=Object.defineProperty,te=(n,e)=>xr(n,"name",{value:e,configurable:!0}),Te="DropdownMenu",[vr,vt]=Ue(Te,[at]),ne=at(),[br,bt]=vr(Te),wt=te(n=>{const{__scopeDropdownMenu:e,children:t,dir:s,open:o,defaultOpen:i,onOpenChange:a,modal:l=!0}=n,u=ne(e),c=d.useRef(null),[m,p]=qe({prop:o,defaultProp:i??!1,onChange:a,caller:Te});return r.jsx(br,{scope:e,triggerId:De(),triggerRef:c,contentId:De(),open:m,onOpenChange:p,onOpenToggle:d.useCallback(()=>p(h=>!h),[p]),modal:l,children:r.jsx(dr,{...u,open:m,onOpenChange:p,dir:s,modal:l,children:t})})},"DropdownMenu"),wr="DropdownMenuTrigger",yt=d.forwardRef(te(function(e,t){const{__scopeDropdownMenu:s,disabled:o=!1,...i}=e,a=bt(wr,s),l=ne(s),u=Y(t,a.triggerRef);return r.jsx(mr,{asChild:!0,...l,children:r.jsx(be.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":o?"":void 0,disabled:o,...i,ref:u,onPointerDown:j(e.onPointerDown,c=>{!o&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:j(e.onKeyDown,c=>{o||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})},"DropdownMenuTrigger")),It=te(n=>{const{__scopeDropdownMenu:e,...t}=n,s=ne(e);return r.jsx(fr,{...s,...t})},"DropdownMenuPortal"),yr="DropdownMenuContent",Mt=d.forwardRef(te(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=bt(yr,s),a=ne(s),l=d.useRef(!1);return r.jsx(hr,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...o,ref:t,onCloseAutoFocus:j(e.onCloseAutoFocus,u=>{var c;l.current||(c=i.triggerRef.current)==null||c.focus(),l.current=!1,u.preventDefault()}),onInteractOutside:j(e.onInteractOutside,u=>{const c=u.detail.originalEvent,m=c.button===0&&c.ctrlKey===!0,p=c.button===2||m;(!i.modal||p)&&(l.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),Ct=d.forwardRef(te(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=ne(s);return r.jsx(pr,{...i,...o,ref:t})},"DropdownMenuItem")),St=d.forwardRef(te(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=ne(s);return r.jsx(gr,{...i,...o,ref:t})},"DropdownMenuSeparator")),Lt=wt,jt=yt,Ir=It,Tt=Mt,Rt=Ct,Nt=St;const Mr=Object.freeze(Object.defineProperty({__proto__:null,Content:Tt,DropdownMenu:wt,DropdownMenuContent:Mt,DropdownMenuItem:Ct,DropdownMenuPortal:It,DropdownMenuSeparator:St,DropdownMenuTrigger:yt,Item:Rt,Portal:Ir,Root:Lt,Separator:Nt,Trigger:jt,createDropdownMenuScope:vt},Symbol.toStringTag,{value:"Module"})),Cr=ue(jt),Sr=ue(Tt),Lr=ue(Rt),jr=ue(Nt),Pt=d.forwardRef((n,e)=>{const t=_(15);let s,o,i;t[0]!==n?({onClick:o,disabled:s,...i}=n,t[0]=n,t[1]=s,t[2]=o,t[3]=i):(s=t[1],o=t[2],i=t[3]);const a=P(Tr),{switchToNewThread:l}=kn();let u;t[4]!==a?(u=a?{"data-active":"true","aria-current":"true"}:null,t[4]=a,t[5]=u):u=t[5];let c;t[6]!==o||t[7]!==l?(c=j(o,l),t[6]=o,t[7]=l,t[8]=c):c=t[8];let m;return t[9]!==s||t[10]!==e||t[11]!==i||t[12]!==u||t[13]!==c?(m=r.jsx(we.button,{type:"button",...u,...i,ref:e,disabled:s,onClick:c}),t[9]=s,t[10]=e,t[11]=i,t[12]=u,t[13]=c,t[14]=m):m=t[14],m});Pt.displayName="ThreadListPrimitive.New";function Tr(n){return n.threads.newThreadId===n.threads.mainThreadId}const Rr=()=>{const{loadMore:n,disabled:e}=Fn();return e?null:n},Nr=oe("ThreadListPrimitive.LoadMore",Rr),[Pr,Er]=We("ThreadList"),ve=Pr,Et=Ie(null),Dr=Et.Provider,Re=()=>ye(Et),Dt=d.forwardRef((n,e)=>{const t=_(3);let s;return t[0]!==n||t[1]!==e?(s=r.jsx(ve.Provider,{scope:void 0,children:r.jsx(ve.Slot,{scope:void 0,children:r.jsx(we.div,{...n,ref:e})})}),t[0]=n,t[1]=e,t[2]=s):s=t[2],s});Dt.displayName="ThreadListPrimitive.Root";var _r=Me({ItemByIndex:()=>nt,Items:()=>rt,LoadMore:()=>Nr,New:()=>Pt,Root:()=>Dt});const _t=d.forwardRef((n,e)=>{const t=P(c=>c.threads.mainThreadId===c.threadListItem.id),s=_e(null),o=_e(null),i=He(()=>({triggerRef:s,moreRef:o}),[]),a=Er(void 0),l=le(),u=c=>{const m=l==="rtl"?"ArrowLeft":"ArrowRight",p=l==="rtl"?"ArrowRight":"ArrowLeft",h=s.current,f=o.current;if(h&&c.target===h)if(c.key==="ArrowDown"||c.key==="ArrowUp"){const x=a().map(b=>b.ref.current).filter(b=>b!==null),g=x[x.indexOf(h)+(c.key==="ArrowDown"?1:-1)];g&&(g.focus(),c.preventDefault())}else c.key===m&&f&&(f.focus(),c.preventDefault());else f&&c.target===f&&c.key===p&&(h==null||h.focus(),c.preventDefault())};return r.jsx(Dr,{value:i,children:r.jsx(we.div,{...t?{"data-active":"true","aria-current":"true"}:null,...n,onKeyDown:j(n.onKeyDown,u),ref:e})})});_t.displayName="ThreadListItemPrimitive.Root";const Ar=()=>{const{archive:n}=Dn();return n},Or=oe("ThreadListItemPrimitive.Archive",Ar),kr=()=>{const{unarchive:n}=An();return n},Fr=oe("ThreadListItemPrimitive.Unarchive",kr),Br=()=>{const{delete:n}=_n();return n},Kr=oe("ThreadListItemPrimitive.Delete",Br),$r=()=>{const{switchTo:n}=On();return n},zr=oe("ThreadListItemPrimitive.Trigger",$r),At=d.forwardRef((n,e)=>{var i;const t=_(3),s=Y(e,(i=Re())==null?void 0:i.triggerRef);let o;return t[0]!==n||t[1]!==s?(o=r.jsx(ve.ItemSlot,{scope:void 0,children:r.jsx(zr,{...n,ref:s})}),t[0]=n,t[1]=s,t[2]=o):o=t[2],o});At.displayName="ThreadListItemPrimitive.Trigger";var Ot=Me({Archive:()=>Or,Delete:()=>Kr,Root:()=>_t,Title:()=>st,Trigger:()=>At,Unarchive:()=>Fr});const ie=vt(),kt=Ie(()=>{}),Ft=()=>ye(kt),Bt=Ie(!1),Kt=()=>ye(Bt),$t=n=>{const e=_(26);let t,s,o,i,a,l,u;e[0]!==n?({__scopeThreadListItemMore:t,open:a,defaultOpen:s,onOpenChange:i,sharedFocusGroup:u,modal:o,...l}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=u):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],u=e[7]);const c=u===void 0?!1:u,m=c?!1:o??!0,p=ie(t),h=s??!1;let f;e[8]!==i?(f=i?{onChange:i}:{},e[8]=i,e[9]=f):f=e[9];let x;e[10]!==a||e[11]!==h||e[12]!==f?(x={prop:a,defaultProp:h,caller:"ThreadListItemMorePrimitive.Root",...f},e[10]=a,e[11]=h,e[12]=f,e[13]=x):x=e[13];const[g,b]=qe(x);let y;e[14]!==m||e[15]!==g||e[16]!==l||e[17]!==p||e[18]!==b?(y=r.jsx(Lt,{...p,...l,modal:m,open:g,onOpenChange:b}),e[14]=m,e[15]=g,e[16]=l,e[17]=p,e[18]=b,e[19]=y):y=e[19];let M;e[20]!==b||e[21]!==y?(M=r.jsx(kt.Provider,{value:b,children:y}),e[20]=b,e[21]=y,e[22]=M):M=e[22];let L;return e[23]!==c||e[24]!==M?(L=r.jsx(Bt.Provider,{value:c,children:M}),e[23]=c,e[24]=M,e[25]=L):L=e[25],L};$t.displayName="ThreadListItemMorePrimitive.Root";const zt=d.forwardRef((n,e)=>{const t=_(10),{__scopeThreadListItemMore:s,...o}=n,i=ie(s),a=Re(),l=Ft(),u=Kt(),c=Y(e,a==null?void 0:a.moreRef),m=le()==="rtl"?"ArrowLeft":"ArrowRight",p=Cr;let h;t[0]!==m||t[1]!==l||t[2]!==u?(h=g=>{!u||g.key!==m||(g.preventDefault(),l(!0))},t[0]=m,t[1]=l,t[2]=u,t[3]=h):h=t[3];const f=j(o.onKeyDown,h);let x;return t[4]!==p||t[5]!==c||t[6]!==o||t[7]!==i||t[8]!==f?(x=r.jsx(p,{...i,...o,onKeyDown:f,ref:c}),t[4]=p,t[5]=c,t[6]=o,t[7]=i,t[8]=f,t[9]=x):x=t[9],x});zt.displayName="ThreadListItemMorePrimitive.Trigger";const Gt=d.forwardRef((n,e)=>{const t=_(21),{__scopeThreadListItemMore:s,portalProps:o,sideOffset:i,...a}=n,l=i===void 0?4:i,u=ie(s),c=Ft(),m=Re(),p=Kt(),h=le()==="rtl"?"ArrowRight":"ArrowLeft",f=Mr,x=Sr;let g;t[0]!==h||t[1]!==(m==null?void 0:m.moreRef)||t[2]!==c||t[3]!==p?(g=O=>{var F;!p||O.key!==h||(O.preventDefault(),c(!1),(F=m==null?void 0:m.moreRef.current)==null||F.focus())},t[0]=h,t[1]=m==null?void 0:m.moreRef,t[2]=c,t[3]=p,t[4]=g):g=t[4];const b=j(a.onKeyDown,g);let y;t[5]!==(m==null?void 0:m.moreRef)||t[6]!==p?(y=()=>{var O;p&&((O=m==null?void 0:m.moreRef.current)==null||O.focus())},t[5]=m==null?void 0:m.moreRef,t[6]=p,t[7]=y):y=t[7];const M=j(a.onEscapeKeyDown,y);let L;t[8]!==x||t[9]!==e||t[10]!==a||t[11]!==u||t[12]!==l||t[13]!==b||t[14]!==M?(L=r.jsx(x,{...u,...a,onKeyDown:b,onEscapeKeyDown:M,ref:e,sideOffset:l}),t[8]=x,t[9]=e,t[10]=a,t[11]=u,t[12]=l,t[13]=b,t[14]=M,t[15]=L):L=t[15];let R;return t[16]!==o||t[17]!==u||t[18]!==f.Portal||t[19]!==L?(R=r.jsx(f.Portal,{...u,...o,children:L}),t[16]=o,t[17]=u,t[18]=f.Portal,t[19]=L,t[20]=R):R=t[20],R});Gt.displayName="ThreadListItemMorePrimitive.Content";const Ht=d.forwardRef((n,e)=>{const t=_(7);let s,o;t[0]!==n?({__scopeThreadListItemMore:s,...o}=n,t[0]=n,t[1]=s,t[2]=o):(s=t[1],o=t[2]);const i=ie(s);let a;return t[3]!==e||t[4]!==o||t[5]!==i?(a=r.jsx(Lr,{...i,...o,ref:e}),t[3]=e,t[4]=o,t[5]=i,t[6]=a):a=t[6],a});Ht.displayName="ThreadListItemMorePrimitive.Item";const Ut=d.forwardRef((n,e)=>{const t=_(7);let s,o;t[0]!==n?({__scopeThreadListItemMore:s,...o}=n,t[0]=n,t[1]=s,t[2]=o):(s=t[1],o=t[2]);const i=ie(s);let a;return t[3]!==e||t[4]!==o||t[5]!==i?(a=r.jsx(jr,{...i,...o,ref:e}),t[3]=e,t[4]=o,t[5]=i,t[6]=a):a=t[6],a});Ut.displayName="ThreadListItemMorePrimitive.Separator";var pe=Me({Content:()=>Gt,Item:()=>Ht,Root:()=>$t,Separator:()=>Ut,Trigger:()=>zt});function Gr(){const n=ee(),e=Qe(),t=Ce(),s=Ze(),o=t||s,[i,a]=d.useState(!1),[l,u]=d.useState(""),[c,m]=d.useState(null),p=d.useRef(null),h=d.useRef(null),f=d.useId(),x=(n==null?void 0:n.isLibraryEnabled)===!0&&e!=null,g=(n==null?void 0:n.historyAgentFilter)??null;d.useEffect(()=>{i||u("")},[i]);const{agents:b,isInitialLoading:y,isSearching:M,loadingMore:L,hasMore:R,listRef:O,sentinelRef:F}=gn({enabled:i&&x,query:l});if(d.useLayoutEffect(()=>{if(!i||o){m(null);return}const I=()=>{var D;const T=(D=p.current)==null?void 0:D.getBoundingClientRect();T&&m({top:T.top,left:T.right+4})};return I(),window.addEventListener("resize",I),window.addEventListener("scroll",I,!0),()=>{window.removeEventListener("resize",I),window.removeEventListener("scroll",I,!0)}},[i,o]),d.useEffect(()=>{if(!i||o)return;const I=T=>{var C,k;const D=T.target;(C=p.current)!=null&&C.contains(D)||(k=h.current)!=null&&k.contains(D)||a(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[i,o]),!x)return null;const A=I=>{(n==null?void 0:n.isComposerEnabled)===!0?n.openDraft():n==null||n.openLibraryHome(),n==null||n.setHistoryAgentFilter(I),a(!1)},E=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"p-1",onMouseDown:I=>I.stopPropagation(),children:[r.jsx(xn,{query:l,setQuery:u,placeholder:"Search agents"}),M?r.jsx("p",{className:"text-text-secondary px-1 pt-1 text-[11px]",role:"status",children:"Searching…"}):null]}),r.jsxs("div",{ref:O,className:K("mt-1 overflow-y-auto",o?"min-h-0 flex-1 px-1 pb-2":"min-h-48 max-h-64"),children:[l.trim()===""?r.jsxs(Ae,{className:K("justify-between",g==null&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>A(null),children:["All chats",g==null?r.jsx(z,{name:"check",className:"size-3.5 shrink-0"}):null]}):null,y?r.jsx("p",{className:"px-2 py-3 text-center text-xs text-text-secondary",children:"Loading…"}):b.length===0?r.jsx("p",{className:"text-text-secondary px-2 py-6 text-center text-xs",role:"status",children:l.trim()?`No agents match "${l.trim()}".`:"No agents yet."}):r.jsxs(r.Fragment,{children:[b.map(I=>{const T=vn(I),D=(g==null?void 0:g.agentId)===T;return r.jsxs(Ae,{className:K("justify-between gap-2 text-left",D&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>A({agentId:T,agentName:I.name,intent:"history"}),children:[r.jsx("span",{className:"min-w-0 truncate",children:I.name}),D?r.jsx(z,{name:"check",className:"size-3.5 shrink-0"}):null]},T)}),R?r.jsx("div",{ref:F,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:L?r.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]})]});return r.jsxs("div",{className:"relative shrink-0",children:[r.jsxs("button",{ref:p,type:"button","aria-label":g!=null?`Filter chat history by agent (${g.agentName})`:"Filter chat history by agent","aria-haspopup":o?"dialog":"menu","aria-expanded":i,"aria-controls":i?f:void 0,title:"Filter by agent",className:se({variant:"ghost",size:"icon",className:K("relative size-7 shrink-0 text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text",g!=null&&"text-text-primary")}),onClick:()=>a(I=>!I),children:[r.jsx(z,{name:"funnel",className:"size-3.5"}),g!=null?r.jsx("span",{className:"bg-primary-button-bg absolute top-1 right-1 size-1.5 rounded-full","aria-hidden":!0,"data-testid":"history-filter-active-dot"}):null]}),o&&i?r.jsx(Je,{open:!0,onOpenChange:a,id:f,"aria-label":"Filter agents",children:r.jsx("div",{className:"flex min-h-0 flex-1 flex-col p-2",role:"menu",children:E})}):null,!o&&i&&c!=null?bn.createPortal(r.jsx("div",{ref:h,id:f,role:"menu","aria-label":"Filter agents",style:{top:c.top,left:c.left},className:"aui-popup-enter font-sans-flex fixed z-50 w-56 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md",children:E}),wn(p.current)):null]})}function Hr({open:n,initialTitle:e,saving:t=!1,onOpenChange:s,onSave:o}){const[i,a]=d.useState(e),l=d.useRef(null);d.useEffect(()=>{n&&a(e)},[n,e]),d.useEffect(()=>{if(!n)return;const f=l.current;f!=null&&(f.focus(),f.select())},[n]);const u=i.trim(),m=u.length>0&&u.length<=Oe&&!t,p=()=>{m&&o(u)},h=f=>{t||s(f)};return r.jsx(yn,{open:n,onOpenChange:h,title:"Rename session",contentSized:!0,"aria-label":"Rename session",footer:r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsx(ke.Secondary,{type:"button",disabled:t,onClick:()=>h(!1),children:"Cancel"}),r.jsx(ke.Primary,{type:"button",disabled:!m,onClick:p,children:"Save"})]}),children:r.jsx("div",{className:"px-5 py-4",children:r.jsx("input",{ref:l,"aria-label":"Session title",value:i,readOnly:t,maxLength:Oe,className:In("h-9"),onChange:f=>a(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),p())}})})})}var Ur="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium outline-none transition-colors hover:bg-ghost-button-hover focus:bg-ghost-button-hover data-[highlighted]:bg-ghost-button-hover",Vr="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-failure-bg outline-none transition-colors hover:bg-failure-bg/12 hover:text-failure-bg focus:bg-failure-bg/12 focus:text-failure-bg data-[highlighted]:bg-failure-bg/12 data-[highlighted]:text-failure-bg";function Xr({canRename:n,renameDisabled:e,canDelete:t,deleteDisabled:s,onRename:o}){const i=N("PermissionGuard"),a=Ze(),l=Ce(),[u,c]=d.useState(!1),[m,p]=d.useState(),h=l||a,f=d.useCallback(y=>{const M=y==null?void 0:y.closest(".aui-theme-root");p(M instanceof HTMLElement?M:void 0)},[]),x=se({variant:"ghost",size:"icon",className:"size-7 shrink-0 text-text-secondary hover:bg-transparent hover:text-text-primary"}),g=n?r.jsx(i,{allowed:!e,children:r.jsxs("button",{type:"button",className:Ur,disabled:e,onClick:()=>{e||(c(!1),o())},children:[r.jsx(z,{name:"pencil",className:"size-3.5"}),"Rename"]})}):null,b=t?r.jsx(i,{allowed:!s,children:r.jsxs(Ot.Delete,{className:Vr,onClick:()=>{s||c(!1)},children:[r.jsx(z,{name:"trash",className:"size-3.5"}),"Delete"]})}):null;return h?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Session actions",title:"Session actions","aria-haspopup":"dialog","aria-expanded":u,className:x,onClick:()=>c(!0),children:r.jsx(z,{name:"ellipsis",className:"size-3.5"})}),u?r.jsx(Je,{open:!0,onOpenChange:c,"aria-label":"Session actions",children:r.jsxs("div",{className:"flex flex-col gap-1 p-2 *:w-full",role:"menu",children:[g,b]})}):null]}):r.jsxs(pe.Root,{sharedFocusGroup:!0,children:[r.jsx(pe.Trigger,{ref:f,"aria-label":"Session actions",title:"Session actions",className:x,children:r.jsx(z,{name:"ellipsis",className:"size-3.5"})}),r.jsxs(pe.Content,{portalProps:{container:m},align:"end",sideOffset:4,className:"aui-popup-enter font-sans-flex z-50 min-w-32 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md *:w-full",children:[g,b]})]})}function Wr({onThreadOpen:n,canRenameSession:e,canDeleteSession:t,canManageResource:s,canDeleteResource:o}){const i=G(),a=ee(),l=mn(),u=N("ThreadListRow"),c=P(C=>C.threadListItem.id),m=P(C=>C.threadListItem.remoteId),p=P(C=>C.threadListItem.title),h=P(C=>C.threadListItem.lastMessageAt),f=P(C=>C.threadListItem.custom),x=P(C=>C.threads.mainThreadId),g=fn(f),b=e&&m!=null,y=t&&m!=null,M=b||y,L=m!=null&&!s(m),R=m!=null&&!o(m),O=(a==null?void 0:a.libraryOpen)===!0||(a==null?void 0:a.sessionsOpen)===!0||(a==null?void 0:a.schedulesOpen)===!0,[F,A]=d.useState(!1),[E,I]=d.useState(!1),T=p??"New Chat",D=async C=>{if(C===(p??"").trim()){A(!1);return}I(!0);try{await i.threadListItem().rename(C),A(!1)}catch(k){l==null||l.showError(k)}finally{I(!1)}};return r.jsxs(Ot.Root,{className:"min-w-0",children:[r.jsx(u,{title:T,active:c===x&&!O,agentName:g,lastMessageAt:h,onSelect:()=>{n==null||n(),a==null||a.setSettingsOpen(!1),a==null||a.setLibraryOpen(!1),a==null||a.setSessionsOpen(!1),a==null||a.setSchedulesOpen(!1);const C=hn(f),k=!C&&(a==null?void 0:a.mode.status)==="active"&&!a.mode.isMutable&&(g==null?a.mode.agentName==null&&a.mode.agentId==null:a.mode.agentName===g||a.mode.agentId===g),w=pn({sessionMutable:C,shellMutable:(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable,...(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable?{shellAgentName:a.mode.agentName,shellAgentId:a.mode.agentId}:{},remoteId:m,pendingSessionId:a==null?void 0:a.pendingSessionId});if((k||w)&&m!=null){Promise.resolve(i.threads().switchToThread(c)).catch(()=>{});return}if(m!=null){a==null||a.openHistorySession({sessionId:m,isMutable:C,...g!=null?{agentName:g}:{}});return}Promise.resolve(i.threads().switchToThread(c)).catch(()=>{})},actions:M?r.jsx(Xr,{canRename:b,renameDisabled:L,canDelete:y,deleteDisabled:R,onRename:()=>A(!0)}):void 0}),r.jsx(Hr,{open:F,initialTitle:p??"",saving:E,onOpenChange:A,onSave:C=>{D(C)}})]})}function Yr(n){const e=P(s=>s.threads.threadIds),t=P(s=>s.threads.threadItems);return d.useMemo(()=>{const s=dn({threadIds:e,threadItems:t});if(n==="default")return s;const o=new Map;for(const i of t)o.set(i.id,i),i.remoteId!=null&&o.set(i.remoteId,i);return s.filter(i=>{const a=e[i];if(a===void 0)return!1;const l=o.get(a);return(l==null?void 0:l.remoteId)!=null})},[e,t,n])}function qr({indices:n,onThreadOpen:e,canRenameSession:t,canDeleteSession:s,canManageResource:o,canDeleteResource:i}){const a=P(l=>l.threads.threadIds);return r.jsx(r.Fragment,{children:n.map(l=>{const u=a[l]??String(l);return r.jsx(Se,{index:l,archived:!1,children:r.jsx(Wr,{onThreadOpen:e,canRenameSession:t,canDeleteSession:s,canManageResource:o,canDeleteResource:i})},u)})})}var Qr="aui_thread-list-viewport",Zr=80;function Jr({children:n,viewportRef:e,hideScrollbar:t}){var u;const s=ee(),o=P(c=>c.threadListItem.remoteId),i=(u=s==null?void 0:s.historyAgentFilter)==null?void 0:u.intent,a=(s==null?void 0:s.isLibraryEnabled)===!0&&i!=="try-agent"&&(i==="history"||s.mode.status!=="active"||s.mode.isMutable||s.pendingSessionId!=null||o!=null),l=(s==null?void 0:s.historyAgentFilter)==null?"Chat History":`Chats for ${s.historyAgentFilter.agentName}`;return r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-1 py-1",children:[r.jsx("h2",{className:"min-w-0 flex-1 truncate px-1.5 py-1 text-sm font-medium text-text-secondary",children:l}),a?r.jsx(Gr,{}):null]}),r.jsx("div",{ref:e,"data-slot":Qr,className:K("flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",t&&"aui-scrollbar-hidden"),children:n})]})}function es({onThreadOpen:n,variant:e="default"}={}){const t=G(),s=Qe(),o=P(w=>w.threads.isLoading),i=P(w=>w.threads.isLoadingMore),a=P(w=>w.threads.hasMore),l=P(w=>w.threads.threadIds),u=P(w=>w.threads.threadItems),c=ee(),m=N("ThreadListShell"),p=N("ThreadListNewButton"),h=N("AgentsLibraryButton"),f=N("SessionsBrowserButton"),x=N("SchedulesButton"),g=N("ThreadListRowSkeleton"),b=N("ThreadListEmptyState"),y=Yr(e),M=d.useRef(null),L=d.useRef(a),R=d.useRef(t);L.current=a,R.current=t;const O=(c==null?void 0:c.isNewChatEnabled)!==!1,F=(c==null?void 0:c.mode.status)==="idle",A=e==="recent-history",E=typeof(s==null?void 0:s.renameSession)=="function",I=typeof(s==null?void 0:s.deleteSession)=="function",T=d.useMemo(()=>u.flatMap(w=>w.remoteId==null?[]:[w.remoteId]),[u]),{allows:D}=un({resourceType:"session",resourceIds:T});d.useEffect(()=>{if(F||o||i)return;const w=M.current;if(!w)return;let Q=!1;const U=()=>{if(Q||!L.current||w.clientHeight<=0)return;const me=w.scrollHeight-w.scrollTop-w.clientHeight;w.scrollHeight>w.clientHeight&&me>Zr||R.current.threads().loadMore()};w.addEventListener("scroll",U,{passive:!0});const V=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>U());return V?V.observe(w):window.addEventListener("resize",U),U(),()=>{Q=!0,w.removeEventListener("scroll",U),V==null||V.disconnect(),V||window.removeEventListener("resize",U)}},[a,F,o,i,l.length]);const C=()=>{if(n==null||n(),c==null||c.setLibraryOpen(!1),c==null||c.setSessionsOpen(!1),c!=null&&c.isComposerEnabled){c.openDraft();return}c==null||c.setSettingsOpen(!1),c==null||c.setSchedulesOpen(!1),Promise.resolve(t.threads().switchToNewThread()).catch(()=>{})};let k;return F?k=r.jsx(b,{message:A?"No recent chats":void 0}):o?k=r.jsx(g,{}):y.length===0?k=r.jsx(b,{message:A?"No recent chats":void 0}):k=r.jsx(_r.Root,{className:"flex min-h-0 flex-col gap-0.5",children:r.jsx(qr,{indices:y,onThreadOpen:n,canRenameSession:E,canDeleteSession:I,canManageResource:w=>D(w,"MANAGE"),canDeleteResource:w=>D(w,"DELETE")})}),r.jsx(m,{header:A?null:r.jsxs("div",{className:"flex flex-col gap-1",children:[O?r.jsx(p,{onClick:C}):null,r.jsx(h,{}),r.jsx(f,{}),r.jsx(x,{})]}),children:r.jsxs(Jr,{viewportRef:M,hideScrollbar:A,children:[k,!F&&a?r.jsx("div",{className:"h-4 shrink-0","aria-hidden":!0}):null]})})}var ts=d.lazy(()=>tt(()=>import("./SettingsBuilder-G5CP5X6Q-XQVNLXzw.js"),__vite__mapDeps([0,1,2]),import.meta.url)),ns=d.lazy(()=>tt(()=>import("./SchedulesPage-TIS3BH67-CoDDvRbI.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(n=>({default:n.SchedulesPage}))),rs="h-5 w-5 max-w-40 shrink-0 object-contain",ss="w-20",$e=K(jn,"text-sidebar-text"),ze="bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text";function os({overlayOpen:n,mode:e}){return!n&&(e==null?void 0:e.status)==="active"&&!e.isCreateAgent}function as(){var h;const n=G(),e=ee(),t=N("AgentsLibraryButton"),s=N("SessionsBrowserButton"),o=N("SchedulesButton"),i=(e==null?void 0:e.isNewChatEnabled)!==!1,a=(e==null?void 0:e.settingsOpen)===!0||(e==null?void 0:e.libraryOpen)===!0||(e==null?void 0:e.sessionsOpen)===!0||(e==null?void 0:e.schedulesOpen)===!0,l=e==null?void 0:e.mode,u=!a&&(l==null?void 0:l.status)==="active"&&!l.isCreateAgent&&((h=e==null?void 0:e.historyAgentFilter)==null?void 0:h.intent)!=="try-agent",c=!a&&l!=null&&et(l),m=()=>{if(e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled){e.openDraft();return}e==null||e.setSettingsOpen(!1),e==null||e.setSchedulesOpen(!1),Promise.resolve(n.threads().switchToNewThread()).catch(()=>{})},p=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return r.jsxs("nav",{className:"flex min-h-0 flex-1 flex-col items-center gap-1 p-1","aria-label":"Sidebar",children:[i?r.jsxs("button",{type:"button","aria-label":"Start new chat",title:"New chat","aria-current":u?"page":void 0,className:se({variant:"ghost",className:K($e,u&&ze)}),onClick:m,children:[r.jsx(z,{name:"square-pen",size:14}),r.jsx("span",{className:"text-center",children:"New Chat"})]}):null,i&&(e!=null&&e.isComposerEnabled)?r.jsxs("button",{type:"button","aria-label":"Start new agent",title:"New Agent","aria-current":c?"page":void 0,className:se({variant:"ghost",className:K($e,c&&ze)}),onClick:p,children:[r.jsx(z,{name:"agent-2",size:14}),r.jsx("span",{className:"text-center whitespace-nowrap",children:"Build Agent"})]}):null,r.jsx(t,{compact:!0}),r.jsx(s,{compact:!0}),r.jsx(o,{compact:!0})]})}function Ge({onNavigate:n,className:e,railRef:t,...s}){const o=Sn(),i=Ln(o),a=N("BrandLogo"),l=N("UserAvatar");return r.jsxs("aside",{ref:t,className:K(ss,"flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar-bg",e),onClick:u=>{if(n==null)return;const c=u.target;c instanceof Element&&c.closest("button")!=null&&n()},...s,children:[r.jsx("div",{className:"flex h-14 w-full shrink-0 items-center justify-center text-text-primary",children:r.jsx(a,{variant:i.collapsedVariant,className:rs})}),r.jsx(as,{}),r.jsxs("footer",{className:"flex shrink-0 flex-col items-center border-border p-2",children:[r.jsx(Pn,{labeled:!0,className:"flex-col"}),r.jsx(l,{labeled:!0,className:"mt-2 py-1.5"})]})]})}function ps({className:n}){const e=ee(),t=Ce(),s=N("AgentDetailsPage"),o=N("AgentsLibrary"),i=N("SessionsPage"),a=N("ClearChatButton"),l=N("SaveAgentButton"),u=N("SelectAgentEmptyState"),[c,m]=d.useState(!1),p=d.useRef(null),h=d.useRef(null),f=d.useRef(null),x=d.useRef(!1),g=(e==null?void 0:e.mode.status)==="idle",b=(e==null?void 0:e.settingsOpen)===!0,y=(e==null?void 0:e.libraryOpen)===!0,M=(e==null?void 0:e.sessionsOpen)===!0,L=(e==null?void 0:e.schedulesOpen)===!0,R=b||y||M||L,O=e!=null&&et(e.mode)&&!R&&(!t||e.agentConfigOpen),F=os({overlayOpen:R,mode:e==null?void 0:e.mode}),A=Mn();return d.useEffect(()=>{if(!c)return;const E=I=>{I.key==="Escape"&&m(!1)};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[c]),d.useEffect(()=>{var I,T;const E=f.current;if(c){x.current=!0,E&&(E.inert=!0),(I=h.current)==null||I.focus();return}x.current&&(E&&(E.inert=!1),(T=p.current)==null||T.focus(),x.current=!1)},[c]),r.jsxs("div",{className:K("relative flex h-full min-h-0 w-full min-w-0",n),children:[r.jsx(Ge,{className:"hidden md:flex"}),O?r.jsx("aside",{role:"dialog","aria-label":"Agent Config",className:"absolute inset-y-0 left-0 z-20 w-full max-w-sm border-r border-border shadow-xl md:static md:z-auto md:max-w-140 md:flex-1 md:shadow-none 2xl:max-w-150",children:r.jsx(Tn,{showClose:t})}):null,r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-primary-bg",children:[r.jsx(Cn,{className:K("bg-topbar-bg",(R||g||!A)&&"md:hidden"),start:R?null:r.jsx("button",{ref:p,type:"button","aria-label":"Navigation","aria-expanded":c,className:K(se({variant:"ghost",size:"icon"}),"md:hidden"),onClick:()=>m(!0),children:r.jsx(z,{name:"bars"})}),title:R?null:r.jsx(Rn,{}),end:R?null:r.jsxs(r.Fragment,{children:[r.jsx(a,{}),r.jsx(l,{})]})}),r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1",children:[F?r.jsx("aside",{"aria-label":"Recent chats",className:"hidden min-h-0 w-64 shrink-0 border-r border-border bg-sidebar-bg md:flex",children:r.jsx(es,{variant:"recent-history"})}):null,r.jsx("div",{ref:f,className:"min-h-0 min-w-0 flex-1",children:b?r.jsx(d.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(Fe,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(ts,{})}):M?r.jsx(i,{}):y&&(e==null?void 0:e.libraryAgentId)!=null?r.jsx(s,{agentId:e.libraryAgentId},e.libraryAgentId):y?r.jsx(o,{onSelectAgent:()=>m(!1)}):L?r.jsx(d.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(Fe,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(ns,{})}):g?r.jsx(u,{}):r.jsx(Nn,{})})]})]}),c?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close navigation",className:"absolute inset-0 z-[9] cursor-pointer bg-[var(--overlay)] md:hidden",onClick:()=>m(!1)}),r.jsx(Ge,{railRef:h,role:"dialog","aria-label":"Navigation",tabIndex:-1,onNavigate:()=>m(!1),className:"absolute inset-y-0 left-0 z-10 shadow-lg outline-none md:hidden"})]}):null]})}export{ps as SidebarLayout};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aU as $,N as P,r as a,aV as U,j as e,U as Q,W as I,I as z,aX as _,aq as k}from"./index-G7kdtXvB.js";var K=({open:s,onOpenChange:o,onImport:c,busy:v=!1,error:d})=>{const[p,g]=a.useState(""),[b,m]=a.useState(""),[u,j]=a.useState(""),[i,S]=a.useState(""),[n,x]=a.useState(""),N=()=>{g(""),m(""),j(""),S(""),x("")},h=()=>{N(),o(!1)},R=async l=>{if(l.preventDefault(),!(!p.trim()||!b.trim()||!u.trim()||!i.trim()||!n.trim()||v))try{await c({name:p.trim(),description:b.trim(),repoURL:u.trim(),path:i.trim(),ref:n.trim()}),h()}catch{}},L=!!(p.trim()&&b.trim()&&u.trim()&&i.trim()&&n.trim())&&!v;return e.jsx(_,{open:s,onOpenChange:l=>{l||h()},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(z,{name:"github",className:"size-5"})}),contentSized:!0,className:"md:max-w-2xl",children:e.jsx("form",{onSubmit:l=>void R(l),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:p,onChange:l=>{g(l.target.value)},placeholder:"release-notes",autoFocus:!0,required:!0,className:k("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:b,onChange:l=>{m(l.target.value)},placeholder:"Generate release notes from merged pull requests",required:!0,rows:3,className:k("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:l=>{j(l.target.value)},placeholder:"https://github.com/org/repo",required:!0,className:k("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:l=>{S(l.target.value)},placeholder:"skills/release-notes",required:!0,className:k("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:l=>{x(l.target.value)},placeholder:"main",required:!0,className:k("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(I.Primary,{type:"submit",disabled:!L,className:"w-full",children:"Import"})]})]})})})},T=K,q=(s,o,c)=>!s||o.toLowerCase().includes(s)||c.toLowerCase().includes(s),A=s=>"catalogId"in s;function V(s){return typeof s=="object"&&s!==null&&Reflect.get(s,"statusCode")===424}var W=()=>{const{skillCatalog:s}=$(),o=P(),[c,v]=a.useState(""),[d,p]=a.useState([]),[g,b]=a.useState([]),[m,u]=a.useState(!0),[j,i]=a.useState(null),[S,n]=a.useState(null),[x,N]=a.useState(!1),[h,R]=a.useState(!1),[L,l]=a.useState(!1),E=a.useCallback(async()=>{if(s){u(!0),i(null);try{const[t,r]=await Promise.all([s.listSkills(),s.getSkillCatalog()]);p(t),b(r)}catch(t){i(U(t,"Failed to load skills"))}finally{u(!1)}}},[s]);a.useEffect(()=>{E()},[E]);const y=c.trim().toLowerCase(),w=a.useMemo(()=>d.filter(t=>q(y,t.name,t.description)),[d,y]),C=a.useMemo(()=>{const t=new Set(d.flatMap(r=>A(r)?[r.catalogId]:[]));return g.filter(r=>!t.has(r.id)&&q(y,r.name,r.description))},[g,d,y]),F=async(t,r=i)=>{N(!0),i(null);try{await t(),await E()}catch(f){throw V(f)&&R(!0),r(U(f,"Request failed")),f}finally{N(!1)}};if(!s)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Skills catalog is not available."});const G=t=>{F(async()=>{await s.createSkill({catalogId:t.id,name:t.name,description:t.description,repoURL:t.repoURL,path:t.path,ref:t.ref})}).catch(()=>{})},B=t=>{const r=s.deleteSkill;r&&F(async()=>{await r({id:t.id})}).catch(()=>{})},O=async t=>{n(null),await F(async()=>{await s.createSkill(t)},n),setTimeout(()=>{o==null||o.showSuccess({title:`${t.name} imported`})},0)},M=({key:t,name:r,description:f,action:H})=>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(z,{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}),f?e.jsx("p",{className:"mt-0.5 truncate text-sm text-text-secondary",children:f}):null]}),H]},t),D=w.length>0||C.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."}),j?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:j}):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(Q,{query:c,setQuery:v,placeholder:"Search skills"})}),e.jsxs(I.Secondary,{type:"button",className:"shrink-0",disabled:x||h,onClick:()=>{n(null),l(!0)},children:[e.jsx(z,{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&&w.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 · ",w.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:w.map(t=>M({key:t.id,name:t.name,description:t.description,action:s.deleteSkill?e.jsx(I.Secondary,{size:"small",type:"button",disabled:x||h,"aria-label":`Remove ${t.name}`,onClick:()=>{B(t)},children:"Remove"}):null}))})]}):null,!m&&C.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 · ",C.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:C.map(t=>M({key:t.id,name:t.name,description:t.description,action:e.jsx(I.Secondary,{size:"small",type:"button",disabled:x||h,"aria-label":`Enable ${t.name}`,onClick:()=>{G(t)},children:"Enable"})}))})]}):null,!m&&!D?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:y?`No skills match “${c.trim()}”.`:"No skills yet."}):null]})]}),e.jsx(T,{open:L,onOpenChange:t=>{l(t),t||n(null)},onImport:O,busy:x||h,error:S})]})},J=W;export{J as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,j as o,T as a}from"./index-G7kdtXvB.js";import{r as m}from"./chunk-B76JC5B2-BMXX-7i9.js";import{B as i}from"./chunk-62JRHF6Z-DVHPxtc3.js";function p({routes:e,...s}){const r=t.useMemo(()=>m(e),[e]);return o.jsx(i,{basename:r.basename||void 0,children:o.jsx(a,{...s,resolvedRoutes:r})})}export{p as TrueForgeUIWithRouter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as m}from"./chunk-
|
|
1
|
+
import{S as m}from"./chunk-IGYCJIU7-COFxTXYC.js";import{c as x,f,r,j as e,C as p,I as b,d as h,e as v}from"./index-G7kdtXvB.js";import"./chunk-G7BT4OKG-D-wOOnsv.js";function j({className:u}){const d=x("BrandLogo"),{open:a,setOpen:n}=f(),l=r.useRef(null),s=r.useRef(null),i=r.useRef(!1);return r.useEffect(()=>{if(!a)return;const t=o=>{var c;o.key==="Escape"&&!((c=s.current)!=null&&c.querySelector("dialog[open]"))&&n(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[a,n]),r.useEffect(()=>{var t,o;if(a){i.current=!0,(t=s.current)==null||t.focus();return}i.current&&((o=l.current)==null||o.focus(),i.current=!1)},[a]),e.jsxs("div",{className:v("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(p,{children:e.jsx(m,{threadHeaderEnd:e.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:h({variant:"ghost",size:"icon"}),onClick:()=>n(!1),children:e.jsx(b,{name:"xmark"})})})})}):null,e.jsx("button",{ref:l,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:()=>n(t=>!t),children:a?e.jsx("span",{"aria-hidden":!0,className:"text-xl leading-none",children:"×"}):e.jsx(d,{variant:"icon",className:"size-6"})})]})}export{j as WidgetLayout};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as h,G as u,H as g,J as m,K as w}from"./index-
|
|
1
|
+
import{F as h,G as u,H as g,J as m,K as w}from"./index-G7kdtXvB.js";var l={root:"/",settings:"/settings",library:"/library",libraryAgent:"/library/:agentId",schedules:"/schedules",buildAgent:"/build-agent",agent:"/agents/:agentName",session:"/sessions/:sessionId",sessionsBrowser:"/sessions"};function f(n){const e=n.trim(),s=e.startsWith("/")?e:`/${e}`;return s.length>1&&s.endsWith("/")?s.slice(0,-1):s}function a(n,e){return n===!1?null:f(n??e)}function R(n){const e=n==null?void 0:n.paths;return{basename:(n==null?void 0:n.basename)??"",root:f((e==null?void 0:e.root)??l.root),settings:a(e==null?void 0:e.settings,l.settings),library:a(e==null?void 0:e.library,l.library),libraryAgent:a(e==null?void 0:e.libraryAgent,l.libraryAgent),schedules:a(e==null?void 0:e.schedules,l.schedules),buildAgent:a(e==null?void 0:e.buildAgent,l.buildAgent),agent:a(e==null?void 0:e.agent,l.agent),session:a(e==null?void 0:e.session,l.session),sessionsBrowser:a(e==null?void 0:e.sessionsBrowser,l.sessionsBrowser)}}function y(n){return n.split("/").filter(e=>e.length>0)}function c(n,e){return"/"+y(n).map(s=>s.startsWith(":")?encodeURIComponent(e):s).join("/")}function S(n,e){switch(n.type){case"root":return e.root;case"settings":return e.settings;case"library":return e.library;case"libraryAgent":return e.libraryAgent==null?null:c(e.libraryAgent,n.agentId);case"schedules":return e.schedules;case"buildAgent":return e.buildAgent;case"agent":return e.agent==null?null:c(e.agent,n.agentName);case"session":return e.session==null?null:c(e.session,n.sessionId);case"sessionsBrowser":return e.sessionsBrowser}}function N({sessionId:n,routes:e,href:s=typeof window>"u"?"http://localhost/":window.location.href}){const i=S({type:"session",sessionId:n},e);if(i==null)return null;const t=new URL(s),r=e.basename.endsWith("/")?e.basename.slice(0,-1):e.basename;return t.pathname=`${r}${i}`||"/",t.search=A({type:"session"},t.search),t.hash="",t.toString()}function A(n,e){if(n.type==="settings")return e;const s=new URLSearchParams(e.startsWith("?")?e.slice(1):e);if(n.type==="sessionsBrowser")u(s,{tab:null}),g(s);else if(n.type==="libraryAgent"){const t=h(e),r=m(e);u(s,{view:null,timeRange:null,...t.sessionId!=null&&t.agentId!==n.agentId?{sessionId:null,agentId:null}:{}}),g(s),t.tab==="schedules"&&w(s,{status:r.status,q:r.q,isNew:r.isNew})}else n.type==="schedules"?u(s,{sessionId:null,agentId:null,tab:null,view:null,timeRange:null}):(u(s,{sessionId:null,agentId:null,tab:null,view:null,timeRange:null}),g(s));const i=s.toString();return i.length>0?`?${i}`:""}function p(n){try{return decodeURIComponent(n)}catch{return null}}function d(n,e){const s=y(n);if(s.length!==e.length)return null;let i=null;for(const[t,r]of s.entries()){const o=e[t];if(o===void 0)return null;if(r.startsWith(":")){const b=p(o);if(b==null)return null;i=b}else if(r!==o)return null}return i}function I(n,e){const s=f(n),i=y(s);if(e.settings!=null&&s===e.settings)return{type:"settings"};if(e.library!=null&&s===e.library)return{type:"library"};if(e.sessionsBrowser!=null&&s===e.sessionsBrowser)return{type:"sessionsBrowser"};if(e.libraryAgent!=null){const t=d(e.libraryAgent,i);if(t!=null)return{type:"libraryAgent",agentId:t}}if(e.schedules!=null&&s===e.schedules)return{type:"schedules"};if(e.buildAgent!=null&&s===e.buildAgent)return{type:"buildAgent"};if(e.agent!=null){const t=d(e.agent,i);if(t!=null)return{type:"agent",agentName:t}}if(e.session!=null){const t=d(e.session,i);if(t!=null)return{type:"session",sessionId:t}}return s===e.root?{type:"root"}:null}function v({pathname:n,search:e,routes:s}){const i=I(n,s);if(i==null||i.type!=="root")return i;const{agentId:t}=h(e);return t!=null?{type:"libraryAgent",agentId:t}:i}function P(n,e){return n.type!==e.type?!1:n.type==="agent"&&e.type==="agent"?n.agentName===e.agentName:n.type==="libraryAgent"&&e.type==="libraryAgent"?n.agentId===e.agentId:n.type==="session"&&e.type==="session"?n.sessionId===e.sessionId:!0}export{N as a,S as b,v as m,P as p,R as r,A as s};
|
|
Binary file
|
|
Binary file
|