@openhands/agent-canvas 1.5.2 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (711) hide show
  1. package/README.md +1 -1
  2. package/README.windows.md +2 -2
  3. package/build/assets/{Trans-DqF_OEZB.js → Trans-52HCczKK.js} +1 -1
  4. package/build/assets/{acp-providers-DerAmTyY.js → acp-providers-xACMK9ZP.js} +1 -1
  5. package/build/assets/{active-backend-context-DHhm10VS.js → active-backend-context-Cd1qcZsb.js} +1 -1
  6. package/build/assets/{add-backend-modal-BoMkMyLB.js → add-backend-modal-5chsfln3.js} +1 -1
  7. package/build/assets/{agent-profiles-settings-CYPloKYK.js → agent-profiles-settings-BWK4H3kR.js} +1 -1
  8. package/build/assets/agent-server-compatibility-DMY0CihN.js +1 -0
  9. package/build/assets/agent-server-conversation-service.api-CI5-xmIX.js +41 -0
  10. package/build/assets/agent-settings-CMd8-O4f.js +2 -0
  11. package/build/assets/agent-settings-CdrhQJXX.js +1 -0
  12. package/build/assets/{alert-banner-Dh51WURQ.js → alert-banner-CLfWuIAX.js} +1 -1
  13. package/build/assets/api-key-entry-screen-Cc3aC7DZ.js +1 -0
  14. package/build/assets/app-settings-B-DQcBoB.js +1 -0
  15. package/build/assets/{automation-detail-Bn8q0AG3.js → automation-detail-BgxBIpyK.js} +2 -2
  16. package/build/assets/automation-export-Dbur8OHa.js +2 -0
  17. package/build/assets/automations-list-BWfjizlp.js +1 -0
  18. package/build/assets/{back-nav-button-DVknCcSP.js → back-nav-button-CaKvsD1E.js} +1 -1
  19. package/build/assets/backend-form-modal-YcfpuBZo.js +1 -0
  20. package/build/assets/{backend-synced-settings-badge-yVh6Kf4E.js → backend-synced-settings-badge-BellMmgC.js} +1 -1
  21. package/build/assets/{base-modal-CIF_785P.js → base-modal-Cw7enAHz.js} +1 -1
  22. package/build/assets/{brand-button-B1izLAdR.js → brand-button-BulEFHr3.js} +1 -1
  23. package/build/assets/{browser-DKaeq_sT.js → browser-DfVgUREb.js} +2 -2
  24. package/build/assets/browser-store-CBqI3tNR.js +1 -0
  25. package/build/assets/{browser-tab-qb_ftCxW.js → browser-tab-CmIKQB7S.js} +1 -1
  26. package/build/assets/chat-send-button-BchSSwuD.js +1 -0
  27. package/build/assets/circle-check-BXbQ5nEH.js +1 -0
  28. package/build/assets/{circle-plus-check-toggle-DoFIjVE0.js → circle-plus-check-toggle-BhpPjkh9.js} +1 -1
  29. package/build/assets/client-source-DAUgyJsi.js +1 -0
  30. package/build/assets/cloud-funnel-analytics-B5OeWh4y.js +1 -0
  31. package/build/assets/{color-themes-CHizm1xF.js → color-themes-QKMSVfDU.js} +1 -1
  32. package/build/assets/{combobox-caret-CxZpqoSR.js → combobox-caret-kNZtp53R.js} +1 -1
  33. package/build/assets/{command-menu-oTvKDU3Y.js → command-menu-tUsn23zy.js} +1 -1
  34. package/build/assets/{command-store-D8J5LMW1.js → command-store-B0hrIWMN.js} +1 -1
  35. package/build/assets/{condenser-settings-Q1rHh4Qe.js → condenser-settings-BBizzfIH.js} +1 -1
  36. package/build/assets/{confirmation-modal-DGBWM2Ls.js → confirmation-modal-108xng7X.js} +1 -1
  37. package/build/assets/{context-menu-list-item-6psNyl7X.js → context-menu-list-item-BbKfFuN1.js} +1 -1
  38. package/build/assets/conversation-CTzSrLMq.js +1 -0
  39. package/build/assets/conversation-CgcXNb-Z.js +90 -0
  40. package/build/assets/conversation-panel-bscjGQda.js +1 -0
  41. package/build/assets/{conversation-service.api-D8QU-BiL.js → conversation-service.api-DbBvscJA.js} +1 -1
  42. package/build/assets/conversation-state-store-C5GagZHT.js +1 -0
  43. package/build/assets/{conversation-store-LptbOvKa.js → conversation-store-CyVqoa0d.js} +1 -1
  44. package/build/assets/{conversation-tab-empty-state-CNUmIms2.js → conversation-tab-empty-state-2KYlk5Bh.js} +1 -1
  45. package/build/assets/{copy-to-clipboard-button-CFzH_NOX.js → copy-to-clipboard-button-C54YRPMg.js} +1 -1
  46. package/build/assets/declaration-_yumYLEx.js +1 -0
  47. package/build/assets/{device-verify-WBSjJBLH.js → device-verify-D6FW_KZq.js} +1 -1
  48. package/build/assets/{dropdown-classes-D3wMJlXT.js → dropdown-classes-9uONlOg1.js} +1 -1
  49. package/build/assets/{ellipsis-button-CbNnHlIq.js → ellipsis-button-CoaUrKmQ.js} +1 -1
  50. package/build/assets/{entry.client-Dnnak-Hq.js → entry.client-BJSVzw7V.js} +2 -2
  51. package/build/assets/{enum-filter-dropdown-JLYv1t8L.js → enum-filter-dropdown-qQzyjk_q.js} +1 -1
  52. package/build/assets/{environment-switch-overlay-B1PFO8P8.js → environment-switch-overlay-XRWCClLu.js} +1 -1
  53. package/build/assets/extensions-hub-DUp9sWQY.js +1 -0
  54. package/build/assets/extensions-navigation-DmkftjAx.js +1 -0
  55. package/build/assets/file-tUAzhmJ3.js +1 -0
  56. package/build/assets/files-tab-GV5hwiIM.js +1 -0
  57. package/build/assets/files-tab-store-DehyITNC.js +1 -0
  58. package/build/assets/{form-control-classes-CbdN5aO3.js → form-control-classes-BPUnoYyg.js} +1 -1
  59. package/build/assets/git-provider-icon-DDkru3b_.js +1 -0
  60. package/build/assets/highlighted-source-view-CYkPZUxr.js +1 -0
  61. package/build/assets/home-C53WekZ2.js +1 -0
  62. package/build/assets/home-EAwq8ah2.js +1 -0
  63. package/build/assets/index-home-kBdZGKtu.js +1 -0
  64. package/build/assets/install-server-modal-DYk4VP3-.js +1 -0
  65. package/build/assets/{launch-DlXspDku.js → launch-CIecOy_y.js} +1 -1
  66. package/build/assets/lesson-plan-BSEUwflx.js +4 -0
  67. package/build/assets/llm-not-configured-banner-C8uv1PHT.js +27 -0
  68. package/build/assets/llm-settings-0Bb97NCk.js +1 -0
  69. package/build/assets/llm-settings-D4toJ90k.js +1 -0
  70. package/build/assets/{llm-subscription-service-C0zN0-rH.js → llm-subscription-service-BPRw3u3H.js} +1 -1
  71. package/build/assets/{loading-spinner-BcdnT0mN.js → loading-spinner-BCInDEXB.js} +1 -1
  72. package/build/assets/manage-backends-modal-Bon32JYr.js +1 -0
  73. package/build/assets/manifest-ec000ae3.js +1 -0
  74. package/build/assets/markdown-renderer-BlaJOAI2.js +2 -0
  75. package/build/assets/mcp-CFIpOkn2.js +9 -0
  76. package/build/assets/messages-eRPeR4pW.js +40 -0
  77. package/build/assets/{modal-body-Cc2zp0xb.js → modal-body-Bg9UCeoV.js} +1 -1
  78. package/build/assets/{modal-classes-3qT9Ap7Q.js → modal-classes-H1KbJkeC.js} +1 -1
  79. package/build/assets/{modal-close-button-BcIBUdSq.js → modal-close-button-BMLYvo0C.js} +1 -1
  80. package/build/assets/{model-selector-D51W2Q9b.js → model-selector-BqX2RvEr.js} +1 -1
  81. package/build/assets/{navigation-link-D8hfwvxI.js → navigation-link-DoJzTCEz.js} +1 -1
  82. package/build/assets/onboarding-3KO4qE6R.js +1 -0
  83. package/build/assets/onboarding-modal-D4vqkJeT.js +1 -0
  84. package/build/assets/{organization-service.api-Da2jiuBS.js → organization-service.api-CvfQugOt.js} +1 -1
  85. package/build/assets/{path-utils-D53ZHUQU.js → path-utils-DRgexxnX.js} +1 -1
  86. package/build/assets/{plan-components-BdZXPyZU.js → plan-components-qkMiGs_-.js} +1 -1
  87. package/build/assets/{planner-tab-BM-pKx0z.js → planner-tab-ZrjiirRr.js} +1 -1
  88. package/build/assets/{plugins-management-service-DISfOL13.js → plugins-management-service-9qT-r_37.js} +1 -1
  89. package/build/assets/plus-CzE1b-wl.js +1 -0
  90. package/build/assets/{profiles-service.api-DWetW2TL.js → profiles-service.api-CRVlrQpT.js} +1 -1
  91. package/build/assets/{providers-C7lMslCi.js → providers-C2DFGBrf.js} +1 -1
  92. package/build/assets/{proxy-G4ce0fnQ.js → proxy-DnnDqkwn.js} +1 -1
  93. package/build/assets/puzzle-IHQnD54C.js +1 -0
  94. package/build/assets/recommended-automations-launcher-B97vgHuN.js +58 -0
  95. package/build/assets/refresh-cw-DxbAs3SK.js +1 -0
  96. package/build/assets/root-BbONavTg.css +1 -0
  97. package/build/assets/root-D01rpqZU.js +2 -0
  98. package/build/assets/root-layout-BiHbCIkS.js +2 -0
  99. package/build/assets/{runtime-waiting-state-CnyVhX4T.js → runtime-waiting-state-CbUV9txX.js} +1 -1
  100. package/build/assets/{schema-field-CwdqUOnE.js → schema-field-B9-9Ta9u.js} +1 -1
  101. package/build/assets/sdk-section-page-DG1s25Pr.js +1 -0
  102. package/build/assets/{sdk-settings-schema-CLR01YIK.js → sdk-settings-schema-B42JFr5Y.js} +1 -1
  103. package/build/assets/{secrets-service-Ch7RH8eH.js → secrets-service-DvyS6-mV.js} +1 -1
  104. package/build/assets/secrets-settings-CeSq6cQw.js +1 -0
  105. package/build/assets/{segmented-toggle-kzwZkLaj.js → segmented-toggle-DRVJBNy0.js} +1 -1
  106. package/build/assets/settings-Dzo0dJKM.js +1 -0
  107. package/build/assets/{settings-mQUckT0g.js → settings-HcwfqMjJ.js} +1 -1
  108. package/build/assets/{settings-dropdown-input-Dhx9ErGd.js → settings-dropdown-input-B6RL_mt0.js} +1 -1
  109. package/build/assets/settings-index-uAKHyijw.js +1 -0
  110. package/build/assets/{settings-input-BsgQWS5R.js → settings-input-ZoaAPNQh.js} +1 -1
  111. package/build/assets/{settings-list-classes-DSJJX99U.js → settings-list-classes-Dr8LgITi.js} +1 -1
  112. package/build/assets/settings-modal-BVX2G_IT.js +1 -0
  113. package/build/assets/{settings-service.api-DPTFyRXL.js → settings-service.api-BY7ncxIz.js} +1 -1
  114. package/build/assets/{settings-switch-Bes8dIlV.js → settings-switch-DUlGnP0B.js} +1 -1
  115. package/build/assets/{settings-utils-DzCVfiR3.js → settings-utils-kWEEvcdv.js} +1 -1
  116. package/build/assets/shared-conversation-CV4Rtdz2.js +1 -0
  117. package/build/assets/{sidebar-layout-Bm7pa3Vk.js → sidebar-layout-BhGooCga.js} +1 -1
  118. package/build/assets/sidebar-mobile-menu-toggle-BntOJphE.js +1 -0
  119. package/build/assets/{sidebar-nav-link-CHqyFXwV.js → sidebar-nav-link-DkA1XWV8.js} +1 -1
  120. package/build/assets/{sidebar-store-uiUXBU1N.js → sidebar-store-CF3b12-m.js} +1 -1
  121. package/build/assets/{skill-card-pill-row-BPYKQ3IN.js → skill-card-pill-row-_gWe1Tws.js} +1 -1
  122. package/build/assets/skill-icon-badge-C-zbaXbD.js +1 -0
  123. package/build/assets/skills-plugins-BwoXKtrR.js +1 -0
  124. package/build/assets/skills-settings-Crq-fZSt.js +2 -0
  125. package/build/assets/{styled-tooltip-B14i_Uac.js → styled-tooltip-CdnCJ67u.js} +1 -1
  126. package/build/assets/syntax-highlighter-CZK2ab-O.js +1 -0
  127. package/build/assets/{task-list-tab-DyfgG4MC.js → task-list-tab-CONOO9iI.js} +1 -1
  128. package/build/assets/telemetry-CC32dJYW.js +2 -0
  129. package/build/assets/{terminal-BDTa1HEr.js → terminal-CTkDpIU-.js} +1 -1
  130. package/build/assets/{toggle-switch-DX_k418f.js → toggle-switch-yVIzmJLM.js} +1 -1
  131. package/build/assets/{typography-CzfoD9DY.js → typography-BBVEW0un.js} +1 -1
  132. package/build/assets/{use-acp-credential-form-DHd_Id-q.js → use-acp-credential-form-CIsp8hJe.js} +1 -1
  133. package/build/assets/use-activate-agent-profile-BfcTTJJG.js +1 -0
  134. package/build/assets/{use-active-agent-profile-BMDTXsay.js → use-active-agent-profile-CCeFtmk9.js} +1 -1
  135. package/build/assets/{use-active-conversation-BbeVgedA.js → use-active-conversation-Badxj8w4.js} +1 -1
  136. package/build/assets/{use-agent-profiles-Dn_S_Tkz.js → use-agent-profiles-BSWVN6hH.js} +1 -1
  137. package/build/assets/{use-agent-state-5qM3X30V.js → use-agent-state-BzRrhoPd.js} +1 -1
  138. package/build/assets/use-backends-health-BsZikyFW.js +1 -0
  139. package/build/assets/{use-can-manage-org-profiles-CyYqfzeo.js → use-can-manage-org-profiles-Do6mYf6P.js} +1 -1
  140. package/build/assets/{use-cloud-current-user-id-BwMX7jHW.js → use-cloud-current-user-id-Cx3B_0-w.js} +1 -1
  141. package/build/assets/use-config-D9zUVw5b.js +1 -0
  142. package/build/assets/{use-create-conversation-CkKUQVbP.js → use-create-conversation-vvl0kvu7.js} +1 -1
  143. package/build/assets/{use-create-secret-DEgM0MXZ.js → use-create-secret-CB7Dvd4s.js} +1 -1
  144. package/build/assets/use-event-store-BlpSUF7N.js +4 -0
  145. package/build/assets/{use-handle-plan-click-BFcE0Xms.js → use-handle-plan-click-DDZkew9p.js} +1 -1
  146. package/build/assets/use-is-creating-conversation-fxSzN778.js +1 -0
  147. package/build/assets/{use-launch-skill-in-chat-DJWEfVc5.js → use-launch-skill-in-chat-D6_n1fs3.js} +1 -1
  148. package/build/assets/use-llm-profiles-CNQm7HYS.js +1 -0
  149. package/build/assets/use-plugins-marketplace-CloojomS.js +1 -0
  150. package/build/assets/use-runtime-is-ready-Bx_4cfar.js +1 -0
  151. package/build/assets/{use-save-agent-profile-i4FcEP98.js → use-save-agent-profile-Bj7N-1jS.js} +1 -1
  152. package/build/assets/{use-save-settings-DiDEbIJw.js → use-save-settings-BMsb2wk_.js} +1 -1
  153. package/build/assets/use-settings-B9XEmh7i.js +1 -0
  154. package/build/assets/use-settings-nav-items-BGfBS0yL.js +16 -0
  155. package/build/assets/{use-skills-Blpg2BqE.js → use-skills-CSRbvPle.js} +1 -1
  156. package/build/assets/{use-task-list-CfisapBW.js → use-task-list-CTIVLrQA.js} +1 -1
  157. package/build/assets/use-tracking-DjdCssvp.js +1 -0
  158. package/build/assets/{use-user-conversation-BrN2xeQU.js → use-user-conversation-BCpFn-Ei.js} +1 -1
  159. package/build/assets/{useTranslation-Cbf5AGg_.js → useTranslation-CHm_6BRr.js} +1 -1
  160. package/build/assets/{utils-DB9LsAzA.js → utils-CrRpzbM2.js} +1 -1
  161. package/build/assets/vendor-markdown-DzO4uO_0.js +37 -0
  162. package/build/assets/{vendor~browser-wXQ-WZEC.js → vendor~browser-Byfuq5J-.js} +1 -1
  163. package/build/assets/{vendor~browser-tab-CsMb-pta.js → vendor~browser-tab-BLk3qxhw.js} +1 -1
  164. package/build/assets/{vendor~entry.client~root~root-layout~index-home~home~conversation-panel~conversation~launch~dhilvkxv-eGLBu60s.js → vendor~entry.client~root~root-layout~index-home~home~conversation-panel~conversation~launch~dhilvkxv-DTJ_cjR5.js} +2 -2
  165. package/build/assets/{vendor~files-tab-B-5fBohe.js → vendor~files-tab-XmnauIZI.js} +1 -1
  166. package/build/assets/{vendor~launch-_Km3J77E.js → vendor~launch-DeC8QhXQ.js} +1 -1
  167. package/build/assets/{vendor~root-layout~conversation-panel~conversation~shared-conversation-BrguKXCn.js → vendor~root-layout~conversation-panel~conversation~shared-conversation-DDmLzCzm.js} +1 -1
  168. package/build/assets/vendor~root-layout~index-home~home~conversation-panel~conversation-YrfJYTQw.js +1 -0
  169. package/build/assets/{vendor~root-layout~index-home~home~conversation-panel~conversation~launch~skills-settings~a~j2jlu22h-mC0v44WR.js → vendor~root-layout~index-home~home~conversation-panel~conversation~launch~skills-settings~a~j2jlu22h-DoaS51iW.js} +123 -3
  170. package/build/assets/{vendor~root-layout~index-home~home~conversation-panel~conversation~shared-conversation~aler~gfu7qdtz-BOKQkbc6.js → vendor~root-layout~index-home~home~conversation-panel~conversation~shared-conversation~aler~gfu7qdtz-DEYwoy8u.js} +1 -1
  171. package/build/assets/vendor~root-layout~index-home~home~mcp~automations-list~onboarding-modal-DZHLw5Sr.js +1 -0
  172. package/build/assets/{vendor~root~root-layout~index-home~home~conversation-panel~conversation~launch~extensions-h~ftka0fnu-cFNmfAE6.js → vendor~root~root-layout~index-home~home~conversation-panel~conversation~launch~extensions-h~ftka0fnu-UJ4BNDJP.js} +1 -1
  173. package/build/assets/{verification-settings-C8KzAdAX.js → verification-settings-uwOfc16F.js} +1 -1
  174. package/build/index.html +4 -4
  175. package/build/locales/ar/openhands.json +38 -4
  176. package/build/locales/ca/openhands.json +38 -4
  177. package/build/locales/de/openhands.json +38 -4
  178. package/build/locales/en/openhands.json +38 -4
  179. package/build/locales/es/openhands.json +38 -4
  180. package/build/locales/fr/openhands.json +38 -4
  181. package/build/locales/it/openhands.json +38 -4
  182. package/build/locales/ja/openhands.json +38 -4
  183. package/build/locales/ko-KR/openhands.json +38 -4
  184. package/build/locales/no/openhands.json +38 -4
  185. package/build/locales/pt/openhands.json +38 -4
  186. package/build/locales/tr/openhands.json +38 -4
  187. package/build/locales/uk/openhands.json +38 -4
  188. package/build/locales/zh-CN/openhands.json +38 -4
  189. package/build/locales/zh-TW/openhands.json +38 -4
  190. package/config/defaults.json +7 -3
  191. package/dist/api/agent-canvas-updates.cjs +2 -0
  192. package/dist/api/agent-canvas-updates.cjs.map +1 -0
  193. package/dist/api/agent-canvas-updates.d.ts +7 -0
  194. package/dist/api/agent-canvas-updates.js +19 -0
  195. package/dist/api/agent-canvas-updates.js.map +1 -0
  196. package/dist/api/agent-server-adapter.cjs +1 -1
  197. package/dist/api/agent-server-adapter.cjs.map +1 -1
  198. package/dist/api/agent-server-adapter.d.ts +3 -0
  199. package/dist/api/agent-server-adapter.js +1 -0
  200. package/dist/api/agent-server-adapter.js.map +1 -1
  201. package/dist/api/agent-server-compatibility.cjs +1 -1
  202. package/dist/api/agent-server-compatibility.cjs.map +1 -1
  203. package/dist/api/agent-server-compatibility.d.ts +5 -0
  204. package/dist/api/agent-server-compatibility.js +24 -15
  205. package/dist/api/agent-server-compatibility.js.map +1 -1
  206. package/dist/api/agent-server-config.cjs +1 -1
  207. package/dist/api/agent-server-config.cjs.map +1 -1
  208. package/dist/api/agent-server-config.js +11 -8
  209. package/dist/api/agent-server-config.js.map +1 -1
  210. package/dist/api/automation-service/automation-service.api.cjs +2 -0
  211. package/dist/api/automation-service/automation-service.api.cjs.map +1 -0
  212. package/dist/api/automation-service/automation-service.api.d.ts +3 -0
  213. package/dist/api/automation-service/automation-service.api.js +283 -0
  214. package/dist/api/automation-service/automation-service.api.js.map +1 -0
  215. package/dist/api/client-source.cjs +1 -1
  216. package/dist/api/client-source.cjs.map +1 -1
  217. package/dist/api/client-source.d.ts +3 -0
  218. package/dist/api/client-source.js +4 -4
  219. package/dist/api/client-source.js.map +1 -1
  220. package/dist/api/cloud/settings-service.api.cjs.map +1 -1
  221. package/dist/api/cloud/settings-service.api.js.map +1 -1
  222. package/dist/api/conversation-service/agent-server-conversation-service.api.cjs +1 -1
  223. package/dist/api/conversation-service/agent-server-conversation-service.api.cjs.map +1 -1
  224. package/dist/api/conversation-service/agent-server-conversation-service.api.js +111 -109
  225. package/dist/api/conversation-service/agent-server-conversation-service.api.js.map +1 -1
  226. package/dist/api/mcp-health/mcp-health-store.cjs +2 -0
  227. package/dist/api/mcp-health/mcp-health-store.cjs.map +1 -0
  228. package/dist/api/mcp-health/mcp-health-store.d.ts +22 -0
  229. package/dist/api/mcp-health/mcp-health-store.js +45 -0
  230. package/dist/api/mcp-health/mcp-health-store.js.map +1 -0
  231. package/dist/api/mcp-health/probe-mcp-server-health.cjs +2 -0
  232. package/dist/api/mcp-health/probe-mcp-server-health.cjs.map +1 -0
  233. package/dist/api/mcp-health/probe-mcp-server-health.d.ts +31 -0
  234. package/dist/api/mcp-health/probe-mcp-server-health.js +57 -0
  235. package/dist/api/mcp-health/probe-mcp-server-health.js.map +1 -0
  236. package/dist/api/mcp-service/mcp-service.api.cjs +1 -1
  237. package/dist/api/mcp-service/mcp-service.api.cjs.map +1 -1
  238. package/dist/api/mcp-service/mcp-service.api.js +66 -46
  239. package/dist/api/mcp-service/mcp-service.api.js.map +1 -1
  240. package/dist/api/plugins-management-service.cjs.map +1 -1
  241. package/dist/api/plugins-management-service.d.ts +6 -1
  242. package/dist/api/plugins-management-service.js.map +1 -1
  243. package/dist/api/plugins-service.d.ts +30 -2
  244. package/dist/api/secrets-service.cjs +1 -1
  245. package/dist/api/secrets-service.cjs.map +1 -1
  246. package/dist/api/secrets-service.d.ts +6 -6
  247. package/dist/api/secrets-service.js +8 -3
  248. package/dist/api/secrets-service.js.map +1 -1
  249. package/dist/api/settings-service/settings-service.api.cjs +1 -1
  250. package/dist/api/settings-service/settings-service.api.cjs.map +1 -1
  251. package/dist/api/settings-service/settings-service.api.d.ts +1 -1
  252. package/dist/api/settings-service/settings-service.api.js +1 -0
  253. package/dist/api/settings-service/settings-service.api.js.map +1 -1
  254. package/dist/components/conversation-events/chat/event-message-components/critic-result-display.cjs +1 -1
  255. package/dist/components/conversation-events/chat/event-message-components/critic-result-display.js +5 -5
  256. package/dist/components/features/backends/backend-form-modal.cjs +1 -1
  257. package/dist/components/features/backends/backend-form-modal.cjs.map +1 -1
  258. package/dist/components/features/backends/backend-form-modal.d.ts +4 -1
  259. package/dist/components/features/backends/backend-form-modal.js +15 -16
  260. package/dist/components/features/backends/backend-form-modal.js.map +1 -1
  261. package/dist/components/features/backends/backend-selector.cjs +1 -1
  262. package/dist/components/features/backends/backend-selector.cjs.map +1 -1
  263. package/dist/components/features/backends/backend-selector.js +103 -102
  264. package/dist/components/features/backends/backend-selector.js.map +1 -1
  265. package/dist/components/features/backends/manage-backends-modal.cjs +1 -1
  266. package/dist/components/features/backends/manage-backends-modal.cjs.map +1 -1
  267. package/dist/components/features/backends/manage-backends-modal.js +85 -73
  268. package/dist/components/features/backends/manage-backends-modal.js.map +1 -1
  269. package/dist/components/features/chat/chat-interface.cjs +2 -2
  270. package/dist/components/features/chat/chat-interface.cjs.map +1 -1
  271. package/dist/components/features/chat/chat-interface.js +131 -129
  272. package/dist/components/features/chat/chat-interface.js.map +1 -1
  273. package/dist/components/features/chat/confirmation-mode-enabled.cjs +1 -1
  274. package/dist/components/features/chat/confirmation-mode-enabled.js +4 -4
  275. package/dist/components/features/chat/skill-install-restart-banner.cjs +2 -0
  276. package/dist/components/features/chat/skill-install-restart-banner.cjs.map +1 -0
  277. package/dist/components/features/chat/skill-install-restart-banner.d.ts +11 -0
  278. package/dist/components/features/chat/skill-install-restart-banner.js +63 -0
  279. package/dist/components/features/chat/skill-install-restart-banner.js.map +1 -0
  280. package/dist/components/features/conversation/right-panel-toggle.cjs +1 -1
  281. package/dist/components/features/conversation/right-panel-toggle.cjs.map +1 -1
  282. package/dist/components/features/conversation/right-panel-toggle.js +1 -1
  283. package/dist/components/features/conversation/right-panel-toggle.js.map +1 -1
  284. package/dist/components/features/conversation-panel/conversation-panel.cjs +1 -1
  285. package/dist/components/features/conversation-panel/conversation-panel.js +10 -10
  286. package/dist/components/features/mcp-page/custom-server-editor.cjs +1 -1
  287. package/dist/components/features/mcp-page/custom-server-editor.cjs.map +1 -1
  288. package/dist/components/features/mcp-page/custom-server-editor.js +78 -77
  289. package/dist/components/features/mcp-page/custom-server-editor.js.map +1 -1
  290. package/dist/components/features/mcp-page/install-server-modal.cjs +1 -1
  291. package/dist/components/features/mcp-page/install-server-modal.cjs.map +1 -1
  292. package/dist/components/features/mcp-page/install-server-modal.d.ts +4 -1
  293. package/dist/components/features/mcp-page/install-server-modal.js +135 -136
  294. package/dist/components/features/mcp-page/install-server-modal.js.map +1 -1
  295. package/dist/components/features/mcp-page/installed-server-card.cjs +1 -1
  296. package/dist/components/features/mcp-page/installed-server-card.cjs.map +1 -1
  297. package/dist/components/features/mcp-page/installed-server-card.js +40 -34
  298. package/dist/components/features/mcp-page/installed-server-card.js.map +1 -1
  299. package/dist/components/features/mcp-page/mcp-server-health.cjs +2 -0
  300. package/dist/components/features/mcp-page/mcp-server-health.cjs.map +1 -0
  301. package/dist/components/features/mcp-page/mcp-server-health.d.ts +18 -0
  302. package/dist/components/features/mcp-page/mcp-server-health.js +117 -0
  303. package/dist/components/features/mcp-page/mcp-server-health.js.map +1 -0
  304. package/dist/components/features/plugins/build-plugins-view-model.d.ts +10 -1
  305. package/dist/components/features/plugins/plugin-files-section.d.ts +13 -0
  306. package/dist/components/features/settings/agent-canvas-update-card.cjs +2 -0
  307. package/dist/components/features/settings/agent-canvas-update-card.cjs.map +1 -0
  308. package/dist/components/features/settings/agent-canvas-update-card.d.ts +7 -0
  309. package/dist/components/features/settings/agent-canvas-update-card.js +170 -0
  310. package/dist/components/features/settings/agent-canvas-update-card.js.map +1 -0
  311. package/dist/components/features/settings/integrations-settings-link.cjs +2 -0
  312. package/dist/components/features/settings/integrations-settings-link.cjs.map +1 -0
  313. package/dist/components/features/settings/integrations-settings-link.d.ts +5 -0
  314. package/dist/components/features/settings/integrations-settings-link.js +41 -0
  315. package/dist/components/features/settings/integrations-settings-link.js.map +1 -0
  316. package/dist/components/features/settings/llm-profiles/llm-settings-local-view.cjs +1 -1
  317. package/dist/components/features/settings/llm-profiles/llm-settings-local-view.js +1 -1
  318. package/dist/components/features/settings/settings-desktop-sidebar.cjs +1 -1
  319. package/dist/components/features/settings/settings-desktop-sidebar.cjs.map +1 -1
  320. package/dist/components/features/settings/settings-desktop-sidebar.js +31 -21
  321. package/dist/components/features/settings/settings-desktop-sidebar.js.map +1 -1
  322. package/dist/components/features/settings/settings-mobile-drawer.cjs +1 -1
  323. package/dist/components/features/settings/settings-mobile-drawer.cjs.map +1 -1
  324. package/dist/components/features/settings/settings-mobile-drawer.js +40 -30
  325. package/dist/components/features/settings/settings-mobile-drawer.js.map +1 -1
  326. package/dist/components/features/skills/extensions-navigation.cjs +1 -1
  327. package/dist/components/features/skills/extensions-navigation.cjs.map +1 -1
  328. package/dist/components/features/skills/extensions-navigation.js +54 -33
  329. package/dist/components/features/skills/extensions-navigation.js.map +1 -1
  330. package/dist/config/defaults.cjs +1 -1
  331. package/dist/config/defaults.cjs.map +1 -1
  332. package/dist/config/defaults.js +7 -3
  333. package/dist/config/defaults.js.map +1 -1
  334. package/dist/constants/acp-providers.cjs.map +1 -1
  335. package/dist/constants/acp-providers.js.map +1 -1
  336. package/dist/contexts/conversation-websocket-context.cjs +2 -2
  337. package/dist/contexts/conversation-websocket-context.cjs.map +1 -1
  338. package/dist/contexts/conversation-websocket-context.js +169 -166
  339. package/dist/contexts/conversation-websocket-context.js.map +1 -1
  340. package/dist/hooks/mutation/use-delete-llm-profile.cjs +1 -1
  341. package/dist/hooks/mutation/use-delete-llm-profile.js +1 -0
  342. package/dist/hooks/mutation/use-delete-mcp-server.cjs +1 -1
  343. package/dist/hooks/mutation/use-delete-mcp-server.cjs.map +1 -1
  344. package/dist/hooks/mutation/use-delete-mcp-server.js +8 -6
  345. package/dist/hooks/mutation/use-delete-mcp-server.js.map +1 -1
  346. package/dist/hooks/mutation/use-rename-llm-profile.cjs +1 -1
  347. package/dist/hooks/mutation/use-rename-llm-profile.js +1 -0
  348. package/dist/hooks/mutation/use-save-settings.cjs +1 -1
  349. package/dist/hooks/mutation/use-save-settings.js +3 -3
  350. package/dist/hooks/mutation/use-update-mcp-server.cjs +1 -1
  351. package/dist/hooks/mutation/use-update-mcp-server.cjs.map +1 -1
  352. package/dist/hooks/mutation/use-update-mcp-server.js +11 -9
  353. package/dist/hooks/mutation/use-update-mcp-server.js.map +1 -1
  354. package/dist/hooks/query/query-keys.cjs +1 -1
  355. package/dist/hooks/query/query-keys.cjs.map +1 -1
  356. package/dist/hooks/query/query-keys.d.ts +4 -0
  357. package/dist/hooks/query/query-keys.js +2 -2
  358. package/dist/hooks/query/query-keys.js.map +1 -1
  359. package/dist/hooks/query/use-automation-sdk-version.cjs +2 -0
  360. package/dist/hooks/query/use-automation-sdk-version.cjs.map +1 -0
  361. package/dist/hooks/query/use-automation-sdk-version.d.ts +3 -0
  362. package/dist/hooks/query/use-automation-sdk-version.js +63 -0
  363. package/dist/hooks/query/use-automation-sdk-version.js.map +1 -0
  364. package/dist/hooks/query/use-latest-agent-canvas-version.cjs +2 -0
  365. package/dist/hooks/query/use-latest-agent-canvas-version.cjs.map +1 -0
  366. package/dist/hooks/query/use-latest-agent-canvas-version.d.ts +10 -0
  367. package/dist/hooks/query/use-latest-agent-canvas-version.js +19 -0
  368. package/dist/hooks/query/use-latest-agent-canvas-version.js.map +1 -0
  369. package/dist/hooks/query/use-plugin-file-content.d.ts +7 -0
  370. package/dist/hooks/query/use-resolved-workspaces.cjs +1 -1
  371. package/dist/hooks/query/use-resolved-workspaces.cjs.map +1 -1
  372. package/dist/hooks/query/use-resolved-workspaces.js +25 -26
  373. package/dist/hooks/query/use-resolved-workspaces.js.map +1 -1
  374. package/dist/hooks/query/use-search-subdirs.cjs +1 -1
  375. package/dist/hooks/query/use-search-subdirs.cjs.map +1 -1
  376. package/dist/hooks/query/use-search-subdirs.d.ts +5 -0
  377. package/dist/hooks/query/use-search-subdirs.js +16 -4
  378. package/dist/hooks/query/use-search-subdirs.js.map +1 -1
  379. package/dist/hooks/use-device-flow.cjs +1 -1
  380. package/dist/hooks/use-device-flow.js +6 -6
  381. package/dist/hooks/use-llm-configured.cjs +1 -1
  382. package/dist/hooks/use-llm-configured.js +3 -3
  383. package/dist/hooks/use-mcp-server-health.cjs +2 -0
  384. package/dist/hooks/use-mcp-server-health.cjs.map +1 -0
  385. package/dist/hooks/use-mcp-server-health.d.ts +11 -0
  386. package/dist/hooks/use-mcp-server-health.js +18 -0
  387. package/dist/hooks/use-mcp-server-health.js.map +1 -0
  388. package/dist/hooks/use-skill-installs.cjs +2 -0
  389. package/dist/hooks/use-skill-installs.cjs.map +1 -0
  390. package/dist/hooks/use-skill-installs.d.ts +10 -0
  391. package/dist/hooks/use-skill-installs.js +21 -0
  392. package/dist/hooks/use-skill-installs.js.map +1 -0
  393. package/dist/hooks/use-tracking.cjs +1 -1
  394. package/dist/hooks/use-tracking.cjs.map +1 -1
  395. package/dist/hooks/use-tracking.d.ts +3 -3
  396. package/dist/hooks/use-tracking.js +67 -52
  397. package/dist/hooks/use-tracking.js.map +1 -1
  398. package/dist/i18n/declaration.cjs +1 -1
  399. package/dist/i18n/declaration.cjs.map +1 -1
  400. package/dist/i18n/declaration.d.ts +35 -1
  401. package/dist/i18n/declaration.js +1 -1
  402. package/dist/i18n/declaration.js.map +1 -1
  403. package/dist/i18n/translation.cjs +3 -3
  404. package/dist/i18n/translation.cjs.map +1 -1
  405. package/dist/i18n/translation.js +623 -45
  406. package/dist/i18n/translation.js.map +1 -1
  407. package/dist/index.cjs +1 -1
  408. package/dist/index.js +1 -2
  409. package/dist/lib/index.cjs +1 -1
  410. package/dist/lib/index.d.ts +0 -1
  411. package/dist/lib/index.js +0 -1
  412. package/dist/locales/ar/openhands.json +38 -4
  413. package/dist/locales/ca/openhands.json +38 -4
  414. package/dist/locales/de/openhands.json +38 -4
  415. package/dist/locales/en/openhands.json +38 -4
  416. package/dist/locales/es/openhands.json +38 -4
  417. package/dist/locales/fr/openhands.json +38 -4
  418. package/dist/locales/it/openhands.json +38 -4
  419. package/dist/locales/ja/openhands.json +38 -4
  420. package/dist/locales/ko-KR/openhands.json +38 -4
  421. package/dist/locales/no/openhands.json +38 -4
  422. package/dist/locales/pt/openhands.json +38 -4
  423. package/dist/locales/tr/openhands.json +38 -4
  424. package/dist/locales/uk/openhands.json +38 -4
  425. package/dist/locales/zh-CN/openhands.json +38 -4
  426. package/dist/locales/zh-TW/openhands.json +38 -4
  427. package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian-rovo.cjs +2 -0
  428. package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian-rovo.cjs.map +1 -0
  429. package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian-rovo.js +44 -0
  430. package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian-rovo.js.map +1 -0
  431. package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian.cjs +1 -1
  432. package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian.cjs.map +1 -1
  433. package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian.js +13 -0
  434. package/dist/node_modules/@openhands/extensions/integrations/catalog/atlassian.js.map +1 -1
  435. package/dist/node_modules/@openhands/extensions/integrations/catalog/github.cjs +1 -1
  436. package/dist/node_modules/@openhands/extensions/integrations/catalog/github.cjs.map +1 -1
  437. package/dist/node_modules/@openhands/extensions/integrations/catalog/github.js +21 -1
  438. package/dist/node_modules/@openhands/extensions/integrations/catalog/github.js.map +1 -1
  439. package/dist/node_modules/@openhands/extensions/integrations/catalog/linear.cjs +1 -1
  440. package/dist/node_modules/@openhands/extensions/integrations/catalog/linear.cjs.map +1 -1
  441. package/dist/node_modules/@openhands/extensions/integrations/catalog/linear.js +1 -1
  442. package/dist/node_modules/@openhands/extensions/integrations/catalog/linear.js.map +1 -1
  443. package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-outlook.cjs +1 -1
  444. package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-outlook.cjs.map +1 -1
  445. package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-outlook.js +13 -0
  446. package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-outlook.js.map +1 -1
  447. package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-teams.cjs +1 -1
  448. package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-teams.cjs.map +1 -1
  449. package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-teams.js +13 -0
  450. package/dist/node_modules/@openhands/extensions/integrations/catalog/microsoft-teams.js.map +1 -1
  451. package/dist/node_modules/@openhands/extensions/integrations/catalog/notion.cjs +1 -1
  452. package/dist/node_modules/@openhands/extensions/integrations/catalog/notion.cjs.map +1 -1
  453. package/dist/node_modules/@openhands/extensions/integrations/catalog/notion.js +13 -0
  454. package/dist/node_modules/@openhands/extensions/integrations/catalog/notion.js.map +1 -1
  455. package/dist/node_modules/@openhands/extensions/integrations/catalog/onedrive.cjs +1 -1
  456. package/dist/node_modules/@openhands/extensions/integrations/catalog/onedrive.cjs.map +1 -1
  457. package/dist/node_modules/@openhands/extensions/integrations/catalog/onedrive.js +13 -0
  458. package/dist/node_modules/@openhands/extensions/integrations/catalog/onedrive.js.map +1 -1
  459. package/dist/node_modules/@openhands/extensions/integrations/catalog/sharepoint.cjs +1 -1
  460. package/dist/node_modules/@openhands/extensions/integrations/catalog/sharepoint.cjs.map +1 -1
  461. package/dist/node_modules/@openhands/extensions/integrations/catalog/sharepoint.js +13 -0
  462. package/dist/node_modules/@openhands/extensions/integrations/catalog/sharepoint.js.map +1 -1
  463. package/dist/node_modules/@openhands/extensions/integrations/catalog/slack.cjs +1 -1
  464. package/dist/node_modules/@openhands/extensions/integrations/catalog/slack.cjs.map +1 -1
  465. package/dist/node_modules/@openhands/extensions/integrations/catalog/slack.js +16 -2
  466. package/dist/node_modules/@openhands/extensions/integrations/catalog/slack.js.map +1 -1
  467. package/dist/node_modules/@openhands/extensions/integrations/catalog/vanta.cjs +2 -0
  468. package/dist/node_modules/@openhands/extensions/integrations/catalog/vanta.cjs.map +1 -0
  469. package/dist/node_modules/@openhands/extensions/integrations/catalog/vanta.js +46 -0
  470. package/dist/node_modules/@openhands/extensions/integrations/catalog/vanta.js.map +1 -0
  471. package/dist/node_modules/@openhands/extensions/integrations/catalog-index.cjs +1 -1
  472. package/dist/node_modules/@openhands/extensions/integrations/catalog-index.cjs.map +1 -1
  473. package/dist/node_modules/@openhands/extensions/integrations/catalog-index.js +74 -70
  474. package/dist/node_modules/@openhands/extensions/integrations/catalog-index.js.map +1 -1
  475. package/dist/node_modules/@openhands/extensions/skills/index.cjs +123 -3
  476. package/dist/node_modules/@openhands/extensions/skills/index.cjs.map +1 -1
  477. package/dist/node_modules/@openhands/extensions/skills/index.js +7 -1
  478. package/dist/node_modules/@openhands/extensions/skills/index.js.map +1 -1
  479. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.cjs +2 -0
  480. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.cjs.map +1 -0
  481. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.js +9 -0
  482. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.js.map +1 -0
  483. package/dist/node_modules/lucide-react/dist/esm/icons/info.cjs +2 -0
  484. package/dist/node_modules/lucide-react/dist/esm/icons/info.cjs.map +1 -0
  485. package/dist/node_modules/lucide-react/dist/esm/icons/info.js +21 -0
  486. package/dist/node_modules/lucide-react/dist/esm/icons/info.js.map +1 -0
  487. package/dist/package.cjs +1 -1
  488. package/dist/package.cjs.map +1 -1
  489. package/dist/package.js +10 -3
  490. package/dist/package.js.map +1 -1
  491. package/dist/routes/app-settings.cjs +1 -1
  492. package/dist/routes/app-settings.cjs.map +1 -1
  493. package/dist/routes/app-settings.js +113 -67
  494. package/dist/routes/app-settings.js.map +1 -1
  495. package/dist/routes/mcp.cjs +1 -1
  496. package/dist/routes/mcp.cjs.map +1 -1
  497. package/dist/routes/mcp.js +1 -0
  498. package/dist/routes/mcp.js.map +1 -1
  499. package/dist/services/cloud-funnel-analytics.cjs +1 -1
  500. package/dist/services/cloud-funnel-analytics.cjs.map +1 -1
  501. package/dist/services/cloud-funnel-analytics.d.ts +2 -2
  502. package/dist/services/cloud-funnel-analytics.js +18 -16
  503. package/dist/services/cloud-funnel-analytics.js.map +1 -1
  504. package/dist/services/settings.cjs +1 -1
  505. package/dist/services/settings.cjs.map +1 -1
  506. package/dist/services/settings.js +1 -0
  507. package/dist/services/settings.js.map +1 -1
  508. package/dist/services/telemetry-context.cjs +2 -0
  509. package/dist/services/telemetry-context.cjs.map +1 -0
  510. package/dist/services/telemetry-context.d.ts +17 -0
  511. package/dist/services/telemetry-context.js +27 -0
  512. package/dist/services/telemetry-context.js.map +1 -0
  513. package/dist/services/telemetry.cjs +1 -1
  514. package/dist/services/telemetry.cjs.map +1 -1
  515. package/dist/services/telemetry.d.ts +7 -5
  516. package/dist/services/telemetry.js +132 -123
  517. package/dist/services/telemetry.js.map +1 -1
  518. package/dist/stores/skill-install-banner-store.cjs +2 -0
  519. package/dist/stores/skill-install-banner-store.cjs.map +1 -0
  520. package/dist/stores/skill-install-banner-store.d.ts +32 -0
  521. package/dist/stores/skill-install-banner-store.js +14 -0
  522. package/dist/stores/skill-install-banner-store.js.map +1 -0
  523. package/dist/stores/use-event-store.cjs +1 -1
  524. package/dist/stores/use-event-store.cjs.map +1 -1
  525. package/dist/stores/use-event-store.js +35 -35
  526. package/dist/stores/use-event-store.js.map +1 -1
  527. package/dist/types/mcp-health.cjs +2 -0
  528. package/dist/types/mcp-health.cjs.map +1 -0
  529. package/dist/types/mcp-health.d.ts +21 -0
  530. package/dist/types/mcp-health.js +6 -0
  531. package/dist/types/mcp-health.js.map +1 -0
  532. package/dist/types/settings.d.ts +1 -0
  533. package/dist/utils/handle-event-for-ui.cjs +1 -1
  534. package/dist/utils/handle-event-for-ui.cjs.map +1 -1
  535. package/dist/utils/handle-event-for-ui.d.ts +5 -0
  536. package/dist/utils/handle-event-for-ui.js +71 -57
  537. package/dist/utils/handle-event-for-ui.js.map +1 -1
  538. package/dist/utils/mcp-credential-validation.cjs +1 -1
  539. package/dist/utils/mcp-credential-validation.cjs.map +1 -1
  540. package/dist/utils/mcp-credential-validation.js +32 -16
  541. package/dist/utils/mcp-credential-validation.js.map +1 -1
  542. package/dist/utils/mcp-server-health-key.cjs +2 -0
  543. package/dist/utils/mcp-server-health-key.cjs.map +1 -0
  544. package/dist/utils/mcp-server-health-key.d.ts +16 -0
  545. package/dist/utils/mcp-server-health-key.js +23 -0
  546. package/dist/utils/mcp-server-health-key.js.map +1 -0
  547. package/dist/utils/mcp-test-error-message.cjs +2 -0
  548. package/dist/utils/mcp-test-error-message.cjs.map +1 -0
  549. package/dist/utils/mcp-test-error-message.d.ts +8 -0
  550. package/dist/utils/mcp-test-error-message.js +14 -0
  551. package/dist/utils/mcp-test-error-message.js.map +1 -0
  552. package/dist/utils/redact-mcp-secrets.cjs +2 -0
  553. package/dist/utils/redact-mcp-secrets.cjs.map +1 -0
  554. package/dist/utils/redact-mcp-secrets.d.ts +13 -0
  555. package/dist/utils/redact-mcp-secrets.js +57 -0
  556. package/dist/utils/redact-mcp-secrets.js.map +1 -0
  557. package/dist/utils/settings-utils.cjs.map +1 -1
  558. package/dist/utils/settings-utils.js.map +1 -1
  559. package/dist/utils/skill-install-events.cjs +3 -0
  560. package/dist/utils/skill-install-events.cjs.map +1 -0
  561. package/dist/utils/skill-install-events.d.ts +16 -0
  562. package/dist/utils/skill-install-events.js +26 -0
  563. package/dist/utils/skill-install-events.js.map +1 -0
  564. package/dist/utils/title-llm-profile.cjs +2 -0
  565. package/dist/utils/title-llm-profile.cjs.map +1 -0
  566. package/dist/utils/title-llm-profile.d.ts +2 -0
  567. package/dist/utils/title-llm-profile.js +11 -0
  568. package/dist/utils/title-llm-profile.js.map +1 -0
  569. package/package.json +10 -3
  570. package/scripts/check-sdk-version-sync.mjs +6 -6
  571. package/scripts/check-translation-completeness.cjs +2 -0
  572. package/scripts/dev-process-utils.mjs +62 -1
  573. package/scripts/dev-safe.mjs +2 -2
  574. package/scripts/dev-static.mjs +5 -3
  575. package/scripts/dev-with-automation.mjs +98 -14
  576. package/scripts/download-node.mjs +382 -0
  577. package/scripts/download-uv.mjs +204 -0
  578. package/scripts/logger.mjs +64 -35
  579. package/build/assets/agent-server-compatibility-C0MtTTwb.js +0 -1
  580. package/build/assets/agent-server-conversation-service.api-lzc8dabY.js +0 -41
  581. package/build/assets/agent-settings-GwiXe_6k.js +0 -2
  582. package/build/assets/agent-settings-OdsyI2gX.js +0 -1
  583. package/build/assets/api-key-entry-screen-2gsoZAOK.js +0 -1
  584. package/build/assets/app-settings-CD9euh81.js +0 -1
  585. package/build/assets/automation-export-Djc8Tf0M.js +0 -2
  586. package/build/assets/automations-list-Dtiolk1h.js +0 -1
  587. package/build/assets/backend-form-modal-B8GtBA-J.js +0 -1
  588. package/build/assets/browser-store-BI6uklCG.js +0 -1
  589. package/build/assets/chat-send-button-BZHG2hAW.js +0 -1
  590. package/build/assets/client-source-CtQjJEy6.js +0 -1
  591. package/build/assets/cloud-funnel-analytics-uzzLlLuj.js +0 -1
  592. package/build/assets/conversation-B8d8_Upd.js +0 -1
  593. package/build/assets/conversation-Lmqm6VJC.js +0 -89
  594. package/build/assets/conversation-panel-B8n40Swu.js +0 -1
  595. package/build/assets/conversation-state-store-B2Bp32XI.js +0 -1
  596. package/build/assets/declaration-BGsHjPEW.js +0 -1
  597. package/build/assets/extensions-hub-DqvwvpCi.js +0 -1
  598. package/build/assets/extensions-navigation-BMc9Nluv.js +0 -1
  599. package/build/assets/files-tab-BAkaV4aO.js +0 -1
  600. package/build/assets/files-tab-store-DJsPxYdg.js +0 -1
  601. package/build/assets/git-provider-icon-xvbukHaT.js +0 -1
  602. package/build/assets/home-D01kSnmo.js +0 -1
  603. package/build/assets/home-NZO2bF4N.js +0 -1
  604. package/build/assets/index-home-BsI6i0TC.js +0 -1
  605. package/build/assets/install-server-modal-BYjqoRyX.js +0 -1
  606. package/build/assets/lesson-plan-cNUjpdFx.js +0 -4
  607. package/build/assets/llm-not-configured-banner-DUPyoFIZ.js +0 -27
  608. package/build/assets/llm-settings-Cs_iieFY.js +0 -1
  609. package/build/assets/llm-settings-J2ke2foG.js +0 -1
  610. package/build/assets/manage-backends-modal-nMoCZ2a0.js +0 -1
  611. package/build/assets/manifest-f1b46f62.js +0 -1
  612. package/build/assets/markdown-renderer-B4V2OMFP.js +0 -2
  613. package/build/assets/mcp-kZM-cAZw.js +0 -9
  614. package/build/assets/messages-CJAv5n4j.js +0 -40
  615. package/build/assets/objectWithoutPropertiesLoose-BgYIAs2y.js +0 -1
  616. package/build/assets/onboarding-Dx8n8HFr.js +0 -1
  617. package/build/assets/onboarding-modal-Bxuxpfdz.js +0 -1
  618. package/build/assets/recommended-automations-launcher-BWRRvMPE.js +0 -58
  619. package/build/assets/refresh-cw-B9B7-vsy.js +0 -1
  620. package/build/assets/root-CYWeTrWE.css +0 -1
  621. package/build/assets/root-layout-ClEl-JlJ.js +0 -2
  622. package/build/assets/root-oT83qVlk.js +0 -2
  623. package/build/assets/sdk-section-page-Cwj0T4gF.js +0 -1
  624. package/build/assets/secrets-settings-Bc_pBX6F.js +0 -1
  625. package/build/assets/settings-index-BzSIM1-N.js +0 -1
  626. package/build/assets/settings-modal-BnZ7mMu7.js +0 -1
  627. package/build/assets/settings-n9a395O0.js +0 -1
  628. package/build/assets/shared-conversation-CIDDti9I.js +0 -1
  629. package/build/assets/sidebar-mobile-menu-toggle-CTX7J4wM.js +0 -1
  630. package/build/assets/skills-plugins-HZEbNDmX.js +0 -1
  631. package/build/assets/skills-settings-BdqijFlC.js +0 -2
  632. package/build/assets/telemetry-SHxpVxk8.js +0 -2
  633. package/build/assets/use-activate-agent-profile-BRDdSwQ0.js +0 -1
  634. package/build/assets/use-backends-health-BagmAE_W.js +0 -1
  635. package/build/assets/use-config-B39iHYFi.js +0 -1
  636. package/build/assets/use-event-store-Bbaz51GR.js +0 -4
  637. package/build/assets/use-llm-profiles-CgRtnj74.js +0 -1
  638. package/build/assets/use-plugins-marketplace-DOJp9rlE.js +0 -1
  639. package/build/assets/use-runtime-is-ready-ziHQvXZQ.js +0 -1
  640. package/build/assets/use-settings-BeJap6YL.js +0 -1
  641. package/build/assets/use-settings-nav-items-D5JJjFHJ.js +0 -16
  642. package/build/assets/use-tracking-DFoPQUSU.js +0 -1
  643. package/build/assets/useMutationState-OnAsCLA_.js +0 -1
  644. package/build/assets/vendor~index-home~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-BD7v71DM.js +0 -2
  645. package/build/assets/vendor~index-home~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-BT05Osu4.js +0 -28
  646. package/build/assets/vendor~index-home~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-COhHANvV.js +0 -2
  647. package/build/assets/vendor~index-home~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-DgzWSMRc.js +0 -2
  648. package/build/assets/vendor~index-home~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-DqZatR3B.js +0 -7
  649. package/build/assets/vendor~index-home~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-FghQ3Z1a.js +0 -1
  650. package/build/assets/vendor~root-layout~index-home~home~conversation-panel~conversation-BTvhGHHG.js +0 -1
  651. package/build/assets/vendor~root-layout~index-home~home~mcp~automations-list~onboarding-modal-C4-GDgiF.js +0 -1
  652. package/dist/components/features/analytics/telemetry-consent-banner.cjs +0 -2
  653. package/dist/components/features/analytics/telemetry-consent-banner.cjs.map +0 -1
  654. package/dist/components/features/analytics/telemetry-consent-banner.d.ts +0 -29
  655. package/dist/components/features/analytics/telemetry-consent-banner.js +0 -59
  656. package/dist/components/features/analytics/telemetry-consent-banner.js.map +0 -1
  657. /package/build/assets/{__vite-browser-external-BQUj0sYu.js → __vite-browser-external-CKHVBTNC.js} +0 -0
  658. /package/build/assets/{agent-server-ui-style-scope-qhnhZHBV.js → agent-server-ui-style-scope-BvSa9on7.js} +0 -0
  659. /package/build/assets/{automation-LZB0MjdV.js → automation-BGiPmxFR.js} +0 -0
  660. /package/build/assets/{canvas-ui-COgjltGz.js → canvas-ui-CC4EJo-H.js} +0 -0
  661. /package/build/assets/{checkmark-h7udgXMM.js → checkmark-ygQB1AtV.js} +0 -0
  662. /package/build/assets/{close-DLFb5kfv.js → close-BjSA0HWT.js} +0 -0
  663. /package/build/assets/{code-tag-DYlAhEQY.js → code-tag-D9aPPbOe.js} +0 -0
  664. /package/build/assets/{common-CxbUL3nR.js → common-CCuqQy_S.js} +0 -0
  665. /package/build/assets/{conversation-local-storage-F6zVMM--.js → conversation-local-storage-BDjWPg0Z.js} +0 -0
  666. /package/build/assets/{copy-BLmGeJcd.js → copy-Dce7sOvS.js} +0 -0
  667. /package/build/assets/{copy-D1YGjP-C.js → copy-iPJAncAj.js} +0 -0
  668. /package/build/assets/{dist-CodhvuAP.js → dist-D9PhjOaq.js} +0 -0
  669. /package/build/assets/{environment-switch-store-DkjlKWzN.js → environment-switch-store-DHfcz4M4.js} +0 -0
  670. /package/build/assets/{extension-module-card-classes-9V3J9J_b.js → extension-module-card-classes-BpebKiN6.js} +0 -0
  671. /package/build/assets/{external-link-lhdITPqq.js → external-link-CpPMXxrV.js} +0 -0
  672. /package/build/assets/{folder-Bk311brm.js → folder-BabbYnbF.js} +0 -0
  673. /package/build/assets/{format-time-delta-DhDbkD7V.js → format-time-delta-BkAmJEPT.js} +0 -0
  674. /package/build/assets/{get-language-from-path-DBqBsCWH.js → get-language-from-path-CPNnuVhI.js} +0 -0
  675. /package/build/assets/{git-status-mapper-DnL9OC8_.js → git-status-mapper-BIXK0AAG.js} +0 -0
  676. /package/build/assets/{iconBase-Dz51Zn5x.js → iconBase-Ch-fOe8B.js} +0 -0
  677. /package/build/assets/{link-external-CaBmUEs_.js → link-external-DfKQroKX.js} +0 -0
  678. /package/build/assets/{list-todo-CAtvkzcy.js → list-todo-6J6zc8oS.js} +0 -0
  679. /package/build/assets/{llm-subscription-DtsX5Lhg.js → llm-subscription-Bvu8BLXc.js} +0 -0
  680. /package/build/assets/{loader-circle-CsAsfLIs.js → loader-circle-DGsqG5qw.js} +0 -0
  681. /package/build/assets/{map-provider-BbIb12oh.js → map-provider-BSvXvVR0.js} +0 -0
  682. /package/build/assets/{middleware-DYHYNAnP.js → middleware-_izt7V6U.js} +0 -0
  683. /package/build/assets/{modal-backdrop-zVwfOJZr.js → modal-backdrop-B7H42xHG.js} +0 -0
  684. /package/build/assets/{navigation-context-DPs2G0X8.js → navigation-context-cvyvI1WA.js} +0 -0
  685. /package/build/assets/{openhands-logo-bcNw5bkY.js → openhands-logo-pEw0nKFP.js} +0 -0
  686. /package/build/assets/{pencil-CWhApFIT.js → pencil-DmSqWUA3.js} +0 -0
  687. /package/build/assets/{react-DPDgL6du.js → react-MKQOkha9.js} +0 -0
  688. /package/build/assets/{search-BgOCR7_c.js → search-B5D5EuSn.js} +0 -0
  689. /package/build/assets/{search-dIQ09UY2.js → search-vnYL5jwV.js} +0 -0
  690. /package/build/assets/{settings-gear-MXCyZW0x.js → settings-gear-BOwF59Bs.js} +0 -0
  691. /package/build/assets/{settings-section-header-context-COMOIaxV.js → settings-section-header-context-CGgHZXrf.js} +0 -0
  692. /package/build/assets/{skills-EqzxYBvT.js → skills-arUOHLcS.js} +0 -0
  693. /package/build/assets/{square-chevron-right-DE-JN-2Z.js → square-chevron-right-EizCGtgq.js} +0 -0
  694. /package/build/assets/{switch-skeleton-DqQwalyu.js → switch-skeleton-BjPRx1QD.js} +0 -0
  695. /package/build/assets/{terminal-Cgf___rK.js → terminal-a57bHgZs.js} +0 -0
  696. /package/build/assets/{trash-2-BU6BlW4i.js → trash-2-CF3hilrY.js} +0 -0
  697. /package/build/assets/{u-check-circle-BqoIxNz_.js → u-check-circle-WGqHdtfO.js} +0 -0
  698. /package/build/assets/{u-check-circle-half-MsShT8Ec.js → u-check-circle-half-LiwZkuFe.js} +0 -0
  699. /package/build/assets/{u-edit-DL5LgKon.js → u-edit-BwHepAPi.js} +0 -0
  700. /package/build/assets/{use-breakpoint-BP3lqLMx.js → use-breakpoint-B-O0lQ84.js} +0 -0
  701. /package/build/assets/{use-click-outside-element-D9BYdANT.js → use-click-outside-element-DLQIMQrz.js} +0 -0
  702. /package/build/assets/{use-is-authed-BezEyfeh.js → use-is-authed-BSeo4coy.js} +0 -0
  703. /package/build/assets/{use-onboarding-completion-C_Swglzp.js → use-onboarding-completion-C0hPNGpw.js} +0 -0
  704. /package/build/assets/{v4-DbCkTSoU.js → v4-q4yWTlMz.js} +0 -0
  705. /package/build/assets/{vendor~browser-By2MVv_N.js → vendor~browser-UwB1jbAZ.js} +0 -0
  706. /package/build/assets/{vendor~conversation-panel~conversation~alert-banner-CxfzCmkN.js → vendor~conversation-panel~conversation~alert-banner-DHDkknt5.js} +0 -0
  707. /package/build/assets/{vendor~index-home~home~conversation-panel~conversation-ChmYLVgz.js → vendor~index-home~home~conversation-panel~conversation-Bff9cq5J.js} +0 -0
  708. /package/build/assets/{vendor~module-D5a_AClf.js → vendor~module-D4DeFV4J.js} +0 -0
  709. /package/build/assets/{vendor~terminal-CnKZILnC.js → vendor~terminal-B7Eiak0-.js} +0 -0
  710. /package/build/assets/{x-ZE4iplpF.js → x-DQB_00VJ.js} +0 -0
  711. /package/build/assets/{x-mark-Batp6gXa.js → x-mark-B32XuEwS.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 ForkConversationRequest,\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 { AgentKind, 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 ProfilesService from \"../profiles-service/profiles-service.api\";\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 assertSubscriptionAuthReady,\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 type WorkspaceMode,\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_server`` is\n // the ACP provider identity (``ACPAgent.acp_server``, SDK #3692) — required so\n // the adapter can source the chip + in-conversation model list from the agent\n // when the ``acpserver`` tag is absent (a profile launch doesn't stamp it,\n // #1571). ``acp_model`` is the Canvas-configured model — preserved so the chip\n // can fall back to it when the SDK runtime model fields aren't populated.\n // Preserving these makes the wire path agree with the unit-test path that\n // builds ``DirectConversationInfo`` directly\n // (e.g. ``__tests__/api/agent-server-adapter.test.ts``).\n return {\n kind: stringOrNull(value.kind),\n acp_server: stringOrNull(value.acp_server),\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 normalizeLaunchedAgentProfile(\n value: unknown,\n): DirectConversationInfo[\"launched_agent_profile\"] {\n if (!isRecord(value)) return null;\n const { agent_profile_id: agentProfileId, revision } = value;\n if (typeof agentProfileId !== \"string\" || typeof revision !== \"number\") {\n return null;\n }\n return { agent_profile_id: agentProfileId, revision };\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 launched_agent_profile: normalizeLaunchedAgentProfile(\n item.launched_agent_profile,\n ),\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 workspaceMode?: WorkspaceMode,\n parentConversationId?: string,\n agentType?: \"default\" | \"plan\",\n sandboxId?: string,\n // Launch from a saved AgentProfile (resolved server-side) instead of the\n // current encrypted agent_settings (#3727). Supported on both local and the\n // cloud app-server (OpenHands #15060): local threads it through the\n // encrypted-settings builder; cloud sends it as a flat request field.\n agentProfileId?: string,\n agentProfileKind?: AgentKind,\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 // When launching from a profile, send `agent_profile_id`; the backend\n // resolves it to agent_settings 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 agent_profile_id: agentProfileId ?? 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 const resolvedWorkspaceMode =\n workspaceMode ?? (workingDirOverride ? \"local_repo\" : \"new_worktree\");\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 worktree: resolvedWorkspaceMode === \"new_worktree\",\n agentProfileId,\n agentProfileKind,\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 workspace_mode: resolvedWorkspaceMode,\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 * Forks a conversation, copying event history up to and including\n * `fromEventId`. Local agent-server only; needs agent-server >= 1.31.0 for\n * `from_event_id` (older backends copy the whole conversation).\n */\n static async forkConversation(\n sourceConversationId: string,\n fromEventId: string,\n title?: string,\n ): Promise<DirectConversationInfo> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n throw new Error(\n \"Branching a conversation isn't supported on the cloud backend yet.\",\n );\n }\n\n // `from_event_id` is accepted by `/fork` but not yet typed in\n // ForkConversationRequest (through client 1.32.0); the client forwards the\n // body verbatim, so cast to carry it. A title also suppresses the backend\n // auto-title, so the \"(branch)\" marker sticks.\n const data = await new ConversationClient(\n getAgentServerClientOptions(),\n ).forkConversation<DirectConversationInfo>(sourceConversationId, {\n from_event_id: fromEventId,\n ...(title ? { title } : {}),\n } as ForkConversationRequest & { from_event_id: string });\n\n // Carry over the source's client-side metadata (repo/branch/workspace/\n // profile/plugins) so the fork hydrates its chat-page badges the same way.\n const sourceMetadata = getStoredConversationMetadata(sourceConversationId);\n if (sourceMetadata) {\n setStoredConversationMetadata(data.id, sourceMetadata);\n }\n\n return data;\n }\n\n /**\n * Returns an event's `parent_id` (the fork point for branching *before* it),\n * or undefined at the root. Uses the single-event endpoint because the events\n * *search* API omits `parent_id`.\n */\n static async getEventParentId(\n conversationId: string,\n eventId: string,\n ): Promise<string | undefined> {\n const event = (await new ConversationClient(\n getAgentServerClientOptions(),\n ).getEvent(conversationId, eventId)) as { parent_id?: string | null };\n return event.parent_id ?? undefined;\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 * Cloud backends route to the app-server's per-conversation\n * `/switch_profile`, which owns the profiles and resolves the swap\n * server-side (base_url/api_key fixups, usage_id derivation, then the\n * agent-server's switch_llm) — so the client only forwards the profile name,\n * mirroring {@link switchAcpModel}.\n */\n static async switchProfile(\n conversationId: string | null,\n profileName: string,\n ): Promise<void> {\n const { backend } = getActiveBackend();\n\n if (backend.kind === \"cloud\") {\n // No conversation (home page): activate globally so the next\n // conversation starts with it. ProfilesService routes to the cloud\n // activate endpoint.\n if (!conversationId) {\n await ProfilesService.activateProfile(profileName);\n return;\n }\n await callCloudProxy({\n backend,\n method: \"POST\",\n path: `/api/v1/app-conversations/${conversationId}/switch_profile`,\n body: { profile_name: profileName },\n });\n return;\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 assertSubscriptionAuthReady({ llm: profile.config });\n await conversationClient.switchLLM(conversationId, {\n ...profile.config,\n model,\n // Keep streaming on after a switch (parity with conversation start);\n // the profile config would otherwise default it to stream=False.\n stream: true,\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 const { backend } = getActiveBackend();\n if (backend.kind === \"cloud\") {\n await callCloudProxy({\n backend,\n method: \"POST\",\n path: `/api/v1/app-conversations/${conversationId}/switch_acp_model`,\n body: { model },\n });\n return;\n }\n\n await new ConversationClient(getAgentServerClientOptions()).switchAcpModel(\n conversationId,\n model,\n );\n }\n}\n\nexport default AgentServerConversationService;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuEA,IAAM,IAAiC,4BACjC,IACJ;AAGF,SAAS,IAAqC;AAC5C,QAAW,MAAM,EAAsC;;AAGzD,SAAS,EAAS,GAAkD;A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,EAAE,eAAY,GAAkB;AAEtC,MAAI,EAAQ,SAAS,SAAS;AAI5B,OAAI,CAAC,GAAgB;AACnB,UAAM,EAAgB,gBAAgB,EAAY;AAClD;;AAEF,SAAM,EAAe;IACnB;IACA,QAAQ;IACR,MAAM,6BAA6B,EAAe;IAClD,MAAM,EAAE,cAAc,GAAa;IACpC,CAAC;AACF;;AAGF,MAAI,CAAC,GAAgB;AACnB,SAAM,IAAI,EAAe,GAA6B,CAAC,CAAC,gBACtD,EACD;AACD;;EAGF,IAAM,IAAgB,GAA6B,EAC7C,IAAqB,IAAI,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;AAErE,EADA,MAAM,EAA4B,EAAE,KAAK,EAAQ,QAAQ,CAAC,EAC1D,MAAM,EAAmB,UAAU,GAAgB;GACjD,GAAG,EAAQ;GACX;GAGA,QAAQ;GAER,UAAU,WAAW,EAAY,GAAG,GAAQ;GAC7C,CAAc;;CAcjB,aAAa,eACX,GACA,GACe;EACf,IAAM,EAAE,eAAY,GAAkB;AACtC,MAAI,EAAQ,SAAS,SAAS;AAC5B,SAAM,EAAe;IACnB;IACA,QAAQ;IACR,MAAM,6BAA6B,EAAe;IAClD,MAAM,EAAE,UAAO;IAChB,CAAC;AACF;;AAGF,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 ForkConversationRequest,\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 { AgentKind, 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 ProfilesService from \"../profiles-service/profiles-service.api\";\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 assertSubscriptionAuthReady,\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 type WorkspaceMode,\n} from \"../conversation-metadata-store\";\nimport { resolveTitleLlmProfile } from \"#/utils/title-llm-profile\";\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\";\n// Creating the first conversation right after a cold agent-server boot (fresh\n// machine or the packaged desktop app, where uvx may still be warming caches)\n// can exceed the client's 60s default timeout.\nconst CREATE_CONVERSATION_TIMEOUT_MS = 5 * 60 * 1000;\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_server`` is\n // the ACP provider identity (``ACPAgent.acp_server``, SDK #3692) — required so\n // the adapter can source the chip + in-conversation model list from the agent\n // when the ``acpserver`` tag is absent (a profile launch doesn't stamp it,\n // #1571). ``acp_model`` is the Canvas-configured model — preserved so the chip\n // can fall back to it when the SDK runtime model fields aren't populated.\n // Preserving these makes the wire path agree with the unit-test path that\n // builds ``DirectConversationInfo`` directly\n // (e.g. ``__tests__/api/agent-server-adapter.test.ts``).\n return {\n kind: stringOrNull(value.kind),\n acp_server: stringOrNull(value.acp_server),\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 normalizeLaunchedAgentProfile(\n value: unknown,\n): DirectConversationInfo[\"launched_agent_profile\"] {\n if (!isRecord(value)) return null;\n const { agent_profile_id: agentProfileId, revision } = value;\n if (typeof agentProfileId !== \"string\" || typeof revision !== \"number\") {\n return null;\n }\n return { agent_profile_id: agentProfileId, revision };\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 launched_agent_profile: normalizeLaunchedAgentProfile(\n item.launched_agent_profile,\n ),\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 workspaceMode?: WorkspaceMode,\n parentConversationId?: string,\n agentType?: \"default\" | \"plan\",\n sandboxId?: string,\n // Launch from a saved AgentProfile (resolved server-side) instead of the\n // current encrypted agent_settings (#3727). Supported on both local and the\n // cloud app-server (OpenHands #15060): local threads it through the\n // encrypted-settings builder; cloud sends it as a flat request field.\n agentProfileId?: string,\n agentProfileKind?: AgentKind,\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 // When launching from a profile, send `agent_profile_id`; the backend\n // resolves it to agent_settings 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 agent_profile_id: agentProfileId ?? null,\n };\n return createCloudAppConversation(request);\n }\n\n const [settings, profiles] = await Promise.all([\n SettingsService.getSettings(),\n ProfilesService.listProfiles().catch(() => undefined),\n ]);\n const titleLlmProfile = resolveTitleLlmProfile(\n settings.title_llm_profile,\n profiles,\n );\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 const resolvedWorkspaceMode =\n workspaceMode ?? (workingDirOverride ? \"local_repo\" : \"new_worktree\");\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 worktree: resolvedWorkspaceMode === \"new_worktree\",\n agentProfileId,\n agentProfileKind,\n titleLlmProfile,\n });\n\n const data = await new ConversationClient(\n getAgentServerClientOptions({ timeout: CREATE_CONVERSATION_TIMEOUT_MS }),\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 workspace_mode: resolvedWorkspaceMode,\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 * Forks a conversation, copying event history up to and including\n * `fromEventId`. Local agent-server only; needs agent-server >= 1.31.0 for\n * `from_event_id` (older backends copy the whole conversation).\n */\n static async forkConversation(\n sourceConversationId: string,\n fromEventId: string,\n title?: string,\n ): Promise<DirectConversationInfo> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n throw new Error(\n \"Branching a conversation isn't supported on the cloud backend yet.\",\n );\n }\n\n // `from_event_id` is accepted by `/fork` but not yet typed in\n // ForkConversationRequest (through client 1.32.0); the client forwards the\n // body verbatim, so cast to carry it. A title also suppresses the backend\n // auto-title, so the \"(branch)\" marker sticks.\n const data = await new ConversationClient(\n getAgentServerClientOptions(),\n ).forkConversation<DirectConversationInfo>(sourceConversationId, {\n from_event_id: fromEventId,\n ...(title ? { title } : {}),\n } as ForkConversationRequest & { from_event_id: string });\n\n // Carry over the source's client-side metadata (repo/branch/workspace/\n // profile/plugins) so the fork hydrates its chat-page badges the same way.\n const sourceMetadata = getStoredConversationMetadata(sourceConversationId);\n if (sourceMetadata) {\n setStoredConversationMetadata(data.id, sourceMetadata);\n }\n\n return data;\n }\n\n /**\n * Returns an event's `parent_id` (the fork point for branching *before* it),\n * or undefined at the root. Uses the single-event endpoint because the events\n * *search* API omits `parent_id`.\n */\n static async getEventParentId(\n conversationId: string,\n eventId: string,\n ): Promise<string | undefined> {\n const event = (await new ConversationClient(\n getAgentServerClientOptions(),\n ).getEvent(conversationId, eventId)) as { parent_id?: string | null };\n return event.parent_id ?? undefined;\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 * Cloud backends route to the app-server's per-conversation\n * `/switch_profile`, which owns the profiles and resolves the swap\n * server-side (base_url/api_key fixups, usage_id derivation, then the\n * agent-server's switch_llm) — so the client only forwards the profile name,\n * mirroring {@link switchAcpModel}.\n */\n static async switchProfile(\n conversationId: string | null,\n profileName: string,\n ): Promise<void> {\n const { backend } = getActiveBackend();\n\n if (backend.kind === \"cloud\") {\n // No conversation (home page): activate globally so the next\n // conversation starts with it. ProfilesService routes to the cloud\n // activate endpoint.\n if (!conversationId) {\n await ProfilesService.activateProfile(profileName);\n return;\n }\n await callCloudProxy({\n backend,\n method: \"POST\",\n path: `/api/v1/app-conversations/${conversationId}/switch_profile`,\n body: { profile_name: profileName },\n });\n return;\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 assertSubscriptionAuthReady({ llm: profile.config });\n await conversationClient.switchLLM(conversationId, {\n ...profile.config,\n model,\n // Keep streaming on after a switch (parity with conversation start);\n // the profile config would otherwise default it to stream=False.\n stream: true,\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 const { backend } = getActiveBackend();\n if (backend.kind === \"cloud\") {\n await callCloudProxy({\n backend,\n method: \"POST\",\n path: `/api/v1/app-conversations/${conversationId}/switch_acp_model`,\n body: { model },\n });\n return;\n }\n\n await new ConversationClient(getAgentServerClientOptions()).switchAcpModel(\n conversationId,\n model,\n );\n }\n}\n\nexport default AgentServerConversationService;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwEA,IAAM,IAAiC,4BAIjC,IAAiC,MAAS,KAC1C,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,EAAM,iBAAiB;EACtD,qBAAqB,EAAa,EAAM,oBAAoB;EAC5D,yBAAyB,EAAoB,EAAM,wBAAwB;EAC5E,GAN4B;;AAS/B,SAAS,EAAe,GAAiD;AACvE,KAAI,CAAC,EAAS,EAAM,CAAE,QAAO;CAC7B,IAAM,IAAM,EAAS,EAAM,IAAI,GAC3B,EAAE,OAAO,EAAa,EAAM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AAI,EAAQ,SAAS,SAAS;AAC5B,SAAM,EAAe;IACnB;IACA,QAAQ;IACR,MAAM,6BAA6B,EAAe;IAClD,MAAM,EAAE,UAAO;IAChB,CAAC;AACF;;AAGF,QAAM,IAAI,EAAmB,GAA6B,CAAC,CAAC,eAC1D,GACA,EACD"}
@@ -0,0 +1,2 @@
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);var e={},t=new Set,n=1;function r(n){e=n,t.forEach(e=>e())}function i(){return e}function a(e){return t.add(e),()=>{t.delete(e)}}function o(t){let i=n;return n+=1,r({...e,[t]:{status:`checking`,checkId:i}}),i}function s(t,n,i){let a=e[t];a?.status!==`checking`||a.checkId!==n||r({...e,[t]:i})}function c(t,n){r({...e,[t]:n})}function l(t){if(!(t in e))return;let{[t]:n,...i}=e;r(i)}exports.beginMcpHealthCheck=o,exports.clearMcpServerHealth=l,exports.getMcpHealthSnapshot=i,exports.resolveMcpHealthCheck=s,exports.setMcpServerHealth=c,exports.subscribeMcpHealth=a;
2
+ //# sourceMappingURL=mcp-health-store.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-health-store.cjs","names":[],"sources":["../../../src/api/mcp-health/mcp-health-store.ts"],"sourcesContent":["import type { McpServerHealth } from \"#/types/mcp-health\";\n\ntype Listener = () => void;\n\nexport type McpHealthMap = Record<string, McpServerHealth>;\n\n/**\n * In-memory MCP connection-health store, keyed by\n * `getMcpServerHealthKey(server)`. Mirrors the module-store shape of\n * `#/api/backend-registry/health-store` but is deliberately NOT persisted:\n * a health verdict is only as fresh as its probe, so a page reload resets\n * every server to \"unchecked\" instead of resurrecting a possibly-stale\n * \"healthy\".\n */\nlet healthMap: McpHealthMap = {};\nconst listeners = new Set<Listener>();\nlet nextCheckId = 1;\n\nfunction commit(next: McpHealthMap): void {\n healthMap = next;\n listeners.forEach((listener) => listener());\n}\n\nexport function getMcpHealthSnapshot(): McpHealthMap {\n return healthMap;\n}\n\nexport function subscribeMcpHealth(listener: Listener): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\n/** Mark a probe as in flight and return its id for `resolveMcpHealthCheck`. */\nexport function beginMcpHealthCheck(key: string): number {\n const checkId = nextCheckId;\n nextCheckId += 1;\n commit({ ...healthMap, [key]: { status: \"checking\", checkId } });\n return checkId;\n}\n\n/**\n * Commit a probe result, but only while the entry is still the `checking`\n * state that probe created. A slow older probe can never overwrite a newer\n * probe's result, and a probe whose server was edited, deleted, or reseeded\n * mid-flight (entry cleared or replaced) is silently dropped — a stale\n * check can never land a false verdict.\n */\nexport function resolveMcpHealthCheck(\n key: string,\n checkId: number,\n health: McpServerHealth,\n): void {\n const current = healthMap[key];\n if (current?.status !== \"checking\" || current.checkId !== checkId) {\n return;\n }\n commit({ ...healthMap, [key]: health });\n}\n\n/** Unconditional write — used to seed health from a pre-save test result. */\nexport function setMcpServerHealth(key: string, health: McpServerHealth): void {\n commit({ ...healthMap, [key]: health });\n}\n\n/** Drop the entry (back to \"unchecked\") — used when a server changes or is deleted. */\nexport function clearMcpServerHealth(key: string): void {\n if (!(key in healthMap)) return;\n const { [key]: _removed, ...rest } = healthMap;\n commit(rest);\n}\n\n/** Test-only: reset state and listeners. */\nexport function __resetMcpHealthStoreForTests(): void {\n healthMap = {};\n listeners.clear();\n nextCheckId = 1;\n}\n"],"mappings":"gDAcA,IAAI,EAA0B,EAAE,CAC1B,EAAY,IAAI,IAClB,EAAc,EAElB,SAAS,EAAO,EAA0B,CACxC,EAAY,EACZ,EAAU,QAAS,GAAa,GAAU,CAAC,CAG7C,SAAgB,GAAqC,CACnD,OAAO,EAGT,SAAgB,EAAmB,EAAgC,CAEjE,OADA,EAAU,IAAI,EAAS,KACV,CACX,EAAU,OAAO,EAAS,EAK9B,SAAgB,EAAoB,EAAqB,CACvD,IAAM,EAAU,EAGhB,MAFA,IAAe,EACf,EAAO,CAAE,GAAG,GAAY,GAAM,CAAE,OAAQ,WAAY,UAAS,CAAE,CAAC,CACzD,EAUT,SAAgB,EACd,EACA,EACA,EACM,CACN,IAAM,EAAU,EAAU,GACtB,GAAS,SAAW,YAAc,EAAQ,UAAY,GAG1D,EAAO,CAAE,GAAG,GAAY,GAAM,EAAQ,CAAC,CAIzC,SAAgB,EAAmB,EAAa,EAA+B,CAC7E,EAAO,CAAE,GAAG,GAAY,GAAM,EAAQ,CAAC,CAIzC,SAAgB,EAAqB,EAAmB,CACtD,GAAI,EAAE,KAAO,GAAY,OACzB,GAAM,EAAG,GAAM,EAAU,GAAG,GAAS,EACrC,EAAO,EAAK"}
@@ -0,0 +1,22 @@
1
+ import type { McpServerHealth } from "#/types/mcp-health";
2
+ type Listener = () => void;
3
+ export type McpHealthMap = Record<string, McpServerHealth>;
4
+ export declare function getMcpHealthSnapshot(): McpHealthMap;
5
+ export declare function subscribeMcpHealth(listener: Listener): () => void;
6
+ /** Mark a probe as in flight and return its id for `resolveMcpHealthCheck`. */
7
+ export declare function beginMcpHealthCheck(key: string): number;
8
+ /**
9
+ * Commit a probe result, but only while the entry is still the `checking`
10
+ * state that probe created. A slow older probe can never overwrite a newer
11
+ * probe's result, and a probe whose server was edited, deleted, or reseeded
12
+ * mid-flight (entry cleared or replaced) is silently dropped — a stale
13
+ * check can never land a false verdict.
14
+ */
15
+ export declare function resolveMcpHealthCheck(key: string, checkId: number, health: McpServerHealth): void;
16
+ /** Unconditional write — used to seed health from a pre-save test result. */
17
+ export declare function setMcpServerHealth(key: string, health: McpServerHealth): void;
18
+ /** Drop the entry (back to "unchecked") — used when a server changes or is deleted. */
19
+ export declare function clearMcpServerHealth(key: string): void;
20
+ /** Test-only: reset state and listeners. */
21
+ export declare function __resetMcpHealthStoreForTests(): void;
22
+ export {};
@@ -0,0 +1,45 @@
1
+ //#region src/api/mcp-health/mcp-health-store.ts
2
+ var e = {}, t = /* @__PURE__ */ new Set(), n = 1;
3
+ function r(n) {
4
+ e = n, t.forEach((e) => e());
5
+ }
6
+ function i() {
7
+ return e;
8
+ }
9
+ function a(e) {
10
+ return t.add(e), () => {
11
+ t.delete(e);
12
+ };
13
+ }
14
+ function o(t) {
15
+ let i = n;
16
+ return n += 1, r({
17
+ ...e,
18
+ [t]: {
19
+ status: "checking",
20
+ checkId: i
21
+ }
22
+ }), i;
23
+ }
24
+ function s(t, n, i) {
25
+ let a = e[t];
26
+ a?.status !== "checking" || a.checkId !== n || r({
27
+ ...e,
28
+ [t]: i
29
+ });
30
+ }
31
+ function c(t, n) {
32
+ r({
33
+ ...e,
34
+ [t]: n
35
+ });
36
+ }
37
+ function l(t) {
38
+ if (!(t in e)) return;
39
+ let { [t]: n, ...i } = e;
40
+ r(i);
41
+ }
42
+ //#endregion
43
+ export { o as beginMcpHealthCheck, l as clearMcpServerHealth, i as getMcpHealthSnapshot, s as resolveMcpHealthCheck, c as setMcpServerHealth, a as subscribeMcpHealth };
44
+
45
+ //# sourceMappingURL=mcp-health-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-health-store.js","names":[],"sources":["../../../src/api/mcp-health/mcp-health-store.ts"],"sourcesContent":["import type { McpServerHealth } from \"#/types/mcp-health\";\n\ntype Listener = () => void;\n\nexport type McpHealthMap = Record<string, McpServerHealth>;\n\n/**\n * In-memory MCP connection-health store, keyed by\n * `getMcpServerHealthKey(server)`. Mirrors the module-store shape of\n * `#/api/backend-registry/health-store` but is deliberately NOT persisted:\n * a health verdict is only as fresh as its probe, so a page reload resets\n * every server to \"unchecked\" instead of resurrecting a possibly-stale\n * \"healthy\".\n */\nlet healthMap: McpHealthMap = {};\nconst listeners = new Set<Listener>();\nlet nextCheckId = 1;\n\nfunction commit(next: McpHealthMap): void {\n healthMap = next;\n listeners.forEach((listener) => listener());\n}\n\nexport function getMcpHealthSnapshot(): McpHealthMap {\n return healthMap;\n}\n\nexport function subscribeMcpHealth(listener: Listener): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\n/** Mark a probe as in flight and return its id for `resolveMcpHealthCheck`. */\nexport function beginMcpHealthCheck(key: string): number {\n const checkId = nextCheckId;\n nextCheckId += 1;\n commit({ ...healthMap, [key]: { status: \"checking\", checkId } });\n return checkId;\n}\n\n/**\n * Commit a probe result, but only while the entry is still the `checking`\n * state that probe created. A slow older probe can never overwrite a newer\n * probe's result, and a probe whose server was edited, deleted, or reseeded\n * mid-flight (entry cleared or replaced) is silently dropped — a stale\n * check can never land a false verdict.\n */\nexport function resolveMcpHealthCheck(\n key: string,\n checkId: number,\n health: McpServerHealth,\n): void {\n const current = healthMap[key];\n if (current?.status !== \"checking\" || current.checkId !== checkId) {\n return;\n }\n commit({ ...healthMap, [key]: health });\n}\n\n/** Unconditional write — used to seed health from a pre-save test result. */\nexport function setMcpServerHealth(key: string, health: McpServerHealth): void {\n commit({ ...healthMap, [key]: health });\n}\n\n/** Drop the entry (back to \"unchecked\") — used when a server changes or is deleted. */\nexport function clearMcpServerHealth(key: string): void {\n if (!(key in healthMap)) return;\n const { [key]: _removed, ...rest } = healthMap;\n commit(rest);\n}\n\n/** Test-only: reset state and listeners. */\nexport function __resetMcpHealthStoreForTests(): void {\n healthMap = {};\n listeners.clear();\n nextCheckId = 1;\n}\n"],"mappings":";AAcA,IAAI,IAA0B,EAAE,EAC1B,oBAAY,IAAI,KAAe,EACjC,IAAc;AAElB,SAAS,EAAO,GAA0B;AAExC,CADA,IAAY,GACZ,EAAU,SAAS,MAAa,GAAU,CAAC;;AAG7C,SAAgB,IAAqC;AACnD,QAAO;;AAGT,SAAgB,EAAmB,GAAgC;AAEjE,QADA,EAAU,IAAI,EAAS,QACV;AACX,IAAU,OAAO,EAAS;;;AAK9B,SAAgB,EAAoB,GAAqB;CACvD,IAAM,IAAU;AAGhB,QAFA,KAAe,GACf,EAAO;EAAE,GAAG;GAAY,IAAM;GAAE,QAAQ;GAAY;GAAS;EAAE,CAAC,EACzD;;AAUT,SAAgB,EACd,GACA,GACA,GACM;CACN,IAAM,IAAU,EAAU;AACtB,IAAS,WAAW,cAAc,EAAQ,YAAY,KAG1D,EAAO;EAAE,GAAG;GAAY,IAAM;EAAQ,CAAC;;AAIzC,SAAgB,EAAmB,GAAa,GAA+B;AAC7E,GAAO;EAAE,GAAG;GAAY,IAAM;EAAQ,CAAC;;AAIzC,SAAgB,EAAqB,GAAmB;AACtD,KAAI,EAAE,KAAO,GAAY;CACzB,IAAM,GAAG,IAAM,GAAU,GAAG,MAAS;AACrC,GAAO,EAAK"}
@@ -0,0 +1,2 @@
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`./mcp-health-store.cjs`),t=require(`../../utils/mcp-server-health-key.cjs`),n=require(`../../utils/mcp-credential-validation.cjs`),r=require(`../../utils/redact-mcp-secrets.cjs`),i=require(`../mcp-service/mcp-service.api.cjs`);var a=/\b(401|403)\b|unauthorized|forbidden|invalid[ _-]?(token|credentials?|api[ _-]?key)/i;function o(e,t){return{status:`failed`,kind:`unknown`,error:r.redactMcpSecrets(t instanceof Error?t.message:String(t),e),checkedAt:Date.now()}}function s(e,t){let r=Date.now();if(!t.ok)return{status:`failed`,kind:(t.error_kind===`connection`||t.error_kind===`unknown`)&&a.test(t.error)?`credentials`:t.error_kind,error:t.error,checkedAt:r};let i=n.getCredentialValidationForServer(e);return{status:`healthy`,verification:i&&t.tools.includes(i.toolCall.name)&&t.tool_result&&!t.tool_result.is_error?`verified`:`connectivity-only`,toolCount:t.tools.length,checkedAt:r}}async function c(n){let r=t.getMcpServerHealthKey(n),a=e.beginMcpHealthCheck(r),c;try{c=s(n,await i.default.testServer(n))}catch(e){c=o(n,e)}e.resolveMcpHealthCheck(r,a,c)}async function l(n){let r=t.getMcpServerHealthKey(n),a=e.beginMcpHealthCheck(r);try{let t=await i.default.authorizeOAuth(n);return e.resolveMcpHealthCheck(r,a,s(n,t)),t}catch(t){return e.resolveMcpHealthCheck(r,a,o(n,t)),null}}function u(n,r,i){let a=t.getMcpServerHealthKey(n);i.some(e=>t.getMcpServerHealthKey(e)===a)||e.setMcpServerHealth(a,s(n,r))}exports.probeMcpServerHealth=c,exports.reauthorizeMcpServerHealth=l,exports.seedMcpServerHealth=u;
2
+ //# sourceMappingURL=probe-mcp-server-health.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe-mcp-server-health.cjs","names":[],"sources":["../../../src/api/mcp-health/probe-mcp-server-health.ts"],"sourcesContent":["import McpService from \"#/api/mcp-service/mcp-service.api\";\nimport type { McpServerHealth } from \"#/types/mcp-health\";\nimport type {\n ExtendedMCPTestResponse,\n MCPServerConfig,\n} from \"#/types/mcp-server\";\nimport { getCredentialValidationForServer } from \"#/utils/mcp-credential-validation\";\nimport { getMcpServerHealthKey } from \"#/utils/mcp-server-health-key\";\nimport { redactMcpSecrets } from \"#/utils/redact-mcp-secrets\";\nimport {\n beginMcpHealthCheck,\n resolveMcpHealthCheck,\n setMcpServerHealth,\n} from \"./mcp-health-store\";\n\n/**\n * Conservative auth-failure sniffing for hosted servers that reject a bad\n * token at the HTTP handshake: the backend can only classify those as\n * `connection`/`unknown` (the MCP connection itself failed), but the\n * guidance the user needs is the credentials one.\n */\nconst AUTH_FAILURE_TEXT =\n /\\b(401|403)\\b|unauthorized|forbidden|invalid[ _-]?(token|credentials?|api[ _-]?key)/i;\n\nfunction failedHealth(\n server: MCPServerConfig,\n error: unknown,\n): McpServerHealth {\n const message = error instanceof Error ? error.message : String(error);\n return {\n status: \"failed\",\n kind: \"unknown\",\n error: redactMcpSecrets(message, server),\n checkedAt: Date.now(),\n };\n}\n\n/**\n * Map a test/OAuth probe response (already secret-redacted and\n * credential-interpreted by `McpService`) to a card health state.\n *\n * `verified` requires the catalog entry's read-only probe tool to have been\n * advertised AND invoked without error; everything else that connected is\n * `connectivity-only` — truthfully labeled, never silently upgraded.\n */\nexport function interpretMcpTestResponse(\n server: MCPServerConfig,\n response: ExtendedMCPTestResponse,\n): McpServerHealth {\n const checkedAt = Date.now();\n if (!response.ok) {\n const kind =\n (response.error_kind === \"connection\" ||\n response.error_kind === \"unknown\") &&\n AUTH_FAILURE_TEXT.test(response.error)\n ? \"credentials\"\n : response.error_kind;\n return { status: \"failed\", kind, error: response.error, checkedAt };\n }\n const validation = getCredentialValidationForServer(server);\n const verified =\n !!validation &&\n response.tools.includes(validation.toolCall.name) &&\n !!response.tool_result &&\n !response.tool_result.is_error;\n return {\n status: \"healthy\",\n verification: verified ? \"verified\" : \"connectivity-only\",\n toolCount: response.tools.length,\n checkedAt,\n };\n}\n\n/** Run the non-mutating connection probe and publish the result. */\nexport async function probeMcpServerHealth(\n server: MCPServerConfig,\n): Promise<void> {\n const key = getMcpServerHealthKey(server);\n const checkId = beginMcpHealthCheck(key);\n let health: McpServerHealth;\n try {\n const response = await McpService.testServer(server);\n health = interpretMcpTestResponse(server, response);\n } catch (error) {\n health = failedHealth(server, error);\n }\n resolveMcpHealthCheck(key, checkId, health);\n}\n\n/**\n * Run the interactive OAuth authorization probe and publish the result.\n * Returns the raw response (null on transport error) so the caller can\n * persist a refreshed `oauth_state`.\n */\nexport async function reauthorizeMcpServerHealth(\n server: MCPServerConfig,\n): Promise<ExtendedMCPTestResponse | null> {\n const key = getMcpServerHealthKey(server);\n const checkId = beginMcpHealthCheck(key);\n try {\n const response = await McpService.authorizeOAuth(server);\n resolveMcpHealthCheck(\n key,\n checkId,\n interpretMcpTestResponse(server, response),\n );\n return response;\n } catch (error) {\n resolveMcpHealthCheck(key, checkId, failedHealth(server, error));\n return null;\n }\n}\n\n/**\n * Publish a just-saved server's health from the pre-save test result the\n * install/edit flow already produced (same config, moments earlier), so its\n * card shows a verdict immediately without a second probe.\n *\n * `otherServers` are the servers whose health must NOT be overwritten —\n * callers pass the pre-save list, excluding the server being saved. When a\n * same-shape duplicate exists (health keys exclude secret values, so two\n * installs of one catalog entry can collide until the save suffixes the\n * name), the seed is skipped and the new card simply starts \"unchecked\".\n */\nexport function seedMcpServerHealth(\n server: MCPServerConfig,\n response: ExtendedMCPTestResponse,\n otherServers: MCPServerConfig[],\n): void {\n const key = getMcpServerHealthKey(server);\n if (otherServers.some((other) => getMcpServerHealthKey(other) === key)) {\n return;\n }\n setMcpServerHealth(key, interpretMcpTestResponse(server, response));\n}\n"],"mappings":"oSAqBA,IAAM,EACJ,uFAEF,SAAS,EACP,EACA,EACiB,CAEjB,MAAO,CACL,OAAQ,SACR,KAAM,UACN,MAAO,EAAA,iBAJO,aAAiB,MAAQ,EAAM,QAAU,OAAO,EAAM,CAInC,EAAO,CACxC,UAAW,KAAK,KAAK,CACtB,CAWH,SAAgB,EACd,EACA,EACiB,CACjB,IAAM,EAAY,KAAK,KAAK,CAC5B,GAAI,CAAC,EAAS,GAOZ,MAAO,CAAE,OAAQ,SAAU,MALxB,EAAS,aAAe,cACvB,EAAS,aAAe,YAC1B,EAAkB,KAAK,EAAS,MAAM,CAClC,cACA,EAAS,WACkB,MAAO,EAAS,MAAO,YAAW,CAErE,IAAM,EAAa,EAAA,iCAAiC,EAAO,CAM3D,MAAO,CACL,OAAQ,UACR,aANE,GACF,EAAS,MAAM,SAAS,EAAW,SAAS,KAAK,EAC/C,EAAS,aACX,CAAC,EAAS,YAAY,SAGG,WAAa,oBACtC,UAAW,EAAS,MAAM,OAC1B,YACD,CAIH,eAAsB,EACpB,EACe,CACf,IAAM,EAAM,EAAA,sBAAsB,EAAO,CACnC,EAAU,EAAA,oBAAoB,EAAI,CACpC,EACJ,GAAI,CAEF,EAAS,EAAyB,EAAQ,MADnB,EAAA,QAAW,WAAW,EAAO,CACD,OAC5C,EAAO,CACd,EAAS,EAAa,EAAQ,EAAM,CAEtC,EAAA,sBAAsB,EAAK,EAAS,EAAO,CAQ7C,eAAsB,EACpB,EACyC,CACzC,IAAM,EAAM,EAAA,sBAAsB,EAAO,CACnC,EAAU,EAAA,oBAAoB,EAAI,CACxC,GAAI,CACF,IAAM,EAAW,MAAM,EAAA,QAAW,eAAe,EAAO,CAMxD,OALA,EAAA,sBACE,EACA,EACA,EAAyB,EAAQ,EAAS,CAC3C,CACM,QACA,EAAO,CAEd,OADA,EAAA,sBAAsB,EAAK,EAAS,EAAa,EAAQ,EAAM,CAAC,CACzD,MAeX,SAAgB,EACd,EACA,EACA,EACM,CACN,IAAM,EAAM,EAAA,sBAAsB,EAAO,CACrC,EAAa,KAAM,GAAU,EAAA,sBAAsB,EAAM,GAAK,EAAI,EAGtE,EAAA,mBAAmB,EAAK,EAAyB,EAAQ,EAAS,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { McpServerHealth } from "#/types/mcp-health";
2
+ import type { ExtendedMCPTestResponse, MCPServerConfig } from "#/types/mcp-server";
3
+ /**
4
+ * Map a test/OAuth probe response (already secret-redacted and
5
+ * credential-interpreted by `McpService`) to a card health state.
6
+ *
7
+ * `verified` requires the catalog entry's read-only probe tool to have been
8
+ * advertised AND invoked without error; everything else that connected is
9
+ * `connectivity-only` — truthfully labeled, never silently upgraded.
10
+ */
11
+ export declare function interpretMcpTestResponse(server: MCPServerConfig, response: ExtendedMCPTestResponse): McpServerHealth;
12
+ /** Run the non-mutating connection probe and publish the result. */
13
+ export declare function probeMcpServerHealth(server: MCPServerConfig): Promise<void>;
14
+ /**
15
+ * Run the interactive OAuth authorization probe and publish the result.
16
+ * Returns the raw response (null on transport error) so the caller can
17
+ * persist a refreshed `oauth_state`.
18
+ */
19
+ export declare function reauthorizeMcpServerHealth(server: MCPServerConfig): Promise<ExtendedMCPTestResponse | null>;
20
+ /**
21
+ * Publish a just-saved server's health from the pre-save test result the
22
+ * install/edit flow already produced (same config, moments earlier), so its
23
+ * card shows a verdict immediately without a second probe.
24
+ *
25
+ * `otherServers` are the servers whose health must NOT be overwritten —
26
+ * callers pass the pre-save list, excluding the server being saved. When a
27
+ * same-shape duplicate exists (health keys exclude secret values, so two
28
+ * installs of one catalog entry can collide until the save suffixes the
29
+ * name), the seed is skipped and the new card simply starts "unchecked".
30
+ */
31
+ export declare function seedMcpServerHealth(server: MCPServerConfig, response: ExtendedMCPTestResponse, otherServers: MCPServerConfig[]): void;
@@ -0,0 +1,57 @@
1
+ import { beginMcpHealthCheck as e, resolveMcpHealthCheck as t, setMcpServerHealth as n } from "./mcp-health-store.js";
2
+ import { getMcpServerHealthKey as r } from "../../utils/mcp-server-health-key.js";
3
+ import { getCredentialValidationForServer as i } from "../../utils/mcp-credential-validation.js";
4
+ import { redactMcpSecrets as a } from "../../utils/redact-mcp-secrets.js";
5
+ import o from "../mcp-service/mcp-service.api.js";
6
+ //#region src/api/mcp-health/probe-mcp-server-health.ts
7
+ var s = /\b(401|403)\b|unauthorized|forbidden|invalid[ _-]?(token|credentials?|api[ _-]?key)/i;
8
+ function c(e, t) {
9
+ return {
10
+ status: "failed",
11
+ kind: "unknown",
12
+ error: a(t instanceof Error ? t.message : String(t), e),
13
+ checkedAt: Date.now()
14
+ };
15
+ }
16
+ function l(e, t) {
17
+ let n = Date.now();
18
+ if (!t.ok) return {
19
+ status: "failed",
20
+ kind: (t.error_kind === "connection" || t.error_kind === "unknown") && s.test(t.error) ? "credentials" : t.error_kind,
21
+ error: t.error,
22
+ checkedAt: n
23
+ };
24
+ let r = i(e);
25
+ return {
26
+ status: "healthy",
27
+ verification: r && t.tools.includes(r.toolCall.name) && t.tool_result && !t.tool_result.is_error ? "verified" : "connectivity-only",
28
+ toolCount: t.tools.length,
29
+ checkedAt: n
30
+ };
31
+ }
32
+ async function u(n) {
33
+ let i = r(n), a = e(i), s;
34
+ try {
35
+ s = l(n, await o.testServer(n));
36
+ } catch (e) {
37
+ s = c(n, e);
38
+ }
39
+ t(i, a, s);
40
+ }
41
+ async function d(n) {
42
+ let i = r(n), a = e(i);
43
+ try {
44
+ let e = await o.authorizeOAuth(n);
45
+ return t(i, a, l(n, e)), e;
46
+ } catch (e) {
47
+ return t(i, a, c(n, e)), null;
48
+ }
49
+ }
50
+ function f(e, t, i) {
51
+ let a = r(e);
52
+ i.some((e) => r(e) === a) || n(a, l(e, t));
53
+ }
54
+ //#endregion
55
+ export { u as probeMcpServerHealth, d as reauthorizeMcpServerHealth, f as seedMcpServerHealth };
56
+
57
+ //# sourceMappingURL=probe-mcp-server-health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe-mcp-server-health.js","names":[],"sources":["../../../src/api/mcp-health/probe-mcp-server-health.ts"],"sourcesContent":["import McpService from \"#/api/mcp-service/mcp-service.api\";\nimport type { McpServerHealth } from \"#/types/mcp-health\";\nimport type {\n ExtendedMCPTestResponse,\n MCPServerConfig,\n} from \"#/types/mcp-server\";\nimport { getCredentialValidationForServer } from \"#/utils/mcp-credential-validation\";\nimport { getMcpServerHealthKey } from \"#/utils/mcp-server-health-key\";\nimport { redactMcpSecrets } from \"#/utils/redact-mcp-secrets\";\nimport {\n beginMcpHealthCheck,\n resolveMcpHealthCheck,\n setMcpServerHealth,\n} from \"./mcp-health-store\";\n\n/**\n * Conservative auth-failure sniffing for hosted servers that reject a bad\n * token at the HTTP handshake: the backend can only classify those as\n * `connection`/`unknown` (the MCP connection itself failed), but the\n * guidance the user needs is the credentials one.\n */\nconst AUTH_FAILURE_TEXT =\n /\\b(401|403)\\b|unauthorized|forbidden|invalid[ _-]?(token|credentials?|api[ _-]?key)/i;\n\nfunction failedHealth(\n server: MCPServerConfig,\n error: unknown,\n): McpServerHealth {\n const message = error instanceof Error ? error.message : String(error);\n return {\n status: \"failed\",\n kind: \"unknown\",\n error: redactMcpSecrets(message, server),\n checkedAt: Date.now(),\n };\n}\n\n/**\n * Map a test/OAuth probe response (already secret-redacted and\n * credential-interpreted by `McpService`) to a card health state.\n *\n * `verified` requires the catalog entry's read-only probe tool to have been\n * advertised AND invoked without error; everything else that connected is\n * `connectivity-only` — truthfully labeled, never silently upgraded.\n */\nexport function interpretMcpTestResponse(\n server: MCPServerConfig,\n response: ExtendedMCPTestResponse,\n): McpServerHealth {\n const checkedAt = Date.now();\n if (!response.ok) {\n const kind =\n (response.error_kind === \"connection\" ||\n response.error_kind === \"unknown\") &&\n AUTH_FAILURE_TEXT.test(response.error)\n ? \"credentials\"\n : response.error_kind;\n return { status: \"failed\", kind, error: response.error, checkedAt };\n }\n const validation = getCredentialValidationForServer(server);\n const verified =\n !!validation &&\n response.tools.includes(validation.toolCall.name) &&\n !!response.tool_result &&\n !response.tool_result.is_error;\n return {\n status: \"healthy\",\n verification: verified ? \"verified\" : \"connectivity-only\",\n toolCount: response.tools.length,\n checkedAt,\n };\n}\n\n/** Run the non-mutating connection probe and publish the result. */\nexport async function probeMcpServerHealth(\n server: MCPServerConfig,\n): Promise<void> {\n const key = getMcpServerHealthKey(server);\n const checkId = beginMcpHealthCheck(key);\n let health: McpServerHealth;\n try {\n const response = await McpService.testServer(server);\n health = interpretMcpTestResponse(server, response);\n } catch (error) {\n health = failedHealth(server, error);\n }\n resolveMcpHealthCheck(key, checkId, health);\n}\n\n/**\n * Run the interactive OAuth authorization probe and publish the result.\n * Returns the raw response (null on transport error) so the caller can\n * persist a refreshed `oauth_state`.\n */\nexport async function reauthorizeMcpServerHealth(\n server: MCPServerConfig,\n): Promise<ExtendedMCPTestResponse | null> {\n const key = getMcpServerHealthKey(server);\n const checkId = beginMcpHealthCheck(key);\n try {\n const response = await McpService.authorizeOAuth(server);\n resolveMcpHealthCheck(\n key,\n checkId,\n interpretMcpTestResponse(server, response),\n );\n return response;\n } catch (error) {\n resolveMcpHealthCheck(key, checkId, failedHealth(server, error));\n return null;\n }\n}\n\n/**\n * Publish a just-saved server's health from the pre-save test result the\n * install/edit flow already produced (same config, moments earlier), so its\n * card shows a verdict immediately without a second probe.\n *\n * `otherServers` are the servers whose health must NOT be overwritten —\n * callers pass the pre-save list, excluding the server being saved. When a\n * same-shape duplicate exists (health keys exclude secret values, so two\n * installs of one catalog entry can collide until the save suffixes the\n * name), the seed is skipped and the new card simply starts \"unchecked\".\n */\nexport function seedMcpServerHealth(\n server: MCPServerConfig,\n response: ExtendedMCPTestResponse,\n otherServers: MCPServerConfig[],\n): void {\n const key = getMcpServerHealthKey(server);\n if (otherServers.some((other) => getMcpServerHealthKey(other) === key)) {\n return;\n }\n setMcpServerHealth(key, interpretMcpTestResponse(server, response));\n}\n"],"mappings":";;;;;;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AmB,GAAK,EAAyB,GAAQ,EAAS,CAAC"}
@@ -1,2 +1,2 @@
1
- require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../node_modules/@openhands/typescript-client/dist/client/mcp-client.cjs`);require(`../../node_modules/@openhands/typescript-client/dist/clients.cjs`);const t=require(`../backend-registry/active-store.cjs`),n=require(`../agent-server-client-options.cjs`),r=require(`../../utils/mcp-credential-validation.cjs`),i=require(`./mcp-redacted-credentials.cjs`);var a=120;function o(e){return e.type===`stdio`?{transport:`stdio`,command:e.command,...e.args?.length&&{args:e.args},...e.env&&Object.keys(e.env).length>0&&{env:e.env}}:{transport:e.type===`sse`?`sse`:`http`,url:e.url,...e.headers&&Object.keys(e.headers).length>0&&{headers:e.headers},...e.auth?{auth:e.auth}:{}}}function s(e){return e.auth?.strategy===`oauth2`?a:e.timeout}async function c(e){let t=r.getCredentialValidationForServer(e),n=o(await i.substituteRedactedMcpCredentials(e)),a=s(e);return{server:n,...e.name?{name:e.name}:{},...a===void 0?{}:{timeout:a},...t?{tool_call:t.toolCall}:{}}}function l(){if(t.getActiveBackend().backend.kind===`local`){let{host:e,apiKey:t}=n.getAgentServerClientOptions();return{host:e,...t?{apiKey:t}:{}}}let e=t.getRegisteredBackends().find(e=>e.kind===`local`&&e.host);if(e)return{host:e.host.replace(/\/+$/,``),...e.apiKey?{apiKey:e.apiKey}:{}};throw Error(`OAuth authorization requires a reachable local backend.`)}function u(){let{host:t,apiKey:n}=l();return new e.MCPClient({host:t,...n?{apiKey:n}:{},timeout:a*1e3+5e3})}function d(e){return e.status===`succeeded`?{ok:!0,tools:e.tools??[],...e.tool_result!==void 0&&{tool_result:e.tool_result},...e.oauth_state!==void 0&&{oauth_state:e.oauth_state}}:{ok:!1,error:e.error||`OAuth authorization did not complete`,error_kind:e.error_kind||`unknown`}}var f=e=>new Promise(t=>{window.setTimeout(t,e)}),p=class i{static async testServer(i){if(t.getActiveBackend().backend.kind===`cloud`)return{ok:!0,tools:[]};let a=r.getCredentialValidationForServer(i),{host:o,apiKey:s}=n.getAgentServerClientOptions(),l=new e.MCPClient({host:o,...s?{apiKey:s}:{}});try{let e=await c(i),t=await l.testServer(e);if(t.ok&&a&&t.tool_result){let e=a.interpret(t.tool_result);if(e)return{ok:!1,error:e,error_kind:`credentials`}}return t}finally{l.close()}}static async startOAuth(e){let t=u();try{return await i.startOAuthWithClient(t,e)}finally{t.close()}}static async getOAuthStatus(e){let t=u();try{return await i.getOAuthStatusWithClient(t,e)}finally{t.close()}}static async submitOAuthCallback(e,t){let n=u();try{return await i.submitOAuthCallbackWithClient(n,e,t)}finally{n.close()}}static async authorizeOAuth(e){let t=window.open(`about:blank`,`_blank`),n=u();try{let r=await i.startOAuthWithClient(n,e);if(!r.ok||!r.job_id||!r.authorization_url)return t?.close(),{ok:!1,error:r.error||`Could not start OAuth authorization`,error_kind:r.error_kind||`unknown`};let o=await i.getOAuthStatusWithClient(n,r.job_id);for(let e=0;e<20;e+=1){if(o.status===`succeeded`||o.status===`failed`)return t?.close(),d(o);if(o.callback_ready)break;await f(250),o=await i.getOAuthStatusWithClient(n,r.job_id)}t&&(t.location.href=r.authorization_url);for(let e=0;e<a;e+=1)if(await f(1e3),o=await i.getOAuthStatusWithClient(n,r.job_id),o.status===`succeeded`||o.status===`failed`)return t?.close(),d(o);return{ok:!1,error:`OAuth authorization timed out`,error_kind:`timeout`}}finally{n.close()}}static async startOAuthWithClient(e,t){let n=await c(t);return e.startOAuth(n)}static async getOAuthStatusWithClient(e,t){return e.getOAuthStatus(t)}static async submitOAuthCallbackWithClient(e,t,n){return e.submitOAuthCallback(t,{callback_url:n})}};exports.default=p;
1
+ require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../node_modules/@openhands/typescript-client/dist/client/mcp-client.cjs`);require(`../../node_modules/@openhands/typescript-client/dist/clients.cjs`);const t=require(`../backend-registry/active-store.cjs`),n=require(`../agent-server-client-options.cjs`),r=require(`../../utils/mcp-credential-validation.cjs`),i=require(`../../utils/redact-mcp-secrets.cjs`),a=require(`./mcp-redacted-credentials.cjs`);var o=120;function s(e){return e.type===`stdio`?{transport:`stdio`,command:e.command,...e.args?.length&&{args:e.args},...e.env&&Object.keys(e.env).length>0&&{env:e.env}}:{transport:e.type===`sse`?`sse`:`http`,url:e.url,...e.headers&&Object.keys(e.headers).length>0&&{headers:e.headers},...e.auth?{auth:e.auth}:{}}}function c(e){return e.auth?.strategy===`oauth2`?o:e.timeout}async function l(e){let t=r.getCredentialValidationForServer(e),n=await a.substituteRedactedMcpCredentials(e),i=s(n),o=c(e);return{request:{server:i,...e.name?{name:e.name}:{},...o===void 0?{}:{timeout:o},...t?{tool_call:t.toolCall}:{}},substituted:n}}function u(e,t){return e.ok?e.tool_result?{...e,tool_result:{...e.tool_result,text:i.redactMcpSecrets(e.tool_result.text,...t)}}:e:{...e,error:i.redactMcpSecrets(e.error,...t)}}function d(e,t,n){let r=u(e,n);if(r.ok&&t&&r.tool_result&&r.tools.includes(t.toolCall.name)){let e=t.interpret(r.tool_result);if(e)return{ok:!1,error:e,error_kind:`credentials`}}return r}function f(){if(t.getActiveBackend().backend.kind===`local`){let{host:e,apiKey:t}=n.getAgentServerClientOptions();return{host:e,...t?{apiKey:t}:{}}}let e=t.getRegisteredBackends().find(e=>e.kind===`local`&&e.host);if(e)return{host:e.host.replace(/\/+$/,``),...e.apiKey?{apiKey:e.apiKey}:{}};throw Error(`OAuth authorization requires a reachable local backend.`)}function p(){let{host:t,apiKey:n}=f();return new e.MCPClient({host:t,...n?{apiKey:n}:{},timeout:o*1e3+5e3})}function m(e){return e.status===`succeeded`?{ok:!0,tools:e.tools??[],...e.tool_result!==void 0&&{tool_result:e.tool_result},...e.oauth_state!==void 0&&{oauth_state:e.oauth_state}}:{ok:!1,error:e.error||`OAuth authorization did not complete`,error_kind:e.error_kind||`unknown`}}var h=e=>new Promise(t=>{window.setTimeout(t,e)}),g=class i{static async testServer(i){if(t.getActiveBackend().backend.kind===`cloud`)return{ok:!0,tools:[]};let a=r.getCredentialValidationForServer(i),{host:o,apiKey:s}=n.getAgentServerClientOptions(),c=new e.MCPClient({host:o,...s?{apiKey:s}:{}});try{let{request:e,substituted:t}=await l(i);return d(await c.testServer(e),a,[t,i])}finally{c.close()}}static async startOAuth(e){let t=p();try{return await i.startOAuthWithClient(t,e)}finally{t.close()}}static async getOAuthStatus(e){let t=p();try{return await i.getOAuthStatusWithClient(t,e)}finally{t.close()}}static async submitOAuthCallback(e,t){let n=p();try{return await i.submitOAuthCallbackWithClient(n,e,t)}finally{n.close()}}static async authorizeOAuth(e){let t=r.getCredentialValidationForServer(e),n=n=>d(n,t,[e]),a=window.open(`about:blank`,`_blank`),s=p();try{let t=await i.startOAuthWithClient(s,e);if(!t.ok||!t.job_id||!t.authorization_url)return a?.close(),n({ok:!1,error:t.error||`Could not start OAuth authorization`,error_kind:t.error_kind||`unknown`});let r=await i.getOAuthStatusWithClient(s,t.job_id);for(let e=0;e<20;e+=1){if(r.status===`succeeded`||r.status===`failed`)return a?.close(),n(m(r));if(r.callback_ready)break;await h(250),r=await i.getOAuthStatusWithClient(s,t.job_id)}a&&(a.location.href=t.authorization_url);for(let e=0;e<o;e+=1)if(await h(1e3),r=await i.getOAuthStatusWithClient(s,t.job_id),r.status===`succeeded`||r.status===`failed`)return a?.close(),n(m(r));return{ok:!1,error:`OAuth authorization timed out`,error_kind:`timeout`}}finally{s.close()}}static async startOAuthWithClient(e,t){let{request:n}=await l(t);return e.startOAuth(n)}static async getOAuthStatusWithClient(e,t){return e.getOAuthStatus(t)}static async submitOAuthCallbackWithClient(e,t,n){return e.submitOAuthCallback(t,{callback_url:n})}};exports.default=g;
2
2
  //# sourceMappingURL=mcp-service.api.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-service.api.cjs","names":[],"sources":["../../../src/api/mcp-service/mcp-service.api.ts"],"sourcesContent":["import { MCPClient } from \"@openhands/typescript-client/clients\";\nimport type { MCPTestRequest } from \"@openhands/typescript-client\";\nimport { getAgentServerClientOptions } from \"../agent-server-client-options\";\nimport {\n getActiveBackend,\n getRegisteredBackends,\n} from \"../backend-registry/active-store\";\nimport { getCredentialValidationForServer } from \"#/utils/mcp-credential-validation\";\nimport type { MCPAuthCredential } from \"#/types/mcp-auth\";\nimport type {\n ExtendedMCPTestResponse,\n MCPOAuthStartResponse,\n MCPOAuthStatusResponse,\n MCPServerConfig,\n} from \"#/types/mcp-server\";\nimport { substituteRedactedMcpCredentials } from \"./mcp-redacted-credentials\";\n\nconst OAUTH_MCP_TEST_TIMEOUT_SECONDS = 120;\n\ntype MCPTestServer = {\n transport?: \"stdio\" | \"http\" | \"sse\";\n command?: string;\n args?: string[];\n env?: Record<string, string>;\n url?: string;\n headers?: Record<string, string>;\n auth?: MCPAuthCredential;\n};\n\ninterface ExtendedMCPTestRequest {\n server: MCPTestServer;\n name?: string;\n timeout?: number;\n tool_call?: {\n name: string;\n arguments: Record<string, unknown>;\n };\n}\n\nfunction toMcpServer(server: MCPServerConfig): MCPTestServer {\n if (server.type === \"stdio\") {\n return {\n transport: \"stdio\",\n command: server.command!,\n ...(server.args?.length && { args: server.args }),\n ...(server.env &&\n Object.keys(server.env).length > 0 && { env: server.env }),\n };\n }\n return {\n transport: server.type === \"sse\" ? \"sse\" : \"http\",\n url: server.url!,\n ...(server.headers &&\n Object.keys(server.headers).length > 0 && { headers: server.headers }),\n ...(server.auth ? { auth: server.auth } : {}),\n };\n}\n\nfunction getMcpTestTimeout(server: MCPServerConfig): number | undefined {\n if (server.auth?.strategy !== \"oauth2\") return server.timeout;\n return OAUTH_MCP_TEST_TIMEOUT_SECONDS;\n}\n\nasync function buildMcpTestRequest(\n server: MCPServerConfig,\n): Promise<ExtendedMCPTestRequest> {\n const validation = getCredentialValidationForServer(server);\n const serverSpec = toMcpServer(\n await substituteRedactedMcpCredentials(server),\n );\n const timeout = getMcpTestTimeout(server);\n return {\n server: serverSpec,\n ...(server.name ? { name: server.name } : {}),\n ...(timeout !== undefined ? { timeout } : {}),\n ...(validation ? { tool_call: validation.toolCall } : {}),\n };\n}\n\nfunction getMcpProbeOptions(): { host: string; apiKey?: string } {\n const active = getActiveBackend().backend;\n if (active.kind === \"local\") {\n const { host, apiKey } = getAgentServerClientOptions();\n return { host, ...(apiKey ? { apiKey } : {}) };\n }\n\n const localBackend = getRegisteredBackends().find(\n (backend) => backend.kind === \"local\" && backend.host,\n );\n if (localBackend) {\n return {\n host: localBackend.host.replace(/\\/+$/, \"\"),\n ...(localBackend.apiKey ? { apiKey: localBackend.apiKey } : {}),\n };\n }\n throw new Error(\"OAuth authorization requires a reachable local backend.\");\n}\n\nfunction createMcpProbeClient(): MCPClient {\n const { host, apiKey } = getMcpProbeOptions();\n return new MCPClient({\n host,\n ...(apiKey ? { apiKey } : {}),\n timeout: OAUTH_MCP_TEST_TIMEOUT_SECONDS * 1000 + 5000,\n });\n}\n\nfunction oauthStatusToTestResponse(\n status: MCPOAuthStatusResponse,\n): ExtendedMCPTestResponse {\n if (status.status === \"succeeded\") {\n return {\n ok: true,\n tools: status.tools ?? [],\n ...(status.tool_result !== undefined && {\n tool_result: status.tool_result,\n }),\n ...(status.oauth_state !== undefined && {\n oauth_state: status.oauth_state,\n }),\n };\n }\n return {\n ok: false,\n error: status.error || \"OAuth authorization did not complete\",\n error_kind: status.error_kind || \"unknown\",\n };\n}\n\nconst sleep = (ms: number) =>\n new Promise<void>((resolve) => {\n window.setTimeout(resolve, ms);\n });\n\nclass McpService {\n static async testServer(\n server: MCPServerConfig,\n ): Promise<ExtendedMCPTestResponse> {\n // The MCP connectivity-test endpoint lives on the local agent-server. It\n // spawns the configured stdio command / opens an SSE-or-SHTTP connection\n // from that process's environment. Cloud backends don't expose this\n // endpoint to the frontend — the MCP server would actually run inside the\n // cloud sandbox, which isn't reachable from the browser before the user\n // starts a conversation. Calling `getAgentServerClientOptions()` here for\n // a cloud-active session would throw `NoBackendAvailableError(\"No backend\n // is configured.\")` and block the install flow entirely. Short-circuit\n // with a synthetic success so saving proceeds; any real connection\n // failure surfaces inside the conversation runtime instead.\n if (getActiveBackend().backend.kind === \"cloud\") {\n return { ok: true, tools: [] };\n }\n const validation = getCredentialValidationForServer(server);\n const { host, apiKey } = getAgentServerClientOptions();\n const client = new MCPClient({ host, ...(apiKey ? { apiKey } : {}) });\n try {\n const request = await buildMcpTestRequest(server);\n const result = (await client.testServer(\n request as MCPTestRequest,\n )) as ExtendedMCPTestResponse;\n if (result.ok && validation && result.tool_result) {\n const credentialError = validation.interpret(result.tool_result);\n if (credentialError) {\n return {\n ok: false,\n error: credentialError,\n error_kind: \"credentials\",\n };\n }\n }\n return result;\n } finally {\n client.close();\n }\n }\n\n static async startOAuth(\n server: MCPServerConfig,\n ): Promise<MCPOAuthStartResponse> {\n const client = createMcpProbeClient();\n try {\n return await McpService.startOAuthWithClient(client, server);\n } finally {\n client.close();\n }\n }\n\n static async getOAuthStatus(jobId: string): Promise<MCPOAuthStatusResponse> {\n const client = createMcpProbeClient();\n try {\n return await McpService.getOAuthStatusWithClient(client, jobId);\n } finally {\n client.close();\n }\n }\n\n static async submitOAuthCallback(\n jobId: string,\n callbackUrl: string,\n ): Promise<MCPOAuthStatusResponse> {\n const client = createMcpProbeClient();\n try {\n return await McpService.submitOAuthCallbackWithClient(\n client,\n jobId,\n callbackUrl,\n );\n } finally {\n client.close();\n }\n }\n\n static async authorizeOAuth(\n server: MCPServerConfig,\n ): Promise<ExtendedMCPTestResponse> {\n const popup = window.open(\"about:blank\", \"_blank\");\n const client = createMcpProbeClient();\n try {\n const start = await McpService.startOAuthWithClient(client, server);\n if (!start.ok || !start.job_id || !start.authorization_url) {\n popup?.close();\n return {\n ok: false,\n error: start.error || \"Could not start OAuth authorization\",\n error_kind: start.error_kind || \"unknown\",\n };\n }\n\n let status = await McpService.getOAuthStatusWithClient(\n client,\n start.job_id,\n );\n for (let attempt = 0; attempt < 20; attempt += 1) {\n if (status.status === \"succeeded\" || status.status === \"failed\") {\n popup?.close();\n return oauthStatusToTestResponse(status);\n }\n if (status.callback_ready) break;\n await sleep(250);\n status = await McpService.getOAuthStatusWithClient(\n client,\n start.job_id,\n );\n }\n\n if (popup) {\n popup.location.href = start.authorization_url;\n }\n\n for (\n let attempt = 0;\n attempt < OAUTH_MCP_TEST_TIMEOUT_SECONDS;\n attempt += 1\n ) {\n await sleep(1000);\n status = await McpService.getOAuthStatusWithClient(\n client,\n start.job_id,\n );\n if (status.status === \"succeeded\" || status.status === \"failed\") {\n popup?.close();\n return oauthStatusToTestResponse(status);\n }\n }\n\n return {\n ok: false,\n error: \"OAuth authorization timed out\",\n error_kind: \"timeout\",\n };\n } finally {\n client.close();\n }\n }\n\n private static async startOAuthWithClient(\n client: MCPClient,\n server: MCPServerConfig,\n ): Promise<MCPOAuthStartResponse> {\n const request = await buildMcpTestRequest(server);\n return client.startOAuth(request as MCPTestRequest);\n }\n\n private static async getOAuthStatusWithClient(\n client: MCPClient,\n jobId: string,\n ): Promise<MCPOAuthStatusResponse> {\n return client.getOAuthStatus(jobId);\n }\n\n private static async submitOAuthCallbackWithClient(\n client: MCPClient,\n jobId: string,\n callbackUrl: string,\n ): Promise<MCPOAuthStatusResponse> {\n return client.submitOAuthCallback(jobId, { callback_url: callbackUrl });\n }\n}\n\nexport default McpService;\n"],"mappings":"qaAiBA,IAAM,EAAiC,IAsBvC,SAAS,EAAY,EAAwC,CAU3D,OATI,EAAO,OAAS,QACX,CACL,UAAW,QACX,QAAS,EAAO,QAChB,GAAI,EAAO,MAAM,QAAU,CAAE,KAAM,EAAO,KAAM,CAChD,GAAI,EAAO,KACT,OAAO,KAAK,EAAO,IAAI,CAAC,OAAS,GAAK,CAAE,IAAK,EAAO,IAAK,CAC5D,CAEI,CACL,UAAW,EAAO,OAAS,MAAQ,MAAQ,OAC3C,IAAK,EAAO,IACZ,GAAI,EAAO,SACT,OAAO,KAAK,EAAO,QAAQ,CAAC,OAAS,GAAK,CAAE,QAAS,EAAO,QAAS,CACvE,GAAI,EAAO,KAAO,CAAE,KAAM,EAAO,KAAM,CA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B,CACrC,GAAI,CACF,IAAM,EAAQ,MAAM,EAAW,qBAAqB,EAAQ,EAAO,CACnE,GAAI,CAAC,EAAM,IAAM,CAAC,EAAM,QAAU,CAAC,EAAM,kBAEvC,OADA,GAAO,OAAO,CACP,CACL,GAAI,GACJ,MAAO,EAAM,OAAS,sCACtB,WAAY,EAAM,YAAc,UACjC,CAGH,IAAI,EAAS,MAAM,EAAW,yBAC5B,EACA,EAAM,OACP,CACD,IAAK,IAAI,EAAU,EAAG,EAAU,GAAI,GAAW,EAAG,CAChD,GAAI,EAAO,SAAW,aAAe,EAAO,SAAW,SAErD,OADA,GAAO,OAAO,CACP,EAA0B,EAAO,CAE1C,GAAI,EAAO,eAAgB,MAC3B,MAAM,EAAM,IAAI,CAChB,EAAS,MAAM,EAAW,yBACxB,EACA,EAAM,OACP,CAGC,IACF,EAAM,SAAS,KAAO,EAAM,mBAG9B,IACE,IAAI,EAAU,EACd,EAAU,EACV,GAAW,EAOX,GALA,MAAM,EAAM,IAAK,CACjB,EAAS,MAAM,EAAW,yBACxB,EACA,EAAM,OACP,CACG,EAAO,SAAW,aAAe,EAAO,SAAW,SAErD,OADA,GAAO,OAAO,CACP,EAA0B,EAAO,CAI5C,MAAO,CACL,GAAI,GACJ,MAAO,gCACP,WAAY,UACb,QACO,CACR,EAAO,OAAO,EAIlB,aAAqB,qBACnB,EACA,EACgC,CAChC,IAAM,EAAU,MAAM,EAAoB,EAAO,CACjD,OAAO,EAAO,WAAW,EAA0B,CAGrD,aAAqB,yBACnB,EACA,EACiC,CACjC,OAAO,EAAO,eAAe,EAAM,CAGrC,aAAqB,8BACnB,EACA,EACA,EACiC,CACjC,OAAO,EAAO,oBAAoB,EAAO,CAAE,aAAc,EAAa,CAAC"}
