@capagents/forgeqe 2.9.2 → 2.9.3
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/dist/docs-site/docs/architecture/index.html +6 -0
- package/dist/docs-site/docs/search.js +1 -1
- package/dist/docs-site/docs/web-app/index.html +12 -1
- package/dist/forgeqe.js +1717 -1677
- package/dist/web/assets/{Agent-BFwkMMHm.js → Agent-B6xfobJ9.js} +3 -3
- package/dist/web/assets/{ApiTests-Bgt4R_yB.js → ApiTests-BwgezlYi.js} +3 -3
- package/dist/web/assets/Browse-DDzk_KTh.js +2 -0
- package/dist/web/assets/Chat-BdlfK2ra.js +3 -0
- package/dist/web/assets/{CommandPalette-nmLCmEsp.js → CommandPalette-Cla7m818.js} +1 -1
- package/dist/web/assets/{Compare-CGcGp9qD.js → Compare-BxUfo0rI.js} +1 -1
- package/dist/web/assets/{Cost-BvCShgln.js → Cost-Dpa8aWQG.js} +1 -1
- package/dist/web/assets/{Data-3EEe7vIz.js → Data-D_7m2GL6.js} +2 -2
- package/dist/web/assets/Desktop-CgslBkAr.js +1 -0
- package/dist/web/assets/DesktopReview-CsW65QZz.js +1 -0
- package/dist/web/assets/{Evidence-D1HiXQK6.js → Evidence-SYt-mbDx.js} +1 -1
- package/dist/web/assets/{Explore-2M7wI0Sf.js → Explore--B18Jvg9.js} +1 -1
- package/dist/web/assets/{Features-DmQ5JiMI.js → Features-BerYifH7.js} +1 -1
- package/dist/web/assets/{Flags-Bg-l5HxL.js → Flags-ABMq---p.js} +1 -1
- package/dist/web/assets/{Flaky-DJlkxmHT.js → Flaky-DKeceXsa.js} +1 -1
- package/dist/web/assets/{ForceGraph-B5i3Ewd5.js → ForceGraph-C9HFjZX3.js} +1 -1
- package/dist/web/assets/{Impact-huKs-mOc.js → Impact-DQ2c0dTT.js} +1 -1
- package/dist/web/assets/{Jobs-BwK79TQ8.js → Jobs-Dy_C2x36.js} +2 -2
- package/dist/web/assets/{KindPage-C0MoC9da.js → KindPage-DQzstMyM.js} +4 -4
- package/dist/web/assets/{Migration-CTVyQeqW.js → Migration-B4GWsCLR.js} +1 -1
- package/dist/web/assets/{Product-BHqJVCMn.js → Product-CgVhHMMY.js} +1 -1
- package/dist/web/assets/{Production-GL8lbwxD.js → Production-OdB4gZ3T.js} +1 -1
- package/dist/web/assets/{Quality-jI3YgvqZ.js → Quality-DOV4suvD.js} +1 -1
- package/dist/web/assets/{Readiness-B3OZ51FG.js → Readiness-DawfUUHc.js} +1 -1
- package/dist/web/assets/Record-C9uAKGYM.js +2 -0
- package/dist/web/assets/{Regression-v2dpbgs4.js → Regression-DZdddPfI.js} +2 -2
- package/dist/web/assets/{Reports-BAat71wo.js → Reports-BHOS6af1.js} +1 -1
- package/dist/web/assets/{Response-DjqmewrL.js → Response-qfMk4Nrh.js} +1 -1
- package/dist/web/assets/{RunDiff-BbBom2fJ.js → RunDiff-BNywFV7t.js} +1 -1
- package/dist/web/assets/{Runs-CIQWWRl3.js → Runs-BJPYXRiB.js} +1 -1
- package/dist/web/assets/{Steps-DfNHCe8N.js → Steps-Cdzyueit.js} +1 -1
- package/dist/web/assets/{TestCases-8BBW6RSi.js → TestCases-DcYY2l9q.js} +1 -1
- package/dist/web/assets/{TestData-BFkACDve.js → TestData-CrzKA3xh.js} +1 -1
- package/dist/web/assets/{TestDebt-CUcklHEN.js → TestDebt-CVDJT511.js} +1 -1
- package/dist/web/assets/Tosca-CBwGCrbL.js +3 -0
- package/dist/web/assets/{WhatsNew-CBS7kmGu.js → WhatsNew-CIOTidx-.js} +1 -1
- package/dist/web/assets/{dataParts-B3Fz4S59.js → dataParts-CUb0Q0IZ.js} +1 -1
- package/dist/web/assets/{families-BiqSaqoO.js → families-C9MndVzT.js} +1 -1
- package/dist/web/assets/filters-Bk7ovF3M.js +1 -0
- package/dist/web/assets/{fold-b2g0_ndv.js → fold-97yBCSav.js} +1 -1
- package/dist/web/assets/frame-CqWJMIHh.js +4 -0
- package/dist/web/assets/index-ASvNRLI7.js +73 -0
- package/dist/web/assets/index-B5o9vY-v.css +2 -0
- package/dist/web/assets/{logos-DSveGjIW.js → logos-CbNeXLAM.js} +1 -1
- package/dist/web/assets/{palette-CF8GLAVN.js → palette-Dg3RS-ff.js} +1 -1
- package/dist/web/assets/{parts-D7OvxdrL.js → parts-CPAyV15O.js} +1 -1
- package/dist/web/assets/{productParts-BDM3LIjp.js → productParts-BpXw1jMa.js} +1 -1
- package/dist/web/assets/{qualityParts-DP09bVel.js → qualityParts-8TPKphgl.js} +1 -1
- package/dist/web/assets/recordTest-DvnpHsd2.js +1 -0
- package/dist/web/assets/{rows-B0vZ5x5N.js → rows-BdYJLCRD.js} +1 -1
- package/dist/web/assets/{segmented-BfWimTC0.js → segmented-DlF5rvSR.js} +1 -1
- package/dist/web/assets/{thread-DASfqw-f.js → thread-DlyX7xQt.js} +1 -1
- package/dist/web/assets/{usePageChat-BLEUldCJ.js → usePageChat-Dhu3upXA.js} +1 -1
- package/dist/web/index.html +4 -4
- package/docs/ARCHITECTURE.md +5 -0
- package/docs/WEB_APP.md +17 -1
- package/forgeqe.example.yaml +1 -0
- package/package.json +1 -1
- package/py/forgeqe_desktop/agentdesktop_driver.py +69 -0
- package/py/forgeqe_desktop/boxes.py +32 -0
- package/py/forgeqe_desktop/handhooks.py +55 -5
- package/py/forgeqe_desktop/pywinauto_driver.py +25 -0
- package/py/forgeqe_desktop/service.py +85 -3
- package/py/forgeqe_engine/brand.py +3 -0
- package/py/forgeqe_engine/browser.py +46 -6
- package/py/forgeqe_engine/cli.py +10 -1
- package/py/forgeqe_engine/recordsession.py +92 -2
- package/py/forgeqe_engine/video.py +423 -0
- package/py/forgeqe_mobile/hyperexecute.py +1 -1
- package/py/forgeqe_mobile/maestro.py +1 -1
- package/py/forgeqe_tosca/vendored.py +3 -2
- package/dist/web/assets/Browse-B3YI1MeV.js +0 -2
- package/dist/web/assets/Chat-K3kp-ji2.js +0 -3
- package/dist/web/assets/Desktop-Drj-7jBV.js +0 -1
- package/dist/web/assets/Record-Yw-SGwQ9.js +0 -2
- package/dist/web/assets/Tosca-DTWwUJBW.js +0 -3
- package/dist/web/assets/desktopAppPath-CMac6aJ0.js +0 -1
- package/dist/web/assets/filters-B4VDnWbr.js +0 -1
- package/dist/web/assets/frame-D-hqu7Oi.js +0 -4
- package/dist/web/assets/index-CtX74khE.js +0 -45
- package/dist/web/assets/index-DUf5ddb0.css +0 -2
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Videos of what ForgeQE drives where browser-use's recorder (``start_video`` in browser.py) does not reach: a recording
|
|
3
|
+
by hand (the tester's tab, over the recorder's own DevTools connection), a replay (the frames Playwright's runner kept),
|
|
4
|
+
and a desktop run (the screen).
|
|
5
|
+
|
|
6
|
+
Every video is ``video.mp4`` (H.264), made by the ffmpeg that the pinned ``imageio-ffmpeg`` package ships inside
|
|
7
|
+
itself: found in the package's own ``binaries`` folder, never on PATH and never through ``IMAGEIO_FFMPEG_EXE``, started
|
|
8
|
+
with an argument list and system settings only. Frames reach it on stdin as raw RGB pixels of a fixed size, so nothing
|
|
9
|
+
a page or an app shows ever reaches its command line. A video runs in real time at ``FPS`` frames a second (the
|
|
10
|
+
latest picture is repeated while nothing changes), stops growing after ``MAX_SECONDS``, and a video that could not be
|
|
11
|
+
finished is removed rather than kept half written.
|
|
12
|
+
"""
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import io
|
|
16
|
+
import json
|
|
17
|
+
import os
|
|
18
|
+
import re
|
|
19
|
+
import subprocess
|
|
20
|
+
import sys
|
|
21
|
+
import threading
|
|
22
|
+
import time
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
from typing import Any, Callable, Dict, List, Optional, Tuple
|
|
25
|
+
|
|
26
|
+
VIDEO_FILE = "video.mp4"
|
|
27
|
+
FPS = 5
|
|
28
|
+
MAX_SECONDS = 3600
|
|
29
|
+
# Pictures are made smaller to fit, never larger: a 4K screen is a 1920-wide video.
|
|
30
|
+
MAX_WIDTH = 1920
|
|
31
|
+
MAX_HEIGHT = 1200
|
|
32
|
+
FINISH_SECONDS = 120.0
|
|
33
|
+
# A replay's frames: <ms since the start>.jpg, written by its runner (src/code/replay.ts).
|
|
34
|
+
FRAME_NAME = re.compile(r"^(\d{1,9})\.jpg$")
|
|
35
|
+
MAX_FRAMES = 20000
|
|
36
|
+
MAX_FRAME_BYTES = 8 * 1024 * 1024
|
|
37
|
+
_ENV_KEEP = ("SYSTEMROOT", "WINDIR", "TMP", "TEMP", "TMPDIR", "LANG", "LC_ALL")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def ffmpeg_exe() -> Optional[str]:
|
|
41
|
+
"""The ffmpeg inside the imageio-ffmpeg package, or None when the package (or its binary) is not there."""
|
|
42
|
+
try:
|
|
43
|
+
import imageio_ffmpeg
|
|
44
|
+
except Exception:
|
|
45
|
+
return None
|
|
46
|
+
folder = Path(imageio_ffmpeg.__file__).resolve().parent / "binaries"
|
|
47
|
+
try:
|
|
48
|
+
found = sorted(p for p in folder.iterdir() if p.name.startswith("ffmpeg-") and p.is_file() and not p.is_symlink())
|
|
49
|
+
except OSError:
|
|
50
|
+
return None
|
|
51
|
+
for exe in found:
|
|
52
|
+
if sys.platform == "win32" and exe.suffix.lower() != ".exe":
|
|
53
|
+
continue
|
|
54
|
+
if sys.platform == "win32" or os.access(exe, os.X_OK):
|
|
55
|
+
return str(exe)
|
|
56
|
+
return None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def video_ready() -> bool:
|
|
60
|
+
try:
|
|
61
|
+
import PIL # noqa: F401
|
|
62
|
+
except Exception:
|
|
63
|
+
return False
|
|
64
|
+
return ffmpeg_exe() is not None
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _even(n: int) -> int:
|
|
68
|
+
return max(2, n - (n % 2))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def fit_size(width: int, height: int, max_width: int = MAX_WIDTH, max_height: int = MAX_HEIGHT) -> Tuple[int, int]:
|
|
72
|
+
"""The video's size for pictures of this size: as large, or smaller to fit, and even on both sides (H.264 wants it)."""
|
|
73
|
+
width, height = max(2, int(width)), max(2, int(height))
|
|
74
|
+
scale = min(1.0, max_width / width, max_height / height)
|
|
75
|
+
return _even(round(width * scale)), _even(round(height * scale))
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def ffmpeg_args(exe: str, size: Tuple[int, int], fps: int, out: Path) -> List[str]:
|
|
79
|
+
w, h = size
|
|
80
|
+
return [
|
|
81
|
+
exe, "-hide_banner", "-loglevel", "error", "-y",
|
|
82
|
+
"-f", "rawvideo", "-pix_fmt", "rgb24", "-s", f"{w}x{h}", "-r", str(fps), "-i", "-",
|
|
83
|
+
"-an", "-c:v", "libx264", "-preset", "veryfast", "-crf", "28", "-pix_fmt", "yuv420p", "-movflags", "+faststart",
|
|
84
|
+
str(out),
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _child_env() -> Dict[str, str]:
|
|
89
|
+
"""System settings only: ffmpeg needs nothing of ForgeQE's."""
|
|
90
|
+
keep = {k.upper() for k in _ENV_KEEP} if sys.platform == "win32" else set(_ENV_KEEP)
|
|
91
|
+
return {k: v for k, v in os.environ.items() if (k.upper() if sys.platform == "win32" else k) in keep}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _picture(data: Any) -> Any:
|
|
95
|
+
"""A PIL image in RGB from an image or the bytes of a JPEG or PNG; None when it is neither."""
|
|
96
|
+
from PIL import Image
|
|
97
|
+
|
|
98
|
+
try:
|
|
99
|
+
if isinstance(data, Image.Image):
|
|
100
|
+
img = data
|
|
101
|
+
else:
|
|
102
|
+
if not isinstance(data, (bytes, bytearray)) or len(data) > MAX_FRAME_BYTES:
|
|
103
|
+
return None
|
|
104
|
+
img = Image.open(io.BytesIO(bytes(data)))
|
|
105
|
+
img.load()
|
|
106
|
+
return img.convert("RGB") if img.mode != "RGB" else img
|
|
107
|
+
except Exception:
|
|
108
|
+
return None
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _letterbox(img: Any, size: Tuple[int, int]) -> bytes:
|
|
112
|
+
"""The picture fitted into the video's size, centred on black: raw RGB pixels."""
|
|
113
|
+
from PIL import Image
|
|
114
|
+
|
|
115
|
+
if img.size == size:
|
|
116
|
+
return img.tobytes()
|
|
117
|
+
scale = min(size[0] / img.width, size[1] / img.height)
|
|
118
|
+
w, h = max(1, round(img.width * scale)), max(1, round(img.height * scale))
|
|
119
|
+
canvas = Image.new("RGB", size, (0, 0, 0))
|
|
120
|
+
canvas.paste(img.resize((w, h), Image.Resampling.BILINEAR), ((size[0] - w) // 2, (size[1] - h) // 2))
|
|
121
|
+
return canvas.tobytes()
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class FrameVideo:
|
|
125
|
+
"""
|
|
126
|
+
A video made as it happens: ``frame`` gives the latest picture (an image, or JPEG or PNG bytes), a thread writes the
|
|
127
|
+
latest one ``fps`` times a second. ffmpeg starts with the first picture, whose size the video takes. ``hold(True)``
|
|
128
|
+
pauses it (nothing is written, and the time held is not in the video); ``close`` finishes the file.
|
|
129
|
+
"""
|
|
130
|
+
|
|
131
|
+
def __init__(self, out: Path, *, fps: int = FPS, max_seconds: float = MAX_SECONDS, exe: Optional[str] = None, clock: Callable[[], float] = time.monotonic) -> None:
|
|
132
|
+
self.out = Path(out)
|
|
133
|
+
self.fps = max(1, int(fps))
|
|
134
|
+
self.max_frames = int(max_seconds * self.fps)
|
|
135
|
+
self.exe = exe
|
|
136
|
+
self.clock = clock
|
|
137
|
+
self.size: Optional[Tuple[int, int]] = None
|
|
138
|
+
self.written = 0
|
|
139
|
+
self.error = ""
|
|
140
|
+
self._latest: Any = None
|
|
141
|
+
self._fresh = False
|
|
142
|
+
self._pixels: Optional[bytes] = None
|
|
143
|
+
self._held = False
|
|
144
|
+
self._lock = threading.Lock()
|
|
145
|
+
self._stop = threading.Event()
|
|
146
|
+
self._proc: Optional[subprocess.Popen] = None
|
|
147
|
+
self._thread: Optional[threading.Thread] = None
|
|
148
|
+
self._t0 = 0.0
|
|
149
|
+
self._due_base = 0
|
|
150
|
+
|
|
151
|
+
def start(self) -> bool:
|
|
152
|
+
"""Get ready; False (and ``error`` says why) when no video can be made here."""
|
|
153
|
+
self.exe = self.exe or ffmpeg_exe()
|
|
154
|
+
if not self.exe:
|
|
155
|
+
self.error = "the engine's video packages are missing (run forgeqe setup)"
|
|
156
|
+
return False
|
|
157
|
+
try:
|
|
158
|
+
import PIL # noqa: F401
|
|
159
|
+
except Exception:
|
|
160
|
+
self.error = "Pillow is missing (run forgeqe setup)"
|
|
161
|
+
return False
|
|
162
|
+
self.out.parent.mkdir(parents=True, exist_ok=True)
|
|
163
|
+
self._thread = threading.Thread(target=self._run, name="forgeqe-video", daemon=True)
|
|
164
|
+
self._thread.start()
|
|
165
|
+
return True
|
|
166
|
+
|
|
167
|
+
def frame(self, data: Any) -> None:
|
|
168
|
+
"""The picture shown now (decoded later, by the writer, at most ``fps`` times a second)."""
|
|
169
|
+
if self._stop.is_set():
|
|
170
|
+
return
|
|
171
|
+
with self._lock:
|
|
172
|
+
if self._held:
|
|
173
|
+
return
|
|
174
|
+
self._latest = data
|
|
175
|
+
self._fresh = True
|
|
176
|
+
|
|
177
|
+
def hold(self, held: bool) -> None:
|
|
178
|
+
with self._lock:
|
|
179
|
+
if held == self._held:
|
|
180
|
+
return
|
|
181
|
+
self._held = held
|
|
182
|
+
if not held:
|
|
183
|
+
# Carry on from where it stopped: the time held is not caught up with repeated pictures.
|
|
184
|
+
self._t0 = self.clock()
|
|
185
|
+
self._due_base = self.written
|
|
186
|
+
self._fresh = self._latest is not None
|
|
187
|
+
|
|
188
|
+
def _pixels_now(self) -> Optional[bytes]:
|
|
189
|
+
with self._lock:
|
|
190
|
+
data, fresh = self._latest, self._fresh
|
|
191
|
+
self._fresh = False
|
|
192
|
+
if fresh and data is not None:
|
|
193
|
+
img = _picture(data)
|
|
194
|
+
if img is not None:
|
|
195
|
+
if self.size is None:
|
|
196
|
+
self.size = fit_size(img.width, img.height)
|
|
197
|
+
self._pixels = _letterbox(img, self.size)
|
|
198
|
+
return self._pixels
|
|
199
|
+
|
|
200
|
+
def _open(self) -> bool:
|
|
201
|
+
assert self.exe and self.size
|
|
202
|
+
try:
|
|
203
|
+
self._proc = subprocess.Popen(
|
|
204
|
+
ffmpeg_args(self.exe, self.size, self.fps, self.out),
|
|
205
|
+
stdin=subprocess.PIPE,
|
|
206
|
+
stdout=subprocess.DEVNULL,
|
|
207
|
+
stderr=subprocess.DEVNULL,
|
|
208
|
+
env=_child_env(),
|
|
209
|
+
shell=False,
|
|
210
|
+
)
|
|
211
|
+
except OSError as ex:
|
|
212
|
+
self.error = f"ffmpeg did not start ({ex.__class__.__name__})"
|
|
213
|
+
return False
|
|
214
|
+
return True
|
|
215
|
+
|
|
216
|
+
def _write(self, pixels: bytes) -> bool:
|
|
217
|
+
try:
|
|
218
|
+
assert self._proc is not None and self._proc.stdin is not None
|
|
219
|
+
self._proc.stdin.write(pixels)
|
|
220
|
+
self.written += 1
|
|
221
|
+
return True
|
|
222
|
+
except (OSError, ValueError):
|
|
223
|
+
self.error = "ffmpeg stopped taking pictures"
|
|
224
|
+
return False
|
|
225
|
+
|
|
226
|
+
def _run(self) -> None:
|
|
227
|
+
step = 1.0 / self.fps
|
|
228
|
+
while not self._stop.is_set():
|
|
229
|
+
pixels = self._pixels_now()
|
|
230
|
+
if pixels is None:
|
|
231
|
+
self._stop.wait(step)
|
|
232
|
+
continue
|
|
233
|
+
if self._proc is None:
|
|
234
|
+
if not self._open():
|
|
235
|
+
return
|
|
236
|
+
with self._lock:
|
|
237
|
+
self._t0, self._due_base = self.clock(), 0
|
|
238
|
+
with self._lock:
|
|
239
|
+
held, t0, base = self._held, self._t0, self._due_base
|
|
240
|
+
if not held:
|
|
241
|
+
due = base + int((self.clock() - t0) * self.fps) + 1
|
|
242
|
+
# Real time: a picture that took long to come is shown for as long as it was there (at most 2 s caught up).
|
|
243
|
+
for _ in range(min(max(0, due - self.written), self.fps * 2)):
|
|
244
|
+
if self.written >= self.max_frames:
|
|
245
|
+
self._stop.set()
|
|
246
|
+
break
|
|
247
|
+
if not self._write(pixels):
|
|
248
|
+
return
|
|
249
|
+
self._stop.wait(step)
|
|
250
|
+
|
|
251
|
+
def close(self, timeout: float = FINISH_SECONDS) -> Optional[Path]:
|
|
252
|
+
"""Finish the file: its path, or None (nothing removed is left behind) when no video was made."""
|
|
253
|
+
self._stop.set()
|
|
254
|
+
if self._thread is not None:
|
|
255
|
+
self._thread.join(timeout=10)
|
|
256
|
+
proc = self._proc
|
|
257
|
+
if proc is None:
|
|
258
|
+
return None
|
|
259
|
+
try:
|
|
260
|
+
if proc.stdin is not None:
|
|
261
|
+
proc.stdin.close()
|
|
262
|
+
except OSError:
|
|
263
|
+
pass
|
|
264
|
+
try:
|
|
265
|
+
proc.wait(timeout=timeout)
|
|
266
|
+
except subprocess.TimeoutExpired:
|
|
267
|
+
proc.kill()
|
|
268
|
+
proc.wait()
|
|
269
|
+
ok = proc.returncode == 0 and self.written > 0 and self.out.is_file() and self.out.stat().st_size > 0
|
|
270
|
+
if not ok:
|
|
271
|
+
self.error = self.error or f"ffmpeg ended with {proc.returncode}"
|
|
272
|
+
try:
|
|
273
|
+
self.out.unlink()
|
|
274
|
+
except OSError:
|
|
275
|
+
pass
|
|
276
|
+
return None
|
|
277
|
+
return self.out
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def frames_in(folder: Path) -> List[Tuple[int, Path]]:
|
|
281
|
+
"""A replay's frames, by their time: only ``<ms>.jpg`` regular files directly in the folder, at most MAX_FRAMES."""
|
|
282
|
+
out: List[Tuple[int, Path]] = []
|
|
283
|
+
try:
|
|
284
|
+
entries = list(os.scandir(folder))
|
|
285
|
+
except OSError:
|
|
286
|
+
return []
|
|
287
|
+
for e in entries:
|
|
288
|
+
m = FRAME_NAME.match(e.name)
|
|
289
|
+
if m and e.is_file(follow_symlinks=False):
|
|
290
|
+
out.append((int(m.group(1)), Path(e.path)))
|
|
291
|
+
out.sort()
|
|
292
|
+
return out[:MAX_FRAMES]
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def encode_frames(folder: Path, out: Path, *, fps: int = FPS, max_seconds: float = MAX_SECONDS, exe: Optional[str] = None) -> Tuple[Optional[Path], str]:
|
|
296
|
+
"""
|
|
297
|
+
A video of frames kept with their times (a replay's): each moment shows the latest frame taken by then. (path, "")
|
|
298
|
+
or (None, why not).
|
|
299
|
+
"""
|
|
300
|
+
frames = frames_in(folder)
|
|
301
|
+
if not frames:
|
|
302
|
+
return None, "no frames were kept"
|
|
303
|
+
exe = exe or ffmpeg_exe()
|
|
304
|
+
if not exe:
|
|
305
|
+
return None, "the engine's video packages are missing (run forgeqe setup)"
|
|
306
|
+
first = _picture(frames[0][1].read_bytes()) if frames[0][1].stat().st_size <= MAX_FRAME_BYTES else None
|
|
307
|
+
if first is None:
|
|
308
|
+
return None, "the first frame is not a picture"
|
|
309
|
+
size = fit_size(first.width, first.height)
|
|
310
|
+
out = Path(out)
|
|
311
|
+
out.parent.mkdir(parents=True, exist_ok=True)
|
|
312
|
+
try:
|
|
313
|
+
proc = subprocess.Popen(ffmpeg_args(exe, size, fps, out), stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, env=_child_env(), shell=False)
|
|
314
|
+
except OSError as ex:
|
|
315
|
+
return None, f"ffmpeg did not start ({ex.__class__.__name__})"
|
|
316
|
+
start = frames[0][0]
|
|
317
|
+
end = min(frames[-1][0] - start, int(max_seconds * 1000))
|
|
318
|
+
count = end * fps // 1000 + 1
|
|
319
|
+
i, pixels, ok = 0, _letterbox(first, size), True
|
|
320
|
+
assert proc.stdin is not None
|
|
321
|
+
try:
|
|
322
|
+
for n in range(count):
|
|
323
|
+
at = start + n * 1000 // fps
|
|
324
|
+
moved = False
|
|
325
|
+
while i + 1 < len(frames) and frames[i + 1][0] <= at:
|
|
326
|
+
i += 1
|
|
327
|
+
moved = True
|
|
328
|
+
if moved:
|
|
329
|
+
p = frames[i][1]
|
|
330
|
+
img = _picture(p.read_bytes()) if p.stat().st_size <= MAX_FRAME_BYTES else None
|
|
331
|
+
if img is not None:
|
|
332
|
+
pixels = _letterbox(img, size)
|
|
333
|
+
proc.stdin.write(pixels)
|
|
334
|
+
except (OSError, ValueError):
|
|
335
|
+
ok = False
|
|
336
|
+
try:
|
|
337
|
+
proc.stdin.close()
|
|
338
|
+
except OSError:
|
|
339
|
+
pass
|
|
340
|
+
try:
|
|
341
|
+
proc.wait(timeout=FINISH_SECONDS)
|
|
342
|
+
except subprocess.TimeoutExpired:
|
|
343
|
+
proc.kill()
|
|
344
|
+
proc.wait()
|
|
345
|
+
if not ok or proc.returncode != 0 or not out.is_file() or not out.stat().st_size:
|
|
346
|
+
try:
|
|
347
|
+
out.unlink()
|
|
348
|
+
except OSError:
|
|
349
|
+
pass
|
|
350
|
+
return None, f"ffmpeg ended with {proc.returncode}"
|
|
351
|
+
return out, ""
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
class ScreenVideo:
|
|
355
|
+
"""
|
|
356
|
+
A video of this computer's screen (a desktop run): Pillow's ImageGrab, the main screen, taken ``fps`` times a
|
|
357
|
+
second on a thread of its own. ``start`` is False (``error`` says why) where the screen cannot be read, such as a
|
|
358
|
+
computer with no display, or macOS before Screen Recording is allowed for the app running ForgeQE.
|
|
359
|
+
"""
|
|
360
|
+
|
|
361
|
+
def __init__(self, out: Path, *, fps: int = FPS, grab: Optional[Callable[[], Any]] = None, exe: Optional[str] = None) -> None:
|
|
362
|
+
self.video = FrameVideo(out, fps=fps, exe=exe)
|
|
363
|
+
self.fps = self.video.fps
|
|
364
|
+
self._grab = grab
|
|
365
|
+
self._stop = threading.Event()
|
|
366
|
+
self._thread: Optional[threading.Thread] = None
|
|
367
|
+
self.error = ""
|
|
368
|
+
|
|
369
|
+
def _take(self) -> Any:
|
|
370
|
+
if self._grab is not None:
|
|
371
|
+
return self._grab()
|
|
372
|
+
from PIL import ImageGrab
|
|
373
|
+
|
|
374
|
+
return ImageGrab.grab()
|
|
375
|
+
|
|
376
|
+
def start(self) -> bool:
|
|
377
|
+
try:
|
|
378
|
+
first = self._take()
|
|
379
|
+
except Exception as ex:
|
|
380
|
+
self.error = f"the screen cannot be read here ({ex.__class__.__name__})"
|
|
381
|
+
return False
|
|
382
|
+
if first is None:
|
|
383
|
+
self.error = "the screen cannot be read here"
|
|
384
|
+
return False
|
|
385
|
+
if not self.video.start():
|
|
386
|
+
self.error = self.video.error
|
|
387
|
+
return False
|
|
388
|
+
self.video.frame(first)
|
|
389
|
+
self._thread = threading.Thread(target=self._run, name="forgeqe-screen", daemon=True)
|
|
390
|
+
self._thread.start()
|
|
391
|
+
return True
|
|
392
|
+
|
|
393
|
+
def _run(self) -> None:
|
|
394
|
+
step = 1.0 / self.fps
|
|
395
|
+
while not self._stop.is_set():
|
|
396
|
+
started = time.monotonic()
|
|
397
|
+
try:
|
|
398
|
+
img = self._take()
|
|
399
|
+
except Exception:
|
|
400
|
+
img = None
|
|
401
|
+
if img is not None:
|
|
402
|
+
self.video.frame(img)
|
|
403
|
+
self._stop.wait(max(0.0, step - (time.monotonic() - started)))
|
|
404
|
+
|
|
405
|
+
def close(self) -> Optional[Path]:
|
|
406
|
+
self._stop.set()
|
|
407
|
+
if self._thread is not None:
|
|
408
|
+
self._thread.join(timeout=10)
|
|
409
|
+
path = self.video.close()
|
|
410
|
+
if path is None and not self.error:
|
|
411
|
+
self.error = self.video.error
|
|
412
|
+
return path
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
def main(args: List[str], out: Any) -> int:
|
|
416
|
+
"""``python -m forgeqe_engine video <frames folder> <file.mp4>``: a replay's frames as a video (src/code/replay.ts)."""
|
|
417
|
+
if len(args) != 2 or not args[1].endswith(".mp4"):
|
|
418
|
+
result: Dict[str, Any] = {"success": False, "error": "usage: video <frames folder> <file.mp4>"}
|
|
419
|
+
else:
|
|
420
|
+
path, why = encode_frames(Path(args[0]), Path(args[1]))
|
|
421
|
+
result = {"success": True, "video": str(path)} if path else {"success": False, "error": why}
|
|
422
|
+
out.write(json.dumps({"type": "done", "result": result}) + "\n")
|
|
423
|
+
return 0 if result["success"] else 1
|
|
@@ -243,7 +243,7 @@ def run_hyperexecute(
|
|
|
243
243
|
args = [settings["cli"], "--user", user, "--key", key, "--config", cfg.name, "--download-artifacts", "--download-artifacts-path", "artifacts", "--force-clean-artifacts"]
|
|
244
244
|
child_env = {k: v for k, v in env.items() if k not in (settings["username_env"], settings["access_key_env"])}
|
|
245
245
|
try:
|
|
246
|
-
proc = run(args, cwd=str(project), env=child_env, capture_output=True, text=True, timeout=timeout, shell=False)
|
|
246
|
+
proc = run(args, cwd=str(project), env=child_env, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=timeout, shell=False)
|
|
247
247
|
except FileNotFoundError:
|
|
248
248
|
raise WorkflowError(f"the HyperExecute CLI is not at {settings['cli']}; download it from TestMu (hyperexecute) and set mobile.maestro.testmu.cli")
|
|
249
249
|
except subprocess.TimeoutExpired:
|
|
@@ -358,7 +358,7 @@ def run_maestro(
|
|
|
358
358
|
resolved = shutil.which(command[0]) or command[0]
|
|
359
359
|
args = [resolved, *command[1:], *(["--device", device] if device else []), "test", "--format", "junit", "--output", str(junit), "--debug-output", str(debug), *flows]
|
|
360
360
|
try:
|
|
361
|
-
proc = run(args, env=dict(env), capture_output=True, text=True, timeout=timeout, shell=False)
|
|
361
|
+
proc = run(args, env=dict(env), capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=timeout, shell=False)
|
|
362
362
|
except FileNotFoundError:
|
|
363
363
|
raise WorkflowError(f"Maestro is not installed or not on PATH ({command[0]}); see https://maestro.mobile.dev")
|
|
364
364
|
except subprocess.TimeoutExpired:
|
|
@@ -41,9 +41,10 @@ def manifests(path: Path, test_attributes: Optional[List[str]] = None, skip_modu
|
|
|
41
41
|
cfg["skip_modules"] = list(skip_modules)
|
|
42
42
|
if cfg: # parse_tsu reads parse_tsu.config.json from its output folder (it wins over one next to the .tsu)
|
|
43
43
|
(out / "parse_tsu.config.json").write_text(json.dumps(cfg), encoding="utf-8")
|
|
44
|
+
# -X utf8: -I ignores PYTHONUTF8, and on Windows the parser's progress marks (✓) would not fit the ANSI code page.
|
|
44
45
|
r = subprocess.run(
|
|
45
|
-
[sys.executable, "-I", str(PARSER), str(linked.resolve()), "--steps-json", "--out-dir", str(out)],
|
|
46
|
-
capture_output=True, text=True, timeout=timeout, cwd=tmp, shell=False,
|
|
46
|
+
[sys.executable, "-I", "-X", "utf8", str(PARSER), str(linked.resolve()), "--steps-json", "--out-dir", str(out)],
|
|
47
|
+
capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=timeout, cwd=tmp, shell=False,
|
|
47
48
|
)
|
|
48
49
|
if r.returncode != 0:
|
|
49
50
|
last = (r.stderr or r.stdout or "").strip().splitlines()
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CtX74khE.js","assets/line-icons-CQ-3V8ax.js","assets/filters-B4VDnWbr.js","assets/frame-D-hqu7Oi.js","assets/index-DUf5ddb0.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{D as e,E as t,Ir as n,Nr as r,ir as i}from"./line-icons-CQ-3V8ax.js";import{B as a,R as o,Wt as s,Z as c,_ as l,bt as u,f as d,i as f,jt as p,lt as m,n as h,tt as g}from"./filters-B4VDnWbr.js";import{Et as _,It as v,Nt as y,Ut as b,dt as x,ft as S,ht as C,kt as w,lt as T,mt as E,pt as D,r as ee,t as O,ut as k}from"./frame-D-hqu7Oi.js";import{H as A,V as j}from"./index-CtX74khE.js";import{t as M}from"./palette-CF8GLAVN.js";import{a as N,i as P,n as F,t as I}from"./rows-B0vZ5x5N.js";var L=n(r(),1),R=s(),z={agents:[`approvals`,`jobs`],quality:[`runs`],assurance:[`review`]};function B(e){let t=new Set(e.flatMap(e=>z[e]||[])),n=[...t].sort().join(`,`),[r,i]=(0,L.useState)(null);return(0,L.useEffect)(()=>{let n=!0;i(null);let r=(e,t)=>e?t().catch(()=>null):Promise.resolve(null);return Promise.all([r(t.has(`runs`),()=>p.list().then(e=>e.runs)),r(t.has(`approvals`),()=>c.list().then(e=>e.approvals)),r(t.has(`jobs`),()=>u.list().then(e=>e.jobs)),r(t.has(`review`),()=>m.review())]).then(([t,r,a,o])=>{n&&i([...A(t,r,a),...j(o)].filter(t=>e.includes(t.category)))}),()=>{n=!1}},[n,e.join(`,`)]),r}var V={fail:`bg-fail-soft text-fail hover:text-fail`,warn:`bg-warn-soft text-warn hover:text-warn`,accent:`bg-accent-soft text-accent-fg hover:text-accent-fg`};function H({items:e}){return e?.length?(0,R.jsx)(`nav`,{"aria-label":`Needs a look`,className:`flex flex-wrap gap-2`,children:e.map(e=>(0,R.jsx)(`a`,{href:e.href,className:a(`flex items-center rounded-[12px] px-3 py-2 text-sm font-medium no-underline`,V[e.tone]),children:e.label},e.id))}):null}function U({ids:e}){let t=e.map(e=>v.find(t=>t.id===e)).filter(e=>!!e);return t.length?(0,R.jsxs)(`section`,{"aria-labelledby":`agents-here`,className:`flex flex-col gap-2`,children:[(0,R.jsx)(`h2`,{id:`agents-here`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Agents that work here`}),(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-wrap gap-2 p-0`,children:t.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(`a`,{href:d(`agents`,e.id),"data-tip":e.about,className:`flex min-h-9 items-center gap-2 rounded-[8px] bg-surface-strong px-3 text-[13px] font-medium text-ink no-underline hover:bg-line hover:text-ink`,children:[(0,R.jsx)(w,{agent:e.agent,px:18,decorative:!0}),b(e.agent).name]})},e.id))})]}):null}var W=96;function G(){let[t,n]=(0,L.useState)(null),[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(0),[l,u]=(0,L.useState)(5),p=(0,L.useRef)(null);(0,L.useEffect)(()=>{let e=!0;return g.list().then(t=>e&&n(t.chats),t=>e&&i(t.message)),()=>{e=!1}},[]);let m=(0,L.useMemo)(()=>P((t||[]).filter(e=>F(e,a))),[t,a]);(0,L.useLayoutEffect)(()=>{let e=()=>{let e=p.current;if(!e)return;let t=e.firstElementChild?.offsetHeight||56;u(N(window.innerHeight-e.getBoundingClientRect().top-W,t))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[m.length>0]),(0,L.useEffect)(()=>c(0),[a,l]);let _=Math.max(1,Math.ceil(m.length/l)),v=Math.min(s,_-1),y=m.slice(v*l,v*l+l);return(0,R.jsxs)(`section`,{"aria-labelledby":`recent-chats`,className:`flex max-w-[720px] flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,R.jsx)(`h2`,{id:`recent-chats`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Recent chats`}),t&&t.length>0&&(0,R.jsxs)(`a`,{href:d(`chats`),className:`inline-flex items-center gap-1 text-[13px] no-underline`,children:[`All chats (`,t.length,`)`,(0,R.jsx)(e,{size:14,"aria-hidden":`true`})]})]}),t&&t.length>0&&(0,R.jsx)(f,{id:`find-a-recent-chat`,label:`Find a chat`,value:a,onChange:o,className:`max-w-none flex-none`}),r&&(0,R.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail`,children:r}),!t&&!r&&(0,R.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Loading…`}),t&&t.length===0&&(0,R.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No chats yet. A chat you start shows up here.`}),t&&t.length>0&&m.length===0&&(0,R.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No chat matches.`}),m.length>0&&(0,R.jsxs)(`div`,{className:`@container rounded-[14px] card border`,children:[(0,R.jsx)(`ul`,{ref:p,className:`m-0 flex list-none flex-col p-1.5`,children:y.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsx)(I,{c:e})},e.id))}),m.length>l&&(0,R.jsx)(h,{page:v,size:l,total:m.length,onPage:c,label:`Pages of chats`})]})]})}var K=6;function q({id:e,title:t,links:n,empty:r,className:i}){return(0,R.jsxs)(`section`,{"aria-labelledby":e,className:a(`flex min-w-0 flex-col gap-2`,i),children:[(0,R.jsx)(`h2`,{id:e,className:`m-0 text-[13px] font-semibold text-muted`,children:t}),n.length?(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-wrap gap-2 p-0`,children:n.map(e=>(0,R.jsx)(`li`,{className:`min-w-0 max-w-full`,children:(0,R.jsxs)(`a`,{href:e.to,"data-tip":e.tip,className:`flex min-h-9 items-center gap-2 rounded-[8px] bg-surface-strong px-3 text-[13px] font-medium text-ink no-underline hover:bg-line hover:text-ink`,children:[(0,R.jsx)(l,{name:e.icon,px:18}),(0,R.jsx)(`span`,{className:`max-w-[32ch] truncate`,children:e.label})]})},e.key))}):(0,R.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:r})]})}var J=e=>({key:e.id,to:D(e),label:e.label,tip:e.about,icon:e.icon});function Y({scope:e,pins:t,className:n}){let r=C(),i=new Map(e.map(e=>[e.id,e])),o=e=>e.map(e=>i.get(e)).filter(e=>!!e).map(J);return(0,R.jsxs)(`div`,{className:a(`grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2`,n),children:[(0,R.jsx)(q,{id:`favourites`,title:`Favourites`,links:o(t.pins),empty:`Star a page below to keep it here and in the sidebar.`}),(0,R.jsx)(q,{id:`recents`,title:`Recent`,links:o(r).slice(0,K),empty:`Pages you open will show up here.`})]})}function X({icon:e,title:n,about:r,back:i,children:o}){return(0,R.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,R.jsx)(ee,{}),(0,R.jsxs)(`main`,{className:a(O,`flex-auto gap-5`),children:[i&&(0,R.jsxs)(`a`,{href:i.href,className:`inline-flex items-center gap-1 self-start text-[13px] no-underline`,children:[(0,R.jsx)(t,{size:14,"aria-hidden":`true`}),i.label]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,R.jsx)(_,{pixel:e,size:`lg`}),(0,R.jsx)(`h1`,{className:`m-0 flex-1 text-[26px] font-semibold tracking-[-0.01em]`,children:n})]}),(0,R.jsx)(`p`,{className:`m-0 max-w-[70ch] text-sm leading-relaxed text-ink-2`,children:r}),o]})]})}function Z({category:e,query:t,pins:n}){let[r,i]=(0,L.useState)(null);(0,L.useEffect)(()=>{let e=!0;return y(()=>import(`./index-CtX74khE.js`).then(e=>e.o).then(t=>e&&i(t.SETTINGS_INDEX),()=>e&&i([])),__vite__mapDeps([0,1,2,3,4])),()=>{e=!1}},[]);let a=M(e,r||[],t),o=a.filter(e=>e.kind===`page`),s=a.filter(e=>e.kind===`field`),c=o.map(t=>e.areas.flatMap(e=>e.items).find(e=>e.id===t.id)).filter(e=>!!e);return(0,R.jsxs)(`div`,{className:`flex max-w-[720px] flex-col gap-4`,"aria-live":`polite`,children:[c.length>0&&(0,R.jsxs)(`section`,{"aria-labelledby":`found-pages`,className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h2`,{id:`found-pages`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Pages`}),(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:c.map(e=>(0,R.jsx)(Q,{item:e,pins:n},e.id))})]}),s.length>0&&(0,R.jsxs)(`section`,{"aria-labelledby":`found-settings`,className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h2`,{id:`found-settings`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Settings`}),(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:s.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(`a`,{href:e.href,className:`flex min-h-11 flex-col justify-center rounded-[10px] px-2 py-2 text-sm text-ink no-underline hover:bg-surface-strong hover:text-ink`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,R.jsx)(`span`,{className:`text-[13px] break-all text-muted`,children:e.meta})]})},e.id))})]}),!a.length&&(0,R.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:r?`No page or setting matches.`:`Looking…`})]})}function Q({item:e,pins:t}){let n=t.pins.includes(e.id);return(0,R.jsxs)(`li`,{className:`relative`,children:[(0,R.jsxs)(`a`,{href:D(e),className:`flex min-h-11 items-center gap-2.5 rounded-[10px] py-2 pr-10 pl-2 text-sm text-ink no-underline hover:bg-surface-strong hover:text-ink`,children:[(0,R.jsx)(l,{name:e.icon,px:18}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,R.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.about})]})]}),(0,R.jsx)(o,{variant:`icon`,size:`icon`,"aria-pressed":n,"aria-label":n?`Unpin ${e.label}`:`Pin ${e.label} to the sidebar`,"data-tip":n?`Unpin ${e.label}`:`Pin ${e.label} to the sidebar`,onClick:()=>t.toggle(e.id),className:a(`absolute top-1/2 right-0 size-8 -translate-y-1/2`,n?`text-ink`:`text-muted`),children:(0,R.jsx)(i,{size:14,strokeWidth:1.8,fill:n?`currentColor`:`none`,"aria-hidden":`true`})})]})}function te({category:e,area:t,pins:n,index:r}){let i=`area-${e.id}-${r}`;return(0,R.jsxs)(`section`,{"aria-labelledby":i,className:`@container/col flex min-w-0 flex-col`,children:[(0,R.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5 border-b border-line px-2 pt-1 pb-3`,children:[(0,R.jsxs)(`h2`,{id:i,className:`m-0 text-[16px] font-semibold`,children:[(0,R.jsx)(`a`,{href:x(e,t),className:`text-ink no-underline hover:text-ink hover:underline`,children:t.label}),(0,R.jsx)(`span`,{className:`ml-2 text-[13px] font-normal text-muted tabular-nums`,children:t.items.length})]}),(0,R.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:t.about})]}),(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:t.items.map(e=>(0,R.jsx)(Q,{item:e,pins:n},e.id))})]})}var $=`grid grid-cols-1 items-start gap-x-6 gap-y-8 @2xl:grid-cols-2 @5xl:grid-cols-3`;function ne({sub:t}){let n=E(),[r,i]=(0,L.useState)(``),[a,o,...s]=(t||``).split(`/`).filter(Boolean),c=a?k.find(e=>e.id===a):void 0,l=c&&o?c.areas.find(e=>e.id===o):void 0;(0,L.useEffect)(()=>i(``),[a]);let u=B(l||a&&!c?[]:c?[c.id]:k.map(e=>e.id));return a&&!c||o&&!l||s.length?(0,R.jsx)(X,{icon:`info`,title:`Nothing here`,about:`That address is not a part of ForgeQE.`,back:{href:d(`browse`),label:`ForgeQE`},children:null}):c&&l?(0,R.jsxs)(X,{icon:c.icon,title:l.label,about:l.about,back:{href:S(c),label:c.label},children:[(0,R.jsx)(Y,{scope:l.items,pins:n,className:`max-w-[720px]`}),(0,R.jsx)(`ul`,{className:`m-0 flex max-w-[720px] list-none flex-col gap-1 p-0`,children:l.items.map(e=>(0,R.jsx)(Q,{item:e,pins:n},e.id))}),c.id===`agents`&&l.id===`chat`&&(0,R.jsx)(G,{})]}):c?(0,R.jsxs)(X,{icon:c.icon,title:c.label,about:c.about,back:{href:d(`browse`),label:`ForgeQE`},children:[c.id===`admin`&&(0,R.jsx)(f,{id:`find-a-setting`,label:`Find a setting`,value:r,onChange:i,placeholder:`Find a setting, by its name or forgeqe.yaml key`,className:`max-w-[720px] flex-none`}),r.trim()?(0,R.jsx)(Z,{category:c,query:r,pins:n}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(H,{items:u}),(0,R.jsx)(Y,{scope:c.areas.flatMap(e=>e.items),pins:n}),(0,R.jsx)(U,{ids:c.agents||[]}),(0,R.jsx)(`div`,{className:`@container`,children:(0,R.jsx)(`div`,{className:$,children:c.areas.map((e,t)=>(0,R.jsx)(te,{category:c,area:e,pins:n,index:t},e.id))})})]})]}):(0,R.jsxs)(X,{icon:`board`,title:`ForgeQE`,about:`Every part of ForgeQE, by what it is for. Open a category to see its areas, or pin a page to keep it in the sidebar, below the categories.`,children:[(0,R.jsx)(Y,{scope:T.map(e=>e.item),pins:n}),(0,R.jsx)(`div`,{className:`@container`,children:(0,R.jsx)(`div`,{className:$,children:k.map(t=>(0,R.jsx)(`section`,{"aria-labelledby":`cat-${t.id}`,className:`flex min-w-0 flex-col`,children:(0,R.jsxs)(`a`,{href:S(t),className:`flex items-start gap-3 rounded-[12px] p-2 text-ink no-underline hover:bg-surface-strong hover:text-ink`,children:[(0,R.jsx)(_,{pixel:t.icon}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,R.jsxs)(`span`,{id:`cat-${t.id}`,className:`flex items-center gap-1 text-[16px] font-semibold`,children:[t.label,(0,R.jsx)(e,{size:14,"aria-hidden":`true`,className:`text-muted`})]}),(0,R.jsx)(`span`,{className:`text-[13px] text-muted`,children:t.about}),(0,R.jsx)(`span`,{className:`mt-1 text-[13px] text-ink-2`,children:t.areas.map(e=>e.label).join(` · `)}),u?.some(e=>e.category===t.id)&&(0,R.jsx)(`span`,{className:`mt-1 text-[13px] font-medium text-warn`,children:u.filter(e=>e.category===t.id).map(e=>e.label).join(` · `)})]})]})},t.id))})})]})}export{ne as Browse};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{An as e,C as t,Gn as n,Ir as r,Nr as i,T as a,Xn as o,i as s,ln as c}from"./line-icons-CQ-3V8ax.js";import{B as l,R as u,Wt as d,Y as f,f as p,h as m,i as h,l as g,tt as _,z as v}from"./filters-B4VDnWbr.js";import{Et as y,a as b,gt as x,n as S,r as C,t as w}from"./frame-D-hqu7Oi.js";import{B as T,F as E,I as ee,L as D,P as O,R as k,T as A,i as j,w as te,z as ne}from"./index-CtX74khE.js";import{n as re}from"./Response-DjqmewrL.js";import{n as ie}from"./thread-DASfqw-f.js";import{i as M,n as N,r as P,t as F}from"./rows-B0vZ5x5N.js";var I=r(i(),1),L=d();function R({id:e}){let[r,i]=(0,I.useState)([]),[a,d]=(0,I.useState)(null),[h,g]=(0,I.useState)(!1),[y,x]=(0,I.useState)(``),[C,w]=(0,I.useState)(``),[j,M]=(0,I.useState)(!1),N=T(C,w,`reply`,{chat:e}),P=(0,I.useRef)(null),F=(0,I.useRef)(null),R=(0,I.useRef)(!0),[z,B]=(0,I.useState)(!0);(0,I.useEffect)(()=>{let t=!1,n=0;return i([]),d(null),x(``),w(``),N.reset(),(async()=>{for(;!t;)try{let r=await _.events(e,n,n>0);if(t)return;x(``),d({title:r.title,state:r.state,profile:r.profile,settingsChanged:r.settingsChanged===!0}),r.events.length&&(n=r.events[r.events.length-1].n,i(e=>[...e,...r.events]))}catch(e){if(t||(x(e.message),e.status===404))return;await new Promise(e=>setTimeout(e,2e3))}})(),()=>{t=!0}},[e]);let V=(0,I.useMemo)(()=>ie(r),[r]),H=(0,I.useMemo)(()=>{let e=new Map;for(let t of V.turns.flatMap(e=>e.changes)){let n=e.get(t.path);e.set(t.path,n?{...n,added:n.added+t.added,removed:n.removed+t.removed}:{path:t.path,added:t.added,removed:t.removed})}return[...e.values()]},[V]),U=(0,I.useMemo)(()=>{let e=[];for(let t of V.turns){for(let n of t.tests)n.testFile&&e.push({label:n.ok?`Test`:`Test (failed)`,path:n.testFile,kind:`test`});for(let n of t.reports)e.push({label:/\.html?$/i.test(n.path)?`Report`:`Run report`,path:n.path,kind:`report`})}return e.filter((t,n)=>e.findIndex(e=>e.path===t.path)===n)},[V]),W=(0,I.useRef)(()=>{});b(V.context||V.usage||H.length||U.length||V.uses?{context:V.context,usage:V.usage,agents:V.agents,model:V.model?.name,changes:H,outputs:U,uses:V.uses,busy:a?.state===`busy`||a?.state===`starting`,...H.length?{onCreatePr:()=>W.current()}:{}}:null);let G=a?.state,K=G===`busy`||G===`starting`,q=G===`closed`||G===`failed`,J=V.turns.at(-1),Y=!!J&&!J.outcome&&(J.asks.some(e=>e.answer===void 0)||J.waits.some(e=>e.answer===void 0));(0,I.useEffect)(()=>{let e=document.documentElement,t=()=>window.innerHeight+window.scrollY>=e.scrollHeight-48,n=e=>{R.current=e,B(e)},r=window.scrollY,i=()=>{t()?n(!0):window.scrollY<r-2&&n(!1),r=window.scrollY},a=new ResizeObserver(()=>{R.current&&!t()&&window.scrollTo({top:e.scrollHeight,behavior:`instant`})});return P.current&&a.observe(P.current),F.current&&a.observe(F.current),window.addEventListener(`scroll`,i,{passive:!0}),()=>{a.disconnect(),window.removeEventListener(`scroll`,i)}},[]);let ae=()=>{R.current=!0,B(!0),window.scrollTo({top:document.documentElement.scrollHeight,behavior:`smooth`})},[X,oe]=(0,I.useState)(null);(0,I.useEffect)(()=>void f.settings().then(oe,()=>{}),[]);let Z=(0,I.useCallback)(async e=>{try{await e()}catch(e){x(e.message)}},[]),Q=D(`chat-${e}`.replace(/[^\w-]/g,``).slice(0,80),e=>{w(e),ee(`reply`)}),$=async t=>{if(!(j||!t.trim()&&!N.hasFiles)){M(!0),R.current=!0,B(!0);try{let n=await N.wrap(t);if(!n.trim())return;await _.send(e,n),w(``),N.reset({keep:!0}),x(``),Q.close()}catch(e){x(e.message)}finally{M(!1)}}};return W.current=()=>{if(a?.state===`busy`||a?.state===`starting`||j)return;let e=H.map(e=>`- ${e.path}`).join(`
|
|
2
|
-
`);$(`Open a pull request with the changes you made in this chat:\n${e}\n\nUse a new branch, a clear title and description, and tell me its link.`)},(0,L.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,L.jsxs)(`header`,{className:`sticky top-0 z-20 flex items-center gap-1 border-b border-line-soft bg-bg py-3 pr-16 pl-5 md:pr-5`,children:[(0,L.jsx)(S,{}),(0,L.jsx)(`h1`,{className:`m-0 ml-2 min-w-0 flex-1 truncate text-base font-semibold`,children:a?.title||`Chat`}),V.model&&(0,L.jsxs)(`span`,{className:`hidden min-h-9 items-center gap-1.5 rounded-lg px-2 text-sm text-ink-2 sm:inline-flex`,"data-tip":`The model this chat uses`,children:[(0,L.jsx)(m,{icon:o,size:14,className:`text-accent-fg`}),V.model.name]})]}),(0,L.jsxs)(`main`,{ref:P,className:`mx-auto box-border flex w-full max-w-[960px] flex-auto flex-col gap-8 px-6 pt-8 pb-6`,children:[!a&&!y&&(0,L.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Opening the chat…`}),V.turns.map((t,n)=>(0,L.jsxs)(`section`,{"aria-label":`Message ${n+1}`,className:`flex flex-col gap-5`,children:[(0,L.jsx)(ne,{text:t.user,scope:{chat:e}}),(0,L.jsx)(re,{turn:t,live:n===V.turns.length-1&&!q,onAnswer:(t,n)=>Z(()=>_.answer(e,t,n)),onProceed:(t,n)=>Z(()=>_.proceed(e,t,n))})]},t.id)),J?.outcome===`done`&&J.next.length>0&&!K&&!q&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2 pl-12`,children:J.next.map(e=>(0,L.jsx)(`button`,{type:`button`,"data-tip":e.request===e.label?void 0:e.request,onClick:()=>void $(e.request),className:`inline-flex min-h-10 cursor-pointer items-center rounded-[8px] border-0 bg-surface-strong px-4 text-sm font-medium text-ink-2 hover:bg-line hover:text-ink`,children:e.label},e.label))}),(V.fatal||q&&V.ended)&&(0,L.jsxs)(`div`,{role:`alert`,className:l(`flex flex-col gap-2 rounded-[14px] px-4 py-3 text-sm leading-relaxed`,V.fatal||G===`failed`?`bg-fail-soft text-fail`:`bg-surface-muted text-ink-2`),children:[(0,L.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:V.fatal||V.ended?.message||(G===`failed`?`ForgeQE stopped unexpectedly.`:`This chat has ended.`)}),q&&(0,L.jsx)(`span`,{className:`text-ink-2`,children:`Write below to carry on: ForgeQE starts again with this conversation.`}),V.ended?.stderr&&(0,L.jsx)(`pre`,{className:`m-0 max-h-[200px] overflow-auto rounded-lg bg-bg/60 px-3 py-2 font-mono text-[12px] whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,children:V.ended.stderr.join(`
|
|
3
|
-
`)}),(0,L.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsxs)(`a`,{className:v({size:`sm`}),href:p(),"data-tip":`Start a new chat`,children:[(0,L.jsx)(c,{"aria-hidden":`true`}),`Chat`]}),V.fatal&&/model|key|sign/i.test(V.fatal)&&(0,L.jsxs)(`a`,{className:v({size:`sm`}),href:p(`settings`,`models`),"data-tip":`Set up the models`,children:[(0,L.jsx)(n,{"aria-hidden":`true`}),`Models`]}),V.fatal&&/runtime|engine|setup/i.test(V.fatal)&&(0,L.jsxs)(`a`,{className:v({size:`sm`}),href:p(`settings`,`setup`),children:[(0,L.jsx)(n,{"aria-hidden":`true`}),`Set up`]})]})]}),V.notes.map((e,t)=>(0,L.jsx)(`p`,{className:`m-0 text-sm text-muted [overflow-wrap:anywhere]`,children:e},t))]}),(0,L.jsx)(`div`,{ref:F,className:`sticky bottom-0 z-10 bg-gradient-to-t from-bg from-70% to-transparent px-6 pt-4 pb-5`,children:(0,L.jsxs)(`div`,{className:`relative mx-auto flex w-full max-w-[880px] flex-col gap-2`,children:[!z&&K&&(0,L.jsxs)(`button`,{type:`button`,onClick:ae,"data-tip":`Go to the latest activity`,className:`absolute -top-11 left-1/2 inline-flex min-h-8 -translate-x-1/2 cursor-pointer items-center gap-1.5 rounded-[8px] border-0 bg-surface-strong px-3 text-[13px] font-medium text-ink-2 shadow-sm hover:bg-line hover:text-ink`,children:[(0,L.jsx)(s,{size:14,"aria-hidden":`true`}),`Latest`]}),(0,L.jsxs)(`div`,{"aria-live":`polite`,children:[a?.settingsChanged&&!K&&!q&&!Y&&(0,L.jsxs)(`div`,{role:`status`,className:`mb-2 flex flex-wrap items-center gap-2 rounded-[12px] border border-accent-line bg-accent-soft px-3 py-2 text-sm`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1`,children:`The settings changed since this chat started. Carry on with them? The conversation is kept.`}),(0,L.jsxs)(u,{size:`sm`,variant:`primary`,disabled:h,onClick:()=>{g(!0),_.refresh(e).then(()=>{g(!1),d(e=>e&&{...e,settingsChanged:!1,state:`starting`})},e=>{g(!1),x(e.message)})},"data-tip":`Carry on with the new settings`,children:[(0,L.jsx)(t,{"aria-hidden":`true`}),`Apply`]})]}),(y||N.error)&&(0,L.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:y||N.error})]}),(0,L.jsx)(k,{id:`reply`,label:`Reply to ForgeQE`,rows:1,value:C,onChange:w,onSend:()=>void $(C),onStop:()=>Z(()=>_.stop(e)),busy:K&&!Y,disabled:j||Y||Q.running,canSend:!!C.trim()||N.hasFiles,onEdit:N.onEdit,onKey:N.onKeyDown,onFiles:N.onFiles,dropping:N.dropping,drop:N.drop,mentions:N.mentions,combo:N.combo,top:(0,L.jsxs)(L.Fragment,{children:[N.chips,Q.state&&(0,L.jsx)(E,{state:Q.state,onStop:()=>void Q.stop(),onUndo:Q.undo,onClose:Q.close})]}),left:(0,L.jsxs)(L.Fragment,{children:[N.paperclip,(0,L.jsx)(A,{chat:e,thread:V,ended:q,snap:X,onError:x}),(0,L.jsx)(O,{running:Q.running,disabled:!C.trim()||j||Y,onClick:()=>void Q.start(C)})]}),placeholder:q?`Write to carry on this chat…`:Y?`Answer above to go on`:K?`ForgeQE is working…`:`Reply to ForgeQE…`,right:(0,L.jsx)(te,{chat:e,thread:V,ended:q,busy:K||j,snap:X,onError:x})})]})})]})}var z=[{id:`all`,label:`All`},{id:`working`,label:`Working`},{id:`waiting`,label:`Needs you`},{id:`done`,label:`Your turn`},{id:`ended`,label:`Ended`}],B=50;function V(){let[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(``),[o,s]=(0,I.useState)(`all`),[d,f]=(0,I.useState)(``),[m,b]=(0,I.useState)(B);(0,I.useEffect)(()=>b(B),[o,d]),(0,I.useEffect)(()=>{let e=!1,t=()=>_.list().then(t=>!e&&n(t.chats),t=>!e&&i(t.message));t();let r=setInterval(t,5e3);return()=>{e=!0,clearInterval(r)}},[]);let S=(0,I.useMemo)(()=>{let e={all:0,working:0,waiting:0,done:0,ended:0};for(let n of t||[])e.all++,e[P(n)]++;return e},[t]),T=(0,I.useMemo)(()=>M((t||[]).filter(e=>(o===`all`||P(e)===o)&&N(e,d))),[t,o,d]),E=(0,I.useMemo)(()=>{let e=[];for(let t of T.slice(0,m)){let n=j(t.lastAt||t.started),r=e.find(e=>e.day===n);r?r.chats.push(t):e.push({day:n,chats:[t]})}return e},[T,m]);return(0,L.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,L.jsx)(C,{}),(0,L.jsxs)(`main`,{className:l(w,`gap-5`),children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(y,{pixel:x.chats,size:`lg`}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,L.jsx)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:`Chats`}),(0,L.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Each one is its own ForgeQE agent in your project folder. Past chats stay here after forgeqe web restarts, to read or carry on.`})]}),(0,L.jsxs)(`a`,{className:l(v({variant:`primary`}),`gap-2`),href:p(),children:[(0,L.jsx)(e,{"aria-hidden":`true`}),`New chat`]})]}),t&&t.length>0&&(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`div`,{role:`radiogroup`,"aria-label":`Show`,className:`flex flex-wrap gap-1 rounded-[10px] bg-surface-strong p-1`,children:z.map(e=>(0,L.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":o===e.id,onClick:()=>s(e.id),className:l(`inline-flex min-h-8 cursor-pointer items-center gap-1.5 rounded-[7px] border-0 px-3 text-sm font-medium`,o===e.id?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:[e.label,(0,L.jsx)(`span`,{className:l(`tabular-nums text-[12px]`,e.id===`waiting`&&S.waiting?`text-warn`:`text-muted`),children:S[e.id]})]},e.id))}),(0,L.jsx)(h,{id:`find-a-chat`,label:`Find a chat`,value:d,onChange:f})]}),r&&(0,L.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail`,children:r}),!t&&!r&&(0,L.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Loading…`}),t&&t.length===0&&(0,L.jsx)(g,{icon:c,title:`No chats yet`,action:(0,L.jsxs)(`a`,{className:v({size:`sm`}),href:p(),"data-tip":`Start a chat`,children:[(0,L.jsx)(c,{"aria-hidden":`true`}),`Chat`]}),children:`Ask ForgeQE to run test cases, explore a journey, write a test or review requirements. Each chat shows up here, and stays after forgeqe web restarts so you can carry it on.`}),t&&t.length>0&&T.length===0&&(0,L.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No chat matches.`}),T.length>0&&(0,L.jsxs)(`div`,{className:`@container rounded-[14px] card border`,children:[(0,L.jsxs)(`div`,{"aria-hidden":`true`,className:`hidden grid-cols-[minmax(0,1fr)_120px_90px_150px_96px] gap-x-4 border-b border-line-soft px-6 py-2 text-[12px] font-medium text-muted @3xl:grid`,children:[(0,L.jsx)(`span`,{children:`Chat`}),(0,L.jsx)(`span`,{children:`Status`}),(0,L.jsx)(`span`,{children:`Messages`}),(0,L.jsx)(`span`,{children:`Model`}),(0,L.jsx)(`span`,{className:`text-right`,children:`Last activity`})]}),E.map(e=>(0,L.jsxs)(`section`,{"aria-labelledby":`day-${e.day}`,children:[(0,L.jsxs)(`h2`,{id:`day-${e.day}`,className:`sticky top-0 z-[1] m-0 border-b border-line-soft bg-surface-muted/95 px-6 py-1.5 text-[12px] font-semibold tracking-wide text-muted uppercase backdrop-blur`,children:[e.day,` `,(0,L.jsxs)(`span`,{className:`font-normal tabular-nums`,children:[`· `,e.chats.length]})]}),(0,L.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-1.5`,children:e.chats.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(F,{c:e})},e.id))})]},e.day)),T.length>m&&(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-line-soft px-6 py-3 text-[13px] text-muted`,children:[(0,L.jsxs)(`span`,{children:[`Showing `,m,` of `,T.length]}),(0,L.jsxs)(u,{size:`sm`,onClick:()=>b(m+B),children:[(0,L.jsx)(a,{"aria-hidden":`true`}),`More (`,Math.min(B,T.length-m),`)`]})]})]})]})]})}export{R as Chat,V as Chats};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$n as e,$t as t,A as n,An as r,Ar as i,Dn as a,Ir as o,Nr as s,Zn as c,j as l,kr as u,ln as d,pn as f,wr as p}from"./line-icons-CQ-3V8ax.js";import{B as m,Dt as h,R as g,V as _,Wt as v,a as y,c as ee,f as b,h as te,l as x,o as S,ot as C,t as w,tt as T,z as E}from"./filters-B4VDnWbr.js";import{Et as D,Ot as O,_t as ne,at as k,ct as A,et as j,gt as re,it as M,nt as N,r as P,rt as F,st as I,t as L,tt as R}from"./frame-D-hqu7Oi.js";import{l as z,r as B}from"./index-CtX74khE.js";import{n as V}from"./segmented-BfWimTC0.js";import{a as H,c as U}from"./dataParts-B3Fz4S59.js";import{n as W,t as G}from"./desktopAppPath-CMac6aJ0.js";var K=o(s(),1),q=v(),J=[`workflows`,`runs`,`machine`],Y={replay:[`Replaying the workflow`,`Replayed the workflow`,`working`],explore:[`Exploring the app`,`Explored the app`,`thinking`],validate:[`Checking the workflow`,`Checked the workflow`,`searching`],setup:[`Setting up the desktop engine`,`Set up the desktop engine`,`working`],doctor:[`Checking this machine`,`Checked this machine`,`searching`]},ie={explore:`Explored`,record:`Recorded`,project:`Project`},ae={replay:`Replay`,explore:`Explore`,record:`Recording`},X=e=>e.mode===`replay`&&e.ok&&e.heals>0&&!e.healsAccepted;async function Z(e,t){try{let{id:t}=await T.start(e,{});location.hash=b(`chats`,t)}catch(e){t(e.message)}}function oe(){let[e,t]=(0,K.useState)(null),[n,r]=(0,K.useState)(``),[i,a]=(0,K.useState)(!1),o=(0,K.useCallback)(()=>{C.view().then(e=>{t(e),r(``)},e=>r(e.message))},[]);(0,K.useEffect)(o,[o]);let s=!!e?.job?.running;return(0,K.useEffect)(()=>{if(!s)return;let e=setInterval(o,1e3);return()=>clearInterval(e)},[s,o]),{view:e,error:n,setError:r,busy:i||s,act:async e=>{a(!0),r(``);try{return await e(),o(),!0}catch(e){return r(e.message),!1}finally{a(!1)}},load:o,stop:()=>void C.stop().then(o)}}function Q({on:e,set:t,children:n}){return(0,q.jsxs)(`label`,{className:`flex items-center gap-2.5 text-sm text-ink-2`,children:[(0,q.jsx)(ne,{checked:e,onChange:t,label:n}),n]})}function $({label:e,hint:t,children:n}){return(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium`,children:[e,n,t&&(0,q.jsx)(`span`,{className:`text-[12.5px] font-normal text-muted`,children:t})]})}function se({w:e,page:t,onClose:n}){let{view:r}=t,[o,s]=(0,K.useState)({}),[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(r.heal),[f,p]=(0,K.useState)(!1);(0,K.useEffect)(()=>{e&&(s(Object.fromEntries(e.variables.map(e=>[e.name,e.value]))),l(``),d(r.heal),p(!1))},[e,r.heal]);let m=c.startsWith(`file:`)?{file:c.slice(5)}:c.startsWith(`request:`)?{request:c.slice(8)}:void 0,h=`flex flex-col gap-3 rounded-[12px] card border p-3`;return(0,q.jsx)(O,{open:!!e,onClose:n,title:e?`Replay ${e.name}`:`Replay`,description:`Runs the workflow's steps in its app with no model, checking its expect steps. It takes over this machine's mouse and keyboard while it runs: use a test machine and a test account.`,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(g,{onClick:n,children:[(0,q.jsx)(i,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(g,{variant:`primary`,disabled:t.busy||!e,onClick:async()=>{e&&await t.act(()=>C.replay({workflow:e.path,variables:o,...m?{rows:m}:{},heal:u,updateBaselines:f}))&&n()},"data-tip":`Replay now`,children:[(0,q.jsx)(a,{"aria-hidden":`true`}),`Replay`]})]}),children:e&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-3`,children:[(0,q.jsxs)(`p`,{className:`m-0 flex flex-wrap gap-x-3 text-[13px] text-muted`,children:[(0,q.jsx)(`span`,{className:`font-mono`,children:e.path}),(0,q.jsxs)(`span`,{children:[e.app||`no app`,` · `,_(e.steps,`step`),` · `,_(e.checks,`check`)]})]}),e.checks===0&&(0,q.jsx)(`p`,{className:`m-0 rounded-[10px] bg-warn-soft px-3 py-2 text-[13px] text-warn`,children:`It has no checks of the outcome: a replay passes when its steps run. Ask the agent to add expect steps.`}),e.variables.length>0&&(0,q.jsxs)(`div`,{className:h,children:[(0,q.jsx)(`h3`,{className:`m-0 text-sm font-semibold`,children:`Values`}),(0,q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-3`,children:e.variables.map(e=>(0,q.jsx)($,{label:e.name,children:(0,q.jsx)(y,{value:o[e.name]??``,onChange:t=>s({...o,[e.name]:t.target.value})})},e.name))})]}),(0,q.jsxs)(`div`,{className:h,children:[(0,q.jsx)(`h3`,{className:`m-0 text-sm font-semibold`,children:`Test data`}),(0,q.jsx)($,{label:`Rows`,hint:`Each row replays the workflow once, its columns over the values above.`,children:(0,q.jsxs)(S,{value:c,onChange:e=>l(e.target.value),children:[(0,q.jsx)(`option`,{value:``,children:`Once, with the values above`}),r.rows.files.map(e=>(0,q.jsxs)(`option`,{value:`file:${e}`,children:[`Each row of `,e]},e)),r.rows.requests.map(e=>(0,q.jsxs)(`option`,{value:`request:${e}`,children:[`Each row of request `,e]},e))]})})]}),(0,q.jsxs)(`div`,{className:h,children:[(0,q.jsx)(`h3`,{className:`m-0 text-sm font-semibold`,children:`While it runs`}),(0,q.jsx)(Q,{on:u,set:d,children:`Heal a step whose control moved`}),(0,q.jsx)(Q,{on:f,set:p,children:`Take new image baselines`})]})]})})}function ce({open:e,page:t,onClose:r}){let{view:a}=t,[o,s]=(0,K.useState)(a.apps[0]?.name??``),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(``);return(0,q.jsx)(O,{open:e,onClose:r,title:`Explore a goal`,description:`UFO² carries out the goal in the app with a vision model and saves what it did as a workflow, with checks of the outcome, to replay with no model.`,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(g,{onClick:r,children:[(0,q.jsx)(i,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(g,{variant:`primary`,disabled:t.busy||!l.trim()||!o,onClick:async()=>{await t.act(()=>C.explore(o,l.trim(),d.trim()))&&(u(``),f(``),r())},"data-tip":`Start: UFO² takes over the mouse and keyboard`,children:[(0,q.jsx)(c,{"aria-hidden":`true`}),`Start exploring`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-3`,children:[(0,q.jsx)($,{label:`App`,children:(0,q.jsx)(S,{value:o,onChange:e=>s(e.target.value),children:a.apps.map(e=>(0,q.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,q.jsx)($,{label:`Goal`,hint:`One line, as you would ask a tester.`,children:(0,q.jsx)(y,{value:l,maxLength:500,placeholder:`Create an invoice for Contoso and save it`,onChange:e=>u(e.target.value)})}),(0,q.jsx)($,{label:`Name`,hint:`Optional: the workflow's name.`,children:(0,q.jsx)(y,{value:d,maxLength:80,onChange:e=>f(e.target.value)})}),(0,q.jsxs)(`p`,{className:`m-0 flex gap-2 rounded-[10px] bg-warn-soft px-3 py-2 text-[13px] text-warn`,children:[(0,q.jsx)(n,{size:16,"aria-hidden":`true`,className:`mt-0.5 flex-none`}),`UFO² controls this machine's mouse and keyboard in `,o||`the app`,`, in that app's windows only (no shell commands). Use a test machine and a test account.`]})]})})}function le({open:e,page:t,onClose:n}){let{view:r}=t,[a,o]=(0,K.useState)(r.windows),[s,c]=(0,K.useState)(!1);return(0,q.jsx)(O,{open:e,onClose:n,title:`Set up the desktop engine`,description:`Downloads ForgeQE's pinned packages for desktop replay on this machine, and takes a few minutes.`,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(g,{onClick:n,children:[(0,q.jsx)(i,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(g,{variant:`primary`,disabled:t.busy,onClick:async()=>{await t.act(()=>C.setup({ufo:r.windows&&a,force:s}))&&n()},children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Set up`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 pt-3`,children:[r.windows?(0,q.jsx)(Q,{on:a,set:o,children:`With UFO², for exploring a goal`}):(0,q.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`On this system workflows replay on agent-desktop, which this sets up too. Exploring and recording by hand need Windows.`}),(0,q.jsx)(Q,{on:s,set:c,children:`Set it up again from scratch`})]})})}function ue({open:e,page:t,onClose:n}){let[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(``),[h,_]=(0,K.useState)(!1),v=()=>{o(``),c(``),u(!1),f(``),m(``)};return(0,q.jsx)(O,{open:e,onClose:n,title:`Add a desktop app`,description:`The app's program on this computer: an .exe on Windows. It is added to the active environment's apps (or forgeqe.yaml's), so it can be recorded, explored and replayed by its name.`,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(g,{onClick:n,children:[(0,q.jsx)(i,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(g,{variant:`primary`,disabled:h||!a.trim()||!s.trim(),onClick:async()=>{_(!0),m(``);try{await C.addApp({name:s.trim(),path:a.trim(),...d.trim()?{description:d.trim()}:{}}),t.load(),v(),n()}catch(e){m(e.message)}finally{_(!1)}},children:[(0,q.jsx)(r,{"aria-hidden":`true`}),h?`Adding…`:`Add the app`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-3`,children:[(0,q.jsx)($,{label:`Program`,hint:`Type its path, or Browse to choose it on this computer.`,children:(0,q.jsx)(G,{value:a,onChange:e=>{o(e),l||c(e.trim()?W(e):``)},onPicked:(e,t)=>{l||c(t)},onError:m})}),(0,q.jsx)($,{label:`Name`,hint:`How workflows and the agent name it: letters, digits and _ . -`,children:(0,q.jsx)(y,{value:s,maxLength:40,spellCheck:!1,onChange:e=>{u(!0),c(e.target.value)}})}),(0,q.jsx)($,{label:`What it is for`,hint:`Optional: one line the agent reads to pick the app.`,children:(0,q.jsx)(y,{value:d,maxLength:200,placeholder:`Back-office invoicing`,onChange:e=>f(e.target.value)})}),p&&(0,q.jsx)(U,{text:p})]})})}function de({page:e,onReplay:n,onExplore:r}){let{view:i}=e,[o,s]=(0,K.useState)(i.apps[0]?.name??``),l=i.windows?void 0:i.windowsOnly,u=()=>e.act(async()=>{await h.start({kind:`desktop`,app:o}),location.hash=b(`record`)});return(0,q.jsx)(j,{label:`Desktop workflows`,minWidth:720,placeholder:`Find a workflow`,empty:`No workflows yet: record one by hand, explore a goal, or keep .yaml files with format: forgeqe-desktop-v1 in the project.`,tools:(0,q.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[i.apps.length>1&&(0,q.jsx)(S,{size:`sm`,"aria-label":`App to record`,value:o,onChange:e=>s(e.target.value),className:`w-auto`,children:i.apps.map(e=>(0,q.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,q.jsxs)(g,{size:`sm`,disabled:e.busy||!i.windows||!o,onClick:()=>void u(),"data-tip":l??`Record your steps in ${o}: no model`,children:[(0,q.jsx)(f,{"aria-hidden":`true`}),`Record by hand`]}),(0,q.jsxs)(g,{size:`sm`,variant:`primary`,disabled:e.busy||!i.windows||!i.apps.length,onClick:r,"data-tip":l??`UFO² carries out a goal and saves it as a workflow`,children:[(0,q.jsx)(c,{"aria-hidden":`true`}),`Explore a goal`]})]}),head:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`th`,{className:F,children:`Workflow`}),(0,q.jsx)(`th`,{className:F,children:`App`}),(0,q.jsx)(`th`,{className:M,children:`Steps`}),(0,q.jsx)(`th`,{className:M,children:`Checks`}),(0,q.jsx)(`th`,{className:F,children:`From`}),(0,q.jsx)(`th`,{className:F,children:(0,q.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:i.workflows.map(r=>(0,q.jsxs)(`tr`,{className:k,children:[(0,q.jsx)(`td`,{className:R,children:(0,q.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:r.name}),(0,q.jsx)(`span`,{className:`max-w-[300px] truncate font-mono text-[12px] text-muted`,"data-tip":r.path,children:r.path})]})}),(0,q.jsx)(`td`,{className:m(R,`whitespace-nowrap`),children:r.app||(0,q.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,q.jsx)(`td`,{className:N,children:r.steps}),(0,q.jsx)(`td`,{className:m(N,r.checks===0&&`text-warn`),"data-tip":r.checks===0?`No checks of the outcome: a replay passes when its steps run`:void 0,children:r.checks}),(0,q.jsxs)(`td`,{className:m(R,`whitespace-nowrap`),children:[ie[r.from],(0,q.jsx)(`span`,{className:`block text-[12px] text-muted`,children:B(r.modified)})]}),(0,q.jsx)(`td`,{className:m(R,`whitespace-nowrap text-right`),children:(0,q.jsxs)(`span`,{className:`inline-flex gap-1`,children:[(0,q.jsx)(g,{size:`icon`,variant:`icon`,disabled:e.busy,onClick:()=>n(r),"aria-label":`Replay ${r.name}`,"data-tip":`Replay ${r.name}`,className:`size-8`,children:(0,q.jsx)(a,{"aria-hidden":`true`})}),(0,q.jsx)(g,{size:`icon`,variant:`icon`,disabled:e.busy,onClick:()=>void e.act(()=>C.validate(r.path)),"aria-label":`Check ${r.name}`,"data-tip":`Check it without running it`,className:`size-8`,children:(0,q.jsx)(t,{"aria-hidden":`true`})}),(0,q.jsx)(g,{size:`icon`,variant:`icon`,onClick:()=>void Z(`Desktop agent: look at the desktop workflow ${r.path} and tell me what to fix or add (a wait, a timeout, a dialog to dismiss, checks of the outcome); change it with desktop_edit_workflow only after showing me the change.`,e.setError),"aria-label":`Improve ${r.name} with the agent`,"data-tip":`Improve it with the agent`,className:`size-8`,children:(0,q.jsx)(p,{"aria-hidden":`true`})})]})})]},r.path))})}function fe({page:e}){let{view:t}=e,[n,r]=(0,K.useState)(`all`),[i,a]=(0,K.useState)(``),o=t.runs.filter(e=>!e.ok),s=t.runs.filter(X),c=n===`failed`?o:n===`heals`?s:t.runs;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[i&&(0,q.jsx)(`p`,{role:`status`,className:`m-0 rounded-[10px] bg-pass-soft px-3 py-1.5 text-[13px] text-pass`,children:i}),(0,q.jsx)(j,{label:`Desktop runs`,minWidth:720,resetKey:n,placeholder:`Find a run`,empty:n===`all`?`No desktop runs yet: replay, record or explore a workflow.`:`None.`,tools:(0,q.jsx)(w,{value:n,onChange:r,items:[{id:`all`,label:`All`,n:t.runs.length},{id:`failed`,label:`Failed`,n:o.length,alert:!0},{id:`heals`,label:`Heals to accept`,n:s.length}]}),head:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`th`,{className:F,children:`Run`}),(0,q.jsx)(`th`,{className:F,children:`Result`}),(0,q.jsx)(`th`,{className:M,children:`Steps`}),(0,q.jsx)(`th`,{className:F,children:`Heals`}),(0,q.jsx)(`th`,{className:F,children:(0,q.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:c.map(t=>(0,q.jsxs)(`tr`,{className:k,children:[(0,q.jsx)(`td`,{className:R,children:(0,q.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,q.jsxs)(`span`,{className:`font-medium`,children:[ae[t.mode],`: `,t.name]}),(0,q.jsx)(`span`,{className:`text-[12px] text-muted`,children:[t.app,B(t.at)].filter(Boolean).join(` · `)}),(t.failed||t.error)&&(0,q.jsx)(`span`,{className:`max-w-[380px] truncate text-[12px] text-fail`,"data-tip":t.failed?t.failed.error:t.error,children:t.failed?`Step ${t.failed.index} (${t.failed.op}): ${t.failed.error||`failed`}`:t.error})]})}),(0,q.jsx)(`td`,{className:m(R,`whitespace-nowrap`),children:(0,q.jsx)(ee,{tone:t.ok?`pass`:`fail`,children:t.many?`${t.many.passed} of ${t.many.total}`:t.ok?`Passed`:`Failed`})}),(0,q.jsx)(`td`,{className:N,children:t.steps||(0,q.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,q.jsx)(`td`,{className:m(R,`whitespace-nowrap`),children:t.heals?t.healsAccepted?(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[13px] text-pass`,children:[(0,q.jsx)(l,{size:14,"aria-hidden":`true`}),`In the workflow`]}):t.ok?(0,q.jsxs)(g,{size:`sm`,disabled:e.busy,onClick:()=>void e.act(async()=>{let e=await C.acceptHeals(t.dir);a(`Wrote ${_(e.written,`healed step`)} into ${e.workflow}.`)}),"data-tip":`Write the new locators into the workflow`,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Accept `,_(t.heals,`heal`)]}):(0,q.jsxs)(`span`,{className:`text-[13px] text-muted`,"data-tip":`The replay failed after healing, so its heals may be wrong`,children:[_(t.heals,`heal`),`, not offered`]}):(0,q.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,q.jsx)(`td`,{className:m(R,`whitespace-nowrap text-right`),children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[t.report&&(0,q.jsx)(z,{path:t.report,children:`Report`}),!t.ok&&(0,q.jsx)(g,{size:`icon`,variant:`icon`,onClick:()=>void Z(`Desktop agent: the desktop ${t.mode} ${t.dir} failed${t.workflow?` (workflow ${t.workflow})`:``}. Read its report, tell me why, and offer a fix.`,e.setError),"aria-label":`Ask the agent why it failed`,"data-tip":`Ask the agent why it failed`,className:`size-8`,children:(0,q.jsx)(d,{"aria-hidden":`true`})})]})})]},t.dir))})]})}function pe({page:e,onSetup:i,onAdd:a}){let{view:o}=e,s=o.driver===`auto`?o.windows?`pywinauto`:`agent-desktop`:o.driver,c=[{label:`Replay`,ok:o.engine.ready,note:o.engine.ready?`On ${s}`:(o.engine.error||`The desktop engine is not set up`).replace(/^./,e=>e.toUpperCase())},{label:`Explore and record`,ok:o.windows&&o.engine.ufo,note:o.windows?o.engine.ufo?`UFO² is set up`:`UFO² is not set up`:`Windows only`},{label:`Healing`,ok:o.heal,note:o.heal?`A moved control is healed with the model`:`desktop.heal is off`}],d=`flex flex-col rounded-[12px] card border`;return(0,q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,320px),1fr))] items-start gap-6`,children:[(0,q.jsxs)(`section`,{"aria-labelledby":`desktop-machine`,className:`flex flex-col gap-2`,children:[(0,q.jsx)(`h2`,{id:`desktop-machine`,className:`m-0 text-[13px] font-semibold text-muted`,children:`This machine`}),(0,q.jsx)(`ul`,{className:m(d,`m-0 list-none divide-y divide-line-soft p-0`),children:c.map(e=>(0,q.jsxs)(`li`,{className:`flex items-start gap-2.5 px-3 py-2.5`,children:[e.ok?(0,q.jsx)(l,{size:16,"aria-label":`Ready`,className:`mt-0.5 flex-none text-pass`}):(0,q.jsx)(n,{size:16,"aria-label":`Not ready`,className:`mt-0.5 flex-none text-warn`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-medium`,children:e.label}),(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted [overflow-wrap:anywhere]`,"data-tip":!e.ok&&e.label===`Explore and record`&&o.windowsOnly?o.windowsOnly:void 0,children:e.note})]})]},e.label))}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsxs)(g,{size:`sm`,disabled:e.busy,onClick:()=>void e.act(()=>C.doctor()),"data-tip":`Whether replay can run here unattended`,children:[(0,q.jsx)(t,{"aria-hidden":`true`}),`Check`]}),(0,q.jsxs)(g,{size:`sm`,variant:o.engine.ready?`outline`:`primary`,disabled:e.busy,onClick:i,"data-tip":`Download and set up the desktop engine`,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Set up`]})]})]}),(0,q.jsxs)(`section`,{"aria-labelledby":`desktop-apps`,className:`flex flex-col gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,q.jsx)(`h2`,{id:`desktop-apps`,className:`m-0 flex-1 text-[13px] font-semibold text-muted`,children:`Apps`}),(0,q.jsxs)(g,{size:`sm`,onClick:a,"data-tip":`Add an app by its program on this computer`,children:[(0,q.jsx)(r,{"aria-hidden":`true`}),`Add an app`]})]}),o.apps.length?(0,q.jsx)(`ul`,{className:m(d,`m-0 list-none divide-y divide-line-soft p-0`),children:o.apps.map(e=>(0,q.jsxs)(`li`,{className:`flex items-start gap-2.5 px-3 py-2.5`,children:[(0,q.jsx)(te,{icon:f,size:16,className:`mt-0.5 flex-none text-muted`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-medium`,children:e.name}),(0,q.jsx)(`span`,{className:`truncate font-mono text-[12px] text-muted`,"data-tip":e.path,children:e.path||`No path`}),e.description&&(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:e.description})]})]},e.name))}):(0,q.jsxs)(x,{className:`py-3`,children:[`No desktop apps yet: add one by its program, or in `,(0,q.jsx)(`a`,{href:b(`settings`,`environments`),children:`Settings, Environments`}),`.`]}),(0,q.jsxs)(`p`,{className:`m-0 text-[12.5px] text-muted`,children:[`Secrets a workflow may type: `,o.secrets.length?o.secrets.join(`, `):`none`,`.`,o.refusedSecrets.length>0&&(0,q.jsxs)(`span`,{className:`text-fail`,children:[` `,o.refusedSecrets.join(`, `),` `,o.refusedSecrets.length===1?`is`:`are`,` ForgeQE's own: take `,o.refusedSecrets.length===1?`it`:`them`,` out of desktop.secrets, or nothing replays.`]})]})]})]})}function me({view:e,onTab:t}){let n=e.runs.filter(e=>e.mode===`replay`),r=n.filter(e=>e.ok).length,i=n[0],a=e.runs.filter(X).length,o=e.workflows.filter(e=>e.checks===0).length;return(0,q.jsxs)(A,{label:`Desktop at a glance`,children:[(0,q.jsx)(I,{compact:!0,label:`Workflows`,value:e.workflows.length,note:o?(0,q.jsxs)(`span`,{className:`text-warn`,children:[o,` without checks`]}):`${_(e.apps.length,`app`)}`}),(0,q.jsx)(I,{compact:!0,label:`Replays passed`,value:n.length?`${r} of ${n.length}`:`—`,tone:n.length&&r<n.length?`text-fail`:void 0,note:i?`Last ${B(i.at)}`:`None yet`}),(0,q.jsx)(I,{compact:!0,label:`Heals to accept`,value:a,tone:a?`text-accent-fg`:void 0,note:a?(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(`runs`),className:`cursor-pointer border-0 bg-transparent p-0 text-[13px] text-accent-fg hover:underline`,children:`Review them`}):`From passed replays`}),(0,q.jsx)(I,{compact:!0,label:`Replay here`,value:e.engine.ready?`Ready`:`Not set up`,tone:e.engine.ready?`text-pass`:`text-warn`,note:e.engine.ready?e.windows?`Windows`:`Explore needs Windows`:(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(`machine`),className:`cursor-pointer border-0 bg-transparent p-0 text-[13px] text-accent-fg hover:underline`,children:`Set it up`})})]})}function he({sub:t}){let n=oe(),{view:r,error:i}=n,a=J.includes(t)?t:`workflows`,[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[u,f]=(0,K.useState)(!1),[p,h]=(0,K.useState)(!1),_=r?.job??null,v=e=>location.hash=b(`desktop`,e),y={workflows:`Workflows${r?` (${r.workflows.length})`:``}`,runs:`Runs${r?` (${r.runs.length})`:``}`,machine:`Machine and apps`};return(0,q.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,q.jsx)(P,{}),(0,q.jsxs)(`main`,{className:m(L,`@container flex-auto gap-4`),children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,q.jsx)(D,{pixel:re.desktop,size:`lg`}),(0,q.jsx)(`h1`,{className:`m-0 flex-1 text-[26px] font-semibold tracking-[-0.01em]`,children:`Desktop apps`}),(0,q.jsxs)(`a`,{href:b(`agents`,`desktop`),"data-tip":`Ask the Desktop agent`,className:m(E({size:`sm`}),`no-underline`),children:[(0,q.jsx)(d,{"aria-hidden":`true`}),`Ask the agent`]})]}),(0,q.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2`,children:`Workflows for Windows thick-client apps: explore a goal with UFO² or record your steps by hand, then replay them with no model, a moved control healed and offered for the workflow.`}),i&&(0,q.jsx)(U,{text:i}),!r&&!i&&(0,q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),r&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(me,{view:r,onTab:v}),_&&(_.running||!_.endedAt||Date.now()-Date.parse(_.endedAt)<6e5)&&(0,q.jsx)(H,{job:_,onStop:n.stop,words:Y}),_?.question&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[12px] bg-accent-soft p-3 text-[13.5px]`,children:[(0,q.jsx)(`p`,{className:`m-0 font-medium`,children:_.question.title}),_.question.detail&&(0,q.jsx)(`p`,{className:`m-0 text-ink-2`,children:_.question.detail}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[_.question.options.map(e=>(0,q.jsx)(g,{size:`sm`,onClick:()=>void n.act(()=>C.answer(_.question.id,e.id)),children:e.label},e.id)),(0,q.jsxs)(g,{size:`sm`,variant:`danger`,onClick:()=>void n.act(()=>C.answer(_.question.id,null)),children:[(0,q.jsx)(e,{fill:`currentColor`,"aria-hidden":`true`}),`Stop`]})]})]}),(0,q.jsx)(V,{label:`Desktop apps`,current:a,onPick:v,tabs:J.map(e=>({id:e,label:y[e]}))}),(0,q.jsxs)(`div`,{role:`tabpanel`,id:`panel-${a}`,"aria-labelledby":`tab-${a}`,children:[a===`workflows`&&(0,q.jsx)(de,{page:{...n,view:r},onReplay:s,onExplore:()=>l(!0)}),a===`runs`&&(0,q.jsx)(fe,{page:{...n,view:r}}),a===`machine`&&(0,q.jsx)(pe,{page:{...n,view:r},onSetup:()=>f(!0),onAdd:()=>h(!0)})]}),(0,q.jsx)(se,{w:o,page:{...n,view:r},onClose:()=>s(null)}),(0,q.jsx)(ce,{open:c,page:{...n,view:r},onClose:()=>l(!1)}),(0,q.jsx)(le,{open:u,page:{...n,view:r},onClose:()=>f(!1)}),(0,q.jsx)(ue,{open:p,page:{...n,view:r},onClose:()=>h(!1)})]})]})]})}export{he as Desktop};
|