@openhands/agent-canvas 1.0.0-rc.3 → 1.0.0-rc.5

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 (34) hide show
  1. package/README.md +2 -2
  2. package/README.windows.md +2 -2
  3. package/build/assets/{analytics-consent-form-modal-Ce-_Skcd.js → analytics-consent-form-modal-D4ndXdkQ.js} +1 -1
  4. package/build/assets/{automations-list-Ces5shz5.js → automations-list-CoYj4o97.js} +1 -1
  5. package/build/assets/{home-sJAFzI6v.js → home-D77Xasws.js} +1 -1
  6. package/build/assets/install-server-modal-BjmEphcZ.js +1 -0
  7. package/build/assets/{manifest-d3e8504d.js → manifest-08c25e0c.js} +1 -1
  8. package/build/assets/{mcp-kJYdM8aJ.js → mcp-CiokQDek.js} +2 -2
  9. package/build/assets/{onboarding-CZ_7nd-M.js → onboarding-CGUaLHfQ.js} +1 -1
  10. package/build/assets/{recommended-automations-launcher-B1kfmFTQ.js → recommended-automations-launcher-C1_CKGHa.js} +1 -1
  11. package/build/assets/{root-CIZ7Rv1X.js → root-DVv3y8Fb.js} +1 -1
  12. package/build/assets/{root-layout-B5ijp9At.js → root-layout-lUjioorg.js} +2 -2
  13. package/build/assets/telemetry--BA6QguL.js +2 -0
  14. package/build/index.html +3 -3
  15. package/config/defaults.json +2 -6
  16. package/dist/api/mcp-service/mcp-service.api.cjs +1 -1
  17. package/dist/api/mcp-service/mcp-service.api.cjs.map +1 -1
  18. package/dist/api/mcp-service/mcp-service.api.js +19 -14
  19. package/dist/api/mcp-service/mcp-service.api.js.map +1 -1
  20. package/dist/components/features/mcp-page/custom-server-editor.cjs +1 -1
  21. package/dist/components/features/mcp-page/custom-server-editor.cjs.map +1 -1
  22. package/dist/components/features/mcp-page/custom-server-editor.js +63 -62
  23. package/dist/components/features/mcp-page/custom-server-editor.js.map +1 -1
  24. package/dist/package.cjs +1 -1
  25. package/dist/package.cjs.map +1 -1
  26. package/dist/package.js +3 -1
  27. package/dist/package.js.map +1 -1
  28. package/package.json +3 -1
  29. package/scripts/check-sdk-version-sync.mjs +6 -6
  30. package/scripts/dev-safe.mjs +32 -8
  31. package/scripts/dev-with-automation.mjs +25 -1
  32. package/scripts/logger.mjs +77 -0
  33. package/build/assets/install-server-modal-BjEzlLF5.js +0 -1
  34. package/build/assets/telemetry-j9SLrtY7.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-rc.3
