@openhands/agent-canvas 1.0.0-rc.8 → 1.0.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.windows.md +2 -2
- package/build/assets/{acp-providers-BqUvf67Q.js → acp-providers-Dzb4nxxB.js} +1 -1
- package/build/assets/{active-backend-context-CNF2lPkA.js → active-backend-context-B2OSC-qe.js} +1 -1
- package/build/assets/{add-backend-modal-BywVr6uq.js → add-backend-modal-lG8XDYjr.js} +1 -1
- package/build/assets/{agent-server-adapter-k8veH-1O.js → agent-server-adapter-BPpZcLOE.js} +3 -3
- package/build/assets/agent-server-client-options-wXLeJYeM.js +1 -0
- package/build/assets/{agent-server-conversation-service.api-CGbkhsLj.js → agent-server-conversation-service.api-C4Fc9Jnp.js} +1 -1
- package/build/assets/{agent-settings-DoHXHcoA.js → agent-settings-Blipgztd.js} +1 -1
- package/build/assets/{analytics-consent-form-modal-CVhsAREx.js → analytics-consent-form-modal-Cujm1lCj.js} +1 -1
- package/build/assets/{api-key-entry-screen-Dnr5TcV0.js → api-key-entry-screen-BarZU9nr.js} +1 -1
- package/build/assets/{app-settings-Bgm2-yOM.js → app-settings-CofRfixq.js} +1 -1
- package/build/assets/{automation-detail-86M_yMqz.js → automation-detail-BV4Cn0O8.js} +1 -1
- package/build/assets/{automations-list-BWUILrqY.js → automations-list-BaJ61q7P.js} +1 -1
- package/build/assets/{backend-form-modal-Dl29wkF5.js → backend-form-modal-B3BCZDPq.js} +1 -1
- package/build/assets/{backend-synced-settings-badge-Dcd4712m.js → backend-synced-settings-badge-Da0G6Lwv.js} +1 -1
- package/build/assets/{chat-send-button-BhoO7T0s.js → chat-send-button-DzRpAQr4.js} +1 -1
- package/build/assets/{condenser-settings-DgQ0rsAf.js → condenser-settings-Bo07FAEi.js} +1 -1
- package/build/assets/{conversation-CayU5Lrr.js → conversation-DDdRyW4z.js} +3 -3
- package/build/assets/conversation-panel-Dww2uJOd.js +1 -0
- package/build/assets/conversation-rGQV1Eym.js +1 -0
- package/build/assets/{conversation-service.api-shHWtFwu.js → conversation-service.api-ByRiRU1e.js} +1 -1
- package/build/assets/{edit-automation-modal-8y9Uctxo.js → edit-automation-modal-CpA_JKLY.js} +1 -1
- package/build/assets/{entry.client-D_wtryHT.js → entry.client-DUpefbBp.js} +1 -1
- package/build/assets/{extensions-hub-CoWO3SzQ.js → extensions-hub-BYCLWP3d.js} +1 -1
- package/build/assets/{extensions-navigation-D5w2sFQe.js → extensions-navigation-3FLKfb6g.js} +1 -1
- package/build/assets/{files-tab-CxdtgkIe.js → files-tab-CBUPwSV1.js} +1 -1
- package/build/assets/{home-3joHMYSR.js → home-BDCL0Psk.js} +1 -1
- package/build/assets/{install-server-modal-_7l1gcjd.js → install-server-modal-CWZhBKwH.js} +1 -1
- package/build/assets/{launch-fU77utLO.js → launch-CMZknx1e.js} +1 -1
- package/build/assets/{lesson-plan-CHGc-B8Y.js → lesson-plan-y520IDs6.js} +1 -1
- package/build/assets/{llm-client-P9f2gKeW.js → llm-client-D6EtdLBs.js} +1 -1
- package/build/assets/{llm-not-configured-banner-BMGzpBPV.js → llm-not-configured-banner-CJyURBCm.js} +1 -1
- package/build/assets/llm-settings-BW6yW2Go.js +1 -0
- package/build/assets/{llm-settings-yDgbXP6Q.js → llm-settings-CiY22Wzi.js} +1 -1
- package/build/assets/{manage-backends-modal-tfdzTXWU.js → manage-backends-modal-v5POMal5.js} +1 -1
- package/build/assets/{manifest-bbc1374e.js → manifest-eccb7f46.js} +1 -1
- package/build/assets/{mcp-Dopstf0t.js → mcp-DgPFZ_Dv.js} +1 -1
- package/build/assets/{messages-CsFUrAen.js → messages-Dq6AQ8mp.js} +1 -1
- package/build/assets/{model-selector-sioC8xP4.js → model-selector-CdZs21EZ.js} +1 -1
- package/build/assets/{onboarding-CQh50i2z.js → onboarding-Cdwu8QIy.js} +1 -1
- package/build/assets/{option-service.api-DjPvPAtd.js → option-service.api-CdYnKVsu.js} +1 -1
- package/build/assets/{organization-service.api-BNc9Kn6n.js → organization-service.api-CzMvXIQT.js} +1 -1
- package/build/assets/{path-utils-YlkpoImJ.js → path-utils-DKu3CNkH.js} +1 -1
- package/build/assets/{planner-tab-DjIFIQDk.js → planner-tab-YkOp7QXt.js} +1 -1
- package/build/assets/{profiles-client-BNvHck-I.js → profiles-client-BjUo3q05.js} +1 -1
- package/build/assets/{providers-BiWSYwRT.js → providers-CbpQft-X.js} +1 -1
- package/build/assets/{proxy--Uy1iGsW.js → proxy-Bx3NeKeo.js} +1 -1
- package/build/assets/{recommended-automations-launcher-DCi0RXIj.js → recommended-automations-launcher-WxaZcjRD.js} +1 -1
- package/build/assets/{root-DrHpnAqU.js → root-CiNoOVrb.js} +2 -2
- package/build/assets/{root-layout-Cf7FC9DC.js → root-layout-DUw-s9LS.js} +2 -2
- package/build/assets/{sdk-section-page-COlGKv4E.js → sdk-section-page-DPBwwLle.js} +1 -1
- package/build/assets/{secrets-service-D6Gcymcs.js → secrets-service-Skzza9sx.js} +1 -1
- package/build/assets/{secrets-settings-DYfTc5c8.js → secrets-settings-DmpsTC9V.js} +1 -1
- package/build/assets/{settings-DRmVFdOc.js → settings-ChsRtIJQ.js} +1 -1
- package/build/assets/{settings-index-B035V2pu.js → settings-index-BLfmrKRl.js} +1 -1
- package/build/assets/{settings-modal-CeRvS5Bc.js → settings-modal-Cth7Zb-I.js} +1 -1
- package/build/assets/{settings-service.api-CFt5HmXD.js → settings-service.api-CcpckquT.js} +1 -1
- package/build/assets/{shared-conversation-CBbpyPaD.js → shared-conversation-Y0C8zqdr.js} +1 -1
- package/build/assets/{sidebar-mobile-menu-toggle-SKcwsEtD.js → sidebar-mobile-menu-toggle-BvcBXvLY.js} +1 -1
- package/build/assets/{sidebar-nav-link-CPWuQ_c6.js → sidebar-nav-link-BekRAssb.js} +1 -1
- package/build/assets/{skills-client-Ui_9FvXp.js → skills-client-CgraS-wA.js} +1 -1
- package/build/assets/{skills-plugins-Dc4ec3CW.js → skills-plugins-rIza_fUf.js} +1 -1
- package/build/assets/{skills-settings-B6HwvA0S.js → skills-settings-Dvl7gpEx.js} +1 -1
- package/build/assets/{telemetry-DCFAqpIA.js → telemetry-CAWBJ_rB.js} +1 -1
- package/build/assets/{terminal-CltMeLv4.js → terminal-BFypysgZ.js} +1 -1
- package/build/assets/{use-acp-credential-form-LjCIhMSK.js → use-acp-credential-form-Dj7Jkhgp.js} +1 -1
- package/build/assets/{use-active-conversation-B0_rXnqa.js → use-active-conversation-BkohEtaN.js} +1 -1
- package/build/assets/{use-agent-settings-schema-D8x5LJVS.js → use-agent-settings-schema-Lf_lBAky.js} +1 -1
- package/build/assets/{use-agent-state-BuOzLeFN.js → use-agent-state-DITv5qV7.js} +1 -1
- package/build/assets/{use-cloud-current-user-id-DVZXa_WH.js → use-cloud-current-user-id-CSm3kgqy.js} +1 -1
- package/build/assets/{use-config-5zEjywCL.js → use-config-DVU9HaPf.js} +1 -1
- package/build/assets/{use-create-conversation-pV2eA-e9.js → use-create-conversation-CJUAOf1q.js} +1 -1
- package/build/assets/{use-create-secret-ClPpLBgD.js → use-create-secret-LObNBU3M.js} +1 -1
- package/build/assets/{use-handle-plan-click-CwN_nNib.js → use-handle-plan-click-BdcdMWbv.js} +1 -1
- package/build/assets/{use-llm-profiles-CWLfWjav.js → use-llm-profiles-BBTR-OsK.js} +1 -1
- package/build/assets/use-runtime-is-ready-BOQpqCvp.js +1 -0
- package/build/assets/{use-save-settings-Xp8DD-jf.js → use-save-settings-7_MLft-Y.js} +1 -1
- package/build/assets/{use-settings-0SeqaDeW.js → use-settings-CNsxccvQ.js} +1 -1
- package/build/assets/{use-settings-nav-items-DVrMNk0I.js → use-settings-nav-items-ykMjd_NG.js} +1 -1
- package/build/assets/{use-skills-Bv8LXrys.js → use-skills-_unimM2d.js} +1 -1
- package/build/assets/{use-tracking-BhyV5A9i.js → use-tracking-C9P88zSo.js} +1 -1
- package/build/assets/{use-user-conversation-6yFVEXiG.js → use-user-conversation-2jZZ-MLA.js} +1 -1
- package/build/assets/{vendor~root-layout~home~conversation-panel~conversation~launch~mcp~settings~settings-index~~m3acswdn-CGm-Jxp5.js → vendor~root-layout~home~conversation-panel~conversation~launch~mcp~settings~settings-index~~m3acswdn-DQE89epK.js} +1 -1
- package/build/assets/{verification-settings-Be6NxjuT.js → verification-settings-EUkt_CkZ.js} +1 -1
- package/build/index.html +4 -4
- package/config/defaults.json +1 -6
- 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/dist/utils/websocket-url.cjs +1 -1
- package/dist/utils/websocket-url.cjs.map +1 -1
- package/dist/utils/websocket-url.js +2 -2
- package/dist/utils/websocket-url.js.map +1 -1
- package/package.json +1 -1
- package/build/assets/agent-server-client-options-B-C8JaTb.js +0 -1
- package/build/assets/conversation-erinyBqT.js +0 -1
- package/build/assets/conversation-panel-DiI4q-8-.js +0 -1
- package/build/assets/llm-settings-BRotm_g6.js +0 -1
- package/build/assets/use-runtime-is-ready-Bbory9-s.js +0 -1
package/README.md
CHANGED
|
@@ -82,7 +82,7 @@ docker run -it --rm \
|
|
|
82
82
|
-p 8000:8000 \
|
|
83
83
|
-v "$HOME/.openhands:/home/openhands/.openhands" \
|
|
84
84
|
-v "${PROJECTS_PATH}:/projects" \
|
|
85
|
-
ghcr.io/openhands/agent-canvas:1.0.0-rc.
|
|
85
|
+
ghcr.io/openhands/agent-canvas:1.0.0-rc.9
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
**Windows (PowerShell / Windows Terminal):** See [README.windows.md](./README.windows.md) for the equivalent commands.
|
package/README.windows.md
CHANGED
|
@@ -12,7 +12,7 @@ For the main install options and overall context, see [README.md](./README.md).
|
|
|
12
12
|
- A host directory for `PROJECTS_PATH` containing the project folders you want the agent to access (create it before starting the container)
|
|
13
13
|
|
|
14
14
|
```powershell
|
|
15
|
-
docker pull ghcr.io/openhands/agent-canvas:1.0.0-rc.
|
|
15
|
+
docker pull ghcr.io/openhands/agent-canvas:1.0.0-rc.9
|
|
16
16
|
|
|
17
17
|
$env:PROJECTS_PATH = Join-Path $HOME "projects" # directory containing your project folders
|
|
18
18
|
New-Item -ItemType Directory -Force -Path $env:PROJECTS_PATH, (Join-Path $env:USERPROFILE ".openhands") | Out-Null
|
|
@@ -21,7 +21,7 @@ docker run -it --rm `
|
|
|
21
21
|
-p 8000:8000 `
|
|
22
22
|
-v "$($env:USERPROFILE)\.openhands:/home/openhands/.openhands" `
|
|
23
23
|
-v "$($env:PROJECTS_PATH):/projects" `
|
|
24
|
-
ghcr.io/openhands/agent-canvas:1.0.0-rc.
|
|
24
|
+
ghcr.io/openhands/agent-canvas:1.0.0-rc.9
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
The agent will be able to access any project under `PROJECTS_PATH`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./declaration-D9ucT0fq.js";import{n as t}from"./vendor~root-layout~home~conversation-panel~conversation~launch~mcp~settings~settings-index~~m3acswdn-
|
|
1
|
+
import{t as e}from"./declaration-D9ucT0fq.js";import{n as t}from"./vendor~root-layout~home~conversation-panel~conversation~launch~mcp~settings~settings-index~~m3acswdn-DQE89epK.js";var n=`cli-generic`,r=new Set([`default`,`default (recommended)`]);function i(e){if(typeof e!=`string`)return null;let t=e.trim();return!t||r.has(t.toLowerCase())||t===`acp-managed`?null:t}function a(e){for(let t of[e.runtimeName,e.runtimeId,e.configured,e.sdkLlm]){let e=i(t);if(e)return e}return e.providerDefault??null}var o={"claude-code":{icon:`claude-code`,description_key:e.ONBOARDING$AGENT_CLAUDE_CODE_DESCRIPTION},codex:{icon:`codex`,description_key:e.ONBOARDING$AGENT_CODEX_DESCRIPTION},"gemini-cli":{icon:`gemini`,description_key:e.ONBOARDING$AGENT_GEMINI_CLI_DESCRIPTION}},s=Object.entries(o).map(([e,n])=>{let r=t(e);return{key:e,display_name:r?.display_name??e,default_command:r?[...r.default_command]:[],available_models:r?.available_models?.map(e=>({id:e.id,label:e.label})),default_model:r?.default_model??void 0,description_key:n.description_key,icon:n.icon}}),c=`custom`,l={codex:[{name:`CODEX_AUTH_JSON`,secret:!0,multiline:!0,hint_key:e.ONBOARDING$ACP_SECRET_FILE_BLOB_HINT,hint_values:{file:`~/.codex/auth.json`}}],"claude-code":[{name:`CLAUDE_CODE_OAUTH_TOKEN`,secret:!0,hint_key:e.ONBOARDING$ACP_SECRET_OAUTH_TOKEN_HINT}],"gemini-cli":[{name:`GOOGLE_APPLICATION_CREDENTIALS_JSON`,secret:!0,multiline:!0,hint_key:e.ONBOARDING$ACP_SECRET_FILE_BLOB_HINT,hint_values:{file:`~/.config/gcloud/application_default_credentials.json`}},{name:`GOOGLE_CLOUD_PROJECT`,hint_key:e.ONBOARDING$ACP_SECRET_GCP_PROJECT_HINT},{name:`GOOGLE_CLOUD_LOCATION`,hint_key:e.ONBOARDING$ACP_SECRET_GCP_LOCATION_HINT},{name:`GOOGLE_GENAI_USE_VERTEXAI`,hint_key:e.ONBOARDING$ACP_SECRET_VERTEXAI_FLAG_HINT}]},u={"claude-code":[[`CLAUDE_CODE_OAUTH_TOKEN`,`ANTHROPIC_API_KEY`],[`CLAUDE_CODE_OAUTH_TOKEN`,`ANTHROPIC_BASE_URL`]]};function d(e,t){return e?(u[e]??[]).filter(([e,n])=>t(e)&&t(n)):[]}var f=`gemini-2.5-pro`;function p(e){return e===`gemini-cli`?f:h(e)?.default_model??null}function m(n){if(!n)return[];let r=t(n);if(!r)return[];let i=[...l[n]??[]];return r.api_key_env_var&&i.push({name:r.api_key_env_var,secret:!0,hint_key:e.ONBOARDING$ACP_SECRET_API_KEY_HINT}),r.base_url_env_var&&i.push({name:r.base_url_env_var,hint_key:e.ONBOARDING$ACP_SECRET_BASE_URL_HINT}),i}function h(e){if(e)return s.find(t=>t.key===e)}function g(e){let t=h(e);return t?t.display_name:null}function _(e){return h(e)?.icon??`cli-generic`}function v(e,t){return t?h(e)?.available_models?.find(e=>e.id===t)?.label??t:null}function y(e,t={}){if(e===`openhands`)return{agent_kind:`openhands`};let n=e===c,r=n?void 0:h(e);if(!n&&!r&&!t.allowUnknownServer)return null;let i=t.model===void 0?p(e):t.model;return{agent_kind:`acp`,acp_server:e,acp_command:t.command??[],acp_args:[],acp_model:i??null}}export{d as a,g as c,_ as d,a as f,y as i,m as l,s as n,p as o,n as r,h as s,c as t,v as u};
|
package/build/assets/{active-backend-context-CNF2lPkA.js → active-backend-context-B2OSC-qe.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{o as n}from"./declaration-D9ucT0fq.js";import{o as r,r as i,u as a}from"./query-client-config-Ca3tW1AH.js";import{D as o,O as s,S as c,a as l,c as u,d,f,h as p,i as m,l as h,n as g,o as _,p as v,s as y,u as b}from"./agent-server-client-options-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{o as n}from"./declaration-D9ucT0fq.js";import{o as r,r as i,u as a}from"./query-client-config-Ca3tW1AH.js";import{D as o,O as s,S as c,a as l,c as u,d,f,h as p,i as m,l as h,n as g,o as _,p as v,s as y,u as b}from"./agent-server-client-options-wXLeJYeM.js";var x=class{constructor(e){this.host=e.host.replace(/\/$/,``),this.apiKey=e.apiKey,this.client=new s({baseUrl:this.host,apiKey:this.apiKey,timeout:e.timeout||6e4})}async getRoot(){return(await this.client.get(`/`)).data}async getAlive(){return(await this.client.get(`/alive`)).data}async getHealth(){return(await this.client.get(`/health`)).data}async getReady(){return(await this.client.get(`/ready`,{acceptableStatusCodes:new Set([200,503])})).data}async getServerInfo(){return(await this.client.get(`/server_info`)).data}close(){this.client.close()}},S=e(t(),1),C=5e3,w=null,T=e=>Array.isArray(e?.usable_tools)?e.usable_tools:null,E=class extends Error{details;noBackendConfigured;constructor(e,t){let n=t?.noBackendConfigured??!1;super(n?`No agent server backend is configured yet. Add a backend to get started.`:`Could not connect to the configured agent server. Make sure it is running and reachable, then reload the page.`),this.name=`AgentServerUnavailableError`,this.details=e??null,this.noBackendConfigured=n}},D=e=>e instanceof E||typeof e==`object`&&!!e&&`name`in e&&e.name===`AgentServerUnavailableError`,O=e=>c()&&M(e,401);function k(){w=null}function A(e){let t=T(w);return Array.isArray(t)?t.includes(e):!0}function j(e){return e instanceof Error&&e.name===`HttpError`&&`status`in e&&typeof e.status==`number`}function M(e,t){return j(e)&&e.status===t}async function N(){let e=y();if(!e){if(k(),b(l().backend))throw new E(`No backend configured`,{noBackendConfigured:!0});return null}let t=g({host:e.host,sessionApiKey:e.apiKey||null,timeout:C}),n;try{n=await new x(t).getServerInfo()}catch(e){throw k(),M(e,401)?e:new E(e instanceof Error?e.message:null)}if(c())try{await new o(t).getSettings()}catch(e){if(M(e,401))throw e;console.warn(`[agent-server] getSettings() probe failed (non-401):`,e)}return w=n,n}var P={WEB_CLIENT_CONFIG:[`web-client-config`]},F={all:[`settings`],byScope:e=>[`settings`,e],personal:()=>[`settings`,`personal`]},I={all:[`llm-profiles`]},L={all:[`local-workspaces`]},R={staleTime:1e3*60*5,gcTime:1e3*60*15},z=n(),B=S.createContext(null);function V(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`backend-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function H({children:e}){let t=S.useSyncExternalStore(v,h,h),n=S.useCallback(()=>{k(),i.invalidateQueries({queryKey:P.WEB_CLIENT_CONFIG})},[]),o=S.useCallback((e,t)=>{let r=_()?.backendId??null,i=_()?.orgId??null,a=t??null;e===r&&a===i||(d({backendId:e,orgId:a}),n())},[n]),s=S.useCallback(e=>{let t={...e,id:V()};return f([...u(),t]),d({backendId:t.id}),n(),t},[n]),c=S.useCallback((e,t)=>{let r=u().find(t=>t.id===e),i=_()?.backendId??null;f(u().map(n=>n.id===e?{...n,...t}:n));let o=t.host!==void 0&&r!==void 0&&t.host!==r.host,s=t.apiKey!==void 0&&r!==void 0&&t.apiKey!==r.apiKey;(o||s)&&(a(e),i===e&&n())},[n]),l=S.useCallback(e=>{f(u().filter(t=>t.id!==e)),r(e),n()},[n]),p=S.useMemo(()=>({backends:t.backends,active:t.active,setActive:o,addBackend:s,updateBackend:c,removeBackend:l}),[t,o,s,c,l]);return(0,z.jsx)(B.Provider,{value:p,children:e})}function U(){let e=S.useContext(B);if(!e)throw Error(`useActiveBackendContext must be used inside <ActiveBackendProvider>`);return e}function W(){let e=S.useContext(B);return e?e.active:{backend:p()??m,orgId:null}}export{I as a,F as c,A as d,D as f,x as h,R as i,k as l,N as m,W as n,L as o,M as p,U as r,P as s,H as t,O as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-BFRubm34.js";import{o as t}from"./declaration-D9ucT0fq.js";import{n}from"./backend-form-modal-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-BFRubm34.js";import{o as t}from"./declaration-D9ucT0fq.js";import{n}from"./backend-form-modal-B3BCZDPq.js";var r=e({AddBackendModal:()=>a}),i=t();function a({onClose:e}){return(0,i.jsx)(n,{mode:`add`,onClose:e})}export{r as n,a as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/secrets-service-
|
|
2
|
-
import{t as e}from"./preload-helper-CT1Z6Pdu.js";import{t}from"./common-Dh7OqABE.js";import{n,s as r,x as i}from"./agent-server-client-options-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/secrets-service-Skzza9sx.js","assets/rolldown-runtime-BFRubm34.js","assets/agent-server-client-options-wXLeJYeM.js","assets/proxy-Bx3NeKeo.js","assets/vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~bxn4ldi1-_LydBB1e.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{t as e}from"./preload-helper-CT1Z6Pdu.js";import{t}from"./common-Dh7OqABE.js";import{n,s as r,x as i}from"./agent-server-client-options-wXLeJYeM.js";import{d as a}from"./active-backend-context-B2OSC-qe.js";import{t as o}from"./vendor~root-layout~home~conversation-panel~conversation~launch~mcp~settings~settings-index~~m3acswdn-DQE89epK.js";import{n as s}from"./proxy-Bx3NeKeo.js";import{t as c}from"./vendor~root-layout~home~conversation-panel~conversation~launch~skills-settings~mcp~automati~dou5smdo-DavKsAvB.js";import{t as l}from"./settings-wh2sLLJM.js";import{f as u,o as d,s as f}from"./acp-providers-Dzb4nxxB.js";import{t as p}from"./settings-service.api-CcpckquT.js";var m=[];for(let e=0;e<256;++e)m.push((e+256).toString(16).slice(1));function h(e,t=0){return(m[e[t+0]]+m[e[t+1]]+m[e[t+2]]+m[e[t+3]]+`-`+m[e[t+4]]+m[e[t+5]]+`-`+m[e[t+6]]+m[e[t+7]]+`-`+m[e[t+8]]+m[e[t+9]]+`-`+m[e[t+10]]+m[e[t+11]]+m[e[t+12]]+m[e[t+13]]+m[e[t+14]]+m[e[t+15]]).toLowerCase()}var g=new Uint8Array(16);function _(){return crypto.getRandomValues(g)}function v(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():y(e,t,n)}function y(e,t,n){e||={};let r=e.random??e.rng?.()??_();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return h(r)}var b=`openhands-agent-server-conversation-metadata`,x=()=>{if(typeof window>`u`)return{};try{let e=window.localStorage.getItem(b);if(!e)return{};let t=JSON.parse(e);return!t||typeof t!=`object`?{}:t}catch{return{}}},S=e=>{if(!(typeof window>`u`)){if(Object.keys(e).length===0){window.localStorage.removeItem(b);return}window.localStorage.setItem(b,JSON.stringify(e))}},C=e=>x()[e]??null,w=(e,t)=>{let n=x();n[e]=t,S(n)},T=e=>{let t=x();e in t&&(delete t[e],S(t))},E=`canvas_ui`,D=`canvas_ui_tool`,O=[`terminal`,`file_editor`,`task_tracker`,E],k=`browser_tool_set`,A=`task_tool_set`;function j(){return!0}function M(){let e=(void 0)?.trim();if(e)return e;if(typeof window<`u`){let e=window.__AGENT_CANVAS_RUNTIME_SERVICES_INFO__;if(typeof e==`string`)return e.trim()||null}return null}function N(){let e=M();if(!e)return null;try{let t=JSON.parse(e);return!t||typeof t!=`object`?null:t}catch{return null}}function P(){return N()?.mode??null}function F(){let e=N();if(!e?.services)return;let t=[];t.push(`<RUNTIME_SERVICES>`),e.mode?t.push(`You are running inside an agent-canvas dev stack started in '${e.mode}' mode.`):t.push(`You are running inside an agent-canvas dev stack.`),t.push(`The following services are reachable from your sandbox. URLs are written`,`from your point of view (i.e., as you should curl/fetch them).`,``);let{agent_server:n,ingress:r,automation:i}=e.services,a=e.services.frontend??e.services.vite;n?.url_from_agent&&t.push(`* Agent Server (you): ${n.url_from_agent}`,` ${n.description??`The agent-server hosting your tool calls.`}`),r?.url_from_agent&&t.push(`* Ingress: ${r.url_from_agent}`,` ${r.description??`Unified entry point for browser-facing traffic.`}`),a?.url_from_agent&&t.push(`* Frontend: ${a.url_from_agent}`,` ${a.description??`Frontend dev server.`}`),i?.url_from_agent?(t.push(`* Automation backend: ${i.url_from_agent}`,` ${i.description??`OpenHands Automations service.`}`),i.docs_url&&t.push(` Docs: ${i.docs_url}`),i.openapi_url&&t.push(` OpenAPI: ${i.openapi_url}`),i.auth_env_var&&t.push(` Auth: header 'X-Session-API-Key: $${i.auth_env_var}'`)):t.push(`* Automation backend: not running in this dev mode (skip /api/automation calls).`);let o=n?.url_from_agent;return t.push(``,`Trust this block over guessing: do not assume any other URLs are running.`),o&&t.push(`In particular, ${o} inside your sandbox is the Agent Server`,`you are running inside of — NOT the automation backend.`),t.push(`</RUNTIME_SERVICES>`),t.join(`
|
|
3
3
|
`)}function I(e){let{host:t}=n();return`${t}/api/conversations/${e}`}function L(e){return`Conversation ${e.slice(0,5)}`}function R(e){let r=C(e.id),a=e.agent?.kind===`ACPAgent`,o=a?e.tags?.acpserver??null:null;return{id:e.id,created_by_user_id:null,selected_repository:r?.selected_repository??null,selected_branch:r?.selected_branch??null,git_provider:r?.git_provider??null,selected_workspace:r?.selected_workspace??null,active_profile:r?.active_profile??null,title:e.title?.trim()?e.title:L(e.id),trigger:null,pr_number:[],agent_kind:a?`acp`:`openhands`,acp_server:o,llm_model:a?u({runtimeName:e.current_model_name,runtimeId:e.current_model_id,configured:e.agent?.acp_model,sdkLlm:e.agent?.llm?.model}):e.agent?.llm?.model??l.llm_model,metrics:e.metrics?{accumulated_cost:e.metrics.accumulated_cost??null,max_budget_per_task:e.metrics.max_budget_per_task??null,accumulated_token_usage:e.metrics.accumulated_token_usage?{prompt_tokens:e.metrics.accumulated_token_usage.prompt_tokens??0,completion_tokens:e.metrics.accumulated_token_usage.completion_tokens??0,cache_read_tokens:e.metrics.accumulated_token_usage.cache_read_tokens??0,cache_write_tokens:e.metrics.accumulated_token_usage.cache_write_tokens??0,context_window:e.metrics.accumulated_token_usage.context_window??0,per_turn_token:e.metrics.accumulated_token_usage.per_turn_token??0}:null}:null,created_at:e.created_at,updated_at:e.updated_at,execution_status:e.execution_status??t.IDLE,sandbox_status:e.sandbox_status??null,conversation_url:I(e.id),session_api_key:n().apiKey??null,sandbox_id:null,workspace:{working_dir:e.workspace?.working_dir??i()},public:!1,sub_conversation_ids:[]}}function z(e){return{items:e.items.map(R),next_page_id:e.next_page_id??null}}var B=`acpserver`,V=new Set([`schema_version`,`agent_settings`,`workspace`,`conversation_id`,`initial_message`,`plugins`]);function H(e){return!e||typeof e!=`object`||Array.isArray(e)?{}:structuredClone(e)}function U(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function ee(e){return e.confirmation_mode===!0?e.security_analyzer===`llm`?{kind:`ConfirmRisky`,threshold:`HIGH`,confirm_unknown:!0}:{kind:`AlwaysConfirm`}:{kind:`NeverConfirm`}}function W(e){switch(e.security_analyzer){case`llm`:return{kind:`LLMSecurityAnalyzer`};case`pattern`:return{kind:`PatternSecurityAnalyzer`};case`policy_rail`:return{kind:`PolicyRailSecurityAnalyzer`};default:return}}function G(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&typeof e.name==`string`}function K(e,t){return e===k?j()&&a(e):e===A?t.enable_sub_agents===!0&&a(e):!0}function q(e){let t=new Map;for(let e of O)t.set(e,{name:e,params:{}});for(let n of[k,A])K(n,e)&&t.set(n,{name:n,params:{}});let n=e.tools;if(Array.isArray(n)&&n.every(e=>G(e)))for(let r of n)K(r.name,e)&&t.set(r.name,{name:r.name,params:H(r.params)});return Array.from(t.values())}function J(e,t){let n=[e?.trim(),t?.trim()].filter(Boolean);return n.length===0?null:{role:`user`,content:[{type:`text`,text:n.join(`
|
|
4
4
|
|
|
5
|
-
`)}],run:!0}}function Y(){return c.map(e=>{let t=e.triggers?.length>0?{type:`keyword`,keywords:e.triggers}:null;return{name:e.name,content:e.content,trigger:t,source:`public`,description:e.description??null,is_agentskills_format:!0,...e.license?{license:e.license}:{},...e.compatibility?{compatibility:e.compatibility}:{}}})}function X(e){let t=F(),n=H(e.agent_context),r=[...Array.isArray(n.skills)?n.skills:[],...Y()];return{...n,skills:r,load_public_skills:!1,load_user_skills:!0,load_project_skills:!0,...t?{system_message_suffix:t}:{}}}function Z(e){return H(e.agent_settings).agent_kind===`acp`}function Q(e){let t=H(e.agent_settings).acp_server;return typeof t==`string`&&t.length>0?t:void 0}function $(e){let t=e.acp_command;if(!(Array.isArray(t)&&t.length===0)&&t!==void 0)return t;let n=f(typeof e.acp_server==`string`?e.acp_server:void 0);return n?[...n.default_command]:t}function te(e){let t=H(e.agent_settings),n={agent_kind:`acp`,agent_context:X(t)};for(let e of o){if(e===`acp_model`||e===`acp_env`)continue;let r=e===`acp_command`?$(t):t[e];r!=null&&(n[e]=r)}let r=H(t.mcp_config);Object.keys(r).length>0&&`mcpServers`in r&&(n.mcp_config=r);let i=typeof t.acp_server==`string`?t.acp_server:void 0,a=u({configured:t.acp_model,providerDefault:d(i)});return a&&(n.acp_model=a),n}function ne(e){let t=H(e.agent_settings),n=H(t.llm);n.model=typeof n.model==`string`&&n.model.trim().length>0?n.model:l.llm_model;let r=U(n.api_key);r?n.api_key=r:delete n.api_key;let i=U(n.base_url);i?n.base_url=i:delete n.base_url;let a=H(t.mcp_config);(Object.keys(a).length===0||!(`mcpServers`in a))&&delete t.mcp_config,delete t.acp_server;for(let e of o)delete t[e];return delete t.acp_env,{...t,llm:n,agent_context:X(t),tools:q(t)}}function re(e){return Z(e)?te(e):ne(e)}function ie(e){let{settings:t,query:n,conversationInstructions:r,plugins:a,workingDir:o}=e,s=H(t.conversation_settings),c=J(n,r);return V.forEach(e=>delete s[e]),{...s,workspace:{kind:`LocalWorkspace`,working_dir:o??i()},...c?{initial_message:c}:{},...a?.length?{plugins:a.map(e=>({source:e.source,...e.ref?{ref:e.ref}:{},...e.repo_path?{repo_path:e.repo_path}:{}}))}:{}}}function ae(e){let t=e.encryptedAgentSettings?{...e.settings,agent_settings:e.encryptedAgentSettings}:e.settings,n=Z(t),i=re(t),a=n?Q(t):void 0,o=ie(e.encryptedConversationSettings?{...e,settings:{...e.settings,conversation_settings:e.encryptedConversationSettings}}:e),c={agent_settings:i,workspace:o.workspace,confirmation_policy:ee(o),max_iterations:typeof o.max_iterations==`number`?o.max_iterations:500,stuck_detection:!0,autotitle:!0,worktree:e.worktree??!0};a&&(c.tags={[B]:a}),e.secretsEncrypted&&!n&&(c.secrets_encrypted=!0),e.conversationId&&(c.conversation_id=e.conversationId);let l=W(o);if(l&&(c.security_analyzer=l),o.initial_message&&(c.initial_message=o.initial_message),o.plugins&&(c.plugins=o.plugins),o.hook_config&&(c.hook_config=o.hook_config),c.tool_module_qualnames={[E]:D,...o.tool_module_qualnames??{}},o.agent_definitions&&(c.agent_definitions=o.agent_definitions),e.customSecrets&&e.customSecrets.length>0){let t=r(),n=t?s(t):{},i={};for(let t of e.customSecrets){let e={kind:`LookupSecret`,url:`/api/settings/secrets/${encodeURIComponent(t.name)}`,description:t.description};Object.keys(n).length>0&&(e.headers=n),i[t.name]=e}c.secrets=i}return c}async function oe(t){let{SecretsService:n}=await e(async()=>{let{SecretsService:e}=await import(`./secrets-service-
|
|
5
|
+
`)}],run:!0}}function Y(){return c.map(e=>{let t=e.triggers?.length>0?{type:`keyword`,keywords:e.triggers}:null;return{name:e.name,content:e.content,trigger:t,source:`public`,description:e.description??null,is_agentskills_format:!0,...e.license?{license:e.license}:{},...e.compatibility?{compatibility:e.compatibility}:{}}})}function X(e){let t=F(),n=H(e.agent_context),r=[...Array.isArray(n.skills)?n.skills:[],...Y()];return{...n,skills:r,load_public_skills:!1,load_user_skills:!0,load_project_skills:!0,...t?{system_message_suffix:t}:{}}}function Z(e){return H(e.agent_settings).agent_kind===`acp`}function Q(e){let t=H(e.agent_settings).acp_server;return typeof t==`string`&&t.length>0?t:void 0}function $(e){let t=e.acp_command;if(!(Array.isArray(t)&&t.length===0)&&t!==void 0)return t;let n=f(typeof e.acp_server==`string`?e.acp_server:void 0);return n?[...n.default_command]:t}function te(e){let t=H(e.agent_settings),n={agent_kind:`acp`,agent_context:X(t)};for(let e of o){if(e===`acp_model`||e===`acp_env`)continue;let r=e===`acp_command`?$(t):t[e];r!=null&&(n[e]=r)}let r=H(t.mcp_config);Object.keys(r).length>0&&`mcpServers`in r&&(n.mcp_config=r);let i=typeof t.acp_server==`string`?t.acp_server:void 0,a=u({configured:t.acp_model,providerDefault:d(i)});return a&&(n.acp_model=a),n}function ne(e){let t=H(e.agent_settings),n=H(t.llm);n.model=typeof n.model==`string`&&n.model.trim().length>0?n.model:l.llm_model;let r=U(n.api_key);r?n.api_key=r:delete n.api_key;let i=U(n.base_url);i?n.base_url=i:delete n.base_url;let a=H(t.mcp_config);(Object.keys(a).length===0||!(`mcpServers`in a))&&delete t.mcp_config,delete t.acp_server;for(let e of o)delete t[e];return delete t.acp_env,{...t,llm:n,agent_context:X(t),tools:q(t)}}function re(e){return Z(e)?te(e):ne(e)}function ie(e){let{settings:t,query:n,conversationInstructions:r,plugins:a,workingDir:o}=e,s=H(t.conversation_settings),c=J(n,r);return V.forEach(e=>delete s[e]),{...s,workspace:{kind:`LocalWorkspace`,working_dir:o??i()},...c?{initial_message:c}:{},...a?.length?{plugins:a.map(e=>({source:e.source,...e.ref?{ref:e.ref}:{},...e.repo_path?{repo_path:e.repo_path}:{}}))}:{}}}function ae(e){let t=e.encryptedAgentSettings?{...e.settings,agent_settings:e.encryptedAgentSettings}:e.settings,n=Z(t),i=re(t),a=n?Q(t):void 0,o=ie(e.encryptedConversationSettings?{...e,settings:{...e.settings,conversation_settings:e.encryptedConversationSettings}}:e),c={agent_settings:i,workspace:o.workspace,confirmation_policy:ee(o),max_iterations:typeof o.max_iterations==`number`?o.max_iterations:500,stuck_detection:!0,autotitle:!0,worktree:e.worktree??!0};a&&(c.tags={[B]:a}),e.secretsEncrypted&&!n&&(c.secrets_encrypted=!0),e.conversationId&&(c.conversation_id=e.conversationId);let l=W(o);if(l&&(c.security_analyzer=l),o.initial_message&&(c.initial_message=o.initial_message),o.plugins&&(c.plugins=o.plugins),o.hook_config&&(c.hook_config=o.hook_config),c.tool_module_qualnames={[E]:D,...o.tool_module_qualnames??{}},o.agent_definitions&&(c.agent_definitions=o.agent_definitions),e.customSecrets&&e.customSecrets.length>0){let t=r(),n=t?s(t):{},i={};for(let t of e.customSecrets){let e={kind:`LookupSecret`,url:`/api/settings/secrets/${encodeURIComponent(t.name)}`,description:t.description};Object.keys(n).length>0&&(e.headers=n),i[t.name]=e}c.secrets=i}return c}async function oe(t){let{SecretsService:n}=await e(async()=>{let{SecretsService:e}=await import(`./secrets-service-Skzza9sx.js`).then(e=>e.n);return{SecretsService:e}},__vite__mapDeps([0,1,2,3,4])),[r,i]=await Promise.all([p.getSettingsForConversation(),n.getSecrets()]),{agentSettings:a,conversationSettings:o,secretsEncrypted:s}=r;return ae({...t,encryptedAgentSettings:a,encryptedConversationSettings:o,secretsEncrypted:s,customSecrets:i})}function se(){return{hooks:[]}}export{R as a,T as c,P as i,w as l,se as n,z as o,L as r,C as s,oe as t,v as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends Error{constructor(e,t,n,r){super(r||`HTTP ${e}: ${t}`),this.status=e,this.statusText=t,this.response=n,this.name=`HttpError`}},t=class{constructor(e){this.baseUrl=e.baseUrl.replace(/\/$/,``),this.apiKey=e.apiKey,this.timeout=e.timeout||6e4}async request(t){let n=t.url.startsWith(`/`)?t.url.slice(1):t.url,r=new URL(n,this.baseUrl+`/`);t.params&&Object.entries(t.params).forEach(([e,t])=>{t!=null&&(Array.isArray(t)?t.forEach(t=>r.searchParams.append(e,String(t))):r.searchParams.append(e,String(t)))});let i={"Content-Type":`application/json`,...t.headers};this.apiKey&&(i[`X-Session-API-Key`]=this.apiKey);let a={method:t.method,headers:i,signal:AbortSignal.timeout(t.timeout||this.timeout)};t.credentials&&(a.credentials=t.credentials),t.data&&t.method!==`GET`&&(t.data instanceof FormData?(delete i[`Content-Type`],a.body=t.data):a.body=JSON.stringify(t.data));try{let n=await fetch(r.toString(),a);if(!(t.acceptableStatusCodes?.has(n.status)||!t.acceptableStatusCodes&&n.ok)){let t;try{t=n.headers.get(`content-type`)?.includes(`application/json`)?await n.json():await n.text()}catch{t=null}throw new e(n.status,n.statusText,t,`HTTP request failed (${n.status} ${n.statusText}): ${JSON.stringify(t)}`)}let i=await this.parseResponse(n,t.responseType||`auto`),o={};return n.headers.forEach((e,t)=>{o[t]=e}),{data:i,status:n.status,statusText:n.statusText,headers:o}}catch(n){throw n instanceof e?n:n instanceof Error?n.name===`AbortError`?Error(`Request timeout after ${t.timeout||this.timeout}ms`,{cause:n}):Error(`Request failed: ${n.message}`,{cause:n}):Error(`Unknown request error`,{cause:n})}}async parseResponse(e,t){return t===`json`?await e.json():t===`text`?await e.text():t===`blob`?await e.blob():t===`arrayBuffer`?await e.arrayBuffer():e.headers.get(`content-type`)?.includes(`application/json`)?await e.json():await e.text()}async get(e,t){return this.request({method:`GET`,url:e,...t})}async post(e,t,n){return this.request({method:`POST`,url:e,data:t,...n})}async put(e,t,n){return this.request({method:`PUT`,url:e,data:t,...n})}async patch(e,t,n){return this.request({method:`PATCH`,url:e,data:t,...n})}async delete(e,t){return this.request({method:`DELETE`,url:e,...t})}close(){}},n=class{constructor(e){this.host=e.host.replace(/\/$/,``),this.apiKey=e.apiKey,this.client=new t({baseUrl:this.host,apiKey:this.apiKey,timeout:e.timeout||6e4})}async getAgentSchema(){return(await this.client.get(`/api/settings/agent-schema`)).data}async getSettings(e={}){return(await this.client.get(`/api/settings`,{headers:e.exposeSecrets?{"X-Expose-Secrets":e.exposeSecrets}:void 0})).data}async updateSettings(e){return(await this.client.patch(`/api/settings`,e)).data}async listSecrets(){return(await this.client.get(`/api/settings/secrets`)).data}async upsertSecret(e){return(await this.client.put(`/api/settings/secrets`,e)).data}async getSecret(e){return(await this.client.get(`/api/settings/secrets/${encodeURIComponent(e)}`,{responseType:`text`})).data}async deleteSecret(e){return(await this.client.delete(`/api/settings/secrets/${encodeURIComponent(e)}`)).data}async getConversationSchema(){return(await this.client.get(`/api/settings/conversation-schema`)).data}async listProfiles(){return(await this.client.get(`/api/profiles`)).data}async getProfile(e,t={}){return(await this.client.get(`/api/profiles/${encodeURIComponent(e)}`,{headers:t.exposeSecrets?{"X-Expose-Secrets":t.exposeSecrets}:void 0})).data}async saveProfile(e,t){return(await this.client.post(`/api/profiles/${encodeURIComponent(e)}`,t)).data}async deleteProfile(e){return(await this.client.delete(`/api/profiles/${encodeURIComponent(e)}`)).data}async renameProfile(e,t){return(await this.client.post(`/api/profiles/${encodeURIComponent(e)}/rename`,{new_name:t})).data}close(){this.client.close()}};function r(e){if(e&&!e.startsWith(`/`))try{let t=new URL(e),n=t.hostname,r=window.location.hostname??window.location.host?.split(`:`)[0];return r&&(n===`localhost`||n===`127.0.0.1`)&&r!==`localhost`&&r!==`127.0.0.1`?`${r}:${t.port}`:t.host}catch{return window.location.host}return window.location.host}function i(e){if(e&&!e.startsWith(`/`))try{return(new URL(e).pathname.split(`/api/conversations`)[0]||``).replace(/\/$/,``)}catch{return``}return``}function a(e){let t=r(e),n=i(e),a=window.location.protocol===`https:`,s=o(e)===`https:`;return`${a||s?`https:`:`http:`}//${t}${n}`}function o(e){if(!e||e.startsWith(`/`))return null;try{return new URL(e).protocol}catch{return null}}function s(e,t){let n=r(e),a=i(e),s=window.location.protocol===`https:`,c=o(e)===`https:`,l=`${s||c?`wss:`:`ws:`}//${n}${a}/sockets/bash-events`;return t?`${l}?session_api_key=${encodeURIComponent(t)}`:l}function c(e,t){if(!e)return null;let n=r(t),a=i(t),s=window.location.protocol===`https:`,c=o(t)===`https:`;return`${s||c?`wss:`:`ws:`}//${n}${a}/sockets/events/${e}`}var l=`workspace/project`;function u(e){return e?.trim()||null}function ee(e){if(!e)return null;let t=e.trim().replace(/\/$/,``);return t?/^https?:\/\//i.test(t)?t:typeof window<`u`?`${window.location.protocol}//${t}`:`http://${t}`:null}function d(){return ee(void 0)}function f(){let e=u(void 0);if(e)return e;if(typeof window<`u`){let e=window.__AGENT_CANVAS_SESSION_API_KEY__;if(typeof e==`string`)return u(e)}return null}function p(){return{baseUrl:m()??``,sessionApiKey:h()??``}}function m(){return d()||(typeof window<`u`?window.location.origin:null)}function h(){return f()}function g(){return(void 0)?.trim()||l}function _(e){return`${g().replace(/\/+$/,``)}/${e.replace(/-/g,``)}`}function v(){let e=h();return e?{"X-Session-API-Key":e}:{}}function y(){return typeof window<`u`&&window.__AGENT_CANVAS_AUTH_REQUIRED__===!0}function b(){return y()?!h():!1}var x=`default-local`,S=`Local`;function C(){let e=m(),t=h();return!e||!t?null:{id:x,name:S,host:e,apiKey:t,kind:`local`}}var w=`openhands-backends`,T=`openhands-active-backend`,E=`openhands-agent-server-config`;function D(e){return e===`local`||e===`cloud`}function te(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.name==`string`&&typeof t.host==`string`&&typeof t.apiKey==`string`&&D(t.kind)}function ne(e){if(typeof e!=`string`)return null;let t=e.trim().replace(/\/+$/,``);return t?/^https?:\/\//i.test(t)?t:`http://${t}`:null}function re(){let e=window.localStorage.getItem(E);if(!e)return null;try{let t=JSON.parse(e),n=ne(t.baseUrl),r=typeof t.sessionApiKey==`string`?t.sessionApiKey.trim():``;return!n||!r?null:{id:x,name:S,host:n,apiKey:r,kind:`local`}}catch{return null}}function O(){window.localStorage.removeItem(E)}function k(e){return N(e),O(),e}function A(e){try{let{hostname:t}=new URL(e);return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`[::1]`}catch{return!1}}function j(e,t){return e.id!==`default-local`||e.kind!==`local`?!1:e.host===t.host||A(e.host)&&A(t.host)}function M(e){let t=C();if(!t)return e;let n=!1,r=e.map(e=>!j(e,t)||e.apiKey===t.apiKey?e:(n=!0,{...e,apiKey:t.apiKey}));return n?(N(r),r):e}function N(e){if(!(typeof window>`u`))try{window.localStorage.setItem(w,JSON.stringify(e))}catch{}}function P(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(w);if(e===null){let e=re();if(e)return k([e]);let t=C();return t?k([t]):[]}let t=JSON.parse(e);if(!Array.isArray(t))return[];let n=t.filter(te);if(n.length===0){let e=C();return e?k([e]):[]}let r=M(n);return O(),r}catch{return[]}}function F(e){if(!e)return null;try{let t=JSON.parse(e);if(typeof t!=`object`||!t||typeof t.backendId!=`string`)return null;let n=t.orgId;return{backendId:t.backendId,orgId:typeof n==`string`&&n.length>0?n:null}}catch{return null}}function I(e,t){try{return e?.getItem(t)??null}catch{return null}}function L(e,t,n){try{e?.setItem(t,n)}catch{}}function R(e,t){try{e?.removeItem(t)}catch{}}function z(){return typeof window>`u`?null:F(I(window.sessionStorage,T))||F(I(window.localStorage,T))}function B(e){if(typeof window>`u`)return;if(!e){R(window.sessionStorage,T),R(window.localStorage,T);return}let t=JSON.stringify({backendId:e.backendId,orgId:e.orgId??null});L(window.sessionStorage,T,t),L(window.localStorage,T,t)}var V=`no-backend`,H={id:V,name:`No Backend Available`,host:``,apiKey:``,kind:`local`};function U(e){return e.id===V}function W(e){return e[0]??H}function G(e,t){let n=null,r=null;if(t){let i=e.find(e=>e.id===t.backendId);i&&(n=i,r=t.orgId??null)}return n||(n=W(e),r=null),{backends:e,selection:t,active:{backend:n,orgId:r}}}var K=G(P(),z()),q=new Set;function J(){q.forEach(e=>e())}function Y(){return K.active}function X(){let e=K.active.backend;return e.kind===`local`&&!U(e)?e:null}function ie(){return K.backends}function ae(){return K.selection}function oe(){return K}function se(e){B(e),K=G(K.backends,e),J()}function ce(e){N(e);let t=K.selection;t&&!e.some(e=>e.id===t.backendId)&&(t=null,B(null)),K=G(e,t),J()}function le(e){return q.add(e),()=>{q.delete(e)}}var Z=class extends Error{constructor(){super(`No backend is configured.`),this.name=`NoBackendAvailableError`}};function Q(e){return e.replace(/\/+$/,``)}function ue(e,t){return e.host?Q(e.host):e.conversationUrl?Q(a(e.conversationUrl)):Q(t?.host??``)}function $(e={}){let t=X();if(!t&&!e.host&&!e.conversationUrl)throw new Z;let n=e.sessionApiKey??e.apiKey??t?.apiKey??void 0;return{host:ue(e,t),...n?{apiKey:n}:{},workingDir:e.workingDir??g(),...e.timeout===void 0?{}:{timeout:e.timeout}}}function de(e){let{host:t,apiKey:n,timeout:r}=$(e);return{baseUrl:t,...n?{apiKey:n}:{},timeout:r??6e4}}export{b as C,n as D,c as E,t as O,y as S,a as T,_,Y as a,v as b,ie as c,se as d,ce as f,l as g,C as h,H as i,e as k,oe as l,S as m,$ as n,ae as o,le as p,de as r,X as s,Z as t,U as u,m as v,s as w,g as x,p as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{O as e,T as t,_ as n,a as r,k as i,n as a,s as o,t as s,x as c}from"./agent-server-client-options-B-C8JaTb.js";import{c as l,r as u,u as d}from"./vendor~root-layout~home~conversation-panel~conversation~launch~mcp~settings~settings-index~~m3acswdn-CGm-Jxp5.js";import{t as f}from"./profiles-client-BNvHck-I.js";import{t as p}from"./proxy--Uy1iGsW.js";import{a as m,c as h,l as g,n as _,o as v,r as y,s as b,t as x,u as S}from"./agent-server-adapter-k8veH-1O.js";import{t as C}from"./settings-service.api-CFt5HmXD.js";var w=class{constructor(t){this.host=t.host.replace(/\/$/,``),this.apiKey=t.apiKey,this.client=new e({baseUrl:this.host,apiKey:this.apiKey,timeout:t.timeout||6e4})}async createConversation(e){return(await this.client.post(`/api/conversations`,e)).data}async searchConversations(e={}){return(await this.client.get(`/api/conversations/search`,{params:e})).data}async countConversations(e={}){return(await this.client.get(`/api/conversations/count`,{params:e})).data}async getConversations(e){return(await this.client.get(`/api/conversations`,{params:{ids:e}})).data}async getConversation(e){return(await this.client.get(`/api/conversations/${e}`)).data}async searchEvents(e,t={}){return(await this.client.get(`/api/conversations/${e}/events/search`,{params:t})).data}async getEvent(e,t){return(await this.client.get(`/api/conversations/${e}/events/${t}`)).data}async getEvents(e,t){return Promise.all(t.map(async t=>{try{return await this.getEvent(e,t)}catch(e){if(e instanceof i&&e.status===404)return null;throw e}}))}async sendEvent(e,t,n={}){await this.client.post(`/api/conversations/${e}/events`,{...t,...n.run===void 0?{}:{run:n.run}})}async pauseConversation(e){return(await this.client.post(`/api/conversations/${e}/pause`,{})).data}async interruptConversation(e){return(await this.client.post(`/api/conversations/${e}/interrupt`,{})).data}async runConversation(e){return(await this.client.post(`/api/conversations/${e}/run`,{})).data}async askAgent(e,t){return(await this.client.post(`/api/conversations/${e}/ask_agent`,{question:t})).data}async getEventCount(e,t={}){return(await this.client.get(`/api/conversations/${e}/events/count`,{params:t})).data}async respondToConfirmation(e,t){return(await this.client.post(`/api/conversations/${e}/events/respond_to_confirmation`,t)).data}async getAgentFinalResponse(e){return(await this.client.get(`/api/conversations/${e}/agent_final_response`)).data}async setConfirmationPolicy(e,t){let n=`policy`in t?t:{policy:t};return(await this.client.post(`/api/conversations/${e}/confirmation_policy`,n)).data}async condenseConversation(e){return(await this.client.post(`/api/conversations/${e}/condense`,{})).data}async setSecurityAnalyzer(e,t){let n=T(t)?t:{security_analyzer:t};return(await this.client.post(`/api/conversations/${e}/security_analyzer`,n)).data}async updateSecrets(e,t){return(await this.client.post(`/api/conversations/${e}/secrets`,t)).data}async forkConversation(e,t={},n={}){return(await this.client.post(`/api/conversations/${e}/fork`,t,{params:n.includeSkills===void 0?void 0:{include_skills:n.includeSkills}})).data}async switchProfile(e,t){await this.client.post(`/api/conversations/${e}/switch_profile`,{profile_name:t})}async switchLLM(e,t){await this.client.post(`/api/conversations/${e}/switch_llm`,{llm:t})}async switchAcpModel(e,t){await this.client.post(`/api/conversations/${e}/switch_acp_model`,{model:t})}async deleteConversation(e){await this.client.delete(`/api/conversations/${e}`)}async updateConversation(e,t){return(await this.client.patch(`/api/conversations/${e}`,t)).data}close(){this.client.close()}};function T(e){return typeof e==`object`&&!!e&&`security_analyzer`in e}var E=new Map;function ee(e){return/^([/\\]|[a-zA-Z]:[/\\])/.test(e)}function D(e,t){return`${e.replace(/[/\\]+$/,``)}/${t.replace(/^[/\\]+/,``)}`}async function O(e={}){let t=a(e),n=t.host,r=E.get(n);if(r)return r;let i=(async()=>{let{home:e}=await new d(t).getHome();if(!e||typeof e!=`string`)throw Error(`Agent server returned an empty home directory`);return e.replace(/[/\\]+$/,``)})();E.set(n,i);try{return await i}catch(e){throw E.delete(n),e}}async function k(e,t={}){let n=e.replace(/[/\\]+$/,``);return n?ee(n)?n:D(await O(t),n):O(t)}function A(e){if(!e?.id)return e;let t=b(e.id);return t?{...e,selected_repository:e.selected_repository??t.selected_repository??null,selected_branch:e.selected_branch??t.selected_branch??null,git_provider:e.git_provider??t.git_provider??null,selected_workspace:e.selected_workspace??t.selected_workspace??null}:e}function j(){let e=r().backend;if(e.kind!==`cloud`)throw Error(`Cloud conversations call requires a cloud backend.`);return e}async function M(e=20,t){let n=j(),r=new URLSearchParams;r.set(`limit`,String(e)),t&&r.set(`page_id`,t),r.set(`sort_order`,`UPDATED_AT_DESC`);let i=await p({backend:n,method:`GET`,path:`/api/v1/app-conversations/search?${r.toString()}`});return{items:(i?.items??[]).map(e=>A(e)),next_page_id:i?.next_page_id??null}}async function N(e){if(e.length===0)return[];let t=j(),n=new URLSearchParams;for(let t of e)n.append(`ids`,t);return(await p({backend:t,method:`GET`,path:`/api/v1/app-conversations?${n.toString()}`})??[]).map(A)}async function P(e){return await p({backend:j(),method:`POST`,path:`/api/v1/app-conversations`,body:e})}async function F(e){return p({backend:j(),method:`GET`,path:`/api/v1/app-conversations/${e}/download`,responseType:`blob`})}async function I(e){await p({backend:j(),method:`DELETE`,path:`/api/v1/app-conversations/${e}`})}async function L(e,t){return await p({backend:j(),method:`PATCH`,path:`/api/v1/app-conversations/${e}`,body:{public:t}})}async function te(e){await p({backend:j(),method:`POST`,path:`/api/v1/sandboxes/${e}/pause`})}async function ne(e){await p({backend:j(),method:`POST`,path:`/api/v1/sandboxes/${e}/resume`})}async function re(e,t){let n=j(),r=new URLSearchParams;return r.append(`file_path`,t),await p({backend:n,method:`GET`,path:`/api/v1/app-conversations/${e}/file?${r.toString()}`})??``}async function ie(e){let t=j(),n=new URLSearchParams;return n.set(`ids`,e),(await p({backend:t,method:`GET`,path:`/api/v1/app-conversations/start-tasks?${n.toString()}`}))?.[0]??null}var R=`1970-01-01T00:00:00.000Z`,z=`Unable to load conversations because the selected agent server returned data this UI does not understand. Check the backend URL/session key and update the agent server if needed.`;function B(){return Error(z)}function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function H(e){return typeof e==`number`?e:null}function U(e){return typeof e==`number`?e:0}function W(e){return typeof e==`string`?e:null}function G(e,t,n){let r=e[t]??e[n];return typeof r==`string`&&r.trim()?r:R}function K(e){return V(e)?{prompt_tokens:U(e.prompt_tokens),completion_tokens:U(e.completion_tokens),cache_read_tokens:U(e.cache_read_tokens),cache_write_tokens:U(e.cache_write_tokens),context_window:U(e.context_window),per_turn_token:U(e.per_turn_token)}:null}function q(e){return V(e)?{accumulated_cost:H(e.accumulated_cost),max_budget_per_task:H(e.max_budget_per_task),accumulated_token_usage:K(e.accumulated_token_usage)}:null}function J(e){if(!V(e))return null;let t=V(e.llm)?{model:W(e.llm.model)}:null;return{kind:W(e.kind),acp_model:W(e.acp_model),llm:t}}function ae(e){return V(e)?{working_dir:W(e.working_dir)}:null}function oe(e){if(!V(e))return null;let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}function Y(e){if(!e.startsWith(`/`))return null;let t=[];for(let n of e.split(`/`))if(n&&n!==`.`)if(n===`..`){if(!t.length)return null;t.pop()}else t.push(n);return`/${t.join(`/`)}`}function X(e,t){let n=Y(e),r=Y(t);if(!n||!r||n!==r&&!n.startsWith(`${r}/`))throw Error(`Conversation file path must stay inside the workspace`);return n}function Z(e){if(!V(e)||typeof e.id!=`string`||!e.id.trim())throw B();return{id:e.id.trim(),title:W(e.title),created_at:G(e,`created_at`,`createdAt`),updated_at:G(e,`updated_at`,`updatedAt`),execution_status:W(e.execution_status),sandbox_status:W(e.sandbox_status),metrics:q(e.metrics),agent:J(e.agent),workspace:ae(e.workspace),tags:oe(e.tags),current_model_id:W(e.current_model_id),current_model_name:W(e.current_model_name)}}function Q(e){if(!Array.isArray(e))throw B();return e.map(Z)}function se(e){if(Array.isArray(e))return{items:Q(e),next_page_id:null};if(!V(e))throw B();return{items:Q(e.items),next_page_id:typeof e.next_page_id==`string`?e.next_page_id:null}}var ce=new Set([`idle`,`running`,`paused`,`waiting_for_confirmation`,`finished`,`error`,`stuck`]);function le(e){let t=e??`idle`;return ce.has(t)?t:`idle`}function $(e,t){if(!e)throw Error(`Conversation ${t} was not found`);return e}var ue=class{static async sendMessage(e,n,i){let o=r().backend,s=i?.conversationUrl??null,c=i?.sessionApiKey??null;if(o.kind===`cloud`){if(!s||!c){let[t]=await N([e]);s=t?.conversation_url?.trim()??null,c=t?.session_api_key?.trim()??null}if(!s||!c)throw Error(`Conversation sandbox is still starting. Wait for it to finish, then try again.`);return await p({backend:o,method:`POST`,hostOverride:t(s),path:`/api/conversations/${e}/events`,body:{...n,run:!0},authMode:`session-api-key`,sessionApiKey:c}),n}return await new w(a({conversationUrl:s,sessionApiKey:c})).sendEvent(e,n,{run:!0}),n}static async createConversation(e,t,i,c,l,u,d,f,p){if(r().backend.kind===`cloud`)return P({initial_message:e?{role:`user`,content:[{type:`text`,text:e}]}:null,title:t??null,selected_repository:c?.selected_repository??null,selected_branch:c?.selected_branch??null,git_provider:c?.git_provider??null,plugins:i??null,parent_conversation_id:d??null,agent_type:f,sandbox_id:p??null});let m=await C.getSettings(),h=S(),_=await k(l??n(h)),v=u??(l?`local_repo`:`new_worktree`),y=await x({settings:m,query:e,conversationInstructions:t,plugins:i,conversationId:h,workingDir:_,worktree:v===`new_worktree`}),b=await new w(a()).createConversation(y),T=o();if(!T)throw new s;return(c?.selected_repository||l)&&g(b.id,{selected_repository:c?.selected_repository??null,selected_branch:c?.selected_branch??null,git_provider:c?.git_provider??null,selected_workspace:l??null,workspace_mode:v}),{id:b.id,created_by_user_id:null,status:`READY`,detail:null,app_conversation_id:b.id,agent_server_url:T.host,request:{initial_message:y.initial_message,plugins:i??null},created_at:b.created_at,updated_at:b.updated_at}}static async getStartTask(e){return r().backend.kind===`cloud`?ie(e):null}static async getVSCodeUrl(e,t,n){let r=await this.resolveConversationWorkingDir(e);return{vscode_url:await new l(a({conversationUrl:t,sessionApiKey:n})).getUrl({baseUrl:typeof window<`u`?window.location.origin:void 0,workspaceDir:r})}}static async resolveConversationWorkingDir(e){let[t]=await this.batchGetAppConversations([e]);return t?.workspace?.working_dir??c()}static async batchGetAppConversations(e){return e.length===0?[]:r().backend.kind===`cloud`?N(e):Q(await new w(a()).getConversations(e)).map(e=>m(e))}static async updateConversationPublicFlag(e,t){if(r().backend.kind!==`cloud`)throw Error(`Public sharing requires a cloud backend.`);return L(e,t)}static async updateConversationRepository(e,t,n,r){t?g(e,{...b(e)??{},selected_repository:t,selected_branch:n??null,git_provider:r??null}):h(e);let[i]=await this.batchGetAppConversations([e]);return $(i,e)}static async readConversationFile(e,t){if(r().backend.kind===`cloud`)return re(e,X(t??`/workspace/project/.agents_tmp/PLAN.md`,`/workspace/project`));let n=await this.resolveConversationWorkingDir(e),i=X(t??`${n}/.agents_tmp/PLAN.md`,n);return new d(a()).downloadTextFile(i)}static async downloadConversation(e){return r().backend.kind===`cloud`?F(e):new d(a()).downloadTrajectory(e)}static async getHooks(e){return _()}static async getRuntimeConversation(e,n,i){let o=r().backend,s=o.kind===`cloud`&&n?await p({backend:o,method:`GET`,hostOverride:t(n),path:`/api/conversations/${e}`,authMode:`session-api-key`,sessionApiKey:i}):await new w(a({conversationUrl:n,sessionApiKey:i})).getConversation(e),c=Z(s),l=V(s)?s.stats:null;return{id:c.id,title:c.title?.trim()?c.title:y(c.id),metrics:q(c.metrics),created_at:c.created_at,updated_at:c.updated_at,status:le(c.execution_status),stats:V(l)?l:{usage_to_metrics:{}}}}static async searchConversations(e=20,t){return r().backend.kind===`cloud`?M(e,t):v(se(await new w(a()).searchConversations({limit:e,page_id:t,sort_order:u.UPDATED_AT_DESC})))}static async deleteConversation(e){r().backend.kind===`cloud`?await I(e):await new w(a()).deleteConversation(e),h(e)}static async updateConversationTitle(e,t){await new w(a()).updateConversation(e,{title:t});let[n]=await this.batchGetAppConversations([e]);return $(n,e)}static async switchProfile(e,t){if(r().backend.kind===`cloud`)throw Error(`LLM profile switching is only supported for local agent-server backends.`);if(!e){await new f(a()).activateProfile(t);return}let n=a(),i=new w(n),o=await new f(n).getProfile(t,{exposeSecrets:`encrypted`}),s=typeof o.config.model==`string`?o.config.model:``;if(!s)throw Error(`Profile '${t}' has no model.`);await i.switchLLM(e,{...o.config,model:s,usage_id:`profile:${t}:${S()}`})}static async switchAcpModel(e,t){let{backend:n}=r();if(n.kind===`cloud`){await p({backend:n,method:`POST`,path:`/api/v1/app-conversations/${e}/switch_acp_model`,body:{model:t}});return}await new w(a()).switchAcpModel(e,t)}};export{k as a,ne as i,N as n,w as o,te as r,ue as t};
|
|
1
|
+
import{O as e,T as t,_ as n,a as r,k as i,n as a,s as o,t as s,x as c}from"./agent-server-client-options-wXLeJYeM.js";import{c as l,r as u,u as d}from"./vendor~root-layout~home~conversation-panel~conversation~launch~mcp~settings~settings-index~~m3acswdn-DQE89epK.js";import{t as f}from"./profiles-client-BjUo3q05.js";import{t as p}from"./proxy-Bx3NeKeo.js";import{a as m,c as h,l as g,n as _,o as v,r as y,s as b,t as x,u as S}from"./agent-server-adapter-BPpZcLOE.js";import{t as C}from"./settings-service.api-CcpckquT.js";var w=class{constructor(t){this.host=t.host.replace(/\/$/,``),this.apiKey=t.apiKey,this.client=new e({baseUrl:this.host,apiKey:this.apiKey,timeout:t.timeout||6e4})}async createConversation(e){return(await this.client.post(`/api/conversations`,e)).data}async searchConversations(e={}){return(await this.client.get(`/api/conversations/search`,{params:e})).data}async countConversations(e={}){return(await this.client.get(`/api/conversations/count`,{params:e})).data}async getConversations(e){return(await this.client.get(`/api/conversations`,{params:{ids:e}})).data}async getConversation(e){return(await this.client.get(`/api/conversations/${e}`)).data}async searchEvents(e,t={}){return(await this.client.get(`/api/conversations/${e}/events/search`,{params:t})).data}async getEvent(e,t){return(await this.client.get(`/api/conversations/${e}/events/${t}`)).data}async getEvents(e,t){return Promise.all(t.map(async t=>{try{return await this.getEvent(e,t)}catch(e){if(e instanceof i&&e.status===404)return null;throw e}}))}async sendEvent(e,t,n={}){await this.client.post(`/api/conversations/${e}/events`,{...t,...n.run===void 0?{}:{run:n.run}})}async pauseConversation(e){return(await this.client.post(`/api/conversations/${e}/pause`,{})).data}async interruptConversation(e){return(await this.client.post(`/api/conversations/${e}/interrupt`,{})).data}async runConversation(e){return(await this.client.post(`/api/conversations/${e}/run`,{})).data}async askAgent(e,t){return(await this.client.post(`/api/conversations/${e}/ask_agent`,{question:t})).data}async getEventCount(e,t={}){return(await this.client.get(`/api/conversations/${e}/events/count`,{params:t})).data}async respondToConfirmation(e,t){return(await this.client.post(`/api/conversations/${e}/events/respond_to_confirmation`,t)).data}async getAgentFinalResponse(e){return(await this.client.get(`/api/conversations/${e}/agent_final_response`)).data}async setConfirmationPolicy(e,t){let n=`policy`in t?t:{policy:t};return(await this.client.post(`/api/conversations/${e}/confirmation_policy`,n)).data}async condenseConversation(e){return(await this.client.post(`/api/conversations/${e}/condense`,{})).data}async setSecurityAnalyzer(e,t){let n=T(t)?t:{security_analyzer:t};return(await this.client.post(`/api/conversations/${e}/security_analyzer`,n)).data}async updateSecrets(e,t){return(await this.client.post(`/api/conversations/${e}/secrets`,t)).data}async forkConversation(e,t={},n={}){return(await this.client.post(`/api/conversations/${e}/fork`,t,{params:n.includeSkills===void 0?void 0:{include_skills:n.includeSkills}})).data}async switchProfile(e,t){await this.client.post(`/api/conversations/${e}/switch_profile`,{profile_name:t})}async switchLLM(e,t){await this.client.post(`/api/conversations/${e}/switch_llm`,{llm:t})}async switchAcpModel(e,t){await this.client.post(`/api/conversations/${e}/switch_acp_model`,{model:t})}async deleteConversation(e){await this.client.delete(`/api/conversations/${e}`)}async updateConversation(e,t){return(await this.client.patch(`/api/conversations/${e}`,t)).data}close(){this.client.close()}};function T(e){return typeof e==`object`&&!!e&&`security_analyzer`in e}var E=new Map;function ee(e){return/^([/\\]|[a-zA-Z]:[/\\])/.test(e)}function D(e,t){return`${e.replace(/[/\\]+$/,``)}/${t.replace(/^[/\\]+/,``)}`}async function O(e={}){let t=a(e),n=t.host,r=E.get(n);if(r)return r;let i=(async()=>{let{home:e}=await new d(t).getHome();if(!e||typeof e!=`string`)throw Error(`Agent server returned an empty home directory`);return e.replace(/[/\\]+$/,``)})();E.set(n,i);try{return await i}catch(e){throw E.delete(n),e}}async function k(e,t={}){let n=e.replace(/[/\\]+$/,``);return n?ee(n)?n:D(await O(t),n):O(t)}function A(e){if(!e?.id)return e;let t=b(e.id);return t?{...e,selected_repository:e.selected_repository??t.selected_repository??null,selected_branch:e.selected_branch??t.selected_branch??null,git_provider:e.git_provider??t.git_provider??null,selected_workspace:e.selected_workspace??t.selected_workspace??null}:e}function j(){let e=r().backend;if(e.kind!==`cloud`)throw Error(`Cloud conversations call requires a cloud backend.`);return e}async function M(e=20,t){let n=j(),r=new URLSearchParams;r.set(`limit`,String(e)),t&&r.set(`page_id`,t),r.set(`sort_order`,`UPDATED_AT_DESC`);let i=await p({backend:n,method:`GET`,path:`/api/v1/app-conversations/search?${r.toString()}`});return{items:(i?.items??[]).map(e=>A(e)),next_page_id:i?.next_page_id??null}}async function N(e){if(e.length===0)return[];let t=j(),n=new URLSearchParams;for(let t of e)n.append(`ids`,t);return(await p({backend:t,method:`GET`,path:`/api/v1/app-conversations?${n.toString()}`})??[]).map(A)}async function P(e){return await p({backend:j(),method:`POST`,path:`/api/v1/app-conversations`,body:e})}async function F(e){return p({backend:j(),method:`GET`,path:`/api/v1/app-conversations/${e}/download`,responseType:`blob`})}async function I(e){await p({backend:j(),method:`DELETE`,path:`/api/v1/app-conversations/${e}`})}async function L(e,t){return await p({backend:j(),method:`PATCH`,path:`/api/v1/app-conversations/${e}`,body:{public:t}})}async function te(e){await p({backend:j(),method:`POST`,path:`/api/v1/sandboxes/${e}/pause`})}async function ne(e){await p({backend:j(),method:`POST`,path:`/api/v1/sandboxes/${e}/resume`})}async function re(e,t){let n=j(),r=new URLSearchParams;return r.append(`file_path`,t),await p({backend:n,method:`GET`,path:`/api/v1/app-conversations/${e}/file?${r.toString()}`})??``}async function ie(e){let t=j(),n=new URLSearchParams;return n.set(`ids`,e),(await p({backend:t,method:`GET`,path:`/api/v1/app-conversations/start-tasks?${n.toString()}`}))?.[0]??null}var R=`1970-01-01T00:00:00.000Z`,z=`Unable to load conversations because the selected agent server returned data this UI does not understand. Check the backend URL/session key and update the agent server if needed.`;function B(){return Error(z)}function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function H(e){return typeof e==`number`?e:null}function U(e){return typeof e==`number`?e:0}function W(e){return typeof e==`string`?e:null}function G(e,t,n){let r=e[t]??e[n];return typeof r==`string`&&r.trim()?r:R}function K(e){return V(e)?{prompt_tokens:U(e.prompt_tokens),completion_tokens:U(e.completion_tokens),cache_read_tokens:U(e.cache_read_tokens),cache_write_tokens:U(e.cache_write_tokens),context_window:U(e.context_window),per_turn_token:U(e.per_turn_token)}:null}function q(e){return V(e)?{accumulated_cost:H(e.accumulated_cost),max_budget_per_task:H(e.max_budget_per_task),accumulated_token_usage:K(e.accumulated_token_usage)}:null}function J(e){if(!V(e))return null;let t=V(e.llm)?{model:W(e.llm.model)}:null;return{kind:W(e.kind),acp_model:W(e.acp_model),llm:t}}function ae(e){return V(e)?{working_dir:W(e.working_dir)}:null}function oe(e){if(!V(e))return null;let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}function Y(e){if(!e.startsWith(`/`))return null;let t=[];for(let n of e.split(`/`))if(n&&n!==`.`)if(n===`..`){if(!t.length)return null;t.pop()}else t.push(n);return`/${t.join(`/`)}`}function X(e,t){let n=Y(e),r=Y(t);if(!n||!r||n!==r&&!n.startsWith(`${r}/`))throw Error(`Conversation file path must stay inside the workspace`);return n}function Z(e){if(!V(e)||typeof e.id!=`string`||!e.id.trim())throw B();return{id:e.id.trim(),title:W(e.title),created_at:G(e,`created_at`,`createdAt`),updated_at:G(e,`updated_at`,`updatedAt`),execution_status:W(e.execution_status),sandbox_status:W(e.sandbox_status),metrics:q(e.metrics),agent:J(e.agent),workspace:ae(e.workspace),tags:oe(e.tags),current_model_id:W(e.current_model_id),current_model_name:W(e.current_model_name)}}function Q(e){if(!Array.isArray(e))throw B();return e.map(Z)}function se(e){if(Array.isArray(e))return{items:Q(e),next_page_id:null};if(!V(e))throw B();return{items:Q(e.items),next_page_id:typeof e.next_page_id==`string`?e.next_page_id:null}}var ce=new Set([`idle`,`running`,`paused`,`waiting_for_confirmation`,`finished`,`error`,`stuck`]);function le(e){let t=e??`idle`;return ce.has(t)?t:`idle`}function $(e,t){if(!e)throw Error(`Conversation ${t} was not found`);return e}var ue=class{static async sendMessage(e,n,i){let o=r().backend,s=i?.conversationUrl??null,c=i?.sessionApiKey??null;if(o.kind===`cloud`){if(!s||!c){let[t]=await N([e]);s=t?.conversation_url?.trim()??null,c=t?.session_api_key?.trim()??null}if(!s||!c)throw Error(`Conversation sandbox is still starting. Wait for it to finish, then try again.`);return await p({backend:o,method:`POST`,hostOverride:t(s),path:`/api/conversations/${e}/events`,body:{...n,run:!0},authMode:`session-api-key`,sessionApiKey:c}),n}return await new w(a({conversationUrl:s,sessionApiKey:c})).sendEvent(e,n,{run:!0}),n}static async createConversation(e,t,i,c,l,u,d,f,p){if(r().backend.kind===`cloud`)return P({initial_message:e?{role:`user`,content:[{type:`text`,text:e}]}:null,title:t??null,selected_repository:c?.selected_repository??null,selected_branch:c?.selected_branch??null,git_provider:c?.git_provider??null,plugins:i??null,parent_conversation_id:d??null,agent_type:f,sandbox_id:p??null});let m=await C.getSettings(),h=S(),_=await k(l??n(h)),v=u??(l?`local_repo`:`new_worktree`),y=await x({settings:m,query:e,conversationInstructions:t,plugins:i,conversationId:h,workingDir:_,worktree:v===`new_worktree`}),b=await new w(a()).createConversation(y),T=o();if(!T)throw new s;return(c?.selected_repository||l)&&g(b.id,{selected_repository:c?.selected_repository??null,selected_branch:c?.selected_branch??null,git_provider:c?.git_provider??null,selected_workspace:l??null,workspace_mode:v}),{id:b.id,created_by_user_id:null,status:`READY`,detail:null,app_conversation_id:b.id,agent_server_url:T.host,request:{initial_message:y.initial_message,plugins:i??null},created_at:b.created_at,updated_at:b.updated_at}}static async getStartTask(e){return r().backend.kind===`cloud`?ie(e):null}static async getVSCodeUrl(e,t,n){let r=await this.resolveConversationWorkingDir(e);return{vscode_url:await new l(a({conversationUrl:t,sessionApiKey:n})).getUrl({baseUrl:typeof window<`u`?window.location.origin:void 0,workspaceDir:r})}}static async resolveConversationWorkingDir(e){let[t]=await this.batchGetAppConversations([e]);return t?.workspace?.working_dir??c()}static async batchGetAppConversations(e){return e.length===0?[]:r().backend.kind===`cloud`?N(e):Q(await new w(a()).getConversations(e)).map(e=>m(e))}static async updateConversationPublicFlag(e,t){if(r().backend.kind!==`cloud`)throw Error(`Public sharing requires a cloud backend.`);return L(e,t)}static async updateConversationRepository(e,t,n,r){t?g(e,{...b(e)??{},selected_repository:t,selected_branch:n??null,git_provider:r??null}):h(e);let[i]=await this.batchGetAppConversations([e]);return $(i,e)}static async readConversationFile(e,t){if(r().backend.kind===`cloud`)return re(e,X(t??`/workspace/project/.agents_tmp/PLAN.md`,`/workspace/project`));let n=await this.resolveConversationWorkingDir(e),i=X(t??`${n}/.agents_tmp/PLAN.md`,n);return new d(a()).downloadTextFile(i)}static async downloadConversation(e){return r().backend.kind===`cloud`?F(e):new d(a()).downloadTrajectory(e)}static async getHooks(e){return _()}static async getRuntimeConversation(e,n,i){let o=r().backend,s=o.kind===`cloud`&&n?await p({backend:o,method:`GET`,hostOverride:t(n),path:`/api/conversations/${e}`,authMode:`session-api-key`,sessionApiKey:i}):await new w(a({conversationUrl:n,sessionApiKey:i})).getConversation(e),c=Z(s),l=V(s)?s.stats:null;return{id:c.id,title:c.title?.trim()?c.title:y(c.id),metrics:q(c.metrics),created_at:c.created_at,updated_at:c.updated_at,status:le(c.execution_status),stats:V(l)?l:{usage_to_metrics:{}}}}static async searchConversations(e=20,t){return r().backend.kind===`cloud`?M(e,t):v(se(await new w(a()).searchConversations({limit:e,page_id:t,sort_order:u.UPDATED_AT_DESC})))}static async deleteConversation(e){r().backend.kind===`cloud`?await I(e):await new w(a()).deleteConversation(e),h(e)}static async updateConversationTitle(e,t){await new w(a()).updateConversation(e,{title:t});let[n]=await this.batchGetAppConversations([e]);return $(n,e)}static async switchProfile(e,t){if(r().backend.kind===`cloud`)throw Error(`LLM profile switching is only supported for local agent-server backends.`);if(!e){await new f(a()).activateProfile(t);return}let n=a(),i=new w(n),o=await new f(n).getProfile(t,{exposeSecrets:`encrypted`}),s=typeof o.config.model==`string`?o.config.model:``;if(!s)throw Error(`Profile '${t}' has no model.`);await i.switchLLM(e,{...o.config,model:s,usage_id:`profile:${t}:${S()}`})}static async switchAcpModel(e,t){let{backend:n}=r();if(n.kind===`cloud`){await p({backend:n,method:`POST`,path:`/api/v1/app-conversations/${e}/switch_acp_model`,body:{model:t}});return}await new w(a()).switchAcpModel(e,t)}};export{k as a,ne as i,N as n,w as o,te as r,ue as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,t}from"./rolldown-runtime-BFRubm34.js";import{t as n}from"./react-CM_dJw1Z.js";import{L as r}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-BjMt2JeR.js";import{o as i,t as a}from"./declaration-D9ucT0fq.js";import{t as o}from"./useTranslation-CL6FTf1b.js";import{g as s,m as c,p as l}from"./query-client-config-Ca3tW1AH.js";import{t as u}from"./utils-eXk6yerZ.js";import{t as d}from"./brand-button-9SOzmqPP.js";import{t as f}from"./settings-input-BM8ANxDb.js";import{c as p,i as m,n as h,o as g,s as _,t as v}from"./acp-providers-
|
|
1
|
+
import{a as e,t}from"./rolldown-runtime-BFRubm34.js";import{t as n}from"./react-CM_dJw1Z.js";import{L as r}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-BjMt2JeR.js";import{o as i,t as a}from"./declaration-D9ucT0fq.js";import{t as o}from"./useTranslation-CL6FTf1b.js";import{g as s,m as c,p as l}from"./query-client-config-Ca3tW1AH.js";import{t as u}from"./utils-eXk6yerZ.js";import{t as d}from"./brand-button-9SOzmqPP.js";import{t as f}from"./settings-input-BM8ANxDb.js";import{c as p,i as m,n as h,o as g,s as _,t as v}from"./acp-providers-Dzb4nxxB.js";import{r as y}from"./use-settings-CNsxccvQ.js";import{t as ee}from"./use-save-settings-7_MLft-Y.js";import{t as te}from"./use-agent-settings-schema-Lf_lBAky.js";import{i as ne,r as re}from"./sdk-settings-field-metadata-p2GVlft7.js";import{t as b}from"./settings-dropdown-input-BP-arqjU.js";import{t as ie}from"./settings-switch-xa6q4M6j.js";import{r as x}from"./typography-BLSEGjph.js";import{a as S,i as C,n as w,r as T,t as ae}from"./use-acp-credential-form-Dj7Jkhgp.js";var E=e(n(),1),D=i();function oe({form:e,providerKey:t}){let{t:n}=o(`openhands`),{fields:r,values:i,setValue:s,secretExists:c,conflicts:l}=e,{status:u,isChecking:d}=w(t),f=p(t)??t;return r.length===0?null:(0,D.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,D.jsx)(x.Text,{className:`text-sm font-medium text-white`,children:n(a.SETTINGS$ACP_CREDENTIALS_TITLE)}),(0,D.jsx)(x.Text,{className:`text-xs text-[#717888]`,children:n(a.SETTINGS$ACP_CREDENTIALS_DESCRIPTION)})]}),(0,D.jsx)(C,{status:u,isChecking:d,providerName:f,testIdPrefix:`settings-acp-auth`}),(0,D.jsx)(`div`,{className:`flex flex-col gap-5`,children:r.map(e=>(0,D.jsx)(T,{field:e,value:i[e.name]??``,onChange:t=>s(e.name,t),alreadySet:c(e.name),testId:`settings-acp-secret-${e.name}`,showOptionalTag:!0},e.name))}),(0,D.jsx)(S,{conflicts:l})]})}var O=t(((e,t)=>{var n=[`||`,`&&`,`;;`,`|&`,`<(`,`<<<`,`>>`,`>&`,`<&`,`&`,`;`,`(`,`)`,`|`,`<`,`>`],r=/[\n\r\u2028\u2029]/,i=/[\s#!"$&'():;<=>@\\^`|]/g;t.exports=function(e){return e.map(function(e){if(e===``)return`''`;if(e&&typeof e==`object`){if(e.op===`glob`){if(typeof e.pattern!=`string`)throw TypeError("glob token requires a string `pattern`");if(r.test(e.pattern))throw TypeError("glob `pattern` must not contain line terminators");return e.pattern.replace(i,`\\$&`)}if(typeof e.op==`string`){if(n.indexOf(e.op)<0)throw TypeError("invalid `op` value: "+JSON.stringify(e.op));return e.op.replace(/[\s\S]/g,`\\$&`)}if(typeof e.comment==`string`){if(r.test(e.comment))throw TypeError("`comment` must not contain line terminators");return`#`+e.comment}throw TypeError(`unrecognized object token shape`)}return/["\s\\]/.test(e)&&!/'/.test(e)?`'`+e.replace(/(['])/g,`\\$1`)+`'`:/["'\s]/.test(e)?`"`+e.replace(/(["\\$`!])/g,`\\$1`)+`"`:String(e).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g,`$1\\$2`)}).join(` `)}})),k=t(((e,t)=>{for(var n=`(?:`+[`\\|\\|`,`\\&\\&`,`;;`,`\\|\\&`,`\\<\\(`,`\\<\\<\\<`,`>>`,`>\\&`,`<\\&`,`[&;()|<>]`].join(`|`)+`)`,r=RegExp(`^`+n+`$`),i=`|&;()<> \\t`,a=`"((\\\\"|[^"])*?)"`,o=`'((\\\\'|[^'])*?)'`,s=/^#$/,c=`'`,l=`"`,u=`$`,d=``,f=4294967296,p=0;p<4;p++)d+=(f*Math.random()).toString(16);var m=RegExp(`^`+d);function h(e,t){for(var n=t.lastIndex,r=[],i;i=t.exec(e);)r.push(i),t.lastIndex===i.index&&(t.lastIndex+=1);return t.lastIndex=n,r}function g(e,t,n){var r=typeof e==`function`?e(n):e[n];return r===void 0&&n!=``?r=``:r===void 0&&(r=`$`),typeof r==`object`?t+d+JSON.stringify(r)+d:t+r}function _(e,t,d){d||={};var f=d.escape||`\\`,p=`(\\`+f+`['"`+i+`]|[^\\s'"`+i+`])+`,m=h(e,new RegExp([`(`+n+`)`,`(`+p+`|`+a+`|`+o+`)+`].join(`|`),`g`));if(m.length===0)return[];t||={};var _=!1;return m.map(function(n){var i=n[0];if(!i||_)return;if(r.test(i))return{op:i};var a=!1,o=!1,d=``,p=!1,m;function h(){m+=1;var e,n,r=i.charAt(m);if(r===`{`){if(m+=1,i.charAt(m)===`}`)throw Error(`Bad substitution: `+i.slice(m-2,m+1));if(e=i.indexOf(`}`,m),e<0)throw Error(`Bad substitution: `+i.slice(m));n=i.slice(m,e),m=e}else if(/[*@#?$!_-]/.test(r))n=r,m+=1;else{var a=i.slice(m);e=a.match(/[^\w\d_]/),e?(n=a.slice(0,e.index),m+=e.index-1):(n=a,m=i.length)}return g(t,``,n)}for(m=0;m<i.length;m++){var v=i.charAt(m);if(p||=!a&&(v===`*`||v===`?`),o)d+=v,o=!1;else if(a)v===a?a=!1:a==c?d+=v:v===f?(m+=1,v=i.charAt(m),v===l||v===f||v===u?d+=v:d+=f+v):v===u?d+=h():d+=v;else if(v===l||v===c)a=v;else if(r.test(v))return{op:i};else if(s.test(v)){_=!0;var y={comment:e.slice(n.index+m+1)};return d.length?[d,y]:[y]}else v===f?o=!0:v===u?d+=h():d+=v}return p?{op:`glob`,pattern:d}:d}).reduce(function(e,t){return t===void 0?e:e.concat(t)},[])}t.exports=function(e,t,n){var r=_(e,t,n);return typeof t==`function`?r.reduce(function(e,t){if(typeof t==`object`)return e.concat(t);var n=t.split(RegExp(`(`+d+`.*?`+d+`)`,`g`));return n.length===1?e.concat(n[0]):e.concat(n.filter(Boolean).map(function(e){return m.test(e)?JSON.parse(e.split(d)[1]):e}))},[]):r}})),{quote:A}=e(t((e=>{e.quote=O(),e.parse=k()}))(),1);function se(e){let t=[],n=0,r=``,i=!1;for(;n<e.length;){let a=e[n];if(a===` `||a===` `||a===`
|
|
2
2
|
`||a===`\r`){i&&=(t.push(r),r=``,!1),n+=1;continue}if(a===`'`){for(i=!0,n+=1;n<e.length&&e[n]!==`'`;)r+=e[n],n+=1;n<e.length&&(n+=1);continue}if(a===`"`){for(i=!0,n+=1;n<e.length&&e[n]!==`"`;){if(e[n]===`\\`&&n+1<e.length){let t=e[n+1];if(t===`"`||t===`\\`){r+=t,n+=2;continue}}r+=e[n],n+=1}n<e.length&&(n+=1);continue}if(a===`\\`&&n+1<e.length){i=!0,r+=e[n+1],n+=2;continue}i=!0,r+=a,n+=1}return i&&t.push(r),t}var j=/[\s"'\\$`&|;<>(){}*?#!~[\]]/;function M(e){return e.map(e=>j.test(e)||e===``?A([e]):e).join(` `)}var N={hideTitle:!0},P=`enable_sub_agents`,ce=`npx -y <package-name>`,F=`__custom_model__`;function I(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function L(e,t){let n=se(e).join(` `);for(let e of t)if(n===e.default_command.join(` `))return e.key;return v}function le(e){return e?.find(e=>e.key===P)}function ue(e,t){return typeof e==`boolean`?e:t?.default===!0}function R(e,t){return e?.available_models?.some(({id:e})=>e===t.trim())??!1}function z(){let{t:e}=o(`openhands`),{data:t,isLoading:n}=y(),{mutate:r,isPending:i}=ee(),{data:p}=te(t?.agent_settings_schema),S=le(E.useMemo(()=>p?.sections.flatMap(e=>e.fields),[p])),C=E.useMemo(()=>ue(t?.agent_settings?.[P],S),[S,t?.agent_settings]),[w,T]=(0,E.useState)(C),[O,k]=(0,E.useState)(`openhands`),[A,j]=(0,E.useState)(``),[N,z]=(0,E.useState)(``),[B,V]=(0,E.useState)(!1),[de,H]=(0,E.useState)(!1),U=O===`acp`?L(A,h):null,W=ae(U&&U!==`custom`?U:null),G=(0,E.useRef)(null),K=(0,E.useRef)(null),q=(0,E.useRef)(``);if((0,E.useEffect)(()=>{if(t&&G.current!==t){if(G.current=t,t.agent_settings?.agent_kind===`acp`){k(`acp`);let e=t.agent_settings?.acp_server,n=typeof e==`string`?e:void 0,r=_(n),i=I(t.agent_settings?.acp_command),a=[...i.length>0?i:r?.default_command??[],...I(t.agent_settings?.acp_args)],o=a.length>0?M(a):``;j(o),K.current=n??null,q.current=o;let s=t.agent_settings?.acp_model,c=typeof s==`string`?s.trim():``;z(c||g(n)||``),V(!!c&&(!r||!R(r,c)))}else k(`openhands`),j(``),z(``),K.current=null,q.current=``,V(!1);H(!1)}},[t]),(0,E.useEffect)(()=>{T(C)},[C]),n)return null;let J=O===`acp`,Y=se(A),fe=J&&Y.length===0,X=L(A,h),Z=_(X),pe=Z?.available_models??[],me=pe.length>0,he=R(Z,N),ge=B||!he?F:N,Q=!!Z&&Y.join(` `)===Z.default_command.join(` `),_e=M(h[0]?.default_command??[])||ce,$=de||!J&&w!==C,ve=W.isDirty,ye=$||ve,be=i||W.isSaving,xe=async()=>{if(W.isDirty){if(!await W.save({silent:$}))return;W.reset()}if($)if(J){let t=!!(Z&&Q),n=K.current,i=A===q.current,o=!!n&&n!==`custom`&&!h.some(e=>e.key===n),u=J&&i&&o,d=m(u?n:Z&&Q?Z.key:v,{command:t?[]:Y,model:N.trim()||void 0,allowUnknownServer:u});if(!d)return;r({agent_settings_diff:d},{onError:t=>{l(s(t)||e(a.ERROR$GENERIC))},onSuccess:()=>{c(e(a.SETTINGS$SAVED)),H(!1)}})}else r({agent_settings_diff:{agent_kind:`openhands`,enable_sub_agents:w}},{onError:t=>{l(s(t)||e(a.ERROR$GENERIC))},onSuccess:()=>{c(e(a.SETTINGS$SAVED)),H(!1)}})},Se=S?ne(e,S.key,S.label):e(a.SCHEMA$ENABLE_SUB_AGENTS$LABEL),Ce=S?re(e,S.key,S.description):e(a.SCHEMA$ENABLE_SUB_AGENTS$DESCRIPTION);return(0,D.jsxs)(`div`,{"data-testid":`agent-settings-screen`,className:`flex flex-col gap-6 pb-8 max-w-2xl`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(x.H2,{className:`mb-2`,children:e(a.SETTINGS$NAV_AGENT)}),(0,D.jsx)(x.Paragraph,{className:`text-sm text-[#A3A3A3]`,children:e(a.SETTINGS$AGENT_PAGE_DESCRIPTION)})]}),(0,D.jsx)(b,{testId:`agent-type-selector`,name:`agent-type`,label:e(a.SETTINGS$NAV_AGENT),items:[{key:`openhands`,label:e(a.SETTINGS$AGENT_TYPE_OPENHANDS)},{key:`acp`,label:e(a.SETTINGS$AGENT_TYPE_ACP)}],selectedKey:O,onSelectionChange:e=>{if(!e)return;let t=e;if(k(t),t===`acp`&&!A){let e=h[0];e&&(j(M(e.default_command)),z(g(e.key)??``),V(!1))}else t===`openhands`&&V(!1);H(!0)}}),!J&&(0,D.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,D.jsx)(ie,{testId:`agent-settings-enable-sub-agents`,isToggled:w,onToggle:e=>{T(e)},children:Se}),Ce?(0,D.jsx)(x.Paragraph,{className:u(`pl-12`,`text-tertiary-alt text-xs leading-5`),children:Ce}):null]}),J&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(b,{testId:`agent-preset-selector`,name:`agent-preset`,label:e(a.SETTINGS$AGENT_PRESET),items:[...h.map(e=>({key:e.key,label:e.display_name})),{key:`custom`,label:e(a.SETTINGS$AGENT_PRESET_CUSTOM)}],selectedKey:X,onSelectionChange:e=>{if(!e)return;let t=String(e),n=_(t);n?(j(M(n.default_command)),z(g(t)??``),V(!1)):t===`custom`&&(j(``),z(``),V(!0)),H(!0)}}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,D.jsx)(x.Text,{className:`text-sm`,children:e(a.SETTINGS$AGENT_COMMAND)}),(0,D.jsx)(`textarea`,{"data-testid":`agent-command-input`,className:`bg-tertiary border border-[#717888] rounded-sm p-2 text-sm font-mono text-white placeholder:text-[#717888] min-h-[60px] resize-y focus:outline-none focus:border-white`,value:A,placeholder:_e,onChange:e=>{let t=e.target.value,n=L(A,h),r=L(t,h);r!==n&&(z(g(r)??``),V(!1)),j(t),H(!0)}}),(0,D.jsx)(x.Text,{className:`text-xs text-[#717888]`,children:e(a.SETTINGS$AGENT_COMMAND_HINT)})]}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[me&&(0,D.jsx)(b,{testId:`agent-model-selector`,name:`agent-model`,label:e(a.SETTINGS$AGENT_MODEL),items:[...pe.map(e=>({key:e.id,label:e.label})),{key:F,label:e(a.SETTINGS$AGENT_PRESET_CUSTOM)}],selectedKey:ge,onSelectionChange:e=>{if(!e)return;let t=String(e);t===F?(V(!0),z(``)):(V(!1),z(t)),H(!0)}}),ge===F&&(0,D.jsx)(f,{testId:`agent-model-input`,label:e(me?a.SETTINGS$AGENT_CUSTOM_MODEL:a.SETTINGS$AGENT_MODEL),type:`text`,className:`w-full`,value:N,showOptionalTag:!0,onChange:e=>{z(e),H(!0)}}),(0,D.jsx)(x.Text,{className:`text-xs text-[#717888]`,children:e(a.SETTINGS$AGENT_MODEL_HINT)})]})]}),J&&X!==`custom`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`hr`,{className:`border-[#3D4046]`}),(0,D.jsx)(oe,{form:W,providerKey:X})]}),(0,D.jsx)(`div`,{children:(0,D.jsx)(d,{testId:`agent-save-button`,type:`button`,variant:`primary`,isDisabled:be||!ye||fe,onClick:xe,children:e(be?a.SETTINGS$SAVING:a.SETTINGS$SAVE_CHANGES)})})]})}var B=r(z);export{B as default,N as handle};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,t}from"./declaration-D9ucT0fq.js";import{t as n}from"./useTranslation-CL6FTf1b.js";import{n as r}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~oli4dvxu-BmOMM-6e.js";import{r as i}from"./telemetry-
|
|
1
|
+
import{o as e,t}from"./declaration-D9ucT0fq.js";import{t as n}from"./useTranslation-CL6FTf1b.js";import{n as r}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~oli4dvxu-BmOMM-6e.js";import{r as i}from"./telemetry-CAWBJ_rB.js";import{t as a}from"./modal-backdrop-_VbcKk5K.js";import{n as o}from"./modal-body-Cd-PtMHr.js";import{n as s,r as c}from"./base-modal-DvuGYyu1.js";import{t as l}from"./brand-button-9SOzmqPP.js";import{t as u}from"./handle-capture-consent-CPMXU29K.js";import{t as d}from"./use-save-settings-7_MLft-Y.js";var f=e();function p({onClose:e}){let p=r(),{t:m}=n(`openhands`),{mutate:h}=d();return(0,f.jsx)(a,{children:(0,f.jsx)(`form`,{"data-testid":`user-capture-consent-form`,onSubmit:async t=>{t.preventDefault();let n=new FormData(t.currentTarget).get(`analytics`)===`on`;h({user_consents_to_analytics:n},{onSuccess:()=>{u(p,n),i(n?`granted`:`denied`),e()}})},className:`flex flex-col gap-2`,children:(0,f.jsxs)(o,{className:`border border-[var(--oh-border)]`,children:[(0,f.jsx)(c,{title:m(t.ANALYTICS$TITLE)}),(0,f.jsx)(s,{children:m(t.ANALYTICS$DESCRIPTION)}),(0,f.jsxs)(`label`,{className:`flex gap-2 items-center self-start text-sm`,children:[(0,f.jsx)(`input`,{name:`analytics`,type:`checkbox`,defaultChecked:!0}),m(t.ANALYTICS$SEND_ANONYMOUS_DATA)]}),(0,f.jsx)(l,{testId:`confirm-preferences`,type:`submit`,variant:`primary`,className:`w-full`,children:m(t.ANALYTICS$CONFIRM_PREFERENCES)})]})})})}export{p as AnalyticsConsentFormModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{o as n,t as r}from"./declaration-D9ucT0fq.js";import{t as i}from"./useTranslation-CL6FTf1b.js";import{t as a}from"./utils-eXk6yerZ.js";import{D as o,n as s,u as c}from"./agent-server-client-options-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{o as n,t as r}from"./declaration-D9ucT0fq.js";import{t as i}from"./useTranslation-CL6FTf1b.js";import{t as a}from"./utils-eXk6yerZ.js";import{D as o,n as s,u as c}from"./agent-server-client-options-wXLeJYeM.js";import{p as l,r as u}from"./active-backend-context-B2OSC-qe.js";import{r as d,t as f}from"./modal-body-Cd-PtMHr.js";import{t as p}from"./brand-button-9SOzmqPP.js";import{r as m,t as h}from"./backend-form-modal-B3BCZDPq.js";var g=e(t(),1),_=n();function v(){let{t:e}=i(`openhands`),{active:t,addBackend:n,updateBackend:v}=u(),y=window.location.origin,[b,x]=g.useState(!1),[S,C]=g.useState(`idle`),[w,T]=g.useState(null),E=g.useCallback(async i=>{x(!0),C(`idle`),T(null);try{await new o(s({host:i.host,sessionApiKey:i.apiKey,timeout:5e3})).getSettings(),C(`success`),c(t.backend)?n(i):v(t.backend.id,i),window.location.reload()}catch(t){if(C(`error`),l(t,401))T(e(r.AUTH$INVALID_KEY));else{let n=t instanceof Error?t.message:String(t);T(`${e(r.AUTH$CONNECTION_FAILED)}${n?`: ${n}`:``}`)}x(!1)}},[t.backend,n,v,e]);return(0,_.jsx)(`div`,{"data-testid":`api-key-entry-screen`,className:`flex min-h-screen items-center justify-center bg-base px-6`,children:(0,_.jsxs)(`div`,{className:a(`relative rounded-xl border border-[var(--oh-border)] bg-base-secondary`,d(`md`),f),children:[(0,_.jsx)(`div`,{className:`px-6 pt-6 pb-2 pr-12`,children:(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(r.BACKEND$ADD_TITLE)})}),(0,_.jsx)(`div`,{className:`px-6 pb-6 pt-2`,children:(0,_.jsx)(h,{mode:`add`,backend:{...t.backend,host:y,apiKey:``,name:``},onSubmitted:()=>{},testIdRoot:`api-key-entry`,hostReadOnly:!0,requireApiKey:!0,onSubmitOverride:E,renderActions:({canSubmit:t,testIdRoot:n})=>(0,_.jsxs)(_.Fragment,{children:[S!==`idle`&&(0,_.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,_.jsx)(m,{isConnected:S===`success`}),(0,_.jsx)(`span`,{"data-testid":`${n}-status`,className:S===`error`?`text-red-400`:`text-green-400`,children:S===`error`?w:e(r.ONBOARDING$BACKEND_STATUS_CONNECTED)})]}),(0,_.jsx)(p,{type:`submit`,variant:`secondary`,isDisabled:!t||b,testId:`${n}-submit`,className:`w-full text-center`,children:e(b?r.ONBOARDING$BACKEND_STATUS_CHECKING:r.BACKEND$CONNECT)})]})})})]})})}export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{L as n}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-BjMt2JeR.js";import{o as r,t as i}from"./declaration-D9ucT0fq.js";import{t as a}from"./useTranslation-CL6FTf1b.js";import{_ as o,g as s,m as c,p as l}from"./query-client-config-Ca3tW1AH.js";import{n as u}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~oli4dvxu-BmOMM-6e.js";import{t as d}from"./brand-button-9SOzmqPP.js";import{i as f,n as p,r as m,t as h}from"./color-themes-0biOprdo.js";import{t as g}from"./settings-input-BM8ANxDb.js";import{t as _}from"./settings-wh2sLLJM.js";import{r as v}from"./use-settings-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{L as n}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-BjMt2JeR.js";import{o as r,t as i}from"./declaration-D9ucT0fq.js";import{t as a}from"./useTranslation-CL6FTf1b.js";import{_ as o,g as s,m as c,p as l}from"./query-client-config-Ca3tW1AH.js";import{n as u}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~oli4dvxu-BmOMM-6e.js";import{t as d}from"./brand-button-9SOzmqPP.js";import{i as f,n as p,r as m,t as h}from"./color-themes-0biOprdo.js";import{t as g}from"./settings-input-BM8ANxDb.js";import{t as _}from"./settings-wh2sLLJM.js";import{r as v}from"./use-settings-CNsxccvQ.js";import{t as y}from"./handle-capture-consent-CPMXU29K.js";import{t as b}from"./use-save-settings-7_MLft-Y.js";import{n as x,t as S}from"./switch-skeleton-BbIWemkK.js";import{t as C}from"./settings-dropdown-input-BP-arqjU.js";import{t as w}from"./settings-switch-xa6q4M6j.js";var T=e(t(),1),E=r();function D({defaultKey:e,onChange:t,name:n}){let{t:r}=a(`openhands`);return(0,E.jsx)(C,{testId:n,name:n,onInputChange:t,label:r(i.SETTINGS$LANGUAGE),items:o.map(e=>({key:e.value,label:e.label})),defaultSelectedKey:e,isClearable:!1,wrapperClassName:`w-full min-w-0`})}function O(){let{t:e}=a(`openhands`),t=T.useCallback(e=>{if(!e)return;let t=e;p(t),m(t)},[]);return(0,E.jsx)(C,{testId:`color-theme-input`,name:`color-theme-input`,label:e(i.SETTINGS$COLOR_THEME),items:h.map(e=>({key:e.key,label:e.label})),defaultSelectedKey:f(),onSelectionChange:t,isClearable:!1,wrapperClassName:`w-full min-w-0`})}function k(){return(0,E.jsxs)(`div`,{"data-testid":`app-settings-skeleton`,className:`px-11 py-9 flex flex-col gap-6`,children:[(0,E.jsx)(x,{}),(0,E.jsx)(S,{}),(0,E.jsx)(S,{})]})}function A(){let e=u(),{t}=a(`openhands`),{mutate:n,isPending:r}=b(),{data:f,isLoading:p}=v(),[m,h]=T.useState(!1),[x,S]=T.useState(!1),[C,A]=T.useState(!1),[j,M]=T.useState(!1),[N,P]=T.useState(!1),F=r=>{let a=r.get(`language-input`)?.toString(),u=o.find(({label:e})=>e===a)?.value||_.language,d=r.get(`enable-analytics-switch`)?.toString()===`on`;n({language:u,user_consents_to_analytics:d,enable_sound_notifications:r.get(`enable-sound-notifications-switch`)?.toString()===`on`,git_user_name:r.get(`git-user-name-input`)?.toString()||_.git_user_name,git_user_email:r.get(`git-user-email-input`)?.toString()||_.git_user_email},{onSuccess:()=>{y(e,d),c(t(i.SETTINGS$SAVED))},onError:e=>{l(s(e)||t(i.ERROR$GENERIC))},onSettled:()=>{h(!1),S(!1),A(!1),M(!1),P(!1)}})},I=e=>{let t=o.find(({label:t})=>t===e)?.label,n=o.find(({value:e})=>e===f?.language)?.label;h(t!==n)},L=e=>{S(e!==(f?.user_consents_to_analytics??!0))},R=e=>{A(e!==!!f?.enable_sound_notifications)},z=e=>{let t=f?.git_user_name;M(e!==t)},B=e=>{let t=f?.git_user_email;P(e!==t)},V=!m&&!x&&!C&&!j&&!N,H=!f||p||r;return(0,E.jsxs)(`form`,{"data-testid":`app-settings-screen`,action:F,className:`flex flex-col gap-6`,children:[H&&(0,E.jsx)(k,{}),!H&&(0,E.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,E.jsx)(D,{name:`language-input`,defaultKey:f.language,onChange:I}),(0,E.jsx)(O,{}),(0,E.jsx)(w,{testId:`enable-analytics-switch`,name:`enable-analytics-switch`,defaultIsToggled:f.user_consents_to_analytics??!0,onToggle:L,children:t(i.ANALYTICS$SEND_ANONYMOUS_DATA)}),(0,E.jsx)(w,{testId:`enable-sound-notifications-switch`,name:`enable-sound-notifications-switch`,defaultIsToggled:!!f.enable_sound_notifications,onToggle:R,children:t(i.SETTINGS$SOUND_NOTIFICATIONS)}),(0,E.jsxs)(`div`,{className:`border-t border-[var(--oh-border)] pt-6 mt-2`,children:[(0,E.jsx)(`h3`,{className:`text-lg font-medium mb-2`,children:t(i.SETTINGS$GIT_SETTINGS)}),(0,E.jsx)(`p`,{className:`mb-4 text-sm leading-5 text-tertiary-light`,children:t(i.SETTINGS$GIT_SETTINGS_DESCRIPTION)}),(0,E.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,E.jsx)(g,{testId:`git-user-name-input`,name:`git-user-name-input`,type:`text`,label:t(i.SETTINGS$GIT_USERNAME),defaultValue:f.git_user_name||``,onChange:z,placeholder:t(i.SETTINGS$GIT_USERNAME_PLACEHOLDER),className:`w-full min-w-0`}),(0,E.jsx)(g,{testId:`git-user-email-input`,name:`git-user-email-input`,type:`email`,label:t(i.SETTINGS$GIT_EMAIL),defaultValue:f.git_user_email||``,onChange:B,placeholder:t(i.SETTINGS$GIT_EMAIL_PLACEHOLDER),className:`w-full min-w-0`})]}),(0,E.jsx)(`div`,{className:`flex justify-start pt-4`,children:(0,E.jsxs)(d,{testId:`submit-button`,variant:`primary`,type:`submit`,isDisabled:r||V,children:[!r&&t(i.SETTINGS$SAVE_CHANGES),r&&t(i.SETTINGS$SAVING)]})})]})]})]})}var j=n(A);export{j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{L as n,P as r}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-BjMt2JeR.js";import{o as i,t as a}from"./declaration-D9ucT0fq.js";import{t as o}from"./useQuery-DGRSm7IT.js";import{t as s}from"./useTranslation-CL6FTf1b.js";import{m as c,p as l}from"./query-client-config-Ca3tW1AH.js";import{t as u}from"./back-nav-button-D20Avel_.js";import{t as d}from"./utils-eXk6yerZ.js";import{T as f,a as p,n as m}from"./agent-server-client-options-B-C8JaTb.js";import{n as h}from"./active-backend-context-CNF2lPkA.js";import{f as g}from"./vendor~root-layout~home~conversation-panel~conversation~launch~mcp~settings~settings-index~~m3acswdn-CGm-Jxp5.js";import{r as _}from"./modal-classes-CNm4ovfm.js";import{n as v}from"./navigation-context-BpAOh_t5.js";import{n as y,r as b}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~bxn4ldi1-_LydBB1e.js";import{t as x}from"./proxy--Uy1iGsW.js";import{t as S}from"./use-tracking-BhyV5A9i.js";import{t as C}from"./u-edit-DIgADxLH.js";import{t as w}from"./terminal-B92mACR5.js";import{t as T}from"./use-user-conversation-6yFVEXiG.js";import{t as E}from"./toggle-switch-CL_wRiGs.js";import{t as D}from"./x-mark-C42svtnu.js";import{t as O}from"./code-tag-chmctf4w.js";import{t as k}from"./link-external-ooNztGLp.js";import{C as A,S as ee,_ as j,a as M,b as te,c as N,d as P,f as F,i as I,l as L,m as ne,n as re,o as ie,p as ae,r as oe,s as se,t as ce,u as le,w as ue,x as de,y as fe}from"./edit-automation-modal-8y9Uctxo.js";import{t as R}from"./automation-XLxhq3I8.js";var z=e(t()),B=i();function V(){let{t:e}=s(`openhands`);return(0,B.jsx)(u,{to:`/automations`,children:e(a.AUTOMATIONS$DETAIL$BACK_TO_LIST)})}var pe=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3`})});function me({active:e}){let{t}=s(`openhands`);return(0,B.jsx)(`span`,{"data-testid":e?`active-status-badge-active`:`active-status-badge-inactive`,className:d(`inline-flex items-center rounded-full px-3 py-1 text-xs font-medium`,e?`bg-[var(--oh-success)]/15 text-[var(--oh-success)]`:`bg-surface-raised text-muted`),children:t(e?a.AUTOMATIONS$DETAIL$ACTIVE:a.AUTOMATIONS$DETAIL$INACTIVE)})}function he({automation:e,onToggle:t,onEdit:n,onDelete:r,onRunNow:i,isRunningNow:o=!1}){let{t:c}=s(`openhands`),l=ae(`manage_automations`),u=[...n?[{label:c(a.AUTOMATIONS$EDIT),icon:(0,B.jsx)(C,{className:`size-4`}),onClick:n}]:[],{label:e.enabled?c(a.AUTOMATIONS$TURN_OFF):c(a.AUTOMATIONS$TURN_ON),icon:(0,B.jsx)(se,{className:`size-4`}),onClick:t},{label:c(a.AUTOMATIONS$DOWNLOAD_TARBALL),icon:(0,B.jsx)(pe,{className:`size-4`}),onClick:()=>{ue.downloadTarball(e.id,e.name)}},{label:c(a.AUTOMATIONS$DELETE),icon:(0,B.jsx)(ie,{className:`size-4`}),onClick:r}];return(0,B.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e.name}),(0,B.jsx)(me,{active:e.enabled})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l&&i&&(0,B.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-md border border-[var(--oh-border)] px-3 py-1.5 text-sm font-medium text-content transition-colors hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:o||!e.enabled,onClick:i,children:[(0,B.jsx)(F,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),o?`Starting…`:c(a.AUTOMATIONS$RUN_NOW)]}),l&&(0,B.jsx)(E,{enabled:e.enabled,label:e.enabled?c(a.AUTOMATIONS$TURN_OFF):c(a.AUTOMATIONS$TURN_ON),onToggle:t}),l&&(0,B.jsx)(ne,{items:u})]})]})})}function H({icon:e,title:t,children:n}){return(0,B.jsxs)(`div`,{className:`rounded-2xl border border-[var(--oh-border)] bg-[var(--oh-surface)]`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--oh-border)] px-5 py-3`,children:[(0,B.jsx)(`span`,{className:`size-4 text-muted`,children:e}),(0,B.jsx)(`h3`,{className:`text-sm font-medium text-content`,children:t})]}),(0,B.jsx)(`div`,{className:`px-5 py-5`,children:n})]})}var ge=240,_e=`max-h-60`;function ve({prompt:e}){let{t}=s(`openhands`),[n,r]=z.useState(!1),[i,o]=z.useState(!1),c=z.useRef(null),l=i&&!n;return z.useLayoutEffect(()=>{let e=c.current;if(!e)return;let t=()=>{o(e.scrollHeight>ge)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]),(0,B.jsx)(H,{icon:(0,B.jsx)(w,{className:`size-4`}),title:t(a.AUTOMATIONS$DETAIL$PROMPT),children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(`p`,{ref:c,className:d(`whitespace-pre-wrap text-sm leading-6 text-content`,l&&d(_e,`overflow-hidden`)),"data-testid":`automation-prompt-content`,children:e}),l?(0,B.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-20 bg-gradient-to-t from-[var(--oh-surface)] to-transparent`,"aria-hidden":!0,"data-testid":`automation-prompt-fade`}):null]}),i?(0,B.jsx)(`button`,{type:`button`,className:`self-start cursor-pointer text-sm font-normal text-[var(--oh-muted)] hover:text-white`,onClick:()=>r(e=>!e),"data-testid":`automation-prompt-toggle`,children:t(n?a.COMMON$VIEW_LESS:a.COMMON$VIEW_MORE)}):null]})})}var ye=e=>(0,B.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:[(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 0 1 1.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.56.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.893.149c-.425.07-.765.383-.93.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 0 1-1.449.12l-.738-.527c-.35-.25-.806-.272-1.204-.107-.397.165-.71.505-.78.929l-.15.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 0 1-.12-1.45l.527-.737c.25-.35.273-.806.108-1.204-.165-.397-.506-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.108-1.204l-.526-.738a1.125 1.125 0 0 1 .12-1.45l.773-.773a1.125 1.125 0 0 1 1.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894Z`}),(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z`})]}),be=e=>(0,B.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:[(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6 3v12m0 0a3 3 0 1 0 3 3M6 15a3 3 0 0 1 3-3h6a3 3 0 0 0 3-3V3m0 0a3 3 0 1 0 0 0`}),(0,B.jsx)(`circle`,{cx:6,cy:3,r:2}),(0,B.jsx)(`circle`,{cx:18,cy:3,r:2}),(0,B.jsx)(`circle`,{cx:9,cy:18,r:2})]}),U=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z`})}),W=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0v-7.5A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5`})}),xe=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M14.857 17.082a23.848 23.848 0 0 0 5.454-1.31A8.967 8.967 0 0 1 18 9.75V9A6 6 0 0 0 6 9v.75a8.967 8.967 0 0 1-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 0 1-5.714 0m5.714 0a3 3 0 1 1-5.714 0`})});function G({icon:e,label:t,children:n}){return(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`size-3.5 text-muted`,children:e}),(0,B.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:t})]}),(0,B.jsx)(`div`,{className:`text-sm text-content`,children:n})]})}function Se({branch:e}){return(0,B.jsx)(`span`,{className:`inline-flex items-center rounded-full border border-[var(--oh-border)] bg-surface-raised px-2.5 py-0.5 text-xs text-muted`,children:e})}var K=60;function Ce({filter:e}){let{t}=s(`openhands`),[n,r]=(0,z.useState)(!1),i=e.length>K;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,B.jsx)(`span`,{className:`break-all`,children:i&&!n?`${e.slice(0,K)}…`:e}),i&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-expanded":n,className:`text-xs text-muted hover:text-content self-start`,children:t(n?a.SETTINGS$SKILLS_SHOW_LESS:a.SETTINGS$SKILLS_SHOW_MORE)})]})}function we({automation:e}){let{t}=s(`openhands`),n=e.trigger.type===`event`,r=e.trigger.schedule??``;e.trigger.schedule_human&&(r=e.timezone?`${e.trigger.schedule_human} (${e.timezone})`:e.trigger.schedule_human);let i=t(n?a.AUTOMATIONS$DETAIL$TRIGGER_EVENT:a.AUTOMATIONS$DETAIL$TRIGGER_SCHEDULE);return(0,B.jsx)(H,{icon:(0,B.jsx)(ye,{className:`size-4`}),title:t(a.AUTOMATIONS$DETAIL$CONFIGURATION),children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-5`,children:[e.repository&&(0,B.jsx)(G,{icon:(0,B.jsx)(be,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$REPOSITORIES),children:(0,B.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e.repository,e.branch&&(0,B.jsx)(Se,{branch:e.branch})]})}),(0,B.jsx)(G,{icon:(0,B.jsx)(U,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$TRIGGER),children:i}),!n&&(0,B.jsx)(G,{icon:(0,B.jsx)(W,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$SCHEDULE),children:r}),n&&e.trigger.source&&(0,B.jsx)(G,{icon:(0,B.jsx)(le,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$EVENT_SOURCE),children:e.trigger.source}),n&&e.trigger.on&&(0,B.jsx)(G,{icon:(0,B.jsx)(k,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$EVENT_TYPE),children:N(e.trigger.on)}),n&&e.trigger.filter&&(0,B.jsx)(G,{icon:(0,B.jsx)(O,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$EVENT_FILTER),children:(0,B.jsx)(Ce,{filter:e.trigger.filter})}),(0,B.jsx)(G,{icon:(0,B.jsx)(L,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$MODEL),children:e.model??`Active profile`}),e.notification&&(0,B.jsx)(G,{icon:(0,B.jsx)(xe,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$NOTIFICATION),children:e.notification})]})})}var Te=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 0 1-.657.643 48.39 48.39 0 0 1-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 0 1-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 0 0-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.039 48.039 0 0 1-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 0 0 .657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 0 1-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 0 0 5.427-.63 48.05 48.05 0 0 0 .582-4.717.532.532 0 0 0-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 0 0 .658-.663 48.422 48.422 0 0 0-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 0 1-.61-.58v0Z`})});function Ee({name:e}){return(0,B.jsx)(`span`,{className:`inline-flex items-center rounded-full border border-[var(--oh-border)] bg-[var(--oh-surface-deep)] px-3.5 py-1.5 text-sm text-content`,children:e})}function De({plugins:e}){let{t}=s(`openhands`);return(0,B.jsx)(H,{icon:(0,B.jsx)(Te,{className:`size-4`}),title:t(a.AUTOMATIONS$DETAIL$PLUGINS),children:(0,B.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,B.jsx)(Ee,{name:e},e))})})}var q=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182`})});function J(e,t){return new Date(e).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`})}function Oe(e,t,n){let r=Date.now()-new Date(e).getTime(),i=Math.floor(r/6e4),o=Math.floor(r/36e5),s=Math.floor(r/864e5);return i<1?n(a.AUTOMATIONS$DETAIL$TIME_JUST_NOW):i<60?n(a.AUTOMATIONS$DETAIL$TIME_MINUTES_AGO,{count:i}):o<24?n(a.AUTOMATIONS$DETAIL$TIME_HOURS_AGO,{count:o}):s===1?n(a.AUTOMATIONS$DETAIL$TIME_YESTERDAY):s<7?n(a.AUTOMATIONS$DETAIL$TIME_DAYS_AGO,{count:s}):J(e,t)}function ke({createdAt:e,lastRunAt:t}){let{t:n,i18n:r}=s(`openhands`),i=r.language;return(0,B.jsx)(H,{icon:(0,B.jsx)(q,{className:`size-4`}),title:n(a.AUTOMATIONS$DETAIL$ACTIVITY),children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4`,children:[(0,B.jsx)(G,{icon:(0,B.jsx)(W,{className:`size-3.5`}),label:n(a.AUTOMATIONS$DETAIL$CREATED),children:J(e,i)}),(0,B.jsx)(G,{icon:(0,B.jsx)(P,{className:`size-3.5`}),label:n(a.AUTOMATIONS$DETAIL$LAST_RUN),children:t?Oe(t,i,n):n(a.AUTOMATIONS$DETAIL$TIME_NEVER)})]})})}var Ae=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z`})}),je={[R.COMPLETED]:{label:a.AUTOMATIONS$DETAIL$SUCCESSFUL,style:`border-[var(--oh-success)]/50 bg-[var(--oh-success)]/10 text-[var(--oh-success)]`},[R.FAILED]:{label:a.AUTOMATIONS$DETAIL$FAILED,style:`border-[var(--oh-danger)]/50 bg-[var(--oh-danger)]/10 text-danger`},[R.PENDING]:{label:a.AUTOMATIONS$DETAIL$PENDING,style:`border-[var(--oh-border)] bg-surface-raised text-muted`},[R.RUNNING]:{label:a.AUTOMATIONS$DETAIL$RUNNING,style:`border-[var(--oh-border)] bg-surface-raised text-muted`}};function Me({status:e}){switch(e){case R.COMPLETED:return(0,B.jsx)(U,{"data-testid":`run-status-icon-completed`,className:`size-3.5`});case R.FAILED:return(0,B.jsx)(Ae,{"data-testid":`run-status-icon-failed`,className:`size-3.5`});default:return(0,B.jsx)(P,{"data-testid":`run-status-icon-pending`,className:`size-3.5`})}}function Ne({status:e}){let{t}=s(`openhands`),n=je[e];return(0,B.jsxs)(`span`,{className:d(`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium`,n.style),children:[(0,B.jsx)(Me,{status:e}),t(n.label)]})}var Pe=20;function Fe(e){return e.kind===`BashOutput`}var Ie=class e{static async listOutputs(t,n,r){let i=[],a;for(let o=0;o<Pe;o+=1){let o=await e.searchEvents(t,n,{kind__eq:`BashOutput`,command_id__eq:r,sort_order:`TIMESTAMP`,...a?{page_id:a}:{}});if(o.items.forEach(e=>{Fe(e)&&i.push(e)}),!o.next_page_id)break;a=o.next_page_id}return i}static async searchEvents(e,t,n){let r=p().backend;if(r.kind===`cloud`){if(!e)throw Error(`BashService.listOutputs requires a conversation URL on cloud backends`);let i=new URLSearchParams;return Object.entries(n).forEach(([e,t])=>{t!=null&&i.set(e,String(t))}),x({backend:r,method:`GET`,hostOverride:f(e),path:`/api/bash/bash_events/search?${i.toString()}`,authMode:`session-api-key`,sessionApiKey:t})}return new g(m({...e?{conversationUrl:e}:{},sessionApiKey:t})).searchEvents(n)}},Le=[`bash-command-logs`];function Re(e){switch(e){case`MISSING`:return`missing`;case`PAUSED`:return`paused`;case`STARTING`:return`starting`;case`ERROR`:return`errored`;case`RUNNING`:case null:case void 0:default:return null}}function Y(e){if(!b.isAxiosError(e))return null;if(!e.response)return`unreachable`;let t=e.response.status;return t===404||t>=500?`unreachable`:null}function ze(e){let{conversationId:t,bashCommandId:n,enabled:r=!0}=e,i=h(),a=T(r?t??null:null),s=a.data,c=s?.conversation_url??null,l=s?.session_api_key??null,u=i.backend.kind===`cloud`,d=a.isFetched,f=null,p=!1;u&&d&&(s?f=Re(s.sandbox_status)??(s.conversation_url?null:`missing`):p=!0);let m=r&&!!n&&(u?!!c:!0)&&!f&&!p,g=o({queryKey:[...Le,n,c,l,i.backend.id,i.orgId],queryFn:()=>Ie.listOutputs(c,l,n),enabled:m,staleTime:60*1e3,gcTime:300*1e3,retry:!1}),_=u?Y(g.error):null,v=f??_;return{data:g.data,error:_?null:g.error,isFetching:g.isFetching,isPending:g.isPending,isResolvingConversation:u&&a.isPending,conversationMissing:p,sandboxIssue:v}}var Be={missing:a.AUTOMATIONS$DETAIL$LOGS_SANDBOX_MISSING,paused:a.AUTOMATIONS$DETAIL$LOGS_SANDBOX_PAUSED,starting:a.AUTOMATIONS$DETAIL$LOGS_SANDBOX_STARTING,errored:a.AUTOMATIONS$DETAIL$LOGS_SANDBOX_ERROR,unreachable:a.AUTOMATIONS$DETAIL$LOGS_SANDBOX_UNREACHABLE};function X(e,t){return[...e].sort((e,t)=>{let n=e.timestamp.localeCompare(t.timestamp);return n===0?(e.order??0)-(t.order??0):n}).map(e=>e[t]??``).join(``)}function Ve({conversationId:e,bashCommandId:t,isOpen:n,onClose:r}){let{t:i}=s(`openhands`),[o,c]=(0,z.useState)(`stdout`),{data:l,isFetching:u,isResolvingConversation:f,sandboxIssue:p,conversationMissing:m,error:h}=ze({conversationId:e,bashCommandId:t,enabled:n});(0,z.useEffect)(()=>{n&&c(`stdout`)},[n,t]),(0,z.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r]);let{stdout:g,stderr:v}=(0,z.useMemo)(()=>l?{stdout:X(l,`stdout`),stderr:X(l,`stderr`)}:{stdout:``,stderr:``},[l]);if(!n)return null;let y=f||u&&!l,b=!t,x=o===`stdout`?g:v,S=`border-b-2 px-3 py-2 text-sm font-normal transition-colors focus:outline-none`,C=`border-[var(--oh-primary)] text-white`,w=`border-transparent text-muted hover:text-content`;return(0,B.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,role:`dialog`,"aria-modal":`true`,"aria-label":i(a.AUTOMATIONS$DETAIL$LOGS_TITLE),children:[(0,B.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:r,onKeyDown:e=>{e.key===`Escape`&&r()},role:`presentation`}),(0,B.jsxs)(`div`,{className:`relative flex max-h-[80vh] w-full max-w-3xl flex-col rounded-xl border border-[var(--oh-border)] bg-[var(--oh-surface)] p-6`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:r,className:`absolute right-4 top-4 text-muted hover:text-foreground`,"aria-label":i(a.AUTOMATIONS$CANCEL),children:(0,B.jsx)(D,{className:`size-5`})}),(0,B.jsx)(`h2`,{className:d(`pr-8`,_),children:i(a.AUTOMATIONS$DETAIL$LOGS_TITLE)}),(0,B.jsxs)(`div`,{role:`tablist`,"aria-label":i(a.AUTOMATIONS$DETAIL$LOGS_TITLE),className:`mt-4 flex gap-1 border-b border-[var(--oh-border)]`,children:[(0,B.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":o===`stdout`,"aria-controls":`run-logs-panel-stdout`,id:`run-logs-tab-stdout`,tabIndex:o===`stdout`?0:-1,onClick:()=>c(`stdout`),className:`${S} ${o===`stdout`?C:w}`,children:i(a.AUTOMATIONS$DETAIL$LOGS_TAB_OUTPUT)}),(0,B.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":o===`stderr`,"aria-controls":`run-logs-panel-stderr`,id:`run-logs-tab-stderr`,tabIndex:o===`stderr`?0:-1,onClick:()=>c(`stderr`),className:`${S} ${o===`stderr`?C:w}`,children:i(a.AUTOMATIONS$DETAIL$LOGS_TAB_ERROR)})]}),(0,B.jsxs)(`div`,{role:`tabpanel`,id:`run-logs-panel-${o}`,"aria-labelledby":`run-logs-tab-${o}`,className:`mt-3 min-h-[12rem] flex-1 overflow-auto rounded-lg border border-[var(--oh-border)] bg-black/40 p-4 font-mono text-xs`,children:[b&&(0,B.jsx)(`p`,{className:`text-muted italic`,children:i(a.AUTOMATIONS$DETAIL$LOGS_NO_COMMAND)}),!b&&m&&(0,B.jsx)(`p`,{className:`text-muted italic`,children:i(a.AUTOMATIONS$DETAIL$LOGS_CONVERSATION_MISSING)}),!b&&!m&&p&&(0,B.jsx)(`p`,{"data-testid":`run-logs-sandbox-issue-${p}`,className:`text-muted italic`,children:i(Be[p])}),!b&&!m&&!p&&y&&(0,B.jsx)(`p`,{className:`text-muted italic`,children:i(a.AUTOMATIONS$DETAIL$LOGS_LOADING)}),!b&&!m&&!p&&!y&&h&&!l&&(0,B.jsxs)(`p`,{className:`text-danger`,children:[i(a.AUTOMATIONS$DETAIL$LOGS_ERROR),`: `,String(h)]}),!y&&!p&&l&&(0,B.jsx)(`pre`,{"data-testid":`run-logs-output-${o}`,className:`whitespace-pre-wrap break-words ${o===`stderr`?`text-danger`:`text-content`}`,children:x.length>0?x:(0,B.jsx)(`span`,{className:`text-muted italic`,children:i(a.AUTOMATIONS$DETAIL$LOGS_EMPTY)})})]})]})]})}function He(e,t){return new Date(e).toLocaleDateString(t,{weekday:`long`,year:`numeric`,month:`long`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function Ue(e){if(!e)return!0;let t=new Date(e).getTime();return Number.isNaN(t)||t===0}function We(e){return`/conversations/${e}`}function Ge({run:e}){let{t,i18n:n}=s(`openhands`),r=!!e.conversation_id,i=!!e.bash_command_id,o=e.status===R.COMPLETED||e.status===R.FAILED,c=!r&&o,[l,u]=(0,z.useState)(!1),[d]=(0,z.useState)(()=>new Date().toISOString()),f=He(Ue(e.started_at)?d:e.started_at,n.language),p=i?(0,B.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),e.preventDefault(),u(!0)},className:`rounded-md p-1 text-muted hover:bg-surface-raised hover:text-foreground focus:bg-surface-raised focus:outline-none`,"aria-label":t(a.AUTOMATIONS$DETAIL$LOGS_VIEW,{timestamp:f}),title:t(a.AUTOMATIONS$DETAIL$LOGS_VIEW_SHORT),children:(0,B.jsx)(w,{className:`size-4`})}):null,m=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`span`,{className:`text-sm text-content`,children:f}),c&&(0,B.jsxs)(`span`,{className:`text-xs text-muted italic`,children:[`(`,t(a.AUTOMATIONS$DETAIL$NO_CONVERSATION),`)`]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,(0,B.jsx)(Ne,{status:e.status})]})]});return(0,B.jsxs)(B.Fragment,{children:[r&&e.conversation_id?(0,B.jsx)(`a`,{href:We(e.conversation_id),className:`flex items-center justify-between px-5 py-3 transition-colors cursor-pointer hover:bg-surface-raised focus:bg-surface-raised focus:outline-none`,"aria-label":`View conversation for run at ${f}`,children:m}):(0,B.jsx)(`div`,{className:`flex items-center justify-between px-5 py-3 cursor-default`,children:m}),i&&(0,B.jsx)(Ve,{conversationId:e.conversation_id,bashCommandId:e.bash_command_id,isOpen:l,onClose:()=>u(!1)})]})}var Z=20;function Ke({automationId:e}){let{t}=s(`openhands`),[n,r]=(0,z.useState)(Z),{data:i,isLoading:o}=A({id:e,limit:n,offset:0}),c=i?i.total>i.runs.length:!1;return(0,B.jsxs)(`div`,{className:`rounded-2xl border border-[var(--oh-border)] bg-[var(--oh-surface)]`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--oh-border)] px-5 py-3`,children:[(0,B.jsx)(`span`,{className:`size-4 text-muted`,children:(0,B.jsx)(q,{className:`size-4`})}),(0,B.jsx)(`h3`,{className:`text-sm font-medium text-content`,children:t(a.AUTOMATIONS$DETAIL$ACTIVITY_LOG)})]}),o&&(0,B.jsx)(`div`,{className:`space-y-1 p-5`,children:Array.from({length:3}).map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between py-3`,children:[(0,B.jsx)(`div`,{className:`h-5 w-64 animate-pulse rounded bg-surface-raised`}),(0,B.jsx)(`div`,{className:`h-6 w-24 animate-pulse rounded-full bg-surface-raised`})]},`skeleton-${t}`))}),!o&&i?.runs.length===0&&(0,B.jsx)(`p`,{className:`px-5 py-8 text-center text-sm text-muted`,children:t(a.AUTOMATIONS$DETAIL$NO_RUNS)}),!o&&i&&i.runs.length>0&&(0,B.jsxs)(`div`,{children:[i.runs.map((e,t)=>(0,B.jsx)(`div`,{className:t>0?`border-t border-[var(--oh-border)]`:``,children:(0,B.jsx)(Ge,{run:e})},e.id)),c&&(0,B.jsx)(`div`,{className:`border-t border-[var(--oh-border)] px-5 py-3`,children:(0,B.jsx)(`button`,{type:`button`,onClick:()=>r(e=>e+Z),className:`text-sm text-muted hover:text-foreground`,children:t(a.AUTOMATIONS$DETAIL$LOAD_MORE_RUNS)})})]})]})}function Q({className:e}){return(0,B.jsx)(`div`,{className:d(`animate-pulse rounded bg-surface-raised`,e)})}function $(){return(0,B.jsxs)(`div`,{className:`flex flex-col gap-4`,"data-testid":`detail-skeleton`,children:[(0,B.jsx)(Q,{className:`h-5 w-40`}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(Q,{className:`h-6 w-48`}),(0,B.jsx)(Q,{className:`h-6 w-16 rounded-full`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(Q,{className:`h-6 w-11 rounded-full`}),(0,B.jsx)(Q,{className:`h-8 w-8`})]})]}),(0,B.jsx)(Q,{className:`h-5 w-96`}),(0,B.jsx)(Q,{className:`h-36 w-full rounded-2xl`}),(0,B.jsx)(Q,{className:`h-72 w-full rounded-2xl`}),(0,B.jsx)(Q,{className:`h-32 w-full rounded-2xl`}),(0,B.jsx)(Q,{className:`h-40 w-full rounded-2xl`})]})}function qe(){let{t:e}=s(`openhands`);return(0,B.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20`,children:[(0,B.jsx)(M,{className:`size-12 text-muted`}),(0,B.jsx)(`p`,{className:`mt-4 text-sm font-medium text-content`,children:e(a.AUTOMATIONS$DETAIL$NOT_FOUND_TITLE)}),(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:e(a.AUTOMATIONS$DETAIL$NOT_FOUND_MESSAGE)}),(0,B.jsx)(`div`,{className:`mt-6`,children:(0,B.jsx)(V,{})})]})}var Je=n(function(){let{t:e}=s(`openhands`),{automationId:t}=r(),{navigate:n}=v(),[i,o]=(0,z.useState)(!1),[u,d]=(0,z.useState)(!1),{data:f,isLoading:p,refetch:m}=j(),g=f?.status===`ok`,_=h(),b=(0,z.useRef)(_.backend.id).current!==_.backend.id,{data:x,isLoading:C,isError:w,error:T,refetch:E}=ee({id:t??``,enabled:g&&!b}),{trackPrebuiltAutomationEnabled:D}=S(),O=de(),k=fe(),A=te(),M=w&&y(T)&&T.response?.status===404;if(p)return(0,B.jsx)(`div`,{className:`min-h-full`,children:(0,B.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,B.jsx)($,{})})});if(!g)return(0,B.jsx)(`div`,{className:`min-h-full`,children:(0,B.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,B.jsx)(oe,{onRetry:m})})});if(C)return(0,B.jsx)(`div`,{className:`min-h-full`,children:(0,B.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,B.jsx)($,{})})});if(M)return(0,B.jsx)(`div`,{className:`min-h-full`,children:(0,B.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,B.jsx)(qe,{})})});if(w||!x)return(0,B.jsx)(`div`,{className:`min-h-full`,children:(0,B.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,B.jsx)(I,{onRetry:()=>E()})})});let N=()=>{let e=!x.enabled;O.mutate({id:x.id,enabled:e}),e&&D({automationId:x.id,automationName:x.name})},P=()=>{k.mutate(x.id,{onSuccess:()=>{n?.(`/automations`)}})},F=()=>{A.mutate(x.id,{onSuccess:()=>{c(e(a.AUTOMATIONS$RUN_NOW_SUCCESS))},onError:t=>{l(y(t)?t.response?.data?.message||t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR):t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR))}})},L=_.backend.kind===`local`;return(0,B.jsx)(`div`,{className:`min-h-full`,children:(0,B.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,B.jsx)(V,{}),(0,B.jsx)(he,{automation:x,onToggle:N,onEdit:L?()=>d(!0):void 0,onDelete:()=>o(!0),onRunNow:F,isRunningNow:A.isPending}),x.prompt&&(0,B.jsx)(ve,{prompt:x.prompt}),(0,B.jsx)(we,{automation:x}),x.plugins&&x.plugins.length>0&&(0,B.jsx)(De,{plugins:x.plugins}),(0,B.jsx)(ke,{createdAt:x.created_at,lastRunAt:x.last_triggered_at}),(0,B.jsx)(Ke,{automationId:x.id}),(0,B.jsx)(re,{automationName:x.name,isOpen:i,onConfirm:P,onCancel:()=>o(!1)}),L&&(0,B.jsx)(ce,{automation:x,isOpen:u,onClose:()=>d(!1)})]})})})});export{Je as default};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{L as n,P as r}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-BjMt2JeR.js";import{o as i,t as a}from"./declaration-D9ucT0fq.js";import{t as o}from"./useQuery-DGRSm7IT.js";import{t as s}from"./useTranslation-CL6FTf1b.js";import{m as c,p as l}from"./query-client-config-Ca3tW1AH.js";import{t as u}from"./back-nav-button-D20Avel_.js";import{t as d}from"./utils-eXk6yerZ.js";import{T as f,a as p,n as m}from"./agent-server-client-options-wXLeJYeM.js";import{n as h}from"./active-backend-context-B2OSC-qe.js";import{f as g}from"./vendor~root-layout~home~conversation-panel~conversation~launch~mcp~settings~settings-index~~m3acswdn-DQE89epK.js";import{r as _}from"./modal-classes-CNm4ovfm.js";import{n as v}from"./navigation-context-BpAOh_t5.js";import{n as y,r as b}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~bxn4ldi1-_LydBB1e.js";import{t as x}from"./proxy-Bx3NeKeo.js";import{t as S}from"./use-tracking-C9P88zSo.js";import{t as C}from"./u-edit-DIgADxLH.js";import{t as w}from"./terminal-B92mACR5.js";import{t as T}from"./use-user-conversation-2jZZ-MLA.js";import{t as E}from"./toggle-switch-CL_wRiGs.js";import{t as D}from"./x-mark-C42svtnu.js";import{t as O}from"./code-tag-chmctf4w.js";import{t as k}from"./link-external-ooNztGLp.js";import{C as A,S as ee,_ as j,a as M,b as te,c as N,d as P,f as F,i as I,l as L,m as ne,n as re,o as ie,p as ae,r as oe,s as se,t as ce,u as le,w as ue,x as de,y as fe}from"./edit-automation-modal-CpA_JKLY.js";import{t as R}from"./automation-XLxhq3I8.js";var z=e(t()),B=i();function V(){let{t:e}=s(`openhands`);return(0,B.jsx)(u,{to:`/automations`,children:e(a.AUTOMATIONS$DETAIL$BACK_TO_LIST)})}var pe=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3`})});function me({active:e}){let{t}=s(`openhands`);return(0,B.jsx)(`span`,{"data-testid":e?`active-status-badge-active`:`active-status-badge-inactive`,className:d(`inline-flex items-center rounded-full px-3 py-1 text-xs font-medium`,e?`bg-[var(--oh-success)]/15 text-[var(--oh-success)]`:`bg-surface-raised text-muted`),children:t(e?a.AUTOMATIONS$DETAIL$ACTIVE:a.AUTOMATIONS$DETAIL$INACTIVE)})}function he({automation:e,onToggle:t,onEdit:n,onDelete:r,onRunNow:i,isRunningNow:o=!1}){let{t:c}=s(`openhands`),l=ae(`manage_automations`),u=[...n?[{label:c(a.AUTOMATIONS$EDIT),icon:(0,B.jsx)(C,{className:`size-4`}),onClick:n}]:[],{label:e.enabled?c(a.AUTOMATIONS$TURN_OFF):c(a.AUTOMATIONS$TURN_ON),icon:(0,B.jsx)(se,{className:`size-4`}),onClick:t},{label:c(a.AUTOMATIONS$DOWNLOAD_TARBALL),icon:(0,B.jsx)(pe,{className:`size-4`}),onClick:()=>{ue.downloadTarball(e.id,e.name)}},{label:c(a.AUTOMATIONS$DELETE),icon:(0,B.jsx)(ie,{className:`size-4`}),onClick:r}];return(0,B.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e.name}),(0,B.jsx)(me,{active:e.enabled})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l&&i&&(0,B.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-md border border-[var(--oh-border)] px-3 py-1.5 text-sm font-medium text-content transition-colors hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:o||!e.enabled,onClick:i,children:[(0,B.jsx)(F,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),o?`Starting…`:c(a.AUTOMATIONS$RUN_NOW)]}),l&&(0,B.jsx)(E,{enabled:e.enabled,label:e.enabled?c(a.AUTOMATIONS$TURN_OFF):c(a.AUTOMATIONS$TURN_ON),onToggle:t}),l&&(0,B.jsx)(ne,{items:u})]})]})})}function H({icon:e,title:t,children:n}){return(0,B.jsxs)(`div`,{className:`rounded-2xl border border-[var(--oh-border)] bg-[var(--oh-surface)]`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--oh-border)] px-5 py-3`,children:[(0,B.jsx)(`span`,{className:`size-4 text-muted`,children:e}),(0,B.jsx)(`h3`,{className:`text-sm font-medium text-content`,children:t})]}),(0,B.jsx)(`div`,{className:`px-5 py-5`,children:n})]})}var ge=240,_e=`max-h-60`;function ve({prompt:e}){let{t}=s(`openhands`),[n,r]=z.useState(!1),[i,o]=z.useState(!1),c=z.useRef(null),l=i&&!n;return z.useLayoutEffect(()=>{let e=c.current;if(!e)return;let t=()=>{o(e.scrollHeight>ge)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]),(0,B.jsx)(H,{icon:(0,B.jsx)(w,{className:`size-4`}),title:t(a.AUTOMATIONS$DETAIL$PROMPT),children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(`p`,{ref:c,className:d(`whitespace-pre-wrap text-sm leading-6 text-content`,l&&d(_e,`overflow-hidden`)),"data-testid":`automation-prompt-content`,children:e}),l?(0,B.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-20 bg-gradient-to-t from-[var(--oh-surface)] to-transparent`,"aria-hidden":!0,"data-testid":`automation-prompt-fade`}):null]}),i?(0,B.jsx)(`button`,{type:`button`,className:`self-start cursor-pointer text-sm font-normal text-[var(--oh-muted)] hover:text-white`,onClick:()=>r(e=>!e),"data-testid":`automation-prompt-toggle`,children:t(n?a.COMMON$VIEW_LESS:a.COMMON$VIEW_MORE)}):null]})})}var ye=e=>(0,B.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:[(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 0 1 1.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.56.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.893.149c-.425.07-.765.383-.93.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 0 1-1.449.12l-.738-.527c-.35-.25-.806-.272-1.204-.107-.397.165-.71.505-.78.929l-.15.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 0 1-.12-1.45l.527-.737c.25-.35.273-.806.108-1.204-.165-.397-.506-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.108-1.204l-.526-.738a1.125 1.125 0 0 1 .12-1.45l.773-.773a1.125 1.125 0 0 1 1.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894Z`}),(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z`})]}),be=e=>(0,B.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:[(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6 3v12m0 0a3 3 0 1 0 3 3M6 15a3 3 0 0 1 3-3h6a3 3 0 0 0 3-3V3m0 0a3 3 0 1 0 0 0`}),(0,B.jsx)(`circle`,{cx:6,cy:3,r:2}),(0,B.jsx)(`circle`,{cx:18,cy:3,r:2}),(0,B.jsx)(`circle`,{cx:9,cy:18,r:2})]}),U=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z`})}),W=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0v-7.5A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5`})}),xe=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M14.857 17.082a23.848 23.848 0 0 0 5.454-1.31A8.967 8.967 0 0 1 18 9.75V9A6 6 0 0 0 6 9v.75a8.967 8.967 0 0 1-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 0 1-5.714 0m5.714 0a3 3 0 1 1-5.714 0`})});function G({icon:e,label:t,children:n}){return(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`size-3.5 text-muted`,children:e}),(0,B.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:t})]}),(0,B.jsx)(`div`,{className:`text-sm text-content`,children:n})]})}function Se({branch:e}){return(0,B.jsx)(`span`,{className:`inline-flex items-center rounded-full border border-[var(--oh-border)] bg-surface-raised px-2.5 py-0.5 text-xs text-muted`,children:e})}var K=60;function Ce({filter:e}){let{t}=s(`openhands`),[n,r]=(0,z.useState)(!1),i=e.length>K;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,B.jsx)(`span`,{className:`break-all`,children:i&&!n?`${e.slice(0,K)}…`:e}),i&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-expanded":n,className:`text-xs text-muted hover:text-content self-start`,children:t(n?a.SETTINGS$SKILLS_SHOW_LESS:a.SETTINGS$SKILLS_SHOW_MORE)})]})}function we({automation:e}){let{t}=s(`openhands`),n=e.trigger.type===`event`,r=e.trigger.schedule??``;e.trigger.schedule_human&&(r=e.timezone?`${e.trigger.schedule_human} (${e.timezone})`:e.trigger.schedule_human);let i=t(n?a.AUTOMATIONS$DETAIL$TRIGGER_EVENT:a.AUTOMATIONS$DETAIL$TRIGGER_SCHEDULE);return(0,B.jsx)(H,{icon:(0,B.jsx)(ye,{className:`size-4`}),title:t(a.AUTOMATIONS$DETAIL$CONFIGURATION),children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-5`,children:[e.repository&&(0,B.jsx)(G,{icon:(0,B.jsx)(be,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$REPOSITORIES),children:(0,B.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e.repository,e.branch&&(0,B.jsx)(Se,{branch:e.branch})]})}),(0,B.jsx)(G,{icon:(0,B.jsx)(U,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$TRIGGER),children:i}),!n&&(0,B.jsx)(G,{icon:(0,B.jsx)(W,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$SCHEDULE),children:r}),n&&e.trigger.source&&(0,B.jsx)(G,{icon:(0,B.jsx)(le,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$EVENT_SOURCE),children:e.trigger.source}),n&&e.trigger.on&&(0,B.jsx)(G,{icon:(0,B.jsx)(k,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$EVENT_TYPE),children:N(e.trigger.on)}),n&&e.trigger.filter&&(0,B.jsx)(G,{icon:(0,B.jsx)(O,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$EVENT_FILTER),children:(0,B.jsx)(Ce,{filter:e.trigger.filter})}),(0,B.jsx)(G,{icon:(0,B.jsx)(L,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$MODEL),children:e.model??`Active profile`}),e.notification&&(0,B.jsx)(G,{icon:(0,B.jsx)(xe,{className:`size-3.5`}),label:t(a.AUTOMATIONS$DETAIL$NOTIFICATION),children:e.notification})]})})}var Te=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 0 1-.657.643 48.39 48.39 0 0 1-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 0 1-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 0 0-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.039 48.039 0 0 1-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 0 0 .657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 0 1-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 0 0 5.427-.63 48.05 48.05 0 0 0 .582-4.717.532.532 0 0 0-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 0 0 .658-.663 48.422 48.422 0 0 0-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 0 1-.61-.58v0Z`})});function Ee({name:e}){return(0,B.jsx)(`span`,{className:`inline-flex items-center rounded-full border border-[var(--oh-border)] bg-[var(--oh-surface-deep)] px-3.5 py-1.5 text-sm text-content`,children:e})}function De({plugins:e}){let{t}=s(`openhands`);return(0,B.jsx)(H,{icon:(0,B.jsx)(Te,{className:`size-4`}),title:t(a.AUTOMATIONS$DETAIL$PLUGINS),children:(0,B.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,B.jsx)(Ee,{name:e},e))})})}var q=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182`})});function J(e,t){return new Date(e).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`})}function Oe(e,t,n){let r=Date.now()-new Date(e).getTime(),i=Math.floor(r/6e4),o=Math.floor(r/36e5),s=Math.floor(r/864e5);return i<1?n(a.AUTOMATIONS$DETAIL$TIME_JUST_NOW):i<60?n(a.AUTOMATIONS$DETAIL$TIME_MINUTES_AGO,{count:i}):o<24?n(a.AUTOMATIONS$DETAIL$TIME_HOURS_AGO,{count:o}):s===1?n(a.AUTOMATIONS$DETAIL$TIME_YESTERDAY):s<7?n(a.AUTOMATIONS$DETAIL$TIME_DAYS_AGO,{count:s}):J(e,t)}function ke({createdAt:e,lastRunAt:t}){let{t:n,i18n:r}=s(`openhands`),i=r.language;return(0,B.jsx)(H,{icon:(0,B.jsx)(q,{className:`size-4`}),title:n(a.AUTOMATIONS$DETAIL$ACTIVITY),children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4`,children:[(0,B.jsx)(G,{icon:(0,B.jsx)(W,{className:`size-3.5`}),label:n(a.AUTOMATIONS$DETAIL$CREATED),children:J(e,i)}),(0,B.jsx)(G,{icon:(0,B.jsx)(P,{className:`size-3.5`}),label:n(a.AUTOMATIONS$DETAIL$LAST_RUN),children:t?Oe(t,i,n):n(a.AUTOMATIONS$DETAIL$TIME_NEVER)})]})})}var Ae=e=>(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,B.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z`})}),je={[R.COMPLETED]:{label:a.AUTOMATIONS$DETAIL$SUCCESSFUL,style:`border-[var(--oh-success)]/50 bg-[var(--oh-success)]/10 text-[var(--oh-success)]`},[R.FAILED]:{label:a.AUTOMATIONS$DETAIL$FAILED,style:`border-[var(--oh-danger)]/50 bg-[var(--oh-danger)]/10 text-danger`},[R.PENDING]:{label:a.AUTOMATIONS$DETAIL$PENDING,style:`border-[var(--oh-border)] bg-surface-raised text-muted`},[R.RUNNING]:{label:a.AUTOMATIONS$DETAIL$RUNNING,style:`border-[var(--oh-border)] bg-surface-raised text-muted`}};function Me({status:e}){switch(e){case R.COMPLETED:return(0,B.jsx)(U,{"data-testid":`run-status-icon-completed`,className:`size-3.5`});case R.FAILED:return(0,B.jsx)(Ae,{"data-testid":`run-status-icon-failed`,className:`size-3.5`});default:return(0,B.jsx)(P,{"data-testid":`run-status-icon-pending`,className:`size-3.5`})}}function Ne({status:e}){let{t}=s(`openhands`),n=je[e];return(0,B.jsxs)(`span`,{className:d(`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium`,n.style),children:[(0,B.jsx)(Me,{status:e}),t(n.label)]})}var Pe=20;function Fe(e){return e.kind===`BashOutput`}var Ie=class e{static async listOutputs(t,n,r){let i=[],a;for(let o=0;o<Pe;o+=1){let o=await e.searchEvents(t,n,{kind__eq:`BashOutput`,command_id__eq:r,sort_order:`TIMESTAMP`,...a?{page_id:a}:{}});if(o.items.forEach(e=>{Fe(e)&&i.push(e)}),!o.next_page_id)break;a=o.next_page_id}return i}static async searchEvents(e,t,n){let r=p().backend;if(r.kind===`cloud`){if(!e)throw Error(`BashService.listOutputs requires a conversation URL on cloud backends`);let i=new URLSearchParams;return Object.entries(n).forEach(([e,t])=>{t!=null&&i.set(e,String(t))}),x({backend:r,method:`GET`,hostOverride:f(e),path:`/api/bash/bash_events/search?${i.toString()}`,authMode:`session-api-key`,sessionApiKey:t})}return new g(m({...e?{conversationUrl:e}:{},sessionApiKey:t})).searchEvents(n)}},Le=[`bash-command-logs`];function Re(e){switch(e){case`MISSING`:return`missing`;case`PAUSED`:return`paused`;case`STARTING`:return`starting`;case`ERROR`:return`errored`;case`RUNNING`:case null:case void 0:default:return null}}function Y(e){if(!b.isAxiosError(e))return null;if(!e.response)return`unreachable`;let t=e.response.status;return t===404||t>=500?`unreachable`:null}function ze(e){let{conversationId:t,bashCommandId:n,enabled:r=!0}=e,i=h(),a=T(r?t??null:null),s=a.data,c=s?.conversation_url??null,l=s?.session_api_key??null,u=i.backend.kind===`cloud`,d=a.isFetched,f=null,p=!1;u&&d&&(s?f=Re(s.sandbox_status)??(s.conversation_url?null:`missing`):p=!0);let m=r&&!!n&&(u?!!c:!0)&&!f&&!p,g=o({queryKey:[...Le,n,c,l,i.backend.id,i.orgId],queryFn:()=>Ie.listOutputs(c,l,n),enabled:m,staleTime:60*1e3,gcTime:300*1e3,retry:!1}),_=u?Y(g.error):null,v=f??_;return{data:g.data,error:_?null:g.error,isFetching:g.isFetching,isPending:g.isPending,isResolvingConversation:u&&a.isPending,conversationMissing:p,sandboxIssue:v}}var Be={missing:a.AUTOMATIONS$DETAIL$LOGS_SANDBOX_MISSING,paused:a.AUTOMATIONS$DETAIL$LOGS_SANDBOX_PAUSED,starting:a.AUTOMATIONS$DETAIL$LOGS_SANDBOX_STARTING,errored:a.AUTOMATIONS$DETAIL$LOGS_SANDBOX_ERROR,unreachable:a.AUTOMATIONS$DETAIL$LOGS_SANDBOX_UNREACHABLE};function X(e,t){return[...e].sort((e,t)=>{let n=e.timestamp.localeCompare(t.timestamp);return n===0?(e.order??0)-(t.order??0):n}).map(e=>e[t]??``).join(``)}function Ve({conversationId:e,bashCommandId:t,isOpen:n,onClose:r}){let{t:i}=s(`openhands`),[o,c]=(0,z.useState)(`stdout`),{data:l,isFetching:u,isResolvingConversation:f,sandboxIssue:p,conversationMissing:m,error:h}=ze({conversationId:e,bashCommandId:t,enabled:n});(0,z.useEffect)(()=>{n&&c(`stdout`)},[n,t]),(0,z.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r]);let{stdout:g,stderr:v}=(0,z.useMemo)(()=>l?{stdout:X(l,`stdout`),stderr:X(l,`stderr`)}:{stdout:``,stderr:``},[l]);if(!n)return null;let y=f||u&&!l,b=!t,x=o===`stdout`?g:v,S=`border-b-2 px-3 py-2 text-sm font-normal transition-colors focus:outline-none`,C=`border-[var(--oh-primary)] text-white`,w=`border-transparent text-muted hover:text-content`;return(0,B.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,role:`dialog`,"aria-modal":`true`,"aria-label":i(a.AUTOMATIONS$DETAIL$LOGS_TITLE),children:[(0,B.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:r,onKeyDown:e=>{e.key===`Escape`&&r()},role:`presentation`}),(0,B.jsxs)(`div`,{className:`relative flex max-h-[80vh] w-full max-w-3xl flex-col rounded-xl border border-[var(--oh-border)] bg-[var(--oh-surface)] p-6`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:r,className:`absolute right-4 top-4 text-muted hover:text-foreground`,"aria-label":i(a.AUTOMATIONS$CANCEL),children:(0,B.jsx)(D,{className:`size-5`})}),(0,B.jsx)(`h2`,{className:d(`pr-8`,_),children:i(a.AUTOMATIONS$DETAIL$LOGS_TITLE)}),(0,B.jsxs)(`div`,{role:`tablist`,"aria-label":i(a.AUTOMATIONS$DETAIL$LOGS_TITLE),className:`mt-4 flex gap-1 border-b border-[var(--oh-border)]`,children:[(0,B.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":o===`stdout`,"aria-controls":`run-logs-panel-stdout`,id:`run-logs-tab-stdout`,tabIndex:o===`stdout`?0:-1,onClick:()=>c(`stdout`),className:`${S} ${o===`stdout`?C:w}`,children:i(a.AUTOMATIONS$DETAIL$LOGS_TAB_OUTPUT)}),(0,B.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":o===`stderr`,"aria-controls":`run-logs-panel-stderr`,id:`run-logs-tab-stderr`,tabIndex:o===`stderr`?0:-1,onClick:()=>c(`stderr`),className:`${S} ${o===`stderr`?C:w}`,children:i(a.AUTOMATIONS$DETAIL$LOGS_TAB_ERROR)})]}),(0,B.jsxs)(`div`,{role:`tabpanel`,id:`run-logs-panel-${o}`,"aria-labelledby":`run-logs-tab-${o}`,className:`mt-3 min-h-[12rem] flex-1 overflow-auto rounded-lg border border-[var(--oh-border)] bg-black/40 p-4 font-mono text-xs`,children:[b&&(0,B.jsx)(`p`,{className:`text-muted italic`,children:i(a.AUTOMATIONS$DETAIL$LOGS_NO_COMMAND)}),!b&&m&&(0,B.jsx)(`p`,{className:`text-muted italic`,children:i(a.AUTOMATIONS$DETAIL$LOGS_CONVERSATION_MISSING)}),!b&&!m&&p&&(0,B.jsx)(`p`,{"data-testid":`run-logs-sandbox-issue-${p}`,className:`text-muted italic`,children:i(Be[p])}),!b&&!m&&!p&&y&&(0,B.jsx)(`p`,{className:`text-muted italic`,children:i(a.AUTOMATIONS$DETAIL$LOGS_LOADING)}),!b&&!m&&!p&&!y&&h&&!l&&(0,B.jsxs)(`p`,{className:`text-danger`,children:[i(a.AUTOMATIONS$DETAIL$LOGS_ERROR),`: `,String(h)]}),!y&&!p&&l&&(0,B.jsx)(`pre`,{"data-testid":`run-logs-output-${o}`,className:`whitespace-pre-wrap break-words ${o===`stderr`?`text-danger`:`text-content`}`,children:x.length>0?x:(0,B.jsx)(`span`,{className:`text-muted italic`,children:i(a.AUTOMATIONS$DETAIL$LOGS_EMPTY)})})]})]})]})}function He(e,t){return new Date(e).toLocaleDateString(t,{weekday:`long`,year:`numeric`,month:`long`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function Ue(e){if(!e)return!0;let t=new Date(e).getTime();return Number.isNaN(t)||t===0}function We(e){return`/conversations/${e}`}function Ge({run:e}){let{t,i18n:n}=s(`openhands`),r=!!e.conversation_id,i=!!e.bash_command_id,o=e.status===R.COMPLETED||e.status===R.FAILED,c=!r&&o,[l,u]=(0,z.useState)(!1),[d]=(0,z.useState)(()=>new Date().toISOString()),f=He(Ue(e.started_at)?d:e.started_at,n.language),p=i?(0,B.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),e.preventDefault(),u(!0)},className:`rounded-md p-1 text-muted hover:bg-surface-raised hover:text-foreground focus:bg-surface-raised focus:outline-none`,"aria-label":t(a.AUTOMATIONS$DETAIL$LOGS_VIEW,{timestamp:f}),title:t(a.AUTOMATIONS$DETAIL$LOGS_VIEW_SHORT),children:(0,B.jsx)(w,{className:`size-4`})}):null,m=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`span`,{className:`text-sm text-content`,children:f}),c&&(0,B.jsxs)(`span`,{className:`text-xs text-muted italic`,children:[`(`,t(a.AUTOMATIONS$DETAIL$NO_CONVERSATION),`)`]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,(0,B.jsx)(Ne,{status:e.status})]})]});return(0,B.jsxs)(B.Fragment,{children:[r&&e.conversation_id?(0,B.jsx)(`a`,{href:We(e.conversation_id),className:`flex items-center justify-between px-5 py-3 transition-colors cursor-pointer hover:bg-surface-raised focus:bg-surface-raised focus:outline-none`,"aria-label":`View conversation for run at ${f}`,children:m}):(0,B.jsx)(`div`,{className:`flex items-center justify-between px-5 py-3 cursor-default`,children:m}),i&&(0,B.jsx)(Ve,{conversationId:e.conversation_id,bashCommandId:e.bash_command_id,isOpen:l,onClose:()=>u(!1)})]})}var Z=20;function Ke({automationId:e}){let{t}=s(`openhands`),[n,r]=(0,z.useState)(Z),{data:i,isLoading:o}=A({id:e,limit:n,offset:0}),c=i?i.total>i.runs.length:!1;return(0,B.jsxs)(`div`,{className:`rounded-2xl border border-[var(--oh-border)] bg-[var(--oh-surface)]`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--oh-border)] px-5 py-3`,children:[(0,B.jsx)(`span`,{className:`size-4 text-muted`,children:(0,B.jsx)(q,{className:`size-4`})}),(0,B.jsx)(`h3`,{className:`text-sm font-medium text-content`,children:t(a.AUTOMATIONS$DETAIL$ACTIVITY_LOG)})]}),o&&(0,B.jsx)(`div`,{className:`space-y-1 p-5`,children:Array.from({length:3}).map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between py-3`,children:[(0,B.jsx)(`div`,{className:`h-5 w-64 animate-pulse rounded bg-surface-raised`}),(0,B.jsx)(`div`,{className:`h-6 w-24 animate-pulse rounded-full bg-surface-raised`})]},`skeleton-${t}`))}),!o&&i?.runs.length===0&&(0,B.jsx)(`p`,{className:`px-5 py-8 text-center text-sm text-muted`,children:t(a.AUTOMATIONS$DETAIL$NO_RUNS)}),!o&&i&&i.runs.length>0&&(0,B.jsxs)(`div`,{children:[i.runs.map((e,t)=>(0,B.jsx)(`div`,{className:t>0?`border-t border-[var(--oh-border)]`:``,children:(0,B.jsx)(Ge,{run:e})},e.id)),c&&(0,B.jsx)(`div`,{className:`border-t border-[var(--oh-border)] px-5 py-3`,children:(0,B.jsx)(`button`,{type:`button`,onClick:()=>r(e=>e+Z),className:`text-sm text-muted hover:text-foreground`,children:t(a.AUTOMATIONS$DETAIL$LOAD_MORE_RUNS)})})]})]})}function Q({className:e}){return(0,B.jsx)(`div`,{className:d(`animate-pulse rounded bg-surface-raised`,e)})}function $(){return(0,B.jsxs)(`div`,{className:`flex flex-col gap-4`,"data-testid":`detail-skeleton`,children:[(0,B.jsx)(Q,{className:`h-5 w-40`}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(Q,{className:`h-6 w-48`}),(0,B.jsx)(Q,{className:`h-6 w-16 rounded-full`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(Q,{className:`h-6 w-11 rounded-full`}),(0,B.jsx)(Q,{className:`h-8 w-8`})]})]}),(0,B.jsx)(Q,{className:`h-5 w-96`}),(0,B.jsx)(Q,{className:`h-36 w-full rounded-2xl`}),(0,B.jsx)(Q,{className:`h-72 w-full rounded-2xl`}),(0,B.jsx)(Q,{className:`h-32 w-full rounded-2xl`}),(0,B.jsx)(Q,{className:`h-40 w-full rounded-2xl`})]})}function qe(){let{t:e}=s(`openhands`);return(0,B.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20`,children:[(0,B.jsx)(M,{className:`size-12 text-muted`}),(0,B.jsx)(`p`,{className:`mt-4 text-sm font-medium text-content`,children:e(a.AUTOMATIONS$DETAIL$NOT_FOUND_TITLE)}),(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:e(a.AUTOMATIONS$DETAIL$NOT_FOUND_MESSAGE)}),(0,B.jsx)(`div`,{className:`mt-6`,children:(0,B.jsx)(V,{})})]})}var Je=n(function(){let{t:e}=s(`openhands`),{automationId:t}=r(),{navigate:n}=v(),[i,o]=(0,z.useState)(!1),[u,d]=(0,z.useState)(!1),{data:f,isLoading:p,refetch:m}=j(),g=f?.status===`ok`,_=h(),b=(0,z.useRef)(_.backend.id).current!==_.backend.id,{data:x,isLoading:C,isError:w,error:T,refetch:E}=ee({id:t??``,enabled:g&&!b}),{trackPrebuiltAutomationEnabled:D}=S(),O=de(),k=fe(),A=te(),M=w&&y(T)&&T.response?.status===404;if(p)return(0,B.jsx)(`div`,{className:`min-h-full`,children:(0,B.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,B.jsx)($,{})})});if(!g)return(0,B.jsx)(`div`,{className:`min-h-full`,children:(0,B.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,B.jsx)(oe,{onRetry:m})})});if(C)return(0,B.jsx)(`div`,{className:`min-h-full`,children:(0,B.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,B.jsx)($,{})})});if(M)return(0,B.jsx)(`div`,{className:`min-h-full`,children:(0,B.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,B.jsx)(qe,{})})});if(w||!x)return(0,B.jsx)(`div`,{className:`min-h-full`,children:(0,B.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,B.jsx)(I,{onRetry:()=>E()})})});let N=()=>{let e=!x.enabled;O.mutate({id:x.id,enabled:e}),e&&D({automationId:x.id,automationName:x.name})},P=()=>{k.mutate(x.id,{onSuccess:()=>{n?.(`/automations`)}})},F=()=>{A.mutate(x.id,{onSuccess:()=>{c(e(a.AUTOMATIONS$RUN_NOW_SUCCESS))},onError:t=>{l(y(t)?t.response?.data?.message||t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR):t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR))}})},L=_.backend.kind===`local`;return(0,B.jsx)(`div`,{className:`min-h-full`,children:(0,B.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,B.jsx)(V,{}),(0,B.jsx)(he,{automation:x,onToggle:N,onEdit:L?()=>d(!0):void 0,onDelete:()=>o(!0),onRunNow:F,isRunningNow:A.isPending}),x.prompt&&(0,B.jsx)(ve,{prompt:x.prompt}),(0,B.jsx)(we,{automation:x}),x.plugins&&x.plugins.length>0&&(0,B.jsx)(De,{plugins:x.plugins}),(0,B.jsx)(ke,{createdAt:x.created_at,lastRunAt:x.last_triggered_at}),(0,B.jsx)(Ke,{automationId:x.id}),(0,B.jsx)(re,{automationName:x.name,isOpen:i,onConfirm:P,onCancel:()=>o(!1)}),L&&(0,B.jsx)(ce,{automation:x,isOpen:u,onClose:()=>d(!1)})]})})})});export{Je as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{L as n}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-BjMt2JeR.js";import{t as r}from"./react-dom-hVBnwgwZ.js";import{o as i,t as a}from"./declaration-D9ucT0fq.js";import{n as o,t as s}from"./recommended-automations-launcher-DCi0RXIj.js";import{t as c}from"./Trans-sy4l4TyQ.js";import{t as l}from"./useTranslation-CL6FTf1b.js";import{m as u,p as d}from"./query-client-config-Ca3tW1AH.js";import{t as f}from"./createLucideIcon-CkGTf9Qj.js";import{t as p}from"./check-BhnsMsWy.js";import{t as m}from"./utils-eXk6yerZ.js";import{n as h}from"./active-backend-context-CNF2lPkA.js";import{t as g}from"./modal-backdrop-_VbcKk5K.js";import{n as _}from"./modal-classes-CNm4ovfm.js";import{t as v}from"./brand-button-9SOzmqPP.js";import{n as y}from"./navigation-context-BpAOh_t5.js";import{t as b}from"./styled-tooltip-X61SEwqk.js";import{u as x}from"./dropdown-classes-CVp0kVdt.js";import{n as ee}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~bxn4ldi1-_LydBB1e.js";import{t as S}from"./modal-close-button-Dbo0NAMt.js";import{t as te}from"./use-tracking-BhyV5A9i.js";import{n as C,t as w}from"./context-menu-list-item-BQU0jZPq.js";import{t as T}from"./u-edit-DIgADxLH.js";import{t as E}from"./folder-DPTBlxWb.js";import{t as D}from"./search-C_l_XW4e.js";import{a as O,i as k,n as A,o as j,r as M,t as N}from"./extension-module-card-classes-DP5J6ngE.js";import{n as P}from"./skill-card-pill-row-DeodrwPG.js";import{n as F,t as I}from"./use-launch-skill-in-chat-BTgXIu3N.js";import{_ as ne,b as re,c as L,d as R,f as z,g as B,h as V,i as ie,l as H,m as U,n as ae,o as oe,p as W,r as se,s as ce,t as le,u as G,v as ue,x as de,y as fe}from"./edit-automation-modal-8y9Uctxo.js";var pe=f(`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`}]]),me=f(`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`}]]),he=f(`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`}]]),K=e(t(),1),q=i();function ge({value:e,onChange:t,className:n}){let{t:r}=l(`openhands`);return(0,q.jsxs)(`div`,{className:m(`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,q.jsx)(D,{className:`ml-3 size-4 shrink-0 text-tertiary-alt`,"aria-hidden":!0}),(0,q.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:r(a.AUTOMATIONS$SEARCH_PLACEHOLDER),"aria-label":r(a.AUTOMATIONS$SEARCH_PLACEHOLDER),className:`min-w-0 flex-1 border-0 bg-transparent px-3 text-sm text-white outline-none placeholder:text-tertiary-alt`})]})}function J(e,t){let n=[];if(e.repository&&n.push({id:`repository`,node:(0,q.jsxs)(`span`,{className:m(k,`gap-1`),children:[(0,q.jsx)(E,{className:`size-3 shrink-0`}),e.repository]})}),e.trigger.type===`event`){let t=[e.trigger.on?L(e.trigger.on):``,e.trigger.source?`(${e.trigger.source})`:``].filter(Boolean).join(` `);n.push({id:`event-trigger`,node:(0,q.jsxs)(`span`,{className:m(k,`gap-1`),children:[(0,q.jsx)(G,{className:`size-3 shrink-0`}),t]})})}else n.push({id:`schedule`,node:(0,q.jsxs)(`span`,{className:m(k,`gap-1`),children:[(0,q.jsx)(R,{className:`size-3 shrink-0`}),t]})});return e.model&&n.push({id:`model`,node:(0,q.jsxs)(`span`,{className:m(k,`gap-1`),children:[(0,q.jsx)(H,{className:`size-3 shrink-0`}),e.model]})}),n}function Y({automation:e,t,canManage:n,onRunNow:r,isRunPending:i,onView:o,onEdit:s,onToggle:c,onDelete:l}){return[...n?[{label:t(a.AUTOMATIONS$RUN_NOW),icon:(0,q.jsx)(z,{className:`size-4`}),onClick:()=>r(e.id),disabled:i||!e.enabled}]:[],{label:t(a.COMMON$VIEW),icon:(0,q.jsx)(pe,{className:`size-4`,"aria-hidden":!0}),onClick:o},...n&&s?[{label:t(a.AUTOMATIONS$EDIT),icon:(0,q.jsx)(T,{className:`size-4`}),onClick:()=>s(e.id)}]:[],...n?[{label:e.enabled?t(a.AUTOMATIONS$TURN_OFF):t(a.AUTOMATIONS$TURN_ON),icon:(0,q.jsx)(ce,{className:`size-4`}),onClick:()=>c(e.id,e.enabled)},{label:t(a.AUTOMATIONS$DELETE),icon:(0,q.jsx)(oe,{className:`size-4`}),onClick:()=>l(e.id)}]:[]]}function _e({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onEdit:o}){let{navigate:s}=y(),{t:c}=l(`openhands`),u=W(`manage_automations`),d=e.trigger.schedule_human||e.trigger.type,f=(0,K.useMemo)(()=>J(e,d),[e,d]),p=()=>{s?.(`/automations/${e.id}`)},h=Y({automation:e,t:c,canManage:u,onRunNow:n,isRunPending:r,onView:p,onEdit:o,onToggle:t,onDelete:i}),g=()=>{p()};return(0,q.jsxs)(`div`,{role:`link`,tabIndex:0,"data-testid":`automation-card-${e.id}`,onClick:g,onKeyDown:e=>{e.key===`Enter`&&g()},className:m(`flex min-w-0 flex-col gap-3 overflow-hidden p-4 text-left`,O,M),children:[(0,q.jsxs)(`header`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,q.jsxs)(`h3`,{className:`flex items-center gap-2 truncate text-sm font-semibold text-white`,children:[e.trigger.type===`event`?(0,q.jsx)(G,{className:`size-4 shrink-0 text-muted`}):(0,q.jsx)(R,{className:`size-4 shrink-0 text-muted`}),(0,q.jsx)(`span`,{className:`truncate`,children:e.name})]}),e.prompt?(0,q.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-tertiary-light`,children:e.prompt}):null]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[u?(0,q.jsxs)(`button`,{type:`button`,"data-testid":`automation-run-now-${e.id}`,"aria-busy":r,disabled:r||!e.enabled,onClick:t=>{t.stopPropagation(),n(e.id)},className:B,children:[(0,q.jsx)(z,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),c(a.AUTOMATIONS$RUN_NOW)]}):null,(0,q.jsx)(U,{items:h})]})]}),f.length>0?(0,q.jsx)(P,{pills:f,testId:`automation-pills-${e.id}`}):null]})}var ve=`overflow-hidden rounded-md border border-[var(--oh-border)] bg-base-secondary`,ye=[`h-11`,`border-t border-[var(--oh-border)] transition-colors`].join(` `),be=`hover:bg-interactive-hover-low outline-none focus:outline-none focus-visible:outline-none focus-visible:bg-interactive-hover-low`,X=`px-3 align-middle`,xe=[ye,be,`cursor-pointer`].join(` `),Se=`openhands-automations-view`;function Ce(){return typeof window>`u`?`grid`:window.localStorage.getItem(`openhands-automations-view`)===`list`?`list`:`grid`}function we(e){window.localStorage.setItem(Se,e)}function Te({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onEdit:o}){let{navigate:s}=y(),{t:c}=l(`openhands`),u=W(`manage_automations`),d=e.trigger.schedule_human||e.trigger.type,f=(0,K.useMemo)(()=>J(e,d),[e,d]),p=()=>{s?.(`/automations/${e.id}`)},h=Y({automation:e,t:c,canManage:u,onRunNow:n,isRunPending:r,onView:p,onEdit:o,onToggle:t,onDelete:i}),g=()=>{p()};return(0,q.jsxs)(`tr`,{"data-testid":`automation-list-row-${e.id}`,onClick:g,onKeyDown:e=>{e.key===`Enter`&&g()},tabIndex:0,className:m(xe,`cursor-pointer`),children:[(0,q.jsx)(`td`,{className:X,children:(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.trigger.type===`event`?(0,q.jsx)(G,{className:`size-4 shrink-0 text-muted`}):(0,q.jsx)(R,{className:`size-4 shrink-0 text-muted`}),(0,q.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate text-sm font-medium text-white`,title:e.name,children:e.name}),f.length>0?(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(P,{pills:f,testId:`automation-pills-${e.id}`})}):null]})}),(0,q.jsx)(`td`,{className:m(`w-0 whitespace-nowrap`,X),children:(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[u?(0,q.jsx)(b,{content:c(a.AUTOMATIONS$RUN_NOW),placement:`top`,children:(0,q.jsx)(`button`,{type:`button`,"data-testid":`automation-run-now-${e.id}`,"aria-label":c(a.AUTOMATIONS$RUN_NOW),"aria-busy":r,disabled:r||!e.enabled,onClick:t=>{t.stopPropagation(),n(e.id)},className:V,children:(0,q.jsx)(z,{className:`size-4 shrink-0`,"aria-hidden":!0})})}):null,(0,q.jsx)(U,{items:h})]})})]})}function Z({title:e,count:t,automations:n,view:r,onToggle:i,onRunNow:a,runPendingId:s=null,onDelete:c,onEdit:l}){return n.length===0?null:(0,q.jsxs)(`section`,{children:[(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:e}),(0,q.jsx)(o,{count:t})]}),r===`grid`?(0,q.jsx)(`div`,{className:m(`mt-3`,A),children:(0,q.jsx)(`div`,{className:N,children:n.map(e=>(0,q.jsx)(_e,{automation:e,onToggle:i,onRunNow:a,isRunPending:s===e.id,onDelete:c,onEdit:l},e.id))})}):(0,q.jsx)(`div`,{className:m(ve,`mt-3`),children:(0,q.jsx)(`table`,{className:`w-full min-w-full [&>tbody>tr:first-child]:border-t-0`,children:(0,q.jsx)(`tbody`,{children:n.map(e=>(0,q.jsx)(Te,{automation:e,onToggle:i,onRunNow:a,isRunPending:s===e.id,onDelete:c,onEdit:l},e.id))})})})]})}var Ee=e(r(),1),Q=[{value:`grid`,icon:me,labelKey:a.AUTOMATIONS$VIEW_GRID,testId:`automations-view-toggle-grid`},{value:`list`,icon:he,labelKey:a.AUTOMATIONS$VIEW_LIST,testId:`automations-view-toggle-list`}];function De({icon:e,label:t,isSelected:n}){return(0,q.jsxs)(`span`,{className:`flex min-w-0 w-full items-center gap-2`,children:[(0,q.jsx)(`span`,{className:x,"aria-hidden":!0,children:(0,q.jsx)(e,{})}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),n?(0,q.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]})}function Oe({view:e,onChange:t,disabled:n=!1}){let{t:r}=l(`openhands`),[i,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(),u=(0,K.useRef)(null),d=(0,K.useRef)(null),f=(Q.find(t=>t.value===e)??Q[0]).icon;(0,K.useLayoutEffect)(()=>{if(!i||!u.current)return;let e=()=>{let e=u.current?.getBoundingClientRect();e&&c({position:`fixed`,zIndex:9999,top:e.bottom+4,right:window.innerWidth-e.right})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[i]),(0,K.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;u.current?.contains(t)||d.current?.contains(t)||o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let p=i&&s?(0,q.jsx)(C,{ref:d,theme:`popover`,className:`min-w-[10rem]`,children:Q.map(n=>(0,q.jsx)(`li`,{children:(0,q.jsx)(w,{testId:n.testId,onClick:()=>{t(n.value),o(!1)},className:`group`,children:(0,q.jsx)(De,{icon:n.icon,label:r(n.labelKey),isSelected:e===n.value})})},n.value))}):null;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{ref:u,type:`button`,"data-testid":`automations-view-toggle`,"aria-label":r(a.AUTOMATIONS$VIEW_MODE),"aria-haspopup":`menu`,"aria-expanded":i,"aria-disabled":n,disabled:n,onClick:()=>{n||o(e=>!e)},className:m(`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,q.jsx)(f,{className:`size-4`,"aria-hidden":!0})}),i&&s&&typeof document<`u`?Ee.createPortal((0,q.jsx)(`div`,{style:s,children:p}),document.body):null]})}function ke(){return(0,q.jsxs)(`div`,{"data-testid":`automation-card-skeleton`,className:`${O} border border-transparent p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,q.jsx)(`div`,{className:`h-5 w-40 animate-pulse rounded bg-surface-raised`}),(0,q.jsx)(`div`,{className:`h-5 w-10 animate-pulse rounded-full bg-surface-raised`})]}),(0,q.jsx)(`div`,{className:`mt-2 h-4 w-72 animate-pulse rounded bg-surface-raised`}),(0,q.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,q.jsx)(`div`,{className:`h-7 w-32 animate-pulse rounded-full bg-surface-raised`}),(0,q.jsx)(`div`,{className:`h-7 w-28 animate-pulse rounded-full bg-surface-raised`}),(0,q.jsx)(`div`,{className:`h-7 w-24 animate-pulse rounded-full bg-surface-raised`})]})]})}var Ae=e=>(0,q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,q.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m19.5 8.25-7.5 7.5-7.5-7.5`})}),je=`https://docs.openhands.dev/openhands/usage/automations/overview`;function Me({children:e}){return(0,q.jsx)(`span`,{className:`whitespace-nowrap`,children:e})}function Ne({children:e}){return(0,q.jsx)(`code`,{"data-testid":`automations-create-instructions-example`,className:m(`mx-0.5 inline-block rounded-sm border border-[var(--oh-border-subtle)]`,`bg-[var(--oh-surface-raised)] px-1.5 py-0.5 align-baseline font-mono text-[11px] text-white`),children:e})}function Pe({children:e}){return(0,q.jsx)(q.Fragment,{children:e})}var Fe={example:(0,q.jsx)(Me,{}),cmd:(0,q.jsx)(Ne,{}),punct:(0,q.jsx)(Pe,{})};function $({onLaunch:e}={}){let{t}=l(`openhands`),n=I();return(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsxs)(`p`,{className:`text-sm leading-relaxed text-tertiary-light`,children:[(0,q.jsx)(c,{ns:`openhands`,i18nKey:a.AUTOMATIONS$EMPTY_OPTION_CONVERSATION_DESC,components:Fe}),` `,t(a.AUTOMATIONS$CREATE_INSTRUCTIONS_GUIDANCE)]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,q.jsx)(`a`,{href:je,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-muted underline transition-colors hover:text-foreground`,children:t(a.AUTOMATIONS$EMPTY_LEARN_MORE)}),(0,q.jsx)(v,{type:`button`,variant:`primary`,testId:`automations-create-automation`,onClick:()=>{n(t(a.AUTOMATIONS$CREATE_AUTOMATION_PROMPT),e)},startContent:(0,q.jsx)(F,{className:`size-4`,"aria-hidden":!0}),children:t(a.AUTOMATIONS$CREATE_AUTOMATION_BUTTON)})]})]})}function Ie({collapsible:e=!1}){let{t}=l(`openhands`),[n,r]=(0,K.useState)(!e);return e?(0,q.jsxs)(`div`,{className:`w-full rounded-lg border border-[var(--oh-border)] bg-[var(--oh-surface)]`,children:[(0,q.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,q.jsx)(`span`,{className:`text-sm font-normal text-content`,children:t(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,q.jsx)(Ae,{className:m(`size-5 text-muted transition-transform`,n&&`rotate-180`)})]}),n?(0,q.jsx)(`div`,{className:`px-4 pb-4`,children:(0,q.jsx)($,{})}):null]}):(0,q.jsxs)(`div`,{className:`w-full max-w-2xl`,children:[(0,q.jsx)(`h3`,{className:`text-center text-sm font-medium text-content`,children:t(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,q.jsx)(`div`,{className:`mt-4`,children:(0,q.jsx)($,{})})]})}function Le(){let{t:e}=l(`openhands`);return(0,q.jsxs)(`div`,{"data-testid":`automations-empty`,className:j,children:[(0,q.jsx)(`p`,{className:`text-sm text-white`,children:e(a.AUTOMATIONS$EMPTY)}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-tertiary-light`,children:e(a.AUTOMATIONS$EMPTY_HINT)}),(0,q.jsx)(`div`,{className:`mt-8 flex justify-center border-t border-[var(--oh-border)] pt-8`,children:(0,q.jsx)(Ie,{})})]})}function Re({isOpen:e,onClose:t}){let{t:n}=l(`openhands`);return e?(0,q.jsx)(g,{onClose:t,"aria-label":n(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE),children:(0,q.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,q.jsx)(S,{onClose:t,testId:`add-automation-modal-close`}),(0,q.jsx)(`header`,{className:`flex-shrink-0 px-6 pb-4 pt-6`,children:(0,q.jsx)(`h2`,{id:`add-automation-modal-title`,className:m(`pr-6`,_),children:n(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)})}),(0,q.jsx)(`div`,{className:`px-6 pb-6`,children:(0,q.jsx)($,{onLaunch:t})})]})}):null}var ze=50,Be=n(function(){let{t:e}=l(`openhands`),[t,n]=(0,K.useState)(``),[r,i]=(0,K.useState)(()=>Ce()),[o,c]=(0,K.useState)(ze),[f,p]=(0,K.useState)(null),[m,g]=(0,K.useState)(null),[_,y]=(0,K.useState)(!1),b=h().backend.kind===`local`,{data:x,isLoading:S,refetch:C}=ne(),w=x?.status===`ok`,{data:T,isLoading:E,isError:D,refetch:O}=ue({limit:o,offset:0,enabled:w}),{trackPrebuiltAutomationEnabled:k}=te(),A=de(),j=fe(),M=re(),N=(0,K.useMemo)(()=>{if(!T?.automations)return[];let e=t.toLowerCase();return e?T.automations.filter(t=>t.name.toLowerCase().includes(e)||(t.prompt??``).toLowerCase().includes(e)||t.repository?.toLowerCase().includes(e)||t.model?.toLowerCase().includes(e)):T.automations},[T?.automations,t]),P=(0,K.useMemo)(()=>N.filter(e=>e.enabled),[N]),F=(0,K.useMemo)(()=>N.filter(e=>!e.enabled),[N]),I=(e,t)=>{let n=!t;if(A.mutate({id:e,enabled:n}),n){let t=T?.automations.find(t=>t.id===e);k({automationId:e,automationName:t?.name??e})}},L=t=>{M.mutate(t,{onSuccess:()=>{u(e(a.AUTOMATIONS$RUN_NOW_SUCCESS))},onError:t=>{d(ee(t)?t.response?.data?.message||t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR):t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR))}})},R=e=>{let t=T?.automations.find(t=>t.id===e);t&&p({id:e,name:t.name})},z=e=>{let t=T?.automations.find(t=>t.id===e);t&&g(t)},B=()=>{f&&(j.mutate(f.id),p(null))},V=(0,K.useCallback)(e=>{i(e),we(e)},[]),H=T?T.total>T.automations.length:!1,U=!E&&!D&&T?.automations.length===0;return S?(0,q.jsx)(`div`,{className:`min-h-full`,children:(0,q.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,q.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)}),(0,q.jsx)(`div`,{className:`mt-6 flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,q.jsx)(ke,{},`skeleton-${String(t)}`))})]})}):w?(0,q.jsx)(`div`,{className:`min-h-full`,children:(0,q.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h1`,{className:`text-xl font-semibold text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)})]}),(0,q.jsx)(v,{type:`button`,variant:`secondary`,testId:`automations-add-automation`,className:`shrink-0 whitespace-nowrap`,onClick:()=>y(!0),children:e(a.AUTOMATIONS$ADD_AUTOMATION)})]}),(0,q.jsxs)(`div`,{className:`mt-6 flex items-stretch gap-2`,children:[(0,q.jsx)(ge,{value:t,onChange:n}),(0,q.jsx)(Oe,{view:r,onChange:V,disabled:U})]}),(0,q.jsxs)(`div`,{className:`mt-6 flex flex-col gap-6`,children:[E&&(0,q.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,q.jsx)(ke,{},`skeleton-${String(t)}`))}),D&&!E&&(0,q.jsx)(ie,{onRetry:O}),U&&(0,q.jsx)(Le,{}),!E&&!D&&T&&T.automations.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Z,{title:e(a.AUTOMATIONS$ACTIVE),count:P.length,automations:P,view:r,onToggle:I,onRunNow:L,runPendingId:M.isPending?M.variables??null:null,onDelete:R,onEdit:b?z:void 0}),(0,q.jsx)(Z,{title:e(a.AUTOMATIONS$INACTIVE),count:F.length,automations:F,view:r,onToggle:I,onRunNow:L,runPendingId:M.isPending?M.variables??null:null,onDelete:R,onEdit:b?z:void 0}),H&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>c(e=>e+ze),className:`self-center rounded-lg border border-[var(--oh-border)] px-6 py-2 text-sm text-white hover:bg-surface-raised`,children:e(a.AUTOMATIONS$LOAD_MORE)})]})]}),(0,q.jsx)(`div`,{className:`mt-6`,children:(0,q.jsx)(s,{query:t})}),(0,q.jsx)(ae,{automationName:f?.name??``,isOpen:f!==null,onConfirm:B,onCancel:()=>p(null)}),m&&(0,q.jsx)(le,{automation:m,isOpen:m!==null,onClose:()=>g(null)}),(0,q.jsx)(Re,{isOpen:_,onClose:()=>y(!1)})]})}):(0,q.jsx)(`div`,{className:`min-h-full`,children:(0,q.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,q.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)}),(0,q.jsx)(se,{onRetry:C})]})})});export{Be as default};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{L as n}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-BjMt2JeR.js";import{t as r}from"./react-dom-hVBnwgwZ.js";import{o as i,t as a}from"./declaration-D9ucT0fq.js";import{n as o,t as s}from"./recommended-automations-launcher-WxaZcjRD.js";import{t as c}from"./Trans-sy4l4TyQ.js";import{t as l}from"./useTranslation-CL6FTf1b.js";import{m as u,p as d}from"./query-client-config-Ca3tW1AH.js";import{t as f}from"./createLucideIcon-CkGTf9Qj.js";import{t as p}from"./check-BhnsMsWy.js";import{t as m}from"./utils-eXk6yerZ.js";import{n as h}from"./active-backend-context-B2OSC-qe.js";import{t as g}from"./modal-backdrop-_VbcKk5K.js";import{n as _}from"./modal-classes-CNm4ovfm.js";import{t as v}from"./brand-button-9SOzmqPP.js";import{n as y}from"./navigation-context-BpAOh_t5.js";import{t as b}from"./styled-tooltip-X61SEwqk.js";import{u as x}from"./dropdown-classes-CVp0kVdt.js";import{n as ee}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~bxn4ldi1-_LydBB1e.js";import{t as S}from"./modal-close-button-Dbo0NAMt.js";import{t as te}from"./use-tracking-C9P88zSo.js";import{n as C,t as w}from"./context-menu-list-item-BQU0jZPq.js";import{t as T}from"./u-edit-DIgADxLH.js";import{t as E}from"./folder-DPTBlxWb.js";import{t as D}from"./search-C_l_XW4e.js";import{a as O,i as k,n as A,o as j,r as M,t as N}from"./extension-module-card-classes-DP5J6ngE.js";import{n as P}from"./skill-card-pill-row-DeodrwPG.js";import{n as F,t as I}from"./use-launch-skill-in-chat-BTgXIu3N.js";import{_ as ne,b as re,c as L,d as R,f as z,g as B,h as V,i as ie,l as H,m as U,n as ae,o as oe,p as W,r as se,s as ce,t as le,u as G,v as ue,x as de,y as fe}from"./edit-automation-modal-CpA_JKLY.js";var pe=f(`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`}]]),me=f(`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`}]]),he=f(`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`}]]),K=e(t(),1),q=i();function ge({value:e,onChange:t,className:n}){let{t:r}=l(`openhands`);return(0,q.jsxs)(`div`,{className:m(`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,q.jsx)(D,{className:`ml-3 size-4 shrink-0 text-tertiary-alt`,"aria-hidden":!0}),(0,q.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:r(a.AUTOMATIONS$SEARCH_PLACEHOLDER),"aria-label":r(a.AUTOMATIONS$SEARCH_PLACEHOLDER),className:`min-w-0 flex-1 border-0 bg-transparent px-3 text-sm text-white outline-none placeholder:text-tertiary-alt`})]})}function J(e,t){let n=[];if(e.repository&&n.push({id:`repository`,node:(0,q.jsxs)(`span`,{className:m(k,`gap-1`),children:[(0,q.jsx)(E,{className:`size-3 shrink-0`}),e.repository]})}),e.trigger.type===`event`){let t=[e.trigger.on?L(e.trigger.on):``,e.trigger.source?`(${e.trigger.source})`:``].filter(Boolean).join(` `);n.push({id:`event-trigger`,node:(0,q.jsxs)(`span`,{className:m(k,`gap-1`),children:[(0,q.jsx)(G,{className:`size-3 shrink-0`}),t]})})}else n.push({id:`schedule`,node:(0,q.jsxs)(`span`,{className:m(k,`gap-1`),children:[(0,q.jsx)(R,{className:`size-3 shrink-0`}),t]})});return e.model&&n.push({id:`model`,node:(0,q.jsxs)(`span`,{className:m(k,`gap-1`),children:[(0,q.jsx)(H,{className:`size-3 shrink-0`}),e.model]})}),n}function Y({automation:e,t,canManage:n,onRunNow:r,isRunPending:i,onView:o,onEdit:s,onToggle:c,onDelete:l}){return[...n?[{label:t(a.AUTOMATIONS$RUN_NOW),icon:(0,q.jsx)(z,{className:`size-4`}),onClick:()=>r(e.id),disabled:i||!e.enabled}]:[],{label:t(a.COMMON$VIEW),icon:(0,q.jsx)(pe,{className:`size-4`,"aria-hidden":!0}),onClick:o},...n&&s?[{label:t(a.AUTOMATIONS$EDIT),icon:(0,q.jsx)(T,{className:`size-4`}),onClick:()=>s(e.id)}]:[],...n?[{label:e.enabled?t(a.AUTOMATIONS$TURN_OFF):t(a.AUTOMATIONS$TURN_ON),icon:(0,q.jsx)(ce,{className:`size-4`}),onClick:()=>c(e.id,e.enabled)},{label:t(a.AUTOMATIONS$DELETE),icon:(0,q.jsx)(oe,{className:`size-4`}),onClick:()=>l(e.id)}]:[]]}function _e({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onEdit:o}){let{navigate:s}=y(),{t:c}=l(`openhands`),u=W(`manage_automations`),d=e.trigger.schedule_human||e.trigger.type,f=(0,K.useMemo)(()=>J(e,d),[e,d]),p=()=>{s?.(`/automations/${e.id}`)},h=Y({automation:e,t:c,canManage:u,onRunNow:n,isRunPending:r,onView:p,onEdit:o,onToggle:t,onDelete:i}),g=()=>{p()};return(0,q.jsxs)(`div`,{role:`link`,tabIndex:0,"data-testid":`automation-card-${e.id}`,onClick:g,onKeyDown:e=>{e.key===`Enter`&&g()},className:m(`flex min-w-0 flex-col gap-3 overflow-hidden p-4 text-left`,O,M),children:[(0,q.jsxs)(`header`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,q.jsxs)(`h3`,{className:`flex items-center gap-2 truncate text-sm font-semibold text-white`,children:[e.trigger.type===`event`?(0,q.jsx)(G,{className:`size-4 shrink-0 text-muted`}):(0,q.jsx)(R,{className:`size-4 shrink-0 text-muted`}),(0,q.jsx)(`span`,{className:`truncate`,children:e.name})]}),e.prompt?(0,q.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-tertiary-light`,children:e.prompt}):null]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[u?(0,q.jsxs)(`button`,{type:`button`,"data-testid":`automation-run-now-${e.id}`,"aria-busy":r,disabled:r||!e.enabled,onClick:t=>{t.stopPropagation(),n(e.id)},className:B,children:[(0,q.jsx)(z,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),c(a.AUTOMATIONS$RUN_NOW)]}):null,(0,q.jsx)(U,{items:h})]})]}),f.length>0?(0,q.jsx)(P,{pills:f,testId:`automation-pills-${e.id}`}):null]})}var ve=`overflow-hidden rounded-md border border-[var(--oh-border)] bg-base-secondary`,ye=[`h-11`,`border-t border-[var(--oh-border)] transition-colors`].join(` `),be=`hover:bg-interactive-hover-low outline-none focus:outline-none focus-visible:outline-none focus-visible:bg-interactive-hover-low`,X=`px-3 align-middle`,xe=[ye,be,`cursor-pointer`].join(` `),Se=`openhands-automations-view`;function Ce(){return typeof window>`u`?`grid`:window.localStorage.getItem(`openhands-automations-view`)===`list`?`list`:`grid`}function we(e){window.localStorage.setItem(Se,e)}function Te({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onEdit:o}){let{navigate:s}=y(),{t:c}=l(`openhands`),u=W(`manage_automations`),d=e.trigger.schedule_human||e.trigger.type,f=(0,K.useMemo)(()=>J(e,d),[e,d]),p=()=>{s?.(`/automations/${e.id}`)},h=Y({automation:e,t:c,canManage:u,onRunNow:n,isRunPending:r,onView:p,onEdit:o,onToggle:t,onDelete:i}),g=()=>{p()};return(0,q.jsxs)(`tr`,{"data-testid":`automation-list-row-${e.id}`,onClick:g,onKeyDown:e=>{e.key===`Enter`&&g()},tabIndex:0,className:m(xe,`cursor-pointer`),children:[(0,q.jsx)(`td`,{className:X,children:(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.trigger.type===`event`?(0,q.jsx)(G,{className:`size-4 shrink-0 text-muted`}):(0,q.jsx)(R,{className:`size-4 shrink-0 text-muted`}),(0,q.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate text-sm font-medium text-white`,title:e.name,children:e.name}),f.length>0?(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(P,{pills:f,testId:`automation-pills-${e.id}`})}):null]})}),(0,q.jsx)(`td`,{className:m(`w-0 whitespace-nowrap`,X),children:(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[u?(0,q.jsx)(b,{content:c(a.AUTOMATIONS$RUN_NOW),placement:`top`,children:(0,q.jsx)(`button`,{type:`button`,"data-testid":`automation-run-now-${e.id}`,"aria-label":c(a.AUTOMATIONS$RUN_NOW),"aria-busy":r,disabled:r||!e.enabled,onClick:t=>{t.stopPropagation(),n(e.id)},className:V,children:(0,q.jsx)(z,{className:`size-4 shrink-0`,"aria-hidden":!0})})}):null,(0,q.jsx)(U,{items:h})]})})]})}function Z({title:e,count:t,automations:n,view:r,onToggle:i,onRunNow:a,runPendingId:s=null,onDelete:c,onEdit:l}){return n.length===0?null:(0,q.jsxs)(`section`,{children:[(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:e}),(0,q.jsx)(o,{count:t})]}),r===`grid`?(0,q.jsx)(`div`,{className:m(`mt-3`,A),children:(0,q.jsx)(`div`,{className:N,children:n.map(e=>(0,q.jsx)(_e,{automation:e,onToggle:i,onRunNow:a,isRunPending:s===e.id,onDelete:c,onEdit:l},e.id))})}):(0,q.jsx)(`div`,{className:m(ve,`mt-3`),children:(0,q.jsx)(`table`,{className:`w-full min-w-full [&>tbody>tr:first-child]:border-t-0`,children:(0,q.jsx)(`tbody`,{children:n.map(e=>(0,q.jsx)(Te,{automation:e,onToggle:i,onRunNow:a,isRunPending:s===e.id,onDelete:c,onEdit:l},e.id))})})})]})}var Ee=e(r(),1),Q=[{value:`grid`,icon:me,labelKey:a.AUTOMATIONS$VIEW_GRID,testId:`automations-view-toggle-grid`},{value:`list`,icon:he,labelKey:a.AUTOMATIONS$VIEW_LIST,testId:`automations-view-toggle-list`}];function De({icon:e,label:t,isSelected:n}){return(0,q.jsxs)(`span`,{className:`flex min-w-0 w-full items-center gap-2`,children:[(0,q.jsx)(`span`,{className:x,"aria-hidden":!0,children:(0,q.jsx)(e,{})}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),n?(0,q.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]})}function Oe({view:e,onChange:t,disabled:n=!1}){let{t:r}=l(`openhands`),[i,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(),u=(0,K.useRef)(null),d=(0,K.useRef)(null),f=(Q.find(t=>t.value===e)??Q[0]).icon;(0,K.useLayoutEffect)(()=>{if(!i||!u.current)return;let e=()=>{let e=u.current?.getBoundingClientRect();e&&c({position:`fixed`,zIndex:9999,top:e.bottom+4,right:window.innerWidth-e.right})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[i]),(0,K.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;u.current?.contains(t)||d.current?.contains(t)||o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let p=i&&s?(0,q.jsx)(C,{ref:d,theme:`popover`,className:`min-w-[10rem]`,children:Q.map(n=>(0,q.jsx)(`li`,{children:(0,q.jsx)(w,{testId:n.testId,onClick:()=>{t(n.value),o(!1)},className:`group`,children:(0,q.jsx)(De,{icon:n.icon,label:r(n.labelKey),isSelected:e===n.value})})},n.value))}):null;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{ref:u,type:`button`,"data-testid":`automations-view-toggle`,"aria-label":r(a.AUTOMATIONS$VIEW_MODE),"aria-haspopup":`menu`,"aria-expanded":i,"aria-disabled":n,disabled:n,onClick:()=>{n||o(e=>!e)},className:m(`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,q.jsx)(f,{className:`size-4`,"aria-hidden":!0})}),i&&s&&typeof document<`u`?Ee.createPortal((0,q.jsx)(`div`,{style:s,children:p}),document.body):null]})}function ke(){return(0,q.jsxs)(`div`,{"data-testid":`automation-card-skeleton`,className:`${O} border border-transparent p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,q.jsx)(`div`,{className:`h-5 w-40 animate-pulse rounded bg-surface-raised`}),(0,q.jsx)(`div`,{className:`h-5 w-10 animate-pulse rounded-full bg-surface-raised`})]}),(0,q.jsx)(`div`,{className:`mt-2 h-4 w-72 animate-pulse rounded bg-surface-raised`}),(0,q.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,q.jsx)(`div`,{className:`h-7 w-32 animate-pulse rounded-full bg-surface-raised`}),(0,q.jsx)(`div`,{className:`h-7 w-28 animate-pulse rounded-full bg-surface-raised`}),(0,q.jsx)(`div`,{className:`h-7 w-24 animate-pulse rounded-full bg-surface-raised`})]})]})}var Ae=e=>(0,q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,q.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m19.5 8.25-7.5 7.5-7.5-7.5`})}),je=`https://docs.openhands.dev/openhands/usage/automations/overview`;function Me({children:e}){return(0,q.jsx)(`span`,{className:`whitespace-nowrap`,children:e})}function Ne({children:e}){return(0,q.jsx)(`code`,{"data-testid":`automations-create-instructions-example`,className:m(`mx-0.5 inline-block rounded-sm border border-[var(--oh-border-subtle)]`,`bg-[var(--oh-surface-raised)] px-1.5 py-0.5 align-baseline font-mono text-[11px] text-white`),children:e})}function Pe({children:e}){return(0,q.jsx)(q.Fragment,{children:e})}var Fe={example:(0,q.jsx)(Me,{}),cmd:(0,q.jsx)(Ne,{}),punct:(0,q.jsx)(Pe,{})};function $({onLaunch:e}={}){let{t}=l(`openhands`),n=I();return(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsxs)(`p`,{className:`text-sm leading-relaxed text-tertiary-light`,children:[(0,q.jsx)(c,{ns:`openhands`,i18nKey:a.AUTOMATIONS$EMPTY_OPTION_CONVERSATION_DESC,components:Fe}),` `,t(a.AUTOMATIONS$CREATE_INSTRUCTIONS_GUIDANCE)]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,q.jsx)(`a`,{href:je,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-muted underline transition-colors hover:text-foreground`,children:t(a.AUTOMATIONS$EMPTY_LEARN_MORE)}),(0,q.jsx)(v,{type:`button`,variant:`primary`,testId:`automations-create-automation`,onClick:()=>{n(t(a.AUTOMATIONS$CREATE_AUTOMATION_PROMPT),e)},startContent:(0,q.jsx)(F,{className:`size-4`,"aria-hidden":!0}),children:t(a.AUTOMATIONS$CREATE_AUTOMATION_BUTTON)})]})]})}function Ie({collapsible:e=!1}){let{t}=l(`openhands`),[n,r]=(0,K.useState)(!e);return e?(0,q.jsxs)(`div`,{className:`w-full rounded-lg border border-[var(--oh-border)] bg-[var(--oh-surface)]`,children:[(0,q.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,q.jsx)(`span`,{className:`text-sm font-normal text-content`,children:t(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,q.jsx)(Ae,{className:m(`size-5 text-muted transition-transform`,n&&`rotate-180`)})]}),n?(0,q.jsx)(`div`,{className:`px-4 pb-4`,children:(0,q.jsx)($,{})}):null]}):(0,q.jsxs)(`div`,{className:`w-full max-w-2xl`,children:[(0,q.jsx)(`h3`,{className:`text-center text-sm font-medium text-content`,children:t(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,q.jsx)(`div`,{className:`mt-4`,children:(0,q.jsx)($,{})})]})}function Le(){let{t:e}=l(`openhands`);return(0,q.jsxs)(`div`,{"data-testid":`automations-empty`,className:j,children:[(0,q.jsx)(`p`,{className:`text-sm text-white`,children:e(a.AUTOMATIONS$EMPTY)}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-tertiary-light`,children:e(a.AUTOMATIONS$EMPTY_HINT)}),(0,q.jsx)(`div`,{className:`mt-8 flex justify-center border-t border-[var(--oh-border)] pt-8`,children:(0,q.jsx)(Ie,{})})]})}function Re({isOpen:e,onClose:t}){let{t:n}=l(`openhands`);return e?(0,q.jsx)(g,{onClose:t,"aria-label":n(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE),children:(0,q.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,q.jsx)(S,{onClose:t,testId:`add-automation-modal-close`}),(0,q.jsx)(`header`,{className:`flex-shrink-0 px-6 pb-4 pt-6`,children:(0,q.jsx)(`h2`,{id:`add-automation-modal-title`,className:m(`pr-6`,_),children:n(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)})}),(0,q.jsx)(`div`,{className:`px-6 pb-6`,children:(0,q.jsx)($,{onLaunch:t})})]})}):null}var ze=50,Be=n(function(){let{t:e}=l(`openhands`),[t,n]=(0,K.useState)(``),[r,i]=(0,K.useState)(()=>Ce()),[o,c]=(0,K.useState)(ze),[f,p]=(0,K.useState)(null),[m,g]=(0,K.useState)(null),[_,y]=(0,K.useState)(!1),b=h().backend.kind===`local`,{data:x,isLoading:S,refetch:C}=ne(),w=x?.status===`ok`,{data:T,isLoading:E,isError:D,refetch:O}=ue({limit:o,offset:0,enabled:w}),{trackPrebuiltAutomationEnabled:k}=te(),A=de(),j=fe(),M=re(),N=(0,K.useMemo)(()=>{if(!T?.automations)return[];let e=t.toLowerCase();return e?T.automations.filter(t=>t.name.toLowerCase().includes(e)||(t.prompt??``).toLowerCase().includes(e)||t.repository?.toLowerCase().includes(e)||t.model?.toLowerCase().includes(e)):T.automations},[T?.automations,t]),P=(0,K.useMemo)(()=>N.filter(e=>e.enabled),[N]),F=(0,K.useMemo)(()=>N.filter(e=>!e.enabled),[N]),I=(e,t)=>{let n=!t;if(A.mutate({id:e,enabled:n}),n){let t=T?.automations.find(t=>t.id===e);k({automationId:e,automationName:t?.name??e})}},L=t=>{M.mutate(t,{onSuccess:()=>{u(e(a.AUTOMATIONS$RUN_NOW_SUCCESS))},onError:t=>{d(ee(t)?t.response?.data?.message||t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR):t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR))}})},R=e=>{let t=T?.automations.find(t=>t.id===e);t&&p({id:e,name:t.name})},z=e=>{let t=T?.automations.find(t=>t.id===e);t&&g(t)},B=()=>{f&&(j.mutate(f.id),p(null))},V=(0,K.useCallback)(e=>{i(e),we(e)},[]),H=T?T.total>T.automations.length:!1,U=!E&&!D&&T?.automations.length===0;return S?(0,q.jsx)(`div`,{className:`min-h-full`,children:(0,q.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,q.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)}),(0,q.jsx)(`div`,{className:`mt-6 flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,q.jsx)(ke,{},`skeleton-${String(t)}`))})]})}):w?(0,q.jsx)(`div`,{className:`min-h-full`,children:(0,q.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h1`,{className:`text-xl font-semibold text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)})]}),(0,q.jsx)(v,{type:`button`,variant:`secondary`,testId:`automations-add-automation`,className:`shrink-0 whitespace-nowrap`,onClick:()=>y(!0),children:e(a.AUTOMATIONS$ADD_AUTOMATION)})]}),(0,q.jsxs)(`div`,{className:`mt-6 flex items-stretch gap-2`,children:[(0,q.jsx)(ge,{value:t,onChange:n}),(0,q.jsx)(Oe,{view:r,onChange:V,disabled:U})]}),(0,q.jsxs)(`div`,{className:`mt-6 flex flex-col gap-6`,children:[E&&(0,q.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,q.jsx)(ke,{},`skeleton-${String(t)}`))}),D&&!E&&(0,q.jsx)(ie,{onRetry:O}),U&&(0,q.jsx)(Le,{}),!E&&!D&&T&&T.automations.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Z,{title:e(a.AUTOMATIONS$ACTIVE),count:P.length,automations:P,view:r,onToggle:I,onRunNow:L,runPendingId:M.isPending?M.variables??null:null,onDelete:R,onEdit:b?z:void 0}),(0,q.jsx)(Z,{title:e(a.AUTOMATIONS$INACTIVE),count:F.length,automations:F,view:r,onToggle:I,onRunNow:L,runPendingId:M.isPending?M.variables??null:null,onDelete:R,onEdit:b?z:void 0}),H&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>c(e=>e+ze),className:`self-center rounded-lg border border-[var(--oh-border)] px-6 py-2 text-sm text-white hover:bg-surface-raised`,children:e(a.AUTOMATIONS$LOAD_MORE)})]})]}),(0,q.jsx)(`div`,{className:`mt-6`,children:(0,q.jsx)(s,{query:t})}),(0,q.jsx)(ae,{automationName:f?.name??``,isOpen:f!==null,onConfirm:B,onCancel:()=>p(null)}),m&&(0,q.jsx)(le,{automation:m,isOpen:m!==null,onClose:()=>g(null)}),(0,q.jsx)(Re,{isOpen:_,onClose:()=>y(!1)})]})}):(0,q.jsx)(`div`,{className:`min-h-full`,children:(0,q.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,q.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)}),(0,q.jsx)(se,{onRetry:C})]})})});export{Be as default};
|