@openhands/agent-canvas 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.windows.md +2 -2
- package/build/assets/{Trans-DY6toRDu.js → Trans-Ch-OVWEA.js} +1 -1
- package/build/assets/{acp-providers-Djl6vNn-.js → acp-providers-Sy2LKyMa.js} +1 -1
- package/build/assets/{active-backend-context-B3umL5R-.js → active-backend-context-hxq31W25.js} +1 -1
- package/build/assets/{add-backend-modal-DljoP9lc.js → add-backend-modal-Bgy8anoR.js} +1 -1
- package/build/assets/{agent-profiles-settings-BJMmTZgv.js → agent-profiles-settings-3mmXljZX.js} +1 -1
- package/build/assets/{agent-server-conversation-service.api-D_ZvtJjG.js → agent-server-conversation-service.api-CuSdr4Qb.js} +3 -3
- package/build/assets/{agent-settings-lUknCeaF.js → agent-settings-B-W10B4E.js} +1 -1
- package/build/assets/agent-settings-D_yOy8XB.js +1 -0
- package/build/assets/{api-key-entry-screen-CWEHcPJA.js → api-key-entry-screen-Dl0qVYi4.js} +1 -1
- package/build/assets/{app-settings-Dj90qosy.js → app-settings-yVizGXox.js} +1 -1
- package/build/assets/{automation-detail-CXJU0_gF.js → automation-detail-dvJfLs5u.js} +1 -1
- package/build/assets/{automation-export-FWY9LPsG.js → automation-export-BPcgLqPD.js} +1 -1
- package/build/assets/{automations-list-DDGBkWLC.js → automations-list-CUXogTe0.js} +1 -1
- package/build/assets/backend-form-modal-CQJGmItq.js +1 -0
- package/build/assets/{backend-synced-settings-badge-CanzmG12.js → backend-synced-settings-badge-D9hZx05w.js} +1 -1
- package/build/assets/{condenser-settings-30cX9SK6.js → condenser-settings-Ca8fYZ_Z.js} +1 -1
- package/build/assets/conversation-9NBSRoR9.js +1 -0
- package/build/assets/{conversation-BltULtFA.js → conversation-BXg6Oti2.js} +3 -3
- package/build/assets/conversation-panel-CZri9Rup.js +1 -0
- package/build/assets/{conversation-service.api-DQaKzIRj.js → conversation-service.api-DPBQvTKD.js} +1 -1
- package/build/assets/{device-verify-BsznkV-a.js → device-verify-Dj6I4Iqe.js} +1 -1
- package/build/assets/{entry.client-JixNvFrr.js → entry.client-2_3ePAm0.js} +1 -1
- package/build/assets/{extensions-hub-DfvgqzTc.js → extensions-hub-CLjmOGqS.js} +1 -1
- package/build/assets/{extensions-navigation-D9i0DL62.js → extensions-navigation-B5MeUiMq.js} +1 -1
- package/build/assets/{files-tab-DDtEJcGE.js → files-tab-UVoray88.js} +1 -1
- package/build/assets/{git-provider-icon-BjkecAuV.js → git-provider-icon-o6hdnJUB.js} +1 -1
- package/build/assets/{home-BCKWpKpf.js → home-D1IHvGTN.js} +1 -1
- package/build/assets/{install-server-modal-BIugLhVB.js → install-server-modal-BbuQaA2w.js} +1 -1
- package/build/assets/{launch-BgIlZLSX.js → launch-V_3Rp7WS.js} +1 -1
- package/build/assets/{lesson-plan-DgpP80mJ.js → lesson-plan-jC0HBoe6.js} +1 -1
- package/build/assets/{llm-not-configured-banner-BlX8NifC.js → llm-not-configured-banner-DoARbcdL.js} +1 -1
- package/build/assets/{llm-settings-kU5v0H1Z.js → llm-settings-4JMLV8mq.js} +1 -1
- package/build/assets/llm-settings-D91gMw3U.js +1 -0
- package/build/assets/{manage-backends-modal-C8FJQIZR.js → manage-backends-modal-DkWAMSle.js} +1 -1
- package/build/assets/{manifest-56d40d7c.js → manifest-aa5c29f6.js} +1 -1
- package/build/assets/{mcp-CHkklDMv.js → mcp-BQufNPZ6.js} +1 -1
- package/build/assets/{messages-B3RugH7P.js → messages-BnJCqnFf.js} +1 -1
- package/build/assets/{model-selector-BOj1wBlq.js → model-selector-BfqpMkSJ.js} +1 -1
- package/build/assets/{onboarding-DYhDxmI9.js → onboarding-Bu-HN1ze.js} +1 -1
- package/build/assets/{onboarding-modal-CP_WxDC9.js → onboarding-modal-CZgjs5Bx.js} +1 -1
- package/build/assets/{option-service.api-C0tYT4-r.js → option-service.api-BrZ5q87N.js} +1 -1
- package/build/assets/{organization-service.api-CnynNoT-.js → organization-service.api-Bk4pCGU1.js} +1 -1
- package/build/assets/{path-utils-DWcgCGen.js → path-utils-CSmuZoix.js} +1 -1
- package/build/assets/{planner-tab-CCqdXxkL.js → planner-tab-Dhyqcqmb.js} +1 -1
- package/build/assets/{plugins-management-service-BAp70KN7.js → plugins-management-service-BRBLxvUl.js} +1 -1
- package/build/assets/{profiles-service.api-CeYEmSM3.js → profiles-service.api-BMXQ9pZC.js} +1 -1
- package/build/assets/{providers-BxCuC9bZ.js → providers-BpO967xS.js} +1 -1
- package/build/assets/{proxy-CHmFkV16.js → proxy-BgJLtxu7.js} +1 -1
- package/build/assets/{recommended-automations-launcher-CVEF_1pc.js → recommended-automations-launcher-CTcGTl4d.js} +1 -1
- package/build/assets/root-BM5WgQ4_.js +2 -0
- package/build/assets/{root-layout-CttG_lQi.js → root-layout-BdoyoobY.js} +2 -2
- package/build/assets/{schema-field-xUr6rDd6.js → schema-field-BSHrUMme.js} +1 -1
- package/build/assets/{sdk-section-page-CbLrVUa3.js → sdk-section-page-t82gsOqa.js} +1 -1
- package/build/assets/{secrets-service-CZYjNxFw.js → secrets-service-B2GqPV0N.js} +1 -1
- package/build/assets/{secrets-settings-DxTx9HgU.js → secrets-settings-Cx6yJlyb.js} +1 -1
- package/build/assets/{settings-DnlfS09K.js → settings-DmPLkgq0.js} +1 -1
- package/build/assets/{settings-index-BjeuYFFa.js → settings-index-D6sxWSRk.js} +1 -1
- package/build/assets/{settings-modal-DfTcL-mV.js → settings-modal-CwrZKrTq.js} +1 -1
- package/build/assets/{settings-service.api-K4ncGlBv.js → settings-service.api-Ce-ub11I.js} +1 -1
- package/build/assets/{shared-conversation-DWtBkJv7.js → shared-conversation-BDREQPnE.js} +1 -1
- package/build/assets/{sidebar-mobile-menu-toggle-CMmAYkh8.js → sidebar-mobile-menu-toggle-VvvX32iF.js} +1 -1
- package/build/assets/{skills-plugins-BJ040luO.js → skills-plugins-2Y44YHbO.js} +1 -1
- package/build/assets/{skills-settings-BYn4-AQQ.js → skills-settings-BUv04tSc.js} +1 -1
- package/build/assets/{suspense-X5dBsJzn.js → suspense-BO1Tl_Vf.js} +1 -1
- package/build/assets/{terminal-BsGcSpRS.js → terminal-B61WrJdS.js} +1 -1
- package/build/assets/{use-acp-credential-form-EtnbtYt0.js → use-acp-credential-form-MzZM6D7D.js} +1 -1
- package/build/assets/{use-activate-agent-profile-WaAZYz4E.js → use-activate-agent-profile-20v1xU0H.js} +1 -1
- package/build/assets/{use-active-agent-profile-CYY3vGar.js → use-active-agent-profile-BkJN7Xsy.js} +1 -1
- package/build/assets/{use-active-conversation-D-r929nx.js → use-active-conversation-DOZVSVtU.js} +1 -1
- package/build/assets/{use-agent-profiles-DEAMFp-W.js → use-agent-profiles-DwZxnwO5.js} +1 -1
- package/build/assets/{use-agent-state-DijdVAQ0.js → use-agent-state-DHZO1obC.js} +1 -1
- package/build/assets/{use-backends-health-DkC7tKkC.js → use-backends-health-CRHzuvxO.js} +1 -1
- package/build/assets/{use-can-manage-org-profiles-BEo0peGn.js → use-can-manage-org-profiles-C-OhWVBS.js} +1 -1
- package/build/assets/{use-cloud-current-user-id-Dm99wXp2.js → use-cloud-current-user-id-utFreJ0i.js} +1 -1
- package/build/assets/use-config-mJrtZHP1.js +1 -0
- package/build/assets/{use-create-conversation-CTsvZ96U.js → use-create-conversation-DdqsP78F.js} +1 -1
- package/build/assets/{use-create-secret-D5O5qdWC.js → use-create-secret-D0HCOZFu.js} +1 -1
- package/build/assets/{use-handle-plan-click-Mn_SNTCh.js → use-handle-plan-click-DyRASKMC.js} +1 -1
- package/build/assets/use-is-authed-B6M0mcGL.js +1 -0
- package/build/assets/use-llm-profiles-RC-PkpBl.js +1 -0
- package/build/assets/{use-plugins-marketplace-BGb-KgfD.js → use-plugins-marketplace-FHlbeQ4c.js} +1 -1
- package/build/assets/use-runtime-is-ready-RKj2WmEh.js +1 -0
- package/build/assets/use-save-agent-profile-tvDP15mh.js +1 -0
- package/build/assets/{use-save-settings-D1HoCDbn.js → use-save-settings-BGlSfuYn.js} +1 -1
- package/build/assets/{use-settings-BReAMxCG.js → use-settings-CH5LzXD8.js} +1 -1
- package/build/assets/{use-settings-nav-items-xe1YgLnE.js → use-settings-nav-items-Dwktv8wo.js} +1 -1
- package/build/assets/{use-skills-Dqo-pDDx.js → use-skills-CSzSL6HG.js} +1 -1
- package/build/assets/{use-tracking-2ZwQwpg_.js → use-tracking-BIXzagSI.js} +1 -1
- package/build/assets/{use-user-conversation-OAfenBRG.js → use-user-conversation-zpx7I18x.js} +1 -1
- package/build/assets/{useMutation-DCE9RcgK.js → useMutation-DrCAVg5w.js} +1 -1
- package/build/assets/{useMutationState-BUab8Kxr.js → useMutationState-D8QN0ZCy.js} +1 -1
- package/build/assets/{useQueries-CRzaAqzH.js → useQueries-DClgUTc7.js} +1 -1
- package/build/assets/{useQuery-CpjHYtZc.js → useQuery-CRBP8vIS.js} +1 -1
- package/build/assets/{vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~d1e18dtv-5Q6lQJdE.js → vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~nfpll1wp-BCpa95De.js} +1 -1
- package/build/assets/{vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~nn5zty47-Zl0G1QCy.js → vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~jewnulst-C57fm7C-.js} +1 -1
- package/build/assets/{vendor~root-layout~home~conversation-panel~conversation~launch~settings~settings-index~agen~enjl5xdm-mMKDm94D.js → vendor~root-layout~home~conversation-panel~conversation~launch~settings~settings-index~agen~enjl5xdm-B0EIDu4M.js} +1 -1
- package/build/assets/{verification-settings-DnXS6VWv.js → verification-settings-D576N2xa.js} +1 -1
- package/build/index.html +4 -4
- package/build/locales/en/openhands.json +1 -1
- package/config/defaults.json +1 -1
- package/dist/components/features/backends/backend-form-modal.cjs +1 -1
- package/dist/components/features/backends/backend-form-modal.cjs.map +1 -1
- package/dist/components/features/backends/backend-form-modal.d.ts +3 -1
- package/dist/components/features/backends/backend-form-modal.js +17 -16
- package/dist/components/features/backends/backend-form-modal.js.map +1 -1
- package/dist/config/defaults.cjs +1 -1
- package/dist/config/defaults.cjs.map +1 -1
- package/dist/config/defaults.js +1 -1
- package/dist/config/defaults.js.map +1 -1
- package/dist/i18n/translation.cjs +1 -1
- package/dist/i18n/translation.cjs.map +1 -1
- package/dist/i18n/translation.js +1 -1
- package/dist/i18n/translation.js.map +1 -1
- package/dist/locales/en/openhands.json +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +1 -1
- package/build/assets/agent-settings-BVVFzBWS.js +0 -1
- package/build/assets/backend-form-modal-DSbrafX2.js +0 -1
- package/build/assets/conversation-e0a0_X4S.js +0 -1
- package/build/assets/conversation-panel-Cr9_ZGI-.js +0 -1
- package/build/assets/llm-settings-DJmbryaE.js +0 -1
- package/build/assets/root-uJ2t9rCQ.js +0 -2
- package/build/assets/use-config-CHzNIHpv.js +0 -1
- package/build/assets/use-is-authed-_dhQ2Xuj.js +0 -1
- package/build/assets/use-llm-profiles-BMhPDlwQ.js +0 -1
- package/build/assets/use-runtime-is-ready-CC-KrLKe.js +0 -1
- package/build/assets/use-save-agent-profile-CLMmbx_X.js +0 -1
- /package/build/assets/{vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~i3v2mlbw-BrJQ3XZH.js → vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~epa72zsm-B4rXs7Zd.js} +0 -0
- /package/build/assets/{vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~ncdxw0bh-ClHnt5lR.js → vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~lf310vj7-CSVPGId3.js} +0 -0
- /package/build/assets/{vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~k6tszsdc-Bb-xMtbv.js → vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~ivvrgjsa-BlIZPCXX.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{Ct as t,bt as n,xt as r}from"./vendor-styling-CI0PQ3ab.js";import{n as i}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~i3v2mlbw-BrJQ3XZH.js";import{t as a}from"./useMutation-DCE9RcgK.js";import{t as o}from"./useQuery-CpjHYtZc.js";import{t as s}from"./useTranslation-CDRCKC9-.js";import{t as c}from"./declaration-gq8V5eTU.js";import{b as l,y as u}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~ncdxw0bh-ClHnt5lR.js";import{A as d,j as ee,n as f}from"./active-backend-context-B3umL5R-.js";import{t as p}from"./utils-D3U3rlqr.js";import{c as m,t as h,u as g}from"./agent-server-client-options-DVLRd9sw.js";import{t as _}from"./proxy-CHmFkV16.js";import{r as v}from"./modal-classes-Cf-4tbHz.js";import{f as te,l as ne}from"./form-control-classes-ChpNBe9n.js";import{t as y}from"./brand-button-vMVuyDXu.js";import{r as b,u as x}from"./dropdown-classes-DJSXeLqc.js";import{t as re}from"./settings-input-bD6npsDm.js";import{t as S}from"./use-tracking-2ZwQwpg_.js";import{t as ie}from"./use-llm-profiles-BMhPDlwQ.js";import{n as C,t as ae}from"./context-menu-list-item-BD5_EaKN.js";import{t as w}from"./settings-dropdown-input-BjunGXJb.js";import{t as T}from"./x-mark-Batp6gXa.js";import{t as E}from"./automation-BU8zu-FP.js";var D=`/api/automation`,O=l.create();O.interceptors.request.use(e=>{if(e.baseURL)return e;let t=g();if(!t)throw new h;e.baseURL=t.host;let n=t.apiKey?.trim();return n&&e.headers.set(`X-Session-API-Key`,n),e});function k(e,t){let n=new URLSearchParams;return n.set(`limit`,String(e)),n.set(`offset`,String(t)),n.toString()}function oe(e){return e.trigger.type===`event`?{type:`event`,source:e.trigger.source,on:e.trigger.on,...e.trigger.filter&&{filter:e.trigger.filter}}:{type:`cron`,schedule:e.trigger.schedule,timezone:e.timezone??e.trigger.timezone??`UTC`}}function se(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`pending.${crypto.randomUUID()}`:`pending.${Date.now()}.${Math.random().toString(36).slice(2,10)}`}function ce(e){if(!e.prompt)throw Error(`An automation prompt is required for import.`);let t=e.repository?[{url:e.repository,...e.branch&&{ref:e.branch},...!e.repository.includes(`://`)&&!e.repository.startsWith(`git@`)&&{provider:`github`}}]:void 0;return{path:`${D}/v1/preset/${e.plugins?.length?`plugin`:`prompt`}`,body:{name:e.name,prompt:e.prompt,trigger:{type:`event`,source:`agent-canvas-import`,on:se()},...e.model&&{model:e.model},...t&&{repos:t},...e.plugins?.length&&{plugins:e.plugins.map(e=>({source:e}))}}}}function A(e){let t=e.apiKey.trim();return{baseURL:e.host,...t&&{headers:{"X-Session-API-Key":t}}}}function j(e){return e.orgId?{"X-Org-Id":e.orgId}:void 0}var M=class e{static async listAutomations(e={}){let{limit:t=50,offset:n=0}=e,r=m().backend;if(r.kind===`cloud`)return _({backend:r,method:`GET`,path:`${D}/v1?${k(t,n)}`});let{data:i}=await O.get(`${D}/v1`,{params:{limit:t,offset:n}});return i}static async getAutomations(t=50,n=0){return e.listAutomations({limit:t,offset:n})}static async getAutomation(e){let t=m().backend,n=`${D}/v1/${encodeURIComponent(e)}`;if(t.kind===`cloud`)return _({backend:t,method:`GET`,path:n});let{data:r}=await O.get(n);return r}static async createAutomation(e){let t=m(),{path:n,body:r}=ce(e),i;if(t.backend.kind===`cloud`)i=await _({backend:t.backend,method:`POST`,path:n,body:r,headers:j(t)});else{let{data:e}=await O.post(n,r,A(t.backend));i=e}let a=`${D}/v1/${encodeURIComponent(i.id)}`,o={trigger:oe(e),enabled:!1};try{if(t.backend.kind===`cloud`)return await _({backend:t.backend,method:`PATCH`,path:a,body:o,headers:j(t)});let{data:e}=await O.patch(a,o,A(t.backend));return e}catch(e){try{t.backend.kind===`cloud`?await _({backend:t.backend,method:`DELETE`,path:a,headers:j(t)}):await O.delete(a,A(t.backend))}catch(t){throw AggregateError([e,t],`Failed to disable the imported automation and clean it up.`)}throw e}}static async updateAutomation(e,t){let n=m().backend,r=`${D}/v1/${encodeURIComponent(e)}`;if(n.kind===`cloud`)return _({backend:n,method:`PATCH`,path:r,body:t});let{data:i}=await O.patch(r,t);return i}static async deleteAutomation(e){let t=m().backend,n=`${D}/v1/${encodeURIComponent(e)}`;if(t.kind===`cloud`){await _({backend:t,method:`DELETE`,path:n});return}await O.delete(n)}static async dispatchAutomation(e){let t=m().backend,n=`${D}/v1/${encodeURIComponent(e)}/dispatch`;if(t.kind===`cloud`)return _({backend:t,method:`POST`,path:n});let{data:r}=await O.post(n);return r}static async listAutomationRuns(e,t={}){let{limit:n=50,offset:r=0}=t,i=m().backend,a=`${D}/v1/${encodeURIComponent(e)}/runs`;if(i.kind===`cloud`)return _({backend:i,method:`GET`,path:`${a}?${k(n,r)}`});let{data:o}=await O.get(a,{params:{limit:n,offset:r}});return o}static async getAutomationRuns(t,n=50,r=0){return e.listAutomationRuns(t,{limit:n,offset:r})}static async toggleAutomation(t,n){return e.updateAutomation(t,{enabled:n})}static async downloadTarball(e,t){let n=m().backend,r=`${D}/v1/${encodeURIComponent(e)}/tarball`,i;if(n.kind===`cloud`)i=await _({backend:n,method:`GET`,path:r,responseType:`blob`});else{let{data:e}=await O.get(r,{responseType:`blob`});i=e}let a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`${t}.tar`,o.click(),URL.revokeObjectURL(a)}static async checkHealth(){let e=m().backend,t=`${D}/health`;try{if(e.kind===`cloud`)return await _({backend:e,method:`GET`,path:t,timeoutSeconds:5});let{data:n}=await O.get(t,{timeout:5e3});return n}catch{return{status:`error`}}}},N=e(t()),le=e(r(),1),P=n(),F=[`automation-detail`],I=[`automation-runs`];function ue(e){let{id:t,enabled:n=!0}=e,r=f();return o({queryKey:[...F,t,r.backend.id,r.orgId],queryFn:()=>M.getAutomation(t),staleTime:300*1e3,enabled:!!t&&n})}function de(e){let{id:t,limit:n=20,offset:r=0,enabled:i=!0}=e,a=f();return o({queryKey:[...I,t,{limit:n,offset:r},a.backend.id,a.orgId],queryFn:()=>M.getAutomationRuns(t,n,r),staleTime:60*1e3,enabled:!!t&&i,refetchInterval:e=>{let t=e.state.data;return t&&t.runs.some(e=>e.status===E.PENDING||e.status===E.RUNNING)?3e3:!1}})}var L=[`automations`];function fe(e={}){let{limit:t=50,offset:n=0,enabled:r=!0}=e,i=f();return o({queryKey:[...L,{limit:t,offset:n},i.backend.id,i.orgId],queryFn:()=>M.getAutomations(t,n),staleTime:0,enabled:r})}function pe(){let e=i(),t=f(),{trackAutomationDeactivated:n}=S();return a({mutationFn:({id:e,enabled:t})=>M.toggleAutomation(e,t),onSuccess:(r,i)=>{e.invalidateQueries({queryKey:L}),e.invalidateQueries({queryKey:F}),i.enabled||n({backendKind:t.backend.kind})}})}function R(){let e=i(),t=f(),{trackAutomationImported:n}=S();return a({mutationFn:e=>M.createAutomation({...e,enabled:!1}),onSuccess:()=>{e.invalidateQueries({queryKey:L}),n({backendKind:t.backend.kind})}})}function z(){let e=i(),t=f(),{trackAutomationEdited:n}=S();return a({mutationFn:({id:e,body:t})=>M.updateAutomation(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:L}),e.invalidateQueries({queryKey:F}),n({backendKind:t.backend.kind})}})}function B(){let e=i(),t=f(),{trackAutomationDeleted:n}=S();return a({mutationFn:e=>M.deleteAutomation(e),onSuccess:()=>{e.invalidateQueries({queryKey:L}),n({backendKind:t.backend.kind})}})}function me(){let e=i(),t=f(),{trackAutomationExecuted:n}=S();return a({mutationFn:e=>M.dispatchAutomation(e),onSuccess:(r,i)=>{e.invalidateQueries({queryKey:L}),e.invalidateQueries({queryKey:F}),e.invalidateQueries({queryKey:[...I,i]}),n({backendKind:t.backend.kind})}})}var he=[`automation-health`];function ge(){let e=f();return o({queryKey:[...he,e.backend.id,e.orgId],queryFn:()=>M.checkHealth(),staleTime:30*1e3,retry:!1})}var _e=e=>(0,P.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`currentColor`,viewBox:`0 0 20 20`,...e,children:(0,P.jsx)(`path`,{d:`M10 6a2 2 0 110-4 2 2 0 010 4zm0 6a2 2 0 110-4 2 2 0 010 4zm0 6a2 2 0 110-4 2 2 0 010 4z`})}),V=p(`inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent text-muted hover:bg-interactive-hover hover:text-white focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted`,b),ve=p(`inline-flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-md border-0 bg-transparent px-2 text-xs text-muted hover:bg-interactive-hover hover:text-white focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted`,b);function ye({icon:e,label:t}){return(0,P.jsxs)(`span`,{className:`flex min-w-0 w-full items-center gap-2`,children:[(0,P.jsx)(`span`,{className:p(`[&_svg]:size-4`,x),"aria-hidden":!0,children:e}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t})]})}function be({items:e}){let{t}=s(`openhands`),[n,r]=(0,N.useState)(!1),[i,a]=(0,N.useState)(),o=(0,N.useRef)(null),l=(0,N.useRef)(null);(0,N.useLayoutEffect)(()=>{if(!n||!o.current)return;let e=()=>{let e=o.current?.getBoundingClientRect();e&&a({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)}},[n]),(0,N.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.target;o.current?.contains(t)||l.current?.contains(t)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let u=n&&i?(0,P.jsx)(C,{ref:l,theme:`popover`,className:`min-w-[10rem]`,children:e.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsx)(ae,{onClick:t=>{t.stopPropagation(),e.onClick(),r(!1)},isDisabled:e.disabled,className:`group`,children:(0,P.jsx)(ye,{icon:e.icon,label:e.label})})},e.label))}):null;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{ref:o,type:`button`,onClick:e=>{e.stopPropagation(),r(e=>!e)},className:V,"aria-label":t(c.AUTOMATIONS$ACTIONS_MENU),"aria-expanded":n,"aria-haspopup":`menu`,children:(0,P.jsx)(_e,{className:`size-4`})}),n&&i&&typeof document<`u`?le.createPortal((0,P.jsx)(`div`,{style:i,children:u}),document.body):null]})}function xe(e){return!0}var Se=e=>(0,P.jsxs)(`svg`,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,P.jsx)(`g`,{clipPath:`url(#clip0_8467_30872)`,children:(0,P.jsx)(`path`,{d:`M6.26693 21.4874L6.25583 21.4951L6.24514 21.5033C5.95991 21.7227 5.5 21.5308 5.5 21.0996V2.89961C5.5 2.4684 5.95991 2.2765 6.24514 2.49592L6.25634 2.50452L6.26799 2.51249L19.518 11.5625L19.518 11.5625L19.5226 11.5656C19.8258 11.7677 19.8258 12.1815 19.5226 12.3836L19.5226 12.3835L19.5169 12.3874L6.26693 21.4874Z`,fill:`currentColor`,stroke:`currentColor`})}),(0,P.jsx)(`defs`,{children:(0,P.jsx)(`clipPath`,{id:`clip0_8467_30872`,children:(0,P.jsx)(`rect`,{width:24,height:24,fill:`white`})})})]}),H=e=>(0,P.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`})}),Ce=e=>(0,P.jsx)(`svg`,{viewBox:`0 0 18 18`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,P.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M2.4375 9C2.4375 5.37563 5.37563 2.4375 9 2.4375C12.6244 2.4375 15.5625 5.37563 15.5625 9C15.5625 12.6244 12.6244 15.5625 9 15.5625C5.37563 15.5625 2.4375 12.6244 2.4375 9ZM4.13812 6.5625C4.81317 5.21867 6.02897 4.19333 7.49996 3.77204C7.15155 4.17641 6.85182 4.65395 6.60713 5.17892C6.40828 5.60556 6.24263 6.06975 6.11494 6.5625H4.13812ZM3.72196 7.6875C3.61778 8.10783 3.5625 8.54746 3.5625 9C3.5625 9.45254 3.61778 9.89217 3.72196 10.3125H5.89738C5.84161 9.88758 5.8125 9.44852 5.8125 8.99998C5.8125 8.55142 5.84161 8.11239 5.89737 7.6875H3.72196ZM7.0333 7.6875C6.97087 8.10689 6.9375 8.54634 6.9375 8.99998C6.9375 9.45367 6.97087 9.89313 7.0333 10.3125H10.9667C11.0291 9.89311 11.0625 9.45367 11.0625 9.00002C11.0625 8.54637 11.0291 8.1069 10.9667 7.6875H7.0333ZM12.1026 7.6875C12.1584 8.1124 12.1875 8.55145 12.1875 9.00002C12.1875 9.44858 12.1584 9.88762 12.1026 10.3125H14.278C14.3822 9.89217 14.4375 9.45254 14.4375 9C14.4375 8.54746 14.3822 8.10783 14.278 7.6875H12.1026ZM13.8619 6.5625H11.885C11.7574 6.06976 11.5917 5.6056 11.3929 5.17897C11.1482 4.65397 10.8484 4.1764 10.5 3.77203C11.971 4.19331 13.1868 5.21866 13.8619 6.5625ZM10.7171 6.5625H7.28293C7.38007 6.23971 7.49559 5.93571 7.62681 5.65419C7.99835 4.85708 8.48101 4.26914 8.99997 3.92442C9.51895 4.26913 10.0016 4.8571 10.3732 5.65424C10.5044 5.93575 10.6199 6.23973 10.7171 6.5625ZM4.13812 11.4375H6.11496C6.24963 11.9572 6.42655 12.4452 6.64015 12.8909C6.87835 13.3879 7.16685 13.8413 7.50006 14.228C6.02902 13.8067 4.81318 12.7814 4.13812 11.4375ZM10.7171 11.4375H7.28295C7.3869 11.7829 7.51191 12.1068 7.65465 12.4047C8.02305 13.1733 8.49456 13.7398 9.00007 14.0756C9.51902 13.7308 10.0017 13.1429 10.3732 12.3458C10.5044 12.0643 10.6199 11.7603 10.7171 11.4375ZM11.3929 12.8211C11.5917 12.3944 11.7574 11.9303 11.8851 11.4375H13.8619C13.1868 12.7813 11.971 13.8067 10.5 14.228C10.8485 13.8236 11.1482 13.346 11.3929 12.8211Z`,fill:`currentColor`})}),we=e=>(0,P.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z`})}),Te=/^(\d+)$/;function U(e,t,n){let r=e.match(Te);if(!r)return null;let i=Number(r[1]);return Number.isNaN(i)||i<t||i>n?null:i}function Ee(e){let t=(e??``).trim();if(!t)return{kind:`custom`,raw:``};let n=t.split(/\s+/);if(n.length!==5)return{kind:`custom`,raw:t};let[r,i,a,o,s]=n,c=U(r,0,59),l=U(i,0,23);if(c===null||l===null)return{kind:`custom`,raw:t};if(a!==`*`||o!==`*`)return{kind:`custom`,raw:t,hour:l,minute:c};if(s===`*`||s===`0-6`)return{kind:`daily`,hour:l,minute:c};if(s===`1-5`)return{kind:`weekdays`,hour:l,minute:c};let u=U(s,0,6);return u===null?{kind:`custom`,raw:t,hour:l,minute:c}:{kind:`weekly`,hour:l,minute:c,weekday:u}}function De(e){let{kind:t,hour:n,minute:r,weekday:i}=e;switch(t){case`daily`:return`${r} ${n} * * *`;case`weekdays`:return`${r} ${n} * * 1-5`;case`weekly`:return`${r} ${n} * * ${i??1}`;default:return t}}function W(e,t){return`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`}function G(e){let t=e.match(/^(\d{1,2}):(\d{2})$/);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return Number.isNaN(n)||Number.isNaN(r)||n<0||n>23||r<0||r>59?null:{hour:n,minute:r}}function K(e){return e?Array.isArray(e)?e.join(`, `):e:`—`}var Oe=e=>(0,P.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5.636 5.636a9 9 0 1012.728 0M12 3v9`})}),ke=e=>(0,P.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})}),q=e=>(0,P.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:1.5,...e,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z`})});function Ae({onRetry:e}){let{t}=s(`openhands`);return(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20`,children:[(0,P.jsx)(q,{className:`size-12 text-danger`}),(0,P.jsx)(`p`,{className:`mt-4 text-sm text-muted`,children:t(c.AUTOMATIONS$ERROR_TITLE)}),(0,P.jsx)(`button`,{type:`button`,onClick:e,className:`mt-4 rounded-lg border border-[var(--oh-border)] px-4 py-2 text-sm text-white hover:bg-surface-raised`,children:t(c.AUTOMATIONS$ERROR_RETRY)})]})}function je({onRetry:e}){let{t}=s(`openhands`);return(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 px-4`,children:[(0,P.jsx)(q,{className:`size-12 text-[var(--oh-warning)]`}),(0,P.jsx)(`h2`,{className:`mt-4 text-lg font-medium text-content`,children:t(c.AUTOMATIONS$BACKEND_UNAVAILABLE_TITLE)}),(0,P.jsx)(`p`,{className:`mt-2 text-sm text-muted text-center max-w-md`,children:t(c.AUTOMATIONS$BACKEND_UNAVAILABLE_MESSAGE)}),(0,P.jsx)(y,{type:`button`,variant:`secondary`,className:`mt-6`,onClick:e,children:t(c.AUTOMATIONS$BACKEND_UNAVAILABLE_RETRY)})]})}function Me({automationName:e,isOpen:t,onConfirm:n,onCancel:r}){let{t:i}=s(`openhands`);return t?(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,P.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:r,onKeyDown:e=>{e.key===`Escape`&&r()},role:`presentation`}),(0,P.jsxs)(`div`,{className:`relative w-full max-w-sm rounded-xl border border-[var(--oh-border)] bg-[var(--oh-surface)] p-6`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:r,className:`absolute right-4 top-4 text-muted hover:text-foreground`,"aria-label":i(c.BUTTON$CLOSE),children:(0,P.jsx)(T,{className:`size-5`})}),(0,P.jsx)(`h2`,{className:v,children:i(c.AUTOMATIONS$DELETE_CONFIRM_TITLE)}),(0,P.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:i(c.AUTOMATIONS$DELETE_CONFIRM_MESSAGE,{name:e})}),(0,P.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg border border-[var(--oh-border)] px-4 py-2 text-sm text-white hover:bg-surface-raised`,children:i(c.AUTOMATIONS$CANCEL)}),(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-lg bg-danger px-4 py-2 text-sm text-white hover:bg-danger/80`,children:i(c.AUTOMATIONS$DELETE)})]})]})]}):null}var J=`__active__`,Ne=[c.AUTOMATIONS$WEEKDAY_SUN,c.AUTOMATIONS$WEEKDAY_MON,c.AUTOMATIONS$WEEKDAY_TUE,c.AUTOMATIONS$WEEKDAY_WED,c.AUTOMATIONS$WEEKDAY_THU,c.AUTOMATIONS$WEEKDAY_FRI,c.AUTOMATIONS$WEEKDAY_SAT];function Pe(e){if(e.trigger.type===`event`)return{name:e.name,prompt:e.prompt??``,model:e.model??``,frequency:`custom`,weekday:1,timeOfDay:``,isCustomSchedule:!0,rawSchedule:``};let t=Ee(e.trigger.schedule);return t.kind===`custom`?{name:e.name,prompt:e.prompt??``,model:e.model??``,frequency:`custom`,weekday:1,timeOfDay:t.hour!==void 0&&t.minute!==void 0?W(t.hour,t.minute):``,isCustomSchedule:!0,rawSchedule:t.raw}:{name:e.name,prompt:e.prompt??``,model:e.model??``,frequency:t.kind,weekday:t.kind===`weekly`?t.weekday??1:1,timeOfDay:W(t.hour,t.minute),isCustomSchedule:!1,rawSchedule:e.trigger.schedule??``}}function Fe({automation:e,isOpen:t,onClose:n}){let{t:r}=s(`openhands`),i=z(),{data:a,isLoading:o}=ie(),l=a?.profiles??[],f=[{key:J,label:r(c.COMMON$ACTIVE_PROFILE)},...l.map(e=>({key:e.name,label:e.name}))],m=(0,N.useMemo)(()=>Pe(e),[e]),[h,g]=(0,N.useState)(m),[_,b]=(0,N.useState)(null);if((0,N.useEffect)(()=>{t&&(g(m),b(null))},[t,m]),!t)return null;let x=[{key:`daily`,label:r(c.AUTOMATIONS$FREQUENCY_DAILY)},{key:`weekdays`,label:r(c.AUTOMATIONS$FREQUENCY_WEEKDAYS)},{key:`weekly`,label:r(c.AUTOMATIONS$FREQUENCY_WEEKLY)},...h.isCustomSchedule?[{key:`custom`,label:r(c.AUTOMATIONS$FREQUENCY_CUSTOM)}]:[]],S=Ne.map((e,t)=>({key:String(t),label:r(e)})),C=!h.isCustomSchedule||G(h.timeOfDay)!==null||h.timeOfDay===``;return(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,P.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`presentation`}),(0,P.jsxs)(`div`,{className:`relative w-full max-w-md rounded-xl border border-[var(--oh-border)] bg-[var(--oh-surface)] p-6`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`absolute right-4 top-4 text-muted hover:text-foreground`,"aria-label":r(c.AUTOMATIONS$CANCEL),children:(0,P.jsx)(T,{className:`size-5`})}),(0,P.jsx)(`h2`,{className:v,children:r(c.AUTOMATIONS$EDIT_TITLE)}),(0,P.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let a=h.name.trim();if(!a){b(r(c.AUTOMATIONS$NAME_REQUIRED));return}b(null);let o={};a!==e.name&&(o.name=a);let s=h.prompt.trim();s!==(e.prompt??``).trim()&&(o.prompt=s.length===0?null:s);let l=h.model.trim();if(l!==(e.model??``)&&(o.model=l===``?null:l),!h.isCustomSchedule&&h.frequency!==`custom`){let t=G(h.timeOfDay);if(t){let n=De({kind:h.frequency,hour:t.hour,minute:t.minute,weekday:h.frequency===`weekly`?h.weekday:void 0});n!==e.trigger.schedule&&(o.trigger={...e.trigger,schedule:n})}}if(Object.keys(o).length===0){n();return}i.mutate({id:e.id,body:o},{onSuccess:()=>{ee(r(c.AUTOMATIONS$EDIT_SUCCESS)),n()},onError:e=>{d(u(e)?e.response?.data?.message||e.message||r(c.AUTOMATIONS$EDIT_ERROR):e.message||r(c.AUTOMATIONS$EDIT_ERROR))}})},className:`mt-4 flex flex-col gap-4`,"aria-label":r(c.AUTOMATIONS$EDIT_TITLE),children:[(0,P.jsx)(re,{testId:`edit-automation-name`,name:`name`,type:`text`,label:r(c.AUTOMATIONS$NAME),value:h.name,onChange:e=>g(t=>({...t,name:e})),error:_??void 0,showRequiredTag:!0}),(0,P.jsxs)(`label`,{className:`flex flex-col gap-2.5 w-full min-w-0`,children:[(0,P.jsx)(`span`,{className:`text-sm`,children:r(c.AUTOMATIONS$PROMPT)}),(0,P.jsx)(`textarea`,{"data-testid":`edit-automation-prompt`,name:`prompt`,value:h.prompt,onChange:e=>g(t=>({...t,prompt:e.target.value})),rows:4,className:p(ne,`placeholder:italic`)}),(0,P.jsx)(`span`,{className:`text-xs text-muted`,children:r(c.AUTOMATIONS$EDIT_PROMPT_HINT)})]}),(o||l.length>0)&&(0,P.jsx)(w,{testId:`edit-automation-model`,name:`model`,label:r(c.AUTOMATIONS$DETAIL$MODEL),items:f,selectedKey:h.model||J,isLoading:o,placeholder:r(c.COMMON$ACTIVE_PROFILE),onSelectionChange:e=>g(t=>({...t,model:e&&e!==J?String(e):``}))}),e.trigger.type===`event`?(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-[var(--oh-surface-raised)] p-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(c.AUTOMATIONS$DETAIL$TRIGGER)}),(0,P.jsx)(`span`,{className:`text-sm text-content`,children:r(c.AUTOMATIONS$DETAIL$TRIGGER_EVENT)})]}),e.trigger.source&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(c.AUTOMATIONS$DETAIL$EVENT_SOURCE)}),(0,P.jsx)(`span`,{className:`text-sm text-content`,children:e.trigger.source})]}),e.trigger.on&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(c.AUTOMATIONS$DETAIL$EVENT_TYPE)}),(0,P.jsx)(`code`,{className:`text-xs font-mono text-content`,children:K(e.trigger.on)})]}),e.trigger.filter&&(0,P.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(c.AUTOMATIONS$DETAIL$EVENT_FILTER)}),(0,P.jsx)(`code`,{className:`text-xs font-mono text-content break-all`,children:e.trigger.filter})]})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(w,{testId:`edit-automation-frequency`,name:`frequency`,label:r(c.AUTOMATIONS$FREQUENCY),items:x,selectedKey:h.frequency,isDisabled:h.isCustomSchedule,onSelectionChange:e=>{!e||h.isCustomSchedule||g(t=>({...t,frequency:e}))}}),h.frequency===`weekly`&&!h.isCustomSchedule&&(0,P.jsx)(w,{testId:`edit-automation-weekday`,name:`weekday`,label:r(c.AUTOMATIONS$WEEKDAY),items:S,selectedKey:String(h.weekday),onSelectionChange:e=>{e!==null&&g(t=>({...t,weekday:Number(e)}))}}),(0,P.jsxs)(`label`,{className:`flex flex-col gap-2.5 w-full min-w-0`,children:[(0,P.jsx)(`span`,{className:`text-sm`,children:r(c.AUTOMATIONS$TIME_OF_DAY)}),(0,P.jsx)(`input`,{"data-testid":`edit-automation-time`,name:`timeOfDay`,type:`time`,value:h.timeOfDay,onChange:e=>g(t=>({...t,timeOfDay:e.target.value})),disabled:h.isCustomSchedule&&!C,className:p(te,`disabled:bg-[var(--oh-surface-raised)]`)}),e.timezone&&(0,P.jsxs)(`span`,{className:`text-xs text-muted`,children:[r(c.AUTOMATIONS$TIMEZONE),`: `,e.timezone]})]}),h.isCustomSchedule&&(0,P.jsxs)(`p`,{className:`text-xs text-muted`,"data-testid":`custom-schedule-hint`,children:[r(c.AUTOMATIONS$CUSTOM_SCHEDULE_HINT),h.rawSchedule&&(0,P.jsxs)(P.Fragment,{children:[` `,(0,P.jsx)(`code`,{className:`text-xs text-content`,children:h.rawSchedule})]})]})]}),(0,P.jsxs)(`div`,{className:`mt-2 flex justify-end gap-3`,children:[(0,P.jsx)(y,{testId:`edit-automation-cancel`,type:`button`,variant:`secondary`,onClick:n,isDisabled:i.isPending,children:r(c.AUTOMATIONS$CANCEL)}),(0,P.jsx)(y,{testId:`edit-automation-save`,type:`submit`,variant:`primary`,isDisabled:i.isPending,"aria-busy":i.isPending,children:i.isPending?r(c.AUTOMATIONS$SAVING):r(c.AUTOMATIONS$SAVE)})]})]})]})]})}var Y=new Set([`cron`,`schedule`,`event`]),X=class extends Error{issues;constructor(e){super(e.join(`
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{Ct as t,bt as n,xt as r}from"./vendor-styling-CI0PQ3ab.js";import{n as i}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~epa72zsm-B4rXs7Zd.js";import{t as a}from"./useMutation-DrCAVg5w.js";import{t as o}from"./useQuery-CRBP8vIS.js";import{t as s}from"./useTranslation-CDRCKC9-.js";import{t as c}from"./declaration-gq8V5eTU.js";import{b as l,y as u}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~lf310vj7-CSVPGId3.js";import{A as d,j as ee,n as f}from"./active-backend-context-hxq31W25.js";import{t as p}from"./utils-D3U3rlqr.js";import{c as m,t as h,u as g}from"./agent-server-client-options-DVLRd9sw.js";import{t as _}from"./proxy-BgJLtxu7.js";import{r as v}from"./modal-classes-Cf-4tbHz.js";import{f as te,l as ne}from"./form-control-classes-ChpNBe9n.js";import{t as y}from"./brand-button-vMVuyDXu.js";import{r as b,u as x}from"./dropdown-classes-DJSXeLqc.js";import{t as re}from"./settings-input-bD6npsDm.js";import{t as S}from"./use-tracking-BIXzagSI.js";import{t as ie}from"./use-llm-profiles-RC-PkpBl.js";import{n as C,t as ae}from"./context-menu-list-item-BD5_EaKN.js";import{t as w}from"./settings-dropdown-input-BjunGXJb.js";import{t as T}from"./x-mark-Batp6gXa.js";import{t as E}from"./automation-BU8zu-FP.js";var D=`/api/automation`,O=l.create();O.interceptors.request.use(e=>{if(e.baseURL)return e;let t=g();if(!t)throw new h;e.baseURL=t.host;let n=t.apiKey?.trim();return n&&e.headers.set(`X-Session-API-Key`,n),e});function k(e,t){let n=new URLSearchParams;return n.set(`limit`,String(e)),n.set(`offset`,String(t)),n.toString()}function oe(e){return e.trigger.type===`event`?{type:`event`,source:e.trigger.source,on:e.trigger.on,...e.trigger.filter&&{filter:e.trigger.filter}}:{type:`cron`,schedule:e.trigger.schedule,timezone:e.timezone??e.trigger.timezone??`UTC`}}function se(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`pending.${crypto.randomUUID()}`:`pending.${Date.now()}.${Math.random().toString(36).slice(2,10)}`}function ce(e){if(!e.prompt)throw Error(`An automation prompt is required for import.`);let t=e.repository?[{url:e.repository,...e.branch&&{ref:e.branch},...!e.repository.includes(`://`)&&!e.repository.startsWith(`git@`)&&{provider:`github`}}]:void 0;return{path:`${D}/v1/preset/${e.plugins?.length?`plugin`:`prompt`}`,body:{name:e.name,prompt:e.prompt,trigger:{type:`event`,source:`agent-canvas-import`,on:se()},...e.model&&{model:e.model},...t&&{repos:t},...e.plugins?.length&&{plugins:e.plugins.map(e=>({source:e}))}}}}function A(e){let t=e.apiKey.trim();return{baseURL:e.host,...t&&{headers:{"X-Session-API-Key":t}}}}function j(e){return e.orgId?{"X-Org-Id":e.orgId}:void 0}var M=class e{static async listAutomations(e={}){let{limit:t=50,offset:n=0}=e,r=m().backend;if(r.kind===`cloud`)return _({backend:r,method:`GET`,path:`${D}/v1?${k(t,n)}`});let{data:i}=await O.get(`${D}/v1`,{params:{limit:t,offset:n}});return i}static async getAutomations(t=50,n=0){return e.listAutomations({limit:t,offset:n})}static async getAutomation(e){let t=m().backend,n=`${D}/v1/${encodeURIComponent(e)}`;if(t.kind===`cloud`)return _({backend:t,method:`GET`,path:n});let{data:r}=await O.get(n);return r}static async createAutomation(e){let t=m(),{path:n,body:r}=ce(e),i;if(t.backend.kind===`cloud`)i=await _({backend:t.backend,method:`POST`,path:n,body:r,headers:j(t)});else{let{data:e}=await O.post(n,r,A(t.backend));i=e}let a=`${D}/v1/${encodeURIComponent(i.id)}`,o={trigger:oe(e),enabled:!1};try{if(t.backend.kind===`cloud`)return await _({backend:t.backend,method:`PATCH`,path:a,body:o,headers:j(t)});let{data:e}=await O.patch(a,o,A(t.backend));return e}catch(e){try{t.backend.kind===`cloud`?await _({backend:t.backend,method:`DELETE`,path:a,headers:j(t)}):await O.delete(a,A(t.backend))}catch(t){throw AggregateError([e,t],`Failed to disable the imported automation and clean it up.`)}throw e}}static async updateAutomation(e,t){let n=m().backend,r=`${D}/v1/${encodeURIComponent(e)}`;if(n.kind===`cloud`)return _({backend:n,method:`PATCH`,path:r,body:t});let{data:i}=await O.patch(r,t);return i}static async deleteAutomation(e){let t=m().backend,n=`${D}/v1/${encodeURIComponent(e)}`;if(t.kind===`cloud`){await _({backend:t,method:`DELETE`,path:n});return}await O.delete(n)}static async dispatchAutomation(e){let t=m().backend,n=`${D}/v1/${encodeURIComponent(e)}/dispatch`;if(t.kind===`cloud`)return _({backend:t,method:`POST`,path:n});let{data:r}=await O.post(n);return r}static async listAutomationRuns(e,t={}){let{limit:n=50,offset:r=0}=t,i=m().backend,a=`${D}/v1/${encodeURIComponent(e)}/runs`;if(i.kind===`cloud`)return _({backend:i,method:`GET`,path:`${a}?${k(n,r)}`});let{data:o}=await O.get(a,{params:{limit:n,offset:r}});return o}static async getAutomationRuns(t,n=50,r=0){return e.listAutomationRuns(t,{limit:n,offset:r})}static async toggleAutomation(t,n){return e.updateAutomation(t,{enabled:n})}static async downloadTarball(e,t){let n=m().backend,r=`${D}/v1/${encodeURIComponent(e)}/tarball`,i;if(n.kind===`cloud`)i=await _({backend:n,method:`GET`,path:r,responseType:`blob`});else{let{data:e}=await O.get(r,{responseType:`blob`});i=e}let a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`${t}.tar`,o.click(),URL.revokeObjectURL(a)}static async checkHealth(){let e=m().backend,t=`${D}/health`;try{if(e.kind===`cloud`)return await _({backend:e,method:`GET`,path:t,timeoutSeconds:5});let{data:n}=await O.get(t,{timeout:5e3});return n}catch{return{status:`error`}}}},N=e(t()),le=e(r(),1),P=n(),F=[`automation-detail`],I=[`automation-runs`];function ue(e){let{id:t,enabled:n=!0}=e,r=f();return o({queryKey:[...F,t,r.backend.id,r.orgId],queryFn:()=>M.getAutomation(t),staleTime:300*1e3,enabled:!!t&&n})}function de(e){let{id:t,limit:n=20,offset:r=0,enabled:i=!0}=e,a=f();return o({queryKey:[...I,t,{limit:n,offset:r},a.backend.id,a.orgId],queryFn:()=>M.getAutomationRuns(t,n,r),staleTime:60*1e3,enabled:!!t&&i,refetchInterval:e=>{let t=e.state.data;return t&&t.runs.some(e=>e.status===E.PENDING||e.status===E.RUNNING)?3e3:!1}})}var L=[`automations`];function fe(e={}){let{limit:t=50,offset:n=0,enabled:r=!0}=e,i=f();return o({queryKey:[...L,{limit:t,offset:n},i.backend.id,i.orgId],queryFn:()=>M.getAutomations(t,n),staleTime:0,enabled:r})}function pe(){let e=i(),t=f(),{trackAutomationDeactivated:n}=S();return a({mutationFn:({id:e,enabled:t})=>M.toggleAutomation(e,t),onSuccess:(r,i)=>{e.invalidateQueries({queryKey:L}),e.invalidateQueries({queryKey:F}),i.enabled||n({backendKind:t.backend.kind})}})}function R(){let e=i(),t=f(),{trackAutomationImported:n}=S();return a({mutationFn:e=>M.createAutomation({...e,enabled:!1}),onSuccess:()=>{e.invalidateQueries({queryKey:L}),n({backendKind:t.backend.kind})}})}function z(){let e=i(),t=f(),{trackAutomationEdited:n}=S();return a({mutationFn:({id:e,body:t})=>M.updateAutomation(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:L}),e.invalidateQueries({queryKey:F}),n({backendKind:t.backend.kind})}})}function B(){let e=i(),t=f(),{trackAutomationDeleted:n}=S();return a({mutationFn:e=>M.deleteAutomation(e),onSuccess:()=>{e.invalidateQueries({queryKey:L}),n({backendKind:t.backend.kind})}})}function me(){let e=i(),t=f(),{trackAutomationExecuted:n}=S();return a({mutationFn:e=>M.dispatchAutomation(e),onSuccess:(r,i)=>{e.invalidateQueries({queryKey:L}),e.invalidateQueries({queryKey:F}),e.invalidateQueries({queryKey:[...I,i]}),n({backendKind:t.backend.kind})}})}var he=[`automation-health`];function ge(){let e=f();return o({queryKey:[...he,e.backend.id,e.orgId],queryFn:()=>M.checkHealth(),staleTime:30*1e3,retry:!1})}var _e=e=>(0,P.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`currentColor`,viewBox:`0 0 20 20`,...e,children:(0,P.jsx)(`path`,{d:`M10 6a2 2 0 110-4 2 2 0 010 4zm0 6a2 2 0 110-4 2 2 0 010 4zm0 6a2 2 0 110-4 2 2 0 010 4z`})}),V=p(`inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent text-muted hover:bg-interactive-hover hover:text-white focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted`,b),ve=p(`inline-flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-md border-0 bg-transparent px-2 text-xs text-muted hover:bg-interactive-hover hover:text-white focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted`,b);function ye({icon:e,label:t}){return(0,P.jsxs)(`span`,{className:`flex min-w-0 w-full items-center gap-2`,children:[(0,P.jsx)(`span`,{className:p(`[&_svg]:size-4`,x),"aria-hidden":!0,children:e}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t})]})}function be({items:e}){let{t}=s(`openhands`),[n,r]=(0,N.useState)(!1),[i,a]=(0,N.useState)(),o=(0,N.useRef)(null),l=(0,N.useRef)(null);(0,N.useLayoutEffect)(()=>{if(!n||!o.current)return;let e=()=>{let e=o.current?.getBoundingClientRect();e&&a({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)}},[n]),(0,N.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.target;o.current?.contains(t)||l.current?.contains(t)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let u=n&&i?(0,P.jsx)(C,{ref:l,theme:`popover`,className:`min-w-[10rem]`,children:e.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsx)(ae,{onClick:t=>{t.stopPropagation(),e.onClick(),r(!1)},isDisabled:e.disabled,className:`group`,children:(0,P.jsx)(ye,{icon:e.icon,label:e.label})})},e.label))}):null;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{ref:o,type:`button`,onClick:e=>{e.stopPropagation(),r(e=>!e)},className:V,"aria-label":t(c.AUTOMATIONS$ACTIONS_MENU),"aria-expanded":n,"aria-haspopup":`menu`,children:(0,P.jsx)(_e,{className:`size-4`})}),n&&i&&typeof document<`u`?le.createPortal((0,P.jsx)(`div`,{style:i,children:u}),document.body):null]})}function xe(e){return!0}var Se=e=>(0,P.jsxs)(`svg`,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,P.jsx)(`g`,{clipPath:`url(#clip0_8467_30872)`,children:(0,P.jsx)(`path`,{d:`M6.26693 21.4874L6.25583 21.4951L6.24514 21.5033C5.95991 21.7227 5.5 21.5308 5.5 21.0996V2.89961C5.5 2.4684 5.95991 2.2765 6.24514 2.49592L6.25634 2.50452L6.26799 2.51249L19.518 11.5625L19.518 11.5625L19.5226 11.5656C19.8258 11.7677 19.8258 12.1815 19.5226 12.3836L19.5226 12.3835L19.5169 12.3874L6.26693 21.4874Z`,fill:`currentColor`,stroke:`currentColor`})}),(0,P.jsx)(`defs`,{children:(0,P.jsx)(`clipPath`,{id:`clip0_8467_30872`,children:(0,P.jsx)(`rect`,{width:24,height:24,fill:`white`})})})]}),H=e=>(0,P.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`})}),Ce=e=>(0,P.jsx)(`svg`,{viewBox:`0 0 18 18`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,P.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M2.4375 9C2.4375 5.37563 5.37563 2.4375 9 2.4375C12.6244 2.4375 15.5625 5.37563 15.5625 9C15.5625 12.6244 12.6244 15.5625 9 15.5625C5.37563 15.5625 2.4375 12.6244 2.4375 9ZM4.13812 6.5625C4.81317 5.21867 6.02897 4.19333 7.49996 3.77204C7.15155 4.17641 6.85182 4.65395 6.60713 5.17892C6.40828 5.60556 6.24263 6.06975 6.11494 6.5625H4.13812ZM3.72196 7.6875C3.61778 8.10783 3.5625 8.54746 3.5625 9C3.5625 9.45254 3.61778 9.89217 3.72196 10.3125H5.89738C5.84161 9.88758 5.8125 9.44852 5.8125 8.99998C5.8125 8.55142 5.84161 8.11239 5.89737 7.6875H3.72196ZM7.0333 7.6875C6.97087 8.10689 6.9375 8.54634 6.9375 8.99998C6.9375 9.45367 6.97087 9.89313 7.0333 10.3125H10.9667C11.0291 9.89311 11.0625 9.45367 11.0625 9.00002C11.0625 8.54637 11.0291 8.1069 10.9667 7.6875H7.0333ZM12.1026 7.6875C12.1584 8.1124 12.1875 8.55145 12.1875 9.00002C12.1875 9.44858 12.1584 9.88762 12.1026 10.3125H14.278C14.3822 9.89217 14.4375 9.45254 14.4375 9C14.4375 8.54746 14.3822 8.10783 14.278 7.6875H12.1026ZM13.8619 6.5625H11.885C11.7574 6.06976 11.5917 5.6056 11.3929 5.17897C11.1482 4.65397 10.8484 4.1764 10.5 3.77203C11.971 4.19331 13.1868 5.21866 13.8619 6.5625ZM10.7171 6.5625H7.28293C7.38007 6.23971 7.49559 5.93571 7.62681 5.65419C7.99835 4.85708 8.48101 4.26914 8.99997 3.92442C9.51895 4.26913 10.0016 4.8571 10.3732 5.65424C10.5044 5.93575 10.6199 6.23973 10.7171 6.5625ZM4.13812 11.4375H6.11496C6.24963 11.9572 6.42655 12.4452 6.64015 12.8909C6.87835 13.3879 7.16685 13.8413 7.50006 14.228C6.02902 13.8067 4.81318 12.7814 4.13812 11.4375ZM10.7171 11.4375H7.28295C7.3869 11.7829 7.51191 12.1068 7.65465 12.4047C8.02305 13.1733 8.49456 13.7398 9.00007 14.0756C9.51902 13.7308 10.0017 13.1429 10.3732 12.3458C10.5044 12.0643 10.6199 11.7603 10.7171 11.4375ZM11.3929 12.8211C11.5917 12.3944 11.7574 11.9303 11.8851 11.4375H13.8619C13.1868 12.7813 11.971 13.8067 10.5 14.228C10.8485 13.8236 11.1482 13.346 11.3929 12.8211Z`,fill:`currentColor`})}),we=e=>(0,P.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z`})}),Te=/^(\d+)$/;function U(e,t,n){let r=e.match(Te);if(!r)return null;let i=Number(r[1]);return Number.isNaN(i)||i<t||i>n?null:i}function Ee(e){let t=(e??``).trim();if(!t)return{kind:`custom`,raw:``};let n=t.split(/\s+/);if(n.length!==5)return{kind:`custom`,raw:t};let[r,i,a,o,s]=n,c=U(r,0,59),l=U(i,0,23);if(c===null||l===null)return{kind:`custom`,raw:t};if(a!==`*`||o!==`*`)return{kind:`custom`,raw:t,hour:l,minute:c};if(s===`*`||s===`0-6`)return{kind:`daily`,hour:l,minute:c};if(s===`1-5`)return{kind:`weekdays`,hour:l,minute:c};let u=U(s,0,6);return u===null?{kind:`custom`,raw:t,hour:l,minute:c}:{kind:`weekly`,hour:l,minute:c,weekday:u}}function De(e){let{kind:t,hour:n,minute:r,weekday:i}=e;switch(t){case`daily`:return`${r} ${n} * * *`;case`weekdays`:return`${r} ${n} * * 1-5`;case`weekly`:return`${r} ${n} * * ${i??1}`;default:return t}}function W(e,t){return`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`}function G(e){let t=e.match(/^(\d{1,2}):(\d{2})$/);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return Number.isNaN(n)||Number.isNaN(r)||n<0||n>23||r<0||r>59?null:{hour:n,minute:r}}function K(e){return e?Array.isArray(e)?e.join(`, `):e:`—`}var Oe=e=>(0,P.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5.636 5.636a9 9 0 1012.728 0M12 3v9`})}),ke=e=>(0,P.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})}),q=e=>(0,P.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:1.5,...e,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z`})});function Ae({onRetry:e}){let{t}=s(`openhands`);return(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20`,children:[(0,P.jsx)(q,{className:`size-12 text-danger`}),(0,P.jsx)(`p`,{className:`mt-4 text-sm text-muted`,children:t(c.AUTOMATIONS$ERROR_TITLE)}),(0,P.jsx)(`button`,{type:`button`,onClick:e,className:`mt-4 rounded-lg border border-[var(--oh-border)] px-4 py-2 text-sm text-white hover:bg-surface-raised`,children:t(c.AUTOMATIONS$ERROR_RETRY)})]})}function je({onRetry:e}){let{t}=s(`openhands`);return(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 px-4`,children:[(0,P.jsx)(q,{className:`size-12 text-[var(--oh-warning)]`}),(0,P.jsx)(`h2`,{className:`mt-4 text-lg font-medium text-content`,children:t(c.AUTOMATIONS$BACKEND_UNAVAILABLE_TITLE)}),(0,P.jsx)(`p`,{className:`mt-2 text-sm text-muted text-center max-w-md`,children:t(c.AUTOMATIONS$BACKEND_UNAVAILABLE_MESSAGE)}),(0,P.jsx)(y,{type:`button`,variant:`secondary`,className:`mt-6`,onClick:e,children:t(c.AUTOMATIONS$BACKEND_UNAVAILABLE_RETRY)})]})}function Me({automationName:e,isOpen:t,onConfirm:n,onCancel:r}){let{t:i}=s(`openhands`);return t?(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,P.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:r,onKeyDown:e=>{e.key===`Escape`&&r()},role:`presentation`}),(0,P.jsxs)(`div`,{className:`relative w-full max-w-sm rounded-xl border border-[var(--oh-border)] bg-[var(--oh-surface)] p-6`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:r,className:`absolute right-4 top-4 text-muted hover:text-foreground`,"aria-label":i(c.BUTTON$CLOSE),children:(0,P.jsx)(T,{className:`size-5`})}),(0,P.jsx)(`h2`,{className:v,children:i(c.AUTOMATIONS$DELETE_CONFIRM_TITLE)}),(0,P.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:i(c.AUTOMATIONS$DELETE_CONFIRM_MESSAGE,{name:e})}),(0,P.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg border border-[var(--oh-border)] px-4 py-2 text-sm text-white hover:bg-surface-raised`,children:i(c.AUTOMATIONS$CANCEL)}),(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-lg bg-danger px-4 py-2 text-sm text-white hover:bg-danger/80`,children:i(c.AUTOMATIONS$DELETE)})]})]})]}):null}var J=`__active__`,Ne=[c.AUTOMATIONS$WEEKDAY_SUN,c.AUTOMATIONS$WEEKDAY_MON,c.AUTOMATIONS$WEEKDAY_TUE,c.AUTOMATIONS$WEEKDAY_WED,c.AUTOMATIONS$WEEKDAY_THU,c.AUTOMATIONS$WEEKDAY_FRI,c.AUTOMATIONS$WEEKDAY_SAT];function Pe(e){if(e.trigger.type===`event`)return{name:e.name,prompt:e.prompt??``,model:e.model??``,frequency:`custom`,weekday:1,timeOfDay:``,isCustomSchedule:!0,rawSchedule:``};let t=Ee(e.trigger.schedule);return t.kind===`custom`?{name:e.name,prompt:e.prompt??``,model:e.model??``,frequency:`custom`,weekday:1,timeOfDay:t.hour!==void 0&&t.minute!==void 0?W(t.hour,t.minute):``,isCustomSchedule:!0,rawSchedule:t.raw}:{name:e.name,prompt:e.prompt??``,model:e.model??``,frequency:t.kind,weekday:t.kind===`weekly`?t.weekday??1:1,timeOfDay:W(t.hour,t.minute),isCustomSchedule:!1,rawSchedule:e.trigger.schedule??``}}function Fe({automation:e,isOpen:t,onClose:n}){let{t:r}=s(`openhands`),i=z(),{data:a,isLoading:o}=ie(),l=a?.profiles??[],f=[{key:J,label:r(c.COMMON$ACTIVE_PROFILE)},...l.map(e=>({key:e.name,label:e.name}))],m=(0,N.useMemo)(()=>Pe(e),[e]),[h,g]=(0,N.useState)(m),[_,b]=(0,N.useState)(null);if((0,N.useEffect)(()=>{t&&(g(m),b(null))},[t,m]),!t)return null;let x=[{key:`daily`,label:r(c.AUTOMATIONS$FREQUENCY_DAILY)},{key:`weekdays`,label:r(c.AUTOMATIONS$FREQUENCY_WEEKDAYS)},{key:`weekly`,label:r(c.AUTOMATIONS$FREQUENCY_WEEKLY)},...h.isCustomSchedule?[{key:`custom`,label:r(c.AUTOMATIONS$FREQUENCY_CUSTOM)}]:[]],S=Ne.map((e,t)=>({key:String(t),label:r(e)})),C=!h.isCustomSchedule||G(h.timeOfDay)!==null||h.timeOfDay===``;return(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,P.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`presentation`}),(0,P.jsxs)(`div`,{className:`relative w-full max-w-md rounded-xl border border-[var(--oh-border)] bg-[var(--oh-surface)] p-6`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`absolute right-4 top-4 text-muted hover:text-foreground`,"aria-label":r(c.AUTOMATIONS$CANCEL),children:(0,P.jsx)(T,{className:`size-5`})}),(0,P.jsx)(`h2`,{className:v,children:r(c.AUTOMATIONS$EDIT_TITLE)}),(0,P.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let a=h.name.trim();if(!a){b(r(c.AUTOMATIONS$NAME_REQUIRED));return}b(null);let o={};a!==e.name&&(o.name=a);let s=h.prompt.trim();s!==(e.prompt??``).trim()&&(o.prompt=s.length===0?null:s);let l=h.model.trim();if(l!==(e.model??``)&&(o.model=l===``?null:l),!h.isCustomSchedule&&h.frequency!==`custom`){let t=G(h.timeOfDay);if(t){let n=De({kind:h.frequency,hour:t.hour,minute:t.minute,weekday:h.frequency===`weekly`?h.weekday:void 0});n!==e.trigger.schedule&&(o.trigger={...e.trigger,schedule:n})}}if(Object.keys(o).length===0){n();return}i.mutate({id:e.id,body:o},{onSuccess:()=>{ee(r(c.AUTOMATIONS$EDIT_SUCCESS)),n()},onError:e=>{d(u(e)?e.response?.data?.message||e.message||r(c.AUTOMATIONS$EDIT_ERROR):e.message||r(c.AUTOMATIONS$EDIT_ERROR))}})},className:`mt-4 flex flex-col gap-4`,"aria-label":r(c.AUTOMATIONS$EDIT_TITLE),children:[(0,P.jsx)(re,{testId:`edit-automation-name`,name:`name`,type:`text`,label:r(c.AUTOMATIONS$NAME),value:h.name,onChange:e=>g(t=>({...t,name:e})),error:_??void 0,showRequiredTag:!0}),(0,P.jsxs)(`label`,{className:`flex flex-col gap-2.5 w-full min-w-0`,children:[(0,P.jsx)(`span`,{className:`text-sm`,children:r(c.AUTOMATIONS$PROMPT)}),(0,P.jsx)(`textarea`,{"data-testid":`edit-automation-prompt`,name:`prompt`,value:h.prompt,onChange:e=>g(t=>({...t,prompt:e.target.value})),rows:4,className:p(ne,`placeholder:italic`)}),(0,P.jsx)(`span`,{className:`text-xs text-muted`,children:r(c.AUTOMATIONS$EDIT_PROMPT_HINT)})]}),(o||l.length>0)&&(0,P.jsx)(w,{testId:`edit-automation-model`,name:`model`,label:r(c.AUTOMATIONS$DETAIL$MODEL),items:f,selectedKey:h.model||J,isLoading:o,placeholder:r(c.COMMON$ACTIVE_PROFILE),onSelectionChange:e=>g(t=>({...t,model:e&&e!==J?String(e):``}))}),e.trigger.type===`event`?(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-[var(--oh-surface-raised)] p-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(c.AUTOMATIONS$DETAIL$TRIGGER)}),(0,P.jsx)(`span`,{className:`text-sm text-content`,children:r(c.AUTOMATIONS$DETAIL$TRIGGER_EVENT)})]}),e.trigger.source&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(c.AUTOMATIONS$DETAIL$EVENT_SOURCE)}),(0,P.jsx)(`span`,{className:`text-sm text-content`,children:e.trigger.source})]}),e.trigger.on&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(c.AUTOMATIONS$DETAIL$EVENT_TYPE)}),(0,P.jsx)(`code`,{className:`text-xs font-mono text-content`,children:K(e.trigger.on)})]}),e.trigger.filter&&(0,P.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(c.AUTOMATIONS$DETAIL$EVENT_FILTER)}),(0,P.jsx)(`code`,{className:`text-xs font-mono text-content break-all`,children:e.trigger.filter})]})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(w,{testId:`edit-automation-frequency`,name:`frequency`,label:r(c.AUTOMATIONS$FREQUENCY),items:x,selectedKey:h.frequency,isDisabled:h.isCustomSchedule,onSelectionChange:e=>{!e||h.isCustomSchedule||g(t=>({...t,frequency:e}))}}),h.frequency===`weekly`&&!h.isCustomSchedule&&(0,P.jsx)(w,{testId:`edit-automation-weekday`,name:`weekday`,label:r(c.AUTOMATIONS$WEEKDAY),items:S,selectedKey:String(h.weekday),onSelectionChange:e=>{e!==null&&g(t=>({...t,weekday:Number(e)}))}}),(0,P.jsxs)(`label`,{className:`flex flex-col gap-2.5 w-full min-w-0`,children:[(0,P.jsx)(`span`,{className:`text-sm`,children:r(c.AUTOMATIONS$TIME_OF_DAY)}),(0,P.jsx)(`input`,{"data-testid":`edit-automation-time`,name:`timeOfDay`,type:`time`,value:h.timeOfDay,onChange:e=>g(t=>({...t,timeOfDay:e.target.value})),disabled:h.isCustomSchedule&&!C,className:p(te,`disabled:bg-[var(--oh-surface-raised)]`)}),e.timezone&&(0,P.jsxs)(`span`,{className:`text-xs text-muted`,children:[r(c.AUTOMATIONS$TIMEZONE),`: `,e.timezone]})]}),h.isCustomSchedule&&(0,P.jsxs)(`p`,{className:`text-xs text-muted`,"data-testid":`custom-schedule-hint`,children:[r(c.AUTOMATIONS$CUSTOM_SCHEDULE_HINT),h.rawSchedule&&(0,P.jsxs)(P.Fragment,{children:[` `,(0,P.jsx)(`code`,{className:`text-xs text-content`,children:h.rawSchedule})]})]})]}),(0,P.jsxs)(`div`,{className:`mt-2 flex justify-end gap-3`,children:[(0,P.jsx)(y,{testId:`edit-automation-cancel`,type:`button`,variant:`secondary`,onClick:n,isDisabled:i.isPending,children:r(c.AUTOMATIONS$CANCEL)}),(0,P.jsx)(y,{testId:`edit-automation-save`,type:`submit`,variant:`primary`,isDisabled:i.isPending,"aria-busy":i.isPending,children:i.isPending?r(c.AUTOMATIONS$SAVING):r(c.AUTOMATIONS$SAVE)})]})]})]})]})}var Y=new Set([`cron`,`schedule`,`event`]),X=class extends Error{issues;constructor(e){super(e.join(`
|
|
2
2
|
`)),this.name=`AutomationFileValidationError`,this.issues=e}};function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e,t,n,r){let i=e[t];if(typeof i!=`string`||i.trim().length===0){r.push(`${n}: expected a non-empty string`);return}return i}function $(e,t,n,r){let i=e[t];if(i!==void 0){if(typeof i!=`string`){r.push(`${n}: expected a string`);return}return i}}function Ie(e,t){if(!Z(e)){t.push(`spec.trigger: expected an object`);return}let n=Q(e,`type`,`spec.trigger.type`,t);n&&!Y.has(n)&&t.push(`spec.trigger.type: expected one of "cron", "schedule", or "event"`);let r=$(e,`schedule`,`spec.trigger.schedule`,t),i=$(e,`schedule_human`,`spec.trigger.schedule_human`,t),a=$(e,`timezone`,`spec.trigger.timezone`,t),o=$(e,`source`,`spec.trigger.source`,t),s=$(e,`filter`,`spec.trigger.filter`,t),c;if(e.on!==void 0&&(typeof e.on==`string`||Array.isArray(e.on)&&e.on.length>0&&e.on.every(e=>typeof e==`string`&&e.trim().length>0)?c=e.on:t.push(`spec.trigger.on: expected a string or a non-empty array of strings`)),(n===`cron`||n===`schedule`)&&!r?.trim()&&t.push(`spec.trigger.schedule: required for a scheduled trigger`),n===`event`&&(o?.trim()||t.push(`spec.trigger.source: required for an event trigger`),(c===void 0||typeof c==`string`&&c.trim().length===0)&&t.push(`spec.trigger.on: required for an event trigger`)),!(!n||!Y.has(n)))return{type:n,...r!==void 0&&{schedule:r},...i!==void 0&&{schedule_human:i},...a!==void 0&&{timezone:a},...o!==void 0&&{source:o},...c!==void 0&&{on:c},...s!==void 0&&{filter:s}}}function Le(e){let t=e.timezone??e.trigger.timezone;return{version:1,kind:`automation`,spec:{name:e.name,trigger:{...e.trigger},enabled:e.enabled,prompt:e.prompt,...e.repository!==void 0&&{repository:e.repository},...e.model!==void 0&&{model:e.model},...e.branch!==void 0&&{branch:e.branch},...e.plugins!==void 0&&{plugins:[...e.plugins]},...e.notification!==void 0&&{notification:e.notification},...t!==void 0&&{timezone:t}}}}function Re(e){return`${e.name.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||e.id}.automation.json`}function ze(e){let t=[];if(!Z(e))throw new X([`file: expected a JSON object`]);if(e.version!==1&&t.push(`version: expected 1`),e.kind!==`automation`&&t.push(`kind: expected "automation"`),!Z(e.spec))throw t.push(`spec: expected an object`),new X(t);let n=Q(e.spec,`name`,`spec.name`,t),r=Q(e.spec,`prompt`,`spec.prompt`,t),i=Ie(e.spec.trigger,t),a=e.spec.enabled;typeof a!=`boolean`&&t.push(`spec.enabled: expected a boolean`);let o=$(e.spec,`repository`,`spec.repository`,t),s=$(e.spec,`branch`,`spec.branch`,t),c=$(e.spec,`notification`,`spec.notification`,t),l=$(e.spec,`timezone`,`spec.timezone`,t),u;e.spec.model===null||e.spec.model===void 0||typeof e.spec.model==`string`&&e.spec.model.trim().length>0?u=e.spec.model:t.push(`spec.model: expected a non-empty string or null`);let d;if(e.spec.plugins!==void 0&&(Array.isArray(e.spec.plugins)&&e.spec.plugins.every(e=>typeof e==`string`&&e.trim().length>0)?d=[...e.spec.plugins]:t.push(`spec.plugins: expected an array of non-empty strings`)),t.length>0||!n||!r||!i)throw new X(t);return{name:n,prompt:r,trigger:i,enabled:a,...o!==void 0&&{repository:o},...u!==void 0&&{model:u},...s!==void 0&&{branch:s},...d!==void 0&&{plugins:d},...c!==void 0&&{notification:c},...l!==void 0&&{timezone:l}}}export{me as C,de as D,ue as E,M as O,B as S,pe as T,be as _,Me as a,ge as b,q as c,K as d,we as f,xe as g,Se as h,Fe as i,ke as l,H as m,ze as n,je as o,Ce as p,Le as r,Ae as s,Re as t,Oe as u,V as v,R as w,fe as x,ve as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{Ct as t,bt as n,xt as r}from"./vendor-styling-CI0PQ3ab.js";import{L as i}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~byh8a1g4-XNPdpuO8.js";import{t as a}from"./Trans-DY6toRDu.js";import{t as o}from"./useTranslation-CDRCKC9-.js";import{t as s}from"./declaration-gq8V5eTU.js";import{y as c}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~ncdxw0bh-ClHnt5lR.js";import{A as l,M as u,j as d,n as f}from"./active-backend-context-B3umL5R-.js";import{t as p}from"./createLucideIcon-CVAsW2Yo.js";import{t as m}from"./check-Bvi71siz.js";import{i as h,t as g}from"./utils-D3U3rlqr.js";import{t as _}from"./modal-backdrop-zVwfOJZr.js";import{n as v}from"./modal-classes-Cf-4tbHz.js";import{t as y}from"./brand-button-vMVuyDXu.js";import{n as b}from"./navigation-context-DPs2G0X8.js";import{t as x}from"./styled-tooltip-CgX2oRaK.js";import{u as S}from"./dropdown-classes-DJSXeLqc.js";import{t as C}from"./modal-close-button-B6CfxxJj.js";import{t as ee}from"./use-tracking-2ZwQwpg_.js";import{n as w,t as te}from"./recommended-automations-launcher-CVEF_1pc.js";import{n as T,t as E}from"./context-menu-list-item-BD5_EaKN.js";import{t as D}from"./u-edit-DJ90xc8Z.js";import{t as O}from"./folder-mMWFvaw0.js";import{t as k}from"./search-BsjCEFNf.js";import{a as A,i as j,n as M,o as N,r as ne,t as P}from"./extension-module-card-classes-9V3J9J_b.js";import{n as F}from"./skill-card-pill-row-eTIkE4nz.js";import{n as I,t as re}from"./use-launch-skill-in-chat-BnoDgvAy.js";import{C as ie,S as ae,T as oe,_ as L,a as se,b as ce,d as R,f as z,g as B,h as V,i as le,l as H,m as U,n as ue,o as de,p as W,r as fe,s as pe,t as me,u as G,v as K,w as he,x as ge,y as q}from"./automation-export-FWY9LPsG.js";var _e=p(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),ve=p(`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`}]]),ye=p(`file-up`,[[`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:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),be=p(`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`}]]),xe=p(`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`}]]),J=e(t(),1),Y=n();function Se({value:e,onChange:t,className:n}){let{t:r}=o(`openhands`);return(0,Y.jsxs)(`div`,{className:g(`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,Y.jsx)(k,{className:`ml-3 size-4 shrink-0 text-tertiary-alt`,"aria-hidden":!0}),(0,Y.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:r(s.AUTOMATIONS$SEARCH_PLACEHOLDER),"aria-label":r(s.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 X(e,t){let n=[];if(e.repository&&n.push({id:`repository`,node:(0,Y.jsxs)(`span`,{className:g(j,`gap-1`),children:[(0,Y.jsx)(O,{className:`size-3 shrink-0`}),e.repository]})}),e.trigger.type===`event`){let t=[e.trigger.on?R(e.trigger.on):``,e.trigger.source?`(${e.trigger.source})`:``].filter(Boolean).join(` `);n.push({id:`event-trigger`,node:(0,Y.jsxs)(`span`,{className:g(j,`gap-1`),children:[(0,Y.jsx)(W,{className:`size-3 shrink-0`}),t]})})}else n.push({id:`schedule`,node:(0,Y.jsxs)(`span`,{className:g(j,`gap-1`),children:[(0,Y.jsx)(U,{className:`size-3 shrink-0`}),t]})});return e.model&&n.push({id:`model`,node:(0,Y.jsxs)(`span`,{className:g(j,`gap-1`),children:[(0,Y.jsx)(z,{className:`size-3 shrink-0`}),e.model]})}),n}function Ce({automation:e,t,canManage:n,onRunNow:r,isRunPending:i,onView:a,onExport:o,onEdit:c,onToggle:l,onDelete:u}){return[...n?[{label:t(s.AUTOMATIONS$RUN_NOW),icon:(0,Y.jsx)(V,{className:`size-4`}),onClick:()=>r(e.id),disabled:i||!e.enabled}]:[],{label:t(s.COMMON$VIEW),icon:(0,Y.jsx)(ve,{className:`size-4`,"aria-hidden":!0}),onClick:a},{label:t(s.AUTOMATIONS$EXPORT),icon:(0,Y.jsx)(_e,{className:`size-4`,"aria-hidden":!0}),onClick:()=>o(e)},...n&&c?[{label:t(s.AUTOMATIONS$EDIT),icon:(0,Y.jsx)(D,{className:`size-4`}),onClick:()=>c(e.id)}]:[],...n?[{label:e.enabled?t(s.AUTOMATIONS$TURN_OFF):t(s.AUTOMATIONS$TURN_ON),icon:(0,Y.jsx)(G,{className:`size-4`}),onClick:()=>l(e.id,e.enabled)},{label:t(s.AUTOMATIONS$DELETE),icon:(0,Y.jsx)(H,{className:`size-4`}),onClick:()=>u(e.id)}]:[]]}function we({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onExport:a,onEdit:c}){let{navigate:l}=b(),{t:u}=o(`openhands`),d=B(`manage_automations`),f=e.trigger.schedule_human||e.trigger.type,p=(0,J.useMemo)(()=>X(e,f),[e,f]),m=()=>{l?.(`/automations/${e.id}`)},h=Ce({automation:e,t:u,canManage:d,onRunNow:n,isRunPending:r,onView:m,onExport:a,onEdit:c,onToggle:t,onDelete:i}),_=()=>{m()};return(0,Y.jsxs)(`div`,{role:`link`,tabIndex:0,"data-testid":`automation-card-${e.id}`,onClick:_,onKeyDown:e=>{e.key===`Enter`&&_()},className:g(`flex min-w-0 flex-col gap-3 overflow-hidden p-4 text-left`,A,ne),children:[(0,Y.jsxs)(`header`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,Y.jsxs)(`h3`,{className:`flex items-center gap-2 truncate text-sm font-semibold text-white`,children:[e.trigger.type===`event`?(0,Y.jsx)(W,{className:`size-4 shrink-0 text-muted`}):(0,Y.jsx)(U,{className:`size-4 shrink-0 text-muted`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name})]}),e.prompt?(0,Y.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-tertiary-light`,children:e.prompt}):null]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[d?(0,Y.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:q,children:[(0,Y.jsx)(V,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),u(s.AUTOMATIONS$RUN_NOW)]}):null,(0,Y.jsx)(L,{items:h})]})]}),p.length>0?(0,Y.jsx)(F,{pills:p,testId:`automation-pills-${e.id}`}):null]})}var Te=`overflow-hidden rounded-md border border-[var(--oh-border)] bg-base-secondary`,Ee=[`h-11`,`border-t border-[var(--oh-border)] transition-colors`].join(` `),De=`hover:bg-interactive-hover-low outline-none focus:outline-none focus-visible:outline-none focus-visible:bg-interactive-hover-low`,Oe=`px-3 align-middle`,ke=[Ee,De,`cursor-pointer`].join(` `),Ae=`openhands-automations-view`;function je(){return typeof window>`u`?`grid`:window.localStorage.getItem(`openhands-automations-view`)===`list`?`list`:`grid`}function Me(e){window.localStorage.setItem(Ae,e)}function Ne({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onExport:a,onEdit:c}){let{navigate:l}=b(),{t:u}=o(`openhands`),d=B(`manage_automations`),f=e.trigger.schedule_human||e.trigger.type,p=(0,J.useMemo)(()=>X(e,f),[e,f]),m=()=>{l?.(`/automations/${e.id}`)},h=Ce({automation:e,t:u,canManage:d,onRunNow:n,isRunPending:r,onView:m,onExport:a,onEdit:c,onToggle:t,onDelete:i}),_=()=>{m()};return(0,Y.jsxs)(`tr`,{"data-testid":`automation-list-row-${e.id}`,onClick:_,onKeyDown:e=>{e.key===`Enter`&&_()},tabIndex:0,className:g(ke,`cursor-pointer`),children:[(0,Y.jsx)(`td`,{className:Oe,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.trigger.type===`event`?(0,Y.jsx)(W,{className:`size-4 shrink-0 text-muted`}):(0,Y.jsx)(U,{className:`size-4 shrink-0 text-muted`}),(0,Y.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate text-sm font-medium text-white`,title:e.name,children:e.name}),p.length>0?(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(F,{pills:p,testId:`automation-pills-${e.id}`})}):null]})}),(0,Y.jsx)(`td`,{className:g(`w-0 whitespace-nowrap`,Oe),children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[d?(0,Y.jsx)(x,{content:u(s.AUTOMATIONS$RUN_NOW),placement:`top`,children:(0,Y.jsx)(`button`,{type:`button`,"data-testid":`automation-run-now-${e.id}`,"aria-label":u(s.AUTOMATIONS$RUN_NOW),"aria-busy":r,disabled:r||!e.enabled,onClick:t=>{t.stopPropagation(),n(e.id)},className:K,children:(0,Y.jsx)(V,{className:`size-4 shrink-0`,"aria-hidden":!0})})}):null,(0,Y.jsx)(L,{items:h})]})})]})}function Pe({title:e,count:t,automations:n,view:r,onToggle:i,onRunNow:a,runPendingId:o=null,onDelete:s,onExport:c,onEdit:l}){return n.length===0?null:(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center`,children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:e}),(0,Y.jsx)(w,{count:t})]}),r===`grid`?(0,Y.jsx)(`div`,{className:g(`mt-3`,M),children:(0,Y.jsx)(`div`,{className:P,children:n.map(e=>(0,Y.jsx)(we,{automation:e,onToggle:i,onRunNow:a,isRunPending:o===e.id,onDelete:s,onExport:c,onEdit:l},e.id))})}):(0,Y.jsx)(`div`,{className:g(Te,`mt-3`),children:(0,Y.jsx)(`table`,{className:`w-full min-w-full [&>tbody>tr:first-child]:border-t-0`,children:(0,Y.jsx)(`tbody`,{children:n.map(e=>(0,Y.jsx)(Ne,{automation:e,onToggle:i,onRunNow:a,isRunPending:o===e.id,onDelete:s,onExport:c,onEdit:l},e.id))})})})]})}var Fe=e(r(),1);function Ie({icon:e,label:t,isSelected:n}){return(0,Y.jsxs)(`span`,{className:`flex min-w-0 w-full items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:S,"aria-hidden":!0,children:(0,Y.jsx)(e,{})}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),n?(0,Y.jsx)(m,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]})}var Z=[{value:`grid`,icon:be,labelKey:s.AUTOMATIONS$VIEW_GRID,testId:`automations-view-toggle-grid`},{value:`list`,icon:xe,labelKey:s.AUTOMATIONS$VIEW_LIST,testId:`automations-view-toggle-list`}];function Le({view:e,onChange:t,disabled:n=!1}){let{t:r}=o(`openhands`),[i,a]=(0,J.useState)(!1),[c,l]=(0,J.useState)(),u=(0,J.useRef)(null),d=(0,J.useRef)(null),f=(Z.find(t=>t.value===e)??Z[0]).icon;(0,J.useLayoutEffect)(()=>{if(!i||!u.current)return;let e=()=>{let e=u.current?.getBoundingClientRect();e&&l({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,J.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;u.current?.contains(t)||d.current?.contains(t)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let p=i&&c?(0,Y.jsx)(T,{ref:d,theme:`popover`,className:`min-w-[10rem]`,children:Z.map(n=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(E,{testId:n.testId,onClick:()=>{t(n.value),a(!1)},className:`group`,children:(0,Y.jsx)(Ie,{icon:n.icon,label:r(n.labelKey),isSelected:e===n.value})})},n.value))}):null;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{ref:u,type:`button`,"data-testid":`automations-view-toggle`,"aria-label":r(s.AUTOMATIONS$VIEW_MODE),"aria-haspopup":`menu`,"aria-expanded":i,"aria-disabled":n,disabled:n,onClick:()=>{n||a(e=>!e)},className:g(`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,Y.jsx)(f,{className:`size-4`,"aria-hidden":!0})}),i&&c&&typeof document<`u`?Fe.createPortal((0,Y.jsx)(`div`,{style:c,children:p}),document.body):null]})}function Re(){return(0,Y.jsxs)(`div`,{"data-testid":`automation-card-skeleton`,className:`${A} border border-transparent p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,Y.jsx)(`div`,{className:`h-5 w-40 animate-pulse rounded bg-surface-raised`}),(0,Y.jsx)(`div`,{className:`h-5 w-10 animate-pulse rounded-full bg-surface-raised`})]}),(0,Y.jsx)(`div`,{className:`mt-2 h-4 w-72 animate-pulse rounded bg-surface-raised`}),(0,Y.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,Y.jsx)(`div`,{className:`h-7 w-32 animate-pulse rounded-full bg-surface-raised`}),(0,Y.jsx)(`div`,{className:`h-7 w-28 animate-pulse rounded-full bg-surface-raised`}),(0,Y.jsx)(`div`,{className:`h-7 w-24 animate-pulse rounded-full bg-surface-raised`})]})]})}var ze=e=>(0,Y.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,Y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m19.5 8.25-7.5 7.5-7.5-7.5`})}),Be=`https://docs.openhands.dev/openhands/usage/automations/overview`;function Ve({children:e}){return(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:e})}function He({children:e}){return(0,Y.jsx)(`code`,{"data-testid":`automations-create-instructions-example`,className:g(`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 Ue({children:e}){return(0,Y.jsx)(Y.Fragment,{children:e})}var We={example:(0,Y.jsx)(Ve,{}),cmd:(0,Y.jsx)(He,{}),punct:(0,Y.jsx)(Ue,{})};function Q({onLaunch:e}={}){let{t}=o(`openhands`),n=re(),r=f(),{trackAutomationCreated:i}=ee();return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Y.jsxs)(`p`,{className:`text-sm leading-relaxed text-tertiary-light`,children:[(0,Y.jsx)(a,{ns:`openhands`,i18nKey:s.AUTOMATIONS$EMPTY_OPTION_CONVERSATION_DESC,components:We}),` `,t(s.AUTOMATIONS$CREATE_INSTRUCTIONS_GUIDANCE)]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Y.jsx)(`a`,{href:Be,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-muted underline transition-colors hover:text-foreground`,children:t(s.AUTOMATIONS$EMPTY_LEARN_MORE)}),(0,Y.jsx)(y,{type:`button`,variant:`primary`,testId:`automations-create-automation`,onClick:()=>{i({backendKind:r.backend.kind}),n(t(s.AUTOMATIONS$CREATE_AUTOMATION_PROMPT),e)},startContent:(0,Y.jsx)(I,{className:`size-4`,"aria-hidden":!0}),children:t(s.AUTOMATIONS$CREATE_AUTOMATION_BUTTON)})]})]})}function Ge({collapsible:e=!1}){let{t}=o(`openhands`),[n,r]=(0,J.useState)(!e);return e?(0,Y.jsxs)(`div`,{className:`w-full rounded-lg border border-[var(--oh-border)] bg-[var(--oh-surface)]`,children:[(0,Y.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,Y.jsx)(`span`,{className:`text-sm font-normal text-content`,children:t(s.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,Y.jsx)(ze,{className:g(`size-5 text-muted transition-transform`,n&&`rotate-180`)})]}),n?(0,Y.jsx)(`div`,{className:`px-4 pb-4`,children:(0,Y.jsx)(Q,{})}):null]}):(0,Y.jsxs)(`div`,{className:`w-full max-w-2xl`,children:[(0,Y.jsx)(`h3`,{className:`text-center text-sm font-medium text-content`,children:t(s.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(Q,{})})]})}function Ke(){let{t:e}=o(`openhands`);return(0,Y.jsxs)(`div`,{"data-testid":`automations-empty`,className:N,children:[(0,Y.jsx)(`p`,{className:`text-sm text-white`,children:e(s.AUTOMATIONS$EMPTY)}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-tertiary-light`,children:e(s.AUTOMATIONS$EMPTY_HINT)}),(0,Y.jsx)(`div`,{className:`mt-8 flex justify-center border-t border-[var(--oh-border)] pt-8`,children:(0,Y.jsx)(Ge,{})})]})}function qe({isOpen:e,onClose:t}){let{t:n}=o(`openhands`);return e?(0,Y.jsx)(_,{onClose:t,"aria-label":n(s.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE),children:(0,Y.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,Y.jsx)(C,{onClose:t,testId:`add-automation-modal-close`}),(0,Y.jsx)(`header`,{className:`flex-shrink-0 px-6 pb-4 pt-6`,children:(0,Y.jsx)(`h2`,{id:`add-automation-modal-title`,className:g(`pr-6`,v),children:n(s.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)})}),(0,Y.jsx)(`div`,{className:`px-6 pb-6`,children:(0,Y.jsx)(Q,{onLaunch:t})})]})}):null}function $({label:e,value:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-muted`,children:e}),(0,Y.jsx)(`dd`,{className:`whitespace-pre-wrap break-words text-sm text-content`,children:t})]})}function Je({isOpen:e,spec:t,isImporting:n,onClose:r,onImport:i}){let{t:a}=o(`openhands`);if(!e||!t)return null;let c=t.trigger.type===`event`?[t.trigger.source,R(t.trigger.on)].filter(Boolean).join(`: `):[t.trigger.schedule_human??t.trigger.schedule,t.timezone??t.trigger.timezone].filter(Boolean).join(` · `);return(0,Y.jsx)(_,{onClose:n?void 0:r,closeOnEscape:!n,closeOnBackdropClick:!n,"aria-label":a(s.AUTOMATIONS$IMPORT),children:(0,Y.jsxs)(`div`,{"data-testid":`import-automation-modal`,className:`relative flex max-h-[85vh] w-[min(36rem,calc(100vw-2rem))] flex-col rounded-xl border border-[var(--oh-border)] bg-base-secondary`,children:[(0,Y.jsx)(C,{onClose:r,testId:`import-automation-modal-close`,disabled:n}),(0,Y.jsxs)(`header`,{className:`px-6 pb-4 pt-6`,children:[(0,Y.jsx)(`h2`,{className:g(`pr-6`,v),children:a(s.AUTOMATIONS$IMPORT)}),(0,Y.jsx)(`p`,{className:`mt-2 text-sm text-tertiary-light`,children:a(s.AUTOMATIONS$IMPORT_PREVIEW_DESCRIPTION)})]}),(0,Y.jsxs)(`dl`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto border-y border-[var(--oh-border)] px-6 py-5`,children:[(0,Y.jsx)($,{label:a(s.AUTOMATIONS$NAME),value:t.name}),(0,Y.jsx)($,{label:a(s.AUTOMATIONS$DETAIL$TRIGGER),value:c}),(0,Y.jsx)($,{label:a(s.AUTOMATIONS$PROMPT),value:t.prompt??``}),t.plugins&&t.plugins.length>0?(0,Y.jsx)($,{label:a(s.AUTOMATIONS$DETAIL$PLUGINS),value:t.plugins.join(`, `)}):null]}),(0,Y.jsxs)(`footer`,{className:`px-6 py-5`,children:[(0,Y.jsx)(`p`,{className:`mb-4 text-sm text-tertiary-light`,children:a(s.AUTOMATIONS$IMPORT_DISABLED_NOTICE)}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,Y.jsx)(y,{testId:`import-automation-cancel`,type:`button`,variant:`secondary`,onClick:r,isDisabled:n,children:a(s.AUTOMATIONS$CANCEL)}),(0,Y.jsx)(y,{testId:`import-automation-confirm`,type:`button`,variant:`primary`,onClick:i,isDisabled:n,"aria-busy":n,children:a(n?s.AUTOMATIONS$IMPORTING:s.AUTOMATIONS$IMPORT)})]})]})]})})}var Ye=50,Xe=i(function(){let{t:e}=o(`openhands`),[t,n]=(0,J.useState)(``),[r,i]=(0,J.useState)(()=>je()),[a,p]=(0,J.useState)(Ye),[m,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null),[b,x]=(0,J.useState)(!1),[S,C]=(0,J.useState)(null),w=(0,J.useRef)(null),T=f(),E=T.backend.kind===`local`,{data:D,isLoading:O,refetch:k}=ce(),A=D?.status===`ok`,{data:j,isLoading:M,isError:N,refetch:ne}=ge({limit:a,offset:0,enabled:A}),{trackPrebuiltAutomationEnabled:P,trackAutomationExported:F}=ee(),I=oe(),re=ae(),L=ie(),R=he(),z=(0,J.useMemo)(()=>{if(!j?.automations)return[];let e=t.toLowerCase();return e?j.automations.filter(t=>t.name.toLowerCase().includes(e)||(t.prompt??``).toLowerCase().includes(e)||t.repository?.toLowerCase().includes(e)||t.model?.toLowerCase().includes(e)):j.automations},[j?.automations,t]),B=(0,J.useMemo)(()=>z.filter(e=>e.enabled),[z]),V=(0,J.useMemo)(()=>z.filter(e=>!e.enabled),[z]),H=(e,t)=>{let n=!t;if(I.mutate({id:e,enabled:n}),n){let t=j?.automations.find(t=>t.id===e);P({automationId:e,automationName:t?.name??e})}},U=t=>{L.mutate(t,{onSuccess:()=>{d(e(s.AUTOMATIONS$RUN_NOW_SUCCESS))},onError:t=>{l(c(t)?t.response?.data?.message||t.message||e(s.AUTOMATIONS$RUN_NOW_ERROR):t.message||e(s.AUTOMATIONS$RUN_NOW_ERROR))}})},W=e=>{let t=j?.automations.find(t=>t.id===e);t&&g({id:e,name:t.name})},G=e=>{let t=j?.automations.find(t=>t.id===e);t&&v(t)},K=e=>{let t=`${JSON.stringify(fe(e),null,2)}\n`;h(new Blob([t],{type:`application/json`}),me(e)),F({backendKind:T.backend.kind})},q=async t=>{let n=t.currentTarget,r=n.files?.[0];if(n.value=``,r)try{let t;try{t=JSON.parse(await r.text())}catch{l(e(s.AUTOMATIONS$IMPORT_INVALID_JSON));return}C(ue(t))}catch(t){l(t instanceof Error?t.message:e(s.ERROR$GENERIC))}},_e=()=>{S&&R.mutate({...S,enabled:!1},{onSuccess:t=>{C(null),u(e(s.AUTOMATIONS$IMPORT_SUCCESS,{name:t.name}),e(s.AUTOMATIONS$IMPORT_VIEW),`/automations/${encodeURIComponent(t.id)}`)},onError:t=>{let n=c(t)?t.response?.data?.detail:void 0;l(typeof n==`string`?n:c(t)?t.message:e(s.ERROR$GENERIC))}})},ve=()=>{m&&(re.mutate(m.id),g(null))},be=(0,J.useCallback)(e=>{i(e),Me(e)},[]),xe=j?j.total>j.automations.length:!1,X=!M&&!N&&j?.automations.length===0;return O?(0,Y.jsx)(`div`,{className:`min-h-full`,children:(0,Y.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(s.AUTOMATIONS$TITLE)}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(s.AUTOMATIONS$SUBTITLE)}),(0,Y.jsx)(`div`,{className:`mt-6 flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,Y.jsx)(Re,{},`skeleton-${String(t)}`))})]})}):A?(0,Y.jsx)(`div`,{className:`min-h-full`,children:(0,Y.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-semibold text-content`,children:e(s.AUTOMATIONS$TITLE)}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(s.AUTOMATIONS$SUBTITLE)})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2`,children:[(0,Y.jsx)(y,{type:`button`,variant:`secondary`,testId:`automations-import-automation`,className:`whitespace-nowrap`,onClick:()=>w.current?.click(),startContent:(0,Y.jsx)(ye,{className:`size-4`,"aria-hidden":!0}),children:e(s.AUTOMATIONS$IMPORT)}),(0,Y.jsx)(`input`,{ref:w,type:`file`,accept:`application/json,.json`,className:`hidden`,"data-testid":`automations-import-file`,onChange:q}),(0,Y.jsx)(y,{type:`button`,variant:`secondary`,testId:`automations-add-automation`,className:`whitespace-nowrap`,onClick:()=>x(!0),children:e(s.AUTOMATIONS$ADD_AUTOMATION)})]})]}),(0,Y.jsxs)(`div`,{className:`mt-6 flex items-stretch gap-2`,children:[(0,Y.jsx)(Se,{value:t,onChange:n}),(0,Y.jsx)(Le,{view:r,onChange:be,disabled:X})]}),(0,Y.jsxs)(`div`,{className:`mt-6 flex flex-col gap-6`,children:[M&&(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,Y.jsx)(Re,{},`skeleton-${String(t)}`))}),N&&!M&&(0,Y.jsx)(pe,{onRetry:ne}),X&&(0,Y.jsx)(Ke,{}),!M&&!N&&j&&j.automations.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Pe,{title:e(s.AUTOMATIONS$ACTIVE),count:B.length,automations:B,view:r,onToggle:H,onRunNow:U,runPendingId:L.isPending?L.variables??null:null,onDelete:W,onExport:K,onEdit:E?G:void 0}),(0,Y.jsx)(Pe,{title:e(s.AUTOMATIONS$INACTIVE),count:V.length,automations:V,view:r,onToggle:H,onRunNow:U,runPendingId:L.isPending?L.variables??null:null,onDelete:W,onExport:K,onEdit:E?G:void 0}),xe&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>p(e=>e+Ye),className:`self-center rounded-lg border border-[var(--oh-border)] px-6 py-2 text-sm text-white hover:bg-surface-raised`,children:e(s.AUTOMATIONS$LOAD_MORE)})]})]}),(0,Y.jsx)(`div`,{className:`mt-6`,children:(0,Y.jsx)(te,{query:t})}),(0,Y.jsx)(se,{automationName:m?.name??``,isOpen:m!==null,onConfirm:ve,onCancel:()=>g(null)}),_&&(0,Y.jsx)(le,{automation:_,isOpen:_!==null,onClose:()=>v(null)}),(0,Y.jsx)(qe,{isOpen:b,onClose:()=>x(!1)}),(0,Y.jsx)(Je,{isOpen:S!==null,spec:S,isImporting:R.isPending,onClose:()=>C(null),onImport:_e})]})}):(0,Y.jsx)(`div`,{className:`min-h-full`,children:(0,Y.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(s.AUTOMATIONS$TITLE)}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(s.AUTOMATIONS$SUBTITLE)}),(0,Y.jsx)(de,{onRetry:k})]})})});export{Xe as default};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{Ct as t,bt as n,xt as r}from"./vendor-styling-CI0PQ3ab.js";import{L as i}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~byh8a1g4-XNPdpuO8.js";import{t as a}from"./Trans-Ch-OVWEA.js";import{t as o}from"./useTranslation-CDRCKC9-.js";import{t as s}from"./declaration-gq8V5eTU.js";import{y as c}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~lf310vj7-CSVPGId3.js";import{A as l,M as u,j as d,n as f}from"./active-backend-context-hxq31W25.js";import{t as p}from"./createLucideIcon-CVAsW2Yo.js";import{t as m}from"./check-Bvi71siz.js";import{i as h,t as g}from"./utils-D3U3rlqr.js";import{t as _}from"./modal-backdrop-zVwfOJZr.js";import{n as v}from"./modal-classes-Cf-4tbHz.js";import{t as y}from"./brand-button-vMVuyDXu.js";import{n as b}from"./navigation-context-DPs2G0X8.js";import{t as x}from"./styled-tooltip-CgX2oRaK.js";import{u as S}from"./dropdown-classes-DJSXeLqc.js";import{t as C}from"./modal-close-button-B6CfxxJj.js";import{t as ee}from"./use-tracking-BIXzagSI.js";import{n as w,t as te}from"./recommended-automations-launcher-CTcGTl4d.js";import{n as T,t as E}from"./context-menu-list-item-BD5_EaKN.js";import{t as D}from"./u-edit-DJ90xc8Z.js";import{t as O}from"./folder-mMWFvaw0.js";import{t as k}from"./search-BsjCEFNf.js";import{a as A,i as j,n as M,o as N,r as ne,t as P}from"./extension-module-card-classes-9V3J9J_b.js";import{n as F}from"./skill-card-pill-row-eTIkE4nz.js";import{n as I,t as re}from"./use-launch-skill-in-chat-BnoDgvAy.js";import{C as ie,S as ae,T as oe,_ as L,a as se,b as ce,d as R,f as z,g as B,h as V,i as le,l as H,m as U,n as ue,o as de,p as W,r as fe,s as pe,t as me,u as G,v as K,w as he,x as ge,y as q}from"./automation-export-BPcgLqPD.js";var _e=p(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),ve=p(`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`}]]),ye=p(`file-up`,[[`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:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),be=p(`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`}]]),xe=p(`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`}]]),J=e(t(),1),Y=n();function Se({value:e,onChange:t,className:n}){let{t:r}=o(`openhands`);return(0,Y.jsxs)(`div`,{className:g(`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,Y.jsx)(k,{className:`ml-3 size-4 shrink-0 text-tertiary-alt`,"aria-hidden":!0}),(0,Y.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:r(s.AUTOMATIONS$SEARCH_PLACEHOLDER),"aria-label":r(s.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 X(e,t){let n=[];if(e.repository&&n.push({id:`repository`,node:(0,Y.jsxs)(`span`,{className:g(j,`gap-1`),children:[(0,Y.jsx)(O,{className:`size-3 shrink-0`}),e.repository]})}),e.trigger.type===`event`){let t=[e.trigger.on?R(e.trigger.on):``,e.trigger.source?`(${e.trigger.source})`:``].filter(Boolean).join(` `);n.push({id:`event-trigger`,node:(0,Y.jsxs)(`span`,{className:g(j,`gap-1`),children:[(0,Y.jsx)(W,{className:`size-3 shrink-0`}),t]})})}else n.push({id:`schedule`,node:(0,Y.jsxs)(`span`,{className:g(j,`gap-1`),children:[(0,Y.jsx)(U,{className:`size-3 shrink-0`}),t]})});return e.model&&n.push({id:`model`,node:(0,Y.jsxs)(`span`,{className:g(j,`gap-1`),children:[(0,Y.jsx)(z,{className:`size-3 shrink-0`}),e.model]})}),n}function Ce({automation:e,t,canManage:n,onRunNow:r,isRunPending:i,onView:a,onExport:o,onEdit:c,onToggle:l,onDelete:u}){return[...n?[{label:t(s.AUTOMATIONS$RUN_NOW),icon:(0,Y.jsx)(V,{className:`size-4`}),onClick:()=>r(e.id),disabled:i||!e.enabled}]:[],{label:t(s.COMMON$VIEW),icon:(0,Y.jsx)(ve,{className:`size-4`,"aria-hidden":!0}),onClick:a},{label:t(s.AUTOMATIONS$EXPORT),icon:(0,Y.jsx)(_e,{className:`size-4`,"aria-hidden":!0}),onClick:()=>o(e)},...n&&c?[{label:t(s.AUTOMATIONS$EDIT),icon:(0,Y.jsx)(D,{className:`size-4`}),onClick:()=>c(e.id)}]:[],...n?[{label:e.enabled?t(s.AUTOMATIONS$TURN_OFF):t(s.AUTOMATIONS$TURN_ON),icon:(0,Y.jsx)(G,{className:`size-4`}),onClick:()=>l(e.id,e.enabled)},{label:t(s.AUTOMATIONS$DELETE),icon:(0,Y.jsx)(H,{className:`size-4`}),onClick:()=>u(e.id)}]:[]]}function we({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onExport:a,onEdit:c}){let{navigate:l}=b(),{t:u}=o(`openhands`),d=B(`manage_automations`),f=e.trigger.schedule_human||e.trigger.type,p=(0,J.useMemo)(()=>X(e,f),[e,f]),m=()=>{l?.(`/automations/${e.id}`)},h=Ce({automation:e,t:u,canManage:d,onRunNow:n,isRunPending:r,onView:m,onExport:a,onEdit:c,onToggle:t,onDelete:i}),_=()=>{m()};return(0,Y.jsxs)(`div`,{role:`link`,tabIndex:0,"data-testid":`automation-card-${e.id}`,onClick:_,onKeyDown:e=>{e.key===`Enter`&&_()},className:g(`flex min-w-0 flex-col gap-3 overflow-hidden p-4 text-left`,A,ne),children:[(0,Y.jsxs)(`header`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,Y.jsxs)(`h3`,{className:`flex items-center gap-2 truncate text-sm font-semibold text-white`,children:[e.trigger.type===`event`?(0,Y.jsx)(W,{className:`size-4 shrink-0 text-muted`}):(0,Y.jsx)(U,{className:`size-4 shrink-0 text-muted`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name})]}),e.prompt?(0,Y.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-tertiary-light`,children:e.prompt}):null]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[d?(0,Y.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:q,children:[(0,Y.jsx)(V,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),u(s.AUTOMATIONS$RUN_NOW)]}):null,(0,Y.jsx)(L,{items:h})]})]}),p.length>0?(0,Y.jsx)(F,{pills:p,testId:`automation-pills-${e.id}`}):null]})}var Te=`overflow-hidden rounded-md border border-[var(--oh-border)] bg-base-secondary`,Ee=[`h-11`,`border-t border-[var(--oh-border)] transition-colors`].join(` `),De=`hover:bg-interactive-hover-low outline-none focus:outline-none focus-visible:outline-none focus-visible:bg-interactive-hover-low`,Oe=`px-3 align-middle`,ke=[Ee,De,`cursor-pointer`].join(` `),Ae=`openhands-automations-view`;function je(){return typeof window>`u`?`grid`:window.localStorage.getItem(`openhands-automations-view`)===`list`?`list`:`grid`}function Me(e){window.localStorage.setItem(Ae,e)}function Ne({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onExport:a,onEdit:c}){let{navigate:l}=b(),{t:u}=o(`openhands`),d=B(`manage_automations`),f=e.trigger.schedule_human||e.trigger.type,p=(0,J.useMemo)(()=>X(e,f),[e,f]),m=()=>{l?.(`/automations/${e.id}`)},h=Ce({automation:e,t:u,canManage:d,onRunNow:n,isRunPending:r,onView:m,onExport:a,onEdit:c,onToggle:t,onDelete:i}),_=()=>{m()};return(0,Y.jsxs)(`tr`,{"data-testid":`automation-list-row-${e.id}`,onClick:_,onKeyDown:e=>{e.key===`Enter`&&_()},tabIndex:0,className:g(ke,`cursor-pointer`),children:[(0,Y.jsx)(`td`,{className:Oe,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.trigger.type===`event`?(0,Y.jsx)(W,{className:`size-4 shrink-0 text-muted`}):(0,Y.jsx)(U,{className:`size-4 shrink-0 text-muted`}),(0,Y.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate text-sm font-medium text-white`,title:e.name,children:e.name}),p.length>0?(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(F,{pills:p,testId:`automation-pills-${e.id}`})}):null]})}),(0,Y.jsx)(`td`,{className:g(`w-0 whitespace-nowrap`,Oe),children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[d?(0,Y.jsx)(x,{content:u(s.AUTOMATIONS$RUN_NOW),placement:`top`,children:(0,Y.jsx)(`button`,{type:`button`,"data-testid":`automation-run-now-${e.id}`,"aria-label":u(s.AUTOMATIONS$RUN_NOW),"aria-busy":r,disabled:r||!e.enabled,onClick:t=>{t.stopPropagation(),n(e.id)},className:K,children:(0,Y.jsx)(V,{className:`size-4 shrink-0`,"aria-hidden":!0})})}):null,(0,Y.jsx)(L,{items:h})]})})]})}function Pe({title:e,count:t,automations:n,view:r,onToggle:i,onRunNow:a,runPendingId:o=null,onDelete:s,onExport:c,onEdit:l}){return n.length===0?null:(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center`,children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:e}),(0,Y.jsx)(w,{count:t})]}),r===`grid`?(0,Y.jsx)(`div`,{className:g(`mt-3`,M),children:(0,Y.jsx)(`div`,{className:P,children:n.map(e=>(0,Y.jsx)(we,{automation:e,onToggle:i,onRunNow:a,isRunPending:o===e.id,onDelete:s,onExport:c,onEdit:l},e.id))})}):(0,Y.jsx)(`div`,{className:g(Te,`mt-3`),children:(0,Y.jsx)(`table`,{className:`w-full min-w-full [&>tbody>tr:first-child]:border-t-0`,children:(0,Y.jsx)(`tbody`,{children:n.map(e=>(0,Y.jsx)(Ne,{automation:e,onToggle:i,onRunNow:a,isRunPending:o===e.id,onDelete:s,onExport:c,onEdit:l},e.id))})})})]})}var Fe=e(r(),1);function Ie({icon:e,label:t,isSelected:n}){return(0,Y.jsxs)(`span`,{className:`flex min-w-0 w-full items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:S,"aria-hidden":!0,children:(0,Y.jsx)(e,{})}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),n?(0,Y.jsx)(m,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]})}var Z=[{value:`grid`,icon:be,labelKey:s.AUTOMATIONS$VIEW_GRID,testId:`automations-view-toggle-grid`},{value:`list`,icon:xe,labelKey:s.AUTOMATIONS$VIEW_LIST,testId:`automations-view-toggle-list`}];function Le({view:e,onChange:t,disabled:n=!1}){let{t:r}=o(`openhands`),[i,a]=(0,J.useState)(!1),[c,l]=(0,J.useState)(),u=(0,J.useRef)(null),d=(0,J.useRef)(null),f=(Z.find(t=>t.value===e)??Z[0]).icon;(0,J.useLayoutEffect)(()=>{if(!i||!u.current)return;let e=()=>{let e=u.current?.getBoundingClientRect();e&&l({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,J.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;u.current?.contains(t)||d.current?.contains(t)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let p=i&&c?(0,Y.jsx)(T,{ref:d,theme:`popover`,className:`min-w-[10rem]`,children:Z.map(n=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(E,{testId:n.testId,onClick:()=>{t(n.value),a(!1)},className:`group`,children:(0,Y.jsx)(Ie,{icon:n.icon,label:r(n.labelKey),isSelected:e===n.value})})},n.value))}):null;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{ref:u,type:`button`,"data-testid":`automations-view-toggle`,"aria-label":r(s.AUTOMATIONS$VIEW_MODE),"aria-haspopup":`menu`,"aria-expanded":i,"aria-disabled":n,disabled:n,onClick:()=>{n||a(e=>!e)},className:g(`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,Y.jsx)(f,{className:`size-4`,"aria-hidden":!0})}),i&&c&&typeof document<`u`?Fe.createPortal((0,Y.jsx)(`div`,{style:c,children:p}),document.body):null]})}function Re(){return(0,Y.jsxs)(`div`,{"data-testid":`automation-card-skeleton`,className:`${A} border border-transparent p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,Y.jsx)(`div`,{className:`h-5 w-40 animate-pulse rounded bg-surface-raised`}),(0,Y.jsx)(`div`,{className:`h-5 w-10 animate-pulse rounded-full bg-surface-raised`})]}),(0,Y.jsx)(`div`,{className:`mt-2 h-4 w-72 animate-pulse rounded bg-surface-raised`}),(0,Y.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,Y.jsx)(`div`,{className:`h-7 w-32 animate-pulse rounded-full bg-surface-raised`}),(0,Y.jsx)(`div`,{className:`h-7 w-28 animate-pulse rounded-full bg-surface-raised`}),(0,Y.jsx)(`div`,{className:`h-7 w-24 animate-pulse rounded-full bg-surface-raised`})]})]})}var ze=e=>(0,Y.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,Y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m19.5 8.25-7.5 7.5-7.5-7.5`})}),Be=`https://docs.openhands.dev/openhands/usage/automations/overview`;function Ve({children:e}){return(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:e})}function He({children:e}){return(0,Y.jsx)(`code`,{"data-testid":`automations-create-instructions-example`,className:g(`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 Ue({children:e}){return(0,Y.jsx)(Y.Fragment,{children:e})}var We={example:(0,Y.jsx)(Ve,{}),cmd:(0,Y.jsx)(He,{}),punct:(0,Y.jsx)(Ue,{})};function Q({onLaunch:e}={}){let{t}=o(`openhands`),n=re(),r=f(),{trackAutomationCreated:i}=ee();return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Y.jsxs)(`p`,{className:`text-sm leading-relaxed text-tertiary-light`,children:[(0,Y.jsx)(a,{ns:`openhands`,i18nKey:s.AUTOMATIONS$EMPTY_OPTION_CONVERSATION_DESC,components:We}),` `,t(s.AUTOMATIONS$CREATE_INSTRUCTIONS_GUIDANCE)]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Y.jsx)(`a`,{href:Be,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-muted underline transition-colors hover:text-foreground`,children:t(s.AUTOMATIONS$EMPTY_LEARN_MORE)}),(0,Y.jsx)(y,{type:`button`,variant:`primary`,testId:`automations-create-automation`,onClick:()=>{i({backendKind:r.backend.kind}),n(t(s.AUTOMATIONS$CREATE_AUTOMATION_PROMPT),e)},startContent:(0,Y.jsx)(I,{className:`size-4`,"aria-hidden":!0}),children:t(s.AUTOMATIONS$CREATE_AUTOMATION_BUTTON)})]})]})}function Ge({collapsible:e=!1}){let{t}=o(`openhands`),[n,r]=(0,J.useState)(!e);return e?(0,Y.jsxs)(`div`,{className:`w-full rounded-lg border border-[var(--oh-border)] bg-[var(--oh-surface)]`,children:[(0,Y.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,Y.jsx)(`span`,{className:`text-sm font-normal text-content`,children:t(s.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,Y.jsx)(ze,{className:g(`size-5 text-muted transition-transform`,n&&`rotate-180`)})]}),n?(0,Y.jsx)(`div`,{className:`px-4 pb-4`,children:(0,Y.jsx)(Q,{})}):null]}):(0,Y.jsxs)(`div`,{className:`w-full max-w-2xl`,children:[(0,Y.jsx)(`h3`,{className:`text-center text-sm font-medium text-content`,children:t(s.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(Q,{})})]})}function Ke(){let{t:e}=o(`openhands`);return(0,Y.jsxs)(`div`,{"data-testid":`automations-empty`,className:N,children:[(0,Y.jsx)(`p`,{className:`text-sm text-white`,children:e(s.AUTOMATIONS$EMPTY)}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-tertiary-light`,children:e(s.AUTOMATIONS$EMPTY_HINT)}),(0,Y.jsx)(`div`,{className:`mt-8 flex justify-center border-t border-[var(--oh-border)] pt-8`,children:(0,Y.jsx)(Ge,{})})]})}function qe({isOpen:e,onClose:t}){let{t:n}=o(`openhands`);return e?(0,Y.jsx)(_,{onClose:t,"aria-label":n(s.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE),children:(0,Y.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,Y.jsx)(C,{onClose:t,testId:`add-automation-modal-close`}),(0,Y.jsx)(`header`,{className:`flex-shrink-0 px-6 pb-4 pt-6`,children:(0,Y.jsx)(`h2`,{id:`add-automation-modal-title`,className:g(`pr-6`,v),children:n(s.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)})}),(0,Y.jsx)(`div`,{className:`px-6 pb-6`,children:(0,Y.jsx)(Q,{onLaunch:t})})]})}):null}function $({label:e,value:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-muted`,children:e}),(0,Y.jsx)(`dd`,{className:`whitespace-pre-wrap break-words text-sm text-content`,children:t})]})}function Je({isOpen:e,spec:t,isImporting:n,onClose:r,onImport:i}){let{t:a}=o(`openhands`);if(!e||!t)return null;let c=t.trigger.type===`event`?[t.trigger.source,R(t.trigger.on)].filter(Boolean).join(`: `):[t.trigger.schedule_human??t.trigger.schedule,t.timezone??t.trigger.timezone].filter(Boolean).join(` · `);return(0,Y.jsx)(_,{onClose:n?void 0:r,closeOnEscape:!n,closeOnBackdropClick:!n,"aria-label":a(s.AUTOMATIONS$IMPORT),children:(0,Y.jsxs)(`div`,{"data-testid":`import-automation-modal`,className:`relative flex max-h-[85vh] w-[min(36rem,calc(100vw-2rem))] flex-col rounded-xl border border-[var(--oh-border)] bg-base-secondary`,children:[(0,Y.jsx)(C,{onClose:r,testId:`import-automation-modal-close`,disabled:n}),(0,Y.jsxs)(`header`,{className:`px-6 pb-4 pt-6`,children:[(0,Y.jsx)(`h2`,{className:g(`pr-6`,v),children:a(s.AUTOMATIONS$IMPORT)}),(0,Y.jsx)(`p`,{className:`mt-2 text-sm text-tertiary-light`,children:a(s.AUTOMATIONS$IMPORT_PREVIEW_DESCRIPTION)})]}),(0,Y.jsxs)(`dl`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto border-y border-[var(--oh-border)] px-6 py-5`,children:[(0,Y.jsx)($,{label:a(s.AUTOMATIONS$NAME),value:t.name}),(0,Y.jsx)($,{label:a(s.AUTOMATIONS$DETAIL$TRIGGER),value:c}),(0,Y.jsx)($,{label:a(s.AUTOMATIONS$PROMPT),value:t.prompt??``}),t.plugins&&t.plugins.length>0?(0,Y.jsx)($,{label:a(s.AUTOMATIONS$DETAIL$PLUGINS),value:t.plugins.join(`, `)}):null]}),(0,Y.jsxs)(`footer`,{className:`px-6 py-5`,children:[(0,Y.jsx)(`p`,{className:`mb-4 text-sm text-tertiary-light`,children:a(s.AUTOMATIONS$IMPORT_DISABLED_NOTICE)}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,Y.jsx)(y,{testId:`import-automation-cancel`,type:`button`,variant:`secondary`,onClick:r,isDisabled:n,children:a(s.AUTOMATIONS$CANCEL)}),(0,Y.jsx)(y,{testId:`import-automation-confirm`,type:`button`,variant:`primary`,onClick:i,isDisabled:n,"aria-busy":n,children:a(n?s.AUTOMATIONS$IMPORTING:s.AUTOMATIONS$IMPORT)})]})]})]})})}var Ye=50,Xe=i(function(){let{t:e}=o(`openhands`),[t,n]=(0,J.useState)(``),[r,i]=(0,J.useState)(()=>je()),[a,p]=(0,J.useState)(Ye),[m,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null),[b,x]=(0,J.useState)(!1),[S,C]=(0,J.useState)(null),w=(0,J.useRef)(null),T=f(),E=T.backend.kind===`local`,{data:D,isLoading:O,refetch:k}=ce(),A=D?.status===`ok`,{data:j,isLoading:M,isError:N,refetch:ne}=ge({limit:a,offset:0,enabled:A}),{trackPrebuiltAutomationEnabled:P,trackAutomationExported:F}=ee(),I=oe(),re=ae(),L=ie(),R=he(),z=(0,J.useMemo)(()=>{if(!j?.automations)return[];let e=t.toLowerCase();return e?j.automations.filter(t=>t.name.toLowerCase().includes(e)||(t.prompt??``).toLowerCase().includes(e)||t.repository?.toLowerCase().includes(e)||t.model?.toLowerCase().includes(e)):j.automations},[j?.automations,t]),B=(0,J.useMemo)(()=>z.filter(e=>e.enabled),[z]),V=(0,J.useMemo)(()=>z.filter(e=>!e.enabled),[z]),H=(e,t)=>{let n=!t;if(I.mutate({id:e,enabled:n}),n){let t=j?.automations.find(t=>t.id===e);P({automationId:e,automationName:t?.name??e})}},U=t=>{L.mutate(t,{onSuccess:()=>{d(e(s.AUTOMATIONS$RUN_NOW_SUCCESS))},onError:t=>{l(c(t)?t.response?.data?.message||t.message||e(s.AUTOMATIONS$RUN_NOW_ERROR):t.message||e(s.AUTOMATIONS$RUN_NOW_ERROR))}})},W=e=>{let t=j?.automations.find(t=>t.id===e);t&&g({id:e,name:t.name})},G=e=>{let t=j?.automations.find(t=>t.id===e);t&&v(t)},K=e=>{let t=`${JSON.stringify(fe(e),null,2)}\n`;h(new Blob([t],{type:`application/json`}),me(e)),F({backendKind:T.backend.kind})},q=async t=>{let n=t.currentTarget,r=n.files?.[0];if(n.value=``,r)try{let t;try{t=JSON.parse(await r.text())}catch{l(e(s.AUTOMATIONS$IMPORT_INVALID_JSON));return}C(ue(t))}catch(t){l(t instanceof Error?t.message:e(s.ERROR$GENERIC))}},_e=()=>{S&&R.mutate({...S,enabled:!1},{onSuccess:t=>{C(null),u(e(s.AUTOMATIONS$IMPORT_SUCCESS,{name:t.name}),e(s.AUTOMATIONS$IMPORT_VIEW),`/automations/${encodeURIComponent(t.id)}`)},onError:t=>{let n=c(t)?t.response?.data?.detail:void 0;l(typeof n==`string`?n:c(t)?t.message:e(s.ERROR$GENERIC))}})},ve=()=>{m&&(re.mutate(m.id),g(null))},be=(0,J.useCallback)(e=>{i(e),Me(e)},[]),xe=j?j.total>j.automations.length:!1,X=!M&&!N&&j?.automations.length===0;return O?(0,Y.jsx)(`div`,{className:`min-h-full`,children:(0,Y.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(s.AUTOMATIONS$TITLE)}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(s.AUTOMATIONS$SUBTITLE)}),(0,Y.jsx)(`div`,{className:`mt-6 flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,Y.jsx)(Re,{},`skeleton-${String(t)}`))})]})}):A?(0,Y.jsx)(`div`,{className:`min-h-full`,children:(0,Y.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-semibold text-content`,children:e(s.AUTOMATIONS$TITLE)}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(s.AUTOMATIONS$SUBTITLE)})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2`,children:[(0,Y.jsx)(y,{type:`button`,variant:`secondary`,testId:`automations-import-automation`,className:`whitespace-nowrap`,onClick:()=>w.current?.click(),startContent:(0,Y.jsx)(ye,{className:`size-4`,"aria-hidden":!0}),children:e(s.AUTOMATIONS$IMPORT)}),(0,Y.jsx)(`input`,{ref:w,type:`file`,accept:`application/json,.json`,className:`hidden`,"data-testid":`automations-import-file`,onChange:q}),(0,Y.jsx)(y,{type:`button`,variant:`secondary`,testId:`automations-add-automation`,className:`whitespace-nowrap`,onClick:()=>x(!0),children:e(s.AUTOMATIONS$ADD_AUTOMATION)})]})]}),(0,Y.jsxs)(`div`,{className:`mt-6 flex items-stretch gap-2`,children:[(0,Y.jsx)(Se,{value:t,onChange:n}),(0,Y.jsx)(Le,{view:r,onChange:be,disabled:X})]}),(0,Y.jsxs)(`div`,{className:`mt-6 flex flex-col gap-6`,children:[M&&(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,Y.jsx)(Re,{},`skeleton-${String(t)}`))}),N&&!M&&(0,Y.jsx)(pe,{onRetry:ne}),X&&(0,Y.jsx)(Ke,{}),!M&&!N&&j&&j.automations.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Pe,{title:e(s.AUTOMATIONS$ACTIVE),count:B.length,automations:B,view:r,onToggle:H,onRunNow:U,runPendingId:L.isPending?L.variables??null:null,onDelete:W,onExport:K,onEdit:E?G:void 0}),(0,Y.jsx)(Pe,{title:e(s.AUTOMATIONS$INACTIVE),count:V.length,automations:V,view:r,onToggle:H,onRunNow:U,runPendingId:L.isPending?L.variables??null:null,onDelete:W,onExport:K,onEdit:E?G:void 0}),xe&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>p(e=>e+Ye),className:`self-center rounded-lg border border-[var(--oh-border)] px-6 py-2 text-sm text-white hover:bg-surface-raised`,children:e(s.AUTOMATIONS$LOAD_MORE)})]})]}),(0,Y.jsx)(`div`,{className:`mt-6`,children:(0,Y.jsx)(te,{query:t})}),(0,Y.jsx)(se,{automationName:m?.name??``,isOpen:m!==null,onConfirm:ve,onCancel:()=>g(null)}),_&&(0,Y.jsx)(le,{automation:_,isOpen:_!==null,onClose:()=>v(null)}),(0,Y.jsx)(qe,{isOpen:b,onClose:()=>x(!1)}),(0,Y.jsx)(Je,{isOpen:S!==null,spec:S,isImporting:R.isPending,onClose:()=>C(null),onImport:_e})]})}):(0,Y.jsx)(`div`,{className:`min-h-full`,children:(0,Y.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(s.AUTOMATIONS$TITLE)}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(s.AUTOMATIONS$SUBTITLE)}),(0,Y.jsx)(de,{onRetry:k})]})})});export{Xe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,r as t}from"./rolldown-runtime-BFRubm34.js";import{Ct as n,bt as r}from"./vendor-styling-CI0PQ3ab.js";import{t as i}from"./useQuery-CRBP8vIS.js";import{t as a}from"./useTranslation-CDRCKC9-.js";import{t as o}from"./declaration-gq8V5eTU.js";import{m as s}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~lf310vj7-CSVPGId3.js";import{F as c,I as l,R as u,h as d,p as f,r as p}from"./active-backend-context-hxq31W25.js";import{t as m}from"./utils-D3U3rlqr.js";import{T as h,n as g}from"./agent-server-client-options-DVLRd9sw.js";import{a as _,i as v,n as y,r as b,t as x}from"./use-backends-health-CRHzuvxO.js";import{t as S}from"./modal-backdrop-zVwfOJZr.js";import{n as C,r as w,t as T}from"./modal-body-DouOE5KH.js";import{n as E,r as D}from"./modal-classes-Cf-4tbHz.js";import{t as O}from"./brand-button-vMVuyDXu.js";import{n as k}from"./navigation-context-DPs2G0X8.js";import{t as A}from"./modal-close-button-B6CfxxJj.js";import{t as j}from"./settings-input-bD6npsDm.js";import{t as ee}from"./segmented-toggle-DyQqPhoD.js";import{t as M}from"./use-tracking-BIXzagSI.js";var N=e(n()),P=r(),F=e=>(0,P.jsxs)(`svg`,{width:1365,height:1365,viewBox:`0 -24 148 148`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,P.jsx)(`path`,{d:`M71.7542 16.863V2.97414C71.7542 1.82355 72.6872 0.890503 73.8378 0.890503C74.9884 0.890503 75.9214 1.82355 75.9214 2.97414V16.863C75.9214 18.0136 74.9884 18.9466 73.8378 18.9466C72.6872 18.9466 71.7542 18.0136 71.7542 16.863Z`,fill:`white`}),(0,P.jsx)(`path`,{d:`M82.5272 18.9329L89.4716 6.90477C90.0469 5.90832 91.3215 5.5668 92.3179 6.1421C93.3144 6.7174 93.6559 7.99197 93.0806 8.98841L86.1362 21.0165C85.5609 22.0129 84.2863 22.3545 83.2899 21.7792C82.2934 21.2039 81.9519 19.9293 82.5272 18.9329Z`,fill:`white`}),(0,P.jsx)(`path`,{d:`M65.1481 18.9329L58.2037 6.90477C57.6284 5.90832 56.3538 5.5668 55.3574 6.1421C54.3609 6.7174 54.0194 7.99197 54.5947 8.98841L61.5391 21.0165C62.1144 22.0129 63.389 22.3545 64.3854 21.7792C65.3819 21.2039 65.7234 19.9293 65.1481 18.9329Z`,fill:`white`}),(0,P.jsx)(`path`,{d:`M140.606 62.0292C140.606 58.409 141.583 47.6748 141.89 44.1323C142.097 41.7374 141.809 40.4247 141.424 39.7542C141.141 39.2626 140.699 38.915 139.634 38.8436C138.865 38.7921 138.027 39.0114 137.401 39.5761C136.814 40.1052 136.159 41.1682 136.159 43.3176L136.155 43.4388L135.198 59.758C135.164 60.3451 134.883 60.8911 134.424 61.2599C133.966 61.6284 133.374 61.7859 132.793 61.6941L122.764 60.1068L111.948 58.6703C110.949 58.5376 110.188 57.7084 110.142 56.7016L109.561 44.1323C109.535 43.621 109.51 43.1141 109.484 42.6146C109.241 37.9294 109.022 33.7805 109.022 32.4282C109.022 28.3859 108.338 26.6806 107.74 25.9634C107.263 25.3915 106.577 25.1402 105.11 25.1402C104.583 25.1402 104.212 25.2481 103.933 25.4111C103.659 25.5714 103.346 25.8587 103.049 26.4208C102.41 27.6257 101.945 29.891 102.118 33.8479C102.342 38.9804 102.692 42.8146 103.035 46.2718C103.377 49.7231 103.718 52.8561 103.908 56.4971C104.204 62.1966 104.178 66.1256 103.945 68.7924C103.828 70.124 103.656 71.1996 103.423 72.0501C103.202 72.8558 102.871 73.6757 102.296 74.2887C101.6 75.0303 100.608 75.3844 99.577 75.136C98.7592 74.9389 98.1847 74.4215 97.8706 74.0916C97.2141 73.4017 96.7501 72.5106 96.568 72.0512C95.5097 69.3812 92.2352 63.1808 87.8023 59.6811C86.5089 58.6599 85.5666 58.3652 84.9736 58.3204C84.4148 58.2783 84.0094 58.4436 83.6909 58.6967C83.34 58.9756 83.0781 59.3811 82.9479 59.7643C82.9019 59.8999 82.8823 59.9968 82.8741 60.0584C84.0759 62.0865 88.8421 69.5222 91.0896 77.069C92.7648 82.6941 96.8038 88.4259 99.8194 90.8809C102.74 93.258 107.988 94.7313 113.9 95.0218C119.756 95.3095 125.788 94.4121 130.033 92.5092C138.233 88.8334 139.903 80.7382 140.651 77.2292C141.232 74.5057 141.243 71.5987 141.087 68.9009C141.01 67.5551 140.894 66.2969 140.793 65.1373C140.695 64.0105 140.606 62.9215 140.606 62.0292ZM120.986 27.0953C120.986 25.8314 120.648 24.7049 120.089 23.9514C119.583 23.27 118.84 22.7987 117.646 22.7984C116.668 22.7982 116.011 22.9187 115.546 23.1167C115.13 23.2943 114.781 23.5699 114.463 24.0831C113.73 25.2671 113.192 27.6455 113.189 32.384L113.721 43.9088C113.91 47.5661 114.106 51.4922 114.235 54.7707L120.986 55.6666V27.0953ZM125.153 56.2652L131.172 57.218L131.992 43.267V32.5083C131.992 31.031 131.39 30.1275 130.678 29.5489C129.884 28.9039 128.957 28.6731 128.519 28.6731C127.722 28.6731 126.899 28.797 126.306 29.2179C125.849 29.5421 125.153 30.3087 125.153 32.5083V56.2652ZM136.159 35.4278C137.406 34.8069 138.74 34.6083 139.912 34.6868C142.037 34.8292 143.91 35.718 145.037 37.6779C146.06 39.4592 146.273 41.8136 146.041 44.4927C145.72 48.1949 144.772 58.6457 144.772 62.0292C144.772 62.708 144.843 63.6116 144.944 64.7758C145.042 65.907 145.165 67.2389 145.247 68.6606C145.411 71.4987 145.422 74.8383 144.727 78.0987C144.002 81.4953 142.041 91.6918 131.738 96.3108C126.731 98.5551 120.002 99.4936 113.696 99.1838C107.445 98.8767 101.128 97.3189 97.1887 94.1122C93.4809 91.0937 88.9938 84.6307 87.0962 78.2589C84.9529 71.0619 80.3109 63.9646 79.1527 61.9533C78.4706 60.7689 78.684 59.3628 79.0019 58.4258C79.3607 57.3688 80.0554 56.2631 81.0993 55.4337C82.1758 54.5784 83.6043 54.0377 85.2876 54.1647C86.9369 54.2893 88.6462 55.0393 90.3834 56.4107C94.8541 59.9401 98.1342 65.5082 99.7424 68.9231C99.759 68.7664 99.779 68.6024 99.7941 68.4298C100.003 66.0435 100.039 62.3344 99.7467 56.7132C99.5635 53.1942 99.2356 50.1809 98.8888 46.6828C98.5425 43.1904 98.184 39.2713 97.955 34.0302C97.7722 29.8481 98.2012 26.6722 99.3672 24.471C99.9716 23.3302 100.79 22.4223 101.83 21.814C102.866 21.2087 103.995 20.974 105.11 20.974C106.759 20.974 108.813 21.2062 110.448 22.7678C110.593 22.4576 110.75 22.1652 110.921 21.8899C111.676 20.6698 112.681 19.8084 113.912 19.2835C115.095 18.7791 116.378 18.6309 117.646 18.6311C120.195 18.6315 122.164 19.7567 123.434 21.4683C124.256 22.576 124.75 23.8775 124.985 25.1982C126.338 24.5876 127.691 24.5068 128.519 24.5068C129.933 24.5068 131.784 25.0791 133.305 26.3154C134.908 27.6179 136.159 29.6733 136.159 32.5083V35.4278Z`,fill:`white`}),(0,P.jsx)(`path`,{d:`M7.15661 62.0292C7.15661 58.409 6.17994 47.6748 5.87291 44.1323C5.6654 41.7374 5.95357 40.4247 6.33875 39.7542C6.62116 39.2626 7.06336 38.915 8.12834 38.8436C8.89759 38.7921 9.73544 39.0114 10.3616 39.5761C10.9484 40.1052 11.6032 41.1682 11.6032 43.3176L11.6074 43.4388L12.5644 59.758C12.5988 60.3451 12.8798 60.8911 13.338 61.2599C13.7961 61.6284 14.3887 61.7859 14.9695 61.6941L24.9988 60.1068L35.8143 58.6703C36.8135 58.5376 37.5741 57.7084 37.6208 56.7016L38.2015 44.1323C38.2279 43.621 38.2525 43.1141 38.2784 42.6146C38.5218 37.9294 38.7401 33.7805 38.7401 32.4282C38.7401 28.3859 39.4246 26.6806 40.0227 25.9634C40.4996 25.3915 41.185 25.1402 42.6523 25.1402C43.1794 25.1402 43.5505 25.2481 43.8295 25.4111C44.1038 25.5714 44.416 25.8587 44.7138 26.4208C45.3521 27.6257 45.8173 29.891 45.6444 33.8479C45.4201 38.9804 45.0703 42.8146 44.7275 46.2718C44.3853 49.7231 44.0443 52.8561 43.8548 56.4971C43.5582 62.1966 43.5847 66.1256 43.8179 68.7924C43.9344 70.124 44.1069 71.1996 44.3396 72.0501C44.5601 72.8558 44.891 73.6757 45.4663 74.2887C46.1625 75.0303 47.1546 75.3844 48.1855 75.136C49.0033 74.9389 49.5778 74.4215 49.8918 74.0916C50.5484 73.4017 51.0123 72.5106 51.1945 72.0512C52.2527 69.3812 55.5272 63.1808 59.9601 59.6811C61.2536 58.6599 62.1958 58.3652 62.7889 58.3204C63.3476 58.2783 63.753 58.4436 64.0715 58.6967C64.4225 58.9756 64.6844 59.3811 64.8146 59.7643C64.8606 59.8999 64.8801 59.9968 64.8883 60.0584C63.6866 62.0865 58.9204 69.5222 56.6729 77.069C54.9977 82.6941 50.9586 88.4259 47.9431 90.8809C45.0229 93.258 39.7747 94.7313 33.8624 95.0218C28.0068 95.3095 21.9748 94.4121 17.7297 92.5092C9.52988 88.8334 7.85961 80.7382 7.11129 77.2292C6.53054 74.5057 6.5195 71.5987 6.67496 68.9009C6.75251 67.5551 6.86809 66.2969 6.96901 65.1373C7.06707 64.0105 7.1566 62.9215 7.15661 62.0292ZM26.7768 27.0953C26.7768 25.8314 27.1147 24.7049 27.6737 23.9514C28.1792 23.27 28.9221 22.7987 30.1167 22.7984C31.0942 22.7982 31.7518 22.9187 32.2162 23.1167C32.6326 23.2943 32.9817 23.5699 33.2996 24.0831C34.0328 25.2671 34.5705 27.6455 34.5738 32.384L34.0416 43.9088C33.8524 47.5661 33.6565 51.4922 33.5273 54.7707L26.7768 55.6666V27.0953ZM22.6095 56.2652L16.5904 57.218L15.7705 43.267V32.5083C15.7705 31.031 16.3726 30.1275 17.0847 29.5489C17.8785 28.9039 18.8058 28.6731 19.2432 28.6731C20.0404 28.6731 20.8634 28.797 21.4565 29.2179C21.9131 29.5421 22.6095 30.3087 22.6095 32.5083V56.2652ZM11.6032 35.4278C10.3568 34.8069 9.02265 34.6083 7.8501 34.6868C5.72541 34.8292 3.85197 35.718 2.72584 37.6779C1.70247 39.4592 1.48924 41.8136 1.72143 44.4927C2.0423 48.1949 2.99038 58.6457 2.99038 62.0292C2.99037 62.708 2.91991 63.6116 2.81859 64.7758C2.72014 65.907 2.59699 67.2389 2.51505 68.6606C2.3515 71.4987 2.34041 74.8383 3.0357 78.0987C3.76005 81.4953 5.72154 91.6918 16.0245 96.3108C21.0311 98.5551 27.7601 99.4936 34.0669 99.1838C40.3172 98.8767 46.6346 97.3189 50.5737 94.1122C54.2816 91.0937 58.7686 84.6307 60.6662 78.2589C62.8095 71.0619 67.4515 63.9646 68.6098 61.9533C69.2919 60.7689 69.0785 59.3628 68.7605 58.4258C68.4018 57.3688 67.707 56.2631 66.6632 55.4337C65.5867 54.5784 64.1582 54.0377 62.4748 54.1647C60.8256 54.2893 59.1162 55.0393 57.379 56.4107C52.9083 59.9401 49.6283 65.5082 48.02 68.9231C48.0034 68.7664 47.9835 68.6024 47.9684 68.4298C47.7597 66.0435 47.7232 62.3344 48.0158 56.7132C48.1989 53.1942 48.5269 50.1809 48.8737 46.6828C49.22 43.1904 49.5784 39.2713 49.8075 34.0302C49.9903 29.8481 49.5612 26.6722 48.3952 24.471C47.7909 23.3302 46.9729 22.4223 45.9321 21.814C44.8964 21.2087 43.7676 20.974 42.6523 20.974C41.0038 20.974 38.9497 21.2062 37.3141 22.7678C37.1698 22.4576 37.0124 22.1652 36.8419 21.8899C36.0863 20.6698 35.0817 19.8084 33.8508 19.2835C32.6679 18.7791 31.3849 18.6309 30.1167 18.6311C27.5677 18.6315 25.5986 19.7567 24.3285 21.4683C23.5066 22.576 23.0121 23.8775 22.7771 25.1982C21.4247 24.5876 20.0718 24.5068 19.2432 24.5068C17.8298 24.5068 15.9788 25.0791 14.4573 26.3154C12.8542 27.6179 11.6032 29.6733 11.6032 32.5083V35.4278Z`,fill:`white`})]}),I=class extends Error{constructor(e,t){super(e),this.code=t,this.name=`DeviceFlowError`}},L=6e5,R=3e4;function z(e){try{let t=e.trim().toLowerCase(),n=/^https?:\/\//i.test(t)?t:`https://${t}`,r=new URL(n).hostname;return r.endsWith(`.all-hands.dev`)||r===`all-hands.dev`||r.endsWith(`.openhands.dev`)||r===`openhands.dev`}catch{return!1}}async function B(e,t,n,r,i,a){let o=r===void 0?void 0:typeof r==`string`||r instanceof Blob||r instanceof FormData||r instanceof URLSearchParams?r:JSON.stringify(r);return await fetch(`${e.replace(/\/+$/,``)}${n}`,{method:t,headers:{...i?{"Content-Type":i}:{}},body:o,signal:a})}async function te(e){let t=e.replace(/\/+$/,``);try{let e=await B(t,`POST`,`/oauth/device/authorize`,{},`application/json`);if(!e.ok)throw new I(`Failed to start device flow: Server returned ${e.status}`);let n=await e.json();if(!n.device_code||!n.user_code||!n.verification_uri)throw new I(`Invalid response from device authorization endpoint: missing required fields`);let r=n.verification_uri_complete??`${n.verification_uri}?user_code=${encodeURIComponent(n.user_code)}`;return{device_code:n.device_code,user_code:n.user_code,verification_uri:n.verification_uri,verification_uri_complete:r,expires_in:n.expires_in??600,interval:n.interval??5}}catch(e){throw e instanceof I?e:new I(`Failed to start device flow: ${e instanceof Error?e.message:String(e)}`)}}async function ne(e,t,n){let r=e.replace(/\/+$/,``),i=n.timeout??L,a=Math.max(1,n.interval)*1e3,o=Date.now();for(;Date.now()-o<i;){if(n.signal?.aborted)throw new I(`Authorization cancelled`,`cancelled`);try{let e=await B(r,`POST`,`/oauth/device/token`,new URLSearchParams({grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:t}).toString(),`application/x-www-form-urlencoded`,n.signal);if(e.ok){let t=await e.json();if(!t.access_token)throw new I(`Invalid token response: missing access_token`);return{access_token:t.access_token,token_type:t.token_type??`Bearer`,expires_in:t.expires_in}}let i;try{i=await e.json()}catch{throw new I(`Unexpected response from server: ${e.status}`)}let{error:o,error_description:s}=i;switch(o){case`authorization_pending`:break;case`slow_down`:a=typeof i.interval==`number`&&isFinite(i.interval)&&i.interval>0?Math.max(1,Math.min(i.interval,30))*1e3:Math.min(a+5e3,R);break;case`expired_token`:throw new I(`Device code has expired. Please try again.`,`expired_token`);case`access_denied`:throw new I(`Authorization request was denied.`,`access_denied`);default:throw new I(`Authorization error: ${o}${s?` - ${s}`:``}`,o)}}catch(e){if(e instanceof I)throw e;if(e instanceof DOMException&&e.name===`AbortError`)throw new I(`Authorization cancelled`,`cancelled`);console.warn(`Network error during polling, retrying:`,e)}try{await re(a,n.signal)}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?new I(`Authorization cancelled`,`cancelled`):e}}throw new I(`Timeout waiting for authorization. Please try again.`,`timeout`)}function re(e,t){return new Promise((n,r)=>{if(t?.aborted){r(new DOMException(`Aborted`,`AbortError`));return}let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(new DOMException(`Aborted`,`AbortError`))},{once:!0})})}var V=e=>(0,P.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,P.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M15.3235 10.9352L11.5016 14.2111L7.67969 10.9352L8.6152 9.84375L11.5016 12.3178L14.388 9.84375L15.3235 10.9352Z`,fill:`currentColor`})});function H(e,t,n){let r=n?.lastError??null,i=t?.kind===`cloud`;return i&&!t?.apiKey?.trim()||v(r)?e(o.BACKEND$STATUS_DISCONNECTED_ADD_API_KEY):b(r)?e(o.BACKEND$STATUS_DISCONNECTED_CHECK_API_KEY):y(r)?e(o.BACKEND$LOGGED_OUT):n?.isConnected===!0?e(o.ONBOARDING$BACKEND_STATUS_CONNECTED):i&&n?.isConnected===!1&&(x(r)||u(r))?e(o.BACKEND$STATUS_DISCONNECTED_CHECK_CLOUD_ACCESS):n?.isConnected===!1&&l(r)?e(o.BACKEND$STATUS_DISCONNECTED_CHECK_TUNNEL):n?.isConnected===!1&&u(r)?e(o.BACKEND$STATUS_DISCONNECTED_CHECK_URL_OR_NETWORK):n?.isConnected===!1?e(o.ONBOARDING$BACKEND_STATUS_DISCONNECTED):e(o.ONBOARDING$BACKEND_STATUS_CHECKING)}function U({isConnected:e,className:t}){let n,r,i;return e===`unavailable`?(n=`bg-[var(--oh-text-tertiary)]`,r=`No Backend Available`,i=`unavailable`):e===!0?(n=`bg-[var(--oh-status-success)]`,r=`Connected`,i=`connected`):e===!1?(n=`bg-red-500`,r=`Disconnected`,i=`disconnected`):(n=`bg-[var(--oh-interactive-selected)]`,r=`Checking connection`,i=`checking`),(0,P.jsx)(`span`,{"data-testid":`backend-status-dot`,"data-status":i,"aria-label":r,title:r,role:`status`,className:m(`inline-block w-2 h-2 rounded-full shrink-0`,n,t)})}var W={status:`idle`,verificationUrl:null,userCode:null,apiKey:null,error:null,errorCode:null};function ie(){let[e,t]=N.useState(W),n=N.useRef(null),r=N.useCallback(e=>{n.current?.abort();let r=new AbortController;n.current=r,t({...W,status:`starting`}),(async()=>{let n;try{n=await te(e)}catch(e){if(r.signal.aborted)return;let n=e instanceof Error?e.message:`Failed to start device flow`,i=e instanceof I?e.code:void 0;t({...W,status:`error`,error:n,errorCode:i??null});return}if(!r.signal.aborted){t({...W,status:`awaiting_authorization`,verificationUrl:n.verification_uri_complete,userCode:n.user_code});try{let i=await ne(e,n.device_code,{interval:n.interval,signal:r.signal});if(r.signal.aborted)return;t({...W,status:`success`,apiKey:i.access_token})}catch(e){if(r.signal.aborted)return;if(e instanceof I&&e.code===`cancelled`){t(W);return}let n=e instanceof Error?e.message:`Authorization failed`,i=e instanceof I?e.code:void 0;t({...W,status:`error`,error:n,errorCode:i??null})}}})()},[]),i=N.useCallback(()=>{n.current?.abort(),n.current=null,t(W)},[]),a=N.useCallback(()=>{n.current?.abort(),n.current=null,t(W)},[]);return N.useEffect(()=>()=>{n.current?.abort()},[]),{...e,start:r,cancel:i,reset:a}}function G(e){try{return new URL(e).protocol===`https:`}catch{return!1}}function K({host:e,onSuccess:t,testIdRoot:n,isDisabled:r=!1,idleButtonLabel:i,idleButtonContent:s,className:c,buttonClassName:l,buttonVariant:u=`primary`,statusDisplay:d=`inline`}){let{t:f}=a(`openhands`),p=ie(),h=N.useRef(null);N.useEffect(()=>()=>{h.current?.close()},[]),N.useEffect(()=>{if(p.status===`awaiting_authorization`&&p.verificationUrl&&h.current&&!h.current.closed){if(!G(p.verificationUrl)){console.error(`Invalid verification URL protocol`);return}try{h.current.location.href=p.verificationUrl}catch{h.current=window.open(p.verificationUrl,`_blank`,`noopener,noreferrer`)}}},[p.status,p.verificationUrl]),N.useEffect(()=>{if(p.status===`success`&&p.apiKey)try{t(p.apiKey)}finally{p.reset(),h.current?.close()}},[p.status,p.apiKey,p.reset,t]);let g=()=>{let t=e.trim().replace(/\/+$/,``),n=/^https?:\/\//i.test(t)?t:`https://${t}`;try{let e=new URL(n);if(e.username||e.password)throw Error(`Invalid URL format`)}catch{return}h.current=window.open(`about:blank`,`_blank`),h.current||console.warn(`Popup blocked - user will need to use manual link`),p.start(n)},_=()=>{p.cancel(),h.current?.close()},v=(0,P.jsx)(ae,{status:p.status,error:p.error,verificationUrl:p.verificationUrl,testIdRoot:n,onCancel:_,onRetry:g}),y=d===`modal`&&p.status!==`idle`,b=i??f(o.BACKEND$LOGIN_WITH_OPENHANDS);return(0,P.jsxs)(`div`,{"data-testid":`${n}-device-flow`,className:m(`flex flex-col gap-3`,c),children:[p.status===`idle`&&u===`unstyled`&&(0,P.jsx)(`button`,{type:`button`,onClick:g,"data-testid":`${n}-login-button`,className:l,disabled:r,"aria-label":s?b:void 0,children:s??b}),p.status===`idle`&&u!==`unstyled`&&(0,P.jsx)(O,{type:`button`,variant:u,onClick:g,testId:`${n}-login-button`,className:m(`w-full`,l),isDisabled:r,ariaLabel:s?b:void 0,children:s??b}),d===`inline`?v:null,y?(0,P.jsx)(S,{onClose:_,"aria-label":f(o.BACKEND$LOGIN_WITH_OPENHANDS),closeOnBackdropClick:!1,children:(0,P.jsx)(C,{testID:`${n}-auth-modal`,width:`sm`,className:`items-stretch border border-[var(--oh-border)]`,children:v})}):null]})}function ae({status:e,error:t,verificationUrl:n,testIdRoot:r,onCancel:i,onRetry:s}){let{t:c}=a(`openhands`);if(e===`idle`||e===`success`)return null;if(e===`starting`)return(0,P.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-base-tertiary p-3`,"data-testid":`${r}-auth-starting`,role:`status`,"aria-live":`polite`,children:[(0,P.jsx)(q,{}),(0,P.jsx)(`span`,{className:`text-sm text-[var(--oh-text-tertiary)]`,children:c(o.BACKEND$AUTH_STARTING)})]});if(e===`awaiting_authorization`){let e=n&&G(n)?n:null;return(0,P.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-lg bg-base-tertiary p-4`,"data-testid":`${r}-auth-awaiting`,role:`status`,"aria-live":`polite`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(q,{}),(0,P.jsx)(`span`,{className:`text-sm font-medium text-white`,children:c(o.BACKEND$AUTH_AWAITING)})]}),(0,P.jsx)(`p`,{className:`text-sm leading-5 text-[var(--oh-text-tertiary)]`,children:c(o.BACKEND$AUTH_BROWSER_OPENED)}),e?(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md border border-[var(--oh-border)] bg-[var(--oh-surface)] p-3 text-xs text-[var(--oh-muted)]`,children:[(0,P.jsx)(`p`,{children:c(o.BACKEND$AUTH_OPEN_MANUALLY)}),(0,P.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`max-h-16 overflow-auto break-all text-blue-400 hover:underline`,children:e})]}):null,(0,P.jsx)(O,{type:`button`,variant:`secondary`,onClick:i,testId:`${r}-auth-cancel`,className:`w-full`,children:c(o.BACKEND$AUTH_CANCEL)})]})}return(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-red-700 bg-red-900/20 p-4`,"data-testid":`${r}-auth-error`,role:`alert`,children:[(0,P.jsx)(`p`,{className:`text-sm text-red-400`,children:t}),(0,P.jsx)(O,{type:`button`,variant:`secondary`,onClick:s,testId:`${r}-auth-retry`,className:`w-full`,children:c(o.BACKEND$AUTH_RETRY)})]})}function q(){return(0,P.jsx)(`svg`,{className:`animate-spin h-4 w-4 text-white`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,P.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})})}var oe=t({BackendConnectionOptions:()=>$,BackendForm:()=>Q,BackendFormModal:()=>ve});function se(e){return z(e)?`cloud`:`local`}function ce(e){let t=e.toLowerCase().replace(/^\[|\]$/g,``);return!!(t===`localhost`||t===`::1`||t===`::`||t===`0.0.0.0`||/^127\./.test(t)||/^::ffff:127\./i.test(t)||/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[01])\./.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)||/^f[cd][0-9a-f]{2}:/i.test(t)||t.endsWith(`.local`)||!t.includes(`.`)&&!t.includes(`:`))}function J(e){let t=e.trim().replace(/\/+$/,``);if(!t)return``;if(/^https?:\/\//i.test(t))return t;let n=t.match(/^\[([^\]]+)\]/);return`${ce(n?n[1]:(t.match(/:/g)??[]).length>1?t:t.split(`:`)[0])?`http`:`https`}://${t}`}function Y(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=J(t);if(!n)return!1;try{let e=new URL(n);return(e.protocol===`http:`||e.protocol===`https:`)&&e.hostname.length>0}catch{return!1}}var X=`https://app.all-hands.dev`;function le(e,t){return e(o.BACKEND$CONNECTION_TEST_FAILED,{host:t,interpolation:{escapeValue:!1}})}function ue(e){return c(e)}function de(e,t){let n=ue(t);return n?`${e}\n${n}`:e}async function Z(e){e.kind===`local`&&f(await new s(g({host:e.host,sessionApiKey:e.apiKey||null,timeout:5e3})).getServerInfo())}function fe({backend:e,testIdRoot:t}){let{t:n}=a(`openhands`),r=_([e])[e.id],c=r?.isConnected??null,l=r?.disabled===!0,u=r?.consecutiveFailures??0,f=r?.lastError??null,{data:p}=i({queryKey:[`backend-version`,e.host,e.apiKey],queryFn:async()=>d(await new s(g({host:e.host,sessionApiKey:e.apiKey||null,timeout:5e3})).getServerInfo()),retry:!1,staleTime:6e4,enabled:e.kind===`local`&&!l}),m=H(n,e,r),h=e.kind===`cloud`?n(o.BACKEND$KIND_CLOUD):n(o.BACKEND$KIND_LOCAL);return(0,P.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,P.jsxs)(`div`,{"data-testid":`${t}-status`,className:`flex items-center gap-3 text-sm`,children:[(0,P.jsx)(U,{isConnected:c}),(0,P.jsx)(`span`,{className:`text-white`,"data-testid":`${t}-status-label`,children:m}),(0,P.jsx)(`span`,{className:`text-tertiary-alt`,children:`·`}),(0,P.jsx)(`span`,{className:`text-[var(--oh-text-tertiary)]`,children:h}),p?(0,P.jsx)(`span`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`${t}-version`,children:n(o.BACKEND$VERSION_LABEL,{version:p})}):null]}),l?(0,P.jsxs)(`div`,{"data-testid":`${t}-status-error`,className:`flex flex-col gap-1 rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm`,children:[(0,P.jsx)(`span`,{className:`font-semibold text-red-300`,children:n(o.BACKEND$HEALTH_FAILED_TITLE)}),(0,P.jsx)(`span`,{className:`text-xs text-[var(--oh-text-tertiary)]`,children:n(o.BACKEND$HEALTH_FAILED_DETAIL,{count:u})}),f?(0,P.jsx)(`span`,{"data-testid":`${t}-status-error-message`,className:`text-xs text-red-300 whitespace-pre-wrap break-words`,children:f}):null]}):null]})}function pe({initialName:e=``,initialHost:t=``,initialApiKey:n=``,onTestConnection:r,onSuccess:i,requireApiKey:o=!1,onSubmitOverride:s}){let{t:c}=a(`openhands`),[l,u]=N.useState(e),[d,f]=N.useState(t),[p,m]=N.useState(n),[h,g]=N.useState(null),[_,v]=N.useState(!1),[y,b]=N.useState(null),x=y??se(d),S=o||x!==`local`,C=l.trim().length>0&&Y(d)&&(!S||p.trim().length>0);return{name:l,setName:u,host:d,setHost:f,apiKey:p,setApiKey:m,connectionError:h,setConnectionError:g,isSubmitting:_,kind:x,setKind:b,canSubmit:C,handleSubmit:N.useCallback(async e=>{if(e.preventDefault(),!C||_)return;let t={name:l.trim(),host:J(d),apiKey:p.trim(),kind:x};g(null),v(!0);try{s?await s(t):(await r(t),i())}catch(e){g(de(le(c,t.host),e))}finally{v(!1)}},[C,_,l,d,p,x,r,i,o,s,c])}}function Q({mode:e,backend:t,onSubmitted:n,renderActions:r,testIdRoot:i,hostReadOnly:s,requireApiKey:c,hideConfigurationFields:l=!1,onSubmitOverride:u}){let{t:d}=a(`openhands`),{addBackend:f,updateBackend:h}=p(),g=e===`edit`&&t?t.kind:null,{name:_,setName:v,host:y,setHost:b,apiKey:x,setApiKey:S,connectionError:C,setConnectionError:w,isSubmitting:T,kind:E,handleSubmit:D}=pe({initialName:t?.name??``,initialHost:t?.host??``,initialApiKey:t?.apiKey??``,onTestConnection:Z,onSuccess:async()=>{let r={name:_.trim(),host:J(y),apiKey:x.trim(),kind:g??E};e===`edit`&&t?h(t.id,r):f(r),n()},requireApiKey:c,onSubmitOverride:u}),[k,A]=N.useState(!1),[ee,M]=N.useState(!1),F=g??E,I=i??(e===`edit`?`edit-backend`:`add-backend`),L=c||F!==`local`,R=_.trim().length>0&&Y(y)&&(!L||x.trim().length>0),z=k&&!_.trim()?d(o.BACKEND$NAME_REQUIRED):void 0,B=ee?y.trim()?Y(y)?void 0:d(o.BACKEND$HOST_INVALID):d(o.BACKEND$HOST_REQUIRED):void 0;return(0,P.jsxs)(`form`,{"data-testid":`${I}-form`,onSubmit:async e=>{if(!R){A(!0),M(!0);return}await D(e)},className:`flex flex-col gap-4`,children:[(0,P.jsxs)(`div`,{"data-testid":`${I}-configuration-fields`,className:m(`flex flex-col gap-4`,l&&`hidden`),children:[(0,P.jsx)(j,{testId:`${I}-name`,name:`${I}-name`,type:`text`,label:d(o.BACKEND$NAME_LABEL),value:_,onChange:e=>{v(e),w(null)},onBlur:()=>A(!0),placeholder:`Production`,className:`w-full`,showRequiredTag:!0,error:z}),(0,P.jsx)(j,{testId:`${I}-host`,name:`${I}-host`,type:`text`,label:d(o.BACKEND$HOST_LABEL),value:y,onChange:s?void 0:e=>{b(e),w(null)},onBlur:()=>M(!0),placeholder:X,className:`w-full`,showRequiredTag:!0,error:B,isDisabled:s}),(0,P.jsx)(j,{testId:`${I}-api-key`,name:`${I}-api-key`,type:`password`,label:d(o.BACKEND$KEY_LABEL),value:x,onChange:e=>{S(e),w(null)},placeholder:``,className:`w-full`}),C?(0,P.jsx)(`div`,{role:`alert`,"data-testid":`${I}-error`,className:`rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm text-red-300 whitespace-pre-wrap break-words`,children:C}):null,e===`edit`&&t&&(0,P.jsx)(fe,{backend:t,testIdRoot:I})]}),r?r({canSubmit:R&&!T,isSubmitting:T,testIdRoot:I}):(0,P.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2 w-full`,children:[(0,P.jsx)(O,{type:`button`,variant:`secondary`,onClick:n,testId:`${I}-cancel`,children:d(o.BUTTON$CANCEL)}),(0,P.jsx)(O,{type:`submit`,variant:`primary`,isDisabled:!R||T,testId:`${I}-submit`,children:d(o.BACKEND$SAVE)})]})]})}function me(){let{currentPath:e,navigate:t}=k();return N.useCallback(()=>{/^\/automations\/[^/]+/.test(e)?t(`/automations`):/^\/conversations\/[^/]+/.test(e)&&t(`/conversations`)},[e,t])}function $({onConnected:e,testIdRoot:t=`add-backend`,initialManualBackend:n,requireManualApiKey:r=!1,manualSubmitLabel:i,manualSubmittingLabel:s,manualSubmitTestId:c}){let{t:l}=a(`openhands`),u=h();return u?(0,P.jsx)(`div`,{"data-testid":`${t}-connection-options`,className:`flex justify-center`,children:(0,P.jsx)(`div`,{className:`w-full`,children:(0,P.jsx)(ge,{onConnected:e,testIdRoot:t,lockedHost:u})})}):(0,P.jsxs)(`div`,{"data-testid":`${t}-connection-options`,className:`flex flex-col gap-6 md:flex-row`,children:[(0,P.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,P.jsx)(he,{onConnected:e,testIdRoot:t,initialBackend:n,requireApiKey:r,submitLabel:i??l(o.BACKEND$CONNECT),submittingLabel:s??l(o.ONBOARDING$BACKEND_STATUS_CHECKING),submitTestId:c})}),(0,P.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,P.jsx)(ge,{onConnected:e,testIdRoot:t})})]})}function he({onConnected:e,testIdRoot:t,initialBackend:n,requireApiKey:r,submitLabel:i,submittingLabel:s,submitTestId:c}){let{t:l}=a(`openhands`),{name:u,setName:d,host:f,setHost:p,apiKey:m,setApiKey:h,connectionError:g,setConnectionError:_,isSubmitting:v,kind:y,setKind:b,canSubmit:x,handleSubmit:S}=pe({initialName:n?.name??``,initialHost:n?.host??``,initialApiKey:n?.apiKey??``,onTestConnection:Z,onSuccess:()=>{e({name:u.trim(),host:J(f),apiKey:m.trim(),kind:y},`manual`)},requireApiKey:r});return(0,P.jsxs)(`form`,{"data-testid":`${t}-form`,onSubmit:S,className:`flex flex-col gap-4 flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,P.jsx)(j,{testId:`${t}-name`,name:`${t}-name`,type:`text`,label:l(o.BACKEND$NAME_LABEL),value:u,onChange:e=>{d(e),_(null)},placeholder:`e.g. My Server`,className:`w-full`}),(0,P.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,children:l(o.BACKEND$NAME_HELPER)})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,P.jsx)(j,{testId:`${t}-host`,name:`${t}-host`,type:`text`,label:l(o.BACKEND$HOST_LABEL),value:f,onChange:e=>{p(e),_(null)},placeholder:`http://localhost:8000`,className:`w-full`}),(0,P.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)]`,"data-testid":`${t}-host-helper`,children:l(o.BACKEND$HOST_HELPER)})]}),(0,P.jsxs)(`div`,{className:`flex flex-col items-start gap-2.5`,children:[(0,P.jsx)(`span`,{className:`text-sm`,children:l(o.BACKEND$KIND_LABEL)}),(0,P.jsx)(ee,{value:y,options:[{value:`local`,label:l(o.BACKEND$KIND_LOCAL)},{value:`cloud`,label:l(o.BACKEND$KIND_CLOUD)}],onChange:e=>b(e),ariaLabel:l(o.BACKEND$KIND_LABEL),testId:`${t}-kind`})]}),(0,P.jsx)(j,{testId:`${t}-api-key`,name:`${t}-api-key`,type:`password`,label:l(o.BACKEND$KEY_LABEL),value:m,onChange:e=>{h(e),_(null)},placeholder:`sk-••••••••••`,className:`w-full`}),g?(0,P.jsx)(`div`,{role:`alert`,"data-testid":`${t}-error`,className:`rounded-md border border-red-500/40 bg-red-500/10 p-3 text-sm text-red-300 whitespace-pre-wrap break-words`,children:g}):null,(0,P.jsx)(O,{type:`submit`,variant:`secondary`,isDisabled:!x||v,testId:c??`${t}-submit`,className:`w-full text-center`,children:v?s:i})]})}function ge({onConnected:e,testIdRoot:t,lockedHost:n}){let{t:r}=a(`openhands`),[i,s]=N.useState(!1),[c,l]=N.useState(``),u=n??(c.trim()||X);return(0,P.jsxs)(`div`,{className:`flex flex-1 min-w-0 flex-col items-center gap-3 pb-8`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,P.jsx)(F,{width:56,height:56,"aria-hidden":!0}),(0,P.jsx)(`h4`,{className:D,"data-testid":`${t}-cloud-title`,children:r(o.BACKEND$CLOUD_TITLE)})]}),(0,P.jsx)(`p`,{className:`text-center text-sm leading-relaxed text-[var(--oh-muted)]`,children:r(o.BACKEND$CLOUD_DESCRIPTION)}),(0,P.jsx)(K,{host:u,onSuccess:t=>{e({name:`OpenHands Cloud`,host:J(u),apiKey:t,kind:`cloud`},`cloud_login`)},testIdRoot:t}),n?null:(0,P.jsxs)(`div`,{className:`w-full`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":i,"data-testid":`${t}-advanced-toggle`,className:`flex w-full cursor-pointer items-center justify-center gap-1 text-center text-xs text-[var(--oh-muted)] transition-colors hover:text-content-2`,children:[(0,P.jsx)(`span`,{children:r(o.BACKEND$ADVANCED)}),(0,P.jsx)(V,{className:m(`h-4 w-4 shrink-0 text-muted transition-transform`,i&&`rotate-180`),"aria-hidden":!0})]}),(0,P.jsxs)(`div`,{className:m(`pt-2`,!i&&`pointer-events-none invisible`),"aria-hidden":!i,children:[(0,P.jsx)(j,{testId:`${t}-cloud-host`,name:`${t}-cloud-host`,type:`text`,label:r(o.BACKEND$HOST_LABEL),value:c,onChange:l,placeholder:X,className:`w-full`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oh-muted)]`,children:r(o.BACKEND$LOGIN_CLOUD_HINT)})]})]})]})}function _e({onClose:e,source:t}){let{addBackend:n}=p(),r=me(),{trackBackendAdded:i}=M();return(0,P.jsx)($,{onConnected:N.useCallback((a,o)=>{n(a);let s=a.host===X;i({backendKind:a.kind,connectionMethod:o,isOpenhandsCloud:s,isCustomHost:!s,hasApiKey:!!a.apiKey,source:t}),r(),e()},[n,r,e,i,t])})}function ve({mode:e,backend:t,onClose:n,source:r=`add_backend_modal`,hideCloseButton:i=!1}){let{t:s}=a(`openhands`);if(e===`add`)return(0,P.jsx)(S,{onClose:i?void 0:n,closeOnEscape:!1,closeOnBackdropClick:!i,"aria-label":s(o.BACKEND$ADD_TITLE),children:(0,P.jsxs)(`div`,{"data-testid":i?`onboarding-modal`:`add-backend-modal`,className:m(`relative rounded-xl border border-[var(--oh-border)] bg-base-secondary`,w(`xl`),T),children:[i?null:(0,P.jsx)(A,{onClose:n,testId:`add-backend-close`}),i?null:(0,P.jsx)(`div`,{className:`px-6 pt-6 pb-2 pr-12`,children:(0,P.jsx)(`h2`,{className:E,children:s(o.BACKEND$ADD_TITLE)})}),(0,P.jsx)(`div`,{className:m(`px-6 pb-6`,i?`pt-6`:`pt-2`),children:(0,P.jsx)(_e,{onClose:n,source:r})})]})});let c=`edit-backend`;return(0,P.jsx)(S,{onClose:n,closeOnEscape:!1,"aria-label":s(o.BACKEND$EDIT_TITLE),children:(0,P.jsxs)(`div`,{"data-testid":`${c}-modal`,className:m(`relative bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]`,w(`md`)),children:[(0,P.jsx)(A,{onClose:n,testId:`${c}-close`}),(0,P.jsx)(`h2`,{className:m(`pr-6`,E),children:s(o.BACKEND$EDIT_TITLE)}),(0,P.jsx)(Q,{mode:`edit`,backend:t,onSubmitted:n,testIdRoot:c})]})})}export{K as a,V as c,oe as i,Q as n,U as o,ve as r,H as s,$ as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bt as e}from"./vendor-styling-CI0PQ3ab.js";import{t}from"./useTranslation-CDRCKC9-.js";import{t as n}from"./declaration-gq8V5eTU.js";import{n as r}from"./active-backend-context-
|
|
1
|
+
import{bt as e}from"./vendor-styling-CI0PQ3ab.js";import{t}from"./useTranslation-CDRCKC9-.js";import{t as n}from"./declaration-gq8V5eTU.js";import{n as r}from"./active-backend-context-hxq31W25.js";import{n as i,t as a}from"./use-cloud-current-user-id-utFreJ0i.js";import{r as o}from"./typography-D8mHDeNG.js";var s=e();function c(){let{t:e}=t(),o=r(),s=i(),c=a();if(o.backend.kind!==`cloud`||!o.orgId)return o.backend.name;let l=s[o.backend.id]?.orgs.find(e=>e.id===o.orgId);if(!l)return o.backend.name;let u=c[o.backend.id]?.userId??null,d=u&&l.id===u?e(n.BACKEND$PERSONAL_WORKSPACE):l.name;return`${o.backend.name} – ${d}`}function l(){let{t:e}=t(),i=r(),a=c();return(0,s.jsx)(`div`,{"data-testid":`backend-synced-settings-badge`,className:`flex items-center`,children:(0,s.jsx)(o.Text,{className:`text-[11px] font-medium text-[var(--oh-text-dim)] leading-5`,children:e(n.SETTINGS$BACKEND_SYNCED_BADGE,{name:a,host:i.backend.host,interpolation:{escapeValue:!1}})})})}export{l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bt as e}from"./vendor-styling-CI0PQ3ab.js";import{L as t}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~byh8a1g4-XNPdpuO8.js";import{t as n}from"./sdk-section-page-
|
|
1
|
+
import{bt as e}from"./vendor-styling-CI0PQ3ab.js";import{L as t}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~byh8a1g4-XNPdpuO8.js";import{t as n}from"./sdk-section-page-t82gsOqa.js";var r=e();function i(){return(0,r.jsx)(n,{settingsSources:[{settingsSource:`agent_settings`,sectionKeys:[`condenser`]}],testId:`condenser-settings-screen`})}var a=t(i);export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./conversation-BXg6Oti2.js";export{e as default};
|