1
+ {"version":3,"file":"mcp-service.api.cjs","names":[],"sources":["../../../src/api/mcp-service/mcp-service.api.ts"],"sourcesContent":["import { MCPClient } from \"@openhands/typescript-client/clients\";\nimport type { MCPTestRequest } from \"@openhands/typescript-client\";\nimport { getAgentServerClientOptions } from \"../agent-server-client-options\";\nimport {\n getActiveBackend,\n getRegisteredBackends,\n} from \"../backend-registry/active-store\";\nimport {\n getCredentialValidationForServer,\n type CredentialValidation,\n} from \"#/utils/mcp-credential-validation\";\nimport type { MCPAuthCredential } from \"#/types/mcp-auth\";\nimport type {\n ExtendedMCPTestResponse,\n MCPOAuthStartResponse,\n MCPOAuthStatusResponse,\n MCPServerConfig,\n} from \"#/types/mcp-server\";\nimport { redactMcpSecrets } from \"#/utils/redact-mcp-secrets\";\nimport { substituteRedactedMcpCredentials } from \"./mcp-redacted-credentials\";\n\nconst OAUTH_MCP_TEST_TIMEOUT_SECONDS = 120;\n\ntype MCPTestServer = {\n transport?: \"stdio\" | \"http\" | \"sse\";\n command?: string;\n args?: string[];\n env?: Record<string, string>;\n url?: string;\n headers?: Record<string, string>;\n auth?: MCPAuthCredential;\n};\n\ninterface ExtendedMCPTestRequest {\n server: MCPTestServer;\n name?: string;\n timeout?: number;\n tool_call?: {\n name: string;\n arguments: Record<string, unknown>;\n };\n}\n\nfunction toMcpServer(server: MCPServerConfig): MCPTestServer {\n if (server.type === \"stdio\") {\n return {\n transport: \"stdio\",\n command: server.command!,\n ...(server.args?.length && { args: server.args }),\n ...(server.env &&\n Object.keys(server.env).length > 0 && { env: server.env }),\n };\n }\n return {\n transport: server.type === \"sse\" ? \"sse\" : \"http\",\n url: server.url!,\n ...(server.headers &&\n Object.keys(server.headers).length > 0 && { headers: server.headers }),\n ...(server.auth ? { auth: server.auth } : {}),\n };\n}\n\nfunction getMcpTestTimeout(server: MCPServerConfig): number | undefined {\n if (server.auth?.strategy !== \"oauth2\") return server.timeout;\n return OAUTH_MCP_TEST_TIMEOUT_SECONDS;\n}\n\nasync function buildMcpTestRequest(server: MCPServerConfig): Promise<{\n request: ExtendedMCPTestRequest;\n substituted: MCPServerConfig;\n}> {\n const validation = getCredentialValidationForServer(server);\n const substituted = await substituteRedactedMcpCredentials(server);\n const serverSpec = toMcpServer(substituted);\n const timeout = getMcpTestTimeout(server);\n return {\n request: {\n server: serverSpec,\n ...(server.name ? { name: server.name } : {}),\n ...(timeout !== undefined ? { timeout } : {}),\n ...(validation ? { tool_call: validation.toolCall } : {}),\n },\n substituted,\n };\n}\n\nfunction redactMcpTestResponse(\n result: ExtendedMCPTestResponse,\n redactionSources: (MCPServerConfig | undefined)[],\n): ExtendedMCPTestResponse {\n if (!result.ok) {\n return {\n ...result,\n error: redactMcpSecrets(result.error, ...redactionSources),\n };\n }\n if (result.tool_result) {\n return {\n ...result,\n tool_result: {\n ...result.tool_result,\n text: redactMcpSecrets(result.tool_result.text, ...redactionSources),\n },\n };\n }\n return result;\n}\n\n/**\n * Display-boundary post-processing shared by the test and OAuth probes:\n * scrub secrets from error/tool-result text, then let the catalog entry's\n * credential validation turn a failed read-only tool call into a\n * `credentials` failure. The interpretation only runs when the probe tool\n * is actually advertised in `tools` — a server variant that doesn't expose\n * the tool (e.g. a hosted alternative to the stdio server the spec was\n * written for) must degrade to a connectivity-only success, not be\n * misreported as bad credentials.\n */\nfunction finalizeMcpTestResponse(\n result: ExtendedMCPTestResponse,\n validation: CredentialValidation | undefined,\n redactionSources: (MCPServerConfig | undefined)[],\n): ExtendedMCPTestResponse {\n const redacted = redactMcpTestResponse(result, redactionSources);\n if (\n redacted.ok &&\n validation &&\n redacted.tool_result &&\n redacted.tools.includes(validation.toolCall.name)\n ) {\n const credentialError = validation.interpret(redacted.tool_result);\n if (credentialError) {\n return {\n ok: false,\n error: credentialError,\n error_kind: \"credentials\",\n };\n }\n }\n return redacted;\n}\n\nfunction getMcpProbeOptions(): { host: string; apiKey?: string } {\n const active = getActiveBackend().backend;\n if (active.kind === \"local\") {\n const { host, apiKey } = getAgentServerClientOptions();\n return { host, ...(apiKey ? { apiKey } : {}) };\n }\n\n const localBackend = getRegisteredBackends().find(\n (backend) => backend.kind === \"local\" && backend.host,\n );\n if (localBackend) {\n return {\n host: localBackend.host.replace(/\\/+$/, \"\"),\n ...(localBackend.apiKey ? { apiKey: localBackend.apiKey } : {}),\n };\n }\n throw new Error(\"OAuth authorization requires a reachable local backend.\");\n}\n\nfunction createMcpProbeClient(): MCPClient {\n const { host, apiKey } = getMcpProbeOptions();\n return new MCPClient({\n host,\n ...(apiKey ? { apiKey } : {}),\n timeout: OAUTH_MCP_TEST_TIMEOUT_SECONDS * 1000 + 5000,\n });\n}\n\nfunction oauthStatusToTestResponse(\n status: MCPOAuthStatusResponse,\n): ExtendedMCPTestResponse {\n if (status.status === \"succeeded\") {\n return {\n ok: true,\n tools: status.tools ?? [],\n ...(status.tool_result !== undefined && {\n tool_result: status.tool_result,\n }),\n ...(status.oauth_state !== undefined && {\n oauth_state: status.oauth_state,\n }),\n };\n }\n return {\n ok: false,\n error: status.error || \"OAuth authorization did not complete\",\n error_kind: status.error_kind || \"unknown\",\n };\n}\n\nconst sleep = (ms: number) =>\n new Promise<void>((resolve) => {\n window.setTimeout(resolve, ms);\n });\n\nclass McpService {\n static async testServer(\n server: MCPServerConfig,\n ): Promise<ExtendedMCPTestResponse> {\n // The MCP connectivity-test endpoint lives on the local agent-server. It\n // spawns the configured stdio command / opens an SSE-or-SHTTP connection\n // from that process's environment. Cloud backends don't expose this\n // endpoint to the frontend — the MCP server would actually run inside the\n // cloud sandbox, which isn't reachable from the browser before the user\n // starts a conversation. Calling `getAgentServerClientOptions()` here for\n // a cloud-active session would throw `NoBackendAvailableError(\"No backend\n // is configured.\")` and block the install flow entirely. Short-circuit\n // with a synthetic success so saving proceeds; any real connection\n // failure surfaces inside the conversation runtime instead.\n if (getActiveBackend().backend.kind === \"cloud\") {\n return { ok: true, tools: [] };\n }\n const validation = getCredentialValidationForServer(server);\n const { host, apiKey } = getAgentServerClientOptions();\n const client = new MCPClient({ host, ...(apiKey ? { apiKey } : {}) });\n try {\n const { request, substituted } = await buildMcpTestRequest(server);\n const result = (await client.testServer(\n request as MCPTestRequest,\n )) as ExtendedMCPTestResponse;\n // Redact against both config forms: `server` may hold fresh plaintext\n // input, `substituted` the stored (encrypted) round-trip values.\n return finalizeMcpTestResponse(result, validation, [substituted, server]);\n } finally {\n client.close();\n }\n }\n\n static async startOAuth(\n server: MCPServerConfig,\n ): Promise<MCPOAuthStartResponse> {\n const client = createMcpProbeClient();\n try {\n return await McpService.startOAuthWithClient(client, server);\n } finally {\n client.close();\n }\n }\n\n static async getOAuthStatus(jobId: string): Promise<MCPOAuthStatusResponse> {\n const client = createMcpProbeClient();\n try {\n return await McpService.getOAuthStatusWithClient(client, jobId);\n } finally {\n client.close();\n }\n }\n\n static async submitOAuthCallback(\n jobId: string,\n callbackUrl: string,\n ): Promise<MCPOAuthStatusResponse> {\n const client = createMcpProbeClient();\n try {\n return await McpService.submitOAuthCallbackWithClient(\n client,\n jobId,\n callbackUrl,\n );\n } finally {\n client.close();\n }\n }\n\n static async authorizeOAuth(\n server: MCPServerConfig,\n ): Promise<ExtendedMCPTestResponse> {\n const validation = getCredentialValidationForServer(server);\n const finalize = (result: ExtendedMCPTestResponse) =>\n finalizeMcpTestResponse(result, validation, [server]);\n const popup = window.open(\"about:blank\", \"_blank\");\n const client = createMcpProbeClient();\n try {\n const start = await McpService.startOAuthWithClient(client, server);\n if (!start.ok || !start.job_id || !start.authorization_url) {\n popup?.close();\n return finalize({\n ok: false,\n error: start.error || \"Could not start OAuth authorization\",\n error_kind: start.error_kind || \"unknown\",\n });\n }\n\n let status = await McpService.getOAuthStatusWithClient(\n client,\n start.job_id,\n );\n for (let attempt = 0; attempt < 20; attempt += 1) {\n if (status.status === \"succeeded\" || status.status === \"failed\") {\n popup?.close();\n return finalize(oauthStatusToTestResponse(status));\n }\n if (status.callback_ready) break;\n await sleep(250);\n status = await McpService.getOAuthStatusWithClient(\n client,\n start.job_id,\n );\n }\n\n if (popup) {\n popup.location.href = start.authorization_url;\n }\n\n for (\n let attempt = 0;\n attempt < OAUTH_MCP_TEST_TIMEOUT_SECONDS;\n attempt += 1\n ) {\n await sleep(1000);\n status = await McpService.getOAuthStatusWithClient(\n client,\n start.job_id,\n );\n if (status.status === \"succeeded\" || status.status === \"failed\") {\n popup?.close();\n return finalize(oauthStatusToTestResponse(status));\n }\n }\n\n return {\n ok: false,\n error: \"OAuth authorization timed out\",\n error_kind: \"timeout\",\n };\n } finally {\n client.close();\n }\n }\n\n private static async startOAuthWithClient(\n client: MCPClient,\n server: MCPServerConfig,\n ): Promise<MCPOAuthStartResponse> {\n const { request } = await buildMcpTestRequest(server);\n return client.startOAuth(request as MCPTestRequest);\n }\n\n private static async getOAuthStatusWithClient(\n client: MCPClient,\n jobId: string,\n ): Promise<MCPOAuthStatusResponse> {\n return client.getOAuthStatus(jobId);\n }\n\n private static async submitOAuthCallbackWithClient(\n client: MCPClient,\n jobId: string,\n callbackUrl: string,\n ): Promise<MCPOAuthStatusResponse> {\n return client.submitOAuthCallback(jobId, { callback_url: callbackUrl });\n }\n}\n\nexport default McpService;\n"],"mappings":"qdAqBA,IAAM,EAAiC,IAsBvC,SAAS,EAAY,EAAwC,CAU3D,OATI,EAAO,OAAS,QACX,CACL,UAAW,QACX,QAAS,EAAO,QAChB,GAAI,EAAO,MAAM,QAAU,CAAE,KAAM,EAAO,KAAM,CAChD,GAAI,EAAO,KACT,OAAO,KAAK,EAAO,IAAI,CAAC,OAAS,GAAK,CAAE,IAAK,EAAO,IAAK,CAC5D,CAEI,CACL,UAAW,EAAO,OAAS,MAAQ,MAAQ,OAC3C,IAAK,EAAO,IACZ,GAAI,EAAO,SACT,OAAO,KAAK,EAAO,QAAQ,CAAC,OAAS,GAAK,CAAE,QAAS,EAAO,QAAS,CACvE,GAAI,EAAO,KAAO,CAAE,KAAM,EAAO,KAAM,CAAG,EAAE,CAC7C,CAGH,SAAS,EAAkB,EAA6C,CAEtE,OADI,EAAO,MAAM,WAAa,SACvB,EADwC,EAAO,QAIxD,eAAe,EAAoB,EAGhC,CACD,IAAM,EAAa,EAAA,iCAAiC,EAAO,CACrD,EAAc,MAAM,EAAA,iCAAiC,EAAO,CAC5D,EAAa,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