@truefoundry/trueforge 0.187.0-rc.1 → 0.187.0-rc.2
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-IQBCA7PK-BjFskF44.js → AgentCodeSnippets-KRNZUDA3-CNnaws58.js} +1 -1
- package/dist/_frontend/assets/AgentCodeSnippets-KRNZUDA3-CNnaws58.js.br +0 -0
- package/dist/_frontend/assets/AgentCodeSnippets-KRNZUDA3-CNnaws58.js.gz +0 -0
- package/dist/_frontend/assets/{AgentMetricChart-7V42QCLW-B6i3t-3u.js → AgentMetricChart-OV2LLPBQ-DW-hRGPF.js} +1 -1
- package/dist/_frontend/assets/AgentMetricChart-OV2LLPBQ-DW-hRGPF.js.br +0 -0
- package/dist/_frontend/assets/AgentMetricChart-OV2LLPBQ-DW-hRGPF.js.gz +0 -0
- package/dist/_frontend/assets/{AgentOverview-NUS7DF3V-BLN7Mc1A.js → AgentOverview-DIVQXYTD-Dk4w7kJi.js} +1 -1
- package/dist/_frontend/assets/AgentOverview-DIVQXYTD-Dk4w7kJi.js.br +0 -0
- package/dist/_frontend/assets/AgentOverview-DIVQXYTD-Dk4w7kJi.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessionEventTimeline-YV5IMM36-CjuIEqY5.js → AgentSessionEventTimeline-B37KD6JC-BBlyCGa-.js} +1 -1
- package/dist/_frontend/assets/AgentSessionEventTimeline-B37KD6JC-BBlyCGa-.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-B37KD6JC-BBlyCGa-.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessionEventTimelineChart-T47VTMR6-cJdpKneN.js → AgentSessionEventTimelineChart-GGVUJ6AM-sRgpwM2S.js} +1 -1
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-GGVUJ6AM-sRgpwM2S.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-GGVUJ6AM-sRgpwM2S.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessions-JVLIS2OC-DfKqLMq_.js → AgentSessions-WLZRCGYQ-BaQt6Mdz.js} +1 -1
- package/dist/_frontend/assets/AgentSessions-WLZRCGYQ-BaQt6Mdz.js.br +0 -0
- package/dist/_frontend/assets/AgentSessions-WLZRCGYQ-BaQt6Mdz.js.gz +0 -0
- package/dist/_frontend/assets/{AppearanceSettings-EY2WXRWB-C3VtWEAm.js → AppearanceSettings-UEYHOB2J-DmthQL1S.js} +1 -1
- package/dist/_frontend/assets/AppearanceSettings-UEYHOB2J-DmthQL1S.js.br +0 -0
- package/dist/_frontend/assets/AppearanceSettings-UEYHOB2J-DmthQL1S.js.gz +0 -0
- package/dist/_frontend/assets/{ConnectorSettings-X6OHZ6KA-u4N4OWzr.js → ConnectorSettings-VQ7CTUM5-BLj1QcxG.js} +1 -1
- package/dist/_frontend/assets/ConnectorSettings-VQ7CTUM5-BLj1QcxG.js.br +0 -0
- package/dist/_frontend/assets/ConnectorSettings-VQ7CTUM5-BLj1QcxG.js.gz +0 -0
- package/dist/_frontend/assets/{DockLayout-SEEHTHCB-qMMUFfFT.js → DockLayout-AEFR44GJ-Cvdwne2I.js} +1 -1
- package/dist/_frontend/assets/{DrawerLayout-DPIUGY42-Bxv9hChU.js → DrawerLayout-IMYRUVVF-9mp6LCtM.js} +2 -2
- package/dist/_frontend/assets/DrawerLayout-IMYRUVVF-9mp6LCtM.js.br +0 -0
- package/dist/_frontend/assets/DrawerLayout-IMYRUVVF-9mp6LCtM.js.gz +0 -0
- package/dist/_frontend/assets/{EnvironmentsPage-EUA7T7IZ-B9cZm1H2.js → EnvironmentsPage-I4OX4N6O-CaSrJiI0.js} +1 -1
- package/dist/_frontend/assets/EnvironmentsPage-I4OX4N6O-CaSrJiI0.js.br +0 -0
- package/dist/_frontend/assets/EnvironmentsPage-I4OX4N6O-CaSrJiI0.js.gz +0 -0
- package/dist/_frontend/assets/{MemorySettings-7IT3OBVB-CXPWhBSp.js → MemorySettings-6Y7OQGBZ-Cx6tkpwR.js} +1 -1
- package/dist/_frontend/assets/MemorySettings-6Y7OQGBZ-Cx6tkpwR.js.br +0 -0
- package/dist/_frontend/assets/MemorySettings-6Y7OQGBZ-Cx6tkpwR.js.gz +0 -0
- package/dist/_frontend/assets/{ModelSettings-PNXNGQ5L-ePcg3Aqh.js → ModelSettings-PXQVXZIW-Bq8R7Ku5.js} +1 -1
- package/dist/_frontend/assets/ModelSettings-PXQVXZIW-Bq8R7Ku5.js.br +0 -0
- package/dist/_frontend/assets/ModelSettings-PXQVXZIW-Bq8R7Ku5.js.gz +0 -0
- package/dist/_frontend/assets/{SandboxSettings-H5NXXJGM-D5w4szt5.js → SandboxSettings-IH7HAGW2-BtilbrtJ.js} +1 -1
- package/dist/_frontend/assets/SandboxSettings-IH7HAGW2-BtilbrtJ.js.br +0 -0
- package/dist/_frontend/assets/SandboxSettings-IH7HAGW2-BtilbrtJ.js.gz +0 -0
- package/dist/_frontend/assets/{SchedulesPage-CAQD2Q4F-CO8Z5teK.js → SchedulesPage-I52TNBAZ-ClnGQZ5d.js} +1 -1
- package/dist/_frontend/assets/SchedulesPage-I52TNBAZ-ClnGQZ5d.js.br +0 -0
- package/dist/_frontend/assets/SchedulesPage-I52TNBAZ-ClnGQZ5d.js.gz +0 -0
- package/dist/_frontend/assets/{SettingsBuilder-YMBHISA3-BXfV41lI.js → SettingsBuilder-OKV2POOV-CsW3joKv.js} +2 -2
- package/dist/_frontend/assets/SettingsBuilder-OKV2POOV-CsW3joKv.js.br +0 -0
- package/dist/_frontend/assets/SettingsBuilder-OKV2POOV-CsW3joKv.js.gz +0 -0
- package/dist/_frontend/assets/ShellRouteSync-RMJGHQAP-c5W1ir3h.js +1 -0
- package/dist/_frontend/assets/ShellRouteSync-RMJGHQAP-c5W1ir3h.js.br +0 -0
- package/dist/_frontend/assets/ShellRouteSync-RMJGHQAP-c5W1ir3h.js.gz +0 -0
- package/dist/_frontend/assets/SidebarLayout-LHUY6YNV-BWILGqg4.js +2 -0
- package/dist/_frontend/assets/SidebarLayout-LHUY6YNV-BWILGqg4.js.br +0 -0
- package/dist/_frontend/assets/SidebarLayout-LHUY6YNV-BWILGqg4.js.gz +0 -0
- package/dist/_frontend/assets/{SkillSettings-NVL4XWDS-BYXZ85YV.js → SkillSettings-DNSX7ANY-DCUzAc7H.js} +1 -1
- package/dist/_frontend/assets/SkillSettings-DNSX7ANY-DCUzAc7H.js.br +0 -0
- package/dist/_frontend/assets/SkillSettings-DNSX7ANY-DCUzAc7H.js.gz +0 -0
- package/dist/_frontend/assets/{TrueForgeUIWithRouter-7O2WTUMN-B1RH13sW.js → TrueForgeUIWithRouter-4U734LMX-C0-HJ0AT.js} +1 -1
- package/dist/_frontend/assets/{WebSearchSettings-QHDG5HBJ-BnNzyKFb.js → WebSearchSettings-A7WZKVHW-l95PltgD.js} +1 -1
- package/dist/_frontend/assets/WebSearchSettings-A7WZKVHW-l95PltgD.js.br +0 -0
- package/dist/_frontend/assets/WebSearchSettings-A7WZKVHW-l95PltgD.js.gz +0 -0
- package/dist/_frontend/assets/{WidgetLayout-VSLU2TXO-DRJouw53.js → WidgetLayout-4DQOLH36-CeDtG2Zz.js} +1 -1
- package/dist/_frontend/assets/WidgetLayout-4DQOLH36-CeDtG2Zz.js.br +0 -0
- package/dist/_frontend/assets/WidgetLayout-4DQOLH36-CeDtG2Zz.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-2PBSR643-DucDomKE.js → chunk-4QN7ONBR-CtFqtChE.js} +1 -1
- package/dist/_frontend/assets/chunk-4QN7ONBR-CtFqtChE.js.br +0 -0
- package/dist/_frontend/assets/chunk-4QN7ONBR-CtFqtChE.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-XOQYBULH-CRvLiR9N.js → chunk-BNMKM5SY-CiR8M-oi.js} +1 -1
- package/dist/_frontend/assets/chunk-DW4YYV6Q-Cm0KW5r-.js +1 -0
- package/dist/_frontend/assets/chunk-DW4YYV6Q-Cm0KW5r-.js.br +0 -0
- package/dist/_frontend/assets/chunk-DW4YYV6Q-Cm0KW5r-.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-EAY2YDVF-BEYTBRlX.js → chunk-LBXXYCLT-bkjw_srH.js} +2 -2
- package/dist/_frontend/assets/chunk-LBXXYCLT-bkjw_srH.js.br +0 -0
- package/dist/_frontend/assets/chunk-LBXXYCLT-bkjw_srH.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-OB3PAWPO-CdLNGkFp.js → chunk-OB3PAWPO-CYqixJeQ.js} +1 -1
- package/dist/_frontend/assets/chunk-OB3PAWPO-CYqixJeQ.js.br +0 -0
- package/dist/_frontend/assets/chunk-OB3PAWPO-CYqixJeQ.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-OO6QO7FR-Clj6a-iP.js → chunk-OO6QO7FR-DrdcbTUi.js} +1 -1
- package/dist/_frontend/assets/chunk-OO6QO7FR-DrdcbTUi.js.br +0 -0
- package/dist/_frontend/assets/chunk-OO6QO7FR-DrdcbTUi.js.gz +0 -0
- package/dist/_frontend/assets/{cssMode-DuqNkvPv.js → cssMode-DDD53ZUi.js} +1 -1
- package/dist/_frontend/assets/cssMode-DDD53ZUi.js.br +0 -0
- package/dist/_frontend/assets/cssMode-DDD53ZUi.js.gz +0 -0
- package/dist/_frontend/assets/{freemarker2-BUfzpeUx.js → freemarker2-CRj5NS3U.js} +1 -1
- package/dist/_frontend/assets/freemarker2-CRj5NS3U.js.br +0 -0
- package/dist/_frontend/assets/freemarker2-CRj5NS3U.js.gz +0 -0
- package/dist/_frontend/assets/{handlebars-BLeRLDUd.js → handlebars-C6YyUK7_.js} +1 -1
- package/dist/_frontend/assets/handlebars-C6YyUK7_.js.br +0 -0
- package/dist/_frontend/assets/handlebars-C6YyUK7_.js.gz +0 -0
- package/dist/_frontend/assets/{html-wpJwQ7Au.js → html-CpXVWyO_.js} +1 -1
- package/dist/_frontend/assets/html-CpXVWyO_.js.br +0 -0
- package/dist/_frontend/assets/html-CpXVWyO_.js.gz +0 -0
- package/dist/_frontend/assets/{htmlMode-BWjgtyr-.js → htmlMode-Dszq47gi.js} +1 -1
- package/dist/_frontend/assets/htmlMode-Dszq47gi.js.br +0 -0
- package/dist/_frontend/assets/htmlMode-Dszq47gi.js.gz +0 -0
- package/dist/_frontend/assets/{index-aGz8KXsj.js → index-B8Nmgjfa.js} +3 -3
- package/dist/_frontend/assets/index-B8Nmgjfa.js.br +0 -0
- package/dist/_frontend/assets/index-B8Nmgjfa.js.gz +0 -0
- package/dist/_frontend/assets/{index-DJa8qqht.css → index-BOoQko_5.css} +1 -1
- package/dist/_frontend/assets/index-BOoQko_5.css.br +0 -0
- package/dist/_frontend/assets/index-BOoQko_5.css.gz +0 -0
- package/dist/_frontend/assets/{index-DdfF63OT.js → index-C5ROvRRa.js} +279 -279
- package/dist/_frontend/assets/index-C5ROvRRa.js.br +0 -0
- package/dist/_frontend/assets/index-C5ROvRRa.js.gz +0 -0
- package/dist/_frontend/assets/{javascript-680NVpb6.js → javascript-B88igjtP.js} +1 -1
- package/dist/_frontend/assets/{jsonMode-B1wjPa_B.js → jsonMode-BZzU_TMA.js} +1 -1
- package/dist/_frontend/assets/jsonMode-BZzU_TMA.js.br +0 -0
- package/dist/_frontend/assets/jsonMode-BZzU_TMA.js.gz +0 -0
- package/dist/_frontend/assets/{liquid-DLZXw_l9.js → liquid-Brdo2hkK.js} +1 -1
- package/dist/_frontend/assets/liquid-Brdo2hkK.js.br +0 -0
- package/dist/_frontend/assets/liquid-Brdo2hkK.js.gz +0 -0
- package/dist/_frontend/assets/{lspLanguageFeatures-D2El5kWs.js → lspLanguageFeatures-DacM8YTI.js} +1 -1
- package/dist/_frontend/assets/lspLanguageFeatures-DacM8YTI.js.br +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-DacM8YTI.js.gz +0 -0
- package/dist/_frontend/assets/{mdx-BzqZXT2Y.js → mdx-Rpde0mTI.js} +1 -1
- package/dist/_frontend/assets/mdx-Rpde0mTI.js.br +0 -0
- package/dist/_frontend/assets/mdx-Rpde0mTI.js.gz +0 -0
- package/dist/_frontend/assets/{python-CL4qUpZU.js → python-BdIx5c_G.js} +1 -1
- package/dist/_frontend/assets/python-BdIx5c_G.js.br +0 -0
- package/dist/_frontend/assets/python-BdIx5c_G.js.gz +0 -0
- package/dist/_frontend/assets/{razor-Dx9DYEQN.js → razor-DA1tjeuw.js} +1 -1
- package/dist/_frontend/assets/razor-DA1tjeuw.js.br +0 -0
- package/dist/_frontend/assets/razor-DA1tjeuw.js.gz +0 -0
- package/dist/_frontend/assets/{tsMode-BSSS0gzy.js → tsMode-CXE4YxbN.js} +1 -1
- package/dist/_frontend/assets/tsMode-CXE4YxbN.js.br +0 -0
- package/dist/_frontend/assets/tsMode-CXE4YxbN.js.gz +0 -0
- package/dist/_frontend/assets/{typescript-BFmTNmj1.js → typescript-Chefx5R7.js} +1 -1
- package/dist/_frontend/assets/typescript-Chefx5R7.js.br +0 -0
- package/dist/_frontend/assets/typescript-Chefx5R7.js.gz +0 -0
- package/dist/_frontend/assets/{workers-DJIs8BcT.js → workers-EMqh1N7k.js} +1 -1
- package/dist/_frontend/assets/workers-EMqh1N7k.js.br +0 -0
- package/dist/_frontend/assets/workers-EMqh1N7k.js.gz +0 -0
- package/dist/_frontend/assets/{xml-D3m5kfkf.js → xml-BXOoSnTt.js} +1 -1
- package/dist/_frontend/assets/xml-BXOoSnTt.js.br +0 -0
- package/dist/_frontend/assets/xml-BXOoSnTt.js.gz +0 -0
- package/dist/_frontend/assets/{yaml-DFIuplXI.js → yaml-CvUTtZnk.js} +1 -1
- package/dist/_frontend/assets/yaml-CvUTtZnk.js.br +0 -0
- package/dist/_frontend/assets/yaml-CvUTtZnk.js.gz +0 -0
- package/dist/_frontend/index.html +2 -2
- package/package.json +1 -1
- package/dist/_frontend/assets/AgentCodeSnippets-IQBCA7PK-BjFskF44.js.br +0 -0
- package/dist/_frontend/assets/AgentCodeSnippets-IQBCA7PK-BjFskF44.js.gz +0 -0
- package/dist/_frontend/assets/AgentMetricChart-7V42QCLW-B6i3t-3u.js.br +0 -0
- package/dist/_frontend/assets/AgentMetricChart-7V42QCLW-B6i3t-3u.js.gz +0 -0
- package/dist/_frontend/assets/AgentOverview-NUS7DF3V-BLN7Mc1A.js.br +0 -0
- package/dist/_frontend/assets/AgentOverview-NUS7DF3V-BLN7Mc1A.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-YV5IMM36-CjuIEqY5.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-YV5IMM36-CjuIEqY5.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-T47VTMR6-cJdpKneN.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-T47VTMR6-cJdpKneN.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessions-JVLIS2OC-DfKqLMq_.js.br +0 -0
- package/dist/_frontend/assets/AgentSessions-JVLIS2OC-DfKqLMq_.js.gz +0 -0
- package/dist/_frontend/assets/AppearanceSettings-EY2WXRWB-C3VtWEAm.js.br +0 -0
- package/dist/_frontend/assets/AppearanceSettings-EY2WXRWB-C3VtWEAm.js.gz +0 -0
- package/dist/_frontend/assets/ConnectorSettings-X6OHZ6KA-u4N4OWzr.js.br +0 -0
- package/dist/_frontend/assets/ConnectorSettings-X6OHZ6KA-u4N4OWzr.js.gz +0 -0
- package/dist/_frontend/assets/DrawerLayout-DPIUGY42-Bxv9hChU.js.br +0 -0
- package/dist/_frontend/assets/DrawerLayout-DPIUGY42-Bxv9hChU.js.gz +0 -0
- package/dist/_frontend/assets/EnvironmentsPage-EUA7T7IZ-B9cZm1H2.js.br +0 -0
- package/dist/_frontend/assets/EnvironmentsPage-EUA7T7IZ-B9cZm1H2.js.gz +0 -0
- package/dist/_frontend/assets/MemorySettings-7IT3OBVB-CXPWhBSp.js.br +0 -0
- package/dist/_frontend/assets/MemorySettings-7IT3OBVB-CXPWhBSp.js.gz +0 -0
- package/dist/_frontend/assets/ModelSettings-PNXNGQ5L-ePcg3Aqh.js.br +0 -0
- package/dist/_frontend/assets/ModelSettings-PNXNGQ5L-ePcg3Aqh.js.gz +0 -0
- package/dist/_frontend/assets/SandboxSettings-H5NXXJGM-D5w4szt5.js.br +0 -0
- package/dist/_frontend/assets/SandboxSettings-H5NXXJGM-D5w4szt5.js.gz +0 -0
- package/dist/_frontend/assets/SchedulesPage-CAQD2Q4F-CO8Z5teK.js.br +0 -0
- package/dist/_frontend/assets/SchedulesPage-CAQD2Q4F-CO8Z5teK.js.gz +0 -0
- package/dist/_frontend/assets/SettingsBuilder-YMBHISA3-BXfV41lI.js.br +0 -0
- package/dist/_frontend/assets/SettingsBuilder-YMBHISA3-BXfV41lI.js.gz +0 -0
- package/dist/_frontend/assets/ShellRouteSync-RY46ZMDU-9e9CFMDE.js +0 -1
- package/dist/_frontend/assets/ShellRouteSync-RY46ZMDU-9e9CFMDE.js.br +0 -0
- package/dist/_frontend/assets/ShellRouteSync-RY46ZMDU-9e9CFMDE.js.gz +0 -0
- package/dist/_frontend/assets/SidebarLayout-DSB56OFA-CjOToD_g.js +0 -2
- package/dist/_frontend/assets/SidebarLayout-DSB56OFA-CjOToD_g.js.br +0 -0
- package/dist/_frontend/assets/SidebarLayout-DSB56OFA-CjOToD_g.js.gz +0 -0
- package/dist/_frontend/assets/SkillSettings-NVL4XWDS-BYXZ85YV.js.br +0 -0
- package/dist/_frontend/assets/SkillSettings-NVL4XWDS-BYXZ85YV.js.gz +0 -0
- package/dist/_frontend/assets/WebSearchSettings-QHDG5HBJ-BnNzyKFb.js.br +0 -0
- package/dist/_frontend/assets/WebSearchSettings-QHDG5HBJ-BnNzyKFb.js.gz +0 -0
- package/dist/_frontend/assets/WidgetLayout-VSLU2TXO-DRJouw53.js.br +0 -0
- package/dist/_frontend/assets/WidgetLayout-VSLU2TXO-DRJouw53.js.gz +0 -0
- package/dist/_frontend/assets/chunk-2PBSR643-DucDomKE.js.br +0 -0
- package/dist/_frontend/assets/chunk-2PBSR643-DucDomKE.js.gz +0 -0
- package/dist/_frontend/assets/chunk-EAY2YDVF-BEYTBRlX.js.br +0 -0
- package/dist/_frontend/assets/chunk-EAY2YDVF-BEYTBRlX.js.gz +0 -0
- package/dist/_frontend/assets/chunk-KWC2LXMU-DxiqJRhP.js +0 -1
- package/dist/_frontend/assets/chunk-KWC2LXMU-DxiqJRhP.js.br +0 -0
- package/dist/_frontend/assets/chunk-KWC2LXMU-DxiqJRhP.js.gz +0 -0
- package/dist/_frontend/assets/chunk-OB3PAWPO-CdLNGkFp.js.br +0 -0
- package/dist/_frontend/assets/chunk-OB3PAWPO-CdLNGkFp.js.gz +0 -0
- package/dist/_frontend/assets/chunk-OO6QO7FR-Clj6a-iP.js.br +0 -0
- package/dist/_frontend/assets/chunk-OO6QO7FR-Clj6a-iP.js.gz +0 -0
- package/dist/_frontend/assets/cssMode-DuqNkvPv.js.br +0 -0
- package/dist/_frontend/assets/cssMode-DuqNkvPv.js.gz +0 -0
- package/dist/_frontend/assets/freemarker2-BUfzpeUx.js.br +0 -0
- package/dist/_frontend/assets/freemarker2-BUfzpeUx.js.gz +0 -0
- package/dist/_frontend/assets/handlebars-BLeRLDUd.js.br +0 -0
- package/dist/_frontend/assets/handlebars-BLeRLDUd.js.gz +0 -0
- package/dist/_frontend/assets/html-wpJwQ7Au.js.br +0 -0
- package/dist/_frontend/assets/html-wpJwQ7Au.js.gz +0 -0
- package/dist/_frontend/assets/htmlMode-BWjgtyr-.js.br +0 -0
- package/dist/_frontend/assets/htmlMode-BWjgtyr-.js.gz +0 -0
- package/dist/_frontend/assets/index-DJa8qqht.css.br +0 -0
- package/dist/_frontend/assets/index-DJa8qqht.css.gz +0 -0
- package/dist/_frontend/assets/index-DdfF63OT.js.br +0 -0
- package/dist/_frontend/assets/index-DdfF63OT.js.gz +0 -0
- package/dist/_frontend/assets/index-aGz8KXsj.js.br +0 -0
- package/dist/_frontend/assets/index-aGz8KXsj.js.gz +0 -0
- package/dist/_frontend/assets/jsonMode-B1wjPa_B.js.br +0 -0
- package/dist/_frontend/assets/jsonMode-B1wjPa_B.js.gz +0 -0
- package/dist/_frontend/assets/liquid-DLZXw_l9.js.br +0 -0
- package/dist/_frontend/assets/liquid-DLZXw_l9.js.gz +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-D2El5kWs.js.br +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-D2El5kWs.js.gz +0 -0
- package/dist/_frontend/assets/mdx-BzqZXT2Y.js.br +0 -0
- package/dist/_frontend/assets/mdx-BzqZXT2Y.js.gz +0 -0
- package/dist/_frontend/assets/python-CL4qUpZU.js.br +0 -0
- package/dist/_frontend/assets/python-CL4qUpZU.js.gz +0 -0
- package/dist/_frontend/assets/razor-Dx9DYEQN.js.br +0 -0
- package/dist/_frontend/assets/razor-Dx9DYEQN.js.gz +0 -0
- package/dist/_frontend/assets/tsMode-BSSS0gzy.js.br +0 -0
- package/dist/_frontend/assets/tsMode-BSSS0gzy.js.gz +0 -0
- package/dist/_frontend/assets/typescript-BFmTNmj1.js.br +0 -0
- package/dist/_frontend/assets/typescript-BFmTNmj1.js.gz +0 -0
- package/dist/_frontend/assets/workers-DJIs8BcT.js.br +0 -0
- package/dist/_frontend/assets/workers-DJIs8BcT.js.gz +0 -0
- package/dist/_frontend/assets/xml-D3m5kfkf.js.br +0 -0
- package/dist/_frontend/assets/xml-D3m5kfkf.js.gz +0 -0
- package/dist/_frontend/assets/yaml-DFIuplXI.js.br +0 -0
- package/dist/_frontend/assets/yaml-DFIuplXI.js.gz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as Ce}from"./chunk-XOQYBULH-CRvLiR9N.js";import{bV as oe,$ as Se,a0 as we,cd as ce,r,x as G,j as e,a8 as Ae,ab as w,I as A,ce as Ee,g as $,aE as ee,bY as ke,at as _,bW as le,cf as ie,cg as ze}from"./index-DdfF63OT.js";var Me=[{value:"none",label:"None"},{value:"header",label:"API Key"},{value:"dcr",label:"OAuth"}],Z=ee("h-11 shadow-sm"),B=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),De=({open:a,onOpenChange:x,onSubmit:m,connector:n,busy:N=!1,error:b})=>{const[g,o]=r.useState(""),[f,y]=r.useState(""),[C,E]=r.useState(""),[h,S]=r.useState("dcr"),[c,d]=r.useState(""),[k,z]=r.useState(""),j=n!==void 0,D=ee(`h-11 shadow-sm ${j?"cursor-not-allowed bg-secondary-bg/60 text-text-secondary opacity-40":""}`),i=()=>{o(""),y(""),E(""),S("dcr"),d(""),z("")};r.useEffect(()=>{a&&(o((n==null?void 0:n.name)??""),y((n==null?void 0:n.url)??""),E((n==null?void 0:n.description)??""),S((n==null?void 0:n.auth.type)??"dcr"),d(""),z((n==null?void 0:n.auth.type)==="header"?n.auth.headerName??"":""))},[n,a]);const v=l=>{l||i(),x(l)},F=!!c.trim()||(n==null?void 0:n.auth.type)==="header",I=!!g.trim()&&!!C.trim()&&!!f.trim()&&(h!=="header"||F),K=async l=>{if(l.preventDefault(),!I||N)return;const M=h==="header"?{type:"header",apiKey:c.trim(),...k.trim()?{headerName:k.trim()}:{}}:{type:h};try{await m({name:g.trim(),url:f.trim(),description:C.trim(),auth:M}),i(),x(!1)}catch{}};return e.jsx(ke,{open:a,onOpenChange:v,title:j?"Edit MCP server":"Add MCP server",description:j?"Update how this connector authenticates.":"Point at a remote MCP endpoint. It then behaves like any other connector.",contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(A,{name:"mcp-server",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:l=>void K(l),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(B,{})]}),e.jsx("input",{id:"mcp-server-name",type:"text",required:!0,value:g,readOnly:j,"aria-disabled":j,onChange:l=>{o(l.target.value)},placeholder:"analytics-postgres-mcp",autoFocus:!j,className:D})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-description",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Description",e.jsx(B,{})]}),e.jsx("textarea",{id:"mcp-server-description",value:C,onChange:l=>{E(l.target.value)},placeholder:"Query analytics from Postgres",required:!0,rows:3,className:ee("resize-y py-2.5 shadow-sm")})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["URL",e.jsx(B,{})]}),e.jsx("input",{id:"mcp-server-url",type:"url",required:!0,value:f,onChange:l=>{y(l.target.value)},placeholder:"https://mcp.example.com/mcp",className:Z})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"mb-1.5 text-sm font-medium text-text-primary",children:["Auth type",e.jsx(B,{})]}),e.jsx("div",{className:"flex w-full flex-row rounded-md border border-border bg-secondary-bg/40 p-1",children:Me.map(l=>e.jsxs("label",{className:`flex h-8 flex-1 cursor-pointer items-center justify-center rounded-sm text-sm font-medium transition-colors ${h===l.value?"bg-dropdown-selected-item-bg text-dropdown-selected-item-text shadow-sm":"text-text-secondary hover:text-text-primary"}`,children:[e.jsx("input",{type:"radio",name:"mcp-auth-type",value:l.value,checked:h===l.value,onChange:()=>{S(l.value)},className:"sr-only"}),l.label]},l.value))})]}),h==="dcr"?e.jsxs("div",{className:"flex gap-1.5 bg-secondary-bg/40 p-2 rounded-md",children:[e.jsx(A,{name:"info",className:"size-3.5 mt-1 text-text-secondary"}),e.jsx("div",{className:"text-xs text-text-secondary leading-5.5",children:"Sign-in only — the server must support dynamic client registration. Manual OAuth (client ID / secret) isn't supported yet."})]}):null,h==="header"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",(n==null?void 0:n.auth.type)==="header"?e.jsx("span",{className:"font-normal text-text-secondary",children:" (leave blank to keep current)"}):e.jsx(B,{})]}),e.jsx("input",{id:"mcp-server-api-key",type:"password",required:(n==null?void 0:n.auth.type)!=="header",value:c,onChange:l=>{d(l.target.value)},placeholder:"Bearer <Paste the token from the provider>","aria-describedby":"mcp-server-api-key-hint",className:Z}),e.jsx("p",{id:"mcp-server-api-key-hint",className:"mt-1.5 text-xs text-text-secondary",children:`This is the value for the "${k.trim()||"Authorization"}" header.`})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-header-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Header name ",e.jsx("span",{className:"font-normal text-text-secondary",children:"(optional)"})]}),e.jsx("input",{id:"mcp-server-header-name",type:"text",value:k,onChange:l=>{z(l.target.value)},placeholder:"Authorization",className:Z})]})]}):null]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[b?e.jsx("p",{className:"text-failure-bg text-sm",children:b}):null,e.jsx(w.Primary,{type:"submit",size:"large",disabled:!I||N,className:"w-full shrink-0",children:j?"Save":"Add"})]})]})})},de=De,J={dcr:"OAuth2",header:"API Key",none:"No Auth"};function Fe({text:a}){const x=r.useRef(null),[m,n]=r.useState(!1),[N,b]=r.useState(!1),[g,o]=r.useState(16);return r.useLayoutEffect(()=>{n(!1),o(16)},[a]),r.useLayoutEffect(()=>{const f=x.current;if(!f)return;if(!m){o(16),b(f.scrollWidth>f.clientWidth+1);return}o(16);const y=requestAnimationFrame(()=>{o(f.scrollHeight)});return()=>cancelAnimationFrame(y)},[a,m]),a?e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("p",{ref:x,style:{maxHeight:g},className:$("mt-0.5 overflow-hidden font-mono text-xs leading-4 text-text-secondary transition-[max-height] duration-300 ease-in-out",!m&&"whitespace-nowrap",!m&&N&&"pr-[5.75rem]"),children:[a,m&&N?e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"cursor-pointer font-mono text-xs font-medium text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!0,onClick:()=>n(!1),children:"Show less"})]}):null]}),!m&&N?e.jsxs("button",{type:"button",className:"absolute top-0.5 right-0 cursor-pointer bg-card-bg pl-1.5 font-mono text-xs font-medium leading-4 text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!1,onClick:()=>n(!0),children:[e.jsx("span",{"aria-hidden":!0,className:"text-text-secondary",children:"…"}),e.jsx("span",{className:"ml-1",children:"Read more"})]}):null]}):null}var Re=({connector:a,onBack:x,onConnectorRefreshed:m,onEdit:n,onDisconnect:N,onRemove:b,busy:g=!1})=>{const{connectorCatalog:o}=oe(),{handleAuthorize:f,isOAuthLoading:y}=ce(),[C,E]=r.useState([]),[h,S]=r.useState(!0),[c,d]=r.useState(null),[k,z]=r.useState(!1);r.useEffect(()=>{let i=!1;return E([]),d(null),S(!0),o.getToolsByConnectorId({id:a.id}).then(v=>{i||E(v)}).catch(v=>{i||d(G(v,"Failed to load connector tools"))}).finally(()=>{i||S(!1)}),()=>{i=!0}},[a.authenticated,a.id,o]);const j=async()=>{z(!0),d(null);try{const i=await o.getConnector({id:a.id});m(i)}catch(i){d(G(i,"Failed to refresh connector details"))}finally{z(!1)}},D=y||k;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:x,className:"mb-3 inline-flex w-fit items-center gap-1 rounded-md py-1 pr-2 text-sm text-text-secondary hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",children:[e.jsx(A,{name:"chevron-left",className:"size-3.5"}),"Connectors"]}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-y-auto pb-1",children:[e.jsxs("header",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(A,{name:"mcp-server",className:"size-5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-lg font-semibold text-text-primary",children:a.name}),e.jsx("span",{className:"inline-flex items-center rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-text-secondary",children:J[a.auth.type]??J.none}),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",a.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:$("h-1.5 w-1.5 rounded-full",a.authenticated?"bg-success-bg":"bg-primary-button-bg")}),a.authenticated?"Connected":"Not authenticated"]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:e.jsx("span",{className:"text-text-secondary",children:a.description})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(w.Secondary,{size:"small",type:"button",disabled:g,onClick:n,children:[e.jsx(A,{name:"pencil",className:"size-3"}),"Edit"]}),a.auth.type==="dcr"&&!a.authenticated?e.jsx(w.Secondary,{size:"small",type:"button",disabled:g||D,onClick:()=>{f(a.id,i=>{i&&j()})},children:D?"Connecting…":"Connect"}):a.auth.type==="dcr"&&!a.requiresAuth?e.jsx(w.Secondary,{size:"small",type:"button",disabled:g,onClick:N,children:"Disconnect"}):null,b?e.jsx(w.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:g,"aria-label":`Remove ${a.name}`,onClick:b,children:"Remove"}):null]})]}),e.jsx("section",{className:"mt-6","aria-labelledby":"connector-tools-heading",children:h?e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"Loading tools…"}):c?e.jsxs("div",{className:"rounded-xl border border-failure-bg/30 bg-failure-bg/10 p-6 text-center text-sm text-failure-bg",children:[c,a.auth.type==="dcr"&&!a.authenticated&&e.jsx("div",{className:"font-bold mt-1",children:"Click Connect and authenticate successfully to view tools."})]}):C.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("h5",{id:"connector-tools-heading",className:"mb-2 text-[0.8125rem] font-semibold text-text-primary",children:["Tools ",e.jsxs("span",{className:"font-normal text-text-secondary",children:["· ",C.length]})]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:C.map(i=>e.jsx("article",{className:"flex min-h-12 items-start gap-3 border-b border-border px-3 py-2 last:border-b-0",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h6",{className:"text-sm font-medium text-text-primary",children:i.name}),e.jsx(Fe,{text:i.description})]})},i.id))})]}):e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"No tools reported for this connector."})})]})]})},Ie=Re,Oe=()=>{const{connectorCatalog:a}=oe(),x=Se(),m=we(),{handleAuthorize:n,isOAuthLoading:N}=ce(),[b,g]=r.useState(""),[o,f]=r.useState({ordered:[],authStatusById:new Map}),[y,C]=r.useState(!0),[E,h]=r.useState(null),[S,c]=r.useState(null),[d,k]=r.useState(!1),[z,j]=r.useState([]),[D,i]=r.useState(!1),[v,F]=r.useState(null),[I,K]=r.useState(null),[l,M]=r.useState(null),[me,te]=r.useState(null),[X,q]=r.useState(null),[ue,O]=r.useState(null),se=r.useMemo(()=>(z??[]).reduce((t,s)=>(t[s.name]=s.logo??"",t),{}),[z]),H=r.useCallback(async()=>{C(!0),h(null);try{const[t,s]=await Promise.all([a.listConnectors(),a.getConnectorCatalog()]);j(s);const p=t??[],R=new Set(p.map(u=>u.id)),W=[...p.map(u=>({connector:u,isConfigured:!0})),...s.filter(u=>!R.has(u.id)).map(u=>({connector:u,isConfigured:!1}))];f({ordered:W,authStatusById:new Map(W.map(u=>[u.connector.id,u.isConfigured?u.connector.authenticated:!1]))}),M(u=>u?t.find(Y=>Y.id===u.id)??null:null)}catch(t){h(G(t,"Failed to load connectors"))}finally{C(!1)}},[a]);r.useEffect(()=>{H()},[H]);const T=b.trim().toLowerCase(),U=r.useMemo(()=>T?o.ordered.filter(({connector:t})=>{var s;return t.name.toLowerCase().includes(T)||(((s=t.description)==null?void 0:s.toLowerCase().includes(T))??!1)||t.url.toLowerCase().includes(T)}):o.ordered,[o.ordered,T]),V=r.useMemo(()=>{const t=[];for(const s of U)if(s.isConfigured){const p=o.authStatusById.get(s.connector.id)??s.connector.authenticated;t.push(p===s.connector.authenticated?s.connector:{...s.connector,authenticated:p})}return t},[o.authStatusById,U]),Q=r.useMemo(()=>{const t=[];for(const s of U)s.isConfigured||t.push(s.connector);return t},[U]),P=async(t,s=h)=>{k(!0),h(null);try{await t(),await H()}catch(p){throw s(G(p,"Request failed")),p}finally{k(!1)}},ae=()=>{K(null),c(null)},xe=t=>{if(t.auth.type==="header"){c(null),K(t);return}P(async()=>{await ie({connectorCatalog:a,entry:t}),m(_.Settings.CONNECTOR_SAVED,{connector_name:t.name,mode:"create"})}).catch(()=>{})},he=t=>{if(!I)return;const s=I;c(null),P(async()=>{await ie({connectorCatalog:a,entry:s,auth:ze({entry:s,apiKey:t})}),ae(),setTimeout(()=>{x==null||x.showSuccess({title:`${s.name} connected`}),m(_.Settings.CONNECTOR_SAVED,{connector_name:s.name,mode:"create"})},100)},c).catch(()=>{})},re=async t=>{c(null),await P(async()=>{v?await a.updateConnector({id:v.id,...t}):await a.createConnector({...t})},c),setTimeout(()=>{x==null||x.showSuccess({title:`${t.name} ${v?"updated":"added"}`}),m(_.Settings.CONNECTOR_SAVED,{connector_name:t.name,mode:v?"update":"create"})},0)},pe=t=>{P(async()=>{await a.disconnectConnector({id:t.id}),m(_.Settings.CONNECTOR_DISCONNECTED,{connector_name:t.name}),M(null)}).catch(()=>{})},fe=()=>{d||(q(null),O(null))},be=t=>{const s=a.deleteConnector;s&&(O(null),P(async()=>{await s({id:t.id}),m(_.Settings.CONNECTOR_DELETED,{connector_name:t.name}),q(null),M(null)},O).catch(()=>{}))},ge=t=>{M(s=>(s==null?void 0:s.id)===t.id?t:s),f(s=>{const p=new Map(s.authStatusById);return p.set(t.id,t.authenticated),{ordered:s.ordered.map(R=>R.isConfigured&&R.connector.id===t.id?{connector:t,isConfigured:!0}:R),authStatusById:p}})},ye=(t,s)=>{const p=se[t.name],R=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:p?e.jsx(le,{src:p,alt:t.name,className:"size-4.5"}):e.jsx(A,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("div",{className:"flex items-center gap-2",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",t.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:$("h-1.5 w-1.5 rounded-full",t.authenticated?"bg-success-bg":"bg-primary-button-bg")}),t.authenticated?"Connected":"Added"]})})]}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description})]})]}),W="flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0",u=t.auth.type==="dcr"&&!t.authenticated,Y=N&&me===t.id;return e.jsxs("article",{className:`${W} cursor-pointer transition-colors hover:bg-ghost-button-hover/60`,onClick:()=>{M(t)},children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:R}),e.jsxs("div",{className:"flex items-center gap-2",children:[u?e.jsx(w.Secondary,{size:"small",type:"button",disabled:d||Y,onClick:L=>{L.stopPropagation(),te(t.id),n(t.id,Ne=>{te(null),Ne&&H()})},children:Y?"Connecting…":"Connect"}):null,e.jsxs(w.Secondary,{size:"small",type:"button",disabled:d,onClick:L=>{L.stopPropagation(),c(null),F(t),i(!0)},children:[e.jsx(A,{name:"pencil",className:"size-3"}),"Edit"]}),a.deleteConnector?e.jsx(w.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:d,"aria-label":`Remove ${t.name}`,onClick:L=>{L.stopPropagation(),O(null),q(t)},children:"Remove"}):null,e.jsx(A,{name:"chevron-right",className:"size-4"})]})]},t.id)},ve=t=>{const s=se[t.name];return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:s?e.jsx(le,{src:s,alt:t.name,className:"size-4.5"}):e.jsx(A,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description??t.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("span",{className:"hidden text-xs text-text-secondary sm:inline",children:J[t.auth.type]??J.none}),e.jsx(w.Secondary,{size:"small",type:"button",disabled:d,onClick:()=>{xe(t)},children:t.auth.type==="dcr"?"Add":"Connect"})]})]},t.id)},ne=X?e.jsx(Ce,{title:"Remove connector?",description:`“${X.name}” will no longer be available to your agents.`,busy:d,error:ue,onCancel:fe,onConfirm:()=>{be(X)}}):null;if(l)return e.jsxs(e.Fragment,{children:[e.jsx(Ie,{connector:l,busy:d,onBack:()=>{M(null)},onConnectorRefreshed:ge,onEdit:()=>{c(null),F(l),i(!0)},onDisconnect:()=>{pe(l)},onRemove:a.deleteConnector?()=>{O(null),q(l)}:void 0}),e.jsx(de,{open:D,onOpenChange:t=>{i(t),t||(F(null),c(null))},onSubmit:re,connector:v??void 0,busy:d,error:S}),ne]});const je=V.length>0||Q.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Connectors"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect tools your agents can use."}),E?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:E}):null,e.jsx("div",{className:"mt-4 min-h-0 min-w-0 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full min-w-0 flex-col gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Ae,{query:b,setQuery:g,placeholder:"Search connectors"})}),e.jsxs(w.Secondary,{type:"button",className:"shrink-0",onClick:()=>{c(null),F(null),i(!0)},children:[e.jsx(A,{name:"plus",size:"1rem",className:"mr-1"}),"Add MCP Server"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[y?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!y&&V.length>0?e.jsxs("section",{"aria-labelledby":"connected-connectors-heading",children:[e.jsxs("h4",{id:"connected-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Configured · ",V.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:V.map(t=>ye(t))})]}):null,!y&&Q.length>0?e.jsxs("section",{"aria-labelledby":"available-connectors-heading",children:[e.jsxs("h4",{id:"available-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",Q.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:Q.map(t=>ve(t))})]}):null,!y&&!je?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:b.trim()?`No connectors match “${b.trim()}”.`:"No connectors yet."}):null]}),e.jsx(Ee,{entry:I,busy:d,error:S,onSubmit:he,onCancel:ae}),e.jsx(de,{open:D,onOpenChange:t=>{i(t),t||(F(null),c(null))},onSubmit:re,connector:v??void 0,busy:d,error:S}),ne]})})]})},Le=Oe;export{Le as default};
|
|
1
|
+
import{C as Ce}from"./chunk-BNMKM5SY-CiR8M-oi.js";import{bV as oe,$ as Se,a0 as we,cd as ce,r,x as G,j as e,a8 as Ae,ab as w,I as A,ce as Ee,g as $,aE as ee,bY as ke,at as _,bW as le,cf as ie,cg as ze}from"./index-C5ROvRRa.js";var Me=[{value:"none",label:"None"},{value:"header",label:"API Key"},{value:"dcr",label:"OAuth"}],Z=ee("h-11 shadow-sm"),B=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),De=({open:a,onOpenChange:x,onSubmit:m,connector:n,busy:N=!1,error:b})=>{const[g,o]=r.useState(""),[f,y]=r.useState(""),[C,E]=r.useState(""),[h,S]=r.useState("dcr"),[c,d]=r.useState(""),[k,z]=r.useState(""),j=n!==void 0,D=ee(`h-11 shadow-sm ${j?"cursor-not-allowed bg-secondary-bg/60 text-text-secondary opacity-40":""}`),i=()=>{o(""),y(""),E(""),S("dcr"),d(""),z("")};r.useEffect(()=>{a&&(o((n==null?void 0:n.name)??""),y((n==null?void 0:n.url)??""),E((n==null?void 0:n.description)??""),S((n==null?void 0:n.auth.type)??"dcr"),d(""),z((n==null?void 0:n.auth.type)==="header"?n.auth.headerName??"":""))},[n,a]);const v=l=>{l||i(),x(l)},F=!!c.trim()||(n==null?void 0:n.auth.type)==="header",I=!!g.trim()&&!!C.trim()&&!!f.trim()&&(h!=="header"||F),K=async l=>{if(l.preventDefault(),!I||N)return;const M=h==="header"?{type:"header",apiKey:c.trim(),...k.trim()?{headerName:k.trim()}:{}}:{type:h};try{await m({name:g.trim(),url:f.trim(),description:C.trim(),auth:M}),i(),x(!1)}catch{}};return e.jsx(ke,{open:a,onOpenChange:v,title:j?"Edit MCP server":"Add MCP server",description:j?"Update how this connector authenticates.":"Point at a remote MCP endpoint. It then behaves like any other connector.",contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(A,{name:"mcp-server",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:l=>void K(l),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(B,{})]}),e.jsx("input",{id:"mcp-server-name",type:"text",required:!0,value:g,readOnly:j,"aria-disabled":j,onChange:l=>{o(l.target.value)},placeholder:"analytics-postgres-mcp",autoFocus:!j,className:D})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-description",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Description",e.jsx(B,{})]}),e.jsx("textarea",{id:"mcp-server-description",value:C,onChange:l=>{E(l.target.value)},placeholder:"Query analytics from Postgres",required:!0,rows:3,className:ee("resize-y py-2.5 shadow-sm")})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["URL",e.jsx(B,{})]}),e.jsx("input",{id:"mcp-server-url",type:"url",required:!0,value:f,onChange:l=>{y(l.target.value)},placeholder:"https://mcp.example.com/mcp",className:Z})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"mb-1.5 text-sm font-medium text-text-primary",children:["Auth type",e.jsx(B,{})]}),e.jsx("div",{className:"flex w-full flex-row rounded-md border border-border bg-secondary-bg/40 p-1",children:Me.map(l=>e.jsxs("label",{className:`flex h-8 flex-1 cursor-pointer items-center justify-center rounded-sm text-sm font-medium transition-colors ${h===l.value?"bg-dropdown-selected-item-bg text-dropdown-selected-item-text shadow-sm":"text-text-secondary hover:text-text-primary"}`,children:[e.jsx("input",{type:"radio",name:"mcp-auth-type",value:l.value,checked:h===l.value,onChange:()=>{S(l.value)},className:"sr-only"}),l.label]},l.value))})]}),h==="dcr"?e.jsxs("div",{className:"flex gap-1.5 bg-secondary-bg/40 p-2 rounded-md",children:[e.jsx(A,{name:"info",className:"size-3.5 mt-1 text-text-secondary"}),e.jsx("div",{className:"text-xs text-text-secondary leading-5.5",children:"Sign-in only — the server must support dynamic client registration. Manual OAuth (client ID / secret) isn't supported yet."})]}):null,h==="header"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",(n==null?void 0:n.auth.type)==="header"?e.jsx("span",{className:"font-normal text-text-secondary",children:" (leave blank to keep current)"}):e.jsx(B,{})]}),e.jsx("input",{id:"mcp-server-api-key",type:"password",required:(n==null?void 0:n.auth.type)!=="header",value:c,onChange:l=>{d(l.target.value)},placeholder:"Bearer <Paste the token from the provider>","aria-describedby":"mcp-server-api-key-hint",className:Z}),e.jsx("p",{id:"mcp-server-api-key-hint",className:"mt-1.5 text-xs text-text-secondary",children:`This is the value for the "${k.trim()||"Authorization"}" header.`})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-header-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Header name ",e.jsx("span",{className:"font-normal text-text-secondary",children:"(optional)"})]}),e.jsx("input",{id:"mcp-server-header-name",type:"text",value:k,onChange:l=>{z(l.target.value)},placeholder:"Authorization",className:Z})]})]}):null]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[b?e.jsx("p",{className:"text-failure-bg text-sm",children:b}):null,e.jsx(w.Primary,{type:"submit",size:"large",disabled:!I||N,className:"w-full shrink-0",children:j?"Save":"Add"})]})]})})},de=De,J={dcr:"OAuth2",header:"API Key",none:"No Auth"};function Fe({text:a}){const x=r.useRef(null),[m,n]=r.useState(!1),[N,b]=r.useState(!1),[g,o]=r.useState(16);return r.useLayoutEffect(()=>{n(!1),o(16)},[a]),r.useLayoutEffect(()=>{const f=x.current;if(!f)return;if(!m){o(16),b(f.scrollWidth>f.clientWidth+1);return}o(16);const y=requestAnimationFrame(()=>{o(f.scrollHeight)});return()=>cancelAnimationFrame(y)},[a,m]),a?e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("p",{ref:x,style:{maxHeight:g},className:$("mt-0.5 overflow-hidden font-mono text-xs leading-4 text-text-secondary transition-[max-height] duration-300 ease-in-out",!m&&"whitespace-nowrap",!m&&N&&"pr-[5.75rem]"),children:[a,m&&N?e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"cursor-pointer font-mono text-xs font-medium text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!0,onClick:()=>n(!1),children:"Show less"})]}):null]}),!m&&N?e.jsxs("button",{type:"button",className:"absolute top-0.5 right-0 cursor-pointer bg-card-bg pl-1.5 font-mono text-xs font-medium leading-4 text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!1,onClick:()=>n(!0),children:[e.jsx("span",{"aria-hidden":!0,className:"text-text-secondary",children:"…"}),e.jsx("span",{className:"ml-1",children:"Read more"})]}):null]}):null}var Re=({connector:a,onBack:x,onConnectorRefreshed:m,onEdit:n,onDisconnect:N,onRemove:b,busy:g=!1})=>{const{connectorCatalog:o}=oe(),{handleAuthorize:f,isOAuthLoading:y}=ce(),[C,E]=r.useState([]),[h,S]=r.useState(!0),[c,d]=r.useState(null),[k,z]=r.useState(!1);r.useEffect(()=>{let i=!1;return E([]),d(null),S(!0),o.getToolsByConnectorId({id:a.id}).then(v=>{i||E(v)}).catch(v=>{i||d(G(v,"Failed to load connector tools"))}).finally(()=>{i||S(!1)}),()=>{i=!0}},[a.authenticated,a.id,o]);const j=async()=>{z(!0),d(null);try{const i=await o.getConnector({id:a.id});m(i)}catch(i){d(G(i,"Failed to refresh connector details"))}finally{z(!1)}},D=y||k;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:x,className:"mb-3 inline-flex w-fit items-center gap-1 rounded-md py-1 pr-2 text-sm text-text-secondary hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",children:[e.jsx(A,{name:"chevron-left",className:"size-3.5"}),"Connectors"]}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-y-auto pb-1",children:[e.jsxs("header",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(A,{name:"mcp-server",className:"size-5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-lg font-semibold text-text-primary",children:a.name}),e.jsx("span",{className:"inline-flex items-center rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-text-secondary",children:J[a.auth.type]??J.none}),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",a.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:$("h-1.5 w-1.5 rounded-full",a.authenticated?"bg-success-bg":"bg-primary-button-bg")}),a.authenticated?"Connected":"Not authenticated"]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:e.jsx("span",{className:"text-text-secondary",children:a.description})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(w.Secondary,{size:"small",type:"button",disabled:g,onClick:n,children:[e.jsx(A,{name:"pencil",className:"size-3"}),"Edit"]}),a.auth.type==="dcr"&&!a.authenticated?e.jsx(w.Secondary,{size:"small",type:"button",disabled:g||D,onClick:()=>{f(a.id,i=>{i&&j()})},children:D?"Connecting…":"Connect"}):a.auth.type==="dcr"&&!a.requiresAuth?e.jsx(w.Secondary,{size:"small",type:"button",disabled:g,onClick:N,children:"Disconnect"}):null,b?e.jsx(w.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:g,"aria-label":`Remove ${a.name}`,onClick:b,children:"Remove"}):null]})]}),e.jsx("section",{className:"mt-6","aria-labelledby":"connector-tools-heading",children:h?e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"Loading tools…"}):c?e.jsxs("div",{className:"rounded-xl border border-failure-bg/30 bg-failure-bg/10 p-6 text-center text-sm text-failure-bg",children:[c,a.auth.type==="dcr"&&!a.authenticated&&e.jsx("div",{className:"font-bold mt-1",children:"Click Connect and authenticate successfully to view tools."})]}):C.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("h5",{id:"connector-tools-heading",className:"mb-2 text-[0.8125rem] font-semibold text-text-primary",children:["Tools ",e.jsxs("span",{className:"font-normal text-text-secondary",children:["· ",C.length]})]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:C.map(i=>e.jsx("article",{className:"flex min-h-12 items-start gap-3 border-b border-border px-3 py-2 last:border-b-0",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h6",{className:"text-sm font-medium text-text-primary",children:i.name}),e.jsx(Fe,{text:i.description})]})},i.id))})]}):e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"No tools reported for this connector."})})]})]})},Ie=Re,Oe=()=>{const{connectorCatalog:a}=oe(),x=Se(),m=we(),{handleAuthorize:n,isOAuthLoading:N}=ce(),[b,g]=r.useState(""),[o,f]=r.useState({ordered:[],authStatusById:new Map}),[y,C]=r.useState(!0),[E,h]=r.useState(null),[S,c]=r.useState(null),[d,k]=r.useState(!1),[z,j]=r.useState([]),[D,i]=r.useState(!1),[v,F]=r.useState(null),[I,K]=r.useState(null),[l,M]=r.useState(null),[me,te]=r.useState(null),[X,q]=r.useState(null),[ue,O]=r.useState(null),se=r.useMemo(()=>(z??[]).reduce((t,s)=>(t[s.name]=s.logo??"",t),{}),[z]),H=r.useCallback(async()=>{C(!0),h(null);try{const[t,s]=await Promise.all([a.listConnectors(),a.getConnectorCatalog()]);j(s);const p=t??[],R=new Set(p.map(u=>u.id)),W=[...p.map(u=>({connector:u,isConfigured:!0})),...s.filter(u=>!R.has(u.id)).map(u=>({connector:u,isConfigured:!1}))];f({ordered:W,authStatusById:new Map(W.map(u=>[u.connector.id,u.isConfigured?u.connector.authenticated:!1]))}),M(u=>u?t.find(Y=>Y.id===u.id)??null:null)}catch(t){h(G(t,"Failed to load connectors"))}finally{C(!1)}},[a]);r.useEffect(()=>{H()},[H]);const T=b.trim().toLowerCase(),U=r.useMemo(()=>T?o.ordered.filter(({connector:t})=>{var s;return t.name.toLowerCase().includes(T)||(((s=t.description)==null?void 0:s.toLowerCase().includes(T))??!1)||t.url.toLowerCase().includes(T)}):o.ordered,[o.ordered,T]),V=r.useMemo(()=>{const t=[];for(const s of U)if(s.isConfigured){const p=o.authStatusById.get(s.connector.id)??s.connector.authenticated;t.push(p===s.connector.authenticated?s.connector:{...s.connector,authenticated:p})}return t},[o.authStatusById,U]),Q=r.useMemo(()=>{const t=[];for(const s of U)s.isConfigured||t.push(s.connector);return t},[U]),P=async(t,s=h)=>{k(!0),h(null);try{await t(),await H()}catch(p){throw s(G(p,"Request failed")),p}finally{k(!1)}},ae=()=>{K(null),c(null)},xe=t=>{if(t.auth.type==="header"){c(null),K(t);return}P(async()=>{await ie({connectorCatalog:a,entry:t}),m(_.Settings.CONNECTOR_SAVED,{connector_name:t.name,mode:"create"})}).catch(()=>{})},he=t=>{if(!I)return;const s=I;c(null),P(async()=>{await ie({connectorCatalog:a,entry:s,auth:ze({entry:s,apiKey:t})}),ae(),setTimeout(()=>{x==null||x.showSuccess({title:`${s.name} connected`}),m(_.Settings.CONNECTOR_SAVED,{connector_name:s.name,mode:"create"})},100)},c).catch(()=>{})},re=async t=>{c(null),await P(async()=>{v?await a.updateConnector({id:v.id,...t}):await a.createConnector({...t})},c),setTimeout(()=>{x==null||x.showSuccess({title:`${t.name} ${v?"updated":"added"}`}),m(_.Settings.CONNECTOR_SAVED,{connector_name:t.name,mode:v?"update":"create"})},0)},pe=t=>{P(async()=>{await a.disconnectConnector({id:t.id}),m(_.Settings.CONNECTOR_DISCONNECTED,{connector_name:t.name}),M(null)}).catch(()=>{})},fe=()=>{d||(q(null),O(null))},be=t=>{const s=a.deleteConnector;s&&(O(null),P(async()=>{await s({id:t.id}),m(_.Settings.CONNECTOR_DELETED,{connector_name:t.name}),q(null),M(null)},O).catch(()=>{}))},ge=t=>{M(s=>(s==null?void 0:s.id)===t.id?t:s),f(s=>{const p=new Map(s.authStatusById);return p.set(t.id,t.authenticated),{ordered:s.ordered.map(R=>R.isConfigured&&R.connector.id===t.id?{connector:t,isConfigured:!0}:R),authStatusById:p}})},ye=(t,s)=>{const p=se[t.name],R=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:p?e.jsx(le,{src:p,alt:t.name,className:"size-4.5"}):e.jsx(A,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("div",{className:"flex items-center gap-2",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",t.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:$("h-1.5 w-1.5 rounded-full",t.authenticated?"bg-success-bg":"bg-primary-button-bg")}),t.authenticated?"Connected":"Added"]})})]}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description})]})]}),W="flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0",u=t.auth.type==="dcr"&&!t.authenticated,Y=N&&me===t.id;return e.jsxs("article",{className:`${W} cursor-pointer transition-colors hover:bg-ghost-button-hover/60`,onClick:()=>{M(t)},children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:R}),e.jsxs("div",{className:"flex items-center gap-2",children:[u?e.jsx(w.Secondary,{size:"small",type:"button",disabled:d||Y,onClick:L=>{L.stopPropagation(),te(t.id),n(t.id,Ne=>{te(null),Ne&&H()})},children:Y?"Connecting…":"Connect"}):null,e.jsxs(w.Secondary,{size:"small",type:"button",disabled:d,onClick:L=>{L.stopPropagation(),c(null),F(t),i(!0)},children:[e.jsx(A,{name:"pencil",className:"size-3"}),"Edit"]}),a.deleteConnector?e.jsx(w.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:d,"aria-label":`Remove ${t.name}`,onClick:L=>{L.stopPropagation(),O(null),q(t)},children:"Remove"}):null,e.jsx(A,{name:"chevron-right",className:"size-4"})]})]},t.id)},ve=t=>{const s=se[t.name];return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:s?e.jsx(le,{src:s,alt:t.name,className:"size-4.5"}):e.jsx(A,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description??t.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("span",{className:"hidden text-xs text-text-secondary sm:inline",children:J[t.auth.type]??J.none}),e.jsx(w.Secondary,{size:"small",type:"button",disabled:d,onClick:()=>{xe(t)},children:t.auth.type==="dcr"?"Add":"Connect"})]})]},t.id)},ne=X?e.jsx(Ce,{title:"Remove connector?",description:`“${X.name}” will no longer be available to your agents.`,busy:d,error:ue,onCancel:fe,onConfirm:()=>{be(X)}}):null;if(l)return e.jsxs(e.Fragment,{children:[e.jsx(Ie,{connector:l,busy:d,onBack:()=>{M(null)},onConnectorRefreshed:ge,onEdit:()=>{c(null),F(l),i(!0)},onDisconnect:()=>{pe(l)},onRemove:a.deleteConnector?()=>{O(null),q(l)}:void 0}),e.jsx(de,{open:D,onOpenChange:t=>{i(t),t||(F(null),c(null))},onSubmit:re,connector:v??void 0,busy:d,error:S}),ne]});const je=V.length>0||Q.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Connectors"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect tools your agents can use."}),E?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:E}):null,e.jsx("div",{className:"mt-4 min-h-0 min-w-0 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full min-w-0 flex-col gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Ae,{query:b,setQuery:g,placeholder:"Search connectors"})}),e.jsxs(w.Secondary,{type:"button",className:"shrink-0",onClick:()=>{c(null),F(null),i(!0)},children:[e.jsx(A,{name:"plus",size:"1rem",className:"mr-1"}),"Add MCP Server"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[y?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!y&&V.length>0?e.jsxs("section",{"aria-labelledby":"connected-connectors-heading",children:[e.jsxs("h4",{id:"connected-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Configured · ",V.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:V.map(t=>ye(t))})]}):null,!y&&Q.length>0?e.jsxs("section",{"aria-labelledby":"available-connectors-heading",children:[e.jsxs("h4",{id:"available-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",Q.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:Q.map(t=>ve(t))})]}):null,!y&&!je?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:b.trim()?`No connectors match “${b.trim()}”.`:"No connectors yet."}):null]}),e.jsx(Ee,{entry:I,busy:d,error:S,onSubmit:he,onCancel:ae}),e.jsx(de,{open:D,onOpenChange:t=>{i(t),t||(F(null),c(null))},onSubmit:re,connector:v??void 0,busy:d,error:S}),ne]})})]})},Le=Oe;export{Le as default};
|
|
Binary file
|
|
Binary file
|
package/dist/_frontend/assets/{DockLayout-SEEHTHCB-qMMUFfFT.js → DockLayout-AEFR44GJ-Cvdwne2I.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as a}from"./chunk-
|
|
1
|
+
import{S as a}from"./chunk-LBXXYCLT-bkjw_srH.js";import{j as o,C as t,g as l}from"./index-C5ROvRRa.js";import"./chunk-DW4YYV6Q-Cm0KW5r-.js";function n({className:r}){return o.jsx(t,{children:o.jsx("div",{"data-aui-compact-layout":!0,className:l("ml-auto flex h-full w-full max-w-[min(400px,100%)] min-h-0 min-w-0 flex-col border-l border-border bg-primary-bg shadow-[-4px_0_24px_color-mix(in_oklab,var(--shadow-color)_6%,transparent)]",r),children:o.jsx(a,{})})})}export{n as DockLayout};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-
|
|
2
|
-
import{u as T,b as R,c as U,d as t,r,e as V,s as F,j as s,P as M,I as g,f as x,S as f,D as H,g as q,_ as j}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-OKV2POOV-CsW3joKv.js","./index-C5ROvRRa.js","./index-BOoQko_5.css","./SchedulesPage-I52TNBAZ-ClnGQZ5d.js","./chunk-4QN7ONBR-CtFqtChE.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as T,b as R,c as U,d as t,r,e as V,s as F,j as s,P as M,I as g,f as x,S as f,D as H,g as q,_ as j}from"./index-C5ROvRRa.js";import{A as G,S as J,N as K,T as Q}from"./chunk-DW4YYV6Q-Cm0KW5r-.js";var W=r.lazy(()=>j(()=>import("./SettingsBuilder-OKV2POOV-CsW3joKv.js"),__vite__mapDeps([0,1,2]),import.meta.url)),X=r.lazy(()=>j(()=>import("./SchedulesPage-I52TNBAZ-ClnGQZ5d.js"),__vite__mapDeps([3,4,1,2]),import.meta.url).then(c=>({default:c.SchedulesPage})));function $({className:c}){const b=T(),e=R(),l=U(),A=t("ClearChatButton"),y=t("ResetAgentBuilderButton"),h=t("AgentDetailsPage"),C=t("AgentsLibrary"),S=t("SessionsPage"),N=t("ShareChatButton"),v=t("SaveAgentButton"),w=t("AgentUnsavedChangesStatus"),O=t("SelectAgentEmptyState"),B=t("UserAvatar"),_=r.useRef(null),E=(e==null?void 0:e.mode.status)==="idle",u=(e==null?void 0:e.settingsOpen)===!0,a=(e==null?void 0:e.libraryOpen)===!0,d=(e==null?void 0:e.sessionsOpen)===!0,i=(e==null?void 0:e.schedulesOpen)===!0,o=u||a||d||i,P=V(),m=e!=null&&F(e.mode),n=l&&(d||i||m&&!u&&!a),k=m&&!o&&!l,p=(e==null?void 0:e.isNewChatEnabled)!==!1,D=()=>{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(b.threads().switchToNewThread()).catch(()=>{})},I=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()},L=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSchedulesOpen(!1),e==null||e.setSessionsOpen(!1),n&&m&&(e==null||e.openDraft())},z=n||a||i;return s.jsxs("div",{className:q("relative flex h-full min-h-0 w-full bg-primary-bg",c),children:[k?s.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:w-88 md:max-w-none md:shrink-0 md:shadow-none",children:s.jsx(G,{})}):null,s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[s.jsx(M,{className:"bg-topbar-bg",title:z?s.jsxs("button",{type:"button",className:x({variant:"ghost",size:"small"}),onClick:L,children:[s.jsx(g,{name:"arrow-left"}),"Back to chat"]}):o?null:s.jsx(K,{}),end:s.jsxs(s.Fragment,{children:[!o&&!n?s.jsxs(s.Fragment,{children:[s.jsx(w,{}),s.jsx(y,{}),s.jsx(N,{}),s.jsx(A,{}),s.jsx(v,{})]}):null,s.jsx(J,{},"shell-actions"),s.jsx(B,{}),!o&&!n?s.jsxs(s.Fragment,{children:[p&&!P?s.jsx("button",{type:"button","aria-label":"New Chat",title:"New Chat",className:x({variant:"ghost",size:"icon"}),onClick:D,children:s.jsx(g,{name:"square-pen"})}):null,p&&(e!=null&&e.isComposerEnabled)&&!l?s.jsx("button",{type:"button","aria-label":"New Agent",title:"New Agent",className:x({variant:"ghost",size:"icon"}),onClick:I,children:s.jsx(g,{name:"agent-2"})}):null]}):null]})}),s.jsx("div",{ref:_,className:"min-h-0 min-w-0 flex-1",children:u?s.jsx(r.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(f,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(W,{})}):n?s.jsx(H,{}):d?s.jsx(S,{}):a&&(e==null?void 0:e.libraryAgentId)!=null?s.jsx(h,{agentId:e.libraryAgentId},e.libraryAgentId):a?s.jsx(C,{}):i?s.jsx(r.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(f,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(X,{})}):E?s.jsx(O,{}):s.jsx(Q,{})})]})]})}export{$ as DrawerLayout};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as De}from"./chunk-XOQYBULH-CRvLiR9N.js";import{B as X}from"./chunk-2PBSR643-DucDomKE.js";import{aH as ve,X as Te,b as Pe,$ as Ne,a0 as je,aI as Me,r as h,aJ as $,Y as me,a2 as Re,x as ye,a1 as Be,aK as J,aL as ue,aM as ee,j as e,a8 as _e,g as M,V as B,ab as F,I as C,P as ze,ad as Z,ac as Le,aN as Oe,ae as Ve,af as Fe,ag as xe,ah as T,ai as Ie,aj as P,aO as qe,aP as Qe,aG as Ge,aw as He,f as _,al as Ke,ar as Ue,ax as Ye,aQ as he,aB as $e,at as W,d as Je,am as Ze,aR as Xe,aS as We,a4 as en}from"./index-DdfF63OT.js";function pe(n){var l,a,s,i,m,o,d,c;return{name:n.name,description:n.description??"",buildScript:((l=n.image)==null?void 0:l.buildScript)??"",cpu:String(((a=n.resources)==null?void 0:a.cpu)??1),memory:String(((s=n.resources)==null?void 0:s.memory)??1),disk:String(((i=n.resources)==null?void 0:i.disk)??3),networkBlockAll:((m=n.networking)==null?void 0:m.networkBlockAll)===!0,domainAllowList:((o=n.networking)==null?void 0:o.domainAllowList)??"",secrets:((c=(d=n.networking)==null?void 0:d.secrets)==null?void 0:c.map(N=>({...N,hosts:[...N.hosts]})))??[],environmentVariables:Object.entries(n.environmentVariables??{}).map(([N,v])=>({key:N,value:v}))}}function nn(n){const l=Number(n.cpu),a=Number(n.memory),s=Number(n.disk),i=Object.fromEntries(n.environmentVariables.map(o=>[o.key.trim(),o.value]).filter(([o,d])=>o.length>0&&d.length>0)),m=n.networkBlockAll?void 0:n.secrets.map(o=>({env:o.env.trim(),value:o.value,hosts:o.hosts.map(d=>d.trim()).filter(d=>d.length>0)})).filter(o=>o.env.length>0&&o.value.length>0);return{name:n.name.trim(),...n.description.trim().length===0?{}:{description:n.description.trim()},...n.buildScript.trim().length===0?{}:{image:{type:"build",buildScript:n.buildScript}},resources:{cpu:Number.isFinite(l)&&l>0?l:1,memory:Number.isFinite(a)&&a>0?a:1,disk:Number.isFinite(s)&&s>0?s:3},...Object.keys(i).length===0?{}:{environmentVariables:i},networking:n.networkBlockAll?{networkBlockAll:!0}:{networkBlockAll:!1,...n.domainAllowList.trim().length===0?{}:{domainAllowList:n.domainAllowList.trim()},...m==null||m.length===0?{}:{secrets:m}}}}function tn(n){const l=n.name.trim();if(l.length===0)return"Name is required";if(ee(l))return`Name "${We}" is reserved`;const a=Number(n.cpu),s=Number(n.memory),i=Number(n.disk);if(!Number.isFinite(a)||a<=0)return"CPU must be a positive number";if(!Number.isFinite(s)||s<=0)return"Memory must be a positive number";if(!Number.isFinite(i)||i<=0)return"Disk must be a positive number";if(!n.networkBlockAll){for(const m of n.secrets)if(m.env.trim().length!==0&&m.value.trim().length===0)return"Secret value is required"}return null}var w="w-full rounded-md border border-border bg-input-box-bg px-2.5 py-1.5 text-sm text-text-primary placeholder:text-text-secondary/70 outline-none focus:border-primary-button-bg",fe="text-sm font-medium text-text-primary",O="rounded-lg border border-border p-4 flex flex-col gap-4";function sn({values:n,onChange:l,nameDisabled:a,readOnly:s=!1}){const i=Je("MonacoEditorCore"),m=h.useId(),[o,d]=h.useState(!1),c=r=>l({...n,...r}),N={readOnly:s,lineNumbers:"on",renderFinalNewline:"on",tabFocusMode:!o},v=r=>c({buildScript:r});return e.jsxs("fieldset",{disabled:s,className:"m-0 flex min-w-0 flex-col gap-4 border-0 p-0 pb-8",children:[e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:fe,children:"Name"}),e.jsx("input",{className:M(w,a&&"opacity-70"),value:n.name,disabled:a,placeholder:"my-environment",onChange:r=>c({name:r.target.value})})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:fe,children:"Description"}),e.jsx("textarea",{className:M(w,"min-h-20 resize-y"),value:n.description,placeholder:"write description ...",onChange:r=>c({description:r.target.value})})]}),e.jsxs("div",{className:O,children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Image And Resources"}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{id:m,className:"text-xs font-medium text-text-secondary",children:"Build Script"}),e.jsx("button",{type:"button","aria-label":"Edit build script full screen","aria-haspopup":"dialog",title:"Full screen",className:_({variant:"ghost",size:"icon",className:"size-7 shrink-0"}),onClick:()=>d(!0),children:e.jsx(C,{name:"expand",className:"size-4"})})]}),e.jsx("div",{role:"group","aria-labelledby":m,className:"h-36 overflow-hidden rounded-md border border-border bg-input-box-bg",children:o?null:e.jsx(i,{value:n.buildScript,language:"shell",height:"100%",options:N,onChange:v})}),e.jsx(Ze,{open:o,onOpenChange:d,"aria-label":"Edit build script full screen",className:"h-[calc(100dvh-2rem)] max-h-none w-[calc(100vw-2rem)] max-w-none",children:o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border px-4 py-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-primary",children:"Build Script"}),e.jsx(F.Secondary,{type:"button",size:"small",onClick:()=>d(!1),children:"Done"})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(i,{autoFocus:!0,value:n.buildScript,language:"shell",height:"100%",options:N,onChange:v})})]}):null})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"CPU"}),e.jsx("input",{className:w,type:"number",min:.1,step:"any",value:n.cpu,placeholder:"type...",onChange:r=>c({cpu:r.target.value})})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Memory (GB)"}),e.jsx("input",{className:w,type:"number",min:.1,step:"any",value:n.memory,placeholder:"type...",onChange:r=>c({memory:r.target.value})})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Disk (GB)"}),e.jsx("input",{className:w,type:"number",min:.1,step:"any",value:n.disk,placeholder:"type...",onChange:r=>c({disk:r.target.value})})]})]})]}),e.jsxs("div",{className:O,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Environment Variables"}),e.jsx("button",{type:"button",className:"cursor-pointer text-xs font-medium text-text-secondary transition-colors hover:text-text-primary",onClick:()=>c({environmentVariables:[...n.environmentVariables,{key:"",value:""}]}),children:"+ Add Variables"})]}),n.environmentVariables.map((r,f)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("input",{className:w,value:r.key,placeholder:"KEY",onChange:g=>{const u=n.environmentVariables.map((b,p)=>p===f?{...b,key:g.target.value}:b);c({environmentVariables:u})}}),e.jsx("input",{className:w,value:r.value,placeholder:"value",onChange:g=>{const u=n.environmentVariables.map((b,p)=>p===f?{...b,value:g.target.value}:b);c({environmentVariables:u})}})]}),e.jsx("button",{type:"button",className:_({variant:"ghost",size:"icon"}),"aria-label":"Remove environment variable",onClick:()=>c({environmentVariables:n.environmentVariables.filter((g,u)=>u!==f)}),children:e.jsx(C,{name:"trash",className:"size-3.5 text-failure-bg"})})]},f))]}),e.jsxs("div",{className:O,children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-medium text-text-primary",children:"Block All Network"}),e.jsx("span",{className:"text-xs text-text-secondary",children:"Overrides the domain allow list"})]}),e.jsx(Xe,{checked:n.networkBlockAll,onCheckedChange:r=>c({networkBlockAll:r}),"aria-label":"Block All Network"})]}),n.networkBlockAll?null:e.jsxs("label",{className:"flex flex-col gap-1.5 pt-1",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Domain Allow List"}),e.jsx("input",{className:w,value:n.domainAllowList,placeholder:"api.github.com,api.openai.com",onChange:r=>c({domainAllowList:r.target.value})})]})]}),n.networkBlockAll?null:e.jsxs("div",{className:O,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Secrets"}),e.jsxs("span",{className:"text-xs text-text-secondary",children:["Synced immediately with existing sandboxes."," ",e.jsxs("a",{href:"https://trueforge.dev/sandbox#how-changes-reach-a-running-session",target:"_blank",rel:"noreferrer",className:"text-primary-button-bg inline-flex items-center gap-1 hover:underline",children:["Learn more",e.jsx(C,{name:"external-link",className:"size-3"})]})]})]}),e.jsx("button",{type:"button",className:"cursor-pointer text-xs font-medium text-text-secondary transition-colors hover:text-text-primary",onClick:()=>c({secrets:[...n.secrets,{env:"",value:"",hosts:[]}]}),children:"+ Add Secret"})]}),n.secrets.map((r,f)=>e.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-border p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("input",{className:w,value:r.env,placeholder:"ENV_NAME",onChange:g=>{const u=n.secrets.map((b,p)=>p===f?{...b,env:g.target.value}:b);c({secrets:u})}}),e.jsx("input",{className:w,type:"password",value:r.value,placeholder:"value",onChange:g=>{const u=n.secrets.map((b,p)=>p===f?{...b,value:g.target.value}:b);c({secrets:u})}})]}),e.jsx("button",{type:"button",className:_({variant:"ghost",size:"icon"}),"aria-label":"Remove secret",onClick:()=>c({secrets:n.secrets.filter((g,u)=>u!==f)}),children:e.jsx(C,{name:"trash",className:"size-3.5 text-failure-bg"})})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("input",{className:w,value:r.hosts.join(","),placeholder:"api.github.com,api.openai.com",onChange:g=>{const u=g.target.value.split(",").map(p=>p.trim()),b=n.secrets.map((p,j)=>j===f?{...p,hosts:u}:p);c({secrets:b})}}),e.jsx("span",{className:"text-xs text-text-secondary",children:"Hosts allowed to resolve secret (comma-separated)."})]})]},f))]})]})}function an({open:n,onOpenChange:l,mode:a,environment:s,readOnly:i=!1,onSaved:m}){const o=ve(),d=Ne(),c=je(),[N,v]=h.useState(()=>pe(he())),[r,f]=h.useState(!1),[g,u]=h.useState(null);h.useEffect(()=>{if(!n){u(null),f(!1);return}const j=a==="edit"&&s!=null?s.manifest:he();v(pe(j)),u(null)},[n,a,s]);const b=async j=>{j.preventDefault(),u(null);const A=tn(N);if(A!=null){u(A);return}f(!0);try{const E=nn(N),R=a==="create"?await o.createEnvironment({manifest:E}):await o.createOrUpdateEnvironment({manifest:E});c(a==="create"?W.Environment.CREATED:W.Environment.EDITED,{environment_name:R.name,environment_id:R.id}),d==null||d.showSuccess({title:a==="create"?"Environment created":"Environment updated"}),m==null||m(),l(!1)}catch(E){u(ye(E,"Failed to save environment")),d==null||d.showError(E)}finally{f(!1)}},p=a==="create"?"New environment":(s==null?void 0:s.name)??"Edit environment";return e.jsx($e,{open:n,onOpenChange:l,title:p,description:i?"View the environment configuration.":"Configure the environment.",size:"xl",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(F.Secondary,{type:"button",disabled:r,onClick:()=>l(!1),children:i?"Close":"Cancel"}),i?null:e.jsx(F.Primary,{type:"submit",form:"environment-form",disabled:r,children:r?"Saving…":a==="create"?"Create":"Save"})]}),children:e.jsxs("form",{id:"environment-form",className:"flex min-h-0 flex-1 flex-col gap-4 px-5 pt-4 pb-10",onSubmit:j=>void b(j),children:[g!=null?e.jsx("p",{className:"text-sm text-failure-bg",children:g}):null,e.jsx(sn,{values:N,onChange:v,nameDisabled:a==="edit",readOnly:i})]})})}var rn={pending:{label:"Building",variant:"info",icon:"loader"},ready:{label:"Ready",variant:"success",icon:"check"},failed:{label:"Failed",variant:"destructive",icon:"triangle-exclamation"}};function ln({reason:n}){const[l,a]=h.useState(!1),s=h.useCallback(i=>{i.stopPropagation(),navigator.clipboard.writeText(n).then(()=>{a(!0),window.setTimeout(()=>a(!1),1500)},()=>{})},[n]);return e.jsxs("span",{className:"flex max-w-md items-start gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 text-left break-words whitespace-pre-wrap",children:n}),e.jsx("button",{type:"button","aria-label":l?"Copied":"Copy failure message",title:l?"Copied":"Copy",className:_({variant:"ghost",size:"icon",className:"size-6 shrink-0"}),onClick:s,children:e.jsx(C,{name:l?"check":"copy",size:"0.875rem"})})]})}function on({status:n,statusReason:l}){const a=rn[n],s=e.jsxs(X,{variant:a.variant,shape:"rounded",size:"sm",children:[e.jsx(C,{name:a.icon,className:a.icon==="loader"?"size-3.5 shrink-0 animate-spin":"size-3.5 shrink-0"}),a.label]});return n==="failed"&&l!=null&&l.length>0?e.jsx(B,{content:e.jsx(ln,{reason:l}),className:"max-w-md whitespace-normal",dismissOnClick:!1,children:s}):s}var cn=[10,25],dn=1e4,mn=[];function ge(n){return Math.min(Math.max(n,1),25)}function be(n){return n===void 0||n===""?void 0:n}function un({environment:n,canManage:l,canDelete:a,canSetDefault:s}){const i=l?void 0:"You do not have permission to manage this environment.",m=ee(n.name);return{edit:m?"This environment is provided by the platform and cannot be edited.":i,setDefault:i??(s?n.isDefault?"Already the default.":n.enabled?n.status!=="ready"?"Only a ready environment can be the default.":void 0:"Enable the environment before making it the default.":"Only admins can choose the default environment."),toggleEnabled:i??(n.isDefault&&n.enabled?"The default environment cannot be disabled. Make another one the default first.":void 0),delete:m?"This environment is provided by the platform and cannot be deleted.":n.isDefault?"The default environment cannot be deleted. Make another one the default first.":a?void 0:"You do not have permission to delete this environment."}}function V({label:n,icon:l,reason:a,className:s,onClick:i}){const m=e.jsxs(Ye,{className:M("whitespace-nowrap",s),disabled:a!==void 0,onClick:i,children:[e.jsx(C,{name:l,className:"size-3.5"}),n]});return a===void 0?m:e.jsx(B,{content:a,side:"left",className:"max-w-xs whitespace-normal text-left",interactive:!1,children:e.jsx("span",{className:"block w-full",children:m})})}function gn({embedded:n=!1}){var le,oe,ce;const l=ve(),a=Te(),s=Pe(),i=Ne(),m=je(),{canCreateSandboxEnvironment:o,loading:d}=Me(),[c,N]=h.useState(()=>$(window.location.search).q??""),[v,r]=h.useState({kind:"closed"}),[f,g]=h.useState(null),[u,b]=h.useState(()=>ge(Ue)),p=JSON.stringify([u]),[j,A]=h.useState(()=>({scope:p,token:void 0}));j.scope!==p&&A({scope:p,token:void 0});const E=j.scope===p?j.token:void 0,R=h.useRef(!1),ne=h.useRef((s==null?void 0:s.settingsOpen)??!1),I=(s==null?void 0:s.settingsOpen)??!1,q=h.useMemo(()=>({limit:u,...E===void 0?{}:{pageToken:E}}),[u,E]),Q=h.useMemo(()=>me.environments.list(q),[q]),S=Re({queryKey:Q,queryFn:()=>l.listEnvironments(q),placeholderData:en},a),y=((le=S.data)==null?void 0:le.data)??mn,te=!S.isPlaceholderData,z=te?be((oe=S.data)==null?void 0:oe.nextPageToken):void 0,G=te?be((ce=S.data)==null?void 0:ce.previousPageToken):void 0,we=S.isPending||S.isPlaceholderData,H=S.error!=null&&y.length===0?ye(S.error,"Check your connection and try again."):null,{refetch:se}=S,{allows:K}=Be({resourceType:"sandbox_environment",resourceIds:y.map(t=>t.id)}),U=h.useCallback(()=>{a.invalidateQueries({queryKey:me.environments.all()}),s==null||s.invalidateEnvironmentsList()},[a,s]);h.useEffect(()=>{J({q:c.trim().length===0?null:c})},[c]),h.useEffect(()=>{ne.current&&!I&&se(),ne.current=I},[I,se]),h.useEffect(()=>{const t=y.filter(D=>D.status==="pending");if(t.length===0)return;const x=window.setInterval(async()=>{try{const Y=(await Promise.all(t.map(k=>l.getEnvironment({name:k.name}).catch(()=>null)))).filter(k=>k!=null);if(Y.length===0)return;a.setQueryData(Q,k=>k==null?k:{...k,data:k.data.map(de=>Y.find(Ae=>Ae.name===de.name)??de)}),Y.some(k=>k.status!=="pending")&&(s==null||s.invalidateEnvironmentsList())}catch{}},dn);return()=>window.clearInterval(x)},[y,l,Q,a,s]),h.useEffect(()=>{if(d)return;const t=$(window.location.search);if(!R.current&&t.isNew){R.current=!0,J({isNew:null}),r(o?{kind:"create"}:x=>x.kind==="create"?{kind:"closed"}:x);return}o||r(x=>x.kind==="create"?{kind:"closed"}:x)},[o,d]),h.useEffect(()=>{const t=()=>{const x=$(window.location.search);N(x.q??""),x.isNew&&(d||(J({isNew:null}),o&&r({kind:"create"})))};return window.addEventListener(ue,t),()=>window.removeEventListener(ue,t)},[o,d]);const L=h.useMemo(()=>{const t=c.trim().toLowerCase();return t.length===0?y:y.filter(x=>x.name.toLowerCase().includes(t)||x.description.toLowerCase().includes(t))},[y,c]),ke=v.kind==="edit"&&(ee(v.environment.name)||!K(v.environment.id,"MANAGE")),Ee=z!=null||G!=null||y.length>0,ae=we&&y.length===0,Se=()=>{o&&r({kind:"create"})},Ce=async()=>{if(f==null)return;const t=f;g(null);try{await l.deleteEnvironment({name:t.name}),m(W.Environment.DELETED,{environment_name:t.name,environment_id:t.id}),i==null||i.showSuccess({title:"Environment deleted"}),A({scope:p,token:void 0}),U()}catch(x){i==null||i.showError(x)}},ie=async({change:t,title:x})=>{try{await t(),i==null||i.showSuccess({title:x}),U()}catch(D){i==null||i.showError(D)}},re=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:M(n?"min-w-0 flex-1 sm:max-w-64":"w-64"),children:e.jsx(_e,{query:c,setQuery:N,placeholder:"Search environments by name"})}),e.jsx(B,{content:o||d?void 0:"Only admins can create sandbox environments",children:e.jsx("span",{className:"inline-flex shrink-0",children:e.jsxs(F.Primary,{type:"button",onClick:Se,disabled:!o,children:[e.jsx(C,{name:"plus",className:"size-3.5"}),"New Environment"]})})})]});return e.jsxs("div",{className:M("flex h-full min-h-0 flex-col",n?"bg-transparent":"bg-primary-bg"),children:[n?e.jsxs("div",{className:"flex shrink-0 flex-col gap-3 border-b border-border px-4 py-4 sm:flex-row sm:items-start sm:justify-between sm:px-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Environments"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Customize sandbox images, resources, and networking for agent runs."})]}),e.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:re})]}):e.jsx(ze,{title:"Environments",end:re}),e.jsx("div",{className:M("flex min-h-0 flex-1 flex-col px-4 py-4",n&&"sm:px-6",(H!=null||ae||y.length===0||L.length===0)&&"overflow-auto"),children:H!=null?e.jsx("div",{role:"alert",className:"flex flex-1 flex-col items-center justify-center",children:e.jsx(Z,{title:"Couldn't load environments",description:H,className:"h-auto min-h-0 flex-none py-0"})}):ae?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading environments",children:Array.from({length:5},(t,x)=>e.jsx(Le,{className:"h-12 w-full rounded-md"},x))}):y.length===0?e.jsx(Z,{title:"No environments yet",description:"Create an environment to customize sandbox images, resources, and networking.",className:"min-h-full"}):L.length===0?e.jsx(Z,{title:"No environments found",description:e.jsxs(e.Fragment,{children:["No environments match ",e.jsx(Oe,{children:c.trim()}),"."]}),className:"min-h-full"}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-border",children:[e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsxs(Ve,{className:"min-w-240 bg-card-bg",children:[e.jsx(Fe,{children:e.jsxs(xe,{className:"hover:bg-transparent",children:[e.jsx(T,{className:"w-[15.6rem] max-w-[15.6rem]",children:"Name"}),e.jsx(T,{children:"Availability"}),e.jsx(T,{children:"Build Status"}),e.jsx(T,{children:"Resources"}),e.jsx(T,{children:"Networking"}),e.jsx(T,{children:"Updated"}),e.jsx(T,{className:"w-16"})]})}),e.jsx(Ie,{children:L.map(t=>{const x=un({environment:t,canManage:K(t.id,"MANAGE"),canDelete:K(t.id,"DELETE"),canSetDefault:o});return e.jsxs(xe,{className:"cursor-pointer",onClick:()=>r({kind:"edit",environment:t}),children:[e.jsx(P,{className:"w-[15.6rem] max-w-[15.6rem]",children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:t.name}),t.isDefault?e.jsx(B,{content:"Agents that do not pick an environment run in this one.",className:"max-w-xs whitespace-normal text-left",triggerClassName:"shrink-0",children:e.jsx(X,{variant:"info",shape:"pill",children:"Default"})}):null]}),t.description.length>0?e.jsx(B,{content:t.description,className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full max-w-full",children:e.jsx("span",{className:"block truncate text-xs text-text-secondary",children:t.description})}):null]})}),e.jsx(P,{children:e.jsx(X,{variant:t.enabled?"success":"outline",shape:"pill",dot:!0,children:t.enabled?"Enabled":"Disabled"})}),e.jsx(P,{onClick:D=>D.stopPropagation(),children:e.jsx(on,{status:t.status,statusReason:t.statusReason})}),e.jsx(P,{className:"text-sm text-text-secondary",children:qe(t.manifest.resources)}),e.jsx(P,{className:"text-sm text-text-secondary",children:Qe(t.manifest.networking)}),e.jsx(P,{className:"text-sm text-text-secondary",children:Ge(t.updatedAt)}),e.jsx(P,{onClick:D=>D.stopPropagation(),children:e.jsxs(He,{align:"end",className:"min-w-48",trigger:e.jsx("button",{type:"button",className:_({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(C,{name:"ellipsis-vertical",className:"size-3.5"})}),children:[e.jsx(V,{label:"Edit",icon:"pencil",reason:x.edit,onClick:()=>r({kind:"edit",environment:t})}),e.jsx(V,{label:"Set as default",icon:"check",reason:x.setDefault,onClick:()=>void ie({change:()=>l.setDefaultEnvironment({name:t.name}),title:`“${t.name}” is now the default`})}),e.jsx(V,{label:t.enabled?"Disable":"Enable",icon:t.enabled?"circle-xmark":"circle-check",reason:x.toggleEnabled,onClick:()=>void ie({change:()=>l.setEnvironmentEnabled({name:t.name,enabled:!t.enabled}),title:t.enabled?"Environment disabled":"Environment enabled"})}),e.jsx(V,{label:"Delete",icon:"trash",className:"text-failure-bg focus-visible:text-failure-bg",reason:x.delete,onClick:()=>g(t)})]})})]},t.id)})})]})}),Ee?e.jsx("div",{className:"shrink-0 border-t border-border",children:e.jsx(Ke,{pageSize:u,rowCount:L.length,canPrev:G!=null,canNext:z!=null,onPrev:()=>A({scope:p,token:G}),onNext:()=>{z!=null&&A({scope:p,token:z})},pageSizeOptions:cn,onPageSizeChange:t=>{b(ge(t))}})}):null]})}),e.jsx(an,{open:v.kind!=="closed",mode:v.kind==="edit"?"edit":"create",...v.kind==="edit"?{environment:v.environment,readOnly:ke}:{},onOpenChange:t=>{t||r({kind:"closed"})},onSaved:()=>{A({scope:p,token:void 0}),U()}}),f!=null?e.jsx(De,{title:"Delete environment",description:e.jsxs(e.Fragment,{children:["Delete ",e.jsx("span",{className:"font-medium text-text-primary",children:f.name}),"? This cannot be undone. Delete fails if any agent still references the environment."]}),confirmLabel:"Delete",onCancel:()=>g(null),onConfirm:()=>void Ce()}):null]})}export{gn as EnvironmentsPage,dn as PENDING_ENVIRONMENTS_POLL_INTERVAL_MS};
|
|
1
|
+
import{C as De}from"./chunk-BNMKM5SY-CiR8M-oi.js";import{B as X}from"./chunk-4QN7ONBR-CtFqtChE.js";import{aH as ve,X as Te,b as Pe,$ as Ne,a0 as je,aI as Me,r as h,aJ as $,Y as me,a2 as Re,x as ye,a1 as Be,aK as J,aL as ue,aM as ee,j as e,a8 as _e,g as M,V as B,ab as F,I as C,P as ze,ad as Z,ac as Le,aN as Oe,ae as Ve,af as Fe,ag as xe,ah as T,ai as Ie,aj as P,aO as qe,aP as Qe,aG as Ge,aw as He,f as _,al as Ke,ar as Ue,ax as Ye,aQ as he,aB as $e,at as W,d as Je,am as Ze,aR as Xe,aS as We,a4 as en}from"./index-C5ROvRRa.js";function pe(n){var l,a,s,i,m,o,d,c;return{name:n.name,description:n.description??"",buildScript:((l=n.image)==null?void 0:l.buildScript)??"",cpu:String(((a=n.resources)==null?void 0:a.cpu)??1),memory:String(((s=n.resources)==null?void 0:s.memory)??1),disk:String(((i=n.resources)==null?void 0:i.disk)??3),networkBlockAll:((m=n.networking)==null?void 0:m.networkBlockAll)===!0,domainAllowList:((o=n.networking)==null?void 0:o.domainAllowList)??"",secrets:((c=(d=n.networking)==null?void 0:d.secrets)==null?void 0:c.map(N=>({...N,hosts:[...N.hosts]})))??[],environmentVariables:Object.entries(n.environmentVariables??{}).map(([N,v])=>({key:N,value:v}))}}function nn(n){const l=Number(n.cpu),a=Number(n.memory),s=Number(n.disk),i=Object.fromEntries(n.environmentVariables.map(o=>[o.key.trim(),o.value]).filter(([o,d])=>o.length>0&&d.length>0)),m=n.networkBlockAll?void 0:n.secrets.map(o=>({env:o.env.trim(),value:o.value,hosts:o.hosts.map(d=>d.trim()).filter(d=>d.length>0)})).filter(o=>o.env.length>0&&o.value.length>0);return{name:n.name.trim(),...n.description.trim().length===0?{}:{description:n.description.trim()},...n.buildScript.trim().length===0?{}:{image:{type:"build",buildScript:n.buildScript}},resources:{cpu:Number.isFinite(l)&&l>0?l:1,memory:Number.isFinite(a)&&a>0?a:1,disk:Number.isFinite(s)&&s>0?s:3},...Object.keys(i).length===0?{}:{environmentVariables:i},networking:n.networkBlockAll?{networkBlockAll:!0}:{networkBlockAll:!1,...n.domainAllowList.trim().length===0?{}:{domainAllowList:n.domainAllowList.trim()},...m==null||m.length===0?{}:{secrets:m}}}}function tn(n){const l=n.name.trim();if(l.length===0)return"Name is required";if(ee(l))return`Name "${We}" is reserved`;const a=Number(n.cpu),s=Number(n.memory),i=Number(n.disk);if(!Number.isFinite(a)||a<=0)return"CPU must be a positive number";if(!Number.isFinite(s)||s<=0)return"Memory must be a positive number";if(!Number.isFinite(i)||i<=0)return"Disk must be a positive number";if(!n.networkBlockAll){for(const m of n.secrets)if(m.env.trim().length!==0&&m.value.trim().length===0)return"Secret value is required"}return null}var w="w-full rounded-md border border-border bg-input-box-bg px-2.5 py-1.5 text-sm text-text-primary placeholder:text-text-secondary/70 outline-none focus:border-primary-button-bg",fe="text-sm font-medium text-text-primary",O="rounded-lg border border-border p-4 flex flex-col gap-4";function sn({values:n,onChange:l,nameDisabled:a,readOnly:s=!1}){const i=Je("MonacoEditorCore"),m=h.useId(),[o,d]=h.useState(!1),c=r=>l({...n,...r}),N={readOnly:s,lineNumbers:"on",renderFinalNewline:"on",tabFocusMode:!o},v=r=>c({buildScript:r});return e.jsxs("fieldset",{disabled:s,className:"m-0 flex min-w-0 flex-col gap-4 border-0 p-0 pb-8",children:[e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:fe,children:"Name"}),e.jsx("input",{className:M(w,a&&"opacity-70"),value:n.name,disabled:a,placeholder:"my-environment",onChange:r=>c({name:r.target.value})})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:fe,children:"Description"}),e.jsx("textarea",{className:M(w,"min-h-20 resize-y"),value:n.description,placeholder:"write description ...",onChange:r=>c({description:r.target.value})})]}),e.jsxs("div",{className:O,children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Image And Resources"}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{id:m,className:"text-xs font-medium text-text-secondary",children:"Build Script"}),e.jsx("button",{type:"button","aria-label":"Edit build script full screen","aria-haspopup":"dialog",title:"Full screen",className:_({variant:"ghost",size:"icon",className:"size-7 shrink-0"}),onClick:()=>d(!0),children:e.jsx(C,{name:"expand",className:"size-4"})})]}),e.jsx("div",{role:"group","aria-labelledby":m,className:"h-36 overflow-hidden rounded-md border border-border bg-input-box-bg",children:o?null:e.jsx(i,{value:n.buildScript,language:"shell",height:"100%",options:N,onChange:v})}),e.jsx(Ze,{open:o,onOpenChange:d,"aria-label":"Edit build script full screen",className:"h-[calc(100dvh-2rem)] max-h-none w-[calc(100vw-2rem)] max-w-none",children:o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border px-4 py-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-primary",children:"Build Script"}),e.jsx(F.Secondary,{type:"button",size:"small",onClick:()=>d(!1),children:"Done"})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(i,{autoFocus:!0,value:n.buildScript,language:"shell",height:"100%",options:N,onChange:v})})]}):null})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"CPU"}),e.jsx("input",{className:w,type:"number",min:.1,step:"any",value:n.cpu,placeholder:"type...",onChange:r=>c({cpu:r.target.value})})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Memory (GB)"}),e.jsx("input",{className:w,type:"number",min:.1,step:"any",value:n.memory,placeholder:"type...",onChange:r=>c({memory:r.target.value})})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Disk (GB)"}),e.jsx("input",{className:w,type:"number",min:.1,step:"any",value:n.disk,placeholder:"type...",onChange:r=>c({disk:r.target.value})})]})]})]}),e.jsxs("div",{className:O,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Environment Variables"}),e.jsx("button",{type:"button",className:"cursor-pointer text-xs font-medium text-text-secondary transition-colors hover:text-text-primary",onClick:()=>c({environmentVariables:[...n.environmentVariables,{key:"",value:""}]}),children:"+ Add Variables"})]}),n.environmentVariables.map((r,f)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("input",{className:w,value:r.key,placeholder:"KEY",onChange:g=>{const u=n.environmentVariables.map((b,p)=>p===f?{...b,key:g.target.value}:b);c({environmentVariables:u})}}),e.jsx("input",{className:w,value:r.value,placeholder:"value",onChange:g=>{const u=n.environmentVariables.map((b,p)=>p===f?{...b,value:g.target.value}:b);c({environmentVariables:u})}})]}),e.jsx("button",{type:"button",className:_({variant:"ghost",size:"icon"}),"aria-label":"Remove environment variable",onClick:()=>c({environmentVariables:n.environmentVariables.filter((g,u)=>u!==f)}),children:e.jsx(C,{name:"trash",className:"size-3.5 text-failure-bg"})})]},f))]}),e.jsxs("div",{className:O,children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-medium text-text-primary",children:"Block All Network"}),e.jsx("span",{className:"text-xs text-text-secondary",children:"Overrides the domain allow list"})]}),e.jsx(Xe,{checked:n.networkBlockAll,onCheckedChange:r=>c({networkBlockAll:r}),"aria-label":"Block All Network"})]}),n.networkBlockAll?null:e.jsxs("label",{className:"flex flex-col gap-1.5 pt-1",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Domain Allow List"}),e.jsx("input",{className:w,value:n.domainAllowList,placeholder:"api.github.com,api.openai.com",onChange:r=>c({domainAllowList:r.target.value})})]})]}),n.networkBlockAll?null:e.jsxs("div",{className:O,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Secrets"}),e.jsxs("span",{className:"text-xs text-text-secondary",children:["Synced immediately with existing sandboxes."," ",e.jsxs("a",{href:"https://trueforge.dev/sandbox#how-changes-reach-a-running-session",target:"_blank",rel:"noreferrer",className:"text-primary-button-bg inline-flex items-center gap-1 hover:underline",children:["Learn more",e.jsx(C,{name:"external-link",className:"size-3"})]})]})]}),e.jsx("button",{type:"button",className:"cursor-pointer text-xs font-medium text-text-secondary transition-colors hover:text-text-primary",onClick:()=>c({secrets:[...n.secrets,{env:"",value:"",hosts:[]}]}),children:"+ Add Secret"})]}),n.secrets.map((r,f)=>e.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-border p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("input",{className:w,value:r.env,placeholder:"ENV_NAME",onChange:g=>{const u=n.secrets.map((b,p)=>p===f?{...b,env:g.target.value}:b);c({secrets:u})}}),e.jsx("input",{className:w,type:"password",value:r.value,placeholder:"value",onChange:g=>{const u=n.secrets.map((b,p)=>p===f?{...b,value:g.target.value}:b);c({secrets:u})}})]}),e.jsx("button",{type:"button",className:_({variant:"ghost",size:"icon"}),"aria-label":"Remove secret",onClick:()=>c({secrets:n.secrets.filter((g,u)=>u!==f)}),children:e.jsx(C,{name:"trash",className:"size-3.5 text-failure-bg"})})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("input",{className:w,value:r.hosts.join(","),placeholder:"api.github.com,api.openai.com",onChange:g=>{const u=g.target.value.split(",").map(p=>p.trim()),b=n.secrets.map((p,j)=>j===f?{...p,hosts:u}:p);c({secrets:b})}}),e.jsx("span",{className:"text-xs text-text-secondary",children:"Hosts allowed to resolve secret (comma-separated)."})]})]},f))]})]})}function an({open:n,onOpenChange:l,mode:a,environment:s,readOnly:i=!1,onSaved:m}){const o=ve(),d=Ne(),c=je(),[N,v]=h.useState(()=>pe(he())),[r,f]=h.useState(!1),[g,u]=h.useState(null);h.useEffect(()=>{if(!n){u(null),f(!1);return}const j=a==="edit"&&s!=null?s.manifest:he();v(pe(j)),u(null)},[n,a,s]);const b=async j=>{j.preventDefault(),u(null);const A=tn(N);if(A!=null){u(A);return}f(!0);try{const E=nn(N),R=a==="create"?await o.createEnvironment({manifest:E}):await o.createOrUpdateEnvironment({manifest:E});c(a==="create"?W.Environment.CREATED:W.Environment.EDITED,{environment_name:R.name,environment_id:R.id}),d==null||d.showSuccess({title:a==="create"?"Environment created":"Environment updated"}),m==null||m(),l(!1)}catch(E){u(ye(E,"Failed to save environment")),d==null||d.showError(E)}finally{f(!1)}},p=a==="create"?"New environment":(s==null?void 0:s.name)??"Edit environment";return e.jsx($e,{open:n,onOpenChange:l,title:p,description:i?"View the environment configuration.":"Configure the environment.",size:"xl",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(F.Secondary,{type:"button",disabled:r,onClick:()=>l(!1),children:i?"Close":"Cancel"}),i?null:e.jsx(F.Primary,{type:"submit",form:"environment-form",disabled:r,children:r?"Saving…":a==="create"?"Create":"Save"})]}),children:e.jsxs("form",{id:"environment-form",className:"flex min-h-0 flex-1 flex-col gap-4 px-5 pt-4 pb-10",onSubmit:j=>void b(j),children:[g!=null?e.jsx("p",{className:"text-sm text-failure-bg",children:g}):null,e.jsx(sn,{values:N,onChange:v,nameDisabled:a==="edit",readOnly:i})]})})}var rn={pending:{label:"Building",variant:"info",icon:"loader"},ready:{label:"Ready",variant:"success",icon:"check"},failed:{label:"Failed",variant:"destructive",icon:"triangle-exclamation"}};function ln({reason:n}){const[l,a]=h.useState(!1),s=h.useCallback(i=>{i.stopPropagation(),navigator.clipboard.writeText(n).then(()=>{a(!0),window.setTimeout(()=>a(!1),1500)},()=>{})},[n]);return e.jsxs("span",{className:"flex max-w-md items-start gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 text-left break-words whitespace-pre-wrap",children:n}),e.jsx("button",{type:"button","aria-label":l?"Copied":"Copy failure message",title:l?"Copied":"Copy",className:_({variant:"ghost",size:"icon",className:"size-6 shrink-0"}),onClick:s,children:e.jsx(C,{name:l?"check":"copy",size:"0.875rem"})})]})}function on({status:n,statusReason:l}){const a=rn[n],s=e.jsxs(X,{variant:a.variant,shape:"rounded",size:"sm",children:[e.jsx(C,{name:a.icon,className:a.icon==="loader"?"size-3.5 shrink-0 animate-spin":"size-3.5 shrink-0"}),a.label]});return n==="failed"&&l!=null&&l.length>0?e.jsx(B,{content:e.jsx(ln,{reason:l}),className:"max-w-md whitespace-normal",dismissOnClick:!1,children:s}):s}var cn=[10,25],dn=1e4,mn=[];function ge(n){return Math.min(Math.max(n,1),25)}function be(n){return n===void 0||n===""?void 0:n}function un({environment:n,canManage:l,canDelete:a,canSetDefault:s}){const i=l?void 0:"You do not have permission to manage this environment.",m=ee(n.name);return{edit:m?"This environment is provided by the platform and cannot be edited.":i,setDefault:i??(s?n.isDefault?"Already the default.":n.enabled?n.status!=="ready"?"Only a ready environment can be the default.":void 0:"Enable the environment before making it the default.":"Only admins can choose the default environment."),toggleEnabled:i??(n.isDefault&&n.enabled?"The default environment cannot be disabled. Make another one the default first.":void 0),delete:m?"This environment is provided by the platform and cannot be deleted.":n.isDefault?"The default environment cannot be deleted. Make another one the default first.":a?void 0:"You do not have permission to delete this environment."}}function V({label:n,icon:l,reason:a,className:s,onClick:i}){const m=e.jsxs(Ye,{className:M("whitespace-nowrap",s),disabled:a!==void 0,onClick:i,children:[e.jsx(C,{name:l,className:"size-3.5"}),n]});return a===void 0?m:e.jsx(B,{content:a,side:"left",className:"max-w-xs whitespace-normal text-left",interactive:!1,children:e.jsx("span",{className:"block w-full",children:m})})}function gn({embedded:n=!1}){var le,oe,ce;const l=ve(),a=Te(),s=Pe(),i=Ne(),m=je(),{canCreateSandboxEnvironment:o,loading:d}=Me(),[c,N]=h.useState(()=>$(window.location.search).q??""),[v,r]=h.useState({kind:"closed"}),[f,g]=h.useState(null),[u,b]=h.useState(()=>ge(Ue)),p=JSON.stringify([u]),[j,A]=h.useState(()=>({scope:p,token:void 0}));j.scope!==p&&A({scope:p,token:void 0});const E=j.scope===p?j.token:void 0,R=h.useRef(!1),ne=h.useRef((s==null?void 0:s.settingsOpen)??!1),I=(s==null?void 0:s.settingsOpen)??!1,q=h.useMemo(()=>({limit:u,...E===void 0?{}:{pageToken:E}}),[u,E]),Q=h.useMemo(()=>me.environments.list(q),[q]),S=Re({queryKey:Q,queryFn:()=>l.listEnvironments(q),placeholderData:en},a),y=((le=S.data)==null?void 0:le.data)??mn,te=!S.isPlaceholderData,z=te?be((oe=S.data)==null?void 0:oe.nextPageToken):void 0,G=te?be((ce=S.data)==null?void 0:ce.previousPageToken):void 0,we=S.isPending||S.isPlaceholderData,H=S.error!=null&&y.length===0?ye(S.error,"Check your connection and try again."):null,{refetch:se}=S,{allows:K}=Be({resourceType:"sandbox_environment",resourceIds:y.map(t=>t.id)}),U=h.useCallback(()=>{a.invalidateQueries({queryKey:me.environments.all()}),s==null||s.invalidateEnvironmentsList()},[a,s]);h.useEffect(()=>{J({q:c.trim().length===0?null:c})},[c]),h.useEffect(()=>{ne.current&&!I&&se(),ne.current=I},[I,se]),h.useEffect(()=>{const t=y.filter(D=>D.status==="pending");if(t.length===0)return;const x=window.setInterval(async()=>{try{const Y=(await Promise.all(t.map(k=>l.getEnvironment({name:k.name}).catch(()=>null)))).filter(k=>k!=null);if(Y.length===0)return;a.setQueryData(Q,k=>k==null?k:{...k,data:k.data.map(de=>Y.find(Ae=>Ae.name===de.name)??de)}),Y.some(k=>k.status!=="pending")&&(s==null||s.invalidateEnvironmentsList())}catch{}},dn);return()=>window.clearInterval(x)},[y,l,Q,a,s]),h.useEffect(()=>{if(d)return;const t=$(window.location.search);if(!R.current&&t.isNew){R.current=!0,J({isNew:null}),r(o?{kind:"create"}:x=>x.kind==="create"?{kind:"closed"}:x);return}o||r(x=>x.kind==="create"?{kind:"closed"}:x)},[o,d]),h.useEffect(()=>{const t=()=>{const x=$(window.location.search);N(x.q??""),x.isNew&&(d||(J({isNew:null}),o&&r({kind:"create"})))};return window.addEventListener(ue,t),()=>window.removeEventListener(ue,t)},[o,d]);const L=h.useMemo(()=>{const t=c.trim().toLowerCase();return t.length===0?y:y.filter(x=>x.name.toLowerCase().includes(t)||x.description.toLowerCase().includes(t))},[y,c]),ke=v.kind==="edit"&&(ee(v.environment.name)||!K(v.environment.id,"MANAGE")),Ee=z!=null||G!=null||y.length>0,ae=we&&y.length===0,Se=()=>{o&&r({kind:"create"})},Ce=async()=>{if(f==null)return;const t=f;g(null);try{await l.deleteEnvironment({name:t.name}),m(W.Environment.DELETED,{environment_name:t.name,environment_id:t.id}),i==null||i.showSuccess({title:"Environment deleted"}),A({scope:p,token:void 0}),U()}catch(x){i==null||i.showError(x)}},ie=async({change:t,title:x})=>{try{await t(),i==null||i.showSuccess({title:x}),U()}catch(D){i==null||i.showError(D)}},re=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:M(n?"min-w-0 flex-1 sm:max-w-64":"w-64"),children:e.jsx(_e,{query:c,setQuery:N,placeholder:"Search environments by name"})}),e.jsx(B,{content:o||d?void 0:"Only admins can create sandbox environments",children:e.jsx("span",{className:"inline-flex shrink-0",children:e.jsxs(F.Primary,{type:"button",onClick:Se,disabled:!o,children:[e.jsx(C,{name:"plus",className:"size-3.5"}),"New Environment"]})})})]});return e.jsxs("div",{className:M("flex h-full min-h-0 flex-col",n?"bg-transparent":"bg-primary-bg"),children:[n?e.jsxs("div",{className:"flex shrink-0 flex-col gap-3 border-b border-border px-4 py-4 sm:flex-row sm:items-start sm:justify-between sm:px-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Environments"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Customize sandbox images, resources, and networking for agent runs."})]}),e.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:re})]}):e.jsx(ze,{title:"Environments",end:re}),e.jsx("div",{className:M("flex min-h-0 flex-1 flex-col px-4 py-4",n&&"sm:px-6",(H!=null||ae||y.length===0||L.length===0)&&"overflow-auto"),children:H!=null?e.jsx("div",{role:"alert",className:"flex flex-1 flex-col items-center justify-center",children:e.jsx(Z,{title:"Couldn't load environments",description:H,className:"h-auto min-h-0 flex-none py-0"})}):ae?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading environments",children:Array.from({length:5},(t,x)=>e.jsx(Le,{className:"h-12 w-full rounded-md"},x))}):y.length===0?e.jsx(Z,{title:"No environments yet",description:"Create an environment to customize sandbox images, resources, and networking.",className:"min-h-full"}):L.length===0?e.jsx(Z,{title:"No environments found",description:e.jsxs(e.Fragment,{children:["No environments match ",e.jsx(Oe,{children:c.trim()}),"."]}),className:"min-h-full"}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-border",children:[e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsxs(Ve,{className:"min-w-240 bg-card-bg",children:[e.jsx(Fe,{children:e.jsxs(xe,{className:"hover:bg-transparent",children:[e.jsx(T,{className:"w-[15.6rem] max-w-[15.6rem]",children:"Name"}),e.jsx(T,{children:"Availability"}),e.jsx(T,{children:"Build Status"}),e.jsx(T,{children:"Resources"}),e.jsx(T,{children:"Networking"}),e.jsx(T,{children:"Updated"}),e.jsx(T,{className:"w-16"})]})}),e.jsx(Ie,{children:L.map(t=>{const x=un({environment:t,canManage:K(t.id,"MANAGE"),canDelete:K(t.id,"DELETE"),canSetDefault:o});return e.jsxs(xe,{className:"cursor-pointer",onClick:()=>r({kind:"edit",environment:t}),children:[e.jsx(P,{className:"w-[15.6rem] max-w-[15.6rem]",children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:t.name}),t.isDefault?e.jsx(B,{content:"Agents that do not pick an environment run in this one.",className:"max-w-xs whitespace-normal text-left",triggerClassName:"shrink-0",children:e.jsx(X,{variant:"info",shape:"pill",children:"Default"})}):null]}),t.description.length>0?e.jsx(B,{content:t.description,className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full max-w-full",children:e.jsx("span",{className:"block truncate text-xs text-text-secondary",children:t.description})}):null]})}),e.jsx(P,{children:e.jsx(X,{variant:t.enabled?"success":"outline",shape:"pill",dot:!0,children:t.enabled?"Enabled":"Disabled"})}),e.jsx(P,{onClick:D=>D.stopPropagation(),children:e.jsx(on,{status:t.status,statusReason:t.statusReason})}),e.jsx(P,{className:"text-sm text-text-secondary",children:qe(t.manifest.resources)}),e.jsx(P,{className:"text-sm text-text-secondary",children:Qe(t.manifest.networking)}),e.jsx(P,{className:"text-sm text-text-secondary",children:Ge(t.updatedAt)}),e.jsx(P,{onClick:D=>D.stopPropagation(),children:e.jsxs(He,{align:"end",className:"min-w-48",trigger:e.jsx("button",{type:"button",className:_({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(C,{name:"ellipsis-vertical",className:"size-3.5"})}),children:[e.jsx(V,{label:"Edit",icon:"pencil",reason:x.edit,onClick:()=>r({kind:"edit",environment:t})}),e.jsx(V,{label:"Set as default",icon:"check",reason:x.setDefault,onClick:()=>void ie({change:()=>l.setDefaultEnvironment({name:t.name}),title:`“${t.name}” is now the default`})}),e.jsx(V,{label:t.enabled?"Disable":"Enable",icon:t.enabled?"circle-xmark":"circle-check",reason:x.toggleEnabled,onClick:()=>void ie({change:()=>l.setEnvironmentEnabled({name:t.name,enabled:!t.enabled}),title:t.enabled?"Environment disabled":"Environment enabled"})}),e.jsx(V,{label:"Delete",icon:"trash",className:"text-failure-bg focus-visible:text-failure-bg",reason:x.delete,onClick:()=>g(t)})]})})]},t.id)})})]})}),Ee?e.jsx("div",{className:"shrink-0 border-t border-border",children:e.jsx(Ke,{pageSize:u,rowCount:L.length,canPrev:G!=null,canNext:z!=null,onPrev:()=>A({scope:p,token:G}),onNext:()=>{z!=null&&A({scope:p,token:z})},pageSizeOptions:cn,onPageSizeChange:t=>{b(ge(t))}})}):null]})}),e.jsx(an,{open:v.kind!=="closed",mode:v.kind==="edit"?"edit":"create",...v.kind==="edit"?{environment:v.environment,readOnly:ke}:{},onOpenChange:t=>{t||r({kind:"closed"})},onSaved:()=>{A({scope:p,token:void 0}),U()}}),f!=null?e.jsx(De,{title:"Delete environment",description:e.jsxs(e.Fragment,{children:["Delete ",e.jsx("span",{className:"font-medium text-text-primary",children:f.name}),"? This cannot be undone. Delete fails if any agent still references the environment."]}),confirmLabel:"Delete",onCancel:()=>g(null),onConfirm:()=>void Ce()}):null]})}export{gn as EnvironmentsPage,dn as PENDING_ENVIRONMENTS_POLL_INTERVAL_MS};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as ne,q as le,t as oe,bI as ie,bH as de,X as ce,$ as me,a0 as ue,a2 as $,Y as j,r as d,x as S,j as e,ac as G,aR as xe,I as R,ab as F,at as O,bY as ye,aE as ge}from"./index-
|
|
1
|
+
import{l as ne,q as le,t as oe,bI as ie,bH as de,X as ce,$ as me,a0 as ue,a2 as $,Y as j,r as d,x as S,j as e,ac as G,aR as xe,I as R,ab as F,at as O,bY as ye,aE as ge}from"./index-C5ROvRRa.js";var Z=ge("h-11 shadow-sm"),pe=({open:p,onOpenChange:h,onSave:k,title:x,description:l,initialServerUrl:o="",requireApiKey:s=!0,busy:b=!1,error:E})=>{const[t,y]=d.useState(""),[g,c]=d.useState(o);d.useEffect(()=>{p&&(y(""),c(o))},[p,o]);const N=i=>{i||(y(""),c(o)),h(i)},m=t.trim(),f=!s||!!m,P=async i=>{if(i.preventDefault(),!(!f||b))try{await k({apiKey:m,serverUrl:g.trim()}),h(!1)}catch{}};return e.jsx(ye,{open:p,onOpenChange:N,title:x,description:l,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(R,{name:"brain",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:P,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"memory-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",s?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"memory-provider-api-key",type:"password",required:s,value:t,onChange:i=>{y(i.target.value)},placeholder:s?"Zep API key":"Leave blank to keep existing",autoFocus:!0,className:Z})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"memory-provider-server-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Server URL ",e.jsx("span",{className:"font-normal text-text-secondary",children:"(optional)"})]}),e.jsx("input",{id:"memory-provider-server-url",type:"url",value:g,onChange:i=>{c(i.target.value)},placeholder:"Leave blank for Zep Cloud",className:Z})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[E?e.jsx("p",{className:"text-failure-bg text-sm",children:E}):null,e.jsx(F.Primary,{type:"submit",size:"large",disabled:!f||b,className:"w-full shrink-0",children:"Save"})]})]})})},he=pe,be=[],fe=[],ve=()=>{var D,Q,Y,B,V;const p=ne(),h=(D=le())==null?void 0:D.settings,k=oe(),x=ie(),l=de(),o=ce(),s=me(),b=ue(),t=k&&((Q=h==null?void 0:h.memoryProviders)==null?void 0:Q.manageProviders)!==!1?p==null?void 0:p.memoryCatalog:void 0,y=$({queryKey:j.settings.configuration(),queryFn:()=>l==null?Promise.reject(new Error("Configuration server is not configured.")):l.getConfiguration(),enabled:l!=null},o),g=$({queryKey:j.settings.memoryProviders(),queryFn:async()=>{if(t==null)throw new Error("Memory catalog is not configured.");const[r,a]=await Promise.all([t.listMemoryProviders(),t.getMemoryProviderCatalog()]);return{providers:r,catalog:a}},enabled:t!=null},o),c=((Y=y.data)==null?void 0:Y.memory.enabled)??null,N=l!=null&&y.isPending,m=((B=g.data)==null?void 0:B.providers)??be,f=((V=g.data)==null?void 0:V.catalog)??fe,P=g.isPending,[i,T]=d.useState(!1),[H,K]=d.useState(null),[X,v]=d.useState(null),[M,_]=d.useState(!1),[u,w]=d.useState(null),[n,C]=d.useState(null),J=y.isError?S(y.error,"Failed to load the memory setting"):g.isError?S(g.error,"Failed to load memory providers"):null,U=m.length>0,A=d.useMemo(()=>{if(U)return[];const r=new Set(m.map(a=>a.catalogId));return f.filter(a=>!r.has(a.id))},[f,m,U]);if(t==null&&l==null)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Memory settings are not available."});const W=async r=>{if(l){T(!0),K(null);try{const a=await l.updateConfiguration({memory:{enabled:r}});await o.cancelQueries({queryKey:j.settings.configuration()}),o.setQueryData(j.settings.configuration(),a),x==null||x(),s==null||s.showSuccess({title:a.memory.enabled?"Memory turned on":"Memory turned off"}),b(O.Settings.MEMORY_TENANT_TOGGLED,{enabled:a.memory.enabled})}catch(a){K(S(a,"Failed to save the memory setting"))}finally{T(!1)}}},z=async r=>{_(!0),v(null);try{await r(),await o.invalidateQueries({queryKey:j.settings.memoryProviders()}),x==null||x()}catch(a){throw v(S(a,"Request failed")),a}finally{_(!1)}},ee=async r=>{!u||!t||(await z(async()=>{await t.createMemoryProvider({catalogId:u.id,name:u.name,type:u.type,apiKey:r.apiKey,...r.serverUrl===""?{}:{serverUrl:r.serverUrl}})}),w(null),s==null||s.showSuccess({title:`${u.name} configured`}),b(O.Settings.MEMORY_PROVIDER_SAVED,{provider_name:u.name,mode:"create"}))},re=async r=>{!n||!t||(await z(async()=>{await t.updateMemoryProvider({id:n.id,...r.apiKey===""?{}:{apiKey:r.apiKey},...r.serverUrl===""?{}:{serverUrl:r.serverUrl}})}),C(null),s==null||s.showSuccess({title:`${n.name} updated`}),b(O.Settings.MEMORY_PROVIDER_SAVED,{provider_name:n.name,mode:"update"}))},se=l==null||c!==null,q=t!=null&&se&&c!==!1,L=H??J,te=u!=null||n!=null,I=n!=null,ae=n?`Update ${n.name}`:u?`Configure ${u.name}`:"Configure memory provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Memory"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Let TrueForge personalize your conversations based on your past chats."}),L?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:L}):null,N?e.jsx(G,{className:"mt-4 h-16 w-full rounded-xl bg-gray-150 dark:bg-secondary-bg",role:"status","aria-label":"Loading memory"}):null,c!==null?e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4 rounded-xl border border-border bg-card-bg p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Allow memory"}),e.jsx("p",{className:"mt-0.5 text-xs text-text-secondary",children:c?"Agents may remember details from past chats.":"Agents cannot use memory, including in chats that already had it."})]}),e.jsx(xe,{checked:c,disabled:i,"aria-label":"Allow memory",onCheckedChange:r=>{W(r)}})]}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:t!=null&&(N||q&&P)?e.jsx(G,{className:"h-16 w-full rounded-xl bg-gray-150 dark:bg-secondary-bg",role:"status","aria-label":"Loading memory providers"}):q?e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:"Configure a provider so agents can remember details. Only one can be active at a time."}),m.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",m.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:m.map(r=>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(R,{name:"brain",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:r.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:r.serverUrl??"Zep Cloud"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm font-medium text-success-bg",children:[e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}),"Connected"]}),e.jsx(F.Secondary,{size:"small",type:"button",disabled:M,onClick:()=>{v(null),w(null),C(r)},children:"Update"})]})]},r.id))})]}):null,U?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",A.length]}),A.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:"No memory providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:A.map(r=>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(R,{name:"brain",className:"size-4.5"})}),e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:r.name})]}),e.jsx(F.Secondary,{type:"button",disabled:M,onClick:()=>{v(null),C(null),w(r)},children:"Configure"})]},r.id))})]})]}):null}),e.jsx(he,{open:te,onOpenChange:r=>{r||(v(null),w(null),C(null))},onSave:I?re:ee,title:ae,description:I?"Update this memory provider. Leave API key blank to keep the existing key.":"Configure this memory provider. API key is never stored in the catalog.",initialServerUrl:(n==null?void 0:n.serverUrl)??"",requireApiKey:!I,busy:M,error:X})]})},Ne=ve;export{Ne as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as Xe}from"./chunk-XOQYBULH-CRvLiR9N.js";import{bV as We,q as Ye,t as Je,$ as Te,a0 as Re,r as o,x as Q,j as e,a8 as Ze,ab as G,I as U,bW as Se,g as k,bH as Ve,bI as et,X as Le,a2 as Oe,Y as ye,bX as tt,at as ae,ac as De,aR as st,bY as _e,bZ as rt,b_ as at,b$ as nt,c0 as xe,c1 as $e,k as ot,c2 as lt,c3 as it,c4 as Ee,c5 as je,c6 as Ie,c7 as Ue,aE as ze,J as dt,c8 as ct,c9 as ut,ca as mt,cb as xt,V as pt,cc as bt}from"./index-DdfF63OT.js";var Fe={gridTemplateColumns:`minmax(0,1fr) repeat(${xe.length},4.5rem)`};function ht(s){const r=s.properties.autoRouting;return(r==null?void 0:r.supported)===!0?null:{title:"Not available for auto routing",text:(r==null?void 0:r.unsupportedReason)??"Auto routing support is not reported for this model."}}function ft(s){var r;return((r=s.properties.autoRouting)==null?void 0:r.supported)===!0}function gt(s,r){return s.name.localeCompare(r.name)}function vt(s){return[!0,!1].flatMap(r=>mt(s.filter(x=>ft(x)===r)).sort(gt).map(x=>({...x,key:`${r?"supported":"unsupported"}:${x.name}`,models:[...x.models].sort((l,b)=>l.id.localeCompare(b.id))})))}var Be=o.memo(({model:s,checked:r,limitBlock:x,onToggle:l})=>{const b=s.properties.autoRouting,h=ht(s),c=r?null:h??x,d=(b==null?void 0:b.supported)===!0?b.categories:[],p=e.jsxs("button",{type:"button",role:"option","aria-selected":r,"aria-label":s.id,"aria-disabled":c!=null||void 0,className:k("grid w-full items-center px-3.5 text-left text-sm text-text-primary focus-visible:bg-ghost-button-hover focus-visible:outline-none",c==null?"cursor-pointer hover:bg-ghost-button-hover":"cursor-not-allowed opacity-50"),style:Fe,onClick:()=>{c==null&&l(s.name)},children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(xt,{checked:r,className:"size-4.5 rounded-[0.3125rem]"}),e.jsx("span",{className:"truncate",children:s.id})]}),h==null?e.jsx(Ue,{categories:d,className:"h-11"}):e.jsx("span",{className:"h-11 content-center justify-self-center",style:{gridColumn:`2 / span ${String(xe.length)}`},children:e.jsx("span",{className:"rounded-full border border-text-secondary/30 px-2 py-px text-xs text-text-secondary",children:"Not supported"})})]});return c==null?p:e.jsx(pt,{side:"right",interactive:!1,triggerClassName:"block w-full",className:"w-[16.25rem] whitespace-normal rounded-lg bg-text-primary px-3 py-2.5 text-[0.8125rem] leading-[1.1875rem] text-primary-bg shadow-lg",content:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block font-semibold",children:c.title}),e.jsx("span",{className:"block",children:c.text})]}),children:e.jsx("span",{className:"block w-full",children:p})})});Be.displayName="AutoModelPickerOption";var yt=({listboxId:s,models:r,selected:x,limitBlock:l,onToggle:b})=>{const[h,c]=o.useState(""),d=ct(h),p=o.useMemo(()=>vt(d?r.filter(S=>ut({model:S,needle:d})):r),[r,d]);return e.jsxs("div",{className:"aui-popup-enter absolute left-0 top-full z-50 mt-2 flex max-h-[24.5rem] w-[40rem] max-w-[calc(100vw-3rem)] flex-col overflow-hidden rounded-lg border border-border bg-card-bg text-text-primary shadow-lg",children:[e.jsx("div",{className:"border-b border-border p-2.5",children:e.jsx("input",{type:"search",value:h,onChange:S=>c(S.target.value),placeholder:"Search models","aria-label":"Search models",className:ze("h-9"),autoFocus:!0})}),e.jsxs("div",{className:"grid items-center border-b border-border px-3.5 py-2 text-[0.6875rem] uppercase tracking-[0.08em]",style:Fe,children:[e.jsx("div",{}),e.jsx(Ie,{})]}),e.jsxs("div",{id:s,role:"listbox","aria-multiselectable":!0,"aria-label":"Models Auto can choose from",className:"min-h-0 flex-1 overflow-y-auto py-1.5",children:[p.map((S,g)=>{const M=`${s}-provider-${String(g)}`;return e.jsxs("div",{role:"group","aria-labelledby":M,children:[e.jsx("div",{id:M,className:"truncate px-3.5 pb-1 pt-2.5 text-[0.6875rem] uppercase tracking-[0.08em] text-text-secondary",children:S.name}),S.models.map(m=>e.jsx(Be,{model:m,checked:x.has(m.name),limitBlock:l,onToggle:b},m.name))]},S.key)}),p.length===0?e.jsx("p",{className:"px-3.5 py-3.5 text-[0.8125rem] text-text-secondary",children:r.length===0?"No models are available to select.":"No models match."}):null]})]})},jt=yt,ge="grid items-center px-6",ve={gridTemplateColumns:`minmax(0,1fr) repeat(${xe.length},minmax(0,7rem)) 2.5rem`};function Nt({left:s,right:r}){return s.length===r.length&&s.every(x=>r.includes(x))}function wt({name:s,model:r,listingKnown:x}){if(r===void 0)return{name:s,label:dt(s),categories:[],problem:x?"Not visible to you":null};const l=r.properties.autoRouting;return{name:s,label:r.id,categories:(l==null?void 0:l.supported)===!0?l.categories:[],problem:(l==null?void 0:l.supported)===!0?null:"Not available for auto routing"}}function Ct(s){return s.map($e).join(", ")}function kt({selectedCount:s,gaps:r,hasProblem:x,dirty:l,belowMinimum:b}){if(s===0)return{text:`No models selected.${l?` Pick at least ${String(je)} to update.`:" With none selected, Auto stays unavailable."}`,warning:!1};if(r.length>0){const h=r.length>1;return{text:`${Ct(r)} ${h?"have":"has"} no model. Add a model that covers ${h?"them":"it"}.`,warning:!0}}return x&&l?{text:"Remove the flagged models to update.",warning:!1}:b&&l?{text:`Pick at least ${String(je)} to update.`,warning:!1}:{text:"",warning:!1}}var St=({candidateModels:s,saving:r,onSave:x})=>{const l=ot(),b=Le(),h=o.useId(),c=o.useRef(null),d=o.useRef(null),[p,S]=o.useState(s),[g,M]=o.useState(!1),m=Oe({queryKey:ye.catalog.models(),queryFn:()=>l==null?Promise.reject(new Error("Server is not configured.")):l.getModels(),enabled:l!=null},b),O=o.useMemo(()=>m.data??[],[m.data]),y=o.useMemo(()=>new Map(O.map(u=>[u.name,u])),[O]),w=m.isSuccess,D=o.useMemo(()=>p.map(u=>wt({name:u,model:y.get(u),listingKnown:w})),[p,y,w]),_=o.useMemo(()=>lt(D.map(u=>u.categories)),[D]),Y=w?it(_):[],P=D.some(u=>u.problem!==null),T=o.useMemo(()=>new Set(p),[p]),z=o.useMemo(()=>!Nt({left:p,right:s}),[p,s]),f=p.length>=Ee,F=p.length<je,J=kt({selectedCount:p.length,gaps:Y,hasProblem:P,dirty:z,belowMinimum:F}),H=!r&&!F&&!P&&Y.length===0,Z=o.useMemo(()=>f?{title:"Model limit reached",text:`Auto can use at most ${String(Ee)} models. Remove one to add another.`}:null,[f]),R=o.useCallback(u=>S(N=>N.includes(u)?N.filter(E=>E!==u):[...N,u]),[]),X=o.useCallback(()=>M(!1),[]);o.useEffect(()=>{if(!g)return;const u=N=>{var E;N.target instanceof Node&&((E=d.current)!=null&&E.contains(N.target))||X()};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[g,X]);const V=o.useCallback(u=>{var N;u.key!=="Escape"||!g||(u.stopPropagation(),X(),(N=c.current)==null||N.focus())},[g,X]),A=o.useCallback(()=>x(p),[x,p]);return m.isPending?e.jsx("div",{className:"border-t border-border p-6",children:e.jsx(De,{"data-testid":"auto-model-candidate-list-skeleton",className:"h-24 w-full rounded-md"})}):e.jsxs("div",{className:"border-t border-border",onKeyDown:V,children:[e.jsxs("div",{className:k(ge,"pb-2 pt-4 text-xs uppercase tracking-[0.08em]"),style:ve,children:[e.jsx("div",{className:"text-text-secondary",children:"Model"}),e.jsx(Ie,{}),e.jsx("div",{})]}),D.length===0?e.jsx("p",{className:"border-t border-border px-6 py-5 text-[0.8125rem] text-text-secondary",children:"Add the models Auto may route to."}):null,D.map(u=>e.jsxs("div",{className:k(ge,"min-h-16 border-t border-border"),style:ve,children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("div",{className:"truncate text-[0.9375rem] font-medium text-text-primary",children:u.label}),u.problem!==null?e.jsx("div",{className:"truncate text-[0.8125rem] text-failure-bg",children:u.problem}):null]}),e.jsx(Ue,{categories:u.categories,className:"h-16"}),e.jsx("button",{type:"button","aria-label":`Remove ${u.name}`,disabled:r,className:"inline-flex size-7 items-center justify-center justify-self-end rounded-md text-text-secondary hover:bg-ghost-button-hover hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring disabled:opacity-50",onClick:()=>R(u.name),children:e.jsx(U,{name:"xmark",size:"0.75rem"})})]},u.name)),w?e.jsxs("div",{className:k(ge,"min-h-12 border-t border-border bg-black/10 text-[0.8125rem]"),style:ve,children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.08em] text-text-secondary",children:"Coverage"}),xe.map((u,N)=>{const E=_[N]??0;return e.jsx("div",{className:k("text-center",E>0?"text-text-secondary":"text-warning-bg"),children:E>0?`${String(E)} model${E>1?"s":""}`:"No model"},u)}),e.jsx("div",{})]}):null,m.isError?e.jsx("p",{className:"border-t border-border px-6 py-3 text-xs text-failure-bg",children:Q(m.error,"Failed to load models")}):null,e.jsxs("div",{className:"flex items-center justify-between gap-4 border-t border-border px-6 py-3.5",children:[e.jsxs("div",{ref:d,className:"relative",children:[e.jsxs(G.Secondary,{ref:c,size:"small",type:"button","aria-haspopup":"listbox","aria-expanded":g,"aria-controls":g?h:void 0,disabled:r,onClick:()=>M(u=>!u),children:[e.jsx(U,{name:"plus"}),"Add models"]}),g?e.jsx(jt,{listboxId:h,models:O,selected:T,limitBlock:Z,onToggle:R}):null]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-3",children:[e.jsx("p",{role:"status",className:k("text-right text-[0.8125rem]",J.warning?"text-warning-bg":"text-text-secondary"),children:J.text}),z?e.jsx(G.Primary,{size:"small",type:"button",disabled:!H,onClick:A,children:"Update"}):null]})]})]})},Et=St,Mt=new Intl.ListFormat("en",{type:"disjunction"}).format(xe.map($e)),Pt=()=>{var M;const s=Ve(),r=et(),x=Le(),l=Te(),b=Re(),h=Oe({queryKey:ye.settings.configuration(),queryFn:()=>s==null?Promise.reject(new Error("Configuration server is not configured.")):s.getConfiguration(),enabled:s!=null},x),c=tt({mutationFn:m=>s==null?Promise.reject(new Error("Configuration server is not configured.")):s.updateConfiguration({autoModelRouting:m}),onSuccess:(m,O)=>{x.setQueryData(ye.settings.configuration(),m),r==null||r();const{enabled:y,candidateModels:w}=m.autoModelRouting;O.candidateModels===void 0?(l==null||l.showSuccess({title:y?"Auto model routing turned on":"Auto model routing turned off"}),b(ae.Settings.AUTO_MODE_TENANT_TOGGLED,{enabled:y})):(l==null||l.showSuccess({title:"Models updated"}),b(ae.Settings.AUTO_MODE_CANDIDATE_MODELS_SAVED,{model_count:w.length}))}},x);if(!s)return null;const d=c.isError?Q(c.error,"Failed to save the Auto mode setting"):h.isError?Q(h.error,"Failed to load the Auto mode setting"):null,p=(M=h.data)==null?void 0:M.autoModelRouting,g=(c.isPending?c.variables.enabled:void 0)??(p==null?void 0:p.enabled);return e.jsxs(e.Fragment,{children:[d?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:d}):null,h.isPending?e.jsx(De,{"data-testid":"auto-mode-setting-skeleton",className:"mt-4 h-16 w-full rounded-xl"}):null,g!==void 0?e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"rounded-xl border border-border bg-card-bg",children:[e.jsxs("div",{className:"flex items-start justify-between gap-6 p-6",children:[e.jsxs("div",{className:"flex min-w-0 max-w-[42.5rem] flex-col gap-1.5",children:[e.jsx("h4",{className:"text-lg font-semibold text-text-primary",children:"Auto model routing"}),e.jsx("p",{className:"text-pretty text-sm leading-[1.375rem] text-text-secondary",children:g?`Each task is matched to a tier: ${Mt}. Auto picks a suitable model from the ones you select, so include at least one for every tier.`:"Intelligently picks a suitable model for each task."})]}),e.jsx(st,{size:"md",checked:g,disabled:c.isPending,className:"disabled:opacity-100","aria-label":"Auto model routing",onCheckedChange:m=>{c.mutate({enabled:m})}})]}),g&&p?e.jsx(Et,{candidateModels:p.candidateModels,saving:c.isPending,onSave:m=>{c.mutate({candidateModels:m})}},JSON.stringify(p.candidateModels)):null]})}):null]})},Me=Pt,Pe=ze("h-11 shadow-sm"),At=({open:s,onOpenChange:r,onSave:x,title:l,description:b,initialBaseUrl:h="",baseUrlPlaceholder:c="https://api.openai.com/v1",requireApiKey:d=!0,submitLabel:p="Save",busy:S=!1,error:g})=>{const[M,m]=o.useState(""),[O,y]=o.useState(""),[w,D]=o.useState(!1),_=()=>{m(""),y(""),D(!1)};o.useEffect(()=>{s&&(m(""),y(h),D(!1))},[s,h]);const Y=f=>{f||_(),r(f)},P=M.trim(),T=!d||!!P,z=async f=>{if(f.preventDefault(),!(!T||S))try{await x({apiKey:P,baseUrl:O.trim()}),_(),r(!1)}catch{}};return e.jsx(_e,{open:s,onOpenChange:Y,title:l,description:b,contentSized:!0,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:"model-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",d?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"model-provider-api-key",type:"password",required:d,value:M,onChange:f=>{m(f.target.value)},placeholder:d?"Enter API key":"Enter a new key",autoFocus:!0,className:Pe}),d?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(rt,{expanded:w,onChange:(f,F)=>D(F),className:"rounded-md border border-border",children:[e.jsx(at,{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(U,{name:"chevron-down",className:k("size-4 shrink-0 text-text-secondary transition-transform duration-200",w?"rotate-0":"-rotate-90")})]})}),e.jsxs(nt,{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:O,onChange:f=>{y(f.target.value)},placeholder:c,className:Pe}),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:[g?e.jsx("p",{className:"text-failure-bg text-sm",children:g}):null,e.jsx(G.Primary,{type:"submit",size:"large",disabled:!T||S,className:"w-full shrink-0",children:p})]})]})})},Tt=At,Rt="128000",Lt="4096",Ke=()=>({id:"",name:"",advancedExpanded:!0,contextLength:"",maxOutputTokens:""}),Ae=s=>(s==null?void 0:s.models.map(r=>{var x,l,b,h,c;return{id:r.id,name:r.name,advancedExpanded:!0,reasoningEfforts:(x=r.properties)==null?void 0:x.reasoningEfforts,contextLength:((b=(l=r.properties)==null?void 0:l.contextLength)==null?void 0:b.toString())??"",maxOutputTokens:((c=(h=r.properties)==null?void 0:h.maxOutputTokens)==null?void 0:c.toString())??"",nameDirty:!0}}))??[Ke()],re="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",oe="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function he(s){const r=s.trim();if(r==="")return null;const x=Number(r);return Number.isInteger(x)&&x>0?x:null}function Ot(s){return s.replace(/([a-zA-Z])(\d)/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").slice(0,64).replace(/-+$/g,"")}var ue=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),le=({children:s})=>e.jsx("p",{className:"mt-1 text-xs text-failure-bg",children:s}),me=({children:s})=>e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:s}),Dt=({open:s,onOpenChange:r,onSubmit:x,reasoningEffortOptions:l,busy:b=!1,error:h,isEditMode:c=!1,initialValues:d})=>{const[p,S]=o.useState((d==null?void 0:d.name)??""),[g,M]=o.useState((d==null?void 0:d.baseUrl)??""),[m,O]=o.useState(""),[y,w]=o.useState(()=>Ae(d)),[D,_]=o.useState(!1),[Y,P]=o.useState(!1),T=()=>{S((d==null?void 0:d.name)??""),M((d==null?void 0:d.baseUrl)??""),O(""),w(Ae(d)),_(!1),P(!1)},z=a=>{a||T(),r(a)},f=(a,n)=>{w(L=>L.map((j,$)=>$===a?{...j,...n}:j))},F=()=>{_(!0),P(!0),w(a=>a.map(n=>({...n,idTouched:!0,contextTouched:!0,maxTouched:!0})))},J=p.trim(),H=J?null:"Name is required.",Z=g.trim();let R=null;if(!Z)R="Base URL is required.";else try{new URL(Z)}catch{R="Enter a valid URL."}const X=a=>a.id.trim()?null:"Model ID is required.",V=a=>a.name.trim()?null:"Model name is required.",A=a=>he(a.contextLength)==null?"Set the model's context window.":null,u=a=>he(a.maxOutputTokens)==null?"Set the max output tokens.":null,N=!H&&!R&&y.every(a=>!X(a)&&!V(a)),E=D&&H,ie=Y&&R,te=async()=>{if(F(),!N||b)return;const a=y.findIndex(n=>A(n)||u(n));if(a!==-1){f(a,{advancedExpanded:!0});const n=y[a],L=n&&A(n)?"context-length":"max-output-tokens";setTimeout(()=>{var $;const j=document.getElementById(`custom-provider-model-${a}-${L}`);($=j==null?void 0:j.scrollIntoView)==null||$.call(j,{block:"center",behavior:"smooth"}),j==null||j.focus()},0);return}try{await x({name:J,baseUrl:Z,apiKey:m.trim(),models:y.map(n=>{var B;const L={};(B=n.reasoningEfforts)!=null&&B.length&&(L.reasoningEfforts=n.reasoningEfforts);const j=he(n.contextLength);j!=null&&(L.contextLength=j);const $=he(n.maxOutputTokens);return $!=null&&(L.maxOutputTokens=$),{id:n.id.trim(),name:n.name.trim(),...Object.keys(L).length>0?{properties:L}:{}}})}),z(!1)}catch{}};return e.jsx(_e,{open:s,onOpenChange:z,title:c?`Edit ${(d==null?void 0:d.name)??p}`:"Add custom provider",description:c?"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:a=>{a.preventDefault(),te()},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(ue,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:p,onChange:a=>S(a.target.value),onBlur:()=>_(!0),placeholder:"local-llama",autoFocus:!c,readOnly:c,"aria-readonly":c,"aria-invalid":E?!0:void 0,className:k(re,c&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",E&&oe)}),c?e.jsx(me,{children:"Provider names cannot be changed after creation."}):null,E?e.jsx(le,{children:H}):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(ue,{})]}),e.jsx("input",{id:"custom-provider-base-url",type:"text",value:g,onChange:a=>M(a.target.value),onBlur:()=>P(!0),placeholder:"http://localhost:11434/v1",autoFocus:c,"aria-invalid":ie?!0:void 0,className:k(re,ie&&oe)}),ie?e.jsx(le,{children:R}):Z?null:e.jsx(me,{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:m,onChange:a=>O(a.target.value),placeholder:"sk-…",className:re}),e.jsx(me,{children:c?"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(ue,{})]}),e.jsx("div",{className:"clear-both",children:y.map((a,n)=>{const L=X(a),j=a.idTouched&&L,$=V(a),B=!!$&&a.nameDirty,pe=A(a),be=u(a),se=a.contextTouched&&pe,K=a.maxTouched&&be;return e.jsxs("div",{className:k("pb-6",n>0?"border-t border-border pt-6":"pt-1"),style:n>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-${n}-id`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model ID"}),e.jsx("input",{id:`custom-provider-model-${n}-id`,type:"text",value:a.id,onChange:C=>{const W=C.target.value;f(n,{id:W,...a.nameDirty?{}:{name:Ot(W)}})},onBlur:()=>f(n,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":j?!0:void 0,className:k(re,"font-mono",j&&oe)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${n}-name`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model name"}),e.jsx("input",{id:`custom-provider-model-${n}-name`,type:"text",value:a.name,onChange:C=>f(n,{name:C.target.value,nameDirty:!0}),placeholder:"llama-3-1-70b","aria-invalid":B?!0:void 0,className:k(re,B&&oe)})]}),e.jsx("button",{type:"button","aria-label":`Remove model ${n+1}`,disabled:y.length===1||b,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(C=>C.filter((W,ne)=>ne!==n)),children:e.jsx(U,{name:"trash",className:"size-4"})})]}),j?e.jsx(le,{children:L}):null,B?e.jsx(le,{children:$}):null,e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button","aria-expanded":a.advancedExpanded,"aria-controls":`custom-provider-model-${n}-advanced`,className:"flex cursor-pointer items-center gap-1.5 text-sm font-medium text-text-primary",onClick:()=>f(n,{advancedExpanded:!a.advancedExpanded}),children:[e.jsx(U,{name:"chevron-down",className:k("size-4 text-text-secondary transition-transform",a.advancedExpanded?"":"-rotate-90")}),"Advanced"]}),a.advancedExpanded?e.jsxs("div",{id:`custom-provider-model-${n}-advanced`,className:"mt-3 space-y-4 pl-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${n}-context-length`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Context length",e.jsx(ue,{})]}),e.jsx("input",{id:`custom-provider-model-${n}-context-length`,type:"number",min:1,inputMode:"numeric",value:a.contextLength,onChange:C=>f(n,{contextLength:C.target.value}),onBlur:()=>f(n,{contextTouched:!0}),placeholder:Rt,"aria-invalid":se?!0:void 0,className:k(re,se&&oe)}),se?e.jsx(le,{children:pe}):a.contextLength.trim()===""?e.jsx(me,{children:"Model's total token window."}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${n}-max-output-tokens`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Max output tokens",e.jsx(ue,{})]}),e.jsx("input",{id:`custom-provider-model-${n}-max-output-tokens`,type:"number",min:1,inputMode:"numeric",value:a.maxOutputTokens,onChange:C=>f(n,{maxOutputTokens:C.target.value}),onBlur:()=>f(n,{maxTouched:!0}),placeholder:Lt,"aria-invalid":K?!0:void 0,className:k(re,K&&oe)}),K?e.jsx(le,{children:be}):a.maxOutputTokens.trim()===""?e.jsx(me,{children:"Longest reply the model allows — use its real limit."}):null]}),l&&l.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:a.reasoningEfforts!==void 0,"aria-label":`Enable reasoning effort for model ${n+1}`,disabled:b,onChange:C=>f(n,{reasoningEfforts:C.target.checked?[]:void 0})}),e.jsx("span",{className:"text-text-secondary text-xs font-medium",children:"Reasoning effort"})]}),a.reasoningEfforts!==void 0?e.jsx("div",{role:"group","aria-label":`Supported reasoning efforts for model ${n+1}`,className:"mt-2 flex flex-wrap gap-2",children:l.map(C=>{var ne;const W=((ne=a.reasoningEfforts)==null?void 0:ne.includes(C))??!1;return e.jsx("button",{type:"button","aria-pressed":W,disabled:b,className:k("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",W?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-border text-text-secondary hover:bg-ghost-button-hover"),onClick:()=>{var de;return f(n,{reasoningEfforts:W?(de=a.reasoningEfforts)==null?void 0:de.filter(fe=>fe!==C):[...a.reasoningEfforts??[],C]})},children:C},C)})}):null]}):null]}):null]})]},n)})}),e.jsxs(G.Secondary,{size:"small",type:"button",className:"mt-4 w-fit",onClick:()=>w(a=>[...a,Ke()]),children:[e.jsx(U,{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:[h?e.jsx("p",{className:"text-failure-bg text-sm",children:h}):null,e.jsx(G.Primary,{type:"submit",size:"large",disabled:!N||b,className:"w-full",children:c?"Save changes":"Add provider"})]})]})})},_t=Dt;function Ne(s){return s.kind==="model"&&s.provider.models.length===1}function $t(s){return s.kind==="provider"?`“${s.provider.name}” and all of its models will no longer be available to your agents.`:Ne(s)?`“${s.model.name}” is the only model left in ${s.provider.name}, so the whole provider will be removed.`:`“${s.model.name}” will no longer be available to your agents. The rest of ${s.provider.name} stays configured.`}function It(s){return"baseUrl"in s&&typeof s.baseUrl=="string"?s.baseUrl:""}var Ut=()=>{var we,Ce;const{modelCatalog:s}=We(),r=Ye(),x=Je(),l=Te(),b=Re(),h=x&&((Ce=(we=r==null?void 0:r.settings)==null?void 0:we.modelProviders)==null?void 0:Ce.manageProviders)!==!1,c=r!=null&&r.auto.status!=="not_configured",d=c&&h,[p,S]=o.useState(""),[g,M]=o.useState([]),[m,O]=o.useState([]),[y,w]=o.useState(!0),[D,_]=o.useState(null),[Y,P]=o.useState(null),[T,z]=o.useState(!1),[f,F]=o.useState(null),[J,H]=o.useState(null),[Z,R]=o.useState(null),[X,V]=o.useState(!1),[A,u]=o.useState(null),[N,E]=o.useState(null),[ie,te]=o.useState(null),a=o.useMemo(()=>(m??[]).reduce((t,i)=>(t[i.name]=i.logo??"",t),{}),[m]),n=p.trim().toLowerCase(),L=o.useCallback(async()=>{if(!h){M([]),O([]),w(!1);return}w(!0),_(null);try{const[t,i]=await Promise.all([s.listModelProviders(),s.getModelProviderCatalog()]);M(t),O(i)}catch(t){_(Q(t,"Failed to load model providers"))}finally{w(!1)}},[s,h]);o.useEffect(()=>{L()},[L]);const j=o.useMemo(()=>new Set(g.map(t=>t.type)),[g]),$=o.useMemo(()=>g.filter(t=>{var i;return((i=t.name)==null?void 0:i.toLowerCase().includes(n))||t.models.some(v=>v.name.toLowerCase().includes(n)||v.id.toLowerCase().includes(n))}),[g,n]),B=o.useMemo(()=>m.filter(t=>t.type!=="custom"&&!j.has(t.type)&&(t.name.toLowerCase().includes(n)||t.models.some(i=>i.name.toLowerCase().includes(n)||i.id.toLowerCase().includes(n)))),[m,j,n]),pe=o.useMemo(()=>{var t;return(t=m.find(i=>i.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[m]),be=o.useMemo(()=>{const t=new Map;for(const i of m)t.set(i.type,i.models);return t},[m]),se=()=>{F(null),H(null),R(null)},K=async(t,i)=>{z(!0),_(null);try{await t(),await L(),se()}catch(v){throw i?i(v):l==null?_(Q(v,"Request failed")):l.showError(v),v}finally{z(!1)}},C=async(t,i)=>{R(null),await K(async()=>{await s.createModelProvider(bt({entry:t,draft:i}))},v=>R(Q(v,"Request failed"))),b(ae.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"create"})},W=async(t,i)=>{R(null),await K(async()=>{await s.updateModelProvider({id:t.id,type:t.type,name:t.name,...i.baseUrl?{baseUrl:i.baseUrl}:{},apiKey:i.apiKey,models:t.models})},v=>R(Q(v,"Request failed"))),l==null||l.showSuccess({title:`${t.name} updated`}),b(ae.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"update"})},ne=()=>{T||(E(null),te(null))},de=({provider:t,models:i},v)=>K(async()=>{await s.updateModelProvider({id:t.id,type:t.type,name:t.name,...t.baseUrl?{baseUrl:t.baseUrl}:{},apiKey:"",models:i})},v),fe=t=>{te(null);const i=q=>te(Q(q,"Request failed"));let v;if(t.kind==="model"&&!Ne(t))v=de({provider:t.provider,models:t.provider.models.filter(q=>q.id!==t.model.id)},i);else{const q=s.deleteModelProvider;q!==void 0&&(v=K(async()=>{await q({id:t.provider.id}),b(ae.Settings.MODEL_PROVIDER_DELETED,{provider_name:t.provider.name})},i))}v==null||v.then(()=>E(null)).catch(()=>{})},qe=async t=>{P(null),await K(async()=>{await s.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},i=>P(Q(i,"Request failed"))),setTimeout(()=>{l==null||l.showSuccess({title:`${t.name} added`}),b(ae.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"create"})},0)},Qe=async t=>{if(!A)return;const i=A;P(null),await K(async()=>{await s.updateModelProvider({id:i.id,type:i.type,name:i.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},v=>P(Q(v,"Request failed"))),setTimeout(()=>{l==null||l.showSuccess({title:"Model provider updated",description:`${i.name} was updated successfully.`}),b(ae.Settings.MODEL_PROVIDER_SAVED,{provider_name:i.name,mode:"update"})},0)},Ge=A?{name:A.name,baseUrl:A.baseUrl??"",models:A.models}:void 0,ee=f!=null?g.find(t=>t.id===f)??null:null,ce=J!=null?m.find(t=>t.type===J)??null:null,He=ee!=null||ce!=null;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Models"}),h?e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect providers and choose which models are available."}):null,D?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:D}):null,c&&!d?e.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto",children:e.jsx(Me,{})}):null,h?e.jsx("div",{className:k("mt-4 min-h-0 min-w-0 flex-1",d?"overflow-y-auto":"overflow-y-hidden"),children:e.jsxs("div",{className:k("flex min-w-0 flex-col gap-3",!d&&"h-full"),children:[d?e.jsx(Me,{}):null,e.jsxs("div",{className:"flex min-w-0 flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Ze,{query:p,setQuery:S,placeholder:"Search providers and models"})}),e.jsxs(G.Secondary,{type:"button",className:"shrink-0 sm:self-auto",onClick:()=>{P(null),u(null),V(!0)},children:[e.jsx(U,{name:"plus",size:"1rem",className:"mr-1"}),"Add Custom Provider"]})]}),e.jsxs("div",{className:k("flex flex-col gap-2",!d&&"flex-1 overflow-y-auto"),children:[y?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!y&&$.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:$.map(t=>{const i=be.get(t.type)??[],v=new Set(t.models.map(I=>I.id)),q=i.filter(I=>!v.has(I.id)),ke=a[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:ke?e.jsx(Se,{src:ke,alt:t.name,className:"size-4.5"}):e.jsx(U,{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(G.Secondary,{size:"small",className:"text-[0.8125rem]",type:"button","aria-label":`Edit ${t.name}`,title:`Edit ${t.name}`,disabled:T,onClick:()=>{t.type==="custom"?(se(),P(null),u(t),V(!0)):(R(null),H(null),F(t.id))},children:[e.jsx(U,{name:"pencil",className:"size-3.5"}),"Edit"]}),s.deleteModelProvider?e.jsx(G.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:T,onClick:()=>{te(null),E({kind:"provider",provider: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(I=>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:I.name}),t.models.length>1||s.deleteModelProvider?e.jsx("button",{type:"button","aria-label":`Remove ${I.name}`,disabled:T,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:()=>{te(null),E({kind:"model",provider:t,model:I})},children:e.jsx(U,{name:"trash",className:"size-3.5"})}):null]},I.id)),q.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 · ",q.length]}),q.map(I=>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:I.name}),e.jsx(G.Secondary,{size:"small",type:"button",disabled:T,onClick:()=>{de({provider:t,models:[...t.models,I]}).catch(()=>{})},children:"Add"})]},I.id))]}):null]})]},t.id)})})]}):null,!y&&B.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:B.map(t=>{const i=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:i?e.jsx(Se,{src:i,alt:t.name,className:"size-4.5"}):e.jsx(U,{name:"cpu",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",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(v=>v.name).join(" · ")})]})]}),e.jsxs(G.Secondary,{type:"button",disabled:T,onClick:()=>{R(null),F(null),H(t.type)},children:[e.jsx(U,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!y&&$.length===0&&B.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:n?`No providers match “${p.trim()}”.`:"No model providers yet."}):null]}),N?e.jsx(Xe,{title:N.kind==="model"&&!Ne(N)?"Remove model?":"Remove provider?",description:$t(N),busy:T,error:ie,onCancel:ne,onConfirm:()=>{fe(N)}}):null,e.jsx(Tt,{open:He,onOpenChange:t=>{t||se()},onSave:t=>{if(ee)return W(ee,t);if(ce)return C(ce,t)},title:ee?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:ee?ee.baseUrl??"":ce?It(ce):"",requireApiKey:ee==null,submitLabel:ee?"Save":"Create",busy:T,error:Z}),e.jsx(_t,{open:X,onOpenChange:t=>{V(t),t||(P(null),u(null))},isEditMode:A!==null,initialValues:Ge,onSubmit:A?Qe:qe,reasoningEffortOptions:pe,busy:T,error:Y},(A==null?void 0:A.id)??"add-custom-provider")]})}):null]})},Bt=Ut;export{Bt as default};
|
|
1
|
+
import{C as Xe}from"./chunk-BNMKM5SY-CiR8M-oi.js";import{bV as We,q as Ye,t as Je,$ as Te,a0 as Re,r as o,x as Q,j as e,a8 as Ze,ab as G,I as U,bW as Se,g as k,bH as Ve,bI as et,X as Le,a2 as Oe,Y as ye,bX as tt,at as ae,ac as De,aR as st,bY as _e,bZ as rt,b_ as at,b$ as nt,c0 as xe,c1 as $e,k as ot,c2 as lt,c3 as it,c4 as Ee,c5 as je,c6 as Ie,c7 as Ue,aE as ze,J as dt,c8 as ct,c9 as ut,ca as mt,cb as xt,V as pt,cc as bt}from"./index-C5ROvRRa.js";var Fe={gridTemplateColumns:`minmax(0,1fr) repeat(${xe.length},4.5rem)`};function ht(s){const r=s.properties.autoRouting;return(r==null?void 0:r.supported)===!0?null:{title:"Not available for auto routing",text:(r==null?void 0:r.unsupportedReason)??"Auto routing support is not reported for this model."}}function ft(s){var r;return((r=s.properties.autoRouting)==null?void 0:r.supported)===!0}function gt(s,r){return s.name.localeCompare(r.name)}function vt(s){return[!0,!1].flatMap(r=>mt(s.filter(x=>ft(x)===r)).sort(gt).map(x=>({...x,key:`${r?"supported":"unsupported"}:${x.name}`,models:[...x.models].sort((l,b)=>l.id.localeCompare(b.id))})))}var Be=o.memo(({model:s,checked:r,limitBlock:x,onToggle:l})=>{const b=s.properties.autoRouting,h=ht(s),c=r?null:h??x,d=(b==null?void 0:b.supported)===!0?b.categories:[],p=e.jsxs("button",{type:"button",role:"option","aria-selected":r,"aria-label":s.id,"aria-disabled":c!=null||void 0,className:k("grid w-full items-center px-3.5 text-left text-sm text-text-primary focus-visible:bg-ghost-button-hover focus-visible:outline-none",c==null?"cursor-pointer hover:bg-ghost-button-hover":"cursor-not-allowed opacity-50"),style:Fe,onClick:()=>{c==null&&l(s.name)},children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(xt,{checked:r,className:"size-4.5 rounded-[0.3125rem]"}),e.jsx("span",{className:"truncate",children:s.id})]}),h==null?e.jsx(Ue,{categories:d,className:"h-11"}):e.jsx("span",{className:"h-11 content-center justify-self-center",style:{gridColumn:`2 / span ${String(xe.length)}`},children:e.jsx("span",{className:"rounded-full border border-text-secondary/30 px-2 py-px text-xs text-text-secondary",children:"Not supported"})})]});return c==null?p:e.jsx(pt,{side:"right",interactive:!1,triggerClassName:"block w-full",className:"w-[16.25rem] whitespace-normal rounded-lg bg-text-primary px-3 py-2.5 text-[0.8125rem] leading-[1.1875rem] text-primary-bg shadow-lg",content:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block font-semibold",children:c.title}),e.jsx("span",{className:"block",children:c.text})]}),children:e.jsx("span",{className:"block w-full",children:p})})});Be.displayName="AutoModelPickerOption";var yt=({listboxId:s,models:r,selected:x,limitBlock:l,onToggle:b})=>{const[h,c]=o.useState(""),d=ct(h),p=o.useMemo(()=>vt(d?r.filter(S=>ut({model:S,needle:d})):r),[r,d]);return e.jsxs("div",{className:"aui-popup-enter absolute left-0 top-full z-50 mt-2 flex max-h-[24.5rem] w-[40rem] max-w-[calc(100vw-3rem)] flex-col overflow-hidden rounded-lg border border-border bg-card-bg text-text-primary shadow-lg",children:[e.jsx("div",{className:"border-b border-border p-2.5",children:e.jsx("input",{type:"search",value:h,onChange:S=>c(S.target.value),placeholder:"Search models","aria-label":"Search models",className:ze("h-9"),autoFocus:!0})}),e.jsxs("div",{className:"grid items-center border-b border-border px-3.5 py-2 text-[0.6875rem] uppercase tracking-[0.08em]",style:Fe,children:[e.jsx("div",{}),e.jsx(Ie,{})]}),e.jsxs("div",{id:s,role:"listbox","aria-multiselectable":!0,"aria-label":"Models Auto can choose from",className:"min-h-0 flex-1 overflow-y-auto py-1.5",children:[p.map((S,g)=>{const M=`${s}-provider-${String(g)}`;return e.jsxs("div",{role:"group","aria-labelledby":M,children:[e.jsx("div",{id:M,className:"truncate px-3.5 pb-1 pt-2.5 text-[0.6875rem] uppercase tracking-[0.08em] text-text-secondary",children:S.name}),S.models.map(m=>e.jsx(Be,{model:m,checked:x.has(m.name),limitBlock:l,onToggle:b},m.name))]},S.key)}),p.length===0?e.jsx("p",{className:"px-3.5 py-3.5 text-[0.8125rem] text-text-secondary",children:r.length===0?"No models are available to select.":"No models match."}):null]})]})},jt=yt,ge="grid items-center px-6",ve={gridTemplateColumns:`minmax(0,1fr) repeat(${xe.length},minmax(0,7rem)) 2.5rem`};function Nt({left:s,right:r}){return s.length===r.length&&s.every(x=>r.includes(x))}function wt({name:s,model:r,listingKnown:x}){if(r===void 0)return{name:s,label:dt(s),categories:[],problem:x?"Not visible to you":null};const l=r.properties.autoRouting;return{name:s,label:r.id,categories:(l==null?void 0:l.supported)===!0?l.categories:[],problem:(l==null?void 0:l.supported)===!0?null:"Not available for auto routing"}}function Ct(s){return s.map($e).join(", ")}function kt({selectedCount:s,gaps:r,hasProblem:x,dirty:l,belowMinimum:b}){if(s===0)return{text:`No models selected.${l?` Pick at least ${String(je)} to update.`:" With none selected, Auto stays unavailable."}`,warning:!1};if(r.length>0){const h=r.length>1;return{text:`${Ct(r)} ${h?"have":"has"} no model. Add a model that covers ${h?"them":"it"}.`,warning:!0}}return x&&l?{text:"Remove the flagged models to update.",warning:!1}:b&&l?{text:`Pick at least ${String(je)} to update.`,warning:!1}:{text:"",warning:!1}}var St=({candidateModels:s,saving:r,onSave:x})=>{const l=ot(),b=Le(),h=o.useId(),c=o.useRef(null),d=o.useRef(null),[p,S]=o.useState(s),[g,M]=o.useState(!1),m=Oe({queryKey:ye.catalog.models(),queryFn:()=>l==null?Promise.reject(new Error("Server is not configured.")):l.getModels(),enabled:l!=null},b),O=o.useMemo(()=>m.data??[],[m.data]),y=o.useMemo(()=>new Map(O.map(u=>[u.name,u])),[O]),w=m.isSuccess,D=o.useMemo(()=>p.map(u=>wt({name:u,model:y.get(u),listingKnown:w})),[p,y,w]),_=o.useMemo(()=>lt(D.map(u=>u.categories)),[D]),Y=w?it(_):[],P=D.some(u=>u.problem!==null),T=o.useMemo(()=>new Set(p),[p]),z=o.useMemo(()=>!Nt({left:p,right:s}),[p,s]),f=p.length>=Ee,F=p.length<je,J=kt({selectedCount:p.length,gaps:Y,hasProblem:P,dirty:z,belowMinimum:F}),H=!r&&!F&&!P&&Y.length===0,Z=o.useMemo(()=>f?{title:"Model limit reached",text:`Auto can use at most ${String(Ee)} models. Remove one to add another.`}:null,[f]),R=o.useCallback(u=>S(N=>N.includes(u)?N.filter(E=>E!==u):[...N,u]),[]),X=o.useCallback(()=>M(!1),[]);o.useEffect(()=>{if(!g)return;const u=N=>{var E;N.target instanceof Node&&((E=d.current)!=null&&E.contains(N.target))||X()};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[g,X]);const V=o.useCallback(u=>{var N;u.key!=="Escape"||!g||(u.stopPropagation(),X(),(N=c.current)==null||N.focus())},[g,X]),A=o.useCallback(()=>x(p),[x,p]);return m.isPending?e.jsx("div",{className:"border-t border-border p-6",children:e.jsx(De,{"data-testid":"auto-model-candidate-list-skeleton",className:"h-24 w-full rounded-md"})}):e.jsxs("div",{className:"border-t border-border",onKeyDown:V,children:[e.jsxs("div",{className:k(ge,"pb-2 pt-4 text-xs uppercase tracking-[0.08em]"),style:ve,children:[e.jsx("div",{className:"text-text-secondary",children:"Model"}),e.jsx(Ie,{}),e.jsx("div",{})]}),D.length===0?e.jsx("p",{className:"border-t border-border px-6 py-5 text-[0.8125rem] text-text-secondary",children:"Add the models Auto may route to."}):null,D.map(u=>e.jsxs("div",{className:k(ge,"min-h-16 border-t border-border"),style:ve,children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("div",{className:"truncate text-[0.9375rem] font-medium text-text-primary",children:u.label}),u.problem!==null?e.jsx("div",{className:"truncate text-[0.8125rem] text-failure-bg",children:u.problem}):null]}),e.jsx(Ue,{categories:u.categories,className:"h-16"}),e.jsx("button",{type:"button","aria-label":`Remove ${u.name}`,disabled:r,className:"inline-flex size-7 items-center justify-center justify-self-end rounded-md text-text-secondary hover:bg-ghost-button-hover hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring disabled:opacity-50",onClick:()=>R(u.name),children:e.jsx(U,{name:"xmark",size:"0.75rem"})})]},u.name)),w?e.jsxs("div",{className:k(ge,"min-h-12 border-t border-border bg-black/10 text-[0.8125rem]"),style:ve,children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.08em] text-text-secondary",children:"Coverage"}),xe.map((u,N)=>{const E=_[N]??0;return e.jsx("div",{className:k("text-center",E>0?"text-text-secondary":"text-warning-bg"),children:E>0?`${String(E)} model${E>1?"s":""}`:"No model"},u)}),e.jsx("div",{})]}):null,m.isError?e.jsx("p",{className:"border-t border-border px-6 py-3 text-xs text-failure-bg",children:Q(m.error,"Failed to load models")}):null,e.jsxs("div",{className:"flex items-center justify-between gap-4 border-t border-border px-6 py-3.5",children:[e.jsxs("div",{ref:d,className:"relative",children:[e.jsxs(G.Secondary,{ref:c,size:"small",type:"button","aria-haspopup":"listbox","aria-expanded":g,"aria-controls":g?h:void 0,disabled:r,onClick:()=>M(u=>!u),children:[e.jsx(U,{name:"plus"}),"Add models"]}),g?e.jsx(jt,{listboxId:h,models:O,selected:T,limitBlock:Z,onToggle:R}):null]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-3",children:[e.jsx("p",{role:"status",className:k("text-right text-[0.8125rem]",J.warning?"text-warning-bg":"text-text-secondary"),children:J.text}),z?e.jsx(G.Primary,{size:"small",type:"button",disabled:!H,onClick:A,children:"Update"}):null]})]})]})},Et=St,Mt=new Intl.ListFormat("en",{type:"disjunction"}).format(xe.map($e)),Pt=()=>{var M;const s=Ve(),r=et(),x=Le(),l=Te(),b=Re(),h=Oe({queryKey:ye.settings.configuration(),queryFn:()=>s==null?Promise.reject(new Error("Configuration server is not configured.")):s.getConfiguration(),enabled:s!=null},x),c=tt({mutationFn:m=>s==null?Promise.reject(new Error("Configuration server is not configured.")):s.updateConfiguration({autoModelRouting:m}),onSuccess:(m,O)=>{x.setQueryData(ye.settings.configuration(),m),r==null||r();const{enabled:y,candidateModels:w}=m.autoModelRouting;O.candidateModels===void 0?(l==null||l.showSuccess({title:y?"Auto model routing turned on":"Auto model routing turned off"}),b(ae.Settings.AUTO_MODE_TENANT_TOGGLED,{enabled:y})):(l==null||l.showSuccess({title:"Models updated"}),b(ae.Settings.AUTO_MODE_CANDIDATE_MODELS_SAVED,{model_count:w.length}))}},x);if(!s)return null;const d=c.isError?Q(c.error,"Failed to save the Auto mode setting"):h.isError?Q(h.error,"Failed to load the Auto mode setting"):null,p=(M=h.data)==null?void 0:M.autoModelRouting,g=(c.isPending?c.variables.enabled:void 0)??(p==null?void 0:p.enabled);return e.jsxs(e.Fragment,{children:[d?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:d}):null,h.isPending?e.jsx(De,{"data-testid":"auto-mode-setting-skeleton",className:"mt-4 h-16 w-full rounded-xl"}):null,g!==void 0?e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"rounded-xl border border-border bg-card-bg",children:[e.jsxs("div",{className:"flex items-start justify-between gap-6 p-6",children:[e.jsxs("div",{className:"flex min-w-0 max-w-[42.5rem] flex-col gap-1.5",children:[e.jsx("h4",{className:"text-lg font-semibold text-text-primary",children:"Auto model routing"}),e.jsx("p",{className:"text-pretty text-sm leading-[1.375rem] text-text-secondary",children:g?`Each task is matched to a tier: ${Mt}. Auto picks a suitable model from the ones you select, so include at least one for every tier.`:"Intelligently picks a suitable model for each task."})]}),e.jsx(st,{size:"md",checked:g,disabled:c.isPending,className:"disabled:opacity-100","aria-label":"Auto model routing",onCheckedChange:m=>{c.mutate({enabled:m})}})]}),g&&p?e.jsx(Et,{candidateModels:p.candidateModels,saving:c.isPending,onSave:m=>{c.mutate({candidateModels:m})}},JSON.stringify(p.candidateModels)):null]})}):null]})},Me=Pt,Pe=ze("h-11 shadow-sm"),At=({open:s,onOpenChange:r,onSave:x,title:l,description:b,initialBaseUrl:h="",baseUrlPlaceholder:c="https://api.openai.com/v1",requireApiKey:d=!0,submitLabel:p="Save",busy:S=!1,error:g})=>{const[M,m]=o.useState(""),[O,y]=o.useState(""),[w,D]=o.useState(!1),_=()=>{m(""),y(""),D(!1)};o.useEffect(()=>{s&&(m(""),y(h),D(!1))},[s,h]);const Y=f=>{f||_(),r(f)},P=M.trim(),T=!d||!!P,z=async f=>{if(f.preventDefault(),!(!T||S))try{await x({apiKey:P,baseUrl:O.trim()}),_(),r(!1)}catch{}};return e.jsx(_e,{open:s,onOpenChange:Y,title:l,description:b,contentSized:!0,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:"model-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",d?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"model-provider-api-key",type:"password",required:d,value:M,onChange:f=>{m(f.target.value)},placeholder:d?"Enter API key":"Enter a new key",autoFocus:!0,className:Pe}),d?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(rt,{expanded:w,onChange:(f,F)=>D(F),className:"rounded-md border border-border",children:[e.jsx(at,{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(U,{name:"chevron-down",className:k("size-4 shrink-0 text-text-secondary transition-transform duration-200",w?"rotate-0":"-rotate-90")})]})}),e.jsxs(nt,{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:O,onChange:f=>{y(f.target.value)},placeholder:c,className:Pe}),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:[g?e.jsx("p",{className:"text-failure-bg text-sm",children:g}):null,e.jsx(G.Primary,{type:"submit",size:"large",disabled:!T||S,className:"w-full shrink-0",children:p})]})]})})},Tt=At,Rt="128000",Lt="4096",Ke=()=>({id:"",name:"",advancedExpanded:!0,contextLength:"",maxOutputTokens:""}),Ae=s=>(s==null?void 0:s.models.map(r=>{var x,l,b,h,c;return{id:r.id,name:r.name,advancedExpanded:!0,reasoningEfforts:(x=r.properties)==null?void 0:x.reasoningEfforts,contextLength:((b=(l=r.properties)==null?void 0:l.contextLength)==null?void 0:b.toString())??"",maxOutputTokens:((c=(h=r.properties)==null?void 0:h.maxOutputTokens)==null?void 0:c.toString())??"",nameDirty:!0}}))??[Ke()],re="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",oe="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function he(s){const r=s.trim();if(r==="")return null;const x=Number(r);return Number.isInteger(x)&&x>0?x:null}function Ot(s){return s.replace(/([a-zA-Z])(\d)/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").slice(0,64).replace(/-+$/g,"")}var ue=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),le=({children:s})=>e.jsx("p",{className:"mt-1 text-xs text-failure-bg",children:s}),me=({children:s})=>e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:s}),Dt=({open:s,onOpenChange:r,onSubmit:x,reasoningEffortOptions:l,busy:b=!1,error:h,isEditMode:c=!1,initialValues:d})=>{const[p,S]=o.useState((d==null?void 0:d.name)??""),[g,M]=o.useState((d==null?void 0:d.baseUrl)??""),[m,O]=o.useState(""),[y,w]=o.useState(()=>Ae(d)),[D,_]=o.useState(!1),[Y,P]=o.useState(!1),T=()=>{S((d==null?void 0:d.name)??""),M((d==null?void 0:d.baseUrl)??""),O(""),w(Ae(d)),_(!1),P(!1)},z=a=>{a||T(),r(a)},f=(a,n)=>{w(L=>L.map((j,$)=>$===a?{...j,...n}:j))},F=()=>{_(!0),P(!0),w(a=>a.map(n=>({...n,idTouched:!0,contextTouched:!0,maxTouched:!0})))},J=p.trim(),H=J?null:"Name is required.",Z=g.trim();let R=null;if(!Z)R="Base URL is required.";else try{new URL(Z)}catch{R="Enter a valid URL."}const X=a=>a.id.trim()?null:"Model ID is required.",V=a=>a.name.trim()?null:"Model name is required.",A=a=>he(a.contextLength)==null?"Set the model's context window.":null,u=a=>he(a.maxOutputTokens)==null?"Set the max output tokens.":null,N=!H&&!R&&y.every(a=>!X(a)&&!V(a)),E=D&&H,ie=Y&&R,te=async()=>{if(F(),!N||b)return;const a=y.findIndex(n=>A(n)||u(n));if(a!==-1){f(a,{advancedExpanded:!0});const n=y[a],L=n&&A(n)?"context-length":"max-output-tokens";setTimeout(()=>{var $;const j=document.getElementById(`custom-provider-model-${a}-${L}`);($=j==null?void 0:j.scrollIntoView)==null||$.call(j,{block:"center",behavior:"smooth"}),j==null||j.focus()},0);return}try{await x({name:J,baseUrl:Z,apiKey:m.trim(),models:y.map(n=>{var B;const L={};(B=n.reasoningEfforts)!=null&&B.length&&(L.reasoningEfforts=n.reasoningEfforts);const j=he(n.contextLength);j!=null&&(L.contextLength=j);const $=he(n.maxOutputTokens);return $!=null&&(L.maxOutputTokens=$),{id:n.id.trim(),name:n.name.trim(),...Object.keys(L).length>0?{properties:L}:{}}})}),z(!1)}catch{}};return e.jsx(_e,{open:s,onOpenChange:z,title:c?`Edit ${(d==null?void 0:d.name)??p}`:"Add custom provider",description:c?"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:a=>{a.preventDefault(),te()},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(ue,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:p,onChange:a=>S(a.target.value),onBlur:()=>_(!0),placeholder:"local-llama",autoFocus:!c,readOnly:c,"aria-readonly":c,"aria-invalid":E?!0:void 0,className:k(re,c&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",E&&oe)}),c?e.jsx(me,{children:"Provider names cannot be changed after creation."}):null,E?e.jsx(le,{children:H}):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(ue,{})]}),e.jsx("input",{id:"custom-provider-base-url",type:"text",value:g,onChange:a=>M(a.target.value),onBlur:()=>P(!0),placeholder:"http://localhost:11434/v1",autoFocus:c,"aria-invalid":ie?!0:void 0,className:k(re,ie&&oe)}),ie?e.jsx(le,{children:R}):Z?null:e.jsx(me,{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:m,onChange:a=>O(a.target.value),placeholder:"sk-…",className:re}),e.jsx(me,{children:c?"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(ue,{})]}),e.jsx("div",{className:"clear-both",children:y.map((a,n)=>{const L=X(a),j=a.idTouched&&L,$=V(a),B=!!$&&a.nameDirty,pe=A(a),be=u(a),se=a.contextTouched&&pe,K=a.maxTouched&&be;return e.jsxs("div",{className:k("pb-6",n>0?"border-t border-border pt-6":"pt-1"),style:n>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-${n}-id`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model ID"}),e.jsx("input",{id:`custom-provider-model-${n}-id`,type:"text",value:a.id,onChange:C=>{const W=C.target.value;f(n,{id:W,...a.nameDirty?{}:{name:Ot(W)}})},onBlur:()=>f(n,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":j?!0:void 0,className:k(re,"font-mono",j&&oe)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${n}-name`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model name"}),e.jsx("input",{id:`custom-provider-model-${n}-name`,type:"text",value:a.name,onChange:C=>f(n,{name:C.target.value,nameDirty:!0}),placeholder:"llama-3-1-70b","aria-invalid":B?!0:void 0,className:k(re,B&&oe)})]}),e.jsx("button",{type:"button","aria-label":`Remove model ${n+1}`,disabled:y.length===1||b,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(C=>C.filter((W,ne)=>ne!==n)),children:e.jsx(U,{name:"trash",className:"size-4"})})]}),j?e.jsx(le,{children:L}):null,B?e.jsx(le,{children:$}):null,e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button","aria-expanded":a.advancedExpanded,"aria-controls":`custom-provider-model-${n}-advanced`,className:"flex cursor-pointer items-center gap-1.5 text-sm font-medium text-text-primary",onClick:()=>f(n,{advancedExpanded:!a.advancedExpanded}),children:[e.jsx(U,{name:"chevron-down",className:k("size-4 text-text-secondary transition-transform",a.advancedExpanded?"":"-rotate-90")}),"Advanced"]}),a.advancedExpanded?e.jsxs("div",{id:`custom-provider-model-${n}-advanced`,className:"mt-3 space-y-4 pl-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${n}-context-length`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Context length",e.jsx(ue,{})]}),e.jsx("input",{id:`custom-provider-model-${n}-context-length`,type:"number",min:1,inputMode:"numeric",value:a.contextLength,onChange:C=>f(n,{contextLength:C.target.value}),onBlur:()=>f(n,{contextTouched:!0}),placeholder:Rt,"aria-invalid":se?!0:void 0,className:k(re,se&&oe)}),se?e.jsx(le,{children:pe}):a.contextLength.trim()===""?e.jsx(me,{children:"Model's total token window."}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${n}-max-output-tokens`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Max output tokens",e.jsx(ue,{})]}),e.jsx("input",{id:`custom-provider-model-${n}-max-output-tokens`,type:"number",min:1,inputMode:"numeric",value:a.maxOutputTokens,onChange:C=>f(n,{maxOutputTokens:C.target.value}),onBlur:()=>f(n,{maxTouched:!0}),placeholder:Lt,"aria-invalid":K?!0:void 0,className:k(re,K&&oe)}),K?e.jsx(le,{children:be}):a.maxOutputTokens.trim()===""?e.jsx(me,{children:"Longest reply the model allows — use its real limit."}):null]}),l&&l.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:a.reasoningEfforts!==void 0,"aria-label":`Enable reasoning effort for model ${n+1}`,disabled:b,onChange:C=>f(n,{reasoningEfforts:C.target.checked?[]:void 0})}),e.jsx("span",{className:"text-text-secondary text-xs font-medium",children:"Reasoning effort"})]}),a.reasoningEfforts!==void 0?e.jsx("div",{role:"group","aria-label":`Supported reasoning efforts for model ${n+1}`,className:"mt-2 flex flex-wrap gap-2",children:l.map(C=>{var ne;const W=((ne=a.reasoningEfforts)==null?void 0:ne.includes(C))??!1;return e.jsx("button",{type:"button","aria-pressed":W,disabled:b,className:k("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",W?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-border text-text-secondary hover:bg-ghost-button-hover"),onClick:()=>{var de;return f(n,{reasoningEfforts:W?(de=a.reasoningEfforts)==null?void 0:de.filter(fe=>fe!==C):[...a.reasoningEfforts??[],C]})},children:C},C)})}):null]}):null]}):null]})]},n)})}),e.jsxs(G.Secondary,{size:"small",type:"button",className:"mt-4 w-fit",onClick:()=>w(a=>[...a,Ke()]),children:[e.jsx(U,{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:[h?e.jsx("p",{className:"text-failure-bg text-sm",children:h}):null,e.jsx(G.Primary,{type:"submit",size:"large",disabled:!N||b,className:"w-full",children:c?"Save changes":"Add provider"})]})]})})},_t=Dt;function Ne(s){return s.kind==="model"&&s.provider.models.length===1}function $t(s){return s.kind==="provider"?`“${s.provider.name}” and all of its models will no longer be available to your agents.`:Ne(s)?`“${s.model.name}” is the only model left in ${s.provider.name}, so the whole provider will be removed.`:`“${s.model.name}” will no longer be available to your agents. The rest of ${s.provider.name} stays configured.`}function It(s){return"baseUrl"in s&&typeof s.baseUrl=="string"?s.baseUrl:""}var Ut=()=>{var we,Ce;const{modelCatalog:s}=We(),r=Ye(),x=Je(),l=Te(),b=Re(),h=x&&((Ce=(we=r==null?void 0:r.settings)==null?void 0:we.modelProviders)==null?void 0:Ce.manageProviders)!==!1,c=r!=null&&r.auto.status!=="not_configured",d=c&&h,[p,S]=o.useState(""),[g,M]=o.useState([]),[m,O]=o.useState([]),[y,w]=o.useState(!0),[D,_]=o.useState(null),[Y,P]=o.useState(null),[T,z]=o.useState(!1),[f,F]=o.useState(null),[J,H]=o.useState(null),[Z,R]=o.useState(null),[X,V]=o.useState(!1),[A,u]=o.useState(null),[N,E]=o.useState(null),[ie,te]=o.useState(null),a=o.useMemo(()=>(m??[]).reduce((t,i)=>(t[i.name]=i.logo??"",t),{}),[m]),n=p.trim().toLowerCase(),L=o.useCallback(async()=>{if(!h){M([]),O([]),w(!1);return}w(!0),_(null);try{const[t,i]=await Promise.all([s.listModelProviders(),s.getModelProviderCatalog()]);M(t),O(i)}catch(t){_(Q(t,"Failed to load model providers"))}finally{w(!1)}},[s,h]);o.useEffect(()=>{L()},[L]);const j=o.useMemo(()=>new Set(g.map(t=>t.type)),[g]),$=o.useMemo(()=>g.filter(t=>{var i;return((i=t.name)==null?void 0:i.toLowerCase().includes(n))||t.models.some(v=>v.name.toLowerCase().includes(n)||v.id.toLowerCase().includes(n))}),[g,n]),B=o.useMemo(()=>m.filter(t=>t.type!=="custom"&&!j.has(t.type)&&(t.name.toLowerCase().includes(n)||t.models.some(i=>i.name.toLowerCase().includes(n)||i.id.toLowerCase().includes(n)))),[m,j,n]),pe=o.useMemo(()=>{var t;return(t=m.find(i=>i.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[m]),be=o.useMemo(()=>{const t=new Map;for(const i of m)t.set(i.type,i.models);return t},[m]),se=()=>{F(null),H(null),R(null)},K=async(t,i)=>{z(!0),_(null);try{await t(),await L(),se()}catch(v){throw i?i(v):l==null?_(Q(v,"Request failed")):l.showError(v),v}finally{z(!1)}},C=async(t,i)=>{R(null),await K(async()=>{await s.createModelProvider(bt({entry:t,draft:i}))},v=>R(Q(v,"Request failed"))),b(ae.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"create"})},W=async(t,i)=>{R(null),await K(async()=>{await s.updateModelProvider({id:t.id,type:t.type,name:t.name,...i.baseUrl?{baseUrl:i.baseUrl}:{},apiKey:i.apiKey,models:t.models})},v=>R(Q(v,"Request failed"))),l==null||l.showSuccess({title:`${t.name} updated`}),b(ae.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"update"})},ne=()=>{T||(E(null),te(null))},de=({provider:t,models:i},v)=>K(async()=>{await s.updateModelProvider({id:t.id,type:t.type,name:t.name,...t.baseUrl?{baseUrl:t.baseUrl}:{},apiKey:"",models:i})},v),fe=t=>{te(null);const i=q=>te(Q(q,"Request failed"));let v;if(t.kind==="model"&&!Ne(t))v=de({provider:t.provider,models:t.provider.models.filter(q=>q.id!==t.model.id)},i);else{const q=s.deleteModelProvider;q!==void 0&&(v=K(async()=>{await q({id:t.provider.id}),b(ae.Settings.MODEL_PROVIDER_DELETED,{provider_name:t.provider.name})},i))}v==null||v.then(()=>E(null)).catch(()=>{})},qe=async t=>{P(null),await K(async()=>{await s.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},i=>P(Q(i,"Request failed"))),setTimeout(()=>{l==null||l.showSuccess({title:`${t.name} added`}),b(ae.Settings.MODEL_PROVIDER_SAVED,{provider_name:t.name,mode:"create"})},0)},Qe=async t=>{if(!A)return;const i=A;P(null),await K(async()=>{await s.updateModelProvider({id:i.id,type:i.type,name:i.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},v=>P(Q(v,"Request failed"))),setTimeout(()=>{l==null||l.showSuccess({title:"Model provider updated",description:`${i.name} was updated successfully.`}),b(ae.Settings.MODEL_PROVIDER_SAVED,{provider_name:i.name,mode:"update"})},0)},Ge=A?{name:A.name,baseUrl:A.baseUrl??"",models:A.models}:void 0,ee=f!=null?g.find(t=>t.id===f)??null:null,ce=J!=null?m.find(t=>t.type===J)??null:null,He=ee!=null||ce!=null;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Models"}),h?e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect providers and choose which models are available."}):null,D?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:D}):null,c&&!d?e.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto",children:e.jsx(Me,{})}):null,h?e.jsx("div",{className:k("mt-4 min-h-0 min-w-0 flex-1",d?"overflow-y-auto":"overflow-y-hidden"),children:e.jsxs("div",{className:k("flex min-w-0 flex-col gap-3",!d&&"h-full"),children:[d?e.jsx(Me,{}):null,e.jsxs("div",{className:"flex min-w-0 flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Ze,{query:p,setQuery:S,placeholder:"Search providers and models"})}),e.jsxs(G.Secondary,{type:"button",className:"shrink-0 sm:self-auto",onClick:()=>{P(null),u(null),V(!0)},children:[e.jsx(U,{name:"plus",size:"1rem",className:"mr-1"}),"Add Custom Provider"]})]}),e.jsxs("div",{className:k("flex flex-col gap-2",!d&&"flex-1 overflow-y-auto"),children:[y?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!y&&$.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:$.map(t=>{const i=be.get(t.type)??[],v=new Set(t.models.map(I=>I.id)),q=i.filter(I=>!v.has(I.id)),ke=a[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:ke?e.jsx(Se,{src:ke,alt:t.name,className:"size-4.5"}):e.jsx(U,{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(G.Secondary,{size:"small",className:"text-[0.8125rem]",type:"button","aria-label":`Edit ${t.name}`,title:`Edit ${t.name}`,disabled:T,onClick:()=>{t.type==="custom"?(se(),P(null),u(t),V(!0)):(R(null),H(null),F(t.id))},children:[e.jsx(U,{name:"pencil",className:"size-3.5"}),"Edit"]}),s.deleteModelProvider?e.jsx(G.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:T,onClick:()=>{te(null),E({kind:"provider",provider: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(I=>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:I.name}),t.models.length>1||s.deleteModelProvider?e.jsx("button",{type:"button","aria-label":`Remove ${I.name}`,disabled:T,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:()=>{te(null),E({kind:"model",provider:t,model:I})},children:e.jsx(U,{name:"trash",className:"size-3.5"})}):null]},I.id)),q.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 · ",q.length]}),q.map(I=>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:I.name}),e.jsx(G.Secondary,{size:"small",type:"button",disabled:T,onClick:()=>{de({provider:t,models:[...t.models,I]}).catch(()=>{})},children:"Add"})]},I.id))]}):null]})]},t.id)})})]}):null,!y&&B.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:B.map(t=>{const i=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:i?e.jsx(Se,{src:i,alt:t.name,className:"size-4.5"}):e.jsx(U,{name:"cpu",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",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(v=>v.name).join(" · ")})]})]}),e.jsxs(G.Secondary,{type:"button",disabled:T,onClick:()=>{R(null),F(null),H(t.type)},children:[e.jsx(U,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!y&&$.length===0&&B.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:n?`No providers match “${p.trim()}”.`:"No model providers yet."}):null]}),N?e.jsx(Xe,{title:N.kind==="model"&&!Ne(N)?"Remove model?":"Remove provider?",description:$t(N),busy:T,error:ie,onCancel:ne,onConfirm:()=>{fe(N)}}):null,e.jsx(Tt,{open:He,onOpenChange:t=>{t||se()},onSave:t=>{if(ee)return W(ee,t);if(ce)return C(ce,t)},title:ee?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:ee?ee.baseUrl??"":ce?It(ce):"",requireApiKey:ee==null,submitLabel:ee?"Save":"Create",busy:T,error:Z}),e.jsx(_t,{open:X,onOpenChange:t=>{V(t),t||(P(null),u(null))},isEditMode:A!==null,initialValues:Ge,onSubmit:A?Qe:qe,reasoningEffortOptions:pe,busy:T,error:Y},(A==null?void 0:A.id)??"add-custom-provider")]})}):null]})},Bt=Ut;export{Bt as default};
|
|
Binary file
|
|
Binary file
|