@openhands/agent-canvas 1.0.0-alpha.8 → 1.0.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +17 -6
  2. package/build/assets/{add-backend-modal-KMmPQNZU.js → add-backend-modal-FsnpTTgO.js} +1 -1
  3. package/build/assets/{agent-server-conversation-service.api-DSl9G5UR.js → agent-server-conversation-service.api-BZmUqtiO.js} +1 -1
  4. package/build/assets/{automation-detail-g5-RZ0da.js → automation-detail-R-99FUce.js} +1 -1
  5. package/build/assets/{automations-list-DHoq_0MM.js → automations-list-Dfu2c-_D.js} +1 -1
  6. package/build/assets/backend-form-modal-DxYjqqAK.js +1 -0
  7. package/build/assets/browser-HrYc5Gce.js +5 -0
  8. package/build/assets/conversation--ldUK72N.js +19 -0
  9. package/build/assets/conversation-eNrhH94O.js +1 -0
  10. package/build/assets/conversation-panel-B49Jpqpb.js +1 -0
  11. package/build/assets/{conversation-service.api-C8pYCyV6.js → conversation-service.api--f8WglOC.js} +1 -1
  12. package/build/assets/conversation-websocket-context-BW68-J8o.js +3 -0
  13. package/build/assets/{entry.client-D9uR9Blz.js → entry.client-CqqXOSvd.js} +2 -2
  14. package/build/assets/{files-tab-B3A1NDlZ.js → files-tab-CQHdWpQt.js} +1 -1
  15. package/build/assets/git-control-bar-branch-button-C8u5rzjc.js +27 -0
  16. package/build/assets/{git-provider-icon-DYE9n7fs.js → git-provider-icon-D-a-rcLm.js} +1 -1
  17. package/build/assets/{home-dIzxi5Dd.js → home-DD0GroCu.js} +1 -1
  18. package/build/assets/{launch-hZ0ifhcV.js → launch-B2mbfOSm.js} +1 -1
  19. package/build/assets/llm-settings-BEyqixPI.js +1 -0
  20. package/build/assets/{llm-settings-CcHqGOYL.js → llm-settings-BdiaGFbg.js} +1 -1
  21. package/build/assets/{manage-backends-modal-rYeyGx7j.js → manage-backends-modal-s22zCdEW.js} +1 -1
  22. package/build/assets/{manifest-97e839da.js → manifest-9d1c34fb.js} +1 -1
  23. package/build/assets/{messages-T2ewVkbp.js → messages-6aOyUu3r.js} +1 -1
  24. package/build/assets/{path-utils-CqJboYxo.js → path-utils-BVbe598W.js} +1 -1
  25. package/build/assets/{planner-tab-BrntFmb1.js → planner-tab-bN6r1G-1.js} +1 -1
  26. package/build/assets/{recommended-automations-launcher-BI9NhG8Y.js → recommended-automations-launcher-mJhK6Atl.js} +1 -1
  27. package/build/assets/{root-BS1Td78t.js → root-3t9rxEpE.js} +2 -2
  28. package/build/assets/{root-layout-BLjAEgle.js → root-layout-BjVwHmta.js} +2 -2
  29. package/build/assets/{shared-conversation-a0QV8o99.js → shared-conversation-EZV0FRIf.js} +1 -1
  30. package/build/assets/{sidebar-mobile-menu-toggle-DTUNI1WQ.js → sidebar-mobile-menu-toggle-BnbzzpQl.js} +1 -1
  31. package/build/assets/{skills-settings-DOnMn9q1.js → skills-settings-CG2hu34D.js} +1 -1
  32. package/build/assets/{task-list-tab-Day9nhRT.js → task-list-tab-465DDju0.js} +1 -1
  33. package/build/assets/{terminal-ro4SNjUU.js → terminal-CcgBEVnC.js} +1 -1
  34. package/build/assets/{use-active-conversation-D15D9GgR.js → use-active-conversation-DS5j9R4q.js} +1 -1
  35. package/build/assets/{use-agent-state-DE5dlEXJ.js → use-agent-state-D2C9SeGw.js} +1 -1
  36. package/build/assets/{use-create-conversation-DW7AGgLA.js → use-create-conversation-BEZg__Vv.js} +1 -1
  37. package/build/assets/{use-event-store-CQZCcVz-.js → use-event-store-BT_gV3ut.js} +1 -1
  38. package/build/assets/{use-handle-plan-click-DpgEQDAV.js → use-handle-plan-click-uOpew2LO.js} +1 -1
  39. package/build/assets/{use-runtime-is-ready-XFbT16BD.js → use-runtime-is-ready-pGSbPddC.js} +1 -1
  40. package/build/assets/{use-skills-Xe0vjPMt.js → use-skills-BIvlWblA.js} +1 -1
  41. package/build/assets/{use-task-list-Bs90uF2N.js → use-task-list-DDeNHprj.js} +1 -1
  42. package/build/assets/{use-unified-vscode-url-BOsIOd-b.js → use-unified-vscode-url-wAMzv8Sn.js} +1 -1
  43. package/build/assets/{use-user-conversation-Mc0mQgkl.js → use-user-conversation-B_zDoSeh.js} +1 -1
  44. package/build/assets/{vscode-tab-C0ShhiSU.js → vscode-tab-B0vdh9gU.js} +1 -1
  45. package/build/index.html +4 -4
  46. package/dist/api/agent-server-adapter.cjs +1 -1
  47. package/dist/api/agent-server-adapter.cjs.map +1 -1
  48. package/dist/api/agent-server-adapter.js +1 -0
  49. package/dist/api/agent-server-adapter.js.map +1 -1
  50. package/dist/api/skills-service.cjs +1 -1
  51. package/dist/api/skills-service.cjs.map +1 -1
  52. package/dist/api/skills-service.d.ts +1 -1
  53. package/dist/api/skills-service.js +2 -2
  54. package/dist/api/skills-service.js.map +1 -1
  55. package/dist/components/features/backends/backend-form-modal.cjs +1 -1
  56. package/dist/components/features/backends/backend-form-modal.cjs.map +1 -1
  57. package/dist/components/features/backends/backend-form-modal.js +149 -142
  58. package/dist/components/features/backends/backend-form-modal.js.map +1 -1
  59. package/dist/components/features/conversation-panel/skills-modal.cjs +1 -1
  60. package/dist/components/features/conversation-panel/skills-modal.cjs.map +1 -1
  61. package/dist/components/features/conversation-panel/skills-modal.js +1 -1
  62. package/dist/components/features/conversation-panel/skills-modal.js.map +1 -1
  63. package/dist/contexts/conversation-websocket-context.cjs +3 -3
  64. package/dist/contexts/conversation-websocket-context.cjs.map +1 -1
  65. package/dist/contexts/conversation-websocket-context.js +97 -89
  66. package/dist/contexts/conversation-websocket-context.js.map +1 -1
  67. package/dist/hooks/chat/use-slash-command.cjs +1 -1
  68. package/dist/hooks/chat/use-slash-command.cjs.map +1 -1
  69. package/dist/hooks/chat/use-slash-command.js +1 -1
  70. package/dist/hooks/chat/use-slash-command.js.map +1 -1
  71. package/dist/hooks/query/use-conversation-skills.cjs +2 -0
  72. package/dist/hooks/query/use-conversation-skills.cjs.map +1 -0
  73. package/dist/hooks/query/use-conversation-skills.d.ts +7 -0
  74. package/dist/hooks/query/use-conversation-skills.js +8 -0
  75. package/dist/hooks/query/use-conversation-skills.js.map +1 -0
  76. package/dist/hooks/query/use-skills.cjs +1 -1
  77. package/dist/hooks/query/use-skills.cjs.map +1 -1
  78. package/dist/hooks/query/use-skills.d.ts +6 -1
  79. package/dist/hooks/query/use-skills.js +3 -3
  80. package/dist/hooks/query/use-skills.js.map +1 -1
  81. package/dist/package.cjs +1 -1
  82. package/dist/package.cjs.map +1 -1
  83. package/dist/package.js +3 -3
  84. package/dist/package.js.map +1 -1
  85. package/dist/routes/conversation.cjs +1 -1
  86. package/dist/routes/conversation.cjs.map +1 -1
  87. package/dist/routes/conversation.js +61 -63
  88. package/dist/routes/conversation.js.map +1 -1
  89. package/dist/stores/use-event-store.cjs +1 -1
  90. package/dist/stores/use-event-store.cjs.map +1 -1
  91. package/dist/stores/use-event-store.d.ts +22 -0
  92. package/dist/stores/use-event-store.js +9 -1
  93. package/dist/stores/use-event-store.js.map +1 -1
  94. package/dist/ui/context-menu.d.ts +1 -1
  95. package/dist/ui/help-link.d.ts +1 -1
  96. package/package.json +3 -3
  97. package/scripts/dev-safe.mjs +35 -17
  98. package/scripts/dev-with-automation.mjs +24 -49
  99. package/build/assets/backend-form-modal-K6IMCr3p.js +0 -1
  100. package/build/assets/browser-DKG63inJ.js +0 -5
  101. package/build/assets/conversation-BD5WemJI.js +0 -19
  102. package/build/assets/conversation-C47K62n8.js +0 -1
  103. package/build/assets/conversation-panel-Dn-S56Gk.js +0 -1
  104. package/build/assets/conversation-websocket-context-Ywrxd_9p.js +0 -3
  105. package/build/assets/git-control-bar-branch-button-CcIpmyfM.js +0 -27
  106. package/build/assets/llm-settings-2036m7Wt.js +0 -1
  107. /package/build/assets/{link-external-Df8J52xI.js → link-external-C9d6Fo3x.js} +0 -0
  108. /package/build/assets/{use-llm-profiles-D3-KXwQ0.js → use-llm-profiles-O4a9V6RC.js} +0 -0
@@ -5,13 +5,13 @@ import { getAgentServerClientOptions as r } from "./agent-server-client-options.
5
5
  import { fetchCloudSkills as i } from "./cloud/skills-service.api.js";
6
6
  //#region src/api/skills-service.ts
