@openhands/agent-canvas 1.0.0-beta.9 → 1.0.0-rc.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 (31) hide show
  1. package/README.md +2 -2
  2. package/README.windows.md +2 -2
  3. package/build/assets/{analytics-consent-form-modal-CmWcFlc6.js → analytics-consent-form-modal-DxkThW4K.js} +1 -1
  4. package/build/assets/{home-TrU0fLgG.js → home-CWw845Rz.js} +1 -1
  5. package/build/assets/llm-settings-CAnFYAEG.js +1 -0
  6. package/build/assets/{llm-settings-C4R4HMUO.js → llm-settings-DotqpmCF.js} +1 -1
  7. package/build/assets/{manifest-8c2efa8a.js → manifest-61ec2d68.js} +1 -1
  8. package/build/assets/model-selector-CZOi4V7r.js +1 -0
  9. package/build/assets/{onboarding-DLr9jbKH.js → onboarding-CPCKYvFh.js} +1 -1
  10. package/build/assets/{root-BietmyRa.js → root-CklXEh3W.js} +1 -1
  11. package/build/assets/{root-layout-BgPi-t57.js → root-layout-BCA_X8XL.js} +2 -2
  12. package/build/assets/{settings-modal-nJYxCsyp.js → settings-modal-DdntdOGP.js} +1 -1
  13. package/build/assets/telemetry-fQFd-8V3.js +2 -0
  14. package/build/index.html +3 -3
  15. package/dist/api/config-service/config-service.api.cjs +1 -1
  16. package/dist/api/config-service/config-service.api.cjs.map +1 -1
  17. package/dist/api/config-service/config-service.api.d.ts +12 -0
  18. package/dist/api/config-service/config-service.api.js +55 -18
  19. package/dist/api/config-service/config-service.api.js.map +1 -1
  20. package/dist/hooks/query/use-verified-models.cjs +1 -1
  21. package/dist/hooks/query/use-verified-models.cjs.map +1 -1
  22. package/dist/hooks/query/use-verified-models.js +7 -6
  23. package/dist/hooks/query/use-verified-models.js.map +1 -1
  24. package/dist/package.cjs +1 -1
  25. package/dist/package.cjs.map +1 -1
  26. package/dist/package.js +1 -1
  27. package/dist/package.js.map +1 -1
  28. package/package.json +1 -1
  29. package/build/assets/llm-settings-Dq3w2cob.js +0 -1
  30. package/build/assets/model-selector-DoL0CL0_.js +0 -1
  31. package/build/assets/telemetry-3piyXm5H.js +0 -2
package/README.md CHANGED
@@ -74,7 +74,7 @@ agent-canvas --backend-only # agent server + automation backend + ingress only
74
74
 
75
75
  **macOS / Linux:**
76
76
  ```sh
77
- docker pull ghcr.io/openhands/agent-canvas:1.0.0-beta.9
77
+ docker pull ghcr.io/openhands/agent-canvas:1.0.0-rc.1
78
78
 
79
79
  export PROJECTS_PATH="$HOME/projects" # directory containing your project folders
80
80
  mkdir -p "$PROJECTS_PATH" "$HOME/.openhands"
@@ -83,7 +83,7 @@ docker run -it --rm \
83
83
  -p 8000:8000 \
84
84
  -v "$HOME/.openhands:/home/openhands/.openhands" \
85
85
  -v "${PROJECTS_PATH}:/projects" \
86
- ghcr.io/openhands/agent-canvas:1.0.0-beta.9
86
+ ghcr.io/openhands/agent-canvas:1.0.0-rc.1
87
87
  ```
88
88
 
89
89
  **Windows (PowerShell / Windows Terminal):** See [README.windows.md](./README.windows.md) for the equivalent commands.
package/README.windows.md CHANGED
@@ -12,7 +12,7 @@ For the main install options and overall context, see [README.md](./README.md).
12
12
  - A host directory for `PROJECTS_PATH` containing the project folders you want the agent to access (create it before starting the container)
13
13
 
14
14
  ```powershell
15
- docker pull ghcr.io/openhands/agent-canvas:1.0.0-beta.9
15
+ docker pull ghcr.io/openhands/agent-canvas:1.0.0-rc.1
16
16
 
17
17
  $env:PROJECTS_PATH = Join-Path $HOME "projects" # directory containing your project folders
18
18
  New-Item -ItemType Directory -Force -Path $env:PROJECTS_PATH, (Join-Path $env:USERPROFILE ".openhands") | Out-Null
@@ -21,7 +21,7 @@ docker run -it --rm `
21
21
  -p 8000:8000 `
22
22
  -v "$($env:USERPROFILE)\.openhands:/home/openhands/.openhands" `
23
23
  -v "$($env:PROJECTS_PATH):/projects" `
24
- ghcr.io/openhands/agent-canvas:1.0.0-beta.9
24
+ ghcr.io/openhands/agent-canvas:1.0.0-rc.1
25
25
  ```
26
26
 
27
27
  The agent will be able to access any project under `PROJECTS_PATH`.
