@openhands/agent-canvas 1.0.0-beta.8 → 1.0.0-beta.9
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 +2 -2
- package/README.windows.md +2 -2
- package/build/assets/{QueryClientProvider-Cnr-Yl3j.js → QueryClientProvider-w1cZWY41.js} +1 -1
- package/build/assets/{Trans-4jmk54WC.js → Trans-BJeYqz2A.js} +1 -1
- package/build/assets/{acp-providers-BAX8OU5C.js → acp-providers-DJr8DlNG.js} +1 -1
- package/build/assets/{acp-route-guard-HPk6TV-L.js → acp-route-guard-A__sWgbc.js} +1 -1
- package/build/assets/{active-backend-context-BSPE-W72.js → active-backend-context-I2w666XY.js} +1 -1
- package/build/assets/add-backend-modal-BDBDBXsJ.js +1 -0
- package/build/assets/agent-server-conversation-service.api-Cagoqq1V.js +5 -0
- package/build/assets/agent-settings-BXBaybB_.js +2 -0
- package/build/assets/{alert-banner-DFnn_lC6.js → alert-banner-NeUl1-PQ.js} +1 -1
- package/build/assets/analytics-consent-form-modal-CmWcFlc6.js +1 -0
- package/build/assets/{api-key-entry-screen-myuWMqzW.js → api-key-entry-screen-ByXA4hXH.js} +1 -1
- package/build/assets/{app-settings-CCcX8ZEH.js → app-settings-C-U6jONZ.js} +1 -1
- package/build/assets/automation-detail-Dbmgt974.js +1 -0
- package/build/assets/automations-list-BLJzAd-p.js +1 -0
- package/build/assets/{back-nav-button-7dQJ2k3O.js → back-nav-button-DgkK0Ka6.js} +1 -1
- package/build/assets/{backend-form-modal-D3bDMO3C.js → backend-form-modal-CeB983Sj.js} +1 -1
- package/build/assets/{backend-synced-settings-badge-BkW5evM0.js → backend-synced-settings-badge-BktJcGgH.js} +1 -1
- package/build/assets/{base-modal-C2oy2EBG.js → base-modal-DZCNv0A4.js} +1 -1
- package/build/assets/{brand-button-DJ_S16rO.js → brand-button-LBFNic99.js} +1 -1
- package/build/assets/browser-D08Sp3ZY.js +5 -0
- package/build/assets/{browser-tab-dvSPdvkm.js → browser-tab-be3QvXg9.js} +1 -1
- package/build/assets/chat-send-button-5qz0zj6R.js +1 -0
- package/build/assets/{checkmark-Dus0b6jt.js → checkmark-Rmpruj7q.js} +1 -1
- package/build/assets/{chevron-left-small-_uvG7RVM.js → chevron-left-small-6nyFCWVQ.js} +1 -1
- package/build/assets/{circle-plus-check-toggle-DKS8MAVV.js → circle-plus-check-toggle-DquBwJ_6.js} +1 -1
- package/build/assets/{close-BU5iTc66.js → close-D_o3d8QM.js} +1 -1
- package/build/assets/{code-tag-BzyqOtPD.js → code-tag-DhsjDB-v.js} +1 -1
- package/build/assets/{combobox-caret-BJC7XJsz.js → combobox-caret-CO7eozIY.js} +1 -1
- package/build/assets/{condenser-settings-DCTulgLO.js → condenser-settings-BulzYEuW.js} +1 -1
- package/build/assets/{confirmation-modal-B5Ca6qFE.js → confirmation-modal-CMAtd9R0.js} +1 -1
- package/build/assets/{context-menu-list-item-7tAcm2c3.js → context-menu-list-item-D0swnhFt.js} +1 -1
- package/build/assets/conversation-BrjF2-Ky.js +1 -0
- package/build/assets/conversation-HgR_TTPE.js +19 -0
- package/build/assets/conversation-panel-BlRcO5AC.js +1 -0
- package/build/assets/conversation-service.api-B_Pdmwsa.js +1 -0
- package/build/assets/{conversation-tab-empty-state-CStQLPVW.js → conversation-tab-empty-state-DYjKsg_c.js} +1 -1
- package/build/assets/conversation-websocket-context-G95yfL81.js +3 -0
- package/build/assets/{copy-Chg-sFu3.js → copy-BM0RpLez.js} +1 -1
- package/build/assets/{custom-toast-handlers-ufGJ6_Rc.js → custom-toast-handlers-BohXx7uh.js} +1 -1
- package/build/assets/{declaration-CR6HMp29.js → declaration-DaUdB2Wg.js} +1 -1
- package/build/assets/{device-verify-C6mj28zv.js → device-verify-DiEJqpJb.js} +1 -1
- package/build/assets/dist-Bl-1K5Tv.js +1 -0
- package/build/assets/{dist-C3NfioQC.js → dist-xtCm0O6P.js} +1 -1
- package/build/assets/{dropdown-classes-BsVmxlNG.js → dropdown-classes-Vqz86I0R.js} +1 -1
- package/build/assets/{edit-automation-modal-DamwL0s0.js → edit-automation-modal-CNZgSSiH.js} +1 -1
- package/build/assets/{entry.client-Cn71WM8q.js → entry.client-BvKgdCQ9.js} +2 -2
- package/build/assets/{enum-filter-dropdown-5JeF2RLb.js → enum-filter-dropdown-DdFgk0EM.js} +1 -1
- package/build/assets/{environment-switch-overlay-Tf_BIfeR.js → environment-switch-overlay-CuBuZOaa.js} +1 -1
- package/build/assets/{extensions-hub-CUEmfvGy.js → extensions-hub-Dayqvv0n.js} +1 -1
- package/build/assets/{extensions-navigation-VQ-3umJ7.js → extensions-navigation-yFLAU06N.js} +1 -1
- package/build/assets/{file-BTY6Gyy9.js → file-DwHCkWZT.js} +1 -1
- package/build/assets/files-tab-CMredyYX.js +1 -0
- package/build/assets/{folder-D1T2W1cj.js → folder-2h1hR1Qb.js} +1 -1
- package/build/assets/git-control-bar-branch-button-D8blTNXh.js +27 -0
- package/build/assets/{globe-Bzj_0oXT.js → globe-qFjFNG6J.js} +1 -1
- package/build/assets/home-TrU0fLgG.js +1 -0
- package/build/assets/{i18n-DET2iOyh.js → i18n-zDndR1Ne.js} +1 -1
- package/build/assets/install-server-modal-D8Q0xZcN.js +1 -0
- package/build/assets/{launch-DGghLfGx.js → launch-I00QV8YT.js} +1 -1
- package/build/assets/{lesson-plan-duSsqWVs.js → lesson-plan-C18uB_56.js} +1 -1
- package/build/assets/{link-external-DGxVm4Ps.js → link-external-DtcdPFbw.js} +1 -1
- package/build/assets/llm-settings-C4R4HMUO.js +1 -0
- package/build/assets/llm-settings-Dq3w2cob.js +1 -0
- package/build/assets/{loading-spinner-5GT9q1xy.js → loading-spinner-DNwR4--Z.js} +1 -1
- package/build/assets/{manage-backends-modal-CRMwyU0t.js → manage-backends-modal-Ceo_SOcf.js} +1 -1
- package/build/assets/manifest-8c2efa8a.js +1 -0
- package/build/assets/{markdown-renderer-B3IAVfv4.js → markdown-renderer-D6B-u2nM.js} +1 -1
- package/build/assets/{mcp-CfDRAmPn.js → mcp-EvrLVTla.js} +1 -1
- package/build/assets/messages-Bz9TWjlh.js +36 -0
- package/build/assets/modal-backdrop-BDqI1zBV.js +1 -0
- package/build/assets/{modal-body-aoa2fx5W.js → modal-body-CCLCqX1J.js} +1 -1
- package/build/assets/{modal-classes-6YqcqA6y.js → modal-classes-DwTdT3IK.js} +1 -1
- package/build/assets/{modal-close-button-CtWOUMmw.js → modal-close-button-gQgKqUf-.js} +1 -1
- package/build/assets/{model-selector-DcztJSxT.js → model-selector-DoL0CL0_.js} +1 -1
- package/build/assets/{mutation-D0OogFCz.js → mutation-CaJwPR9O.js} +1 -1
- package/build/assets/{navigation-context-BdKYH32C.js → navigation-context-aNGUUtdq.js} +1 -1
- package/build/assets/{navigation-link-U4vY9i_C.js → navigation-link-CYkF2y3K.js} +1 -1
- package/build/assets/onboarding-DLr9jbKH.js +1 -0
- package/build/assets/{openhands-logo-CCo0wJZX.js → openhands-logo-CHmtDV-t.js} +1 -1
- package/build/assets/{organization-service.api-BeuMC9QL.js → organization-service.api-Dn74hBTH.js} +1 -1
- package/build/assets/path-utils-BjxzIGLp.js +1 -0
- package/build/assets/{plan-components-CRDMQzsS.js → plan-components--aLlpASH.js} +1 -1
- package/build/assets/{planner-tab-Dte6Vzza.js → planner-tab-B-5EeCEm.js} +1 -1
- package/build/assets/{providers-eUyo6pgr.js → providers-DknP6O2g.js} +1 -1
- package/build/assets/{proxy-BqDMnUY-.js → proxy-sRh0WKI7.js} +1 -1
- package/build/assets/{query-client-config-CRnGSujB.js → query-client-config-CWWGQWvw.js} +1 -1
- package/build/assets/{recommended-automations-launcher-D5ADbXao.js → recommended-automations-launcher-BIul0osB.js} +3 -3
- package/build/assets/root-BietmyRa.js +2 -0
- package/build/assets/{root-Z2VHU4R3.css → root-CN7qsvxg.css} +1 -1
- package/build/assets/root-layout-BgPi-t57.js +2 -0
- package/build/assets/{sdk-section-page-CRCRY3PG.js → sdk-section-page-VmtJWH3A.js} +1 -1
- package/build/assets/{sdk-settings-schema-CLmJ9sho.js → sdk-settings-schema-DFievvEK.js} +1 -1
- package/build/assets/{search-SuJctqNJ.js → search-BeVRXvX7.js} +1 -1
- package/build/assets/{secrets-service-B9AFn9OE.js → secrets-service-DVtlLWY8.js} +1 -1
- package/build/assets/{secrets-settings-0UrKMS60.js → secrets-settings-BLMvCkKm.js} +1 -1
- package/build/assets/{settings-6t6LGW04.js → settings-CXvJUx_j.js} +1 -1
- package/build/assets/{settings-dropdown-input-BtoovFre.js → settings-dropdown-input-DA_pzHWE.js} +1 -1
- package/build/assets/{settings-gear-Dd8K2_8B.js → settings-gear-aNebYlCy.js} +1 -1
- package/build/assets/{settings-index-CR6Ou73o.js → settings-index-CycvkOoq.js} +1 -1
- package/build/assets/{settings-input-CehsXnb3.js → settings-input-8y5p4kze.js} +1 -1
- package/build/assets/{settings-list-classes-E3v_f6QG.js → settings-list-classes-Qk7zl0Wu.js} +1 -1
- package/build/assets/settings-modal-nJYxCsyp.js +1 -0
- package/build/assets/{settings-section-header-context-DewwJ0-F.js → settings-section-header-context-B77tsYlx.js} +1 -1
- package/build/assets/{settings-service.api-DwtyDeGh.js → settings-service.api-DxIEtvx6.js} +1 -1
- package/build/assets/{settings-switch-BiBuS3xa.js → settings-switch-ba4DuiNO.js} +1 -1
- package/build/assets/{settings-utils-DY04tWG1.js → settings-utils-BxzHqLmZ.js} +1 -1
- package/build/assets/{shared-conversation-BzccsVej.js → shared-conversation-x41nZQi7.js} +1 -1
- package/build/assets/{sidebar-mobile-menu-toggle-DGlRg6jG.js → sidebar-mobile-menu-toggle-C0mmabKj.js} +1 -1
- package/build/assets/{sidebar-nav-link-dgVb8Fpy.js → sidebar-nav-link-BsYdDFfb.js} +1 -1
- package/build/assets/{skill-card-pill-row-BW9qvhoK.js → skill-card-pill-row-BhUlGcYB.js} +1 -1
- package/build/assets/{skills-0GRKX5Xj.js → skills-TYjOUQ2d.js} +1 -1
- package/build/assets/{skills-plugins-DctDrZ8Y.js → skills-plugins-D0pdqgKa.js} +1 -1
- package/build/assets/{skills-settings-rvxImDj_.js → skills-settings-VqKTkmVl.js} +2 -2
- package/build/assets/{styled-tooltip-hdfMXPQC.js → styled-tooltip-TCp7svY3.js} +1 -1
- package/build/assets/{switch-skeleton-DSKqSx2A.js → switch-skeleton-cKrdaYGj.js} +1 -1
- package/build/assets/{task-list-tab-DT6_zfUs.js → task-list-tab-BiizRsY3.js} +1 -1
- package/build/assets/telemetry-3piyXm5H.js +2 -0
- package/build/assets/{terminal-CPYWdo4j.js → terminal-BSYITdM0.js} +1 -1
- package/build/assets/{terminal-KldRPIRT.js → terminal-CpgZx6go.js} +1 -1
- package/build/assets/{toggle-switch-T2v6sJ6l.js → toggle-switch-CUgOZqZu.js} +1 -1
- package/build/assets/{typography-BDgnT7Yp.js → typography-Bvw0IxaN.js} +1 -1
- package/build/assets/{u-check-circle-half-steSK_JB.js → u-check-circle-half-DjpjzWu3.js} +1 -1
- package/build/assets/{u-check-circle-DOauqQKb.js → u-check-circle-u9QiS4Fr.js} +1 -1
- package/build/assets/{u-circuit-x3ExjBbU.js → u-circuit-DlBlOwx9.js} +1 -1
- package/build/assets/{u-edit-BbrptMCa.js → u-edit-BIYzjs3v.js} +1 -1
- package/build/assets/{use-active-conversation-sPgfSkql.js → use-active-conversation-q1wT8LI5.js} +1 -1
- package/build/assets/{use-agent-settings-schema-B66kGIi_.js → use-agent-settings-schema-Yxf7KGyG.js} +1 -1
- package/build/assets/{use-agent-state-Dp3pD1h3.js → use-agent-state-CCHlVqvY.js} +1 -1
- package/build/assets/{use-cloud-current-user-id-ClKFPjFz.js → use-cloud-current-user-id-BAKf91Zx.js} +1 -1
- package/build/assets/{use-config-C9pvb0Sm.js → use-config-DwfigQ_Y.js} +1 -1
- package/build/assets/use-create-conversation-BEzddjXn.js +1 -0
- package/build/assets/{use-get-secrets-oyC7PFRz.js → use-get-secrets-BlO1BfUo.js} +1 -1
- package/build/assets/{use-handle-plan-click-DP6Rs-YP.js → use-handle-plan-click-Bfl0zIBr.js} +1 -1
- package/build/assets/use-is-authed-hHndEep7.js +1 -0
- package/build/assets/{use-launch-skill-in-chat-sQNEOLGD.js → use-launch-skill-in-chat-3ydwpi_M.js} +1 -1
- package/build/assets/use-llm-profiles-E-jjZMZw.js +1 -0
- package/build/assets/use-runtime-is-ready-DBWzvAmc.js +1 -0
- package/build/assets/use-save-settings-rE9aA29R.js +1 -0
- package/build/assets/{use-settings-DeO7nvpM.js → use-settings-BPTbE7lg.js} +1 -1
- package/build/assets/{use-settings-nav-items-BGMFn25b.js → use-settings-nav-items-C7MOWj09.js} +1 -1
- package/build/assets/{use-skills-DWIK3l3a.js → use-skills-QhoaIYGF.js} +1 -1
- package/build/assets/{use-task-list-CsT10CBb.js → use-task-list-YMkSzdDv.js} +1 -1
- package/build/assets/use-tracking-DQYdZpxi.js +1 -0
- package/build/assets/{use-unified-vscode-url-DXPtB317.js → use-unified-vscode-url-DFtNIC1Q.js} +1 -1
- package/build/assets/{use-user-conversation-DJen4YIP.js → use-user-conversation-BRAseenw.js} +1 -1
- package/build/assets/{useMutation-GSSKKebK.js → useMutation-DDo48A8t.js} +1 -1
- package/build/assets/{useTranslation-B6voJV4y.js → useTranslation-CEcjrme-.js} +1 -1
- package/build/assets/{utils-DCVfKFRt.js → utils-CdgBzLA7.js} +1 -1
- package/build/assets/{vendor~browser-BrOJLj3y.js → vendor~browser-DWk6fNtJ.js} +1 -1
- package/build/assets/{vendor~browser-tab-BxhTtM9_.js → vendor~browser-tab-NZdVoI2Z.js} +1 -1
- package/build/assets/{vendor~conversation-panel~conversation-C9o-K1hW.js → vendor~conversation-panel~conversation-gp03cWZW.js} +1 -1
- package/build/assets/{vendor~conversation-panel~conversation~index-RXYdJYxU.js → vendor~conversation-panel~conversation~index-BZ5C6Xpz.js} +1 -1
- package/build/assets/{vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~jfc6hidu-DJS-rJdI.js → vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~oli4dvxu-BodGsxSf.js} +1 -1
- package/build/assets/{vendor~files-tab-BtkpAiMX.js → vendor~files-tab-Buz36Y-q.js} +1 -1
- package/build/assets/{vendor~home~conversation-panel~conversation-PK1-gtXU.js → vendor~home~conversation-panel~conversation-DG0H5SkJ.js} +2 -2
- package/build/assets/{vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-6ByzelMS.js → vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-1pTajrpX.js} +1 -1
- package/build/assets/{vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-BED5W_c4.js → vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-9Il_wz8U.js} +1 -1
- package/build/assets/{vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-CCbqAFiI.js → vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-B7I1ZxCx.js} +1 -1
- package/build/assets/{vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-E4d6IEfI.js → vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-Ceeqkj0k.js} +1 -1
- package/build/assets/{vendor~launch-BXgl67Re.js → vendor~launch-DXL78kBf.js} +1 -1
- package/build/assets/{vendor~root-layout~conversation-panel~conversation~shared-conversation-DW31UyBp.js → vendor~root-layout~conversation-panel~conversation~shared-conversation-CfAc3nMS.js} +1 -1
- package/build/assets/vendor~root-layout~home~conversation-panel~conversation-DkwcKRtv.js +1 -0
- package/build/assets/{vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~iguv7bgw-tTR8C6m0.js → vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~iguv7bgw-BC9XTECT.js} +1 -1
- package/build/assets/{vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~iguv7bgw-6Rm8U_Sr.js → vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~iguv7bgw-DSqEbr0N.js} +1 -1
- package/build/assets/{vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~k776hupu-BJbu9kpL.js → vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~k776hupu-D0XUSHNN.js} +2 -2
- package/build/assets/{vendor~root-layout~home~conversation-panel~conversation~shared-conversation~alert-banner~pl~rqjteh0a-d2oallMa.js → vendor~root-layout~home~conversation-panel~conversation~shared-conversation~alert-banner~pl~rqjteh0a-CcFtthyg.js} +1 -1
- package/build/assets/vendor~root-layout~home~mcp~automations-list-BnIlGhjl.js +1 -0
- package/build/assets/{vendor~home~mcp~automations-list-BgV86Sti.js → vendor~root-layout~home~mcp~automations-list-cNHi83v_.js} +1 -1
- package/build/assets/{vendor~home~mcp~llm-settings~agent-settings~condenser-settings~verification-settings~app-se~ocm3mykx-CjJdFLoM.js → vendor~root-layout~home~mcp~llm-settings~agent-settings~condenser-settings~verification-set~o7tv66sg-BGWUbqUq.js} +1 -1
- package/build/assets/{vendor~home~mcp~llm-settings~agent-settings~condenser-settings~verification-settings~app-se~ocm3mykx-m8dOii0J.js → vendor~root-layout~home~mcp~llm-settings~agent-settings~condenser-settings~verification-set~o7tv66sg-BuCSnjsW.js} +2 -2
- package/build/assets/{vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~f2l2lr17-DYXOLEck.js → vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~jaomi49z-Cw89stA6.js} +1 -1
- package/build/assets/{verification-settings-C_zHuDx9.js → verification-settings-CIqtxWat.js} +1 -1
- package/build/assets/{vscode-tab-DH9x7xXS.js → vscode-tab-DEt72yJX.js} +1 -1
- package/build/assets/{waiting-for-runtime-message-CdK3btDZ.js → waiting-for-runtime-message-DSjJfeoj.js} +1 -1
- package/build/assets/{x-mark-BrkSPIiT.js → x-mark-DsJ9tDD0.js} +1 -1
- package/build/index.html +4 -4
- package/build/locales/ar/openhands.json +4 -2
- package/build/locales/ca/openhands.json +4 -2
- package/build/locales/de/openhands.json +4 -2
- package/build/locales/en/openhands.json +4 -2
- package/build/locales/es/openhands.json +4 -2
- package/build/locales/fr/openhands.json +4 -2
- package/build/locales/it/openhands.json +4 -2
- package/build/locales/ja/openhands.json +4 -2
- package/build/locales/ko-KR/openhands.json +4 -2
- package/build/locales/no/openhands.json +4 -2
- package/build/locales/pt/openhands.json +4 -2
- package/build/locales/tr/openhands.json +4 -2
- package/build/locales/uk/openhands.json +4 -2
- package/build/locales/zh-CN/openhands.json +4 -2
- package/build/locales/zh-TW/openhands.json +4 -2
- package/config/defaults.json +1 -1
- package/dist/api/agent-server-home.cjs +2 -0
- package/dist/api/agent-server-home.cjs.map +1 -0
- package/dist/api/agent-server-home.d.ts +34 -0
- package/dist/api/agent-server-home.js +33 -0
- package/dist/api/agent-server-home.js.map +1 -0
- package/dist/api/conversation-file-upload.api.cjs +1 -1
- package/dist/api/conversation-file-upload.api.cjs.map +1 -1
- package/dist/api/conversation-file-upload.api.js +4 -1
- package/dist/api/conversation-file-upload.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 +101 -100
- package/dist/api/conversation-service/agent-server-conversation-service.api.js.map +1 -1
- package/dist/api/option-service/option-service.api.cjs.map +1 -1
- package/dist/api/option-service/option-service.api.js.map +1 -1
- package/dist/api/workspace-upload-path.cjs +1 -1
- package/dist/api/workspace-upload-path.cjs.map +1 -1
- package/dist/api/workspace-upload-path.d.ts +44 -2
- package/dist/api/workspace-upload-path.js +16 -14
- package/dist/api/workspace-upload-path.js.map +1 -1
- package/dist/components/features/automations/recommended-automations-launcher.d.ts +3 -1
- package/dist/components/features/automations/recommended-automations-section.d.ts +3 -1
- 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 +7 -1
- package/dist/components/features/backends/backend-form-modal.js +94 -91
- package/dist/components/features/backends/backend-form-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 +66 -66
- 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/switch-profile-button.cjs +1 -1
- package/dist/components/features/chat/switch-profile-button.js +3 -3
- package/dist/components/features/conversation-panel/conversation-card/conversation-card.cjs +1 -1
- package/dist/components/features/conversation-panel/conversation-card/conversation-card.cjs.map +1 -1
- package/dist/components/features/conversation-panel/conversation-card/conversation-card.js +5 -5
- package/dist/components/features/conversation-panel/conversation-card/conversation-card.js.map +1 -1
- package/dist/components/features/onboarding/index.d.ts +1 -0
- package/dist/components/features/onboarding/onboarding-host.d.ts +3 -1
- package/dist/components/features/onboarding/onboarding-modal.d.ts +7 -3
- package/dist/components/features/onboarding/onboarding-preview.d.ts +4 -0
- package/dist/components/features/onboarding/steps/say-hello-step.d.ts +3 -1
- 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/sdk-settings/sdk-section-page.cjs +1 -1
- package/dist/components/features/settings/sdk-settings/sdk-section-page.cjs.map +1 -1
- package/dist/components/features/settings/sdk-settings/sdk-section-page.d.ts +3 -1
- package/dist/components/features/settings/sdk-settings/sdk-section-page.js +56 -56
- package/dist/components/features/settings/sdk-settings/sdk-section-page.js.map +1 -1
- package/dist/components/features/skills/extensions-navigation.cjs +1 -1
- package/dist/components/features/skills/extensions-navigation.js +7 -7
- package/dist/components/shared/modals/modal-backdrop.cjs +1 -1
- package/dist/components/shared/modals/modal-backdrop.cjs.map +1 -1
- package/dist/components/shared/modals/modal-backdrop.d.ts +3 -1
- package/dist/components/shared/modals/modal-backdrop.js +3 -3
- package/dist/components/shared/modals/modal-backdrop.js.map +1 -1
- package/dist/components/shared/modals/settings/settings-form.cjs +1 -1
- package/dist/components/shared/modals/settings/settings-form.cjs.map +1 -1
- package/dist/components/shared/modals/settings/settings-form.js +7 -7
- package/dist/components/shared/modals/settings/settings-form.js.map +1 -1
- package/dist/hooks/chat/use-model-interceptor.cjs +1 -1
- package/dist/hooks/chat/use-model-interceptor.js +4 -4
- package/dist/hooks/mutation/use-save-settings.cjs +1 -1
- package/dist/hooks/mutation/use-save-settings.cjs.map +1 -1
- package/dist/hooks/mutation/use-save-settings.js +13 -14
- package/dist/hooks/mutation/use-save-settings.js.map +1 -1
- package/dist/hooks/query/use-llm-profiles.cjs +1 -1
- package/dist/hooks/query/use-llm-profiles.js +5 -5
- package/dist/hooks/use-download-conversation.cjs +1 -1
- package/dist/hooks/use-download-conversation.cjs.map +1 -1
- package/dist/hooks/use-download-conversation.js +4 -4
- package/dist/hooks/use-download-conversation.js.map +1 -1
- package/dist/hooks/use-tracking.cjs +1 -1
- package/dist/hooks/use-tracking.cjs.map +1 -1
- package/dist/hooks/use-tracking.d.ts +31 -0
- package/dist/hooks/use-tracking.js +51 -14
- 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 +2 -0
- package/dist/i18n/declaration.js +1 -1
- package/dist/i18n/declaration.js.map +1 -1
- package/dist/i18n/translation.cjs +1 -1
- package/dist/i18n/translation.cjs.map +1 -1
- package/dist/i18n/translation.js +64 -30
- package/dist/i18n/translation.js.map +1 -1
- package/dist/locales/ar/openhands.json +4 -2
- package/dist/locales/ca/openhands.json +4 -2
- package/dist/locales/de/openhands.json +4 -2
- package/dist/locales/en/openhands.json +4 -2
- package/dist/locales/es/openhands.json +4 -2
- package/dist/locales/fr/openhands.json +4 -2
- package/dist/locales/it/openhands.json +4 -2
- package/dist/locales/ja/openhands.json +4 -2
- package/dist/locales/ko-KR/openhands.json +4 -2
- package/dist/locales/no/openhands.json +4 -2
- package/dist/locales/pt/openhands.json +4 -2
- package/dist/locales/tr/openhands.json +4 -2
- package/dist/locales/uk/openhands.json +4 -2
- package/dist/locales/zh-CN/openhands.json +4 -2
- package/dist/locales/zh-TW/openhands.json +4 -2
- package/dist/package.cjs +1 -1
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/dist/routes/llm-settings.cjs +1 -1
- package/dist/routes/llm-settings.cjs.map +1 -1
- package/dist/routes/llm-settings.d.ts +3 -1
- package/dist/routes/llm-settings.js +17 -16
- package/dist/routes/llm-settings.js.map +1 -1
- package/package.json +1 -1
- package/scripts/dev-static.mjs +0 -2
- package/scripts/dev-with-automation.mjs +0 -2
- package/scripts/static-server.mjs +13 -3
- package/build/assets/add-backend-modal-mXKmfMI2.js +0 -1
- package/build/assets/agent-server-conversation-service.api-B9TUYJon.js +0 -5
- package/build/assets/agent-settings-g3F623RJ.js +0 -2
- package/build/assets/analytics-consent-form-modal-BQCNeNVt.js +0 -1
- package/build/assets/automation-detail-BDHLHSJd.js +0 -1
- package/build/assets/automations-list-CiNtQhq_.js +0 -1
- package/build/assets/browser-CGM-k-sH.js +0 -5
- package/build/assets/conversation-BKhikfYl.js +0 -1
- package/build/assets/conversation-DTn8jN8L.js +0 -19
- package/build/assets/conversation-panel-DfHR42mG.js +0 -1
- package/build/assets/conversation-service.api-B6CkzaKD.js +0 -1
- package/build/assets/conversation-websocket-context-DShEuLjh.js +0 -3
- package/build/assets/dist-DNeWJ2bh.js +0 -1
- package/build/assets/ellipsis-button-Vh5MvRZa.js +0 -1
- package/build/assets/files-tab-C47fQEeL.js +0 -1
- package/build/assets/git-branch-DQS2nMK4.js +0 -1
- package/build/assets/git-control-bar-branch-button-BT0aWH-o.js +0 -27
- package/build/assets/git-provider-icon-Pi-Cxpgv.js +0 -1
- package/build/assets/home-C3k6sFvB.js +0 -1
- package/build/assets/install-server-modal-6fuq-TU6.js +0 -1
- package/build/assets/llm-settings-BKraGtOu.js +0 -1
- package/build/assets/llm-settings-DRQTgOF1.js +0 -1
- package/build/assets/manage-workspaces-modal-BYmGD1W7.js +0 -1
- package/build/assets/manifest-99b06a11.js +0 -1
- package/build/assets/messages-Ba1vaw6t.js +0 -36
- package/build/assets/modal-backdrop-RfNCrSpK.js +0 -1
- package/build/assets/path-utils-z12iCrQO.js +0 -1
- package/build/assets/root-BmhaEJJ8.js +0 -2
- package/build/assets/root-layout-CNggm0d8.js +0 -2
- package/build/assets/settings-modal-T_Yk1Zfo.js +0 -1
- package/build/assets/use-create-conversation-B-lwTnfE.js +0 -1
- package/build/assets/use-is-authed-dw2026rR.js +0 -1
- package/build/assets/use-is-creating-conversation-DX2qSlfL.js +0 -1
- package/build/assets/use-llm-profiles-Bh5JqZUZ.js +0 -1
- package/build/assets/use-runtime-is-ready-BakOUVU-.js +0 -1
- package/build/assets/use-save-settings-uXXkqvD7.js +0 -1
- package/build/assets/vendor~home~mcp~automations-list-CZSK-lT2.js +0 -1
- package/build/assets/vendor~root-layout~home~conversation-panel~conversation-B5WNMnt4.js +0 -1
- /package/build/assets/{automation-XDPAjiZi.js → automation-DJ_3GeXD.js} +0 -0
- /package/build/assets/{browser-store-DAsixKdU.js → browser-store-JRrcGdlk.js} +0 -0
- /package/build/assets/{check-CYxAHs85.js → check-CZhEL6rP.js} +0 -0
- /package/build/assets/{chevron-down-Bnmd5iG-.js → chevron-down-KhWYEjeW.js} +0 -0
- /package/build/assets/{color-themes-B9pm9c-R.js → color-themes-0biOprdo.js} +0 -0
- /package/build/assets/{command-store-CE1weJy8.js → command-store-UzKGSUC2.js} +0 -0
- /package/build/assets/{files-tab-store-m0ARqX_E.js → files-tab-store-DLU28g8C.js} +0 -0
- /package/build/assets/{iconBase-DE30Zj_-.js → iconBase-BVhFI-0E.js} +0 -0
- /package/build/assets/{map-provider-BJ_8KZKU.js → map-provider-C3Z5Dx2J.js} +0 -0
- /package/build/assets/{sdk-settings-field-metadata-DQiaIBie.js → sdk-settings-field-metadata-C6KMD-jZ.js} +0 -0
- /package/build/assets/{settings-like-page-layout-classes-D7YjdTd0.js → settings-like-page-layout-classes-DNg2vKSM.js} +0 -0
- /package/build/assets/{use-breakpoint-DF_RiQ6s.js → use-breakpoint-DpxHDmuH.js} +0 -0
- /package/build/assets/{use-event-store-BomO7ywK.js → use-event-store-Cxqc45Sw.js} +0 -0
- /package/build/assets/{vendor~browser-DisFGEp9.js → vendor~browser-BDNLFng6.js} +0 -0
- /package/build/assets/{vendor~conversation-panel~conversation~alert-banner-w-I2sY6c.js → vendor~conversation-panel~conversation~alert-banner-D_hRW_zc.js} +0 -0
- /package/build/assets/{vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~g56ukk6u-DsSvIDZQ.js → vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~h07fzaqi-D15MEcqi.js} +0 -0
- /package/build/assets/{vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~hkqzh1hb-BZ0HXuHD.js → vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~j8sdb9mk-OFpe9fX_.js} +0 -0
- /package/build/assets/{vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~zm51vy4j-BClAMeFe.js → vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~lpdshwee-BPuuVEqr.js} +0 -0
- /package/build/assets/{vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-CG96FCly.js → vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-CXivI4Ym.js} +0 -0
- /package/build/assets/{vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-CyZ-3lDQ.js → vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-Dr3Ow7Ms.js} +0 -0
- /package/build/assets/{vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~i4kjfqhl-CbAhtEMv.js → vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~i4kjfqhl-B1TKKuuH.js} +0 -0
- /package/build/assets/{vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~ninslayh-CLlsvdNP.js → vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~e9ykmtgh-Fa-nXZ4M.js} +0 -0
- /package/build/assets/{vendor~terminal-DZaJIY8A.js → vendor~terminal-0ObOedYm.js} +0 -0
- /package/build/assets/{vscode-url-helper-Cwy1A62q.js → vscode-url-helper-BMq8JBhB.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-server-conversation-service.api.js","names":[],"sources":["../../../src/api/conversation-service/agent-server-conversation-service.api.ts"],"sourcesContent":["import {\n ConversationSortOrder,\n type LLMConfig,\n} from \"@openhands/typescript-client\";\nimport {\n ConversationClient,\n FileClient,\n ProfilesClient,\n VSCodeClient,\n} from \"@openhands/typescript-client/clients\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { Provider } from \"#/types/settings\";\nimport type { ConversationRuntimeContext } from \"#/api/conversation-file-upload.api\";\nimport { buildHttpBaseUrl } from \"#/utils/websocket-url\";\nimport {\n buildConversationWorkingDir,\n getAgentServerWorkingDir,\n} from \"../agent-server-config\";\nimport {\n getActiveBackend,\n getEffectiveLocalBackend,\n} from \"../backend-registry/active-store\";\nimport { callCloudProxy } from \"../cloud/proxy\";\nimport {\n batchGetCloudConversations,\n createCloudAppConversation,\n deleteCloudConversation,\n downloadCloudConversation,\n getCloudAppConversationStartTask,\n readCloudConversationFile,\n searchCloudConversations,\n updateCloudConversationPublicFlag,\n} from \"../cloud/conversation-service.api\";\nimport {\n DirectConversationInfo,\n buildStartConversationRequestWithEncryptedSettings,\n emptyHooksResponse,\n getDefaultConversationTitle,\n toAppConversation,\n toConversationPage,\n} from \"../agent-server-adapter\";\nimport { GetVSCodeUrlResponse } from \"../open-hands.types\";\nimport {\n getAgentServerClientOptions,\n NoBackendAvailableError,\n} from \"../agent-server-client-options\";\nimport SettingsService from \"../settings-service/settings-service.api\";\nimport {\n ConversationMetadata,\n getStoredConversationMetadata,\n removeStoredConversationMetadata,\n setStoredConversationMetadata,\n} from \"../conversation-metadata-store\";\nimport type {\n GetHooksResponse,\n PluginSpec,\n AppConversation,\n AppConversationPage,\n AppConversationStartRequest,\n AppConversationStartTask,\n MetricsSnapshot,\n RuntimeConversationInfo,\n SendMessageRequest,\n SendMessageResponse,\n} from \"./agent-server-conversation-service.types\";\n\nconst DEFAULT_CONVERSATION_TIMESTAMP = \"1970-01-01T00:00:00.000Z\";\nconst INVALID_CONVERSATION_RESPONSE_MESSAGE =\n \"Unable to load conversations because the selected agent server returned \" +\n \"data this UI does not understand. Check the backend URL/session key and \" +\n \"update the agent server if needed.\";\nfunction invalidConversationResponse(): Error {\n return new Error(INVALID_CONVERSATION_RESPONSE_MESSAGE);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction numberOrNull(value: unknown): number | null {\n return typeof value === \"number\" ? value : null;\n}\n\nfunction numberOrZero(value: unknown): number {\n return typeof value === \"number\" ? value : 0;\n}\n\nfunction stringOrNull(value: unknown): string | null {\n return typeof value === \"string\" ? value : null;\n}\n\nfunction readTimestamp(\n item: Record<string, unknown>,\n snakeKey: \"created_at\" | \"updated_at\",\n camelKey: \"createdAt\" | \"updatedAt\",\n): string {\n const value = item[snakeKey] ?? item[camelKey];\n return typeof value === \"string\" && value.trim()\n ? value\n : DEFAULT_CONVERSATION_TIMESTAMP;\n}\n\nfunction normalizeTokenUsage(\n value: unknown,\n): NonNullable<MetricsSnapshot[\"accumulated_token_usage\"]> | null {\n if (!isRecord(value)) return null;\n\n return {\n prompt_tokens: numberOrZero(value.prompt_tokens),\n completion_tokens: numberOrZero(value.completion_tokens),\n cache_read_tokens: numberOrZero(value.cache_read_tokens),\n cache_write_tokens: numberOrZero(value.cache_write_tokens),\n context_window: numberOrZero(value.context_window),\n per_turn_token: numberOrZero(value.per_turn_token),\n };\n}\n\nfunction normalizeMetrics(value: unknown): MetricsSnapshot | null {\n if (!isRecord(value)) return null;\n\n return {\n accumulated_cost: numberOrNull(value.accumulated_cost),\n max_budget_per_task: numberOrNull(value.max_budget_per_task),\n accumulated_token_usage: normalizeTokenUsage(value.accumulated_token_usage),\n };\n}\n\nfunction normalizeAgent(value: unknown): DirectConversationInfo[\"agent\"] {\n if (!isRecord(value)) return null;\n const llm = isRecord(value.llm)\n ? { model: stringOrNull(value.llm.model) }\n : null;\n // ``kind`` is the SDK's pydantic discriminator (``\"Agent\"`` vs ``\"ACPAgent\"``);\n // ``toAppConversation`` reads it to derive ``agent_kind``. ``acp_model`` is\n // the Canvas-configured model on the ACPAgent — preserved so the conversation\n // adapter and the conversation chip can fall back to it when the SDK runtime\n // model fields aren't populated. Preserving these here makes the wire path\n // agree with the unit-test path that builds ``DirectConversationInfo``\n // directly (e.g. ``__tests__/api/agent-server-adapter.test.ts``).\n return {\n kind: stringOrNull(value.kind),\n acp_model: stringOrNull(value.acp_model),\n llm,\n };\n}\n\nfunction normalizeWorkspace(\n value: unknown,\n): DirectConversationInfo[\"workspace\"] {\n if (!isRecord(value)) return null;\n return { working_dir: stringOrNull(value.working_dir) };\n}\n\n/**\n * Accept the agent-server's ``tags: Record[str, str]`` payload defensively:\n * the wire shape is guaranteed by the server-side validator (keys\n * ``^[a-z0-9]+$``, string values), but a non-conforming response (older\n * server, raw API write, future schema drift) must never crash the parser\n * — Canvas only consumes ``acpserver`` and falls back to a generic chip\n * for anything it doesn't recognize. Drop entries whose value isn't a\n * plain string; return ``null`` when the wire field is absent or not an\n * object so consumers can use ``info.tags?.[KEY] ?? null`` uniformly.\n */\nfunction normalizeTags(value: unknown): Record<string, string> | null {\n if (!isRecord(value)) return null;\n const tags: Record<string, string> = {};\n for (const [key, entry] of Object.entries(value)) {\n if (typeof entry === \"string\") {\n tags[key] = entry;\n }\n }\n return tags;\n}\n\nfunction normalizeAbsolutePath(path: string): string | null {\n if (!path.startsWith(\"/\")) return null;\n\n const segments: string[] = [];\n for (const segment of path.split(\"/\")) {\n if (segment && segment !== \".\") {\n if (segment === \"..\") {\n if (!segments.length) return null;\n segments.pop();\n } else {\n segments.push(segment);\n }\n }\n }\n\n return `/${segments.join(\"/\")}`;\n}\n\nfunction requirePathInsideDirectory(path: string, directory: string): string {\n const normalizedPath = normalizeAbsolutePath(path);\n const normalizedDirectory = normalizeAbsolutePath(directory);\n\n if (\n !normalizedPath ||\n !normalizedDirectory ||\n (normalizedPath !== normalizedDirectory &&\n !normalizedPath.startsWith(`${normalizedDirectory}/`))\n ) {\n throw new Error(\"Conversation file path must stay inside the workspace\");\n }\n\n return normalizedPath;\n}\n\nfunction requireDirectConversationInfo(item: unknown): DirectConversationInfo {\n if (!isRecord(item) || typeof item.id !== \"string\" || !item.id.trim()) {\n throw invalidConversationResponse();\n }\n\n return {\n id: item.id.trim(),\n title: stringOrNull(item.title),\n created_at: readTimestamp(item, \"created_at\", \"createdAt\"),\n updated_at: readTimestamp(item, \"updated_at\", \"updatedAt\"),\n execution_status: stringOrNull(item.execution_status),\n sandbox_status: stringOrNull(item.sandbox_status),\n metrics: normalizeMetrics(item.metrics),\n agent: normalizeAgent(item.agent),\n workspace: normalizeWorkspace(item.workspace),\n tags: normalizeTags(item.tags),\n // SDK-runtime ACP model fields (populated when the agent-server supports\n // ``ConversationInfo.current_model_*``). Consumed by the conversation\n // adapter to drive the per-card chip's model text. Older agent-servers\n // omit these — adapter handles ``undefined`` / ``null`` gracefully.\n current_model_id: stringOrNull(item.current_model_id),\n current_model_name: stringOrNull(item.current_model_name),\n };\n}\n\nfunction requireDirectConversationItems(\n items: unknown,\n): DirectConversationInfo[] {\n if (!Array.isArray(items)) {\n throw invalidConversationResponse();\n }\n return items.map(requireDirectConversationInfo);\n}\n\nfunction requireConversationSearchPage(page: unknown): {\n items: DirectConversationInfo[];\n next_page_id: string | null;\n} {\n if (Array.isArray(page)) {\n return {\n items: requireDirectConversationItems(page),\n next_page_id: null,\n };\n }\n\n if (!isRecord(page)) {\n throw invalidConversationResponse();\n }\n\n return {\n items: requireDirectConversationItems(page.items),\n next_page_id:\n typeof page.next_page_id === \"string\" ? page.next_page_id : null,\n };\n}\n\nconst RUNTIME_STATUSES = new Set<string>([\n \"idle\",\n \"running\",\n \"paused\",\n \"waiting_for_confirmation\",\n \"finished\",\n \"error\",\n \"stuck\",\n]);\n\nfunction toRuntimeStatus(\n status: DirectConversationInfo[\"execution_status\"],\n): RuntimeConversationInfo[\"status\"] {\n const nextStatus = status ?? \"idle\";\n return (\n RUNTIME_STATUSES.has(nextStatus) ? nextStatus : \"idle\"\n ) as RuntimeConversationInfo[\"status\"];\n}\n\nfunction requireAppConversation(\n conversation: AppConversation | null | undefined,\n conversationId: string,\n): AppConversation {\n if (!conversation) {\n throw new Error(`Conversation ${conversationId} was not found`);\n }\n return conversation;\n}\n\nclass AgentServerConversationService {\n static async sendMessage(\n conversationId: string,\n message: SendMessageRequest,\n runtime?: ConversationRuntimeContext | null,\n ): Promise<SendMessageResponse> {\n const active = getActiveBackend().backend;\n let conversationUrl = runtime?.conversationUrl ?? null;\n let sessionApiKey = runtime?.sessionApiKey ?? null;\n\n if (active.kind === \"cloud\") {\n if (!conversationUrl || !sessionApiKey) {\n const [conversation] = await batchGetCloudConversations([\n conversationId,\n ]);\n conversationUrl = conversation?.conversation_url?.trim() ?? null;\n sessionApiKey = conversation?.session_api_key?.trim() ?? null;\n }\n\n if (!conversationUrl || !sessionApiKey) {\n throw new Error(\n \"Conversation sandbox is still starting. Wait for it to finish, then try again.\",\n );\n }\n\n await callCloudProxy({\n backend: active,\n method: \"POST\",\n hostOverride: buildHttpBaseUrl(conversationUrl),\n path: `/api/conversations/${conversationId}/events`,\n body: { ...message, run: true },\n authMode: \"session-api-key\",\n sessionApiKey,\n });\n\n return message;\n }\n\n await new ConversationClient(\n getAgentServerClientOptions({ conversationUrl, sessionApiKey }),\n ).sendEvent(conversationId, message, {\n run: true,\n });\n\n return message;\n }\n\n static async createConversation(\n initialUserMsg?: string,\n conversationInstructions?: string,\n plugins?: PluginSpec[],\n metadata?: ConversationMetadata | null,\n workingDirOverride?: string,\n parentConversationId?: string,\n agentType?: \"default\" | \"plan\",\n sandboxId?: string,\n ): Promise<AppConversationStartTask> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n // Cloud path mirrors OpenHands' frontend: build a flat\n // AppConversationStartRequest, POST /api/v1/app-conversations\n // (returns a WORKING task), and let the conversation route's\n // useTaskPolling drive it to READY. NO encrypted-settings\n // round-trip — the cloud backend holds secrets server-side.\n const request: AppConversationStartRequest = {\n initial_message: initialUserMsg\n ? {\n role: \"user\",\n content: [{ type: \"text\", text: initialUserMsg }],\n }\n : null,\n title: conversationInstructions ?? null,\n selected_repository: metadata?.selected_repository ?? null,\n selected_branch: metadata?.selected_branch ?? null,\n git_provider: metadata?.git_provider ?? null,\n plugins: plugins ?? null,\n parent_conversation_id: parentConversationId ?? null,\n agent_type: agentType,\n sandbox_id: sandboxId ?? null,\n };\n return createCloudAppConversation(request);\n }\n\n const settings = await SettingsService.getSettings();\n const conversationId = uuidv4();\n const workingDir =\n workingDirOverride ?? buildConversationWorkingDir(conversationId);\n\n // Use encrypted settings to avoid exposing secrets in the browser\n const payload = await buildStartConversationRequestWithEncryptedSettings({\n settings,\n query: initialUserMsg,\n conversationInstructions,\n plugins,\n conversationId,\n workingDir,\n });\n\n const data = await new ConversationClient(\n getAgentServerClientOptions(),\n ).createConversation<DirectConversationInfo>(payload);\n const localBackend = getEffectiveLocalBackend();\n if (!localBackend) throw new NoBackendAvailableError();\n\n if (metadata?.selected_repository || workingDirOverride) {\n // The agent-server runtime has no concept of selected repo/branch/\n // workspace, so persist the home-page selection client-side.\n // `toAppConversation` reads the repo/branch fields back to hydrate\n // the chat-page badges; `useHasAttachedSource` reads\n // `selected_workspace` to default the Files tab to Diff mode when\n // the user explicitly attached a local workspace.\n setStoredConversationMetadata(data.id, {\n selected_repository: metadata?.selected_repository ?? null,\n selected_branch: metadata?.selected_branch ?? null,\n git_provider: metadata?.git_provider ?? null,\n selected_workspace: workingDirOverride ?? null,\n });\n }\n\n return {\n id: data.id,\n created_by_user_id: null,\n status: \"READY\",\n detail: null,\n app_conversation_id: data.id,\n agent_server_url: localBackend.host,\n request: {\n initial_message: payload.initial_message as\n | AppConversationStartRequest[\"initial_message\"]\n | undefined,\n plugins: plugins ?? null,\n },\n created_at: data.created_at,\n updated_at: data.updated_at,\n };\n }\n\n static async getStartTask(\n taskId: string,\n ): Promise<AppConversationStartTask | null> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return getCloudAppConversationStartTask(taskId);\n }\n // Local agent-server creates conversations synchronously — every\n // local \"task\" is already READY when createConversation returns, so\n // there's nothing to poll for.\n return null;\n }\n\n static async getVSCodeUrl(\n conversationId: string,\n conversationUrl: string | null | undefined,\n sessionApiKey?: string | null,\n ): Promise<GetVSCodeUrlResponse> {\n // Local-only path. Cloud conversations read the VSCode URL straight\n // from the cloud-computed `sandbox.exposed_urls` (see\n // `useUnifiedVSCodeUrl` + `useCloudSandbox`); the runtime's own\n // `/api/vscode/url` only knows its internal `localhost:8001`, which\n // the user's browser can't reach.\n const workspaceDir =\n await this.resolveConversationWorkingDir(conversationId);\n // Local mode: the typescript-client targets the local agent-server\n // directly via the conversationUrl override.\n const vscodeUrl = await new VSCodeClient(\n getAgentServerClientOptions({\n conversationUrl,\n sessionApiKey,\n }),\n ).getUrl({\n baseUrl:\n typeof window !== \"undefined\" ? window.location.origin : undefined,\n workspaceDir,\n });\n\n return { vscode_url: vscodeUrl };\n }\n\n static async resolveConversationWorkingDir(\n conversationId: string,\n ): Promise<string> {\n const [conversation] = await this.batchGetAppConversations([\n conversationId,\n ]);\n return conversation?.workspace?.working_dir ?? getAgentServerWorkingDir();\n }\n\n static async batchGetAppConversations(\n ids: string[],\n ): Promise<(AppConversation | null)[]> {\n if (ids.length === 0) return [];\n\n if (getActiveBackend().backend.kind === \"cloud\") {\n return batchGetCloudConversations(ids);\n }\n\n const data = await new ConversationClient(\n getAgentServerClientOptions(),\n ).getConversations<DirectConversationInfo>(ids);\n\n return requireDirectConversationItems(data).map((item) =>\n toAppConversation(item),\n );\n }\n\n static async updateConversationPublicFlag(\n conversationId: string,\n isPublic: boolean,\n ): Promise<AppConversation> {\n if (getActiveBackend().backend.kind !== \"cloud\") {\n throw new Error(\"Public sharing requires a cloud backend.\");\n }\n return updateCloudConversationPublicFlag(conversationId, isPublic);\n }\n\n static async updateConversationRepository(\n conversationId: string,\n repository: string | null,\n branch?: string | null,\n gitProvider?: string | null,\n ): Promise<AppConversation> {\n if (repository) {\n const existing = getStoredConversationMetadata(conversationId);\n setStoredConversationMetadata(conversationId, {\n ...(existing ?? {}),\n selected_repository: repository,\n selected_branch: branch ?? null,\n git_provider: (gitProvider as Provider | null | undefined) ?? null,\n });\n } else {\n removeStoredConversationMetadata(conversationId);\n }\n const [conversation] = await this.batchGetAppConversations([\n conversationId,\n ]);\n return requireAppConversation(conversation, conversationId);\n }\n\n static async readConversationFile(\n conversationId: string,\n filePath?: string,\n ): Promise<string> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n // Cloud exposes a per-conversation file endpoint; the sandbox\n // working dir is fixed (`/workspace/project`), so PLAN.md lives at\n // a known absolute path. Mirrors OpenHands' readConversationFile.\n const path = requirePathInsideDirectory(\n filePath ?? \"/workspace/project/.agents_tmp/PLAN.md\",\n \"/workspace/project\",\n );\n return readCloudConversationFile(conversationId, path);\n }\n\n const workingDir = await this.resolveConversationWorkingDir(conversationId);\n const path = requirePathInsideDirectory(\n filePath ?? `${workingDir}/.agents_tmp/PLAN.md`,\n workingDir,\n );\n return new FileClient(getAgentServerClientOptions()).downloadTextFile(path);\n }\n\n static async downloadConversation(conversationId: string): Promise<Blob> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return downloadCloudConversation(conversationId);\n }\n\n return new FileClient(getAgentServerClientOptions()).downloadTrajectory(\n conversationId,\n );\n }\n\n static async getHooks(conversationId: string): Promise<GetHooksResponse> {\n if (!conversationId) {\n return emptyHooksResponse();\n }\n return emptyHooksResponse();\n }\n\n static async getRuntimeConversation(\n conversationId: string,\n conversationUrl: string | null | undefined,\n sessionApiKey?: string | null,\n ): Promise<RuntimeConversationInfo> {\n const active = getActiveBackend().backend;\n\n type RawRuntime = DirectConversationInfo & {\n stats?: RuntimeConversationInfo[\"stats\"];\n };\n\n // Cloud mode: route through the cloud-proxy to the runtime sandbox at\n // the conversation's runtime URL — same pattern as getVSCodeUrl. Local\n // mode forwards conversationUrl so the host explicitly resolves to the\n // conversation's runtime instead of falling back to the active backend.\n const response =\n active.kind === \"cloud\" && conversationUrl\n ? await callCloudProxy<RawRuntime>({\n backend: active,\n method: \"GET\",\n hostOverride: buildHttpBaseUrl(conversationUrl),\n path: `/api/conversations/${conversationId}`,\n authMode: \"session-api-key\",\n sessionApiKey,\n })\n : await new ConversationClient(\n getAgentServerClientOptions({\n conversationUrl,\n sessionApiKey,\n }),\n ).getConversation<RawRuntime>(conversationId);\n const data = requireDirectConversationInfo(response);\n const stats = isRecord(response) ? response.stats : null;\n\n return {\n id: data.id,\n title: data.title?.trim()\n ? data.title\n : getDefaultConversationTitle(data.id),\n metrics: normalizeMetrics(data.metrics),\n created_at: data.created_at,\n updated_at: data.updated_at,\n status: toRuntimeStatus(data.execution_status),\n stats: isRecord(stats) ? stats : { usage_to_metrics: {} },\n };\n }\n\n static async searchConversations(\n limit: number = 20,\n pageId?: string,\n ): Promise<AppConversationPage> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return searchCloudConversations(limit, pageId);\n }\n\n const data = await new ConversationClient(\n getAgentServerClientOptions(),\n ).searchConversations({\n limit,\n page_id: pageId,\n sort_order: ConversationSortOrder.UPDATED_AT_DESC,\n });\n\n return toConversationPage(requireConversationSearchPage(data));\n }\n\n static async deleteConversation(conversationId: string): Promise<void> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n await deleteCloudConversation(conversationId);\n } else {\n await new ConversationClient(\n getAgentServerClientOptions(),\n ).deleteConversation(conversationId);\n }\n removeStoredConversationMetadata(conversationId);\n }\n\n static async updateConversationTitle(\n conversationId: string,\n title: string,\n ): Promise<AppConversation> {\n await new ConversationClient(\n getAgentServerClientOptions(),\n ).updateConversation(conversationId, {\n title,\n });\n const [conversation] = await this.batchGetAppConversations([\n conversationId,\n ]);\n return requireAppConversation(conversation, conversationId);\n }\n\n /**\n * Switches the LLM profile for the running conversation when one is open\n * (POST /switch_profile — per-conversation swap, doesn't change the user's\n * default profile). When called without a conversationId (home page),\n * falls back to POST /activate so the next conversation created picks up\n * the chosen profile.\n *\n * The per-conversation endpoint accepts only the profile name, so the UI does\n * not need to fetch or forward profile secrets. That keeps switching working\n * even when the agent server has no OH_SECRET_KEY for encrypted secret export.\n */\n static async switchProfile(\n conversationId: string | null,\n profileName: string,\n ): Promise<void> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n throw new Error(\n \"LLM profile switching is only supported for local agent-server backends.\",\n );\n }\n\n if (!conversationId) {\n await new ProfilesClient(getAgentServerClientOptions()).activateProfile(\n profileName,\n );\n return;\n }\n\n const clientOptions = getAgentServerClientOptions();\n const conversationClient = new ConversationClient(clientOptions);\n const profile = await new ProfilesClient(clientOptions).getProfile(\n profileName,\n { exposeSecrets: \"encrypted\" },\n );\n const model =\n typeof profile.config.model === \"string\" ? profile.config.model : \"\";\n if (!model) throw new Error(`Profile '${profileName}' has no model.`);\n await conversationClient.switchLLM(conversationId, {\n ...profile.config,\n model,\n // Avoid stale first-write-wins entries in the backend LLM registry.\n usage_id: `profile:${profileName}:${uuidv4()}`,\n } as LLMConfig);\n }\n\n /**\n * Switches the model of a running ACP conversation in place (POST\n * /switch_acp_model — the ACP analog of {@link switchProfile}'s /switch_profile).\n * The agent-server calls the ACP wrapper's ``session/set_model`` on the live\n * session, preserving context. Mirrors {@link switchProfile}'s\n * local-backend-only guard and per-conversation ConversationClient call.\n *\n * Only valid once an ACP session exists (after the first message); the\n * agent-server returns 409 before then — the home/no-session default is\n * persisted via Settings instead (see ``use-switch-acp-model``).\n */\n static async switchAcpModel(\n conversationId: string,\n model: string,\n ): Promise<void> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n throw new Error(\n \"ACP model switching is only supported for local agent-server backends.\",\n );\n }\n\n await new ConversationClient(getAgentServerClientOptions()).switchAcpModel(\n conversationId,\n model,\n );\n }\n}\n\nexport default AgentServerConversationService;\n"],"mappings":";;;;;;;;;;;;;;;;;AAkEA,IAAM,IAAiC,4BACjC,IACJ;AAGF,SAAS,IAAqC;AAC5C,QAAW,MAAM,EAAsC;;AAGzD,SAAS,EAAS,GAAkD;AAClE,QAAO,OAAO,KAAU,cAAY,KAAkB,CAAC,MAAM,QAAQ,EAAM;;AAG7E,SAAS,EAAa,GAA+B;AACnD,QAAO,OAAO,KAAU,WAAW,IAAQ;;AAG7C,SAAS,EAAa,GAAwB;AAC5C,QAAO,OAAO,KAAU,WAAW,IAAQ;;AAG7C,SAAS,EAAa,GAA+B;AACnD,QAAO,OAAO,KAAU,WAAW,IAAQ;;AAG7C,SAAS,EACP,GACA,GACA,GACQ;CACR,IAAM,IAAQ,EAAK,MAAa,EAAK;AACrC,QAAO,OAAO,KAAU,YAAY,EAAM,MAAM,GAC5C,IACA;;AAGN,SAAS,EACP,GACgE;AAGhE,QAFK,EAAS,EAAM,GAEb;EACL,eAAe,EAAa,EAAM,cAAc;EAChD,mBAAmB,EAAa,EAAM,kBAAkB;EACxD,mBAAmB,EAAa,EAAM,kBAAkB;EACxD,oBAAoB,EAAa,EAAM,mBAAmB;EAC1D,gBAAgB,EAAa,EAAM,eAAe;EAClD,gBAAgB,EAAa,EAAM,eAAe;EACnD,GAT4B;;AAY/B,SAAS,EAAiB,GAAwC;AAGhE,QAFK,EAAS,EAAM,GAEb;EACL,kBAAkB,EAAa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;AACpE,MAAI,CAAC,EAAO,OAAU,MAAM,YAAY,EAAY,iBAAiB;AACrE,QAAM,EAAmB,UAAU,GAAgB;GACjD,GAAG,EAAQ;GACX;GAEA,UAAU,WAAW,EAAY,GAAG,GAAQ;GAC7C,CAAc;;CAcjB,aAAa,eACX,GACA,GACe;AACf,MAAI,GAAkB,CAAC,QAAQ,SAAS,QACtC,OAAU,MACR,yEACD;AAGH,QAAM,IAAI,EAAmB,GAA6B,CAAC,CAAC,eAC1D,GACA,EACD"}
|
|
1
|
+
{"version":3,"file":"agent-server-conversation-service.api.js","names":[],"sources":["../../../src/api/conversation-service/agent-server-conversation-service.api.ts"],"sourcesContent":["import {\n ConversationSortOrder,\n type LLMConfig,\n} from \"@openhands/typescript-client\";\nimport {\n ConversationClient,\n FileClient,\n ProfilesClient,\n VSCodeClient,\n} from \"@openhands/typescript-client/clients\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { Provider } from \"#/types/settings\";\nimport type { ConversationRuntimeContext } from \"#/api/conversation-file-upload.api\";\nimport { buildHttpBaseUrl } from \"#/utils/websocket-url\";\nimport {\n buildConversationWorkingDir,\n getAgentServerWorkingDir,\n} from \"../agent-server-config\";\nimport { resolveAbsoluteAgentServerPath } from \"../agent-server-home\";\nimport {\n getActiveBackend,\n getEffectiveLocalBackend,\n} from \"../backend-registry/active-store\";\nimport { callCloudProxy } from \"../cloud/proxy\";\nimport {\n batchGetCloudConversations,\n createCloudAppConversation,\n deleteCloudConversation,\n downloadCloudConversation,\n getCloudAppConversationStartTask,\n readCloudConversationFile,\n searchCloudConversations,\n updateCloudConversationPublicFlag,\n} from \"../cloud/conversation-service.api\";\nimport {\n DirectConversationInfo,\n buildStartConversationRequestWithEncryptedSettings,\n emptyHooksResponse,\n getDefaultConversationTitle,\n toAppConversation,\n toConversationPage,\n} from \"../agent-server-adapter\";\nimport { GetVSCodeUrlResponse } from \"../open-hands.types\";\nimport {\n getAgentServerClientOptions,\n NoBackendAvailableError,\n} from \"../agent-server-client-options\";\nimport SettingsService from \"../settings-service/settings-service.api\";\nimport {\n ConversationMetadata,\n getStoredConversationMetadata,\n removeStoredConversationMetadata,\n setStoredConversationMetadata,\n} from \"../conversation-metadata-store\";\nimport type {\n GetHooksResponse,\n PluginSpec,\n AppConversation,\n AppConversationPage,\n AppConversationStartRequest,\n AppConversationStartTask,\n MetricsSnapshot,\n RuntimeConversationInfo,\n SendMessageRequest,\n SendMessageResponse,\n} from \"./agent-server-conversation-service.types\";\n\nconst DEFAULT_CONVERSATION_TIMESTAMP = \"1970-01-01T00:00:00.000Z\";\nconst INVALID_CONVERSATION_RESPONSE_MESSAGE =\n \"Unable to load conversations because the selected agent server returned \" +\n \"data this UI does not understand. Check the backend URL/session key and \" +\n \"update the agent server if needed.\";\nfunction invalidConversationResponse(): Error {\n return new Error(INVALID_CONVERSATION_RESPONSE_MESSAGE);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction numberOrNull(value: unknown): number | null {\n return typeof value === \"number\" ? value : null;\n}\n\nfunction numberOrZero(value: unknown): number {\n return typeof value === \"number\" ? value : 0;\n}\n\nfunction stringOrNull(value: unknown): string | null {\n return typeof value === \"string\" ? value : null;\n}\n\nfunction readTimestamp(\n item: Record<string, unknown>,\n snakeKey: \"created_at\" | \"updated_at\",\n camelKey: \"createdAt\" | \"updatedAt\",\n): string {\n const value = item[snakeKey] ?? item[camelKey];\n return typeof value === \"string\" && value.trim()\n ? value\n : DEFAULT_CONVERSATION_TIMESTAMP;\n}\n\nfunction normalizeTokenUsage(\n value: unknown,\n): NonNullable<MetricsSnapshot[\"accumulated_token_usage\"]> | null {\n if (!isRecord(value)) return null;\n\n return {\n prompt_tokens: numberOrZero(value.prompt_tokens),\n completion_tokens: numberOrZero(value.completion_tokens),\n cache_read_tokens: numberOrZero(value.cache_read_tokens),\n cache_write_tokens: numberOrZero(value.cache_write_tokens),\n context_window: numberOrZero(value.context_window),\n per_turn_token: numberOrZero(value.per_turn_token),\n };\n}\n\nfunction normalizeMetrics(value: unknown): MetricsSnapshot | null {\n if (!isRecord(value)) return null;\n\n return {\n accumulated_cost: numberOrNull(value.accumulated_cost),\n max_budget_per_task: numberOrNull(value.max_budget_per_task),\n accumulated_token_usage: normalizeTokenUsage(value.accumulated_token_usage),\n };\n}\n\nfunction normalizeAgent(value: unknown): DirectConversationInfo[\"agent\"] {\n if (!isRecord(value)) return null;\n const llm = isRecord(value.llm)\n ? { model: stringOrNull(value.llm.model) }\n : null;\n // ``kind`` is the SDK's pydantic discriminator (``\"Agent\"`` vs ``\"ACPAgent\"``);\n // ``toAppConversation`` reads it to derive ``agent_kind``. ``acp_model`` is\n // the Canvas-configured model on the ACPAgent — preserved so the conversation\n // adapter and the conversation chip can fall back to it when the SDK runtime\n // model fields aren't populated. Preserving these here makes the wire path\n // agree with the unit-test path that builds ``DirectConversationInfo``\n // directly (e.g. ``__tests__/api/agent-server-adapter.test.ts``).\n return {\n kind: stringOrNull(value.kind),\n acp_model: stringOrNull(value.acp_model),\n llm,\n };\n}\n\nfunction normalizeWorkspace(\n value: unknown,\n): DirectConversationInfo[\"workspace\"] {\n if (!isRecord(value)) return null;\n return { working_dir: stringOrNull(value.working_dir) };\n}\n\n/**\n * Accept the agent-server's ``tags: Record[str, str]`` payload defensively:\n * the wire shape is guaranteed by the server-side validator (keys\n * ``^[a-z0-9]+$``, string values), but a non-conforming response (older\n * server, raw API write, future schema drift) must never crash the parser\n * — Canvas only consumes ``acpserver`` and falls back to a generic chip\n * for anything it doesn't recognize. Drop entries whose value isn't a\n * plain string; return ``null`` when the wire field is absent or not an\n * object so consumers can use ``info.tags?.[KEY] ?? null`` uniformly.\n */\nfunction normalizeTags(value: unknown): Record<string, string> | null {\n if (!isRecord(value)) return null;\n const tags: Record<string, string> = {};\n for (const [key, entry] of Object.entries(value)) {\n if (typeof entry === \"string\") {\n tags[key] = entry;\n }\n }\n return tags;\n}\n\nfunction normalizeAbsolutePath(path: string): string | null {\n if (!path.startsWith(\"/\")) return null;\n\n const segments: string[] = [];\n for (const segment of path.split(\"/\")) {\n if (segment && segment !== \".\") {\n if (segment === \"..\") {\n if (!segments.length) return null;\n segments.pop();\n } else {\n segments.push(segment);\n }\n }\n }\n\n return `/${segments.join(\"/\")}`;\n}\n\nfunction requirePathInsideDirectory(path: string, directory: string): string {\n const normalizedPath = normalizeAbsolutePath(path);\n const normalizedDirectory = normalizeAbsolutePath(directory);\n\n if (\n !normalizedPath ||\n !normalizedDirectory ||\n (normalizedPath !== normalizedDirectory &&\n !normalizedPath.startsWith(`${normalizedDirectory}/`))\n ) {\n throw new Error(\"Conversation file path must stay inside the workspace\");\n }\n\n return normalizedPath;\n}\n\nfunction requireDirectConversationInfo(item: unknown): DirectConversationInfo {\n if (!isRecord(item) || typeof item.id !== \"string\" || !item.id.trim()) {\n throw invalidConversationResponse();\n }\n\n return {\n id: item.id.trim(),\n title: stringOrNull(item.title),\n created_at: readTimestamp(item, \"created_at\", \"createdAt\"),\n updated_at: readTimestamp(item, \"updated_at\", \"updatedAt\"),\n execution_status: stringOrNull(item.execution_status),\n sandbox_status: stringOrNull(item.sandbox_status),\n metrics: normalizeMetrics(item.metrics),\n agent: normalizeAgent(item.agent),\n workspace: normalizeWorkspace(item.workspace),\n tags: normalizeTags(item.tags),\n // SDK-runtime ACP model fields (populated when the agent-server supports\n // ``ConversationInfo.current_model_*``). Consumed by the conversation\n // adapter to drive the per-card chip's model text. Older agent-servers\n // omit these — adapter handles ``undefined`` / ``null`` gracefully.\n current_model_id: stringOrNull(item.current_model_id),\n current_model_name: stringOrNull(item.current_model_name),\n };\n}\n\nfunction requireDirectConversationItems(\n items: unknown,\n): DirectConversationInfo[] {\n if (!Array.isArray(items)) {\n throw invalidConversationResponse();\n }\n return items.map(requireDirectConversationInfo);\n}\n\nfunction requireConversationSearchPage(page: unknown): {\n items: DirectConversationInfo[];\n next_page_id: string | null;\n} {\n if (Array.isArray(page)) {\n return {\n items: requireDirectConversationItems(page),\n next_page_id: null,\n };\n }\n\n if (!isRecord(page)) {\n throw invalidConversationResponse();\n }\n\n return {\n items: requireDirectConversationItems(page.items),\n next_page_id:\n typeof page.next_page_id === \"string\" ? page.next_page_id : null,\n };\n}\n\nconst RUNTIME_STATUSES = new Set<string>([\n \"idle\",\n \"running\",\n \"paused\",\n \"waiting_for_confirmation\",\n \"finished\",\n \"error\",\n \"stuck\",\n]);\n\nfunction toRuntimeStatus(\n status: DirectConversationInfo[\"execution_status\"],\n): RuntimeConversationInfo[\"status\"] {\n const nextStatus = status ?? \"idle\";\n return (\n RUNTIME_STATUSES.has(nextStatus) ? nextStatus : \"idle\"\n ) as RuntimeConversationInfo[\"status\"];\n}\n\nfunction requireAppConversation(\n conversation: AppConversation | null | undefined,\n conversationId: string,\n): AppConversation {\n if (!conversation) {\n throw new Error(`Conversation ${conversationId} was not found`);\n }\n return conversation;\n}\n\nclass AgentServerConversationService {\n static async sendMessage(\n conversationId: string,\n message: SendMessageRequest,\n runtime?: ConversationRuntimeContext | null,\n ): Promise<SendMessageResponse> {\n const active = getActiveBackend().backend;\n let conversationUrl = runtime?.conversationUrl ?? null;\n let sessionApiKey = runtime?.sessionApiKey ?? null;\n\n if (active.kind === \"cloud\") {\n if (!conversationUrl || !sessionApiKey) {\n const [conversation] = await batchGetCloudConversations([\n conversationId,\n ]);\n conversationUrl = conversation?.conversation_url?.trim() ?? null;\n sessionApiKey = conversation?.session_api_key?.trim() ?? null;\n }\n\n if (!conversationUrl || !sessionApiKey) {\n throw new Error(\n \"Conversation sandbox is still starting. Wait for it to finish, then try again.\",\n );\n }\n\n await callCloudProxy({\n backend: active,\n method: \"POST\",\n hostOverride: buildHttpBaseUrl(conversationUrl),\n path: `/api/conversations/${conversationId}/events`,\n body: { ...message, run: true },\n authMode: \"session-api-key\",\n sessionApiKey,\n });\n\n return message;\n }\n\n await new ConversationClient(\n getAgentServerClientOptions({ conversationUrl, sessionApiKey }),\n ).sendEvent(conversationId, message, {\n run: true,\n });\n\n return message;\n }\n\n static async createConversation(\n initialUserMsg?: string,\n conversationInstructions?: string,\n plugins?: PluginSpec[],\n metadata?: ConversationMetadata | null,\n workingDirOverride?: string,\n parentConversationId?: string,\n agentType?: \"default\" | \"plan\",\n sandboxId?: string,\n ): Promise<AppConversationStartTask> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n // Cloud path mirrors OpenHands' frontend: build a flat\n // AppConversationStartRequest, POST /api/v1/app-conversations\n // (returns a WORKING task), and let the conversation route's\n // useTaskPolling drive it to READY. NO encrypted-settings\n // round-trip — the cloud backend holds secrets server-side.\n const request: AppConversationStartRequest = {\n initial_message: initialUserMsg\n ? {\n role: \"user\",\n content: [{ type: \"text\", text: initialUserMsg }],\n }\n : null,\n title: conversationInstructions ?? null,\n selected_repository: metadata?.selected_repository ?? null,\n selected_branch: metadata?.selected_branch ?? null,\n git_provider: metadata?.git_provider ?? null,\n plugins: plugins ?? null,\n parent_conversation_id: parentConversationId ?? null,\n agent_type: agentType,\n sandbox_id: sandboxId ?? null,\n };\n return createCloudAppConversation(request);\n }\n\n const settings = await SettingsService.getSettings();\n const conversationId = uuidv4();\n // @spec WUP-001 — Send an absolute working_dir to the agent-server.\n // The default is `workspace/project/<hex>` (relative); without\n // resolving it here, `/api/file/upload` later prepends `/` and writes\n // to `/workspace/...` (read-only on macOS and fresh containers). When\n // the user picks an explicit workspace, `workingDirOverride` is\n // already absolute (it comes from `search_subdirs`).\n const workingDir = await resolveAbsoluteAgentServerPath(\n workingDirOverride ?? buildConversationWorkingDir(conversationId),\n );\n\n // Use encrypted settings to avoid exposing secrets in the browser\n const payload = await buildStartConversationRequestWithEncryptedSettings({\n settings,\n query: initialUserMsg,\n conversationInstructions,\n plugins,\n conversationId,\n workingDir,\n });\n\n const data = await new ConversationClient(\n getAgentServerClientOptions(),\n ).createConversation<DirectConversationInfo>(payload);\n const localBackend = getEffectiveLocalBackend();\n if (!localBackend) throw new NoBackendAvailableError();\n\n if (metadata?.selected_repository || workingDirOverride) {\n // The agent-server runtime has no concept of selected repo/branch/\n // workspace, so persist the home-page selection client-side.\n // `toAppConversation` reads the repo/branch fields back to hydrate\n // the chat-page badges; `useHasAttachedSource` reads\n // `selected_workspace` to default the Files tab to Diff mode when\n // the user explicitly attached a local workspace.\n setStoredConversationMetadata(data.id, {\n selected_repository: metadata?.selected_repository ?? null,\n selected_branch: metadata?.selected_branch ?? null,\n git_provider: metadata?.git_provider ?? null,\n selected_workspace: workingDirOverride ?? null,\n });\n }\n\n return {\n id: data.id,\n created_by_user_id: null,\n status: \"READY\",\n detail: null,\n app_conversation_id: data.id,\n agent_server_url: localBackend.host,\n request: {\n initial_message: payload.initial_message as\n | AppConversationStartRequest[\"initial_message\"]\n | undefined,\n plugins: plugins ?? null,\n },\n created_at: data.created_at,\n updated_at: data.updated_at,\n };\n }\n\n static async getStartTask(\n taskId: string,\n ): Promise<AppConversationStartTask | null> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return getCloudAppConversationStartTask(taskId);\n }\n // Local agent-server creates conversations synchronously — every\n // local \"task\" is already READY when createConversation returns, so\n // there's nothing to poll for.\n return null;\n }\n\n static async getVSCodeUrl(\n conversationId: string,\n conversationUrl: string | null | undefined,\n sessionApiKey?: string | null,\n ): Promise<GetVSCodeUrlResponse> {\n // Local-only path. Cloud conversations read the VSCode URL straight\n // from the cloud-computed `sandbox.exposed_urls` (see\n // `useUnifiedVSCodeUrl` + `useCloudSandbox`); the runtime's own\n // `/api/vscode/url` only knows its internal `localhost:8001`, which\n // the user's browser can't reach.\n const workspaceDir =\n await this.resolveConversationWorkingDir(conversationId);\n // Local mode: the typescript-client targets the local agent-server\n // directly via the conversationUrl override.\n const vscodeUrl = await new VSCodeClient(\n getAgentServerClientOptions({\n conversationUrl,\n sessionApiKey,\n }),\n ).getUrl({\n baseUrl:\n typeof window !== \"undefined\" ? window.location.origin : undefined,\n workspaceDir,\n });\n\n return { vscode_url: vscodeUrl };\n }\n\n static async resolveConversationWorkingDir(\n conversationId: string,\n ): Promise<string> {\n const [conversation] = await this.batchGetAppConversations([\n conversationId,\n ]);\n return conversation?.workspace?.working_dir ?? getAgentServerWorkingDir();\n }\n\n static async batchGetAppConversations(\n ids: string[],\n ): Promise<(AppConversation | null)[]> {\n if (ids.length === 0) return [];\n\n if (getActiveBackend().backend.kind === \"cloud\") {\n return batchGetCloudConversations(ids);\n }\n\n const data = await new ConversationClient(\n getAgentServerClientOptions(),\n ).getConversations<DirectConversationInfo>(ids);\n\n return requireDirectConversationItems(data).map((item) =>\n toAppConversation(item),\n );\n }\n\n static async updateConversationPublicFlag(\n conversationId: string,\n isPublic: boolean,\n ): Promise<AppConversation> {\n if (getActiveBackend().backend.kind !== \"cloud\") {\n throw new Error(\"Public sharing requires a cloud backend.\");\n }\n return updateCloudConversationPublicFlag(conversationId, isPublic);\n }\n\n static async updateConversationRepository(\n conversationId: string,\n repository: string | null,\n branch?: string | null,\n gitProvider?: string | null,\n ): Promise<AppConversation> {\n if (repository) {\n const existing = getStoredConversationMetadata(conversationId);\n setStoredConversationMetadata(conversationId, {\n ...(existing ?? {}),\n selected_repository: repository,\n selected_branch: branch ?? null,\n git_provider: (gitProvider as Provider | null | undefined) ?? null,\n });\n } else {\n removeStoredConversationMetadata(conversationId);\n }\n const [conversation] = await this.batchGetAppConversations([\n conversationId,\n ]);\n return requireAppConversation(conversation, conversationId);\n }\n\n static async readConversationFile(\n conversationId: string,\n filePath?: string,\n ): Promise<string> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n // Cloud exposes a per-conversation file endpoint; the sandbox\n // working dir is fixed (`/workspace/project`), so PLAN.md lives at\n // a known absolute path. Mirrors OpenHands' readConversationFile.\n const path = requirePathInsideDirectory(\n filePath ?? \"/workspace/project/.agents_tmp/PLAN.md\",\n \"/workspace/project\",\n );\n return readCloudConversationFile(conversationId, path);\n }\n\n const workingDir = await this.resolveConversationWorkingDir(conversationId);\n const path = requirePathInsideDirectory(\n filePath ?? `${workingDir}/.agents_tmp/PLAN.md`,\n workingDir,\n );\n return new FileClient(getAgentServerClientOptions()).downloadTextFile(path);\n }\n\n static async downloadConversation(conversationId: string): Promise<Blob> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return downloadCloudConversation(conversationId);\n }\n\n return new FileClient(getAgentServerClientOptions()).downloadTrajectory(\n conversationId,\n );\n }\n\n static async getHooks(conversationId: string): Promise<GetHooksResponse> {\n if (!conversationId) {\n return emptyHooksResponse();\n }\n return emptyHooksResponse();\n }\n\n static async getRuntimeConversation(\n conversationId: string,\n conversationUrl: string | null | undefined,\n sessionApiKey?: string | null,\n ): Promise<RuntimeConversationInfo> {\n const active = getActiveBackend().backend;\n\n type RawRuntime = DirectConversationInfo & {\n stats?: RuntimeConversationInfo[\"stats\"];\n };\n\n // Cloud mode: route through the cloud-proxy to the runtime sandbox at\n // the conversation's runtime URL — same pattern as getVSCodeUrl. Local\n // mode forwards conversationUrl so the host explicitly resolves to the\n // conversation's runtime instead of falling back to the active backend.\n const response =\n active.kind === \"cloud\" && conversationUrl\n ? await callCloudProxy<RawRuntime>({\n backend: active,\n method: \"GET\",\n hostOverride: buildHttpBaseUrl(conversationUrl),\n path: `/api/conversations/${conversationId}`,\n authMode: \"session-api-key\",\n sessionApiKey,\n })\n : await new ConversationClient(\n getAgentServerClientOptions({\n conversationUrl,\n sessionApiKey,\n }),\n ).getConversation<RawRuntime>(conversationId);\n const data = requireDirectConversationInfo(response);\n const stats = isRecord(response) ? response.stats : null;\n\n return {\n id: data.id,\n title: data.title?.trim()\n ? data.title\n : getDefaultConversationTitle(data.id),\n metrics: normalizeMetrics(data.metrics),\n created_at: data.created_at,\n updated_at: data.updated_at,\n status: toRuntimeStatus(data.execution_status),\n stats: isRecord(stats) ? stats : { usage_to_metrics: {} },\n };\n }\n\n static async searchConversations(\n limit: number = 20,\n pageId?: string,\n ): Promise<AppConversationPage> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return searchCloudConversations(limit, pageId);\n }\n\n const data = await new ConversationClient(\n getAgentServerClientOptions(),\n ).searchConversations({\n limit,\n page_id: pageId,\n sort_order: ConversationSortOrder.UPDATED_AT_DESC,\n });\n\n return toConversationPage(requireConversationSearchPage(data));\n }\n\n static async deleteConversation(conversationId: string): Promise<void> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n await deleteCloudConversation(conversationId);\n } else {\n await new ConversationClient(\n getAgentServerClientOptions(),\n ).deleteConversation(conversationId);\n }\n removeStoredConversationMetadata(conversationId);\n }\n\n static async updateConversationTitle(\n conversationId: string,\n title: string,\n ): Promise<AppConversation> {\n await new ConversationClient(\n getAgentServerClientOptions(),\n ).updateConversation(conversationId, {\n title,\n });\n const [conversation] = await this.batchGetAppConversations([\n conversationId,\n ]);\n return requireAppConversation(conversation, conversationId);\n }\n\n /**\n * Switches the LLM profile for the running conversation when one is open\n * (POST /switch_profile — per-conversation swap, doesn't change the user's\n * default profile). When called without a conversationId (home page),\n * falls back to POST /activate so the next conversation created picks up\n * the chosen profile.\n *\n * The per-conversation endpoint accepts only the profile name, so the UI does\n * not need to fetch or forward profile secrets. That keeps switching working\n * even when the agent server has no OH_SECRET_KEY for encrypted secret export.\n */\n static async switchProfile(\n conversationId: string | null,\n profileName: string,\n ): Promise<void> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n throw new Error(\n \"LLM profile switching is only supported for local agent-server backends.\",\n );\n }\n\n if (!conversationId) {\n await new ProfilesClient(getAgentServerClientOptions()).activateProfile(\n profileName,\n );\n return;\n }\n\n const clientOptions = getAgentServerClientOptions();\n const conversationClient = new ConversationClient(clientOptions);\n const profile = await new ProfilesClient(clientOptions).getProfile(\n profileName,\n { exposeSecrets: \"encrypted\" },\n );\n const model =\n typeof profile.config.model === \"string\" ? profile.config.model : \"\";\n if (!model) throw new Error(`Profile '${profileName}' has no model.`);\n await conversationClient.switchLLM(conversationId, {\n ...profile.config,\n model,\n // Avoid stale first-write-wins entries in the backend LLM registry.\n usage_id: `profile:${profileName}:${uuidv4()}`,\n } as LLMConfig);\n }\n\n /**\n * Switches the model of a running ACP conversation in place (POST\n * /switch_acp_model — the ACP analog of {@link switchProfile}'s /switch_profile).\n * The agent-server calls the ACP wrapper's ``session/set_model`` on the live\n * session, preserving context. Mirrors {@link switchProfile}'s\n * local-backend-only guard and per-conversation ConversationClient call.\n *\n * Only valid once an ACP session exists (after the first message); the\n * agent-server returns 409 before then — the home/no-session default is\n * persisted via Settings instead (see ``use-switch-acp-model``).\n */\n static async switchAcpModel(\n conversationId: string,\n model: string,\n ): Promise<void> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n throw new Error(\n \"ACP model switching is only supported for local agent-server backends.\",\n );\n }\n\n await new ConversationClient(getAgentServerClientOptions()).switchAcpModel(\n conversationId,\n model,\n );\n }\n}\n\nexport default AgentServerConversationService;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmEA,IAAM,IAAiC,4BACjC,IACJ;AAGF,SAAS,IAAqC;AAC5C,QAAW,MAAM,EAAsC;;AAGzD,SAAS,EAAS,GAAkD;AAClE,QAAO,OAAO,KAAU,cAAY,KAAkB,CAAC,MAAM,QAAQ,EAAM;;AAG7E,SAAS,EAAa,GAA+B;AACnD,QAAO,OAAO,KAAU,WAAW,IAAQ;;AAG7C,SAAS,EAAa,GAAwB;AAC5C,QAAO,OAAO,KAAU,WAAW,IAAQ;;AAG7C,SAAS,EAAa,GAA+B;AACnD,QAAO,OAAO,KAAU,WAAW,IAAQ;;AAG7C,SAAS,EACP,GACA,GACA,GACQ;CACR,IAAM,IAAQ,EAAK,MAAa,EAAK;AACrC,QAAO,OAAO,KAAU,YAAY,EAAM,MAAM,GAC5C,IACA;;AAGN,SAAS,EACP,GACgE;AAGhE,QAFK,EAAS,EAAM,GAEb;EACL,eAAe,EAAa,EAAM,cAAc;EAChD,mBAAmB,EAAa,EAAM,kBAAkB;EACxD,mBAAmB,EAAa,EAAM,kBAAkB;EACxD,oBAAoB,EAAa,EAAM,mBAAmB;EAC1D,gBAAgB,EAAa,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I,EAAmB,EAAc,EAC1D,IAAU,MAAM,IAAI,EAAe,EAAc,CAAC,WACtD,GACA,EAAE,eAAe,aAAa,CAC/B,EACK,IACJ,OAAO,EAAQ,OAAO,SAAU,WAAW,EAAQ,OAAO,QAAQ;AACpE,MAAI,CAAC,EAAO,OAAU,MAAM,YAAY,EAAY,iBAAiB;AACrE,QAAM,EAAmB,UAAU,GAAgB;GACjD,GAAG,EAAQ;GACX;GAEA,UAAU,WAAW,EAAY,GAAG,GAAQ;GAC7C,CAAc;;CAcjB,aAAa,eACX,GACA,GACe;AACf,MAAI,GAAkB,CAAC,QAAQ,SAAS,QACtC,OAAU,MACR,yEACD;AAGH,QAAM,IAAI,EAAmB,GAA6B,CAAC,CAAC,eAC1D,GACA,EACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"option-service.api.cjs","names":[],"sources":["../../../src/api/option-service/option-service.api.ts"],"sourcesContent":["import { LLMMetadataClient } from \"@openhands/typescript-client/clients\";\nimport { loadAgentServerInfo } from \"../agent-server-compatibility\";\nimport { getAgentServerClientOptions } from \"../agent-server-client-options\";\nimport { ModelsResponse, WebClientConfig } from \"./option.types\";\n\nclass OptionService {\n static async getModels(): Promise<ModelsResponse> {\n const llmClient = new LLMMetadataClient(getAgentServerClientOptions());\n const [models, verifiedByProvider, providers] = await Promise.all([\n llmClient.getModels(),\n llmClient.getVerifiedModels(),\n llmClient.getProviders(),\n ]);\n\n const verifiedProviders = Object.keys(verifiedByProvider ?? {}).sort();\n const verifiedModels = verifiedProviders.flatMap(\n (provider) => verifiedByProvider[provider] ?? [],\n );\n\n return {\n models: models ?? [],\n verified_models: verifiedModels,\n verified_providers:\n providers?.filter((provider) => verifiedProviders.includes(provider)) ??\n verifiedProviders,\n default_model: verifiedModels[0] ?? models?.[0] ?? \"\",\n };\n }\n\n static async getConfig(): Promise<WebClientConfig> {\n await loadAgentServerInfo();\n\n return {\n posthog_client_key
|
|
1
|
+
{"version":3,"file":"option-service.api.cjs","names":[],"sources":["../../../src/api/option-service/option-service.api.ts"],"sourcesContent":["import { LLMMetadataClient } from \"@openhands/typescript-client/clients\";\nimport { loadAgentServerInfo } from \"../agent-server-compatibility\";\nimport { getAgentServerClientOptions } from \"../agent-server-client-options\";\nimport { ModelsResponse, WebClientConfig } from \"./option.types\";\n\nclass OptionService {\n static async getModels(): Promise<ModelsResponse> {\n const llmClient = new LLMMetadataClient(getAgentServerClientOptions());\n const [models, verifiedByProvider, providers] = await Promise.all([\n llmClient.getModels(),\n llmClient.getVerifiedModels(),\n llmClient.getProviders(),\n ]);\n\n const verifiedProviders = Object.keys(verifiedByProvider ?? {}).sort();\n const verifiedModels = verifiedProviders.flatMap(\n (provider) => verifiedByProvider[provider] ?? [],\n );\n\n return {\n models: models ?? [],\n verified_models: verifiedModels,\n verified_providers:\n providers?.filter((provider) => verifiedProviders.includes(provider)) ??\n verifiedProviders,\n default_model: verifiedModels[0] ?? models?.[0] ?? \"\",\n };\n }\n\n static async getConfig(): Promise<WebClientConfig> {\n await loadAgentServerInfo();\n\n return {\n posthog_client_key:\n (import.meta.env.VITE_POSTHOG_CLIENT_KEY as string | undefined) ?? null,\n feature_flags: {\n hide_llm_settings: false,\n hide_users_page: true,\n },\n providers_configured: [],\n maintenance_start_time: null,\n recaptcha_site_key: null,\n faulty_models: [],\n error_message: null,\n updated_at: new Date().toISOString(),\n };\n }\n}\n\nexport default OptionService;\n"],"mappings":"6OAKA,IAAM,EAAN,KAAoB,CAClB,aAAa,WAAqC,CAChD,IAAM,EAAY,IAAI,EAAA,kBAAkB,EAAA,6BAA6B,CAAC,CAChE,CAAC,EAAQ,EAAoB,GAAa,MAAM,QAAQ,IAAI,CAChE,EAAU,WAAW,CACrB,EAAU,mBAAmB,CAC7B,EAAU,cAAc,CACzB,CAAC,CAEI,EAAoB,OAAO,KAAK,GAAsB,EAAE,CAAC,CAAC,MAAM,CAChE,EAAiB,EAAkB,QACtC,GAAa,EAAmB,IAAa,EAAE,CACjD,CAED,MAAO,CACL,OAAQ,GAAU,EAAE,CACpB,gBAAiB,EACjB,mBACE,GAAW,OAAQ,GAAa,EAAkB,SAAS,EAAS,CAAC,EACrE,EACF,cAAe,EAAe,IAAM,IAAS,IAAM,GACpD,CAGH,aAAa,WAAsC,CAGjD,OAFA,MAAM,EAAA,qBAAqB,CAEpB,CACL,mBACqE,KACrE,cAAe,CACb,kBAAmB,GACnB,gBAAiB,GAClB,CACD,qBAAsB,EAAE,CACxB,uBAAwB,KACxB,mBAAoB,KACpB,cAAe,EAAE,CACjB,cAAe,KACf,WAAY,IAAI,MAAM,CAAC,aAAa,CACrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"option-service.api.js","names":[],"sources":["../../../src/api/option-service/option-service.api.ts"],"sourcesContent":["import { LLMMetadataClient } from \"@openhands/typescript-client/clients\";\nimport { loadAgentServerInfo } from \"../agent-server-compatibility\";\nimport { getAgentServerClientOptions } from \"../agent-server-client-options\";\nimport { ModelsResponse, WebClientConfig } from \"./option.types\";\n\nclass OptionService {\n static async getModels(): Promise<ModelsResponse> {\n const llmClient = new LLMMetadataClient(getAgentServerClientOptions());\n const [models, verifiedByProvider, providers] = await Promise.all([\n llmClient.getModels(),\n llmClient.getVerifiedModels(),\n llmClient.getProviders(),\n ]);\n\n const verifiedProviders = Object.keys(verifiedByProvider ?? {}).sort();\n const verifiedModels = verifiedProviders.flatMap(\n (provider) => verifiedByProvider[provider] ?? [],\n );\n\n return {\n models: models ?? [],\n verified_models: verifiedModels,\n verified_providers:\n providers?.filter((provider) => verifiedProviders.includes(provider)) ??\n verifiedProviders,\n default_model: verifiedModels[0] ?? models?.[0] ?? \"\",\n };\n }\n\n static async getConfig(): Promise<WebClientConfig> {\n await loadAgentServerInfo();\n\n return {\n posthog_client_key
|
|
1
|
+
{"version":3,"file":"option-service.api.js","names":[],"sources":["../../../src/api/option-service/option-service.api.ts"],"sourcesContent":["import { LLMMetadataClient } from \"@openhands/typescript-client/clients\";\nimport { loadAgentServerInfo } from \"../agent-server-compatibility\";\nimport { getAgentServerClientOptions } from \"../agent-server-client-options\";\nimport { ModelsResponse, WebClientConfig } from \"./option.types\";\n\nclass OptionService {\n static async getModels(): Promise<ModelsResponse> {\n const llmClient = new LLMMetadataClient(getAgentServerClientOptions());\n const [models, verifiedByProvider, providers] = await Promise.all([\n llmClient.getModels(),\n llmClient.getVerifiedModels(),\n llmClient.getProviders(),\n ]);\n\n const verifiedProviders = Object.keys(verifiedByProvider ?? {}).sort();\n const verifiedModels = verifiedProviders.flatMap(\n (provider) => verifiedByProvider[provider] ?? [],\n );\n\n return {\n models: models ?? [],\n verified_models: verifiedModels,\n verified_providers:\n providers?.filter((provider) => verifiedProviders.includes(provider)) ??\n verifiedProviders,\n default_model: verifiedModels[0] ?? models?.[0] ?? \"\",\n };\n }\n\n static async getConfig(): Promise<WebClientConfig> {\n await loadAgentServerInfo();\n\n return {\n posthog_client_key:\n (import.meta.env.VITE_POSTHOG_CLIENT_KEY as string | undefined) ?? null,\n feature_flags: {\n hide_llm_settings: false,\n hide_users_page: true,\n },\n providers_configured: [],\n maintenance_start_time: null,\n recaptcha_site_key: null,\n faulty_models: [],\n error_message: null,\n updated_at: new Date().toISOString(),\n };\n }\n}\n\nexport default OptionService;\n"],"mappings":";;;;AAKA,IAAM,IAAN,MAAoB;CAClB,aAAa,YAAqC;EAChD,IAAM,IAAY,IAAI,EAAkB,GAA6B,CAAC,EAChE,CAAC,GAAQ,GAAoB,KAAa,MAAM,QAAQ,IAAI;GAChE,EAAU,WAAW;GACrB,EAAU,mBAAmB;GAC7B,EAAU,cAAc;GACzB,CAAC,EAEI,IAAoB,OAAO,KAAK,KAAsB,EAAE,CAAC,CAAC,MAAM,EAChE,IAAiB,EAAkB,SACtC,MAAa,EAAmB,MAAa,EAAE,CACjD;AAED,SAAO;GACL,QAAQ,KAAU,EAAE;GACpB,iBAAiB;GACjB,oBACE,GAAW,QAAQ,MAAa,EAAkB,SAAS,EAAS,CAAC,IACrE;GACF,eAAe,EAAe,MAAM,IAAS,MAAM;GACpD;;CAGH,aAAa,YAAsC;AAGjD,SAFA,MAAM,GAAqB,EAEpB;GACL,oBACqE;GACrE,eAAe;IACb,mBAAmB;IACnB,iBAAiB;IAClB;GACD,sBAAsB,EAAE;GACxB,wBAAwB;GACxB,oBAAoB;GACpB,eAAe,EAAE;GACjB,eAAe;GACf,6BAAY,IAAI,MAAM,EAAC,aAAa;GACrC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./agent-server-config.cjs`)
|
|
1
|
+
require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./agent-server-config.cjs`);require(`./agent-server-client-options.cjs`);const t=require(`./agent-server-home.cjs`),n=require(`./conversation-metadata-store.cjs`),r=require(`./conversation-service/agent-server-conversation-service.api.cjs`);var i=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function a(e){let t=e.split(/[\\/]+/).filter(Boolean),n=t[t.length-1];if(!n||n===`.`||n===`..`)throw Error(`Invalid file name`);return n}async function o(e,n={}){return t.resolveAbsoluteAgentServerPath(e,n)}async function s(e,t,n={}){let r=a(e);return`${(await o(t,n)).replace(/[/\\]+$/,``)}/${r}`}async function c(t,a){if(a?.id===t&&a.workspace?.working_dir?.trim())return a.workspace.working_dir.trim();let o=n.getStoredConversationMetadata(t);return o?.selected_workspace?.trim()?o.selected_workspace.trim():i.test(t)?r.default.resolveConversationWorkingDir(t):e.getAgentServerWorkingDir()}exports.buildWorkspaceUploadPath=s,exports.getSafeUploadFileName=a,exports.resolveConversationUploadWorkingDir=c;
|
|
2
2
|
//# sourceMappingURL=workspace-upload-path.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-upload-path.cjs","names":[],"sources":["../../src/api/workspace-upload-path.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"workspace-upload-path.cjs","names":[],"sources":["../../src/api/workspace-upload-path.ts"],"sourcesContent":["// @spec WUP-001 — Resolve relative working dirs against /api/file/home\nimport AgentServerConversationService from \"#/api/conversation-service/agent-server-conversation-service.api\";\nimport { getAgentServerWorkingDir } from \"#/api/agent-server-config\";\nimport {\n type AgentServerClientOverrides,\n getAgentServerClientOptions,\n} from \"#/api/agent-server-client-options\";\nimport { resolveAbsoluteAgentServerPath } from \"#/api/agent-server-home\";\nimport { getStoredConversationMetadata } from \"#/api/conversation-metadata-store\";\nimport type { AppConversation } from \"#/api/conversation-service/agent-server-conversation-service.types\";\n\nconst UUID_PATTERN =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nexport function getSafeUploadFileName(fileName: string): string {\n const parts = fileName.split(/[\\\\/]+/).filter(Boolean);\n const safeName = parts[parts.length - 1];\n\n if (!safeName || safeName === \".\" || safeName === \"..\") {\n throw new Error(\"Invalid file name\");\n }\n\n return safeName;\n}\n\n/**\n * @deprecated The old `prepend `/` if not already absolute` behaviour is the\n * root cause of #XXXX (relative `workspace/project` → `/workspace/project`,\n * which is on a read-only mount on macOS / fresh containers). Callers that\n * need an actual absolute path must use {@link resolveAbsoluteWorkspacePath}\n * so the relative leg is anchored against `/api/file/home` instead.\n *\n * Kept for the rare callers that genuinely just want a leading-slash\n * normaliser on a value already known to be agent-server-rooted (e.g.\n * cosmetic display, log strings).\n */\nexport function toAbsoluteWorkspacePath(path: string): string {\n return path.startsWith(\"/\") ? path : `/${path}`;\n}\n\n/**\n * Resolve `workingDir` to an absolute path the agent-server's file APIs\n * accept. Relative paths are joined against `/api/file/home` (cached per\n * backend); absolute paths pass through.\n */\nexport async function resolveAbsoluteWorkspacePath(\n workingDir: string,\n overrides: AgentServerClientOverrides = {},\n): Promise<string> {\n return resolveAbsoluteAgentServerPath(workingDir, overrides);\n}\n\n/**\n * Build the absolute destination path for a file upload, resolving the\n * working-dir leg via {@link resolveAbsoluteWorkspacePath}.\n */\nexport async function buildWorkspaceUploadPath(\n fileName: string,\n workingDir: string,\n overrides: AgentServerClientOverrides = {},\n): Promise<string> {\n const safeName = getSafeUploadFileName(fileName);\n const absoluteDir = await resolveAbsoluteWorkspacePath(workingDir, overrides);\n return `${absoluteDir.replace(/[/\\\\]+$/, \"\")}/${safeName}`;\n}\n\n/**\n * Resolve the working directory for a file upload into a conversation's\n * workspace.\n *\n * **Returns the raw working dir string** — which may be relative (e.g.\n * `workspace/project/<hex>`) when the default `DEFAULT_WORKING_DIR` is in\n * use. Callers that need an actual filesystem-absolute path (e.g. to pass to\n * the agent-server's `/api/file/upload` endpoint) **must** funnel this result\n * through {@link buildWorkspaceUploadPath}, which calls\n * {@link resolveAbsoluteWorkspacePath} to anchor any relative segment against\n * the agent-server's home directory.\n *\n * Why not resolve here? Because this function is also called by cloud-runtime\n * upload paths where the overrides (conversationUrl, sessionApiKey) aren't\n * available until {@link uploadFilesToConversation} assembles them. Keeping\n * the resolution step in {@link buildWorkspaceUploadPath} means both the\n * local and cloud legs share a single resolution point with the correct\n * override context.\n */\nexport async function resolveConversationUploadWorkingDir(\n conversationId: string,\n currentConversation?: AppConversation | null,\n): Promise<string> {\n if (\n currentConversation?.id === conversationId &&\n currentConversation.workspace?.working_dir?.trim()\n ) {\n return currentConversation.workspace.working_dir.trim();\n }\n\n const stored = getStoredConversationMetadata(conversationId);\n if (stored?.selected_workspace?.trim()) {\n return stored.selected_workspace.trim();\n }\n\n if (UUID_PATTERN.test(conversationId)) {\n return AgentServerConversationService.resolveConversationWorkingDir(\n conversationId,\n );\n }\n\n return getAgentServerWorkingDir();\n}\n\n// Re-export so callers can construct overrides matching what\n// {@link buildWorkspaceUploadPath} expects without importing two modules.\nexport type { AgentServerClientOverrides };\nexport { getAgentServerClientOptions };\n"],"mappings":"+SAWA,IAAM,EACJ,6EAEF,SAAgB,EAAsB,EAA0B,CAC9D,IAAM,EAAQ,EAAS,MAAM,SAAS,CAAC,OAAO,QAAQ,CAChD,EAAW,EAAM,EAAM,OAAS,GAEtC,GAAI,CAAC,GAAY,IAAa,KAAO,IAAa,KAChD,MAAU,MAAM,oBAAoB,CAGtC,OAAO,EAuBT,eAAsB,EACpB,EACA,EAAwC,EAAE,CACzB,CACjB,OAAO,EAAA,+BAA+B,EAAY,EAAU,CAO9D,eAAsB,EACpB,EACA,EACA,EAAwC,EAAE,CACzB,CACjB,IAAM,EAAW,EAAsB,EAAS,CAEhD,MAAO,IAAG,MADgB,EAA6B,EAAY,EAAU,EACvD,QAAQ,UAAW,GAAG,CAAC,GAAG,IAsBlD,eAAsB,EACpB,EACA,EACiB,CACjB,GACE,GAAqB,KAAO,GAC5B,EAAoB,WAAW,aAAa,MAAM,CAElD,OAAO,EAAoB,UAAU,YAAY,MAAM,CAGzD,IAAM,EAAS,EAAA,8BAA8B,EAAe,CAW5D,OAVI,GAAQ,oBAAoB,MAAM,CAC7B,EAAO,mBAAmB,MAAM,CAGrC,EAAa,KAAK,EAAe,CAC5B,EAAA,QAA+B,8BACpC,EACD,CAGI,EAAA,0BAA0B"}
|
|
@@ -1,6 +1,48 @@
|
|
|
1
|
+
import { type AgentServerClientOverrides, getAgentServerClientOptions } from "#/api/agent-server-client-options";
|
|
1
2
|
import type { AppConversation } from "#/api/conversation-service/agent-server-conversation-service.types";
|
|
2
3
|
export declare function getSafeUploadFileName(fileName: string): string;
|
|
3
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated The old `prepend `/` if not already absolute` behaviour is the
|
|
6
|
+
* root cause of #XXXX (relative `workspace/project` → `/workspace/project`,
|
|
7
|
+
* which is on a read-only mount on macOS / fresh containers). Callers that
|
|
8
|
+
* need an actual absolute path must use {@link resolveAbsoluteWorkspacePath}
|
|
9
|
+
* so the relative leg is anchored against `/api/file/home` instead.
|
|
10
|
+
*
|
|
11
|
+
* Kept for the rare callers that genuinely just want a leading-slash
|
|
12
|
+
* normaliser on a value already known to be agent-server-rooted (e.g.
|
|
13
|
+
* cosmetic display, log strings).
|
|
14
|
+
*/
|
|
4
15
|
export declare function toAbsoluteWorkspacePath(path: string): string;
|
|
5
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Resolve `workingDir` to an absolute path the agent-server's file APIs
|
|
18
|
+
* accept. Relative paths are joined against `/api/file/home` (cached per
|
|
19
|
+
* backend); absolute paths pass through.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveAbsoluteWorkspacePath(workingDir: string, overrides?: AgentServerClientOverrides): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Build the absolute destination path for a file upload, resolving the
|
|
24
|
+
* working-dir leg via {@link resolveAbsoluteWorkspacePath}.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildWorkspaceUploadPath(fileName: string, workingDir: string, overrides?: AgentServerClientOverrides): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve the working directory for a file upload into a conversation's
|
|
29
|
+
* workspace.
|
|
30
|
+
*
|
|
31
|
+
* **Returns the raw working dir string** — which may be relative (e.g.
|
|
32
|
+
* `workspace/project/<hex>`) when the default `DEFAULT_WORKING_DIR` is in
|
|
33
|
+
* use. Callers that need an actual filesystem-absolute path (e.g. to pass to
|
|
34
|
+
* the agent-server's `/api/file/upload` endpoint) **must** funnel this result
|
|
35
|
+
* through {@link buildWorkspaceUploadPath}, which calls
|
|
36
|
+
* {@link resolveAbsoluteWorkspacePath} to anchor any relative segment against
|
|
37
|
+
* the agent-server's home directory.
|
|
38
|
+
*
|
|
39
|
+
* Why not resolve here? Because this function is also called by cloud-runtime
|
|
40
|
+
* upload paths where the overrides (conversationUrl, sessionApiKey) aren't
|
|
41
|
+
* available until {@link uploadFilesToConversation} assembles them. Keeping
|
|
42
|
+
* the resolution step in {@link buildWorkspaceUploadPath} means both the
|
|
43
|
+
* local and cloud legs share a single resolution point with the correct
|
|
44
|
+
* override context.
|
|
45
|
+
*/
|
|
6
46
|
export declare function resolveConversationUploadWorkingDir(conversationId: string, currentConversation?: AppConversation | null): Promise<string>;
|
|
47
|
+
export type { AgentServerClientOverrides };
|
|
48
|
+
export { getAgentServerClientOptions };
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import { getAgentServerWorkingDir as e } from "./agent-server-config.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import "./agent-server-client-options.js";
|
|
3
|
+
import { resolveAbsoluteAgentServerPath as t } from "./agent-server-home.js";
|
|
4
|
+
import { getStoredConversationMetadata as n } from "./conversation-metadata-store.js";
|
|
5
|
+
import r from "./conversation-service/agent-server-conversation-service.api.js";
|
|
4
6
|
//#region src/api/workspace-upload-path.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
+
var i = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
8
|
+
function a(e) {
|
|
7
9
|
let t = e.split(/[\\/]+/).filter(Boolean), n = t[t.length - 1];
|
|
8
10
|
if (!n || n === "." || n === "..") throw Error("Invalid file name");
|
|
9
11
|
return n;
|
|
10
12
|
}
|
|
11
|
-
function
|
|
12
|
-
return
|
|
13
|
+
async function o(e, n = {}) {
|
|
14
|
+
return t(e, n);
|
|
13
15
|
}
|
|
14
|
-
function
|
|
15
|
-
let
|
|
16
|
-
return `${
|
|
16
|
+
async function s(e, t, n = {}) {
|
|
17
|
+
let r = a(e);
|
|
18
|
+
return `${(await o(t, n)).replace(/[/\\]+$/, "")}/${r}`;
|
|
17
19
|
}
|
|
18
|
-
async function
|
|
19
|
-
if (a?.id ===
|
|
20
|
-
let o = t
|
|
21
|
-
return o?.selected_workspace?.trim() ? o.selected_workspace.trim() :
|
|
20
|
+
async function c(t, a) {
|
|
21
|
+
if (a?.id === t && a.workspace?.working_dir?.trim()) return a.workspace.working_dir.trim();
|
|
22
|
+
let o = n(t);
|
|
23
|
+
return o?.selected_workspace?.trim() ? o.selected_workspace.trim() : i.test(t) ? r.resolveConversationWorkingDir(t) : e();
|
|
22
24
|
}
|
|
23
25
|
//#endregion
|
|
24
|
-
export {
|
|
26
|
+
export { s as buildWorkspaceUploadPath, a as getSafeUploadFileName, c as resolveConversationUploadWorkingDir };
|
|
25
27
|
|
|
26
28
|
//# sourceMappingURL=workspace-upload-path.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-upload-path.js","names":[],"sources":["../../src/api/workspace-upload-path.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"workspace-upload-path.js","names":[],"sources":["../../src/api/workspace-upload-path.ts"],"sourcesContent":["// @spec WUP-001 — Resolve relative working dirs against /api/file/home\nimport AgentServerConversationService from \"#/api/conversation-service/agent-server-conversation-service.api\";\nimport { getAgentServerWorkingDir } from \"#/api/agent-server-config\";\nimport {\n type AgentServerClientOverrides,\n getAgentServerClientOptions,\n} from \"#/api/agent-server-client-options\";\nimport { resolveAbsoluteAgentServerPath } from \"#/api/agent-server-home\";\nimport { getStoredConversationMetadata } from \"#/api/conversation-metadata-store\";\nimport type { AppConversation } from \"#/api/conversation-service/agent-server-conversation-service.types\";\n\nconst UUID_PATTERN =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nexport function getSafeUploadFileName(fileName: string): string {\n const parts = fileName.split(/[\\\\/]+/).filter(Boolean);\n const safeName = parts[parts.length - 1];\n\n if (!safeName || safeName === \".\" || safeName === \"..\") {\n throw new Error(\"Invalid file name\");\n }\n\n return safeName;\n}\n\n/**\n * @deprecated The old `prepend `/` if not already absolute` behaviour is the\n * root cause of #XXXX (relative `workspace/project` → `/workspace/project`,\n * which is on a read-only mount on macOS / fresh containers). Callers that\n * need an actual absolute path must use {@link resolveAbsoluteWorkspacePath}\n * so the relative leg is anchored against `/api/file/home` instead.\n *\n * Kept for the rare callers that genuinely just want a leading-slash\n * normaliser on a value already known to be agent-server-rooted (e.g.\n * cosmetic display, log strings).\n */\nexport function toAbsoluteWorkspacePath(path: string): string {\n return path.startsWith(\"/\") ? path : `/${path}`;\n}\n\n/**\n * Resolve `workingDir` to an absolute path the agent-server's file APIs\n * accept. Relative paths are joined against `/api/file/home` (cached per\n * backend); absolute paths pass through.\n */\nexport async function resolveAbsoluteWorkspacePath(\n workingDir: string,\n overrides: AgentServerClientOverrides = {},\n): Promise<string> {\n return resolveAbsoluteAgentServerPath(workingDir, overrides);\n}\n\n/**\n * Build the absolute destination path for a file upload, resolving the\n * working-dir leg via {@link resolveAbsoluteWorkspacePath}.\n */\nexport async function buildWorkspaceUploadPath(\n fileName: string,\n workingDir: string,\n overrides: AgentServerClientOverrides = {},\n): Promise<string> {\n const safeName = getSafeUploadFileName(fileName);\n const absoluteDir = await resolveAbsoluteWorkspacePath(workingDir, overrides);\n return `${absoluteDir.replace(/[/\\\\]+$/, \"\")}/${safeName}`;\n}\n\n/**\n * Resolve the working directory for a file upload into a conversation's\n * workspace.\n *\n * **Returns the raw working dir string** — which may be relative (e.g.\n * `workspace/project/<hex>`) when the default `DEFAULT_WORKING_DIR` is in\n * use. Callers that need an actual filesystem-absolute path (e.g. to pass to\n * the agent-server's `/api/file/upload` endpoint) **must** funnel this result\n * through {@link buildWorkspaceUploadPath}, which calls\n * {@link resolveAbsoluteWorkspacePath} to anchor any relative segment against\n * the agent-server's home directory.\n *\n * Why not resolve here? Because this function is also called by cloud-runtime\n * upload paths where the overrides (conversationUrl, sessionApiKey) aren't\n * available until {@link uploadFilesToConversation} assembles them. Keeping\n * the resolution step in {@link buildWorkspaceUploadPath} means both the\n * local and cloud legs share a single resolution point with the correct\n * override context.\n */\nexport async function resolveConversationUploadWorkingDir(\n conversationId: string,\n currentConversation?: AppConversation | null,\n): Promise<string> {\n if (\n currentConversation?.id === conversationId &&\n currentConversation.workspace?.working_dir?.trim()\n ) {\n return currentConversation.workspace.working_dir.trim();\n }\n\n const stored = getStoredConversationMetadata(conversationId);\n if (stored?.selected_workspace?.trim()) {\n return stored.selected_workspace.trim();\n }\n\n if (UUID_PATTERN.test(conversationId)) {\n return AgentServerConversationService.resolveConversationWorkingDir(\n conversationId,\n );\n }\n\n return getAgentServerWorkingDir();\n}\n\n// Re-export so callers can construct overrides matching what\n// {@link buildWorkspaceUploadPath} expects without importing two modules.\nexport type { AgentServerClientOverrides };\nexport { getAgentServerClientOptions };\n"],"mappings":";;;;;;AAWA,IAAM,IACJ;AAEF,SAAgB,EAAsB,GAA0B;CAC9D,IAAM,IAAQ,EAAS,MAAM,SAAS,CAAC,OAAO,QAAQ,EAChD,IAAW,EAAM,EAAM,SAAS;AAEtC,KAAI,CAAC,KAAY,MAAa,OAAO,MAAa,KAChD,OAAU,MAAM,oBAAoB;AAGtC,QAAO;;AAuBT,eAAsB,EACpB,GACA,IAAwC,EAAE,EACzB;AACjB,QAAO,EAA+B,GAAY,EAAU;;AAO9D,eAAsB,EACpB,GACA,GACA,IAAwC,EAAE,EACzB;CACjB,IAAM,IAAW,EAAsB,EAAS;AAEhD,QAAO,IAAG,MADgB,EAA6B,GAAY,EAAU,EACvD,QAAQ,WAAW,GAAG,CAAC,GAAG;;AAsBlD,eAAsB,EACpB,GACA,GACiB;AACjB,KACE,GAAqB,OAAO,KAC5B,EAAoB,WAAW,aAAa,MAAM,CAElD,QAAO,EAAoB,UAAU,YAAY,MAAM;CAGzD,IAAM,IAAS,EAA8B,EAAe;AAW5D,QAVI,GAAQ,oBAAoB,MAAM,GAC7B,EAAO,mBAAmB,MAAM,GAGrC,EAAa,KAAK,EAAe,GAC5B,EAA+B,8BACpC,EACD,GAGI,GAA0B"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
interface RecommendedAutomationsLauncherProps {
|
|
2
2
|
query?: string;
|
|
3
3
|
onLaunched?: () => void;
|
|
4
|
+
/** When true, only the automation card grid scrolls inside its section. */
|
|
5
|
+
scrollableGrid?: boolean;
|
|
4
6
|
}
|
|
5
7
|
export declare function buildAutomationPrompt(basePrompt: string, backendKind: "local" | "cloud", backendHost?: string): string;
|
|
6
|
-
export declare function RecommendedAutomationsLauncher({ query, onLaunched, }: RecommendedAutomationsLauncherProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export declare function RecommendedAutomationsLauncher({ query, onLaunched, scrollableGrid, }: RecommendedAutomationsLauncherProps): import("react/jsx-runtime").JSX.Element | null;
|
|
7
9
|
export {};
|
|
@@ -5,7 +5,9 @@ interface RecommendedAutomationsSectionProps {
|
|
|
5
5
|
installedServers: MCPServerConfig[];
|
|
6
6
|
query?: string;
|
|
7
7
|
onSelect: (automation: RecommendedAutomation) => void;
|
|
8
|
+
/** When true, title, description, and cards share one scroll area. */
|
|
9
|
+
scrollableGrid?: boolean;
|
|
8
10
|
}
|
|
9
11
|
export declare function getAutomationsByPopularity(catalog: RecommendedAutomation[]): RecommendedAutomation[];
|
|
10
|
-
export declare function RecommendedAutomationsSection({ backendKind, installedServers, query, onSelect, }: RecommendedAutomationsSectionProps): import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
export declare function RecommendedAutomationsSection({ backendKind, installedServers, query, onSelect, scrollableGrid, }: RecommendedAutomationsSectionProps): import("react/jsx-runtime").JSX.Element | null;
|
|
11
13
|
export {};
|
|
@@ -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(`../../../contexts/active-backend-context.cjs`),o=require(`../../../node_modules/@openhands/typescript-client/dist/client/server-client.cjs`),s=require(`../../../node_modules/@tanstack/react-query/build/modern/useQuery.cjs`),c=require(`../../../api/agent-server-client-options.cjs`),l=require(`../../shared/modals/modal-backdrop.cjs`),u=require(`../../shared/modals/modal-body.cjs`),d=require(`../../../utils/modal-classes.cjs`),f=require(`../../shared/modals/modal-close-button.cjs`),p=require(`../settings/brand-button.cjs`),m=require(`../settings/settings-input.cjs`),h=require(`../../../hooks/query/use-backends-health.cjs`),g=require(`../../../assets/branding/openhands-logo-white.cjs`),_=require(`../../../icons/chevron-down-small.cjs`),v=require(`./backend-status-dot.cjs`),y=require(`./device-flow-auth.cjs`);let b=require(`react`);b=e.__toESM(b,1);let x=require(`react/jsx-runtime`);function S(e){let t=e.trim().toLowerCase();return t.includes(`all-hands.dev`)||t.includes(`openhands.dev`)?`cloud`:`local`}function C(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 w(e){let t=e.trim().replace(/\/+$/,``);if(!t)return``;if(/^https?:\/\//i.test(t))return t;let n=t.match(/^\[([^\]]+)\]/);return`${C(n?n[1]:(t.match(/:/g)??[]).length>1?t:t.split(`:`)[0])?`http`:`https`}://${t}`}function T(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=w(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 E=`https://app.all-hands.dev`;function D(e,t){return e(n.I18nKey.BACKEND$CONNECTION_TEST_FAILED,{host:t,interpolation:{escapeValue:!1}})}function O(e){return e instanceof Error?e.message:typeof e==`string`?e:null}function k(e,t){let n=O(t);return n?`${e}\n${n}`:e}async function A(e){e.kind===`local`&&await new o.ServerClient(c.getAgentServerClientOptions({host:e.host,sessionApiKey:e.apiKey||null,timeout:5e3})).getServerInfo()}function j({backend:e,testIdRoot:r}){let{t:i}=t.useTranslation(`openhands`),a=h.useBackendsHealth([e])[e.id],l=a?.isConnected??null,u=a?.disabled===!0,d=a?.consecutiveFailures??0,f=a?.lastError??null,{data:p}=s.useQuery({queryKey:[`backend-version`,e.host,e.apiKey],queryFn:async()=>(await new o.ServerClient(c.getAgentServerClientOptions({host:e.host,sessionApiKey:e.apiKey||null,timeout:5e3})).getServerInfo()).version??null,retry:!1,staleTime:6e4,enabled:e.kind===`local`&&!u}),m;m=i(l===!0?n.I18nKey.ONBOARDING$BACKEND_STATUS_CONNECTED:l===!1?n.I18nKey.ONBOARDING$BACKEND_STATUS_DISCONNECTED:n.I18nKey.ONBOARDING$BACKEND_STATUS_CHECKING);let g=e.kind===`cloud`?i(n.I18nKey.BACKEND$KIND_CLOUD):i(n.I18nKey.BACKEND$KIND_LOCAL);return(0,x.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,x.jsxs)(`div`,{"data-testid":`${r}-status`,className:`flex items-center gap-3 text-sm`,children:[(0,x.jsx)(v.BackendStatusDot,{isConnected:l}),(0,x.jsx)(`span`,{className:`text-white`,"data-testid":`${r}-status-label`,children:m}),(0,x.jsx)(`span`,{className:`text-tertiary-alt`,children:`·`}),(0,x.jsx)(`span`,{className:`text-[var(--oh-text-tertiary)]`,children:g}),p?(0,x.jsx)(`span`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`${r}-version`,children:i(n.I18nKey.BACKEND$VERSION_LABEL,{version:p})}):null]}),u?(0,x.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,x.jsx)(`span`,{className:`font-semibold text-red-300`,children:i(n.I18nKey.BACKEND$HEALTH_FAILED_TITLE)}),(0,x.jsx)(`span`,{className:`text-xs text-[var(--oh-text-tertiary)]`,children:i(n.I18nKey.BACKEND$HEALTH_FAILED_DETAIL,{count:d})}),f?(0,x.jsx)(`span`,{"data-testid":`${r}-status-error-message`,className:`text-xs text-red-300 whitespace-pre-wrap break-words`,children:f}):null]}):null]})}function M({mode:e,backend:r,onSubmitted:i,renderActions:o,testIdRoot:s,hostReadOnly:c,requireApiKey:l,onSubmitOverride:u}){let{t:d}=t.useTranslation(`openhands`),{addBackend:f,updateBackend:h}=a.useActiveBackendContext(),[g,_]=b.default.useState(r?.name??``),[v,y]=b.default.useState(r?.host??``),[C,O]=b.default.useState(r?.apiKey??``),[M,N]=b.default.useState(null),[P,F]=b.default.useState(!1),[I,L]=b.default.useState(!1),[R,z]=b.default.useState(!1),B=S(v),V=s??(e===`edit`?`edit-backend`:`add-backend`),H=l||B!==`local`,U=g.trim().length>0&&T(v)&&(!H||C.trim().length>0),W=I&&!g.trim()?d(n.I18nKey.BACKEND$NAME_REQUIRED):void 0,G=R?v.trim()?T(v)?void 0:d(n.I18nKey.BACKEND$HOST_INVALID):d(n.I18nKey.BACKEND$HOST_REQUIRED):void 0;return(0,x.jsxs)(`form`,{"data-testid":`${V}-form`,onSubmit:async t=>{if(t.preventDefault(),P)return;if(!U){L(!0),z(!0);return}let n={name:g.trim(),host:w(v),apiKey:C.trim(),kind:B};N(null),F(!0);try{if(u){await u(n);return}await A(n),e===`edit`&&r?h(r.id,n):f(n),i()}catch(e){N(k(D(d,n.host),e))}finally{F(!1)}},className:`flex flex-col gap-4`,children:[(0,x.jsx)(m.SettingsInput,{testId:`${V}-name`,name:`${V}-name`,type:`text`,label:d(n.I18nKey.BACKEND$NAME_LABEL),value:g,onChange:e=>{_(e),N(null)},onBlur:()=>L(!0),placeholder:`Production`,className:`w-full`,showRequiredTag:!0,error:W}),(0,x.jsx)(m.SettingsInput,{testId:`${V}-host`,name:`${V}-host`,type:`text`,label:d(n.I18nKey.BACKEND$HOST_LABEL),value:v,onChange:c?void 0:e=>{y(e),N(null)},onBlur:()=>z(!0),placeholder:E,className:`w-full`,showRequiredTag:!0,error:G,isDisabled:c}),(0,x.jsx)(m.SettingsInput,{testId:`${V}-api-key`,name:`${V}-api-key`,type:`password`,label:d(n.I18nKey.BACKEND$KEY_LABEL),value:C,onChange:e=>{O(e),N(null)},placeholder:``,className:`w-full`}),M?(0,x.jsx)(`div`,{role:`alert`,"data-testid":`${V}-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:M}):null,e===`edit`&&r&&(0,x.jsx)(j,{backend:r,testIdRoot:V}),o?o({canSubmit:U&&!P,isSubmitting:P,testIdRoot:V}):(0,x.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2 w-full`,children:[(0,x.jsx)(p.BrandButton,{type:`button`,variant:`secondary`,onClick:i,testId:`${V}-cancel`,children:d(n.I18nKey.BUTTON$CANCEL)}),(0,x.jsx)(p.BrandButton,{type:`submit`,variant:`primary`,isDisabled:!U||P,testId:`${V}-submit`,children:d(n.I18nKey.BACKEND$SAVE)})]})]})}function N(){let{currentPath:e,navigate:t}=i.useNavigation();return b.default.useCallback(()=>{/^\/automations\/[^/]+/.test(e)?t(`/automations`):/^\/conversations\/[^/]+/.test(e)&&t(`/conversations`)},[e,t])}function P({onClose:e}){let{t:r}=t.useTranslation(`openhands`),{addBackend:i}=a.useActiveBackendContext(),o=N(),[s,c]=b.default.useState(``),[l,u]=b.default.useState(``),[d,f]=b.default.useState(``),[h,g]=b.default.useState(null),[_,v]=b.default.useState(!1),y=S(l),C=s.trim().length>0&&T(l)&&(y===`local`||d.trim().length>0);return(0,x.jsxs)(`form`,{"data-testid":`add-backend-form`,onSubmit:async t=>{if(t.preventDefault(),!C||_)return;let n={name:s.trim(),host:w(l),apiKey:d.trim(),kind:y};g(null),v(!0);try{await A(n),i(n),o(),e()}catch(e){g(k(D(r,n.host),e))}finally{v(!1)}},className:`flex flex-col gap-4 flex-1 min-w-0`,children:[(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(m.SettingsInput,{testId:`add-backend-name`,name:`add-backend-name`,type:`text`,label:r(n.I18nKey.BACKEND$NAME_LABEL),value:s,onChange:e=>{c(e),g(null)},placeholder:`e.g. My Server`,className:`w-full`}),(0,x.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,children:r(n.I18nKey.BACKEND$NAME_HELPER)})]}),(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(m.SettingsInput,{testId:`add-backend-host`,name:`add-backend-host`,type:`text`,label:r(n.I18nKey.BACKEND$HOST_LABEL),value:l,onChange:e=>{u(e),g(null)},placeholder:`http://localhost:8000`,className:`w-full`}),(0,x.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`add-backend-host-helper`,children:r(n.I18nKey.BACKEND$HOST_HELPER)})]}),(0,x.jsx)(m.SettingsInput,{testId:`add-backend-api-key`,name:`add-backend-api-key`,type:`password`,label:r(n.I18nKey.BACKEND$KEY_LABEL),value:d,onChange:e=>{f(e),g(null)},placeholder:`sk-••••••••••`,className:`w-full`}),h?(0,x.jsx)(`div`,{role:`alert`,"data-testid":`add-backend-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:h}):null,(0,x.jsx)(p.BrandButton,{type:`submit`,variant:`secondary`,isDisabled:!C||_,testId:`add-backend-submit`,className:`w-full text-center`,children:r(_?n.I18nKey.ONBOARDING$BACKEND_STATUS_CHECKING:n.I18nKey.BACKEND$CONNECT)})]})}function F({onClose:e}){let{t:i}=t.useTranslation(`openhands`),{addBackend:o}=a.useActiveBackendContext(),s=N(),[c,l]=b.default.useState(!1),[u,f]=b.default.useState(``),p=u.trim()||E;return(0,x.jsxs)(`div`,{className:`flex flex-1 min-w-0 flex-col items-center gap-3`,children:[(0,x.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,x.jsx)(g.default,{width:56,height:56,"aria-hidden":!0}),(0,x.jsx)(`h4`,{className:d.modalTitleLgMediumClassName,"data-testid":`add-backend-cloud-title`,children:i(n.I18nKey.BACKEND$CLOUD_TITLE)})]}),(0,x.jsx)(`p`,{className:`text-center text-sm leading-relaxed text-[var(--oh-muted)]`,children:i(n.I18nKey.BACKEND$CLOUD_DESCRIPTION)}),(0,x.jsx)(y.DeviceFlowAuth,{host:p,onSuccess:t=>{o({name:`OpenHands Cloud`,host:w(p),apiKey:t,kind:`cloud`}),s(),e()},testIdRoot:`add-backend`}),(0,x.jsxs)(`div`,{className:`w-full`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,"data-testid":`add-backend-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,x.jsx)(`span`,{children:i(n.I18nKey.BACKEND$ADVANCED)}),(0,x.jsx)(_.default,{className:r.cn(`h-4 w-4 shrink-0 text-muted transition-transform`,c&&`rotate-180`),"aria-hidden":!0})]}),(0,x.jsxs)(`div`,{className:r.cn(`pt-2`,!c&&`pointer-events-none invisible`),"aria-hidden":!c,children:[(0,x.jsx)(m.SettingsInput,{testId:`add-backend-cloud-host`,name:`add-backend-cloud-host`,type:`text`,label:i(n.I18nKey.BACKEND$HOST_LABEL),value:u,onChange:f,placeholder:E,className:`w-full`}),(0,x.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oh-muted)]`,children:i(n.I18nKey.BACKEND$LOGIN_CLOUD_HINT)})]})]})]})}function I({mode:e,backend:i,onClose:a}){let{t:o}=t.useTranslation(`openhands`);if(e===`add`)return(0,x.jsx)(l.ModalBackdrop,{onClose:a,closeOnEscape:!1,"aria-label":o(n.I18nKey.BACKEND$ADD_TITLE),children:(0,x.jsxs)(`div`,{"data-testid":`add-backend-modal`,className:r.cn(`relative rounded-xl border border-[var(--oh-border)] bg-base-secondary`,u.modalWidthClassName(`xl`),u.MODAL_MAX_WIDTH_VIEWPORT),children:[(0,x.jsx)(f.ModalCloseButton,{onClose:a,testId:`add-backend-close`}),(0,x.jsx)(`div`,{className:`px-6 pt-6 pb-2 pr-12`,children:(0,x.jsx)(`h2`,{className:d.modalTitleLgClassName,children:o(n.I18nKey.BACKEND$ADD_TITLE)})}),(0,x.jsxs)(`div`,{className:`flex gap-6 px-6 pb-6 pt-2`,children:[(0,x.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,x.jsx)(P,{onClose:a})}),(0,x.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center`,children:[(0,x.jsx)(`div`,{className:`flex-1 w-px bg-[var(--oh-border)]`}),(0,x.jsx)(`span`,{className:`py-3 text-xs uppercase text-[var(--oh-muted)]`,children:o(n.I18nKey.BACKEND$LOGIN_OR)}),(0,x.jsx)(`div`,{className:`flex-1 w-px bg-[var(--oh-border)]`})]}),(0,x.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,x.jsx)(F,{onClose:a})})]})]})});let s=`edit-backend`;return(0,x.jsx)(l.ModalBackdrop,{onClose:a,closeOnEscape:!1,"aria-label":o(n.I18nKey.BACKEND$EDIT_TITLE),children:(0,x.jsxs)(`div`,{"data-testid":`${s}-modal`,className:r.cn(`relative bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]`,u.modalWidthClassName(`md`)),children:[(0,x.jsx)(f.ModalCloseButton,{onClose:a,testId:`${s}-close`}),(0,x.jsx)(`h2`,{className:r.cn(`pr-6`,d.modalTitleLgClassName),children:o(n.I18nKey.BACKEND$EDIT_TITLE)}),(0,x.jsx)(M,{mode:`edit`,backend:i,onSubmitted:a,testIdRoot:s})]})})}exports.BackendFormModal=I;
|
|
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(`../../../contexts/active-backend-context.cjs`),o=require(`../../../node_modules/@openhands/typescript-client/dist/client/server-client.cjs`),s=require(`../../../node_modules/@tanstack/react-query/build/modern/useQuery.cjs`),c=require(`../../../api/agent-server-client-options.cjs`),l=require(`../../shared/modals/modal-backdrop.cjs`),u=require(`../../shared/modals/modal-body.cjs`),d=require(`../../../utils/modal-classes.cjs`),f=require(`../../shared/modals/modal-close-button.cjs`),p=require(`../settings/brand-button.cjs`),m=require(`../settings/settings-input.cjs`),h=require(`../../../hooks/query/use-backends-health.cjs`),g=require(`../../../assets/branding/openhands-logo-white.cjs`),_=require(`../../../icons/chevron-down-small.cjs`),v=require(`./backend-status-dot.cjs`),y=require(`./device-flow-auth.cjs`);let b=require(`react`);b=e.__toESM(b,1);let x=require(`react/jsx-runtime`);function S(e){let t=e.trim().toLowerCase();return t.includes(`all-hands.dev`)||t.includes(`openhands.dev`)?`cloud`:`local`}function C(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 w(e){let t=e.trim().replace(/\/+$/,``);if(!t)return``;if(/^https?:\/\//i.test(t))return t;let n=t.match(/^\[([^\]]+)\]/);return`${C(n?n[1]:(t.match(/:/g)??[]).length>1?t:t.split(`:`)[0])?`http`:`https`}://${t}`}function T(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=w(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 E=`https://app.all-hands.dev`;function D(e,t){return e(n.I18nKey.BACKEND$CONNECTION_TEST_FAILED,{host:t,interpolation:{escapeValue:!1}})}function O(e){return e instanceof Error?e.message:typeof e==`string`?e:null}function k(e,t){let n=O(t);return n?`${e}\n${n}`:e}async function A(e){e.kind===`local`&&await new o.ServerClient(c.getAgentServerClientOptions({host:e.host,sessionApiKey:e.apiKey||null,timeout:5e3})).getServerInfo()}function j({backend:e,testIdRoot:r}){let{t:i}=t.useTranslation(`openhands`),a=h.useBackendsHealth([e])[e.id],l=a?.isConnected??null,u=a?.disabled===!0,d=a?.consecutiveFailures??0,f=a?.lastError??null,{data:p}=s.useQuery({queryKey:[`backend-version`,e.host,e.apiKey],queryFn:async()=>(await new o.ServerClient(c.getAgentServerClientOptions({host:e.host,sessionApiKey:e.apiKey||null,timeout:5e3})).getServerInfo()).version??null,retry:!1,staleTime:6e4,enabled:e.kind===`local`&&!u}),m;m=i(l===!0?n.I18nKey.ONBOARDING$BACKEND_STATUS_CONNECTED:l===!1?n.I18nKey.ONBOARDING$BACKEND_STATUS_DISCONNECTED:n.I18nKey.ONBOARDING$BACKEND_STATUS_CHECKING);let g=e.kind===`cloud`?i(n.I18nKey.BACKEND$KIND_CLOUD):i(n.I18nKey.BACKEND$KIND_LOCAL);return(0,x.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,x.jsxs)(`div`,{"data-testid":`${r}-status`,className:`flex items-center gap-3 text-sm`,children:[(0,x.jsx)(v.BackendStatusDot,{isConnected:l}),(0,x.jsx)(`span`,{className:`text-white`,"data-testid":`${r}-status-label`,children:m}),(0,x.jsx)(`span`,{className:`text-tertiary-alt`,children:`·`}),(0,x.jsx)(`span`,{className:`text-[var(--oh-text-tertiary)]`,children:g}),p?(0,x.jsx)(`span`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`${r}-version`,children:i(n.I18nKey.BACKEND$VERSION_LABEL,{version:p})}):null]}),u?(0,x.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,x.jsx)(`span`,{className:`font-semibold text-red-300`,children:i(n.I18nKey.BACKEND$HEALTH_FAILED_TITLE)}),(0,x.jsx)(`span`,{className:`text-xs text-[var(--oh-text-tertiary)]`,children:i(n.I18nKey.BACKEND$HEALTH_FAILED_DETAIL,{count:d})}),f?(0,x.jsx)(`span`,{"data-testid":`${r}-status-error-message`,className:`text-xs text-red-300 whitespace-pre-wrap break-words`,children:f}):null]}):null]})}function M({mode:e,backend:i,onSubmitted:o,renderActions:s,testIdRoot:c,hostReadOnly:l,requireApiKey:u,hideConfigurationFields:d=!1,onSubmitOverride:f}){let{t:h}=t.useTranslation(`openhands`),{addBackend:g,updateBackend:_}=a.useActiveBackendContext(),[v,y]=b.default.useState(i?.name??``),[C,O]=b.default.useState(i?.host??``),[M,N]=b.default.useState(i?.apiKey??``),[P,F]=b.default.useState(null),[I,L]=b.default.useState(!1),[R,z]=b.default.useState(!1),[B,V]=b.default.useState(!1),H=S(C),U=c??(e===`edit`?`edit-backend`:`add-backend`),W=u||H!==`local`,G=v.trim().length>0&&T(C)&&(!W||M.trim().length>0),K=R&&!v.trim()?h(n.I18nKey.BACKEND$NAME_REQUIRED):void 0,q=B?C.trim()?T(C)?void 0:h(n.I18nKey.BACKEND$HOST_INVALID):h(n.I18nKey.BACKEND$HOST_REQUIRED):void 0;return(0,x.jsxs)(`form`,{"data-testid":`${U}-form`,onSubmit:async t=>{if(t.preventDefault(),I)return;if(!G){z(!0),V(!0);return}let n={name:v.trim(),host:w(C),apiKey:M.trim(),kind:H};F(null),L(!0);try{if(f){await f(n);return}await A(n),e===`edit`&&i?_(i.id,n):g(n),o()}catch(e){F(k(D(h,n.host),e))}finally{L(!1)}},className:`flex flex-col gap-4`,children:[(0,x.jsxs)(`div`,{"data-testid":`${U}-configuration-fields`,className:r.cn(`flex flex-col gap-4`,d&&`hidden`),children:[(0,x.jsx)(m.SettingsInput,{testId:`${U}-name`,name:`${U}-name`,type:`text`,label:h(n.I18nKey.BACKEND$NAME_LABEL),value:v,onChange:e=>{y(e),F(null)},onBlur:()=>z(!0),placeholder:`Production`,className:`w-full`,showRequiredTag:!0,error:K}),(0,x.jsx)(m.SettingsInput,{testId:`${U}-host`,name:`${U}-host`,type:`text`,label:h(n.I18nKey.BACKEND$HOST_LABEL),value:C,onChange:l?void 0:e=>{O(e),F(null)},onBlur:()=>V(!0),placeholder:E,className:`w-full`,showRequiredTag:!0,error:q,isDisabled:l}),(0,x.jsx)(m.SettingsInput,{testId:`${U}-api-key`,name:`${U}-api-key`,type:`password`,label:h(n.I18nKey.BACKEND$KEY_LABEL),value:M,onChange:e=>{N(e),F(null)},placeholder:``,className:`w-full`}),P?(0,x.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:P}):null,e===`edit`&&i&&(0,x.jsx)(j,{backend:i,testIdRoot:U})]}),s?s({canSubmit:G&&!I,isSubmitting:I,testIdRoot:U}):(0,x.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2 w-full`,children:[(0,x.jsx)(p.BrandButton,{type:`button`,variant:`secondary`,onClick:o,testId:`${U}-cancel`,children:h(n.I18nKey.BUTTON$CANCEL)}),(0,x.jsx)(p.BrandButton,{type:`submit`,variant:`primary`,isDisabled:!G||I,testId:`${U}-submit`,children:h(n.I18nKey.BACKEND$SAVE)})]})]})}function N(){let{currentPath:e,navigate:t}=i.useNavigation();return b.default.useCallback(()=>{/^\/automations\/[^/]+/.test(e)?t(`/automations`):/^\/conversations\/[^/]+/.test(e)&&t(`/conversations`)},[e,t])}function P({onClose:e}){let{t:r}=t.useTranslation(`openhands`),{addBackend:i}=a.useActiveBackendContext(),o=N(),[s,c]=b.default.useState(``),[l,u]=b.default.useState(``),[d,f]=b.default.useState(``),[h,g]=b.default.useState(null),[_,v]=b.default.useState(!1),y=S(l),C=s.trim().length>0&&T(l)&&(y===`local`||d.trim().length>0);return(0,x.jsxs)(`form`,{"data-testid":`add-backend-form`,onSubmit:async t=>{if(t.preventDefault(),!C||_)return;let n={name:s.trim(),host:w(l),apiKey:d.trim(),kind:y};g(null),v(!0);try{await A(n),i(n),o(),e()}catch(e){g(k(D(r,n.host),e))}finally{v(!1)}},className:`flex flex-col gap-4 flex-1 min-w-0`,children:[(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(m.SettingsInput,{testId:`add-backend-name`,name:`add-backend-name`,type:`text`,label:r(n.I18nKey.BACKEND$NAME_LABEL),value:s,onChange:e=>{c(e),g(null)},placeholder:`e.g. My Server`,className:`w-full`}),(0,x.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,children:r(n.I18nKey.BACKEND$NAME_HELPER)})]}),(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(m.SettingsInput,{testId:`add-backend-host`,name:`add-backend-host`,type:`text`,label:r(n.I18nKey.BACKEND$HOST_LABEL),value:l,onChange:e=>{u(e),g(null)},placeholder:`http://localhost:8000`,className:`w-full`}),(0,x.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`add-backend-host-helper`,children:r(n.I18nKey.BACKEND$HOST_HELPER)})]}),(0,x.jsx)(m.SettingsInput,{testId:`add-backend-api-key`,name:`add-backend-api-key`,type:`password`,label:r(n.I18nKey.BACKEND$KEY_LABEL),value:d,onChange:e=>{f(e),g(null)},placeholder:`sk-••••••••••`,className:`w-full`}),h?(0,x.jsx)(`div`,{role:`alert`,"data-testid":`add-backend-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:h}):null,(0,x.jsx)(p.BrandButton,{type:`submit`,variant:`secondary`,isDisabled:!C||_,testId:`add-backend-submit`,className:`w-full text-center`,children:r(_?n.I18nKey.ONBOARDING$BACKEND_STATUS_CHECKING:n.I18nKey.BACKEND$CONNECT)})]})}function F({onClose:e}){let{t:i}=t.useTranslation(`openhands`),{addBackend:o}=a.useActiveBackendContext(),s=N(),[c,l]=b.default.useState(!1),[u,f]=b.default.useState(``),p=u.trim()||E;return(0,x.jsxs)(`div`,{className:`flex flex-1 min-w-0 flex-col items-center gap-3`,children:[(0,x.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,x.jsx)(g.default,{width:56,height:56,"aria-hidden":!0}),(0,x.jsx)(`h4`,{className:d.modalTitleLgMediumClassName,"data-testid":`add-backend-cloud-title`,children:i(n.I18nKey.BACKEND$CLOUD_TITLE)})]}),(0,x.jsx)(`p`,{className:`text-center text-sm leading-relaxed text-[var(--oh-muted)]`,children:i(n.I18nKey.BACKEND$CLOUD_DESCRIPTION)}),(0,x.jsx)(y.DeviceFlowAuth,{host:p,onSuccess:t=>{o({name:`OpenHands Cloud`,host:w(p),apiKey:t,kind:`cloud`}),s(),e()},testIdRoot:`add-backend`}),(0,x.jsxs)(`div`,{className:`w-full`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,"data-testid":`add-backend-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,x.jsx)(`span`,{children:i(n.I18nKey.BACKEND$ADVANCED)}),(0,x.jsx)(_.default,{className:r.cn(`h-4 w-4 shrink-0 text-muted transition-transform`,c&&`rotate-180`),"aria-hidden":!0})]}),(0,x.jsxs)(`div`,{className:r.cn(`pt-2`,!c&&`pointer-events-none invisible`),"aria-hidden":!c,children:[(0,x.jsx)(m.SettingsInput,{testId:`add-backend-cloud-host`,name:`add-backend-cloud-host`,type:`text`,label:i(n.I18nKey.BACKEND$HOST_LABEL),value:u,onChange:f,placeholder:E,className:`w-full`}),(0,x.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oh-muted)]`,children:i(n.I18nKey.BACKEND$LOGIN_CLOUD_HINT)})]})]})]})}function I({mode:e,backend:i,onClose:a}){let{t:o}=t.useTranslation(`openhands`);if(e===`add`)return(0,x.jsx)(l.ModalBackdrop,{onClose:a,closeOnEscape:!1,"aria-label":o(n.I18nKey.BACKEND$ADD_TITLE),children:(0,x.jsxs)(`div`,{"data-testid":`add-backend-modal`,className:r.cn(`relative rounded-xl border border-[var(--oh-border)] bg-base-secondary`,u.modalWidthClassName(`xl`),u.MODAL_MAX_WIDTH_VIEWPORT),children:[(0,x.jsx)(f.ModalCloseButton,{onClose:a,testId:`add-backend-close`}),(0,x.jsx)(`div`,{className:`px-6 pt-6 pb-2 pr-12`,children:(0,x.jsx)(`h2`,{className:d.modalTitleLgClassName,children:o(n.I18nKey.BACKEND$ADD_TITLE)})}),(0,x.jsxs)(`div`,{className:`flex gap-6 px-6 pb-6 pt-2`,children:[(0,x.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,x.jsx)(P,{onClose:a})}),(0,x.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center`,children:[(0,x.jsx)(`div`,{className:`flex-1 w-px bg-[var(--oh-border)]`}),(0,x.jsx)(`span`,{className:`py-3 text-xs uppercase text-[var(--oh-muted)]`,children:o(n.I18nKey.BACKEND$LOGIN_OR)}),(0,x.jsx)(`div`,{className:`flex-1 w-px bg-[var(--oh-border)]`})]}),(0,x.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,x.jsx)(F,{onClose:a})})]})]})});let s=`edit-backend`;return(0,x.jsx)(l.ModalBackdrop,{onClose:a,closeOnEscape:!1,"aria-label":o(n.I18nKey.BACKEND$EDIT_TITLE),children:(0,x.jsxs)(`div`,{"data-testid":`${s}-modal`,className:r.cn(`relative bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]`,u.modalWidthClassName(`md`)),children:[(0,x.jsx)(f.ModalCloseButton,{onClose:a,testId:`${s}-close`}),(0,x.jsx)(`h2`,{className:r.cn(`pr-6`,d.modalTitleLgClassName),children:o(n.I18nKey.BACKEND$EDIT_TITLE)}),(0,x.jsx)(M,{mode:`edit`,backend:i,onSubmitted:a,testIdRoot:s})]})})}exports.BackendFormModal=I;
|
|
2
2
|
//# sourceMappingURL=backend-form-modal.cjs.map
|