@openhands/agent-canvas 1.5.1 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.windows.md +2 -2
- package/build/assets/{Trans-DqF_OEZB.js → Trans-52HCczKK.js} +1 -1
- package/build/assets/{acp-providers-DerAmTyY.js → acp-providers-xACMK9ZP.js} +1 -1
- package/build/assets/{active-backend-context-B8rMv0X9.js → active-backend-context-Cd1qcZsb.js} +1 -1
- package/build/assets/{add-backend-modal-CxC7BNEc.js → add-backend-modal-5chsfln3.js} +1 -1
- package/build/assets/{agent-profiles-settings-BJb8YXR1.js → agent-profiles-settings-BWK4H3kR.js} +1 -1
- package/build/assets/agent-server-compatibility-DMY0CihN.js +1 -0
- package/build/assets/agent-server-conversation-service.api-CI5-xmIX.js +41 -0
- package/build/assets/agent-settings-CMd8-O4f.js +2 -0
- package/build/assets/agent-settings-CdrhQJXX.js +1 -0
- package/build/assets/{alert-banner-Dh51WURQ.js → alert-banner-CLfWuIAX.js} +1 -1
- package/build/assets/api-key-entry-screen-Cc3aC7DZ.js +1 -0
- package/build/assets/app-settings-B-DQcBoB.js +1 -0
- package/build/assets/{automation-detail-CZsu2CoM.js → automation-detail-BgxBIpyK.js} +2 -2
- package/build/assets/automation-export-Dbur8OHa.js +2 -0
- package/build/assets/automations-list-BWfjizlp.js +1 -0
- package/build/assets/{back-nav-button-DVknCcSP.js → back-nav-button-CaKvsD1E.js} +1 -1
- package/build/assets/backend-form-modal-YcfpuBZo.js +1 -0
- package/build/assets/{backend-synced-settings-badge-BSfN0AZA.js → backend-synced-settings-badge-BellMmgC.js} +1 -1
- package/build/assets/{base-modal-CIF_785P.js → base-modal-Cw7enAHz.js} +1 -1
- package/build/assets/{brand-button-B1izLAdR.js → brand-button-BulEFHr3.js} +1 -1
- package/build/assets/{browser-DKaeq_sT.js → browser-DfVgUREb.js} +2 -2
- package/build/assets/browser-store-CBqI3tNR.js +1 -0
- package/build/assets/{browser-tab-qb_ftCxW.js → browser-tab-CmIKQB7S.js} +1 -1
- package/build/assets/chat-send-button-BchSSwuD.js +1 -0
- package/build/assets/circle-check-BXbQ5nEH.js +1 -0
- package/build/assets/{circle-plus-check-toggle-DoFIjVE0.js → circle-plus-check-toggle-BhpPjkh9.js} +1 -1
- package/build/assets/client-source-DAUgyJsi.js +1 -0
- package/build/assets/cloud-funnel-analytics-B5OeWh4y.js +1 -0
- package/build/assets/{color-themes-CHizm1xF.js → color-themes-QKMSVfDU.js} +1 -1
- package/build/assets/{combobox-caret-CxZpqoSR.js → combobox-caret-kNZtp53R.js} +1 -1
- package/build/assets/{command-menu-oTvKDU3Y.js → command-menu-tUsn23zy.js} +1 -1
- package/build/assets/{command-store-D8J5LMW1.js → command-store-B0hrIWMN.js} +1 -1
- package/build/assets/{condenser-settings-BGlWn93P.js → condenser-settings-BBizzfIH.js} +1 -1
- package/build/assets/{confirmation-modal-DGBWM2Ls.js → confirmation-modal-108xng7X.js} +1 -1
- package/build/assets/{context-menu-list-item-6psNyl7X.js → context-menu-list-item-BbKfFuN1.js} +1 -1
- package/build/assets/conversation-CTzSrLMq.js +1 -0
- package/build/assets/conversation-CgcXNb-Z.js +90 -0
- package/build/assets/conversation-panel-bscjGQda.js +1 -0
- package/build/assets/{conversation-service.api-_f9GlIEi.js → conversation-service.api-DbBvscJA.js} +1 -1
- package/build/assets/conversation-state-store-C5GagZHT.js +1 -0
- package/build/assets/{conversation-store-LptbOvKa.js → conversation-store-CyVqoa0d.js} +1 -1
- package/build/assets/{conversation-tab-empty-state-CNUmIms2.js → conversation-tab-empty-state-2KYlk5Bh.js} +1 -1
- package/build/assets/{copy-to-clipboard-button-CFzH_NOX.js → copy-to-clipboard-button-C54YRPMg.js} +1 -1
- package/build/assets/declaration-_yumYLEx.js +1 -0
- package/build/assets/{device-verify-WBSjJBLH.js → device-verify-D6FW_KZq.js} +1 -1
- package/build/assets/{dropdown-classes-D3wMJlXT.js → dropdown-classes-9uONlOg1.js} +1 -1
- package/build/assets/{ellipsis-button-CbNnHlIq.js → ellipsis-button-CoaUrKmQ.js} +1 -1
- package/build/assets/{entry.client-DNlPGxsu.js → entry.client-BJSVzw7V.js} +2 -2
- package/build/assets/{enum-filter-dropdown-JLYv1t8L.js → enum-filter-dropdown-qQzyjk_q.js} +1 -1
- package/build/assets/{environment-switch-overlay-B1PFO8P8.js → environment-switch-overlay-XRWCClLu.js} +1 -1
- package/build/assets/extensions-hub-DUp9sWQY.js +1 -0
- package/build/assets/extensions-navigation-DmkftjAx.js +1 -0
- package/build/assets/file-tUAzhmJ3.js +1 -0
- package/build/assets/files-tab-GV5hwiIM.js +1 -0
- package/build/assets/files-tab-store-DehyITNC.js +1 -0
- package/build/assets/{form-control-classes-CbdN5aO3.js → form-control-classes-BPUnoYyg.js} +1 -1
- package/build/assets/git-provider-icon-DDkru3b_.js +1 -0
- package/build/assets/highlighted-source-view-CYkPZUxr.js +1 -0
- package/build/assets/home-C53WekZ2.js +1 -0
- package/build/assets/home-EAwq8ah2.js +1 -0
- package/build/assets/index-home-kBdZGKtu.js +1 -0
- package/build/assets/install-server-modal-DYk4VP3-.js +1 -0
- package/build/assets/{launch-CAGavYl-.js → launch-CIecOy_y.js} +1 -1
- package/build/assets/lesson-plan-BSEUwflx.js +4 -0
- package/build/assets/llm-not-configured-banner-C8uv1PHT.js +27 -0
- package/build/assets/llm-settings-0Bb97NCk.js +1 -0
- package/build/assets/llm-settings-D4toJ90k.js +1 -0
- package/build/assets/{llm-subscription-service-Casyzgn1.js → llm-subscription-service-BPRw3u3H.js} +1 -1
- package/build/assets/{loading-spinner-BcdnT0mN.js → loading-spinner-BCInDEXB.js} +1 -1
- package/build/assets/manage-backends-modal-Bon32JYr.js +1 -0
- package/build/assets/manifest-ec000ae3.js +1 -0
- package/build/assets/markdown-renderer-BlaJOAI2.js +2 -0
- package/build/assets/mcp-CFIpOkn2.js +9 -0
- package/build/assets/messages-eRPeR4pW.js +40 -0
- package/build/assets/{modal-body-Cc2zp0xb.js → modal-body-Bg9UCeoV.js} +1 -1
- package/build/assets/{modal-classes-3qT9Ap7Q.js → modal-classes-H1KbJkeC.js} +1 -1
- package/build/assets/{modal-close-button-BcIBUdSq.js → modal-close-button-BMLYvo0C.js} +1 -1
- package/build/assets/{model-selector-DJrMrFAr.js → model-selector-BqX2RvEr.js} +1 -1
- package/build/assets/{navigation-link-D8hfwvxI.js → navigation-link-DoJzTCEz.js} +1 -1
- package/build/assets/onboarding-3KO4qE6R.js +1 -0
- package/build/assets/onboarding-modal-D4vqkJeT.js +1 -0
- package/build/assets/{organization-service.api-vrRNwOma.js → organization-service.api-CvfQugOt.js} +1 -1
- package/build/assets/{path-utils-PNfCKQDV.js → path-utils-DRgexxnX.js} +1 -1
- package/build/assets/{plan-components-BdZXPyZU.js → plan-components-qkMiGs_-.js} +1 -1
- package/build/assets/{planner-tab-ByOw1he8.js → planner-tab-ZrjiirRr.js} +1 -1
- package/build/assets/{plugins-management-service-B75jyC56.js → plugins-management-service-9qT-r_37.js} +1 -1
- package/build/assets/plus-CzE1b-wl.js +1 -0
- package/build/assets/{profiles-service.api-BQTklD5D.js → profiles-service.api-CRVlrQpT.js} +1 -1
- package/build/assets/{providers-DfTB2gPd.js → providers-C2DFGBrf.js} +1 -1
- package/build/assets/{proxy-B3tCGf0X.js → proxy-DnnDqkwn.js} +1 -1
- package/build/assets/puzzle-IHQnD54C.js +1 -0
- package/build/assets/recommended-automations-launcher-B97vgHuN.js +58 -0
- package/build/assets/refresh-cw-DxbAs3SK.js +1 -0
- package/build/assets/root-BbONavTg.css +1 -0
- package/build/assets/root-D01rpqZU.js +2 -0
- package/build/assets/root-layout-BiHbCIkS.js +2 -0
- package/build/assets/{runtime-waiting-state-CnyVhX4T.js → runtime-waiting-state-CbUV9txX.js} +1 -1
- package/build/assets/{schema-field-CUwk4wrQ.js → schema-field-B9-9Ta9u.js} +1 -1
- package/build/assets/sdk-section-page-DG1s25Pr.js +1 -0
- package/build/assets/{sdk-settings-schema-CLR01YIK.js → sdk-settings-schema-B42JFr5Y.js} +1 -1
- package/build/assets/{secrets-service-CvyPWJhg.js → secrets-service-DvyS6-mV.js} +1 -1
- package/build/assets/secrets-settings-CeSq6cQw.js +1 -0
- package/build/assets/{segmented-toggle-kzwZkLaj.js → segmented-toggle-DRVJBNy0.js} +1 -1
- package/build/assets/settings-Dzo0dJKM.js +1 -0
- package/build/assets/{settings-mQUckT0g.js → settings-HcwfqMjJ.js} +1 -1
- package/build/assets/{settings-dropdown-input-Dhx9ErGd.js → settings-dropdown-input-B6RL_mt0.js} +1 -1
- package/build/assets/settings-index-uAKHyijw.js +1 -0
- package/build/assets/{settings-input-BsgQWS5R.js → settings-input-ZoaAPNQh.js} +1 -1
- package/build/assets/{settings-list-classes-DSJJX99U.js → settings-list-classes-Dr8LgITi.js} +1 -1
- package/build/assets/settings-modal-BVX2G_IT.js +1 -0
- package/build/assets/{settings-service.api-DXk5TdeJ.js → settings-service.api-BY7ncxIz.js} +1 -1
- package/build/assets/{settings-switch-Bes8dIlV.js → settings-switch-DUlGnP0B.js} +1 -1
- package/build/assets/{settings-utils-DzCVfiR3.js → settings-utils-kWEEvcdv.js} +1 -1
- package/build/assets/shared-conversation-CV4Rtdz2.js +1 -0
- package/build/assets/{sidebar-layout-Bm7pa3Vk.js → sidebar-layout-BhGooCga.js} +1 -1
- package/build/assets/sidebar-mobile-menu-toggle-BntOJphE.js +1 -0
- package/build/assets/{sidebar-nav-link-CHqyFXwV.js → sidebar-nav-link-DkA1XWV8.js} +1 -1
- package/build/assets/{sidebar-store-uiUXBU1N.js → sidebar-store-CF3b12-m.js} +1 -1
- package/build/assets/{skill-card-pill-row-BPYKQ3IN.js → skill-card-pill-row-_gWe1Tws.js} +1 -1
- package/build/assets/skill-icon-badge-C-zbaXbD.js +1 -0
- package/build/assets/skills-plugins-BwoXKtrR.js +1 -0
- package/build/assets/skills-settings-Crq-fZSt.js +2 -0
- package/build/assets/{styled-tooltip-B14i_Uac.js → styled-tooltip-CdnCJ67u.js} +1 -1
- package/build/assets/syntax-highlighter-CZK2ab-O.js +1 -0
- package/build/assets/{task-list-tab-DyfgG4MC.js → task-list-tab-CONOO9iI.js} +1 -1
- package/build/assets/telemetry-CC32dJYW.js +2 -0
- package/build/assets/{terminal-DRXt2Lr4.js → terminal-CTkDpIU-.js} +1 -1
- package/build/assets/{toggle-switch-DX_k418f.js → toggle-switch-yVIzmJLM.js} +1 -1
- package/build/assets/{typography-CzfoD9DY.js → typography-BBVEW0un.js} +1 -1
- package/build/assets/{use-acp-credential-form-Bm8qXdlc.js → use-acp-credential-form-CIsp8hJe.js} +1 -1
- package/build/assets/use-activate-agent-profile-BfcTTJJG.js +1 -0
- package/build/assets/{use-active-agent-profile-hI-x-UBa.js → use-active-agent-profile-CCeFtmk9.js} +1 -1
- package/build/assets/{use-active-conversation-2qeez40F.js → use-active-conversation-Badxj8w4.js} +1 -1
- package/build/assets/{use-agent-profiles-0pr5bLS7.js → use-agent-profiles-BSWVN6hH.js} +1 -1
- package/build/assets/{use-agent-state-C6peDXUm.js → use-agent-state-BzRrhoPd.js} +1 -1
- package/build/assets/use-backends-health-BsZikyFW.js +1 -0
- package/build/assets/{use-can-manage-org-profiles-Ck_bsNbH.js → use-can-manage-org-profiles-Do6mYf6P.js} +1 -1
- package/build/assets/{use-cloud-current-user-id-DUCSxNjY.js → use-cloud-current-user-id-Cx3B_0-w.js} +1 -1
- package/build/assets/use-config-D9zUVw5b.js +1 -0
- package/build/assets/{use-create-conversation-r1JHfKO5.js → use-create-conversation-vvl0kvu7.js} +1 -1
- package/build/assets/{use-create-secret-Cf2N11d2.js → use-create-secret-CB7Dvd4s.js} +1 -1
- package/build/assets/use-event-store-BlpSUF7N.js +4 -0
- package/build/assets/{use-handle-plan-click-CsAW3FlH.js → use-handle-plan-click-DDZkew9p.js} +1 -1
- package/build/assets/use-is-creating-conversation-fxSzN778.js +1 -0
- package/build/assets/{use-launch-skill-in-chat-DJWEfVc5.js → use-launch-skill-in-chat-D6_n1fs3.js} +1 -1
- package/build/assets/use-llm-profiles-CNQm7HYS.js +1 -0
- package/build/assets/use-plugins-marketplace-CloojomS.js +1 -0
- package/build/assets/use-runtime-is-ready-Bx_4cfar.js +1 -0
- package/build/assets/{use-save-agent-profile-RqUGqTv6.js → use-save-agent-profile-Bj7N-1jS.js} +1 -1
- package/build/assets/{use-save-settings-Chvzeu2s.js → use-save-settings-BMsb2wk_.js} +1 -1
- package/build/assets/use-settings-B9XEmh7i.js +1 -0
- package/build/assets/use-settings-nav-items-BGfBS0yL.js +16 -0
- package/build/assets/{use-skills-xrVoKYrF.js → use-skills-CSRbvPle.js} +1 -1
- package/build/assets/{use-task-list-CfisapBW.js → use-task-list-CTIVLrQA.js} +1 -1
- package/build/assets/use-tracking-DjdCssvp.js +1 -0
- package/build/assets/{use-user-conversation-CnE4zhOA.js → use-user-conversation-BCpFn-Ei.js} +1 -1
- package/build/assets/{useTranslation-Cbf5AGg_.js → useTranslation-CHm_6BRr.js} +1 -1
- package/build/assets/{utils-DB9LsAzA.js → utils-CrRpzbM2.js} +1 -1
- package/build/assets/vendor-markdown-DzO4uO_0.js +37 -0
- package/build/assets/{vendor~browser-wXQ-WZEC.js → vendor~browser-Byfuq5J-.js} +1 -1
- package/build/assets/{vendor~browser-tab-CsMb-pta.js → vendor~browser-tab-BLk3qxhw.js} +1 -1
- package/build/assets/{vendor~entry.client~root~root-layout~index-home~home~conversation-panel~conversation~launch~dhilvkxv-eGLBu60s.js → vendor~entry.client~root~root-layout~index-home~home~conversation-panel~conversation~launch~dhilvkxv-DTJ_cjR5.js} +2 -2
- package/build/assets/{vendor~files-tab-B-5fBohe.js → vendor~files-tab-XmnauIZI.js} +1 -1
- package/build/assets/{vendor~launch-_Km3J77E.js → vendor~launch-DeC8QhXQ.js} +1 -1
- package/build/assets/{vendor~root-layout~conversation-panel~conversation~shared-conversation-BrguKXCn.js → vendor~root-layout~conversation-panel~conversation~shared-conversation-DDmLzCzm.js} +1 -1
- package/build/assets/vendor~root-layout~index-home~home~conversation-panel~conversation-YrfJYTQw.js +1 -0
- package/build/assets/{vendor~root-layout~index-home~home~conversation-panel~conversation~launch~skills-settings~a~j2jlu22h-mC0v44WR.js → vendor~root-layout~index-home~home~conversation-panel~conversation~launch~skills-settings~a~j2jlu22h-DoaS51iW.js} +123 -3
- package/build/assets/{vendor~root-layout~index-home~home~conversation-panel~conversation~shared-conversation~aler~gfu7qdtz-BOKQkbc6.js → vendor~root-layout~index-home~home~conversation-panel~conversation~shared-conversation~aler~gfu7qdtz-DEYwoy8u.js} +1 -1
- package/build/assets/vendor~root-layout~index-home~home~mcp~automations-list~onboarding-modal-DZHLw5Sr.js +1 -0
- package/build/assets/{vendor~root~root-layout~index-home~home~conversation-panel~conversation~launch~extensions-h~ftka0fnu-cFNmfAE6.js → vendor~root~root-layout~index-home~home~conversation-panel~conversation~launch~extensions-h~ftka0fnu-UJ4BNDJP.js} +1 -1
- package/build/assets/{verification-settings-CfkrXoSa.js → verification-settings-uwOfc16F.js} +1 -1
- package/build/index.html +4 -4
- package/build/locales/ar/openhands.json +38 -4
- package/build/locales/ca/openhands.json +38 -4
- package/build/locales/de/openhands.json +38 -4
- package/build/locales/en/openhands.json +38 -4
- package/build/locales/es/openhands.json +38 -4
- package/build/locales/fr/openhands.json +38 -4
- package/build/locales/it/openhands.json +38 -4
- package/build/locales/ja/openhands.json +38 -4
- package/build/locales/ko-KR/openhands.json +38 -4
- package/build/locales/no/openhands.json +38 -4
- package/build/locales/pt/openhands.json +38 -4
- package/build/locales/tr/openhands.json +38 -4
- package/build/locales/uk/openhands.json +38 -4
- package/build/locales/zh-CN/openhands.json +38 -4
- package/build/locales/zh-TW/openhands.json +38 -4
- package/config/defaults.json +7 -3
- package/dist/api/agent-canvas-updates.cjs +2 -0
- package/dist/api/agent-canvas-updates.cjs.map +1 -0
- package/dist/api/agent-canvas-updates.d.ts +7 -0
- package/dist/api/agent-canvas-updates.js +19 -0
- package/dist/api/agent-canvas-updates.js.map +1 -0
- package/dist/api/agent-server-adapter.cjs +1 -1
- package/dist/api/agent-server-adapter.cjs.map +1 -1
- package/dist/api/agent-server-adapter.d.ts +3 -0
- package/dist/api/agent-server-adapter.js +1 -0
- package/dist/api/agent-server-adapter.js.map +1 -1
- package/dist/api/agent-server-compatibility.cjs +1 -1
- package/dist/api/agent-server-compatibility.cjs.map +1 -1
- package/dist/api/agent-server-compatibility.d.ts +5 -0
- package/dist/api/agent-server-compatibility.js +24 -15
- package/dist/api/agent-server-compatibility.js.map +1 -1
- package/dist/api/agent-server-config.cjs +1 -1
- package/dist/api/agent-server-config.cjs.map +1 -1
- package/dist/api/agent-server-config.js +11 -8
- package/dist/api/agent-server-config.js.map +1 -1
- package/dist/api/automation-service/automation-service.api.cjs +2 -0
- package/dist/api/automation-service/automation-service.api.cjs.map +1 -0
- package/dist/api/automation-service/automation-service.api.d.ts +3 -0
- package/dist/api/automation-service/automation-service.api.js +283 -0
- package/dist/api/automation-service/automation-service.api.js.map +1 -0
- package/dist/api/client-source.cjs +1 -1
- package/dist/api/client-source.cjs.map +1 -1
- package/dist/api/client-source.d.ts +3 -0
- package/dist/api/client-source.js +4 -4
- package/dist/api/client-source.js.map +1 -1
- package/dist/api/cloud/settings-service.api.cjs.map +1 -1
- package/dist/api/cloud/settings-service.api.js.map +1 -1
- package/dist/api/conversation-service/agent-server-conversation-service.api.cjs +1 -1
- package/dist/api/conversation-service/agent-server-conversation-service.api.cjs.map +1 -1
- package/dist/api/conversation-service/agent-server-conversation-service.api.js +111 -109
- package/dist/api/conversation-service/agent-server-conversation-service.api.js.map +1 -1
- package/dist/api/mcp-health/mcp-health-store.cjs +2 -0
- package/dist/api/mcp-health/mcp-health-store.cjs.map +1 -0
- package/dist/api/mcp-health/mcp-health-store.d.ts +22 -0
- package/dist/api/mcp-health/mcp-health-store.js +45 -0
- package/dist/api/mcp-health/mcp-health-store.js.map +1 -0
- package/dist/api/mcp-health/probe-mcp-server-health.cjs +2 -0
- package/dist/api/mcp-health/probe-mcp-server-health.cjs.map +1 -0
- package/dist/api/mcp-health/probe-mcp-server-health.d.ts +31 -0
- package/dist/api/mcp-health/probe-mcp-server-health.js +57 -0
- package/dist/api/mcp-health/probe-mcp-server-health.js.map +1 -0
- package/dist/api/mcp-service/mcp-service.api.cjs +1 -1
- package/dist/api/mcp-service/mcp-service.api.cjs.map +1 -1
- package/dist/api/mcp-service/mcp-service.api.js +66 -46
- package/dist/api/mcp-service/mcp-service.api.js.map +1 -1
- package/dist/api/plugins-management-service.cjs.map +1 -1
- package/dist/api/plugins-management-service.d.ts +6 -1
- package/dist/api/plugins-management-service.js.map +1 -1
- package/dist/api/plugins-service.d.ts +30 -2
- package/dist/api/secrets-service.cjs +1 -1
- package/dist/api/secrets-service.cjs.map +1 -1
- package/dist/api/secrets-service.d.ts +6 -6
- package/dist/api/secrets-service.js +8 -3
- package/dist/api/secrets-service.js.map +1 -1
- package/dist/api/settings-service/settings-service.api.cjs +1 -1
- package/dist/api/settings-service/settings-service.api.cjs.map +1 -1
- package/dist/api/settings-service/settings-service.api.d.ts +1 -1
- package/dist/api/settings-service/settings-service.api.js +1 -0
- package/dist/api/settings-service/settings-service.api.js.map +1 -1
- package/dist/components/conversation-events/chat/event-message-components/critic-result-display.cjs +1 -1
- package/dist/components/conversation-events/chat/event-message-components/critic-result-display.js +5 -5
- package/dist/components/features/backends/backend-form-modal.cjs +1 -1
- package/dist/components/features/backends/backend-form-modal.cjs.map +1 -1
- package/dist/components/features/backends/backend-form-modal.d.ts +4 -1
- package/dist/components/features/backends/backend-form-modal.js +15 -16
- package/dist/components/features/backends/backend-form-modal.js.map +1 -1
- package/dist/components/features/backends/backend-selector.cjs +1 -1
- package/dist/components/features/backends/backend-selector.cjs.map +1 -1
- package/dist/components/features/backends/backend-selector.js +103 -102
- package/dist/components/features/backends/backend-selector.js.map +1 -1
- package/dist/components/features/backends/manage-backends-modal.cjs +1 -1
- package/dist/components/features/backends/manage-backends-modal.cjs.map +1 -1
- package/dist/components/features/backends/manage-backends-modal.js +85 -73
- package/dist/components/features/backends/manage-backends-modal.js.map +1 -1
- package/dist/components/features/chat/chat-interface.cjs +2 -2
- package/dist/components/features/chat/chat-interface.cjs.map +1 -1
- package/dist/components/features/chat/chat-interface.js +131 -129
- package/dist/components/features/chat/chat-interface.js.map +1 -1
- package/dist/components/features/chat/confirmation-mode-enabled.cjs +1 -1
- package/dist/components/features/chat/confirmation-mode-enabled.js +4 -4
- package/dist/components/features/chat/skill-install-restart-banner.cjs +2 -0
- package/dist/components/features/chat/skill-install-restart-banner.cjs.map +1 -0
- package/dist/components/features/chat/skill-install-restart-banner.d.ts +11 -0
- package/dist/components/features/chat/skill-install-restart-banner.js +63 -0
- package/dist/components/features/chat/skill-install-restart-banner.js.map +1 -0
- package/dist/components/features/conversation/right-panel-toggle.cjs +1 -1
- package/dist/components/features/conversation/right-panel-toggle.cjs.map +1 -1
- package/dist/components/features/conversation/right-panel-toggle.js +1 -1
- package/dist/components/features/conversation/right-panel-toggle.js.map +1 -1
- package/dist/components/features/conversation-panel/conversation-panel.cjs +1 -1
- package/dist/components/features/conversation-panel/conversation-panel.js +10 -10
- package/dist/components/features/mcp-page/custom-server-editor.cjs +1 -1
- package/dist/components/features/mcp-page/custom-server-editor.cjs.map +1 -1
- package/dist/components/features/mcp-page/custom-server-editor.js +78 -77
- package/dist/components/features/mcp-page/custom-server-editor.js.map +1 -1
- package/dist/components/features/mcp-page/install-server-modal.cjs +1 -1
- package/dist/components/features/mcp-page/install-server-modal.cjs.map +1 -1
- package/dist/components/features/mcp-page/install-server-modal.d.ts +4 -1
- package/dist/components/features/mcp-page/install-server-modal.js +135 -136
- package/dist/components/features/mcp-page/install-server-modal.js.map +1 -1
- package/dist/components/features/mcp-page/installed-server-card.cjs +1 -1
- package/dist/components/features/mcp-page/installed-server-card.cjs.map +1 -1
- package/dist/components/features/mcp-page/installed-server-card.js +40 -34
- package/dist/components/features/mcp-page/installed-server-card.js.map +1 -1
- package/dist/components/features/mcp-page/mcp-server-health.cjs +2 -0
- package/dist/components/features/mcp-page/mcp-server-health.cjs.map +1 -0
- package/dist/components/features/mcp-page/mcp-server-health.d.ts +18 -0
- package/dist/components/features/mcp-page/mcp-server-health.js +117 -0
- package/dist/components/features/mcp-page/mcp-server-health.js.map +1 -0
- package/dist/components/features/plugins/build-plugins-view-model.d.ts +10 -1
- package/dist/components/features/plugins/plugin-files-section.d.ts +13 -0
- package/dist/components/features/settings/agent-canvas-update-card.cjs +2 -0
- package/dist/components/features/settings/agent-canvas-update-card.cjs.map +1 -0
- package/dist/components/features/settings/agent-canvas-update-card.d.ts +7 -0
- package/dist/components/features/settings/agent-canvas-update-card.js +170 -0
- package/dist/components/features/settings/agent-canvas-update-card.js.map +1 -0
- package/dist/components/features/settings/integrations-settings-link.cjs +2 -0
- package/dist/components/features/settings/integrations-settings-link.cjs.map +1 -0
- package/dist/components/features/settings/integrations-settings-link.d.ts +5 -0
- package/dist/components/features/settings/integrations-settings-link.js +41 -0
- package/dist/components/features/settings/integrations-settings-link.js.map +1 -0
- package/dist/components/features/settings/llm-profiles/llm-settings-local-view.cjs +1 -1
- package/dist/components/features/settings/llm-profiles/llm-settings-local-view.js +1 -1
- package/dist/components/features/settings/settings-desktop-sidebar.cjs +1 -1
- package/dist/components/features/settings/settings-desktop-sidebar.cjs.map +1 -1
- package/dist/components/features/settings/settings-desktop-sidebar.js +31 -21
- package/dist/components/features/settings/settings-desktop-sidebar.js.map +1 -1
- package/dist/components/features/settings/settings-mobile-drawer.cjs +1 -1
- package/dist/components/features/settings/settings-mobile-drawer.cjs.map +1 -1
- package/dist/components/features/settings/settings-mobile-drawer.js +40 -30
- package/dist/components/features/settings/settings-mobile-drawer.js.map +1 -1
- package/dist/components/features/skills/extensions-navigation.cjs +1 -1
- package/dist/components/features/skills/extensions-navigation.cjs.map +1 -1
- package/dist/components/features/skills/extensions-navigation.js +54 -33
- package/dist/components/features/skills/extensions-navigation.js.map +1 -1
- package/dist/config/defaults.cjs +1 -1
- package/dist/config/defaults.cjs.map +1 -1
- package/dist/config/defaults.js +7 -3
- package/dist/config/defaults.js.map +1 -1
- package/dist/constants/acp-providers.cjs.map +1 -1
- package/dist/constants/acp-providers.js.map +1 -1
- package/dist/contexts/conversation-websocket-context.cjs +2 -2
- package/dist/contexts/conversation-websocket-context.cjs.map +1 -1
- package/dist/contexts/conversation-websocket-context.js +169 -166
- package/dist/contexts/conversation-websocket-context.js.map +1 -1
- package/dist/hooks/mutation/use-delete-llm-profile.cjs +1 -1
- package/dist/hooks/mutation/use-delete-llm-profile.js +1 -0
- package/dist/hooks/mutation/use-delete-mcp-server.cjs +1 -1
- package/dist/hooks/mutation/use-delete-mcp-server.cjs.map +1 -1
- package/dist/hooks/mutation/use-delete-mcp-server.js +8 -6
- package/dist/hooks/mutation/use-delete-mcp-server.js.map +1 -1
- package/dist/hooks/mutation/use-rename-llm-profile.cjs +1 -1
- package/dist/hooks/mutation/use-rename-llm-profile.js +1 -0
- package/dist/hooks/mutation/use-save-settings.cjs +1 -1
- package/dist/hooks/mutation/use-save-settings.js +3 -3
- package/dist/hooks/mutation/use-update-mcp-server.cjs +1 -1
- package/dist/hooks/mutation/use-update-mcp-server.cjs.map +1 -1
- package/dist/hooks/mutation/use-update-mcp-server.js +11 -9
- package/dist/hooks/mutation/use-update-mcp-server.js.map +1 -1
- package/dist/hooks/query/query-keys.cjs +1 -1
- package/dist/hooks/query/query-keys.cjs.map +1 -1
- package/dist/hooks/query/query-keys.d.ts +4 -0
- package/dist/hooks/query/query-keys.js +2 -2
- package/dist/hooks/query/query-keys.js.map +1 -1
- package/dist/hooks/query/use-automation-sdk-version.cjs +2 -0
- package/dist/hooks/query/use-automation-sdk-version.cjs.map +1 -0
- package/dist/hooks/query/use-automation-sdk-version.d.ts +3 -0
- package/dist/hooks/query/use-automation-sdk-version.js +63 -0
- package/dist/hooks/query/use-automation-sdk-version.js.map +1 -0
- package/dist/hooks/query/use-latest-agent-canvas-version.cjs +2 -0
- package/dist/hooks/query/use-latest-agent-canvas-version.cjs.map +1 -0
- package/dist/hooks/query/use-latest-agent-canvas-version.d.ts +10 -0
- package/dist/hooks/query/use-latest-agent-canvas-version.js +19 -0
- package/dist/hooks/query/use-latest-agent-canvas-version.js.map +1 -0
- package/dist/hooks/query/use-plugin-file-content.d.ts +7 -0
- package/dist/hooks/query/use-resolved-workspaces.cjs +1 -1
- package/dist/hooks/query/use-resolved-workspaces.cjs.map +1 -1
- package/dist/hooks/query/use-resolved-workspaces.js +25 -26
- package/dist/hooks/query/use-resolved-workspaces.js.map +1 -1
- package/dist/hooks/query/use-search-subdirs.cjs +1 -1
- package/dist/hooks/query/use-search-subdirs.cjs.map +1 -1
- package/dist/hooks/query/use-search-subdirs.d.ts +5 -0
- package/dist/hooks/query/use-search-subdirs.js +16 -4
- package/dist/hooks/query/use-search-subdirs.js.map +1 -1
- package/dist/hooks/query/use-task-polling.cjs +1 -1
- package/dist/hooks/query/use-task-polling.cjs.map +1 -1
- package/dist/hooks/query/use-task-polling.d.ts +19 -3
- package/dist/hooks/query/use-task-polling.js +36 -35
- package/dist/hooks/query/use-task-polling.js.map +1 -1
- package/dist/hooks/use-device-flow.cjs +1 -1
- package/dist/hooks/use-device-flow.js +6 -6
- package/dist/hooks/use-llm-configured.cjs +1 -1
- package/dist/hooks/use-llm-configured.js +3 -3
- package/dist/hooks/use-mcp-server-health.cjs +2 -0
- package/dist/hooks/use-mcp-server-health.cjs.map +1 -0
- package/dist/hooks/use-mcp-server-health.d.ts +11 -0
- package/dist/hooks/use-mcp-server-health.js +18 -0
- package/dist/hooks/use-mcp-server-health.js.map +1 -0
- package/dist/hooks/use-skill-installs.cjs +2 -0
- package/dist/hooks/use-skill-installs.cjs.map +1 -0
- package/dist/hooks/use-skill-installs.d.ts +10 -0
- package/dist/hooks/use-skill-installs.js +21 -0
- package/dist/hooks/use-skill-installs.js.map +1 -0
- package/dist/hooks/use-tracking.cjs +1 -1
- package/dist/hooks/use-tracking.cjs.map +1 -1
- package/dist/hooks/use-tracking.d.ts +3 -3
- package/dist/hooks/use-tracking.js +67 -52
- package/dist/hooks/use-tracking.js.map +1 -1
- package/dist/i18n/declaration.cjs +1 -1
- package/dist/i18n/declaration.cjs.map +1 -1
- package/dist/i18n/declaration.d.ts +35 -1
- package/dist/i18n/declaration.js +1 -1
- package/dist/i18n/declaration.js.map +1 -1
- package/dist/i18n/translation.cjs +3 -3
- package/dist/i18n/translation.cjs.map +1 -1
- package/dist/i18n/translation.js +623 -45
- package/dist/i18n/translation.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -2
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.js +0 -1
- package/dist/locales/ar/openhands.json +38 -4
- package/dist/locales/ca/openhands.json +38 -4
- package/dist/locales/de/openhands.json +38 -4
- package/dist/locales/en/openhands.json +38 -4
- package/dist/locales/es/openhands.json +38 -4
- package/dist/locales/fr/openhands.json +38 -4
- package/dist/locales/it/openhands.json +38 -4
- package/dist/locales/ja/openhands.json +38 -4
- package/dist/locales/ko-KR/openhands.json +38 -4
- package/dist/locales/no/openhands.json +38 -4
- package/dist/locales/pt/openhands.json +38 -4
- package/dist/locales/tr/openhands.json +38 -4
- package/dist/locales/uk/openhands.json +38 -4
- package/dist/locales/zh-CN/openhands.json +38 -4
- package/dist/locales/zh-TW/openhands.json +38 -4
- package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian-rovo.cjs +2 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian-rovo.cjs.map +1 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian-rovo.js +44 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian-rovo.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian.cjs +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian.cjs.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian.js +13 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian.js.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/github.cjs +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/github.cjs.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/github.js +21 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/github.js.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/linear.cjs +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/linear.cjs.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/linear.js +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/linear.js.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-outlook.cjs +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-outlook.cjs.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-outlook.js +13 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-outlook.js.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-teams.cjs +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-teams.cjs.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-teams.js +13 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-teams.js.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/notion.cjs +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/notion.cjs.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/notion.js +13 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/notion.js.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/onedrive.cjs +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/onedrive.cjs.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/onedrive.js +13 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/onedrive.js.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/sharepoint.cjs +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/sharepoint.cjs.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/sharepoint.js +13 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/sharepoint.js.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/slack.cjs +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/slack.cjs.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/slack.js +16 -2
- package/dist/node_modules/@openhands/extensions/integrations/catalog/slack.js.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/vanta.cjs +2 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/vanta.cjs.map +1 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/vanta.js +46 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/vanta.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog-index.cjs +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog-index.cjs.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog-index.js +74 -70
- package/dist/node_modules/@openhands/extensions/integrations/catalog-index.js.map +1 -1
- package/dist/node_modules/@openhands/extensions/skills/index.cjs +123 -3
- package/dist/node_modules/@openhands/extensions/skills/index.cjs.map +1 -1
- package/dist/node_modules/@openhands/extensions/skills/index.js +7 -1
- package/dist/node_modules/@openhands/extensions/skills/index.js.map +1 -1
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.cjs +2 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.cjs.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.js +9 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.js.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/info.cjs +2 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/info.cjs.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/info.js +21 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/info.js.map +1 -0
- package/dist/package.cjs +1 -1
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +10 -3
- package/dist/package.js.map +1 -1
- package/dist/routes/app-settings.cjs +1 -1
- package/dist/routes/app-settings.cjs.map +1 -1
- package/dist/routes/app-settings.js +113 -67
- package/dist/routes/app-settings.js.map +1 -1
- package/dist/routes/conversation.cjs +1 -1
- package/dist/routes/conversation.cjs.map +1 -1
- package/dist/routes/conversation.js +1 -1
- package/dist/routes/conversation.js.map +1 -1
- package/dist/routes/mcp.cjs +1 -1
- package/dist/routes/mcp.cjs.map +1 -1
- package/dist/routes/mcp.js +1 -0
- package/dist/routes/mcp.js.map +1 -1
- package/dist/services/cloud-funnel-analytics.cjs +1 -1
- package/dist/services/cloud-funnel-analytics.cjs.map +1 -1
- package/dist/services/cloud-funnel-analytics.d.ts +2 -2
- package/dist/services/cloud-funnel-analytics.js +18 -16
- package/dist/services/cloud-funnel-analytics.js.map +1 -1
- package/dist/services/settings.cjs +1 -1
- package/dist/services/settings.cjs.map +1 -1
- package/dist/services/settings.js +1 -0
- package/dist/services/settings.js.map +1 -1
- package/dist/services/telemetry-context.cjs +2 -0
- package/dist/services/telemetry-context.cjs.map +1 -0
- package/dist/services/telemetry-context.d.ts +17 -0
- package/dist/services/telemetry-context.js +27 -0
- package/dist/services/telemetry-context.js.map +1 -0
- package/dist/services/telemetry.cjs +1 -1
- package/dist/services/telemetry.cjs.map +1 -1
- package/dist/services/telemetry.d.ts +7 -5
- package/dist/services/telemetry.js +132 -123
- package/dist/services/telemetry.js.map +1 -1
- package/dist/stores/skill-install-banner-store.cjs +2 -0
- package/dist/stores/skill-install-banner-store.cjs.map +1 -0
- package/dist/stores/skill-install-banner-store.d.ts +32 -0
- package/dist/stores/skill-install-banner-store.js +14 -0
- package/dist/stores/skill-install-banner-store.js.map +1 -0
- package/dist/stores/use-event-store.cjs +1 -1
- package/dist/stores/use-event-store.cjs.map +1 -1
- package/dist/stores/use-event-store.js +35 -35
- package/dist/stores/use-event-store.js.map +1 -1
- package/dist/types/mcp-health.cjs +2 -0
- package/dist/types/mcp-health.cjs.map +1 -0
- package/dist/types/mcp-health.d.ts +21 -0
- package/dist/types/mcp-health.js +6 -0
- package/dist/types/mcp-health.js.map +1 -0
- package/dist/types/settings.d.ts +1 -0
- package/dist/utils/handle-event-for-ui.cjs +1 -1
- package/dist/utils/handle-event-for-ui.cjs.map +1 -1
- package/dist/utils/handle-event-for-ui.d.ts +5 -0
- package/dist/utils/handle-event-for-ui.js +71 -57
- package/dist/utils/handle-event-for-ui.js.map +1 -1
- package/dist/utils/mcp-credential-validation.cjs +1 -1
- package/dist/utils/mcp-credential-validation.cjs.map +1 -1
- package/dist/utils/mcp-credential-validation.js +32 -16
- package/dist/utils/mcp-credential-validation.js.map +1 -1
- package/dist/utils/mcp-server-health-key.cjs +2 -0
- package/dist/utils/mcp-server-health-key.cjs.map +1 -0
- package/dist/utils/mcp-server-health-key.d.ts +16 -0
- package/dist/utils/mcp-server-health-key.js +23 -0
- package/dist/utils/mcp-server-health-key.js.map +1 -0
- package/dist/utils/mcp-test-error-message.cjs +2 -0
- package/dist/utils/mcp-test-error-message.cjs.map +1 -0
- package/dist/utils/mcp-test-error-message.d.ts +8 -0
- package/dist/utils/mcp-test-error-message.js +14 -0
- package/dist/utils/mcp-test-error-message.js.map +1 -0
- package/dist/utils/redact-mcp-secrets.cjs +2 -0
- package/dist/utils/redact-mcp-secrets.cjs.map +1 -0
- package/dist/utils/redact-mcp-secrets.d.ts +13 -0
- package/dist/utils/redact-mcp-secrets.js +57 -0
- package/dist/utils/redact-mcp-secrets.js.map +1 -0
- package/dist/utils/settings-utils.cjs.map +1 -1
- package/dist/utils/settings-utils.js.map +1 -1
- package/dist/utils/skill-install-events.cjs +3 -0
- package/dist/utils/skill-install-events.cjs.map +1 -0
- package/dist/utils/skill-install-events.d.ts +16 -0
- package/dist/utils/skill-install-events.js +26 -0
- package/dist/utils/skill-install-events.js.map +1 -0
- package/dist/utils/title-llm-profile.cjs +2 -0
- package/dist/utils/title-llm-profile.cjs.map +1 -0
- package/dist/utils/title-llm-profile.d.ts +2 -0
- package/dist/utils/title-llm-profile.js +11 -0
- package/dist/utils/title-llm-profile.js.map +1 -0
- package/package.json +10 -3
- package/scripts/check-sdk-version-sync.mjs +6 -6
- package/scripts/check-translation-completeness.cjs +2 -0
- package/scripts/dev-process-utils.mjs +62 -1
- package/scripts/dev-safe.mjs +2 -2
- package/scripts/dev-static.mjs +5 -3
- package/scripts/dev-with-automation.mjs +98 -14
- package/scripts/download-node.mjs +382 -0
- package/scripts/download-uv.mjs +204 -0
- package/scripts/logger.mjs +64 -35
- package/build/assets/agent-server-compatibility-BWN-EIQn.js +0 -1
- package/build/assets/agent-server-conversation-service.api-DSPIkMwJ.js +0 -41
- package/build/assets/agent-settings-CgCnqaAA.js +0 -2
- package/build/assets/agent-settings-DDkSavD7.js +0 -1
- package/build/assets/api-key-entry-screen-iZc7n8AI.js +0 -1
- package/build/assets/app-settings-B5zyipxJ.js +0 -1
- package/build/assets/automation-export-BwRX6H32.js +0 -2
- package/build/assets/automations-list-lHAVzMoA.js +0 -1
- package/build/assets/backend-form-modal-RGcu909r.js +0 -1
- package/build/assets/browser-store-BI6uklCG.js +0 -1
- package/build/assets/chat-send-button-BZHG2hAW.js +0 -1
- package/build/assets/client-source-BZK8vRs2.js +0 -1
- package/build/assets/cloud-funnel-analytics-Zcv57hfT.js +0 -1
- package/build/assets/conversation-BoCYx8n2.js +0 -89
- package/build/assets/conversation-DgHqMjnY.js +0 -1
- package/build/assets/conversation-panel-78Rxh_-I.js +0 -1
- package/build/assets/conversation-state-store-B2Bp32XI.js +0 -1
- package/build/assets/declaration-BGsHjPEW.js +0 -1
- package/build/assets/extensions-hub-CCbLA7IM.js +0 -1
- package/build/assets/extensions-navigation-CPNjMNvR.js +0 -1
- package/build/assets/files-tab-store-DJsPxYdg.js +0 -1
- package/build/assets/files-tab-y4K7EXBO.js +0 -1
- package/build/assets/git-provider-icon-ITvsH4Ko.js +0 -1
- package/build/assets/home-BwbeOWwU.js +0 -1
- package/build/assets/home-DKPGQ5P3.js +0 -1
- package/build/assets/index-home-Bko2Itv5.js +0 -1
- package/build/assets/install-server-modal-Qk1gwyI8.js +0 -1
- package/build/assets/lesson-plan-DMCPdtrf.js +0 -4
- package/build/assets/llm-not-configured-banner-C1ktyb3C.js +0 -27
- package/build/assets/llm-settings-BBsZFi9l.js +0 -1
- package/build/assets/llm-settings-DFkJQr_w.js +0 -1
- package/build/assets/manage-backends-modal-CKQ46rvw.js +0 -1
- package/build/assets/manifest-03478bbf.js +0 -1
- package/build/assets/markdown-renderer-B4V2OMFP.js +0 -2
- package/build/assets/mcp-BapoJsDc.js +0 -9
- package/build/assets/messages-CUBFMY5o.js +0 -40
- package/build/assets/objectWithoutPropertiesLoose-BgYIAs2y.js +0 -1
- package/build/assets/onboarding-6NMkdNxV.js +0 -1
- package/build/assets/onboarding-modal-Q4AnpIdg.js +0 -1
- package/build/assets/recommended-automations-launcher-Bj7PuHY1.js +0 -58
- package/build/assets/refresh-cw-B9B7-vsy.js +0 -1
- package/build/assets/root-CDnuTToz.js +0 -2
- package/build/assets/root-CYWeTrWE.css +0 -1
- package/build/assets/root-layout-DfYVlcRG.js +0 -2
- package/build/assets/sdk-section-page-DLLNrYjI.js +0 -1
- package/build/assets/secrets-settings-CHy72A5C.js +0 -1
- package/build/assets/settings-B9S8UVQr.js +0 -1
- package/build/assets/settings-index-BKDl2CQ-.js +0 -1
- package/build/assets/settings-modal-DeK11CyT.js +0 -1
- package/build/assets/shared-conversation-9atDzTR4.js +0 -1
- package/build/assets/sidebar-mobile-menu-toggle-giMMZctn.js +0 -1
- package/build/assets/skills-plugins-Tropusio.js +0 -1
- package/build/assets/skills-settings-BvzBBCWk.js +0 -2
- package/build/assets/telemetry-C5JMEfqB.js +0 -2
- package/build/assets/use-activate-agent-profile-DlykqEfN.js +0 -1
- package/build/assets/use-backends-health-CLHPitJM.js +0 -1
- package/build/assets/use-config-B5r8erYt.js +0 -1
- package/build/assets/use-event-store-Bbaz51GR.js +0 -4
- package/build/assets/use-llm-profiles-Dr5__SlZ.js +0 -1
- package/build/assets/use-plugins-marketplace-BplU65ae.js +0 -1
- package/build/assets/use-runtime-is-ready-vCFOcLFa.js +0 -1
- package/build/assets/use-settings-CyxSlyTQ.js +0 -1
- package/build/assets/use-settings-nav-items-zEkSO_Bf.js +0 -16
- package/build/assets/use-tracking-D2Qg5Lpd.js +0 -1
- package/build/assets/useMutationState-OnAsCLA_.js +0 -1
- package/build/assets/vendor~index-home~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-BD7v71DM.js +0 -2
- package/build/assets/vendor~index-home~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-BT05Osu4.js +0 -28
- package/build/assets/vendor~index-home~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-COhHANvV.js +0 -2
- package/build/assets/vendor~index-home~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-DgzWSMRc.js +0 -2
- package/build/assets/vendor~index-home~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-DqZatR3B.js +0 -7
- package/build/assets/vendor~index-home~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-FghQ3Z1a.js +0 -1
- package/build/assets/vendor~root-layout~index-home~home~conversation-panel~conversation-BTvhGHHG.js +0 -1
- package/build/assets/vendor~root-layout~index-home~home~mcp~automations-list~onboarding-modal-C4-GDgiF.js +0 -1
- package/dist/components/features/analytics/telemetry-consent-banner.cjs +0 -2
- package/dist/components/features/analytics/telemetry-consent-banner.cjs.map +0 -1
- package/dist/components/features/analytics/telemetry-consent-banner.d.ts +0 -29
- package/dist/components/features/analytics/telemetry-consent-banner.js +0 -59
- package/dist/components/features/analytics/telemetry-consent-banner.js.map +0 -1
- /package/build/assets/{__vite-browser-external-BQUj0sYu.js → __vite-browser-external-CKHVBTNC.js} +0 -0
- /package/build/assets/{agent-server-ui-style-scope-qhnhZHBV.js → agent-server-ui-style-scope-BvSa9on7.js} +0 -0
- /package/build/assets/{automation-LZB0MjdV.js → automation-BGiPmxFR.js} +0 -0
- /package/build/assets/{canvas-ui-COgjltGz.js → canvas-ui-CC4EJo-H.js} +0 -0
- /package/build/assets/{checkmark-h7udgXMM.js → checkmark-ygQB1AtV.js} +0 -0
- /package/build/assets/{close-DLFb5kfv.js → close-BjSA0HWT.js} +0 -0
- /package/build/assets/{code-tag-DYlAhEQY.js → code-tag-D9aPPbOe.js} +0 -0
- /package/build/assets/{common-CxbUL3nR.js → common-CCuqQy_S.js} +0 -0
- /package/build/assets/{conversation-local-storage-F6zVMM--.js → conversation-local-storage-BDjWPg0Z.js} +0 -0
- /package/build/assets/{copy-BLmGeJcd.js → copy-Dce7sOvS.js} +0 -0
- /package/build/assets/{copy-D1YGjP-C.js → copy-iPJAncAj.js} +0 -0
- /package/build/assets/{dist-CodhvuAP.js → dist-D9PhjOaq.js} +0 -0
- /package/build/assets/{environment-switch-store-DkjlKWzN.js → environment-switch-store-DHfcz4M4.js} +0 -0
- /package/build/assets/{extension-module-card-classes-9V3J9J_b.js → extension-module-card-classes-BpebKiN6.js} +0 -0
- /package/build/assets/{external-link-lhdITPqq.js → external-link-CpPMXxrV.js} +0 -0
- /package/build/assets/{folder-Bk311brm.js → folder-BabbYnbF.js} +0 -0
- /package/build/assets/{format-time-delta-DhDbkD7V.js → format-time-delta-BkAmJEPT.js} +0 -0
- /package/build/assets/{get-language-from-path-DBqBsCWH.js → get-language-from-path-CPNnuVhI.js} +0 -0
- /package/build/assets/{git-status-mapper-DnL9OC8_.js → git-status-mapper-BIXK0AAG.js} +0 -0
- /package/build/assets/{iconBase-Dz51Zn5x.js → iconBase-Ch-fOe8B.js} +0 -0
- /package/build/assets/{link-external-CaBmUEs_.js → link-external-DfKQroKX.js} +0 -0
- /package/build/assets/{list-todo-CAtvkzcy.js → list-todo-6J6zc8oS.js} +0 -0
- /package/build/assets/{llm-subscription-DtsX5Lhg.js → llm-subscription-Bvu8BLXc.js} +0 -0
- /package/build/assets/{loader-circle-CsAsfLIs.js → loader-circle-DGsqG5qw.js} +0 -0
- /package/build/assets/{map-provider-BbIb12oh.js → map-provider-BSvXvVR0.js} +0 -0
- /package/build/assets/{middleware-DYHYNAnP.js → middleware-_izt7V6U.js} +0 -0
- /package/build/assets/{modal-backdrop-zVwfOJZr.js → modal-backdrop-B7H42xHG.js} +0 -0
- /package/build/assets/{navigation-context-DPs2G0X8.js → navigation-context-cvyvI1WA.js} +0 -0
- /package/build/assets/{openhands-logo-bcNw5bkY.js → openhands-logo-pEw0nKFP.js} +0 -0
- /package/build/assets/{pencil-CWhApFIT.js → pencil-DmSqWUA3.js} +0 -0
- /package/build/assets/{react-DPDgL6du.js → react-MKQOkha9.js} +0 -0
- /package/build/assets/{search-BgOCR7_c.js → search-B5D5EuSn.js} +0 -0
- /package/build/assets/{search-dIQ09UY2.js → search-vnYL5jwV.js} +0 -0
- /package/build/assets/{settings-gear-MXCyZW0x.js → settings-gear-BOwF59Bs.js} +0 -0
- /package/build/assets/{settings-section-header-context-COMOIaxV.js → settings-section-header-context-CGgHZXrf.js} +0 -0
- /package/build/assets/{skills-EqzxYBvT.js → skills-arUOHLcS.js} +0 -0
- /package/build/assets/{square-chevron-right-DE-JN-2Z.js → square-chevron-right-EizCGtgq.js} +0 -0
- /package/build/assets/{switch-skeleton-DqQwalyu.js → switch-skeleton-BjPRx1QD.js} +0 -0
- /package/build/assets/{terminal-Cgf___rK.js → terminal-a57bHgZs.js} +0 -0
- /package/build/assets/{trash-2-BU6BlW4i.js → trash-2-CF3hilrY.js} +0 -0
- /package/build/assets/{u-check-circle-BqoIxNz_.js → u-check-circle-WGqHdtfO.js} +0 -0
- /package/build/assets/{u-check-circle-half-MsShT8Ec.js → u-check-circle-half-LiwZkuFe.js} +0 -0
- /package/build/assets/{u-edit-DL5LgKon.js → u-edit-BwHepAPi.js} +0 -0
- /package/build/assets/{use-breakpoint-BP3lqLMx.js → use-breakpoint-B-O0lQ84.js} +0 -0
- /package/build/assets/{use-click-outside-element-D9BYdANT.js → use-click-outside-element-DLQIMQrz.js} +0 -0
- /package/build/assets/{use-is-authed-BezEyfeh.js → use-is-authed-BSeo4coy.js} +0 -0
- /package/build/assets/{use-onboarding-completion-C_Swglzp.js → use-onboarding-completion-C0hPNGpw.js} +0 -0
- /package/build/assets/{v4-DbCkTSoU.js → v4-q4yWTlMz.js} +0 -0
- /package/build/assets/{vendor~browser-By2MVv_N.js → vendor~browser-UwB1jbAZ.js} +0 -0
- /package/build/assets/{vendor~conversation-panel~conversation~alert-banner-CxfzCmkN.js → vendor~conversation-panel~conversation~alert-banner-DHDkknt5.js} +0 -0
- /package/build/assets/{vendor~index-home~home~conversation-panel~conversation-ChmYLVgz.js → vendor~index-home~home~conversation-panel~conversation-Bff9cq5J.js} +0 -0
- /package/build/assets/{vendor~module-D5a_AClf.js → vendor~module-D4DeFV4J.js} +0 -0
- /package/build/assets/{vendor~terminal-CnKZILnC.js → vendor~terminal-B7Eiak0-.js} +0 -0
- /package/build/assets/{x-ZE4iplpF.js → x-DQB_00VJ.js} +0 -0
- /package/build/assets/{x-mark-Batp6gXa.js → x-mark-B32XuEwS.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-service.api.cjs","names":[],"sources":["../../../src/api/settings-service/settings-service.api.ts"],"sourcesContent":["import { SettingsClient } from \"@openhands/typescript-client/clients\";\nimport { DEFAULT_SETTINGS } from \"#/services/settings\";\nimport { Settings, SettingsSchema, SettingsValue } from \"#/types/settings\";\nimport {\n getSdkMcpServerMap,\n hasRedactedMcpSecretLeaf,\n stringRecord,\n} from \"#/utils/mcp-config\";\nimport { getActiveBackend } from \"../backend-registry/active-store\";\nimport {\n fetchCloudConversationSettingsSchema,\n fetchCloudSettings,\n fetchCloudSettingsSchema,\n saveCloudSettings,\n} from \"../cloud/settings-service.api\";\nimport { getAgentServerClientOptions } from \"../agent-server-client-options\";\n\n/**\n * Fields the agent-server stores under `misc_settings.app_preferences` (see\n * SDK `openhands.sdk.settings.AppPreferences`). Mirrored here as a flat\n * partial of Settings so the rest of the frontend can keep treating them as\n * top-level keys (`settings.language`, `settings.disabled_skills`, …).\n */\nexport const APP_PREFERENCE_FIELDS = [\n \"language\",\n \"user_consents_to_analytics\",\n \"enable_sound_notifications\",\n \"git_user_name\",\n \"git_user_email\",\n \"disabled_skills\",\n] as const;\n\nexport type AppPreferenceField = (typeof APP_PREFERENCE_FIELDS)[number];\n\nexport type AppPreferences = Partial<Pick<Settings, AppPreferenceField>>;\n\n/**\n * Container for frontend-owned settings the agent doesn't interpret.\n * Mirrors the SDK `MiscSettings` model introduced in agent-server 1.27.\n *\n * Single nested category today (`app_preferences`). Adding a future\n * category (e.g. `ui_preferences`) is a non-breaking change for the wire\n * shape — it just adds another optional sibling here.\n */\nexport interface MiscSettings {\n app_preferences?: AppPreferences;\n}\n\n/**\n * Response from GET /api/settings\n * Mirrors the SettingsResponse model in the agent server.\n */\nexport interface SettingsApiResponse {\n agent_settings: Record<string, SettingsValue>;\n conversation_settings: Record<string, SettingsValue>;\n llm_api_key_is_set: boolean;\n /**\n * Frontend-owned settings the agent does not interpret (currently just\n * `app_preferences`). Added in agent-server 1.27; earlier servers omit\n * the field entirely, in which case the frontend falls back to defaults.\n */\n misc_settings?: MiscSettings;\n}\n\n/**\n * Request payload for PATCH /api/settings.\n *\n * `misc_settings_diff` is deep-merged into the persisted `misc_settings`\n * block, matching the semantics of `agent_settings_diff` /\n * `conversation_settings_diff`. A partial diff like\n * `{ app_preferences: { language: \"fr\" } }` updates only `language` and\n * leaves every other `app_preferences` field alone. Lists\n * (`disabled_skills`) are replaced wholesale rather than merged.\n */\nexport interface SettingsUpdateRequest {\n agent_settings_diff?: Record<string, SettingsValue>;\n conversation_settings_diff?: Record<string, SettingsValue>;\n misc_settings_diff?: MiscSettings;\n // Permit additional keys so this stays assignable to the underlying\n // typescript-client SDK type, which uses `[key: string]: unknown` for\n // forward compatibility.\n [key: string]: unknown;\n}\n\nconst APP_PREFERENCE_FIELD_SET: ReadonlySet<string> = new Set(\n APP_PREFERENCE_FIELDS,\n);\n\nconst isAppPreferenceField = (key: string): key is AppPreferenceField =>\n APP_PREFERENCE_FIELD_SET.has(key);\n\n/**\n * Split known app-preference keys out of a save payload so callers can\n * route them through `misc_settings_diff.app_preferences` (local) or as\n * flat top-level keys (cloud), while the remaining fields flow into the\n * `agent_settings_diff` / `conversation_settings_diff` branches.\n */\nconst extractAppPreferences = (\n input: Record<string, unknown>,\n): { extracted: AppPreferences; rest: Record<string, unknown> } => {\n const extracted: AppPreferences = {};\n const rest: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(input)) {\n if (isAppPreferenceField(key)) {\n (extracted as Record<string, unknown>)[key] = value;\n } else {\n rest[key] = value;\n }\n }\n return { extracted, rest };\n};\n\n/**\n * Secret exposure mode for X-Expose-Secrets header.\n *\n * - undefined: Returns redacted secrets (\"**********\")\n * - \"encrypted\": Returns cipher-encrypted values (safe for frontend to round-trip)\n * - \"plaintext\": Returns raw secret values (backend use only!)\n */\nexport type ExposeSecretsMode = \"encrypted\" | \"plaintext\" | undefined;\n\nconst deepClone = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T;\n\nconst mergeRecords = (\n base: Record<string, SettingsValue> | null | undefined,\n next: Record<string, SettingsValue> | null | undefined,\n) => ({ ...(base ?? {}), ...(next ?? {}) });\n\n/**\n * Retry helper for API calls with exponential backoff.\n */\nasync function withRetry<T>(\n fn: () => Promise<T>,\n maxRetries: number = 3,\n baseDelayMs: number = 500,\n): Promise<T> {\n for (let attempt = 0; attempt < maxRetries; attempt += 1) {\n try {\n return await fn();\n } catch (error) {\n if (attempt >= maxRetries - 1) {\n throw error;\n }\n\n const delay = baseDelayMs * 2 ** attempt;\n\n await new Promise<void>((resolve) => {\n setTimeout(resolve, delay);\n });\n }\n }\n\n throw new Error(\"Retry attempts exhausted\");\n}\n\n/**\n * In-memory cache for settings to avoid repeated network calls.\n * The cache is invalidated on save operations.\n */\nlet settingsCache: {\n /** Settings with redacted secrets for display */\n redacted: SettingsApiResponse | null;\n /** Settings with encrypted secrets for conversation start */\n encrypted: SettingsApiResponse | null;\n /** Timestamp when the cache was last populated */\n timestamp: number;\n} = {\n redacted: null,\n encrypted: null,\n timestamp: 0,\n};\n\nconst CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes\n\nconst isCacheValid = () => Date.now() - settingsCache.timestamp < CACHE_TTL_MS;\n\nconst clearCache = () => {\n settingsCache = { redacted: null, encrypted: null, timestamp: 0 };\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === \"object\" && !Array.isArray(value);\n\nconst basicAuthHeader = (username: string, password: string): string => {\n const token = btoa(`${username}:${password}`);\n return `Basic ${token}`;\n};\n\nconst headersFromMcpAuth = (\n auth: Record<string, unknown>,\n): Record<string, string> | null => {\n switch (auth.strategy) {\n case \"none\":\n return {};\n case \"api_key\": {\n if (typeof auth.value !== \"string\" || !auth.value) return null;\n const header =\n typeof auth.header_name === \"string\" && auth.header_name\n ? auth.header_name\n : \"Authorization\";\n const value =\n header === \"Authorization\" ? `Bearer ${auth.value}` : auth.value;\n return { [header]: value };\n }\n case \"bearer\":\n if (typeof auth.value !== \"string\" || !auth.value) return null;\n return { Authorization: `Bearer ${auth.value}` };\n case \"basic\":\n if (\n typeof auth.username !== \"string\" ||\n typeof auth.password !== \"string\"\n ) {\n return null;\n }\n return { Authorization: basicAuthHeader(auth.username, auth.password) };\n case \"header\":\n return stringRecord(auth.headers) ?? {};\n case \"oauth2\": {\n const tokens = isRecord(auth.state) ? auth.state.tokens : undefined;\n if (!isRecord(tokens) || typeof tokens.access_token !== \"string\") {\n return null;\n }\n return { Authorization: `Bearer ${tokens.access_token}` };\n }\n default:\n return null;\n }\n};\n\nconst cloudCompatibleMcpConfig = (value: unknown): unknown => {\n if (!isRecord(value)) return value;\n\n const hasWrapper = isRecord(value.mcpServers);\n const serverMap: Record<string, unknown> = hasWrapper\n ? (value.mcpServers as Record<string, unknown>)\n : value;\n\n const converted = Object.fromEntries(\n Object.entries(serverMap).map(([name, server]) => {\n if (!isRecord(server) || !isRecord(server.auth)) return [name, server];\n\n const authHeaders = headersFromMcpAuth(server.auth);\n if (authHeaders === null) return [name, server];\n\n const nextServer = { ...server };\n const existingHeaders = stringRecord(server.headers) ?? {};\n const mergedHeaders = { ...existingHeaders, ...authHeaders };\n delete nextServer.auth;\n if (Object.keys(mergedHeaders).length > 0) {\n nextServer.headers = mergedHeaders;\n } else {\n delete nextServer.headers;\n }\n return [name, nextServer];\n }),\n );\n\n return hasWrapper ? { ...value, mcpServers: converted } : converted;\n};\n\nconst hasRedactedMcpSecrets = (mcpConfig: unknown): boolean => {\n const servers = getSdkMcpServerMap(mcpConfig);\n if (!servers) return false;\n return Object.values(servers).some(\n (server) =>\n hasRedactedMcpSecretLeaf(isRecord(server) ? server.auth : undefined) ||\n hasRedactedMcpSecretLeaf(isRecord(server) ? server.headers : undefined) ||\n hasRedactedMcpSecretLeaf(isRecord(server) ? server.env : undefined),\n );\n};\n\nconst removesMcpServer = (previous: unknown, next: unknown): boolean => {\n const previousServers = getSdkMcpServerMap(previous);\n const nextServers = getSdkMcpServerMap(next);\n if (!previousServers || !nextServers) return false;\n return Object.keys(previousServers).some((name) => !(name in nextServers));\n};\n\n/**\n * Transform API response into Settings object with derived fields.\n */\nconst transformApiResponse = (\n response: SettingsApiResponse,\n): Partial<Settings> => {\n const agentSettings = response.agent_settings ?? {};\n const conversationSettings = response.conversation_settings ?? {};\n\n const partial: Partial<Settings> = {\n agent_settings: agentSettings,\n conversation_settings: conversationSettings,\n llm_api_key_set: response.llm_api_key_is_set,\n };\n\n // App-level user preferences come back nested under\n // `misc_settings.app_preferences` from the local agent-server (added in\n // 1.27, restructured into the `misc_settings` container in the follow-up\n // refactor). Hoist them onto the flat Settings shape the rest of the\n // frontend already speaks. Older servers omit the `misc_settings` field\n // entirely; the migration helper invoked from `getSettings` promotes any\n // leftover localStorage values to the server on first run, so the omitted\n // case just falls back to defaults.\n const prefs = response.misc_settings?.app_preferences;\n if (prefs) {\n for (const key of APP_PREFERENCE_FIELDS) {\n const value = prefs[key];\n if (value !== undefined) {\n (partial as Record<string, unknown>)[key] = value;\n }\n }\n }\n\n return partial;\n};\n\n/**\n * Sync derived settings fields from agent_settings and conversation_settings.\n * This ensures backward compatibility with code that reads top-level fields.\n */\nconst syncDerivedSettings = (settings: Partial<Settings>): Settings => {\n const agentSettings = mergeRecords(\n DEFAULT_SETTINGS.agent_settings ?? {},\n settings.agent_settings ?? {},\n );\n const conversationSettings = mergeRecords(\n DEFAULT_SETTINGS.conversation_settings ?? {},\n settings.conversation_settings ?? {},\n );\n\n const merged = {\n ...deepClone(DEFAULT_SETTINGS),\n ...settings,\n provider_tokens_set: {\n ...(DEFAULT_SETTINGS.provider_tokens_set ?? {}),\n ...(settings.provider_tokens_set ?? {}),\n },\n agent_settings: agentSettings,\n conversation_settings: conversationSettings,\n } as Settings;\n\n const llm = agentSettings.llm as Record<string, SettingsValue> | undefined;\n const condenser = agentSettings.condenser as\n | Record<string, SettingsValue>\n | undefined;\n\n if (typeof agentSettings.agent === \"string\") {\n merged.agent = agentSettings.agent;\n }\n if (typeof llm?.model === \"string\" && llm.model.length > 0) {\n merged.llm_model = llm.model;\n }\n if (typeof llm?.base_url === \"string\") {\n merged.llm_base_url = llm.base_url;\n }\n // Note: api_key may be redacted (\"**********\") when fetched without expose header\n // We don't sync it to top-level llm_api_key to avoid overwriting with redacted value\n if (typeof condenser?.enabled === \"boolean\") {\n merged.enable_default_condenser = condenser.enabled;\n }\n if (typeof condenser?.max_size === \"number\") {\n merged.condenser_max_size = condenser.max_size;\n }\n if (typeof conversationSettings.confirmation_mode === \"boolean\") {\n merged.confirmation_mode = conversationSettings.confirmation_mode;\n }\n if (\n typeof conversationSettings.security_analyzer === \"string\" ||\n conversationSettings.security_analyzer === null\n ) {\n merged.security_analyzer = conversationSettings.security_analyzer as\n | string\n | null;\n }\n if (typeof conversationSettings.max_iterations === \"number\") {\n merged.max_iterations = conversationSettings.max_iterations;\n }\n\n merged.search_api_key_set = !!merged.search_api_key;\n\n return merged;\n};\n\nclass SettingsService {\n /**\n * Fetch settings from the agent server API with retry logic.\n *\n * @param exposeSecrets - Controls how secrets are returned:\n * - undefined: Secrets are redacted (\"**********\") - safe for display\n * - \"encrypted\": Secrets are cipher-encrypted - safe for round-trip to start conversation\n * - \"plaintext\": Raw secrets - DO NOT USE from frontend\n */\n static async fetchSettingsFromApi(\n exposeSecrets?: ExposeSecretsMode,\n ): Promise<SettingsApiResponse> {\n return withRetry(() =>\n new SettingsClient(getAgentServerClientOptions()).getSettings({\n exposeSecrets,\n }),\n ) as Promise<SettingsApiResponse>;\n }\n\n /**\n * Get settings for display (secrets are redacted).\n * Uses in-memory cache for performance.\n */\n static async getSettings(): Promise<Settings> {\n // Cloud uses a different settings shape (flat top-level fields\n // including provider_tokens_set, llm_model, etc.). Branch out before\n // touching the local-only cache: cloud responses bypass the local\n // SettingsApiResponse shape and feed straight into syncDerivedSettings\n // so cloud-native fields like provider_tokens_set reach the GUI's\n // useUserProviders → useAppInstallations → useGitRepositories chain.\n if (getActiveBackend().backend.kind === \"cloud\") {\n try {\n const cloud = await withRetry(() => fetchCloudSettings());\n return syncDerivedSettings(cloud);\n } catch (error) {\n console.warn(\"Failed to fetch cloud settings, using defaults:\", error);\n return syncDerivedSettings({});\n }\n }\n\n // Check cache first\n if (isCacheValid() && settingsCache.redacted) {\n return syncDerivedSettings(transformApiResponse(settingsCache.redacted));\n }\n\n try {\n const response = await this.fetchSettingsFromApi();\n settingsCache.redacted = response;\n settingsCache.timestamp = Date.now();\n return syncDerivedSettings(transformApiResponse(response));\n } catch (error) {\n // If API fails, return defaults\n console.warn(\"Failed to fetch settings from API, using defaults:\", error);\n return syncDerivedSettings({});\n }\n }\n\n /**\n * Get settings with encrypted secrets for starting conversations.\n * The encrypted secrets can be passed to the start conversation API\n * with secrets_encrypted=true for server-side decryption.\n *\n * @throws Error if encrypted settings cannot be fetched - conversations\n * should not start with broken/redacted credentials.\n */\n static async getSettingsForConversation(): Promise<{\n agentSettings: Record<string, SettingsValue>;\n conversationSettings: Record<string, SettingsValue>;\n secretsEncrypted: boolean;\n }> {\n // Check cache first\n if (isCacheValid() && settingsCache.encrypted) {\n return {\n agentSettings: settingsCache.encrypted.agent_settings,\n conversationSettings: settingsCache.encrypted.conversation_settings,\n secretsEncrypted: true,\n };\n }\n\n // Fetch encrypted settings - this MUST succeed for conversations to work.\n // Do not fall back to redacted settings as that would cause auth failures.\n const response = await this.fetchSettingsFromApi(\"encrypted\");\n settingsCache.encrypted = response;\n if (!settingsCache.timestamp) {\n settingsCache.timestamp = Date.now();\n }\n return {\n agentSettings: response.agent_settings,\n conversationSettings: response.conversation_settings,\n secretsEncrypted: true,\n };\n }\n\n static async getSettingsSchema(): Promise<SettingsSchema> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return (await fetchCloudSettingsSchema()) as SettingsSchema;\n }\n return (await new SettingsClient(\n getAgentServerClientOptions(),\n ).getAgentSchema()) as SettingsSchema;\n }\n\n static async getConversationSettingsSchema(): Promise<SettingsSchema> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return (await fetchCloudConversationSettingsSchema()) as SettingsSchema;\n }\n return (await new SettingsClient(\n getAgentServerClientOptions(),\n ).getConversationSchema()) as SettingsSchema;\n }\n\n /**\n * Save settings to the agent server API.\n * Uses PATCH for incremental updates.\n */\n static async saveSettings(\n settings: Partial<Settings> & Record<string, unknown>,\n ): Promise<boolean> {\n // Split app-level user-preference fields (language, git identity, sound\n // notifications, analytics consent, disabled_skills) off and route them\n // through `misc_settings_diff.app_preferences` (local) or as flat\n // top-level keys (cloud). The local agent-server stores them under\n // `PersistedSettings.misc_settings.app_preferences`; the cloud accepts\n // them as flat keys on `POST /api/v1/settings`.\n const { extracted: appPreferences, rest } = extractAppPreferences(\n settings as Record<string, unknown>,\n );\n const hasAppPreferences = Object.keys(appPreferences).length > 0;\n\n const payload: SettingsUpdateRequest = {};\n\n // Extract agent_settings_diff\n const agentSettingsDiff = rest.agent_settings_diff as\n | Record<string, SettingsValue>\n | undefined;\n if (agentSettingsDiff && Object.keys(agentSettingsDiff).length > 0) {\n payload.agent_settings_diff = agentSettingsDiff;\n }\n\n // Extract conversation_settings_diff\n const conversationSettingsDiff = rest.conversation_settings_diff as\n | Record<string, SettingsValue>\n | undefined;\n if (\n conversationSettingsDiff &&\n Object.keys(conversationSettingsDiff).length > 0\n ) {\n payload.conversation_settings_diff = conversationSettingsDiff;\n }\n\n if (hasAppPreferences) {\n payload.misc_settings_diff = { app_preferences: appPreferences };\n }\n\n const isCloud = getActiveBackend().backend.kind === \"cloud\";\n\n // The backend applies ``agent_settings_diff`` by deep-merging it into the\n // existing ``agent_settings`` dict (see SDK\n // ``openhands.agent_server.persistence.models._deep_merge``). That works\n // for scalar fields but is wrong for ``mcp_config``, which is\n // a name-keyed map: a diff that omits a server cannot remove it (stale\n // key stays), and a diff whose key indices shift (e.g. after deleting\n // index 0, the second server is renumbered) leaves the original keys\n // behind as duplicates pointing to the wrong server config.\n //\n // The only way to make ``mcp_config`` behave like a replace through this\n // API is to first null it out — ``null`` is not a dict, so deep-merge\n // takes the else branch and sets the field to ``None`` outright — and\n // then send the new value in a follow-up call. We do this for every\n // ``mcp_config`` write, including adds (the wasted round-trip is\n // negligible for this user action and avoids divergent code paths).\n const agentDiff = payload.agent_settings_diff;\n // Send a pre-clear PATCH when the diff sets ``mcp_config`` to a non-null\n // value. A second PATCH below then writes the new value. Skipping the\n // pre-clear when the caller is already clearing (``mcp_config: null``)\n // avoids a pointless duplicate request.\n const needsMcpPreClear =\n !!agentDiff && \"mcp_config\" in agentDiff && agentDiff.mcp_config !== null;\n\n // The pre-clear is destructive: if the follow-up write fails after the\n // clear succeeds, the user's MCP config is left empty. Snapshot the\n // previous value (in raw SDK-native shape, NOT the GUI's parsed MCPConfig)\n // before pre-clearing so we can attempt a best-effort rollback. The\n // original write error is always re-thrown to the caller regardless\n // of rollback success — the GUI's react-query mutations surface that\n // as an error toast so the user knows to retry.\n //\n // Snapshot must be the SDK-native server map because that is what the\n // backend expects on the rollback PATCH.\n // ``SettingsService.getSettings`` returns a GUI Settings object whose\n // ``mcp_config`` is typed as the parsed frontend MCPConfig and\n // defaults to empty arrays when nothing is installed, so it is not\n // suitable for round-tripping back to the backend.\n let mcpConfigSnapshot: unknown = undefined;\n if (needsMcpPreClear) {\n try {\n if (isCloud) {\n const raw = (await fetchCloudSettings()) as {\n agent_settings?: { mcp_config?: unknown };\n };\n mcpConfigSnapshot = raw?.agent_settings?.mcp_config;\n } else {\n const raw = (await SettingsService.fetchSettingsFromApi()) as {\n agent_settings?: { mcp_config?: unknown };\n };\n mcpConfigSnapshot = raw?.agent_settings?.mcp_config;\n }\n } catch {\n // Snapshot failed (network blip, etc.). Continue without rollback\n // ability — the original write error will still surface.\n }\n }\n\n // Cloud settings may redact MCP env/header/auth secrets without an\n // encrypted exposure mode. A pre-clear before a non-delete update can\n // permanently erase unchanged secrets; for updates that keep all existing\n // server keys, rely on the backend deep-merge to preserve redacted leaves\n // while applying edited fields and newly typed credentials.\n const shouldUseCloudMergePatchForRedactedMcpSecrets =\n isCloud &&\n needsMcpPreClear &&\n hasRedactedMcpSecrets(mcpConfigSnapshot) &&\n !removesMcpServer(mcpConfigSnapshot, agentDiff?.mcp_config);\n const shouldPreClearMcpConfig =\n needsMcpPreClear && !shouldUseCloudMergePatchForRedactedMcpSecrets;\n\n if (isCloud) {\n const hasCloudWork =\n !!payload.agent_settings_diff ||\n !!payload.conversation_settings_diff ||\n hasAppPreferences;\n if (!hasCloudWork) {\n return true;\n }\n if (shouldPreClearMcpConfig) {\n await withRetry(() =>\n saveCloudSettings({\n agent_settings_diff: { mcp_config: null },\n }),\n );\n }\n // Build the cloud payload from the same diffs, but as a separate\n // object so undefined keys don't appear in the call (saveCloudSettings\n // is called from tests with an exact-shape assertion).\n const cloudPayload: Parameters<typeof saveCloudSettings>[0] = {};\n if (payload.agent_settings_diff) {\n cloudPayload.agent_settings_diff = { ...payload.agent_settings_diff };\n if (\"mcp_config\" in cloudPayload.agent_settings_diff) {\n cloudPayload.agent_settings_diff.mcp_config =\n cloudCompatibleMcpConfig(\n cloudPayload.agent_settings_diff.mcp_config,\n ) as SettingsValue;\n }\n }\n if (payload.conversation_settings_diff) {\n cloudPayload.conversation_settings_diff =\n payload.conversation_settings_diff;\n }\n if (hasAppPreferences) {\n // The cloud `POST /api/v1/settings` takes app-preference fields as\n // flat top-level keys (not under `app_preferences_diff`).\n // `saveCloudSettings` re-flattens them onto the request body.\n cloudPayload.app_preferences = appPreferences;\n }\n try {\n await withRetry(() => saveCloudSettings(cloudPayload));\n } catch (err) {\n if (shouldPreClearMcpConfig && mcpConfigSnapshot) {\n // Best-effort rollback. We deliberately do not wrap in withRetry:\n // the user's session is already in a degraded state and we want\n // to surface the original error promptly. Swallowing the restore\n // error preserves the original failure context for the caller.\n try {\n await saveCloudSettings({\n agent_settings_diff: {\n mcp_config: mcpConfigSnapshot as SettingsValue,\n },\n });\n } catch {\n // Rollback failed; the original error takes precedence.\n }\n }\n throw err;\n }\n } else {\n // The local agent-server PATCH /api/settings requires at least one of\n // the three diff fields. Skip the request entirely if nothing changed.\n const hasLocalDiffs =\n !!payload.agent_settings_diff ||\n !!payload.conversation_settings_diff ||\n !!payload.misc_settings_diff;\n if (!hasLocalDiffs) {\n return true;\n }\n if (shouldPreClearMcpConfig) {\n await withRetry(() =>\n new SettingsClient(getAgentServerClientOptions()).updateSettings({\n agent_settings_diff: { mcp_config: null },\n }),\n );\n }\n try {\n await withRetry(() =>\n new SettingsClient(getAgentServerClientOptions()).updateSettings(\n payload,\n ),\n );\n } catch (err) {\n if (shouldPreClearMcpConfig && mcpConfigSnapshot) {\n // See cloud branch above for rationale.\n try {\n await new SettingsClient(\n getAgentServerClientOptions(),\n ).updateSettings({\n agent_settings_diff: {\n mcp_config: mcpConfigSnapshot as SettingsValue,\n },\n });\n } catch {\n // Rollback failed; the original error takes precedence.\n }\n }\n throw err;\n }\n }\n\n // Invalidate cache after successful save\n clearCache();\n\n return true;\n }\n\n /**\n * Invalidate the settings cache.\n * Call this when settings may have changed externally.\n */\n static invalidateCache(): void {\n clearCache();\n }\n}\n\nexport default SettingsService;\n"],"mappings":"ucAuBA,IAAa,EAAwB,CACnC,WACA,6BACA,6BACA,gBACA,iBACA,kBACD,CAsDK,EAAgD,IAAI,IACxD,EACD,CAEK,EAAwB,GAC5B,EAAyB,IAAI,EAAI,CAQ7B,EACJ,GACiE,CACjE,IAAM,EAA4B,EAAE,CAC9B,EAAgC,EAAE,CACxC,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAM,CAC1C,EAAqB,EAAI,CAC1B,EAAsC,GAAO,EAE9C,EAAK,GAAO,EAGhB,MAAO,CAAE,YAAW,OAAM,EAYtB,EAAgB,GAAgB,KAAK,MAAM,KAAK,UAAU,EAAM,CAAC,CAEjE,GACJ,EACA,KACI,CAAE,GAAI,GAAQ,EAAE,CAAG,GAAI,GAAQ,EAAE,CAAG,EAK1C,eAAe,EACb,EACA,EAAqB,EACrB,EAAsB,IACV,CACZ,IAAK,IAAI,EAAU,EAAG,EAAU,EAAY,GAAW,EACrD,GAAI,CACF,OAAO,MAAM,GAAI,OACV,EAAO,CACd,GAAI,GAAW,EAAa,EAC1B,MAAM,EAGR,IAAM,EAAQ,EAAc,GAAK,EAEjC,MAAM,IAAI,QAAe,GAAY,CACnC,WAAW,EAAS,EAAM,EAC1B,CAIN,MAAU,MAAM,2BAA2B,CAO7C,IAAI,EAOA,CACF,SAAU,KACV,UAAW,KACX,UAAW,EACZ,CAEK,EAAe,IAAS,IAExB,MAAqB,KAAK,KAAK,CAAG,EAAc,UA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C,eAAe,CAC/D,oBAAqB,CAAE,WAAY,KAAM,CAC1C,CAAC,CACH,CAEH,GAAI,CACF,MAAM,MACJ,IAAI,EAAA,eAAe,EAAA,6BAA6B,CAAC,CAAC,eAChD,EACD,CACF,OACM,EAAK,CACZ,GAAI,GAA2B,EAE7B,GAAI,CACF,MAAM,IAAI,EAAA,eACR,EAAA,6BAA6B,CAC9B,CAAC,eAAe,CACf,oBAAqB,CACnB,WAAY,EACb,CACF,CAAC,MACI,EAIV,MAAM,GAOV,OAFA,GAAY,CAEL,GAOT,OAAO,iBAAwB,CAC7B,GAAY"}
|
|
1
|
+
{"version":3,"file":"settings-service.api.cjs","names":[],"sources":["../../../src/api/settings-service/settings-service.api.ts"],"sourcesContent":["import { SettingsClient } from \"@openhands/typescript-client/clients\";\nimport { DEFAULT_SETTINGS } from \"#/services/settings\";\nimport { Settings, SettingsSchema, SettingsValue } from \"#/types/settings\";\nimport {\n getSdkMcpServerMap,\n hasRedactedMcpSecretLeaf,\n stringRecord,\n} from \"#/utils/mcp-config\";\nimport { getActiveBackend } from \"../backend-registry/active-store\";\nimport {\n fetchCloudConversationSettingsSchema,\n fetchCloudSettings,\n fetchCloudSettingsSchema,\n saveCloudSettings,\n} from \"../cloud/settings-service.api\";\nimport { getAgentServerClientOptions } from \"../agent-server-client-options\";\n\n/**\n * Fields the agent-server stores under `misc_settings.app_preferences` (see\n * SDK `openhands.sdk.settings.AppPreferences`). Mirrored here as a flat\n * partial of Settings so the rest of the frontend can keep treating them as\n * top-level keys (`settings.language`, `settings.disabled_skills`, …).\n */\nexport const APP_PREFERENCE_FIELDS = [\n \"language\",\n \"user_consents_to_analytics\",\n \"enable_sound_notifications\",\n \"git_user_name\",\n \"git_user_email\",\n \"title_llm_profile\",\n \"disabled_skills\",\n] as const;\n\nexport type AppPreferenceField = (typeof APP_PREFERENCE_FIELDS)[number];\n\nexport type AppPreferences = Partial<Pick<Settings, AppPreferenceField>>;\n\n/**\n * Container for frontend-owned settings the agent doesn't interpret.\n * Mirrors the SDK `MiscSettings` model introduced in agent-server 1.27.\n *\n * Single nested category today (`app_preferences`). Adding a future\n * category (e.g. `ui_preferences`) is a non-breaking change for the wire\n * shape — it just adds another optional sibling here.\n */\nexport interface MiscSettings {\n app_preferences?: AppPreferences;\n}\n\n/**\n * Response from GET /api/settings\n * Mirrors the SettingsResponse model in the agent server.\n */\nexport interface SettingsApiResponse {\n agent_settings: Record<string, SettingsValue>;\n conversation_settings: Record<string, SettingsValue>;\n llm_api_key_is_set: boolean;\n /**\n * Frontend-owned settings the agent does not interpret (currently just\n * `app_preferences`). Added in agent-server 1.27; earlier servers omit\n * the field entirely, in which case the frontend falls back to defaults.\n */\n misc_settings?: MiscSettings;\n}\n\n/**\n * Request payload for PATCH /api/settings.\n *\n * `misc_settings_diff` is deep-merged into the persisted `misc_settings`\n * block, matching the semantics of `agent_settings_diff` /\n * `conversation_settings_diff`. A partial diff like\n * `{ app_preferences: { language: \"fr\" } }` updates only `language` and\n * leaves every other `app_preferences` field alone. Lists\n * (`disabled_skills`) are replaced wholesale rather than merged.\n */\nexport interface SettingsUpdateRequest {\n agent_settings_diff?: Record<string, SettingsValue>;\n conversation_settings_diff?: Record<string, SettingsValue>;\n misc_settings_diff?: MiscSettings;\n // Permit additional keys so this stays assignable to the underlying\n // typescript-client SDK type, which uses `[key: string]: unknown` for\n // forward compatibility.\n [key: string]: unknown;\n}\n\nconst APP_PREFERENCE_FIELD_SET: ReadonlySet<string> = new Set(\n APP_PREFERENCE_FIELDS,\n);\n\nconst isAppPreferenceField = (key: string): key is AppPreferenceField =>\n APP_PREFERENCE_FIELD_SET.has(key);\n\n/**\n * Split known app-preference keys out of a save payload so callers can\n * route them through `misc_settings_diff.app_preferences` (local) or as\n * flat top-level keys (cloud), while the remaining fields flow into the\n * `agent_settings_diff` / `conversation_settings_diff` branches.\n */\nconst extractAppPreferences = (\n input: Record<string, unknown>,\n): { extracted: AppPreferences; rest: Record<string, unknown> } => {\n const extracted: AppPreferences = {};\n const rest: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(input)) {\n if (isAppPreferenceField(key)) {\n (extracted as Record<string, unknown>)[key] = value;\n } else {\n rest[key] = value;\n }\n }\n return { extracted, rest };\n};\n\n/**\n * Secret exposure mode for X-Expose-Secrets header.\n *\n * - undefined: Returns redacted secrets (\"**********\")\n * - \"encrypted\": Returns cipher-encrypted values (safe for frontend to round-trip)\n * - \"plaintext\": Returns raw secret values (backend use only!)\n */\nexport type ExposeSecretsMode = \"encrypted\" | \"plaintext\" | undefined;\n\nconst deepClone = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T;\n\nconst mergeRecords = (\n base: Record<string, SettingsValue> | null | undefined,\n next: Record<string, SettingsValue> | null | undefined,\n) => ({ ...(base ?? {}), ...(next ?? {}) });\n\n/**\n * Retry helper for API calls with exponential backoff.\n */\nasync function withRetry<T>(\n fn: () => Promise<T>,\n maxRetries: number = 3,\n baseDelayMs: number = 500,\n): Promise<T> {\n for (let attempt = 0; attempt < maxRetries; attempt += 1) {\n try {\n return await fn();\n } catch (error) {\n if (attempt >= maxRetries - 1) {\n throw error;\n }\n\n const delay = baseDelayMs * 2 ** attempt;\n\n await new Promise<void>((resolve) => {\n setTimeout(resolve, delay);\n });\n }\n }\n\n throw new Error(\"Retry attempts exhausted\");\n}\n\n/**\n * In-memory cache for settings to avoid repeated network calls.\n * The cache is invalidated on save operations.\n */\nlet settingsCache: {\n /** Settings with redacted secrets for display */\n redacted: SettingsApiResponse | null;\n /** Settings with encrypted secrets for conversation start */\n encrypted: SettingsApiResponse | null;\n /** Timestamp when the cache was last populated */\n timestamp: number;\n} = {\n redacted: null,\n encrypted: null,\n timestamp: 0,\n};\n\nconst CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes\n\nconst isCacheValid = () => Date.now() - settingsCache.timestamp < CACHE_TTL_MS;\n\nconst clearCache = () => {\n settingsCache = { redacted: null, encrypted: null, timestamp: 0 };\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === \"object\" && !Array.isArray(value);\n\nconst basicAuthHeader = (username: string, password: string): string => {\n const token = btoa(`${username}:${password}`);\n return `Basic ${token}`;\n};\n\nconst headersFromMcpAuth = (\n auth: Record<string, unknown>,\n): Record<string, string> | null => {\n switch (auth.strategy) {\n case \"none\":\n return {};\n case \"api_key\": {\n if (typeof auth.value !== \"string\" || !auth.value) return null;\n const header =\n typeof auth.header_name === \"string\" && auth.header_name\n ? auth.header_name\n : \"Authorization\";\n const value =\n header === \"Authorization\" ? `Bearer ${auth.value}` : auth.value;\n return { [header]: value };\n }\n case \"bearer\":\n if (typeof auth.value !== \"string\" || !auth.value) return null;\n return { Authorization: `Bearer ${auth.value}` };\n case \"basic\":\n if (\n typeof auth.username !== \"string\" ||\n typeof auth.password !== \"string\"\n ) {\n return null;\n }\n return { Authorization: basicAuthHeader(auth.username, auth.password) };\n case \"header\":\n return stringRecord(auth.headers) ?? {};\n case \"oauth2\": {\n const tokens = isRecord(auth.state) ? auth.state.tokens : undefined;\n if (!isRecord(tokens) || typeof tokens.access_token !== \"string\") {\n return null;\n }\n return { Authorization: `Bearer ${tokens.access_token}` };\n }\n default:\n return null;\n }\n};\n\nconst cloudCompatibleMcpConfig = (value: unknown): unknown => {\n if (!isRecord(value)) return value;\n\n const hasWrapper = isRecord(value.mcpServers);\n const serverMap: Record<string, unknown> = hasWrapper\n ? (value.mcpServers as Record<string, unknown>)\n : value;\n\n const converted = Object.fromEntries(\n Object.entries(serverMap).map(([name, server]) => {\n if (!isRecord(server) || !isRecord(server.auth)) return [name, server];\n\n const authHeaders = headersFromMcpAuth(server.auth);\n if (authHeaders === null) return [name, server];\n\n const nextServer = { ...server };\n const existingHeaders = stringRecord(server.headers) ?? {};\n const mergedHeaders = { ...existingHeaders, ...authHeaders };\n delete nextServer.auth;\n if (Object.keys(mergedHeaders).length > 0) {\n nextServer.headers = mergedHeaders;\n } else {\n delete nextServer.headers;\n }\n return [name, nextServer];\n }),\n );\n\n return hasWrapper ? { ...value, mcpServers: converted } : converted;\n};\n\nconst hasRedactedMcpSecrets = (mcpConfig: unknown): boolean => {\n const servers = getSdkMcpServerMap(mcpConfig);\n if (!servers) return false;\n return Object.values(servers).some(\n (server) =>\n hasRedactedMcpSecretLeaf(isRecord(server) ? server.auth : undefined) ||\n hasRedactedMcpSecretLeaf(isRecord(server) ? server.headers : undefined) ||\n hasRedactedMcpSecretLeaf(isRecord(server) ? server.env : undefined),\n );\n};\n\nconst removesMcpServer = (previous: unknown, next: unknown): boolean => {\n const previousServers = getSdkMcpServerMap(previous);\n const nextServers = getSdkMcpServerMap(next);\n if (!previousServers || !nextServers) return false;\n return Object.keys(previousServers).some((name) => !(name in nextServers));\n};\n\n/**\n * Transform API response into Settings object with derived fields.\n */\nconst transformApiResponse = (\n response: SettingsApiResponse,\n): Partial<Settings> => {\n const agentSettings = response.agent_settings ?? {};\n const conversationSettings = response.conversation_settings ?? {};\n\n const partial: Partial<Settings> = {\n agent_settings: agentSettings,\n conversation_settings: conversationSettings,\n llm_api_key_set: response.llm_api_key_is_set,\n };\n\n // App-level user preferences come back nested under\n // `misc_settings.app_preferences` from the local agent-server (added in\n // 1.27, restructured into the `misc_settings` container in the follow-up\n // refactor). Hoist them onto the flat Settings shape the rest of the\n // frontend already speaks. Older servers omit the `misc_settings` field\n // entirely; the migration helper invoked from `getSettings` promotes any\n // leftover localStorage values to the server on first run, so the omitted\n // case just falls back to defaults.\n const prefs = response.misc_settings?.app_preferences;\n if (prefs) {\n for (const key of APP_PREFERENCE_FIELDS) {\n const value = prefs[key];\n if (value !== undefined) {\n (partial as Record<string, unknown>)[key] = value;\n }\n }\n }\n\n return partial;\n};\n\n/**\n * Sync derived settings fields from agent_settings and conversation_settings.\n * This ensures backward compatibility with code that reads top-level fields.\n */\nconst syncDerivedSettings = (settings: Partial<Settings>): Settings => {\n const agentSettings = mergeRecords(\n DEFAULT_SETTINGS.agent_settings ?? {},\n settings.agent_settings ?? {},\n );\n const conversationSettings = mergeRecords(\n DEFAULT_SETTINGS.conversation_settings ?? {},\n settings.conversation_settings ?? {},\n );\n\n const merged = {\n ...deepClone(DEFAULT_SETTINGS),\n ...settings,\n provider_tokens_set: {\n ...(DEFAULT_SETTINGS.provider_tokens_set ?? {}),\n ...(settings.provider_tokens_set ?? {}),\n },\n agent_settings: agentSettings,\n conversation_settings: conversationSettings,\n } as Settings;\n\n const llm = agentSettings.llm as Record<string, SettingsValue> | undefined;\n const condenser = agentSettings.condenser as\n | Record<string, SettingsValue>\n | undefined;\n\n if (typeof agentSettings.agent === \"string\") {\n merged.agent = agentSettings.agent;\n }\n if (typeof llm?.model === \"string\" && llm.model.length > 0) {\n merged.llm_model = llm.model;\n }\n if (typeof llm?.base_url === \"string\") {\n merged.llm_base_url = llm.base_url;\n }\n // Note: api_key may be redacted (\"**********\") when fetched without expose header\n // We don't sync it to top-level llm_api_key to avoid overwriting with redacted value\n if (typeof condenser?.enabled === \"boolean\") {\n merged.enable_default_condenser = condenser.enabled;\n }\n if (typeof condenser?.max_size === \"number\") {\n merged.condenser_max_size = condenser.max_size;\n }\n if (typeof conversationSettings.confirmation_mode === \"boolean\") {\n merged.confirmation_mode = conversationSettings.confirmation_mode;\n }\n if (\n typeof conversationSettings.security_analyzer === \"string\" ||\n conversationSettings.security_analyzer === null\n ) {\n merged.security_analyzer = conversationSettings.security_analyzer as\n | string\n | null;\n }\n if (typeof conversationSettings.max_iterations === \"number\") {\n merged.max_iterations = conversationSettings.max_iterations;\n }\n\n merged.search_api_key_set = !!merged.search_api_key;\n\n return merged;\n};\n\nclass SettingsService {\n /**\n * Fetch settings from the agent server API with retry logic.\n *\n * @param exposeSecrets - Controls how secrets are returned:\n * - undefined: Secrets are redacted (\"**********\") - safe for display\n * - \"encrypted\": Secrets are cipher-encrypted - safe for round-trip to start conversation\n * - \"plaintext\": Raw secrets - DO NOT USE from frontend\n */\n static async fetchSettingsFromApi(\n exposeSecrets?: ExposeSecretsMode,\n ): Promise<SettingsApiResponse> {\n return withRetry(() =>\n new SettingsClient(getAgentServerClientOptions()).getSettings({\n exposeSecrets,\n }),\n ) as Promise<SettingsApiResponse>;\n }\n\n /**\n * Get settings for display (secrets are redacted).\n * Uses in-memory cache for performance.\n */\n static async getSettings(): Promise<Settings> {\n // Cloud uses a different settings shape (flat top-level fields\n // including provider_tokens_set, llm_model, etc.). Branch out before\n // touching the local-only cache: cloud responses bypass the local\n // SettingsApiResponse shape and feed straight into syncDerivedSettings\n // so cloud-native fields like provider_tokens_set reach the GUI's\n // useUserProviders → useAppInstallations → useGitRepositories chain.\n if (getActiveBackend().backend.kind === \"cloud\") {\n try {\n const cloud = await withRetry(() => fetchCloudSettings());\n return syncDerivedSettings(cloud);\n } catch (error) {\n console.warn(\"Failed to fetch cloud settings, using defaults:\", error);\n return syncDerivedSettings({});\n }\n }\n\n // Check cache first\n if (isCacheValid() && settingsCache.redacted) {\n return syncDerivedSettings(transformApiResponse(settingsCache.redacted));\n }\n\n try {\n const response = await this.fetchSettingsFromApi();\n settingsCache.redacted = response;\n settingsCache.timestamp = Date.now();\n return syncDerivedSettings(transformApiResponse(response));\n } catch (error) {\n // If API fails, return defaults\n console.warn(\"Failed to fetch settings from API, using defaults:\", error);\n return syncDerivedSettings({});\n }\n }\n\n /**\n * Get settings with encrypted secrets for starting conversations.\n * The encrypted secrets can be passed to the start conversation API\n * with secrets_encrypted=true for server-side decryption.\n *\n * @throws Error if encrypted settings cannot be fetched - conversations\n * should not start with broken/redacted credentials.\n */\n static async getSettingsForConversation(): Promise<{\n agentSettings: Record<string, SettingsValue>;\n conversationSettings: Record<string, SettingsValue>;\n secretsEncrypted: boolean;\n }> {\n // Check cache first\n if (isCacheValid() && settingsCache.encrypted) {\n return {\n agentSettings: settingsCache.encrypted.agent_settings,\n conversationSettings: settingsCache.encrypted.conversation_settings,\n secretsEncrypted: true,\n };\n }\n\n // Fetch encrypted settings - this MUST succeed for conversations to work.\n // Do not fall back to redacted settings as that would cause auth failures.\n const response = await this.fetchSettingsFromApi(\"encrypted\");\n settingsCache.encrypted = response;\n if (!settingsCache.timestamp) {\n settingsCache.timestamp = Date.now();\n }\n return {\n agentSettings: response.agent_settings,\n conversationSettings: response.conversation_settings,\n secretsEncrypted: true,\n };\n }\n\n static async getSettingsSchema(): Promise<SettingsSchema> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return (await fetchCloudSettingsSchema()) as SettingsSchema;\n }\n return (await new SettingsClient(\n getAgentServerClientOptions(),\n ).getAgentSchema()) as SettingsSchema;\n }\n\n static async getConversationSettingsSchema(): Promise<SettingsSchema> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return (await fetchCloudConversationSettingsSchema()) as SettingsSchema;\n }\n return (await new SettingsClient(\n getAgentServerClientOptions(),\n ).getConversationSchema()) as SettingsSchema;\n }\n\n /**\n * Save settings to the agent server API.\n * Uses PATCH for incremental updates.\n */\n static async saveSettings(\n settings: Partial<Settings> & Record<string, unknown>,\n ): Promise<boolean> {\n // Split app-level user-preference fields (language, git identity, sound\n // notifications, analytics consent, disabled_skills) off and route them\n // through `misc_settings_diff.app_preferences` (local) or as flat\n // top-level keys (cloud). The local agent-server stores them under\n // `PersistedSettings.misc_settings.app_preferences`; the cloud accepts\n // them as flat keys on `POST /api/v1/settings`.\n const { extracted: appPreferences, rest } = extractAppPreferences(\n settings as Record<string, unknown>,\n );\n const hasAppPreferences = Object.keys(appPreferences).length > 0;\n\n const payload: SettingsUpdateRequest = {};\n\n // Extract agent_settings_diff\n const agentSettingsDiff = rest.agent_settings_diff as\n | Record<string, SettingsValue>\n | undefined;\n if (agentSettingsDiff && Object.keys(agentSettingsDiff).length > 0) {\n payload.agent_settings_diff = agentSettingsDiff;\n }\n\n // Extract conversation_settings_diff\n const conversationSettingsDiff = rest.conversation_settings_diff as\n | Record<string, SettingsValue>\n | undefined;\n if (\n conversationSettingsDiff &&\n Object.keys(conversationSettingsDiff).length > 0\n ) {\n payload.conversation_settings_diff = conversationSettingsDiff;\n }\n\n if (hasAppPreferences) {\n payload.misc_settings_diff = { app_preferences: appPreferences };\n }\n\n const isCloud = getActiveBackend().backend.kind === \"cloud\";\n\n // The backend applies ``agent_settings_diff`` by deep-merging it into the\n // existing ``agent_settings`` dict (see SDK\n // ``openhands.agent_server.persistence.models._deep_merge``). That works\n // for scalar fields but is wrong for ``mcp_config``, which is\n // a name-keyed map: a diff that omits a server cannot remove it (stale\n // key stays), and a diff whose key indices shift (e.g. after deleting\n // index 0, the second server is renumbered) leaves the original keys\n // behind as duplicates pointing to the wrong server config.\n //\n // The only way to make ``mcp_config`` behave like a replace through this\n // API is to first null it out — ``null`` is not a dict, so deep-merge\n // takes the else branch and sets the field to ``None`` outright — and\n // then send the new value in a follow-up call. We do this for every\n // ``mcp_config`` write, including adds (the wasted round-trip is\n // negligible for this user action and avoids divergent code paths).\n const agentDiff = payload.agent_settings_diff;\n // Send a pre-clear PATCH when the diff sets ``mcp_config`` to a non-null\n // value. A second PATCH below then writes the new value. Skipping the\n // pre-clear when the caller is already clearing (``mcp_config: null``)\n // avoids a pointless duplicate request.\n const needsMcpPreClear =\n !!agentDiff && \"mcp_config\" in agentDiff && agentDiff.mcp_config !== null;\n\n // The pre-clear is destructive: if the follow-up write fails after the\n // clear succeeds, the user's MCP config is left empty. Snapshot the\n // previous value (in raw SDK-native shape, NOT the GUI's parsed MCPConfig)\n // before pre-clearing so we can attempt a best-effort rollback. The\n // original write error is always re-thrown to the caller regardless\n // of rollback success — the GUI's react-query mutations surface that\n // as an error toast so the user knows to retry.\n //\n // Snapshot must be the SDK-native server map because that is what the\n // backend expects on the rollback PATCH.\n // ``SettingsService.getSettings`` returns a GUI Settings object whose\n // ``mcp_config`` is typed as the parsed frontend MCPConfig and\n // defaults to empty arrays when nothing is installed, so it is not\n // suitable for round-tripping back to the backend.\n let mcpConfigSnapshot: unknown = undefined;\n if (needsMcpPreClear) {\n try {\n if (isCloud) {\n const raw = (await fetchCloudSettings()) as {\n agent_settings?: { mcp_config?: unknown };\n };\n mcpConfigSnapshot = raw?.agent_settings?.mcp_config;\n } else {\n const raw = (await SettingsService.fetchSettingsFromApi()) as {\n agent_settings?: { mcp_config?: unknown };\n };\n mcpConfigSnapshot = raw?.agent_settings?.mcp_config;\n }\n } catch {\n // Snapshot failed (network blip, etc.). Continue without rollback\n // ability — the original write error will still surface.\n }\n }\n\n // Cloud settings may redact MCP env/header/auth secrets without an\n // encrypted exposure mode. A pre-clear before a non-delete update can\n // permanently erase unchanged secrets; for updates that keep all existing\n // server keys, rely on the backend deep-merge to preserve redacted leaves\n // while applying edited fields and newly typed credentials.\n const shouldUseCloudMergePatchForRedactedMcpSecrets =\n isCloud &&\n needsMcpPreClear &&\n hasRedactedMcpSecrets(mcpConfigSnapshot) &&\n !removesMcpServer(mcpConfigSnapshot, agentDiff?.mcp_config);\n const shouldPreClearMcpConfig =\n needsMcpPreClear && !shouldUseCloudMergePatchForRedactedMcpSecrets;\n\n if (isCloud) {\n const hasCloudWork =\n !!payload.agent_settings_diff ||\n !!payload.conversation_settings_diff ||\n hasAppPreferences;\n if (!hasCloudWork) {\n return true;\n }\n if (shouldPreClearMcpConfig) {\n await withRetry(() =>\n saveCloudSettings({\n agent_settings_diff: { mcp_config: null },\n }),\n );\n }\n // Build the cloud payload from the same diffs, but as a separate\n // object so undefined keys don't appear in the call (saveCloudSettings\n // is called from tests with an exact-shape assertion).\n const cloudPayload: Parameters<typeof saveCloudSettings>[0] = {};\n if (payload.agent_settings_diff) {\n cloudPayload.agent_settings_diff = { ...payload.agent_settings_diff };\n if (\"mcp_config\" in cloudPayload.agent_settings_diff) {\n cloudPayload.agent_settings_diff.mcp_config =\n cloudCompatibleMcpConfig(\n cloudPayload.agent_settings_diff.mcp_config,\n ) as SettingsValue;\n }\n }\n if (payload.conversation_settings_diff) {\n cloudPayload.conversation_settings_diff =\n payload.conversation_settings_diff;\n }\n if (hasAppPreferences) {\n // The cloud `POST /api/v1/settings` takes app-preference fields as\n // flat top-level keys (not under `app_preferences_diff`).\n // `saveCloudSettings` re-flattens them onto the request body.\n cloudPayload.app_preferences = appPreferences;\n }\n try {\n await withRetry(() => saveCloudSettings(cloudPayload));\n } catch (err) {\n if (shouldPreClearMcpConfig && mcpConfigSnapshot) {\n // Best-effort rollback. We deliberately do not wrap in withRetry:\n // the user's session is already in a degraded state and we want\n // to surface the original error promptly. Swallowing the restore\n // error preserves the original failure context for the caller.\n try {\n await saveCloudSettings({\n agent_settings_diff: {\n mcp_config: mcpConfigSnapshot as SettingsValue,\n },\n });\n } catch {\n // Rollback failed; the original error takes precedence.\n }\n }\n throw err;\n }\n } else {\n // The local agent-server PATCH /api/settings requires at least one of\n // the three diff fields. Skip the request entirely if nothing changed.\n const hasLocalDiffs =\n !!payload.agent_settings_diff ||\n !!payload.conversation_settings_diff ||\n !!payload.misc_settings_diff;\n if (!hasLocalDiffs) {\n return true;\n }\n if (shouldPreClearMcpConfig) {\n await withRetry(() =>\n new SettingsClient(getAgentServerClientOptions()).updateSettings({\n agent_settings_diff: { mcp_config: null },\n }),\n );\n }\n try {\n await withRetry(() =>\n new SettingsClient(getAgentServerClientOptions()).updateSettings(\n payload,\n ),\n );\n } catch (err) {\n if (shouldPreClearMcpConfig && mcpConfigSnapshot) {\n // See cloud branch above for rationale.\n try {\n await new SettingsClient(\n getAgentServerClientOptions(),\n ).updateSettings({\n agent_settings_diff: {\n mcp_config: mcpConfigSnapshot as SettingsValue,\n },\n });\n } catch {\n // Rollback failed; the original error takes precedence.\n }\n }\n throw err;\n }\n }\n\n // Invalidate cache after successful save\n clearCache();\n\n return true;\n }\n\n /**\n * Invalidate the settings cache.\n * Call this when settings may have changed externally.\n */\n static invalidateCache(): void {\n clearCache();\n }\n}\n\nexport default SettingsService;\n"],"mappings":"ucAuBA,IAAa,EAAwB,CACnC,WACA,6BACA,6BACA,gBACA,iBACA,oBACA,kBACD,CAsDK,EAAgD,IAAI,IACxD,EACD,CAEK,EAAwB,GAC5B,EAAyB,IAAI,EAAI,CAQ7B,EACJ,GACiE,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AW,CACvD,EACJ,GAAoB,CAAC,EAEvB,GAAI,EAAS,CAKX,GAAI,EAHA,EAAQ,qBACR,EAAQ,4BACV,GAEA,MAAO,GAEL,GACF,MAAM,MACJ,EAAA,kBAAkB,CAChB,oBAAqB,CAAE,WAAY,KAAM,CAC1C,CAAC,CACH,CAKH,IAAM,EAAwD,EAAE,CAC5D,EAAQ,sBACV,EAAa,oBAAsB,CAAE,GAAG,EAAQ,oBAAqB,CACjE,eAAgB,EAAa,sBAC/B,EAAa,oBAAoB,WAC/B,EACE,EAAa,oBAAoB,WAClC,GAGH,EAAQ,6BACV,EAAa,2BACX,EAAQ,4BAER,IAIF,EAAa,gBAAkB,GAEjC,GAAI,CACF,MAAM,MAAgB,EAAA,kBAAkB,EAAa,CAAC,OAC/C,EAAK,CACZ,GAAI,GAA2B,EAK7B,GAAI,CACF,MAAM,EAAA,kBAAkB,CACtB,oBAAqB,CACnB,WAAY,EACb,CACF,CAAC,MACI,EAIV,MAAM,OAEH,CAOL,GAAI,EAHA,EAAQ,qBACR,EAAQ,4BACR,EAAQ,oBAEV,MAAO,GAEL,GACF,MAAM,MACJ,IAAI,EAAA,eAAe,EAAA,6BAA6B,CAAC,CAAC,eAAe,CAC/D,oBAAqB,CAAE,WAAY,KAAM,CAC1C,CAAC,CACH,CAEH,GAAI,CACF,MAAM,MACJ,IAAI,EAAA,eAAe,EAAA,6BAA6B,CAAC,CAAC,eAChD,EACD,CACF,OACM,EAAK,CACZ,GAAI,GAA2B,EAE7B,GAAI,CACF,MAAM,IAAI,EAAA,eACR,EAAA,6BAA6B,CAC9B,CAAC,eAAe,CACf,oBAAqB,CACnB,WAAY,EACb,CACF,CAAC,MACI,EAIV,MAAM,GAOV,OAFA,GAAY,CAEL,GAOT,OAAO,iBAAwB,CAC7B,GAAY"}
|
|
@@ -5,7 +5,7 @@ import { Settings, SettingsSchema, SettingsValue } from "#/types/settings";
|
|
|
5
5
|
* partial of Settings so the rest of the frontend can keep treating them as
|
|
6
6
|
* top-level keys (`settings.language`, `settings.disabled_skills`, …).
|
|
7
7
|
*/
|
|
8
|
-
export declare const APP_PREFERENCE_FIELDS: readonly ["language", "user_consents_to_analytics", "enable_sound_notifications", "git_user_name", "git_user_email", "disabled_skills"];
|
|
8
|
+
export declare const APP_PREFERENCE_FIELDS: readonly ["language", "user_consents_to_analytics", "enable_sound_notifications", "git_user_name", "git_user_email", "title_llm_profile", "disabled_skills"];
|
|
9
9
|
export type AppPreferenceField = (typeof APP_PREFERENCE_FIELDS)[number];
|
|
10
10
|
export type AppPreferences = Partial<Pick<Settings, AppPreferenceField>>;
|
|
11
11
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-service.api.js","names":[],"sources":["../../../src/api/settings-service/settings-service.api.ts"],"sourcesContent":["import { SettingsClient } from \"@openhands/typescript-client/clients\";\nimport { DEFAULT_SETTINGS } from \"#/services/settings\";\nimport { Settings, SettingsSchema, SettingsValue } from \"#/types/settings\";\nimport {\n getSdkMcpServerMap,\n hasRedactedMcpSecretLeaf,\n stringRecord,\n} from \"#/utils/mcp-config\";\nimport { getActiveBackend } from \"../backend-registry/active-store\";\nimport {\n fetchCloudConversationSettingsSchema,\n fetchCloudSettings,\n fetchCloudSettingsSchema,\n saveCloudSettings,\n} from \"../cloud/settings-service.api\";\nimport { getAgentServerClientOptions } from \"../agent-server-client-options\";\n\n/**\n * Fields the agent-server stores under `misc_settings.app_preferences` (see\n * SDK `openhands.sdk.settings.AppPreferences`). Mirrored here as a flat\n * partial of Settings so the rest of the frontend can keep treating them as\n * top-level keys (`settings.language`, `settings.disabled_skills`, …).\n */\nexport const APP_PREFERENCE_FIELDS = [\n \"language\",\n \"user_consents_to_analytics\",\n \"enable_sound_notifications\",\n \"git_user_name\",\n \"git_user_email\",\n \"disabled_skills\",\n] as const;\n\nexport type AppPreferenceField = (typeof APP_PREFERENCE_FIELDS)[number];\n\nexport type AppPreferences = Partial<Pick<Settings, AppPreferenceField>>;\n\n/**\n * Container for frontend-owned settings the agent doesn't interpret.\n * Mirrors the SDK `MiscSettings` model introduced in agent-server 1.27.\n *\n * Single nested category today (`app_preferences`). Adding a future\n * category (e.g. `ui_preferences`) is a non-breaking change for the wire\n * shape — it just adds another optional sibling here.\n */\nexport interface MiscSettings {\n app_preferences?: AppPreferences;\n}\n\n/**\n * Response from GET /api/settings\n * Mirrors the SettingsResponse model in the agent server.\n */\nexport interface SettingsApiResponse {\n agent_settings: Record<string, SettingsValue>;\n conversation_settings: Record<string, SettingsValue>;\n llm_api_key_is_set: boolean;\n /**\n * Frontend-owned settings the agent does not interpret (currently just\n * `app_preferences`). Added in agent-server 1.27; earlier servers omit\n * the field entirely, in which case the frontend falls back to defaults.\n */\n misc_settings?: MiscSettings;\n}\n\n/**\n * Request payload for PATCH /api/settings.\n *\n * `misc_settings_diff` is deep-merged into the persisted `misc_settings`\n * block, matching the semantics of `agent_settings_diff` /\n * `conversation_settings_diff`. A partial diff like\n * `{ app_preferences: { language: \"fr\" } }` updates only `language` and\n * leaves every other `app_preferences` field alone. Lists\n * (`disabled_skills`) are replaced wholesale rather than merged.\n */\nexport interface SettingsUpdateRequest {\n agent_settings_diff?: Record<string, SettingsValue>;\n conversation_settings_diff?: Record<string, SettingsValue>;\n misc_settings_diff?: MiscSettings;\n // Permit additional keys so this stays assignable to the underlying\n // typescript-client SDK type, which uses `[key: string]: unknown` for\n // forward compatibility.\n [key: string]: unknown;\n}\n\nconst APP_PREFERENCE_FIELD_SET: ReadonlySet<string> = new Set(\n APP_PREFERENCE_FIELDS,\n);\n\nconst isAppPreferenceField = (key: string): key is AppPreferenceField =>\n APP_PREFERENCE_FIELD_SET.has(key);\n\n/**\n * Split known app-preference keys out of a save payload so callers can\n * route them through `misc_settings_diff.app_preferences` (local) or as\n * flat top-level keys (cloud), while the remaining fields flow into the\n * `agent_settings_diff` / `conversation_settings_diff` branches.\n */\nconst extractAppPreferences = (\n input: Record<string, unknown>,\n): { extracted: AppPreferences; rest: Record<string, unknown> } => {\n const extracted: AppPreferences = {};\n const rest: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(input)) {\n if (isAppPreferenceField(key)) {\n (extracted as Record<string, unknown>)[key] = value;\n } else {\n rest[key] = value;\n }\n }\n return { extracted, rest };\n};\n\n/**\n * Secret exposure mode for X-Expose-Secrets header.\n *\n * - undefined: Returns redacted secrets (\"**********\")\n * - \"encrypted\": Returns cipher-encrypted values (safe for frontend to round-trip)\n * - \"plaintext\": Returns raw secret values (backend use only!)\n */\nexport type ExposeSecretsMode = \"encrypted\" | \"plaintext\" | undefined;\n\nconst deepClone = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T;\n\nconst mergeRecords = (\n base: Record<string, SettingsValue> | null | undefined,\n next: Record<string, SettingsValue> | null | undefined,\n) => ({ ...(base ?? {}), ...(next ?? {}) });\n\n/**\n * Retry helper for API calls with exponential backoff.\n */\nasync function withRetry<T>(\n fn: () => Promise<T>,\n maxRetries: number = 3,\n baseDelayMs: number = 500,\n): Promise<T> {\n for (let attempt = 0; attempt < maxRetries; attempt += 1) {\n try {\n return await fn();\n } catch (error) {\n if (attempt >= maxRetries - 1) {\n throw error;\n }\n\n const delay = baseDelayMs * 2 ** attempt;\n\n await new Promise<void>((resolve) => {\n setTimeout(resolve, delay);\n });\n }\n }\n\n throw new Error(\"Retry attempts exhausted\");\n}\n\n/**\n * In-memory cache for settings to avoid repeated network calls.\n * The cache is invalidated on save operations.\n */\nlet settingsCache: {\n /** Settings with redacted secrets for display */\n redacted: SettingsApiResponse | null;\n /** Settings with encrypted secrets for conversation start */\n encrypted: SettingsApiResponse | null;\n /** Timestamp when the cache was last populated */\n timestamp: number;\n} = {\n redacted: null,\n encrypted: null,\n timestamp: 0,\n};\n\nconst CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes\n\nconst isCacheValid = () => Date.now() - settingsCache.timestamp < CACHE_TTL_MS;\n\nconst clearCache = () => {\n settingsCache = { redacted: null, encrypted: null, timestamp: 0 };\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === \"object\" && !Array.isArray(value);\n\nconst basicAuthHeader = (username: string, password: string): string => {\n const token = btoa(`${username}:${password}`);\n return `Basic ${token}`;\n};\n\nconst headersFromMcpAuth = (\n auth: Record<string, unknown>,\n): Record<string, string> | null => {\n switch (auth.strategy) {\n case \"none\":\n return {};\n case \"api_key\": {\n if (typeof auth.value !== \"string\" || !auth.value) return null;\n const header =\n typeof auth.header_name === \"string\" && auth.header_name\n ? auth.header_name\n : \"Authorization\";\n const value =\n header === \"Authorization\" ? `Bearer ${auth.value}` : auth.value;\n return { [header]: value };\n }\n case \"bearer\":\n if (typeof auth.value !== \"string\" || !auth.value) return null;\n return { Authorization: `Bearer ${auth.value}` };\n case \"basic\":\n if (\n typeof auth.username !== \"string\" ||\n typeof auth.password !== \"string\"\n ) {\n return null;\n }\n return { Authorization: basicAuthHeader(auth.username, auth.password) };\n case \"header\":\n return stringRecord(auth.headers) ?? {};\n case \"oauth2\": {\n const tokens = isRecord(auth.state) ? auth.state.tokens : undefined;\n if (!isRecord(tokens) || typeof tokens.access_token !== \"string\") {\n return null;\n }\n return { Authorization: `Bearer ${tokens.access_token}` };\n }\n default:\n return null;\n }\n};\n\nconst cloudCompatibleMcpConfig = (value: unknown): unknown => {\n if (!isRecord(value)) return value;\n\n const hasWrapper = isRecord(value.mcpServers);\n const serverMap: Record<string, unknown> = hasWrapper\n ? (value.mcpServers as Record<string, unknown>)\n : value;\n\n const converted = Object.fromEntries(\n Object.entries(serverMap).map(([name, server]) => {\n if (!isRecord(server) || !isRecord(server.auth)) return [name, server];\n\n const authHeaders = headersFromMcpAuth(server.auth);\n if (authHeaders === null) return [name, server];\n\n const nextServer = { ...server };\n const existingHeaders = stringRecord(server.headers) ?? {};\n const mergedHeaders = { ...existingHeaders, ...authHeaders };\n delete nextServer.auth;\n if (Object.keys(mergedHeaders).length > 0) {\n nextServer.headers = mergedHeaders;\n } else {\n delete nextServer.headers;\n }\n return [name, nextServer];\n }),\n );\n\n return hasWrapper ? { ...value, mcpServers: converted } : converted;\n};\n\nconst hasRedactedMcpSecrets = (mcpConfig: unknown): boolean => {\n const servers = getSdkMcpServerMap(mcpConfig);\n if (!servers) return false;\n return Object.values(servers).some(\n (server) =>\n hasRedactedMcpSecretLeaf(isRecord(server) ? server.auth : undefined) ||\n hasRedactedMcpSecretLeaf(isRecord(server) ? server.headers : undefined) ||\n hasRedactedMcpSecretLeaf(isRecord(server) ? server.env : undefined),\n );\n};\n\nconst removesMcpServer = (previous: unknown, next: unknown): boolean => {\n const previousServers = getSdkMcpServerMap(previous);\n const nextServers = getSdkMcpServerMap(next);\n if (!previousServers || !nextServers) return false;\n return Object.keys(previousServers).some((name) => !(name in nextServers));\n};\n\n/**\n * Transform API response into Settings object with derived fields.\n */\nconst transformApiResponse = (\n response: SettingsApiResponse,\n): Partial<Settings> => {\n const agentSettings = response.agent_settings ?? {};\n const conversationSettings = response.conversation_settings ?? {};\n\n const partial: Partial<Settings> = {\n agent_settings: agentSettings,\n conversation_settings: conversationSettings,\n llm_api_key_set: response.llm_api_key_is_set,\n };\n\n // App-level user preferences come back nested under\n // `misc_settings.app_preferences` from the local agent-server (added in\n // 1.27, restructured into the `misc_settings` container in the follow-up\n // refactor). Hoist them onto the flat Settings shape the rest of the\n // frontend already speaks. Older servers omit the `misc_settings` field\n // entirely; the migration helper invoked from `getSettings` promotes any\n // leftover localStorage values to the server on first run, so the omitted\n // case just falls back to defaults.\n const prefs = response.misc_settings?.app_preferences;\n if (prefs) {\n for (const key of APP_PREFERENCE_FIELDS) {\n const value = prefs[key];\n if (value !== undefined) {\n (partial as Record<string, unknown>)[key] = value;\n }\n }\n }\n\n return partial;\n};\n\n/**\n * Sync derived settings fields from agent_settings and conversation_settings.\n * This ensures backward compatibility with code that reads top-level fields.\n */\nconst syncDerivedSettings = (settings: Partial<Settings>): Settings => {\n const agentSettings = mergeRecords(\n DEFAULT_SETTINGS.agent_settings ?? {},\n settings.agent_settings ?? {},\n );\n const conversationSettings = mergeRecords(\n DEFAULT_SETTINGS.conversation_settings ?? {},\n settings.conversation_settings ?? {},\n );\n\n const merged = {\n ...deepClone(DEFAULT_SETTINGS),\n ...settings,\n provider_tokens_set: {\n ...(DEFAULT_SETTINGS.provider_tokens_set ?? {}),\n ...(settings.provider_tokens_set ?? {}),\n },\n agent_settings: agentSettings,\n conversation_settings: conversationSettings,\n } as Settings;\n\n const llm = agentSettings.llm as Record<string, SettingsValue> | undefined;\n const condenser = agentSettings.condenser as\n | Record<string, SettingsValue>\n | undefined;\n\n if (typeof agentSettings.agent === \"string\") {\n merged.agent = agentSettings.agent;\n }\n if (typeof llm?.model === \"string\" && llm.model.length > 0) {\n merged.llm_model = llm.model;\n }\n if (typeof llm?.base_url === \"string\") {\n merged.llm_base_url = llm.base_url;\n }\n // Note: api_key may be redacted (\"**********\") when fetched without expose header\n // We don't sync it to top-level llm_api_key to avoid overwriting with redacted value\n if (typeof condenser?.enabled === \"boolean\") {\n merged.enable_default_condenser = condenser.enabled;\n }\n if (typeof condenser?.max_size === \"number\") {\n merged.condenser_max_size = condenser.max_size;\n }\n if (typeof conversationSettings.confirmation_mode === \"boolean\") {\n merged.confirmation_mode = conversationSettings.confirmation_mode;\n }\n if (\n typeof conversationSettings.security_analyzer === \"string\" ||\n conversationSettings.security_analyzer === null\n ) {\n merged.security_analyzer = conversationSettings.security_analyzer as\n | string\n | null;\n }\n if (typeof conversationSettings.max_iterations === \"number\") {\n merged.max_iterations = conversationSettings.max_iterations;\n }\n\n merged.search_api_key_set = !!merged.search_api_key;\n\n return merged;\n};\n\nclass SettingsService {\n /**\n * Fetch settings from the agent server API with retry logic.\n *\n * @param exposeSecrets - Controls how secrets are returned:\n * - undefined: Secrets are redacted (\"**********\") - safe for display\n * - \"encrypted\": Secrets are cipher-encrypted - safe for round-trip to start conversation\n * - \"plaintext\": Raw secrets - DO NOT USE from frontend\n */\n static async fetchSettingsFromApi(\n exposeSecrets?: ExposeSecretsMode,\n ): Promise<SettingsApiResponse> {\n return withRetry(() =>\n new SettingsClient(getAgentServerClientOptions()).getSettings({\n exposeSecrets,\n }),\n ) as Promise<SettingsApiResponse>;\n }\n\n /**\n * Get settings for display (secrets are redacted).\n * Uses in-memory cache for performance.\n */\n static async getSettings(): Promise<Settings> {\n // Cloud uses a different settings shape (flat top-level fields\n // including provider_tokens_set, llm_model, etc.). Branch out before\n // touching the local-only cache: cloud responses bypass the local\n // SettingsApiResponse shape and feed straight into syncDerivedSettings\n // so cloud-native fields like provider_tokens_set reach the GUI's\n // useUserProviders → useAppInstallations → useGitRepositories chain.\n if (getActiveBackend().backend.kind === \"cloud\") {\n try {\n const cloud = await withRetry(() => fetchCloudSettings());\n return syncDerivedSettings(cloud);\n } catch (error) {\n console.warn(\"Failed to fetch cloud settings, using defaults:\", error);\n return syncDerivedSettings({});\n }\n }\n\n // Check cache first\n if (isCacheValid() && settingsCache.redacted) {\n return syncDerivedSettings(transformApiResponse(settingsCache.redacted));\n }\n\n try {\n const response = await this.fetchSettingsFromApi();\n settingsCache.redacted = response;\n settingsCache.timestamp = Date.now();\n return syncDerivedSettings(transformApiResponse(response));\n } catch (error) {\n // If API fails, return defaults\n console.warn(\"Failed to fetch settings from API, using defaults:\", error);\n return syncDerivedSettings({});\n }\n }\n\n /**\n * Get settings with encrypted secrets for starting conversations.\n * The encrypted secrets can be passed to the start conversation API\n * with secrets_encrypted=true for server-side decryption.\n *\n * @throws Error if encrypted settings cannot be fetched - conversations\n * should not start with broken/redacted credentials.\n */\n static async getSettingsForConversation(): Promise<{\n agentSettings: Record<string, SettingsValue>;\n conversationSettings: Record<string, SettingsValue>;\n secretsEncrypted: boolean;\n }> {\n // Check cache first\n if (isCacheValid() && settingsCache.encrypted) {\n return {\n agentSettings: settingsCache.encrypted.agent_settings,\n conversationSettings: settingsCache.encrypted.conversation_settings,\n secretsEncrypted: true,\n };\n }\n\n // Fetch encrypted settings - this MUST succeed for conversations to work.\n // Do not fall back to redacted settings as that would cause auth failures.\n const response = await this.fetchSettingsFromApi(\"encrypted\");\n settingsCache.encrypted = response;\n if (!settingsCache.timestamp) {\n settingsCache.timestamp = Date.now();\n }\n return {\n agentSettings: response.agent_settings,\n conversationSettings: response.conversation_settings,\n secretsEncrypted: true,\n };\n }\n\n static async getSettingsSchema(): Promise<SettingsSchema> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return (await fetchCloudSettingsSchema()) as SettingsSchema;\n }\n return (await new SettingsClient(\n getAgentServerClientOptions(),\n ).getAgentSchema()) as SettingsSchema;\n }\n\n static async getConversationSettingsSchema(): Promise<SettingsSchema> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return (await fetchCloudConversationSettingsSchema()) as SettingsSchema;\n }\n return (await new SettingsClient(\n getAgentServerClientOptions(),\n ).getConversationSchema()) as SettingsSchema;\n }\n\n /**\n * Save settings to the agent server API.\n * Uses PATCH for incremental updates.\n */\n static async saveSettings(\n settings: Partial<Settings> & Record<string, unknown>,\n ): Promise<boolean> {\n // Split app-level user-preference fields (language, git identity, sound\n // notifications, analytics consent, disabled_skills) off and route them\n // through `misc_settings_diff.app_preferences` (local) or as flat\n // top-level keys (cloud). The local agent-server stores them under\n // `PersistedSettings.misc_settings.app_preferences`; the cloud accepts\n // them as flat keys on `POST /api/v1/settings`.\n const { extracted: appPreferences, rest } = extractAppPreferences(\n settings as Record<string, unknown>,\n );\n const hasAppPreferences = Object.keys(appPreferences).length > 0;\n\n const payload: SettingsUpdateRequest = {};\n\n // Extract agent_settings_diff\n const agentSettingsDiff = rest.agent_settings_diff as\n | Record<string, SettingsValue>\n | undefined;\n if (agentSettingsDiff && Object.keys(agentSettingsDiff).length > 0) {\n payload.agent_settings_diff = agentSettingsDiff;\n }\n\n // Extract conversation_settings_diff\n const conversationSettingsDiff = rest.conversation_settings_diff as\n | Record<string, SettingsValue>\n | undefined;\n if (\n conversationSettingsDiff &&\n Object.keys(conversationSettingsDiff).length > 0\n ) {\n payload.conversation_settings_diff = conversationSettingsDiff;\n }\n\n if (hasAppPreferences) {\n payload.misc_settings_diff = { app_preferences: appPreferences };\n }\n\n const isCloud = getActiveBackend().backend.kind === \"cloud\";\n\n // The backend applies ``agent_settings_diff`` by deep-merging it into the\n // existing ``agent_settings`` dict (see SDK\n // ``openhands.agent_server.persistence.models._deep_merge``). That works\n // for scalar fields but is wrong for ``mcp_config``, which is\n // a name-keyed map: a diff that omits a server cannot remove it (stale\n // key stays), and a diff whose key indices shift (e.g. after deleting\n // index 0, the second server is renumbered) leaves the original keys\n // behind as duplicates pointing to the wrong server config.\n //\n // The only way to make ``mcp_config`` behave like a replace through this\n // API is to first null it out — ``null`` is not a dict, so deep-merge\n // takes the else branch and sets the field to ``None`` outright — and\n // then send the new value in a follow-up call. We do this for every\n // ``mcp_config`` write, including adds (the wasted round-trip is\n // negligible for this user action and avoids divergent code paths).\n const agentDiff = payload.agent_settings_diff;\n // Send a pre-clear PATCH when the diff sets ``mcp_config`` to a non-null\n // value. A second PATCH below then writes the new value. Skipping the\n // pre-clear when the caller is already clearing (``mcp_config: null``)\n // avoids a pointless duplicate request.\n const needsMcpPreClear =\n !!agentDiff && \"mcp_config\" in agentDiff && agentDiff.mcp_config !== null;\n\n // The pre-clear is destructive: if the follow-up write fails after the\n // clear succeeds, the user's MCP config is left empty. Snapshot the\n // previous value (in raw SDK-native shape, NOT the GUI's parsed MCPConfig)\n // before pre-clearing so we can attempt a best-effort rollback. The\n // original write error is always re-thrown to the caller regardless\n // of rollback success — the GUI's react-query mutations surface that\n // as an error toast so the user knows to retry.\n //\n // Snapshot must be the SDK-native server map because that is what the\n // backend expects on the rollback PATCH.\n // ``SettingsService.getSettings`` returns a GUI Settings object whose\n // ``mcp_config`` is typed as the parsed frontend MCPConfig and\n // defaults to empty arrays when nothing is installed, so it is not\n // suitable for round-tripping back to the backend.\n let mcpConfigSnapshot: unknown = undefined;\n if (needsMcpPreClear) {\n try {\n if (isCloud) {\n const raw = (await fetchCloudSettings()) as {\n agent_settings?: { mcp_config?: unknown };\n };\n mcpConfigSnapshot = raw?.agent_settings?.mcp_config;\n } else {\n const raw = (await SettingsService.fetchSettingsFromApi()) as {\n agent_settings?: { mcp_config?: unknown };\n };\n mcpConfigSnapshot = raw?.agent_settings?.mcp_config;\n }\n } catch {\n // Snapshot failed (network blip, etc.). Continue without rollback\n // ability — the original write error will still surface.\n }\n }\n\n // Cloud settings may redact MCP env/header/auth secrets without an\n // encrypted exposure mode. A pre-clear before a non-delete update can\n // permanently erase unchanged secrets; for updates that keep all existing\n // server keys, rely on the backend deep-merge to preserve redacted leaves\n // while applying edited fields and newly typed credentials.\n const shouldUseCloudMergePatchForRedactedMcpSecrets =\n isCloud &&\n needsMcpPreClear &&\n hasRedactedMcpSecrets(mcpConfigSnapshot) &&\n !removesMcpServer(mcpConfigSnapshot, agentDiff?.mcp_config);\n const shouldPreClearMcpConfig =\n needsMcpPreClear && !shouldUseCloudMergePatchForRedactedMcpSecrets;\n\n if (isCloud) {\n const hasCloudWork =\n !!payload.agent_settings_diff ||\n !!payload.conversation_settings_diff ||\n hasAppPreferences;\n if (!hasCloudWork) {\n return true;\n }\n if (shouldPreClearMcpConfig) {\n await withRetry(() =>\n saveCloudSettings({\n agent_settings_diff: { mcp_config: null },\n }),\n );\n }\n // Build the cloud payload from the same diffs, but as a separate\n // object so undefined keys don't appear in the call (saveCloudSettings\n // is called from tests with an exact-shape assertion).\n const cloudPayload: Parameters<typeof saveCloudSettings>[0] = {};\n if (payload.agent_settings_diff) {\n cloudPayload.agent_settings_diff = { ...payload.agent_settings_diff };\n if (\"mcp_config\" in cloudPayload.agent_settings_diff) {\n cloudPayload.agent_settings_diff.mcp_config =\n cloudCompatibleMcpConfig(\n cloudPayload.agent_settings_diff.mcp_config,\n ) as SettingsValue;\n }\n }\n if (payload.conversation_settings_diff) {\n cloudPayload.conversation_settings_diff =\n payload.conversation_settings_diff;\n }\n if (hasAppPreferences) {\n // The cloud `POST /api/v1/settings` takes app-preference fields as\n // flat top-level keys (not under `app_preferences_diff`).\n // `saveCloudSettings` re-flattens them onto the request body.\n cloudPayload.app_preferences = appPreferences;\n }\n try {\n await withRetry(() => saveCloudSettings(cloudPayload));\n } catch (err) {\n if (shouldPreClearMcpConfig && mcpConfigSnapshot) {\n // Best-effort rollback. We deliberately do not wrap in withRetry:\n // the user's session is already in a degraded state and we want\n // to surface the original error promptly. Swallowing the restore\n // error preserves the original failure context for the caller.\n try {\n await saveCloudSettings({\n agent_settings_diff: {\n mcp_config: mcpConfigSnapshot as SettingsValue,\n },\n });\n } catch {\n // Rollback failed; the original error takes precedence.\n }\n }\n throw err;\n }\n } else {\n // The local agent-server PATCH /api/settings requires at least one of\n // the three diff fields. Skip the request entirely if nothing changed.\n const hasLocalDiffs =\n !!payload.agent_settings_diff ||\n !!payload.conversation_settings_diff ||\n !!payload.misc_settings_diff;\n if (!hasLocalDiffs) {\n return true;\n }\n if (shouldPreClearMcpConfig) {\n await withRetry(() =>\n new SettingsClient(getAgentServerClientOptions()).updateSettings({\n agent_settings_diff: { mcp_config: null },\n }),\n );\n }\n try {\n await withRetry(() =>\n new SettingsClient(getAgentServerClientOptions()).updateSettings(\n payload,\n ),\n );\n } catch (err) {\n if (shouldPreClearMcpConfig && mcpConfigSnapshot) {\n // See cloud branch above for rationale.\n try {\n await new SettingsClient(\n getAgentServerClientOptions(),\n ).updateSettings({\n agent_settings_diff: {\n mcp_config: mcpConfigSnapshot as SettingsValue,\n },\n });\n } catch {\n // Rollback failed; the original error takes precedence.\n }\n }\n throw err;\n }\n }\n\n // Invalidate cache after successful save\n clearCache();\n\n return true;\n }\n\n /**\n * Invalidate the settings cache.\n * Call this when settings may have changed externally.\n */\n static invalidateCache(): void {\n clearCache();\n }\n}\n\nexport default SettingsService;\n"],"mappings":";;;;;;;;AAuBA,IAAa,IAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACD,EAsDK,IAAgD,IAAI,IACxD,EACD,EAEK,KAAwB,MAC5B,EAAyB,IAAI,EAAI,EAQ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ACJ,EAAkB,EAChB,qBAAqB,EAAE,YAAY,MAAM,EAC1C,CAAC,CACH;GAKH,IAAM,IAAwD,EAAE;AAchE,GAbI,EAAQ,wBACV,EAAa,sBAAsB,EAAE,GAAG,EAAQ,qBAAqB,EACjE,gBAAgB,EAAa,wBAC/B,EAAa,oBAAoB,aAC/B,EACE,EAAa,oBAAoB,WAClC,IAGH,EAAQ,+BACV,EAAa,6BACX,EAAQ,6BAER,MAIF,EAAa,kBAAkB;AAEjC,OAAI;AACF,UAAM,QAAgB,EAAkB,EAAa,CAAC;YAC/C,GAAK;AACZ,QAAI,KAA2B,EAK7B,KAAI;AACF,WAAM,EAAkB,EACtB,qBAAqB,EACnB,YAAY,GACb,EACF,CAAC;YACI;AAIV,UAAM;;SAEH;AAOL,OAAI,EAHA,EAAQ,uBACR,EAAQ,8BACR,EAAQ,oBAEV,QAAO;AAET,GAAI,KACF,MAAM,QACJ,IAAI,EAAe,GAA6B,CAAC,CAAC,eAAe,EAC/D,qBAAqB,EAAE,YAAY,MAAM,EAC1C,CAAC,CACH;AAEH,OAAI;AACF,UAAM,QACJ,IAAI,EAAe,GAA6B,CAAC,CAAC,eAChD,EACD,CACF;YACM,GAAK;AACZ,QAAI,KAA2B,EAE7B,KAAI;AACF,WAAM,IAAI,EACR,GAA6B,CAC9B,CAAC,eAAe,EACf,qBAAqB,EACnB,YAAY,GACb,EACF,CAAC;YACI;AAIV,UAAM;;;AAOV,SAFA,GAAY,EAEL;;CAOT,OAAO,kBAAwB;AAC7B,KAAY"}
|
|
1
|
+
{"version":3,"file":"settings-service.api.js","names":[],"sources":["../../../src/api/settings-service/settings-service.api.ts"],"sourcesContent":["import { SettingsClient } from \"@openhands/typescript-client/clients\";\nimport { DEFAULT_SETTINGS } from \"#/services/settings\";\nimport { Settings, SettingsSchema, SettingsValue } from \"#/types/settings\";\nimport {\n getSdkMcpServerMap,\n hasRedactedMcpSecretLeaf,\n stringRecord,\n} from \"#/utils/mcp-config\";\nimport { getActiveBackend } from \"../backend-registry/active-store\";\nimport {\n fetchCloudConversationSettingsSchema,\n fetchCloudSettings,\n fetchCloudSettingsSchema,\n saveCloudSettings,\n} from \"../cloud/settings-service.api\";\nimport { getAgentServerClientOptions } from \"../agent-server-client-options\";\n\n/**\n * Fields the agent-server stores under `misc_settings.app_preferences` (see\n * SDK `openhands.sdk.settings.AppPreferences`). Mirrored here as a flat\n * partial of Settings so the rest of the frontend can keep treating them as\n * top-level keys (`settings.language`, `settings.disabled_skills`, …).\n */\nexport const APP_PREFERENCE_FIELDS = [\n \"language\",\n \"user_consents_to_analytics\",\n \"enable_sound_notifications\",\n \"git_user_name\",\n \"git_user_email\",\n \"title_llm_profile\",\n \"disabled_skills\",\n] as const;\n\nexport type AppPreferenceField = (typeof APP_PREFERENCE_FIELDS)[number];\n\nexport type AppPreferences = Partial<Pick<Settings, AppPreferenceField>>;\n\n/**\n * Container for frontend-owned settings the agent doesn't interpret.\n * Mirrors the SDK `MiscSettings` model introduced in agent-server 1.27.\n *\n * Single nested category today (`app_preferences`). Adding a future\n * category (e.g. `ui_preferences`) is a non-breaking change for the wire\n * shape — it just adds another optional sibling here.\n */\nexport interface MiscSettings {\n app_preferences?: AppPreferences;\n}\n\n/**\n * Response from GET /api/settings\n * Mirrors the SettingsResponse model in the agent server.\n */\nexport interface SettingsApiResponse {\n agent_settings: Record<string, SettingsValue>;\n conversation_settings: Record<string, SettingsValue>;\n llm_api_key_is_set: boolean;\n /**\n * Frontend-owned settings the agent does not interpret (currently just\n * `app_preferences`). Added in agent-server 1.27; earlier servers omit\n * the field entirely, in which case the frontend falls back to defaults.\n */\n misc_settings?: MiscSettings;\n}\n\n/**\n * Request payload for PATCH /api/settings.\n *\n * `misc_settings_diff` is deep-merged into the persisted `misc_settings`\n * block, matching the semantics of `agent_settings_diff` /\n * `conversation_settings_diff`. A partial diff like\n * `{ app_preferences: { language: \"fr\" } }` updates only `language` and\n * leaves every other `app_preferences` field alone. Lists\n * (`disabled_skills`) are replaced wholesale rather than merged.\n */\nexport interface SettingsUpdateRequest {\n agent_settings_diff?: Record<string, SettingsValue>;\n conversation_settings_diff?: Record<string, SettingsValue>;\n misc_settings_diff?: MiscSettings;\n // Permit additional keys so this stays assignable to the underlying\n // typescript-client SDK type, which uses `[key: string]: unknown` for\n // forward compatibility.\n [key: string]: unknown;\n}\n\nconst APP_PREFERENCE_FIELD_SET: ReadonlySet<string> = new Set(\n APP_PREFERENCE_FIELDS,\n);\n\nconst isAppPreferenceField = (key: string): key is AppPreferenceField =>\n APP_PREFERENCE_FIELD_SET.has(key);\n\n/**\n * Split known app-preference keys out of a save payload so callers can\n * route them through `misc_settings_diff.app_preferences` (local) or as\n * flat top-level keys (cloud), while the remaining fields flow into the\n * `agent_settings_diff` / `conversation_settings_diff` branches.\n */\nconst extractAppPreferences = (\n input: Record<string, unknown>,\n): { extracted: AppPreferences; rest: Record<string, unknown> } => {\n const extracted: AppPreferences = {};\n const rest: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(input)) {\n if (isAppPreferenceField(key)) {\n (extracted as Record<string, unknown>)[key] = value;\n } else {\n rest[key] = value;\n }\n }\n return { extracted, rest };\n};\n\n/**\n * Secret exposure mode for X-Expose-Secrets header.\n *\n * - undefined: Returns redacted secrets (\"**********\")\n * - \"encrypted\": Returns cipher-encrypted values (safe for frontend to round-trip)\n * - \"plaintext\": Returns raw secret values (backend use only!)\n */\nexport type ExposeSecretsMode = \"encrypted\" | \"plaintext\" | undefined;\n\nconst deepClone = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T;\n\nconst mergeRecords = (\n base: Record<string, SettingsValue> | null | undefined,\n next: Record<string, SettingsValue> | null | undefined,\n) => ({ ...(base ?? {}), ...(next ?? {}) });\n\n/**\n * Retry helper for API calls with exponential backoff.\n */\nasync function withRetry<T>(\n fn: () => Promise<T>,\n maxRetries: number = 3,\n baseDelayMs: number = 500,\n): Promise<T> {\n for (let attempt = 0; attempt < maxRetries; attempt += 1) {\n try {\n return await fn();\n } catch (error) {\n if (attempt >= maxRetries - 1) {\n throw error;\n }\n\n const delay = baseDelayMs * 2 ** attempt;\n\n await new Promise<void>((resolve) => {\n setTimeout(resolve, delay);\n });\n }\n }\n\n throw new Error(\"Retry attempts exhausted\");\n}\n\n/**\n * In-memory cache for settings to avoid repeated network calls.\n * The cache is invalidated on save operations.\n */\nlet settingsCache: {\n /** Settings with redacted secrets for display */\n redacted: SettingsApiResponse | null;\n /** Settings with encrypted secrets for conversation start */\n encrypted: SettingsApiResponse | null;\n /** Timestamp when the cache was last populated */\n timestamp: number;\n} = {\n redacted: null,\n encrypted: null,\n timestamp: 0,\n};\n\nconst CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes\n\nconst isCacheValid = () => Date.now() - settingsCache.timestamp < CACHE_TTL_MS;\n\nconst clearCache = () => {\n settingsCache = { redacted: null, encrypted: null, timestamp: 0 };\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === \"object\" && !Array.isArray(value);\n\nconst basicAuthHeader = (username: string, password: string): string => {\n const token = btoa(`${username}:${password}`);\n return `Basic ${token}`;\n};\n\nconst headersFromMcpAuth = (\n auth: Record<string, unknown>,\n): Record<string, string> | null => {\n switch (auth.strategy) {\n case \"none\":\n return {};\n case \"api_key\": {\n if (typeof auth.value !== \"string\" || !auth.value) return null;\n const header =\n typeof auth.header_name === \"string\" && auth.header_name\n ? auth.header_name\n : \"Authorization\";\n const value =\n header === \"Authorization\" ? `Bearer ${auth.value}` : auth.value;\n return { [header]: value };\n }\n case \"bearer\":\n if (typeof auth.value !== \"string\" || !auth.value) return null;\n return { Authorization: `Bearer ${auth.value}` };\n case \"basic\":\n if (\n typeof auth.username !== \"string\" ||\n typeof auth.password !== \"string\"\n ) {\n return null;\n }\n return { Authorization: basicAuthHeader(auth.username, auth.password) };\n case \"header\":\n return stringRecord(auth.headers) ?? {};\n case \"oauth2\": {\n const tokens = isRecord(auth.state) ? auth.state.tokens : undefined;\n if (!isRecord(tokens) || typeof tokens.access_token !== \"string\") {\n return null;\n }\n return { Authorization: `Bearer ${tokens.access_token}` };\n }\n default:\n return null;\n }\n};\n\nconst cloudCompatibleMcpConfig = (value: unknown): unknown => {\n if (!isRecord(value)) return value;\n\n const hasWrapper = isRecord(value.mcpServers);\n const serverMap: Record<string, unknown> = hasWrapper\n ? (value.mcpServers as Record<string, unknown>)\n : value;\n\n const converted = Object.fromEntries(\n Object.entries(serverMap).map(([name, server]) => {\n if (!isRecord(server) || !isRecord(server.auth)) return [name, server];\n\n const authHeaders = headersFromMcpAuth(server.auth);\n if (authHeaders === null) return [name, server];\n\n const nextServer = { ...server };\n const existingHeaders = stringRecord(server.headers) ?? {};\n const mergedHeaders = { ...existingHeaders, ...authHeaders };\n delete nextServer.auth;\n if (Object.keys(mergedHeaders).length > 0) {\n nextServer.headers = mergedHeaders;\n } else {\n delete nextServer.headers;\n }\n return [name, nextServer];\n }),\n );\n\n return hasWrapper ? { ...value, mcpServers: converted } : converted;\n};\n\nconst hasRedactedMcpSecrets = (mcpConfig: unknown): boolean => {\n const servers = getSdkMcpServerMap(mcpConfig);\n if (!servers) return false;\n return Object.values(servers).some(\n (server) =>\n hasRedactedMcpSecretLeaf(isRecord(server) ? server.auth : undefined) ||\n hasRedactedMcpSecretLeaf(isRecord(server) ? server.headers : undefined) ||\n hasRedactedMcpSecretLeaf(isRecord(server) ? server.env : undefined),\n );\n};\n\nconst removesMcpServer = (previous: unknown, next: unknown): boolean => {\n const previousServers = getSdkMcpServerMap(previous);\n const nextServers = getSdkMcpServerMap(next);\n if (!previousServers || !nextServers) return false;\n return Object.keys(previousServers).some((name) => !(name in nextServers));\n};\n\n/**\n * Transform API response into Settings object with derived fields.\n */\nconst transformApiResponse = (\n response: SettingsApiResponse,\n): Partial<Settings> => {\n const agentSettings = response.agent_settings ?? {};\n const conversationSettings = response.conversation_settings ?? {};\n\n const partial: Partial<Settings> = {\n agent_settings: agentSettings,\n conversation_settings: conversationSettings,\n llm_api_key_set: response.llm_api_key_is_set,\n };\n\n // App-level user preferences come back nested under\n // `misc_settings.app_preferences` from the local agent-server (added in\n // 1.27, restructured into the `misc_settings` container in the follow-up\n // refactor). Hoist them onto the flat Settings shape the rest of the\n // frontend already speaks. Older servers omit the `misc_settings` field\n // entirely; the migration helper invoked from `getSettings` promotes any\n // leftover localStorage values to the server on first run, so the omitted\n // case just falls back to defaults.\n const prefs = response.misc_settings?.app_preferences;\n if (prefs) {\n for (const key of APP_PREFERENCE_FIELDS) {\n const value = prefs[key];\n if (value !== undefined) {\n (partial as Record<string, unknown>)[key] = value;\n }\n }\n }\n\n return partial;\n};\n\n/**\n * Sync derived settings fields from agent_settings and conversation_settings.\n * This ensures backward compatibility with code that reads top-level fields.\n */\nconst syncDerivedSettings = (settings: Partial<Settings>): Settings => {\n const agentSettings = mergeRecords(\n DEFAULT_SETTINGS.agent_settings ?? {},\n settings.agent_settings ?? {},\n );\n const conversationSettings = mergeRecords(\n DEFAULT_SETTINGS.conversation_settings ?? {},\n settings.conversation_settings ?? {},\n );\n\n const merged = {\n ...deepClone(DEFAULT_SETTINGS),\n ...settings,\n provider_tokens_set: {\n ...(DEFAULT_SETTINGS.provider_tokens_set ?? {}),\n ...(settings.provider_tokens_set ?? {}),\n },\n agent_settings: agentSettings,\n conversation_settings: conversationSettings,\n } as Settings;\n\n const llm = agentSettings.llm as Record<string, SettingsValue> | undefined;\n const condenser = agentSettings.condenser as\n | Record<string, SettingsValue>\n | undefined;\n\n if (typeof agentSettings.agent === \"string\") {\n merged.agent = agentSettings.agent;\n }\n if (typeof llm?.model === \"string\" && llm.model.length > 0) {\n merged.llm_model = llm.model;\n }\n if (typeof llm?.base_url === \"string\") {\n merged.llm_base_url = llm.base_url;\n }\n // Note: api_key may be redacted (\"**********\") when fetched without expose header\n // We don't sync it to top-level llm_api_key to avoid overwriting with redacted value\n if (typeof condenser?.enabled === \"boolean\") {\n merged.enable_default_condenser = condenser.enabled;\n }\n if (typeof condenser?.max_size === \"number\") {\n merged.condenser_max_size = condenser.max_size;\n }\n if (typeof conversationSettings.confirmation_mode === \"boolean\") {\n merged.confirmation_mode = conversationSettings.confirmation_mode;\n }\n if (\n typeof conversationSettings.security_analyzer === \"string\" ||\n conversationSettings.security_analyzer === null\n ) {\n merged.security_analyzer = conversationSettings.security_analyzer as\n | string\n | null;\n }\n if (typeof conversationSettings.max_iterations === \"number\") {\n merged.max_iterations = conversationSettings.max_iterations;\n }\n\n merged.search_api_key_set = !!merged.search_api_key;\n\n return merged;\n};\n\nclass SettingsService {\n /**\n * Fetch settings from the agent server API with retry logic.\n *\n * @param exposeSecrets - Controls how secrets are returned:\n * - undefined: Secrets are redacted (\"**********\") - safe for display\n * - \"encrypted\": Secrets are cipher-encrypted - safe for round-trip to start conversation\n * - \"plaintext\": Raw secrets - DO NOT USE from frontend\n */\n static async fetchSettingsFromApi(\n exposeSecrets?: ExposeSecretsMode,\n ): Promise<SettingsApiResponse> {\n return withRetry(() =>\n new SettingsClient(getAgentServerClientOptions()).getSettings({\n exposeSecrets,\n }),\n ) as Promise<SettingsApiResponse>;\n }\n\n /**\n * Get settings for display (secrets are redacted).\n * Uses in-memory cache for performance.\n */\n static async getSettings(): Promise<Settings> {\n // Cloud uses a different settings shape (flat top-level fields\n // including provider_tokens_set, llm_model, etc.). Branch out before\n // touching the local-only cache: cloud responses bypass the local\n // SettingsApiResponse shape and feed straight into syncDerivedSettings\n // so cloud-native fields like provider_tokens_set reach the GUI's\n // useUserProviders → useAppInstallations → useGitRepositories chain.\n if (getActiveBackend().backend.kind === \"cloud\") {\n try {\n const cloud = await withRetry(() => fetchCloudSettings());\n return syncDerivedSettings(cloud);\n } catch (error) {\n console.warn(\"Failed to fetch cloud settings, using defaults:\", error);\n return syncDerivedSettings({});\n }\n }\n\n // Check cache first\n if (isCacheValid() && settingsCache.redacted) {\n return syncDerivedSettings(transformApiResponse(settingsCache.redacted));\n }\n\n try {\n const response = await this.fetchSettingsFromApi();\n settingsCache.redacted = response;\n settingsCache.timestamp = Date.now();\n return syncDerivedSettings(transformApiResponse(response));\n } catch (error) {\n // If API fails, return defaults\n console.warn(\"Failed to fetch settings from API, using defaults:\", error);\n return syncDerivedSettings({});\n }\n }\n\n /**\n * Get settings with encrypted secrets for starting conversations.\n * The encrypted secrets can be passed to the start conversation API\n * with secrets_encrypted=true for server-side decryption.\n *\n * @throws Error if encrypted settings cannot be fetched - conversations\n * should not start with broken/redacted credentials.\n */\n static async getSettingsForConversation(): Promise<{\n agentSettings: Record<string, SettingsValue>;\n conversationSettings: Record<string, SettingsValue>;\n secretsEncrypted: boolean;\n }> {\n // Check cache first\n if (isCacheValid() && settingsCache.encrypted) {\n return {\n agentSettings: settingsCache.encrypted.agent_settings,\n conversationSettings: settingsCache.encrypted.conversation_settings,\n secretsEncrypted: true,\n };\n }\n\n // Fetch encrypted settings - this MUST succeed for conversations to work.\n // Do not fall back to redacted settings as that would cause auth failures.\n const response = await this.fetchSettingsFromApi(\"encrypted\");\n settingsCache.encrypted = response;\n if (!settingsCache.timestamp) {\n settingsCache.timestamp = Date.now();\n }\n return {\n agentSettings: response.agent_settings,\n conversationSettings: response.conversation_settings,\n secretsEncrypted: true,\n };\n }\n\n static async getSettingsSchema(): Promise<SettingsSchema> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return (await fetchCloudSettingsSchema()) as SettingsSchema;\n }\n return (await new SettingsClient(\n getAgentServerClientOptions(),\n ).getAgentSchema()) as SettingsSchema;\n }\n\n static async getConversationSettingsSchema(): Promise<SettingsSchema> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return (await fetchCloudConversationSettingsSchema()) as SettingsSchema;\n }\n return (await new SettingsClient(\n getAgentServerClientOptions(),\n ).getConversationSchema()) as SettingsSchema;\n }\n\n /**\n * Save settings to the agent server API.\n * Uses PATCH for incremental updates.\n */\n static async saveSettings(\n settings: Partial<Settings> & Record<string, unknown>,\n ): Promise<boolean> {\n // Split app-level user-preference fields (language, git identity, sound\n // notifications, analytics consent, disabled_skills) off and route them\n // through `misc_settings_diff.app_preferences` (local) or as flat\n // top-level keys (cloud). The local agent-server stores them under\n // `PersistedSettings.misc_settings.app_preferences`; the cloud accepts\n // them as flat keys on `POST /api/v1/settings`.\n const { extracted: appPreferences, rest } = extractAppPreferences(\n settings as Record<string, unknown>,\n );\n const hasAppPreferences = Object.keys(appPreferences).length > 0;\n\n const payload: SettingsUpdateRequest = {};\n\n // Extract agent_settings_diff\n const agentSettingsDiff = rest.agent_settings_diff as\n | Record<string, SettingsValue>\n | undefined;\n if (agentSettingsDiff && Object.keys(agentSettingsDiff).length > 0) {\n payload.agent_settings_diff = agentSettingsDiff;\n }\n\n // Extract conversation_settings_diff\n const conversationSettingsDiff = rest.conversation_settings_diff as\n | Record<string, SettingsValue>\n | undefined;\n if (\n conversationSettingsDiff &&\n Object.keys(conversationSettingsDiff).length > 0\n ) {\n payload.conversation_settings_diff = conversationSettingsDiff;\n }\n\n if (hasAppPreferences) {\n payload.misc_settings_diff = { app_preferences: appPreferences };\n }\n\n const isCloud = getActiveBackend().backend.kind === \"cloud\";\n\n // The backend applies ``agent_settings_diff`` by deep-merging it into the\n // existing ``agent_settings`` dict (see SDK\n // ``openhands.agent_server.persistence.models._deep_merge``). That works\n // for scalar fields but is wrong for ``mcp_config``, which is\n // a name-keyed map: a diff that omits a server cannot remove it (stale\n // key stays), and a diff whose key indices shift (e.g. after deleting\n // index 0, the second server is renumbered) leaves the original keys\n // behind as duplicates pointing to the wrong server config.\n //\n // The only way to make ``mcp_config`` behave like a replace through this\n // API is to first null it out — ``null`` is not a dict, so deep-merge\n // takes the else branch and sets the field to ``None`` outright — and\n // then send the new value in a follow-up call. We do this for every\n // ``mcp_config`` write, including adds (the wasted round-trip is\n // negligible for this user action and avoids divergent code paths).\n const agentDiff = payload.agent_settings_diff;\n // Send a pre-clear PATCH when the diff sets ``mcp_config`` to a non-null\n // value. A second PATCH below then writes the new value. Skipping the\n // pre-clear when the caller is already clearing (``mcp_config: null``)\n // avoids a pointless duplicate request.\n const needsMcpPreClear =\n !!agentDiff && \"mcp_config\" in agentDiff && agentDiff.mcp_config !== null;\n\n // The pre-clear is destructive: if the follow-up write fails after the\n // clear succeeds, the user's MCP config is left empty. Snapshot the\n // previous value (in raw SDK-native shape, NOT the GUI's parsed MCPConfig)\n // before pre-clearing so we can attempt a best-effort rollback. The\n // original write error is always re-thrown to the caller regardless\n // of rollback success — the GUI's react-query mutations surface that\n // as an error toast so the user knows to retry.\n //\n // Snapshot must be the SDK-native server map because that is what the\n // backend expects on the rollback PATCH.\n // ``SettingsService.getSettings`` returns a GUI Settings object whose\n // ``mcp_config`` is typed as the parsed frontend MCPConfig and\n // defaults to empty arrays when nothing is installed, so it is not\n // suitable for round-tripping back to the backend.\n let mcpConfigSnapshot: unknown = undefined;\n if (needsMcpPreClear) {\n try {\n if (isCloud) {\n const raw = (await fetchCloudSettings()) as {\n agent_settings?: { mcp_config?: unknown };\n };\n mcpConfigSnapshot = raw?.agent_settings?.mcp_config;\n } else {\n const raw = (await SettingsService.fetchSettingsFromApi()) as {\n agent_settings?: { mcp_config?: unknown };\n };\n mcpConfigSnapshot = raw?.agent_settings?.mcp_config;\n }\n } catch {\n // Snapshot failed (network blip, etc.). Continue without rollback\n // ability — the original write error will still surface.\n }\n }\n\n // Cloud settings may redact MCP env/header/auth secrets without an\n // encrypted exposure mode. A pre-clear before a non-delete update can\n // permanently erase unchanged secrets; for updates that keep all existing\n // server keys, rely on the backend deep-merge to preserve redacted leaves\n // while applying edited fields and newly typed credentials.\n const shouldUseCloudMergePatchForRedactedMcpSecrets =\n isCloud &&\n needsMcpPreClear &&\n hasRedactedMcpSecrets(mcpConfigSnapshot) &&\n !removesMcpServer(mcpConfigSnapshot, agentDiff?.mcp_config);\n const shouldPreClearMcpConfig =\n needsMcpPreClear && !shouldUseCloudMergePatchForRedactedMcpSecrets;\n\n if (isCloud) {\n const hasCloudWork =\n !!payload.agent_settings_diff ||\n !!payload.conversation_settings_diff ||\n hasAppPreferences;\n if (!hasCloudWork) {\n return true;\n }\n if (shouldPreClearMcpConfig) {\n await withRetry(() =>\n saveCloudSettings({\n agent_settings_diff: { mcp_config: null },\n }),\n );\n }\n // Build the cloud payload from the same diffs, but as a separate\n // object so undefined keys don't appear in the call (saveCloudSettings\n // is called from tests with an exact-shape assertion).\n const cloudPayload: Parameters<typeof saveCloudSettings>[0] = {};\n if (payload.agent_settings_diff) {\n cloudPayload.agent_settings_diff = { ...payload.agent_settings_diff };\n if (\"mcp_config\" in cloudPayload.agent_settings_diff) {\n cloudPayload.agent_settings_diff.mcp_config =\n cloudCompatibleMcpConfig(\n cloudPayload.agent_settings_diff.mcp_config,\n ) as SettingsValue;\n }\n }\n if (payload.conversation_settings_diff) {\n cloudPayload.conversation_settings_diff =\n payload.conversation_settings_diff;\n }\n if (hasAppPreferences) {\n // The cloud `POST /api/v1/settings` takes app-preference fields as\n // flat top-level keys (not under `app_preferences_diff`).\n // `saveCloudSettings` re-flattens them onto the request body.\n cloudPayload.app_preferences = appPreferences;\n }\n try {\n await withRetry(() => saveCloudSettings(cloudPayload));\n } catch (err) {\n if (shouldPreClearMcpConfig && mcpConfigSnapshot) {\n // Best-effort rollback. We deliberately do not wrap in withRetry:\n // the user's session is already in a degraded state and we want\n // to surface the original error promptly. Swallowing the restore\n // error preserves the original failure context for the caller.\n try {\n await saveCloudSettings({\n agent_settings_diff: {\n mcp_config: mcpConfigSnapshot as SettingsValue,\n },\n });\n } catch {\n // Rollback failed; the original error takes precedence.\n }\n }\n throw err;\n }\n } else {\n // The local agent-server PATCH /api/settings requires at least one of\n // the three diff fields. Skip the request entirely if nothing changed.\n const hasLocalDiffs =\n !!payload.agent_settings_diff ||\n !!payload.conversation_settings_diff ||\n !!payload.misc_settings_diff;\n if (!hasLocalDiffs) {\n return true;\n }\n if (shouldPreClearMcpConfig) {\n await withRetry(() =>\n new SettingsClient(getAgentServerClientOptions()).updateSettings({\n agent_settings_diff: { mcp_config: null },\n }),\n );\n }\n try {\n await withRetry(() =>\n new SettingsClient(getAgentServerClientOptions()).updateSettings(\n payload,\n ),\n );\n } catch (err) {\n if (shouldPreClearMcpConfig && mcpConfigSnapshot) {\n // See cloud branch above for rationale.\n try {\n await new SettingsClient(\n getAgentServerClientOptions(),\n ).updateSettings({\n agent_settings_diff: {\n mcp_config: mcpConfigSnapshot as SettingsValue,\n },\n });\n } catch {\n // Rollback failed; the original error takes precedence.\n }\n }\n throw err;\n }\n }\n\n // Invalidate cache after successful save\n clearCache();\n\n return true;\n }\n\n /**\n * Invalidate the settings cache.\n * Call this when settings may have changed externally.\n */\n static invalidateCache(): void {\n clearCache();\n }\n}\n\nexport default SettingsService;\n"],"mappings":";;;;;;;;AAuBA,IAAa,IAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACD,EAsDK,IAAgD,IAAI,IACxD,EACD,EAEK,KAAwB,MAC5B,EAAyB,IAAI,EAAI,EAQ7B,KACJ,MACiE;CACjE,IAAM,IAA4B,EAAE,EAC9B,IAAgC,EAAE;AACxC,MAAK,IAAM,CAAC,GAAK,MAAU,OAAO,QAAQ,EAAM,CAC9C,CAAI,EAAqB,EAAI,GAC1B,EAAsC,KAAO,IAE9C,EAAK,KAAO;AAGhB,QAAO;EAAE;EAAW;EAAM;GAYtB,KAAgB,MAAgB,KAAK,MAAM,KAAK,UAAU,EAAM,CAAC,EAEjE,KACJ,GACA,OACI;CAAE,GAAI,KAAQ,EAAE;CAAG,GAAI,KAAQ,EAAE;CAAG;AAK1C,eAAe,EACb,GACA,IAAqB,GACrB,IAAsB,KACV;AACZ,MAAK,IAAI,IAAU,GAAG,IAAU,GAAY,KAAW,EACrD,KAAI;AACF,SAAO,MAAM,GAAI;UACV,GAAO;AACd,MAAI,KAAW,IAAa,EAC1B,OAAM;EAGR,IAAM,IAAQ,IAAc,KAAK;AAEjC,QAAM,IAAI,SAAe,MAAY;AACnC,cAAW,GAAS,EAAM;IAC1B;;AAIN,OAAU,MAAM,2BAA2B;;AAO7C,IAAI,IAOA;CACF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UAAM,QACJ,IAAI,EAAe,GAA6B,CAAC,CAAC,eAChD,EACD,CACF;YACM,GAAK;AACZ,QAAI,KAA2B,EAE7B,KAAI;AACF,WAAM,IAAI,EACR,GAA6B,CAC9B,CAAC,eAAe,EACf,qBAAqB,EACnB,YAAY,GACb,EACF,CAAC;YACI;AAIV,UAAM;;;AAOV,SAFA,GAAY,EAEL;;CAOT,OAAO,kBAAwB;AAC7B,KAAY"}
|
package/dist/components/conversation-events/chat/event-message-components/critic-result-display.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`../../../../_virtual/_rolldown/runtime.cjs`),t=require(`../../../../node_modules/react-i18next/dist/es/useTranslation.cjs`),n=require(`../../../../i18n/declaration.cjs`),r=require(`../../../../
|
|
1
|
+
const e=require(`../../../../_virtual/_rolldown/runtime.cjs`),t=require(`../../../../node_modules/react-i18next/dist/es/useTranslation.cjs`),n=require(`../../../../i18n/declaration.cjs`),r=require(`../../../../icons/angle-down-solid.cjs`),i=require(`../../../../icons/angle-up-solid.cjs`),a=require(`../../../../hooks/query/use-settings.cjs`);let o=require(`react`);o=e.__toESM(o,1);let s=require(`react/jsx-runtime`);function c(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function l(e){let t=Math.round(e*5);return{filled:t,empty:5-t}}function u(e){return e>=.6?`text-green-400`:e>=.4?`text-yellow-400`:`text-red-400`}function d(e){return e>=.7?`text-red-400 font-semibold`:e>=.5?`text-yellow-400`:`text-neutral-400`}function f(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function p(e){let t=e?.verification;if(!f(t))return null;let n=t.enable_iterative_refinement;return typeof n==`boolean`?n:null}function m({feature:e}){let t=Math.round(e.probability*100),n=d(e.probability);return(0,s.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,s.jsx)(`span`,{className:`text-neutral-200`,children:e.display_name}),(0,s.jsxs)(`span`,{className:n,children:[`(`,t,`%)`]})]})}function h({label:e,features:t}){return!t||t.length===0?null:(0,s.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1 text-xs`,children:[(0,s.jsx)(`span`,{className:`font-semibold text-neutral-300`,children:e}),t.map((e,t)=>(0,s.jsxs)(o.default.Fragment,{children:[t>0&&(0,s.jsx)(`span`,{className:`text-neutral-500`,children:`·`}),(0,s.jsx)(m,{feature:e})]},e.name))]})}function g({categorized:e}){let{t:r}=t.useTranslation(),i=e.agent_behavioral_issues&&e.agent_behavioral_issues.length>0,a=e.user_followup_patterns&&e.user_followup_patterns.length>0,o=e.infrastructure_issues&&e.infrastructure_issues.length>0,c=e.other&&e.other.length>0;return!i&&!a&&!o&&!c?null:(0,s.jsxs)(`div`,{className:`flex flex-col gap-1 mt-1.5`,children:[i&&(0,s.jsx)(h,{label:r(n.I18nKey.CRITIC$POTENTIAL_ISSUES),features:e.agent_behavioral_issues}),o&&(0,s.jsx)(h,{label:r(n.I18nKey.CRITIC$INFRASTRUCTURE),features:e.infrastructure_issues}),a&&(0,s.jsx)(h,{label:r(n.I18nKey.CRITIC$LIKELY_FOLLOWUP),features:e.user_followup_patterns}),c&&(0,s.jsx)(h,{label:r(n.I18nKey.CRITIC$OTHER),features:e.other})]})}function _({criticResult:e}){let{t:d}=t.useTranslation(),{data:f}=a.useSettings(),[m,h]=o.default.useState(!1),_=c(e.score),{filled:v,empty:y}=l(_),b=u(_),x=(_*100).toFixed(1),S=p(f?.agent_settings)===!1,C=e.metadata?.categorized_features,w=C!=null&&((C.agent_behavioral_issues??[]).length>0||(C.user_followup_patterns??[]).length>0||(C.infrastructure_issues??[]).length>0||(C.other??[]).length>0);return(0,s.jsxs)(`div`,{className:`border-l-2 border-neutral-600 pl-2 my-2 py-1.5 text-sm`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,s.jsx)(`span`,{className:`font-semibold text-neutral-300 text-xs`,children:d(n.I18nKey.CRITIC$SUCCESS_LIKELIHOOD_LABEL)}),(0,s.jsxs)(`span`,{className:`${b} text-xs tracking-wide`,"aria-label":`Score: ${x}%`,children:[`★`.repeat(v),`☆`.repeat(y)]}),(0,s.jsxs)(`span`,{className:`text-neutral-500 text-xs`,children:[`(`,x,`%)`]}),w&&(0,s.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),className:`cursor-pointer ml-1`,"aria-label":d(m?n.I18nKey.BUTTON$COLLAPSE_DETAILS:n.I18nKey.BUTTON$EXPAND_DETAILS),children:m?(0,s.jsx)(i.default,{className:`h-3 w-3 inline fill-neutral-400`}):(0,s.jsx)(r.default,{className:`h-3 w-3 inline fill-neutral-400`})})]}),m&&w&&(0,s.jsx)(g,{categorized:C}),S&&(0,s.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-neutral-500`,"data-testid":`critic-iterative-refinement-hint`,children:d(n.I18nKey.CRITIC$ITERATIVE_REFINEMENT_HINT)})]})}exports.CriticResultDisplay=_;
|
|
2
2
|
//# sourceMappingURL=critic-result-display.cjs.map
|
package/dist/components/conversation-events/chat/event-message-components/critic-result-display.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useTranslation as e } from "../../../../node_modules/react-i18next/dist/es/useTranslation.js";
|
|
2
2
|
import { I18nKey as t } from "../../../../i18n/declaration.js";
|
|
3
|
-
import
|
|
4
|
-
import r from "../../../../icons/angle-
|
|
5
|
-
import i from "../../../../
|
|
3
|
+
import n from "../../../../icons/angle-down-solid.js";
|
|
4
|
+
import r from "../../../../icons/angle-up-solid.js";
|
|
5
|
+
import { useSettings as i } from "../../../../hooks/query/use-settings.js";
|
|
6
6
|
import a from "react";
|
|
7
7
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
8
|
//#region src/components/conversation-events/chat/event-message-components/critic-result-display.tsx
|
|
@@ -85,7 +85,7 @@ function g({ categorized: n }) {
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
function _({ criticResult: d }) {
|
|
88
|
-
let { t: f } = e(), { data: m } =
|
|
88
|
+
let { t: f } = e(), { data: m } = i(), [h, _] = a.useState(!1), v = c(d.score), { filled: y, empty: b } = l(v), x = u(v), S = (v * 100).toFixed(1), C = p(m?.agent_settings) === !1, w = d.metadata?.categorized_features, T = w != null && ((w.agent_behavioral_issues ?? []).length > 0 || (w.user_followup_patterns ?? []).length > 0 || (w.infrastructure_issues ?? []).length > 0 || (w.other ?? []).length > 0);
|
|
89
89
|
return /* @__PURE__ */ s("div", {
|
|
90
90
|
className: "border-l-2 border-neutral-600 pl-2 my-2 py-1.5 text-sm",
|
|
91
91
|
children: [
|
|
@@ -114,7 +114,7 @@ function _({ criticResult: d }) {
|
|
|
114
114
|
onClick: () => _((e) => !e),
|
|
115
115
|
className: "cursor-pointer ml-1",
|
|
116
116
|
"aria-label": f(h ? t.BUTTON$COLLAPSE_DETAILS : t.BUTTON$EXPAND_DETAILS),
|
|
117
|
-
children: o(h ?
|
|
117
|
+
children: o(h ? r : n, { className: "h-3 w-3 inline fill-neutral-400" })
|
|
118
118
|
})
|
|
119
119
|
]
|
|
120
120
|
}),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`../../../_virtual/_rolldown/runtime.cjs`),t=require(`../../../node_modules/react-i18next/dist/es/useTranslation.cjs`),n=require(`../../../i18n/declaration.cjs`),r=require(`../../../utils/utils.cjs`),i=require(`../../../context/navigation-context.cjs`),a=require(`../../../node_modules/@openhands/typescript-client/dist/client/server-client.cjs`),o=require(`../../../node_modules/@openhands/typescript-client/dist/client/device-flow-client.cjs`);require(`../../../node_modules/@openhands/typescript-client/dist/clients.cjs`);const s=require(`../../../api/agent-server-config.cjs`),c=require(`../../../api/agent-server-client-options.cjs`),l=require(`../../../api/agent-server-compatibility.cjs`),u=require(`../../../utils/user-facing-error.cjs`),d=require(`../../../node_modules/@tanstack/react-query/build/modern/useQuery.cjs`),f=require(`../../../contexts/active-backend-context.cjs`);require(`../../../api/device-flow-client.cjs`);const p=require(`../../../hooks/use-tracking.cjs`),m=require(`../../shared/modals/modal-backdrop.cjs`),h=require(`../../shared/modals/modal-body.cjs`),g=require(`../../../utils/modal-classes.cjs`),_=require(`../../shared/modals/modal-close-button.cjs`),v=require(`../settings/brand-button.cjs`),y=require(`../settings/settings-input.cjs`),b=require(`../../../hooks/query/use-backends-health.cjs`),x=require(`../../../assets/branding/openhands-logo-white.cjs`),S=require(`../files-tab/segmented-toggle.cjs`),C=require(`../../../icons/chevron-down-small.cjs`),w=require(`./backend-status-label.cjs`),T=require(`./backend-status-dot.cjs`),E=require(`./device-flow-auth.cjs`);let D=require(`react`);D=e.__toESM(D,1);let O=require(`react/jsx-runtime`);function k(e){return o.isOpenHandsCloudHost(e)?`cloud`:`local`}function A(e){let t=e.toLowerCase().replace(/^\[|\]$/g,``);return!!(t===`localhost`||t===`::1`||t===`::`||t===`0.0.0.0`||/^127\./.test(t)||/^::ffff:127\./i.test(t)||/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[01])\./.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)||/^f[cd][0-9a-f]{2}:/i.test(t)||t.endsWith(`.local`)||!t.includes(`.`)&&!t.includes(`:`))}function j(e){let t=e.trim().replace(/\/+$/,``);if(!t)return``;if(/^https?:\/\//i.test(t))return t;let n=t.match(/^\[([^\]]+)\]/);return`${A(n?n[1]:(t.match(/:/g)??[]).length>1?t:t.split(`:`)[0])?`http`:`https`}://${t}`}function M(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=j(t);if(!n)return!1;try{let e=new URL(n);return(e.protocol===`http:`||e.protocol===`https:`)&&e.hostname.length>0}catch{return!1}}var N=`https://app.all-hands.dev`;function P(e,t){return e(n.I18nKey.BACKEND$CONNECTION_TEST_FAILED,{host:t,interpolation:{escapeValue:!1}})}function F(e){return u.getUserFacingConnectionErrorMessage(e)}function I(e,t){let n=F(t);return n?`${e}\n${n}`:e}async function L(e){e.kind===`local`&&l.assertAgentServerVersionIsSupported(await new a.ServerClient(c.getAgentServerClientOptions({host:e.host,sessionApiKey:e.apiKey||null,timeout:5e3})).getServerInfo())}function R({backend:e,testIdRoot:r}){let{t:i}=t.useTranslation(`openhands`),o=b.useBackendsHealth([e])[e.id],s=o?.isConnected??null,u=o?.disabled===!0,f=o?.consecutiveFailures??0,p=o?.lastError??null,{data:m}=d.useQuery({queryKey:[`backend-version`,e.host,e.apiKey],queryFn:async()=>l.getDisplayAgentServerVersion(await new a.ServerClient(c.getAgentServerClientOptions({host:e.host,sessionApiKey:e.apiKey||null,timeout:5e3})).getServerInfo()),retry:!1,staleTime:6e4,enabled:e.kind===`local`&&!u}),h=w.getBackendStatusLabel(i,e,o),g=e.kind===`cloud`?i(n.I18nKey.BACKEND$KIND_CLOUD):i(n.I18nKey.BACKEND$KIND_LOCAL);return(0,O.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,O.jsxs)(`div`,{"data-testid":`${r}-status`,className:`flex items-center gap-3 text-sm`,children:[(0,O.jsx)(T.BackendStatusDot,{isConnected:s}),(0,O.jsx)(`span`,{className:`text-white`,"data-testid":`${r}-status-label`,children:h}),(0,O.jsx)(`span`,{className:`text-tertiary-alt`,children:`·`}),(0,O.jsx)(`span`,{className:`text-[var(--oh-text-tertiary)]`,children:g}),m?(0,O.jsx)(`span`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`${r}-version`,children:i(n.I18nKey.BACKEND$VERSION_LABEL,{version:m})}):null]}),u?(0,O.jsxs)(`div`,{"data-testid":`${r}-status-error`,className:`flex flex-col gap-1 rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm`,children:[(0,O.jsx)(`span`,{className:`font-semibold text-red-300`,children:i(n.I18nKey.BACKEND$HEALTH_FAILED_TITLE)}),(0,O.jsx)(`span`,{className:`text-xs text-[var(--oh-text-tertiary)]`,children:i(n.I18nKey.BACKEND$HEALTH_FAILED_DETAIL,{count:f})}),p?(0,O.jsx)(`span`,{"data-testid":`${r}-status-error-message`,className:`text-xs text-red-300 whitespace-pre-wrap break-words`,children:p}):null]}):null]})}function z({initialName:e=``,initialHost:n=``,initialApiKey:r=``,onTestConnection:i,onSuccess:a,requireApiKey:o=!1,onSubmitOverride:s}){let{t:c}=t.useTranslation(`openhands`),[l,u]=D.default.useState(e),[d,f]=D.default.useState(n),[p,m]=D.default.useState(r),[h,g]=D.default.useState(null),[_,v]=D.default.useState(!1),[y,b]=D.default.useState(null),x=y??k(d),S=o||x!==`local`,C=l.trim().length>0&&M(d)&&(!S||p.trim().length>0);return{name:l,setName:u,host:d,setHost:f,apiKey:p,setApiKey:m,connectionError:h,setConnectionError:g,isSubmitting:_,kind:x,setKind:b,canSubmit:C,handleSubmit:D.default.useCallback(async e=>{if(e.preventDefault(),!C||_)return;let t={name:l.trim(),host:j(d),apiKey:p.trim(),kind:x};g(null),v(!0);try{s?await s(t):(await i(t),a())}catch(e){g(I(P(c,t.host),e))}finally{v(!1)}},[C,_,l,d,p,x,i,a,o,s,c])}}function B({mode:e,backend:i,onSubmitted:a,renderActions:o,testIdRoot:s,hostReadOnly:c,requireApiKey:l,hideConfigurationFields:u=!1,onSubmitOverride:d}){let{t:p}=t.useTranslation(`openhands`),{addBackend:m,updateBackend:h}=f.useActiveBackendContext(),g=e===`edit`&&i?i.kind:null,{name:_,setName:b,host:x,setHost:S,apiKey:C,setApiKey:w,connectionError:T,setConnectionError:E,isSubmitting:k,kind:A,handleSubmit:P}=z({initialName:i?.name??``,initialHost:i?.host??``,initialApiKey:i?.apiKey??``,onTestConnection:L,onSuccess:async()=>{let t={name:_.trim(),host:j(x),apiKey:C.trim(),kind:g??A};e===`edit`&&i?h(i.id,t):m(t),a()},requireApiKey:l,onSubmitOverride:d}),[F,I]=D.default.useState(!1),[B,V]=D.default.useState(!1),H=g??A,U=s??(e===`edit`?`edit-backend`:`add-backend`),W=l||H!==`local`,G=_.trim().length>0&&M(x)&&(!W||C.trim().length>0),K=F&&!_.trim()?p(n.I18nKey.BACKEND$NAME_REQUIRED):void 0,q=B?x.trim()?M(x)?void 0:p(n.I18nKey.BACKEND$HOST_INVALID):p(n.I18nKey.BACKEND$HOST_REQUIRED):void 0;return(0,O.jsxs)(`form`,{"data-testid":`${U}-form`,onSubmit:async e=>{if(!G){I(!0),V(!0);return}await P(e)},className:`flex flex-col gap-4`,children:[(0,O.jsxs)(`div`,{"data-testid":`${U}-configuration-fields`,className:r.cn(`flex flex-col gap-4`,u&&`hidden`),children:[(0,O.jsx)(y.SettingsInput,{testId:`${U}-name`,name:`${U}-name`,type:`text`,label:p(n.I18nKey.BACKEND$NAME_LABEL),value:_,onChange:e=>{b(e),E(null)},onBlur:()=>I(!0),placeholder:`Production`,className:`w-full`,showRequiredTag:!0,error:K}),(0,O.jsx)(y.SettingsInput,{testId:`${U}-host`,name:`${U}-host`,type:`text`,label:p(n.I18nKey.BACKEND$HOST_LABEL),value:x,onChange:c?void 0:e=>{S(e),E(null)},onBlur:()=>V(!0),placeholder:N,className:`w-full`,showRequiredTag:!0,error:q,isDisabled:c}),(0,O.jsx)(y.SettingsInput,{testId:`${U}-api-key`,name:`${U}-api-key`,type:`password`,label:p(n.I18nKey.BACKEND$KEY_LABEL),value:C,onChange:e=>{w(e),E(null)},placeholder:``,className:`w-full`}),T?(0,O.jsx)(`div`,{role:`alert`,"data-testid":`${U}-error`,className:`rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm text-red-300 whitespace-pre-wrap break-words`,children:T}):null,e===`edit`&&i&&(0,O.jsx)(R,{backend:i,testIdRoot:U})]}),o?o({canSubmit:G&&!k,isSubmitting:k,testIdRoot:U}):(0,O.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2 w-full`,children:[(0,O.jsx)(v.BrandButton,{type:`button`,variant:`secondary`,onClick:a,testId:`${U}-cancel`,children:p(n.I18nKey.BUTTON$CANCEL)}),(0,O.jsx)(v.BrandButton,{type:`submit`,variant:`primary`,isDisabled:!G||k,testId:`${U}-submit`,children:p(n.I18nKey.BACKEND$SAVE)})]})]})}function V(){let{currentPath:e,navigate:t}=i.useNavigation();return D.default.useCallback(()=>{/^\/automations\/[^/]+/.test(e)?t(`/automations`):/^\/conversations\/[^/]+/.test(e)&&t(`/conversations`)},[e,t])}function H({onConnected:e,testIdRoot:r=`add-backend`,initialManualBackend:i,requireManualApiKey:a=!1,manualSubmitLabel:o,manualSubmittingLabel:c,manualSubmitTestId:l,analyticsSource:u}){let{t:d}=t.useTranslation(`openhands`),f=s.getLockedCloudHost();return f?(0,O.jsx)(`div`,{"data-testid":`${r}-connection-options`,className:`flex justify-center`,children:(0,O.jsx)(`div`,{className:`w-full`,children:(0,O.jsx)(W,{onConnected:e,testIdRoot:r,lockedHost:f,analyticsSource:u})})}):(0,O.jsxs)(`div`,{"data-testid":`${r}-connection-options`,className:`flex flex-col gap-6 md:flex-row`,children:[(0,O.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,O.jsx)(U,{onConnected:e,testIdRoot:r,initialBackend:i,requireApiKey:a,submitLabel:o??d(n.I18nKey.BACKEND$CONNECT),submittingLabel:c??d(n.I18nKey.ONBOARDING$BACKEND_STATUS_CHECKING),submitTestId:l})}),(0,O.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,O.jsx)(W,{onConnected:e,testIdRoot:r,analyticsSource:u})})]})}function U({onConnected:e,testIdRoot:r,initialBackend:i,requireApiKey:a,submitLabel:o,submittingLabel:s,submitTestId:c}){let{t:l}=t.useTranslation(`openhands`),{name:u,setName:d,host:f,setHost:p,apiKey:m,setApiKey:h,connectionError:g,setConnectionError:_,isSubmitting:b,kind:x,setKind:C,canSubmit:w,handleSubmit:T}=z({initialName:i?.name??``,initialHost:i?.host??``,initialApiKey:i?.apiKey??``,onTestConnection:L,onSuccess:()=>{e({name:u.trim(),host:j(f),apiKey:m.trim(),kind:x},`manual`)},requireApiKey:a});return(0,O.jsxs)(`form`,{"data-testid":`${r}-form`,onSubmit:T,className:`flex flex-col gap-4 flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(y.SettingsInput,{testId:`${r}-name`,name:`${r}-name`,type:`text`,label:l(n.I18nKey.BACKEND$NAME_LABEL),value:u,onChange:e=>{d(e),_(null)},placeholder:`e.g. My Server`,className:`w-full`}),(0,O.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,children:l(n.I18nKey.BACKEND$NAME_HELPER)})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(y.SettingsInput,{testId:`${r}-host`,name:`${r}-host`,type:`text`,label:l(n.I18nKey.BACKEND$HOST_LABEL),value:f,onChange:e=>{p(e),_(null)},placeholder:`http://localhost:8000`,className:`w-full`}),(0,O.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`${r}-host-helper`,children:l(n.I18nKey.BACKEND$HOST_HELPER)})]}),(0,O.jsxs)(`div`,{className:`flex flex-col items-start gap-2.5`,children:[(0,O.jsx)(`span`,{className:`text-sm`,children:l(n.I18nKey.BACKEND$KIND_LABEL)}),(0,O.jsx)(S.SegmentedToggle,{value:x,options:[{value:`local`,label:l(n.I18nKey.BACKEND$KIND_LOCAL)},{value:`cloud`,label:l(n.I18nKey.BACKEND$KIND_CLOUD)}],onChange:e=>C(e),ariaLabel:l(n.I18nKey.BACKEND$KIND_LABEL),testId:`${r}-kind`})]}),(0,O.jsx)(y.SettingsInput,{testId:`${r}-api-key`,name:`${r}-api-key`,type:`password`,label:l(n.I18nKey.BACKEND$KEY_LABEL),value:m,onChange:e=>{h(e),_(null)},placeholder:`sk-••••••••••`,className:`w-full`}),g?(0,O.jsx)(`div`,{role:`alert`,"data-testid":`${r}-error`,className:`rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm text-red-300 whitespace-pre-wrap break-words`,children:g}):null,(0,O.jsx)(v.BrandButton,{type:`submit`,variant:`secondary`,isDisabled:!w||b,testId:c??`${r}-submit`,className:`w-full text-center`,children:b?s:o})]})}function W({onConnected:e,testIdRoot:i,lockedHost:a,analyticsSource:o}){let{t:s}=t.useTranslation(`openhands`),[c,l]=D.default.useState(!1),[u,d]=D.default.useState(``),f=a??(u.trim()||N);return(0,O.jsxs)(`div`,{className:`flex flex-1 min-w-0 flex-col items-center gap-3 pb-8`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,O.jsx)(x.default,{width:56,height:56,"aria-hidden":!0}),(0,O.jsx)(`h4`,{className:g.modalTitleLgMediumClassName,"data-testid":`${i}-cloud-title`,children:s(n.I18nKey.BACKEND$CLOUD_TITLE)})]}),(0,O.jsx)(`p`,{className:`text-center text-sm leading-relaxed text-[var(--oh-muted)]`,children:s(n.I18nKey.BACKEND$CLOUD_DESCRIPTION)}),(0,O.jsx)(E.DeviceFlowAuth,{host:f,onSuccess:t=>{e({name:`OpenHands Cloud`,host:j(f),apiKey:t,kind:`cloud`},`cloud_login`)},testIdRoot:i,analyticsSource:o}),a?null:(0,O.jsxs)(`div`,{className:`w-full`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,"data-testid":`${i}-advanced-toggle`,className:`flex w-full cursor-pointer items-center justify-center gap-1 text-center text-xs text-[var(--oh-muted)] transition-colors hover:text-content-2`,children:[(0,O.jsx)(`span`,{children:s(n.I18nKey.BACKEND$ADVANCED)}),(0,O.jsx)(C.default,{className:r.cn(`h-4 w-4 shrink-0 text-muted transition-transform`,c&&`rotate-180`),"aria-hidden":!0})]}),(0,O.jsxs)(`div`,{className:r.cn(`pt-2`,!c&&`pointer-events-none invisible`),"aria-hidden":!c,children:[(0,O.jsx)(y.SettingsInput,{testId:`${i}-cloud-host`,name:`${i}-cloud-host`,type:`text`,label:s(n.I18nKey.BACKEND$HOST_LABEL),value:u,onChange:d,placeholder:N,className:`w-full`}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oh-muted)]`,children:s(n.I18nKey.BACKEND$LOGIN_CLOUD_HINT)})]})]})]})}function G({onClose:e,source:t}){let{addBackend:n}=f.useActiveBackendContext(),r=V(),{trackBackendAdded:i}=p.useTracking();return(0,O.jsx)(H,{onConnected:D.default.useCallback((a,s)=>{n(a);let c=o.isOpenHandsCloudHost(a.host);i({backendKind:a.kind,connectionMethod:s,isOpenhandsCloud:c,isCustomHost:!c,hasApiKey:!!a.apiKey,source:t}),r(),e()},[n,r,e,i,t]),analyticsSource:t})}function K({mode:e,backend:i,onClose:a,source:o=`add_backend_modal`,hideCloseButton:s=!1}){let{t:c}=t.useTranslation(`openhands`);if(e===`add`)return(0,O.jsx)(m.ModalBackdrop,{onClose:s?void 0:a,closeOnEscape:!1,closeOnBackdropClick:!s,"aria-label":c(n.I18nKey.BACKEND$ADD_TITLE),children:(0,O.jsxs)(`div`,{"data-testid":s?`onboarding-modal`:`add-backend-modal`,className:r.cn(`relative rounded-xl border border-[var(--oh-border)] bg-base-secondary`,h.modalWidthClassName(`xl`),h.MODAL_MAX_WIDTH_VIEWPORT),children:[s?null:(0,O.jsx)(_.ModalCloseButton,{onClose:a,testId:`add-backend-close`}),s?null:(0,O.jsx)(`div`,{className:`px-6 pt-6 pb-2 pr-12`,children:(0,O.jsx)(`h2`,{className:g.modalTitleLgClassName,children:c(n.I18nKey.BACKEND$ADD_TITLE)})}),(0,O.jsx)(`div`,{className:r.cn(`px-6 pb-6`,s?`pt-6`:`pt-2`),children:(0,O.jsx)(G,{onClose:a,source:o})})]})});let l=`edit-backend`;return(0,O.jsx)(m.ModalBackdrop,{onClose:a,closeOnEscape:!1,"aria-label":c(n.I18nKey.BACKEND$EDIT_TITLE),children:(0,O.jsxs)(`div`,{"data-testid":`${l}-modal`,className:r.cn(`relative bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]`,h.modalWidthClassName(`md`)),children:[(0,O.jsx)(_.ModalCloseButton,{onClose:a,testId:`${l}-close`}),(0,O.jsx)(`h2`,{className:r.cn(`pr-6`,g.modalTitleLgClassName),children:c(n.I18nKey.BACKEND$EDIT_TITLE)}),(0,O.jsx)(B,{mode:`edit`,backend:i,onSubmitted:a,testIdRoot:l})]})})}exports.BackendFormModal=K;
|
|
1
|
+
const e=require(`../../../_virtual/_rolldown/runtime.cjs`),t=require(`../../../node_modules/react-i18next/dist/es/useTranslation.cjs`),n=require(`../../../i18n/declaration.cjs`),r=require(`../../../utils/utils.cjs`),i=require(`../../../context/navigation-context.cjs`),a=require(`../../../node_modules/@openhands/typescript-client/dist/client/server-client.cjs`),o=require(`../../../node_modules/@openhands/typescript-client/dist/client/device-flow-client.cjs`);require(`../../../node_modules/@openhands/typescript-client/dist/clients.cjs`);const s=require(`../../../api/agent-server-config.cjs`),c=require(`../../../api/agent-server-client-options.cjs`),l=require(`../../../api/agent-server-compatibility.cjs`),u=require(`../../../utils/user-facing-error.cjs`),d=require(`../../../node_modules/@tanstack/react-query/build/modern/useQuery.cjs`),f=require(`../../../contexts/active-backend-context.cjs`),p=require(`../../../hooks/use-tracking.cjs`),m=require(`../../shared/modals/modal-backdrop.cjs`),h=require(`../../shared/modals/modal-body.cjs`),g=require(`../../../utils/modal-classes.cjs`),_=require(`../../shared/modals/modal-close-button.cjs`),v=require(`../settings/brand-button.cjs`),y=require(`../settings/settings-input.cjs`),b=require(`../../../hooks/query/use-backends-health.cjs`),x=require(`../../../assets/branding/openhands-logo-white.cjs`),S=require(`../files-tab/segmented-toggle.cjs`);require(`../../../api/device-flow-client.cjs`);const C=require(`../../../icons/chevron-down-small.cjs`),w=require(`./backend-status-label.cjs`),T=require(`./backend-status-dot.cjs`),E=require(`./device-flow-auth.cjs`);let D=require(`react`);D=e.__toESM(D,1);let O=require(`react/jsx-runtime`);function k(e){return o.isOpenHandsCloudHost(e)?`cloud`:`local`}function A(e){let t=e.toLowerCase().replace(/^\[|\]$/g,``);return!!(t===`localhost`||t===`::1`||t===`::`||t===`0.0.0.0`||/^127\./.test(t)||/^::ffff:127\./i.test(t)||/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[01])\./.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)||/^f[cd][0-9a-f]{2}:/i.test(t)||t.endsWith(`.local`)||!t.includes(`.`)&&!t.includes(`:`))}function j(e){let t=e.trim().replace(/\/+$/,``);if(!t)return``;if(/^https?:\/\//i.test(t))return t;let n=t.match(/^\[([^\]]+)\]/);return`${A(n?n[1]:(t.match(/:/g)??[]).length>1?t:t.split(`:`)[0])?`http`:`https`}://${t}`}function M(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=j(t);if(!n)return!1;try{let e=new URL(n);return(e.protocol===`http:`||e.protocol===`https:`)&&e.hostname.length>0}catch{return!1}}var N=`https://app.all-hands.dev`;function P(e,t){return e(n.I18nKey.BACKEND$CONNECTION_TEST_FAILED,{host:t,interpolation:{escapeValue:!1}})}function F(e){return u.getUserFacingConnectionErrorMessage(e)}function I(e,t){let n=F(t);return n?`${e}\n${n}`:e}async function L(e){if(e.kind!==`local`)return{agentServerVersion:null};let t=await new a.ServerClient(c.getAgentServerClientOptions({host:e.host,sessionApiKey:e.apiKey||null,timeout:5e3})).getServerInfo();return l.assertAgentServerVersionIsSupported(t),{agentServerVersion:l.getDisplayAgentServerVersion(t)}}function R({backend:e,testIdRoot:r}){let{t:i}=t.useTranslation(`openhands`),o=b.useBackendsHealth([e])[e.id],s=o?.isConnected??null,u=o?.disabled===!0,f=o?.consecutiveFailures??0,p=o?.lastError??null,{data:m}=d.useQuery({queryKey:[`backend-version`,e.host,e.apiKey],queryFn:async()=>l.getDisplayAgentServerVersion(await new a.ServerClient(c.getAgentServerClientOptions({host:e.host,sessionApiKey:e.apiKey||null,timeout:5e3})).getServerInfo()),retry:!1,staleTime:6e4,enabled:e.kind===`local`&&!u}),h=w.getBackendStatusLabel(i,e,o),g=e.kind===`cloud`?i(n.I18nKey.BACKEND$KIND_CLOUD):i(n.I18nKey.BACKEND$KIND_LOCAL);return(0,O.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,O.jsxs)(`div`,{"data-testid":`${r}-status`,className:`flex items-center gap-3 text-sm`,children:[(0,O.jsx)(T.BackendStatusDot,{isConnected:s}),(0,O.jsx)(`span`,{className:`text-white`,"data-testid":`${r}-status-label`,children:h}),(0,O.jsx)(`span`,{className:`text-tertiary-alt`,children:`·`}),(0,O.jsx)(`span`,{className:`text-[var(--oh-text-tertiary)]`,children:g}),m?(0,O.jsx)(`span`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`${r}-version`,children:i(n.I18nKey.BACKEND$VERSION_LABEL,{version:m})}):null]}),u?(0,O.jsxs)(`div`,{"data-testid":`${r}-status-error`,className:`flex flex-col gap-1 rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm`,children:[(0,O.jsx)(`span`,{className:`font-semibold text-red-300`,children:i(n.I18nKey.BACKEND$HEALTH_FAILED_TITLE)}),(0,O.jsx)(`span`,{className:`text-xs text-[var(--oh-text-tertiary)]`,children:i(n.I18nKey.BACKEND$HEALTH_FAILED_DETAIL,{count:f})}),p?(0,O.jsx)(`span`,{"data-testid":`${r}-status-error-message`,className:`text-xs text-red-300 whitespace-pre-wrap break-words`,children:p}):null]}):null]})}function z({initialName:e=``,initialHost:n=``,initialApiKey:r=``,onTestConnection:i,onSuccess:a,requireApiKey:o=!1,onSubmitOverride:s}){let{t:c}=t.useTranslation(`openhands`),[l,u]=D.default.useState(e),[d,f]=D.default.useState(n),[p,m]=D.default.useState(r),[h,g]=D.default.useState(null),[_,v]=D.default.useState(!1),[y,b]=D.default.useState(null),x=y??k(d),S=o||x!==`local`,C=l.trim().length>0&&M(d)&&(!S||p.trim().length>0);return{name:l,setName:u,host:d,setHost:f,apiKey:p,setApiKey:m,connectionError:h,setConnectionError:g,isSubmitting:_,kind:x,setKind:b,canSubmit:C,handleSubmit:D.default.useCallback(async e=>{if(e.preventDefault(),!C||_)return;let t={name:l.trim(),host:j(d),apiKey:p.trim(),kind:x};g(null),v(!0);try{s?await s(t):a(await i(t))}catch(e){g(I(P(c,t.host),e))}finally{v(!1)}},[C,_,l,d,p,x,i,a,o,s,c])}}function B({mode:e,backend:i,onSubmitted:a,renderActions:o,testIdRoot:s,hostReadOnly:c,requireApiKey:l,hideConfigurationFields:u=!1,onSubmitOverride:d}){let{t:p}=t.useTranslation(`openhands`),{addBackend:m,updateBackend:h}=f.useActiveBackendContext(),g=e===`edit`&&i?i.kind:null,{name:_,setName:b,host:x,setHost:S,apiKey:C,setApiKey:w,connectionError:T,setConnectionError:E,isSubmitting:k,kind:A,handleSubmit:P}=z({initialName:i?.name??``,initialHost:i?.host??``,initialApiKey:i?.apiKey??``,onTestConnection:L,onSuccess:async()=>{let t={name:_.trim(),host:j(x),apiKey:C.trim(),kind:g??A};e===`edit`&&i?h(i.id,t):m(t),a()},requireApiKey:l,onSubmitOverride:d}),[F,I]=D.default.useState(!1),[B,V]=D.default.useState(!1),H=g??A,U=s??(e===`edit`?`edit-backend`:`add-backend`),W=l||H!==`local`,G=_.trim().length>0&&M(x)&&(!W||C.trim().length>0),K=F&&!_.trim()?p(n.I18nKey.BACKEND$NAME_REQUIRED):void 0,q=B?x.trim()?M(x)?void 0:p(n.I18nKey.BACKEND$HOST_INVALID):p(n.I18nKey.BACKEND$HOST_REQUIRED):void 0;return(0,O.jsxs)(`form`,{"data-testid":`${U}-form`,onSubmit:async e=>{if(!G){I(!0),V(!0);return}await P(e)},className:`flex flex-col gap-4`,children:[(0,O.jsxs)(`div`,{"data-testid":`${U}-configuration-fields`,className:r.cn(`flex flex-col gap-4`,u&&`hidden`),children:[(0,O.jsx)(y.SettingsInput,{testId:`${U}-name`,name:`${U}-name`,type:`text`,label:p(n.I18nKey.BACKEND$NAME_LABEL),value:_,onChange:e=>{b(e),E(null)},onBlur:()=>I(!0),placeholder:`Production`,className:`w-full`,showRequiredTag:!0,error:K}),(0,O.jsx)(y.SettingsInput,{testId:`${U}-host`,name:`${U}-host`,type:`text`,label:p(n.I18nKey.BACKEND$HOST_LABEL),value:x,onChange:c?void 0:e=>{S(e),E(null)},onBlur:()=>V(!0),placeholder:N,className:`w-full`,showRequiredTag:!0,error:q,isDisabled:c}),(0,O.jsx)(y.SettingsInput,{testId:`${U}-api-key`,name:`${U}-api-key`,type:`password`,label:p(n.I18nKey.BACKEND$KEY_LABEL),value:C,onChange:e=>{w(e),E(null)},placeholder:``,className:`w-full`}),T?(0,O.jsx)(`div`,{role:`alert`,"data-testid":`${U}-error`,className:`rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm text-red-300 whitespace-pre-wrap break-words`,children:T}):null,e===`edit`&&i&&(0,O.jsx)(R,{backend:i,testIdRoot:U})]}),o?o({canSubmit:G&&!k,isSubmitting:k,testIdRoot:U}):(0,O.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2 w-full`,children:[(0,O.jsx)(v.BrandButton,{type:`button`,variant:`secondary`,onClick:a,testId:`${U}-cancel`,children:p(n.I18nKey.BUTTON$CANCEL)}),(0,O.jsx)(v.BrandButton,{type:`submit`,variant:`primary`,isDisabled:!G||k,testId:`${U}-submit`,children:p(n.I18nKey.BACKEND$SAVE)})]})]})}function V(){let{currentPath:e,navigate:t}=i.useNavigation();return D.default.useCallback(()=>{/^\/automations\/[^/]+/.test(e)?t(`/automations`):/^\/conversations\/[^/]+/.test(e)&&t(`/conversations`)},[e,t])}function H({onConnected:e,testIdRoot:r=`add-backend`,initialManualBackend:i,requireManualApiKey:a=!1,manualSubmitLabel:o,manualSubmittingLabel:c,manualSubmitTestId:l,analyticsSource:u}){let{t:d}=t.useTranslation(`openhands`),f=s.getLockedCloudHost();return f?(0,O.jsx)(`div`,{"data-testid":`${r}-connection-options`,className:`flex justify-center`,children:(0,O.jsx)(`div`,{className:`w-full`,children:(0,O.jsx)(W,{onConnected:e,testIdRoot:r,lockedHost:f,analyticsSource:u})})}):(0,O.jsxs)(`div`,{"data-testid":`${r}-connection-options`,className:`flex flex-col gap-6 md:flex-row`,children:[(0,O.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,O.jsx)(U,{onConnected:e,testIdRoot:r,initialBackend:i,requireApiKey:a,submitLabel:o??d(n.I18nKey.BACKEND$CONNECT),submittingLabel:c??d(n.I18nKey.ONBOARDING$BACKEND_STATUS_CHECKING),submitTestId:l})}),(0,O.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,O.jsx)(W,{onConnected:e,testIdRoot:r,analyticsSource:u})})]})}function U({onConnected:e,testIdRoot:r,initialBackend:i,requireApiKey:a,submitLabel:o,submittingLabel:s,submitTestId:c}){let{t:l}=t.useTranslation(`openhands`),{name:u,setName:d,host:f,setHost:p,apiKey:m,setApiKey:h,connectionError:g,setConnectionError:_,isSubmitting:b,kind:x,setKind:C,canSubmit:w,handleSubmit:T}=z({initialName:i?.name??``,initialHost:i?.host??``,initialApiKey:i?.apiKey??``,onTestConnection:L,onSuccess:t=>{e({name:u.trim(),host:j(f),apiKey:m.trim(),kind:x},`manual`,t)},requireApiKey:a});return(0,O.jsxs)(`form`,{"data-testid":`${r}-form`,onSubmit:T,className:`flex flex-col gap-4 flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(y.SettingsInput,{testId:`${r}-name`,name:`${r}-name`,type:`text`,label:l(n.I18nKey.BACKEND$NAME_LABEL),value:u,onChange:e=>{d(e),_(null)},placeholder:`e.g. My Server`,className:`w-full`}),(0,O.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,children:l(n.I18nKey.BACKEND$NAME_HELPER)})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(y.SettingsInput,{testId:`${r}-host`,name:`${r}-host`,type:`text`,label:l(n.I18nKey.BACKEND$HOST_LABEL),value:f,onChange:e=>{p(e),_(null)},placeholder:`http://localhost:8000`,className:`w-full`}),(0,O.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`${r}-host-helper`,children:l(n.I18nKey.BACKEND$HOST_HELPER)})]}),(0,O.jsxs)(`div`,{className:`flex flex-col items-start gap-2.5`,children:[(0,O.jsx)(`span`,{className:`text-sm`,children:l(n.I18nKey.BACKEND$KIND_LABEL)}),(0,O.jsx)(S.SegmentedToggle,{value:x,options:[{value:`local`,label:l(n.I18nKey.BACKEND$KIND_LOCAL)},{value:`cloud`,label:l(n.I18nKey.BACKEND$KIND_CLOUD)}],onChange:e=>C(e),ariaLabel:l(n.I18nKey.BACKEND$KIND_LABEL),testId:`${r}-kind`})]}),(0,O.jsx)(y.SettingsInput,{testId:`${r}-api-key`,name:`${r}-api-key`,type:`password`,label:l(n.I18nKey.BACKEND$KEY_LABEL),value:m,onChange:e=>{h(e),_(null)},placeholder:`sk-••••••••••`,className:`w-full`}),g?(0,O.jsx)(`div`,{role:`alert`,"data-testid":`${r}-error`,className:`rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm text-red-300 whitespace-pre-wrap break-words`,children:g}):null,(0,O.jsx)(v.BrandButton,{type:`submit`,variant:`secondary`,isDisabled:!w||b,testId:c??`${r}-submit`,className:`w-full text-center`,children:b?s:o})]})}function W({onConnected:e,testIdRoot:i,lockedHost:a,analyticsSource:o}){let{t:s}=t.useTranslation(`openhands`),[c,l]=D.default.useState(!1),[u,d]=D.default.useState(``),f=a??(u.trim()||N);return(0,O.jsxs)(`div`,{className:`flex flex-1 min-w-0 flex-col items-center gap-3 pb-8`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,O.jsx)(x.default,{width:56,height:56,"aria-hidden":!0}),(0,O.jsx)(`h4`,{className:g.modalTitleLgMediumClassName,"data-testid":`${i}-cloud-title`,children:s(n.I18nKey.BACKEND$CLOUD_TITLE)})]}),(0,O.jsx)(`p`,{className:`text-center text-sm leading-relaxed text-[var(--oh-muted)]`,children:s(n.I18nKey.BACKEND$CLOUD_DESCRIPTION)}),(0,O.jsx)(E.DeviceFlowAuth,{host:f,onSuccess:t=>{e({name:`OpenHands Cloud`,host:j(f),apiKey:t,kind:`cloud`},`cloud_login`)},testIdRoot:i,analyticsSource:o}),a?null:(0,O.jsxs)(`div`,{className:`w-full`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,"data-testid":`${i}-advanced-toggle`,className:`flex w-full cursor-pointer items-center justify-center gap-1 text-center text-xs text-[var(--oh-muted)] transition-colors hover:text-content-2`,children:[(0,O.jsx)(`span`,{children:s(n.I18nKey.BACKEND$ADVANCED)}),(0,O.jsx)(C.default,{className:r.cn(`h-4 w-4 shrink-0 text-muted transition-transform`,c&&`rotate-180`),"aria-hidden":!0})]}),(0,O.jsxs)(`div`,{className:r.cn(`pt-2`,!c&&`pointer-events-none invisible`),"aria-hidden":!c,children:[(0,O.jsx)(y.SettingsInput,{testId:`${i}-cloud-host`,name:`${i}-cloud-host`,type:`text`,label:s(n.I18nKey.BACKEND$HOST_LABEL),value:u,onChange:d,placeholder:N,className:`w-full`}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oh-muted)]`,children:s(n.I18nKey.BACKEND$LOGIN_CLOUD_HINT)})]})]})]})}function G({onClose:e,source:t}){let{addBackend:n}=f.useActiveBackendContext(),r=V(),{trackBackendAdded:i}=p.useTracking();return(0,O.jsx)(H,{onConnected:D.default.useCallback((a,o,s)=>{n(a),i({backendKind:a.kind,connectionMethod:o,hasApiKey:!!a.apiKey,source:t,agentServerVersion:s?.agentServerVersion}),r(),e()},[n,r,e,i,t]),analyticsSource:t})}function K({mode:e,backend:i,onClose:a,source:o=`add_backend_modal`,hideCloseButton:s=!1}){let{t:c}=t.useTranslation(`openhands`);if(e===`add`)return(0,O.jsx)(m.ModalBackdrop,{onClose:s?void 0:a,closeOnEscape:!1,closeOnBackdropClick:!s,"aria-label":c(n.I18nKey.BACKEND$ADD_TITLE),children:(0,O.jsxs)(`div`,{"data-testid":s?`onboarding-modal`:`add-backend-modal`,className:r.cn(`relative rounded-xl border border-[var(--oh-border)] bg-base-secondary`,h.modalWidthClassName(`xl`),h.MODAL_MAX_WIDTH_VIEWPORT),children:[s?null:(0,O.jsx)(_.ModalCloseButton,{onClose:a,testId:`add-backend-close`}),s?null:(0,O.jsx)(`div`,{className:`px-6 pt-6 pb-2 pr-12`,children:(0,O.jsx)(`h2`,{className:g.modalTitleLgClassName,children:c(n.I18nKey.BACKEND$ADD_TITLE)})}),(0,O.jsx)(`div`,{className:r.cn(`px-6 pb-6`,s?`pt-6`:`pt-2`),children:(0,O.jsx)(G,{onClose:a,source:o})})]})});let l=`edit-backend`;return(0,O.jsx)(m.ModalBackdrop,{onClose:a,closeOnEscape:!1,"aria-label":c(n.I18nKey.BACKEND$EDIT_TITLE),children:(0,O.jsxs)(`div`,{"data-testid":`${l}-modal`,className:r.cn(`relative bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]`,h.modalWidthClassName(`md`)),children:[(0,O.jsx)(_.ModalCloseButton,{onClose:a,testId:`${l}-close`}),(0,O.jsx)(`h2`,{className:r.cn(`pr-6`,g.modalTitleLgClassName),children:c(n.I18nKey.BACKEND$EDIT_TITLE)}),(0,O.jsx)(B,{mode:`edit`,backend:i,onSubmitted:a,testIdRoot:l})]})})}exports.BackendFormModal=K;
|
|
2
2
|
//# sourceMappingURL=backend-form-modal.cjs.map
|