@reason-machines/cli-linux-arm64-musl 0.2.381 → 0.2.382
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 +3 -1
- package/bin/ara +2 -2
- package/bin/vm-hands/api-credentials-xppmbg0m.js +2 -0
- package/bin/vm-hands/api-xmpbsm6b.js +2 -0
- package/bin/vm-hands/{ask-relay-fc0jc3t5.js → ask-relay-zjqyxvxe.js} +3 -3
- package/bin/vm-hands/connect-cli-ehxeg8m5.js +2 -0
- package/bin/vm-hands/{custom-endpoint-device-zhpake9f.js → custom-endpoint-device-bm94e9r0.js} +1 -1
- package/bin/vm-hands/desktop-account-3tnm4z5w.js +2 -0
- package/bin/vm-hands/{device-workspace-vbcry9d6.js → device-workspace-0xsj5ykf.js} +1 -1
- package/bin/vm-hands/hands-worker-source-azdrrhsz.js +2 -0
- package/bin/vm-hands/{index-bbk6a9sk.js → index-7f2kwwen.js} +1 -1
- package/bin/vm-hands/{install-receipt-7x81ek76.js → install-receipt-3xyx3rdd.js} +1 -1
- package/bin/vm-hands/local-automation-ynx1qr9v.js +2 -0
- package/bin/vm-hands/local-capabilities-855ch0dq.js +2 -0
- package/bin/vm-hands/local-desktop-users-ajb81vjm.js +2 -0
- package/bin/vm-hands/local-display-mac-9h6btvvq.js +2 -0
- package/bin/vm-hands/local-display-session-f9ywkbba.js +2 -0
- package/bin/vm-hands/local-pty-session-cjas515w.js +2 -0
- package/bin/vm-hands/managed-runtime-dars4628.js +2 -0
- package/bin/vm-hands/{network-contract-zqvt1v0t.js → network-contract-dsw79qkc.js} +1 -1
- package/bin/vm-hands/package-smk3nqjs.js +2 -0
- package/bin/vm-hands/permissions-pdmhp2s3.js +2 -0
- package/bin/vm-hands/{reason-hands-protocol-8fxjynte.js → reason-hands-protocol-7d7xj1h3.js} +1 -1
- package/bin/vm-hands/serve-service-n6xd6323.js +2 -0
- package/bin/vm-hands/status-2m75kz1h.js +96 -0
- package/bin/vm-hands/version-74zqccyz.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-06qnb2w1.js +458 -0
- package/bin/vm-hands/{vm-hands-entry-lite-7shpbsw8.js → vm-hands-entry-lite-1gxktkpe.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-hgkf1svv.js → vm-hands-entry-lite-23bb8ce4.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-245929bs.js +346 -0
- package/bin/vm-hands/vm-hands-entry-lite-2e18tm6w.js +245 -0
- package/bin/vm-hands/{vm-hands-entry-lite-g036gtem.js → vm-hands-entry-lite-2t0vcvd8.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-0asdf4pm.js → vm-hands-entry-lite-2tcjqgfp.js} +3 -3
- package/bin/vm-hands/vm-hands-entry-lite-3n3xh0xv.js +540 -0
- package/bin/vm-hands/vm-hands-entry-lite-50n6vbfx.js +251 -0
- package/bin/vm-hands/{vm-hands-entry-lite-j2q1k9vb.js → vm-hands-entry-lite-51hmj6am.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-zfwg7ehq.js → vm-hands-entry-lite-5n4vsm6b.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-8fj07njx.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-4q8tsaqv.js → vm-hands-entry-lite-8zawqa9q.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-3hbe4em3.js → vm-hands-entry-lite-9cmfthkq.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-45j8qwsf.js → vm-hands-entry-lite-9w5vs9zv.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-k7wwza46.js → vm-hands-entry-lite-aj1ccphg.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-za55dtte.js → vm-hands-entry-lite-ammr3xbc.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-yjn6sk08.js → vm-hands-entry-lite-ch7y4b1b.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-34e71nbe.js → vm-hands-entry-lite-cwe16c51.js} +174 -16
- package/bin/vm-hands/vm-hands-entry-lite-dh5gwmyf.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-dsdwzasy.js +105 -0
- package/bin/vm-hands/{vm-hands-entry-lite-5pm6bhb8.js → vm-hands-entry-lite-e0gdt6r5.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-5kgvss4p.js → vm-hands-entry-lite-e2mjbqmr.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-ejm5er3h.js +7 -0
- package/bin/vm-hands/{vm-hands-entry-lite-mh0xecf3.js → vm-hands-entry-lite-f02906k8.js} +4 -4
- package/bin/vm-hands/vm-hands-entry-lite-f5230h6t.js +67 -0
- package/bin/vm-hands/{vm-hands-entry-lite-zh8p7ndn.js → vm-hands-entry-lite-fb5dzy9x.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-fyvgav60.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-g7h6wjqy.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-h8dbw0c7.js +4 -0
- package/bin/vm-hands/{vm-hands-entry-lite-nhtb458c.js → vm-hands-entry-lite-hnsm5t36.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-r6pap1kh.js → vm-hands-entry-lite-ma001vzh.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-anmv8hp7.js → vm-hands-entry-lite-mn64e4pt.js} +286 -104
- package/bin/vm-hands/{vm-hands-entry-lite-9cgm6g8t.js → vm-hands-entry-lite-pk3q774c.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-qef2ndkd.js +6 -0
- package/bin/vm-hands/vm-hands-entry-lite-qnnfvm5r.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-qwf78yqr.js +11 -0
- package/bin/vm-hands/vm-hands-entry-lite-r8qg3wp1.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-rd0ak4ye.js +4 -0
- package/bin/vm-hands/{vm-hands-entry-lite-00qsbphw.js → vm-hands-entry-lite-rpn0frzb.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-g9rvf5qk.js → vm-hands-entry-lite-rtt2w6c6.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-sex82vb1.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-dgxxsdwb.js → vm-hands-entry-lite-xrthfx3q.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-kxdw4myj.js → vm-hands-entry-lite-y2s2w174.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-hc3p6r9p.js → vm-hands-entry-lite-zjfr0zh8.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
- package/bin/vm-hands/{vm-hands-executor-qssgfea1.js → vm-hands-executor-yx6mxa2p.js} +1 -1
- package/bin/vm-hands/vm-hands-op-runner-yt3v3v6w.js +2 -0
- package/bin/vm-hands/{vm-hands-runtime-5me6cpmn.js → vm-hands-runtime-ygddqgbs.js} +3 -3
- package/bin/vm-hands/worker-sandbox-tgqbmy6b.js +2 -0
- package/package.json +1 -1
- package/bin/vm-hands/api-af9g18n7.js +0 -2
- package/bin/vm-hands/api-credentials-65mrr3tn.js +0 -2
- package/bin/vm-hands/connect-cli-j478km3s.js +0 -2
- package/bin/vm-hands/desktop-account-5zvgspyw.js +0 -2
- package/bin/vm-hands/hands-worker-source-h0b1j53p.js +0 -2
- package/bin/vm-hands/local-automation-c86tjeft.js +0 -2
- package/bin/vm-hands/local-capabilities-1h99gkt6.js +0 -2
- package/bin/vm-hands/local-desktop-users-0hadyvx1.js +0 -2
- package/bin/vm-hands/local-display-mac-v1pc7177.js +0 -2
- package/bin/vm-hands/local-display-session-tzq0hne8.js +0 -2
- package/bin/vm-hands/local-pty-session-hs7rq03x.js +0 -2
- package/bin/vm-hands/managed-runtime-5dqaaw1x.js +0 -2
- package/bin/vm-hands/package-3cd7cfyv.js +0 -2
- package/bin/vm-hands/permissions-vbyqjbyb.js +0 -2
- package/bin/vm-hands/serve-service-be739c9s.js +0 -2
- package/bin/vm-hands/status-s8ny6men.js +0 -96
- package/bin/vm-hands/version-8s4syrp2.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-1085xsma.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-4m40gwkf.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-62wmnm7g.js +0 -540
- package/bin/vm-hands/vm-hands-entry-lite-98076n5g.js +0 -62
- package/bin/vm-hands/vm-hands-entry-lite-bvbfcp1k.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-c01eyep6.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-dcynw6t2.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-hh24bq0d.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-jb2sr2r7.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-kt5aj2ax.js +0 -11
- package/bin/vm-hands/vm-hands-entry-lite-n9nnb482.js +0 -459
- package/bin/vm-hands/vm-hands-entry-lite-sb9a1jcn.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-xg3d0a2y.js +0 -340
- package/bin/vm-hands/vm-hands-entry-lite-zamt8xp7.js +0 -181
- package/bin/vm-hands/vm-hands-entry-lite-ze9msfq1.js +0 -3
- package/bin/vm-hands/vm-hands-op-runner-b76rjaps.js +0 -2
- package/bin/vm-hands/worker-sandbox-wpzkvwer.js +0 -2
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{vg as k0}from"./vm-hands-entry-lite-dh5gwmyf.js";import{Mg as f0}from"./vm-hands-entry-lite-xrthfx3q.js";import{Sg as uq}from"./vm-hands-entry-lite-fb5dzy9x.js";import{ej as cq}from"./vm-hands-entry-lite-8zawqa9q.js";import{lj as i}from"./vm-hands-entry-lite-fyvgav60.js";import{$j as G8,Uj as _,Xj as g0,_j as h0,ak as y0,ck as l8,fk as G0,hk as A0}from"./vm-hands-entry-lite-1gxktkpe.js";import{jk as H0}from"./vm-hands-entry-lite-rd0ak4ye.js";import{Ek as K}from"./vm-hands-entry-lite-51hmj6am.js";import{execFile as f1,spawn as I0}from"child_process";import{randomBytes as g1}from"crypto";import{chmodSync as h1,existsSync as p0,lstatSync as k1,mkdirSync as I1,readFileSync as p1,rmSync as v1,writeFileSync as Wq}from"fs";import{connect as u1}from"net";import{join as $}from"path";var Gq="./desktop-wallpaper-0pjhgyfk.jpg";var Aq="./dock-browser-afp005mt.png";var Sq="./dock-files-rywdm96b.png";var Vq="./dock-terminal-s41cj1jp.png";var Fq=`# Sets the X root window background and _XROOTPMAP_ID, as feh --bg-fill does.
|
|
3
|
+
# The native Blaxel image ships no feh, hsetroot or compositor, but it does ship
|
|
4
|
+
# python3-gi and libX11. tint2 reads _XROOTPMAP_ID to draw its transparent panel.
|
|
5
|
+
# Usage: DISPLAY=:99 python3 set-root-wallpaper.py IMAGE
|
|
6
|
+
import ctypes, sys
|
|
7
|
+
import gi
|
|
8
|
+
gi.require_version("GdkPixbuf", "2.0")
|
|
9
|
+
from gi.repository import GdkPixbuf
|
|
10
|
+
x = ctypes.cdll.LoadLibrary("libX11.so.6")
|
|
11
|
+
x.XOpenDisplay.restype = ctypes.c_void_p
|
|
12
|
+
x.XOpenDisplay.argtypes = [ctypes.c_char_p]
|
|
13
|
+
d = x.XOpenDisplay(None)
|
|
14
|
+
if not d: sys.exit("no display")
|
|
15
|
+
for name, res, args in [
|
|
16
|
+
("XDefaultScreen", ctypes.c_int, [ctypes.c_void_p]),
|
|
17
|
+
("XRootWindow", ctypes.c_ulong, [ctypes.c_void_p, ctypes.c_int]),
|
|
18
|
+
("XDisplayWidth", ctypes.c_int, [ctypes.c_void_p, ctypes.c_int]),
|
|
19
|
+
("XDisplayHeight", ctypes.c_int, [ctypes.c_void_p, ctypes.c_int]),
|
|
20
|
+
("XDefaultDepth", ctypes.c_int, [ctypes.c_void_p, ctypes.c_int]),
|
|
21
|
+
("XDefaultVisual", ctypes.c_void_p, [ctypes.c_void_p, ctypes.c_int]),
|
|
22
|
+
("XDefaultGC", ctypes.c_void_p, [ctypes.c_void_p, ctypes.c_int]),
|
|
23
|
+
("XCreatePixmap", ctypes.c_ulong, [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint]),
|
|
24
|
+
("XCreateImage", ctypes.c_void_p, [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int, ctypes.c_int, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint, ctypes.c_int, ctypes.c_int]),
|
|
25
|
+
("XPutImage", ctypes.c_int, [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_uint, ctypes.c_uint]),
|
|
26
|
+
("XInternAtom", ctypes.c_ulong, [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_int]),
|
|
27
|
+
("XChangeProperty", ctypes.c_int, [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_int, ctypes.c_int, ctypes.c_void_p, ctypes.c_int]),
|
|
28
|
+
("XSetWindowBackgroundPixmap", ctypes.c_int, [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_ulong]),
|
|
29
|
+
("XClearWindow", ctypes.c_int, [ctypes.c_void_p, ctypes.c_ulong]),
|
|
30
|
+
("XSetCloseDownMode", ctypes.c_int, [ctypes.c_void_p, ctypes.c_int]),
|
|
31
|
+
("XCloseDisplay", ctypes.c_int, [ctypes.c_void_p]),
|
|
32
|
+
]:
|
|
33
|
+
f = getattr(x, name); f.restype = res; f.argtypes = args
|
|
34
|
+
s = x.XDefaultScreen(d); root = x.XRootWindow(d, s)
|
|
35
|
+
w, h = x.XDisplayWidth(d, s), x.XDisplayHeight(d, s)
|
|
36
|
+
if x.XDefaultDepth(d, s) != 24: sys.exit("unsupported depth")
|
|
37
|
+
# Scale to cover the screen, then crop the centre.
|
|
38
|
+
src = GdkPixbuf.Pixbuf.new_from_file(sys.argv[1])
|
|
39
|
+
k = max(w / src.get_width(), h / src.get_height())
|
|
40
|
+
sw, sh = max(w, round(src.get_width() * k)), max(h, round(src.get_height() * k))
|
|
41
|
+
pb = src.scale_simple(sw, sh, GdkPixbuf.InterpType.BILINEAR).new_subpixbuf((sw - w) // 2, (sh - h) // 2, w, h).copy()
|
|
42
|
+
if pb.get_has_alpha(): pb = pb.composite_color_simple(w, h, GdkPixbuf.InterpType.NEAREST, 255, 1, 0, 0)
|
|
43
|
+
rgb, stride = pb.get_pixels(), pb.get_rowstride()
|
|
44
|
+
bgrx = bytearray(w * h * 4)
|
|
45
|
+
for y in range(h):
|
|
46
|
+
row = rgb[y * stride:y * stride + w * 3]; o = y * w * 4
|
|
47
|
+
bgrx[o:o + w * 4:4] = row[2::3]; bgrx[o + 1:o + w * 4:4] = row[1::3]; bgrx[o + 2:o + w * 4:4] = row[0::3]
|
|
48
|
+
buf = ctypes.create_string_buffer(bytes(bgrx), len(bgrx))
|
|
49
|
+
pix = x.XCreatePixmap(d, root, w, h, 24)
|
|
50
|
+
img = x.XCreateImage(d, x.XDefaultVisual(d, s), 24, 2, 0, buf, w, h, 32, 0) # ZPixmap
|
|
51
|
+
x.XPutImage(d, pix, x.XDefaultGC(d, s), img, 0, 0, 0, 0, w, h)
|
|
52
|
+
ref = ctypes.c_ulong(pix)
|
|
53
|
+
for atom in (b"_XROOTPMAP_ID", b"ESETROOT_PMAP_ID"):
|
|
54
|
+
x.XChangeProperty(d, root, x.XInternAtom(d, atom, 0), 20, 32, 0, ctypes.byref(ref), 1) # XA_PIXMAP, PropModeReplace
|
|
55
|
+
x.XSetWindowBackgroundPixmap(d, root, pix)
|
|
56
|
+
x.XClearWindow(d, root)
|
|
57
|
+
x.XSetCloseDownMode(d, 1) # RetainPermanent: the pixmap outlives this process
|
|
58
|
+
x.XCloseDisplay(d)
|
|
59
|
+
`;var Q8=32,Kq=76;function qx(q){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
60
|
+
<openbox_config xmlns="http://openbox.org/3.4/rc">
|
|
61
|
+
<theme><keepBorder>no</keepBorder></theme>
|
|
62
|
+
<applications>
|
|
63
|
+
<!-- Debian Chromium is "Chromium"; Chrome for Testing is "Chromium-browser". -->
|
|
64
|
+
<application class="Chromium*">
|
|
65
|
+
<decor>no</decor>
|
|
66
|
+
<position force="yes"><x>${Q8}</x><y>${Q8}</y></position>
|
|
67
|
+
<size><width>${q.width-Q8*2}</width><height>${q.height-Q8-Kq}</height></size>
|
|
68
|
+
</application>
|
|
69
|
+
</applications>
|
|
70
|
+
</openbox_config>`}var xx=`# Remote sandbox dock \u2014 launcher icons only, centred, no panel fill
|
|
71
|
+
panel_items = L
|
|
72
|
+
panel_size = 100% 46
|
|
73
|
+
panel_margin = 0 10
|
|
74
|
+
panel_padding = 0 0 10
|
|
75
|
+
panel_position = bottom center horizontal
|
|
76
|
+
panel_shrink = 1
|
|
77
|
+
panel_background_id = 0
|
|
78
|
+
panel_layer = top
|
|
79
|
+
mouse_effects = 1
|
|
80
|
+
mouse_hover_icon_asb = 100 0 12
|
|
81
|
+
mouse_pressed_icon_asb = 100 0 -12
|
|
82
|
+
|
|
83
|
+
launcher_icon_size = 46
|
|
84
|
+
launcher_padding = 0 0 10
|
|
85
|
+
launcher_background_id = 0
|
|
86
|
+
launcher_tooltip = 1
|
|
87
|
+
|
|
88
|
+
launcher_item_app = /tmp/ara-chromium.desktop
|
|
89
|
+
launcher_item_app = /tmp/ara-terminal.desktop
|
|
90
|
+
launcher_item_app = /tmp/ara-files.desktop
|
|
91
|
+
`,Qx=`corner-radius = 12;
|
|
92
|
+
rounded-corners-exclude = [
|
|
93
|
+
"class_g = 'tint2'",
|
|
94
|
+
"window_type = 'dock'",
|
|
95
|
+
"window_type = 'desktop'"
|
|
96
|
+
];
|
|
97
|
+
backend = "xrender";
|
|
98
|
+
shadow = false;
|
|
99
|
+
fading = false;
|
|
100
|
+
vsync = false;
|
|
101
|
+
inactive-opacity = 1.0;
|
|
102
|
+
active-opacity = 1.0;
|
|
103
|
+
`,Xx="/tmp/ara-dock-browser.png",Px=`[Desktop Entry]
|
|
104
|
+
Name=Chrome
|
|
105
|
+
Exec=chromium --no-sandbox %U
|
|
106
|
+
Icon=${Xx}
|
|
107
|
+
Type=Application
|
|
108
|
+
Categories=Network;WebBrowser;
|
|
109
|
+
`,bx=`[Desktop Entry]
|
|
110
|
+
Name=Terminal
|
|
111
|
+
Exec=bash -c "DISPLAY=:99 xterm -fa DejaVuSansMono -fs 11 -bg black -fg white"
|
|
112
|
+
Icon=/tmp/ara-dock-terminal.png
|
|
113
|
+
Type=Application
|
|
114
|
+
Categories=System;TerminalEmulator;
|
|
115
|
+
`,Jx=`[Desktop Entry]
|
|
116
|
+
Name=Files
|
|
117
|
+
Exec=bash -c "DISPLAY=:99 pcmanfm --no-desktop"
|
|
118
|
+
Icon=/tmp/ara-dock-files.png
|
|
119
|
+
Type=Application
|
|
120
|
+
Categories=System;FileManager;
|
|
121
|
+
`;var zq={"wallpaper.jpg":Gq,"dock-browser.png":Aq,"dock-terminal.png":Vq,"dock-files.png":Sq},Wx=Fq,Nx='set_wallpaper() { if command -v feh >/dev/null 2>&1; then feh --bg-fill "$1"; else python3 "$2" "$1"; fi; }';function Mq(q){let x=(J)=>J.replaceAll("DISPLAY=:99",`DISPLAY=${q.display}`).replaceAll("/tmp/ara-",`${q.root}/ara-`),Q=new Set(q.absent??[]),P=xx.split(`
|
|
122
|
+
`).filter((J)=>!(Q.has("terminal")&&J.endsWith("/ara-terminal.desktop"))&&!(Q.has("files")&&J.endsWith("/ara-files.desktop"))).join(`
|
|
123
|
+
`);return{files:{"openbox/rc.xml":qx(q.screen),"tint2/tint2rc":x(P),"picom/picom.conf":Qx,...Q.has("terminal")?{}:{"ara-terminal.desktop":x(bx)},...Q.has("files")?{}:{"ara-files.desktop":x(Jx)},"ara-chromium.desktop":x(Px).replace("chromium --no-sandbox %U",q.browserExec),"ara-set-root-wallpaper.py":Wx},start:['ticks() { line=$(cat "/proc/$1/stat" 2>/dev/null) || return 1; rest=${line##*) }; case $rest in Z*|X*) return 1;; esac; printf "%s" "$rest" | cut -d " " -f20; }','alive() { [ -f "$ROOT/$1.pid" ] || return 1; read -r pid start <"$ROOT/$1.pid"; current=$(ticks "$pid") || return 1; [ "$current" = "$start" ] && kill -0 "$pid" 2>/dev/null; }','launch() { name=$1; shift; "$@" 9>&- >"$ROOT/$name.log" 2>&1 & pid=$!; start=$(ticks "$pid"); printf "%s %s\\n" "$pid" "$start" >"$ROOT/$name.pid"; }',Nx,'[ ! -f "$ROOT/ara-wallpaper.jpg" ] || set_wallpaper "$ROOT/ara-wallpaper.jpg" "$ROOT/ara-set-root-wallpaper.py" || true','if ! alive tint2 && command -v tint2 >/dev/null 2>&1; then launch tint2 tint2 -c "$ROOT/tint2/tint2rc"; fi','if ! alive picom && command -v picom >/dev/null 2>&1; then launch picom picom --config "$ROOT/picom/picom.conf"; fi']}}import{createHash as lq}from"crypto";import{once as Gx}from"events";import{createWriteStream as Ax,existsSync as Sx,mkdirSync as Vx,mkdtempSync as k9,readFileSync as C8,readdirSync as I9,renameSync as Fx,realpathSync as Kx,rmSync as zx,statSync as r8,writeFileSync as Mx}from"fs";import{delimiter as v9,dirname as m8,join as Z}from"path";import{finished as Yx}from"stream/promises";var g8="omljlfpmafedpplnpkkahegadhkimdje",D9="https://chromewebstore.google.com/detail/reason/omljlfpmafedpplnpkkahegadhkimdje";function y9(q){if(!q||typeof q!=="object"||Array.isArray(q)||!("version"in q)||q.version!==1||!("status"in q))return null;if(q.status==="unavailable")return Object.keys(q).length===2?{version:1,status:"unavailable"}:null;if(q.status!=="connected"||Object.keys(q).length!==5||!("deviceId"in q)||typeof q.deviceId!=="string"||!/^[A-Za-z0-9._:-]{1,160}$/.test(q.deviceId)||!("apiOrigin"in q)||typeof q.apiOrigin!=="string"||q.apiOrigin.length>2048||!("managedRootIds"in q)||!Array.isArray(q.managedRootIds)||q.managedRootIds.length>32)return null;let x=[];for(let Q of q.managedRootIds){if(typeof Q!=="string"||!/^[A-Za-z0-9._:-]{1,160}$/.test(Q))return null;x.push(Q)}try{let Q=new URL(q.apiOrigin);if(Q.origin!==q.apiOrigin||Q.username||Q.password||!(Q.protocol==="https:"||Q.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(Q.hostname)))return null}catch{return null}return{version:1,status:"connected",deviceId:q.deviceId,apiOrigin:q.apiOrigin,managedRootIds:x}}var h={ocu:{repository:"https://github.com/iFurySt/open-codex-computer-use.git",revision:"386a260d1ab8b690adbbb27f7471595cf0c2b752",version:"0.3.5"},obu:{repository:"https://github.com/iFurySt/open-browser-use.git",revision:"ac015846df75928fbcf0f3a0f3ba3a210ce1a507",version:"0.1.42"}},v={version:"155.0.8059.84",macArm64Sha256:"13b9e98ce56f5ce18e100a009f455c9285f399e7c9dc8a76fdf2f3a9755bb5f2",linux64Sha256:"cf0f049892dea22e6a6db26d47ed0d7776b7158edcbec4634086633df8bafcbc",win64Sha256:"507f2a031441d10c62b5e3d4e863f09ac1198a571c1419976cbd8387f639afde"};var X8={ocu:{url:`https://registry.npmjs.org/open-computer-use/-/open-computer-use-${h.ocu.version}.tgz`,sha256:"7c16a87c8cd357787b02c0ebd040dd5f93880c1fb51c1901caa2e0c05d063130",size_bytes:5844280},obu:{url:`https://registry.npmjs.org/open-browser-use/-/open-browser-use-${h.obu.version}.tgz`,sha256:"9386d8ce0a147b3f55e1807b68edf736836378807541c457c9b5f6ca2cabaa4e",size_bytes:21372018},extension:{url:`https://github.com/iFurySt/open-browser-use/releases/download/v${h.obu.version}/open-browser-use-chrome-extension-${h.obu.version}.zip`,sha256:"c9c07bec1175e12ea6985b0e7784a5ef01fd03f014b958224a1e17dcd838a241",size_bytes:31070}},d="pnbmoicbkopffjjgfgfglopechaiemkp";import{spawn as k8}from"child_process";import{createRequire as Ux}from"module";import{join as Lx}from"path";var jx=30000,Bx=1048576;function I8(){return process.env.SystemRoot??"C:\\Windows"}function Cx(){return Lx(I8(),"System32","WindowsPowerShell","v1.0","powershell.exe")}var Rx=String.raw`
|
|
124
|
+
$ErrorActionPreference = "Stop"
|
|
125
|
+
Add-Type -TypeDefinition @"
|
|
126
|
+
using System;
|
|
127
|
+
using System.Runtime.InteropServices;
|
|
128
|
+
public static class ReasonInput {
|
|
129
|
+
[StructLayout(LayoutKind.Sequential)] public struct MOUSEINPUT { public int dx; public int dy; public int mouseData; public uint dwFlags; public uint time; public IntPtr dwExtraInfo; }
|
|
130
|
+
[StructLayout(LayoutKind.Sequential)] public struct KEYBDINPUT { public ushort wVk; public ushort wScan; public uint dwFlags; public uint time; public IntPtr dwExtraInfo; }
|
|
131
|
+
[StructLayout(LayoutKind.Explicit)] public struct UNION { [FieldOffset(0)] public MOUSEINPUT mi; [FieldOffset(0)] public KEYBDINPUT ki; }
|
|
132
|
+
[StructLayout(LayoutKind.Sequential)] public struct INPUT { public uint type; public UNION u; }
|
|
133
|
+
[DllImport("user32.dll")] static extern uint SendInput(uint count, INPUT[] inputs, int size);
|
|
134
|
+
[DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
|
|
135
|
+
[DllImport("user32.dll")] public static extern int GetSystemMetrics(int index);
|
|
136
|
+
[DllImport("user32.dll")] static extern uint MapVirtualKey(uint code, uint type);
|
|
137
|
+
[DllImport("user32.dll")] public static extern uint GetClipboardSequenceNumber();
|
|
138
|
+
static void Send(INPUT input) { SendInput(1, new INPUT[] { input }, Marshal.SizeOf(typeof(INPUT))); }
|
|
139
|
+
public static void Mouse(uint flags, int x, int y, int data) {
|
|
140
|
+
INPUT input = new INPUT(); input.type = 0;
|
|
141
|
+
input.u.mi.dx = x; input.u.mi.dy = y; input.u.mi.mouseData = data; input.u.mi.dwFlags = flags; Send(input);
|
|
142
|
+
}
|
|
143
|
+
public static void Key(ushort vk, ushort unit, uint flags) {
|
|
144
|
+
INPUT input = new INPUT(); input.type = 1;
|
|
145
|
+
input.u.ki.wVk = vk; input.u.ki.wScan = vk != 0 ? (ushort)MapVirtualKey(vk, 0) : unit; input.u.ki.dwFlags = flags; Send(input);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
"@
|
|
149
|
+
[void][ReasonInput]::SetProcessDPIAware()
|
|
150
|
+
$width = [ReasonInput]::GetSystemMetrics(0)
|
|
151
|
+
$height = [ReasonInput]::GetSystemMetrics(1)
|
|
152
|
+
$session = [Diagnostics.Process]::GetCurrentProcess().SessionId
|
|
153
|
+
[Console]::Out.WriteLine('{"session":' + $session + ',"width":' + $width + ',"height":' + $height + '}')
|
|
154
|
+
[Console]::Out.Flush()
|
|
155
|
+
$mode = "__MODE__"
|
|
156
|
+
if ($mode -eq "probe") { exit 0 }
|
|
157
|
+
if ($mode -eq "clipboard") {
|
|
158
|
+
# Only changes made during this pairing: never export the initial clipboard.
|
|
159
|
+
$parent = Get-Process -Id __PARENT__
|
|
160
|
+
$last = [ReasonInput]::GetClipboardSequenceNumber()
|
|
161
|
+
while (-not $parent.HasExited) {
|
|
162
|
+
Start-Sleep -Milliseconds 100
|
|
163
|
+
$count = [ReasonInput]::GetClipboardSequenceNumber()
|
|
164
|
+
if ($count -eq $last) { continue }
|
|
165
|
+
$last = $count
|
|
166
|
+
try { $text = Get-Clipboard -Raw } catch { continue }
|
|
167
|
+
if (-not $text) { continue }
|
|
168
|
+
$bytes = [Text.Encoding]::UTF8.GetBytes($text)
|
|
169
|
+
if ($bytes.Length -gt __MAX_TEXT_BYTES__) { continue }
|
|
170
|
+
[Console]::Out.WriteLine("c " + [Convert]::ToBase64String($bytes))
|
|
171
|
+
[Console]::Out.Flush()
|
|
172
|
+
}
|
|
173
|
+
exit 0
|
|
174
|
+
}
|
|
175
|
+
$scaleX = 65535.0 / [Math]::Max(1, $width - 1)
|
|
176
|
+
$scaleY = 65535.0 / [Math]::Max(1, $height - 1)
|
|
177
|
+
while ($null -ne ($line = [Console]::In.ReadLine())) {
|
|
178
|
+
$n = $line.Split(" ")
|
|
179
|
+
try {
|
|
180
|
+
switch ($n[0]) {
|
|
181
|
+
"p" { [ReasonInput]::Mouse(0x8001, [int]([int]$n[1] * $scaleX), [int]([int]$n[2] * $scaleY), 0) }
|
|
182
|
+
"b" { [ReasonInput]::Mouse([uint32]$n[1], 0, 0, [int]$n[2]) }
|
|
183
|
+
"k" { [ReasonInput]::Key([uint16]$n[1], [uint16]$n[2], [uint32]$n[3]) }
|
|
184
|
+
"c" { Set-Clipboard -Value ([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($n[1]))) }
|
|
185
|
+
}
|
|
186
|
+
} catch { [Console]::Error.WriteLine("input: $_") }
|
|
187
|
+
}
|
|
188
|
+
`;function p8(q){let x=Rx.replace("__MODE__",q).replace("__PARENT__",String(process.pid)).replace("__MAX_TEXT_BYTES__",String(_));return[Cx(),["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",Buffer.from(x,"utf16le").toString("base64")]]}var Dx=["USERPROFILE","LOCALAPPDATA","APPDATA","TEMP","TMP","PSModuleAnalysisCachePath"];function v8(){let q=Dx.flatMap((x)=>process.env[x]?[[x,process.env[x]]]:[]);return{...Object.fromEntries(q),SystemRoot:I8(),windir:I8()}}function Hq(q){let x;try{x=JSON.parse(q)}catch{return null}if(!x||typeof x!=="object")return null;let Q=x,P=(X,b)=>typeof X==="number"&&Number.isSafeInteger(X)&&X>=b;return P(Q.session,0)&&P(Q.width,1)&&P(Q.height,1)?{session:Q.session,width:Q.width,height:Q.height}:null}function fq(){return new Promise((q)=>{let x=k8(...p8("probe"),{env:v8(),stdio:["ignore","pipe","ignore"],windowsHide:!0}),Q="",P=setTimeout(()=>{x.kill("SIGKILL"),q(null)},jx);x.stdout.setEncoding("utf8").on("data",(X)=>{Q+=X}),x.once("error",()=>{clearTimeout(P),q(null)}),x.once("close",()=>{clearTimeout(P),q(Hq(Q.split(/\r?\n/)[0]??""))})})}var P8;function gq(){if(P8!==void 0)return P8;if(process.platform!=="win32")return P8=!1;try{let q=Ux(import.meta.url)("bun:ffi"),{symbols:x}=q.dlopen("kernel32.dll",{GetCurrentProcessId:{args:[],returns:q.FFIType.u32},ProcessIdToSessionId:{args:[q.FFIType.u32,q.FFIType.ptr],returns:q.FFIType.i32}}),Q=new Uint32Array(1);return P8=x.ProcessIdToSessionId(x.GetCurrentProcessId(),Q)!==0&&Q[0]>0}catch{return P8=!1}}var Yq=[{bit:1,down:2,up:4},{bit:2,down:32,up:64},{bit:4,down:8,up:16}],wq=2048,_q=4096,Tx=[[8,wq,120],[16,wq,-120],[32,_q,-120],[64,_q,120]],$q=1,h8=2,Zx=4,yx=new Set([65505,65506]),Oq=new Set([65507,65508,65511,65512,65513,65514,65027,65515,65516]),Eq=new Map([[65505,[160,!1]],[65506,[161,!1]],[65507,[162,!1]],[65508,[163,!0]],[65511,[164,!1]],[65512,[165,!0]],[65513,[164,!1]],[65514,[165,!0]],[65027,[165,!0]],[65515,[91,!0]],[65516,[92,!0]],[65288,[8,!1]],[65289,[9,!1]],[65056,[9,!1]],[65293,[13,!1]],[65307,[27,!1]],[65535,[46,!0]],[65379,[45,!0]],[65360,[36,!0]],[65367,[35,!0]],[65365,[33,!0]],[65366,[34,!0]],[65361,[37,!0]],[65362,[38,!0]],[65363,[39,!0]],[65364,[40,!0]],[65383,[93,!0]],[65509,[20,!1]],[65299,[19,!1]],[65300,[145,!1]],[65377,[44,!0]],[65407,[144,!0]],[32,[32,!1]],[65421,[13,!0]],[65408,[32,!1]],[65450,[106,!1]],[65451,[107,!1]],[65452,[108,!1]],[65453,[109,!1]],[65454,[110,!1]],[65455,[111,!0]],[65429,[36,!1]],[65430,[37,!1]],[65431,[38,!1]],[65432,[39,!1]],[65433,[40,!1]],[65434,[33,!1]],[65435,[34,!1]],[65436,[35,!1]],[65438,[45,!1]],[65439,[46,!1]],...Array.from({length:10},(q,x)=>[65456+x,[96+x,!1]]),...Array.from({length:24},(q,x)=>[65470+x,[112+x,!1]])]);class hq{x=-1;y=-1;mask=0;held=new Set;pressed=new Set;pointer(q,x,Q){let P=[];if(q!==this.x||x!==this.y)this.x=q,this.y=x,P.push(`p ${q} ${x}`);for(let X of Yq){let b=(this.mask&X.bit)!==0,J=(Q&X.bit)!==0;if(b!==J)P.push(`b ${J?X.down:X.up} 0`)}for(let[X,b,J]of Tx)if(!(this.mask&X)&&Q&X)P.push(`b ${b} ${J}`);return this.mask=Q,P}key(q,x){let Q=q?0:h8;if(yx.has(x)||Oq.has(x))if(q)this.held.add(x);else this.held.delete(x);let P=Eq.get(x);if(P)return[`k ${P[0]} 0 ${Q|(P[1]?$q:0)}`];let X=x<256?x:(x&4278190080)===16777216?x&16777215:0,b=String.fromCharCode(X),J=[...this.held].some((T)=>Oq.has(T)),N=/^[A-Za-z0-9]$/.test(b)?b.toUpperCase().charCodeAt(0):0;if(N&&(q?J:this.pressed.has(N))){if(q)this.pressed.add(N);else this.pressed.delete(N);return[`k ${N} 0 ${Q}`]}if(X<33||X>=127&&X<160||X>65535||X>=55296&&X<57344)return[];return[`k 0 ${X} ${Q|Zx}`]}release(){let q=Yq.filter((x)=>this.mask&x.bit).map((x)=>`b ${x.up} 0`);for(let x of this.pressed)q.push(`k ${x} 0 ${h8}`);for(let x of this.held){let[Q,P]=Eq.get(x);q.push(`k ${Q} 0 ${h8|(P?$q:0)}`)}return this.mask=0,this.pressed.clear(),this.held.clear(),q}}function kq(q){let x=k8(...p8("input"),{env:v8(),stdio:["pipe","pipe","ignore"],windowsHide:!0}),Q=new hq,P="",X=!1,b=null,J=()=>{if(b?.kill("SIGKILL"),x.exitCode!==null||x.signalCode!==null)return;x.stdin.end(Q.release().map((U)=>`${U}
|
|
189
|
+
`).join("")),setTimeout(()=>x.kill("SIGKILL"),2000).unref()},N=(U)=>{if(X)return;X=!0,J(),q.end(U)},T=(U)=>N({error:new K("display_unavailable",U)}),L=(U)=>{if(X||U.length===0)return;if(x.stdin.write(U.map((y)=>`${y}
|
|
190
|
+
`).join("")),x.stdin.writableLength>Bx)N({reason:"input_backpressure"})},C=()=>{b=k8(...p8("clipboard"),{env:v8(),stdio:["ignore","pipe","ignore"],windowsHide:!0});let U="";b.stdout?.on("data",(y)=>{if(X)return;U+=y.toString("ascii");for(let R=U.indexOf(`
|
|
191
|
+
`);R>=0;R=U.indexOf(`
|
|
192
|
+
`)){let Y=U.slice(0,R).replace(/\r$/,"");if(U=U.slice(R+1),!Y.startsWith("c "))continue;let S=Y.slice(2);if(S.length>Math.ceil(_/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(S)){N({reason:"display_protocol"});return}let W=Buffer.from(S,"base64");if(W.byteLength<=_)q.clipboard(W.toString("utf8"));if(X)return}if(U.length>Math.ceil(_/3)*4+4)N({reason:"display_protocol"})}),b.once("error",()=>T("Reason could not watch this computer's desktop clipboard.")),b.once("exit",()=>{if(!X)T("Reason could not watch this computer's desktop clipboard.")})};return x.stdout.on("data",(U)=>{if(X||P===null)return;P+=U.toString("utf8");let y=P.indexOf(`
|
|
193
|
+
`);if(y<0){if(P.length>4096)N({reason:"display_protocol"});return}let R=Hq(P.slice(0,y).trim());if(P=null,!R)N({reason:"display_protocol"});else if(R.session===0)T("This Windows worker runs as a service, which has no desktop: run it in the signed-in desktop session.");else C(),q.ready({width:R.width,height:R.height})}),x.stdin.on("error",()=>{return}),x.once("error",()=>T("Reason could not start this computer's desktop input.")),x.once("exit",()=>{if(P!==null)T("Reason could not start this computer's desktop input.");else N({reason:"display_closed"})}),{pointer:(U,y,R)=>L(Q.pointer(U,y,R)),key:(U,y)=>L(Q.key(U,y)),clipboard:(U)=>L([`c ${Buffer.from(U,"utf8").toString("base64")}`]),close(){X=!0,J()}}}var wx=["none","standard","all"],B8="22.23.3",_x={"linux-x64":"1084aa36196bba4c3a5e69a1ee388a6e4ff729dad09445fbcd434b28fe3c24af","linux-arm64":"5ced2d48d1d7198739b7f86804de0171aefb6823b684b12341d3321afc3cb0b2","darwin-arm64":"23b25245dcfb9af7262f8ff142e9e2e0af025368117329e7a7458a51e5922f53","win32-x64":"2b0ff57b049cda1bbcea2240eec20467018713c1efe1f7360c2681859b90ed71","win32-arm64":"33dad22e4cef5ee8f9fbb1b0d037fdacd0e56d12a4580f0d63f68b894deab535"},u8={"linux-x64":{ocu:"dist/linux/amd64/open-computer-use",obu:"native/linux-amd64/open-browser-use"},"linux-arm64":{ocu:"dist/linux/arm64/open-computer-use",obu:"native/linux-arm64/open-browser-use"},"darwin-arm64":{ocu:"dist/Open Computer Use.app/Contents/MacOS/OpenComputerUse",obu:"native/darwin-arm64/open-browser-use"},"win32-x64":{ocu:"dist/windows/amd64/open-computer-use.exe",obu:"native/windows-amd64/open-browser-use.exe"},"win32-arm64":{ocu:"dist/windows/arm64/open-computer-use.exe",obu:"native/windows-arm64/open-browser-use.exe"}},rq="chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",mq="chrome-win64/chrome.exe",a={version:"9.0.2",url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffmpeg.zip",sha256:"c8ed4c4e6978a03c485edbfe4e0a5dc2380f8a30bba5150531b31b094492d924"},$x={version:a.version,url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffprobe.zip",sha256:"fcbe839537485eaee7a7a8bc5cbc0f90d53617e80943e8a5b2e31cb851197ea6"},c8={version:a.version,url:`https://github.com/GyanD/codexffmpeg/releases/download/${a.version}/ffmpeg-${a.version}-essentials_build.zip`,sha256:"60f467265b1e312373dbcd92200c2618a74850f98d3d078e94296bb3fa2047ba"},Iq=`ffmpeg-${c8.version}-essentials_build/bin`,c="com.ifuryst.open_browser_use.extension",dq="com.reasonmachines.browser_use.extension",pq="/tmp/reason-browser-use",d8=["tint2","picom","xterm","pcmanfm"],aq=["fonts-droid-fallback"],sq=["pulseaudio"],Ox=["xvfb","openbox","x11vnc","x11-utils","x11-xserver-utils","xdotool","dbus-x11","at-spi2-core","python3","python3-gi","gir1.2-atspi-2.0","gir1.2-gtk-3.0","fonts-dejavu-core",...aq,"galculator","chromium","ffmpeg","tmux",...sq,...d8],Ex=new Set([...d8,...aq,...sq]),vq=Ox.filter((q)=>q!=="chromium"&&!Ex.has(q)),Hx=["Xvfb","openbox","x11vnc","xdotool","dbus-launch","python3","ffmpeg","tmux"],j8="/usr/bin/chromium",fx=["/usr/local/bin","/usr/bin","/bin","/opt/homebrew/bin"];function iq(q=process.platform,x=process.arch){let Q=`${q}-${x}`;return Q==="linux-x64"||Q==="linux-arm64"||Q==="darwin-arm64"||Q==="win32-x64"||Q==="win32-arm64"?Q:null}function s(q){return q==="win32-x64"||q==="win32-arm64"}function a8(q){return s(q)?`node-v${B8}-${q.replace("win32","win")}`:`node-v${B8}-${q}`}function R8(q){return{node:{version:B8,url:`https://nodejs.org/dist/v${B8}/${a8(q)}${s(q)?".zip":".tar.gz"}`,sha256:_x[q]},open_computer_use:{version:h.ocu.version,url:X8.ocu.url,sha256:X8.ocu.sha256},open_browser_use:{version:h.obu.version,url:X8.obu.url,sha256:X8.obu.sha256},...q==="darwin-arm64"?{chrome_for_testing:{version:v.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${v.version}/mac-arm64/chrome-mac-arm64.zip`,sha256:v.macArm64Sha256}}:s(q)?{chrome_for_testing:{version:v.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${v.version}/win64/chrome-win64.zip`,sha256:v.win64Sha256}}:{}}}function gx(q){let x={extension:d};for(let[Q,P]of Object.entries(R8(q)))x[Q]=`${P.version}@${P.sha256}`;return x}function nq(q){return Z(q,".local","share","reason","desktop")}function oq(q,x=uq()){let Q=nq(x),P=(U)=>Z(Q,U,R8(q)[U]?.version??""),X=P("open_computer_use"),b=P("open_browser_use"),J=q==="darwin-arm64",N=s(q),T=Z(x,"Library","Application Support"),L=Z(process.platform==="win32"&&process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:Z(x,"AppData","Local"),"OpenBrowserUse"),C=J?Z(T,"Google","Chrome","NativeMessagingHosts",`${c}.json`):N?Z(L,"NativeMessagingHosts",`${c}.json`):Z(x,".config","google-chrome","NativeMessagingHosts",`${c}.json`);return{root:Q,automation:Z(m8(Q),"automation"),receipt:Z(Q,"receipt.json"),minimal:i8(x),node:N?Z(P("node"),a8(q),"node.exe"):Z(P("node"),"bin","node"),ocuDir:X,ocu:Z(X,u8[q].ocu),ocuApp:J?Z(X,"dist","Open Computer Use.app"):null,obuDir:b,obu:Z(b,"cli","open-browser-use.js"),nativeHost:Z(b,u8[q].obu),extensionDir:J?Z(T,"OpenBrowserUse","chrome-extension","release"):N?Z(L,"chrome-extension","release"):Z(x,".local","share","open-browser-use","chrome-extension","release"),setupNativeHostManifest:C,nativeHostManifests:J?[C,Z(T,"Google","ChromeForTesting","NativeMessagingHosts",`${c}.json`)]:N?[C]:[Z(x,".config","chromium","NativeMessagingHosts",`${c}.json`),Z(x,".config","google-chrome-for-testing","NativeMessagingHosts",`${c}.json`)],browser:J?Z(P("chrome_for_testing"),rq):N?Z(P("chrome_for_testing"),mq):j8,userChromeHost:J?Z(Q,"user-chrome","reason-browser-use"):null,userChromeRegistration:J?Z(T,"Google","Chrome","NativeMessagingHosts",`${dq}.json`):null,ffmpegDir:Z(Q,"ffmpeg"),ffmpeg:J?Z(Q,"ffmpeg",a.version,"ffmpeg"):N?Z(Q,"ffmpeg",c8.version,Iq,"ffmpeg.exe"):null,ffprobe:J?Z(Q,"ffprobe",$x.version,"ffprobe"):N?Z(Q,"ffmpeg",c8.version,Iq,"ffprobe.exe"):null}}function tq(q){try{let x=JSON.parse(C8(q,"utf8"));if(typeof x!=="object"||x===null)return null;let Q=x,P=Q.pins;if(Q.schema_version!==1||typeof Q.platform!=="string"||typeof P!=="object"||P===null||!Object.values(P).every((X)=>typeof X==="string")||!wx.includes(Q.permissions)||!Array.isArray(Q.missing_system_packages)||!Q.missing_system_packages.every((X)=>typeof X==="string")||typeof Q.updated_at!=="string")return null;return{schema_version:1,platform:Q.platform,pins:P,permissions:Q.permissions,missing_system_packages:Q.missing_system_packages,updated_at:Q.updated_at}}catch{return null}}function hx(q,x,Q=384){Vx(m8(q),{recursive:!0,mode:448});let P=`${q}.pending.${process.pid}`;Mx(P,x,{mode:Q}),Fx(P,q)}function k(q){try{return r8(q).isFile()}catch{return!1}}function eq(q){try{let x=r8(q);return x.isFile()&&(x.mode&73)!==0}catch{return!1}}function kx(q){try{return C8(q,"utf8")}catch{return null}}function u(q){for(let x of fx){let Q=Z(x,q);try{let P=r8(Q);if(P.isFile()&&(P.mode&73)!==0)return Q}catch{}}return null}function Ix(q){try{let x=JSON.parse(C8(Z(q,"package.json"),"utf8"));return typeof x==="object"&&x!==null&&typeof x.version==="string"?x.version:null}catch{return null}}function px(q,x,Q){let P=R8(Q)[q];if(!P)return!1;let X=s(Q);if(q==="node")return k(X?Z(x,a8(Q),"node.exe"):Z(x,"bin","node"));if(q==="chrome_for_testing")return k(Z(x,X?mq:rq));let b=u8[Q][q==="open_computer_use"?"ocu":"obu"];return Ix(x)===P.version&&k(Z(x,b))&&(q==="open_computer_use"||k(Z(x,"cli","open-browser-use.js")))}function vx(q){return lq("sha256").update(Buffer.from(q,"base64")).digest("hex").slice(0,32).replace(/./g,(x)=>String.fromCharCode(97+Number.parseInt(x,16)))}function s8(q){try{let x=JSON.parse(C8(q,"utf8"));return typeof x==="object"&&x!==null&&!Array.isArray(x)?x:null}catch{return null}}function ux(q){let x=s8(Z(q.extensionDir,"manifest.json"));return x!==null&&x.version===h.obu.version&&typeof x.key==="string"&&vx(x.key)===d}function cx(q,x){let Q=q?.allowed_origins;return q!==null&&q.name===c&&Array.isArray(Q)&&Q.length===1&&Q[0]===`chrome-extension://${d}/`&&(x===void 0||q.path===x)}function lx(q){return ux(q)&&k(q.nativeHost)&&q.nativeHostManifests.every((x)=>cx(s8(x),q.nativeHost))}function rx(q){return`#!/bin/sh
|
|
194
|
+
# Reason's Chrome extension host (reason desktop install): Open Browser Use on Reason's socket directory.
|
|
195
|
+
obu=${`'${q.replaceAll("'","'\\''")}'`}
|
|
196
|
+
case "$1" in
|
|
197
|
+
chrome-extension://*) exec "$obu" host --socket-dir ${pq} ;;
|
|
198
|
+
mcp) shift; exec "$obu" mcp --socket-dir ${pq} "$@" ;;
|
|
199
|
+
esac
|
|
200
|
+
exec "$obu" "$@"
|
|
201
|
+
`}function mx(q){let x=s8(q),Q=x?.allowed_origins;return x!==null&&x.name===dq&&x.type==="stdio"&&Array.isArray(Q)&&Q.includes(`chrome-extension://${g8}/`)&&typeof x.path==="string"&&eq(x.path)}function dx(q,x){if(!q.userChromeHost||!q.userChromeRegistration)return null;if(!x||kx(q.userChromeHost)!==rx(q.nativeHost)||!eq(q.userChromeHost))return{code:"user_chrome_browser_use_missing"};return mx(q.userChromeRegistration)?{host:q.userChromeHost}:{code:"user_chrome_native_host_unregistered"}}var ax={display:["display","desktop_session","desktop_video"],computer:["display","desktop_session","system_packages","node","open_computer_use"],browser:["display","desktop_session","system_packages","node","open_computer_use","open_browser_use","browser_extension","browser","chrome_for_testing"]};function I(q={}){let x=q.platform===void 0?iq():q.platform;if(!x)return null;let Q=oq(x,q.home),P=tq(Q.receipt),X=gx(x),b=P!==null&&P.platform===x&&JSON.stringify(Object.entries(P.pins).sort())===JSON.stringify(Object.entries(X).sort()),J=[],N=R8(x);for(let W of["node","open_computer_use","open_browser_use","chrome_for_testing"]){let G=N[W];if(!G)continue;let V=px(W,Z(Q.root,W,G.version),x),F=P?.pins[W],E=V&&F===X[W]?"ready":F!==void 0&&F!==X[W]?"outdated":"missing";J.push({name:W,state:E,detail:G.version})}let T=P?.pins.extension===d&&lx(Q);J.push({name:"browser_extension",state:T?"ready":"missing",detail:d});let L=u("Xvfb"),C=u("x11vnc"),U=u("openbox");if(s(x))J.push(gq()?{name:"desktop_session",state:"ready",detail:"signed-in desktop session"}:{name:"desktop_session",state:"missing",detail:"run the worker in the signed-in desktop session, not as a service"}),J.push(Q.ffmpeg&&k(Q.ffmpeg)?{name:"desktop_video",state:"ready",detail:Q.ffmpeg}:{name:"desktop_video",state:"missing",detail:"run `reason desktop install` for desktop video"});else if(x!=="darwin-arm64"){J.push(k(j8)?{name:"browser",state:"ready",detail:j8}:{name:"browser",state:"missing",detail:`non-snap Chromium at ${j8}`});let W=L!==null&&C!==null&&U!==null;J.push({name:"display",state:W?"ready":"missing",detail:"Xvfb + openbox + x11vnc"});let G=Hx.filter((w)=>u(w)===null),V=(P?.missing_system_packages??vq).filter((w)=>vq.includes(w)),F=G.length===0&&V.length===0;J.push(F?{name:"system_packages",state:"ready"}:{name:"system_packages",state:"missing",detail:[...new Set([...V,...G])].join(" ")});let E=d8.filter((w)=>u(w)===null);J.push(E.length===0?{name:"desktop_look",state:"ready"}:{name:"desktop_look",state:"missing",detail:E.join(" ")})}let y=Q.ffmpeg&&k(Q.ffmpeg)?Q.ffmpeg:u("ffmpeg"),R=!y?null:y===Q.ffmpeg?Q.ffprobe:Z(m8(Kx(y)),"ffprobe"),Y=b&&J.every((W)=>W.state==="ready"),S=(W)=>b&&J.every((G)=>!ax[W].includes(G.name)||G.state==="ready");return{platform:x,root:Q.root,automation:Q.automation,ready:Y,features:{display:S("display"),computer:S("computer"),browser:S("browser")},node:Q.node,ocu:Q.ocu,obu:Q.obu,nativeHost:Q.nativeHost,extensionDir:Q.extensionDir,browser:Q.browser,ffmpeg:y,ffprobe:R&&k(R)?R:null,userChrome:dx(Q,b&&["node","open_browser_use"].every((W)=>J.find((G)=>G.name===W)?.state==="ready")),pulseaudio:u("pulseaudio"),xvfb:L,x11vnc:C,openbox:U,components:J}}function q0(q){return sx(q)?cq():[]}function sx(q){return q?.platform==="darwin-arm64"&&q.ffmpeg===Z(q.root,"ffmpeg",a.version,"ffmpeg")}async function t9(q,x,Q,P=fetch){try{let X=await P(q,{redirect:"follow"});if(!X.ok||!X.body)throw Error(`download failed (HTTP ${X.status}): ${q}`);let b=lq("sha256"),J=Ax(Q,{mode:384});try{let T=X.body.getReader();for(let L=await T.read();!L.done;L=await T.read())if(b.update(L.value),!J.write(L.value))await Gx(J,"drain")}finally{J.end(),await Yx(J)}let N=b.digest("hex");if(N!==x)throw Error(`digest mismatch for ${q}: expected ${x}, got ${N}`)}catch(X){throw zx(Q,{force:!0}),X}}function i8(q){return Z(nq(q),"minimal.json")}function ix(q=i()){return Sx(i8(q))}function e9(q={}){hx(i8(q.home??i()),`${JSON.stringify({version:1,minimal_at:(q.now?.()??new Date).toISOString()})}
|
|
202
|
+
`)}function qQ(q={}){let x=q.platform===void 0?iq():q.platform;if(x===null)return null;let Q=q.home??i();if(tq(oq(x,Q).receipt)!==null)return"refresh";return ix(Q)?null:"install"}import{execFile as N1,spawn as Qq}from"child_process";import{existsSync as U1}from"fs";import{connect as L1}from"net";function nx(){let q=new Set,x=null,Q=(X)=>({holder:x?.viewer??null,you:x===X,same_user:Boolean(x?.viewer&&X.viewer&&x.viewer.user_id===X.viewer.user_id)}),P=()=>{for(let X of q)X.notify(Q(X))};return{join(X){return q.add(X),X.notify(Q(X)),()=>{if(!q.delete(X))return;if(x!==X)return;x=null,P()}},claim(X){if(x===X||!q.has(X))return;x=X,P()}}}var x0=nx();import{spawn as ox}from"child_process";import{existsSync as tx}from"fs";import{connect as ex}from"net";import{join as D8}from"path";var X0="reason_desktop",b8={sampleRate:48000,channels:2,codec:"opus"},q1=5000,x1=107,Q1=262144,t8=(q)=>D8(q,"native"),T8=(q)=>`unix:${q}`;function n8(q,x=1000){if(!tx(q))return Promise.resolve(!1);return new Promise((Q)=>{let P=ex({path:q}),X=(b)=>{P.destroy(),Q(b)};P.setTimeout(x,()=>X(!1)),P.once("error",()=>X(!1)),P.once("close",()=>X(!1)),P.once("connect",()=>X(!0))})}async function P0(q,x){if(!x)return null;let Q=t8(q);if(Buffer.byteLength(Q)>x1||/["'\\\s]/.test(Q))return null;try{if(await n8(Q))return Q;let P=ox(x,["--daemonize=no","--system=no","--use-pid-file=no","--exit-idle-time=-1","--disallow-exit=yes","--realtime=no","--high-priority=no","--disallow-module-loading=yes","--log-level=warning",`--log-target=file:${D8(q,"pulseaudio.log")}`,"-n",`--load=module-native-protocol-unix socket="${Q}" auth-anonymous=1 auth-cookie-enabled=0`,`--load=module-null-sink sink_name=${X0} rate=${b8.sampleRate} channels=${b8.channels} sink_properties=device.description=Reason_desktop`],{detached:!0,stdio:"ignore",env:{HOME:q,PATH:"/usr/bin:/bin",XDG_RUNTIME_DIR:q,PULSE_RUNTIME_PATH:D8(q,"runtime"),PULSE_STATE_PATH:D8(q,"state")}}),X=!1;P.once("error",()=>{X=!0}),P.once("exit",()=>{X=!0}),P.unref();let b=Date.now()+q1;while(Date.now()<b){if(await n8(Q))return Q;if(X)return await n8(Q)?Q:null;await new Promise((J)=>setTimeout(J,50))}if(!X)P.kill("SIGKILL");return null}catch{return null}}function b0(){let{sampleRate:q,channels:x}=b8;return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer","-f","pulse","-sample_rate",String(q),"-channels",String(x),"-fragment_size",String(q*x*2/50),"-i",`${X0}.monitor`,"-vn","-ac",String(x),"-ar",String(q),"-c:a","libopus","-b:a","64k","-application","lowdelay","-frame_duration","20","-flush_packets","1","-page_duration","20000","-f","ogg","pipe:1"]}var X1=[79,103,103,83],P1=Buffer.from("OpusHead"),b1=Buffer.from("OpusTags"),Q0=(q,x)=>q.byteLength>=x.byteLength&&x.every((Q,P)=>q[P]===Q);class o8 extends Error{constructor(q){super(q);this.name="OggProtocolError"}}class e8{buffer=new Uint8Array(0);partial=[];partialBytes=0;push(q){let x=new Uint8Array(this.buffer.byteLength+q.byteLength);x.set(this.buffer),x.set(q,this.buffer.byteLength);let Q=[],P=0;while(x.byteLength-P>=27){if(X1.some((y,R)=>x[P+R]!==y)||x[P+4]!==0)throw new o8("invalid_page");let X=(x[P+5]&1)!==0,b=x[P+26];if(x.byteLength-P<27+b)break;let J=x.subarray(P+27,P+27+b),N=J.reduce((y,R)=>y+R,0),T=27+b+N;if(x.byteLength-P<T)break;if(!X&&this.partialBytes>0)this.resetPartial();let L=X&&this.partialBytes===0,C=P+27+b,U=C;for(let y of J){if(C+=y,y===255)continue;if(this.appendPartial(x.subarray(U,C),L),U=C,!L){let R=this.takePartial();if(R.byteLength>0&&!Q0(R,P1)&&!Q0(R,b1))Q.push(R)}L=!1,this.resetPartial()}if(U<C)this.appendPartial(x.subarray(U,C),L);P+=T}return this.buffer=x.slice(P),Q}appendPartial(q,x){if(x||q.byteLength===0)return;if(this.partialBytes+=q.byteLength,this.partialBytes>Q1)throw new o8("packet_too_large");this.partial.push(q.slice())}takePartial(){if(this.partial.length===1)return this.partial[0];let q=new Uint8Array(this.partialBytes),x=0;for(let Q of this.partial)q.set(Q,x),x+=Q.byteLength;return q}resetPartial(){this.partial=[],this.partialBytes=0}}import{spawn as J1}from"child_process";var J0=1048576,W1=String.raw`
|
|
203
|
+
import gi, json, os, sys
|
|
204
|
+
gi.require_version("Gtk", "3.0")
|
|
205
|
+
from gi.repository import Gtk, Gdk, GLib
|
|
206
|
+
if not Gtk.init_check()[0]:
|
|
207
|
+
sys.exit(1)
|
|
208
|
+
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
|
209
|
+
pending = b""
|
|
210
|
+
generation = 0
|
|
211
|
+
def send(value):
|
|
212
|
+
print(json.dumps(value, ensure_ascii=True), flush=True)
|
|
213
|
+
def changed(clipboard, event):
|
|
214
|
+
global generation
|
|
215
|
+
generation += 1
|
|
216
|
+
current = generation
|
|
217
|
+
def received(clipboard, text, unused):
|
|
218
|
+
if current == generation and text is not None and len(text.encode("utf-8")) <= ${_}:
|
|
219
|
+
send({"text": text})
|
|
220
|
+
clipboard.request_text(received, None)
|
|
221
|
+
# No request_text on startup: never share the pre-existing clipboard.
|
|
222
|
+
clipboard.connect("owner-change", changed)
|
|
223
|
+
def input_ready(fd, condition):
|
|
224
|
+
global pending
|
|
225
|
+
chunk = os.read(fd, 65536)
|
|
226
|
+
if not chunk:
|
|
227
|
+
Gtk.main_quit()
|
|
228
|
+
return False
|
|
229
|
+
pending += chunk
|
|
230
|
+
while b"\n" in pending:
|
|
231
|
+
line, pending = pending.split(b"\n", 1)
|
|
232
|
+
text = json.loads(line)
|
|
233
|
+
if not isinstance(text, str) or len(text.encode("utf-8")) > ${_} or "\x00" in text:
|
|
234
|
+
sys.exit(1)
|
|
235
|
+
clipboard.set_text(text, -1)
|
|
236
|
+
send("ack")
|
|
237
|
+
if len(pending) > ${_*6+2}:
|
|
238
|
+
sys.exit(1)
|
|
239
|
+
return True
|
|
240
|
+
GLib.io_add_watch(0, GLib.IO_IN | GLib.IO_HUP, input_ready)
|
|
241
|
+
send("ready")
|
|
242
|
+
Gtk.main()
|
|
243
|
+
`;function W0(q,x){let Q=J1("/usr/bin/python3",["-I","-u","-c",W1],{env:{DISPLAY:q.display,XAUTHORITY:q.xauthority},stdio:["pipe","pipe","ignore"]}),P=!1,X=!0,b="",J=0,N=[],T=setTimeout(()=>C(),5000),L=()=>{P=!0,clearTimeout(T),N.length=0,Q.kill("SIGKILL")},C=()=>{if(P)return;L(),x.end({error:new K("display_unavailable","Reason could not start this Linux desktop's UTF-8 clipboard.")})},U=(y,R=32)=>{if(P)return;if(!X){y();return}if(J+=R,J>J0)L(),x.end({reason:"input_backpressure"});else N.push({apply:y,bytes:R})};return Q.stdout.on("data",(y)=>{if(P)return;b+=y.toString("ascii");for(let R=b.indexOf(`
|
|
244
|
+
`);R>=0;R=b.indexOf(`
|
|
245
|
+
`)){let Y=b.slice(0,R);b=b.slice(R+1);let S;try{S=JSON.parse(Y)}catch{C();return}if(S==="ready"||S==="ack"){clearTimeout(T),X=!1;while(!X&&!P&&N.length){let W=N.shift();J-=W.bytes,W.apply()}}else if(S&&typeof S==="object"&&"text"in S&&typeof S.text==="string"&&Buffer.byteLength(S.text)<=_)x.clipboard(S.text);else{C();return}if(P)return}if(b.length>_*6+32)C()}),Q.stdin.on("error",C),Q.once("error",C),Q.once("exit",C),{apply:U,write(y){if(Buffer.byteLength(y)>_||y.includes("\x00")){C();return}let R=`${JSON.stringify(y)}
|
|
246
|
+
`;U(()=>{if(X=!0,T=setTimeout(()=>C(),5000),Q.stdin.write(R),Q.stdin.writableLength>J0)L(),x.end({reason:"input_backpressure"})},Buffer.byteLength(R))},close:L}}var n={smooth:{fps:60,crf:23,kbps:8000,x264Preset:"ultrafast",threads:2,scale:1},sharp:{fps:30,crf:19,kbps:1e4,x264Preset:"superfast",scale:1},data_saver:{fps:20,crf:28,kbps:2000,x264Preset:"ultrafast",scale:0.75},balanced:{fps:30,crf:23,kbps:4000,x264Preset:"ultrafast",threads:2,scale:1}},j1="avc1.4D002A",N0={width:1920,height:1080},B1=262144,C1=0.2,R1=250,D1=1e4,T1=1024,qq=1e4,Z1=500,y1=60,G1=1e4,A1=1000,U0=1048576,S0={kind:"mac_screen",sound:null},V0={kind:"windows_screen",sound:null},S1,L0=()=>S1??=I()?.ffmpeg??null,y8=(q,x,Q)=>Qq(q,x,{env:Q,stdio:["ignore","pipe","ignore"],windowsHide:!0}),V1,Xq=()=>V1??=q0(I()),j0=(q,x,Q)=>{let[P,...X]=[...Xq(),q];return y8(P,[...X,...x],Q)},B0=()=>_0?.videotoolbox?"h264_videotoolbox":"libx264",F1=()=>Math.round(performance.now()*1000),xq=new Set,C0=!1;function F0(q){if(xq.add(q),q.once("exit",()=>xq.delete(q)),C0)return;C0=!0,process.once("exit",()=>{for(let x of xq)try{x.kill("SIGKILL")}catch{}})}function K0(q){try{q.stdout?.destroy()}catch{}if(q.exitCode!==null||q.signalCode!==null)return;try{q.kill("SIGTERM")}catch{return}let x=setTimeout(()=>{if(q.exitCode===null&&q.signalCode===null)try{q.kill("SIGKILL")}catch{}},Z1);q.once("exit",()=>clearTimeout(x))}function K1(q,x,Q){return{args:["-f","x11grab","-draw_mouse","1","-framerate",String(q),"-video_size",`${x.width}x${x.height}`,"-i",Q],size:x}}function z1(q){return{args:["-f","avfoundation","-capture_cursor","1","-pixel_format","nv12","-framerate",String(q),"-i","Capture screen 0:none"],size:null}}function M1(q,x){return{args:["-f","gdigrab","-draw_mouse","1","-framerate",String(q),"-offset_x","0","-offset_y","0","-video_size",`${x.width}x${x.height}`,"-i","desktop"],size:x}}function Y1(q){return{args:["-probesize","32","-analyzeduration","0","-f","image2pipe","-c:v","mjpeg","-framerate",String(q),"-i","pipe:0"],size:null}}var z0=1700000;function M0(q){return Math.min(1,Math.round(Math.sqrt(z0/(q.width*q.height))*100)/100)}function w1(q,x,Q){let P=Qq(Q.axe,["stream-video","--udid",Q.udid,"--format","ffmpeg","--fps","30","--quality","85","--scale",String(Math.min(0.99,M0(Q.size)))],{stdio:["ignore","pipe","ignore"]}),X=Qq(q,x,{env:{},stdio:["pipe","pipe","ignore"]});P.stdout.pipe(X.stdin),X.stdin.on("error",()=>{});let b=()=>{if(P.exitCode===null&&P.signalCode===null)P.kill("SIGTERM")};return X.once("exit",b),X.once("error",b),P.once("exit",()=>{if(X.exitCode===null&&X.signalCode===null)X.kill("SIGTERM")}),P.once("error",()=>{if(X.exitCode===null&&X.signalCode===null)X.kill("SIGTERM")}),X}function R0(q){let x=Math.min(1,N0.width/q.width,N0.height/q.height);return{width:Math.round(q.width*x),height:Math.round(q.height*x)}}function Z8(q,x,Q,P="libx264"){let X=n[q],b=(U)=>Math.max(2,Math.floor(U/2)*2),J={width:b(Q.width*X.scale),height:b(Q.height*X.scale)},N=J.width!==x.size?.width||J.height!==x.size.height,T=Math.max(1,Math.round(X.kbps*2/X.fps)),L=["-g",String(X.fps*y1)],C=P==="h264_videotoolbox"?["-c:v","h264_videotoolbox","-realtime","1","-prio_speed","1","-allow_sw","1","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","nv12",...L,"-b:v",`${X.kbps}k`,"-maxrate",`${X.kbps}k`,"-bufsize",`${T}k`,"-bsf:v","h264_metadata=aud=insert"]:["-c:v","libx264","-preset",X.x264Preset,"-tune","zerolatency","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","yuv420p",...X.threads?["-threads",String(X.threads)]:[],"-x264-params","aud=1:repeat-headers=1",...L,"-crf",String(X.crf),"-maxrate",`${X.kbps}k`,"-bufsize",`${T}k`];return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer",...x.args,"-an",...N?["-vf",`scale=${J.width}:${J.height}:flags=fast_bilinear`]:[],...C,"-flush_packets","1","-f","h264","pipe:1"]}class Y0{buffer=new Uint8Array(0);scanned=0;key=!1;micros=0;push(q,x){if(this.buffer.byteLength===0)this.micros=x;let Q=new Uint8Array(this.buffer.byteLength+q.byteLength);Q.set(this.buffer),Q.set(q,this.buffer.byteLength),this.buffer=Q;let P=[],X=this.scanned;while(X+3<this.buffer.byteLength){if(this.buffer[X]!==0||this.buffer[X+1]!==0||this.buffer[X+2]!==1){X++;continue}let b=this.buffer[X+3]&31,J=X>0&&this.buffer[X-1]===0?X-1:X;if(b===9&&J>0)P.push({data:this.buffer.slice(0,J),key:this.key,micros:this.micros}),this.buffer=this.buffer.subarray(J),this.key=!1,this.micros=x,X-=J;if(b===5)this.key=!0;X+=3}return this.scanned=X,P}}function _1(q,x){let Q=L1({path:q}),P=Buffer.alloc(0),X="version",b=0,J=!1,N=[],T=0,L=!1,C=(W)=>{if(L)return;L=!0,Q.destroy(),x.end(W)},U=()=>C({reason:"display_protocol"}),y=(W)=>{if(L)return;if(!J){if(T+=W.byteLength,T>U0)C({reason:"input_backpressure"});else N.push(W);return}if(Q.write(W),Q.writableLength>U0)C({reason:"input_backpressure"})},R=(W)=>{P=P.subarray(W)},Y=()=>{switch(X){case"version":{if(P.byteLength<12)return!1;let W=/^RFB (\d{3})\.(\d{3})\n$/.exec(P.subarray(0,12).toString("latin1"));if(!W||Number(W[1])*1000+Number(W[2])<3007)return U(),!1;return R(12),Q.write(`RFB 003.007
|
|
247
|
+
`),X="security",!0}case"security":{if(P.byteLength<1)return!1;let W=P[0];if(W===0)return U(),!1;if(P.byteLength<1+W)return!1;if(!P.subarray(1,1+W).includes(1))return U(),!1;return R(1+W),Q.write(Buffer.from([1,1])),X="init",!0}case"init":{if(P.byteLength<24)return!1;let W=P.readUInt32BE(20);if(W>65536)return U(),!1;if(P.byteLength<24+W)return!1;let G={width:P.readUInt16BE(0),height:P.readUInt16BE(2)};if(R(24+W),G.width===0||G.height===0)return U(),!1;X="messages",J=!0;for(let V of N)Q.write(V);return N=[],T=0,x.ready(G),!L}case"skip":{let W=Math.min(b,P.byteLength);if(R(W),b-=W,b>0)return!1;return X="messages",!0}case"messages":{if(P.byteLength<1)return!1;switch(P[0]){case 1:{if(P.byteLength<6)return!1;let W=6+P.readUInt16BE(4)*6;if(P.byteLength<W)return!1;return R(W),!0}case 2:return R(1),!0;case 3:{if(P.byteLength<8)return!1;let W=P.readUInt32BE(4);if(W>_/2)return R(8),X="skip",b=W,!0;if(P.byteLength<8+W)return!1;let G=P.subarray(8,8+W).toString("latin1");return R(8+W),x.clipboard(G),!L}default:return U(),!1}}}},S=!1;return Q.once("connect",()=>{S=!0}),Q.on("data",(W)=>{if(L)return;P=P.byteLength?Buffer.concat([P,W]):W;while(!L&&Y());}),Q.once("error",()=>{if(!S)C({error:new K("display_unavailable","Reason could not reach this machine's desktop server.")})}),Q.once("close",()=>C({reason:"display_closed"})),{pointer(W,G,V){let F=Buffer.alloc(6);F.writeUInt8(5,0),F.writeUInt8(V&255,1),F.writeUInt16BE(W,2),F.writeUInt16BE(G,4),y(F)},key(W,G){let V=Buffer.alloc(8);V.writeUInt8(4,0),V.writeUInt8(W?1:0,1),V.writeUInt32BE(G>>>0,4),y(V)},clipboard(W){if(Array.from(W).some((F)=>F.codePointAt(0)>255)){C({reason:"clipboard_unicode_unsupported"});return}let G=Buffer.from(W,"latin1"),V=Buffer.alloc(8);V.writeUInt8(6,0),V.writeUInt32BE(G.byteLength,4),y(Buffer.concat([V,G]))},close(){L=!0,Q.destroy()}}}class Pq{run=null;viewers=new Set;get running(){return this.run!==null}start(q,x,Q,P){this.viewers.add(q),this.stop();let X;try{X=Q()}catch{this.fail();return}F0(X);let b={child:X,splitter:new Y0};this.run=b;for(let N of[...this.viewers])N.started(x);X.stdout?.on("data",(N)=>{if(this.run!==b)return;for(let T of b.splitter.push(N,P()))for(let L of[...this.viewers])L.unit(T)});let J=()=>{if(this.run!==b)return;this.run=null,this.fail()};X.once("exit",J),X.once("error",J)}leave(q){if(!this.viewers.delete(q))return;if(this.viewers.size===0)this.stop()}stop(){if(!this.run)return;K0(this.run.child),this.run=null}fail(){for(let q of[...this.viewers])q.failed()}}var D0=new WeakMap;function $1(q){let x=D0.get(q);if(!x)D0.set(q,x=new Pq);return x}function w0(q,x,Q={}){let P=Q.micros??F1,X=new y0,b=x.request.preset,J=null,N=null,T=null,L=!1,C=null,U=!1,y=!1,R=null,Y=0,S=0,W=!1,G=null,V=null,F=0,E=null,w=[],t=0,A=[],f=new Uint32Array(qq+1),p=0,F8=null,K8=0,e=0,z8=0,Lq=0,jq=0,J8=null,M8=0,l={frames:0,bytes:0,since:P()},r=[],q8=0,Y8,w8=!1,c0=P(),O={},m=()=>Math.round((P()-c0)/1000),Bq=Q.control??x0,_8=null,$8=null,H=(B)=>{let j=G8(B);return q.send(j),Lq+=j.byteLength,j.byteLength},W8=(B)=>{if(q.done)return;if(q.open)H({type:"error",code:B});q.end({reason:B})},N8=()=>Math.max(B1,n[b].kbps*1000/8*C1),U8=()=>P()/1000,l0=()=>{while(A.length>1&&A[0].atMs<U8()-D1)A.shift();return A[0]?.rttMs??null},Cq=(B)=>{let j=l0();if(j===null||w.length===0)return!1;let D=(j+R1)*B;return U8()-w[0].sentMs>D||t>D/1000*n[b].kbps*1000/8},r0=(B)=>{if(F===0)return;let j=Math.min(B,F-1);if(E!==null&&j<=E)return;E=j;let D=U8();while(w.length&&w[0].seq<=j){let z=w.shift();if(t-=z.bytes,z.seq!==j)continue;let M=Math.max(0,D-z.sentMs);while(A.length&&A.at(-1).rttMs>=M)A.pop();A.push({atMs:D,rttMs:M}),f[Math.min(qq,Math.round(M))]++,p++,F8=Math.min(F8??M,M)}},m0=()=>{let B=0;for(let j=0;j<=qq;j++)if(B+=f[j],B*2>=p)return j;return 0},d0=()=>q.bufferedAmount<=N8()/2&&!Cq(0.5),Rq=()=>{w8=!0,r=[],q8=0,C?.leave(O8),C=null},Dq=(B)=>{if(q.done)return;if(B.key)O.first_key_ms??=m();if(!L){if(!C||r.length===0&&!B.key)return;if(r.push(B),q8+=B.data.byteLength,q8>N8())Rq();return}if(W){e++;return}if(q.bufferedAmount>N8()||Cq(1)){W=!0,e++,G=setInterval(()=>{if(q.done||!d0())return;if(G)clearInterval(G);G=null,W=!1,H8()},Q.drainPollMs??25);return}if(!U){if(!B.key){e++;return}if(H({type:"hello",width:N.width,height:N.height,fps:n[b].fps,preset:b,codec:j1}),U=!0,O.first_frame_ms??=m(),!y&&J?.sound)H({type:"audioHello",...b8}),y=!0}let j=H({type:"frame",key:B.key,seq:F,captureMicros:B.micros,data:B.data});if(w.push({seq:F,sentMs:U8(),bytes:j}),t+=j,w.length>T1)t-=w.shift().bytes;F++,K8++,J8??=B.micros,M8=B.micros,l.frames++,l.bytes+=j},O8={started(B){b=B,U=!1,r=[],q8=0},unit:Dq,failed:()=>W8("encoder_failed")},E8=()=>{let B=(Q.ffmpeg??L0)();if(!J||!N){W8("encoder_failed");return}let[j,D]=[J,N],z="kind"in j&&j.kind==="simulator"?j.stream:null;if(!B&&!z){W8("encoder_failed");return}if(C??="kind"in j&&j.kind==="mac_screen"?$1(Q.spawn??j0):new Pq,O.encoder_ms===void 0)O.encoder_ms=m(),O.encoder_shared=C.running;C.start(O8,b,()=>{let M=n[b].fps;if(z)return z(M,n[b].kbps,z0);if("kind"in j&&j.kind==="simulator"){let g=Math.min(0.99,M0(j.size)),x8={width:j.size.width*g,height:j.size.height*g};return w1(B,Z8(b,Y1(Math.min(M,30)),x8,(Q.macEncoder??B0)()),j)}if("kind"in j&&j.kind==="windows_screen")return(Q.spawn??y8)(B,Z8(b,M1(M,D),R0(D)),{SystemRoot:process.env.SystemRoot??"C:\\Windows"});return"kind"in j?(Q.spawn??j0)(B,Z8(b,z1(M),R0(D),(Q.macEncoder??B0)()),{}):(Q.spawn??y8)(B,Z8(b,K1(M,D,j.display),D),{DISPLAY:j.display,XAUTHORITY:j.xauthority})},P)},L8=()=>{if(!R)return;K0(R.child),R=null},a0=()=>{let B=(Q.ffmpeg??L0)();if(R||q.done||!y||!J?.sound||!B)return;let j;try{j=(Q.spawn??y8)(B,b0(),{PULSE_SERVER:T8(J.sound)})}catch{return}F0(j);let D={child:j,reader:new e8};R=D,j.stdout?.on("data",(M)=>{if(R!==D||q.done)return;let g;try{g=D.reader.push(M)}catch{L8();return}let x8=P();for(let s0 of g){if(q.bufferedAmount>N8()){S++;continue}H({type:"audio",captureMicros:x8,data:s0}),Y++}});let z=()=>{if(R===D)L8()};j.once("exit",z),j.once("error",z)},H8=()=>{if(!C||q.done)return;z8++,E8()},Tq=()=>{if(q.done||!N)return;if(!L){if(C||w8)return;E8(),Y8=setTimeout(()=>{if(!L)Rq()},G1);return}if(clearTimeout(Y8),O.encoder_early===void 0){if(O.encoder_early=C!==null,w8)O.hold_lapsed=!0}if(!C)E8();let B=r;r=[],q8=0;for(let j of B)Dq(j);V??=setInterval(()=>{let j=P(),D=Math.max(0.001,(j-l.since)/1e6);H({type:"stats",stats:{fps:Math.round(l.frames/D*10)/10,kbps:Math.round(l.bytes*8/1000/D),dropped:e,restarts:z8,queued_bytes:q.bufferedAmount}}),l={frames:0,bytes:0,since:j}},A1)};x.desktop.then((B)=>{if(q.done)return;J=B;let j={ready(D){N=D,O.desktop_ms??=m(),Tq()},clipboard(D){if(q.open&&Buffer.byteLength(D)<=_)H({type:"serverClipboard",text:D})},end(D){if("reason"in D&&q.open)H({type:"error",code:D.reason});q.end(D)}};if("kind"in B&&B.kind==="simulator")T=B.input,j.ready(B.points);else if("kind"in B&&B.kind==="windows_screen")T=(Q.windowsInput??kq)(j);else if("kind"in B)T=(Q.macInput??((D)=>A0(D,Xq())))(j);else{let D=(Q.linuxClipboard??W0)(B,j),z=_1(B.rfbSocket,{...j,clipboard:(M)=>{if(!D)j.clipboard(M)}});T=D?{pointer:(M,g,x8)=>D.apply(()=>z.pointer(M,g,x8)),key:(M,g)=>D.apply(()=>z.key(M,g)),clipboard:(M)=>D.write(M),close(){D.close(),z.close()}}:z}Zq()},(B)=>q.end({error:B}));function Zq(){if($8||!x.viewerSameNetwork||!L||q.done||!J||!("kind"in J)||J.kind!=="mac_screen")return;$8=(Q.macWindows??G0)((B)=>{if(q.open)H({type:"windows",bounds:B})})}let yq={viewer:x.viewer??null,notify(B){if(q.open)H({type:"control",control:B})}},f8=(B)=>{if(!T)return;if(!J||!("kind"in J)||J.kind!=="simulator")Bq.claim(yq);B(T)};return{opened(){O.relay_ms??=m()},received(B){jq+=B.byteLength;let j;try{j=X.push(B)}catch{W8("viewer_protocol");return}for(let D of j){if(q.done)return;switch(D.type){case"ping":H({type:"pong",token:D.token});break;case"pointer":f8((z)=>z.pointer(D.x,D.y,D.buttons));break;case"key":f8((z)=>z.key(D.down,D.keysym));break;case"clientClipboard":f8((z)=>z.clipboard(D.text));break;case"config":if(D.preset!==b)b=D.preset,H8();break;case"keyframeRequest":if(U&&!W)H8();break;case"ack":r0(D.seq);break;case"audioEnable":if(D.on)a0();else L8();break;default:break}}if(!L&&!q.done){if(L=!0,O.viewer_ms=m(),x.viewer)_8=Bq.join(yq);Tq(),Zq()}},close(){if(_8?.(),_8=null,$8?.close(),G)clearInterval(G);if(V)clearInterval(V);clearTimeout(Y8),C?.leave(O8),L8(),T?.close()},summary:()=>({output_bytes:Lq,input_bytes:jq,video:{preset:b,frames:K8,dropped:e,restarts:z8,avg_fps:J8!==null&&M8>J8?Math.round((K8-1)/((M8-J8)/1e6)*10)/10:0,min_rtt_ms:Math.round(F8??0),p50_rtt_ms:p?m0():0,audio_packets:Y,audio_dropped:S,connect:O}})}}var T0=null,_0=null,O1=null,E1=null;function H1(){let q=I();return q?.features.display?q.ffmpeg:null}function $0(q){return T0??=new Promise((x)=>{N1(q,["-hide_banner","-encoders"],{env:{},timeout:5000,killSignal:"SIGKILL",maxBuffer:1048576,encoding:"utf8"},(Q,P)=>{let X=(b)=>!Q&&new RegExp(`^\\s*V\\S*\\s+${b}\\s`,"m").test(P);x(_0={x264:X("libx264"),videotoolbox:X("h264_videotoolbox")})})}),T0}var Z0=null;function FQ(){return Z0??=(async()=>{let q=[I()?.ffmpeg,"/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg"].find((Q)=>Boolean(Q&&U1(Q)));if(!q)return null;let x=await $0(q);return x.videotoolbox||x.x264?q:null})(),Z0}function bq(q=process.platform,x={}){if(q!=="linux"&&q!=="darwin"&&q!=="win32")return Promise.resolve(!1);let Q=(x.ffmpeg??H1)();if(!Q)return Promise.resolve(!1);let P=(x.encoders??$0)(Q);if(q==="linux")return P.then((b)=>b.x264);if(q==="win32"){let b=x.windowsScreen?x.windowsScreen():E1??=fq();return Promise.all([P,b]).then(([J,N])=>J.x264&&(N?.session??0)>0)}let X=x.macScreen?x.macScreen():O1??=l8(Xq());return Promise.all([P,X]).then(([b,J])=>(b.x264||b.videotoolbox)&&J?.screen===!0&&J.accessibility)}var c1=43200000,A8=":99",l1=60000,V8=15000,Nq={width:1280,height:800},r1=/^[A-Za-z0-9._:-]{1,160}$/;function m1(q){return Boolean(q)&&typeof q==="object"&&!Array.isArray(q)}var d1=["video","viewer","viewer_same_network","viewer_network"];function a1(q,x=Date.now()){let Q=["relay_url","session_id","expires_at"];if(!m1(q)||Q.some((N)=>!(N in q))||Object.keys(q).some((N)=>!Q.includes(N)&&!d1.includes(N)))throw new K("invalid_display_request","Reason desktop request is malformed.");let P="video"in q?h0(q.video):void 0,X="viewer"in q?g0(q.viewer):null;if(P===null)throw new K("invalid_display_request","Reason desktop video request is invalid.");let b=null;try{b=typeof q.relay_url==="string"?new URL(q.relay_url):null}catch{}if(!b||b.protocol!=="wss:"&&b.protocol!=="ws:"||b.username||b.password)throw new K("invalid_display_request","Reason desktop relay URL is invalid.");if(typeof q.session_id!=="string"||!r1.test(q.session_id))throw new K("invalid_display_request","Reason desktop session identity is invalid.");let J=typeof q.expires_at==="string"?Date.parse(q.expires_at):Number.NaN;if(!Number.isFinite(J)||J<=x)throw new K("invalid_display_request","Reason desktop session has already expired.");return{relay_url:q.relay_url,session_id:q.session_id,expires_at:new Date(Math.min(J,x+c1)).toISOString(),...P?{video:P}:{},...X?{viewer:X}:{},...P&&q.viewer_same_network===!0?{viewer_same_network:!0}:{}}}function O0(q=process.platform){return(q==="linux"||q==="darwin"||q==="win32")&&I()?.features.display===!0}async function vQ(){if(process.platform==="win32")return O0()&&await bq();if(process.platform!=="darwin")return O0();return await bq()}function S8(q){I1(q,{recursive:!0,mode:448});let x=k1(q);if(!x.isDirectory()||x.isSymbolicLink()||process.getuid&&x.uid!==process.getuid())throw new K("display_unavailable","Reason desktop state directory is not private.");h1(q,448)}function s1(q,x){let Q=(X)=>{let b=Buffer.alloc(2);return b.writeUInt16BE(X.length),Buffer.concat([b,X])},P=Buffer.from([255,255]);return Buffer.concat([P,Q(Buffer.alloc(0)),Q(Buffer.from(q)),Q(Buffer.from("MIT-MAGIC-COOKIE-1")),Q(x)])}function o(q,x,Q=2000){return new Promise((P)=>{let X=u1(q),b="",J=(N)=>{X.destroy(),P(N)};X.setTimeout(Q,()=>J(!1)),X.once("error",()=>J(!1)),X.once("close",()=>J(!1)),X.once("connect",()=>{if(!x)J(!0)}),X.on("data",(N)=>{if(b+=N.toString("latin1"),b.length>=4)J(b.startsWith("RFB "))})})}async function v0(q,x){let Q=Date.now()+x;while(Date.now()<Q){if(await q())return!0;await new Promise((P)=>setTimeout(P,100))}return!1}function Uq(q,x,Q){return new Promise((P)=>{let X=I0(q,x,{detached:!0,stdio:"ignore",env:Q});X.once("error",()=>P(-1)),X.once("exit",(b)=>P(b)),X.unref(),setTimeout(()=>P(null),V8).unref()})}var Jq=null;function i1(q=i()){return Jq??=n1(q).finally(()=>{Jq=null}),Jq}async function n1(q){let x=I({home:q});if(!x?.xvfb||!x.x11vnc||!x.openbox)throw new K("display_unavailable","Run `reason desktop install` on this machine to enable its desktop.");H0({root:x.root,automation:x.automation,extensionDir:x.extensionDir});let Q=$(x.root,"display");S8(Q);let P=await t1(q,Q,x.x11vnc);if(P)return P;let X={display:A8,xauthority:$(Q,"Xauthority"),rfbSocket:$(Q,"rfb.sock")},b=$(Q,"pulse"),J=(async()=>{try{S8(b)}catch{return null}return await P0(b,x.pulseaudio)})(),N=$(Q,"home");S8(N);let T={HOME:N,PATH:"/usr/local/bin:/usr/bin:/bin",DISPLAY:X.display,XAUTHORITY:X.xauthority};if(x.pulseaudio)T.PULSE_SERVER=T8(t8(b));let L=async()=>({...X,sound:await J});if(await o({path:X.rfbSocket},!0))return await L();if(!p0(X.xauthority))Wq(X.xauthority,s1(A8.slice(1),g1(16)),{mode:384,flag:"wx"});let C=e1($(Q,"theme"),X.display),U={path:`/tmp/.X11-unix/X${A8.slice(1)}`};if(!await o(U,!1)){if(Uq(x.xvfb,[X.display,"-screen","0",`${Nq.width}x${Nq.height}x24`,"-nolisten","tcp","-auth",X.xauthority],T),!await v0(()=>o(U,!1),V8))throw new K("display_unavailable","Reason could not start the virtual display.");Uq(x.openbox,["--config-file",C.openboxConfig],T)}if(await q9(C,T),!await u0(x.x11vnc,X,Q,"x11vnc.log",T))throw new K("display_unavailable","Reason could not start the desktop server.");return await L()}async function u0(q,x,Q,P,X){if(await o({path:x.rfbSocket},!0))return!0;v1(x.rfbSocket,{force:!0});let b=await Uq(q,["-display",x.display,"-auth",x.xauthority,"-rfbport","0","-rfbportv6","-1","-unixsock",x.rfbSocket,"-nopw","-forever","-shared","-noxdamage","-sb","0","-rfbversion","3.7","-quiet","-bg","-o",$(Q,P)],X);if(b!==null&&b!==0)return!1;return await v0(()=>o({path:x.rfbSocket},!0),V8)}async function o1(){let q=["DISPLAY","XAUTHORITY","WAYLAND_DISPLAY","XDG_SESSION_TYPE"],x=(Q)=>Object.fromEntries(q.flatMap((P)=>Q[P]?[[P,Q[P]]]:[]));if(process.env.DISPLAY)return x(process.env);try{let Q=await new Promise((P,X)=>f1("systemctl",["--user","show-environment"],{encoding:"utf8",timeout:2000},(b,J)=>b?X(b):P(J)));return x(Object.fromEntries(Q.split(`
|
|
248
|
+
`).flatMap((P)=>{let X=P.indexOf("=");return X>0?[[P.slice(0,X),P.slice(X+1)]]:[]})))}catch{return{}}}var E0=new Set;async function t1(q,x,Q){let P=await o1(),X=/^:(\d+)(?:\.\d+)?$/.exec(P.DISPLAY??"")?.[1];if(!X||`:${X}`===A8||P.WAYLAND_DISPLAY||P.XDG_SESSION_TYPE==="wayland")return null;let b={display:`:${X}`,xauthority:P.XAUTHORITY??$(q,".Xauthority"),rfbSocket:$(x,`rfb-${X}.sock`)},J=`${b.display} ${b.xauthority}`;if(E0.has(J)||!await o({path:`/tmp/.X11-unix/X${X}`},!1))return null;let N={HOME:q,PATH:"/usr/local/bin:/usr/bin:/bin",DISPLAY:b.display,XAUTHORITY:b.xauthority};if(await u0(Q,b,x,`x11vnc-${X}.log`,N))return{...b,sound:null};return E0.add(J),process.stderr.write(`Reason worker: your screen ${b.display} could not be served; using the virtual desktop
|
|
249
|
+
`),null}function e1(q,x){let Q=`chromium --no-first-run --no-default-browser-check${process.geteuid?.()===0?" --no-sandbox":""} %U`,P=[["terminal","xterm"],["files","pcmanfm"]].filter(([,b])=>!p0(`/usr/bin/${b}`)).map(([b])=>b),X=Mq({root:q,display:x,screen:Nq,browserExec:Q,absent:P});for(let b of["","openbox","tint2","picom"])S8($(q,b));for(let[b,J]of Object.entries(X.files))Wq($(q,b),J,{mode:384});for(let[b,J]of Object.entries(zq))Wq($(q,`ara-${b}`),p1(J),{mode:384});return{root:q,openboxConfig:$(q,"openbox","rc.xml"),start:X.start}}async function q9(q,x){let Q=[`ROOT=${JSON.stringify(q.root)}`,...q.start,"openbox --reconfigure >/dev/null 2>&1 || true"].join(`
|
|
250
|
+
`);await new Promise((P)=>{let X=I0("/bin/sh",["-c",Q],{stdio:"ignore",env:{...x,PATH:"/usr/bin:/bin"}}),b=setTimeout(()=>{X.kill(),P()},V8);X.once("error",()=>{clearTimeout(b),P()}),X.once("exit",()=>{clearTimeout(b),P()})})}async function uQ(q,x={}){let Q=x.now??Date.now,P=a1(q.payload,Q());if(q.signal.throwIfAborted(),!P.video)throw new K("display_video_required","Reason desktops stream as video now; this request came without it.");let X=x.platform??process.platform;if(X!=="linux"&&X!=="darwin"&&X!=="win32")throw new K("display_video_unsupported","This machine does not serve desktop video.");let b=P.video,J=(x.video?.desktop??(X==="darwin"?async()=>S0:X==="win32"?async()=>V0:i1))();return await x9(q.signal,P,x,Q,(N)=>w0(N,{request:b,desktop:J,...P.viewer?{viewer:P.viewer}:{},viewerSameNetwork:P.viewer_same_network===!0},x.video),(N)=>G8({type:"error",code:N}))}function x9(q,x,Q,P,X,b){let J=P();return new Promise((N,T)=>{let L=null,C=!1,U=!1,y,R,Y,S=!1,W=null,G=(A)=>{if(U)return;if(W)A=W;U=!0,clearTimeout(y),clearTimeout(R),q.removeEventListener("abort",F),Y?.close();try{L?.close(1000,"display_session_over")}catch{}if("error"in A){T(A.error);return}N({reason:A.reason,...Y?.summary(),duration_ms:Math.max(0,P()-J)})},V=()=>G({error:new K("display_relay_unavailable","Reason could not reach the desktop relay.")}),F=()=>{let A=q.reason;G({error:A instanceof K?A:new K("cancelled","Reason closed the desktop session.")})},E=()=>{if(!W||!L)return;let A=W.error;try{L.send(b(A instanceof K?A.code:"display_unavailable"))}catch{}G(W)};if(Y=X({get done(){return U||W!==null},get open(){return C&&!U&&W===null},get bufferedAmount(){return L?.bufferedAmount??0},send(A){if(U||W||!C||!L)return;try{L.send(A)}catch{G({reason:"relay_closed"})}},end:(A)=>{if(U||W)return;if(!("error"in A)){G(A);return}if(W=A,S&&C)E()}}),U){Y.close();return}if(q.aborted){F();return}q.addEventListener("abort",F,{once:!0}),y=setTimeout(()=>G({reason:"session_expired"}),Math.max(1,Date.parse(x.expires_at)-P())),R=setTimeout(()=>G({reason:"viewer_absent"}),Q.viewerWaitMs??l1);try{L=(Q.connect??k0)(x.relay_url,(Q.loadProxy??f0)()?.url)}catch{V();return}L.binaryType="arraybuffer",L.onopen=()=>{if(U||!L)return;C=!0,Y?.opened()},L.onmessage=(A)=>{if(U)return;let f=A.data,p=f instanceof ArrayBuffer?new Uint8Array(f):ArrayBuffer.isView(f)?new Uint8Array(f.buffer,f.byteOffset,f.byteLength):null;if(!p||p.byteLength===0)return;if(clearTimeout(R),S=!0,W){E();return}Y?.received(p)},L.onclose=()=>{if(U)return;if(!C){V();return}G({reason:"relay_closed"})},L.onerror=()=>{if(U||C)return;V()}})}
|
|
251
|
+
export{g8 as Tf,D9 as Uf,y9 as Vf,d as Wf,T8 as Xf,FQ as Yf,bq as Zf,pq as _f,oq as $f,I as ag,t9 as bg,e9 as cg,qQ as dg,c1 as eg,A8 as fg,a1 as gg,O0 as hg,vQ as ig,S8 as jg,i1 as kg,uQ as lg};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ik as W}from"./vm-hands-entry-lite-zjfr0zh8.js";var T=W.string().max(201).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/).refine((Q)=>Q.split("/").every((Z)=>Z!=="."&&Z!=="..")),G=W.string().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_./-]*$/).refine((Q)=>!Q.includes("..")&&!Q.includes("//")&&!Q.endsWith("/")&&!Q.endsWith(".lock")),M=W.string().regex(/^[a-f0-9]{40}$/),q=W.number().int().positive(),C=W.string().min(1).max(256),A=W.string().max(60000),B={version:W.literal(1),repoFullName:T},J=W.array(W.string().max(1024).regex(/^(?:Co-authored-by: [^<>\r\n\x00]+ <[^<>\s]+@[^<>\s]+>|Reason-Contributor-ID: rc_[a-f0-9]{32})$/)).max(1000),c=W.strictObject({expectedTrailers:J,missingFromHead:J}),y=W.discriminatedUnion("action",[W.strictObject({action:W.literal("edit"),title:C.optional(),body:A.optional(),base:G.optional()}),W.strictObject({action:W.enum(["ready","draft","close"])}),W.strictObject({action:W.literal("metadata"),field:W.enum(["reviewer","assignee","label"]),change:W.enum(["add","remove"]),value:W.string().min(1).max(100).refine((Q)=>!/[\r\n\0]/.test(Q))})]),d=W.discriminatedUnion("kind",[W.strictObject({...B,kind:W.literal("read"),path:W.string().min(1).max(2048),accept:W.enum(["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"]).optional()}),W.strictObject({...B,kind:W.literal("pr_review_context"),number:q,after:W.string().min(1).max(1024).optional()}),W.strictObject({...B,kind:W.literal("prepare"),branch:G,baseSha:M,defaultBranch:G,diagnosticsVersion:W.literal(1).optional()}),W.strictObject({...B,kind:W.literal("publish"),branch:G,defaultBranch:G,baseSha:M,remoteHeadSha:M.nullable(),contributorTrailers:J.optional()}),W.strictObject({...B,kind:W.literal("pr_create"),head:G,base:G,title:C,body:A,draft:W.boolean()}),W.strictObject({...B,kind:W.literal("pr_mutation"),number:q,mutation:y}),W.strictObject({...B,kind:W.literal("pr_merge"),number:q,expectedHeadSha:M,expectedBaseRef:G,method:W.enum(["merge","squash","rebase"]),commitBody:W.string().max(65536).optional()})]),O=["local_device_gh_prepare_setup","local_device_gh_prepare_metadata","local_device_gh_prepare_private_init","local_device_gh_prepare_fetch","local_device_gh_prepare_base_mismatch","local_device_gh_prepare_checkout_validation","local_device_gh_prepare_checkout_init","local_device_gh_prepare_materialization"];function h(Q){return O.some((Z)=>Z===Q)}class R extends Error{code;constructor(Q){super(Q);this.code=Q}}function ZQ(Q,Z,$){let z=d.safeParse(Q);return Z==="failed"&&z.success&&z.data.kind==="prepare"&&z.data.diagnosticsVersion===1&&h($)}var x=245760,$Q=W.discriminatedUnion("kind",[W.strictObject({kind:W.literal("pr_review_context"),body:W.string().max(x)}),W.strictObject({kind:W.literal("prepare"),headSha:M}),W.strictObject({kind:W.literal("read"),status:W.number().int().min(200).max(599),headers:W.record(W.string(),W.string().max(8192)).refine((Q)=>Object.keys(Q).every((Z)=>Z==="link"||Z==="content-type")),body:W.string().max(x)}),W.strictObject({kind:W.literal("publish"),headSha:M,scannedObjectCount:W.number().int().min(0).max(5000),attribution:c.optional()}),W.strictObject({kind:W.literal("pr_create"),url:W.string().max(1024).regex(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/)}),W.strictObject({kind:W.literal("pr_mutation"),number:q,applied:W.literal(!0)}),W.strictObject({kind:W.literal("pr_merge"),number:q,merged:W.literal(!0)})]).refine((Q)=>new TextEncoder().encode(JSON.stringify(Q)).byteLength<=x,"local_device_gh_result_too_large"),r=W.strictObject({source:W.enum(["agent","human"]),operationId:W.uuid()}),m=W.strictObject({version:W.literal(1),userId:W.guid(),deviceId:W.guid(),rootId:W.guid(),runId:W.guid(),merge:r.optional(),contributorRefresh:W.guid().optional(),repoFullName:T.nullable(),rootRevision:W.string().regex(/^[1-9][0-9]*$/),readOnly:W.boolean(),generation:W.number().int().positive().nullable(),fenceId:W.guid().nullable()}).refine((Q)=>Q.generation===null===(Q.fenceId===null));function P(Q){return/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(Q)&&Q.split("/").every((Z)=>Z!=="."&&Z!=="..")}function KQ(Q,Z,$={},z="read"){if(P(Q)&&(Z==="/search/issues"||Z.startsWith("/search/issues?")))return p(Q,Z,$);if(!P(Q)||!Z.startsWith(`/repos/${Q}/`)&&Z!==`/repos/${Q}`)throw Error("local_device_gh_repository_mismatch");if(/[\\#\u0000-\u001f]/.test(Z)||/%(?:2e|5c|00)/i.test(Z))throw Error("local_device_gh_path_denied");let V=new URL(Z,"https://api.github.com");if(V.pathname!==Z.split("?")[0]||V.username||V.password)throw Error("local_device_gh_path_denied");let Y;try{Y=decodeURIComponent(V.pathname.slice(`/repos/${Q}`.length))}catch{throw Error("local_device_gh_path_denied")}if(Y.includes("%")||Y.split("/").some((D)=>D==="."||D===".."))throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.body!=null)throw Error("local_device_gh_mutation_not_admitted");if(![/^$/,/^\/commits$/,/^\/pulls$/,/^\/pulls\/[1-9][0-9]*(?:\/(?:commits|files|reviews|comments))?$/,/^\/issues\/[1-9][0-9]*(?:\/comments)?$/,/^\/issues\/comments\/[1-9][0-9]*\/reactions$/,/^\/commits\/[A-Za-z0-9_./-]+(?:\/(?:check-runs|status))?$/,/^\/check-runs\/[1-9][0-9]*(?:\/annotations)?$/,/^\/branches\/[A-Za-z0-9_./-]+$/,/^\/git\/ref\/heads\/[A-Za-z0-9_./-]+$/,/^\/compare\/[A-Za-z0-9_./-]+\.\.\.[A-Za-z0-9_./-]+$/].some((D)=>D.test(Y)))throw Error("local_device_gh_path_denied");if(V.searchParams.forEach((D,X)=>{if(X==="per_page"&&/^[1-9][0-9]*$/.test(D)&&Number(D)<=100)return;if(X==="page"&&/^[1-9][0-9]*$/.test(D)&&Number(D)<=100)return;if(Y==="/pulls"&&X==="state"&&["open","closed","all"].includes(D))return;if(Y==="/pulls"&&X==="sort"&&D==="updated")return;if(Y==="/pulls"&&X==="direction"&&D==="desc")return;if(Y==="/pulls"&&["head","base"].includes(X)&&/^[A-Za-z0-9_./:-]{1,255}$/.test(D))return;throw Error("local_device_gh_query_denied")}),$.headers)new Headers($.headers).forEach((X,_)=>{if(_!=="accept"||!["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"].includes(X))throw Error("local_device_gh_header_denied")})}function p(Q,Z,$){if(/[\\#\u0000-\u001f]/.test(Z))throw Error("local_device_gh_path_denied");let z=new URL(Z,"https://api.github.com");if(z.pathname!=="/search/issues"||z.username||z.password)throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.body!=null)throw Error("local_device_gh_mutation_not_admitted");let V=null;z.searchParams.forEach((H,D)=>{if(D==="q"&&V===null){V=H;return}if(D==="per_page"&&/^[1-9][0-9]*$/.test(H)&&Number(H)<=100)return;if(D==="page"&&/^[1-9][0-9]*$/.test(H)&&Number(H)<=100)return;throw Error("local_device_gh_query_denied")});let Y=`repo:${Q.toLowerCase()} `,N=V?.toLowerCase()??"";if(N.length>512||!(N+" ").startsWith(Y)||/(?:^|\s)(?:repo|org|user):/.test(N.slice(Y.length)))throw Error("local_device_gh_query_denied");if($.headers)new Headers($.headers).forEach((H,D)=>{if(D!=="accept"||H!=="application/vnd.github+json")throw Error("local_device_gh_header_denied")})}var DQ=`query PullRequestReviewContext($owner: String!, $repo: String!, $number: Int!, $after: String) {
|
|
3
3
|
repository(owner: $owner, name: $repo) {
|
|
4
4
|
nameWithOwner
|
|
5
5
|
pullRequest(number: $number) {
|
|
@@ -39,4 +39,4 @@ import{Vj as W}from"./vm-hands-entry-lite-hc3p6r9p.js";var T=W.string().max(201)
|
|
|
39
39
|
`)||!/^[a-f0-9]{64}$/.test(Q.bodySha256))throw Error("Invalid Reason Device proof input.");return Buffer.from([Z,$,Q.pathAndQuery,Q.timestamp,Q.nonce,Q.challenge,Q.bodySha256].join(`
|
|
40
40
|
`),"utf8")}function K(Q){return Boolean(Q)&&typeof Q==="object"&&!Array.isArray(Q)}function t(Q,Z){return typeof Q==="string"&&Z.some(($)=>$===Q)}function k(Q){return K(Q)&&typeof Q.id==="string"&&typeof Q.label==="string"&&typeof Q.path_fingerprint==="string"}function v(Q){return K(Q)&&Number.isInteger(Q.seq)&&Number(Q.seq)>=0&&typeof Q.kind==="string"&&/^[A-Za-z0-9._:-]{1,64}$/.test(Q.kind)&&K(Q.payload)}function w(Q){throw Error(Q)}function ZW(Q,Z){let $=K(Q)?Q:{},z=typeof $.error==="string"?$.error:`http_${Z}`,V=typeof $.detail==="string"?$.detail:typeof $.message==="string"?$.message:`Reason Device request failed (${Z})`;return{code:z,message:V}}function l(Q){if(!K(Q)||typeof Q.challenge!=="string"||Q.challenge.length<16||Q.challenge.length>1024||Q.challenge.includes(`
|
|
41
41
|
`)||typeof Q.expires_at!=="string"||!Number.isFinite(Date.parse(Q.expires_at)))w("Reason returned an invalid Device proof challenge.");return{challenge:Q.challenge,expires_at:Q.expires_at}}function L(Q,Z){if(!K(Q)||typeof Q.device_id!=="string"||Q.auth_scheme!=="p256"||Q.organization_id!==void 0&&typeof Q.organization_id!=="string"||Q.protocol_version!==j||!Array.isArray(Q.roots)||!Q.roots.every(k)||Z&&typeof Q.organization_id!=="string"||Q.device_credential!==void 0)w(Z?"Reason returned an invalid Device enrollment.":"Reason returned an invalid Device registration.");return{...{device_id:Q.device_id,...typeof Q.organization_id==="string"?{organization_id:Q.organization_id}:{},protocol_version:j,roots:Q.roots},auth_scheme:"p256"}}function $W(Q){return L(Q,!1)}function KW(Q){let Z=L(Q,!0);if(typeof Z.organization_id!=="string")return w("Reason returned an invalid Device enrollment.");return{...Z,organization_id:Z.organization_id}}function DW(Q){if(!K(Q)||typeof Q.server_time!=="string"||typeof Q.drain!=="boolean")return w("Reason returned an invalid Device heartbeat.");return{server_time:Q.server_time,drain:Q.drain,...f(Q),...typeof Q.update_policy==="string"||Q.update_policy===null?{update_policy:Q.update_policy}:{},...typeof Q.supported_protocol_version==="number"?{supported_protocol_version:Q.supported_protocol_version}:{},...a(Q.latest_cli_versions),...Q.hands_prespawn===!0?{hands_prespawn:!0}:{}}}var u=["account_root_metadata_supported","workspace_root_metadata_supported","account_root_path_supported","home_contained_roots_supported","root_paths_supported","startup_supported"];function f(Q){return Object.fromEntries(u.filter((Z)=>Q[Z]===!0).map((Z)=>[Z,!0]))}function zW(Q){if(!K(Q))return;try{return{...l(Q),...f(Q)}}catch{return}}function a(Q){if(!K(Q))return{};let Z={};for(let $ of s){let z=Q[$];if(typeof z==="string"&&/^(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})$/.test(z))Z[$]=z}return Object.keys(Z).length>0?{latest_cli_versions:Z}:{}}function FW(Q){if(!K(Q)||!Array.isArray(Q.roots)||!Q.roots.every(k))return w("Reason returned an invalid Device root sync.");return{roots:Q.roots}}function wW(Q){if(!K(Q)||Q.user_id!==void 0&&typeof Q.user_id!=="string"||typeof Q.organization_id!=="string"||typeof Q.organization_name!=="string"||typeof Q.organization_slug!=="string")return w("Reason returned an invalid Device identity.");return{...typeof Q.user_id==="string"?{user_id:Q.user_id}:{},organization_id:Q.organization_id,organization_name:Q.organization_name,organization_slug:Q.organization_slug}}function VW(Q){if(!K(Q)||Q.disconnected!==!0)return w("Reason did not disconnect this Device.");let Z=Q.sessions_moved;return typeof Z==="number"&&Number.isSafeInteger(Z)&&Z>=0?{disconnected:!0,sessions_moved:Z}:{disconnected:!0}}function YW(Q){if(K(Q)&&Q.ok===!0&&typeof Q.expires==="number")return{ok:!0,expires:Q.expires};if(K(Q)&&Q.ok===!1&&typeof Q.error==="string")return{ok:!1,error:Q.error};return w("Reason did not answer the local login hand-over.")}function HW(Q){if(!K(Q)||Q.accepted!==!0)return w("Reason did not accept the Device lifecycle event.");return{accepted:!0}}function e(Q){return Buffer.byteLength(JSON.stringify(Q),"utf8")}function XW(Q,Z=b){if(!K(Q)||typeof Q.operation_id!=="string"||typeof Q.attempt_id!=="string"||typeof Q.attempt_token!=="string"||!/^(?:reason|ara)_attempt_/.test(Q.attempt_token)||typeof Q.lease_until!=="string"||typeof Q.run_id!=="string"||typeof Q.root_id!=="string"||Q.owner!==void 0&&!E(Q.owner)||!t(Q.capability,Z)||!K(Q.payload)||Q.protocol_version!==j||e(Q.payload)>n||Q.authority!==void 0&&!U(Q.authority)||Q.local_github_authority!==void 0&&!m.safeParse(Q.local_github_authority).success||Q.capability==="github.local.v1"&&!m.safeParse(Q.local_github_authority).success||Q.recording_authority!==void 0&&!S(Q.recording_authority)||Q.capability==="browser.recording.v1"&&(!S(Q.recording_authority)||!E(Q.owner))||Q.capability!=="browser.recording.v1"&&Q.recording_authority!==void 0)return w("Reason returned an invalid Device operation claim.");let $={operation_id:Q.operation_id,attempt_id:Q.attempt_id,attempt_token:Q.attempt_token,lease_until:Q.lease_until,run_id:Q.run_id,root_id:Q.root_id,capability:Q.capability,payload:Q.payload,...U(Q.authority)?{authority:Q.authority}:{},...S(Q.recording_authority)?{recording_authority:Object.freeze({...Q.recording_authority})}:{},...Q.local_github_authority!==void 0?{local_github_authority:m.parse(Q.local_github_authority)}:{},...Q.capability==="hands.connect"&&K(Q.environment)&&K(Q.environment.payload)&&U(Q.environment.authority)?{environment:{payload:Q.environment.payload,authority:Q.environment.authority}}:{},protocol_version:j};if(Q.owner!==void 0)$.owner=Object.freeze({...Q.owner});return $}function GW(Q){if(!K(Q)||typeof Q.lease_until!=="string"||!Array.isArray(Q.controls)||!Q.controls.every(v)||!Number.isInteger(Q.next_control_seq)||Number(Q.next_control_seq)<0)return w("Reason returned an invalid Device operation heartbeat.");return{lease_until:Q.lease_until,controls:Q.controls,next_control_seq:Number(Q.next_control_seq)}}function BW(Q){if(!K(Q)||!Number.isInteger(Q.next_event_seq)||Number(Q.next_event_seq)<0||typeof Q.duplicate!=="boolean"||!Number.isInteger(Q.accepted_count)||Number(Q.accepted_count)<0)return w("Reason returned an invalid Device operation event result.");return{next_event_seq:Number(Q.next_event_seq),duplicate:Q.duplicate,accepted_count:Number(Q.accepted_count)}}function MW(Q){if(!K(Q)||!K(Q.payload)||!U(Q.authority))return w("Reason returned an invalid Device environment delivery.");return{payload:Q.payload,authority:Q.authority}}function QQ(Q){return Q==="succeeded"||Q==="failed"||Q==="cancelled"||Q==="expired"}function gW(Q){if(!K(Q)||!QQ(Q.status)||typeof Q.idempotent!=="boolean")return w("Reason returned an invalid Device operation completion.");return{status:Q.status,idempotent:Q.idempotent}}
|
|
42
|
-
export{d as
|
|
42
|
+
export{d as ye,R as ze,ZQ as Ae,x as Be,$Q as Ce,m as De,KQ as Ee,DQ as Fe,zQ as Ge,b as He,j as Ie,I as Je,n as Ke,HQ as Le,XQ as Me,GQ as Ne,BQ as Oe,MQ as Pe,gQ as Qe,qQ as Re,NQ as Se,mQ as Te,UQ as Ue,jQ as Ve,xQ as We,JQ as Xe,SQ as Ye,IQ as Ze,PQ as _e,TQ as $e,CQ as af,AQ as bf,bQ as cf,EQ as df,kQ as ef,LQ as ff,fQ as gf,_Q as hf,cQ as if,yQ as jf,dQ as kf,OQ as lf,hQ as mf,RQ as nf,rQ as of,pQ as pf,nQ as qf,oQ as rf,sQ as sf,iQ as tf,tQ as uf,vQ as vf,lQ as wf,uQ as xf,aQ as yf,eQ as zf,i as Af,QW as Bf,WW as Cf,ZW as Df,l as Ef,$W as Ff,KW as Gf,DW as Hf,zW as If,FW as Jf,wW as Kf,VW as Lf,YW as Mf,HW as Nf,XW as Of,GW as Pf,BW as Qf,MW as Rf,gW as Sf};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{lj as F}from"./vm-hands-entry-lite-fyvgav60.js";import{Lj as b}from"./vm-hands-entry-lite-aj1ccphg.js";import{randomUUID as d}from"crypto";import{spawnSync as C}from"child_process";import{chmodSync as zj,cpSync as Jj,existsSync as U,lstatSync as M,mkdirSync as h,readdirSync as Wj,readFileSync as I,readlinkSync as Zj,realpathSync as R,renameSync as P,rmdirSync as $j,rmSync as G,symlinkSync as E,writeFileSync as qj}from"fs";import{dirname as B,join as K,relative as Kj,resolve as Qj}from"path";var s="so.ara.cli",Vj="5LJFSBRY2F",wj="Background/Reason.app",m="ReasonBackgroundIdentity",Sj="Contents/Helpers/ReasonPermissionTile";var S="AraBackgroundIdentity",Xj="Reason",Dj=`anchor apple generic and identifier "${s}" and certificate leaf[subject.OU] = "${Vj}"`;class H extends Error{code;constructor(j,z){super(z);this.code=j;this.name="MacOSBackgroundIdentityError"}}var T="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function v(j=F()){return K(j,"Library","Application Support","Reason","Background","Reason.app")}function _(j=F()){return K(j,"Library","Application Support","Ara","Background","Ara.app")}function fj(j=process.execPath){return K(B(R(j)),wj)}function Fj(j){try{return M(j).isFile()}catch{return!1}}function f(j){return[m,S].map((z)=>K(j,"Contents","MacOS",z)).find(Fj)??null}function w(j){try{if(!M(j).isDirectory())return!1;let z=I(K(j,"Contents","Info.plist"),"utf8");return z.includes(`<string>${s}</string>`)&&(z.includes(`<string>${Xj}</string>`)||z.includes("<string>Ara</string>"))&&f(j)!==null}catch{return!1}}function u(j=F()){let z=v(j);if(!w(z))return null;try{let J=I(K(z,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(J)?.[1]??null}catch{return null}}function Gj(j,z=F()){let J=u(z);return J===null||p(A(J.split(".")),A(j.split(/[.-]/).slice(0,3)))}var Yj=1e4;function i(j,z){return C(j,[...z],{stdio:"ignore",timeout:Yj}).status??1}var l=new Set;function r(j){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let z=(J)=>{try{return R(J)}catch{return Qj(J)}};if(j!==void 0&&z(j)!==z(F()))return;throw Error("A test tried to change this computer's real Reason background identity; pass a temporary home. Refused by scripts/test-env.ts.")}var c=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.ara(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,o=new Set(["ara","ara.exe","reason","reason.exe"]);function A(j){return j.map((z)=>Number(z))}function p(j,z){for(let J=0;J<3;J+=1)if(j[J]!==z[J])return j[J]<z[J];return!1}var Nj=[0,2,161];function Pj(j){if(j===null)return!0;let z=Nj,J=null;try{J=R(process.execPath)}catch{}return j.some((W)=>{let Z=c.exec(W);if(Z){let X=Z[1]===void 0?Z.slice(4,7):Z.slice(1,4);return p(A(X),z)}let $=W.slice(W.lastIndexOf("/")+1);return o.has($)&&W!==J&&W!==process.execPath})}function Bj(){let j=C("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(j.status!==0)return null;let z=[];for(let J of j.stdout.split(`
|
|
3
3
|
`)){let W=/^\s*(\d+)\s+(\S.*)$/.exec(J);if(!W||Number(W[1])===process.pid)continue;let Z=W[2].trimEnd(),$=Z.slice(Z.lastIndexOf("/")+1);if(!c.test(Z)&&o.has($)){let Q=C("/usr/sbin/lsof",["-a","-p",W[1],"-d","txt","-Fn"],{encoding:"utf8",timeout:5000}).stdout?.split(`
|
|
4
4
|
`).find((V)=>V.startsWith("n/"));if(Q)Z=Q.slice(1)}z.push(Z)}return z}function vj(j){if(r(j.home),!w(j.sourceApp))throw new H("identity_invalid","The packaged Reason background identity is missing or invalid.");let z=j.command??i,J=v(j.home),W=B(J);h(W,{recursive:!0,mode:448}),zj(W,448);let Z=R(j.sourceApp),$=null;try{$=R(J)}catch{}if(Z!==$){let X=`${process.pid}.${d()}`,Q=K(W,`.Reason.app.${X}.tmp`),V=K(W,`.Reason.app.${X}.old`),Y=!1;try{if(Jj(Z,Q,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!w(Q))throw new H("identity_invalid","The copied Reason background identity is invalid.");let O=j.releaseSigned?["--test-requirement",`=${Dj}`]:[];if(z("/usr/bin/codesign",["--verify","--strict",...O,Q])!==0)throw new H("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let L=!1;for(let D=0;D<4;D+=1){let N=!1;try{P(J,V),N=!0,Y=!0}catch(q){if(q.code!=="ENOENT")throw q}if(D===0)j.beforePublish?.();try{P(Q,J),L=!0}catch(q){let jj=q.code;if(!["EEXIST","ENOTEMPTY"].includes(jj??""))throw q;if(N)G(V,{recursive:!0,force:!0}),Y=!1;if(D===3)throw q;continue}if(N)G(V,{recursive:!0,force:!0}),Y=!1;break}if(!L)throw Error("Could not publish Reason's background identity.")}catch(O){if(Y&&!U(J)&&U(V))P(V,J);throw O}finally{G(Q,{recursive:!0,force:!0}),G(V,{recursive:!0,force:!0})}}return e(J,j,{verified:Z!==$}),J}function n(j){return K(B(j),".Reason.app.registered")}function t(j){try{let z=M(j);return z.isDirectory()?`${z.ino}:${z.birthtimeMs}`:null}catch{return null}}function k(j){let z=t(j);try{return z!==null&&I(n(j),"utf8")===z}catch{return!1}}function a(j){if(w(j))return"bundle";try{if(M(K(j,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return M(K(j,"Contents","MacOS",S)).isSymbolicLink()?"retired":null}catch{return null}}function e(j,z,J={}){let W=z.command??i;if(!J.verified&&W("/usr/bin/codesign",["--verify","--strict",j])!==0)throw new H("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if(W(T,["-f",j])!==0)throw new H("identity_register_failed","Could not register Reason's macOS background identity.");let Z=t(j);try{if(Z)qj(n(j),Z,{mode:384})}catch{}try{Oj(j,z.home,W,z.runningExecutables??Bj)}catch($){let X=$.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${X})
|
|
5
5
|
`)}}function Oj(j,z,J,W){let Z=f(j);if(!Z)return;let $=_(z),X=B($),Q=(q)=>K(q,"Contents","MacOS",S),V=Kj(B(Q($)),Z),Y=`${process.pid}.${d()}`,O=a($);if(O===null)return;let L=O==="bundle";if(L)J(T,["-u",$]);let D=K(X,`.Ara.app.${Y}.old`);if(!l.has($)&&!Pj(W())){if(!L)J(T,["-u",$]);try{P($,D)}catch(q){if(q.code==="ENOENT")return;throw q}G(D,{recursive:!0,force:!0}),Lj(X);return}if(!L){if(Zj(Q($))===V)return;let q=`${Q($)}.${Y}`;E(V,q);try{P(q,Q($))}finally{G(q,{force:!0})}return}let N=K(X,`.Ara.app.${Y}.shim`);h(B(Q(N)),{recursive:!0}),E(V,Q(N));try{try{P($,D)}catch(q){if(q.code==="ENOENT")return;throw q}try{P(N,$)}catch(q){if(U($))return;throw P(D,$),q}}finally{G(N,{recursive:!0,force:!0}),G(D,{recursive:!0,force:!0})}}function Lj(j){try{if(Wj(j).some((J)=>J!==".DS_Store"))return;G(K(j,".DS_Store"),{force:!0}),$j(j)}catch{}}var x=new Map;function Hj(j=F()){let z=x.get(j);if(z)return z;if(process.platform!=="darwin")return[];let J=g(j);if(J===null&&U(B(v(j))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),J=g(j);if(J===null)return[];return x.set(j,J),J}function g(j){let z=v(j),J=_(j);if(!w(z)||!k(z))try{Mj({home:j,skipWhenSettled:!0})}catch{}let W=w(z)&&(k(z)||!w(J))?z:w(J)?J:null,Z=W?f(W):null;if(!Z)return null;if(W===J)l.add(J);let $=C(Z,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return $.status===0&&$.stdout===`spawn
|
|
6
6
|
`?[Z,"--spawn"]:[]}var y=new Map;function Cj(j=F()){let z=Hj(j),J=z[0];if(!J)return[];let W=y.get(J);if(W===void 0){let Z=C(J,["--can-spawn-computer-use"],{env:{},timeout:2000,encoding:"utf8"});W=Z.status===0&&Z.stdout===`spawn
|
|
7
7
|
`,y.set(J,W)}return W?z:[]}function Ej(j=Cj(),z=F()){if(j.length>0)return null;if(u(z)===null)return"computer_use_identity_missing";return Gj(b,z)?"computer_use_identity_outdated":"computer_use_identity_unavailable"}function Mj(j={}){r(j.home);let z=v(j.home);if(j.skipWhenSettled&&w(z)&&k(z)&&a(_(j.home))===null)return!0;if(!w(z)){let J=_(j.home);if(!w(J))return!1;try{return vj({...j,sourceApp:J}),!0}catch(W){if(!w(z))throw W}}return e(z,j),!0}var Rj="REASON_WORKER_IDENTITY_APP";function xj(j,z=process.env,J=F()){let W=z[Rj];return W&&W===v(J)?W:j}function gj(j,z){if(process.platform!=="darwin")return null;let J=v(j),W=K(J,"Contents","MacOS",m),Z=C(W,["--can-run-worker",z],{env:{},timeout:2000,encoding:"utf8"});return Z.status===0&&Z.stdout===`run-worker
|
|
8
8
|
`?{app:J,executable:W}:null}
|
|
9
|
-
export{s as
|
|
9
|
+
export{s as Wi,Vj as Xi,Sj as Yi,H as Zi,T as _i,v as $i,fj as aj,u as bj,Gj as cj,vj as dj,Hj as ej,Cj as fj,Ej as gj,Mj as hj,Rj as ij,xj as jj,gj as kj};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ik as q}from"./vm-hands-entry-lite-zjfr0zh8.js";var u=25,U=q.object({machine:q.string().min(1).max(200),person:q.string().min(1).max(200),team:q.string().min(1).max(200),version:q.string().max(64).optional(),wait_seconds:q.number().int().min(0).max(u).optional()}),x=q.discriminatedUnion("kind",[q.object({id:q.string(),kind:q.literal("who"),all:q.boolean().optional()}),q.object({id:q.string(),kind:q.literal("send"),to:q.string(),body:q.string(),from_name:q.string(),from_agent:q.string(),wake:q.boolean(),reply_to:q.string().max(100).optional(),notify:q.boolean().optional()})]),V=q.object({job:x.nullable(),retry_after_seconds:q.number().optional()}),B=q.object({address:q.string(),person:q.string(),machine:q.string(),agent:q.string(),repo:q.string().nullable(),branch:q.string().nullable(),status:q.string(),since:q.number().nullable(),doing:q.string().nullable(),worker:q.boolean(),tier:q.string().max(10).optional()}),F=q.object({person:q.string(),machine:q.string(),online:q.boolean()}),G=q.object({team:q.string().nullable(),sessions:q.array(B).max(2000),machines:q.array(F).max(500),all:q.boolean().optional()}),H=q.object({address:q.string().max(300),state:q.string().max(40),note:q.string().max(500)}),X=q.union([q.object({who:G}),q.object({sent:q.object({ids:q.array(q.string().max(100)).max(500),recipients:q.array(q.string().max(300)).max(500),from:q.string().max(300),deliveries:q.array(H).max(500).optional()})}),q.object({error:q.string().min(1).max(2000)})]),K=q.object({id:q.string().max(100),from:q.string().max(300),from_agent:q.string().max(100).nullable(),to:q.string().max(300),reply_to:q.string().max(100).nullable(),body:q.string().max(64000),sent_at:q.number()}),Z=q.object({messages:q.array(K).max(100)});
|
|
3
3
|
export{u as va,V as wa};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Hk as e}from"./vm-hands-entry-lite-2t0vcvd8.js";var i=e((o,t)=>{t.exports={name:"playwright-core",version:"1.60.0",description:"A high-level API to automate web browsers",repository:{type:"git",url:"git+https://github.com/microsoft/playwright.git"},homepage:"https://playwright.dev",engines:{node:">=18"},author:{name:"Microsoft Corporation"},license:"Apache-2.0",exports:{".":{types:"./index.d.ts",import:"./index.mjs",require:"./index.js",default:"./index.js"},"./package.json":"./package.json","./lib/bootstrap":"./lib/bootstrap.js","./lib/coreBundle":"./lib/coreBundle.js","./lib/utilsBundle":"./lib/utilsBundle.js","./lib/tools/cli-client/program":"./lib/tools/cli-client/program.js"},bin:{"playwright-core":"cli.js"},types:"types/types.d.ts"}});
|
|
3
3
|
export{i as Aa};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{O as
|
|
2
|
+
import{Pj as $}from"./vm-hands-entry-lite-23bb8ce4.js";var O=$.version,Z=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function S(B,D){if(!Z.test(B)||!Z.test(D))throw Error("cannot compare invalid CLI versions");let J=(q)=>{let y=q.indexOf("-");return y===-1?[q,void 0]:[q.slice(0,y),q.slice(y+1)]},[j,F]=J(B),[w,G]=J(D),K=j.split(".").map(BigInt),M=w.split(".").map(BigInt);for(let q=0;q<3;q+=1){if(K[q]===M[q])continue;return K[q]<M[q]?-1:1}if(F===void 0||G===void 0){if(F===G)return 0;return F===void 0?1:-1}let Q=F.split("."),U=G.split("."),A=Math.max(Q.length,U.length);for(let q=0;q<A;q+=1){let y=Q[q],z=U[q];if(y===void 0||z===void 0){if(y===z)return 0;return y===void 0?-1:1}if(y===z)continue;let H=/^\d+$/.test(y),W=/^\d+$/.test(z);if(H&&W){let X=BigInt(y),Y=BigInt(z);if(X===Y)continue;return X<Y?-1:1}if(H!==W)return H?-1:1;return y<z?-1:1}return 0}function k(B,D){return D?`cli ${B} \xB7 agent ${D}`:`cli ${B}`}
|
|
3
|
+
export{O as Lj,Z as Mj,S as Nj,k as Oj};
|