7
7
  var a = class {
8
- static async getSkills() {
8
+ static async getSkills(a) {
9
9
  return t().backend.kind === "cloud" ? i() : (await new n(r()).getSkills({
10
10
  load_public: !0,
11
11
  load_user: !0,
12
12
  load_project: !0,
13
13
  load_org: !1,
14
- project_dir: e()
14
+ project_dir: a ?? e()
15
15
  })).skills ?? [];
16
16
  }
17
17
  };
@@ -1 +1 @@
1
- {"version":3,"file":"skills-service.js","names":[],"sources":["../../src/api/skills-service.ts"],"sourcesContent":["import { SkillsClient } from \"@openhands/typescript-client/clients\";\nimport { SkillInfo } from \"#/types/settings\";\nimport { getAgentServerWorkingDir } from \"./agent-server-config\";\nimport { getActiveBackend } from \"./backend-registry/active-store\";\nimport { fetchCloudSkills } from \"./cloud/skills-service.api\";\nimport { getAgentServerClientOptions } from \"./agent-server-client-options\";\n\nclass SkillsService {\n static async getSkills(): Promise<SkillInfo[]> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return fetchCloudSkills();\n }\n\n // Always load public skills on the global Skills settings page so the user\n // sees the available catalog even on a fresh dev environment with no local\n // user/project skills. Conversation creation paths still gate on\n // shouldLoadPublicSkills() to keep new-conversation latency low.\n const response = await new SkillsClient(\n getAgentServerClientOptions(),\n ).getSkills({\n load_public: true,\n load_user: true,\n load_project: true,\n load_org: false,\n project_dir: getAgentServerWorkingDir(),\n });\n\n return (response.skills ?? []) as SkillInfo[];\n }\n}\n\nexport default SkillsService;\n"],"mappings":";;;;;;AAOA,IAAM,IAAN,MAAoB;CAClB,aAAa,YAAkC;AAmB7C,SAlBI,GAAkB,CAAC,QAAQ,SAAS,UAC/B,GAAkB,IAiBnB,MAVe,IAAI,EACzB,GAA6B,CAC9B,CAAC,UAAU;GACV,aAAa;GACb,WAAW;GACX,cAAc;GACd,UAAU;GACV,aAAa,GAA0B;GACxC,CAAC,EAEe,UAAU,EAAE"}
1
+ {"version":3,"file":"skills-service.js","names":[],"sources":["../../src/api/skills-service.ts"],"sourcesContent":["import { SkillsClient } from \"@openhands/typescript-client/clients\";\nimport { SkillInfo } from \"#/types/settings\";\nimport { getAgentServerWorkingDir } from \"./agent-server-config\";\nimport { getActiveBackend } from \"./backend-registry/active-store\";\nimport { fetchCloudSkills } from \"./cloud/skills-service.api\";\nimport { getAgentServerClientOptions } from \"./agent-server-client-options\";\n\nclass SkillsService {\n static async getSkills(projectDir?: string): Promise<SkillInfo[]> {\n if (getActiveBackend().backend.kind === \"cloud\") {\n return fetchCloudSkills();\n }\n\n // Always load public skills on the global Skills settings page so the user\n // sees the available catalog even on a fresh dev environment with no local\n // user/project skills. Conversation creation paths still gate on\n // shouldLoadPublicSkills() to keep new-conversation latency low.\n const response = await new SkillsClient(\n getAgentServerClientOptions(),\n ).getSkills({\n load_public: true,\n load_user: true,\n load_project: true,\n load_org: false,\n project_dir: projectDir ?? getAgentServerWorkingDir(),\n });\n\n return (response.skills ?? []) as SkillInfo[];\n }\n}\n\nexport default SkillsService;\n"],"mappings":";;;;;;AAOA,IAAM,IAAN,MAAoB;CAClB,aAAa,UAAU,GAA2C;AAmBhE,SAlBI,GAAkB,CAAC,QAAQ,SAAS,UAC/B,GAAkB,IAiBnB,MAVe,IAAI,EACzB,GAA6B,CAC9B,CAAC,UAAU;GACV,aAAa;GACb,WAAW;GACX,cAAc;GACd,UAAU;GACV,aAAa,KAAc,GAA0B;GACtD,CAAC,EAEe,UAAU,EAAE"}
@@ -1,2 +1,2 @@
1
- const e=require(`../../../_virtual/_rolldown/runtime.cjs`),t=require(`../../../node_modules/react-i18next/dist/es/useTranslation.cjs`),n=require(`../../../i18n/declaration.cjs`),r=require(`../../../utils/utils.cjs`),i=require(`../../../contexts/active-backend-context.cjs`),a=require(`../../../node_modules/@openhands/typescript-client/dist/client/server-client.cjs`),o=require(`../../../node_modules/@tanstack/react-query/build/modern/useQuery.cjs`),s=require(`../../../api/agent-server-client-options.cjs`),c=require(`../../shared/modals/modal-backdrop.cjs`),l=require(`../../shared/modals/modal-body.cjs`),u=require(`../../shared/modals/modal-close-button.cjs`),d=require(`../settings/brand-button.cjs`),f=require(`../settings/settings-input.cjs`),p=require(`../../../hooks/query/use-backends-health.cjs`),m=require(`../../../assets/branding/openhands-logo-white.cjs`),h=require(`../../../icons/chevron-down-small.cjs`),g=require(`./backend-status-dot.cjs`),_=require(`./device-flow-auth.cjs`);let v=require(`react`);v=e.__toESM(v,1);let y=require(`react/jsx-runtime`);function b(e){let t=e.trim().toLowerCase();return t.includes(`all-hands.dev`)||t.includes(`openhands.dev`)?`cloud`:`local`}function x(e){let t=e.toLowerCase().replace(/^\[|\]$/g,``);return!!(t===`localhost`||t===`::1`||t===`::`||t===`0.0.0.0`||/^127\./.test(t)||/^::ffff:127\./i.test(t)||/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[01])\./.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)||/^f[cd][0-9a-f]{2}:/i.test(t)||t.endsWith(`.local`)||!t.includes(`.`)&&!t.includes(`:`))}function S(e){let t=e.trim().replace(/\/+$/,``);if(!t)return``;if(/^https?:\/\//i.test(t))return t;let n=t.match(/^\[([^\]]+)\]/);return`${x(n?n[1]:(t.match(/:/g)??[]).length>1?t:t.split(`:`)[0])?`http`:`https`}://${t}`}function C(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=S(t);if(!n)return!1;try{let e=new URL(n);return(e.protocol===`http:`||e.protocol===`https:`)&&e.hostname.length>0}catch{return!1}}var w=`https://app.all-hands.dev`;function T({backend:e,testIdRoot:r}){let{t:i}=t.useTranslation(`openhands`),c=p.useBackendsHealth([e])[e.id],l=c?.isConnected??null,u=c?.disabled===!0,d=c?.consecutiveFailures??0,f=c?.lastError??null,{data:m}=o.useQuery({queryKey:[`backend-version`,e.host,e.apiKey],queryFn:async()=>(await new a.ServerClient(s.getAgentServerClientOptions({host:e.host,sessionApiKey:e.apiKey||null,timeout:5e3})).getServerInfo()).version??null,retry:!1,staleTime:6e4,enabled:e.kind===`local`&&!u}),h;h=i(l===!0?n.I18nKey.ONBOARDING$BACKEND_STATUS_CONNECTED:l===!1?n.I18nKey.ONBOARDING$BACKEND_STATUS_DISCONNECTED:n.I18nKey.ONBOARDING$BACKEND_STATUS_CHECKING);let _=e.kind===`cloud`?i(n.I18nKey.BACKEND$KIND_CLOUD):i(n.I18nKey.BACKEND$KIND_LOCAL);return(0,y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,y.jsxs)(`div`,{"data-testid":`${r}-status`,className:`flex items-center gap-3 text-sm`,children:[(0,y.jsx)(g.BackendStatusDot,{isConnected:l}),(0,y.jsx)(`span`,{className:`text-white`,"data-testid":`${r}-status-label`,children:h}),(0,y.jsx)(`span`,{className:`text-tertiary-alt`,children:`·`}),(0,y.jsx)(`span`,{className:`text-[var(--oh-text-tertiary)]`,children:_}),m?(0,y.jsx)(`span`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`${r}-version`,children:i(n.I18nKey.BACKEND$VERSION_LABEL,{version:m})}):null]}),u?(0,y.jsxs)(`div`,{"data-testid":`${r}-status-error`,className:`flex flex-col gap-1 rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm`,children:[(0,y.jsx)(`span`,{className:`font-semibold text-red-300`,children:i(n.I18nKey.BACKEND$HEALTH_FAILED_TITLE)}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--oh-text-tertiary)]`,children:i(n.I18nKey.BACKEND$HEALTH_FAILED_DETAIL,{count:d})}),f?(0,y.jsx)(`span`,{"data-testid":`${r}-status-error-message`,className:`text-xs text-red-300 whitespace-pre-wrap break-words`,children:f}):null]}):null]})}function E({mode:e,backend:r,onSubmitted:a,renderActions:o,testIdRoot:s}){let{t:c}=t.useTranslation(`openhands`),{addBackend:l,updateBackend:u}=i.useActiveBackendContext(),[p,m]=v.default.useState(r?.name??``),[h,g]=v.default.useState(r?.host??``),[_,x]=v.default.useState(r?.apiKey??``),[E,D]=v.default.useState(!1),[O,k]=v.default.useState(!1),A=b(h),j=s??(e===`edit`?`edit-backend`:`add-backend`),M=p.trim().length>0&&C(h)&&(A===`local`||_.trim().length>0),N=E&&!p.trim()?c(n.I18nKey.BACKEND$NAME_REQUIRED):void 0,P=O?h.trim()?C(h)?void 0:c(n.I18nKey.BACKEND$HOST_INVALID):c(n.I18nKey.BACKEND$HOST_REQUIRED):void 0;return(0,y.jsxs)(`form`,{"data-testid":`${j}-form`,onSubmit:t=>{if(t.preventDefault(),!M){D(!0),k(!0);return}let n={name:p.trim(),host:S(h),apiKey:_.trim(),kind:A};e===`edit`&&r?u(r.id,n):l(n),a()},className:`flex flex-col gap-4`,children:[(0,y.jsx)(f.SettingsInput,{testId:`${j}-name`,name:`${j}-name`,type:`text`,label:c(n.I18nKey.BACKEND$NAME_LABEL),value:p,onChange:m,onBlur:()=>D(!0),placeholder:`Production`,className:`w-full`,showRequiredTag:!0,error:N}),(0,y.jsx)(f.SettingsInput,{testId:`${j}-host`,name:`${j}-host`,type:`text`,label:c(n.I18nKey.BACKEND$HOST_LABEL),value:h,onChange:g,onBlur:()=>k(!0),placeholder:w,className:`w-full`,showRequiredTag:!0,error:P}),(0,y.jsx)(f.SettingsInput,{testId:`${j}-api-key`,name:`${j}-api-key`,type:`password`,label:c(n.I18nKey.BACKEND$KEY_LABEL),value:_,onChange:x,placeholder:``,className:`w-full`}),e===`edit`&&r&&(0,y.jsx)(T,{backend:r,testIdRoot:j}),o?o({canSubmit:M,testIdRoot:j}):(0,y.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2 w-full`,children:[(0,y.jsx)(d.BrandButton,{type:`button`,variant:`secondary`,onClick:a,testId:`${j}-cancel`,children:c(n.I18nKey.BUTTON$CANCEL)}),(0,y.jsx)(d.BrandButton,{type:`submit`,variant:`primary`,isDisabled:!M,testId:`${j}-submit`,children:c(n.I18nKey.BACKEND$SAVE)})]})]})}function D({onClose:e}){let{t:r}=t.useTranslation(`openhands`),{addBackend:a}=i.useActiveBackendContext(),[o,s]=v.default.useState(``),[c,l]=v.default.useState(``),[u,p]=v.default.useState(``),m=b(c),h=o.trim().length>0&&C(c)&&(m===`local`||u.trim().length>0);return(0,y.jsxs)(`form`,{"data-testid":`add-backend-form`,onSubmit:t=>{t.preventDefault(),h&&(a({name:o.trim(),host:S(c),apiKey:u.trim(),kind:m}),e())},className:`flex flex-col gap-4 flex-1 min-w-0`,children:[(0,y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,y.jsx)(f.SettingsInput,{testId:`add-backend-name`,name:`add-backend-name`,type:`text`,label:r(n.I18nKey.BACKEND$NAME_LABEL),value:o,onChange:s,placeholder:`e.g. My Server`,className:`w-full`}),(0,y.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,children:r(n.I18nKey.BACKEND$NAME_HELPER)})]}),(0,y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,y.jsx)(f.SettingsInput,{testId:`add-backend-host`,name:`add-backend-host`,type:`text`,label:r(n.I18nKey.BACKEND$HOST_LABEL),value:c,onChange:l,placeholder:`http://localhost:8000`,className:`w-full`}),(0,y.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`add-backend-host-helper`,children:r(n.I18nKey.BACKEND$HOST_HELPER)})]}),(0,y.jsx)(f.SettingsInput,{testId:`add-backend-api-key`,name:`add-backend-api-key`,type:`password`,label:r(n.I18nKey.BACKEND$KEY_LABEL),value:u,onChange:p,placeholder:`sk-••••••••••`,className:`w-full`}),(0,y.jsx)(d.BrandButton,{type:`submit`,variant:`secondary`,isDisabled:!h,testId:`add-backend-submit`,className:`w-full text-center`,children:r(n.I18nKey.BACKEND$CONNECT)})]})}function O({onClose:e}){let{t:a}=t.useTranslation(`openhands`),{addBackend:o}=i.useActiveBackendContext(),[s,c]=v.default.useState(!1),[l,u]=v.default.useState(``),d=l.trim()||w;return(0,y.jsxs)(`div`,{className:`flex flex-1 min-w-0 flex-col items-center gap-3`,children:[(0,y.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,y.jsx)(m.default,{width:56,height:56,"aria-hidden":!0}),(0,y.jsx)(`h4`,{className:`text-lg font-medium text-white`,"data-testid":`add-backend-cloud-title`,children:a(n.I18nKey.BACKEND$CLOUD_TITLE)})]}),(0,y.jsx)(`p`,{className:`text-center text-sm leading-relaxed text-[var(--oh-muted)]`,children:a(n.I18nKey.BACKEND$CLOUD_DESCRIPTION)}),(0,y.jsx)(_.DeviceFlowAuth,{host:d,onSuccess:t=>{o({name:`OpenHands Cloud`,host:S(d),apiKey:t,kind:`cloud`}),e()},testIdRoot:`add-backend`}),(0,y.jsxs)(`div`,{className:`w-full`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:()=>c(e=>!e),"aria-expanded":s,"data-testid":`add-backend-advanced-toggle`,className:`flex w-full cursor-pointer items-center justify-center gap-1 text-center text-xs text-[var(--oh-muted)] transition-colors hover:text-content-2`,children:[(0,y.jsx)(`span`,{children:a(n.I18nKey.BACKEND$ADVANCED)}),(0,y.jsx)(h.default,{className:r.cn(`h-4 w-4 shrink-0 text-muted transition-transform`,s&&`rotate-180`),"aria-hidden":!0})]}),(0,y.jsxs)(`div`,{className:r.cn(`pt-2`,!s&&`pointer-events-none invisible`),"aria-hidden":!s,children:[(0,y.jsx)(f.SettingsInput,{testId:`add-backend-cloud-host`,name:`add-backend-cloud-host`,type:`text`,label:a(n.I18nKey.BACKEND$HOST_LABEL),value:l,onChange:u,placeholder:w,className:`w-full`}),(0,y.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oh-muted)]`,children:a(n.I18nKey.BACKEND$LOGIN_CLOUD_HINT)})]})]})]})}function k({mode:e,backend:i,onClose:a}){let{t:o}=t.useTranslation(`openhands`);if(e===`add`)return(0,y.jsx)(c.ModalBackdrop,{onClose:a,closeOnEscape:!1,"aria-label":o(n.I18nKey.BACKEND$ADD_TITLE),children:(0,y.jsxs)(`div`,{"data-testid":`add-backend-modal`,className:r.cn(`relative rounded-xl border border-[var(--oh-border)] bg-base-secondary`,l.modalWidthClassName(`xl`),l.MODAL_MAX_WIDTH_VIEWPORT),children:[(0,y.jsx)(u.ModalCloseButton,{onClose:a,testId:`add-backend-close`}),(0,y.jsx)(`div`,{className:`px-6 pt-6 pb-2 pr-12`,children:(0,y.jsx)(`h2`,{className:`text-lg font-semibold`,children:o(n.I18nKey.BACKEND$ADD_TITLE)})}),(0,y.jsxs)(`div`,{className:`flex gap-6 px-6 pb-6 pt-2`,children:[(0,y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,y.jsx)(D,{onClose:a})}),(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center`,children:[(0,y.jsx)(`div`,{className:`flex-1 w-px bg-[var(--oh-border)]`}),(0,y.jsx)(`span`,{className:`py-3 text-xs uppercase text-[var(--oh-muted)]`,children:o(n.I18nKey.BACKEND$LOGIN_OR)}),(0,y.jsx)(`div`,{className:`flex-1 w-px bg-[var(--oh-border)]`})]}),(0,y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,y.jsx)(O,{onClose:a})})]})]})});let s=`edit-backend`;return(0,y.jsx)(c.ModalBackdrop,{onClose:a,closeOnEscape:!1,"aria-label":o(n.I18nKey.BACKEND$EDIT_TITLE),children:(0,y.jsxs)(`div`,{"data-testid":`${s}-modal`,className:r.cn(`relative bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]`,l.modalWidthClassName(`md`)),children:[(0,y.jsx)(u.ModalCloseButton,{onClose:a,testId:`${s}-close`}),(0,y.jsx)(`h2`,{className:`pr-6 text-lg font-semibold`,children:o(n.I18nKey.BACKEND$EDIT_TITLE)}),(0,y.jsx)(E,{mode:`edit`,backend:i,onSubmitted:a,testIdRoot:s})]})})}exports.BackendFormModal=k;
1
+ const e=require(`../../../_virtual/_rolldown/runtime.cjs`),t=require(`../../../node_modules/react-i18next/dist/es/useTranslation.cjs`),n=require(`../../../i18n/declaration.cjs`),r=require(`../../../utils/utils.cjs`),i=require(`../../../context/navigation-context.cjs`),a=require(`../../../contexts/active-backend-context.cjs`),o=require(`../../../node_modules/@openhands/typescript-client/dist/client/server-client.cjs`),s=require(`../../../node_modules/@tanstack/react-query/build/modern/useQuery.cjs`),c=require(`../../../api/agent-server-client-options.cjs`),l=require(`../../shared/modals/modal-backdrop.cjs`),u=require(`../../shared/modals/modal-body.cjs`),d=require(`../../shared/modals/modal-close-button.cjs`),f=require(`../settings/brand-button.cjs`),p=require(`../settings/settings-input.cjs`),m=require(`../../../hooks/query/use-backends-health.cjs`),h=require(`../../../assets/branding/openhands-logo-white.cjs`),g=require(`../../../icons/chevron-down-small.cjs`),_=require(`./backend-status-dot.cjs`),v=require(`./device-flow-auth.cjs`);let y=require(`react`);y=e.__toESM(y,1);let b=require(`react/jsx-runtime`);function x(e){let t=e.trim().toLowerCase();return t.includes(`all-hands.dev`)||t.includes(`openhands.dev`)?`cloud`:`local`}function S(e){let t=e.toLowerCase().replace(/^\[|\]$/g,``);return!!(t===`localhost`||t===`::1`||t===`::`||t===`0.0.0.0`||/^127\./.test(t)||/^::ffff:127\./i.test(t)||/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[01])\./.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)||/^f[cd][0-9a-f]{2}:/i.test(t)||t.endsWith(`.local`)||!t.includes(`.`)&&!t.includes(`:`))}function C(e){let t=e.trim().replace(/\/+$/,``);if(!t)return``;if(/^https?:\/\//i.test(t))return t;let n=t.match(/^\[([^\]]+)\]/);return`${S(n?n[1]:(t.match(/:/g)??[]).length>1?t:t.split(`:`)[0])?`http`:`https`}://${t}`}function w(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=C(t);if(!n)return!1;try{let e=new URL(n);return(e.protocol===`http:`||e.protocol===`https:`)&&e.hostname.length>0}catch{return!1}}var T=`https://app.all-hands.dev`;function E({backend:e,testIdRoot:r}){let{t:i}=t.useTranslation(`openhands`),a=m.useBackendsHealth([e])[e.id],l=a?.isConnected??null,u=a?.disabled===!0,d=a?.consecutiveFailures??0,f=a?.lastError??null,{data:p}=s.useQuery({queryKey:[`backend-version`,e.host,e.apiKey],queryFn:async()=>(await new o.ServerClient(c.getAgentServerClientOptions({host:e.host,sessionApiKey:e.apiKey||null,timeout:5e3})).getServerInfo()).version??null,retry:!1,staleTime:6e4,enabled:e.kind===`local`&&!u}),h;h=i(l===!0?n.I18nKey.ONBOARDING$BACKEND_STATUS_CONNECTED:l===!1?n.I18nKey.ONBOARDING$BACKEND_STATUS_DISCONNECTED:n.I18nKey.ONBOARDING$BACKEND_STATUS_CHECKING);let g=e.kind===`cloud`?i(n.I18nKey.BACKEND$KIND_CLOUD):i(n.I18nKey.BACKEND$KIND_LOCAL);return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsxs)(`div`,{"data-testid":`${r}-status`,className:`flex items-center gap-3 text-sm`,children:[(0,b.jsx)(_.BackendStatusDot,{isConnected:l}),(0,b.jsx)(`span`,{className:`text-white`,"data-testid":`${r}-status-label`,children:h}),(0,b.jsx)(`span`,{className:`text-tertiary-alt`,children:`·`}),(0,b.jsx)(`span`,{className:`text-[var(--oh-text-tertiary)]`,children:g}),p?(0,b.jsx)(`span`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`${r}-version`,children:i(n.I18nKey.BACKEND$VERSION_LABEL,{version:p})}):null]}),u?(0,b.jsxs)(`div`,{"data-testid":`${r}-status-error`,className:`flex flex-col gap-1 rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm`,children:[(0,b.jsx)(`span`,{className:`font-semibold text-red-300`,children:i(n.I18nKey.BACKEND$HEALTH_FAILED_TITLE)}),(0,b.jsx)(`span`,{className:`text-xs text-[var(--oh-text-tertiary)]`,children:i(n.I18nKey.BACKEND$HEALTH_FAILED_DETAIL,{count:d})}),f?(0,b.jsx)(`span`,{"data-testid":`${r}-status-error-message`,className:`text-xs text-red-300 whitespace-pre-wrap break-words`,children:f}):null]}):null]})}function D({mode:e,backend:r,onSubmitted:i,renderActions:o,testIdRoot:s}){let{t:c}=t.useTranslation(`openhands`),{addBackend:l,updateBackend:u}=a.useActiveBackendContext(),[d,m]=y.default.useState(r?.name??``),[h,g]=y.default.useState(r?.host??``),[_,v]=y.default.useState(r?.apiKey??``),[S,D]=y.default.useState(!1),[O,k]=y.default.useState(!1),A=x(h),j=s??(e===`edit`?`edit-backend`:`add-backend`),M=d.trim().length>0&&w(h)&&(A===`local`||_.trim().length>0),N=S&&!d.trim()?c(n.I18nKey.BACKEND$NAME_REQUIRED):void 0,P=O?h.trim()?w(h)?void 0:c(n.I18nKey.BACKEND$HOST_INVALID):c(n.I18nKey.BACKEND$HOST_REQUIRED):void 0;return(0,b.jsxs)(`form`,{"data-testid":`${j}-form`,onSubmit:t=>{if(t.preventDefault(),!M){D(!0),k(!0);return}let n={name:d.trim(),host:C(h),apiKey:_.trim(),kind:A};e===`edit`&&r?u(r.id,n):l(n),i()},className:`flex flex-col gap-4`,children:[(0,b.jsx)(p.SettingsInput,{testId:`${j}-name`,name:`${j}-name`,type:`text`,label:c(n.I18nKey.BACKEND$NAME_LABEL),value:d,onChange:m,onBlur:()=>D(!0),placeholder:`Production`,className:`w-full`,showRequiredTag:!0,error:N}),(0,b.jsx)(p.SettingsInput,{testId:`${j}-host`,name:`${j}-host`,type:`text`,label:c(n.I18nKey.BACKEND$HOST_LABEL),value:h,onChange:g,onBlur:()=>k(!0),placeholder:T,className:`w-full`,showRequiredTag:!0,error:P}),(0,b.jsx)(p.SettingsInput,{testId:`${j}-api-key`,name:`${j}-api-key`,type:`password`,label:c(n.I18nKey.BACKEND$KEY_LABEL),value:_,onChange:v,placeholder:``,className:`w-full`}),e===`edit`&&r&&(0,b.jsx)(E,{backend:r,testIdRoot:j}),o?o({canSubmit:M,testIdRoot:j}):(0,b.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2 w-full`,children:[(0,b.jsx)(f.BrandButton,{type:`button`,variant:`secondary`,onClick:i,testId:`${j}-cancel`,children:c(n.I18nKey.BUTTON$CANCEL)}),(0,b.jsx)(f.BrandButton,{type:`submit`,variant:`primary`,isDisabled:!M,testId:`${j}-submit`,children:c(n.I18nKey.BACKEND$SAVE)})]})]})}function O(){let{currentPath:e,navigate:t}=i.useNavigation();return y.default.useCallback(()=>{/^\/automations\/[^/]+/.test(e)?t(`/automations`):/^\/conversations\/[^/]+/.test(e)&&t(`/conversations`)},[e,t])}function k({onClose:e}){let{t:r}=t.useTranslation(`openhands`),{addBackend:i}=a.useActiveBackendContext(),o=O(),[s,c]=y.default.useState(``),[l,u]=y.default.useState(``),[d,m]=y.default.useState(``),h=x(l),g=s.trim().length>0&&w(l)&&(h===`local`||d.trim().length>0);return(0,b.jsxs)(`form`,{"data-testid":`add-backend-form`,onSubmit:t=>{t.preventDefault(),g&&(i({name:s.trim(),host:C(l),apiKey:d.trim(),kind:h}),o(),e())},className:`flex flex-col gap-4 flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(p.SettingsInput,{testId:`add-backend-name`,name:`add-backend-name`,type:`text`,label:r(n.I18nKey.BACKEND$NAME_LABEL),value:s,onChange:c,placeholder:`e.g. My Server`,className:`w-full`}),(0,b.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,children:r(n.I18nKey.BACKEND$NAME_HELPER)})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(p.SettingsInput,{testId:`add-backend-host`,name:`add-backend-host`,type:`text`,label:r(n.I18nKey.BACKEND$HOST_LABEL),value:l,onChange:u,placeholder:`http://localhost:8000`,className:`w-full`}),(0,b.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`add-backend-host-helper`,children:r(n.I18nKey.BACKEND$HOST_HELPER)})]}),(0,b.jsx)(p.SettingsInput,{testId:`add-backend-api-key`,name:`add-backend-api-key`,type:`password`,label:r(n.I18nKey.BACKEND$KEY_LABEL),value:d,onChange:m,placeholder:`sk-••••••••••`,className:`w-full`}),(0,b.jsx)(f.BrandButton,{type:`submit`,variant:`secondary`,isDisabled:!g,testId:`add-backend-submit`,className:`w-full text-center`,children:r(n.I18nKey.BACKEND$CONNECT)})]})}function A({onClose:e}){let{t:i}=t.useTranslation(`openhands`),{addBackend:o}=a.useActiveBackendContext(),s=O(),[c,l]=y.default.useState(!1),[u,d]=y.default.useState(``),f=u.trim()||T;return(0,b.jsxs)(`div`,{className:`flex flex-1 min-w-0 flex-col items-center gap-3`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,b.jsx)(h.default,{width:56,height:56,"aria-hidden":!0}),(0,b.jsx)(`h4`,{className:`text-lg font-medium text-white`,"data-testid":`add-backend-cloud-title`,children:i(n.I18nKey.BACKEND$CLOUD_TITLE)})]}),(0,b.jsx)(`p`,{className:`text-center text-sm leading-relaxed text-[var(--oh-muted)]`,children:i(n.I18nKey.BACKEND$CLOUD_DESCRIPTION)}),(0,b.jsx)(v.DeviceFlowAuth,{host:f,onSuccess:t=>{o({name:`OpenHands Cloud`,host:C(f),apiKey:t,kind:`cloud`}),s(),e()},testIdRoot:`add-backend`}),(0,b.jsxs)(`div`,{className:`w-full`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,"data-testid":`add-backend-advanced-toggle`,className:`flex w-full cursor-pointer items-center justify-center gap-1 text-center text-xs text-[var(--oh-muted)] transition-colors hover:text-content-2`,children:[(0,b.jsx)(`span`,{children:i(n.I18nKey.BACKEND$ADVANCED)}),(0,b.jsx)(g.default,{className:r.cn(`h-4 w-4 shrink-0 text-muted transition-transform`,c&&`rotate-180`),"aria-hidden":!0})]}),(0,b.jsxs)(`div`,{className:r.cn(`pt-2`,!c&&`pointer-events-none invisible`),"aria-hidden":!c,children:[(0,b.jsx)(p.SettingsInput,{testId:`add-backend-cloud-host`,name:`add-backend-cloud-host`,type:`text`,label:i(n.I18nKey.BACKEND$HOST_LABEL),value:u,onChange:d,placeholder:T,className:`w-full`}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oh-muted)]`,children:i(n.I18nKey.BACKEND$LOGIN_CLOUD_HINT)})]})]})]})}function j({mode:e,backend:i,onClose:a}){let{t:o}=t.useTranslation(`openhands`);if(e===`add`)return(0,b.jsx)(l.ModalBackdrop,{onClose:a,closeOnEscape:!1,"aria-label":o(n.I18nKey.BACKEND$ADD_TITLE),children:(0,b.jsxs)(`div`,{"data-testid":`add-backend-modal`,className:r.cn(`relative rounded-xl border border-[var(--oh-border)] bg-base-secondary`,u.modalWidthClassName(`xl`),u.MODAL_MAX_WIDTH_VIEWPORT),children:[(0,b.jsx)(d.ModalCloseButton,{onClose:a,testId:`add-backend-close`}),(0,b.jsx)(`div`,{className:`px-6 pt-6 pb-2 pr-12`,children:(0,b.jsx)(`h2`,{className:`text-lg font-semibold`,children:o(n.I18nKey.BACKEND$ADD_TITLE)})}),(0,b.jsxs)(`div`,{className:`flex gap-6 px-6 pb-6 pt-2`,children:[(0,b.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,b.jsx)(k,{onClose:a})}),(0,b.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center`,children:[(0,b.jsx)(`div`,{className:`flex-1 w-px bg-[var(--oh-border)]`}),(0,b.jsx)(`span`,{className:`py-3 text-xs uppercase text-[var(--oh-muted)]`,children:o(n.I18nKey.BACKEND$LOGIN_OR)}),(0,b.jsx)(`div`,{className:`flex-1 w-px bg-[var(--oh-border)]`})]}),(0,b.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,b.jsx)(A,{onClose:a})})]})]})});let s=`edit-backend`;return(0,b.jsx)(l.ModalBackdrop,{onClose:a,closeOnEscape:!1,"aria-label":o(n.I18nKey.BACKEND$EDIT_TITLE),children:(0,b.jsxs)(`div`,{"data-testid":`${s}-modal`,className:r.cn(`relative bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]`,u.modalWidthClassName(`md`)),children:[(0,b.jsx)(d.ModalCloseButton,{onClose:a,testId:`${s}-close`}),(0,b.jsx)(`h2`,{className:`pr-6 text-lg font-semibold`,children:o(n.I18nKey.BACKEND$EDIT_TITLE)}),(0,b.jsx)(D,{mode:`edit`,backend:i,onSubmitted:a,testIdRoot:s})]})})}exports.BackendFormModal=j;
2
2
  //# sourceMappingURL=backend-form-modal.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"backend-form-modal.cjs","names":[],"sources":["../../../../src/components/features/backends/backend-form-modal.tsx"],"sourcesContent":["import React from \"react\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useTranslation } from \"react-i18next\";\nimport { ServerClient } from \"@openhands/typescript-client/clients\";\nimport OpenHandsLogoWhite from \"#/assets/branding/openhands-logo-white.svg?react\";\nimport { ModalBackdrop } from \"#/components/shared/modals/modal-backdrop\";\nimport {\n MODAL_MAX_WIDTH_VIEWPORT,\n modalWidthClassName,\n} from \"#/components/shared/modals/modal-body\";\nimport { ModalCloseButton } from \"#/components/shared/modals/modal-close-button\";\nimport { BrandButton } from \"#/components/features/settings/brand-button\";\nimport { SettingsInput } from \"#/components/features/settings/settings-input\";\nimport { useActiveBackendContext } from \"#/contexts/active-backend-context\";\nimport { useBackendsHealth } from \"#/hooks/query/use-backends-health\";\nimport { getAgentServerClientOptions } from \"#/api/agent-server-client-options\";\nimport ChevronDownSmallIcon from \"#/icons/chevron-down-small.svg?react\";\nimport { I18nKey } from \"#/i18n/declaration\";\nimport type { Backend, BackendKind } from \"#/api/backend-registry/types\";\nimport { cn } from \"#/utils/utils\";\nimport { BackendStatusDot } from \"./backend-status-dot\";\nimport { DeviceFlowAuth } from \"./device-flow-auth\";\n\nexport type BackendFormMode = \"add\" | \"edit\";\n\ninterface BackendFormModalProps {\n mode: BackendFormMode;\n /** Required when `mode === \"edit\"`. */\n backend?: Backend;\n onClose: () => void;\n}\n\nfunction inferKindFromHost(host: string): BackendKind {\n const trimmed = host.trim().toLowerCase();\n if (trimmed.includes(\"all-hands.dev\") || trimmed.includes(\"openhands.dev\")) {\n return \"cloud\";\n }\n return \"local\";\n}\n\n/**\n * Returns true for hostnames that represent a local / private-network address.\n * Used by normalizeHost to choose http:// instead of https://.\n */\nfunction isLocalAddress(hostname: string): boolean {\n // Strip IPv6 bracket notation: [::1] → ::1\n const h = hostname.toLowerCase().replace(/^\\[|\\]$/g, \"\");\n // IPv6 loopback, any-address, and named loopback\n if (h === \"localhost\" || h === \"::1\" || h === \"::\" || h === \"0.0.0.0\")\n return true;\n // 127.x.x.x loopback range + IPv4-mapped loopback (::ffff:127.x.x.x)\n if (/^127\\./.test(h) || /^::ffff:127\\./i.test(h)) return true;\n // RFC 1918 private ranges\n if (/^10\\./.test(h)) return true;\n if (/^192\\.168\\./.test(h)) return true;\n if (/^172\\.(1[6-9]|2\\d|3[01])\\./.test(h)) return true;\n // IPv6 link-local (fe80::/10) and unique local (fc00::/7)\n if (/^fe[89ab][0-9a-f]:/i.test(h)) return true;\n if (/^f[cd][0-9a-f]{2}:/i.test(h)) return true;\n // mDNS / Bonjour (.local)\n if (h.endsWith(\".local\")) return true;\n // Single-label hostnames (no dots, no colons) are local network names.\n // Colons are excluded so bare IPv6 addresses don't accidentally match.\n if (!h.includes(\".\") && !h.includes(\":\")) return true;\n return false;\n}\n\nfunction normalizeHost(host: string): string {\n const trimmed = host.trim().replace(/\\/+$/, \"\");\n if (!trimmed) return \"\";\n // Already has an explicit scheme — respect it.\n if (/^https?:\\/\\//i.test(trimmed)) return trimmed;\n // Extract the pure hostname for scheme selection, handling three cases:\n // [::1]:8080 → bracket IPv6 notation → extract ::1\n // ::1 → bare IPv6 (multiple colons, no bracket) → whole string\n // host:port → regular host:port → part before the colon\n const bracketMatch = trimmed.match(/^\\[([^\\]]+)\\]/);\n const hostname = bracketMatch\n ? bracketMatch[1]\n : (trimmed.match(/:/g) ?? []).length > 1\n ? trimmed\n : trimmed.split(\":\")[0];\n const scheme = isLocalAddress(hostname) ? \"http\" : \"https\";\n return `${scheme}://${trimmed}`;\n}\n\n/**\n * Returns true when `host` represents a reachable backend URL.\n *\n * Rules (applied in order):\n * 1. Must be non-empty after trimming.\n * 2. Must contain no whitespace — spaces can never appear in a host/port.\n * 3. After normalisation (bare hosts get `https://` prepended), must parse\n * as a valid http or https URL with a non-empty hostname.\n */\nfunction isValidHostUrl(host: string): boolean {\n const trimmed = host.trim();\n if (!trimmed) return false;\n // Spaces anywhere in the input are an immediate rejection.\n if (/\\s/.test(trimmed)) return false;\n const normalized = normalizeHost(trimmed);\n if (!normalized) return false;\n try {\n const url = new URL(normalized);\n return (\n (url.protocol === \"http:\" || url.protocol === \"https:\") &&\n url.hostname.length > 0\n );\n } catch {\n return false;\n }\n}\n\nconst DEFAULT_OPENHANDS_CLOUD_HOST = \"https://app.all-hands.dev\";\n\n/**\n * Live status row for the edit form: shows a connection dot, a\n * \"Local\"/\"Cloud\" label, and the agent server's reported version when\n * available. Replaces the legacy local/cloud radio fieldset (kind is\n * now inferred from the host).\n */\nfunction BackendStatusBadge({\n backend,\n testIdRoot,\n}: {\n backend: Backend;\n testIdRoot: string;\n}) {\n const { t } = useTranslation(\"openhands\");\n const healthByBackendId = useBackendsHealth([backend]);\n const health = healthByBackendId[backend.id];\n const isConnected = health?.isConnected ?? null;\n const disabled = health?.disabled === true;\n const consecutiveFailures = health?.consecutiveFailures ?? 0;\n const lastError = health?.lastError ?? null;\n\n const { data: version } = useQuery({\n queryKey: [\"backend-version\", backend.host, backend.apiKey],\n queryFn: async () => {\n const info = await new ServerClient(\n getAgentServerClientOptions({\n host: backend.host,\n sessionApiKey: backend.apiKey || null,\n timeout: 5000,\n }),\n ).getServerInfo();\n return info.version ?? null;\n },\n retry: false,\n staleTime: 60_000,\n enabled: backend.kind === \"local\" && !disabled,\n });\n\n let statusLabel: string;\n if (isConnected === true) {\n statusLabel = t(I18nKey.ONBOARDING$BACKEND_STATUS_CONNECTED);\n } else if (isConnected === false) {\n statusLabel = t(I18nKey.ONBOARDING$BACKEND_STATUS_DISCONNECTED);\n } else {\n statusLabel = t(I18nKey.ONBOARDING$BACKEND_STATUS_CHECKING);\n }\n\n const kindLabel =\n backend.kind === \"cloud\"\n ? t(I18nKey.BACKEND$KIND_CLOUD)\n : t(I18nKey.BACKEND$KIND_LOCAL);\n\n return (\n <div className=\"flex flex-col gap-2\">\n <div\n data-testid={`${testIdRoot}-status`}\n className=\"flex items-center gap-3 text-sm\"\n >\n <BackendStatusDot isConnected={isConnected} />\n <span className=\"text-white\" data-testid={`${testIdRoot}-status-label`}>\n {statusLabel}\n </span>\n <span className=\"text-tertiary-alt\">·</span>\n <span className=\"text-[var(--oh-text-tertiary)]\">{kindLabel}</span>\n {version ? (\n <span\n className=\"text-xs text-[var(--oh-muted)]\"\n data-testid={`${testIdRoot}-version`}\n >\n {t(I18nKey.BACKEND$VERSION_LABEL, { version })}\n </span>\n ) : null}\n </div>\n\n {disabled ? (\n <div\n data-testid={`${testIdRoot}-status-error`}\n className=\"flex flex-col gap-1 rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm\"\n >\n <span className=\"font-semibold text-red-300\">\n {t(I18nKey.BACKEND$HEALTH_FAILED_TITLE)}\n </span>\n <span className=\"text-xs text-[var(--oh-text-tertiary)]\">\n {t(I18nKey.BACKEND$HEALTH_FAILED_DETAIL, {\n count: consecutiveFailures,\n })}\n </span>\n {lastError ? (\n <span\n data-testid={`${testIdRoot}-status-error-message`}\n className=\"text-xs text-red-300 whitespace-pre-wrap break-words\"\n >\n {lastError}\n </span>\n ) : null}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport interface BackendFormProps {\n mode: BackendFormMode;\n /** Required when `mode === \"edit\"`. */\n backend?: Backend;\n /**\n * Called after the form is submitted and the backend has been\n * persisted. Use this to dismiss a containing modal, advance an\n * onboarding step, etc.\n */\n onSubmitted: () => void;\n /**\n * Optional render slot rendered in place of the default\n * Save / Cancel button row, so callers (e.g. the onboarding flow)\n * can re-skin the action area while still owning submission via the\n * standard `<form onSubmit>` flow. Receives the form's submit-ready\n * state.\n */\n renderActions?: (state: {\n canSubmit: boolean;\n testIdRoot: string;\n }) => React.ReactNode;\n /** Used to disambiguate test ids across the same screen. */\n testIdRoot?: string;\n}\n\n/**\n * Reusable form body for adding / editing a backend. Renders the\n * common name / host / API-key inputs plus the kind selector\n * (radio buttons in `add` mode, status badge in `edit` mode).\n *\n * Rendered as a `<form>`, so consumers should put any extra controls\n * either inside `renderActions` or as siblings inside a wrapping\n * element — but submission flows through the standard form submit so\n * Enter-to-submit still works.\n */\nexport function BackendForm({\n mode,\n backend,\n onSubmitted,\n renderActions,\n testIdRoot: explicitTestIdRoot,\n}: BackendFormProps) {\n const { t } = useTranslation(\"openhands\");\n const { addBackend, updateBackend } = useActiveBackendContext();\n\n const [name, setName] = React.useState(backend?.name ?? \"\");\n const [host, setHost] = React.useState(backend?.host ?? \"\");\n const [apiKey, setApiKey] = React.useState(backend?.apiKey ?? \"\");\n\n // Inline validation: only show errors after the user has left a field.\n const [nameTouched, setNameTouched] = React.useState(false);\n const [hostTouched, setHostTouched] = React.useState(false);\n\n // Kind is inferred from the host on every change.\n const kind: BackendKind = inferKindFromHost(host);\n\n const testIdRoot =\n explicitTestIdRoot ?? (mode === \"edit\" ? \"edit-backend\" : \"add-backend\");\n\n const canSubmit =\n name.trim().length > 0 &&\n isValidHostUrl(host) &&\n (kind === \"local\" || apiKey.trim().length > 0);\n\n // Error messages — only surfaced after the user has blurred the field.\n const nameError =\n nameTouched && !name.trim() ? t(I18nKey.BACKEND$NAME_REQUIRED) : undefined;\n const hostError = hostTouched\n ? !host.trim()\n ? t(I18nKey.BACKEND$HOST_REQUIRED)\n : !isValidHostUrl(host)\n ? t(I18nKey.BACKEND$HOST_INVALID)\n : undefined\n : undefined;\n\n const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (!canSubmit) {\n // Mark all validated fields as touched so inline errors become visible\n // (e.g. user pressed Enter before filling required fields).\n setNameTouched(true);\n setHostTouched(true);\n return;\n }\n\n const payload = {\n name: name.trim(),\n host: normalizeHost(host),\n apiKey: apiKey.trim(),\n kind,\n };\n\n if (mode === \"edit\" && backend) {\n updateBackend(backend.id, payload);\n } else {\n addBackend(payload);\n }\n\n onSubmitted();\n };\n\n return (\n <form\n data-testid={`${testIdRoot}-form`}\n onSubmit={handleSubmit}\n className=\"flex flex-col gap-4\"\n >\n <SettingsInput\n testId={`${testIdRoot}-name`}\n name={`${testIdRoot}-name`}\n type=\"text\"\n label={t(I18nKey.BACKEND$NAME_LABEL)}\n value={name}\n onChange={setName}\n onBlur={() => setNameTouched(true)}\n placeholder=\"Production\"\n className=\"w-full\"\n showRequiredTag\n error={nameError}\n />\n\n <SettingsInput\n testId={`${testIdRoot}-host`}\n name={`${testIdRoot}-host`}\n type=\"text\"\n label={t(I18nKey.BACKEND$HOST_LABEL)}\n value={host}\n onChange={setHost}\n onBlur={() => setHostTouched(true)}\n placeholder={DEFAULT_OPENHANDS_CLOUD_HOST}\n className=\"w-full\"\n showRequiredTag\n error={hostError}\n />\n\n <SettingsInput\n testId={`${testIdRoot}-api-key`}\n name={`${testIdRoot}-api-key`}\n type=\"password\"\n label={t(I18nKey.BACKEND$KEY_LABEL)}\n value={apiKey}\n onChange={setApiKey}\n placeholder=\"\"\n className=\"w-full\"\n />\n\n {mode === \"edit\" && backend && (\n <BackendStatusBadge backend={backend} testIdRoot={testIdRoot} />\n )}\n\n {renderActions ? (\n renderActions({ canSubmit, testIdRoot })\n ) : (\n <div className=\"flex justify-end gap-2 mt-2 w-full\">\n <BrandButton\n type=\"button\"\n variant=\"secondary\"\n onClick={onSubmitted}\n testId={`${testIdRoot}-cancel`}\n >\n {t(I18nKey.BUTTON$CANCEL)}\n </BrandButton>\n <BrandButton\n type=\"submit\"\n variant=\"primary\"\n isDisabled={!canSubmit}\n testId={`${testIdRoot}-submit`}\n >\n {t(I18nKey.BACKEND$SAVE)}\n </BrandButton>\n </div>\n )}\n </form>\n );\n}\n\n// ── Add-mode two-column layout ──────────────────────────────────────\n\n/**\n * Left column of the \"Add a Backend\" modal: manual connection via\n * Host + API Key. Designed for self-hosted agent servers and\n * self-hosted OpenHands Cloud with API key auth.\n */\nfunction ManualConnectionColumn({ onClose }: { onClose: () => void }) {\n const { t } = useTranslation(\"openhands\");\n const { addBackend } = useActiveBackendContext();\n\n const [name, setName] = React.useState(\"\");\n const [host, setHost] = React.useState(\"\");\n const [apiKey, setApiKey] = React.useState(\"\");\n\n const kind: BackendKind = inferKindFromHost(host);\n const canSubmit =\n name.trim().length > 0 &&\n isValidHostUrl(host) &&\n (kind === \"local\" || apiKey.trim().length > 0);\n\n const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n if (!canSubmit) return;\n addBackend({\n name: name.trim(),\n host: normalizeHost(host),\n apiKey: apiKey.trim(),\n kind,\n });\n onClose();\n };\n\n return (\n <form\n data-testid=\"add-backend-form\"\n onSubmit={handleSubmit}\n className=\"flex flex-col gap-4 flex-1 min-w-0\"\n >\n <div className=\"flex flex-col gap-1\">\n <SettingsInput\n testId=\"add-backend-name\"\n name=\"add-backend-name\"\n type=\"text\"\n label={t(I18nKey.BACKEND$NAME_LABEL)}\n value={name}\n onChange={setName}\n placeholder=\"e.g. My Server\"\n className=\"w-full\"\n />\n <p className=\"text-xs text-[var(--oh-muted)]\">\n {t(I18nKey.BACKEND$NAME_HELPER)}\n </p>\n </div>\n\n <div className=\"flex flex-col gap-1\">\n <SettingsInput\n testId=\"add-backend-host\"\n name=\"add-backend-host\"\n type=\"text\"\n label={t(I18nKey.BACKEND$HOST_LABEL)}\n value={host}\n onChange={setHost}\n placeholder=\"http://localhost:8000\"\n className=\"w-full\"\n />\n <p\n className=\"text-xs text-[var(--oh-muted)]\"\n data-testid=\"add-backend-host-helper\"\n >\n {t(I18nKey.BACKEND$HOST_HELPER)}\n </p>\n </div>\n\n <SettingsInput\n testId=\"add-backend-api-key\"\n name=\"add-backend-api-key\"\n type=\"password\"\n label={t(I18nKey.BACKEND$KEY_LABEL)}\n value={apiKey}\n onChange={setApiKey}\n placeholder=\"sk-••••••••••\"\n className=\"w-full\"\n />\n\n <BrandButton\n type=\"submit\"\n variant=\"secondary\"\n isDisabled={!canSubmit}\n testId=\"add-backend-submit\"\n className=\"w-full text-center\"\n >\n {t(I18nKey.BACKEND$CONNECT)}\n </BrandButton>\n </form>\n );\n}\n\n/**\n * Right column of the \"Add a Backend\" modal: one-click OAuth login\n * with OpenHands Cloud. Includes an \"Advanced\" disclosure for\n * users who self-host OpenHands Cloud and need to override the host.\n */\nfunction CloudLoginColumn({ onClose }: { onClose: () => void }) {\n const { t } = useTranslation(\"openhands\");\n const { addBackend } = useActiveBackendContext();\n\n const [advancedOpen, setAdvancedOpen] = React.useState(false);\n const [customHost, setCustomHost] = React.useState(\"\");\n\n const effectiveHost = customHost.trim() || DEFAULT_OPENHANDS_CLOUD_HOST;\n\n const handleLoginSuccess = (apiKey: string) => {\n addBackend({\n name: \"OpenHands Cloud\",\n host: normalizeHost(effectiveHost),\n apiKey,\n kind: \"cloud\",\n });\n onClose();\n };\n\n return (\n <div className=\"flex flex-1 min-w-0 flex-col items-center gap-3\">\n <div className=\"flex flex-col items-center gap-1\">\n <OpenHandsLogoWhite width={56} height={56} aria-hidden />\n\n <h4\n className=\"text-lg font-medium text-white\"\n data-testid=\"add-backend-cloud-title\"\n >\n {t(I18nKey.BACKEND$CLOUD_TITLE)}\n </h4>\n </div>\n\n <p className=\"text-center text-sm leading-relaxed text-[var(--oh-muted)]\">\n {t(I18nKey.BACKEND$CLOUD_DESCRIPTION)}\n </p>\n\n <DeviceFlowAuth\n host={effectiveHost}\n onSuccess={handleLoginSuccess}\n testIdRoot=\"add-backend\"\n />\n\n <div className=\"w-full\">\n <button\n type=\"button\"\n onClick={() => setAdvancedOpen((open) => !open)}\n aria-expanded={advancedOpen}\n data-testid=\"add-backend-advanced-toggle\"\n className=\"flex w-full cursor-pointer items-center justify-center gap-1 text-center text-xs text-[var(--oh-muted)] transition-colors hover:text-content-2\"\n >\n <span>{t(I18nKey.BACKEND$ADVANCED)}</span>\n <ChevronDownSmallIcon\n className={cn(\n \"h-4 w-4 shrink-0 text-muted transition-transform\",\n advancedOpen && \"rotate-180\",\n )}\n aria-hidden\n />\n </button>\n <div\n className={cn(\n \"pt-2\",\n !advancedOpen && \"pointer-events-none invisible\",\n )}\n aria-hidden={!advancedOpen}\n >\n <SettingsInput\n testId=\"add-backend-cloud-host\"\n name=\"add-backend-cloud-host\"\n type=\"text\"\n label={t(I18nKey.BACKEND$HOST_LABEL)}\n value={customHost}\n onChange={setCustomHost}\n placeholder={DEFAULT_OPENHANDS_CLOUD_HOST}\n className=\"w-full\"\n />\n <p className=\"mt-1 text-xs text-[var(--oh-muted)]\">\n {t(I18nKey.BACKEND$LOGIN_CLOUD_HINT)}\n </p>\n </div>\n </div>\n </div>\n );\n}\n\n// ── Modal wrappers ──────────────────────────────────────────────────\n\n/**\n * Modal wrapper. In **add** mode it renders a two-column layout\n * (manual connection | OR | Cloud login). In **edit** mode it wraps\n * the standard `BackendForm`.\n */\nexport function BackendFormModal({\n mode,\n backend,\n onClose,\n}: BackendFormModalProps) {\n const { t } = useTranslation(\"openhands\");\n\n if (mode === \"add\") {\n return (\n <ModalBackdrop\n onClose={onClose}\n closeOnEscape={false}\n aria-label={t(I18nKey.BACKEND$ADD_TITLE)}\n >\n <div\n data-testid=\"add-backend-modal\"\n className={cn(\n \"relative rounded-xl border border-[var(--oh-border)] bg-base-secondary\",\n modalWidthClassName(\"xl\"),\n MODAL_MAX_WIDTH_VIEWPORT,\n )}\n >\n <ModalCloseButton onClose={onClose} testId=\"add-backend-close\" />\n {/* Header */}\n <div className=\"px-6 pt-6 pb-2 pr-12\">\n <h2 className=\"text-lg font-semibold\">\n {t(I18nKey.BACKEND$ADD_TITLE)}\n </h2>\n </div>\n\n {/* Two-column body */}\n <div className=\"flex gap-6 px-6 pb-6 pt-2\">\n {/* Left: manual connection */}\n <div className=\"flex-1 min-w-0\">\n <ManualConnectionColumn onClose={onClose} />\n </div>\n\n {/* Vertical OR divider */}\n <div className=\"flex shrink-0 flex-col items-center\">\n <div className=\"flex-1 w-px bg-[var(--oh-border)]\" />\n <span className=\"py-3 text-xs uppercase text-[var(--oh-muted)]\">\n {t(I18nKey.BACKEND$LOGIN_OR)}\n </span>\n <div className=\"flex-1 w-px bg-[var(--oh-border)]\" />\n </div>\n\n {/* Right: cloud login */}\n <div className=\"flex-1 min-w-0\">\n <CloudLoginColumn onClose={onClose} />\n </div>\n </div>\n </div>\n </ModalBackdrop>\n );\n }\n\n // Edit mode — single-column form (unchanged)\n const testIdRoot = \"edit-backend\";\n return (\n <ModalBackdrop\n onClose={onClose}\n closeOnEscape={false}\n aria-label={t(I18nKey.BACKEND$EDIT_TITLE)}\n >\n <div\n data-testid={`${testIdRoot}-modal`}\n className={cn(\n \"relative bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]\",\n modalWidthClassName(\"md\"),\n )}\n >\n <ModalCloseButton onClose={onClose} testId={`${testIdRoot}-close`} />\n <h2 className=\"pr-6 text-lg font-semibold\">\n {t(I18nKey.BACKEND$EDIT_TITLE)}\n </h2>\n <BackendForm\n mode=\"edit\"\n backend={backend}\n onSubmitted={onClose}\n testIdRoot={testIdRoot}\n />\n </div>\n </ModalBackdrop>\n );\n}\n"],"mappings":"gjCAgCA,SAAS,EAAkB,EAA2B,CACpD,IAAM,EAAU,EAAK,MAAM,CAAC,aAAa,CAIzC,OAHI,EAAQ,SAAS,gBAAgB,EAAI,EAAQ,SAAS,gBAAgB,CACjE,QAEF,QAOT,SAAS,EAAe,EAA2B,CAEjD,IAAM,EAAI,EAAS,aAAa,CAAC,QAAQ,WAAY,GAAG,CAkBxD,MADA,GAfI,IAAM,aAAe,IAAM,OAAS,IAAM,MAAQ,IAAM,WAGxD,SAAS,KAAK,EAAE,EAAI,iBAAiB,KAAK,EAAE,EAE5C,QAAQ,KA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AW,CAAA,CACxC,CAAA,EAGN,EAAA,EAAA,MAAC,MAAD,CAAK,UAAU,+CAAf,EACE,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,oCAAsC,CAAA,EACrD,EAAA,EAAA,KAAC,OAAD,CAAM,UAAU,yDACb,EAAE,EAAA,QAAQ,iBAAiB,CACvB,CAAA,EACP,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,oCAAsC,CAAA,CACjD,IAGN,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,2BACb,EAAA,EAAA,KAAC,EAAD,CAA2B,UAAW,CAAA,CAClC,CAAA,CACF,GACF,GACQ,CAAA,CAKpB,IAAM,EAAa,eACnB,OACE,EAAA,EAAA,KAAC,EAAA,cAAD,CACW,UACT,cAAe,GACf,aAAY,EAAE,EAAA,QAAQ,mBAAmB,WAEzC,EAAA,EAAA,MAAC,MAAD,CACE,cAAa,GAAG,EAAW,QAC3B,UAAW,EAAA,GACT,iGACA,EAAA,oBAAoB,KAAK,CAC1B,UALH,EAOE,EAAA,EAAA,KAAC,EAAA,iBAAD,CAA2B,UAAS,OAAQ,GAAG,EAAW,QAAW,CAAA,EACrE,EAAA,EAAA,KAAC,KAAD,CAAI,UAAU,sCACX,EAAE,EAAA,QAAQ,mBAAmB,CAC3B,CAAA,EACL,EAAA,EAAA,KAAC,EAAD,CACE,KAAK,OACI,UACT,YAAa,EACD,aACZ,CAAA,CACE,GACQ,CAAA"}
1
+ {"version":3,"file":"backend-form-modal.cjs","names":[],"sources":["../../../../src/components/features/backends/backend-form-modal.tsx"],"sourcesContent":["import React from \"react\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useTranslation } from \"react-i18next\";\nimport { ServerClient } from \"@openhands/typescript-client/clients\";\nimport OpenHandsLogoWhite from \"#/assets/branding/openhands-logo-white.svg?react\";\nimport { ModalBackdrop } from \"#/components/shared/modals/modal-backdrop\";\nimport {\n MODAL_MAX_WIDTH_VIEWPORT,\n modalWidthClassName,\n} from \"#/components/shared/modals/modal-body\";\nimport { ModalCloseButton } from \"#/components/shared/modals/modal-close-button\";\nimport { BrandButton } from \"#/components/features/settings/brand-button\";\nimport { SettingsInput } from \"#/components/features/settings/settings-input\";\nimport { useActiveBackendContext } from \"#/contexts/active-backend-context\";\nimport { useNavigation } from \"#/context/navigation-context\";\nimport { useBackendsHealth } from \"#/hooks/query/use-backends-health\";\nimport { getAgentServerClientOptions } from \"#/api/agent-server-client-options\";\nimport ChevronDownSmallIcon from \"#/icons/chevron-down-small.svg?react\";\nimport { I18nKey } from \"#/i18n/declaration\";\nimport type { Backend, BackendKind } from \"#/api/backend-registry/types\";\nimport { cn } from \"#/utils/utils\";\nimport { BackendStatusDot } from \"./backend-status-dot\";\nimport { DeviceFlowAuth } from \"./device-flow-auth\";\n\nexport type BackendFormMode = \"add\" | \"edit\";\n\ninterface BackendFormModalProps {\n mode: BackendFormMode;\n /** Required when `mode === \"edit\"`. */\n backend?: Backend;\n onClose: () => void;\n}\n\nfunction inferKindFromHost(host: string): BackendKind {\n const trimmed = host.trim().toLowerCase();\n if (trimmed.includes(\"all-hands.dev\") || trimmed.includes(\"openhands.dev\")) {\n return \"cloud\";\n }\n return \"local\";\n}\n\n/**\n * Returns true for hostnames that represent a local / private-network address.\n * Used by normalizeHost to choose http:// instead of https://.\n */\nfunction isLocalAddress(hostname: string): boolean {\n // Strip IPv6 bracket notation: [::1] → ::1\n const h = hostname.toLowerCase().replace(/^\\[|\\]$/g, \"\");\n // IPv6 loopback, any-address, and named loopback\n if (h === \"localhost\" || h === \"::1\" || h === \"::\" || h === \"0.0.0.0\")\n return true;\n // 127.x.x.x loopback range + IPv4-mapped loopback (::ffff:127.x.x.x)\n if (/^127\\./.test(h) || /^::ffff:127\\./i.test(h)) return true;\n // RFC 1918 private ranges\n if (/^10\\./.test(h)) return true;\n if (/^192\\.168\\./.test(h)) return true;\n if (/^172\\.(1[6-9]|2\\d|3[01])\\./.test(h)) return true;\n // IPv6 link-local (fe80::/10) and unique local (fc00::/7)\n if (/^fe[89ab][0-9a-f]:/i.test(h)) return true;\n if (/^f[cd][0-9a-f]{2}:/i.test(h)) return true;\n // mDNS / Bonjour (.local)\n if (h.endsWith(\".local\")) return true;\n // Single-label hostnames (no dots, no colons) are local network names.\n // Colons are excluded so bare IPv6 addresses don't accidentally match.\n if (!h.includes(\".\") && !h.includes(\":\")) return true;\n return false;\n}\n\nfunction normalizeHost(host: string): string {\n const trimmed = host.trim().replace(/\\/+$/, \"\");\n if (!trimmed) return \"\";\n // Already has an explicit scheme — respect it.\n if (/^https?:\\/\\//i.test(trimmed)) return trimmed;\n // Extract the pure hostname for scheme selection, handling three cases:\n // [::1]:8080 → bracket IPv6 notation → extract ::1\n // ::1 → bare IPv6 (multiple colons, no bracket) → whole string\n // host:port → regular host:port → part before the colon\n const bracketMatch = trimmed.match(/^\\[([^\\]]+)\\]/);\n const hostname = bracketMatch\n ? bracketMatch[1]\n : (trimmed.match(/:/g) ?? []).length > 1\n ? trimmed\n : trimmed.split(\":\")[0];\n const scheme = isLocalAddress(hostname) ? \"http\" : \"https\";\n return `${scheme}://${trimmed}`;\n}\n\n/**\n * Returns true when `host` represents a reachable backend URL.\n *\n * Rules (applied in order):\n * 1. Must be non-empty after trimming.\n * 2. Must contain no whitespace — spaces can never appear in a host/port.\n * 3. After normalisation (bare hosts get `https://` prepended), must parse\n * as a valid http or https URL with a non-empty hostname.\n */\nfunction isValidHostUrl(host: string): boolean {\n const trimmed = host.trim();\n if (!trimmed) return false;\n // Spaces anywhere in the input are an immediate rejection.\n if (/\\s/.test(trimmed)) return false;\n const normalized = normalizeHost(trimmed);\n if (!normalized) return false;\n try {\n const url = new URL(normalized);\n return (\n (url.protocol === \"http:\" || url.protocol === \"https:\") &&\n url.hostname.length > 0\n );\n } catch {\n return false;\n }\n}\n\nconst DEFAULT_OPENHANDS_CLOUD_HOST = \"https://app.all-hands.dev\";\n\n/**\n * Live status row for the edit form: shows a connection dot, a\n * \"Local\"/\"Cloud\" label, and the agent server's reported version when\n * available. Replaces the legacy local/cloud radio fieldset (kind is\n * now inferred from the host).\n */\nfunction BackendStatusBadge({\n backend,\n testIdRoot,\n}: {\n backend: Backend;\n testIdRoot: string;\n}) {\n const { t } = useTranslation(\"openhands\");\n const healthByBackendId = useBackendsHealth([backend]);\n const health = healthByBackendId[backend.id];\n const isConnected = health?.isConnected ?? null;\n const disabled = health?.disabled === true;\n const consecutiveFailures = health?.consecutiveFailures ?? 0;\n const lastError = health?.lastError ?? null;\n\n const { data: version } = useQuery({\n queryKey: [\"backend-version\", backend.host, backend.apiKey],\n queryFn: async () => {\n const info = await new ServerClient(\n getAgentServerClientOptions({\n host: backend.host,\n sessionApiKey: backend.apiKey || null,\n timeout: 5000,\n }),\n ).getServerInfo();\n return info.version ?? null;\n },\n retry: false,\n staleTime: 60_000,\n enabled: backend.kind === \"local\" && !disabled,\n });\n\n let statusLabel: string;\n if (isConnected === true) {\n statusLabel = t(I18nKey.ONBOARDING$BACKEND_STATUS_CONNECTED);\n } else if (isConnected === false) {\n statusLabel = t(I18nKey.ONBOARDING$BACKEND_STATUS_DISCONNECTED);\n } else {\n statusLabel = t(I18nKey.ONBOARDING$BACKEND_STATUS_CHECKING);\n }\n\n const kindLabel =\n backend.kind === \"cloud\"\n ? t(I18nKey.BACKEND$KIND_CLOUD)\n : t(I18nKey.BACKEND$KIND_LOCAL);\n\n return (\n <div className=\"flex flex-col gap-2\">\n <div\n data-testid={`${testIdRoot}-status`}\n className=\"flex items-center gap-3 text-sm\"\n >\n <BackendStatusDot isConnected={isConnected} />\n <span className=\"text-white\" data-testid={`${testIdRoot}-status-label`}>\n {statusLabel}\n </span>\n <span className=\"text-tertiary-alt\">·</span>\n <span className=\"text-[var(--oh-text-tertiary)]\">{kindLabel}</span>\n {version ? (\n <span\n className=\"text-xs text-[var(--oh-muted)]\"\n data-testid={`${testIdRoot}-version`}\n >\n {t(I18nKey.BACKEND$VERSION_LABEL, { version })}\n </span>\n ) : null}\n </div>\n\n {disabled ? (\n <div\n data-testid={`${testIdRoot}-status-error`}\n className=\"flex flex-col gap-1 rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm\"\n >\n <span className=\"font-semibold text-red-300\">\n {t(I18nKey.BACKEND$HEALTH_FAILED_TITLE)}\n </span>\n <span className=\"text-xs text-[var(--oh-text-tertiary)]\">\n {t(I18nKey.BACKEND$HEALTH_FAILED_DETAIL, {\n count: consecutiveFailures,\n })}\n </span>\n {lastError ? (\n <span\n data-testid={`${testIdRoot}-status-error-message`}\n className=\"text-xs text-red-300 whitespace-pre-wrap break-words\"\n >\n {lastError}\n </span>\n ) : null}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport interface BackendFormProps {\n mode: BackendFormMode;\n /** Required when `mode === \"edit\"`. */\n backend?: Backend;\n /**\n * Called after the form is submitted and the backend has been\n * persisted. Use this to dismiss a containing modal, advance an\n * onboarding step, etc.\n */\n onSubmitted: () => void;\n /**\n * Optional render slot rendered in place of the default\n * Save / Cancel button row, so callers (e.g. the onboarding flow)\n * can re-skin the action area while still owning submission via the\n * standard `<form onSubmit>` flow. Receives the form's submit-ready\n * state.\n */\n renderActions?: (state: {\n canSubmit: boolean;\n testIdRoot: string;\n }) => React.ReactNode;\n /** Used to disambiguate test ids across the same screen. */\n testIdRoot?: string;\n}\n\n/**\n * Reusable form body for adding / editing a backend. Renders the\n * common name / host / API-key inputs plus the kind selector\n * (radio buttons in `add` mode, status badge in `edit` mode).\n *\n * Rendered as a `<form>`, so consumers should put any extra controls\n * either inside `renderActions` or as siblings inside a wrapping\n * element — but submission flows through the standard form submit so\n * Enter-to-submit still works.\n */\nexport function BackendForm({\n mode,\n backend,\n onSubmitted,\n renderActions,\n testIdRoot: explicitTestIdRoot,\n}: BackendFormProps) {\n const { t } = useTranslation(\"openhands\");\n const { addBackend, updateBackend } = useActiveBackendContext();\n\n const [name, setName] = React.useState(backend?.name ?? \"\");\n const [host, setHost] = React.useState(backend?.host ?? \"\");\n const [apiKey, setApiKey] = React.useState(backend?.apiKey ?? \"\");\n\n // Inline validation: only show errors after the user has left a field.\n const [nameTouched, setNameTouched] = React.useState(false);\n const [hostTouched, setHostTouched] = React.useState(false);\n\n // Kind is inferred from the host on every change.\n const kind: BackendKind = inferKindFromHost(host);\n\n const testIdRoot =\n explicitTestIdRoot ?? (mode === \"edit\" ? \"edit-backend\" : \"add-backend\");\n\n const canSubmit =\n name.trim().length > 0 &&\n isValidHostUrl(host) &&\n (kind === \"local\" || apiKey.trim().length > 0);\n\n // Error messages — only surfaced after the user has blurred the field.\n const nameError =\n nameTouched && !name.trim() ? t(I18nKey.BACKEND$NAME_REQUIRED) : undefined;\n const hostError = hostTouched\n ? !host.trim()\n ? t(I18nKey.BACKEND$HOST_REQUIRED)\n : !isValidHostUrl(host)\n ? t(I18nKey.BACKEND$HOST_INVALID)\n : undefined\n : undefined;\n\n const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (!canSubmit) {\n // Mark all validated fields as touched so inline errors become visible\n // (e.g. user pressed Enter before filling required fields).\n setNameTouched(true);\n setHostTouched(true);\n return;\n }\n\n const payload = {\n name: name.trim(),\n host: normalizeHost(host),\n apiKey: apiKey.trim(),\n kind,\n };\n\n if (mode === \"edit\" && backend) {\n updateBackend(backend.id, payload);\n } else {\n addBackend(payload);\n }\n\n onSubmitted();\n };\n\n return (\n <form\n data-testid={`${testIdRoot}-form`}\n onSubmit={handleSubmit}\n className=\"flex flex-col gap-4\"\n >\n <SettingsInput\n testId={`${testIdRoot}-name`}\n name={`${testIdRoot}-name`}\n type=\"text\"\n label={t(I18nKey.BACKEND$NAME_LABEL)}\n value={name}\n onChange={setName}\n onBlur={() => setNameTouched(true)}\n placeholder=\"Production\"\n className=\"w-full\"\n showRequiredTag\n error={nameError}\n />\n\n <SettingsInput\n testId={`${testIdRoot}-host`}\n name={`${testIdRoot}-host`}\n type=\"text\"\n label={t(I18nKey.BACKEND$HOST_LABEL)}\n value={host}\n onChange={setHost}\n onBlur={() => setHostTouched(true)}\n placeholder={DEFAULT_OPENHANDS_CLOUD_HOST}\n className=\"w-full\"\n showRequiredTag\n error={hostError}\n />\n\n <SettingsInput\n testId={`${testIdRoot}-api-key`}\n name={`${testIdRoot}-api-key`}\n type=\"password\"\n label={t(I18nKey.BACKEND$KEY_LABEL)}\n value={apiKey}\n onChange={setApiKey}\n placeholder=\"\"\n className=\"w-full\"\n />\n\n {mode === \"edit\" && backend && (\n <BackendStatusBadge backend={backend} testIdRoot={testIdRoot} />\n )}\n\n {renderActions ? (\n renderActions({ canSubmit, testIdRoot })\n ) : (\n <div className=\"flex justify-end gap-2 mt-2 w-full\">\n <BrandButton\n type=\"button\"\n variant=\"secondary\"\n onClick={onSubmitted}\n testId={`${testIdRoot}-cancel`}\n >\n {t(I18nKey.BUTTON$CANCEL)}\n </BrandButton>\n <BrandButton\n type=\"submit\"\n variant=\"primary\"\n isDisabled={!canSubmit}\n testId={`${testIdRoot}-submit`}\n >\n {t(I18nKey.BACKEND$SAVE)}\n </BrandButton>\n </div>\n )}\n </form>\n );\n}\n\n// ── Add-mode two-column layout ──────────────────────────────────────\n\n/**\n * @spec BM-002 — Adding a backend auto-switches the active selection to it\n * (BM-001), so a backend-scoped detail page the user is viewing now belongs\n * to the previous backend. Redirect to that section's list so they never see\n * stale data, mirroring the switch-backend redirect in BackendSelector.\n */\nfunction useRedirectAfterAddBackend() {\n const { currentPath, navigate } = useNavigation();\n return React.useCallback(() => {\n if (/^\\/automations\\/[^/]+/.test(currentPath)) navigate(\"/automations\");\n else if (/^\\/conversations\\/[^/]+/.test(currentPath))\n navigate(\"/conversations\");\n }, [currentPath, navigate]);\n}\n\n/**\n * Left column of the \"Add a Backend\" modal: manual connection via\n * Host + API Key. Designed for self-hosted agent servers and\n * self-hosted OpenHands Cloud with API key auth.\n */\nfunction ManualConnectionColumn({ onClose }: { onClose: () => void }) {\n const { t } = useTranslation(\"openhands\");\n const { addBackend } = useActiveBackendContext();\n const redirectAfterAdd = useRedirectAfterAddBackend();\n\n const [name, setName] = React.useState(\"\");\n const [host, setHost] = React.useState(\"\");\n const [apiKey, setApiKey] = React.useState(\"\");\n\n const kind: BackendKind = inferKindFromHost(host);\n const canSubmit =\n name.trim().length > 0 &&\n isValidHostUrl(host) &&\n (kind === \"local\" || apiKey.trim().length > 0);\n\n const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n if (!canSubmit) return;\n addBackend({\n name: name.trim(),\n host: normalizeHost(host),\n apiKey: apiKey.trim(),\n kind,\n });\n redirectAfterAdd();\n onClose();\n };\n\n return (\n <form\n data-testid=\"add-backend-form\"\n onSubmit={handleSubmit}\n className=\"flex flex-col gap-4 flex-1 min-w-0\"\n >\n <div className=\"flex flex-col gap-1\">\n <SettingsInput\n testId=\"add-backend-name\"\n name=\"add-backend-name\"\n type=\"text\"\n label={t(I18nKey.BACKEND$NAME_LABEL)}\n value={name}\n onChange={setName}\n placeholder=\"e.g. My Server\"\n className=\"w-full\"\n />\n <p className=\"text-xs text-[var(--oh-muted)]\">\n {t(I18nKey.BACKEND$NAME_HELPER)}\n </p>\n </div>\n\n <div className=\"flex flex-col gap-1\">\n <SettingsInput\n testId=\"add-backend-host\"\n name=\"add-backend-host\"\n type=\"text\"\n label={t(I18nKey.BACKEND$HOST_LABEL)}\n value={host}\n onChange={setHost}\n placeholder=\"http://localhost:8000\"\n className=\"w-full\"\n />\n <p\n className=\"text-xs text-[var(--oh-muted)]\"\n data-testid=\"add-backend-host-helper\"\n >\n {t(I18nKey.BACKEND$HOST_HELPER)}\n </p>\n </div>\n\n <SettingsInput\n testId=\"add-backend-api-key\"\n name=\"add-backend-api-key\"\n type=\"password\"\n label={t(I18nKey.BACKEND$KEY_LABEL)}\n value={apiKey}\n onChange={setApiKey}\n placeholder=\"sk-••••••••••\"\n className=\"w-full\"\n />\n\n <BrandButton\n type=\"submit\"\n variant=\"secondary\"\n isDisabled={!canSubmit}\n testId=\"add-backend-submit\"\n className=\"w-full text-center\"\n >\n {t(I18nKey.BACKEND$CONNECT)}\n </BrandButton>\n </form>\n );\n}\n\n/**\n * Right column of the \"Add a Backend\" modal: one-click OAuth login\n * with OpenHands Cloud. Includes an \"Advanced\" disclosure for\n * users who self-host OpenHands Cloud and need to override the host.\n */\nfunction CloudLoginColumn({ onClose }: { onClose: () => void }) {\n const { t } = useTranslation(\"openhands\");\n const { addBackend } = useActiveBackendContext();\n const redirectAfterAdd = useRedirectAfterAddBackend();\n\n const [advancedOpen, setAdvancedOpen] = React.useState(false);\n const [customHost, setCustomHost] = React.useState(\"\");\n\n const effectiveHost = customHost.trim() || DEFAULT_OPENHANDS_CLOUD_HOST;\n\n const handleLoginSuccess = (apiKey: string) => {\n addBackend({\n name: \"OpenHands Cloud\",\n host: normalizeHost(effectiveHost),\n apiKey,\n kind: \"cloud\",\n });\n redirectAfterAdd();\n onClose();\n };\n\n return (\n <div className=\"flex flex-1 min-w-0 flex-col items-center gap-3\">\n <div className=\"flex flex-col items-center gap-1\">\n <OpenHandsLogoWhite width={56} height={56} aria-hidden />\n\n <h4\n className=\"text-lg font-medium text-white\"\n data-testid=\"add-backend-cloud-title\"\n >\n {t(I18nKey.BACKEND$CLOUD_TITLE)}\n </h4>\n </div>\n\n <p className=\"text-center text-sm leading-relaxed text-[var(--oh-muted)]\">\n {t(I18nKey.BACKEND$CLOUD_DESCRIPTION)}\n </p>\n\n <DeviceFlowAuth\n host={effectiveHost}\n onSuccess={handleLoginSuccess}\n testIdRoot=\"add-backend\"\n />\n\n <div className=\"w-full\">\n <button\n type=\"button\"\n onClick={() => setAdvancedOpen((open) => !open)}\n aria-expanded={advancedOpen}\n data-testid=\"add-backend-advanced-toggle\"\n className=\"flex w-full cursor-pointer items-center justify-center gap-1 text-center text-xs text-[var(--oh-muted)] transition-colors hover:text-content-2\"\n >\n <span>{t(I18nKey.BACKEND$ADVANCED)}</span>\n <ChevronDownSmallIcon\n className={cn(\n \"h-4 w-4 shrink-0 text-muted transition-transform\",\n advancedOpen && \"rotate-180\",\n )}\n aria-hidden\n />\n </button>\n <div\n className={cn(\n \"pt-2\",\n !advancedOpen && \"pointer-events-none invisible\",\n )}\n aria-hidden={!advancedOpen}\n >\n <SettingsInput\n testId=\"add-backend-cloud-host\"\n name=\"add-backend-cloud-host\"\n type=\"text\"\n label={t(I18nKey.BACKEND$HOST_LABEL)}\n value={customHost}\n onChange={setCustomHost}\n placeholder={DEFAULT_OPENHANDS_CLOUD_HOST}\n className=\"w-full\"\n />\n <p className=\"mt-1 text-xs text-[var(--oh-muted)]\">\n {t(I18nKey.BACKEND$LOGIN_CLOUD_HINT)}\n </p>\n </div>\n </div>\n </div>\n );\n}\n\n// ── Modal wrappers ──────────────────────────────────────────────────\n\n/**\n * Modal wrapper. In **add** mode it renders a two-column layout\n * (manual connection | OR | Cloud login). In **edit** mode it wraps\n * the standard `BackendForm`.\n */\nexport function BackendFormModal({\n mode,\n backend,\n onClose,\n}: BackendFormModalProps) {\n const { t } = useTranslation(\"openhands\");\n\n if (mode === \"add\") {\n return (\n <ModalBackdrop\n onClose={onClose}\n closeOnEscape={false}\n aria-label={t(I18nKey.BACKEND$ADD_TITLE)}\n >\n <div\n data-testid=\"add-backend-modal\"\n className={cn(\n \"relative rounded-xl border border-[var(--oh-border)] bg-base-secondary\",\n modalWidthClassName(\"xl\"),\n MODAL_MAX_WIDTH_VIEWPORT,\n )}\n >\n <ModalCloseButton onClose={onClose} testId=\"add-backend-close\" />\n {/* Header */}\n <div className=\"px-6 pt-6 pb-2 pr-12\">\n <h2 className=\"text-lg font-semibold\">\n {t(I18nKey.BACKEND$ADD_TITLE)}\n </h2>\n </div>\n\n {/* Two-column body */}\n <div className=\"flex gap-6 px-6 pb-6 pt-2\">\n {/* Left: manual connection */}\n <div className=\"flex-1 min-w-0\">\n <ManualConnectionColumn onClose={onClose} />\n </div>\n\n {/* Vertical OR divider */}\n <div className=\"flex shrink-0 flex-col items-center\">\n <div className=\"flex-1 w-px bg-[var(--oh-border)]\" />\n <span className=\"py-3 text-xs uppercase text-[var(--oh-muted)]\">\n {t(I18nKey.BACKEND$LOGIN_OR)}\n </span>\n <div className=\"flex-1 w-px bg-[var(--oh-border)]\" />\n </div>\n\n {/* Right: cloud login */}\n <div className=\"flex-1 min-w-0\">\n <CloudLoginColumn onClose={onClose} />\n </div>\n </div>\n </div>\n </ModalBackdrop>\n );\n }\n\n // Edit mode — single-column form (unchanged)\n const testIdRoot = \"edit-backend\";\n return (\n <ModalBackdrop\n onClose={onClose}\n closeOnEscape={false}\n aria-label={t(I18nKey.BACKEND$EDIT_TITLE)}\n >\n <div\n data-testid={`${testIdRoot}-modal`}\n className={cn(\n \"relative bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]\",\n modalWidthClassName(\"md\"),\n )}\n >\n <ModalCloseButton onClose={onClose} testId={`${testIdRoot}-close`} />\n <h2 className=\"pr-6 text-lg font-semibold\">\n {t(I18nKey.BACKEND$EDIT_TITLE)}\n </h2>\n <BackendForm\n mode=\"edit\"\n backend={backend}\n onSubmitted={onClose}\n testIdRoot={testIdRoot}\n />\n </div>\n </ModalBackdrop>\n );\n}\n"],"mappings":"qmCAiCA,SAAS,EAAkB,EAA2B,CACpD,IAAM,EAAU,EAAK,MAAM,CAAC,aAAa,CAIzC,OAHI,EAAQ,SAAS,gBAAgB,EAAI,EAAQ,SAAS,gBAAgB,CACjE,QAEF,QAOT,SAAS,EAAe,EAA2B,CAEjD,IAAM,EAAI,EAAS,aAAa,CAAC,QAAQ,WAAY,GAAG,CAkBxD,MADA,GAfI,IAAM,aAAe,IAAM,OAAS,IAAM,MAAQ,IAAM,WAGxD,SAAS,KAAK,EAAE,EAAI,iBAAiB,KAAK,EAAE,EAE5C,QAAQ,KAAK,EAAE,EACf,cAAc,KAAK,EAAE,EACrB,6BAA6B,KAAK,EAAE,EAEpC,sBAAsB,KAAK,EAAE,EAC7B,sBAAsB,KAAK,EAAE,EAE7B,EAAE,SAAS,SAAS,EAGpB,CAAC,EAAE,SA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