77
+ docker pull ghcr.io/openhands/agent-canvas:1.0.0-rc.5
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-rc.3
86
+ ghcr.io/openhands/agent-canvas:1.0.0-rc.5
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-rc.3
15
+ docker pull ghcr.io/openhands/agent-canvas:1.0.0-rc.5
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-rc.3
24
+ ghcr.io/openhands/agent-canvas:1.0.0-rc.5
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-IA661TBv.js";import{t as n}from"./useTranslation-CbJtty1g.js";import{n as r}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~oli4dvxu-CBEOG8NF.js";import{r as i}from"./telemetry-j9SLrtY7.js";import{t as a}from"./modal-backdrop-B1si6TUd.js";import{n as o}from"./modal-body-2Po2nl1e.js";import{n as s,r as c}from"./base-modal-Ba5WcNb6.js";import{t as l}from"./brand-button-BoiPxAGm.js";import{t as u}from"./handle-capture-consent-DDnXMC9Y.js";import{t as d}from"./use-save-settings-CP23emUY.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-IA661TBv.js";import{t as n}from"./useTranslation-CbJtty1g.js";import{n as r}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~oli4dvxu-CBEOG8NF.js";import{r as i}from"./telemetry--BA6QguL.js";import{t as a}from"./modal-backdrop-B1si6TUd.js";import{n as o}from"./modal-body-2Po2nl1e.js";import{n as s,r as c}from"./base-modal-Ba5WcNb6.js";import{t as l}from"./brand-button-BoiPxAGm.js";import{t as u}from"./handle-capture-consent-DDnXMC9Y.js";import{t as d}from"./use-save-settings-CP23emUY.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}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{o as i,t as a}from"./declaration-IA661TBv.js";import{n as o,t as s}from"./recommended-automations-launcher-B1kfmFTQ.js";import{t as c}from"./Trans-rF21Jwln.js";import{t as l}from"./useTranslation-CbJtty1g.js";import{t as u}from"./createLucideIcon-C9OEnwvX.js";import{t as d}from"./check-BDAbW7je.js";import{n as f,r as p}from"./custom-toast-handlers-fgD4IYsu.js";import{a as m,c as h,i as g,o as _,r as v,s as y}from"./circle-plus-check-toggle-CboDp7XB.js";import{t as b}from"./utils-CVcuFUYj.js";import{n as ee}from"./active-backend-context-CQTk4wD8.js";import{t as x}from"./modal-backdrop-B1si6TUd.js";import{n as S}from"./modal-classes-9XTtWCtF.js";import{t as C}from"./brand-button-BoiPxAGm.js";import{n as w}from"./navigation-context-CszaA-CJ.js";import{t as T}from"./styled-tooltip-GXy1qxsO.js";import{u as E}from"./dropdown-classes-lT1LUsbO.js";import{n as te}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~e9ykmtgh-DMH1jSwL.js";import{t as D}from"./modal-close-button-DY-rVmld.js";import{t as ne}from"./use-tracking-CjLZgh8X.js";import{n as O,t as k}from"./context-menu-list-item-CHWCx1Mc.js";import{t as A}from"./u-edit-foF02hwH.js";import{t as j}from"./folder-wShAU0y7.js";import{t as M}from"./search-BqXT2Ied.js";import{n as N}from"./skill-card-pill-row-Bg5joQf6.js";import{t as P}from"./globe-CQ_5xwpo.js";import{n as F,t as I}from"./use-launch-skill-in-chat-ClRJlIx7.js";import{_ as re,b as ie,c as L,d as R,f as z,g as ae,h as B,i as oe,l as V,m as H,n as se,o as ce,p as U,r as le,s as ue,t as de,u as W,v as fe,y as pe}from"./edit-automation-modal-C-oC5tis.js";var me=u(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),he=u(`grid-2x2`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),ge=u(`rows-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]),G=e(t(),1),K=i();function _e({value:e,onChange:t,className:n}){let{t:r}=l(`openhands`);return(0,K.jsxs)(`div`,{className:b(`relative flex min-w-0 flex-1 items-center`,`h-9 rounded-lg border border-[var(--oh-border)] bg-base-secondary`,`focus-within:border-white/40 focus-within:ring-1 focus-within:ring-white/20`,`transition-colors`,n),children:[(0,K.jsx)(M,{className:`ml-3 size-4 shrink-0 text-tertiary-alt`,"aria-hidden":!0}),(0,K.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:r(a.AUTOMATIONS$SEARCH_PLACEHOLDER),"aria-label":r(a.AUTOMATIONS$SEARCH_PLACEHOLDER),className:`min-w-0 flex-1 border-0 bg-transparent px-3 text-sm text-white outline-none placeholder:text-tertiary-alt`})]})}function q(e,t){let n=[];if(e.repository&&n.push({id:`repository`,node:(0,K.jsxs)(`span`,{className:b(_,`gap-1`),children:[(0,K.jsx)(j,{className:`size-3 shrink-0`}),e.repository]})}),e.trigger.type===`event`){let t=[e.trigger.on?L(e.trigger.on):``,e.trigger.source?`(${e.trigger.source})`:``].filter(Boolean).join(` `);n.push({id:`event-trigger`,node:(0,K.jsxs)(`span`,{className:b(_,`gap-1`),children:[(0,K.jsx)(P,{className:`size-3 shrink-0`}),t]})})}else n.push({id:`schedule`,node:(0,K.jsxs)(`span`,{className:b(_,`gap-1`),children:[(0,K.jsx)(W,{className:`size-3 shrink-0`}),t]})});return e.model&&n.push({id:`model`,node:(0,K.jsxs)(`span`,{className:b(_,`gap-1`),children:[(0,K.jsx)(V,{className:`size-3 shrink-0`}),e.model]})}),n}function J({automation:e,t,canManage:n,onRunNow:r,isRunPending:i,onView:o,onEdit:s,onToggle:c,onDelete:l}){return[...n?[{label:t(a.AUTOMATIONS$RUN_NOW),icon:(0,K.jsx)(R,{className:`size-4`}),onClick:()=>r(e.id),disabled:i||!e.enabled}]:[],{label:t(a.COMMON$VIEW),icon:(0,K.jsx)(me,{className:`size-4`,"aria-hidden":!0}),onClick:o},...n&&s?[{label:t(a.AUTOMATIONS$EDIT),icon:(0,K.jsx)(A,{className:`size-4`}),onClick:()=>s(e.id)}]:[],...n?[{label:e.enabled?t(a.AUTOMATIONS$TURN_OFF):t(a.AUTOMATIONS$TURN_ON),icon:(0,K.jsx)(ue,{className:`size-4`}),onClick:()=>c(e.id,e.enabled)},{label:t(a.AUTOMATIONS$DELETE),icon:(0,K.jsx)(ce,{className:`size-4`}),onClick:()=>l(e.id)}]:[]]}function ve({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onEdit:o}){let{navigate:s}=w(),{t:c}=l(`openhands`),u=z(`manage_automations`),d=e.trigger.schedule_human||e.trigger.type,f=(0,G.useMemo)(()=>q(e,d),[e,d]),p=()=>{s?.(`/automations/${e.id}`)},h=J({automation:e,t:c,canManage:u,onRunNow:n,isRunPending:r,onView:p,onEdit:o,onToggle:t,onDelete:i}),g=()=>{p()};return(0,K.jsxs)(`div`,{role:`link`,tabIndex:0,"data-testid":`automation-card-${e.id}`,onClick:g,onKeyDown:e=>{e.key===`Enter`&&g()},className:b(`flex min-w-0 flex-col gap-3 overflow-hidden p-4 text-left`,y,m),children:[(0,K.jsxs)(`header`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,K.jsxs)(`h3`,{className:`flex items-center gap-2 truncate text-sm font-semibold text-white`,children:[e.trigger.type===`event`?(0,K.jsx)(P,{className:`size-4 shrink-0 text-muted`}):(0,K.jsx)(W,{className:`size-4 shrink-0 text-muted`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.name})]}),e.prompt?(0,K.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-tertiary-light`,children:e.prompt}):null]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[u?(0,K.jsxs)(`button`,{type:`button`,"data-testid":`automation-run-now-${e.id}`,"aria-busy":r,disabled:r||!e.enabled,onClick:t=>{t.stopPropagation(),n(e.id)},className:B,children:[(0,K.jsx)(R,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),c(a.AUTOMATIONS$RUN_NOW)]}):null,(0,K.jsx)(U,{items:h})]})]}),f.length>0?(0,K.jsx)(N,{pills:f,testId:`automation-pills-${e.id}`}):null]})}var ye=`overflow-hidden rounded-md border border-[var(--oh-border)] bg-base-secondary`,be=[`h-11`,`border-t border-[var(--oh-border)] transition-colors`].join(` `),xe=`hover:bg-interactive-hover-low outline-none focus:outline-none focus-visible:outline-none focus-visible:bg-interactive-hover-low`,Y=`px-3 align-middle`,Se=[be,xe,`cursor-pointer`].join(` `),Ce=`openhands-automations-view`;function we(){return typeof window>`u`?`grid`:window.localStorage.getItem(`openhands-automations-view`)===`list`?`list`:`grid`}function Te(e){window.localStorage.setItem(Ce,e)}function Ee({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onEdit:o}){let{navigate:s}=w(),{t:c}=l(`openhands`),u=z(`manage_automations`),d=e.trigger.schedule_human||e.trigger.type,f=(0,G.useMemo)(()=>q(e,d),[e,d]),p=()=>{s?.(`/automations/${e.id}`)},m=J({automation:e,t:c,canManage:u,onRunNow:n,isRunPending:r,onView:p,onEdit:o,onToggle:t,onDelete:i}),h=()=>{p()};return(0,K.jsxs)(`tr`,{"data-testid":`automation-list-row-${e.id}`,onClick:h,onKeyDown:e=>{e.key===`Enter`&&h()},tabIndex:0,className:b(Se,`cursor-pointer`),children:[(0,K.jsx)(`td`,{className:Y,children:(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.trigger.type===`event`?(0,K.jsx)(P,{className:`size-4 shrink-0 text-muted`}):(0,K.jsx)(W,{className:`size-4 shrink-0 text-muted`}),(0,K.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate text-sm font-medium text-white`,title:e.name,children:e.name}),f.length>0?(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(N,{pills:f,testId:`automation-pills-${e.id}`})}):null]})}),(0,K.jsx)(`td`,{className:b(`w-0 whitespace-nowrap`,Y),children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[u?(0,K.jsx)(T,{content:c(a.AUTOMATIONS$RUN_NOW),placement:`top`,children:(0,K.jsx)(`button`,{type:`button`,"data-testid":`automation-run-now-${e.id}`,"aria-label":c(a.AUTOMATIONS$RUN_NOW),"aria-busy":r,disabled:r||!e.enabled,onClick:t=>{t.stopPropagation(),n(e.id)},className:H,children:(0,K.jsx)(R,{className:`size-4 shrink-0`,"aria-hidden":!0})})}):null,(0,K.jsx)(U,{items:m})]})})]})}function X({title:e,count:t,automations:n,view:r,onToggle:i,onRunNow:a,runPendingId:s=null,onDelete:c,onEdit:l}){return n.length===0?null:(0,K.jsxs)(`section`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:e}),(0,K.jsx)(o,{count:t})]}),r===`grid`?(0,K.jsx)(`div`,{className:b(`mt-3`,g),children:(0,K.jsx)(`div`,{className:v,children:n.map(e=>(0,K.jsx)(ve,{automation:e,onToggle:i,onRunNow:a,isRunPending:s===e.id,onDelete:c,onEdit:l},e.id))})}):(0,K.jsx)(`div`,{className:b(ye,`mt-3`),children:(0,K.jsx)(`table`,{className:`w-full min-w-full [&>tbody>tr:first-child]:border-t-0`,children:(0,K.jsx)(`tbody`,{children:n.map(e=>(0,K.jsx)(Ee,{automation:e,onToggle:i,onRunNow:a,isRunPending:s===e.id,onDelete:c,onEdit:l},e.id))})})})]})}var De=e(r(),1),Z=[{value:`grid`,icon:he,labelKey:a.AUTOMATIONS$VIEW_GRID,testId:`automations-view-toggle-grid`},{value:`list`,icon:ge,labelKey:a.AUTOMATIONS$VIEW_LIST,testId:`automations-view-toggle-list`}];function Oe({icon:e,label:t,isSelected:n}){return(0,K.jsxs)(`span`,{className:`flex min-w-0 w-full items-center gap-2`,children:[(0,K.jsx)(`span`,{className:E,"aria-hidden":!0,children:(0,K.jsx)(e,{})}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),n?(0,K.jsx)(d,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]})}function ke({view:e,onChange:t,disabled:n=!1}){let{t:r}=l(`openhands`),[i,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(),u=(0,G.useRef)(null),d=(0,G.useRef)(null),f=(Z.find(t=>t.value===e)??Z[0]).icon;(0,G.useLayoutEffect)(()=>{if(!i||!u.current)return;let e=()=>{let e=u.current?.getBoundingClientRect();e&&c({position:`fixed`,zIndex:9999,top:e.bottom+4,right:window.innerWidth-e.right})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[i]),(0,G.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;u.current?.contains(t)||d.current?.contains(t)||o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let p=i&&s?(0,K.jsx)(O,{ref:d,theme:`popover`,className:`min-w-[10rem]`,children:Z.map(n=>(0,K.jsx)(`li`,{children:(0,K.jsx)(k,{testId:n.testId,onClick:()=>{t(n.value),o(!1)},className:`group`,children:(0,K.jsx)(Oe,{icon:n.icon,label:r(n.labelKey),isSelected:e===n.value})})},n.value))}):null;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{ref:u,type:`button`,"data-testid":`automations-view-toggle`,"aria-label":r(a.AUTOMATIONS$VIEW_MODE),"aria-haspopup":`menu`,"aria-expanded":i,"aria-disabled":n,disabled:n,onClick:()=>{n||o(e=>!e)},className:b(`inline-flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-[var(--oh-border)] bg-base-secondary text-white transition-colors hover:bg-[var(--oh-interactive-hover)] focus-visible:border-white/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white/20`,`disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-base-secondary`),children:(0,K.jsx)(f,{className:`size-4`,"aria-hidden":!0})}),i&&s&&typeof document<`u`?De.createPortal((0,K.jsx)(`div`,{style:s,children:p}),document.body):null]})}function Q(){return(0,K.jsxs)(`div`,{"data-testid":`automation-card-skeleton`,className:`${y} border border-transparent p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsx)(`div`,{className:`h-5 w-40 animate-pulse rounded bg-surface-raised`}),(0,K.jsx)(`div`,{className:`h-5 w-10 animate-pulse rounded-full bg-surface-raised`})]}),(0,K.jsx)(`div`,{className:`mt-2 h-4 w-72 animate-pulse rounded bg-surface-raised`}),(0,K.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,K.jsx)(`div`,{className:`h-7 w-32 animate-pulse rounded-full bg-surface-raised`}),(0,K.jsx)(`div`,{className:`h-7 w-28 animate-pulse rounded-full bg-surface-raised`}),(0,K.jsx)(`div`,{className:`h-7 w-24 animate-pulse rounded-full bg-surface-raised`})]})]})}var Ae=e=>(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m19.5 8.25-7.5 7.5-7.5-7.5`})}),je=`https://docs.openhands.dev/openhands/usage/automations/overview`;function Me({children:e}){return(0,K.jsx)(`span`,{className:`whitespace-nowrap`,children:e})}function Ne({children:e}){return(0,K.jsx)(`code`,{"data-testid":`automations-create-instructions-example`,className:b(`mx-0.5 inline-block rounded-sm border border-[var(--oh-border-subtle)]`,`bg-[var(--oh-surface-raised)] px-1.5 py-0.5 align-baseline font-mono text-[11px] text-white`),children:e})}function Pe({children:e}){return(0,K.jsx)(K.Fragment,{children:e})}var Fe={example:(0,K.jsx)(Me,{}),cmd:(0,K.jsx)(Ne,{}),punct:(0,K.jsx)(Pe,{})};function $({onLaunch:e}={}){let{t}=l(`openhands`),n=I();return(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsxs)(`p`,{className:`text-sm leading-relaxed text-tertiary-light`,children:[(0,K.jsx)(c,{ns:`openhands`,i18nKey:a.AUTOMATIONS$EMPTY_OPTION_CONVERSATION_DESC,components:Fe}),` `,t(a.AUTOMATIONS$CREATE_INSTRUCTIONS_GUIDANCE)]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,K.jsx)(`a`,{href:je,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-muted underline transition-colors hover:text-foreground`,children:t(a.AUTOMATIONS$EMPTY_LEARN_MORE)}),(0,K.jsx)(C,{type:`button`,variant:`primary`,testId:`automations-create-automation`,onClick:()=>{n(t(a.AUTOMATIONS$CREATE_AUTOMATION_PROMPT),e)},startContent:(0,K.jsx)(F,{className:`size-4`,"aria-hidden":!0}),children:t(a.AUTOMATIONS$CREATE_AUTOMATION_BUTTON)})]})]})}function Ie({collapsible:e=!1}){let{t}=l(`openhands`),[n,r]=(0,G.useState)(!e);return e?(0,K.jsxs)(`div`,{className:`w-full rounded-lg border border-[var(--oh-border)] bg-[var(--oh-surface)]`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),"aria-expanded":n,className:`flex w-full items-center justify-between rounded-lg p-4 text-left transition-colors hover:bg-surface-raised`,children:[(0,K.jsx)(`span`,{className:`text-sm font-normal text-content`,children:t(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,K.jsx)(Ae,{className:b(`size-5 text-muted transition-transform`,n&&`rotate-180`)})]}),n?(0,K.jsx)(`div`,{className:`px-4 pb-4`,children:(0,K.jsx)($,{})}):null]}):(0,K.jsxs)(`div`,{className:`w-full max-w-2xl`,children:[(0,K.jsx)(`h3`,{className:`text-center text-sm font-medium text-content`,children:t(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,K.jsx)(`div`,{className:`mt-4`,children:(0,K.jsx)($,{})})]})}function Le(){let{t:e}=l(`openhands`);return(0,K.jsxs)(`div`,{"data-testid":`automations-empty`,className:h,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e(a.AUTOMATIONS$EMPTY)}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-tertiary-light`,children:e(a.AUTOMATIONS$EMPTY_HINT)}),(0,K.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,K.jsx)(Ie,{})})]})}function Re({isOpen:e,onClose:t}){let{t:n}=l(`openhands`);return e?(0,K.jsx)(x,{onClose:t,"aria-label":n(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE),children:(0,K.jsxs)(`div`,{"data-testid":`add-automation-modal`,className:`relative flex w-full max-w-lg flex-col rounded-xl border border-[var(--oh-border)] bg-base-secondary`,children:[(0,K.jsx)(D,{onClose:t,testId:`add-automation-modal-close`}),(0,K.jsx)(`header`,{className:`flex-shrink-0 px-6 pb-4 pt-6`,children:(0,K.jsx)(`h2`,{id:`add-automation-modal-title`,className:b(`pr-6`,S),children:n(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)})}),(0,K.jsx)(`div`,{className:`px-6 pb-6`,children:(0,K.jsx)($,{onLaunch:t})})]})}):null}var ze=50,Be=n(function(){let{t:e}=l(`openhands`),[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(()=>we()),[o,c]=(0,G.useState)(ze),[u,d]=(0,G.useState)(null),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(!1),v=ee().backend.kind===`local`,{data:y,isLoading:b,refetch:x}=ae(),S=y?.status===`ok`,{data:w,isLoading:T,isError:E,refetch:D}=re({limit:o,offset:0,enabled:S}),{trackPrebuiltAutomationEnabled:O}=ne(),k=ie(),A=fe(),j=pe(),M=(0,G.useMemo)(()=>{if(!w?.automations)return[];let e=t.toLowerCase();return e?w.automations.filter(t=>t.name.toLowerCase().includes(e)||(t.prompt??``).toLowerCase().includes(e)||t.repository?.toLowerCase().includes(e)||t.model?.toLowerCase().includes(e)):w.automations},[w?.automations,t]),N=(0,G.useMemo)(()=>M.filter(e=>e.enabled),[M]),P=(0,G.useMemo)(()=>M.filter(e=>!e.enabled),[M]),F=(e,t)=>{let n=!t;if(k.mutate({id:e,enabled:n}),n){let t=w?.automations.find(t=>t.id===e);O({automationId:e,automationName:t?.name??e})}},I=t=>{j.mutate(t,{onSuccess:()=>{p(e(a.AUTOMATIONS$RUN_NOW_SUCCESS))},onError:t=>{f(te(t)?t.response?.data?.message||t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR):t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR))}})},L=e=>{let t=w?.automations.find(t=>t.id===e);t&&d({id:e,name:t.name})},R=e=>{let t=w?.automations.find(t=>t.id===e);t&&h(t)},z=()=>{u&&(A.mutate(u.id),d(null))},B=(0,G.useCallback)(e=>{i(e),Te(e)},[]),V=w?w.total>w.automations.length:!1,H=!T&&!E&&w?.automations.length===0;return b?(0,K.jsx)(`div`,{className:`min-h-full`,children:(0,K.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)}),(0,K.jsx)(`div`,{className:`mt-6 flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,K.jsx)(Q,{},`skeleton-${String(t)}`))})]})}):S?(0,K.jsx)(`div`,{className:`min-h-full`,children:(0,K.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-semibold text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)})]}),(0,K.jsx)(C,{type:`button`,variant:`secondary`,testId:`automations-add-automation`,className:`shrink-0 whitespace-nowrap`,onClick:()=>_(!0),children:e(a.AUTOMATIONS$ADD_AUTOMATION)})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex items-stretch gap-2`,children:[(0,K.jsx)(_e,{value:t,onChange:n}),(0,K.jsx)(ke,{view:r,onChange:B,disabled:H})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex flex-col gap-6`,children:[T&&(0,K.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,K.jsx)(Q,{},`skeleton-${String(t)}`))}),E&&!T&&(0,K.jsx)(oe,{onRetry:D}),H&&(0,K.jsx)(Le,{}),!T&&!E&&w&&w.automations.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{title:e(a.AUTOMATIONS$ACTIVE),count:N.length,automations:N,view:r,onToggle:F,onRunNow:I,runPendingId:j.isPending?j.variables??null:null,onDelete:L,onEdit:v?R:void 0}),(0,K.jsx)(X,{title:e(a.AUTOMATIONS$INACTIVE),count:P.length,automations:P,view:r,onToggle:F,onRunNow:I,runPendingId:j.isPending?j.variables??null:null,onDelete:L,onEdit:v?R:void 0}),V&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(e=>e+ze),className:`self-center rounded-lg border border-[var(--oh-border)] px-6 py-2 text-sm text-white hover:bg-surface-raised`,children:e(a.AUTOMATIONS$LOAD_MORE)})]})]}),(0,K.jsx)(`div`,{className:`mt-6`,children:(0,K.jsx)(s,{query:t})}),(0,K.jsx)(se,{automationName:u?.name??``,isOpen:u!==null,onConfirm:z,onCancel:()=>d(null)}),m&&(0,K.jsx)(de,{automation:m,isOpen:m!==null,onClose:()=>h(null)}),(0,K.jsx)(Re,{isOpen:g,onClose:()=>_(!1)})]})}):(0,K.jsx)(`div`,{className:`min-h-full`,children:(0,K.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)}),(0,K.jsx)(le,{onRetry:x})]})})});export{Be as default};
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{o as i,t as a}from"./declaration-IA661TBv.js";import{n as o,t as s}from"./recommended-automations-launcher-C1_CKGHa.js";import{t as c}from"./Trans-rF21Jwln.js";import{t as l}from"./useTranslation-CbJtty1g.js";import{t as u}from"./createLucideIcon-C9OEnwvX.js";import{t as d}from"./check-BDAbW7je.js";import{n as f,r as p}from"./custom-toast-handlers-fgD4IYsu.js";import{a as m,c as h,i as g,o as _,r as v,s as y}from"./circle-plus-check-toggle-CboDp7XB.js";import{t as b}from"./utils-CVcuFUYj.js";import{n as ee}from"./active-backend-context-CQTk4wD8.js";import{t as x}from"./modal-backdrop-B1si6TUd.js";import{n as S}from"./modal-classes-9XTtWCtF.js";import{t as C}from"./brand-button-BoiPxAGm.js";import{n as w}from"./navigation-context-CszaA-CJ.js";import{t as T}from"./styled-tooltip-GXy1qxsO.js";import{u as E}from"./dropdown-classes-lT1LUsbO.js";import{n as te}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~e9ykmtgh-DMH1jSwL.js";import{t as D}from"./modal-close-button-DY-rVmld.js";import{t as ne}from"./use-tracking-CjLZgh8X.js";import{n as O,t as k}from"./context-menu-list-item-CHWCx1Mc.js";import{t as A}from"./u-edit-foF02hwH.js";import{t as j}from"./folder-wShAU0y7.js";import{t as M}from"./search-BqXT2Ied.js";import{n as N}from"./skill-card-pill-row-Bg5joQf6.js";import{t as P}from"./globe-CQ_5xwpo.js";import{n as F,t as I}from"./use-launch-skill-in-chat-ClRJlIx7.js";import{_ as re,b as ie,c as L,d as R,f as z,g as ae,h as B,i as oe,l as V,m as H,n as se,o as ce,p as U,r as le,s as ue,t as de,u as W,v as fe,y as pe}from"./edit-automation-modal-C-oC5tis.js";var me=u(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),he=u(`grid-2x2`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),ge=u(`rows-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]),G=e(t(),1),K=i();function _e({value:e,onChange:t,className:n}){let{t:r}=l(`openhands`);return(0,K.jsxs)(`div`,{className:b(`relative flex min-w-0 flex-1 items-center`,`h-9 rounded-lg border border-[var(--oh-border)] bg-base-secondary`,`focus-within:border-white/40 focus-within:ring-1 focus-within:ring-white/20`,`transition-colors`,n),children:[(0,K.jsx)(M,{className:`ml-3 size-4 shrink-0 text-tertiary-alt`,"aria-hidden":!0}),(0,K.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:r(a.AUTOMATIONS$SEARCH_PLACEHOLDER),"aria-label":r(a.AUTOMATIONS$SEARCH_PLACEHOLDER),className:`min-w-0 flex-1 border-0 bg-transparent px-3 text-sm text-white outline-none placeholder:text-tertiary-alt`})]})}function q(e,t){let n=[];if(e.repository&&n.push({id:`repository`,node:(0,K.jsxs)(`span`,{className:b(_,`gap-1`),children:[(0,K.jsx)(j,{className:`size-3 shrink-0`}),e.repository]})}),e.trigger.type===`event`){let t=[e.trigger.on?L(e.trigger.on):``,e.trigger.source?`(${e.trigger.source})`:``].filter(Boolean).join(` `);n.push({id:`event-trigger`,node:(0,K.jsxs)(`span`,{className:b(_,`gap-1`),children:[(0,K.jsx)(P,{className:`size-3 shrink-0`}),t]})})}else n.push({id:`schedule`,node:(0,K.jsxs)(`span`,{className:b(_,`gap-1`),children:[(0,K.jsx)(W,{className:`size-3 shrink-0`}),t]})});return e.model&&n.push({id:`model`,node:(0,K.jsxs)(`span`,{className:b(_,`gap-1`),children:[(0,K.jsx)(V,{className:`size-3 shrink-0`}),e.model]})}),n}function J({automation:e,t,canManage:n,onRunNow:r,isRunPending:i,onView:o,onEdit:s,onToggle:c,onDelete:l}){return[...n?[{label:t(a.AUTOMATIONS$RUN_NOW),icon:(0,K.jsx)(R,{className:`size-4`}),onClick:()=>r(e.id),disabled:i||!e.enabled}]:[],{label:t(a.COMMON$VIEW),icon:(0,K.jsx)(me,{className:`size-4`,"aria-hidden":!0}),onClick:o},...n&&s?[{label:t(a.AUTOMATIONS$EDIT),icon:(0,K.jsx)(A,{className:`size-4`}),onClick:()=>s(e.id)}]:[],...n?[{label:e.enabled?t(a.AUTOMATIONS$TURN_OFF):t(a.AUTOMATIONS$TURN_ON),icon:(0,K.jsx)(ue,{className:`size-4`}),onClick:()=>c(e.id,e.enabled)},{label:t(a.AUTOMATIONS$DELETE),icon:(0,K.jsx)(ce,{className:`size-4`}),onClick:()=>l(e.id)}]:[]]}function ve({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onEdit:o}){let{navigate:s}=w(),{t:c}=l(`openhands`),u=z(`manage_automations`),d=e.trigger.schedule_human||e.trigger.type,f=(0,G.useMemo)(()=>q(e,d),[e,d]),p=()=>{s?.(`/automations/${e.id}`)},h=J({automation:e,t:c,canManage:u,onRunNow:n,isRunPending:r,onView:p,onEdit:o,onToggle:t,onDelete:i}),g=()=>{p()};return(0,K.jsxs)(`div`,{role:`link`,tabIndex:0,"data-testid":`automation-card-${e.id}`,onClick:g,onKeyDown:e=>{e.key===`Enter`&&g()},className:b(`flex min-w-0 flex-col gap-3 overflow-hidden p-4 text-left`,y,m),children:[(0,K.jsxs)(`header`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,K.jsxs)(`h3`,{className:`flex items-center gap-2 truncate text-sm font-semibold text-white`,children:[e.trigger.type===`event`?(0,K.jsx)(P,{className:`size-4 shrink-0 text-muted`}):(0,K.jsx)(W,{className:`size-4 shrink-0 text-muted`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.name})]}),e.prompt?(0,K.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-tertiary-light`,children:e.prompt}):null]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[u?(0,K.jsxs)(`button`,{type:`button`,"data-testid":`automation-run-now-${e.id}`,"aria-busy":r,disabled:r||!e.enabled,onClick:t=>{t.stopPropagation(),n(e.id)},className:B,children:[(0,K.jsx)(R,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),c(a.AUTOMATIONS$RUN_NOW)]}):null,(0,K.jsx)(U,{items:h})]})]}),f.length>0?(0,K.jsx)(N,{pills:f,testId:`automation-pills-${e.id}`}):null]})}var ye=`overflow-hidden rounded-md border border-[var(--oh-border)] bg-base-secondary`,be=[`h-11`,`border-t border-[var(--oh-border)] transition-colors`].join(` `),xe=`hover:bg-interactive-hover-low outline-none focus:outline-none focus-visible:outline-none focus-visible:bg-interactive-hover-low`,Y=`px-3 align-middle`,Se=[be,xe,`cursor-pointer`].join(` `),Ce=`openhands-automations-view`;function we(){return typeof window>`u`?`grid`:window.localStorage.getItem(`openhands-automations-view`)===`list`?`list`:`grid`}function Te(e){window.localStorage.setItem(Ce,e)}function Ee({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onEdit:o}){let{navigate:s}=w(),{t:c}=l(`openhands`),u=z(`manage_automations`),d=e.trigger.schedule_human||e.trigger.type,f=(0,G.useMemo)(()=>q(e,d),[e,d]),p=()=>{s?.(`/automations/${e.id}`)},m=J({automation:e,t:c,canManage:u,onRunNow:n,isRunPending:r,onView:p,onEdit:o,onToggle:t,onDelete:i}),h=()=>{p()};return(0,K.jsxs)(`tr`,{"data-testid":`automation-list-row-${e.id}`,onClick:h,onKeyDown:e=>{e.key===`Enter`&&h()},tabIndex:0,className:b(Se,`cursor-pointer`),children:[(0,K.jsx)(`td`,{className:Y,children:(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.trigger.type===`event`?(0,K.jsx)(P,{className:`size-4 shrink-0 text-muted`}):(0,K.jsx)(W,{className:`size-4 shrink-0 text-muted`}),(0,K.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate text-sm font-medium text-white`,title:e.name,children:e.name}),f.length>0?(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(N,{pills:f,testId:`automation-pills-${e.id}`})}):null]})}),(0,K.jsx)(`td`,{className:b(`w-0 whitespace-nowrap`,Y),children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[u?(0,K.jsx)(T,{content:c(a.AUTOMATIONS$RUN_NOW),placement:`top`,children:(0,K.jsx)(`button`,{type:`button`,"data-testid":`automation-run-now-${e.id}`,"aria-label":c(a.AUTOMATIONS$RUN_NOW),"aria-busy":r,disabled:r||!e.enabled,onClick:t=>{t.stopPropagation(),n(e.id)},className:H,children:(0,K.jsx)(R,{className:`size-4 shrink-0`,"aria-hidden":!0})})}):null,(0,K.jsx)(U,{items:m})]})})]})}function X({title:e,count:t,automations:n,view:r,onToggle:i,onRunNow:a,runPendingId:s=null,onDelete:c,onEdit:l}){return n.length===0?null:(0,K.jsxs)(`section`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:e}),(0,K.jsx)(o,{count:t})]}),r===`grid`?(0,K.jsx)(`div`,{className:b(`mt-3`,g),children:(0,K.jsx)(`div`,{className:v,children:n.map(e=>(0,K.jsx)(ve,{automation:e,onToggle:i,onRunNow:a,isRunPending:s===e.id,onDelete:c,onEdit:l},e.id))})}):(0,K.jsx)(`div`,{className:b(ye,`mt-3`),children:(0,K.jsx)(`table`,{className:`w-full min-w-full [&>tbody>tr:first-child]:border-t-0`,children:(0,K.jsx)(`tbody`,{children:n.map(e=>(0,K.jsx)(Ee,{automation:e,onToggle:i,onRunNow:a,isRunPending:s===e.id,onDelete:c,onEdit:l},e.id))})})})]})}var De=e(r(),1),Z=[{value:`grid`,icon:he,labelKey:a.AUTOMATIONS$VIEW_GRID,testId:`automations-view-toggle-grid`},{value:`list`,icon:ge,labelKey:a.AUTOMATIONS$VIEW_LIST,testId:`automations-view-toggle-list`}];function Oe({icon:e,label:t,isSelected:n}){return(0,K.jsxs)(`span`,{className:`flex min-w-0 w-full items-center gap-2`,children:[(0,K.jsx)(`span`,{className:E,"aria-hidden":!0,children:(0,K.jsx)(e,{})}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),n?(0,K.jsx)(d,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]})}function ke({view:e,onChange:t,disabled:n=!1}){let{t:r}=l(`openhands`),[i,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(),u=(0,G.useRef)(null),d=(0,G.useRef)(null),f=(Z.find(t=>t.value===e)??Z[0]).icon;(0,G.useLayoutEffect)(()=>{if(!i||!u.current)return;let e=()=>{let e=u.current?.getBoundingClientRect();e&&c({position:`fixed`,zIndex:9999,top:e.bottom+4,right:window.innerWidth-e.right})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[i]),(0,G.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;u.current?.contains(t)||d.current?.contains(t)||o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let p=i&&s?(0,K.jsx)(O,{ref:d,theme:`popover`,className:`min-w-[10rem]`,children:Z.map(n=>(0,K.jsx)(`li`,{children:(0,K.jsx)(k,{testId:n.testId,onClick:()=>{t(n.value),o(!1)},className:`group`,children:(0,K.jsx)(Oe,{icon:n.icon,label:r(n.labelKey),isSelected:e===n.value})})},n.value))}):null;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{ref:u,type:`button`,"data-testid":`automations-view-toggle`,"aria-label":r(a.AUTOMATIONS$VIEW_MODE),"aria-haspopup":`menu`,"aria-expanded":i,"aria-disabled":n,disabled:n,onClick:()=>{n||o(e=>!e)},className:b(`inline-flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-[var(--oh-border)] bg-base-secondary text-white transition-colors hover:bg-[var(--oh-interactive-hover)] focus-visible:border-white/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white/20`,`disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-base-secondary`),children:(0,K.jsx)(f,{className:`size-4`,"aria-hidden":!0})}),i&&s&&typeof document<`u`?De.createPortal((0,K.jsx)(`div`,{style:s,children:p}),document.body):null]})}function Q(){return(0,K.jsxs)(`div`,{"data-testid":`automation-card-skeleton`,className:`${y} border border-transparent p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsx)(`div`,{className:`h-5 w-40 animate-pulse rounded bg-surface-raised`}),(0,K.jsx)(`div`,{className:`h-5 w-10 animate-pulse rounded-full bg-surface-raised`})]}),(0,K.jsx)(`div`,{className:`mt-2 h-4 w-72 animate-pulse rounded bg-surface-raised`}),(0,K.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,K.jsx)(`div`,{className:`h-7 w-32 animate-pulse rounded-full bg-surface-raised`}),(0,K.jsx)(`div`,{className:`h-7 w-28 animate-pulse rounded-full bg-surface-raised`}),(0,K.jsx)(`div`,{className:`h-7 w-24 animate-pulse rounded-full bg-surface-raised`})]})]})}var Ae=e=>(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m19.5 8.25-7.5 7.5-7.5-7.5`})}),je=`https://docs.openhands.dev/openhands/usage/automations/overview`;function Me({children:e}){return(0,K.jsx)(`span`,{className:`whitespace-nowrap`,children:e})}function Ne({children:e}){return(0,K.jsx)(`code`,{"data-testid":`automations-create-instructions-example`,className:b(`mx-0.5 inline-block rounded-sm border border-[var(--oh-border-subtle)]`,`bg-[var(--oh-surface-raised)] px-1.5 py-0.5 align-baseline font-mono text-[11px] text-white`),children:e})}function Pe({children:e}){return(0,K.jsx)(K.Fragment,{children:e})}var Fe={example:(0,K.jsx)(Me,{}),cmd:(0,K.jsx)(Ne,{}),punct:(0,K.jsx)(Pe,{})};function $({onLaunch:e}={}){let{t}=l(`openhands`),n=I();return(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsxs)(`p`,{className:`text-sm leading-relaxed text-tertiary-light`,children:[(0,K.jsx)(c,{ns:`openhands`,i18nKey:a.AUTOMATIONS$EMPTY_OPTION_CONVERSATION_DESC,components:Fe}),` `,t(a.AUTOMATIONS$CREATE_INSTRUCTIONS_GUIDANCE)]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,K.jsx)(`a`,{href:je,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-muted underline transition-colors hover:text-foreground`,children:t(a.AUTOMATIONS$EMPTY_LEARN_MORE)}),(0,K.jsx)(C,{type:`button`,variant:`primary`,testId:`automations-create-automation`,onClick:()=>{n(t(a.AUTOMATIONS$CREATE_AUTOMATION_PROMPT),e)},startContent:(0,K.jsx)(F,{className:`size-4`,"aria-hidden":!0}),children:t(a.AUTOMATIONS$CREATE_AUTOMATION_BUTTON)})]})]})}function Ie({collapsible:e=!1}){let{t}=l(`openhands`),[n,r]=(0,G.useState)(!e);return e?(0,K.jsxs)(`div`,{className:`w-full rounded-lg border border-[var(--oh-border)] bg-[var(--oh-surface)]`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),"aria-expanded":n,className:`flex w-full items-center justify-between rounded-lg p-4 text-left transition-colors hover:bg-surface-raised`,children:[(0,K.jsx)(`span`,{className:`text-sm font-normal text-content`,children:t(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,K.jsx)(Ae,{className:b(`size-5 text-muted transition-transform`,n&&`rotate-180`)})]}),n?(0,K.jsx)(`div`,{className:`px-4 pb-4`,children:(0,K.jsx)($,{})}):null]}):(0,K.jsxs)(`div`,{className:`w-full max-w-2xl`,children:[(0,K.jsx)(`h3`,{className:`text-center text-sm font-medium text-content`,children:t(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,K.jsx)(`div`,{className:`mt-4`,children:(0,K.jsx)($,{})})]})}function Le(){let{t:e}=l(`openhands`);return(0,K.jsxs)(`div`,{"data-testid":`automations-empty`,className:h,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e(a.AUTOMATIONS$EMPTY)}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-tertiary-light`,children:e(a.AUTOMATIONS$EMPTY_HINT)}),(0,K.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,K.jsx)(Ie,{})})]})}function Re({isOpen:e,onClose:t}){let{t:n}=l(`openhands`);return e?(0,K.jsx)(x,{onClose:t,"aria-label":n(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE),children:(0,K.jsxs)(`div`,{"data-testid":`add-automation-modal`,className:`relative flex w-full max-w-lg flex-col rounded-xl border border-[var(--oh-border)] bg-base-secondary`,children:[(0,K.jsx)(D,{onClose:t,testId:`add-automation-modal-close`}),(0,K.jsx)(`header`,{className:`flex-shrink-0 px-6 pb-4 pt-6`,children:(0,K.jsx)(`h2`,{id:`add-automation-modal-title`,className:b(`pr-6`,S),children:n(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)})}),(0,K.jsx)(`div`,{className:`px-6 pb-6`,children:(0,K.jsx)($,{onLaunch:t})})]})}):null}var ze=50,Be=n(function(){let{t:e}=l(`openhands`),[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(()=>we()),[o,c]=(0,G.useState)(ze),[u,d]=(0,G.useState)(null),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(!1),v=ee().backend.kind===`local`,{data:y,isLoading:b,refetch:x}=ae(),S=y?.status===`ok`,{data:w,isLoading:T,isError:E,refetch:D}=re({limit:o,offset:0,enabled:S}),{trackPrebuiltAutomationEnabled:O}=ne(),k=ie(),A=fe(),j=pe(),M=(0,G.useMemo)(()=>{if(!w?.automations)return[];let e=t.toLowerCase();return e?w.automations.filter(t=>t.name.toLowerCase().includes(e)||(t.prompt??``).toLowerCase().includes(e)||t.repository?.toLowerCase().includes(e)||t.model?.toLowerCase().includes(e)):w.automations},[w?.automations,t]),N=(0,G.useMemo)(()=>M.filter(e=>e.enabled),[M]),P=(0,G.useMemo)(()=>M.filter(e=>!e.enabled),[M]),F=(e,t)=>{let n=!t;if(k.mutate({id:e,enabled:n}),n){let t=w?.automations.find(t=>t.id===e);O({automationId:e,automationName:t?.name??e})}},I=t=>{j.mutate(t,{onSuccess:()=>{p(e(a.AUTOMATIONS$RUN_NOW_SUCCESS))},onError:t=>{f(te(t)?t.response?.data?.message||t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR):t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR))}})},L=e=>{let t=w?.automations.find(t=>t.id===e);t&&d({id:e,name:t.name})},R=e=>{let t=w?.automations.find(t=>t.id===e);t&&h(t)},z=()=>{u&&(A.mutate(u.id),d(null))},B=(0,G.useCallback)(e=>{i(e),Te(e)},[]),V=w?w.total>w.automations.length:!1,H=!T&&!E&&w?.automations.length===0;return b?(0,K.jsx)(`div`,{className:`min-h-full`,children:(0,K.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)}),(0,K.jsx)(`div`,{className:`mt-6 flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,K.jsx)(Q,{},`skeleton-${String(t)}`))})]})}):S?(0,K.jsx)(`div`,{className:`min-h-full`,children:(0,K.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-semibold text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)})]}),(0,K.jsx)(C,{type:`button`,variant:`secondary`,testId:`automations-add-automation`,className:`shrink-0 whitespace-nowrap`,onClick:()=>_(!0),children:e(a.AUTOMATIONS$ADD_AUTOMATION)})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex items-stretch gap-2`,children:[(0,K.jsx)(_e,{value:t,onChange:n}),(0,K.jsx)(ke,{view:r,onChange:B,disabled:H})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex flex-col gap-6`,children:[T&&(0,K.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,K.jsx)(Q,{},`skeleton-${String(t)}`))}),E&&!T&&(0,K.jsx)(oe,{onRetry:D}),H&&(0,K.jsx)(Le,{}),!T&&!E&&w&&w.automations.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{title:e(a.AUTOMATIONS$ACTIVE),count:N.length,automations:N,view:r,onToggle:F,onRunNow:I,runPendingId:j.isPending?j.variables??null:null,onDelete:L,onEdit:v?R:void 0}),(0,K.jsx)(X,{title:e(a.AUTOMATIONS$INACTIVE),count:P.length,automations:P,view:r,onToggle:F,onRunNow:I,runPendingId:j.isPending?j.variables??null:null,onDelete:L,onEdit:v?R:void 0}),V&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(e=>e+ze),className:`self-center rounded-lg border border-[var(--oh-border)] px-6 py-2 text-sm text-white hover:bg-surface-raised`,children:e(a.AUTOMATIONS$LOAD_MORE)})]})]}),(0,K.jsx)(`div`,{className:`mt-6`,children:(0,K.jsx)(s,{query:t})}),(0,K.jsx)(se,{automationName:u?.name??``,isOpen:u!==null,onConfirm:z,onCancel:()=>d(null)}),m&&(0,K.jsx)(de,{automation:m,isOpen:m!==null,onClose:()=>h(null)}),(0,K.jsx)(Re,{isOpen:g,onClose:()=>_(!1)})]})}):(0,K.jsx)(`div`,{className:`min-h-full`,children:(0,K.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)}),(0,K.jsx)(le,{onRetry:x})]})})});export{Be 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,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-IA661TBv.js";import{r as o}from"./recommended-automations-launcher-B1kfmFTQ.js";import{t as s}from"./useTranslation-CbJtty1g.js";import{t as c}from"./vendor~root-layout~home~conversation-panel~conversation-Cg0nXqVs.js";import{a as l}from"./vendor~root-layout~home~mcp~automations-list-DGOI7kQz.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-CZ_7nd-M.js";import{a as x,n as S,t as C}from"./custom-toast-handlers-fgD4IYsu.js";import{t as w}from"./utils-CVcuFUYj.js";import{n as T}from"./active-backend-context-CQTk4wD8.js";import{t as E}from"./modal-backdrop-B1si6TUd.js";import{n as D}from"./modal-body-2Po2nl1e.js";import{r as O}from"./base-modal-Ba5WcNb6.js";import{a as k,g as A,o as j,p as M,t as N}from"./brand-button-BoiPxAGm.js";import{t as P}from"./use-config-DSzkljTq.js";import{n as F}from"./navigation-context-CszaA-CJ.js";import{t as I}from"./styled-tooltip-GXy1qxsO.js";import{i as L,n as R}from"./dropdown-classes-lT1LUsbO.js";import{c as z,f as B,l as V,r as H}from"./chat-send-button-qKFZuB9E.js";import{t as U}from"./conversation-store-CiYGBud3.js";import{t as W}from"./modal-close-button-DY-rVmld.js";import{r as ee}from"./use-settings-0qFqC-r6.js";import{t as te}from"./use-llm-profiles-CyNVoVqm.js";import{t as G}from"./use-create-conversation-CzvaVA5A.js";import{l as ne}from"./vendor~root-layout~home~conversation-panel~conversation~shared-conversation~alert-banner~pl~rqjteh0a-BwbkftxT.js";import{t as re}from"./folder-wShAU0y7.js";import{r as K}from"./typography-Cx7uw7z3.js";import{A as ie,F as ae,I as oe,M as q,N as se,a as ce,c as le,d as ue,f as de,i as fe,l as pe,n as me,o as he,p as ge,r as _e,s as ve,t as ye,u as be}from"./git-control-bar-branch-button-D1uam-nI.js";import{d as xe}from"./conversation-websocket-context-Bb4XBXoc.js";import{r as Se}from"./settings-utils-chxTa1vn.js";var J=e(t(),1);async function Y(e){let{imagesToEmbed:t}=oe(e.images,e.imagesMarkedUploadAsFile),n=await Promise.all(t.map(e=>q(e)));xe.getState().enqueuePendingMessage({conversationId:e.conversationId,text:e.text,content:e.text,imageUrls:n,fileUrls:[]})}var X=i();function Ce(){let{t:e}=s(`openhands`);return(0,X.jsx)(`div`,{className:`flex min-h-[80px] w-full items-center justify-center py-2`,children:(0,X.jsx)(K.H1,{className:`w-full text-center leading-normal`,children:e(`HOME$LETS_START_BUILDING`)})})}function we({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,X.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,X.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center`,children:o?(0,X.jsx)(l,{"aria-hidden":!0,className:`h-4 w-4`,strokeWidth:2}):(0,X.jsx)(B,{width:16,height:16,className:`shrink-0`})}),(0,X.jsx)(`span`,{className:`text-sm font-normal leading-5`,children:c})]});return r?(0,X.jsx)(I,{content:r,placement:`top`,children:(0,X.jsx)(`span`,{className:`inline-flex`,children:u})}):u}function Te({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,J.useState)(t?.name??``),g=(0,J.useRef)(null),_=(0,J.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,J.useCallback)(e=>{u(e),e&&h(e.name)},[u]),y=(0,J.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,X.jsx)(le,{item:e,index:t,isSelected:r?.id===e.id,getItemProps:i,getDisplayText:e=>e.name,getItemKey:e=>e.id},e.id),A=e=>(0,X.jsx)(ve,{inputValue:e,searchMessage:p(a.HOME$NO_WORKSPACES),emptyMessage:p(a.HOME$NO_WORKSPACES),testId:`workspace-dropdown-empty`}),M=(0,J.useMemo)(()=>(0,X.jsxs)(`div`,{className:L,children:[(0,X.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,X.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,X.jsxs)(`div`,{className:w(`relative`,r),children:[(0,X.jsxs)(`div`,{className:`group relative text-[var(--oh-muted)] hover:text-white`,children:[(0,X.jsx)(`div`,{className:`absolute left-2 top-1/2 transform -translate-y-1/2 z-10`,children:(0,X.jsx)(V,{width:16,height:16})}),(0,X.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,X.jsxs)(`div`,{className:`absolute right-1 top-1/2 transform -translate-y-1/2 flex items-center`,children:[t&&(0,X.jsx)(be,{disabled:i,onClear:y}),(0,X.jsx)(pe,{isOpen:b,disabled:i,getToggleButtonProps:x})]})]}),(0,X.jsx)(he,{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,X.jsx)(I,{content:o,placement:`top`,children:(0,X.jsx)(`span`,{className:`block`,children:N})}):N}var Z=`oh:home-selected-workspace-path`;function Ee(){if(typeof window>`u`)return null;try{let e=window.sessionStorage.getItem(Z);return e&&e.length>0?e:null}catch{return null}}function Q(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Z,e):window.sessionStorage.removeItem(Z)}catch{}}function De({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]=J.useState(null),[A,j]=J.useState(!1),[M,P]=J.useState(!1),{mutate:I,isPending:L,isSuccess:R}=G(),z=o(),B=L||R||z,V=J.useCallback(e=>{k(e),Q(e?.path??null)},[]);J.useEffect(()=>{let e=Ee();if(!e)return;let t=C.find(t=>t.path===e);if(t){k(e=>e?.path===t.path?e:t);return}!w&&!T&&!D&&(Q(null),k(t=>t?.path===e?null:t))},[T,w,C,D]);let H=l.length>0||!!D,U=null;D?U=D:w?U=n(a.HOME$LOADING):T&&(U=n(a.HOME$WORKSPACE_SCAN_ERROR));let W=!!D||e||w&&C.length===0;return(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[!t&&(0,X.jsxs)(`div`,{className:`flex items-center gap-[10px] pb-4`,children:[(0,X.jsx)(re,{width:24,height:24}),(0,X.jsx)(`span`,{className:`leading-5 font-bold text-base text-white`,children:n(a.HOME$WORKSPACES_TAB)})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] pb-4`,children:[(0,X.jsx)(Te,{workspaces:C,value:O,placeholder:D?n(a.HOME$WORKSPACES_UNSUPPORTED_PLACEHOLDER):W?n(a.HOME$LOADING):void 0,disabled:W,disabledTooltip:D,showManage:C.length>0||l.length>0,onChange:V,onAddClick:()=>j(!0),onManageClick:()=>P(!0),className:`max-w-auto`},O?.path??`empty-workspace-selection`),H&&U&&(0,X.jsx)(`p`,{className:`px-1 text-xs text-[var(--oh-text-secondary)]`,"data-testid":`workspace-status-message`,children:U})]}),(0,X.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,X.jsx)(p,{isOpen:A,onClose:()=>j(!1),onAdd:e=>h(e),onAddParent:e=>x(e)}),(0,X.jsx)(_,{isOpen:M,workspaces:C,workspaceParents:l,onClose:()=>P(!1),onRemove:e=>{O?.path===e&&V(null),y(e)},onRemoveParent:e=>{O?.parentPath===e&&V(null),S(e)}})]})}function Oe({isOpen:e,onClose:t,onConfirm:n}){let{t:r}=s(`openhands`),{isLoadingSettings:i}=z();return e?(0,X.jsx)(E,{onClose:t,children:(0,X.jsxs)(D,{width:`sm`,className:`relative items-start border border-[var(--oh-border)] !gap-4`,children:[(0,X.jsx)(W,{onClose:t,testId:`close-open-workspace-dialog`}),(0,X.jsx)(`div`,{className:`w-full pr-6`,children:(0,X.jsx)(O,{title:r(a.HOME$OPEN_WORKSPACE)})}),(0,X.jsx)(`div`,{className:`w-full`,"data-testid":`open-workspace-dialog-body`,children:(0,X.jsx)(De,{isLoadingSettings:i,onConfirm:e=>{n(e),t()}})})]})}):null}function ke({onRepoSelection:e,isLoadingSettings:t=!1,onConfirm:n}){let{navigate:r}=F(),[i,c]=J.useState(null),[l,u]=J.useState(null),[d,f]=J.useState(null),{providers:p}=z(),{addRecentRepository:m,setLastSelectedProvider:h,getLastSelectedProvider:g}=H(),{mutate:_,isPending:v,isSuccess:y}=G(),b=o(),{t:x}=s(`openhands`);J.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=J.useCallback(e=>{u(e)},[]);return(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[!n&&(0,X.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-[10px] pb-4`,children:[(0,X.jsx)(B,{width:24,height:24}),(0,X.jsx)(`span`,{className:`leading-5 font-bold text-base text-white`,children:x(a.COMMON$OPEN_REPOSITORY)})]})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] pb-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm text-white font-normal leading-[22px]`,children:x(a.HOME$SELECT_OR_INSERT_URL)}),p.length<=1?null:(0,X.jsx)(ce,{providers:p,value:d,placeholder:`Select Provider`,className:`max-w-[500px]`,onChange:C,disabled:t})]}),(0,X.jsx)(_e,{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,X.jsx)(fe,{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,X.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 Ae({isOpen:e,onClose:t,onConfirm:n}){let{t:r}=s(`openhands`),{isLoadingSettings:i}=z();return e?(0,X.jsx)(E,{onClose:t,children:(0,X.jsxs)(D,{width:`sm`,className:`relative items-start border border-[var(--oh-border)] !gap-4`,children:[(0,X.jsx)(W,{onClose:t,testId:`close-open-repository-dialog`}),(0,X.jsx)(`div`,{className:`w-full pr-6`,children:(0,X.jsx)(O,{title:r(a.COMMON$OPEN_REPOSITORY)})}),(0,X.jsx)(`div`,{className:`w-full`,"data-testid":`open-repository-dialog-body`,children:(0,X.jsx)(ke,{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,X.jsxs)(`div`,{className:`flex flex-row gap-2.5 items-center flex-wrap`,"data-testid":`home-git-control-bar-preview`,children:[(0,X.jsx)(me,{selectedRepository:t?.full_name??null,gitProvider:r??null,workspaceName:a,onClick:i}),n?(0,X.jsx)(ye,{selectedBranch:n.name,selectedRepository:t?.full_name??null,gitProvider:r??null}):null]})}function je(){let{t:e}=s(`openhands`),{backend:t}=T(),{navigate:n}=F(),r=t.kind===`local`,[i,c]=(0,J.useState)(!1),[l,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),{mutate:y,isPending:b}=G(),w=o(),E=b||w,{images:D,files:O,imagesMarkedUploadAsFile:k,clearAllFiles:A}=U(),{handleUpload:j}=ue(),{error:M}=v({enabled:r}),N=r?u(M,e):null,P=r?!!l:!!f&&!!m,I=de(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(ae)}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}se(e,{content:i,images:s.images,files:s.files,imagesMarkedUploadAsFile:[...k]}),A(),await Y({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 Y({conversationId:a,text:i,images:[],imagesMarkedUploadAsFile:[]}),n(`/conversations/${a}`)},onError:e=>{x.dismiss(u),S(e instanceof Error?e.message:null)}})});return(0,X.jsxs)(`div`,{"data-testid":`home-chat-launcher`,className:`flex w-full max-w-[800px] flex-col gap-4 md:px-4`,children:[(0,X.jsx)(`div`,{className:`flex w-full justify-center`,children:(0,X.jsx)(Ce,{})}),(0,X.jsx)(`div`,{className:`w-full`,children:(0,X.jsx)(ge,{onSubmit:I,onFilesPaste:j,disabled:E})}),(0,X.jsx)(`div`,{className:`flex justify-start`,children:P?(0,X.jsx)($,{workspace:l,repository:f,branch:m,provider:g,onRepoClick:()=>c(!0)}):(0,X.jsx)(we,{kind:r?`local`:`cloud`,onClick:()=>c(!0),disabled:E||!!N,disabledTooltip:N})}),r?(0,X.jsx)(Oe,{isOpen:i,onClose:()=>c(!1),onConfirm:e=>{d(e),p(null),h(null),_(null)}}):(0,X.jsx)(Ae,{isOpen:i,onClose:()=>c(!1),onConfirm:({repository:e,branch:t,provider:n})=>{p(e),h(t),_(n??e.git_provider),d(null)}})]})}function Me(){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=Se(`/settings/llm`,r?.feature_flags);return{isConfigured:l||u||d||f,isLoading:t||n&&!e||i||a&&!r||s||c&&!o}}function Ne(){let{t:e}=s(`openhands`),{navigate:t}=F(),{isConfigured:n,isLoading:r}=Me();return r||n?null:(0,X.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,X.jsxs)(`div`,{className:`flex items-center`,children:[(0,X.jsx)(`div`,{className:`flex-shrink-0`,children:(0,X.jsx)(ne,{className:`text-primary align-middle`})}),(0,X.jsx)(K.Text,{className:`ml-3 text-sm font-medium`,children:e(a.HOME$LLM_NOT_CONFIGURED_MESSAGE)})]}),(0,X.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 Pe(){let e=h(r().search);return(0,X.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,X.jsx)(Ne,{}),(0,X.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col items-center justify-center`,children:(0,X.jsx)(je,{})}),e?null:(0,X.jsx)(y,{})]})}var Fe=n(Pe);export{Fe 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-IA661TBv.js";import{r as o}from"./recommended-automations-launcher-C1_CKGHa.js";import{t as s}from"./useTranslation-CbJtty1g.js";import{t as c}from"./vendor~root-layout~home~conversation-panel~conversation-Cg0nXqVs.js";import{a as l}from"./vendor~root-layout~home~mcp~automations-list-DGOI7kQz.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-CGUaLHfQ.js";import{a as x,n as S,t as C}from"./custom-toast-handlers-fgD4IYsu.js";import{t as w}from"./utils-CVcuFUYj.js";import{n as T}from"./active-backend-context-CQTk4wD8.js";import{t as E}from"./modal-backdrop-B1si6TUd.js";import{n as D}from"./modal-body-2Po2nl1e.js";import{r as O}from"./base-modal-Ba5WcNb6.js";import{a as k,g as A,o as j,p as M,t as N}from"./brand-button-BoiPxAGm.js";import{t as P}from"./use-config-DSzkljTq.js";import{n as F}from"./navigation-context-CszaA-CJ.js";import{t as I}from"./styled-tooltip-GXy1qxsO.js";import{i as L,n as R}from"./dropdown-classes-lT1LUsbO.js";import{c as z,f as B,l as V,r as H}from"./chat-send-button-qKFZuB9E.js";import{t as U}from"./conversation-store-CiYGBud3.js";import{t as W}from"./modal-close-button-DY-rVmld.js";import{r as ee}from"./use-settings-0qFqC-r6.js";import{t as te}from"./use-llm-profiles-CyNVoVqm.js";import{t as G}from"./use-create-conversation-CzvaVA5A.js";import{l as ne}from"./vendor~root-layout~home~conversation-panel~conversation~shared-conversation~alert-banner~pl~rqjteh0a-BwbkftxT.js";import{t as re}from"./folder-wShAU0y7.js";import{r as K}from"./typography-Cx7uw7z3.js";import{A as ie,F as ae,I as oe,M as q,N as se,a as ce,c as le,d as ue,f as de,i as fe,l as pe,n as me,o as he,p as ge,r as _e,s as ve,t as ye,u as be}from"./git-control-bar-branch-button-D1uam-nI.js";import{d as xe}from"./conversation-websocket-context-Bb4XBXoc.js";import{r as Se}from"./settings-utils-chxTa1vn.js";var J=e(t(),1);async function Y(e){let{imagesToEmbed:t}=oe(e.images,e.imagesMarkedUploadAsFile),n=await Promise.all(t.map(e=>q(e)));xe.getState().enqueuePendingMessage({conversationId:e.conversationId,text:e.text,content:e.text,imageUrls:n,fileUrls:[]})}var X=i();function Ce(){let{t:e}=s(`openhands`);return(0,X.jsx)(`div`,{className:`flex min-h-[80px] w-full items-center justify-center py-2`,children:(0,X.jsx)(K.H1,{className:`w-full text-center leading-normal`,children:e(`HOME$LETS_START_BUILDING`)})})}function we({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,X.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,X.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center`,children:o?(0,X.jsx)(l,{"aria-hidden":!0,className:`h-4 w-4`,strokeWidth:2}):(0,X.jsx)(B,{width:16,height:16,className:`shrink-0`})}),(0,X.jsx)(`span`,{className:`text-sm font-normal leading-5`,children:c})]});return r?(0,X.jsx)(I,{content:r,placement:`top`,children:(0,X.jsx)(`span`,{className:`inline-flex`,children:u})}):u}function Te({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,J.useState)(t?.name??``),g=(0,J.useRef)(null),_=(0,J.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,J.useCallback)(e=>{u(e),e&&h(e.name)},[u]),y=(0,J.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,X.jsx)(le,{item:e,index:t,isSelected:r?.id===e.id,getItemProps:i,getDisplayText:e=>e.name,getItemKey:e=>e.id},e.id),A=e=>(0,X.jsx)(ve,{inputValue:e,searchMessage:p(a.HOME$NO_WORKSPACES),emptyMessage:p(a.HOME$NO_WORKSPACES),testId:`workspace-dropdown-empty`}),M=(0,J.useMemo)(()=>(0,X.jsxs)(`div`,{className:L,children:[(0,X.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,X.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,X.jsxs)(`div`,{className:w(`relative`,r),children:[(0,X.jsxs)(`div`,{className:`group relative text-[var(--oh-muted)] hover:text-white`,children:[(0,X.jsx)(`div`,{className:`absolute left-2 top-1/2 transform -translate-y-1/2 z-10`,children:(0,X.jsx)(V,{width:16,height:16})}),(0,X.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,X.jsxs)(`div`,{className:`absolute right-1 top-1/2 transform -translate-y-1/2 flex items-center`,children:[t&&(0,X.jsx)(be,{disabled:i,onClear:y}),(0,X.jsx)(pe,{isOpen:b,disabled:i,getToggleButtonProps:x})]})]}),(0,X.jsx)(he,{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,X.jsx)(I,{content:o,placement:`top`,children:(0,X.jsx)(`span`,{className:`block`,children:N})}):N}var Z=`oh:home-selected-workspace-path`;function Ee(){if(typeof window>`u`)return null;try{let e=window.sessionStorage.getItem(Z);return e&&e.length>0?e:null}catch{return null}}function Q(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Z,e):window.sessionStorage.removeItem(Z)}catch{}}function De({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]=J.useState(null),[A,j]=J.useState(!1),[M,P]=J.useState(!1),{mutate:I,isPending:L,isSuccess:R}=G(),z=o(),B=L||R||z,V=J.useCallback(e=>{k(e),Q(e?.path??null)},[]);J.useEffect(()=>{let e=Ee();if(!e)return;let t=C.find(t=>t.path===e);if(t){k(e=>e?.path===t.path?e:t);return}!w&&!T&&!D&&(Q(null),k(t=>t?.path===e?null:t))},[T,w,C,D]);let H=l.length>0||!!D,U=null;D?U=D:w?U=n(a.HOME$LOADING):T&&(U=n(a.HOME$WORKSPACE_SCAN_ERROR));let W=!!D||e||w&&C.length===0;return(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[!t&&(0,X.jsxs)(`div`,{className:`flex items-center gap-[10px] pb-4`,children:[(0,X.jsx)(re,{width:24,height:24}),(0,X.jsx)(`span`,{className:`leading-5 font-bold text-base text-white`,children:n(a.HOME$WORKSPACES_TAB)})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] pb-4`,children:[(0,X.jsx)(Te,{workspaces:C,value:O,placeholder:D?n(a.HOME$WORKSPACES_UNSUPPORTED_PLACEHOLDER):W?n(a.HOME$LOADING):void 0,disabled:W,disabledTooltip:D,showManage:C.length>0||l.length>0,onChange:V,onAddClick:()=>j(!0),onManageClick:()=>P(!0),className:`max-w-auto`},O?.path??`empty-workspace-selection`),H&&U&&(0,X.jsx)(`p`,{className:`px-1 text-xs text-[var(--oh-text-secondary)]`,"data-testid":`workspace-status-message`,children:U})]}),(0,X.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,X.jsx)(p,{isOpen:A,onClose:()=>j(!1),onAdd:e=>h(e),onAddParent:e=>x(e)}),(0,X.jsx)(_,{isOpen:M,workspaces:C,workspaceParents:l,onClose:()=>P(!1),onRemove:e=>{O?.path===e&&V(null),y(e)},onRemoveParent:e=>{O?.parentPath===e&&V(null),S(e)}})]})}function Oe({isOpen:e,onClose:t,onConfirm:n}){let{t:r}=s(`openhands`),{isLoadingSettings:i}=z();return e?(0,X.jsx)(E,{onClose:t,children:(0,X.jsxs)(D,{width:`sm`,className:`relative items-start border border-[var(--oh-border)] !gap-4`,children:[(0,X.jsx)(W,{onClose:t,testId:`close-open-workspace-dialog`}),(0,X.jsx)(`div`,{className:`w-full pr-6`,children:(0,X.jsx)(O,{title:r(a.HOME$OPEN_WORKSPACE)})}),(0,X.jsx)(`div`,{className:`w-full`,"data-testid":`open-workspace-dialog-body`,children:(0,X.jsx)(De,{isLoadingSettings:i,onConfirm:e=>{n(e),t()}})})]})}):null}function ke({onRepoSelection:e,isLoadingSettings:t=!1,onConfirm:n}){let{navigate:r}=F(),[i,c]=J.useState(null),[l,u]=J.useState(null),[d,f]=J.useState(null),{providers:p}=z(),{addRecentRepository:m,setLastSelectedProvider:h,getLastSelectedProvider:g}=H(),{mutate:_,isPending:v,isSuccess:y}=G(),b=o(),{t:x}=s(`openhands`);J.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=J.useCallback(e=>{u(e)},[]);return(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[!n&&(0,X.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-[10px] pb-4`,children:[(0,X.jsx)(B,{width:24,height:24}),(0,X.jsx)(`span`,{className:`leading-5 font-bold text-base text-white`,children:x(a.COMMON$OPEN_REPOSITORY)})]})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] pb-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm text-white font-normal leading-[22px]`,children:x(a.HOME$SELECT_OR_INSERT_URL)}),p.length<=1?null:(0,X.jsx)(ce,{providers:p,value:d,placeholder:`Select Provider`,className:`max-w-[500px]`,onChange:C,disabled:t})]}),(0,X.jsx)(_e,{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,X.jsx)(fe,{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,X.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 Ae({isOpen:e,onClose:t,onConfirm:n}){let{t:r}=s(`openhands`),{isLoadingSettings:i}=z();return e?(0,X.jsx)(E,{onClose:t,children:(0,X.jsxs)(D,{width:`sm`,className:`relative items-start border border-[var(--oh-border)] !gap-4`,children:[(0,X.jsx)(W,{onClose:t,testId:`close-open-repository-dialog`}),(0,X.jsx)(`div`,{className:`w-full pr-6`,children:(0,X.jsx)(O,{title:r(a.COMMON$OPEN_REPOSITORY)})}),(0,X.jsx)(`div`,{className:`w-full`,"data-testid":`open-repository-dialog-body`,children:(0,X.jsx)(ke,{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,X.jsxs)(`div`,{className:`flex flex-row gap-2.5 items-center flex-wrap`,"data-testid":`home-git-control-bar-preview`,children:[(0,X.jsx)(me,{selectedRepository:t?.full_name??null,gitProvider:r??null,workspaceName:a,onClick:i}),n?(0,X.jsx)(ye,{selectedBranch:n.name,selectedRepository:t?.full_name??null,gitProvider:r??null}):null]})}function je(){let{t:e}=s(`openhands`),{backend:t}=T(),{navigate:n}=F(),r=t.kind===`local`,[i,c]=(0,J.useState)(!1),[l,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),{mutate:y,isPending:b}=G(),w=o(),E=b||w,{images:D,files:O,imagesMarkedUploadAsFile:k,clearAllFiles:A}=U(),{handleUpload:j}=ue(),{error:M}=v({enabled:r}),N=r?u(M,e):null,P=r?!!l:!!f&&!!m,I=de(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(ae)}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}se(e,{content:i,images:s.images,files:s.files,imagesMarkedUploadAsFile:[...k]}),A(),await Y({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 Y({conversationId:a,text:i,images:[],imagesMarkedUploadAsFile:[]}),n(`/conversations/${a}`)},onError:e=>{x.dismiss(u),S(e instanceof Error?e.message:null)}})});return(0,X.jsxs)(`div`,{"data-testid":`home-chat-launcher`,className:`flex w-full max-w-[800px] flex-col gap-4 md:px-4`,children:[(0,X.jsx)(`div`,{className:`flex w-full justify-center`,children:(0,X.jsx)(Ce,{})}),(0,X.jsx)(`div`,{className:`w-full`,children:(0,X.jsx)(ge,{onSubmit:I,onFilesPaste:j,disabled:E})}),(0,X.jsx)(`div`,{className:`flex justify-start`,children:P?(0,X.jsx)($,{workspace:l,repository:f,branch:m,provider:g,onRepoClick:()=>c(!0)}):(0,X.jsx)(we,{kind:r?`local`:`cloud`,onClick:()=>c(!0),disabled:E||!!N,disabledTooltip:N})}),r?(0,X.jsx)(Oe,{isOpen:i,onClose:()=>c(!1),onConfirm:e=>{d(e),p(null),h(null),_(null)}}):(0,X.jsx)(Ae,{isOpen:i,onClose:()=>c(!1),onConfirm:({repository:e,branch:t,provider:n})=>{p(e),h(t),_(n??e.git_provider),d(null)}})]})}function Me(){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=Se(`/settings/llm`,r?.feature_flags);return{isConfigured:l||u||d||f,isLoading:t||n&&!e||i||a&&!r||s||c&&!o}}function Ne(){let{t:e}=s(`openhands`),{navigate:t}=F(),{isConfigured:n,isLoading:r}=Me();return r||n?null:(0,X.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,X.jsxs)(`div`,{className:`flex items-center`,children:[(0,X.jsx)(`div`,{className:`flex-shrink-0`,children:(0,X.jsx)(ne,{className:`text-primary align-middle`})}),(0,X.jsx)(K.Text,{className:`ml-3 text-sm font-medium`,children:e(a.HOME$LLM_NOT_CONFIGURED_MESSAGE)})]}),(0,X.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 Pe(){let e=h(r().search);return(0,X.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,X.jsx)(Ne,{}),(0,X.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col items-center justify-center`,children:(0,X.jsx)(je,{})}),e?null:(0,X.jsx)(y,{})]})}var Fe=n(Pe);export{Fe as default};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./useMutation-7hG0GuPx.js";import{o as r,t as i}from"./declaration-IA661TBv.js";import{n as a}from"./QueryClientProvider-7oLZ1RtQ.js";import{t as o}from"./useTranslation-CbJtty1g.js";import{t as s}from"./retrieve-axios-error-message-DbnSBc_1.js";import{n as c,t as l}from"./vendor~root-layout~home~mcp~automations-list-DGOI7kQz.js";import{n as u,r as d}from"./custom-toast-handlers-fgD4IYsu.js";import{t as f}from"./utils-CVcuFUYj.js";import{c as p,n as m}from"./agent-server-client-options-Dvgeb3x4.js";import{t as h}from"./mcp-client-xEdbDxOL.js";import{a as g}from"./query-keys-CQaji0wJ.js";import{t as ee}from"./modal-backdrop-B1si6TUd.js";import{n as te}from"./modal-classes-9XTtWCtF.js";import{t as _}from"./brand-button-BoiPxAGm.js";import{t as v}from"./styled-tooltip-GXy1qxsO.js";import{t as y}from"./modal-close-button-DY-rVmld.js";import{t as b}from"./settings-input-DsoZj8Dm.js";import{t as x}from"./v4-BygpdDmc.js";import{t as S}from"./settings-service.api-4u2RKC8k.js";import{a as C,i as w,r as T}from"./use-settings-0qFqC-r6.js";import{t as E}from"./secrets-service-rJqZtDmI.js";function D(e){return[...e.sse_servers.map((e,t)=>({id:`sse-${t}`,type:`sse`,url:typeof e==`string`?e:e.url,api_key:typeof e==`object`?e.api_key:void 0})),...e.stdio_servers.map((e,t)=>({id:`stdio-${t}`,type:`stdio`,name:e.name,command:e.command,args:e.args,env:e.env})),...e.shttp_servers.map((e,t)=>({id:`shttp-${t}`,type:`shttp`,url:typeof e==`string`?e:e.url,api_key:typeof e==`object`?e.api_key:void 0,timeout:typeof e==`object`?e.timeout:void 0}))]}var O=e(t(),1),k=r();function A(e){return e.connectionOptions.filter(e=>e.provider===`mcp`&&!!e.transport)}function j(e){let t=A(e);return t.find(t=>t.id===e.defaultConnectionOptionId)??t[0]}function M(e){return e.auth.strategy!==`oauth2`}function N(e){let t=A(e),n=t.find(t=>t.id===e.defaultConnectionOptionId);return n&&M(n)?n:t.find(M)}function P(e){return j(e)?.transport}var F=`https://mcp.linear.app/sse`,ne=`https://mcp.linear.app/mcp`,re=`https://linear.app/docs/mcp`;function ie(e){return e.id===`linear`?{...e,docsUrl:re,installHint:`Authenticate with a Linear API key (Linear → Settings → Security & access) — sent as a Bearer token. Optional when the endpoint accepts your OAuth session.`,connectionOptions:e.connectionOptions.map(e=>e.transport?.kind===`sse`&&L(e.transport.url,F)?{...e,auth:{...e.auth,strategy:`bearer`},transport:{kind:`shttp`,url:ne,apiKeyOptional:e.transport.apiKeyOptional}}:e)}:e}function ae(e){return e.map(ie).filter(e=>!!j(e))}var I=e=>{try{return new URL(e)}catch{return null}};function L(e,t){let n=typeof e==`string`?e:``,r=typeof t==`string`?t:``;if(!n||!r)return!1;let i=I(n),a=I(r);return!i||!a?n.replace(/\/+$/,``)===r.replace(/\/+$/,``):i.protocol===a.protocol&&i.host===a.host&&i.pathname.replace(/\/+$/,``)===a.pathname.replace(/\/+$/,``)}function oe(e,t){return t.find(t=>z(e,t))??null}function R(e,t){for(let n of A(e)){let e=oe(n.transport,t);if(e)return e}return null}function z(e,t){if(e.kind===`shttp`){let n=e.url;return t.type===`shttp`&&!!t.url&&L(t.url,n)}if(e.kind===`sse`){let n=e.url;return t.type===`sse`&&!!t.url&&L(t.url,n)}return t.type===`stdio`&&t.name===e.serverName}function B(e,t){return!e.runtimeAvailability||e.runtimeAvailability===`all`?!0:e.runtimeAvailability===t}function V(e){return e.trim().toLowerCase()}function H(e){return e.map((e,t)=>({entry:e,index:t})).sort((e,t)=>(t.entry.popularityRank??0)-(e.entry.popularityRank??0)||e.index-t.index).map(({entry:e})=>e)}function U(e,t){return t.find(t=>t.id===e)}function W(e,t){let n=V(t);return n?[e.name,e.description,e.id,...e.keywords??[]].join(` `).toLowerCase().includes(n):!0}function G(e,t,n){let r=V(n);return r?[e.type,`name`in e?e.name:void 0,`command`in e?e.command:void 0,`args`in e?e.args?.join(` `):void 0,`url`in e?e.url:void 0,t?.name,t?.description,t?.id,...t?.keywords??[]].filter(Boolean).join(` `).toLowerCase().includes(r):!0}function K(e,t){return t.find(t=>A(t).some(t=>z(t.transport,e)))}function se({fieldKey:e,checked:t,onToggle:n}){let{t:r}=o(`openhands`);return(0,k.jsxs)(`label`,{"data-testid":`mcp-install-save-secret-${e}`,className:f(`flex items-center gap-2 px-3 py-2 mt-0.5 rounded-lg border cursor-pointer transition-colors`,t?`border-green-500/35 bg-green-500/10`:`border-[var(--oh-border)] bg-transparent hover:bg-white/[0.03]`),children:[(0,k.jsx)(`input`,{className:`sr-only`,id:`mcp-save-secret-checkbox-${e}`,type:`checkbox`,checked:t,onChange:e=>n(e.target.checked)}),(0,k.jsx)(`span`,{"aria-hidden":`true`,className:f(`relative inline-flex h-[22px] w-[40px] shrink-0 items-center rounded-full border transition-colors duration-200`,t?`border-green-500 bg-green-500`:`border-[var(--oh-border)] bg-surface-raised`),children:(0,k.jsx)(`span`,{className:f(`inline-block size-4 rounded-full transition-transform duration-200`,t?`translate-x-[21px] bg-white`:`translate-x-[2px] bg-[var(--oh-muted)]`)})}),(0,k.jsx)(`span`,{className:`text-sm`,children:r(i.MCP$ALSO_SAVE_AS_SECRET)}),(0,k.jsx)(`code`,{className:f(`ml-auto text-[11px] font-mono tracking-tight border rounded px-1.5 py-0.5`,t?`text-green-500 border-green-500/35 bg-white/[0.04]`:`text-tertiary-alt border-[var(--oh-border)]`),children:e}),(0,k.jsx)(v,{content:r(i.MCP$SAVE_AS_SECRET_TOOLTIP),placement:`top`,children:(0,k.jsx)(`button`,{type:`button`,"aria-label":r(i.MCP$SAVE_AS_SECRET_TOOLTIP),className:`flex items-center justify-center size-[15px] shrink-0 rounded-full border border-[var(--oh-muted)] text-tertiary-alt text-[9px] font-bold cursor-help`,onClick:e=>e.preventDefault(),children:`?`})})]})}var ce={xs:`h-4 w-4 rounded [&>svg]:h-2.5 [&>svg]:w-2.5`,sm:`h-5 w-5 rounded-md [&>svg]:h-3 [&>svg]:w-3`,md:`h-10 w-10 rounded-lg [&>svg]:h-5 [&>svg]:w-5`};function q({entry:e,size:t=`md`,className:n,fallback:r,testId:i}){return(0,k.jsx)(`span`,{"aria-hidden":`true`,title:e?.name,"data-testid":i,className:f(`inline-flex shrink-0 items-center justify-center overflow-hidden`,`border border-white/10 shadow-[inset_0_1px_0_rgba(255,255,255,0.18)]`,ce[t],n),style:{backgroundColor:e?.iconBg??`var(--oh-color-tertiary)`,color:e?.iconColor??`#FFFFFF`},children:e?c[e.id]??r??l:r??l})}function J(){let e=a(),{data:t}=T();return n({mutationFn:async e=>{if(!t)return;let n=w(t.agent_settings?.mcp_config),r={sse_servers:[...n.sse_servers],stdio_servers:[...n.stdio_servers],shttp_servers:[...n.shttp_servers]};if(e.type===`sse`){let t={url:e.url,...e.api_key&&{api_key:e.api_key}};r.sse_servers.push(t)}else if(e.type===`stdio`){let t={name:e.name,command:e.command,...e.args&&{args:e.args},...e.env&&{env:e.env}};r.stdio_servers.push(t)}else if(e.type===`shttp`){let t={url:e.url,...e.api_key&&{api_key:e.api_key},...e.timeout!==void 0&&{timeout:e.timeout}};r.shttp_servers.push(t)}await S.saveSettings({agent_settings_diff:{mcp_config:C(r)}})},onSuccess:()=>{e.invalidateQueries({queryKey:g.personal()})}})}function le(e){return e.type===`stdio`?{type:`stdio`,command:e.command,...e.args?.length&&{args:e.args},...e.env&&Object.keys(e.env).length>0&&{env:e.env}}:{type:e.type,url:e.url,...e.api_key?{api_key:e.api_key}:{}}}var ue=class{static async testServer(e){if(p().backend.kind===`cloud`)return{ok:!0,tools:[]};let{host:t,apiKey:n}=m(),r=new h({host:t,...n?{apiKey:n}:{}});try{return await r.testServer({server:le(e),...e.name?{name:e.name}:{},...e.timeout?{timeout:e.timeout}:{}})}finally{r.close()}}};function Y(){return n({mutationFn:e=>ue.testServer(e)})}function X(e){return e.length<=3?e.join(`, `):`${e.slice(0,3).join(`, `)} … (+${e.length-3})`}function de(){let{t:e}=o(`openhands`),t=a();return(0,O.useCallback)((n,r,a)=>{let o=n.filter(e=>a[e.key]&&(r[e.key]??``).trim());o.length!==0&&Promise.allSettled(o.map(e=>E.createSecret(e.key,r[e.key].trim(),e.label))).then(n=>{let r=o.filter((e,t)=>n[t].status===`fulfilled`).map(e=>e.key),a=o.filter((e,t)=>n[t].status===`rejected`).map(e=>e.key);r.length>0&&(t.invalidateQueries({queryKey:[`secrets-search`]}),t.invalidateQueries({queryKey:[`secrets`]}),d(e(i.MCP$SECRETS_SAVED,{keys:X(r)}))),a.length>0&&u(e(i.MCP$SECRETS_SAVE_FAILED,{keys:X(a)}))})},[e,t])}function Z(e){let t=/\[([^\]]+)\]\(([^)]+)\)/g,n=[],r=0;for(let i of e.matchAll(t))i.index>r&&n.push(e.slice(r,i.index)),n.push((0,k.jsx)(`a`,{href:/^https?:\/\//i.test(i[2])?i[2]:`#`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-white transition-colors`,children:i[1]},i.index)),r=i.index+i[0].length;return r<e.length&&n.push(e.slice(r)),n}function Q(e){return e?.transport.kind!==`shttp`&&e?.transport.kind!==`sse`?!1:[`api_key`,`bearer`,`basic`].includes(e.auth.strategy)}function $(e){return e.transport.kind===`stdio`?e.auth.apiKeyOptional??!1:e.auth.apiKeyOptional??e.transport.apiKeyOptional??!1}function fe(e){let t={},n={},r=N(e),i=r?.transport;if(i?.kind===`stdio`){for(let e of i.envFields??[])t[e.key]=``,n[e.key]=e.type===`password`;for(let e of i.argFields??[])t[e.key]=``}else Q(r)&&(t.api_key=``);return{values:t,errors:{},savedAsSecret:n}}function pe({entry:e,onClose:t,onSuccess:n}){let{t:r}=o(`openhands`),{mutate:a,isPending:c}=J(),{mutate:l,isPending:u}=Y(),f=de(),[p,m]=O.useState(()=>fe(e)),h=O.useRef(p);h.current=p;let[g,v]=O.useState(null),S=N(e),C=S?.transport,w=u||c,T=(e,t)=>{m(n=>({...n,values:{...n.values,[e]:t},errors:{...n.errors,[e]:null}})),v(null)},E=(e,t)=>{m(n=>({...n,savedAsSecret:{...n.savedAsSecret,[e]:t}}))},D=e=>{switch(e.error_kind){case`timeout`:return r(i.MCP$TEST_ERROR_TIMEOUT);case`connection`:return r(i.MCP$TEST_ERROR_CONNECTION);default:return r(i.MCP$TEST_ERROR_UNKNOWN,{error:e.error})}},A=o=>{l(o,{onSuccess:c=>{if(!c.ok){v(D(c));return}a(o,{onSuccess:()=>{d(r(i.MCP$INSTALL_SUCCESS)),n?.(e),t(),C?.kind===`stdio`&&f(C.envFields??[],h.current.values,h.current.savedAsSecret)},onError:e=>{v(s(e)||r(i.ERROR$GENERIC))}})},onError:e=>{v(s(e)||r(i.ERROR$GENERIC))}})},j=()=>{if(C?.kind!==`shttp`&&C?.kind!==`sse`||!S)return;let e=p.values.api_key?.trim()??``,t=Q(S);if(t&&!$(S)&&!e){m(e=>({...e,errors:{api_key:r(i.MCP$ERROR_FIELD_REQUIRED)}}));return}A({id:`${C.kind}-${x()}`,type:C.kind,url:C.url,...t&&e&&{api_key:e}})},M=()=>{if(C?.kind!==`stdio`)return;let e=C,t={};for(let n of e.envFields??[])n.required&&!(p.values[n.key]??``).trim()&&(t[n.key]=r(i.MCP$ERROR_FIELD_REQUIRED));for(let n of e.argFields??[])n.required&&!(p.values[n.key]??``).trim()&&(t[n.key]=r(i.MCP$ERROR_FIELD_REQUIRED));if(Object.values(t).some(Boolean)){m(e=>({...e,errors:t}));return}let n={};for(let t of e.envFields??[]){let e=p.values[t.key]?.trim();e&&(n[t.key]=e)}let a=[];for(let t of e.argFields??[]){let e=p.values[t.key]?.trim();if(e)for(let t of e.split(/\s+/))t&&a.push(t)}A({id:`stdio-${x()}`,type:`stdio`,name:e.serverName,command:e.command,args:[...e.args,...a],...Object.keys(n).length>0&&{env:n}})};return(0,k.jsx)(ee,{onClose:t,"aria-label":e.name,children:(0,k.jsxs)(`form`,{"data-testid":`mcp-install-modal`,"data-marketplace-id":e.id,onSubmit:e=>(e.preventDefault(),v(null),C?.kind===`shttp`||C?.kind===`sse`?j():M()),className:`relative bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)] w-[520px] max-w-[90vw] max-h-[85vh] overflow-y-auto custom-scrollbar`,children:[(0,k.jsx)(y,{onClose:t,testId:`mcp-install-modal-close`,disabled:w}),(0,k.jsxs)(`div`,{className:`flex items-start gap-3 pr-6`,children:[(0,k.jsx)(q,{entry:e}),(0,k.jsxs)(`div`,{className:`flex flex-col flex-1`,children:[(0,k.jsx)(`h2`,{className:te,children:e.name}),(0,k.jsx)(`p`,{className:`text-xs text-tertiary-light`,children:e.description})]})]}),e.installHint&&(0,k.jsx)(`p`,{className:`text-xs text-tertiary-light`,children:e.installHint}),e.docsUrl&&(0,k.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-xs text-[var(--oh-muted)] hover:text-white hover:underline self-start transition-colors`,children:r(i.MCP$VIEW_DOCS)}),(0,k.jsx)(`div`,{className:`flex flex-col gap-3`,children:(()=>{if(C?.kind===`shttp`||C?.kind===`sse`){let e=Q(S),t=S?$(S):!1;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(b,{testId:`mcp-install-field-url`,name:`url`,type:`url`,label:r(i.SETTINGS$MCP_URL),value:C.url,onChange:()=>{},isDisabled:!0,className:`w-full`}),e?(0,k.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(b,{testId:`mcp-install-field-api_key`,name:`api_key`,type:`password`,label:r(i.SETTINGS$MCP_API_KEY),value:p.values.api_key??``,onChange:e=>T(`api_key`,e),placeholder:r(i.SETTINGS$MCP_API_KEY_PLACEHOLDER),showOptionalTag:t,required:!t,className:`w-full`}),p.errors.api_key&&(0,k.jsx)(`p`,{className:`text-xs text-red-500`,children:p.errors.api_key})]}):null]})}if(C?.kind!==`stdio`)return null;let e=C;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(b,{testId:`mcp-install-field-command-readonly`,name:`command-readonly`,type:`text`,label:r(i.MCP$COMMAND_LABEL),value:`${e.command} ${e.args.join(` `)}`.trim(),onChange:()=>{},isDisabled:!0,className:`w-full`}),(e.envFields??[]).map(e=>(0,k.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(b,{testId:`mcp-install-field-${e.key}`,name:e.key,type:e.type===`password`?`password`:`text`,label:e.label,value:p.values[e.key]??``,onChange:t=>T(e.key,t),placeholder:e.placeholder,required:e.required,showOptionalTag:!e.required,className:`w-full`}),e.helperText&&(0,k.jsx)(`p`,{className:`text-xs text-tertiary-alt`,children:Z(e.helperText)}),p.errors[e.key]&&(0,k.jsx)(`p`,{className:`text-xs text-red-500`,children:p.errors[e.key]}),e.key in p.savedAsSecret&&(0,k.jsx)(se,{fieldKey:e.key,checked:p.savedAsSecret[e.key],onToggle:t=>E(e.key,t)})]},e.key)),(e.argFields??[]).map(e=>(0,k.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(b,{testId:`mcp-install-field-${e.key}`,name:e.key,type:e.type===`password`?`password`:`text`,label:e.label,value:p.values[e.key]??``,onChange:t=>T(e.key,t),placeholder:e.placeholder,required:e.required,showOptionalTag:!e.required,className:`w-full`}),e.helperText&&(0,k.jsx)(`p`,{className:`text-xs text-tertiary-alt`,children:Z(e.helperText)}),p.errors[e.key]&&(0,k.jsx)(`p`,{className:`text-xs text-red-500`,children:p.errors[e.key]})]},e.key))]})})()}),g&&(0,k.jsx)(`p`,{"data-testid":`mcp-install-modal-error`,className:`text-sm text-red-500 whitespace-pre-wrap`,children:g}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2`,children:[(0,k.jsx)(_,{type:`button`,variant:`secondary`,onClick:t,testId:`mcp-install-cancel`,children:r(i.BUTTON$CANCEL)}),(0,k.jsx)(_,{type:`submit`,variant:`primary`,isDisabled:w,testId:`mcp-install-submit`,children:r(u?i.MCP$VERIFYING:c?i.SETTINGS$SAVING:i.MCP$INSTALL_BUTTON)})]})]})})}export{K as a,H as c,G as d,B as f,q as i,U as l,D as m,Y as n,R as o,W as p,J as r,P as s,pe as t,ae as u};