@reason-machines/cli-linux-arm64-musl 0.2.276 → 0.2.278
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/bin/ara +1 -1
- package/bin/vm-hands/connect-cli-qphdm1f1.js +2 -0
- package/bin/vm-hands/custom-endpoint-device-92914wyp.js +2 -0
- package/bin/vm-hands/desktop-account-vsrtgkk9.js +2 -0
- package/bin/vm-hands/desktop-wallpaper-0pjhgyfk.jpg +0 -0
- package/bin/vm-hands/device-workspace-zk5xwd10.js +2 -0
- package/bin/vm-hands/dock-browser-afp005mt.png +0 -0
- package/bin/vm-hands/dock-files-rywdm96b.png +0 -0
- package/bin/vm-hands/dock-terminal-s41cj1jp.png +0 -0
- package/bin/vm-hands/hands-worker-source-da93x0qx.js +2 -0
- package/bin/vm-hands/index-w9nq2f0p.js +12818 -0
- package/bin/vm-hands/local-automation-tvf2dbfq.js +2 -0
- package/bin/vm-hands/local-capabilities-p579j21r.js +2 -0
- package/bin/vm-hands/local-desktop-users-3j79jbyp.js +2 -0
- package/bin/vm-hands/local-display-mac-j1v3mcgx.js +2 -0
- package/bin/vm-hands/local-display-session-jwdq3jb4.js +2 -0
- package/bin/vm-hands/network-contract-41qanjhp.js +2 -0
- package/bin/vm-hands/package-rx9y4bwe.js +2 -0
- package/bin/vm-hands/permissions-2s0qyrg0.js +2 -0
- package/bin/vm-hands/reason-hands-protocol-51gs8j7v.js +2 -0
- package/bin/vm-hands/status-2d21kwsn.js +96 -0
- package/bin/vm-hands/version-1qgvgegp.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-1bvbhwbb.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-1hwdab4e.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-2xas56hm.js +43 -0
- package/bin/vm-hands/vm-hands-entry-lite-51hcyapr.js +529 -0
- package/bin/vm-hands/vm-hands-entry-lite-5pxbx31d.js +179 -0
- package/bin/vm-hands/vm-hands-entry-lite-65pbrs1x.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-7gh1rbn7.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-84aq8d12.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-8wyfep1z.js +343 -0
- package/bin/vm-hands/vm-hands-entry-lite-9pmag2qk.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-anaydk9m.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-bfwf82rw.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-bwt3y6wz.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-c2nrar90.js +4046 -0
- package/bin/vm-hands/vm-hands-entry-lite-ffg7rf02.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-fraghb8k.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-gqncr2j0.js +42 -0
- package/bin/vm-hands/vm-hands-entry-lite-htn1genx.js +459 -0
- package/bin/vm-hands/vm-hands-entry-lite-jwqqfjba.js +759 -0
- package/bin/vm-hands/vm-hands-entry-lite-k4c504n7.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-n07kxrd1.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-ptmqg51y.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-qvrnx0vk.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-s2xydt0n.js +112 -0
- package/bin/vm-hands/vm-hands-entry-lite-s5qn1k80.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-sv6xwe0h.js +66 -0
- package/bin/vm-hands/vm-hands-entry-lite-y4sjgfqz.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite.js +2 -0
- package/bin/vm-hands/vm-hands-executor-v2qjnrb5.js +9 -0
- package/bin/vm-hands/vm-hands-op-runner-ej1c20a6.js +2 -0
- package/bin/vm-hands/vm-hands-runtime-yyy4ad4z.js +4 -0
- package/bin/vm-hands/worker-sandbox-nnce49w0.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{cf as Z8}from"./vm-hands-entry-lite-bfwf82rw.js";import{lf as R0}from"./vm-hands-entry-lite-ptmqg51y.js";import{gg as Kq}from"./vm-hands-entry-lite-2xas56hm.js";import{Cg as p,Fg as V0,Ig as F0,Jg as C8,Kg as eq,Mg as f8,Pg as q0,Rg as x0}from"./vm-hands-entry-lite-s2xydt0n.js";import{Wg as wq}from"./vm-hands-entry-lite-s5qn1k80.js";import{Xg as o,Yg as C0}from"./vm-hands-entry-lite-9pmag2qk.js";import{jh as B0}from"./vm-hands-entry-lite-84aq8d12.js";import{zh as A0}from"./vm-hands-entry-lite-anaydk9m.js";import{Gh as S}from"./vm-hands-entry-lite-ffg7rf02.js";import{execFile as A1,spawn as w0}from"child_process";import{randomBytes as V1}from"crypto";import{chmodSync as F1,existsSync as w1,lstatSync as K1,mkdirSync as M1,readFileSync as z1,rmSync as Y1,writeFileSync as xq}from"fs";import{connect as _1}from"net";import{join as f}from"path";var Bq="./desktop-wallpaper-0pjhgyfk.jpg";var Rq="./dock-browser-afp005mt.png";var Cq="./dock-files-rywdm96b.png";var yq="./dock-terminal-s41cj1jp.png";var Sq=`# 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 X8=32,Zq=76;function p0(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>${X8}</x><y>${X8}</y></position>
|
|
67
|
+
<size><width>${q.width-X8*2}</width><height>${q.height-X8-Zq}</height></size>
|
|
68
|
+
</application>
|
|
69
|
+
</applications>
|
|
70
|
+
</openbox_config>`}var v0=`# 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
|
+
`,u0=`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
|
+
`,c0="/tmp/ara-dock-browser.png",r0=`[Desktop Entry]
|
|
104
|
+
Name=Chrome
|
|
105
|
+
Exec=chromium --no-sandbox %U
|
|
106
|
+
Icon=${c0}
|
|
107
|
+
Type=Application
|
|
108
|
+
Categories=Network;WebBrowser;
|
|
109
|
+
`,m0=`[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
|
+
`,l0=`[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 Gq={"wallpaper.jpg":Bq,"dock-browser.png":Rq,"dock-terminal.png":yq,"dock-files.png":Cq},d0=Sq,s0='set_wallpaper() { if command -v feh >/dev/null 2>&1; then feh --bg-fill "$1"; else python3 "$2" "$1"; fi; }';function Aq(q){let x=(P)=>P.replaceAll("DISPLAY=:99",`DISPLAY=${q.display}`).replaceAll("/tmp/ara-",`${q.root}/ara-`);return{files:{"openbox/rc.xml":p0(q.screen),"tint2/tint2rc":x(v0),"picom/picom.conf":u0,"ara-terminal.desktop":x(m0),"ara-files.desktop":x(l0),"ara-chromium.desktop":x(r0).replace("chromium --no-sandbox %U",q.browserExec),"ara-set-root-wallpaper.py":d0},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"; [ "$(ticks "$pid")" = "$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"; }',s0,'[ ! -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 Mq}from"crypto";import{once as a0}from"events";import{createWriteStream as i0,existsSync as n0,mkdirSync as o0,mkdtempSync as GX,readFileSync as D8,readdirSync as AX,renameSync as t0,realpathSync as e0,rmSync as qx,statSync as g8,writeFileSync as xx}from"fs";import{dirname as h8,join as G}from"path";import{finished as Xx}from"stream/promises";var $8="omljlfpmafedpplnpkkahegadhkimdje",PX="https://chromewebstore.google.com/detail/reason/omljlfpmafedpplnpkkahegadhkimdje";function NX(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 X of q.managedRootIds){if(typeof X!=="string"||!/^[A-Za-z0-9._:-]{1,160}$/.test(X))return null;x.push(X)}try{let X=new URL(q.apiOrigin);if(X.origin!==q.apiOrigin||X.username||X.password||!(X.protocol==="https:"||X.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(X.hostname)))return null}catch{return null}return{version:1,status:"connected",deviceId:q.deviceId,apiOrigin:q.apiOrigin,managedRootIds:x}}var c={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"}},j8={version:"154.0.8037.57",macArm64Sha256:"0e6b3439469c1b8b95b2e89c72ea29f7af00fb2c28a8878358a0b6002b6d3a64",linux64Sha256:"ceee2972074d441ea7c4ba8bcc0eaab77e7e87680f6653d73d3065851fe10302"};var Q8={ocu:{url:`https://registry.npmjs.org/open-computer-use/-/open-computer-use-${c.ocu.version}.tgz`,sha256:"7c16a87c8cd357787b02c0ebd040dd5f93880c1fb51c1901caa2e0c05d063130",size_bytes:5844280},obu:{url:`https://registry.npmjs.org/open-browser-use/-/open-browser-use-${c.obu.version}.tgz`,sha256:"9386d8ce0a147b3f55e1807b68edf736836378807541c457c9b5f6ca2cabaa4e",size_bytes:21372018},extension:{url:`https://github.com/iFurySt/open-browser-use/releases/download/v${c.obu.version}/open-browser-use-chrome-extension-${c.obu.version}.zip`,sha256:"c9c07bec1175e12ea6985b0e7784a5ef01fd03f014b958224a1e17dcd838a241",size_bytes:31070}},i="pnbmoicbkopffjjgfgfglopechaiemkp";var Qx=["none","standard","all"],O8="22.23.3",Px={"linux-x64":"1084aa36196bba4c3a5e69a1ee388a6e4ff729dad09445fbcd434b28fe3c24af","linux-arm64":"5ced2d48d1d7198739b7f86804de0171aefb6823b684b12341d3321afc3cb0b2","darwin-arm64":"23b25245dcfb9af7262f8ff142e9e2e0af025368117329e7a7458a51e5922f53"},H8={"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"}},zq="chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",k8={version:"9.0.2",url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffmpeg.zip",sha256:"c8ed4c4e6978a03c485edbfe4e0a5dc2380f8a30bba5150531b31b094492d924"},bx={version:k8.version,url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffprobe.zip",sha256:"fcbe839537485eaee7a7a8bc5cbc0f90d53617e80943e8a5b2e31cb851197ea6"},n="com.ifuryst.open_browser_use.extension",Yq="com.reasonmachines.browser_use.extension",Vq="/tmp/reason-browser-use",I8=["tint2","picom","xterm","pcmanfm"],_q=["fonts-droid-fallback"],Eq=["pulseaudio"],Jx=["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",..._q,"galculator","chromium","ffmpeg","tmux",...Eq,...I8],Nx=new Set([...I8,..._q,...Eq]),Fq=Jx.filter((q)=>q!=="chromium"&&!Nx.has(q)),Wx=["Xvfb","openbox","x11vnc","xdotool","dbus-launch","python3","ffmpeg","tmux"],U8="/usr/bin/chromium",Lx=["/usr/local/bin","/usr/bin","/bin","/opt/homebrew/bin"];function $q(q=process.platform,x=process.arch){let X=`${q}-${x}`;return X==="linux-x64"||X==="linux-arm64"||X==="darwin-arm64"?X:null}function T8(q){return{node:{version:O8,url:`https://nodejs.org/dist/v${O8}/node-v${O8}-${q}.tar.gz`,sha256:Px[q]},open_computer_use:{version:c.ocu.version,url:Q8.ocu.url,sha256:Q8.ocu.sha256},open_browser_use:{version:c.obu.version,url:Q8.obu.url,sha256:Q8.obu.sha256},...q==="darwin-arm64"?{chrome_for_testing:{version:j8.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${j8.version}/mac-arm64/chrome-mac-arm64.zip`,sha256:j8.macArm64Sha256}}:{}}}function jx(q){let x={extension:i};for(let[X,Q]of Object.entries(T8(q)))x[X]=`${Q.version}@${Q.sha256}`;return x}function Oq(q){return G(q,".local","share","reason","desktop")}function Hq(q,x=wq()){let X=Oq(x),Q=(W)=>G(X,W,T8(q)[W]?.version??""),P=Q("open_computer_use"),b=Q("open_browser_use"),J=q==="darwin-arm64",L=G(x,"Library","Application Support"),Z=J?G(L,"Google","Chrome","NativeMessagingHosts",`${n}.json`):G(x,".config","google-chrome","NativeMessagingHosts",`${n}.json`);return{root:X,automation:G(h8(X),"automation"),receipt:G(X,"receipt.json"),minimal:v8(x),node:G(Q("node"),"bin","node"),ocuDir:P,ocu:G(P,H8[q].ocu),ocuApp:J?G(P,"dist","Open Computer Use.app"):null,obuDir:b,obu:G(b,"cli","open-browser-use.js"),nativeHost:G(b,H8[q].obu),extensionDir:J?G(L,"OpenBrowserUse","chrome-extension","release"):G(x,".local","share","open-browser-use","chrome-extension","release"),setupNativeHostManifest:Z,nativeHostManifests:J?[Z,G(L,"Google","ChromeForTesting","NativeMessagingHosts",`${n}.json`)]:[G(x,".config","chromium","NativeMessagingHosts",`${n}.json`),G(x,".config","google-chrome-for-testing","NativeMessagingHosts",`${n}.json`)],browser:J?G(Q("chrome_for_testing"),zq):U8,userChromeHost:J?G(X,"user-chrome","reason-browser-use"):null,userChromeRegistration:J?G(L,"Google","Chrome","NativeMessagingHosts",`${Yq}.json`):null,ffmpegDir:G(X,"ffmpeg"),ffmpeg:J?G(X,"ffmpeg",k8.version,"ffmpeg"):null,ffprobe:J?G(X,"ffprobe",bx.version,"ffprobe"):null}}function fq(q){try{let x=JSON.parse(D8(q,"utf8"));if(typeof x!=="object"||x===null)return null;let X=x,Q=X.pins;if(X.schema_version!==1||typeof X.platform!=="string"||typeof Q!=="object"||Q===null||!Object.values(Q).every((P)=>typeof P==="string")||!Qx.includes(X.permissions)||!Array.isArray(X.missing_system_packages)||!X.missing_system_packages.every((P)=>typeof P==="string")||typeof X.updated_at!=="string")return null;return{schema_version:1,platform:X.platform,pins:Q,permissions:X.permissions,missing_system_packages:X.missing_system_packages,updated_at:X.updated_at}}catch{return null}}function Ux(q,x,X=384){o0(h8(q),{recursive:!0,mode:448});let Q=`${q}.pending.${process.pid}`;xx(Q,x,{mode:X}),t0(Q,q)}function r(q){try{return g8(q).isFile()}catch{return!1}}function gq(q){try{let x=g8(q);return x.isFile()&&(x.mode&73)!==0}catch{return!1}}function Dx(q){try{return D8(q,"utf8")}catch{return null}}function l(q){for(let x of Lx){let X=G(x,q);try{let Q=g8(X);if(Q.isFile()&&(Q.mode&73)!==0)return X}catch{}}return null}function Tx(q){try{let x=JSON.parse(D8(G(q,"package.json"),"utf8"));return typeof x==="object"&&x!==null&&typeof x.version==="string"?x.version:null}catch{return null}}function Bx(q,x,X){let Q=T8(X)[q];if(!Q)return!1;if(q==="node")return r(G(x,"bin","node"));if(q==="chrome_for_testing")return r(G(x,zq));let P=H8[X][q==="open_computer_use"?"ocu":"obu"];return Tx(x)===Q.version&&r(G(x,P))&&(q==="open_computer_use"||r(G(x,"cli","open-browser-use.js")))}function Rx(q){return Mq("sha256").update(Buffer.from(q,"base64")).digest("hex").slice(0,32).replace(/./g,(x)=>String.fromCharCode(97+Number.parseInt(x,16)))}function p8(q){try{let x=JSON.parse(D8(q,"utf8"));return typeof x==="object"&&x!==null&&!Array.isArray(x)?x:null}catch{return null}}function Cx(q){let x=p8(G(q.extensionDir,"manifest.json"));return x!==null&&x.version===c.obu.version&&typeof x.key==="string"&&Rx(x.key)===i}function yx(q,x){let X=q?.allowed_origins;return q!==null&&q.name===n&&Array.isArray(X)&&X.length===1&&X[0]===`chrome-extension://${i}/`&&(x===void 0||q.path===x)}function Sx(q){return Cx(q)&&r(q.nativeHost)&&q.nativeHostManifests.every((x)=>yx(p8(x),q.nativeHost))}function Zx(q){return`#!/bin/sh
|
|
122
|
+
# Reason's Chrome extension host (reason desktop install): Open Browser Use on Reason's socket directory.
|
|
123
|
+
obu=${`'${q.replaceAll("'","'\\''")}'`}
|
|
124
|
+
case "$1" in
|
|
125
|
+
chrome-extension://*) exec "$obu" host --socket-dir ${Vq} ;;
|
|
126
|
+
mcp) shift; exec "$obu" mcp --socket-dir ${Vq} "$@" ;;
|
|
127
|
+
esac
|
|
128
|
+
exec "$obu" "$@"
|
|
129
|
+
`}function Gx(q){let x=p8(q),X=x?.allowed_origins;return x!==null&&x.name===Yq&&x.type==="stdio"&&Array.isArray(X)&&X.includes(`chrome-extension://${$8}/`)&&typeof x.path==="string"&&gq(x.path)}function Ax(q,x){if(!q.userChromeHost||!q.userChromeRegistration)return null;if(!x||Dx(q.userChromeHost)!==Zx(q.nativeHost)||!gq(q.userChromeHost))return{code:"user_chrome_browser_use_missing"};return Gx(q.userChromeRegistration)?{host:q.userChromeHost}:{code:"user_chrome_native_host_unregistered"}}var Vx={display:["display"],computer:["display","system_packages","node","open_computer_use"],browser:["display","system_packages","node","open_computer_use","open_browser_use","browser_extension","browser","chrome_for_testing"]};function m(q={}){let x=q.platform===void 0?$q():q.platform;if(!x)return null;let X=Hq(x,q.home),Q=fq(X.receipt),P=jx(x),b=Q!==null&&Q.platform===x&&JSON.stringify(Object.entries(Q.pins).sort())===JSON.stringify(Object.entries(P).sort()),J=[],L=T8(x);for(let N of["node","open_computer_use","open_browser_use","chrome_for_testing"]){let y=L[N];if(!y)continue;let F=Bx(N,G(X.root,N,y.version),x),K=Q?.pins[N],$=F&&K===P[N]?"ready":K!==void 0&&K!==P[N]?"outdated":"missing";J.push({name:N,state:$,detail:y.version})}let Z=Q?.pins.extension===i&&Sx(X);J.push({name:"browser_extension",state:Z?"ready":"missing",detail:i});let W=l("Xvfb"),U=l("x11vnc"),C=l("openbox");if(x!=="darwin-arm64"){J.push(r(U8)?{name:"browser",state:"ready",detail:U8}:{name:"browser",state:"missing",detail:`non-snap Chromium at ${U8}`});let N=W!==null&&U!==null&&C!==null;J.push({name:"display",state:N?"ready":"missing",detail:"Xvfb + openbox + x11vnc"});let y=Wx.filter((_)=>l(_)===null),F=(Q?.missing_system_packages??Fq).filter((_)=>Fq.includes(_)),K=y.length===0&&F.length===0;J.push(K?{name:"system_packages",state:"ready"}:{name:"system_packages",state:"missing",detail:[...new Set([...F,...y])].join(" ")});let $=I8.filter((_)=>l(_)===null);J.push($.length===0?{name:"desktop_look",state:"ready"}:{name:"desktop_look",state:"missing",detail:$.join(" ")})}let R=X.ffmpeg&&r(X.ffmpeg)?X.ffmpeg:l("ffmpeg"),T=!R?null:R===X.ffmpeg?X.ffprobe:G(h8(e0(R)),"ffprobe"),Y=b&&J.every((N)=>N.state==="ready"),A=(N)=>b&&J.every((y)=>!Vx[N].includes(y.name)||y.state==="ready");return{platform:x,root:X.root,automation:X.automation,ready:Y,features:{display:A("display"),computer:A("computer"),browser:A("browser")},node:X.node,ocu:X.ocu,obu:X.obu,nativeHost:X.nativeHost,extensionDir:X.extensionDir,browser:X.browser,ffmpeg:R,ffprobe:T&&r(T)?T:null,userChrome:Ax(X,b&&["node","open_browser_use"].every((N)=>J.find((y)=>y.name===N)?.state==="ready")),pulseaudio:l("pulseaudio"),xvfb:W,x11vnc:U,openbox:C,components:J}}function hq(q){return Fx(q)?Kq():[]}function Fx(q){return q?.platform==="darwin-arm64"&&q.ffmpeg===G(q.root,"ffmpeg",k8.version,"ffmpeg")}async function HX(q,x,X,Q=fetch){try{let P=await Q(q,{redirect:"follow"});if(!P.ok||!P.body)throw Error(`download failed (HTTP ${P.status}): ${q}`);let b=Mq("sha256"),J=i0(X,{mode:384});try{let Z=P.body.getReader();for(let W=await Z.read();!W.done;W=await Z.read())if(b.update(W.value),!J.write(W.value))await a0(J,"drain")}finally{J.end(),await Xx(J)}let L=b.digest("hex");if(L!==x)throw Error(`digest mismatch for ${q}: expected ${x}, got ${L}`)}catch(P){throw qx(X,{force:!0}),P}}function v8(q){return G(Oq(q),"minimal.json")}function wx(q=o()){return n0(v8(q))}function fX(q={}){Ux(v8(q.home??o()),`${JSON.stringify({version:1,minimal_at:(q.now?.()??new Date).toISOString()})}
|
|
130
|
+
`)}function gX(q={}){let x=q.platform===void 0?$q():q.platform;if(x===null)return null;let X=q.home??o();if(fq(Hq(x,X).receipt)!==null)return"refresh";return wx(X)?null:"install"}import{execFile as kx,spawn as a8}from"child_process";import{existsSync as Ix}from"fs";import{connect as px}from"net";function Kx(){let q=new Set,x=null,X=(P)=>({holder:x?.viewer??null,you:x===P,same_user:Boolean(x?.viewer&&P.viewer&&x.viewer.user_id===P.viewer.user_id)}),Q=()=>{for(let P of q)P.notify(X(P))};return{join(P){return q.add(P),P.notify(X(P)),()=>{if(!q.delete(P))return;if(x!==P)return;x=null,Q()}},claim(P){if(x===P||!q.has(P))return;x=P,Q()}}}var kq=Kx();import{spawn as Mx}from"child_process";import{existsSync as zx}from"fs";import{connect as Yx}from"net";import{join as B8}from"path";var pq="reason_desktop",P8={sampleRate:48000,channels:2,codec:"opus"},_x=5000,Ex=107,$x=262144,r8=(q)=>B8(q,"native"),R8=(q)=>`unix:${q}`;function u8(q,x=1000){if(!zx(q))return Promise.resolve(!1);return new Promise((X)=>{let Q=Yx({path:q}),P=(b)=>{Q.destroy(),X(b)};Q.setTimeout(x,()=>P(!1)),Q.once("error",()=>P(!1)),Q.once("close",()=>P(!1)),Q.once("connect",()=>P(!0))})}async function vq(q,x){if(!x)return null;let X=r8(q);if(Buffer.byteLength(X)>Ex||/["'\\\s]/.test(X))return null;try{if(await u8(X))return X;let Q=Mx(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:${B8(q,"pulseaudio.log")}`,"-n",`--load=module-native-protocol-unix socket="${X}" auth-anonymous=1 auth-cookie-enabled=0`,`--load=module-null-sink sink_name=${pq} rate=${P8.sampleRate} channels=${P8.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:B8(q,"runtime"),PULSE_STATE_PATH:B8(q,"state")}}),P=!1;Q.once("error",()=>{P=!0}),Q.once("exit",()=>{P=!0}),Q.unref();let b=Date.now()+_x;while(Date.now()<b){if(await u8(X))return X;if(P)return await u8(X)?X:null;await new Promise((J)=>setTimeout(J,50))}if(!P)Q.kill("SIGKILL");return null}catch{return null}}function uq(){let{sampleRate:q,channels:x}=P8;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",`${pq}.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 Ox=[79,103,103,83],Hx=Buffer.from("OpusHead"),fx=Buffer.from("OpusTags"),Iq=(q,x)=>q.byteLength>=x.byteLength&&x.every((X,Q)=>q[Q]===X);class c8 extends Error{constructor(q){super(q);this.name="OggProtocolError"}}class m8{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 X=[],Q=0;while(x.byteLength-Q>=27){if(Ox.some((R,T)=>x[Q+T]!==R)||x[Q+4]!==0)throw new c8("invalid_page");let P=(x[Q+5]&1)!==0,b=x[Q+26];if(x.byteLength-Q<27+b)break;let J=x.subarray(Q+27,Q+27+b),L=J.reduce((R,T)=>R+T,0),Z=27+b+L;if(x.byteLength-Q<Z)break;if(!P&&this.partialBytes>0)this.resetPartial();let W=P&&this.partialBytes===0,U=Q+27+b,C=U;for(let R of J){if(U+=R,R===255)continue;if(this.appendPartial(x.subarray(C,U),W),C=U,!W){let T=this.takePartial();if(T.byteLength>0&&!Iq(T,Hx)&&!Iq(T,fx))X.push(T)}W=!1,this.resetPartial()}if(C<U)this.appendPartial(x.subarray(C,U),W);Q+=Z}return this.buffer=x.slice(Q),X}appendPartial(q,x){if(x||q.byteLength===0)return;if(this.partialBytes+=q.byteLength,this.partialBytes>$x)throw new c8("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 X of this.partial)q.set(X,x),x+=X.byteLength;return q}resetPartial(){this.partial=[],this.partialBytes=0}}import{spawn as gx}from"child_process";var cq=1048576,hx=String.raw`
|
|
131
|
+
import gi, json, os, sys
|
|
132
|
+
gi.require_version("Gtk", "3.0")
|
|
133
|
+
from gi.repository import Gtk, Gdk, GLib
|
|
134
|
+
if not Gtk.init_check()[0]:
|
|
135
|
+
sys.exit(1)
|
|
136
|
+
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
|
137
|
+
pending = b""
|
|
138
|
+
generation = 0
|
|
139
|
+
def send(value):
|
|
140
|
+
print(json.dumps(value, ensure_ascii=True), flush=True)
|
|
141
|
+
def changed(clipboard, event):
|
|
142
|
+
global generation
|
|
143
|
+
generation += 1
|
|
144
|
+
current = generation
|
|
145
|
+
def received(clipboard, text, unused):
|
|
146
|
+
if current == generation and text is not None and len(text.encode("utf-8")) <= ${p}:
|
|
147
|
+
send({"text": text})
|
|
148
|
+
clipboard.request_text(received, None)
|
|
149
|
+
# No request_text on startup: never share the pre-existing clipboard.
|
|
150
|
+
clipboard.connect("owner-change", changed)
|
|
151
|
+
def input_ready(fd, condition):
|
|
152
|
+
global pending
|
|
153
|
+
chunk = os.read(fd, 65536)
|
|
154
|
+
if not chunk:
|
|
155
|
+
Gtk.main_quit()
|
|
156
|
+
return False
|
|
157
|
+
pending += chunk
|
|
158
|
+
while b"\n" in pending:
|
|
159
|
+
line, pending = pending.split(b"\n", 1)
|
|
160
|
+
text = json.loads(line)
|
|
161
|
+
if not isinstance(text, str) or len(text.encode("utf-8")) > ${p} or "\x00" in text:
|
|
162
|
+
sys.exit(1)
|
|
163
|
+
clipboard.set_text(text, -1)
|
|
164
|
+
send("ack")
|
|
165
|
+
if len(pending) > ${p*6+2}:
|
|
166
|
+
sys.exit(1)
|
|
167
|
+
return True
|
|
168
|
+
GLib.io_add_watch(0, GLib.IO_IN | GLib.IO_HUP, input_ready)
|
|
169
|
+
send("ready")
|
|
170
|
+
Gtk.main()
|
|
171
|
+
`;function rq(q,x){let X=gx("/usr/bin/python3",["-I","-u","-c",hx],{env:{DISPLAY:q.display,XAUTHORITY:q.xauthority},stdio:["pipe","pipe","ignore"]}),Q=!1,P=!0,b="",J=0,L=[],Z=setTimeout(()=>U(),5000),W=()=>{Q=!0,clearTimeout(Z),L.length=0,X.kill("SIGKILL")},U=()=>{if(Q)return;W(),x.end({error:new S("display_unavailable","Reason could not start this Linux desktop's UTF-8 clipboard.")})},C=(R,T=32)=>{if(Q)return;if(!P){R();return}if(J+=T,J>cq)W(),x.end({reason:"input_backpressure"});else L.push({apply:R,bytes:T})};return X.stdout.on("data",(R)=>{if(Q)return;b+=R.toString("ascii");for(let T=b.indexOf(`
|
|
172
|
+
`);T>=0;T=b.indexOf(`
|
|
173
|
+
`)){let Y=b.slice(0,T);b=b.slice(T+1);let A;try{A=JSON.parse(Y)}catch{U();return}if(A==="ready"||A==="ack"){clearTimeout(Z),P=!1;while(!P&&!Q&&L.length){let N=L.shift();J-=N.bytes,N.apply()}}else if(A&&typeof A==="object"&&"text"in A&&typeof A.text==="string"&&Buffer.byteLength(A.text)<=p)x.clipboard(A.text);else{U();return}if(Q)return}if(b.length>p*6+32)U()}),X.stdin.on("error",U),X.once("error",U),X.once("exit",U),{apply:C,write(R){if(Buffer.byteLength(R)>p||R.includes("\x00")){U();return}let T=`${JSON.stringify(R)}
|
|
174
|
+
`;C(()=>{if(P=!0,Z=setTimeout(()=>U(),5000),X.stdin.write(T),X.stdin.writableLength>cq)W(),x.end({reason:"input_backpressure"})},Buffer.byteLength(T))},close:W}}var t={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}},vx="avc1.4D002A",mq={width:1920,height:1080},ux=262144,cx=0.2,rx=250,mx=1e4,lx=1024,l8=1e4,dx=500,sx=60,ax=1e4,ix=1000,lq=1048576,X0={kind:"mac_screen",sound:null},nx,dq=()=>nx??=m()?.ffmpeg??null,i8=(q,x,X)=>a8(q,x,{env:X,stdio:["ignore","pipe","ignore"]}),ox,n8=()=>ox??=hq(m()),sq=(q,x,X)=>{let[Q,...P]=[...n8(),q];return i8(Q,[...P,...x],X)},aq=()=>L0?.videotoolbox?"h264_videotoolbox":"libx264",tx=()=>Math.round(performance.now()*1000),d8=new Set,iq=!1;function Q0(q){if(d8.add(q),q.once("exit",()=>d8.delete(q)),iq)return;iq=!0,process.once("exit",()=>{for(let x of d8)try{x.kill("SIGKILL")}catch{}})}function P0(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{}},dx);q.once("exit",()=>clearTimeout(x))}function ex(q,x,X){return{args:["-f","x11grab","-draw_mouse","1","-framerate",String(q),"-video_size",`${x.width}x${x.height}`,"-i",X],size:x}}function q1(q){return{args:["-f","avfoundation","-capture_cursor","1","-pixel_format","nv12","-framerate",String(q),"-i","Capture screen 0:none"],size:null}}function x1(q){return{args:["-probesize","32","-analyzeduration","0","-f","image2pipe","-c:v","mjpeg","-framerate",String(q),"-i","pipe:0"],size:null}}var b0=1700000;function J0(q){return Math.min(1,Math.round(Math.sqrt(b0/(q.width*q.height))*100)/100)}function X1(q,x,X){let Q=a8(X.axe,["stream-video","--udid",X.udid,"--format","ffmpeg","--fps","30","--quality","85","--scale",String(Math.min(0.99,J0(X.size)))],{stdio:["ignore","pipe","ignore"]}),P=a8(q,x,{env:{},stdio:["pipe","pipe","ignore"]});Q.stdout.pipe(P.stdin),P.stdin.on("error",()=>{});let b=()=>{if(Q.exitCode===null&&Q.signalCode===null)Q.kill("SIGTERM")};return P.once("exit",b),P.once("error",b),Q.once("exit",()=>{if(P.exitCode===null&&P.signalCode===null)P.kill("SIGTERM")}),Q.once("error",()=>{if(P.exitCode===null&&P.signalCode===null)P.kill("SIGTERM")}),P}function Q1(q){let x=Math.min(1,mq.width/q.width,mq.height/q.height);return{width:Math.round(q.width*x),height:Math.round(q.height*x)}}function s8(q,x,X,Q="libx264"){let P=t[q],b=(C)=>Math.max(2,Math.floor(C/2)*2),J={width:b(X.width*P.scale),height:b(X.height*P.scale)},L=J.width!==x.size?.width||J.height!==x.size.height,Z=Math.max(1,Math.round(P.kbps*2/P.fps)),W=["-g",String(P.fps*sx)],U=Q==="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",...W,"-b:v",`${P.kbps}k`,"-maxrate",`${P.kbps}k`,"-bufsize",`${Z}k`,"-bsf:v","h264_metadata=aud=insert"]:["-c:v","libx264","-preset",P.x264Preset,"-tune","zerolatency","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","yuv420p",...P.threads?["-threads",String(P.threads)]:[],"-x264-params","aud=1:repeat-headers=1",...W,"-crf",String(P.crf),"-maxrate",`${P.kbps}k`,"-bufsize",`${Z}k`];return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer",...x.args,"-an",...L?["-vf",`scale=${J.width}:${J.height}:flags=fast_bilinear`]:[],...U,"-flush_packets","1","-f","h264","pipe:1"]}class N0{buffer=new Uint8Array(0);scanned=0;key=!1;micros=0;push(q,x){if(this.buffer.byteLength===0)this.micros=x;let X=new Uint8Array(this.buffer.byteLength+q.byteLength);X.set(this.buffer),X.set(q,this.buffer.byteLength),this.buffer=X;let Q=[],P=this.scanned;while(P+3<this.buffer.byteLength){if(this.buffer[P]!==0||this.buffer[P+1]!==0||this.buffer[P+2]!==1){P++;continue}let b=this.buffer[P+3]&31,J=P>0&&this.buffer[P-1]===0?P-1:P;if(b===9&&J>0)Q.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,P-=J;if(b===5)this.key=!0;P+=3}return this.scanned=P,Q}}function P1(q,x){let X=px({path:q}),Q=Buffer.alloc(0),P="version",b=0,J=!1,L=[],Z=0,W=!1,U=(N)=>{if(W)return;W=!0,X.destroy(),x.end(N)},C=()=>U({reason:"display_protocol"}),R=(N)=>{if(W)return;if(!J){if(Z+=N.byteLength,Z>lq)U({reason:"input_backpressure"});else L.push(N);return}if(X.write(N),X.writableLength>lq)U({reason:"input_backpressure"})},T=(N)=>{Q=Q.subarray(N)},Y=()=>{switch(P){case"version":{if(Q.byteLength<12)return!1;let N=/^RFB (\d{3})\.(\d{3})\n$/.exec(Q.subarray(0,12).toString("latin1"));if(!N||Number(N[1])*1000+Number(N[2])<3007)return C(),!1;return T(12),X.write(`RFB 003.007
|
|
175
|
+
`),P="security",!0}case"security":{if(Q.byteLength<1)return!1;let N=Q[0];if(N===0)return C(),!1;if(Q.byteLength<1+N)return!1;if(!Q.subarray(1,1+N).includes(1))return C(),!1;return T(1+N),X.write(Buffer.from([1,1])),P="init",!0}case"init":{if(Q.byteLength<24)return!1;let N=Q.readUInt32BE(20);if(N>65536)return C(),!1;if(Q.byteLength<24+N)return!1;let y={width:Q.readUInt16BE(0),height:Q.readUInt16BE(2)};if(T(24+N),y.width===0||y.height===0)return C(),!1;P="messages",J=!0;for(let F of L)X.write(F);return L=[],Z=0,x.ready(y),!W}case"skip":{let N=Math.min(b,Q.byteLength);if(T(N),b-=N,b>0)return!1;return P="messages",!0}case"messages":{if(Q.byteLength<1)return!1;switch(Q[0]){case 1:{if(Q.byteLength<6)return!1;let N=6+Q.readUInt16BE(4)*6;if(Q.byteLength<N)return!1;return T(N),!0}case 2:return T(1),!0;case 3:{if(Q.byteLength<8)return!1;let N=Q.readUInt32BE(4);if(N>p/2)return T(8),P="skip",b=N,!0;if(Q.byteLength<8+N)return!1;let y=Q.subarray(8,8+N).toString("latin1");return T(8+N),x.clipboard(y),!W}default:return C(),!1}}}},A=!1;return X.once("connect",()=>{A=!0}),X.on("data",(N)=>{if(W)return;Q=Q.byteLength?Buffer.concat([Q,N]):N;while(!W&&Y());}),X.once("error",()=>{if(!A)U({error:new S("display_unavailable","Reason could not reach this machine's desktop server.")})}),X.once("close",()=>U({reason:"display_closed"})),{pointer(N,y,F){let K=Buffer.alloc(6);K.writeUInt8(5,0),K.writeUInt8(F&255,1),K.writeUInt16BE(N,2),K.writeUInt16BE(y,4),R(K)},key(N,y){let F=Buffer.alloc(8);F.writeUInt8(4,0),F.writeUInt8(N?1:0,1),F.writeUInt32BE(y>>>0,4),R(F)},clipboard(N){if(Array.from(N).some((K)=>K.codePointAt(0)>255)){U({reason:"clipboard_unicode_unsupported"});return}let y=Buffer.from(N,"latin1"),F=Buffer.alloc(8);F.writeUInt8(6,0),F.writeUInt32BE(y.byteLength,4),R(Buffer.concat([F,y]))},close(){W=!0,X.destroy()}}}class o8{run=null;viewers=new Set;get running(){return this.run!==null}start(q,x,X,Q){this.viewers.add(q),this.stop();let P;try{P=X()}catch{this.fail();return}Q0(P);let b={child:P,splitter:new N0};this.run=b;for(let L of[...this.viewers])L.started(x);P.stdout?.on("data",(L)=>{if(this.run!==b)return;for(let Z of b.splitter.push(L,Q()))for(let W of[...this.viewers])W.unit(Z)});let J=()=>{if(this.run!==b)return;this.run=null,this.fail()};P.once("exit",J),P.once("error",J)}leave(q){if(!this.viewers.delete(q))return;if(this.viewers.size===0)this.stop()}stop(){if(!this.run)return;P0(this.run.child),this.run=null}fail(){for(let q of[...this.viewers])q.failed()}}var nq=new WeakMap;function b1(q){let x=nq.get(q);if(!x)nq.set(q,x=new o8);return x}function W0(q,x,X={}){let Q=X.micros??tx,P=new eq,b=x.request.preset,J=null,L=null,Z=null,W=!1,U=null,C=!1,R=!1,T=null,Y=0,A=0,N=!1,y=null,F=null,K=0,$=null,_=[],E=0,V=[],g=new Uint32Array(l8+1),v=0,w=null,O=0,k=0,I=0,bq=0,Jq=0,b8=null,V8=0,d={frames:0,bytes:0,since:Q()},s=[],q8=0,F8,w8=!1,z0=Q(),H={},a=()=>Math.round((Q()-z0)/1000),Nq=X.control??kq,K8=null,M8=null,h=(D)=>{let j=C8(D);return q.send(j),bq+=j.byteLength,j.byteLength},J8=(D)=>{if(q.done)return;if(q.open)h({type:"error",code:D});q.end({reason:D})},N8=()=>Math.max(ux,t[b].kbps*1000/8*cx),W8=()=>Q()/1000,Y0=()=>{while(V.length>1&&V[0].atMs<W8()-mx)V.shift();return V[0]?.rttMs??null},Wq=(D)=>{let j=Y0();if(j===null||_.length===0)return!1;let B=(j+rx)*D;return W8()-_[0].sentMs>B||E>B/1000*t[b].kbps*1000/8},_0=(D)=>{if(K===0)return;let j=Math.min(D,K-1);if($!==null&&j<=$)return;$=j;let B=W8();while(_.length&&_[0].seq<=j){let M=_.shift();if(E-=M.bytes,M.seq!==j)continue;let z=Math.max(0,B-M.sentMs);while(V.length&&V.at(-1).rttMs>=z)V.pop();V.push({atMs:B,rttMs:z}),g[Math.min(l8,Math.round(z))]++,v++,w=Math.min(w??z,z)}},E0=()=>{let D=0;for(let j=0;j<=l8;j++)if(D+=g[j],D*2>=v)return j;return 0},$0=()=>q.bufferedAmount<=N8()/2&&!Wq(0.5),Lq=()=>{w8=!0,s=[],q8=0,U?.leave(z8),U=null},jq=(D)=>{if(q.done)return;if(D.key)H.first_key_ms??=a();if(!W){if(!U||s.length===0&&!D.key)return;if(s.push(D),q8+=D.data.byteLength,q8>N8())Lq();return}if(N){k++;return}if(q.bufferedAmount>N8()||Wq(1)){N=!0,k++,y=setInterval(()=>{if(q.done||!$0())return;if(y)clearInterval(y);y=null,N=!1,_8()},X.drainPollMs??25);return}if(!C){if(!D.key){k++;return}if(h({type:"hello",width:L.width,height:L.height,fps:t[b].fps,preset:b,codec:vx}),C=!0,H.first_frame_ms??=a(),!R&&J?.sound)h({type:"audioHello",...P8}),R=!0}let j=h({type:"frame",key:D.key,seq:K,captureMicros:D.micros,data:D.data});if(_.push({seq:K,sentMs:W8(),bytes:j}),E+=j,_.length>lx)E-=_.shift().bytes;K++,O++,b8??=D.micros,V8=D.micros,d.frames++,d.bytes+=j},z8={started(D){b=D,C=!1,s=[],q8=0},unit:jq,failed:()=>J8("encoder_failed")},Y8=()=>{let D=(X.ffmpeg??dq)();if(!J||!L){J8("encoder_failed");return}let[j,B]=[J,L],M="kind"in j&&j.kind==="simulator"?j.stream:null;if(!D&&!M){J8("encoder_failed");return}if(U??="kind"in j&&j.kind==="mac_screen"?b1(X.spawn??sq):new o8,H.encoder_ms===void 0)H.encoder_ms=a(),H.encoder_shared=U.running;U.start(z8,b,()=>{let z=t[b].fps;if(M)return M(z,t[b].kbps,b0);if("kind"in j&&j.kind==="simulator"){let u=Math.min(0.99,J0(j.size)),x8={width:j.size.width*u,height:j.size.height*u};return X1(D,s8(b,x1(Math.min(z,30)),x8,(X.macEncoder??aq)()),j)}return"kind"in j?(X.spawn??sq)(D,s8(b,q1(z),Q1(B),(X.macEncoder??aq)()),{}):(X.spawn??i8)(D,s8(b,ex(z,B,j.display),B),{DISPLAY:j.display,XAUTHORITY:j.xauthority})},Q)},L8=()=>{if(!T)return;P0(T.child),T=null},O0=()=>{let D=(X.ffmpeg??dq)();if(T||q.done||!R||!J?.sound||!D)return;let j;try{j=(X.spawn??i8)(D,uq(),{PULSE_SERVER:R8(J.sound)})}catch{return}Q0(j);let B={child:j,reader:new m8};T=B,j.stdout?.on("data",(z)=>{if(T!==B||q.done)return;let u;try{u=B.reader.push(z)}catch{L8();return}let x8=Q();for(let H0 of u){if(q.bufferedAmount>N8()){A++;continue}h({type:"audio",captureMicros:x8,data:H0}),Y++}});let M=()=>{if(T===B)L8()};j.once("exit",M),j.once("error",M)},_8=()=>{if(!U||q.done)return;I++,Y8()},Uq=()=>{if(q.done||!L)return;if(!W){if(U||w8)return;Y8(),F8=setTimeout(()=>{if(!W)Lq()},ax);return}if(clearTimeout(F8),H.encoder_early===void 0){if(H.encoder_early=U!==null,w8)H.hold_lapsed=!0}if(!U)Y8();let D=s;s=[],q8=0;for(let j of D)jq(j);F??=setInterval(()=>{let j=Q(),B=Math.max(0.001,(j-d.since)/1e6);h({type:"stats",stats:{fps:Math.round(d.frames/B*10)/10,kbps:Math.round(d.bytes*8/1000/B),dropped:k,restarts:I,queued_bytes:q.bufferedAmount}}),d={frames:0,bytes:0,since:j}},ix)};x.desktop.then((D)=>{if(q.done)return;J=D;let j={ready(B){L=B,H.desktop_ms??=a(),Uq()},clipboard(B){if(q.open&&Buffer.byteLength(B)<=p)h({type:"serverClipboard",text:B})},end(B){if("reason"in B&&q.open)h({type:"error",code:B.reason});q.end(B)}};if("kind"in D&&D.kind==="simulator")Z=D.input,j.ready(D.points);else if("kind"in D)Z=(X.macInput??((B)=>x0(B,n8())))(j);else{let B=(X.linuxClipboard??rq)(D,j),M=P1(D.rfbSocket,{...j,clipboard:(z)=>{if(!B)j.clipboard(z)}});Z=B?{pointer:(z,u,x8)=>B.apply(()=>M.pointer(z,u,x8)),key:(z,u)=>B.apply(()=>M.key(z,u)),clipboard:(z)=>B.write(z),close(){B.close(),M.close()}}:M}Dq()},(D)=>q.end({error:D}));function Dq(){if(M8||!x.viewerSameNetwork||!W||q.done||!J||!("kind"in J)||J.kind!=="mac_screen")return;M8=(X.macWindows??q0)((D)=>{if(q.open)h({type:"windows",bounds:D})})}let Tq={viewer:x.viewer??null,notify(D){if(q.open)h({type:"control",control:D})}},E8=(D)=>{if(!Z)return;if(!J||!("kind"in J)||J.kind!=="simulator")Nq.claim(Tq);D(Z)};return{opened(){H.relay_ms??=a()},received(D){Jq+=D.byteLength;let j;try{j=P.push(D)}catch{J8("viewer_protocol");return}for(let B of j){if(q.done)return;switch(B.type){case"ping":h({type:"pong",token:B.token});break;case"pointer":E8((M)=>M.pointer(B.x,B.y,B.buttons));break;case"key":E8((M)=>M.key(B.down,B.keysym));break;case"clientClipboard":E8((M)=>M.clipboard(B.text));break;case"config":if(B.preset!==b)b=B.preset,_8();break;case"keyframeRequest":if(C&&!N)_8();break;case"ack":_0(B.seq);break;case"audioEnable":if(B.on)O0();else L8();break;default:break}}if(!W&&!q.done){if(W=!0,H.viewer_ms=a(),x.viewer)K8=Nq.join(Tq);Uq(),Dq()}},close(){if(K8?.(),K8=null,M8?.close(),y)clearInterval(y);if(F)clearInterval(F);clearTimeout(F8),U?.leave(z8),L8(),Z?.close()},summary:()=>({output_bytes:bq,input_bytes:Jq,video:{preset:b,frames:O,dropped:k,restarts:I,avg_fps:b8!==null&&V8>b8?Math.round((O-1)/((V8-b8)/1e6)*10)/10:0,min_rtt_ms:Math.round(w??0),p50_rtt_ms:v?E0():0,audio_packets:Y,audio_dropped:A,connect:H}})}}var oq=null,L0=null,J1=null;function N1(){let q=m();return q?.features.display?q.ffmpeg:null}function j0(q){return oq??=new Promise((x)=>{kx(q,["-hide_banner","-encoders"],{env:{},timeout:5000,killSignal:"SIGKILL",maxBuffer:1048576,encoding:"utf8"},(X,Q)=>{let P=(b)=>!X&&new RegExp(`^\\s*V\\S*\\s+${b}\\s`,"m").test(Q);x(L0={x264:P("libx264"),videotoolbox:P("h264_videotoolbox")})})}),oq}var tq=null;function Q9(){return tq??=(async()=>{let q=[m()?.ffmpeg,"/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg"].find((X)=>Boolean(X&&Ix(X)));if(!q)return null;let x=await j0(q);return x.videotoolbox||x.x264?q:null})(),tq}function U0(q=process.platform,x={}){if(q!=="linux"&&q!=="darwin")return Promise.resolve(!1);let X=(x.ffmpeg??N1)();if(!X)return Promise.resolve(!1);let Q=(x.encoders??j0)(X);if(q==="linux")return Q.then((b)=>b.x264);let P=x.macScreen?x.macScreen():J1??=f8(n8());return Promise.all([Q,P]).then(([b,J])=>(b.x264||b.videotoolbox)&&J?.screen===!0&&J.accessibility)}import{existsSync as t8,realpathSync as y0,statSync as W1}from"fs";import{platform as L1}from"os";import{isAbsolute as S0,sep as j1}from"path";var U1=43200000,D0=R0,D1=4,T1=/^[A-Za-z0-9._:-]{1,160}$/,B1=1000;function Z0(q){return Boolean(q)&&typeof q==="object"&&!Array.isArray(q)}function S8(q,x){if(typeof q!=="number"||!Number.isFinite(q)||q<=0)return x;return Math.min(B1,Math.max(1,Math.floor(q)))}function R1(q,x=Date.now()){let X=["relay_url","session_id","expires_at"],Q=new Set([...X,"cols","rows","cwd","workspace"]);if(!Z0(q)||X.some((U)=>!(U in q))||Object.keys(q).some((U)=>!Q.has(U)))throw new S("invalid_pty_request","Reason terminal request is malformed.");let{relay_url:P,session_id:b,expires_at:J}=q;if(typeof P!=="string")throw new S("invalid_pty_request","Reason terminal relay URL is missing.");let L;try{L=new URL(P)}catch{throw new S("invalid_pty_request","Reason terminal relay URL is invalid.")}if(L.protocol!=="wss:"&&L.protocol!=="ws:"||L.username||L.password)throw new S("invalid_pty_request","Reason terminal relay URL is invalid.");if(typeof b!=="string"||!T1.test(b))throw new S("invalid_pty_request","Reason terminal session identity is invalid.");let Z=typeof J==="string"?Date.parse(J):Number.NaN;if(!Number.isFinite(Z)||Z<=x)throw new S("invalid_pty_request","Reason terminal session has already expired.");if(q.cwd!==void 0&&typeof q.cwd!=="string")throw new S("invalid_pty_request","Reason terminal working directory is invalid.");let W=q.workspace===void 0?void 0:B0(q.workspace);if(W===null||W&&q.cwd!==void 0)throw new S("invalid_pty_request","Reason terminal workspace is invalid.");return{relay_url:P,session_id:b,expires_at:new Date(Math.min(Z,x+U1)).toISOString(),cols:S8(q.cols,80),rows:S8(q.rows,24),...q.cwd===void 0?{}:{cwd:q.cwd},...W?{workspace:W}:{}}}function C1(q,x){return x===q||x.startsWith(q+j1)}function T0(q,x){if(x===void 0)return q;if(!S0(x))throw new S("pty_cwd_invalid","Reason terminal working directory must be absolute.");let X;try{X=y0(x)}catch{throw new S("pty_cwd_invalid","Reason terminal working directory does not exist.")}if(!C1(q,X))throw new S("pty_cwd_outside_root","Reason terminal working directory escapes the granted root.");if(!W1(X).isDirectory())throw new S("pty_cwd_invalid","Reason terminal working directory is not a directory.");return X}function y1(q=process.env){let x=q.SHELL;if(x&&S0(x)&&t8(x))return x;for(let X of L1()==="darwin"?["/bin/zsh","/bin/bash","/bin/sh"]:["/bin/bash","/bin/sh"])if(t8(X))return X;return"/bin/sh"}function S1(){let q=globalThis.Bun;if(!q)throw new S("pty_unavailable","Reason terminals require the Bun runtime.");return q.spawn}function T9(){return typeof globalThis.Bun<"u"}var Z1=(q)=>{let x=S1()({cmd:[q.shell,"-i","-l"],cwd:q.cwd,env:{...q.environment,TERM:"xterm-256color"},terminal:{cols:q.cols,rows:q.rows,data:(Q,P)=>{q.onData(P)}}}),X=x.terminal;if(!X){try{x.kill()}catch{}throw new S("pty_unavailable","Reason could not allocate a pseudo-terminal.")}return{write:(Q)=>X.write(Q),resize:(Q,P)=>X.resize(Q,P),kill:()=>{try{x.kill()}catch{}},exited:x.exited.then((Q)=>typeof Q==="number"?Q:null,()=>null)}},e8=(q,x)=>{return x===void 0?new WebSocket(q):new WebSocket(q,{proxy:x})},y8=new Set;function G1(q){if(y8.size>=D1||y8.has(q))return null;y8.add(q);let x=!1;return()=>{if(x)return;x=!0,y8.delete(q)}}async function B9(q,x={}){let X=x.now??Date.now,Q=R1(q.payload,X()),P=G1(q.operationId);if(!P)throw new S("pty_slot_busy","This Reason Device already runs the maximum number of terminals.");let b=X(),J,L,Z;try{let W=Q.workspace?C0(q.root,Q.workspace):void 0;J=W?T0(t8(W.boundary)?y0(W.boundary):W.boundary,W.path):T0(q.root,Q.cwd),L=x.environment??process.env,Z=x.shellPath??y1(L)}catch(W){throw P(),W}return await new Promise((W,U)=>{let C=null,R=null,T=!1,Y=!1,A=!1,N=null,y=0,F=0,K=[],$=0,_=null,E=(w)=>{if(A)return;if(A=!0,_)clearTimeout(_);q.signal.removeEventListener("abort",V);try{C?.kill()}catch{}try{R?.close(1000,"pty_session_over")}catch{}if(P(),w.kind==="rejected"){U(w.error);return}let O={reason:w.reason,exit_code:N,output_bytes:y,input_bytes:F,duration_ms:Math.max(0,X()-b)};q.emitEvent("pty.stopped",{...O}).catch(()=>{return}),W({...O})},V=()=>{let w=q.signal.reason;E({kind:"rejected",error:w instanceof S?w:new S("cancelled","Reason closed the terminal session.")})};if(q.signal.aborted){V();return}q.signal.addEventListener("abort",V,{once:!0}),_=setTimeout(()=>E({kind:"resolved",reason:"session_expired"}),Math.max(1,Date.parse(Q.expires_at)-X()));let g=(w)=>{if(y+=w.byteLength,!T||!R){if(K.push(w),$+=w.byteLength,$>D0)E({kind:"resolved",reason:"output_backpressure"});return}try{R.send(w)}catch{E({kind:"resolved",reason:"relay_closed"});return}if(R.bufferedAmount>D0)E({kind:"resolved",reason:"output_backpressure"})};try{C=(x.spawnPty??Z1)({shell:Z,args:["-i","-l"],cwd:J,cols:Q.cols,rows:Q.rows,environment:L,onData:(w)=>{if(!A)g(w)}})}catch(w){E({kind:"rejected",error:w instanceof S?w:new S("pty_spawn_failed","Reason could not start the terminal shell.")});return}C.exited.then((w)=>{if(A)return;if(N=w,T&&R)try{R.send(JSON.stringify({t:"exit",code:w}))}catch{}E({kind:"resolved",reason:"shell_exited"})});let v=(x.loadProxy??Z8)()?.url;try{R=(x.connect??e8)(Q.relay_url,v)}catch{E({kind:"rejected",error:new S("pty_relay_unavailable","Reason could not reach the terminal relay.")});return}R.binaryType="arraybuffer",R.onopen=()=>{if(A||!R)return;T=!0;try{R.send(JSON.stringify({t:"open",cols:Q.cols,rows:Q.rows}));for(let w of K.splice(0))R.send(w);$=0}catch{E({kind:"resolved",reason:"relay_closed"});return}Y=!0,q.emitEvent("pty.ready",{session_id:Q.session_id,cols:Q.cols,rows:Q.rows}).catch(()=>{return})},R.onmessage=(w)=>{if(A||!C)return;let O=w.data;if(typeof O==="string"){let I;try{I=JSON.parse(O)}catch{return}if(!Z0(I))return;if(I.t==="resize"){try{C.resize(S8(I.cols,Q.cols),S8(I.rows,Q.rows))}catch{}return}if(I.t==="close")E({kind:"resolved",reason:"client_closed"});return}let k=O instanceof ArrayBuffer?new Uint8Array(O):ArrayBuffer.isView(O)?new Uint8Array(O.buffer,O.byteOffset,O.byteLength):null;if(!k||k.byteLength===0)return;F+=k.byteLength;try{C.write(k)}catch{}},R.onclose=()=>{if(A)return;if(!Y){E({kind:"rejected",error:new S("pty_relay_unavailable","Reason could not reach the terminal relay.")});return}E({kind:"resolved",reason:"relay_closed"})},R.onerror=()=>{if(A||Y)return;E({kind:"rejected",error:new S("pty_relay_unavailable","Reason could not reach the terminal relay.")})}})}var E1=43200000,G8=":99",$1=60000,A8=15000,Xq={width:1280,height:800},O1=/^[A-Za-z0-9._:-]{1,160}$/;function H1(q){return Boolean(q)&&typeof q==="object"&&!Array.isArray(q)}var f1=["video","viewer","viewer_same_network","viewer_network"];function g1(q,x=Date.now()){let X=["relay_url","session_id","expires_at"];if(!H1(q)||X.some((L)=>!(L in q))||Object.keys(q).some((L)=>!X.includes(L)&&!f1.includes(L)))throw new S("invalid_display_request","Reason desktop request is malformed.");let Q="video"in q?F0(q.video):void 0,P="viewer"in q?V0(q.viewer):null;if(Q===null)throw new S("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 S("invalid_display_request","Reason desktop relay URL is invalid.");if(typeof q.session_id!=="string"||!O1.test(q.session_id))throw new S("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 S("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+E1)).toISOString(),...Q?{video:Q}:{},...P?{viewer:P}:{},...Q&&q.viewer_same_network===!0?{viewer_same_network:!0}:{}}}function h1(q=process.platform){return(q==="linux"||q==="darwin")&&m()?.features.display===!0}async function $9(){if(process.platform!=="darwin")return h1();return await U0()}function Qq(q){M1(q,{recursive:!0,mode:448});let x=K1(q);if(!x.isDirectory()||x.isSymbolicLink()||process.getuid&&x.uid!==process.getuid())throw new S("display_unavailable","Reason desktop state directory is not private.");F1(q,448)}function k1(q,x){let X=(P)=>{let b=Buffer.alloc(2);return b.writeUInt16BE(P.length),Buffer.concat([b,P])},Q=Buffer.from([255,255]);return Buffer.concat([Q,X(Buffer.alloc(0)),X(Buffer.from(q)),X(Buffer.from("MIT-MAGIC-COOKIE-1")),X(x)])}function e(q,x,X=2000){return new Promise((Q)=>{let P=_1(q),b="",J=(L)=>{P.destroy(),Q(L)};P.setTimeout(X,()=>J(!1)),P.once("error",()=>J(!1)),P.once("close",()=>J(!1)),P.once("connect",()=>{if(!x)J(!0)}),P.on("data",(L)=>{if(b+=L.toString("latin1"),b.length>=4)J(b.startsWith("RFB "))})})}async function K0(q,x){let X=Date.now()+x;while(Date.now()<X){if(await q())return!0;await new Promise((Q)=>setTimeout(Q,100))}return!1}function Pq(q,x,X){return new Promise((Q)=>{let P=w0(q,x,{detached:!0,stdio:"ignore",env:X});P.once("error",()=>Q(-1)),P.once("exit",(b)=>Q(b)),P.unref(),setTimeout(()=>Q(null),A8).unref()})}var qq=null;function I1(q=o()){return qq??=p1(q).finally(()=>{qq=null}),qq}async function p1(q){let x=m({home:q});if(!x?.xvfb||!x.x11vnc||!x.openbox)throw new S("display_unavailable","Run `reason desktop install` on this machine to enable its desktop.");A0({root:x.root,automation:x.automation,extensionDir:x.extensionDir});let X=f(x.root,"display");Qq(X);let Q=await u1(q,X,x.x11vnc);if(Q)return Q;let P={display:G8,xauthority:f(X,"Xauthority"),rfbSocket:f(X,"rfb.sock")},b=f(X,"pulse"),J=(async()=>{try{Qq(b)}catch{return null}return await vq(b,x.pulseaudio)})(),L={HOME:q,PATH:"/usr/local/bin:/usr/bin:/bin",DISPLAY:P.display,XAUTHORITY:P.xauthority};if(x.pulseaudio)L.PULSE_SERVER=R8(r8(b));let Z=async()=>({...P,sound:await J});if(await e({path:P.rfbSocket},!0))return await Z();if(!w1(P.xauthority))xq(P.xauthority,k1(G8.slice(1),V1(16)),{mode:384,flag:"wx"});let W=c1(f(X,"theme"),P.display),U={path:`/tmp/.X11-unix/X${G8.slice(1)}`};if(!await e(U,!1)){if(Pq(x.xvfb,[P.display,"-screen","0",`${Xq.width}x${Xq.height}x24`,"-nolisten","tcp","-auth",P.xauthority],L),!await K0(()=>e(U,!1),A8))throw new S("display_unavailable","Reason could not start the virtual display.");Pq(x.openbox,["--config-file",W.openboxConfig],L)}if(await r1(W,L),!await M0(x.x11vnc,P,X,"x11vnc.log",L))throw new S("display_unavailable","Reason could not start the desktop server.");return await Z()}async function M0(q,x,X,Q,P){if(await e({path:x.rfbSocket},!0))return!0;Y1(x.rfbSocket,{force:!0});let b=await Pq(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",f(X,Q)],P);if(b!==null&&b!==0)return!1;return await K0(()=>e({path:x.rfbSocket},!0),A8)}async function v1(){let q=["DISPLAY","XAUTHORITY","WAYLAND_DISPLAY","XDG_SESSION_TYPE"],x=(X)=>Object.fromEntries(q.flatMap((Q)=>X[Q]?[[Q,X[Q]]]:[]));if(process.env.DISPLAY)return x(process.env);try{let X=await new Promise((Q,P)=>A1("systemctl",["--user","show-environment"],{encoding:"utf8",timeout:2000},(b,J)=>b?P(b):Q(J)));return x(Object.fromEntries(X.split(`
|
|
176
|
+
`).flatMap((Q)=>{let P=Q.indexOf("=");return P>0?[[Q.slice(0,P),Q.slice(P+1)]]:[]})))}catch{return{}}}var G0=new Set;async function u1(q,x,X){let Q=await v1(),P=/^:(\d+)(?:\.\d+)?$/.exec(Q.DISPLAY??"")?.[1];if(!P||`:${P}`===G8||Q.WAYLAND_DISPLAY||Q.XDG_SESSION_TYPE==="wayland")return null;let b={display:`:${P}`,xauthority:Q.XAUTHORITY??f(q,".Xauthority"),rfbSocket:f(x,`rfb-${P}.sock`)},J=`${b.display} ${b.xauthority}`;if(G0.has(J)||!await e({path:`/tmp/.X11-unix/X${P}`},!1))return null;let L={HOME:q,PATH:"/usr/local/bin:/usr/bin:/bin",DISPLAY:b.display,XAUTHORITY:b.xauthority};if(await M0(X,b,x,`x11vnc-${P}.log`,L))return{...b,sound:null};return G0.add(J),process.stderr.write(`Reason worker: your screen ${b.display} could not be served; using the virtual desktop
|
|
177
|
+
`),null}function c1(q,x){let X=`chromium --no-first-run --no-default-browser-check${process.geteuid?.()===0?" --no-sandbox":""} %U`,Q=Aq({root:q,display:x,screen:Xq,browserExec:X});for(let P of["","openbox","tint2","picom"])Qq(f(q,P));for(let[P,b]of Object.entries(Q.files))xq(f(q,P),b,{mode:384});for(let[P,b]of Object.entries(Gq))xq(f(q,`ara-${P}`),z1(b),{mode:384});return{root:q,openboxConfig:f(q,"openbox","rc.xml"),start:Q.start}}async function r1(q,x){let X=[`ROOT=${JSON.stringify(q.root)}`,...q.start,"openbox --reconfigure >/dev/null 2>&1 || true"].join(`
|
|
178
|
+
`);await new Promise((Q)=>{let P=w0("/bin/sh",["-c",X],{stdio:"ignore",env:{...x,PATH:"/usr/bin:/bin"}}),b=setTimeout(()=>{P.kill(),Q()},A8);P.once("error",()=>{clearTimeout(b),Q()}),P.once("exit",()=>{clearTimeout(b),Q()})})}async function O9(q,x={}){let X=x.now??Date.now,Q=g1(q.payload,X());if(q.signal.throwIfAborted(),!Q.video)throw new S("display_video_required","Reason desktops stream as video now; this request came without it.");let P=x.platform??process.platform;if(P!=="linux"&&P!=="darwin")throw new S("display_video_unsupported","This machine does not serve desktop video.");let b=Q.video,J=(x.video?.desktop??(P==="darwin"?async()=>X0:I1))();return await m1(q.signal,Q,x,X,(L)=>W0(L,{request:b,desktop:J,...Q.viewer?{viewer:Q.viewer}:{},viewerSameNetwork:Q.viewer_same_network===!0},x.video),(L)=>C8({type:"error",code:L}))}function m1(q,x,X,Q,P,b){let J=Q();return new Promise((L,Z)=>{let W=null,U=!1,C=!1,R,T,Y,A=!1,N=null,y=(V)=>{if(C)return;if(N)V=N;C=!0,clearTimeout(R),clearTimeout(T),q.removeEventListener("abort",K),Y?.close();try{W?.close(1000,"display_session_over")}catch{}if("error"in V){Z(V.error);return}L({reason:V.reason,...Y?.summary(),duration_ms:Math.max(0,Q()-J)})},F=()=>y({error:new S("display_relay_unavailable","Reason could not reach the desktop relay.")}),K=()=>{let V=q.reason;y({error:V instanceof S?V:new S("cancelled","Reason closed the desktop session.")})},$=()=>{if(!N||!W)return;let V=N.error;try{W.send(b(V instanceof S?V.code:"display_unavailable"))}catch{}y(N)};if(Y=P({get done(){return C||N!==null},get open(){return U&&!C&&N===null},get bufferedAmount(){return W?.bufferedAmount??0},send(V){if(C||N||!U||!W)return;try{W.send(V)}catch{y({reason:"relay_closed"})}},end:(V)=>{if(C||N)return;if(!("error"in V)){y(V);return}if(N=V,A&&U)$()}}),C){Y.close();return}if(q.aborted){K();return}q.addEventListener("abort",K,{once:!0}),R=setTimeout(()=>y({reason:"session_expired"}),Math.max(1,Date.parse(x.expires_at)-Q())),T=setTimeout(()=>y({reason:"viewer_absent"}),X.viewerWaitMs??$1);try{W=(X.connect??e8)(x.relay_url,(X.loadProxy??Z8)()?.url)}catch{F();return}W.binaryType="arraybuffer",W.onopen=()=>{if(C||!W)return;U=!0,Y?.opened()},W.onmessage=(V)=>{if(C)return;let g=V.data,v=g instanceof ArrayBuffer?new Uint8Array(g):ArrayBuffer.isView(g)?new Uint8Array(g.buffer,g.byteOffset,g.byteLength):null;if(!v||v.byteLength===0)return;if(clearTimeout(T),A=!0,N){$();return}Y?.received(v)},W.onclose=()=>{if(C)return;if(!U){F();return}y({reason:"relay_closed"})},W.onerror=()=>{if(C||U)return;F()}})}
|
|
179
|
+
export{U1 as $d,D0 as ae,D1 as be,T9 as ce,B9 as de,$8 as ee,PX as fe,NX as ge,i as he,R8 as ie,Q9 as je,U0 as ke,Vq as le,Hq as me,m as ne,HX as oe,fX as pe,gX as qe,E1 as re,G8 as se,g1 as te,h1 as ue,$9 as ve,Qq as we,I1 as xe,O9 as ye};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Qb as D}from"./vm-hands-entry-lite-qvrnx0vk.js";import{Gh as j}from"./vm-hands-entry-lite-ffg7rf02.js";import{statSync as i}from"fs";import{delimiter as n,join as t}from"path";function _(q,z=process.env.PATH??""){if(!q||q.includes("/")||q.includes("\x00"))return!1;return z.split(n).some((G)=>{if(!G)return!1;try{let Q=i(t(G,q));return Q.isFile()&&(Q.mode&73)!==0}catch{return!1}})}import{spawn as r,spawnSync as e}from"child_process";import{existsSync as k,mkdtempSync as E,readFileSync as O,readdirSync as o,realpathSync as qq,rmSync as b,statSync as zq}from"fs";import{platform as y,tmpdir as g}from"os";import{dirname as A,join as Z}from"path";import{fileURLToPath as Gq,pathToFileURL as T}from"url";var Hq=["bwrap","socat","rg"],Jq=2000,v=20000,Qq=3,P=4000,Vq=new Set([".git",".hg",".svn","node_modules"]),Wq=["runAsHostUid","sysrq-trigger"],Yq=Z(A(A(Gq(import.meta.url))),"packages/sandbox-runtime/src/index.ts"),h=!1;function fq(){h=!0}async function u(){let z=h?Z(A(qq(process.execPath)),"runtime","srt"):void 0;if(z&&process.platform==="linux"&&!k(Z(z,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(z){let J=O(Z(z,"sandbox-runtime.mjs"),"utf8");for(let Y of Wq)if(!J.includes(Y))throw Error(`packaged_sandbox_runtime_fork_missing:${Y}`)}let H=(await import(z?T(Z(z,"sandbox-runtime.mjs")).href:T(Yq).href)).SandboxManager;if(!H||typeof H.initialize!=="function"||typeof H.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:H}}function Zq(q={}){if((q.platformName??y())!=="linux")return!1;let G=q.fileExists??k,Q=q.readFile??((H)=>O(H,"utf8"));for(let H of["/.dockerenv","/run/.containerenv"])try{if(G(H))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(Q("/proc/1/cgroup"))}catch{return!1}}function l(q){return["/bin/true","/usr/bin/true"].find((z)=>q(z))??null}function $q(q,z){return q==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",z]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",z]}function jq(q,z){try{let G=e("bwrap",$q(q,z),{stdio:"ignore",timeout:Jq});return!G.error&&G.status===0}catch{return!1}}function Bq(q){let z=q.platformName??y();if(z!=="linux")return null;let G=q.hasExecutable??_;if(!Hq.every((V)=>G(V)))return null;let Q=q.fileExists??k,H=l(Q);if(!H)return null;let J=B??(q.containerized??Zq({platformName:z})?"weak":"strict");return(q.probeNamespaces??((V)=>jq(V,H)))(J)?J:null}var L=null,C=!1,K=null,S=null,f=null,B=null,F=null;function M(){throw I("sandbox_mode_conflict"),new j("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function xq(q){if(B!==null&&B!==q||C&&L!==null&&L!==q||F!==null&&F!==q)M();B=q}function I(q){K=q}function c(q){if(K)return!1;if(!C){if(L=Bq(q??{}),C=!0,L&&!q)d()}return L!==null}function Lq(){return c()?L:null}var U=null,w=0;function m(q){if(K)throw new j("sandbox_unavailable","Confined execution is unavailable in this worker process.");if(B&&q.sandboxMode&&B!==q.sandboxMode)M();let z=B??q.sandboxMode??Lq();if(!z)throw new j("sandbox_unavailable","Confined command execution is unavailable on this operating system.");if(F&&F!==z)M();return F=z,U??=(async()=>{let{SandboxManager:G}=await(q.loadSandboxRuntime??u)();return await G.initialize(Iq(z)),G})().catch((G)=>{throw U=null,I(`initialize_failed: ${String(G)}`),G instanceof j?G:new j("sandbox_unavailable","The confined execution sandbox failed to start.")}),U.then((G)=>{if(K)throw new j("sandbox_unavailable","Confined execution became unavailable during sandbox initialization.");return G})}async function Kq(){let q=U;if(U=null,!q)return;try{await(await q).reset()}catch{}}async function d(q={}){if(K)return!1;if(q.loadSandboxRuntime)return x(q.loadSandboxRuntime);if(!c())return!1;return S??=x(u),S}async function x(q){try{let{SandboxManager:z}=await q(),G=z.checkDependencies().errors;if(G.length>0)return I(`dependencies_missing: ${G.join(", ")}`),!1;return!K}catch(z){return I(`load_failed: ${String(z)}`),!1}}async function Rq(q={}){if(!q.loadSandboxRuntime&&!q.sandboxMode){if(!await d())return!1;return f??=R({}),f}return R(q)}async function R(q){let z;try{z=await m(q)}catch{return!1}let G=await Xq(z);if(!G)I("confined_command_failed");if(w===0)await Kq();return G}async function Xq(q){let z=l(k);if(!z)return!1;let G=E(Z(g(),"reason-device-probe-"));try{let{argv:Q}=await q.wrapWithSandboxArgv(a([z]),p(),{filesystem:s({root:G,allowWrite:!1,temporaryDirectory:G,protectedPaths:[]})},void 0,G),[H,...J]=Q;if(!H)return!1;return await Fq(H,J,G)}catch{return!1}finally{try{q.cleanupAfterCommand()}catch{}b(G,{recursive:!0,force:!0})}}function Fq(q,z,G,Q={}){return new Promise((H)=>{let J=!1,Y,V=(X)=>{if(J)return;J=!0,clearTimeout(Y),H(X)},W;try{W=(Q.spawnChild??r)(q,z,{cwd:G,env:{PATH:D,HOME:G,TMPDIR:G},stdio:"ignore"})}catch{V(!1);return}W.once("error",()=>V(!1));let $=(X,N)=>V(X===0&&N===null);if(W.once("exit",$),W.once("close",$),W.exitCode!==null||W.signalCode!==null)$(W.exitCode,W.signalCode);if(J)return;Y=setTimeout(()=>{V(!1);try{W.kill("SIGKILL")}catch{}},Math.min(Q.timeoutMs??v,v))})}function p(q=k){return["/bin/bash","/bin/sh"].find((z)=>q(z))??"/bin/sh"}function a(q){return q.map((z)=>`'${z.replaceAll("'","'\\''")}'`).join(" ")}function Uq(q,z,G=(Q)=>o(Q,{withFileTypes:!0}).filter((H)=>H.isDirectory()||H.isFile()).map((H)=>H.name)){let Q=[],H=[{path:q,depth:0}],J=0;while(H.length>0&&J<P){let Y=H.pop(),V;try{V=G(Y.path)}catch{continue}for(let W of V){if(J+=1,J>P)break;let $=Z(Y.path,W);if(z($)){Q.push($);continue}if(Y.depth+1<Qq&&!Vq.has(W))H.push({path:$,depth:Y.depth+1})}}return Q}function s(q){let z=Z(q.root,".git"),G=[];try{if(zq(z).isDirectory())G=[Z(z,"config"),Z(z,"hooks")]}catch{}return{denyRead:["/home","/root","/tmp","/tmp/.X11-unix",...q.protectedPaths],allowRead:[q.root,q.temporaryDirectory],allowWrite:[...q.allowWrite?[q.root]:[],q.temporaryDirectory],denyWrite:[...q.protectedPaths,...G]}}function Iq(q){return{network:{allowedDomains:[],deniedDomains:[]},filesystem:{denyRead:[],allowRead:[],allowWrite:[],denyWrite:[]},...q==="weak"?{enableWeakerNestedSandbox:!0}:{}}}function Dq(q){let z=q.createTemporaryDirectory??(()=>E(Z(g(),"reason-device-"))),G=q.removeTemporaryDirectory??((Q)=>b(Q,{recursive:!0,force:!0}));return async(Q,H,J)=>{let Y=await m(q),V=z();w+=1;try{let W;try{W=await Y.wrapWithSandboxArgv(a([Q,...H]),q.shell??p(),{filesystem:s({root:J.root,allowWrite:J.allowWrite,temporaryDirectory:V,protectedPaths:Uq(J.root,q.isProtectedPath)})},J.signal,J.cwd)}catch(N){throw N instanceof j?N:new j("sandbox_unavailable","The confined execution sandbox could not wrap the command.")}let[$,...X]=W.argv;if(!$)throw new j("sandbox_unavailable","The confined execution sandbox produced no command.");return await q.spawnCaptured($,X,{cwd:J.cwd,timeoutMs:J.timeoutMs,signal:J.signal,env:q.scrubEnvironment(J.root,V)})}finally{w-=1;try{Y.cleanupAfterCommand()}catch{}G(V)}}}
|
|
3
|
+
export{_ as Jb,fq as Kb,xq as Lb,c as Mb,Rq as Nb,p as Ob,Dq as Pb};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var j=Object.create;var{getPrototypeOf:k,defineProperty:f,getOwnPropertyNames:l}=Object;var m=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,s=(a,b,c)=>{var g=a!=null&&typeof a==="object";if(g){var h=b?o??=new WeakMap:p??=new WeakMap,i=h.get(a);if(i)return i}c=a!=null?j(k(a)):{};let d=b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c;for(let e of l(a))if(!m.call(d,e))f(d,e,{get:n.bind(a,e),enumerable:!0});if(g)h.set(a,d);return d};var t=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var q=(a)=>a;function r(a,b){this[a]=q.bind(null,b)}var u=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0,configurable:!0,set:r.bind(b,c)})};var v=import.meta.require;
|
|
3
|
+
export{s as Hh,t as Ih,u as Jh,v as Kh};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var U=".reason/workspace",T="workspace_base",W="sessions",y="workspace_layout",g=".reason/workspace/sessions",$=/^[0-9a-f]{8}$/;function C(b){if(!F(b))return!1;let j=".reason/workspace/sessions/";if(!b.startsWith(j))return!1;let q=b.slice(j.length).split("/");return q.length===2&&$.test(q[0])}var B=4096,G="workspaces/pi";function F(b){if(typeof b!=="string"||!b||b.length>B)return!1;if(b.startsWith("/")||b.includes("\x00")||b.includes("\\"))return!1;return b.split("/").every((j)=>j!==""&&j!=="."&&j!=="..")}function V(b){if(b.kind==="root"){if(b.path===void 0)return".";if(!F(b.path))throw Error("invalid_device_workspace_identity");return b.path}if(!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,159}$/.test(b.workspaceId)||b.workspaceId==="."||b.workspaceId==="..")throw Error("invalid_device_workspace_identity");let j=b.layout==="sessions"?"sessions":G;return`${b.base?`${b.base}/`:""}${j}/${b.workspaceId}/repo`}function P(b){if(!b||typeof b!=="object"||Array.isArray(b))return null;let j=b;if(j.kind==="root"&&Object.keys(j).length===1)return{kind:"root"};if(j.kind==="root"&&Object.keys(j).length===2&&F(j.path))return{kind:"root",path:j.path};if(j.kind!=="managed"||typeof j.workspaceId!=="string"||Object.keys(j).length!==2+(j.base===void 0?0:1)+(j.layout===void 0?0:1)||j.base!==void 0&&j.base!==".reason/workspace"||j.layout!==void 0&&j.layout!=="sessions")return null;let q={kind:"managed",workspaceId:j.workspaceId,...j.base===".reason/workspace"?{base:".reason/workspace"}:{},...j.layout==="sessions"?{layout:"sessions"}:{}};try{return V(q),q}catch{return null}}var X="/home/runner",x="/run/reason/sessions",f=/^(?:\/[A-Za-z0-9._-]+)+$/,M=/-sidechat-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/,K=/^(.+)-repository-[a-z0-9][a-z0-9._-]*-[0-9a-f]{12}$/;function Y(b){return M.exec(b)?.[1]??K.exec(b)?.[1]??b}var Z=/^((?:\/[A-Za-z0-9._-]+)+)\/\.reason\/workspace\/(workspaces\/pi|sessions)\/([^/]+)$/,A="*/.reason/workspace/workspaces/pi/*|*/.reason/workspace/sessions/*";function H(b,j=X,q="sessions"){if(!f.test(j)||j.split("/").some((Q)=>Q==="."||Q===".."))throw Error("invalid_cloud_payload_home");let J=`${j}/${V({kind:"managed",workspaceId:b,base:".reason/workspace",...q?{layout:q}:{}})}`,z=`${x}/${Y(b)}`;return{home:j,root:J.slice(0,-5),checkout:J,control:z,jobEnv:`${z}/job.env`,cloudAccess:`${z}/cloud-access`,logs:`${z}/logs`,pin:`${z}/ws`}}function N(b){return Z.exec(b.replace(/\/+$/,""))?.[2]==="sessions"?"sessions":null}function L(b){return{kind:"managed",workspaceId:b,layout:"sessions"}}function D(b){let j=Z.exec(b.replace(/\/+$/,""));if(!j)return null;try{let q=H(j[3],j[1],N(b));return q.root===b.replace(/\/+$/,"")?q:null}catch{return null}}
|
|
3
|
+
export{U as ah,T as bh,W as ch,y as dh,g as eh,$ as fh,C as gh,F as hh,V as ih,P as jh,X as kh,x as lh,M as mh,K as nh,Z as oh,A as ph,H as qh,N as rh,L as sh,D as th};
|