@@ -1 +1 @@
1
- import{o as e,t}from"./declaration-DaUdB2Wg.js";import{t as n}from"./useTranslation-CEcjrme-.js";import{n as r}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~oli4dvxu-BodGsxSf.js";import{r as i}from"./telemetry-3piyXm5H.js";import{t as a}from"./modal-backdrop-BDqI1zBV.js";import{n as o}from"./modal-body-CCLCqX1J.js";import{n as s,r as c}from"./base-modal-DZCNv0A4.js";import{t as l}from"./brand-button-LBFNic99.js";import{t as u}from"./handle-capture-consent-3XrjZ8wi.js";import{t as d}from"./use-save-settings-rE9aA29R.js";var f=e();function p({onClose:e}){let p=r(),{t:m}=n(`openhands`),{mutate:h}=d();return(0,f.jsx)(a,{children:(0,f.jsx)(`form`,{"data-testid":`user-capture-consent-form`,onSubmit:async t=>{t.preventDefault();let n=new FormData(t.currentTarget).get(`analytics`)===`on`;h({user_consents_to_analytics:n},{onSuccess:()=>{u(p,n),i(n?`granted`:`denied`),e()}})},className:`flex flex-col gap-2`,children:(0,f.jsxs)(o,{className:`border border-[var(--oh-border)]`,children:[(0,f.jsx)(c,{title:m(t.ANALYTICS$TITLE)}),(0,f.jsx)(s,{children:m(t.ANALYTICS$DESCRIPTION)}),(0,f.jsxs)(`label`,{className:`flex gap-2 items-center self-start text-sm`,children:[(0,f.jsx)(`input`,{name:`analytics`,type:`checkbox`,defaultChecked:!0}),m(t.ANALYTICS$SEND_ANONYMOUS_DATA)]}),(0,f.jsx)(l,{testId:`confirm-preferences`,type:`submit`,variant:`primary`,className:`w-full`,children:m(t.ANALYTICS$CONFIRM_PREFERENCES)})]})})})}export{p as AnalyticsConsentFormModal};
1
+ import{o as e,t}from"./declaration-DaUdB2Wg.js";import{t as n}from"./useTranslation-CEcjrme-.js";import{n as r}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~oli4dvxu-BodGsxSf.js";import{r as i}from"./telemetry-fQFd-8V3.js";import{t as a}from"./modal-backdrop-BDqI1zBV.js";import{n as o}from"./modal-body-CCLCqX1J.js";import{n as s,r as c}from"./base-modal-DZCNv0A4.js";import{t as l}from"./brand-button-LBFNic99.js";import{t as u}from"./handle-capture-consent-3XrjZ8wi.js";import{t as d}from"./use-save-settings-rE9aA29R.js";var f=e();function p({onClose:e}){let p=r(),{t:m}=n(`openhands`),{mutate:h}=d();return(0,f.jsx)(a,{children:(0,f.jsx)(`form`,{"data-testid":`user-capture-consent-form`,onSubmit:async t=>{t.preventDefault();let n=new FormData(t.currentTarget).get(`analytics`)===`on`;h({user_consents_to_analytics:n},{onSuccess:()=>{u(p,n),i(n?`granted`:`denied`),e()}})},className:`flex flex-col gap-2`,children:(0,f.jsxs)(o,{className:`border border-[var(--oh-border)]`,children:[(0,f.jsx)(c,{title:m(t.ANALYTICS$TITLE)}),(0,f.jsx)(s,{children:m(t.ANALYTICS$DESCRIPTION)}),(0,f.jsxs)(`label`,{className:`flex gap-2 items-center self-start text-sm`,children:[(0,f.jsx)(`input`,{name:`analytics`,type:`checkbox`,defaultChecked:!0}),m(t.ANALYTICS$SEND_ANONYMOUS_DATA)]}),(0,f.jsx)(l,{testId:`confirm-preferences`,type:`submit`,variant:`primary`,className:`w-full`,children:m(t.ANALYTICS$CONFIRM_PREFERENCES)})]})})})}export{p as AnalyticsConsentFormModal};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{L as n,k as r}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{o as i,t as a}from"./declaration-DaUdB2Wg.js";import{r as o}from"./recommended-automations-launcher-BIul0osB.js";import{t as s}from"./useTranslation-CEcjrme-.js";import{t as c}from"./vendor~root-layout~home~conversation-panel~conversation-DkwcKRtv.js";import{a as l}from"./vendor~root-layout~home~mcp~automations-list-BnIlGhjl.js";import{a as u,c as d,d as f,i as p,l as m,n as h,o as g,r as _,s as v,t as y,u as b}from"./onboarding-DLr9jbKH.js";import{a as x,n as S,t as C}from"./custom-toast-handlers-BohXx7uh.js";import{t as w}from"./utils-CdgBzLA7.js";import{n as T}from"./active-backend-context-I2w666XY.js";import{t as E}from"./modal-backdrop-BDqI1zBV.js";import{n as D}from"./modal-body-CCLCqX1J.js";import{r as O}from"./base-modal-DZCNv0A4.js";import{a as k,g as A,o as j,p as M,t as N}from"./brand-button-LBFNic99.js";import{t as P}from"./use-config-DwfigQ_Y.js";import{n as F}from"./navigation-context-aNGUUtdq.js";import{t as I}from"./styled-tooltip-TCp7svY3.js";import{i as L,n as R}from"./dropdown-classes-Vqz86I0R.js";import{c as z,f as B,l as V,r as H}from"./chat-send-button-5qz0zj6R.js";import{t as U}from"./conversation-store-CC-isCnP.js";import{t as W}from"./modal-close-button-gQgKqUf-.js";import{r as ee}from"./use-settings-BPTbE7lg.js";import{t as G}from"./use-create-conversation-BEzddjXn.js";import{t as te}from"./use-llm-profiles-E-jjZMZw.js";import{l as ne}from"./vendor~root-layout~home~conversation-panel~conversation~shared-conversation~alert-banner~pl~rqjteh0a-CcFtthyg.js";import{t as re}from"./folder-2h1hR1Qb.js";import{r as K}from"./typography-Bvw0IxaN.js";import{A as ie,F as q,I as J,M as Y,N as ae,a as oe,c as se,d as ce,f as le,i as ue,l as de,n as fe,o as pe,p as me,r as he,s as ge,t as _e,u as ve}from"./git-control-bar-branch-button-D8blTNXh.js";import{d as ye}from"./conversation-websocket-context-G95yfL81.js";import{r as be}from"./settings-utils-BxzHqLmZ.js";var X=e(t(),1);async function Z(e){let{imagesToEmbed:t}=J(e.images,e.imagesMarkedUploadAsFile),n=await Promise.all(t.map(e=>Y(e)));ye.getState().enqueuePendingMessage({conversationId:e.conversationId,text:e.text,content:e.text,imageUrls:n,fileUrls:[]})}var Q=i();function xe(){let{t:e}=s(`openhands`);return(0,Q.jsx)(`div`,{className:`flex min-h-[80px] w-full items-center justify-center py-2`,children:(0,Q.jsx)(K.H1,{className:`w-full text-center leading-normal`,children:e(`HOME$LETS_START_BUILDING`)})})}function Se({kind:e,onClick:t,disabled:n=!1,disabledTooltip:r}){let{t:i}=s(`openhands`),o=e===`local`,c=i(o?a.HOME$OPEN_WORKSPACE:a.COMMON$OPEN_REPOSITORY),u=(0,Q.jsxs)(`button`,{type:`button`,"data-testid":o?`open-workspace-button`:`open-repository-button`,onClick:t,disabled:n,className:w(`flex flex-row items-center gap-2 rounded-full px-2.5 py-1 text-white`,k,M,A,n?`cursor-not-allowed opacity-50`:`cursor-pointer hover:bg-surface-raised`),children:[(0,Q.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center`,children:o?(0,Q.jsx)(l,{"aria-hidden":!0,className:`h-4 w-4`,strokeWidth:2}):(0,Q.jsx)(B,{width:16,height:16,className:`shrink-0`})}),(0,Q.jsx)(`span`,{className:`text-sm font-normal leading-5`,children:c})]});return r?(0,Q.jsx)(I,{content:r,placement:`top`,children:(0,Q.jsx)(`span`,{className:`inline-flex`,children:u})}):u}function Ce({workspaces:e,value:t,placeholder:n,className:r,disabled:i=!1,disabledTooltip:o,showManage:l,onChange:u,onAddClick:d,onManageClick:f}){let{t:p}=s(`openhands`),[m,h]=(0,X.useState)(t?.name??``),g=(0,X.useRef)(null),_=(0,X.useMemo)(()=>{let t=m.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.path.toLowerCase().includes(t)):e},[e,m]),v=(0,X.useCallback)(e=>{u(e),e&&h(e.name)},[u]),y=(0,X.useCallback)(()=>{v(null),h(``)},[v]),{isOpen:b,getToggleButtonProps:x,getMenuProps:S,getInputProps:C,highlightedIndex:T,getItemProps:E,selectedItem:D,closeMenu:O}=c({items:_,itemToString:e=>e?.name??``,selectedItem:t,onSelectedItemChange:({selectedItem:e})=>{v(e??null)},inputValue:m,stateReducer:(e,t)=>t.type===c.stateChangeTypes.InputClick&&e.isOpen?{...t.changes,isOpen:!0}:t.changes}),k=(e,t,n,r,i)=>(0,Q.jsx)(se,{item:e,index:t,isSelected:r?.id===e.id,getItemProps:i,getDisplayText:e=>e.name,getItemKey:e=>e.id},e.id),A=e=>(0,Q.jsx)(ge,{inputValue:e,searchMessage:p(a.HOME$NO_WORKSPACES),emptyMessage:p(a.HOME$NO_WORKSPACES),testId:`workspace-dropdown-empty`}),M=(0,X.useMemo)(()=>(0,Q.jsxs)(`div`,{className:L,children:[(0,Q.jsx)(`button`,{type:`button`,"data-testid":`add-workspaces-button`,className:w(R,`cursor-pointer`),onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation(),O(),d()},children:p(a.HOME$ADD_WORKSPACES)}),(l??e.length>0)&&(0,Q.jsx)(`button`,{type:`button`,"data-testid":`manage-workspaces-button`,className:w(R,`cursor-pointer`),onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation(),O(),f()},children:p(a.HOME$MANAGE_WORKSPACES)})]}),[d,f,p,O,e.length,l]),N=(0,Q.jsxs)(`div`,{className:w(`relative`,r),children:[(0,Q.jsxs)(`div`,{className:`group relative text-[var(--oh-muted)] hover:text-white`,children:[(0,Q.jsx)(`div`,{className:`absolute left-2 top-1/2 transform -translate-y-1/2 z-10`,children:(0,Q.jsx)(V,{width:16,height:16})}),(0,Q.jsx)(`input`,{...C({disabled:i,placeholder:n??p(a.HOME$WORKSPACE_PLACEHOLDER),className:w(j,`text-inherit shadow-none pl-7 pr-16 text-sm font-normal leading-5`,`placeholder:text-[var(--oh-muted)]`,`disabled:cursor-not-allowed disabled:opacity-60`),onChange:e=>{h(e.target.value)}}),"data-testid":`workspace-dropdown`}),(0,Q.jsxs)(`div`,{className:`absolute right-1 top-1/2 transform -translate-y-1/2 flex items-center`,children:[t&&(0,Q.jsx)(ve,{disabled:i,onClear:y}),(0,Q.jsx)(de,{isOpen:b,disabled:i,getToggleButtonProps:x})]})]}),(0,Q.jsx)(pe,{isOpen:b,filteredItems:_,inputValue:m,highlightedIndex:T,selectedItem:D,getMenuProps:S,getItemProps:E,menuRef:g,renderItem:k,renderEmptyState:A,stickyFooterItem:M,testId:`workspace-dropdown-menu`,itemKey:e=>e.id})]});return o?(0,Q.jsx)(I,{content:o,placement:`top`,children:(0,Q.jsx)(`span`,{className:`block`,children:N})}):N}function we({isLoadingSettings:e=!1,onConfirm:t}){let{t:n}=s(`openhands`),{navigate:r}=F(),{data:i,error:c}=v(),l=i?.workspaceParents??[],{mutate:h}=m(),{mutate:y}=b(),{mutate:x}=d(),{mutate:S}=f(),{workspaces:C,isLoading:w,isError:T,error:E}=g(),D=u(c??E,n),[O,k]=X.useState(null),[A,j]=X.useState(!1),[M,P]=X.useState(!1),{mutate:I,isPending:L,isSuccess:R}=G(),z=o(),B=L||R||z,V=l.length>0||!!D,H=null;D?H=D:w?H=n(a.HOME$LOADING):T&&(H=n(a.HOME$WORKSPACE_SCAN_ERROR));let U=!!D||e||w&&C.length===0;return(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[!t&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-[10px] pb-4`,children:[(0,Q.jsx)(re,{width:24,height:24}),(0,Q.jsx)(`span`,{className:`leading-5 font-bold text-base text-white`,children:n(a.HOME$WORKSPACES_TAB)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-[10px] pb-4`,children:[(0,Q.jsx)(Ce,{workspaces:C,value:O,placeholder:D?n(a.HOME$WORKSPACES_UNSUPPORTED_PLACEHOLDER):U?n(a.HOME$LOADING):void 0,disabled:U,disabledTooltip:D,showManage:C.length>0||l.length>0,onChange:k,onAddClick:()=>j(!0),onManageClick:()=>P(!0),className:`max-w-auto`}),V&&H&&(0,Q.jsx)(`p`,{className:`px-1 text-xs text-[var(--oh-text-secondary)]`,"data-testid":`workspace-status-message`,children:H})]}),(0,Q.jsx)(N,{testId:`workspace-launch-button`,variant:`primary`,type:`button`,isDisabled:!O||!t&&B||e,onClick:()=>{if(O){if(t){t(O);return}I({workingDir:O.path},{onSuccess:e=>r(`/conversations/${e.conversation_id}`)})}},className:t?`w-full`:`w-auto absolute bottom-5 left-5 right-5`,children:t?n(a.BUTTON$CONFIRM):B?n(a.HOME$LOADING):`Launch`}),(0,Q.jsx)(p,{isOpen:A,onClose:()=>j(!1),onAdd:e=>h(e),onAddParent:e=>x(e)}),(0,Q.jsx)(_,{isOpen:M,workspaces:C,workspaceParents:l,onClose:()=>P(!1),onRemove:e=>{O?.path===e&&k(null),y(e)},onRemoveParent:e=>{O?.parentPath===e&&k(null),S(e)}})]})}function Te({isOpen:e,onClose:t,onConfirm:n}){let{t:r}=s(`openhands`),{isLoadingSettings:i}=z();return e?(0,Q.jsx)(E,{onClose:t,children:(0,Q.jsxs)(D,{width:`sm`,className:`relative items-start border border-[var(--oh-border)] !gap-4`,children:[(0,Q.jsx)(W,{onClose:t,testId:`close-open-workspace-dialog`}),(0,Q.jsx)(`div`,{className:`w-full pr-6`,children:(0,Q.jsx)(O,{title:r(a.HOME$OPEN_WORKSPACE)})}),(0,Q.jsx)(`div`,{className:`w-full`,"data-testid":`open-workspace-dialog-body`,children:(0,Q.jsx)(we,{isLoadingSettings:i,onConfirm:e=>{n(e),t()}})})]})}):null}function Ee({onRepoSelection:e,isLoadingSettings:t=!1,onConfirm:n}){let{navigate:r}=F(),[i,c]=X.useState(null),[l,u]=X.useState(null),[d,f]=X.useState(null),{providers:p}=z(),{addRecentRepository:m,setLastSelectedProvider:h,getLastSelectedProvider:g}=H(),{mutate:_,isPending:v,isSuccess:y}=G(),b=o(),{t:x}=s(`openhands`);X.useEffect(()=>{if(p.length!==0){if(p.length===1&&!d){f(p[0]);return}if(p.length>1&&!d){let e=g();e&&p.includes(e)&&f(e)}}},[p,d,g]);let S=v||y||b,C=t=>{t!==d&&(f(t),h(t),c(null),u(null),e?.(null))},w=X.useCallback(e=>{u(e)},[]);return(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[!n&&(0,Q.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-[10px] pb-4`,children:[(0,Q.jsx)(B,{width:24,height:24}),(0,Q.jsx)(`span`,{className:`leading-5 font-bold text-base text-white`,children:x(a.COMMON$OPEN_REPOSITORY)})]})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-[10px] pb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-white font-normal leading-[22px]`,children:x(a.HOME$SELECT_OR_INSERT_URL)}),p.length<=1?null:(0,Q.jsx)(oe,{providers:p,value:d,placeholder:`Select Provider`,className:`max-w-[500px]`,onChange:C,disabled:t})]}),(0,Q.jsx)(he,{provider:d||p[0],value:i?.id||null,repositoryName:i?.full_name||null,placeholder:`user/repo`,disabled:!d||t,onChange:t=>{t?(e?.(t),c(t)):(e?.(null),c(null),u(null))},className:`max-w-auto`}),(()=>{let e=i?.main_branch||null;return(0,Q.jsx)(ue,{repository:i?.full_name||null,provider:d||p[0],selectedBranch:l,onBranchSelect:w,defaultBranch:e,placeholder:`Select branch...`,className:`max-w-full`,disabled:!i||t})})()]}),(0,Q.jsx)(N,{testId:`repo-launch-button`,variant:`primary`,type:`button`,isDisabled:!i||!l||!n&&S||p.length>1&&!d||t,onClick:()=>{if(!(!i||!l)){if(m(i),n){n({repository:i,branch:l,provider:d});return}_({repository:{name:i.full_name||``,gitProvider:i.git_provider||`github`,branch:l.name||`main`}},{onSuccess:e=>r(`/conversations/${e.conversation_id}`)})}},className:`w-full`,children:n?x(a.BUTTON$CONFIRM):S?x(`HOME$LOADING`):`Launch`})]})}function De({isOpen:e,onClose:t,onConfirm:n}){let{t:r}=s(`openhands`),{isLoadingSettings:i}=z();return e?(0,Q.jsx)(E,{onClose:t,children:(0,Q.jsxs)(D,{width:`sm`,className:`relative items-start border border-[var(--oh-border)] !gap-4`,children:[(0,Q.jsx)(W,{onClose:t,testId:`close-open-repository-dialog`}),(0,Q.jsx)(`div`,{className:`w-full pr-6`,children:(0,Q.jsx)(O,{title:r(a.COMMON$OPEN_REPOSITORY)})}),(0,Q.jsx)(`div`,{className:`w-full`,"data-testid":`open-repository-dialog-body`,children:(0,Q.jsx)(Ee,{isLoadingSettings:i,onConfirm:e=>{n(e),t()}})})]})}):null}function $({workspace:e,repository:t,branch:n,provider:r,onRepoClick:i}){let a=e?e.path.replace(/\/+$/,``).split(`/`).pop()||e.path:null;return(0,Q.jsxs)(`div`,{className:`flex flex-row gap-2.5 items-center flex-wrap`,"data-testid":`home-git-control-bar-preview`,children:[(0,Q.jsx)(fe,{selectedRepository:t?.full_name??null,gitProvider:r??null,workspaceName:a,onClick:i}),n?(0,Q.jsx)(_e,{selectedBranch:n.name,selectedRepository:t?.full_name??null,gitProvider:r??null}):null]})}function Oe(){let{t:e}=s(`openhands`),{backend:t}=T(),{navigate:n}=F(),r=t.kind===`local`,[i,c]=(0,X.useState)(!1),[l,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(null),{mutate:y,isPending:b}=G(),w=o(),E=b||w,{images:D,files:O,imagesMarkedUploadAsFile:k,clearAllFiles:A}=U(),{handleUpload:j}=ce(),{error:M}=v({enabled:r}),N=r?u(M,e):null,P=r?!!l:!!f&&!!m,I=le(null,t=>{let i=t.trim(),o=D.length>0||O.length>0;if(!i&&!o||E)return;let s={images:[...D],files:[...O]},c={query:o?void 0:i||void 0};r&&l?c={...c,workingDir:l.path}:!r&&f&&m&&(c={...c,repository:{name:f.full_name,gitProvider:f.git_provider,branch:m.name}});let u=x.loading(e(a.HOME$CREATING_CONVERSATION),C);y(c,{onSuccess:async t=>{x.dismiss(u);try{sessionStorage.removeItem(q)}catch{}let a=t.conversation_id,c=a.startsWith(`task-`);if(o)if(!r||c){let e=t.task_id??(c?a.slice(5):null);if(!e){S(null);return}ae(e,{content:i,images:s.images,files:s.files,imagesMarkedUploadAsFile:[...k]}),A(),await Z({conversationId:a,text:i,images:s.images,imagesMarkedUploadAsFile:k}),n(`/conversations/${a}`);return}else try{await ie({conversationId:a,content:i,images:s.images,files:s.files,imagesMarkedUploadAsFile:k,t:e}),A()}catch(e){S(e instanceof Error?e.message:null);return}c&&i&&await Z({conversationId:a,text:i,images:[],imagesMarkedUploadAsFile:[]}),n(`/conversations/${a}`)},onError:e=>{x.dismiss(u),S(e instanceof Error?e.message:null)}})});return(0,Q.jsxs)(`div`,{"data-testid":`home-chat-launcher`,className:`flex w-full max-w-[800px] flex-col gap-4 md:px-4`,children:[(0,Q.jsx)(`div`,{className:`flex w-full justify-center`,children:(0,Q.jsx)(xe,{})}),(0,Q.jsx)(`div`,{className:`w-full`,children:(0,Q.jsx)(me,{onSubmit:I,onFilesPaste:j,disabled:E})}),(0,Q.jsx)(`div`,{className:`flex justify-start`,children:P?(0,Q.jsx)($,{workspace:l,repository:f,branch:m,provider:g,onRepoClick:()=>c(!0)}):(0,Q.jsx)(Se,{kind:r?`local`:`cloud`,onClick:()=>c(!0),disabled:E||!!N,disabledTooltip:N})}),r?(0,Q.jsx)(Te,{isOpen:i,onClose:()=>c(!1),onConfirm:e=>{d(e),p(null),h(null),_(null)}}):(0,Q.jsx)(De,{isOpen:i,onClose:()=>c(!1),onConfirm:({repository:e,branch:t,provider:n})=>{p(e),h(t),_(n??e.git_provider),d(null)}})]})}function ke(){let{data:e,isLoading:t,isError:n}=ee(),{data:r,isLoading:i,isError:a}=P(),{data:o,isLoading:s,isError:c}=te(),l=e?.agent_settings?.agent_kind===`acp`,u=e?.llm_api_key_set===!0,d=o?.profiles.find(e=>e.name===o.active_profile)?.api_key_set===!0,f=be(`/settings/llm`,r?.feature_flags);return{isConfigured:l||u||d||f,isLoading:t||n&&!e||i||a&&!r||s||c&&!o}}function Ae(){let{t:e}=s(`openhands`),{navigate:t}=F(),{isConfigured:n,isLoading:r}=ke();return r||n?null:(0,Q.jsxs)(`div`,{"data-testid":`home-llm-not-configured-banner`,role:`alert`,className:`bg-base border border-primary text-white p-4 rounded flex flex-row items-center justify-between gap-3 mt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(`div`,{className:`flex-shrink-0`,children:(0,Q.jsx)(ne,{className:`text-primary align-middle`})}),(0,Q.jsx)(K.Text,{className:`ml-3 text-sm font-medium`,children:e(a.HOME$LLM_NOT_CONFIGURED_MESSAGE)})]}),(0,Q.jsx)(N,{testId:`home-llm-not-configured-action`,type:`button`,variant:`primary`,onClick:()=>t(`/settings/llm`),children:e(a.HOME$LLM_NOT_CONFIGURED_ACTION)})]})}function je(){let e=h(r().search);return(0,Q.jsxs)(`div`,{"data-testid":`home-screen`,className:`custom-scrollbar-always flex h-full flex-col overflow-y-auto rounded-xl bg-transparent px-4 md:px-0 lg:px-[42px]`,children:[(0,Q.jsx)(Ae,{}),(0,Q.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col items-center justify-center`,children:(0,Q.jsx)(Oe,{})}),e?null:(0,Q.jsx)(y,{})]})}var Me=n(je);export{Me as default};
1
+ import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{L as n,k as r}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{o as i,t as a}from"./declaration-DaUdB2Wg.js";import{r as o}from"./recommended-automations-launcher-BIul0osB.js";import{t as s}from"./useTranslation-CEcjrme-.js";import{t as c}from"./vendor~root-layout~home~conversation-panel~conversation-DkwcKRtv.js";import{a as l}from"./vendor~root-layout~home~mcp~automations-list-BnIlGhjl.js";import{a as u,c as d,d as f,i as p,l as m,n as h,o as g,r as _,s as v,t as y,u as b}from"./onboarding-CPCKYvFh.js";import{a as x,n as S,t as C}from"./custom-toast-handlers-BohXx7uh.js";import{t as w}from"./utils-CdgBzLA7.js";import{n as T}from"./active-backend-context-I2w666XY.js";import{t as E}from"./modal-backdrop-BDqI1zBV.js";import{n as D}from"./modal-body-CCLCqX1J.js";import{r as O}from"./base-modal-DZCNv0A4.js";import{a as k,g as A,o as j,p as M,t as N}from"./brand-button-LBFNic99.js";import{t as P}from"./use-config-DwfigQ_Y.js";import{n as F}from"./navigation-context-aNGUUtdq.js";import{t as I}from"./styled-tooltip-TCp7svY3.js";import{i as L,n as R}from"./dropdown-classes-Vqz86I0R.js";import{c as z,f as B,l as V,r as H}from"./chat-send-button-5qz0zj6R.js";import{t as U}from"./conversation-store-CC-isCnP.js";import{t as W}from"./modal-close-button-gQgKqUf-.js";import{r as ee}from"./use-settings-BPTbE7lg.js";import{t as G}from"./use-create-conversation-BEzddjXn.js";import{t as te}from"./use-llm-profiles-E-jjZMZw.js";import{l as ne}from"./vendor~root-layout~home~conversation-panel~conversation~shared-conversation~alert-banner~pl~rqjteh0a-CcFtthyg.js";import{t as re}from"./folder-2h1hR1Qb.js";import{r as K}from"./typography-Bvw0IxaN.js";import{A as ie,F as q,I as J,M as Y,N as ae,a as oe,c as se,d as ce,f as le,i as ue,l as de,n as fe,o as pe,p as me,r as he,s as ge,t as _e,u as ve}from"./git-control-bar-branch-button-D8blTNXh.js";import{d as ye}from"./conversation-websocket-context-G95yfL81.js";import{r as be}from"./settings-utils-BxzHqLmZ.js";var X=e(t(),1);async function Z(e){let{imagesToEmbed:t}=J(e.images,e.imagesMarkedUploadAsFile),n=await Promise.all(t.map(e=>Y(e)));ye.getState().enqueuePendingMessage({conversationId:e.conversationId,text:e.text,content:e.text,imageUrls:n,fileUrls:[]})}var Q=i();function xe(){let{t:e}=s(`openhands`);return(0,Q.jsx)(`div`,{className:`flex min-h-[80px] w-full items-center justify-center py-2`,children:(0,Q.jsx)(K.H1,{className:`w-full text-center leading-normal`,children:e(`HOME$LETS_START_BUILDING`)})})}function Se({kind:e,onClick:t,disabled:n=!1,disabledTooltip:r}){let{t:i}=s(`openhands`),o=e===`local`,c=i(o?a.HOME$OPEN_WORKSPACE:a.COMMON$OPEN_REPOSITORY),u=(0,Q.jsxs)(`button`,{type:`button`,"data-testid":o?`open-workspace-button`:`open-repository-button`,onClick:t,disabled:n,className:w(`flex flex-row items-center gap-2 rounded-full px-2.5 py-1 text-white`,k,M,A,n?`cursor-not-allowed opacity-50`:`cursor-pointer hover:bg-surface-raised`),children:[(0,Q.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center`,children:o?(0,Q.jsx)(l,{"aria-hidden":!0,className:`h-4 w-4`,strokeWidth:2}):(0,Q.jsx)(B,{width:16,height:16,className:`shrink-0`})}),(0,Q.jsx)(`span`,{className:`text-sm font-normal leading-5`,children:c})]});return r?(0,Q.jsx)(I,{content:r,placement:`top`,children:(0,Q.jsx)(`span`,{className:`inline-flex`,children:u})}):u}function Ce({workspaces:e,value:t,placeholder:n,className:r,disabled:i=!1,disabledTooltip:o,showManage:l,onChange:u,onAddClick:d,onManageClick:f}){let{t:p}=s(`openhands`),[m,h]=(0,X.useState)(t?.name??``),g=(0,X.useRef)(null),_=(0,X.useMemo)(()=>{let t=m.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.path.toLowerCase().includes(t)):e},[e,m]),v=(0,X.useCallback)(e=>{u(e),e&&h(e.name)},[u]),y=(0,X.useCallback)(()=>{v(null),h(``)},[v]),{isOpen:b,getToggleButtonProps:x,getMenuProps:S,getInputProps:C,highlightedIndex:T,getItemProps:E,selectedItem:D,closeMenu:O}=c({items:_,itemToString:e=>e?.name??``,selectedItem:t,onSelectedItemChange:({selectedItem:e})=>{v(e??null)},inputValue:m,stateReducer:(e,t)=>t.type===c.stateChangeTypes.InputClick&&e.isOpen?{...t.changes,isOpen:!0}:t.changes}),k=(e,t,n,r,i)=>(0,Q.jsx)(se,{item:e,index:t,isSelected:r?.id===e.id,getItemProps:i,getDisplayText:e=>e.name,getItemKey:e=>e.id},e.id),A=e=>(0,Q.jsx)(ge,{inputValue:e,searchMessage:p(a.HOME$NO_WORKSPACES),emptyMessage:p(a.HOME$NO_WORKSPACES),testId:`workspace-dropdown-empty`}),M=(0,X.useMemo)(()=>(0,Q.jsxs)(`div`,{className:L,children:[(0,Q.jsx)(`button`,{type:`button`,"data-testid":`add-workspaces-button`,className:w(R,`cursor-pointer`),onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation(),O(),d()},children:p(a.HOME$ADD_WORKSPACES)}),(l??e.length>0)&&(0,Q.jsx)(`button`,{type:`button`,"data-testid":`manage-workspaces-button`,className:w(R,`cursor-pointer`),onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation(),O(),f()},children:p(a.HOME$MANAGE_WORKSPACES)})]}),[d,f,p,O,e.length,l]),N=(0,Q.jsxs)(`div`,{className:w(`relative`,r),children:[(0,Q.jsxs)(`div`,{className:`group relative text-[var(--oh-muted)] hover:text-white`,children:[(0,Q.jsx)(`div`,{className:`absolute left-2 top-1/2 transform -translate-y-1/2 z-10`,children:(0,Q.jsx)(V,{width:16,height:16})}),(0,Q.jsx)(`input`,{...C({disabled:i,placeholder:n??p(a.HOME$WORKSPACE_PLACEHOLDER),className:w(j,`text-inherit shadow-none pl-7 pr-16 text-sm font-normal leading-5`,`placeholder:text-[var(--oh-muted)]`,`disabled:cursor-not-allowed disabled:opacity-60`),onChange:e=>{h(e.target.value)}}),"data-testid":`workspace-dropdown`}),(0,Q.jsxs)(`div`,{className:`absolute right-1 top-1/2 transform -translate-y-1/2 flex items-center`,children:[t&&(0,Q.jsx)(ve,{disabled:i,onClear:y}),(0,Q.jsx)(de,{isOpen:b,disabled:i,getToggleButtonProps:x})]})]}),(0,Q.jsx)(pe,{isOpen:b,filteredItems:_,inputValue:m,highlightedIndex:T,selectedItem:D,getMenuProps:S,getItemProps:E,menuRef:g,renderItem:k,renderEmptyState:A,stickyFooterItem:M,testId:`workspace-dropdown-menu`,itemKey:e=>e.id})]});return o?(0,Q.jsx)(I,{content:o,placement:`top`,children:(0,Q.jsx)(`span`,{className:`block`,children:N})}):N}function we({isLoadingSettings:e=!1,onConfirm:t}){let{t:n}=s(`openhands`),{navigate:r}=F(),{data:i,error:c}=v(),l=i?.workspaceParents??[],{mutate:h}=m(),{mutate:y}=b(),{mutate:x}=d(),{mutate:S}=f(),{workspaces:C,isLoading:w,isError:T,error:E}=g(),D=u(c??E,n),[O,k]=X.useState(null),[A,j]=X.useState(!1),[M,P]=X.useState(!1),{mutate:I,isPending:L,isSuccess:R}=G(),z=o(),B=L||R||z,V=l.length>0||!!D,H=null;D?H=D:w?H=n(a.HOME$LOADING):T&&(H=n(a.HOME$WORKSPACE_SCAN_ERROR));let U=!!D||e||w&&C.length===0;return(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[!t&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-[10px] pb-4`,children:[(0,Q.jsx)(re,{width:24,height:24}),(0,Q.jsx)(`span`,{className:`leading-5 font-bold text-base text-white`,children:n(a.HOME$WORKSPACES_TAB)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-[10px] pb-4`,children:[(0,Q.jsx)(Ce,{workspaces:C,value:O,placeholder:D?n(a.HOME$WORKSPACES_UNSUPPORTED_PLACEHOLDER):U?n(a.HOME$LOADING):void 0,disabled:U,disabledTooltip:D,showManage:C.length>0||l.length>0,onChange:k,onAddClick:()=>j(!0),onManageClick:()=>P(!0),className:`max-w-auto`}),V&&H&&(0,Q.jsx)(`p`,{className:`px-1 text-xs text-[var(--oh-text-secondary)]`,"data-testid":`workspace-status-message`,children:H})]}),(0,Q.jsx)(N,{testId:`workspace-launch-button`,variant:`primary`,type:`button`,isDisabled:!O||!t&&B||e,onClick:()=>{if(O){if(t){t(O);return}I({workingDir:O.path},{onSuccess:e=>r(`/conversations/${e.conversation_id}`)})}},className:t?`w-full`:`w-auto absolute bottom-5 left-5 right-5`,children:t?n(a.BUTTON$CONFIRM):B?n(a.HOME$LOADING):`Launch`}),(0,Q.jsx)(p,{isOpen:A,onClose:()=>j(!1),onAdd:e=>h(e),onAddParent:e=>x(e)}),(0,Q.jsx)(_,{isOpen:M,workspaces:C,workspaceParents:l,onClose:()=>P(!1),onRemove:e=>{O?.path===e&&k(null),y(e)},onRemoveParent:e=>{O?.parentPath===e&&k(null),S(e)}})]})}function Te({isOpen:e,onClose:t,onConfirm:n}){let{t:r}=s(`openhands`),{isLoadingSettings:i}=z();return e?(0,Q.jsx)(E,{onClose:t,children:(0,Q.jsxs)(D,{width:`sm`,className:`relative items-start border border-[var(--oh-border)] !gap-4`,children:[(0,Q.jsx)(W,{onClose:t,testId:`close-open-workspace-dialog`}),(0,Q.jsx)(`div`,{className:`w-full pr-6`,children:(0,Q.jsx)(O,{title:r(a.HOME$OPEN_WORKSPACE)})}),(0,Q.jsx)(`div`,{className:`w-full`,"data-testid":`open-workspace-dialog-body`,children:(0,Q.jsx)(we,{isLoadingSettings:i,onConfirm:e=>{n(e),t()}})})]})}):null}function Ee({onRepoSelection:e,isLoadingSettings:t=!1,onConfirm:n}){let{navigate:r}=F(),[i,c]=X.useState(null),[l,u]=X.useState(null),[d,f]=X.useState(null),{providers:p}=z(),{addRecentRepository:m,setLastSelectedProvider:h,getLastSelectedProvider:g}=H(),{mutate:_,isPending:v,isSuccess:y}=G(),b=o(),{t:x}=s(`openhands`);X.useEffect(()=>{if(p.length!==0){if(p.length===1&&!d){f(p[0]);return}if(p.length>1&&!d){let e=g();e&&p.includes(e)&&f(e)}}},[p,d,g]);let S=v||y||b,C=t=>{t!==d&&(f(t),h(t),c(null),u(null),e?.(null))},w=X.useCallback(e=>{u(e)},[]);return(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[!n&&(0,Q.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-[10px] pb-4`,children:[(0,Q.jsx)(B,{width:24,height:24}),(0,Q.jsx)(`span`,{className:`leading-5 font-bold text-base text-white`,children:x(a.COMMON$OPEN_REPOSITORY)})]})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-[10px] pb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-white font-normal leading-[22px]`,children:x(a.HOME$SELECT_OR_INSERT_URL)}),p.length<=1?null:(0,Q.jsx)(oe,{providers:p,value:d,placeholder:`Select Provider`,className:`max-w-[500px]`,onChange:C,disabled:t})]}),(0,Q.jsx)(he,{provider:d||p[0],value:i?.id||null,repositoryName:i?.full_name||null,placeholder:`user/repo`,disabled:!d||t,onChange:t=>{t?(e?.(t),c(t)):(e?.(null),c(null),u(null))},className:`max-w-auto`}),(()=>{let e=i?.main_branch||null;return(0,Q.jsx)(ue,{repository:i?.full_name||null,provider:d||p[0],selectedBranch:l,onBranchSelect:w,defaultBranch:e,placeholder:`Select branch...`,className:`max-w-full`,disabled:!i||t})})()]}),(0,Q.jsx)(N,{testId:`repo-launch-button`,variant:`primary`,type:`button`,isDisabled:!i||!l||!n&&S||p.length>1&&!d||t,onClick:()=>{if(!(!i||!l)){if(m(i),n){n({repository:i,branch:l,provider:d});return}_({repository:{name:i.full_name||``,gitProvider:i.git_provider||`github`,branch:l.name||`main`}},{onSuccess:e=>r(`/conversations/${e.conversation_id}`)})}},className:`w-full`,children:n?x(a.BUTTON$CONFIRM):S?x(`HOME$LOADING`):`Launch`})]})}function De({isOpen:e,onClose:t,onConfirm:n}){let{t:r}=s(`openhands`),{isLoadingSettings:i}=z();return e?(0,Q.jsx)(E,{onClose:t,children:(0,Q.jsxs)(D,{width:`sm`,className:`relative items-start border border-[var(--oh-border)] !gap-4`,children:[(0,Q.jsx)(W,{onClose:t,testId:`close-open-repository-dialog`}),(0,Q.jsx)(`div`,{className:`w-full pr-6`,children:(0,Q.jsx)(O,{title:r(a.COMMON$OPEN_REPOSITORY)})}),(0,Q.jsx)(`div`,{className:`w-full`,"data-testid":`open-repository-dialog-body`,children:(0,Q.jsx)(Ee,{isLoadingSettings:i,onConfirm:e=>{n(e),t()}})})]})}):null}function $({workspace:e,repository:t,branch:n,provider:r,onRepoClick:i}){let a=e?e.path.replace(/\/+$/,``).split(`/`).pop()||e.path:null;return(0,Q.jsxs)(`div`,{className:`flex flex-row gap-2.5 items-center flex-wrap`,"data-testid":`home-git-control-bar-preview`,children:[(0,Q.jsx)(fe,{selectedRepository:t?.full_name??null,gitProvider:r??null,workspaceName:a,onClick:i}),n?(0,Q.jsx)(_e,{selectedBranch:n.name,selectedRepository:t?.full_name??null,gitProvider:r??null}):null]})}function Oe(){let{t:e}=s(`openhands`),{backend:t}=T(),{navigate:n}=F(),r=t.kind===`local`,[i,c]=(0,X.useState)(!1),[l,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(null),{mutate:y,isPending:b}=G(),w=o(),E=b||w,{images:D,files:O,imagesMarkedUploadAsFile:k,clearAllFiles:A}=U(),{handleUpload:j}=ce(),{error:M}=v({enabled:r}),N=r?u(M,e):null,P=r?!!l:!!f&&!!m,I=le(null,t=>{let i=t.trim(),o=D.length>0||O.length>0;if(!i&&!o||E)return;let s={images:[...D],files:[...O]},c={query:o?void 0:i||void 0};r&&l?c={...c,workingDir:l.path}:!r&&f&&m&&(c={...c,repository:{name:f.full_name,gitProvider:f.git_provider,branch:m.name}});let u=x.loading(e(a.HOME$CREATING_CONVERSATION),C);y(c,{onSuccess:async t=>{x.dismiss(u);try{sessionStorage.removeItem(q)}catch{}let a=t.conversation_id,c=a.startsWith(`task-`);if(o)if(!r||c){let e=t.task_id??(c?a.slice(5):null);if(!e){S(null);return}ae(e,{content:i,images:s.images,files:s.files,imagesMarkedUploadAsFile:[...k]}),A(),await Z({conversationId:a,text:i,images:s.images,imagesMarkedUploadAsFile:k}),n(`/conversations/${a}`);return}else try{await ie({conversationId:a,content:i,images:s.images,files:s.files,imagesMarkedUploadAsFile:k,t:e}),A()}catch(e){S(e instanceof Error?e.message:null);return}c&&i&&await Z({conversationId:a,text:i,images:[],imagesMarkedUploadAsFile:[]}),n(`/conversations/${a}`)},onError:e=>{x.dismiss(u),S(e instanceof Error?e.message:null)}})});return(0,Q.jsxs)(`div`,{"data-testid":`home-chat-launcher`,className:`flex w-full max-w-[800px] flex-col gap-4 md:px-4`,children:[(0,Q.jsx)(`div`,{className:`flex w-full justify-center`,children:(0,Q.jsx)(xe,{})}),(0,Q.jsx)(`div`,{className:`w-full`,children:(0,Q.jsx)(me,{onSubmit:I,onFilesPaste:j,disabled:E})}),(0,Q.jsx)(`div`,{className:`flex justify-start`,children:P?(0,Q.jsx)($,{workspace:l,repository:f,branch:m,provider:g,onRepoClick:()=>c(!0)}):(0,Q.jsx)(Se,{kind:r?`local`:`cloud`,onClick:()=>c(!0),disabled:E||!!N,disabledTooltip:N})}),r?(0,Q.jsx)(Te,{isOpen:i,onClose:()=>c(!1),onConfirm:e=>{d(e),p(null),h(null),_(null)}}):(0,Q.jsx)(De,{isOpen:i,onClose:()=>c(!1),onConfirm:({repository:e,branch:t,provider:n})=>{p(e),h(t),_(n??e.git_provider),d(null)}})]})}function ke(){let{data:e,isLoading:t,isError:n}=ee(),{data:r,isLoading:i,isError:a}=P(),{data:o,isLoading:s,isError:c}=te(),l=e?.agent_settings?.agent_kind===`acp`,u=e?.llm_api_key_set===!0,d=o?.profiles.find(e=>e.name===o.active_profile)?.api_key_set===!0,f=be(`/settings/llm`,r?.feature_flags);return{isConfigured:l||u||d||f,isLoading:t||n&&!e||i||a&&!r||s||c&&!o}}function Ae(){let{t:e}=s(`openhands`),{navigate:t}=F(),{isConfigured:n,isLoading:r}=ke();return r||n?null:(0,Q.jsxs)(`div`,{"data-testid":`home-llm-not-configured-banner`,role:`alert`,className:`bg-base border border-primary text-white p-4 rounded flex flex-row items-center justify-between gap-3 mt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(`div`,{className:`flex-shrink-0`,children:(0,Q.jsx)(ne,{className:`text-primary align-middle`})}),(0,Q.jsx)(K.Text,{className:`ml-3 text-sm font-medium`,children:e(a.HOME$LLM_NOT_CONFIGURED_MESSAGE)})]}),(0,Q.jsx)(N,{testId:`home-llm-not-configured-action`,type:`button`,variant:`primary`,onClick:()=>t(`/settings/llm`),children:e(a.HOME$LLM_NOT_CONFIGURED_ACTION)})]})}function je(){let e=h(r().search);return(0,Q.jsxs)(`div`,{"data-testid":`home-screen`,className:`custom-scrollbar-always flex h-full flex-col overflow-y-auto rounded-xl bg-transparent px-4 md:px-0 lg:px-[42px]`,children:[(0,Q.jsx)(Ae,{}),(0,Q.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col items-center justify-center`,children:(0,Q.jsx)(Oe,{})}),e?null:(0,Q.jsx)(y,{})]})}var Me=n(je);export{Me as default};
@@ -0,0 +1 @@
1
+ import{n as e}from"./llm-settings-DotqpmCF.js";export{e as default};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{L as n}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{t as r}from"./react-dom-hVBnwgwZ.js";import{t as i}from"./useMutation-DDo48A8t.js";import{o as a,t as o}from"./declaration-DaUdB2Wg.js";import{n as s}from"./QueryClientProvider-w1cZWY41.js";import{t as c}from"./useTranslation-CEcjrme-.js";import{t as l}from"./createLucideIcon-Ddu8jDOQ.js";import{t as u}from"./back-nav-button-DgkK0Ka6.js";import{n as d,r as f}from"./custom-toast-handlers-BohXx7uh.js";import{t as p}from"./utils-CdgBzLA7.js";import{n as m}from"./active-backend-context-I2w666XY.js";import{a as h,n as g}from"./query-keys-tAsQcc_9.js";import{t as _}from"./modal-backdrop-BDqI1zBV.js";import{r as v,t as y}from"./modal-body-CCLCqX1J.js";import{r as b}from"./base-modal-DZCNv0A4.js";import{t as x}from"./brand-button-LBFNic99.js";import{t as S}from"./loading-spinner-DNwR4--Z.js";import{n as C,t as w}from"./model-selector-DoL0CL0_.js";import{i as T}from"./dropdown-classes-Vqz86I0R.js";import{t as E}from"./settings-input-8y5p4kze.js";import{t as D}from"./settings-DGY6n4J2.js";import{t as O}from"./settings-service.api-DxIEtvx6.js";import{r as k}from"./use-settings-BPTbE7lg.js";import{a as A,n as j,o as M,r as N,t as P}from"./use-llm-profiles-E-jjZMZw.js";import{t as F}from"./u-edit-BIYzjs3v.js";import{c as ee,d as I,u as te}from"./sdk-settings-schema-DFievvEK.js";import{t as L}from"./use-agent-settings-schema-Yxf7KGyG.js";import{t as ne}from"./sdk-section-page-VmtJWH3A.js";import{r as re}from"./typography-Bvw0IxaN.js";import{t as ie}from"./u-check-circle-u9QiS4Fr.js";import{i as ae,n as oe,r as se,t as ce}from"./settings-list-classes-Qk7zl0Wu.js";import{n as le}from"./settings-section-header-context-B77tsYlx.js";var ue=l(`text-cursor`,[[`path`,{d:`M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1`,key:`uvaxm9`}],[`path`,{d:`M7 22h1a4 4 0 0 0 4-4v-1`,key:`11xy8d`}],[`path`,{d:`M7 2h1a4 4 0 0 1 4 4v1`,key:`1uw06m`}]]),R=e(t()),z=a(),de=e=>(0,z.jsxs)(`svg`,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,z.jsx)(`path`,{d:`M9.9509 15.588H10.8349L16.5125 9.91042L15.6285 9.0264L10.3991 14.2681L8.00867 11.8777L7.12465 12.7617L9.9509 15.588Z`,fill:`currentColor`}),(0,z.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.8521 3.29895C14.8443 3.42346 16.712 4.41954 18.0816 5.78916C19.7002 7.53231 20.5718 9.64898 20.5718 12.1392C20.5718 14.1314 19.8247 15.999 18.5796 17.6177C17.3345 19.1118 15.5914 20.2324 13.5992 20.6059C11.607 20.9794 9.61486 20.7304 7.87171 19.7343C6.12856 18.7382 4.75895 17.2441 4.01189 15.3765C3.26482 13.5088 3.14031 11.3921 3.76286 9.52447C4.38542 7.53231 5.50601 5.91367 7.24916 4.79308C8.86779 3.67248 10.86 3.17444 12.8521 3.29895ZM13.4747 19.3608C15.0933 18.9873 16.5874 18.1157 17.708 16.7461C18.7041 15.3765 19.3267 13.7578 19.2022 12.0147C19.2022 10.0225 18.4551 8.03035 17.0855 6.66073C15.8404 5.41563 14.3463 4.66857 12.6031 4.54405C10.9845 4.41954 9.24132 4.79308 7.87171 5.78916C6.50209 6.78524 5.50601 8.15486 5.00797 9.89801C4.50993 11.5166 4.50993 13.2598 5.25699 14.8784C6.00405 16.4971 7.12465 17.7422 8.61877 18.6137C10.1129 19.4853 11.856 19.7343 13.4747 19.3608Z`,fill:`currentColor`})]});function fe({testId:e,isSet:t}){return(0,z.jsx)(`span`,{"data-testid":e||(t?`set-indicator`:`unset-indicator`),children:(0,z.jsx)(de,{className:p(t?`text-success`:`text-danger`)})})}var B=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function V(e,{isRequired:t=!1}={}){return e===``?!t:B.test(e)}function H(e){let t=e.split(`/`),n=(t[t.length-1]||e).replace(/[^A-Za-z0-9._-]/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``);return n&&!/^[A-Za-z0-9]/.test(n)&&(n=`profile-${n}`),n.length>64&&(n=n.substring(0,64).replace(/-+$/,``)),n||`default-profile`}var U=(0,R.forwardRef)(function({testId:e,ruleTestId:t,value:n,onChange:r,onKeyDown:i,placeholder:a,isDisabled:s,isOptional:l,isRequired:u=!1},d){let{t:f}=c(`openhands`),m=V(n,{isRequired:u}),h=l?`${f(o.SETTINGS$PROFILE_NAME_LABEL)} (${f(o.COMMON$OPTIONAL)})`:f(o.SETTINGS$PROFILE_NAME_LABEL),g=R.useId(),_=t??`${g}-rule`;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(E,{ref:d,testId:e,label:h,type:`text`,className:`w-full`,value:n,placeholder:a??f(o.SETTINGS$PROFILE_NAME_PLACEHOLDER),onChange:r,onKeyDown:i,isDisabled:s,ariaDescribedBy:_,ariaInvalid:!m}),(0,z.jsx)(`p`,{id:_,"data-testid":t,className:p(`text-xs`,m?`text-[var(--oh-muted)]`:`text-red-400`),children:f(o.SETTINGS$PROFILE_NAME_RULE)})]})});function W({isOpen:e,title:t,width:n=`md`,children:r,footer:i,onClose:a,initialFocusRef:o}){let s=(0,R.useRef)(null);return(0,R.useEffect)(()=>{if(!e)return;let t=o?.current??s.current;if(t){let e=setTimeout(()=>{t.focus()},0);return()=>clearTimeout(e)}},[e,o]),(0,R.useEffect)(()=>{if(!e||!s.current)return;let t=s.current,n=e=>{if(e.key!==`Tab`)return;let n=t.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`),r=n[0],i=n[n.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),i?.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r?.focus())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e]),e?(0,z.jsx)(_,{onClose:a,children:(0,z.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`modal-title`,className:p(`bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]`,v(n),y),children:[(0,z.jsx)(b,{id:`modal-title`,title:t}),r,(0,z.jsx)(`div`,{className:`w-full flex justify-end gap-2 mt-2`,children:i})]})}):null}function pe(){let e=s();return i({mutationFn:({name:e,newName:t})=>j.renameProfile(e,t),onSuccess:async()=>{O.invalidateCache(),await e.invalidateQueries({queryKey:g.all}),await e.invalidateQueries({queryKey:h.personal()})},meta:{disableToast:!0}})}function me({profile:e,onClose:t}){let{t:n}=c(`openhands`),[r,i]=(0,R.useState)(``),a=pe(),s=(0,R.useRef)(null);if((0,R.useEffect)(()=>{i(e?.name??``)},[e?.name]),!e)return null;let l=V(r,{isRequired:!0}),u=r===e.name,p=async()=>{if(!l){d(n(o.SETTINGS$PROFILE_NAME_RULE));return}if(u){t();return}try{await a.mutateAsync({name:e.name,newName:r}),f(n(o.SETTINGS$PROFILE_RENAMED,{name:r})),t()}catch(e){d(e instanceof Error?e.message:n(o.ERROR$GENERIC))}},m=()=>{a.isPending||t()},h=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(x,{type:`button`,variant:`tertiary`,onClick:m,isDisabled:a.isPending,children:n(o.BUTTON$CANCEL)}),(0,z.jsx)(x,{testId:`rename-profile-submit`,type:`button`,variant:`primary`,onClick:p,isDisabled:a.isPending||!l,children:a.isPending?(0,z.jsx)(S,{size:`small`}):n(o.BUTTON$RENAME)})]});return(0,z.jsx)(W,{isOpen:!0,title:n(o.SETTINGS$PROFILE_RENAME_TITLE),footer:h,onClose:m,initialFocusRef:s,children:(0,z.jsx)(`div`,{"data-testid":`rename-profile-modal`,className:`flex flex-col gap-3`,children:(0,z.jsx)(U,{ref:s,testId:`rename-profile-input`,ruleTestId:`rename-profile-rule`,value:r,onChange:i,isRequired:!0,onKeyDown:e=>{e.key===`Enter`&&!a.isPending&&l&&p()}})})})}function he(){let e=s();return i({mutationFn:e=>j.deleteProfile(e),onSuccess:async()=>{O.invalidateCache(),await e.invalidateQueries({queryKey:g.all}),await e.invalidateQueries({queryKey:h.personal()})},meta:{disableToast:!0}})}function ge({profile:e,onClose:t}){let{t:n}=c(`openhands`),r=he(),i=(0,R.useRef)(null);if(!e)return null;let a=async()=>{try{await r.mutateAsync(e.name),f(n(o.SETTINGS$PROFILE_DELETED,{name:e.name})),t()}catch(e){d(e instanceof Error?e.message:n(o.ERROR$GENERIC))}},s=()=>{r.isPending||t()},l=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(x,{ref:i,type:`button`,variant:`tertiary`,onClick:s,isDisabled:r.isPending,children:n(o.BUTTON$CANCEL)}),(0,z.jsx)(x,{testId:`delete-profile-confirm`,type:`button`,variant:`danger`,onClick:a,isDisabled:r.isPending,"aria-busy":r.isPending,children:r.isPending?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(S,{size:`small`}),(0,z.jsx)(`span`,{className:`sr-only`,children:n(o.BUTTON$DELETE)})]}):n(o.BUTTON$DELETE)})]});return(0,z.jsx)(W,{isOpen:!0,title:n(o.SETTINGS$PROFILE_DELETE_TITLE),footer:l,onClose:s,initialFocusRef:i,children:(0,z.jsx)(`p`,{className:`text-sm break-all`,children:n(o.SETTINGS$PROFILE_DELETE_CONFIRMATION,{name:e.name})})})}var _e=e(r(),1);function G({index:e,icon:t,label:n,onClick:r,onKeyDown:i,menuItemsRef:a,disabled:o,testId:s}){return(0,z.jsx)(`button`,{ref:t=>{a.current[e]=t},type:`button`,onClick:r,onKeyDown:t=>i(t,e),disabled:o,className:p(`group w-full cursor-pointer rounded px-2 py-2 text-start text-nowrap text-sm font-normal`,`text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]`,`disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent`),role:`menuitem`,"data-testid":s,children:(0,z.jsx)(M,{icon:t,text:n})})}function ve({onEdit:e,onRename:t,onSetActive:n,onDelete:r,isActive:i,isActivating:a,onClose:s,anchorRef:l}){let{t:u}=c(`openhands`),d=(0,R.useRef)(null),f=(0,R.useRef)([]),m=l?.current??null,[h,g]=(0,R.useState)();(0,R.useLayoutEffect)(()=>{if(!m)return;let e=()=>{let e=m.getBoundingClientRect();e&&g({position:`fixed`,zIndex:9999,top:e.bottom+8,right:window.innerWidth-e.right,width:`max-content`})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[m]),(0,R.useEffect)(()=>{f.current[0]?.focus()},[]),(0,R.useEffect)(()=>{let e=e=>{let t=e.target;d.current&&!d.current.contains(t)&&s()},t=e=>{e.key===`Escape`&&s()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[s]);let _=e=>{e(),s()},v=(0,R.useCallback)((e,t)=>{if(e.key===`Tab`){s();return}let n=f.current.filter(Boolean).length;if(e.key===`ArrowDown`){e.preventDefault();let r=(t+1)%n;f.current[r]?.focus()}else if(e.key===`ArrowUp`){e.preventDefault();let r=(t-1+n)%n;f.current[r]?.focus()}},[s]),y=i||a,b=!!m,x=(0,z.jsxs)(`div`,{ref:d,className:p(`absolute right-0 top-full z-10 mt-2 w-[160px] rounded-md border border-[var(--oh-border-subtle)] bg-tertiary px-1 py-1 shadow-lg`,T,b&&`!static !top-auto !bottom-auto !left-auto !right-auto !mt-0`),role:`menu`,"aria-orientation":`vertical`,"data-testid":`profile-actions-menu`,children:[(0,z.jsx)(G,{index:0,icon:(0,z.jsx)(F,{width:16,height:16}),label:u(o.SETTINGS$PROFILE_EDIT),onClick:()=>_(e),onKeyDown:v,menuItemsRef:f,testId:`profile-edit`}),(0,z.jsx)(G,{index:1,icon:(0,z.jsx)(ue,{"aria-hidden":!0,className:`size-4`,strokeWidth:2}),label:u(o.BUTTON$RENAME),onClick:()=>_(t),onKeyDown:v,menuItemsRef:f,testId:`profile-rename`}),(0,z.jsx)(G,{index:2,icon:(0,z.jsx)(ie,{width:16,height:16}),label:u(o.SETTINGS$PROFILE_SET_ACTIVE),onClick:()=>_(n),onKeyDown:v,menuItemsRef:f,disabled:y,testId:`profile-set-active`}),(0,z.jsx)(G,{index:3,icon:(0,z.jsx)(A,{width:16,height:16}),label:u(o.BUTTON$DELETE),onClick:()=>_(r),onKeyDown:v,menuItemsRef:f,testId:`profile-delete`})]});return b?typeof document>`u`||!h?null:_e.createPortal((0,z.jsx)(`div`,{style:h,children:x}),document.body):x}function ye({children:e,className:t,...n}){return(0,z.jsx)(`span`,{className:p(`text-sm leading-4 text-black font-semibold tracking-tighter bg-primary p-1 rounded-full`,t),...n,children:e})}function be({profile:e,isActive:t,onActivate:n,onEdit:r,onRename:i,onDelete:a,isActivating:s}){let{t:l}=c(`openhands`),[u,d]=(0,R.useState)(!1),f=(0,R.useRef)(null);return(0,z.jsxs)(`div`,{"data-testid":`profile-row`,className:p(ae,`justify-between gap-3`),children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,z.jsx)(`span`,{className:`min-w-0 max-w-full truncate text-sm font-medium text-white`,title:e.name,children:e.name}),e.model?(0,z.jsx)(`span`,{className:`min-w-0 max-w-full truncate text-sm text-[var(--oh-muted)]`,title:e.model,children:e.model}):null,t&&(0,z.jsx)(ye,{className:`shrink-0 whitespace-nowrap px-2.5 py-1 text-xs`,"data-testid":`profile-active-badge`,children:l(o.SETTINGS$PROFILE_ACTIVE)})]}),(0,z.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,z.jsx)(N,{ref:f,onClick:()=>d(e=>!e),ariaLabel:l(o.SETTINGS$PROFILE_MENU),testId:`profile-menu-trigger`,className:se}),u&&(0,z.jsx)(ve,{anchorRef:f,onEdit:()=>r(e),onRename:()=>i(e),onSetActive:()=>n(e.name),onDelete:()=>a(e),isActive:t,isActivating:s,onClose:()=>d(!1)})]})]})}function xe({isLoading:e,loadError:t,profiles:n,active:r,onActivate:i,onEdit:a,onRename:s,onDelete:l,isActivating:u}){let{t:d}=c(`openhands`);return e?(0,z.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,z.jsx)(S,{size:`large`})}):t?(0,z.jsx)(`p`,{className:`text-sm text-red-400`,children:d(o.SETTINGS$PROFILES_LOAD_ERROR)}):n.length===0?(0,z.jsx)(`p`,{className:`text-sm text-[var(--oh-muted)] italic`,children:d(o.SETTINGS$PROFILES_EMPTY)}):(0,z.jsx)(`div`,{className:p(ce,oe),children:n.map(e=>(0,z.jsx)(be,{profile:e,isActive:e.name===r,onActivate:i,onEdit:a,onRename:s,onDelete:l,isActivating:u},e.name))})}function K(){let e=s();return i({mutationFn:e=>j.activateProfile(e),onSuccess:async()=>{O.invalidateCache(),await e.invalidateQueries({queryKey:g.all}),await e.invalidateQueries({queryKey:h.personal()})},meta:{disableToast:!0}})}function Se({onAddProfile:e,onEditProfile:t}){let{t:n}=c(`openhands`),{data:r,isLoading:i,error:a}=P(),s=K(),[l,u]=(0,R.useState)(null),[p,m]=(0,R.useState)(null),h=r?.profiles??[],g=r?.active_profile??null;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsx)(`h2`,{className:`text-base font-medium text-white`,children:n(o.SETTINGS$AVAILABLE_PROFILES)}),e?(0,z.jsx)(x,{testId:`add-llm-profile`,type:`button`,variant:`secondary`,className:`ml-auto`,onClick:e,children:n(o.SETTINGS$ADD_LLM_PROFILE)}):null]}),(0,z.jsx)(xe,{isLoading:i,loadError:a??null,profiles:h,active:g,onActivate:async e=>{try{await s.mutateAsync(e),f(n(o.SETTINGS$PROFILE_ACTIVATED,{name:e}))}catch(e){console.error(`Failed to activate profile:`,e),d(n(o.ERROR$GENERIC))}},onEdit:e=>{t?.(e)},onRename:u,onDelete:m,isActivating:s.isPending})]}),(0,z.jsx)(me,{profile:l,onClose:()=>u(null)}),(0,z.jsx)(ge,{profile:p,onClose:()=>m(null)})]})}function q(){let e=s();return i({mutationFn:({name:e,request:t})=>j.saveProfile(e,t),onSuccess:async()=>{O.invalidateCache(),await e.invalidateQueries({queryKey:g.all}),await e.invalidateQueries({queryKey:h.personal()})},meta:{disableToast:!0}})}var J=`https://llm-proxy.app.all-hands.dev/`;function Y(e){return typeof e==`string`&&e.startsWith(`openhands/`)}function Ce({activeProfileName:e,originalName:t,savedName:n}){return e?t?e===t:e===n:!1}function we(){let{t:e}=c(`openhands`),{setHideSectionHeader:t}=le(),n=q(),r=K(),{data:i}=P(),{data:a}=k(),{data:s}=L(a?.agent_settings_schema),l=(0,R.useRef)(s);l.current=s;let[p,m]=(0,R.useState)(`list`),[h,g]=(0,R.useState)(``),[_,v]=(0,R.useState)(null),[y,b]=(0,R.useState)(null),[S,C]=(0,R.useState)(!1);(0,R.useEffect)(()=>(t(p!==`list`),()=>t(!1)),[p,t]);let w=(0,R.useMemo)(()=>new Set(i?.profiles.map(e=>e.name)??[]),[i]),T=(0,R.useMemo)(()=>!(!V(h,{isRequired:!0})||p===`create`&&w.has(h)||p===`edit`&&h!==_?.profile.name&&w.has(h)),[h,p,w,_?.profile.name]),E=(0,R.useCallback)(()=>{g(``),v(null),m(`create`)},[]),D=(0,R.useCallback)(async t=>{try{let e=(await j.getProfile(t.name,`encrypted`)).config??{},n=l.current?.sections.find(e=>e.key===`llm`)?.fields??[],r={};for(let t of n){let n=t.key.startsWith(`llm.`)?t.key.slice(4):t.key;r[t.key]=te(t,e[n])}n.length===0&&(r[`llm.model`]=e.model??``,r[`llm.api_key`]=e.api_key??``,r[`llm.base_url`]=e.base_url??``),v({profile:t,initialValues:r,baseConfig:e}),g(t.name),m(`edit`)}catch(t){console.error(`Failed to fetch profile details:`,t),d(e(o.ERROR$GENERIC))}},[e]),O=(0,R.useCallback)(()=>{m(`list`),v(null),g(``),b(null)},[]),A=(0,R.useCallback)(e=>{if(b(e),p===`create`&&!h){let t=e.values[`llm.model`];if(typeof t==`string`&&t){let e=H(t);w.has(e)||g(e)}}},[p,h,w]),M=(0,R.useCallback)(async()=>{if(!y||!T)return;let t;try{t=y.getDirtyPayload().llm??{}}catch(t){d(t instanceof Error?t.message:e(o.ERROR$GENERIC));return}let a=p===`edit`&&_?.baseConfig?{..._.baseConfig}:{},s={...a,...t};if(y.view===`basic`&&(Y(s.model)?s.base_url=J:delete s.base_url),typeof s.api_key!=`string`||s.api_key.trim()===``){let e=typeof a.api_key==`string`?a.api_key:``;e?s.api_key=e:delete s.api_key}if(!(typeof s.model==`string`&&s.model)){d(e(o.SETTINGS$MODEL_REQUIRED));return}let c=h.trim(),l=_?.profile.name,u=p===`edit`&&l&&l!==c,m=Ce({activeProfileName:i?.active_profile,originalName:l,savedName:c});C(!0);try{u&&await j.renameProfile(l,c),await n.mutateAsync({name:c,request:{llm:s,include_secrets:!0}}),m&&await r.mutateAsync(c),f(e(p===`create`?o.SETTINGS$PROFILE_CREATED:o.SETTINGS$PROFILE_UPDATED,{name:c})),O()}catch(t){console.error(`Failed to save profile:`,t),d(e(o.ERROR$GENERIC))}finally{C(!1)}},[y,T,h,p,_,i?.active_profile,n,r,e,O]);if(p===`list`)return(0,z.jsx)(Se,{onAddProfile:E,onEditProfile:D});let N=e(p===`edit`?o.SETTINGS$EDIT_LLM_PROFILE:o.SETTINGS$ADD_LLM_PROFILE),F=p===`edit`&&_?e(o.SETTINGS$PROFILE_LOADED,{name:_.profile.name}):e(o.SETTINGS$PROFILE_SAVE_HINT);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(u,{testId:`back-to-profiles`,onClick:O,children:e(o.BUTTON$BACK)}),(0,z.jsx)(re.H2,{testId:`profile-editor-title`,children:N}),(0,z.jsx)(`p`,{"data-testid":`profile-editor-description`,className:`text-sm leading-5 text-tertiary-light`,children:F})]}),(0,z.jsx)(U,{testId:`profile-name-input`,value:h,onChange:g,isRequired:!0}),(0,z.jsx)($,{embedded:!0,hideSaveButton:!0,initialValueOverrides:p===`edit`&&_?.initialValues?_.initialValues:{"llm.model":``,"llm.api_key":``,"llm.base_url":``},onSaveControlChange:A},p===`edit`?`edit-${_?.profile.name}`:`new-profile`),(0,z.jsxs)(`div`,{className:`flex justify-start gap-3 pt-4`,children:[(0,z.jsx)(x,{testId:`cancel-profile-btn`,type:`button`,variant:`secondary`,onClick:O,children:e(o.BUTTON$CANCEL)}),(0,z.jsx)(x,{testId:`save-profile-btn`,type:`button`,variant:`primary`,onClick:M,isDisabled:!T||S||!y,"aria-busy":S,children:e(S?o.STATUS$SAVING:o.BUTTON$SAVE)})]})]})}var Te=new Set([`llm.model`,`llm.api_key`,`llm.base_url`]),Ee=(e,t)=>!e||!t?null:`${e}/${t}`,X=(e,t)=>e?.sections.flatMap(e=>e.fields).find(e=>e.key===t)?.default??null,Z={openai:new Set([`https://api.openai.com`,`https://api.openai.com/v1`]),openhands:new Set([J,`https://llm-proxy.app.all-hands.dev/v1`]),litellm_proxy:new Set([J,`https://llm-proxy.app.all-hands.dev/v1`])},De=e=>{try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``)||``;return`${t.origin}${n}`}catch{return e.trim().replace(/\/+$/,``)}},Oe=(e,t)=>{let n=De(t),{provider:r}=C(e);if(r){let e=Z[r];if(e)return e.has(n)}return Object.values(Z).some(e=>e?.has(n))};function Q({testId:e}){let{t}=c(`openhands`);return(0,z.jsx)(I,{testId:e,text:t(o.SETTINGS$OPENHANDS_API_KEY_HELP_TEXT),linkText:t(o.SETTINGS$NAV_API_KEYS),href:`https://app.all-hands.dev/settings/api-keys`,suffix:` ${t(o.SETTINGS$OPENHANDS_API_KEY_HELP_SUFFIX)}`})}function $({scope:e=`personal`,onSaveSuccess:t,initialValueOverrides:n,embedded:r,hideSaveButton:i,suppressSuccessToast:a,onSaveControlChange:s}){let{t:l}=c(`openhands`),{data:u}=k(e),{data:d}=L(u?.agent_settings_schema),f=String(D.agent_settings?.llm?.model??``),p=R.useCallback((e,t)=>{let n=ee(e,t);if(n!==`basic`)return n;let r=e.llm_model??``,i=e.llm_base_url?.trim()??``;return i.length>0&&!Oe(r,i)?`all`:`basic`},[]);return(0,z.jsx)(ne,{scope:e,sectionKeys:[`llm`],excludeKeys:Te,header:R.useCallback(({values:e,isDisabled:t,view:n,onChange:i})=>{let a=typeof e[`llm.model`]==`string`?e[`llm.model`]:``,s=typeof e[`llm.base_url`]==`string`?e[`llm.base_url`]:``,c=a.startsWith(`openhands/`),d=typeof e[`llm.api_key`]==`string`?e[`llm.api_key`]:``,p=r?d.length>0:!!u?.llm_api_key_set,m=(e,n)=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(E,{testId:e,label:l(o.SETTINGS_FORM$API_KEY),type:`password`,className:`w-full`,value:d,placeholder:p?`<hidden>`:``,onChange:e=>i(`llm.api_key`,e),isDisabled:t,startContent:p?(0,z.jsx)(fe,{isSet:p}):void 0}),(0,z.jsx)(I,{testId:n,text:l(o.SETTINGS$DONT_KNOW_API_KEY),linkText:l(o.SETTINGS$CLICK_FOR_INSTRUCTIONS),href:`https://docs.openhands.dev/usage/local-setup#getting-an-api-key`})]});return(0,z.jsx)(`div`,{className:`flex flex-col gap-6`,children:n===`basic`?(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,"data-testid":`llm-settings-form-basic`,children:[(0,z.jsx)(w,{currentModel:a||void 0,currentBaseUrl:s||void 0,onChange:(e,t)=>{let n=Ee(e,t);n&&i(`llm.model`,n)},wrapperClassName:`!flex-col !gap-6`,isDisabled:t}),c?(0,z.jsx)(Q,{testId:`openhands-api-key-help`}):null,m(`llm-api-key-input`,`llm-api-key-help-anchor`)]}):(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,"data-testid":`llm-settings-form-advanced`,children:[(0,z.jsx)(E,{testId:`llm-custom-model-input`,label:l(o.SETTINGS$CUSTOM_MODEL),type:`text`,className:`w-full`,value:a,placeholder:f,onChange:e=>i(`llm.model`,e),isDisabled:t}),c?(0,z.jsx)(Q,{testId:`openhands-api-key-help-2`}):null,(0,z.jsx)(E,{testId:`base-url-input`,label:l(o.SETTINGS$BASE_URL),type:`text`,className:`w-full`,value:s,placeholder:`https://api.openai.com`,onChange:e=>i(`llm.base_url`,e),isDisabled:t}),m(`llm-api-key-input`,`llm-api-key-help-anchor-advanced`)]})})},[f,r,u?.llm_api_key_set,l]),buildPayload:R.useCallback((e,t)=>{let n=structuredClone(e),r=n.llm??{};return t.view===`basic`&&(r.base_url=Y(r.model??t.values[`llm.model`])?J:X(d,`llm.base_url`),n.llm=r),{agent_settings_diff:n}},[d]),getInitialView:p,forceShowAdvancedView:!0,allowAllView:!0,onSaveSuccess:t,initialValueOverrides:n,embedded:r,hideSaveButton:i,suppressSuccessToast:a,onSaveControlChange:s,testId:`llm-settings-screen`})}var ke=n(function(){let{backend:e}=m();return e.kind===`cloud`?(0,z.jsx)($,{}):(0,z.jsx)(we,{})});export{H as a,K as i,ke as n,q as r,$ as t};
1
+ import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{L as n}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{t as r}from"./react-dom-hVBnwgwZ.js";import{t as i}from"./useMutation-DDo48A8t.js";import{o as a,t as o}from"./declaration-DaUdB2Wg.js";import{n as s}from"./QueryClientProvider-w1cZWY41.js";import{t as c}from"./useTranslation-CEcjrme-.js";import{t as l}from"./createLucideIcon-Ddu8jDOQ.js";import{t as u}from"./back-nav-button-DgkK0Ka6.js";import{n as d,r as f}from"./custom-toast-handlers-BohXx7uh.js";import{t as p}from"./utils-CdgBzLA7.js";import{n as m}from"./active-backend-context-I2w666XY.js";import{a as h,n as g}from"./query-keys-tAsQcc_9.js";import{t as _}from"./modal-backdrop-BDqI1zBV.js";import{r as v,t as y}from"./modal-body-CCLCqX1J.js";import{r as b}from"./base-modal-DZCNv0A4.js";import{t as x}from"./brand-button-LBFNic99.js";import{t as S}from"./loading-spinner-DNwR4--Z.js";import{n as C,t as w}from"./model-selector-CZOi4V7r.js";import{i as T}from"./dropdown-classes-Vqz86I0R.js";import{t as E}from"./settings-input-8y5p4kze.js";import{t as D}from"./settings-DGY6n4J2.js";import{t as O}from"./settings-service.api-DxIEtvx6.js";import{r as k}from"./use-settings-BPTbE7lg.js";import{a as A,n as j,o as M,r as N,t as P}from"./use-llm-profiles-E-jjZMZw.js";import{t as F}from"./u-edit-BIYzjs3v.js";import{c as ee,d as I,u as te}from"./sdk-settings-schema-DFievvEK.js";import{t as L}from"./use-agent-settings-schema-Yxf7KGyG.js";import{t as ne}from"./sdk-section-page-VmtJWH3A.js";import{r as re}from"./typography-Bvw0IxaN.js";import{t as ie}from"./u-check-circle-u9QiS4Fr.js";import{i as ae,n as oe,r as se,t as ce}from"./settings-list-classes-Qk7zl0Wu.js";import{n as le}from"./settings-section-header-context-B77tsYlx.js";var ue=l(`text-cursor`,[[`path`,{d:`M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1`,key:`uvaxm9`}],[`path`,{d:`M7 22h1a4 4 0 0 0 4-4v-1`,key:`11xy8d`}],[`path`,{d:`M7 2h1a4 4 0 0 1 4 4v1`,key:`1uw06m`}]]),R=e(t()),z=a(),de=e=>(0,z.jsxs)(`svg`,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,z.jsx)(`path`,{d:`M9.9509 15.588H10.8349L16.5125 9.91042L15.6285 9.0264L10.3991 14.2681L8.00867 11.8777L7.12465 12.7617L9.9509 15.588Z`,fill:`currentColor`}),(0,z.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.8521 3.29895C14.8443 3.42346 16.712 4.41954 18.0816 5.78916C19.7002 7.53231 20.5718 9.64898 20.5718 12.1392C20.5718 14.1314 19.8247 15.999 18.5796 17.6177C17.3345 19.1118 15.5914 20.2324 13.5992 20.6059C11.607 20.9794 9.61486 20.7304 7.87171 19.7343C6.12856 18.7382 4.75895 17.2441 4.01189 15.3765C3.26482 13.5088 3.14031 11.3921 3.76286 9.52447C4.38542 7.53231 5.50601 5.91367 7.24916 4.79308C8.86779 3.67248 10.86 3.17444 12.8521 3.29895ZM13.4747 19.3608C15.0933 18.9873 16.5874 18.1157 17.708 16.7461C18.7041 15.3765 19.3267 13.7578 19.2022 12.0147C19.2022 10.0225 18.4551 8.03035 17.0855 6.66073C15.8404 5.41563 14.3463 4.66857 12.6031 4.54405C10.9845 4.41954 9.24132 4.79308 7.87171 5.78916C6.50209 6.78524 5.50601 8.15486 5.00797 9.89801C4.50993 11.5166 4.50993 13.2598 5.25699 14.8784C6.00405 16.4971 7.12465 17.7422 8.61877 18.6137C10.1129 19.4853 11.856 19.7343 13.4747 19.3608Z`,fill:`currentColor`})]});function fe({testId:e,isSet:t}){return(0,z.jsx)(`span`,{"data-testid":e||(t?`set-indicator`:`unset-indicator`),children:(0,z.jsx)(de,{className:p(t?`text-success`:`text-danger`)})})}var B=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function V(e,{isRequired:t=!1}={}){return e===``?!t:B.test(e)}function H(e){let t=e.split(`/`),n=(t[t.length-1]||e).replace(/[^A-Za-z0-9._-]/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``);return n&&!/^[A-Za-z0-9]/.test(n)&&(n=`profile-${n}`),n.length>64&&(n=n.substring(0,64).replace(/-+$/,``)),n||`default-profile`}var U=(0,R.forwardRef)(function({testId:e,ruleTestId:t,value:n,onChange:r,onKeyDown:i,placeholder:a,isDisabled:s,isOptional:l,isRequired:u=!1},d){let{t:f}=c(`openhands`),m=V(n,{isRequired:u}),h=l?`${f(o.SETTINGS$PROFILE_NAME_LABEL)} (${f(o.COMMON$OPTIONAL)})`:f(o.SETTINGS$PROFILE_NAME_LABEL),g=R.useId(),_=t??`${g}-rule`;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(E,{ref:d,testId:e,label:h,type:`text`,className:`w-full`,value:n,placeholder:a??f(o.SETTINGS$PROFILE_NAME_PLACEHOLDER),onChange:r,onKeyDown:i,isDisabled:s,ariaDescribedBy:_,ariaInvalid:!m}),(0,z.jsx)(`p`,{id:_,"data-testid":t,className:p(`text-xs`,m?`text-[var(--oh-muted)]`:`text-red-400`),children:f(o.SETTINGS$PROFILE_NAME_RULE)})]})});function W({isOpen:e,title:t,width:n=`md`,children:r,footer:i,onClose:a,initialFocusRef:o}){let s=(0,R.useRef)(null);return(0,R.useEffect)(()=>{if(!e)return;let t=o?.current??s.current;if(t){let e=setTimeout(()=>{t.focus()},0);return()=>clearTimeout(e)}},[e,o]),(0,R.useEffect)(()=>{if(!e||!s.current)return;let t=s.current,n=e=>{if(e.key!==`Tab`)return;let n=t.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`),r=n[0],i=n[n.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),i?.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r?.focus())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e]),e?(0,z.jsx)(_,{onClose:a,children:(0,z.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`modal-title`,className:p(`bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]`,v(n),y),children:[(0,z.jsx)(b,{id:`modal-title`,title:t}),r,(0,z.jsx)(`div`,{className:`w-full flex justify-end gap-2 mt-2`,children:i})]})}):null}function pe(){let e=s();return i({mutationFn:({name:e,newName:t})=>j.renameProfile(e,t),onSuccess:async()=>{O.invalidateCache(),await e.invalidateQueries({queryKey:g.all}),await e.invalidateQueries({queryKey:h.personal()})},meta:{disableToast:!0}})}function me({profile:e,onClose:t}){let{t:n}=c(`openhands`),[r,i]=(0,R.useState)(``),a=pe(),s=(0,R.useRef)(null);if((0,R.useEffect)(()=>{i(e?.name??``)},[e?.name]),!e)return null;let l=V(r,{isRequired:!0}),u=r===e.name,p=async()=>{if(!l){d(n(o.SETTINGS$PROFILE_NAME_RULE));return}if(u){t();return}try{await a.mutateAsync({name:e.name,newName:r}),f(n(o.SETTINGS$PROFILE_RENAMED,{name:r})),t()}catch(e){d(e instanceof Error?e.message:n(o.ERROR$GENERIC))}},m=()=>{a.isPending||t()},h=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(x,{type:`button`,variant:`tertiary`,onClick:m,isDisabled:a.isPending,children:n(o.BUTTON$CANCEL)}),(0,z.jsx)(x,{testId:`rename-profile-submit`,type:`button`,variant:`primary`,onClick:p,isDisabled:a.isPending||!l,children:a.isPending?(0,z.jsx)(S,{size:`small`}):n(o.BUTTON$RENAME)})]});return(0,z.jsx)(W,{isOpen:!0,title:n(o.SETTINGS$PROFILE_RENAME_TITLE),footer:h,onClose:m,initialFocusRef:s,children:(0,z.jsx)(`div`,{"data-testid":`rename-profile-modal`,className:`flex flex-col gap-3`,children:(0,z.jsx)(U,{ref:s,testId:`rename-profile-input`,ruleTestId:`rename-profile-rule`,value:r,onChange:i,isRequired:!0,onKeyDown:e=>{e.key===`Enter`&&!a.isPending&&l&&p()}})})})}function he(){let e=s();return i({mutationFn:e=>j.deleteProfile(e),onSuccess:async()=>{O.invalidateCache(),await e.invalidateQueries({queryKey:g.all}),await e.invalidateQueries({queryKey:h.personal()})},meta:{disableToast:!0}})}function ge({profile:e,onClose:t}){let{t:n}=c(`openhands`),r=he(),i=(0,R.useRef)(null);if(!e)return null;let a=async()=>{try{await r.mutateAsync(e.name),f(n(o.SETTINGS$PROFILE_DELETED,{name:e.name})),t()}catch(e){d(e instanceof Error?e.message:n(o.ERROR$GENERIC))}},s=()=>{r.isPending||t()},l=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(x,{ref:i,type:`button`,variant:`tertiary`,onClick:s,isDisabled:r.isPending,children:n(o.BUTTON$CANCEL)}),(0,z.jsx)(x,{testId:`delete-profile-confirm`,type:`button`,variant:`danger`,onClick:a,isDisabled:r.isPending,"aria-busy":r.isPending,children:r.isPending?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(S,{size:`small`}),(0,z.jsx)(`span`,{className:`sr-only`,children:n(o.BUTTON$DELETE)})]}):n(o.BUTTON$DELETE)})]});return(0,z.jsx)(W,{isOpen:!0,title:n(o.SETTINGS$PROFILE_DELETE_TITLE),footer:l,onClose:s,initialFocusRef:i,children:(0,z.jsx)(`p`,{className:`text-sm break-all`,children:n(o.SETTINGS$PROFILE_DELETE_CONFIRMATION,{name:e.name})})})}var _e=e(r(),1);function G({index:e,icon:t,label:n,onClick:r,onKeyDown:i,menuItemsRef:a,disabled:o,testId:s}){return(0,z.jsx)(`button`,{ref:t=>{a.current[e]=t},type:`button`,onClick:r,onKeyDown:t=>i(t,e),disabled:o,className:p(`group w-full cursor-pointer rounded px-2 py-2 text-start text-nowrap text-sm font-normal`,`text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]`,`disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent`),role:`menuitem`,"data-testid":s,children:(0,z.jsx)(M,{icon:t,text:n})})}function ve({onEdit:e,onRename:t,onSetActive:n,onDelete:r,isActive:i,isActivating:a,onClose:s,anchorRef:l}){let{t:u}=c(`openhands`),d=(0,R.useRef)(null),f=(0,R.useRef)([]),m=l?.current??null,[h,g]=(0,R.useState)();(0,R.useLayoutEffect)(()=>{if(!m)return;let e=()=>{let e=m.getBoundingClientRect();e&&g({position:`fixed`,zIndex:9999,top:e.bottom+8,right:window.innerWidth-e.right,width:`max-content`})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[m]),(0,R.useEffect)(()=>{f.current[0]?.focus()},[]),(0,R.useEffect)(()=>{let e=e=>{let t=e.target;d.current&&!d.current.contains(t)&&s()},t=e=>{e.key===`Escape`&&s()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[s]);let _=e=>{e(),s()},v=(0,R.useCallback)((e,t)=>{if(e.key===`Tab`){s();return}let n=f.current.filter(Boolean).length;if(e.key===`ArrowDown`){e.preventDefault();let r=(t+1)%n;f.current[r]?.focus()}else if(e.key===`ArrowUp`){e.preventDefault();let r=(t-1+n)%n;f.current[r]?.focus()}},[s]),y=i||a,b=!!m,x=(0,z.jsxs)(`div`,{ref:d,className:p(`absolute right-0 top-full z-10 mt-2 w-[160px] rounded-md border border-[var(--oh-border-subtle)] bg-tertiary px-1 py-1 shadow-lg`,T,b&&`!static !top-auto !bottom-auto !left-auto !right-auto !mt-0`),role:`menu`,"aria-orientation":`vertical`,"data-testid":`profile-actions-menu`,children:[(0,z.jsx)(G,{index:0,icon:(0,z.jsx)(F,{width:16,height:16}),label:u(o.SETTINGS$PROFILE_EDIT),onClick:()=>_(e),onKeyDown:v,menuItemsRef:f,testId:`profile-edit`}),(0,z.jsx)(G,{index:1,icon:(0,z.jsx)(ue,{"aria-hidden":!0,className:`size-4`,strokeWidth:2}),label:u(o.BUTTON$RENAME),onClick:()=>_(t),onKeyDown:v,menuItemsRef:f,testId:`profile-rename`}),(0,z.jsx)(G,{index:2,icon:(0,z.jsx)(ie,{width:16,height:16}),label:u(o.SETTINGS$PROFILE_SET_ACTIVE),onClick:()=>_(n),onKeyDown:v,menuItemsRef:f,disabled:y,testId:`profile-set-active`}),(0,z.jsx)(G,{index:3,icon:(0,z.jsx)(A,{width:16,height:16}),label:u(o.BUTTON$DELETE),onClick:()=>_(r),onKeyDown:v,menuItemsRef:f,testId:`profile-delete`})]});return b?typeof document>`u`||!h?null:_e.createPortal((0,z.jsx)(`div`,{style:h,children:x}),document.body):x}function ye({children:e,className:t,...n}){return(0,z.jsx)(`span`,{className:p(`text-sm leading-4 text-black font-semibold tracking-tighter bg-primary p-1 rounded-full`,t),...n,children:e})}function be({profile:e,isActive:t,onActivate:n,onEdit:r,onRename:i,onDelete:a,isActivating:s}){let{t:l}=c(`openhands`),[u,d]=(0,R.useState)(!1),f=(0,R.useRef)(null);return(0,z.jsxs)(`div`,{"data-testid":`profile-row`,className:p(ae,`justify-between gap-3`),children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,z.jsx)(`span`,{className:`min-w-0 max-w-full truncate text-sm font-medium text-white`,title:e.name,children:e.name}),e.model?(0,z.jsx)(`span`,{className:`min-w-0 max-w-full truncate text-sm text-[var(--oh-muted)]`,title:e.model,children:e.model}):null,t&&(0,z.jsx)(ye,{className:`shrink-0 whitespace-nowrap px-2.5 py-1 text-xs`,"data-testid":`profile-active-badge`,children:l(o.SETTINGS$PROFILE_ACTIVE)})]}),(0,z.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,z.jsx)(N,{ref:f,onClick:()=>d(e=>!e),ariaLabel:l(o.SETTINGS$PROFILE_MENU),testId:`profile-menu-trigger`,className:se}),u&&(0,z.jsx)(ve,{anchorRef:f,onEdit:()=>r(e),onRename:()=>i(e),onSetActive:()=>n(e.name),onDelete:()=>a(e),isActive:t,isActivating:s,onClose:()=>d(!1)})]})]})}function xe({isLoading:e,loadError:t,profiles:n,active:r,onActivate:i,onEdit:a,onRename:s,onDelete:l,isActivating:u}){let{t:d}=c(`openhands`);return e?(0,z.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,z.jsx)(S,{size:`large`})}):t?(0,z.jsx)(`p`,{className:`text-sm text-red-400`,children:d(o.SETTINGS$PROFILES_LOAD_ERROR)}):n.length===0?(0,z.jsx)(`p`,{className:`text-sm text-[var(--oh-muted)] italic`,children:d(o.SETTINGS$PROFILES_EMPTY)}):(0,z.jsx)(`div`,{className:p(ce,oe),children:n.map(e=>(0,z.jsx)(be,{profile:e,isActive:e.name===r,onActivate:i,onEdit:a,onRename:s,onDelete:l,isActivating:u},e.name))})}function K(){let e=s();return i({mutationFn:e=>j.activateProfile(e),onSuccess:async()=>{O.invalidateCache(),await e.invalidateQueries({queryKey:g.all}),await e.invalidateQueries({queryKey:h.personal()})},meta:{disableToast:!0}})}function Se({onAddProfile:e,onEditProfile:t}){let{t:n}=c(`openhands`),{data:r,isLoading:i,error:a}=P(),s=K(),[l,u]=(0,R.useState)(null),[p,m]=(0,R.useState)(null),h=r?.profiles??[],g=r?.active_profile??null;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsx)(`h2`,{className:`text-base font-medium text-white`,children:n(o.SETTINGS$AVAILABLE_PROFILES)}),e?(0,z.jsx)(x,{testId:`add-llm-profile`,type:`button`,variant:`secondary`,className:`ml-auto`,onClick:e,children:n(o.SETTINGS$ADD_LLM_PROFILE)}):null]}),(0,z.jsx)(xe,{isLoading:i,loadError:a??null,profiles:h,active:g,onActivate:async e=>{try{await s.mutateAsync(e),f(n(o.SETTINGS$PROFILE_ACTIVATED,{name:e}))}catch(e){console.error(`Failed to activate profile:`,e),d(n(o.ERROR$GENERIC))}},onEdit:e=>{t?.(e)},onRename:u,onDelete:m,isActivating:s.isPending})]}),(0,z.jsx)(me,{profile:l,onClose:()=>u(null)}),(0,z.jsx)(ge,{profile:p,onClose:()=>m(null)})]})}function q(){let e=s();return i({mutationFn:({name:e,request:t})=>j.saveProfile(e,t),onSuccess:async()=>{O.invalidateCache(),await e.invalidateQueries({queryKey:g.all}),await e.invalidateQueries({queryKey:h.personal()})},meta:{disableToast:!0}})}var J=`https://llm-proxy.app.all-hands.dev/`;function Y(e){return typeof e==`string`&&e.startsWith(`openhands/`)}function Ce({activeProfileName:e,originalName:t,savedName:n}){return e?t?e===t:e===n:!1}function we(){let{t:e}=c(`openhands`),{setHideSectionHeader:t}=le(),n=q(),r=K(),{data:i}=P(),{data:a}=k(),{data:s}=L(a?.agent_settings_schema),l=(0,R.useRef)(s);l.current=s;let[p,m]=(0,R.useState)(`list`),[h,g]=(0,R.useState)(``),[_,v]=(0,R.useState)(null),[y,b]=(0,R.useState)(null),[S,C]=(0,R.useState)(!1);(0,R.useEffect)(()=>(t(p!==`list`),()=>t(!1)),[p,t]);let w=(0,R.useMemo)(()=>new Set(i?.profiles.map(e=>e.name)??[]),[i]),T=(0,R.useMemo)(()=>!(!V(h,{isRequired:!0})||p===`create`&&w.has(h)||p===`edit`&&h!==_?.profile.name&&w.has(h)),[h,p,w,_?.profile.name]),E=(0,R.useCallback)(()=>{g(``),v(null),m(`create`)},[]),D=(0,R.useCallback)(async t=>{try{let e=(await j.getProfile(t.name,`encrypted`)).config??{},n=l.current?.sections.find(e=>e.key===`llm`)?.fields??[],r={};for(let t of n){let n=t.key.startsWith(`llm.`)?t.key.slice(4):t.key;r[t.key]=te(t,e[n])}n.length===0&&(r[`llm.model`]=e.model??``,r[`llm.api_key`]=e.api_key??``,r[`llm.base_url`]=e.base_url??``),v({profile:t,initialValues:r,baseConfig:e}),g(t.name),m(`edit`)}catch(t){console.error(`Failed to fetch profile details:`,t),d(e(o.ERROR$GENERIC))}},[e]),O=(0,R.useCallback)(()=>{m(`list`),v(null),g(``),b(null)},[]),A=(0,R.useCallback)(e=>{if(b(e),p===`create`&&!h){let t=e.values[`llm.model`];if(typeof t==`string`&&t){let e=H(t);w.has(e)||g(e)}}},[p,h,w]),M=(0,R.useCallback)(async()=>{if(!y||!T)return;let t;try{t=y.getDirtyPayload().llm??{}}catch(t){d(t instanceof Error?t.message:e(o.ERROR$GENERIC));return}let a=p===`edit`&&_?.baseConfig?{..._.baseConfig}:{},s={...a,...t};if(y.view===`basic`&&(Y(s.model)?s.base_url=J:delete s.base_url),typeof s.api_key!=`string`||s.api_key.trim()===``){let e=typeof a.api_key==`string`?a.api_key:``;e?s.api_key=e:delete s.api_key}if(!(typeof s.model==`string`&&s.model)){d(e(o.SETTINGS$MODEL_REQUIRED));return}let c=h.trim(),l=_?.profile.name,u=p===`edit`&&l&&l!==c,m=Ce({activeProfileName:i?.active_profile,originalName:l,savedName:c});C(!0);try{u&&await j.renameProfile(l,c),await n.mutateAsync({name:c,request:{llm:s,include_secrets:!0}}),m&&await r.mutateAsync(c),f(e(p===`create`?o.SETTINGS$PROFILE_CREATED:o.SETTINGS$PROFILE_UPDATED,{name:c})),O()}catch(t){console.error(`Failed to save profile:`,t),d(e(o.ERROR$GENERIC))}finally{C(!1)}},[y,T,h,p,_,i?.active_profile,n,r,e,O]);if(p===`list`)return(0,z.jsx)(Se,{onAddProfile:E,onEditProfile:D});let N=e(p===`edit`?o.SETTINGS$EDIT_LLM_PROFILE:o.SETTINGS$ADD_LLM_PROFILE),F=p===`edit`&&_?e(o.SETTINGS$PROFILE_LOADED,{name:_.profile.name}):e(o.SETTINGS$PROFILE_SAVE_HINT);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(u,{testId:`back-to-profiles`,onClick:O,children:e(o.BUTTON$BACK)}),(0,z.jsx)(re.H2,{testId:`profile-editor-title`,children:N}),(0,z.jsx)(`p`,{"data-testid":`profile-editor-description`,className:`text-sm leading-5 text-tertiary-light`,children:F})]}),(0,z.jsx)(U,{testId:`profile-name-input`,value:h,onChange:g,isRequired:!0}),(0,z.jsx)($,{embedded:!0,hideSaveButton:!0,initialValueOverrides:p===`edit`&&_?.initialValues?_.initialValues:{"llm.model":``,"llm.api_key":``,"llm.base_url":``},onSaveControlChange:A},p===`edit`?`edit-${_?.profile.name}`:`new-profile`),(0,z.jsxs)(`div`,{className:`flex justify-start gap-3 pt-4`,children:[(0,z.jsx)(x,{testId:`cancel-profile-btn`,type:`button`,variant:`secondary`,onClick:O,children:e(o.BUTTON$CANCEL)}),(0,z.jsx)(x,{testId:`save-profile-btn`,type:`button`,variant:`primary`,onClick:M,isDisabled:!T||S||!y,"aria-busy":S,children:e(S?o.STATUS$SAVING:o.BUTTON$SAVE)})]})]})}var Te=new Set([`llm.model`,`llm.api_key`,`llm.base_url`]),Ee=(e,t)=>!e||!t?null:`${e}/${t}`,X=(e,t)=>e?.sections.flatMap(e=>e.fields).find(e=>e.key===t)?.default??null,Z={openai:new Set([`https://api.openai.com`,`https://api.openai.com/v1`]),openhands:new Set([J,`https://llm-proxy.app.all-hands.dev/v1`]),litellm_proxy:new Set([J,`https://llm-proxy.app.all-hands.dev/v1`])},De=e=>{try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``)||``;return`${t.origin}${n}`}catch{return e.trim().replace(/\/+$/,``)}},Oe=(e,t)=>{let n=De(t),{provider:r}=C(e);if(r){let e=Z[r];if(e)return e.has(n)}return Object.values(Z).some(e=>e?.has(n))};function Q({testId:e}){let{t}=c(`openhands`);return(0,z.jsx)(I,{testId:e,text:t(o.SETTINGS$OPENHANDS_API_KEY_HELP_TEXT),linkText:t(o.SETTINGS$NAV_API_KEYS),href:`https://app.all-hands.dev/settings/api-keys`,suffix:` ${t(o.SETTINGS$OPENHANDS_API_KEY_HELP_SUFFIX)}`})}function $({scope:e=`personal`,onSaveSuccess:t,initialValueOverrides:n,embedded:r,hideSaveButton:i,suppressSuccessToast:a,onSaveControlChange:s}){let{t:l}=c(`openhands`),{data:u}=k(e),{data:d}=L(u?.agent_settings_schema),f=String(D.agent_settings?.llm?.model??``),p=R.useCallback((e,t)=>{let n=ee(e,t);if(n!==`basic`)return n;let r=e.llm_model??``,i=e.llm_base_url?.trim()??``;return i.length>0&&!Oe(r,i)?`all`:`basic`},[]);return(0,z.jsx)(ne,{scope:e,sectionKeys:[`llm`],excludeKeys:Te,header:R.useCallback(({values:e,isDisabled:t,view:n,onChange:i})=>{let a=typeof e[`llm.model`]==`string`?e[`llm.model`]:``,s=typeof e[`llm.base_url`]==`string`?e[`llm.base_url`]:``,c=a.startsWith(`openhands/`),d=typeof e[`llm.api_key`]==`string`?e[`llm.api_key`]:``,p=r?d.length>0:!!u?.llm_api_key_set,m=(e,n)=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(E,{testId:e,label:l(o.SETTINGS_FORM$API_KEY),type:`password`,className:`w-full`,value:d,placeholder:p?`<hidden>`:``,onChange:e=>i(`llm.api_key`,e),isDisabled:t,startContent:p?(0,z.jsx)(fe,{isSet:p}):void 0}),(0,z.jsx)(I,{testId:n,text:l(o.SETTINGS$DONT_KNOW_API_KEY),linkText:l(o.SETTINGS$CLICK_FOR_INSTRUCTIONS),href:`https://docs.openhands.dev/usage/local-setup#getting-an-api-key`})]});return(0,z.jsx)(`div`,{className:`flex flex-col gap-6`,children:n===`basic`?(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,"data-testid":`llm-settings-form-basic`,children:[(0,z.jsx)(w,{currentModel:a||void 0,currentBaseUrl:s||void 0,onChange:(e,t)=>{let n=Ee(e,t);n&&i(`llm.model`,n)},wrapperClassName:`!flex-col !gap-6`,isDisabled:t}),c?(0,z.jsx)(Q,{testId:`openhands-api-key-help`}):null,m(`llm-api-key-input`,`llm-api-key-help-anchor`)]}):(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,"data-testid":`llm-settings-form-advanced`,children:[(0,z.jsx)(E,{testId:`llm-custom-model-input`,label:l(o.SETTINGS$CUSTOM_MODEL),type:`text`,className:`w-full`,value:a,placeholder:f,onChange:e=>i(`llm.model`,e),isDisabled:t}),c?(0,z.jsx)(Q,{testId:`openhands-api-key-help-2`}):null,(0,z.jsx)(E,{testId:`base-url-input`,label:l(o.SETTINGS$BASE_URL),type:`text`,className:`w-full`,value:s,placeholder:`https://api.openai.com`,onChange:e=>i(`llm.base_url`,e),isDisabled:t}),m(`llm-api-key-input`,`llm-api-key-help-anchor-advanced`)]})})},[f,r,u?.llm_api_key_set,l]),buildPayload:R.useCallback((e,t)=>{let n=structuredClone(e),r=n.llm??{};return t.view===`basic`&&(r.base_url=Y(r.model??t.values[`llm.model`])?J:X(d,`llm.base_url`),n.llm=r),{agent_settings_diff:n}},[d]),getInitialView:p,forceShowAdvancedView:!0,allowAllView:!0,onSaveSuccess:t,initialValueOverrides:n,embedded:r,hideSaveButton:i,suppressSuccessToast:a,onSaveControlChange:s,testId:`llm-settings-screen`})}var ke=n(function(){let{backend:e}=m();return e.kind===`cloud`?(0,z.jsx)($,{}):(0,z.jsx)(we,{})});export{H as a,K as i,ke as n,q as r,$ as t};