@openhands/agent-canvas 1.0.0-alpha.5 → 1.0.0-alpha.7
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 +41 -7
- package/bin/agent-canvas.mjs +9 -2
- package/build/assets/automation-detail-D7GEU0vR.js +1 -0
- package/build/assets/automations-list-CkVNsgzm.js +1 -0
- package/build/assets/conversation-COZAKz_K.js +1 -0
- package/build/assets/{conversation-D8scXOe7.js → conversation-DWcvnmds.js} +3 -1
- package/build/assets/conversation-panel-CZDStT0b.js +1 -0
- package/build/assets/conversation-websocket-context-DulnrIHh.js +3 -0
- package/build/assets/edit-automation-modal-C3bFxS2f.js +1 -0
- package/build/assets/git-control-bar-branch-button-Bm6rzSpo.js +27 -0
- package/build/assets/{home-D9fJfhQA.js → home-DR11ejqB.js} +1 -1
- package/build/assets/{manifest-f141dc70.js → manifest-f041e61a.js} +1 -1
- package/build/assets/{messages-BfaEAG2q.js → messages-v-q35ObG.js} +1 -1
- package/build/assets/{root-luPHQiBx.js → root-D2PVd51i.js} +1 -1
- package/build/assets/root-layout-B4QioBS6.js +2 -0
- package/build/assets/{shared-conversation-BfZNCsvo.js → shared-conversation-DQlzwdpo.js} +1 -1
- package/build/index.html +3 -3
- package/config/defaults.json +38 -0
- package/dist/components/features/backends/backend-selector.cjs +1 -1
- package/dist/components/features/backends/backend-selector.cjs.map +1 -1
- package/dist/components/features/backends/backend-selector.js +95 -95
- package/dist/components/features/backends/backend-selector.js.map +1 -1
- package/dist/components/features/chat/components/chat-input-actions.cjs +1 -1
- package/dist/components/features/chat/components/chat-input-actions.cjs.map +1 -1
- package/dist/components/features/chat/components/chat-input-actions.js +118 -118
- package/dist/components/features/chat/components/chat-input-actions.js.map +1 -1
- package/dist/components/features/chat/components/slash-command-menu.cjs +1 -1
- package/dist/components/features/chat/components/slash-command-menu.cjs.map +1 -1
- package/dist/components/features/chat/components/slash-command-menu.js +1 -1
- package/dist/components/features/chat/components/slash-command-menu.js.map +1 -1
- package/dist/components/features/sidebar/sidebar-rail-body.cjs +1 -1
- package/dist/components/features/sidebar/sidebar-rail-body.cjs.map +1 -1
- package/dist/components/features/sidebar/sidebar-rail-body.d.ts +1 -2
- package/dist/components/features/sidebar/sidebar-rail-body.js +104 -104
- package/dist/components/features/sidebar/sidebar-rail-body.js.map +1 -1
- package/dist/components/features/sidebar/sidebar.cjs +1 -1
- package/dist/components/features/sidebar/sidebar.cjs.map +1 -1
- package/dist/components/features/sidebar/sidebar.js +82 -83
- package/dist/components/features/sidebar/sidebar.js.map +1 -1
- package/dist/contexts/conversation-websocket-context.cjs +3 -3
- package/dist/contexts/conversation-websocket-context.cjs.map +1 -1
- package/dist/contexts/conversation-websocket-context.js +36 -36
- package/dist/contexts/conversation-websocket-context.js.map +1 -1
- package/dist/hooks/query/use-local-git-info.cjs +3 -1
- package/dist/hooks/query/use-local-git-info.cjs.map +1 -1
- package/dist/hooks/query/use-local-git-info.d.ts +2 -2
- package/dist/hooks/query/use-local-git-info.js +27 -24
- package/dist/hooks/query/use-local-git-info.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +2 -1
- package/dist/package.js.map +1 -1
- package/dist/stores/error-message-store.cjs +1 -1
- package/dist/stores/error-message-store.cjs.map +1 -1
- package/dist/stores/error-message-store.d.ts +10 -1
- package/dist/stores/error-message-store.js +16 -3
- package/dist/stores/error-message-store.js.map +1 -1
- package/package.json +2 -1
- package/scripts/dev-static.mjs +8 -1
- package/scripts/dev-with-automation.mjs +30 -49
- package/scripts/static-build.mjs +2 -6
- package/scripts/static-server.mjs +85 -4
- package/build/assets/automation-detail-ZQs6D2d3.js +0 -1
- package/build/assets/automations-list-CqHXGwSw.js +0 -1
- package/build/assets/conversation-CeGMBOyB.js +0 -1
- package/build/assets/conversation-panel-DMz46ji-.js +0 -1
- package/build/assets/conversation-websocket-context-B0Gd3yiT.js +0 -3
- package/build/assets/edit-automation-modal-DgW0Q8vr.js +0 -1
- package/build/assets/git-control-bar-branch-button-DhpPgadK.js +0 -27
- package/build/assets/root-layout-DvYGxAnr.js +0 -2
package/README.md
CHANGED
|
@@ -27,8 +27,6 @@ If you have questions or feedback, please open a GitHub issue or join the [#proj
|
|
|
27
27
|
|
|
28
28
|
## Quickstart
|
|
29
29
|
|
|
30
|
-
### Direct Install
|
|
31
|
-
|
|
32
30
|
You can install OpenHands to run agents on any machine: on your laptop, on a dedicated computer like a Mac Mini,
|
|
33
31
|
or on a server in the cloud.
|
|
34
32
|
|
|
@@ -41,13 +39,47 @@ them from the same Agent Canvas frontend. E.g. you can share an Agent Server wit
|
|
|
41
39
|
code review and dependency updates, then have your personal agents running on your laptop.
|
|
42
40
|
|
|
43
41
|
> [!WARNING]
|
|
44
|
-
> This runs the agent-server directly on the machine you're installing on
|
|
42
|
+
> This runs the agent-server directly on the machine you're installing on — the agent will have full access to your filesystem!
|
|
43
|
+
|
|
44
|
+
### Option 1: Docker
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
docker pull ghcr.io/openhands/agent-canvas:1.0.0-alpha.6
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
export PROJECTS_PATH=~/projects # directory containing your project folders
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
docker run -it --rm \
|
|
56
|
+
-p 8000:8000 \
|
|
57
|
+
-v ~/.openhands:/home/openhands/.openhands \
|
|
58
|
+
-v ${PROJECTS_PATH}:/projects \
|
|
59
|
+
ghcr.io/openhands/agent-canvas:1.0.0-alpha.6
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The agent will be able to access any project under `PROJECTS_PATH`.
|
|
45
63
|
|
|
46
|
-
|
|
64
|
+
### Option 2: NPM
|
|
47
65
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
66
|
+
**Prerequisites**: Node.js 22.12.x or later, `uv`
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
npm install -g @openhands/agent-canvas
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
export PROJECTS_PATH=~/projects # directory containing your project folders
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
agent-canvas
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Option 3: From Source
|
|
81
|
+
|
|
82
|
+
**Prerequisites**: Node.js 22.12.x or later, `npm`, `uv` (for running the agent server via `uvx`)
|
|
51
83
|
|
|
52
84
|
```sh
|
|
53
85
|
git clone https://github.com/OpenHands/agent-canvas.git
|
|
@@ -56,6 +88,8 @@ npm install
|
|
|
56
88
|
npm run dev
|
|
57
89
|
```
|
|
58
90
|
|
|
91
|
+
---
|
|
92
|
+
|
|
59
93
|
Access the UI at [http://localhost:8000](http://localhost:8000). You can add additional backends directly from the UI.
|
|
60
94
|
|
|
61
95
|
# Architecture
|
package/bin/agent-canvas.mjs
CHANGED
|
@@ -11,16 +11,22 @@
|
|
|
11
11
|
* but serves pre-built static assets instead of the Vite dev server.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { existsSync } from "node:fs";
|
|
14
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
15
15
|
import { join, dirname } from "node:path";
|
|
16
16
|
import { fileURLToPath } from "node:url";
|
|
17
17
|
|
|
18
18
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const PKG_JSON = join(__dirname, "..", "package.json");
|
|
19
20
|
// Build output is in build/ (not build/client/) - see react-router.config.ts unpackClientDirectory
|
|
20
21
|
const BUILD_DIR = join(__dirname, "..", "build");
|
|
21
22
|
|
|
22
|
-
// Check for help
|
|
23
|
+
// Check for version/help flags first
|
|
23
24
|
const args = process.argv.slice(2);
|
|
25
|
+
if (args.includes("-v") || args.includes("--version")) {
|
|
26
|
+
const { version } = JSON.parse(readFileSync(PKG_JSON, "utf-8"));
|
|
27
|
+
console.log(version);
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
24
30
|
if (args.includes("-h") || args.includes("--help")) {
|
|
25
31
|
console.log(`
|
|
26
32
|
@openhands/agent-canvas - Run the Agent Canvas UI with agent-server
|
|
@@ -33,6 +39,7 @@ USAGE:
|
|
|
33
39
|
|
|
34
40
|
OPTIONS:
|
|
35
41
|
-p, --port <port> Ingress port (default: 8000)
|
|
42
|
+
-v, --version Show version number
|
|
36
43
|
-h, --help Show this help message
|
|
37
44
|
|
|
38
45
|
ENVIRONMENT VARIABLES:
|
|
@@ -0,0 +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-DTEXlLSB.js";import{t as i}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~kyz9p27j-DlKA6SoO.js";import{o as a,t as o}from"./declaration-C9nuq2Dj.js";import{t as s}from"./useTranslation-01pF7z10.js";import{n as c,r as l}from"./custom-toast-handlers-BYxhSr3t.js";import{t as u}from"./utils-Czcl6buL.js";import{c as d,i as f,t as p}from"./agent-server-client-options-8OJSXbm8.js";import{n as m}from"./active-backend-context-CkP3ZEJs.js";import{d as h}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-BJm2mGIp.js";import{n as g}from"./navigation-context-BFjstyH6.js";import{t as _}from"./navigation-link-DFQ7YcWq.js";import{n as v,r as y}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~pfbaerbd-zhv9fooy.js";import{t as b}from"./proxy-BMZyC45G.js";import{t as x}from"./u-edit-BPFJBd34.js";import{t as S}from"./terminal-DGuR4559.js";import{t as C}from"./use-user-conversation-BCYpbPT1.js";import{t as w}from"./toggle-switch-gj6T-wsU.js";import{t as T}from"./x-mark-CZ57VvRX.js";import{t as E}from"./clock-DfoVUZVq.js";import{_ as ee,a as D,b as O,c as k,g as te,h as A,i as ne,l as j,n as re,o as M,p as ie,r as ae,s as N,t as oe,u as P,v as se,y as ce}from"./edit-automation-modal-C3bFxS2f.js";import{t as F}from"./automation-XLxhq3I8.js";var I=e(t()),L=a(),le=e=>(0,L.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,L.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15.75 19.5 8.25 12l7.5-7.5`})});function R(){let{t:e}=s(`openhands`);return(0,L.jsxs)(_,{to:`/automations`,className:`inline-flex items-center gap-1.5 text-sm text-muted hover:text-foreground`,children:[(0,L.jsx)(le,{className:`size-4`}),e(o.AUTOMATIONS$DETAIL$BACK_TO_LIST)]})}var ue=e=>(0,L.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,L.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 z({active:e}){let{t}=s(`openhands`);return(0,L.jsx)(`span`,{"data-testid":e?`active-status-badge-active`:`active-status-badge-inactive`,className:u(`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?o.AUTOMATIONS$DETAIL$ACTIVE:o.AUTOMATIONS$DETAIL$INACTIVE)})}function B({automation:e,onToggle:t,onEdit:n,onDelete:r,onRunNow:i,isRunningNow:a=!1}){let{t:c}=s(`openhands`),l=j(`manage_automations`),u=[...n?[{label:c(o.AUTOMATIONS$EDIT),icon:(0,L.jsx)(x,{className:`size-4`}),onClick:n}]:[],{label:e.enabled?c(o.AUTOMATIONS$TURN_OFF):c(o.AUTOMATIONS$TURN_ON),icon:(0,L.jsx)(N,{className:`size-4`}),onClick:t},{label:c(o.AUTOMATIONS$DOWNLOAD_TARBALL),icon:(0,L.jsx)(ue,{className:`size-4`}),onClick:()=>{O.downloadTarball(e.id,e.name)}},{label:c(o.AUTOMATIONS$DELETE),icon:(0,L.jsx)(M,{className:`size-4`}),onClick:r}];return(0,L.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,L.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e.name}),(0,L.jsx)(z,{active:e.enabled})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l&&i&&(0,L.jsx)(`button`,{type:`button`,className:`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:a||!e.enabled,onClick:i,children:a?`Starting…`:`Run now`}),l&&(0,L.jsx)(w,{enabled:e.enabled,label:e.enabled?c(o.AUTOMATIONS$TURN_OFF):c(o.AUTOMATIONS$TURN_ON),onToggle:t}),l&&(0,L.jsx)(P,{items:u})]})]})})}function V({icon:e,title:t,children:n}){return(0,L.jsxs)(`div`,{className:`rounded-2xl border border-[var(--oh-border)] bg-[var(--oh-surface)]`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--oh-border)] px-5 py-3`,children:[(0,L.jsx)(`span`,{className:`size-4 text-muted`,children:e}),(0,L.jsx)(`h3`,{className:`text-sm font-medium text-content`,children:t})]}),(0,L.jsx)(`div`,{className:`px-5 py-5`,children:n})]})}function H({prompt:e}){let{t}=s(`openhands`);return(0,L.jsx)(V,{icon:(0,L.jsx)(S,{className:`size-4`}),title:t(o.AUTOMATIONS$DETAIL$PROMPT),children:(0,L.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6 text-content`,children:e})})}var U=e=>(0,L.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:[(0,L.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,L.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z`})]}),de=e=>(0,L.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:[(0,L.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,L.jsx)(`circle`,{cx:6,cy:3,r:2}),(0,L.jsx)(`circle`,{cx:18,cy:3,r:2}),(0,L.jsx)(`circle`,{cx:9,cy:18,r:2})]}),W=e=>(0,L.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,L.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`})}),G=e=>(0,L.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,L.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`})}),fe=e=>(0,L.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,L.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 K({icon:e,label:t,children:n}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`size-3.5 text-muted`,children:e}),(0,L.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:t})]}),(0,L.jsx)(`div`,{className:`text-sm text-content`,children:n})]})}function pe({branch:e}){return(0,L.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})}function me({automation:e}){let{t}=s(`openhands`),n=e.trigger.schedule??``;e.trigger.schedule_human&&(n=e.timezone?`${e.trigger.schedule_human} (${e.timezone})`:e.trigger.schedule_human);let r=e.trigger.type===`cron`?`Schedule`:e.trigger.type;return(0,L.jsx)(V,{icon:(0,L.jsx)(U,{className:`size-4`}),title:t(o.AUTOMATIONS$DETAIL$CONFIGURATION),children:(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-5`,children:[e.repository&&(0,L.jsx)(K,{icon:(0,L.jsx)(de,{className:`size-3.5`}),label:t(o.AUTOMATIONS$DETAIL$REPOSITORIES),children:(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e.repository,e.branch&&(0,L.jsx)(pe,{branch:e.branch})]})}),(0,L.jsx)(K,{icon:(0,L.jsx)(W,{className:`size-3.5`}),label:t(o.AUTOMATIONS$DETAIL$TRIGGER),children:r}),(0,L.jsx)(K,{icon:(0,L.jsx)(G,{className:`size-3.5`}),label:t(o.AUTOMATIONS$DETAIL$SCHEDULE),children:n}),(0,L.jsx)(K,{icon:(0,L.jsx)(k,{className:`size-3.5`}),label:t(o.AUTOMATIONS$DETAIL$MODEL),children:e.model??`Active profile`}),e.notification&&(0,L.jsx)(K,{icon:(0,L.jsx)(fe,{className:`size-3.5`}),label:t(o.AUTOMATIONS$DETAIL$NOTIFICATION),children:e.notification})]})})}var he=e=>(0,L.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,L.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 q({name:e}){return(0,L.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 ge({plugins:e}){let{t}=s(`openhands`);return(0,L.jsx)(V,{icon:(0,L.jsx)(he,{className:`size-4`}),title:t(o.AUTOMATIONS$DETAIL$PLUGINS),children:(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,L.jsx)(q,{name:e},e))})})}var J=e=>(0,L.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,L.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 Y(e,t){return new Date(e).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`})}function _e(e,t,n){let r=Date.now()-new Date(e).getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5),s=Math.floor(r/864e5);return i<1?n(o.AUTOMATIONS$DETAIL$TIME_JUST_NOW):i<60?n(o.AUTOMATIONS$DETAIL$TIME_MINUTES_AGO,{count:i}):a<24?n(o.AUTOMATIONS$DETAIL$TIME_HOURS_AGO,{count:a}):s===1?n(o.AUTOMATIONS$DETAIL$TIME_YESTERDAY):s<7?n(o.AUTOMATIONS$DETAIL$TIME_DAYS_AGO,{count:s}):Y(e,t)}function ve({createdAt:e,lastRunAt:t}){let{t:n,i18n:r}=s(`openhands`),i=r.language;return(0,L.jsx)(V,{icon:(0,L.jsx)(J,{className:`size-4`}),title:n(o.AUTOMATIONS$DETAIL$ACTIVITY),children:(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4`,children:[(0,L.jsx)(K,{icon:(0,L.jsx)(G,{className:`size-3.5`}),label:n(o.AUTOMATIONS$DETAIL$CREATED),children:Y(e,i)}),(0,L.jsx)(K,{icon:(0,L.jsx)(E,{className:`size-3.5`}),label:n(o.AUTOMATIONS$DETAIL$LAST_RUN),children:t?_e(t,i,n):n(o.AUTOMATIONS$DETAIL$TIME_NEVER)})]})})}var ye=e=>(0,L.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,L.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`})}),be={[F.COMPLETED]:{label:o.AUTOMATIONS$DETAIL$SUCCESSFUL,style:`border-[var(--oh-success)]/50 bg-[var(--oh-success)]/10 text-[var(--oh-success)]`},[F.FAILED]:{label:o.AUTOMATIONS$DETAIL$FAILED,style:`border-[var(--oh-danger)]/50 bg-[var(--oh-danger)]/10 text-danger`},[F.PENDING]:{label:o.AUTOMATIONS$DETAIL$PENDING,style:`border-[var(--oh-border)] bg-surface-raised text-muted`},[F.RUNNING]:{label:o.AUTOMATIONS$DETAIL$RUNNING,style:`border-[var(--oh-border)] bg-surface-raised text-muted`}};function xe({status:e}){switch(e){case F.COMPLETED:return(0,L.jsx)(W,{"data-testid":`run-status-icon-completed`,className:`size-3.5`});case F.FAILED:return(0,L.jsx)(ye,{"data-testid":`run-status-icon-failed`,className:`size-3.5`});default:return(0,L.jsx)(E,{"data-testid":`run-status-icon-pending`,className:`size-3.5`})}}function Se({status:e}){let{t}=s(`openhands`),n=be[e];return(0,L.jsxs)(`span`,{className:u(`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium`,n.style),children:[(0,L.jsx)(xe,{status:e}),t(n.label)]})}var Ce=20;function we(e){return e.kind===`BashOutput`}var Te=class e{static async listOutputs(t,n,r){let i=[],a;for(let o=0;o<Ce;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=>{we(e)&&i.push(e)}),!o.next_page_id)break;a=o.next_page_id}return i}static async searchEvents(e,t,n){let r=d().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))}),b({backend:r,method:`GET`,hostOverride:f(e),path:`/api/bash/bash_events/search?${i.toString()}`,authMode:`session-api-key`,sessionApiKey:t})}return new h(p({...e?{conversationUrl:e}:{},sessionApiKey:t})).searchEvents(n)}},Ee=[`bash-command-logs`];function De(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 Oe(e){if(!y.isAxiosError(e))return null;if(!e.response)return`unreachable`;let t=e.response.status;return t===404||t>=500?`unreachable`:null}function ke(e){let{conversationId:t,bashCommandId:n,enabled:r=!0}=e,a=m(),o=C(t??null),s=o.data,c=s?.conversation_url??null,l=s?.session_api_key??null,u=a.backend.kind===`cloud`,d=o.isFetched,f=null,p=!1;u&&d&&(s?f=De(s.sandbox_status)??(s.conversation_url?null:`missing`):p=!0);let h=r&&!!n&&(u?!!c:!0)&&!f&&!p,g=i({queryKey:[...Ee,n,c,l,a.backend.id,a.orgId],queryFn:()=>Te.listOutputs(c,l,n),enabled:h,staleTime:60*1e3,gcTime:300*1e3,retry:!1}),_=u?Oe(g.error):null,v=f??_;return{data:g.data,error:_?null:g.error,isFetching:g.isFetching,isPending:g.isPending,isResolvingConversation:u&&o.isPending,conversationMissing:p,sandboxIssue:v}}var Ae={missing:o.AUTOMATIONS$DETAIL$LOGS_SANDBOX_MISSING,paused:o.AUTOMATIONS$DETAIL$LOGS_SANDBOX_PAUSED,starting:o.AUTOMATIONS$DETAIL$LOGS_SANDBOX_STARTING,errored:o.AUTOMATIONS$DETAIL$LOGS_SANDBOX_ERROR,unreachable:o.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 je({conversationId:e,bashCommandId:t,isOpen:n,onClose:r}){let{t:i}=s(`openhands`),[a,c]=(0,I.useState)(`stdout`),{data:l,isFetching:u,isResolvingConversation:d,sandboxIssue:f,conversationMissing:p,error:m}=ke({conversationId:e,bashCommandId:t,enabled:n});(0,I.useEffect)(()=>{n&&c(`stdout`)},[n,t]),(0,I.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r]);let{stdout:h,stderr:g}=(0,I.useMemo)(()=>l?{stdout:X(l,`stdout`),stderr:X(l,`stderr`)}:{stdout:``,stderr:``},[l]);if(!n)return null;let _=d||u&&!l,v=!t,y=a===`stdout`?h:g,b=`border-b-2 px-3 py-2 text-sm font-normal transition-colors focus:outline-none`,x=`border-[var(--oh-primary)] text-white`,S=`border-transparent text-muted hover:text-content`;return(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,role:`dialog`,"aria-modal":`true`,"aria-label":i(o.AUTOMATIONS$DETAIL$LOGS_TITLE),children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:r,onKeyDown:e=>{e.key===`Escape`&&r()},role:`presentation`}),(0,L.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,L.jsx)(`button`,{type:`button`,onClick:r,className:`absolute right-4 top-4 text-muted hover:text-foreground`,"aria-label":i(o.AUTOMATIONS$CANCEL),children:(0,L.jsx)(T,{className:`size-5`})}),(0,L.jsx)(`h2`,{className:`pr-8 text-lg font-medium text-white`,children:i(o.AUTOMATIONS$DETAIL$LOGS_TITLE)}),(0,L.jsxs)(`div`,{role:`tablist`,"aria-label":i(o.AUTOMATIONS$DETAIL$LOGS_TITLE),className:`mt-4 flex gap-1 border-b border-[var(--oh-border)]`,children:[(0,L.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":a===`stdout`,"aria-controls":`run-logs-panel-stdout`,id:`run-logs-tab-stdout`,tabIndex:a===`stdout`?0:-1,onClick:()=>c(`stdout`),className:`${b} ${a===`stdout`?x:S}`,children:i(o.AUTOMATIONS$DETAIL$LOGS_TAB_OUTPUT)}),(0,L.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":a===`stderr`,"aria-controls":`run-logs-panel-stderr`,id:`run-logs-tab-stderr`,tabIndex:a===`stderr`?0:-1,onClick:()=>c(`stderr`),className:`${b} ${a===`stderr`?x:S}`,children:i(o.AUTOMATIONS$DETAIL$LOGS_TAB_ERROR)})]}),(0,L.jsxs)(`div`,{role:`tabpanel`,id:`run-logs-panel-${a}`,"aria-labelledby":`run-logs-tab-${a}`,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:[v&&(0,L.jsx)(`p`,{className:`text-muted italic`,children:i(o.AUTOMATIONS$DETAIL$LOGS_NO_COMMAND)}),!v&&p&&(0,L.jsx)(`p`,{className:`text-muted italic`,children:i(o.AUTOMATIONS$DETAIL$LOGS_CONVERSATION_MISSING)}),!v&&!p&&f&&(0,L.jsx)(`p`,{"data-testid":`run-logs-sandbox-issue-${f}`,className:`text-muted italic`,children:i(Ae[f])}),!v&&!p&&!f&&_&&(0,L.jsx)(`p`,{className:`text-muted italic`,children:i(o.AUTOMATIONS$DETAIL$LOGS_LOADING)}),!v&&!p&&!f&&!_&&m&&!l&&(0,L.jsxs)(`p`,{className:`text-danger`,children:[i(o.AUTOMATIONS$DETAIL$LOGS_ERROR),`: `,String(m)]}),!_&&!f&&l&&(0,L.jsx)(`pre`,{"data-testid":`run-logs-output-${a}`,className:`whitespace-pre-wrap break-words ${a===`stderr`?`text-danger`:`text-content`}`,children:y.length>0?y:(0,L.jsx)(`span`,{className:`text-muted italic`,children:i(o.AUTOMATIONS$DETAIL$LOGS_EMPTY)})})]})]})]})}function Me(e,t){return new Date(e).toLocaleDateString(t,{weekday:`long`,year:`numeric`,month:`long`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function Ne(e){if(!e)return!0;let t=new Date(e).getTime();return Number.isNaN(t)||t===0}function Pe(e){return`/conversations/${e}`}function Fe({run:e}){let{t,i18n:n}=s(`openhands`),r=!!e.conversation_id,i=!!e.bash_command_id,[a,c]=(0,I.useState)(!1),[l]=(0,I.useState)(()=>new Date().toISOString()),u=Me(Ne(e.started_at)?l:e.started_at,n.language),d=i?(0,L.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),e.preventDefault(),c(!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(o.AUTOMATIONS$DETAIL$LOGS_VIEW,{timestamp:u}),title:t(o.AUTOMATIONS$DETAIL$LOGS_VIEW_SHORT),children:(0,L.jsx)(S,{className:`size-4`})}):null,f=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`text-sm text-content`,children:u}),!r&&(0,L.jsxs)(`span`,{className:`text-xs text-muted italic`,children:[`(`,t(o.AUTOMATIONS$DETAIL$NO_CONVERSATION),`)`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[d,(0,L.jsx)(Se,{status:e.status})]})]});return(0,L.jsxs)(L.Fragment,{children:[r&&e.conversation_id?(0,L.jsx)(`a`,{href:Pe(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 ${u}`,children:f}):(0,L.jsx)(`div`,{className:`flex items-center justify-between px-5 py-3 cursor-default`,children:f}),i&&(0,L.jsx)(je,{conversationId:e.conversation_id,bashCommandId:e.bash_command_id,isOpen:a,onClose:()=>c(!1)})]})}var Z=20;function Ie({automationId:e}){let{t}=s(`openhands`),[n,r]=(0,I.useState)(Z),{data:i,isLoading:a}=ce({id:e,limit:n,offset:0}),c=i?i.total>i.runs.length:!1;return(0,L.jsxs)(`div`,{className:`rounded-2xl border border-[var(--oh-border)] bg-[var(--oh-surface)]`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--oh-border)] px-5 py-3`,children:[(0,L.jsx)(`span`,{className:`size-4 text-muted`,children:(0,L.jsx)(J,{className:`size-4`})}),(0,L.jsx)(`h3`,{className:`text-sm font-medium text-content`,children:t(o.AUTOMATIONS$DETAIL$ACTIVITY_LOG)})]}),a&&(0,L.jsx)(`div`,{className:`space-y-1 p-5`,children:Array.from({length:3}).map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between py-3`,children:[(0,L.jsx)(`div`,{className:`h-5 w-64 animate-pulse rounded bg-surface-raised`}),(0,L.jsx)(`div`,{className:`h-6 w-24 animate-pulse rounded-full bg-surface-raised`})]},`skeleton-${t}`))}),!a&&i?.runs.length===0&&(0,L.jsx)(`p`,{className:`px-5 py-8 text-center text-sm text-muted`,children:t(o.AUTOMATIONS$DETAIL$NO_RUNS)}),!a&&i&&i.runs.length>0&&(0,L.jsxs)(`div`,{children:[i.runs.map((e,t)=>(0,L.jsx)(`div`,{className:t>0?`border-t border-[var(--oh-border)]`:``,children:(0,L.jsx)(Fe,{run:e})},e.id)),c&&(0,L.jsx)(`div`,{className:`border-t border-[var(--oh-border)] px-5 py-3`,children:(0,L.jsx)(`button`,{type:`button`,onClick:()=>r(e=>e+Z),className:`text-sm text-muted hover:text-foreground`,children:t(o.AUTOMATIONS$DETAIL$LOAD_MORE_RUNS)})})]})]})}function Q({className:e}){return(0,L.jsx)(`div`,{className:u(`animate-pulse rounded bg-surface-raised`,e)})}function $(){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,"data-testid":`detail-skeleton`,children:[(0,L.jsx)(Q,{className:`h-5 w-40`}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(Q,{className:`h-6 w-48`}),(0,L.jsx)(Q,{className:`h-6 w-16 rounded-full`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Q,{className:`h-6 w-11 rounded-full`}),(0,L.jsx)(Q,{className:`h-8 w-8`})]})]}),(0,L.jsx)(Q,{className:`h-5 w-96`}),(0,L.jsx)(Q,{className:`h-36 w-full rounded-2xl`}),(0,L.jsx)(Q,{className:`h-72 w-full rounded-2xl`}),(0,L.jsx)(Q,{className:`h-32 w-full rounded-2xl`}),(0,L.jsx)(Q,{className:`h-40 w-full rounded-2xl`})]})}function Le(){let{t:e}=s(`openhands`);return(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20`,children:[(0,L.jsx)(D,{className:`size-12 text-muted`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-content`,children:e(o.AUTOMATIONS$DETAIL$NOT_FOUND_TITLE)}),(0,L.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:e(o.AUTOMATIONS$DETAIL$NOT_FOUND_MESSAGE)}),(0,L.jsx)(`div`,{className:`mt-6`,children:(0,L.jsx)(R,{})})]})}var Re=n(function(){let{t:e}=s(`openhands`),{automationId:t}=r(),{navigate:n}=g(),[i,a]=(0,I.useState)(!1),[u,d]=(0,I.useState)(!1),{data:f,isLoading:p,refetch:h}=ie(),_=f?.status===`ok`,y=m(),b=(0,I.useRef)(y.backend.id).current!==y.backend.id,{data:x,isLoading:S,isError:C,error:w,refetch:T}=se({id:t??``,enabled:_&&!b}),E=ee(),D=A(),O=te(),k=C&&v(w)&&w.response?.status===404;if(p)return(0,L.jsx)(`div`,{className:`min-h-full`,children:(0,L.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,L.jsx)($,{})})});if(!_)return(0,L.jsx)(`div`,{className:`min-h-full`,children:(0,L.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,L.jsx)(ae,{onRetry:h})})});if(S)return(0,L.jsx)(`div`,{className:`min-h-full`,children:(0,L.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,L.jsx)($,{})})});if(k)return(0,L.jsx)(`div`,{className:`min-h-full`,children:(0,L.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,L.jsx)(Le,{})})});if(C||!x)return(0,L.jsx)(`div`,{className:`min-h-full`,children:(0,L.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,L.jsx)(ne,{onRetry:()=>T()})})});let j=()=>{E.mutate({id:x.id,enabled:!x.enabled})},M=()=>{D.mutate(x.id,{onSuccess:()=>{n?.(`/automations`)}})},N=()=>{O.mutate(x.id,{onSuccess:()=>{l(e(o.AUTOMATIONS$RUN_NOW_SUCCESS))},onError:t=>{c(v(t)?t.response?.data?.message||t.message||e(o.AUTOMATIONS$RUN_NOW_ERROR):t.message||e(o.AUTOMATIONS$RUN_NOW_ERROR))}})},P=y.backend.kind===`local`;return(0,L.jsx)(`div`,{className:`min-h-full`,children:(0,L.jsx)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(R,{}),(0,L.jsx)(B,{automation:x,onToggle:j,onEdit:P?()=>d(!0):void 0,onDelete:()=>a(!0),onRunNow:N,isRunningNow:O.isPending}),x.prompt&&(0,L.jsx)(H,{prompt:x.prompt}),(0,L.jsx)(me,{automation:x}),x.plugins&&x.plugins.length>0&&(0,L.jsx)(ge,{plugins:x.plugins}),(0,L.jsx)(ve,{createdAt:x.created_at,lastRunAt:x.last_triggered_at}),(0,L.jsx)(Ie,{automationId:x.id}),(0,L.jsx)(re,{automationName:x.name,isOpen:i,onConfirm:M,onCancel:()=>a(!1)}),P&&(0,L.jsx)(oe,{automation:x,isOpen:u,onClose:()=>d(!1)})]})})})});export{Re as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{L as n}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{t as r}from"./react-dom-hVBnwgwZ.js";import{o as i,t as a}from"./declaration-C9nuq2Dj.js";import{t as o}from"./Trans-D43bd3yR.js";import{t as s}from"./useTranslation-01pF7z10.js";import{t as c}from"./createLucideIcon-Ddu8jDOQ.js";import{t as l}from"./check-CYxAHs85.js";import{n as u,r as d}from"./custom-toast-handlers-BYxhSr3t.js";import{a as f,c as p,i as m,o as h,r as g,s as _}from"./circle-plus-check-toggle-DRvuu-RD.js";import{t as v}from"./utils-Czcl6buL.js";import{n as ee}from"./active-backend-context-CkP3ZEJs.js";import{t as y}from"./modal-backdrop-B04pVYAD.js";import{t as b}from"./brand-button-8fVVei4i.js";import{n as x}from"./navigation-context-BFjstyH6.js";import{t as S}from"./styled-tooltip-Awq4HMw3.js";import{n as te}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~pfbaerbd-zhv9fooy.js";import{t as C}from"./modal-close-button-SM_WXzDY.js";import{n as w,t as T}from"./context-menu-list-item-DzjPB8aC.js";import{t as E}from"./u-edit-BPFJBd34.js";import{t as D}from"./folder-CerIk8uG.js";import{t as O}from"./search-BCAF9EDS.js";import{n as k,t as ne}from"./recommended-automations-launcher-Cx7svuGE.js";import{n as A}from"./skill-card-pill-row-D0oTWx-a.js";import{t as j}from"./clock-DfoVUZVq.js";import{n as M,t as N}from"./use-launch-skill-in-chat-DOyQsXFO.js";import{_ as re,c as P,d as F,f as I,g as ie,h as ae,i as oe,l as L,m as se,n as ce,o as R,p as le,r as ue,s as z,t as de,u as B}from"./edit-automation-modal-C3bFxS2f.js";var fe=c(`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`}]]),V=c(`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`}]]),pe=c(`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`}]]),H=e(t()),U=i();function me({value:e,onChange:t,className:n}){let{t:r}=s(`openhands`);return(0,U.jsxs)(`div`,{className:v(`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,U.jsx)(O,{className:`ml-3 size-4 shrink-0 text-tertiary-alt`,"aria-hidden":!0}),(0,U.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`})]})}var W=e=>(0,U.jsxs)(`svg`,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,U.jsx)(`g`,{clipPath:`url(#clip0_8467_30872)`,children:(0,U.jsx)(`path`,{d:`M6.26693 21.4874L6.25583 21.4951L6.24514 21.5033C5.95991 21.7227 5.5 21.5308 5.5 21.0996V2.89961C5.5 2.4684 5.95991 2.2765 6.24514 2.49592L6.25634 2.50452L6.26799 2.51249L19.518 11.5625L19.518 11.5625L19.5226 11.5656C19.8258 11.7677 19.8258 12.1815 19.5226 12.3836L19.5226 12.3835L19.5169 12.3874L6.26693 21.4874Z`,fill:`currentColor`,stroke:`currentColor`})}),(0,U.jsx)(`defs`,{children:(0,U.jsx)(`clipPath`,{id:`clip0_8467_30872`,children:(0,U.jsx)(`rect`,{width:24,height:24,fill:`white`})})})]});function G(e,t){let n=[];return e.repository&&n.push({id:`repository`,node:(0,U.jsxs)(`span`,{className:v(h,`gap-1`),children:[(0,U.jsx)(D,{className:`size-3 shrink-0`}),e.repository]})}),n.push({id:`schedule`,node:(0,U.jsxs)(`span`,{className:v(h,`gap-1`),children:[(0,U.jsx)(j,{className:`size-3 shrink-0`}),t]})}),e.model&&n.push({id:`model`,node:(0,U.jsxs)(`span`,{className:v(h,`gap-1`),children:[(0,U.jsx)(P,{className:`size-3 shrink-0`}),e.model]})}),n}function K({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,U.jsx)(W,{className:`size-4`}),onClick:()=>r(e.id),disabled:i||!e.enabled}]:[],{label:t(a.COMMON$VIEW),icon:(0,U.jsx)(fe,{className:`size-4`,"aria-hidden":!0}),onClick:o},...n&&s?[{label:t(a.AUTOMATIONS$EDIT),icon:(0,U.jsx)(E,{className:`size-4`}),onClick:()=>s(e.id)}]:[],...n?[{label:e.enabled?t(a.AUTOMATIONS$TURN_OFF):t(a.AUTOMATIONS$TURN_ON),icon:(0,U.jsx)(z,{className:`size-4`}),onClick:()=>c(e.id,e.enabled)},{label:t(a.AUTOMATIONS$DELETE),icon:(0,U.jsx)(R,{className:`size-4`}),onClick:()=>l(e.id)}]:[]]}function he({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onEdit:o}){let{navigate:c}=x(),{t:l}=s(`openhands`),u=L(`manage_automations`),d=e.trigger.schedule_human||e.trigger.type,p=(0,H.useMemo)(()=>G(e,d),[e,d]),m=()=>{c?.(`/automations/${e.id}`)},h=K({automation:e,t:l,canManage:u,onRunNow:n,isRunPending:r,onView:m,onEdit:o,onToggle:t,onDelete:i}),g=()=>{m()};return(0,U.jsxs)(`div`,{role:`link`,tabIndex:0,"data-testid":`automation-card-${e.id}`,onClick:g,onKeyDown:e=>{e.key===`Enter`&&g()},className:v(`flex min-w-0 flex-col gap-3 overflow-hidden p-4 text-left`,_,f),children:[(0,U.jsxs)(`header`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,U.jsx)(`h3`,{className:`truncate text-sm font-semibold text-white`,children:e.name}),e.prompt?(0,U.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-tertiary-light`,children:e.prompt}):null]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[u?(0,U.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:I,children:[(0,U.jsx)(W,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),l(a.AUTOMATIONS$RUN_NOW)]}):null,(0,U.jsx)(B,{items:h})]})]}),p.length>0?(0,U.jsx)(A,{pills:p,testId:`automation-pills-${e.id}`}):null]})}var ge=`overflow-hidden rounded-md border border-[var(--oh-border)] bg-base-secondary`,q=[`h-11`,`border-t border-[var(--oh-border)] transition-colors`].join(` `),_e=`hover:bg-interactive-hover-low outline-none focus:outline-none focus-visible:outline-none focus-visible:bg-interactive-hover-low`,J=`px-3 align-middle`,ve=[q,_e,`cursor-pointer`].join(` `),ye=`openhands-automations-view`;function be(){return typeof window>`u`?`grid`:window.localStorage.getItem(`openhands-automations-view`)===`list`?`list`:`grid`}function xe(e){window.localStorage.setItem(ye,e)}function Se({automation:e,onToggle:t,onRunNow:n,isRunPending:r=!1,onDelete:i,onEdit:o}){let{navigate:c}=x(),{t:l}=s(`openhands`),u=L(`manage_automations`),d=e.trigger.schedule_human||e.trigger.type,f=(0,H.useMemo)(()=>G(e,d),[e,d]),p=()=>{c?.(`/automations/${e.id}`)},m=K({automation:e,t:l,canManage:u,onRunNow:n,isRunPending:r,onView:p,onEdit:o,onToggle:t,onDelete:i}),h=()=>{p()};return(0,U.jsxs)(`tr`,{"data-testid":`automation-list-row-${e.id}`,onClick:h,onKeyDown:e=>{e.key===`Enter`&&h()},tabIndex:0,className:v(ve,`cursor-pointer`),children:[(0,U.jsx)(`td`,{className:J,children:(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,U.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,U.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,U.jsx)(A,{pills:f,testId:`automation-pills-${e.id}`})}):null]})}),(0,U.jsx)(`td`,{className:v(`w-0 whitespace-nowrap`,J),children:(0,U.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[u?(0,U.jsx)(S,{content:l(a.AUTOMATIONS$RUN_NOW),placement:`top`,children:(0,U.jsx)(`button`,{type:`button`,"data-testid":`automation-run-now-${e.id}`,"aria-label":l(a.AUTOMATIONS$RUN_NOW),"aria-busy":r,disabled:r||!e.enabled,onClick:t=>{t.stopPropagation(),n(e.id)},className:F,children:(0,U.jsx)(W,{className:`size-4 shrink-0`,"aria-hidden":!0})})}):null,(0,U.jsx)(B,{items:m})]})})]})}function Y({title:e,count:t,automations:n,view:r,onToggle:i,onRunNow:a,runPendingId:o=null,onDelete:s,onEdit:c}){return n.length===0?null:(0,U.jsxs)(`section`,{children:[(0,U.jsxs)(`div`,{className:`flex items-center`,children:[(0,U.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:e}),(0,U.jsx)(k,{count:t})]}),r===`grid`?(0,U.jsx)(`div`,{className:v(`mt-3`,m),children:(0,U.jsx)(`div`,{className:g,children:n.map(e=>(0,U.jsx)(he,{automation:e,onToggle:i,onRunNow:a,isRunPending:o===e.id,onDelete:s,onEdit:c},e.id))})}):(0,U.jsx)(`div`,{className:v(ge,`mt-3`),children:(0,U.jsx)(`table`,{className:`w-full min-w-full [&>tbody>tr:first-child]:border-t-0`,children:(0,U.jsx)(`tbody`,{children:n.map(e=>(0,U.jsx)(Se,{automation:e,onToggle:i,onRunNow:a,isRunPending:o===e.id,onDelete:s,onEdit:c},e.id))})})})]})}var Ce=e(r(),1),X=[{value:`grid`,icon:V,labelKey:a.AUTOMATIONS$VIEW_GRID,testId:`automations-view-toggle-grid`},{value:`list`,icon:pe,labelKey:a.AUTOMATIONS$VIEW_LIST,testId:`automations-view-toggle-list`}];function we({icon:e,label:t,isSelected:n}){return(0,U.jsxs)(`span`,{className:`flex min-w-0 w-full items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`flex shrink-0 items-center text-[var(--oh-muted)] transition-colors group-hover:text-[var(--oh-foreground)] group-focus-visible:text-[var(--oh-foreground)] [&_svg]:size-4 [&_svg]:text-current`,"aria-hidden":!0,children:(0,U.jsx)(e,{})}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),n?(0,U.jsx)(l,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]})}function Te({view:e,onChange:t,disabled:n=!1}){let{t:r}=s(`openhands`),[i,o]=(0,H.useState)(!1),[c,l]=(0,H.useState)(),u=(0,H.useRef)(null),d=(0,H.useRef)(null),f=(X.find(t=>t.value===e)??X[0]).icon;(0,H.useLayoutEffect)(()=>{if(!i||!u.current)return;let e=()=>{let e=u.current?.getBoundingClientRect();e&&l({position:`fixed`,zIndex:9999,top:e.bottom+4,right:window.innerWidth-e.right})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[i]),(0,H.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&&c?(0,U.jsx)(w,{ref:d,theme:`popover`,className:`min-w-[10rem]`,children:X.map(n=>(0,U.jsx)(`li`,{children:(0,U.jsx)(T,{testId:n.testId,onClick:()=>{t(n.value),o(!1)},className:`group`,children:(0,U.jsx)(we,{icon:n.icon,label:r(n.labelKey),isSelected:e===n.value})})},n.value))}):null;return(0,U.jsxs)(U.Fragment,{children:[(0,U.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:v(`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,U.jsx)(f,{className:`size-4`,"aria-hidden":!0})}),i&&c&&typeof document<`u`?Ce.createPortal((0,U.jsx)(`div`,{style:c,children:p}),document.body):null]})}function Z(){return(0,U.jsxs)(`div`,{"data-testid":`automation-card-skeleton`,className:`${_} border border-transparent p-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,U.jsx)(`div`,{className:`h-5 w-40 animate-pulse rounded bg-surface-raised`}),(0,U.jsx)(`div`,{className:`h-5 w-10 animate-pulse rounded-full bg-surface-raised`})]}),(0,U.jsx)(`div`,{className:`mt-2 h-4 w-72 animate-pulse rounded bg-surface-raised`}),(0,U.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,U.jsx)(`div`,{className:`h-7 w-32 animate-pulse rounded-full bg-surface-raised`}),(0,U.jsx)(`div`,{className:`h-7 w-28 animate-pulse rounded-full bg-surface-raised`}),(0,U.jsx)(`div`,{className:`h-7 w-24 animate-pulse rounded-full bg-surface-raised`})]})]})}var Ee=e=>(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:2,stroke:`currentColor`,...e,children:(0,U.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m19.5 8.25-7.5 7.5-7.5-7.5`})}),De=`https://docs.openhands.dev/openhands/usage/automations/overview`;function Oe({children:e}){return(0,U.jsx)(`span`,{className:`whitespace-nowrap`,children:e})}function ke({children:e}){return(0,U.jsx)(`code`,{"data-testid":`automations-create-instructions-example`,className:v(`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 Ae({children:e}){return(0,U.jsx)(U.Fragment,{children:e})}var je={example:(0,U.jsx)(Oe,{}),cmd:(0,U.jsx)(ke,{}),punct:(0,U.jsx)(Ae,{})};function Q({onLaunch:e}={}){let{t}=s(`openhands`),n=N();return(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,U.jsxs)(`p`,{className:`text-sm leading-relaxed text-tertiary-light`,children:[(0,U.jsx)(o,{ns:`openhands`,i18nKey:a.AUTOMATIONS$EMPTY_OPTION_CONVERSATION_DESC,components:je}),` `,t(a.AUTOMATIONS$CREATE_INSTRUCTIONS_GUIDANCE)]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,U.jsx)(`a`,{href:De,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-muted underline transition-colors hover:text-foreground`,children:t(a.AUTOMATIONS$EMPTY_LEARN_MORE)}),(0,U.jsx)(b,{type:`button`,variant:`primary`,testId:`automations-create-automation`,onClick:()=>{n(t(a.AUTOMATIONS$CREATE_AUTOMATION_PROMPT),e)},startContent:(0,U.jsx)(M,{className:`size-4`,"aria-hidden":!0}),children:t(a.AUTOMATIONS$CREATE_AUTOMATION_BUTTON)})]})]})}function Me({collapsible:e=!1}){let{t}=s(`openhands`),[n,r]=(0,H.useState)(!e);return e?(0,U.jsxs)(`div`,{className:`w-full rounded-lg border border-[var(--oh-border)] bg-[var(--oh-surface)]`,children:[(0,U.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,U.jsx)(`span`,{className:`text-sm font-normal text-content`,children:t(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,U.jsx)(Ee,{className:v(`size-5 text-muted transition-transform`,n&&`rotate-180`)})]}),n?(0,U.jsx)(`div`,{className:`px-4 pb-4`,children:(0,U.jsx)(Q,{})}):null]}):(0,U.jsxs)(`div`,{className:`w-full max-w-2xl`,children:[(0,U.jsx)(`h3`,{className:`text-center text-sm font-medium text-content`,children:t(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)}),(0,U.jsx)(`div`,{className:`mt-4`,children:(0,U.jsx)(Q,{})})]})}function Ne(){let{t:e}=s(`openhands`);return(0,U.jsxs)(`div`,{"data-testid":`automations-empty`,className:p,children:[(0,U.jsx)(`p`,{className:`text-sm text-white`,children:e(a.AUTOMATIONS$EMPTY)}),(0,U.jsx)(`p`,{className:`mt-1 text-xs text-tertiary-light`,children:e(a.AUTOMATIONS$EMPTY_HINT)}),(0,U.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,U.jsx)(Me,{})})]})}function Pe({isOpen:e,onClose:t}){let{t:n}=s(`openhands`);return e?(0,U.jsx)(y,{onClose:t,"aria-label":n(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE),children:(0,U.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,U.jsx)(C,{onClose:t,testId:`add-automation-modal-close`}),(0,U.jsx)(`header`,{className:`flex-shrink-0 px-6 pb-4 pt-6`,children:(0,U.jsx)(`h2`,{id:`add-automation-modal-title`,className:`pr-6 text-lg font-semibold`,children:n(a.AUTOMATIONS$EMPTY_HOW_TO_CREATE_TITLE)})}),(0,U.jsx)(`div`,{className:`px-6 pb-6`,children:(0,U.jsx)(Q,{onLaunch:t})})]})}):null}var $=50,Fe=n(function(){let{t:e}=s(`openhands`),[t,n]=(0,H.useState)(``),[r,i]=(0,H.useState)(()=>be()),[o,c]=(0,H.useState)($),[l,f]=(0,H.useState)(null),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(!1),_=ee().backend.kind===`local`,{data:v,isLoading:y,refetch:x}=le(),S=v?.status===`ok`,{data:C,isLoading:w,isError:T,refetch:E}=se({limit:o,offset:0,enabled:S}),D=re(),O=ae(),k=ie(),A=(0,H.useMemo)(()=>{if(!C?.automations)return[];let e=t.toLowerCase();return e?C.automations.filter(t=>t.name.toLowerCase().includes(e)||(t.prompt??``).toLowerCase().includes(e)||t.repository?.toLowerCase().includes(e)||t.model?.toLowerCase().includes(e)):C.automations},[C?.automations,t]),j=(0,H.useMemo)(()=>A.filter(e=>e.enabled),[A]),M=(0,H.useMemo)(()=>A.filter(e=>!e.enabled),[A]),N=(e,t)=>{D.mutate({id:e,enabled:!t})},P=t=>{k.mutate(t,{onSuccess:()=>{d(e(a.AUTOMATIONS$RUN_NOW_SUCCESS))},onError:t=>{u(te(t)?t.response?.data?.message||t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR):t.message||e(a.AUTOMATIONS$RUN_NOW_ERROR))}})},F=e=>{let t=C?.automations.find(t=>t.id===e);t&&f({id:e,name:t.name})},I=e=>{let t=C?.automations.find(t=>t.id===e);t&&m(t)},L=()=>{l&&(O.mutate(l.id),f(null))},R=(0,H.useCallback)(e=>{i(e),xe(e)},[]),z=C?C.total>C.automations.length:!1,B=!w&&!T&&C?.automations.length===0;return y?(0,U.jsx)(`div`,{className:`min-h-full`,children:(0,U.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)}),(0,U.jsx)(`div`,{className:`mt-6 flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,U.jsx)(Z,{},`skeleton-${String(t)}`))})]})}):S?(0,U.jsx)(`div`,{className:`min-h-full`,children:(0,U.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-semibold text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)})]}),(0,U.jsx)(b,{type:`button`,variant:`secondary`,testId:`automations-add-automation`,className:`shrink-0 whitespace-nowrap`,onClick:()=>g(!0),children:e(a.AUTOMATIONS$ADD_AUTOMATION)})]}),(0,U.jsxs)(`div`,{className:`mt-6 flex items-stretch gap-2`,children:[(0,U.jsx)(me,{value:t,onChange:n}),(0,U.jsx)(Te,{view:r,onChange:R,disabled:B})]}),(0,U.jsxs)(`div`,{className:`mt-6 flex flex-col gap-6`,children:[w&&(0,U.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,U.jsx)(Z,{},`skeleton-${String(t)}`))}),T&&!w&&(0,U.jsx)(oe,{onRetry:E}),B&&(0,U.jsx)(Ne,{}),!w&&!T&&C&&C.automations.length>0&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Y,{title:e(a.AUTOMATIONS$ACTIVE),count:j.length,automations:j,view:r,onToggle:N,onRunNow:P,runPendingId:k.isPending?k.variables??null:null,onDelete:F,onEdit:_?I:void 0}),(0,U.jsx)(Y,{title:e(a.AUTOMATIONS$INACTIVE),count:M.length,automations:M,view:r,onToggle:N,onRunNow:P,runPendingId:k.isPending?k.variables??null:null,onDelete:F,onEdit:_?I:void 0}),z&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>c(e=>e+$),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,U.jsx)(`div`,{className:`mt-6`,children:(0,U.jsx)(ne,{query:t})}),(0,U.jsx)(ce,{automationName:l?.name??``,isOpen:l!==null,onConfirm:L,onCancel:()=>f(null)}),p&&(0,U.jsx)(de,{automation:p,isOpen:p!==null,onClose:()=>m(null)}),(0,U.jsx)(Pe,{isOpen:h,onClose:()=>g(!1)})]})}):(0,U.jsx)(`div`,{className:`min-h-full`,children:(0,U.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,U.jsx)(`h1`,{className:`text-xl font-medium text-content`,children:e(a.AUTOMATIONS$TITLE)}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:e(a.AUTOMATIONS$SUBTITLE)}),(0,U.jsx)(ue,{onRetry:x})]})})});export{Fe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./conversation-DWcvnmds.js";export{e as default};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/files-tab-CbJ4s7Ik.js","assets/rolldown-runtime-BFRubm34.js","assets/vendor~files-tab-DtLR-QD9.js","assets/iconBase-C7N9pPOs.js","assets/react-CM_dJw1Z.js","assets/vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-BJm2mGIp.js","assets/agent-server-client-options-8OJSXbm8.js","assets/agent-server-conversation-service.api-BdEre_71.js","assets/preload-helper-CT1Z6Pdu.js","assets/profiles-client-D4twHRVf.js","assets/agent-server-compatibility-DvKtnXHw.js","assets/server-client-CG1zHqph.js","assets/settings-service.api-Z6x0l0GU.js","assets/settings-client-CkXDJwIY.js","assets/proxy-BMZyC45G.js","assets/vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~pfbaerbd-zhv9fooy.js","assets/settings-D5am1n6X.js","assets/acp-providers-SCPK1BIU.js","assets/declaration-C9nuq2Dj.js","assets/common-SMkEaBSr.js","assets/vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~kyz9p27j-DlKA6SoO.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~b4cctr4k-B7YVdv1X.js","assets/QueryClientProvider-DITRCGAK.js","assets/useTranslation-01pF7z10.js","assets/context-CEQZwATj.js","assets/vendor~root-layout~home~conversation-panel~conversation~shared-conversation~alert-banner~pl~rqjteh0a-BP1SKG0F.js","assets/vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-CofhIDpd.js","assets/vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-BbFOrAjI.js","assets/objectWithoutPropertiesLoose-Du6eBn-V.js","assets/vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-B92czPCF.js","assets/vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-BW6261Sb.js","assets/vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-DpAdkv8m.js","assets/vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-By5W2oHN.js","assets/react-Do0CT17Y.js","assets/conversation-tab-empty-state-BtFDbyTe.js","assets/utils-Czcl6buL.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~i9dbt75i-CI82Did1.js","assets/markdown-renderer-wZnLDbA1.js","assets/checkmark-BcvXE9bf.js","assets/copy-BxgbrjDT.js","assets/active-backend-context-CkP3ZEJs.js","assets/health-store-BDC2rM-X.js","assets/use-active-conversation-Bu5J9iLy.js","assets/conversation-service.api-YTGTw0pz.js","assets/use-user-conversation-BCYpbPT1.js","assets/use-conversation-id-BOaaZahn.js","assets/navigation-context-BFjstyH6.js","assets/use-agent-state-DN9Nc5pP.js","assets/conversation-state-store-Bc0slAjL.js","assets/use-runtime-is-ready-BQWLEyqa.js","assets/status-DDL-ipIP.js","assets/chevron-left-small-BqSkXTeq.js","assets/link-external-CvxB0BmI.js","assets/folder-CerIk8uG.js","assets/files-tab-store-CDyVTXNT.js","assets/use-event-store-CQZCcVz-.js","assets/typography-BbaUAC4V.js","assets/dist-DZHSA2e6.js","assets/conversation-local-storage-UYl-SX-r.js","assets/git-status-mapper-BI8FyUVp.js","assets/retrieve-axios-error-message-BY-yIkIq.js","assets/browser-tab-DTM6RyoV.js","assets/vendor~browser-tab-BiVxfjJo.js","assets/browser-store-C3AqxAO7.js","assets/vscode-tab-BVhQR2rt.js","assets/use-unified-vscode-url-C5iI-Z5A.js","assets/vscode-url-helper-jesbpos5.js","assets/waiting-for-runtime-message-JotSOBdC.js","assets/brand-button-8fVVei4i.js","assets/planner-tab-yubfN-6U.js","assets/plan-components-gOm-daR3.js","assets/use-handle-plan-click-CgrCGmT1.js","assets/custom-toast-handlers-BYxhSr3t.js","assets/createLucideIcon-Ddu8jDOQ.js","assets/i18n-DkYgs32x.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~skills-settings~m~o9nrx3fm-D44TR8hL.js","assets/use-create-conversation-BWFA_FId.js","assets/useMutation-CRJwk4cR.js","assets/mutation-Cz7N4XAo.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~jfc6hidu-VnmIZrq3.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~zm51vy4j-iOsylxCS.js","assets/use-settings-DzG0C3vO.js","assets/query-keys-tAsQcc_9.js","assets/conversation-store-Z5iMCRpc.js","assets/middleware-BC9EwbB9.js","assets/lesson-plan-CmkRbe6Z.js","assets/task-list-tab-B45ktzHM.js","assets/use-task-list-Bs90uF2N.js","assets/u-check-circle-half-BPcWtWwv.js","assets/u-check-circle-DHGiAi-w.js","assets/terminal-D5pzR9Ru.js","assets/vendor~terminal-BUxzHKcC.js","assets/vendor~terminal-T4IDBjWs.css","assets/command-store-DFN_17p1.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./preload-helper-CT1Z6Pdu.js";import{A as r,L as i,M as a,k as o}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{t as s}from"./react-dom-hVBnwgwZ.js";import{t as c}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~kyz9p27j-DlKA6SoO.js";import{c as l,i as u,r as d,s as f}from"./path-utils-D1ZtqFC7.js";import{t as p}from"./useMutation-CRJwk4cR.js";import{o as m,t as h}from"./declaration-C9nuq2Dj.js";import{n as g}from"./QueryClientProvider-DITRCGAK.js";import{t as _}from"./Trans-D43bd3yR.js";import{t as v}from"./useTranslation-01pF7z10.js";import{a as y,c as b,d as x,i as S,l as C,n as w,o as T,r as E,s as D,t as O,u as k}from"./messages-BfaEAG2q.js";import{c as A,d as j,f as M,i as N,l as ee,n as te,r as P,s as F,t as ne,u as re}from"./sidebar-mobile-menu-toggle-DXplko7u.js";import{a as I,n as L,o as ie,r as ae,t as oe}from"./custom-toast-handlers-BYxhSr3t.js";import{n as se,r as R,t as ce}from"./vendor~conversation-panel~conversation-CbjvWBSu.js";import{a as le,c as ue,d as z,f as de,l as fe,m as B,n as pe,o as V,s as me,t as he,u as ge}from"./conversation-websocket-context-B0Gd3yiT.js";import{t as _e}from"./x-JOBEVLW0.js";import{_ as H,b as ve,c as ye,d as be,k as xe,l as Se,m as Ce,o as we,t as U,u as Te,v as Ee,y as De}from"./utils-Czcl6buL.js";import{S as Oe,r as ke}from"./agent-server-client-options-8OJSXbm8.js";import{n as W}from"./active-backend-context-CkP3ZEJs.js";import{n as Ae}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~jfc6hidu-VnmIZrq3.js";import{a as je,i as Me,o as Ne,t as Pe}from"./agent-server-conversation-service.api-BdEre_71.js";import{t as Fe}from"./modal-backdrop-B04pVYAD.js";import{n as Ie}from"./modal-body-CgUoFQA1.js";import{r as Le}from"./base-modal-B4HvlFHE.js";import{d as Re,t as ze}from"./brand-button-8fVVei4i.js";import{t as Be}from"./loading-spinner-91b5FiMQ.js";import{n as Ve}from"./navigation-context-BFjstyH6.js";import{h as He}from"./vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~iguv7bgw-CuGq_cxH.js";import{O as Ue}from"./vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~iguv7bgw-CFpDeb9o.js";import{t as We}from"./styled-tooltip-Awq4HMw3.js";import{_ as Ge,h as Ke,m as qe,n as Je,p as Ye,s as Xe}from"./git-provider-icon-D8RE4unY.js";import{t as Ze}from"./react-Do0CT17Y.js";import{n as Qe}from"./middleware-BC9EwbB9.js";import{i as $e,s as et}from"./conversation-local-storage-UYl-SX-r.js";import{t as G}from"./conversation-store-Z5iMCRpc.js";import{t as tt}from"./modal-close-button-SM_WXzDY.js";import{t as nt}from"./common-SMkEaBSr.js";import{t as rt}from"./use-is-authed-BFoh8Ogh.js";import{t as it}from"./use-click-outside-element-835W9pC6.js";import{i as at,n as ot,r as st}from"./status-DDL-ipIP.js";import{r as ct}from"./use-settings-DzG0C3vO.js";import{n as lt,t as ut}from"./use-create-conversation-BWFA_FId.js";import{r as dt}from"./conversation-service.api-YTGTw0pz.js";import{i as ft}from"./vendor~root-layout~conversation-panel~conversation~shared-conversation-DrXgiSCq.js";import{n as pt,t as K}from"./context-menu-list-item-DzjPB8aC.js";import{i as q,r as mt,t as ht}from"./ellipsis-button-BoU2-xlG.js";import{t as gt}from"./u-edit-BPFJBd34.js";import{t as _t}from"./skills-BN8atjgW.js";import{t as vt}from"./terminal-DGuR4559.js";import{t as yt}from"./use-user-conversation-BCYpbPT1.js";import{t as bt}from"./conversation-state-store-Bc0slAjL.js";import{C as xt,D as St,E as Ct,I as wt,M as Tt,O as Et,P as Dt,S as Ot,T as kt,_ as At,a as jt,b as Mt,d as Nt,f as Pt,g as Ft,h as It,i as Lt,j as Rt,k as zt,m as Bt,n as Vt,p as Ht,r as Ut,t as Wt,v as Gt,w as Kt,x as qt,y as Jt}from"./git-control-bar-branch-button-DhpPgadK.js";import{n as Yt,t as J}from"./use-conversation-id-BOaaZahn.js";import{t as Y}from"./use-active-conversation-Bu5J9iLy.js";import{t as X}from"./use-agent-state-DN9Nc5pP.js";import{S as Xt,a as Zt,d as Qt,o as $t,t as Z}from"./use-event-store-CQZCcVz-.js";import{t as en}from"./command-store-DFN_17p1.js";import{r as tn}from"./typography-BbaUAC4V.js";import{t as nn}from"./lesson-plan-CmkRbe6Z.js";import{t as rn}from"./copy-BxgbrjDT.js";import{t as an}from"./use-runtime-is-ready-BQWLEyqa.js";import{r as on}from"./plan-components-gOm-daR3.js";import{t as sn}from"./use-breakpoint-B86yKT9n.js";import{n as cn,t as ln}from"./use-unified-vscode-url-C5iI-Z5A.js";import{t as un}from"./use-task-list-Bs90uF2N.js";import{t as dn}from"./vendor~conversation-panel~conversation~alert-banner-Df7_G0zR.js";var Q=e(t(),1),fn={curAgentState:H.LOADING},pn=Ze(e=>({...fn,setCurrentAgentState:t=>e({curAgentState:t}),reset:()=>e(fn)})),mn=`openhands-last-conversation-by-backend`;function hn(e,t){return t?`${e}::${t}`:e}function gn(){if(typeof window>`u`)return{};try{let e=window.localStorage.getItem(mn);if(!e)return{};let t=JSON.parse(e);if(typeof t!=`object`||!t)return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`string`&&r.length>0&&(n[e]=r);return n}catch{return{}}}function _n(e){if(!(typeof window>`u`))try{window.localStorage.setItem(mn,JSON.stringify(e))}catch{}}function vn(e,t,n){if(!n)return;let r=gn();r[hn(e,t)]=n,_n(r)}function yn(e,t){let n=gn(),r=hn(e,t);r in n&&(delete n[r],_n(n))}var bn=e=>({action:x.CHANGE_AGENT_STATE,args:{agent_state:e}}),xn=e=>`error`in e,Sn=e=>`type`in e&&e.type===`error`,Cn=()=>{let{send:e}=k(),t=Z(e=>e.events);Q.useEffect(()=>{if(!t.length)return;let n=t[t.length-1];if(!($t(n)&&Zt(n))){if(xn(n)){if(n.error_code===401){L(`Session expired.`);return}typeof n.error==`string`?L(n.error):L(n.message);return}Sn(n)&&`${n.message??``}`.startsWith(`Agent reached maximum`)&&e(bn(H.PAUSED))}},[t.length])},wn=()=>{let{curAgentState:e}=X();return{runtimeActive:!Ee.includes(e)}};function Tn({children:e}){return Cn(),wn(),e}var $=m(),En=e=>(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 512 512`,...e,children:(0,$.jsx)(`path`,{d:`M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z`})}),Dn={entriesByConversation:{}},On=(e,t,n)=>({entriesByConversation:{...e.entriesByConversation,[t]:n(e.entriesByConversation[t]??[])}}),kn=Ze()(Qe(e=>({...Dn,addPending:(t,n)=>{let r=Ne();return e(e=>On(e,t,e=>[...e,{id:r,question:n,status:`pending`}])),r},resolve:(t,n,r)=>e(e=>On(e,t,e=>e.map(e=>e.id===n?{...e,response:r,status:`done`}:e))),fail:(t,n,r)=>e(e=>On(e,t,e=>e.map(e=>e.id===n?{...e,response:r,status:`error`}:e))),dismiss:(t,n)=>e(e=>On(e,t,e=>e.filter(e=>e.id!==n)))}),{name:`BtwStore`}));function An({onClick:e}){let{t}=v(`openhands`);return(0,$.jsxs)(`button`,{type:`button`,onClick:e,className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-normal text-success bg-success/10 hover:bg-success/20 border border-success/30 transition-colors`,children:[(0,$.jsx)(En,{className:`w-3.5 h-3.5 fill-success`}),(0,$.jsx)(`span`,{children:t(h.CHAT_INTERFACE$BTW_GOT_IT)})]})}function jn({conversationId:e}){let{t}=v(`openhands`),n=kn(e=>e.entriesByConversation),r=kn(e=>e.dismiss),i=e?n[e]??[]:[];return!e||i.length===0?null:(0,$.jsx)(`div`,{"data-testid":`btw-messages`,className:`flex flex-col w-full`,children:i.map(n=>{let i=n.status===`pending`;return(0,$.jsx)(b,{title:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`opacity-60`,children:t(h.CHAT_INTERFACE$BTW_PREFIX)}),(0,$.jsx)(`span`,{children:n.question}),i&&(0,$.jsx)(`span`,{"data-testid":`btw-spinner`,className:`inline-block w-3.5 h-3.5 ml-2 rounded-full border-2 border-[var(--oh-border-input)] border-t-transparent animate-spin`})]}),details:i?t(h.CHAT_INTERFACE$BTW_WAITING_FOR_ANSWER):n.response??``,initiallyExpanded:!i,chevronPosition:`before`,titleTrailing:!i&&(0,$.jsx)(An,{onClick:()=>r(e,n.id)})},n.id)})})}var Mn=`${ve} `,Nn=(e,t)=>{let n=kn(e=>e.addPending),r=kn(e=>e.resolve),i=kn(e=>e.fail);return(0,Q.useCallback)(a=>{let o=a.trim(),s=o===`/btw`||o.startsWith(Mn);if(!e||!s){t(a);return}let c=o.slice(ve.length).trim();if(!c)return;let l=n(e,c);d(e,c).then(({response:t})=>r(e,l,t)).catch(t=>i(e,l,t?.message??`Failed to ask agent`))},[e,t,n,r,i])};function Pn({onSuggestionsClick:e,hasRepository:t,providerTokensReady:n,isConversationReady:r=!0}){let{t:i}=v(`openhands`),{trackPullButtonClick:a}=lt(),o=n&&t&&r;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{a(),e(ye())},disabled:!o,className:U(`flex flex-row gap-1 items-center justify-center px-0.5 py-1 rounded-[100px] w-[76px] min-w-[76px]`,o?`bg-[var(--oh-surface)] hover:bg-tertiary cursor-pointer`:`bg-[rgba(71,74,84,0.50)] cursor-not-allowed`),children:[(0,$.jsx)(`div`,{className:`w-3 h-3 flex items-center justify-center`,children:(0,$.jsx)(xt,{width:12,height:12,color:`white`})}),(0,$.jsx)(`div`,{className:`font-normal text-white text-sm leading-5 max-w-[76px] truncate`,title:i(h.COMMON$PULL),children:i(h.COMMON$PULL)})]})}function Fn({onSuggestionsClick:e,hasRepository:t,providerTokensReady:n,currentGitProvider:r,isConversationReady:i=!0}){let{t:a}=v(`openhands`),{trackPushButtonClick:o}=lt(),s=n&&t&&i;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{o(),e(Se(r))},disabled:!s,className:U(`flex flex-row gap-1 items-center justify-center px-2 py-1 rounded-[100px] w-[77px] min-w-[77px]`,s?`bg-[var(--oh-surface)] hover:bg-tertiary cursor-pointer`:`bg-[rgba(71,74,84,0.50)] cursor-not-allowed`),children:[(0,$.jsx)(`div`,{className:`w-3 h-3 flex items-center justify-center`,children:(0,$.jsx)(Kt,{width:12,height:12,color:`white`})}),(0,$.jsx)(`div`,{className:`font-normal text-white text-sm leading-5 max-w-[77px] truncate`,title:a(h.COMMON$PUSH),children:a(h.COMMON$PUSH)})]})}function In({onSuggestionsClick:e,hasRepository:t,providerTokensReady:n,currentGitProvider:r,isConversationReady:i=!0}){let{t:a}=v(`openhands`),{trackCreatePrButtonClick:o}=lt(),s=n&&t&&i;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{o(),e(we(r))},disabled:!s,className:U(`flex flex-row gap-1 items-center justify-center px-2 py-1 rounded-[100px] w-[126px] min-w-[126px] h-7`,s?`bg-[var(--oh-surface)] hover:bg-tertiary cursor-pointer`:`bg-[rgba(71,74,84,0.50)] cursor-not-allowed`),children:[(0,$.jsx)(`div`,{className:`w-3 h-3 flex items-center justify-center`,children:(0,$.jsx)(Ot,{width:12,height:12,color:`white`})}),(0,$.jsx)(`div`,{className:`font-normal text-white text-sm leading-5 max-w-[126px] truncate`,title:a(h.COMMON$PULL_REQUEST),children:a(h.COMMON$PULL_REQUEST)})]})}function Ln(e){return e.kind===`BashCommand`}function Rn(e){return e.kind===`BashOutput`}function zn(e){return e.kind===`BashError`}function Bn(e,t,n){let r=(0,Q.useRef)(null),i=(0,Q.useRef)([]),a=(0,Q.useRef)([]),o=(0,Q.useRef)(new Map);return(0,Q.useEffect)(()=>{if(!n)return;let s=ke(e,t),c=new WebSocket(s);r.current=c,c.onopen=()=>{for(let{command:e,cwd:t,timeout:n,resolve:r,reject:o}of i.current)a.current.push({resolve:r,reject:o}),c.send(JSON.stringify({command:e,cwd:t,timeout:n}));i.current=[]},c.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(Ln(t)){let e=a.current.shift();e&&o.current.set(t.id,{...e,stdout:[],stderr:[]})}else if(Rn(t)&&t.command_id){let e=o.current.get(t.command_id);e&&(t.stdout&&e.stdout.push(t.stdout),t.stderr&&e.stderr.push(t.stderr),t.exit_code!=null&&(o.current.delete(t.command_id),e.resolve({exit_code:t.exit_code,stdout:e.stdout.join(``),stderr:e.stderr.join(``)})))}else zn(t)&&l(`Bash error: ${t.code}: ${t.detail}`)};function l(e){let t=Error(e);for(let{reject:e}of i.current)e(t);i.current=[];for(let e of a.current)e.reject(t);a.current=[];for(let e of o.current.values())e.reject(t);o.current.clear()}return c.onclose=()=>{r.current=null,l(`Bash WebSocket closed`)},c.onerror=()=>{r.current=null,l(`Bash WebSocket error`)},()=>{c.onclose=null,c.onerror=null,c.close(),r.current=null,l(`Bash WebSocket unmounted`)}},[n,e,t]),(0,Q.useCallback)((e,t,n)=>new Promise((o,s)=>{let c=r.current;if(!c||c.readyState===WebSocket.CLOSED||c.readyState===WebSocket.CLOSING){s(Error(`Bash WebSocket not available`));return}c.readyState===WebSocket.CONNECTING?i.current.push({command:e,cwd:t,timeout:n,resolve:o,reject:s}):(a.current.push({resolve:o,reject:s}),c.send(JSON.stringify({command:e,cwd:t,timeout:n})))}),[])}var Vn={"github.com":`github`,"gitlab.com":`gitlab`,"bitbucket.org":`bitbucket`,"dev.azure.com":`azure_devops`};function Hn(e){return e.replace(/\.git$/,``)}function Un(e){return e?Vn[e.toLowerCase()]??null:null}function Wn(e){let t=e.split(`/`).filter(Boolean),n=t.indexOf(`_git`);return n===-1?t.join(`/`):[...t.slice(0,n),...t.slice(n+1)].join(`/`)}function Gn(e,t,n){let r=Hn(n.replace(/^\/+/,``)),i=Un(t);return{url:e,host:t,repository:(i===`azure_devops`?Wn(r):r)||null,provider:i}}function Kn(e){let t=e?.trim();if(!t)return null;let n=t.match(/^[^@\s]+@([^:\s]+):(.+)$/);if(n){let e=n[1];return Gn(t,e,n[2])}try{let e=new URL(t);return Gn(t,e.hostname||null,e.pathname)}catch{return null}}var qn={repository:null,branch:null,provider:null,remoteUrl:null};async function Jn(e,t){let[n,r]=await Promise.all([e(`git remote get-url origin`,t,10),e(`git rev-parse --abbrev-ref HEAD`,t,10)]),i=n.exit_code===0?n.stdout.trim():``,a=r.exit_code===0?r.stdout.trim():``,o=a&&a!==`HEAD`?a:null;if(!i&&!o)return qn;let s=Kn(i);return{repository:s?.repository??null,provider:s?.provider??null,remoteUrl:i||null,branch:o}}async function Yn(e,t){let n=await e(`find . -mindepth 2 -maxdepth 4 -name .git 2>/dev/null | sed 's#^\\./##' | sed 's#/.git$##'`,t,10);if(n.exit_code!==0)return qn;let r=Array.from(new Set(n.stdout.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)));return r.length===1?Jn(e,`${t}/${r[0]}`.replace(/\/+/g,`/`)):qn}var Xn=()=>{let{data:e}=Y(),t=an(),{backend:n}=W(),r=n.kind===`local`,i=e?.id,a=e?.conversation_url,o=e?.session_api_key,s=e?.workspace?.working_dir?.trim()||Oe(),l=!!e?.selected_repository,u=!!e?.git_provider,d=!!e?.selected_branch,f=r&&t&&!!i&&(!l||!u||!d),p=Bn(a,o,f),m=(0,Q.useRef)(p);return m.current=p,c({queryKey:[`local-git-info`,i,a,o,s],queryFn:async()=>{let e=(e,t,n)=>m.current(e,t,n),t=await Jn(e,s);if(t.repository||t.branch)return t;let n=await Yn(e,s);return n.repository||n.branch?n:qn},enabled:f,retry:!1,staleTime:1e4,refetchInterval:1e4,gcTime:1e3*60*5,meta:{disableToast:!0}})},Zn=()=>{let e=g(),{t}=v(`openhands`);return p({mutationFn:e=>Pe.updateConversationRepository(e.conversationId,e.repository,e.branch,e.gitProvider),onMutate:async t=>{let n=[`user`,`conversation`,t.conversationId];await e.cancelQueries({queryKey:n});let r=e.getQueriesData({queryKey:n});return e.setQueriesData({queryKey:n},e=>e&&{...e,selected_repository:t.repository,selected_branch:t.branch??null,git_provider:t.gitProvider??null}),{previousEntries:r}},onError:(n,r,i)=>{i?.previousEntries.forEach(([t,n])=>{e.setQueryData(t,n)}),L(t(h.CONVERSATION$FAILED_TO_UPDATE_REPOSITORY))},onSuccess:()=>{ae(t(h.CONVERSATION$REPOSITORY_UPDATED))},onSettled:(t,n,r)=>{e.invalidateQueries({queryKey:[`user`,`conversation`,r.conversationId]}),e.invalidateQueries({queryKey:[`user`,`conversations`]}),e.invalidateQueries({queryKey:[`local-git-info`,r.conversationId]})}})};function Qn({children:e,tooltipMessage:t,testId:n,shouldShowTooltip:r}){return r?(0,$.jsx)(We,{content:t,placement:`top`,showArrow:!0,tooltipClassName:`bg-white text-black`,children:(0,$.jsx)(`span`,{"data-testid":n,className:`hover:opacity-100`,children:e})}):e}function $n({isOpen:e,onClose:t,onLaunch:n,defaultProvider:r=`github`}){let{t:i}=v(`openhands`),{providers:a}=Xe(),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{a.length===1&&!o?s(a[0]):a.length>1&&!o&&r&&a.includes(r)&&s(r)},[a,o,r]);let f=(0,Q.useCallback)(e=>{e!==o&&(s(e),l(null),d(null))},[o]),p=(0,Q.useCallback)(e=>{e?(l(e),d(null)):(l(null),d(null))},[]),m=(0,Q.useCallback)(e=>{d(e)},[]),g=()=>{!c||!u||(n(c,u),l(null),d(null),t())},_=()=>{s(null),l(null),d(null),t()};if(!e)return null;let y=c?.git_provider||o||r,b=!!c&&!!u;return(0,$.jsx)(Fe,{onClose:_,children:(0,$.jsxs)(Ie,{width:`sm`,className:`relative items-start border border-[var(--oh-border)] !gap-4`,children:[(0,$.jsx)(tt,{onClose:_,testId:`close-open-repository-modal`}),(0,$.jsx)(`div`,{className:`w-full pr-6`,children:(0,$.jsx)(Le,{title:i(h.CONVERSATION$OPEN_REPOSITORY)})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 w-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-sm text-white font-normal leading-[22px]`,children:i(h.CONVERSATION$SELECT_OR_INSERT_LINK)}),a.length>1&&(0,$.jsx)(jt,{providers:a,value:o,placeholder:`Select Provider`,onChange:f})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-[10px] w-full`,children:[(0,$.jsx)(Ut,{provider:y,value:c?.id||null,repositoryName:c?.full_name||null,onChange:p,placeholder:`Search repositories...`,className:`w-full`}),(0,$.jsx)(Lt,{repository:c?.full_name||null,provider:y,selectedBranch:u,onBranchSelect:m,defaultBranch:c?.main_branch||null,placeholder:`Select branch...`,disabled:!c,className:`w-full`})]})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 w-full`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(ze,{type:`button`,variant:`secondary`,onClick:_,children:i(h.BUTTON$CANCEL)}),(0,$.jsx)(ze,{type:`button`,variant:`primary`,onClick:g,isDisabled:!b,children:i(h.BUTTON$LAUNCH)})]})]})})}function er({onSuggestionsClick:e}){let{t}=v(`openhands`),{conversationId:n}=J(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),{addRecentRepository:c}=Je(),l=z(e=>e.enqueuePendingMessage),u=z(e=>e.markPendingMessageError),{backend:d}=W(),f=d.kind===`local`,{providers:p}=Xe(),m=f||p.length>0,{data:g}=Y(),{repositoryInfo:_}=Et(),{data:y}=Xn(),b=Dt(),x=(0,Q.useRef)(b);(0,Q.useEffect)(()=>{x.current=b},[b]);let{send:S}=k(),C=(0,Q.useRef)(S);(0,Q.useEffect)(()=>{C.current=S},[S]);let{mutate:w}=Zn(),{mutate:T,isPending:E}=ut(),D=g?.selected_repository||_?.selectedRepository,O=g?.git_provider||_?.gitProvider,A=g?.selected_branch||_?.selectedBranch,j=D||y?.repository||void 0,M=O||y?.provider,N=A||y?.branch||void 0,ee=(g?.id?je(g.id):null)?.selected_workspace??null,te=ee&&ee.replace(/\/+$/,``).split(`/`).pop()||null,P=!!j&&!!M,F=!!g&&b===`OPEN`;(0,Q.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]),(0,Q.useEffect)(()=>{if(!a)return;let e=e=>{e.key===`Escape`&&o(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]);let ne=(e,r)=>{n&&(c(e),w({conversationId:n,repository:e.full_name,branch:r.name,gitProvider:e.git_provider},{onSuccess:()=>{if(x.current!==`OPEN`){L(t(h.CONVERSATION$CLONE_COMMAND_FAILED_DISCONNECTED));return}let i=e.git_provider.charAt(0).toUpperCase()+e.git_provider.slice(1),a=`Clone ${e.full_name} from ${i} and checkout branch ${r.name}.`,o=n?l({conversationId:n,text:a}):null;Promise.resolve(C.current({action:`message`,args:{content:a,timestamp:new Date().toISOString()}})).catch(e=>{o&&u(o,e instanceof Error?e.message:`Failed to send message`)})}}))},re=!f||!!j||!!te,I=f&&!P;return re||N||P?(0,$.jsxs)(`div`,{className:`flex flex-row items-center`,children:[(0,$.jsxs)(`div`,{className:`flex flex-row gap-2.5 items-center overflow-x-auto flex-nowrap relative scrollbar-hide`,children:[re?(0,$.jsx)(Vt,{selectedRepository:j,gitProvider:M,workspaceName:te,onClick:()=>i(!0),disabled:!F||I}):null,N?(0,$.jsx)(Wt,{selectedBranch:N,selectedRepository:j,gitProvider:M}):null,P?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Qn,{tooltipMessage:t(h.COMMON$GIT_TOOLS_DISABLED_CONTENT),testId:`git-control-bar-pull-button-tooltip`,shouldShowTooltip:!P,children:(0,$.jsx)(Pn,{onSuggestionsClick:e,hasRepository:P,providerTokensReady:m,isConversationReady:F})}),(0,$.jsx)(Qn,{tooltipMessage:t(h.COMMON$GIT_TOOLS_DISABLED_CONTENT),testId:`git-control-bar-push-button-tooltip`,shouldShowTooltip:!P,children:(0,$.jsx)(Fn,{onSuggestionsClick:e,hasRepository:P,providerTokensReady:m,currentGitProvider:M,isConversationReady:F})}),(0,$.jsx)(Qn,{tooltipMessage:t(h.COMMON$GIT_TOOLS_DISABLED_CONTENT),testId:`git-control-bar-pr-button-tooltip`,shouldShowTooltip:!P,children:(0,$.jsx)(In,{onSuggestionsClick:e,hasRepository:P,providerTokensReady:m,currentGitProvider:M,isConversationReady:F})})]}):null]}),(0,$.jsx)($n,{isOpen:r,onClose:()=>i(!1),onLaunch:ne,defaultProvider:M})]}):null}function tr({onSubmit:e,disabled:t=!1}){let{images:n,files:r,imagesMarkedUploadAsFile:i,clearAllFiles:a,subConversationTaskId:o}=G(),{curAgentState:s}=X(),{data:c}=Y(),{conversationId:l}=Yt(),u=l??c?.id??null,{taskStatus:d}=St(o,c?.id||null),{handleUpload:f}=Nt(),p=Pt(u,Nn(u,t=>{let{imagesToEmbed:o,imagesAsFiles:s}=wt(n,i);e(t,o,[...r,...s]),a()}));return(0,$.jsxs)(`div`,{"data-testid":`interactive-chat-box`,children:[(0,$.jsx)(Ht,{disabled:t||s===H.AWAITING_USER_CONFIRMATION||Ce(d),isNewConversationPending:t,onSubmit:p,onFilesPaste:f}),(0,$.jsx)(`div`,{className:`mt-3 pb-3`,children:(0,$.jsx)(er,{onSuggestionsClick:e=>{p(e)}})})]})}function nr(){let e=Z(e=>e.events),t=Z(e=>e.uiEvents),n=Q.useMemo(()=>t.filter(V),[t]),r=Q.useMemo(()=>e,[e]),i=Q.useMemo(()=>n.length,[n]),a=Q.useMemo(()=>r.some(e=>e.source===`agent`&&!Xt(e)&&!Qt(e)),[r]),o=le(r);return{storeEvents:e,uiEvents:t,renderableEvents:n,allConversationEvents:r,totalEvents:i,hasSubstantiveAgentActions:a,conversationUserEventsExist:o,userEventsExist:o}}var rr=e=>`timestamp`in e?e.timestamp:void 0,ir=e=>{let t=!!e&&$e(e),n=t?void 0:e,{data:r}=yt(e??null),{data:i,isFetched:a}=me(n??void 0),o=Z(e=>e.addEvents),[s,c]=Q.useState(!1),[l,u]=Q.useState(!0),d=Q.useRef(!1),f=Q.useRef(!0);return Q.useEffect(()=>{if(d.current=!1,c(!1),t){f.current=!1,u(!1);return}f.current=!0,u(!0)},[e,t]),Q.useEffect(()=>{t||!a||!i||i.hasMore||(f.current=!1,u(!1))},[t,a,i?.hasMore,n]),{isLoading:s,hasMore:l,loadOlder:Q.useCallback(async()=>{if(!e||$e(e)||d.current||!f.current||!r)return;let{events:t}=Z.getState(),n=t[0];if(!n)return;let i=rr(n);if(!i){f.current=!1,u(!1);return}d.current=!0,c(!0);try{let t=await fe.searchEvents(e,r?.conversation_url??null,r?.session_api_key??null,{limit:50,sortOrder:`TIMESTAMP_DESC`,timestampLt:i});if(!Array.isArray(t.items))throw Error(`Invalid older-events response: expected page.items to be an array.`);let n=[...t.items].reverse();n.length>0&&o(n),(!t.next_page_id||t.items.length<50)&&(f.current=!1,u(!1))}finally{d.current=!1,c(!1)}},[e,r,r?.conversation_url,r?.session_api_key,o])}};function ar(){return(0,$.jsxs)(`div`,{className:`flex items-center space-x-1.5 rounded-full bg-[var(--oh-surface)] px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--oh-muted)] animate-[bounce_0.5s_infinite] translate-y-[1px] [animation-delay:0ms]`}),(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--oh-muted)] animate-[bounce_0.5s_infinite] translate-y-[1px] [animation-delay:75ms]`}),(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--oh-muted)] animate-[bounce_0.5s_infinite] translate-y-[1px] [animation-delay:150ms]`})]})}function or({suggestion:e,onClick:t}){let{t:n}=v(`openhands`);return(0,$.jsxs)(`button`,{type:`button`,className:`list-none border border-[var(--oh-border)] rounded-[15px] hover:bg-surface-raised hover:border-[var(--oh-interactive-hover)] transition-colors flex-1 flex items-center justify-center cursor-pointer gap-[10px] h-[55px] px-4`,onClick:()=>t(e.value),children:[(0,Q.useMemo)(()=>{switch(e.label){case`INCREASE_TEST_COVERAGE`:return(0,$.jsx)(qt,{width:24,height:24,color:`#fff`});case`AUTO_MERGE_PRS`:return(0,$.jsx)(Mt,{width:19,height:20,color:`#fff`});case`FIX_README`:return(0,$.jsx)(Jt,{width:24,height:24,color:`#fff`});case`CLEAN_DEPENDENCIES`:return(0,$.jsx)(Gt,{width:24,height:24,color:`#fff`});default:return null}},[e]),(0,$.jsx)(`span`,{"data-testid":`suggestion`,className:`text-[15px] font-normal leading-5 text-white text-center cursor-pointer`,children:n(e.label)})]})}function sr({suggestions:e,onSuggestionClick:t}){return(0,$.jsx)(`div`,{"data-testid":`suggestions`,className:`grid grid-cols-2 gap-5 max-w-fit`,children:e.map((e,n)=>(0,$.jsx)(or,{suggestion:e,onClick:t},n))})}var cr=h.SUGGESTIONS$HACKER_NEWS,lr=`Please write a bash script which displays the top story on Hacker News. It should show the title, the link, and the number of points.
|
|
2
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./preload-helper-CT1Z6Pdu.js";import{A as r,L as i,M as a,k as o}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{t as s}from"./react-dom-hVBnwgwZ.js";import{t as c}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~kyz9p27j-DlKA6SoO.js";import{c as l,i as u,r as d,s as f}from"./path-utils-D1ZtqFC7.js";import{t as p}from"./useMutation-CRJwk4cR.js";import{o as m,t as h}from"./declaration-C9nuq2Dj.js";import{n as g}from"./QueryClientProvider-DITRCGAK.js";import{t as _}from"./Trans-D43bd3yR.js";import{t as v}from"./useTranslation-01pF7z10.js";import{a as y,c as b,d as x,i as S,l as C,n as w,o as T,r as E,s as D,t as O,u as k}from"./messages-v-q35ObG.js";import{c as A,d as j,f as M,i as N,l as ee,n as te,r as P,s as F,t as ne,u as re}from"./sidebar-mobile-menu-toggle-DXplko7u.js";import{a as I,n as L,o as ie,r as ae,t as oe}from"./custom-toast-handlers-BYxhSr3t.js";import{n as se,r as R,t as ce}from"./vendor~conversation-panel~conversation-CbjvWBSu.js";import{a as le,c as ue,d as z,f as de,l as fe,m as B,n as pe,o as V,s as me,t as he,u as ge}from"./conversation-websocket-context-DulnrIHh.js";import{t as _e}from"./x-JOBEVLW0.js";import{_ as H,b as ve,c as ye,d as be,k as xe,l as Se,m as Ce,o as we,t as U,u as Te,v as Ee,y as De}from"./utils-Czcl6buL.js";import{S as Oe,r as ke}from"./agent-server-client-options-8OJSXbm8.js";import{n as W}from"./active-backend-context-CkP3ZEJs.js";import{n as Ae}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~jfc6hidu-VnmIZrq3.js";import{a as je,i as Me,o as Ne,t as Pe}from"./agent-server-conversation-service.api-BdEre_71.js";import{t as Fe}from"./modal-backdrop-B04pVYAD.js";import{n as Ie}from"./modal-body-CgUoFQA1.js";import{r as Le}from"./base-modal-B4HvlFHE.js";import{d as Re,t as ze}from"./brand-button-8fVVei4i.js";import{t as Be}from"./loading-spinner-91b5FiMQ.js";import{n as Ve}from"./navigation-context-BFjstyH6.js";import{h as He}from"./vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~iguv7bgw-CuGq_cxH.js";import{O as Ue}from"./vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~iguv7bgw-CFpDeb9o.js";import{t as We}from"./styled-tooltip-Awq4HMw3.js";import{_ as Ge,h as Ke,m as qe,n as Je,p as Ye,s as Xe}from"./git-provider-icon-D8RE4unY.js";import{t as Ze}from"./react-Do0CT17Y.js";import{n as Qe}from"./middleware-BC9EwbB9.js";import{i as $e,s as et}from"./conversation-local-storage-UYl-SX-r.js";import{t as G}from"./conversation-store-Z5iMCRpc.js";import{t as tt}from"./modal-close-button-SM_WXzDY.js";import{t as nt}from"./common-SMkEaBSr.js";import{t as rt}from"./use-is-authed-BFoh8Ogh.js";import{t as it}from"./use-click-outside-element-835W9pC6.js";import{i as at,n as ot,r as st}from"./status-DDL-ipIP.js";import{r as ct}from"./use-settings-DzG0C3vO.js";import{n as lt,t as ut}from"./use-create-conversation-BWFA_FId.js";import{r as dt}from"./conversation-service.api-YTGTw0pz.js";import{i as ft}from"./vendor~root-layout~conversation-panel~conversation~shared-conversation-DrXgiSCq.js";import{n as pt,t as K}from"./context-menu-list-item-DzjPB8aC.js";import{i as q,r as mt,t as ht}from"./ellipsis-button-BoU2-xlG.js";import{t as gt}from"./u-edit-BPFJBd34.js";import{t as _t}from"./skills-BN8atjgW.js";import{t as vt}from"./terminal-DGuR4559.js";import{t as yt}from"./use-user-conversation-BCYpbPT1.js";import{t as bt}from"./conversation-state-store-Bc0slAjL.js";import{C as xt,D as St,E as Ct,I as wt,M as Tt,O as Et,P as Dt,S as Ot,T as kt,_ as At,a as jt,b as Mt,d as Nt,f as Pt,g as Ft,h as It,i as Lt,j as Rt,k as zt,m as Bt,n as Vt,p as Ht,r as Ut,t as Wt,v as Gt,w as Kt,x as qt,y as Jt}from"./git-control-bar-branch-button-Bm6rzSpo.js";import{n as Yt,t as J}from"./use-conversation-id-BOaaZahn.js";import{t as Y}from"./use-active-conversation-Bu5J9iLy.js";import{t as X}from"./use-agent-state-DN9Nc5pP.js";import{S as Xt,a as Zt,d as Qt,o as $t,t as Z}from"./use-event-store-CQZCcVz-.js";import{t as en}from"./command-store-DFN_17p1.js";import{r as tn}from"./typography-BbaUAC4V.js";import{t as nn}from"./lesson-plan-CmkRbe6Z.js";import{t as rn}from"./copy-BxgbrjDT.js";import{t as an}from"./use-runtime-is-ready-BQWLEyqa.js";import{r as on}from"./plan-components-gOm-daR3.js";import{t as sn}from"./use-breakpoint-B86yKT9n.js";import{n as cn,t as ln}from"./use-unified-vscode-url-C5iI-Z5A.js";import{t as un}from"./use-task-list-Bs90uF2N.js";import{t as dn}from"./vendor~conversation-panel~conversation~alert-banner-Df7_G0zR.js";var Q=e(t(),1),fn={curAgentState:H.LOADING},pn=Ze(e=>({...fn,setCurrentAgentState:t=>e({curAgentState:t}),reset:()=>e(fn)})),mn=`openhands-last-conversation-by-backend`;function hn(e,t){return t?`${e}::${t}`:e}function gn(){if(typeof window>`u`)return{};try{let e=window.localStorage.getItem(mn);if(!e)return{};let t=JSON.parse(e);if(typeof t!=`object`||!t)return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`string`&&r.length>0&&(n[e]=r);return n}catch{return{}}}function _n(e){if(!(typeof window>`u`))try{window.localStorage.setItem(mn,JSON.stringify(e))}catch{}}function vn(e,t,n){if(!n)return;let r=gn();r[hn(e,t)]=n,_n(r)}function yn(e,t){let n=gn(),r=hn(e,t);r in n&&(delete n[r],_n(n))}var bn=e=>({action:x.CHANGE_AGENT_STATE,args:{agent_state:e}}),xn=e=>`error`in e,Sn=e=>`type`in e&&e.type===`error`,Cn=()=>{let{send:e}=k(),t=Z(e=>e.events);Q.useEffect(()=>{if(!t.length)return;let n=t[t.length-1];if(!($t(n)&&Zt(n))){if(xn(n)){if(n.error_code===401){L(`Session expired.`);return}typeof n.error==`string`?L(n.error):L(n.message);return}Sn(n)&&`${n.message??``}`.startsWith(`Agent reached maximum`)&&e(bn(H.PAUSED))}},[t.length])},wn=()=>{let{curAgentState:e}=X();return{runtimeActive:!Ee.includes(e)}};function Tn({children:e}){return Cn(),wn(),e}var $=m(),En=e=>(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 512 512`,...e,children:(0,$.jsx)(`path`,{d:`M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z`})}),Dn={entriesByConversation:{}},On=(e,t,n)=>({entriesByConversation:{...e.entriesByConversation,[t]:n(e.entriesByConversation[t]??[])}}),kn=Ze()(Qe(e=>({...Dn,addPending:(t,n)=>{let r=Ne();return e(e=>On(e,t,e=>[...e,{id:r,question:n,status:`pending`}])),r},resolve:(t,n,r)=>e(e=>On(e,t,e=>e.map(e=>e.id===n?{...e,response:r,status:`done`}:e))),fail:(t,n,r)=>e(e=>On(e,t,e=>e.map(e=>e.id===n?{...e,response:r,status:`error`}:e))),dismiss:(t,n)=>e(e=>On(e,t,e=>e.filter(e=>e.id!==n)))}),{name:`BtwStore`}));function An({onClick:e}){let{t}=v(`openhands`);return(0,$.jsxs)(`button`,{type:`button`,onClick:e,className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-normal text-success bg-success/10 hover:bg-success/20 border border-success/30 transition-colors`,children:[(0,$.jsx)(En,{className:`w-3.5 h-3.5 fill-success`}),(0,$.jsx)(`span`,{children:t(h.CHAT_INTERFACE$BTW_GOT_IT)})]})}function jn({conversationId:e}){let{t}=v(`openhands`),n=kn(e=>e.entriesByConversation),r=kn(e=>e.dismiss),i=e?n[e]??[]:[];return!e||i.length===0?null:(0,$.jsx)(`div`,{"data-testid":`btw-messages`,className:`flex flex-col w-full`,children:i.map(n=>{let i=n.status===`pending`;return(0,$.jsx)(b,{title:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`opacity-60`,children:t(h.CHAT_INTERFACE$BTW_PREFIX)}),(0,$.jsx)(`span`,{children:n.question}),i&&(0,$.jsx)(`span`,{"data-testid":`btw-spinner`,className:`inline-block w-3.5 h-3.5 ml-2 rounded-full border-2 border-[var(--oh-border-input)] border-t-transparent animate-spin`})]}),details:i?t(h.CHAT_INTERFACE$BTW_WAITING_FOR_ANSWER):n.response??``,initiallyExpanded:!i,chevronPosition:`before`,titleTrailing:!i&&(0,$.jsx)(An,{onClick:()=>r(e,n.id)})},n.id)})})}var Mn=`${ve} `,Nn=(e,t)=>{let n=kn(e=>e.addPending),r=kn(e=>e.resolve),i=kn(e=>e.fail);return(0,Q.useCallback)(a=>{let o=a.trim(),s=o===`/btw`||o.startsWith(Mn);if(!e||!s){t(a);return}let c=o.slice(ve.length).trim();if(!c)return;let l=n(e,c);d(e,c).then(({response:t})=>r(e,l,t)).catch(t=>i(e,l,t?.message??`Failed to ask agent`))},[e,t,n,r,i])};function Pn({onSuggestionsClick:e,hasRepository:t,providerTokensReady:n,isConversationReady:r=!0}){let{t:i}=v(`openhands`),{trackPullButtonClick:a}=lt(),o=n&&t&&r;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{a(),e(ye())},disabled:!o,className:U(`flex flex-row gap-1 items-center justify-center px-0.5 py-1 rounded-[100px] w-[76px] min-w-[76px]`,o?`bg-[var(--oh-surface)] hover:bg-tertiary cursor-pointer`:`bg-[rgba(71,74,84,0.50)] cursor-not-allowed`),children:[(0,$.jsx)(`div`,{className:`w-3 h-3 flex items-center justify-center`,children:(0,$.jsx)(xt,{width:12,height:12,color:`white`})}),(0,$.jsx)(`div`,{className:`font-normal text-white text-sm leading-5 max-w-[76px] truncate`,title:i(h.COMMON$PULL),children:i(h.COMMON$PULL)})]})}function Fn({onSuggestionsClick:e,hasRepository:t,providerTokensReady:n,currentGitProvider:r,isConversationReady:i=!0}){let{t:a}=v(`openhands`),{trackPushButtonClick:o}=lt(),s=n&&t&&i;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{o(),e(Se(r))},disabled:!s,className:U(`flex flex-row gap-1 items-center justify-center px-2 py-1 rounded-[100px] w-[77px] min-w-[77px]`,s?`bg-[var(--oh-surface)] hover:bg-tertiary cursor-pointer`:`bg-[rgba(71,74,84,0.50)] cursor-not-allowed`),children:[(0,$.jsx)(`div`,{className:`w-3 h-3 flex items-center justify-center`,children:(0,$.jsx)(Kt,{width:12,height:12,color:`white`})}),(0,$.jsx)(`div`,{className:`font-normal text-white text-sm leading-5 max-w-[77px] truncate`,title:a(h.COMMON$PUSH),children:a(h.COMMON$PUSH)})]})}function In({onSuggestionsClick:e,hasRepository:t,providerTokensReady:n,currentGitProvider:r,isConversationReady:i=!0}){let{t:a}=v(`openhands`),{trackCreatePrButtonClick:o}=lt(),s=n&&t&&i;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{o(),e(we(r))},disabled:!s,className:U(`flex flex-row gap-1 items-center justify-center px-2 py-1 rounded-[100px] w-[126px] min-w-[126px] h-7`,s?`bg-[var(--oh-surface)] hover:bg-tertiary cursor-pointer`:`bg-[rgba(71,74,84,0.50)] cursor-not-allowed`),children:[(0,$.jsx)(`div`,{className:`w-3 h-3 flex items-center justify-center`,children:(0,$.jsx)(Ot,{width:12,height:12,color:`white`})}),(0,$.jsx)(`div`,{className:`font-normal text-white text-sm leading-5 max-w-[126px] truncate`,title:a(h.COMMON$PULL_REQUEST),children:a(h.COMMON$PULL_REQUEST)})]})}function Ln(e){return e.kind===`BashCommand`}function Rn(e){return e.kind===`BashOutput`}function zn(e){return e.kind===`BashError`}function Bn(e,t,n){let r=(0,Q.useRef)(null),i=(0,Q.useRef)([]),a=(0,Q.useRef)([]),o=(0,Q.useRef)(new Map);return(0,Q.useEffect)(()=>{if(!n)return;let s=ke(e,t),c=new WebSocket(s);r.current=c,c.onopen=()=>{for(let{command:e,cwd:t,timeout:n,resolve:r,reject:o}of i.current)a.current.push({resolve:r,reject:o}),c.send(JSON.stringify({command:e,cwd:t,timeout:n}));i.current=[]},c.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(Ln(t)){let e=a.current.shift();e&&o.current.set(t.id,{...e,stdout:[],stderr:[]})}else if(Rn(t)&&t.command_id){let e=o.current.get(t.command_id);e&&(t.stdout&&e.stdout.push(t.stdout),t.stderr&&e.stderr.push(t.stderr),t.exit_code!=null&&(o.current.delete(t.command_id),e.resolve({exit_code:t.exit_code,stdout:e.stdout.join(``),stderr:e.stderr.join(``)})))}else zn(t)&&l(`Bash error: ${t.code}: ${t.detail}`)};function l(e){let t=Error(e);for(let{reject:e}of i.current)e(t);i.current=[];for(let e of a.current)e.reject(t);a.current=[];for(let e of o.current.values())e.reject(t);o.current.clear()}return c.onclose=()=>{r.current=null,l(`Bash WebSocket closed`)},c.onerror=()=>{r.current=null,l(`Bash WebSocket error`)},()=>{c.onclose=null,c.onerror=null,c.close(),r.current=null,l(`Bash WebSocket unmounted`)}},[n,e,t]),(0,Q.useCallback)((e,t,n)=>new Promise((o,s)=>{let c=r.current;if(!c||c.readyState===WebSocket.CLOSED||c.readyState===WebSocket.CLOSING){s(Error(`Bash WebSocket not available`));return}c.readyState===WebSocket.CONNECTING?i.current.push({command:e,cwd:t,timeout:n,resolve:o,reject:s}):(a.current.push({resolve:o,reject:s}),c.send(JSON.stringify({command:e,cwd:t,timeout:n})))}),[])}var Vn={"github.com":`github`,"gitlab.com":`gitlab`,"bitbucket.org":`bitbucket`,"dev.azure.com":`azure_devops`};function Hn(e){return e.replace(/\.git$/,``)}function Un(e){return e?Vn[e.toLowerCase()]??null:null}function Wn(e){let t=e.split(`/`).filter(Boolean),n=t.indexOf(`_git`);return n===-1?t.join(`/`):[...t.slice(0,n),...t.slice(n+1)].join(`/`)}function Gn(e,t,n){let r=Hn(n.replace(/^\/+/,``)),i=Un(t);return{url:e,host:t,repository:(i===`azure_devops`?Wn(r):r)||null,provider:i}}function Kn(e){let t=e?.trim();if(!t)return null;let n=t.match(/^[^@\s]+@([^:\s]+):(.+)$/);if(n){let e=n[1];return Gn(t,e,n[2])}try{let e=new URL(t);return Gn(t,e.hostname||null,e.pathname)}catch{return null}}var qn={repository:null,branch:null,provider:null,remoteUrl:null},Jn=[`r=$(git remote get-url origin 2>/dev/null)`,`b=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)`,`if [ -z "$r$b" ]; then`,`n=$(find . -mindepth 2 -maxdepth 4 -name .git 2>/dev/null | cut -c3- | sed 's|/.git$||' | sort -u)`,`c=$(printf '%s\\n' "$n" | grep -c '[^[:space:]]')`,`if [ "$c" = "1" ] && [ -n "$n" ]; then`,`r=$(git -C "$n" remote get-url origin 2>/dev/null)`,`b=$(git -C "$n" rev-parse --abbrev-ref HEAD 2>/dev/null)`,`fi`,`fi`,`printf '%s\\n%s' "$r" "$b"`].join(`
|
|
3
|
+
`);async function Yn(e,t){let n=await e(Jn,t,10);if(n.exit_code!==0)return qn;let r=n.stdout.indexOf(`
|
|
4
|
+
`),i=(r>=0?n.stdout.slice(0,r):n.stdout).trim(),a=(r>=0?n.stdout.slice(r+1):``).trim(),o=a&&a!==`HEAD`?a:null;if(!i&&!o)return qn;let s=Kn(i);return{repository:s?.repository??null,provider:s?.provider??null,remoteUrl:i||null,branch:o}}var Xn=()=>{let{data:e}=Y(),t=an(),{backend:n}=W(),r=n.kind===`local`,i=e?.id,a=e?.conversation_url,o=e?.session_api_key,s=e?.workspace?.working_dir?.trim()||Oe(),l=!!e?.selected_repository,u=!!e?.git_provider,d=!!e?.selected_branch,f=r&&t&&!!i&&(!l||!u||!d),p=Bn(a,o,f),m=(0,Q.useRef)(p);return m.current=p,c({queryKey:[`local-git-info`,i,a,o,s],queryFn:async()=>Yn((e,t,n)=>m.current(e,t,n),s),enabled:f,retry:!1,staleTime:1e4,refetchInterval:1e4,gcTime:1e3*60*5,meta:{disableToast:!0}})},Zn=()=>{let e=g(),{t}=v(`openhands`);return p({mutationFn:e=>Pe.updateConversationRepository(e.conversationId,e.repository,e.branch,e.gitProvider),onMutate:async t=>{let n=[`user`,`conversation`,t.conversationId];await e.cancelQueries({queryKey:n});let r=e.getQueriesData({queryKey:n});return e.setQueriesData({queryKey:n},e=>e&&{...e,selected_repository:t.repository,selected_branch:t.branch??null,git_provider:t.gitProvider??null}),{previousEntries:r}},onError:(n,r,i)=>{i?.previousEntries.forEach(([t,n])=>{e.setQueryData(t,n)}),L(t(h.CONVERSATION$FAILED_TO_UPDATE_REPOSITORY))},onSuccess:()=>{ae(t(h.CONVERSATION$REPOSITORY_UPDATED))},onSettled:(t,n,r)=>{e.invalidateQueries({queryKey:[`user`,`conversation`,r.conversationId]}),e.invalidateQueries({queryKey:[`user`,`conversations`]}),e.invalidateQueries({queryKey:[`local-git-info`,r.conversationId]})}})};function Qn({children:e,tooltipMessage:t,testId:n,shouldShowTooltip:r}){return r?(0,$.jsx)(We,{content:t,placement:`top`,showArrow:!0,tooltipClassName:`bg-white text-black`,children:(0,$.jsx)(`span`,{"data-testid":n,className:`hover:opacity-100`,children:e})}):e}function $n({isOpen:e,onClose:t,onLaunch:n,defaultProvider:r=`github`}){let{t:i}=v(`openhands`),{providers:a}=Xe(),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{a.length===1&&!o?s(a[0]):a.length>1&&!o&&r&&a.includes(r)&&s(r)},[a,o,r]);let f=(0,Q.useCallback)(e=>{e!==o&&(s(e),l(null),d(null))},[o]),p=(0,Q.useCallback)(e=>{e?(l(e),d(null)):(l(null),d(null))},[]),m=(0,Q.useCallback)(e=>{d(e)},[]),g=()=>{!c||!u||(n(c,u),l(null),d(null),t())},_=()=>{s(null),l(null),d(null),t()};if(!e)return null;let y=c?.git_provider||o||r,b=!!c&&!!u;return(0,$.jsx)(Fe,{onClose:_,children:(0,$.jsxs)(Ie,{width:`sm`,className:`relative items-start border border-[var(--oh-border)] !gap-4`,children:[(0,$.jsx)(tt,{onClose:_,testId:`close-open-repository-modal`}),(0,$.jsx)(`div`,{className:`w-full pr-6`,children:(0,$.jsx)(Le,{title:i(h.CONVERSATION$OPEN_REPOSITORY)})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 w-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-sm text-white font-normal leading-[22px]`,children:i(h.CONVERSATION$SELECT_OR_INSERT_LINK)}),a.length>1&&(0,$.jsx)(jt,{providers:a,value:o,placeholder:`Select Provider`,onChange:f})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-[10px] w-full`,children:[(0,$.jsx)(Ut,{provider:y,value:c?.id||null,repositoryName:c?.full_name||null,onChange:p,placeholder:`Search repositories...`,className:`w-full`}),(0,$.jsx)(Lt,{repository:c?.full_name||null,provider:y,selectedBranch:u,onBranchSelect:m,defaultBranch:c?.main_branch||null,placeholder:`Select branch...`,disabled:!c,className:`w-full`})]})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 w-full`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(ze,{type:`button`,variant:`secondary`,onClick:_,children:i(h.BUTTON$CANCEL)}),(0,$.jsx)(ze,{type:`button`,variant:`primary`,onClick:g,isDisabled:!b,children:i(h.BUTTON$LAUNCH)})]})]})})}function er({onSuggestionsClick:e}){let{t}=v(`openhands`),{conversationId:n}=J(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),{addRecentRepository:c}=Je(),l=z(e=>e.enqueuePendingMessage),u=z(e=>e.markPendingMessageError),{backend:d}=W(),f=d.kind===`local`,{providers:p}=Xe(),m=f||p.length>0,{data:g}=Y(),{repositoryInfo:_}=Et(),{data:y}=Xn(),b=Dt(),x=(0,Q.useRef)(b);(0,Q.useEffect)(()=>{x.current=b},[b]);let{send:S}=k(),C=(0,Q.useRef)(S);(0,Q.useEffect)(()=>{C.current=S},[S]);let{mutate:w}=Zn(),{mutate:T,isPending:E}=ut(),D=g?.selected_repository||_?.selectedRepository,O=g?.git_provider||_?.gitProvider,A=g?.selected_branch||_?.selectedBranch,j=D||y?.repository||void 0,M=O||y?.provider,N=A||y?.branch||void 0,ee=(g?.id?je(g.id):null)?.selected_workspace??null,te=ee&&ee.replace(/\/+$/,``).split(`/`).pop()||null,P=!!j&&!!M,F=!!g&&b===`OPEN`;(0,Q.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]),(0,Q.useEffect)(()=>{if(!a)return;let e=e=>{e.key===`Escape`&&o(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]);let ne=(e,r)=>{n&&(c(e),w({conversationId:n,repository:e.full_name,branch:r.name,gitProvider:e.git_provider},{onSuccess:()=>{if(x.current!==`OPEN`){L(t(h.CONVERSATION$CLONE_COMMAND_FAILED_DISCONNECTED));return}let i=e.git_provider.charAt(0).toUpperCase()+e.git_provider.slice(1),a=`Clone ${e.full_name} from ${i} and checkout branch ${r.name}.`,o=n?l({conversationId:n,text:a}):null;Promise.resolve(C.current({action:`message`,args:{content:a,timestamp:new Date().toISOString()}})).catch(e=>{o&&u(o,e instanceof Error?e.message:`Failed to send message`)})}}))},re=!f||!!j||!!te,I=f&&!P;return re||N||P?(0,$.jsxs)(`div`,{className:`flex flex-row items-center`,children:[(0,$.jsxs)(`div`,{className:`flex flex-row gap-2.5 items-center overflow-x-auto flex-nowrap relative scrollbar-hide`,children:[re?(0,$.jsx)(Vt,{selectedRepository:j,gitProvider:M,workspaceName:te,onClick:()=>i(!0),disabled:!F||I}):null,N?(0,$.jsx)(Wt,{selectedBranch:N,selectedRepository:j,gitProvider:M}):null,P?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Qn,{tooltipMessage:t(h.COMMON$GIT_TOOLS_DISABLED_CONTENT),testId:`git-control-bar-pull-button-tooltip`,shouldShowTooltip:!P,children:(0,$.jsx)(Pn,{onSuggestionsClick:e,hasRepository:P,providerTokensReady:m,isConversationReady:F})}),(0,$.jsx)(Qn,{tooltipMessage:t(h.COMMON$GIT_TOOLS_DISABLED_CONTENT),testId:`git-control-bar-push-button-tooltip`,shouldShowTooltip:!P,children:(0,$.jsx)(Fn,{onSuggestionsClick:e,hasRepository:P,providerTokensReady:m,currentGitProvider:M,isConversationReady:F})}),(0,$.jsx)(Qn,{tooltipMessage:t(h.COMMON$GIT_TOOLS_DISABLED_CONTENT),testId:`git-control-bar-pr-button-tooltip`,shouldShowTooltip:!P,children:(0,$.jsx)(In,{onSuggestionsClick:e,hasRepository:P,providerTokensReady:m,currentGitProvider:M,isConversationReady:F})})]}):null]}),(0,$.jsx)($n,{isOpen:r,onClose:()=>i(!1),onLaunch:ne,defaultProvider:M})]}):null}function tr({onSubmit:e,disabled:t=!1}){let{images:n,files:r,imagesMarkedUploadAsFile:i,clearAllFiles:a,subConversationTaskId:o}=G(),{curAgentState:s}=X(),{data:c}=Y(),{conversationId:l}=Yt(),u=l??c?.id??null,{taskStatus:d}=St(o,c?.id||null),{handleUpload:f}=Nt(),p=Pt(u,Nn(u,t=>{let{imagesToEmbed:o,imagesAsFiles:s}=wt(n,i);e(t,o,[...r,...s]),a()}));return(0,$.jsxs)(`div`,{"data-testid":`interactive-chat-box`,children:[(0,$.jsx)(Ht,{disabled:t||s===H.AWAITING_USER_CONFIRMATION||Ce(d),isNewConversationPending:t,onSubmit:p,onFilesPaste:f}),(0,$.jsx)(`div`,{className:`mt-3 pb-3`,children:(0,$.jsx)(er,{onSuggestionsClick:e=>{p(e)}})})]})}function nr(){let e=Z(e=>e.events),t=Z(e=>e.uiEvents),n=Q.useMemo(()=>t.filter(V),[t]),r=Q.useMemo(()=>e,[e]),i=Q.useMemo(()=>n.length,[n]),a=Q.useMemo(()=>r.some(e=>e.source===`agent`&&!Xt(e)&&!Qt(e)),[r]),o=le(r);return{storeEvents:e,uiEvents:t,renderableEvents:n,allConversationEvents:r,totalEvents:i,hasSubstantiveAgentActions:a,conversationUserEventsExist:o,userEventsExist:o}}var rr=e=>`timestamp`in e?e.timestamp:void 0,ir=e=>{let t=!!e&&$e(e),n=t?void 0:e,{data:r}=yt(e??null),{data:i,isFetched:a}=me(n??void 0),o=Z(e=>e.addEvents),[s,c]=Q.useState(!1),[l,u]=Q.useState(!0),d=Q.useRef(!1),f=Q.useRef(!0);return Q.useEffect(()=>{if(d.current=!1,c(!1),t){f.current=!1,u(!1);return}f.current=!0,u(!0)},[e,t]),Q.useEffect(()=>{t||!a||!i||i.hasMore||(f.current=!1,u(!1))},[t,a,i?.hasMore,n]),{isLoading:s,hasMore:l,loadOlder:Q.useCallback(async()=>{if(!e||$e(e)||d.current||!f.current||!r)return;let{events:t}=Z.getState(),n=t[0];if(!n)return;let i=rr(n);if(!i){f.current=!1,u(!1);return}d.current=!0,c(!0);try{let t=await fe.searchEvents(e,r?.conversation_url??null,r?.session_api_key??null,{limit:50,sortOrder:`TIMESTAMP_DESC`,timestampLt:i});if(!Array.isArray(t.items))throw Error(`Invalid older-events response: expected page.items to be an array.`);let n=[...t.items].reverse();n.length>0&&o(n),(!t.next_page_id||t.items.length<50)&&(f.current=!1,u(!1))}finally{d.current=!1,c(!1)}},[e,r,r?.conversation_url,r?.session_api_key,o])}};function ar(){return(0,$.jsxs)(`div`,{className:`flex items-center space-x-1.5 rounded-full bg-[var(--oh-surface)] px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--oh-muted)] animate-[bounce_0.5s_infinite] translate-y-[1px] [animation-delay:0ms]`}),(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--oh-muted)] animate-[bounce_0.5s_infinite] translate-y-[1px] [animation-delay:75ms]`}),(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--oh-muted)] animate-[bounce_0.5s_infinite] translate-y-[1px] [animation-delay:150ms]`})]})}function or({suggestion:e,onClick:t}){let{t:n}=v(`openhands`);return(0,$.jsxs)(`button`,{type:`button`,className:`list-none border border-[var(--oh-border)] rounded-[15px] hover:bg-surface-raised hover:border-[var(--oh-interactive-hover)] transition-colors flex-1 flex items-center justify-center cursor-pointer gap-[10px] h-[55px] px-4`,onClick:()=>t(e.value),children:[(0,Q.useMemo)(()=>{switch(e.label){case`INCREASE_TEST_COVERAGE`:return(0,$.jsx)(qt,{width:24,height:24,color:`#fff`});case`AUTO_MERGE_PRS`:return(0,$.jsx)(Mt,{width:19,height:20,color:`#fff`});case`FIX_README`:return(0,$.jsx)(Jt,{width:24,height:24,color:`#fff`});case`CLEAN_DEPENDENCIES`:return(0,$.jsx)(Gt,{width:24,height:24,color:`#fff`});default:return null}},[e]),(0,$.jsx)(`span`,{"data-testid":`suggestion`,className:`text-[15px] font-normal leading-5 text-white text-center cursor-pointer`,children:n(e.label)})]})}function sr({suggestions:e,onSuggestionClick:t}){return(0,$.jsx)(`div`,{"data-testid":`suggestions`,className:`grid grid-cols-2 gap-5 max-w-fit`,children:e.map((e,n)=>(0,$.jsx)(or,{suggestion:e,onClick:t},n))})}var cr=h.SUGGESTIONS$HACKER_NEWS,lr=`Please write a bash script which displays the top story on Hacker News. It should show the title, the link, and the number of points.
|
|
3
5
|
The script should only use tools that are widely available on unix systems, like curl and grep.`,ur=h.SUGGESTIONS$HELLO_WORLD,dr=`I want to create a Hello World app in Javascript that:
|
|
4
6
|
* Displays Hello World in the middle.
|
|
5
7
|
* Has a button that when clicked, changes the greeting with a bouncing animation to fun versions of Hello.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./conversation-DWcvnmds.js";export{e as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~kyz9p27j-DlKA6SoO.js";import{i as r,l as i,n as a}from"./path-utils-D1ZtqFC7.js";import{t as o}from"./useMutation-CRJwk4cR.js";import{o as s}from"./declaration-C9nuq2Dj.js";import{n as ee}from"./QueryClientProvider-DITRCGAK.js";import{t as c}from"./createLucideIcon-Ddu8jDOQ.js";import{a as l,c as u,i as d,n as f,t as p}from"./agent-server-client-options-8OJSXbm8.js";import{n as m}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~jfc6hidu-VnmIZrq3.js";import{i as h}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-BJm2mGIp.js";import{o as g,s as _,t as v}from"./agent-server-conversation-service.api-BdEre_71.js";import{t as y}from"./proxy-BMZyC45G.js";import{t as b}from"./react-Do0CT17Y.js";import{n as x}from"./middleware-BC9EwbB9.js";import{a as te}from"./conversation-local-storage-UYl-SX-r.js";import{t as S}from"./conversation-store-Z5iMCRpc.js";import{t as C}from"./use-user-conversation-BCYpbPT1.js";import{t as ne}from"./conversation-state-store-Bc0slAjL.js";import{C as re,_ as w,a as T,b as ie,c as ae,d as E,f as oe,g as D,h as se,i as O,l as ce,m as le,o as ue,p as de,r as k,s as fe,t as A,u as pe,v as j,x as me,y as he}from"./use-event-store-CQZCcVz-.js";import{t as ge}from"./command-store-DFN_17p1.js";import{t as _e}from"./browser-store-C3AqxAO7.js";import{t as M}from"./files-tab-store-CDyVTXNT.js";var N=c(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),P=e(t(),1),ve=(e,t)=>{let[n,r]=P.useState(!1),[i,a]=P.useState(null),[o,s]=P.useState([]),[ee,c]=P.useState(null),[l,u]=P.useState(!1),d=P.useRef(null),f=P.useRef(0),p=P.useRef(null),m=P.useRef(!0),h=P.useRef(new WeakSet),g=P.useRef(t);P.useEffect(()=>{g.current=t},[t]);let _=P.useCallback(()=>{let t=e;if(g.current?.queryParams){let n=Object.entries(g.current.queryParams).reduce((e,[t,n])=>(e[t]=String(n),e),{});t=`${e}?${new URLSearchParams(n).toString()}`}let n=new WebSocket(t);d.current=n,h.current.add(n),n.onopen=e=>{r(!0),c(null),u(!1),f.current=0,g.current?.onOpen?.(e)},n.onmessage=e=>{a(e.data),s(t=>[...t,e.data]),g.current?.onMessage?.(e)},n.onclose=e=>{let t=h.current.has(n);r(!1),e.code!==1e3&&(c(Error(`WebSocket closed with code ${e.code}: ${e.reason||`Connection closed unexpectedly`}`)),t&&g.current?.onError?.(e)),g.current?.onClose?.(e);let i=g.current?.reconnect?.enabled??!1,a=g.current?.reconnect?.maxAttempts??1/0;i&&t&&m.current&&f.current<a?(u(!0),f.current+=1,p.current=setTimeout(()=>{_()},3e3)):u(!1)},n.onerror=e=>{r(!1),g.current?.onError?.(e)}},[e]);P.useEffect(()=>(m.current=!0,f.current=0,e&&e.trim()!==``&&_(),()=>{if(m.current=!1,p.current&&=(clearTimeout(p.current),null),d.current){let{readyState:e}=d.current;h.current.delete(d.current),(e===WebSocket.CONNECTING||e===WebSocket.OPEN)&&d.current.close(),d.current=null}}),[e,_]);let v=P.useCallback(e=>{d.current?.readyState===WebSocket.OPEN&&d.current.send(e)},[]),y=P.useCallback(()=>{m.current=!1,u(!1),p.current&&=(clearTimeout(p.current),null),d.current&&(h.current.delete(d.current),d.current.close())},[]),b=P.useCallback(()=>{if(m.current=!0,f.current=0,u(!0),c(null),p.current&&=(clearTimeout(p.current),null),d.current){let e=d.current;h.current.delete(e),d.current=null,(e.readyState===WebSocket.CONNECTING||e.readyState===WebSocket.OPEN)&&e.close()}_()},[_]);return{isConnected:n,lastMessage:i,messages:o,error:ee,socket:d.current,sendMessage:v,isReconnecting:l,attemptCount:f.current,disconnect:y,reconnect:b}},F=`Unable to connect to server`,I={errorMessage:null,errorType:null},ye=b(e=>({...I,setErrorMessage:(t,n=`conversation`)=>e(()=>({errorMessage:t,errorType:n})),removeErrorMessage:()=>e(()=>({errorMessage:null,errorType:null})),clearConnectionError:()=>e(e=>e.errorType===`connection`?{errorMessage:null,errorType:null}:e)})),L=15e4,R={pendingMessages:[]},z=()=>`pending-${Date.now()}-${Math.random().toString(36).slice(2,10)}`,be=b((e,t)=>({...R,enqueuePendingMessage:n=>{let r=z(),i={id:r,conversationId:n.conversationId,text:n.text,content:n.content??n.text,status:`sending`,imageUrls:n.imageUrls??[],fileUrls:n.fileUrls??[],timestamp:n.timestamp??new Date().toISOString()};return e(e=>({pendingMessages:[...e.pendingMessages,i]})),setTimeout(()=>{t().pendingMessages.find(e=>e.id===r)?.status===`sending`&&t().markPendingMessageError(r,`Send timed out`)},L),r},markPendingMessageError:(t,n)=>e(e=>({pendingMessages:e.pendingMessages.map(e=>e.id===t?{...e,status:`error`,errorMessage:n}:e)})),markPendingMessageSending:t=>e(e=>({pendingMessages:e.pendingMessages.map(e=>e.id===t?{...e,status:`sending`,errorMessage:void 0}:e)})),removePendingMessage:t=>e(e=>({pendingMessages:e.pendingMessages.filter(e=>e.id!==t)})),consumeMatchingPendingMessage:(t,n)=>{let r=null;return e(e=>{let i=e.pendingMessages.map((e,t)=>({m:e,i:t})).filter(({m:e})=>e.status===`sending`&&e.conversationId===t);if(i.length===0)return e;let a=i.find(({m:e})=>e.content===n)??i[0];return r=a.m,{pendingMessages:[...e.pendingMessages.slice(0,a.i),...e.pendingMessages.slice(a.i+1)]}}),r},clearPendingMessages:()=>e(()=>({...R})),reassignPendingMessages:(t,n)=>e(e=>({pendingMessages:e.pendingMessages.map(e=>e.conversationId===t?{...e,conversationId:n}:e)}))})),B=new Set([`files`,`browser`,`vscode`,`terminal`,`planner`,`tasklist`]);function V(e){let t=S.getState();t.setSelectedTab(e),t.isRightPanelShown||(t.setHasRightPanelToggled(!0),t.setIsRightPanelShown(!0))}function H(e){return B.has(e)}function xe(e){switch(e.command){case`navigate_to_file`:case`show_preview`:V(`files`),e.path&&M.getState().setSelectedPath(e.path);return;case`open_tab`:e.tab&&H(e.tab)?V(e.tab):e.tab&&console.warn(`[canvas_ui] Ignoring open_tab with unknown tab: ${e.tab}`);return}}var U=(e,t,n)=>({entriesByConversation:{...e.entriesByConversation,[t]:[...e.entriesByConversation[t]??[],n]}}),W=b()(x(e=>({entriesByConversation:{},activeProfileByConversation:{},show:(t,n,r)=>e(e=>U(e,t,{id:g(),anchorEventId:n,profiles:r})),recordSwitch:(t,n,r)=>e(e=>({...U(e,t,{id:g(),anchorEventId:n,profiles:[],switchedTo:r}),activeProfileByConversation:{...e.activeProfileByConversation,[t]:r}})),clearActiveProfile:t=>e(e=>{if(!(t in e.activeProfileByConversation))return e;let n={...e.activeProfileByConversation};return delete n[t],{activeProfileByConversation:n}}),clear:t=>e(e=>{let n={...e.entriesByConversation};delete n[t];let r={...e.activeProfileByConversation};return delete r[t],{entriesByConversation:n,activeProfileByConversation:r}}),clearAll:()=>e({entriesByConversation:{},activeProfileByConversation:{}})}),{name:`ModelStore`})),Se=(e,t,n)=>{let{action:r}=e;if((r.kind===`StrReplaceEditorAction`||r.kind===`FileEditorAction`||r.kind===`ExecuteBashAction`)&&n.invalidateQueries({queryKey:[`file_changes`,t]},{cancelRefetch:!1}),(r.kind===`StrReplaceEditorAction`||r.kind===`FileEditorAction`)&&r.path){let e=a(r.path);n.invalidateQueries({queryKey:[`file_diff`,t,e]})}e.tool_name===`SwitchLLMTool`&&(n.invalidateQueries({queryKey:[`user`,`conversation`,t]}),W.getState().clearActiveProfile(t))},G=class{static async respondToConfirmation(e,t,n,r){let i=u().backend;return i.kind===`cloud`?y({backend:i,method:`POST`,hostOverride:d(t),path:`/api/conversations/${e}/events/respond_to_confirmation`,body:n,authMode:`session-api-key`,sessionApiKey:r}):new _(p({conversationUrl:t,sessionApiKey:r})).respondToConfirmation(e,n)}static async getEventCount(e,t,n){let r=u().backend;return r.kind===`cloud`?y({backend:r,method:`GET`,hostOverride:d(t),path:`/api/conversations/${e}/events/count`,authMode:`session-api-key`,sessionApiKey:n}):new _(p({conversationUrl:t,sessionApiKey:n})).getEventCount(e)}static async searchEvents(e,t,n,r={}){let i=u().backend,a=r.limit??100;if(i.kind===`cloud`){let t=Math.min(a,100),n=!!(r.sortOrder||r.pageId||r.timestampGte||r.timestampLt),o=new URLSearchParams;o.set(`limit`,String(t)),r.sortOrder&&o.set(`sort_order`,r.sortOrder),r.pageId&&o.set(`page_id`,r.pageId),r.timestampGte&&o.set(`timestamp__gte`,r.timestampGte),r.timestampLt&&o.set(`timestamp__lt`,r.timestampLt);let s=t=>y({backend:i,method:`GET`,path:`/api/v1/conversation/${e}/events/search?${t.toString()}`});try{let e=await s(o);return{items:e?.items??[],next_page_id:e?.next_page_id??null}}catch(e){if(!n)throw e;return console.warn(`[EventService] Cloud backend doesn't support pagination filters. Falling back to initial load only. Server needs OpenHands/OpenHands#14399.`),{items:[],next_page_id:null}}}let o=await new h(f({conversationUrl:t,sessionApiKey:n}),e).search({limit:a,...r.pageId?{page_id:r.pageId}:{},...r.sortOrder?{sort_order:r.sortOrder}:{},...r.timestampGte?{timestamp__gte:r.timestampGte}:{},...r.timestampLt?{timestamp__lt:r.timestampLt}:{}});return{items:o?.items??[],next_page_id:o?.next_page_id??null}}};function K({message:e,source:t,metadata:n={},posthog:r}){if(!r)return;let i=Error(e);r.captureException(i,{error_source:t||`unknown`,...n})}var Ce=()=>o({mutationKey:[`read-conversation-file`],mutationFn:async({conversationId:e,filePath:t})=>v.readConversationFile(e,t)}),we=b(e=>({cost:null,max_budget_per_task:null,usage:null,setMetrics:t=>e(t)})),Te=e=>{let{data:t}=C(e??null);return n({queryKey:[`conversation-history`,e,t?.conversation_url??null,t?.session_api_key??null],enabled:!!e&&!!t,queryFn:async()=>{if(!e)return{events:[],hasMore:!1,nextPageId:null};let n=await G.searchEvents(e,t?.conversation_url??null,t?.session_api_key??null,{limit:50,sortOrder:`TIMESTAMP_DESC`});if(!Array.isArray(n.items))throw Error(`Invalid conversation history response: expected page.items to be an array.`);return{events:[...n.items].reverse(),hasMore:!!n.next_page_id||n.items.length>=50,nextPageId:n.next_page_id??null}},staleTime:1/0,gcTime:1800*1e3})},q=e=>{if(E(e))return!1;if(O(e)){let t=e.action.kind;return!(!t||t===`ExecuteBashAction`&&e.source===`user`||t===`PlanningFileEditorAction`||t===`SwitchLLMAction`)}return j(e)?!(e.observation.kind===`SwitchLLMObservation`&&!e.observation.is_error):w(e)||T(e)||D(e)?!0:k(e)?e.status===`completed`||e.status===`failed`:!1},J=e=>e.some(e=>e.source===`user`),Y=()=>{let{uiEvents:e}=A.getState();for(let t=e.length-1;t>=0;--t){let n=e[t];if(q(n))return String(n.id)}return null};function Ee(e,t,n=Y()){W.getState().recordSwitch(e,n,t)}var De=s(),Oe=(0,P.createContext)(void 0);function ke(e){return e.llm_message.content.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function X({children:e,conversationId:t,conversationUrl:n,sessionApiKey:a,subConversations:o,subConversationIds:s}){let[c,u]=(0,P.useState)(`CONNECTING`),[d,f]=(0,P.useState)(`CONNECTING`),h=P.useRef(!1),g=P.useRef(!1),v=m(),y=ee(),b=A(e=>e.addEvent),x=A(e=>e.addEvents),{setErrorMessage:C,removeErrorMessage:w,clearConnectionError:D}=ye(),k=be(e=>e.consumeMatchingPendingMessage),{setExecutionStatus:j}=ne(),{appendInput:M,appendOutput:N}=ge(),[I,L]=(0,P.useState)(!0),[R,z]=(0,P.useState)(null),{setPlanContent:B}=S(),{mutate:V}=Ce(),H=(0,P.useRef)(0),U=(0,P.useRef)(null),W=e=>e?.toUpperCase().endsWith(`PLAN.MD`)??!1,q=(0,P.useCallback)(()=>{D()},[D]),J=(0,P.useCallback)(e=>{if(e.value.usage_to_metrics?.agent){let t=e.value.usage_to_metrics.agent,n={cost:t.accumulated_cost,max_budget_per_task:t.max_budget_per_task??null,usage:t.accumulated_token_usage?{prompt_tokens:t.accumulated_token_usage.prompt_tokens,completion_tokens:t.accumulated_token_usage.completion_tokens,cache_read_tokens:t.accumulated_token_usage.cache_read_tokens,cache_write_tokens:t.accumulated_token_usage.cache_write_tokens,context_window:t.accumulated_token_usage.context_window,per_turn_token:t.accumulated_token_usage.per_turn_token}:null};we.getState().setMetrics(n)}},[]),{data:Y,isPending:X,isError:Ae}=Te(t),je=!!t&&X;(0,P.useLayoutEffect)(()=>{!Y||Y.events.length===0||x(Y.events)},[Y,x]);let Me=(0,P.useMemo)(()=>{if(X)return null;let e=Y?.events??[],t=e[e.length-1];return!t||!(`timestamp`in t)||!t.timestamp?null:t.timestamp},[Y,X]),Ne=(0,P.useMemo)(()=>!t||!n||X&&!Ae?null:l(t,n),[t,n,X,Ae]),Z=(0,P.useMemo)(()=>{if(!o?.length)return null;let e=o[0];return!e?.id||!e.conversation_url?null:l(e.id,e.conversation_url)},[o]),Pe=(0,P.useMemo)(()=>Z?c===`CONNECTING`||d===`CONNECTING`?`CONNECTING`:c===`OPEN`&&d===`OPEN`?`OPEN`:c===`CLOSED`&&d===`CLOSED`?`CLOSED`:c===`CLOSING`||d===`CLOSING`?`CLOSING`:`CLOSED`:c,[c,d,Z]);(0,P.useEffect)(()=>{R!==null&&H.current>=R&&I&&L(!1)},[R,I,H]),(0,P.useEffect)(()=>{if(!I&&U.current){let{path:e,conversationId:t}=U.current;V({conversationId:t,filePath:e},{onSuccess:e=>{B(e)},onError:e=>{console.warn(`Failed to read conversation file:`,e)}}),U.current=null}},[I,V,B]),(0,P.useEffect)(()=>{h.current=!1,L(!!s?.length),z(null),H.current=0,U.current=null},[s]),(0,P.useEffect)(()=>{h.current=!1,g.current=!1,U.current=null},[t]);let Fe=(0,P.useMemo)(()=>je||I,[je,I]),Ie=(0,P.useCallback)(e=>{try{let n=JSON.parse(e.data);if(ue(n)){let e=!A.getState().eventIds.has(n.id)&&me(n)?n:null;if(b(n),oe(n)){let e=n;K({message:e.detail,source:`conversation`,metadata:{eventId:e.id,errorCode:e.code},posthog:v}),C(e.detail)}else q();if(T(n)&&K({message:n.error,source:`agent`,metadata:{eventId:n.id,toolName:n.tool_name,toolCallId:n.tool_call_id},posthog:v}),re(n)&&t&&(k(t,ke(n)),te(t,{draftMessage:null})),O(n)&&Se(n,t||`test-conversation-id`,y),E(n)&&(se(n)&&j(n.value.execution_status),fe(n)&&j(n.value),ie(n)&&J(n)),de(n)&&M(n.action.command),le(n)&&N(n.observation.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
2
|
+
`)),ce(n)){let{screenshot_data:e}=n.observation;if(e){let t=e.startsWith(`data:`)?e:`data:image/png;base64,${e}`;_e.getState().setScreenshotSrc(t)}}ae(n)&&_e.getState().setUrl(n.action.url),t&&e&&!e.observation.is_error&&(Ee(t,e.observation.profile_name),e.observation.active_model&&i(y,t,e.observation.active_model),r(y,t)),pe(n)&&xe(n.action)}}catch(e){console.warn(`Failed to parse WebSocket message as JSON:`,e)}},[b,C,k,y,t,j,M,N,J,q,v]),Le=(0,P.useCallback)(e=>{try{let n=JSON.parse(e.data);if(I&&(H.current+=1,R!==null&&H.current>=R&&L(!1)),ue(n)){if(b({...n,isFromPlanningAgent:!0}),oe(n)){let e=n;K({message:e.detail,source:`planning_conversation`,metadata:{eventId:e.id,errorCode:e.code},posthog:v}),C(e.detail)}else q();if(T(n)&&K({message:n.error,source:`planning_agent`,metadata:{eventId:n.id,toolName:n.tool_name,toolCallId:n.tool_call_id},posthog:v}),re(n)&&t&&(k(t,ke(n)),te(t,{draftMessage:null})),O(n)&&Se(n,o?.[0]?.id||`test-conversation-id`,y),E(n)&&(se(n)&&j(n.value.execution_status),fe(n)&&j(n.value),ie(n)&&J(n)),de(n)&&M(n.action.command),le(n)&&N(n.observation.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
3
|
+
`)),he(n)){let{path:e}=n.observation;if(W(e)){let t=o?.[0]?.id;t&&e&&(I?U.current={path:e,conversationId:t}:V({conversationId:t,filePath:e},{onSuccess:e=>{B(e)},onError:e=>{console.warn(`Failed to read conversation file:`,e)}}))}}}}catch(e){console.warn(`Failed to parse WebSocket message as JSON:`,e)}},[b,I,R,C,k,y,o,t,j,M,N,V,B,J,q,v]),Re=(0,P.useMemo)(()=>{let e=Me?{resend_mode:`since`,after_timestamp:Me}:{resend_mode:`all`};return a&&(e.session_api_key=a),{queryParams:e,reconnect:{enabled:!0},onOpen:()=>{u(`OPEN`),h.current=!0,D()},onClose:()=>{u(`CLOSED`)},onError:()=>{u(`CLOSED`),h.current&&C(F,`connection`)},onMessage:Ie}},[Ie,C,D,a,Me]),ze=(0,P.useMemo)(()=>{let e={resend_all:!0};a&&(e.session_api_key=a);let t=o?.[0];return{queryParams:e,reconnect:{enabled:!0},onOpen:async()=>{if(f(`OPEN`),g.current=!0,D(),t?.id&&t.conversation_url)try{let e=await G.getEventCount(t.id,t.conversation_url,t.session_api_key);z(e),e===0&&L(!1)}catch{L(!1)}},onClose:()=>{f(`CLOSED`)},onError:()=>{f(`CLOSED`),g.current&&C(F,`connection`)},onMessage:Le}},[Le,C,D,a,o]),{socket:Q,reconnect:Be}=ve(Ne||``,Re),{socket:$,reconnect:Ve}=ve(Z||``,ze),He=(0,P.useCallback)(()=>{if(w(),S.getState().conversationMode===`plan`&&Z){Ve();return}Be()},[Z,Be,Ve,w]),Ue=(0,P.useCallback)(async e=>{let n=S.getState().conversationMode===`plan`?$:Q;if(n?.readyState!==WebSocket.OPEN){if(!t){let e=Error(`No conversation ID available`);throw C(e.message),e}try{return await new _(p()).sendEvent(t,{role:`user`,content:e.content},{run:!0}),{queued:!0}}catch(e){throw C(e instanceof Error?e.message:`Failed to queue message for delivery`),e}}try{return n.send(JSON.stringify({...e,run:!0})),{queued:!1}}catch(e){throw C(e instanceof Error?e.message:`Failed to send message`),e}},[Q,$,C,t]);(0,P.useEffect)(()=>{Q&&Ne&&(()=>{switch(Q.readyState){case WebSocket.CONNECTING:u(`CONNECTING`);break;case WebSocket.OPEN:u(`OPEN`);break;case WebSocket.CLOSING:u(`CLOSING`);break;case WebSocket.CLOSED:u(`CLOSED`);break;default:u(`CLOSED`);break}})()},[Q,Ne]),(0,P.useEffect)(()=>{$&&Z&&(()=>{switch($.readyState){case WebSocket.CONNECTING:f(`CONNECTING`);break;case WebSocket.OPEN:f(`OPEN`);break;case WebSocket.CLOSING:f(`CLOSING`);break;case WebSocket.CLOSED:f(`CLOSED`);break;default:f(`CLOSED`);break}})()},[$,Z]);let We=(0,P.useMemo)(()=>({connectionState:Pe,sendMessage:Ue,isLoadingHistory:Fe,reconnect:He}),[Pe,Ue,Fe,He]);return(0,De.jsx)(Oe.Provider,{value:We,children:e})}var Ae=()=>(0,P.useContext)(Oe)||null;export{J as a,we as c,be as d,ye as f,Y as i,G as l,N as m,Ae as n,q as o,F as p,Ee as r,Te as s,X as t,W as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./react-dom-hVBnwgwZ.js";import{t as r}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~kyz9p27j-DlKA6SoO.js";import{t as i}from"./useMutation-CRJwk4cR.js";import{o as a,t as o}from"./declaration-C9nuq2Dj.js";import{n as s}from"./QueryClientProvider-DITRCGAK.js";import{t as c}from"./useTranslation-01pF7z10.js";import{n as l,r as u}from"./custom-toast-handlers-BYxhSr3t.js";import{t as d}from"./utils-Czcl6buL.js";import{c as f,u as p}from"./agent-server-client-options-8OJSXbm8.js";import{n as m}from"./active-backend-context-CkP3ZEJs.js";import{a as h,s as g,t as _}from"./brand-button-8fVVei4i.js";import{n as ee,r as v}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~pfbaerbd-zhv9fooy.js";import{t as y}from"./proxy-BMZyC45G.js";import{t as te}from"./settings-input-BWCZt9g2.js";import{n as b,t as ne}from"./context-menu-list-item-DzjPB8aC.js";import{t as x}from"./settings-dropdown-input-CAQWQgx-.js";import{t as S}from"./x-mark-CZ57VvRX.js";var C=`/api/automation`,w=v.create();w.interceptors.request.use(e=>{e.baseURL||=p().host;let t=(void 0)?.trim();return t&&e.headers.set(`X-Session-API-Key`,t),e});function T(e,t){let n=new URLSearchParams;return n.set(`limit`,String(e)),n.set(`offset`,String(t)),n.toString()}var E=class e{static async listAutomations(e={}){let{limit:t=50,offset:n=0}=e,r=f().backend;if(r.kind===`cloud`)return y({backend:r,method:`GET`,path:`${C}/v1?${T(t,n)}`});let{data:i}=await w.get(`${C}/v1`,{params:{limit:t,offset:n}});return i}static async getAutomations(t=50,n=0){return e.listAutomations({limit:t,offset:n})}static async getAutomation(e){let t=f().backend,n=`${C}/v1/${encodeURIComponent(e)}`;if(t.kind===`cloud`)return y({backend:t,method:`GET`,path:n});let{data:r}=await w.get(n);return r}static async updateAutomation(e,t){let n=f().backend,r=`${C}/v1/${encodeURIComponent(e)}`;if(n.kind===`cloud`)return y({backend:n,method:`PATCH`,path:r,body:t});let{data:i}=await w.patch(r,t);return i}static async deleteAutomation(e){let t=f().backend,n=`${C}/v1/${encodeURIComponent(e)}`;if(t.kind===`cloud`){await y({backend:t,method:`DELETE`,path:n});return}await w.delete(n)}static async dispatchAutomation(e){let t=f().backend,n=`${C}/v1/${encodeURIComponent(e)}/dispatch`;if(t.kind===`cloud`)return y({backend:t,method:`POST`,path:n});let{data:r}=await w.post(n);return r}static async listAutomationRuns(e,t={}){let{limit:n=50,offset:r=0}=t,i=f().backend,a=`${C}/v1/${encodeURIComponent(e)}/runs`;if(i.kind===`cloud`)return y({backend:i,method:`GET`,path:`${a}?${T(n,r)}`});let{data:o}=await w.get(a,{params:{limit:n,offset:r}});return o}static async getAutomationRuns(t,n=50,r=0){return e.listAutomationRuns(t,{limit:n,offset:r})}static async toggleAutomation(t,n){return e.updateAutomation(t,{enabled:n})}static async downloadTarball(e,t){let n=f().backend,r=`${C}/v1/${encodeURIComponent(e)}/tarball`,i;if(n.kind===`cloud`)i=await y({backend:n,method:`GET`,path:r,responseType:`blob`});else{let{data:e}=await w.get(r,{responseType:`blob`});i=e}let a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`${t}.tar`,o.click(),URL.revokeObjectURL(a)}static async checkHealth(){let e=f().backend,t=`${C}/health`;try{if(e.kind===`cloud`)return await y({backend:e,method:`GET`,path:t});let{data:n}=await w.get(t,{timeout:5e3});return n}catch{return{status:`error`}}}},D=e(t()),re=e(n(),1),O=a(),k=[`automation-detail`],A=[`automation-runs`];function ie(e){let{id:t,enabled:n=!0}=e,i=m();return r({queryKey:[...k,t,i.backend.id,i.orgId],queryFn:()=>E.getAutomation(t),staleTime:300*1e3,enabled:!!t&&n})}function j(e){let{id:t,limit:n=20,offset:i=0,enabled:a=!0}=e,o=m();return r({queryKey:[...A,t,{limit:n,offset:i},o.backend.id,o.orgId],queryFn:()=>E.getAutomationRuns(t,n,i),staleTime:60*1e3,enabled:!!t&&a})}var M=[`automations`];function N(e={}){let{limit:t=50,offset:n=0,enabled:i=!0}=e,a=m();return r({queryKey:[...M,{limit:t,offset:n},a.backend.id,a.orgId],queryFn:()=>E.getAutomations(t,n),staleTime:0,enabled:i})}function P(){let e=s();return i({mutationFn:({id:e,enabled:t})=>E.toggleAutomation(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:M}),e.invalidateQueries({queryKey:k})}})}function F(){let e=s();return i({mutationFn:({id:e,body:t})=>E.updateAutomation(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:M}),e.invalidateQueries({queryKey:k})}})}function I(){let e=s();return i({mutationFn:e=>E.deleteAutomation(e),onSuccess:()=>{e.invalidateQueries({queryKey:M})}})}function L(){let e=s();return i({mutationFn:e=>E.dispatchAutomation(e),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:M}),e.invalidateQueries({queryKey:k}),e.invalidateQueries({queryKey:[...A,n]})}})}var R=[`automation-health`];function z(){let e=m();return r({queryKey:[...R,e.backend.id,e.orgId],queryFn:()=>E.checkHealth(),staleTime:30*1e3,retry:!1})}var B=e=>(0,O.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`currentColor`,viewBox:`0 0 20 20`,...e,children:(0,O.jsx)(`path`,{d:`M10 6a2 2 0 110-4 2 2 0 010 4zm0 6a2 2 0 110-4 2 2 0 010 4zm0 6a2 2 0 110-4 2 2 0 010 4z`})}),V=`inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent text-muted transition-colors hover:bg-interactive-hover hover:text-white focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted`,H=`inline-flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-md border-0 bg-transparent px-2 text-xs text-muted transition-colors hover:bg-interactive-hover hover:text-white focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted`;function U({icon:e,label:t}){return(0,O.jsxs)(`span`,{className:`flex min-w-0 w-full items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`flex shrink-0 items-center text-[var(--oh-muted)] transition-colors group-hover:text-[var(--oh-foreground)] group-focus-visible:text-[var(--oh-foreground)] [&_svg]:size-4 [&_svg]:text-current`,"aria-hidden":!0,children:e}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t})]})}function W({items:e}){let{t}=c(`openhands`),[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(),s=(0,D.useRef)(null),l=(0,D.useRef)(null);(0,D.useLayoutEffect)(()=>{if(!n||!s.current)return;let e=()=>{let e=s.current?.getBoundingClientRect();e&&a({position:`fixed`,zIndex:9999,top:e.bottom+4,right:window.innerWidth-e.right})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[n]),(0,D.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.target;s.current?.contains(t)||l.current?.contains(t)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let u=n&&i?(0,O.jsx)(b,{ref:l,theme:`popover`,className:`min-w-[10rem]`,children:e.map(e=>(0,O.jsx)(`li`,{children:(0,O.jsx)(ne,{onClick:t=>{t.stopPropagation(),e.onClick(),r(!1)},isDisabled:e.disabled,className:`group`,children:(0,O.jsx)(U,{icon:e.icon,label:e.label})})},e.label))}):null;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{ref:s,type:`button`,onClick:e=>{e.stopPropagation(),r(e=>!e)},className:V,"aria-label":t(o.AUTOMATIONS$ACTIONS_MENU),"aria-expanded":n,"aria-haspopup":`menu`,children:(0,O.jsx)(B,{className:`size-4`})}),n&&i&&typeof document<`u`?re.createPortal((0,O.jsx)(`div`,{style:i,children:u}),document.body):null]})}function G(e){return!0}var K=e=>(0,O.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,O.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z`})}),q=e=>(0,O.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,O.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5.636 5.636a9 9 0 1012.728 0M12 3v9`})}),J=e=>(0,O.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,O.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})}),Y=e=>(0,O.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:1.5,...e,children:(0,O.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z`})});function ae({onRetry:e}){let{t}=c(`openhands`);return(0,O.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20`,children:[(0,O.jsx)(Y,{className:`size-12 text-danger`}),(0,O.jsx)(`p`,{className:`mt-4 text-sm text-muted`,children:t(o.AUTOMATIONS$ERROR_TITLE)}),(0,O.jsx)(`button`,{type:`button`,onClick:e,className:`mt-4 rounded-lg border border-[var(--oh-border)] px-4 py-2 text-sm text-white hover:bg-surface-raised`,children:t(o.AUTOMATIONS$ERROR_RETRY)})]})}function oe({onRetry:e}){let{t}=c(`openhands`);return(0,O.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 px-4`,children:[(0,O.jsx)(Y,{className:`size-12 text-[var(--oh-warning)]`}),(0,O.jsx)(`h2`,{className:`mt-4 text-lg font-medium text-content`,children:t(o.AUTOMATIONS$BACKEND_UNAVAILABLE_TITLE)}),(0,O.jsx)(`p`,{className:`mt-2 text-sm text-muted text-center max-w-md`,children:t(o.AUTOMATIONS$BACKEND_UNAVAILABLE_MESSAGE)}),(0,O.jsx)(_,{type:`button`,variant:`secondary`,className:`mt-6`,onClick:e,children:t(o.AUTOMATIONS$BACKEND_UNAVAILABLE_RETRY)})]})}function se({automationName:e,isOpen:t,onConfirm:n,onCancel:r}){let{t:i}=c(`openhands`);return t?(0,O.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,O.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:r,onKeyDown:e=>{e.key===`Escape`&&r()},role:`presentation`}),(0,O.jsxs)(`div`,{className:`relative w-full max-w-sm rounded-xl border border-[var(--oh-border)] bg-[var(--oh-surface)] p-6`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:r,className:`absolute right-4 top-4 text-muted hover:text-foreground`,"aria-label":`Close`,children:(0,O.jsx)(S,{className:`size-5`})}),(0,O.jsx)(`h2`,{className:`text-lg font-medium text-white`,children:i(o.AUTOMATIONS$DELETE_CONFIRM_TITLE)}),(0,O.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:i(o.AUTOMATIONS$DELETE_CONFIRM_MESSAGE,{name:e})}),(0,O.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg border border-[var(--oh-border)] px-4 py-2 text-sm text-white hover:bg-surface-raised`,children:i(o.AUTOMATIONS$CANCEL)}),(0,O.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-lg bg-danger px-4 py-2 text-sm text-white hover:bg-danger/80`,children:i(o.AUTOMATIONS$DELETE)})]})]})]}):null}var ce=/^(\d+)$/;function X(e,t,n){let r=e.match(ce);if(!r)return null;let i=Number(r[1]);return Number.isNaN(i)||i<t||i>n?null:i}function Z(e){let t=(e??``).trim();if(!t)return{kind:`custom`,raw:``};let n=t.split(/\s+/);if(n.length!==5)return{kind:`custom`,raw:t};let[r,i,a,o,s]=n,c=X(r,0,59),l=X(i,0,23);if(c===null||l===null)return{kind:`custom`,raw:t};if(a!==`*`||o!==`*`)return{kind:`custom`,raw:t,hour:l,minute:c};if(s===`*`||s===`0-6`)return{kind:`daily`,hour:l,minute:c};if(s===`1-5`)return{kind:`weekdays`,hour:l,minute:c};let u=X(s,0,6);return u===null?{kind:`custom`,raw:t,hour:l,minute:c}:{kind:`weekly`,hour:l,minute:c,weekday:u}}function le(e){let{kind:t,hour:n,minute:r,weekday:i}=e;switch(t){case`daily`:return`${r} ${n} * * *`;case`weekdays`:return`${r} ${n} * * 1-5`;case`weekly`:return`${r} ${n} * * ${i??1}`;default:return t}}function Q(e,t){return`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`}function $(e){let t=e.match(/^(\d{1,2}):(\d{2})$/);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return Number.isNaN(n)||Number.isNaN(r)||n<0||n>23||r<0||r>59?null:{hour:n,minute:r}}var ue=[o.AUTOMATIONS$WEEKDAY_SUN,o.AUTOMATIONS$WEEKDAY_MON,o.AUTOMATIONS$WEEKDAY_TUE,o.AUTOMATIONS$WEEKDAY_WED,o.AUTOMATIONS$WEEKDAY_THU,o.AUTOMATIONS$WEEKDAY_FRI,o.AUTOMATIONS$WEEKDAY_SAT];function de(e){let t=Z(e.trigger.schedule);return t.kind===`custom`?{name:e.name,prompt:e.prompt??``,frequency:`custom`,weekday:1,timeOfDay:t.hour!==void 0&&t.minute!==void 0?Q(t.hour,t.minute):``,isCustomSchedule:!0,rawSchedule:t.raw}:{name:e.name,prompt:e.prompt??``,frequency:t.kind,weekday:t.kind===`weekly`?t.weekday??1:1,timeOfDay:Q(t.hour,t.minute),isCustomSchedule:!1,rawSchedule:e.trigger.schedule??``}}function fe({automation:e,isOpen:t,onClose:n}){let{t:r}=c(`openhands`),i=F(),a=(0,D.useMemo)(()=>de(e),[e]),[s,f]=(0,D.useState)(a),[p,m]=(0,D.useState)(null);if((0,D.useEffect)(()=>{t&&(f(a),m(null))},[t,a]),!t)return null;let v=[{key:`daily`,label:r(o.AUTOMATIONS$FREQUENCY_DAILY)},{key:`weekdays`,label:r(o.AUTOMATIONS$FREQUENCY_WEEKDAYS)},{key:`weekly`,label:r(o.AUTOMATIONS$FREQUENCY_WEEKLY)},...s.isCustomSchedule?[{key:`custom`,label:r(o.AUTOMATIONS$FREQUENCY_CUSTOM)}]:[]],y=ue.map((e,t)=>({key:String(t),label:r(e)})),b=!s.isCustomSchedule||$(s.timeOfDay)!==null||s.timeOfDay===``;return(0,O.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,O.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`presentation`}),(0,O.jsxs)(`div`,{className:`relative w-full max-w-md rounded-xl border border-[var(--oh-border)] bg-[var(--oh-surface)] p-6`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:n,className:`absolute right-4 top-4 text-muted hover:text-foreground`,"aria-label":r(o.AUTOMATIONS$CANCEL),children:(0,O.jsx)(S,{className:`size-5`})}),(0,O.jsx)(`h2`,{className:`text-lg font-medium text-white`,children:r(o.AUTOMATIONS$EDIT_TITLE)}),(0,O.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let a=s.name.trim();if(!a){m(r(o.AUTOMATIONS$NAME_REQUIRED));return}m(null);let c={};a!==e.name&&(c.name=a);let d=s.prompt.trim();if(d!==(e.prompt??``).trim()&&(c.prompt=d.length===0?null:d),!s.isCustomSchedule&&s.frequency!==`custom`){let t=$(s.timeOfDay);if(t){let n=le({kind:s.frequency,hour:t.hour,minute:t.minute,weekday:s.frequency===`weekly`?s.weekday:void 0});n!==e.trigger.schedule&&(c.trigger={...e.trigger,schedule:n})}}if(Object.keys(c).length===0){n();return}i.mutate({id:e.id,body:c},{onSuccess:()=>{u(r(o.AUTOMATIONS$EDIT_SUCCESS)),n()},onError:e=>{l(ee(e)?e.response?.data?.message||e.message||r(o.AUTOMATIONS$EDIT_ERROR):e.message||r(o.AUTOMATIONS$EDIT_ERROR))}})},className:`mt-4 flex flex-col gap-4`,"aria-label":r(o.AUTOMATIONS$EDIT_TITLE),children:[(0,O.jsx)(te,{testId:`edit-automation-name`,name:`name`,type:`text`,label:r(o.AUTOMATIONS$NAME),value:s.name,onChange:e=>f(t=>({...t,name:e})),error:p??void 0,showRequiredTag:!0}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-2.5 w-full min-w-0`,children:[(0,O.jsx)(`span`,{className:`text-sm`,children:r(o.AUTOMATIONS$PROMPT)}),(0,O.jsx)(`textarea`,{"data-testid":`edit-automation-prompt`,name:`prompt`,value:s.prompt,onChange:e=>f(t=>({...t,prompt:e.target.value})),rows:4,className:d(h,`placeholder:italic`)}),(0,O.jsx)(`span`,{className:`text-xs text-muted`,children:r(o.AUTOMATIONS$EDIT_PROMPT_HINT)})]}),(0,O.jsx)(x,{testId:`edit-automation-frequency`,name:`frequency`,label:r(o.AUTOMATIONS$FREQUENCY),items:v,selectedKey:s.frequency,isDisabled:s.isCustomSchedule,onSelectionChange:e=>{!e||s.isCustomSchedule||f(t=>({...t,frequency:e}))}}),s.frequency===`weekly`&&!s.isCustomSchedule&&(0,O.jsx)(x,{testId:`edit-automation-weekday`,name:`weekday`,label:r(o.AUTOMATIONS$WEEKDAY),items:y,selectedKey:String(s.weekday),onSelectionChange:e=>{e!==null&&f(t=>({...t,weekday:Number(e)}))}}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-2.5 w-full min-w-0`,children:[(0,O.jsx)(`span`,{className:`text-sm`,children:r(o.AUTOMATIONS$TIME_OF_DAY)}),(0,O.jsx)(`input`,{"data-testid":`edit-automation-time`,name:`timeOfDay`,type:`time`,value:s.timeOfDay,onChange:e=>f(t=>({...t,timeOfDay:e.target.value})),disabled:s.isCustomSchedule&&!b,className:d(g,`disabled:bg-[var(--oh-surface-raised)]`)}),e.timezone&&(0,O.jsxs)(`span`,{className:`text-xs text-muted`,children:[r(o.AUTOMATIONS$TIMEZONE),`: `,e.timezone]})]}),s.isCustomSchedule&&(0,O.jsxs)(`p`,{className:`text-xs text-muted`,"data-testid":`custom-schedule-hint`,children:[r(o.AUTOMATIONS$CUSTOM_SCHEDULE_HINT),s.rawSchedule&&(0,O.jsxs)(O.Fragment,{children:[` `,(0,O.jsx)(`code`,{className:`text-xs text-content`,children:s.rawSchedule})]})]}),(0,O.jsxs)(`div`,{className:`mt-2 flex justify-end gap-3`,children:[(0,O.jsx)(_,{testId:`edit-automation-cancel`,type:`button`,variant:`secondary`,onClick:n,isDisabled:i.isPending,children:r(o.AUTOMATIONS$CANCEL)}),(0,O.jsx)(_,{testId:`edit-automation-save`,type:`submit`,variant:`primary`,isDisabled:i.isPending,"aria-busy":i.isPending,children:i.isPending?r(o.AUTOMATIONS$SAVING):r(o.AUTOMATIONS$SAVE)})]})]})]})]})}export{P as _,Y as a,E as b,K as c,V as d,H as f,L as g,I as h,ae as i,G as l,N as m,se as n,J as o,z as p,oe as r,q as s,fe as t,W as u,ie as v,j as y};
|